2014-10-01 19:39:55 +02:00
|
|
|
/*
|
2016-12-07 17:03:52 +01:00
|
|
|
* Copyright (C) 2014-2016 Freie Universität Berlin
|
2014-10-01 19:39:55 +02:00
|
|
|
*
|
2016-11-08 18:28:32 +01:00
|
|
|
* 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.
|
2014-10-01 19:39:55 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2019-07-07 13:05:43 +02:00
|
|
|
* @ingroup boards_nucleo-l152re
|
2014-10-01 19:39:55 +02:00
|
|
|
* @{
|
|
|
|
*
|
2015-02-12 13:41:56 +01:00
|
|
|
* @file
|
2018-02-27 14:38:06 +01:00
|
|
|
* @brief Peripheral MCU configuration for the nucleo-l152re board
|
2014-10-01 19:39:55 +02:00
|
|
|
*
|
|
|
|
* @author Thomas Eichinger <thomas.eichinger@fu-berlin.de>
|
2016-12-07 17:03:52 +01:00
|
|
|
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
2014-10-01 19:39:55 +02:00
|
|
|
*/
|
|
|
|
|
2017-01-18 13:00:05 +01:00
|
|
|
#ifndef PERIPH_CONF_H
|
|
|
|
#define PERIPH_CONF_H
|
2014-10-01 19:39:55 +02:00
|
|
|
|
2015-09-15 16:54:54 +02:00
|
|
|
#include "periph_cpu.h"
|
2019-07-05 19:52:48 +02:00
|
|
|
#include "cfg_timer_tim5.h"
|
2015-09-15 16:54:54 +02:00
|
|
|
|
2014-10-01 19:39:55 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name Clock system configuration
|
|
|
|
* @{
|
|
|
|
**/
|
2015-08-25 10:12:48 +02:00
|
|
|
#define CLOCK_HSI (16000000U) /* frequency of internal oscillator */
|
2014-10-01 19:39:55 +02:00
|
|
|
#define CLOCK_CORECLOCK (32000000U) /* targeted core clock frequency */
|
2018-02-05 17:10:49 +01:00
|
|
|
/*
|
|
|
|
* 0: no external low speed crystal available,
|
|
|
|
* 1: external crystal available (always 32.768kHz)
|
|
|
|
*
|
|
|
|
* LSE might not be available by default in early (C-01) Nucleo boards.
|
2018-04-16 13:51:47 +02:00
|
|
|
* For newer revisions, an LSE crystal is present and CLOCK_LSE can be set to 1
|
|
|
|
* if one wants to use it.
|
2018-02-05 17:10:49 +01:00
|
|
|
*/
|
|
|
|
#ifndef CLOCK_LSE
|
|
|
|
#define CLOCK_LSE (0)
|
|
|
|
#endif
|
2014-10-01 19:39:55 +02:00
|
|
|
/* configuration of PLL prescaler and multiply values */
|
2015-08-25 10:12:48 +02:00
|
|
|
/* CORECLOCK := HSI / CLOCK_PLL_DIV * CLOCK_PLL_MUL */
|
|
|
|
#define CLOCK_PLL_DIV RCC_CFGR_PLLDIV2
|
|
|
|
#define CLOCK_PLL_MUL RCC_CFGR_PLLMUL4
|
2014-10-01 19:39:55 +02:00
|
|
|
/* configuration of peripheral bus clock prescalers */
|
|
|
|
#define CLOCK_AHB_DIV RCC_CFGR_HPRE_DIV1 /* AHB clock -> 32MHz */
|
|
|
|
#define CLOCK_APB2_DIV RCC_CFGR_PPRE2_DIV1 /* APB2 clock -> 32MHz */
|
|
|
|
#define CLOCK_APB1_DIV RCC_CFGR_PPRE1_DIV1 /* APB1 clock -> 32MHz */
|
|
|
|
/* configuration of flash access cycles */
|
|
|
|
#define CLOCK_FLASH_LATENCY FLASH_ACR_LATENCY
|
2016-12-07 15:33:06 +01:00
|
|
|
|
|
|
|
/* bus clocks for simplified peripheral initialization, UPDATE MANUALLY! */
|
|
|
|
#define CLOCK_AHB (CLOCK_CORECLOCK / 1)
|
|
|
|
#define CLOCK_APB2 (CLOCK_CORECLOCK / 1)
|
|
|
|
#define CLOCK_APB1 (CLOCK_CORECLOCK / 1)
|
2014-10-01 19:39:55 +02:00
|
|
|
/** @} */
|
|
|
|
|
2019-01-07 15:16:07 +01:00
|
|
|
/**
|
|
|
|
* @name DMA streams configuration
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
#ifdef MODULE_PERIPH_DMA
|
|
|
|
static const dma_conf_t dma_config[] = {
|
|
|
|
{ .stream = 1 }, /* DMA1 Channel 2 - SPI1_RX / USART3_TX */
|
|
|
|
{ .stream = 2 }, /* DMA1 Channel 3 - SPI1_TX */
|
|
|
|
{ .stream = 6 }, /* DMA1 Channel 7 - USART2_TX */
|
|
|
|
{ .stream = 4 }, /* DMA1 Channel 4 - USART1_TX */
|
|
|
|
};
|
|
|
|
|
|
|
|
#define DMA_0_ISR isr_dma1_ch2
|
|
|
|
#define DMA_1_ISR isr_dma1_ch3
|
|
|
|
#define DMA_2_ISR isr_dma1_ch7
|
|
|
|
#define DMA_3_ISR isr_dma1_ch4
|
|
|
|
|
2019-07-18 15:14:29 +02:00
|
|
|
#define DMA_NUMOF ARRAY_SIZE(dma_config)
|
2019-01-07 15:16:07 +01:00
|
|
|
#endif
|
|
|
|
/** @} */
|
|
|
|
|
2014-10-01 19:39:55 +02:00
|
|
|
/**
|
2017-01-26 18:14:32 +01:00
|
|
|
* @name UART configuration
|
2016-12-07 17:03:52 +01:00
|
|
|
* @{
|
2014-10-01 19:39:55 +02:00
|
|
|
*/
|
2016-12-07 17:03:52 +01:00
|
|
|
static const uart_conf_t uart_config[] = {
|
|
|
|
{
|
|
|
|
.dev = USART2,
|
|
|
|
.rcc_mask = RCC_APB1ENR_USART2EN,
|
|
|
|
.rx_pin = GPIO_PIN(PORT_A, 3),
|
|
|
|
.tx_pin = GPIO_PIN(PORT_A, 2),
|
|
|
|
.rx_af = GPIO_AF7,
|
|
|
|
.tx_af = GPIO_AF7,
|
|
|
|
.bus = APB1,
|
2019-01-07 15:16:07 +01:00
|
|
|
.irqn = USART2_IRQn,
|
|
|
|
#ifdef MODULE_PERIPH_DMA
|
|
|
|
.dma = 2,
|
|
|
|
.dma_chan = 2
|
|
|
|
#endif
|
2017-01-15 15:19:02 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.dev = USART1,
|
|
|
|
.rcc_mask = RCC_APB2ENR_USART1EN,
|
|
|
|
.rx_pin = GPIO_PIN(PORT_A, 9),
|
|
|
|
.tx_pin = GPIO_PIN(PORT_A, 10),
|
|
|
|
.rx_af = GPIO_AF7,
|
|
|
|
.tx_af = GPIO_AF7,
|
|
|
|
.bus = APB2,
|
2019-01-07 15:16:07 +01:00
|
|
|
.irqn = USART1_IRQn,
|
|
|
|
#ifdef MODULE_PERIPH_DMA
|
|
|
|
.dma = 3,
|
|
|
|
.dma_chan = 2
|
|
|
|
#endif
|
2017-01-15 15:19:02 +01:00
|
|
|
},
|
2018-08-15 10:03:22 +02:00
|
|
|
{
|
|
|
|
.dev = USART3,
|
|
|
|
.rcc_mask = RCC_APB1ENR_USART3EN,
|
|
|
|
.rx_pin = GPIO_PIN(PORT_C, 11),
|
|
|
|
.tx_pin = GPIO_PIN(PORT_C, 10),
|
|
|
|
.rx_af = GPIO_AF7,
|
|
|
|
.tx_af = GPIO_AF7,
|
|
|
|
.bus = APB1,
|
2019-01-07 15:16:07 +01:00
|
|
|
.irqn = USART3_IRQn,
|
|
|
|
#ifdef MODULE_PERIPH_DMA
|
|
|
|
.dma = 0,
|
|
|
|
.dma_chan = 2
|
|
|
|
#endif
|
2018-08-15 10:03:22 +02:00
|
|
|
},
|
2016-12-07 17:03:52 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#define UART_0_ISR (isr_usart2)
|
2018-08-15 10:03:22 +02:00
|
|
|
#define UART_1_ISR (isr_usart1)
|
|
|
|
#define UART_2_ISR (isr_usart3)
|
2016-12-07 17:03:52 +01:00
|
|
|
|
2019-07-18 15:14:29 +02:00
|
|
|
#define UART_NUMOF ARRAY_SIZE(uart_config)
|
2016-12-07 17:03:52 +01:00
|
|
|
/** @} */
|
2014-10-01 19:39:55 +02:00
|
|
|
|
2017-01-15 15:33:31 +01:00
|
|
|
/**
|
|
|
|
* @name PWM configuration
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
static const pwm_conf_t pwm_config[] = {
|
|
|
|
{
|
|
|
|
.dev = TIM2,
|
|
|
|
.rcc_mask = RCC_APB1ENR_TIM2EN,
|
|
|
|
.chan = { { .pin = GPIO_PIN(PORT_B, 3) /* D3 */, .cc_chan = 1 },
|
|
|
|
{ .pin = GPIO_PIN(PORT_B, 10) /* D6 */, .cc_chan = 2 },
|
|
|
|
{ .pin = GPIO_UNDEF, .cc_chan = 0 },
|
|
|
|
{ .pin = GPIO_UNDEF, .cc_chan = 0 } },
|
|
|
|
.af = GPIO_AF1,
|
|
|
|
.bus = APB1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.dev = TIM3,
|
|
|
|
.rcc_mask = RCC_APB1ENR_TIM3EN,
|
|
|
|
.chan = { { .pin = GPIO_PIN(PORT_B, 4) /* D5 */, .cc_chan = 0 },
|
|
|
|
{ .pin = GPIO_PIN(PORT_C, 7) /* D9 */, .cc_chan = 1 },
|
|
|
|
{ .pin = GPIO_PIN(PORT_C, 8), .cc_chan = 2 },
|
|
|
|
{ .pin = GPIO_PIN(PORT_C, 9), .cc_chan = 3 } },
|
|
|
|
.af = GPIO_AF2,
|
|
|
|
.bus = APB1
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-07-18 15:14:29 +02:00
|
|
|
#define PWM_NUMOF ARRAY_SIZE(pwm_config)
|
2017-01-15 15:33:31 +01:00
|
|
|
/** @} */
|
|
|
|
|
2014-10-01 19:39:55 +02:00
|
|
|
/**
|
2017-01-26 18:14:32 +01:00
|
|
|
* @name SPI configuration
|
2016-11-08 18:28:32 +01:00
|
|
|
*
|
|
|
|
* @note The spi_divtable is auto-generated from
|
|
|
|
* `cpu/stm32_common/dist/spi_divtable/spi_divtable.c`
|
2014-10-01 19:39:55 +02:00
|
|
|
* @{
|
|
|
|
*/
|
2016-11-08 18:28:32 +01:00
|
|
|
static const uint8_t spi_divtable[2][5] = {
|
|
|
|
{ /* for APB1 @ 32000000Hz */
|
|
|
|
7, /* -> 125000Hz */
|
|
|
|
5, /* -> 500000Hz */
|
|
|
|
4, /* -> 1000000Hz */
|
|
|
|
2, /* -> 4000000Hz */
|
|
|
|
1 /* -> 8000000Hz */
|
|
|
|
},
|
|
|
|
{ /* for APB2 @ 32000000Hz */
|
|
|
|
7, /* -> 125000Hz */
|
|
|
|
5, /* -> 500000Hz */
|
|
|
|
4, /* -> 1000000Hz */
|
|
|
|
2, /* -> 4000000Hz */
|
|
|
|
1 /* -> 8000000Hz */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const spi_conf_t spi_config[] = {
|
|
|
|
{
|
|
|
|
.dev = SPI1,
|
|
|
|
.mosi_pin = GPIO_PIN(PORT_A, 7),
|
|
|
|
.miso_pin = GPIO_PIN(PORT_A, 6),
|
|
|
|
.sclk_pin = GPIO_PIN(PORT_A, 5),
|
|
|
|
.cs_pin = GPIO_UNDEF,
|
2019-06-07 08:52:42 +02:00
|
|
|
.mosi_af = GPIO_AF5,
|
|
|
|
.miso_af = GPIO_AF5,
|
|
|
|
.sclk_af = GPIO_AF5,
|
|
|
|
.cs_af = GPIO_AF5,
|
2016-11-08 18:28:32 +01:00
|
|
|
.rccmask = RCC_APB2ENR_SPI1EN,
|
2019-01-07 15:16:07 +01:00
|
|
|
.apbbus = APB2,
|
|
|
|
#ifdef MODULE_PERIPH_DMA
|
|
|
|
.tx_dma = 1,
|
|
|
|
.tx_dma_chan = 1,
|
|
|
|
.rx_dma = 0,
|
|
|
|
.rx_dma_chan = 1,
|
|
|
|
#endif
|
2016-11-08 18:28:32 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-07-18 15:14:29 +02:00
|
|
|
#define SPI_NUMOF ARRAY_SIZE(spi_config)
|
2014-10-01 19:39:55 +02:00
|
|
|
/** @} */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name I2C configuration
|
2015-12-07 17:21:34 +01:00
|
|
|
* @{
|
2014-10-01 19:39:55 +02:00
|
|
|
*/
|
2016-02-01 14:04:46 +01:00
|
|
|
static const i2c_conf_t i2c_config[] = {
|
2018-05-31 22:41:26 +02:00
|
|
|
{
|
|
|
|
.dev = I2C1,
|
|
|
|
.speed = I2C_SPEED_NORMAL,
|
|
|
|
.scl_pin = GPIO_PIN(PORT_B, 8),
|
|
|
|
.sda_pin = GPIO_PIN(PORT_B, 9),
|
|
|
|
.scl_af = GPIO_AF4,
|
|
|
|
.sda_af = GPIO_AF4,
|
|
|
|
.bus = APB1,
|
|
|
|
.rcc_mask = RCC_APB1ENR_I2C1EN,
|
|
|
|
.clk = CLOCK_APB1,
|
|
|
|
.irqn = I2C1_EV_IRQn
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.dev = I2C2,
|
|
|
|
.speed = I2C_SPEED_NORMAL,
|
|
|
|
.scl_pin = GPIO_PIN(PORT_B, 10),
|
|
|
|
.sda_pin = GPIO_PIN(PORT_B, 11),
|
|
|
|
.scl_af = GPIO_AF4,
|
|
|
|
.sda_af = GPIO_AF4,
|
|
|
|
.bus = APB1,
|
|
|
|
.rcc_mask = RCC_APB1ENR_I2C2EN,
|
|
|
|
.clk = CLOCK_APB1,
|
|
|
|
.irqn = I2C2_EV_IRQn
|
|
|
|
}
|
2016-02-01 14:04:46 +01:00
|
|
|
};
|
2018-05-31 22:41:26 +02:00
|
|
|
|
|
|
|
#define I2C_0_ISR isr_i2c1_ev
|
|
|
|
#define I2C_1_ISR isr_i2c2_ev
|
|
|
|
|
2019-07-18 15:14:29 +02:00
|
|
|
#define I2C_NUMOF ARRAY_SIZE(i2c_config)
|
2017-03-30 15:02:50 +02:00
|
|
|
/** @} */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name ADC configuration
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
#define ADC_CONFIG { \
|
|
|
|
{ GPIO_PIN(PORT_A, 0), 0 }, \
|
|
|
|
{ GPIO_PIN(PORT_A, 1), 1 }, \
|
|
|
|
{ GPIO_PIN(PORT_A, 4), 4 }, \
|
|
|
|
{ GPIO_PIN(PORT_B, 0), 8 }, \
|
|
|
|
{ GPIO_PIN(PORT_C, 1), 11 }, \
|
|
|
|
{ GPIO_PIN(PORT_C, 0), 10 }, \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ADC_NUMOF (6U)
|
|
|
|
/** @} */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name DAC configuration
|
|
|
|
* @{
|
|
|
|
*/
|
2017-06-27 12:45:50 +02:00
|
|
|
static const dac_conf_t dac_config[] = {
|
|
|
|
{ .pin = GPIO_PIN(PORT_A, 4), .chan = 0 },
|
|
|
|
{ .pin = GPIO_PIN(PORT_A, 5), .chan = 1 }
|
|
|
|
};
|
2016-02-01 14:04:46 +01:00
|
|
|
|
2019-07-18 15:14:29 +02:00
|
|
|
#define DAC_NUMOF ARRAY_SIZE(dac_config)
|
2014-10-01 19:39:55 +02:00
|
|
|
/** @} */
|
|
|
|
|
2017-06-27 12:45:50 +02:00
|
|
|
|
2014-10-01 19:39:55 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-01-18 13:00:05 +01:00
|
|
|
#endif /* PERIPH_CONF_H */
|
2014-10-01 19:39:55 +02:00
|
|
|
/** @} */
|