42 #define _________________________________________LOCAL_TYPES_SECTION________________________________________________________________________ 46 #undef _________________________________________LOCAL_TYPES_SECTION________________________________________________________________________ 54 #define _________________________________________LOCAL_MACROS_SECTION_______________________________________________________________________ 57 #define IsRam(Address) oC_LSF_IsRamAddress(Address) 58 #define IsRom(Address) oC_LSF_IsRomAddress(Address) 64 #define ALIGN_SIZE(SIZE,ALIGNMENT) ((((oC_UInt_t)SIZE) + ALIGNMENT - 1) & ~(ALIGNMENT-1)) 66 #undef _________________________________________LOCAL_MACROS_SECTION_______________________________________________________________________ 68 #define _________________________________________VARIABLES_SECTION__________________________________________________________________________ 75 #undef _________________________________________VARIABLES_SECTION__________________________________________________________________________ 82 #define _________________________________________LOCAL_PROTOTYPES_SECTION___________________________________________________________________ 94 #undef _________________________________________LOCAL_PROTOTYPES_SECTION___________________________________________________________________ 101 #define _________________________________________INTERFACE_FUNCITONS_SECTION________________________________________________________________ 114 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
125 EventInterruptHandler =
NULL;
126 EnabledEventsFlags = 0;
127 SystemTimerFrequency = 0;
129 errorCode = oC_ErrorCode_None;
133 errorCode = oC_ErrorCode_CannotInitializeModule;
149 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
155 EventInterruptHandler =
NULL;
156 EnabledEventsFlags = 0;
157 SystemTimerFrequency = 0;
161 errorCode = oC_ErrorCode_None;
175 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
181 oC_AssignErrorCodeIfFalse(&errorCode , IsRam(EventHandler) || IsRom(EventHandler) , oC_ErrorCode_WrongEventHandlerAddress) &&
182 oC_AssignErrorCodeIfFalse(&errorCode , EventInterruptHandler ==
NULL , oC_ErrorCode_InterruptHandlerAlreadySet)
185 EventInterruptHandler = EventHandler;
186 EnabledEventsFlags = EventsFlags;
188 EnableEventsInterrupts(EventsFlags);
190 errorCode = oC_ErrorCode_None;
271 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
277 oC_AssignErrorCodeIfFalse(&errorCode , IsRom(Interrupt) || IsRam(Interrupt) , oC_ErrorCode_WrongEventHandlerAddress) &&
278 oC_AssignErrorCodeIfFalse(&errorCode , Frequency > 0 && (Frequency <= clockFrequency) , oC_ErrorCode_WrongFrequency)
281 uint32_t prescaler = clockFrequency / Frequency;
287 SystemTimerFrequency = clockFrequency / prescaler;
288 errorCode = oC_ErrorCode_None;
292 errorCode = oC_ErrorCode_FrequencyNotPossible;
309 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
313 if(oC_AssignErrorCodeIfFalse(&errorCode , SystemTimerFrequency != 0 , oC_ErrorCode_SystemClockNotConfigured))
315 *outFrequency = SystemTimerFrequency;
316 errorCode = oC_ErrorCode_None;
331 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
339 errorCode = oC_ErrorCode_None;
343 errorCode = oC_ErrorCode_ContextNotCorrect;
361 oC_Int_t stackSize = 0;
379 oC_Int_t freeStackSize = 0;
386 return freeStackSize;
430 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
435 oC_AssignErrorCodeIfFalse(&errorCode , IsRam(Context) , oC_ErrorCode_OutputAddressNotInRAM ) &&
436 oC_AssignErrorCodeIfFalse(&errorCode , IsRam(Context) || IsRom(ContextHandler) , oC_ErrorCode_WrongEventHandlerAddress ) &&
437 oC_AssignErrorCodeIfFalse(&errorCode , IsRam(ExitHandler) || IsRom(ExitHandler) , oC_ErrorCode_WrongEventHandlerAddress ) &&
438 oC_AssignErrorCodeIfFalse(&errorCode , StackSize > 0 , oC_ErrorCode_WrongStackSize)
443 errorCode = oC_ErrorCode_None;
447 errorCode = oC_ErrorCode_CannotInitializeStack;
529 return oC_ErrorCode_NotSupportedOnTargetMachine;
543 #undef _________________________________________INTERFACE_FUNCITONS_SECTION________________________________________________________________ 551 #define _________________________________________LOCAL_FUNCTIONS_SECTION____________________________________________________________________ 572 if(IsRom(EventInterruptHandler) || IsRam(EventInterruptHandler))
574 if(EnabledEventsFlags & EventFlags)
588 #undef _________________________________________LOCAL_FUNCTIONS_SECTION____________________________________________________________________ 595 #define _________________________________________INTERRUPTS_SECTION_________________________________________________________________________ 607 oC_ASSERT( EventInterruptHandler !=
NULL );
611 #undef _________________________________________INTERRUPTS_SECTION_________________________________________________________________________ #define oC_InterruptHandler(BASE_NAME, TYPE_NAME)
Define handler for interrupt.
oC_SYS_LLD_Context_t * oC_SYS_LLD_GetSystemContext(void)
returns pointer to the system context
oC_SYS_LLD_EventFlags_t
event flags handled by the module.
oC_Int_t oC_MCS_GetMinimumStackBufferSize(oC_Int_t StackSize)
returns minimum stack buffer size
void * oC_MCS_GetCurrentProcessStackPointer(void)
returns current value of PSP
oC_InterruptHandler_t oC_UnexpectedInterruptHandler
Handler for unexpected interrupts.
void(* oC_SYS_LLD_ContextHandler_t)(void *Parameter)
stores pointer to context handler function
oC_Int_t oC_SYS_LLD_GetMinimumContextSize(oC_Int_t StackSize)
returns minimum size to allocate for context
#define oC_MACHINE_FAMILY
double oC_Frequency_t
type to store frequency
void(* oC_SYS_LLD_EventInterrupt_t)(oC_SYS_LLD_EventFlags_t EventFlags, oC_SYS_LLD_Context_t *Context, void *BusAddress)
stores event handler function
oC_ErrorCode_t oC_SYS_LLD_InitializeContext(oC_SYS_LLD_Context_t **Context, oC_Int_t StackSize, oC_SYS_LLD_ContextHandler_t ContextHandler, void *Parameters, oC_SYS_LLD_ContextExitHandler_t ExitHandler)
initializes stack of process
oC_SYS_LLD_Context_t * oC_SYS_LLD_GetCurrentContext(void)
returns pointer to the current context
const char * oC_SYS_LLD_GetMachineFamilyName(void)
returns printable name of the machine family
void * oC_MCS_GetHardFaultReason(void)
returns address that cause a hard fault
The file contains definitions for the compiler, that helps to manage errors, etc. ...
oC_Stack_t oC_MCS_GetSystemStack(void)
returns pointer to the system stack
oC_ErrorCode_t oC_SYS_LLD_TurnOnDriver(void)
initializes the driver to work
const char * oC_SYS_LLD_GetMachineProducentName(void)
returns printable name of the machine producent
The file with interface for LSF module.
bool oC_MCS_ReturnToSystemStack(void)
sets next stack as system stack
oC_ErrorCode_t oC_SYS_LLD_ReturnToSystemContext(void)
switches to the system context
void oC_MCS_Reboot(void)
Software reboots of machine.
void oC_SYS_LLD_ExitCriticalSection(void)
exits from critical section
The file with LLD interface for the MEM driver.
bool oC_MCS_InitializeStack(oC_Stack_t *outStack, void *Buffer, oC_Int_t BufferSize, oC_ContextHandler_t ContextHandler, void *HandlerParameter, oC_ContextExitHandler_t ExitHandler)
initializes stack for the system
oC_ErrorCode_t oC_SYS_LLD_ConfigureSystemTimer(oC_Frequency_t Frequency, oC_SYS_LLD_SysTickIncrementHandler_t Interrupt)
configures system timer
oC_ErrorCode_t oC_SYS_LLD_ReadSystemTimerFrequency(oC_Frequency_t *outFrequency)
reads configured system frequency
void oC_SYS_LLD_Context_t
type for storing context of the machine
void oC_SYS_LLD_TurnOnInterrupts(void)
turns on interrupt
void(* oC_SYS_LLD_SysTickIncrementHandler_t)(void)
stores SysTick interrupt handler
oC_Int_t oC_MCS_GetFreeStackSize(oC_Stack_t Stack)
returns number of free stack
oC_ErrorCode_t oC_SYS_LLD_TurnOffDriver(void)
release the driver
bool oC_MCS_SetNextStack(oC_Stack_t Stack)
sets next stack for context switching
void(* oC_SYS_LLD_ContextExitHandler_t)(void)
pointer to the context exit handler
The file with interface for the module library.
const char * oC_SYS_LLD_GetMachineName(void)
returns printable name of the machine
oC_Frequency_t oC_CLOCK_LLD_GetClockFrequency(void)
returns frequency of the system clock
oC_Int_t oC_SYS_LLD_GetContextStackSize(oC_SYS_LLD_Context_t *Context)
returns size of the stack for context
static bool oC_Module_IsTurnedOn(oC_Module_t Module)
checks if the module is turned on
The file with LLD interface for the CLOCK driver.
oC_ErrorCode_t oC_SYS_LLD_ReadPowerState(float *outVcc)
reads power state
oC_ErrorCode_t oC_SYS_LLD_SetNextContext(oC_SYS_LLD_Context_t *Context)
configures next machine context
void oC_SYS_LLD_EnterCriticalSection(void)
enters to critical section
bool oC_MCS_ConfigureSystemTimer(oC_UInt_t Prescaler, oC_FindNextStackHandler_t FindNextStackHandler)
configures system timer
bool oC_MCS_AreInterruptsEnabled(void)
Checks if interrupts are enabled in HW.
oC_Int_t oC_MCS_GetStackSize(oC_Stack_t Stack)
returns size of stack
static void oC_Module_TurnOn(oC_Module_t Module)
sets module as turned on
Contains machine core specific functions.
bool oC_MCS_InitializeModule(void)
initializes module to work
oC_ErrorCode_t oC_SYS_LLD_SetEventInterruptHandler(oC_SYS_LLD_EventInterrupt_t EventHandler, oC_SYS_LLD_EventFlags_t EventsFlags)
sets event interrupt handler
static void oC_MCS_EnterCriticalSection(void)
Enters to critical section.
oC_Stack_t oC_MCS_GetCurrentStack(void)
returns current stack
The file with interface for the machine module.
The file with interface interrupt module.
void oC_MCS_DisableInterrupts(void)
Globally disables interrupts (always)
#define oC_MCS_IsStackPushDecrementPointer()
returns true if stack push decrements SP
void oC_SYS_LLD_Reset(void)
software reset of the machine
static bool oC_Module_TurnOffVerification(oC_ErrorCode_t *outErrorCode, oC_Module_t Module)
verify if module is turned off
static bool oC_MCS_ExitCriticalSection(void)
Exits from critical section.
static bool oC_Module_TurnOnVerification(oC_ErrorCode_t *outErrorCode, oC_Module_t Module)
verify if module is turned on
void oC_MCS_EnableInterrupts(void)
Globally enables interrupts (always)
The file with LLD interface for the SYS driver.
bool oC_SYS_LLD_AreInterruptsEnabled(void)
checks if interrupts are turned on
void * oC_SYS_LLD_GetLastProcessStackPointer(void)
returns stack pointer of last executed process
bool oC_SYS_LLD_IsStackPushDecrementPointer(void)
flag if stack push is decrement pointer
void oC_SYS_LLD_TurnOffInterrupts(void)
turns off interrupt
bool oC_SYS_LLD_IsMachineSupportMultithreadMode(void)
checks if the machine supports multi-thread mode
Hard fault, reason is unknown.
#define NULL
pointer to a zero
static void oC_Module_TurnOff(oC_Module_t Module)
sets module as turned off
oC_Int_t oC_SYS_LLD_GetContextFreeStackSize(oC_SYS_LLD_Context_t *Context)
returns size of free stack in the context