Page 1 of 1

[TM4C123] CMSIS header includes

Posted: Thu Feb 28, 2019 1:53 pm
by ExXec

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

Re: [TM4C123] CMSIS header includes

Posted: Thu Feb 28, 2019 6:40 pm
by dhylands
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: ... /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: ... 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: ... 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.