atomport-private.h File Reference

Go to the source code of this file.

Defines

#define NO_REG_SAVE
#define INTERRUPT   __interrupt

Functions

void archInitSystemTickTimer (void)
INTERRUPT void TIM1_SystemTickISR (void)

Define Documentation

#define INTERRUPT   __interrupt

Compiler-specific modifiers for interrupt handler functions.

COSMIC: Uses modifier for interrupt handlers. We also force all interrupts to save c_lreg, a separate memory area which Cosmic uses for longs and floats. This memory area must be saved by interrupt handlers for context switch purposes, and to avoid making it impossible to use longs in any OS kernel code accessed by interrupt handlers.

IAR: Uses __interrupt modifier for interrupt handlers.

#define NO_REG_SAVE

Compiler-specific modifier to prevent some functions from saving and restoring registers on entry and exit, if the function is known to never complete (e.g. thread entry points). Reduces stack usage on supporting compilers.


Function Documentation

void archInitSystemTickTimer ( void   ) 

archInitSystemTickTimer

Initialise the system tick timer. Uses the STM8's TIM1 facility.

Returns:
None

Referenced by main().

INTERRUPT void TIM1_SystemTickISR ( void   ) 

System tick ISR.

This is responsible for regularly calling the OS system tick handler. The system tick handler checks if any timer callbacks are necessary, and runs the scheduler.

The CPU automatically saves all registers before calling out to an interrupt handler like this.

The system may decide to schedule in a new thread during the call to atomTimerTick(), in which case the program counter will be redirected to the new thread's running location during atomIntExit(). This ISR function will not actually complete until the thread we interrupted is scheduled back in, at which point the end of this function will be reached (after atomIntExit()) and the IRET call by the compiler will return us to the interrupted thread as if we hadn't run any other thread in the meantime. In other words the interrupted thread can be scheduled out by atomIntExit() and several threads could run before we actually reach the end of this function. When this function does finally complete, the return address (the PC of the thread which was interrupted) will be on the interrupted thread's stack because it was saved on there by the CPU when the interrupt triggered.

As with all interrupts, the ISR should call atomIntEnter() and atomIntExit() on entry and exit. This serves two purposes:

a) To notify the OS that it is running in interrupt context b) To defer the scheduler until after the ISR is completed

We defer all scheduling decisions until after the ISR has completed in case the interrupt handler makes more than one thread ready.

Returns:
None

References uint8_t.


Generated on Fri Jun 4 01:00:01 2010 for atomthreads by  doxygen 1.6.1