Page MenuHomec4science

h_bridge.h
No OneTemporary

File Metadata

Created
Fri, Nov 1, 07:07

h_bridge.h

#ifndef __H_BRIDGE_H
#define __H_BRIDGE_H
#include "../main.h"
#define PWM1_Pin 6
#define PWM1_Port GPIOC
#define PWM2_Pin 7
#define PWM2_Port GPIOC
#define ENB1_Pin 8
#define ENB1_Port GPIOC
#define ENB2_Pin 9
#define ENB2_Port GPIOC
#define nFAULT_Pin GPIO_Pin_15
#define nFAULT_Port GPIOD
#define nSLEEP_Pin GPIO_Pin_14
#define nSLEEP_Port GPIOD
#define PWM_FREQUENCY 30000 // Motor PWM freq. [Hz]
#define PWM_RESOL_SHIFT_DWN 6 // PWM_SCALE = 0xFFFF/2^PWM_RESOL_SHIFT_DWN
#define CURRENT_SCALE_RESOL ((uint32_t)(16-PWM_RESOL_SHIFT_DWN))
#define PWM_TIM_PERIODE ((int16_t)(0xFFFF>>PWM_RESOL_SHIFT_DWN))
#define PWM_TIM_PRESCALER ((int16_t)(SystemCoreClock/APB2_PRESCALER*TIM_MULTIPLIER/PWM_FREQUENCY/PWM_TIM_PERIODE-1))
/** @defgroup H_Bridge Driver / H-bridge
* @brief Driver for the H-bridge of the motor.
*
* The DC motor is supplied by a H-bridge on the HRI board. These power
* electronics are controlled by the microcontroller using a PWM timer.
*
* Call hb_Init() first in the initialization code. Then, call hb_Enable()
* to enable the H-bridge chip (power on), and hb_SetPWM() to set the motor
* voltage.
*
* @addtogroup H_Bridge
* @{
*/
void hb_Init(void);
void hb_Enable(void);
void hb_Disable(void);
void hb_SetPWM(float32_t ratio);
/**
* @}
*/
#endif

Event Timeline