📄 m54455evb_spiflash_test.c
字号:
/*! * \file spiflash_test.c * \brief Test the SPI Flash interface on the M54455EVB (aka Jamaica) * \version $Revision: 1.1 $ * \author Michael Norman */ #include "common.h"#include "dspi.h"#include "m54455evb_fat.h"/********************************************************************//* * Instruction/Command Codes */#define SPIFLASH_WREN 0x06#define SPIFLASH_WRDI 0x04#define SPIFLASH_RDID 0x9F#define SPIFLASH_RDSR 0x05#define SPIFLASH_WRSR 0x01#define SPIFLASH_READ 0x03#define SPIFLASH_FAST_READ 0x0B#define SPIFLASH_PP 0x02#define SPIFLASH_SE 0xD8#define SPIFLASH_BE 0xC7#define SPIFLASH_DP 0xB9#define SPIFLASH_RES 0xAB/* * Serial Flash Status Register */#define SPIFLASH_SR_SRWD 0x80#define SPIFLASH_SR_BP2 0x10#define SPIFLASH_SR_BP1 0x08#define SPIFLASH_SR_BP0 0x04#define SPIFLASH_SR_WEL 0x02#define SPIFLASH_SR_WIP 0x01#define SPIFLASH_SR_BP(x) ((x & 0x7) << 2)/********************************************************************//*! * \brief SPI Flash Test * \return 0 if the tests was successful; non-zero otherwise */intspiflash_test (void){ uint16 rxdata[20]; dspi_init(); /* Read SR */ while ((MCF_DSPI_DSR & 0x000000F0) != 0) {dspi_rx();} dspi_tx(SPIFLASH_RDSR, 1, 0x80); dspi_rx(); dspi_tx(0, 1, 0x00); rxdata[0] = dspi_rx(); if ((MCF_DSPI_DSR & 0x000000F0) != 0) return 1; /* Read ID */ dspi_tx(SPIFLASH_RDID, 1, 0x80); dspi_tx(0, 1, 0x80); dspi_tx(0, 1, 0x80); dspi_tx(0, 1, 0x00); dspi_rx(); rxdata[0] = dspi_rx(); rxdata[1] = dspi_rx(); rxdata[2] = dspi_rx(); if (rxdata[0] != 0x20 || rxdata[1] != 0x20 || rxdata[2] != 0x15) return 2; /* pass */ return 0;}/********************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -