Adjust data types for legacy LED API implementations

This commit is contained in:
George Oikonomou 2018-02-28 21:32:28 +00:00
parent d52bfa0f22
commit 0dfd39adcf
6 changed files with 19 additions and 19 deletions

View File

@ -46,10 +46,10 @@ leds_arch_init(void)
LEDS_PxOUT |= (LEDS_CONF_RED | LEDS_CONF_GREEN | LEDS_CONF_YELLOW);
}
/*---------------------------------------------------------------------------*/
unsigned char
leds_mask_t
leds_arch_get(void)
{
unsigned char leds;
leds_mask_t leds;
leds = LEDS_PxOUT;
return ((leds & LEDS_CONF_RED) ? 0 : LEDS_RED)
| ((leds & LEDS_CONF_GREEN) ? 0 : LEDS_GREEN)
@ -57,7 +57,7 @@ leds_arch_get(void)
}
/*---------------------------------------------------------------------------*/
void
leds_arch_set(unsigned char leds)
leds_arch_set(leds_mask_t leds)
{
LEDS_PxOUT = (LEDS_PxOUT & ~(LEDS_CONF_RED|LEDS_CONF_GREEN|LEDS_CONF_YELLOW))
| ((leds & LEDS_RED) ? 0 : LEDS_CONF_RED)

View File

@ -34,18 +34,18 @@
const struct simInterface leds_interface;
// COOJA variables
unsigned char simLedsValue;
leds_mask_t simLedsValue;
/*-----------------------------------------------------------------------------------*/
void leds_arch_init() {
simLedsValue = 0;
}
/*-----------------------------------------------------------------------------------*/
unsigned char leds_arch_get() {
leds_mask_t leds_arch_get() {
return simLedsValue;
}
/*-----------------------------------------------------------------------------------*/
void leds_arch_set(unsigned char leds) {
void leds_arch_set(leds_mask_t leds) {
if(leds != simLedsValue) {
simLedsValue = leds;
}

View File

@ -38,7 +38,7 @@
#define LED_G (1 << 16)
#define LED_R (1 << 17)
static volatile uint8_t leds;
static volatile leds_mask_t leds;
/*---------------------------------------------------------------------------*/
void
@ -49,14 +49,14 @@ leds_arch_init(void)
leds = 0;
}
/*---------------------------------------------------------------------------*/
unsigned char
leds_mask_t
leds_arch_get(void)
{
return leds;
}
/*---------------------------------------------------------------------------*/
void
leds_arch_set(unsigned char c)
leds_arch_set(leds_mask_t c)
{
uint32 on_mask = 0;
uint32 off_mask = 0;

View File

@ -38,7 +38,7 @@
*/
#include "dev/leds.h"
static unsigned char leds;
static leds_mask_t leds;
/*---------------------------------------------------------------------------*/
void
leds_arch_init(void)
@ -46,14 +46,14 @@ leds_arch_init(void)
leds = 0;
}
/*---------------------------------------------------------------------------*/
unsigned char
leds_mask_t
leds_arch_get(void)
{
return leds;
}
/*---------------------------------------------------------------------------*/
void
leds_arch_set(unsigned char l)
leds_arch_set(leds_mask_t l)
{
leds = l;
}

View File

@ -55,14 +55,14 @@ leds_arch_init(void)
LEDS_OFF(LEDS_MASK);
}
/*---------------------------------------------------------------------------*/
unsigned char
leds_mask_t
leds_arch_get(void)
{
return (unsigned char)(LED_IS_ON(LEDS_MASK) >> LED_START);
return (leds_mask_t)(LED_IS_ON(LEDS_MASK) >> LED_START);
}
/*---------------------------------------------------------------------------*/
void
leds_arch_set(unsigned char leds)
leds_arch_set(leds_mask_t leds)
{
unsigned int mask = (unsigned int)leds << LED_START;
LEDS_OFF(LEDS_MASK);

View File

@ -67,10 +67,10 @@
#define LEDS_3 (1 << (LED_3 - LED_START)) // 4
#define LEDS_4 (1 << (LED_4 - LED_START)) // 8
#define LEDS_GREEN LEDS_1
#define LEDS_YELLOW LEDS_2
#define LEDS_RED LEDS_3
#define LEDS_BLUE LEDS_4
#define LEDS_CONF_GREEN LEDS_1
#define LEDS_CONF_YELLOW LEDS_2
#define LEDS_CONF_RED LEDS_3
#define LEDS_CONF_BLUE LEDS_4
#define LEDS_CONF_ALL (LEDS_1 | LEDS_2 | LEDS_3 | LEDS_4)