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