2 * Copyright (c) 2014, Texas Instruments Incorporated
\r
3 * All rights reserved.
\r
5 * Redistribution and use in source and binary forms, with or without
\r
6 * modification, are permitted provided that the following conditions
\r
9 * * Redistributions of source code must retain the above copyright
\r
10 * notice, this list of conditions and the following disclaimer.
\r
12 * * Redistributions in binary form must reproduce the above copyright
\r
13 * notice, this list of conditions and the following disclaimer in the
\r
14 * documentation and/or other materials provided with the distribution.
\r
16 * * Neither the name of Texas Instruments Incorporated nor the names of
\r
17 * its contributors may be used to endorse or promote products derived
\r
18 * from this software without specific prior written permission.
\r
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
\r
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
\r
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
\r
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
\r
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
\r
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
\r
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
\r
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
\r
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
\r
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
\r
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
32 //*****************************************************************************
\r
34 // sfr.h - Driver for the SFR Module.
\r
36 //*****************************************************************************
\r
38 #ifndef __MSP430WARE_SFR_H__
\r
39 #define __MSP430WARE_SFR_H__
\r
41 #include "inc/hw_memmap.h"
\r
43 #ifdef __MSP430_HAS_SFR__
\r
45 //*****************************************************************************
\r
47 // If building with a C++ compiler, make all of the definitions in this header
\r
48 // have a C binding.
\r
50 //*****************************************************************************
\r
56 //*****************************************************************************
\r
58 // The following are values that can be passed to the interruptMask parameter
\r
59 // for functions: SFR_enableInterrupt(), and SFR_disableInterrupt(); the
\r
60 // interruptFlagMask parameter for functions: SFR_getInterruptStatus(), and
\r
61 // SFR_clearInterrupt() as well as returned by the SFR_getInterruptStatus()
\r
64 //*****************************************************************************
\r
65 #define SFR_JTAG_OUTBOX_INTERRUPT JMBOUTIE
\r
66 #define SFR_JTAG_INBOX_INTERRUPT JMBINIE
\r
67 #define SFR_NMI_PIN_INTERRUPT NMIIE
\r
68 #define SFR_VACANT_MEMORY_ACCESS_INTERRUPT VMAIE
\r
69 #define SFR_OSCILLATOR_FAULT_INTERRUPT OFIE
\r
70 #define SFR_WATCHDOG_INTERVAL_TIMER_INTERRUPT WDTIE
\r
72 //*****************************************************************************
\r
74 // The following are values that can be passed to the pullResistorSetup
\r
75 // parameter for functions: SFR_setResetPinPullResistor().
\r
77 //*****************************************************************************
\r
78 #define SFR_RESISTORDISABLE (!(SYSRSTRE + SYSRSTUP))
\r
79 #define SFR_RESISTORENABLE_PULLUP (SYSRSTRE + SYSRSTUP)
\r
80 #define SFR_RESISTORENABLE_PULLDOWN (SYSRSTRE)
\r
82 //*****************************************************************************
\r
84 // The following are values that can be passed to the edgeDirection parameter
\r
85 // for functions: SFR_setNMIEdge().
\r
87 //*****************************************************************************
\r
88 #define SFR_NMI_RISINGEDGE (!(SYSNMIIES))
\r
89 #define SFR_NMI_FALLINGEDGE (SYSNMIIES)
\r
91 //*****************************************************************************
\r
93 // The following are values that can be passed to the resetPinFunction
\r
94 // parameter for functions: SFR_setResetNMIPinFunction().
\r
96 //*****************************************************************************
\r
97 #define SFR_RESETPINFUNC_RESET (!(SYSNMI))
\r
98 #define SFR_RESETPINFUNC_NMI (SYSNMI)
\r
100 //*****************************************************************************
\r
102 // Prototypes for the APIs.
\r
104 //*****************************************************************************
\r
106 //*****************************************************************************
\r
108 //! \brief Enables selected SFR interrupt sources.
\r
110 //! This function enables the selected SFR interrupt sources. Only the sources
\r
111 //! that are enabled can be reflected to the processor interrupt; disabled
\r
112 //! sources have no effect on the processor. Does not clear interrupt flags.
\r
114 //! \param interruptMask is the bit mask of interrupts that will be enabled.
\r
115 //! Mask value is the logical OR of any of the following:
\r
116 //! - \b SFR_JTAG_OUTBOX_INTERRUPT - JTAG outbox interrupt
\r
117 //! - \b SFR_JTAG_INBOX_INTERRUPT - JTAG inbox interrupt
\r
118 //! - \b SFR_NMI_PIN_INTERRUPT - NMI pin interrupt, if NMI function is
\r
120 //! - \b SFR_VACANT_MEMORY_ACCESS_INTERRUPT - Vacant memory access
\r
122 //! - \b SFR_OSCILLATOR_FAULT_INTERRUPT - Oscillator fault interrupt
\r
123 //! - \b SFR_WATCHDOG_INTERVAL_TIMER_INTERRUPT - Watchdog interval timer
\r
128 //*****************************************************************************
\r
129 extern void SFR_enableInterrupt(uint8_t interruptMask);
\r
131 //*****************************************************************************
\r
133 //! \brief Disables selected SFR interrupt sources.
\r
135 //! This function disables the selected SFR interrupt sources. Only the sources
\r
136 //! that are enabled can be reflected to the processor interrupt; disabled
\r
137 //! sources have no effect on the processor.
\r
139 //! \param interruptMask is the bit mask of interrupts that will be disabled.
\r
140 //! Mask value is the logical OR of any of the following:
\r
141 //! - \b SFR_JTAG_OUTBOX_INTERRUPT - JTAG outbox interrupt
\r
142 //! - \b SFR_JTAG_INBOX_INTERRUPT - JTAG inbox interrupt
\r
143 //! - \b SFR_NMI_PIN_INTERRUPT - NMI pin interrupt, if NMI function is
\r
145 //! - \b SFR_VACANT_MEMORY_ACCESS_INTERRUPT - Vacant memory access
\r
147 //! - \b SFR_OSCILLATOR_FAULT_INTERRUPT - Oscillator fault interrupt
\r
148 //! - \b SFR_WATCHDOG_INTERVAL_TIMER_INTERRUPT - Watchdog interval timer
\r
153 //*****************************************************************************
\r
154 extern void SFR_disableInterrupt(uint8_t interruptMask);
\r
156 //*****************************************************************************
\r
158 //! \brief Returns the status of the selected SFR interrupt flags.
\r
160 //! This function returns the status of the selected SFR interrupt flags in a
\r
161 //! bit mask format matching that passed into the interruptFlagMask parameter.
\r
163 //! \param interruptFlagMask is the bit mask of interrupt flags that the status
\r
164 //! of should be returned.
\r
165 //! Mask value is the logical OR of any of the following:
\r
166 //! - \b SFR_JTAG_OUTBOX_INTERRUPT - JTAG outbox interrupt
\r
167 //! - \b SFR_JTAG_INBOX_INTERRUPT - JTAG inbox interrupt
\r
168 //! - \b SFR_NMI_PIN_INTERRUPT - NMI pin interrupt, if NMI function is
\r
170 //! - \b SFR_VACANT_MEMORY_ACCESS_INTERRUPT - Vacant memory access
\r
172 //! - \b SFR_OSCILLATOR_FAULT_INTERRUPT - Oscillator fault interrupt
\r
173 //! - \b SFR_WATCHDOG_INTERVAL_TIMER_INTERRUPT - Watchdog interval timer
\r
176 //! \return A bit mask of the status of the selected interrupt flags.
\r
177 //! Return Logical OR of any of the following:
\r
178 //! - \b SFR_JTAG_OUTBOX_INTERRUPT JTAG outbox interrupt
\r
179 //! - \b SFR_JTAG_INBOX_INTERRUPT JTAG inbox interrupt
\r
180 //! - \b SFR_NMI_PIN_INTERRUPT NMI pin interrupt, if NMI function is
\r
182 //! - \b SFR_VACANT_MEMORY_ACCESS_INTERRUPT Vacant memory access
\r
184 //! - \b SFR_OSCILLATOR_FAULT_INTERRUPT Oscillator fault interrupt
\r
185 //! - \b SFR_WATCHDOG_INTERVAL_TIMER_INTERRUPT Watchdog interval timer
\r
187 //! \n indicating the status of the masked interrupts
\r
189 //*****************************************************************************
\r
190 extern uint8_t SFR_getInterruptStatus(uint8_t interruptFlagMask);
\r
192 //*****************************************************************************
\r
194 //! \brief Clears the selected SFR interrupt flags.
\r
196 //! This function clears the status of the selected SFR interrupt flags.
\r
198 //! \param interruptFlagMask is the bit mask of interrupt flags that will be
\r
200 //! Mask value is the logical OR of any of the following:
\r
201 //! - \b SFR_JTAG_OUTBOX_INTERRUPT - JTAG outbox interrupt
\r
202 //! - \b SFR_JTAG_INBOX_INTERRUPT - JTAG inbox interrupt
\r
203 //! - \b SFR_NMI_PIN_INTERRUPT - NMI pin interrupt, if NMI function is
\r
205 //! - \b SFR_VACANT_MEMORY_ACCESS_INTERRUPT - Vacant memory access
\r
207 //! - \b SFR_OSCILLATOR_FAULT_INTERRUPT - Oscillator fault interrupt
\r
208 //! - \b SFR_WATCHDOG_INTERVAL_TIMER_INTERRUPT - Watchdog interval timer
\r
213 //*****************************************************************************
\r
214 extern void SFR_clearInterrupt(uint8_t interruptFlagMask);
\r
216 //*****************************************************************************
\r
218 //! \brief Sets the pull-up/down resistor on the ~RST/NMI pin.
\r
220 //! This function sets the pull-up/down resistors on the ~RST/NMI pin to the
\r
221 //! settings from the pullResistorSetup parameter.
\r
223 //! \param pullResistorSetup is the selection of how the pull-up/down resistor
\r
224 //! on the ~RST/NMI pin should be setup or disabled.
\r
225 //! Valid values are:
\r
226 //! - \b SFR_RESISTORDISABLE
\r
227 //! - \b SFR_RESISTORENABLE_PULLUP [Default]
\r
228 //! - \b SFR_RESISTORENABLE_PULLDOWN
\r
229 //! \n Modified bits are \b SYSRSTUP and \b SYSRSTRE of \b SFRRPCR
\r
234 //*****************************************************************************
\r
235 extern void SFR_setResetPinPullResistor(uint16_t pullResistorSetup);
\r
237 //*****************************************************************************
\r
239 //! \brief Sets the edge direction that will assert an NMI from a signal on the
\r
240 //! ~RST/NMI pin if NMI function is active.
\r
242 //! This function sets the edge direction that will assert an NMI from a signal
\r
243 //! on the ~RST/NMI pin if the NMI function is active. To activate the NMI
\r
244 //! function of the ~RST/NMI use the SFR_setResetNMIPinFunction() passing
\r
245 //! SFR_RESETPINFUNC_NMI into the resetPinFunction parameter.
\r
247 //! \param edgeDirection is the direction that the signal on the ~RST/NMI pin
\r
248 //! should go to signal an interrupt, if enabled.
\r
249 //! Valid values are:
\r
250 //! - \b SFR_NMI_RISINGEDGE [Default]
\r
251 //! - \b SFR_NMI_FALLINGEDGE
\r
252 //! \n Modified bits are \b SYSNMIIES of \b SFRRPCR register.
\r
256 //*****************************************************************************
\r
257 extern void SFR_setNMIEdge(uint16_t edgeDirection);
\r
259 //*****************************************************************************
\r
261 //! \brief Sets the function of the ~RST/NMI pin.
\r
263 //! This function sets the functionality of the ~RST/NMI pin, whether in reset
\r
264 //! mode which will assert a reset if a low signal is observed on that pin, or
\r
265 //! an NMI which will assert an interrupt from an edge of the signal dependent
\r
266 //! on the setting of the edgeDirection parameter in SFR_setNMIEdge().
\r
268 //! \param resetPinFunction is the function that the ~RST/NMI pin should take
\r
270 //! Valid values are:
\r
271 //! - \b SFR_RESETPINFUNC_RESET [Default]
\r
272 //! - \b SFR_RESETPINFUNC_NMI
\r
273 //! \n Modified bits are \b SYSNMI of \b SFRRPCR register.
\r
277 //*****************************************************************************
\r
278 extern void SFR_setResetNMIPinFunction(uint8_t resetPinFunction);
\r
280 //*****************************************************************************
\r
282 // Mark the end of the C bindings section for C++ compilers.
\r
284 //*****************************************************************************
\r
290 #endif // __MSP430WARE_SFR_H__
\r