2024-05-11 20:45:59 +08:00
|
|
|
//
|
|
|
|
// 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)
|
|
|
|
{
|
2024-05-13 23:58:29 +08:00
|
|
|
__HAL_TIM_SET_COMPARE(pump->htim, pump->Channel,0);
|
2024-05-11 20:45:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Pump_stop(PumpInstance *pump)
|
|
|
|
{
|
2024-05-13 23:58:29 +08:00
|
|
|
__HAL_TIM_SET_COMPARE(pump->htim, pump->Channel,20000);
|
2024-05-11 20:45:59 +08:00
|
|
|
}
|