Contiki 3.x
leds-arch.c
Go to the documentation of this file.
1 /**
2  * \addtogroup mbxxx-platform
3  *
4  * @{
5  */
6 
7 /*
8  * Copyright (c) 2010, STMicroelectronics.
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  * notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above
17  * copyright notice, this list of conditions and the following
18  * disclaimer in the documentation and/or other materials provided
19  * with the distribution.
20  * 3. The name of the author may not be used to endorse or promote
21  * products derived from this software without specific prior
22  * written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
25  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
28  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
30  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
32  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35  *
36  */
37 
38 /**
39 * \file
40 * Leds.
41 * \author
42 * Salvatore Pitrulli <salvopitru@users.sourceforge.net>
43 */
44 
45 #include PLATFORM_HEADER
46 #include BOARD_HEADER
47 #include "contiki-conf.h"
48 #include "dev/leds.h"
49 #include "hal/micro/micro-common.h"
51 
52 #define LEDS_PORT *((volatile uint32_t *)(GPIO_PxOUT_BASE+(GPIO_Px_OFFSET*(LEDS_CONF_PORT/8))))
53 
54 /*---------------------------------------------------------------------------*/
55 void
57 {
58  halGpioConfig(PORTx_PIN(LEDS_CONF_PORT, LEDS_CONF_RED_PIN), GPIOCFG_OUT);
59  halGpioConfig(PORTx_PIN(LEDS_CONF_PORT, LEDS_CONF_GREEN_PIN), GPIOCFG_OUT);
60  LEDS_PORT |= (LEDS_CONF_RED | LEDS_CONF_GREEN);
61 }
62 /*---------------------------------------------------------------------------*/
63 unsigned char
64 leds_arch_get(void)
65 {
66  return ((LEDS_PORT & LEDS_CONF_RED) ? 0 : LEDS_RED) |
67  ((LEDS_PORT & LEDS_CONF_GREEN) ? 0 : LEDS_GREEN);
68 }
69 /*---------------------------------------------------------------------------*/
70 void
71 leds_arch_set(unsigned char leds)
72 {
73  LEDS_PORT = (LEDS_PORT & ~(LEDS_CONF_RED | LEDS_CONF_GREEN)) |
74  ((leds & LEDS_RED) ? 0 : LEDS_CONF_RED) |
75  ((leds & LEDS_GREEN) ? 0 : LEDS_CONF_GREEN);
76 }
77 /*---------------------------------------------------------------------------*/
78 /** @} */
#define LEDS_RED
LED1 (Red) -&gt; PC0.
Definition: board.h:89
void leds_arch_init(void)
Leds implementation.
Definition: leds-arch.c:48
Utility and convenience functions for STM32W108 microcontroller, common to both the full and minimal ...
#define PORTx_PIN(x, y)
Some registers and variables require indentifying GPIO by a single number instead of the port and pin...
Definition: micro-common.h:55
#define LEDS_GREEN
LED3 (Green) -&gt; PC2.
Definition: board.h:81
Minimal Hal functions common across all microcontroller-specific files.
void halGpioConfig(uint32_t io, uint32_t config)
Configure an IO pin&#39;s operating mode.
Definition: micro-common.c:48