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 // framctl.c - Driver for the framctl Module.
\r
36 //*****************************************************************************
\r
38 //*****************************************************************************
\r
40 //! \addtogroup framctl_api framctl
\r
43 //*****************************************************************************
\r
45 #include "inc/hw_regaccess.h"
\r
46 #include "inc/hw_memmap.h"
\r
48 #ifdef __MSP430_HAS_FRAM__
\r
49 #include "framctl.h"
\r
53 void FRAMCtl_write8(uint8_t *dataPtr,
\r
55 uint16_t numberOfBytes)
\r
57 while(numberOfBytes > 0)
\r
60 *framPtr++ = *dataPtr++;
\r
65 void FRAMCtl_write16(uint16_t *dataPtr,
\r
67 uint16_t numberOfWords)
\r
69 while(numberOfWords > 0)
\r
72 *framPtr++ = *dataPtr++;
\r
77 void FRAMCtl_write32(uint32_t *dataPtr,
\r
84 *framPtr++ = *dataPtr++;
\r
89 void FRAMCtl_fillMemory32(uint32_t value,
\r
101 void FRAMCtl_enableInterrupt(uint8_t interruptMask)
\r
103 uint8_t waitSelection;
\r
105 waitSelection = (HWREG8(FRAM_BASE + OFS_FRCTL0) & 0xFF);
\r
106 // Clear lock in FRAM control registers
\r
107 HWREG16(FRAM_BASE + OFS_FRCTL0) = FWPW | waitSelection;
\r
109 // Enable user selected interrupt sources
\r
110 HWREG16(FRAM_BASE + OFS_GCCTL0) |= interruptMask;
\r
113 uint8_t FRAMCtl_getInterruptStatus(uint16_t interruptFlagMask)
\r
115 return (HWREG16(FRAM_BASE + OFS_GCCTL1) & interruptFlagMask);
\r
118 void FRAMCtl_disableInterrupt(uint16_t interruptMask)
\r
120 uint8_t waitSelection;
\r
122 waitSelection = (HWREG8(FRAM_BASE + OFS_FRCTL0) & 0xFF);
\r
123 //Clear lock in FRAM control registers
\r
124 HWREG16(FRAM_BASE + OFS_FRCTL0) = FWPW | waitSelection;
\r
126 HWREG16(FRAM_BASE + OFS_GCCTL0) &= ~(interruptMask);
\r
129 void FRAMCtl_configureWaitStateControl(uint8_t waitState)
\r
131 // Clear lock in FRAM control registers
\r
132 HWREG16(FRAM_BASE + OFS_FRCTL0) = FWPW;
\r
134 HWREG8(FRAM_BASE + OFS_FRCTL0_L) &= ~NWAITS_7;
\r
135 HWREG8(FRAM_BASE + OFS_FRCTL0_L) |= (waitState);
\r
138 void FRAMCtl_delayPowerUpFromLPM(uint8_t delayStatus)
\r
140 uint8_t waitSelection;
\r
142 waitSelection = (HWREG8(FRAM_BASE + OFS_FRCTL0) & 0xFF);
\r
144 // Clear lock in FRAM control registers
\r
145 HWREG16(FRAM_BASE + OFS_FRCTL0) = FWPW | waitSelection;
\r
147 HWREG8(FRAM_BASE + OFS_GCCTL0_L) &= ~0x02;
\r
148 HWREG8(FRAM_BASE + OFS_GCCTL0_L) |= delayStatus;
\r
152 //*****************************************************************************
\r
154 //! Close the doxygen group for framctl_api
\r
157 //*****************************************************************************
\r