ccNOos  v0.0.0
Build Portable Microcontroller Applications!
TxRxmodule.h
Go to the documentation of this file.
1 /** \file TxRxmodule.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  Declarations for straight C and 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 #ifndef __TXRX_MOD_H__
28 #define __TXRX_MOD_H__
29 
30 #include "console_menu.h"
31 #include "HMC1119.h"
32 #include "MCP23017.h"
33 
34 // Tx/Rx Module Data Structure
35 #define MAX_NUM_ATTENUATORS (3u)
36 #define MAX_MDMS (4u)
37 #define SWITCH_OPEN (0u)
38 
39 struct txRxStruct
40 {
45 
46 };
48 void writeAttenuatorValues(struct txRxStruct* txRxStructPtrIn);
49 void writeModemSwitchValues(struct txRxStruct* txRxStructPtrIn);
50 
51 #ifdef __USINGCONSOLEMENU
52 
53 void parseTxRxMenuAPI(struct txRxStruct* txRxStructPtrIn, struct uiStruct* uiStructPtrIn);
54 void writeTxRxMenuScreen(struct txRxStruct* txRxStructPtrIn, struct uiStruct* uiStructPtrIn);
55 void writeTxRxLogLine(struct txRxStruct* txRxStructPtrIn, struct logStruct* logStructPtrIn);
56 void parseTxRxConfigLine(struct txRxStruct* txRxStructPtrIn, struct configStruct* configStructPtrIn);
57 
58 #endif
59 
60 #define __SatComACS_TxRx_WriteFuncsTemplate(DELAYFUNC) \
61 float ModuloFloat(float floatValue, float* intPartPtr) \
62 { \
63  double intPart, fracPart; \
64  fracPart = modf(floatValue, &intPart); \
65  *intPartPtr = (float)intPart; \
66  return (float)fracPart; \
67 } \
68 void writeAttenuatorValues(struct txRxStruct* txRxStructPtrIn) \
69 { \
70  for (int i = 0; i < MAX_NUM_ATTENUATORS; i++) { \
71  if (txRxStructPtrIn->AttenuatorNeedsWriting[i]) { \
72  txRxStructPtrIn->AttenuatorNeedsWriting[i] = ui8FALSE; \
73  limitDATcmd(&txRxStructPtrIn->AttenuatorValues[i]); \
74  CalcAttenuationBits(&txRxStructPtrIn->AttenuatorValues[i]); \
75  switch (i) { \
76  case 0: \
77  SETPIN_TX_C16(datcmdbit16(txRxStructPtrIn->AttenuatorValues[i].attenSetting)); \
78  SETPIN_TX_C8(datcmdbit8(txRxStructPtrIn->AttenuatorValues[i].attenSetting)); \
79  SETPIN_TX_C4(datcmdbit4(txRxStructPtrIn->AttenuatorValues[i].attenSetting)); \
80  SETPIN_TX_C2(datcmdbit2(txRxStructPtrIn->AttenuatorValues[i].attenSetting)); \
81  SETPIN_TX_C1(datcmdbit1(txRxStructPtrIn->AttenuatorValues[i].attenSetting)); \
82  SETPIN_TX_C0_25(datcmdbit0_25(txRxStructPtrIn->AttenuatorValues[i].attenSetting)); \
83  SETPIN_TX_C0_50(datcmdbit0_50(txRxStructPtrIn->AttenuatorValues[i].attenSetting)); \
84  SETPIN_TX_LE(0x01); \
85  DELAYFUNC; \
86  SETPIN_TX_LE(0x00); \
87  break; \
88  case 1: \
89  SETPIN_RX_C16(datcmdbit16(txRxStructPtrIn->AttenuatorValues[i].attenSetting)); \
90  SETPIN_RX_C8(datcmdbit8(txRxStructPtrIn->AttenuatorValues[i].attenSetting)); \
91  SETPIN_RX_C4(datcmdbit4(txRxStructPtrIn->AttenuatorValues[i].attenSetting)); \
92  SETPIN_RX_C2(datcmdbit2(txRxStructPtrIn->AttenuatorValues[i].attenSetting)); \
93  SETPIN_RX_C1(datcmdbit1(txRxStructPtrIn->AttenuatorValues[i].attenSetting)); \
94  SETPIN_RX_C0_25(datcmdbit0_25(txRxStructPtrIn->AttenuatorValues[i].attenSetting)); \
95  SETPIN_RX_C0_50(datcmdbit0_50(txRxStructPtrIn->AttenuatorValues[i].attenSetting)); \
96  SETPIN_RX_LE(0x01); \
97  DELAYFUNC; \
98  SETPIN_RX_LE(0x00); \
99  break; \
100  case 2: \
101  SETPIN_XX_C16(datcmdbit16(txRxStructPtrIn->AttenuatorValues[i].attenSetting)); \
102  SETPIN_XX_C8(datcmdbit8(txRxStructPtrIn->AttenuatorValues[i].attenSetting)); \
103  SETPIN_XX_C4(datcmdbit4(txRxStructPtrIn->AttenuatorValues[i].attenSetting)); \
104  SETPIN_XX_C2(datcmdbit2(txRxStructPtrIn->AttenuatorValues[i].attenSetting)); \
105  SETPIN_XX_C1(datcmdbit1(txRxStructPtrIn->AttenuatorValues[i].attenSetting)); \
106  SETPIN_XX_C0_25(datcmdbit0_25(txRxStructPtrIn->AttenuatorValues[i].attenSetting)); \
107  SETPIN_XX_C0_50(datcmdbit0_50(txRxStructPtrIn->AttenuatorValues[i].attenSetting)); \
108  SETPIN_XX_LE(0x01); \
109  DELAYFUNC; \
110  SETPIN_XX_LE(0x00); \
111  break; \
112  default: \
113  break; \
114  } \
115  } \
116  } \
117 } \
118 void writeModemSwitchValues(struct txRxStruct* txRxStructPtrIn) \
119  { \
120  for (int i = 0; i < MAX_MDMS; i++) { \
121  if (txRxStructPtrIn->MDMSwitchNeedsWriting[i]) { \
122  txRxStructPtrIn->MDMSwitchNeedsWriting[i] = ui8FALSE; \
123  switch (i) { \
124  case 0: \
125  SETPIN_MDM1_SW(txRxStructPtrIn->MDMSwitchStates[i]); \
126  break; \
127  case 1: \
128  SETPIN_MDM2_SW(txRxStructPtrIn->MDMSwitchStates[i]); \
129  break; \
130  case 2: \
131  SETPIN_MDM3_SW(txRxStructPtrIn->MDMSwitchStates[i]); \
132  break; \
133  case 3: \
134  SETPIN_MDM4_SW(txRxStructPtrIn->MDMSwitchStates[i]); \
135  break; \
136  default: \
137  break; \
138  } \
139  } \
140  } \
141  }
142 #define SatComACS_TxRx_WriteFuncsTemplate(DELAYFUNC) __SatComACS_TxRx_WriteFuncsTemplate(DELAYFUNC)
143 
144 #ifdef __cplusplus
145 
146 
147 #endif // !__cplusplus
148 #endif // !__TXRX_MOD_H__
txRxStruct::AttenuatorValues
struct DATStruct AttenuatorValues[MAX_NUM_ATTENUATORS]
Definition: TxRxmodule.h:41
parseTxRxConfigLine
void parseTxRxConfigLine(struct txRxStruct *txRxStructPtrIn, struct configStruct *configStructPtrIn)
Definition: PlatformApp_Serialization.c:37
txRxStruct::MDMSwitchNeedsWriting
UI_8 MDMSwitchNeedsWriting[MAX_MDMS]
Definition: TxRxmodule.h:44
HMC1119.h
IMS: ccNOos, Declarations for straight C and C++
txRxStruct::MDMSwitchStates
UI_8 MDMSwitchStates[MAX_MDMS]
Definition: TxRxmodule.h:43
writeAttenuatorValues
void writeAttenuatorValues(struct txRxStruct *txRxStructPtrIn)
Definition: Application_Platform_Main.c:72
MAX_MDMS
#define MAX_MDMS
Definition: TxRxmodule.h:36
DATStruct
Definition: HMC1119.h:36
txRxStruct
Definition: TxRxmodule.h:40
MCP23017.h
IMS: ccNOos, Declarations for straight C and C++
writeTxRxLogLine
void writeTxRxLogLine(struct txRxStruct *txRxStructPtrIn, struct logStruct *logStructPtrIn)
Definition: PlatformApp_Serialization.c:36
createtxRxStruct
struct txRxStruct createtxRxStruct()
Definition: TxRxmodule.c:29
writeTxRxMenuScreen
void writeTxRxMenuScreen(struct txRxStruct *txRxStructPtrIn, struct uiStruct *uiStructPtrIn)
Definition: MenuAPI.c:467
txRxStruct::AttenuatorNeedsWriting
UI_8 AttenuatorNeedsWriting[MAX_NUM_ATTENUATORS]
Definition: TxRxmodule.h:42
parseTxRxMenuAPI
void parseTxRxMenuAPI(struct txRxStruct *txRxStructPtrIn, struct uiStruct *uiStructPtrIn)
Definition: MenuAPI.c:387
MAX_NUM_ATTENUATORS
#define MAX_NUM_ATTENUATORS
Definition: TxRxmodule.h:35
writeModemSwitchValues
void writeModemSwitchValues(struct txRxStruct *txRxStructPtrIn)
console_menu.h
IMS: ccNOos, Declarations for straight C and C++