Skip to content

Commit 7120886

Browse files
ABOSTMfpistm
authored andcommitted
Update STM32duino_STM32Ethernet library to use HardwareTimer library
1 parent 72c849f commit 7120886

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

src/utility/stm32_eth.c renamed to src/utility/stm32_eth.cpp

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
******************************************************************************
3-
* @file stm32_eth.c
3+
* @file stm32_eth.cpp
44
* @author WI6LABS
55
* @version V1.0.0
66
* @date 24-May-2017
@@ -96,15 +96,12 @@ static uint8_t DHCP_Started_by_user = 0;
9696
/* Ethernet link status periodic timer */
9797
static uint32_t gEhtLinkTickStart = 0;
9898

99-
/* Handler for stimer */
100-
static stimer_t TimHandle;
101-
10299
/*************************** Function prototype *******************************/
103100
static void Netif_Config(void);
104101
static err_t tcp_recv_callback(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err);
105102
static err_t tcp_sent_callback(void *arg, struct tcp_pcb *tpcb, u16_t len);
106103
static void tcp_err_callback(void *arg, err_t err);
107-
static void scheduler_callback(stimer_t *htim);
104+
static void scheduler_callback(HardwareTimer *HT);
108105
static void TIM_scheduler_Config(void);
109106

110107
/**
@@ -139,12 +136,12 @@ static void Netif_Config(void)
139136

140137
/**
141138
* @brief Scheduler callback. Call by a timer interrupt.
142-
* @param htim: pointer to stimer_t
139+
* @param htim: pointer to HardwareTimer
143140
* @retval None
144141
*/
145-
static void scheduler_callback(stimer_t *htim)
142+
static void scheduler_callback(HardwareTimer *HT)
146143
{
147-
UNUSED(htim);
144+
UNUSED(HT);
148145
stm32_eth_scheduler();
149146
}
150147

@@ -156,13 +153,14 @@ static void scheduler_callback(stimer_t *htim)
156153
*/
157154
static void TIM_scheduler_Config(void)
158155
{
159-
/* Set TIMx instance. */
160-
TimHandle.timer = DEFAULT_ETHERNET_TIMER;
156+
/* Configure HardwareTimer */
157+
HardwareTimer *EthTim = new HardwareTimer(DEFAULT_ETHERNET_TIMER);
158+
EthTim->setMode(1, TIMER_OUTPUT_COMPARE);
161159

162160
/* Timer set to 1ms */
163-
TimerHandleInit(&TimHandle, (uint16_t)(1000 - 1), ((uint32_t)(getTimerClkFreq(DEFAULT_ETHERNET_TIMER) / (1000000)) - 1));
164-
165-
attachIntHandle(&TimHandle, scheduler_callback);
161+
EthTim->setOverflow(1000, MICROSEC_FORMAT);
162+
EthTim->attachInterrupt(scheduler_callback);
163+
EthTim->resume();
166164
}
167165

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

0 commit comments

Comments
 (0)