exklibur
02/22/2025, 3:45 PMfloitsch
02/23/2025, 12:21 PM--mode=0 (the default).
If you don't trust the CS, you can just toggle the CS yourself (gpio.Pin --output and then just pin.set ...).
Since your sensor has 24-bit registers you can't use the Device.Registers facility, but you can just read and write by yourself. However in that case you might need to keep the CS active yourself between the write and read.
For example:
/**
Sends a command to the SPI-device stored in the $device_ field.
Example:
`` // Note this should be 3 '`', but my Discord response doesn't allow that.
send-command_ 0b1100_0000 // Perform single conversion.
`` // Should be 3 '`', but due to Discord...
*/
send-command_ command/int -> none:
device_.write #[command]
/**
Reads a 24-bit register from the SPI-device stored in
$device_ field.
*/
read-register_ register/int -> int:
// The CS5529_F5 only seems to have 5 registers.
assert: 0 <= register <= 4
device_.with-reserved-bus:
read-command := 0b1001_0000 | (register << 1)
device_.write #[register] --keep-cs-active
bytes := device_.read 3
return (bytes[0] << 16) | (bytes[1] << 8) | bytes[2]
unreachableexklibur
02/24/2025, 8:08 PMexklibur
02/24/2025, 8:22 PMfloitsch
02/24/2025, 8:26 PMfloitsch
02/24/2025, 8:26 PMfloitsch
02/24/2025, 8:28 PMfloitsch
02/24/2025, 8:34 PMfloitsch
02/24/2025, 8:42 PMfloitsch
02/25/2025, 4:26 PMfloitsch
02/25/2025, 4:26 PM