#include <ctype.h>
#include <string.h>
#ifndef WITH_W25Q80BV
#define WITH_W25Q80BV (BSP430_PLATFORM_EXP430F5529LP - 0)
#endif
#if (WITH_W25Q80BV - 0)
#define BSP430_PLATFORM_M25P_SUPPORTS_SSE 1
#define BSP430_PLATFORM_M25P_SECTOR_COUNT 16
#define BSP430_PLATFORM_M25P_SECTOR_SIZE 0x10000
#define BSP430_PLATFORM_M25P_SUBSECTOR_SIZE 0x1000
#if (BSP430_PLATFORM_EXP430F5529LP - 0)
#define BSP430_PLATFORM_M25P_CSn_PORT_PERIPH_HANDLE BSP430_PERIPH_PORT6
#define BSP430_PLATFORM_M25P_CSn_PORT_BIT BIT6
#endif
#endif
const uint8_t flashContents[] = {
0xAA, 0x55, 0x0F, 0xF0, 0xCC, 0x33, 0xC3, 0x3C,
0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF
};
uint8_t buffer[256];
unsigned long addr,
unsigned int len)
{
int rc = -1;
if (len > sizeof(buffer)) {
len = sizeof(buffer);
}
}
return rc;
}
uint8_t cmd,
unsigned long addr,
const uint8_t * data,
unsigned int len)
{
unsigned long t0;
unsigned long t1;
int rc;
int sr;
if (0 == rc) {
}
if (0 == rc) {
}
do {
cprintf(
"Write %d took %lu\n", len, t1 - t0);
return rc;
}
void main ()
{
int rc;
unsigned long addr;
unsigned long t0;
unsigned long t1;
cprintf(
"\nBuild " __DATE__
" " __TIME__
"\n");
#ifdef BSP430_PLATFORM_M25P_PWR_PORT_PERIPH_HANDLE
#else
#endif
#ifdef BSP430_PLATFORM_M25P_RSTn_PORT_PERIPH_HANDLE
#else
#endif
memset(&m25p_data, 0, sizeof(m25p_data));
#ifdef BSP430_PLATFORM_M25P_RSTn_PORT_PERIPH_HANDLE
#endif
if (NULL == m25p) {
cprintf(
"M25P device initialization failed.\n");
return;
}
{
#if (BSP430_MODULE_USCI5 - 0)
#else
void * hpl = NULL;
#endif
int sm = -1;
if (hpl) {
sm = 0;
sm |= 0x02;
}
sm |= 0x01;
}
}
if (0 > sm) {
cprintf(
"Unable to extract SPI mode from %s\n",
} else {
}
}
#ifdef BSP430_PLATFORM_M25P_PWR_PORT_PERIPH_HANDLE
{
}
#endif
if (0 == rc) {
}
cprintf(
"READ_IDENTIFICATION got %d\n", rc);
if (0 <= rc) {
}
cprintf(
"Config identified %u sectors of %lu bytes each: %lu bytes total\n",
#if (BSP430_PLATFORM_M25P_SUBSECTOR_SIZE - 0)
cprintf(
"Config supports access as %u sub-sectors of %u bytes each\n",
#else
cprintf(
"Config indicates device is not sub-sector addressable\n");
#endif
cprintf(
"RDID identified %lu bytes total capacity\n", 0x1UL << buffer[2]);
addr = 0;
rc = readFromAddress(m25p, addr, sizeof(flashContents));
if (sizeof(flashContents) != rc) {
cprintf(
"ERROR %d reading initial block\n", rc);
} else {
if (0 == memcmp(flashContents, buffer, rc)) {
cprintf(
"Found expected contents.\n");
} else {
cprintf(
"Did NOT find expected contents.\n");
}
}
cprintf(
"\nTest pattern (expected contents):");
#if (BSP430_PLATFORM_M25P_SUPPORTS_PE - 0)
cprintf(
"PAGE_ERASE got %d\n", rc);
#else
cprintf(
"SECTOR_ERASE got %d\n", rc);
#endif
rc = readFromAddress(m25p, addr, sizeof(buffer));
if (0 < rc) {
}
rc = writeToAddress(m25p,
BSP430_M25P_CMD_PP, addr, flashContents,
sizeof(flashContents));
cprintf(
"PAGE_PROGRAM got %d\n", rc);
rc = readFromAddress(m25p, addr, sizeof(buffer));
if (0 < rc) {
}
cprintf(
"PAGE_PROGRAM to %lx returned %d\n", addr, rc);
rc = readFromAddress(m25p, 0, sizeof(flashContents));
addr = 8;
#if (BSP430_PLATFORM_M25P_SUPPORTS_PW - 0)
cprintf(
"PAGE_WRITE to %lx returned %d\n", addr, rc);
#else
cprintf(
"overwrite PAGE_PROGRAM to unerased %lx returned %d\n", addr, rc);
#endif
rc = readFromAddress(m25p, 0, sizeof(flashContents));
cprintf(
"Initiating bulk erase...");
t0 = t1 = 0;
if (0 == rc) {
}
if (0 == rc) {
int sr;
do {
}
cprintf(
"\nBULK_ERASE got %d\n", rc);
if (0 == rc) {
}
rc = readFromAddress(m25p, 0, sizeof(flashContents));
addr = 0;
while (addr < (256 * 1025L)) {
rc = readFromAddress(m25p, addr, sizeof(buffer));
if (0 > rc) {
break;
}
addr += rc;
break;
}
}