mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-26 02:37:41 +00:00
esp32: provide esp-idf/component/btstack/btstack_port_esp32.c and only minimal app_main in template/main/main.c
This commit is contained in:
parent
fa1ee4d3e8
commit
bd8e4ef6a3
@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Broadcom/Cypress: wait 300 ms after PatchRAM update in hci.c to assert Controller is ready
|
- Broadcom/Cypress: wait 300 ms after PatchRAM update in hci.c to assert Controller is ready
|
||||||
|
- esp32: provide esp-idf/component/btstack/btstack_port_esp32.c and only minimal app_main in template/main/main.c
|
||||||
|
|
||||||
## Changes March 2020
|
## Changes March 2020
|
||||||
|
|
||||||
|
@ -58,6 +58,7 @@
|
|||||||
#include "esp_bt.h"
|
#include "esp_bt.h"
|
||||||
#include "btstack_debug.h"
|
#include "btstack_debug.h"
|
||||||
#include "btstack_audio.h"
|
#include "btstack_audio.h"
|
||||||
|
#include "btstack_port_esp32.h"
|
||||||
|
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
@ -359,17 +360,8 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int btstack_main(int argc, const char * argv[]);
|
uint8_t btstack_init(void){
|
||||||
|
// Setup memory pools and run loop
|
||||||
// main
|
|
||||||
int app_main(void){
|
|
||||||
|
|
||||||
printf("BTstack: setup\n");
|
|
||||||
|
|
||||||
// enable packet logger
|
|
||||||
// hci_dump_open(NULL, HCI_DUMP_STDOUT);
|
|
||||||
|
|
||||||
/// GET STARTED with BTstack ///
|
|
||||||
btstack_memory_init();
|
btstack_memory_init();
|
||||||
btstack_run_loop_init(btstack_run_loop_freertos_get_instance());
|
btstack_run_loop_init(btstack_run_loop_freertos_get_instance());
|
||||||
|
|
||||||
@ -394,10 +386,6 @@ int app_main(void){
|
|||||||
// setup i2s audio sink
|
// setup i2s audio sink
|
||||||
btstack_audio_sink_set_instance(btstack_audio_esp32_sink_get_instance());
|
btstack_audio_sink_set_instance(btstack_audio_esp32_sink_get_instance());
|
||||||
|
|
||||||
btstack_main(0, NULL);
|
return ERROR_CODE_SUCCESS;
|
||||||
|
|
||||||
printf("BTstack: execute run loop\n");
|
|
||||||
btstack_run_loop_execute();
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
52
port/esp32/components/btstack/include/btstack_port_esp32.h
Normal file
52
port/esp32/components/btstack/include/btstack_port_esp32.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* btstack_port_esp32.h
|
||||||
|
*
|
||||||
|
* Integration of ESP32 Bluetooth Controller into BTstack
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __BTSTACK_PORT_ESP32_H
|
||||||
|
#define __BTSTACK_PORT_ESP32_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure BTstack for use with ESP32 VHCI Bluetooth Controller
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @returns status ERROR_CODE_SUCCESS if ok
|
||||||
|
*/
|
||||||
|
|
||||||
|
uint8_t btstack_init(void);
|
||||||
|
|
||||||
|
#endif //__BTSTACK_PORT_ESP32_H
|
@ -117,6 +117,9 @@ def create_examples(script_path, suffix):
|
|||||||
if not os.path.exists(main_folder):
|
if not os.path.exists(main_folder):
|
||||||
os.makedirs(main_folder)
|
os.makedirs(main_folder)
|
||||||
|
|
||||||
|
# copy main file
|
||||||
|
shutil.copyfile(script_path + '/template/main/main.c', apps_folder + "/main/main.c")
|
||||||
|
|
||||||
# copy example file
|
# copy example file
|
||||||
shutil.copyfile(examples_embedded + file, apps_folder + "/main/" + example + ".c")
|
shutil.copyfile(examples_embedded + file, apps_folder + "/main/" + example + ".c")
|
||||||
|
|
||||||
|
64
port/esp32/template/main/main.c
Normal file
64
port/esp32/template/main/main.c
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* main.c
|
||||||
|
*
|
||||||
|
* Minimal main application that initializes BTstack, prepares the example and enters BTstack's Run Loop.
|
||||||
|
*
|
||||||
|
* If needed, you can create other threads. Please note that BTstack's API is not thread-safe and can only be
|
||||||
|
* called from BTstack timers or in response to its callbacks, e.g. packet handlers.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "btstack_port_esp32.h"
|
||||||
|
#include "btstack_run_loop.h"
|
||||||
|
#include "hci_dump.h"
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
extern int btstack_main(int argc, const char * argv[]);
|
||||||
|
|
||||||
|
int app_main(void){
|
||||||
|
|
||||||
|
// optional: enable packet logger
|
||||||
|
// hci_dump_open(NULL, HCI_DUMP_STDOUT);
|
||||||
|
|
||||||
|
// Configure BTstack for ESP32 VHCI Controller
|
||||||
|
btstack_init();
|
||||||
|
|
||||||
|
// Setup example
|
||||||
|
btstack_main(0, NULL);
|
||||||
|
|
||||||
|
// Enter run loop (forever)
|
||||||
|
btstack_run_loop_execute();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user