atmel-samd: Update the Micro Trace Buffer to have better defines.

Same as README.md here: https://github.com/adafruit/gdb-micro-trace-buffer
This commit is contained in:
Scott Shawcroft 2016-10-05 18:42:02 -07:00
parent 90bf13efd5
commit 42f6ba04a2

View File

@ -271,8 +271,14 @@ void MP_WEAK __assert_func(const char *file, int line, const char *func, const c
struct usart_module usart_instance;
#ifdef ENABLE_MICRO_TRACE_BUFFER
#define TRACE_BUFFER_SIZE 256
__attribute__((__aligned__(TRACE_BUFFER_SIZE * sizeof(uint32_t)))) uint32_t mtb[TRACE_BUFFER_SIZE];
// Stores 2 ^ TRACE_BUFFER_MAGNITUDE_PACKETS packets.
// 7 -> 128 packets
#define TRACE_BUFFER_MAGNITUDE_PACKETS 7
// Size in uint32_t. Two per packet.
#define TRACE_BUFFER_SIZE (1 << (TRACE_BUFFER_MAGNITUDE_PACKETS + 1))
// Size in bytes. 4 bytes per uint32_t.
#define TRACE_BUFFER_SIZE_BYTES (TRACE_BUFFER_SIZE << 2)
__attribute__((__aligned__(TRACE_BUFFER_SIZE_BYTES))) uint32_t mtb[TRACE_BUFFER_SIZE];
#endif
// Serial number as hex characters.
@ -292,11 +298,9 @@ void load_serial_number(void) {
void samd21_init(void) {
#ifdef ENABLE_MICRO_TRACE_BUFFER
memset(mtb, 0, sizeof(mtb));
// AWIDTH is 15.
REG_MTB_POSITION = ((uint32_t) (mtb - REG_MTB_BASE)) & 0xFFFFFFF8;
REG_MTB_FLOW = ((uint32_t) mtb + TRACE_BUFFER_SIZE * sizeof(uint32_t)) & 0xFFFFFFF8;
REG_MTB_MASTER = 0x80000000 + 6;
REG_MTB_FLOW = (((uint32_t) mtb - REG_MTB_BASE) + TRACE_BUFFER_SIZE_BYTES) & 0xFFFFFFF8;
REG_MTB_MASTER = 0x80000000 + (TRACE_BUFFER_MAGNITUDE_PACKETS - 1);
#endif
load_serial_number();