void RADIO_DataIndicationPacket(tRxPacket *sRxPacket) { if (sRxPacket->u8Status==SMAC1_TIMEOUT) { /* Put timeout condition code here */ LED1_Neg(); LED2_Neg(); /* indicator for bad or no communication */ EVNT_SetEvent(EVNT_RADIO_TIMEOUT); } else if (sRxPacket->u8Status == SMAC1_SUCCESS) { /* good packet received: handle it. */ if (RADIO_isSniffing) { QueueMessage(RADIO_QUEUE_MSG_SNIFF, (const char*)sRxPacket->pu8Data, sRxPacket->u8DataLength); } /* check if it is the packet we expect...*/ if ( RADIO_AppStatus==RADIO_WAITING_FOR_ACK && UTIL1_strncmp((char*)sRxPacket->pu8Data, RADIO_PREFIX_STR RADIO_ACK_STR, sizeof(RADIO_PREFIX_STR RADIO_ACK_STR)-1)==0 ) /* is it our acknowledge packet? */ { EVNT_SetEvent(EVNT_RADIO_ACK); } else if (UTIL1_strncmp((char*)sRxPacket->pu8Data, RADIO_PREFIX_STR, sizeof(RADIO_PREFIX_STR)-1)==0) { #if PL_HAS_REMOTE && PL_HAS_MOTOR /*! \todo Implement your own message handling */ if (UTIL1_strncmp((char*)sRxPacket->pu8Data, RADIO_PREFIX_STR REMOTE_ACCEL_PREFIX, sizeof(RADIO_PREFIX_STR REMOTE_ACCEL_PREFIX)-1)==0) { QueueMessage(RADIO_QUEUE_MSG_ACCEL, (const char*)sRxPacket->pu8Data, sRxPacket->u8DataLength); } #endif EVNT_SetEvent(EVNT_RADIO_DATA); } else { /* unknown packet? */ EVNT_SetEvent(EVNT_RADIO_UNKNOWN); } } else if (sRxPacket->u8Status==SMAC1_OVERFLOW) { /* received packet, but it was longer than what we expect. */ EVNT_SetEvent(EVNT_RADIO_OVERFLOW); LED1_Neg(); LED2_Neg(); /* indicator for bad or no communication */ } }
void loop(void) { static int cntr = 0; uint8_t buffer[32]; if (device.available()) { // Should be a message for us now uint8_t buf[RH_APP_MAX_MESSAGE_LEN]; uint8_t len = sizeof(buf); if (device.recv(buf, &len)) { LED2_Neg(); cntr++; UTIL1_Num32uToStr(buffer, sizeof(buffer), cntr); UTIL1_strcat(buffer, sizeof(buffer), (const unsigned char*)": "); Serial_print((const char*)buffer); Serial_print("got request: "); Serial_println((char*)buf); // Send a reply uint8_t data[] = "And hello back to you"; device.send(data, sizeof(data)); device.waitPacketSent(); Serial_println("Sent a reply"); } else { Serial_println("recv failed"); } } }
static void CDC_Run(void) { int i; for(;;) { while(CDC1_App_Task(cdc_buffer, sizeof(cdc_buffer))==ERR_BUSOFF) { /* device not enumerated */ LED1_Neg(); LED2_Off(); // WAIT1_Waitms(1); /* just give back some CPU time. S08JM60 does not allow much spare time here! */ } LED1_Off(); LED2_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); (void)CDC1_SendString((unsigned char*)"\r\n"); } else { //WAIT1_Waitms(5); } } }
/*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. ***/ /* Write your code here */ #if 0 for(;;) { LED1_Neg(); WAIT1_Waitms(100); LED2_Neg(); WAIT1_Waitms(100); LED3_Neg(); WAIT1_Waitms(100); } #else APP_Start(); #endif /* For example: for(;;) { } */ /*** 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!!! ***/
static void CDC_Run(void) { int i; SendStr((unsigned char*)"Hello World to Kinetis SCI3!\r\n"); for(;;) { while(CDC1_App_Task(cdc_buffer, sizeof(cdc_buffer))==ERR_BUSOFF) { /* device not enumerated */ LED1_Neg(); LED2_Off(); // WAIT1_Waitms(1); /* just give back some CPU time. */ SendStr((unsigned char*)"waiting to enumerate...\r\n"); } LED1_Off(); LED2_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); (void)CDC1_SendString((unsigned char*)"\r\n"); SendStr((unsigned char*)"echo to SCI3: "); SendStr(in_buffer); SendStr((unsigned char*)"\r\n"); } else { // WAIT1_Waitms(5); } } }
/*! * \brief LED test routine. * This routine tests if: * - we can turn the LEDs properly on and off * - if we can negate them * - if we can set an LED value * - if we can get the LED value * If the test fails, the program will hanging in an endless loop */ void LED_Test(void) { bool isOn = TRUE; LED1_On(); LED2_On(); LED3_On(); LED1_Off(); LED2_Off(); LED3_Off(); LED1_Neg(); LED2_Neg(); LED3_Neg(); LED1_On(); /* if (!LED1_Get()) { LED3_Off(); } LED1_Off(); if (LED1_Get()) { for(;;){}; /* error } LED1_Put(isOn); if (!LED1_Get()) { for(;;){}; /* error } */ }
static portTASK_FUNCTION(Task2, pvParameters) { (void)pvParameters; /* parameter not used */ for(;;) { LED2_Neg(); FRTOS1_vTaskDelay(200/portTICK_RATE_MS); } }
void APP_Run(void) { int i; uint32_t val = 0; unsigned char buf[16]; for(;;) { while(CDC1_App_Task(cdc_buffer, sizeof(cdc_buffer))==ERR_BUSOFF) { /* device not enumerated */ LED1_Neg(); LED2_Off(); WAIT1_Waitms(10); } LED1_Off(); LED2_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 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 }
static void CDC_Run(void) { int i; for(;;) { while(CDC1_App_Task(cdc_buffer, sizeof(cdc_buffer))==ERR_BUSOFF) { /* device not enumerated */ LED1_Neg(); LED2_Off(); WAIT1_Waitms(10); } LED1_Off(); LED2_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); (void)CDC1_SendString((unsigned char*)"\r\n"); } else { WAIT1_Waitms(10); } } }
static portTASK_FUNCTION(BlinkTask, pvParameters) { (void)pvParameters; /* not used */ for(;;) { LED2_Neg(); FRTOS1_vTaskDelay(1000/portTICK_RATE_MS); } /* for */ }
static portTASK_FUNCTION(ShellTask, pvParameters) { unsigned char buf[48]; (void)pvParameters; /* not used */ buf[0] = '\0'; (void)CLS1_ParseWithCommandTable((unsigned char*)CLS1_CMD_HELP, CLS1_GetStdio(), CmdParserTable); for(;;) { (void)CLS1_ReadAndParseWithCommandTable(buf, sizeof(buf), CLS1_GetStdio(), CmdParserTable); FRTOS1_vTaskDelay(50/portTICK_RATE_MS); LED2_Neg(); } }
/** * \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 */ }
static portTASK_FUNCTION(ShellTask, pvParameters) { unsigned char cmd_buf[32]; (void)pvParameters; FSSH1_Init(); cmd_buf[0] = '\0'; (void)FSSH1_ParseCommand((const unsigned char*)FSSH1_CMD_HELP, FSSH1_GetStdio(), ParseCommand); for(;;) { (void)FSSH1_ReadAndParseLine(cmd_buf, sizeof(cmd_buf), FSSH1_GetStdio(), ParseCommand /* local cmd parser */); FRTOS1_vTaskDelay(50/portTICK_RATE_MS); LED2_Neg(); } }
static portTASK_FUNCTION(vSlaveTask2, pvParameters) { /*! \todo Implement functionality */ xSemaphoreHandle sem; sem = (xSemaphoreHandle)pvParameters; for(;;) { if (sem != NULL) { if (FRTOS1_xSemaphoreTake(sem, portMAX_DELAY)==pdTRUE) { LED2_Neg(); } } FRTOS1_vTaskDelay(2000/portTICK_RATE_MS); } }
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 void DiskTest(void) { CLS1_ConstStdIOTypePtr io; io = CLS1_GetStdio(); FAT1_Init(); CLS1_SendStr((unsigned char*)"Waiting for disk to be inserted...\r\n", io->stdOut); while(!FAT1_isDiskPresent()) { /* wait until card is present */ } CLS1_SendStr((unsigned char*)"Mounting File system...\r\n", io->stdOut); FAT1_mount(0, &fileSystemObject); /* mount file system */ (void)Test(io); CLS1_SendStr((unsigned char*)"Finished test...\r\n", io->stdOut); for(;;) { LED2_Neg(); WAIT1_Waitms(100); } }
static portTASK_FUNCTION(USBTask, pvParameters) { static uint8_t cdc_buffer[USB1_DATA_BUFF_SIZE]; uint8_t cntr = 0; (void)pvParameters; /* unused */ USB1_Init(); /* have Init of USB1 component disabled during Startup! */ for(;;) { while(CDC1_App_Task(cdc_buffer, sizeof(cdc_buffer))==ERR_BUSOFF) { /* device not enumerated */ FRTOS1_vTaskDelay(50/portTICK_RATE_MS); LED2_Off(); } cntr++; if ((cntr%16)==0) { LED2_Neg(); } FRTOS1_vTaskDelay(20/portTICK_RATE_MS); } }
static void CDC_Run(void) { int i, cnt = 0; uint32_t val = 0; unsigned char buf[16]; (void)CDC1_SendString((unsigned char*)"Hello world from the KL25Z with USB CDC\r\n"); for(;;) { while(CDC1_App_Task(cdc_buffer, sizeof(cdc_buffer))==ERR_BUSOFF) { /* device not enumerated */ LED1_Neg(); LED2_Off(); WAIT1_Waitms(10); cnt++; if (cnt==100) { LED3_Neg(); cnt = 0; } } LED1_Off(); LED2_Neg(); LED3_Off(); 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); cnt++; if ((cnt%1024)==0) { /* from time to time, write some text */ (void)CDC1_SendString((unsigned char*)"Type some text and it will echo.\r\n"); } } } }
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 */}
static void AppTask(void* param) { const int *whichLED = (int*)param; //(void)param; /* avoid compiler warning */ for(;;) { if (*whichLED==1) { LED1_Neg(); } else if (*whichLED==2) { LED2_Neg(); } #if PL_CONFIG_HAS_KEYS KEY_Scan(); #endif #if PL_CONFIG_HAS_EVENTS EVNT_HandleEvent(APP_EventHandler, TRUE); #endif //FRTOS1_vTaskDelay(500/portTICK_PERIOD_MS); FRTOS1_vTaskDelay(pdMS_TO_TICKS(500)); } }
static void TestFlash(void) { //IFsh1_Init(); LED3_On(); WAIT1_Waitms(500); #if 1 if (IFsh1_EraseSector(FLASH_ADDR)!=ERR_OK) { for(;;) { LED1_Neg(); WAIT1_Waitms(50); } } if (IFsh1_SetBlockFlash(&data[0], FLASH_ADDR, sizeof(data))!=ERR_OK) { for(;;) { LED2_Neg(); WAIT1_Waitms(100); } } #endif LED3_Off(); }
static uint8_t RNETA_HandleRxMessage(RAPP_MSG_Type type, uint8_t size, uint8_t *data, RNWK_ShortAddrType srcAddr, bool *handled, RPHY_PacketDesc *packet) { uint8_t val; (void)srcAddr; (void)packet; switch(type) { case RAPP_MSG_TYPE_DATA: /* <type><size><data */ *handled = TRUE; val = *data; /* get data from packet */ if (val==1) { LED1_Neg(); } else if (val==2) { LED2_Neg(); } else if (val==3) { // LED3_Neg(); } return ERR_OK; default: break; } /* switch */ return ERR_OK; }
static portTASK_FUNCTION(ShellTask, pvParameters) { #if PL_HAS_SD_CARD bool cardMounted = FALSE; static FAT1_FATFS fileSystemObject; #endif unsigned char buf[48]; (void)pvParameters; /* not used */ buf[0] = '\0'; (void)CLS1_ParseWithCommandTable((unsigned char*)CLS1_CMD_HELP, CLS1_GetStdio(), CmdParserTable); #if PL_HAS_SD_CARD FAT1_Init(); #endif for(;;) { #if PL_HAS_SD_CARD (void)FAT1_CheckCardPresence(&cardMounted, 0 /* volume */, &fileSystemObject, CLS1_GetStdio()); #endif (void)CLS1_ReadAndParseWithCommandTable(buf, sizeof(buf), CLS1_GetStdio(), CmdParserTable); FRTOS1_vTaskDelay(50/portTICK_RATE_MS); LED2_Neg(); } }
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) { int i; FDisp1_PixelDim x, y; LCD1_Init(); LCD1_Clear(); #if 1 GDisp1_DrawFilledBox(0, 0, GDisp1_GetWidth()-1, GDisp1_GetHeight()-1, LCD1_COLOR_WHITE); GDisp1_UpdateFull(); GDisp1_DrawFilledBox(0, 0, GDisp1_GetWidth()-1, GDisp1_GetHeight()-1, LCD1_COLOR_RED); GDisp1_UpdateFull(); GDisp1_DrawFilledBox(0, 0, GDisp1_GetWidth()-1, GDisp1_GetHeight()-1, LCD1_COLOR_GREEN); GDisp1_UpdateFull(); GDisp1_DrawFilledBox(0, 0, GDisp1_GetWidth()-1, GDisp1_GetHeight()-1, LCD1_COLOR_BLUE); GDisp1_UpdateFull(); GDisp1_Clear(); GDisp1_UpdateFull(); GDisp1_DrawFilledBox(0, 0, 128, 128, LCD1_COLOR_RED); GDisp1_UpdateFull(); GDisp1_DrawFilledBox(0, 0, 50, 10, LCD1_COLOR_YELLOW); GDisp1_UpdateFull(); LCD1_SetDisplayOrientation(LCD1_ORIENTATION_PORTRAIT); GDisp1_DrawFilledBox(0, 0, 100, 20, LCD1_COLOR_YELLOW); GDisp1_UpdateFull(); x = 0; y = 0; FDisp1_WriteString("Portrait", LCD1_COLOR_RED, &x, &y, Helv14_GetFont()); GDisp1_UpdateFull(); LCD1_SetDisplayOrientation(LCD1_ORIENTATION_LANDSCAPE); GDisp1_DrawFilledBox(0, 0, 100, 20, LCD1_COLOR_ORANGE); x = 0; y = 0; FDisp1_WriteString("Landscape", LCD1_COLOR_GREEN, &x, &y, Helv14_GetFont()); GDisp1_UpdateFull(); LCD1_SetDisplayOrientation(LCD1_ORIENTATION_PORTRAIT180); GDisp1_DrawFilledBox(0, 0, 100, 20, LCD1_COLOR_RED); x = 0; y = 0; FDisp1_WriteString("Portrait180", LCD1_COLOR_BLUE, &x, &y, Helv14_GetFont()); GDisp1_UpdateFull(); LCD1_SetDisplayOrientation(LCD1_ORIENTATION_LANDSCAPE180); GDisp1_DrawFilledBox(0, 0, 100, 20, LCD1_COLOR_BRIGHT_GREEN); x = 0; y = 0; FDisp1_WriteString("Landscape180", LCD1_COLOR_WHITE, &x, &y, Helv14_GetFont()); GDisp1_UpdateFull(); #if 0 LCD1_OpenWindow(0, 0, (LCD1_PixelDim)(LCD1_GetWidth()-1), (LCD1_PixelDim)(LCD1_GetHeight()-1)); /* window for whole display */ for(i=0;i<500;i++) { LCD1_WriteDataWord(LCD1_COLOR_YELLOW); } LCD1_CloseWindow(); #endif LCD1_Clear(); LCD1_SetDisplayOrientation(LCD1_ORIENTATION_PORTRAIT); GDisp1_DrawLine(0, 0, 10, 50, LCD1_COLOR_RED); GDisp1_UpdateFull(); LCD1_SetDisplayOrientation(LCD1_ORIENTATION_LANDSCAPE); GDisp1_DrawLine(0, 0, 10, 50, LCD1_COLOR_GREEN); GDisp1_UpdateFull(); LCD1_SetDisplayOrientation(LCD1_ORIENTATION_LANDSCAPE180); GDisp1_DrawLine(0, 0, 10, 50, LCD1_COLOR_BLUE); GDisp1_UpdateFull(); LCD1_SetDisplayOrientation(LCD1_ORIENTATION_PORTRAIT180); GDisp1_DrawLine(0, 0, 10, 50, LCD1_COLOR_WHITE); LCD1_Clear(); //GDisp1_DrawFilledBox(0, 0, 20, 40, LCD1_COLOR_WHITE); LCD1_SetDisplayOrientation(LCD1_ORIENTATION_PORTRAIT180); GDisp1_DrawFilledBox(0, 0, 20, 40, LCD1_COLOR_RED); GDisp1_UpdateFull(); LCD1_SetDisplayOrientation(LCD1_ORIENTATION_LANDSCAPE); GDisp1_DrawFilledBox(0, 0, 20, 40, LCD1_COLOR_GREEN); GDisp1_UpdateFull(); LCD1_SetDisplayOrientation(LCD1_ORIENTATION_LANDSCAPE180); GDisp1_DrawFilledBox(0, 0, 20, 40, LCD1_COLOR_BLUE); GDisp1_UpdateFull(); GDisp1_DrawFilledBox(50, 50, 20, 30, LCD1_COLOR_RED); GDisp1_DrawFilledBox(0, 0, 96, 96, LCD1_COLOR_BLUE); GDisp1_DrawBox(0, 0, GDisp1_GetWidth(), GDisp1_GetHeight(), 1, LCD1_COLOR_GREEN); x = 0; y = 0; FDisp1_WriteString("Hello", LCD1_COLOR_GREEN, &x, &y, Helv14_GetFont()); GDisp1_UpdateFull(); float f = sin(f+1); EYES_Init(); for(;;) { EYES_Run(); // SpeedTest(); LED1_Neg(); WAIT1_Waitms(100); LED2_Neg(); WAIT1_Waitms(100); LED3_Neg(); WAIT1_Waitms(100); } #endif }
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 void APP_EventHandler(EVNT_Handle event) { #if PL_HAS_LINE_SENSOR #endif static uint16_t buzzer = 1000; switch(event){ case EVNT_INIT: LED1_On(); WAIT1_Waitms(100); LED1_Off(); #if PL_HAS_BUZZER BUZ_Beep(1000,400); #endif break; case EVNT_HEARTBEAT: //LED1_Off(); break; case EVNT_SW_A_RELEASED: //BUZ_Beep(2000,2000); break; case EVNT_SW_A_PRESSED: #if PL_HAS_BUZZER BUZ_Beep(1000,10); #if PL_HAS_BATTLE BATTLE_changeState(BATTLE_STATE_WAIT); #endif /* PL_HAS_BATTLE */ #endif break; case EVNT_SW_A_LPRESSED: #if PL_HAS_LINE_SENSOR LED1_Neg(); EVNT_SetEvent(EVNT_REF_START_STOP_CALIBRATION); #endif break; case EVNT_SW_B_PRESSED: LED2_Neg(); LED3_Neg(); #if PL_HAS_SHELL CLS1_SendStr("SW B pressed\n",CLS1_GetStdio()->stdOut); #endif break; case EVNT_SW_C_PRESSED: LED1_Neg(); LED2_Neg(); #if PL_HAS_SHELL CLS1_SendStr("SW C pressed\n",CLS1_GetStdio()->stdOut); #endif break; case EVNT_SW_D_PRESSED: LED1_Neg(); #if PL_HAS_SHELL CLS1_SendStr("SW D pressed\n",CLS1_GetStdio()->stdOut); #endif break; case EVNT_SW_E_PRESSED: LED2_Neg(); #if PL_HAS_SHELL CLS1_SendStr("SW E pressed\n",CLS1_GetStdio()->stdOut); #endif break; case EVNT_SW_F_PRESSED: LED3_Neg(); #if PL_HAS_SHELL CLS1_SendStr("SW F pressed\n",CLS1_GetStdio()->stdOut); #endif break; case EVNT_SW_G_PRESSED: LED1_Neg(); LED2_Neg(); LED3_Neg(); #if PL_HAS_SHELL CLS1_SendStr("SW g pressed\n",CLS1_GetStdio()->stdOut); #endif break; case EVNT_REF_START_STOP_CALIBRATION: break; default: break; } }
void APP_Run(void) { int cnt=0; /* counter to slow down LED blinking */ uint8_t res; int16_t xyz[3]; #if 0 res = MMA1_Init(); if (res!=ERR_OK) { Err(); } res = MMA1_SetFastMode(FALSE); if (res!=ERR_OK) { Err(); } res = MMA1_Enable(); /* enable accelerometer */ if (res!=ERR_OK) { Err(); } #endif for(;;) { WAIT1_Waitms(10); #if 0 /* implement 'air-mouse' movement */ xyz[0] = MMA1_GetX(); xyz[1] = MMA1_GetY(); xyz[3] = MMA1_GetZ(); /* y axis */ if (xyz[1]>AIR_THRESHOLD) { (void)HIDK2_Move(0, 2); /* moving the cursor left */ } else if (xyz[1]<-AIR_THRESHOLD) { (void)HIDK2_Move(0, -2); /* moving the cursor right */ } /* x axis */ if (xyz[0]>AIR_THRESHOLD) { (void)HIDK2_Move(-2, 0); /* moving the cursor up */ } else if (xyz[0]<-AIR_THRESHOLD) { (void)HIDK2_Move(2, 0); /* moving the cursor down */ } #endif cnt++; if (HIDM1_App_Task()==ERR_BUSOFF) { if ((cnt%128)==0) { /* just slow down blinking */ LED1_Neg(); /* red LED */ LED2_Off(); } } else { if ((cnt%128)==0) { /* just slow down blinking */ LED1_Off(); LED2_Neg(); /* green LED */ } if (SW2_GetVal()==0) { /* button pressed */ WAIT1_Waitms(100); /* wait for debouncing */ if (SW2_GetVal()==0) { /* still pressed */ //(void)HIDK2_Send(0, 8, 8); /* raw move message */ //(void)HIDK2_Send(HIDK2_MOUSE_LEFT, 0, 0); /* send left mouse button */ //(void)HIDK2_Send(0, 0, 0); /* send release button message */ //(void)HIDK2_Move(-8, 0); /* moving the cursor up */ //HIDK2_Click(HIDK2_MOUSE_LEFT); /* left mouse click */ HIDM1_Click(HIDM1_MOUSE_RIGHT); /* right mouse click */ } while(SW2_GetVal()==0) {} /* wait until button is released */ } if (SW3_GetVal()==0) { /* button pressed */ WAIT1_Waitms(100); /* wait for debouncing */ if (SW3_GetVal()==0) { /* still pressed */ HIDM1_Click(HIDM1_MOUSE_LEFT); /* left mouse click */ } while(SW3_GetVal()==0) {} /* wait until button is released */ } } } }