mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Add trace buffer.
* This is a simple buffer used for debugging.
This commit is contained in:
parent
10758f376b
commit
fce3b9476a
@ -154,6 +154,7 @@ FIRM_OBJ += $(addprefix $(BUILD)/$(OMV_DIR)/, \
|
|||||||
stm32fxxx_hal_msp.o \
|
stm32fxxx_hal_msp.o \
|
||||||
soft_i2c.o \
|
soft_i2c.o \
|
||||||
mutex.o \
|
mutex.o \
|
||||||
|
trace.o \
|
||||||
)
|
)
|
||||||
|
|
||||||
FIRM_OBJ += $(addprefix $(BUILD)/$(OMV_DIR)/img/,\
|
FIRM_OBJ += $(addprefix $(BUILD)/$(OMV_DIR)/img/,\
|
||||||
|
|||||||
@ -20,6 +20,7 @@ SRCS += $(addprefix , \
|
|||||||
stm32fxxx_hal_msp.c \
|
stm32fxxx_hal_msp.c \
|
||||||
soft_i2c.c \
|
soft_i2c.c \
|
||||||
mutex.c \
|
mutex.c \
|
||||||
|
trace.c \
|
||||||
)
|
)
|
||||||
|
|
||||||
SRCS += $(addprefix img/, \
|
SRCS += $(addprefix img/, \
|
||||||
|
|||||||
28
src/omv/trace.c
Normal file
28
src/omv/trace.c
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#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();
|
||||||
|
}
|
||||||
14
src/omv/trace.h
Normal file
14
src/omv/trace.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the OpenMV project.
|
||||||
|
* Copyright (c) 2013/2014 Ibrahim Abdelkader <i.abdalkader@gmail.com>
|
||||||
|
* This work is licensed under the MIT license, see the file LICENSE for details.
|
||||||
|
*
|
||||||
|
* Trace buffer.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifndef __TRACE_H__
|
||||||
|
#define __TRACE_H__
|
||||||
|
#include <stdint.h>
|
||||||
|
void trace_init();
|
||||||
|
void trace_insert(uint32_t x);
|
||||||
|
#endif /* __TRACE_H__ */
|
||||||
Loading…
Reference in New Issue
Block a user