Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Community Manager
898 Views

Intel Edison as SPI Master read, interrupts and events in Node.JS

Jump to solution

I checked all examples and didn't find any example for read from slave SPI device. And I have some questions:

  1. In Node.JS there is a method to read data from SPI slave without write data? I know whan Spi.write(...) return reveiver buffer.
  2. There are events for receive the data over SPI?
  3. For manually select slave I should use manual GPIO manipulating for SS pin?

Maybe it's can be done only in C/C++?!

Tags (1)
0 Kudos

Accepted Solutions
Highlighted
Community Manager

Re: Intel Edison as SPI Master read, interrupts and events in Node.JS

Jump to solution

Hi Danil.Borchevkin,

 

 

I recommend you to use the MRAA library which is Node.JS compatible. This library has SPI methods that you might find useful for your application, however, there aren't methods for read-only purposes. Actually, in every SPI transfer, there is data that is sent and data that is received so you cannot write or read only. However, you can write your custom methods for only reading data from the SPI slave device. For this, you would have to use the methods provided by the MRAA library, for example the writeByte() method to send data to the SPI bus. In this case, since you are only interested on receive data from the SPI slave device, you can send dummy data and then, get the data returned by the writeByte() method: https://github.com/intel-iot-devkit/mraa

 

 

Regarding the SS pin question, you have to use a GPIO in order to select the SPI slave device manually. The GPIO should be set to HIGH to keep the SPI slave device unselected, and set it to LOW to select the device.

 

 

Hope you find this information useful.

 

 

Regards,

 

-Diego

View solution in original post

2 Replies
Highlighted
Community Manager
1 View

Re: Intel Edison as SPI Master read, interrupts and events in Node.JS

Jump to solution

Hi Danil.Borchevkin,

 

 

I recommend you to use the MRAA library which is Node.JS compatible. This library has SPI methods that you might find useful for your application, however, there aren't methods for read-only purposes. Actually, in every SPI transfer, there is data that is sent and data that is received so you cannot write or read only. However, you can write your custom methods for only reading data from the SPI slave device. For this, you would have to use the methods provided by the MRAA library, for example the writeByte() method to send data to the SPI bus. In this case, since you are only interested on receive data from the SPI slave device, you can send dummy data and then, get the data returned by the writeByte() method: https://github.com/intel-iot-devkit/mraa

 

 

Regarding the SS pin question, you have to use a GPIO in order to select the SPI slave device manually. The GPIO should be set to HIGH to keep the SPI slave device unselected, and set it to LOW to select the device.

 

 

Hope you find this information useful.

 

 

Regards,

 

-Diego

View solution in original post

Highlighted
Community Manager

Re: Intel Edison as SPI Master read, interrupts and events in Node.JS

Jump to solution

Thank for your help!

0 Kudos