Skip to content

Update STM32duino_STM32Ethernet library to use HardwareTimer library #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions src/utility/stm32_eth.c → src/utility/stm32_eth.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
******************************************************************************
* @file stm32_eth.c
* @file stm32_eth.cpp
* @author WI6LABS
* @version V1.0.0
* @date 24-May-2017
Expand Down Expand Up @@ -96,15 +96,12 @@ static uint8_t DHCP_Started_by_user = 0;
/* Ethernet link status periodic timer */
static uint32_t gEhtLinkTickStart = 0;

/* Handler for stimer */
static stimer_t TimHandle;

/*************************** Function prototype *******************************/
static void Netif_Config(void);
static err_t tcp_recv_callback(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err);
static err_t tcp_sent_callback(void *arg, struct tcp_pcb *tpcb, u16_t len);
static void tcp_err_callback(void *arg, err_t err);
static void scheduler_callback(stimer_t *htim);
static void scheduler_callback(HardwareTimer *HT);
static void TIM_scheduler_Config(void);

/**
Expand Down Expand Up @@ -139,12 +136,12 @@ static void Netif_Config(void)

/**
* @brief Scheduler callback. Call by a timer interrupt.
* @param htim: pointer to stimer_t
* @param htim: pointer to HardwareTimer
* @retval None
*/
static void scheduler_callback(stimer_t *htim)
static void scheduler_callback(HardwareTimer *HT)
{
UNUSED(htim);
UNUSED(HT);
stm32_eth_scheduler();
}

Expand All @@ -156,13 +153,14 @@ static void scheduler_callback(stimer_t *htim)
*/
static void TIM_scheduler_Config(void)
{
/* Set TIMx instance. */
TimHandle.timer = DEFAULT_ETHERNET_TIMER;
/* Configure HardwareTimer */
HardwareTimer *EthTim = new HardwareTimer(DEFAULT_ETHERNET_TIMER);
EthTim->setMode(1, TIMER_OUTPUT_COMPARE);

/* Timer set to 1ms */
TimerHandleInit(&TimHandle, (uint16_t)(1000 - 1), ((uint32_t)(getTimerClkFreq(DEFAULT_ETHERNET_TIMER) / (1000000)) - 1));

attachIntHandle(&TimHandle, scheduler_callback);
EthTim->setOverflow(1000, MICROSEC_FORMAT);
EthTim->attachInterrupt(scheduler_callback);
EthTim->resume();
}

void stm32_eth_init(const uint8_t *mac, const uint8_t *ip, const uint8_t *gw, const uint8_t *netmask)
Expand Down