git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9519 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
8c8a1441fd
commit
c0c9fe70b0
|
@ -565,21 +565,151 @@ static flash_error_t program(void *instance, flash_address_t addr,
|
||||||
}
|
}
|
||||||
|
|
||||||
static flash_error_t start_erase_all(void *instance) {
|
static flash_error_t start_erase_all(void *instance) {
|
||||||
|
M25QDriver *devp = (M25QDriver *)instance;
|
||||||
|
|
||||||
|
osalDbgCheck(instance != NULL);
|
||||||
|
osalDbgAssert((devp->state == FLASH_READY) || (devp->state == FLASH_ERASE),
|
||||||
|
"invalid state");
|
||||||
|
|
||||||
|
if (devp->state == FLASH_ERASE) {
|
||||||
|
return FLASH_BUSY_ERASING;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Bus acquired.*/
|
||||||
|
flash_bus_acquire(devp);
|
||||||
|
|
||||||
|
/* FLASH_ERASE state while the operation is performed.*/
|
||||||
|
devp->state = FLASH_ERASE;
|
||||||
|
|
||||||
|
/* Enabling write operation.*/
|
||||||
|
flash_cmd(devp, M25Q_CMD_WRITE_ENABLE);
|
||||||
|
|
||||||
|
/* Bulk erase command.*/
|
||||||
|
flash_cmd(devp, M25Q_CMD_BULK_ERASE);
|
||||||
|
|
||||||
|
/* Ready state again.*/
|
||||||
|
devp->state = FLASH_READY;
|
||||||
|
|
||||||
|
/* Bus released.*/
|
||||||
|
flash_bus_release(devp);
|
||||||
|
|
||||||
return FLASH_NO_ERROR;
|
return FLASH_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static flash_error_t start_erase_sector(void *instance, flash_sector_t sector) {
|
static flash_error_t start_erase_sector(void *instance, flash_sector_t sector) {
|
||||||
|
M25QDriver *devp = (M25QDriver *)instance;
|
||||||
|
flash_address_t addr = (flash_address_t)(sector * SECTOR_SIZE);
|
||||||
|
|
||||||
|
osalDbgCheck(instance != NULL);
|
||||||
|
osalDbgCheck(sector < descriptor.sectors_count);
|
||||||
|
osalDbgAssert((devp->state == FLASH_READY) || (devp->state == FLASH_ERASE),
|
||||||
|
"invalid state");
|
||||||
|
|
||||||
|
if (devp->state == FLASH_ERASE) {
|
||||||
|
return FLASH_BUSY_ERASING;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Bus acquired.*/
|
||||||
|
flash_bus_acquire(devp);
|
||||||
|
|
||||||
|
/* FLASH_ERASE state while the operation is performed.*/
|
||||||
|
devp->state = FLASH_ERASE;
|
||||||
|
|
||||||
|
/* Enabling write operation.*/
|
||||||
|
flash_cmd(devp, M25Q_CMD_WRITE_ENABLE);
|
||||||
|
|
||||||
|
/* Sector erase command.*/
|
||||||
|
flash_cmd_addr(devp, M25Q_CMD_SECTOR_ERASE, addr);
|
||||||
|
|
||||||
|
/* Ready state again.*/
|
||||||
|
devp->state = FLASH_READY;
|
||||||
|
|
||||||
|
/* Bus released.*/
|
||||||
|
flash_bus_release(devp);
|
||||||
|
|
||||||
return FLASH_NO_ERROR;
|
return FLASH_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static flash_error_t verify_erase(void *instance, flash_sector_t sector) {
|
static flash_error_t verify_erase(void *instance, flash_sector_t sector) {
|
||||||
|
M25QDriver *devp = (M25QDriver *)instance;
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
|
osalDbgCheck(instance != NULL);
|
||||||
|
osalDbgCheck(sector < descriptor.sectors_count);
|
||||||
|
osalDbgAssert((devp->state == FLASH_READY) || (devp->state == FLASH_ERASE),
|
||||||
|
"invalid state");
|
||||||
|
|
||||||
|
if (devp->state == FLASH_ERASE) {
|
||||||
|
return FLASH_BUSY_ERASING;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Bus acquired.*/
|
||||||
|
flash_bus_acquire(devp);
|
||||||
|
|
||||||
|
/* FLASH_READY state while the operation is performed.*/
|
||||||
|
devp->state = FLASH_READ;
|
||||||
|
|
||||||
|
/* Read command.*/
|
||||||
|
|
||||||
|
/* Ready state again.*/
|
||||||
|
devp->state = FLASH_READY;
|
||||||
|
|
||||||
|
/* Bus released.*/
|
||||||
|
flash_bus_release(devp);
|
||||||
|
|
||||||
return FLASH_NO_ERROR;
|
return FLASH_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static flash_error_t query_erase(void *instance, uint32_t *msec) {
|
static flash_error_t query_erase(void *instance, uint32_t *msec) {
|
||||||
|
M25QDriver *devp = (M25QDriver *)instance;
|
||||||
|
uint8_t sts;
|
||||||
|
|
||||||
|
osalDbgCheck(instance != NULL);
|
||||||
|
osalDbgAssert((devp->state == FLASH_READY) || (devp->state == FLASH_ERASE),
|
||||||
|
"invalid state");
|
||||||
|
|
||||||
|
/* If there is an erase in progress then the device must be checked.*/
|
||||||
|
if (devp->state == FLASH_ERASE) {
|
||||||
|
|
||||||
|
/* Bus acquired.*/
|
||||||
|
flash_bus_acquire(devp);
|
||||||
|
|
||||||
|
/* Read status command.*/
|
||||||
|
flash_cmd_receive(devp, M25Q_CMD_READ_FLAG_STATUS_REGISTER, 1, &sts);
|
||||||
|
|
||||||
|
/* If the P/E bit is zero (busy) or the flash in a suspended state then
|
||||||
|
report that the operation is still in progress.*/
|
||||||
|
if (((sts & M25Q_FLAGS_PROGRAM_ERASE) == 0U) ||
|
||||||
|
((sts & M25Q_FLAGS_ERASE_SUSPEND) != 0U)) {
|
||||||
|
|
||||||
|
/* Bus released.*/
|
||||||
|
flash_bus_release(devp);
|
||||||
|
|
||||||
|
/* Recommended time before polling again, this is a simplified
|
||||||
|
implementation.*/
|
||||||
|
if (msec != NULL) {
|
||||||
|
*msec = 1U;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FLASH_BUSY_ERASING;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The device is ready to accept commands.*/
|
||||||
|
devp->state = FLASH_READY;
|
||||||
|
|
||||||
|
/* Checking for errors.*/
|
||||||
|
if ((sts & M25Q_FLAGS_ALL_ERRORS) != 0U) {
|
||||||
|
|
||||||
|
/* Clearing status register.*/
|
||||||
|
flash_cmd(devp, M25Q_CMD_CLEAR_FLAG_STATUS_REGISTER);
|
||||||
|
|
||||||
|
/* Erase operation failed.*/
|
||||||
|
return FLASH_ERROR_ERASE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Bus released.*/
|
||||||
|
flash_bus_release(devp);
|
||||||
|
}
|
||||||
|
|
||||||
return FLASH_NO_ERROR;
|
return FLASH_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
|
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
|
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
|
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList><content id="CCR-qspi-qspip-qspi_lld_receive-(format)" val="4"/><content id="cfg-cmdp-qspi_lld_receive-(format)" val="4"/><content id="id[2]-id-m25qStart-(format)" val="4"/><content id="id[1]-id-m25qStart-(format)" val="4"/><content id="id[0]-id-m25qStart-(format)" val="4"/><content id="AFRL-gpiop-initgpio-(format)" val="4"/><content id="AFRH-gpiop-initgpio-(format)" val="4"/><content id="ODR-gpiop-initgpio-(format)" val="4"/><content id="IDR-gpiop-initgpio-(format)" val="4"/><content id="PUPDR-gpiop-initgpio-(format)" val="4"/><content id="OSPEEDR-gpiop-initgpio-(format)" val="4"/><content id="MODER-gpiop-initgpio-(format)" val="4"/><content id="afrh-config-initgpio-(format)" val="4"/><content id="moder-config-initgpio-(format)" val="4"/><content id="config-initgpio-(format)" val="4"/><content id="r2-(format)" val="4"/><content id="cfg-cmdp-qspiReceive-(format)" val="4"/><content id="CCR-qspi-qspip-qspi_lld_send-(format)" val="4"/><content id="CR-qspi-qspip-qspi_lld_send-(format)" val="4"/><content id="cfg-cmdp-qspiSend-(format)" val="4"/><content id="CR2-adc-adcp-adc_lld_start_conversion-(format)" val="4"/><content id="CR2-adc-null-port_wait_for_interrupt-(format)" val="4"/><content id="cr2-adc_lld_start_conversion-(format)" val="4"/><content id="cmd-flash_cmd_receive-(format)" val="4"/></contentList>"/>
|
<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList><content id="cmd-flash_cmd_receive-(format)" val="4"/><content id="cr2-adc_lld_start_conversion-(format)" val="4"/><content id="CR2-adc-null-port_wait_for_interrupt-(format)" val="4"/><content id="CR2-adc-adcp-adc_lld_start_conversion-(format)" val="4"/><content id="cfg-cmdp-qspiSend-(format)" val="4"/><content id="CR-qspi-qspip-qspi_lld_send-(format)" val="4"/><content id="CCR-qspi-qspip-qspi_lld_send-(format)" val="4"/><content id="cfg-cmdp-qspiReceive-(format)" val="4"/><content id="r2-(format)" val="4"/><content id="config-initgpio-(format)" val="4"/><content id="moder-config-initgpio-(format)" val="4"/><content id="afrh-config-initgpio-(format)" val="4"/><content id="MODER-gpiop-initgpio-(format)" val="4"/><content id="OSPEEDR-gpiop-initgpio-(format)" val="4"/><content id="PUPDR-gpiop-initgpio-(format)" val="4"/><content id="IDR-gpiop-initgpio-(format)" val="4"/><content id="ODR-gpiop-initgpio-(format)" val="4"/><content id="AFRH-gpiop-initgpio-(format)" val="4"/><content id="AFRL-gpiop-initgpio-(format)" val="4"/><content id="id[0]-id-m25qStart-(format)" val="4"/><content id="id[1]-id-m25qStart-(format)" val="4"/><content id="id[2]-id-m25qStart-(format)" val="4"/><content id="cfg-cmdp-qspi_lld_receive-(format)" val="4"/><content id="CCR-qspi-qspip-qspi_lld_receive-(format)" val="4"/></contentList>"/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <globalVariableList/> "/>
|
<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <globalVariableList/> "/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList/> "/>
|
<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList/> "/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="./build/ch.elf"/>
|
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="./build/ch.elf"/>
|
||||||
|
|
Loading…
Reference in New Issue