|
| 1 | +/* |
| 2 | + * SPDX-FileCopyrightText: 2024 BISSELL Homecare, Inc. |
| 3 | + * SPDX-License-Identifier: LGPL-2.1-only |
| 4 | + */ |
| 5 | + |
| 6 | +/** |
| 7 | + * @ingroup boards_nucleo-c071rb |
| 8 | + * @{ |
| 9 | + * |
| 10 | + * @file |
| 11 | + * @brief Peripheral MCU configuration for the Nucleo-C071RB board |
| 12 | + * |
| 13 | + * @author Jason Parker <[email protected]> |
| 14 | + */ |
| 15 | + |
| 16 | +#pragma once |
| 17 | + |
| 18 | +/* Add specific clock configuration (HSE, LSE) for this board here */ |
| 19 | +#ifndef CONFIG_BOARD_HAS_LSE |
| 20 | +# define CONFIG_BOARD_HAS_LSE 1 |
| 21 | +#endif |
| 22 | + |
| 23 | +#include "clk_conf.h" |
| 24 | +#include "cfg_i2c1_pb8_pb9.h" |
| 25 | +#include "cfg_rtt_default.h" |
| 26 | + |
| 27 | +#ifdef __cplusplus |
| 28 | +extern "C" { |
| 29 | +#endif |
| 30 | + |
| 31 | +/** |
| 32 | + * @name Timer configuration |
| 33 | + * @{ |
| 34 | + */ |
| 35 | +static const timer_conf_t timer_config[] = { |
| 36 | + { |
| 37 | + .dev = TIM3, |
| 38 | + .max = 0x0000ffff, |
| 39 | + .rcc_mask = RCC_APBENR1_TIM3EN, |
| 40 | + .bus = APB1, |
| 41 | + .irqn = TIM3_IRQn |
| 42 | + } |
| 43 | +}; |
| 44 | + |
| 45 | +#define TIMER_0_ISR isr_tim3 |
| 46 | + |
| 47 | +#define TIMER_NUMOF ARRAY_SIZE(timer_config) |
| 48 | +/** @} */ |
| 49 | + |
| 50 | +/** |
| 51 | + * @name UART configuration |
| 52 | + * @{ |
| 53 | + */ |
| 54 | +static const uart_conf_t uart_config[] = { |
| 55 | + { |
| 56 | + .dev = USART2, |
| 57 | + .rcc_mask = RCC_APBENR1_USART2EN, |
| 58 | + .rx_pin = GPIO_PIN(PORT_A, 3), |
| 59 | + .tx_pin = GPIO_PIN(PORT_A, 2), |
| 60 | + .rx_af = GPIO_AF1, |
| 61 | + .tx_af = GPIO_AF1, |
| 62 | + .bus = APB1, |
| 63 | + .irqn = USART2_IRQn, |
| 64 | + }, |
| 65 | + { /* Arduino pinout on D0/D1 */ |
| 66 | + .dev = USART1, |
| 67 | + .rcc_mask = RCC_APBENR2_USART1EN, |
| 68 | + .rx_pin = GPIO_PIN(PORT_B, 7), |
| 69 | + .tx_pin = GPIO_PIN(PORT_B, 6), |
| 70 | + .rx_af = GPIO_AF0, |
| 71 | + .tx_af = GPIO_AF0, |
| 72 | + .bus = APB12, |
| 73 | + .irqn = USART1_IRQn, |
| 74 | + }, |
| 75 | +}; |
| 76 | + |
| 77 | +#define UART_0_ISR (isr_usart2) |
| 78 | +#define UART_1_ISR (isr_usart1) |
| 79 | + |
| 80 | +#define UART_NUMOF ARRAY_SIZE(uart_config) |
| 81 | +/** @} */ |
| 82 | + |
| 83 | +/** |
| 84 | + * @name ADC configuration |
| 85 | + * |
| 86 | + * Note that we do not configure all ADC channels, |
| 87 | + * and not in the STM32C071 order. Instead, we |
| 88 | + * just define 6 ADC channels, for the Nucleo |
| 89 | + * Arduino header pins A0-A5. |
| 90 | + * |
| 91 | + * The appropriate ADC device and channel for each pin |
| 92 | + * can be found in the board manual in the pin assignment |
| 93 | + * table. The format of the entries is ADC_IN[Y], where |
| 94 | + * [Y] - describes the used channel - indexed from 1. |
| 95 | + * For example: ADC_IN11 is Channel 11. |
| 96 | + * |
| 97 | + * For the Nucleo-C071RB this information is in the board manual, |
| 98 | + * Table 12 "ARDUINO connectors on NUCLEO-C071RB and NUCLEO-C092RC". |
| 99 | + * |
| 100 | + * @{ |
| 101 | + */ |
| 102 | +static const adc_conf_t adc_config[] = { |
| 103 | + { .pin = GPIO_PIN(PORT_A, 0), .dev = 0, .chan = 0 }, /* ADC_IN0 */ |
| 104 | + { .pin = GPIO_PIN(PORT_A, 1), .dev = 0, .chan = 1 }, /* ADC_IN1 */ |
| 105 | + { .pin = GPIO_PIN(PORT_A, 4), .dev = 0, .chan = 4 }, /* ADC_IN4 */ |
| 106 | + { .pin = GPIO_PIN(PORT_B, 0), .dev = 0, .chan = 17 }, /* ADC_IN17 */ |
| 107 | + { .pin = GPIO_PIN(PORT_C, 4), .dev = 0, .chan = 11 }, /* ADC_IN11 */ |
| 108 | + { .pin = GPIO_PIN(PORT_C, 5), .dev = 0, .chan = 12 }, /* ADC_IN12 */ |
| 109 | +}; |
| 110 | + |
| 111 | +#define ADC_NUMOF ARRAY_SIZE(adc_config) |
| 112 | +/** @} */ |
| 113 | + |
| 114 | +/** |
| 115 | + * @name PWM configuration |
| 116 | + * @{ |
| 117 | + * |
| 118 | + * The appropriate PWM device and channel for each pin can be found |
| 119 | + * in the MCU datasheet table "Alternate function AF0 to AF7". |
| 120 | + * The format of the entries is TIM[X]_CH[Y], where TIM[X] is the timer device |
| 121 | + * and [Y] describes the used channel (indexed from 0). For example TIM3_CH1 is |
| 122 | + * Timer 3, Channel 1 which corresponds to Channel 0 in the PWM configuration |
| 123 | + * structure. |
| 124 | + * The port column in the table describes the connected port. |
| 125 | + * |
| 126 | + * For the Nucleo-C071RB this information can be found in the MCU datasheet, |
| 127 | + * Table 15 "Port B alternate function mapping (AF0 to AF7)". |
| 128 | + * |
| 129 | + */ |
| 130 | +static const pwm_conf_t pwm_config[] = { |
| 131 | + { |
| 132 | + .dev = TIM3, |
| 133 | + .rcc_mask = RCC_APBENR1_TIM3EN, |
| 134 | + .chan = { { .pin = GPIO_PIN(PORT_B, 5) /*CN9 D6 */, .cc_chan = 1 }, |
| 135 | + { .pin = GPIO_PIN(PORT_B, 0) /*CN5 D10 */, .cc_chan = 2 }, |
| 136 | + { .pin = GPIO_PIN(PORT_B, 1) /*CN8 A3 */, .cc_chan = 3 }, |
| 137 | + { .pin = GPIO_UNDEF, .cc_chan = 0 } }, |
| 138 | + .af = GPIO_AF1, |
| 139 | + .bus = APB1 |
| 140 | + }, |
| 141 | +}; |
| 142 | + |
| 143 | +#define PWM_NUMOF ARRAY_SIZE(pwm_config) |
| 144 | +/** @} */ |
| 145 | + |
| 146 | +/** |
| 147 | + * @name SPI configuration |
| 148 | + * @{ |
| 149 | + */ |
| 150 | +static const spi_conf_t spi_config[] = { |
| 151 | + { |
| 152 | + .dev = SPI1, |
| 153 | + .mosi_pin = GPIO_PIN(PORT_A, 7), /* Arduino D11 */ |
| 154 | + .miso_pin = GPIO_PIN(PORT_A, 6), /* Arduino D12 */ |
| 155 | + .sclk_pin = GPIO_PIN(PORT_A, 5), /* Arduino D13 */ |
| 156 | + .cs_pin = GPIO_UNDEF, |
| 157 | + .mosi_af = GPIO_AF0, |
| 158 | + .miso_af = GPIO_AF0, |
| 159 | + .sclk_af = GPIO_AF0, |
| 160 | + .cs_af = GPIO_AF0, |
| 161 | + .rccmask = RCC_APBENR2_SPI1EN, |
| 162 | + .apbbus = APB12, |
| 163 | + }, |
| 164 | +}; |
| 165 | + |
| 166 | +#define SPI_NUMOF ARRAY_SIZE(spi_config) |
| 167 | +/** @} */ |
| 168 | + |
| 169 | +#ifdef __cplusplus |
| 170 | +} |
| 171 | +#endif |
| 172 | + |
| 173 | +/** @} */ |
0 commit comments