Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "rp.h" // /RedPitaya/rp-api/api/include/redpitaya
#include "rp_hw-profiles.h" // /RedPitaya/rp-api/api-hw-profiles/include
int main(int argc, char **argv){
if(rp_Init() != RP_OK){
fprintf(stderr, "RP API initialization failed.\n");
}
uint32_t buff_size = 256;
float *buff_ch1 = (float *)malloc(buff_size * sizeof(float));
rp_AcqReset();
rp_AcqSetDecimation(RP_DEC_8);
rp_AcqSetTriggerDelay(0);
rp_AcqSetGain(0, RP_HIGH);
rp_AcqSetTriggerLevel(RP_CH_1, 0.0);
rp_AcqStart();
sleep(0.000002);
rp_AcqSetTriggerSrc(RP_TRIG_SRC_CHA_PE);
rp_acq_trig_state_t state = RP_TRIG_STATE_TRIGGERED;
while(1){
rp_AcqGetTriggerState(&state);
if(state == RP_TRIG_STATE_TRIGGERED){
break;
}
}
bool fillstate = false;
while(!fillstate){
rp_AcqGetBufferFillState(&fillstate);
}
/* Get write pointer where trigger was met. */
uint32_t pos = 0;
rp_AcqGetWritePointerAtTrig(&pos);
/* Get buffer data from channels A, B, and C */
buffers_t b;
b.size = buff_size;
b.ch_f[0] = buff_ch1;
rp_AcqGetDataV2(pos, &b);
int i;
for(i = 1; i < buff_size; i++){
printf("%f\n",buff_ch1[i]);
}
free(buff_ch1);
rp_Release();
return 0;
}