From 94d4d272ae8fe22a75250ac12d8f835fdd3a5dc9 Mon Sep 17 00:00:00 2001 From: Alexei Date: Wed, 1 Feb 2023 00:56:58 +0700 Subject: [PATCH] Defined few ARM_ETH_MAC functions --- .../board_family/NetworkInterface.c | 98 +++++- RTE/_Target_1/RTE_Components.h | 2 + Test_project_for_GD32107C-EVAL.uvoptx | 312 +----------------- 3 files changed, 94 insertions(+), 318 deletions(-) diff --git a/FreeRTOS/source/portable/NetworkInterface/board_family/NetworkInterface.c b/FreeRTOS/source/portable/NetworkInterface/board_family/NetworkInterface.c index d2b813b..3b8df51 100644 --- a/FreeRTOS/source/portable/NetworkInterface/board_family/NetworkInterface.c +++ b/FreeRTOS/source/portable/NetworkInterface/board_family/NetworkInterface.c @@ -1482,7 +1482,7 @@ ARM_ETH_MAC_CAPABILITIES ARM_ETH_MAC_GetCapabilities (void) 1, ///< 1 = UDP payload checksum generated on transmit 1, ///< 1 = TCP payload checksum generated on transmit 1, ///< 1 = ICMP payload checksum generated on transmit - 1, ///< 0, 1, 2, 3, Ethernet Media Interface type + 0, ///< 0, 1, 2, 3, Ethernet Media Interface type 1, ///< 1 = driver provides initial valid MAC address 1, ///< 1 = callback event \ref ARM_ETH_MAC_EVENT_RX_FRAME generated 1, ///< 1 = callback event \ref ARM_ETH_MAC_EVENT_TX_FRAME generated @@ -1502,6 +1502,7 @@ ARM_ETH_MAC_CAPABILITIES ARM_ETH_MAC_GetCapabilities (void) int32_t ARM_ETH_MAC_Initialize (ARM_ETH_MAC_SignalEvent_t cb_event) { enet_init(ENET_AUTO_NEGOTIATION, ENET_AUTOCHECKSUM_DROP_FAILFRAMES, ENET_RECEIVEALL); + //enet_ptp_start(int32_t updatemethod, uint32_t init_sec, uint32_t init_subsec, uint32_t carry_cfg, uint32_t accuracy_cfg) return pdTRUE; } @@ -1534,19 +1535,30 @@ int32_t ARM_ETH_MAC_PowerControl (ARM_POWER_STATE state) */ int32_t ARM_ETH_MAC_GetMacAddress (ARM_ETH_MAC_ADDR *ptr_addr) { - enet_mac_address_get(ENET_MAC_ADDRESS0, (uint8_t*)&ptr_addr->b[0]); - enet_mac_address_get(ENET_MAC_ADDRESS1, (uint8_t*)&ptr_addr->b[1]); - enet_mac_address_get(ENET_MAC_ADDRESS2, (uint8_t*)&ptr_addr->b[2]); - enet_mac_address_get(ENET_MAC_ADDRESS3, (uint8_t*)&ptr_addr->b[3]); - - return pdTRUE; + if (ptr_addr != NULL) + { + enet_mac_address_get(ENET_MAC_ADDRESS0, (uint8_t*)ptr_addr->b); + return pdPASS; + } + else return pdFAIL; } + /** \fn int32_t ARM_ETH_MAC_SetMacAddress (const ARM_ETH_MAC_ADDR *ptr_addr) \brief Set Ethernet MAC Address. \param[in] ptr_addr Pointer to address \return \ref execution_status */ +int32_t ARM_ETH_MAC_SetMacAddress (const ARM_ETH_MAC_ADDR *ptr_addr) +{ + if (ptr_addr != NULL) + { + enet_mac_address_set(ENET_MAC_ADDRESS0, (uint8_t*)ptr_addr->b); + return pdPASS; + } + else return pdFAIL; +} + /** \fn int32_t ARM_ETH_MAC_SetAddressFilter (const ARM_ETH_MAC_ADDR *ptr_addr, uint32_t num_addr) @@ -1555,6 +1567,18 @@ int32_t ARM_ETH_MAC_GetMacAddress (ARM_ETH_MAC_ADDR *ptr_addr) \param[in] num_addr Number of addresses to configure \return \ref execution_status */ +int32_t ARM_ETH_MAC_SetAddressFilter (const ARM_ETH_MAC_ADDR *ptr_addr, uint32_t num_addr) +{ + + enet_address_filter_config(ENET_MAC_ADDRESS0, ENET_ADDRESS_MASK_BYTE0, ENET_ADDRESS_FILTER_SA); + enet_address_filter_config(ENET_MAC_ADDRESS0, ENET_ADDRESS_MASK_BYTE1, ENET_ADDRESS_FILTER_SA); + enet_address_filter_config(ENET_MAC_ADDRESS0, ENET_ADDRESS_MASK_BYTE2, ENET_ADDRESS_FILTER_SA); + enet_address_filter_config(ENET_MAC_ADDRESS0, ENET_ADDRESS_MASK_BYTE3, ENET_ADDRESS_FILTER_SA); + enet_address_filter_config(ENET_MAC_ADDRESS0, ENET_ADDRESS_MASK_BYTE4, ENET_ADDRESS_FILTER_SA); + enet_address_filter_config(ENET_MAC_ADDRESS0, ENET_ADDRESS_MASK_BYTE5, ENET_ADDRESS_FILTER_SA); + return pdTRUE; +} + /** \fn int32_t ARM_ETH_MAC_SendFrame (const uint8_t *frame, uint32_t len, uint32_t flags) \brief Send Ethernet frame. @@ -1563,6 +1587,14 @@ int32_t ARM_ETH_MAC_GetMacAddress (ARM_ETH_MAC_ADDR *ptr_addr) \param[in] flags Frame transmit flags (see ARM_ETH_MAC_TX_FRAME_...) \return \ref execution_status */ +int32_t ARM_ETH_MAC_SendFrame (const uint8_t *frame, uint32_t len, uint32_t flags) +{ + if (frame != NULL & len > 0) + return enet_frame_transmit((uint8_t*)frame, len); + else + return pdFAIL; +} + /** \fn int32_t ARM_ETH_MAC_ReadFrame (uint8_t *frame, uint32_t len) \brief Read data of received Ethernet frame. @@ -1572,23 +1604,56 @@ int32_t ARM_ETH_MAC_GetMacAddress (ARM_ETH_MAC_ADDR *ptr_addr) - value >= 0: number of data bytes read - value < 0: error occurred, value is execution status as defined with \ref execution_status */ +int32_t ARM_ETH_MAC_ReadFrame (uint8_t *frame, uint32_t len) +{ + if (frame != NULL & len > 0) + return enet_frame_receive(frame, len); + else + return pdFAIL; +} + /** \fn uint32_t ARM_ETH_MAC_GetRxFrameSize (void) \brief Get size of received Ethernet frame. \return number of bytes in received frame */ +uint32_t ARM_ETH_MAC_GetRxFrameSize (void) +{ + return enet_rxframe_size_get(); +} + /** \fn int32_t ARM_ETH_MAC_GetRxFrameTime (ARM_ETH_MAC_TIME *time) \brief Get time of received Ethernet frame. \param[in] time Pointer to time structure for data to read into \return \ref execution_status */ +int32_t ARM_ETH_MAC_GetRxFrameTime (ARM_ETH_MAC_TIME *time) +{ + //if ENET_RXTX_TIMESTAMP bit set in ENET_PTP_TSCTL register (enet_ptp_start(int32_t updatemethod, uint32_t init_sec, uint32_t init_subsec, uint32_t carry_cfg, uint32_t accuracy_cfg);) + enet_ptp_systime_struct systime_struct; + enet_ptp_system_time_get(&systime_struct); + time->sec = systime_struct.second; + time->ns = systime_struct.nanosecond; + return pdPASS; +} + /** \fn int32_t ARM_ETH_MAC_GetTxFrameTime (ARM_ETH_MAC_TIME *time) \brief Get time of transmitted Ethernet frame. \param[in] time Pointer to time structure for data to read into \return \ref execution_status */ +int32_t ARM_ETH_MAC_GetTxFrameTime (ARM_ETH_MAC_TIME *time) +{ + //if ENET_RXTX_TIMESTAMP bit set in ENET_PTP_TSCTL register (enet_ptp_timestamp_function_config(ENET_PTP_SYSTIME_INIT);) + enet_ptp_systime_struct systime_struct; + enet_ptp_system_time_get(&systime_struct); + time->sec = systime_struct.second; + time->ns = systime_struct.nanosecond; + return pdPASS; +} + /** \fn int32_t ARM_ETH_MAC_Control (uint32_t control, uint32_t arg) \brief Control Ethernet Interface. @@ -1596,6 +1661,11 @@ int32_t ARM_ETH_MAC_GetMacAddress (ARM_ETH_MAC_ADDR *ptr_addr) \param[in] arg Argument of operation (optional) \return \ref execution_status */ +int32_t ARM_ETH_MAC_Control (uint32_t control, uint32_t arg) +{ + return pdPASS; +} + /** \fn int32_t ARM_ETH_MAC_ControlTimer (uint32_t control, ARM_ETH_MAC_TIME *time) \brief Control Precision Timer. @@ -1603,6 +1673,11 @@ int32_t ARM_ETH_MAC_GetMacAddress (ARM_ETH_MAC_ADDR *ptr_addr) \param[in] time Pointer to time structure \return \ref execution_status */ +int32_t ARM_ETH_MAC_ControlTimer (uint32_t control, ARM_ETH_MAC_TIME *time) +{ + return pdPASS; +} + /** \fn int32_t ARM_ETH_MAC_PHY_Read (uint8_t phy_addr, uint8_t reg_addr, uint16_t *data) \brief Read Ethernet PHY Register through Management Interface. @@ -1611,6 +1686,11 @@ int32_t ARM_ETH_MAC_GetMacAddress (ARM_ETH_MAC_ADDR *ptr_addr) \param[out] data Pointer where the result is written to \return \ref execution_status */ +int32_t ARM_ETH_MAC_PHY_Read (uint8_t phy_addr, uint8_t reg_addr, uint16_t *data) +{ + return pdPASS; +} + /** \fn int32_t ARM_ETH_MAC_PHY_Write (uint8_t phy_addr, uint8_t reg_addr, uint16_t data) \brief Write Ethernet PHY Register through Management Interface. @@ -1619,6 +1699,10 @@ int32_t ARM_ETH_MAC_GetMacAddress (ARM_ETH_MAC_ADDR *ptr_addr) \param[in] data 16-bit data to write \return \ref execution_status */ +int32_t ARM_ETH_MAC_PHY_Write (uint8_t phy_addr, uint8_t reg_addr, uint16_t data) +{ + return pdPASS; +} /** \fn void ARM_ETH_MAC_SignalEvent (uint32_t event) diff --git a/RTE/_Target_1/RTE_Components.h b/RTE/_Target_1/RTE_Components.h index 430d8ee..b0ae4b4 100644 --- a/RTE/_Target_1/RTE_Components.h +++ b/RTE/_Target_1/RTE_Components.h @@ -24,6 +24,8 @@ #define RTE_RTOS_FreeRTOS_EVENTGROUPS /* RTOS FreeRTOS Event Groups */ /* ARM.FreeRTOS::RTOS:Heap:Heap_2:10.5.1 */ #define RTE_RTOS_FreeRTOS_HEAP_2 /* RTOS FreeRTOS Heap 2 */ +/* GigaDevice::Device:GD32F10x_StdPeripherals:DMA:2.0.2 */ +#define RTE_DEVICE_STDPERIPHERALS_DMA /* GigaDevice::Device:GD32F10x_StdPeripherals:ENET:2.0.2 */ #define RTE_DEVICE_STDPERIPHERALS_ENET /* GigaDevice::Device:GD32F10x_StdPeripherals:EXTI:2.0.2 */ diff --git a/Test_project_for_GD32107C-EVAL.uvoptx b/Test_project_for_GD32107C-EVAL.uvoptx index 6124c5f..544155c 100644 --- a/Test_project_for_GD32107C-EVAL.uvoptx +++ b/Test_project_for_GD32107C-EVAL.uvoptx @@ -153,312 +153,7 @@ UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0GD32F10x_CL -FS08000000 -FL040000 -FP0($$Device:GD32F107VC$Flash\GD32F10x_CL.FLM)) - - - 0 - 0 - 1495 - 1 -
134235448
- 0 - 0 - 0 - 0 - 0 - 1 - .\FreeRTOS\source\portable\NetworkInterface\board_family\NetworkInterface.c - - \\Test_project_for_GD32107C_EVAL\FreeRTOS/source/portable/NetworkInterface/board_family/NetworkInterface.c\1495 -
- - 1 - 0 - 1493 - 1 -
134235428
- 0 - 0 - 0 - 0 - 0 - 1 - .\FreeRTOS\source\portable\NetworkInterface\board_family\NetworkInterface.c - - \\Test_project_for_GD32107C_EVAL\FreeRTOS/source/portable/NetworkInterface/board_family/NetworkInterface.c\1493 -
- - 2 - 0 - 243 - 1 -
134261588
- 0 - 0 - 0 - 0 - 0 - 1 - .\main.c - - \\Test_project_for_GD32107C_EVAL\main.c\243 -
- - 3 - 0 - 2568 - 1 -
2
- 0 - 0 - 0 - 0 - 0 - 1 - C:/Users/User/AppData/Local/Arm/Packs/ARM/CMSIS-FreeRTOS/10.5.1/Source/tasks.c - - \\Test_project_for_GD32107C_EVAL\tasks.c\2568 -
- - 4 - 0 - 57 - 1 -
0
- 0 - 0 - 0 - 0 - 0 - 0 - .\FreeRTOS\source\portable\NetworkInterface\board_family\NetworkInterface.c - - -
- - 5 - 0 - 64 - 1 -
0
- 0 - 0 - 0 - 0 - 0 - 0 - .\FreeRTOS\source\portable\NetworkInterface\board_family\NetworkInterface.c - - -
- - 6 - 0 - 70 - 1 -
0
- 0 - 0 - 0 - 0 - 0 - 0 - .\FreeRTOS\source\portable\NetworkInterface\board_family\NetworkInterface.c - - -
- - 7 - 0 - 80 - 1 -
0
- 0 - 0 - 0 - 0 - 0 - 0 - .\FreeRTOS\source\portable\NetworkInterface\board_family\NetworkInterface.c - - -
- - 8 - 0 - 86 - 1 -
0
- 0 - 0 - 0 - 0 - 0 - 0 - .\FreeRTOS\source\portable\NetworkInterface\board_family\NetworkInterface.c - - -
- - 9 - 0 - 91 - 1 -
0
- 0 - 0 - 0 - 0 - 0 - 0 - .\FreeRTOS\source\portable\NetworkInterface\board_family\NetworkInterface.c - - -
- - 10 - 0 - 1502 - 1 -
0
- 0 - 0 - 0 - 0 - 0 - 0 - .\FreeRTOS\source\portable\NetworkInterface\board_family\NetworkInterface.c - - -
- - 11 - 0 - 1503 - 1 -
0
- 0 - 0 - 0 - 0 - 0 - 0 - .\FreeRTOS\source\portable\NetworkInterface\board_family\NetworkInterface.c - - -
- - 12 - 0 - 1 - 1 -
0
- 0 - 0 - 0 - 0 - 0 - 0 - .\main.c - - -
- - 13 - 0 - 57 - 1 -
0
- 0 - 0 - 0 - 0 - 0 - 0 - .\main.c - - -
- - 14 - 0 - 64 - 1 -
0
- 0 - 0 - 0 - 0 - 0 - 0 - .\main.c - - -
- - 15 - 0 - 70 - 1 -
0
- 0 - 0 - 0 - 0 - 0 - 0 - .\main.c - - -
- - 16 - 0 - 80 - 1 -
0
- 0 - 0 - 0 - 0 - 0 - 0 - .\main.c - - -
- - 17 - 0 - 86 - 1 -
0
- 0 - 0 - 0 - 0 - 0 - 0 - .\main.c - - -
- - 18 - 0 - 91 - 1 -
0
- 0 - 0 - 0 - 0 - 0 - 0 - .\main.c - - -
-
+ 0 @@ -484,11 +179,6 @@ 0 - - C:\Users\User\AppData\Local\Arm\Packs\ARM\CMSIS-FreeRTOS\10.5.1\CMSIS\RTOS2\FreeRTOS\FreeRTOS.scvd - ARM.CMSIS-FreeRTOS.10.5.1 - 1 - 0