@@ -9,16 +9,32 @@ defmodule CircuitsSim.GPIO.Backend do
99 alias CircuitsSim.GPIO.GPIOServer
1010 alias CircuitsSim.GPIO.Handle
1111
12+ @ impl Backend
13+ def enumerate ( _options ) do
14+ DeviceRegistry . bus_names ( :gpio )
15+ end
16+
17+ @ impl Backend
18+ def identifiers ( gpio_spec , _options ) do
19+ # Simplest possible implementation for now.
20+ { :ok , % { controller: "sim" , label: "unknown" , location: gpio_spec } }
21+ end
22+
23+ @ impl Backend
24+ def status ( _gpio_spec , _options ) do
25+ { :error , :unimplemented }
26+ end
27+
1228 @ doc """
1329 Open an GPIO handle
1430 """
1531 @ impl Backend
1632 def open ( gpio_spec , direction , options ) do
1733 with { :ok , identifiers } <- identifiers ( gpio_spec , options ) ,
18- handle = % Handle { gpio_spec: identifiers . gpio_spec } ,
19- :ok <- GPIOServer . set_direction ( identifiers . gpio_spec , direction ) ,
20- :ok <- set_pull_mode ( identifiers . gpio_spec , options [ :pull_mode ] ) ,
21- :ok <- set_initial_value ( identifiers . gpio_spec , options [ :initial_value ] ) do
34+ handle = % Handle { gpio_spec: identifiers . location } ,
35+ :ok <- GPIOServer . set_direction ( identifiers . location , direction ) ,
36+ :ok <- set_pull_mode ( identifiers . location , options [ :pull_mode ] ) ,
37+ :ok <- set_initial_value ( identifiers . location , options [ :initial_value ] ) do
2238 { :ok , handle }
2339 end
2440 end
@@ -33,7 +49,7 @@ defmodule CircuitsSim.GPIO.Backend do
3349 Return information about this backend
3450 """
3551 @ impl Backend
36- def info ( ) do
52+ def backend_info ( ) do
3753 % { backend: __MODULE__ }
3854 end
3955end
0 commit comments