| | |
| | | |
| | | /* GPIO Ports Clock Enable */ |
| | | __HAL_RCC_GPIOD_CLK_ENABLE(); |
| | | __HAL_RCC_GPIOB_CLK_ENABLE(); |
| | | __HAL_RCC_GPIOA_CLK_ENABLE(); |
| | | __HAL_RCC_GPIOB_CLK_ENABLE(); |
| | | |
| | | /*Configure GPIO pin Output Level */ |
| | | HAL_GPIO_WritePin(GPIOB, W1Dat_Pin|Relay_Pin, GPIO_PIN_RESET); |
| | |
| | | |
| | | /*Configure GPIO pin Output Level */ |
| | | HAL_GPIO_WritePin(GPIOB, GreenLed_Pin|BlueLed_Pin|SysLed_Pin, GPIO_PIN_SET); |
| | | |
| | | /*Configure GPIO pins : PAPin PAPin */ |
| | | GPIO_InitStruct.Pin = Key1_Pin|Key2_Pin; |
| | | GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; |
| | | GPIO_InitStruct.Pull = GPIO_NOPULL; |
| | | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
| | | |
| | | /*Configure GPIO pin : PtPin */ |
| | | GPIO_InitStruct.Pin = W1Dat_Pin; |
| | |
| | | GPIO_InitStruct.Pull = GPIO_NOPULL; |
| | | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
| | | HAL_GPIO_Init(RedLed_GPIO_Port, &GPIO_InitStruct); |
| | | |
| | | /*Configure GPIO pin : PtPin */ |
| | | GPIO_InitStruct.Pin = Key3_Pin; |
| | | GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; |
| | | GPIO_InitStruct.Pull = GPIO_NOPULL; |
| | | HAL_GPIO_Init(Key3_GPIO_Port, &GPIO_InitStruct); |
| | | |
| | | /* EXTI interrupt init*/ |
| | | HAL_NVIC_SetPriority(EXTI0_IRQn, 2, 0); |
| | | HAL_NVIC_EnableIRQ(EXTI0_IRQn); |
| | | |
| | | HAL_NVIC_SetPriority(EXTI1_IRQn, 2, 0); |
| | | HAL_NVIC_EnableIRQ(EXTI1_IRQn); |
| | | |
| | | HAL_NVIC_SetPriority(EXTI9_5_IRQn, 2, 0); |
| | | HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); |
| | | |
| | | } |
| | | |
| | |
| | | HAL_GPIO_WritePin(Relay_GPIO_Port, Relay_Pin, level); |
| | | } |
| | | |
| | | /* Description: Key1, Key2, Key3 IRQ Handler callback function.*/ |
| | | void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) |
| | | { |
| | | switch( GPIO_Pin ) |
| | | { |
| | | case Key1_Pin: |
| | | blink_led(RedLed, 500); |
| | | break; |
| | | |
| | | case Key2_Pin: |
| | | blink_led(GreenLed, 500); |
| | | break; |
| | | |
| | | case Key3_Pin: |
| | | blink_led(BlueLed, 500); |
| | | break; |
| | | } |
| | | |
| | | } |
| | | |
| | | /* USER CODE END 2 */ |
| | | |
| | | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |