[BEETLE] Add LED Emulation

The current version of MBED test environment requires LEDs to be present
in the platform.

Beetle HW does not provide any user programmable LEDs. This patch provides an
emulation of the feature by using dummy PINs.

Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
pull/1852/head
Vincenzo Frascino 2016-06-02 18:18:16 +01:00
parent 4f61cfd7f6
commit ce1c2c780a
3 changed files with 27 additions and 10 deletions

View File

@ -126,13 +126,14 @@ typedef enum {
SENSOR_SDA = 506,
SENSOR_SCL = 507,
// Emulated LEDS
LED1 = 1001,
LED2 = 1002,
LED3 = 1003,
LED4 = 1004,
// Not connected
NC = (int)0xFFFFFFFF,
// LEDS not connected
LED1 = NC,
LED2 = NC,
LED3 = NC,
LED4 = NC,
} PinName;
typedef enum {

View File

@ -24,6 +24,9 @@ uint32_t gpio_set(PinName pin) {
pin_value = pin;
} else if (pin >= 16 && pin <= 31) {
pin_value = pin-16;
} else if (pin >= 1001 && pin <= 1004) {
/* Emulated LEDs */
return (1);
}
pin_function(pin, 0);
@ -44,6 +47,9 @@ void gpio_init(gpio_t *obj, PinName pin) {
pin_value = pin;
} else if (pin >= 16 && pin <= 31) {
pin_value = pin-16;
} else if (pin >= 1001 && pin <= 1004) {
/* Emulated LEDs */
return;
}
obj->mask = 0x1 << pin_value;

View File

@ -37,15 +37,25 @@ typedef struct {
} gpio_t;
static inline void gpio_write(gpio_t *obj, int value) {
if (value == 1){
*obj->reg_data |= (obj->mask);
} else if (value == 0){
*obj->reg_data &= ~(obj->mask);
if (obj->pin < LED1 || obj->pin > LED4) {
if (value == 1) {
*obj->reg_data |= (obj->mask);
} else if (value == 0){
*obj->reg_data &= ~(obj->mask);
}
} else {
/* Emulated LEDs return without taking any action */
return;
}
}
static inline int gpio_read(gpio_t *obj) {
return ((*obj->reg_in & obj->mask) ? 1 : 0);
if (obj->pin < LED1 || obj->pin > LED4) {
return ((*obj->reg_in & obj->mask) ? 1 : 0);
} else {
/* Emulated LEDs return OFF always */
return 0;
}
}
#ifdef __cplusplus