diff --git a/board/redbee-dev.h b/board/redbee-dev.h index d7401a60d..4dd761c0d 100644 --- a/board/redbee-dev.h +++ b/board/redbee-dev.h @@ -1,9 +1,9 @@ #ifndef BOARD_REDBEE_DEV_H #define BOARD_REDBEE_DEV_H -#define LED_RED (1 << 23) -#define LED_GREEN (1 << 24) -#define LED_BLUE (1 << 25) +#define LED_RED 23 +#define LED_GREEN 24 +#define LED_BLUE 25 /* XTAL TUNE parameters */ /* see http://devl.org/pipermail/mc1322x/2009-December/000162.html */ diff --git a/board/redbee-econotag.h b/board/redbee-econotag.h index 75ac46855..6838dae93 100644 --- a/board/redbee-econotag.h +++ b/board/redbee-econotag.h @@ -1,9 +1,9 @@ #ifndef BOARD_REDBEE_DEV_H #define BOARD_REDBEE_DEV_H -#define LED_RED (1 << 23) -#define LED_GREEN (1 << 24) -#define LED_BLUE (1 << 25) +#define LED_RED 12 +#define LED_GREEN 21 +#define LED_BLUE 35 /* XTAL TUNE parameters */ /* see http://devl.org/pipermail/mc1322x/2009-December/000162.html */ diff --git a/board/redbee-r1.h b/board/redbee-r1.h index 7737dc33b..698a02549 100644 --- a/board/redbee-r1.h +++ b/board/redbee-r1.h @@ -1,9 +1,9 @@ #ifndef BOARD_REDBEE_R1_H #define BOARD_REDBEE_R1_H -#define LED_RED (1 << 8) -#define LED_GREEN (1 << 9) -#define LED_BLUE (1 << 10) +#define LED_RED 8 +#define LED_GREEN 9 +#define LED_BLUE 10 /* XTAL TUNE parameters */ /* see http://devl.org/pipermail/mc1322x/2009-December/000162.html */ diff --git a/lib/include/gpio.h b/lib/include/gpio.h index 89c16d623..5d79253a8 100644 --- a/lib/include/gpio.h +++ b/lib/include/gpio.h @@ -16,6 +16,11 @@ #define GPIO_PAD_PU_SEL0 ((volatile uint32_t *) 0x80000030) #define GPIO_PAD_PU_SEL1 ((volatile uint32_t *) 0x80000034) +#define GPIO_DATA_SET0 ((volatile uint32_t *) 0x80000048) +#define GPIO_DATA_SET1 ((volatile uint32_t *) 0x8000004c) +#define GPIO_DATA_RESET0 ((volatile uint32_t *) 0x80000050) +#define GPIO_DATA_RESET1 ((volatile uint32_t *) 0x80000054) + /* select pullup or pulldown for GPIO 0-31 (b=0-31) */ #define gpio_sel0_pullup(b) (set_bit(reg32(GPIO_PAD_PU_SEL0),b)) diff --git a/tests/blink-blue.c b/tests/blink-blue.c index a5b0165c6..a9410cd01 100644 --- a/tests/blink-blue.c +++ b/tests/blink-blue.c @@ -3,16 +3,16 @@ #define DELAY 400000 -#define LED_BITS LED_BLUE +#define LED LED_BLUE void main(void) { volatile uint32_t i; - *GPIO_PAD_DIR0 = LED_BITS; + *GPIO_PAD_DIR0 = ( 1<< LED ); while(1) { - *GPIO_DATA0 = LED_BITS; + *GPIO_DATA0 = (1 << LED ); for(i=0; i #include -#include "led.h" - #define DELAY 400000 -#define LED_BITS LED_WHITE +#define LED LED_WHITE void main(void) { volatile uint32_t i; - *GPIO_PAD_DIR0 = LED_BITS; + *GPIO_PAD_DIR0 = ( 1<< LED ); while(1) { - *GPIO_DATA0 = LED_BITS; + *GPIO_DATA0 = (1 << LED ); for(i=0; ilength); for(j=0, k=0; j < ((p->length)%PER_ROW)-1; j++) { for(i=0; i < PER_ROW; i++, k++) { - if(k>=p->length) { break; } + if(k >= (p->length + 1) ) { goto out; } /* + 1 since first byte is len+2 */ printf("%02x ",p->data[j*PER_ROW+i]); } printf("\n\r"); } + out: printf("\n\r"); } return; diff --git a/tests/tests.h b/tests/tests.h index d3b7f48f4..29158c330 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -9,6 +9,14 @@ void uart1_init(uint16_t inc, uint16_t mod); void print_welcome(char* testname); void dump_regs(uint32_t base, uint32_t len); -void print_packet(packet_t *p); +void print_packet(volatile packet_t *p); + +#define toggle_gpio0(x) do { \ + if(bit_is_set(*GPIO_DATA0,x)) { \ + *GPIO_DATA_RESET0 = (1 << x); \ + } else { \ + *GPIO_DATA_SET0 = (1 << x) ; \ + } \ + } while(0); #endif