mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-21 11:54:15 +01:00
Flash: Because on CC/CC3D the flash is initialized before FreeRTOS is started
we cannot use the transaction lock or the delay while saving.
This commit is contained in:
parent
4fc907ad0d
commit
80705cdba1
@ -61,7 +61,9 @@ struct jedec_flash_dev {
|
|||||||
uint32_t device_type;
|
uint32_t device_type;
|
||||||
uint32_t capacity;
|
uint32_t capacity;
|
||||||
const struct pios_flash_jedec_cfg * cfg;
|
const struct pios_flash_jedec_cfg * cfg;
|
||||||
|
#if defined(FLASH_FREERTOS)
|
||||||
xSemaphoreHandle transaction_lock;
|
xSemaphoreHandle transaction_lock;
|
||||||
|
#endif
|
||||||
enum pios_jedec_dev_magic magic;
|
enum pios_jedec_dev_magic magic;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -89,7 +91,9 @@ static struct jedec_flash_dev * PIOS_Flash_Jedec_alloc(void)
|
|||||||
|
|
||||||
jedec_dev->claimed = false;
|
jedec_dev->claimed = false;
|
||||||
jedec_dev->magic = PIOS_JEDEC_DEV_MAGIC;
|
jedec_dev->magic = PIOS_JEDEC_DEV_MAGIC;
|
||||||
|
#if defined(FLASH_FREERTOS)
|
||||||
jedec_dev->transaction_lock = xSemaphoreCreateMutex();
|
jedec_dev->transaction_lock = xSemaphoreCreateMutex();
|
||||||
|
#endif
|
||||||
return(jedec_dev);
|
return(jedec_dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,12 +196,13 @@ int32_t PIOS_Flash_Jedec_Init(uint32_t spi_id, uint32_t slave_num, const struct
|
|||||||
*/
|
*/
|
||||||
int32_t PIOS_Flash_Jedec_StartTransaction()
|
int32_t PIOS_Flash_Jedec_StartTransaction()
|
||||||
{
|
{
|
||||||
|
#if defined(FLASH_FREERTOS)
|
||||||
if(PIOS_Flash_Jedec_Validate(flash_dev) != 0)
|
if(PIOS_Flash_Jedec_Validate(flash_dev) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if(xSemaphoreTake(flash_dev->transaction_lock, portMAX_DELAY) != pdTRUE)
|
if(xSemaphoreTake(flash_dev->transaction_lock, portMAX_DELAY) != pdTRUE)
|
||||||
return -1;
|
return -1;
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,12 +212,13 @@ int32_t PIOS_Flash_Jedec_StartTransaction()
|
|||||||
*/
|
*/
|
||||||
int32_t PIOS_Flash_Jedec_EndTransaction()
|
int32_t PIOS_Flash_Jedec_EndTransaction()
|
||||||
{
|
{
|
||||||
|
#if defined(FLASH_FREERTOS)
|
||||||
if(PIOS_Flash_Jedec_Validate(flash_dev) != 0)
|
if(PIOS_Flash_Jedec_Validate(flash_dev) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if(xSemaphoreGive(flash_dev->transaction_lock) != pdTRUE)
|
if(xSemaphoreGive(flash_dev->transaction_lock) != pdTRUE)
|
||||||
return -1;
|
return -1;
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,8 +294,11 @@ int32_t PIOS_Flash_Jedec_EraseSector(uint32_t addr)
|
|||||||
PIOS_Flash_Jedec_ReleaseBus();
|
PIOS_Flash_Jedec_ReleaseBus();
|
||||||
|
|
||||||
// Keep polling when bus is busy too
|
// Keep polling when bus is busy too
|
||||||
while(PIOS_Flash_Jedec_Busy() != 0)
|
while(PIOS_Flash_Jedec_Busy() != 0) {
|
||||||
|
#if defined(FLASH_FREERTOS)
|
||||||
vTaskDelay(1);
|
vTaskDelay(1);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -320,8 +329,11 @@ int32_t PIOS_Flash_Jedec_EraseChip()
|
|||||||
PIOS_Flash_Jedec_ReleaseBus();
|
PIOS_Flash_Jedec_ReleaseBus();
|
||||||
|
|
||||||
// Keep polling when bus is busy too
|
// Keep polling when bus is busy too
|
||||||
while(PIOS_Flash_Jedec_Busy() != 0)
|
while(PIOS_Flash_Jedec_Busy() != 0) {
|
||||||
|
#if defined(FLASH_FREERTOS)
|
||||||
vTaskDelay(1);
|
vTaskDelay(1);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -374,9 +386,11 @@ int32_t PIOS_Flash_Jedec_WriteData(uint32_t addr, uint8_t * data, uint16_t len)
|
|||||||
PIOS_Flash_Jedec_ReleaseBus();
|
PIOS_Flash_Jedec_ReleaseBus();
|
||||||
|
|
||||||
// Keep polling when bus is busy too
|
// Keep polling when bus is busy too
|
||||||
while(PIOS_Flash_Jedec_Busy() != 0)
|
while(PIOS_Flash_Jedec_Busy() != 0) {
|
||||||
|
#if defined(FLASH_FREERTOS)
|
||||||
vTaskDelay(1);
|
vTaskDelay(1);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@
|
|||||||
#define PIOS_INCLUDE_MS5611
|
#define PIOS_INCLUDE_MS5611
|
||||||
//#define PIOS_INCLUDE_HCSR04
|
//#define PIOS_INCLUDE_HCSR04
|
||||||
#define PIOS_FLASH_ON_ACCEL /* true for second revo */
|
#define PIOS_FLASH_ON_ACCEL /* true for second revo */
|
||||||
|
#define FLASH_FREERTOS
|
||||||
/* Com systems to include */
|
/* Com systems to include */
|
||||||
#define PIOS_INCLUDE_COM
|
#define PIOS_INCLUDE_COM
|
||||||
#define PIOS_INCLUDE_COM_TELEM
|
#define PIOS_INCLUDE_COM_TELEM
|
||||||
|
Loading…
x
Reference in New Issue
Block a user