digidotcom / xbee_ansic_library

A collection of portable ANSI C code for communicating with Digi International's XBee wireless radio modules in API mode.
204 stars 116 forks source link

Can the xbee_cbuf_putch() be used in the UART interrupt? #30

Closed acpie360 closed 1 year ago

acpie360 commented 3 years ago

If I use the xbee_cbuf_putch() in my UART interrupt to buffer incoming serial data, do I need to block the interrupt while using other cbuf functions in the main flow? Thanks.

tomlogic commented 3 years ago

The circular buffer code was written as "single producer, single consumer" and it should be safe to write to the cbuf from a UART interrupt, even if you're interrupting a read from the cbuf. If you're still unsure, you can review that code to confirm that a change to the head pointer mid-read is still safe.