X-Git-Url: https://git.rohieb.name/hackover2013-badge-firmware.git/blobdiff_plain/1cca029c8d64a4c55cc146c331c41f04735c7c8f..adf69ed4aa95d022041388b89a40ecdeb401c4fd:/badge/init.c diff --git a/badge/init.c b/badge/init.c index bb49df1..7f9cec1 100644 --- a/badge/init.c +++ b/badge/init.c @@ -1,4 +1,5 @@ #include "init.h" +#include "backlight.h" #include "pinconfig.h" #include "util/util.h" #include "ui/display.h" @@ -6,60 +7,37 @@ #include #include -static void badge_init_backlight(void) { - HOB_SET_PIN_FUNC(HOB_LCD_BACKLIGHT, CLKOUT); - - wdtInit(false); - SCB_CLKOUTCLKSEL = SCB_MAINCLKSEL_SOURCE_WDTOSC; - SCB_CLKOUTCLKUEN = SCB_CLKOUTCLKUEN_DISABLE; - SCB_CLKOUTCLKUEN = SCB_CLKOUTCLKUEN_UPDATE; - SCB_CLKOUTCLKDIV = 30; -} - void badge_init(void) { -#define INPUT_PIN_CONFIG(spec, mode) do { \ - HOB_SET_PIN_FUNC(spec, GPIO); \ - gpioSetDir(HOB_PORT(spec), HOB_PIN(spec), gpioDirection_Input); \ - gpioSetPullup(&HOB_IOCON(spec), (mode)); \ +#define INPUT_PIN_CONFIG(spec, mode) do { \ + HOB_SET_PIN_FUNC(spec, GPIO); \ + gpioSetDir(HOB_PORT(spec), HOB_PIN(spec), gpioDirection_Input); \ + gpioSetPullup(&HOB_IOCON(spec), (mode)); \ } while(0) -#ifdef HOB_REV2 INPUT_PIN_CONFIG(HOB_BTN_UP , gpioPullupMode_PullUp); INPUT_PIN_CONFIG(HOB_BTN_RIGHT , gpioPullupMode_PullUp); INPUT_PIN_CONFIG(HOB_BTN_DOWN , gpioPullupMode_PullUp); INPUT_PIN_CONFIG(HOB_BTN_LEFT , gpioPullupMode_PullUp); INPUT_PIN_CONFIG(HOB_BTN_A , gpioPullupMode_PullUp); INPUT_PIN_CONFIG(HOB_BTN_B , gpioPullupMode_PullUp); -#else - INPUT_PIN_CONFIG(HOB_BTN_UP , gpioPullupMode_PullDown); - INPUT_PIN_CONFIG(HOB_BTN_RIGHT , gpioPullupMode_PullDown); - INPUT_PIN_CONFIG(HOB_BTN_DOWN , gpioPullupMode_PullDown); - INPUT_PIN_CONFIG(HOB_BTN_LEFT , gpioPullupMode_PullDown); - INPUT_PIN_CONFIG(HOB_BTN_CENTER, gpioPullupMode_PullDown); - INPUT_PIN_CONFIG(HOB_BTN_A , gpioPullupMode_PullDown); - INPUT_PIN_CONFIG(HOB_BTN_B , gpioPullupMode_PullDown); -#endif #undef INPUT_PIN_CONFIG -#define OUTPUT_PIN_CONFIG(spec, value) do { \ - HOB_SET_PIN_FUNC(spec, GPIO); \ - gpioSetDir(HOB_PORT(spec), HOB_PIN(spec), gpioDirection_Output); \ - gpioSetValue(HOB_PORT(spec), HOB_PIN(spec), (value)); \ +#define OUTPUT_PIN_CONFIG(spec, value) do { \ + HOB_SET_PIN_FUNC(spec, GPIO); \ + gpioSetDir(HOB_PORT(spec), HOB_PIN(spec), gpioDirection_Output); \ + gpioSetValue(HOB_PORT(spec), HOB_PIN(spec), (value)); \ } while(0) OUTPUT_PIN_CONFIG(HOB_USB_CONNECT , 1); OUTPUT_PIN_CONFIG(HOB_LCD_CS , 1); OUTPUT_PIN_CONFIG(HOB_LCD_RST , 1); OUTPUT_PIN_CONFIG(HOB_DATAFLASH_CS, 1); - -#ifdef HOB_REV2 OUTPUT_PIN_CONFIG(HOB_LED_LEFT , 0); OUTPUT_PIN_CONFIG(HOB_LED_RIGHT , 0); -#endif #undef OUTPUT_PIN_CONFIG - badge_init_backlight(); + badge_backlight_init(); badge_display_init(); }