From b9a9225c84a809893483a5189e4ccc319498e343 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Thu, 17 Nov 2022 12:05:04 -0500 Subject: [PATCH] format imxrt drver files --- bsp/imxrt/libraries/drivers/drv_flexspi.c | 4 +-- bsp/imxrt/libraries/drivers/drv_rtc.c | 24 +++++--------- bsp/imxrt/libraries/drivers/drv_sdio.c | 6 ++-- bsp/imxrt/libraries/drivers/drv_usbh.c | 2 +- .../libraries/drivers/usb/host/usb_host.h | 2 +- .../drivers/usb/host/usb_host_ehci.c | 32 +++++++++---------- .../drivers/usb/host/usb_host_ehci.h | 2 +- .../libraries/drivers/usb/host/usb_host_hci.c | 8 ++--- bsp/imxrt/libraries/drivers/usb/include/usb.h | 4 +-- .../drivers/usb/include/usb_host_config.h | 6 ++-- bsp/imxrt/libraries/drivers/usb/phy/usb_phy.c | 2 +- 11 files changed, 42 insertions(+), 50 deletions(-) diff --git a/bsp/imxrt/libraries/drivers/drv_flexspi.c b/bsp/imxrt/libraries/drivers/drv_flexspi.c index fd50703353..ee731e1e13 100644 --- a/bsp/imxrt/libraries/drivers/drv_flexspi.c +++ b/bsp/imxrt/libraries/drivers/drv_flexspi.c @@ -80,7 +80,7 @@ static int rt_hw_imxrt_flexspi_init(void) config.ahbConfig.enableAHBBufferable = true; config.ahbConfig.enableReadAddressOpt = true; config.ahbConfig.enableAHBCachable = true; - config.ahbConfig.enableClearAHBBufferOpt = true; + config.ahbConfig.enableClearAHBBufferOpt = true; config.rxSampleClock = FLEXSPI_RX_SAMPLE_CLOCK; if(COMBINATION_MODE) { @@ -125,7 +125,7 @@ static void flexspi_test(void) LOG_D("FLEXSPI Memory 32 bit Write End\n"); memset(recv_buf, 0, sizeof(recv_buf)); - + LOG_D("FLEXSPI Memory 32 bit Read Start\n"); recv_buf[2] = *(flexspi + 11); recv_buf[3] = *(flexspi + 15); diff --git a/bsp/imxrt/libraries/drivers/drv_rtc.c b/bsp/imxrt/libraries/drivers/drv_rtc.c index 0e735a6176..4a95b496d0 100644 --- a/bsp/imxrt/libraries/drivers/drv_rtc.c +++ b/bsp/imxrt/libraries/drivers/drv_rtc.c @@ -33,7 +33,7 @@ static time_t imxrt_hp_get_timestamp(void) snvs_lp_srtc_datetime_t srtcDate = {0}; SNVS_LP_SRTC_GetDatetime(SNVS, &srtcDate); - SNVS_HP_RTC_TimeSynchronize(SNVS); + SNVS_HP_RTC_TimeSynchronize(SNVS); SNVS_HP_RTC_GetDatetime(SNVS, &rtcDate); tm_new.tm_sec = rtcDate.second; @@ -69,7 +69,7 @@ static int imxrt_hp_set_timestamp(time_t timestamp) return -RT_ERROR; } - SNVS_HP_RTC_TimeSynchronize(SNVS); + SNVS_HP_RTC_TimeSynchronize(SNVS); return RT_EOK; } @@ -77,7 +77,7 @@ static int imxrt_hp_set_timestamp(time_t timestamp) static rt_err_t imxrt_hp_rtc_init(rt_device_t dev) { snvs_hp_rtc_config_t snvsRtcConfig; - snvs_lp_srtc_config_t snvsSrtcConfig; + snvs_lp_srtc_config_t snvsSrtcConfig; /* Init SNVS_HP */ SNVS_HP_RTC_GetDefaultConfig(&snvsRtcConfig); @@ -105,12 +105,12 @@ static rt_err_t imxrt_hp_rtc_close(rt_device_t dev) static rt_size_t imxrt_hp_rtc_read(rt_device_t dev, rt_off_t pos, void* buffer, rt_size_t size) { - return RT_EOK; + return -RT_EINVAL; } static rt_size_t imxrt_hp_rtc_write(rt_device_t dev, rt_off_t pos, const void* buffer, rt_size_t size) { - return RT_EOK; + return -RT_EINVAL; } static rt_err_t imxrt_hp_rtc_control(rt_device_t dev, int cmd, void *args) @@ -132,7 +132,7 @@ static rt_err_t imxrt_hp_rtc_control(rt_device_t dev, int cmd, void *args) break; default: - return RT_EINVAL; + return -RT_EINVAL; } return RT_EOK; @@ -179,7 +179,6 @@ static int rtc_sample(int argc, char *argv[]) time_t now; rt_device_t device = RT_NULL; - /*寻找设备*/ device = rt_device_find(RTC_NAME); if (!device) { @@ -187,14 +186,12 @@ static int rtc_sample(int argc, char *argv[]) return RT_ERROR; } - /*初始化RTC设备*/ if(rt_device_open(device, 0) != RT_EOK) { LOG_E("open %s failed!", RTC_NAME); - return RT_ERROR; + return -RT_ERROR; } - /* 设置日期 */ ret = set_date(2018, 12, 3); if (ret != RT_EOK) { @@ -202,7 +199,6 @@ static int rtc_sample(int argc, char *argv[]) return ret; } - /* 设置时间 */ ret = set_time(11, 15, 50); if (ret != RT_EOK) { @@ -210,16 +206,12 @@ static int rtc_sample(int argc, char *argv[]) return ret; } - /* 延时3秒 */ - rt_thread_mdelay(3000); + rt_thread_mdelay(1000); - /* 获取时间 */ now = time(RT_NULL); rt_kprintf("%s\n", ctime(&now)); return ret; } -/* 导出到 msh 命令列表中 */ MSH_CMD_EXPORT(rtc_sample, rtc sample); - #endif /* BSP_USING_RTC */ diff --git a/bsp/imxrt/libraries/drivers/drv_sdio.c b/bsp/imxrt/libraries/drivers/drv_sdio.c index 3fc8b23a5b..8961b3abe3 100644 --- a/bsp/imxrt/libraries/drivers/drv_sdio.c +++ b/bsp/imxrt/libraries/drivers/drv_sdio.c @@ -49,7 +49,7 @@ static int enable_log = 1; #define USDHC_DATA_TIMEOUT (0xFU) /*!< data timeout counter value */ #define SDMMCHOST_SUPPORT_MAX_BLOCK_LENGTH (4096U) #define SDMMCHOST_SUPPORT_MAX_BLOCK_COUNT (USDHC_MAX_BLOCK_COUNT) - + /* Read/write watermark level. The bigger value indicates DMA has higher read/write performance. */ #define USDHC_READ_WATERMARK_LEVEL (0x80U) #define USDHC_WRITE_WATERMARK_LEVEL (0x80U) @@ -404,7 +404,7 @@ rt_int32_t _imxrt_mci_init(void) struct rt_mmcsd_host *host; struct imxrt_mmcsd *mmcsd; uint32_t hs400Capability = 0U; - + host = mmcsd_alloc_host(); if (!host) { @@ -433,7 +433,7 @@ rt_int32_t _imxrt_mci_init(void) MMCSD_SUP_HIGHSPEED | MMCSD_SUP_SDIO_IRQ; #ifdef SOC_IMXRT1170_SERIES #if defined FSL_FEATURE_USDHC_INSTANCE_SUPPORT_HS400_MODEn - hs400Capability = (uint32_t)FSL_FEATURE_USDHC_INSTANCE_SUPPORT_HS400_MODEn(mmcsd->usdhc_host.base); + hs400Capability = (uint32_t)FSL_FEATURE_USDHC_INSTANCE_SUPPORT_HS400_MODEn(mmcsd->usdhc_host.base); #endif #if (defined(FSL_FEATURE_USDHC_HAS_HS400_MODE) && (FSL_FEATURE_USDHC_HAS_HS400_MODE)) if (hs400Capability != 0U) diff --git a/bsp/imxrt/libraries/drivers/drv_usbh.c b/bsp/imxrt/libraries/drivers/drv_usbh.c index 73e16ae9ae..fd80d6ab54 100644 --- a/bsp/imxrt/libraries/drivers/drv_usbh.c +++ b/bsp/imxrt/libraries/drivers/drv_usbh.c @@ -104,7 +104,7 @@ static void USB_HostClockInit(usb_controller_index_t controller_id) usb_phy_config_struct_t phyConfig = { BOARD_USB_PHY_D_CAL, BOARD_USB_PHY_TXCAL45DP, BOARD_USB_PHY_TXCAL45DM, }; - + usbClockFreq = 24000000; if (controller_id == kUSB_ControllerEhci0) diff --git a/bsp/imxrt/libraries/drivers/usb/host/usb_host.h b/bsp/imxrt/libraries/drivers/usb/host/usb_host.h index 8f83396ad1..c6df838fc6 100644 --- a/bsp/imxrt/libraries/drivers/usb/host/usb_host.h +++ b/bsp/imxrt/libraries/drivers/usb/host/usb_host.h @@ -107,7 +107,7 @@ typedef struct _usb_host_process_descriptor_param device */ #ifdef SOC_IMXRT1170_SERIES uint16_t languageId; /*!< It specifies the language ID for string descriptors or is reset to zero for other - descriptors */ + descriptors */ #else uint8_t languageId; /*!< It specifies the language ID for string descriptors or is reset to zero for other descriptors */ diff --git a/bsp/imxrt/libraries/drivers/usb/host/usb_host_ehci.c b/bsp/imxrt/libraries/drivers/usb/host/usb_host_ehci.c index 59105d46ee..0024ed3585 100644 --- a/bsp/imxrt/libraries/drivers/usb/host/usb_host_ehci.c +++ b/bsp/imxrt/libraries/drivers/usb/host/usb_host_ehci.c @@ -1097,7 +1097,7 @@ static void USB_HostBandwidthHsHostComputeCurrentFsls(usb_host_ehci_instance_t * usb_host_ehci_pipe_t *ehciPipePointer; uint8_t index; #ifdef SOC_IMXRT1170_SERIES - uint32_t deviceInfo = 0; + uint32_t deviceInfo = 0; #else uint32_t deviceInfo; #endif @@ -1173,7 +1173,7 @@ static void USB_HostBandwidthHsHostComputeCurrentHsAll(usb_host_ehci_instance_t usb_host_ehci_pipe_t *ehciPipePointer; uint16_t index; #ifdef SOC_IMXRT1170_SERIES - uint32_t deviceInfo = 0U; + uint32_t deviceInfo = 0U; #else uint32_t deviceInfo; #endif @@ -3451,7 +3451,7 @@ static usb_status_t USB_HostEhciStartIP(usb_host_ehci_instance_t *ehciInstance) } #ifdef SOC_IMXRT1170_SERIES /* no interrupt threshold */ - ehciInstance->ehciIpBase->USBCMD &= ~USBHS_USBCMD_ITC_MASK; + ehciInstance->ehciIpBase->USBCMD &= ~USBHS_USBCMD_ITC_MASK; #endif /* start the controller */ ehciInstance->ehciIpBase->USBCMD |= USBHS_USBCMD_RS_MASK; @@ -3665,7 +3665,7 @@ void USB_HostEhciTransactionDone(usb_host_ehci_instance_t *ehciInstance) usb_host_ehci_iso_t *isoPointer; uint32_t dataLength; #ifdef SOC_IMXRT1170_SERIES - uint32_t speed = 0U; + uint32_t speed = 0U; #else uint32_t speed; #endif @@ -3794,7 +3794,7 @@ void USB_HostEhciTransactionDone(usb_host_ehci_instance_t *ehciInstance) /* no action */ } vltQtdPointer = (volatile usb_host_ehci_qtd_t *)vltQtdPointer->nextQtdPointer; - } while (true); + } while (true); #else while ((vltQtdPointer != NULL) && (0U == (transferResults & EHCI_HOST_QTD_IOC_MASK))) /* find the IOC qtd */ @@ -4025,7 +4025,7 @@ void USB_HostEhciPortChange(usb_host_ehci_instance_t *ehciInstance) #ifdef SOC_IMXRT1170_SERIES #if ((defined FSL_FEATURE_SOC_USBPHY_COUNT) && (FSL_FEATURE_SOC_USBPHY_COUNT > 0U)) USB_EhcihostPhyDisconnectDetectCmd(ehciInstance->controllerId, 0); -#endif +#endif #else USB_EhcihostPhyDisconnectDetectCmd(ehciInstance->controllerId, 0); #endif @@ -4192,28 +4192,28 @@ static void USB_HostEhciTimer1(usb_host_ehci_instance_t *ehciInstance) #if (defined(FSL_FEATURE_USBPHY_28FDSOI) && (FSL_FEATURE_USBPHY_28FDSOI > 0U)) ehciInstance->registerPhyBase->USB1_VBUS_DETECT_SET |= USBPHY_USB1_VBUS_DETECT_VBUSVALID_TO_SESSVALID_MASK; -#endif +#endif #endif ehciInstance->ehciIpBase->PORTSC1 |= USBHS_PORTSC1_PHCD_MASK; #ifdef SOC_IMXRT1170_SERIES -#if ((defined FSL_FEATURE_SOC_USBPHY_COUNT) && (FSL_FEATURE_SOC_USBPHY_COUNT > 0U)) +#if ((defined FSL_FEATURE_SOC_USBPHY_COUNT) && (FSL_FEATURE_SOC_USBPHY_COUNT > 0U)) ehciInstance->registerPhyBase->PWD = 0xFFFFFFFFU; while (0U != (ehciInstance->registerPhyBase->CTRL & (USBPHY_CTRL_UTMI_SUSPENDM_MASK))) { __NOP(); } -#endif +#endif #else ehciInstance->registerPhyBase->PWD = 0xFFFFFFFFU; while (0U != (ehciInstance->registerPhyBase->CTRL & (USBPHY_CTRL_UTMI_SUSPENDM_MASK))) { __NOP(); - } + } #endif - + #if (defined(FSL_FEATURE_SOC_USBNC_COUNT) && (FSL_FEATURE_SOC_USBNC_COUNT > 0U)) ehciInstance->registerNcBase->USB_OTGn_CTRL |= USBNC_USB_OTGn_CTRL_WKUP_ID_EN_MASK | USBNC_USB_OTGn_CTRL_WKUP_VBUS_EN_MASK | @@ -4224,7 +4224,7 @@ static void USB_HostEhciTimer1(usb_host_ehci_instance_t *ehciInstance) #if (defined(FSL_FEATURE_USB_ATLANTIC_EHCI_SUPPORT) && (FSL_FEATURE_USB_ATLANTIC_EHCI_SUPPORT > 0U)) #else ehciInstance->ehciIpBase->USBGENCTRL = USBHS_USBGENCTRL_WU_IE_MASK; -#endif +#endif #else ehciInstance->ehciIpBase->USBGENCTRL = USBHS_USBGENCTRL_WU_IE_MASK; #endif @@ -4232,7 +4232,7 @@ static void USB_HostEhciTimer1(usb_host_ehci_instance_t *ehciInstance) #ifdef #if ((defined FSL_FEATURE_SOC_USBPHY_COUNT) && (FSL_FEATURE_SOC_USBPHY_COUNT > 0U)) ehciInstance->registerPhyBase->CTRL |= USBPHY_CTRL_CLKGATE_MASK; -#endif +#endif #else ehciInstance->registerPhyBase->CTRL |= USBPHY_CTRL_CLKGATE_MASK; #endif @@ -4309,11 +4309,11 @@ usb_status_t USB_HostEhciCreate(uint8_t controllerId, #ifdef SOC_IMXRT1170_SERIES #if ((defined FSL_FEATURE_SOC_USBPHY_COUNT) && (FSL_FEATURE_SOC_USBPHY_COUNT > 0U)) ehciInstance->registerPhyBase = (USBPHY_Type *)USB_EhciPhyGetBase(controllerId); -#endif +#endif #else ehciInstance->registerPhyBase = (USBPHY_Type *)USB_EhciPhyGetBase(controllerId); #endif - + #if (defined(FSL_FEATURE_SOC_USBNC_COUNT) && (FSL_FEATURE_SOC_USBNC_COUNT > 0U)) ehciInstance->registerNcBase = (USBNC_Type *)USB_EhciNCGetBase(controllerId); #endif @@ -5084,7 +5084,7 @@ void USB_HostEhciIsrFunction(void *hostHandle) ehciInstance->ehciIpBase->USBCMD |= (USBHS_USBCMD_RS_MASK); ehciInstance->busSuspendStatus = kBus_EhciStartResume; } -#endif +#endif #endif (void)OSA_EventSet(ehciInstance->taskEventHandle, EHCI_TASK_EVENT_PORT_CHANGE); } diff --git a/bsp/imxrt/libraries/drivers/usb/host/usb_host_ehci.h b/bsp/imxrt/libraries/drivers/usb/host/usb_host_ehci.h index 1af4880c92..d1831a4d00 100644 --- a/bsp/imxrt/libraries/drivers/usb/host/usb_host_ehci.h +++ b/bsp/imxrt/libraries/drivers/usb/host/usb_host_ehci.h @@ -312,7 +312,7 @@ typedef struct _usb_host_ehci_instance #ifdef SOC_IMXRT1170_SERIES #if ((defined FSL_FEATURE_SOC_USBPHY_COUNT) && (FSL_FEATURE_SOC_USBPHY_COUNT > 0U)) USBPHY_Type *registerPhyBase; /*!< The base address of the PHY register */ -#endif +#endif #else USBPHY_Type *registerPhyBase; /*!< The base address of the PHY register */ #endif diff --git a/bsp/imxrt/libraries/drivers/usb/host/usb_host_hci.c b/bsp/imxrt/libraries/drivers/usb/host/usb_host_hci.c index 9ae82ae50c..a2ede69979 100644 --- a/bsp/imxrt/libraries/drivers/usb/host/usb_host_hci.c +++ b/bsp/imxrt/libraries/drivers/usb/host/usb_host_hci.c @@ -266,7 +266,7 @@ usb_status_t USB_HostInit(uint8_t controllerId, usb_host_handle *hostHandle, hos { return kStatus_USB_Error; } - + /* HOST instance init*/ hostInstance->controllerId = controllerId; @@ -291,7 +291,7 @@ usb_status_t USB_HostInit(uint8_t controllerId, usb_host_handle *hostHandle, hos transferPrev->next = &hostInstance->transferList[i]; transferPrev = transferPrev->next; } - + /* controller create, the callbackFn is initialized in USB_HostGetControllerInterface */ status = hostInstance->controllerTable->controllerCreate(controllerId, hostInstance, &(hostInstance->controllerHandle)); @@ -700,7 +700,7 @@ usb_status_t USB_HostHelperParseAlternateSetting(usb_host_interface_handle inter /* parse configuration descriptor */ #ifdef SOC_IMXRT1170_SERIES - temp = (void *)((usb_host_interface_t *)interfaceHandle)->interfaceExtension; + temp = (void *)((usb_host_interface_t *)interfaceHandle)->interfaceExtension; #else temp = (void *)((usb_host_interface_t *)interfaceHandle)->interfaceDesc; #endif @@ -711,7 +711,7 @@ usb_status_t USB_HostHelperParseAlternateSetting(usb_host_interface_handle inter #if !defined(SOC_IMXRT1170_SERIES) unionDes = (usb_descriptor_union_t *)((uint32_t)unionDes + unionDes->common.bLength); #endif - + /* search for the alternate setting interface descriptor */ while ((uint32_t)unionDes < endPosition) { diff --git a/bsp/imxrt/libraries/drivers/usb/include/usb.h b/bsp/imxrt/libraries/drivers/usb/include/usb.h index 1472c2a0f8..0a10e0a460 100644 --- a/bsp/imxrt/libraries/drivers/usb/include/usb.h +++ b/bsp/imxrt/libraries/drivers/usb/include/usb.h @@ -61,7 +61,7 @@ #define USB_STACK_COMPONENT_VERSION \ MAKE_VERSION(USB_STACK_VERSION_MAJOR, USB_STACK_VERSION_MINOR, USB_STACK_VERSION_BUGFIX) #endif - + /*! @brief USB error code */ typedef enum _usb_status { @@ -90,7 +90,7 @@ typedef enum _usb_status kStatus_USB_DataOverRun, /*!< The amount of data returned by the endpoint exceeded either the size of the maximum data packet allowed from the endpoint or the remaining buffer size. */ -#endif +#endif } usb_status_t; /*! @brief USB host handle type define */ diff --git a/bsp/imxrt/libraries/drivers/usb/include/usb_host_config.h b/bsp/imxrt/libraries/drivers/usb/include/usb_host_config.h index a3c3b7dbfd..8727a4e05c 100644 --- a/bsp/imxrt/libraries/drivers/usb/include/usb_host_config.h +++ b/bsp/imxrt/libraries/drivers/usb/include/usb_host_config.h @@ -103,7 +103,7 @@ #define USB_HOST_CONFIG_BUFFER_PROPERTY_CACHEABLE (0U) #endif /*! @brief if 1, enable usb compliance test codes; if 0, disable usb compliance test codes. */ -#ifdef SOC_IMXRT1170_SERIES +#ifdef SOC_IMXRT1170_SERIES #ifndef USB_HOST_CONFIG_COMPLIANCE_TEST #define USB_HOST_CONFIG_COMPLIANCE_TEST (0U) #endif @@ -165,7 +165,7 @@ /*! * @brief ohci GTD max count. */ -#define USB_HOST_CONFIG_OHCI_MAX_GTD (16U) +#define USB_HOST_CONFIG_OHCI_MAX_GTD (16U) #else /*! * @brief ohci ED max count. @@ -177,7 +177,7 @@ */ #define USB_HOST_CONFIG_OHCI_MAX_GTD (8U) #endif - + /*! * @brief ohci ITD max count. */ diff --git a/bsp/imxrt/libraries/drivers/usb/phy/usb_phy.c b/bsp/imxrt/libraries/drivers/usb/phy/usb_phy.c index 2ed2b7d3cd..c420482ad2 100644 --- a/bsp/imxrt/libraries/drivers/usb/phy/usb_phy.c +++ b/bsp/imxrt/libraries/drivers/usb/phy/usb_phy.c @@ -505,4 +505,4 @@ void USB_EhcihostPhyDisconnectDetectCmd(uint8_t controllerId, uint8_t enable) } #endif } -#endif \ No newline at end of file +#endif