From 3deacf340c59a89b862f228d251307e71a9c9189 Mon Sep 17 00:00:00 2001 From: Wintermute Date: Sat, 26 Oct 2013 19:02:13 +0200 Subject: [PATCH] =?utf8?q?Pinconfig=20f=C3=BCr=20Endbadge.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Makefile | 1 - badge/init.c | 29 +++++++---------------- badge/jumpnrun/levels/23xentry.lv | 28 +++++++++++----------- badge/jumpnrun/levels/23xhq.lv | 24 +++++++++---------- badge/jumpnrun/levels/skynet.lv | 10 ++++---- badge/main.c | 18 ++++++-------- badge/pinconfig.h | 39 +++++-------------------------- badge/ui/event.c | 10 +------- 8 files changed, 54 insertions(+), 105 deletions(-) diff --git a/Makefile b/Makefile index 6a0817a..21b726e 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,6 @@ DEBUGBUILD = FALSE OPTDEFINES = -D__NEWLIB__ #OPTDEFINES += -DR0KET -OPTDEFINES += -DHOB_REV2 #OPTDEFINES += -DUSBONLY ########################################################################## # Project-specific files diff --git a/badge/init.c b/badge/init.c index cc4d044..33d048d 100644 --- a/badge/init.c +++ b/badge/init.c @@ -17,46 +17,33 @@ static void badge_init_backlight(void) { } void badge_init(void) { -#define INPUT_PIN_CONFIG(spec, mode) do { \ - HOB_SET_PIN_FUNC(spec, GPIO); \ - gpioSetDir(HOB_PORT(spec), HOB_PIN(spec), gpioDirection_Input); \ - gpioSetPullup(&HOB_IOCON(spec), (mode)); \ +#define INPUT_PIN_CONFIG(spec, mode) do { \ + HOB_SET_PIN_FUNC(spec, GPIO); \ + gpioSetDir(HOB_PORT(spec), HOB_PIN(spec), gpioDirection_Input); \ + 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); - INPUT_PIN_CONFIG(HOB_BTN_LEFT , gpioPullupMode_PullDown); - 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 { \ - HOB_SET_PIN_FUNC(spec, GPIO); \ - gpioSetDir(HOB_PORT(spec), HOB_PIN(spec), gpioDirection_Output); \ - gpioSetValue(HOB_PORT(spec), HOB_PIN(spec), (value)); \ +#define OUTPUT_PIN_CONFIG(spec, value) do { \ + HOB_SET_PIN_FUNC(spec, GPIO); \ + gpioSetDir(HOB_PORT(spec), HOB_PIN(spec), gpioDirection_Output); \ + gpioSetValue(HOB_PORT(spec), HOB_PIN(spec), (value)); \ } while(0) OUTPUT_PIN_CONFIG(HOB_USB_CONNECT , 1); OUTPUT_PIN_CONFIG(HOB_LCD_CS , 1); OUTPUT_PIN_CONFIG(HOB_LCD_RST , 1); OUTPUT_PIN_CONFIG(HOB_DATAFLASH_CS, 1); - -#ifdef HOB_REV2 OUTPUT_PIN_CONFIG(HOB_LED_LEFT , 0); OUTPUT_PIN_CONFIG(HOB_LED_RIGHT , 0); -#endif #undef OUTPUT_PIN_CONFIG diff --git a/badge/jumpnrun/levels/23xentry.lv b/badge/jumpnrun/levels/23xentry.lv index 234fbac..aa6f339 100644 --- a/badge/jumpnrun/levels/23xentry.lv +++ b/badge/jumpnrun/levels/23xentry.lv @@ -1,17 +1,17 @@ ### ### # # ^ - # # # # # # c ^ - # # # ??? ^ ????? ??????? ^ - # # # # # < ?? e ^ - ##### ### # # < ??? ?? ?? ?? ?? 01 ^ - ??? < ???? 23 ^ - ^ ????? C S M H S H 23 ^ - < < ????????????????????????????????????????????????23?^^^^ - ?S S? ??? < << 23^^^^^ - ?????? <<< k 23^^^^^ - ^ ^ ? ? ? ?? ??? ? S ? M M <<<< ><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <#^ <#^ C B B @ ^^ G ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^23^^^^^ -########################################################################### ##########^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^23^^^^^ + # # # # # # c ^ + # # # ???? ^^ ????? ????? ^ + # # # # # ^ vv e ^ + < <#^ <#^ C B B @ ^^ G ^ <^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^23^^^^^ +########################################################################### ##########^^^^^^^^^^^^^^^^^^^^ 23 [tiles] 0 tube_top_left 1 tube_top_right @@ -42,3 +42,5 @@ G giraffe V bird W bird_straight X bird_dip +[parameters] +L 4 diff --git a/badge/jumpnrun/levels/23xhq.lv b/badge/jumpnrun/levels/23xhq.lv index 53a7e20..c5e3b47 100644 --- a/badge/jumpnrun/levels/23xhq.lv +++ b/badge/jumpnrun/levels/23xhq.lv @@ -1,15 +1,15 @@ -vvv##vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv??? >< 23 >< -><^23^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^??? >< 23 >< ->< 23 < 23 >< ->< P c k < 23 >< ->< vvvvvvvvv> < 23 >< ->< ?^^^^^^^^^> < 23 >< ->< <^^^vvv> < >< ->< <^^^> < ??^^vvvv> < e >< ->< <^^^^^^^^> < ??^^^^vvvv> < ->< ^ ^ ^^ ^^ ^? ^ ? <^^^^^> < ??^^^^vvvv> <^^^^^^^^^^^^^^^^^^^^^ >< ->< ^?^ ^?^ vvvvv> < ??^^^^vvvv> >< ->< ^??M ^?? M <^^^^^> < ??^^^^vvvv> >< +vvv##vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv???????????????????????? >< 23 >< +><^23^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^??? ?????? >< 23 >< +>< 23 < 23 >< +>< P c k < 23 >< +>< vvvvvvvvv> B < 23 >< +>< ?^^^^^^^^^> B < 23 >< +>< <^^^vvv> < >< +>< B <^^^> < ??^^vvvv> < >< +>< <^^^^^^^^> < ??^^^^vvvv> < +>< ^ ^ ^^ ^^ ^? ^ ? <^^^^^> < ??^^^^vvvv> <^^^^^^ ?^^^^ ^^^^^^^^ >< +>< ^?^ ^?^ vvvvv> < ??^^^^vvvv> ?> >< +>< ^??M ^?? M <^^^^^> < ??^^^^vvvv> B ?> M >< vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv> < ??^^^^vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv>< ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^> < ??^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^>< [tiles] diff --git a/badge/jumpnrun/levels/skynet.lv b/badge/jumpnrun/levels/skynet.lv index c2ca21c..126e7a5 100644 --- a/badge/jumpnrun/levels/skynet.lv +++ b/badge/jumpnrun/levels/skynet.lv @@ -1,10 +1,10 @@ - - @ - - + 23 + 23 @ + 23 + P ??? ????? ????? ??????^^^^^ - P RRRRRRR ????? + R R R R ????? ^^^^???? ??????^^ ??? R ???????? R ???? ????? ^ ^ ?????? ????? R ??? R diff --git a/badge/main.c b/badge/main.c index e3cdb79..9a7d5f1 100644 --- a/badge/main.c +++ b/badge/main.c @@ -112,16 +112,6 @@ 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 }, @@ -130,7 +120,6 @@ 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) { @@ -255,6 +244,13 @@ int main(void) f_mount(0, &fs); #ifdef USBONLY + if(badge_input_raw() & BADGE_EVENT_KEY_LEFT) { + gpioSetValue(HOB_PORT(HOB_LED_LEFT), HOB_PIN(HOB_LED_LEFT) , 1); + } + if(badge_input_raw() & BADGE_EVENT_KEY_RIGHT) { + gpioSetValue(HOB_PORT(HOB_LED_RIGHT), HOB_PIN(HOB_LED_RIGHT) , 1); + } + for(;;) usbmode(); #else if(badge_input_raw() & BADGE_EVENT_KEY_DOWN) { diff --git a/badge/pinconfig.h b/badge/pinconfig.h index 1b4a1b9..e4fd791 100644 --- a/badge/pinconfig.h +++ b/badge/pinconfig.h @@ -3,14 +3,12 @@ #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_BTN_A (1, 8) +#define HOB_BTN_B (1, 9) #define HOB_LCD_CS (3, 0) #define HOB_LCD_RST (3, 1) @@ -24,34 +22,9 @@ #define HOB_USB_CONNECT (0, 6) - #define HOB_LED_LEFT (2, 8) #define HOB_LED_RIGHT (2, 6) -#else - -#define HOB_BTN_UP (3, 2) -#define HOB_BTN_RIGHT (1, 5) -#define HOB_BTN_DOWN (1, 6) -#define HOB_BTN_LEFT (3, 3) -#define HOB_BTN_CENTER (1, 7) -#define HOB_BTN_A (1, 11) -#define HOB_BTN_B (1, 4) - -#define HOB_LCD_CS (1, 0) -#define HOB_LCD_RST (1, 1) -#define HOB_LCD_BACKLIGHT (0, 1) - -#define HOB_DATAFLASH_CS (0, 7) - -#define HOB_RADIO_CE (2, 10) -#define HOB_RADIO_CS (2, 9) -#define HOB_RADIO_IRQ (2, 2) - -#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 @@ -117,10 +90,10 @@ #define HOB_BUILD_IOCON_MASK(pio, flag) HOB_BUILD_IOCON_MASK_I(pio, flag) #define HOB_IOCON_MASK(spec, flag) HOB_BUILD_IOCON_MASK(HOB_PIO_SUFFIX(spec), flag) -#define HOB_SET_PIN_FUNC(spec, func) do { \ - HOB_IOCON(spec) = \ - (HOB_IOCON(spec) & ~HOB_IOCON_MASK(spec, FUNC_MASK)) \ - | HOB_IOCON_MASK(spec, FUNC_ ## func); \ +#define HOB_SET_PIN_FUNC(spec, func) do { \ + HOB_IOCON(spec) = \ + (HOB_IOCON(spec) & ~HOB_IOCON_MASK(spec, FUNC_MASK)) \ + | HOB_IOCON_MASK(spec, FUNC_ ## func); \ } while(0) #endif diff --git a/badge/ui/event.c b/badge/ui/event.c index c705a0e..55cbdbd 100644 --- a/badge/ui/event.c +++ b/badge/ui/event.c @@ -30,21 +30,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) +#else 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 ; } - if (gpioGetValue(HOB_PORT(HOB_BTN_CENTER), HOB_PIN(HOB_BTN_CENTER)) == 1) { result |= BADGE_EVENT_KEY_CENTER; } - if (gpioGetValue(HOB_PORT(HOB_BTN_LEFT ), HOB_PIN(HOB_BTN_LEFT )) == 1) { result |= BADGE_EVENT_KEY_LEFT ; } - if (gpioGetValue(HOB_PORT(HOB_BTN_RIGHT ), HOB_PIN(HOB_BTN_RIGHT )) == 1) { result |= BADGE_EVENT_KEY_RIGHT ; } - if (gpioGetValue(HOB_PORT(HOB_BTN_A ), HOB_PIN(HOB_BTN_A )) == 1) { result |= BADGE_EVENT_KEY_BTN_A ; } - if (gpioGetValue(HOB_PORT(HOB_BTN_B ), HOB_PIN(HOB_BTN_B )) == 1) { result |= BADGE_EVENT_KEY_BTN_B ; } #endif return result; -- 2.20.1