File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -146,4 +146,40 @@ package body STM32.Board is
146
146
AF => STM32.Device.GPIO_AF_FMC_12));
147
147
end Initialize_FSMC ;
148
148
149
+ -- -------------------
150
+ -- Initialize_UART --
151
+ -- -------------------
152
+
153
+ procedure Initialize_UART
154
+ (Speed : STM32.USARTs.Baud_Rates := 115_200 ;
155
+ Stop : STM32.USARTs.Stop_Bits := STM32.USARTs.Stopbits_1;
156
+ Parity : STM32.USARTs.Parities := STM32.USARTs.No_Parity;
157
+ Flow : STM32.USARTs.Flow_Control := STM32.USARTs.No_Flow_Control)
158
+ is
159
+ TX_Pin : GPIO_Point renames STM32.Device.PA9;
160
+ RX_Pin : GPIO_Point renames STM32.Device.PA10;
161
+ begin
162
+ Enable_Clock (UART);
163
+ Enable_Clock (RX_Pin & TX_Pin);
164
+
165
+ Configure_IO
166
+ (TX_Pin & RX_Pin,
167
+ (Mode => Mode_AF,
168
+ AF => GPIO_AF_USART1_7,
169
+ Resistors => Pull_Up,
170
+ AF_Speed => Speed_50MHz,
171
+ AF_Output_Type => Push_Pull));
172
+
173
+ UART.Disable;
174
+
175
+ UART.Set_Baud_Rate (Speed);
176
+ UART.Set_Mode (STM32.USARTs.Tx_Rx_Mode);
177
+ UART.Set_Stop_Bits (Stop);
178
+ UART.Set_Word_Length (STM32.USARTs.Word_Length_8);
179
+ UART.Set_Parity (Parity);
180
+ UART.Set_Flow_Control (Flow);
181
+
182
+ UART.Enable;
183
+ end Initialize_UART ;
184
+
149
185
end STM32.Board ;
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ with STM32.Device; use STM32.Device;
40
40
with STM32.DMA ; use STM32.DMA;
41
41
with STM32.DMA.Interrupts ; use STM32.DMA.Interrupts;
42
42
with STM32.GPIO ; use STM32.GPIO;
43
+ with STM32.USARTs ;
43
44
44
45
with SDCard ;
45
46
with W25Q16 ;
@@ -173,4 +174,16 @@ package STM32.Board is
173
174
procedure Initialize_Flash_Memory ;
174
175
-- MUST be called prior to any use of the Flash
175
176
177
+ -- --------
178
+ -- UART --
179
+ -- --------
180
+
181
+ UART : STM32.USARTs.USART renames STM32.Device.USART_1;
182
+
183
+ procedure Initialize_UART
184
+ (Speed : STM32.USARTs.Baud_Rates := 115_200 ;
185
+ Stop : STM32.USARTs.Stop_Bits := STM32.USARTs.Stopbits_1;
186
+ Parity : STM32.USARTs.Parities := STM32.USARTs.No_Parity;
187
+ Flow : STM32.USARTs.Flow_Control := STM32.USARTs.No_Flow_Control);
188
+
176
189
end STM32.Board ;
You can’t perform that action at this time.
0 commit comments