mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-23 19:20:51 +00:00
stm32-f4discovery-usb: add BTstack sources, build examples, add stub h2 driver
This commit is contained in:
parent
7acb1eef40
commit
4317f7c807
@ -32,23 +32,137 @@ OPT = -Og
|
||||
BUILD_DIR = build
|
||||
|
||||
BTSTACK_ROOT ?= ../..
|
||||
VPATH += ${BTSTACK_ROOT}/example
|
||||
|
||||
######################################
|
||||
# source
|
||||
######################################
|
||||
# C sources
|
||||
C_SOURCES = \
|
||||
${BTSTACK_ROOT}/3rd-party/hxcmod-player/hxcmod.c \
|
||||
${BTSTACK_ROOT}/3rd-party/hxcmod-player/mods/nao-deceased_by_disease.c \
|
||||
${BTSTACK_ROOT}/3rd-party/micro-ecc/uECC.c \
|
||||
${BTSTACK_ROOT}/3rd-party/segger-rtt/SEGGER_RTT.c \
|
||||
${BTSTACK_ROOT}/3rd-party/segger-rtt/SEGGER_RTT_printf.c \
|
||||
${BTSTACK_ROOT}/3rd-party/segger-rtt/SEGGER_RTT_Syscalls_GCC.c \
|
||||
${BTSTACK_ROOT}/3rd-party/yxml/yxml.c \
|
||||
${BTSTACK_ROOT}/3rd-party/md5/md5.c \
|
||||
${BTSTACK_ROOT}/chipset/cc256x/btstack_chipset_cc256x.c \
|
||||
${BTSTACK_ROOT}/example/sco_demo_util.c \
|
||||
${BTSTACK_ROOT}/platform/embedded/btstack_audio_embedded.c \
|
||||
${BTSTACK_ROOT}/platform/embedded/btstack_run_loop_embedded.c \
|
||||
${BTSTACK_ROOT}/platform/embedded/btstack_stdin_embedded.c \
|
||||
${BTSTACK_ROOT}/platform/embedded/btstack_tlv_flash_bank.c \
|
||||
${BTSTACK_ROOT}/platform/embedded/btstack_uart_block_embedded.c \
|
||||
${BTSTACK_ROOT}/src/ad_parser.c \
|
||||
${BTSTACK_ROOT}/src/ble/ancs_client.c \
|
||||
${BTSTACK_ROOT}/src/ble/att_db.c \
|
||||
${BTSTACK_ROOT}/src/ble/att_dispatch.c \
|
||||
${BTSTACK_ROOT}/src/ble/att_server.c \
|
||||
${BTSTACK_ROOT}/src/ble/gatt-service/battery_service_server.c \
|
||||
${BTSTACK_ROOT}/src/ble/gatt-service/device_information_service_server.c \
|
||||
${BTSTACK_ROOT}/src/ble/gatt-service/hids_device.c \
|
||||
${BTSTACK_ROOT}/src/ble/gatt_client.c \
|
||||
${BTSTACK_ROOT}/src/ble/le_device_db_memory.c \
|
||||
${BTSTACK_ROOT}/src/ble/le_device_db_tlv.c \
|
||||
${BTSTACK_ROOT}/src/ble/sm.c \
|
||||
${BTSTACK_ROOT}/src/btstack_audio.c \
|
||||
${BTSTACK_ROOT}/src/btstack_crypto.c \
|
||||
${BTSTACK_ROOT}/src/btstack_hid_parser.c \
|
||||
${BTSTACK_ROOT}/src/btstack_linked_list.c \
|
||||
${BTSTACK_ROOT}/src/btstack_memory.c \
|
||||
${BTSTACK_ROOT}/src/btstack_memory_pool.c \
|
||||
${BTSTACK_ROOT}/src/btstack_resample.c \
|
||||
${BTSTACK_ROOT}/src/btstack_ring_buffer.c \
|
||||
${BTSTACK_ROOT}/src/btstack_run_loop.c \
|
||||
${BTSTACK_ROOT}/src/btstack_tlv.c \
|
||||
${BTSTACK_ROOT}/src/btstack_util.c \
|
||||
${BTSTACK_ROOT}/src/classic/a2dp_sink.c \
|
||||
${BTSTACK_ROOT}/src/classic/a2dp_source.c \
|
||||
${BTSTACK_ROOT}/src/classic/avdtp.c \
|
||||
${BTSTACK_ROOT}/src/classic/avdtp_acceptor.c \
|
||||
${BTSTACK_ROOT}/src/classic/avdtp_initiator.c \
|
||||
${BTSTACK_ROOT}/src/classic/avdtp_sink.c \
|
||||
${BTSTACK_ROOT}/src/classic/avdtp_source.c \
|
||||
${BTSTACK_ROOT}/src/classic/avdtp_util.c \
|
||||
${BTSTACK_ROOT}/src/classic/avrcp.c \
|
||||
${BTSTACK_ROOT}/src/classic/avrcp_browsing_controller.c \
|
||||
${BTSTACK_ROOT}/src/classic/avrcp_controller.c \
|
||||
${BTSTACK_ROOT}/src/classic/avrcp_media_item_iterator.c \
|
||||
${BTSTACK_ROOT}/src/classic/avrcp_target.c \
|
||||
${BTSTACK_ROOT}/src/classic/bnep.c \
|
||||
${BTSTACK_ROOT}/src/classic/btstack_cvsd_plc.c \
|
||||
${BTSTACK_ROOT}/src/classic/btstack_link_key_db_tlv.c \
|
||||
${BTSTACK_ROOT}/src/classic/btstack_sbc_decoder_bluedroid.c \
|
||||
${BTSTACK_ROOT}/src/classic/btstack_sbc_encoder_bluedroid.c \
|
||||
${BTSTACK_ROOT}/src/classic/btstack_sbc_plc.c \
|
||||
${BTSTACK_ROOT}/src/classic/device_id_server.c \
|
||||
${BTSTACK_ROOT}/src/classic/goep_client.c \
|
||||
${BTSTACK_ROOT}/src/classic/hfp.c \
|
||||
${BTSTACK_ROOT}/src/classic/hfp_ag.c \
|
||||
${BTSTACK_ROOT}/src/classic/hfp_gsm_model.c \
|
||||
${BTSTACK_ROOT}/src/classic/hfp_hf.c \
|
||||
${BTSTACK_ROOT}/src/classic/hfp_msbc.c \
|
||||
${BTSTACK_ROOT}/src/classic/hid_device.c \
|
||||
${BTSTACK_ROOT}/src/classic/hsp_ag.c \
|
||||
${BTSTACK_ROOT}/src/classic/hsp_hs.c \
|
||||
${BTSTACK_ROOT}/src/classic/obex_iterator.c \
|
||||
${BTSTACK_ROOT}/src/classic/obex_message_builder.c \
|
||||
${BTSTACK_ROOT}/src/classic/pan.c \
|
||||
${BTSTACK_ROOT}/src/classic/pbap_client.c \
|
||||
${BTSTACK_ROOT}/src/classic/rfcomm.c \
|
||||
${BTSTACK_ROOT}/src/classic/sdp_client.c \
|
||||
${BTSTACK_ROOT}/src/classic/sdp_client_rfcomm.c \
|
||||
${BTSTACK_ROOT}/src/classic/sdp_server.c \
|
||||
${BTSTACK_ROOT}/src/classic/sdp_util.c \
|
||||
${BTSTACK_ROOT}/src/classic/spp_server.c \
|
||||
${BTSTACK_ROOT}/src/hci.c \
|
||||
${BTSTACK_ROOT}/src/hci_cmd.c \
|
||||
${BTSTACK_ROOT}/src/hci_dump.c \
|
||||
${BTSTACK_ROOT}/src/hci_transport_h4.c \
|
||||
${BTSTACK_ROOT}/src/l2cap.c \
|
||||
${BTSTACK_ROOT}/src/l2cap_signaling.c \
|
||||
${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/def.c \
|
||||
${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/inet_chksum.c \
|
||||
${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/init.c \
|
||||
${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ip.c \
|
||||
${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/mem.c \
|
||||
${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/memp.c \
|
||||
${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/netif.c \
|
||||
${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/pbuf.c \
|
||||
${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/tcp.c \
|
||||
${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/tcp_in.c \
|
||||
${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/tcp_out.c \
|
||||
${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/timeouts.c \
|
||||
${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/udp.c \
|
||||
${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/acd.c \
|
||||
${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/dhcp.c \
|
||||
${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/etharp.c \
|
||||
${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/icmp.c \
|
||||
${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/ip4.c \
|
||||
${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/ip4_addr.c \
|
||||
${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/ip4_frag.c \
|
||||
${BTSTACK_ROOT}/3rd-party/lwip/core/src/netif/ethernet.c \
|
||||
${BTSTACK_ROOT}/3rd-party/lwip/core/src/apps/http/altcp_proxyconnect.c \
|
||||
${BTSTACK_ROOT}/3rd-party/lwip/core/src/apps/http/fs.c \
|
||||
${BTSTACK_ROOT}/3rd-party/lwip/core/src/apps/http/httpd.c \
|
||||
${BTSTACK_ROOT}/3rd-party/lwip/dhcp-server/dhserver.c \
|
||||
${BTSTACK_ROOT}/platform/lwip/port/sys_arch.c \
|
||||
${BTSTACK_ROOT}/platform/lwip/bnep_lwip.c \
|
||||
port/port.c \
|
||||
port/usbh_bluetooth.c \
|
||||
port/hci_transport_h2_stm32.c \
|
||||
port/hal_flash_bank_stm32.c \
|
||||
Core/Src/main.c \
|
||||
Core/Src/stm32f4xx_it.c \
|
||||
Core/Src/stm32f4xx_hal_msp.c \
|
||||
${BTSTACK_ROOT}/3rd-party/segger-rtt/SEGGER_RTT.c \
|
||||
${BTSTACK_ROOT}/3rd-party/segger-rtt/SEGGER_RTT_Syscalls_GCC.c \
|
||||
Core/Src/system_stm32f4xx.c \
|
||||
USB_HOST/App/usb_host.c \
|
||||
USB_HOST/Target/usbh_conf.c \
|
||||
USB_HOST/Target/usbh_platform.c \
|
||||
USB_HOST/App/usb_host.c \
|
||||
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_hcd.c \
|
||||
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c \
|
||||
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c \
|
||||
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c \
|
||||
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c \
|
||||
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c \
|
||||
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c \
|
||||
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c \
|
||||
@ -62,17 +176,12 @@ Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c \
|
||||
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c \
|
||||
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c \
|
||||
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c \
|
||||
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c \
|
||||
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c \
|
||||
Core/Src/system_stm32f4xx.c \
|
||||
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_hcd.c \
|
||||
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c \
|
||||
Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_core.c \
|
||||
Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_ctlreq.c \
|
||||
Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_ioreq.c \
|
||||
Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_pipes.c \
|
||||
Middlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid.c \
|
||||
Middlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid_keybd.c \
|
||||
Middlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid_mouse.c \
|
||||
Middlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid_parser.c
|
||||
|
||||
# ASM sources
|
||||
ASM_SOURCES = \
|
||||
@ -129,17 +238,39 @@ AS_INCLUDES =
|
||||
|
||||
# C includes
|
||||
C_INCLUDES = \
|
||||
-IUSB_HOST/App \
|
||||
-IUSB_HOST/Target \
|
||||
-ICore/Inc \
|
||||
-IDrivers/STM32F4xx_HAL_Driver/Inc \
|
||||
-IDrivers/STM32F4xx_HAL_Driver/Inc/Legacy \
|
||||
-IMiddlewares/ST/STM32_USB_Host_Library/Core/Inc \
|
||||
-IMiddlewares/ST/STM32_USB_Host_Library/Class/HID/Inc \
|
||||
-IDrivers/CMSIS/Device/ST/STM32F4xx/Include \
|
||||
-IDrivers/CMSIS/Include \
|
||||
-Iport
|
||||
-IMiddlewares/ST/STM32_USB_Host_Library/Core/Inc \
|
||||
-IMiddlewares/ST/STM32_USB_Host_Library/Class/HID/Inc \
|
||||
|
||||
C_INCLUDES += -I$(BUILD_DIR)
|
||||
C_INCLUDES += -I${BTSTACK_ROOT}/src/ble
|
||||
C_INCLUDES += -I${BTSTACK_ROOT}/src/ble/gatt-service
|
||||
C_INCLUDES += -I${BTSTACK_ROOT}/src/classic
|
||||
C_INCLUDES += -I${BTSTACK_ROOT}/src
|
||||
C_INCLUDES += -I${BTSTACK_ROOT}/3rd-party/micro-ecc
|
||||
C_INCLUDES += -I${BTSTACK_ROOT}/3rd-party/bluedroid/decoder/include
|
||||
C_INCLUDES += -I${BTSTACK_ROOT}/3rd-party/bluedroid/encoder/include
|
||||
C_INCLUDES += -I${BTSTACK_ROOT}/3rd-party/hxcmod-player
|
||||
C_INCLUDES += -I${BTSTACK_ROOT}/3rd-party/hxcmod-player/mods
|
||||
C_INCLUDES += -I${BTSTACK_ROOT}/3rd-party/lwip/core/src/include
|
||||
C_INCLUDES += -I${BTSTACK_ROOT}/3rd-party/lwip/dhcp-server
|
||||
C_INCLUDES += -I${BTSTACK_ROOT}/3rd-party/md5
|
||||
C_INCLUDES += -I${BTSTACK_ROOT}/3rd-party/yxml
|
||||
C_INCLUDES += -I${BTSTACK_ROOT}/3rd-party/segger-rtt
|
||||
C_INCLUDES += -I${BTSTACK_ROOT}/platform/embedded
|
||||
C_INCLUDES += -I${BTSTACK_ROOT}/platform/lwip
|
||||
C_INCLUDES += -I${BTSTACK_ROOT}/platform/lwip/port
|
||||
|
||||
C_INCLUDES += -I bsp
|
||||
C_INCLUDES += -I pdm
|
||||
C_INCLUDES += -I port
|
||||
C_INCLUDES += -I Core/Src
|
||||
C_INCLUDES += -I USB_HOST/Target
|
||||
C_INCLUDES += -I USB_HOST/App
|
||||
|
||||
# compile gcc flags
|
||||
ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
|
||||
@ -167,7 +298,64 @@ LIBDIR =
|
||||
LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
|
||||
|
||||
# default action: build all
|
||||
all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
|
||||
EXAMPLES = \
|
||||
audio_duplex \
|
||||
a2dp_sink_demo \
|
||||
a2dp_source_demo \
|
||||
ancs_client_demo \
|
||||
dut_mode_classic \
|
||||
gap_dedicated_bonding \
|
||||
gap_inquiry \
|
||||
gap_le_advertisements \
|
||||
gatt_battery_query \
|
||||
gatt_browser \
|
||||
gatt_counter \
|
||||
gatt_streamer_server \
|
||||
hfp_ag_demo \
|
||||
hfp_hf_demo \
|
||||
hid_host_demo \
|
||||
hid_keyboard_demo \
|
||||
hid_mouse_demo \
|
||||
hog_keyboard_demo \
|
||||
hog_mouse_demo \
|
||||
hsp_ag_demo \
|
||||
hsp_hs_demo \
|
||||
mod_player \
|
||||
le_streamer_client \
|
||||
pan_lwip_http_server \
|
||||
pbap_client_demo \
|
||||
sdp_bnep_query \
|
||||
sdp_general_query \
|
||||
sdp_rfcomm_query \
|
||||
sine_player \
|
||||
sm_pairing_central \
|
||||
sm_pairing_peripheral \
|
||||
spp_and_gatt_counter \
|
||||
spp_and_gatt_streamer \
|
||||
spp_counter \
|
||||
spp_streamer \
|
||||
spp_streamer_client \
|
||||
|
||||
GATT_FILES = \
|
||||
ancs_client_demo.gatt \
|
||||
gatt_counter.gatt \
|
||||
gatt_streamer_server.gatt \
|
||||
gatt_browser.gatt \
|
||||
gatt_battery_query.gatt \
|
||||
hog_keyboard_demo.gatt \
|
||||
hog_mouse_demo.gatt \
|
||||
sm_pairing_peripheral.gatt \
|
||||
sm_pairing_central.gatt \
|
||||
spp_and_gatt_counter.gatt \
|
||||
spp_and_gatt_streamer.gatt \
|
||||
|
||||
# SBC codec
|
||||
include ${BTSTACK_ROOT}/3rd-party/bluedroid/decoder/Makefile.inc
|
||||
include ${BTSTACK_ROOT}/3rd-party/bluedroid/encoder/Makefile.inc
|
||||
VPATH += ${BTSTACK_ROOT}/3rd-party/bluedroid/decoder/srce
|
||||
VPATH += ${BTSTACK_ROOT}/3rd-party/bluedroid/encoder/srce
|
||||
C_SOURCES += ${SBC_ENCODER}
|
||||
C_SOURCES += ${SBC_DECODER}
|
||||
|
||||
|
||||
#######################################
|
||||
@ -179,15 +367,26 @@ vpath %.c $(sort $(dir $(C_SOURCES)))
|
||||
# list of ASM program objects
|
||||
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
|
||||
vpath %.s $(sort $(dir $(ASM_SOURCES)))
|
||||
all: \
|
||||
$(OBJECTS) \
|
||||
$(addprefix $(BUILD_DIR)/,$(GATT_FILES:.gatt=.h)) \
|
||||
$(addprefix $(BUILD_DIR)/,$(EXAMPLES:=.elf)) \
|
||||
$(addprefix $(BUILD_DIR)/,$(EXAMPLES:=.hex)) \
|
||||
$(addprefix $(BUILD_DIR)/,$(EXAMPLES:=.bin)) \
|
||||
$(addprefix $(BUILD_DIR)/,$(EXAMPLES:=.jdebug)) \
|
||||
|
||||
|
||||
$(BUILD_DIR)/%.h: %.gatt
|
||||
python3 ${BTSTACK_ROOT}/tool/compile_gatt.py $< $@
|
||||
|
||||
|
||||
$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
|
||||
$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
|
||||
|
||||
$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
|
||||
$(AS) -c $(CFLAGS) $< -o $@
|
||||
|
||||
$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
|
||||
$(CC) $(OBJECTS) $(LDFLAGS) -o $@
|
||||
$(BUILD_DIR)/%.elf: Makefile $(OBJECTS) $(BUILD_DIR)/%.o
|
||||
$(CC) $(filter-out Makefile,$^) $(LDFLAGS) -o $@
|
||||
$(SZ) $@
|
||||
|
||||
$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
|
||||
@ -196,6 +395,9 @@ $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
|
||||
$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
|
||||
$(BIN) $< $@
|
||||
|
||||
$(BUILD_DIR)/%.jdebug: ozone.jdebug | $(BUILD_DIR)
|
||||
sed -e "s|EXAMPLE|$(basename $(notdir $@))|" $< > $@
|
||||
|
||||
$(BUILD_DIR):
|
||||
mkdir $@
|
||||
|
||||
|
337
port/stm32-f4discovery-usb/ozone.jdebug
Normal file
337
port/stm32-f4discovery-usb/ozone.jdebug
Normal file
@ -0,0 +1,337 @@
|
||||
/*********************************************************************
|
||||
* (c) SEGGER Microcontroller GmbH *
|
||||
* The Embedded Experts *
|
||||
* www.segger.com *
|
||||
**********************************************************************
|
||||
|
||||
File : /Users/mringwal/Projects/btstack/port/stm32-f4discovery-usb/stm32-f4discovery-usb.jdebug
|
||||
Created : 22 Dec 2020 17:47
|
||||
Ozone Version : V3.20e
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* OnProjectLoad
|
||||
*
|
||||
* Function description
|
||||
* Project load routine. Required.
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
void OnProjectLoad (void) {
|
||||
//
|
||||
// Dialog-generated settings
|
||||
//
|
||||
Project.SetDevice ("STM32F407VG");
|
||||
Project.SetHostIF ("USB", "");
|
||||
Project.SetTargetIF ("SWD");
|
||||
Project.SetTIFSpeed ("50 MHz");
|
||||
Project.AddPathSubstitute ("/Users/mringwal/Projects/btstack/port/stm32-f4discovery-usb", "$(ProjectDir)");
|
||||
Project.AddPathSubstitute ("/users/mringwal/projects/btstack/port/stm32-f4discovery-usb", "$(ProjectDir)");
|
||||
Project.AddSvdFile ("$(InstallDir)/Config/CPU/Cortex-M4F.svd");
|
||||
//
|
||||
// User settings
|
||||
//
|
||||
File.Open ("$(ProjectDir)/EXAMPLE.elf");
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* OnStartupComplete
|
||||
*
|
||||
* Function description
|
||||
* Called when program execution has reached/passed
|
||||
* the startup completion point. Optional.
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
//void OnStartupComplete (void) {
|
||||
//}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* TargetReset
|
||||
*
|
||||
* Function description
|
||||
* Replaces the default target device reset routine. Optional.
|
||||
*
|
||||
* Notes
|
||||
* This example demonstrates the usage when
|
||||
* debugging a RAM program on a Cortex-M target device
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
//void TargetReset (void) {
|
||||
//
|
||||
// unsigned int SP;
|
||||
// unsigned int PC;
|
||||
// unsigned int VectorTableAddr;
|
||||
//
|
||||
// VectorTableAddr = Program.GetBaseAddr();
|
||||
//
|
||||
// if (VectorTableAddr != 0xFFFFFFFF) {
|
||||
// SP = Target.ReadU32(VectorTableAddr);
|
||||
// Target.SetReg("SP", SP);
|
||||
// } else {
|
||||
// Util.Log("Project file error: failed to get program base");
|
||||
// }
|
||||
//
|
||||
// PC = Elf.GetEntryPointPC();
|
||||
//
|
||||
// if (PC != 0xFFFFFFFF) {
|
||||
// Target.SetReg("PC", PC);
|
||||
// } else if (VectorTableAddr != 0xFFFFFFFF) {
|
||||
// PC = Target.ReadU32(VectorTableAddr + 4);
|
||||
// Target.SetReg("PC", PC);
|
||||
//}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* BeforeTargetReset
|
||||
*
|
||||
* Function description
|
||||
* Event handler routine. Optional.
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
//void BeforeTargetReset (void) {
|
||||
//}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* AfterTargetReset
|
||||
*
|
||||
* Function description
|
||||
* Event handler routine. Optional.
|
||||
* - Sets the PC register to program reset value.
|
||||
* - Sets the SP register to program reset value on Cortex-M.
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
void AfterTargetReset (void) {
|
||||
unsigned int SP;
|
||||
unsigned int PC;
|
||||
unsigned int VectorTableAddr;
|
||||
|
||||
VectorTableAddr = Elf.GetBaseAddr();
|
||||
|
||||
if (VectorTableAddr != 0xFFFFFFFF) {
|
||||
SP = Target.ReadU32(VectorTableAddr);
|
||||
Target.SetReg("SP", SP);
|
||||
} else {
|
||||
Util.Log("Project file error: failed to get program base");
|
||||
}
|
||||
|
||||
PC = Elf.GetEntryPointPC();
|
||||
|
||||
if (PC != 0xFFFFFFFF) {
|
||||
Target.SetReg("PC", PC);
|
||||
} else if (VectorTableAddr != 0xFFFFFFFF) {
|
||||
PC = Target.ReadU32(VectorTableAddr + 4);
|
||||
Target.SetReg("PC", PC);
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* DebugStart
|
||||
*
|
||||
* Function description
|
||||
* Replaces the default debug session startup routine. Optional.
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
//void DebugStart (void) {
|
||||
//}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* TargetConnect
|
||||
*
|
||||
* Function description
|
||||
* Replaces the default target IF connection routine. Optional.
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
//void TargetConnect (void) {
|
||||
//}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* BeforeTargetConnect
|
||||
*
|
||||
* Function description
|
||||
* Event handler routine. Optional.
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
//void BeforeTargetConnect (void) {
|
||||
//}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* AfterTargetConnect
|
||||
*
|
||||
* Function description
|
||||
* Event handler routine. Optional.
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
//void AfterTargetConnect (void) {
|
||||
//}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* TargetDownload
|
||||
*
|
||||
* Function description
|
||||
* Replaces the default program download routine. Optional.
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
//void TargetDownload (void) {
|
||||
//}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* BeforeTargetDownload
|
||||
*
|
||||
* Function description
|
||||
* Event handler routine. Optional.
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
//void BeforeTargetDownload (void) {
|
||||
//}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* AfterTargetDownload
|
||||
*
|
||||
* Function description
|
||||
* Event handler routine. Optional.
|
||||
* - Sets the PC register to program reset value.
|
||||
* - Sets the SP register to program reset value on Cortex-M.
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
void AfterTargetDownload (void) {
|
||||
unsigned int SP;
|
||||
unsigned int PC;
|
||||
unsigned int VectorTableAddr;
|
||||
|
||||
VectorTableAddr = Elf.GetBaseAddr();
|
||||
|
||||
if (VectorTableAddr != 0xFFFFFFFF) {
|
||||
SP = Target.ReadU32(VectorTableAddr);
|
||||
Target.SetReg("SP", SP);
|
||||
} else {
|
||||
Util.Log("Project file error: failed to get program base");
|
||||
}
|
||||
|
||||
PC = Elf.GetEntryPointPC();
|
||||
|
||||
if (PC != 0xFFFFFFFF) {
|
||||
Target.SetReg("PC", PC);
|
||||
} else if (VectorTableAddr != 0xFFFFFFFF) {
|
||||
PC = Target.ReadU32(VectorTableAddr + 4);
|
||||
Target.SetReg("PC", PC);
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* BeforeTargetDisconnect
|
||||
*
|
||||
* Function description
|
||||
* Event handler routine. Optional.
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
//void BeforeTargetDisconnect (void) {
|
||||
//}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* AfterTargetDisconnect
|
||||
*
|
||||
* Function description
|
||||
* Event handler routine. Optional.
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
//void AfterTargetDisconnect (void) {
|
||||
//}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* AfterTargetHalt
|
||||
*
|
||||
* Function description
|
||||
* Event handler routine. Optional.
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
//void AfterTargetHalt (void) {
|
||||
//}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* BeforeTargetResume
|
||||
*
|
||||
* Function description
|
||||
* Event handler routine. Optional.
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
//void BeforeTargetResume (void) {
|
||||
//}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* OnSnapshotLoad
|
||||
*
|
||||
* Function description
|
||||
* Called upon loading a snapshot. Optional.
|
||||
*
|
||||
* Additional information
|
||||
* This function is used to restore the target state in cases
|
||||
* where values cannot simply be written to the target.
|
||||
* Typical use: GPIO clock needs to be enabled, before
|
||||
* GPIO is configured.
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
//void OnSnapshotLoad (void) {
|
||||
//}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* OnSnapshotSave
|
||||
*
|
||||
* Function description
|
||||
* Called upon saving a snapshot. Optional.
|
||||
*
|
||||
* Additional information
|
||||
* This function is usually used to save values of the target
|
||||
* state which can either not be trivially read,
|
||||
* or need to be restored in a specific way or order.
|
||||
* Typically use: Memory Mapped Registers,
|
||||
* such as PLL and GPIO configuration.
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
//void OnSnapshotSave (void) {
|
||||
//}
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* OnError
|
||||
*
|
||||
* Function description
|
||||
* Called when an error ocurred. Optional.
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
//void OnError (const char* sErrorMsg) {
|
||||
//}
|
@ -12,12 +12,14 @@
|
||||
|
||||
// BTstack features that can be enabled
|
||||
#define ENABLE_BLE
|
||||
#define ENABLE_BTSTACK_ASSERT
|
||||
#define ENABLE_CC256X_BAUDRATE_CHANGE_FLOWCONTROL_BUG_WORKAROUND
|
||||
#define ENABLE_CLASSIC
|
||||
#define ENABLE_HFP_WIDE_BAND_SPEECH
|
||||
#define ENABLE_LE_CENTRAL
|
||||
#define ENABLE_LE_DATA_CHANNELS
|
||||
#define ENABLE_LE_PERIPHERAL
|
||||
#define ENABLE_LOG_INFO
|
||||
#define ENABLE_LOG_ERROR
|
||||
#define ENABLE_PRINTF_HEXDUMP
|
||||
#define ENABLE_SCO_OVER_HCI
|
||||
|
110
port/stm32-f4discovery-usb/port/hal_flash_bank_stm32.c
Normal file
110
port/stm32-f4discovery-usb/port/hal_flash_bank_stm32.c
Normal file
@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY MATTHIAS RINGWALD 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* hal_flash_bank_stm32.c
|
||||
*
|
||||
* HAL abstraction for Flash memory that can be written anywhere
|
||||
* after being erased
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h> // memcpy
|
||||
|
||||
#include "hal_flash_bank_stm32.h"
|
||||
#include "stm32f4xx_hal.h"
|
||||
|
||||
static uint32_t hal_flash_bank_stm32_get_size(void * context){
|
||||
hal_flash_bank_stm32_t * self = (hal_flash_bank_stm32_t *) context;
|
||||
return self->sector_size;
|
||||
}
|
||||
|
||||
static uint32_t hal_flash_bank_memory_get_alignment(void * context){
|
||||
UNUSED(context);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void hal_flash_bank_stm32_erase(void * context, int bank){
|
||||
hal_flash_bank_stm32_t * self = (hal_flash_bank_stm32_t *) context;
|
||||
if (bank > 1) return;
|
||||
FLASH_EraseInitTypeDef eraseInit;
|
||||
eraseInit.TypeErase = FLASH_TYPEERASE_SECTORS;
|
||||
eraseInit.Sector = self->sectors[bank];
|
||||
eraseInit.NbSectors = 1;
|
||||
eraseInit.VoltageRange = FLASH_VOLTAGE_RANGE_1; // safe value
|
||||
uint32_t sectorError;
|
||||
HAL_FLASH_Unlock();
|
||||
HAL_FLASHEx_Erase(&eraseInit, §orError);
|
||||
HAL_FLASH_Lock();
|
||||
}
|
||||
|
||||
static void hal_flash_bank_stm32_read(void * context, int bank, uint32_t offset, uint8_t * buffer, uint32_t size){
|
||||
hal_flash_bank_stm32_t * self = (hal_flash_bank_stm32_t *) context;
|
||||
|
||||
if (bank > 1) return;
|
||||
if (offset > self->sector_size) return;
|
||||
if ((offset + size) > self->sector_size) return;
|
||||
|
||||
memcpy(buffer, ((uint8_t *) self->banks[bank]) + offset, size);
|
||||
}
|
||||
|
||||
static void hal_flash_bank_stm32_write(void * context, int bank, uint32_t offset, const uint8_t * data, uint32_t size){
|
||||
hal_flash_bank_stm32_t * self = (hal_flash_bank_stm32_t *) context;
|
||||
|
||||
if (bank > 1) return;
|
||||
if (offset > self->sector_size) return;
|
||||
if ((offset + size) > self->sector_size) return;
|
||||
|
||||
unsigned int i;
|
||||
HAL_FLASH_Unlock();
|
||||
for (i=0;i<size;i++){
|
||||
HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, self->banks[bank] + offset +i, data[i]);
|
||||
}
|
||||
HAL_FLASH_Lock();
|
||||
}
|
||||
|
||||
static const hal_flash_bank_t hal_flash_bank_stm32_impl = {
|
||||
/* uint32_t (*get_size)() */ &hal_flash_bank_stm32_get_size,
|
||||
/* uint32_t (*get_alignment)(..); */ &hal_flash_bank_memory_get_alignment,
|
||||
/* void (*erase)(..); */ &hal_flash_bank_stm32_erase,
|
||||
/* void (*read)(..); */ &hal_flash_bank_stm32_read,
|
||||
/* void (*write)(..); */ &hal_flash_bank_stm32_write,
|
||||
};
|
||||
|
||||
const hal_flash_bank_t * hal_flash_bank_stm32_init_instance(hal_flash_bank_stm32_t * context, uint32_t sector_size,
|
||||
uint32_t bank_0_sector, uint32_t bank_1_sector, uintptr_t bank_0_addr, uintptr_t bank_1_addr){
|
||||
context->sector_size = sector_size;
|
||||
context->sectors[0] = bank_0_sector;
|
||||
context->sectors[1] = bank_1_sector;
|
||||
context->banks[0] = bank_0_addr;
|
||||
context->banks[1] = bank_1_addr;
|
||||
return &hal_flash_bank_stm32_impl;
|
||||
}
|
72
port/stm32-f4discovery-usb/port/hal_flash_bank_stm32.h
Normal file
72
port/stm32-f4discovery-usb/port/hal_flash_bank_stm32.h
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY MATTHIAS RINGWALD 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* hal_flash_bank_stm32.h
|
||||
*
|
||||
* HAL abstraction for Flash memory that can be written anywhere
|
||||
* after being erased
|
||||
*/
|
||||
|
||||
#ifndef __HAL_FLASH_BANK_STM32_H
|
||||
#define __HAL_FLASH_BANK_STM32_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "hal_flash_bank.h"
|
||||
|
||||
#if defined __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
uint32_t sector_size;
|
||||
uint32_t sectors[2];
|
||||
uintptr_t banks[2];
|
||||
} hal_flash_bank_stm32_t;
|
||||
|
||||
/**
|
||||
* Configure STM32 HAL Flash Implementation
|
||||
*
|
||||
* @param context of hal_flash_bank_stm32_t
|
||||
* @param bank_size
|
||||
* @param bank_0_sector id
|
||||
* @param bank_1_sector id
|
||||
* @param bank_0_addr
|
||||
* @param bank_1_addr
|
||||
* @return
|
||||
*/
|
||||
const hal_flash_bank_t * hal_flash_bank_stm32_init_instance(hal_flash_bank_stm32_t * context, uint32_t bank_size,
|
||||
uint32_t bank_0_sector, uint32_t bank_1_sector, uintptr_t bank_0_addr, uintptr_t bank_1_addr);
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
101
port/stm32-f4discovery-usb/port/hci_transport_h2_stm32.c
Normal file
101
port/stm32-f4discovery-usb/port/hci_transport_h2_stm32.c
Normal file
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* 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 BTSTACK_FILE__ "hci_transport_h2_stm32.c"
|
||||
|
||||
/*
|
||||
* hci_transport_h2_stm32.c
|
||||
*
|
||||
* HCI Transport API implementation for STM32Cube USB Host Stack
|
||||
*/
|
||||
|
||||
#include "hci_transport_h2_stm32.h"
|
||||
#include <stddef.h>
|
||||
#include "btstack_debug.h"
|
||||
|
||||
static void (*packet_handler)(uint8_t packet_type, uint8_t *packet, uint16_t size) = NULL;
|
||||
|
||||
|
||||
static void hci_transport_h2_stm32_init(const void * transport_config){
|
||||
UNUSED(transport_config);
|
||||
log_info("hci_transport_h2_stm32_init");
|
||||
}
|
||||
|
||||
static int hci_transport_h2_stm32_open(void){
|
||||
log_info("hci_transport_h2_stm32_open");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int hci_transport_h2_stm32_close(void){
|
||||
log_info("hci_transport_h2_stm32_close");
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void hci_transport_h2_stm32_register_packet_handler(void (*handler)(uint8_t packet_type, uint8_t *packet, uint16_t size)){
|
||||
packet_handler = handler;
|
||||
}
|
||||
|
||||
static int hci_transport_h2_stm32_can_send_now(uint8_t packet_type){
|
||||
log_info("hci_transport_h2_stm32_can_send_now");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int hci_transport_h2_stm32_send_packet(uint8_t packet_type, uint8_t * packet, int size){
|
||||
log_info("hci_transport_h2_stm32_send_packet");
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void hci_transport_h2_stm32_set_sco_config(uint16_t voice_setting, int num_connections){
|
||||
log_info("hci_transport_h2_stm32_send_packet, voice 0x%02x, num connections %u", voice_setting, num_connections);
|
||||
}
|
||||
|
||||
const hci_transport_t * hci_transport_h2_stm32_instance(void) {
|
||||
|
||||
static const hci_transport_t instance = {
|
||||
/* const char * name; */ "H4",
|
||||
/* void (*init) (const void *transport_config); */ &hci_transport_h2_stm32_init,
|
||||
/* int (*open)(void); */ &hci_transport_h2_stm32_open,
|
||||
/* int (*close)(void); */ &hci_transport_h2_stm32_close,
|
||||
/* void (*register_packet_handler)(void (*handler)(...); */ &hci_transport_h2_stm32_register_packet_handler,
|
||||
/* int (*can_send_packet_now)(uint8_t packet_type); */ &hci_transport_h2_stm32_can_send_now,
|
||||
/* int (*send_packet)(...); */ &hci_transport_h2_stm32_send_packet,
|
||||
/* int (*set_baudrate)(uint32_t baudrate); */ NULL,
|
||||
/* void (*reset_link)(void); */ NULL,
|
||||
/* void (*set_sco_config)(uint16_t voice_setting, int num_connections); */ &hci_transport_h2_stm32_set_sco_config,
|
||||
};
|
||||
return &instance;
|
||||
}
|
62
port/stm32-f4discovery-usb/port/hci_transport_h2_stm32.h
Normal file
62
port/stm32-f4discovery-usb/port/hci_transport_h2_stm32.h
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* hci_transport_h2_stm32.h
|
||||
*/
|
||||
#ifndef HCI_TRANSPORT_STM32_H
|
||||
#define HCI_TRANSPORT_STM32_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "btstack_defines.h"
|
||||
#include "hci_transport.h"
|
||||
|
||||
#if defined __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* @brief Setup H2 instance for STM32 Cube Host Stack
|
||||
* @param uart_driver to use
|
||||
*/
|
||||
const hci_transport_t * hci_transport_h2_stm32_instance(void);
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // HCI_TRANSPORT_STM32_H
|
175
port/stm32-f4discovery-usb/port/port.c
Normal file
175
port/stm32-f4discovery-usb/port/port.c
Normal file
@ -0,0 +1,175 @@
|
||||
/*
|
||||
* 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 __BTSTACK_FILE__ "port.c"
|
||||
|
||||
// include STM32 first to avoid warning about redefinition of UNUSED
|
||||
#include "stm32f4xx_hal.h"
|
||||
#include "main.h"
|
||||
|
||||
#include "port.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "port.h"
|
||||
#include "btstack.h"
|
||||
#include "btstack_debug.h"
|
||||
#include "btstack_audio.h"
|
||||
#include "btstack_run_loop_embedded.h"
|
||||
#include "btstack_tlv.h"
|
||||
#include "btstack_tlv_flash_bank.h"
|
||||
#include "ble/le_device_db_tlv.h"
|
||||
#include "classic/btstack_link_key_db_tlv.h"
|
||||
#include "hal_flash_bank_stm32.h"
|
||||
#include "hci_transport_h2_stm32.h"
|
||||
|
||||
#ifdef ENABLE_SEGGER_RTT
|
||||
#include "SEGGER_RTT.h"
|
||||
#endif
|
||||
|
||||
static btstack_packet_callback_registration_t hci_event_callback_registration;
|
||||
static btstack_tlv_flash_bank_t btstack_tlv_flash_bank_context;
|
||||
static hal_flash_bank_stm32_t hal_flash_bank_context;
|
||||
|
||||
// hal_time_ms.h
|
||||
#include "hal_time_ms.h"
|
||||
uint32_t hal_time_ms(void){
|
||||
return HAL_GetTick();
|
||||
}
|
||||
|
||||
// hal_cpu.h implementation
|
||||
#include "hal_cpu.h"
|
||||
|
||||
void hal_cpu_disable_irqs(void){
|
||||
__disable_irq();
|
||||
}
|
||||
|
||||
void hal_cpu_enable_irqs(void){
|
||||
__enable_irq();
|
||||
}
|
||||
|
||||
void hal_cpu_enable_irqs_and_sleep(void){
|
||||
__enable_irq();
|
||||
__asm__("wfe"); // go to sleep if event flag isn't set. if set, just clear it. IRQs set event flag
|
||||
}
|
||||
|
||||
#define HAL_FLASH_BANK_SIZE (128 * 1024)
|
||||
#define HAL_FLASH_BANK_0_ADDR 0x080C0000
|
||||
#define HAL_FLASH_BANK_1_ADDR 0x080E0000
|
||||
#define HAL_FLASH_BANK_0_SECTOR FLASH_SECTOR_10
|
||||
#define HAL_FLASH_BANK_1_SECTOR FLASH_SECTOR_11
|
||||
|
||||
int btstack_main(int argc, char ** argv);
|
||||
|
||||
// main.c
|
||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
UNUSED(size);
|
||||
UNUSED(channel);
|
||||
bd_addr_t local_addr;
|
||||
if (packet_type != HCI_EVENT_PACKET) return;
|
||||
switch(hci_event_packet_get_type(packet)){
|
||||
case BTSTACK_EVENT_STATE:
|
||||
if (btstack_event_state_get_state(packet) != HCI_STATE_WORKING) return;
|
||||
gap_local_bd_addr(local_addr);
|
||||
printf("BTstack up and running on %s.\n", bd_addr_to_str(local_addr));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void btstack_assert_failed(const char * file, uint16_t line_nr){
|
||||
printf("ASSERT in %s, line %u failed - HALT\n", file, line_nr);
|
||||
while(1);
|
||||
}
|
||||
|
||||
void port_main(void){
|
||||
|
||||
printf("BTstack on STM32 F4 Discovery with USB support starting...\n");
|
||||
|
||||
// start with BTstack init - especially configure HCI Transport
|
||||
btstack_memory_init();
|
||||
btstack_run_loop_init(btstack_run_loop_embedded_get_instance());
|
||||
|
||||
// uncomment for packet log
|
||||
hci_dump_open( NULL, HCI_DUMP_STDOUT );
|
||||
|
||||
// init HCI
|
||||
hci_init(hci_transport_h2_stm32_instance(), NULL);
|
||||
|
||||
// setup TLV Flash Sector implementation
|
||||
const hal_flash_bank_t * hal_flash_bank_impl = hal_flash_bank_stm32_init_instance(
|
||||
&hal_flash_bank_context,
|
||||
HAL_FLASH_BANK_SIZE,
|
||||
HAL_FLASH_BANK_0_SECTOR,
|
||||
HAL_FLASH_BANK_1_SECTOR,
|
||||
HAL_FLASH_BANK_0_ADDR,
|
||||
HAL_FLASH_BANK_1_ADDR);
|
||||
const btstack_tlv_t * btstack_tlv_impl = btstack_tlv_flash_bank_init_instance(
|
||||
&btstack_tlv_flash_bank_context,
|
||||
hal_flash_bank_impl,
|
||||
&hal_flash_bank_context);
|
||||
|
||||
// setup global tlv
|
||||
btstack_tlv_set_instance(btstack_tlv_impl, &btstack_tlv_flash_bank_context);
|
||||
|
||||
// setup Link Key DB using TLV
|
||||
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);
|
||||
hci_set_link_key_db(btstack_link_key_db);
|
||||
|
||||
// setup LE Device DB using TLV
|
||||
le_device_db_tlv_configure(btstack_tlv_impl, &btstack_tlv_flash_bank_context);
|
||||
|
||||
#if 0
|
||||
#ifdef HAVE_HAL_AUDIO
|
||||
// setup audio
|
||||
btstack_audio_sink_set_instance(btstack_audio_embedded_sink_get_instance());
|
||||
btstack_audio_source_set_instance(btstack_audio_embedded_source_get_instance());
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// inform about BTstack state
|
||||
hci_event_callback_registration.callback = &packet_handler;
|
||||
hci_add_event_handler(&hci_event_callback_registration);
|
||||
|
||||
// hand over to btstack embedded code
|
||||
btstack_main(0, NULL);
|
||||
|
||||
// go
|
||||
btstack_run_loop_execute();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user