diff options
| author | Giovanni Di Sirio <gdisirio@gmail.com> | 2016-06-07 10:12:08 +0000 | 
|---|---|---|
| committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2016-06-07 10:12:08 +0000 | 
| commit | d151ada9c34470d74729e9d00467a40970e5beae (patch) | |
| tree | fdf6bffd7db41cb395931e22c8c9a95e245c47d7 | |
| parent | 2bc539dc98841f5fd04f77475e5687913c11e88f (diff) | |
| download | ChibiOS-d151ada9c34470d74729e9d00467a40970e5beae.tar.gz ChibiOS-d151ada9c34470d74729e9d00467a40970e5beae.tar.bz2 ChibiOS-d151ada9c34470d74729e9d00467a40970e5beae.zip | |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9599 35acf78f-673a-0410-8e92-d51de3d6d3f4
| -rw-r--r-- | os/ex/Micron/m25q.c | 20 | ||||
| -rw-r--r-- | os/hal/lib/peripherals/flash/hal_jesd216_flash.c | 10 | ||||
| -rw-r--r-- | os/hal/lib/peripherals/flash/hal_jesd216_flash.h | 6 | ||||
| -rw-r--r-- | testhal/STM32/STM32F3xx/SPI-N25Q128/Makefile | 12 | ||||
| -rw-r--r-- | testhal/STM32/STM32F3xx/SPI-N25Q128/main.c | 15 | 
5 files changed, 30 insertions, 33 deletions
| diff --git a/os/ex/Micron/m25q.c b/os/ex/Micron/m25q.c index a8fcf1d92..7a2d9a760 100644 --- a/os/ex/Micron/m25q.c +++ b/os/ex/Micron/m25q.c @@ -334,7 +334,7 @@ static flash_error_t m25q_read(void *instance, flash_address_t addr,    }    /* 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.*/    devp->state = FLASH_READ; @@ -371,7 +371,7 @@ static flash_error_t m25q_program(void *instance, flash_address_t addr,    }    /* 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.*/    devp->state = FLASH_PGM; @@ -430,7 +430,7 @@ static flash_error_t m25q_start_erase_all(void *instance) {    }    /* 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.*/    devp->state = FLASH_ERASE; @@ -462,7 +462,7 @@ static flash_error_t m25q_start_erase_sector(void *instance,    }    /* 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.*/    devp->state = FLASH_ERASE; @@ -496,7 +496,7 @@ static flash_error_t m25q_verify_erase(void *instance,    }    /* 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.*/    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) {      /* Bus acquired.*/ -    jesd216_bus_acquire(devp->config->busp); +    jesd216_bus_acquire(devp->config->busp, devp->config->buscfg);      /* Read status command.*/      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) {      /* Bus acquisition.*/ -    jesd216_bus_acquire(devp->config->busp); +    jesd216_bus_acquire(devp->config->busp, devp->config->buscfg);      /* Starting bus device.*/      jesd216_start(devp->config->busp, devp->config->buscfg); @@ -736,7 +736,7 @@ void m25qStop(M25QDriver *devp) {    if (devp->state != FLASH_STOP) {      /* Bus acquisition.*/ -    jesd216_bus_acquire(devp->config->busp); +    jesd216_bus_acquire(devp->config->busp, devp->config->buscfg);      /* Stopping bus device.*/      jesd216_stop(devp->config->busp); @@ -773,7 +773,7 @@ void m25qMemoryMap(M25QDriver *devp, uint8_t **addrp) {    qspi_command_t cmd;    /* Bus acquisition.*/ -  jesd216_bus_acquire(devp->config->busp); +  jesd216_bus_acquire(devp->config->busp, devp->config->buscfg);    /* Activating XIP mode in the device.*/    jesd216_cmd(devp->config->busp, M25Q_CMD_WRITE_ENABLE); @@ -817,7 +817,7 @@ void m25qMemoryMap(M25QDriver *devp, uint8_t **addrp) {  void m25qMemoryUnmap(M25QDriver *devp) {    /* Bus acquisition.*/ -  jesd216_bus_acquire(devp->config->busp); +  jesd216_bus_acquire(devp->config->busp, devp->config->buscfg);    qspiUnmapFlash(devp->config->busp); diff --git a/os/hal/lib/peripherals/flash/hal_jesd216_flash.c b/os/hal/lib/peripherals/flash/hal_jesd216_flash.c index 53f458c03..58212a2a1 100644 --- a/os/hal/lib/peripherals/flash/hal_jesd216_flash.c +++ b/os/hal/lib/peripherals/flash/hal_jesd216_flash.c @@ -332,7 +332,9 @@ void jesd216_cmd_addr_dummy_receive(BUSDriver *busp,  #if ((JESD216_BUS_MODE != JESD216_BUS_MODE_SPI) &&                          \
       (JESD216_SHARED_BUS == TRUE)) || defined(__DOXYGEN__)
 -void jesd216_bus_acquire(BUSDriver *busp) {
 +void jesd216_bus_acquire(BUSDriver *busp, BUSConfig *config) {
 +
 +  (void)config;
    qspiAcquireBus(busp);
  }
 @@ -343,13 +345,13 @@ void jesd216_bus_release(BUSDriver *busp) {  }
  #elif (JESD216_BUS_MODE == JESD216_BUS_MODE_SPI) &&                         \
        (JESD216_SHARED_BUS == TRUE)
 -static void jesd216_bus_acquire(BUSDriver *busp) {
 +void jesd216_bus_acquire(BUSDriver *busp, const BUSConfig *config) {
    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);
  }
 diff --git a/os/hal/lib/peripherals/flash/hal_jesd216_flash.h b/os/hal/lib/peripherals/flash/hal_jesd216_flash.h index bb2214e81..1cff3cc32 100644 --- a/os/hal/lib/peripherals/flash/hal_jesd216_flash.h +++ b/os/hal/lib/peripherals/flash/hal_jesd216_flash.h @@ -78,7 +78,7 @@  /**
   * @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
  #endif
 @@ -107,7 +107,7 @@  #endif
  #if (JESD216_BUS_MODE == JESD216_BUS_MODE_SPI) &&                           \
 -    (JESD216_SHARED_SPI == TRUE) &&                                         \
 +    (JESD216_SHARED_BUS == TRUE) &&                                         \
      (SPI_USE_MUTUAL_EXCLUSION == FALSE)
  #error "JESD216_SHARED_SPI requires SPI_USE_MUTUAL_EXCLUSION"
  #endif
 @@ -209,7 +209,7 @@ extern "C" {                                        size_t n, uint8_t *p);
  #endif /* JESD216_BUS_MODE != JESD216_BUS_MODE_SPI */
  #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);
  #endif
  #ifdef __cplusplus
 diff --git a/testhal/STM32/STM32F3xx/SPI-N25Q128/Makefile b/testhal/STM32/STM32F3xx/SPI-N25Q128/Makefile index da75f7dc1..bc34444bd 100644 --- a/testhal/STM32/STM32F3xx/SPI-N25Q128/Makefile +++ b/testhal/STM32/STM32F3xx/SPI-N25Q128/Makefile @@ -98,7 +98,7 @@ include $(CHIBIOS)/os/hal/osal/rt/osal.mk  include $(CHIBIOS)/os/rt/rt.mk
  include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
  # 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
  # Define linker script file here
 @@ -113,8 +113,8 @@ CSRC = $(STARTUPSRC) \         $(HALSRC) \
         $(PLATFORMSRC) \
         $(BOARDSRC) \
 -       $(N25Q128SRC) \
 -       $(MFSSRC) \
 +       $(STREAMSSRC) \
 +       $(M25QSRC) \
         main.c
  # 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 \
           $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
 -         $(HALINC) $(PLATFORMINC) $(BOARDINC) \
 -         $(N25Q128INC) $(MFSINC)
 +         $(HALINC) $(PLATFORMINC) $(BOARDINC) $(M25QINC) \
 +         $(STREAMSINC) $(CHIBIOS)/os/various
  #
  # Project, sources and paths
 @@ -198,7 +198,7 @@ CPPWARN = -Wall -Wextra -Wundef  #
  # 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
  UADEFS =
 diff --git a/testhal/STM32/STM32F3xx/SPI-N25Q128/main.c b/testhal/STM32/STM32F3xx/SPI-N25Q128/main.c index daababdf8..ebdadf1d8 100644 --- a/testhal/STM32/STM32F3xx/SPI-N25Q128/main.c +++ b/testhal/STM32/STM32F3xx/SPI-N25Q128/main.c @@ -17,7 +17,7 @@  #include "ch.h"
  #include "hal.h"
 -#include "n25q128_spi.h"
 +#include "m25q.h"
  /*
   * Maximum speed SPI configuration (18MHz, CPHA=0, CPOL=0, MSb first).
 @@ -33,7 +33,7 @@ static const SPIConfig hs_spicfg = {  /*
   * Flash driver configuration.
   */
 -static const N25Q128Config flashcfg = {
 +static const M25QConfig flashcfg = {
    &SPID2,
    &hs_spicfg
  };
 @@ -41,7 +41,7 @@ static const N25Q128Config flashcfg = {  /*
   * Flash driver object.
   */
 -static N25Q128Driver flash;
 +static M25QDriver flash;
  /*
   * Generic buffer.
 @@ -111,13 +111,8 @@ int main(void) {    /*
     * Initializing and starting flash driver.
     */
 -  n25q128ObjectInit(&flash);
 -  n25q128Start(&flash, &flashcfg);
 -
 -  /*
 -   * Reading flash identifier.
 -   */
 -  n25q128ReadId(&flash, buffer, 17);
 +  m25qObjectInit(&flash);
 +  m25qStart(&flash, &flashcfg);
    /* Programming a pattern.*/
    err = flashProgram(&flash, 0, pattern, 128);
 | 
