-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspi_flash.h
More file actions
166 lines (150 loc) · 6.6 KB
/
Copy pathspi_flash.h
File metadata and controls
166 lines (150 loc) · 6.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
//*****************************************************************************
//
// spi_flash.h - Prototypes for the SPI flash driver.
//
// Copyright (c) 2012-2020 Texas Instruments Incorporated. All rights reserved.
// Software License Agreement
//
// Texas Instruments (TI) is supplying this software for use solely and
// exclusively on TI's microcontroller products. The software is owned by
// TI and/or its suppliers, and is protected under applicable copyright
// laws. You may not combine this software with "viral" open-source
// software in order to form a larger program.
//
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
// DAMAGES, FOR ANY REASON WHATSOEVER.
//
// This is part of revision 2.2.0.295 of the Tiva Utility Library.
//
//*****************************************************************************
#ifndef __SPI_FLASH_H__
#define __SPI_FLASH_H__
//*****************************************************************************
//
//! \addtogroup spi_flash_api
//! @{
//
//*****************************************************************************
//*****************************************************************************
//
//! The state structure used when performing non-blocking SPI flash operations.
//
//*****************************************************************************
typedef struct
{
//
//! The base address of the SSI module that is being used.
//
uint32_t ui32Base;
//
//! The command that is being send to the SPI flash.
//
uint16_t ui16Cmd;
//
//! The current state of the SPI flash state machine.
//
uint16_t ui16State;
//
//! The SPI flash address associated with the command.
//
uint32_t ui32Addr;
//
//! A pointer to the data buffer that is being read or written.
//
uint8_t *pui8Buffer;
//
//! The count of bytes left to be read.
//
uint32_t ui32ReadCount;
//
//! The count of bytes left to be written.
//
uint32_t ui32WriteCount;
//
//! A flag that is true if uDMA used be used for the transfer.
//
bool bUseDMA;
//
//! The uDMA channel to use for transmitting when using uDMA for the
//! transfer.
//
uint32_t ui32TxChannel;
//
//! The uDMA channel to use for receiving when using uDMA for the transfer.
//
uint32_t ui32RxChannel;
}
tSPIFlashState;
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
//*****************************************************************************
//
// The possible return values from the SPI flash interrupt handler.
//
//*****************************************************************************
#define SPI_FLASH_IDLE 0
#define SPI_FLASH_WORKING 1
#define SPI_FLASH_DONE 3
//*****************************************************************************
//
// Prototypes.
//
//*****************************************************************************
extern uint32_t SPIFlashIntHandler(tSPIFlashState *pState);
extern void SPIFlashInit(uint32_t ui32Base, uint32_t ui32Clock,
uint32_t ui32BitRate);
extern void SPIFlashWriteStatus(uint32_t ui32Base, uint8_t ui8Status);
extern void SPIFlashPageProgram(uint32_t ui32Base, uint32_t ui32Addr,
const uint8_t *pui8Data, uint32_t ui32Count);
extern void SPIFlashPageProgramNonBlocking(tSPIFlashState *pState,
uint32_t ui32Base,
uint32_t ui32Addr,
const uint8_t *pui8Data,
uint32_t ui32Count, bool bUseDMA,
uint32_t ui32TxChannel);
extern void SPIFlashRead(uint32_t ui32Base, uint32_t ui32Addr,
uint8_t *pui8Data, uint32_t ui32Count);
extern void SPIFlashReadNonBlocking(tSPIFlashState *pState, uint32_t ui32Base,
uint32_t ui32Addr, uint8_t *pui8Data,
uint32_t ui32Count, bool bUseDMA,
uint32_t ui32TxChannel,
uint32_t ui32RxChannel);
extern void SPIFlashWriteDisable(uint32_t ui32Base);
extern uint8_t SPIFlashReadStatus(uint32_t ui32Base);
extern void SPIFlashWriteEnable(uint32_t ui32Base);
extern void SPIFlashFastRead(uint32_t ui32Base, uint32_t ui32Addr,
uint8_t *pui8Data, uint32_t ui32Count);
extern void SPIFlashFastReadNonBlocking(tSPIFlashState *pState,
uint32_t ui32Base, uint32_t ui32Addr,
uint8_t *pui8Data, uint32_t ui32Count,
bool bUseDMA, uint32_t ui32TxChannel,
uint32_t ui32RxChannel);
extern void SPIFlashSectorErase(uint32_t ui32Base, uint32_t ui32Addr);
extern void SPIFlashDualRead(uint32_t ui32Base, uint32_t ui32Addr,
uint8_t *pui8Data, uint32_t ui32Count);
extern void SPIFlashDualReadNonBlocking(tSPIFlashState *pState,
uint32_t ui32Base, uint32_t ui32Addr,
uint8_t *pui8Data, uint32_t ui32Count,
bool bUseDMA, uint32_t ui32TxChannel,
uint32_t ui32RxChannel);
extern void SPIFlashBlockErase32(uint32_t ui32Base, uint32_t ui32Addr);
extern void SPIFlashQuadRead(uint32_t ui32Base, uint32_t ui32Addr,
uint8_t *pui8Data, uint32_t ui32Count);
extern void SPIFlashQuadReadNonBlocking(tSPIFlashState *pState,
uint32_t ui32Base, uint32_t ui32Addr,
uint8_t *pui8Data, uint32_t ui32Count,
bool bUseDMA, uint32_t ui32TxChannel,
uint32_t ui32RxChannel);
extern void SPIFlashReadID(uint32_t ui32Base, uint8_t *pui8ManufacturerID,
uint16_t *pui16DeviceID);
extern void SPIFlashChipErase(uint32_t ui32Base);
extern void SPIFlashBlockErase64(uint32_t ui32Base, uint32_t ui32Addr);
#endif // __SPI_FLASH_H__