4.46. Main

4.46.1. Module Files

4.46.1.1. Driver

  • src/app/main/main.c

  • src/app/main/include/main.h

4.46.1.2. Configuration

none

4.46.1.3. Unit Test

  • tests/unit/app/main/test_main.c

4.46.2. Description

The main module provides the application entry point and performs the platform startup sequence before handing over control to the operating system scheduler.

At startup the following steps are performed:

  • reads and stores the reset source,

  • initializes hardware drivers and low-level peripherals (e.g., SPI, GPIO)

  • initializes diagnostics and executes startup self-tests,

  • initializes the operating system objects (queues, mutexes, events and tasks),

  • enables IRQs after OS/task setup to avoid early interrupt handling on not-yet-created task handles,

  • checks OS boot state and traps on initialization failures,

  • stores the scheduler start tick and starts the scheduler.

Once the scheduler is started, normal operation continues in the configured tasks. Returning from main is an error.

For unit tests, the entry function is exposed as unit_test_main() instead of main() so the startup sequence can be called from the test harness without conflicting with the host test runner entry point.