updated to use the leds on the RedBee hardware and made it a little more general.

Signed-off-by: Mariano Alvira <mar@devl.org>
This commit is contained in:
Mariano Alvira 2009-06-22 12:35:39 -04:00
parent c419d7403b
commit e1059a9b15
9 changed files with 51 additions and 17 deletions

13
include/led.h Normal file
View file

@ -0,0 +1,13 @@
#ifndef LED_H
#define LED_H
#define LED_RED ((1 << 23) | (1 << 8))
#define LED_GREEN ((1 << 24) | (1 << 9))
#define LED_BLUE ((1 << 25) | (1 << 10))
#define LED_YELLOW (LED_RED | LED_GREEN )
#define LED_PURPLE (LED_RED | LED_BLUE)
#define LED_CYAN ( LED_GREEN | LED_BLUE)
#define LED_WHITE (LED_RED | LED_GREEN | LED_BLUE)
#endif

View file

@ -6,17 +6,20 @@
#include "embedded_types.h" #include "embedded_types.h"
#include "isr.h" #include "isr.h"
#include "led.h"
#define LED_BITS LED_BLUE
__attribute__ ((section ("startup"))) __attribute__ ((section ("startup")))
void main(void) { void main(void) {
*(volatile uint32_t *)GPIO_PAD_DIR0 = 0x00000400; *(volatile uint32_t *)GPIO_PAD_DIR0 = LED_BITS;
volatile uint32_t i; volatile uint32_t i;
while(1) { while(1) {
*(volatile uint32_t *)GPIO_DATA0 = 0x00000400; *(volatile uint32_t *)GPIO_DATA0 = LED_BITS;
for(i=0; i<DELAY; i++) { continue; } for(i=0; i<DELAY; i++) { continue; }

View file

@ -6,17 +6,20 @@
#include "embedded_types.h" #include "embedded_types.h"
#include "isr.h" #include "isr.h"
#include "led.h"
#define LED_BITS LED_GREEN
__attribute__ ((section ("startup"))) __attribute__ ((section ("startup")))
void main(void) { void main(void) {
*(volatile uint32_t *)GPIO_PAD_DIR0 = 0x00000200; *(volatile uint32_t *)GPIO_PAD_DIR0 = LED_BITS;
volatile uint32_t i; volatile uint32_t i;
while(1) { while(1) {
*(volatile uint32_t *)GPIO_DATA0 = 0x00000200; *(volatile uint32_t *)GPIO_DATA0 = LED_BITS;
for(i=0; i<DELAY; i++) { continue; } for(i=0; i<DELAY; i++) { continue; }

View file

@ -6,15 +6,18 @@
#include "embedded_types.h" #include "embedded_types.h"
#include "isr.h" #include "isr.h"
#include "led.h"
#define LED_BITS LED_RED
__attribute__ ((section ("startup"))) void main(void) { __attribute__ ((section ("startup"))) void main(void) {
*(volatile uint32_t *)GPIO_PAD_DIR0 = 0x00000100; *(volatile uint32_t *)GPIO_PAD_DIR0 = LED_BITS;
volatile uint32_t i; volatile uint32_t i;
while(1) { while(1) {
*(volatile uint32_t *)GPIO_DATA0 = 0x00000100; *(volatile uint32_t *)GPIO_DATA0 = LED_BITS;
for(i=0; i<DELAY; i++) { continue; } for(i=0; i<DELAY; i++) { continue; }

View file

@ -6,17 +6,20 @@
#include "embedded_types.h" #include "embedded_types.h"
#include "isr.h" #include "isr.h"
#include "led.h"
#define LED_BITS LED_WHITE
__attribute__ ((section ("startup"))) __attribute__ ((section ("startup")))
void main(void) { void main(void) {
*(volatile uint32_t *)GPIO_PAD_DIR0 = 0x00000700; *(volatile uint32_t *)GPIO_PAD_DIR0 = LED_BITS;
volatile uint32_t i; volatile uint32_t i;
while(1) { while(1) {
*(volatile uint32_t *)GPIO_DATA0 = 0x00000700; *(volatile uint32_t *)GPIO_DATA0 = LED_BITS;
for(i=0; i<DELAY; i++) { continue; } for(i=0; i<DELAY; i++) { continue; }

View file

@ -65,7 +65,10 @@ void dump_regs(uint32_t base, uint32_t len) {
volatile uint8_t led; volatile uint8_t led;
#define led_on() do { led = 1; reg(GPIO_DATA0) = 0x00000200; } while(0); #include "led.h"
#define LED LED_GREEN
#define led_on() do { led = 1; reg(GPIO_DATA0) = LED; } while(0);
#define led_off() do { led = 0; reg(GPIO_DATA0) = 0x00000000; } while(0); #define led_off() do { led = 0; reg(GPIO_DATA0) = 0x00000000; } while(0);
void toggle_led(void) { void toggle_led(void) {
@ -85,7 +88,7 @@ void main(void) {
uint32_t tmp; uint32_t tmp;
uint16_t status; uint16_t status;
*(volatile uint32_t *)GPIO_PAD_DIR0 = 0x00000200; *(volatile uint32_t *)GPIO_PAD_DIR0 = LED;
led_on(); led_on();
/* Restore UART regs. to default */ /* Restore UART regs. to default */
@ -112,7 +115,7 @@ void main(void) {
init_phy(); init_phy();
set_power(0x0f); /* 0dbm */ set_power(0x0f); /* 0dbm */
set_channel(0); /* channel 11 */ set_channel(1); /* channel 11 */
reg(MACA_CONTROL) = SMAC_MACA_CNTL_INIT_STATE; reg(MACA_CONTROL) = SMAC_MACA_CNTL_INIT_STATE;
for(i=0; i<DELAY; i++) { continue; } for(i=0; i<DELAY; i++) { continue; }

View file

@ -92,7 +92,9 @@ void dump_regs(uint32_t base, uint32_t len) {
volatile uint8_t led; volatile uint8_t led;
#define led_on() do { led = 1; reg(GPIO_DATA0) = 0x00000100; } while(0); #include "led.h"
#define LED LED_RED
#define led_on() do { led = 1; reg(GPIO_DATA0) = LED; } while(0);
#define led_off() do { led = 0; reg(GPIO_DATA0) = 0x00000000; } while(0); #define led_off() do { led = 0; reg(GPIO_DATA0) = 0x00000000; } while(0);
void toggle_led(void) { void toggle_led(void) {
@ -121,7 +123,7 @@ void main(void) {
uint32_t tmp; uint32_t tmp;
uint16_t status; uint16_t status;
*(volatile uint32_t *)GPIO_PAD_DIR0 = 0x00000100; *(volatile uint32_t *)GPIO_PAD_DIR0 = LED;
led_on(); led_on();
/* Restore UART regs. to default */ /* Restore UART regs. to default */
@ -149,7 +151,7 @@ void main(void) {
init_phy(); init_phy();
set_power(0x0f); /* 0dbm */ set_power(0x0f); /* 0dbm */
set_channel(0); /* channel 11 */ set_channel(1); /* channel 11 */
reg(MACA_CONTROL) = SMAC_MACA_CNTL_INIT_STATE; reg(MACA_CONTROL) = SMAC_MACA_CNTL_INIT_STATE;
for(i=0; i<DELAY; i++) { continue; } for(i=0; i<DELAY; i++) { continue; }

View file

@ -50,10 +50,11 @@
//#include "sys-interrupt.h" //#include "sys-interrupt.h"
#include "isr.h" #include "isr.h"
#include "led.h"
volatile uint8_t led; volatile uint8_t led;
#define LED_VAL 0x00000300 #define LED_VAL LED_PURPLE
#define led_init() do { reg32(GPIO_PAD_DIR0) = LED_VAL; } while(0); #define led_init() do { reg32(GPIO_PAD_DIR0) = LED_VAL; } while(0);
#define led_on() do { led = 1; reg32(GPIO_DATA0) = LED_VAL; } while(0); #define led_on() do { led = 1; reg32(GPIO_DATA0) = LED_VAL; } while(0);
#define led_off() do { led = 0; reg32(GPIO_DATA0) = 0x00000000; } while(0); #define led_off() do { led = 0; reg32(GPIO_DATA0) = 0x00000000; } while(0);

View file

@ -7,12 +7,15 @@
#include "embedded_types.h" #include "embedded_types.h"
#include "utils.h" #include "utils.h"
#include "timer.h" #include "timer.h"
#include "led.h"
#define LED LED_YELLOW
__attribute__ ((section ("startup"))) __attribute__ ((section ("startup")))
void main(void) { void main(void) {
/* pin direction */ /* pin direction */
reg32(GPIO_PAD_DIR0) = 0x00000500; reg32(GPIO_PAD_DIR0) = LED;
/* timer setup */ /* timer setup */
/* CTRL */ /* CTRL */
@ -37,7 +40,7 @@ void main(void) {
while(1) { while(1) {
/* blink on */ /* blink on */
reg32(GPIO_DATA0) = 0x00000500; reg32(GPIO_DATA0) = LED;
while((reg16(TMR0_SCTRL)>>15) == 0) { continue; } while((reg16(TMR0_SCTRL)>>15) == 0) { continue; }
reg16(TMR0_SCTRL) = 0; /*clear bit 15, and all the others --- should be ok, but clearly not "the right thing to do" */ reg16(TMR0_SCTRL) = 0; /*clear bit 15, and all the others --- should be ok, but clearly not "the right thing to do" */