2020-2021 Sunseeker Telemetry and Lighting System
battbak.c
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // battbak.c - Driver for the battbak Module.
4 //
5 //*****************************************************************************
6 
7 //*****************************************************************************
8 //
11 //
12 //*****************************************************************************
13 
14 #include "inc/hw_memmap.h"
15 
16 #ifdef __MSP430_HAS_BATTERY_CHARGER__
17 #include "battbak.h"
18 
19 #include <assert.h>
20 
21 uint16_t BattBak_unlockBackupSubSystem (uint16_t baseAddress)
22 {
23  HWREG8(baseAddress + OFS_BAKCTL) &= ~(LOCKBAK);
24  return (HWREG8(baseAddress + OFS_BAKCTL) & LOCKBAK);
25 }
26 
27 void BattBak_enableBackupSupplyToADC (uint16_t baseAddress)
28 {
29  HWREG8(baseAddress + OFS_BAKCTL) |= BAKADC;
30 }
31 
32 void BattBak_disableBackupSupplyToADC (uint16_t baseAddress)
33 {
34  HWREG8(baseAddress + OFS_BAKCTL) &= ~(BAKADC);
35 }
36 
37 void BattBak_switchToBackupSupplyManually (uint16_t baseAddress)
38 {
39  HWREG8(baseAddress + OFS_BAKCTL) |= BAKSW;
40 }
41 
42 void BattBak_disable (uint16_t baseAddress)
43 {
44  HWREG8(baseAddress + OFS_BAKCTL) |= BAKDIS;
45 }
46 
47 void BattBak_initAndEnableCharger (uint16_t baseAddress,
48  uint8_t chargerEndVoltage,
49  uint8_t chargeCurrent)
50 {
51  HWREG16(baseAddress +
52  OFS_BAKCHCTL) = CHPWD + chargerEndVoltage + chargeCurrent + CHEN;
53 }
54 
55 void BattBak_disableCharger (uint16_t baseAddress)
56 {
57  HWREG16(baseAddress + OFS_BAKCHCTL) = CHPWD;
58 }
59 
60 void BattBak_setBackupRAMData (uint16_t baseAddress,
61  uint8_t backupRAMSelect,
62  uint16_t data)
63 {
64  HWREG16(baseAddress + backupRAMSelect) = data;
65 }
66 
67 uint16_t BattBak_getBackupRAMData (uint16_t baseAddress,
68  uint8_t backupRAMSelect)
69 {
70  return ( HWREG16(baseAddress + backupRAMSelect) );
71 }
72 
73 #endif
74 //*****************************************************************************
75 //
78 //
79 //*****************************************************************************
#define HWREG8(x)
Definition: hw_memmap.h:41
#define HWREG16(x)
Definition: hw_memmap.h:39