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
);
12 SCB_CLKOUTCLKSEL
= SCB_MAINCLKSEL_SOURCE_INTERNALOSC
;
13 SCB_CLKOUTCLKUEN
= SCB_CLKOUTCLKUEN_DISABLE
;
14 SCB_CLKOUTCLKUEN
= SCB_CLKOUTCLKUEN_UPDATE
;
15 SCB_CLKOUTCLKDIV
= 30;
18 void badge_init(void) {
19 #define INPUT_PIN_CONFIG(spec, mode) do { \
20 HOB_SET_PIN_FUNC(spec, GPIO); \
21 gpioSetDir(HOB_PORT(spec), HOB_PIN(spec), gpioDirection_Input); \
22 gpioSetPullup(&HOB_IOCON(spec), (mode)); \
25 INPUT_PIN_CONFIG(HOB_BTN_UP
, gpioPullupMode_PullDown
);
26 INPUT_PIN_CONFIG(HOB_BTN_RIGHT
, gpioPullupMode_PullDown
);
27 INPUT_PIN_CONFIG(HOB_BTN_DOWN
, gpioPullupMode_PullDown
);
28 INPUT_PIN_CONFIG(HOB_BTN_LEFT
, gpioPullupMode_PullDown
);
29 INPUT_PIN_CONFIG(HOB_BTN_CENTER
, gpioPullupMode_PullDown
);
30 INPUT_PIN_CONFIG(HOB_BTN_A
, gpioPullupMode_PullDown
);
31 INPUT_PIN_CONFIG(HOB_BTN_B
, gpioPullupMode_PullDown
);
32 #undef INPUT_PIN_CONFIG
34 #define OUTPUT_PIN_CONFIG(spec, value) do { \
35 HOB_SET_PIN_FUNC(spec, GPIO); \
36 gpioSetDir(HOB_PORT(spec), HOB_PIN(spec), gpioDirection_Output); \
37 gpioSetValue(HOB_PORT(spec), HOB_PIN(spec), (value)); \
40 OUTPUT_PIN_CONFIG(HOB_USB_CONNECT
, 1);
41 OUTPUT_PIN_CONFIG(HOB_LCD_CS
, 1);
42 OUTPUT_PIN_CONFIG(HOB_LCD_RST
, 1);
43 OUTPUT_PIN_CONFIG(HOB_DATAFLASH_CS
, 1);
44 #undef OUTPUT_PIN_CONFIG
46 badge_init_backlight();