1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

flash: use uintptr_t to hold opaque pointers

When storing an opaque pointer value in a uint, the
appropriate type is uintptr_t which is guaranteed to
be wide enough to hold a pointer.

This is particularly important when the code can be
compiled in a sim or unit test environment which is
intended to run on a 64-bit machine.

Conflicts:
	flight/PiOS/Common/pios_flash_jedec.c
	flight/targets/DiscoveryF4/System/pios_board.c
	flight/targets/FlyingF4/System/pios_board.c
	flight/targets/Freedom/System/pios_board.c
	flight/targets/Quanton/System/pios_board.c
This commit is contained in:
Stacey Sheldon 2012-12-14 23:13:33 -05:00 committed by Alessio Morale
parent dd5f4b949c
commit 17b8696261
12 changed files with 104 additions and 104 deletions

View File

@ -13,19 +13,19 @@
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "pios.h"
@ -86,10 +86,10 @@ static int32_t PIOS_Flash_Jedec_Busy(struct jedec_flash_dev * flash_dev);
static struct jedec_flash_dev * PIOS_Flash_Jedec_alloc(void)
{
struct jedec_flash_dev * flash_dev;
flash_dev = (struct jedec_flash_dev *)pvPortMalloc(sizeof(*flash_dev));
if (!flash_dev) return (NULL);
flash_dev->claimed = false;
flash_dev->magic = PIOS_JEDEC_DEV_MAGIC;
#if defined(FLASH_FREERTOS)
@ -114,7 +114,7 @@ static int32_t PIOS_Flash_Jedec_Validate(struct jedec_flash_dev * flash_dev) {
/**
* @brief Initialize the flash device and enable write access
*/
int32_t PIOS_Flash_Jedec_Init(uint32_t * flash_id, uint32_t spi_id, uint32_t slave_num, const struct pios_flash_jedec_cfg * cfg)
int32_t PIOS_Flash_Jedec_Init(uintptr_t * flash_id, uint32_t spi_id, uint32_t slave_num, const struct pios_flash_jedec_cfg * cfg)
{
struct jedec_flash_dev * flash_dev = PIOS_Flash_Jedec_alloc();
if (flash_dev == NULL)
@ -129,7 +129,7 @@ int32_t PIOS_Flash_Jedec_Init(uint32_t * flash_id, uint32_t spi_id, uint32_t sla
return -1;
/* Give back a handle to this flash device */
*flash_id = (uint32_t) flash_dev;
*flash_id = (uintptr_t) flash_dev;
return 0;
}
@ -141,12 +141,12 @@ int32_t PIOS_Flash_Jedec_Init(uint32_t * flash_id, uint32_t spi_id, uint32_t sla
*/
static int32_t PIOS_Flash_Jedec_ClaimBus(struct jedec_flash_dev * flash_dev)
{
if(PIOS_SPI_ClaimBus(flash_dev->spi_id) < 0)
if (PIOS_SPI_ClaimBus(flash_dev->spi_id) < 0)
return -1;
PIOS_SPI_RC_PinSet(flash_dev->spi_id, flash_dev->slave_num, 0);
flash_dev->claimed = true;
return 0;
}
@ -246,15 +246,15 @@ static int32_t PIOS_Flash_Jedec_ReadID(struct jedec_flash_dev * flash_dev)
* @brief Grab the semaphore to perform a transaction
* @return 0 for success, -1 for timeout
*/
static int32_t PIOS_Flash_Jedec_StartTransaction(uint32_t flash_id)
static int32_t PIOS_Flash_Jedec_StartTransaction(uintptr_t flash_id)
{
struct jedec_flash_dev * flash_dev = (struct jedec_flash_dev *)flash_id;
if(PIOS_Flash_Jedec_Validate(flash_dev) != 0)
if (PIOS_Flash_Jedec_Validate(flash_dev) != 0)
return -1;
#if defined(PIOS_INCLUDE_FREERTOS)
if(xSemaphoreTake(flash_dev->transaction_lock, portMAX_DELAY) != pdTRUE)
if (xSemaphoreTake(flash_dev->transaction_lock, portMAX_DELAY) != pdTRUE)
return -2;
#endif
@ -265,15 +265,15 @@ static int32_t PIOS_Flash_Jedec_StartTransaction(uint32_t flash_id)
* @brief Release the semaphore to perform a transaction
* @return 0 for success, -1 for timeout
*/
static int32_t PIOS_Flash_Jedec_EndTransaction(uint32_t flash_id)
static int32_t PIOS_Flash_Jedec_EndTransaction(uintptr_t flash_id)
{
struct jedec_flash_dev * flash_dev = (struct jedec_flash_dev *)flash_id;
if(PIOS_Flash_Jedec_Validate(flash_dev) != 0)
if (PIOS_Flash_Jedec_Validate(flash_dev) != 0)
return -1;
#if defined(PIOS_INCLUDE_FREERTOS)
if(xSemaphoreGive(flash_dev->transaction_lock) != pdTRUE)
if (xSemaphoreGive(flash_dev->transaction_lock) != pdTRUE)
return -2;
#endif
@ -282,16 +282,16 @@ static int32_t PIOS_Flash_Jedec_EndTransaction(uint32_t flash_id)
#else /* FLASH_USE_FREERTOS_LOCKS */
static int32_t PIOS_Flash_Jedec_StartTransaction(uint32_t flash_id)
static int32_t PIOS_Flash_Jedec_StartTransaction(uintptr_t flash_id)
{
return 0;
}
static int32_t PIOS_Flash_Jedec_EndTransaction(uint32_t flash_id)
}
static int32_t PIOS_Flash_Jedec_EndTransaction(uintptr_t flash_id)
{
return 0;
}
}
#endif /* FLASH_USE_FREERTOS_LOCKS */
/**
@ -301,11 +301,11 @@ static int32_t PIOS_Flash_Jedec_EndTransaction(uint32_t flash_id)
* @retval -1 if unable to claim bus
* @retval
*/
static int32_t PIOS_Flash_Jedec_EraseSector(uint32_t flash_id, uint32_t addr)
static int32_t PIOS_Flash_Jedec_EraseSector(uintptr_t flash_id, uint32_t addr)
{
struct jedec_flash_dev * flash_dev = (struct jedec_flash_dev *)flash_id;
if(PIOS_Flash_Jedec_Validate(flash_dev) != 0)
if (PIOS_Flash_Jedec_Validate(flash_dev) != 0)
return -1;
uint8_t ret;
@ -316,12 +316,12 @@ static int32_t PIOS_Flash_Jedec_EraseSector(uint32_t flash_id, uint32_t addr)
if (PIOS_Flash_Jedec_ClaimBus(flash_dev) != 0)
return -1;
if(PIOS_SPI_TransferBlock(flash_dev->spi_id,out,NULL,sizeof(out),NULL) < 0) {
if (PIOS_SPI_TransferBlock(flash_dev->spi_id,out,NULL,sizeof(out),NULL) < 0) {
PIOS_Flash_Jedec_ReleaseBus(flash_dev);
return -2;
}
PIOS_Flash_Jedec_ReleaseBus(flash_dev);
// Keep polling when bus is busy too
@ -338,11 +338,11 @@ static int32_t PIOS_Flash_Jedec_EraseSector(uint32_t flash_id, uint32_t addr)
* @brief Execute the whole chip
* @returns 0 if successful, -1 if unable to claim bus
*/
static int32_t PIOS_Flash_Jedec_EraseChip(uint32_t flash_id)
static int32_t PIOS_Flash_Jedec_EraseChip(uintptr_t flash_id)
{
struct jedec_flash_dev * flash_dev = (struct jedec_flash_dev *)flash_id;
if(PIOS_Flash_Jedec_Validate(flash_dev) != 0)
if (PIOS_Flash_Jedec_Validate(flash_dev) != 0)
return -1;
uint8_t ret;
@ -353,12 +353,12 @@ static int32_t PIOS_Flash_Jedec_EraseChip(uint32_t flash_id)
if (PIOS_Flash_Jedec_ClaimBus(flash_dev) != 0)
return -1;
if(PIOS_SPI_TransferBlock(flash_dev->spi_id,out,NULL,sizeof(out),NULL) < 0) {
if (PIOS_SPI_TransferBlock(flash_dev->spi_id,out,NULL,sizeof(out),NULL) < 0) {
PIOS_Flash_Jedec_ReleaseBus(flash_dev);
return -2;
}
PIOS_Flash_Jedec_ReleaseBus(flash_dev);
// Keep polling when bus is busy too
@ -372,7 +372,7 @@ static int32_t PIOS_Flash_Jedec_EraseChip(uint32_t flash_id)
#endif
PIOS_LED_Toggle(PIOS_LED_HEARTBEAT);
}
return 0;
@ -389,7 +389,7 @@ static int32_t PIOS_Flash_Jedec_EraseChip(uint32_t flash_id)
* @retval -2 Size exceeds 256 bytes
* @retval -3 Length to write would wrap around page boundary
*/
static int32_t PIOS_Flash_Jedec_WriteData(uint32_t flash_id, uint32_t addr, uint8_t * data, uint16_t len)
static int32_t PIOS_Flash_Jedec_WriteData(uintptr_t flash_id, uint32_t addr, uint8_t * data, uint16_t len)
{
struct jedec_flash_dev * flash_dev = (struct jedec_flash_dev *)flash_id;
@ -400,11 +400,11 @@ static int32_t PIOS_Flash_Jedec_WriteData(uint32_t flash_id, uint32_t addr, uint
uint8_t out[4] = {JEDEC_PAGE_WRITE, (addr >> 16) & 0xff, (addr >> 8) & 0xff , addr & 0xff};
/* Can only write one page at a time */
if(len > 0x100)
if (len > 0x100)
return -2;
/* Ensure number of bytes fits after starting address before end of page */
if(((addr & 0xff) + len) > 0x100)
if (((addr & 0xff) + len) > 0x100)
return -3;
if ((ret = PIOS_Flash_Jedec_WriteEnable(flash_dev)) != 0)
@ -413,14 +413,14 @@ static int32_t PIOS_Flash_Jedec_WriteData(uint32_t flash_id, uint32_t addr, uint
/* Execute write page command and clock in address. Keep CS asserted */
if (PIOS_Flash_Jedec_ClaimBus(flash_dev) != 0)
return -1;
if(PIOS_SPI_TransferBlock(flash_dev->spi_id,out,NULL,sizeof(out),NULL) < 0) {
if (PIOS_SPI_TransferBlock(flash_dev->spi_id,out,NULL,sizeof(out),NULL) < 0) {
PIOS_Flash_Jedec_ReleaseBus(flash_dev);
return -1;
}
/* Clock out data to flash */
if(PIOS_SPI_TransferBlock(flash_dev->spi_id,data,NULL,len,NULL) < 0) {
if (PIOS_SPI_TransferBlock(flash_dev->spi_id,data,NULL,len,NULL) < 0) {
PIOS_Flash_Jedec_ReleaseBus(flash_dev);
return -1;
}
@ -439,8 +439,8 @@ static int32_t PIOS_Flash_Jedec_WriteData(uint32_t flash_id, uint32_t addr, uint
return -1;
PIOS_SPI_TransferByte(flash_dev->spi_id, JEDEC_READ_STATUS);
while(PIOS_SPI_TransferByte(flash_dev->spi_id, JEDEC_READ_STATUS) & JEDEC_STATUS_BUSY);
while (PIOS_SPI_TransferByte(flash_dev->spi_id, JEDEC_READ_STATUS) & JEDEC_STATUS_BUSY);
PIOS_Flash_Jedec_ReleaseBus(flash_dev);
#endif
@ -457,45 +457,45 @@ static int32_t PIOS_Flash_Jedec_WriteData(uint32_t flash_id, uint32_t addr, uint
* @retval -2 Size exceeds 256 bytes
* @retval -3 Length to write would wrap around page boundary
*/
static int32_t PIOS_Flash_Jedec_WriteChunks(uint32_t flash_id, uint32_t addr, struct pios_flash_chunk chunks[], uint32_t num)
static int32_t PIOS_Flash_Jedec_WriteChunks(uintptr_t flash_id, uint32_t addr, struct pios_flash_chunk chunks[], uint32_t num)
{
struct jedec_flash_dev * flash_dev = (struct jedec_flash_dev *)flash_id;
if(PIOS_Flash_Jedec_Validate(flash_dev) != 0)
if (PIOS_Flash_Jedec_Validate(flash_dev) != 0)
return -1;
uint8_t ret;
uint8_t out[4] = {JEDEC_PAGE_WRITE, (addr >> 16) & 0xff, (addr >> 8) & 0xff , addr & 0xff};
/* Can only write one page at a time */
uint32_t len = 0;
for(uint32_t i = 0; i < num; i++)
for (uint32_t i = 0; i < num; i++)
len += chunks[i].len;
if(len > 0x100)
if (len > 0x100)
return -2;
/* Ensure number of bytes fits after starting address before end of page */
if(((addr & 0xff) + len) > 0x100)
if (((addr & 0xff) + len) > 0x100)
return -3;
if ((ret = PIOS_Flash_Jedec_WriteEnable(flash_dev)) != 0)
return ret;
/* Execute write page command and clock in address. Keep CS asserted */
if (PIOS_Flash_Jedec_ClaimBus(flash_dev) != 0)
return -1;
if(PIOS_SPI_TransferBlock(flash_dev->spi_id,out,NULL,sizeof(out),NULL) < 0) {
if (PIOS_SPI_TransferBlock(flash_dev->spi_id,out,NULL,sizeof(out),NULL) < 0) {
PIOS_Flash_Jedec_ReleaseBus(flash_dev);
return -1;
}
for(uint32_t i = 0; i < num; i++) {
for (uint32_t i = 0; i < num; i++) {
struct pios_flash_chunk * chunk = &chunks[i];
/* Clock out data to flash */
if(PIOS_SPI_TransferBlock(flash_dev->spi_id,chunk->addr,NULL,chunk->len,NULL) < 0) {
if (PIOS_SPI_TransferBlock(flash_dev->spi_id,chunk->addr,NULL,chunk->len,NULL) < 0) {
PIOS_Flash_Jedec_ReleaseBus(flash_dev);
return -1;
}
@ -516,11 +516,11 @@ static int32_t PIOS_Flash_Jedec_WriteChunks(uint32_t flash_id, uint32_t addr, st
* @return Zero if success or error code
* @retval -1 Unable to claim SPI bus
*/
static int32_t PIOS_Flash_Jedec_ReadData(uint32_t flash_id, uint32_t addr, uint8_t * data, uint16_t len)
static int32_t PIOS_Flash_Jedec_ReadData(uintptr_t flash_id, uint32_t addr, uint8_t * data, uint16_t len)
{
struct jedec_flash_dev * flash_dev = (struct jedec_flash_dev *)flash_id;
if(PIOS_Flash_Jedec_Validate(flash_dev) != 0)
if (PIOS_Flash_Jedec_Validate(flash_dev) != 0)
return -1;
if (PIOS_Flash_Jedec_ClaimBus(flash_dev) == -1)
@ -528,14 +528,14 @@ static int32_t PIOS_Flash_Jedec_ReadData(uint32_t flash_id, uint32_t addr, uint8
/* Execute read command and clock in address. Keep CS asserted */
uint8_t out[] = {JEDEC_READ_DATA, (addr >> 16) & 0xff, (addr >> 8) & 0xff , addr & 0xff};
if(PIOS_SPI_TransferBlock(flash_dev->spi_id,out,NULL,sizeof(out),NULL) < 0) {
if (PIOS_SPI_TransferBlock(flash_dev->spi_id,out,NULL,sizeof(out),NULL) < 0) {
PIOS_Flash_Jedec_ReleaseBus(flash_dev);
return -2;
}
/* Copy the transfer data to the buffer */
if(PIOS_SPI_TransferBlock(flash_dev->spi_id,NULL,data,len,NULL) < 0) {
if (PIOS_SPI_TransferBlock(flash_dev->spi_id,NULL,data,len,NULL) < 0) {
PIOS_Flash_Jedec_ReleaseBus(flash_dev);
return -3;
}

View File

@ -50,7 +50,7 @@ struct logfs_state {
/* Underlying flash driver glue */
const struct pios_flash_driver * driver;
uint32_t flash_id;
uintptr_t flash_id;
};
static struct logfs_state logfs;
@ -461,7 +461,7 @@ static int32_t logfs_mount_log(uint8_t arena_id)
* @brief Initialize the flash object setting FS
* @return 0 if success, -1 if failure
*/
int32_t PIOS_FLASHFS_Logfs_Init(uintptr_t * fs_id, const struct flashfs_logfs_cfg * cfg, const struct pios_flash_driver * driver, uint32_t flash_id)
int32_t PIOS_FLASHFS_Logfs_Init(uintptr_t * fs_id, const struct flashfs_logfs_cfg * cfg, const struct pios_flash_driver * driver, uintptr_t flash_id)
{
PIOS_Assert(cfg);
PIOS_Assert(fs_id);

View File

@ -166,7 +166,7 @@ static struct pios_internal_flash_dev * PIOS_Flash_Internal_alloc(void)
#endif /* defined(PIOS_INCLUDE_FREERTOS) */
int32_t PIOS_Flash_Internal_Init(uint32_t * flash_id, const struct pios_flash_internal_cfg * cfg)
int32_t PIOS_Flash_Internal_Init(uintptr_t * flash_id, const struct pios_flash_internal_cfg * cfg)
{
struct pios_internal_flash_dev * flash_dev;
@ -178,7 +178,7 @@ int32_t PIOS_Flash_Internal_Init(uint32_t * flash_id, const struct pios_flash_in
flash_dev->transaction_lock = xSemaphoreCreateMutex();
#endif /* defined(PIOS_INCLUDE_FREERTOS) */
*flash_id = (uint32_t) flash_dev;
*flash_id = (uintptr_t) flash_dev;
return 0;
}
@ -190,7 +190,7 @@ int32_t PIOS_Flash_Internal_Init(uint32_t * flash_id, const struct pios_flash_in
*********************************/
#include "pios_flash.h"
static int32_t PIOS_Flash_Internal_StartTransaction(uint32_t flash_id)
static int32_t PIOS_Flash_Internal_StartTransaction(uintptr_t flash_id)
{
struct pios_internal_flash_dev * flash_dev = (struct pios_internal_flash_dev *)flash_id;
@ -207,7 +207,7 @@ static int32_t PIOS_Flash_Internal_StartTransaction(uint32_t flash_id)
return 0;
}
static int32_t PIOS_Flash_Internal_EndTransaction(uint32_t flash_id)
static int32_t PIOS_Flash_Internal_EndTransaction(uintptr_t flash_id)
{
struct pios_internal_flash_dev * flash_dev = (struct pios_internal_flash_dev *)flash_id;
@ -225,7 +225,7 @@ static int32_t PIOS_Flash_Internal_EndTransaction(uint32_t flash_id)
return 0;
}
static int32_t PIOS_Flash_Internal_EraseSector(uint32_t flash_id, uint32_t addr)
static int32_t PIOS_Flash_Internal_EraseSector(uintptr_t flash_id, uint32_t addr)
{
struct pios_internal_flash_dev * flash_dev = (struct pios_internal_flash_dev *)flash_id;
@ -249,7 +249,7 @@ static int32_t PIOS_Flash_Internal_EraseSector(uint32_t flash_id, uint32_t addr)
return 0;
}
static int32_t PIOS_Flash_Internal_WriteData(uint32_t flash_id, uint32_t addr, uint8_t * data, uint16_t len)
static int32_t PIOS_Flash_Internal_WriteData(uintptr_t flash_id, uint32_t addr, uint8_t * data, uint16_t len)
{
PIOS_Assert(data);
@ -291,7 +291,7 @@ static int32_t PIOS_Flash_Internal_WriteData(uint32_t flash_id, uint32_t addr, u
return 0;
}
static int32_t PIOS_Flash_Internal_ReadData(uint32_t flash_id, uint32_t addr, uint8_t * data, uint16_t len)
static int32_t PIOS_Flash_Internal_ReadData(uintptr_t flash_id, uint32_t addr, uint8_t * data, uint16_t len)
{
PIOS_Assert(data);

View File

@ -35,13 +35,13 @@ struct pios_flash_chunk {
};
struct pios_flash_driver {
int32_t (*start_transaction)(uint32_t flash_id);
int32_t (*end_transaction)(uint32_t flash_id);
int32_t (*erase_chip)(uint32_t flash_id);
int32_t (*erase_sector)(uint32_t flash_id, uint32_t addr);
int32_t (*write_data)(uint32_t flash_id, uint32_t addr, uint8_t * data, uint16_t len);
int32_t (*write_chunks)(uint32_t flash_id, uint32_t addr, struct pios_flash_chunk chunks[], uint32_t num_chunks);
int32_t (*read_data)(uint32_t flash_id, uint32_t addr, uint8_t * data, uint16_t len);
int32_t (*start_transaction)(uintptr_t flash_id);
int32_t (*end_transaction)(uintptr_t flash_id);
int32_t (*erase_chip)(uintptr_t flash_id);
int32_t (*erase_sector)(uintptr_t flash_id, uint32_t addr);
int32_t (*write_data)(uintptr_t flash_id, uint32_t addr, uint8_t * data, uint16_t len);
int32_t (*write_chunks)(uintptr_t flash_id, uint32_t addr, struct pios_flash_chunk chunks[], uint32_t num_chunks);
int32_t (*read_data)(uintptr_t flash_id, uint32_t addr, uint8_t * data, uint16_t len);
};
#endif /* PIOS_FLASH_H_ */

View File

@ -35,6 +35,6 @@ struct pios_flash_internal_cfg {
;
};
extern int32_t PIOS_Flash_Internal_Init(uint32_t * flash_id, const struct pios_flash_internal_cfg * cfg);
extern int32_t PIOS_Flash_Internal_Init(uintptr_t * flash_id, const struct pios_flash_internal_cfg * cfg);
#endif /* PIOS_FLASH_INTERNAL_H_ */

View File

@ -40,6 +40,6 @@ struct pios_flash_jedec_cfg {
uint32_t chip_erase;
};
int32_t PIOS_Flash_Jedec_Init(uint32_t * flash_id, uint32_t spi_id, uint32_t slave_num, const struct pios_flash_jedec_cfg * cfg);
int32_t PIOS_Flash_Jedec_Init(uintptr_t * flash_id, uint32_t spi_id, uint32_t slave_num, const struct pios_flash_jedec_cfg * cfg);
#endif /* PIOS_FLASH_JEDEC_H_ */

View File

@ -41,6 +41,6 @@ struct flashfs_logfs_cfg {
uint32_t page_size; /* Maximum flash burst write size */
};
int32_t PIOS_FLASHFS_Logfs_Init(uintptr_t * fs_id, const struct flashfs_logfs_cfg * cfg, const struct pios_flash_driver * driver, uint32_t flash_id);
int32_t PIOS_FLASHFS_Logfs_Init(uintptr_t * fs_id, const struct flashfs_logfs_cfg * cfg, const struct pios_flash_driver * driver, uintptr_t flash_id);
#endif /* PIOS_FLASHFS_LOGFS_PRIV_H_ */

View File

@ -162,7 +162,7 @@ void PIOS_Board_Init(void) {
#endif
uint32_t flash_id;
uintptr_t flash_id;
uintptr_t fs_id;
switch(bdinfo->board_rev) {
case BOARD_REVISION_CC:

View File

@ -300,8 +300,8 @@ void PIOS_Board_Init(void) {
}
#if defined(PIOS_INCLUDE_FLASH)
/* Connect flash to the approrpiate interface and configure it */
uint32_t flash_id;
/* Connect flash to the appropriate interface and configure it */
uintptr_t flash_id;
PIOS_Flash_Jedec_Init(&flash_id, pios_spi_telem_flash_id, 1, &flash_m25p_cfg);
uintptr_t fs_id;
PIOS_FLASHFS_Logfs_Init(&fs_id, &flashfs_m25p_cfg, &pios_jedec_flash_driver, flash_id);

View File

@ -381,12 +381,12 @@ void PIOS_Board_Init(void) {
if (PIOS_SPI_Init(&pios_spi_flash_id, &pios_spi_flash_cfg)) {
PIOS_DEBUG_Assert(0);
}
/* Connect flash to the approrpiate interface and configure it */
uint32_t flash_id;
/* Connect flash to the appropriate interface and configure it */
uintptr_t flash_id;
PIOS_Flash_Jedec_Init(&flash_id, pios_spi_flash_id, 0, &flash_m25p_cfg);
#else
/* Connect flash to the approrpiate interface and configure it */
uint32_t flash_id;
/* Connect flash to the appropriate interface and configure it */
uintptr_t flash_id;
PIOS_Flash_Jedec_Init(&flash_id, pios_spi_accel_id, 1, &flash_m25p_cfg);
#endif
uintptr_t fs_id;

View File

@ -31,7 +31,7 @@ int main (int argc, char * argv[])
/* dd if=/dev/zero bs=1 count=2MiB | tr '\000' '\377' > theflash.bin */
uint32_t flash_id;
uintptr_t flash_id;
rc = PIOS_Flash_UT_Init(&flash_id, &flash_config);
if (rc != 0) {
printf ("flash init failed (%d)\n", rc);

View File

@ -26,7 +26,7 @@ static struct flash_ut_dev * PIOS_Flash_UT_Alloc(void)
return flash_dev;
}
int32_t PIOS_Flash_UT_Init(uint32_t * flash_id, const struct pios_flash_ut_cfg * cfg)
int32_t PIOS_Flash_UT_Init(uintptr_t * flash_id, const struct pios_flash_ut_cfg * cfg)
{
/* Check inputs */
assert(flash_id);
@ -50,7 +50,7 @@ int32_t PIOS_Flash_UT_Init(uint32_t * flash_id, const struct pios_flash_ut_cfg *
return -2;
}
*flash_id = (uint32_t)flash_dev;
*flash_id = (uintptr_t)flash_dev;
return 0;
}
@ -62,7 +62,7 @@ int32_t PIOS_Flash_UT_Init(uint32_t * flash_id, const struct pios_flash_ut_cfg *
*********************************/
#include "pios_flash.h"
static int32_t PIOS_Flash_UT_StartTransaction(uint32_t flash_id)
static int32_t PIOS_Flash_UT_StartTransaction(uintptr_t flash_id)
{
struct flash_ut_dev * flash_dev = (struct flash_ut_dev *)flash_id;
@ -73,7 +73,7 @@ static int32_t PIOS_Flash_UT_StartTransaction(uint32_t flash_id)
return 0;
}
static int32_t PIOS_Flash_UT_EndTransaction(uint32_t flash_id)
static int32_t PIOS_Flash_UT_EndTransaction(uintptr_t flash_id)
{
struct flash_ut_dev * flash_dev = (struct flash_ut_dev *)flash_id;
@ -84,7 +84,7 @@ static int32_t PIOS_Flash_UT_EndTransaction(uint32_t flash_id)
return 0;
}
static int32_t PIOS_Flash_UT_EraseSector(uint32_t flash_id, uint32_t addr)
static int32_t PIOS_Flash_UT_EraseSector(uintptr_t flash_id, uint32_t addr)
{
struct flash_ut_dev * flash_dev = (struct flash_ut_dev *)flash_id;
@ -106,7 +106,7 @@ static int32_t PIOS_Flash_UT_EraseSector(uint32_t flash_id, uint32_t addr)
return 0;
}
static int32_t PIOS_Flash_UT_WriteData(uint32_t flash_id, uint32_t addr, uint8_t * data, uint16_t len)
static int32_t PIOS_Flash_UT_WriteData(uintptr_t flash_id, uint32_t addr, uint8_t * data, uint16_t len)
{
/* Check inputs */
assert(data);
@ -127,7 +127,7 @@ static int32_t PIOS_Flash_UT_WriteData(uint32_t flash_id, uint32_t addr, uint8_t
return 0;
}
static int32_t PIOS_Flash_UT_ReadData(uint32_t flash_id, uint32_t addr, uint8_t * data, uint16_t len)
static int32_t PIOS_Flash_UT_ReadData(uintptr_t flash_id, uint32_t addr, uint8_t * data, uint16_t len)
{
/* Check inputs */
assert(data);