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); }
uint8_t chibiInit() { return chb_init(); }
void systemInit() { cpuInit(); systickInit((CFG_CPU_CCLK / 1000) * CFG_SYSTICK_DELAY_IN_MS); gpioInit(); pmuInit(); adcInit(); // Init adc pins to avoid wasting 60uA in deep sleep #ifdef CFG_PRINTF_UART // Initialise UART with the default baud rate (set in projectconfig.h) uartInit(CFG_UART_BAUDRATE); #endif // Switch to 3.3V if TPS780 (etc.) is being used #if defined CFG_VREG_ALT_PRESENT && CFG_VREG_ALT_PRESENT == 1 gpioSetDir(CFG_VREG_ALT_PORT, CFG_VREG_ALT_PIN, gpioDirection_Output); gpioSetValue(CFG_VREG_ALT_PORT, CFG_VREG_ALT_PIN, 0); gpioSetPullup(&CFG_VREG_ALT_REG32, gpioPullupMode_Inactive); #endif // Set LED pin as output and turn LED off gpioSetDir(CFG_LED_PORT, CFG_LED_PIN, 1); gpioSetValue(CFG_LED_PORT, CFG_LED_PIN, CFG_LED_OFF); // Initialise the ST7565 128x64 pixel display #ifdef CFG_ST7565 st7565Init(); st7565ClearScreen(); // Clear the screen st7565Backlight(1); // Enable the backlight #endif // Initialise the SSD1306 OLED display #ifdef CFG_SSD1306 ssd1306Init(SSD1306_SWITCHCAPVCC); ssd1306ClearScreen(); // Clear the screen #endif // Initialise EEPROM #ifdef CFG_I2CEEPROM mcp24aaInit(); #endif // Initialise Chibi #ifdef CFG_CHIBI // Write addresses to EEPROM for the first time if necessary // uint16_t addr_short = 0x1166; // uint64_t addr_ieee = addr_short; // mcp24aaWriteBuffer(CFG_CHIBI_EEPROM_SHORTADDR, (uint8_t *)&addr_short, 2); // mcp24aaWriteBuffer(CFG_CHIBI_EEPROM_IEEEADDR, (uint8_t *)&addr_ieee, 8); chb_init(); #endif // Setup SD Card #ifdef CFG_SDCARD // Turn off SD card by default (saves power) gpioSetDir(CFG_SDCARD_ENPORT, CFG_SDCARD_ENPIN, gpioDirection_Output); /* Set enable pin to output */ gpioSetValue(CFG_SDCARD_ENPORT, CFG_SDCARD_ENPIN, 0); /* Disable card by setting ENPIN low */ gpioSetPullup(&CFG_SDCARD_ENREG32, gpioPullupMode_Inactive); #endif #ifdef CFG_LM75B // Initialise LM75B lm75bInit(); // Read temp once to make sure we are in sleep mode int32_t temp; lm75bGetTemperature(&temp); #endif #ifdef CFG_BAT // Turn off battery voltage divider by default gpioSetDir(CFG_BAT_ENPORT, CFG_BAT_ENPIN, gpioDirection_Output ); // Set voltage divider enable pin to output gpioSetValue(CFG_BAT_ENPORT, CFG_BAT_ENPIN, 0 ); // Disable the voltage divider by default gpioSetPullup(&CFG_BAT_ENREG32, gpioPullupMode_Inactive); #endif // Start the command line interface (if requested) #ifdef CFG_INTERFACE printf("%sType '?' for a list of available commands%s", CFG_PRINTF_NEWLINE, CFG_PRINTF_NEWLINE); cmdInit(); #endif }