git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9599 35acf78f-673a-0410-8e92-d51de3d6d3f4

This commit is contained in:
Giovanni Di Sirio 2016-06-07 10:12:08 +00:00
parent 2bc539dc98
commit d151ada9c3
5 changed files with 30 additions and 33 deletions

View File

@ -334,7 +334,7 @@ static flash_error_t m25q_read(void *instance, flash_address_t addr,
} }
/* Bus acquired.*/ /* Bus acquired.*/
jesd216_bus_acquire(devp->config->busp); jesd216_bus_acquire(devp->config->busp, devp->config->buscfg);
/* FLASH_READY state while the operation is performed.*/ /* FLASH_READY state while the operation is performed.*/
devp->state = FLASH_READ; devp->state = FLASH_READ;
@ -371,7 +371,7 @@ static flash_error_t m25q_program(void *instance, flash_address_t addr,
} }
/* Bus acquired.*/ /* Bus acquired.*/
jesd216_bus_acquire(devp->config->busp); jesd216_bus_acquire(devp->config->busp, devp->config->buscfg);
/* FLASH_PGM state while the operation is performed.*/ /* FLASH_PGM state while the operation is performed.*/
devp->state = FLASH_PGM; devp->state = FLASH_PGM;
@ -430,7 +430,7 @@ static flash_error_t m25q_start_erase_all(void *instance) {
} }
/* Bus acquired.*/ /* Bus acquired.*/
jesd216_bus_acquire(devp->config->busp); jesd216_bus_acquire(devp->config->busp, devp->config->buscfg);
/* FLASH_ERASE state while the operation is performed.*/ /* FLASH_ERASE state while the operation is performed.*/
devp->state = FLASH_ERASE; devp->state = FLASH_ERASE;
@ -462,7 +462,7 @@ static flash_error_t m25q_start_erase_sector(void *instance,
} }
/* Bus acquired.*/ /* Bus acquired.*/
jesd216_bus_acquire(devp->config->busp); jesd216_bus_acquire(devp->config->busp, devp->config->buscfg);
/* FLASH_ERASE state while the operation is performed.*/ /* FLASH_ERASE state while the operation is performed.*/
devp->state = FLASH_ERASE; devp->state = FLASH_ERASE;
@ -496,7 +496,7 @@ static flash_error_t m25q_verify_erase(void *instance,
} }
/* Bus acquired.*/ /* Bus acquired.*/
jesd216_bus_acquire(devp->config->busp); jesd216_bus_acquire(devp->config->busp, devp->config->buscfg);
/* FLASH_READY state while the operation is performed.*/ /* FLASH_READY state while the operation is performed.*/
devp->state = FLASH_READ; devp->state = FLASH_READ;
@ -553,7 +553,7 @@ static flash_error_t m25q_query_erase(void *instance, uint32_t *msec) {
if (devp->state == FLASH_ERASE) { if (devp->state == FLASH_ERASE) {
/* Bus acquired.*/ /* Bus acquired.*/
jesd216_bus_acquire(devp->config->busp); jesd216_bus_acquire(devp->config->busp, devp->config->buscfg);
/* Read status command.*/ /* Read status command.*/
jesd216_cmd_receive(devp->config->busp, M25Q_CMD_READ_FLAG_STATUS_REGISTER, jesd216_cmd_receive(devp->config->busp, M25Q_CMD_READ_FLAG_STATUS_REGISTER,
@ -646,7 +646,7 @@ void m25qStart(M25QDriver *devp, const M25QConfig *config) {
if (devp->state == FLASH_STOP) { if (devp->state == FLASH_STOP) {
/* Bus acquisition.*/ /* Bus acquisition.*/
jesd216_bus_acquire(devp->config->busp); jesd216_bus_acquire(devp->config->busp, devp->config->buscfg);
/* Starting bus device.*/ /* Starting bus device.*/
jesd216_start(devp->config->busp, devp->config->buscfg); jesd216_start(devp->config->busp, devp->config->buscfg);
@ -736,7 +736,7 @@ void m25qStop(M25QDriver *devp) {
if (devp->state != FLASH_STOP) { if (devp->state != FLASH_STOP) {
/* Bus acquisition.*/ /* Bus acquisition.*/
jesd216_bus_acquire(devp->config->busp); jesd216_bus_acquire(devp->config->busp, devp->config->buscfg);
/* Stopping bus device.*/ /* Stopping bus device.*/
jesd216_stop(devp->config->busp); jesd216_stop(devp->config->busp);
@ -773,7 +773,7 @@ void m25qMemoryMap(M25QDriver *devp, uint8_t **addrp) {
qspi_command_t cmd; qspi_command_t cmd;
/* Bus acquisition.*/ /* Bus acquisition.*/
jesd216_bus_acquire(devp->config->busp); jesd216_bus_acquire(devp->config->busp, devp->config->buscfg);
/* Activating XIP mode in the device.*/ /* Activating XIP mode in the device.*/
jesd216_cmd(devp->config->busp, M25Q_CMD_WRITE_ENABLE); jesd216_cmd(devp->config->busp, M25Q_CMD_WRITE_ENABLE);
@ -817,7 +817,7 @@ void m25qMemoryMap(M25QDriver *devp, uint8_t **addrp) {
void m25qMemoryUnmap(M25QDriver *devp) { void m25qMemoryUnmap(M25QDriver *devp) {
/* Bus acquisition.*/ /* Bus acquisition.*/
jesd216_bus_acquire(devp->config->busp); jesd216_bus_acquire(devp->config->busp, devp->config->buscfg);
qspiUnmapFlash(devp->config->busp); qspiUnmapFlash(devp->config->busp);

View File

@ -332,7 +332,9 @@ void jesd216_cmd_addr_dummy_receive(BUSDriver *busp,
#if ((JESD216_BUS_MODE != JESD216_BUS_MODE_SPI) && \ #if ((JESD216_BUS_MODE != JESD216_BUS_MODE_SPI) && \
(JESD216_SHARED_BUS == TRUE)) || defined(__DOXYGEN__) (JESD216_SHARED_BUS == TRUE)) || defined(__DOXYGEN__)
void jesd216_bus_acquire(BUSDriver *busp) { void jesd216_bus_acquire(BUSDriver *busp, BUSConfig *config) {
(void)config;
qspiAcquireBus(busp); qspiAcquireBus(busp);
} }
@ -343,13 +345,13 @@ void jesd216_bus_release(BUSDriver *busp) {
} }
#elif (JESD216_BUS_MODE == JESD216_BUS_MODE_SPI) && \ #elif (JESD216_BUS_MODE == JESD216_BUS_MODE_SPI) && \
(JESD216_SHARED_BUS == TRUE) (JESD216_SHARED_BUS == TRUE)
static void jesd216_bus_acquire(BUSDriver *busp) { void jesd216_bus_acquire(BUSDriver *busp, const BUSConfig *config) {
spiAcquireBus(busp); spiAcquireBus(busp);
spiStart(busp, busp->config->spicfg); spiStart(busp, config);
} }
static void jesd216_bus_release(BUSDriver *busp) { void jesd216_bus_release(BUSDriver *busp) {
spiReleaseBus(busp); spiReleaseBus(busp);
} }

View File

@ -78,7 +78,7 @@
/** /**
* @brief Physical transport interface. * @brief Physical transport interface.
*/ */
#if !defined(JESD216_USE_SPI) || defined(__DOXYGEN__) #if !defined(JESD216_BUS_MODE) || defined(__DOXYGEN__)
#define JESD216_BUS_MODE JESD216_BUS_MODE_QSPI4L #define JESD216_BUS_MODE JESD216_BUS_MODE_QSPI4L
#endif #endif
@ -107,7 +107,7 @@
#endif #endif
#if (JESD216_BUS_MODE == JESD216_BUS_MODE_SPI) && \ #if (JESD216_BUS_MODE == JESD216_BUS_MODE_SPI) && \
(JESD216_SHARED_SPI == TRUE) && \ (JESD216_SHARED_BUS == TRUE) && \
(SPI_USE_MUTUAL_EXCLUSION == FALSE) (SPI_USE_MUTUAL_EXCLUSION == FALSE)
#error "JESD216_SHARED_SPI requires SPI_USE_MUTUAL_EXCLUSION" #error "JESD216_SHARED_SPI requires SPI_USE_MUTUAL_EXCLUSION"
#endif #endif
@ -209,7 +209,7 @@ extern "C" {
size_t n, uint8_t *p); size_t n, uint8_t *p);
#endif /* JESD216_BUS_MODE != JESD216_BUS_MODE_SPI */ #endif /* JESD216_BUS_MODE != JESD216_BUS_MODE_SPI */
#if JESD216_SHARED_BUS == TRUE #if JESD216_SHARED_BUS == TRUE
void jesd216_bus_acquire(BUSDriver *busp); void jesd216_bus_acquire(BUSDriver *busp, const BUSConfig *config);
void jesd216_bus_release(BUSDriver *busp); void jesd216_bus_release(BUSDriver *busp);
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -98,7 +98,7 @@ include $(CHIBIOS)/os/hal/osal/rt/osal.mk
include $(CHIBIOS)/os/rt/rt.mk include $(CHIBIOS)/os/rt/rt.mk
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
# Other files (optional). # Other files (optional).
include $(CHIBIOS)/os/ex/Micron/n25q128_spi.mk include $(CHIBIOS)/os/ex/Micron/m25q.mk
include $(CHIBIOS)/os/ex/subsystems/mfs/mfs.mk include $(CHIBIOS)/os/ex/subsystems/mfs/mfs.mk
# Define linker script file here # Define linker script file here
@ -113,8 +113,8 @@ CSRC = $(STARTUPSRC) \
$(HALSRC) \ $(HALSRC) \
$(PLATFORMSRC) \ $(PLATFORMSRC) \
$(BOARDSRC) \ $(BOARDSRC) \
$(N25Q128SRC) \ $(STREAMSSRC) \
$(MFSSRC) \ $(M25QSRC) \
main.c main.c
# C++ sources that can be compiled in ARM or THUMB mode depending on the global # C++ sources that can be compiled in ARM or THUMB mode depending on the global
@ -147,8 +147,8 @@ ASMXSRC = $(STARTUPASM) $(PORTASM) $(OSALASM)
INCDIR = $(CHIBIOS)/os/license \ INCDIR = $(CHIBIOS)/os/license \
$(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \ $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
$(HALINC) $(PLATFORMINC) $(BOARDINC) \ $(HALINC) $(PLATFORMINC) $(BOARDINC) $(M25QINC) \
$(N25Q128INC) $(MFSINC) $(STREAMSINC) $(CHIBIOS)/os/various
# #
# Project, sources and paths # Project, sources and paths
@ -198,7 +198,7 @@ CPPWARN = -Wall -Wextra -Wundef
# #
# List all user C define here, like -D_DEBUG=1 # List all user C define here, like -D_DEBUG=1
UDEFS = -DCHPRINTF_USE_FLOAT=1 UDEFS = -DCHPRINTF_USE_FLOAT=1 -DJESD216_BUS_MODE=JESD216_BUS_MODE_SPI
# Define ASM defines here # Define ASM defines here
UADEFS = UADEFS =

View File

@ -17,7 +17,7 @@
#include "ch.h" #include "ch.h"
#include "hal.h" #include "hal.h"
#include "n25q128_spi.h" #include "m25q.h"
/* /*
* Maximum speed SPI configuration (18MHz, CPHA=0, CPOL=0, MSb first). * Maximum speed SPI configuration (18MHz, CPHA=0, CPOL=0, MSb first).
@ -33,7 +33,7 @@ static const SPIConfig hs_spicfg = {
/* /*
* Flash driver configuration. * Flash driver configuration.
*/ */
static const N25Q128Config flashcfg = { static const M25QConfig flashcfg = {
&SPID2, &SPID2,
&hs_spicfg &hs_spicfg
}; };
@ -41,7 +41,7 @@ static const N25Q128Config flashcfg = {
/* /*
* Flash driver object. * Flash driver object.
*/ */
static N25Q128Driver flash; static M25QDriver flash;
/* /*
* Generic buffer. * Generic buffer.
@ -111,13 +111,8 @@ int main(void) {
/* /*
* Initializing and starting flash driver. * Initializing and starting flash driver.
*/ */
n25q128ObjectInit(&flash); m25qObjectInit(&flash);
n25q128Start(&flash, &flashcfg); m25qStart(&flash, &flashcfg);
/*
* Reading flash identifier.
*/
n25q128ReadId(&flash, buffer, 17);
/* Programming a pattern.*/ /* Programming a pattern.*/
err = flashProgram(&flash, 0, pattern, 128); err = flashProgram(&flash, 0, pattern, 128);