1 //*****************************************************************************
2 //
3 // flash.h - Prototypes for the flash driver.
4 //
5 // Copyright (c) 2005-2011 Texas Instruments Incorporated.  All rights reserved.
6 // Software License Agreement
7 //
8 // Texas Instruments (TI) is supplying this software for use solely and
9 // exclusively on TI's microcontroller products. The software is owned by
10 // TI and/or its suppliers, and is protected under applicable copyright
11 // laws. You may not combine this software with "viral" open-source
12 // software in order to form a larger program.
13 //
14 // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
15 // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
16 // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17 // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
18 // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
19 // DAMAGES, FOR ANY REASON WHATSOEVER.
20 //
21 // This is part of revision 8264 of the Stellaris Peripheral Driver Library.
22 //
23 //*****************************************************************************
24 
25 #ifndef __FLASH_H__
26 #define __FLASH_H__
27 
28 //*****************************************************************************
29 //
30 // If building with a C++ compiler, make all of the definitions in this header
31 // have a C binding.
32 //
33 //*****************************************************************************
34 #ifdef __cplusplus
35 extern "C"
36 {
37 #endif
38 
39 //*****************************************************************************
40 //
41 // Values that can be passed to FlashProtectSet(), and returned by
42 // FlashProtectGet().
43 //
44 //*****************************************************************************
45 typedef enum
46 {
47     FlashReadWrite,                         // Flash can be read and written
48     FlashReadOnly,                          // Flash can only be read
49     FlashExecuteOnly                        // Flash can only be executed
50 }
51 tFlashProtection;
52 
53 //*****************************************************************************
54 //
55 // Values passed to FlashIntEnable(), FlashIntDisable() and FlashIntClear() and
56 // returned from FlashIntStatus().
57 //
58 //*****************************************************************************
59 #define FLASH_INT_PROGRAM     0x00000002 // Programming Interrupt Mask
60 #define FLASH_INT_ACCESS      0x00000001 // Access Interrupt Mask
61 #define FLASH_INT_EEPROM      0x00000004 // EEPROM Interrupt Mask
62 #define FLASH_INT_VOLTAGE_ERR 0x00000200 // Voltage Error Interrupt Mask
63 #define FLASH_INT_DATA_ERR    0x00000400 // Invalid Data Interrupt Mask
64 #define FLASH_INT_ERASE_ERR   0x00000800 // Erase Error Interrupt Mask
65 #define FLASH_INT_PROGRAM_ERR 0x00002000 // Program Verify Error Interrupt Mask
66 
67 //*****************************************************************************
68 //
69 // Prototypes for the APIs.
70 //
71 //*****************************************************************************
72 extern unsigned long FlashUsecGet(void);
73 extern void FlashUsecSet(unsigned long ulClocks);
74 extern long FlashErase(unsigned long ulAddress);
75 extern long FlashProgram(unsigned long *pulData, unsigned long ulAddress,
76                          unsigned long ulCount);
77 extern tFlashProtection FlashProtectGet(unsigned long ulAddress);
78 extern long FlashProtectSet(unsigned long ulAddress,
79                             tFlashProtection eProtect);
80 extern long FlashProtectSave(void);
81 extern long FlashUserGet(unsigned long *pulUser0, unsigned long *pulUser1);
82 extern long FlashUserSet(unsigned long ulUser0, unsigned long ulUser1);
83 extern long FlashUserSave(void);
84 extern void FlashIntRegister(void (*pfnHandler)(void));
85 extern void FlashIntUnregister(void);
86 extern void FlashIntEnable(unsigned long ulIntFlags);
87 extern void FlashIntDisable(unsigned long ulIntFlags);
88 extern unsigned long FlashIntStatus(tBoolean bMasked);
89 extern void FlashIntClear(unsigned long ulIntFlags);
90 
91 //*****************************************************************************
92 //
93 // Deprecated function names.  These definitions ensure backwards compatibility
94 // but new code should avoid using deprecated function names since these will
95 // be removed at some point in the future.
96 //
97 //*****************************************************************************
98 #ifndef DEPRECATED
99 #define FlashIntGetStatus       FlashIntStatus
100 #endif
101 
102 //*****************************************************************************
103 //
104 // Mark the end of the C bindings section for C++ compilers.
105 //
106 //*****************************************************************************
107 #ifdef __cplusplus
108 }
109 #endif
110 
111 #endif // __FLASH_H__
112