mirror of
https://github.com/CyberMind-FR/secubox-deb.git
synced 2026-07-28 21:17:36 +00:00
Smart-Strip v1.1:
- RP2350A MCU with TrustZone-M + AT42QT2120 touch IC
- 6× RGB LEDs (SK6812-MINI-E) + 6 capacitive touch zones
- Dual-mode: USB-C 2.0 (HID+CDC) / I²C (0x42)
- Hamiltonien sweep AUTH→MESH following SecuBox charte
- Parser CDC with whitelist grammar (no eval, no dynamic alloc)
- Interactive HTML simulator included
Build fixes:
- Skip X11/kiosk packages for SECUBOX_LITE=1 profiles
- Skip netdata/glances for lite profiles (ESPRESSObin)
- Skip LXC for lite profiles (limited storage)
- ESPRESSObin image now fits in 3584M (548M compressed)
Files:
- docs/hardware/smart-strip-v1.1.md (550-line spec)
- docs/hardware/smart-strip/simulator.html
- packages/secubox-smart-strip/firmware/{parser,ring_buffer}.{c,h}
- packages/secubox-smart-strip/host/secubox_smart_strip.py
- wiki/Smart-Strip.md
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
47 lines
1.4 KiB
C
47 lines
1.4 KiB
C
/*
|
|
* ring_buffer.h - Lock-free single-producer single-consumer FIFO byte buffer
|
|
*
|
|
* Used by the Smart-Strip firmware for:
|
|
* - CDC USB ingress (USB IRQ writes, parser task reads)
|
|
* - Diagnostic log ring (parser writes drops/errors, STATUS cmd reads)
|
|
*
|
|
* Power-of-2 capacity required (mask-based wraparound, no modulo).
|
|
*
|
|
* SecuBox / CyberMind - SBX-STR-01 v1.1
|
|
*/
|
|
|
|
#ifndef SBX_RING_BUFFER_H
|
|
#define SBX_RING_BUFFER_H
|
|
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
#include <stdbool.h>
|
|
|
|
typedef struct {
|
|
uint8_t *buf;
|
|
uint16_t capacity; /* power of 2 */
|
|
uint16_t mask; /* capacity - 1 */
|
|
volatile uint16_t head; /* write index, producer */
|
|
volatile uint16_t tail; /* read index, consumer */
|
|
} rb_t;
|
|
|
|
/* Initialise. capacity MUST be a power of 2. Returns false otherwise. */
|
|
bool rb_init(rb_t *rb, uint8_t *storage, uint16_t capacity);
|
|
|
|
/* Producer side. Returns number of bytes actually written (may be < len if full). */
|
|
uint16_t rb_write(rb_t *rb, const uint8_t *src, uint16_t len);
|
|
|
|
/* Consumer side. Returns number of bytes actually read (may be < len if empty). */
|
|
uint16_t rb_read(rb_t *rb, uint8_t *dst, uint16_t len);
|
|
|
|
/* Inspectors (cheap, no locking). */
|
|
uint16_t rb_used(const rb_t *rb);
|
|
uint16_t rb_free(const rb_t *rb);
|
|
bool rb_empty(const rb_t *rb);
|
|
bool rb_full(const rb_t *rb);
|
|
|
|
/* Wipe contents. NOT safe to call concurrent with producer/consumer. */
|
|
void rb_reset(rb_t *rb);
|
|
|
|
#endif /* SBX_RING_BUFFER_H */
|