Go to the source code of this file.
Macros | |
#define | M25P16_PAGESIZE 256 |
Functions | |
void | m25p16_eraseCompletely () |
void | m25p16_eraseSector (uint32_t address) |
const flashGeometry_t * | m25p16_getGeometry () |
bool | m25p16_init () |
bool | m25p16_isReady () |
void | m25p16_pageProgram (uint32_t address, const uint8_t *data, int length) |
void | m25p16_pageProgramBegin (uint32_t address) |
void | m25p16_pageProgramContinue (const uint8_t *data, int length) |
void | m25p16_pageProgramFinish () |
int | m25p16_readBytes (uint32_t address, uint8_t *buffer, int length) |
bool | m25p16_waitForReady (uint32_t timeoutMillis) |
#define M25P16_PAGESIZE 256 |
Definition at line 27 of file drv_m25p16.h.
void m25p16_eraseCompletely | ( | ) |
Definition at line 243 of file drv_m25p16.c.
void m25p16_eraseSector | ( | uint32_t | address | ) |
Erase a sector full of bytes to all 1's at the given byte offset in the flash chip.
Definition at line 228 of file drv_m25p16.c.
const flashGeometry_t* m25p16_getGeometry | ( | ) |
Fetch information about the detected flash chip layout.
Can be called before calling m25p16_init() (the result would have totalSize = 0).
Definition at line 330 of file drv_m25p16.c.
bool m25p16_init | ( | ) |
Initialize the driver, must be called before any other routines.
Attempts to detect a connected m25p16. If found, true is returned and device capacity can be fetched with m25p16_getGeometry().
Definition at line 217 of file drv_m25p16.c.
bool m25p16_isReady | ( | ) |
Definition at line 128 of file drv_m25p16.c.
void m25p16_pageProgram | ( | uint32_t | address, |
const uint8_t * | data, | ||
int | length | ||
) |
Write bytes to a flash page. Address must not cross a page boundary.
Bits can only be set to zero, not from zero back to one again. In order to set bits to 1, use the erase command.
Length must be smaller than the page size.
This will wait for the flash to become ready before writing begins.
Datasheet indicates typical programming time is 0.8ms for 256 bytes, 0.2ms for 64 bytes, 0.05ms for 16 bytes. (Although the maximum possible write time is noted as 5ms).
If you want to write multiple buffers (whose sum of sizes is still not more than the page size) then you can break this operation up into one beginProgram call, one or more continueProgram calls, and one finishProgram call.
Definition at line 290 of file drv_m25p16.c.
void m25p16_pageProgramBegin | ( | uint32_t | address | ) |
Definition at line 252 of file drv_m25p16.c.
void m25p16_pageProgramContinue | ( | const uint8_t * | data, |
int | length | ||
) |
Definition at line 265 of file drv_m25p16.c.
void m25p16_pageProgramFinish | ( | ) |
Definition at line 270 of file drv_m25p16.c.
int m25p16_readBytes | ( | uint32_t | address, |
uint8_t * | buffer, | ||
int | length | ||
) |
Read length
bytes into the provided buffer
from the flash starting from the given address
(which need not lie on a page boundary).
Waits up to DEFAULT_TIMEOUT_MILLIS milliseconds for the flash to become ready before reading.
The number of bytes actually read is returned, which can be zero if an error or timeout occurred.
Definition at line 307 of file drv_m25p16.c.
bool m25p16_waitForReady | ( | uint32_t | timeoutMillis | ) |
Definition at line 136 of file drv_m25p16.c.