Jumpnrun: Neueste Entwicklung geportet. Schnellere Bewegung, neuer Gegner,
[hackover2013-badge-firmware.git] / badge / init.c
1 #include "init.h"
2 #include "pinconfig.h"
3 #include "util/util.h"
4 #include "ui/display.h"
5
6 #include <core/wdt/wdt.h>
7 #include <core/gpio/gpio.h>
8
9 static void badge_init_backlight(void) {
10 HOB_SET_PIN_FUNC(HOB_LCD_BACKLIGHT, CLKOUT);
11
12 SCB_CLKOUTCLKSEL = SCB_MAINCLKSEL_SOURCE_INTERNALOSC;
13 SCB_CLKOUTCLKUEN = SCB_CLKOUTCLKUEN_DISABLE;
14 SCB_CLKOUTCLKUEN = SCB_CLKOUTCLKUEN_UPDATE;
15 SCB_CLKOUTCLKDIV = 30;
16 }
17
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)); \
23 } while(0)
24
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
33
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)); \
38 } while(0)
39
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
45
46 badge_init_backlight();
47 badge_display_init();
48 }
This page took 0.064025 seconds and 5 git commands to generate.