ccNOos  v0.0.0
Build Portable Microcontroller Applications!
APTmodule.c
Go to the documentation of this file.
1 /** \file APTmodule.c
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  Implementation for straight C
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 #include "APTmodule.h"
28 
29 
30 
32 {
33  struct gpsStruct outStruct;
34  outStruct.devptr = nullptr;
35  outStruct.data = createGPSDataStruct();
36  outStruct.Connected = ui8FALSE;
37  outStruct.newGPSData = ui8FALSE;
38  return outStruct;
39 }
41 {
42  struct eCompStruct outStruct;
43  outStruct.devptr = nullptr;
44  outStruct.Connected = ui8FALSE;
45  outStruct.neweCompassData = ui8FALSE;
46  outStruct.data = createEcompDataStruct();
47  return outStruct;
48 }
50 {
51  struct aptStruct outStruct;
52  outStruct.eCompass = createeCompStruct();
53  outStruct.GPS = creategpsStruct();
54  return outStruct;
55 }
57 {
58  struct wmmStruct outStruct;
59  outStruct.magdeclination = 0;
60  outStruct.lastGoodThreshold = 0;
61  outStruct.lastGoodMultiplier = 0;
62  outStruct.lastGoodmagdeclination = 0;
63  outStruct.lastGoodlongitude = 0;
64  outStruct.lastGoodlatitude = 0;
65  outStruct.lastGoodaltitude = 0;
66  return outStruct;
67 }
68 
69 void tryReadAPTData(struct aptStruct* aptStructPtrIn)
70 {
71  // try read gps, if got string(s)
72  if (readGPS(&aptStructPtrIn->GPS))
73  {
74  // try parse strings
75  if (tryParseGPSData(&aptStructPtrIn->GPS.devptr->devdata.inbuff.charbuff[0], &aptStructPtrIn->GPS.data))
76  {
77  aptStructPtrIn->GPS.newGPSData = ui8TRUE; // this signals to state machine that new gps data is available from gps device
78  }
79  aptStructPtrIn->GPS.devptr->devdata.newDataReadIn = ui8FALSE;
80  }
81  // try read eCompass, if got string(s)
82  if (readEcompass(&aptStructPtrIn->eCompass))
83  {
84  // try parse strings
85  if (tryParseEcompData(&aptStructPtrIn->eCompass.devptr->devdata.inbuff.charbuff[0], &aptStructPtrIn->eCompass.data))
86  {
87  aptStructPtrIn->eCompass.neweCompassData = ui8TRUE; // this signals to state machine that new gps data is available from gps device
88  }
89  aptStructPtrIn->eCompass.devptr->devdata.newDataReadIn = ui8FALSE;
90  }
91 }
92 
creategpsStruct
struct gpsStruct creategpsStruct()
Definition: APTmodule.c:31
tryParseEcompData
UI_8 tryParseEcompData(char *eCompStringin, struct eCompDataStruct *eCompDataPtr)
Definition: HMR3300.c:43
tryParseGPSData
UI_8 tryParseGPSData(char *gpsStringin, struct gpsData *gpsDataPtr)
Definition: NEO_LEA_M8T.c:227
gpsStruct::Connected
UI_8 Connected
Definition: APTmodule.h:41
eCompStruct::neweCompassData
UI_8 neweCompassData
Definition: APTmodule.h:50
wmmStruct::magdeclination
float magdeclination
Definition: APTmodule.h:67
gpsStruct::devptr
struct SerialDeviceStruct * devptr
Definition: APTmodule.h:38
readEcompass
UI_8 readEcompass(struct eCompStruct *eCompStructPtrIn)
Definition: Application_Platform_Main.c:74
devicedatastruct::inbuff
union devicebufferunion inbuff
Definition: io_device.h:63
ui8FALSE
#define ui8FALSE
Definition: version_config.h:190
devicebufferunion::charbuff
char charbuff[charBuffMax]
Definition: io_device.h:55
wmmStruct
Definition: APTmodule.h:66
createEcompDataStruct
struct eCompDataStruct createEcompDataStruct()
Definition: HMR3300.c:29
readGPS
UI_8 readGPS(struct gpsStruct *gpsStructPtrIn)
Definition: Application_Platform_Main.c:73
eCompStruct::data
struct eCompDataStruct data
Definition: APTmodule.h:49
ui8TRUE
#define ui8TRUE
Definition: version_config.h:191
aptStruct::GPS
struct gpsStruct GPS
Definition: APTmodule.h:58
gpsStruct::data
struct gpsData data
Definition: APTmodule.h:39
createGPSDataStruct
struct gpsData createGPSDataStruct()
Definition: NEO_LEA_M8T.c:29
aptStruct
Definition: APTmodule.h:57
tryReadAPTData
void tryReadAPTData(struct aptStruct *aptStructPtrIn)
Definition: APTmodule.c:69
eCompStruct::devptr
struct SerialDeviceStruct * devptr
Definition: APTmodule.h:48
createaptStruct
struct aptStruct createaptStruct()
Definition: APTmodule.c:49
gpsStruct
Definition: APTmodule.h:37
APTmodule.h
IMS: ccNOos, Declarations for straight C and C++
eCompStruct
Definition: APTmodule.h:47
gpsStruct::newGPSData
UI_8 newGPSData
Definition: APTmodule.h:40
createeCompStruct
struct eCompStruct createeCompStruct()
Definition: APTmodule.c:40
devicedatastruct::newDataReadIn
UI_8 newDataReadIn
Definition: io_device.h:66
createwmmStruct
struct wmmStruct createwmmStruct()
Definition: APTmodule.c:56
SerialDeviceStruct::devdata
struct devicedatastruct devdata
Definition: io_device.h:122
aptStruct::eCompass
struct eCompStruct eCompass
Definition: APTmodule.h:59