Night R
Published © CC BY-NC

Running a Finite State Machine on STM32 through Ada

Demonstrating a bug-free Soft Finite State Machine by using STM32 Nucleo144 Dev. Board and Adacore through GNAT

IntermediateFull instructions providedOver 2 days4,913
Running a Finite State Machine on STM32 through Ada

Things used in this project

Hardware components

Nucleo 144 STM32F7
ST STM32L4, STM32F7 Nucleo 144 STM32F7
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1

Software apps and online services

GNAT Community
AdaCore GNAT Community
AdaCore Ada Drivers Library

Story

Read more

Schematics

Nucleo144#nowiringstuff

Code

MainProg.adb

ADA
with Pins;
with Utils;

package body Program is

   type Fan_State is (Stop, Slow, Medium, Fast);

   type Buttons_State is (None, Up, Down, Both);

   procedure Control_Motor (S : in Fan_State) is
   begin
      case S is
         when Stop =>
            -- stop the motor
            Pins.Write (Pins.Pin_4, False);
            Pins.Write (Pins.Pin_5, False);
            Pins.Write (Pins.Pin_6, False);

         when Slow =>
            -- first circuit on
            Pins.Write (Pins.Pin_4, True);
            Pins.Write (Pins.Pin_5, False);
            Pins.Write (Pins.Pin_6, False);

         when Medium =>
            -- second circuit on
            Pins.Write (Pins.Pin_4, False);
            Pins.Write (Pins.Pin_5, True);
            Pins.Write (Pins.Pin_6, False);

         when Fast =>
            -- third circuit on
            Pins.Write (Pins.Pin_4, False);
            Pins.Write (Pins.Pin_5, False);
            Pins.Write (Pins.Pin_6, True);
      end case;
   end Control_Motor;

   procedure Read_Buttons (B : out Buttons_State) is
      B_Down : Boolean;
      B_Up : Boolean;
   begin
      Pins.Read (Pins.Pin_2, B_Down);
      Pins.Read (Pins.Pin_3, B_Up);

      if not B_Down and not B_Up then
         B := Both;
      elsif not B_Down and B_Up then
         B := Down;
      elsif B_Down and not B_Up then
         B := Up;
      else
         B := None;
      end if;
   end Read_Buttons;
   
   procedure Run is
      Current_State : Fan_State;
      Buttons : Buttons_State;
   begin

      -- initialize the device
      Pins.Enable_Input (Pins.Pin_2, Pins.Pulled_Up);
      Pins.Enable_Input (Pins.Pin_3, Pins.Pulled_Up);
      Pins.Enable_Output (Pins.Pin_4);
      Pins.Enable_Output (Pins.Pin_5);
      Pins.Enable_Output (Pins.Pin_6);
      Current_State := Stop;
      Control_Motor (Current_State);
   
      -- repeat the control loop
      loop
         Read_Buttons (Buttons);
      
         case Current_State is
            when Stop =>
               case Buttons is
                  when None | Down | Both =>
                     -- nothing to do
                     Null;
                  when Up =>
                     Current_State := Slow;
               end case;

            when Slow =>
               case Buttons is
                  when None =>
                     -- nothing to do
                     Null;
                  when Down | Both =>
                     Current_State := Stop;
                  when Up =>
                     Current_State := Medium;
               end case;

            when Medium =>
               case Buttons is
                  when None =>
                     -- nothing to do
                     Null;
                  when Down =>
                     Current_State := Slow;
                  when Up =>
                     Current_State := Fast;
                  when Both =>
                     Current_State := Stop;
               end case;

            when Fast =>
               case Buttons is
                  when None | Up =>
                     -- nothing to do
                     Null;
                  when Down =>
                     Current_State := Medium;
                  when Both =>
                     Current_State := Stop;
               end case;
         end case;

         Control_Motor (Current_State);
      
         Utils.Waste_Some_Time;
      end loop;
   end Run;

end Program;

pins.adb

ADA
with Registers;

package body Pins is

   use type Registers.Word;

   procedure Enable_Input (Pin : in Pin_ID; Mode : in Input_Mode) is
   begin
      case Pin is
         when Pin_2 =>
            Registers.RCC_AHB1ENR := Registers.RCC_AHB1ENR
                or 2#10_0000#; -- bit 5
            
            Registers.GPIOF_MODER := Registers.GPIOF_MODER
               and 2#0011_1111_1111_1111_1111_1111_1111_1111#; -- bits 30-31
            
            if Mode = Pulled_Up then
               Registers.GPIOF_PUPDR := (Registers.GPIOF_PUPDR
                  and 2#0011_1111_1111_1111_1111_1111_1111_1111#)
                   or 2#0100_0000_0000_0000_0000_0000_0000_0000#;
            else
               Registers.GPIOF_PUPDR := Registers.GPIOF_PUPDR
                  and 2#0011_1111_1111_1111_1111_1111_1111_1111#;
            end if;

         when Pin_3 =>
            Registers.RCC_AHB1ENR := Registers.RCC_AHB1ENR
                or 2#1_0000#; -- bit 4
            
            Registers.GPIOE_MODER := Registers.GPIOE_MODER
               and 2#1111_0011_1111_1111_1111_1111_1111_1111#; -- bits 26-27
            
            if Mode = Pulled_Up then
               Registers.GPIOE_PUPDR := (Registers.GPIOE_PUPDR
                  and 2#1111_0011_1111_1111_1111_1111_1111_1111#)
                   or 2#0000_0100_0000_0000_0000_0000_0000_0000#;
            else
               Registers.GPIOE_PUPDR := Registers.GPIOE_PUPDR
                  and 2#1111_0011_1111_1111_1111_1111_1111_1111#;
            end if;

         when Pin_4 =>
            Registers.RCC_AHB1ENR := Registers.RCC_AHB1ENR
                or 2#10_0000#; -- bit 5
            
            Registers.GPIOF_MODER := Registers.GPIOF_MODER
               and 2#1100_1111_1111_1111_1111_1111_1111_1111#; -- bits 28-29
            
            if Mode = Pulled_Up then
               Registers.GPIOF_PUPDR := (Registers.GPIOF_PUPDR
                  and 2#1100_1111_1111_1111_1111_1111_1111_1111#)
                   or 2#0001_0000_0000_0000_0000_0000_0000_0000#;
            else
               Registers.GPIOF_PUPDR := Registers.GPIOF_PUPDR
                  and 2#1100_1111_1111_1111_1111_1111_1111_1111#;
            end if;

         when Pin_5 =>
            Registers.RCC_AHB1ENR := Registers.RCC_AHB1ENR
                or 2#1_0000#; -- bit 4
            
            Registers.GPIOE_MODER := Registers.GPIOE_MODER
               and 2#1111_1111_0011_1111_1111_1111_1111_1111#; -- bits 22-23
            
            if Mode = Pulled_Up then
               Registers.GPIOE_PUPDR := (Registers.GPIOE_PUPDR
                  and 2#1111_1111_0011_1111_1111_1111_1111_1111#)
                   or 2#0000_0000_0100_0000_0000_0000_0000_0000#;
            else
               Registers.GPIOE_PUPDR := Registers.GPIOE_PUPDR
                  and 2#1111_1111_0011_1111_1111_1111_1111_1111#;
            end if;

         when Pin_6 =>
            Registers.RCC_AHB1ENR := Registers.RCC_AHB1ENR
                or 2#1_0000#; -- bit 4
            
            Registers.GPIOE_MODER := Registers.GPIOE_MODER
               and 2#1111_1111_1111_0011_1111_1111_1111_1111#; -- bits 18-19
            
            if Mode = Pulled_Up then
               Registers.GPIOE_PUPDR := (Registers.GPIOE_PUPDR
                  and 2#1111_1111_1111_0011_1111_1111_1111_1111#)
                   or 2#0000_0000_0000_0100_0000_0000_0000_0000#;
            else
               Registers.GPIOE_PUPDR := Registers.GPIOE_PUPDR
                  and 2#1111_1111_1111_0011_1111_1111_1111_1111#;
            end if;

         when Pin_7 =>
            Registers.RCC_AHB1ENR := Registers.RCC_AHB1ENR
                or 2#10_0000#; -- bit 5
            
            Registers.GPIOF_MODER := Registers.GPIOF_MODER
               and 2#1111_0011_1111_1111_1111_1111_1111_1111#; -- bits 26-27
            
            if Mode = Pulled_Up then
               Registers.GPIOF_PUPDR := (Registers.GPIOF_PUPDR
                  and 2#1111_0011_1111_1111_1111_1111_1111_1111#)
                   or 2#0000_0100_0000_0000_0000_0000_0000_0000#;
            else
               Registers.GPIOF_PUPDR := Registers.GPIOF_PUPDR
                  and 2#1111_0011_1111_1111_1111_1111_1111_1111#;
            end if;

         when Pin_8 =>
            Registers.RCC_AHB1ENR := Registers.RCC_AHB1ENR
                or 2#10_0000#; -- bit 5
            
            Registers.GPIOF_MODER := Registers.GPIOF_MODER
               and 2#1111_1100_1111_1111_1111_1111_1111_1111#; -- bits 24-25
            
            if Mode = Pulled_Up then
               Registers.GPIOF_PUPDR := (Registers.GPIOF_PUPDR
                  and 2#1111_1100_1111_1111_1111_1111_1111_1111#)
                   or 2#0000_0001_0000_0000_0000_0000_0000_0000#;
            else
               Registers.GPIOF_PUPDR := Registers.GPIOF_PUPDR
                  and 2#1111_1100_1111_1111_1111_1111_1111_1111#;
            end if;

         when Pin_9 =>
            Registers.RCC_AHB1ENR := Registers.RCC_AHB1ENR
                or 2#1000#; -- bit 3
            
            Registers.GPIOD_MODER := Registers.GPIOD_MODER
               and 2#0011_1111_1111_1111_1111_1111_1111_1111#; -- bit pair 30-31
            
            if Mode = Pulled_Up then
               Registers.GPIOD_PUPDR := (Registers.GPIOD_PUPDR
                  and 2#0011_1111_1111_1111_1111_1111_1111_1111#)
                   or 2#0100_0000_0000_0000_0000_0000_0000_0000#;
            else
               Registers.GPIOD_PUPDR := Registers.GPIOD_PUPDR
                  and 2#0011_1111_1111_1111_1111_1111_1111_1111#;
            end if;

         when Pin_10 =>
            Registers.RCC_AHB1ENR := Registers.RCC_AHB1ENR
                or 2#1000#; -- bit 3
            
            Registers.GPIOD_MODER := Registers.GPIOD_MODER
               and 2#1100_1111_1111_1111_1111_1111_1111_1111#; -- bit pair 28-29
            
            if Mode = Pulled_Up then
               Registers.GPIOD_PUPDR := (Registers.GPIOD_PUPDR
                  and 2#1100_1111_1111_1111_1111_1111_1111_1111#)
                   or 2#0001_0000_0000_0000_0000_0000_0000_0000#;
            else
               Registers.GPIOD_PUPDR := Registers.GPIOD_PUPDR
                  and 2#1100_1111_1111_1111_1111_1111_1111_1111#;
            end if;

         when Pin_11 =>
            Registers.RCC_AHB1ENR := Registers.RCC_AHB1ENR
                or 2#1#; -- bit 0
            
            Registers.GPIOA_MODER := Registers.GPIOA_MODER
               and 2#1111_1111_1111_1111_0011_1111_1111_1111#; -- bit pair 14-15
            
            if Mode = Pulled_Up then
               Registers.GPIOA_PUPDR := (Registers.GPIOA_PUPDR
                  and 2#1111_1111_1111_1111_0011_1111_1111_1111#)
                   or 2#0000_0000_0000_0000_0100_0000_0000_0000#;
            else
               Registers.GPIOA_PUPDR := Registers.GPIOA_PUPDR
                  and 2#1111_1111_1111_1111_0011_1111_1111_1111#;
            end if;

         when Pin_12 =>
            Registers.RCC_AHB1ENR := Registers.RCC_AHB1ENR
                or 2#1#; -- bit 0
            
            Registers.GPIOA_MODER := Registers.GPIOA_MODER
               and 2#1111_1111_1111_1111_1100_1111_1111_1111#; -- bit pair 12-13
            
            if Mode = Pulled_Up then
               Registers.GPIOA_PUPDR := (Registers.GPIOA_PUPDR
                  and 2#1111_1111_1111_1111_1100_1111_1111_1111#)
                   or 2#0000_0000_0000_0000_0001_0000_0000_0000#;
            else
               Registers.GPIOA_PUPDR := Registers.GPIOA_PUPDR
                  and 2#1111_1111_1111_1111_1100_1111_1111_1111#;
            end if;

         when Pin_13 =>
            Registers.RCC_AHB1ENR := Registers.RCC_AHB1ENR
                or 2#1#; -- bit 0
            
            Registers.GPIOA_MODER := Registers.GPIOA_MODER
               and 2#1111_1111_1111_1111_1111_0011_1111_1111#; -- bit pair 10-11
            
            if Mode = Pulled_Up then
               Registers.GPIOA_PUPDR := (Registers.GPIOA_PUPDR
                  and 2#1111_1111_1111_1111_1111_0011_1111_1111#)
                   or 2#0000_0000_0000_0000_0000_0100_0000_0000#;
            else
               Registers.GPIOA_PUPDR := Registers.GPIOA_PUPDR
                  and 2#1111_1111_1111_1111_1111_0011_1111_1111#;
            end if;

         end case;
   end Enable_Input;
   
   procedure Enable_Output (Pin : in Pin_ID) is
   begin
      case Pin is
         when Pin_2 =>
            Registers.RCC_AHB1ENR := Registers.RCC_AHB1ENR
                or 2#10_0000#; -- bit 5
            Registers.GPIOF_MODER := (Registers.GPIOF_MODER
               and 2#0011_1111_1111_1111_1111_1111_1111_1111#)
                or 2#0100_0000_0000_0000_0000_0000_0000_0000#; -- bits 30-31

         when Pin_3 =>
            Registers.RCC_AHB1ENR := Registers.RCC_AHB1ENR
                or 2#1_0000#; -- bit 4
            Registers.GPIOE_MODER := (Registers.GPIOE_MODER
               and 2#1111_0011_1111_1111_1111_1111_1111_1111#)
                or 2#0000_0100_0000_0000_0000_0000_0000_0000#; -- bits 26-27

         when Pin_4 =>
            Registers.RCC_AHB1ENR := Registers.RCC_AHB1ENR
                or 2#10_0000#; -- bit 5
            Registers.GPIOF_MODER := (Registers.GPIOF_MODER
               and 2#1100_1111_1111_1111_1111_1111_1111_1111#)
                or 2#0001_0000_0000_0000_0000_0000_0000_0000#; -- bits 28-29

         when Pin_5 =>
            Registers.RCC_AHB1ENR := Registers.RCC_AHB1ENR
                or 2#1_0000#; -- bit 4
            Registers.GPIOE_MODER := (Registers.GPIOE_MODER
               and 2#1111_1111_0011_1111_1111_1111_1111_1111#)
                or 2#0000_0000_0100_0000_0000_0000_0000_0000#; -- bits 22-23

         when Pin_6 =>
            Registers.RCC_AHB1ENR := Registers.RCC_AHB1ENR
                or 2#1_0000#; -- bit 4
            Registers.GPIOE_MODER := (Registers.GPIOE_MODER
               and 2#1111_1111_1111_0011_1111_1111_1111_1111#)
                or 2#0000_0000_0000_0100_0000_0000_0000_0000#; -- bits 18-19

         when Pin_7 =>
            Registers.RCC_AHB1ENR := Registers.RCC_AHB1ENR
                or 2#10_0000#; -- bit 5
            Registers.GPIOF_MODER := (Registers.GPIOF_MODER
               and 2#1111_0011_1111_1111_1111_1111_1111_1111#)
                or 2#0000_0100_0000_0000_0000_0000_0000_0000#; -- bits 26-27

         when Pin_8 =>
            Registers.RCC_AHB1ENR := Registers.RCC_AHB1ENR
                or 2#10_0000#; -- bit 5
            Registers.GPIOF_MODER := (Registers.GPIOF_MODER
               and 2#1111_1100_1111_1111_1111_1111_1111_1111#)
                or 2#0000_0001_0000_0000_0000_0000_0000_0000#; -- bits 24-25

         when Pin_9 =>
            Registers.RCC_AHB1ENR := Registers.RCC_AHB1ENR
                or 2#1000#; -- bit 3
            Registers.GPIOD_MODER := (Registers.GPIOD_MODER
               and 2#0011_1111_1111_1111_1111_1111_1111_1111#)
                or 2#0100_0000_0000_0000_0000_0000_0000_0000#; -- bits 30-31

         when Pin_10 =>
            Registers.RCC_AHB1ENR := Registers.RCC_AHB1ENR
                or 2#1000#; -- bit 3
            Registers.GPIOD_MODER := (Registers.GPIOD_MODER
               and 2#1100_1111_1111_1111_1111_1111_1111_1111#)
                or 2#0001_0000_0000_0000_0000_0000_0000_0000#; -- bits 28-29

         when Pin_11 =>
            Registers.RCC_AHB1ENR := Registers.RCC_AHB1ENR
                or 2#1#; -- bit 0
            Registers.GPIOA_MODER := (Registers.GPIOA_MODER
               and 2#1111_1111_1111_1111_0011_1111_1111_1111#)
                or 2#0000_0000_0000_0000_0100_0000_0000_0000#; -- bits 14-15

         when Pin_12 =>
            Registers.RCC_AHB1ENR := Registers.RCC_AHB1ENR
                or 2#1#; -- bit 0
            Registers.GPIOA_MODER := (Registers.GPIOA_MODER
               and 2#1111_1111_1111_1111_1100_1111_1111_1111#)
                or 2#0000_0000_0000_0000_0001_0000_0000_0000#; -- bits 12-13

         when Pin_13 =>
            Registers.RCC_AHB1ENR := Registers.RCC_AHB1ENR
                or 2#1#; -- bit 0
            Registers.GPIOA_MODER := (Registers.GPIOA_MODER
               and 2#1111_1111_1111_1111_1111_0011_1111_1111#)
                or 2#0000_0000_0000_0000_0000_0100_0000_0000#; -- bits 10-11
      end case;
   end Enable_Output;
   
   procedure Read (Pin : in Pin_ID; State : out Boolean) is
      Data : Registers.Word;
   begin
      case Pin is
         when Pin_2 =>
            Data := Registers.GPIOF_IDR;
            State := (Data and 2#1000_0000_0000_0000#) /= 0; -- bit 15

         when Pin_3 =>
            Data := Registers.GPIOE_IDR;
            State := (Data and 2#10_0000_0000_0000#) /= 0; -- bit 13

         when Pin_4 =>
            Data := Registers.GPIOF_IDR;
            State := (Data and 2#100_0000_0000_0000#) /= 0; -- bit 14

         when Pin_5 =>
            Data := Registers.GPIOE_IDR;
            State := (Data and 2#1000_0000_0000#) /= 0; -- bit 11

         when Pin_6 =>
            Data := Registers.GPIOE_IDR;
            State := (Data and 2#10_0000_0000#) /= 0; -- bit 9

         when Pin_7 =>
            Data := Registers.GPIOF_IDR;
            State := (Data and 2#10_0000_0000_0000#) /= 0; -- bit 13

         when Pin_8 =>
            Data := Registers.GPIOF_IDR;
            State := (Data and 2#1_0000_0000_0000#) /= 0; -- bit 12

         when Pin_9 =>
            Data := Registers.GPIOD_IDR;
            State := (Data and 2#1000_0000_0000_0000#) /= 0; -- bit 15

         when Pin_10 =>
            Data := Registers.GPIOD_IDR;
            State := (Data and 2#100_0000_0000_0000#) /= 0; -- bit 14

         when Pin_11 =>
            Data := Registers.GPIOA_IDR;
            State := (Data and 2#1000_0000#) /= 0; -- bit 7

         when Pin_12 =>
            Data := Registers.GPIOA_IDR;
            State := (Data and 2#100_0000#) /= 0; -- bit 6

         when Pin_13 =>
            Data := Registers.GPIOA_IDR;
            State := (Data and 2#10_0000#) /= 0; -- bit 5
      end case;            
   end Read;

   procedure Write (Pin : in Pin_ID; State : Boolean) is
   begin
      case Pin is
         when Pin_2 =>
            if State then
               Registers.GPIOF_BSRR := 2#1000_0000_0000_0000#; -- bit 15
            else
               Registers.GPIOF_BSRR := 2#1000_0000_0000_0000_0000_0000_0000_0000#;
            end if;

         when Pin_3 =>
            if State then
               Registers.GPIOE_BSRR := 2#10_0000_0000_0000#; -- bit 13
            else
               Registers.GPIOE_BSRR := 2#10_0000_0000_0000_0000_0000_0000_0000#;
            end if;

         when Pin_4 =>
            if State then
               Registers.GPIOF_BSRR := 2#100_0000_0000_0000#; -- bit 14
            else
               Registers.GPIOF_BSRR := 2#100_0000_0000_0000_0000_0000_0000_0000#;
            end if;

         when Pin_5 =>
            if State then
               Registers.GPIOE_BSRR := 2#1000_0000_0000#; -- bit 11
            else
               Registers.GPIOE_BSRR := 2#1000_0000_0000_0000_0000_0000_0000#;
            end if;

         when Pin_6 =>
            if State then
               Registers.GPIOE_BSRR := 2#10_0000_0000#; -- bit 9
            else
               Registers.GPIOE_BSRR := 2#10_0000_0000_0000_0000_0000_0000#;
            end if;

         when Pin_7 =>
            if State then
               Registers.GPIOF_BSRR := 2#10_0000_0000_0000#; -- bit 13
            else
               Registers.GPIOF_BSRR := 2#10_0000_0000_0000_0000_0000_0000_0000#;
            end if;

         when Pin_8 =>
            if State then
               Registers.GPIOF_BSRR := 2#1_0000_0000_0000#; -- bit 12
            else
               Registers.GPIOF_BSRR := 2#1_0000_0000_0000_0000_0000_0000_0000#;
            end if;

         when Pin_9 =>
            if State then
               Registers.GPIOD_BSRR := 2#1000_0000_0000_0000#; -- bit 15
            else
               Registers.GPIOD_BSRR := 2#1000_0000_0000_0000_0000_0000_0000_0000#;
            end if;

         when Pin_10 =>
            if State then
               Registers.GPIOD_BSRR := 2#100_0000_0000_0000#; -- bit 14
            else
               Registers.GPIOD_BSRR := 2#100_0000_0000_0000_0000_0000_0000_0000#;
            end if;

         when Pin_11 =>
            if State then
               Registers.GPIOA_BSRR := 2#1000_0000#; -- bit 7
            else
               Registers.GPIOA_BSRR := 2#1000_0000_0000_0000_0000_0000#;
            end if;

         when Pin_12 =>
            if State then
               Registers.GPIOA_BSRR := 2#100_0000#; -- bit 6
            else
               Registers.GPIOA_BSRR := 2#100_0000_0000_0000_0000_0000#;
            end if;

         when Pin_13 =>
            if State then
               Registers.GPIOA_BSRR := 2#10_0000#; -- bit 5
            else
               Registers.GPIOA_BSRR := 2#10_0000_0000_0000_0000_0000#;
            end if;
      end case;
   end Write;

end Pins;

utils.adb

ADA
package body Utils is

   procedure Spin_Indefinitely is
   begin
      loop
         null;
      end loop;
   end Spin_Indefinitely;

   procedure Waste_Some_Time is
      Iterations : constant := 100_000;
   begin
      for I in 1 .. Iterations loop
         null;
      end loop;
   end Waste_Some_Time;

end Utils;

registers.adb

ADA
package Registers is

   type Word is mod 2**32;

   RCC_CR : Word;
   pragma Volatile (RCC_CR);
   pragma Import (C, RCC_CR, "RCC_CR");

   RCC_AHB1ENR : Word;
   pragma Volatile (RCC_AHB1ENR);
   pragma Import (C, RCC_AHB1ENR, "RCC_AHB1ENR");

   RCC_AHB2ENR : Word;
   pragma Volatile (RCC_AHB2ENR);
   pragma Import (C, RCC_AHB2ENR, "RCC_AHB2ENR");

   GPIOA_MODER : Word;
   pragma Volatile (GPIOA_MODER);
   pragma Import (C, GPIOA_MODER, "GPIOA_MODER");

   GPIOA_PUPDR : Word;
   pragma Volatile (GPIOA_PUPDR);
   pragma Import (C, GPIOA_PUPDR, "GPIOA_PUPDR");

   GPIOA_IDR : Word;
   pragma Volatile (GPIOA_IDR);
   pragma Import (C, GPIOA_IDR, "GPIOA_IDR");

   GPIOA_BSRR : Word;
   pragma Volatile (GPIOA_BSRR);
   pragma Import (C, GPIOA_BSRR, "GPIOA_BSRR");

   GPIOD_MODER : Word;
   pragma Volatile (GPIOD_MODER);
   pragma Import (C, GPIOD_MODER, "GPIOD_MODER");

   GPIOD_PUPDR : Word;
   pragma Volatile (GPIOD_PUPDR);
   pragma Import (C, GPIOD_PUPDR, "GPIOD_PUPDR");

   GPIOD_IDR : Word;
   pragma Volatile (GPIOD_IDR);
   pragma Import (C, GPIOD_IDR, "GPIOD_IDR");

   GPIOD_BSRR : Word;
   pragma Volatile (GPIOD_BSRR);
   pragma Import (C, GPIOD_BSRR, "GPIOD_BSRR");

   GPIOE_MODER : Word;
   pragma Volatile (GPIOE_MODER);
   pragma Import (C, GPIOE_MODER, "GPIOE_MODER");

   GPIOE_PUPDR : Word;
   pragma Volatile (GPIOE_PUPDR);
   pragma Import (C, GPIOE_PUPDR, "GPIOE_PUPDR");

   GPIOE_IDR : Word;
   pragma Volatile (GPIOE_IDR);
   pragma Import (C, GPIOE_IDR, "GPIOE_IDR");

   GPIOE_BSRR : Word;
   pragma Volatile (GPIOE_BSRR);
   pragma Import (C, GPIOE_BSRR, "GPIOE_BSRR");

   GPIOF_MODER : Word;
   pragma Volatile (GPIOF_MODER);
   pragma Import (C, GPIOF_MODER, "GPIOF_MODER");

   GPIOF_PUPDR : Word;
   pragma Volatile (GPIOF_PUPDR);
   pragma Import (C, GPIOF_PUPDR, "GPIOF_PUPDR");

   GPIOF_IDR : Word;
   pragma Volatile (GPIOF_IDR);
   pragma Import (C, GPIOF_IDR, "GPIOF_IDR");

   GPIOF_BSRR : Word;
   pragma Volatile (GPIOF_BSRR);
   pragma Import (C, GPIOF_BSRR, "GPIOF_BSRR");

   RNG_CR : Word;
   pragma Volatile (RNG_CR);
   pragma Import (C, RNG_CR, "RNG_CR");

   RNG_SR : Word;
   pragma Volatile (RNG_SR);
   pragma Import (C, RNG_SR, "RNG_SR");

   RNG_DR : Word;
   pragma Volatile (RNG_DR);
   pragma Import (C, RNG_DR, "RNG_DR");

end Registers;

Credits

Night R

Night R

16 projects • 50 followers
R&D Engineer @ IoT Solutions Provider, Robotics Engineer @ SIS Corp., Passionate for Hardware hacking, 12+ years experience in programming..

Comments