HRI board firmware v2.1 Microcontroller firmware of the board used during the HRI labs.

callback_timers.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2017 EPFL-LSRO (Laboratoire de Systemes Robotiques).
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #ifndef __CALLBACK_TIMERS_H
18 #define __CALLBACK_TIMERS_H
19
20 #include "../main.h"
21
22 typedef void (*cbt_PeriodicTaskFunc)(void);
23
24 // TIMX_PERIOD is the clock divider at the input of the timers.
25 // So, the timer will increment its counter, every TIMX_PERIOD ticks of the system clock (168 MHz).
26 #define TIM10_PRESCALER ((uint16_t)(SystemCoreClock/APB2_PRESCALER*TIM_MULTIPLIER/1000000-1)) // CLK_CNT = 1[us] (current loop)
27 #define TIM6_PRESCALER ((uint16_t)(SystemCoreClock/APB1_PRESCALER*TIM_MULTIPLIER/1000000-1)) // CLK_CNT = 1[us] (control loop)
28 #define TIM7_PRESCALER ((uint16_t)(SystemCoreClock/APB1_PRESCALER*TIM_MULTIPLIER/1000000-1)) // CLK_CNT = 1[us] (data loop)
29
45 void cbt_Init(void);
46 void cbt_SetCurrentLoopTimer(cbt_PeriodicTaskFunc f, uint32_t period);
47 void cbt_SetHapticControllerTimer(cbt_PeriodicTaskFunc f, uint32_t period);
48 void cbt_SetCommLoopTimer(cbt_PeriodicTaskFunc f, uint32_t period);
49 void cbt_SetHapticControllerPeriod(uint32_t period);
50 void cbt_SetCommLoopPeriod(uint32_t period);
51 uint32_t cbt_GetCurrentLoopPeriod(void);
52 uint32_t cbt_GetHapticControllerPeriod(void);
53 uint32_t cbt_GetCommLoopPeriod(void);
54
59 #endif
cbt_Init
void cbt_Init(void)
Initialize the timers to call an interrupt routine periodically.
Definition: callback_timers.c:39
cbt_SetHapticControllerPeriod
void cbt_SetHapticControllerPeriod(uint32_t period)
Set the period of the position loop.
Definition: callback_timers.c:211
cbt_GetCommLoopPeriod
uint32_t cbt_GetCommLoopPeriod(void)
Get the period of the communication loop.
Definition: callback_timers.c:249
cbt_GetCurrentLoopPeriod
uint32_t cbt_GetCurrentLoopPeriod(void)
Get the period of the current loop.
Definition: callback_timers.c:231
cbt_PeriodicTaskFunc
void(* cbt_PeriodicTaskFunc)(void)
Definition: callback_timers.h:22
cbt_SetCommLoopPeriod
void cbt_SetCommLoopPeriod(uint32_t period)
Set the period of the communication loop.
Definition: callback_timers.c:221
cbt_SetCommLoopTimer
void cbt_SetCommLoopTimer(cbt_PeriodicTaskFunc f, uint32_t period)
Set the function to call periodically by the timer 7.
Definition: callback_timers.c:83
cbt_SetCurrentLoopTimer
void cbt_SetCurrentLoopTimer(cbt_PeriodicTaskFunc f, uint32_t period)
Set the function to call periodically by the timer 1.
Definition: callback_timers.c:57
cbt_SetHapticControllerTimer
void cbt_SetHapticControllerTimer(cbt_PeriodicTaskFunc f, uint32_t period)
Set the function to call periodically by the timer 6.
Definition: callback_timers.c:70
cbt_GetHapticControllerPeriod
uint32_t cbt_GetHapticControllerPeriod(void)
Get the period of the position loop.
Definition: callback_timers.c:240