static void APP_HandleEvent(EVNT_Handle event) { switch(event) { case EVNT_INIT: LED1_On(); WAIT1_Waitms(500); LED1_Off(); break; #if PL_NOF_KEYS>=1 case EVNT_SW1_PRESSED: LED1_Neg(); #if PL_HAS_BUZZER (void)BUZ_Beep(300, 500); #endif #if PL_HAS_REMOTE if (REMOTE_GetOnOff()) { REMOTE_SetOnOff(FALSE); } else { REMOTE_SetOnOff(TRUE); } #endif break; #endif #if PL_NOF_KEYS>=2 case EVNT_SW2_PRESSED: LED2_Neg(); #if PL_HAS_REMOTE && PL_APP_ACCEL_CONTROL_SENDER //(void)RSTDIO_SendToTxStdio(RSTDIO_QUEUE_TX_IN, "buzzer buz 800 400\r\n", sizeof("buzzer buz 800 400\r\n")-1); #endif 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 #if PL_HAS_LED_HEARTBEAT case EVNT_LED_HEARTBEAT: LED4_Neg(); break; #endif default: #if PL_HAS_RADIO //RADIO_AppHandleEvent(event); #endif break; } }
static portTASK_FUNCTION(Task4, pvParameters) { (void)pvParameters; /* parameter not used */ for(;;) { LED4_Neg(); FRTOS1_vTaskDelay(800/portTICK_RATE_MS); } }
/*lint -save -e970 Disable MISRA rule (6.3) checking. */ int main(void) /*lint -restore Enable MISRA rule (6.3) checking. */ { /* 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(200); LED2_Neg(); WAIT1_Waitms(200); LED3_Neg(); WAIT1_Waitms(200); LED4_Neg(); WAIT1_Waitms(200); CDC_Run(); /*** Don't write any code pass this line, or it will be deleted during code generation. ***/ /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/ #ifdef PEX_RTOS_START PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */ #endif /*** End of RTOS startup code. ***/ /*** 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!!! ***/
void APP_Run(void) { LED1_Neg(); LED2_Neg(); LED3_Neg(); LED4_Neg(); DiskTest(); }
void APP_Start(void) { LED1_Neg(); LED2_Neg(); LED3_Neg(); LED4_Neg(); LED5_Neg(); LED6_Neg(); LED7_Neg(); LED8_Neg(); if (FRTOS1_xTaskCreate( MainTask, /* pointer to the task */ (unsigned char *)"Main", /* task name for kernel awareness debugging */ configMINIMAL_STACK_SIZE, /* task stack size */ (void*)NULL, /* optional task startup argument */ tskIDLE_PRIORITY+1, /* initial priority */ (xTaskHandle*)NULL /* optional task handle to create */ ) != pdPASS) { /*lint -e527 */ for(;;){} /* error! probably out of memory */ /*lint +e527 */ } FRTOS1_vTaskStartScheduler(); #if 0 for(;;) { LED1_Neg(); WAIT1_Waitms(200); } #endif }
/** * \brief FreeRTOS task */ static portTASK_FUNCTION(MyTask, pvParameters) { (void)pvParameters; /* parameter not used */ for(;;) { LED1_Neg(); FRTOS1_vTaskDelay(100/portTICK_RATE_MS); LED2_Neg(); FRTOS1_vTaskDelay(100/portTICK_RATE_MS); LED3_Neg(); FRTOS1_vTaskDelay(100/portTICK_RATE_MS); LED4_Neg(); FRTOS1_vTaskDelay(100/portTICK_RATE_MS); } /* for */ }
void LCD_Run(void) { GDisp1_PixelDim x, y; short xOffset, yOffset; GDisp1_PixelColor color; unsigned char line; D4DLCDHW_Init_Flexbus_16b(); LCD1_Init(); GDisp1_DrawFilledBox(0, 0, GDisp1_GetWidth(), GDisp1_GetHeight(), GDisp1_COLOR_WHITE); color = GDisp1_COLOR_BLUE; yOffset = xOffset = OFFSET; x = y = 0; line = 1; for(;;) { /* toggle the LED's */ LED2_Neg(); LED3_Neg(); LED4_Neg(); /* show graphic routines */ GDisp1_DrawBox(x, y, BOX_WIDTH, BOX_HEIGHT, 2, color); if (x>GDisp1_GetWidth()-BOX_WIDTH) { xOffset = -xOffset; } if (y>GDisp1_GetHeight()-BOX_HEIGHT) { yOffset = -yOffset; } color++; /* iterate through color */ x += xOffset; y += yOffset; /* draw some text */ PrintTouchText(line); line++; if (line>10) { /* clear text area */ line = 1; GDisp1_DrawFilledBox(0, 0, 150, 160, color); } /* handling touch screen */ TCHS1_Scan(); /* this will call TCHS1_OnEvent() */ } /* for */}
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!!! ***/
void APP_Run(void) { uint16_t i; for(i=0;i<16;i++) { LED1_Neg(); LED2_Neg(); LED3_Neg(); LED4_Neg(); WAIT1_Waitms(50); } SHELL_Init(); if (FRTOS1_xTaskCreate( Task1, /* pointer to the task */ "Task1", /* task name for kernel awareness debugging */ configMINIMAL_STACK_SIZE, /* task stack size */ (void*)NULL, /* optional task startup argument */ tskIDLE_PRIORITY, /* initial priority */ (xTaskHandle*)NULL /* optional task handle to create */ ) != pdPASS) { /*lint -e527 */ for(;;){}; /* error! probably out of memory */ /*lint +e527 */ } if (FRTOS1_xTaskCreate( Task2, /* pointer to the task */ "Task2", /* task name for kernel awareness debugging */ configMINIMAL_STACK_SIZE, /* task stack size */ (void*)NULL, /* optional task startup argument */ tskIDLE_PRIORITY, /* initial priority */ (xTaskHandle*)NULL /* optional task handle to create */ ) != pdPASS) { /*lint -e527 */ for(;;){}; /* error! probably out of memory */ /*lint +e527 */ } if (FRTOS1_xTaskCreate( Task3, /* pointer to the task */ "Task3", /* task name for kernel awareness debugging */ configMINIMAL_STACK_SIZE, /* task stack size */ (void*)NULL, /* optional task startup argument */ tskIDLE_PRIORITY, /* initial priority */ (xTaskHandle*)NULL /* optional task handle to create */ ) != pdPASS) { /*lint -e527 */ for(;;){}; /* error! probably out of memory */ /*lint +e527 */ } if (FRTOS1_xTaskCreate( Task4, /* pointer to the task */ "Task4", /* task name for kernel awareness debugging */ configMINIMAL_STACK_SIZE, /* task stack size */ (void*)NULL, /* optional task startup argument */ tskIDLE_PRIORITY, /* initial priority */ (xTaskHandle*)NULL /* optional task handle to create */ ) != pdPASS) { /*lint -e527 */ for(;;){}; /* error! probably out of memory */ /*lint +e527 */ } FRTOS1_vTaskStartScheduler(); }
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_LedBlink(void) { LED4_Neg(); TRG1_AddTrigger(TRG1_LED_BLINK, 100, APP_LedBlink); }
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; } }