|
V7配套的CMSIS-Driver驱动,将对下面的两个函数做个条件编译,可以选择官方的,也可以选择我修正的。
下面是官方的,速度94Mbps
- /**
- \fn int32_t ReadFrame (uint8_t *frame, uint32_t len)
- \brief Read data of received Ethernet frame.
- \param[in] frame Pointer to frame buffer for data to read into
- \param[in] len Frame buffer length in bytes
- \return number of data bytes read or execution status
- - value >= 0: number of data bytes read
- - value < 0: error occurred, value is execution status as defined with \ref execution_status
- */
- static int32_t ReadFrame (uint8_t *frame, uint32_t len) {
- if ((frame == NULL) && (len != 0U)) {
- /* Invalid parameters */
- return ARM_DRIVER_ERROR_PARAMETER;
- }
- if ((Emac.flags & EMAC_FLAG_POWER) == 0U) {
- /* Driver not yet powered */
- return ARM_DRIVER_ERROR;
- }
- if ((frame != NULL) && (Emac.rx_buf.buffer != NULL)) {
- memcpy (frame, Emac.rx_buf.buffer, len);
- Emac.rx_buf.buffer = NULL;
- }
- /* Return block back to EMAC-DMA */
- HAL_ETH_BuildRxDescriptors (Emac.h);
- return (len);
- }
- /**
- \fn uint32_t GetRxFrameSize (void)
- \brief Get size of received Ethernet frame.
- \return number of bytes in received frame
- */
- static uint32_t GetRxFrameSize (void) {
- uint32_t len = 0;
- /* Clean and invalidate data cache */
- SCB_CleanInvalidateDCache();
- if(HAL_ETH_GetRxDataBuffer(Emac.h, &Emac.rx_buf) == HAL_OK) {
- if (HAL_ETH_GetRxDataLength (Emac.h, &len) == HAL_OK) {
- return (len);
- }
- }
- /* No data available */
- return (0);
- }
复制代码
下面是我修改的,99Mbps
- /**
- \fn int32_t ReadFrame (uint8_t *frame, uint32_t len)
- \brief Read data of received Ethernet frame.
- \param[in] frame Pointer to frame buffer for data to read into
- \param[in] len Frame buffer length in bytes
- \return number of data bytes read or execution status
- - value >= 0: number of data bytes read
- - value < 0: error occurred, value is execution status as defined with \ref execution_status
- */
- ETH_BufferTypeDef rx_buf;
- static int32_t ReadFrame (uint8_t *frame, uint32_t len) {
- if ((frame == NULL) && (len != 0U)) {
- /* Invalid parameters */
- return ARM_DRIVER_ERROR_PARAMETER;
- }
- if ((Emac.flags & EMAC_FLAG_POWER) == 0U) {
- /* Driver not yet powered */
- return ARM_DRIVER_ERROR;
- }
-
- if (frame != NULL) {
- SCB_CleanInvalidateDCache();
- memcpy (frame, rx_buf.buffer, len);
-
- }
- return (len);
- }
- /**
- \fn uint32_t GetRxFrameSize (void)
- \brief Get size of received Ethernet frame.
- \return number of bytes in received frame
- */
- static uint32_t GetRxFrameSize (void) {
- uint32_t len;
-
- if(HAL_ETH_GetRxDataBuffer(Emac.h, &rx_buf) == HAL_OK)
- {
- HAL_ETH_GetRxDataLength(Emac.h, &len);
- /* Build Rx descriptor to be ready for next data reception */
- HAL_ETH_BuildRxDescriptors(Emac.h);
-
- return (len);
- }
- /* No data available */
- return (0);
- }
复制代码
|
评分
-
查看全部评分
|