How to read data from a serial (SPI) connection in C?

后端 未结 3 1522
无人及你
无人及你 2021-01-23 09:51

I am trying to write a program that will be installed on a Linux MCU (Raspberry Pi) that will read serial data coming to it from yet another MCU (something homegrown that I will

3条回答
  •  -上瘾入骨i
    2021-01-23 10:32

    On Unix everything is a file

    If the spi_bcm2708 driver installed correctly there should be a /dev/whatever file for the device ( or several for accessing the device in different ways).

    If one wasn't created automatically you can make an entry with mknod

    User space code simply has to open the /dev/whatever file as if it was any other regular file and read/write data from it. That's the whole point of Unix.

    edit: that's exactly what the code in the linked question is doing, it's opening the terminal /dev/ttyS0 as a file with open() and reading/writing to it.

提交回复
热议问题