void main(void) { int cdc_in; int uart_in; volatile UINT8 u8Error; hw_init(); MCU_init(); GL_Init( GL_FD_HORIZONTAL | GL_FD_TOUCH_BEEP_ON, GLF_65K_COLORS, GLF_16M_COLORS, &OnDrawScreenBackground ); win_main_font = (GL_HFONT) & Arial_16px; GL_Screen_Activate((GL_HSCREEN) &screen); SPI_Init(); if ((u8Error = SD_Init()) != INIT_FAILS) { FAT_Read_Master_Block(); loadFiles(); redraw(); SD_LOADED_BEEP(); } else { NO_SD_BEEP(); } EnableInterrupts; while (1) { // handle touch (FIXME typo in GL lib (HaDNle)) GL_TS_HadnleActions(); } }
int main(void) { MCU_init(); /* call Device Initialization */ SOPT_COPE =0; /*apago el watchdog*/ testdiv(); testsqrt(); testrsqrt(); testlog2(); testexp2(); testexp2log2(); #ifdef FIXED_POINT testilog2(); #endif return ret; }
void main(void) { MCU_init(); // inicializa o microcontrolador flash_init(); // inicializa a FSL while (1) { if (save_status) // se há requisição de salvamento na flash { save_status = 0; // limpa a requisição flash_erase(); // apaga a flash // se o led está ligado, salva 0 no endereço 0xFC00 // se o led está desligado, o endereço 0xFC00 permanece com 0xFF if (!LED_RPB) flash_write32(0,0xFC00); } } }
void main(void) { MCU_init(); PORTA = 0x00; OPAMP_EN = 1; for(;;) { yo++; /* _FEED_COP(); by default, COP is disabled with device init. When enabling, also reset the watchdog. */ //LED_ERR = 0; // Aide pour le debug: enlève l'erreur pour le watchdog timer //MAT: c'est étrange on dirait qu'on ne vient jamais dans le main... // les interrupts RTI sont peut-être trop fréquentes à 4 kHz } }
void main(void) { unsigned char counter; EnableInterrupts; MCU_init(); /* include your code here */ //3. Disable interrupts to permit execution of the code DisableInterrupts; //4. Cycle that writes a byte form value 0 to 127 Erase(0x3200); for(counter=0;counter<=127;counter++) { Program(0x3200 + counter, counter); } for(;;) { __RESET_WATCHDOG(); /* feeds the dog */ } /* loop forever */ /* please make sure that you never leave main */ }
int main(int argc,char ** argv) { MCU_init(); /* call Device Initialization */ SOPT_COPE =0; /*apago el watchdog*/ EnableInterrupts; //tic(); ALLOC_STACK; while(1){ if (argc>1) { int k; for (k=1;k<argc;++k) { test1d(atoi(argv[k]),0); test1d(atoi(argv[k]),1); } }else{ test1d(32,0); test1d(32,1); test1d(64,0); test1d(64,1); test1d(128,0); test1d(128,1); test1d(256,0); test1d(256,1); #ifndef RADIX_TWO_ONLY test1d(36,0); test1d(36,1); test1d(50,0); test1d(50,1); test1d(120,0); test1d(120,1); test1d(105,0); test1d(105,1); #endif } } return ret; }
void main(void) { #if(BOOTLOADER_ENABLE == 1) ISR_vtable_reallocation(); #endif MCU_init(); /* MCU Initialization */ // Initialize BRTOS BRTOS_Init(); /* Peripheral inicialization */ #if (DEBUG == 1) /* flash clock for reprogramming */ Flash_Clock_Init(); /* Initialize A/D Converter and bandgap reference */ ADC_Setup(HighSpeed, ShortSampleTime, 12); if(ADC_Bandgap_Set() != BANDGAP_OK){ while(1){} } #endif #if(DEBUG == 1) #if(NETWORK_ENABLE == 1) GPSNET_Init(); if(InstallTask(&GPSNET_RxApp,"GPSNET RX task",320,APP3_Priority) != OK) { while(1){}; } /* if(InstallTask(&GPSNET_TxApp,"GPSNET TX task",1280,APP2_Priority) != OK) { while(1){}; } */ if(InstallTask(&GPSNET_SensorApp,"GPSNET Sensor task",1280,APP1_Priority) != OK) { while(1){}; } #endif #endif if(InstallTask(&System_Time,"System Time",320,System_Time_Priority) != OK) { while(1){}; }; if(InstallTask(&Comm2PC_Task,"Comm2PC task",448,Comm2PC_Task_Priority) != OK) { while(1){}; }; if(InstallTask(&HeartBeat_LED_Task,"HeartBeat LED task",320,HeartBeat_LED_Priority) != OK) { while(1){}; }; // Start Task Scheduler if(BRTOSStart() != OK) { while(1){}; }; for(;;) { /* __RESET_WATCHDOG(); by default, COP is disabled with device init. When enabling, also reset the watchdog. */ } /* loop forever */ /* please make sure that you never leave main */ }
static int hdmi_task_handle(void *data) { static BOOL bSignal ; BOOL bOldSignal, bChangeMode ; int dump_count = 0 ; int stable_count = 0; MCU_init() ; printk("\n%s\n" , VERSION_STRING); while(1){ HoldSystem(); hdmirx_clear_hpd(); #ifdef _COPY_EDID_ CopyDefaultEDID() ; #endif InitHDMIRX(TRUE); hdmirx_set_hpd(); xCntCnt = 0 ; xCntSum = 0 ; while(hdmirx_device.it660x_enable){ while(hdmirx_device.task_pause){ msleep(10); } if(ReadRXIntPin()) { Check_HDMInterrupt(); } //if(IsTimeOut(20)){ dump_count ++ ; bOldSignal = bSignal ; bSignal = CheckHDMIRX(); bChangeMode = (bSignal != bOldSignal); if(bChangeMode) { // if Changed Mode ... if(bSignal) { stable_count = 0; update_status(0); // if signal is TRUE , then ... dump_vidmode(); if( IsHDMIRXHDMIMode() ) dump_InfoFrame() ; dump_audSts(); } else { stable_count = 0; stop_vdin(); update_status(1); // if signal is FALSE , then ... xCntCnt = 0 ; xCntSum = 0 ; } bChangeMode = FALSE ; // clear bChange Mode action } else { // if not change mode, ... if(bSignal) { if(stable_count<stable_threshold){ stable_count++; if(stable_count == stable_threshold){ start_vdin(getHDMIRXHorzActive(), getHDMIRXVertActive(), 10000, IsHDMIRXInterlace()); } } update_status(0); // if signal is TRUE , then ... if( (dump_count % 20) == 1 ) { xCntCnt ++ ; xCntSum += getHDMIRXxCnt() ; if( xCntCnt > 40 ) { xCntCnt /= 2 ; xCntSum /= 2 ; } } } else { stable_count = 0; stop_vdin(); update_status(1); // if signal is FALSE , then ... xCntCnt = 0 ; xCntSum = 0 ; } } if( dump_count > (DUMP_TIME*1000/20) ) { dump_count = 0 ; if( bSignal ) { dump_vidmode(); if( IsHDMIRXHDMIMode() ) dump_InfoFrame() ; dump_audSts(); } else { printk("Reg10 = %02X\nReg12 = %02X\nReg64 = %02X\nReg65 = %02X\n" ,(int)HDMIRX_ReadI2C_Byte(0x10) ,(int)HDMIRX_ReadI2C_Byte(0x12) ,(int)HDMIRX_ReadI2C_Byte(0x64) ,(int)HDMIRX_ReadI2C_Byte(0x65) ) ; } printk("\n\n") ; DumpHDMIRXReg(); } //}// if(IsTimeOut(20)) msleep(10); } PowerDownHDMI(); } return 0; }
static int hdmi_task_handle(void *data) { int repeater = 0; int stable_count = 0; static BOOL bSignal ; BOOL bOldSignal, bChangeMode ; int i; int dump_count = 0 ; MCU_init() ; printk("\n%s\n" , VERSION_STRING); while(1){ HoldSystem(); hdmirx_clear_hpd(); #ifdef _COPY_EDID_ CopyDefaultEDID() ; #endif repeater=repeater_enable ; #if 0 GetCurrentHDMIPort(); SelectHDMIPort(CAT_HDMI_PORTA); #endif // InitHDMIRX(FALSE); if( repeater ) { DownStreamCount = 3 ; RxHDCPSetRepeater(); } else { RxHDCPSetReceiver(); } hdmirx_set_hpd(); while(hdmirx_device.it660x_enable){ while(hdmirx_device.task_pause){ msleep(10); } //HoldSystem(); if(ReadRXIntPin()) { Check_HDMInterrupt(); } //if(IsTimeOut(20)) //{ dump_count ++ ; bOldSignal = bSignal ; bSignal = CheckHDMIRX(); bChangeMode = (bSignal != bOldSignal); if(bChangeMode) { // if Changed Mode ... if(bSignal) { stable_count = 0; update_status(0); // if signal is TRUE , then ... dump_vidmode(); if( IsHDMIRXHDMIMode() ) dump_InfoFrame() ; dump_audSts(); } else { stable_count = 0; stop_vdin(); update_status(1); // if signal is FALSE , then ... xCntCnt = 0 ; xCntSum = 0 ; } bChangeMode = FALSE ; // clear bChange Mode action } else { // if not change mode, ... if(bSignal) { if(stable_count<stable_threshold){ stable_count++; if(stable_count == stable_threshold){ start_vdin(getHDMIRXHorzActive(), getHDMIRXVertActive(), 10000, IsHDMIRXInterlace()); } } update_status(0); // if signal is TRUE , then ... if( (dump_count % 20) == 1 ) { xCntCnt ++ ; xCntSum += getHDMIRXxCnt() ; if( xCntCnt > 40 ) { xCntCnt /= 2 ; xCntSum /= 2 ; } } } else { stable_count = 0; stop_vdin(); update_status(1); // if signal is FALSE , then ... xCntCnt = 0 ; xCntSum = 0 ; } } if( dump_count > (DUMP_TIME*1000/20) ) { dump_count = 0 ; if( bSignal ) { dump_vidmode(); if( IsHDMIRXHDMIMode() ) dump_InfoFrame() ; dump_audSts(); } else { printk("Reg10 = %02X\nReg12 = %02X\nReg64 = %02X\nReg65 = %02X\n" ,(int)HDMIRX_ReadI2C_Byte(0x10) ,(int)HDMIRX_ReadI2C_Byte(0x12) ,(int)HDMIRX_ReadI2C_Byte(0x64) ,(int)HDMIRX_ReadI2C_Byte(0x65) ) ; } printk("\n\n"); DumpHDMIRXReg(); } if( (dump_count % (1000/20)) == 0) { if( repeater!=repeater_enable ) { repeater=repeater_enable ; hdmirx_clear_hpd(); if( repeater ) { if( DownStreamCount == 0 ) { DownStreamCount = 5 ; } else { DownStreamCount -- ; } printk("Set Repeater Mode, DownStream = %d\n",DownStreamCount) ; RxHDCPSetRepeater(); } else { RxHDCPSetReceiver(); } hdmirx_set_hpd(); } } if( repeater ) { if(IsRxAuthStart()) { DelayCounter = 0 ; } if(IsRxAuthDone()) { DelayCounter = DownStreamCount*2+1 ; } if(DelayCounter > 0) { DelayCounter -- ; if(DelayCounter == 0) { for(i = 0 ; i < 5*DownStreamCount ; i++) { KSVList[i] = SampleKSVList[i] ; } setRxHDCPKSVList(0,KSVList,DownStreamCount); if( DownStreamCount > 0 ) { bStatus=DownStreamCount|0x0100 ; } else { bStatus=0; } setRxHDCPBStatus(bStatus); setRxHDCPCalcSHA(); } } } //}// if(IsTimeOut(20)) msleep(10); } PowerDownHDMI(); } return 0; }
static int hdmi_task_handle(void *data) { int repeater = 0; int stable_count = 0; static BOOL bSignal ; BOOL bOldSignal, bChangeMode ; int i; int pre_state; MCU_init() ; HoldSystem(); hdmirx_clear_hpd(); update_status(1); printk("\n%s\n" , VERSION_STRING); while(1){ if(hdmirx_device.task_pause){ continue; } if((hdmirx_device.state == HDMIRX_STATE_HPD_HIGH)|| (hdmirx_device.state == HDMIRX_STATE_STABLE) || (hdmirx_device.state == HDMIRX_STATE_READY)){ if(ReadRXIntPin()) { Check_HDMInterrupt(); } bOldSignal = bSignal ; bSignal = CheckHDMIRX(); bChangeMode = (bSignal != bOldSignal); } pre_state = hdmirx_device.state; switch(hdmirx_device.state){ case HDMIRX_STATE_POWEROFF: if(hdmirx_device.it660x_enable){ repeater=repeater_enable ; if( repeater ){ hdmi_repeater_set_hdcp_mode(HDMI_TX_HDCP_MODE_REPEATER); RxHDCPSetRepeater(); } else{ hdmi_repeater_set_hdcp_mode(HDMI_TX_HDCP_MODE_NONE_REPEATER); RxHDCPSetReceiver(); } hdmirx_device.state = HDMIRX_STATE_POWERON; } break; case HDMIRX_STATE_POWERON: if(hdmirx_device.it660x_enable == 0){ hdmirx_clear_hpd(); PowerDownHDMI(); hdmirx_device.state = HDMIRX_STATE_POWEROFF; } else{ if((!repeater)||(get_hdmi_tx_state(HDMI_TX_STATE_HPD)==1)){ hdmirx_set_hpd(); hdmirx_device.state = HDMIRX_STATE_HPD_HIGH; } } break; case HDMIRX_STATE_HPD_HIGH: if(hdmirx_device.it660x_enable == 0){ hdmirx_clear_hpd(); PowerDownHDMI(); hdmirx_device.state = HDMIRX_STATE_POWEROFF; } else if(bSignal){ stable_count = 0; hdmirx_device.state = HDMIRX_STATE_STABLE; } break; case HDMIRX_STATE_STABLE: if(hdmirx_device.it660x_enable == 0){ hdmirx_clear_hpd(); PowerDownHDMI(); update_status(1); hdmirx_device.state = HDMIRX_STATE_POWEROFF; } else if(!bSignal){ update_status(1); hdmirx_device.state = HDMIRX_STATE_HPD_HIGH; } else{ update_status(0); if(bChangeMode){ stable_count = 0; } if(stable_count<stable_threshold){ stable_count++; } if((stable_count == stable_threshold)&&(hdmirx_device.vdin_enable)){ start_vdin(getHDMIRXHorzActive(), getHDMIRXVertActive(), 10000, IsHDMIRXInterlace()); hdmirx_device.state = HDMIRX_STATE_READY; } } break; case HDMIRX_STATE_READY: if(hdmirx_device.it660x_enable == 0){ stop_vdin(); hdmirx_clear_hpd(); PowerDownHDMI(); update_status(1); hdmirx_device.state = HDMIRX_STATE_POWEROFF; } else if(repeater&&get_hdmi_tx_state(HDMI_TX_STATE_HPD)==0){ hdmirx_clear_hpd(); hdmirx_device.state = HDMIRX_STATE_POWERON; } else if((!bSignal)||bChangeMode){ stop_vdin(); update_status(1); hdmirx_device.state = HDMIRX_STATE_HPD_HIGH; } else if(hdmirx_device.vdin_enable == 0){ stop_vdin(); hdmirx_device.state = HDMIRX_STATE_STABLE; } else{ update_status(0); } break; } if(pre_state != hdmirx_device.state){ printk("[HDMIRX State] %s -> %s\n", state_name[pre_state], state_name[hdmirx_device.state]); } bChangeMode = FALSE ; // clear bChange Mode action /* HDCP */ if(repeater&& ((hdmirx_device.state == HDMIRX_STATE_HPD_HIGH)|| (hdmirx_device.state == HDMIRX_STATE_STABLE) || (hdmirx_device.state == HDMIRX_STATE_READY))){ static int pre_tx_auth = 0; if(IsRxAuthStart()) { printk("[HDMIRX HDCP] RX auth start\n"); hdmi_repeater_enable_hdcp(0); while(!get_hdmi_tx_state(HDMI_TX_STATE_HDCP_CMD_DONE)){ msleep(10); } hdmi_repeater_enable_hdcp(1); } if(get_hdmi_tx_state(HDMI_TX_STATE_HDCP_AUTH) == 1){ if(pre_tx_auth == 0) printk("[HDMIRX HDCP] TX authenticated\n"); pre_tx_auth = 1; if(IsRxAuthDone()) { printk("[HDMIRX HDCP] RX auth done\n"); char bksv_buf[5]; /* to do, read b-ksv list */ hdmi_hdcp_get_bksv(bksv_buf, 0); printk("BKSV: "); for(i = 0;i < 5; i++) { printk("%02x", bksv_buf[i]); KSVList[i] = bksv_buf[i]; } printk(" \r\n"); DownStreamCount = 1; if(test_flag&1){ DownStreamCount = 3; for(i = 0 ; i < 5*DownStreamCount ; i++) { KSVList[i] = SampleKSVList[i] ; printk("%0x\n", SampleKSVList[i]); } } setRxHDCPKSVList(0,KSVList,DownStreamCount); if( DownStreamCount > 0 ){ bStatus=DownStreamCount|0x0100 ; } else{ bStatus=0; } setRxHDCPBStatus(bStatus); setRxHDCPCalcSHA(); } } else{ if(pre_tx_auth == 1) printk("[HDMIRX HDCP] TX none auth\n"); pre_tx_auth = 0; } } /*HDCP end*/ msleep(10); } }