mirror of
https://github.com/Fishwaldo/bl_mcu_sdk.git
synced 2025-07-23 13:18:59 +00:00
[feat][tlsf] add tlsf component
This commit is contained in:
parent
d9adf21997
commit
05e403062c
15 changed files with 1765 additions and 55 deletions
|
@ -3,7 +3,11 @@
|
|||
#include "bflb_clock.h"
|
||||
#include "bflb_rtc.h"
|
||||
#include "bflb_flash.h"
|
||||
#include "mmheap.h"
|
||||
#ifdef CONFIG_TLSF
|
||||
#include "bflb_tlsf.h"
|
||||
#else
|
||||
#include "bflb_mmheap.h"
|
||||
#endif
|
||||
#include "board.h"
|
||||
#include "bl602_glb.h"
|
||||
#include "bl602_sflash.h"
|
||||
|
@ -11,14 +15,20 @@
|
|||
extern uint32_t __HeapBase;
|
||||
extern uint32_t __HeapLimit;
|
||||
|
||||
#ifndef CONFIG_TLSF
|
||||
struct heap_info mmheap_root;
|
||||
|
||||
static struct bflb_device_s *uart0;
|
||||
|
||||
static struct heap_region system_mmheap[] = {
|
||||
{ NULL, 0 },
|
||||
{ NULL, 0 }, /* Terminates the array. */
|
||||
};
|
||||
#endif
|
||||
|
||||
static struct bflb_device_s *uart0;
|
||||
|
||||
#if defined(CONFIG_BFLOG)
|
||||
static struct bflb_device_s *rtc;
|
||||
#endif
|
||||
|
||||
static void system_clock_init(void)
|
||||
{
|
||||
|
@ -126,19 +136,28 @@ void board_init(void)
|
|||
|
||||
bflb_irq_restore(flag);
|
||||
|
||||
#ifdef CONFIG_TLSF
|
||||
bflb_mmheap_init((void *)&__HeapBase, ((size_t)&__HeapLimit - (size_t)&__HeapBase));
|
||||
#else
|
||||
system_mmheap[0].addr = (uint8_t *)&__HeapBase;
|
||||
system_mmheap[0].mem_size = ((size_t)&__HeapLimit - (size_t)&__HeapBase);
|
||||
|
||||
if (system_mmheap[0].mem_size > 0) {
|
||||
mmheap_init(&mmheap_root, system_mmheap);
|
||||
bflb_mmheap_init(&mmheap_root, system_mmheap);
|
||||
}
|
||||
#endif
|
||||
|
||||
console_init();
|
||||
|
||||
bl_show_log();
|
||||
bl_show_flashinfo();
|
||||
|
||||
printf("dynamic memory init success,heap size = %d Kbyte \r\n", system_mmheap[0].mem_size / 1024);
|
||||
printf("dynamic memory init success,heap size = %d Kbyte \r\n", ((size_t)&__HeapLimit - (size_t)&__HeapBase) / 1024);
|
||||
|
||||
printf("cgen1:%08x\r\n", getreg32(BFLB_GLB_CGEN1_BASE));
|
||||
#if defined(CONFIG_BFLOG)
|
||||
rtc = bflb_device_get_by_name("rtc");
|
||||
#endif
|
||||
}
|
||||
|
||||
void board_uartx_gpio_init()
|
||||
|
@ -183,6 +202,19 @@ void board_pwm_gpio_init()
|
|||
// bflb_gpio_init(gpio, GPIO_PIN_4, GPIO_FUNC_PWM0 | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
}
|
||||
|
||||
void board_ir_gpio_init(void)
|
||||
{
|
||||
struct bflb_device_s *gpio;
|
||||
|
||||
gpio = bflb_device_get_by_name("gpio");
|
||||
/* IR TX only support GPIO 11 */
|
||||
bflb_gpio_init(gpio, GPIO_PIN_11, GPIO_ANALOG | GPIO_SMT_EN | GPIO_DRV_0);
|
||||
|
||||
/* IR RX support GPIO 11 ~ GPIO 13 */
|
||||
bflb_gpio_init(gpio, GPIO_PIN_12, GPIO_INPUT | GPIO_SMT_EN | GPIO_DRV_0);
|
||||
GLB_IR_RX_GPIO_Sel(GLB_GPIO_PIN_12);
|
||||
}
|
||||
|
||||
void board_adc_gpio_init()
|
||||
{
|
||||
// struct bflb_device_s *gpio;
|
||||
|
@ -202,4 +234,21 @@ void board_dac_gpio_init()
|
|||
// bflb_gpio_init(gpio, GPIO_PIN_11, GPIO_ANALOG | GPIO_SMT_EN | GPIO_DRV_0);
|
||||
// /* DAC_CHB */
|
||||
// bflb_gpio_init(gpio, GPIO_PIN_17, GPIO_ANALOG | GPIO_SMT_EN | GPIO_DRV_0);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BFLOG
|
||||
__attribute__((weak)) uint64_t bflog_clock(void)
|
||||
{
|
||||
return bflb_mtimer_get_time_us();
|
||||
}
|
||||
|
||||
__attribute__((weak)) uint32_t bflog_time(void)
|
||||
{
|
||||
return BFLB_RTC_TIME2SEC(bflb_rtc_get_time(rtc));
|
||||
}
|
||||
|
||||
__attribute__((weak)) char *bflog_thread(void)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
#endif
|
|
@ -10,6 +10,7 @@ void board_adc_gpio_init();
|
|||
void board_dac_gpio_init();
|
||||
void board_emac_gpio_init();
|
||||
void board_pwm_gpio_init();
|
||||
void board_ir_gpio_init();
|
||||
|
||||
#define DEFAULT_TEST_UART "uart1"
|
||||
#define DEFAULT_TEST_UART_DMA_TX_REQUEST DMA_REQUEST_UART1_TX
|
||||
|
|
|
@ -3,7 +3,11 @@
|
|||
#include "bflb_clock.h"
|
||||
#include "bflb_rtc.h"
|
||||
#include "bflb_flash.h"
|
||||
#include "mmheap.h"
|
||||
#ifdef CONFIG_TLSF
|
||||
#include "bflb_tlsf.h"
|
||||
#else
|
||||
#include "bflb_mmheap.h"
|
||||
#endif
|
||||
#include "board.h"
|
||||
#include "bl616_tzc_sec.h"
|
||||
#include "bl616_psram.h"
|
||||
|
@ -19,12 +23,14 @@
|
|||
extern uint32_t __HeapBase;
|
||||
extern uint32_t __HeapLimit;
|
||||
|
||||
#ifndef CONFIG_TLSF
|
||||
struct heap_info mmheap_root;
|
||||
|
||||
static struct heap_region system_mmheap[] = {
|
||||
{ NULL, 0 },
|
||||
{ NULL, 0 }, /* Terminates the array. */
|
||||
};
|
||||
#endif
|
||||
|
||||
static struct bflb_device_s *uart0;
|
||||
|
||||
|
@ -54,6 +60,7 @@ static void peripheral_clock_init(void)
|
|||
PERIPHERAL_CLOCK_IR_ENABLE();
|
||||
PERIPHERAL_CLOCK_I2S_ENABLE();
|
||||
PERIPHERAL_CLOCK_USB_ENABLE();
|
||||
PERIPHERAL_CLOCK_CAN_ENABLE();
|
||||
|
||||
GLB_Set_UART_CLK(ENABLE, HBN_UART_CLK_XCLK, 0);
|
||||
GLB_Set_SPI_CLK(ENABLE, GLB_SPI_CLK_MCU_MUXPLL_160M, 0);
|
||||
|
@ -63,13 +70,12 @@ static void peripheral_clock_init(void)
|
|||
GLB_Set_DIG_512K_CLK(ENABLE, ENABLE, 0x4E);
|
||||
GLB_Set_PWM1_IO_Sel(GLB_PWM1_IO_DIFF_END);
|
||||
GLB_Set_IR_CLK(ENABLE, GLB_IR_CLK_SRC_XCLK, 19);
|
||||
GLB_Set_CAM_CLK(ENABLE, GLB_CAM_CLK_WIFIPLL_96M, 3);
|
||||
|
||||
GLB_Set_PKA_CLK_Sel(GLB_PKA_CLK_MCU_MUXPLL_160M);
|
||||
#ifdef CONFIG_BSP_SDH_SDCARD
|
||||
PERIPHERAL_CLOCK_SDH_ENABLE();
|
||||
GLB_Set_SDH_CLK(ENABLE, GLB_SDH_CLK_WIFIPLL_96M, 0);
|
||||
GLB_AHB_MCU_Software_Reset(GLB_AHB_MCU_SW_EXT_SDH);
|
||||
SDH_ClockSet(400000, 96000000, 48000000);
|
||||
#endif
|
||||
|
||||
GLB_Set_USB_CLK_From_WIFIPLL(1);
|
||||
|
@ -210,22 +216,26 @@ void board_init(void)
|
|||
|
||||
bflb_irq_restore(flag);
|
||||
|
||||
#ifdef CONFIG_TLSF
|
||||
bflb_mmheap_init((void *)&__HeapBase, ((size_t)&__HeapLimit - (size_t)&__HeapBase));
|
||||
#else
|
||||
system_mmheap[0].addr = (uint8_t *)&__HeapBase;
|
||||
system_mmheap[0].mem_size = ((size_t)&__HeapLimit - (size_t)&__HeapBase);
|
||||
|
||||
if (system_mmheap[0].mem_size > 0) {
|
||||
mmheap_init(&mmheap_root, system_mmheap);
|
||||
bflb_mmheap_init(&mmheap_root, system_mmheap);
|
||||
}
|
||||
|
||||
#endif
|
||||
console_init();
|
||||
|
||||
bl_show_log();
|
||||
bl_show_flashinfo();
|
||||
|
||||
printf("dynamic memory init success,heap size = %d Kbyte \r\n", system_mmheap[0].mem_size / 1024);
|
||||
printf("dynamic memory init success,heap size = %d Kbyte \r\n", ((size_t)&__HeapLimit - (size_t)&__HeapBase) / 1024);
|
||||
|
||||
printf("sig1:%08lx\r\n", BL_RD_REG(GLB_BASE, GLB_UART_CFG1));
|
||||
printf("sig2:%08lx\r\n", BL_RD_REG(GLB_BASE, GLB_UART_CFG2));
|
||||
printf("sig1:%08x\r\n", BL_RD_REG(GLB_BASE, GLB_UART_CFG1));
|
||||
printf("sig2:%08x\r\n", BL_RD_REG(GLB_BASE, GLB_UART_CFG2));
|
||||
printf("cgen1:%08x\r\n", getreg32(BFLB_GLB_CGEN1_BASE));
|
||||
|
||||
#if (defined(CONFIG_LUA) || defined(CONFIG_BFLOG) || defined(CONFIG_FATFS))
|
||||
rtc = bflb_device_get_by_name("rtc");
|
||||
|
@ -361,15 +371,90 @@ void board_ir_gpio_init(void)
|
|||
GLB_IR_RX_GPIO_Sel(GLB_GPIO_PIN_10);
|
||||
}
|
||||
|
||||
void board_dvp1_gpio_init(void)
|
||||
{
|
||||
struct bflb_device_s *gpio;
|
||||
|
||||
gpio = bflb_device_get_by_name("gpio");
|
||||
/* I2C GPIO */
|
||||
bflb_gpio_init(gpio, GPIO_PIN_0, GPIO_FUNC_I2C0 | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_1, GPIO_FUNC_I2C0 | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
|
||||
/* Power down GPIO */
|
||||
bflb_gpio_init(gpio, GPIO_PIN_2, GPIO_OUTPUT | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_reset(gpio, GPIO_PIN_2);
|
||||
|
||||
/* Reset GPIO */
|
||||
bflb_gpio_init(gpio, GPIO_PIN_3, GPIO_OUTPUT | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_set(gpio, GPIO_PIN_3);
|
||||
|
||||
/* MCLK GPIO */
|
||||
bflb_gpio_init(gpio, GPIO_PIN_23, GPIO_FUNC_CLKOUT | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
|
||||
/* DVP1 GPIO */
|
||||
bflb_gpio_init(gpio, GPIO_PIN_24, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_25, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_26, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_27, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_28, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_29, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_30, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_31, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_32, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_33, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_34, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
}
|
||||
|
||||
void board_dvp2_gpio_init(void)
|
||||
{
|
||||
struct bflb_device_s *gpio;
|
||||
|
||||
gpio = bflb_device_get_by_name("gpio");
|
||||
/* I2C GPIO */
|
||||
bflb_gpio_init(gpio, GPIO_PIN_28, GPIO_FUNC_I2C0 | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_27, GPIO_FUNC_I2C0 | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
|
||||
/* Power down GPIO */
|
||||
bflb_gpio_init(gpio, GPIO_PIN_29, GPIO_OUTPUT | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_reset(gpio, GPIO_PIN_29);
|
||||
|
||||
/* Reset GPIO */
|
||||
bflb_gpio_init(gpio, GPIO_PIN_30, GPIO_OUTPUT | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_set(gpio, GPIO_PIN_30);
|
||||
|
||||
/* MCLK GPIO */
|
||||
bflb_gpio_init(gpio, GPIO_PIN_20, GPIO_FUNC_CLKOUT | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
|
||||
/* DVP2 GPIO */
|
||||
bflb_gpio_init(gpio, GPIO_PIN_0, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_1, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_3, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_10, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_11, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_12, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_13, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_14, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_15, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_16, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_17, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
}
|
||||
|
||||
void board_iso11898_gpio_init()
|
||||
{
|
||||
// struct bflb_device_s *gpio;
|
||||
|
||||
// gpio = bflb_device_get_by_name("gpio");
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BFLOG
|
||||
__attribute__((weak)) uint64_t bflog_clock(void)
|
||||
{
|
||||
return CPU_Get_MTimer_Counter();
|
||||
return bflb_mtimer_get_time_us();
|
||||
}
|
||||
|
||||
__attribute__((weak)) uint32_t bflog_time(void)
|
||||
{
|
||||
return BFLB_RTC_TIME2SEC(bflb_rtc_get_time(rtc)) + 1640995200;
|
||||
return BFLB_RTC_TIME2SEC(bflb_rtc_get_time(rtc));
|
||||
}
|
||||
|
||||
__attribute__((weak)) char *bflog_thread(void)
|
||||
|
@ -381,12 +466,12 @@ __attribute__((weak)) char *bflog_thread(void)
|
|||
#ifdef CONFIG_LUA
|
||||
__attribute__((weak)) clock_t luaport_clock(void)
|
||||
{
|
||||
return (clock_t)CPU_Get_MTimer_Counter();
|
||||
return (clock_t)bflb_mtimer_get_time_us();
|
||||
}
|
||||
|
||||
__attribute__((weak)) time_t luaport_time(time_t *seconds)
|
||||
{
|
||||
time_t t = (time_t)BFLB_RTC_TIME2SEC(bflb_rtc_get_time(rtc)) + 1640995200;
|
||||
time_t t = (time_t)BFLB_RTC_TIME2SEC(bflb_rtc_get_time(rtc));
|
||||
if (seconds != NULL) {
|
||||
*seconds = t;
|
||||
}
|
||||
|
@ -401,7 +486,7 @@ __attribute__((weak)) uint32_t get_fattime(void)
|
|||
{
|
||||
bflb_timestamp_t tm;
|
||||
|
||||
bflb_timestamp_utc2time(BFLB_RTC_TIME2SEC(bflb_rtc_get_time(rtc)) + 1640995200, &tm);
|
||||
bflb_timestamp_utc2time(BFLB_RTC_TIME2SEC(bflb_rtc_get_time(rtc)), &tm);
|
||||
|
||||
return ((uint32_t)(tm.year - 1980) << 25) /* Year 2015 */
|
||||
| ((uint32_t)tm.mon << 21) /* Month 1 */
|
||||
|
|
|
@ -12,6 +12,9 @@ void board_dac_gpio_init();
|
|||
void board_emac_gpio_init();
|
||||
void board_sdh_gpio_init();
|
||||
void board_ir_gpio_init();
|
||||
void board_dvp1_gpio_init();
|
||||
void board_dvp2_gpio_init();
|
||||
void board_iso11898_gpio_init();
|
||||
|
||||
#define DEFAULT_TEST_UART "uart1"
|
||||
#define DEFAULT_TEST_UART_DMA_TX_REQUEST DMA_REQUEST_UART1_TX
|
||||
|
|
|
@ -3,7 +3,11 @@
|
|||
#include "bflb_clock.h"
|
||||
#include "bflb_rtc.h"
|
||||
#include "bflb_flash.h"
|
||||
#include "mmheap.h"
|
||||
#ifdef CONFIG_TLSF
|
||||
#include "bflb_tlsf.h"
|
||||
#else
|
||||
#include "bflb_mmheap.h"
|
||||
#endif
|
||||
#include "board.h"
|
||||
#include "bl702_glb.h"
|
||||
#include "bl702_sflash.h"
|
||||
|
@ -11,14 +15,20 @@
|
|||
extern uint32_t __HeapBase;
|
||||
extern uint32_t __HeapLimit;
|
||||
|
||||
#ifndef CONFIG_TLSF
|
||||
struct heap_info mmheap_root;
|
||||
|
||||
static struct bflb_device_s *uart0;
|
||||
|
||||
static struct heap_region system_mmheap[] = {
|
||||
{ NULL, 0 },
|
||||
{ NULL, 0 }, /* Terminates the array. */
|
||||
};
|
||||
#endif
|
||||
|
||||
static struct bflb_device_s *uart0;
|
||||
|
||||
#if defined(CONFIG_BFLOG)
|
||||
static struct bflb_device_s *rtc;
|
||||
#endif
|
||||
|
||||
static void system_clock_init(void)
|
||||
{
|
||||
|
@ -44,6 +54,7 @@ static void peripheral_clock_init(void)
|
|||
GLB_Set_UART_CLK(ENABLE, HBN_UART_CLK_96M, 0);
|
||||
GLB_Set_SPI_CLK(ENABLE, 0);
|
||||
GLB_Set_I2C_CLK(ENABLE, 0);
|
||||
GLB_Set_IR_CLK(ENABLE, GLB_IR_CLK_SRC_XCLK, 15);
|
||||
|
||||
GLB_Set_ADC_CLK(ENABLE, GLB_ADC_CLK_XCLK, 1);
|
||||
GLB_Set_DAC_CLK(ENABLE, GLB_DAC_CLK_XCLK, 0x3E);
|
||||
|
@ -131,20 +142,28 @@ void board_init(void)
|
|||
|
||||
bflb_irq_restore(flag);
|
||||
|
||||
#ifdef CONFIG_TLSF
|
||||
bflb_mmheap_init((void *)&__HeapBase, ((size_t)&__HeapLimit - (size_t)&__HeapBase));
|
||||
#else
|
||||
system_mmheap[0].addr = (uint8_t *)&__HeapBase;
|
||||
system_mmheap[0].mem_size = ((size_t)&__HeapLimit - (size_t)&__HeapBase);
|
||||
|
||||
if (system_mmheap[0].mem_size > 0) {
|
||||
mmheap_init(&mmheap_root, system_mmheap);
|
||||
bflb_mmheap_init(&mmheap_root, system_mmheap);
|
||||
}
|
||||
#endif
|
||||
|
||||
console_init();
|
||||
|
||||
bl_show_log();
|
||||
|
||||
bl_show_flashinfo();
|
||||
|
||||
printf("dynamic memory init success,heap size = %d Kbyte \r\n", system_mmheap[0].mem_size / 1024);
|
||||
printf("dynamic memory init success,heap size = %d Kbyte \r\n", ((size_t)&__HeapLimit - (size_t)&__HeapBase) / 1024);
|
||||
|
||||
printf("cgen1:%08x\r\n", getreg32(BFLB_GLB_CGEN1_BASE));
|
||||
#if defined(CONFIG_BFLOG)
|
||||
rtc = bflb_device_get_by_name("rtc");
|
||||
#endif
|
||||
}
|
||||
|
||||
void board_uartx_gpio_init()
|
||||
|
@ -192,6 +211,21 @@ void board_pwm_gpio_init()
|
|||
bflb_gpio_init(gpio, GPIO_PIN_4, GPIO_FUNC_PWM0 | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
}
|
||||
|
||||
void board_ir_gpio_init(void)
|
||||
{
|
||||
struct bflb_device_s *gpio;
|
||||
|
||||
gpio = bflb_device_get_by_name("gpio");
|
||||
/* IR TX support GPIO 22 or GPIO 23 */
|
||||
bflb_gpio_init(gpio, GPIO_PIN_22, GPIO_ANALOG | GPIO_SMT_EN | GPIO_DRV_0);
|
||||
GLB_IR_LED_Driver_Output_Disable(GLB_GPIO_PIN_23);
|
||||
GLB_IR_LED_Driver_Output_Enable(GLB_GPIO_PIN_22);
|
||||
|
||||
/* IR RX support GPIO 17 ~ GPIO 31 */
|
||||
bflb_gpio_init(gpio, GPIO_PIN_18, GPIO_INPUT | GPIO_SMT_EN | GPIO_DRV_0);
|
||||
GLB_IR_RX_GPIO_Sel(GLB_GPIO_PIN_18);
|
||||
}
|
||||
|
||||
void board_adc_gpio_init()
|
||||
{
|
||||
struct bflb_device_s *gpio;
|
||||
|
@ -232,4 +266,39 @@ void board_emac_gpio_init()
|
|||
/* enable audio clock */
|
||||
PDS_Enable_PLL_Clk(PDS_PLL_CLK_48M);
|
||||
PDS_Set_Audio_PLL_Freq(AUDIO_PLL_50000000_HZ);
|
||||
}
|
||||
}
|
||||
|
||||
void board_keyscan_gpio_init(void)
|
||||
{
|
||||
struct bflb_device_s *gpio;
|
||||
|
||||
gpio = bflb_device_get_by_name("gpio");
|
||||
bflb_gpio_init(gpio, GPIO_PIN_0, GPIO_FUN_KEY_SCAN_COL | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_OUTPUT | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_1, GPIO_FUN_KEY_SCAN_COL | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_OUTPUT | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_2, GPIO_FUN_KEY_SCAN_COL | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_OUTPUT | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_3, GPIO_FUN_KEY_SCAN_COL | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_OUTPUT | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
|
||||
bflb_gpio_init(gpio, GPIO_PIN_16, GPIO_FUN_KEY_SCAN_ROW | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_INPUT | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_17, GPIO_FUN_KEY_SCAN_ROW | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_INPUT | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_18, GPIO_FUN_KEY_SCAN_ROW | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_INPUT | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_19, GPIO_FUN_KEY_SCAN_ROW | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_INPUT | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
|
||||
GLB_Set_QDEC_CLK(GLB_QDEC_CLK_F32K, 0);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BFLOG
|
||||
__attribute__((weak)) uint64_t bflog_clock(void)
|
||||
{
|
||||
return bflb_mtimer_get_time_us();
|
||||
}
|
||||
|
||||
__attribute__((weak)) uint32_t bflog_time(void)
|
||||
{
|
||||
return BFLB_RTC_TIME2SEC(bflb_rtc_get_time(rtc));
|
||||
}
|
||||
|
||||
__attribute__((weak)) char *bflog_thread(void)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
#endif
|
|
@ -10,6 +10,7 @@ void board_adc_gpio_init();
|
|||
void board_dac_gpio_init();
|
||||
void board_emac_gpio_init();
|
||||
void board_pwm_gpio_init();
|
||||
void board_ir_gpio_init();
|
||||
|
||||
#define DEFAULT_TEST_UART "uart1"
|
||||
#define DEFAULT_TEST_UART_DMA_TX_REQUEST DMA_REQUEST_UART1_TX
|
||||
|
|
|
@ -26,7 +26,7 @@ MEMORY
|
|||
itcm_memory (rx) : ORIGIN = 0x3eff0000, LENGTH = 28K
|
||||
dtcm_memory (rx) : ORIGIN = 0x3eff7000, LENGTH = 4K
|
||||
nocache_ram_memory (!rx) : ORIGIN = 0x3eff8000, LENGTH = 0K
|
||||
ram_memory (!rx) : ORIGIN = 0x3eff8000, LENGTH = 64K
|
||||
ram_memory (!rx) : ORIGIN = 0x3eff8000, LENGTH = 32K + 32K
|
||||
xram_memory (!rx) : ORIGIN = 0x40004000, LENGTH = 16K
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,11 @@
|
|||
#include "bflb_clock.h"
|
||||
#include "bflb_rtc.h"
|
||||
#include "bflb_flash.h"
|
||||
#include "mmheap.h"
|
||||
#ifdef CONFIG_TLSF
|
||||
#include "bflb_tlsf.h"
|
||||
#else
|
||||
#include "bflb_mmheap.h"
|
||||
#endif
|
||||
#include "bl808_glb.h"
|
||||
#include "bl808_sflash.h"
|
||||
#include "bl808_psram_uhs.h"
|
||||
|
@ -19,18 +23,21 @@
|
|||
extern uint32_t __HeapBase;
|
||||
extern uint32_t __HeapLimit;
|
||||
|
||||
#ifndef CONFIG_TLSF
|
||||
struct heap_info mmheap_root;
|
||||
|
||||
static struct heap_region system_mmheap[] = {
|
||||
{ NULL, 0 },
|
||||
{ NULL, 0 }, /* Terminates the array. */
|
||||
};
|
||||
#endif
|
||||
|
||||
static struct bflb_device_s *uart0;
|
||||
|
||||
#if (defined(CONFIG_LUA) || defined(CONFIG_BFLOG) || defined(CONFIG_FATFS))
|
||||
static struct bflb_device_s *rtc;
|
||||
#endif
|
||||
|
||||
#if defined(CPU_M0)
|
||||
static void system_clock_init(void)
|
||||
{
|
||||
|
@ -42,6 +49,7 @@ static void system_clock_init(void)
|
|||
|
||||
GLB_Set_MCU_System_CLK(GLB_MCU_SYS_CLK_WIFIPLL_320M);
|
||||
GLB_Set_DSP_System_CLK(GLB_DSP_SYS_CLK_CPUPLL_400M);
|
||||
GLB_Config_CPU_PLL(GLB_XTAL_40M, cpuPllCfg_480M);
|
||||
|
||||
CPU_Set_MTimer_CLK(ENABLE, CPU_Get_MTimer_Source_Clock() / 1000 / 1000 - 1);
|
||||
}
|
||||
|
@ -60,6 +68,7 @@ static void peripheral_clock_init(void)
|
|||
PERIPHERAL_CLOCK_IR_ENABLE();
|
||||
PERIPHERAL_CLOCK_I2S_ENABLE();
|
||||
PERIPHERAL_CLOCK_USB_ENABLE();
|
||||
PERIPHERAL_CLOCK_CAN_UART2_ENABLE();
|
||||
|
||||
GLB_Set_ADC_CLK(ENABLE, GLB_ADC_CLK_XCLK, 4);
|
||||
GLB_Set_UART_CLK(ENABLE, HBN_UART_CLK_XCLK, 0);
|
||||
|
@ -71,8 +80,10 @@ static void peripheral_clock_init(void)
|
|||
GLB_Set_DIG_CLK_Sel(GLB_DIG_CLK_XCLK);
|
||||
GLB_Set_DIG_512K_CLK(ENABLE, ENABLE, 0x4E);
|
||||
GLB_Set_PWM1_IO_Sel(GLB_PWM1_IO_DIFF_END);
|
||||
GLB_Set_CAM_CLK(ENABLE, GLB_CAM_CLK_WIFIPLL_96M, 3);
|
||||
|
||||
GLB_Set_PKA_CLK_Sel(GLB_PKA_CLK_MCU_MUXPLL_160M);
|
||||
|
||||
#ifdef CONFIG_BSP_SDH_SDCARD
|
||||
PERIPHERAL_CLOCK_SDH_ENABLE();
|
||||
uint32_t tmp_val;
|
||||
|
@ -81,12 +92,11 @@ static void peripheral_clock_init(void)
|
|||
tmp_val2 &= ~(1 << 0);
|
||||
tmp_val = BL_SET_REG_BITS_VAL(tmp_val, PDS_CR_PDS_GPIO_KEEP_EN, tmp_val2);
|
||||
BL_WR_REG(PDS_BASE, PDS_CTL5, tmp_val);
|
||||
|
||||
GLB_Set_SDH_CLK(ENABLE, GLB_SDH_CLK_WIFIPLL_96M, 0);
|
||||
GLB_AHB_MCU_Software_Reset(GLB_AHB_MCU_SW_SDH);
|
||||
#endif
|
||||
GLB_Set_USB_CLK_From_WIFIPLL(1);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PSRAM
|
||||
#define WB_4MB_PSRAM (1)
|
||||
#define UHS_32MB_PSRAM (2)
|
||||
|
@ -236,12 +246,16 @@ void board_init(void)
|
|||
|
||||
bflb_irq_restore(flag);
|
||||
|
||||
#ifdef CONFIG_TLSF
|
||||
bflb_mmheap_init((void *)&__HeapBase, ((size_t)&__HeapLimit - (size_t)&__HeapBase));
|
||||
#else
|
||||
system_mmheap[0].addr = (uint8_t *)&__HeapBase;
|
||||
system_mmheap[0].mem_size = ((size_t)&__HeapLimit - (size_t)&__HeapBase);
|
||||
|
||||
if (system_mmheap[0].mem_size > 0) {
|
||||
mmheap_init(&mmheap_root, system_mmheap);
|
||||
bflb_mmheap_init(&mmheap_root, system_mmheap);
|
||||
}
|
||||
#endif
|
||||
|
||||
console_init();
|
||||
|
||||
|
@ -275,21 +289,26 @@ void board_init(void)
|
|||
|
||||
bflb_irq_initialize();
|
||||
|
||||
#ifdef CONFIG_TLSF
|
||||
bflb_mmheap_init((void *)&__HeapBase, ((size_t)&__HeapLimit - (size_t)&__HeapBase));
|
||||
#else
|
||||
system_mmheap[0].addr = (uint8_t *)&__HeapBase;
|
||||
system_mmheap[0].mem_size = ((size_t)&__HeapLimit - (size_t)&__HeapBase);
|
||||
|
||||
if (system_mmheap[0].mem_size > 0) {
|
||||
mmheap_init(&mmheap_root, system_mmheap);
|
||||
bflb_mmheap_init(&mmheap_root, system_mmheap);
|
||||
}
|
||||
#endif
|
||||
|
||||
console_init();
|
||||
|
||||
bl_show_log();
|
||||
|
||||
printf("dynamic memory init success,heap size = %d Kbyte \r\n", system_mmheap[0].mem_size / 1024);
|
||||
printf("dynamic memory init success,heap size = %d Kbyte \r\n", ((size_t)&__HeapLimit - (size_t)&__HeapBase) / 1024);
|
||||
|
||||
printf("sig1:%08x\r\n", BL_RD_REG(GLB_BASE, GLB_UART_CFG1));
|
||||
printf("sig2:%08x\r\n", BL_RD_REG(GLB_BASE, GLB_UART_CFG2));
|
||||
printf("cgen1:%08x\r\n", getreg32(BFLB_GLB_CGEN1_BASE));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -419,7 +438,6 @@ void board_emac_gpio_init(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BSP_SDH_SDCARD
|
||||
void board_sdh_gpio_init(void)
|
||||
{
|
||||
struct bflb_device_s *gpio;
|
||||
|
@ -431,27 +449,58 @@ void board_sdh_gpio_init(void)
|
|||
bflb_gpio_init(gpio, GPIO_PIN_3, GPIO_FUNC_SDH | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_2);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_4, GPIO_FUNC_SDH | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_2);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_5, GPIO_FUNC_SDH | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_2);
|
||||
|
||||
/* config sdh clock */
|
||||
SDH_ClockSet(400000, 96000000, 48000000);
|
||||
|
||||
#ifdef CONFIG_BSP_FATFS_SDH_SDCARD
|
||||
extern void fatfs_sdh_driver_register(void);
|
||||
fatfs_sdh_driver_register();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
void board_dvp1_gpio_init(void)
|
||||
{
|
||||
struct bflb_device_s *gpio;
|
||||
|
||||
gpio = bflb_device_get_by_name("gpio");
|
||||
/* I2C GPIO */
|
||||
bflb_gpio_init(gpio, GPIO_PIN_22, GPIO_FUNC_I2C0 | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_23, GPIO_FUNC_I2C0 | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
|
||||
/* Power down GPIO */
|
||||
bflb_gpio_init(gpio, GPIO_PIN_21, GPIO_OUTPUT | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_reset(gpio, GPIO_PIN_21);
|
||||
|
||||
/* Reset GPIO */
|
||||
bflb_gpio_init(gpio, GPIO_PIN_20, GPIO_OUTPUT | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_set(gpio, GPIO_PIN_20);
|
||||
|
||||
/* MCLK GPIO */
|
||||
bflb_gpio_init(gpio, GPIO_PIN_33, GPIO_FUNC_CLKOUT | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
|
||||
/* DVP1 GPIO */
|
||||
bflb_gpio_init(gpio, GPIO_PIN_16, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_17, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_24, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_25, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_26, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_27, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_28, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_29, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_30, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_31, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
bflb_gpio_init(gpio, GPIO_PIN_32, GPIO_FUNC_CAM | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
|
||||
}
|
||||
|
||||
void board_iso11898_gpio_init()
|
||||
{
|
||||
// struct bflb_device_s *gpio;
|
||||
|
||||
// gpio = bflb_device_get_by_name("gpio");
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BFLOG
|
||||
__attribute__((weak)) uint64_t bflog_clock(void)
|
||||
{
|
||||
return CPU_Get_MTimer_Counter();
|
||||
return bflb_mtimer_get_time_us();
|
||||
}
|
||||
|
||||
__attribute__((weak)) uint32_t bflog_time(void)
|
||||
{
|
||||
return BFLB_RTC_TIME2SEC(bflb_rtc_get_time(rtc)) + 1640995200;
|
||||
return BFLB_RTC_TIME2SEC(bflb_rtc_get_time(rtc));
|
||||
}
|
||||
|
||||
__attribute__((weak)) char *bflog_thread(void)
|
||||
|
@ -463,12 +512,12 @@ __attribute__((weak)) char *bflog_thread(void)
|
|||
#ifdef CONFIG_LUA
|
||||
__attribute__((weak)) clock_t luaport_clock(void)
|
||||
{
|
||||
return (clock_t)CPU_Get_MTimer_Counter();
|
||||
return (clock_t)bflb_mtimer_get_time_us();
|
||||
}
|
||||
|
||||
__attribute__((weak)) time_t luaport_time(time_t *seconds)
|
||||
{
|
||||
time_t t = (time_t)BFLB_RTC_TIME2SEC(bflb_rtc_get_time(rtc)) + 1640995200;
|
||||
time_t t = (time_t)BFLB_RTC_TIME2SEC(bflb_rtc_get_time(rtc));
|
||||
if (seconds != NULL) {
|
||||
*seconds = t;
|
||||
}
|
||||
|
@ -483,7 +532,7 @@ __attribute__((weak)) uint32_t get_fattime(void)
|
|||
{
|
||||
bflb_timestamp_t tm;
|
||||
|
||||
bflb_timestamp_utc2time(BFLB_RTC_TIME2SEC(bflb_rtc_get_time(rtc)) + 1640995200, &tm);
|
||||
bflb_timestamp_utc2time(BFLB_RTC_TIME2SEC(bflb_rtc_get_time(rtc)), &tm);
|
||||
|
||||
return ((uint32_t)(tm.year - 1980) << 25) /* Year 2015 */
|
||||
| ((uint32_t)tm.mon << 21) /* Month 1 */
|
||||
|
|
|
@ -12,15 +12,14 @@ void board_adc_gpio_init(void);
|
|||
void board_dac_gpio_init(void);
|
||||
void board_ir_gpio_init(void);
|
||||
void board_emac_gpio_init(void);
|
||||
|
||||
#ifdef CONFIG_BSP_SDH_SDCARD
|
||||
void board_sdh_gpio_init(void);
|
||||
#endif
|
||||
void board_dvp1_gpio_init(void);
|
||||
void board_iso11898_gpio_init();
|
||||
|
||||
#define DEFAULT_TEST_UART "uart1"
|
||||
#define DEFAULT_TEST_UART "uart1"
|
||||
#define DEFAULT_TEST_UART_DMA_TX_REQUEST DMA_REQUEST_UART1_TX
|
||||
#define DEFAULT_TEST_UART_DMA_RX_REQUEST DMA_REQUEST_UART1_RX
|
||||
#define DEFAULT_TEST_UART_DMA_TDR DMA_ADDR_UART1_TDR
|
||||
#define DEFAULT_TEST_UART_DMA_RDR DMA_ADDR_UART1_RDR
|
||||
#define DEFAULT_TEST_UART_DMA_TDR DMA_ADDR_UART1_TDR
|
||||
#define DEFAULT_TEST_UART_DMA_RDR DMA_ADDR_UART1_RDR
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue