Merge pull request #13142 from rajkan01/fix_emac_chrono_warning

EMAC: Fix Chrono compliation warnings
pull/13172/head
Martin Kojtal 2020-06-19 10:06:58 +02:00 committed by GitHub
commit 15b7fe404e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 136 additions and 113 deletions

View File

@ -26,6 +26,7 @@
#include "netsocket/nsapi_types.h"
#include "mbed_shared_queues.h"
using namespace std::chrono;
/********************************************************************************
* Internal data
@ -40,7 +41,7 @@
/** \brief Driver thread priority */
#define THREAD_PRIORITY (osPriorityNormal)
#define PHY_TASK_PERIOD_MS 200
#define PHY_TASK_PERIOD 200ms
fvp_EMAC::fvp_EMAC() : _thread(THREAD_PRIORITY, THREAD_STACKSIZE, NULL, "fvp_emac_thread")
@ -229,7 +230,7 @@ bool fvp_EMAC::power_up()
/* Allow the PHY task to detect the initial link state and set up the proper flags */
ThisThread::sleep_for(10);
_phy_task_handle = mbed::mbed_event_queue()->call_every(PHY_TASK_PERIOD_MS, mbed::callback(this, &fvp_EMAC::phy_task));
_phy_task_handle = mbed::mbed_event_queue()->call_every(PHY_TASK_PERIOD, mbed::callback(this, &fvp_EMAC::phy_task));
return true;
}

View File

@ -48,6 +48,8 @@
#include "kinetis_emac.h"
#include "mbed_power_mgmt.h"
using namespace std::chrono;
enet_handle_t g_handle;
// TX Buffer descriptors
uint8_t *tx_desc_start_addr;
@ -75,7 +77,7 @@ extern "C" void kinetis_init_eth_hardware(void);
/** \brief Driver thread priority */
#define THREAD_PRIORITY (osPriorityNormal)
#define PHY_TASK_PERIOD_MS 200
#define PHY_TASK_PERIOD 200ms
Kinetis_EMAC::Kinetis_EMAC() : xTXDCountSem(ENET_TX_RING_LEN, ENET_TX_RING_LEN), hwaddr()
{
@ -132,10 +134,11 @@ void Kinetis_EMAC::tx_reclaim()
while ((tx_consume_index != tx_produce_index) &&
(!(g_handle.txBdDirty->control & ENET_BUFFDESCRIPTOR_TX_READY_MASK))) {
memory_manager->free(tx_buff[tx_consume_index % ENET_TX_RING_LEN]);
if (g_handle.txBdDirty->control & ENET_BUFFDESCRIPTOR_TX_WRAP_MASK)
if (g_handle.txBdDirty->control & ENET_BUFFDESCRIPTOR_TX_WRAP_MASK) {
g_handle.txBdDirty = g_handle.txBdBase;
else
} else {
g_handle.txBdDirty++;
}
tx_consume_index += 1;
xTXDCountSem.release();
@ -164,8 +167,7 @@ void Kinetis_EMAC::tx_isr()
void Kinetis_EMAC::ethernet_callback(ENET_Type *base, enet_handle_t *handle, enet_event_t event, void *param)
{
Kinetis_EMAC *enet = static_cast<Kinetis_EMAC *>(param);
switch (event)
{
switch (event) {
case kENET_RxEvent:
enet->rx_isr();
break;
@ -191,13 +193,15 @@ bool Kinetis_EMAC::low_level_init_successful()
// Allocate RX descriptors
rx_desc_start_addr = (uint8_t *)calloc(1, sizeof(enet_rx_bd_struct_t) * ENET_RX_RING_LEN + ENET_BUFF_ALIGNMENT);
if(!rx_desc_start_addr)
if (!rx_desc_start_addr) {
return false;
}
// Allocate TX descriptors
tx_desc_start_addr = (uint8_t *)calloc(1, sizeof(enet_tx_bd_struct_t) * ENET_TX_RING_LEN + ENET_BUFF_ALIGNMENT);
if(!tx_desc_start_addr)
if (!tx_desc_start_addr) {
return false;
}
rx_desc_start_addr = (uint8_t *)ENET_ALIGN(rx_desc_start_addr, ENET_BUFF_ALIGNMENT);
tx_desc_start_addr = (uint8_t *)ENET_ALIGN(tx_desc_start_addr, ENET_BUFF_ALIGNMENT);
@ -205,8 +209,9 @@ bool Kinetis_EMAC::low_level_init_successful()
/* Create buffers for each receive BD */
for (i = 0; i < ENET_RX_RING_LEN; i++) {
rx_buff[i] = memory_manager->alloc_heap(ENET_ETH_MAX_FLEN, ENET_BUFF_ALIGNMENT);
if (NULL == rx_buff[i])
if (NULL == rx_buff[i]) {
return false;
}
rx_ptr[i] = (uint32_t *)memory_manager->get_ptr(rx_buff[i]);
}
@ -507,7 +512,7 @@ bool Kinetis_EMAC::power_up()
/* Allow the PHY task to detect the initial link state and set up the proper flags */
osDelay(10);
phy_task_handle = mbed::mbed_event_queue()->call_every(PHY_TASK_PERIOD_MS, mbed::callback(this, &Kinetis_EMAC::phy_task));
phy_task_handle = mbed::mbed_event_queue()->call_every(PHY_TASK_PERIOD, mbed::callback(this, &Kinetis_EMAC::phy_task));
return true;
}
@ -585,13 +590,15 @@ void Kinetis_EMAC::set_memory_manager(EMACMemoryManager &mem_mngr)
}
Kinetis_EMAC &Kinetis_EMAC::get_instance() {
Kinetis_EMAC &Kinetis_EMAC::get_instance()
{
static Kinetis_EMAC emac;
return emac;
}
// Weak so a module can override
MBED_WEAK EMAC &EMAC::get_default_instance() {
MBED_WEAK EMAC &EMAC::get_default_instance()
{
return Kinetis_EMAC::get_instance();
}

View File

@ -27,6 +27,8 @@
#include "gd32xx_emac.h"
using namespace std::chrono;
/* \brief Flags for worker thread */
#define _ENET_FLAG_RX (1)
@ -34,7 +36,7 @@
#define _THREAD_STACKSIZE (512)
#define _THREAD_PRIORITY (osPriorityHigh)
#define _PHY_TASK_PERIOD_MS (200)
#define _PHY_TASK_PERIOD (200ms)
#define _ENET_HW_ADDR_SIZE (6)
#define _ENET_MTU_SIZE (1500)
@ -345,7 +347,7 @@ bool GD32_EMAC::power_up()
/* Worker thread */
rx_thread = create_new_thread("gd32_emac_thread", &GD32_EMAC::thread_function, this, _THREAD_STACKSIZE, _THREAD_PRIORITY, &rx_thread_cb);
phy_task_handle = mbed::mbed_event_queue()->call_every(_PHY_TASK_PERIOD_MS, mbed::callback(this, &GD32_EMAC::phy_task));
phy_task_handle = mbed::mbed_event_queue()->call_every(_PHY_TASK_PERIOD, mbed::callback(this, &GD32_EMAC::phy_task));
/* Allow the PHY task to detect the initial link state and set up the proper flags */
osDelay(10);

View File

@ -36,6 +36,8 @@
#include "numaker_emac.h"
#include "numaker_eth_hal.h"
using namespace std::chrono;
/********************************************************************************
*
********************************************************************************/
@ -53,7 +55,7 @@ extern "C" void numaker_eth_rx_next(void);
/** \brief Driver thread priority */
#define THREAD_PRIORITY (osPriorityNormal)
#define PHY_TASK_PERIOD_MS 200
#define PHY_TASK_PERIOD 200ms
NUMAKER_EMAC::NUMAKER_EMAC() : thread(0), hwaddr()
{
@ -331,7 +333,7 @@ bool NUMAKER_EMAC::power_up()
/* PHY monitoring task */
phy_state = PHY_UNLINKED_STATE;
phy_task_handle = mbed::mbed_event_queue()->call_every(PHY_TASK_PERIOD_MS, mbed::callback(this, &NUMAKER_EMAC::phy_task));
phy_task_handle = mbed::mbed_event_queue()->call_every(PHY_TASK_PERIOD, mbed::callback(this, &NUMAKER_EMAC::phy_task));
/* Allow the PHY task to detect the initial link state and set up the proper flags */
osDelay(10);

View File

@ -48,6 +48,8 @@
#include "imx_emac.h"
#include "mbed_power_mgmt.h"
using namespace std::chrono;
enet_handle_t g_handle;
// RX packet buffer pointers
emac_mem_buf_t *rx_buff[ENET_RX_RING_LEN];
@ -71,7 +73,7 @@ extern "C" void kinetis_init_eth_hardware(void);
/** \brief Driver thread priority */
#define THREAD_PRIORITY (osPriorityNormal)
#define PHY_TASK_PERIOD_MS 200
#define PHY_TASK_PERIOD 200ms
Kinetis_EMAC::Kinetis_EMAC() : xTXDCountSem(ENET_TX_RING_LEN, ENET_TX_RING_LEN), hwaddr()
{
@ -134,10 +136,11 @@ void Kinetis_EMAC::tx_reclaim()
while ((tx_consume_index != tx_produce_index) &&
(!(g_handle.txBdDirty[0]->control & ENET_BUFFDESCRIPTOR_TX_READY_MASK))) {
memory_manager->free(tx_buff[tx_consume_index % ENET_TX_RING_LEN]);
if (g_handle.txBdDirty[0]->control & ENET_BUFFDESCRIPTOR_TX_WRAP_MASK)
if (g_handle.txBdDirty[0]->control & ENET_BUFFDESCRIPTOR_TX_WRAP_MASK) {
g_handle.txBdDirty[0] = g_handle.txBdBase[0];
else
} else {
g_handle.txBdDirty[0]++;
}
tx_consume_index += 1;
xTXDCountSem.release();
@ -166,8 +169,7 @@ void Kinetis_EMAC::tx_isr()
void Kinetis_EMAC::ethernet_callback(ENET_Type *base, enet_handle_t *handle, enet_event_t event, void *param)
{
Kinetis_EMAC *enet = static_cast<Kinetis_EMAC *>(param);
switch (event)
{
switch (event) {
case kENET_RxEvent:
enet->rx_isr();
break;
@ -198,8 +200,9 @@ bool Kinetis_EMAC::low_level_init_successful()
for (i = 0; i < ENET_RX_RING_LEN; i++) {
rx_buff[i] = memory_manager->alloc_heap(ENET_ALIGN(ENET_ETH_MAX_FLEN, ENET_BUFF_ALIGNMENT),
ENET_BUFF_ALIGNMENT);
if (NULL == rx_buff[i])
if (NULL == rx_buff[i]) {
return false;
}
rx_ptr[i] = (uint32_t *)memory_manager->get_ptr(rx_buff[i]);
SCB_InvalidateDCache_by_Addr(rx_ptr[i], ENET_ALIGN(ENET_ETH_MAX_FLEN, ENET_BUFF_ALIGNMENT));
@ -511,7 +514,7 @@ bool Kinetis_EMAC::power_up()
/* Allow the PHY task to detect the initial link state and set up the proper flags */
osDelay(10);
phy_task_handle = mbed::mbed_event_queue()->call_every(PHY_TASK_PERIOD_MS, mbed::callback(this, &Kinetis_EMAC::phy_task));
phy_task_handle = mbed::mbed_event_queue()->call_every(PHY_TASK_PERIOD, mbed::callback(this, &Kinetis_EMAC::phy_task));
return true;
}
@ -589,13 +592,15 @@ void Kinetis_EMAC::set_memory_manager(EMACMemoryManager &mem_mngr)
}
Kinetis_EMAC &Kinetis_EMAC::get_instance() {
Kinetis_EMAC &Kinetis_EMAC::get_instance()
{
static Kinetis_EMAC emac;
return emac;
}
// Weak so a module can override
MBED_WEAK EMAC &EMAC::get_default_instance() {
MBED_WEAK EMAC &EMAC::get_default_instance()
{
return Kinetis_EMAC::get_instance();
}

View File

@ -31,6 +31,8 @@
#include "lpc546xx_emac_config.h"
#include "lpc546xx_emac.h"
using namespace std::chrono;
enet_handle_t g_handle;
// RX packet buffer pointers
emac_mem_buf_t *rx_buff[ENET_RX_RING_LEN];
@ -54,7 +56,7 @@ extern "C" void lpc546xx_init_eth_hardware(void);
/** \brief Driver thread priority */
#define THREAD_PRIORITY (osPriorityNormal)
#define PHY_TASK_PERIOD_MS 200
#define PHY_TASK_PERIOD 200ms
LPC546XX_EMAC::LPC546XX_EMAC() : xTXDCountSem(ENET_TX_RING_LEN, ENET_TX_RING_LEN), hwaddr()
{
@ -143,8 +145,7 @@ void LPC546XX_EMAC::ethernet_callback(ENET_Type *base, enet_handle_t *handle, en
{
LPC546XX_EMAC *enet = static_cast<LPC546XX_EMAC *>(param);
switch (event)
{
switch (event) {
case kENET_RxIntEvent:
enet->rx_isr();
break;
@ -217,8 +218,9 @@ bool LPC546XX_EMAC::low_level_init_successful()
/* Create buffers for each receive BD */
for (i = 0; i < ENET_RX_RING_LEN; i++) {
rx_buff[i] = memory_manager->alloc_heap(buffCfg.rxBuffSizeAlign, ENET_BUFF_ALIGNMENT);
if (NULL == rx_buff[i])
if (NULL == rx_buff[i]) {
return false;
}
rx_ptr[i] = (uint32_t)memory_manager->get_ptr(rx_buff[i]);
}
@ -364,8 +366,7 @@ void LPC546XX_EMAC::packet_rx()
}
/* Set command for rx when it is suspend. */
if (suspend)
{
if (suspend) {
ENET->DMA_CH[0].DMA_CHX_RXDESC_TAIL_PTR = ENET->DMA_CH[0].DMA_CHX_RXDESC_TAIL_PTR;
}
}
@ -438,7 +439,8 @@ bool LPC546XX_EMAC::link_out(emac_mem_buf_t *buf)
#define STATE_UNKNOWN (-1)
int phy_link_status(void) {
int phy_link_status(void)
{
bool connection_status;
uint32_t phyAddr = 0;
@ -497,7 +499,7 @@ bool LPC546XX_EMAC::power_up()
prev_state.speed = (phy_speed_t)STATE_UNKNOWN;
prev_state.duplex = (phy_duplex_t)STATE_UNKNOWN;
phy_task_handle = mbed::mbed_event_queue()->call_every(PHY_TASK_PERIOD_MS, mbed::callback(this, &LPC546XX_EMAC::phy_task));
phy_task_handle = mbed::mbed_event_queue()->call_every(PHY_TASK_PERIOD, mbed::callback(this, &LPC546XX_EMAC::phy_task));
/* Allow the PHY task to detect the initial link state and set up the proper flags */
osDelay(10);
@ -583,13 +585,15 @@ void LPC546XX_EMAC::set_memory_manager(EMACMemoryManager &mem_mngr)
}
LPC546XX_EMAC &LPC546XX_EMAC::get_instance() {
LPC546XX_EMAC &LPC546XX_EMAC::get_instance()
{
static LPC546XX_EMAC emac;
return emac;
}
// Weak so a module can override
MBED_WEAK EMAC &EMAC::get_default_instance() {
MBED_WEAK EMAC &EMAC::get_default_instance()
{
return LPC546XX_EMAC::get_instance();
}

View File

@ -52,13 +52,15 @@
#include "lwip/api.h"
#endif
using namespace std::chrono;
/* \brief Flags for worker thread */
#define FLAG_RX 1
/** \brief Driver thread priority */
#define THREAD_PRIORITY (osPriorityHigh)
#define PHY_TASK_PERIOD_MS 200
#define PHY_TASK_PERIOD 200ms
#define STM_HWADDR_SIZE (6)
#define STM_ETH_MTU_SIZE 1500
@ -890,7 +892,7 @@ bool STM32_EMAC::power_up()
#endif
phy_task_handle = mbed::mbed_event_queue()->call_every(PHY_TASK_PERIOD_MS, mbed::callback(this, &STM32_EMAC::phy_task));
phy_task_handle = mbed::mbed_event_queue()->call_every(PHY_TASK_PERIOD, mbed::callback(this, &STM32_EMAC::phy_task));
#if defined (STM32F767xx) || defined (STM32F769xx) || defined (STM32F777xx)\
|| defined (STM32F779xx)