Mplab C30 Compiler [patched] Link
// Interrupt-safe put (disables interrupts) inline int c30_cbuf_put(c30_cbuf_t *cb, unsigned char data) unsigned int next_head = (cb->head + 1) & cb->mask; if (next_head == cb->tail) return -1; // full
// Interrupt-safe get inline int c30_cbuf_get(c30_cbuf_t *cb, unsigned char *data) if (cb->head == cb->tail) return -1; // empty mplab c30 compiler
int main() init_uart_buffer(); unsigned char ch; while (1) if (c30_cbuf_get(&uart_rx, &ch) == 0) // process byte head + 1) & cb->
// ------------------------------------------------------------ // 2. CIRCULAR BUFFER (with DMA/DSP-friendly alignment) // ------------------------------------------------------------ typedef struct volatile unsigned int head; volatile unsigned int tail; unsigned int mask; // size-1, must be power of two unsigned char Y_DATA_SPACE *buffer; // force Y-space for DSP unsigned int len; c30_cbuf_t; if (next_head == cb->