mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Rename fb_stack to fb_alloc and call init0 in main
This commit is contained in:
parent
cfa9b6e440
commit
db667c061f
@ -99,7 +99,7 @@ OBJ += $(wildcard $(BUILD)/$(WINC1500_DIR)/src/*.o)
|
||||
OBJ += $(addprefix $(BUILD)/$(OMV_DIR)/, \
|
||||
main.o \
|
||||
xalloc.o \
|
||||
fb_stack.o \
|
||||
fb_alloc.o \
|
||||
ff_wrapper.o \
|
||||
array.o \
|
||||
usbdbg.o \
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
SRCS += $(addprefix , \
|
||||
main.c \
|
||||
xalloc.c \
|
||||
fb_stack.c \
|
||||
fb_alloc.c \
|
||||
ff_wrapper.c \
|
||||
array.c \
|
||||
usbdbg.c \
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
*/
|
||||
#include <mp.h>
|
||||
#include "framebuffer.h"
|
||||
#include "fb_stack.h"
|
||||
#include "fb_alloc.h"
|
||||
|
||||
extern char _fs_cache;
|
||||
static char *pointer = &_fs_cache;
|
||||
@ -18,12 +18,14 @@ NORETURN static void fb_alloc_fail()
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_MemoryError, "Out of Memory!!!"));
|
||||
}
|
||||
|
||||
void fb_init() {
|
||||
void fb_alloc_init0()
|
||||
{
|
||||
pointer = &_fs_cache;
|
||||
}
|
||||
|
||||
// returns null pointer without error if size==0
|
||||
void *fb_alloc(uint32_t size) {
|
||||
void *fb_alloc(uint32_t size)
|
||||
{
|
||||
if (!size) {
|
||||
return NULL;
|
||||
}
|
||||
@ -45,13 +47,15 @@ void *fb_alloc(uint32_t size) {
|
||||
}
|
||||
|
||||
// returns null pointer without error if size==0
|
||||
void *fb_alloc0(uint32_t size) {
|
||||
void *fb_alloc0(uint32_t size)
|
||||
{
|
||||
void *mem = fb_alloc(size);
|
||||
memset(mem, 0, size);
|
||||
return mem;
|
||||
}
|
||||
|
||||
void fb_free() {
|
||||
void fb_free()
|
||||
{
|
||||
if (pointer < &_fs_cache) {
|
||||
pointer += *((uint32_t *) pointer); // Get size and pop.
|
||||
}
|
||||
@ -6,11 +6,11 @@
|
||||
* Interface for using extra frame buffer RAM as a stack.
|
||||
*
|
||||
*/
|
||||
#ifndef __FB_STACK_H__
|
||||
#define __FB_STACK_H__
|
||||
#ifndef __FB_ALLOC_H__
|
||||
#define __FB_ALLOC_H__
|
||||
#include <stdint.h>
|
||||
void fb_init();
|
||||
void fb_alloc_init0();
|
||||
void *fb_alloc(uint32_t size);
|
||||
void *fb_alloc0(uint32_t size);
|
||||
void fb_free();
|
||||
#endif /* __FF_WRAPPER_H__ */
|
||||
#endif /* __FF_ALLOC_H__ */
|
||||
@ -47,6 +47,7 @@
|
||||
#include "sensor.h"
|
||||
#include "usbdbg.h"
|
||||
#include "sdram.h"
|
||||
#include "fb_alloc.h"
|
||||
|
||||
#include "usbd_core.h"
|
||||
#include "usbd_desc.h"
|
||||
@ -312,6 +313,7 @@ soft_reset:
|
||||
uart_init0();
|
||||
pyb_usb_init0();
|
||||
sensor_init0();
|
||||
fb_alloc_init0();
|
||||
|
||||
#if MICROPY_HW_ENABLE_RTC
|
||||
if (first_soft_reset) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user