Loading...
Searching...
No Matches
periph_cpu.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
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
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25#include <stdint.h>
26#include "cpu.h"
27
32#define __IO volatile
34
39#define PM_NUM_MODES (4)
41
45typedef struct {
47 __IO uint32_t DIR;
49 uint32_t _reserved[3];
53 __IO uint32_t MASK;
57 __IO uint32_t PIN;
59 __IO uint32_t SET;
61 __IO uint32_t CLR;
63
67#define FIO_PORTS ((FIO_PORT_t*)FIO_BASE_ADDR)
68
72#define PINSEL ((__IO uint32_t *)(PINSEL_BASE_ADDR))
73
77#define PINMODE ((__IO uint32_t *)(PINSEL_BASE_ADDR + 0x40))
78
85int gpio_init_mux(unsigned pin, unsigned mux);
86
90#define GPIO_PIN(port, pin) (port<<5 | pin)
91
92#ifndef DOXYGEN
93#define HAVE_GPIO_FLANK_T
94typedef enum {
95 GPIO_FALLING = 1,
96 GPIO_RISING = 2,
97 GPIO_BOTH = 3
99#endif /* ifndef DOXYGEN */
100
104typedef struct {
105 lpc23xx_uart_t *dev;
106 uint8_t irq_prio_rx;
107 uint8_t pinsel_rx;
108 uint8_t pinsel_tx;
109 uint32_t pinsel_msk_rx;
110 uint32_t pinsel_msk_tx;
112
116typedef struct {
117 lpc23xx_spi_t *dev;
118 uint8_t pinsel_mosi;
119 uint8_t pinsel_miso;
120 uint8_t pinsel_clk;
123 uint32_t pinsel_msk_clk;
124} spi_conf_t;
125
129#define TIMER_CHANNEL_NUMOF (4U)
130
134#define PERIPH_TIMER_PROVIDES_SET
135
140#define PERIPH_SPI_NEEDS_INIT_CS
141#define PERIPH_SPI_NEEDS_TRANSFER_BYTE
142#define PERIPH_SPI_NEEDS_TRANSFER_REG
143#define PERIPH_SPI_NEEDS_TRANSFER_REGS
145
146#ifndef DOXYGEN
151#define HAVE_SPI_CLK_T
152typedef enum {
153 SPI_CLK_100KHZ = 100,
154 SPI_CLK_400KHZ = 400,
155 SPI_CLK_1MHZ = 1000,
156 SPI_CLK_5MHZ = 5000,
157 SPI_CLK_10MHZ = 10000
158} spi_clk_t;
160#endif /* ndef DOXYGEN */
161
172#define DAC_NUMOF (1U)
173
174#ifndef DOXYGEN
179#define HAVE_ADC_RES_T
180typedef enum {
181 ADC_RES_16BIT = 0xff,
182 ADC_RES_14BIT = 0xfe,
183 ADC_RES_12BIT = 0xfd,
184 ADC_RES_10BIT = 0b000,
185 ADC_RES_9BIT = 0b001,
186 ADC_RES_8BIT = 0b010,
187 ADC_RES_7BIT = 0b011,
188 ADC_RES_6BIT = 0b100,
189 ADC_RES_5BIT = 0b101,
190 ADC_RES_4BIT = 0b110,
191 ADC_RES_3BIT = 0b111,
192} adc_res_t;
194#endif /* ndef DOXYGEN */
195
199typedef struct {
200 uint8_t chan;
201 uint8_t pinsel;
202 uint32_t pinsel_msk;
203} adc_conf_t;
204
205#ifndef DOXYGEN
210#define HAVE_I2C_SPEED_T
211typedef enum {
212 I2C_SPEED_LOW = 10000,
213 I2C_SPEED_NORMAL = 100000,
214 I2C_SPEED_FAST = 400000,
217#endif /* ndef DOXYGEN */
218
222typedef struct {
223 lpc23xx_i2c_t *dev;
225 uint8_t irq_prio;
226 uint8_t pinsel_sda;
227 uint8_t pinsel_scl;
230} i2c_conf_t;
231
236#define PERIPH_I2C_NEED_READ_REG
237#define PERIPH_I2C_NEED_WRITE_REG
239
245#if defined(MODULE_PERIPH_RTC) && !defined(RTC_NORMALIZE_COMPAT)
246#define RTC_NORMALIZE_COMPAT (1)
247#endif
249
250#ifdef __cplusplus
251}
252#endif
253
gpio_flank_t
Definition periph_cpu.h:179
i2c_speed_t
Definition periph_cpu.h:275
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition periph_cpu.h:277
@ I2C_SPEED_LOW
low speed mode: ~10 kbit/s
Definition periph_cpu.h:276
@ I2C_SPEED_FAST
fast mode: ~400 kbit/s
Definition periph_cpu.h:278
spi_clk_t
Definition periph_cpu.h:351
@ SPI_CLK_10MHZ
drive the SPI bus with 10MHz
Definition periph_cpu.h:356
@ SPI_CLK_5MHZ
drive the SPI bus with 5MHz
Definition periph_cpu.h:355
@ SPI_CLK_400KHZ
drive the SPI bus with 400KHz
Definition periph_cpu.h:353
@ SPI_CLK_1MHZ
drive the SPI bus with 1MHz
Definition periph_cpu.h:354
@ SPI_CLK_100KHZ
drive the SPI bus with 100KHz
Definition periph_cpu.h:352
void gpio_init_mux(gpio_t pin, uint8_t over, uint8_t sel, uint8_t func)
Configure an alternate function for the given pin.
adc_res_t
Possible ADC resolution settings.
Definition adc.h:92
@ ADC_RES_16BIT
ADC resolution: 16 bit.
Definition adc.h:98
@ ADC_RES_8BIT
ADC resolution: 8 bit.
Definition adc.h:94
@ ADC_RES_14BIT
ADC resolution: 14 bit.
Definition adc.h:97
@ ADC_RES_6BIT
ADC resolution: 6 bit.
Definition adc.h:93
@ ADC_RES_10BIT
ADC resolution: 10 bit.
Definition adc.h:95
@ ADC_RES_12BIT
ADC resolution: 12 bit.
Definition adc.h:96
#define __IO
LPC2387 MCU defines.
Definition periph_cpu.h:32
Fast GPIO register definition struct.
Definition periph_cpu.h:45
__IO uint32_t MASK
Set bits to ignore corresponding bits when accessing PIN, SET or CLR register of this port.
Definition periph_cpu.h:53
uint32_t _reserved[3]
12 bytes of reserved memory we don't need to access
Definition periph_cpu.h:49
__IO uint32_t SET
Output pins are set to high by setting the corresponding bit.
Definition periph_cpu.h:59
__IO uint32_t DIR
Direction: Output if corresponding bit is set, otherwise input.
Definition periph_cpu.h:47
__IO uint32_t PIN
The current state of each pin of this port is accessible here (regardless of direction): If bit is se...
Definition periph_cpu.h:57
__IO uint32_t CLR
Output pins are set to low by setting the corresponding bit.
Definition periph_cpu.h:61
ADC device configuration.
Definition periph_cpu.h:377
uint8_t pinsel
PINSEL# of the ADC pin.
Definition periph_cpu.h:201
uint32_t pinsel_msk
PINSEL Mask for ADC pin.
Definition periph_cpu.h:202
I2C configuration structure.
Definition periph_cpu.h:298
uint32_t pinsel_msk_scl
SCL PINSEL Mask.
Definition periph_cpu.h:229
i2c_speed_t speed
Configured bus speed, actual speed may be lower but never higher.
Definition periph_cpu.h:303
uint8_t pinsel_sda
PINSEL# of the SDA pin.
Definition periph_cpu.h:226
TWI_t * dev
Pointer to hardware module registers.
Definition periph_cpu.h:299
uint8_t pinsel_scl
PINSEL# of the SCL pin.
Definition periph_cpu.h:227
uint8_t irq_prio
priority of the I2C IRQ
Definition periph_cpu.h:225
uint32_t pinsel_msk_sda
SDA PINSEL Mask.
Definition periph_cpu.h:228
SPI device configuration.
Definition periph_cpu.h:336
SPI_t * dev
pointer to the used SPI device
Definition periph_cpu.h:337
uint8_t pinsel_miso
PINSEL# of the MISO pin.
Definition periph_cpu.h:119
uint32_t pinsel_msk_clk
CLK PINSEL Mask.
Definition periph_cpu.h:123
uint8_t pinsel_clk
PINSEL# of the CLK pin.
Definition periph_cpu.h:120
uint8_t pinsel_mosi
PINSEL# of the MOSI pin.
Definition periph_cpu.h:118
uint32_t pinsel_msk_mosi
MOSI PINSEL Mask.
Definition periph_cpu.h:121
uint32_t pinsel_msk_miso
MISO PINSEL Mask.
Definition periph_cpu.h:122
UART device configuration.
Definition periph_cpu.h:217
USART_t * dev
pointer to the used UART device
Definition periph_cpu.h:218
uint8_t pinsel_rx
PINSEL# of the RX pin.
Definition periph_cpu.h:107
uint32_t pinsel_msk_tx
TX PINSEL Mask.
Definition periph_cpu.h:110
uint8_t pinsel_tx
PINSEL# of the TX pin.
Definition periph_cpu.h:108
uint8_t irq_prio_rx
priority of the RX IRQ
Definition periph_cpu.h:106
uint32_t pinsel_msk_rx
RX PINSEL Mask.
Definition periph_cpu.h:109