//
// Created by IRIS on 25-2-10.
//

#include "Shutter.h"

#define Shutter_port GPIOD
#define Shutter1_pin GPIO_PIN_1
#define Shutter2_pin GPIO_PIN_0


void Shutter_Init(void)
{
    GPIO_InitTypeDef GPIO_InitStruct = {0};
    __HAL_RCC_GPIOD_CLK_ENABLE();

    GPIO_InitStruct.Pin = Shutter1_pin | Shutter2_pin;
    GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
    HAL_GPIO_Init(Shutter_port, &GPIO_InitStruct);
}

void Shutter_Open(uint8_t shutter)
{
    if (shutter == Shutter_1)
    {
        HAL_GPIO_WritePin(Shutter_port, Shutter1_pin, 1);
    }
    else if (shutter == Shutter_2)
    {
        HAL_GPIO_WritePin(Shutter_port, Shutter2_pin, 1);
    }

}

void Shutter_Close(uint8_t shutter)
{
    if (shutter == Shutter_1)
    {
        HAL_GPIO_WritePin(Shutter_port, Shutter1_pin, 0);
    }
    else if (shutter == Shutter_2)
    {
        HAL_GPIO_WritePin(Shutter_port, Shutter2_pin, 0);
    }
}
