From d9057a3263919355c5ec77cdcecee1262249c494 Mon Sep 17 00:00:00 2001 From: BernardXiong Date: Sat, 25 Sep 2021 11:53:23 +0800 Subject: [PATCH 1/4] [BSP] fix the formating issue for drv_spi in ls2k --- bsp/ls2kdev/drivers/drv_spi.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/bsp/ls2kdev/drivers/drv_spi.c b/bsp/ls2kdev/drivers/drv_spi.c index 5a42acbee8..3e7bd06b26 100644 --- a/bsp/ls2kdev/drivers/drv_spi.c +++ b/bsp/ls2kdev/drivers/drv_spi.c @@ -15,36 +15,38 @@ #include #include #include + #include #include #include "drv_spi.h" #ifdef RT_USING_SPI +#ifdef RT_USING_SPI_GPIOCS +#include +#endif + static void spi_init(uint8_t spre_spr, uint8_t copl, uint8_t cpha) { - SET_SPI(SPSR, 0xc0); + SET_SPI(SPSR, 0xc0); SET_SPI(PARAM, 0x40); SET_SPI(PARAM2, 0x01); SET_SPI(SPER, (spre_spr & 0b00001100) >> 2); - SET_SPI(SPCR, 0x50 | copl << 3 | cpha << 2 | (spre_spr & 0b00000011)); + SET_SPI(SPCR, 0x50 | copl << 3 | cpha << 2 | (spre_spr & 0b00000011)); SET_SPI(SOFTCS, 0xff); } -static void spi_set_csn(uint8_t val) +rt_inline void spi_set_csn(uint8_t val) { SET_SPI(SOFTCS, val); } -#ifdef RT_USING_SPI_GPIOCS - #include -#endif -static void spi_set_cs(unsigned char cs, int new_status) +static void spi_set_cs(unsigned char cs, int new_status) { if (cs < 4) { unsigned char val = 0; val = GET_SPI(SOFTCS); - val |= 0x01 << cs ; // csen=1 + val |= 0x01 << cs ; // csen=1 if (new_status) // cs = 1 { val |= (0x10 << cs); // csn=1 @@ -64,6 +66,7 @@ static void spi_set_cs(unsigned char cs, int new_status) } #endif } + static uint8_t spi_write_for_response(uint8_t data) { uint8_t val; @@ -94,6 +97,7 @@ static int cmd_spi_init(int argc, char *argv[]) } } MSH_CMD_EXPORT(cmd_spi_init, cmd_spi_init); + static int cmd_spi_set_csn(int argc, char *argv[]) { uint8_t val, csn; @@ -110,6 +114,7 @@ static int cmd_spi_set_csn(int argc, char *argv[]) } } MSH_CMD_EXPORT(cmd_spi_set_csn, cmd_spi_set_csn); + static int cmd_spi_write(int argc, char *argv[]) { uint8_t data, resp; @@ -129,6 +134,7 @@ MSH_CMD_EXPORT(cmd_spi_write, cmd_spi_write); static rt_err_t configure(struct rt_spi_device *device, struct rt_spi_configuration *configuration); static rt_uint32_t xfer(struct rt_spi_device *device, struct rt_spi_message *message); + const static unsigned char SPI_DIV_TABLE[] = {0b0000, 0b0001, 0b0100, 0b0010, 0b0011, 0b0101, 0b0110, 0b0111, 0b1000, 0b1001, 0b1010, 0b1011}; // 2 4 8 16 32 64 128 256 512 1024 2048 4096 static rt_err_t configure(struct rt_spi_device *device, @@ -171,8 +177,8 @@ static rt_err_t configure(struct rt_spi_device *device, return RT_EOK; } -static rt_uint32_t xfer(struct rt_spi_device *device, - struct rt_spi_message *message) + +static rt_uint32_t xfer(struct rt_spi_device *device, struct rt_spi_message *message) { unsigned char cs = 0; @@ -214,18 +220,19 @@ static rt_uint32_t xfer(struct rt_spi_device *device, } return message->length; } + static struct rt_spi_ops loongson_spi_ops = { .configure = configure, .xfer = xfer }; static struct rt_spi_bus loongson_spi; + static int loongson_spi_init() { //rt_kprintf("spi_init\n"); return rt_spi_bus_register(&loongson_spi, "spi", &loongson_spi_ops); } INIT_BOARD_EXPORT(loongson_spi_init); - #endif /*@}*/ From 43336faf1e89052aeb9605f4cdbf63ee7b54fe97 Mon Sep 17 00:00:00 2001 From: BernardXiong Date: Sat, 25 Sep 2021 12:05:46 +0800 Subject: [PATCH 2/4] [BSP] fix formatting issue in APM32 BSP --- .../APM32F10x_StdPeriphDriver/src/apm32f10x_fmc.c | 6 +++--- .../APM32F10x_StdPeriphDriver/src/apm32f10x_gpio.c | 2 +- .../APM32F10x_StdPeriphDriver/src/apm32f10x_pmu.c | 6 +++--- .../APM32F10x_StdPeriphDriver/src/apm32f10x_rcm.c | 2 +- .../APM32F10x_StdPeriphDriver/src/apm32f10x_sdio.c | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bsp/apm32/libraries/APM32F10x_Library/APM32F10x_StdPeriphDriver/src/apm32f10x_fmc.c b/bsp/apm32/libraries/APM32F10x_Library/APM32F10x_StdPeriphDriver/src/apm32f10x_fmc.c index 357ecf637a..63f8bf81ae 100644 --- a/bsp/apm32/libraries/APM32F10x_Library/APM32F10x_StdPeriphDriver/src/apm32f10x_fmc.c +++ b/bsp/apm32/libraries/APM32F10x_Library/APM32F10x_StdPeriphDriver/src/apm32f10x_fmc.c @@ -347,11 +347,11 @@ FMC_STATUS_T FMC_ProgramOptionByteData(uint32_t address, uint8_t data) * * @param page:the address of the pages to be write protection * This parameter can be any combination of the following values: - * for APM32F10X_LD £º + * for APM32F10X_LD * @arg FLASH_WRP_PAGE_0_3 to FLASH_WRP_PAGE_28_31 - * for APM32F10X_MD £º + * for APM32F10X_MD * @arg FLASH_WRP_PAGE_0_3 to FLASH_WRP_PAGE_124_127 - * for APM32F10X_HD £º + * for APM32F10X_HD * @arg FLASH_WRP_PAGE_0_1 to FLASH_WRP_PAGE_60_61 or FLASH_WRP_PAGE_62_127 * @arg FMC_WRP_PAGE_ALL * diff --git a/bsp/apm32/libraries/APM32F10x_Library/APM32F10x_StdPeriphDriver/src/apm32f10x_gpio.c b/bsp/apm32/libraries/APM32F10x_Library/APM32F10x_StdPeriphDriver/src/apm32f10x_gpio.c index 9182ae9290..a3c1518eb5 100644 --- a/bsp/apm32/libraries/APM32F10x_Library/APM32F10x_StdPeriphDriver/src/apm32f10x_gpio.c +++ b/bsp/apm32/libraries/APM32F10x_Library/APM32F10x_StdPeriphDriver/src/apm32f10x_gpio.c @@ -466,7 +466,7 @@ void GPIO_ConfigPinRemap(GPIO_REMAP_T remap) { regVal |= 0x0F000000; } - + mask <<= bitOffset; regVal &= (uint32_t)~mask; val <<= bitOffset; diff --git a/bsp/apm32/libraries/APM32F10x_Library/APM32F10x_StdPeriphDriver/src/apm32f10x_pmu.c b/bsp/apm32/libraries/APM32F10x_Library/APM32F10x_StdPeriphDriver/src/apm32f10x_pmu.c index 2398ebe0e4..571ccabd92 100644 --- a/bsp/apm32/libraries/APM32F10x_Library/APM32F10x_StdPeriphDriver/src/apm32f10x_pmu.c +++ b/bsp/apm32/libraries/APM32F10x_Library/APM32F10x_StdPeriphDriver/src/apm32f10x_pmu.c @@ -88,7 +88,7 @@ void PMU_DisablePVD(void) /*! * @brief Configure a voltage threshold detected by a power supply voltage detector (PVD). * - * @param level£ºspecifies the PVD detection level + * @param level : specifies the PVD detection level * This parameter can be one of the following values: * @arg PMU_PVD_LEVEL_2V2 : Config PVD detection level to 2.2V * @arg PMU_PVD_LEVEL_2V3 : Config PVD detection level to 2.3V @@ -198,7 +198,7 @@ void PMU_EnterSTANDBYMode(void) /*! * @brief Read the specified PWR flag is set or not. * - * @param flag£ºReads the status of specifies the flag. + * @param flag£ºReads the status of specifies the flag. * This parameter can be one of the following values: * @arg PMU_FLAG_WUE : Wake Up flag * @arg PMU_FLAG_SB : StandBy flag @@ -226,7 +226,7 @@ uint8_t PMU_ReadStatusFlag(PMU_FLAG_T flag) /*! * @brief Clears the PWR's pending flags. * - * @param flag£ºClears the status of specifies the flag. + * @param flag£ºClears the status of specifies the flag. * This parameter can be one of the following values: * @arg PMU_FLAG_WUE : Wake Up flag * @arg PMU_FLAG_SB : StandBy flag diff --git a/bsp/apm32/libraries/APM32F10x_Library/APM32F10x_StdPeriphDriver/src/apm32f10x_rcm.c b/bsp/apm32/libraries/APM32F10x_Library/APM32F10x_StdPeriphDriver/src/apm32f10x_rcm.c index 71151193e2..a1d6205224 100644 --- a/bsp/apm32/libraries/APM32F10x_Library/APM32F10x_StdPeriphDriver/src/apm32f10x_rcm.c +++ b/bsp/apm32/libraries/APM32F10x_Library/APM32F10x_StdPeriphDriver/src/apm32f10x_rcm.c @@ -1032,7 +1032,7 @@ void RCM_ClearStatusFlag(void) /*! * @brief Reads the specified RCM interrupt Flag * - * @param flag £ºReads specifies RCM interrupt flag. + * @param flag : Reads specifies RCM interrupt flag. * This parameter can be one of the following values: * @arg RCM_INT_LSIRDY : LSI ready interrupt flag * @arg RCM_INT_LSERDY : LSE ready interrupt flag diff --git a/bsp/apm32/libraries/APM32F10x_Library/APM32F10x_StdPeriphDriver/src/apm32f10x_sdio.c b/bsp/apm32/libraries/APM32F10x_Library/APM32F10x_StdPeriphDriver/src/apm32f10x_sdio.c index 3c76e77076..f79af54970 100644 --- a/bsp/apm32/libraries/APM32F10x_Library/APM32F10x_StdPeriphDriver/src/apm32f10x_sdio.c +++ b/bsp/apm32/libraries/APM32F10x_Library/APM32F10x_StdPeriphDriver/src/apm32f10x_sdio.c @@ -289,7 +289,7 @@ uint32_t SDIO_ReadDataCounter(void) /*! * @brief Write the SDIO Data * - * @param Data£ºWrite 32-bit data + * @param Data : Write 32-bit data * * @retval None */ From c82bce24a77e3ad525b55c2c5d4460055f33c4e3 Mon Sep 17 00:00:00 2001 From: BernardXiong Date: Sat, 25 Sep 2021 12:09:09 +0800 Subject: [PATCH 3/4] [BSP] fix formating issue --- .../APM32F10x_StdPeriphDriver/src/apm32f10x_pmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bsp/apm32/libraries/APM32F10x_Library/APM32F10x_StdPeriphDriver/src/apm32f10x_pmu.c b/bsp/apm32/libraries/APM32F10x_Library/APM32F10x_StdPeriphDriver/src/apm32f10x_pmu.c index 571ccabd92..969b1a98d7 100644 --- a/bsp/apm32/libraries/APM32F10x_Library/APM32F10x_StdPeriphDriver/src/apm32f10x_pmu.c +++ b/bsp/apm32/libraries/APM32F10x_Library/APM32F10x_StdPeriphDriver/src/apm32f10x_pmu.c @@ -198,7 +198,7 @@ void PMU_EnterSTANDBYMode(void) /*! * @brief Read the specified PWR flag is set or not. * - * @param flag£ºReads the status of specifies the flag. + * @param flag : Reads the status of specifies the flag. * This parameter can be one of the following values: * @arg PMU_FLAG_WUE : Wake Up flag * @arg PMU_FLAG_SB : StandBy flag @@ -226,7 +226,7 @@ uint8_t PMU_ReadStatusFlag(PMU_FLAG_T flag) /*! * @brief Clears the PWR's pending flags. * - * @param flag£ºClears the status of specifies the flag. + * @param flag : Clears the status of specifies the flag. * This parameter can be one of the following values: * @arg PMU_FLAG_WUE : Wake Up flag * @arg PMU_FLAG_SB : StandBy flag From 861c579c600d143085c45b0a7228b1b01eae2fec Mon Sep 17 00:00:00 2001 From: nrush <1741598985@qq.com> Date: Sun, 10 Oct 2021 07:41:03 +0000 Subject: [PATCH 4/4] [Kernel] Add build time to the boot printing When the firmware is built many times in a day, we can not distinguish them by current boot printing for the lack of compile time. So, it is necessary to add __TIME__ to rt_show_version(). Signed-off-by: nrush <1741598985@qq.com> --- src/kservice.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/kservice.c b/src/kservice.c index 91872492fb..a256bdcf86 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -546,8 +546,8 @@ void rt_show_version(void) { rt_kprintf("\n \\ | /\n"); rt_kprintf("- RT - Thread Operating System\n"); - rt_kprintf(" / | \\ %d.%d.%d build %s\n", - RT_VERSION, RT_SUBVERSION, RT_REVISION, __DATE__); + rt_kprintf(" / | \\ %d.%d.%d build %s %s\n", + RT_VERSION, RT_SUBVERSION, RT_REVISION, __DATE__, __TIME__); rt_kprintf(" 2006 - 2021 Copyright by rt-thread team\n"); } RTM_EXPORT(rt_show_version);