diff options
author | Jim Mussared <jim.mussared@gmail.com> | 2020-05-11 21:20:07 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2020-06-05 14:04:20 +1000 |
commit | e6881f08292d03f089185718c131f543d095089b (patch) | |
tree | 1819a0b92c14bdeb3289e49c799454ba3d6cf43c /py/ringbuf.h | |
parent | 02cc4462b70729a42cb127c840fee891dd08a0d4 (diff) | |
download | micropython-e6881f08292d03f089185718c131f543d095089b.tar.gz micropython-e6881f08292d03f089185718c131f543d095089b.zip |
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.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/py/ringbuf.h b/py/ringbuf.h index 293e418306..4685848961 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) { |