2020-2021 Sunseeker Telemetry and Lighting System
ref.c
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // ref.c - Driver for the ref Module.
4 //
5 //*****************************************************************************
6 
7 //*****************************************************************************
8 //
11 //
12 //*****************************************************************************
13 
14 #include "inc/hw_memmap.h"
15 
16 #ifdef __MSP430_HAS_REF__
17 #include "ref.h"
18 
19 #include <assert.h>
20 
21 void Ref_setReferenceVoltage (uint16_t baseAddress,
22  uint8_t referenceVoltageSelect)
23 {
24  HWREG8(baseAddress + OFS_REFCTL0_L) &= ~(REFVSEL_3);
25  HWREG8(baseAddress + OFS_REFCTL0_L) |= referenceVoltageSelect;
26 }
27 
28 void Ref_disableTempSensor (uint16_t baseAddress)
29 {
30  HWREG8(baseAddress + OFS_REFCTL0_L) |= REFTCOFF;
31 }
32 
33 void Ref_enableTempSensor (uint16_t baseAddress)
34 {
35  HWREG8(baseAddress + OFS_REFCTL0_L) &= ~(REFTCOFF);
36 }
37 
38 void Ref_enableReferenceVoltageOutput (uint16_t baseAddress)
39 {
40  HWREG8(baseAddress + OFS_REFCTL0_L) |= REFOUT;
41 }
42 
43 void Ref_disableReferenceVoltageOutput (uint16_t baseAddress)
44 {
45  HWREG8(baseAddress + OFS_REFCTL0_L) &= ~(REFOUT);
46 }
47 
48 void Ref_enableReferenceVoltage (uint16_t baseAddress)
49 {
50  HWREG8(baseAddress + OFS_REFCTL0_L) |= REFON;
51 }
52 
53 void Ref_disableReferenceVoltage (uint16_t baseAddress)
54 {
55  HWREG8(baseAddress + OFS_REFCTL0_L) &= ~(REFON);
56 }
57 
58 uint16_t Ref_getBandgapMode (uint16_t baseAddress)
59 {
60  return (HWREG16((baseAddress) + OFS_REFCTL0) & BGMODE);
61 }
62 
63 bool Ref_isBandgapActive (uint16_t baseAddress)
64 {
65  if (HWREG16((baseAddress) + OFS_REFCTL0) & REFBGACT){
66  return (REF_ACTIVE) ;
67  } else {
68  return (REF_INACTIVE) ;
69  }
70 }
71 
72 uint16_t Ref_isRefGenBusy (uint16_t baseAddress)
73 {
74  return (HWREG16((baseAddress) + OFS_REFCTL0) & REFGENBUSY);
75 }
76 
77 bool Ref_isRefGenActive (uint16_t baseAddress)
78 {
79  if (HWREG16((baseAddress) + OFS_REFCTL0) & REFGENACT){
80  return (REF_ACTIVE) ;
81  } else {
82  return (REF_INACTIVE) ;
83  }
84 }
85 
86 
87 #endif
88 //*****************************************************************************
89 //
92 //
93 //*****************************************************************************
#define HWREG8(x)
Definition: hw_memmap.h:41
#define HWREG16(x)
Definition: hw_memmap.h:39