ccNOos  v0.0.0
Build Portable Microcontroller Applications!
Platform_Arduino.h
Go to the documentation of this file.
1 /** \file Platform_Arduino.h
2 * \brief <a href="https://www.inmechasol.org/" target="_blank">IMS</a>:
3  <a href="https://github.com/InMechaSol/ccNOos" target="_blank">ccNOos</a>,
4  Platform Specification, Arduino
5 
6  Copyright 2021 <a href="https://www.inmechasol.org/" target="_blank">InMechaSol, Inc</a>
7 
8  Licensed under the Apache License, Version 2.0(the "License");
9  you may not use this file except in compliance with the License.
10  You may obtain a copy of the License at
11 
12  http://www.apache.org/licenses/LICENSE-2.0
13 
14  Unless required by applicable law or agreed to in writing, software
15  distributed under the License is distributed on an "AS IS" BASIS,
16  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  See the License for the specific language governing permissions and
18  limitations under the License.
19 
20 Notes:
21  (.c includes .h) - for straight C or
22  (.cpp includes .c which includes .h) - for C++ wrapped straight C
23  *Always compiled to a single compilation unit, either C or CPP, not both
24 
25 */
26 
27 #if PLATFORM_NAME!=Arduino
28 error PLATFORM_NAME must be Arduino
29 #endif
30 
31 
32 #ifdef REDEFINE_NULLPTR
33 #error Must not compile with -DREDEFINE_NULLPTR on Aduino ATMega (maybe others, need to test)
34 #endif // !REDEFINE_NULLPTR
35 #ifndef __NOEXCEPTIONS
36 #error Must compile with -D__NOEXCEPTIONS on Aduino ATMega (maybe others, need to test)
37 #endif // !__NOEXCEPTIONS
38 
39 
40 #include <Arduino.h>
41 #include <Adafruit_MCP23017.h>
42 #include "execution_system.h"
43 #include "console_menu.h"
44 #define LIGHT_OFF (0u) // 1-PSoC4, 0-most others
45 #define uSEC_PER_CLOCK (1000u)
46 
51 
52 int gpsCharInt = -1;
53 int eCompCharInt = -1;
54 int consoleCharInt = -1;
55 int lcdCharInt = -1;
56 int idx = 0;
58 {
59  consoleCharInt = Serial.read();
60  gpsCharInt = Serial1.read();
61  eCompCharInt = Serial2.read();
62 }
63 
64 // 0) (Optional) Platform Config and Log Files/Devices
65 // 1) Platform Setup Function
67 {
68  //<platformSetup>
69 #ifdef __USINGCONSOLEMENU
70 #ifdef __USINGFLOATPRINTF
71  asm(".global _printf_float");
72 #endif
73 #endif
80 
87 
89  GPSserialdev.baudRate = 9600;
94 
96  eCompserialdev.baudRate = 19200;
101 
102  Serial.begin(115200);
103  Serial1.begin(GPSserialdev.baudRate);
104  Serial2.begin(eCompserialdev.baudRate);
105  Serial3.begin(LCDKeyPadserialdev.baudRate);
106  Wire.begin();
107 
108  while (!Serial) {
109  ; // wait for serial port to connect. Needed for native USB port only
110  }
111  //</platformSetup>
112 }
113 // 2) Platform Start Function
115 {
116  //<platformStart>
125  //</platformStart>
126 }
127 // 3) Platform Loop Delay Function
129 {
130 
131  ReadSerialUARTS();
132 
133 
134  //<platformLoopDelay>
135  ;
136  //</platformLoopDelay>
137 }
138 
139 #ifdef __USINGCONSOLEMENU
140 
141 // 8) Platform API Functions (From Template?)
142 PlatformAPIFuncsTemplate(size + 1);
143 
144 #endif
145 // 9) Global Execution System Instance
146 //executionSystemClass PLATFORM_EXESYS_NAME(PLATFORM_NAME)(uSEC_PER_CLOCK);
147 // 10) ExeSys API Functions (From Template?)
console_menu.h
IMS: ccNOos, Declarations for straight C and C++
SerialDeviceStruct::baudRate
int baudRate
Definition: io_device.h:117
consoleCharInt
int consoleCharInt
Definition: Platform_Arduino.h:54
ReadSerialUARTS
void ReadSerialUARTS()
Definition: Platform_Arduino.h:57
handshake_none
@ handshake_none
Definition: io_device.h:109
eCompCharInt
int eCompCharInt
Definition: Platform_Arduino.h:53
LCDKeyPadserialdev
struct SerialDeviceStruct LCDKeyPadserialdev
Definition: Platform_Arduino.h:49
SerialDeviceStruct::dataBits
int dataBits
Definition: io_device.h:118
SerialDeviceStruct::parity
enum portParityEnum parity
Definition: io_device.h:120
GPSserialdev
struct SerialDeviceStruct GPSserialdev
Definition: Platform_Arduino.h:47
ConsoleMenuserialdev
struct SerialDeviceStruct ConsoleMenuserialdev
Definition: Platform_Arduino.h:50
gpsCharInt
int gpsCharInt
Definition: Platform_Arduino.h:52
SerialDeviceStruct::numBytes2Read
int numBytes2Read
Definition: io_device.h:123
ExeSysAPIFuncsTemplate
#define ExeSysAPIFuncsTemplate
Definition: execution_system.h:97
execution_system.h
IMS: ccNOos, Declarations for straight C and C++
eCompserialdev
struct SerialDeviceStruct eCompserialdev
Definition: Platform_Arduino.h:48
SerialDeviceStruct::stopBits
enum portStopBitsEnum stopBits
Definition: io_device.h:119
platformLoopDelay
void platformLoopDelay()
Definition: Platform_Arduino.h:128
SerialDeviceStruct
Definition: io_device.h:116
parity_none
@ parity_none
Definition: io_device.h:101
platformStart
void platformStart()
Definition: Platform_Arduino.h:114
SerialDeviceStruct::handshake
enum portHandshakeEnum handshake
Definition: io_device.h:121
lcdCharInt
int lcdCharInt
Definition: Platform_Arduino.h:55
platformSetup
void platformSetup()
Definition: Platform_Arduino.h:66
stop_one
@ stop_one
Definition: io_device.h:95
idx
int idx
Definition: Platform_Arduino.h:56
createDeviceStruct
struct devicedatastruct createDeviceStruct()
Definition: io_device.c:31
SerialDeviceStruct::devdata
struct devicedatastruct devdata
Definition: io_device.h:122
SerialDeviceStruct::readIndex
int readIndex
Definition: io_device.h:124