Contiki 3.x
led.c
Go to the documentation of this file.
1 /** @file hal/micro/cortexm3/led.c
2  * @brief LED manipulation routines; stack and example APIs
3  *
4  * <!--(C) COPYRIGHT 2010 STMicroelectronics. All rights reserved. -->
5  */
6 
7 #include PLATFORM_HEADER
8 #include BOARD_HEADER
9 #include "hal/micro/led.h"
10 #include "hal/micro/micro-common.h"
12 
13 void halInitLed(void)
14 {
15  /* Set GPIO pins for Led D1 and Led D3 */
16  halGpioConfig(LED_D1, GPIOCFG_OUT);
17  halGpioConfig(LED_D3, GPIOCFG_OUT);
18  /* Switch off Led D1,D3 */
19  halClearLed(LED_D1);
20  halClearLed(LED_D3);
21 }
22 
24 {
25  halGpioSet(led, 0);
26 }
27 
29 {
30  halGpioSet(led, 1);
31 }
32 
34 {
35  //to avoid contention with other code using the other pins for other
36  //purposes, we disable interrupts since this is a read-modify-write
37  ATOMIC(
38  if(led/8 < 3) {
39  *((volatile uint32_t *)(GPIO_PxOUT_BASE+(GPIO_Px_OFFSET*(led/8)))) ^= BIT(led&7);
40  }
41  )
42 }
Utility and convenience functions for STM32W108 microcontroller, common to both the full and minimal ...
Header for led APIs.
void halSetLed(HalBoardLed led)
Turns on (sets) a GPIO pin connected to an LED so that the LED turns on.
Definition: led.c:23
void halGpioSet(uint32_t gpio, boolean value)
Set/Clear single GPIO bit.
Definition: micro-common.c:63
#define BIT(x)
Useful to reference a single bit of a byte.
void halToggleLed(HalBoardLed led)
Atomically wraps an XOR or similar operation for a single GPIO pin attached to an LED...
Definition: led.c:33
void halInitLed(void)
Configures GPIOs pertaining to the control of LEDs.
Definition: led.c:13
Minimal Hal functions common across all microcontroller-specific files.
uint8_t HalBoardLed
Ensures that the definitions from the BOARD_HEADER are always used as parameters to the LED functions...
Definition: led.h:28
void halClearLed(HalBoardLed led)
Turns off (clears) a GPIO pin connected to an LED, which turns off the LED.
Definition: led.c:28
#define ATOMIC(blah)
A block of code may be made atomic by wrapping it with this macro.
Definition: gnu.h:459
void halGpioConfig(uint32_t io, uint32_t config)
Configure an IO pin&#39;s operating mode.
Definition: micro-common.c:48