From 4d035478fc0e7db5d04fffaff19300d37bb8772a Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Tue, 5 Jul 2022 11:47:20 +0200 Subject: [PATCH 1/5] fix: typo found with codespell Signed-off-by: Frederic Pillon --- src/SD.cpp | 2 +- src/bsp_sd.h | 2 +- src/ffconf_default_32020.h | 2 +- src/ffconf_default_68300.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/SD.cpp b/src/SD.cpp index a1440dc..b175eb5 100644 --- a/src/SD.cpp +++ b/src/SD.cpp @@ -26,7 +26,7 @@ directories which simplifies interacting with files in subdirectories. * Utility methods are provided to determine whether a file exists - and to create a directory heirarchy. + and to create a directory hierarchy. */ diff --git a/src/bsp_sd.h b/src/bsp_sd.h index 9a75bd9..6c2d831 100644 --- a/src/bsp_sd.h +++ b/src/bsp_sd.h @@ -50,7 +50,7 @@ extern "C" { #endif #if !defined(STM32_CORE_VERSION) || (STM32_CORE_VERSION <= 0x01060100) #error "This library version required a STM32 core version > 1.6.1.\ -Please update the core or install previous libray version." +Please update the core or install previous library version." #endif /*SD Card information structure */ diff --git a/src/ffconf_default_32020.h b/src/ffconf_default_32020.h index 725a733..d65054d 100644 --- a/src/ffconf_default_32020.h +++ b/src/ffconf_default_32020.h @@ -179,7 +179,7 @@ / option to 1 and f_getfree() function at first time after volume mount will / force a full FAT scan. / -/ 0: Load all informations in the FSINFO if available. +/ 0: Load all information in the FSINFO if available. / 1: Do not trust free cluster count in the FSINFO. */ diff --git a/src/ffconf_default_68300.h b/src/ffconf_default_68300.h index 4ba019a..0e655b3 100644 --- a/src/ffconf_default_68300.h +++ b/src/ffconf_default_68300.h @@ -210,7 +210,7 @@ / number and only an FAT volume found on the physical drive will be mounted. / When multi-partition is enabled (1), each logical drive number can be bound to / arbitrary physical drive and partition listed in the VolToPart[]. Also f_fdisk() -/ funciton will be available. */ +/ function will be available. */ #define _MIN_SS 512 From 49a5ac3af4ea2fe8bdc7ce559e2851ec19baa729 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Tue, 5 Jul 2022 14:02:20 +0200 Subject: [PATCH 2/5] ci: deploy codespell Signed-off-by: Frederic Pillon --- .github/workflows/codespell.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/workflows/codespell.yml diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml new file mode 100644 index 0000000..8eb24b6 --- /dev/null +++ b/.github/workflows/codespell.yml @@ -0,0 +1,14 @@ +name: codespell +on: + push: + branches: + - main + pull_request: + workflow_dispatch: +jobs: + codespell: + name: Check for spelling errors + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + - uses: codespell-project/actions-codespell@master \ No newline at end of file From 8acd7ec9a3780a35c127969bdab9c3c83e0e62cd Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Tue, 5 Jul 2022 14:30:31 +0200 Subject: [PATCH 3/5] ci: deploy compile-examples One boards per series with SD capabilities: F1, F2, F4, F7, H7, L4, L5 and U5 Note: currently no L1 board declared in the core with SD capability. Signed-off-by: Frederic Pillon --- .github/workflows/compile-examples.yml | 40 ++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/compile-examples.yml diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml new file mode 100644 index 0000000..03f5ff0 --- /dev/null +++ b/.github/workflows/compile-examples.yml @@ -0,0 +1,40 @@ +name: Compile Examples +on: + push: + branches: + - main + paths-ignore: + - '*.json' + - '**.md' + - keywords.txt + - library.properties + pull_request: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + fqbn: + - STMicroelectronics:stm32:GenF1:pnum=BLUEBUTTON_F103RCT + - STMicroelectronics:stm32:Nucleo_144:pnum=NUCLEO_F207ZG + - STMicroelectronics:stm32:GenF4:pnum=FEATHER_F405 + - STMicroelectronics:stm32:Disco:pnum=DISCO_F746NG + - STMicroelectronics:stm32:GenH7:pnum=DAISY_PATCH_SM + - STMicroelectronics:stm32:Eval:pnum=STEVAL_MKSBOX1V1,usb=CDCgen + - STMicroelectronics:stm32:Nucleo_144:pnum=NUCLEO_L552ZE_Q + - STMicroelectronics:stm32:Nucleo_144:pnum=NUCLEO_U575ZI_Q + steps: + - uses: actions/checkout@main + - uses: arduino/compile-sketches@v1 + with: + fqbn: ${{ matrix.fqbn }} + platforms: | + - source-url: https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json + name: STMicroelectronics:stm32 + libraries: | + # Install the library from the local path. + - source-path: ./ + - name: FatFS \ No newline at end of file From cc39046ef09a6c15c5ba95e3ef883f2181055e6d Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Tue, 5 Jul 2022 14:36:21 +0200 Subject: [PATCH 4/5] chore: apply astyle Signed-off-by: Frederic Pillon --- src/SD.cpp | 4 +- src/STM32SD.h | 5 +- src/bsp_sd.c | 108 ++++++++++++++++++------------------- src/ffconf.h | 12 ++--- src/ffconf_default_32020.h | 2 +- src/ffconf_default_68300.h | 24 ++++----- 6 files changed, 79 insertions(+), 76 deletions(-) diff --git a/src/SD.cpp b/src/SD.cpp index b175eb5..21c8faa 100644 --- a/src/SD.cpp +++ b/src/SD.cpp @@ -144,13 +144,13 @@ File SDClass::open(const char *filepath, uint8_t mode /* = FA_READ */) file._fil->fs = 0; file._dir.fs = 0; #endif - + if ((mode == FILE_WRITE) && (!SD.exists(filepath))) { mode = mode | FA_CREATE_ALWAYS; } file._res = f_open(file._fil, filepath, mode); - if ( file._res != FR_OK) { + if (file._res != FR_OK) { free(file._fil); file._fil = NULL; file._res = f_opendir(&file._dir, filepath); diff --git a/src/STM32SD.h b/src/STM32SD.h index f3a44b4..5249d36 100644 --- a/src/STM32SD.h +++ b/src/STM32SD.h @@ -74,7 +74,10 @@ class File { DIR _dir = {}; // init all fields to 0 FRESULT _res = FR_OK; - FRESULT getErrorstate(void) {return _res;} + FRESULT getErrorstate(void) + { + return _res; + } }; diff --git a/src/bsp_sd.c b/src/bsp_sd.c index 6dea47c..a42a086 100644 --- a/src/bsp_sd.c +++ b/src/bsp_sd.c @@ -41,64 +41,64 @@ /* Definition for BSP SD */ #if defined(SDMMC1) || defined(SDMMC2) -#ifndef SD_INSTANCE -#define SD_INSTANCE SDMMC1 -#endif - -#define SD_CLK_ENABLE __HAL_RCC_SDMMC1_CLK_ENABLE -#define SD_CLK_DISABLE __HAL_RCC_SDMMC1_CLK_DISABLE -#ifdef SDMMC2 -#define SD_CLK2_ENABLE __HAL_RCC_SDMMC2_CLK_ENABLE -#define SD_CLK2_DISABLE __HAL_RCC_SDMMC2_CLK_DISABLE -#endif - -#define SD_CLK_EDGE SDMMC_CLOCK_EDGE_RISING -#define SD_CLK_BYPASS SDMMC_CLOCK_BYPASS_DISABLE -#define SD_CLK_PWR_SAVE SDMMC_CLOCK_POWER_SAVE_DISABLE -#define SD_BUS_WIDE_1B SDMMC_BUS_WIDE_1B -#define SD_BUS_WIDE_4B SDMMC_BUS_WIDE_4B -#define SD_BUS_WIDE_8B SDMMC_BUS_WIDE_8B -#define SD_HW_FLOW_CTRL_ENABLE SDMMC_HARDWARE_FLOW_CONTROL_ENABLE -#define SD_HW_FLOW_CTRL_DISABLE SDMMC_HARDWARE_FLOW_CONTROL_DISABLE - -#ifdef STM32H7xx -#define SD_CLK_DIV 1 -#else -#define SD_CLK_DIV SDMMC_TRANSFER_CLK_DIV -#endif - -#ifdef SDMMC_TRANSCEIVER_ENABLE -#define SD_TRANSCEIVER_ENABLE SDMMC_TRANSCEIVER_ENABLE -#define SD_TRANSCEIVER_DISABLE SDMMC_TRANSCEIVER_DISABLE -#endif + #ifndef SD_INSTANCE + #define SD_INSTANCE SDMMC1 + #endif + + #define SD_CLK_ENABLE __HAL_RCC_SDMMC1_CLK_ENABLE + #define SD_CLK_DISABLE __HAL_RCC_SDMMC1_CLK_DISABLE + #ifdef SDMMC2 + #define SD_CLK2_ENABLE __HAL_RCC_SDMMC2_CLK_ENABLE + #define SD_CLK2_DISABLE __HAL_RCC_SDMMC2_CLK_DISABLE + #endif + + #define SD_CLK_EDGE SDMMC_CLOCK_EDGE_RISING + #define SD_CLK_BYPASS SDMMC_CLOCK_BYPASS_DISABLE + #define SD_CLK_PWR_SAVE SDMMC_CLOCK_POWER_SAVE_DISABLE + #define SD_BUS_WIDE_1B SDMMC_BUS_WIDE_1B + #define SD_BUS_WIDE_4B SDMMC_BUS_WIDE_4B + #define SD_BUS_WIDE_8B SDMMC_BUS_WIDE_8B + #define SD_HW_FLOW_CTRL_ENABLE SDMMC_HARDWARE_FLOW_CONTROL_ENABLE + #define SD_HW_FLOW_CTRL_DISABLE SDMMC_HARDWARE_FLOW_CONTROL_DISABLE + + #ifdef STM32H7xx + #define SD_CLK_DIV 1 + #else + #define SD_CLK_DIV SDMMC_TRANSFER_CLK_DIV + #endif + + #ifdef SDMMC_TRANSCEIVER_ENABLE + #define SD_TRANSCEIVER_ENABLE SDMMC_TRANSCEIVER_ENABLE + #define SD_TRANSCEIVER_DISABLE SDMMC_TRANSCEIVER_DISABLE + #endif #elif defined(SDIO) -#define SD_INSTANCE SDIO -#define SD_CLK_ENABLE __HAL_RCC_SDIO_CLK_ENABLE -#define SD_CLK_DISABLE __HAL_RCC_SDIO_CLK_DISABLE -#define SD_CLK_EDGE SDIO_CLOCK_EDGE_RISING -#define SD_CLK_BYPASS SDIO_CLOCK_BYPASS_DISABLE -#define SD_CLK_PWR_SAVE SDIO_CLOCK_POWER_SAVE_DISABLE -#define SD_BUS_WIDE_1B SDIO_BUS_WIDE_1B -#define SD_BUS_WIDE_4B SDIO_BUS_WIDE_4B -#define SD_BUS_WIDE_8B SDIO_BUS_WIDE_8B -#define SD_HW_FLOW_CTRL_ENABLE SDIO_HARDWARE_FLOW_CONTROL_ENABLE -#define SD_HW_FLOW_CTRL_DISABLE SDIO_HARDWARE_FLOW_CONTROL_DISABLE -#define SD_CLK_DIV SDIO_TRANSFER_CLK_DIV + #define SD_INSTANCE SDIO + #define SD_CLK_ENABLE __HAL_RCC_SDIO_CLK_ENABLE + #define SD_CLK_DISABLE __HAL_RCC_SDIO_CLK_DISABLE + #define SD_CLK_EDGE SDIO_CLOCK_EDGE_RISING + #define SD_CLK_BYPASS SDIO_CLOCK_BYPASS_DISABLE + #define SD_CLK_PWR_SAVE SDIO_CLOCK_POWER_SAVE_DISABLE + #define SD_BUS_WIDE_1B SDIO_BUS_WIDE_1B + #define SD_BUS_WIDE_4B SDIO_BUS_WIDE_4B + #define SD_BUS_WIDE_8B SDIO_BUS_WIDE_8B + #define SD_HW_FLOW_CTRL_ENABLE SDIO_HARDWARE_FLOW_CONTROL_ENABLE + #define SD_HW_FLOW_CTRL_DISABLE SDIO_HARDWARE_FLOW_CONTROL_DISABLE + #define SD_CLK_DIV SDIO_TRANSFER_CLK_DIV #else -#error "Unknown SD_INSTANCE" + #error "Unknown SD_INSTANCE" #endif #ifndef SD_HW_FLOW_CTRL -#define SD_HW_FLOW_CTRL SD_HW_FLOW_CTRL_DISABLE + #define SD_HW_FLOW_CTRL SD_HW_FLOW_CTRL_DISABLE #endif #ifndef SD_BUS_WIDE -#define SD_BUS_WIDE SD_BUS_WIDE_4B + #define SD_BUS_WIDE SD_BUS_WIDE_4B #endif #if defined(SDMMC_TRANSCEIVER_ENABLE) && !defined(SD_TRANSCEIVER_MODE) -#define SD_TRANSCEIVER_MODE SD_TRANSCEIVER_DISABLE + #define SD_TRANSCEIVER_MODE SD_TRANSCEIVER_DISABLE #endif /* BSP SD Private Variables */ @@ -106,17 +106,17 @@ static SD_HandleTypeDef uSdHandle; static uint32_t SD_detect_ll_gpio_pin = LL_GPIO_PIN_ALL; static GPIO_TypeDef *SD_detect_gpio_port = GPIOA; #ifdef SDMMC_TRANSCEIVER_ENABLE -static uint32_t SD_trans_en_ll_gpio_pin = LL_GPIO_PIN_ALL; -static GPIO_TypeDef *SD_trans_en_gpio_port = GPIOA; -static uint32_t SD_trans_sel_ll_gpio_pin = LL_GPIO_PIN_ALL; -static GPIO_TypeDef *SD_trans_sel_gpio_port = GPIOA; + static uint32_t SD_trans_en_ll_gpio_pin = LL_GPIO_PIN_ALL; + static GPIO_TypeDef *SD_trans_en_gpio_port = GPIOA; + static uint32_t SD_trans_sel_ll_gpio_pin = LL_GPIO_PIN_ALL; + static GPIO_TypeDef *SD_trans_sel_gpio_port = GPIOA; #endif #ifndef STM32L1xx -#define SD_OK HAL_OK -#define SD_TRANSFER_OK ((uint8_t)0x00) -#define SD_TRANSFER_BUSY ((uint8_t)0x01) + #define SD_OK HAL_OK + #define SD_TRANSFER_OK ((uint8_t)0x00) + #define SD_TRANSFER_BUSY ((uint8_t)0x01) #else /* STM32L1xx */ -static SD_CardInfo uSdCardInfo; + static SD_CardInfo uSdCardInfo; #endif diff --git a/src/ffconf.h b/src/ffconf.h index d1fcbe9..3120ca0 100644 --- a/src/ffconf.h +++ b/src/ffconf.h @@ -10,12 +10,12 @@ /* FatFs specific configuration options. */ #if __has_include("ffconf_custom.h") -#include "ffconf_custom.h" + #include "ffconf_custom.h" #else -#if _FATFS == 68300 -#include "ffconf_default_68300.h" -#else -#include "ffconf_default_32020.h" -#endif + #if _FATFS == 68300 + #include "ffconf_default_68300.h" + #else + #include "ffconf_default_32020.h" + #endif #endif #endif /* _ARDUINO_FFCONF_H */ diff --git a/src/ffconf_default_32020.h b/src/ffconf_default_32020.h index d65054d..2ff8ea6 100644 --- a/src/ffconf_default_32020.h +++ b/src/ffconf_default_32020.h @@ -236,7 +236,7 @@ /� These options have no effect at read-only configuration (_FS_READONLY == 1). */ #if _NORTC_YEAR < 1980 || _NORTC_YEAR > 2107 || _NORTC_MON < 1 || _NORTC_MON > 12 || _NORTC_MDAY < 1 || _NORTC_MDAY > 31 -#error Invalid _FS_NORTC settings + #error Invalid _FS_NORTC settings #endif #endif /* _FFCONFIG */ diff --git a/src/ffconf_default_68300.h b/src/ffconf_default_68300.h index 0e655b3..ef77914 100644 --- a/src/ffconf_default_68300.h +++ b/src/ffconf_default_68300.h @@ -287,9 +287,9 @@ #define _FS_REENTRANT 0 #if _FS_REENTRANT -#include "cmsis_os.h" -#define _FS_TIMEOUT 1000 -#define _SYNC_t osSemaphoreId + #include "cmsis_os.h" + #define _FS_TIMEOUT 1000 + #define _SYNC_t osSemaphoreId #endif /* The option _FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs / module itself. Note that regardless of this option, file access to different @@ -311,16 +311,16 @@ /* #include // O/S definitions */ #if _USE_LFN == 3 -#if !defined(ff_malloc) || !defined(ff_free) -#include -#endif + #if !defined(ff_malloc) || !defined(ff_free) + #include + #endif -#if !defined(ff_malloc) -#define ff_malloc malloc -#endif + #if !defined(ff_malloc) + #define ff_malloc malloc + #endif -#if !defined(ff_free) -#define ff_free free -#endif + #if !defined(ff_free) + #define ff_free free + #endif #endif /*--- End of configuration options ---*/ From cd596f390b97371417aadab95864d59d2a043ca6 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Tue, 5 Jul 2022 14:52:05 +0200 Subject: [PATCH 5/5] ci: deploy astyle Signed-off-by: Frederic Pillon --- .github/workflows/astyle.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/astyle.yml diff --git a/.github/workflows/astyle.yml b/.github/workflows/astyle.yml new file mode 100644 index 0000000..a2e1b4d --- /dev/null +++ b/.github/workflows/astyle.yml @@ -0,0 +1,30 @@ +name: astyle +on: + push: + branches: + - main + paths-ignore: + - '*.json' + - '**.md' + - keywords.txt + - library.properties + pull_request: + paths-ignore: + - '*.json' + - '**.md' + - keywords.txt + - library.properties + workflow_dispatch: +jobs: + astyle: + name: Check code formatting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + - uses: stm32duino/actions/astyle-check@main + # Use the output from the `Astyle` step + - name: Astyle Errors + if: failure() + run: | + cat ${{ steps.Astyle.outputs.astyle-result }} + exit 1 \ No newline at end of file