TM STM32F4xx Libraries  v1.0.0
Libraries for STM32F4xx devices from Tilen Majerle
tm_stm32f4_servo.h
1 
30 #ifndef TM_SERVO_H
31 #define TM_SERVO_H 110
32 
33 /* C++ detection */
34 #ifdef __cplusplus
35 extern C {
36 #endif
37 
77 #include "stm32f4xx.h"
78 #include "stm32f4xx_rcc.h"
79 #include "stm32f4xx_gpio.h"
80 #include "stm32f4xx_tim.h"
81 #include "defines.h"
82 #include "tm_stm32f4_pwm.h"
83 #include "tm_stm32f4_timer_properties.h"
84 
94 #ifndef SERVO_MICROS_MIN
95 #define SERVO_MICROS_MIN 1000
96 #endif
97 
101 #ifndef SERVO_MICROS_MAX
102 #define SERVO_MICROS_MAX 2000
103 #endif
104 
118 typedef struct {
120  TIM_TypeDef* TIM;
123  float Degrees;
124  uint16_t Micros;
125 } TM_SERVO_t;
126 
130 typedef enum {
134 
153 TM_SERVO_Result_t TM_SERVO_Init(TM_SERVO_t* ServoStruct, TIM_TypeDef* TIMx, TM_PWM_Channel_t PWMChannel, TM_PWM_PinsPack_t Pinspack);
154 
162 TM_SERVO_Result_t TM_SERVO_SetDegrees(TM_SERVO_t* ServoStruct, float degrees);
163 
170 TM_SERVO_Result_t TM_SERVO_SetMicros(TM_SERVO_t* ServoStruct, uint16_t micros);
171 
184 /* C++ detection */
185 #ifdef __cplusplus
186 }
187 #endif
188 
189 #endif
PWM Timer data.
Definition: tm_stm32f4_pwm.h:142
Servo structure.
Definition: tm_stm32f4_servo.h:118
TM_SERVO_Result_t TM_SERVO_SetDegrees(TM_SERVO_t *ServoStruct, float degrees)
Set rotation degrees for servo.
Definition: tm_stm32f4_servo.h:131
TM_SERVO_Result_t TM_SERVO_Init(TM_SERVO_t *ServoStruct, TIM_TypeDef *TIMx, TM_PWM_Channel_t PWMChannel, TM_PWM_PinsPack_t Pinspack)
Initializes TIM and PWM for servo motor purpose.
TM_PWM_PinsPack_t Pinspack
Definition: tm_stm32f4_servo.h:122
TM_PWM_PinsPack_t
Pin selected for corresponding channel on specific channel.
Definition: tm_stm32f4_pwm.h:167
TM_PWM_Channel_t Channel
Definition: tm_stm32f4_servo.h:121
Definition: tm_stm32f4_servo.h:132
TM_PWM_TIM_t PWM
Definition: tm_stm32f4_servo.h:119
uint16_t Micros
Definition: tm_stm32f4_servo.h:124
float Degrees
Definition: tm_stm32f4_servo.h:123
TM_SERVO_Result_t
Results enumeration.
Definition: tm_stm32f4_servo.h:130
TM_SERVO_Result_t TM_SERVO_SetMicros(TM_SERVO_t *ServoStruct, uint16_t micros)
Sets pulse length in microseconds.
TM_PWM_Channel_t
Channel selection for PWM on specific timer.
Definition: tm_stm32f4_pwm.h:157
TIM_TypeDef * TIM
Definition: tm_stm32f4_servo.h:120