/*
 * bsp_motor.c
 *
 *  Created on: 2024Äê11ÔÂ30ÈÕ
 *      Author: 123
 */
#include "bsp_motor.h"

//uint8_t motor_state = 0;
valve_state valve_status = {0};
void BSP_MOTOR_Init(void)
{
    GPIOB_ResetBits(NSLEEP_PIN);
    GPIOB_ModeCfg(NSLEEP_PIN, GPIO_ModeOut_PP_5mA);

    GPIOB_ResetBits(COIL_A);
    GPIOB_ModeCfg(COIL_A, GPIO_ModeOut_PP_5mA);

    GPIOB_ResetBits(COIL_B);
    GPIOB_ModeCfg(COIL_B, GPIO_ModeOut_PP_5mA);

    //VALVE_CLOSE();
}
void VALVE_OPEN(void)
{
    GPIOB_SetBits(NSLEEP_PIN);
    //IN1 + ; IN2 -
    GPIOB_SetBits(COIL_A);
    GPIOB_ResetBits(COIL_B);
    valve_status.motor_state = 1;
}

void VALVE_CLOSE(void)
{
    GPIOB_SetBits(NSLEEP_PIN);
    //IN1 - ; IN2 +
    GPIOB_ResetBits(COIL_A);
    GPIOB_SetBits(COIL_B);
    valve_status.motor_state = 0;
}

void VALVE_STOP(void)
{
    GPIOB_ResetBits(NSLEEP_PIN);
    //IN1 + ; IN2 +
    GPIOB_SetBits(COIL_A);
    GPIOB_SetBits(COIL_B);
}

    
