use new gpio interface
This commit is contained in:
parent
c6012611ba
commit
35c9c66c23
12 changed files with 44 additions and 60 deletions
|
@ -1,9 +1,9 @@
|
|||
#ifndef BOARD_REDBEE_DEV_H
|
||||
#define BOARD_REDBEE_DEV_H
|
||||
|
||||
#define LED_RED 12
|
||||
#define LED_GREEN 21
|
||||
#define LED_BLUE 0 /* FIXME: Was 35 - in high GPIO bank so it doesn't work */
|
||||
#define LED_RED 44
|
||||
#define LED_GREEN 45
|
||||
#define LED_BLUE 44 /* don't have a blue LED so we reuse red */
|
||||
|
||||
/* XTAL TUNE parameters */
|
||||
/* see http://devl.org/pipermail/mc1322x/2009-December/000162.html */
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#define clear_bit(val, bit) (val = (val & ~(1 << bit)))
|
||||
#define set_bit(val, bit) (val = (val | (1 << bit)))
|
||||
|
||||
#define ones(num) ( (1<<num) - 1 )
|
||||
#define ones(num) ( (1ULL << num) - 1 )
|
||||
#define bit_mask(length, shift) (ones(length) << shift)
|
||||
#define get_field(val, field) ((val & field##_MASK) >> field)
|
||||
//#define bitfield(name, length, shift) ( #define #name length #define #name##_MASK bit_mask(length, shift))
|
||||
|
|
|
@ -3,21 +3,21 @@
|
|||
|
||||
#define DELAY 400000
|
||||
|
||||
#define LED LED_BLUE
|
||||
#define LED (1ULL << LED_BLUE)
|
||||
|
||||
void main(void) {
|
||||
volatile uint32_t i;
|
||||
|
||||
*GPIO_PAD_DIR0 = LED;
|
||||
gpio_pad_dir(LED);
|
||||
|
||||
while(1) {
|
||||
|
||||
*GPIO_DATA0 = LED;
|
||||
gpio_data(LED);
|
||||
|
||||
for(i=0; i<DELAY; i++) { continue; }
|
||||
|
||||
*GPIO_DATA0 = 0x00000000;
|
||||
|
||||
gpio_data(0);
|
||||
|
||||
for(i=0; i<DELAY; i++) { continue; }
|
||||
|
||||
};
|
||||
|
|
|
@ -3,21 +3,21 @@
|
|||
|
||||
#define DELAY 400000
|
||||
|
||||
#define LED LED_GREEN
|
||||
#define LED (1ULL << LED_GREEN)
|
||||
|
||||
void main(void) {
|
||||
volatile uint32_t i;
|
||||
|
||||
*GPIO_PAD_DIR0 = LED;
|
||||
gpio_pad_dir(LED);
|
||||
|
||||
while(1) {
|
||||
|
||||
*GPIO_DATA0 = LED;
|
||||
gpio_data(LED);
|
||||
|
||||
for(i=0; i<DELAY; i++) { continue; }
|
||||
|
||||
*GPIO_DATA0 = 0x00000000;
|
||||
|
||||
gpio_data(0);
|
||||
|
||||
for(i=0; i<DELAY; i++) { continue; }
|
||||
|
||||
};
|
||||
|
|
|
@ -3,21 +3,21 @@
|
|||
|
||||
#define DELAY 400000
|
||||
|
||||
#define LED LED_RED
|
||||
#define LED (1ULL << LED_RED)
|
||||
|
||||
void main(void) {
|
||||
volatile uint32_t i;
|
||||
|
||||
*GPIO_PAD_DIR0 = LED;
|
||||
gpio_pad_dir(LED);
|
||||
|
||||
while(1) {
|
||||
|
||||
*GPIO_DATA0 = LED;
|
||||
gpio_data(LED);
|
||||
|
||||
for(i=0; i<DELAY; i++) { continue; }
|
||||
|
||||
*GPIO_DATA0 = 0x00000000;
|
||||
|
||||
gpio_data(0);
|
||||
|
||||
for(i=0; i<DELAY; i++) { continue; }
|
||||
|
||||
};
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <mc1322x.h>
|
||||
#include <board.h>
|
||||
|
||||
#include "led.h"
|
||||
|
||||
#define DELAY 400000
|
||||
|
@ -9,16 +10,16 @@
|
|||
void main(void) {
|
||||
volatile uint32_t i;
|
||||
|
||||
*GPIO_PAD_DIR0 = LED;
|
||||
gpio_pad_dir(LED);
|
||||
|
||||
while(1) {
|
||||
|
||||
*GPIO_DATA0 = LED;
|
||||
gpio_data(LED);
|
||||
|
||||
for(i=0; i<DELAY; i++) { continue; }
|
||||
|
||||
*GPIO_DATA0 = 0x00000000;
|
||||
|
||||
gpio_data(0);
|
||||
|
||||
for(i=0; i<DELAY; i++) { continue; }
|
||||
|
||||
};
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef LED_H
|
||||
#define LED_H
|
||||
|
||||
#define LED_YELLOW ((1 << LED_RED) | (1 << LED_GREEN) )
|
||||
#define LED_PURPLE ((1 << LED_RED) | (1 << LED_BLUE))
|
||||
#define LED_CYAN ( (1 << LED_GREEN) | (1 << LED_BLUE))
|
||||
#define LED_WHITE ((1 << LED_RED) | (1 << LED_GREEN) | (1 << LED_BLUE))
|
||||
#define LED_YELLOW ((1ULL << LED_RED) | (1ULL << LED_GREEN) )
|
||||
#define LED_PURPLE ((1ULL << LED_RED) | (1ULL << LED_BLUE))
|
||||
#define LED_CYAN ( (1ULL << LED_GREEN) | (1ULL << LED_BLUE))
|
||||
#define LED_WHITE ((1ULL << LED_RED) | (1ULL << LED_GREEN) | (1ULL << LED_BLUE))
|
||||
|
||||
#endif
|
||||
|
|
|
@ -9,18 +9,19 @@
|
|||
|
||||
void maca_rx_callback(volatile packet_t *p) {
|
||||
(void)p;
|
||||
toggle_gpio0(LED);
|
||||
toggle_gpio0(LED);
|
||||
gpio_data_set(1ULL<< LED);
|
||||
gpio_data_reset(1ULL<< LED);
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
volatile packet_t *p;
|
||||
|
||||
*GPIO_DATA0 = 0x00000000;
|
||||
*GPIO_PAD_DIR0 = ( 1 << LED );
|
||||
gpio_data(0);
|
||||
|
||||
gpio_pad_dir_set( 1ULL << LED );
|
||||
/* read from the data register instead of the pad */
|
||||
/* this is needed because the led clamps the voltage low */
|
||||
*GPIO_DATA_SEL0 = ( 1 << LED );
|
||||
gpio_data_sel( 1ULL << LED);
|
||||
|
||||
/* trim the reference osc. to 24MHz */
|
||||
trim_xtal();
|
||||
|
@ -32,12 +33,8 @@ void main(void) {
|
|||
maca_init();
|
||||
|
||||
/* sets up tx_on, should be a board specific item */
|
||||
*GPIO_FUNC_SEL2 = (0x01 << ((44-16*2)*2));
|
||||
*GPIO_PAD_DIR_SET1 = (1 << (44-32));
|
||||
|
||||
/* sets up rx_on, should be a board specific item */
|
||||
*GPIO_FUNC_SEL2 = (0x02 << ((45-16*2)*2));
|
||||
*GPIO_PAD_DIR_SET1 = (1 << (45-32));
|
||||
// *GPIO_FUNC_SEL2 = (0x01 << ((44-16*2)*2));
|
||||
gpio_pad_dir_set( 1ULL << 44 );
|
||||
|
||||
set_power(0x0f); /* 0dbm */
|
||||
set_channel(0); /* channel 11 */
|
||||
|
|
|
@ -46,15 +46,9 @@ void main(void) {
|
|||
// set_power(0x11); /* 0x11 = 3dbm, see 3-22 */
|
||||
set_power(0x12); /* 0x12 is the highest, not documented */
|
||||
|
||||
*GPIO_DATA0 = 0x00000000;
|
||||
*GPIO_PAD_DIR0 = ( 1 << LED );
|
||||
/* read from the data register instead of the pad */
|
||||
/* this is needed because the led clamps the voltage low */
|
||||
*GPIO_DATA_SEL0 = ( 1 << LED );
|
||||
|
||||
/* sets up tx_on, should be a board specific item */
|
||||
*GPIO_FUNC_SEL2 = (0x01 << ((44-16*2)*2));
|
||||
*GPIO_PAD_DIR_SET1 = (1 << (44-32));
|
||||
gpio_pad_dir_set( 1ULL << 44 );
|
||||
|
||||
print_welcome("rftest-tx");
|
||||
|
||||
|
|
|
@ -10,12 +10,4 @@ void print_welcome(char* testname);
|
|||
void dump_regs(uint32_t base, uint32_t len);
|
||||
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
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
|
||||
volatile uint8_t led;
|
||||
|
||||
#define LED_VAL LED_PURPLE
|
||||
#define led_init() do { *GPIO_PAD_DIR0 = LED_VAL; } while(0);
|
||||
#define led_on() do { led = 1; *GPIO_DATA0 = LED_VAL; } while(0);
|
||||
#define led_off() do { led = 0; *GPIO_DATA0 = 0x00000000; } while(0);
|
||||
#define LED LED_PURPLE
|
||||
#define led_init() do { gpio_pad_dir_set(LED); } while(0);
|
||||
#define led_on() do { led = 1; gpio_data_set(LED); } while(0);
|
||||
#define led_off() do { led = 0; gpio_data_set(0); } while(0);
|
||||
|
||||
void toggle_led(void) {
|
||||
if(0 == led) {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
void main(void) {
|
||||
|
||||
/* pin direction */
|
||||
*GPIO_PAD_DIR0 = LED;
|
||||
gpio_pad_dir_set(LED);
|
||||
|
||||
/* timer setup */
|
||||
/* CTRL */
|
||||
|
@ -34,13 +34,13 @@ void main(void) {
|
|||
while(1) {
|
||||
|
||||
/* blink on */
|
||||
*GPIO_DATA0 = LED;
|
||||
gpio_data_set(LED);
|
||||
|
||||
while((*TMR0_SCTRL >> 15) == 0) { continue; }
|
||||
*TMR0_SCTRL = 0; /*clear bit 15, and all the others --- should be ok, but clearly not "the right thing to do" */
|
||||
|
||||
/* blink off */
|
||||
*GPIO_DATA0 = 0x00000000;
|
||||
gpio_data_set(0);
|
||||
|
||||
while((*TMR0_SCTRL >> 15) == 0) { continue; }
|
||||
*TMR0_SCTRL = 0; /*clear bit 15, and all the others --- should be ok, but clearly not "the right thing to do" */
|
||||
|
|
Loading…
Add table
Reference in a new issue