@@ -109,7 +109,7 @@ uint8_t lineSetup[] = {0x00, 0xc2, 0x01, 0x00, 0x00, 0x00, 0x08};
109
109
110
110
#define CDC_POLLING_INTERVAL 1 /* in ms. The max is 65 and the min is 1 */
111
111
112
- TIM_HandleTypeDef TimHandle ;
112
+ stimer_t TimHandle ;
113
113
114
114
volatile uint8_t dfu_request = 0 ;
115
115
/* For a bug in some Linux 64 bit PC we need to delay the reset of the CPU of 500ms seconds */
@@ -162,12 +162,9 @@ USBD_CDC_ItfTypeDef USBD_Interface_fops_FS =
162
162
*/
163
163
static int8_t CDC_Init_FS (void )
164
164
{
165
- /*##-3- Configure the TIM Base generation #################################*/
165
+ /*##-3- Configure and start the TIM Base generation #################################*/
166
166
TIM_Config ();
167
167
168
- /*##-4- Start the TIM Base generation in interrupt mode ####################*/
169
- /* Start Channel1 */
170
- HAL_TIM_Base_Start_IT (& TimHandle );
171
168
/* Set Application Buffers */
172
169
USBD_CDC_SetTxBuffer (& hUSBD_Device_CDC , UserTxBufferFS , 1 );
173
170
USBD_CDC_SetRxBuffer (& hUSBD_Device_CDC , StackRxBufferFS );
@@ -360,25 +357,21 @@ void CDC_enable_TIM_Interrupt(void)
360
357
static void TIM_Config (void )
361
358
{
362
359
/* Set TIMx instance */
363
- TimHandle .Instance = TIM6 ;
364
-
360
+ TimHandle .timer = TIM6 ;
365
361
/* Initialize TIM6 peripheral as follow:
366
362
+ Period = 10000 - 1
367
363
+ Prescaler = ((SystemCoreClock/2)/10000) - 1
368
364
+ ClockDivision = 0
369
365
+ Counter direction = Up
370
366
*/
371
- TimHandle .Init .Period = (CDC_POLLING_INTERVAL * 1000 ) - 1 ;
372
- TimHandle .Init .Prescaler = 84 - 1 ;
373
- TimHandle .Init .ClockDivision = 0 ;
374
- TimHandle .Init .CounterMode = TIM_COUNTERMODE_UP ;
367
+ TimerHandleInit (& TimHandle , (uint16_t )((CDC_POLLING_INTERVAL * 1000 ) - 1 ), (84 - 1 )); //CDC_POLLING_INTERVAL
375
368
376
- timer_attach_interrupt_handle (& TimHandle , HAL_TIM6_PeriodElapsedCallback );
377
- HAL_TIM_Base_Init (& TimHandle );
378
369
HAL_NVIC_SetPriority (TIM6_DAC_IRQn , 6 , 0 );
370
+
371
+ timer_attach_interrupt_handle (& TimHandle .handle , TIM6_PeriodElapsedCallback );
379
372
}
380
373
381
- void HAL_TIM6_PeriodElapsedCallback ( TIM_HandleTypeDef * htim )
374
+ void TIM6_PeriodElapsedCallback ( stimer_t * htim )
382
375
{
383
376
uint8_t status ;
384
377
0 commit comments