ccNOos  v0.0.0
Build Portable Microcontroller Applications!
Functions
execution_system.c File Reference

IMS: ccNOos, Implementation for straight C More...

#include "execution_system.h"
#include "console_menu.h"
Include dependency graph for execution_system.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

struct executionSystemStruct CreateExecutionSystemStruct (UI_32 uSperTick)
 
void ModuleExeArea (UI_32 ExcpIndex, struct linkedEntryPointStruct *exeListHeadIn)
 
void ModuleExceptionArea (struct linkedEntryPointStruct *exeListHeadIn)
 
int ExecuteMain (struct executionSystemStruct *exeStructIn, struct executionEntryStruct *exeEntryPtrsIn)
 
int ExecuteSetup (struct executionSystemStruct *exeStructIn, struct executionEntryStruct *exeEntryPtrsIn)
 
int ExecuteLoop (struct executionSystemStruct *exeStructIn, struct executionEntryStruct *exeEntryPtrsIn)
 
void ExecuteSysTick (struct executionSystemStruct *exeStructIn, struct executionEntryStruct *exeEntryPtrsIn)
 

Detailed Description

IMS: ccNOos, Implementation for straight C

Copyright 2021 InMechaSol, Inc

Licensed under the Apache License, Version 2.0(the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Notes: (.c includes .h) - for straight C or (.cpp includes .c which includes .h) - for C++ wrapped straight C Always compiled to a single compilation unit, either C or CPP, not both

Definition in file execution_system.c.

Function Documentation

◆ CreateExecutionSystemStruct()

struct executionSystemStruct CreateExecutionSystemStruct ( UI_32  uSperTick)

Definition at line 1 of file execution_system.c.

34 {
35  struct executionSystemStruct outStruct;
36  outStruct.hourTicks = 0u;
37  outStruct.uSecTicks = 0u;
38  outStruct.uSecPerSysTick = uSperTick;
39  return outStruct;
40 }

◆ ExecuteLoop()

int ExecuteLoop ( struct executionSystemStruct exeStructIn,
struct executionEntryStruct exeEntryPtrsIn 
)

Definition at line 173 of file execution_system.c.

177 {
178  // module exception and loop execution areas
180  exeEntryPtrsIn->exceptionListHead
181  );
182 
184  EXP_LOOP,
185  exeEntryPtrsIn->loopListHead
186  );
187 
189 
190  return RETURN_SUCCESS;
191 }

◆ ExecuteMain()

int ExecuteMain ( struct executionSystemStruct exeStructIn,
struct executionEntryStruct exeEntryPtrsIn 
)

Definition at line 112 of file execution_system.c.

116 {
117  if(exeStructIn == nullptr || exeEntryPtrsIn == nullptr)
118  return RETURN_ERROR;
119 
120  // platform exe system setup
121  platformSetup();
122 
123  // module setup execution area
125  EXP_SETUP,
126  exeEntryPtrsIn->setupListHead
127  );
128 
129  // platform exe system start
130  platformStart();
131 
132  // module exception and loop execution areas
133  for(;;)
134  {
136  exeEntryPtrsIn->exceptionListHead
137  );
138 
140  EXP_LOOP,
141  exeEntryPtrsIn->loopListHead
142  );
143 
145  }
146 
147  return RETURN_SUCCESS;
148 }

◆ ExecuteSetup()

int ExecuteSetup ( struct executionSystemStruct exeStructIn,
struct executionEntryStruct exeEntryPtrsIn 
)

Definition at line 150 of file execution_system.c.

154 {
155  if(exeStructIn == nullptr || exeEntryPtrsIn == nullptr)
156  return RETURN_ERROR;
157 
158  // platform exe system setup
159  platformSetup();
160 
161  // module setup execution area
163  EXP_SETUP,
164  exeEntryPtrsIn->setupListHead
165  );
166 
167  // platform exe system start
168  platformStart();
169 
170  return RETURN_SUCCESS;
171 }

◆ ExecuteSysTick()

void ExecuteSysTick ( struct executionSystemStruct exeStructIn,
struct executionEntryStruct exeEntryPtrsIn 
)

Definition at line 193 of file execution_system.c.

197 {
198  exeStructIn->uSecTicks += exeStructIn->uSecPerSysTick;
199  if(exeStructIn->uSecTicks >= TIME_uS_PER_HR)
200  {
201  exeStructIn->uSecTicks = 0u;
202  exeStructIn->hourTicks++;
203  }
204 
205  // module systick execution area
207  EXP_SYSTICK,
208  exeEntryPtrsIn->sysTickListHead
209  );
210 
211 }

◆ ModuleExceptionArea()

void ModuleExceptionArea ( struct linkedEntryPointStruct exeListHeadIn)

Definition at line 80 of file execution_system.c.

83 {
84  struct linkedEntryPointStruct* currentExeNode = exeListHeadIn;
85  int retVal;
86  if(currentExeNode!=nullptr)
87  {
88  if(currentExeNode->entryPoint != nullptr)
89  {
90  do
91  {
92  if(currentExeNode->dataPtr->exceptionFlags!=0u)
93  retVal = currentExeNode->entryPoint(
94  currentExeNode->dataPtr
95  );
96  else
97  retVal = RETURN_SUCCESS;
98 
99  if(retVal != RETURN_SUCCESS)
100  currentExeNode->dataPtr->exceptionFlags |= (0x00000001 << EXP_HANDLER);
101 
102  if(currentExeNode->nextPtr != nullptr)
103  currentExeNode = currentExeNode->nextPtr;
104  else
105  break;
106 
107  }while(currentExeNode->entryPoint != nullptr);
108  }
109  }
110 }

◆ ModuleExeArea()

void ModuleExeArea ( UI_32  ExcpIndex,
struct linkedEntryPointStruct exeListHeadIn 
)

Definition at line 47 of file execution_system.c.

51 {
52  struct linkedEntryPointStruct* currentExeNode = exeListHeadIn;
53  int retVal;
54  if(currentExeNode!=nullptr)
55  {
56  if(currentExeNode->entryPoint != nullptr)
57  {
58  do
59  {
60  if(currentExeNode->dataPtr->exceptionFlags==0u)
61  retVal = currentExeNode->entryPoint(
62  currentExeNode->dataPtr
63  );
64  else
65  retVal = RETURN_SUCCESS;
66 
67  if(retVal != RETURN_SUCCESS)
68  currentExeNode->dataPtr->exceptionFlags |= (0x00000001 << ExcpIndex);
69 
70  if(currentExeNode->nextPtr != nullptr)
71  currentExeNode = currentExeNode->nextPtr;
72  else
73  break;
74 
75  }while(currentExeNode->entryPoint != nullptr);
76  }
77  }
78 }
linkedEntryPointStruct::dataPtr
struct computeModuleStruct * dataPtr
Definition: execution_system.h:117
EXP_SETUP
#define EXP_SETUP
Definition: execution_system.h:43
executionSystemStruct::uSecPerSysTick
UI_32 uSecPerSysTick
Definition: execution_system.h:60
EXP_HANDLER
#define EXP_HANDLER
Definition: execution_system.h:47
executionEntryStruct::loopListHead
struct linkedEntryPointStruct * loopListHead
Definition: execution_system.h:126
ModuleExeArea
void ModuleExeArea(UI_32 ExcpIndex, struct linkedEntryPointStruct *exeListHeadIn)
Definition: execution_system.c:47
linkedEntryPointStruct::nextPtr
struct linkedEntryPointStruct * nextPtr
Definition: execution_system.h:116
executionSystemStruct
Definition: execution_system.h:57
executionEntryStruct::exceptionListHead
struct linkedEntryPointStruct * exceptionListHead
Definition: execution_system.h:128
platformStart
void platformStart()
Definition: Platform_Arduino.h:114
linkedEntryPointStruct::entryPoint
int(* entryPoint)(struct computeModuleStruct *dataPtrIn)
Definition: execution_system.h:118
EXP_LOOP
#define EXP_LOOP
Definition: execution_system.h:44
platformSetup
void platformSetup()
Definition: Platform_Arduino.h:66
platformLoopDelay
void platformLoopDelay()
Definition: Platform_Arduino.h:128
EXP_SYSTICK
#define EXP_SYSTICK
Definition: execution_system.h:45
ModuleExceptionArea
void ModuleExceptionArea(struct linkedEntryPointStruct *exeListHeadIn)
Definition: execution_system.c:80
executionSystemStruct::hourTicks
UI_32 hourTicks
Definition: execution_system.h:59
executionEntryStruct::setupListHead
struct linkedEntryPointStruct * setupListHead
Definition: execution_system.h:125
computeModuleStruct::exceptionFlags
UI_32 exceptionFlags
Definition: compute_module.h:34
linkedEntryPointStruct
Definition: execution_system.h:115
TIME_uS_PER_HR
#define TIME_uS_PER_HR
Definition: execution_system.h:35
RETURN_SUCCESS
#define RETURN_SUCCESS
Function Return Value for Success.
Definition: version_config.h:87
RETURN_ERROR
#define RETURN_ERROR
Function Return Value for ERROR.
Definition: version_config.h:92
executionSystemStruct::uSecTicks
UI_32 uSecTicks
Definition: execution_system.h:58
executionEntryStruct::sysTickListHead
struct linkedEntryPointStruct * sysTickListHead
Definition: execution_system.h:127