2020-2021 Sunseeker Telemetry and Lighting System
sysctl.c
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // sysctl.c - Driver for the sysctl Module.
4 //
5 //*****************************************************************************
6 
7 //*****************************************************************************
8 //
11 //
12 //*****************************************************************************
13 
14 #include "inc/hw_memmap.h"
15 
16 #ifdef __MSP430_HAS_SYS__
17 #include "sysctl.h"
18 
19 #include <assert.h>
20 
21 void SysCtl_enableDedicatedJTAGPins (void)
22 {
23  HWREG8(SYS_BASE + OFS_SYSCTL_L) |= SYSJTAGPIN;
24 }
25 
26 uint8_t SysCtl_getBSLEntryIndication (void)
27 {
28  if ( HWREG8(SYS_BASE + OFS_SYSCTL_L) & SYSBSLIND){
29  return (SYSCTL_BSLENTRY_INDICATED) ;
30  } else {
31  return (SYSCTL_BSLENTRY_NOTINDICATED) ;
32  }
33 }
34 
35 void SysCtl_enablePMMAccessProtect (void)
36 {
37  HWREG8(SYS_BASE + OFS_SYSCTL_L) |= SYSPMMPE;
38 }
39 
40 void SysCtl_enableRAMBasedInterruptVectors (void)
41 {
42  HWREG8(SYS_BASE + OFS_SYSCTL_L) |= SYSRIVECT;
43 }
44 
45 void SysCtl_disableRAMBasedInterruptVectors (void)
46 {
47  HWREG8(SYS_BASE + OFS_SYSCTL_L) &= ~(SYSRIVECT);
48 }
49 
50 void SysCtl_enableBSLProtect (void)
51 {
52  HWREG16(SYS_BASE + OFS_SYSBSLC) |= SYSBSLPE;
53 }
54 
55 void SysCtl_disableBSLProtect (void)
56 {
57  HWREG16(SYS_BASE + OFS_SYSBSLC) &= ~(SYSBSLPE);
58 }
59 
60 void SysCtl_enableBSLMemory (void)
61 {
62  HWREG16(SYS_BASE + OFS_SYSBSLC) &= ~(SYSBSLOFF);
63 }
64 
65 void SysCtl_disableBSLMemory (void)
66 {
67  HWREG16(SYS_BASE + OFS_SYSBSLC) |= SYSBSLOFF;
68 }
69 
70 void SysCtl_setRAMAssignedToBSL (uint8_t BSLRAMAssignment)
71 {
72  HWREG8(SYS_BASE + OFS_SYSBSLC_L) &= ~(SYSBSLR);
73  HWREG8(SYS_BASE + OFS_SYSBSLC_L) |= BSLRAMAssignment;
74 }
75 
76 void SysCtl_setBSLSize (uint8_t BSLSizeSelect)
77 {
78  HWREG8(SYS_BASE + OFS_SYSBSLC_L) &= ~(SYSBSLSIZE0 + SYSBSLSIZE1);
79  HWREG8(SYS_BASE + OFS_SYSBSLC_L) |= BSLSizeSelect;
80 }
81 
82 void SysCtl_initJTAGMailbox (uint8_t mailboxSizeSelect,
83  uint8_t autoClearInboxFlagSelect)
84 {
85  HWREG8(SYS_BASE + OFS_SYSJMBC_L) &= ~(JMBCLR1OFF + JMBCLR0OFF + JMBMODE);
86  HWREG8(SYS_BASE + OFS_SYSJMBC_L) |=
87  mailboxSizeSelect + autoClearInboxFlagSelect;
88 }
89 
90 uint8_t SysCtl_getJTAGMailboxFlagStatus (uint8_t mailboxFlagMask)
91 {
92  return ( HWREG8(SYS_BASE + OFS_SYSJMBC_L) & mailboxFlagMask);
93 }
94 
95 void SysCtl_clearJTAGMailboxFlagStatus (uint8_t mailboxFlagMask)
96 {
97  HWREG8(SYS_BASE + OFS_SYSJMBC_L) &= ~(mailboxFlagMask);
98 }
99 
100 uint16_t SysCtl_getJTAGInboxMessage16Bit (uint8_t inboxSelect)
101 {
102  return ( HWREG16(SYS_BASE + OFS_SYSJMBI0 + inboxSelect) );
103 }
104 
105 uint32_t SysCtl_getJTAGInboxMessage32Bit (void)
106 {
107  uint32_t JTAGInboxMessageLow = HWREG16(SYS_BASE + OFS_SYSJMBI0);
108  uint32_t JTAGInboxMessageHigh = HWREG16(SYS_BASE + OFS_SYSJMBI1);
109 
110  return ( (JTAGInboxMessageHigh << 16) + JTAGInboxMessageLow );
111 }
112 
113 void SysCtl_setJTAGOutgoingMessage16Bit (uint8_t outboxSelect,
114  uint16_t outgoingMessage)
115 {
116  HWREG16(SYS_BASE + OFS_SYSJMBO0 + outboxSelect) = outgoingMessage;
117 }
118 
119 void SysCtl_setJTAGOutgoingMessage32Bit (uint32_t outgoingMessage)
120 {
121  HWREG16(SYS_BASE + OFS_SYSJMBO0) = (outgoingMessage);
122  HWREG16(SYS_BASE + OFS_SYSJMBO1) = (outgoingMessage >> 16);
123 }
124 
125 
126 #endif
127 //*****************************************************************************
128 //
131 //
132 //*****************************************************************************
#define HWREG8(x)
Definition: hw_memmap.h:41
#define HWREG16(x)
Definition: hw_memmap.h:39