MAX32665 SDK Documentation  0.2
Software Development Kit Overview and API Documentation
mx25.h
1 
5  /* ****************************************************************************
6  * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a
9  * copy of this software and associated documentation files (the "Software"),
10  * to deal in the Software without restriction, including without limitation
11  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12  * and/or sell copies of the Software, and to permit persons to whom the
13  * Software is furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included
16  * in all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21  * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
22  * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24  * OTHER DEALINGS IN THE SOFTWARE.
25  *
26  * Except as contained in this notice, the name of Maxim Integrated
27  * Products, Inc. shall not be used except as stated in the Maxim Integrated
28  * Products, Inc. Branding Policy.
29  *
30  * The mere transfer of this software does not imply any licenses
31  * of trade secrets, proprietary technology, copyrights, patents,
32  * trademarks, maskwork rights, or any other form of intellectual
33  * property whatsoever. Maxim Integrated Products, Inc. retains all
34  * ownership rights.
35  *
36  * $Date: 2018-11-08 15:08:58 -0600 (Thu, 08 Nov 2018) $
37  * $Revision: 39056 $
38  *
39  **************************************************************************** */
40 
41 /* Define to prevent redundant inclusion */
42 #ifndef _MX25_H_
43 #define _MX25_H_
44 
45 /* **** Includes **** */
46 #include "mxc_config.h"
47 #include "mxc_sys.h"
48 #include "spi.h"
49 #include "spixfc.h"
50 #include "mxc_errors.h"
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
61 /* **** Definitions **** */
62 #define MX25_Read_DUMMY 8
63 #define MX25_DREAD_DUMMY 4
64 #define MX25_QREAD_DUMMY 6
66 #define MX25_WIP_MASK 0x01
67 #define MX25_WEL_MASK 0x02
68 #define MX25_QE_MASK 0x40
69 #define MX25_WP_MASK 0x80
76 #define MX25_CMD_RST_EN 0x66
77 #define MX25_CMD_RST_MEM 0x99
78 #define MX25_CMD_ID 0x9F
79 #define MX25_CMD_WRITE_EN 0x06
80 #define MX25_CMD_WRITE_DIS 0x04
82 #define MX25_CMD_READ 0x0B
83 #define MX25_CMD_DREAD 0xBB
84 #define MX25_CMD_QREAD 0xEB
85 #define MX25_CMD_HPM 0xA3
87 #define MX25_CMD_READ_SR 0x05
88 #define MX25_CMD_WRITE_SR 0x01
90 #define MX25_CMD_PPROG 0x02
91 #define MX25_CMD_QUAD_PROG 0X38
93 #define MX25_CMD_4K_ERASE 0x20
94 #define MX25_CMD_32K_ERASE 0x52
95 #define MX25_CMD_64K_ERASE 0xD8
96 #define MX25_CMD_BULK_ERASE 0xC7
101 typedef enum {
105 }
107 
108 /* *** Globals **** */
109 
110 /* **** Function Prototypes **** */
111 
117 int MX25_Init(void);
118 
124 int MX25_Reset(void);
125 
130 uint32_t MX25_ID(void);
131 
138 int MX25_Quad(int enable);
139 
149 int MX25_Read(uint32_t address, uint8_t *rx_buf, uint32_t rx_len, spixfc_width_t width);
150 
157 int MX25_Write_Protect(int enable);
158 
171 int MX25_Program_Page(uint32_t address, const uint8_t *tx_buf, uint32_t tx_len, spixfc_width_t width);
172 
179 int MX25_Bulk_Erase(void);
180 
188 int MX25_Erase(uint32_t address, MX25_Erase_t size);
189 
194 int MX25_Read_SR(uint8_t* buf);
195 
200 int MX25_Write_SR(uint8_t value);
201 
203 #ifdef __cplusplus
204 }
205 #endif
206 
207 #endif /* _MX25_H_ */
int MX25_Read(uint32_t address, uint8_t *rx_buf, uint32_t rx_len, spixfc_width_t width)
Read data out by using 4-wire SPI mode.
int MX25_Program_Page(uint32_t address, const uint8_t *tx_buf, uint32_t tx_len, spixfc_width_t width)
Program the memory to tx_buf and length tx_len, applies to both SPI and QPI modes.
4KB Sector Erase
Definition: mx25.h:102
int MX25_Init(void)
Initialize SPI configuration and reset n25q.
int MX25_Write_Protect(int enable)
enable write protection
MX25_Erase_t
Enumeration type to select the size for an Erase command.
Definition: mx25.h:101
int MX25_Read_SR(uint8_t *buf)
Read status register.
spixfc_width_t
Number of data lines to use.
Definition: spixfc.h:80
uint32_t MX25_ID(void)
Read manufacturer ID.
int MX25_Write_SR(uint8_t value)
Write status register.
int MX25_Reset(void)
Reset the MX25 flash memory.
int MX25_Bulk_Erase(void)
Bulk erase the MX25 flash memory.
32KB Block Erase
Definition: mx25.h:103
int MX25_Quad(int enable)
Enable/Disable the Quad Enable(QE) bit in the status register.
64KB Block Erase
Definition: mx25.h:104
int MX25_Erase(uint32_t address, MX25_Erase_t size)
Erase memory segments.