2015-08-06 12:58:08 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser
|
|
|
|
* General Public License v2.1. See the file LICENSE in the top level
|
|
|
|
* directory for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ingroup cpu_lpc2387
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @brief CPU specific definitions for internal peripheral handling
|
|
|
|
*
|
|
|
|
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
|
|
|
*/
|
|
|
|
|
2017-01-18 13:00:05 +01:00
|
|
|
#ifndef PERIPH_CPU_H
|
|
|
|
#define PERIPH_CPU_H
|
2015-08-06 12:58:08 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2015-06-09 12:45:35 +02:00
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "cpu.h"
|
|
|
|
|
2015-08-06 12:58:08 +02:00
|
|
|
/**
|
|
|
|
* @brief LPC2387 MCU defines
|
|
|
|
* @{
|
|
|
|
*/
|
2015-06-09 12:45:35 +02:00
|
|
|
#define __IO volatile
|
|
|
|
|
2019-11-07 20:21:02 +01:00
|
|
|
/**
|
|
|
|
* @name Power mode configuration
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
#define PM_NUM_MODES (4)
|
|
|
|
/** @} */
|
|
|
|
|
2015-08-06 12:58:08 +02:00
|
|
|
/**
|
|
|
|
* @brief Fast GPIO register definition struct
|
|
|
|
*/
|
2015-06-09 12:45:35 +02:00
|
|
|
typedef struct {
|
2018-06-18 09:10:25 +02:00
|
|
|
/** @brief Direction: Output if corresponding bit is set, otherwise input */
|
|
|
|
__IO uint32_t DIR;
|
|
|
|
/** @brief 12 bytes of reseved memory we don't need to access */
|
|
|
|
uint32_t _reserved[3];
|
|
|
|
/** @brief Set bits to ignore corresponding bits when accessing `PIN`, `SET`
|
|
|
|
* or `CLR` register of this port
|
|
|
|
*/
|
|
|
|
__IO uint32_t MASK;
|
|
|
|
/** @brief The current state of each pin of this port is accessible here
|
|
|
|
* (regardless of direction): If bit is set input is high
|
|
|
|
*/
|
|
|
|
__IO uint32_t PIN;
|
|
|
|
/** @brief Output pins are set to high by setting the corresponding bit */
|
|
|
|
__IO uint32_t SET;
|
|
|
|
/** @brief Output pins are set to low by setting the corresponding bit */
|
|
|
|
__IO uint32_t CLR;
|
2015-06-09 12:45:35 +02:00
|
|
|
} FIO_PORT_t;
|
|
|
|
|
|
|
|
#define FIO_PORTS ((FIO_PORT_t*)FIO_BASE_ADDR)
|
|
|
|
#define PINSEL ((__IO uint32_t *)(PINSEL_BASE_ADDR))
|
|
|
|
#define PINMODE ((__IO uint32_t *)(PINSEL_BASE_ADDR + 0x40))
|
|
|
|
|
|
|
|
int gpio_init_mux(unsigned pin, unsigned mux);
|
|
|
|
void gpio_init_states(void);
|
|
|
|
|
2018-06-18 09:10:25 +02:00
|
|
|
#define GPIO_PIN(port, pin) (port<<5 | pin)
|
2015-06-09 12:45:35 +02:00
|
|
|
|
2016-06-29 21:05:14 +02:00
|
|
|
#ifndef DOXYGEN
|
2015-06-09 12:45:35 +02:00
|
|
|
#define HAVE_GPIO_FLANK_T
|
|
|
|
typedef enum {
|
|
|
|
GPIO_FALLING = 1, /**< emit interrupt on falling flank */
|
|
|
|
GPIO_RISING = 2, /**< emit interrupt on rising flank */
|
|
|
|
GPIO_BOTH = 3 /**< emit interrupt on both flanks */
|
|
|
|
} gpio_flank_t;
|
2016-06-29 21:05:14 +02:00
|
|
|
#endif /* ndef DOXYGEN */
|
2015-06-09 12:45:35 +02:00
|
|
|
|
2019-10-30 00:53:39 +01:00
|
|
|
/**
|
|
|
|
* @brief UART device configuration
|
|
|
|
*/
|
|
|
|
typedef struct {
|
|
|
|
lpc23xx_uart_t *dev; /**< pointer to the UART device */
|
|
|
|
uint8_t irq_prio_rx; /**< priority of the RX IRQ */
|
|
|
|
uint8_t pinsel_rx; /**< PINSEL# of the RX pin */
|
|
|
|
uint8_t pinsel_tx; /**< PINSEL# of the TX pin */
|
|
|
|
uint32_t pinsel_msk_rx; /**< RX PINSEL Mask */
|
|
|
|
uint32_t pinsel_msk_tx; /**< TX PINSEL Mask */
|
|
|
|
} uart_conf_t;
|
|
|
|
|
2015-06-19 11:45:06 +02:00
|
|
|
/**
|
2015-09-03 23:47:59 +02:00
|
|
|
* @brief Number of available timer channels
|
|
|
|
*/
|
|
|
|
#define TIMER_CHAN_NUMOF (4U)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Declare needed generic SPI functions
|
2015-06-19 11:45:06 +02:00
|
|
|
* @{
|
|
|
|
*/
|
2016-11-08 18:25:21 +01:00
|
|
|
#define PERIPH_SPI_NEEDS_INIT_CS
|
|
|
|
#define PERIPH_SPI_NEEDS_TRANSFER_BYTE
|
2015-06-19 11:45:06 +02:00
|
|
|
#define PERIPH_SPI_NEEDS_TRANSFER_REG
|
|
|
|
#define PERIPH_SPI_NEEDS_TRANSFER_REGS
|
2015-08-06 12:58:08 +02:00
|
|
|
/* @} */
|
|
|
|
|
2019-02-07 08:33:36 +01:00
|
|
|
#ifndef DOXYGEN
|
2016-11-08 18:25:21 +01:00
|
|
|
/**
|
|
|
|
* @brief Override SPI clock speed values
|
2017-01-25 14:18:21 +01:00
|
|
|
* @{
|
2016-11-08 18:25:21 +01:00
|
|
|
*/
|
|
|
|
#define HAVE_SPI_CLK_T
|
|
|
|
typedef enum {
|
|
|
|
SPI_CLK_100KHZ = 100, /**< drive the SPI bus with 100KHz */
|
|
|
|
SPI_CLK_400KHZ = 400, /**< drive the SPI bus with 400KHz */
|
|
|
|
SPI_CLK_1MHZ = 1000, /**< drive the SPI bus with 1MHz */
|
|
|
|
SPI_CLK_5MHZ = 5000, /**< drive the SPI bus with 5MHz */
|
|
|
|
SPI_CLK_10MHZ = 10000 /**< drive the SPI bus with 10MHz */
|
|
|
|
} spi_clk_t;
|
2017-01-25 14:18:21 +01:00
|
|
|
/** @} */
|
2019-02-07 08:33:36 +01:00
|
|
|
#endif /* ndef DOXYGEN */
|
2016-11-08 18:25:21 +01:00
|
|
|
|
2015-08-06 12:58:08 +02:00
|
|
|
/* @} */
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-01-18 13:00:05 +01:00
|
|
|
#endif /* PERIPH_CPU_H */
|
2015-06-19 11:45:06 +02:00
|
|
|
/** @} */
|