stm32-ada/examples/led_flasher/led_flasher.adb

29 lines
741 B
Ada

with Board; use Board;
with STM32.RCC; use STM32.RCC;
with Chip.Units; use Chip.Units;
with STM32.GPIO; use STM32.GPIO;
with STM32.GPIO.Ports; use STM32.GPIO.Ports;
with Ada.Real_Time; use Ada.Real_Time;
procedure LED_Flasher is
Period: constant Time_Span := Milliseconds(250);
On_Time: constant Time_Span := Milliseconds(10);
Now: Time := Clock;
package LED is new GPIO_Port_Boolean(LED_Port, LED_Bit);
begin
LED_RCC_EN := True;
LED.Set_MODER (Output_Mode);
LED.Set_OTYPER (Push_Pull_Type);
LED.Set_OSPEEDR (Very_High_Speed);
LED.Set_PUPDR (No_Pull);
loop
LED.Set (LED_On);
delay until Now + On_Time;
LED.Set (not LED_On);
Now := Now + Period;
delay until Now;
end loop;
end Led_Flasher;