From: Wintermute Date: Sun, 13 Oct 2013 01:56:12 +0000 (+0200) Subject: Support für neuen Prototypen X-Git-Url: https://git.rohieb.name/hackover2013-badge-firmware.git/commitdiff_plain/ead4a16614e0b46cf7e4f00feec1411067c1c6f4?ds=inline Support für neuen Prototypen --- diff --git a/Makefile b/Makefile index 0abe529..58aaa5b 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ DEBUGBUILD = FALSE # IDE Flags (Keeps various IDEs happy) ########################################################################## -OPTDEFINES = -D __NEWLIB__ -DR0KET +OPTDEFINES = -D __NEWLIB__ -DHOB_REV2 ########################################################################## # Project-specific files diff --git a/badge/init.c b/badge/init.c index 4623b8e..8a8983e 100644 --- a/badge/init.c +++ b/badge/init.c @@ -9,6 +9,7 @@ static void badge_init_backlight(void) { HOB_SET_PIN_FUNC(HOB_LCD_BACKLIGHT, CLKOUT); + // wdtInit(false); SCB_CLKOUTCLKSEL = SCB_MAINCLKSEL_SOURCE_INTERNALOSC; SCB_CLKOUTCLKUEN = SCB_CLKOUTCLKUEN_DISABLE; SCB_CLKOUTCLKUEN = SCB_CLKOUTCLKUEN_UPDATE; @@ -22,6 +23,14 @@ void badge_init(void) { 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); @@ -29,6 +38,8 @@ void badge_init(void) { 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 { \ diff --git a/badge/jumpnrun/enemies.c b/badge/jumpnrun/enemies.c index 7d31eed..ac5dd98 100644 --- a/badge/jumpnrun/enemies.c +++ b/badge/jumpnrun/enemies.c @@ -90,7 +90,7 @@ void enemy_collision_player_jumpable(jumpnrun_enemy *self, if(rectangle_intersect(&rect_self, &rect_hacker)) { if(fixed_point_gt(state->inertia.y, FIXED_POINT(0, 0))) { self->flags &= ~JUMPNRUN_ENEMY_SPAWNED; - state->inertia_mod.y = FIXED_POINT(0, -167); + state->inertia_mod.y = FIXED_POINT(0, -250); state->jumpable_frames = 12; } else { state->status = JUMPNRUN_DEAD; diff --git a/badge/main.c b/badge/main.c index ffa0be1..156d8e2 100644 --- a/badge/main.c +++ b/badge/main.c @@ -104,6 +104,16 @@ void rbInit() { uint32_t volatile *reg; gpioPullupMode_t mode; } const input_pins[] = { +#ifdef HOB_REV2 + { RB_BTN0 , &RB_BTN0_IO , gpioPullupMode_PullDown }, + { RB_BTN1 , &RB_BTN1_IO , gpioPullupMode_PullDown }, + { RB_BTN2 , &RB_BTN2_IO , gpioPullupMode_PullDown }, + { RB_BTN3 , &RB_BTN3_IO , gpioPullupMode_PullDown }, + { RB_BTN4 , &RB_BTN4_IO , gpioPullupMode_PullDown }, + { RB_HB0 , &RB_HB0_IO , gpioPullupMode_PullDown }, + { RB_HB1 , &RB_HB1_IO , gpioPullupMode_PullDown }, + { RB_PWR_CHRG, &RB_PWR_CHRG_IO, gpioPullupMode_PullDown } +#else { RB_BTN0 , &RB_BTN0_IO , gpioPullupMode_PullUp }, { RB_BTN1 , &RB_BTN1_IO , gpioPullupMode_PullUp }, { RB_BTN2 , &RB_BTN2_IO , gpioPullupMode_PullUp }, @@ -112,6 +122,7 @@ void rbInit() { { RB_HB0 , &RB_HB0_IO , gpioPullupMode_PullUp }, { RB_HB1 , &RB_HB1_IO , gpioPullupMode_PullUp }, { RB_PWR_CHRG, &RB_PWR_CHRG_IO, gpioPullupMode_PullUp } +#endif }; for(int i = 0; i < ARRAY_SIZE(input_pins); ++i) { diff --git a/badge/pinconfig.h b/badge/pinconfig.h index 52f05b9..7f39856 100644 --- a/badge/pinconfig.h +++ b/badge/pinconfig.h @@ -3,6 +3,30 @@ #include +#ifdef HOB_REV2 + +#define HOB_BTN_UP (1, 11) +#define HOB_BTN_RIGHT (1, 7) +#define HOB_BTN_DOWN (1, 6) +#define HOB_BTN_LEFT (1, 5) +#define HOB_BTN_A (1, 9) +#define HOB_BTN_B (1, 8) + +#define HOB_LCD_CS (3, 0) +#define HOB_LCD_RST (3, 1) +#define HOB_LCD_BACKLIGHT (0, 1) + +#define HOB_DATAFLASH_CS (0, 7) + +#define HOB_RADIO_CE (2, 2) +#define HOB_RADIO_CS (2, 10) +#define HOB_RADIO_IRQ (2, 9) + +#define HOB_USB_CONNECT (0, 6) + + +#else + #define HOB_BTN_UP (3, 2) #define HOB_BTN_RIGHT (1, 5) #define HOB_BTN_DOWN (1, 6) @@ -23,6 +47,8 @@ #define HOB_USB_CONNECT (0, 6) +#endif + #define HOB_PIO0_0 nRESET_PIO0_0 #define HOB_PIO0_1 PIO0_1 #define HOB_PIO0_2 PIO0_2 diff --git a/badge/ui/event.c b/badge/ui/event.c index 779398f..eb4f44a 100644 --- a/badge/ui/event.c +++ b/badge/ui/event.c @@ -29,6 +29,13 @@ uint8_t badge_input_raw(void) { if (gpioGetValue(RB_BTN1) == 0) { result |= BADGE_EVENT_KEY_LEFT ; } if (gpioGetValue(RB_HB0 ) == 0) { result |= BADGE_EVENT_KEY_BTN_A ; } if (gpioGetValue(RB_HB1 ) == 0) { result |= BADGE_EVENT_KEY_BTN_B ; } +#elif defined(HOB_REV2) + if (gpioGetValue(HOB_PORT(HOB_BTN_UP ), HOB_PIN(HOB_BTN_UP )) == 0) { result |= BADGE_EVENT_KEY_UP ; } + if (gpioGetValue(HOB_PORT(HOB_BTN_DOWN ), HOB_PIN(HOB_BTN_DOWN )) == 0) { result |= BADGE_EVENT_KEY_DOWN ; } + if (gpioGetValue(HOB_PORT(HOB_BTN_LEFT ), HOB_PIN(HOB_BTN_LEFT )) == 0) { result |= BADGE_EVENT_KEY_LEFT ; } + if (gpioGetValue(HOB_PORT(HOB_BTN_RIGHT ), HOB_PIN(HOB_BTN_RIGHT )) == 0) { result |= BADGE_EVENT_KEY_RIGHT ; } + if (gpioGetValue(HOB_PORT(HOB_BTN_A ), HOB_PIN(HOB_BTN_A )) == 0) { result |= BADGE_EVENT_KEY_BTN_A ; } + if (gpioGetValue(HOB_PORT(HOB_BTN_B ), HOB_PIN(HOB_BTN_B )) == 0) { result |= BADGE_EVENT_KEY_BTN_B ; } #else if (gpioGetValue(HOB_PORT(HOB_BTN_UP ), HOB_PIN(HOB_BTN_UP )) == 1) { result |= BADGE_EVENT_KEY_UP ; } if (gpioGetValue(HOB_PORT(HOB_BTN_DOWN ), HOB_PIN(HOB_BTN_DOWN )) == 1) { result |= BADGE_EVENT_KEY_DOWN ; }