From 06bb5a6a18c82f41474d57c24a14a061508712ab Mon Sep 17 00:00:00 2001 From: Paul Helter Date: Fri, 30 Sep 2022 14:26:51 -0700 Subject: [PATCH 01/12] Support for CMake builds. Added Linux stub port for now to allow cross compilation. --- CMakeLists.txt | 2 -- portable/linux/ff_sddisk.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9721885..bc017f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -208,6 +208,4 @@ target_link_libraries( freertos_plus_fat add_subdirectory(portable) add_subdirectory(test) - - FetchContent_MakeAvailable(freertos_kernel) diff --git a/portable/linux/ff_sddisk.c b/portable/linux/ff_sddisk.c index 679344a..467ea6a 100644 --- a/portable/linux/ff_sddisk.c +++ b/portable/linux/ff_sddisk.c @@ -143,7 +143,6 @@ BaseType_t FF_SDDiskMount( FF_Disk_t * pxDisk ) FF_PRINTF( "****** FreeRTOS+FAT initialized %u sectors\n", ( unsigned ) pxDisk->pxIOManager->xPartition.ulTotalSectors ); return pdPASS; } - return pdFAIL; } /*-----------------------------------------------------------*/ @@ -173,7 +172,6 @@ BaseType_t FF_SDDiskDelete( FF_Disk_t * pxDisk ) { vPortFree( pxDisk ); } - return pdTRUE; } /*-----------------------------------------------------------*/ From 321db9e43ad933b6794390819b21a4fc057e33a8 Mon Sep 17 00:00:00 2001 From: Paul Helter Date: Sun, 23 Oct 2022 13:53:25 -0700 Subject: [PATCH 02/12] Fixing misuse of doxygen documentation --- ff_format.c | 44 +++---- portable/STM32F4xx/stm32f4xx_hal_sd.c | 154 ++++++++++++------------ portable/STM32F4xx/stm32f4xx_hal_sd.h | 24 ++-- portable/STM32F4xx/stm32f4xx_ll_sdmmc.c | 34 +++--- portable/STM32F4xx/stm32f4xx_ll_sdmmc.h | 24 ++-- portable/STM32F7xx/stm32f7xx_hal_sd.c | 154 +++++++++++++----------- portable/STM32F7xx/stm32f7xx_hal_sd.h | 24 ++-- 7 files changed, 233 insertions(+), 225 deletions(-) diff --git a/ff_format.c b/ff_format.c index cac3127..05c9fe0 100755 --- a/ff_format.c +++ b/ff_format.c @@ -219,9 +219,9 @@ static portINLINE uint32_t ulMin32( uint32_t a, /** * @brief: Decide whether FAT32 or FAT16 shall be used and try to find an optimum cluster size. - * @param[in] pxSet: A set of parameters describing this format session. - * @param[in] xPreferFAT16: When pdTRUE, it will use FAT16 in stead of FAT32. - * @param[in] xSmallClusters: When pdTRUE, it will make the cluster size as small as possible. + * @param[in] pxSet A set of parameters describing this format session. + * @param[in] xPreferFAT16 When pdTRUE, it will use FAT16 in stead of FAT32. + * @param[in] xSmallClusters When pdTRUE, it will make the cluster size as small as possible. * @return A standard +FAT error code ( not an errno ). * @note In order to get the best speed, use pdFALSE, pdFALSE: to get FAT32 with large clusters. */ @@ -304,7 +304,7 @@ static FF_Error_t prvFormatGetClusterSize( struct xFormatSet * pxSet, /** * @brief: Optimise FAT location: for bigger disks, let the FAT start at 4MB. - * @param[in] pxSet: A set of parameters describing this format session. + * @param[in] pxSet A set of parameters describing this format session. */ static void prvFormatOptimiseFATLocation( struct xFormatSet * pxSet ) { @@ -340,7 +340,7 @@ static void prvFormatOptimiseFATLocation( struct xFormatSet * pxSet ) /** * @brief: Write the so-called BIOS Parameter Block ( BPB ). It describes the FAT partition. - * @param[in] pxSet: A set of parameters describing this format session. + * @param[in] pxSet A set of parameters describing this format session. * @return A standard +FAT error code. */ static FF_Error_t prvFormatWriteBPB( struct xFormatSet * pxSet, @@ -427,8 +427,8 @@ static FF_Error_t prvFormatWriteBPB( struct xFormatSet * pxSet, /** * @brief: Initialise and clear the File Allocation Table ( FAT ). - * @param[in] pxSet: A set of parameters describing this format session. - * @param[in] lFatBeginLBA: The number of first sector of the FAT. + * @param[in] pxSet A set of parameters describing this format session. + * @param[in] lFatBeginLBA The number of first sector of the FAT. * @return A standard +FAT error code. */ static FF_Error_t prvFormatInitialiseFAT( struct xFormatSet * pxSet, @@ -489,7 +489,7 @@ static FF_Error_t prvFormatInitialiseFAT( struct xFormatSet * pxSet, /** * @brief: Initialise and clear the root directory. - * @param[in] pxSet: A set of parameters describing this format session. + * @param[in] pxSet A set of parameters describing this format session. * @return A standard +FAT error code. */ static FF_Error_t prvFormatInitialiseRootDir( struct xFormatSet * pxSet, @@ -535,10 +535,10 @@ static FF_Error_t prvFormatInitialiseRootDir( struct xFormatSet * pxSet, /** * @brief Now deprecated, please use the new function 'FF_FormatDisk()'. - * @param[in] pxDisk: The disk object. - * @param[in] xPartitionNumber: the numer of the partitioned that must be FAT-formatted. - * @param[in] xPreferFAT16: When pdTRUE, it will use FAT16 in stead of FAT32. - * @param[in] xSmallClusters: When pdTRUE, it will make the cluster size as small as possible. + * @param[in] pxDisk The disk object. + * @param[in] xPartitionNumber the numer of the partitioned that must be FAT-formatted. + * @param[in] xPreferFAT16 When pdTRUE, it will use FAT16 in stead of FAT32. + * @param[in] xSmallClusters When pdTRUE, it will make the cluster size as small as possible. * @return A standard +FAT error code ( not an errno ). */ FF_Error_t FF_Format( FF_Disk_t * pxDisk, @@ -555,11 +555,11 @@ FF_Error_t FF_Format( FF_Disk_t * pxDisk, /** * @brief Format a partition of a disk, either as FAT16 or FAT32. It assumes that * is has already been partitioned. - * @param[in] pxDisk: The disk object. - * @param[in] xPartitionNumber: the numer of the partitioned that must be FAT-formatted. - * @param[in] xPreferFAT16: When pdTRUE, it will use FAT16 in stead of FAT32. - * @param[in] xSmallClusters: When pdTRUE, it will make the cluster size as small as possible. - * @param[in] pcVolumeName: A string of 11 characters representing the name of the disk. + * @param[in] pxDisk The disk object. + * @param[in] xPartitionNumber the numer of the partitioned that must be FAT-formatted. + * @param[in] xPreferFAT16 When pdTRUE, it will use FAT16 in stead of FAT32. + * @param[in] xSmallClusters When pdTRUE, it will make the cluster size as small as possible. + * @param[in] pcVolumeName A string of 11 characters representing the name of the disk. * @return A standard +FAT error code ( not an errno ). */ FF_Error_t FF_FormatDisk( FF_Disk_t * pxDisk, @@ -744,7 +744,7 @@ FF_Error_t FF_FormatDisk( FF_Disk_t * pxDisk, /** * @brief Create primary and extended partitions. - * @param[in] pxSet: A set of parameters describing this format session. + * @param[in] pxSet A set of parameters describing this format session. * @return A standard +FAT error code. */ static FF_Error_t prvPartitionPrimary( struct xPartitionSet * pxSet ) @@ -793,8 +793,8 @@ static FF_Error_t prvPartitionPrimary( struct xPartitionSet * pxSet ) /** * @brief Create primary and extended partitions. - * @param[in] pxSet: A set of parameters describing this format session. - * @param[in] pParams: A set of variables describing the partitions. + * @param[in] pxSet A set of parameters describing this format session. + * @param[in] pParams A set of variables describing the partitions. * @return A standard +FAT error code. */ static FF_Error_t prvPartitionExtended( struct xPartitionSet * pxSet, @@ -909,8 +909,8 @@ static FF_Error_t prvPartitionExtended( struct xPartitionSet * pxSet, /** * @brief Create/initialise the partitions of a disk. - * @param[in] pxDisk : The definition of the disk. - * @param[in] pParams : A description of how the partitions shall be formatted. + * @param[in] pxDisk The definition of the disk. + * @param[in] pParams A description of how the partitions shall be formatted. * @return A standard +FAT error code ( not an errno ). */ FF_Error_t FF_Partition( FF_Disk_t * pxDisk, diff --git a/portable/STM32F4xx/stm32f4xx_hal_sd.c b/portable/STM32F4xx/stm32f4xx_hal_sd.c index 3694ef9..b444502 100755 --- a/portable/STM32F4xx/stm32f4xx_hal_sd.c +++ b/portable/STM32F4xx/stm32f4xx_hal_sd.c @@ -353,8 +353,8 @@ /** * @brief Initializes the SD card according to the specified parameters in the * SD_HandleTypeDef and create the associated handle. - * @param hsd: SD handle - * @param SDCardInfo: HAL_SD_CardInfoTypedef structure for SD card information + * @param hsd SD handle + * @param SDCardInfo HAL_SD_CardInfoTypedef structure for SD card information * @retval HAL SD error state */ HAL_SD_ErrorTypedef HAL_SD_Init( SD_HandleTypeDef * hsd, @@ -418,7 +418,7 @@ /** * @brief De-Initializes the SD card. - * @param hsd: SD handle + * @param hsd SD handle * @retval HAL status */ HAL_StatusTypeDef HAL_SD_DeInit( SD_HandleTypeDef * hsd ) @@ -435,7 +435,7 @@ /** * @brief Initializes the SD MSP. - * @param hsd: SD handle + * @param hsd SD handle * @retval None */ __weak void HAL_SD_MspInit( SD_HandleTypeDef * hsd ) @@ -447,7 +447,7 @@ /** * @brief De-Initialize SD MSP. - * @param hsd: SD handle + * @param hsd SD handle * @retval None */ __weak void HAL_SD_MspDeInit( SD_HandleTypeDef * hsd ) @@ -479,12 +479,12 @@ /** * @brief Reads block(s) from a specified address in a card. The Data transfer * is managed by polling mode. - * @param hsd: SD handle - * @param pReadBuffer: pointer to the buffer that will contain the received data - * @param ReadAddr: Address from where data is to be read - * @param BlockSize: SD card Data block size + * @param hsd SD handle + * @param pReadBuffer pointer to the buffer that will contain the received data + * @param ReadAddr Address from where data is to be read + * @param BlockSize SD card Data block size * @note BlockSize must be 512 bytes. - * @param NumberOfBlocks: Number of SD blocks to read + * @param NumberOfBlocks Number of SD blocks to read * @retval SD Card error state */ HAL_SD_ErrorTypedef HAL_SD_ReadBlocks( SD_HandleTypeDef * hsd, @@ -668,12 +668,12 @@ /** * @brief Allows to write block(s) to a specified address in a card. The Data * transfer is managed by polling mode. - * @param hsd: SD handle - * @param pWriteBuffer: pointer to the buffer that will contain the data to transmit - * @param WriteAddr: Address from where data is to be written - * @param BlockSize: SD card Data block size + * @param hsd SD handle + * @param pWriteBuffer pointer to the buffer that will contain the data to transmit + * @param WriteAddr Address from where data is to be written + * @param BlockSize SD card Data block size * @note BlockSize must be 512 bytes. - * @param NumberOfBlocks: Number of SD blocks to write + * @param NumberOfBlocks Number of SD blocks to write * @retval SD Card error state */ HAL_SD_ErrorTypedef HAL_SD_WriteBlocks( SD_HandleTypeDef * hsd, @@ -916,12 +916,12 @@ * is managed by DMA mode. * @note This API should be followed by the function HAL_SD_CheckReadOperation() * to check the completion of the read process - * @param hsd: SD handle - * @param pReadBuffer: Pointer to the buffer that will contain the received data - * @param ReadAddr: Address from where data is to be read - * @param BlockSize: SD card Data block size + * @param hsd SD handle + * @param pReadBuffer Pointer to the buffer that will contain the received data + * @param ReadAddr Address from where data is to be read + * @param BlockSize SD card Data block size * @note BlockSize must be 512 bytes. - * @param NumberOfBlocks: Number of blocks to read. + * @param NumberOfBlocks Number of blocks to read. * @retval SD Card error state */ HAL_SD_ErrorTypedef HAL_SD_ReadBlocks_DMA( SD_HandleTypeDef * hsd, @@ -1035,12 +1035,12 @@ * is managed by DMA mode. * @note This API should be followed by the function HAL_SD_CheckWriteOperation() * to check the completion of the write process (by SD current status polling). - * @param hsd: SD handle - * @param pWriteBuffer: pointer to the buffer that will contain the data to transmit - * @param WriteAddr: Address from where data is to be read - * @param BlockSize: the SD card Data block size + * @param hsd SD handle + * @param pWriteBuffer pointer to the buffer that will contain the data to transmit + * @param WriteAddr Address from where data is to be read + * @param BlockSize the SD card Data block size * @note BlockSize must be 512 bytes. - * @param NumberOfBlocks: Number of blocks to write + * @param NumberOfBlocks Number of blocks to write * @retval SD Card error state */ void FF_Sleep( uint32_t ulTime_ms ); @@ -1182,8 +1182,8 @@ * This API should be called after HAL_SD_ReadBlocks_DMA() function * to insure that all data sent by the card is already transferred by the * DMA controller. - * @param hsd: SD handle - * @param Timeout: Timeout duration + * @param hsd SD handle + * @param Timeout Timeout duration * @retval SD Card error state */ @@ -1272,8 +1272,8 @@ * This API should be called after HAL_SD_WriteBlocks_DMA() function * to insure that all data sent by the card is already transferred by the * DMA controller. - * @param hsd: SD handle - * @param Timeout: Timeout duration + * @param hsd SD handle + * @param Timeout Timeout duration * @retval SD Card error state */ HAL_SD_ErrorTypedef HAL_SD_CheckWriteOperation( SD_HandleTypeDef * hsd, @@ -1366,9 +1366,9 @@ /** * @brief Erases the specified memory area of the given SD card. - * @param hsd: SD handle - * @param startaddr: Start byte address - * @param endaddr: End byte address + * @param hsd SD handle + * @param startaddr Start byte address + * @param endaddr End byte address * @retval SD Card error state */ HAL_SD_ErrorTypedef HAL_SD_Erase( SD_HandleTypeDef * hsd, @@ -1474,7 +1474,7 @@ /** * @brief This function handles SD card interrupt request. - * @param hsd: SD handle + * @param hsd SD handle * @retval None */ void HAL_SD_IRQHandler( SD_HandleTypeDef * hsd ) @@ -1546,7 +1546,7 @@ /** * @brief SD end of transfer callback. - * @param hsd: SD handle + * @param hsd SD handle * @retval None */ __weak void HAL_SD_XferCpltCallback( SD_HandleTypeDef * hsd ) @@ -1558,7 +1558,7 @@ /** * @brief SD Transfer Error callback. - * @param hsd: SD handle + * @param hsd SD handle * @retval None */ __weak void HAL_SD_XferErrorCallback( SD_HandleTypeDef * hsd ) @@ -1570,7 +1570,7 @@ /** * @brief SD Transfer complete Rx callback in non blocking mode. - * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * @param hdma pointer to a DMA_HandleTypeDef structure that contains * the configuration information for the specified DMA module. * @retval None */ @@ -1583,7 +1583,7 @@ /** * @brief SD DMA transfer complete Rx error callback. - * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * @param hdma pointer to a DMA_HandleTypeDef structure that contains * the configuration information for the specified DMA module. * @retval None */ @@ -1596,7 +1596,7 @@ /** * @brief SD Transfer complete Tx callback in non blocking mode. - * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * @param hdma pointer to a DMA_HandleTypeDef structure that contains * the configuration information for the specified DMA module. * @retval None */ @@ -1609,7 +1609,7 @@ /** * @brief SD DMA transfer complete error Tx callback. - * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * @param hdma pointer to a DMA_HandleTypeDef structure that contains * the configuration information for the specified DMA module. * @retval None */ @@ -1641,8 +1641,8 @@ /** * @brief Returns information about specific card. - * @param hsd: SD handle - * @param pCardInfo: Pointer to a HAL_SD_CardInfoTypedef structure that + * @param hsd SD handle + * @param pCardInfo Pointer to a HAL_SD_CardInfoTypedef structure that * contains all SD cardinformation * @retval SD Card error state */ @@ -1855,8 +1855,8 @@ /** * @brief Enables wide bus operation for the requested card if supported by * card. - * @param hsd: SD handle - * @param WideMode: Specifies the SD card wide bus mode + * @param hsd SD handle + * @param WideMode Specifies the SD card wide bus mode * This parameter can be one of the following values: * @arg SDIO_BUS_WIDE_8B: 8-bit data transfer (Only for MMC) * @arg SDIO_BUS_WIDE_4B: 4-bit data transfer @@ -1915,7 +1915,7 @@ /** * @brief Aborts an ongoing data transfer. - * @param hsd: SD handle + * @param hsd SD handle * @retval SD Card error state */ HAL_SD_ErrorTypedef HAL_SD_StopTransfer( SD_HandleTypeDef * hsd ) @@ -1942,7 +1942,7 @@ * This API must be used after "Transfer State" * @note This operation should be followed by the configuration * of PLL to have SDIOCK clock between 67 and 75 MHz - * @param hsd: SD handle + * @param hsd SD handle * @retval SD Card error state */ HAL_SD_ErrorTypedef HAL_SD_HighSpeed( SD_HandleTypeDef * hsd ) @@ -2103,8 +2103,8 @@ /** * @brief Returns the current SD card's status. - * @param hsd: SD handle - * @param pSDstatus: Pointer to the buffer that will contain the SD card status + * @param hsd SD handle + * @param pSDstatus Pointer to the buffer that will contain the SD card status * SD Status register) * @retval SD Card error state */ @@ -2243,7 +2243,7 @@ /** * @brief Gets the current sd card data status. - * @param hsd: SD handle + * @param hsd SD handle * @retval Data Transfer state */ HAL_SD_TransferStateTypedef HAL_SD_GetStatus( SD_HandleTypeDef * hsd ) @@ -2270,8 +2270,8 @@ /** * @brief Gets the SD card status. - * @param hsd: SD handle - * @param pCardStatus: Pointer to the HAL_SD_CardStatusTypedef structure that + * @param hsd SD handle + * @param pCardStatus Pointer to the HAL_SD_CardStatusTypedef structure that * will contain the SD card status information * @retval SD Card error state */ @@ -2368,7 +2368,7 @@ /** * @brief SD DMA transfer complete Rx callback. - * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * @param hdma pointer to a DMA_HandleTypeDef structure that contains * the configuration information for the specified DMA module. * @retval None */ @@ -2393,7 +2393,7 @@ /** * @brief SD DMA transfer Error Rx callback. - * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * @param hdma pointer to a DMA_HandleTypeDef structure that contains * the configuration information for the specified DMA module. * @retval None */ @@ -2407,7 +2407,7 @@ /** * @brief SD DMA transfer complete Tx callback. - * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * @param hdma pointer to a DMA_HandleTypeDef structure that contains * the configuration information for the specified DMA module. * @retval None */ @@ -2432,7 +2432,7 @@ /** * @brief SD DMA transfer Error Tx callback. - * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * @param hdma pointer to a DMA_HandleTypeDef structure that contains * the configuration information for the specified DMA module. * @retval None */ @@ -2446,7 +2446,7 @@ /** * @brief Returns the SD current state. - * @param hsd: SD handle + * @param hsd SD handle * @retval SD card current state */ static HAL_SD_CardStateTypedef SD_GetState( SD_HandleTypeDef * hsd ) @@ -2466,7 +2466,7 @@ /** * @brief Initializes all cards or single card as the case may be Card(s) come * into standby state. - * @param hsd: SD handle + * @param hsd SD handle * @retval SD Card error state */ static HAL_SD_ErrorTypedef SD_Initialize_Cards( SD_HandleTypeDef * hsd ) @@ -2557,8 +2557,8 @@ /** * @brief Selects of Deselects the corresponding card. - * @param hsd: SD handle - * @param addr: Address of the card to be selected + * @param hsd SD handle + * @param addr Address of the card to be selected * @retval SD Card error state */ static HAL_SD_ErrorTypedef SD_Select_Deselect( SD_HandleTypeDef * hsd, @@ -2585,7 +2585,7 @@ * @brief Enquires cards about their operating voltage and configures clock * controls and stores SD information that will be needed in future * in the SD handle. - * @param hsd: SD handle + * @param hsd SD handle * @retval SD Card error state */ static HAL_SD_ErrorTypedef SD_PowerON( SD_HandleTypeDef * hsd ) @@ -2733,7 +2733,7 @@ /** * @brief Turns the SDIO output signals off. - * @param hsd: SD handle + * @param hsd SD handle * @retval SD Card error state */ static HAL_SD_ErrorTypedef SD_PowerOFF( SD_HandleTypeDef * hsd ) @@ -2748,8 +2748,8 @@ /** * @brief Returns the current card's status. - * @param hsd: SD handle - * @param pCardStatus: pointer to the buffer that will contain the SD card + * @param hsd SD handle + * @param pCardStatus pointer to the buffer that will contain the SD card * status (Card Status register) * @retval SD Card error state */ @@ -2790,7 +2790,7 @@ /** * @brief Checks for error conditions for CMD0. - * @param hsd: SD handle + * @param hsd SD handle * @retval SD Card error state */ static HAL_SD_ErrorTypedef SD_CmdError( SD_HandleTypeDef * hsd ) @@ -2831,7 +2831,7 @@ /** * @brief Checks for error conditions for R7 response. - * @param hsd: SD handle + * @param hsd SD handle * @retval SD Card error state */ static HAL_SD_ErrorTypedef SD_CmdResp7Error( SD_HandleTypeDef * hsd ) @@ -2883,8 +2883,8 @@ /** * @brief Checks for error conditions for R1 response. - * @param hsd: SD handle - * @param SD_CMD: The sent command index + * @param hsd SD handle + * @param SD_CMD The sent command index * @retval SD Card error state */ static HAL_SD_ErrorTypedef SD_CmdResp1Error( SD_HandleTypeDef * hsd, @@ -3040,7 +3040,7 @@ /** * @brief Checks for error conditions for R3 (OCR) response. - * @param hsd: SD handle + * @param hsd SD handle * @retval SD Card error state */ static HAL_SD_ErrorTypedef SD_CmdResp3Error( SD_HandleTypeDef * hsd ) @@ -3068,7 +3068,7 @@ /** * @brief Checks for error conditions for R2 (CID or CSD) response. - * @param hsd: SD handle + * @param hsd SD handle * @retval SD Card error state */ static HAL_SD_ErrorTypedef SD_CmdResp2Error( SD_HandleTypeDef * hsd ) @@ -3108,9 +3108,9 @@ /** * @brief Checks for error conditions for R6 (RCA) response. - * @param hsd: SD handle - * @param SD_CMD: The sent command index - * @param pRCA: Pointer to the variable that will contain the SD card relative + * @param hsd SD handle + * @param SD_CMD The sent command index + * @param pRCA Pointer to the variable that will contain the SD card relative * address RCA * @retval SD Card error state */ @@ -3189,7 +3189,7 @@ /** * @brief Enables the SDIO wide bus mode. - * @param hsd: SD handle + * @param hsd SD handle * @retval SD Card error state */ static HAL_SD_ErrorTypedef SD_WideBus_Enable( SD_HandleTypeDef * hsd ) @@ -3258,7 +3258,7 @@ /** * @brief Disables the SDIO wide bus mode. - * @param hsd: SD handle + * @param hsd SD handle * @retval SD Card error state */ static HAL_SD_ErrorTypedef SD_WideBus_Disable( SD_HandleTypeDef * hsd ) @@ -3328,8 +3328,8 @@ /** * @brief Finds the SD card SCR register value. - * @param hsd: SD handle - * @param pSCR: pointer to the buffer that will contain the SCR value + * @param hsd SD handle + * @param pSCR pointer to the buffer that will contain the SCR value * @retval SD Card error state */ static HAL_SD_ErrorTypedef SD_FindSCR( SD_HandleTypeDef * hsd, @@ -3452,8 +3452,8 @@ /** * @brief Checks if the SD card is in programming state. - * @param hsd: SD handle - * @param pStatus: pointer to the variable that will contain the SD card state + * @param hsd SD handle + * @param pStatus pointer to the variable that will contain the SD card state * @retval SD Card error state */ static HAL_SD_ErrorTypedef SD_IsCardProgramming( SD_HandleTypeDef * hsd, diff --git a/portable/STM32F4xx/stm32f4xx_hal_sd.h b/portable/STM32F4xx/stm32f4xx_hal_sd.h index 5d339ba..71950be 100755 --- a/portable/STM32F4xx/stm32f4xx_hal_sd.h +++ b/portable/STM32F4xx/stm32f4xx_hal_sd.h @@ -476,8 +476,8 @@ /** * @brief Enable the SD device interrupt. - * @param __HANDLE__: SD Handle - * @param __INTERRUPT__: specifies the SDIO interrupt sources to be enabled. + * @param __HANDLE__ SD Handle + * @param __INTERRUPT__ specifies the SDIO interrupt sources to be enabled. * This parameter can be one or a combination of the following values: * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt @@ -510,8 +510,8 @@ /** * @brief Disable the SD device interrupt. - * @param __HANDLE__: SD Handle - * @param __INTERRUPT__: specifies the SDIO interrupt sources to be disabled. + * @param __HANDLE__ SD Handle + * @param __INTERRUPT__ specifies the SDIO interrupt sources to be disabled. * This parameter can be one or a combination of the following values: * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt @@ -544,8 +544,8 @@ /** * @brief Check whether the specified SD flag is set or not. - * @param __HANDLE__: SD Handle - * @param __FLAG__: specifies the flag to check. + * @param __HANDLE__ SD Handle + * @param __FLAG__ specifies the flag to check. * This parameter can be one of the following values: * @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed) * @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed) @@ -577,8 +577,8 @@ /** * @brief Clear the SD's pending flags. - * @param __HANDLE__: SD Handle - * @param __FLAG__: specifies the flag to clear. + * @param __HANDLE__ SD Handle + * @param __FLAG__ specifies the flag to clear. * This parameter can be one or a combination of the following values: * @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed) * @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed) @@ -599,8 +599,8 @@ /** * @brief Check whether the specified SD interrupt has occurred or not. - * @param __HANDLE__: SD Handle - * @param __INTERRUPT__: specifies the SDIO interrupt source to check. + * @param __HANDLE__ SD Handle + * @param __INTERRUPT__ specifies the SDIO interrupt source to check. * This parameter can be one of the following values: * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt @@ -633,8 +633,8 @@ /** * @brief Clear the SD's interrupt pending bits. - * @param __HANDLE__ : SD Handle - * @param __INTERRUPT__: specifies the interrupt pending bit to clear. + * @param __HANDLE__ SD Handle + * @param __INTERRUPT__ specifies the interrupt pending bit to clear. * This parameter can be one or a combination of the following values: * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt diff --git a/portable/STM32F4xx/stm32f4xx_ll_sdmmc.c b/portable/STM32F4xx/stm32f4xx_ll_sdmmc.c index 54b6591..af942ed 100644 --- a/portable/STM32F4xx/stm32f4xx_ll_sdmmc.c +++ b/portable/STM32F4xx/stm32f4xx_ll_sdmmc.c @@ -206,8 +206,8 @@ /** * @brief Initializes the SDIO according to the specified * parameters in the SDIO_InitTypeDef and create the associated handle. - * @param SDIOx: Pointer to SDIO register base - * @param Init: SDIO initialization structure + * @param SDIOx Pointer to SDIO register base + * @param Init SDIO initialization structure * @retval HAL status */ HAL_StatusTypeDef SDIO_Init( SDIO_TypeDef * SDIOx, @@ -260,7 +260,7 @@ /** * @brief Read data (word) from Rx FIFO in blocking mode (polling) - * @param SDIOx: Pointer to SDIO register base + * @param SDIOx Pointer to SDIO register base * @retval HAL status */ uint32_t SDIO_ReadFIFO( SDIO_TypeDef * SDIOx ) @@ -271,8 +271,8 @@ /** * @brief Write data (word) to Tx FIFO in blocking mode (polling) - * @param SDIOx: Pointer to SDIO register base - * @param pWriteData: pointer to data to write + * @param SDIOx Pointer to SDIO register base + * @param pWriteData pointer to data to write * @retval HAL status */ HAL_StatusTypeDef SDIO_WriteFIFO( SDIO_TypeDef * SDIOx, @@ -305,7 +305,7 @@ /** * @brief Set SDIO Power state to ON. - * @param SDIOx: Pointer to SDIO register base + * @param SDIOx Pointer to SDIO register base * @retval HAL status */ HAL_StatusTypeDef SDIO_PowerState_ON( SDIO_TypeDef * SDIOx ) @@ -318,7 +318,7 @@ /** * @brief Set SDIO Power state to OFF. - * @param SDIOx: Pointer to SDIO register base + * @param SDIOx Pointer to SDIO register base * @retval HAL status */ HAL_StatusTypeDef SDIO_PowerState_OFF( SDIO_TypeDef * SDIOx ) @@ -331,7 +331,7 @@ /** * @brief Get SDIO Power state. - * @param SDIOx: Pointer to SDIO register base + * @param SDIOx Pointer to SDIO register base * @retval Power status of the controller. The returned value can be one of the * following values: * - 0x00: Power OFF @@ -346,8 +346,8 @@ /** * @brief Configure the SDIO command path according to the specified parameters in * SDIO_CmdInitTypeDef structure and send the command - * @param SDIOx: Pointer to SDIO register base - * @param SDIO_CmdInitStruct: pointer to a SDIO_CmdInitTypeDef structure that contains + * @param SDIOx Pointer to SDIO register base + * @param SDIO_CmdInitStruct pointer to a SDIO_CmdInitTypeDef structure that contains * the configuration information for the SDIO command * @retval HAL status */ @@ -379,7 +379,7 @@ /** * @brief Return the command index of last command for which response received - * @param SDIOx: Pointer to SDIO register base + * @param SDIOx Pointer to SDIO register base * @retval Command index of the last command response received */ uint8_t SDIO_GetCommandResponse( SDIO_TypeDef * SDIOx ) @@ -390,7 +390,7 @@ /** * @brief Return the response received from the card for the last command - * @param SDIO_RESP: Specifies the SDIO response register. + * @param SDIO_RESP Specifies the SDIO response register. * This parameter can be one of the following values: * @arg SDIO_RESP1: Response Register 1 * @arg SDIO_RESP2: Response Register 2 @@ -414,8 +414,8 @@ /** * @brief Configure the SDIO data path according to the specified * parameters in the SDIO_DataInitTypeDef. - * @param SDIOx: Pointer to SDIO register base - * @param SDIO_DataInitStruct : pointer to a SDIO_DataInitTypeDef structure + * @param SDIOx Pointer to SDIO register base + * @param SDIO_DataInitStruct pointer to a SDIO_DataInitTypeDef structure * that contains the configuration information for the SDIO command. * @retval HAL status */ @@ -453,7 +453,7 @@ /** * @brief Returns number of remaining data bytes to be transferred. - * @param SDIOx: Pointer to SDIO register base + * @param SDIOx Pointer to SDIO register base * @retval Number of remaining data bytes to be transferred */ uint32_t SDIO_GetDataCounter( SDIO_TypeDef * SDIOx ) @@ -463,7 +463,7 @@ /** * @brief Get the FIFO data - * @param SDIOx: Pointer to SDIO register base + * @param SDIOx Pointer to SDIO register base * @retval Data received */ uint32_t SDIO_GetFIFOCount( SDIO_TypeDef * SDIOx ) @@ -474,7 +474,7 @@ /** * @brief Sets one of the two options of inserting read wait interval. - * @param SDIO_ReadWaitMode: SD I/O Read Wait operation mode. + * @param SDIO_ReadWaitMode SD I/O Read Wait operation mode. * This parameter can be: * @arg SDIO_READ_WAIT_MODE_CLK: Read Wait control by stopping SDIOCLK * @arg SDIO_READ_WAIT_MODE_DATA2: Read Wait control using SDIO_DATA2 diff --git a/portable/STM32F4xx/stm32f4xx_ll_sdmmc.h b/portable/STM32F4xx/stm32f4xx_ll_sdmmc.h index 3b29d85..ae08fb9 100644 --- a/portable/STM32F4xx/stm32f4xx_ll_sdmmc.h +++ b/portable/STM32F4xx/stm32f4xx_ll_sdmmc.h @@ -606,8 +606,8 @@ /** * @brief Enable the SDIO device interrupt. - * @param __INSTANCE__ : Pointer to SDIO register base - * @param __INTERRUPT__ : specifies the SDIO interrupt sources to be enabled. + * @param __INSTANCE__ Pointer to SDIO register base + * @param __INTERRUPT__ specifies the SDIO interrupt sources to be enabled. * This parameter can be one or a combination of the following values: * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt @@ -640,8 +640,8 @@ /** * @brief Disable the SDIO device interrupt. - * @param __INSTANCE__ : Pointer to SDIO register base - * @param __INTERRUPT__ : specifies the SDIO interrupt sources to be disabled. + * @param __INSTANCE__ Pointer to SDIO register base + * @param __INTERRUPT__ specifies the SDIO interrupt sources to be disabled. * This parameter can be one or a combination of the following values: * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt @@ -674,8 +674,8 @@ /** * @brief Checks whether the specified SDIO flag is set or not. - * @param __INSTANCE__ : Pointer to SDIO register base - * @param __FLAG__: specifies the flag to check. + * @param __INSTANCE__ Pointer to SDIO register base + * @param __FLAG__ specifies the flag to check. * This parameter can be one of the following values: * @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed) * @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed) @@ -708,8 +708,8 @@ /** * @brief Clears the SDIO pending flags. - * @param __INSTANCE__ : Pointer to SDIO register base - * @param __FLAG__: specifies the flag to clear. + * @param __INSTANCE__ Pointer to SDIO register base + * @param __FLAG__ specifies the flag to clear. * This parameter can be one or a combination of the following values: * @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed) * @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed) @@ -730,8 +730,8 @@ /** * @brief Checks whether the specified SDIO interrupt has occurred or not. - * @param __INSTANCE__ : Pointer to SDIO register base - * @param __INTERRUPT__: specifies the SDIO interrupt source to check. + * @param __INSTANCE__ Pointer to SDIO register base + * @param __INTERRUPT__ specifies the SDIO interrupt source to check. * This parameter can be one of the following values: * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt @@ -764,8 +764,8 @@ /** * @brief Clears the SDIO's interrupt pending bits. - * @param __INSTANCE__ : Pointer to SDIO register base - * @param __INTERRUPT__: specifies the interrupt pending bit to clear. + * @param __INSTANCE__ Pointer to SDIO register base + * @param __INTERRUPT__ specifies the interrupt pending bit to clear. * This parameter can be one or a combination of the following values: * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt diff --git a/portable/STM32F7xx/stm32f7xx_hal_sd.c b/portable/STM32F7xx/stm32f7xx_hal_sd.c index 37d9ab4..e382363 100755 --- a/portable/STM32F7xx/stm32f7xx_hal_sd.c +++ b/portable/STM32F7xx/stm32f7xx_hal_sd.c @@ -440,8 +440,8 @@ /** * @brief Initializes the SD card according to the specified parameters in the * SD_HandleTypeDef and create the associated handle. - * @param hsd: SD handle - * @param SDCardInfo: HAL_SD_CardInfoTypedef structure for SD card information + * @param hsd SD handle + * @param SDCardInfo HAL_SD_CardInfoTypedef structure for SD card information * @retval HAL SD error state */ HAL_SD_ErrorTypedef HAL_SD_Init( SD_HandleTypeDef * hsd, @@ -510,7 +510,7 @@ /** * @brief De-Initializes the SD card. - * @param hsd: SD handle + * @param hsd SD handle * @retval HAL status */ HAL_StatusTypeDef HAL_SD_DeInit( SD_HandleTypeDef * hsd ) @@ -527,7 +527,7 @@ /** * @brief Initializes the SD MSP. - * @param hsd: SD handle + * @param hsd SD handle * @retval None */ __weak void HAL_SD_MspInit( SD_HandleTypeDef * hsd ) @@ -539,7 +539,7 @@ /** * @brief De-Initialize SD MSP. - * @param hsd: SD handle + * @param hsd SD handle * @retval None */ __weak void HAL_SD_MspDeInit( SD_HandleTypeDef * hsd ) @@ -571,10 +571,12 @@ /** * @brief Reads block(s) from a specified address in a card. The Data transfer * is managed by polling mode. - * @param hsd: SD handle - * @param pReadBuffer: pointer to the buffer that will contain the received data - * @param ReadAddr: Address from where data is to be read as a byte-offset. - * @param NumberOfBlocks: Number of SD blocks to read + * @param hsd SD handle + * @param pReadBuffer pointer to the buffer that will contain the received data + * @param ReadAddr Address from where data is to be read + * @param BlockSize SD card Data block size + * @note BlockSize must be 512 bytes. + * @param NumberOfBlocks Number of SD blocks to read * @retval SD Card error state */ HAL_SD_ErrorTypedef HAL_SD_ReadBlocks( SD_HandleTypeDef * hsd, @@ -750,10 +752,12 @@ /** * @brief Allows to write block(s) to a specified address in a card. The Data * transfer is managed by polling mode. - * @param hsd: SD handle - * @param pWriteBuffer: pointer to the buffer that will contain the data to transmit - * @param WriteAddr: Address from where data is to be written - * @param NumberOfBlocks: Number of SD blocks to write + * @param hsd SD handle + * @param pWriteBuffer pointer to the buffer that will contain the data to transmit + * @param WriteAddr Address from where data is to be written + * @param BlockSize SD card Data block size + * @note BlockSize must be 512 bytes. + * @param NumberOfBlocks Number of SD blocks to write * @retval SD Card error state */ HAL_SD_ErrorTypedef HAL_SD_WriteBlocks( SD_HandleTypeDef * hsd, @@ -988,10 +992,12 @@ * is managed by DMA mode. * @note This API should be followed by the function HAL_SD_CheckReadOperation() * to check the completion of the read process - * @param hsd: SD handle - * @param pReadBuffer: Pointer to the buffer that will contain the received data - * @param ReadAddr: Address from where data is to be read - * @param NumberOfBlocks: Number of blocks to read. + * @param hsd SD handle + * @param pReadBuffer Pointer to the buffer that will contain the received data + * @param ReadAddr Address from where data is to be read + * @param BlockSize SD card Data block size + * @note BlockSize must be 512 bytes. + * @param NumberOfBlocks Number of blocks to read. * @retval SD Card error state */ HAL_SD_ErrorTypedef HAL_SD_ReadBlocks_DMA( SD_HandleTypeDef * hsd, @@ -1103,10 +1109,12 @@ * is managed by DMA mode. * @note This API should be followed by the function HAL_SD_CheckWriteOperation() * to check the completion of the write process (by SD current status polling). - * @param hsd: SD handle - * @param pWriteBuffer: pointer to the buffer that will contain the data to transmit - * @param WriteAddr: Address from where data is to be read - * @param NumberOfBlocks: Number of blocks to write + * @param hsd SD handle + * @param pWriteBuffer pointer to the buffer that will contain the data to transmit + * @param WriteAddr Address from where data is to be read + * @param BlockSize the SD card Data block size + * @note BlockSize must be 512 bytes. + * @param NumberOfBlocks Number of blocks to write * @retval SD Card error state */ HAL_SD_ErrorTypedef HAL_SD_WriteBlocks_DMA( SD_HandleTypeDef * hsd, @@ -1240,8 +1248,8 @@ * This API should be called after HAL_SD_ReadBlocks_DMA() function * to insure that all data sent by the card is already transferred by the * DMA controller. - * @param hsd: SD handle - * @param Timeout: Timeout duration + * @param hsd SD handle + * @param Timeout Timeout duration * @retval SD Card error state */ @@ -1330,8 +1338,8 @@ * This API should be called after HAL_SD_WriteBlocks_DMA() function * to insure that all data sent by the card is already transferred by the * DMA controller. - * @param hsd: SD handle - * @param Timeout: Timeout duration + * @param hsd SD handle + * @param Timeout Timeout duration * @retval SD Card error state */ HAL_SD_ErrorTypedef HAL_SD_CheckWriteOperation( SD_HandleTypeDef * hsd, @@ -1424,9 +1432,9 @@ /** * @brief Erases the specified memory area of the given SD card. - * @param hsd: SD handle - * @param startaddr: Start byte address - * @param endaddr: End byte address + * @param hsd SD handle + * @param startaddr Start byte address + * @param endaddr End byte address * @retval SD Card error state */ HAL_SD_ErrorTypedef HAL_SD_Erase( SD_HandleTypeDef * hsd, @@ -1532,7 +1540,7 @@ /** * @brief This function handles SD card interrupt request. - * @param hsd: SD handle + * @param hsd SD handle * @retval None */ void HAL_SD_IRQHandler( SD_HandleTypeDef * hsd ) @@ -1596,7 +1604,7 @@ /** * @brief SD end of transfer callback. - * @param hsd: SD handle + * @param hsd SD handle * @retval None */ __weak void HAL_SD_XferCpltCallback( SD_HandleTypeDef * hsd ) @@ -1608,7 +1616,7 @@ /** * @brief SD Transfer Error callback. - * @param hsd: SD handle + * @param hsd SD handle * @retval None */ __weak void HAL_SD_XferErrorCallback( SD_HandleTypeDef * hsd ) @@ -1620,7 +1628,7 @@ /** * @brief SD Transfer complete Rx callback in non blocking mode. - * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * @param hdma pointer to a DMA_HandleTypeDef structure that contains * the configuration information for the specified DMA module. * @retval None */ @@ -1633,7 +1641,7 @@ /** * @brief SD DMA transfer complete Rx error callback. - * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * @param hdma pointer to a DMA_HandleTypeDef structure that contains * the configuration information for the specified DMA module. * @retval None */ @@ -1646,7 +1654,7 @@ /** * @brief SD Transfer complete Tx callback in non blocking mode. - * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * @param hdma pointer to a DMA_HandleTypeDef structure that contains * the configuration information for the specified DMA module. * @retval None */ @@ -1659,7 +1667,7 @@ /** * @brief SD DMA transfer complete error Tx callback. - * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * @param hdma pointer to a DMA_HandleTypeDef structure that contains * the configuration information for the specified DMA module. * @retval None */ @@ -1691,8 +1699,8 @@ /** * @brief Returns information about specific card. - * @param hsd: SD handle - * @param pCardInfo: Pointer to a HAL_SD_CardInfoTypedef structure that + * @param hsd SD handle + * @param pCardInfo Pointer to a HAL_SD_CardInfoTypedef structure that * contains all SD cardinformation * @retval SD Card error state */ @@ -1905,8 +1913,8 @@ /** * @brief Enables wide bus operation for the requested card if supported by * card. - * @param hsd: SD handle - * @param WideMode: Specifies the SD card wide bus mode + * @param hsd SD handle + * @param WideMode Specifies the SD card wide bus mode * This parameter can be one of the following values: * @arg SDIO_BUS_WIDE_8B: 8-bit data transfer (Only for MMC) * @arg SDIO_BUS_WIDE_4B: 4-bit data transfer @@ -1965,7 +1973,7 @@ /** * @brief Aborts an ongoing data transfer. - * @param hsd: SD handle + * @param hsd SD handle * @retval SD Card error state */ HAL_SD_ErrorTypedef HAL_SD_StopTransfer( SD_HandleTypeDef * hsd ) @@ -1992,7 +2000,7 @@ * This API must be used after "Transfer State" * @note This operation should be followed by the configuration * of PLL to have SDIOCK clock between 67 and 75 MHz - * @param hsd: SD handle + * @param hsd SD handle * @retval SD Card error state */ HAL_SD_ErrorTypedef HAL_SD_HighSpeed( SD_HandleTypeDef * hsd ) @@ -2145,8 +2153,8 @@ /** * @brief Returns the current SD card's status. - * @param hsd: SD handle - * @param pSDstatus: Pointer to the buffer that will contain the SD card status + * @param hsd SD handle + * @param pSDstatus Pointer to the buffer that will contain the SD card status * SD Status register) * @retval SD Card error state */ @@ -2277,7 +2285,7 @@ /** * @brief Gets the current sd card data status. - * @param hsd: SD handle + * @param hsd SD handle * @retval Data Transfer state */ HAL_SD_TransferStateTypedef HAL_SD_GetStatus( SD_HandleTypeDef * hsd ) @@ -2304,8 +2312,8 @@ /** * @brief Gets the SD card status. - * @param hsd: SD handle - * @param pCardStatus: Pointer to the HAL_SD_CardStatusTypedef structure that + * @param hsd SD handle + * @param pCardStatus Pointer to the HAL_SD_CardStatusTypedef structure that * will contain the SD card status information * @retval SD Card error state */ @@ -2402,7 +2410,7 @@ /** * @brief SD DMA transfer complete Rx callback. - * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * @param hdma pointer to a DMA_HandleTypeDef structure that contains * the configuration information for the specified DMA module. * @retval None */ @@ -2427,7 +2435,7 @@ /** * @brief SD DMA transfer Error Rx callback. - * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * @param hdma pointer to a DMA_HandleTypeDef structure that contains * the configuration information for the specified DMA module. * @retval None */ @@ -2441,7 +2449,7 @@ /** * @brief SD DMA transfer complete Tx callback. - * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * @param hdma pointer to a DMA_HandleTypeDef structure that contains * the configuration information for the specified DMA module. * @retval None */ @@ -2466,7 +2474,7 @@ /** * @brief SD DMA transfer Error Tx callback. - * @param hdma: pointer to a DMA_HandleTypeDef structure that contains + * @param hdma pointer to a DMA_HandleTypeDef structure that contains * the configuration information for the specified DMA module. * @retval None */ @@ -2480,7 +2488,7 @@ /** * @brief Returns the SD current state. - * @param hsd: SD handle + * @param hsd SD handle * @retval SD card current state */ static HAL_SD_CardStateTypedef SD_GetState( SD_HandleTypeDef * hsd ) @@ -2500,7 +2508,7 @@ /** * @brief Initializes all cards or single card as the case may be Card(s) come * into standby state. - * @param hsd: SD handle + * @param hsd SD handle * @retval SD Card error state */ static HAL_SD_ErrorTypedef SD_Initialize_Cards( SD_HandleTypeDef * hsd ) @@ -2591,8 +2599,8 @@ /** * @brief Selects of Deselects the corresponding card. - * @param hsd: SD handle - * @param addr: Address of the card to be selected + * @param hsd SD handle + * @param addr Address of the card to be selected * @retval SD Card error state */ static HAL_SD_ErrorTypedef SD_Select_Deselect( SD_HandleTypeDef * hsd, @@ -2619,7 +2627,7 @@ * @brief Enquires cards about their operating voltage and configures clock * controls and stores SD information that will be needed in future * in the SD handle. - * @param hsd: SD handle + * @param hsd SD handle * @retval SD Card error state */ static HAL_SD_ErrorTypedef SD_PowerON( SD_HandleTypeDef * hsd ) @@ -2767,7 +2775,7 @@ /** * @brief Turns the SDMMC output signals off. - * @param hsd: SD handle + * @param hsd SD handle * @retval SD Card error state */ static HAL_SD_ErrorTypedef SD_PowerOFF( SD_HandleTypeDef * hsd ) @@ -2782,8 +2790,8 @@ /** * @brief Returns the current card's status. - * @param hsd: SD handle - * @param pCardStatus: pointer to the buffer that will contain the SD card + * @param hsd SD handle + * @param pCardStatus pointer to the buffer that will contain the SD card * status (Card Status register) * @retval SD Card error state */ @@ -2824,7 +2832,7 @@ /** * @brief Checks for error conditions for CMD0. - * @param hsd: SD handle + * @param hsd SD handle * @retval SD Card error state */ static HAL_SD_ErrorTypedef SD_CmdError( SD_HandleTypeDef * hsd ) @@ -2865,7 +2873,7 @@ /** * @brief Checks for error conditions for R7 response. - * @param hsd: SD handle + * @param hsd SD handle * @retval SD Card error state */ static HAL_SD_ErrorTypedef SD_CmdResp7Error( SD_HandleTypeDef * hsd ) @@ -2917,8 +2925,8 @@ /** * @brief Checks for error conditions for R1 response. - * @param hsd: SD handle - * @param SD_CMD: The sent command index + * @param hsd SD handle + * @param SD_CMD The sent command index * @retval SD Card error state */ static HAL_SD_ErrorTypedef SD_CmdResp1Error( SD_HandleTypeDef * hsd, @@ -3073,7 +3081,7 @@ /** * @brief Checks for error conditions for R3 (OCR) response. - * @param hsd: SD handle + * @param hsd SD handle * @retval SD Card error state */ static HAL_SD_ErrorTypedef SD_CmdResp3Error( SD_HandleTypeDef * hsd ) @@ -3101,7 +3109,7 @@ /** * @brief Checks for error conditions for R2 (CID or CSD) response. - * @param hsd: SD handle + * @param hsd SD handle * @retval SD Card error state */ static HAL_SD_ErrorTypedef SD_CmdResp2Error( SD_HandleTypeDef * hsd ) @@ -3141,9 +3149,9 @@ /** * @brief Checks for error conditions for R6 (RCA) response. - * @param hsd: SD handle - * @param SD_CMD: The sent command index - * @param pRCA: Pointer to the variable that will contain the SD card relative + * @param hsd SD handle + * @param SD_CMD The sent command index + * @param pRCA Pointer to the variable that will contain the SD card relative * address RCA * @retval SD Card error state */ @@ -3222,7 +3230,7 @@ /** * @brief Enables the SDMMC wide bus mode. - * @param hsd: SD handle + * @param hsd SD handle * @retval SD Card error state */ static HAL_SD_ErrorTypedef SD_WideBus_Enable( SD_HandleTypeDef * hsd ) @@ -3291,7 +3299,7 @@ /** * @brief Disables the SDMMC wide bus mode. - * @param hsd: SD handle + * @param hsd SD handle * @retval SD Card error state */ static HAL_SD_ErrorTypedef SD_WideBus_Disable( SD_HandleTypeDef * hsd ) @@ -3361,8 +3369,8 @@ /** * @brief Finds the SD card SCR register value. - * @param hsd: SD handle - * @param pSCR: pointer to the buffer that will contain the SCR value + * @param hsd SD handle + * @param pSCR pointer to the buffer that will contain the SCR value * @retval SD Card error state */ static HAL_SD_ErrorTypedef SD_FindSCR( SD_HandleTypeDef * hsd, @@ -3477,8 +3485,8 @@ /** * @brief Checks if the SD card is in programming state. - * @param hsd: SD handle - * @param pStatus: pointer to the variable that will contain the SD card state + * @param hsd SD handle + * @param pStatus pointer to the variable that will contain the SD card state * @retval SD Card error state */ static HAL_SD_ErrorTypedef SD_IsCardProgramming( SD_HandleTypeDef * hsd, diff --git a/portable/STM32F7xx/stm32f7xx_hal_sd.h b/portable/STM32F7xx/stm32f7xx_hal_sd.h index 7555416..aa61dd1 100755 --- a/portable/STM32F7xx/stm32f7xx_hal_sd.h +++ b/portable/STM32F7xx/stm32f7xx_hal_sd.h @@ -477,8 +477,8 @@ /** * @brief Enable the SD device interrupt. - * @param __HANDLE__: SD Handle - * @param __INTERRUPT__: specifies the SDMMC interrupt sources to be enabled. + * @param __HANDLE__ SD Handle + * @param __INTERRUPT__ specifies the SDMMC interrupt sources to be enabled. * This parameter can be one or a combination of the following values: * @arg SDMMC_IT_CCRCFAIL: Command response received (CRC check failed) interrupt * @arg SDMMC_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt @@ -508,8 +508,8 @@ /** * @brief Disable the SD device interrupt. - * @param __HANDLE__: SD Handle - * @param __INTERRUPT__: specifies the SDMMC interrupt sources to be disabled. + * @param __HANDLE__ SD Handle + * @param __INTERRUPT__ specifies the SDMMC interrupt sources to be disabled. * This parameter can be one or a combination of the following values: * @arg SDMMC_IT_CCRCFAIL: Command response received (CRC check failed) interrupt * @arg SDMMC_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt @@ -539,8 +539,8 @@ /** * @brief Check whether the specified SD flag is set or not. - * @param __HANDLE__: SD Handle - * @param __FLAG__: specifies the flag to check. + * @param __HANDLE__ SD Handle + * @param __FLAG__ specifies the flag to check. * This parameter can be one of the following values: * @arg SDMMC_FLAG_CCRCFAIL: Command response received (CRC check failed) * @arg SDMMC_FLAG_DCRCFAIL: Data block sent/received (CRC check failed) @@ -570,8 +570,8 @@ /** * @brief Clear the SD's pending flags. - * @param __HANDLE__: SD Handle - * @param __FLAG__: specifies the flag to clear. + * @param __HANDLE__ SD Handle + * @param __FLAG__ specifies the flag to clear. * This parameter can be one or a combination of the following values: * @arg SDMMC_FLAG_CCRCFAIL: Command response received (CRC check failed) * @arg SDMMC_FLAG_DCRCFAIL: Data block sent/received (CRC check failed) @@ -590,8 +590,8 @@ /** * @brief Check whether the specified SD interrupt has occurred or not. - * @param __HANDLE__: SD Handle - * @param __INTERRUPT__: specifies the SDMMC interrupt source to check. + * @param __HANDLE__ SD Handle + * @param __INTERRUPT__ specifies the SDMMC interrupt source to check. * This parameter can be one of the following values: * @arg SDMMC_IT_CCRCFAIL: Command response received (CRC check failed) interrupt * @arg SDMMC_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt @@ -621,8 +621,8 @@ /** * @brief Clear the SD's interrupt pending bits. - * @param __HANDLE__ : SD Handle - * @param __INTERRUPT__: specifies the interrupt pending bit to clear. + * @param __HANDLE__ SD Handle + * @param __INTERRUPT__ specifies the interrupt pending bit to clear. * This parameter can be one or a combination of the following values: * @arg SDMMC_IT_CCRCFAIL: Command response received (CRC check failed) interrupt * @arg SDMMC_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt From b583a7369c4775087a0a46a9b29986f9ffc7e659 Mon Sep 17 00:00:00 2001 From: Paul Helter Date: Mon, 31 Oct 2022 19:02:52 -0700 Subject: [PATCH 03/12] Converting prints from %lu to %u where possible as per request in comments related to (#35) --- ff_format.c | 11 ++++++----- portable/ATSAM4E/ff_sddisk.c | 22 +++++++++++----------- portable/ATSAM4E/ff_sddisk_r.c | 22 +++++++++++----------- portable/STM32F4xx/ff_sddisk.c | 22 +++++++++++----------- portable/STM32F7xx/ff_sddisk.c | 22 +++++++++++----------- portable/Zynq.2019.3/ff_sddisk.c | 6 +++--- portable/Zynq/ff_sddisk.c | 22 +++++++++++----------- portable/common/ff_ramdisk.c | 8 ++++---- portable/lpc18xx/ff_sddisk.c | 14 +++++++------- 9 files changed, 75 insertions(+), 74 deletions(-) diff --git a/ff_format.c b/ff_format.c index 05c9fe0..3edd290 100755 --- a/ff_format.c +++ b/ff_format.c @@ -373,8 +373,8 @@ static FF_Error_t prvFormatWriteBPB( struct xFormatSet * pxSet, FF_putLong( pxSet->pucSectorBuffer, OFS_BPB_HiddSec_32, ( uint32_t ) pxSet->ulHiddenSectors ); /* 0x01C / n.a. 0 for nonparitioned volume */ FF_putChar( pxSet->pucSectorBuffer, OFS_BPB_SecPerClus_8, ( uint32_t ) pxSet->ulSectorsPerCluster ); /* 0x00D / Only 1, 2, 4, 8, 16, 32, 64, 128 */ - FF_PRINTF( "FF_Format: SecCluster %lu DatSec %lu DataClus %lu pxSet->ulClusterBeginLBA %lu\n", - pxSet->ulSectorsPerCluster, pxSet->ulUsableDataSectors, pxSet->ulUsableDataClusters, pxSet->ulClusterBeginLBA ); + FF_PRINTF( "FF_Format: SecCluster %u DatSec %u DataClus %u pxSet->ulClusterBeginLBA %lu\n", + (unsigned) pxSet->ulSectorsPerCluster, (unsigned) pxSet->ulUsableDataSectors, (unsigned) pxSet->ulUsableDataClusters, pxSet->ulClusterBeginLBA ); /* This field is the new 32-bit total count of sectors on the volume. */ /* This count includes the count of all sectors in all four regions of the volume */ @@ -462,7 +462,7 @@ static FF_Error_t prvFormatInitialiseFAT( struct xFormatSet * pxSet, xReturn = FF_BlockWrite( pxSet->pxIOManager, ( uint32_t ) lFatBeginLBA + pxSet->ulSectorsPerFAT, 1, pxSet->pucSectorBuffer, pdFALSE ); } - FF_PRINTF( "FF_Format: Clearing entire FAT (2 x %lu sectors):\n", pxSet->ulSectorsPerFAT ); + FF_PRINTF( "FF_Format: Clearing entire FAT (2 x %u sectors):\n", (unsigned) pxSet->ulSectorsPerFAT ); { int32_t addr; @@ -636,8 +636,9 @@ FF_Error_t FF_FormatDisk( FF_Disk_t * pxDisk, xSet.ulClustersPerFATSector = xSet.pxIOManager->usSectorSize / sizeof( uint16_t ); } - FF_PRINTF( "FF_Format: Secs %lu Rsvd %lu Hidden %lu Root %lu Data %lu\n", - xSet.ulSectorCount, xSet.ulFATReservedSectors, xSet.ulHiddenSectors, xSet.iFAT16RootSectors, xSet.ulSectorCount - xSet.ulNonDataSectors ); + FF_PRINTF( "FF_Format: Secs %u Rsvd %u Hidden %u Root %u Data %u\n", + (unsigned) xSet.ulSectorCount, (unsigned) xSet.ulFATReservedSectors, (unsigned) xSet.ulHiddenSectors, + (unsigned) xSet.iFAT16RootSectors, (unsigned) xSet.ulSectorCount - xSet.ulNonDataSectors ); /*****************************/ diff --git a/portable/ATSAM4E/ff_sddisk.c b/portable/ATSAM4E/ff_sddisk.c index a4b4c1d..c78bd69 100755 --- a/portable/ATSAM4E/ff_sddisk.c +++ b/portable/ATSAM4E/ff_sddisk.c @@ -209,7 +209,7 @@ static int32_t prvFFRead( uint8_t * pucBuffer, else { /* Some error occurred. */ - FF_PRINTF( "prvFFRead: %lu: %ld\n", ulSectorNumber, lResult ); + FF_PRINTF( "prvFFRead: %u: %d\n", (unsigned) ulSectorNumber, (int) lResult ); } } else @@ -219,7 +219,7 @@ static int32_t prvFFRead( uint8_t * pucBuffer, if( pxDisk->xStatus.bIsInitialised != pdFALSE ) { - FF_PRINTF( "prvFFRead: warning: %lu + %lu > %lu\n", ulSectorNumber, ulSectorCount, pxDisk->ulNumberOfSectors ); + FF_PRINTF( "prvFFRead: warning: %u + %u > %u\n", (unsigned) ulSectorNumber, (unsigned) ulSectorCount, (unsigned) pxDisk->ulNumberOfSectors ); } } @@ -284,14 +284,14 @@ static int32_t prvFFWrite( uint8_t * pucBuffer, } else { - FF_PRINTF( "prvFFWrite: %lu: %ld\n", ulSectorNumber, lResult ); + FF_PRINTF( "prvFFWrite: %u: %d\n", (unsigned) ulSectorNumber, (int) lResult ); } } else { if( pxDisk->xStatus.bIsInitialised != pdFALSE ) { - FF_PRINTF( "prvFFWrite: warning: %lu + %lu > %lu\n", ulSectorNumber, ulSectorCount, pxDisk->ulNumberOfSectors ); + FF_PRINTF( "prvFFWrite: warning: %u + %u > %u\n", (unsigned) ulSectorNumber, (unsigned)ulSectorCount, (unsigned)pxDisk->ulNumberOfSectors ); } } @@ -511,7 +511,7 @@ BaseType_t FF_SDDiskMount( FF_Disk_t * pxDisk ) else { pxDisk->xStatus.bIsMounted = pdTRUE; - FF_PRINTF( "****** FreeRTOS+FAT initialized %lu sectors\n", pxDisk->pxIOManager->xPartition.ulTotalSectors ); + FF_PRINTF( "****** FreeRTOS+FAT initialized %u sectors\n", (unsigned)pxDisk->pxIOManager->xPartition.ulTotalSectors ); FF_SDDiskShowPartition( pxDisk ); xReturn = pdPASS; } @@ -615,10 +615,10 @@ BaseType_t FF_SDDiskShowPartition( FF_Disk_t * pxDisk ) FF_PRINTF( "Partition Nr %8u\n", pxDisk->xStatus.bPartitionNumber ); FF_PRINTF( "Type %8u (%s)\n", pxIOManager->xPartition.ucType, pcTypeName ); FF_PRINTF( "VolLabel '%8s' \n", pxIOManager->xPartition.pcVolumeLabel ); - FF_PRINTF( "TotalSectors %8lu\n", pxIOManager->xPartition.ulTotalSectors ); - FF_PRINTF( "SecsPerCluster %8lu\n", pxIOManager->xPartition.ulSectorsPerCluster ); - FF_PRINTF( "Size %8lu MB\n", ulTotalSizeMB ); - FF_PRINTF( "FreeSize %8lu MB ( %d perc free )\n", ulFreeSizeMB, iPercentageFree ); + FF_PRINTF( "TotalSectors %8u\n", (unsigned) pxIOManager->xPartition.ulTotalSectors ); + FF_PRINTF( "SecsPerCluster %8u\n", (unsigned) pxIOManager->xPartition.ulSectorsPerCluster ); + FF_PRINTF( "Size %8u MB\n", (unsigned) ulTotalSizeMB ); + FF_PRINTF( "FreeSize %8u MB ( %d perc free )\n", (unsigned) ulFreeSizeMB, iPercentageFree ); } return xReturn; @@ -714,9 +714,9 @@ static BaseType_t prvSDMMCInit( BaseType_t xDriveNumber ) } else { - FF_PRINTF( "HAL_SD_Init: type: %s Capacity: %lu MB\n", + FF_PRINTF( "HAL_SD_Init: type: %s Capacity: %u MB\n", xSDCardInfo.type & CARD_TYPE_HC ? "SDHC" : "SD", - ( xSDCardInfo.capacity << 1 ) / 2048 ); + (unsigned)(( xSDCardInfo.capacity << 1 ) / 2048U )); xReturn = pdPASS; } diff --git a/portable/ATSAM4E/ff_sddisk_r.c b/portable/ATSAM4E/ff_sddisk_r.c index dc278f0..b26d2f8 100644 --- a/portable/ATSAM4E/ff_sddisk_r.c +++ b/portable/ATSAM4E/ff_sddisk_r.c @@ -100,7 +100,7 @@ static int32_t prvFFRead( uint8_t * pucBuffer, else { /* Some error occurred. */ - FF_PRINTF( "prvFFRead: %lu: %lu\n", ulSectorNumber, lResult ); + FF_PRINTF( "prvFFRead: %u: %u\n", (unsigned) ulSectorNumber, (unsigned) lResult ); } } else @@ -110,7 +110,7 @@ static int32_t prvFFRead( uint8_t * pucBuffer, if( pxDisk->xStatus.bIsInitialised != pdFALSE ) { - FF_PRINTF( "prvFFRead: warning: %lu + %lu > %lu\n", ulSectorNumber, ulSectorCount, pxDisk->ulNumberOfSectors ); + FF_PRINTF( "prvFFRead: warning: %u + %u > %u\n", (unsigned) ulSectorNumber, (unsigned) ulSectorCount, (unsigned) pxDisk->ulNumberOfSectors ); } } @@ -142,14 +142,14 @@ static int32_t prvFFWrite( uint8_t * pucBuffer, } else { - FF_PRINTF( "prvFFWrite: %lu: %lu\n", ulSectorNumber, xResult ); + FF_PRINTF( "prvFFWrite: %u: %u\n", ulSectorNumber, xResult ); } } else { if( pxDisk->xStatus.bIsInitialised != pdFALSE ) { - FF_PRINTF( "prvFFWrite: warning: %lu + %lu > %lu\n", ulSectorNumber, ulSectorCount, pxDisk->ulNumberOfSectors ); + FF_PRINTF( "prvFFWrite: warning: %u + %u > %u\n", (unsigned) ulSectorNumber, (unsigned) ulSectorCount, (unsigned) pxDisk->ulNumberOfSectors ); } } @@ -356,7 +356,7 @@ BaseType_t FF_SDDiskMount( FF_Disk_t * pxDisk ) else { pxDisk->xStatus.bIsMounted = pdTRUE; - FF_PRINTF( "****** FreeRTOS+FAT initialized %lu sectors\n", pxDisk->pxIOManager->xPartition.ulTotalSectors ); + FF_PRINTF( "****** FreeRTOS+FAT initialized %u sectors\n", (unsigned) pxDisk->pxIOManager->xPartition.ulTotalSectors ); xReturn = pdPASS; } @@ -459,10 +459,10 @@ BaseType_t FF_SDDiskShowPartition( FF_Disk_t * pxDisk ) FF_PRINTF( "Partition Nr %8u\n", pxDisk->xStatus.bPartitionNumber ); FF_PRINTF( "Type %8u (%s)\n", pxIOManager->xPartition.ucType, pcTypeName ); FF_PRINTF( "VolLabel '%8s' \n", pxIOManager->xPartition.pcVolumeLabel ); - FF_PRINTF( "TotalSectors %8lu\n", pxIOManager->xPartition.ulTotalSectors ); - FF_PRINTF( "SecsPerCluster %8lu\n", pxIOManager->xPartition.ulSectorsPerCluster ); - FF_PRINTF( "Size %8lu MB\n", ulTotalSizeMB ); - FF_PRINTF( "FreeSize %8lu MB ( %d perc free )\n", ulFreeSizeMB, iPercentageFree ); + FF_PRINTF( "TotalSectors %8u\n", (unsigned) pxIOManager->xPartition.ulTotalSectors ); + FF_PRINTF( "SecsPerCluster %8u\n", (unsigned) pxIOManager->xPartition.ulSectorsPerCluster ); + FF_PRINTF( "Size %8u MB\n", (unsigned) ulTotalSizeMB ); + FF_PRINTF( "FreeSize %8u MB ( %d perc free )\n", (unsigned) ulFreeSizeMB, iPercentageFree ); } return xReturn; @@ -559,9 +559,9 @@ static BaseType_t prvSDMMCInit( BaseType_t xDriveNumber ) } else { - FF_PRINTF( "HAL_SD_Init: type: %s Capacity: %lu MB\n", + FF_PRINTF( "HAL_SD_Init: type: %s Capacity: %u MB\n", xSDCardInfo.type & CARD_TYPE_HC ? "SDHC" : "SD", - ( xSDCardInfo.capacity << 1 ) / 2048 ); + (unsigned) ( xSDCardInfo.capacity << 1 ) / 2048 ); xReturn = pdPASS; } diff --git a/portable/STM32F4xx/ff_sddisk.c b/portable/STM32F4xx/ff_sddisk.c index f835351..dd5d153 100755 --- a/portable/STM32F4xx/ff_sddisk.c +++ b/portable/STM32F4xx/ff_sddisk.c @@ -256,7 +256,7 @@ static int32_t prvFFRead( uint8_t * pucBuffer, else { /* Some error occurred. */ - FF_PRINTF( "prvFFRead: %lu: %u (%s)\n", ulSectorNumber, sd_result, prvSDCodePrintable( sd_result ) ); + FF_PRINTF( "prvFFRead: %u: %u (%s)\n", (unsigned) ulSectorNumber, sd_result, prvSDCodePrintable( sd_result ) ); } } else @@ -266,7 +266,7 @@ static int32_t prvFFRead( uint8_t * pucBuffer, if( pxDisk->xStatus.bIsInitialised != pdFALSE ) { - FF_PRINTF( "prvFFRead: warning: %lu + %lu > %lu\n", ulSectorNumber, ulSectorCount, pxDisk->ulNumberOfSectors ); + FF_PRINTF( "prvFFRead: warning: %u + %u > %u\n", (unsigned) ulSectorNumber, (unsigned) ulSectorCount, (unsinged) pxDisk->ulNumberOfSectors ); } } @@ -353,14 +353,14 @@ static int32_t prvFFWrite( uint8_t * pucBuffer, } else { - FF_PRINTF( "prvFFWrite: %lu: %u (%s)\n", ulSectorNumber, sd_result, prvSDCodePrintable( sd_result ) ); + FF_PRINTF( "prvFFWrite: %u: %u (%s)\n", (unsigned) ulSectorNumber, sd_result, prvSDCodePrintable( sd_result ) ); } } else { if( pxDisk->xStatus.bIsInitialised != pdFALSE ) { - FF_PRINTF( "prvFFWrite: warning: %lu + %lu > %lu\n", ulSectorNumber, ulSectorCount, pxDisk->ulNumberOfSectors ); + FF_PRINTF( "prvFFWrite: warning: %u + %u > %u\n", (unsigned) ulSectorNumber, (unsigned)ulSectorCount, (unsigned)pxDisk->ulNumberOfSectors ); } } @@ -608,7 +608,7 @@ BaseType_t FF_SDDiskMount( FF_Disk_t * pxDisk ) else { pxDisk->xStatus.bIsMounted = pdTRUE; - FF_PRINTF( "****** FreeRTOS+FAT initialized %lu sectors\n", pxDisk->pxIOManager->xPartition.ulTotalSectors ); + FF_PRINTF( "****** FreeRTOS+FAT initialized %u sectors\n", (unsigned) pxDisk->pxIOManager->xPartition.ulTotalSectors ); xReturn = pdPASS; } @@ -711,10 +711,10 @@ BaseType_t FF_SDDiskShowPartition( FF_Disk_t * pxDisk ) FF_PRINTF( "Partition Nr %8u\n", pxDisk->xStatus.bPartitionNumber ); FF_PRINTF( "Type %8u (%s)\n", pxIOManager->xPartition.ucType, pcTypeName ); FF_PRINTF( "VolLabel '%8s' \n", pxIOManager->xPartition.pcVolumeLabel ); - FF_PRINTF( "TotalSectors %8lu\n", pxIOManager->xPartition.ulTotalSectors ); - FF_PRINTF( "SecsPerCluster %8lu\n", pxIOManager->xPartition.ulSectorsPerCluster ); - FF_PRINTF( "Size %8lu MB\n", ulTotalSizeMB ); - FF_PRINTF( "FreeSize %8lu MB ( %d perc free )\n", ulFreeSizeMB, iPercentageFree ); + FF_PRINTF( "TotalSectors %8u\n", (unsigned) pxIOManager->xPartition.ulTotalSectors ); + FF_PRINTF( "SecsPerCluster %8u\n", (unsigned) pxIOManager->xPartition.ulSectorsPerCluster ); + FF_PRINTF( "Size %8u MB\n", (unsigned) ulTotalSizeMB ); + FF_PRINTF( "FreeSize %8u MB ( %d perc free )\n", (unsigned) ulFreeSizeMB, iPercentageFree ); } return xReturn; @@ -866,11 +866,11 @@ static BaseType_t prvSDMMCInit( BaseType_t xDriveNumber ) } } #endif /* if ( BUS_4BITS != 0 ) */ - FF_PRINTF( "HAL_SD_Init: %d: %s type: %s Capacity: %lu MB\n", + FF_PRINTF( "HAL_SD_Init: %d: %s type: %s Capacity: %u MB\n", SD_state, prvSDCodePrintable( ( uint32_t ) SD_state ), xSDHandle.CardType == HIGH_CAPACITY_SD_CARD ? "SDHC" : "SD", - xSDCardInfo.CardCapacity / ( 1024 * 1024 ) ); + (unsigned)(xSDCardInfo.CardCapacity / ( 1024 * 1024 ) )); return SD_state == SD_OK ? 1 : 0; } diff --git a/portable/STM32F7xx/ff_sddisk.c b/portable/STM32F7xx/ff_sddisk.c index b23e62b..588b2ed 100755 --- a/portable/STM32F7xx/ff_sddisk.c +++ b/portable/STM32F7xx/ff_sddisk.c @@ -342,7 +342,7 @@ static int32_t prvFFRead( uint8_t * pucBuffer, else { /* Some error occurred. */ - FF_PRINTF( "prvFFRead: %lu: %lu (%s)\n", ulSectorNumber, sd_result, prvSDCodePrintable( sd_result ) ); + FF_PRINTF( "prvFFRead: %u: %lu (%s)\n", (unsigned) ulSectorNumber, sd_result, prvSDCodePrintable( sd_result ) ); } } else @@ -352,7 +352,7 @@ static int32_t prvFFRead( uint8_t * pucBuffer, if( pxDisk->xStatus.bIsInitialised != pdFALSE ) { - FF_PRINTF( "prvFFRead: warning: %lu + %lu > %lu\n", ulSectorNumber, ulSectorCount, pxDisk->ulNumberOfSectors ); + FF_PRINTF( "prvFFRead: warning: %u + %u > %u\n", (unsigned) ulSectorNumber, (unsigned)ulSectorCount, (unsigned)pxDisk->ulNumberOfSectors ); } } @@ -441,14 +441,14 @@ static int32_t prvFFWrite( uint8_t * pucBuffer, } else { - FF_PRINTF( "prvFFWrite: %lu: %lu (%s)\n", ulSectorNumber, sd_result, prvSDCodePrintable( sd_result ) ); + FF_PRINTF( "prvFFWrite: %u: %lu (%s)\n", (unsigned)ulSectorNumber, sd_result, prvSDCodePrintable( sd_result ) ); } } else { if( pxDisk->xStatus.bIsInitialised != pdFALSE ) { - FF_PRINTF( "prvFFWrite: warning: %lu + %lu > %lu\n", ulSectorNumber, ulSectorCount, pxDisk->ulNumberOfSectors ); + FF_PRINTF( "prvFFWrite: warning: %u + %u > %u\n", (unsigned) ulSectorNumber, (unsigned) ulSectorCount, (unsigned) pxDisk->ulNumberOfSectors ); } } @@ -727,7 +727,7 @@ BaseType_t FF_SDDiskMount( FF_Disk_t * pxDisk ) else { pxDisk->xStatus.bIsMounted = pdTRUE; - FF_PRINTF( "****** FreeRTOS+FAT initialized %lu sectors\n", pxDisk->pxIOManager->xPartition.ulTotalSectors ); + FF_PRINTF( "****** FreeRTOS+FAT initialized %u sectors\n", (unsigned) pxDisk->pxIOManager->xPartition.ulTotalSectors ); xReturn = pdPASS; } @@ -830,10 +830,10 @@ BaseType_t FF_SDDiskShowPartition( FF_Disk_t * pxDisk ) FF_PRINTF( "Partition Nr %8u\n", pxDisk->xStatus.bPartitionNumber ); FF_PRINTF( "Type %8u (%s)\n", pxIOManager->xPartition.ucType, pcTypeName ); FF_PRINTF( "VolLabel '%8s' \n", pxIOManager->xPartition.pcVolumeLabel ); - FF_PRINTF( "TotalSectors %8lu\n", pxIOManager->xPartition.ulTotalSectors ); - FF_PRINTF( "SecsPerCluster %8lu\n", pxIOManager->xPartition.ulSectorsPerCluster ); - FF_PRINTF( "Size %8lu MB\n", ulTotalSizeMB ); - FF_PRINTF( "FreeSize %8lu MB ( %d perc free )\n", ulFreeSizeMB, iPercentageFree ); + FF_PRINTF( "TotalSectors %8u\n", (unsigned) pxIOManager->xPartition.ulTotalSectors ); + FF_PRINTF( "SecsPerCluster %8u\n", (unsigned) pxIOManager->xPartition.ulSectorsPerCluster ); + FF_PRINTF( "Size %8u MB\n", (unsigned) ulTotalSizeMB ); + FF_PRINTF( "FreeSize %8u MB ( %d perc free )\n", (unsigned) ulFreeSizeMB, iPercentageFree ); } return xReturn; @@ -985,10 +985,10 @@ static BaseType_t prvSDMMCInit( BaseType_t xDriveNumber ) } } #endif /* if ( BUS_4BITS != 0 ) */ - FF_PRINTF( "HAL_SD_Init: %d: %s type: %s Capacity: %lu MB\n", + FF_PRINTF( "HAL_SD_Init: %d: %s type: %s Capacity: %u MB\n", SD_state, prvSDCodePrintable( ( uint32_t ) SD_state ), xSDHandle.CardType == HIGH_CAPACITY_SD_CARD ? "SDHC" : "SD", - xSDCardInfo.CardCapacity / ( 1024 * 1024 ) ); + (unsigned)(xSDCardInfo.CardCapacity / ( 1024 * 1024 ) )); return ( SD_state == SD_OK ) ? pdPASS : pdFAIL; } diff --git a/portable/Zynq.2019.3/ff_sddisk.c b/portable/Zynq.2019.3/ff_sddisk.c index a357a97..bc187e1 100644 --- a/portable/Zynq.2019.3/ff_sddisk.c +++ b/portable/Zynq.2019.3/ff_sddisk.c @@ -256,7 +256,7 @@ static int32_t prvFFRead( uint8_t * pucBuffer, if( pxDisk->xStatus.bIsInitialised != pdFALSE ) { - FF_PRINTF( "prvFFRead: warning: %lu + %lu > %lu\n", ulSectorNumber, ulSectorCount, pxDisk->ulNumberOfSectors ); + FF_PRINTF( "prvFFRead: warning: %u + %u > %u\n", (unsigned)ulSectorNumber, (unsigned)ulSectorCount, (unsigned)pxDisk->ulNumberOfSectors ); } lReturnCode = FF_ERR_IOMAN_OUT_OF_BOUNDS_READ | FF_ERRFLAG; @@ -334,8 +334,8 @@ static int32_t prvFFWrite( uint8_t * pucBuffer, if( pxDisk->xStatus.bIsInitialised ) { - FF_PRINTF( "prvFFWrite::read: warning: %lu + %lu > %lu\n", - ulSectorNumber, ulSectorCount, pxDisk->ulNumberOfSectors ); + FF_PRINTF( "prvFFWrite::read: warning: %u + %u > %u\n", + (unsigned)ulSectorNumber, (unsigned)ulSectorCount, (unsigned)pxDisk->ulNumberOfSectors ); } } diff --git a/portable/Zynq/ff_sddisk.c b/portable/Zynq/ff_sddisk.c index cab4316..152970f 100755 --- a/portable/Zynq/ff_sddisk.c +++ b/portable/Zynq/ff_sddisk.c @@ -222,7 +222,7 @@ static int32_t prvFFRead( uint8_t * pucBuffer, if( pxDisk->xStatus.bIsInitialised != pdFALSE ) { - FF_PRINTF( "prvFFRead: warning: %lu + %lu > %lu\n", ulSectorNumber, ulSectorCount, pxDisk->ulNumberOfSectors ); + FF_PRINTF( "prvFFRead: warning: %u + %u > %u\n", (unsigned)ulSectorNumber, (unsigned)ulSectorCount, (unsigned)pxDisk->ulNumberOfSectors ); } lReturnCode = FF_ERR_IOMAN_OUT_OF_BOUNDS_READ | FF_ERRFLAG; @@ -300,8 +300,8 @@ static int32_t prvFFWrite( uint8_t * pucBuffer, if( pxDisk->xStatus.bIsInitialised ) { - FF_PRINTF( "prvFFWrite::read: warning: %lu + %lu > %lu\n", - ulSectorNumber, ulSectorCount, pxDisk->ulNumberOfSectors ); + FF_PRINTF( "prvFFWrite::read: warning: %u + %u > %u\n", + (unsigned)ulSectorNumber, (unsigned)ulSectorCount, (unsigned)pxDisk->ulNumberOfSectors ); } } @@ -569,7 +569,7 @@ BaseType_t FF_SDDiskMount( FF_Disk_t * pxDisk ) else { pxDisk->xStatus.bIsMounted = pdTRUE; - FF_PRINTF( "****** FreeRTOS+FAT initialized %lu sectors\n", pxDisk->pxIOManager->xPartition.ulTotalSectors ); + FF_PRINTF( "****** FreeRTOS+FAT initialized %u sectors\n", (unsigned) pxDisk->pxIOManager->xPartition.ulTotalSectors ); } return xReturn; @@ -672,13 +672,13 @@ BaseType_t FF_SDDiskShowPartition( FF_Disk_t * pxDisk ) FF_PRINTF( "Partition Nr %8u\n", pxDisk->xStatus.bPartitionNumber ); FF_PRINTF( "Type %8u (%s)\n", pxIOManager->xPartition.ucType, pcTypeName ); FF_PRINTF( "VolLabel '%8s' \n", pxIOManager->xPartition.pcVolumeLabel ); - FF_PRINTF( "TotalSectors %8lu\n", pxIOManager->xPartition.ulTotalSectors ); - FF_PRINTF( "DataSectors %8lu\n", pxIOManager->xPartition.ulDataSectors ); - FF_PRINTF( "SecsPerCluster %8lu\n", pxIOManager->xPartition.ulSectorsPerCluster ); - FF_PRINTF( "Size %8lu MB\n", ulTotalSizeMB ); - FF_PRINTF( "FreeSize %8lu MB ( %d perc free )\n", ulFreeSizeMB, iPercentageFree ); - FF_PRINTF( "BeginLBA %8lu\n", pxIOManager->xPartition.ulBeginLBA ); - FF_PRINTF( "FATBeginLBA %8lu\n", pxIOManager->xPartition.ulFATBeginLBA ); + FF_PRINTF( "TotalSectors %8u\n", (unsigned) pxIOManager->xPartition.ulTotalSectors ); + FF_PRINTF( "DataSectors %8u\n", (unsigned) pxIOManager->xPartition.ulDataSectors ); + FF_PRINTF( "SecsPerCluster %8u\n", (unsigned) pxIOManager->xPartition.ulSectorsPerCluster ); + FF_PRINTF( "Size %8u MB\n", (unsigned) ulTotalSizeMB ); + FF_PRINTF( "FreeSize %8u MB ( %d perc free )\n", (unsigned) ulFreeSizeMB, iPercentageFree ); + FF_PRINTF( "BeginLBA %8u\n", (unsigned) pxIOManager->xPartition.ulBeginLBA ); + FF_PRINTF( "FATBeginLBA %8u\n", (unsigned) pxIOManager->xPartition.ulFATBeginLBA ); } return xReturn; diff --git a/portable/common/ff_ramdisk.c b/portable/common/ff_ramdisk.c index f48da1b..9053251 100644 --- a/portable/common/ff_ramdisk.c +++ b/portable/common/ff_ramdisk.c @@ -419,10 +419,10 @@ BaseType_t FF_RAMDiskShowPartition( FF_Disk_t * pxDisk ) FF_PRINTF( "Partition Nr %8u\n", pxDisk->xStatus.bPartitionNumber ); FF_PRINTF( "Type %8u (%s)\n", pxIOManager->xPartition.ucType, pcTypeName ); FF_PRINTF( "VolLabel '%8s' \n", pxIOManager->xPartition.pcVolumeLabel ); - FF_PRINTF( "TotalSectors %8lu\n", ( unsigned long ) pxIOManager->xPartition.ulTotalSectors ); - FF_PRINTF( "SecsPerCluster %8lu\n", ( unsigned long ) pxIOManager->xPartition.ulSectorsPerCluster ); - FF_PRINTF( "Size %8lu KB\n", ( unsigned long ) ulTotalSizeKB ); - FF_PRINTF( "FreeSize %8lu KB ( %d perc free )\n", ( unsigned long ) ulFreeSizeKB, iPercentageFree ); + FF_PRINTF( "TotalSectors %8u\n", ( unsigned ) pxIOManager->xPartition.ulTotalSectors ); + FF_PRINTF( "SecsPerCluster %8u\n", ( unsigned ) pxIOManager->xPartition.ulSectorsPerCluster ); + FF_PRINTF( "Size %8u KB\n", ( unsigned ) ulTotalSizeKB ); + FF_PRINTF( "FreeSize %8u KB ( %d perc free )\n", ( unsigned ) ulFreeSizeKB, iPercentageFree ); } return xReturn; diff --git a/portable/lpc18xx/ff_sddisk.c b/portable/lpc18xx/ff_sddisk.c index 4acb062..b70bede 100755 --- a/portable/lpc18xx/ff_sddisk.c +++ b/portable/lpc18xx/ff_sddisk.c @@ -126,7 +126,7 @@ static int32_t prvFFRead( uint8_t * pucBuffer, if( pxDisk->xStatus.bIsInitialised != 0 ) { - FF_PRINTF( "prvFFRead: warning: %lu + %lu > %lu\n", ulSectorNumber, ulSectorCount, pxDisk->ulNumberOfSectors ); + FF_PRINTF( "prvFFRead: warning: %u + %u > %u\n", (unsigned)ulSectorNumber, (unsigned)ulSectorCount, (unsigned)pxDisk->ulNumberOfSectors ); } iReturn = ( FF_ERR_IOMAN_OUT_OF_BOUNDS_READ | FF_ERRFLAG ); @@ -167,7 +167,7 @@ static int32_t prvFFWrite( uint8_t * pucBuffer, if( pxDisk->xStatus.bIsInitialised ) { - FF_PRINTF( "prvFFWrite: warning: %lu + %lu > %lu\n", ulSectorNumber, ulSectorCount, pxDisk->ulNumberOfSectors ); + FF_PRINTF( "prvFFWrite: warning: %u + %u > %u\n", (unsigned)ulSectorNumber, (unsigned)ulSectorCount, (unsigned)pxDisk->ulNumberOfSectors ); } iReturn = ( FF_ERR_IOMAN_OUT_OF_BOUNDS_WRITE | FF_ERRFLAG ); @@ -336,7 +336,7 @@ BaseType_t FF_SDDiskMount( FF_Disk_t * pxDisk ) else { pxDisk->xStatus.bIsMounted = pdTRUE; - FF_PRINTF( "****** FreeRTOS+FAT initialized %lu sectors\n", pxDisk->pxIOManager->xPartition.ulTotalSectors ); + FF_PRINTF( "****** FreeRTOS+FAT initialized %u sectors\n", ( unsigned ) pxDisk->pxIOManager->xPartition.ulTotalSectors ); FF_SDDiskShowPartition( pxDisk ); xReturn = pdPASS; } @@ -440,10 +440,10 @@ BaseType_t FF_SDDiskShowPartition( FF_Disk_t * pxDisk ) FF_PRINTF( "Partition Nr %8u\n", pxDisk->xStatus.bPartitionNumber ); FF_PRINTF( "Type %8u (%s)\n", pxIOManager->xPartition.ucType, pcTypeName ); FF_PRINTF( "VolLabel '%8s' \n", pxIOManager->xPartition.pcVolumeLabel ); - FF_PRINTF( "TotalSectors %8lu\n", pxIOManager->xPartition.ulTotalSectors ); - FF_PRINTF( "SecsPerCluster %8lu\n", pxIOManager->xPartition.ulSectorsPerCluster ); - FF_PRINTF( "Size %8lu MB\n", ulTotalSizeMB ); - FF_PRINTF( "FreeSize %8lu MB ( %d perc free )\n", ulFreeSizeMB, iPercentageFree ); + FF_PRINTF( "TotalSectors %8u\n", (unsigned) pxIOManager->xPartition.ulTotalSectors ); + FF_PRINTF( "SecsPerCluster %8u\n", (unsigned) pxIOManager->xPartition.ulSectorsPerCluster ); + FF_PRINTF( "Size %8u MB\n", (unsigned) ulTotalSizeMB ); + FF_PRINTF( "FreeSize %8u MB ( %d perc free )\n", (unsigned) ulFreeSizeMB, iPercentageFree ); } return xReturn; From 15c8f65a6f79ca234918379deb192dfefffff960 Mon Sep 17 00:00:00 2001 From: Paul Helter Date: Mon, 31 Oct 2022 20:10:57 -0700 Subject: [PATCH 04/12] Fixing clang compiler warnings. --- test/build-combination/CMakeLists.txt | 14 ++------------ .../Common/include/FreeRTOSConfig.h | 2 +- test/build-combination/Common/main.c | 7 ++++--- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/test/build-combination/CMakeLists.txt b/test/build-combination/CMakeLists.txt index cbaf7d0..a86754b 100644 --- a/test/build-combination/CMakeLists.txt +++ b/test/build-combination/CMakeLists.txt @@ -26,18 +26,8 @@ target_sources(freertos_plus_fat_build_test target_compile_options(freertos_plus_fat_build_test PRIVATE - # $<$:-Wno-cast-qual> - # $<$:-Wno-format-nonliteral> - # $<$:-Wno-implicit-function-declaration> - # $<$:-Wno-missing-noreturn> - # $<$:-Wno-missing-prototypes> - # $<$:-Wno-missing-variable-declarations> - # $<$:-Wno-reserved-identifier> - # $<$:-Wno-shorten-64-to-32> - # $<$:-Wno-sign-conversion> - # $<$:-Wno-unused-parameter> - # $<$:-Wno-unused-macros> - # $<$:-Wno-unused-variable> + $<$:-Wno-missing-noreturn> + $<$:-Wno-missing-prototypes> ) target_link_libraries(freertos_plus_fat_build_test diff --git a/test/build-combination/Common/include/FreeRTOSConfig.h b/test/build-combination/Common/include/FreeRTOSConfig.h index a54951d..7d7c195 100644 --- a/test/build-combination/Common/include/FreeRTOSConfig.h +++ b/test/build-combination/Common/include/FreeRTOSConfig.h @@ -116,7 +116,7 @@ /* Assert call defined for debug builds. */ void vAssertCalled( const char * pcFile, - unsigned long ulLine ); + unsigned long ulLine ) __attribute__((noreturn)); #define configASSERT( x ) diff --git a/test/build-combination/Common/main.c b/test/build-combination/Common/main.c index 4a550f2..e78a081 100644 --- a/test/build-combination/Common/main.c +++ b/test/build-combination/Common/main.c @@ -35,13 +35,11 @@ #include "task.h" /* System application includes. */ +#include "FreeRTOSConfig.h" #include "ff_headers.h" #include "ff_stdio.h" #include "ff_ramdisk.h" -#define mainHOST_NAME "Build Combination" -#define mainDEVICE_NICK_NAME "Build_Combination" - /* The number and size of sectors that will make up the RAM disk. The RAM disk * is huge to allow some verbose FTP tests used in previous demos. */ #define mainRAM_DISK_SECTOR_SIZE 512UL /* Currently fixed! */ @@ -140,6 +138,9 @@ void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, uint32_t * pulTimerTaskStackSize ) { /* Provide a stub for this function. */ + (void) ppxTimerTaskTCBBuffer; + (void) ppxTimerTaskStackBuffer; + (void) pulTimerTaskStackSize; } void vApplicationMallocFailedHook( void ) From bdc2f5a1949ae0303a9c90fa33b8d37d9a632dee Mon Sep 17 00:00:00 2001 From: Paul Helter Date: Wed, 2 Nov 2022 22:53:02 -0700 Subject: [PATCH 05/12] Fixing build test to work regardless of configuration. --- .../Common/include/FreeRTOSConfig.h | 1 - test/build-combination/Common/main.c | 43 +++++-------------- 2 files changed, 11 insertions(+), 33 deletions(-) diff --git a/test/build-combination/Common/include/FreeRTOSConfig.h b/test/build-combination/Common/include/FreeRTOSConfig.h index 7d7c195..0af8da0 100644 --- a/test/build-combination/Common/include/FreeRTOSConfig.h +++ b/test/build-combination/Common/include/FreeRTOSConfig.h @@ -125,7 +125,6 @@ void vAssertCalled( const char * pcFile, #define configPRINTF( X ) /* Non-format version thread-safe print. */ -extern void vLoggingPrint( const char * pcMessage ); #define configPRINT( X ) /* Non-format version thread-safe print. */ diff --git a/test/build-combination/Common/main.c b/test/build-combination/Common/main.c index e78a081..d89bc36 100644 --- a/test/build-combination/Common/main.c +++ b/test/build-combination/Common/main.c @@ -53,8 +53,6 @@ int main( void ) { /* Initialize the FAT RamDisk */ - /* vLoggingPrint( "FF_RAMDiskInit\n" ); */ - static uint8_t ucRAMDisk[ mainRAM_DISK_SECTORS * mainRAM_DISK_SECTOR_SIZE ]; FF_Disk_t * pxDisk; @@ -67,41 +65,16 @@ int main( void ) return 0; } /*-----------------------------------------------------------*/ +#if ( configUSE_IDLE_HOOK != 0 ) void vApplicationIdleHook( void ) { /* Exit. Just a stub. */ } -/*-----------------------------------------------------------*/ -void vAssertCalled( const char * pcFile, - unsigned long ulLine ) -{ - ( void ) pcFile; - ( void ) ulLine; - - taskDISABLE_INTERRUPTS(); - { - while( 1 ) - { - } - } - taskENABLE_INTERRUPTS(); -} -/*-----------------------------------------------------------*/ - -void vLoggingPrint( const char * pcMessage ) -{ - ( void ) pcMessage; -} +#endif /*-----------------------------------------------------------*/ -void getUserCmd( char * pucUserCmd ) -{ - /* Provide a stub for this function. */ - ( void ) pucUserCmd; -} - -/*-----------------------------------------------------------*/ +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, @@ -112,20 +85,25 @@ void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, ( void ) ppxIdleTaskStackBuffer; ( void ) pulIdleTaskStackSize; } +#endif /*-----------------------------------------------------------*/ - +#if ( configUSE_TICK_HOOK != 0 ) void vApplicationTickHook( void ) { /* Provide a stub for this function. */ } +#endif /*-----------------------------------------------------------*/ - +#if ( configUSE_DAEMON_TASK_STARTUP_HOOK != 0 ) void vApplicationDaemonTaskStartupHook( void ) { /* Provide a stub for this function. */ } +#endif + +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) /* * Callback that provides the inputs necessary to generate a randomized TCP @@ -142,6 +120,7 @@ void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, (void) ppxTimerTaskStackBuffer; (void) pulTimerTaskStackSize; } +#endif void vApplicationMallocFailedHook( void ) { From c095b29a8cda3da643f810e6bcf9a57629029280 Mon Sep 17 00:00:00 2001 From: Paul Helter Date: Thu, 3 Nov 2022 00:38:12 -0700 Subject: [PATCH 06/12] Adding in for Zynq port dependency on uncached_memory target. --- portable/CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/portable/CMakeLists.txt b/portable/CMakeLists.txt index 09837a0..33d8c09 100644 --- a/portable/CMakeLists.txt +++ b/portable/CMakeLists.txt @@ -95,10 +95,18 @@ target_compile_options( freertos_plus_fat_port $<$:-Wno-unused-parameter> ) +if( (FREERTOS_PLUS_FAT_PORT STREQUAL ZYNQ_2019_3) AND NOT TARGET freertos_xil_uncached_memory ) + # Note: the ZYNQ_2019_3 - assumes the use of freertos_xil_uncached_memory.h from F + message(FATAL_ERROR "For FREERTOS_PLUS_FAT_PORT=ZYNQ_2019_3, must have a freertos_xil_uncached_memory target" + "This can be found in FreeRTOS-Plus-TCP NetworkInterface/Zynq/uncached_memory.*") +endif() + target_link_libraries( freertos_plus_fat_port PUBLIC freertos_plus_fat_port_common PRIVATE freertos_plus_fat freertos_kernel + + $<$:freertos_xil_uncached_memory> ) From c6e8021cb08610e2dd538172776758a42b1966b7 Mon Sep 17 00:00:00 2001 From: Paul Helter Date: Thu, 3 Nov 2022 00:38:31 -0700 Subject: [PATCH 07/12] Excluding build_test from all build - must request it explicitly. --- .github/workflows/ci.yml | 2 +- test/build-combination/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 021575f..93df344 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,7 +57,7 @@ jobs: - name: Build checks (Default configuration) run: | cmake -S . -B build/ -DFREERTOS_PLUS_FAT_TEST_CONFIGURATION=DEFAULT_CONF - make -C build/ + cmake --build build --target freertos_plus_tcp_build_test # complexity: # runs-on: ubuntu-latest diff --git a/test/build-combination/CMakeLists.txt b/test/build-combination/CMakeLists.txt index a86754b..0c13e50 100644 --- a/test/build-combination/CMakeLists.txt +++ b/test/build-combination/CMakeLists.txt @@ -17,7 +17,7 @@ else() add_library( freertos_config ALIAS freertos_plus_fat_config_default) endif() -add_executable(freertos_plus_fat_build_test) +add_executable(freertos_plus_fat_build_test EXCLUDE_FROM_ALL) target_sources(freertos_plus_fat_build_test PRIVATE From 51633665a9b054c3379894236eb38c5c06fcc84a Mon Sep 17 00:00:00 2001 From: Paul Helter Date: Thu, 3 Nov 2022 10:27:10 -0700 Subject: [PATCH 08/12] Ensuring XPAR_XSDPS_0_IS_CACHE_COHERENT is 1 for this build since using a modified xsdps driver that requires it. --- portable/Zynq.2019.3/xsdps_g.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/portable/Zynq.2019.3/xsdps_g.c b/portable/Zynq.2019.3/xsdps_g.c index de49e9d..fafd6f5 100644 --- a/portable/Zynq.2019.3/xsdps_g.c +++ b/portable/Zynq.2019.3/xsdps_g.c @@ -59,9 +59,15 @@ #define XPAR_XSDPS_0_BUS_WIDTH 0 /* XSDPS_4_BIT_WIDTH */ #define XPAR_XSDPS_0_MIO_BANK 0 #define XPAR_XSDPS_0_HAS_EMIO 0 -#ifndef XPAR_XSDPS_0_IS_CACHE_COHERENT -#define XPAR_XSDPS_0_IS_CACHE_COHERENT 1 /* 0 Tables are located in uncached memory */ + +/* + * Note: XPAR_XSDPS_0_IS_CACHE_COHERENT is defined in xparameters.h which is an autogenerated file. + * Modifying there won't work since it will get reset on a new build so it is re-set here. + */ +#ifdef XPAR_XSDPS_0_IS_CACHE_COHERENT +#undef XPAR_XSDPS_0_IS_CACHE_COHERENT #endif +#define XPAR_XSDPS_0_IS_CACHE_COHERENT 1 /* 0 Tables are located in uncached memory */ XSdPs_Config XSdPs_ConfigTable[] = { From 105f900852cf608d4dd839f159e4e0d0460f1b30 Mon Sep 17 00:00:00 2001 From: Paul Helter Date: Thu, 3 Nov 2022 11:22:28 -0700 Subject: [PATCH 09/12] Updating compiler warnings. --- CMakeLists.txt | 2 ++ portable/linux/ff_sddisk.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bc017f3..a081ae8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -175,9 +175,11 @@ target_compile_definitions( freertos_plus_fat target_compile_options( freertos_plus_fat PRIVATE + $<$:-Wno-array-bounds> $<$:-Wno-cast-qual> $<$:-Wno-constant-conversion> $<$:-Wno-covered-switch-default> + $<$:-Wno-declaration-after-statement> $<$:-Wno-documentation-unknown-command> $<$:-Wno-documentation> $<$:-Wno-extra-semi-stmt> diff --git a/portable/linux/ff_sddisk.c b/portable/linux/ff_sddisk.c index 467ea6a..80ad938 100644 --- a/portable/linux/ff_sddisk.c +++ b/portable/linux/ff_sddisk.c @@ -76,9 +76,10 @@ void FF_SDDiskFlush( FF_Disk_t * pxDisk ) FF_Disk_t * FF_SDDiskInit( const char * pcName ) { - ( void ) pcName; /* Unused */ FF_Disk_t * pxDisk = NULL; + ( void ) pcName; /* Unused */ + pxDisk = ( FF_Disk_t * ) pvPortMalloc( sizeof( *pxDisk ) ); if( pxDisk == NULL ) From a37b5f00c6a664283d4475ca2c8131162f2ab64b Mon Sep 17 00:00:00 2001 From: Paul Helter Date: Fri, 4 Nov 2022 13:25:15 -0700 Subject: [PATCH 10/12] Fixing documentation, signed/unsigned conversion. Bugfix for time based code for removing failure in 2032 due to uint32_t used for time. --- CMakeLists.txt | 56 ++++++++-- ff_dir.c | 147 ++++++++++++------------- ff_fat.c | 63 +++++------ ff_file.c | 259 ++++++++++++++++++++------------------------ ff_format.c | 50 ++++----- ff_ioman.c | 156 ++++++++++++-------------- ff_stdio.c | 41 ++++--- ff_string.c | 2 +- ff_sys.c | 2 +- ff_time.c | 57 +++++----- include/ff_error.h | 1 + include/ff_stdio.h | 7 +- include/ff_string.h | 2 +- 13 files changed, 413 insertions(+), 430 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a081ae8..da5a782 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -122,6 +122,54 @@ FetchContent_Declare( freertos_kernel GIT_TAG feature/fixing-clang-gnu-compiler-warnings #master ) + +######################################################################## +# Requirements +set(CMAKE_C_STANDARD 99) +set(CMAKE_C_STANDARD_REQUIRED ON) + +######################################################################## +# Overall Compile Options +# Note the compile option strategy is to error on everything and then +# Per library opt-out of things that are warnings/errors. +# This ensures that no matter what strategy for compilation you take, the +# builds will still occur. +# +# Only tested with GNU and Clang. +# Other options are https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html#variable:CMAKE_%3CLANG%3E_COMPILER_ID +# Naming of compilers translation map: +# +# FreeRTOS | CMake +# ------------------- +# CCS | ?TBD? +# GCC | GNU, Clang, *Clang Others? +# IAR | IAR +# Keil | ARMCC +# MSVC | MSVC # Note only for MinGW? +# Renesas | ?TBD? + +add_compile_options( + ### Gnu/Clang C Options + $<$:-fdiagnostics-color=always> + $<$:-fcolor-diagnostics> + + $<$:-Wall> + $<$:-Wextra> + $<$:-Wpedantic> + $<$:-Werror> + $<$:-Weverything> + + $<$:-Weverything> + + # Enablement of supported but not widely used doxygen special commands + # https://doxygen.nl/manual/commands.html + $<$:-fcomment-block-commands=retval> + + # TODO: Add in other Compilers here. + +) + + ######################################################################## add_library( freertos_plus_fat STATIC ) @@ -180,19 +228,11 @@ target_compile_options( freertos_plus_fat $<$:-Wno-constant-conversion> $<$:-Wno-covered-switch-default> $<$:-Wno-declaration-after-statement> - $<$:-Wno-documentation-unknown-command> - $<$:-Wno-documentation> - $<$:-Wno-extra-semi-stmt> $<$:-Wno-format> - $<$:-Wno-implicit-int-conversion> - $<$:-Wno-missing-variable-declarations> $<$:-Wno-overflow> $<$:-Wno-padded> $<$:-Wno-pedantic> - $<$:-Wno-reserved-macro-identifier> - $<$:-Wno-shorten-64-to-32> - $<$:-Wno-sign-conversion> $<$:-Wno-tautological-constant-out-of-range-compare> $<$:-Wno-type-limits> $<$:-Wno-undef> diff --git a/ff_dir.c b/ff_dir.c index dcb712d..ede5ced 100644 --- a/ff_dir.c +++ b/ff_dir.c @@ -164,10 +164,10 @@ static BaseType_t FF_ValidShortChar( char cChar ); do { - c1 = *pcString1++; - c2 = *pcString2++; - c1 = ( unsigned char ) prvToLower( ( unsigned char ) c1 ); - c2 = ( unsigned char ) prvToLower( ( unsigned char ) c2 ); + c1 = ( unsigned char ) *pcString1++; + c2 = ( unsigned char ) *pcString2++; + c1 = prvToLower( c1 ); + c2 = prvToLower( c2 ); } while( ( c1 == c2 ) && ( c1 != '\0' ) ); @@ -220,11 +220,11 @@ static BaseType_t FF_ShortNameExists( FF_IOManager_t * pxIOManager, #if ffconfigHASH_FUNCTION == CRC16 { - ulHash = ( uint32_t ) FF_GetCRC16( ( uint8_t * ) pcShortName, strlen( pcShortName ) ); + ulHash = ( uint32_t ) FF_GetCRC16( ( uint8_t * ) pcShortName, ( uint32_t ) strlen( pcShortName ) ); } #else /* ffconfigHASH_FUNCTION == CRC8 */ { - ulHash = ( uint32_t ) FF_GetCRC8( ( uint8_t * ) pcShortName, strlen( pcShortName ) ); + ulHash = ( uint32_t ) FF_GetCRC8( ( uint8_t * ) pcShortName, ( uint32_t ) strlen( pcShortName ) ); } #endif { @@ -427,7 +427,7 @@ static BaseType_t FF_ShortNameExists( FF_IOManager_t * pxIOManager, if( ( pxFindParams->lFreeEntry < 0 ) && ( ++freeCount == entriesNeeded ) ) { /* Remember the beginning entry in the sequential sequence. */ - pxFindParams->lFreeEntry = ( pxDirEntry->usCurrentItem - ( entriesNeeded - 1 ) ); + pxFindParams->lFreeEntry = ( pxDirEntry->usCurrentItem - ( int32_t )( entriesNeeded - 1 ) ); } continue; @@ -542,17 +542,17 @@ static BaseType_t FF_ShortNameExists( FF_IOManager_t * pxIOManager, { /* use ASCII notation. */ for( xIndex = 0; ( xIndex < 10 ) && ( pcCurPtr < pcLastPtr ); xIndex += 2 ) { - *( pcCurPtr++ ) = src[ FF_FAT_LFN_NAME_1 + xIndex ]; + *( pcCurPtr++ ) = ( char ) src[ FF_FAT_LFN_NAME_1 + xIndex ]; } for( xIndex = 0; ( xIndex < 12 ) && ( pcCurPtr < pcLastPtr ); xIndex += 2 ) { - *( pcCurPtr++ ) = src[ FF_FAT_LFN_NAME_2 + xIndex ]; + *( pcCurPtr++ ) = ( char ) src[ FF_FAT_LFN_NAME_2 + xIndex ]; } for( xIndex = 0; ( xIndex < 4 ) && ( pcCurPtr < pcLastPtr ); xIndex += 2 ) { - *( pcCurPtr++ ) = src[ FF_FAT_LFN_NAME_3 + xIndex ]; + *( pcCurPtr++ ) = ( char ) src[ FF_FAT_LFN_NAME_3 + xIndex ]; } } #endif /* ( ffconfigUNICODE_UTF16_SUPPORT == 0 ) && !( ffconfigUNICODE_UTF8_SUPPORT == 0 ) */ @@ -690,8 +690,7 @@ static BaseType_t FF_ShortNameExists( FF_IOManager_t * pxIOManager, /** - * @private - **/ + * **/ #if ( ffconfigUNICODE_UTF16_SUPPORT != 0 ) uint32_t FF_FindDir( FF_IOManager_t * pxIOManager, const FF_T_WCHAR * pcPath, @@ -842,8 +841,7 @@ static BaseType_t FF_ShortNameExists( FF_IOManager_t * pxIOManager, #if ( ffconfigSHORTNAME_CASE != 0 ) /** - * @private - * For short-name entries, NT/XP etc store case information in byte 0x0c + * * For short-name entries, NT/XP etc store case information in byte 0x0c * Use this to show proper case of "README.txt" or "source.H" **/ #if ( ffconfigUNICODE_UTF16_SUPPORT != 0 ) @@ -881,9 +879,7 @@ static BaseType_t FF_ShortNameExists( FF_IOManager_t * pxIOManager, #if ( ffconfigUNICODE_UTF16_SUPPORT != 0 ) /** - * @private - * Expand a short-name, adding a zero after each character - **/ + * **/ static void FF_ShortNameExpand( FF_T_WCHAR * pFileName ) { @@ -902,10 +898,6 @@ static BaseType_t FF_ShortNameExists( FF_IOManager_t * pxIOManager, #endif /* ffconfigUNICODE_UTF16_SUPPORT */ /*-----------------------------------------------------------*/ -/** - * @private - **/ - static void FF_ProcessShortName( char * pcName ) { char pcShortName[ 13 ]; @@ -1120,17 +1112,16 @@ FF_Error_t FF_CleanupEntryFetch( FF_IOManager_t * pxIOManager, /*-----------------------------------------------------------*/ /** - * @private * @brief Find the cluster for a given Entry within a directory - * @brief Make an exception for the root directory ( non FAT32 only ): - * @brief Just calculate the cluster ( don't consult the actual FAT ) + * Make an exception for the root directory ( non FAT32 only ): + * Just calculate the cluster ( don't consult the actual FAT ) * * @param pxIOManager FF_IOManager_t object that was created by FF_CreateIOManger( ). * @param ulEntry The sequence number of the entry of interest * @param pxContext Context of current search * - * @Return FF_ERR_NONE on success - * @Return Possible error returned by FF_TraverseFAT( ) or END_OF_DIR + * @retval FF_ERR_NONE on success + * @retval Possible error returned by FF_TraverseFAT( ) or END_OF_DIR * * Side effects: * - pxContext->ulCurrentClusterNum : relative cluster number ( 0 <= Num < ulChainLength ) @@ -1147,7 +1138,7 @@ static FF_Error_t FF_Traverse( FF_IOManager_t * pxIOManager, /* Check if we're past the last cluster ( ulChainLength is also valid for root sectors ). */ if( ( ulClusterNum + 1 ) > pxContext->ulChainLength ) { - xError = FF_ERR_DIR_END_OF_DIR | FF_TRAVERSE; /* End of Dir was reached! */ + xError = FF_createERR( FF_ERR_DIR_END_OF_DIR, FF_TRAVERSE ); /* End of Dir was reached! */ } else if( ( pxIOManager->xPartition.ucType != FF_T_FAT32 ) && ( pxContext->ulDirCluster == pxIOManager->xPartition.ulRootDirCluster ) ) @@ -1155,7 +1146,7 @@ static FF_Error_t FF_Traverse( FF_IOManager_t * pxIOManager, /* Double-check if the entry number isn't too high. */ if( ulEntry > ( ( pxIOManager->xPartition.ulRootDirSectors * pxIOManager->xPartition.usBlkSize ) / FF_SIZEOF_DIRECTORY_ENTRY ) ) { - xError = ( FF_Error_t ) ( FF_ERR_DIR_END_OF_DIR | FF_FETCHENTRYWITHCONTEXT ); + xError = FF_createERR( FF_ERR_DIR_END_OF_DIR, FF_FETCHENTRYWITHCONTEXT ); } else { @@ -1229,7 +1220,7 @@ FF_Error_t FF_FetchEntryWithContext( FF_IOManager_t * pxIOManager, if( pxContext->pxBuffer == NULL ) { - xError = ( FF_Error_t ) ( FF_ERR_DEVICE_DRIVER_FAILED | FF_FETCHENTRYWITHCONTEXT ); + xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_FETCHENTRYWITHCONTEXT ); } } } @@ -1287,7 +1278,7 @@ FF_Error_t FF_PushEntryWithContext( FF_IOManager_t * pxIOManager, if( pxContext->pxBuffer == NULL ) { - xError = ( FF_Error_t ) ( FF_ERR_DEVICE_DRIVER_FAILED | FF_FETCHENTRYWITHCONTEXT ); + xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_FETCHENTRYWITHCONTEXT ); } } } @@ -1305,8 +1296,7 @@ FF_Error_t FF_PushEntryWithContext( FF_IOManager_t * pxIOManager, /** - * @private - **/ + * **/ FF_Error_t FF_GetEntry( FF_IOManager_t * pxIOManager, uint16_t usEntry, uint32_t ulDirCluster, @@ -1331,7 +1321,7 @@ FF_Error_t FF_GetEntry( FF_IOManager_t * pxIOManager, { if( FF_isEndOfDir( ucEntryBuffer ) != pdFALSE ) { - xError = ( FF_Error_t ) ( FF_ERR_DIR_END_OF_DIR | FF_GETENTRY ); + xError = FF_createERR( FF_ERR_DIR_END_OF_DIR, FF_GETENTRY ); } else { @@ -1528,17 +1518,17 @@ FF_Error_t FF_PopulateLongDirent( FF_IOManager_t * pxIOManager, for( xIndex = 0; ( xIndex < 10 ) && ( pcCurPtr < pcLastPtr ); xIndex += 2 ) { - *( pcCurPtr++ ) = pucEntryBuffer[ FF_FAT_LFN_NAME_1 + xIndex ]; + *( pcCurPtr++ ) = ( char ) pucEntryBuffer[ FF_FAT_LFN_NAME_1 + xIndex ]; } for( xIndex = 0; ( xIndex < 12 ) && ( pcCurPtr < pcLastPtr ); xIndex += 2 ) { - *( pcCurPtr++ ) = pucEntryBuffer[ FF_FAT_LFN_NAME_2 + xIndex ]; + *( pcCurPtr++ ) = ( char ) pucEntryBuffer[ FF_FAT_LFN_NAME_2 + xIndex ]; } for( xIndex = 0; ( xIndex < 4 ) && ( pcCurPtr < pcLastPtr ); xIndex += 2 ) { - *( pcCurPtr++ ) = pucEntryBuffer[ FF_FAT_LFN_NAME_3 + xIndex ]; + *( pcCurPtr++ ) = ( char ) pucEntryBuffer[ FF_FAT_LFN_NAME_3 + xIndex ]; } if( ( xNumLFNs == ( y - 1 ) ) && ( pcCurPtr < pcLastPtr ) ) @@ -1623,7 +1613,6 @@ FF_Error_t FF_PopulateLongDirent( FF_IOManager_t * pxIOManager, /*-----------------------------------------------------------*/ /** - * @public * @brief Find's the first directory entry for the provided path. * * All values recorded in pxDirEntry must be preserved to and between calls to @@ -1647,9 +1636,9 @@ FF_Error_t FF_PopulateLongDirent( FF_IOManager_t * pxIOManager, * @param pxDirEntry FF_DirEnt_t object to store the entry information. * @param path String to of the path to the Dir being listed. * - * @Return 0 on success - * @Return FF_ERR_DEVICE_DRIVER_FAILED if device access failed. - * @Return -2 if Dir was not found. + * @retval 0 on success + * @retval FF_ERR_DEVICE_DRIVER_FAILED if device access failed. + * @retval -2 if Dir was not found. * **/ #if ( ffconfigUNICODE_UTF16_SUPPORT != 0 ) @@ -1683,13 +1672,13 @@ FF_Error_t FF_PopulateLongDirent( FF_IOManager_t * pxIOManager, if( pxIOManager == NULL ) { - xError = ( FF_Error_t ) ( FF_ERR_NULL_POINTER | FF_FINDFIRST ); + xError = FF_createERR( FF_ERR_NULL_POINTER, FF_FINDFIRST ); } #if ( ffconfigREMOVABLE_MEDIA != 0 ) else if( ( pxIOManager->ucFlags & FF_IOMAN_DEVICE_IS_EXTRACTED ) != 0 ) { - xError = ( FF_Error_t ) ( FF_ERR_IOMAN_DRIVER_NOMEDIUM | FF_FINDFIRST ); + xError = FF_createERR( FF_ERR_IOMAN_DRIVER_NOMEDIUM, FF_FINDFIRST ); } #endif /* ffconfigREMOVABLE_MEDIA */ else @@ -1744,7 +1733,7 @@ FF_Error_t FF_PopulateLongDirent( FF_IOManager_t * pxIOManager, { if( pxDirEntry->ulDirCluster == 0 ) { - xError = ( FF_Error_t ) ( FF_ERR_DIR_INVALID_PATH | FF_FINDFIRST ); + xError = FF_createERR( FF_ERR_DIR_INVALID_PATH, FF_FINDFIRST ); } else { @@ -1765,7 +1754,6 @@ FF_Error_t FF_PopulateLongDirent( FF_IOManager_t * pxIOManager, /*-----------------------------------------------------------*/ /** - * @public * @brief Get's the next Entry based on the data recorded in the FF_DirEnt_t object. * * All values recorded in pxDirEntry must be preserved to and between calls to @@ -1774,7 +1762,7 @@ FF_Error_t FF_PopulateLongDirent( FF_IOManager_t * pxIOManager, * @param pxIOManager FF_IOManager_t object that was created by FF_CreateIOManger( ). * @param pxDirEntry FF_DirEnt_t object to store the entry information. ( As initialised by FF_FindFirst( )). * - * @Return FF_ERR_DEVICE_DRIVER_FAILED is device access failed. + * @retval FF_ERR_DEVICE_DRIVER_FAILED is device access failed. * **/ FF_Error_t FF_FindNext( FF_IOManager_t * pxIOManager, @@ -1790,13 +1778,13 @@ FF_Error_t FF_FindNext( FF_IOManager_t * pxIOManager, if( pxIOManager == NULL ) { - xError = ( FF_Error_t ) ( FF_ERR_NULL_POINTER | FF_FINDNEXT ); + xError = FF_createERR( FF_ERR_NULL_POINTER, FF_FINDNEXT ); } #if ( ffconfigREMOVABLE_MEDIA != 0 ) else if( ( pxIOManager->ucFlags & FF_IOMAN_DEVICE_IS_EXTRACTED ) != 0 ) { - xError = ( FF_Error_t ) ( FF_ERR_IOMAN_DRIVER_NOMEDIUM | FF_FINDNEXT ); + xError = FF_createERR( FF_ERR_IOMAN_DRIVER_NOMEDIUM, FF_FINDNEXT ); } #endif /* ffconfigREMOVABLE_MEDIA */ else @@ -1839,7 +1827,7 @@ FF_Error_t FF_FindNext( FF_IOManager_t * pxIOManager, if( FF_isEndOfDir( pucEntryBuffer ) ) { /* End of directory, generate a pseudo error 'DIR_END_OF_DIR'. */ - xError = ( FF_Error_t ) ( FF_ERR_DIR_END_OF_DIR | FF_FINDNEXT ); + xError = FF_createERR( FF_ERR_DIR_END_OF_DIR, FF_FINDNEXT ); break; } @@ -1975,7 +1963,7 @@ FF_Error_t FF_FindNext( FF_IOManager_t * pxIOManager, if( pxDirEntry->usCurrentItem == FF_MAX_ENTRIES_PER_DIRECTORY ) { - xError = ( FF_Error_t ) ( FF_ERR_DIR_END_OF_DIR | FF_FINDNEXT ); + xError = FF_createERR( FF_ERR_DIR_END_OF_DIR, FF_FINDNEXT ); } { @@ -2015,14 +2003,14 @@ static int32_t FF_FindFreeDirent( FF_IOManager_t * pxIOManager, if( FF_isERR( xError ) == pdFALSE ) { - uxEntry = pxFindParams->lFreeEntry >= 0 ? pxFindParams->lFreeEntry : 0; + uxEntry = pxFindParams->lFreeEntry >= 0 ? ( UBaseType_t ) pxFindParams->lFreeEntry : 0U; for( ; uxEntry < FF_MAX_ENTRIES_PER_DIRECTORY; uxEntry++ ) { if( ( pucEntryBuffer == NULL ) || ( pucEntryBuffer >= xFetchContext.pxBuffer->pucBuffer + ( pxIOManager->usSectorSize - FF_SIZEOF_DIRECTORY_ENTRY ) ) ) { - xError = FF_FetchEntryWithContext( pxIOManager, uxEntry, &xFetchContext, NULL ); + xError = FF_FetchEntryWithContext( pxIOManager, ( uint32_t ) uxEntry, &xFetchContext, NULL ); if( FF_GETERROR( xError ) == FF_ERR_DIR_END_OF_DIR ) { @@ -2100,11 +2088,11 @@ static int32_t FF_FindFreeDirent( FF_IOManager_t * pxIOManager, if( xEntryFound != pdFALSE ) { /* No error has occurred and a free directory entry has been found. */ - xError = uxEntry; + xError = ( FF_Error_t ) uxEntry; } else { - xError = ( FF_Error_t ) ( FF_ERR_DIR_DIRECTORY_FULL | FF_FINDFREEDIRENT ); + xError = FF_createERR( FF_ERR_DIR_DIRECTORY_FULL, FF_FINDFREEDIRENT ); } } @@ -2261,7 +2249,7 @@ static BaseType_t FF_ValidShortChar( char cChar ) /* Remember where we put the first space. */ if( pxFindParams->ucFirstTilde > xIndex ) { - pxFindParams->ucFirstTilde = xIndex; + pxFindParams->ucFirstTilde = ( uint8_t ) xIndex; } while( xIndex < 8 ) @@ -2344,7 +2332,7 @@ static BaseType_t FF_ValidShortChar( char cChar ) if( ( xLastDot == 0 ) && ( xIndex < 6 ) ) { /* This is a file name like ".info" or ".root" */ - pxFindParams->ucFirstTilde = xIndex; + pxFindParams->ucFirstTilde = ( uint8_t ) xIndex; } while( xIndex < 11 ) @@ -2354,7 +2342,7 @@ static BaseType_t FF_ValidShortChar( char cChar ) if( ( xLastDot < pxFindParams->ucFirstTilde ) && ( xLastDot > 0 ) ) { - pxFindParams->ucFirstTilde = xLastDot; + pxFindParams->ucFirstTilde = ( uint8_t ) xLastDot; } if( NameLen < pxFindParams->ucFirstTilde ) /* Names like "Abc" will become "~Abc". */ @@ -2397,7 +2385,7 @@ int32_t FF_FindShortName( FF_IOManager_t * pxIOManager, { if( ( pxFindParams->ulFlags & FIND_FLAG_SHORTNAME_FOUND ) != 0 ) { - xResult = ( FF_Error_t ) ( FF_ERR_DIR_OBJECT_EXISTS | FF_CREATESHORTNAME ); + xResult = FF_createERR( FF_ERR_DIR_OBJECT_EXISTS, FF_CREATESHORTNAME ); } else { @@ -2423,7 +2411,7 @@ int32_t FF_FindShortName( FF_IOManager_t * pxIOManager, } else { - xResult = ( FF_Error_t ) ( FF_ERR_DIR_OBJECT_EXISTS | FF_CREATESHORTNAME ); + xResult = FF_createERR( FF_ERR_DIR_OBJECT_EXISTS, FF_CREATESHORTNAME ); } } else @@ -2505,7 +2493,7 @@ int32_t FF_FindShortName( FF_IOManager_t * pxIOManager, if( xIndex >= FF_MAX_ENTRIES_PER_DIRECTORY ) { - xResult = ( FF_Error_t ) ( FF_ERR_DIR_DIRECTORY_FULL | FF_CREATESHORTNAME ); + xResult = FF_createERR( FF_ERR_DIR_DIRECTORY_FULL, FF_CREATESHORTNAME ); break; } } @@ -2538,7 +2526,7 @@ int32_t FF_FindShortName( FF_IOManager_t * pxIOManager, memset( pucEntryBuffer, 0, FF_SIZEOF_DIRECTORY_ENTRY ); - FF_putChar( pucEntryBuffer, FF_FAT_LFN_ORD, ( uint8_t ) ( ( uxLFN & ~0x40 ) ) ); + FF_putChar( pucEntryBuffer, FF_FAT_LFN_ORD, ( uint8_t ) ( ( uxLFN & ~0x40U ) ) ); FF_putChar( pucEntryBuffer, FF_FAT_DIRENT_ATTRIB, ( uint8_t ) FF_FAT_ATTR_LFN ); FF_putChar( pucEntryBuffer, FF_FAT_LFN_CHECKSUM, ( uint8_t ) ucCheckSum ); @@ -2624,7 +2612,8 @@ int32_t FF_FindShortName( FF_IOManager_t * pxIOManager, FF_Error_t xError = FF_ERR_NONE; BaseType_t xNumLFNs; BaseType_t xEndPos; - BaseType_t xIndex, y; + BaseType_t xIndex; + UBaseType_t y; FF_FetchContext_t xFetchContext; uint8_t pucEntryBuffer[ FF_SIZEOF_DIRECTORY_ENTRY ]; @@ -2651,7 +2640,7 @@ int32_t FF_FindShortName( FF_IOManager_t * pxIOManager, if( y > ffconfigMAX_FILENAME ) { - xError = ( FF_Error_t ) ( FF_ERR_DIR_NAME_TOO_LONG | FF_CREATELFNS ); + xError = FF_createERR( FF_ERR_DIR_NAME_TOO_LONG, FF_CREATELFNS ); } else { @@ -2672,7 +2661,7 @@ int32_t FF_FindShortName( FF_IOManager_t * pxIOManager, if( y > ffconfigMAX_FILENAME ) { - xError = ( FF_Error_t ) ( FF_ERR_DIR_NAME_TOO_LONG | FF_CREATELFNS ); + xError = FF_createERR( FF_ERR_DIR_NAME_TOO_LONG, FF_CREATELFNS ); break; } } @@ -2705,7 +2694,7 @@ int32_t FF_FindShortName( FF_IOManager_t * pxIOManager, if( y > ffconfigMAX_FILENAME ) { - xError = ( FF_Error_t ) ( FF_ERR_DIR_NAME_TOO_LONG | FF_CREATELFNS ); + xError = FF_createERR( FF_ERR_DIR_NAME_TOO_LONG, FF_CREATELFNS ); break; } } @@ -2717,7 +2706,7 @@ int32_t FF_FindShortName( FF_IOManager_t * pxIOManager, if( y > ffconfigMAX_FILENAME ) { - xError = ( FF_Error_t ) ( FF_ERR_DIR_NAME_TOO_LONG | FF_CREATELFNS ); + xError = FF_createERR( FF_ERR_DIR_NAME_TOO_LONG, FF_CREATELFNS ); } } #endif /* if ( ffconfigUNICODE_UTF8_SUPPORT != 0 ) */ @@ -2810,7 +2799,7 @@ FF_Error_t FF_ExtendDirectory( FF_IOManager_t * pxIOManager, ( pxIOManager->xPartition.ucType != FF_T_FAT32 ) ) { /* root directories on FAT12 and FAT16 can not be extended. */ - xError = ( FF_Error_t ) ( FF_ERR_DIR_CANT_EXTEND_ROOT_DIR | FF_EXTENDDIRECTORY ); + xError = FF_createERR( FF_ERR_DIR_CANT_EXTEND_ROOT_DIR, FF_EXTENDDIRECTORY ); } else if( pxIOManager->xPartition.ulFreeClusterCount == 0UL ) { @@ -2822,7 +2811,7 @@ FF_Error_t FF_ExtendDirectory( FF_IOManager_t * pxIOManager, { if( pxIOManager->xPartition.ulFreeClusterCount == 0UL ) { - xError = ( FF_Error_t ) ( FF_ERR_FAT_NO_FREE_CLUSTERS | FF_EXTENDDIRECTORY ); + xError = FF_createERR( FF_ERR_FAT_NO_FREE_CLUSTERS, FF_EXTENDDIRECTORY ); } else { @@ -3075,7 +3064,7 @@ FF_Error_t FF_CreateDirent( FF_IOManager_t * pxIOManager, FF_ProcessShortName( pcShortName ); /* Format the shortname to 8.3. */ #if ( ffconfigHASH_FUNCTION == CRC16 ) { - FF_AddDirentHash( pxIOManager, ulDirCluster, ( uint32_t ) FF_GetCRC16( ( uint8_t * ) pcShortName, strlen( pcShortName ) ) ); + FF_AddDirentHash( pxIOManager, ulDirCluster, ( uint32_t ) FF_GetCRC16( ( uint8_t * ) pcShortName, ( uint32_t ) strlen( pcShortName ) ) ); } #elif ( ffconfigHASH_FUNCTION == CRC8 ) { @@ -3184,10 +3173,10 @@ FF_Error_t FF_CreateDirent( FF_IOManager_t * pxIOManager, * @param pxIOManager Pointer to the FF_IOManager_t object. * @param pcPath Path of the directory to create. * - * @Return FF_ERR_NULL_POINTER if pxIOManager was NULL. - * @Return FF_ERR_DIR_OBJECT_EXISTS if the object specified by path already exists. - * @Return FF_ERR_DIR_INVALID_PATH - * @Return FF_ERR_NONE on success. + * @retval FF_ERR_NULL_POINTER if pxIOManager was NULL. + * @retval FF_ERR_DIR_OBJECT_EXISTS if the object specified by path already exists. + * @retval FF_ERR_DIR_INVALID_PATH + * @retval FF_ERR_NONE on success. **/ #if ( ffconfigUNICODE_UTF16_SUPPORT != 0 ) FF_Error_t FF_MkDir( FF_IOManager_t * pxIOManager, @@ -3220,14 +3209,14 @@ FF_Error_t FF_CreateDirent( FF_IOManager_t * pxIOManager, { if( pxIOManager == NULL ) { - xError = ( FF_Error_t ) ( FF_ERR_NULL_POINTER | FF_MKDIR ); + xError = FF_createERR( FF_ERR_NULL_POINTER, FF_MKDIR ); break; } #if ( ffconfigREMOVABLE_MEDIA != 0 ) if( ( pxIOManager->ucFlags & FF_IOMAN_DEVICE_IS_EXTRACTED ) != 0 ) { - xError = ( FF_Error_t ) ( FF_ERR_IOMAN_DRIVER_NOMEDIUM | FF_MKDIR ); + xError = FF_createERR( FF_ERR_IOMAN_DRIVER_NOMEDIUM, FF_MKDIR ); break; } #endif /* ffconfigREMOVABLE_MEDIA */ @@ -3262,7 +3251,7 @@ FF_Error_t FF_CreateDirent( FF_IOManager_t * pxIOManager, if( pcDirName[ 0 ] == '\0' ) { - xError = ( FF_ERR_DIR_OBJECT_EXISTS | FF_MKDIR ); + xError = FF_createERR( FF_ERR_DIR_OBJECT_EXISTS, FF_MKDIR ); break; } @@ -3275,7 +3264,7 @@ FF_Error_t FF_CreateDirent( FF_IOManager_t * pxIOManager, if( xFindParams.ulDirCluster == 0UL ) { - xError = ( FF_Error_t ) ( FF_ERR_DIR_INVALID_PATH | FF_MKDIR ); + xError = FF_createERR( FF_ERR_DIR_INVALID_PATH, FF_MKDIR ); break; } @@ -3288,7 +3277,7 @@ FF_Error_t FF_CreateDirent( FF_IOManager_t * pxIOManager, { if( FF_isERR( xError ) == pdFALSE ) { - xError = ( FF_Error_t ) ( FF_ERR_DIR_OBJECT_EXISTS | FF_MKDIR ); + xError = FF_createERR( FF_ERR_DIR_OBJECT_EXISTS, FF_MKDIR ); } break; @@ -3322,7 +3311,7 @@ FF_Error_t FF_CreateDirent( FF_IOManager_t * pxIOManager, if( xMyDirectory.ulObjectCluster == 0UL ) { /* Couldn't allocate any space for the dir! */ - xError = ( FF_Error_t ) ( FF_ERR_DIR_EXTEND_FAILED | FF_MKDIR ); + xError = FF_createERR( FF_ERR_DIR_EXTEND_FAILED, FF_MKDIR ); break; } @@ -3521,7 +3510,7 @@ FF_Error_t FF_RmLFNs( FF_IOManager_t * pxIOManager, /* Generate the Hash. */ #if ( ffconfigHASH_FUNCTION == CRC16 ) { - ulHash = FF_GetCRC16( ( uint8_t * ) pcMyShortName, strlen( pcMyShortName ) ); + ulHash = FF_GetCRC16( ( uint8_t * ) pcMyShortName, ( uint32_t ) strlen( pcMyShortName ) ); } #else /* ffconfigHASH_FUNCTION == CRC8 */ { diff --git a/ff_fat.c b/ff_fat.c index b849689..c6ad160 100755 --- a/ff_fat.c +++ b/ff_fat.c @@ -339,7 +339,7 @@ FF_Buffer_t * prvGetFromFATBuffers( FF_IOManager_t * pxIOManager, { /* Setting an error code without the Module/Function, * will be filled-in by the caller. */ - xError = ( FF_Error_t ) ( FF_ERR_DEVICE_DRIVER_FAILED | FF_ERRFLAG ); + xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_ERRFLAG ); } } @@ -394,7 +394,7 @@ FF_Buffer_t * prvGetFromFATBuffers( FF_IOManager_t * pxIOManager, if( pxBuffer == NULL ) { - xError = ( FF_Error_t ) ( FF_ERR_DEVICE_DRIVER_FAILED | FF_GETFATENTRY ); + xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_GETFATENTRY ); } else { @@ -444,7 +444,7 @@ uint32_t FF_getFATEntry( FF_IOManager_t * pxIOManager, { /* _HT_ find a more specific error code. * Probably not really important as this is a function internal to the library. */ - xError = ( FF_Error_t ) ( FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE | FF_GETFATENTRY ); + xError = FF_createERR( FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE, FF_GETFATENTRY ); } else { @@ -505,7 +505,7 @@ uint32_t FF_getFATEntry( FF_IOManager_t * pxIOManager, if( FF_isERR( xError ) ) { - xError = FF_GETERROR( xError ) | FF_GETFATENTRY; + xError = ( FF_Error_t ) ( FF_GETERROR( xError ) | FF_GETFATENTRY ); } else { @@ -568,7 +568,7 @@ uint32_t FF_getFATEntry( FF_IOManager_t * pxIOManager, *pxError = xError; } - return ( int32_t ) ulFATEntry; + return ulFATEntry; } /* FF_getFATEntry() */ /*-----------------------------------------------------------*/ @@ -595,14 +595,14 @@ FF_Error_t FF_ClearCluster( FF_IOManager_t * pxIOManager, if( pxBuffer == NULL ) { - xError = ( FF_Error_t ) ( FF_ERR_DEVICE_DRIVER_FAILED | FF_CLEARCLUSTER ); + xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_CLEARCLUSTER ); break; } memset( pxBuffer->pucBuffer, 0x00, pxIOManager->usSectorSize ); } - xError = FF_BlockWrite( pxIOManager, ulBaseLBA + xIndex, 1, pxBuffer->pucBuffer, pdFALSE ); + xError = FF_BlockWrite( pxIOManager, ( uint32_t ) ( ulBaseLBA + xIndex ), 1U, pxBuffer->pucBuffer, pdFALSE ); if( FF_isERR( xError ) ) { @@ -631,7 +631,6 @@ FF_Error_t FF_ClearCluster( FF_IOManager_t * pxIOManager, /*-----------------------------------------------------------*/ /** - * @private * @brief Returns the Cluster address of the Cluster number from the beginning of a chain. * * @param pxIOManager FF_IOManager_t Object @@ -639,7 +638,6 @@ FF_Error_t FF_ClearCluster( FF_IOManager_t * pxIOManager, * @param ulCount Number of Cluster in the chain, * * - * **/ uint32_t FF_TraverseFAT( FF_IOManager_t * pxIOManager, uint32_t ulStart, @@ -728,7 +726,6 @@ uint32_t FF_FindEndOfChain( FF_IOManager_t * pxIOManager, /*-----------------------------------------------------------*/ /** - * @private * @brief Tests if the ulFATEntry is an End of Chain Marker. * * @param pxIOManager FF_IOManager_t Object @@ -826,7 +823,7 @@ BaseType_t FF_isEndOfChain( FF_IOManager_t * pxIOManager, { if( pxBuffer == NULL ) { - xError = ( FF_Error_t ) ( FF_ERR_DEVICE_DRIVER_FAILED | FF_PUTFATENTRY ); + xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_PUTFATENTRY ); break; } @@ -844,7 +841,7 @@ BaseType_t FF_isEndOfChain( FF_IOManager_t * pxIOManager, { if( pxBuffer == NULL ) { - xError = ( FF_Error_t ) ( FF_ERR_DEVICE_DRIVER_FAILED | FF_PUTFATENTRY ); + xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_PUTFATENTRY ); break; } @@ -864,7 +861,6 @@ BaseType_t FF_isEndOfChain( FF_IOManager_t * pxIOManager, #endif /* if ( ffconfigFAT12_SUPPORT != 0 ) */ /** - * @private * @brief Writes a new Entry to the FAT Tables. * * @param pxIOManager IOMAN object. @@ -899,7 +895,7 @@ FF_Error_t FF_putFATEntry( FF_IOManager_t * pxIOManager, if( ( ulCluster == 0ul ) || ( ulCluster >= pxIOManager->xPartition.ulNumClusters ) ) { /* find a more specific error code. */ - xError = ( FF_Error_t ) ( FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE | FF_PUTFATENTRY ); + xError = FF_createERR( FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE, FF_PUTFATENTRY ); } else { @@ -950,7 +946,7 @@ FF_Error_t FF_putFATEntry( FF_IOManager_t * pxIOManager, if( FF_isERR( xError ) ) { - xError = FF_GETERROR( xError ) | FF_PUTFATENTRY; + xError = (FF_Error_t) ( FF_GETERROR( xError ) | FF_PUTFATENTRY ); break; } @@ -1007,13 +1003,12 @@ FF_Error_t FF_putFATEntry( FF_IOManager_t * pxIOManager, /*-----------------------------------------------------------*/ /** - * @private * @brief Finds a Free Cluster and returns its number. * * @param pxIOManager IOMAN Object. * * @return The number of the cluster found to be free. - * @return 0 on error. + * @retval 0 on error. **/ #if ( ffconfigFAT12_SUPPORT != 0 ) static uint32_t prvFindFreeClusterSimple( FF_IOManager_t * pxIOManager, @@ -1112,7 +1107,7 @@ uint32_t FF_FindFreeCluster( FF_IOManager_t * pxIOManager, if( pxBuffer == NULL ) { - xError = ( FF_Error_t ) ( FF_ERR_DEVICE_DRIVER_FAILED | FF_FINDFREECLUSTER ); + xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_FINDFREECLUSTER ); } else { @@ -1134,8 +1129,8 @@ uint32_t FF_FindFreeCluster( FF_IOManager_t * pxIOManager, uint32_t ulFATSector; uint32_t ulFATOffset; - ulEntriesPerSector = pxIOManager->usSectorSize / xEntrySize; - ulFATOffset = ulCluster * xEntrySize; + ulEntriesPerSector = ( uint32_t ) ( pxIOManager->usSectorSize / xEntrySize ); + ulFATOffset = ( uint32_t ) ( ulCluster * xEntrySize ); /* Start from a sector where the first free entry is expected, * and iterate through every FAT sector. */ @@ -1147,7 +1142,7 @@ uint32_t FF_FindFreeCluster( FF_IOManager_t * pxIOManager, if( pxBuffer == NULL ) { - xError = ( FF_Error_t ) ( FF_ERR_DEVICE_DRIVER_FAILED | FF_FINDFREECLUSTER ); + xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_FINDFREECLUSTER ); break; } @@ -1156,7 +1151,7 @@ uint32_t FF_FindFreeCluster( FF_IOManager_t * pxIOManager, /* Double-check: don't use non-existing clusters */ if( ulCluster >= uNumClusters ) { - xError = ( FF_Error_t ) ( FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE | FF_FINDFREECLUSTER ); + xError = FF_createERR( FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE, FF_FINDFREECLUSTER ); break; } @@ -1201,7 +1196,7 @@ uint32_t FF_FindFreeCluster( FF_IOManager_t * pxIOManager, if( ( FF_isERR( xError ) == pdFALSE ) && ( ulFATSector == pxIOManager->xPartition.ulSectorsPerFAT ) ) { - xError = ( FF_Error_t ) ( FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE | FF_FINDFREECLUSTER ); + xError = FF_createERR( FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE, FF_FINDFREECLUSTER ); } } /* if( FF_isERR( xError ) == pdFALSE ) */ } /* if( pxIOManager->xPartition.ucType != FF_T_FAT12 ) */ @@ -1243,10 +1238,9 @@ uint32_t FF_FindFreeCluster( FF_IOManager_t * pxIOManager, /*-----------------------------------------------------------*/ /** - * @private * @brief Creates a Cluster Chain - * @return > 0 New created cluster - * @return = 0 See pxError + * @retval > 0 New created cluster + * @retval = 0 See pxError **/ uint32_t FF_CreateClusterChain( FF_IOManager_t * pxIOManager, FF_Error_t * pxError ) @@ -1316,17 +1310,16 @@ uint32_t FF_GetChainLength( FF_IOManager_t * pxIOManager, /*-----------------------------------------------------------*/ /** - * @private * @brief Free's Disk space by freeing unused links on Cluster Chains * - * @param pxIOManager, IOMAN object. + * @param pxIOManager IOMAN object. * @param ulStartCluster Cluster Number that starts the chain. - * @param ulCount Number of Clusters from the end of the chain to unlink. - * @param ulCount 0 Means Free the entire chain (delete file). - * @param ulCount 1 Means mark the start cluster with EOF. + * @param xDoTruncate Perform truncation of the FAT entry + * when non-zero - truncate + * when 0 - do not perform truncation * - * @return 0 On Success. - * @return -1 If the device driver failed to provide access. + * @retval 0 On Success. + * @retval -1 If the device driver failed to provide access. * **/ FF_Error_t FF_UnlinkClusterChain( FF_IOManager_t * pxIOManager, @@ -1494,7 +1487,7 @@ uint32_t FF_CountFreeClusters( FF_IOManager_t * pxIOManager, if( pxBuffer == NULL ) { - xError = ( FF_Error_t ) ( FF_ERR_DEVICE_DRIVER_FAILED | FF_COUNTFREECLUSTERS ); + xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_COUNTFREECLUSTERS ); } else { @@ -1542,7 +1535,7 @@ uint32_t FF_CountFreeClusters( FF_IOManager_t * pxIOManager, if( pxBuffer == NULL ) { - xError = ( FF_Error_t ) ( FF_ERR_DEVICE_DRIVER_FAILED | FF_COUNTFREECLUSTERS ); + xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_COUNTFREECLUSTERS ); break; } diff --git a/ff_file.c b/ff_file.c index c7d10de..387149c 100755 --- a/ff_file.c +++ b/ff_file.c @@ -43,20 +43,20 @@ static FF_Error_t FF_Truncate( FF_FILE * pxFile, BaseType_t bClosing ); -static int32_t FF_ReadPartial( FF_FILE * pxFile, - uint32_t ulItemLBA, - uint32_t ulRelBlockPos, - uint32_t ulCount, - uint8_t * pucBuffer, - FF_Error_t * pxError ); - -static int32_t FF_WritePartial( FF_FILE * pxFile, +static uint32_t FF_ReadPartial( FF_FILE * pxFile, uint32_t ulItemLBA, uint32_t ulRelBlockPos, uint32_t ulCount, - const uint8_t * pucBuffer, + uint8_t * pucBuffer, FF_Error_t * pxError ); +static uint32_t FF_WritePartial( FF_FILE * pxFile, + uint32_t ulItemLBA, + uint32_t ulRelBlockPos, + uint32_t ulCount, + const uint8_t * pucBuffer, + FF_Error_t * pxError ); + static uint32_t FF_SetCluster( FF_FILE * pxFile, FF_Error_t * pxError ); static uint32_t FF_FileLBA( FF_FILE * pxFile ); @@ -67,10 +67,9 @@ static FF_Error_t FF_ExtendFile( FF_FILE * pxFile, /*-----------------------------------------------------------*/ /** - * @public * @brief Converts STDIO mode strings into the equivalent FreeRTOS+FAT mode. * - * @param Mode The mode string e.g. "rb" "rb+" "w" "a" "r" "w+" "a+" etc + * @param pcMode The mode string e.g. "rb" "rb+" "w" "a" "r" "w+" "a+" etc * * @return Returns the mode bits that should be passed to the FF_Open function. **/ @@ -136,7 +135,7 @@ static FF_FILE * prvAllocFileHandle( FF_IOManager_t * pxIOManager, if( pxFile == NULL ) { - *pxError = ( FF_Error_t ) ( FF_ERR_NOT_ENOUGH_MEMORY | FF_OPEN ); + *pxError = FF_createERR( FF_ERR_NOT_ENOUGH_MEMORY, FF_OPEN ); } else { @@ -152,7 +151,7 @@ static FF_FILE * prvAllocFileHandle( FF_IOManager_t * pxIOManager, } else { - *pxError = ( FF_Error_t ) ( FF_ERR_NOT_ENOUGH_MEMORY | FF_OPEN ); + *pxError = FF_createERR( FF_ERR_NOT_ENOUGH_MEMORY, FF_OPEN ); ffconfigFREE( pxFile ); /* Make sure that NULL will be returned. */ pxFile = NULL; @@ -207,7 +206,6 @@ static FF_FILE * prvAllocFileHandle( FF_IOManager_t * pxIOManager, **/ /** - * @public * @brief Opens a File for Access * * @param pxIOManager FF_IOManager_t object that was created by FF_CreateIOManger(). @@ -218,7 +216,6 @@ static FF_FILE * prvAllocFileHandle( FF_IOManager_t * pxIOManager, * @param pxError To be checked when a NULL pointer is returned. * * @return NULL pointer on error, in which case pxError should be checked for more information. - * @return pxError can be: **/ #if ( ffconfigUNICODE_UTF16_SUPPORT != 0 ) FF_FILE * FF_Open( FF_IOManager_t * pxIOManager, @@ -264,13 +261,13 @@ static FF_FILE * prvAllocFileHandle( FF_IOManager_t * pxIOManager, { /* Use the error function code 'FF_OPEN' as this static * function is only called from that function. */ - xError = ( FF_Error_t ) ( FF_ERR_NULL_POINTER | FF_OPEN ); + xError = FF_createERR( FF_ERR_NULL_POINTER, FF_OPEN ); } #if ( ffconfigREMOVABLE_MEDIA != 0 ) else if( ( pxIOManager->ucFlags & FF_IOMAN_DEVICE_IS_EXTRACTED ) != 0 ) { - xError = ( FF_Error_t ) ( FF_ERR_IOMAN_DRIVER_NOMEDIUM | FF_OPEN ); + xError = FF_createERR( FF_ERR_IOMAN_DRIVER_NOMEDIUM, FF_OPEN ); } #endif /* ffconfigREMOVABLE_MEDIA */ else @@ -306,7 +303,7 @@ static FF_FILE * prvAllocFileHandle( FF_IOManager_t * pxIOManager, FF_CreateShortName( &xFindParams, pcFileName ); /* Lookup the path and find the cluster pointing to the directory: */ - xFindParams.ulDirCluster = FF_FindDir( pxIOManager, pcPath, xIndex, &xError ); + xFindParams.ulDirCluster = FF_FindDir( pxIOManager, pcPath, ( uint16_t ) xIndex, &xError ); if( xFindParams.ulDirCluster == 0ul ) { @@ -355,7 +352,7 @@ static FF_FILE * prvAllocFileHandle( FF_IOManager_t * pxIOManager, * Maybe the user wants to create it? */ if( ( ucMode & FF_MODE_CREATE ) == 0 ) { - xError = ( FF_Error_t ) ( FF_ERR_FILE_NOT_FOUND | FF_OPEN ); + xError = FF_createERR( FF_ERR_FILE_NOT_FOUND, FF_OPEN ); } else { @@ -376,12 +373,12 @@ static FF_FILE * prvAllocFileHandle( FF_IOManager_t * pxIOManager, if( ( xDirEntry.ucAttrib == FF_FAT_ATTR_DIR ) && ( ( ucMode & FF_MODE_DIR ) == 0 ) ) { /* Not the object, File Not Found! */ - xError = ( FF_Error_t ) ( FF_ERR_FILE_OBJECT_IS_A_DIR | FF_OPEN ); + xError = FF_createERR( FF_ERR_FILE_OBJECT_IS_A_DIR, FF_OPEN ); } /*---------- Ensure Read-Only files don't get opened for Writing. */ else if( ( ( ucMode & ( FF_MODE_WRITE | FF_MODE_APPEND ) ) != 0 ) && ( ( xDirEntry.ucAttrib & FF_FAT_ATTR_READONLY ) != 0 ) ) { - xError = ( FF_Error_t ) ( FF_ERR_FILE_IS_READ_ONLY | FF_OPEN ); + xError = FF_createERR( FF_ERR_FILE_IS_READ_ONLY, FF_OPEN ); } } @@ -428,7 +425,7 @@ static FF_FILE * prvAllocFileHandle( FF_IOManager_t * pxIOManager, if( ( ( pxFileChain->ucMode | pxFile->ucMode ) & ( FF_MODE_WRITE | FF_MODE_APPEND ) ) != 0 ) { /* File is already open! DON'T ALLOW IT! */ - xError = ( FF_Error_t ) ( FF_ERR_FILE_ALREADY_OPEN | FF_OPEN ); + xError = FF_createERR( FF_ERR_FILE_ALREADY_OPEN, FF_OPEN ); break; } } @@ -492,7 +489,6 @@ static FF_FILE * prvAllocFileHandle( FF_IOManager_t * pxIOManager, /*-----------------------------------------------------------*/ /** - * @public * @brief Tests if a Directory contains any other files or folders. * * @param pxIOManager FF_IOManager_t object returned from the FF_CreateIOManger() function. @@ -559,16 +555,15 @@ static FF_FILE * prvAllocFileHandle( FF_IOManager_t * pxIOManager, * The directory 'path' will be removed or renamed * now clear all entries starting with 'path' in the path cache */ - BaseType_t xIndex; - BaseType_t pathLen = STRLEN( pcPath ); + UBaseType_t pathLen = STRLEN( pcPath ); FF_PendSemaphore( pxIOManager->pvSemaphore ); { - for( xIndex = 0; xIndex < ffconfigPATH_CACHE_DEPTH; xIndex++ ) + for( UBaseType_t xIndex = 0; xIndex < ffconfigPATH_CACHE_DEPTH; xIndex++ ) { - BaseType_t len2 = STRLEN( pxIOManager->xPartition.pxPathCache[ xIndex ].pcPath ); + UBaseType_t len2 = STRLEN( pxIOManager->xPartition.pxPathCache[ xIndex ].pcPath ); - if( ( len2 >= pathLen ) && FF_strmatch( pxIOManager->xPartition.pxPathCache[ xIndex ].pcPath, pcPath, pathLen ) ) + if( ( len2 >= pathLen ) && FF_strmatch( pxIOManager->xPartition.pxPathCache[ xIndex ].pcPath, pcPath, ( BaseType_t ) pathLen ) ) { pxIOManager->xPartition.pxPathCache[ xIndex ].pcPath[ 0 ] = '\0'; pxIOManager->xPartition.pxPathCache[ xIndex ].ulDirCluster = 0; @@ -597,13 +592,13 @@ static FF_FILE * prvAllocFileHandle( FF_IOManager_t * pxIOManager, if( pxIOManager == NULL ) { - xError = ( FF_Error_t ) ( FF_ERR_NULL_POINTER | FF_RMDIR ); + xError = FF_createERR( FF_ERR_NULL_POINTER, FF_RMDIR ); } #if ( ffconfigREMOVABLE_MEDIA != 0 ) else if( ( pxIOManager->ucFlags & FF_IOMAN_DEVICE_IS_EXTRACTED ) != 0 ) { - xError = ( FF_Error_t ) ( FF_ERR_IOMAN_DRIVER_NOMEDIUM | FF_RMDIR ); + xError = FF_createERR( FF_ERR_IOMAN_DRIVER_NOMEDIUM, FF_RMDIR ); } #endif /* ffconfigREMOVABLE_MEDIA */ else @@ -627,7 +622,7 @@ static FF_FILE * prvAllocFileHandle( FF_IOManager_t * pxIOManager, * statements. */ if( FF_isDirEmpty( pxIOManager, pcPath ) == pdFALSE ) { - xError = ( FF_ERR_DIR_NOT_EMPTY | FF_RMDIR ); + xError = FF_createERR( FF_ERR_DIR_NOT_EMPTY, FF_RMDIR ); break; } @@ -853,18 +848,17 @@ static FF_FILE * prvAllocFileHandle( FF_IOManager_t * pxIOManager, /*-----------------------------------------------------------*/ /** - * @public * @brief Moves a file or directory from source to destination. * * @param pxIOManager The FF_IOManager_t object pointer. * @param szSourceFile String of the source file to be moved or renamed. * @param szDestinationFile String of the destination file to where the source should be moved or renamed. * - * @return FF_ERR_NONE on success. - * @return FF_ERR_FILE_DESTINATION_EXISTS if the destination file exists. - * @return FF_ERR_FILE_COULD_NOT_CREATE_DIRENT if dirent creation failed (fatal error!). - * @return FF_ERR_FILE_DIR_NOT_FOUND if destination directory was not found. - * @return FF_ERR_FILE_SOURCE_NOT_FOUND if the source file was not found. + * @retval FF_ERR_NONE on success. + * @retval FF_ERR_FILE_DESTINATION_EXISTS if the destination file exists. + * @retval FF_ERR_FILE_COULD_NOT_CREATE_DIRENT if dirent creation failed (fatal error!). + * @retval FF_ERR_FILE_DIR_NOT_FOUND if destination directory was not found. + * @retval FF_ERR_FILE_SOURCE_NOT_FOUND if the source file was not found. * **/ @@ -884,7 +878,7 @@ static FF_FILE * prvAllocFileHandle( FF_IOManager_t * pxIOManager, FF_FILE * pSrcFile, * pxDestFile; FF_DirEnt_t xMyFile; uint8_t ucEntryBuffer[ 32 ]; - BaseType_t xIndex; + UBaseType_t xIndex; uint32_t ulDirCluster = 0ul; FF_FetchContext_t xFetchContext; @@ -896,13 +890,13 @@ static FF_FILE * prvAllocFileHandle( FF_IOManager_t * pxIOManager, if( pxIOManager == NULL ) { - xError = ( FF_Error_t ) ( FF_ERR_NULL_POINTER | FF_MOVE ); + xError = FF_createERR( FF_ERR_NULL_POINTER, FF_MOVE ); } #if ( ffconfigREMOVABLE_MEDIA != 0 ) else if( ( pxIOManager->ucFlags & FF_IOMAN_DEVICE_IS_EXTRACTED ) != 0 ) { - xError = ( FF_Error_t ) ( FF_ERR_IOMAN_DRIVER_NOMEDIUM | FF_MOVE ); + xError = FF_createERR( FF_ERR_IOMAN_DRIVER_NOMEDIUM, FF_MOVE ); } #endif /* ffconfigREMOVABLE_MEDIA */ else @@ -912,7 +906,7 @@ static FF_FILE * prvAllocFileHandle( FF_IOManager_t * pxIOManager, if( ( pxDestFile != NULL ) || ( FF_GETERROR( xError ) == FF_ERR_FILE_OBJECT_IS_A_DIR ) ) { - xError = ( FF_Error_t ) ( FF_ERR_FILE_DESTINATION_EXISTS | FF_MOVE ); + xError = FF_createERR( FF_ERR_FILE_DESTINATION_EXISTS, FF_MOVE ); if( pxDestFile != NULL ) { @@ -963,7 +957,7 @@ static FF_FILE * prvAllocFileHandle( FF_IOManager_t * pxIOManager, xMyFile.ulObjectCluster = pSrcFile->ulObjectCluster; xMyFile.usCurrentItem = 0; - xIndex = ( BaseType_t ) STRLEN( szDestinationFile ); + xIndex = ( UBaseType_t ) STRLEN( szDestinationFile ); while( xIndex != 0 ) { @@ -986,7 +980,7 @@ static FF_FILE * prvAllocFileHandle( FF_IOManager_t * pxIOManager, /* Find the (cluster of the) directory in which the target file will be located. * It must exist before calling FF_Move(). */ - ulDirCluster = FF_FindDir( pxIOManager, szDestinationFile, xIndex, &xError ); + ulDirCluster = FF_FindDir( pxIOManager, szDestinationFile, ( uint16_t ) xIndex, &xError ); } } } @@ -1054,7 +1048,7 @@ static FF_FILE * prvAllocFileHandle( FF_IOManager_t * pxIOManager, } else /* ulDirCluster == 0ul */ { - xError = ( FF_Error_t ) ( FF_ERR_FILE_DIR_NOT_FOUND | FF_MOVE ); + xError = FF_createERR( FF_ERR_FILE_DIR_NOT_FOUND, FF_MOVE ); } } @@ -1090,13 +1084,12 @@ static FF_FILE * prvAllocFileHandle( FF_IOManager_t * pxIOManager, /*-----------------------------------------------------------*/ /** - * @public * @brief Get's the next Entry based on the data recorded in the FF_DirEnt_t object. * * @param pxFile FF_FILE object that was created by FF_Open(). * - * @return pdTRUE if End of File was reached. pdFALSE if not. - * @return pdFALSE if a null pointer was provided. + * @retval pdTRUE if End of File was reached. pdFALSE if not. + * @retval pdFALSE if a null pointer was provided. * **/ BaseType_t FF_isEOF( FF_FILE * pxFile ) @@ -1117,13 +1110,11 @@ BaseType_t FF_isEOF( FF_FILE * pxFile ) /*-----------------------------------------------------------*/ /** - * @public * @brief Checks the number of bytes left on a read handle * * @param pxFile An open file handle * - * @return Less than zero: an error code - * @return Number of bytes left to read from handle + * @return Less than zero: an error code, or Number of bytes left to read from handle **/ int32_t FF_BytesLeft( FF_FILE * pxFile ) { @@ -1146,37 +1137,36 @@ int32_t FF_BytesLeft( FF_FILE * pxFile ) xReturn = pxFile->ulFileSize - pxFile->ulFilePointer; } - return xReturn; + return ( int32_t ) xReturn; } /* FF_BytesLeft() */ /*-----------------------------------------------------------*/ /** - * @public * @brief Returns the file size of a read handle * - * @param pxFile An open file handle + * @param pxFile An open file handle + * @param[out] pulSize Writes # of bytes in a file to the parameter. * - * @return Less than zero: an error code - * @return Number of bytes left to read from handle + * @return Less than zero: an error code, or Number of bytes left to read from handle **/ FF_Error_t FF_GetFileSize( FF_FILE * pxFile, - uint32_t * pulSize ) /* Writes # of bytes in a file to the parameter. */ + uint32_t * pulSize ) { - BaseType_t xReturn; + FF_Error_t xReturn; if( pxFile == NULL ) { - xReturn = ( FF_Error_t ) ( FF_ERR_NULL_POINTER | FF_BYTESLEFT ); + xReturn = FF_createERR( FF_ERR_NULL_POINTER, FF_BYTESLEFT ); *( pulSize ) = ( uint32_t ) 0u; } else if( FF_isERR( FF_CheckValid( pxFile ) ) ) { - xReturn = ( FF_Error_t ) ( FF_ERR_FILE_BAD_HANDLE | FF_BYTESLEFT ); + xReturn = FF_createERR( FF_ERR_FILE_BAD_HANDLE, FF_BYTESLEFT ); *( pulSize ) = ( uint32_t ) 0u; } else { - xReturn = 0; + xReturn = FF_ERR_NONE; *( pulSize ) = pxFile->ulFileSize; } @@ -1323,7 +1313,7 @@ static FF_Error_t FF_ExtendFile( FF_FILE * pxFile, if( ( pxFile->ucMode & FF_MODE_WRITE ) != FF_MODE_WRITE ) { - xError = ( FF_Error_t ) ( FF_ERR_FILE_NOT_OPENED_IN_WRITE_MODE | FF_EXTENDFILE ); + xError = FF_createERR( FF_ERR_FILE_NOT_OPENED_IN_WRITE_MODE, FF_EXTENDFILE ); } else { @@ -1389,7 +1379,7 @@ static FF_Error_t FF_ExtendFile( FF_FILE * pxFile, if( ( FF_isERR( xError ) == pdFALSE ) && ( ulNextCluster == 0UL ) ) { - xError = ( FF_Error_t ) ( FF_ERR_FAT_NO_FREE_CLUSTERS | FF_EXTENDFILE ); + xError = FF_createERR( FF_ERR_FAT_NO_FREE_CLUSTERS, FF_EXTENDFILE ); } if( FF_isERR( xError ) ) @@ -1555,7 +1545,6 @@ static FF_Error_t FF_WriteClusters( FF_FILE * pxFile, /*-----------------------------------------------------------*/ /** - * @private * @brief Calculate the Logical Block Address (LBA) * * @param pxFile The file handle @@ -1580,9 +1569,8 @@ static uint32_t FF_FileLBA( FF_FILE * pxFile ) /*-----------------------------------------------------------*/ /** - * @private * @brief Depending on FilePointer, calculate CurrentCluster - * @brief and traverse the FAT to find the right ulAddrCurrentCluster + * and traverse the FAT to find the right ulAddrCurrentCluster * * @param pxFile The file handle * @@ -1639,12 +1627,12 @@ static uint32_t FF_SetCluster( FF_FILE * pxFile, } /* FF_SetCluster() */ /*-----------------------------------------------------------*/ -static int32_t FF_ReadPartial( FF_FILE * pxFile, - uint32_t ulItemLBA, - uint32_t ulRelBlockPos, - uint32_t ulCount, - uint8_t * pucBuffer, - FF_Error_t * pxError ) +static uint32_t FF_ReadPartial( FF_FILE * pxFile, + uint32_t ulItemLBA, + uint32_t ulRelBlockPos, + uint32_t ulCount, + uint8_t * pucBuffer, + FF_Error_t * pxError ) { FF_Error_t xError = FF_ERR_NONE; uint32_t ulBytesRead; @@ -1709,7 +1697,7 @@ static int32_t FF_ReadPartial( FF_FILE * pxFile, if( pxBuffer == NULL ) { - xError = ( FF_Error_t ) ( FF_ERR_DEVICE_DRIVER_FAILED | FF_READ ); + xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_READ ); ulBytesRead = 0ul; } else @@ -1732,13 +1720,12 @@ static int32_t FF_ReadPartial( FF_FILE * pxFile, /*-----------------------------------------------------------*/ /** - * @public * @brief Equivalent to fread() * * @param pxFile FF_FILE object that was created by FF_Open(). * @param ulElementSize The size of an element to read. * @param ulCount The number of elements to read. - * @param buffer A pointer to a buffer of adequate size to be filled with the requested data. + * @param pucBuffer A pointer to a buffer of adequate size to be filled with the requested data. * * @return Number of bytes read. * @@ -1768,7 +1755,7 @@ int32_t FF_Read( FF_FILE * pxFile, if( pxFile == NULL ) { - xError = ( FF_Error_t ) ( FF_ERR_NULL_POINTER | FF_READ ); + xError = FF_createERR( FF_ERR_NULL_POINTER, FF_READ ); } else { @@ -1780,13 +1767,13 @@ int32_t FF_Read( FF_FILE * pxFile, if( ( pxFile->ucMode & FF_MODE_READ ) == 0 ) { /* File was not opened with READ mode access. */ - xError = ( FF_Error_t ) ( FF_ERR_FILE_NOT_OPENED_IN_READ_MODE | FF_READ ); + xError = FF_createERR( FF_ERR_FILE_NOT_OPENED_IN_READ_MODE, FF_READ ); } else if( pxFile->ulFilePointer >= pxFile->ulFileSize ) { /* The end-of-file is reached. The error READ_ZERO will not be * returned, it is just used to avoid further processing. */ - xError = ( FF_Error_t ) ( FF_ERR_FILE_READ_ZERO | FF_READ ); + xError = FF_createERR( FF_ERR_FILE_READ_ZERO, FF_READ ); } else if( ( pxFile->ulFilePointer + ulBytesLeft ) > pxFile->ulFileSize ) { @@ -1973,14 +1960,13 @@ int32_t FF_Read( FF_FILE * pxFile, /*-----------------------------------------------------------*/ /** - * @public * @brief Equivalent to fgetc() * * @param pxFile FF_FILE object that was created by FF_Open(). * - * @return The character that was read (cast as a 32-bit interger). -1 on EOF. - * @return FF_Error_t code. (Check with if(FF_isERR(xRetVal)) {}). - * @return -1 EOF (end of file). + * @retval The character that was read (cast as a 32-bit interger). -1 on EOF. + * @retval FF_Error_t code. (Check with if(FF_isERR(xRetVal)) {}). + * @retval -1 EOF (end of file). * **/ int32_t FF_GetC( FF_FILE * pxFile ) @@ -1992,17 +1978,17 @@ int32_t FF_GetC( FF_FILE * pxFile ) if( pxFile == NULL ) { - xResult = FF_ERR_NULL_POINTER | FF_GETC; /* Ensure this is a signed error. */ + xResult = (FF_Error_t) ( FF_ERR_NULL_POINTER | FF_GETC ); /* Ensure this is a signed error. */ } else if( ( pxFile->ucMode & FF_MODE_READ ) == 0 ) { - xResult = FF_ERR_FILE_NOT_OPENED_IN_READ_MODE | FF_GETC; + xResult = (FF_Error_t) ( FF_ERR_FILE_NOT_OPENED_IN_READ_MODE | FF_GETC ); } else if( pxFile->ulFilePointer >= pxFile->ulFileSize ) { /* The end-of-file is reached. The error READ_ZERO will not be * returned, it is just used to avoid further processing. */ - xResult = FF_ERR_FILE_READ_ZERO | FF_READ; + xResult = (FF_Error_t) ( FF_ERR_FILE_READ_ZERO | FF_READ ); } else { @@ -2026,7 +2012,6 @@ int32_t FF_GetC( FF_FILE * pxFile ) /*-----------------------------------------------------------*/ /** - * @public * @brief Gets a Line from a Text File, but no more than ulLimit characters. The line will be NULL terminated. * * The behaviour of this function is undefined when called on a binary file. @@ -2035,12 +2020,12 @@ int32_t FF_GetC( FF_FILE * pxFile ) * This function works for both UNIX line feeds, and Windows CRLF type files. * * @param pxFile The FF_FILE object pointer. - * @param szLine The character buffer where the line should be stored. + * @param pcLine The character buffer where the line should be stored. * @param ulLimit This should be the max number of characters that szLine can hold. * * @return The number of characters read from the line, on success. - * @return 0 when no more lines are available, or when ulLimit is 0. - * @return FF_ERR_NULL_POINTER if pxFile or szLine are NULL; + * 0 when no more lines are available, or when ulLimit is 0. + * FF_ERR_NULL_POINTER if pxFile or szLine are NULL; * **/ int32_t FF_GetLine( FF_FILE * pxFile, @@ -2053,7 +2038,7 @@ int32_t FF_GetLine( FF_FILE * pxFile, if( ( pxFile == NULL ) || ( pcLine == NULL ) ) { - xResult = FF_ERR_NULL_POINTER | FF_GETLINE; + xResult = FF_createERR( FF_ERR_NULL_POINTER, FF_GETLINE ); } else { @@ -2082,7 +2067,7 @@ int32_t FF_GetLine( FF_FILE * pxFile, { /* Although FF_GetC() returns an End Of File, * the last few characters will be returned first. */ - iChar = xIndex; + iChar = ( int32_t )xIndex; } break; @@ -2097,7 +2082,7 @@ int32_t FF_GetLine( FF_FILE * pxFile, if( FF_isERR( iChar ) == pdFALSE ) { /* Return the number of bytes read. */ - xResult = xIndex; + xResult = ( int32_t ) xIndex; } else { @@ -2110,12 +2095,12 @@ int32_t FF_GetLine( FF_FILE * pxFile, } /* FF_GetLine() */ /*-----------------------------------------------------------*/ -static int32_t FF_WritePartial( FF_FILE * pxFile, - uint32_t ulItemLBA, - uint32_t ulRelBlockPos, - uint32_t ulCount, - const uint8_t * pucBuffer, - FF_Error_t * pxError ) +static uint32_t FF_WritePartial( FF_FILE * pxFile, + uint32_t ulItemLBA, + uint32_t ulRelBlockPos, + uint32_t ulCount, + const uint8_t * pucBuffer, + FF_Error_t * pxError ) { FF_Error_t xError; uint32_t ulBytesWritten; @@ -2186,7 +2171,7 @@ static int32_t FF_WritePartial( FF_FILE * pxFile, if( pxBuffer == NULL ) { - xError = ( FF_Error_t ) ( FF_ERR_DEVICE_DRIVER_FAILED | FF_WRITE ); + xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_WRITE ); } else { @@ -2220,7 +2205,6 @@ static int32_t FF_WritePartial( FF_FILE * pxFile, /*-----------------------------------------------------------*/ /** - * @public * @brief Writes data to a File. * * @param pxFile FILE Pointer. @@ -2234,7 +2218,7 @@ static int32_t FF_WritePartial( FF_FILE * pxFile, * 3. Write complete clusters: FF_WriteClusters() * 4. Write remaining sectors: FF_BlockWrite() * 5. Write remaining bytes: FF_WritePartial() - * @return + * @return FF_ERR_NONE when success, otherwise one of FF_ERR_* when failure **/ int32_t FF_Write( FF_FILE * pxFile, uint32_t ulElementSize, @@ -2255,7 +2239,7 @@ int32_t FF_Write( FF_FILE * pxFile, if( pxFile == NULL ) { - xError = ( FF_Error_t ) ( FF_ERR_NULL_POINTER | FF_READ ); + xError = FF_createERR( FF_ERR_NULL_POINTER, FF_READ ); } else { @@ -2266,7 +2250,7 @@ int32_t FF_Write( FF_FILE * pxFile, { if( ( pxFile->ucMode & FF_MODE_WRITE ) == 0 ) { - xError = ( FF_Error_t ) ( FF_ERR_FILE_NOT_OPENED_IN_WRITE_MODE | FF_WRITE ); + xError = FF_createERR( FF_ERR_FILE_NOT_OPENED_IN_WRITE_MODE, FF_WRITE ); } /* Make sure a write is after the append point. */ else if( ( pxFile->ucMode & FF_MODE_APPEND ) != 0 ) @@ -2470,7 +2454,6 @@ int32_t FF_Write( FF_FILE * pxFile, /*-----------------------------------------------------------*/ /** - * @public * @brief Writes a char to a FILE. * * @param pxFile FILE Pointer. @@ -2488,11 +2471,11 @@ int32_t FF_PutC( FF_FILE * pxFile, if( pxFile == NULL ) { /* Ensure we don't have a Null file pointer on a Public interface. */ - xResult = FF_ERR_NULL_POINTER | FF_PUTC; + xResult = FF_createERR( FF_ERR_NULL_POINTER, FF_PUTC ); } else if( ( pxFile->ucMode & FF_MODE_WRITE ) == 0 ) { - xResult = FF_ERR_FILE_NOT_OPENED_IN_WRITE_MODE | FF_PUTC; + xResult = FF_createERR( FF_ERR_FILE_NOT_OPENED_IN_WRITE_MODE, FF_PUTC ); } else { @@ -2546,17 +2529,16 @@ int32_t FF_PutC( FF_FILE * pxFile, /*-----------------------------------------------------------*/ /** - * @public * @brief Equivalent to fseek() * * @param pxFile FF_FILE object that was created by FF_Open(). - * @param ulOffset An integer (+/-) to seek to, from the specified origin. + * @param lOffset An integer (+/-) to seek to, from the specified origin. * @param xOrigin Where to seek from. (FF_SEEK_SET seek from start, FF_SEEK_CUR seek from current position, or FF_SEEK_END seek from end of file). * - * @return 0 on Sucess, - * @return -2 if offset results in an invalid position in the file. - * @return FF_ERR_NULL_POINTER if a FF_FILE pointer was not received. - * @return -3 if an invalid origin was provided. + * @retval 0 on Sucess, + * @retval -2 if offset results in an invalid position in the file. + * @retval FF_ERR_NULL_POINTER if a FF_FILE pointer was not received. + * @retval -3 if an invalid origin was provided. * **/ FF_Error_t FF_Seek( FF_FILE * pxFile, @@ -2645,14 +2627,13 @@ FF_Error_t FF_Seek( FF_FILE * pxFile, #if ( ffconfigREMOVABLE_MEDIA != 0 ) /** - * @public * @brief Invalidate all file handles belonging to pxIOManager * * @param pIoMan FF_IOManager_t object that was created by FF_CreateIOManger(). * - * @return 0 if no handles were open - * @return >0 the amount of handles that were invalidated - * @return <0 probably an invalid FF_IOManager_t pointer + * @retval 0 if no handles were open + * @retval >0 the amount of handles that were invalidated + * @retval <0 probably an invalid FF_IOManager_t pointer * **/ int32_t FF_Invalidate( FF_IOManager_t * pxIOManager ) @@ -2695,15 +2676,14 @@ FF_Error_t FF_Seek( FF_FILE * pxFile, /*-----------------------------------------------------------*/ /** - * @public * @brief Check validity of file handle * * @param pxFile FF_FILE object that was created by FF_Open(). * - * @return 0 on sucess. - * @return FF_ERR_NULL_POINTER if a null pointer was provided. - * @return FF_ERR_FILE_BAD_HANDLE if handle is not recognized - * @return FF_ERR_FILE_MEDIA_REMOVED please call FF_Close + * @retval 0 on sucess. + * @retval FF_ERR_NULL_POINTER if a null pointer was provided. + * @retval FF_ERR_FILE_BAD_HANDLE if handle is not recognized + * @retval FF_ERR_FILE_MEDIA_REMOVED please call FF_Close * **/ FF_Error_t FF_CheckValid( FF_FILE * pxFile ) @@ -2713,14 +2693,14 @@ FF_Error_t FF_CheckValid( FF_FILE * pxFile ) if( ( pxFile == NULL ) || ( pxFile->pxIOManager == NULL ) ) { - xError = ( FF_Error_t ) ( FF_ERR_NULL_POINTER | FF_CHECKVALID ); + xError = FF_createERR( FF_ERR_NULL_POINTER, FF_CHECKVALID ); } else { FF_PendSemaphore( pxFile->pxIOManager->pvSemaphore ); { pxFileChain = ( FF_FILE * ) pxFile->pxIOManager->FirstFile; - xError = ( FF_Error_t ) ( FF_ERR_FILE_BAD_HANDLE | FF_CHECKVALID ); + xError = FF_createERR( FF_ERR_FILE_BAD_HANDLE, FF_CHECKVALID ); while( pxFileChain != NULL ) { @@ -2730,7 +2710,7 @@ FF_Error_t FF_CheckValid( FF_FILE * pxFile ) if( ( pxFileChain->ulValidFlags & FF_VALID_FLAG_INVALID ) != 0 ) { /* The medium has been removed while this file handle was open. */ - xError = ( FF_Error_t ) ( FF_ERR_FILE_MEDIA_REMOVED | FF_CHECKVALID ); + xError = FF_createERR( FF_ERR_FILE_MEDIA_REMOVED, FF_CHECKVALID ); } else #endif @@ -2755,7 +2735,6 @@ FF_Error_t FF_CheckValid( FF_FILE * pxFile ) #if ( ffconfigTIME_SUPPORT != 0 ) /** - * @public * @brief Set the time-stamp(s) of a file entry * * @param pxFile FF_FILE object that was created by FF_Open(). @@ -2778,11 +2757,11 @@ FF_Error_t FF_CheckValid( FF_FILE * pxFile ) { if( pxFile->ulValidFlags & FF_VALID_FLAG_DELETED ) { /*if (pxFile->FileDeleted) */ - xError = ( FF_Error_t ) ( FF_ERR_FILE_NOT_FOUND | FF_SETFILETIME ); + xError = FF_createERR( FF_ERR_FILE_NOT_FOUND, FF_SETFILETIME ); } else if( ( pxFile->ucMode & ( FF_MODE_WRITE | FF_MODE_APPEND ) ) == 0 ) { - xError = ( FF_Error_t ) ( FF_ERR_FILE_NOT_OPENED_IN_WRITE_MODE | FF_SETFILETIME ); + xError = FF_createERR( FF_ERR_FILE_NOT_OPENED_IN_WRITE_MODE, FF_SETFILETIME ); } else { @@ -2824,7 +2803,6 @@ FF_Error_t FF_CheckValid( FF_FILE * pxFile ) #if ( ffconfigTIME_SUPPORT != 0 ) /** - * @public * @brief Set the time-stamp(s) of a file entry (by name) * * @param pxIOManager FF_IOManager_t device handle @@ -2887,7 +2865,7 @@ FF_Error_t FF_CheckValid( FF_FILE * pxFile ) { if( xFindParams.ulDirCluster == 0 ) { - xError = ( FF_Error_t ) ( FF_ERR_FILE_NOT_FOUND | FF_SETTIME ); + xError = FF_createERR( FF_ERR_FILE_NOT_FOUND, FF_SETTIME ); } else { @@ -2898,7 +2876,7 @@ FF_Error_t FF_CheckValid( FF_FILE * pxFile ) if( ulFileCluster == 0ul ) { /*FF_PRINTF ("FF_SetTime: Can not find '%s'\n", pcFileName); */ - xError = ( FF_Error_t ) ( FF_ERR_FILE_NOT_FOUND | FF_SETTIME ); + xError = FF_createERR( FF_ERR_FILE_NOT_FOUND, FF_SETTIME ); } } } @@ -2991,7 +2969,7 @@ FF_Error_t FF_CheckValid( FF_FILE * pxFile ) if( !xFindParams.ulDirCluster ) { - xError = ( FF_Error_t ) ( FF_ERR_FILE_NOT_FOUND | FF_SETTIME ); + xError = FF_createERR( FF_ERR_FILE_NOT_FOUND, FF_SETTIME ); break; } @@ -3005,7 +2983,7 @@ FF_Error_t FF_CheckValid( FF_FILE * pxFile ) if( ulFileCluster == 0ul ) { /*FF_PRINTF ("FF_SetTime: Can not find '%s'\n", pcFileName); */ - xError = ( FF_Error_t ) ( FF_ERR_FILE_NOT_FOUND | FF_SETTIME ); + xError = FF_createERR( FF_ERR_FILE_NOT_FOUND, FF_SETTIME ); break; } @@ -3034,13 +3012,12 @@ FF_Error_t FF_CheckValid( FF_FILE * pxFile ) /*-----------------------------------------------------------*/ /** - * @public * @brief Equivalent to fclose() * * @param pxFile FF_FILE object that was created by FF_Open(). * - * @return 0 on sucess. - * @return -1 if a null pointer was provided. + * @retval 0 on sucess. + * @retval -1 if a null pointer was provided. * **/ FF_Error_t FF_Close( FF_FILE * pxFile ) @@ -3054,7 +3031,7 @@ FF_Error_t FF_Close( FF_FILE * pxFile ) { if( pxFile == NULL ) { - xError = ( FF_Error_t ) ( FF_ERR_NULL_POINTER | FF_CLOSE ); + xError = FF_createERR( FF_ERR_NULL_POINTER, FF_CLOSE ); break; } @@ -3209,13 +3186,12 @@ FF_Error_t FF_Close( FF_FILE * pxFile ) /*-----------------------------------------------------------*/ /** - * @public * @brief Make Filesize equal to the FilePointer and truncates the file to this position * * @param pxFile FF_FILE object that was created by FF_Open(). * - * @return 0 on sucess. - * @return negative if some error occurred + * @retval 0 on sucess. + * @retval negative if some error occurred * **/ FF_Error_t FF_SetEof( FF_FILE * pxFile ) @@ -3239,7 +3215,7 @@ FF_Error_t FF_SetEof( FF_FILE * pxFile ) } else { - xError = ( FF_Error_t ) ( FF_ERR_FILE_NOT_OPENED_IN_WRITE_MODE | FF_SETEOF ); + xError = FF_createERR( FF_ERR_FILE_NOT_OPENED_IN_WRITE_MODE, FF_SETEOF ); } return xError; @@ -3247,13 +3223,12 @@ FF_Error_t FF_SetEof( FF_FILE * pxFile ) /*-----------------------------------------------------------*/ /** - * @public * @brief Truncate a file to 'pxFile->ulFileSize' * * @param pxFile FF_FILE object that was created by FF_Open(). * - * @return 0 on sucess. - * @return negative if some error occurred + * @retval 0 on sucess. + * @retval negative if some error occurred * **/ static FF_Error_t FF_Truncate( FF_FILE * pxFile, diff --git a/ff_format.c b/ff_format.c index 3edd290..3c2c413 100755 --- a/ff_format.c +++ b/ff_format.c @@ -252,13 +252,13 @@ static FF_Error_t prvFormatGetClusterSize( struct xFormatSet * pxSet, for( ; ; ) { - int32_t groupSize; + uint32_t groupSize; /* Usable sectors */ pxSet->ulUsableDataSectors = pxSet->ulSectorCount - pxSet->ulNonDataSectors; /* Each group consists of 'xFATCount' sectors + 'ulClustersPerFATSector' clusters */ - groupSize = pxSet->xFATCount + pxSet->ulClustersPerFATSector * pxSet->ulSectorsPerCluster; + groupSize = ( uint32_t ) pxSet->xFATCount + pxSet->ulClustersPerFATSector * pxSet->ulSectorsPerCluster; /* This amount of groups will fit: */ - pxSet->ulSectorsPerFAT = ( pxSet->ulUsableDataSectors + groupSize - pxSet->ulSectorsPerCluster - pxSet->xFATCount ) / groupSize; + pxSet->ulSectorsPerFAT = ( uint32_t ) ( ( pxSet->ulUsableDataSectors + groupSize - pxSet->ulSectorsPerCluster - ( uint32_t ) pxSet->xFATCount ) / groupSize ); pxSet->ulUsableDataClusters = ulMin32( ( uint32_t ) ( pxSet->ulUsableDataSectors - pxSet->xFATCount * pxSet->ulSectorsPerFAT ) / pxSet->ulSectorsPerCluster, @@ -283,7 +283,7 @@ static FF_Error_t prvFormatGetClusterSize( struct xFormatSet * pxSet, pxSet->ucFATType == FF_T_FAT32 ? 32 : 16, xPreferFAT16 ? 16 : 32, ( unsigned ) pxSet->ulSectorCount ); - xReturn = FF_ERR_IOMAN_BAD_MEMSIZE | FF_MODULE_FORMAT; + xReturn = FF_createERR( FF_ERR_IOMAN_BAD_MEMSIZE, FF_MODULE_FORMAT ); break; } @@ -321,7 +321,7 @@ static void prvFormatOptimiseFATLocation( struct xFormatSet * pxSet ) * http://3gfp.com/wp/2014/07/formatting-sd-cards-for-speed-and-lifetime/ */ pxSet->ulFATReservedSectors = MX_LBA_TO_MOVE_FAT - pxSet->ulHiddenSectors; - pxSet->ulNonDataSectors = pxSet->ulFATReservedSectors + pxSet->iFAT16RootSectors; + pxSet->ulNonDataSectors = pxSet->ulFATReservedSectors + ( uint32_t ) pxSet->iFAT16RootSectors; ulRemaining = ( pxSet->ulNonDataSectors + 2U * pxSet->ulSectorsPerFAT ) % 128U; @@ -329,7 +329,7 @@ static void prvFormatOptimiseFATLocation( struct xFormatSet * pxSet ) { /* In order to get ClusterBeginLBA well aligned (on a 128 sector boundary) */ pxSet->ulFATReservedSectors += ( 128U - ulRemaining ); - pxSet->ulNonDataSectors = pxSet->ulFATReservedSectors + pxSet->iFAT16RootSectors; + pxSet->ulNonDataSectors = pxSet->ulFATReservedSectors + ( uint32_t ) pxSet->iFAT16RootSectors; } pxSet->ulUsableDataSectors = pxSet->ulSectorCount - pxSet->ulNonDataSectors - 2 * pxSet->ulSectorsPerFAT; @@ -511,7 +511,7 @@ static FF_Error_t prvFormatInitialiseRootDir( struct xFormatSet * pxSet, } else { - lLastAddress = lDirectoryBegin + pxSet->ulSectorsPerCluster; + lLastAddress = lDirectoryBegin + ( int32_t ) pxSet->ulSectorsPerCluster; } FF_PRINTF( "FF_Format: Clearing root directory at %08lX: %lu sectors\n", lDirectoryBegin, lLastAddress - lDirectoryBegin ); @@ -587,7 +587,7 @@ FF_Error_t FF_FormatDisk( FF_Disk_t * pxDisk, { if( xPartitionNumber >= xSet.xPartitionsFound.iCount ) { - xReturn = FF_ERR_IOMAN_INVALID_PARTITION_NUM | FF_MODULE_FORMAT; + xReturn = FF_createERR( FF_ERR_IOMAN_INVALID_PARTITION_NUM, FF_MODULE_FORMAT ); break; } @@ -617,10 +617,10 @@ FF_Error_t FF_FormatDisk( FF_Disk_t * pxDisk, xSet.pxIOManager->xPartition.ulBeginLBA = xSet.pxMyPartition->ulStartLBA; /* TODO: Find some solution here to get a unique disk ID */ - xSet.ulVolumeID = ( rand() << 16 ) | rand(); /*_RB_ rand() has proven problematic in some environments. */ + xSet.ulVolumeID = ( ( uint32_t ) rand() << 16 ) | ( uint32_t ) rand(); /*_RB_ rand() has proven problematic in some environments. */ /* Sectors within partition which can not be used */ - xSet.ulNonDataSectors = xSet.ulFATReservedSectors + xSet.iFAT16RootSectors; + xSet.ulNonDataSectors = xSet.ulFATReservedSectors + ( uint32_t ) xSet.iFAT16RootSectors; /* A fs dependent constant: */ if( xSet.ucFATType == FF_T_FAT32 ) @@ -665,7 +665,7 @@ FF_Error_t FF_FormatDisk( FF_Disk_t * pxDisk, if( xSet.pucSectorBuffer == NULL ) { - xReturn = FF_ERR_NOT_ENOUGH_MEMORY | FF_MODULE_FORMAT; + xReturn = FF_createERR( FF_ERR_NOT_ENOUGH_MEMORY, FF_MODULE_FORMAT ); break; } @@ -700,7 +700,7 @@ FF_Error_t FF_FormatDisk( FF_Disk_t * pxDisk, } /*****************************/ - lFatBeginLBA = xSet.ulHiddenSectors + xSet.ulFATReservedSectors; + lFatBeginLBA = ( int32_t ) ( xSet.ulHiddenSectors + xSet.ulFATReservedSectors ); /* Initialise the FAT. */ xReturn = prvFormatInitialiseFAT( &( xSet ), lFatBeginLBA ); @@ -711,22 +711,22 @@ FF_Error_t FF_FormatDisk( FF_Disk_t * pxDisk, } /*****************************/ - lDirectoryBegin = lFatBeginLBA + ( 2 * xSet.ulSectorsPerFAT ); + lDirectoryBegin = lFatBeginLBA + ( int32_t ) ( 2 * xSet.ulSectorsPerFAT ); #if ( ffconfigTIME_SUPPORT != 0 ) { FF_SystemTime_t str_t; - int16_t myShort; + uint16_t myShort; FF_GetSystemTime( &str_t ); - myShort = ( ( str_t.Hour << 11 ) & 0xF800 ) | - ( ( str_t.Minute << 5 ) & 0x07E0 ) | - ( ( str_t.Second / 2 ) & 0x001F ); + myShort = ( ( uint16_t ) ( str_t.Hour << 11U ) & 0xF800U ) | + ( ( uint16_t ) ( str_t.Minute << 5U ) & 0x07E0U ) | + ( ( uint16_t ) ( str_t.Second / 2U ) & 0x001FU ); FF_putShort( xSet.pucSectorBuffer, 22, ( uint32_t ) myShort ); - myShort = ( ( ( str_t.Year - 1980 ) << 9 ) & 0xFE00 ) | - ( ( str_t.Month << 5 ) & 0x01E0 ) | - ( str_t.Day & 0x001F ); + myShort = ( ( uint16_t ) ( ( str_t.Year - 1980 ) << 9U ) & 0xFE00U ) | + ( ( uint16_t ) ( str_t.Month << 5U ) & 0x01E0U ) | + ( ( uint16_t ) ( str_t.Day & 0x001FU ) ); FF_putShort( xSet.pucSectorBuffer, 24, ( uint32_t ) myShort ); } #endif /* ffconfigTIME_SUPPORT */ @@ -964,7 +964,7 @@ FF_Error_t FF_Partition( FF_Disk_t * pxDisk, pParams->xSizes[ 0 ] = 100; } - ulSummedSizes = pParams->xSizes[ 0 ]; + ulSummedSizes = ( uint32_t ) pParams->xSizes[ 0 ]; } /* Correct PrimaryCount if necessary. */ @@ -983,7 +983,7 @@ FF_Error_t FF_Partition( FF_Disk_t * pxDisk, pParams->ulHiddenSectors = 4096; } - ulReservedSpace = xSet.ulInterSpace * ( xSet.xPartitionCount - pParams->xPrimaryCount ); + ulReservedSpace = xSet.ulInterSpace * ( uint32_t ) ( xSet.xPartitionCount - pParams->xPrimaryCount ); } else { @@ -1008,7 +1008,7 @@ FF_Error_t FF_Partition( FF_Disk_t * pxDisk, if( ulSummedSizes > 100 ) { - return FF_FORMATPARTITION | FF_ERR_IOMAN_BAD_MEMSIZE; + return ( FF_Error_t ) ( FF_FORMATPARTITION | FF_ERR_IOMAN_BAD_MEMSIZE ); } ulSummedSizes = 100; @@ -1018,7 +1018,7 @@ FF_Error_t FF_Partition( FF_Disk_t * pxDisk, if( ulSummedSizes > ulAvailable ) { - return FF_FORMATPARTITION | FF_ERR_IOMAN_BAD_MEMSIZE; + return ( FF_Error_t ) ( FF_FORMATPARTITION | FF_ERR_IOMAN_BAD_MEMSIZE ); } break; @@ -1045,7 +1045,7 @@ FF_Error_t FF_Partition( FF_Disk_t * pxDisk, case eSizeIsSectors: /* Assign fixed number of sectors (512 byte each) */ default: /* Just for the compiler(s) */ - ulSize = pParams->xSizes[ xPartitionNumber ]; + ulSize = ( uint32_t ) pParams->xSizes[ xPartitionNumber ]; break; } diff --git a/ff_ioman.c b/ff_ioman.c index c26cdff..276904f 100755 --- a/ff_ioman.c +++ b/ff_ioman.c @@ -76,18 +76,14 @@ static BaseType_t prvHasActiveHandles( FF_IOManager_t * pxIOManager ); /** - * @public * @brief Creates an FF_IOManager_t object, to initialise FreeRTOS+FAT * - * @param pucCacheMem Pointer to a buffer for the cache. (NULL if ok to Malloc). - * @param ulCacheSize The size of the provided buffer, or size of the cache to be created. - * (Must be at least 2 * ulSectorSize). Always a multiple of ulSectorSize. - * @param usSectorSize The block size of devices to be attached. If in doubt use 512. + * @param pxParameters The Creation parameters to create the IO manager with * @param pError Pointer to a signed byte for error checking. Can be NULL if not required. * To be checked when a NULL pointer is returned. * - * @Return Returns a pointer to an FF_IOManager_t type object. NULL on xError, check the contents of - * @Return pError + * @return Returns a pointer to an FF_IOManager_t type object. NULL on xError, check the contents of + pError **/ FF_IOManager_t * FF_CreateIOManger( FF_CreationParameters_t * pxParameters, FF_Error_t * pError ) @@ -95,7 +91,7 @@ FF_IOManager_t * FF_CreateIOManger( FF_CreationParameters_t * pxParameters, FF_IOManager_t * pxIOManager = NULL; FF_Error_t xError; uint32_t ulCacheSize = pxParameters->ulMemorySize; - uint32_t usSectorSize = pxParameters->ulSectorSize; + uint32_t usSectorSize = ( uint32_t ) pxParameters->ulSectorSize; /* Normally: * ulSectorSize = 512 @@ -103,13 +99,13 @@ FF_IOManager_t * FF_CreateIOManger( FF_CreationParameters_t * pxParameters, if( ( ( usSectorSize % 512 ) != 0 ) || ( usSectorSize == 0 ) ) { /* ulSectorSize Size not a multiple of 512 or it is zero*/ - xError = FF_ERR_IOMAN_BAD_BLKSIZE | FF_CREATEIOMAN; + xError = FF_createERR( FF_ERR_IOMAN_BAD_BLKSIZE, FF_CREATEIOMAN ); } else if( ( ( ulCacheSize % ( uint32_t ) usSectorSize ) != 0 ) || ( ulCacheSize == 0 ) || ( ulCacheSize == ( uint32_t ) usSectorSize ) ) { /* The size of the caching memory (ulCacheSize) must now be atleast 2 * ulSectorSize (or a deadlock will occur). */ - xError = FF_ERR_IOMAN_BAD_MEMSIZE | FF_CREATEIOMAN; + xError = FF_createERR( FF_ERR_IOMAN_BAD_MEMSIZE, FF_CREATEIOMAN ); } else { @@ -128,13 +124,13 @@ FF_IOManager_t * FF_CreateIOManger( FF_CreationParameters_t * pxParameters, else { /* xEventGroupCreate() probably failed. */ - xError = FF_ERR_NOT_ENOUGH_MEMORY | FF_CREATEIOMAN; + xError = FF_createERR( FF_ERR_NOT_ENOUGH_MEMORY, FF_CREATEIOMAN ); } } else { /* ffconfigMALLOC() failed. */ - xError = FF_ERR_NOT_ENOUGH_MEMORY | FF_CREATEIOMAN; + xError = FF_createERR( FF_ERR_NOT_ENOUGH_MEMORY, FF_CREATEIOMAN ); } } @@ -158,7 +154,7 @@ FF_IOManager_t * FF_CreateIOManger( FF_CreationParameters_t * pxParameters, } else { - xError = FF_ERR_NOT_ENOUGH_MEMORY | FF_CREATEIOMAN; + xError = FF_createERR( FF_ERR_NOT_ENOUGH_MEMORY, FF_CREATEIOMAN ); } } @@ -170,7 +166,7 @@ FF_IOManager_t * FF_CreateIOManger( FF_CreationParameters_t * pxParameters, if( FF_isERR( xError ) == pdFALSE ) { - pxIOManager->usSectorSize = usSectorSize; + pxIOManager->usSectorSize = ( uint16_t ) usSectorSize; pxIOManager->usCacheSize = ( uint16_t ) ( ulCacheSize / ( uint32_t ) usSectorSize ); /* Malloc() memory for buffer objects. FreeRTOS+FAT never refers to a @@ -195,7 +191,7 @@ FF_IOManager_t * FF_CreateIOManger( FF_CreationParameters_t * pxParameters, if( pxIOManager->pvSemaphoreOpen == NULL ) { /* Tell the user that there was not enough mmory. */ - xError = FF_ERR_NOT_ENOUGH_MEMORY | FF_CREATEIOMAN; + xError = FF_createERR( FF_ERR_NOT_ENOUGH_MEMORY, FF_CREATEIOMAN); } else #endif /* ffconfigPROTECT_FF_FOPEN_WITH_SEMAPHORE */ @@ -212,7 +208,7 @@ FF_IOManager_t * FF_CreateIOManger( FF_CreationParameters_t * pxParameters, } else { - xError = FF_ERR_NOT_ENOUGH_MEMORY | FF_CREATEIOMAN; + xError = FF_createERR( FF_ERR_NOT_ENOUGH_MEMORY, FF_CREATEIOMAN ); } } @@ -235,12 +231,11 @@ FF_IOManager_t * FF_CreateIOManger( FF_CreationParameters_t * pxParameters, /*-----------------------------------------------------------*/ /** - * @public * @brief Destroys an FF_IOManager_t object, and frees all assigned memory. * * @param pxIOManager Pointer to an FF_IOManager_t object, as returned from FF_CreateIOManger. * - * @Return FF_ERR_NONE on sucess, or a documented error code on failure. (FF_ERR_NULL_POINTER) + * @return FF_ERR_NONE on sucess, or a documented error code on failure. (FF_ERR_NULL_POINTER) * **/ FF_Error_t FF_DeleteIOManager( FF_IOManager_t * pxIOManager ) @@ -250,7 +245,7 @@ FF_Error_t FF_DeleteIOManager( FF_IOManager_t * pxIOManager ) /* Ensure no NULL pointer was provided. */ if( pxIOManager == NULL ) { - xError = FF_ERR_NULL_POINTER | FF_DESTROYIOMAN; + xError = FF_createERR( FF_ERR_NULL_POINTER, FF_DESTROYIOMAN ); } else { @@ -290,7 +285,6 @@ FF_Error_t FF_DeleteIOManager( FF_IOManager_t * pxIOManager ) /*-----------------------------------------------------------*/ /** - * @private * @brief Initialises Buffer Descriptions as part of the FF_IOManager_t object initialisation. * * @param pxIOManager IOMAN Object. @@ -315,12 +309,11 @@ void FF_IOMAN_InitBufferDescriptors( FF_IOManager_t * pxIOManager ) /*-----------------------------------------------------------*/ /** - * @private * @brief Flushes all Write cache buffers with no active Handles. * * @param pxIOManager IOMAN Object. * - * @Return FF_ERR_NONE on Success. + * @return FF_ERR_NONE on Success. **/ FF_Error_t FF_FlushCache( FF_IOManager_t * pxIOManager ) { @@ -329,7 +322,7 @@ FF_Error_t FF_FlushCache( FF_IOManager_t * pxIOManager ) if( pxIOManager == NULL ) { - xError = FF_ERR_NULL_POINTER | FF_FLUSHCACHE; + xError = FF_createERR( FF_ERR_NULL_POINTER, FF_FLUSHCACHE ); } else { @@ -539,7 +532,6 @@ FF_Buffer_t * FF_GetBuffer( FF_IOManager_t * pxIOManager, /*-----------------------------------------------------------*/ /** - * @private * @brief Releases a buffer resource. * * @param pxIOManager Pointer to an FF_IOManager_t object. @@ -602,7 +594,7 @@ int32_t FF_BlockRead( FF_IOManager_t * pxIOManager, * In that case this test will be skipped. */ if( ( ulSectorLBA + ulNumSectors ) > ( pxIOManager->xPartition.ulTotalSectors + pxIOManager->xPartition.ulBeginLBA ) ) { - slRetVal = FF_ERR_IOMAN_OUT_OF_BOUNDS_READ | FF_BLOCKREAD; + slRetVal = FF_createERR( FF_ERR_IOMAN_OUT_OF_BOUNDS_READ, FF_BLOCKREAD ); } } @@ -655,7 +647,7 @@ int32_t FF_BlockWrite( FF_IOManager_t * pxIOManager, * In that case this test will be skipped. */ if( ( ulSectorLBA + ulNumSectors ) > ( pxIOManager->xPartition.ulTotalSectors + pxIOManager->xPartition.ulBeginLBA ) ) { - slRetVal = FF_ERR_IOMAN_OUT_OF_BOUNDS_WRITE | FF_BLOCKWRITE; + slRetVal = FF_createERR( FF_ERR_IOMAN_OUT_OF_BOUNDS_WRITE , FF_BLOCKWRITE ); } } @@ -698,7 +690,7 @@ int32_t FF_BlockWrite( FF_IOManager_t * pxIOManager, * It may be set to one of these values: FF_T_FAT[12,16,32] * just to force the driver to assume a certain FAT type. */ -uint8_t ucAssumeFATType; +static uint8_t ucAssumeFATType = 0; /* The history of FAT types: * The Microsoft documents says that the actual type: FAT-12, FAT-16 and FAT-32 @@ -755,7 +747,7 @@ static FF_Error_t prvDetermineFatType( FF_IOManager_t * pxIOManager ) if( pxBuffer == NULL ) { - xError = FF_ERR_DEVICE_DRIVER_FAILED | FF_DETERMINEFATTYPE; + xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_DETERMINEFATTYPE ); } else { @@ -774,7 +766,7 @@ static FF_Error_t prvDetermineFatType( FF_IOManager_t * pxIOManager ) #if ( ffconfigFAT_CHECK != 0 ) if( ( ulFirstWord & 0x3FF ) != 0x3F8 ) { - xError = FF_ERR_IOMAN_NOT_FAT_FORMATTED | FF_DETERMINEFATTYPE; + xError = FF_createERR( FF_ERR_IOMAN_NOT_FAT_FORMATTED, FF_DETERMINEFATTYPE); } else #endif /* ffconfigFAT_CHECK */ @@ -807,7 +799,7 @@ static FF_Error_t prvDetermineFatType( FF_IOManager_t * pxIOManager ) pxIOManager->xPartition.ulFATBeginLBA, ulFirstWord ); } - xError = FF_ERR_IOMAN_INVALID_FORMAT | FF_DETERMINEFATTYPE; + xError = FF_createERR( FF_ERR_IOMAN_INVALID_FORMAT, FF_DETERMINEFATTYPE ); } } #endif /* ffconfigFAT_CHECK */ @@ -896,10 +888,10 @@ void FF_ReadParts( uint8_t * pucBuffer, */ for( xPartNr = 0; xPartNr < 4; xPartNr++, uxOffset += 16, pxParts++ ) { - pxParts->ucActive = FF_getChar( pucBuffer, uxOffset + FF_FAT_PTBL_ACTIVE ); - pxParts->ucPartitionID = FF_getChar( pucBuffer, uxOffset + FF_FAT_PTBL_ID ); - pxParts->ulSectorCount = FF_getLong( pucBuffer, uxOffset + FF_FAT_PTBL_SECT_COUNT ); - pxParts->ulStartLBA = FF_getLong( pucBuffer, uxOffset + FF_FAT_PTBL_LBA ); + pxParts->ucActive = FF_getChar( pucBuffer, ( uint32_t ) ( uxOffset + FF_FAT_PTBL_ACTIVE ) ); + pxParts->ucPartitionID = FF_getChar( pucBuffer, ( uint32_t ) ( uxOffset + FF_FAT_PTBL_ID ) ); + pxParts->ulSectorCount = FF_getLong( pucBuffer, ( uint32_t ) ( uxOffset + FF_FAT_PTBL_SECT_COUNT ) ); + pxParts->ulStartLBA = FF_getLong( pucBuffer, ( uint32_t ) ( uxOffset + FF_FAT_PTBL_LBA ) ); } } /*-----------------------------------------------------------*/ @@ -952,7 +944,7 @@ static FF_Error_t FF_ParseExtended( FF_IOManager_t * pxIOManager, if( pxBuffer == NULL ) { - xError = FF_PARSEEXTENDED | FF_ERR_DEVICE_DRIVER_FAILED; /* | FUNCTION...; */ + xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_PARSEEXTENDED ); break; } } @@ -1063,15 +1055,14 @@ static FF_Error_t FF_ParseExtended( FF_IOManager_t * pxIOManager, /*-----------------------------------------------------------*/ /** - * @public * @brief Searches a disk for all primary and extended/logical partitions - * @brief Previously called FF_PartitionCount + * Previously called FF_PartitionCount * * @param pxIOManager FF_IOManager_t object. * @param pPartsFound Contains an array of ffconfigMAX_PARTITIONS partitions * - * @Return >=0 Number of partitions found - * @Return <0 error + * @return >=0 Number of partitions found + * <0 error **/ FF_Error_t FF_PartitionSearch( FF_IOManager_t * pxIOManager, FF_SPartFound_t * pPartsFound ) @@ -1092,7 +1083,7 @@ FF_Error_t FF_PartitionSearch( FF_IOManager_t * pxIOManager, if( pxBuffer == NULL ) { - xError = FF_ERR_DEVICE_DRIVER_FAILED | FF_PARTITIONSEARCH; + xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_PARTITIONSEARCH ); break; } @@ -1125,7 +1116,7 @@ FF_Error_t FF_PartitionSearch( FF_IOManager_t * pxIOManager, FF_getChar( ucDataBuffer, FF_FAT_MBR_SIGNATURE + 1 ) ); /* No MBR and no PBR then no partition found. */ - xError = FF_ERR_IOMAN_INVALID_FORMAT | FF_PARTITIONSEARCH; + xError = FF_createERR( FF_ERR_IOMAN_INVALID_FORMAT ,FF_PARTITIONSEARCH ); break; } } @@ -1157,7 +1148,7 @@ FF_Error_t FF_PartitionSearch( FF_IOManager_t * pxIOManager, } else { - xError = FF_ERR_IOMAN_INVALID_FORMAT | FF_PARTITIONSEARCH; + xError = FF_createERR( FF_ERR_IOMAN_INVALID_FORMAT, FF_PARTITIONSEARCH); break; } } @@ -1207,7 +1198,7 @@ FF_Error_t FF_PartitionSearch( FF_IOManager_t * pxIOManager, if( !prvIsValidMedia( media ) ) { FF_PRINTF( "FF_Part: Looks like PBR but media %02X\n", media ); - xError = FF_ERR_IOMAN_NO_MOUNTABLE_PARTITION | FF_PARTITIONSEARCH; + xError = FF_createERR( FF_ERR_IOMAN_NO_MOUNTABLE_PARTITION, FF_PARTITIONSEARCH); goto done; } @@ -1275,7 +1266,7 @@ static FF_Error_t FF_GetEfiPartitionEntry( FF_IOManager_t * pxIOManager, { if( ulPartitionNumber >= 128 ) { - xError = FF_ERR_IOMAN_INVALID_PARTITION_NUM | FF_GETEFIPARTITIONENTRY; + xError = FF_createERR( FF_ERR_IOMAN_INVALID_PARTITION_NUM, FF_GETEFIPARTITIONENTRY); break; } @@ -1283,7 +1274,7 @@ static FF_Error_t FF_GetEfiPartitionEntry( FF_IOManager_t * pxIOManager, if( pxBuffer == NULL ) { - xError = FF_ERR_DEVICE_DRIVER_FAILED | FF_GETEFIPARTITIONENTRY; + xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_GETEFIPARTITIONENTRY); break; } @@ -1295,7 +1286,7 @@ static FF_Error_t FF_GetEfiPartitionEntry( FF_IOManager_t * pxIOManager, if( FF_isERR( xError ) == pdFALSE ) { - xError = FF_ERR_IOMAN_INVALID_FORMAT | FF_GETEFIPARTITIONENTRY; + xError = FF_createERR( FF_ERR_IOMAN_INVALID_FORMAT, FF_GETEFIPARTITIONENTRY); } break; @@ -1326,7 +1317,7 @@ static FF_Error_t FF_GetEfiPartitionEntry( FF_IOManager_t * pxIOManager, /* Check CRC */ if( ulGPTHeadCRC != ulGPTCrcCheck ) { - xError = FF_ERR_IOMAN_GPT_HEADER_CORRUPT | FF_GETEFIPARTITIONENTRY; + xError = FF_createERR( FF_ERR_IOMAN_GPT_HEADER_CORRUPT, FF_GETEFIPARTITIONENTRY); break; } @@ -1338,7 +1329,7 @@ static FF_Error_t FF_GetEfiPartitionEntry( FF_IOManager_t * pxIOManager, { if( pxBuffer == NULL ) { - xError = FF_ERR_DEVICE_DRIVER_FAILED | FF_GETEFIPARTITIONENTRY; + xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_GETEFIPARTITIONENTRY); break; } @@ -1351,7 +1342,7 @@ static FF_Error_t FF_GetEfiPartitionEntry( FF_IOManager_t * pxIOManager, { if( pxPartition->ulBeginLBA == 0ul ) { - xError = FF_ERR_IOMAN_INVALID_PARTITION_NUM | FF_GETEFIPARTITIONENTRY; + xError = FF_createERR( FF_ERR_IOMAN_INVALID_PARTITION_NUM, FF_GETEFIPARTITIONENTRY); } } } @@ -1362,24 +1353,23 @@ static FF_Error_t FF_GetEfiPartitionEntry( FF_IOManager_t * pxIOManager, /*-----------------------------------------------------------*/ /** - * @public * @brief Mounts the Specified partition, the volume specified by the FF_IOManager_t object provided. * * The device drivers must adhere to the specification provided by * FF_WriteBlocks_t and FF_ReadBlocks_t. * - * @param pxIOManager FF_IOManager_t object. - * @param PartitionNumber The primary or logical partition number to be mounted, + * @param pxDisk Disk instance. + * @param xPartitionNumber The primary or logical partition number to be mounted, * ranging between 0 and ffconfigMAX_PARTITIONS-1 (normally 0) * Note that FF_PartitionSearch can be called in advance to * enumerate all available partitions * - * @Return 0 on success. - * @Return FF_ERR_NULL_POINTER if a pxIOManager object wasn't provided. - * @Return FF_ERR_IOMAN_INVALID_PARTITION_NUM if the partition number is out of range. - * @Return FF_ERR_IOMAN_NO_MOUNTABLE_PARTITION if no partition was found. - * @Return FF_ERR_IOMAN_INVALID_FORMAT if the master boot record or partition boot block didn't provide sensible data. - * @Return FF_ERR_IOMAN_NOT_FAT_FORMATTED if the volume or partition couldn't be determined to be FAT. (@see FreeRTOSFATConfig.h) + * @return 0 on success. + * FF_ERR_NULL_POINTER if a pxIOManager object wasn't provided. + * FF_ERR_IOMAN_INVALID_PARTITION_NUM if the partition number is out of range. + * FF_ERR_IOMAN_NO_MOUNTABLE_PARTITION if no partition was found. + * FF_ERR_IOMAN_INVALID_FORMAT if the master boot record or partition boot block didn't provide sensible data. + * FF_ERR_IOMAN_NOT_FAT_FORMATTED if the volume or partition couldn't be determined to be FAT. (@see FreeRTOSFATConfig.h) * **/ FF_Error_t FF_Mount( FF_Disk_t * pxDisk, @@ -1388,7 +1378,7 @@ FF_Error_t FF_Mount( FF_Disk_t * pxDisk, FF_Partition_t * pxPartition; FF_Buffer_t * pxBuffer = 0; FF_Error_t xError = FF_ERR_NONE; - int16_t rootEntryCount; + uint16_t rootEntryCount; FF_IOManager_t * pxIOManager = pxDisk->pxIOManager; /* HT TODO: find a method to safely determine the FAT type: 32/16/12 */ @@ -1407,7 +1397,7 @@ FF_Error_t FF_Mount( FF_Disk_t * pxDisk, { if( pxIOManager == NULL ) { - xError = FF_ERR_NULL_POINTER | FF_MOUNT; + xError = FF_createERR( FF_ERR_NULL_POINTER, FF_MOUNT); break; } @@ -1451,13 +1441,13 @@ FF_Error_t FF_Mount( FF_Disk_t * pxDisk, if( xPartitionCount == 0 ) { - xError = FF_ERR_IOMAN_NO_MOUNTABLE_PARTITION | FF_MOUNT; + xError = FF_createERR( FF_ERR_IOMAN_NO_MOUNTABLE_PARTITION, FF_MOUNT); break; } if( xPartitionNumber >= xPartitionCount ) { - xError = FF_ERR_IOMAN_INVALID_PARTITION_NUM | FF_MOUNT; + xError = FF_createERR( FF_ERR_IOMAN_INVALID_PARTITION_NUM, FF_MOUNT); break; } @@ -1467,7 +1457,7 @@ FF_Error_t FF_Mount( FF_Disk_t * pxDisk, if( pxMyPartition->ucPartitionID == 0xEE ) { - xError = FF_GetEfiPartitionEntry( pxIOManager, xPartitionNumber ); + xError = FF_GetEfiPartitionEntry( pxIOManager, ( uint32_t ) xPartitionNumber ); if( FF_isERR( xError ) ) { @@ -1480,7 +1470,7 @@ FF_Error_t FF_Mount( FF_Disk_t * pxDisk, if( pxBuffer == NULL ) { - xError = FF_ERR_DEVICE_DRIVER_FAILED | FF_MOUNT; + xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_MOUNT); break; } @@ -1493,7 +1483,7 @@ FF_Error_t FF_Mount( FF_Disk_t * pxDisk, if( FF_isERR( xError ) == pdFALSE ) { - xError = FF_ERR_IOMAN_INVALID_FORMAT | FF_MOUNT; + xError = FF_createERR( FF_ERR_IOMAN_INVALID_FORMAT, FF_MOUNT); } break; @@ -1539,12 +1529,12 @@ FF_Error_t FF_Mount( FF_Disk_t * pxDisk, if( pxPartition->usBlkSize == 0 ) { - xError = FF_ERR_IOMAN_INVALID_FORMAT | FF_MOUNT; + xError = FF_createERR( FF_ERR_IOMAN_INVALID_FORMAT, FF_MOUNT); break; } - rootEntryCount = FF_getShort( pxBuffer->pucBuffer, FF_FAT_ROOT_ENTRY_COUNT ); - pxPartition->ulRootDirSectors = ( ( rootEntryCount * 32 ) + pxPartition->usBlkSize - 1 ) / pxPartition->usBlkSize; + rootEntryCount = FF_getShort( pxBuffer->pucBuffer, ( uint32_t ) FF_FAT_ROOT_ENTRY_COUNT ); + pxPartition->ulRootDirSectors = ( uint32_t ) ( ( ( rootEntryCount * 32 ) + pxPartition->usBlkSize - 1 ) / pxPartition->usBlkSize ); pxPartition->ulFirstDataSector = pxPartition->ulClusterBeginLBA + pxPartition->ulRootDirSectors; pxPartition->ulDataSectors = pxPartition->ulTotalSectors - ( pxPartition->usReservedSectors + ( pxPartition->ucNumFATS * pxPartition->ulSectorsPerFAT ) + pxPartition->ulRootDirSectors ); @@ -1562,7 +1552,7 @@ FF_Error_t FF_Mount( FF_Disk_t * pxDisk, */ if( pxPartition->ulSectorsPerCluster == 0 ) { - xError = FF_ERR_IOMAN_INVALID_FORMAT | FF_MOUNT; + xError = FF_createERR( FF_ERR_IOMAN_INVALID_FORMAT, FF_MOUNT); break; } @@ -1629,12 +1619,11 @@ FF_Error_t FF_Mount( FF_Disk_t * pxDisk, /*-----------------------------------------------------------*/ /** - * @private * @brief Checks the cache for Active Handles * * @param pxIOManager FF_IOManager_t Object. * - * @Return pdTRUE if an active handle is found, else pdFALSE. + * @return pdTRUE if an active handle is found, else pdFALSE. * * @pre This function must be wrapped with the cache handling semaphore. **/ @@ -1666,12 +1655,11 @@ static BaseType_t prvHasActiveHandles( FF_IOManager_t * pxIOManager ) /*-----------------------------------------------------------*/ /** - * @public * @brief Unmounts the active partition. * - * @param pxIOManager FF_IOManager_t Object. + * @param pxDisk Disk instance. * - * @Return FF_ERR_NONE on success. + * @return FF_ERR_NONE on success. **/ FF_Error_t FF_Unmount( FF_Disk_t * pxDisk ) { @@ -1685,7 +1673,7 @@ FF_Error_t FF_Unmount( FF_Disk_t * pxDisk ) if( pxDisk->pxIOManager == NULL ) { - xError = FF_ERR_NULL_POINTER | FF_UNMOUNT; + xError = FF_createERR( FF_ERR_NULL_POINTER, FF_UNMOUNT); } else if( pxDisk->pxIOManager->xPartition.ucPartitionMounted == 0 ) { @@ -1699,12 +1687,12 @@ FF_Error_t FF_Unmount( FF_Disk_t * pxDisk ) if( prvHasActiveHandles( pxIOManager ) != 0 ) { /* Active handles found on the cache. */ - xError = FF_ERR_IOMAN_ACTIVE_HANDLES | FF_UNMOUNT; + xError = FF_createERR( FF_ERR_IOMAN_ACTIVE_HANDLES, FF_UNMOUNT); } else if( pxIOManager->FirstFile != NULL ) { /* Open files in this partition. */ - xError = FF_ERR_IOMAN_ACTIVE_HANDLES | FF_UNMOUNT; + xError = FF_createERR( FF_ERR_IOMAN_ACTIVE_HANDLES, FF_UNMOUNT); } else { @@ -1729,7 +1717,7 @@ FF_Error_t FF_Unmount( FF_Disk_t * pxDisk ) if( !pxBuffer ) { - xError = FF_ERR_DEVICE_DRIVER_FAILED | FF_UNMOUNT; + xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_UNMOUNT); break; } @@ -1820,7 +1808,7 @@ FF_Error_t FF_IncreaseFreeClusters( FF_IOManager_t * pxIOManager, if( pxBuffer == NULL ) { - xError = FF_ERR_DEVICE_DRIVER_FAILED | FF_INCREASEFREECLUSTERS; + xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_INCREASEFREECLUSTERS); } else { @@ -1894,7 +1882,7 @@ FF_Error_t FF_DecreaseFreeClusters( FF_IOManager_t * pxIOManager, if( pxBuffer == NULL ) { - xError = FF_ERR_DEVICE_DRIVER_FAILED | FF_DECREASEFREECLUSTERS; + xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_DECREASEFREECLUSTERS); } else { @@ -1927,8 +1915,8 @@ FF_Error_t FF_DecreaseFreeClusters( FF_IOManager_t * pxIOManager, * * @param pxIOManager FF_IOManager_t Object returned from FF_CreateIOManger() * - * @Return The blocksize of the partition. A value less than 0 when an error occurs. - * @Return Any negative value can be cast to the FF_Error_t type. + * @return The blocksize of the partition. A value less than 0 when an error occurs. + * Any negative value can be cast to the FF_Error_t type. **/ int32_t FF_GetPartitionBlockSize( FF_IOManager_t * pxIOManager ) { @@ -1940,7 +1928,7 @@ int32_t FF_GetPartitionBlockSize( FF_IOManager_t * pxIOManager ) } else { - lReturn = FF_ERR_NULL_POINTER | FF_GETPARTITIONBLOCKSIZE; + lReturn = FF_createERR( FF_ERR_NULL_POINTER, FF_GETPARTITIONBLOCKSIZE ); } return lReturn; @@ -1954,7 +1942,7 @@ int32_t FF_GetPartitionBlockSize( FF_IOManager_t * pxIOManager ) * * @param pxIOManager FF_IOManager_t Object returned from FF_CreateIOManger() * - * @Return The total number of bytes that the mounted partition or volume contains. + * @return The total number of bytes that the mounted partition or volume contains. * **/ uint64_t FF_GetVolumeSize( FF_IOManager_t * pxIOManager ) diff --git a/ff_stdio.c b/ff_stdio.c index 505827e..8b61266 100755 --- a/ff_stdio.c +++ b/ff_stdio.c @@ -72,7 +72,7 @@ int prvFFErrorToErrno( FF_Error_t xError ); * Generate a time stamp for the file. */ #if ( ffconfigTIME_SUPPORT == 1 ) - static uint32_t prvFileTime( FF_SystemTime_t * pxTime ); + static time_t prvFileTime( FF_SystemTime_t * pxTime ); #endif #if ( ffconfigHAS_CWD == 1 ) @@ -230,12 +230,12 @@ int ff_fseek( FF_FILE * pxStream, #if ( ffconfigDEV_SUPPORT != 0 ) if( pxStream->pxDevNode != NULL ) { - xError = FF_Device_Seek( pxStream, lOffset, iWhence ); + xError = FF_Device_Seek( pxStream, ( int32_t ) lOffset, iWhence ); } else #endif { - xError = FF_Seek( pxStream, lOffset, iWhence ); + xError = FF_Seek( pxStream, ( int32_t ) lOffset, iWhence ); } ff_errno = prvFFErrorToErrno( xError ); @@ -350,7 +350,7 @@ size_t ff_fread( void * pvBuffer, else #endif { - iReturned = FF_Read( pxStream, xSize, xItems, ( uint8_t * ) pvBuffer ); + iReturned = FF_Read( pxStream, ( uint32_t ) xSize, ( uint32_t ) xItems, ( uint8_t * ) pvBuffer ); } ff_errno = prvFFErrorToErrno( iReturned ); @@ -391,7 +391,7 @@ size_t ff_fwrite( const void * pvBuffer, else #endif { - iReturned = FF_Write( pxStream, xSize, xItems, ( uint8_t * ) pvBuffer ); + iReturned = FF_Write( pxStream, ( uint32_t ) xSize, ( uint32_t ) xItems, ( uint8_t * ) pvBuffer ); } ff_errno = prvFFErrorToErrno( iReturned ); @@ -509,7 +509,7 @@ char * ff_fgets( char * pcBuffer, int32_t xResult; int ff_errno; - xResult = FF_GetLine( pxStream, ( char * ) pcBuffer, xCount ); + xResult = FF_GetLine( pxStream, ( char * ) pcBuffer, ( uint32_t ) xCount ); /* This call seems to result in errno being incorrectly set to * FF_ERR_IOMAN_NO_MOUNTABLE_PARTITION when an EOF is encountered. */ @@ -582,7 +582,7 @@ FF_FILE * ff_truncate( const char * pcFileName, else if( ulLength > ( uint32_t ) lTruncateSize ) { /* Seek the desired position */ - xResult = FF_Seek( pxStream, lTruncateSize, FF_SEEK_SET ); + xResult = FF_Seek( pxStream, ( int32_t ) lTruncateSize, FF_SEEK_SET ); /* Make the current position equal to its length */ if( FF_isERR( xResult ) == pdFALSE ) @@ -1076,7 +1076,7 @@ int ff_stat( const char * pcName, FF_CreateShortName( &xFindParams, pcFileName ); /* Lookup the path and find the cluster pointing to the directory: */ - xFindParams.ulDirCluster = FF_FindDir( xHandler.pxManager, pcName, xIndex, &xError ); + xFindParams.ulDirCluster = FF_FindDir( xHandler.pxManager, pcName, ( uint16_t ) xIndex, &xError ); } if( FF_isERR( xError ) == pdFALSE ) @@ -1103,7 +1103,7 @@ int ff_stat( const char * pcName, /* Test 'ulFileCluster' again, it might have been changed. */ if( ulFileCluster == 0ul ) { - xError = FF_ERR_FILE_NOT_FOUND | FF_STAT_FUNC; + xError = FF_createERR( FF_ERR_FILE_NOT_FOUND, FF_STAT_FUNC ); } } @@ -1133,13 +1133,13 @@ int ff_stat( const char * pcName, * if xDirEntry has not been initialised. */ pxStatBuffer->st_size = xDirEntry.ulFileSize; pxStatBuffer->st_ino = xDirEntry.ulObjectCluster; - pxStatBuffer->st_dev = ( short ) xHandler.xFSIndex; + pxStatBuffer->st_dev = ( uint16_t ) xHandler.xFSIndex; #if ( ffconfigTIME_SUPPORT == 1 ) { - pxStatBuffer->st_atime = ( unsigned long ) prvFileTime( &( xDirEntry.xAccessedTime ) ); - pxStatBuffer->st_mtime = ( unsigned long ) prvFileTime( &( xDirEntry.xModifiedTime ) ); - pxStatBuffer->st_ctime = ( unsigned long ) prvFileTime( &( xDirEntry.xCreateTime ) ); + pxStatBuffer->st_atime = prvFileTime( &( xDirEntry.xAccessedTime ) ); + pxStatBuffer->st_mtime = prvFileTime( &( xDirEntry.xModifiedTime ) ); + pxStatBuffer->st_ctime = prvFileTime( &( xDirEntry.xCreateTime ) ); } #endif } @@ -1188,7 +1188,7 @@ int ff_stat( const char * pcName, { /* The CWD will be stored without a trailing '/'. If "/" * happens to be the CWD, it will be stored as an empty string. */ - iLength = strlen( pcDirectoryName ); + iLength = ( int ) strlen( pcDirectoryName ); /* Knock off the trailing / if one exits - being careful not to * remove the trailing slash if this is the root directory. */ @@ -1432,7 +1432,7 @@ int ff_findnext( FF_FindData_t * pxFindData ) int found; pxFindData->xDirectoryHandler.xFSIndex--; - found = FF_FS_Get( pxFindData->xDirectoryHandler.xFSIndex, &xSubSystem ); + found = FF_FS_Get( ( int ) pxFindData->xDirectoryHandler.xFSIndex, &xSubSystem ); if( ( found == pdFALSE ) || ( xSubSystem.pcPath[ 1 ] == '\0' ) ) { @@ -1535,11 +1535,11 @@ int ff_isdirempty( const char * pcPath ) /* Find the i/o manager which can handle this path */ if( FF_FS_Find( pcPath, &xHandler ) == pdFALSE ) { - iResult = ( int ) ( FF_ERR_NULL_POINTER | FF_ISDIREMPTY ); + iResult = ( int ) FF_createERR( FF_ERR_NULL_POINTER, FF_ISDIREMPTY ); } else { - iResult = FF_isDirEmpty( xHandler.pxManager, xHandler.pcPath ); + iResult = ( int ) FF_isDirEmpty( xHandler.pxManager, xHandler.pcPath ); } /* Store the errno to thread local storage. */ @@ -2165,10 +2165,9 @@ int prvFFErrorToErrno( FF_Error_t xError ) #if ( ffconfigTIME_SUPPORT == 1 ) - static uint32_t prvFileTime( FF_SystemTime_t * pxTime ) + time_t prvFileTime( FF_SystemTime_t * pxTime ) { FF_TimeStruct_t xTime; - time_t xReturn; xTime.tm_sec = pxTime->Second; xTime.tm_min = pxTime->Minute; @@ -2177,9 +2176,7 @@ int prvFFErrorToErrno( FF_Error_t xError ) xTime.tm_mon = pxTime->Month - 1; xTime.tm_year = pxTime->Year - 1900; - xReturn = FreeRTOS_mktime( &xTime ); - - return xReturn; + return FreeRTOS_mktime( &xTime ); } #endif /* if ( ffconfigTIME_SUPPORT == 1 ) */ diff --git a/ff_string.c b/ff_string.c index 935d0cf..430c705 100755 --- a/ff_string.c +++ b/ff_string.c @@ -196,7 +196,7 @@ if( xLength == 0 ) { - xLength = strlen( str1 ); + xLength = (BaseType_t) strlen( str1 ); if( xLength != ( BaseType_t ) strlen( str2 ) ) { diff --git a/ff_sys.c b/ff_sys.c index a9c03dc..62406c0 100755 --- a/ff_sys.c +++ b/ff_sys.c @@ -143,7 +143,7 @@ int FF_FS_Add( const char * pcPath, iReturn = pdTRUE; strncpy( file_systems.xSystems[ xUseIndex ].pcPath, pcPath, sizeof( file_systems.xSystems[ xUseIndex ].pcPath ) - 1 ); file_systems.xSystems[ xUseIndex ].pcPath[ sizeof( file_systems.xSystems[ xUseIndex ].pcPath ) - 1 ] = 0; - file_systems.xSystems[ xUseIndex ].xPathlen = uxPathLength; + file_systems.xSystems[ xUseIndex ].xPathlen = ( BaseType_t ) uxPathLength; file_systems.xSystems[ xUseIndex ].pxManager = pxDisk->pxIOManager; } } diff --git a/ff_time.c b/ff_time.c index d3b81db..11ab20e 100755 --- a/ff_time.c +++ b/ff_time.c @@ -46,7 +46,6 @@ #if ( ffconfigTIME_SUPPORT != 0 ) /* This if-block spans the rest of the source file. */ /** - * @public * @brief Populates an FF_SystemTime_t object with the current time from the system. * * The developer must modify this function so that it is suitable for their platform. @@ -68,12 +67,12 @@ /* Fill the fields in 'xTimeStruct'. */ FreeRTOS_gmtime_r( &secs, &xTimeStruct ); - pxTime->Hour = xTimeStruct.tm_hour; - pxTime->Minute = xTimeStruct.tm_min; - pxTime->Second = xTimeStruct.tm_sec; - pxTime->Day = xTimeStruct.tm_mday; - pxTime->Month = xTimeStruct.tm_mon + 1; - pxTime->Year = xTimeStruct.tm_year + 1900; + pxTime->Hour = ( uint16_t ) xTimeStruct.tm_hour; + pxTime->Minute = ( uint16_t ) xTimeStruct.tm_min; + pxTime->Second = ( uint16_t ) xTimeStruct.tm_sec; + pxTime->Day = ( uint16_t ) xTimeStruct.tm_mday; + pxTime->Month = ( uint16_t ) xTimeStruct.tm_mon + 1; + pxTime->Year = ( uint16_t ) xTimeStruct.tm_year + 1900; return 0; } /* FF_GetSystemTime() */ @@ -105,8 +104,8 @@ #define WEEK_DAY_SATURDAY 6 /* Make a bitmask with a '1' for each 31-day month. */ - #define _MM( month ) ( 1u << ( month - 1 ) ) - #define MASK_LONG_MONTHS ( _MM( 1 ) | _MM( 3 ) | _MM( 5 ) | _MM( 7 ) | _MM( 8 ) | _MM( 10 ) | _MM( 12 ) ) + #define MM_( month ) ( 1u << ( month - 1 ) ) + #define MASK_LONG_MONTHS ( MM_( 1 ) | MM_( 3 ) | MM_( 5 ) | MM_( 7 ) | MM_( 8 ) | MM_( 10 ) | MM_( 12 ) ) #define DAYS_UNTIL_1970 ( ( 1970 * 365 ) + ( 1970 / 4 ) - ( 1970 / 100 ) + ( 1970 / 400 ) ) #define DAYS_BEFORE_MARCH ( 59 ) @@ -141,7 +140,7 @@ static portINLINE unsigned long ulDaysPerYear( int iYear ) { - int iDays; + unsigned long iDays; if( iIsLeapyear( iYear ) ) { @@ -155,10 +154,10 @@ return iDays; } - static int iDaysPerMonth( int iYear, - int iMonth ) + static unsigned long iDaysPerMonth( int iYear, + int iMonth ) { - int iDays; + unsigned long iDays; /* Month is zero-based, 1 is February. */ if( iMonth != 1 ) @@ -205,7 +204,7 @@ ulDayNumber = ( unsigned long ) ( xTime / SECONDS_PER_DAY ); /* Today's HH:MM:SS */ - pxTimeBuf->tm_hour = ulDaySeconds / SECONDS_PER_HOUR; + pxTimeBuf->tm_hour = ( int ) ulDaySeconds / SECONDS_PER_HOUR; pxTimeBuf->tm_min = ( ulDaySeconds % SECONDS_PER_HOUR ) / 60; pxTimeBuf->tm_sec = ulDaySeconds % 60; @@ -230,7 +229,7 @@ pxTimeBuf->tm_year = iYear - TM_STRUCT_FIRST_YEAR; /* The day within this year. */ - pxTimeBuf->tm_yday = ulDayNumber; + pxTimeBuf->tm_yday = ( int ) ulDayNumber; /* Month are counted as 0..11 */ iMonth = 0; @@ -252,7 +251,7 @@ pxTimeBuf->tm_mon = iMonth; /* Month days are counted as 1..31 */ - pxTimeBuf->tm_mday = ulDayNumber + 1; + pxTimeBuf->tm_mday = ( int )ulDayNumber + 1; return pxTimeBuf; } @@ -263,10 +262,10 @@ int iYear = 1900 + pxTimeBuf->tm_year; /* 20xx */ /* Get month zero-based. */ int iMonth = pxTimeBuf->tm_mon; /* 0..11 */ - uint32_t ulDays; - uint32_t ulResult; + time_t ulDays; + time_t ulResult; - ulDays = pxTimeBuf->tm_mday - 1; /* 1..31 */ + ulDays = ( time_t ) ( pxTimeBuf->tm_mday - 1 ); /* 1..31 */ /* Make March the first month. */ iMonth -= 2; @@ -279,22 +278,22 @@ } /* Add the number of days past until this month. */ - ulDays += ( ( 306 * iMonth ) + 5 ) / 10; + ulDays += ( time_t ) ( ( ( 306 * iMonth ) + 5 ) / 10 ); /* Add days past before this year: */ ulDays += - +( iYear * 365 ) /* Every normal year. */ - + ( iYear / 4 ) /* Plus a day for every leap year. */ - - ( iYear / 100 ) /* Minus the centuries. */ - + ( iYear / 400 ) /* Except every fourth century. */ - - ( DAYS_UNTIL_1970 ) /* Minus the days before 1-1-1970 */ - + ( DAYS_BEFORE_MARCH ); /* Because 2 months were subtracted. */ + + ( time_t ) ( iYear * 365 ) /* Every normal year. */ + + ( time_t ) ( iYear / 4 ) /* Plus a day for every leap year. */ + - ( time_t ) ( iYear / 100 ) /* Minus the centuries. */ + + ( time_t ) ( iYear / 400 ) /* Except every fourth century. */ + - ( time_t ) ( DAYS_UNTIL_1970 ) /* Minus the days before 1-1-1970 */ + + ( time_t ) ( DAYS_BEFORE_MARCH ); /* Because 2 months were subtracted. */ ulResult = ( ulDays * SECONDS_PER_DAY ) + - ( pxTimeBuf->tm_hour * SECONDS_PER_HOUR ) + - ( pxTimeBuf->tm_min * SECONDS_PER_MINUTE ) + - pxTimeBuf->tm_sec; + ( time_t ) ( ( pxTimeBuf->tm_hour * SECONDS_PER_HOUR ) + + ( pxTimeBuf->tm_min * SECONDS_PER_MINUTE ) + + ( pxTimeBuf->tm_sec ) ); return ulResult; } diff --git a/include/ff_error.h b/include/ff_error.h index 8948706..0f8cf63 100755 --- a/include/ff_error.h +++ b/include/ff_error.h @@ -62,6 +62,7 @@ #define FF_GETMOD_FUNC( x ) ( ( ( ( unsigned ) x ) >> FF_FUNCTION_SHIFT ) & 0xFFFF ) #define FF_ERRFLAG 0x80000000 #define FF_isERR( x ) ( ( ( x ) & FF_ERRFLAG ) != 0 ) +#define FF_createERR( x, id ) ( ( FF_Error_t ) ( ( x ) | ( id ) ) ) /*----- FreeRTOS+FAT Module Identifiers */ #define FF_MODULE_IOMAN ( ( 1 << FF_MODULE_SHIFT ) | FF_ERRFLAG ) diff --git a/include/ff_stdio.h b/include/ff_stdio.h index 12af285..48bd9f9 100755 --- a/include/ff_stdio.h +++ b/include/ff_stdio.h @@ -87,10 +87,11 @@ uint16_t st_dev; /* The device on which the file can be found (see ff_sys.c) */ uint16_t st_mode; /* The mode (attribute bits) of this file or directory. */ + /* Note time_t must be used here otherwise will have bugs when 2032 (uint32_t second clock rolls over) */ #if ( ffconfigTIME_SUPPORT == 1 ) - uint32_t st_atime; - uint32_t st_mtime; - uint32_t st_ctime; + time_t st_atime; + time_t st_mtime; + time_t st_ctime; #endif /* ffconfigTIME_SUPPORT */ } FF_Stat_t; diff --git a/include/ff_string.h b/include/ff_string.h index 4dfbca2..21a068d 100755 --- a/include/ff_string.h +++ b/include/ff_string.h @@ -132,7 +132,7 @@ int32_t FF_Utf32stoUtf8s( uint8_t * Utf8String, #define STRNCPY( target, src, maxlen ) wcsncpy( ( target ), ( src ), ( maxlen ) ) #define STRLEN( string ) wcslen( ( string ) ) #else - #define STRNCPY( target, src, maxlen ) strncpy( ( target ), ( src ), ( maxlen ) ); + #define STRNCPY( target, src, maxlen ) strncpy( ( target ), ( src ), ( maxlen ) ) #define STRLEN( string ) strlen( ( string ) ) #endif From 3f8fb14670e17c17f6bcea9ad6399ab253d0a805 Mon Sep 17 00:00:00 2001 From: Paul Helter Date: Mon, 1 May 2023 19:50:57 +0000 Subject: [PATCH 11/12] Fixing error creation using FF_createERR everywhere missed. --- ff_dir.c | 4 ++-- ff_fat.c | 8 ++++---- ff_file.c | 20 ++++++++++---------- ff_format.c | 4 ++-- ff_stdio.c | 16 ++++++++-------- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/ff_dir.c b/ff_dir.c index a5fad23..30f18bc 100644 --- a/ff_dir.c +++ b/ff_dir.c @@ -794,7 +794,7 @@ static BaseType_t FF_ShortNameExists( FF_IOManager_t * pxIOManager, if( ( pcToken != NULL ) && ( ( FF_isERR( xError ) == pdFALSE ) || ( FF_GETERROR( xError ) == FF_ERR_DIR_END_OF_DIR ) ) ) { - xError = ( FF_Error_t ) ( FF_FINDDIR | FF_ERR_FILE_INVALID_PATH ); + xError = FF_createERR( FF_FINDDIR, FF_ERR_FILE_INVALID_PATH ); } #if ( ffconfigPATH_CACHE != 0 ) /* Update the PATH CACHE with a new PATH. */ @@ -1143,7 +1143,7 @@ static FF_Error_t FF_Traverse( FF_IOManager_t * pxIOManager, /* Check if we're past the last cluster ( ulChainLength is also valid for root sectors ). */ if( ( ulClusterNum + 1 ) > pxContext->ulChainLength ) { - xError = FF_ERR_DIR_END_OF_DIR | FF_TRAVERSE; /* End of Dir was reached! */ + xError = FF_createERR(FF_ERR_DIR_END_OF_DIR, FF_TRAVERSE); /* End of Dir was reached! */ } else if( ( pxIOManager->xPartition.ucType != FF_T_FAT32 ) && ( pxContext->ulDirCluster == pxIOManager->xPartition.ulRootDirCluster ) ) diff --git a/ff_fat.c b/ff_fat.c index c6ad160..1bb8f41 100755 --- a/ff_fat.c +++ b/ff_fat.c @@ -372,7 +372,7 @@ FF_Buffer_t * prvGetFromFATBuffers( FF_IOManager_t * pxIOManager, if( FF_isERR( xError ) ) { - xError = FF_GETERROR( xError ) | FF_GETFATENTRY; + xError = FF_CreateError(FF_GETERROR( xError ), FF_GETFATENTRY); } else { @@ -505,7 +505,7 @@ uint32_t FF_getFATEntry( FF_IOManager_t * pxIOManager, if( FF_isERR( xError ) ) { - xError = ( FF_Error_t ) ( FF_GETERROR( xError ) | FF_GETFATENTRY ); + xError = FF_createERR( FF_GETERROR( xError ), FF_GETFATENTRY ); } else { @@ -946,7 +946,7 @@ FF_Error_t FF_putFATEntry( FF_IOManager_t * pxIOManager, if( FF_isERR( xError ) ) { - xError = (FF_Error_t) ( FF_GETERROR( xError ) | FF_PUTFATENTRY ); + xError = FF_createERR( FF_GETERROR( xError ), FF_PUTFATENTRY ); break; } @@ -1055,7 +1055,7 @@ FF_Error_t FF_putFATEntry( FF_IOManager_t * pxIOManager, { /* There is no free cluster any more. */ ulCluster = 0; - xError = ( FF_Error_t ) ( FF_FINDFREECLUSTER | FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE ); + xError = FF_createERR( FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE, FF_FINDFREECLUSTER ); } *pxError = xError; diff --git a/ff_file.c b/ff_file.c index ae08f10..361f6a9 100644 --- a/ff_file.c +++ b/ff_file.c @@ -1134,11 +1134,11 @@ int32_t FF_BytesLeft( FF_FILE * pxFile ) if( pxFile == NULL ) { - xReturn = FF_ERR_NULL_POINTER | FF_BYTESLEFT; + xReturn = FF_createERR(FF_ERR_NULL_POINTER, FF_BYTESLEFT); } else if( ( pxFile->ucMode & FF_MODE_READ ) == 0 ) { - xReturn = FF_ERR_FILE_NOT_OPENED_IN_READ_MODE | FF_BYTESLEFT; + xReturn = FF_createERR(FF_ERR_FILE_NOT_OPENED_IN_READ_MODE, FF_BYTESLEFT); } else if( pxFile->ulFilePointer >= pxFile->ulFileSize ) { @@ -1149,7 +1149,7 @@ int32_t FF_BytesLeft( FF_FILE * pxFile ) xReturn = pxFile->ulFileSize - pxFile->ulFilePointer; } - return xReturn; + return (int32_t) xReturn; } /* FF_BytesLeft() */ /*-----------------------------------------------------------*/ @@ -1990,17 +1990,17 @@ int32_t FF_GetC( FF_FILE * pxFile ) if( pxFile == NULL ) { - xResult = FF_ERR_NULL_POINTER | FF_GETC; /* Ensure this is a signed error. */ + xResult = FF_createERR(FF_ERR_NULL_POINTER, FF_GETC); /* Ensure this is a signed error. */ } else if( ( pxFile->ucMode & FF_MODE_READ ) == 0 ) { - xResult = (FF_Error_t) ( FF_ERR_FILE_NOT_OPENED_IN_READ_MODE | FF_GETC ); + xResult = FF_createERR( FF_ERR_FILE_NOT_OPENED_IN_READ_MODE, FF_GETC ); } else if( pxFile->ulFilePointer >= pxFile->ulFileSize ) { /* The end-of-file is reached. The error READ_ZERO will not be * returned, it is just used to avoid further processing. */ - xResult = (FF_Error_t) ( FF_ERR_FILE_READ_ZERO | FF_READ ); + xResult = FF_createERR( FF_ERR_FILE_READ_ZERO, FF_READ ); } else { @@ -2483,7 +2483,7 @@ int32_t FF_PutC( FF_FILE * pxFile, if( pxFile == NULL ) { /* Ensure we don't have a Null file pointer on a Public interface. */ - xResult = FF_ERR_NULL_POINTER | FF_PUTC; + xResult = FF_createERR(FF_ERR_NULL_POINTER, FF_PUTC); } else if( ( pxFile->ucMode & FF_MODE_WRITE ) == 0 ) { @@ -2609,7 +2609,7 @@ FF_Error_t FF_Seek( FF_FILE * pxFile, } else { - xError = ( FF_Error_t ) ( FF_SEEK | FF_ERR_FILE_SEEK_INVALID_ORIGIN ); + xError = FF_createERR( FF_ERR_FILE_SEEK_INVALID_ORIGIN, FF_SEEK ); /* To supress a compiler warning. */ ulPosition = ( uint32_t ) 0u; } @@ -2626,7 +2626,7 @@ FF_Error_t FF_Seek( FF_FILE * pxFile, } else { - xError = ( FF_Error_t ) ( FF_SEEK | FF_ERR_FILE_SEEK_INVALID_POSITION ); + xError = FF_createERR( FF_ERR_FILE_SEEK_INVALID_POSITION, FF_SEEK ); } } } @@ -2769,7 +2769,7 @@ FF_Error_t FF_CheckValid( FF_FILE * pxFile ) { if( pxFile->ulValidFlags & FF_VALID_FLAG_DELETED ) { /*if (pxFile->FileDeleted) */ - xError = ( FF_Error_t ) ( FF_ERR_FILE_NOT_FOUND | FF_SETFILETIME ); + xError = FF_createERR( FF_ERR_FILE_NOT_FOUND, FF_SETFILETIME ); } else if( ( pxFile->ucMode & ( FF_MODE_WRITE | FF_MODE_APPEND ) ) == 0 ) { diff --git a/ff_format.c b/ff_format.c index 3c2c413..b90f494 100755 --- a/ff_format.c +++ b/ff_format.c @@ -1008,7 +1008,7 @@ FF_Error_t FF_Partition( FF_Disk_t * pxDisk, if( ulSummedSizes > 100 ) { - return ( FF_Error_t ) ( FF_FORMATPARTITION | FF_ERR_IOMAN_BAD_MEMSIZE ); + return FF_createERR ( FF_ERR_IOMAN_BAD_MEMSIZE, FF_FORMATPARTITION ); } ulSummedSizes = 100; @@ -1018,7 +1018,7 @@ FF_Error_t FF_Partition( FF_Disk_t * pxDisk, if( ulSummedSizes > ulAvailable ) { - return ( FF_Error_t ) ( FF_FORMATPARTITION | FF_ERR_IOMAN_BAD_MEMSIZE ); + return FF_createERR( FF_ERR_IOMAN_BAD_MEMSIZE, FF_FORMATPARTITION ); } break; diff --git a/ff_stdio.c b/ff_stdio.c index b9f0dac..97c806a 100644 --- a/ff_stdio.c +++ b/ff_stdio.c @@ -924,7 +924,7 @@ int ff_rename( const char * pcOldName, /* Find the i/o manager which can handle this path */ if( FF_FS_Find( pcOldName, &xHandlers[ 0 ] ) == pdFALSE ) { - xError = ( int32_t ) ( FF_ERR_NULL_POINTER | FF_MOVE ); + xError = FF_createERR( FF_ERR_NULL_POINTER, FF_MOVE ); ff_errno = pdFREERTOS_ERRNO_ENXIO; /* No such device or address */ } else @@ -938,7 +938,7 @@ int ff_rename( const char * pcOldName, { /* Could not allocate space to store a file name. */ ff_errno = pdFREERTOS_ERRNO_ENOMEM; - xError = ( int32_t ) ( FF_ERR_NOT_ENOUGH_MEMORY | FF_MOVE ); + xError = FF_createERR( FF_ERR_NOT_ENOUGH_MEMORY, FF_MOVE ); } else { @@ -960,12 +960,12 @@ int ff_rename( const char * pcOldName, /* Find the i/o manager which can handle this path */ if( FF_FS_Find( pcNewName, &( xHandlers[ 1 ] ) ) == pdFALSE ) { - xError = ( int32_t ) ( FF_ERR_NULL_POINTER | FF_MOVE ); + xError = FF_createERR( FF_ERR_NULL_POINTER, FF_MOVE ); ff_errno = pdFREERTOS_ERRNO_ENXIO; /* No such device or address */ } else if( xHandlers[ 0 ].pxManager != xHandlers[ 1 ].pxManager ) { - xError = ( int32_t ) ( FF_ERR_NULL_POINTER | FF_MOVE ); + xError = FF_createERR( FF_ERR_NULL_POINTER, FF_MOVE ); /* Cross-device link, which can not be done. */ ff_errno = pdFREERTOS_ERRNO_EXDEV; } @@ -1039,7 +1039,7 @@ int ff_stat( const char * pcName, if( FF_FS_Find( pcName, &xHandler ) == pdFALSE ) { /* No such device or address. */ - xError = ( FF_Error_t ) ( pdFREERTOS_ERRNO_ENXIO | FF_STAT_FUNC ); + xError = FF_createERR( pdFREERTOS_ERRNO_ENXIO, FF_STAT_FUNC ); } else { @@ -1300,7 +1300,7 @@ int ff_findfirst( const char * pcPath, { if( ( iIsRootDir == pdFALSE ) || ( FF_FS_Count() == 0 ) ) { - stdioSET_ERRNO( prvFFErrorToErrno( ( FF_Error_t ) ( FF_ERR_NULL_POINTER | FF_FINDFIRST ) ) ); + stdioSET_ERRNO( prvFFErrorToErrno( FF_createERR( FF_ERR_NULL_POINTER, FF_FINDFIRST ) ) ); iReturn = -1; } } @@ -1351,12 +1351,12 @@ int ff_findnext( FF_FindData_t * pxFindData ) if( pxFindData->xDirectoryHandler.u.bits.bIsValid == pdFALSE ) { - xError = ( FF_Error_t ) ( FF_ERR_DIR_INVALID_PARAMETER | FF_FINDNEXT ); + xError = FF_createERR( FF_ERR_DIR_INVALID_PARAMETER, FF_FINDNEXT ); FF_PRINTF( "ff_findnext: xDirectoryHandler not valid\n" ); } else { - xError = ( FF_Error_t ) ( FF_ERR_DIR_END_OF_DIR | FF_FINDNEXT ); + xError = FF_createERR( FF_ERR_DIR_END_OF_DIR, FF_FINDNEXT ); if( pxFindData->xDirectoryHandler.pxManager != NULL ) { From a4b67ec7f9b6be9433cf083aff9946ff9ad4da55 Mon Sep 17 00:00:00 2001 From: Paul Helter Date: Mon, 1 May 2023 20:14:37 +0000 Subject: [PATCH 12/12] Defaulting to MountFailIgnore = 1 instead of 0 --- portable/Zynq.2019.3/ff_sddisk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/portable/Zynq.2019.3/ff_sddisk.c b/portable/Zynq.2019.3/ff_sddisk.c index 595db55..8478699 100644 --- a/portable/Zynq.2019.3/ff_sddisk.c +++ b/portable/Zynq.2019.3/ff_sddisk.c @@ -433,7 +433,7 @@ static CacheMemoryInfo_t * pucGetSDIOCacheMemory( BaseType_t xPartition ) /*-----------------------------------------------------------*/ /* Initialise the SDIO driver and mount an SD card */ -BaseType_t xMountFailIgnore = 0; +BaseType_t xMountFailIgnore = 1; /* _HT_ : the function FF_SDDiskInit() used to mount partition-0. * It would be nice if it has a parameter indicating the partition