Nut/OS  5.0.5
API Reference
Initialization

Starting Nut/OS. More...

Collaboration diagram for Initialization:

Defines

#define NUT_THREAD_MAINSTACK   1024
#define NUT_THREAD_IDLESTACK   256
#define NUTMEM_END   (uintptr_t)(NUTMEM_START + NUTMEM_SIZE - 1U)
 Last memory address.
#define HEAP_START   &__heap_start
#define HEAP_SIZE   ((uintptr_t) (NUTMEM_END - 256 - (uintptr_t) (&__heap_start)))
#define NUT_THREAD_MAINSTACK   1024
#define NUT_THREAD_IDLESTACK   256
#define NUTMEM_END   &_ramend
#define HEAP_START   &__heap_start
#define HEAP_SIZE   ((uintptr_t)(NUTMEM_END) - (uintptr_t)(HEAP_START))

Functions

void NutAppMain (void *arg)
void NutIdle (void *arg)
 Idle thread.
void NutInit (void)
 Nut/OS Initialization.

Variables

void * __heap_start
void * _ramend
 Last memory address.
void * __heap_start
 Start of heap.

Detailed Description

Starting Nut/OS.


Define Documentation

#define NUT_THREAD_MAINSTACK   1024

Referenced by NutIdle().

#define NUT_THREAD_IDLESTACK   256

Referenced by NutInit().

#define NUTMEM_END   (uintptr_t)(NUTMEM_START + NUTMEM_SIZE - 1U)

Last memory address.

#define HEAP_START   &__heap_start

Referenced by NutInit().

#define HEAP_SIZE   ((uintptr_t) (NUTMEM_END - 256 - (uintptr_t) (&__heap_start)))

Referenced by NutInit().

#define NUT_THREAD_MAINSTACK   1024
#define NUT_THREAD_IDLESTACK   256
#define NUTMEM_END   &_ramend
#define HEAP_START   &__heap_start
#define HEAP_SIZE   ((uintptr_t)(NUTMEM_END) - (uintptr_t)(HEAP_START))

Function Documentation

void NutAppMain ( void *  arg)

Referenced by NutIdle().

void NutIdle ( void *  arg)

Idle thread.

Parameters:
argIgnored by the idle thread.

This function runs in an endless loop as a lowest priority thread.

References main, NUT_THREAD_MAINSTACK, NUT_THREAD_STACK_ADD, NUT_THREAD_STACK_MULT, NutIdleInit(), NutLoadConfig(), NutMainInit(), NutThreadCreate(), NutThreadDestroy(), NutThreadSetPriority(), NutThreadYield(), and NutTimerInit().

Referenced by main(), and NutInit().

Here is the call graph for this function:

void ATTRIBUTE_NUTINIT_SECTION 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.

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")));
Todo:
Make heap threshold configurable, currently hardcoded at 384.
Todo:
Make wait states for external memory access configuratble.
Todo:
Make early UART initialization for kernel debugging configurable.

References _O_CREAT, _O_TRUNC, _O_WRONLY, _NUTDEVICE::dev_init, _NUTDEVICE::dev_open, HEAP_SIZE, HEAP_START, MC_FMR, MC_FWS_2R3W, McuInit(), NUT_THREAD_IDLESTACK, NUT_THREAD_STACK_ADD, NUT_THREAD_STACK_MULT, NutBoardInit(), NutGetCpuClock(), NutHeapAdd, NutIdle(), NutThreadCreate(), outr, puts, and stdout.

Here is the call graph for this function:


Variable Documentation

void* __heap_start
void * _ramend

Last memory address.

void* __heap_start

Start of heap.