4 #include "ui/display.h"
6 #include <core/wdt/wdt.h>
7 #include <core/gpio/gpio.h>
9 static void badge_init_backlight(void) {
10 HOB_SET_PIN_FUNC(HOB_LCD_BACKLIGHT
, CLKOUT
);
13 SCB_CLKOUTCLKSEL
= SCB_MAINCLKSEL_SOURCE_WDTOSC
;
14 SCB_CLKOUTCLKUEN
= SCB_CLKOUTCLKUEN_DISABLE
;
15 SCB_CLKOUTCLKUEN
= SCB_CLKOUTCLKUEN_UPDATE
;
16 SCB_CLKOUTCLKDIV
= 75;
19 void badge_init(void) {
20 #define INPUT_PIN_CONFIG(spec, mode) do { \
21 HOB_SET_PIN_FUNC(spec, GPIO); \
22 gpioSetDir(HOB_PORT(spec), HOB_PIN(spec), gpioDirection_Input); \
23 gpioSetPullup(&HOB_IOCON(spec), (mode)); \
26 INPUT_PIN_CONFIG(HOB_BTN_UP
, gpioPullupMode_PullUp
);
27 INPUT_PIN_CONFIG(HOB_BTN_RIGHT
, gpioPullupMode_PullUp
);
28 INPUT_PIN_CONFIG(HOB_BTN_DOWN
, gpioPullupMode_PullUp
);
29 INPUT_PIN_CONFIG(HOB_BTN_LEFT
, gpioPullupMode_PullUp
);
30 INPUT_PIN_CONFIG(HOB_BTN_A
, gpioPullupMode_PullUp
);
31 INPUT_PIN_CONFIG(HOB_BTN_B
, gpioPullupMode_PullUp
);
33 #undef INPUT_PIN_CONFIG
35 #define OUTPUT_PIN_CONFIG(spec, value) do { \
36 HOB_SET_PIN_FUNC(spec, GPIO); \
37 gpioSetDir(HOB_PORT(spec), HOB_PIN(spec), gpioDirection_Output); \
38 gpioSetValue(HOB_PORT(spec), HOB_PIN(spec), (value)); \
41 OUTPUT_PIN_CONFIG(HOB_USB_CONNECT
, 1);
42 OUTPUT_PIN_CONFIG(HOB_LCD_CS
, 1);
43 OUTPUT_PIN_CONFIG(HOB_LCD_RST
, 1);
44 OUTPUT_PIN_CONFIG(HOB_DATAFLASH_CS
, 1);
45 OUTPUT_PIN_CONFIG(HOB_LED_LEFT
, 0);
46 OUTPUT_PIN_CONFIG(HOB_LED_RIGHT
, 0);
48 #undef OUTPUT_PIN_CONFIG
50 badge_init_backlight();