/******************************************************************************* * Private functions ******************************************************************************/ static int console_tty_open(char* dev_path) { int tmp_file_fd; struct termios t; LOG_printf(LOG_LVL_WARNING, "Try to open console on device %s\n", dev_path); tmp_file_fd = open (dev_path, O_RDWR | O_NONBLOCK); if (tmp_file_fd < 0) { LOG_printf(LOG_LVL_WARNING, "Can't open device %s. Errno %d\n", dev_path, errno); return -1; } /* Get current attributes */ tcgetattr(tmp_file_fd, &t); /* Set raw mode */ cfmakeraw(&t); /* Set Baudrate */ cfsetospeed(&t, B19200); cfsetispeed(&t, B19200); /* Flush IO */ tcflush(tmp_file_fd, TCIOFLUSH); /* Apply changes */ tcsetattr(tmp_file_fd, TCSANOW, &t); return tmp_file_fd; }
main() { LOG_printf(&myLog, "main begin"); /*DSK6713_LED_toggle(0); DSK6713_LED_toggle(1); DSK6713_LED_toggle(2); DSK6713_LED_toggle(3);*/ hMcbsp = 0; CSL_init(); /* Configure McBSP0 and AIC23 */ Config_DSK6713_AIC23(); /* Configure McBSP1*/ hMcbsp = MCBSP_open(MCBSP_DEV1, MCBSP_OPEN_RESET); MCBSP_config(hMcbsp, &datainterface_config); /* configure EDMA */ config_EDMA(); /* finally the interrupts */ config_interrupts(); //MCBSP_start(hMcbsp, RRST, 0xffffffff); // EIGEN!!!: Start Field: Recieve MCBSP_start(hMcbsp, MCBSP_RCV_START | MCBSP_XMIT_START | MCBSP_SRGR_START | MCBSP_SRGR_FRAMESYNC, 220); // EIGEN!!!: Start Field: Recieve // Es gibt auch noch MCBSP_SRGR_START (start sample Rate Generator) und MCBSP_SRGR_FRAMESYNC (start frame sync. generation) MCBSP_write(hMcbsp, 0x0); /* one shot */ LOG_printf(&myLog, "main end"); //DSK6713_LED_toggle(2); } /* finished*/
/** * \brief CSL Audio Class main function * * \param None * * \return None */ void main(void) { CSL_Status status; Uint32 gpioIoDir; // Disable trace to reduce MHz load //TRC_disable(TRC_GBLTARG); /* Clock gate all peripherals */ CSL_SYSCTRL_REGS->PCGCR1 = 0x7FFF; CSL_SYSCTRL_REGS->PCGCR2 = 0x007F; #if defined(USE_I2S0_PB) || defined(USE_I2S0_REC) /* SP0 Mode 1 (I2S0 and GP[5:4]) */ CSL_FINST(CSL_SYSCTRL_REGS->EBSR, SYS_EBSR_SP0MODE, MODE1); #else /* SP0 Mode 2 (GP[5:0]) -- GPIO02/GPIO04 for debug */ CSL_FINST(CSL_SYSCTRL_REGS->EBSR, SYS_EBSR_SP0MODE, MODE2); #endif #if defined(USE_I2S1_PB) || defined(USE_I2S1_REC) /* SP1 Mode 1 (I2S1 and GP[11:10]) */ CSL_FINST(CSL_SYSCTRL_REGS->EBSR, SYS_EBSR_SP1MODE, MODE1); #else /* SP1 Mode 2 (GP[11:6]) */ CSL_FINST(CSL_SYSCTRL_REGS->EBSR, SYS_EBSR_SP1MODE, MODE2); /* need GPIO10 for AIC3204 reset */ #endif /* PP Mode 1 (SPI, GPIO[17:12], UART, and I2S2) -- note this allows UART */ CSL_FINST(CSL_SYSCTRL_REGS->EBSR, SYS_EBSR_PPMODE, MODE1); /* Reset C5515 -- ungates all peripherals */ C5515_reset(); /* Initialize DSP PLL */ status = pll_sample(); if (status != CSL_SOK) { LOG_printf(&trace, "ERROR: Unable to initialize PLL"); } /* Clear pending timer interrupts */ CSL_SYSCTRL_REGS->TIAFR = 0x7; #if !defined(USE_I2S0_PB) && !defined(USE_I2S0_REC) /* GPIO02 and GPIO04 for debug */ /* GPIO10 for AIC3204 reset */ gpioIoDir = (((Uint32)CSL_GPIO_DIR_OUTPUT)<<CSL_GPIO_PIN2) | (((Uint32)CSL_GPIO_DIR_OUTPUT)<<CSL_GPIO_PIN4) | (((Uint32)CSL_GPIO_DIR_OUTPUT)<<CSL_GPIO_PIN10); #else /* GPIO10 for AIC3204 reset */ gpioIoDir = (((Uint32)CSL_GPIO_DIR_OUTPUT)<<CSL_GPIO_PIN10) #endif status = gpioInit(gpioIoDir, 0x00000000, 0x00000000); if (status != GPIOCTRL_SOK) { LOG_printf(&trace, "ERROR: Unable to initialize GPIO"); } /* Enable the USB LDO */ *(volatile ioport unsigned int *)(0x7004) |= 0x0001; }
/* Reconfigures codec in response to USB message */ void CodecConfigTask(void) { CodecCfgMsgObj codecCfgMsg; Int16 *pData; while (1) { //TSK_settime(TSK_self()); // statistic collection if (MBX_pend(&MBX_codecConfig, &codecCfgMsg, SYS_FOREVER)) { switch (codecCfgMsg.wMsg) { case CODEC_CFG_MSG_ADJ_VOL_L: pData = (Int16 *)codecCfgMsg.wData; Adjust_Volume(*pData, 0); break; case CODEC_CFG_MSG_ADJ_VOL_R: pData = (Int16 *)codecCfgMsg.wData; Adjust_Volume(*pData, 1); break; case CODEC_CFG_MSG_ADJ_MUTE: pData = (Int16 *)codecCfgMsg.wData; if ((*pData & 0xff) == 0) { // un-mute //STS_set(&mySts1, CLK_gethtime()); if(Set_Mute_State(FALSE) == FALSE) { LOG_printf(&trace, "FAILED MUTE CLEAR\n"); } //STS_delta(&mySts1, CLK_gethtime()); //TSK_deltatime(TSK_self()); // statistic collection break; } else if ((*pData & 0xff) == 1) { // mute //STS_set(&mySts1, CLK_gethtime()); if(Set_Mute_State(TRUE) == FALSE) { LOG_printf(&trace, "FAILED MUTE SET\n"); } //STS_delta(&mySts1, CLK_gethtime()); //TSK_deltatime(TSK_self()); // statistic collection } break; default: break; } } } }
int loadso (void) { void *hdl, *func; /* load libmemmgr.s.so */ LOG_printf("calling dl_open at %08lx\n", (l4_addr_t)dlopen); hdl = dlopen("libmemmgr.s.so", 2); LOG_printf("handle libmemmgr=%08lx\n", (l4_addr_t)hdl); init_memmgr = dlsym(hdl, "init_memmgr"); LOG_printf("init_memmgr=%08lx\n", (l4_addr_t)init_memmgr); seek_free_mem = dlsym(hdl, "seek_free_mem"); LOG_printf("seek_free_mem=%08lx\n", (l4_addr_t)seek_free_mem); is_mem_used = dlsym(hdl, "is_mem_used"); LOG_printf("is_mem_used=%08lx\n", (l4_addr_t)is_mem_used); alloc_mem_area = dlsym(hdl, "alloc_mem_area"); LOG_printf("alloc_mem_area=%08lx\n", (l4_addr_t)alloc_mem_area); dealloc_mem_area = dlsym(hdl, "dealloc_mem_area"); LOG_printf("dealloc_mem_area=%08lx\n", (l4_addr_t)dealloc_mem_area); print_used_mem = dlsym(hdl, "print_used_mem"); LOG_printf("print_used_mem=%08lx\n", (l4_addr_t)print_used_mem); return 0; }
static int console_tty_probe(char* dev_path, int autodetect) { int tmp_file_fd, wakeup_result; char tmp_dev_path[MAX_DEV_PATH_LEN]; int devno = 0; if (autodetect) { for (devno=0; devno<10; devno++) { snprintf(tmp_dev_path, MAX_DEV_PATH_LEN, "%s%d", dev_path, devno); LOG_printf(LOG_LVL_INFO, "Look-up for console on device %s\n", tmp_dev_path); tmp_file_fd = console_tty_open(tmp_dev_path); if (tmp_file_fd != -1) { wakeup_result = console_wakeup(tmp_file_fd); if (wakeup_result == 1) { LOG_printf(LOG_LVL_INFO, "Found console on device %s\n", tmp_dev_path); break; } else { close(tmp_file_fd); tmp_file_fd = -1; } } } } else { tmp_file_fd = console_tty_open(dev_path); if (tmp_file_fd != -1) { wakeup_result = console_wakeup(tmp_file_fd); if (wakeup_result == 1) { return tmp_file_fd; } else { close(tmp_file_fd); tmp_file_fd = -1; } } } return tmp_file_fd; }
void config_interrupts(void) { LOG_printf(&myLog, "config interrupts begin"); //Wie muss das mapping genau stattfinden? // McBSP --> EDMA ? // EDMA --> CPU ? // IRQ_globalDisable(); IRQ_map(IRQ_EVT_EDMAINT, 8); // EIGEN!!!: Ist hier 8 richtig? IRQ_clear(IRQ_EVT_EDMAINT); // EIGEN!!!: IRQ_enable(IRQ_EVT_EDMAINT); // EIGEN!!!: IRQ_globalEnable(); LOG_printf(&myLog, "config interrupts end"); }
VOID GSML1Mgr_SendCommand(GSML1Mgr *pThis, Packet *pPacket) { CmdPkt oCmdPkt; CmdPkt_Parse(&oCmdPkt, pPacket); LOG_printf(&trace, "GSML1Mgr: Sent Cmd/Response = %d", CmdPkt_GetCommand(&oCmdPkt)); ITaskQ_Write(&pThis->oTxFPGACommandQ, pPacket); }
/* * process the data received from the USB - called by SWI_Process_USB_Input ***********************************************************************/ void process_usb_input(void) { pAcClassHandle pAcClassHdl; CSL_AcObject *pAcHandle; pUsbEpHandle hUsbOutEp; CSL_Status status; pAcClassHdl = AC_AppHandle.pAcObj; pAcHandle = &pAcClassHdl->acHandle; hUsbOutEp = &pAcHandle->isoOutEpObj; if(active_sample_rate == ACTIVE_SAMPLE_RATE_16KHZ) { // playback 16KHz USB data status = pAcHandle->playAudio(rx_pkt_size_16K_playback/2, &pAcHandle->lbaBufferPb[0], &pAcHandle->lbaBufferPb[0], (void*)(&pAcHandle->playBackActive)); } else { // playback 48KHz USB data status = pAcHandle->playAudio(hUsbOutEp->maxPktSiz/2, &pAcHandle->lbaBufferPb[0], &pAcHandle->lbaBufferPb[0], (void*)(&pAcHandle->playBackActive)); } if(status != CSL_AC_MEDIACCESS_SUCCESS) { LOG_printf(&trace, "ERROR: process_usb_input() failed:\n"); } }
void csl_i2c_test(void) { CSL_Status result; LOG_printf(&trace, "I2C test:"); result = CSL_i2cPolledTest(); if(result == CSL_I2C_TEST_PASSED) { LOG_printf(&trace, "I2C test passed"); } else { LOG_printf(&trace, "I2C test FAILED!!"); } }
void l4x_exit_thread(void) { #ifndef CONFIG_L4_VCPU int i; if (unlikely(current->thread.is_hybrid)) { l4_cap_idx_t hybgate; l4_msgtag_t tag; l4_umword_t o = 0; hybgate = L4LX_KERN_CAP_HYBRID_BASE + (current->pid << L4_CAP_SHIFT); tag = l4_ipc_gate_get_infos(hybgate, &o); if (l4_error(tag)) printk("hybrid: Could not get gate info, leaking mem.\n"); else kfree((void *)o); tag = l4_task_unmap(L4_BASE_TASK_CAP, l4_obj_fpage(hybgate, 0, L4_FPAGE_RWX), L4_FP_ALL_SPACES); if (l4_error(tag)) printk("hybrid: Delete of gate failed.\n"); } for (i = 0; i < NR_CPUS; i++) { l4_cap_idx_t thread_id = current->thread.user_thread_ids[i]; /* check if we were a non-user thread (i.e., have no user-space partner) */ if (unlikely(l4_is_invalid_cap(thread_id) || !thread_id)) continue; #ifdef DEBUG LOG_printf("exit_thread: trying to delete %s(%d, " PRINTF_L4TASK_FORM ")\n", current->comm, current->pid, PRINTF_L4TASK_ARG(thread_id)); #endif /* If task_delete fails we don't free the task number so that it * won't be used again. */ if (likely(!l4lx_task_delete_thread(thread_id))) { l4x_hybrid_remove(current); current->thread.user_thread_ids[i] = L4_INVALID_CAP; l4lx_task_number_free(thread_id); current->thread.started = 0; } else printk("%s: failed to delete task " PRINTF_L4TASK_FORM "\n", __func__, PRINTF_L4TASK_ARG(thread_id)); } #endif #ifdef CONFIG_X86_DS ds_exit_thread(current); #endif }
static void console_reader_thread_stop(vantage_console_context_t *vantage_console_priv) { if (loglevel > 0) { LOG_printf(LOG_LVL_INFO, "TTY Reader thread stop request\n"); } vantage_console_priv->tty_thread_stop_req = 1; }
/******************************************************************************* * Public functions ******************************************************************************/ int VTG_console_init(char* dev_path, int use_usb_serial, VTG_DataReadyIndicateCb_t DataReadyIndicateCb) { struct itimerspec timer_new_value; vantage_console_priv.use_usb_serial = use_usb_serial; strncpy(vantage_console_priv.console_dev_path, dev_path, MAX_DEV_PATH_LEN); int tty_fd = console_tty_probe(dev_path, use_usb_serial); if (tty_fd < 0) { return -1; } vantage_console_priv.console_tty_fd = tty_fd; vantage_console_priv.DataReadyIndicateCb = DataReadyIndicateCb; console_wakeup(vantage_console_priv.console_tty_fd); vantage_console_priv.timer_fd = timerfd_create(CLOCK_REALTIME, TFD_NONBLOCK); if (vantage_console_priv.timer_fd == -1) { LOG_printf(LOG_LVL_ERROR, "Error creating timer fd\n"); return -1; } vantage_console_priv.tty_thread_stop_req = 0; pthread_create(&(vantage_console_priv.tty_reader_thread), NULL, &console_reader_thread, &vantage_console_priv); timer_new_value.it_interval.tv_sec = VANTAGE_PERIODIC_WEATHER_DATA_QUERY_IN_S; timer_new_value.it_interval.tv_nsec = 0; timer_new_value.it_value.tv_sec = 1; timer_new_value.it_value.tv_nsec = 0; if (timerfd_settime(vantage_console_priv.timer_fd, 0, &timer_new_value, NULL) == -1) { LOG_printf(LOG_LVL_ERROR, "%s: timerfd_settime error (%d)\n", __FUNCTION__, errno); return -1; } return 0; }
void i2sTxStart(void) { Uint16 status; status = i2sPlayAudio(i2sHandleTx, (Uint32*)i2sNextTxLeftBuf, (Uint32*)i2sNextTxRightBuf); if(status != 0) { LOG_printf(&trace, "I2S Tx Failed\n"); } }
static int local_web_update_data_section(int fd_out, struct WeatherDataHead_s* WeatherDataHead) { char *file_data = NULL, *dates_content = NULL, *data_content_1 = NULL, *data_content_2 = NULL, *data_content_3 = NULL; int records_count, ret = 0, n, dates_len, file_data_size; weather_data_entry_t *tmp; weather_data_t *weather_data; if (loglevel > 1) { LOG_printf(LOG_LVL_DEBUG, "+%s\n", __FUNCTION__); } LOCAL_WEB_UPDATE_BUFFER_MALLOC(dates_content, DATE_CONTENT_BUFFER_SIZE); LOCAL_WEB_UPDATE_BUFFER_MALLOC(data_content_1, DATA_CONTENT_BUFFER_SIZE); LOCAL_WEB_UPDATE_BUFFER_MALLOC(data_content_2, DATA_CONTENT_BUFFER_SIZE); LOCAL_WEB_UPDATE_BUFFER_MALLOC(data_content_3, DATA_CONTENT_BUFFER_SIZE); /* Allocate a temporary buffer which will be used to store datas to be written * to the output file. * Use the size of the dates and data contents for the buffer allocation size. */ file_data_size = DATE_CONTENT_BUFFER_SIZE + (DATA_CONTENT_BUFFER_SIZE * 3) + 200; file_data = malloc(file_data_size); if (file_data == NULL) { perror("malloc"); ret = -1; goto local_web_update_data_section_exit; } memset(file_data, '\0', file_data_size); /* Create dates strings */ records_count = 0; dates_len = 0; TAILQ_FOREACH(tmp, WeatherDataHead, ListEntry) { weather_data = &tmp->weather_data_average; dates_len += snprintf(dates_content + dates_len, DATE_CONTENT_BUFFER_SIZE - dates_len, "\"%04d-%02d-%02d %02d:%02d:%02d\",", weather_data->tm.tm_year + 1900, weather_data->tm.tm_mon + 1, weather_data->tm.tm_mday, weather_data->tm.tm_hour, weather_data->tm.tm_min, weather_data->tm.tm_sec); records_count++; }
VOID GSML1Mgr_DoCommandProcessing( GSML1Mgr *pThis, Packet *pRxPacket ) { CommandType eCommand; UINT8 nRxMgr = 255, nTxMgr = 255; CmdPkt oCmdPkt; CmdPkt_Parse(&oCmdPkt, pRxPacket); eCommand = CmdPkt_GetCommand(&oCmdPkt); LOG_printf(&trace, "GSML1Mgr: RxMgr[%d] Received Cmd = %d", oCmdPkt.pPacket->nRxMgr, eCommand); switch( eCommand ) { case IPU_TO_DSP_SCAN_BEACON_FREQ : case IPU_TO_DSP_CONFIGURE_RECEIVER : case IPU_TO_DSP_CONFIGURE_VBTS_MODE : case IPU_TO_DSP_SET_TSC_FOR_RECEIVER : case IPU_TO_DSP_SET_TSC_FOR_VBTS_MODE : case IPU_TO_DSP_STOP_RECEIVER : case IPU_TO_DSP_STOP_VBTS_MODE : case IPU_TO_DSP_STOP_SCANNING_ARFCN: case DSP_TO_FPGA_RX_TUNE: case IPU_TO_DSP_STOP_SCANING_BAND: nRxMgr = oCmdPkt.pPacket->nRxMgr; RxMgr_DoCommandProcessing( &pThis->oRxMgr[nRxMgr], &oCmdPkt); // TODO break; case IPU_TO_DSP_CONFIGURE_TRANSMITTER : case IPU_TO_DSP_CONFIG_AREA_JAMMING : case IPU_TO_DSP_SET_TSC_FOR_TRANSMITTER : case IPU_TO_DSP_STOP_TRANSMITTER: case IPU_TO_DSP_STOP_AREA_JAMMING: case DSP_TO_FPGA_TX_TUNE: nTxMgr = oCmdPkt.pPacket->nTxMgr; TxMgr_DoCommandProcessing( &pThis->oTxMgr[nTxMgr], &oCmdPkt); // TODO break; default: // SEND ERROR BACK TO SENDER.. // COMMAND IS NOT EXPECTED HERE break; } }
int load_ixfs (void) { void *hdl, *identify, *load, *fixup; IXFHandler *handler, *last; void *rc; rc = get_ixf_handler("lx", &handler); if (!rc) return 1; LOG_printf("Identify=%x, Load=%x, Fixup=%x\n", handler->Identify, handler->Load, handler->Fixup); IXFHandlers = handler; rc = get_ixf_handler("ne", &handler->next); if (!rc) return 1; LOG_printf("Identify=%x, Load=%x, Fixup=%x\n", handler->next->Identify, handler->next->Load, handler->next->Fixup); return 0; }
/** * \brief Void main(Void) * * Main function of the sample application. This function enables * the mcasp instance in the power sleep controller and also * enables the pinmux for the mcasp 1 instance. * * \param None * \return None */ Void main(Void) { printf("Main entered.\n"); LOG_printf(&trace,"\r\nAudio Sample Main\n"); /* enable the pinmux for the mcasp device */ configureAudio(); printf("Config done.\n"); return; }
static void usage(void) { LOG_printf( "usage: fer_l4lx_vtm [-q|-Q]" " [-d val]\n" "\n" " -q,--quiet ... Be quiet and do not disturb the system with\n" " long output (also no trace output). Useful\n" " for longer running overhead measurements.\n" " -Q,--Quiet ... Be really QUIET and do not disturb the system with\n" " any output at runtime (also no trace output). \n" " Useful for longer running overhead measurements.\n" ); }
/** * \brief Call back function for DMA left channel receive complete * * This function will be called when DMA receive completes * This function changes the destination address of the DMA channel and * restarts the DMA transfer. * * \param dmaStatus [IN] Status of the DMA transfer * \param dataCallback [IN] I2S handle * * \return void * */ void I2S_DmaRxLChCallBack( PSP_DMATransferStatus dmaStatus, void *dataCallback ) { Uint16 *ptrRxLeft; Uint16 i; #ifdef ENABLE_RECORD if ((dataCallback != NULL) && (dmaStatus == PSP_DMA_TRANSFER_COMPLETE)) { /* Get pointer to ping/pong buffer */ ptrRxLeft = &my_i2sRxLeftBuf[0]; if (left_rx_buf_sel == 0x1) /* check ping or pong buffer */ { /* this buffer has data to be processed */ ptrRxLeft += DMA_TARNSFER_SZ; } left_rx_buf_sel ^= 0x1; /* update ping/pong */ // copy data to the /*if(SEM_count(&SEM_BufferFull) > PROCESS_BUFFER_SIZE/DMA_TARNSFER_SZ){ return; }*/ for (i = 0; i < DMA_BUFFER_SZ; i++) { // NOTE: since we need datapack to be disabled on I2S tx, we need it disabled on I2S rx therefore // we get 2 words per DMA transfer so the offset into DMA buffers has to be twice as big recInLeftBuf = *ptrRxLeft; ptrRxLeft += 2; circular_buffer_put(recInLeftBuf); /*bufferIn[bufferInIdx] = (recInLeftBuf & 0xFF); bufferInIdx = (bufferInIdx+1) % PROCESS_BUFFER_SIZE; bufferIn[bufferInIdx] = ((recInLeftBuf >> 8) & 0xFF); bufferInIdx = (bufferInIdx+1) % PROCESS_BUFFER_SIZE; */ } SEM_post(&SEM_BufferFull); //LOG_printf(&trace, "IN log %ld\n",bufferInIdx); } else { #ifdef DEBUG_LOG_PRINT LOG_printf(&trace, "Left RX DMA Failed"); #endif } #endif // ENABLE_RECORD }
/** * \brief Call back function for DMA transmit complete * * This function will be called when DMA transmit completes. * This function changes the source address of the DMA channel and * restarts the DMA transfer. * * \param dmaStatus [IN] Status of the DMA transfer * \param dataCallback [IN] I2S handle * * \return void * */ void I2S_DmaTxRChCallBack( PSP_DMATransferStatus dmaStatus, void *dataCallback ) { if ((dataCallback != NULL) && (dmaStatus == PSP_DMA_TRANSFER_COMPLETE)) { SEM_post(&SEM_PingPongTxRightComplete); } else { #ifdef DEBUG_LOG_PRINT LOG_printf(&trace, "Right TX DMA Failed"); #endif } }
/* * interrupt routine to test input from I2S on a SampleBySample basis ***********************************************************************/ void i2s_rxIsr(void) /* dispatcher used */ //interrupt void i2s_rxIsr(void) /* no dispatcher used */ { /* SampleBySample */ #ifdef SAMPLE_BY_SAMPLE_REC static Uint16 sample_cnt = 0; //if (set_record_interface >= START_REC_WAIT_NUM_FRAMES) //if (h_usb_int_tcount > 1) /* wait for IN tokens from Host */ { /* Get sample from I2S input, place in input circular buffer */ codec_input_buffer[codec_input_buffer_input_index] = *(ioport volatile unsigned *)I2S2_I2SRXLT1; // instead of changing codec sample rate to 16KHz, get same input sample 3 times (when codec is set to 48KHz) if (sample_cnt >= 2) { codec_input_buffer_input_index++; if (codec_input_buffer_input_index >= CODEC_INPUT_BUFFER_SIZE) { codec_input_buffer_input_index = 0; SEM_post(&SEM_DmaRxLeftComplete); } codec_input_sample_count++; // check for overflow if (codec_input_sample_count > CODEC_INPUT_BUFFER_SIZE) { codec_input_buffer_overflow++; //LOG_printf(&trace, "ERROR: codec_input_buffer_overflow: %d", codec_input_buffer_overflow); LOG_printf(&trace, "ERROR: codec input buffer OVERFLOW: %d", codec_input_sample_count); } } } if ((set_record_interface >= 2) && (++sample_cnt >= 3)) { #ifdef COUNT_REC_SAMPS_IN_USB_FRAME_REC i2sRxSampCnt++; #endif sample_cnt = 0; } #endif /* SAMPLE_BY_SAMPLE_REC */ }
/** ============================================================================ * @func main * * @desc Entry function. * * @modif None * ============================================================================ */ Void main(Int argc, Char* argv []) { /* Task handler for TSK_create */ TSK_Handle tskMessageTask; #if !defined (DSP_BOOTMODE_NOBOOT) /* Get the number of transfers to be done by the application */ numTransfers = atoi(argv [0]); /* Initialize DSP/BIOS LINK. */ DSPLINK_init(); #endif /* Creating task for TSKMESSAGE application */ tskMessageTask = TSK_create(tskMessage, NULL, 0); if (tskMessageTask == NULL) { SET_FAILURE_REASON(SYS_EALLOC); LOG_printf(&trace, "Create TSKMESSAGE: Failed.\n"); } }
void * get_ixf_handler(char *fmtname, IXFHandler **handler) { char lib[0x40]; void *hdl; strcpy(lib, fmtname); strcat(lib, ".ixf"); hdl = dlopen(lib, 2); if (!hdl) return 0; LOG_printf("handle %s=%08lx\n", lib, (l4_addr_t)hdl); (*handler) = (IXFHandler *)malloc(sizeof(IXFHandler)); // todo: release! (*handler)->Identify = getsym(hdl, fmtname, "Identify"); (*handler)->Load = getsym(hdl, fmtname, "Load"); (*handler)->Fixup = getsym(hdl, fmtname, "Fixup"); (*handler)->next = 0; return hdl; }
/* Perform Playback (Tx) audio algorithm processing */ void PbAudioAlgTsk(void) { Int16 status; Int16 *pbOutBuf; Uint16 tempInBlk; while (1) { SEM_pend(&SEM_PbAudioAlg, SYS_FOREVER); /* Select AER output buffer */ HWI_disable(); pbOutBuf = ping_pong_i2sTxBuf + (!tx_buf_sel)*i2sTxBuffSz; HWI_enable(); if ((usb_play_mode == TRUE) && (rdy_to_consume_asrc_output == TRUE)) { /* Combine ASRC output */ SWI_disable(); tempInBlk = asrcOutputFifoInBlk; SWI_enable(); status = combineAsrcOutput(asrcOutputFifo, asrcOutputFifoBlkNumSamps, tempInBlk, &asrcOutputFifoOutBlk, &asrcOutputFifoOutBlkSampCnt, ASRC_NUM_CH_STEREO, tempPbOutBuf, i2sTxBuffSz>>1); if (status == CMBASRC_FIFO_UND) { asrcOutputFifoOutError++; LOG_printf(&trace, "ERROR: ASRC output FIFO UNDERFLOW"); //LOG_printf(&trace, "%04x %d", (asrcOutputFifoInBlk<<8) | asrcOutputFifoOutBlk, asrcOutputFifoOutBlkSampCnt); // debug } } else if (usb_play_mode == TRUE)
void config_EDMA(void) { LOG_printf(&myLog, "config EDMA begin"); // EIGEN!!!: Konfiguration Recieve Ping /* Konfiguration der EDMA zum Lesen*/ hEdmaRcv = EDMA_open(EDMA_CHA_REVT1, EDMA_OPEN_RESET); // EDMA Channel for REVT1 hEdmaReloadRcvPing = EDMA_allocTable(-1); // Reload-Parameters Ping hEdmaReloadRcvPong = EDMA_allocTable(-1); // Reload-Parameters Pong 2 Param Sets needed (Ping & Pong) -> Pong write on my own hEdmaReloadRcvPeng = EDMA_allocTable(-1); // Reload-Parameters Peng configEDMARcv.src = MCBSP_getRcvAddr(hMcbsp); // source addr //Recieve Ping tccRcvPing = EDMA_intAlloc(-1); // next available TCC configEDMARcv.opt |= EDMA_FMK(OPT,TCC,tccRcvPing); // Grundkonfiguration EDMA-channel configEDMARcv.dst = ((int)Buffer_in_ping)/* & 0xFFFF*/; // Zieladresse //configEDMARcv.dst = ((short)Buffer_in_ping)/* & 0xFFFF*/; // Zieladresse /* Erster Transfer und Reload-Ping */ EDMA_config(hEdmaRcv, &configEDMARcv); EDMA_config(hEdmaReloadRcvPing, &configEDMARcv); //Recieve Pong tccRcvPong = EDMA_intAlloc(-1); // next available TCC configEDMARcv.opt |= EDMA_FMK(OPT,TCC,tccRcvPong); // Grundkonfiguration EDMA-channel configEDMARcv.dst = ((int)Buffer_in_pong)/* & 0xFFFF*/; // Zieladresse //configEDMARcv.dst = ((short)Buffer_in_pong)/* & 0xFFFF*/; // Zieladresse /* Erster Transfer und Reload-Ping */ EDMA_config(hEdmaReloadRcvPong, &configEDMARcv); //Recieve Peng tccRcvPeng = EDMA_intAlloc(-1); // next available TCC configEDMARcv.opt |= EDMA_FMK(OPT,TCC,tccRcvPeng); // Grundkonfiguration EDMA-channel configEDMARcv.dst = ((int)Buffer_in_peng)/* & 0xFFFF*/; // Zieladresse //configEDMARcv.dst = ((short)Buffer_in_peng)/* & 0xFFFF*/; // Zieladresse /* Erster Transfer und Reload-Ping */ EDMA_config(hEdmaReloadRcvPeng, &configEDMARcv); /* link transfers ping -> pong -> peng -> ping */ EDMA_link(hEdmaRcv,hEdmaReloadRcvPong); EDMA_link(hEdmaReloadRcvPong,hEdmaReloadRcvPeng); EDMA_link(hEdmaReloadRcvPeng,hEdmaReloadRcvPing); EDMA_link(hEdmaReloadRcvPing,hEdmaReloadRcvPong); /* do you want to hear music? */ // Gleiche Konfiguration wie oben für Lesen muss nun für Schreiben angewendet werden hEdmaXmt = EDMA_open(EDMA_CHA_XEVT1, EDMA_OPEN_RESET); // EDMA Channel for REVT1 hEdmaReloadXmtPing = EDMA_allocTable(-1); // Reload-Parameters Ping hEdmaReloadXmtPong = EDMA_allocTable(-1); // Reload-Parameters Pong 2 Param Sets needed (Ping & Pong) -> Pong write on my own hEdmaReloadXmtPeng = EDMA_allocTable(-1); // Reload-Parameters Peng configEDMAXmt.dst = MCBSP_getXmtAddr(hMcbsp); // destination addr //Transmit Ping tccXmtPing = EDMA_intAlloc(-1); // next available TCC configEDMAXmt.opt |= EDMA_FMK(OPT,TCC,tccXmtPing); // Grundkonfiguration EDMA-channel configEDMAXmt.src = ((int)Buffer_out_ping)/* & 0xFFFF*/; // Quelladresse //configEDMAXmt.src = ((short)Buffer_out_ping)/* & 0xFFFF*/; // Quelladresse /* Erster Transfer und Reload-Ping */ EDMA_config(hEdmaXmt, &configEDMAXmt); EDMA_config(hEdmaReloadXmtPing, &configEDMAXmt); //Transmit Pong tccXmtPong = EDMA_intAlloc(-1); // next available TCC configEDMAXmt.opt |= EDMA_FMK(OPT,TCC,tccXmtPong); // Grundkonfiguration EDMA-channel configEDMAXmt.src = ((int)Buffer_out_pong)/* & 0xFFFF*/; // Quelladresse //configEDMAXmt.src = ((short)Buffer_out_pong)/* & 0xFFFF*/; // Quelladresse /* Erster Transfer und Reload-Ping */ EDMA_config(hEdmaReloadXmtPong, &configEDMAXmt); //Transmit Peng tccXmtPeng = EDMA_intAlloc(-1); // next available TCC configEDMAXmt.opt |= EDMA_FMK(OPT,TCC,tccXmtPeng); // Grundkonfiguration EDMA-channel configEDMAXmt.src = ((int)Buffer_out_peng)/* & 0xFFFF*/; // Quelladresse //configEDMAXmt.src = ((short)Buffer_out_peng)/* & 0xFFFF*/; // Quelladresse /* Erster Transfer und Reload-Ping */ EDMA_config(hEdmaReloadXmtPeng, &configEDMAXmt); /* link transfers ping -> pong -> ping */ EDMA_link(hEdmaXmt,hEdmaReloadXmtPong); EDMA_link(hEdmaReloadXmtPong,hEdmaReloadXmtPeng); EDMA_link(hEdmaReloadXmtPeng,hEdmaReloadXmtPing); EDMA_link(hEdmaReloadXmtPing,hEdmaReloadXmtPong); /* enable EDMA TCC */ //recieve ping EDMA_intClear(tccRcvPing); EDMA_intEnable(tccRcvPing); //recieve pong EDMA_intClear(tccRcvPong); EDMA_intEnable(tccRcvPong); //recieve peng EDMA_intClear(tccRcvPeng); EDMA_intEnable(tccRcvPeng); //transmit ping EDMA_intClear(tccXmtPing); EDMA_intEnable(tccXmtPing); //transmit pong EDMA_intClear(tccXmtPong); EDMA_intEnable(tccXmtPong); //transmit peng EDMA_intClear(tccXmtPeng); EDMA_intEnable(tccXmtPeng); /* which EDMAs do we have to enable? */ EDMA_enableChannel(hEdmaRcv); EDMA_enableChannel(hEdmaXmt); LOG_printf(&myLog, "config EDMA end"); }
/** * \brief Tests I2C polled mode operation * * \param none * * \return Test result */ CSL_Status CSL_i2cPolledTest(void) { CSL_Status status; CSL_Status result; Uint16 startStop; volatile Uint16 looper; volatile int i; result = CSL_I2C_TEST_FAILED; /* Initialize I2C module */ status = I2C_init(CSL_I2C0); if(status != CSL_SOK) { LOG_printf(&trace, "I2C Init Failed!!"); return(result); } /* Setup I2C module */ i2cSetup.addrMode = CSL_I2C_ADDR_7BIT; // EEPROM I2C device address is 7-bit (101.0xxx) i2cSetup.bitCount = CSL_I2C_BC_8BITS; // I2C bit count is 8-bit i2cSetup.loopBack = CSL_I2C_LOOPBACK_DISABLE; i2cSetup.freeMode = CSL_I2C_FREEMODE_DISABLE; i2cSetup.repeatMode = CSL_I2C_REPEATMODE_DISABLE; i2cSetup.ownAddr = CSL_I2C_OWN_ADDR; i2cSetup.sysInputClk = CSL_I2C_SYS_CLK; i2cSetup.i2cBusFreq = CSL_I2C_BUS_FREQ; startStop = ((CSL_I2C_START) | (CSL_I2C_STOP)); status = I2C_setup(&i2cSetup); if(status != CSL_SOK) { LOG_printf(&trace, "I2C Setup Failed!!"); return(result); } for(i = 0; i < CSL_I2C_PAGES; i++){ LOG_printf(&trace, "Page %d", i); /* Assign the EEPROM page address */ gI2cWrBuf[0] = (CSL_I2C_PAGE_SIZE*i)>>8; gI2cWrBuf[1] = (CSL_I2C_PAGE_SIZE*i)&0xFF; for(looper = 0; looper < CSL_I2C_PAGE_SIZE; looper++) { gI2cWrBuf[looper + CSL_EEPROM_ADDR_SIZE] = i*CSL_I2C_PAGE_SIZE + looper; gI2cRdBuf[looper] = 0x0000; } /* Write data */ status = I2C_write(gI2cWrBuf, (CSL_I2C_PAGE_SIZE + CSL_EEPROM_ADDR_SIZE), CSL_I2C_EEPROM_ADDR, TRUE, startStop, CSL_I2C_MAX_TIMEOUT); if(status != CSL_SOK) { LOG_printf(&trace, "\tI2C Write Failed!!"); return(result); } LOG_printf(&trace, "\tI2C Write Complete"); /* Give some delay */ for(looper = 0; looper < CSL_I2C_MAX_TIMEOUT; looper++){;} /* Read data */ status = I2C_read(gI2cRdBuf, CSL_I2C_PAGE_SIZE, CSL_I2C_EEPROM_ADDR, gI2cWrBuf, CSL_EEPROM_ADDR_SIZE, TRUE, startStop, CSL_I2C_MAX_TIMEOUT, FALSE); if(status != CSL_SOK) { LOG_printf(&trace, "\tI2C Read Failed!!"); return(result); } LOG_printf(&trace, "\tI2C Read Complete"); /* Compare the buffers */ for(looper = 0; looper < CSL_I2C_PAGE_SIZE; looper++) { if(gI2cWrBuf[looper + CSL_EEPROM_ADDR_SIZE] != gI2cRdBuf[looper]) { LOG_printf(&trace, "\tRead Write Buffers Does not Match!!"); return(result); } } if(looper == CSL_I2C_PAGE_SIZE) { LOG_printf(&trace, "\tRead Write Buffers Match!!"); } } result = CSL_I2C_TEST_PASSED; return(result); }
VOID TestDataPkt(VOID) { LOG_printf(&trace, "Real TrafficTx1 %d", sizeof(RealTrafficTx1)); LOG_printf(&trace, "Real ControlTx1 %d", sizeof(RealControlTx1)); LOG_printf(&trace, "Real RachTx1 %d", sizeof(RealRachTx1)); LOG_printf(&trace, "Real DemodTx1 %d", sizeof(RealDemodTx1)); LOG_printf(&trace, "Real DSP_IPU_HEADER %d", sizeof(RealL2DspToIpuHeader)); LOG_printf(&trace, "Real IPU_DSP_HEADER %d", sizeof(RealL2IpuToDspHeader)); oTraffic.oInfo.L2ValidFlag = 0x1; oTraffic.oL2DspToIpuPayload[0].oHeader.nARFCN = 0x1777; oTraffic.oL2DspToIpuPayload[0].oHeader.nBAND = 0x3; oTraffic.oL2DspToIpuPayload[0].oHeader.nTS = 0x7; oTraffic.oL2DspToIpuPayload[0].oHeader.nDirection = 0x1; oTraffic.oL2DspToIpuPayload[0].oHeader.nTSC = 0x3; oTraffic.oL2DspToIpuPayload[0].oHeader.nFrameNum = 0x777777; oTraffic.oL2DspToIpuPayload[0].oHeader.nChannelType = 0x17; oTraffic.oL2DspToIpuPayload[0].oHeader.nSubSlotNum = 0x3; oTraffic.oL2DspToIpuPayload[0].oHeader.nSNRinQ8 = 0x7777; oTraffic.oL2DspToIpuPayload[0].oHeader.nRxLevel = 0x7777; oTraffic.oL2DspToIpuPayload[0].oHeader.nTOA = 0x77; oTraffic.oL2DspToIpuPayload[0].oHeader.nCipherMode = 0x1; oTraffic.oL2DspToIpuPayload[0].oHeader.nFHEnabled = 0x1; oTraffic.oL2DspToIpuPayload[0].oHeader.nARFCN_FH = 0x1DDD; oTraffic.oL2DspToIpuPayload[0].oHeader.nErrorCode = 0x7777; oTraffic.oL2DspToIpuPayload[0].oHeader.nReserved = 0x9999; DataPkt_MakeType1(oRealTraffic, oTraffic); //DataPkt_MakeType2(oRealControl, oControl); //DataPkt_MakeType3(oRealRach, oRach); //DataPkt_MakeType4(oRealDemod, oDemod); DataPkt_GetL2IpuToDspHeader(&oDataTx1.Data1Header, &oRealTraffic.Data1Header); LOG_printf(&trace, "0x%x", oDataTx1.Data1Header.nARFCN); LOG_printf(&trace, "0x%x", oDataTx1.Data1Header.nBAND); LOG_printf(&trace, "0x%x", oDataTx1.Data1Header.nTS); LOG_printf(&trace, "0x%x", oDataTx1.Data1Header.nDirection); LOG_printf(&trace, "0x%x", oDataTx1.Data1Header.nTSC); LOG_printf(&trace, "0x%x", oDataTx1.Data1Header.nFrameNum); LOG_printf(&trace, "0x%x", oDataTx1.Data1Header.nChannelType); LOG_printf(&trace, "0x%x", oDataTx1.Data1Header.nSubSlotNum); LOG_printf(&trace, "0x%x", oDataTx1.Data1Header.nTxLevelinQ8); LOG_printf(&trace, "0x%x", oDataTx1.Data1Header.nTA); }
/** * \brief Function to play the audio * * \param dataLength - Length of the data to be sent to audio device (In words) * \param leftDataBuf - Left data buffer pointer * \param rightDataBuf - Right data buffer pointer * \param ptr - Pointer to hold the palyback status * * \return Media status */ CSL_AcMediaStatus appPlayAudio( Uint16 dataLength, Uint16 *leftDataBuf, Uint16 *rightDataBuf, void *ptr ) { Uint16 *playBackActive; Int16 asrcOutputFifoNumBlk; #ifdef ENABLE_ASRC Uint16 numOutSamps; Int16 status; #else Uint16 looper; Uint16 tmpIdx; #endif #ifdef C5535_EZDSP_DEMO int i, numSample; int *samplePtr; extern int bufferIn[1024]; extern int bufferInIdx; // get the number of samples numSample = dataLength/2; samplePtr = (int*)leftDataBuf; #endif // NOTE: leftDataBuf and rightDataBuf point to the same buffer playBackActive = (Uint16*)ptr; *playBackActive = TRUE; // the first byte is the number of bytes in the buffer followed by the first left audio sample leftDataBuf++; #ifdef C5535_EZDSP_DEMO samplePtr++; for (i=0; i<numSample; i++) { if (bufferInIdx<256) { /* Take average of left and right channels. */ //temp = (signed long)samplePtr[i*2] + (signed long)samplePtr[i*2+1]; //temp >>= 1; /* Divide by 2 to prevent overload at output */ //bufferIn[bufferInIdx] = (int)temp; // copy the audio sample from the USB buffer into bufferIn (left channel only) bufferIn[bufferInIdx] = (int)samplePtr[i*2]*2; bufferInIdx++; // if the bufferIn is filled, then send a semaphore to the SpectrumDisplayTask if (bufferInIdx==256) { // send semaphore SEM_post(&SEM_BufferInReady); } } } #endif #ifdef ENABLE_STEREO_PLAYBACK // stereo USB audio - the audio data is L R L R ........ #ifdef ENABLE_ASRC //STS_add(&mySts2, hAsrc->numOutSamps); // debug /* Update ASRC phase increment */ status = ASRC_updatePhaseIncr(hAsrc); //STS_add(&mySts2, hAsrc->deltaPhaseIncr); if (status != ASRC_SOK) { usb_error++; LOG_printf(&trace, "ERROR: ASRC_updatePhaseIncr() failed: %d\n", status); } /* Update ASRC input FIFO */ status = ASRC_updateInFifo(hAsrc, (Int16 *)leftDataBuf, dataLength/2); if (status != ASRC_SOK) { usb_error++; LOG_printf(&trace, "ERROR: ASRC_updateInFifo() failed: %d\n", status); } /* Get ASRC number of output samples to generate */ status = ASRC_getNumOutSamps(hAsrc, &numOutSamps); if (status != ASRC_SOK) { usb_error++; LOG_printf(&trace, "ERROR: ASRC_getNumOutSamps() failed."); } //HWI_disable(); /* Check output FIFO overflow -- require at least one free buffer in output FIFO */ asrcOutputFifoNumBlk = asrcOutputFifoInBlk - asrcOutputFifoOutBlk + 1; //HWI_enable(); if (asrcOutputFifoNumBlk < 0) { asrcOutputFifoNumBlk += ASRC_OUTPUT_FIFO_NUM_BLK; } //STS_add(&mySts2, asrcOutputFifoNumBlk); // debug //LOG_printf(&trace, "%d", asrcOutputFifoNumBlk); // debug if (asrcOutputFifoNumBlk > (ASRC_OUTPUT_FIFO_NUM_BLK - 2)) { asrcOutputFifoInError++; LOG_printf(&trace, "ERROR: ASRC output FIFO OVERFLOW"); //LOG_printf(&trace, "%04x %d", (asrcOutputFifoInBlk<<8)|asrcOutputFifoOutBlk, asrcOutputFifoNumBlk); } /* Generate ASRC output samples */ status = ASRC_genOutInterpCoefs16b(hAsrc, &asrcOutputFifo[asrcOutputFifoInBlk][0], numOutSamps); if (status != ASRC_SOK) { usb_error++; LOG_printf(&trace, "ERROR: ASRC_genOutInterpCoefs16b() failed."); } /* Update ASRC output FIFO */ if (rdy_to_consume_asrc_output == TRUE) { //HWI_disable(); asrcOutputFifoBlkNumSamps[asrcOutputFifoInBlk] = 2 * numOutSamps; // outFifoNumCh * numOutSamps; //HWI_enable(); asrcOutputFifoInBlk = (asrcOutputFifoInBlk + 1) & (ASRC_OUTPUT_FIFO_NUM_BLK - 1); } if (usb_play_mode == FALSE) { usb_play_mode = TRUE; } #else /* ENABLE_ASRC */ /* Copy audio samples to circular buffer */ for (looper = 0; looper < (dataLength/2); looper++) { /* Check for overflow */ tmpIdx = no_asrc_buffer_input_index + 1; if (tmpIdx >= CODEC_OUTPUT_BUFFER_SIZE) { tmpIdx = 0; } if(tmpIdx == no_asrc_buffer_output_index) { no_asrc_buffer_in_error++; LOG_printf(&trace, "ERROR: no_asrc_buffer OVERFLOW"); } /* Copy left */ no_asrc_buffer[no_asrc_buffer_input_index++] = *leftDataBuf++; /* Copy right */ no_asrc_buffer[no_asrc_buffer_input_index++] = *leftDataBuf++; if (no_asrc_buffer_input_index >= CODEC_OUTPUT_BUFFER_SIZE) { no_asrc_buffer_inwrap++; no_asrc_buffer_input_index = 0; } } //HWI_disable(); /* Check output FIFO overflow -- require at least one free buffer in output FIFO */ asrcOutputFifoNumBlk = asrcOutputFifoInBlk - asrcOutputFifoOutBlk + 1; //HWI_enable(); if (asrcOutputFifoNumBlk < 0) { asrcOutputFifoNumBlk += ASRC_OUTPUT_FIFO_NUM_BLK; } if (asrcOutputFifoNumBlk > (ASRC_OUTPUT_FIFO_NUM_BLK - 2)) { asrcOutputFifoInError++; LOG_printf(&trace, "ERROR: ASRC output FIFO OVERFLOW"); } /* Copy audio samples to codec output FIFO */ for (looper = 0; looper < (dataLength/2); looper++) { /* Check for underflow */ if (no_asrc_buffer_output_index == no_asrc_buffer_input_index) { no_asrc_buffer_out_error++; LOG_printf(&trace, "ERROR: no_asrc_buffer UNDERFLOW"); } asrcOutputFifo[asrcOutputFifoInBlk][2*looper] = no_asrc_buffer[no_asrc_buffer_output_index++]; asrcOutputFifo[asrcOutputFifoInBlk][2*looper+1] = no_asrc_buffer[no_asrc_buffer_output_index++]; if(no_asrc_buffer_output_index >= CODEC_OUTPUT_BUFFER_SIZE) { no_asrc_buffer_outwrap++; no_asrc_buffer_output_index = 0; } } if (rdy_to_consume_asrc_output == TRUE) { /* Update codec output FIFO */ //HWI_disable(); asrcOutputFifoBlkNumSamps[asrcOutputFifoInBlk] = dataLength; //HWI_enable(); asrcOutputFifoInBlk = (asrcOutputFifoInBlk + 1) & (ASRC_OUTPUT_FIFO_NUM_BLK - 1); } if (usb_play_mode == FALSE) { usb_play_mode = TRUE; } #endif /* ENABLE_ASRC */ #else //ENABLE_STEREO_PLAYBACK LOG_printf(&trace, "ERROR: assumed stereo playback, but ENABLE_STEREO_PLAYBACK is not defined"); #endif // ENABLE_STEREO_PLAYBACK return(CSL_AC_MEDIACCESS_SUCCESS); }
/** * \brief Function to record the audio * * \param dataLength - Length of the data to be received audio device * \param leftDataBuf - Left data buffer pointer * \param rightDataBuf - Right data buffer pointer * \param ptr - Pointer for future use * * \return Media status */ CSL_AcMediaStatus appRecordAudio( Uint16 dataLength, Uint16 *leftDataBuf, Uint16 *rightDataBuf, void *ptr ) { #ifdef ENABLE_RECORD Int16 codec_input_sample_count; Uint16 i; //STS_add(&mySts1, dataLength); // debug /* Compute number of samples in circular buffer */ codec_input_sample_count = codec_input_buffer_input_index - codec_input_buffer_output_index; if (codec_input_sample_count < 0) { codec_input_sample_count += CODEC_INPUT_BUFFER_SIZE; } /* First word is length in bytes */ *leftDataBuf++ = 2*dataLength; //#ifndef SEND_KNOWN_DATA_TO_USB #if 0 // check for underflow if (codec_input_sample_count >= dataLength) { // get the data from the circular buffer for(i = 0; i < dataLength; i++) { *leftDataBuf++ = codec_input_buffer[codec_input_buffer_output_index++]; if (codec_input_buffer_output_index >= CODEC_INPUT_BUFFER_SIZE) { codec_input_buffer_output_index = 0; } } } else { //codec input underflow - send 0's for (i = 0; i < dataLength; i++) { *leftDataBuf++ = 0; } if (set_record_interface >= START_REC_WAIT_FRAMES) { codec_input_buffer_underflow++; LOG_printf(&trace, "ERROR: codec input buffer UNDERFLOW: %d\n", codec_input_sample_count); } } #else // SEND_KNOWN_DATA_TO_USB // debug for(i = 0; i < dataLength; i++) { *leftDataBuf++ = data_to_usb[data_to_usb_idx] / 8; data_to_usb_idx = (data_to_usb_idx + 1) & (DATA_TO_USB_SIZE-1); codec_input_buffer_output_index++; if (codec_input_buffer_output_index >= CODEC_INPUT_BUFFER_SIZE) { codec_input_buffer_output_index = 0; } } #endif // SEND_KNOWN_DATA_TO_USB #endif // ENABLE_RECORD return(CSL_AC_MEDIACCESS_SUCCESS); }