Skip to content

Initialisation and Ready to Drive

Tim Brewis edited this page Mar 17, 2022 · 3 revisions

Initialisation

The hardware initialisation process is mostly handled by the code generated automatically by STM32CubeIDE from the project configuration file.

Initialisation of the RTOS threads happens in App_ThreadX_Init() which is called during the ThreadX kernel initialisation (tx_kernel_enter()). The initialisation process is as follows:

  • Allocate memory for the stack of each thread from the application memory pool using tx_byte_allocate().
  • Create each thread using tx_thread_create().
  • Initialise the message passing system (?).
  • Complete the ready-to-drive procedure.
  • Exit initialisation and begin running the ThreadX scheduler.

Ready-to-Drive

The RTOS kernel will not begin scheduling threads until the ready-to-drive procedure is completed. This is handled by the ready_to_drive() function which:

  1. Turns on the built-in red LED.
  2. Waits for a rising edge on the ready-to-drive input signal.
  3. Drives the buzzer output pin for the number of seconds specified by READY_TO_DRIVE_BUZZER_TIME.
  4. Turns off the built-in red LED.

The ready-to-drive input signal can be overridden for testing by setting READY_TO_DRIVE_OVERRIDE in the configuration header which will use the 'USER' button on the dev board as a replacement for the ready-to-drive signal. The behaviour of the process is otherwise the same.