mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-28 19:20:54 +00:00
stm32-sx1280: extract btstack_port.c
This commit is contained in:
parent
1d870952eb
commit
80205deec3
@ -37,7 +37,7 @@ set(CMAKE_CXX_STANDARD 11)
|
||||
#add_definitions(-DARM_MATH_CM4 -DARM_MATH_MATRIX_CHECK -DARM_MATH_ROUNDING -D__FPU_PRESENT=1)
|
||||
add_definitions(-DUSE_HAL_DRIVER -DSTM32L451xx)
|
||||
|
||||
file(GLOB_RECURSE SOURCES "startup/*.*" "Drivers/*.*" "Src/*.*")
|
||||
file(GLOB_RECURSE SOURCES "startup/*.*" "Drivers/*.*" "Src/*.*" "port/*.*")
|
||||
|
||||
include_directories(Inc Drivers/STM32L4xx_HAL_Driver/Inc Drivers/STM32L4xx_HAL_Driver/Inc/Legacy Drivers/CMSIS/Device/ST/STM32L4xx/Include Drivers/CMSIS/Include)
|
||||
|
||||
|
@ -100,6 +100,7 @@ Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi.c \
|
||||
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi_ex.c \
|
||||
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c \
|
||||
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c \
|
||||
port/btstack_port.c \
|
||||
SMTC_Drivers/sx1280-driver-c/sx1280-hal.c \
|
||||
SMTC_Drivers/sx1280-driver-c/sx1280.c \
|
||||
Src/main.c \
|
||||
|
@ -60,6 +60,7 @@
|
||||
#include "btstack_tlv.h"
|
||||
#include "btstack_tlv_none.h"
|
||||
#include "ble/le_device_db_tlv.h"
|
||||
#include "hal_cpu.h"
|
||||
|
||||
// access to timers
|
||||
extern TIM_HandleTypeDef htim2;
|
||||
@ -347,22 +348,9 @@ static void (*packet_handler)(uint8_t packet_type, uint8_t *packet, uint16_t siz
|
||||
|
||||
static btstack_data_source_t hci_transport_data_source;
|
||||
|
||||
static hci_transport_t hci_transport;
|
||||
static uint8_t hci_outgoing_event[258];
|
||||
static bool hci_outgoing_event_ready;
|
||||
|
||||
void btstack_assert_failed(const char * file, uint16_t line_nr){
|
||||
printf("Assert: file %s, line %u\n", file, line_nr);
|
||||
while (1);
|
||||
}
|
||||
|
||||
/** hal_cpu.h */
|
||||
|
||||
// TODO: implement
|
||||
void hal_cpu_disable_irqs(void){}
|
||||
void hal_cpu_enable_irqs(void){}
|
||||
void hal_cpu_enable_irqs_and_sleep(void){}
|
||||
|
||||
// memory pool for acl-le pdus
|
||||
static ll_pdu_t * btstack_memory_ll_pdu_get(void){
|
||||
void * buffer = btstack_memory_pool_get(&ll_pdu_pool);
|
||||
@ -1210,57 +1198,19 @@ void controller_init(void){
|
||||
|
||||
}
|
||||
|
||||
static const hci_transport_t controller_transport = {
|
||||
"sx1280-vhci",
|
||||
&transport_init,
|
||||
&transport_open,
|
||||
&transport_close,
|
||||
&transport_register_packet_handler,
|
||||
NULL,
|
||||
&transport_send_packet,
|
||||
NULL, // set baud rate
|
||||
NULL, // reset link
|
||||
NULL, // set SCO config
|
||||
};
|
||||
|
||||
const hci_transport_t * controller_get_hci_transport(void){
|
||||
// setup hci transport wrapper
|
||||
hci_transport.name = "SX1280-VHCI";
|
||||
hci_transport.init = transport_init;
|
||||
hci_transport.open = transport_open;
|
||||
hci_transport.close = transport_close;
|
||||
hci_transport.register_packet_handler = transport_register_packet_handler;
|
||||
hci_transport.can_send_packet_now = NULL;
|
||||
hci_transport.send_packet = transport_send_packet;
|
||||
hci_transport.set_baudrate = NULL;
|
||||
return &hci_transport;
|
||||
}
|
||||
|
||||
void btstack_main(void);
|
||||
void ble_rx( void ){
|
||||
|
||||
// test code
|
||||
// lptim1_calibration();
|
||||
|
||||
// Bring up BTstack
|
||||
printf("BTstack Controller using Semtech SA1280\n");
|
||||
|
||||
btstack_memory_init();
|
||||
btstack_run_loop_init(btstack_run_loop_embedded_get_instance());
|
||||
|
||||
// initialize controller
|
||||
controller_init();
|
||||
|
||||
// get virtual HCI transpoft
|
||||
const hci_transport_t * hci_transport = controller_get_hci_transport();
|
||||
|
||||
// TODO: use flash storage
|
||||
|
||||
const btstack_tlv_t * btstack_tlv_impl = btstack_tlv_none_init_instance();
|
||||
// setup global tlv
|
||||
btstack_tlv_set_instance(btstack_tlv_impl, NULL);
|
||||
|
||||
// setup LE Device DB using TLV
|
||||
le_device_db_tlv_configure(btstack_tlv_impl, NULL);
|
||||
|
||||
// init HCI
|
||||
hci_init(hci_transport, NULL);
|
||||
|
||||
// enable full log output while porting
|
||||
hci_dump_open(NULL, HCI_DUMP_STDOUT);
|
||||
|
||||
// hand over to btstack embedded code
|
||||
btstack_main();
|
||||
|
||||
// go
|
||||
btstack_run_loop_execute();
|
||||
|
||||
while (1){};
|
||||
return &controller_transport;
|
||||
}
|
||||
|
109
port/stm32-sx1280/port/btstack_port.c
Normal file
109
port/stm32-sx1280/port/btstack_port.c
Normal file
@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (C) 2020 BlueKitchen GmbH
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holders nor the names of
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* 4. Any redistribution, use, or modification is done solely for
|
||||
* personal benefit and not for any commercial purpose or for
|
||||
* monetary gain.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
|
||||
* RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* Please inquire about commercial licensing options at
|
||||
* contact@bluekitchen-gmbh.com
|
||||
*
|
||||
*/
|
||||
|
||||
#define DEBUG
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "controller.h"
|
||||
|
||||
//#include "debug.h"
|
||||
#include "btstack_config.h"
|
||||
#include "btstack_debug.h"
|
||||
#include "btstack_util.h"
|
||||
#include "btstack_memory.h"
|
||||
#include "btstack_run_loop.h"
|
||||
#include "btstack_run_loop_embedded.h"
|
||||
#include "hci_event.h"
|
||||
#include "hci_transport.h"
|
||||
#include "btstack_tlv.h"
|
||||
#include "btstack_tlv_none.h"
|
||||
#include "ble/le_device_db_tlv.h"
|
||||
|
||||
void btstack_assert_failed(const char * file, uint16_t line_nr){
|
||||
printf("Assert: file %s, line %u\n", file, line_nr);
|
||||
while (1);
|
||||
}
|
||||
|
||||
/** hal_cpu.h */
|
||||
|
||||
// TODO: implement
|
||||
void hal_cpu_disable_irqs(void){}
|
||||
void hal_cpu_enable_irqs(void){}
|
||||
void hal_cpu_enable_irqs_and_sleep(void){}
|
||||
|
||||
void btstack_main(void);
|
||||
void ble_rx( void ){
|
||||
|
||||
// test code
|
||||
// lptim1_calibration();
|
||||
|
||||
// Bring up BTstack
|
||||
printf("BTstack Controller using Semtech SA1280\n");
|
||||
|
||||
btstack_memory_init();
|
||||
btstack_run_loop_init(btstack_run_loop_embedded_get_instance());
|
||||
|
||||
// initialize controller
|
||||
controller_init();
|
||||
|
||||
// get virtual HCI transpoft
|
||||
const hci_transport_t * hci_transport = controller_get_hci_transport();
|
||||
|
||||
// TODO: use flash storage
|
||||
|
||||
const btstack_tlv_t * btstack_tlv_impl = btstack_tlv_none_init_instance();
|
||||
// setup global tlv
|
||||
btstack_tlv_set_instance(btstack_tlv_impl, NULL);
|
||||
|
||||
// setup LE Device DB using TLV
|
||||
le_device_db_tlv_configure(btstack_tlv_impl, NULL);
|
||||
|
||||
// init HCI
|
||||
hci_init(hci_transport, NULL);
|
||||
|
||||
// enable full log output while porting
|
||||
hci_dump_open(NULL, HCI_DUMP_STDOUT);
|
||||
|
||||
// hand over to btstack embedded code
|
||||
btstack_main();
|
||||
|
||||
// go
|
||||
btstack_run_loop_execute();
|
||||
|
||||
while (1){};
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user