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

IMS: ccNOos, Declarations for straight C and C++ More...

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

Go to the source code of this file.

Data Structures

struct  executionSystemStruct
 
struct  linkedIODeviceStruct
 
struct  linkedEntryPointStruct
 
struct  executionEntryStruct
 

Macros

#define TIME_us_PER_MIN   (60000000u)
 
#define TIME_uS_PER_HR   (3600000000u)
 
#define TIME_uS_PER_SEC   (1000000u)
 
#define TIME_SEC_PER_MIN   (60u)
 
#define TIME_MIN_PER_HR   (60u)
 
#define EXP_SETUP   (0u)
 
#define EXP_LOOP   (1u)
 
#define EXP_SYSTICK   (2u)
 
#define EXP_PLATFORM   (3u)
 
#define EXP_HANDLER   (4u)
 
#define _DeclareExeSys   struct executionSystemStruct exeSystem;
 
#define _ExeSys_   exeSystem.
 
#define __ExeSysAPIFuncsTemplate
 
#define ExeSysAPIFuncsTemplate   __ExeSysAPIFuncsTemplate
 

Functions

void platformSetup ()
 
void platformStart ()
 
void platformLoopDelay ()
 
struct executionSystemStruct CreateExecutionSystemStruct (UI_32 uSperTick)
 
UI_32 getuSecTicks ()
 
UI_32 getHourTicks ()
 
UI_32 getuSecPerSysTick ()
 
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)
 
void applicationConfig ()
 

Detailed Description

IMS: ccNOos, Declarations for straight C and 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.h.

Macro Definition Documentation

◆ __ExeSysAPIFuncsTemplate

#define __ExeSysAPIFuncsTemplate
Value:
_DeclareExeSys \
UI_32 getuSecTicks()\
{\
return _ExeSys_ uSecTicks;\
}\
UI_32 getHourTicks()\
{\
return _ExeSys_ hourTicks;\
}\
{\
return _ExeSys_ uSecPerSysTick;\
}

Definition at line 83 of file execution_system.h.

◆ _DeclareExeSys

#define _DeclareExeSys   struct executionSystemStruct exeSystem;

Definition at line 79 of file execution_system.h.

◆ _ExeSys_

#define _ExeSys_   exeSystem.

Definition at line 80 of file execution_system.h.

◆ ExeSysAPIFuncsTemplate

#define ExeSysAPIFuncsTemplate   __ExeSysAPIFuncsTemplate

Definition at line 97 of file execution_system.h.

◆ EXP_HANDLER

#define EXP_HANDLER   (4u)

Definition at line 47 of file execution_system.h.

◆ EXP_LOOP

#define EXP_LOOP   (1u)

Definition at line 44 of file execution_system.h.

◆ EXP_PLATFORM

#define EXP_PLATFORM   (3u)

Definition at line 46 of file execution_system.h.

◆ EXP_SETUP

#define EXP_SETUP   (0u)

Definition at line 43 of file execution_system.h.

◆ EXP_SYSTICK

#define EXP_SYSTICK   (2u)

Definition at line 45 of file execution_system.h.

◆ TIME_MIN_PER_HR

#define TIME_MIN_PER_HR   (60u)

Definition at line 39 of file execution_system.h.

◆ TIME_SEC_PER_MIN

#define TIME_SEC_PER_MIN   (60u)

Definition at line 38 of file execution_system.h.

◆ TIME_uS_PER_HR

#define TIME_uS_PER_HR   (3600000000u)

Definition at line 35 of file execution_system.h.

◆ TIME_us_PER_MIN

#define TIME_us_PER_MIN   (60000000u)

Definition at line 34 of file execution_system.h.

◆ TIME_uS_PER_SEC

#define TIME_uS_PER_SEC   (1000000u)

Definition at line 36 of file execution_system.h.

Function Documentation

◆ applicationConfig()

void applicationConfig ( )

◆ 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 }

◆ getHourTicks()

UI_32 getHourTicks ( )

◆ getuSecPerSysTick()

UI_32 getuSecPerSysTick ( )

◆ getuSecTicks()

UI_32 getuSecTicks ( )

◆ 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 }

◆ platformLoopDelay()

void platformLoopDelay ( )

Definition at line 169 of file Platform_Arduino.h.

170 {
171 
172  ReadSerialUARTS();
173 
174 
175  //<platformLoopDelay>
176  ;
177  //</platformLoopDelay>
178 }

◆ platformSetup()

void platformSetup ( )

Definition at line 73 of file Platform_Arduino.h.

74 {
75  //<platformSetup>
76 #ifdef __USINGCONSOLEMENU
77 #ifdef __USINGFLOATPRINTF
78  asm(".global _printf_float");
79 #endif
80 #endif
87 
94 
96  GPSserialdev.baudRate = 9600;
101 
103  eCompserialdev.baudRate = 19200;
108 
109  Serial.begin(115200);
110  Serial1.begin(GPSserialdev.baudRate);
111  Serial2.begin(eCompserialdev.baudRate);
112  Serial3.begin(LCDKeyPadserialdev.baudRate);
113  Wire.begin();
114 
115  while (!Serial) {
116  ; // wait for serial port to connect. Needed for native USB port only
117  }
118  //</platformSetup>
119 }

◆ platformStart()

void platformStart ( )

Definition at line 121 of file Platform_Arduino.h.

122 {
123  //<platformStart>
132  IC1.begin(IC1Addr);
133  IC1.pinMode(0, OUTPUT);
134  IC1.pinMode(1, OUTPUT);
135  IC1.pinMode(2, OUTPUT);
136  IC1.pinMode(3, OUTPUT);
137  IC1.pinMode(4, OUTPUT);
138  IC1.pinMode(5, OUTPUT);
139  IC1.pinMode(6, OUTPUT);
140  IC1.pinMode(7, OUTPUT);
141  IC1.pinMode(8, OUTPUT);
142  IC1.pinMode(9, OUTPUT);
143  IC1.pinMode(10, OUTPUT);
144  IC1.pinMode(11, OUTPUT);
145  IC1.pinMode(12, OUTPUT);
146  IC1.pinMode(13, OUTPUT);
147  IC1.pinMode(14, OUTPUT);
148  IC1.pinMode(15, OUTPUT);
149  IC12.begin(IC12Addr);
150  IC12.pinMode(0, OUTPUT);
151  IC12.pinMode(1, OUTPUT);
152  IC12.pinMode(2, OUTPUT);
153  IC12.pinMode(3, OUTPUT);
154  IC12.pinMode(4, OUTPUT);
155  IC12.pinMode(5, OUTPUT);
156  IC12.pinMode(6, OUTPUT);
157  IC12.pinMode(7, OUTPUT);
158  IC12.pinMode(8, OUTPUT);
159  IC12.pinMode(9, OUTPUT);
160  IC12.pinMode(10, OUTPUT);
161  IC12.pinMode(11, OUTPUT);
162  IC12.pinMode(12, OUTPUT);
163  IC12.pinMode(13, OUTPUT);
164  IC12.pinMode(14, OUTPUT);
165  IC12.pinMode(15, OUTPUT);
166  //</platformStart>
167 }
executionSystemStruct::uSecTicks
UI_32 uSecTicks
Definition: execution_system.h:58
executionSystemStruct::uSecPerSysTick
UI_32 uSecPerSysTick
Definition: execution_system.h:60
parity_none
@ parity_none
Definition: io_device.h:101
executionEntryStruct::exceptionListHead
struct linkedEntryPointStruct * exceptionListHead
Definition: execution_system.h:128
getHourTicks
UI_32 getHourTicks()
platformLoopDelay
void platformLoopDelay()
Definition: Platform_Arduino.h:169
SerialDeviceStruct::parity
enum portParityEnum parity
Definition: io_device.h:120
IC12
Adafruit_MCP23017 IC12
Definition: Platform_Arduino.h:68
SerialDeviceStruct::readIndex
int readIndex
Definition: io_device.h:124
executionSystemStruct::hourTicks
UI_32 hourTicks
Definition: execution_system.h:59
EXP_SYSTICK
#define EXP_SYSTICK
Definition: execution_system.h:45
RETURN_ERROR
#define RETURN_ERROR
Function Return Value for ERROR.
Definition: version_config.h:92
EXP_LOOP
#define EXP_LOOP
Definition: execution_system.h:44
executionEntryStruct::loopListHead
struct linkedEntryPointStruct * loopListHead
Definition: execution_system.h:126
_ExeSys_
#define _ExeSys_
Definition: execution_system.h:80
linkedEntryPointStruct::dataPtr
struct computeModuleStruct * dataPtr
Definition: execution_system.h:117
executionEntryStruct::setupListHead
struct linkedEntryPointStruct * setupListHead
Definition: execution_system.h:125
ModuleExceptionArea
void ModuleExceptionArea(struct linkedEntryPointStruct *exeListHeadIn)
Definition: execution_system.c:80
SerialDeviceStruct::numBytes2Read
int numBytes2Read
Definition: io_device.h:123
ReadSerialUARTS
void ReadSerialUARTS()
Definition: Platform_Arduino.h:57
ModuleExeArea
void ModuleExeArea(UI_32 ExcpIndex, struct linkedEntryPointStruct *exeListHeadIn)
Definition: execution_system.c:47
linkedEntryPointStruct::nextPtr
struct linkedEntryPointStruct * nextPtr
Definition: execution_system.h:116
computeModuleStruct::exceptionFlags
UI_32 exceptionFlags
Definition: compute_module.h:34
LCDKeyPadserialdev
struct SerialDeviceStruct LCDKeyPadserialdev
Definition: Platform_Arduino.h:49
platformSetup
void platformSetup()
Definition: Platform_Arduino.h:73
IC1
Adafruit_MCP23017 IC1
Definition: Platform_Arduino.h:67
RETURN_SUCCESS
#define RETURN_SUCCESS
Function Return Value for Success.
Definition: version_config.h:87
createDeviceStruct
struct devicedatastruct createDeviceStruct()
Definition: io_device.c:31
linkedEntryPointStruct
Definition: execution_system.h:115
IC12Addr
#define IC12Addr
Definition: Platform_Arduino.h:66
SerialDeviceStruct::stopBits
enum portStopBitsEnum stopBits
Definition: io_device.h:119
EXP_HANDLER
#define EXP_HANDLER
Definition: execution_system.h:47
executionEntryStruct::sysTickListHead
struct linkedEntryPointStruct * sysTickListHead
Definition: execution_system.h:127
executionSystemStruct
Definition: execution_system.h:57
linkedEntryPointStruct::entryPoint
int(* entryPoint)(struct computeModuleStruct *dataPtrIn)
Definition: execution_system.h:118
TIME_uS_PER_HR
#define TIME_uS_PER_HR
Definition: execution_system.h:35
GPSserialdev
struct SerialDeviceStruct GPSserialdev
Definition: Platform_Arduino.h:47
ConsoleMenuserialdev
struct SerialDeviceStruct ConsoleMenuserialdev
Definition: Platform_Arduino.h:50
SerialDeviceStruct::handshake
enum portHandshakeEnum handshake
Definition: io_device.h:121
IC1Addr
#define IC1Addr
Definition: Platform_Arduino.h:65
getuSecPerSysTick
UI_32 getuSecPerSysTick()
getuSecTicks
UI_32 getuSecTicks()
SerialDeviceStruct::devdata
struct devicedatastruct devdata
Definition: io_device.h:122
SerialDeviceStruct::baudRate
int baudRate
Definition: io_device.h:117
eCompserialdev
struct SerialDeviceStruct eCompserialdev
Definition: Platform_Arduino.h:48
EXP_SETUP
#define EXP_SETUP
Definition: execution_system.h:43
handshake_none
@ handshake_none
Definition: io_device.h:109
SerialDeviceStruct::dataBits
int dataBits
Definition: io_device.h:118
platformStart
void platformStart()
Definition: Platform_Arduino.h:121
stop_one
@ stop_one
Definition: io_device.h:95