mirror of https://github.com/ARMmbed/mbed-os.git
Changed STM emac driver to loop RX frame reading
parent
953f1b615a
commit
de72090d26
|
@ -237,26 +237,27 @@ error:
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should allocate a a contiguous memory buffer and transfer the bytes of the incoming
|
* Should allocate a contiguous memory buffer and transfer the bytes of the incoming
|
||||||
* packet to the buffer.
|
* packet to the buffer.
|
||||||
*
|
*
|
||||||
* @return a memory buffer filled with the received packet (including MAC header)
|
* @param buf If a frame was received and the memory buffer allocation was successful, a memory
|
||||||
* NULL on memory error
|
* buffer filled with the received packet (including MAC header)
|
||||||
|
* @return negative value when no more frames,
|
||||||
|
* zero when frame is received
|
||||||
*/
|
*/
|
||||||
emac_mem_buf_t *STM32_EMAC::low_level_input()
|
int STM32_EMAC::low_level_input(emac_mem_buf_t **buf)
|
||||||
{
|
{
|
||||||
uint16_t len = 0;
|
uint16_t len = 0;
|
||||||
uint8_t *buffer;
|
uint8_t *buffer;
|
||||||
__IO ETH_DMADescTypeDef *dmarxdesc;
|
__IO ETH_DMADescTypeDef *dmarxdesc;
|
||||||
uint32_t bufferoffset = 0;
|
uint32_t bufferoffset = 0;
|
||||||
uint32_t byteslefttocopy = 0;
|
uint32_t byteslefttocopy = 0;
|
||||||
emac_mem_buf_t *buf = 0;
|
|
||||||
emac_mem_buf_t *q;
|
emac_mem_buf_t *q;
|
||||||
uint32_t payloadoffset = 0;
|
uint32_t payloadoffset = 0;
|
||||||
|
|
||||||
/* get received frame */
|
/* get received frame */
|
||||||
if (HAL_ETH_GetReceivedFrame(&EthHandle) != HAL_OK) {
|
if (HAL_ETH_GetReceivedFrame_IT(&EthHandle) != HAL_OK) {
|
||||||
return NULL;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Obtain the size of the packet and put it into the "len" variable. */
|
/* Obtain the size of the packet and put it into the "len" variable. */
|
||||||
|
@ -268,13 +269,13 @@ emac_mem_buf_t *STM32_EMAC::low_level_input()
|
||||||
|
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
/* Allocate a memory buffer chain from buffer pool */
|
/* Allocate a memory buffer chain from buffer pool */
|
||||||
buf = memory_manager->alloc_pool(len, 0);
|
*buf = memory_manager->alloc_pool(len, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf != NULL) {
|
if (*buf != NULL) {
|
||||||
dmarxdesc = EthHandle.RxFrameInfos.FSRxDesc;
|
dmarxdesc = EthHandle.RxFrameInfos.FSRxDesc;
|
||||||
bufferoffset = 0;
|
bufferoffset = 0;
|
||||||
for (q = buf; q != NULL; q = memory_manager->get_next(q)) {
|
for (q = *buf; q != NULL; q = memory_manager->get_next(q)) {
|
||||||
byteslefttocopy = memory_manager->get_len(q);
|
byteslefttocopy = memory_manager->get_len(q);
|
||||||
payloadoffset = 0;
|
payloadoffset = 0;
|
||||||
|
|
||||||
|
@ -316,7 +317,7 @@ emac_mem_buf_t *STM32_EMAC::low_level_input()
|
||||||
/* Resume DMA reception */
|
/* Resume DMA reception */
|
||||||
EthHandle.Instance->DMARPDR = 0;
|
EthHandle.Instance->DMARPDR = 0;
|
||||||
}
|
}
|
||||||
return buf;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -325,16 +326,17 @@ emac_mem_buf_t *STM32_EMAC::low_level_input()
|
||||||
*/
|
*/
|
||||||
void STM32_EMAC::packet_rx()
|
void STM32_EMAC::packet_rx()
|
||||||
{
|
{
|
||||||
emac_mem_buf_t *p;
|
|
||||||
|
|
||||||
/* move received packet into a new buf */
|
/* move received packet into a new buf */
|
||||||
p = low_level_input();
|
while (1) {
|
||||||
if (p == NULL) {
|
emac_mem_buf_t *p = NULL;
|
||||||
return;
|
if (low_level_input(&p) < 0) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
if (p) {
|
||||||
emac_link_input_cb(p);
|
emac_link_input_cb(p);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** \brief Worker thread.
|
/** \brief Worker thread.
|
||||||
*
|
*
|
||||||
|
|
|
@ -154,7 +154,7 @@ public:
|
||||||
private:
|
private:
|
||||||
bool low_level_init_successful();
|
bool low_level_init_successful();
|
||||||
void packet_rx();
|
void packet_rx();
|
||||||
emac_mem_buf_t *low_level_input();
|
int low_level_input(emac_mem_buf_t **buf);
|
||||||
static void thread_function(void* pvParameters);
|
static void thread_function(void* pvParameters);
|
||||||
static void rmii_watchdog_thread_function(void* pvParameters);
|
static void rmii_watchdog_thread_function(void* pvParameters);
|
||||||
void phy_task();
|
void phy_task();
|
||||||
|
|
Loading…
Reference in New Issue