aboutsummaryrefslogtreecommitdiff
path: root/py/ringbuf.h
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2020-05-11 21:20:07 +1000
committerDamien George <damien.p.george@gmail.com>2020-06-05 14:04:20 +1000
commite6881f08292d03f089185718c131f543d095089b (patch)
tree1819a0b92c14bdeb3289e49c799454ba3d6cf43c /py/ringbuf.h
parent02cc4462b70729a42cb127c840fee891dd08a0d4 (diff)
extmod/modbluetooth: Make modbluetooth event not a bitfield.
There doesn't appear to be any use for only triggering on specific events, so it's just easier to number them sequentially. This makes them smaller values so they take up only 1 byte in the ringbuf, only 1 byte for the opcode in the bytecode, and makes room for more events. Also add a couple of new event types that need to be implemented (to avoid re-numbering later). And rename _COMPLETE and _STATUS to _DONE for consistency. In the future the "trigger" keyword argument can be reinstated by requiring the user to compute the bitmask, eg: ble.irq(handler, 1 << _IRQ_SCAN_RESULT | 1 << _IRQ_SCAN_DONE)
Diffstat (limited to 'py/ringbuf.h')
-rw-r--r--py/ringbuf.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/py/ringbuf.h b/py/ringbuf.h
index 293e41830..468584896 100644
--- a/py/ringbuf.h
+++ b/py/ringbuf.h
@@ -63,6 +63,13 @@ static inline int ringbuf_get(ringbuf_t *r) {
return v;
}
+static inline int ringbuf_peek(ringbuf_t *r) {
+ if (r->iget == r->iput) {
+ return -1;
+ }
+ return r->buf[r->iget];
+}
+
static inline int ringbuf_put(ringbuf_t *r, uint8_t v) {
uint32_t iput_new = r->iput + 1;
if (iput_new >= r->size) {