engineering/modules/motor/Air_pump/air_pump.c

31 lines
629 B
C

//
// Created by SJQ on 2024/5/11.
//
#include "air_pump.h"
#include "stdlib.h"
#include "memory.h"
// 通过此函数注册一个舵机
PumpInstance *PumpInit(TIM_HandleTypeDef *htim,uint32_t Channel) {
PumpInstance *pump = (PumpInstance *) malloc(sizeof(PumpInstance));
memset(pump, 0, sizeof(PumpInstance));
pump->htim = htim;
pump->Channel = Channel;
HAL_TIM_PWM_Start(htim, Channel);
return pump;
}
void Pump_open(PumpInstance *pump)
{
__HAL_TIM_SET_COMPARE(pump->htim, pump->Channel,0);
}
void Pump_stop(PumpInstance *pump)
{
__HAL_TIM_SET_COMPARE(pump->htim, pump->Channel,20000);
}