pico_examples_2.0.0_cd57c29a/blog/01-zfp-blink/src/systick.adb

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
with RP2040_SVD.PPB; use RP2040_SVD.PPB;
--with RP2040_SVD;     use RP2040_SVD;
with System.Machine_Code;

package body SysTick is
    procedure SysTick_Handler is
    begin
       Ticks := Ticks + 1;
    end SysTick_Handler;

    procedure Enable is
    begin
        --  reload every 1ms
        PPB_Periph.SYST_RVR.RELOAD := SYST_RVR_RELOAD_Field (12_000_000 / 1_000);

        PPB_Periph.SYST_CSR :=
            (CLKSOURCE => True, --  cpu clock
             TICKINT   => True,
             ENABLE    => True,
             others    => <>);
    end Enable;

    procedure Wait is
    begin
       System.Machine_Code.Asm ("wfi", Volatile => True);
    end Wait;
end SysTick;