periph_cpu_common.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2016 Leon George
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
18 #include "cpu.h"
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
27 #define CPUID_ADDR (&FCFG->MAC_BLE_0)
31 #define CPUID_LEN (16U)
32 
37 #define PROVIDES_PM_SET_LOWEST_CORTEXM
40 #ifndef DOXYGEN
44 #define HAVE_GPIO_MODE_T
45 typedef enum {
46  GPIO_IN = (IOCFG_INPUT_ENABLE | IOCFG_PULLCTL_OFF),
47  GPIO_IN_PD = (IOCFG_INPUT_ENABLE | IOCFG_PULLCTL_DOWN),
48  GPIO_IN_PU = (IOCFG_INPUT_ENABLE | IOCFG_PULLCTL_UP),
52 } gpio_mode_t;
53 
57 #define HAVE_GPIO_FLANK_T
58 typedef enum {
62 } gpio_flank_t;
63 
67 #define GPIO_PIN(x, y) (((x) & 0) | (y))
68 
69 /*
70  * @brief Invalid UART mode mask
71  *
72  * This mask is also used to force data_bits_t to be uint32_t type
73  * since it may be assigned a uint32_t variable in uart_mode
74  */
75 #define UART_INVALID_MODE (0x8000000)
76 
81 #define HAVE_UART_PARITY_T
82 typedef enum {
83  UART_PARITY_NONE = 0,
84  UART_PARITY_EVEN = (UART_LCRH_PEN | UART_LCRH_EPS),
85  UART_PARITY_ODD = UART_LCRH_PEN,
95 #define HAVE_UART_DATA_BITS_T
96 typedef enum {
97  UART_DATA_BITS_5 = UART_LCRH_WLEN_5,
98  UART_DATA_BITS_6 = UART_LCRH_WLEN_6,
99  UART_DATA_BITS_7 = UART_LCRH_WLEN_7,
100  UART_DATA_BITS_8 = UART_LCRH_WLEN_8
108 #define HAVE_UART_STOP_BITS_T
109 typedef enum {
110  UART_STOP_BITS_1 = 0,
111  UART_STOP_BITS_2 = UART_LCRH_STP2,
119 typedef struct {
120  uart_regs_t *regs;
121  int tx_pin;
122  int rx_pin;
123 #ifdef MODULE_PERIPH_UART_HW_FC
124  int rts_pin;
125  int cts_pin;
126 #endif
127  int intn;
128 } uart_conf_t;
137 typedef struct {
138  uint8_t cfg;
139  uint8_t chn;
140 } timer_conf_t;
141 
152 #define TIMER_CHANNEL_NUMOF 2
153 
154 #define PERIPH_I2C_NEED_READ_REG
155 #define PERIPH_I2C_NEED_READ_REGS
156 #define PERIPH_I2C_NEED_WRITE_REG
157 #define PERIPH_I2C_NEED_WRITE_REGS
158 
159 #endif /* ifndef DOXYGEN */
160 
161 #ifdef __cplusplus
162 }
163 #endif
164 
@ GPIO_OUT
select GPIO MASK as output
Definition: periph_cpu.h:161
@ GPIO_IN
select GPIO MASK as input
Definition: periph_cpu.h:160
#define IOCFG_EDGEDET_BOTH
edge detection on both edges
#define IOCFG_IOMODE_OPEN_DRAIN
open drain
#define IOCFG_PULLCTL_DOWN
pull down
#define IOCFG_EDGEDET_RISING
edge detection on rising edge
#define IOCFG_PULLCTL_UP
pull up
#define IOCFG_PULLCTL_OFF
no IO pull
#define IOCFG_EDGEDET_FALLING
edge detection on falling edge
gpio_mode_t
Available pin modes.
Definition: periph_cpu.h:91
@ GPIO_FALLING
emit interrupt on falling flank
@ GPIO_RISING
emit interrupt on rising flank
@ GPIO_BOTH
not supported -> random value
@ 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_PARITY_SPACE
space parity
Definition: periph_cpu.h:506
@ UART_PARITY_NONE
no parity
Definition: periph_cpu.h:502
@ UART_PARITY_EVEN
even parity
Definition: periph_cpu.h:503
@ UART_PARITY_ODD
odd parity
Definition: periph_cpu.h:504
@ UART_PARITY_MARK
mark parity
Definition: periph_cpu.h:505
@ UART_STOP_BITS_2
2 stop bits
Definition: periph_cpu.h:535
@ UART_STOP_BITS_1
1 stop bit
Definition: periph_cpu.h:534
@ UART_DATA_BITS_6
6 data bits
Definition: periph_cpu.h:519
@ UART_DATA_BITS_5
5 data bits
Definition: periph_cpu.h:518
@ UART_DATA_BITS_7
7 data bits
Definition: periph_cpu.h:520
@ UART_DATA_BITS_8
8 data bits
Definition: periph_cpu.h:521
gpio_flank_t
Enumeration of supported GPIO flanks.
uart_parity_t
Definition of possible parity modes.
Definition: periph_cpu.h:501
uart_stop_bits_t
Definition of possible stop bits lengths.
Definition: periph_cpu.h:533
#define UART_INVALID_MODE
Invalid UART mode mask.
Definition: periph_cpu.h:492
uart_data_bits_t
Definition of possible data bits lengths in a UART frame.
Definition: periph_cpu.h:517
Timer device configuration.
Definition: periph_cpu.h:260
UART device configuration.
Definition: periph_cpu.h:214
UART component registers.