|
| 1 | + /* |
| 2 | + * This file is part of the MicroPython project, http://micropython.org/ |
| 3 | + * |
| 4 | + * The MIT License (MIT) |
| 5 | + * |
| 6 | + * Copyright (c) 2019 Lucian Copeland for Adafruit Industries |
| 7 | + * |
| 8 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 9 | + * of this software and associated documentation files (the "Software"), to deal |
| 10 | + * in the Software without restriction, including without limitation the rights |
| 11 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 12 | + * copies of the Software, and to permit persons to whom the Software is |
| 13 | + * furnished to do so, subject to the following conditions: |
| 14 | + * |
| 15 | + * The above copyright notice and this permission notice shall be included in |
| 16 | + * all copies or substantial portions of the Software. |
| 17 | + * |
| 18 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 21 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 22 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 23 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 24 | + * THE SOFTWARE. |
| 25 | + */ |
| 26 | + |
| 27 | +#include "py/obj.h" |
| 28 | +#include "py/mphal.h" |
| 29 | +#include "stm32f4/pins.h" |
| 30 | +#include "stm32f4/periph.h" |
| 31 | + |
| 32 | +// I2C |
| 33 | + |
| 34 | +I2C_TypeDef * mcu_i2c_banks[3] = {I2C1, I2C2, I2C3}; |
| 35 | + |
| 36 | +const mcu_i2c_sda_obj_t mcu_i2c_sda_list[5] = { |
| 37 | + I2C_SDA(1, 4, &pin_PB07), |
| 38 | + I2C_SDA(1, 4, &pin_PB09), |
| 39 | + I2C_SDA(2, 9, &pin_PB03), |
| 40 | + I2C_SDA(3, 4, &pin_PC09), |
| 41 | + I2C_SDA(3, 9, &pin_PB04), |
| 42 | +}; |
| 43 | + |
| 44 | +const mcu_i2c_scl_obj_t mcu_i2c_scl_list[4] = { |
| 45 | + I2C_SCL(1, 4, &pin_PB06), |
| 46 | + I2C_SCL(1, 4, &pin_PB08), |
| 47 | + I2C_SCL(2, 4, &pin_PB10), |
| 48 | + I2C_SCL(3, 4, &pin_PA08) |
| 49 | +}; |
| 50 | + |
| 51 | +// SPI |
| 52 | + |
| 53 | +SPI_TypeDef * mcu_spi_banks[4] = {SPI1, SPI2, SPI3, SPI4}; |
| 54 | + |
| 55 | +const mcu_spi_sck_obj_t mcu_spi_sck_list[9] = { |
| 56 | + SPI(1, 5, &pin_PA05), |
| 57 | + SPI(1, 5, &pin_PB03), |
| 58 | + SPI(2, 5, &pin_PB10), |
| 59 | + SPI(2, 5, &pin_PB13), |
| 60 | + SPI(2, 5, &pin_PD03), |
| 61 | + SPI(3, 6, &pin_PB03), |
| 62 | + SPI(3, 6, &pin_PC10), |
| 63 | + SPI(4, 5, &pin_PE02), |
| 64 | + SPI(4, 5, &pin_PE12), |
| 65 | +}; |
| 66 | + |
| 67 | +const mcu_spi_mosi_obj_t mcu_spi_mosi_list[9] = { |
| 68 | + SPI(1, 5, &pin_PA07), |
| 69 | + SPI(1, 5, &pin_PB05), |
| 70 | + SPI(2, 5, &pin_PB15), |
| 71 | + SPI(2, 5, &pin_PC03), |
| 72 | + SPI(3, 6, &pin_PB05), |
| 73 | + SPI(3, 6, &pin_PC12), |
| 74 | + SPI(3, 5, &pin_PD06), |
| 75 | + SPI(4, 5, &pin_PE06), |
| 76 | + SPI(4, 5, &pin_PE14), |
| 77 | +}; |
| 78 | + |
| 79 | +const mcu_spi_miso_obj_t mcu_spi_miso_list[8] = { |
| 80 | + SPI(1, 5, &pin_PA06), |
| 81 | + SPI(1, 5, &pin_PB04), |
| 82 | + SPI(2, 5, &pin_PB14), |
| 83 | + SPI(2, 5, &pin_PC02), |
| 84 | + SPI(3, 6, &pin_PB04), |
| 85 | + SPI(3, 6, &pin_PC11), |
| 86 | + SPI(4, 5, &pin_PE05), |
| 87 | + SPI(4, 5, &pin_PE13), |
| 88 | +}; |
| 89 | + |
| 90 | +const mcu_spi_nss_obj_t mcu_spi_nss_list[9] = { |
| 91 | + SPI(1, 5, &pin_PA04), |
| 92 | + SPI(1, 5, &pin_PA15), |
| 93 | + SPI(2, 5, &pin_PB09), |
| 94 | + SPI(2, 5, &pin_PB12), |
| 95 | + SPI(3, 6, &pin_PA04), |
| 96 | + SPI(3, 6, &pin_PA15), |
| 97 | + SPI(4, 6, &pin_PB12), |
| 98 | + SPI(4, 5, &pin_PE04), |
| 99 | + SPI(4, 5, &pin_PE11), |
| 100 | +}; |
| 101 | + |
| 102 | +USART_TypeDef * mcu_uart_banks[MAX_UART] = {USART1, USART2, NULL, NULL, NULL, USART6}; |
| 103 | +bool mcu_uart_has_usart[MAX_UART] = {true, true, false, false, false, true}; |
| 104 | + |
| 105 | +const mcu_uart_tx_obj_t mcu_uart_tx_list[6] = { |
| 106 | + UART(2, 7, &pin_PA02), |
| 107 | + UART(1, 7, &pin_PA09), |
| 108 | + UART(6, 8, &pin_PA11), |
| 109 | + UART(1, 7, &pin_PB06), |
| 110 | + UART(6, 8, &pin_PC06), |
| 111 | + UART(2, 7, &pin_PD05), |
| 112 | +}; |
| 113 | + |
| 114 | +const mcu_uart_rx_obj_t mcu_uart_rx_list[6] = { |
| 115 | + UART(2, 7, &pin_PA03), |
| 116 | + UART(1, 7, &pin_PA10), |
| 117 | + UART(6, 8, &pin_PA12), |
| 118 | + UART(1, 7, &pin_PB07), |
| 119 | + UART(6, 8, &pin_PC07), |
| 120 | + UART(2, 7, &pin_PD06), |
| 121 | +}; |
| 122 | + |
| 123 | +//Timers |
| 124 | +//TIM6 and TIM7 are basic timers that are only used by DAC, and don't have pins |
| 125 | +TIM_TypeDef * mcu_tim_banks[14] = {TIM1, TIM2, TIM3, TIM4, TIM5, NULL, NULL, NULL, TIM9, TIM10, |
| 126 | + TIM11, NULL, NULL, NULL}; |
| 127 | + |
| 128 | +const mcu_tim_pin_obj_t mcu_tim_pin_list[44] = { |
| 129 | + TIM(2,1,1,&pin_PA00), |
| 130 | + TIM(5,2,1,&pin_PA00), |
| 131 | + TIM(2,1,2,&pin_PA01), |
| 132 | + TIM(5,2,2,&pin_PA01), |
| 133 | + TIM(2,1,3,&pin_PA02), |
| 134 | + TIM(5,2,3,&pin_PA02), |
| 135 | + TIM(2,1,4,&pin_PA03), |
| 136 | + TIM(5,2,4,&pin_PA03), |
| 137 | + TIM(9,3,1,&pin_PA02), |
| 138 | + TIM(9,3,2,&pin_PA03), |
| 139 | + TIM(3,2,1,&pin_PA06), |
| 140 | + TIM(3,2,2,&pin_PA07), |
| 141 | + TIM(1,1,1,&pin_PA08), |
| 142 | + TIM(1,1,2,&pin_PA09), |
| 143 | + TIM(1,1,3,&pin_PA10), |
| 144 | + TIM(1,1,4,&pin_PA11), |
| 145 | + TIM(2,1,1,&pin_PA15), |
| 146 | + TIM(3,2,3,&pin_PB00), |
| 147 | + TIM(3,2,4,&pin_PB01), |
| 148 | + TIM(2,1,2,&pin_PB03), |
| 149 | + TIM(3,2,1,&pin_PB04), |
| 150 | + TIM(3,2,2,&pin_PB05), |
| 151 | + TIM(4,2,1,&pin_PB06), |
| 152 | + TIM(4,2,2,&pin_PB07), |
| 153 | + TIM(4,2,3,&pin_PB08), |
| 154 | + TIM(10,2,1,&pin_PB08), |
| 155 | + TIM(4,2,4,&pin_PB09), |
| 156 | + TIM(11,2,1,&pin_PB09), |
| 157 | + TIM(2,1,3,&pin_PB10), |
| 158 | + TIM(3,2,1,&pin_PC06), |
| 159 | + TIM(3,2,2,&pin_PC07), |
| 160 | + TIM(3,2,3,&pin_PC08), |
| 161 | + TIM(3,2,4,&pin_PC09), |
| 162 | + TIM(4,2,1,&pin_PD12), |
| 163 | + TIM(4,2,2,&pin_PD13), |
| 164 | + TIM(4,2,3,&pin_PD14), |
| 165 | + TIM(4,2,4,&pin_PD15), |
| 166 | + TIM(9,3,1,&pin_PE05), |
| 167 | + TIM(9,3,2,&pin_PE06), |
| 168 | + TIM(1,1,1,&pin_PE09), |
| 169 | + TIM(1,1,2,&pin_PE11), |
| 170 | + TIM(1,1,3,&pin_PE13), |
| 171 | + TIM(1,1,4,&pin_PE14), |
| 172 | +}; |
0 commit comments