void APP_HandleEvent(byte event) { switch(event) { case EVNT1_INIT: LED1_On(); WAIT1_Waitms(200); LED2_On(); WAIT1_Waitms(200); LED3_On(); WAIT1_Waitms(200); LED4_On(); WAIT1_Waitms(200); LED1_Off(); LED2_Off(); LED3_Off(); LED4_Off(); break; case EVNT1_SW1_PRESSED: LED1_On(); WAIT1_Waitms(200); LED1_Off(); break; case EVNT1_SW2_PRESSED: LED2_On(); WAIT1_Waitms(200); LED2_Off(); break; case EVNT1_SW3_PRESSED: LED3_On(); WAIT1_Waitms(200); LED3_Off(); break; case EVNT1_SW4_PRESSED: LED4_On(); WAIT1_Waitms(200); LED4_Off(); break; case EVNT1_SW1_LONG_PRESSED: LED1_On(); WAIT1_Waitms(500); LED1_Off(); break; case EVNT1_SW2_LONG_PRESSED: LED2_On(); WAIT1_Waitms(500); LED2_Off(); break; case EVNT1_SW3_LONG_PRESSED: LED3_On(); WAIT1_Waitms(500); LED3_Off(); break; case EVNT1_SW4_LONG_PRESSED: LED4_On(); WAIT1_Waitms(500); LED4_Off(); break; } /* switch */ }
/**************************************************************************** Function: void SetLEDs(BYTE setting) Summary: change the LED settings of the boards Description: change the LED settings of the boards Precondition: None Parameters: BYTE setting - bitmap for desired LED setting (1 = On, 0 = Off) bit 0 = LED 0 bit 1 = LED 1 bit 2 = LED 2 ... bit 7 = LED 7 Return Values: None Remarks: None ***************************************************************************/ static void SetLEDs(BYTE setting) { if((setting & 0x01) == 0x01) { LED0_On(); } else { LED0_Off(); } if((setting & 0x02) == 0x02) { LED1_On(); } else { LED1_Off(); } if((setting & 0x04) == 0x04) { LED2_On(); } else { LED2_Off(); } if((setting & 0x08) == 0x08) { LED3_On(); } else { LED3_Off(); } if((setting & 0x10) == 0x10) { LED4_On(); } else { LED4_Off(); } if((setting & 0x20) == 0x20) { LED5_On(); } else { LED5_Off(); } if((setting & 0x40) == 0x40) { LED6_On(); } else { LED6_Off(); } if((setting & 0x80) == 0x80) { LED7_On(); } else { LED7_Off(); } }
void USART1_IRQHandler(void) { if (USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) { //==SET uart1_data = USART_ReceiveData(USART1); if(i == '0'){ if (uart1_data =='a') i = uart1_data; else if(uart1_data =='d') i = uart1_data; else i = '0'; } else if(i == 'a'){ i = (uart1_data =='b') ? uart1_data : '0'; } else if(i == 'b'){ i = (uart1_data =='c') ? uart1_data : '0'; } else if(i == 'c'){ if (uart1_data =='3') i = uart1_data; else if(uart1_data =='4') i = uart1_data; else i = '0'; } else if(i == '3'){ if(uart1_data =='o') LED3_On(); else if(uart1_data =='f') LED3_Off(); i = '0'; } else if(i == '4'){ if(uart1_data =='o') LED4_On(); else if(uart1_data =='f') LED4_Off(); i = '0'; } else if(i == 'd'){ i = (uart1_data =='e') ? uart1_data : '0'; } else if(i == 'e'){ i = (uart1_data =='f') ? uart1_data : '0'; } else if(i == 'f'){ if(uart1_data =='3') LED3_Toggle(); else if(uart1_data =='4') LED4_Toggle(); i = '0'; } USART_SendData(USART1, i); } }
void APP_HandleEvent(byte event) { switch(event) { case EVNT1_INIT: LED1_On(); LED2_On(); LED3_On(); LED4_On(); WAIT1_Waitms(500); LED1_Off(); LED2_Off(); LED3_Off(); LED4_Off(); break; case EVNT1_BTN1_PRESSED: #if HAS_SOUND RTOS_StartSounder(300); #endif LED4_Neg(); SHELL_SendStr("SW1 pressed!\r\n"); break; case EVNT1_BTN2_PRESSED: #if HAS_SOUND RTOS_StartSounder(500); #endif LED5_Neg(); SHELL_SendStr("SW2 pressed!\r\n"); break; case EVNT1_BTN3_PRESSED: #if HAS_SOUND RTOS_StartSounder(700); #endif LED7_Neg(); SHELL_SendStr("SW3 pressed!\r\n"); break; case EVNT1_BTN4_PRESSED: #if HAS_SOUND RTOS_StartSounder(900); #endif LED8_Neg(); SHELL_SendStr("SW4 pressed!\r\n"); break; default: break; } /* switch */ }
void APP_Run(void) { int i; uint32_t val = 0; unsigned char buf[16]; Buzzer_SetRatio16(0xFFFF/2); /* 50% duty ratio */ for(;;) { while(CDC1_App_Task(cdc_buffer, sizeof(cdc_buffer))==ERR_BUSOFF) { /* device not enumerated */ LED1_Neg(); LED2_Off(); LED3_Neg(); LED4_Off(); WAIT1_Waitms(10); } LED1_Off(); LED2_Neg(); LED3_Off(); LED4_Neg(); if (CDC1_GetCharsInRxBuf()!=0) { i = 0; while( i<sizeof(in_buffer)-1 && CDC1_GetChar(&in_buffer[i])==ERR_OK ) { i++; } in_buffer[i] = '\0'; (void)CDC1_SendString((unsigned char*)"echo: "); (void)CDC1_SendString(in_buffer); UTIL1_strcpy(buf, sizeof(buf), (unsigned char*)"val: "); UTIL1_strcatNum32u(buf, sizeof(buf), val); UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"\r\n"); (void)CDC1_SendString(buf); val++; } else { WAIT1_Waitms(10); } } }
void main(void) { /* Write your local variable definition here */ /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/ PE_low_level_init(); /*** End of Processor Expert internal initialization. ***/ LED1_Neg(); WAIT1_Waitms(100); LED2_Neg(); WAIT1_Waitms(100); LED3_Neg(); WAIT1_Waitms(100); LED4_Neg(); WAIT1_Waitms(100); LED1_Off(); LED2_Off(); LED3_Off(); LED4_Off(); CDC_Run(); /*** Don't write any code pass this line, or it will be deleted during code generation. ***/ /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/ for(;;){} /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/ } /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
static portTASK_FUNCTION(TaskMain, pvParameters ) { byte i; #if PL_HAS_HW_LED byte cntr; #endif /* The parameters are not used. */ (void)pvParameters; #if PL_HAS_WATCHDOG WDOG_Clear(); #endif #if PL_HAS_HW_TOUCHSCREEN TouchScreen_CheckTouchScreenCalibrationData(); #endif BUZ_Init(); #if PL_HAS_UI APP_Init(); #endif #if PL_HAS_HW_LED cntr = 0; LED3_On(); LED4_Off(); #endif for(;;) { #if PL_HAS_HW_TOUCHSCREEN TCHS1_Scan(); #endif #if PL_POLL_KEYS2 KEY2_ScanKeys(); /* poll keys */ #endif i = 10; /* to avoid stalling */ while (EVNT1_EventsPending() && i>0) { EVNT1_HandleEvent(); i--; } #if PL_HAS_HW_LED cntr++; if (cntr == 10) { /* change LED's */ LED3_Neg(); LED4_Neg(); cntr = 0; } #endif #if PL_HAS_AUTO_DEMO #if PL_HAS_FONT_DEMO FRTOS1_vTaskDelay((2*1000)/portTICK_RATE_MS); APP_SetApplicationMode(APP_MODE_FONT_DEMO); FRTOS1_vTaskDelay((10*1000)/portTICK_RATE_MS); #endif #if PL_HAS_ACCEL_DEMO APP_SetApplicationMode(APP_MODE_ACCEL_DEMO); FRTOS1_vTaskDelay((15*1000)/portTICK_RATE_MS); ACCEL_StopAccelDemo(); FRTOS1_vTaskDelay((2*1000)/portTICK_RATE_MS); #endif #if 0 && PL_HAS_TETRIS_DEMO APP_SetApplicationMode(APP_MODE_TETRIS); FRTOS1_vTaskDelay((5*1000)/portTICK_RATE_MS); TETRIS_KillTask(); FRTOS1_vTaskDelay((2*1000)/portTICK_RATE_MS); #endif #if PL_HAS_CUBE_DEMO APP_SetApplicationMode(APP_MODE_3D_CUBE); FRTOS1_vTaskDelay((8*1000)/portTICK_RATE_MS); CUBE_CloseShipWindow(); FRTOS1_vTaskDelay((2*1000)/portTICK_RATE_MS); CUBE_CloseCubeWindow(); FRTOS1_vTaskDelay((2*1000)/portTICK_RATE_MS); #endif //APP_SetApplicationMode(APP_MODE_MAIN_MENU); //FRTOS1_vTaskDelay((5*1000)/portTICK_RATE_MS); heapSize = FRTOS1_xPortGetFreeHeapSize(); #endif FRTOS1_vTaskDelay(50/portTICK_RATE_MS); } /* for */ }
static void APP_EvntHandler(EVNT_Handle event) { switch (event) { case EVNT_INIT: LED1_On(); WAIT1_Waitms(100); LED1_Off(); break; #if PL_HAS_LED_HEARTBEAT case EVNT_LED_HEARTBEAT: LED3_Neg(); break; #endif #if PL_NOF_KEYS>=1 case EVNT_SW1_PRESSED: if (REF_IsCalibrated()) { STR_Start(); } break; case EVNT_SW1_LPRESSED: #if PL_HAS_LINE_SENSOR LED4_On(); WAIT1_Waitms(500); EVNT_SetEvent(EVNT_REF_START_STOP_CALIBRATION); DRV_Drive_Forward(40); WAIT1_Waitms(300); DRV_Drive_Forward(-60); WAIT1_Waitms(200); DRV_Drive_Forward(0); EVNT_SetEvent(EVNT_REF_START_STOP_CALIBRATION); WAIT1_Waitms(500); if (REF_IsCalibrated()) { LED4_Off(); } break; #endif break; #endif #if PL_NOF_KEYS>=2 case EVNT_SW2_PRESSED: LED2_Neg(); break; #endif #if PL_NOF_KEYS>=3 case EVNT_SW3_PRESSED: LED3_Neg(); break; #endif #if PL_NOF_KEYS>=4 case EVNT_SW4_PRESSED: LED4_Neg(); break; #endif default: break; } }