Contiki 2.6

led.c

Go to the documentation of this file.
00001 /** @file hal/micro/cortexm3/led.c
00002  *  @brief LED manipulation routines; stack and example APIs
00003  *
00004  * <!--(C) COPYRIGHT 2010 STMicroelectronics. All rights reserved.        -->
00005  */
00006 
00007 #include PLATFORM_HEADER
00008 #include BOARD_HEADER
00009 #include "hal/micro/led.h"
00010 #include "hal/micro/micro-common.h"
00011 #include "hal/micro/cortexm3/micro-common.h"
00012 
00013 void halInitLed(void)
00014 {
00015   /* Set GPIO pins for Led D1 and Led D3  */
00016   halGpioConfig(LED_D1, GPIOCFG_OUT);
00017   halGpioConfig(LED_D3, GPIOCFG_OUT);
00018   /* Switch off Led D1,D3 */
00019   halClearLed(LED_D1);
00020   halClearLed(LED_D3);
00021 }
00022 
00023 void halSetLed(HalBoardLed led)
00024 {
00025   halGpioSet(led, 0);
00026 }
00027 
00028 void halClearLed(HalBoardLed led)
00029 {
00030   halGpioSet(led, 1);
00031 }
00032 
00033 void halToggleLed(HalBoardLed led)
00034 {
00035   //to avoid contention with other code using the other pins for other
00036   //purposes, we disable interrupts since this is a read-modify-write
00037   ATOMIC(
00038     if(led/8 < 3) {
00039       *((volatile int32u *)(GPIO_PxOUT_BASE+(GPIO_Px_OFFSET*(led/8)))) ^= BIT(led&7);
00040     }
00041   )
00042 }