#include <stdio.h>
#include "atom.h"
#include "atomport-private.h"
#include "atomtests.h"
#include "atomtimer.h"
#include "uart.h"
#include <avr/pgmspace.h>
Defines | |
#define | IDLE_STACK_SIZE_BYTES 128 |
#define | MAIN_STACK_SIZE_BYTES 204 |
Functions | |
int | main (void) |
#define IDLE_STACK_SIZE_BYTES 128 |
Referenced by main().
#define MAIN_STACK_SIZE_BYTES 204 |
Referenced by main().
int main | ( | void | ) |
main
Program entry point.
Sets up the AVR hardware resources (system tick timer interrupt) necessary for the OS to be started. Creates an application thread and starts the OS.
Reuse part of the idle thread's stack for the stack required during this startup function.
Note: to protect OS structures and data during initialisation, interrupts must remain disabled until the first thread has been restored. They are reenabled at the very end of the first thread restore, at which point it is safe for a reschedule to take place.
Initialise the OS before creating our threads.
Note that we tell the OS that the idle stack is half its actual size. This prevents it prefilling the bottom half with known values for stack-checkig purposes, which we cannot allow because we are temporarily using it for our own stack. The remainder will still be available once the OS is started, this only prevents the OS from prefilling it.
If you are not reusing the idle thread's stack during startup then you should pass in the correct size here.
First application thread successfully created. It is now possible to start the OS. Execution will not return from atomOSStart(), which will restore the context of our application thread and start executing it.
Note that interrupts are still disabled at this point. They will be enabled as we restore and execute our first thread in archFirstThreadRestore().
References avrInitSystemTickTimer(), IDLE_STACK_SIZE_BYTES, and MAIN_STACK_SIZE_BYTES.