2015-10-09 19:40:39 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2012, STMicroelectronics.
|
|
|
|
* 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
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Neither the name of the Institute nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 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.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2015-07-31 17:11:27 +02:00
|
|
|
/**
|
|
|
|
* \addtogroup stm32nucleo-spirit1-peripherals
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* \file
|
|
|
|
* Driver for the stm32nucleo-spirit1 LEDs
|
|
|
|
*/
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2015-07-24 16:30:10 +02:00
|
|
|
#include "contiki-conf.h"
|
|
|
|
#include "dev/leds.h"
|
2015-07-31 17:11:27 +02:00
|
|
|
#include "st-lib.h"
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2015-07-24 16:30:10 +02:00
|
|
|
#ifndef COMPILE_SENSORS
|
2015-07-31 17:11:27 +02:00
|
|
|
/* The Red LED (on SPIRIT1 exp board) is exposed only if the sensor board is NOT
|
|
|
|
* used, becasue of a pin conflict.
|
|
|
|
*/
|
2015-10-09 19:40:39 +02:00
|
|
|
extern st_lib_gpio_typedef *st_lib_a_led_gpio_port[];
|
2015-07-31 17:11:27 +02:00
|
|
|
extern const uint16_t st_lib_a_led_gpio_pin[];
|
2015-07-24 16:30:10 +02:00
|
|
|
#endif /*COMPILE_SENSORS*/
|
|
|
|
|
2015-10-09 19:40:39 +02:00
|
|
|
extern st_lib_gpio_typedef *st_lib_gpio_port[];
|
2015-07-31 17:11:27 +02:00
|
|
|
extern const uint16_t st_lib_gpio_pin[];
|
2015-07-24 16:30:10 +02:00
|
|
|
/*---------------------------------------------------------------------------*/
|
2015-10-09 19:40:39 +02:00
|
|
|
void
|
|
|
|
leds_arch_init(void)
|
2015-07-24 16:30:10 +02:00
|
|
|
{
|
2015-07-31 17:11:27 +02:00
|
|
|
/* We have at least one led, the one on the Nucleo (GREEN)*/
|
|
|
|
st_lib_bsp_led_init(LED2);
|
|
|
|
st_lib_bsp_led_off(LED2);
|
2015-07-24 16:30:10 +02:00
|
|
|
|
|
|
|
#ifndef COMPILE_SENSORS
|
2015-07-31 17:11:27 +02:00
|
|
|
/* The Red LED (on SPIRIT1 exp board) is exposed only if the sensor board is NOT
|
|
|
|
* used, becasue of a pin conflict.
|
|
|
|
*/
|
|
|
|
st_lib_radio_shield_led_init(RADIO_SHIELD_LED);
|
|
|
|
st_lib_radio_shield_led_off(RADIO_SHIELD_LED);
|
2015-07-24 16:30:10 +02:00
|
|
|
#endif /*COMPILE_SENSORS*/
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2015-10-09 19:40:39 +02:00
|
|
|
unsigned char
|
|
|
|
leds_arch_get(void)
|
2015-07-24 16:30:10 +02:00
|
|
|
{
|
2015-10-09 19:40:39 +02:00
|
|
|
unsigned char ret = 0;
|
|
|
|
if(st_lib_hal_gpio_read_pin(st_lib_gpio_port[LED2], st_lib_gpio_pin[LED2])) {
|
2015-07-24 16:30:10 +02:00
|
|
|
ret |= LEDS_GREEN;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef COMPILE_SENSORS
|
2015-07-31 17:11:27 +02:00
|
|
|
/* The Red LED (on SPIRIT1 exp board) is exposed only if the sensor board is NOT
|
|
|
|
* used, becasue of a pin conflict.
|
|
|
|
*/
|
2015-10-09 19:40:39 +02:00
|
|
|
if(st_lib_hal_gpio_read_pin(st_lib_a_led_gpio_port[RADIO_SHIELD_LED],
|
|
|
|
st_lib_a_led_gpio_pin[RADIO_SHIELD_LED])) {
|
2015-07-24 16:30:10 +02:00
|
|
|
ret |= LEDS_RED;
|
|
|
|
}
|
|
|
|
#endif /*COMPILE_SENSORS*/
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2015-10-09 19:40:39 +02:00
|
|
|
void
|
|
|
|
leds_arch_set(unsigned char leds)
|
2015-07-24 16:30:10 +02:00
|
|
|
{
|
2015-10-09 19:40:39 +02:00
|
|
|
if(leds & LEDS_GREEN) {
|
2015-07-31 17:11:27 +02:00
|
|
|
st_lib_bsp_led_on(LED2);
|
|
|
|
} else {
|
|
|
|
st_lib_bsp_led_off(LED2);
|
2015-07-24 16:30:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef COMPILE_SENSORS
|
2015-07-31 17:11:27 +02:00
|
|
|
/* The Red LED (on SPIRIT1 exp board) is exposed only if the sensor board is NOT
|
|
|
|
* used, becasue of a pin conflict.
|
|
|
|
*/
|
2015-10-09 19:40:39 +02:00
|
|
|
if(leds & LEDS_RED) {
|
2015-07-31 17:11:27 +02:00
|
|
|
st_lib_radio_shield_led_on(RADIO_SHIELD_LED);
|
|
|
|
} else {
|
|
|
|
st_lib_radio_shield_led_off(RADIO_SHIELD_LED);
|
2015-07-24 16:30:10 +02:00
|
|
|
}
|
|
|
|
#endif /*COMPILE_SENSORS*/
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2015-07-31 17:11:27 +02:00
|
|
|
/** @} */
|