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 
9 #pragma once
10 
22 #include <stdint.h>
23 
24 #include "cpu.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #ifndef DOXYGEN
35 #define HAVE_GPIO_T
36 typedef uint8_t gpio_t;
42 #define GPIO_PIN(port, pin) (gpio_t)((port << 5) | pin)
43 
48 #define PIN_DIR_IN (0x00 << 0)
49 #define PIN_DIR_OUT (0x01 << 0)
50 #define PIN_MODE_PU (0x00 << 1)
51 #define PIN_MODE_PD (0x02 << 1)
52 #define PIN_MODE_NONE (0x03 << 1)
53 #define PIN_MODE_OD (0x01 << 3)
54 
55 #define HAVE_GPIO_MODE_T
56 typedef enum {
57  GPIO_IN = (PIN_DIR_IN | PIN_MODE_NONE),
58  GPIO_IN_PD = (PIN_DIR_IN | PIN_MODE_PD),
59  GPIO_IN_PU = (PIN_DIR_IN | PIN_MODE_PU),
60  GPIO_OUT = (PIN_DIR_OUT | PIN_MODE_NONE),
61  GPIO_OD = (PIN_DIR_OUT | PIN_MODE_OD),
62  GPIO_OD_PU = (PIN_DIR_OUT | PIN_MODE_OD | PIN_MODE_PU)
63 } gpio_mode_t;
65 #endif /* ndef DOXYGEN */
66 
70 #define PROVIDES_PM_LAYERED_OFF
71 
75 #define PM_NUM_MODES (3U)
76 
80 typedef struct {
81  LPC_UART_TypeDef *dev;
82  uint8_t irq_rx;
83  uint8_t clk_offset;
84  uint8_t pinsel;
85  uint8_t pinsel_shift;
86  uint8_t pinsel_af;
87 } uart_conf_t;
88 
89 #ifdef __cplusplus
90 }
91 #endif
92 
@ GPIO_OUT
select GPIO MASK as output
Definition: periph_cpu.h:164
@ GPIO_IN
select GPIO MASK as input
Definition: periph_cpu.h:163
gpio_mode_t
Available pin modes.
Definition: periph_cpu.h:91
unsigned int gpio_t
GPIO type identifier.
Definition: gpio.h:91
@ GPIO_OD
configure as output in open-drain mode without pull resistor
Definition: gpio.h:123
@ GPIO_IN_PU
configure as input with pull-up resistor
Definition: gpio.h:121
@ GPIO_OD_PU
configure as output in open-drain mode with pull resistor enabled
Definition: gpio.h:125
@ GPIO_IN_PD
configure as input with pull-down resistor
Definition: gpio.h:120
UART device configuration.
Definition: periph_cpu.h:217
uint8_t pinsel_shift
TX/RX bitshift of the PINSEL# register.
Definition: periph_cpu.h:85
uint8_t pinsel
PINSEL# of the RX and TX pin.
Definition: periph_cpu.h:84
LPC_UART_TypeDef * dev
pointer to the UART device
Definition: periph_cpu.h:81
uint8_t irq_rx
RX IRQ number.
Definition: periph_cpu.h:82
uint8_t clk_offset
The offset of the periph in the clk sel.
Definition: periph_cpu.h:83
uint8_t pinsel_af
Alternate function of the PINSEL# register.
Definition: periph_cpu.h:86