Implement and use the new LED HAL (OpenMote)
This commit is contained in:
parent
f468fcd2a7
commit
e39472f7d0
@ -63,14 +63,21 @@
|
||||
* @{
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define LEDS_RED 16 /**< LED1 (Red) -> PC4 */
|
||||
#define LEDS_YELLOW 64 /**< LED2 (Yellow) -> PC6 */
|
||||
#define LEDS_GREEN 128 /**< LED3 (Green) -> PC7 */
|
||||
#define LEDS_ORANGE 32 /**< LED4 (Orange) -> PC5 */
|
||||
#define LEDS_CONF_ALL 240
|
||||
#define LEDS_ARCH_L1_PORT GPIO_C_NUM
|
||||
#define LEDS_ARCH_L1_PIN 4
|
||||
#define LEDS_ARCH_L2_PORT GPIO_C_NUM
|
||||
#define LEDS_ARCH_L2_PIN 6
|
||||
#define LEDS_ARCH_L3_PORT GPIO_C_NUM
|
||||
#define LEDS_ARCH_L3_PIN 7
|
||||
#define LEDS_ARCH_L4_PORT GPIO_C_NUM
|
||||
#define LEDS_ARCH_L4_PIN 5
|
||||
|
||||
/* Notify various examples that we have LEDs */
|
||||
#define PLATFORM_HAS_LEDS 1
|
||||
#define LEDS_CONF_RED 1
|
||||
#define LEDS_CONF_YELLOW 2
|
||||
#define LEDS_CONF_GREEN 4
|
||||
#define LEDS_CONF_ORANGE 8
|
||||
|
||||
#define LEDS_CONF_COUNT 4
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** \name USB configuration
|
||||
|
@ -1,10 +1,11 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Texas Instruments Incorporated - http://www.ti.com/
|
||||
* Copyright (c) 2018, George Oikonomou - http://www.spd.gr
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
@ -26,48 +27,32 @@
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \addtogroup openmote-cc2538
|
||||
* @{
|
||||
*
|
||||
* \defgroup openmote-leds OpenMote-CC2538 LED driver
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* LED driver implementation for the OpenMote-CC2538 platform
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "reg.h"
|
||||
#include "dev/leds.h"
|
||||
#include "dev/gpio.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define LEDS_GPIO_PIN_MASK LEDS_ALL
|
||||
const leds_t leds_arch_leds[] = {
|
||||
{
|
||||
.pin = GPIO_PORT_PIN_TO_GPIO_HAL_PIN(LEDS_ARCH_L1_PORT, LEDS_ARCH_L1_PIN),
|
||||
.negative_logic = false
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PORT_PIN_TO_GPIO_HAL_PIN(LEDS_ARCH_L2_PORT, LEDS_ARCH_L2_PIN),
|
||||
.negative_logic = false
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PORT_PIN_TO_GPIO_HAL_PIN(LEDS_ARCH_L3_PORT, LEDS_ARCH_L3_PIN),
|
||||
.negative_logic = false
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PORT_PIN_TO_GPIO_HAL_PIN(LEDS_ARCH_L4_PORT, LEDS_ARCH_L4_PIN),
|
||||
.negative_logic = false
|
||||
},
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_init(void)
|
||||
{
|
||||
GPIO_SET_OUTPUT(GPIO_C_BASE, LEDS_GPIO_PIN_MASK);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned char
|
||||
leds_arch_get(void)
|
||||
{
|
||||
return GPIO_READ_PIN(GPIO_C_BASE, LEDS_GPIO_PIN_MASK);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_set(unsigned char leds)
|
||||
{
|
||||
GPIO_WRITE_PIN(GPIO_C_BASE, LEDS_GPIO_PIN_MASK, leds);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
@ -82,7 +82,7 @@
|
||||
void board_init(void);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
fade(unsigned char l)
|
||||
fade(leds_mask_t l)
|
||||
{
|
||||
volatile int i;
|
||||
int k, j;
|
||||
|
Loading…
Reference in New Issue
Block a user