12345678910111213141516171819202122232425262728293031323334353637383940 |
- #include "light_driver.h"
- void LightDriver_Init(void)
- {
- GPIO_InitTypeDef GPIO_InitStruct;
- /* GPIO Ports Clock Enable */
- __HAL_RCC_GPIOA_CLK_ENABLE();
- __HAL_RCC_GPIOB_CLK_ENABLE();
-
- /*Configure GPIO pin Output Level */
- HAL_GPIO_WritePin(LIGHT_F_GPIO_Port, LIGHT_F_Pin, GPIO_PIN_RESET);
- HAL_GPIO_WritePin(LIGHT_B_GPIO_Port, LIGHT_B_Pin, GPIO_PIN_RESET);
-
- /*Configure GPIO pins : PBPin PBPin */
- GPIO_InitStruct.Pin = LIGHT_F_Pin;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- HAL_GPIO_Init(LIGHT_F_GPIO_Port, &GPIO_InitStruct);
-
- /*Configure GPIO pins : PAPin PAPin */
- GPIO_InitStruct.Pin = LIGHT_B_Pin;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- HAL_GPIO_Init(LIGHT_B_GPIO_Port, &GPIO_InitStruct);
- }
- void LightDriver_Process(MC_LightSwitch_Struct_t LightSwitchCode)
- {
- if(LightSwitchCode == MC_LightSwitch_ON)
- {
- HAL_GPIO_WritePin(LIGHT_F_GPIO_Port, LIGHT_F_Pin, GPIO_PIN_SET);
- HAL_GPIO_WritePin(LIGHT_B_GPIO_Port, LIGHT_B_Pin, GPIO_PIN_SET);
- }
- else if(LightSwitchCode == MC_LightSwitch_OFF)
- {
- HAL_GPIO_WritePin(LIGHT_F_GPIO_Port, LIGHT_F_Pin, GPIO_PIN_RESET);
- HAL_GPIO_WritePin(LIGHT_B_GPIO_Port, LIGHT_B_Pin, GPIO_PIN_RESET);
- }
- }
|