// ------------------------------------------------------------ // 1. SAFE BANKING MACROS (avoid manual BANKED/FAR typos) // ------------------------------------------------------------ #define BANKED_NEAR ((near)) // Accessible without PSV #define BANKED_FAR attribute ((far)) // Any RAM, slower access #define Y_DATA_SPACE attribute ((space(ymemory))) // For DSP #define AUTO_PSV attribute ((space(auto_psv))) // const in program memory
// Example: declare a large array without banking mistakes #define LARGE_BUFFER(type, name, size) type BANKED_FAR name[size] mplab c30 compiler
#endif // C30_UTILS_H #include "c30_utils.h" // Force buffer into Y data space for faster DSP-style UART processing unsigned char Y_DATA_SPACE uart_rx_buf[64]; // 64 bytes, must be power of two c30_cbuf_t uart_rx; // 64 bytes
// Interrupt-safe get inline int c30_cbuf_get(c30_cbuf_t *cb, unsigned char *data) if (cb->head == cb->tail) return -1; // empty unsigned char *data) if (cb->
// ------------------------------------------------------------ // 1. SAFE BANKING MACROS (avoid manual BANKED/FAR typos) // ------------------------------------------------------------ #define BANKED_NEAR ((near)) // Accessible without PSV #define BANKED_FAR attribute ((far)) // Any RAM, slower access #define Y_DATA_SPACE attribute ((space(ymemory))) // For DSP #define AUTO_PSV attribute ((space(auto_psv))) // const in program memory
// Example: declare a large array without banking mistakes #define LARGE_BUFFER(type, name, size) type BANKED_FAR name[size]
#endif // C30_UTILS_H #include "c30_utils.h" // Force buffer into Y data space for faster DSP-style UART processing unsigned char Y_DATA_SPACE uart_rx_buf[64]; // 64 bytes, must be power of two c30_cbuf_t uart_rx;
// Interrupt-safe get inline int c30_cbuf_get(c30_cbuf_t *cb, unsigned char *data) if (cb->head == cb->tail) return -1; // empty