//#================================================================================================= //#================================================================================================= int __attribute__((section("XCodeMain"))) main( void ) { Tweeq_Init(); mOLED_Init(); mOLED_Clear(); i2c_Init(); MPU_SetAddr(0x68); MPU_Init(); short Y, CPos; CPos = 600; while(1) { Y = MPU_Read_Y(); sprintf(OS_Str_1, "%d ", Y); mOLED_Clear_Array(); mOLED_Print_Str(0, 0, "TweeQ"); mOLED_Print_Str(0, 1, "Y="); mOLED_Print_Str(20, 1, OS_Str_1); //display accel mOLED_Refresh(); //dont forget to refresh LED_HIGH; Delayms(25); LED_LOW; Delayms(25); } return (EXIT_SUCCESS); }
//=====flag: 0 is rotate 0', 1 is rotate 180' flip==== void sensor_rotate(u8 flag) { i2c_Init(GC0308_I2C_BAUD, GC0308_I2C_WRITE_ADDR,GC0308_I2C_READ_ADDR); if(0 == flag) { u8 rot_buf[3]; rot_buf[0] = 0xfe; //select page 0 rot_buf[1] = 0x00; Sensor_WriteRegister(rot_buf,1,1); rot_buf[0] = 0x14; //0',180' rot_buf[1] = 0x13; Sensor_WriteRegister(rot_buf,1,1); // deg_Printf("sensor_rotate 0 \n"); } else if(1 == flag) { u8 rot_buf[3]; rot_buf[0] = 0xfe; //select page 0 rot_buf[1] = 0x00; Sensor_WriteRegister(rot_buf,1,1); rot_buf[0] = 0x14; //0',180' rot_buf[1] = 0x10; Sensor_WriteRegister(rot_buf,1,1); // deg_Printf("sensor_rotate 180 \n"); } sensor_I2C_port_release(); }
Altimeter_Sensor::Altimeter_Sensor() { lps331ap_state = 0; lps331ap_press[0] = 0; lps331ap_press[1] = 0; lps331ap_press[2] = 0; lps331ap_temp[0] = 0; lps331ap_temp[1] = 0; count[0] = 0; count[1] = 0; count[2] = 0; count[3] = 0; i2c_Init(I2CMODE_AUTO, 400000L); // init I2C lib to 400Kbps i2c0master_StartN(SHT21_ADDR, I2C_WRITE,2); //write user reg i2c0master_WriteN(0xe6); i2c0master_WriteN(0x01); // init LPS331AP // set CTRL_REG i2c0master_StartN(LPS331AP_ADDR, I2C_WRITE,2); //set REG2 i2c0master_WriteN(0x21); i2c0master_WriteN(0x00); i2c0master_StartN(LPS331AP_ADDR, I2C_WRITE,2); // set REG1 i2c0master_WriteN(0x20); i2c0master_WriteN(0xe0); i2c0master_StartN(LPS331AP_ADDR, I2C_WRITE,2); //set REG3 i2c0master_WriteN(0x22); i2c0master_WriteN(0x00); // set resolution mode i2c0master_StartN(LPS331AP_ADDR, I2C_WRITE,2); i2c0master_WriteN(0x10); i2c0master_WriteN(0x6a); i2c0master_StartN(LPS331AP_ADDR, I2C_WRITE,2); i2c0master_WriteN(0x25); i2c0master_WriteN(0x00); i2c0master_StartN(LPS331AP_ADDR, I2C_WRITE,2); i2c0master_WriteN(0x26); i2c0master_WriteN(0x00); rawHeightFromSensor=-1; }
/** The main function. This is called on startup and contains the main loop. */ int main(void) { LCD_Init(); LCD_Clear(); Keypad_Init(); i2c_Init(); PN532_init(); char c; int writeMode = 0; char buffer[32] = ""; while (1) { c = Keypad_WaitAndGetKey(); // * key pressed: toggle write mode if (c == '*') { LCD_ClearBuffer(); buffer[0] = '\0'; writeMode = 1 - writeMode; LCD_WriteString(writeMode ? "Write mode..." : "Write ended."); } // # key pressed while not in write mode: read from NFC else if (c == '#' && !writeMode) { LCD_WriteString("Read from NFC..."); if (readStringFromNFC(buffer)) { LCD_WriteString(buffer); } else { LCD_WriteString("No Data"); } } // any key other than * pressed while in write mode: write to NFC else if (writeMode) { LCD_AppendCharToScreen(c); int len = strlen(buffer); buffer[len] = c; buffer[len + 1] = '\0'; if (!writeStringToNFC(buffer)) { LCD_WriteString("Error 63."); } } // otherwise: just show the pressed key else { LCD_AppendCharToScreen(c); } } }
//======return 0: do nothing , 1: will lock file==== u8 Gsen_check_lock_flag(void) { u8 flag = 0; u8 now_xdata,now_ydata,now_zdata; s8 GsXData,GsYData,GsZData; if(bSFBusy_Flag == 0) { i2c_Init(G_SEN_BAUD, G_SEN_WRITE_ADDR,G_SEN_READ_ADDR); now_xdata = Gsen_Read_Reg(0x41); now_ydata = Gsen_Read_Reg(0x42); now_zdata = Gsen_Read_Reg(0x43); sensor_I2C_port_release(); } //deg_Printf("x=%x, y=%x, z=%x\n",now_xdata,now_ydata,now_zdata); if((now_xdata&0xff) >= 0x80) GsXData =-(128 - (now_xdata&0x7f)); else GsXData = now_xdata&0x7f; if((now_ydata&0xff) >= 0x80) GsYData =-(128 - (now_ydata&0x7f)); else GsYData = now_ydata&0x7f; if((now_zdata&0xff) >= 0x80) GsZData =-(128 - (now_zdata&0x7f)); else GsZData = now_zdata&0x7f; if(((GsXData - sen_hold_last_xdata) > sys_ctl.Gsensor_senstivity_value)||((GsXData - sen_hold_last_xdata) < -sys_ctl.Gsensor_senstivity_value) ) { flag = 1; //deg_Printf("X=%x\n",GsXData - sen_hold_last_xdata); } if(((GsYData - sen_hold_last_ydata) > sys_ctl.Gsensor_senstivity_value)||((GsYData - sen_hold_last_ydata) < -sys_ctl.Gsensor_senstivity_value)) { flag = 1; //deg_Printf("Y=%x\n",GsYData - sen_hold_last_ydata); } if(((GsZData - sen_hold_last_zdata) > sys_ctl.Gsensor_senstivity_value)||((GsZData - sen_hold_last_zdata) < -sys_ctl.Gsensor_senstivity_value)) { flag = 1; //deg_Printf("Z=%x\n",GsZData - sen_hold_last_zdata); } sen_hold_last_xdata = GsXData; sen_hold_last_ydata = GsYData; sen_hold_last_zdata = GsZData; return flag; }
/*FUNCTION*------------------------------------------------------------------- * * Function Name : _usb_otg_max3353_init * Returned Value : * Comments : * * *END*----------------------------------------------------------------------*/ uint8_t _usb_otg_max3353_init ( usb_otg_max3353_call_struct_t * otg_max3353_call_ptr ) { usb_otg_state_struct_t * usb_otg_struct_ptr = ((usb_otg_max3353_call_struct_t *)otg_max3353_call_ptr)->otg_handle_ptr; uint8_t channel = otg_max3353_call_ptr->channel; /* configure GPIO for I2C function */ i2c_Init(channel); _bsp_usb_otg_max3353_set_pin_int(FALSE, TRUE); OS_Event_set(usb_otg_struct_ptr->otg_isr_event, USB_OTG_MAX3353_ISR_EVENT); _otg_max3353_enable_disable(channel,TRUE); OS_install_isr(otg_max3353_call_ptr->init_param_ptr->vector, (void (*)(void *))_usb_otg_max3353_isr, otg_max3353_call_ptr); OS_intr_init(otg_max3353_call_ptr->init_param_ptr->vector,otg_max3353_call_ptr->init_param_ptr->priority,0,TRUE); return USB_OK; }
//=====flag: 0 is rotate 0', 1 is rotate 180' flip==== void sensor_rotate(u8 flag) { u8 rot_buf[2]; i2c_Init(SIV121DS_I2C_BAUD, SIV121DS_I2C_WRITE_ADDR,SIV121DS_I2C_READ_ADDR); //deg_Printf("rotate=%x",flag); if(0 == flag) { rot_buf[0] = 0x04; rot_buf[1] = 0x03; Sensor_WriteRegister(rot_buf,1,1); } else if(1 == flag) { rot_buf[0] = 0x04; rot_buf[1] = 0x00; Sensor_WriteRegister(rot_buf,1,1); } sensor_I2C_port_release(); }
//to-do write in comments what these do. void init9axis(){ i2c_Init(); i2c_ResetBus(); i2c_Start(acc_i2c_addr,I2C_WRITE); i2c_Write(0x20); i2c_Write(0x2F); i2c_ResetBus(); // i2c_Start(acc_i2c_addr,I2C_WRITE); // i2c_Write(0x23); // i2c_Write(0xC0); // i2c_ResetBus(); i2c_Start(mag_i2c_addr,I2C_WRITE); i2c_Write(0x00); i2c_Write(0x08); i2c_ResetBus(); i2c_Start(mag_i2c_addr,I2C_WRITE); i2c_Write(0x01); i2c_Write(0x60); i2c_ResetBus(); i2c_Start(mag_i2c_addr,I2C_WRITE); i2c_Write(0x02); i2c_Write(0x00); i2c_ResetBus(); i2c_Start(gyr_i2c_addr,I2C_WRITE); i2c_Write(0x16); i2c_Write(0x18); i2c_ResetBus(); //Setup Timer4 to be used as a trigger for information collection TMR4 =0; T4CON=0; T4CONbits.TCKPS = 0b11; // 1:8 for now _T4IP = 0x01; // Set Timer4 Interrupt Priority Level IFS1bits.T4IF = 0; // Clear Timer4 Interrupt Flag IEC1bits.T4IE = 1; // Enable Timer4 interrupt T4CONbits.TON = 1; // turn on T4 }
void main(void) { Sys_Init(); putchar(' '); XBR0_Init(); PCA_Init(); i2c_Init(); while(1) { if (new_range) { new_range = 0; cmrange = ReadRanger(); Data[0] = 0x51; //write 0x51 to reg 0 of the ranger: i2c_write_data(ranger_addr, 0, Data, 1) ; // write one byte of data to reg 0 at addr printf("range = %d\r\n", cmrange); } } }
void G_sensor_init(void) { SETB(GSEN_DETECT_PORT_DIR, GSEN_DETECT_PORT_BIT); SETB(GSEN_DETECT_PORT_IE, GSEN_DETECT_PORT_BIT); CLRB(GSEN_DETECT_PORT_PU, GSEN_DETECT_PORT_BIT); CLRB(GSEN_DETECT_PORT_PD, GSEN_DETECT_PORT_BIT); if(bSFBusy_Flag == 0) { i2c_Init(G_SEN_BAUD, G_SEN_WRITE_ADDR,G_SEN_READ_ADDR); Gsensor_ID = u8sensor_Read_Gsen_ID(); if(Gsensor_ID != G_SEN_ID) { sensor_I2C_port_release(); return; } Gsen_Write_Reg(0x44,0x28); //setting normal not int Gsen_Write_Reg(0x45,(G_SEN_XG_CONF | 0x20)); sen_hold_last_xdata = Gsen_Read_Reg(0x41); sen_hold_last_ydata = Gsen_Read_Reg(0x42); sen_hold_last_zdata = Gsen_Read_Reg(0x43); sensor_I2C_port_release(); } }
/******************************************************************************* * Function Name : sensor_Init * Description : initialize the sensor * Input : None * Output : None * Return : None *******************************************************************************/ u8 sensor_Init(void) { u32 i; u8 j; u8 u8Buf[2]; u8 SensorId; #if(SYS_CLK == 120000000) sensor_ClockInit(24000000); #elif(SYS_CLK == 48000000) sensor_ClockInit(12000000); #endif u8SensorwriteID = OV7725_I2C_WRITE_ADDR; u8SensorreadID = OV7725_I2C_READ_ADDR; u8Addrbytnum = 1; u8Databytnum = 1; //=======close sensor power ======== #if (I2C_MAP == I2C_MAP_SW2) //select software simulate I2C signal bI2CBusy_Flag=1; //set dc check unuse bSFBusy_Flag=1; //set tf card check unuse REG32(PMAP_CFG0) &= ~(1<<14); //SPI0_MAP0 not mapping to io REG32(PMAP_CFG0) &= ~(1<<7); // uart not map to io I2C_SCL_SDA_OUT(); I2C_SCL_LOW(); I2C_SDA_LOW(); #endif REG32(SYS_CON) = 0x932B; //SPEC request value REG32(LDO_ACON) &= ~(0xf << 4); //close senosr ldo power #if (USER_CONFIG==CONFIG_AX3251_K6000) Delay_MS(250); //rc reset need delay, IO reset not do it #endif #if (I2C_MAP == I2C_MAP_SW2) //select software simulate I2C signal bI2CBusy_Flag=0; bSFBusy_Flag=0; #endif //======end close sensor power======= //====sensor ldo open====== REG32(LDO_ACON) |= (4<<4); //sensor 3bit 111:3.3v,110:3.2v .... 000:2.6v REG32(LDO_ACON) |= (1<<7); //sensor ldo enable Delay_MS(50); //===end sensor ldo open==== i2c_Init(OV7725_I2C_BAUD, OV7725_I2C_WRITE_ADDR,OV7725_I2C_READ_ADDR); CLRB(REG32(PCON0), 23); //csi Clock Enable Bit //SENSOR_PIN_CONF(); //SENSOR_POWERDN(); SENSOR_NRESET(); Delay_MS(10); SENSOR_RESET(); Delay_MS(10); SENSOR_NRESET(); //SENSOR_NORMAL(); Delay_MS(10); i2c_SendStop(); SensorId = u8sensor_ReadID(); for(i=0; i<sizeof(OV7725InitTable)/2; i++) { for(j=0; j<(u8Addrbytnum+u8Databytnum); j++) { u8Buf[j] = OV7725InitTable[i][j]; } Sensor_WriteRegister(u8Buf,u8Addrbytnum,u8Databytnum); Delay_MS(1); } sensor_I2C_port_release(); deg_Printf("SensorId=%x\n",SensorId); return 0; }
void MainTask(void *arg) { ADI_AFE_DEV_HANDLE hDevice; int16_t dft_results[DFT_RESULTS_COUNT]; q15_t dft_results_q15[DFT_RESULTS_COUNT]; q31_t dft_results_q31[DFT_RESULTS_COUNT]; q31_t magnitude[DFT_RESULTS_COUNT / 2]; q15_t phase[DFT_RESULTS_COUNT / 2]; fixed32_t magnitude_result[DFT_RESULTS_COUNT / 2 - 1]; fixed32_t phase_result[DFT_RESULTS_COUNT / 2 - 1]; char msg[MSG_MAXLEN]; uint8_t err; done = 0; uint16_t pressure_analog; uint32_t pressure; nummeasurements = 0; uint32_t rtcCount; ADI_I2C_RESULT_TYPE i2cResult; // Initialize driver. rtc_Init(); // Calibrate. rtc_Calibrate(); // Initialize UART. if (uart_Init()) { FAIL("ADI_UART_SUCCESS"); } // Initialize I2C. i2c_Init(&i2cDevice); // Initialize flags. bRtcAlarmFlag = bRtcInterrupt = bWdtInterrupt = false; // Get the current count. if (adi_RTC_GetCount(hRTC, &rtcCount)) { FAIL("adi_RTC_GetCount failed"); } // Initialize the AFE API. if (adi_AFE_Init(&hDevice)) { FAIL("adi_AFE_Init"); } // AFE power up. if (adi_AFE_PowerUp(hDevice)) { FAIL("adi_AFE_PowerUp"); } // Excitation Channel Power-up. if (adi_AFE_ExciteChanPowerUp(hDevice)) { FAIL("adi_AFE_ExciteChanPowerUp"); } // TIA Channel Calibration. if (adi_AFE_TiaChanCal(hDevice)) { FAIL("adi_AFE_TiaChanCal"); } // Excitation Channel Calibration (Attenuation Enabled). if (adi_AFE_ExciteChanCalAtten(hDevice)) { FAIL("adi_AFE_ExciteChanCalAtten"); } // Update FCW in the sequence. seq_afe_acmeas2wire[3] = SEQ_MMR_WRITE(REG_AFE_AFE_WG_FCW, FCW); // Update sine amplitude in the sequence. seq_afe_acmeas2wire[4] = SEQ_MMR_WRITE(REG_AFE_AFE_WG_AMPLITUDE, SINE_AMPLITUDE); // Recalculate CRC in software for the AC measurement, because we changed. // FCW and sine amplitude settings. adi_AFE_EnableSoftwareCRC(hDevice, true); // Perform the impedance measurement. if (adi_AFE_RunSequence(hDevice, seq_afe_acmeas2wire, (uint16_t *)dft_results, DFT_RESULTS_COUNT)) { FAIL("Impedance Measurement"); } // Set RTC alarm. printf("rtcCount: %d\r\n", rtcCount); if (ADI_RTC_SUCCESS != adi_RTC_SetAlarm(hRTC, rtcCount + 120)) { FAIL("adi_RTC_SetAlarm failed"); } // Enable RTC alarm. if (ADI_RTC_SUCCESS != adi_RTC_EnableAlarm(hRTC, true)) { FAIL("adi_RTC_EnableAlarm failed"); } // Read the initial impedance. q31_t magnitudecal; q15_t phasecal; convert_dft_results(dft_results, dft_results_q15, dft_results_q31); arm_cmplx_mag_q31(dft_results_q31, &magnitudecal, 2); phasecal = arctan(dft_results[1], dft_results[0]); printf("raw rcal data: %d, %d\r\n", dft_results[1], dft_results[0]); printf("rcal (magnitude, phase) = (%d, %d)\r\n", magnitudecal, phasecal); // Create the message queue for communicating between the ISR and this task. dft_queue = OSQCreate(&dft_queue_msg[0], DFT_QUEUE_SIZE); // Hook into the DFT interrupt. if (ADI_AFE_SUCCESS != adi_AFE_RegisterAfeCallback( hDevice, ADI_AFE_INT_GROUP_CAPTURE, AFE_DFT_Callback, BITM_AFE_AFE_ANALOG_CAPTURE_IEN_DFT_RESULT_READY_IEN)) { FAIL("adi_AFE_RegisterAfeCallback"); } if (ADI_AFE_SUCCESS != adi_AFE_ClearInterruptSource( hDevice, ADI_AFE_INT_GROUP_CAPTURE, BITM_AFE_AFE_ANALOG_CAPTURE_IEN_DFT_RESULT_READY_IEN)) { FAIL("adi_AFE_ClearInterruptSource (1)"); } packed32_t q_result; void *q_result_void; OS_Q_DATA q_data; uint16_t q_size; bool inflated = false; while (true) { // Wait for the user to press the button. printf("MainTask: waiting for button.\n"); OSSemPend(ux_button_semaphore, 0, &err); if (err != OS_ERR_NONE) { FAIL("OSSemPend: MainTask"); } // TODO: fix bug when pressing button multiple times. // Have the pump task inflate the cuff. printf("MainTask: button detected. Resuming pump task.\n"); err = OSTaskResume(TASK_PUMP_PRIO); if (err != OS_ERR_NONE) { FAIL("OSTaskResume: MainTask (1)"); } // Wait a bit. printf("MainTask: waiting a bit.\n"); err = OSTimeDlyHMSM(0, 0, 1, 0); if (err != OS_ERR_NONE) { FAIL("OSTimeDlyHMSM: MainTask (3)"); } // Enable the DFT interrupt. printf("MainTask: enabling DFT interrupt.\n"); if (ADI_AFE_SUCCESS != adi_AFE_EnableInterruptSource( hDevice, ADI_AFE_INT_GROUP_CAPTURE, BITM_AFE_AFE_ANALOG_CAPTURE_IEN_DFT_RESULT_READY_IEN, true)) { FAIL("adi_AFE_EnableInterruptSource"); } PRINT("START\r\n"); printf("START\r\n"); while (true) { // Wait on the queue to get DFT data from the ISR (~76 Hz). //printf("MainTask: pending on DFT queue.\n"); q_result_void = OSQPend(dft_queue, 0, &err); q_result.pointer = q_result_void; if (err != OS_ERR_NONE) { FAIL("OSQPend: dft_queue"); } OSQQuery(dft_queue, &q_data); q_size = q_data.OSNMsgs; // Right after we get this data, get the transducer's value from the // Arduino. //printf("MainTask: getting transducer value via I2C.\n"); i2cResult = adi_I2C_MasterReceive(i2cDevice, I2C_PUMP_SLAVE_ADDRESS, 0x0, ADI_I2C_8_BIT_DATA_ADDRESS_WIDTH, i2c_rx, 3, false); if (i2cResult != ADI_I2C_SUCCESS) { FAIL("adi_I2C_MasterReceive: get pressure from Arduino"); } // Get the analog pressure value from the Arduino. if (i2c_rx[0] == ARDUINO_PRESSURE_AVAILABLE || i2c_rx[0] == ARDUINO_STILL_INFLATING) { pressure_analog = i2c_rx[1] | (i2c_rx[2] << 8); } else { FAIL("Corrupted or unexpected data from Arduino."); } // Convert the analog value to mmHg. pressure = transducer_to_mmhg(pressure_analog); //printf("MainTask: got pressure value: %d mmHg.\n", pressure); // If the pressure is below the threshold, we're done; break the loop. if (inflated && pressure < LOWEST_PRESSURE_THRESHOLD_MMHG) { PRINT("END\r\n"); printf("END\r\n"); inflated = false; break; } else if (pressure > LOWEST_PRESSURE_THRESHOLD_MMHG * 1.1) { inflated = true; } // Convert DFT results to 1.15 and 1.31 formats. dft_results[0] = q_result.parts.magnitude; dft_results[1] = q_result.parts.phase; convert_dft_results(dft_results, dft_results_q15, dft_results_q31); // Compute the magnitude using CMSIS. arm_cmplx_mag_q31(dft_results_q31, magnitude, DFT_RESULTS_COUNT / 2); // Calculate final magnitude values, calibrated with RCAL. fixed32_t magnituderesult; magnituderesult = calculate_magnitude(magnitudecal, magnitude[0]); q15_t phaseresult; phaseresult = arctan(dft_results[1], dft_results[0]); fixed32_t phasecalibrated; // Calibrate with phase from rcal. phasecalibrated = calculate_phase(phasecal, phaseresult); // TODO: dispatch to another thread? //printf("MainTask: sending data via UART.\n");; print_PressureMagnitudePhase("", pressure, magnituderesult, phasecalibrated, q_size); nummeasurements++; } // We're done measuring, for now. Disable the DFT interrupts. printf("MainTask: disabling DFT interrupts.\n"); if (ADI_AFE_SUCCESS != adi_AFE_EnableInterruptSource( hDevice, ADI_AFE_INT_GROUP_CAPTURE, BITM_AFE_AFE_ANALOG_CAPTURE_IEN_DFT_RESULT_READY_IEN, false)) { FAIL("adi_AFE_EnableInterruptSource (false)"); } // Tell the pump task to deflate the cuff. printf("MainTask: resuming pump task to deflate the cuff.\n"); err = OSTaskResume(TASK_PUMP_PRIO); if (err != OS_ERR_NONE) { FAIL("OSTaskResume: MainTask (2)"); } // Suspend until the pump finishes deflating. We can then go back to // listening for the user input. printf("MainTask: suspending to wait for pump task.\n"); err = OSTaskSuspend(OS_PRIO_SELF); if (err != OS_ERR_NONE) { FAIL("OSTaskSuspend: MainTask (3)"); } // Tell the UX that we're done for now. UX_Disengage(); } }
//--------------------------------------------------------------------------------------------------------- // Main Function //--------------------------------------------------------------------------------------------------------- INT32 main() { SYSCLK_INITIATE(); // Configure CPU clock source and operation clock frequency. // The configuration functions are in "SysClkConfig.h" CLK_EnableLDO(CLK_LDOSEL_3_3V); // Enable ISD9100 interl 3.3 LDO. if (! SPIFlash_Initiate()) // Initiate SPI interface and checking flows for accessing SPI flash. while(1); // loop here for easy debug OUTPUTPIN_INITIATE(); // Initiate output pin configuration. // The output pins configurations are defined in "ConfigIO.h". KEYPAD_INITIATE(); // Initiate keypad configurations including direct trigger key and matrix key // The keypad configurations are defined in "ConfigIO.h". ULTRAIO_INITIATE(); // Initiate ultraio output configurations. // The ultraio output pin configurations are defined in "ConfigUltraIO.h" PDMA_INITIATE(); // Initiate PDMA. // After initiation, the PDMA engine clock NVIC are enabled. // Use PdmaCtrl_Open() to set PDMA service channel for desired IP. // Use PdmaCtrl_Start() to trigger PDMA operation. // Reference "PdmaCtrl.h" for PDMA related APIs. // PDMA_INITIATE() must be call before SPK_INITIATE() and MIC_INITIATE(), if open MIC or speaker. SPK_INITIATE(); // Initiate speaker including pop-sound canceling. // After initiation, the APU is paused. // Use SPK_Resume(0) to start APU operation. // Reference "MicSpk.h" for speaker related APIs. MIC_INITIATE(); // Initiate MIC. // After initiation, the ADC is paused. // Use ADC_Resume() to start ADC operation. // Reference "MicSpk.h" for MIC related APIs. App_Initiate(); // Initiate application for audio decode. i2c_Init(); //need to excute before #define I2C_IRQ #ifdef I2C_IRQ I2C_EnableInt(I2C0); NVIC_EnableIRQ(I2C0_IRQn); NVIC_SetPriority(I2C0_IRQn, 0); #endif #ifdef OLED_ENABLE Init_LCD(); clear_LCD(); print_Line(0, "OscarNuLiteExEnc"); // print_Line(1, "2015.11.12 "); // print_Line(2, "Eric Yang "); // print_Line(3, "0.96 OLED 128x64"); #endif while (1) { if ( g_u8AppCtrl&APPCTRL_RECORD ) { if ( App_ProcessRec() == FALSE ) { App_StopRec(); #ifdef OLED_ENABLE print_Line(1, " REC Stop "); #endif } } else if ( g_u8AppCtrl&APPCTRL_PLAY ) { if ( App_ProcessPlay() == FALSE ) { App_StopPlay(); #ifdef OLED_ENABLE print_Line(1, " PLAY Stop "); #endif } } TRIGGER_KEY_CHECK(); // Check and execute direct trigger key actions defined in "InputKeyActions.c" // Default trigger key handler is "Default_KeyHandler()" // The trigger key configurations are defined in "ConfigIO.h". MATRIX_KEY_CHECK(); // Check and execute matrix key actions defined in "InputKeyActions.c" // Default matrix key handler is "Default_KeyHandler()" // The matrix key configurations are defined in "ConfigIO.h". TOUCH_KEY_CHECK(); // Check and execute touch key actions defined in "InputKeyActions.c" // Default touch key handler is "Default_KeyHandler()" // The touch key configurations are defined in "ConfigIO.h". } }