mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
39 lines
795 B
C
39 lines
795 B
C
/*
|
|
* This file is part of the OpenMV project.
|
|
*
|
|
* Copyright (c) 2013-2019 Ibrahim Abdelkader <iabdalkader@openmv.io>
|
|
* Copyright (c) 2013-2019 Kwabena W. Agyeman <kwagyeman@openmv.io>
|
|
*
|
|
* This work is licensed under the MIT license, see the file LICENSE for details.
|
|
*
|
|
* Trace buffer.
|
|
*/
|
|
#include "trace.h"
|
|
#include <stdint.h>
|
|
#include STM32_HAL_H
|
|
|
|
#define TRACEBUF_SIZE (256)
|
|
typedef struct _tracebuf_t {
|
|
uint8_t idx;
|
|
uint8_t buf[TRACEBUF_SIZE];
|
|
} tracebuf_t;
|
|
|
|
static tracebuf_t tracebuf;
|
|
|
|
void trace_init()
|
|
{
|
|
tracebuf.idx = 0;
|
|
for (int i=0; i<TRACEBUF_SIZE; i++) {
|
|
tracebuf.buf[i] = 0;
|
|
}
|
|
}
|
|
|
|
void trace_insert(uint32_t x)
|
|
{
|
|
__disable_irq();
|
|
if (tracebuf.idx < TRACEBUF_SIZE) {
|
|
tracebuf.buf[tracebuf.idx++] = x;
|
|
}
|
|
__enable_irq();
|
|
}
|