anybody can help me to understand what this code do ?
(defun go () (with-i2c (str #x70) ;; slave select for writing operation (write-byte #x21 str) ;; starting address of writing (restart-i2c str) ;; Why i restart for writing ? Why i dont write directly ? (write-byte #x81 str) ;; am choosing a new writing address or im writing the byte #x81 ;; and in this case what is the address of register am writing (restart-i2c str) ;; same as first (write-byte #xe1 str))) ;; why the go function code is different from the set function ;; they both write a bunch of reg with some value (defun set (hr min) (with-i2c (str #x68) (write-byte 0 str) (write-byte 0 str) (write-byte min str) (write-byte hr str)))
and now the big question
if i want to read a register
transform in some way and
write back is this a right approach ?
(with-i2c (str slave-address) (write-byte value-address str) (restart-i2c str 1) (let ((val (read-byte str))) (restart-i2c str) (write-byte (transform va)l str)
thanks for your time