Starting Nut/OS. More...
Defines | |
#define | NUTMEM_END (uint16_t)(NUTXMEM_START + (uint16_t)NUTXMEM_SIZE - 1U) |
Last memory address using external SRAM. | |
#define | NUT_THREAD_MAINSTACK 1024 |
#define | NUT_THREAD_IDLESTACK 128 |
#define | AVR_SLEEP_CTRL_REG MCUCR |
Functions | |
void | NutInit (void) |
Nut/OS Initialization. | |
void | NutAppMain (void *arg) |
uint8_t | NutThreadSetSleepMode (uint8_t mode) |
Sets the sleep mode to enter in Idle thread. | |
void | NutIdle (void *arg) |
AVR Idle thread. | |
Variables | |
uint8_t | nutmem_onchip [NUTMEM_RESERVED] |
Number of bytes reserved in on-chip memory. | |
uint8_t | idle_sleep_mode = SLEEP_MODE_NONE |
Starting Nut/OS.
#define NUT_THREAD_MAINSTACK 1024 |
void NutInit | ( | void | ) |
Nut/OS Initialization.
Initializes the memory management and the thread system and starts an idle thread, which in turn initializes the timer management. Finally the application's main() function is called.
Depending on the compiler, different methods are used to execute this function before main() is called.
For ICCAVR the default crtatmega.o startup file is replaced by crtnut.o, which calls NutInit instead of main(). This is done by adding the following compiler options in the project:
-ucrtnut.o nutinit.o
crtnut.o should be replaced by crtnutram.o, if the application's variable space exceeds 4kB. For boards with RTL8019AS and EEPROM emulation (like Ethernut 1.3 Rev-G) use crtenut.o or crtenutram.o.
For AVRGCC this function is located in section .init8, which is called immediately before jumping to main(). NutInit is defined as:
void NutInit(void) __attribute__ ((naked)) __attribute__ ((section (".init8")));
void NutAppMain | ( | void * | arg | ) |
Sets the sleep mode to enter in Idle thread.
If the idle thread is running, no other thread is active so we can safely put the mcu to sleep.
mode | one of the sleep modes defined in avr/sleep.h or sleep_mode_none (don't enter sleep mode) |
Definition at line 297 of file nutinit.c.
References idle_sleep_mode.
void NutIdle | ( | void * | arg | ) |
AVR Idle thread.
Running at priority 254 in an endless loop.
Definition at line 310 of file nutinit.c.
References _BV, AVR_SLEEP_CTRL_REG, bit_is_set, cbi, idle_sleep_mode, main, NUT_THREAD_MAINSTACK, NUT_THREAD_STACK_ADD, NUT_THREAD_STACK_MULT, NutIdleInit(), NutMainInit(), NutThreadCreate(), NutThreadDestroy(), NutThreadSetPriority(), NutThreadYield(), NutTimerInit(), sbi, and SLEEP_MODE_NONE.
uint8_t nutmem_onchip[NUTMEM_RESERVED] |
Number of bytes reserved in on-chip memory.
AVR offers the option to temporarily use address and data bus lines as general purpose I/O. If such drivers need data memory, this must be located at internal memory addresses.
uint8_t idle_sleep_mode = SLEEP_MODE_NONE |
Definition at line 204 of file nutinit.c.
Referenced by NutIdle(), and NutThreadSetSleepMode().