-
Notifications
You must be signed in to change notification settings - Fork 0
/
stm32f0308_discovery.h
167 lines (138 loc) · 4.08 KB
/
stm32f0308_discovery.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/**
******************************************************************************
* @file stm32f0308_discovery.h
* @author MCD Application Team
* @brief This file contains definitions for STM32F0308-Discovery's Leds, push-
* buttons hardware resources.
******************************************************************************
* @attention
*
* Copyright (c) 2016 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F0308_DISCOVERY_H
#define __STM32F0308_DISCOVERY_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32f0xx_hal.h"
/** @addtogroup BSP
* @{
*/
/** @defgroup STM32F0308_DISCOVERY STM32F0308_DISCOVERY
* @{
*/
/** @defgroup STM32F0308_DISCOVERY_Common STM32F0308_DISCOVERY Common
* @{
*/
/** @defgroup STM32F0308_DISCOVERY_Exported_Types Exported Types
* @{
*/
/**
* @brief LED Types Definition
*/
typedef enum
{
LED3 = 0,
LED4 = 1,
/* Color led aliases */
LED_GREEN = LED3,
LED_BLUE = LED4
}Led_TypeDef;
/**
* @brief BUTTON Types Definition
*/
typedef enum
{
BUTTON_USER = 0
}Button_TypeDef;
typedef enum
{
BUTTON_MODE_GPIO = 0,
BUTTON_MODE_EXTI = 1
}ButtonMode_TypeDef;
/**
* @}
*/
/** @defgroup STM32F0308_DISCOVERY_Exported_Constants Exported Constants
* @{
*/
/**
* @brief Define for STM32F0308_DISCOVERY board
*/
#if !defined (USE_STM320308_DISCO)
#define USE_STM320308_DISCO
#endif
/** @defgroup STM32F0308_DISCOVERY_LED STM32F0308_DISCOVERY LED
* @{
*/
#define LEDn 2
#define LED3_PIN GPIO_PIN_9
#define LED3_GPIO_PORT GPIOC
#define LED3_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
#define LED3_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE()
#define LED4_PIN GPIO_PIN_8
#define LED4_GPIO_PORT GPIOC
#define LED4_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
#define LED4_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE()
#define LEDx_GPIO_CLK_ENABLE(__LED__) do { if((__LED__) == LED3) LED3_GPIO_CLK_ENABLE(); else \
if((__LED__) == LED4) LED4_GPIO_CLK_ENABLE();} while(0)
#define LEDx_GPIO_CLK_DISABLE(__LED__) (((__LED__) == LED3) ? LED3_GPIO_CLK_DISABLE() :\
((__LED__) == LED4) ? LED4_GPIO_CLK_DISABLE() : 0 )
/**
* @}
*/
/** @defgroup STM32F0308_DISCOVERY_BUTTON STM32F0308_DISCOVERY BUTTON
* @{
*/
#define BUTTONn 1
/**
* @brief USER push-button
*/
#define USER_BUTTON_PIN GPIO_PIN_0 /* PA0 */
#define USER_BUTTON_GPIO_PORT GPIOA
#define USER_BUTTON_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
#define USER_BUTTON_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE()
#define USER_BUTTON_EXTI_IRQn EXTI0_1_IRQn
#define BUTTONx_GPIO_CLK_ENABLE(__BUTTON__) do { if((__BUTTON__) == BUTTON_USER) USER_BUTTON_GPIO_CLK_ENABLE();} while(0)
#define BUTTONx_GPIO_CLK_DISABLE(__BUTTON__) (((__BUTTON__) == BUTTON_USER) ? USER_BUTTON_GPIO_CLK_DISABLE() : 0 )
/**
* @}
*/
/**
* @}
*/
/** @defgroup STM32F0308_DISCOVERY_Exported_Functions Exported Functions
* @{
*/
uint32_t BSP_GetVersion(void);
void BSP_LED_Init(Led_TypeDef Led);
void BSP_LED_On(Led_TypeDef Led);
void BSP_LED_Off(Led_TypeDef Led);
void BSP_LED_Toggle(Led_TypeDef Led);
void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef Mode);
uint32_t BSP_PB_GetState(Button_TypeDef Button);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __STM32F0308_DISCOVERY_H */