int main(void) { uint32_t currentSecond, lastSecond; currentSecond = lastSecond = 0; /* Configure the HW */ boardInit(); #if defined CFG_CMSIS_RTOS tid_blinkthread = osThreadCreate(osThread(blink_thread), NULL); tid_mainthread = osThreadGetId(); for (;;) { osDelay(1000); boardLED((currentSecond++) & 1); } #endif while (1) { currentSecond = delayGetSecondsActive(); if (currentSecond != lastSecond) { lastSecond = currentSecond; /* Blinky */ boardLED(lastSecond % 2); } /* Poll for CLI input if CFG_INTERFACE is enabled */ #ifdef CFG_INTERFACE cliPoll(); #endif } }
void boardInit(void) { SystemCoreClockUpdate(); delayInit(); GPIOInit(); #ifdef CFG_PRINTF_UART uartInit(CFG_UART_BAUDRATE); #endif /* Set user LED pin to output and disable it */ LPC_GPIO->DIR[CFG_LED_PORT] |= (1 << CFG_LED_PIN); boardLED(CFG_LED_OFF); /* Start Chibi */ #ifdef CFG_CHIBI /* You may need to write a new address to EEPROM if it doesn't exist */ // uint16_t nodeaddr = 0xCAFE; // uint64_t ieeeaddr = 0x123456780000CAFE; // writeEEPROM((uint8_t*)CFG_EEPROM_CHIBI_NODEADDR, (uint8_t*)&nodeaddr, sizeof(nodeaddr)); // writeEEPROM((uint8_t*)CFG_EEPROM_CHIBI_IEEEADDR, (uint8_t*)&ieeeaddr, sizeof(ieeeaddr)); chb_init(); #endif /* Initialise USB */ #ifdef CFG_USB delay(500); usb_init(); #endif /* Initialise the LCD if requested */ #ifdef CFG_TFTLCD lcdInit(); #endif /* Start the command line interface */ #ifdef CFG_INTERFACE cliInit(); #endif /* Initialise the CC3000 WiFi module and connect to an AP */ #ifdef CFG_CC3000 /* Setup the CC3000 pins */ LPC_IOCON ->TRST_PIO0_14 &= ~0x07; LPC_IOCON ->TRST_PIO0_14 |= 0x01; LPC_IOCON ->PIO0_17 &= ~0x07; LPC_IOCON ->PIO0_16 &= ~0x1F; LPC_IOCON ->PIO0_16 |= (1<<4); #endif /* Turn the user LED on after init to indicate that everything is OK */ boardLED(CFG_LED_ON); }
void boardInit(void) { SystemCoreClockUpdate(); delayInit(); GPIOInit(); #ifdef CFG_PRINTF_UART uartInit(CFG_UART_BAUDRATE); #endif /* Set user LED pin to output and disable it */ LPC_GPIO->DIR[CFG_LED_PORT] |= (1 << CFG_LED_PIN); boardLED(CFG_LED_OFF); /* Start Chibi */ #ifdef CFG_CHIBI /* You may need to write a new address to EEPROM if it doesn't exist */ // uint16_t nodeaddr = 0xCAFE; // uint64_t ieeeaddr = 0x123456780000CAFE; // writeEEPROM((uint8_t*)CFG_EEPROM_CHIBI_NODEADDR, (uint8_t*)&nodeaddr, sizeof(nodeaddr)); // writeEEPROM((uint8_t*)CFG_EEPROM_CHIBI_IEEEADDR, (uint8_t*)&ieeeaddr, sizeof(ieeeaddr)); chb_init(); #endif /* Initialise USB */ #ifdef CFG_USB delay(500); usb_init(); #endif /* Initialise the LCD if requested */ #ifdef CFG_TFTLCD lcdInit(); #endif /* Start the command line interface */ #ifdef CFG_INTERFACE cliInit(); #endif /* Start CC3000 WiFi Module */ #ifdef CFG_CC3000 // ToDo: Make sure CC3000 pins are multiplexed to the correct function // since the init code only sets gpio dir, etc. // ToDo: Init anything else required for the CC3000! #endif /* Turn the user LED on after init to indicate that everything is OK */ boardLED(CFG_LED_ON); }
static void blinky_handler(void * p_context) { static bool led_on = false; led_on = !led_on; boardLED(led_on ? BIT(CFG_LED_CONNECTION) : 0, led_on ? 0 : BIT(CFG_LED_CONNECTION) ); }
void main_thread(void const *argument) { uint32_t currentSecond, lastSecond; currentSecond = lastSecond = 0; for (;;) { osDelay(1000); boardLED((currentSecond++) & 1); } }
int main(void) { uint32_t currentSecond, lastSecond; currentSecond = lastSecond = 0; /* Configure the HW */ boardInit(); while (1) { /* Blinky (1Hz) */ currentSecond = delayGetSecondsActive(); if (currentSecond != lastSecond) { lastSecond = currentSecond; boardLED(lastSecond % 2); } /* Check for binary protocol input if CFG_PROTOCOL is enabled */ #ifdef CFG_PROTOCOL prot_task(NULL); #endif /* Poll for CLI input if CFG_INTERFACE is enabled */ #ifdef CFG_INTERFACE cliPoll(); #endif // if ( usb_custom_is_ready_to_send() ) // { // static uint32_t magic_number = 0; // uint32_t buffer[2][16]; // 2x64 byte in size // buffer[0][0] = magic_number++; // buffer[1][0] = magic_number++; // usb_custom_send(buffer, 64*2); // } // // if (custom_recv_magic_number != 0) // { // printf("%d\n", custom_recv_magic_number); // custom_recv_magic_number = 0; // } /* Optionally enter high level sleep mode here via WFI */ } }
int main(void) { uint32_t currentSecond, lastSecond; currentSecond = lastSecond = 0; /* Run project-specific 'main' loop (as defined in projectconfig.h) */ boardMain(); /* If we ever come back from boardMain() just do blinky */ while (1) { currentSecond = systickGetSecondsActive(); if (currentSecond != lastSecond) { lastSecond = currentSecond; /* Toggle LED once per second */ boardLED(lastSecond % 2); } } return 0; }