Contiki 2.5
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 int32u *)(GPIO_PxOUT_BASE+(GPIO_Px_OFFSET*(led/8)))) ^= BIT(led&7);
40  }
41  )
42 }