How to read and write 24-bit registers using spi code?

695 views Asked by At

I am trying to interface a heart rate sensor with my processor. All the register in it are 24-bits in size . My doubt was can I use the spi driver code from github for this purpose. I am not sure if it would read or write 24-bits. I have taken the spi code from the open source (github). Can anyone please help me out if i could use that code or not? I am providing the link for the spi driver code. Please guide me.

https://github.com/warpboard/linux-imx6/blob/warp/jb4.3_1.1.0-ga/include/linux/spi/spi.h

spi driver header file

Regards,

Sathya Prasad P

1

There are 1 answers

1
user313114 On

if your processor is running linux, I can't see why you shpuldn't use it. just when reading and writing the registers you'll have to read and wrtie 3 chars and copy those chars to and from the integer representation.

actually you'll probably have to copy the chars into a frame with other bytes and ten the whole frame and when receiving do the opposite.

if you're not running linux your may be better off going direc to to the hardware registers of your SPI and sending and receiving the bytes directly, perhaps using the makres example code,