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)); \
27 INPUT_PIN_CONFIG(HOB_BTN_UP
, gpioPullupMode_PullUp
);
28 INPUT_PIN_CONFIG(HOB_BTN_RIGHT
, gpioPullupMode_PullUp
);
29 INPUT_PIN_CONFIG(HOB_BTN_DOWN
, gpioPullupMode_PullUp
);
30 INPUT_PIN_CONFIG(HOB_BTN_LEFT
, gpioPullupMode_PullUp
);
31 INPUT_PIN_CONFIG(HOB_BTN_A
, gpioPullupMode_PullUp
);
32 INPUT_PIN_CONFIG(HOB_BTN_B
, gpioPullupMode_PullUp
);
34 INPUT_PIN_CONFIG(HOB_BTN_UP
, gpioPullupMode_PullDown
);
35 INPUT_PIN_CONFIG(HOB_BTN_RIGHT
, gpioPullupMode_PullDown
);
36 INPUT_PIN_CONFIG(HOB_BTN_DOWN
, gpioPullupMode_PullDown
);
37 INPUT_PIN_CONFIG(HOB_BTN_LEFT
, gpioPullupMode_PullDown
);
38 INPUT_PIN_CONFIG(HOB_BTN_CENTER
, gpioPullupMode_PullDown
);
39 INPUT_PIN_CONFIG(HOB_BTN_A
, gpioPullupMode_PullDown
);
40 INPUT_PIN_CONFIG(HOB_BTN_B
, gpioPullupMode_PullDown
);
43 #undef INPUT_PIN_CONFIG
45 #define OUTPUT_PIN_CONFIG(spec, value) do { \
46 HOB_SET_PIN_FUNC(spec, GPIO); \
47 gpioSetDir(HOB_PORT(spec), HOB_PIN(spec), gpioDirection_Output); \
48 gpioSetValue(HOB_PORT(spec), HOB_PIN(spec), (value)); \
51 OUTPUT_PIN_CONFIG(HOB_USB_CONNECT
, 1);
52 OUTPUT_PIN_CONFIG(HOB_LCD_CS
, 1);
53 OUTPUT_PIN_CONFIG(HOB_LCD_RST
, 1);
54 OUTPUT_PIN_CONFIG(HOB_DATAFLASH_CS
, 1);
57 OUTPUT_PIN_CONFIG(HOB_LED_LEFT
, 0);
58 OUTPUT_PIN_CONFIG(HOB_LED_RIGHT
, 0);
61 #undef OUTPUT_PIN_CONFIG
63 badge_init_backlight();