/** dac management front-end*/ #include #include #include #include #include #include "phal_hw_api.h" #include "hwapi_backd.h" #include "dac_api.h" int semid,semidx; struct dac_interface *my_dac; int tstampcnt=0; void syncTslot (); /** this function is called every dac interrupt. it encompasses the system time slot * and synchronizes local time reference. */ void syncTslot () { post_sem_n(semid,semidx); time_t time; tstamp_to_time(tstampcnt++,&time); set_time(&time); } int configure_dac (struct dac_cfg *dac, int sid, int sidx) { int n; int freq; semid=sid; semidx=sidx; my_dac=dac->ptr; if ((n=my_dac->readcfg(dac->filename,&dac->NsamplesIn,&dac->NsamplesOut))<0) { printf("Error reading dac config. Errno=%d\n",n); return 0; } if ((n=my_dac->init(&dac->ts_len,dac->dacinbuff,dac->dacoutbuff,syncTslot))<0) { printf("Error configuring dac. Errno=%d\n",n); return 0; } return 1; } void close_dac() { my_dac->close(); }