-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathrp-pio-ws2812.ads
More file actions
58 lines (47 loc) · 1.79 KB
/
Copy pathrp-pio-ws2812.ads
File metadata and controls
58 lines (47 loc) · 1.79 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
--
-- Copyright (C) 2022 Fabien Chouteau <fabien.chouteau@gmail.com>
--
-- SPDX-License-Identifier: BSD-3-Clause
--
with RP.GPIO;
with RP.DMA;
package RP.PIO.WS2812
with Preelaborate
is
type Strip
(Pin : not null access RP.GPIO.GPIO_Point;
PIO : not null access PIO_Device;
SM : PIO_SM;
Number_Of_LEDs : Positive)
is tagged record
Data : HAL.UInt32_Array (1 .. Number_Of_LEDs);
Initialized : Boolean := False;
DMA_Ready : Boolean := False;
DMA_Chan : RP.DMA.DMA_Channel_Id;
end record;
function Initialized (This : Strip) return Boolean;
function DMA_Enabled (This : Strip) return Boolean;
procedure Initialize (This : in out Strip;
ASM_Offset : PIO_Address := 0)
with Post => Initialized (This);
procedure Enable_DMA (This : in out Strip;
Chan : RP.DMA.DMA_Channel_Id)
with Pre => Initialized (This),
Post => Initialized (This) and then DMA_Enabled (This);
procedure Disable_DMA (This : in out Strip)
with Pre => Initialized (This) and then DMA_Enabled (This),
Post => Initialized (This) and then not DMA_Enabled (This);
procedure Clear (This : in out Strip);
-- Turn off all LEDs
procedure Set_RGB (This : in out Strip;
Id : Positive;
R, G, B : HAL.UInt8)
with Pre => Id <= This.Number_Of_LEDs;
procedure Set_HSV (This : in out Strip;
Id : Positive;
H, S, V : HAL.UInt8)
with Pre => Id <= This.Number_Of_LEDs;
procedure Update (This : aliased Strip;
Blocking : Boolean := False)
with Pre => Initialized (This);
end RP.PIO.WS2812;