[TM4C123] CMSIS header includes

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
Posts: 83
Joined: Sat Oct 20, 2018 4:02 pm

[TM4C123] CMSIS header includes

Post by ExXec » Thu Feb 28, 2019 1:53 pm


I noticed, that a lot of stm32 modules refer to the "SCB" struct from the CMSIS. However, the corresponding header is not included.
e.g. in pybthread.h:

Code: Select all

static inline void pyb_thread_yield(void) {
    if (pyb_thread_cur->run_next == pyb_thread_cur) {
    } else {

In the port I'm currently making, I copy the stm32 modules and modify them. I always have to add the CMSIS header or it won't compile, but the stm32 compiled just fine. How does this work?

The same goes for the NVIC_SetPriority* functions.

- ExXec

User avatar
Posts: 3600
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada

Re: [TM4C123] CMSIS header includes

Post by dhylands » Thu Feb 28, 2019 6:40 pm

There are 2 types of CMSIS files. The first type are about the core, like Cortex-M4 or Cortex-M3 and includes definitions for the peripherals that can be found on all Cortex-M4's regardless of the manufacturer. There header files can be found here: https://github.com/micropython/micropyt ... /cmsis/inc

These header files contain the definitions for the SCB and NVIC.

The second type of CMSIS files are sepcific to an MCU and describe the peripherals included on the that MCU. These header files can be found here: https://github.com/micropython/stm32lib ... xx/Include

These include definitions for GPIO, RTC, DMA, I2C, SPI, etc.

The stm32 port uses the HAL files. The name of the HAL header file is defined by the macro STM32_HAL_H in the Makefile:
https://github.com/micropython/micropyt ... kefile#L82

The chain of include files to get to core_cm4.h when building for PYBV11 looks something like this:

stm32lib/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h (this it the STM32_HAL_H #define)
stm32lib/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_xxx.h (replace xxx with can/rcc/i2c/gpio/etc)

One simple way to determine this is to run a command something like the following:

Code: Select all

make BOARD=PYBV11 build-PYBV11/uart.pp
You can then look at the build-PYBV11/uart.pp file which will be the uart.c file with all of the #includes fully expanded.

Post Reply