Lazuli
|
Architecture Abstraction API. More...
#include <stdint.h>
#include <Lazuli/common.h>
#include <Lazuli/list.h>
#include <Lazuli/serial.h>
#include <Lazuli/sys/compiler.h>
Go to the source code of this file.
Data Structures | |
struct | U16DivisionResult |
Represents the result of a uin16_t division. More... | |
Typedefs | |
typedef uint8_t | InterruptsStatus |
Define the type used to store interrupts status. More... | |
Functions | |
void | Arch_InfiniteLoop (void) |
Function that loops forever, never returns. | |
void | Arch_ResetSystem (void) |
Reset the whole system. | |
void | Arch_RestoreContextAndReturnFromInterrupt (void *stackPointer) |
Restore the context of a previously saved task, and run it by returning from interrupt. More... | |
void | Arch_StartRunning (void *stackPointer, size_t offsetOfPc) |
Start running the scheduler for the first time with the specified context. More... | |
void | Arch_LoadFromProgmem (const void *source, void *destination, const size_t size) |
Copy bytes from program memory to RAM. More... | |
uint8_t | Arch_LoadU8FromProgmem (const void *source) |
Return a byte stored in program memory. More... | |
uint16_t | Arch_LoadU16FromProgmem (const void *source) |
Return a double-byte word stored in program memory. More... | |
void * | Arch_LoadPointerFromProgmem (const void *source) |
Return a pointer stored in program memory. More... | |
void | Arch_DisableInterrupts (void) |
Disable all interrupts. | |
void | Arch_EnableInterrupts (void) |
Enable all interrupts. | |
InterruptsStatus | Arch_DisableInterruptsGetStatus (void) |
Disable all interrupts and return the previous interrupts status. More... | |
void | Arch_RestoreInterruptsStatus (const InterruptsStatus interruptsStatus) |
Restore a previously saved interrupts status. More... | |
bool | Arch_AreInterruptsEnabled (void) |
Obtain a value indicating if global interrupts are enabled. More... | |
void | Arch_InitIdleCpuMode (void) |
Initialize idle CPU modes. | |
void | Arch_CpuSleep (void) |
Put the CPU to sleep according to the sleep settings. | |
void | Arch_InitInstrumentation (void) |
Initialize the context switch instrumentation. | |
System timer | |
void | Arch_InitSystemTimer (void) |
Initialize the system timer. | |
void | Arch_StartSystemTimer (void) |
Start the system timer. | |
Mutex | |
bool | Arch_TryAcquireLock (volatile uint8_t *const lock) |
Try to acquire a lock by atomically changing the value pointed by the lock parameter. More... | |
Serial | |
void | Arch_GetSerialConfiguration (Lz_SerialConfiguration *const configuration) |
Retrieve the current configuration of the serial line. More... | |
void | Arch_SetSerialConfiguration (const Lz_SerialConfiguration *const configuration) |
Configure the seria line according to the parameter. More... | |
void | Arch_InitSerial (void) |
Initialize serial line with default configuration at system startup. More... | |
U16DivisionResult | Arch_Divide_U16 (uint16_t numerator, uint16_t denominator) |
Perform the Euclidean division between two uint16_t operands. More... | |
Variables | |
void(*)(void) | Arch_LoadFunctionPointerFromProgmem (const void *source) |
Return a function pointer stored in program memory. More... | |
Architecture Abstraction API.
Provides a simple abstraction API to architecture specific functions. This is the API that must be re-implemented if porting to another platform.
This one is taylored after the AVR platform and can be subject to change if porting to another platform.
Definition in file arch.h.
typedef uint8_t InterruptsStatus |
Define the type used to store interrupts status.
You shall ALWAYS set a variable of this type by calling Arch_DisableInterruptsGetStatus(), and NEVER modify its value manually.
void Arch_RestoreContextAndReturnFromInterrupt | ( | void * | stackPointer | ) |
Restore the context of a previously saved task, and run it by returning from interrupt.
The context of a task is saved on its stack. Consists in restoring all of the registers (including the state register) and continue execution of the task by performing a return from interrupt
, as the program counter has previously been saved on the stack by hardware.
stackPointer | The stack pointer of the task to restore. |
void Arch_StartRunning | ( | void * | stackPointer, |
size_t | offsetOfPc | ||
) |
Start running the scheduler for the first time with the specified context.
This function simply ignores all the registers in the context, and jumps directly to the saved return address.
stackPointer | The stack pointer of the task to run, containing its prepared context. |
offsetOfPc | The offset of the PC member in the TaskContextLayout structure (i.e. the saved context of the task). |
void Arch_LoadFromProgmem | ( | const void * | source, |
void * | destination, | ||
const size_t | size | ||
) |
Copy bytes from program memory to RAM.
source | A pointer to the source address in program memory. |
destination | A pointer to the destination address in RAM. |
size | The number of bytes to copy. |
uint8_t Arch_LoadU8FromProgmem | ( | const void * | source | ) |
Return a byte stored in program memory.
source | A pointer to the byte stored in program memory. |
uint16_t Arch_LoadU16FromProgmem | ( | const void * | source | ) |
Return a double-byte word stored in program memory.
source | A pointer to the word stored in program memory. |
void* Arch_LoadPointerFromProgmem | ( | const void * | source | ) |
Return a pointer stored in program memory.
source | A pointer to the pointer stored in program memory. |
InterruptsStatus Arch_DisableInterruptsGetStatus | ( | void | ) |
Disable all interrupts and return the previous interrupts status.
void Arch_RestoreInterruptsStatus | ( | const InterruptsStatus | interruptsStatus | ) |
Restore a previously saved interrupts status.
interruptsStatus | A previously saved InterruptsStatus. |
bool Arch_AreInterruptsEnabled | ( | void | ) |
Obtain a value indicating if global interrupts are enabled.
Try to acquire a lock by atomically changing the value pointed by the lock parameter.
lock | A pointer to the lock. |
void Arch_GetSerialConfiguration | ( | Lz_SerialConfiguration *const | configuration | ) |
Retrieve the current configuration of the serial line.
configuration | A pointer to an allocated Lz_SerialConfiguration used to store the configuration. |
void Arch_SetSerialConfiguration | ( | const Lz_SerialConfiguration *const | configuration | ) |
Configure the seria line according to the parameter.
configuration | A pointer to an existing Lz_SerialConfiguration containg the full configuration to set up the serial line. |
void Arch_InitSerial | ( | void | ) |
U16DivisionResult Arch_Divide_U16 | ( | uint16_t | numerator, |
uint16_t | denominator | ||
) |
Perform the Euclidean division between two uint16_t operands.
numerator | The numerator of the division. |
denominator | The denominator of the division. |
void(*)(void) Arch_LoadFunctionPointerFromProgmem(const void *source) |
Return a function pointer stored in program memory.
source | A pointer to the function pointer stored in program memory. |