rfLPC
A low level library for using NXP's LPC17xx SoC. Config is given for MBED prototyping board
leds.h
Go to the documentation of this file.
1 /* This file is part of rflpc. Copyright 2010-2011 Michael Hauspie
2  *
3  * rflpc is free software: you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation, either version 3 of the License, or
6  * (at your option) any later version.
7  *
8  * rflpc is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with rflpc. If not, see <http://www.gnu.org/licenses/>.
15  */
19 /*
20  Author: Michael Hauspie <michael.hauspie@univ-lille1.fr>
21  Created:
22  Time-stamp: <2014-05-28 16:59:16 (hauspie)>
23 */
24 #ifndef __RFLPC_LEDS_H__
25 #define __RFLPC_LEDS_H__
26 
33 #include "gpio.h"
34 
41 #define RFLPC_LED_1 (1 << RFLPC_PIN_GET_PIN(RFLPC_LED_1_PIN))
42 
43 #define RFLPC_LED_2 (1 << RFLPC_PIN_GET_PIN(RFLPC_LED_2_PIN))
44 
45 #define RFLPC_LED_3 (1 << RFLPC_PIN_GET_PIN(RFLPC_LED_3_PIN))
46 
47 #define RFLPC_LED_4 (1 << RFLPC_PIN_GET_PIN(RFLPC_LED_4_PIN))
48 
53 static inline void rflpc_led_init()
54 {
55  /* Connect LED pins */
60 }
61 
63 static inline void rflpc_led_set(uint32_t l)
64 {
66 }
67 
68 
70 static inline void rflpc_led_clr(uint32_t l)
71 {
73 }
74 
75 
77 static inline void rflpc_led_val(uint32_t l)
78 {
80 }
81 
89 static inline void rflpc_led_binary_value(uint8_t v)
90 {
91  uint32_t leds = 0;
92  if (v & 1)
93  leds |= RFLPC_LED_4;
94  if (v & 2)
95  leds |= RFLPC_LED_3;
96  if (v & 4)
97  leds |= RFLPC_LED_2;
98  if (v & 8)
99  leds |= RFLPC_LED_1;
100  rflpc_led_val(leds);
101 }
102 
105 #endif
#define RFLPC_LED_2
LED 2.
Definition: leds.h:43
void rflpc_gpio_set_pin_mode_output(rflpc_pin_t pin, uint8_t val)
Sets a pin to output mode Uses a pin as output pin and sets its value.
#define RFLPC_LED_4_PIN
On which pin is the LED4 ?
Definition: config-mbed.h:138
static void rflpc_led_init()
Inits the GPIO port to use the leds.
Definition: leds.h:53
static void rflpc_led_set(uint32_t l)
Turns the given led(s) on.
Definition: leds.h:63
GPIO peripheral driver.
#define RFLPC_PIN_GET_PORT(pin)
Returns the X part of the PX_Y form pin description (i.e.
Definition: pinconf.h:50
#define RFLPC_LED_2_PIN
On which pin is the LED2 ?
Definition: config-mbed.h:134
static void rflpc_led_clr(uint32_t l)
Clears the given led(s) (turn them off)
Definition: leds.h:70
#define RFLPC_LED_4
LED 4.
Definition: leds.h:47
#define RFLPC_LED_1_PIN
On which pin is the LED1 ?
Definition: config-mbed.h:132
void rflpc_gpio_set_val(uint8_t gpio, uint32_t val, uint32_t mask)
Sets the value of multiple pins of a given port from a mask and a value.
void rflpc_gpio_set_pins_from_mask(uint8_t gpio, uint32_t mask)
Set multiple pins from a mask.
#define RFLPC_LED_3
LED 3.
Definition: leds.h:45
static void rflpc_led_binary_value(uint8_t v)
Turns the led to reflect a binary 4 digit number.
Definition: leds.h:89
void rflpc_gpio_clr_pins_from_mask(uint8_t gpio, uint32_t mask)
Clean multiple pins from a mask.
#define RFLPC_LED_1
LED 1.
Definition: leds.h:41
static void rflpc_led_val(uint32_t l)
Turns on the leds included in the mask.
Definition: leds.h:77
#define RFLPC_LED_3_PIN
On which pin is the LED3 ?
Definition: config-mbed.h:136