UART – Set Callback Function For UART Communications
Materials
AmebaD [RTL8722DM / RTL8722CSM / RTL8722DM MINI] x 1
USB to TTL Adapter x 1
Example
RTL8722DM / RTL8722CSM Wiring Diagram:
RTL8722DM MINI Wiring Diagram:
Open the example in “File” -> “Examples” -> “AmebaSoftwareSerial” ->
“SoftwareSerial_Irq_Callback”
Once the serial port is open, type in the terminal and press the enter key, and you will see the corresponding output.
Code Reference
mySerial.setAvailableCallback(mySerialCallback); is used to set the
function mySerialCallback as a callback function for software serial.
When a new character is received, the callback function checks if the
character corresponds to the enter key, and releases the semaphore if it
is true, which in turn allows the main loop to print out all the
previously received characters.




