版本
/**
* @brief STM3210C EVAL BSP Driver version number V6.0.0
*/
#define __STM3210C_EVAL_BSP_VERSION_MAIN (0x06) /*!< [31:24] main version */
#define __STM3210C_EVAL_BSP_VERSION_SUB1 (0x00) /*!< [23:16] sub1 version */
#define __STM3210C_EVAL_BSP_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */
#define __STM3210C_EVAL_BSP_VERSION_RC (0x00) /*!< [7:0] release candidate */
#define __STM3210C_EVAL_BSP_VERSION ((__STM3210C_EVAL_BSP_VERSION_MAIN << 24)\
|(__STM3210C_EVAL_BSP_VERSION_SUB1 << 16)\
|(__STM3210C_EVAL_BSP_VERSION_SUB2 << 8 )\
|(__STM3210C_EVAL_BSP_VERSION_RC))
/**
* @brief This method returns the STM3210C EVAL BSP Driver revision
* @retval version : 0xXYZR (8bits for each decimal, R for RC)
*/
uint32_t BSP_GetVersion(void)
{
return __STM3210C_EVAL_BSP_VERSION;
}
LED
* @brief LED variables
*/
GPIO_TypeDef* LED_PORT[LEDn] = {LED1_GPIO_PORT,
LED2_GPIO_PORT,
LED3_GPIO_PORT,
LED4_GPIO_PORT};
const uint16_t LED_PIN[LEDn] = {LED1_PIN,
LED2_PIN,
LED3_PIN,
LED4_PIN};
LED函数
/**
* @brief Configures LED GPIO.
* @param Led: Specifies the Led to be configured.
* This parameter can be one of following parameters:
* @arg LED1
* @arg LED2
* @arg LED3
* @arg LED4
* @retval None
*/
void BSP_LED_Init(Led_TypeDef Led)
{
GPIO_InitTypeDef gpioinitstruct = {0};
/* Enable the GPIO_LED clock */
LEDx_GPIO_CLK_ENABLE(Led);
/* Configure the GPIO_LED pin */
gpioinitstruct.Pin = LED_PIN[Led];
gpioinitstruct.Mode = GPIO_MODE_OUTPUT_PP;
gpioinitstruct.Pull = GPIO_NOPULL;
gpioinitstruct.Speed = GPIO_SPEED_HIGH;
HAL_GPIO_Init(LED_PORT[Led], &gpioinitstruct);
HAL_GPIO_WritePin(LED_PORT[Led], LED_PIN[Led], GPIO_PIN_RESET);
}
/**
* @brief Turns selected LED On.
* @param Led: Specifies the Led to be set on.
* This parameter can be one of following parameters:
* @arg LED1
* @arg LED2
* @arg LED3
* @arg LED4
* @retval None
*/
void BSP_LED_On(Led_TypeDef Led)
{
HAL_GPIO_WritePin(LED_PORT[Led], LED_PIN[Led], GPIO_PIN_SET);
}
/**
* @brief Turns selected LED Off.
* @param Led: Specifies the Led to be set off.
* This parameter can be one of following parameters:
* @arg LED1
* @arg LED2
* @arg LED3
* @arg LED4
* @retval None
*/
void BSP_LED_Off(Led_TypeDef Led)
{
HAL_GPIO_WritePin(LED_PORT[Led], LED_PIN[Led], GPIO_PIN_RESET);
}
/**
* @brief Toggles the selected LED.
* @param Led: Specifies the Led to be toggled.
* This parameter can be one of following parameters:
* @arg LED1
* @arg LED2
* @arg LED3
* @arg LED4
* @retval None
*/
void BSP_LED_Toggle(Led_TypeDef Led)
{
HAL_GPIO_TogglePin(LED_PORT[Led], LED_PIN[Led]);
}
h文件
/** @addtogroup STM3210C_EVAL_LED
* @{
*/
#define LEDn 4
#define LED1_PIN GPIO_PIN_0 /* PB.00*/
#define LED1_GPIO_PORT GPIOB
#define LED1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define LED1_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
#define LED2_PIN GPIO_PIN_1 /* PB.01*/
#define LED2_GPIO_PORT GPIOB
#define LED2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define LED2_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define LED3_PIN GPIO_PIN_14 /* PB.14*/
#define LED3_GPIO_PORT GPIOB
#define LED3_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define LED3_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define LED4_PIN GPIO_PIN_15 /* PB.15*/
#define LED4_GPIO_PORT GPIOB
#define LED4_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define LED4_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define LEDx_GPIO_CLK_ENABLE(__LED__) do { if ((__LED__) == LED1) LED1_GPIO_CLK_ENABLE(); else \
if ((__LED__) == LED2) LED2_GPIO_CLK_ENABLE(); else \
if ((__LED__) == LED3) LED3_GPIO_CLK_ENABLE(); else \
if ((__LED__) == LED4) LED4_GPIO_CLK_ENABLE();} while(0)
#define LEDx_GPIO_CLK_DISABLE(__LED__) (((__LED__) == LED1) ? LED1_GPIO_CLK_DISABLE() :\
((__LED__) == LED2) ? LED2_GPIO_CLK_DISABLE() :\
((__LED__) == LED3) ? LED3_GPIO_CLK_DISABLE() :\
((__LED__) == LED4) ? LED4_GPIO_CLK_DISABLE() : 0 )
/**
* @}
*/