Miosix  2.01
Interfaces

Files

file  arch_registers.h
 
file  atomic_ops.h
 
file  bsp.h
 
file  delays.h
 
file  endianness.h
 
file  gpio.h
 
file  portability.h
 

Namespaces

 miosix
 c++11
 

Macros

#define toLittleEndian16(x)   (x)
 
#define toLittleEndian32(x)   (x)
 
#define toLittleEndian64(x)   (x)
 
#define toBigEndian16(x)   swapBytes16(x)
 
#define toBigEndian32(x)   swapBytes32(x)
 
#define toBigEndian64(x)   swapBytes64(x)
 

Functions

void miosix::shutdown ()
 
void miosix::reboot ()
 
void miosix::delayMs (unsigned int mseconds)
 
void miosix::delayUs (unsigned int useconds)
 
__MIOSIX_INLINE unsigned short swapBytes16 (unsigned short x)
 
__MIOSIX_INLINE unsigned int swapBytes32 (unsigned int x)
 
__MIOSIX_INLINE unsigned long long swapBytes64 (unsigned long long x)
 

Detailed Description

Interfaces between kernel and architecture specific code.

Starting from Miosix 1.53 all calls from kernel to architecture specific code is done through a set of functions, classes and macros grouped in a set of header files in the miosix/interfaces folder. There are multiple implementations of these functions/classes, one for each architecture supported by Miosix. This eases portability since adding a new architecture is done by implementing a well defined set of interfaces.

Some of these functions are not designed to be accessed by user code, for example the functions in portability.h are used by the kernel to create threads and perform context switching, while the Disk class in disk.h is used by the filesystem module to read and write from disk. Such functions are marked as \internal and therefore are not visible by default in this doxygen documentation, because are useless for application developers. If there is the need to port Miosix to another platform it is always possible to build the doxygen documentation manually including \internal functions. Using functions which are marked as \internal in user code might lead to undefined behaviour.

Macro Definition Documentation

#define toBigEndian16 (   x)    swapBytes16(x)

Convert a (signed or unsigned) short int from the system representation to big endian

Parameters
xvalue to convert
Returns
value converted to big endian
#define toBigEndian32 (   x)    swapBytes32(x)

Convert a (signed or unsigned) int from the system representation to big endian

Parameters
xvalue to convert
Returns
value converted to big endian
#define toBigEndian64 (   x)    swapBytes64(x)

Convert a (signed or unsigned) long long from the system representation to big endian

Parameters
xvalue to convert
Returns
value converted to big endian
#define toLittleEndian16 (   x)    (x)

Convert a (signed or unsigned) short int from the system representation to little endian

Parameters
xvalue to convert
Returns
value converted to little endian
#define toLittleEndian32 (   x)    (x)

Convert a (signed or unsigned) int from the system representation to little endian

Parameters
xvalue to convert
Returns
value converted to little endian
#define toLittleEndian64 (   x)    (x)

Convert a (signed or unsigned) long long from the system representation to little endian

Parameters
xvalue to convert
Returns
value converted to little endian

Function Documentation

void miosix::delayMs ( unsigned int  mseconds)

Delay function. Accuracy depends on the underlying implementation which is architecture specific.
Delay time can be inaccurate if interrupts are enabled or the kernel is running due to time spent in interrupts and due to preemption.
It is implemented using busy wait, so can be safely used even when the kernel is paused or interrupts are disabled.
If the kernel is running it is highly recomended to use Thread::sleep since it gives CPU time to other threads and/or it puts the CPU in low power mode.

Parameters
msecondsmilliseconds to wait
void miosix::delayUs ( unsigned int  useconds)

Delay function. Accuracy depends on the underlying implementation which is architecture specific.
Delay time can be inaccurate if interrupts are enabled or the kernel is running due to time spent in interrupts and due to preemption.
It is implemented using busy wait, so can be safely used even when the kernel is paused or interrupts are disabled.

Parameters
usecondsmicroseconds to wait. Only values between 1 and 1000 are allowed. For greater delays use Thread::sleep() or delayMs().
void miosix::reboot ( )

The difference between this function and miosix_private::IRQsystemReboot() is that this function disables filesystem (if enabled), serial port (if enabled) while miosix_private::system_reboot() does not do all these things. miosix_private::IRQsystemReboot() is designed to reboot the system when an unrecoverable error occurs, and is used primarily in kernel code, reboot() is designed to reboot the system in normal conditions.
This function does not return.
WARNING: close all files before using this function, since it unmounts the filesystem.

void miosix::shutdown ( )

This function disables filesystem (if enabled), serial port (if enabled) and shuts down the system, usually by putting the procesor in a deep sleep state.
The action to start a new boot is system-specific, can be for example a reset, powercycle or a special GPIO configured to wakeup the processor from deep sleep.
This function does not return.
WARNING: close all files before using this function, since it unmounts the filesystem.

unsigned short swapBytes16 ( unsigned short  x)
inline
Parameters
xan short int
Returns
the same short with its bytes swapped
unsigned int swapBytes32 ( unsigned int  x)
inline
Parameters
xan int
Returns
the same int with its bytes swapped
unsigned long long swapBytes64 ( unsigned long long  x)
inline
Parameters
xa long long
Returns
the same long long with its bytes swapped