cc2531 LED support

This commit is contained in:
George Oikonomou 2011-12-16 18:54:44 +00:00 committed by George Oikonomou
parent 1db1649b6a
commit 26ae56fcaf
2 changed files with 40 additions and 9 deletions

View file

@ -114,10 +114,17 @@
#endif #endif
/* Some files include leds.h before us */ /* Some files include leds.h before us */
#undef LEDS_GREEN
#undef LEDS_YELLOW #undef LEDS_YELLOW
#undef LEDS_RED #undef LEDS_RED
#define LEDS_YELLOW 4 #define LEDS_YELLOW 4
#if MODEL_CC2531
#define LEDS_RED 1
#define LEDS_GREEN 2
#else
#define LEDS_GREEN 1
#define LEDS_RED 2 #define LEDS_RED 2
#endif
/* DMA Configuration */ /* DMA Configuration */
#ifndef DMA_CONF_ON #ifndef DMA_CONF_ON

View file

@ -42,13 +42,25 @@
#include "cc253x.h" #include "cc253x.h"
/* /*
* LEDS * Smart RF LEDs
* 1: P1_0 * 1: P1_0 (Green)
* 2: P1_1 * 2: P1_1 (Red)
* 3: P1_4 * 3: P1_4 (Yellow)
* 4: P0_1 (LED4 shares port/pin with B1 and is currently unused) * 4: P0_1 (LED4 shares port/pin with B1 and is currently unused)
*
* USB Dongle LEDs
* 1: P0_0 (Red)
* 2: P1_1 (Green - active: low)
*/ */
#if MODEL_CC2531
#define LED2_PIN P0_0
#define LED1_PIN P1_1
/* P0DIR and P0SEL masks */
#define LED2_MASK 0x01
#define LED1_MASK 0x02
#else
/* H/W Connections */ /* H/W Connections */
#define LED1_PIN P1_0 #define LED1_PIN P1_0
#define LED2_PIN P1_1 #define LED2_PIN P1_1
@ -59,29 +71,41 @@
#define LED2_MASK 0x02 #define LED2_MASK 0x02
#define LED3_MASK 0x10 #define LED3_MASK 0x10
#define LED4_MASK 0x02 #define LED4_MASK 0x02
#endif
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void
leds_arch_init(void) leds_arch_init(void)
{ {
#if MODEL_CC2531
P1SEL &= ~LED1_MASK;
P1DIR |= LED1_MASK;
P0SEL &= ~LED2_MASK;
P0DIR |= LED2_MASK;
#else
P1SEL &= ~(LED1_MASK | LED2_MASK | LED3_MASK); P1SEL &= ~(LED1_MASK | LED2_MASK | LED3_MASK);
P1DIR |= (LED1_MASK | LED2_MASK | LED3_MASK); P1DIR |= (LED1_MASK | LED2_MASK | LED3_MASK);
#endif
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
unsigned char unsigned char
leds_arch_get(void) leds_arch_get(void)
{ {
unsigned char v; #if MODEL_CC2531
return (unsigned char) (LED1_PIN | ((LED2_PIN ^ 0x01) << 1));
v = (unsigned char) (LED1_PIN | (LED2_PIN << 1) | (LED3_PIN << 2)); #else
return (unsigned char) (LED1_PIN | (LED2_PIN << 1) | (LED3_PIN << 2));
return v; #endif
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void
leds_arch_set(unsigned char leds) leds_arch_set(unsigned char leds)
{ {
LED1_PIN = leds & 0x01; LED1_PIN = leds & 0x01;
#if MODEL_CC2531
LED2_PIN = ((leds & 0x02) >> 1) ^ 0x01;
#else
LED2_PIN = (leds & 0x02) >> 1; LED2_PIN = (leds & 0x02) >> 1;
LED3_PIN = (leds & 0x04) >> 2; LED3_PIN = (leds & 0x04) >> 2;
#endif
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/