ccNOos  v0.0.0
Build Portable Microcontroller Applications!
Platform_Win32.h
Go to the documentation of this file.
1 /** \file Platform_Win32.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, Win32
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!=Win32
28 error PLATFORM_NAME must be Win32
29 #endif
30 
31 
32 #ifdef REDEFINE_NULLPTR
33 #error Must not compile with -DREDEFINE_NULLPTR on WIN32
34 #endif // !REDEFINE_NULLPTR
35 #ifdef __NOEXCEPTIONS
36 #error Must not compile with -D__NOEXCEPTIONS on WIN32
37 #endif // !__NOEXCEPTIONS
38 
39 
40 #include <ctime>
41 #include <thread>
42 #include <cstdarg>
43 #include <cstdio>
44 #include <iostream>
45 #include <fstream>
46 
47 #include "execution_system.h"
48 #include "console_menu.h"
49 
50 #define LIGHT_OFF (0u) // 1-PSoC4, 0-most others
51 #define uSEC_PER_CLOCK (1000000/CLOCKS_PER_SEC)
52 
53 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
54 // Win32 is a special platfrom, it's a ccNOos test platform but, can link-in os features at the main file
55 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
56 #include "serial_comms.h"
57 #include "adafruit_ft232h.h"
58 
59 struct portParametersStruct GPSPortParams;
60 struct portParametersStruct eCompPortParams;
61 nbserial_class GPS_NBSerial(&GPSPortParams);
62 nbserial_class eComp_NBSerial(&eCompPortParams);
63 
66 
67 // 0) (Optional) Platform Config and Log Files/Devices
68 std::ifstream configFile;
69 std::ofstream LogFile;
70 // 1) Platform Setup Function
72 {
73 
74 #ifdef _WIN32
75  GPSPortParams = buildportParametersStruct("\\\\.\\COM31", 9600);
76  eCompPortParams = buildportParametersStruct("\\\\.\\COM30", 19200);
77 #else
78  GPSPortParams = buildportParametersStruct("/dev/tty1", 9600);
79  eCompPortParams = buildportParametersStruct("/dev/tty2", 19200);
80 #endif
81 
82  openComPort(&GPSPortParams);
83  openComPort(&eCompPortParams);
84 
87 
88  //<platformSetup>
89  //
90  // open config device
91  configFile.open("conFile.json");
92  LogFile.open("logFile.json");
93  // read config string??
94  //
95  // open log device
96  // wrtie log string??
97  //
98  //</platformSetup>
99 }
100 // 2) Platform Start Function
102 {
103  //<platformStart>
104  //</platformStart>
105 }
106 // 3) Platform Loop Delay Function
108 {
109  //<platformLoopDelay>
110  std::this_thread::sleep_for(std::chrono::milliseconds(1));
111  //</platformLoopDelay>
112 }
113 #ifdef __USINGCONSOLEMENU
114 
115 // 8) Platform API Functions (From Template?)
116 PlatformAPIFuncsTemplate(size + 1);
117 #endif
118 // 9) Global Execution System Instance
119 //executionSystemClass PLATFORM_EXESYS_NAME(Plat)(uSEC_PER_CLOCK);
120 // 10) ExeSys API Functions (From Template?)
platformSetup
void platformSetup()
Definition: Platform_Win32.h:71
console_menu.h
IMS: ccNOos, Declarations for straight C and C++
GPSPortParams
struct portParametersStruct GPSPortParams
Definition: Platform_Win32.h:59
LogFile
std::ofstream LogFile
Definition: Platform_Win32.h:69
eCompPortParams
struct portParametersStruct eCompPortParams
Definition: Platform_Win32.h:60
ExeSysAPIFuncsTemplate
#define ExeSysAPIFuncsTemplate
Definition: execution_system.h:97
execution_system.h
IMS: ccNOos, Declarations for straight C and C++
configFile
std::ifstream configFile
Definition: Platform_Win32.h:68
ConsoleMenuDevDataStruct
struct devicedatastruct ConsoleMenuDevDataStruct
Definition: Platform_Win32.h:65
platformStart
void platformStart()
Definition: Platform_Win32.h:101
platformLoopDelay
void platformLoopDelay()
Definition: Platform_Win32.h:107
LCDKeyPadDevDataStruct
struct devicedatastruct LCDKeyPadDevDataStruct
Definition: Platform_Win32.h:64
createDeviceStruct
struct devicedatastruct createDeviceStruct()
Definition: io_device.c:31
devicedatastruct
the common data struct of io devices
Definition: io_device.h:62