PHiLIP
port_bluepill.h
1 /* Copyright 2020 Kevin Weiss for HAW Hamburg
2  *
3  * This file is subject to the terms and conditions of the MIT License. See the
4  * file LICENSE in the top level directory for more details.
5  * SPDX-License-Identifier: MIT
6  */
7 
8 /*
9  ******************************************************************************
10  * @file port_bluepill.h
11  * @author Kevin Weiss
12  * @date 12.03.2020
13  * @brief Bluepill specific porting.
14  ******************************************************************************
15  */
16 
17 #ifndef PORT_BLUEPILL_H_
18 #define PORT_BLUEPILL_H_
19 
20 /******************************************************************************/
21 /* Pin and Ports defines ******************************************************/
22 /******************************************************************************/
23 #define LED0_Pin GPIO_PIN_13
24 #define LED0_GPIO_Port GPIOC
25 
26 #define DEBUG0_Pin GPIO_PIN_0
27 #define DEBUG0_GPIO_Port GPIOA
28 #define DEBUG1_Pin GPIO_PIN_1
29 #define DEBUG1_GPIO_Port GPIOA
30 #define DEBUG2_Pin GPIO_PIN_2
31 #define DEBUG2_GPIO_Port GPIOA
32 
33 /******************************************************************************/
34 #define TEST_PASS_Pin GPIO_PIN_3
35 #define TEST_PASS_GPIO_Port GPIOA
36 #define TEST_WARN_Pin GPIO_PIN_4
37 #define TEST_WARN_GPIO_Port GPIOA
38 #define TEST_FAIL_Pin GPIO_PIN_5
39 #define TEST_FAIL_GPIO_Port GPIOA
40 
41 #define USER_BTN_Pin GPIO_PIN_15
42 #define USER_BTN_GPIO_Port GPIOB
43 #define DUT_RST_Pin GPIO_PIN_12
44 #define DUT_RST_GPIO_Port GPIOB
45 
46 /******************************************************************************/
47 #define DUT_ADC_Pin GPIO_PIN_6
48 #define DUT_ADC_GPIO_Port GPIOA
49 
50 #define PM_LO_ADC_Pin GPIO_PIN_7
51 #define PM_LO_ADC_GPIO_Port GPIOA
52 #define PM_HI_ADC_Pin GPIO_PIN_0
53 #define PM_HI_ADC_GPIO_Port GPIOB
54 #define PM_V_ADC_Pin GPIO_PIN_1
55 #define PM_V_ADC_GPIO_Port GPIOB
56 
57 /******************************************************************************/
58 #define DUT_TX_Pin GPIO_PIN_10
59 #define DUT_TX_GPIO_Port GPIOB
60 #define DUT_RX_Pin GPIO_PIN_11
61 #define DUT_RX_GPIO_Port GPIOB
62 #define DUT_CTS_Pin GPIO_PIN_13
63 #define DUT_CTS_GPIO_Port GPIOB
64 #define DUT_RTS_Pin GPIO_PIN_14
65 #define DUT_RTS_GPIO_Port GPIOB
66 
67 /******************************************************************************/
68 #define DUT_IC_Pin GPIO_PIN_8
69 #define DUT_IC_GPIO_Port GPIOA
70 
71 /******************************************************************************/
72 #define IF_TX_Pin GPIO_PIN_9
73 #define IF_TX_GPIO_Port GPIOA
74 #define IF_RX_Pin GPIO_PIN_10
75 #define IF_RX_GPIO_Port GPIOA
76 
77 /******************************************************************************/
78 #define DUT_NSS_Pin GPIO_PIN_15
79 #define DUT_NSS_GPIO_Port GPIOA
80 #define DUT_SCK_Pin GPIO_PIN_3
81 #define DUT_SCK_GPIO_Port GPIOB
82 #define DUT_MISO_Pin GPIO_PIN_4
83 #define DUT_MISO_GPIO_Port GPIOB
84 #define DUT_MOSI_Pin GPIO_PIN_5
85 #define DUT_MOSI_GPIO_Port GPIOB
86 
87 /******************************************************************************/
88 #define DUT_SCL_Pin GPIO_PIN_6
89 #define DUT_SCL_GPIO_Port GPIOB
90 #define DUT_SDA_Pin GPIO_PIN_7
91 #define DUT_SDA_GPIO_Port GPIOB
92 
93 /******************************************************************************/
94 #define DUT_PWM_Pin GPIO_PIN_8
95 #define DUT_PWM_GPIO_Port GPIOB
96 #define DUT_DAC_Pin GPIO_PIN_9
97 #define DUT_DAC_GPIO_Port GPIOB
98 
99 /******************************************************************************/
100 /* GPIO defines ***************************************************************/
101 /******************************************************************************/
102 #define LED_OFF GPIO_PIN_SET
103 
104 #define GPIO_DEBUG0_INT EXTI0_IRQHandler
105 #define GPIO_DEBUG0_IRQ EXTI0_IRQn
106 #define GPIO_DEBUG1_INT EXTI1_IRQHandler
107 #define GPIO_DEBUG1_IRQ EXTI1_IRQn
108 #define GPIO_DEBUG2_INT EXTI2_IRQHandler
109 #define GPIO_DEBUG2_IRQ EXTI2_IRQn
110 
111 #define GPIO_NSS_CTS_INT EXTI15_10_IRQHandler
112 #define GPIO_NSS_CTS_IRQ EXTI15_10_IRQn
113 
114 /******************************************************************************/
115 /* BOARD defines **************************************************************/
116 /******************************************************************************/
117 #define RCC_HSE_STATE RCC_HSE_ON
118 
119 #define BOARD_ID 1
120 
121 /******************************************************************************/
122 /* SPI defines ****************************************************************/
123 /******************************************************************************/
124 #define DUT_SPI_INST SPI1
125 
126 #define DUT_SPI_CLK_EN() __HAL_RCC_SPI1_CLK_ENABLE()
127 #define DUT_SPI_CLK_DIS() __HAL_RCC_SPI1_CLK_DISABLE()
128 #define DUT_SPI_GPIO_CLK_EN() __HAL_RCC_GPIOB_CLK_ENABLE();__HAL_RCC_GPIOA_CLK_ENABLE()
129 
130 #define DUT_SPI_GPIO_AF_REMAP() __HAL_AFIO_REMAP_SPI1_ENABLE()
131 
132 #define DUT_SPI_INT SPI1_IRQHandler
133 #define DUT_SPI_IRQ SPI1_IRQn
134 
135 #define GPIO_NSS_IRQ GPIO_NSS_CTS_IRQ
136 
137 /******************************************************************************/
138 /* I2C defines ****************************************************************/
139 /******************************************************************************/
140 #define DUT_I2C_INST I2C1
141 
142 #define DUT_I2C_CLK_EN() __HAL_RCC_I2C1_CLK_ENABLE()
143 #define DUT_I2C_CLK_DIS() __HAL_RCC_I2C1_CLK_DISABLE()
144 #define DUT_I2C_GPIO_CLK_EN() __HAL_RCC_GPIOB_CLK_ENABLE()
145 
146 #define DUT_I2C_GPIO_AF_REMAP()
147 
148 #define DUT_I2C_EV_INT I2C1_EV_IRQHandler
149 #define DUT_I2C_EV_IRQ I2C1_EV_IRQn
150 #define DUT_I2C_ERR_INT I2C1_ER_IRQHandler
151 #define DUT_I2C_ERR_IRQ I2C1_ER_IRQn
152 
153 /******************************************************************************/
154 /* UART defines ***************************************************************/
155 /******************************************************************************/
156 #define DUT_UART_INST USART3
157 
158 #define DUT_UART_CLK_EN() __HAL_RCC_USART3_CLK_ENABLE()
159 #define DUT_UART_CLK_DIS() __HAL_RCC_USART3_CLK_DISABLE()
160 #define DUT_UART_GPIO_CLK_EN() __HAL_RCC_GPIOB_CLK_ENABLE()
161 
162 #define DUT_UART_INT USART3_IRQHandler
163 #define DUT_UART_IRQ USART3_IRQn
164 
165 #define GPIO_CTS_IRQ GPIO_NSS_CTS_IRQ
166 
167 #define DUT_UART_RX_DMA_INST DMA1_Channel3
168 #define DUT_UART_DMA_RX_INT DMA1_Channel3_IRQHandler
169 #define DUT_UART_DMA_RX_IRQ DMA1_Channel3_IRQn
170 
171 /******************************************************************************/
172 #define IF_UART_INST USART1
173 
174 #define IF_UART_CLK_EN() __HAL_RCC_USART1_CLK_ENABLE()
175 #define IF_UART_CLK_DIS() __HAL_RCC_USART1_CLK_DISABLE()
176 #define IF_UART_CLK_GPIO_EN() __HAL_RCC_GPIOA_CLK_ENABLE()
177 
178 #define IF_UART_INT USART1_IRQHandler
179 #define IF_UART_IRQ USART1_IRQn
180 
181 #define IF_UART_DMA_RX_INST DMA1_Channel5
182 #define IF_UART_DMA_RX_INT DMA1_Channel5_IRQHandler
183 #define IF_UART_DMA_RX_IRQ DMA1_Channel5_IRQn
184 
185 #define IF_UART_DMA_TX_INST DMA1_Channel4
186 #define IF_UART_DMA_TX_INT DMA1_Channel4_IRQHandler
187 #define IF_UART_DMA_TX_IRQ DMA1_Channel4_IRQn
188 
189 /******************************************************************************/
190 /* PWM_DAC defines ************************************************************/
191 /******************************************************************************/
192 #define DUT_PWM_DAC_INST TIM4
193 #define DUT_PWM_TMR DUT_PWM_DAC_INST
194 #define DUT_DAC_TMR DUT_PWM_DAC_INST
195 
196 #define DUT_PWM_DAC_CLK_EN() __HAL_RCC_TIM4_CLK_ENABLE()
197 #define DUT_PWM_DAC_CLK_DIS() __HAL_RCC_TIM4_CLK_DISABLE()
198 #define DUT_PWM_DAC_GPIO_CLK_EN() __HAL_RCC_GPIOB_CLK_ENABLE()
199 
200 #define DUT_PWM_DAC_GPIO_AF_REMAP()
201 
202 /******************************************************************************/
203 /* IC defines *****************************************************************/
204 /******************************************************************************/
205 #define DUT_IC_INST TIM1
206 #define DUT_IC_CHANNEL TIM_CHANNEL_1
207 
208 #define DUT_IC_CLK_EN() __HAL_RCC_TIM1_CLK_ENABLE()
209 #define DUT_IC_CLK_DIS() __HAL_RCC_TIM1_CLK_DISABLE()
210 #define DUT_IC_GPIO_CLK_EN() __HAL_RCC_GPIOA_CLK_ENABLE()
211 
212 #define DUT_IC_GPIO_INT EXTI9_5_IRQHandler
213 #define DUT_IC_GPIO_IRQ EXTI9_5_IRQn
214 
215 #define DUT_IC_DMA_INST DMA1_Channel2
216 #define DUT_IC_DMA_ID TIM_DMA_ID_CC1
217 #define DUT_IC_DMA_INT DMA1_Channel2_IRQHandler
218 #define DUT_IC_DMA_IRQ DMA1_Channel2_IRQn
219 
220 /******************************************************************************/
221 /* ADC defines ****************************************************************/
222 /******************************************************************************/
223 #define DUT_ADC_INST ADC2
224 #define ADC_CHANNEL ADC_CHANNEL_6
225 
226 #define DUT_ADC_CLK_EN() __HAL_RCC_ADC2_CLK_ENABLE()
227 #define DUT_ADC_GPIO_CLK_EN() __HAL_RCC_GPIOA_CLK_ENABLE()
228 
229 #define DUT_ADC_CLK_DIS() __HAL_RCC_ADC2_CLK_DISABLE()
230 
231 #define ADC_INT ADC1_2_IRQHandler
232 #define ADC_IRQ ADC1_2_IRQn
233 
234 #endif /* PORT_BLUEPILL_H_ */