Skip to content

Commit 4615730

Browse files
committed
Add UART at J6 connector to STM32.Board package
1 parent 5809455 commit 4615730

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

boards/stm32_f4ve/src/stm32-board.adb

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,40 @@ package body STM32.Board is
146146
AF => STM32.Device.GPIO_AF_FMC_12));
147147
end Initialize_FSMC;
148148

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+
149185
end STM32.Board;

boards/stm32_f4ve/src/stm32-board.ads

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ with STM32.Device; use STM32.Device;
4040
with STM32.DMA; use STM32.DMA;
4141
with STM32.DMA.Interrupts; use STM32.DMA.Interrupts;
4242
with STM32.GPIO; use STM32.GPIO;
43+
with STM32.USARTs;
4344

4445
with SDCard;
4546
with W25Q16;
@@ -173,4 +174,16 @@ package STM32.Board is
173174
procedure Initialize_Flash_Memory;
174175
-- MUST be called prior to any use of the Flash
175176

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+
176189
end STM32.Board;

0 commit comments

Comments
 (0)