Contiki 2.6
|
Header file for the control of the M25P16 on sensinode N740s. More...
Go to the source code of this file.
Data Structures | |
struct | m25p16_rdid |
Device Identifier. More... | |
Defines | |
#define | M25P16_BP() (m25p16_rdsr() & M25P16_SR_BP) |
Retrieve Block Protect Bits from the status register. | |
#define | M25P16_WIP() (m25p16_rdsr() & M25P16_SR_WIP) |
Check for Write in Progress. | |
#define | M25P16_WEL() (m25p16_rdsr() & M25P16_SR_WEL) |
Check for Write-Enable. | |
Functions | |
void | m25p16_wren () |
Write Enable (WREN) instruction. | |
void | m25p16_wrdi () |
Write Disable (WRDI) instruction. | |
void | m25p16_rdid (struct m25p16_rdid *rdid) |
Read Identifier (RDID)instruction. | |
uint8_t | m25p16_rdsr () |
Read Status Register (RDSR) instruction. | |
void | m25p16_wrsr (uint8_t val) |
Write Status Register (WRSR) instruction. | |
void | m25p16_read (uint8_t *addr, uint8_t *buff, uint8_t buff_len) |
Read Data Bytes (READ) instruction. | |
void | m25p16_pp (uint8_t *addr, uint8_t *buff, uint8_t buff_len) |
Program Page (PP) instruction. | |
void | m25p16_se (uint8_t s) |
Sector Erase (SE) instruction. | |
void | m25p16_be () |
Bulk Erase (SE) instruction. | |
void | m25p16_dp () |
Deep Power Down (DP) instruction. | |
void | m25p16_res () |
Release from Deep Power Down (RES) instruction. | |
uint8_t | m25p16_res_res () |
Release from Deep Power Down (RES) and Read Electronic Signature instruction. |
Header file for the control of the M25P16 on sensinode N740s.
Definition in file m25p16.h.
#define M25P16_BP | ( | ) | (m25p16_rdsr() & M25P16_SR_BP) |
#define M25P16_WEL | ( | ) | (m25p16_rdsr() & M25P16_SR_WEL) |
Check for Write-Enable.
1 | Write enabled |
0 | Write disabled |
This macro checks if the device is ready to accept a write instruction by reading the value of the WEL bit (bit 1) in the Status Register
Definition at line 125 of file m25p16.h.
Referenced by m25p16_wren().
#define M25P16_WIP | ( | ) | (m25p16_rdsr() & M25P16_SR_WIP) |
Check for Write in Progress.
1 | Write in progress |
0 | Write not in progress |
This macro checks if the device is currently in the middle of a write cycle by reading the value of the WIP bit (bit 0) in the Status Register
Definition at line 116 of file m25p16.h.
Referenced by m25p16_res(), and m25p16_res_res().
void m25p16_be | ( | ) |
Bulk Erase (SE) instruction.
Delete the entire memory, by setting it's contents to all 0xFF (which will read as 0x00 by READ).
This function will set the WEL bit on the SR before attempting to write, so the calling function doesn't need to worry about this.
This call is asynchronous. It will return before the write cycle has completed. Thus, user software must check the WIP bit Write In Progress) before sending further instructions.
This instructions takes a very long time to complete and must be used with care. It can take up to 40 secs (yes, secs). A typical duration is 13 secs
Definition at line 263 of file m25p16.c.
References m25p16_wren().
void m25p16_dp | ( | ) |
Deep Power Down (DP) instruction.
Puts the device into its lowers power consumption mode (This is not the same as the stand-by mode caused by de-selecting the device). While the device is in DP, it will accept no instruction except a RES (Release from DP).
This call is asynchronous and will return as soon as the instruction sequence has been written but before the device has actually entered DP
Dropping to DP takes 3usec and Resuming from DP takes at least 1.8usec, so this sequence should not be used when the sleep interval is estimated to be short (read as: don't DP then RES then DP repeatedly)
void m25p16_pp | ( | uint8_t * | addr, |
uint8_t * | buff, | ||
uint8_t | buff_len | ||
) |
Program Page (PP) instruction.
addr | 3 byte array holding the write start address. MSB stored in addr[0] and LSB in addr[2] |
buff | Pointer to a buffer with the data to be written |
buff_len | Number of bytes to write, Maximum 256 bytes. |
Write BUFF_LEN bytes stored in BUFF to flash, starting from location ADDR. BUFF_LEN may not exceed 256. ADDR should point to a 3 byte array, with the address MSB stored in position 0 and LSB in position 2
If the start address + buff_len exceed page boundaries, the write will wrap to the start of the same page (the page at addr[2:1]).
The bytes will be inverted before being written, so that a value of 0xFF will be written as 0x00 (and subsequently correctly read as 0xFF by READ)
This function will set the WEL bit on the SR before attempting to write, so the calling function doesn't need to worry about this.
This call is asynchronous. It will return before the write cycle has completed. Thus, user software must check the WIP bit Write In Progress) before sending further instructions. This can take up to 5 msecs (typical duration for a 256 byte write is 640 usec)
Definition at line 224 of file m25p16.c.
References m25p16_wren().
void m25p16_rdid | ( | struct m25p16_rdid * | rdid | ) |
Read Identifier (RDID)instruction.
rdid | Pointer to a struct which will hold the information returned by the RDID instruction |
Definition at line 149 of file m25p16.c.
References m25p16_rdid::mem_size, m25p16_rdid::mem_type, m25p16_rdid::uid, and m25p16_rdid::uid_len.
uint8_t m25p16_rdsr | ( | ) |
void m25p16_read | ( | uint8_t * | addr, |
uint8_t * | buff, | ||
uint8_t | buff_len | ||
) |
Read Data Bytes (READ) instruction.
addr | 3 byte array holding the read start address. MSB stored in addr[0] and LSB in addr[2] |
buff | Pointer to a buffer to hold the read bytes. |
buff_len | Number of bytes to read. buff must be long enough to hold buff_len bytes |
The bytes will be inverted after being read, so that a value of 0xFF (empty) in the flash will read as 0x00
void m25p16_res | ( | ) |
Release from Deep Power Down (RES) instruction.
Take the device out of the Deep Power Down mode and bring it to standby. Does not read the electronic signature.
This call is synchronous. When it returns the device will be in standby mode.
Dropping to DP takes 3usec and Resuming from DP takes at least 1.8usec, so this sequence should not be used when the sleep interval is estimated to be short (read as: don't DP then RES then DP repeatedly)
Definition at line 284 of file m25p16.c.
References M25P16_WIP.
uint8_t m25p16_res_res | ( | ) |
Release from Deep Power Down (RES) and Read Electronic Signature instruction.
Take the device out of the Deep Power Down mode and bring it to standby. Does not read the electronic signature.
This call is synchronous. When it returns the device will be in standby mode.
Dropping to DP takes 3usec and Resuming from DP takes at least 1.8usec, so this sequence should not be used when the sleep interval is estimated to be short (read as: don't DP then RES then DP repeatedly)
Release from Deep Power Down (RES) and Read Electronic Signature instruction.
Read and return the Electronic Signature must return 0x14
Definition at line 299 of file m25p16.c.
References M25P16_WIP.
void m25p16_se | ( | uint8_t | s | ) |
Sector Erase (SE) instruction.
s | The number of the sector to be erased |
Delete the entire sector number s, by setting it's contents to all 0xFF (which will read as 0x00 by READ). The flash is broken down into 32 sectors, 64 KBytes each.
This function will set the WEL bit on the SR before attempting to write, so the calling function doesn't need to worry about this.
This call is asynchronous. It will return before the write cycle has completed. Thus, user software must check the WIP bit Write In Progress) before sending further instructions. This can take up to 3 secs (typical duration 600 msec)
Definition at line 248 of file m25p16.c.
References m25p16_wren().
void m25p16_wren | ( | ) |
Write Enable (WREN) instruction.
Completing a WRDI, PP, SE, BE and WRSR resets the write enable latch bit, so this instruction should be used every time before trying to write.
Definition at line 131 of file m25p16.c.
References M25P16_WEL.
Referenced by m25p16_be(), m25p16_pp(), m25p16_se(), and m25p16_wrsr().
void m25p16_wrsr | ( | uint8_t | val | ) |
Write Status Register (WRSR) instruction.
val | Value to be written to the status register |
This instruction does not afect bits 6, 5, 1 and 0 of the SR.
Definition at line 180 of file m25p16.c.
References m25p16_wren().