Here's my first attempt at pushing the user button to blink the red LED on a STM32F4 Discovery board, using AdaCore's GNAT Community Edition.
What you need:
STM32F4 Discovery board
GNAT Community Edition (download and install both the compiler toolchain and the arm-elf)
Ada Drivers Library with examples
It's been a while since I had my STM32 boards installed on my computer, so you may (or may not) need to install a driver for the ST-LINK/V2 programmer...
1. Connect the board, you should have a STM32 STLink device.
2. Start GPS (GNAP Programming Studio).
3. Open one of the examples from the Drivers library / examples / STM32F4_DISCO.
4. Edit main.adb and replace all text with the following source code.
5. Click the Flash to Board icon.
6. Enjoy :)
What you need:
STM32F4 Discovery board
GNAT Community Edition (download and install both the compiler toolchain and the arm-elf)
Ada Drivers Library with examples
It's been a while since I had my STM32 boards installed on my computer, so you may (or may not) need to install a driver for the ST-LINK/V2 programmer...
1. Connect the board, you should have a STM32 STLink device.
2. Start GPS (GNAP Programming Studio).
3. Open one of the examples from the Drivers library / examples / STM32F4_DISCO.
4. Edit main.adb and replace all text with the following source code.
----------------------------------------------------------------
-- --
-- Testing user button and red LED on STM32F4 Discovery board --
-- --
----------------------------------------------------------------
with Ada.Real_Time; use Ada.Real_Time;
with STM32.Board; use STM32.Board;
with STM32.User_Button;
procedure Main is
procedure My_Delay (Milli : Natural);
procedure My_Delay (Milli : Natural) is
begin
delay until Clock + Milliseconds (Milli);
end My_Delay;
begin
Initialize_LEDs;
STM32.User_Button.Initialize;
loop
if STM32.User_Button.Has_Been_Pressed then
STM32.Board.Red_LED.Set;
My_Delay (100);
STM32.Board.Red_LED.Clear;
end if;
end loop;
end Main;
5. Click the Flash to Board icon.
6. Enjoy :)

Comments
Post a Comment