2020-2021 Sunseeker Telemetry and Lighting System
oa.c
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // oa.c - Driver for the oa Module.
4 //
5 //*****************************************************************************
6 
7 //*****************************************************************************
8 //
11 //
12 //*****************************************************************************
13 
14 #include "inc/hw_memmap.h"
15 
16 #ifdef __MSP430_HAS_OA_0__
17 #include "oa.h"
18 
19 #include <assert.h>
20 
21 void OA_openSwitch( uint16_t baseAddress,
22  uint8_t positiveInputMask,
23  uint8_t negativeInputMask,
24  uint8_t groundMask
25  )
26 {
27  HWREG16(baseAddress + OFS_OA0PSW) &= ~positiveInputMask;
28  HWREG16(baseAddress + OFS_OA0NSW) &= ~negativeInputMask;
29  HWREG16(baseAddress + OFS_OA0GSW) &= ~groundMask;
30 }
31 
32 void OA_closeSwitch(uint16_t baseAddress,
33  uint8_t positiveInputMask,
34  uint8_t negativeInputMask,
35  uint8_t groundMask
36  )
37 {
38 
39  HWREG16(baseAddress + OFS_OA0PSW) |= positiveInputMask;
40  HWREG16(baseAddress + OFS_OA0NSW) |= negativeInputMask;
41  HWREG16(baseAddress + OFS_OA0GSW) |= groundMask;
42 }
43 
44 uint8_t OA_getSwitchStatus(uint16_t baseAddress,
45  uint8_t inputTerminal
46  )
47 {
48  uint8_t returnValue = 0;
49 
50  switch(inputTerminal)
51  {
52  case OA_POSITIVE_INPUT_TERMINAL_SWITCHES:
53  returnValue = (HWREG16(baseAddress + OFS_OA0PSW) & (PSW3 |
54  PSW2 |
55  PSW1 |
56  PSW0)
57  );
58  break;
59  case OA_NEGATIVE_INPUT_TERMINAL_SWITCHES:
60  returnValue = (HWREG16(baseAddress + OFS_OA0NSW) & (NSW4 |
61  NSW3 |
62  NSW2 |
63  NSW1 |
64  NSW0)
65  );
66  break;
67  case OA_GROUND_SWITCHES:
68  returnValue = (HWREG16(baseAddress + OFS_OA0GSW) & (GSW1 |
69  GSW0)
70  );
71  break;
72  }
73 
74  return returnValue;
75 
76 }
77 
78 uint8_t OA_getRailToRailInputReadyStatus(uint16_t baseAddress)
79 {
80  return ((HWREG8(baseAddress + OFS_OA0CTL0) & OARRIRDY));
81 }
82 
83 uint8_t OA_getRailToRailInputStatus(uint16_t baseAddress)
84 {
85  return ((HWREG8(baseAddress + OFS_OA0CTL0) & OARRI));
86 }
87 
88 void OA_enableRailToRailInput(uint16_t baseAddress)
89 {
90  HWREG8(baseAddress + OFS_OA0CTL0) |= OARRI;
91 }
92 
93 void OA_disableRailToRailInput(uint16_t baseAddress)
94 {
95  HWREG8(baseAddress + OFS_OA0CTL0) &= ~OARRI;
96 }
97 
98 void OA_disableAmplifierMode(uint16_t baseAddress)
99 {
100  HWREG8(baseAddress + OFS_OA0CTL0) &= ~OAM;
101 }
102 
103 void OA_enableAmplifierMode(uint16_t baseAddress)
104 {
105  HWREG8(baseAddress + OFS_OA0CTL0) |= OAM;
106 }
107 
108 uint8_t OA_getAmplifierModeStatus(uint16_t baseAddress)
109 {
110  return ((HWREG8(baseAddress + OFS_OA0CTL0) & OAM));
111 }
112 
113 #endif
114 //*****************************************************************************
115 //
118 //
119 //*****************************************************************************
#define HWREG8(x)
Definition: hw_memmap.h:41
#define HWREG16(x)
Definition: hw_memmap.h:39
uint8_t returnValue