V7配套的CMSIS-Driver驱动,将对下面的两个函数做个条件编译,可以选择官方的,也可以选择我修正的。
下面是官方的,速度94Mbps
/**
fn int32_t ReadFrame (uint8_t *frame, uint32_t len)
rief 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
eturn 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
ef 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)
rief Get size of received Ethernet frame.
eturn 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);
} |