MotorWare f2806x Driver API Documentation
flash.c
Go to the documentation of this file.
1 /* --COPYRIGHT--,BSD
2  * Copyright (c) 2015, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  * --/COPYRIGHT--*/
37 
38 
39 // **************************************************************************
40 // the includes
41 
43 
44 
45 // **************************************************************************
46 // the defines
47 
48 
49 // **************************************************************************
50 // the globals
51 
52 
53 // **************************************************************************
54 // the functions
55 
57 {
58  FLASH_Obj *flash = (FLASH_Obj *)flashHandle;
59 
60 
62 
63  // set the bits
65 
67 
68  return;
69 } // end of FLASH_clear3VStatus() function
70 
71 
72 #pragma CODE_SECTION(FLASH_disablePipelineMode, "ramfuncs");
74 {
75  FLASH_Obj *flash = (FLASH_Obj *)flashHandle;
76 
77 
79 
80  // clear the bits
81  flash->FOPT &= (~FLASH_FOPT_ENPIPE_BITS);
82 
84 
85  return;
86 } // end of FLASH_disablePipelineMode() function
87 
88 
89 #pragma CODE_SECTION(FLASH_enablePipelineMode, "ramfuncs");
91 {
92  FLASH_Obj *flash = (FLASH_Obj *)flashHandle;
93 
94 
96 
97  // set the bits
98  flash->FOPT |= FLASH_FOPT_ENPIPE_BITS;
99 
101 
102  return;
103 } // end of FLASH_enablePipelineMode() function
104 
105 
107 {
108  FLASH_Obj *flash = (FLASH_Obj *)flashHandle;
109 
110 
111  // get the status
113 
114  return(status);
115 } // end of FLASH_get3VStatus() function
116 
117 
119 {
120  FLASH_Obj *flash = (FLASH_Obj *)flashHandle;
121 
122 
123  // get the status
124  uint16_t count = (flash->FACTIVEWAIT & FLASH_FACTIVEWAIT_ACTIVEWAIT_BITS);
125 
126  return(count);
127 } // end of FLASH_getActiveWaitCount() function
128 
129 
131 {
132  FLASH_Obj *flash = (FLASH_Obj *)flashHandle;
133 
134 
135  // get the status
137 
138  return(status);
139 } // end of FLASH_getActiveWaitStatus() function
140 
141 
143 {
144  FLASH_Obj *flash = (FLASH_Obj *)flashHandle;
145 
146 
147  // get the bits
149 
150  return(mode);
151 } // end of FLASH_getPowerMode() function
152 
153 
155 {
156  FLASH_Obj *flash = (FLASH_Obj *)flashHandle;
157 
158 
159  // get the status
160  uint16_t count = (flash->FSTDBYWAIT & FLASH_FSTDBYWAIT_STDBYWAIT_BITS);
161 
162  return(count);
163 } // end of FLASH_getStandbyWaitCount() function
164 
165 
167 {
168  FLASH_Obj *flash = (FLASH_Obj *)flashHandle;
169 
170 
171  // get the status
173 
174  return(status);
175 } // end of FLASH_getStandbyWaitStatus() function
176 
177 
178 FLASH_Handle FLASH_init(void *pMemory,const size_t numBytes)
179 {
180  FLASH_Handle flashHandle;
181 
182 
183  if(numBytes < sizeof(FLASH_Obj))
184  return((FLASH_Handle)NULL);
185 
186  // assign the handle
187  flashHandle = (FLASH_Handle)pMemory;
188 
189  return(flashHandle);
190 } // end of FLASH_init() function
191 
192 
193 #pragma CODE_SECTION(FLASH_setActiveWaitCount, "ramfuncs");
194 void FLASH_setActiveWaitCount(FLASH_Handle flashHandle,const uint16_t count)
195 {
196  FLASH_Obj *flash = (FLASH_Obj *)flashHandle;
197 
198 
200 
201  flash->FACTIVEWAIT = count;
202 
204 
205  return;
206 } // end of FLASH_setActiveWaitCount() function
207 
208 
209 #pragma CODE_SECTION(FLASH_setNumPagedReadWaitStates, "ramfuncs");
211 {
212  FLASH_Obj *flash = (FLASH_Obj *)flashHandle;
213 
214 
216 
217  // clear the bits
219 
220  // set the bits
221  flash->FBANKWAIT |= numStates;
222 
224 
225  return;
226 } // end of FLASH_setNumPagedReadWaitStates() function
227 
228 
229 #pragma CODE_SECTION(FLASH_setNumRandomReadWaitStates, "ramfuncs");
231 {
232  FLASH_Obj *flash = (FLASH_Obj *)flashHandle;
233 
234 
236 
237  // clear the bits
239 
240  // set the bits
241  flash->FBANKWAIT |= numStates;
242 
244 
245  return;
246 } // end of FLASH_setNumRandomReadWaitStates() function
247 
248 
249 #pragma CODE_SECTION(FLASH_setOtpWaitStates, "ramfuncs");
251 {
252  FLASH_Obj *flash = (FLASH_Obj *)flashHandle;
253 
254 
256 
257  // clear the bits
259 
260  // set the bits
261  flash->FOTPWAIT |= numStates;
262 
264 
265  return;
266 } // end of FLASH_setOneTimeProgrammableStates() function
267 
268 
269 #pragma CODE_SECTION(FLASH_setPowerMode, "ramfuncs");
271 {
272  FLASH_Obj *flash = (FLASH_Obj *)flashHandle;
273 
274 
276 
277  // clear the bits
278  flash->FPWR &= (~FLASH_FPWR_PWR_BITS);
279 
280  // set the bits
281  flash->FPWR |= mode;
282 
284 
285  return;
286 } // end of FLASH_setPowerMode() function
287 
288 
289 #pragma CODE_SECTION(FLASH_setStandbyWaitCount, "ramfuncs");
290 void FLASH_setStandbyWaitCount(FLASH_Handle flashHandle,const uint16_t count)
291 {
292  FLASH_Obj *flash = (FLASH_Obj *)flashHandle;
293 
294 
296 
297  flash->FSTDBYWAIT = count;
298 
300 
301  return;
302 } // end of FLASH_setStandbyWaitCount() function
303 
304 
305 // end of file
#define FLASH_FOTPWAIT_OTPWAIT_BITS
Defines the location of the OTPWAIT bits in the FOTPWAIT register.
Definition: flash.h:101
void FLASH_setOtpWaitStates(FLASH_Handle flashHandle, const FLASH_NumOtpWaitStates_e numStates)
Sets the number of one-time programmable (OTP) wait states.
Definition: flash.c:250
FLASH_3VStatus_e FLASH_get3VStatus(FLASH_Handle flashHandle)
Gets the 3V status.
Definition: flash.c:106
#define DISABLE_PROTECTED_REGISTER_WRITE_MODE
Define to disable protected register writes.
Definition: cpu.h:101
#define FLASH_FBANKWAIT_PAGEWAIT_BITS
Defines the location of the PAGEWAIT bits in the FBANKWAIT register.
Definition: flash.h:96
#define FLASH_FSTDBYWAIT_STDBYWAIT_BITS
Defines the location of the STDBYWAIT bits in the FSTDBYWAIT register.
Definition: flash.h:128
void FLASH_setActiveWaitCount(FLASH_Handle flashHandle, const uint16_t count)
Sets the active wait count.
Definition: flash.c:194
#define FLASH_FPWR_PWR_BITS
Defines the location of the PWR bits in the FPWR register.
Definition: flash.h:106
FLASH_CounterStatus_e
Enumeration to define the counter status.
Definition: flash.h:146
#define FLASH_FBANKWAIT_RANDWAIT_BITS
Defines the location of the RANDWAIT bits in the FBANKWAIT register.
Definition: flash.h:92
void FLASH_disablePipelineMode(FLASH_Handle flashHandle)
Disables the pipeline mode.
Definition: flash.c:73
volatile uint16_t FSTDBYWAIT
Flash Sleep To Standby Wait Register.
Definition: flash.h:238
#define ENABLE_PROTECTED_REGISTER_WRITE_MODE
Define to allow protected register writes.
Definition: cpu.h:93
volatile uint16_t FACTIVEWAIT
Flash Standby to Active Wait Register.
Definition: flash.h:239
FLASH_CounterStatus_e FLASH_getStandbyWaitStatus(FLASH_Handle flashHandle)
Gets the standby wait counter status.
Definition: flash.c:166
void FLASH_setNumPagedReadWaitStates(FLASH_Handle flashHandle, const FLASH_NumPagedWaitStates_e numStates)
Sets the number of paged read wait states.
Definition: flash.c:210
FLASH_NumOtpWaitStates_e
Enumeration to define the number of one-time programmable wait states.
Definition: flash.h:155
uint16_t FLASH_getActiveWaitCount(FLASH_Handle flashHandle)
Gets the active wait count.
Definition: flash.c:118
volatile uint16_t FBANKWAIT
Flash Read Access Wait State Register.
Definition: flash.h:240
FLASH_CounterStatus_e FLASH_getActiveWaitStatus(FLASH_Handle flashHandle)
Gets the active wait counter status.
Definition: flash.c:130
FLASH_Handle FLASH_init(void *pMemory, const size_t numBytes)
Initializes the flash (FLASH) handle.
Definition: flash.c:178
FLASH_3VStatus_e
Enumeration to define the 3V status.
Definition: flash.h:137
volatile uint16_t FOPT
Flash Option Register.
Definition: flash.h:234
void FLASH_setPowerMode(FLASH_Handle flashHandle, const FLASH_PowerMode_e mode)
Sets the power mode.
Definition: flash.c:270
void FLASH_enablePipelineMode(FLASH_Handle flashHandle)
Enables the pipeline mode.
Definition: flash.c:90
volatile uint16_t FOTPWAIT
OTP Read Access Wait State Register.
Definition: flash.h:241
#define FLASH_FSTATUS_STDBYWAITS_BITS
Defines the location of the STDBYWAITS bits in the FSTATUS register.
Definition: flash.h:115
volatile uint16_t FSTATUS
Status Register.
Definition: flash.h:237
FLASH_NumPagedWaitStates_e
Enumeration to define the number of paged wait states.
Definition: flash.h:177
#define FLASH_FSTATUS_ACTIVEWAITS_BITS
Defines the location of the ACTIVEWAITS bits in the FSTATUS register.
Definition: flash.h:119
Defines the flash (FLASH) object.
Definition: flash.h:232
void FLASH_setStandbyWaitCount(FLASH_Handle flashHandle, const uint16_t count)
Sets the standby wait count.
Definition: flash.c:290
volatile uint16_t FPWR
Flash Power Modes Register.
Definition: flash.h:236
uint16_t FLASH_getStandbyWaitCount(FLASH_Handle flashHandle)
Gets the standby wait count.
Definition: flash.c:154
#define FLASH_FOPT_ENPIPE_BITS
Defines the location of the ENPIPE bits in the FOPT register.
Definition: flash.h:82
FLASH_NumRandomWaitStates_e
Enumeration to define the number of random wait states.
Definition: flash.h:200
#define FLASH_FSTATUS_3VSTAT_BITS
Defines the location of the 3VSTAT bits in the FSTATUS register.
Definition: flash.h:123
void FLASH_setNumRandomReadWaitStates(FLASH_Handle flashHandle, const FLASH_NumRandomWaitStates_e numStates)
Sets the number of random read wait states.
Definition: flash.c:230
FLASH_PowerMode_e FLASH_getPowerMode(FLASH_Handle flashHandle)
Gets the power mode.
Definition: flash.c:142
#define FLASH_FACTIVEWAIT_ACTIVEWAIT_BITS
Defines the location of the ACTIVEWAIT bits in the FACTIVEWAIT register.
Definition: flash.h:87
struct _FLASH_Obj_ * FLASH_Handle
Defines the flash (FLASH) handle.
Definition: flash.h:247
Contains public interface to various functions related to the flash (FLASH) object.
FLASH_PowerMode_e
Enumeration to define the power modes.
Definition: flash.h:222
#define FLASH_FSTATUS_PWRS_BITS
Defines the location of the PWRS bits in the FSTATUS register.
Definition: flash.h:111
void FLASH_clear3VStatus(FLASH_Handle flashHandle)
Clears the 3V status.
Definition: flash.c:56