xref: /btstack/port/max32630-fthr/src/btstack_port.c (revision 24efff18d503b865e0dcd62b825ab5cfef2acc77)
1c894dca1SMatthias Ringwald /*******************************************************************************
2c894dca1SMatthias Ringwald * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
3c894dca1SMatthias Ringwald * Author: Ismail H. Kose <[email protected]>
4c894dca1SMatthias Ringwald *
5c894dca1SMatthias Ringwald * Permission is hereby granted, free of charge, to any person obtaining a
6c894dca1SMatthias Ringwald * copy of this software and associated documentation files (the "Software"),
7c894dca1SMatthias Ringwald * to deal in the Software without restriction, including without limitation
8c894dca1SMatthias Ringwald * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9c894dca1SMatthias Ringwald * and/or sell copies of the Software, and to permit persons to whom the
10c894dca1SMatthias Ringwald * Software is furnished to do so, subject to the following conditions:
11c894dca1SMatthias Ringwald *
12c894dca1SMatthias Ringwald * The above copyright notice and this permission notice shall be included
13c894dca1SMatthias Ringwald * in all copies or substantial portions of the Software.
14c894dca1SMatthias Ringwald *
15c894dca1SMatthias Ringwald * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16c894dca1SMatthias Ringwald * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17c894dca1SMatthias Ringwald * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18c894dca1SMatthias Ringwald * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
19c894dca1SMatthias Ringwald * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20c894dca1SMatthias Ringwald * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21c894dca1SMatthias Ringwald * OTHER DEALINGS IN THE SOFTWARE.
22c894dca1SMatthias Ringwald *
23c894dca1SMatthias Ringwald * Except as contained in this notice, the name of Maxim Integrated
24c894dca1SMatthias Ringwald * Products, Inc. shall not be used except as stated in the Maxim Integrated
25c894dca1SMatthias Ringwald * Products, Inc. Branding Policy.
26c894dca1SMatthias Ringwald *
27c894dca1SMatthias Ringwald * The mere transfer of this software does not imply any licenses
28c894dca1SMatthias Ringwald * of trade secrets, proprietary technology, copyrights, patents,
29c894dca1SMatthias Ringwald * trademarks, maskwork rights, or any other form of intellectual
30c894dca1SMatthias Ringwald * property whatsoever. Maxim Integrated Products, Inc. retains all
31c894dca1SMatthias Ringwald * ownership rights.
32c894dca1SMatthias Ringwald *******************************************************************************
33c894dca1SMatthias Ringwald */
34c894dca1SMatthias Ringwald 
35c894dca1SMatthias Ringwald #include "hal_tick.h"
36c894dca1SMatthias Ringwald #include <stdio.h>
37c894dca1SMatthias Ringwald #include <string.h>
38c894dca1SMatthias Ringwald #include "lp.h"
39c894dca1SMatthias Ringwald #include "uart.h"
40c894dca1SMatthias Ringwald #include "board.h"
41*24efff18SMatthias Ringwald #include "led.h"
42c894dca1SMatthias Ringwald #include "btstack_debug.h"
43c894dca1SMatthias Ringwald 
44c894dca1SMatthias Ringwald #include "btstack.h"
45c894dca1SMatthias Ringwald #include "btstack_config.h"
46c894dca1SMatthias Ringwald #include "btstack_run_loop_embedded.h"
47c894dca1SMatthias Ringwald #include "btstack_chipset_cc256x.h"
48c894dca1SMatthias Ringwald #include "btstack_port.h"
49c894dca1SMatthias Ringwald 
50c894dca1SMatthias Ringwald #define CC256X_UART_ID             0
51c894dca1SMatthias Ringwald #define UART_RXFIFO_USABLE     (MXC_UART_FIFO_DEPTH-3)
52c894dca1SMatthias Ringwald 
53c894dca1SMatthias Ringwald static uint32_t baud_rate;
54c894dca1SMatthias Ringwald 
55c894dca1SMatthias Ringwald // rx state
56c894dca1SMatthias Ringwald static int  bytes_to_read = 0;
57c894dca1SMatthias Ringwald static uint8_t * rx_buffer_ptr = 0;
58c894dca1SMatthias Ringwald 
59c894dca1SMatthias Ringwald // tx state
60c894dca1SMatthias Ringwald static int bytes_to_write = 0;
61c894dca1SMatthias Ringwald static uint8_t * tx_buffer_ptr = 0;
62c894dca1SMatthias Ringwald 
63c894dca1SMatthias Ringwald const gpio_cfg_t PAN1326_SLOW_CLK = { PORT_1, PIN_7, GPIO_FUNC_GPIO,
64c894dca1SMatthias Ringwald 		GPIO_PAD_NORMAL };
65c894dca1SMatthias Ringwald const gpio_cfg_t PAN1326_nSHUTD = { PORT_1, PIN_6, GPIO_FUNC_GPIO,
66c894dca1SMatthias Ringwald 		GPIO_PAD_NORMAL };
67c894dca1SMatthias Ringwald const gpio_cfg_t PAN1326_HCIRTS = { PORT_0, PIN_3, GPIO_FUNC_GPIO,
68c894dca1SMatthias Ringwald 		GPIO_PAD_NORMAL };
69c894dca1SMatthias Ringwald 
70c894dca1SMatthias Ringwald static void dummy_handler(void) {};
71c894dca1SMatthias Ringwald static void (*rx_done_handler)(void) = dummy_handler;
72c894dca1SMatthias Ringwald static void (*tx_done_handler)(void) = dummy_handler;
73c894dca1SMatthias Ringwald 
74*24efff18SMatthias Ringwald 
75*24efff18SMatthias Ringwald 
76c894dca1SMatthias Ringwald void hal_cpu_disable_irqs(void)
77c894dca1SMatthias Ringwald {
78c894dca1SMatthias Ringwald 	__disable_irq();
79c894dca1SMatthias Ringwald }
80c894dca1SMatthias Ringwald 
81c894dca1SMatthias Ringwald void hal_cpu_enable_irqs(void)
82c894dca1SMatthias Ringwald {
83c894dca1SMatthias Ringwald 	__enable_irq();
84c894dca1SMatthias Ringwald }
85c894dca1SMatthias Ringwald void hal_cpu_enable_irqs_and_sleep(void)
86c894dca1SMatthias Ringwald {
87c894dca1SMatthias Ringwald 
88c894dca1SMatthias Ringwald }
89c894dca1SMatthias Ringwald 
90c894dca1SMatthias Ringwald void hal_uart_dma_send_block(const uint8_t *buffer, uint16_t len)
91c894dca1SMatthias Ringwald {
92c894dca1SMatthias Ringwald 	tx_buffer_ptr = (uint8_t *)buffer;
93c894dca1SMatthias Ringwald 	bytes_to_write = len;
94c894dca1SMatthias Ringwald }
95c894dca1SMatthias Ringwald 
96c894dca1SMatthias Ringwald void hal_uart_dma_receive_block(uint8_t *buffer, uint16_t len)
97c894dca1SMatthias Ringwald {
98c894dca1SMatthias Ringwald 	rx_buffer_ptr = buffer;
99c894dca1SMatthias Ringwald 	bytes_to_read = len;
100c894dca1SMatthias Ringwald }
101c894dca1SMatthias Ringwald 
102c894dca1SMatthias Ringwald void hal_btstack_run_loop_execute_once(void)
103c894dca1SMatthias Ringwald {
104c894dca1SMatthias Ringwald 	int rx_avail;
105c894dca1SMatthias Ringwald 	int num_rx_bytes;
106c894dca1SMatthias Ringwald 	int tx_avail;
107c894dca1SMatthias Ringwald 	int rx_bytes;
108c894dca1SMatthias Ringwald 	int tx_bytes;
109c894dca1SMatthias Ringwald 	int ret;
110c894dca1SMatthias Ringwald 
111c894dca1SMatthias Ringwald     while (bytes_to_read) {
112c894dca1SMatthias Ringwald 		rx_avail = UART_NumReadAvail(MXC_UART_GET_UART(CC256X_UART_ID));
113c894dca1SMatthias Ringwald 		if (!rx_avail)
114c894dca1SMatthias Ringwald 			break;
115c894dca1SMatthias Ringwald 
116c894dca1SMatthias Ringwald 		if (bytes_to_read > rx_avail)
117c894dca1SMatthias Ringwald 			num_rx_bytes = rx_avail;
118c894dca1SMatthias Ringwald 		else
119c894dca1SMatthias Ringwald 			num_rx_bytes = bytes_to_read;
120c894dca1SMatthias Ringwald 
121c894dca1SMatthias Ringwald 		ret = UART_Read(MXC_UART_GET_UART(CC256X_UART_ID), rx_buffer_ptr, num_rx_bytes, &rx_bytes);
122c894dca1SMatthias Ringwald 		if (ret < 0)
123c894dca1SMatthias Ringwald 			break;
124c894dca1SMatthias Ringwald 
125c894dca1SMatthias Ringwald 		rx_buffer_ptr += rx_bytes;
126c894dca1SMatthias Ringwald         bytes_to_read -= rx_bytes;
127c894dca1SMatthias Ringwald 
128c894dca1SMatthias Ringwald 		 if (bytes_to_read < 0) {
129c894dca1SMatthias Ringwald 			bytes_to_read = 0;
130c894dca1SMatthias Ringwald 		}
131c894dca1SMatthias Ringwald 
132c894dca1SMatthias Ringwald          if (bytes_to_read == 0){
133c894dca1SMatthias Ringwald              (*rx_done_handler)();
134c894dca1SMatthias Ringwald          }
135c894dca1SMatthias Ringwald      }
136c894dca1SMatthias Ringwald 
137c894dca1SMatthias Ringwald      while (bytes_to_write) {
138c894dca1SMatthias Ringwald 		tx_avail = UART_NumWriteAvail(MXC_UART_GET_UART(CC256X_UART_ID));
139c894dca1SMatthias Ringwald 		if (!tx_avail)
140c894dca1SMatthias Ringwald 			break;
141c894dca1SMatthias Ringwald 
142c894dca1SMatthias Ringwald 		if (bytes_to_write > tx_avail)
143c894dca1SMatthias Ringwald 			tx_bytes = tx_avail;
144c894dca1SMatthias Ringwald 		else
145c894dca1SMatthias Ringwald 			tx_bytes = bytes_to_write;
146c894dca1SMatthias Ringwald 
147c894dca1SMatthias Ringwald 		ret = UART_Write(MXC_UART_GET_UART(CC256X_UART_ID), tx_buffer_ptr, tx_bytes);
148c894dca1SMatthias Ringwald 		if (ret < 0)
149c894dca1SMatthias Ringwald 			break;
150c894dca1SMatthias Ringwald 		bytes_to_write -= tx_bytes;
151c894dca1SMatthias Ringwald 		tx_buffer_ptr += tx_bytes;
152c894dca1SMatthias Ringwald 		if (bytes_to_write < 0) {
153c894dca1SMatthias Ringwald 			bytes_to_write = 0;
154c894dca1SMatthias Ringwald 		}
155c894dca1SMatthias Ringwald 
156c894dca1SMatthias Ringwald         if (bytes_to_write == 0){
157c894dca1SMatthias Ringwald              (*tx_done_handler)();
158c894dca1SMatthias Ringwald         }
159c894dca1SMatthias Ringwald      }
160c894dca1SMatthias Ringwald 
161c894dca1SMatthias Ringwald 	btstack_run_loop_embedded_execute_once();
162c894dca1SMatthias Ringwald }
163c894dca1SMatthias Ringwald 
164c894dca1SMatthias Ringwald void hal_uart_init(void)
165c894dca1SMatthias Ringwald {
166c894dca1SMatthias Ringwald 	int error = 0;
167c894dca1SMatthias Ringwald 	uart_cfg_t cfg;
168c894dca1SMatthias Ringwald 
169c894dca1SMatthias Ringwald 	cfg.parity = UART_PARITY_DISABLE;
170c894dca1SMatthias Ringwald 	cfg.size = UART_DATA_SIZE_8_BITS;
171c894dca1SMatthias Ringwald 	cfg.extra_stop = 0;
172c894dca1SMatthias Ringwald 	cfg.cts = 1;
173c894dca1SMatthias Ringwald 	cfg.rts = 1;
174c894dca1SMatthias Ringwald 
175c894dca1SMatthias Ringwald 	cfg.baud = baud_rate;
176c894dca1SMatthias Ringwald 
177c894dca1SMatthias Ringwald 	sys_cfg_uart_t sys_cfg;
178c894dca1SMatthias Ringwald 	sys_cfg.clk_scale = CLKMAN_SCALE_AUTO;
179c894dca1SMatthias Ringwald 
180c894dca1SMatthias Ringwald 	sys_cfg.io_cfg = (ioman_cfg_t )IOMAN_UART(0,
181c894dca1SMatthias Ringwald 			IOMAN_MAP_B, // io_map
182c894dca1SMatthias Ringwald 			IOMAN_MAP_B, // cts_map
183c894dca1SMatthias Ringwald 			IOMAN_MAP_B, // rts_map
184c894dca1SMatthias Ringwald 			1, // io_en
185c894dca1SMatthias Ringwald 			1, // cts_en
186c894dca1SMatthias Ringwald 			1); //rts_en
187c894dca1SMatthias Ringwald 
188c894dca1SMatthias Ringwald 	if ((error = UART_Init(MXC_UART_GET_UART(CC256X_UART_ID), &cfg, &sys_cfg)) != E_NO_ERROR) {
189c894dca1SMatthias Ringwald 		printf("Error initializing UART %d\n", error);
190c894dca1SMatthias Ringwald 		while (1);
191c894dca1SMatthias Ringwald 	} else {
192c894dca1SMatthias Ringwald 		printf("BTSTACK UART Initialized\n");
193c894dca1SMatthias Ringwald 	}
194c894dca1SMatthias Ringwald 
195c894dca1SMatthias Ringwald 	MXC_UART_GET_UART(CC256X_UART_ID)->ctrl |= MXC_F_UART_CTRL_CTS_POLARITY | MXC_F_UART_CTRL_RTS_POLARITY;
196c894dca1SMatthias Ringwald 	MXC_UART_GET_UART(CC256X_UART_ID)->ctrl &= ~((MXC_UART_FIFO_DEPTH - 4) << (MXC_F_UART_CTRL_RTS_LEVEL_POS));
197c894dca1SMatthias Ringwald 	MXC_UART_GET_UART(CC256X_UART_ID)->ctrl |= ((UART_RXFIFO_USABLE) << MXC_F_UART_CTRL_RTS_LEVEL_POS);
198c894dca1SMatthias Ringwald }
199c894dca1SMatthias Ringwald 
200c894dca1SMatthias Ringwald int hal_uart_dma_set_baud(uint32_t baud){
201c894dca1SMatthias Ringwald 	baud_rate = baud;
202c894dca1SMatthias Ringwald 	printf("BAUD RATE IS = %d \n", baud);
203c894dca1SMatthias Ringwald 	hal_uart_init();
204c894dca1SMatthias Ringwald 	return baud_rate;
205c894dca1SMatthias Ringwald }
206c894dca1SMatthias Ringwald 
207c894dca1SMatthias Ringwald void hal_uart_dma_init(void){
208c894dca1SMatthias Ringwald 	bytes_to_write = 0;
209c894dca1SMatthias Ringwald 	bytes_to_read = 0;
210c894dca1SMatthias Ringwald 	hal_uart_dma_set_baud(115200);
211c894dca1SMatthias Ringwald }
212c894dca1SMatthias Ringwald 
213c894dca1SMatthias Ringwald void hal_uart_dma_set_block_received( void (*block_handler)(void)){
214c894dca1SMatthias Ringwald 	rx_done_handler = block_handler;
215c894dca1SMatthias Ringwald }
216c894dca1SMatthias Ringwald 
217c894dca1SMatthias Ringwald void hal_uart_dma_set_block_sent( void (*block_handler)(void)){
218c894dca1SMatthias Ringwald 
219c894dca1SMatthias Ringwald 	tx_done_handler = block_handler;
220c894dca1SMatthias Ringwald }
221c894dca1SMatthias Ringwald 
222c894dca1SMatthias Ringwald void hal_uart_dma_set_csr_irq_handler( void (*csr_irq_handler)(void)){
223c894dca1SMatthias Ringwald 
224c894dca1SMatthias Ringwald }
225c894dca1SMatthias Ringwald 
226c894dca1SMatthias Ringwald void hal_uart_dma_set_sleep(uint8_t sleep){
227c894dca1SMatthias Ringwald 
228c894dca1SMatthias Ringwald }
229c894dca1SMatthias Ringwald 
230c894dca1SMatthias Ringwald void init_slow_clock(void)
231c894dca1SMatthias Ringwald {
232c894dca1SMatthias Ringwald 	MXC_PWRSEQ->reg0 &= ~(MXC_F_PWRSEQ_REG0_PWR_RTCEN_RUN | MXC_F_PWRSEQ_REG0_PWR_RTCEN_SLP);
233c894dca1SMatthias Ringwald 	MXC_PWRSEQ->reg4 &= ~MXC_F_PWRSEQ_REG4_PWR_PSEQ_32K_EN;
234c894dca1SMatthias Ringwald 	MXC_PWRSEQ->reg0 |= MXC_F_PWRSEQ_REG0_PWR_RTCEN_RUN | MXC_F_PWRSEQ_REG0_PWR_RTCEN_SLP; // Enable RTC
235c894dca1SMatthias Ringwald 	hal_delay_us(1);
236c894dca1SMatthias Ringwald 	MXC_PWRSEQ->reg4 |= MXC_F_PWRSEQ_REG4_PWR_PSEQ_32K_EN; // Enable the RTC out of P1.7
237c894dca1SMatthias Ringwald }
238c894dca1SMatthias Ringwald 
239c894dca1SMatthias Ringwald int bt_comm_init() {
240c894dca1SMatthias Ringwald 	int error = 0;
241c894dca1SMatthias Ringwald 	int cnt = 0;
242c894dca1SMatthias Ringwald 
243c894dca1SMatthias Ringwald 	hal_tick_init();
244c894dca1SMatthias Ringwald 	hal_delay_us(1);
245c894dca1SMatthias Ringwald 	if ((error = GPIO_Config(&PAN1326_HCIRTS)) != E_NO_ERROR) {
246c894dca1SMatthias Ringwald 		printf("Error setting PAN1326_HCIRTS %d\n", error);
247c894dca1SMatthias Ringwald 	}
248c894dca1SMatthias Ringwald 	GPIO_OutSet(&PAN1326_HCIRTS);
249c894dca1SMatthias Ringwald 	init_slow_clock();
250c894dca1SMatthias Ringwald 	/*
251c894dca1SMatthias Ringwald 	 * when enabling the P1.7 RTC output, P1.6 will be hardcoded to an input with 25k pullup enabled.
252c894dca1SMatthias Ringwald 	 * There is an internal pullup, so when it is set as an input, it will float high.
253c894dca1SMatthias Ringwald 	 * The PAN1326B data sheet says the NSHUTD pin is pulled down, but the input impedance is stated at 1Meg Ohm,
254c894dca1SMatthias Ringwald 	 * The so the 25k pullup should be enough to reach the minimum 1.42V to enable the device.
255c894dca1SMatthias Ringwald 	 * */
256c894dca1SMatthias Ringwald 	while (GPIO_InGet(&PAN1326_HCIRTS)) {
257c894dca1SMatthias Ringwald 		cnt++;
258c894dca1SMatthias Ringwald 	}
259c894dca1SMatthias Ringwald 
260c894dca1SMatthias Ringwald 	printf("%s CC256X init completed. cnt: %d \n", __func__, cnt);
261c894dca1SMatthias Ringwald 	return 0;
262c894dca1SMatthias Ringwald }
263c894dca1SMatthias Ringwald 
264c894dca1SMatthias Ringwald static hci_transport_config_uart_t config = {
265c894dca1SMatthias Ringwald 	    HCI_TRANSPORT_CONFIG_UART,
266c894dca1SMatthias Ringwald 	    115200,
267c894dca1SMatthias Ringwald 	    4000000,
268c894dca1SMatthias Ringwald 	    1, // flow control
269c894dca1SMatthias Ringwald 	    "max32630fthr",
270c894dca1SMatthias Ringwald 	};
271c894dca1SMatthias Ringwald 
272183c110aSMatthias Ringwald // hal_led.h implementation
273183c110aSMatthias Ringwald #include "hal_led.h"
274183c110aSMatthias Ringwald void hal_led_off(void){
275*24efff18SMatthias Ringwald 	LED_Off(LED_BLUE);
276183c110aSMatthias Ringwald }
277*24efff18SMatthias Ringwald 
278183c110aSMatthias Ringwald void hal_led_on(void){
279*24efff18SMatthias Ringwald 	LED_On(LED_BLUE);
280183c110aSMatthias Ringwald }
281*24efff18SMatthias Ringwald 
282183c110aSMatthias Ringwald void hal_led_toggle(void){
283*24efff18SMatthias Ringwald 	LED_Toggle(LED_BLUE);
284183c110aSMatthias Ringwald }
285183c110aSMatthias Ringwald 
28617ae5bc4SMatthias Ringwald #include "hal_flash_bank_mxc.h"
2875efdcd7dSMatthias Ringwald #include "btstack_tlv.h"
28817ae5bc4SMatthias Ringwald #include "btstack_tlv_flash_bank.h"
2895efdcd7dSMatthias Ringwald #include "btstack_link_key_db_tlv.h"
2905efdcd7dSMatthias Ringwald #include "le_device_db_tlv.h"
2915efdcd7dSMatthias Ringwald 
29217ae5bc4SMatthias Ringwald #define HAL_FLASH_BANK_SIZE    0x2000
29317ae5bc4SMatthias Ringwald #define HAL_FLASH_BANK_0_ADDR  0x1FC000
29417ae5bc4SMatthias Ringwald #define HAL_FLASH_BANK_1_ADDR  0x1FE000
2955efdcd7dSMatthias Ringwald 
29617ae5bc4SMatthias Ringwald static hal_flash_bank_mxc_t hal_flash_bank_context;
29717ae5bc4SMatthias Ringwald static btstack_tlv_flash_bank_t btstack_tlv_flash_bank_context;
2985efdcd7dSMatthias Ringwald 
299c894dca1SMatthias Ringwald int bluetooth_main(void)
300c894dca1SMatthias Ringwald {
301*24efff18SMatthias Ringwald 	LED_Off(LED_GREEN);
302*24efff18SMatthias Ringwald 	LED_On(LED_RED);
303*24efff18SMatthias Ringwald 	LED_Off(LED_BLUE);
304*24efff18SMatthias Ringwald 
305c894dca1SMatthias Ringwald 	bt_comm_init();
306c894dca1SMatthias Ringwald 	/* BT Stack Initialization */
307c894dca1SMatthias Ringwald 	btstack_memory_init();
308c894dca1SMatthias Ringwald 	btstack_run_loop_init(btstack_run_loop_embedded_get_instance());
309c894dca1SMatthias Ringwald 
310c894dca1SMatthias Ringwald 	/* Init HCI */
311c894dca1SMatthias Ringwald 	const hci_transport_t * transport = hci_transport_h4_instance(btstack_uart_block_embedded_instance());
312c894dca1SMatthias Ringwald 	hci_init(transport, &config);
313c894dca1SMatthias Ringwald 	hci_set_chipset(btstack_chipset_cc256x_instance());
3145efdcd7dSMatthias Ringwald 
31517ae5bc4SMatthias Ringwald     // setup TLV Flash Bank implementation
31617ae5bc4SMatthias Ringwald     const hal_flash_bank_t * hal_flash_bank_impl = hal_flash_bank_mxc_init_instance(
31717ae5bc4SMatthias Ringwald     		&hal_flash_bank_context,
31817ae5bc4SMatthias Ringwald     		HAL_FLASH_BANK_SIZE,
31917ae5bc4SMatthias Ringwald 			HAL_FLASH_BANK_0_ADDR,
32017ae5bc4SMatthias Ringwald 			HAL_FLASH_BANK_1_ADDR);
32117ae5bc4SMatthias Ringwald     const btstack_tlv_t * btstack_tlv_impl = btstack_tlv_flash_bank_init_instance(
32217ae5bc4SMatthias Ringwald     		&btstack_tlv_flash_bank_context,
32317ae5bc4SMatthias Ringwald 			hal_flash_bank_impl,
32417ae5bc4SMatthias Ringwald 			&hal_flash_bank_context);
3255efdcd7dSMatthias Ringwald 
3265efdcd7dSMatthias Ringwald     // setup Link Key DB using TLV
32717ae5bc4SMatthias Ringwald     const btstack_link_key_db_t * btstack_link_key_db = btstack_link_key_db_tlv_get_instance(btstack_tlv_impl, &btstack_tlv_flash_bank_context);
3285efdcd7dSMatthias Ringwald     hci_set_link_key_db(btstack_link_key_db);
3295efdcd7dSMatthias Ringwald 
3305efdcd7dSMatthias Ringwald     // setup LE Device DB using TLV
33117ae5bc4SMatthias Ringwald     le_device_db_tlv_configure(btstack_tlv_impl, &btstack_tlv_flash_bank_context);
3325efdcd7dSMatthias Ringwald 
3335efdcd7dSMatthias Ringwald     // go
334c894dca1SMatthias Ringwald 	btstack_main(0, (void *)NULL);
335c894dca1SMatthias Ringwald 
336c894dca1SMatthias Ringwald 	return 0;
337c894dca1SMatthias Ringwald }
338