Home > other >  The realtek RTL8722 run MicroPython on single chip microcomputer, with SPI receiving data from the d
The realtek RTL8722 run MicroPython on single chip microcomputer, with SPI receiving data from the d

Time:04-06

SPI is a rapid and powerful communication protocol, and often in microprocessor is used to receive sensor data or output image signal, in this example will demonstrate how RTL8722 receive data through MicroPython to subordinate mode,

Before the communication connection is established, the need to burn the following code to the Arduino UNO,

 
#include
# define SS 10
Void setup (void) {
Serial.begin(115200);//set the baud rate to 115200 for usart
DigitalWrite (SS, HIGH);//disable the Slave Select
SPI. The begin ();
}

Void loop (void) {
char c;
DigitalWrite (SS, LOW);//enable Slave Select
//send the test string
For (const char * p="Hello, world! \ r "; C=* p; P++) {
SPI. Transfer (c);
Serial. Print (c);
}
Serial. Println ();
DigitalWrite (SS, HIGH);//disable the Slave Select
D


Arduino UNO will be shown in the figure below connection and RTL8722 connection, we use the first "0" group of SPI as from machine, and the Arduino UNO as SPI host


MicroPython then copy the following code and paste paste mode to REPL window, and wait for the code to take effect,
 
From the machine import SPI
S1=SPI (0, mode=SPI SLAVE)
For I in range (14) :
CRH (s1. The read ())

  • Related