Skip to content

Commit

Permalink
Merge branch 'master' into i2c
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Barth committed Dec 19, 2024
2 parents 4e115ce + e34746d commit 4048e29
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 16 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ On Raspberry Pi OS, the daemon `pigpiod` can be installed and launched by using
sudo apt-get install pigpiod
# enable pigpiod via system D
sudo systemctl enable pigpiod
# start pigpiod now
sudo systemctl start pigpiod
```

The daemon can also be launched manually with `sudo pigpiod` in the terminal.
Expand Down
2 changes: 1 addition & 1 deletion src/PiGPIO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module PiGPIO

export Pi

import Base: run
import Base: run, write
using Sockets

include("constants.jl")
Expand Down
10 changes: 6 additions & 4 deletions src/i2c.jl
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,10 @@ the error code).
```julia
(b, d) = i2c_read_block_data(pi, h, 10)
if b >= 0
# process data
# process data
else
# process read failure
# process read failure
end
```
"""
function i2c_read_block_data(self::Pi, handle, reg)
Expand Down Expand Up @@ -456,9 +457,10 @@ the error code).
```julia
(b, d) = i2c_read_i2c_block_data(pi, h, 4, 32)
if b >= 0
# process data
# process data
else
# process read failure
# process read failure
end
```
"""
function i2c_read_i2c_block_data(self::Pi, handle, reg, count)
Expand Down
16 changes: 11 additions & 5 deletions src/pi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ is negative it indicates an error. On error a pigpio
exception will be raised if exceptions is true.
"""
function _u2i(x::UInt32)
v = convert(Int32, x)
v = reinterpret(Int32, x)
if v < 0
if exceptions
error(error_text(v))
Expand Down Expand Up @@ -762,6 +762,7 @@ then GPIO x is high.
h = notify_open(pi)
if h >= 0
notify_begin(pi, h, 1234)
end
```
"""
function notify_open(self::Pi)
Expand All @@ -784,6 +785,7 @@ The following code starts notifications for GPIO 1, 4,
h = notify_open(pi)
if h >= 0
notify_begin(pi, h, 1234)
end
```
"""
function notify_begin(self::Pi, handle, bits)
Expand All @@ -807,6 +809,7 @@ if h >= 0
# ...
notify_begin(pi, h, 1234)
# ...
end
```
"""
function notify_pause(self::Pi, handle)
Expand All @@ -825,6 +828,7 @@ if h >= 0
# ...
notify_close(pi, h)
# ...
end
```
"""
function notify_close(self::Pi, handle)
Expand Down Expand Up @@ -1288,14 +1292,16 @@ otherwise false.
```julia
if wait_for_edge(pi, 23)
print("Rising edge detected")
print("Rising edge detected")
else
print("wait for edge timed out")
print("wait for edge timed out")
end
if wait_for_edge(pi, 23, PiGPIO.FALLING_EDGE, 5.0)
print("Falling edge detected")
print("Falling edge detected")
else
print("wait for falling edge timed out")
print("wait for falling edge timed out")
end
```
"""
function wait_for_edge(self::Pi, user_gpio, edge=RISING_EDGE, wait_timeout=60.0)
Expand Down
15 changes: 9 additions & 6 deletions src/spiSerial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function spi_open(self::Pi, spi_channel, baud, spi_flags=0)
## extension ##
# I spi_flags
extents=IOBuffer()
write(extents, spi_flags::Cint)
write(extents, Cint(spi_flags))
return _u2i(_pigpio_command_ext(
self.sl, _PI_CMD_SPIO, spi_channel, baud, 4, extents))
end
Expand Down Expand Up @@ -121,9 +121,10 @@ the error code).
```julia
(b, d) = spi_read(pi, h, 60) # read 60 bytes from device h
if b == 60
# process read data
# process read data
else
# error path
# error path
end
```
"""
function spi_read(self::Pi, handle, count)
Expand Down Expand Up @@ -296,7 +297,8 @@ the error code).
```julia
(b, d) = serial_read(pi, h2, 100)
if b > 0
# process read data
# process read data
end
```
"""
function serial_read(self::Pi, handle, count)
Expand Down Expand Up @@ -349,7 +351,8 @@ device associated with handle.
rdy = serial_data_available(pi, h1)
if rdy > 0
(b, d) = serial_read(pi, h1, rdy)
(b, d) = serial_read(pi, h1, rdy)
end
```
"""
function serial_data_available(self::Pi, handle)
Expand Down Expand Up @@ -383,7 +386,7 @@ function bb_serial_read_open(self, user_gpio, baud, bb_bits=8)
## extension ##
# I bb_bits
extents = IOBuffer()
write(extents, bb_bits::Cuint)
write(extents, Cuint(bb_bits))
return _u2i(_pigpio_command_ext(
self.sl, _PI_CMD_SLRO, user_gpio, baud, 4, extents))
end
Expand Down

0 comments on commit 4048e29

Please sign in to comment.