add ble support

This commit is contained in:
greedyhao 2021-11-05 17:16:44 +08:00
parent 9e7d7ae525
commit bae4de3b1b
6 changed files with 119 additions and 9 deletions

View File

@ -0,0 +1,74 @@
/*
* Copyright (c) 2006-2021, Bluetrum Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-10-15 greedyhao the first version
*/
#include <rtthread.h>
#include <stdint.h>
#include <stddef.h>
#ifdef BSP_USING_NIMBLE
void nimble_port_run(void);
void nimble_port_init(void);
int ble_hci_rtthread_init(void);
void ble_svc_gap_init(void);
void ble_store_ram_init(void);
int blehr_main(void);
void bb_init(void);
void bthw_get_heap_info(void **p_heap, uint16_t **p_heap_size, uint32_t *p_block_size);
typedef void (*nsmem_cb_init_func)(void *heap_buf, void *heap_size_buf, uint32_t mem_block_max);
#define nsmem_cb_init ((nsmem_cb_init_func)0x84140)
int btctrl_mem_init(void)
{
void *heap_buf;
uint16_t *heap_size_buf;
uint32_t block_size;
bthw_get_heap_info(&heap_buf, &heap_size_buf, &block_size);
// rt_kprintf("heap_buf=0x%p heap_size_buf=0x%p block_size=0x%p\n", heap_buf, heap_size_buf, block_size);
nsmem_cb_init(heap_buf, heap_size_buf, block_size);
return 0;
}
INIT_BOARD_EXPORT(btctrl_mem_init);
static void blehr_thread_entry(void *param)
{
bb_init();
nimble_port_init();
ble_hci_rtthread_init();
ble_svc_gap_init();
/* XXX Need to have template for store */
ble_store_ram_init();
blehr_main();
nimble_port_run();
}
static int blehr_sample(void)
{
rt_thread_t tid = rt_thread_create(
"blehr",
blehr_thread_entry,
RT_NULL,
1024,
15,
1);
if (tid != RT_NULL) {
rt_thread_startup(tid);
}
}
MSH_CMD_EXPORT(blehr_sample, blehr_sample);
#endif

View File

@ -5,6 +5,10 @@ config SOC_AB32VG1
select PKG_USING_BLUETRUM_SDK
default y
config PKG_USING_BLUETRUM_NIMBLE
bool
default n
menu "Onboard Peripheral Drivers"
menuconfig BSP_USING_AUDIO
@ -231,7 +235,18 @@ menu "On-chip Peripheral Drivers"
endmenu
menu "Board extended module Drivers"
endmenu
choice
prompt "BLE STACK"
default BLE_STACK_USING_NULL
help
Select the ble stack
config BLE_STACK_USING_NULL
bool "not use the ble stack"
config BSP_USING_NIMBLE
bool "use nimble stack(iot)"
select PKG_USING_BLUETRUM_NIMBLE
endchoice
endmenu

View File

@ -145,6 +145,11 @@ void rt_hw_board_init(void)
#endif
}
void rt_hw_us_delay(rt_uint32_t us)
{
}
RT_SECTION(".irq.cache")
void cache_init(void)
{

View File

@ -1,17 +1,19 @@
/* Define the flash max size */
__max_flash_size = 1024k;
__max_flash_size = 1020k;
__data_ram_size = 8k;
__data_ram_size = 16k;
__stack_ram_size = 4k;
__comm_ram_size = 42k;
__heap_ram_size = 70k;
__heap_ram_size = 52k;
__ble_ram_size = 10k;
__base = 0x10000000;
__data_vma = 0x11000;
__bram_vma = 0x11000;
__heap_vma = __bram_vma + __ble_ram_size;
__data_vma = __heap_vma + __heap_ram_size;
__stack_vma = __data_vma + __data_ram_size;
__comm_vma = __stack_vma + __stack_ram_size;
__heap_vma = __comm_vma + __comm_ram_size;
__ram1_vma = 0x50000;
@ -21,6 +23,7 @@ MEMORY
flash(rx) : org = __base + 512, len = __max_flash_size
comm(rx) : org = __comm_vma, len = __comm_ram_size
bram : org = __bram_vma, len = __ble_ram_size
data : org = __data_vma, len = __data_ram_size
stack : org = __stack_vma, len = __stack_ram_size
heap : org = __heap_vma, len = __heap_ram_size
@ -89,8 +92,16 @@ SECTIONS
*(.data*)
*(.sdata*)
*(.com_text*)
*(.text.ble_mqueue_get)
*(.text.ble_mqueue_put)
*(.text.os_memblock_get)
} > comm AT > flash
.bram __bram_vma (NOLOAD) : {
*(.btmem.bthw)
*(.btmem*)
} > bram
.bss (NOLOAD):
{
__bss_start = .;

View File

@ -48,8 +48,8 @@ ASFLAGS = ""
CPPDEFINES = []
LOCAL_CPPDEFINES = []
LIBS = ['hal']
LIBPATH = [CWD]
LIBS = []
LIBPATH = []
LINKFLAGS = ""

View File

@ -96,6 +96,11 @@ __exception:
mret
#endif
.org 0x1e0
1: j 1b
nop
mret
.global cpu_irq_comm
cpu_irq_comm:
la a5, __irq_stack