1
1
/* *
2
2
******************************************************************************
3
- * @file stm32_eth.c
3
+ * @file stm32_eth.cpp
4
4
* @author WI6LABS
5
5
* @version V1.0.0
6
6
* @date 24-May-2017
@@ -96,15 +96,12 @@ static uint8_t DHCP_Started_by_user = 0;
96
96
/* Ethernet link status periodic timer */
97
97
static uint32_t gEhtLinkTickStart = 0 ;
98
98
99
- /* Handler for stimer */
100
- static stimer_t TimHandle ;
101
-
102
99
/* ************************** Function prototype *******************************/
103
100
static void Netif_Config (void );
104
101
static err_t tcp_recv_callback (void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err);
105
102
static err_t tcp_sent_callback (void *arg, struct tcp_pcb *tpcb, u16_t len);
106
103
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 );
108
105
static void TIM_scheduler_Config (void );
109
106
110
107
/* *
@@ -139,12 +136,12 @@ static void Netif_Config(void)
139
136
140
137
/* *
141
138
* @brief Scheduler callback. Call by a timer interrupt.
142
- * @param htim: pointer to stimer_t
139
+ * @param htim: pointer to HardwareTimer
143
140
* @retval None
144
141
*/
145
- static void scheduler_callback (stimer_t * htim )
142
+ static void scheduler_callback (HardwareTimer *HT )
146
143
{
147
- UNUSED (htim );
144
+ UNUSED (HT );
148
145
stm32_eth_scheduler ();
149
146
}
150
147
@@ -156,13 +153,14 @@ static void scheduler_callback(stimer_t *htim)
156
153
*/
157
154
static void TIM_scheduler_Config (void )
158
155
{
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);
161
159
162
160
/* 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 ( );
166
164
}
167
165
168
166
void stm32_eth_init (const uint8_t *mac, const uint8_t *ip, const uint8_t *gw, const uint8_t *netmask)
0 commit comments