[core] Move arduino/ files to cores/
This commit is contained in:
38
cores/common/base/config/fal_cfg.h
Normal file
38
cores/common/base/config/fal_cfg.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-05-24. */
|
||||
|
||||
#pragma once
|
||||
|
||||
inline void printf_nop(const char *fmt, ...) {}
|
||||
|
||||
#define FAL_PRINTF printf_nop
|
||||
#define FAL_DEBUG 0
|
||||
|
||||
// Flash device configuration
|
||||
extern const struct fal_flash_dev flash0;
|
||||
|
||||
#define FAL_FLASH_DEV_NAME "flash0"
|
||||
|
||||
#define FAL_FLASH_DEV_TABLE \
|
||||
{ &flash0, }
|
||||
|
||||
#define FAL_DEV_NAME_MAX 16 // no need for 24 chars (default)
|
||||
|
||||
// Partition table
|
||||
#define FAL_PART_HAS_TABLE_CFG
|
||||
|
||||
#define FAL_PART_TABLE_ITEM(part_lower, part_upper) \
|
||||
{ \
|
||||
.magic_word = FAL_PART_MAGIC_WORD, /* magic word */ \
|
||||
.name = #part_lower, /* lowercase name as string */ \
|
||||
.flash_name = FAL_FLASH_DEV_NAME, /* flash device name */ \
|
||||
.offset = FLASH_##part_upper##_OFFSET, /* partition offset macro as uppercase string */ \
|
||||
.len = FLASH_##part_upper##_LENGTH, /* partition length macro as uppercase string */ \
|
||||
},
|
||||
|
||||
// for fal_partition_t
|
||||
#include <fal_def.h>
|
||||
|
||||
/**
|
||||
* @brief Root partition table, representing the entire flash.
|
||||
*/
|
||||
extern fal_partition_t fal_root_part;
|
||||
49
cores/common/base/config/fdb_cfg.h
Normal file
49
cores/common/base/config/fdb_cfg.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Armink, <armink.ztl@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _FDB_CFG_H_
|
||||
#define _FDB_CFG_H_
|
||||
|
||||
/* using KVDB feature */
|
||||
#define FDB_USING_KVDB
|
||||
|
||||
#ifdef FDB_USING_KVDB
|
||||
/* Auto update KV to latest default when current KVDB version number is changed. @see fdb_kvdb.ver_num */
|
||||
// #define FDB_KV_AUTO_UPDATE
|
||||
#endif
|
||||
|
||||
/* using TSDB (Time series database) feature */
|
||||
// #define FDB_USING_TSDB
|
||||
|
||||
/* Using FAL storage mode */
|
||||
#define FDB_USING_FAL_MODE
|
||||
|
||||
#ifdef FDB_USING_FAL_MODE
|
||||
/* the flash write granularity, unit: bit
|
||||
* only support 1(nor flash)/ 8(stm32f2/f4)/ 32(stm32f1) */
|
||||
#define FDB_WRITE_GRAN 8
|
||||
#endif
|
||||
|
||||
/* Using file storage mode by LIBC file API, like fopen/fread/fwrte/fclose */
|
||||
// #define FDB_USING_FILE_LIBC_MODE
|
||||
|
||||
/* Using file storage mode by POSIX file API, like open/read/write/close */
|
||||
// #define FDB_USING_FILE_POSIX_MODE
|
||||
|
||||
/* MCU Endian Configuration, default is Little Endian Order. */
|
||||
// #define FDB_BIG_ENDIAN
|
||||
|
||||
#include <printf_config.h>
|
||||
|
||||
#if LT_DEBUG_FDB
|
||||
#include <printf/printf.h>
|
||||
#define FDB_PRINT(...) __wrap_printf(__VA_ARGS__)
|
||||
#define FDB_DEBUG_ENABLE
|
||||
#else
|
||||
#define FDB_PRINT(...)
|
||||
#endif
|
||||
|
||||
#endif /* _FDB_CFG_H_ */
|
||||
129
cores/common/base/config/printf_config.h
Normal file
129
cores/common/base/config/printf_config.h
Normal file
@@ -0,0 +1,129 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-06-19. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibreTuyaConfig.h>
|
||||
|
||||
#define PRINTF_HAS_DISABLE 1
|
||||
|
||||
// make printf.c define wrapper functions
|
||||
#define printf_ __wrap_printf
|
||||
#define sprintf_ __wrap_sprintf
|
||||
#define vsprintf_ __wrap_vsprintf
|
||||
#define snprintf_ __wrap_snprintf
|
||||
#define vsnprintf_ __wrap_vsnprintf
|
||||
#define vprintf_ __wrap_vprintf
|
||||
|
||||
// declare putchar() method with custom output port
|
||||
void putchar_p(char c, unsigned long port);
|
||||
|
||||
#define WRAP_DISABLE_DEF(name) \
|
||||
extern void __wrap_##name##_disable(); \
|
||||
extern void __wrap_##name##_enable(); \
|
||||
extern void __wrap_##name##_set(unsigned char disabled); \
|
||||
extern unsigned char __wrap_##name##_get();
|
||||
|
||||
#if !LT_UART_SILENT_ENABLED || LT_UART_SILENT_ALL
|
||||
|
||||
#define WRAP_DISABLE_DECL(name) \
|
||||
void __wrap_##name##_disable() {} \
|
||||
void __wrap_##name##_enable() {} \
|
||||
void __wrap_##name##_set(unsigned char disabled) {} \
|
||||
unsigned char __wrap_##name##_get() { \
|
||||
return LT_UART_SILENT_ALL; \
|
||||
}
|
||||
|
||||
#define WRAP_DISABLE_CHECK(name) \
|
||||
{ \
|
||||
if (LT_UART_SILENT_ALL) \
|
||||
return 0; \
|
||||
}
|
||||
|
||||
#else // LT_UART_SILENT_ENABLED && !LT_UART_SILENT_ALL
|
||||
|
||||
#define WRAP_DISABLE_DECL(name) \
|
||||
static unsigned char __wrap_##name##_disabled = 0; \
|
||||
void __wrap_##name##_disable() { \
|
||||
__wrap_##name##_disabled = 1; \
|
||||
} \
|
||||
void __wrap_##name##_enable() { \
|
||||
__wrap_##name##_disabled = 0; \
|
||||
} \
|
||||
void __wrap_##name##_set(unsigned char disabled) { \
|
||||
__wrap_##name##_disabled = disabled; \
|
||||
} \
|
||||
unsigned char __wrap_##name##_get() { \
|
||||
return __wrap_##name##_disabled; \
|
||||
}
|
||||
|
||||
#define WRAP_DISABLE_CHECK(name) \
|
||||
{ \
|
||||
if (__wrap_##name##_disabled) \
|
||||
return 0; \
|
||||
}
|
||||
|
||||
#endif // LT_UART_SILENT_ENABLED && !LT_UART_SILENT_ALL
|
||||
|
||||
#if LT_UART_SILENT_ALL
|
||||
|
||||
#define WRAP_PRINTF(name) \
|
||||
WRAP_DISABLE_DECL(name) \
|
||||
int __wrap_##name(const char *format, ...) { \
|
||||
return 0; \
|
||||
}
|
||||
|
||||
#define WRAP_VPRINTF(name) \
|
||||
WRAP_DISABLE_DECL(name) \
|
||||
int __wrap_##name(const char *format, va_list arg) { \
|
||||
return 0; \
|
||||
}
|
||||
|
||||
#else // !LT_UART_SILENT_ALL
|
||||
|
||||
#define WRAP_PRINTF(name) \
|
||||
WRAP_DISABLE_DECL(name) \
|
||||
int __wrap_##name(const char *format, ...) { \
|
||||
WRAP_DISABLE_CHECK(name); \
|
||||
va_list va; \
|
||||
va_start(va, format); \
|
||||
const int ret = vprintf(format, va); \
|
||||
va_end(va); \
|
||||
return ret; \
|
||||
}
|
||||
|
||||
#define WRAP_VPRINTF(name) \
|
||||
WRAP_DISABLE_DECL(name) \
|
||||
int __wrap_##name(const char *format, va_list arg) { \
|
||||
WRAP_DISABLE_CHECK(name); \
|
||||
return vprintf(format, arg); \
|
||||
}
|
||||
|
||||
#endif // !LT_UART_SILENT_ALL
|
||||
|
||||
#define WRAP_SPRINTF(name) \
|
||||
int __wrap_##name(char *s, const char *format, ...) { \
|
||||
va_list va; \
|
||||
va_start(va, format); \
|
||||
const int ret = vsprintf(s, format, va); \
|
||||
va_end(va); \
|
||||
return ret; \
|
||||
}
|
||||
|
||||
#define WRAP_SNPRINTF(name) \
|
||||
int __wrap_##name(char *s, size_t count, const char *format, ...) { \
|
||||
va_list va; \
|
||||
va_start(va, format); \
|
||||
const int ret = vsnprintf(s, count, format, va); \
|
||||
va_end(va); \
|
||||
return ret; \
|
||||
}
|
||||
|
||||
#define WRAP_VSPRINTF(name) \
|
||||
int __wrap_##name(char *s, const char *format, va_list arg) { \
|
||||
return vsprintf(s, format, arg); \
|
||||
}
|
||||
|
||||
#define WRAP_VSNPRINTF(name) \
|
||||
int __wrap_##name(char *s, size_t count, const char *format, va_list arg) { \
|
||||
return vsnprintf(s, count, format, arg); \
|
||||
}
|
||||
Reference in New Issue
Block a user