Debian Codegraph @

ports/stm32/boards/NUCLEO_L152RE/mpconfigboard.h

raw
1 #define MICROPY_HW_BOARD_NAME "NUCLEO-L152RE"
2 #define MICROPY_HW_MCU_NAME "STM32L152xE"
3
4 #define MICROPY_HW_HAS_SWITCH (1)
5 #define MICROPY_HW_ENABLE_RTC (1)
6 // This board has an external 32kHz crystal
7 #define MICROPY_HW_RTC_USE_LSE (1)
8 #define MICROPY_HW_ENABLE_SERVO (1)
9 #define MICROPY_HW_ENABLE_DAC (1)
10 #define MICROPY_HW_ENABLE_USB (0)
11
12 // HSE is 8MHz, HSI is 16MHz CPU freq set to 32MHz
13 // Default source for the clock is HSI.
14 // For revisions of the board greater than C-01, HSE can be used as a
15 // clock source by removing the #define MICROPY_HW_CLK_USE_HSE line
16 #define MICROPY_HW_CLK_USE_HSI (1)
17
18 #if MICROPY_HW_CLK_USE_HSI
19 #define MICROPY_HW_CLK_PLLMUL (RCC_CFGR_PLLMUL6)
20 #define MICROPY_HW_CLK_PLLDIV (RCC_CFGR_PLLDIV3)
21 #else
22 #define MICROPY_HW_CLK_PLLMUL (RCC_CFGR_PLLMUL12)
23 #define MICROPY_HW_CLK_PLLDIV (RCC_CFGR_PLLDIV3)
24 #endif
25
26 // UART config
27 #define MICROPY_HW_UART1_TX (pin_A9)
28 #define MICROPY_HW_UART1_RX (pin_A10)
29 #define MICROPY_HW_UART2_TX (pin_A2)
30 #define MICROPY_HW_UART2_RX (pin_A3)
31 #define MICROPY_HW_UART3_TX (pin_B10)
32 #define MICROPY_HW_UART3_RX (pin_B11)
33 #define MICROPY_HW_UART4_TX (pin_C10)
34 #define MICROPY_HW_UART4_RX (pin_C11)
35 #define MICROPY_HW_UART5_TX (pin_C12)
36 #define MICROPY_HW_UART5_RX (pin_D2)
37 // UART 2 connects to the STM32F103 (STLINK) on the Nucleo board
38 // and this is exposed as a USB Serial port.
39 #define MICROPY_HW_UART_REPL PYB_UART_2
40 #define MICROPY_HW_UART_REPL_BAUD 115200
41
42 // I2C buses
43 #define MICROPY_HW_I2C1_SCL (pin_B8) // Arduino D15, pin 3 on CN10
44 #define MICROPY_HW_I2C1_SDA (pin_B9) // D14, pin 5 on CN10
45 #define MICROPY_HW_I2C2_SCL (pin_B10) // Arduino D6, pin 25 on CN10
46 #define MICROPY_HW_I2C2_SDA (pin_B11) // Arduino D3, pin 31 on CN10
47
48 // SPI buses
49 #define MICROPY_HW_SPI1_NSS (pin_A15) // pin 17 on CN7
50 #define MICROPY_HW_SPI1_SCK (pin_A5) // Arduino D13, pin 11 on CN10
51 #define MICROPY_HW_SPI1_MISO (pin_A6) // Arduino D12, pin 13 on CN10
52 #define MICROPY_HW_SPI1_MOSI (pin_A7) // Arduino D11, pin 15 on CN10
53
54 #define MICROPY_HW_SPI2_NSS (pin_B12) // pin 16 on CN10
55 #define MICROPY_HW_SPI2_SCK (pin_B13) // pin 30 on CN10
56 #define MICROPY_HW_SPI2_MISO (pin_B14) // pin 28 on CN10
57 #define MICROPY_HW_SPI2_MOSI (pin_B15) // pin 26 on CN10
58
59 #define MICROPY_HW_SPI3_NSS (pin_A4) // Arduino A2, pin 32 on CN7
60 #define MICROPY_HW_SPI3_SCK (pin_C10) // Arduino D3, pin 31 on CN10
61 #define MICROPY_HW_SPI3_MISO (pin_C11) // Arduino D5, pin 27 on CN10
62 #define MICROPY_HW_SPI3_MOSI (pin_C12) // Arduino D4, pin 29 on CN10
63
64 // USRSW is pulled low. Pressing the button makes the input go high.
65 #define MICROPY_HW_USRSW_PIN (pin_C13)
66 #define MICROPY_HW_USRSW_PULL (GPIO_NOPULL)
67 #define MICROPY_HW_USRSW_EXTI_MODE (GPIO_MODE_IT_FALLING)
68 #define MICROPY_HW_USRSW_PRESSED (0)
69
70 // LEDs
71 #define MICROPY_HW_LED1 (pin_A5) // Green LD2 LED on Nucleo
72 #define MICROPY_HW_LED_ON(pin) (mp_hal_pin_high(pin))
73 #define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_low(pin))
74
75 #define MICROPY_HW_FLASH_LATENCY FLASH_LATENCY_1
76
77 // USB config
78 #if MICROPY_HW_ENABLE_USB
79 #if MICROPY_HW_CLK_USE_HSI
80 #error STM32L152RE cannot use USB feature with HSI clock. Use HSE.
81 #endif
82 #define MICROPY_HW_USB_FS (1)
83 #endif