mirror of
				https://github.com/IcedRooibos/py32f0-template.git
				synced 2025-10-30 17:32:05 -07:00 
			
		
		
		
	
		
			
				
	
	
		
			86 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			86 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| #include "py32f0xx_bsp_led.h"
 | |
| 
 | |
| 
 | |
| GPIO_TypeDef* LED_PORT[LEDn] = {LED3_GPIO_PORT};
 | |
| const uint16_t LED_PIN[LEDn] = {LED3_PIN};
 | |
| 
 | |
| 
 | |
| /**
 | |
|   * @brief  Configures LED GPIO.
 | |
|   * @param  Led Specifies the Led to be configured.
 | |
|   *         This parameter can be one of following parameters:
 | |
|   *         @arg  LED3
 | |
|   * @retval None
 | |
|   */
 | |
| void BSP_LED_Init(Led_TypeDef Led)
 | |
| {
 | |
|   GPIO_InitTypeDef  GPIO_InitStruct;
 | |
| 
 | |
|   /* Enable the GPIO_LED Clock */
 | |
|   LEDx_GPIO_CLK_ENABLE(Led);
 | |
| 
 | |
|   /* Configure the GPIO_LED pin */
 | |
|   GPIO_InitStruct.Pin = LED_PIN[Led];
 | |
|   GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
 | |
|   GPIO_InitStruct.Pull = GPIO_NOPULL;
 | |
|   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
 | |
| 
 | |
|   HAL_GPIO_Init(LED_PORT[Led], &GPIO_InitStruct);
 | |
|   HAL_GPIO_WritePin(LED_PORT[Led], LED_PIN[Led], GPIO_PIN_SET);
 | |
| }
 | |
| 
 | |
| /**
 | |
|   * @brief  DeInitialize LED GPIO.
 | |
|   * @param  Led Specifies the Led to be deconfigured.
 | |
|   *         This parameter can be one of the following values:
 | |
|   *         @arg  LED3
 | |
|   * @note BSP_LED_DeInit() does not disable the GPIO clock
 | |
|   * @retval None
 | |
|   */
 | |
| void BSP_LED_DeInit(Led_TypeDef Led)
 | |
| {
 | |
|   GPIO_InitTypeDef  GPIO_InitStruct;
 | |
| 
 | |
|   /* Turn off LED */
 | |
|   HAL_GPIO_WritePin(LED_PORT[Led], LED_PIN[Led], GPIO_PIN_RESET);
 | |
|   /* DeInit the GPIO_LED pin */
 | |
|   GPIO_InitStruct.Pin = LED_PIN[Led];
 | |
|   HAL_GPIO_DeInit(LED_PORT[Led], GPIO_InitStruct.Pin);
 | |
| }
 | |
| 
 | |
| /**
 | |
|   * @brief  Turns selected LED On.
 | |
|   * @param  Led Specifies the Led to be set on.
 | |
|   *   This parameter can be one of following parameters:
 | |
|   *   @arg  LED3
 | |
|   * @retval None
 | |
|   */
 | |
| void BSP_LED_On(Led_TypeDef Led)
 | |
| {
 | |
|   HAL_GPIO_WritePin(LED_PORT[Led], LED_PIN[Led], GPIO_PIN_RESET);
 | |
| }
 | |
| 
 | |
| /**
 | |
|   * @brief  Turns selected LED Off.
 | |
|   * @param  Led Specifies the Led to be set off.
 | |
|   *   This parameter can be one of following parameters:
 | |
|   *            @arg  LED3
 | |
|   * @retval None
 | |
|   */
 | |
| void BSP_LED_Off(Led_TypeDef Led)
 | |
| {
 | |
|   HAL_GPIO_WritePin(LED_PORT[Led], LED_PIN[Led], GPIO_PIN_SET);
 | |
| }
 | |
| 
 | |
| /**
 | |
|   * @brief  Toggles the selected LED.
 | |
|   * @param  Led Specifies the Led to be toggled.
 | |
|   *   This parameter can be one of following parameters:
 | |
|   *            @arg  LED3
 | |
|   * @retval None
 | |
|   */
 | |
| void BSP_LED_Toggle(Led_TypeDef Led)
 | |
| {
 | |
|   HAL_GPIO_TogglePin(LED_PORT[Led], LED_PIN[Led]);
 | |
| }
 | 
