periph_cpu.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Freie Universität Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
20 #ifndef PERIPH_CPU_H
21 #define PERIPH_CPU_H
22 
23 #include <stdint.h>
24 
25 #include "cpu.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #ifndef DOXYGEN
32 
36 #define HAVE_GPIO_T
37 typedef uint8_t gpio_t;
43 #define GPIO_PIN(port, pin) (gpio_t)((port << 5) | pin)
44 
49 #define PIN_DIR_IN (0x00 << 0)
50 #define PIN_DIR_OUT (0x01 << 0)
51 #define PIN_MODE_PU (0x00 << 1)
52 #define PIN_MODE_PD (0x02 << 1)
53 #define PIN_MODE_NONE (0x03 << 1)
54 #define PIN_MODE_OD (0x01 << 3)
55 
56 #define HAVE_GPIO_MODE_T
57 typedef enum {
58  GPIO_IN = (PIN_DIR_IN | PIN_MODE_NONE),
59  GPIO_IN_PD = (PIN_DIR_IN | PIN_MODE_PD),
60  GPIO_IN_PU = (PIN_DIR_IN | PIN_MODE_PU),
61  GPIO_OUT = (PIN_DIR_OUT | PIN_MODE_NONE),
62  GPIO_OD = (PIN_DIR_OUT | PIN_MODE_OD),
63  GPIO_OD_PU = (PIN_DIR_OUT | PIN_MODE_OD | PIN_MODE_PU)
64 } gpio_mode_t;
66 #endif /* ndef DOXYGEN */
67 
71 #define PROVIDES_PM_LAYERED_OFF
72 
76 #define PM_NUM_MODES (2U)
77 
81 typedef struct {
82  LPC_UART_TypeDef *dev;
83  uint8_t irq_rx;
84  uint8_t clk_offset;
85  uint8_t pinsel;
86  uint8_t pinsel_shift;
87  uint8_t pinsel_af;
88 } uart_conf_t;
89 
90 #ifdef __cplusplus
91 }
92 #endif
93 
94 #endif /* PERIPH_CPU_H */
95 
GPIO_IN_PD
@ GPIO_IN_PD
configure as input with pull-down resistor
Definition: gpio.h:120
GPIO_OD
@ GPIO_OD
configure as output in open-drain mode without pull resistor
Definition: gpio.h:123
uart_conf_t::dev
LPC_UART_TypeDef * dev
pointer to the UART device
Definition: periph_cpu.h:82
GPIO_OUT
@ GPIO_OUT
configure as output in push-pull mode
Definition: gpio.h:122
GPIO_IN_PU
@ GPIO_IN_PU
configure as input with pull-up resistor
Definition: gpio.h:121
uart_conf_t::pinsel_af
uint8_t pinsel_af
Alternate function of the PINSEL# register.
Definition: periph_cpu.h:87
uart_conf_t::irq_rx
uint8_t irq_rx
RX IRQ number.
Definition: periph_cpu.h:83
uart_conf_t::clk_offset
uint8_t clk_offset
The offset of the periph in the clk sel.
Definition: periph_cpu.h:84
GPIO_IN
@ GPIO_IN
configure as input without pull resistor
Definition: gpio.h:119
uart_conf_t
UART device configuration.
Definition: periph_cpu.h:166
uart_conf_t::pinsel_shift
uint8_t pinsel_shift
TX/RX bitshift of the PINSEL# register.
Definition: periph_cpu.h:86
GPIO_OD_PU
@ GPIO_OD_PU
configure as output in open-drain mode with pull resistor enabled
Definition: gpio.h:125
uart_conf_t::pinsel
uint8_t pinsel
PINSEL# of the RX and TX pin.
Definition: periph_cpu.h:85
gpio_mode_t
gpio_mode_t
Available pin modes.
Definition: periph_cpu.h:70
gpio_t
unsigned int gpio_t
GPIO type identifier.
Definition: gpio.h:91