Update IDF to 9a26296
This commit is contained in:
parent
0bce98e72c
commit
ba929be27a
@ -21,7 +21,7 @@ compiler.warning_flags.all=-Wall -Werror=all -Wextra
|
||||
|
||||
compiler.path={runtime.tools.xtensa-esp32-elf-gcc.path}/bin/
|
||||
compiler.sdk.path={runtime.platform.path}/tools/sdk
|
||||
compiler.cpreprocessor.flags=-DESP_PLATFORM -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h" -DHAVE_CONFIG_H "-I{compiler.sdk.path}/include/config" "-I{compiler.sdk.path}/include/bluedroid" "-I{compiler.sdk.path}/include/app_trace" "-I{compiler.sdk.path}/include/app_update" "-I{compiler.sdk.path}/include/bootloader_support" "-I{compiler.sdk.path}/include/bt" "-I{compiler.sdk.path}/include/driver" "-I{compiler.sdk.path}/include/esp32" "-I{compiler.sdk.path}/include/ethernet" "-I{compiler.sdk.path}/include/fatfs" "-I{compiler.sdk.path}/include/freertos" "-I{compiler.sdk.path}/include/heap" "-I{compiler.sdk.path}/include/jsmn" "-I{compiler.sdk.path}/include/log" "-I{compiler.sdk.path}/include/mdns" "-I{compiler.sdk.path}/include/mbedtls" "-I{compiler.sdk.path}/include/mbedtls_port" "-I{compiler.sdk.path}/include/newlib" "-I{compiler.sdk.path}/include/nvs_flash" "-I{compiler.sdk.path}/include/openssl" "-I{compiler.sdk.path}/include/soc" "-I{compiler.sdk.path}/include/spi_flash" "-I{compiler.sdk.path}/include/sdmmc" "-I{compiler.sdk.path}/include/tcpip_adapter" "-I{compiler.sdk.path}/include/ulp" "-I{compiler.sdk.path}/include/vfs" "-I{compiler.sdk.path}/include/wear_levelling" "-I{compiler.sdk.path}/include/xtensa-debug-module" "-I{compiler.sdk.path}/include/newlib" "-I{compiler.sdk.path}/include/coap" "-I{compiler.sdk.path}/include/wpa_supplicant" "-I{compiler.sdk.path}/include/expat" "-I{compiler.sdk.path}/include/json" "-I{compiler.sdk.path}/include/nghttp" "-I{compiler.sdk.path}/include/lwip"
|
||||
compiler.cpreprocessor.flags=-DESP_PLATFORM -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h" -DHAVE_CONFIG_H "-I{compiler.sdk.path}/include/config" "-I{compiler.sdk.path}/include/bluedroid" "-I{compiler.sdk.path}/include/app_trace" "-I{compiler.sdk.path}/include/app_update" "-I{compiler.sdk.path}/include/bootloader_support" "-I{compiler.sdk.path}/include/bt" "-I{compiler.sdk.path}/include/driver" "-I{compiler.sdk.path}/include/esp32" "-I{compiler.sdk.path}/include/esp_adc_cal" "-I{compiler.sdk.path}/include/ethernet" "-I{compiler.sdk.path}/include/fatfs" "-I{compiler.sdk.path}/include/freertos" "-I{compiler.sdk.path}/include/heap" "-I{compiler.sdk.path}/include/jsmn" "-I{compiler.sdk.path}/include/log" "-I{compiler.sdk.path}/include/mdns" "-I{compiler.sdk.path}/include/mbedtls" "-I{compiler.sdk.path}/include/mbedtls_port" "-I{compiler.sdk.path}/include/newlib" "-I{compiler.sdk.path}/include/nvs_flash" "-I{compiler.sdk.path}/include/openssl" "-I{compiler.sdk.path}/include/soc" "-I{compiler.sdk.path}/include/spi_flash" "-I{compiler.sdk.path}/include/sdmmc" "-I{compiler.sdk.path}/include/spiffs" "-I{compiler.sdk.path}/include/tcpip_adapter" "-I{compiler.sdk.path}/include/ulp" "-I{compiler.sdk.path}/include/vfs" "-I{compiler.sdk.path}/include/wear_levelling" "-I{compiler.sdk.path}/include/xtensa-debug-module" "-I{compiler.sdk.path}/include/console" "-I{compiler.sdk.path}/include/newlib" "-I{compiler.sdk.path}/include/coap" "-I{compiler.sdk.path}/include/wpa_supplicant" "-I{compiler.sdk.path}/include/expat" "-I{compiler.sdk.path}/include/json" "-I{compiler.sdk.path}/include/nghttp" "-I{compiler.sdk.path}/include/lwip"
|
||||
|
||||
compiler.c.cmd=xtensa-esp32-elf-gcc
|
||||
compiler.c.flags=-std=gnu99 -Os -g3 -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls -nostdlib -Wpointer-arith {compiler.warning_flags} -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -Wno-old-style-declaration -MMD -c
|
||||
@ -33,8 +33,8 @@ compiler.S.cmd=xtensa-esp32-elf-gcc
|
||||
compiler.S.flags=-c -g3 -x assembler-with-cpp -MMD -mlongcalls
|
||||
|
||||
compiler.c.elf.cmd=xtensa-esp32-elf-gcc
|
||||
compiler.c.elf.flags=-nostdlib "-L{compiler.sdk.path}/lib" "-L{compiler.sdk.path}/ld" -T esp32_out.ld -T esp32.common.ld -T esp32.rom.ld -T esp32.peripherals.ld -u ld_include_panic_highint_hdl -u call_user_start_cpu0 -Wl,--gc-sections -Wl,-static -Wl,--undefined=uxTopUsedPriority
|
||||
compiler.c.elf.libs=-lgcc -lstdc++ -lapp_trace -lapp_update -lbootloader_support -lbt -lbtdm_app -lc -lc_nano -lcoap -lcoexist -lcore -lcxx -ldriver -lesp32 -lethernet -lexpat -lfatfs -lfreertos -lhal -lheap -ljsmn -ljson -llog -llwip -lm -lmbedtls -lmdns -lmicro-ecc -lnet80211 -lnewlib -lnghttp -lnvs_flash -lopenssl -lphy -lpp -lrtc -lsdmmc -lsmartconfig -lsoc -lspi_flash -ltcpip_adapter -lulp -lvfs -lwear_levelling -lwpa -lwpa2 -lwpa_supplicant -lwps -lxtensa-debug-module
|
||||
compiler.c.elf.flags=-nostdlib "-L{compiler.sdk.path}/lib" "-L{compiler.sdk.path}/ld" -T esp32_out.ld -T esp32.common.ld -T esp32.rom.ld -T esp32.peripherals.ld -T esp32.rom.spiram_incompatible_fns.ld -u ld_include_panic_highint_hdl -u call_user_start_cpu0 -Wl,--gc-sections -Wl,-static -Wl,--undefined=uxTopUsedPriority
|
||||
compiler.c.elf.libs=-lgcc -lstdc++ -lapp_trace -lapp_update -lbootloader_support -lbt -lbtdm_app -lc -lc_nano -lcoap -lcoexist -lconsole -lcore -lcxx -ldriver -lesp32 -lesp_adc_cal -lethernet -lexpat -lfatfs -lfreertos -lhal -lheap -ljsmn -ljson -llog -llwip -lm -lmbedtls -lmdns -lmicro-ecc -lnet80211 -lnewlib -lnghttp -lnvs_flash -lopenssl -lphy -lpp -lpthread -lrtc -lsdmmc -lsmartconfig -lsoc -lspi_flash -lspiffs -ltcpip_adapter -lulp -lvfs -lwear_levelling -lwpa -lwpa2 -lwpa_supplicant -lwps -lxtensa-debug-module
|
||||
|
||||
compiler.as.cmd=xtensa-esp32-elf-as
|
||||
|
||||
|
@ -32,7 +32,7 @@ import shlex
|
||||
import copy
|
||||
import io
|
||||
|
||||
__version__ = "2.1-beta1"
|
||||
__version__ = "2.1"
|
||||
|
||||
MAX_UINT32 = 0xffffffff
|
||||
MAX_UINT24 = 0xffffff
|
||||
@ -1315,7 +1315,7 @@ class ESP32FirmwareImage(BaseFirmwareImage):
|
||||
|
||||
if self.append_digest:
|
||||
end = load_file.tell()
|
||||
self.stored_digest = load_file.read(16)
|
||||
self.stored_digest = load_file.read(32)
|
||||
load_file.seek(start)
|
||||
calc_digest = hashlib.sha256()
|
||||
calc_digest.update(load_file.read(end - start))
|
||||
@ -1864,6 +1864,15 @@ def image_info(args):
|
||||
calc_checksum = image.calculate_checksum()
|
||||
print('Checksum: %02x (%s)' % (image.checksum,
|
||||
'valid' if image.checksum == calc_checksum else 'invalid - calculated %02x' % calc_checksum))
|
||||
try:
|
||||
digest_msg = 'Not appended'
|
||||
if image.append_digest:
|
||||
is_valid = image.stored_digest == image.calc_digest
|
||||
digest_msg = "%s (%s)" % (hexify(image.calc_digest).lower(),
|
||||
"valid" if is_valid else "invalid")
|
||||
print('Validation Hash: %s' % digest_msg)
|
||||
except AttributeError:
|
||||
pass # ESP8266 image has no append_digest field
|
||||
|
||||
|
||||
def make_image(args):
|
||||
|
@ -57,6 +57,7 @@ env.Prepend(
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "bt"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "driver"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp32"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp_adc_cal"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "ethernet"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "fatfs"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "freertos"),
|
||||
@ -72,11 +73,13 @@ env.Prepend(
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "soc"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "spi_flash"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "sdmmc"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "spiffs"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "tcpip_adapter"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "ulp"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "vfs"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "wear_levelling"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "xtensa-debug-module"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "console"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "newlib"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "coap"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "wpa_supplicant"),
|
||||
@ -91,7 +94,7 @@ env.Prepend(
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "ld")
|
||||
],
|
||||
LIBS=[
|
||||
"gcc", "stdc++", "app_trace", "app_update", "bootloader_support", "bt", "btdm_app", "c", "c_nano", "coap", "coexist", "core", "cxx", "driver", "esp32", "ethernet", "expat", "fatfs", "freertos", "hal", "heap", "jsmn", "json", "log", "lwip", "m", "mbedtls", "mdns", "micro-ecc", "net80211", "newlib", "nghttp", "nvs_flash", "openssl", "phy", "pp", "rtc", "sdmmc", "smartconfig", "soc", "spi_flash", "tcpip_adapter", "ulp", "vfs", "wear_levelling", "wpa", "wpa2", "wpa_supplicant", "wps", "xtensa-debug-module"
|
||||
"gcc", "stdc++", "app_trace", "app_update", "bootloader_support", "bt", "btdm_app", "c", "c_nano", "coap", "coexist", "console", "core", "cxx", "driver", "esp32", "esp_adc_cal", "ethernet", "expat", "fatfs", "freertos", "hal", "heap", "jsmn", "json", "log", "lwip", "m", "mbedtls", "mdns", "micro-ecc", "net80211", "newlib", "nghttp", "nvs_flash", "openssl", "phy", "pp", "pthread", "rtc", "sdmmc", "smartconfig", "soc", "spi_flash", "spiffs", "tcpip_adapter", "ulp", "vfs", "wear_levelling", "wpa", "wpa2", "wpa_supplicant", "wps", "xtensa-debug-module"
|
||||
],
|
||||
|
||||
UPLOADERFLAGS=[
|
||||
@ -110,6 +113,7 @@ env.Append(
|
||||
"-T", "esp32.common.ld",
|
||||
"-T", "esp32.rom.ld",
|
||||
"-T", "esp32.peripherals.ld",
|
||||
"-T", "esp32.rom.spiram_incompatible_fns.ld",
|
||||
"-u", "ld_include_panic_highint_hdl"
|
||||
],
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
@ -126,13 +126,17 @@ esp_err_t esp_ota_set_boot_partition(const esp_partition_t* partition);
|
||||
*
|
||||
* If esp_ota_set_boot_partition() has been called, the partition which was set by that function will be returned.
|
||||
*
|
||||
* If esp_ota_set_boot_partition() has not been called, the result is
|
||||
* equivalent to esp_ota_get_running_partition().
|
||||
* If esp_ota_set_boot_partition() has not been called, the result is usually the same as esp_ota_get_running_partition().
|
||||
* The two results are not equal if the configured boot partition does not contain a valid app (meaning that the running partition
|
||||
* will be an app that the bootloader chose via fallback).
|
||||
*
|
||||
* If the OTA data partition is not present or not valid then the result is the first app partition found in the
|
||||
* partition table. In priority order, this means: the factory app, the first OTA app slot, or the test app partition.
|
||||
*
|
||||
* Note that there is no guarantee the returned partition is a valid app. Use esp_image_load(ESP_IMAGE_VERIFY, ...) to verify if the
|
||||
* partition contains a bootable image.
|
||||
* returned partition contains a bootable image.
|
||||
*
|
||||
* @return Pointer to info for partition structure, or NULL if no partition is found or flash read operation failed. Returned pointer is valid for the lifetime of the application.
|
||||
* @return Pointer to info for partition structure, or NULL if partition table is invalid or a flash read operation failed. Any returned pointer is valid for the lifetime of the application.
|
||||
*/
|
||||
const esp_partition_t* esp_ota_get_boot_partition(void);
|
||||
|
||||
|
@ -126,13 +126,17 @@ esp_err_t esp_ota_set_boot_partition(const esp_partition_t* partition);
|
||||
*
|
||||
* If esp_ota_set_boot_partition() has been called, the partition which was set by that function will be returned.
|
||||
*
|
||||
* If esp_ota_set_boot_partition() has not been called, the result is
|
||||
* equivalent to esp_ota_get_running_partition().
|
||||
* If esp_ota_set_boot_partition() has not been called, the result is usually the same as esp_ota_get_running_partition().
|
||||
* The two results are not equal if the configured boot partition does not contain a valid app (meaning that the running partition
|
||||
* will be an app that the bootloader chose via fallback).
|
||||
*
|
||||
* If the OTA data partition is not present or not valid then the result is the first app partition found in the
|
||||
* partition table. In priority order, this means: the factory app, the first OTA app slot, or the test app partition.
|
||||
*
|
||||
* Note that there is no guarantee the returned partition is a valid app. Use esp_image_load(ESP_IMAGE_VERIFY, ...) to verify if the
|
||||
* partition contains a bootable image.
|
||||
* returned partition contains a bootable image.
|
||||
*
|
||||
* @return Pointer to info for partition structure, or NULL if no partition is found or flash read operation failed. Returned pointer is valid for the lifetime of the application.
|
||||
* @return Pointer to info for partition structure, or NULL if partition table is invalid or a flash read operation failed. Any returned pointer is valid for the lifetime of the application.
|
||||
*/
|
||||
const esp_partition_t* esp_ota_get_boot_partition(void);
|
||||
|
||||
|
@ -76,4 +76,6 @@ period_ms_t osi_alarm_get_remaining_ms(const osi_alarm_t *alarm);
|
||||
// t1 and t2 should be no greater than the time of MAX ticks
|
||||
period_ms_t osi_alarm_time_diff(period_ms_t t1, period_ms_t t2);
|
||||
|
||||
uint32_t osi_time_get_os_boottime_ms(void);
|
||||
|
||||
#endif /*_ALARM_H_*/
|
||||
|
@ -20,7 +20,7 @@
|
||||
#define _ALLOCATOR_H_
|
||||
|
||||
#include <stddef.h>
|
||||
//#include <stdlib.h>
|
||||
#include <stdlib.h>
|
||||
#include "sdkconfig.h"
|
||||
|
||||
typedef void *(*alloc_fn)(size_t size);
|
||||
@ -52,7 +52,7 @@ void osi_mem_dbg_show(void);
|
||||
({ \
|
||||
void *p; \
|
||||
\
|
||||
p = calloc(1, (size)); \
|
||||
p = malloc((size)); \
|
||||
osi_mem_dbg_record(p, size, __func__, __LINE__); \
|
||||
(void *)p; \
|
||||
})
|
||||
@ -67,14 +67,15 @@ void osi_mem_dbg_show(void);
|
||||
})
|
||||
|
||||
#define osi_free(ptr) \
|
||||
({ \
|
||||
osi_mem_dbg_clean(ptr, __func__, __LINE__); \
|
||||
free((ptr)); \
|
||||
})
|
||||
do { \
|
||||
void *tmp_point = (void *)(ptr); \
|
||||
osi_mem_dbg_clean(tmp_point, __func__, __LINE__); \
|
||||
free(tmp_point); \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
|
||||
#define osi_malloc(size) calloc(1, (size))
|
||||
#define osi_malloc(size) malloc((size))
|
||||
#define osi_calloc(size) calloc(1, (size))
|
||||
#define osi_free(p) free((p))
|
||||
|
||||
|
@ -24,10 +24,10 @@
|
||||
#ifndef AVCT_INT_H
|
||||
#define AVCT_INT_H
|
||||
|
||||
#include "gki.h"
|
||||
#include "avct_api.h"
|
||||
#include "avct_defs.h"
|
||||
#include "l2c_api.h"
|
||||
#include "fixed_queue.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** constants
|
||||
@ -81,7 +81,7 @@ typedef struct {
|
||||
BT_HDR *p_rx_msg; /* Message being reassembled */
|
||||
UINT16 conflict_lcid; /* L2CAP channel LCID */
|
||||
BD_ADDR peer_addr; /* BD address of peer */
|
||||
BUFFER_Q tx_q; /* Transmit data buffer queue */
|
||||
fixed_queue_t *tx_q; /* Transmit data buffer queue */
|
||||
BOOLEAN cong; /* TRUE, if congested */
|
||||
} tAVCT_LCB;
|
||||
|
||||
|
@ -24,12 +24,12 @@
|
||||
#ifndef AVDT_INT_H
|
||||
#define AVDT_INT_H
|
||||
|
||||
#include "gki.h"
|
||||
#include "avdt_api.h"
|
||||
#include "avdtc_api.h"
|
||||
#include "avdt_defs.h"
|
||||
#include "l2c_api.h"
|
||||
#include "btm_api.h"
|
||||
#include "fixed_queue.h"
|
||||
|
||||
#if (AVRC_INCLUDED == TRUE)
|
||||
|
||||
@ -425,8 +425,8 @@ typedef union {
|
||||
typedef struct {
|
||||
BD_ADDR peer_addr; /* BD address of peer */
|
||||
TIMER_LIST_ENT timer_entry; /* CCB timer list entry */
|
||||
BUFFER_Q cmd_q; /* Queue for outgoing command messages */
|
||||
BUFFER_Q rsp_q; /* Queue for outgoing response and reject messages */
|
||||
fixed_queue_t *cmd_q; /* Queue for outgoing command messages */
|
||||
fixed_queue_t *rsp_q; /* Queue for outgoing response and reject messages */
|
||||
tAVDT_CTRL_CBACK *proc_cback; /* Procedure callback function */
|
||||
tAVDT_CTRL_CBACK *p_conn_cback; /* Connection/disconnection callback function */
|
||||
void *p_proc_data; /* Pointer to data storage for procedure */
|
||||
@ -453,7 +453,7 @@ typedef struct {
|
||||
BT_HDR *p_buf;
|
||||
UINT32 time_stamp;
|
||||
#if AVDT_MULTIPLEXING == TRUE
|
||||
BUFFER_Q frag_q; /* Queue for outgoing media fragments. p_buf should be 0 */
|
||||
fixed_queue_t *frag_q; /* Queue for outgoing media fragments. p_buf should be 0 */
|
||||
UINT8 *p_data;
|
||||
UINT32 data_len;
|
||||
#endif
|
||||
@ -500,7 +500,7 @@ typedef struct {
|
||||
BOOLEAN cong; /* Whether media transport channel is congested */
|
||||
UINT8 close_code; /* Error code received in close response */
|
||||
#if AVDT_MULTIPLEXING == TRUE
|
||||
BUFFER_Q frag_q; /* Queue for outgoing media fragments */
|
||||
fixed_queue_t *frag_q; /* Queue for outgoing media fragments */
|
||||
UINT32 frag_off; /* length of already received media fragments */
|
||||
UINT32 frag_org_len; /* original length before fragmentation of receiving media packet */
|
||||
UINT8 *p_next_frag; /* next fragment to send */
|
||||
@ -673,7 +673,7 @@ extern void avdt_scb_chk_snd_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
|
||||
extern void avdt_scb_clr_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
|
||||
extern void avdt_scb_tc_timer(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
|
||||
extern void avdt_scb_clr_vars(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
|
||||
extern void avdt_scb_queue_frags(tAVDT_SCB *p_scb, UINT8 **pp_data, UINT32 *p_data_len, BUFFER_Q *pq);
|
||||
extern void avdt_scb_queue_frags(tAVDT_SCB *p_scb, UINT8 **pp_data, UINT32 *p_data_len, fixed_queue_t *pq);
|
||||
|
||||
/* msg function declarations */
|
||||
extern BOOLEAN avdt_msg_send(tAVDT_CCB *p_ccb, BT_HDR *p_msg);
|
||||
|
@ -22,8 +22,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "bt_trace.h"
|
||||
|
||||
#include "osi_arch.h"
|
||||
#include "bt_target.h"
|
||||
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
||||
@ -32,6 +31,20 @@
|
||||
#endif
|
||||
/*Timer Related Defination*/
|
||||
|
||||
//by Snake.T
|
||||
typedef void (TIMER_CBACK)(void *p_tle);
|
||||
typedef struct _tle {
|
||||
struct _tle *p_next;
|
||||
struct _tle *p_prev;
|
||||
TIMER_CBACK *p_cback;
|
||||
INT32 ticks;
|
||||
INT32 ticks_initial;
|
||||
TIMER_PARAM_TYPE param;
|
||||
TIMER_PARAM_TYPE data;
|
||||
UINT16 event;
|
||||
UINT8 in_use;
|
||||
} TIMER_LIST_ENT;
|
||||
|
||||
#define alarm_timer_t uint32_t
|
||||
#define alarm_timer_setfn(timer, cb, data) \
|
||||
do { \
|
||||
@ -45,23 +58,6 @@ do { \
|
||||
#define alarm_timer_now() (0)
|
||||
|
||||
|
||||
/*Thread and locker related defination*/
|
||||
#define RTOS_SUPPORT
|
||||
#ifdef RTOS_SUPPORT
|
||||
#define pthread_mutex_t osi_mutex_t
|
||||
#define pthread_mutex_init(mutex, a) osi_mutex_new(mutex)
|
||||
#define pthread_mutex_destroy(mutex) osi_mutex_free(mutex)
|
||||
#define pthread_mutex_lock osi_mutex_lock
|
||||
#define pthread_mutex_unlock osi_mutex_unlock
|
||||
#else
|
||||
#define pthread_mutex_t uint8_t
|
||||
#define pthread_mutex_init(x1, x2)
|
||||
#define pthread_mutex_destroy(mutex)
|
||||
#define pthread_mutex_lock(mutex)
|
||||
#define pthread_mutex_unlock(mutex)
|
||||
#endif
|
||||
|
||||
|
||||
/*Bluetooth Address*/
|
||||
typedef struct {
|
||||
uint8_t address[6];
|
||||
|
@ -37,8 +37,6 @@
|
||||
#include "sdkconfig.h"
|
||||
#include "bt_types.h" /* This must be defined AFTER buildcfg.h */
|
||||
|
||||
/* Include common GKI definitions used by this platform */
|
||||
#include "gki_target.h"
|
||||
#include "dyn_mem.h" /* defines static and/or dynamic memory for components */
|
||||
|
||||
#if CONFIG_CLASSIC_BT_ENABLED
|
||||
@ -177,15 +175,6 @@
|
||||
#define BTA_DISABLE_DELAY 200 /* in milliseconds */
|
||||
#endif
|
||||
|
||||
// If the next wakeup time is less than this threshold, we should acquire
|
||||
// a wakelock instead of setting a wake alarm so we're not bouncing in
|
||||
// and out of suspend frequently.
|
||||
// in millisecond
|
||||
// TODO(zachoverflow): reinstate in alarm code
|
||||
#ifndef GKI_TIMER_INTERVAL_FOR_WAKELOCK
|
||||
#define GKI_TIMER_INTERVAL_FOR_WAKELOCK 3000
|
||||
#endif
|
||||
|
||||
#ifndef BTA_SYS_TIMER_PERIOD
|
||||
#define BTA_SYS_TIMER_PERIOD 100
|
||||
#endif
|
||||
@ -266,66 +255,63 @@
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** GKI Buffer Pools
|
||||
** Buffer Size
|
||||
**
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef BT_DEFAULT_BUFFER_SIZE
|
||||
#define BT_DEFAULT_BUFFER_SIZE (4096 + 16)
|
||||
#endif
|
||||
|
||||
#ifndef BT_SMALL_BUFFER_SIZE
|
||||
#define BT_SMALL_BUFFER_SIZE 660
|
||||
#endif
|
||||
|
||||
/* Receives HCI events from the lower-layer. */
|
||||
#ifndef HCI_CMD_POOL_ID
|
||||
#define HCI_CMD_POOL_ID GKI_POOL_ID_2
|
||||
#endif
|
||||
|
||||
#ifndef HCI_CMD_POOL_BUF_SIZE
|
||||
#define HCI_CMD_POOL_BUF_SIZE GKI_BUF2_SIZE
|
||||
#endif
|
||||
|
||||
/* Receives ACL data packets from thelower-layer. */
|
||||
#ifndef HCI_ACL_POOL_ID
|
||||
#define HCI_ACL_POOL_ID GKI_POOL_ID_3
|
||||
#endif
|
||||
|
||||
/* Maximum number of buffers available for ACL receive data. */
|
||||
#ifndef HCI_ACL_BUF_MAX
|
||||
#define HCI_ACL_BUF_MAX GKI_BUF3_MAX
|
||||
#endif
|
||||
|
||||
/* Receives SCO data packets from the lower-layer. */
|
||||
#ifndef HCI_SCO_POOL_ID
|
||||
#define HCI_SCO_POOL_ID GKI_POOL_ID_6
|
||||
#ifndef HCI_CMD_BUF_SIZE
|
||||
#define HCI_CMD_BUF_SIZE BT_SMALL_BUFFER_SIZE
|
||||
#endif
|
||||
|
||||
/* Sends SDP data packets. */
|
||||
#ifndef SDP_POOL_ID
|
||||
#define SDP_POOL_ID 3
|
||||
#ifndef SDP_DATA_BUF_SIZE
|
||||
#define SDP_DATA_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
|
||||
#endif
|
||||
|
||||
/* Sends RFCOMM command packets. */
|
||||
#ifndef RFCOMM_CMD_POOL_ID
|
||||
#define RFCOMM_CMD_POOL_ID GKI_POOL_ID_2
|
||||
#ifndef RFCOMM_CMD_BUF_SIZE
|
||||
#define RFCOMM_CMD_BUF_SIZE BT_SMALL_BUFFER_SIZE
|
||||
#endif
|
||||
|
||||
/* Sends RFCOMM data packets. */
|
||||
#ifndef RFCOMM_DATA_POOL_ID
|
||||
#define RFCOMM_DATA_POOL_ID GKI_POOL_ID_3
|
||||
#endif
|
||||
|
||||
#ifndef RFCOMM_DATA_POOL_BUF_SIZE
|
||||
#define RFCOMM_DATA_POOL_BUF_SIZE GKI_BUF3_SIZE
|
||||
#ifndef RFCOMM_DATA_BUF_SIZE
|
||||
#define RFCOMM_DATA_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
|
||||
#endif
|
||||
|
||||
/* Sends L2CAP packets to the peer and HCI messages to the controller. */
|
||||
#ifndef L2CAP_CMD_POOL_ID
|
||||
#define L2CAP_CMD_POOL_ID GKI_POOL_ID_2
|
||||
#ifndef L2CAP_CMD_BUF_SIZE
|
||||
#define L2CAP_CMD_BUF_SIZE BT_SMALL_BUFFER_SIZE
|
||||
#endif
|
||||
|
||||
#ifndef L2CAP_USER_TX_BUF_SIZE
|
||||
#define L2CAP_USER_TX_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
|
||||
#endif
|
||||
|
||||
#ifndef L2CAP_USER_RX_BUF_SIZE
|
||||
#define L2CAP_USER_RX_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
|
||||
#endif
|
||||
|
||||
/* Sends L2CAP segmented packets in ERTM mode */
|
||||
#ifndef L2CAP_FCR_TX_POOL_ID
|
||||
#define L2CAP_FCR_TX_POOL_ID HCI_ACL_POOL_ID
|
||||
#ifndef L2CAP_FCR_TX_BUF_SIZE
|
||||
#define L2CAP_FCR_TX_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
|
||||
#endif
|
||||
|
||||
/* Receives L2CAP segmented packets in ERTM mode */
|
||||
#ifndef L2CAP_FCR_RX_POOL_ID
|
||||
#define L2CAP_FCR_RX_POOL_ID HCI_ACL_POOL_ID
|
||||
#ifndef L2CAP_FCR_RX_BUF_SIZE
|
||||
#define L2CAP_FCR_RX_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
|
||||
#endif
|
||||
|
||||
#ifndef L2CAP_FCR_ERTM_BUF_SIZE
|
||||
#define L2CAP_FCR_ERTM_BUF_SIZE (10240 + 24)
|
||||
#endif
|
||||
|
||||
/* Number of ACL buffers to assign to LE
|
||||
@ -335,114 +321,72 @@
|
||||
#endif
|
||||
|
||||
/* Used by BTM when it sends HCI commands to the controller. */
|
||||
#ifndef BTM_CMD_POOL_ID
|
||||
#define BTM_CMD_POOL_ID GKI_POOL_ID_2
|
||||
#ifndef BTM_CMD_BUF_SIZE
|
||||
#define BTM_CMD_BUF_SIZE BT_SMALL_BUFFER_SIZE
|
||||
#endif
|
||||
|
||||
#ifndef OBX_LRG_DATA_POOL_SIZE
|
||||
#define OBX_LRG_DATA_POOL_SIZE GKI_BUF4_SIZE
|
||||
#ifndef OBX_LRG_DATA_BUF_SIZE
|
||||
#define OBX_LRG_DATA_BUF_SIZE (8080 + 26)
|
||||
#endif
|
||||
|
||||
#ifndef OBX_LRG_DATA_POOL_ID
|
||||
#define OBX_LRG_DATA_POOL_ID GKI_POOL_ID_4
|
||||
#endif
|
||||
/* Used to send data to L2CAP. */
|
||||
#ifndef GAP_DATA_POOL_ID
|
||||
#define GAP_DATA_POOL_ID GKI_POOL_ID_3
|
||||
#endif
|
||||
|
||||
#ifndef SPP_DB_SIZE
|
||||
#define SPP_DB_SIZE GKI_BUF3_SIZE
|
||||
#ifndef GAP_DATA_BUF_SIZE
|
||||
#define GAP_DATA_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
|
||||
#endif
|
||||
|
||||
/* BNEP data and protocol messages. */
|
||||
#ifndef BNEP_POOL_ID
|
||||
#define BNEP_POOL_ID GKI_POOL_ID_3
|
||||
#ifndef BNEP_BUF_SIZE
|
||||
#define BNEP_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
|
||||
#endif
|
||||
|
||||
/* RPC pool for temporary trace message buffers. */
|
||||
#ifndef RPC_SCRATCH_POOL_ID
|
||||
#define RPC_SCRATCH_POOL_ID GKI_POOL_ID_2
|
||||
/* AVDTP buffer size for protocol messages */
|
||||
#ifndef AVDT_CMD_BUF_SIZE
|
||||
#define AVDT_CMD_BUF_SIZE BT_SMALL_BUFFER_SIZE
|
||||
#endif
|
||||
|
||||
/* AVDTP pool for protocol messages */
|
||||
#ifndef AVDT_CMD_POOL_ID
|
||||
#define AVDT_CMD_POOL_ID GKI_POOL_ID_2
|
||||
/* AVDTP buffer size for media packets in case of fragmentation */
|
||||
#ifndef AVDT_DATA_BUF_SIZE
|
||||
#define AVDT_DATA_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
|
||||
#endif
|
||||
|
||||
/* AVDTP pool size for media packets in case of fragmentation */
|
||||
#ifndef AVDT_DATA_POOL_SIZE
|
||||
#define AVDT_DATA_POOL_SIZE GKI_BUF3_SIZE
|
||||
#ifndef PAN_BUF_SIZE
|
||||
#define PAN_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
|
||||
#endif
|
||||
|
||||
#ifndef PAN_POOL_ID
|
||||
#define PAN_POOL_ID GKI_POOL_ID_3
|
||||
/* Maximum amount of the shared buffer to allocate for PAN */
|
||||
#define PAN_POOL_MAX (GKI_BUF3_MAX / 4)
|
||||
/* Maximum number of buffers to allocate for PAN */
|
||||
#ifndef PAN_BUF_MAX
|
||||
#define PAN_BUF_MAX 100
|
||||
#endif
|
||||
|
||||
/* AVCTP pool for protocol messages */
|
||||
#ifndef AVCT_CMD_POOL_ID
|
||||
#define AVCT_CMD_POOL_ID GKI_POOL_ID_1
|
||||
/* AVCTP buffer size for protocol messages */
|
||||
#ifndef AVCT_CMD_BUF_SIZE
|
||||
#define AVCT_CMD_BUF_SIZE 288
|
||||
#endif
|
||||
|
||||
/* AVRCP pool for protocol messages */
|
||||
#ifndef AVRC_CMD_POOL_ID
|
||||
#define AVRC_CMD_POOL_ID GKI_POOL_ID_1
|
||||
/* AVRCP buffer size for protocol messages */
|
||||
#ifndef AVRC_CMD_BUF_SIZE
|
||||
#define AVRC_CMD_BUF_SIZE 288
|
||||
#endif
|
||||
|
||||
/* AVRCP pool size for protocol messages */
|
||||
#ifndef AVRC_CMD_POOL_SIZE
|
||||
#define AVRC_CMD_POOL_SIZE GKI_BUF1_SIZE
|
||||
/* AVRCP Metadata buffer size for protocol messages */
|
||||
#ifndef AVRC_META_CMD_BUF_SIZE
|
||||
#define AVRC_META_CMD_BUF_SIZE BT_SMALL_BUFFER_SIZE
|
||||
#endif
|
||||
|
||||
/* AVRCP Metadata pool for protocol messages */
|
||||
#ifndef AVRC_META_CMD_POOL_ID
|
||||
#define AVRC_META_CMD_POOL_ID GKI_POOL_ID_2
|
||||
#ifndef BTA_HL_LRG_DATA_BUF_SIZE
|
||||
#define BTA_HL_LRG_DATA_BUF_SIZE (10240 + 24)
|
||||
#endif
|
||||
|
||||
/* AVRCP Metadata pool size for protocol messages */
|
||||
#ifndef AVRC_META_CMD_POOL_SIZE
|
||||
#define AVRC_META_CMD_POOL_SIZE GKI_BUF2_SIZE
|
||||
/* GATT Server Database buffer size */
|
||||
#ifndef GATT_DB_BUF_SIZE
|
||||
#define GATT_DB_BUF_SIZE 128
|
||||
#endif
|
||||
|
||||
|
||||
/* AVRCP buffer size for browsing channel messages */
|
||||
#ifndef AVRC_BROWSE_POOL_SIZE
|
||||
#define AVRC_BROWSE_POOL_SIZE GKI_MAX_BUF_SIZE
|
||||
/* GATT Data sending buffer size */
|
||||
#ifndef GATT_DATA_BUF_SIZE
|
||||
#define GATT_DATA_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
|
||||
#endif
|
||||
|
||||
#ifndef BTA_HL_LRG_DATA_POOL_ID
|
||||
#define BTA_HL_LRG_DATA_POOL_ID GKI_POOL_ID_7
|
||||
#endif
|
||||
|
||||
/* GATT Server Database pool ID */
|
||||
#ifndef GATT_DB_POOL_ID
|
||||
#define GATT_DB_POOL_ID GKI_POOL_ID_8
|
||||
#endif
|
||||
|
||||
/* GATT Data sending buffer pool ID, use default ACL pool for fix channel data */
|
||||
#ifndef GATT_BUF_POOL_ID
|
||||
#define GATT_BUF_POOL_ID HCI_ACL_POOL_ID
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Lower Layer Interface
|
||||
**
|
||||
******************************************************************************/
|
||||
|
||||
/* Macro for allocating buffer for HCI commands */
|
||||
#ifndef HCI_GET_CMD_BUF
|
||||
#if (!defined(HCI_USE_VARIABLE_SIZE_CMD_BUF) || (HCI_USE_VARIABLE_SIZE_CMD_BUF == FALSE))
|
||||
/* Allocate fixed-size buffer from HCI_CMD_POOL (default case) */
|
||||
#define HCI_GET_CMD_BUF(paramlen) ((BT_HDR *)GKI_getpoolbuf (HCI_CMD_POOL_ID))
|
||||
#else
|
||||
/* Allocate smallest possible buffer (for platforms with limited RAM) */
|
||||
#define HCI_GET_CMD_BUF(paramlen) ((BT_HDR *)GKI_getbuf ((UINT16)(BT_HDR_SIZE + HCIC_PREAMBLE_SIZE + (paramlen))))
|
||||
#endif
|
||||
#endif /* HCI_GET_CMD_BUF */
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** HCI Services (H4)
|
||||
@ -1267,68 +1211,41 @@
|
||||
#define PORT_CREDIT_RX_LOW 8
|
||||
#endif
|
||||
|
||||
/* if application like BTA, Java or script test engine is running on other than BTU thread, */
|
||||
/* PORT_SCHEDULE_LOCK shall be defined as GKI_sched_lock() or GKI_disable() */
|
||||
#ifndef PORT_SCHEDULE_LOCK
|
||||
#define PORT_SCHEDULE_LOCK GKI_disable()
|
||||
#endif
|
||||
|
||||
/* if application like BTA, Java or script test engine is running on other than BTU thread, */
|
||||
/* PORT_SCHEDULE_LOCK shall be defined as GKI_sched_unlock() or GKI_enable() */
|
||||
#ifndef PORT_SCHEDULE_UNLOCK
|
||||
#define PORT_SCHEDULE_UNLOCK GKI_enable()
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** OBEX
|
||||
**
|
||||
******************************************************************************/
|
||||
#define OBX_14_INCLUDED FALSE
|
||||
|
||||
/* The maximum number of registered servers. */
|
||||
#ifndef OBX_NUM_SERVERS
|
||||
#define OBX_NUM_SERVERS 12
|
||||
/*
|
||||
* Buffer size to reassemble the SDU.
|
||||
* It will allow buffers to be used that are larger than the L2CAP_MAX_MTU.
|
||||
*/
|
||||
#ifndef OBX_USER_RX_BUF_SIZE
|
||||
#define OBX_USER_RX_BUF_SIZE OBX_LRG_DATA_BUF_SIZE
|
||||
#endif
|
||||
|
||||
/* The maximum number of active clients. */
|
||||
#ifndef OBX_NUM_CLIENTS
|
||||
#define OBX_NUM_CLIENTS 8
|
||||
/*
|
||||
* Buffer size to hold the SDU.
|
||||
* It will allow buffers to be used that are larger than the L2CAP_MAX_MTU.
|
||||
*/
|
||||
#ifndef OBX_USER_TX_BUF_SIZE
|
||||
#define OBX_USER_TX_BUF_SIZE OBX_LRG_DATA_BUF_SIZE
|
||||
#endif
|
||||
|
||||
/* This option is application when OBX_14_INCLUDED=TRUE
|
||||
Pool ID where to reassemble the SDU.
|
||||
This Pool will allow buffers to be used that are larger than
|
||||
the L2CAP_MAX_MTU. */
|
||||
#ifndef OBX_USER_RX_POOL_ID
|
||||
#define OBX_USER_RX_POOL_ID OBX_LRG_DATA_POOL_ID
|
||||
/* Buffer size used to hold MPS segments during SDU reassembly. */
|
||||
#ifndef OBX_FCR_RX_BUF_SIZE
|
||||
#define OBX_FCR_RX_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
|
||||
#endif
|
||||
|
||||
/* This option is application when OBX_14_INCLUDED=TRUE
|
||||
Pool ID where to hold the SDU.
|
||||
This Pool will allow buffers to be used that are larger than
|
||||
the L2CAP_MAX_MTU. */
|
||||
#ifndef OBX_USER_TX_POOL_ID
|
||||
#define OBX_USER_TX_POOL_ID OBX_LRG_DATA_POOL_ID
|
||||
#endif
|
||||
|
||||
/* This option is application when OBX_14_INCLUDED=TRUE
|
||||
GKI Buffer Pool ID used to hold MPS segments during SDU reassembly
|
||||
*/
|
||||
#ifndef OBX_FCR_RX_POOL_ID
|
||||
#define OBX_FCR_RX_POOL_ID HCI_ACL_POOL_ID
|
||||
#endif
|
||||
|
||||
/* This option is application when OBX_14_INCLUDED=TRUE
|
||||
GKI Buffer Pool ID used to hold MPS segments used in (re)transmissions.
|
||||
L2CAP_DEFAULT_ERM_POOL_ID is specified to use the HCI ACL data pool.
|
||||
Note: This pool needs to have enough buffers to hold two times the window size negotiated
|
||||
in the L2CA_SetFCROptions (2 * tx_win_size) to allow for retransmissions.
|
||||
The size of each buffer must be able to hold the maximum MPS segment size passed in
|
||||
L2CA_SetFCROptions plus BT_HDR (8) + HCI preamble (4) + L2CAP_MIN_OFFSET (11 - as of BT 2.1 + EDR Spec).
|
||||
*/
|
||||
#ifndef OBX_FCR_TX_POOL_ID
|
||||
#define OBX_FCR_TX_POOL_ID HCI_ACL_POOL_ID
|
||||
/*
|
||||
* Buffer size used to hold MPS segments used in (re)transmissions.
|
||||
* The size of each buffer must be able to hold the maximum MPS segment size
|
||||
* passed in L2CA_SetFCROptions plus BT_HDR (8) + HCI preamble (4) +
|
||||
* L2CAP_MIN_OFFSET (11 - as of BT 2.1 + EDR Spec).
|
||||
*/
|
||||
#ifndef OBX_FCR_TX_BUF_SIZE
|
||||
#define OBX_FCR_TX_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
|
||||
#endif
|
||||
|
||||
/* This option is application when OBX_14_INCLUDED=TRUE
|
||||
@ -1623,16 +1540,12 @@ Range: 2 octets
|
||||
**
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef HID_DEV_SUBCLASS
|
||||
#define HID_DEV_SUBCLASS COD_MINOR_POINTING
|
||||
#ifndef HID_CONTROL_BUF_SIZE
|
||||
#define HID_CONTROL_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
|
||||
#endif
|
||||
|
||||
#ifndef HID_CONTROL_POOL_ID
|
||||
#define HID_CONTROL_POOL_ID 2
|
||||
#endif
|
||||
|
||||
#ifndef HID_INTERRUPT_POOL_ID
|
||||
#define HID_INTERRUPT_POOL_ID 2
|
||||
#ifndef HID_INTERRUPT_BUF_SIZE
|
||||
#define HID_INTERRUPT_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
|
||||
#endif
|
||||
|
||||
/*************************************************************************
|
||||
@ -1767,33 +1680,31 @@ Range: 2 octets
|
||||
#define MCA_NUM_MDLS 4
|
||||
#endif
|
||||
|
||||
/* Pool ID where to reassemble the SDU. */
|
||||
#ifndef MCA_USER_RX_POOL_ID
|
||||
#define MCA_USER_RX_POOL_ID HCI_ACL_POOL_ID
|
||||
/* Buffer size to reassemble the SDU. */
|
||||
#ifndef MCA_USER_RX_BUF_SIZE
|
||||
#define MCA_USER_RX_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
|
||||
#endif
|
||||
|
||||
/* Pool ID where to hold the SDU. */
|
||||
#ifndef MCA_USER_TX_POOL_ID
|
||||
#define MCA_USER_TX_POOL_ID HCI_ACL_POOL_ID
|
||||
/* Buffer size to hold the SDU. */
|
||||
#ifndef MCA_USER_TX_BUF_SIZE
|
||||
#define MCA_USER_TX_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
|
||||
#endif
|
||||
|
||||
/*
|
||||
GKI Buffer Pool ID used to hold MPS segments during SDU reassembly
|
||||
*/
|
||||
#ifndef MCA_FCR_RX_POOL_ID
|
||||
#define MCA_FCR_RX_POOL_ID HCI_ACL_POOL_ID
|
||||
* Buffer size used to hold MPS segments during SDU reassembly
|
||||
*/
|
||||
#ifndef MCA_FCR_RX_BUF_SIZE
|
||||
#define MCA_FCR_RX_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
|
||||
#endif
|
||||
|
||||
/*
|
||||
GKI Buffer Pool ID used to hold MPS segments used in (re)transmissions.
|
||||
L2CAP_DEFAULT_ERM_POOL_ID is specified to use the HCI ACL data pool.
|
||||
Note: This pool needs to have enough buffers to hold two times the window size negotiated
|
||||
in the tL2CAP_FCR_OPTIONS (2 * tx_win_size) to allow for retransmissions.
|
||||
The size of each buffer must be able to hold the maximum MPS segment size passed in
|
||||
tL2CAP_FCR_OPTIONS plus BT_HDR (8) + HCI preamble (4) + L2CAP_MIN_OFFSET (11 - as of BT 2.1 + EDR Spec).
|
||||
*/
|
||||
#ifndef MCA_FCR_TX_POOL_ID
|
||||
#define MCA_FCR_TX_POOL_ID HCI_ACL_POOL_ID
|
||||
* Default buffer size used to hold MPS segments used in (re)transmissions.
|
||||
* The size of each buffer must be able to hold the maximum MPS segment size
|
||||
* passed in tL2CAP_FCR_OPTIONS plus BT_HDR (8) + HCI preamble (4) +
|
||||
* L2CAP_MIN_OFFSET (11 - as of BT 2.1 + EDR Spec).
|
||||
*/
|
||||
#ifndef MCA_FCR_TX_BUF_SIZE
|
||||
#define MCA_FCR_TX_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
|
||||
#endif
|
||||
|
||||
/* MCAP control channel FCR Option:
|
||||
|
@ -404,6 +404,8 @@ typedef void (tBTA_START_ADV_CMPL_CBACK) (tBTA_STATUS status);
|
||||
|
||||
typedef tBTM_SET_PKT_DATA_LENGTH_CBACK tBTA_SET_PKT_DATA_LENGTH_CBACK;
|
||||
|
||||
typedef tBTM_SET_LOCAL_PRIVACY_CBACK tBTA_SET_LOCAL_PRIVACY_CBACK;
|
||||
|
||||
/* advertising channel map */
|
||||
#define BTA_BLE_ADV_CHNL_37 BTM_BLE_ADV_CHNL_37
|
||||
#define BTA_BLE_ADV_CHNL_38 BTM_BLE_ADV_CHNL_38
|
||||
@ -2035,11 +2037,11 @@ extern void BTA_DmSetRandAddress(BD_ADDR rand_addr);
|
||||
** Description Enable/disable privacy on the local device
|
||||
**
|
||||
** Parameters: privacy_enable - enable/disabe privacy on remote device.
|
||||
**
|
||||
** set_local_privacy_cback -callback to be called with result
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmBleConfigLocalPrivacy(BOOLEAN privacy_enable);
|
||||
extern void BTA_DmBleConfigLocalPrivacy(BOOLEAN privacy_enable, tBTA_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -2208,7 +2210,7 @@ extern void BTA_BleDisableAdvInstance(UINT8 inst_id);
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmBleUpdateConnectionParams(BD_ADDR bd_addr, UINT16 min_int,
|
||||
UINT16 max_int, UINT16 latency, UINT16 timeout, tBTA_UPDATE_CONN_PARAM_CBACK *update_conn_param_cb);
|
||||
UINT16 max_int, UINT16 latency, UINT16 timeout);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -304,7 +304,7 @@ extern void bta_av_co_video_stop(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type);
|
||||
** the audio codec
|
||||
**
|
||||
** Returns NULL if data is not ready.
|
||||
** Otherwise, a GKI buffer (BT_HDR*) containing the audio data.
|
||||
** Otherwise, a buffer (BT_HDR*) containing the audio data.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void *bta_av_co_audio_src_data_path(tBTA_AV_CODEC codec_type,
|
||||
|
@ -1157,12 +1157,12 @@ extern void BTA_GATTC_Broadcast(tBTA_GATTC_IF client_if, BOOLEAN start);
|
||||
** only once per connection.
|
||||
**
|
||||
** Parameters conn_id: connection ID.
|
||||
** mtu: desired MTU size to use.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_GATTC_ConfigureMTU (UINT16 conn_id, UINT16 mtu);
|
||||
extern void BTA_GATTC_ConfigureMTU (UINT16 conn_id);
|
||||
|
||||
/*******************************************************************************
|
||||
** BTA GATT Server API
|
||||
@ -1409,10 +1409,10 @@ extern void BTA_SetAttributeValue(UINT16 attr_handle, UINT16 length, UINT8 *valu
|
||||
** length - the value length which has been set to the attribute.
|
||||
** value - the pointer to the value
|
||||
**
|
||||
** Returns None
|
||||
** Returns tBTA_GATT_STATUS
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_GetAttributeValue(UINT16 attr_handle, UINT16 *length, UINT8 **value);
|
||||
extern tBTA_GATT_STATUS BTA_GetAttributeValue(UINT16 attr_handle, UINT16 *length, UINT8 **value);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
36
tools/sdk/include/bluedroid/bta_gatt_common.h
Normal file
36
tools/sdk/include/bluedroid/bta_gatt_common.h
Normal file
@ -0,0 +1,36 @@
|
||||
/******************************************************************************
|
||||
* Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This file contains the action functions for gatts and gattc.
|
||||
*
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "bt_types.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern void BTA_GATT_SetLocalMTU(uint16_t mtu);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -29,7 +29,7 @@
|
||||
#include "bta_gatt_api.h"
|
||||
#include "bta_gattc_ci.h"
|
||||
#include "bta_gattc_co.h"
|
||||
#include "gki.h"
|
||||
#include "fixed_queue.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants and data types
|
||||
@ -184,7 +184,6 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT16 mtu;
|
||||
} tBTA_GATTC_API_CFG_MTU;
|
||||
|
||||
typedef struct {
|
||||
@ -302,7 +301,7 @@ typedef struct {
|
||||
|
||||
tBTA_GATTC_CACHE *p_srvc_cache;
|
||||
tBTA_GATTC_CACHE *p_cur_srvc;
|
||||
BUFFER_Q cache_buffer; /* buffer queue used for storing the cache data */
|
||||
fixed_queue_t *cache_buffer; /* buffer queue used for storing the cache data */
|
||||
UINT8 *p_free; /* starting point to next available byte */
|
||||
UINT16 free_byte; /* number of available bytes in server cache buffer */
|
||||
UINT8 update_count; /* indication received */
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include "bta_gatt_api.h"
|
||||
#include "gatt_api.h"
|
||||
|
||||
#include "gki.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants and data types
|
||||
@ -230,7 +229,7 @@ extern void bta_gatts_add_include_srvc(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS
|
||||
extern void bta_gatts_add_char(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_add_char_descr(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_set_attr_value(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_get_attr_value(UINT16 attr_handle, UINT16 *length, UINT8 **value);
|
||||
extern tGATT_STATUS bta_gatts_get_attr_value(UINT16 attr_handle, UINT16 *length, UINT8 **value);
|
||||
extern void bta_gatts_delete_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_start_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_stop_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg);
|
||||
|
@ -25,7 +25,7 @@
|
||||
#define BTA_SYS_H
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "gki.h"
|
||||
#include "bt_defs.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants and data types
|
||||
|
@ -11,9 +11,11 @@
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __BTC_BLE_STORAGE_H__
|
||||
#define __BTC_BLE_STORAGE_H__
|
||||
#include "bt_types.h"
|
||||
#include "bt_target.h"
|
||||
#include "esp_gap_ble_api.h"
|
||||
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
#define BTC_LE_LOCAL_KEY_IR (1<<0)
|
||||
@ -77,9 +79,12 @@ typedef struct
|
||||
|
||||
extern btc_dm_pairing_cb_t pairing_cb;
|
||||
extern btc_dm_local_key_cb_t ble_local_key_cb;
|
||||
extern btc_bonded_devices_t bonded_devices;
|
||||
|
||||
bt_status_t btc_storage_load_bonded_ble_devices(void);
|
||||
|
||||
bt_status_t btc_get_bonded_ble_devices_list(esp_ble_bond_dev_t *bond_dev);
|
||||
|
||||
bt_status_t btc_in_fetch_bonded_ble_devices(int add);
|
||||
|
||||
void btc_dm_remove_ble_bonding_keys(void);
|
||||
@ -102,14 +107,16 @@ bt_status_t btc_storage_get_ble_bonding_key(bt_bdaddr_t *remote_bd_addr,
|
||||
char *key_value,
|
||||
int key_length);
|
||||
|
||||
bool btc_storage_compare_address_key_value(uint8_t key_type, void *key_value, int key_length);
|
||||
|
||||
bool btc_storage_compare_address_key_value(bt_bdaddr_t *remote_bd_addr,
|
||||
uint8_t key_type, void *key_value, int key_length);
|
||||
bt_status_t btc_storage_add_ble_local_key(char *key,
|
||||
uint8_t key_type,
|
||||
uint8_t key_length);
|
||||
|
||||
bt_status_t btc_storage_remove_ble_bonding_keys(bt_bdaddr_t *remote_bd_addr);
|
||||
|
||||
bt_status_t btc_storage_clear_bond_devices(void);
|
||||
|
||||
bt_status_t btc_storage_remove_ble_local_keys(void);
|
||||
|
||||
bt_status_t btc_storage_get_ble_local_key(uint8_t key_type,
|
||||
@ -119,6 +126,8 @@ bt_status_t btc_storage_get_ble_local_key(uint8_t key_type,
|
||||
bt_status_t btc_storage_get_remote_addr_type(bt_bdaddr_t *remote_bd_addr,
|
||||
int *addr_type);
|
||||
|
||||
int btc_storage_get_num_ble_bond_devices(void);
|
||||
|
||||
bt_status_t btc_storage_set_remote_addr_type(bt_bdaddr_t *remote_bd_addr,
|
||||
uint8_t addr_type);
|
||||
|
||||
@ -126,4 +135,5 @@ void btc_dm_load_ble_local_keys(void);
|
||||
|
||||
void btc_dm_get_ble_local_keys(tBTA_DM_BLE_LOCAL_KEY_MASK *p_key_mask, BT_OCTET16 er,
|
||||
tBTA_BLE_LOCAL_ID_KEYS *p_id_keys);
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
#endif ///__BTC_BLE_STORAGE_H__
|
@ -20,6 +20,8 @@
|
||||
|
||||
#include "bt_types.h"
|
||||
|
||||
#define BTC_LE_DEV_TYPE "DevType"
|
||||
|
||||
typedef struct btc_config_section_iter_t btc_config_section_iter_t;
|
||||
|
||||
bool btc_config_init(void);
|
||||
@ -35,6 +37,7 @@ bool btc_config_set_str(const char *section, const char *key, const char *value)
|
||||
bool btc_config_get_bin(const char *section, const char *key, uint8_t *value, size_t *length);
|
||||
bool btc_config_set_bin(const char *section, const char *key, const uint8_t *value, size_t length);
|
||||
bool btc_config_remove(const char *section, const char *key);
|
||||
bool btc_config_remove_section(const char *section);
|
||||
|
||||
size_t btc_config_get_bin_length(const char *section, const char *key);
|
||||
|
||||
@ -49,7 +52,7 @@ int btc_config_clear(void);
|
||||
|
||||
// TODO(zachoverflow): Eww...we need to move these out. These are peer specific, not config general.
|
||||
bool btc_get_address_type(const BD_ADDR bd_addr, int *p_addr_type);
|
||||
bool btc_compare_address_key_value(char *key_type, void *key_value, int key_length);
|
||||
bool btc_compare_address_key_value(const char *section, char *key_type, void *key_value, int key_length);
|
||||
bool btc_get_device_type(const BD_ADDR bd_addr, int *p_device_type);
|
||||
|
||||
#endif
|
||||
|
@ -40,6 +40,9 @@ typedef enum {
|
||||
BTC_GAP_BLE_PASSKEY_REPLY_EVT,
|
||||
BTC_GAP_BLE_CONFIRM_REPLY_EVT,
|
||||
BTC_GAP_BLE_DISCONNECT_EVT,
|
||||
BTC_GAP_BLE_REMOVE_BOND_DEV_EVT,
|
||||
BTC_GAP_BLE_CLEAR_BOND_DEV_EVT,
|
||||
BTC_GAP_BLE_GET_BOND_DEV_EVT,
|
||||
} btc_gap_ble_act_t;
|
||||
|
||||
/* btc_ble_gap_args_t */
|
||||
@ -89,44 +92,50 @@ typedef union {
|
||||
uint8_t *raw_scan_rsp;
|
||||
uint32_t raw_scan_rsp_len;
|
||||
} cfg_scan_rsp_data_raw;
|
||||
|
||||
//BTC_GAP_BLE_SET_ENCRYPTION_EVT
|
||||
struct set_encryption_args {
|
||||
esp_bd_addr_t bd_addr;
|
||||
esp_ble_sec_act_t sec_act;
|
||||
} set_encryption;
|
||||
|
||||
//BTC_GAP_BLE_SET_SECURITY_PARAM_EVT
|
||||
struct set_security_param_args {
|
||||
esp_ble_sm_param_t param_type;
|
||||
uint8_t len;
|
||||
uint8_t *value;
|
||||
} set_security_param;
|
||||
|
||||
//BTC_GAP_BLE_SECURITY_RSP_EVT
|
||||
struct enc_rsp_args {
|
||||
esp_bd_addr_t bd_addr;
|
||||
bool accept;
|
||||
} sec_rsp;
|
||||
|
||||
//BTC_GAP_BLE_PASSKEY_REPLY_EVT
|
||||
struct enc_passkey_reply_args {
|
||||
esp_bd_addr_t bd_addr;
|
||||
bool accept;
|
||||
uint32_t passkey;
|
||||
} enc_passkey_replay;
|
||||
|
||||
//BTC_GAP_BLE_CONFIRM_REPLY_EVT
|
||||
struct enc_comfirm_reply_args {
|
||||
esp_bd_addr_t bd_addr;
|
||||
bool accept;
|
||||
} enc_comfirm_replay;
|
||||
|
||||
//BTC_GAP_BLE_DISCONNECT_EVT
|
||||
struct disconnect_args {
|
||||
esp_bd_addr_t remote_device;
|
||||
} disconnect;
|
||||
|
||||
//BTC_GAP_BLE_REMOVE_BOND_DEV_EVT
|
||||
struct remove_bond_device_args {
|
||||
esp_bd_addr_t bd_addr;
|
||||
} remove_bond_device;
|
||||
} btc_ble_gap_args_t;
|
||||
|
||||
void btc_gap_ble_call_handler(btc_msg_t *msg);
|
||||
void btc_gap_ble_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
void btc_gap_ble_arg_deep_free(btc_msg_t *msg);
|
||||
void btc_gap_ble_cb_deep_free(btc_msg_t *msg);
|
||||
void btc_gap_ble_cb_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
void btc_gap_callback_init(void);
|
||||
|
||||
#endif /* __BTC_GAP_BLE_H__ */
|
||||
|
@ -68,7 +68,6 @@ typedef union {
|
||||
//BTC_GATTC_ACT_CFG_MTU,
|
||||
struct cfg_mtu_arg {
|
||||
uint16_t conn_id;
|
||||
uint16_t mtu;
|
||||
} cfg_mtu;
|
||||
//BTC_GATTC_ACT_SEARCH_SERVICE,
|
||||
struct search_srvc_arg {
|
||||
|
@ -147,7 +147,7 @@ typedef union {
|
||||
void btc_gatts_call_handler(btc_msg_t *msg);
|
||||
void btc_gatts_cb_handler(btc_msg_t *msg);
|
||||
void btc_gatts_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
void btc_gatts_get_attr_value(uint16_t attr_handle, uint16_t *length, uint8_t **value);
|
||||
esp_gatt_status_t btc_gatts_get_attr_value(uint16_t attr_handle, uint16_t *length, uint8_t **value);
|
||||
|
||||
|
||||
#endif /* __BTC_GATTS_H__ */
|
||||
|
@ -26,6 +26,7 @@ typedef enum {
|
||||
BTC_MAIN_ACT_DEINIT,
|
||||
BTC_MAIN_ACT_ENABLE,
|
||||
BTC_MAIN_ACT_DISABLE,
|
||||
BTC_GATT_ACT_SET_LOCAL_MTU,
|
||||
} btc_main_act_t;
|
||||
|
||||
typedef enum {
|
||||
@ -60,5 +61,13 @@ bt_status_t btc_init_bluetooth(future_t *future);
|
||||
void btc_deinit_bluetooth(future_t *future);
|
||||
#endif
|
||||
|
||||
/* btc_ble_gattc_args_t */
|
||||
typedef union {
|
||||
//BTC_GATT_ACT_SET_LOCAL_MTU,
|
||||
struct set_mtu_arg {
|
||||
uint16_t mtu;
|
||||
} set_mtu;
|
||||
} btc_ble_main_args_t;
|
||||
|
||||
void btc_main_call_handler(btc_msg_t *msg);
|
||||
#endif /* __BTC_BT_MAIN_H__ */
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "bta_api.h"
|
||||
#include "gki.h"
|
||||
#include "btc_av_api.h"
|
||||
|
||||
#if (BTA_AV_INCLUDED == TRUE)
|
||||
@ -174,9 +173,9 @@ extern BOOLEAN btc_media_task_aa_tx_flush_req(void);
|
||||
**
|
||||
** Function btc_media_aa_readbuf
|
||||
**
|
||||
** Description Read an audio GKI buffer from the BTC media TX queue
|
||||
** Description Read an audio buffer from the BTC media TX queue
|
||||
**
|
||||
** Returns pointer on a GKI aa buffer ready to send
|
||||
** Returns pointer on a aa buffer ready to send
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BT_HDR *btc_media_aa_readbuf(void);
|
||||
@ -198,7 +197,7 @@ UINT8 btc_media_sink_enque_buf(BT_HDR *p_buf);
|
||||
**
|
||||
** Function btc_media_aa_writebuf
|
||||
**
|
||||
** Description Enqueue a Advance Audio media GKI buffer to be processed by btc media task.
|
||||
** Description Enqueue a Advance Audio media buffer to be processed by btc media task.
|
||||
**
|
||||
** Returns TRUE is success
|
||||
**
|
||||
@ -209,7 +208,7 @@ extern void btc_media_aa_writebuf(BT_HDR *pBuf, UINT32 timestamp, UINT16 seq_num
|
||||
**
|
||||
** Function btc_media_av_writebuf
|
||||
**
|
||||
** Description Enqueue a video media GKI buffer to be processed by btc media task.
|
||||
** Description Enqueue a video media buffer to be processed by btc media task.
|
||||
**
|
||||
** Returns TRUE is success
|
||||
**
|
||||
|
@ -110,7 +110,6 @@ typedef struct tBAUD_REG_tag {
|
||||
UINT8 ExplicitBaudRate3;
|
||||
} tBAUD_REG;
|
||||
|
||||
#include "gki.h"
|
||||
|
||||
extern const tBAUD_REG baud_rate_regs[];
|
||||
|
||||
|
@ -69,7 +69,9 @@ enum {
|
||||
BTM_REPEATED_ATTEMPTS, /* 19 repeated attempts for LE security requests */
|
||||
BTM_MODE4_LEVEL4_NOT_SUPPORTED, /* 20 Secure Connections Only Mode can't be supported */
|
||||
BTM_PEER_LE_DATA_LEN_UNSUPPORTED, /* 21 peer setting data length is unsupported*/
|
||||
BTM_CONTROL_LE_DATA_LEN_UNSUPPORTED /* 22 controller setting data length is unsupported*/
|
||||
BTM_CONTROL_LE_DATA_LEN_UNSUPPORTED,/* 22 controller setting data length is unsupported*/
|
||||
BTM_SET_PRIVACY_SUCCESS, /* 23 enable/disable local privacy success */
|
||||
BTM_SET_PRIVACY_FAIL, /* 24 enable/disable local privacy failed*/
|
||||
};
|
||||
|
||||
typedef uint8_t tBTM_STATUS;
|
||||
@ -175,6 +177,8 @@ typedef void (tBTM_UPDATE_CONN_PARAM_CBACK) (UINT8 status, BD_ADDR bd_addr, tBTM
|
||||
|
||||
typedef void (tBTM_SET_PKT_DATA_LENGTH_CBACK) (UINT8 status, tBTM_LE_SET_PKT_DATA_LENGTH_PARAMS *data_length_params);
|
||||
|
||||
typedef void (tBTM_SET_LOCAL_PRIVACY_CBACK) (UINT8 status);
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** DEVICE DISCOVERY - Inquiry, Remote Name, Discovery, Class of Device
|
||||
@ -1412,6 +1416,7 @@ typedef UINT8 tBTM_IO_CAP;
|
||||
#define BTM_BLE_INITIATOR_KEY_SIZE 15
|
||||
#define BTM_BLE_RESPONDER_KEY_SIZE 15
|
||||
#define BTM_BLE_MAX_KEY_SIZE 16
|
||||
#define BTM_BLE_MIN_KEY_SIZE 7
|
||||
|
||||
typedef UINT8 tBTM_AUTH_REQ;
|
||||
|
||||
|
@ -27,7 +27,6 @@
|
||||
|
||||
#include "bt_defs.h"
|
||||
#include "btm_api.h"
|
||||
#include "gki.h"
|
||||
#include "bt_common_types.h"
|
||||
|
||||
#define CHANNEL_MAP_LEN 5
|
||||
@ -164,12 +163,12 @@ typedef UINT8 tBTM_BLE_SFP;
|
||||
|
||||
/* default connection interval min */
|
||||
#ifndef BTM_BLE_CONN_INT_MIN_DEF
|
||||
#define BTM_BLE_CONN_INT_MIN_DEF 24 /* recommended min: 30ms = 24 * 1.25 */
|
||||
#define BTM_BLE_CONN_INT_MIN_DEF 10 /* recommended min: 12.5 ms = 10 * 1.25 */
|
||||
#endif
|
||||
|
||||
/* default connection interval max */
|
||||
#ifndef BTM_BLE_CONN_INT_MAX_DEF
|
||||
#define BTM_BLE_CONN_INT_MAX_DEF 40 /* recommended max: 50 ms = 56 * 1.25 */
|
||||
#define BTM_BLE_CONN_INT_MAX_DEF 12 /* recommended max: 15 ms = 12 * 1.25 */
|
||||
#endif
|
||||
|
||||
/* default slave latency */
|
||||
@ -861,6 +860,20 @@ tBTM_BLE_SCAN_SETUP_CBACK bta_ble_scan_setup_cb;
|
||||
extern "C" {
|
||||
#endif
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_BleRegiseterConnParamCallback
|
||||
**
|
||||
** Description register connection parameters update callback func
|
||||
**
|
||||
** Parameters: update_conn_param_cb
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTM_BleRegiseterConnParamCallback(tBTM_UPDATE_CONN_PARAM_CBACK *update_conn_param_cb);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_SecAddBleDevice
|
||||
@ -1596,7 +1609,7 @@ tBTM_STATUS BTM_BleBroadcast(BOOLEAN start);
|
||||
**
|
||||
*******************************************************************************/
|
||||
//extern
|
||||
BOOLEAN BTM_BleConfigPrivacy(BOOLEAN enable);
|
||||
BOOLEAN BTM_BleConfigPrivacy(BOOLEAN enable, tBTM_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cabck);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -27,7 +27,7 @@
|
||||
#define BTM_BLE_INT_H
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "gki.h"
|
||||
#include "fixed_queue.h"
|
||||
#include "hcidefs.h"
|
||||
#include "btm_ble_api.h"
|
||||
#include "btm_int.h"
|
||||
@ -185,6 +185,7 @@ typedef struct {
|
||||
tBTM_BLE_ADDR_CBACK *p_generate_cback;
|
||||
void *p;
|
||||
TIMER_LIST_ENT raddr_timer_ent;
|
||||
tBTM_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cback;
|
||||
} tBTM_LE_RANDOM_CB;
|
||||
|
||||
#define BTM_BLE_MAX_BG_CONN_DEV_NUM 10
|
||||
@ -315,7 +316,7 @@ typedef struct {
|
||||
UINT8 white_list_avail_size;
|
||||
tBTM_BLE_WL_STATE wl_state;
|
||||
|
||||
BUFFER_Q conn_pending_q;
|
||||
fixed_queue_t *conn_pending_q;
|
||||
tBTM_BLE_CONN_ST conn_state;
|
||||
|
||||
/* random address management control block */
|
||||
@ -362,6 +363,7 @@ BOOLEAN btm_ble_send_extended_scan_params(UINT8 scan_type, UINT32 scan_int,
|
||||
UINT8 scan_filter_policy);
|
||||
void btm_ble_stop_inquiry(void);
|
||||
void btm_ble_init (void);
|
||||
void btm_ble_free (void);
|
||||
void btm_ble_connected (UINT8 *bda, UINT16 handle, UINT8 enc_mode, UINT8 role, tBLE_ADDR_TYPE addr_type, BOOLEAN addr_matched);
|
||||
void btm_ble_read_remote_features_complete(UINT8 *p);
|
||||
void btm_ble_write_adv_enable_complete(UINT8 *p);
|
||||
|
@ -27,7 +27,6 @@
|
||||
|
||||
#include "bt_defs.h"
|
||||
#include "bt_target.h"
|
||||
#include "gki.h"
|
||||
#include "hcidefs.h"
|
||||
|
||||
#include "rfcdefs.h"
|
||||
@ -115,7 +114,6 @@ UINT8 conn_addr_type; /* local device address type for this co
|
||||
BD_ADDR active_remote_addr; /* remote address used on this connection */
|
||||
UINT8 active_remote_addr_type; /* local device address type for this connection */
|
||||
BD_FEATURES peer_le_features; /* Peer LE Used features mask for the device */
|
||||
tBTM_UPDATE_CONN_PARAM_CBACK *update_conn_param_cb;
|
||||
tBTM_SET_PKT_DATA_LENGTH_CBACK *p_set_pkt_data_cback;
|
||||
tBTM_LE_SET_PKT_DATA_LENGTH_PARAMS data_length_params;
|
||||
#endif
|
||||
@ -367,7 +365,7 @@ typedef struct {
|
||||
typedef struct {
|
||||
tBTM_ESCO_INFO esco; /* Current settings */
|
||||
#if BTM_SCO_HCI_INCLUDED == TRUE
|
||||
BUFFER_Q xmit_data_q; /* SCO data transmitting queue */
|
||||
fixed_queue_t *xmit_data_q; /* SCO data transmitting queue */
|
||||
#endif
|
||||
tBTM_SCO_CB *p_conn_cb; /* Callback for when connected */
|
||||
tBTM_SCO_CB *p_disc_cb; /* Callback for when disconnect */
|
||||
@ -865,15 +863,21 @@ typedef struct {
|
||||
UINT8 busy_level; /* the current busy level */
|
||||
BOOLEAN is_paging; /* TRUE, if paging is in progess */
|
||||
BOOLEAN is_inquiry; /* TRUE, if inquiry is in progess */
|
||||
BUFFER_Q page_queue;
|
||||
fixed_queue_t *page_queue;
|
||||
BOOLEAN paging;
|
||||
BOOLEAN discing;
|
||||
BUFFER_Q sec_pending_q; /* pending sequrity requests in tBTM_SEC_QUEUE_ENTRY format */
|
||||
fixed_queue_t *sec_pending_q; /* pending sequrity requests in tBTM_SEC_QUEUE_ENTRY format */
|
||||
#if (!defined(BT_TRACE_VERBOSE) || (BT_TRACE_VERBOSE == FALSE))
|
||||
char state_temp_buffer[BTM_STATE_BUFFER_SIZE];
|
||||
#endif
|
||||
} tBTM_CB;
|
||||
|
||||
typedef struct{
|
||||
//connection parameters update callback
|
||||
tBTM_UPDATE_CONN_PARAM_CBACK *update_conn_param_cb;
|
||||
}tBTM_CallbackFunc;
|
||||
|
||||
extern tBTM_CallbackFunc conn_param_update_cb;
|
||||
/*
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
@ -892,6 +896,7 @@ extern tBTM_CB *btm_cb_ptr;
|
||||
********************************************
|
||||
*/
|
||||
void btm_init (void);
|
||||
void btm_free (void);
|
||||
|
||||
/* Internal functions provided by btm_inq.c
|
||||
*******************************************
|
||||
|
@ -28,7 +28,7 @@
|
||||
#define BTU_H
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "gki.h"
|
||||
#include "bt_defs.h"
|
||||
|
||||
// HACK(zachoverflow): temporary dark magic
|
||||
#define BTU_POST_TO_TASK_NO_GOOD_HORRIBLE_HACK 0x1700 // didn't look used in bt_types...here goes nothing
|
||||
|
@ -136,7 +136,7 @@ esp_err_t esp_avrc_ct_deinit(void);
|
||||
* @param[in] tl : transaction label, 0 to 15, consecutive commands should use different values.
|
||||
* @param[in] key_code : passthrough command code, e.g. ESP_AVRC_PT_CMD_PLAY, ESP_AVRC_PT_CMD_STOP, etc.
|
||||
* @param[in] key_state : passthrough command key state, ESP_AVRC_PT_CMD_STATE_PRESSED or
|
||||
* ESP_AVRC_PT_CMD_STATE_PRESSED
|
||||
* ESP_AVRC_PT_CMD_STATE_RELEASED
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
|
@ -22,6 +22,12 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ESP_BLUEDROID_STATUS_CHECK(status) \
|
||||
if (esp_bluedroid_get_status() != (status)) { \
|
||||
return ESP_ERR_INVALID_STATE; \
|
||||
}
|
||||
|
||||
|
||||
/* relate to BT_STATUS_xxx in bt_def.h */
|
||||
/// Status Return Value
|
||||
typedef enum {
|
||||
@ -44,6 +50,7 @@ typedef enum {
|
||||
ESP_BT_STATUS_TIMEOUT, /* relate to BT_STATUS_TIMEOUT in bt_def.h */
|
||||
ESP_BT_STATUS_PEER_LE_DATA_LEN_UNSUPPORTED, /* relate to BTM_PEER_LE_DATA_LEN_UNSUPPORTED in btm_api.h */
|
||||
ESP_BT_STATUS_CONTROL_LE_DATA_LEN_UNSUPPORTED,/* relate to BTM_CONTROL_LE_DATA_LEN_UNSUPPORTED in btm_api.h */
|
||||
ESP_BT_STATUS_ERR_ILLEGAL_PARAMETER_FMT, /* relate to HCI_ERR_ILLEGAL_PARAMETER_FMT in hcidefs.h */
|
||||
} esp_bt_status_t;
|
||||
|
||||
|
||||
@ -107,6 +114,7 @@ typedef enum {
|
||||
#define ESP_BLE_CSR_KEY_MASK (1 << 2) /* relate to BTM_BLE_CSR_KEY_MASK in btm_api.h */
|
||||
/// Used to exchange the link key(this key just used in the BLE & BR/EDR coexist mode) in the init key & response key
|
||||
#define ESP_BLE_LINK_KEY_MASK (1 << 3) /* relate to BTM_BLE_LINK_KEY_MASK in btm_api.h */
|
||||
typedef uint8_t esp_ble_key_mask_t; /* the key mask type */
|
||||
|
||||
/// Minimum of the application id
|
||||
#define ESP_APP_ID_MIN 0x0000
|
||||
|
@ -93,6 +93,11 @@ typedef enum {
|
||||
ESP_GAP_BLE_SET_STATIC_RAND_ADDR_EVT, /*!< When set the static rand address complete, the event comes */
|
||||
ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT, /*!< When update connection parameters complete, the event comes */
|
||||
ESP_GAP_BLE_SET_PKT_LENGTH_COMPLETE_EVT, /*!< When set pkt lenght complete, the event comes */
|
||||
ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT, /*!< When Enable/disable privacy on the local device complete, the event comes */
|
||||
ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT, /*!< When remove the bond device complete, the event comes */
|
||||
ESP_GAP_BLE_CLEAR_BOND_DEV_COMPLETE_EVT, /*!< When clear the bond device clear complete, the event comes */
|
||||
ESP_GAP_BLE_GET_BOND_DEV_COMPLETE_EVT, /*!< When get the bond device list complete, the event comes */
|
||||
ESP_GAP_BLE_EVT_MAX,
|
||||
} esp_gap_ble_cb_event_t;
|
||||
|
||||
/// Advertising data maximum length
|
||||
@ -293,7 +298,7 @@ typedef struct
|
||||
uint16_t ediv; /*!< The ediv value*/
|
||||
uint8_t sec_level; /*!< The security level of the security link*/
|
||||
uint8_t key_size; /*!< The key size(7~16) of the security link*/
|
||||
}esp_ble_penc_keys_t; /*!< The key type*/
|
||||
} esp_ble_penc_keys_t; /*!< The key type*/
|
||||
|
||||
/**
|
||||
* @brief BLE CSRK keys
|
||||
@ -303,7 +308,7 @@ typedef struct
|
||||
uint32_t counter; /*!< The counter */
|
||||
esp_bt_octet16_t csrk; /*!< The csrk key */
|
||||
uint8_t sec_level; /*!< The security level */
|
||||
}esp_ble_pcsrk_keys_t; /*!< The pcsrk key type */
|
||||
} esp_ble_pcsrk_keys_t; /*!< The pcsrk key type */
|
||||
|
||||
/**
|
||||
* @brief BLE pid keys
|
||||
@ -313,7 +318,7 @@ typedef struct
|
||||
esp_bt_octet16_t irk; /*!< The irk value */
|
||||
esp_ble_addr_type_t addr_type; /*!< The address type */
|
||||
esp_bd_addr_t static_addr; /*!< The static address */
|
||||
}esp_ble_pid_keys_t; /*!< The pid key type */
|
||||
} esp_ble_pid_keys_t; /*!< The pid key type */
|
||||
|
||||
/**
|
||||
* @brief BLE Encryption reproduction keys
|
||||
@ -324,7 +329,7 @@ typedef struct
|
||||
uint16_t div; /*!< The div value */
|
||||
uint8_t key_size; /*!< The key size of the security link */
|
||||
uint8_t sec_level; /*!< The security level of the security link */
|
||||
}esp_ble_lenc_keys_t; /*!< The key type */
|
||||
} esp_ble_lenc_keys_t; /*!< The key type */
|
||||
|
||||
/**
|
||||
* @brief BLE SRK keys
|
||||
@ -334,8 +339,8 @@ typedef struct
|
||||
uint32_t counter; /*!< The counter value */
|
||||
uint16_t div; /*!< The div value */
|
||||
uint8_t sec_level; /*!< The security level of the security link */
|
||||
esp_bt_octet16_t csrk; /*!< The csrk key value */
|
||||
}esp_ble_lcsrk_keys; /*!< The csrk key type */
|
||||
esp_bt_octet16_t csrk; /*!< The csrk key value */
|
||||
} esp_ble_lcsrk_keys; /*!< The csrk key type */
|
||||
|
||||
/**
|
||||
* @brief Structure associated with ESP_KEY_NOTIF_EVT
|
||||
@ -352,7 +357,7 @@ typedef struct
|
||||
typedef struct
|
||||
{
|
||||
esp_bd_addr_t bd_addr; /*!< peer address */
|
||||
}esp_ble_sec_req_t; /*!< BLE security request type*/
|
||||
} esp_ble_sec_req_t; /*!< BLE security request type*/
|
||||
|
||||
/**
|
||||
* @brief union type of the security key value
|
||||
@ -364,7 +369,27 @@ typedef union
|
||||
esp_ble_pid_keys_t pid_key; /*!< peer device ID key */
|
||||
esp_ble_lenc_keys_t lenc_key; /*!< local encryption reproduction keys LTK = = d1(ER,DIV,0)*/
|
||||
esp_ble_lcsrk_keys lcsrk_key; /*!< local device CSRK = d1(ER,DIV,1)*/
|
||||
}esp_ble_key_value_t; /*!< ble key value type*/
|
||||
} esp_ble_key_value_t; /*!< ble key value type*/
|
||||
|
||||
/**
|
||||
* @brief struct type of the bond key informatuon value
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
esp_ble_key_mask_t key_mask; /*!< the key mask to indicate witch key is present */
|
||||
esp_ble_penc_keys_t penc_key; /*!< received peer encryption key */
|
||||
esp_ble_pcsrk_keys_t pcsrk_key; /*!< received peer device SRK */
|
||||
esp_ble_pid_keys_t pid_key; /*!< peer device ID key */
|
||||
} esp_ble_bond_key_info_t; /*!< ble bond key information value type */
|
||||
|
||||
/**
|
||||
* @brief struct type of the bond device value
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
esp_bd_addr_t bd_addr; /*!< peer address */
|
||||
esp_ble_bond_key_info_t bond_key; /*!< the bond key information */
|
||||
} esp_ble_bond_dev_t; /*!< the ble bond device type */
|
||||
|
||||
|
||||
/**
|
||||
@ -375,7 +400,7 @@ typedef struct
|
||||
esp_bd_addr_t bd_addr; /*!< peer address */
|
||||
esp_ble_key_type_t key_type; /*!< key type of the security link */
|
||||
esp_ble_key_value_t p_key_value; /*!< the pointer to the key value */
|
||||
}esp_ble_key_t; /*!< the union to the ble key value type*/
|
||||
} esp_ble_key_t; /*!< the union to the ble key value type*/
|
||||
|
||||
/**
|
||||
* @brief structure type of the ble local id keys value
|
||||
@ -384,7 +409,7 @@ typedef struct {
|
||||
esp_bt_octet16_t ir; /*!< the 16 bits of the ir value */
|
||||
esp_bt_octet16_t irk; /*!< the 16 bits of the ir key value */
|
||||
esp_bt_octet16_t dhk; /*!< the 16 bits of the dh key value */
|
||||
}esp_ble_local_id_keys_t; /*!< the structure of the ble local id keys value type*/
|
||||
} esp_ble_local_id_keys_t; /*!< the structure of the ble local id keys value type*/
|
||||
|
||||
|
||||
/**
|
||||
@ -400,7 +425,7 @@ typedef struct
|
||||
uint8_t fail_reason; /*!< The HCI reason/error code for when success=FALSE */
|
||||
esp_ble_addr_type_t addr_type; /*!< Peer device address type */
|
||||
esp_bt_dev_type_t dev_type; /*!< Device type */
|
||||
}esp_ble_auth_cmpl_t; /*!< The ble authentication complite cb type */
|
||||
} esp_ble_auth_cmpl_t; /*!< The ble authentication complite cb type */
|
||||
|
||||
/**
|
||||
* @brief union associated with ble security
|
||||
@ -412,7 +437,7 @@ typedef union
|
||||
esp_ble_key_t ble_key; /*!< BLE SMP keys used when pairing */
|
||||
esp_ble_local_id_keys_t ble_id_keys; /*!< BLE IR event */
|
||||
esp_ble_auth_cmpl_t auth_cmpl; /*!< Authentication complete indication. */
|
||||
}esp_ble_sec_t; /*!< Ble secutity type */
|
||||
} esp_ble_sec_t; /*!< Ble secutity type */
|
||||
|
||||
/// Sub Event of ESP_GAP_BLE_SCAN_RESULT_EVT
|
||||
typedef enum {
|
||||
@ -539,6 +564,33 @@ typedef union {
|
||||
esp_bt_status_t status; /*!< Indicate the set pkt data length operation success status */
|
||||
esp_ble_pkt_data_length_params_t params; /*!< pkt data length value */
|
||||
} pkt_data_lenth_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_PKT_LENGTH_COMPLETE_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT
|
||||
*/
|
||||
struct ble_local_privacy_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate the set local privacy operation success status */
|
||||
} local_privacy_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT
|
||||
*/
|
||||
struct ble_remove_bond_dev_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate the remove bond device operation success status */
|
||||
esp_bd_addr_t bd_addr; /*!< The device address which has been remove from the bond list */
|
||||
}remove_bond_dev_cmpl; /*!< Event parameter of ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_CLEAR_BOND_DEV_COMPLETE_EVT
|
||||
*/
|
||||
struct ble_clear_bond_dev_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate the clear bond device operation success status */
|
||||
}clear_bond_dev_cmpl; /*!< Event parameter of ESP_GAP_BLE_CLEAR_BOND_DEV_COMPLETE_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_GET_BOND_DEV_COMPLETE_EVT
|
||||
*/
|
||||
struct ble_get_bond_dev_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate the get bond device operation success status */
|
||||
uint8_t dev_num; /*!< Indicate the get number device in the bond list */
|
||||
esp_ble_bond_dev_t *bond_dev; /*!< the pointer to the bond device Structure */
|
||||
}get_bond_dev_cmpl; /*!< Event parameter of ESP_GAP_BLE_GET_BOND_DEV_COMPLETE_EVT */
|
||||
} esp_ble_gap_cb_param_t;
|
||||
|
||||
/**
|
||||
@ -814,6 +866,38 @@ esp_err_t esp_ble_passkey_reply(esp_bd_addr_t bd_addr, bool accept, uint32_t pas
|
||||
*/
|
||||
esp_err_t esp_ble_confirm_reply(esp_bd_addr_t bd_addr, bool accept);
|
||||
|
||||
/**
|
||||
* @brief Removes a device from the security database list of
|
||||
* peer device. It manages unpairing event while connected.
|
||||
*
|
||||
* @param[in] bd_addr : BD address of the peer device
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_remove_bond_device(esp_bd_addr_t bd_addr);
|
||||
|
||||
/**
|
||||
* @brief Removes all of the device from the security database list of
|
||||
* peer device. It manages unpairing event while connected.
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_clear_bond_device_list(void);
|
||||
|
||||
/**
|
||||
* @brief Get the device from the security database list of peer device.
|
||||
* It will return the device bonded information from the ESP_GAP_BLE_GET_BOND_DEV_COMPLETE_EVT event.
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_get_bond_device_list(void);
|
||||
|
||||
/**
|
||||
* @brief This function is to disconnect the physical connection of the peer device
|
||||
*
|
||||
|
46
tools/sdk/include/bluedroid/esp_gatt_common_api.h
Normal file
46
tools/sdk/include/bluedroid/esp_gatt_common_api.h
Normal file
@ -0,0 +1,46 @@
|
||||
// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_bt_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Maximum Transmission Unit used in GATT
|
||||
#define ESP_GATT_DEF_BLE_MTU_SIZE 23 /* relate to GATT_DEF_BLE_MTU_SIZE in gatt_api.h */
|
||||
|
||||
// Maximum Transmission Unit allowed in GATT
|
||||
#define ESP_GATT_MAX_MTU_SIZE 517 /* relate to GATT_MAX_MTU_SIZE in gatt_api.h */
|
||||
|
||||
/**
|
||||
* @brief This function is called to set local MTU,
|
||||
* the function is called before BLE connection.
|
||||
*
|
||||
* @param[in] mtu: the size of MTU.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
extern esp_err_t esp_ble_gatt_set_local_mtu (uint16_t mtu);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -68,11 +68,6 @@ typedef enum {
|
||||
ESP_GATTC_DISCONNECT_EVT = 41, /*!< When the ble physical connection disconnected, the event comes */
|
||||
} esp_gattc_cb_event_t;
|
||||
|
||||
/// Maximum Transmission Unit used in GATT
|
||||
#define ESP_GATT_DEF_BLE_MTU_SIZE 23
|
||||
|
||||
/// Maximum Transmission Unit allowed in GATT
|
||||
#define ESP_GATT_MAX_MTU_SIZE 517
|
||||
|
||||
/**
|
||||
* @brief Gatt client callback parameters union
|
||||
@ -355,18 +350,19 @@ esp_err_t esp_ble_gattc_close (esp_gatt_if_t gattc_if, uint16_t conn_id);
|
||||
|
||||
/**
|
||||
* @brief Configure the MTU size in the GATT channel. This can be done
|
||||
* only once per connection.
|
||||
* only once per connection. Before using, use esp_ble_gatt_set_local_mtu()
|
||||
* to configure the local MTU size.
|
||||
*
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] conn_id: connection ID.
|
||||
* @param[in] mtu: desired MTU size to use.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_config_mtu (esp_gatt_if_t gattc_if, uint16_t conn_id, uint16_t mtu);
|
||||
esp_err_t esp_ble_gattc_send_mtu_req (esp_gatt_if_t gattc_if, uint16_t conn_id);
|
||||
|
||||
|
||||
/**
|
||||
@ -634,7 +630,7 @@ esp_err_t esp_ble_gattc_execute_write (esp_gatt_if_t gattc_if, uint16_t conn_id,
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_gatt_status_t esp_ble_gattc_register_for_notify (esp_gatt_if_t gattc_if,
|
||||
esp_err_t esp_ble_gattc_register_for_notify (esp_gatt_if_t gattc_if,
|
||||
esp_bd_addr_t server_bda,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id);
|
||||
@ -653,7 +649,7 @@ esp_gatt_status_t esp_ble_gattc_register_for_notify (esp_gatt_if_t gattc_if,
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_gatt_status_t esp_ble_gattc_unregister_for_notify (esp_gatt_if_t gattc_if,
|
||||
esp_err_t esp_ble_gattc_unregister_for_notify (esp_gatt_if_t gattc_if,
|
||||
esp_bd_addr_t server_bda,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id);
|
||||
|
@ -514,11 +514,11 @@ esp_err_t esp_ble_gatts_set_attr_value(uint16_t attr_handle, uint16_t length, co
|
||||
* @param[out] value: Pointer to attribute value payload, the value cannot be modified by user
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - ESP_GATT_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gatts_get_attr_value(uint16_t attr_handle, uint16_t *length, const uint8_t **value);
|
||||
esp_gatt_status_t esp_ble_gatts_get_attr_value(uint16_t attr_handle, uint16_t *length, const uint8_t **value);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -20,8 +20,10 @@
|
||||
#define _FIXED_QUEUE_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "list.h"
|
||||
|
||||
struct fixed_queue_t;
|
||||
|
||||
typedef struct fixed_queue_t fixed_queue_t;
|
||||
//typedef struct reactor_t reactor_t;
|
||||
|
||||
@ -38,10 +40,14 @@ fixed_queue_t *fixed_queue_new(size_t capacity);
|
||||
// blocked on it) results in undefined behaviour.
|
||||
void fixed_queue_free(fixed_queue_t *queue, fixed_queue_free_cb free_cb);
|
||||
|
||||
// Returns a value indicating whether the given |queue| is empty. |queue| may
|
||||
// not be NULL.
|
||||
// Returns a value indicating whether the given |queue| is empty. If |queue|
|
||||
// is NULL, the return value is true.
|
||||
bool fixed_queue_is_empty(fixed_queue_t *queue);
|
||||
|
||||
// Returns the length of the |queue|. If |queue| is NULL, the return value
|
||||
// is 0.
|
||||
size_t fixed_queue_length(fixed_queue_t *queue);
|
||||
|
||||
// Returns the maximum number of elements this queue may hold. |queue| may
|
||||
// not be NULL.
|
||||
size_t fixed_queue_capacity(fixed_queue_t *queue);
|
||||
@ -66,12 +72,33 @@ bool fixed_queue_try_enqueue(fixed_queue_t *queue, void *data);
|
||||
// the caller. If the queue is empty, this function returns NULL immediately.
|
||||
// Otherwise, the next element in the queue is returned. |queue| may not be
|
||||
// NULL.
|
||||
//void *fixed_queue_try_dequeue(fixed_queue_t *queue);
|
||||
void *fixed_queue_try_dequeue(fixed_queue_t *queue);
|
||||
|
||||
// Returns the first element from |queue|, if present, without dequeuing it.
|
||||
// This function will never block the caller. Returns NULL if there are no elements
|
||||
// in the queue. |queue| may not be NULL.
|
||||
//void *fixed_queue_try_peek(fixed_queue_t *queue);
|
||||
// This function will never block the caller. Returns NULL if there are no
|
||||
// elements in the queue or |queue| is NULL.
|
||||
void *fixed_queue_try_peek_first(fixed_queue_t *queue);
|
||||
|
||||
// Returns the last element from |queue|, if present, without dequeuing it.
|
||||
// This function will never block the caller. Returns NULL if there are no
|
||||
// elements in the queue or |queue| is NULL.
|
||||
void *fixed_queue_try_peek_last(fixed_queue_t *queue);
|
||||
|
||||
// Tries to remove a |data| element from the middle of the |queue|. This
|
||||
// function will never block the caller. If the queue is empty or NULL, this
|
||||
// function returns NULL immediately. |data| may not be NULL. If the |data|
|
||||
// element is found in the queue, a pointer to the removed data is returned,
|
||||
// otherwise NULL.
|
||||
void *fixed_queue_try_remove_from_queue(fixed_queue_t *queue, void *data);
|
||||
|
||||
// Returns the iterateable list with all entries in the |queue|. This function
|
||||
// will never block the caller. |queue| may not be NULL.
|
||||
//
|
||||
// NOTE: The return result of this function is not thread safe: the list could
|
||||
// be modified by another thread, and the result would be unpredictable.
|
||||
// TODO: The usage of this function should be refactored, and the function
|
||||
// itself should be removed.
|
||||
list_t *fixed_queue_get_list(fixed_queue_t *queue);
|
||||
|
||||
// This function returns a valid file descriptor. Callers may perform one
|
||||
// operation on the fd: select(2). If |select| indicates that the file
|
||||
@ -99,4 +126,6 @@ void fixed_queue_unregister_dequeue(fixed_queue_t *queue);
|
||||
|
||||
void fixed_queue_process(fixed_queue_t *queue);
|
||||
|
||||
list_t *fixed_queue_get_list(fixed_queue_t *queue);
|
||||
|
||||
#endif
|
||||
|
@ -18,9 +18,8 @@
|
||||
|
||||
#ifndef __FUTURE_H__
|
||||
#define __FUTURE_H__
|
||||
// #pragma once
|
||||
|
||||
#include "osi_arch.h"
|
||||
#include "semaphore.h"
|
||||
|
||||
struct future {
|
||||
bool ready_can_be_called;
|
||||
|
@ -21,8 +21,8 @@
|
||||
#define GAP_INT_H
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "fixed_queue.h"
|
||||
#include "gap_api.h"
|
||||
#include "gki.h"
|
||||
#include "gatt_api.h"
|
||||
#define GAP_MAX_BLOCKS 2 /* Concurrent GAP commands pending at a time*/
|
||||
/* Define the Generic Access Profile control structure */
|
||||
@ -71,8 +71,8 @@ typedef struct {
|
||||
UINT16 rem_mtu_size;
|
||||
|
||||
BOOLEAN is_congested;
|
||||
BUFFER_Q tx_queue; /* Queue of buffers waiting to be sent */
|
||||
BUFFER_Q rx_queue; /* Queue of buffers waiting to be read */
|
||||
fixed_queue_t *tx_queue; /* Queue of buffers waiting to be sent */
|
||||
fixed_queue_t *rx_queue; /* Queue of buffers waiting to be read */
|
||||
|
||||
UINT32 rx_queue_size; /* Total data count in rx_queue */
|
||||
|
||||
@ -119,7 +119,7 @@ typedef struct {
|
||||
UINT16 cl_op_uuid;
|
||||
BOOLEAN in_use;
|
||||
BOOLEAN connected;
|
||||
BUFFER_Q pending_req_q;
|
||||
fixed_queue_t *pending_req_q;
|
||||
|
||||
} tGAP_CLCB;
|
||||
|
||||
|
@ -943,7 +943,7 @@ tGATT_STATUS GATTS_GetAttributeValue(UINT16 attr_handle, UINT16 *length, UINT8 *
|
||||
** Returns GATT_SUCCESS if command started successfully.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tGATT_STATUS GATTC_ConfigureMTU (UINT16 conn_id, UINT16 mtu);
|
||||
extern tGATT_STATUS GATTC_ConfigureMTU (UINT16 conn_id);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -20,12 +20,11 @@
|
||||
#define GATT_INT_H
|
||||
|
||||
#include "bt_target.h"
|
||||
|
||||
|
||||
#include "bt_trace.h"
|
||||
#include "gatt_api.h"
|
||||
#include "btm_ble_api.h"
|
||||
#include "btu.h"
|
||||
#include "fixed_queue.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@ -222,7 +221,7 @@ typedef struct {
|
||||
typedef struct {
|
||||
void *p_attr_list; /* pointer to the first attribute, either tGATT_ATTR16 or tGATT_ATTR128 */
|
||||
UINT8 *p_free_mem; /* Pointer to free memory */
|
||||
BUFFER_Q svc_buffer; /* buffer queue used for service database */
|
||||
fixed_queue_t *svc_buffer; /* buffer queue used for service database */
|
||||
UINT32 mem_free; /* Memory still available */
|
||||
UINT16 end_handle; /* Last handle number */
|
||||
UINT16 next_handle; /* Next usable handle value */
|
||||
@ -285,7 +284,7 @@ typedef struct {
|
||||
BT_HDR *p_rsp_msg;
|
||||
UINT32 trans_id;
|
||||
tGATT_READ_MULTI multi_req;
|
||||
BUFFER_Q multi_rsp_q;
|
||||
fixed_queue_t *multi_rsp_q;
|
||||
UINT16 handle;
|
||||
UINT8 op_code;
|
||||
UINT8 status;
|
||||
@ -357,7 +356,7 @@ typedef struct{
|
||||
typedef struct{
|
||||
//only store prepare write packets which need
|
||||
//to be responded by stack (not by application)
|
||||
BUFFER_Q queue;
|
||||
fixed_queue_t *queue;
|
||||
|
||||
//store the total number of prepare write packets
|
||||
//including that should be responded by stack or by application
|
||||
@ -369,7 +368,7 @@ typedef struct{
|
||||
}tGATT_PREPARE_WRITE_RECORD;
|
||||
|
||||
typedef struct {
|
||||
BUFFER_Q pending_enc_clcb; /* pending encryption channel q */
|
||||
fixed_queue_t *pending_enc_clcb; /* pending encryption channel q */
|
||||
tGATT_SEC_ACTION sec_act;
|
||||
BD_ADDR peer_bda;
|
||||
tBT_TRANSPORT transport;
|
||||
@ -389,7 +388,7 @@ typedef struct {
|
||||
tGATT_SR_CMD sr_cmd;
|
||||
#endif ///GATTS_INCLUDED == TRUE
|
||||
UINT16 indicate_handle;
|
||||
BUFFER_Q pending_ind_q;
|
||||
fixed_queue_t *pending_ind_q;
|
||||
|
||||
TIMER_LIST_ENT conf_timer_ent; /* peer confirm to indication timer */
|
||||
|
||||
@ -498,7 +497,7 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
tGATT_TCB tcb[GATT_MAX_PHY_CHANNEL];
|
||||
BUFFER_Q sign_op_queue;
|
||||
fixed_queue_t *sign_op_queue;
|
||||
|
||||
tGATT_SR_REG sr_reg[GATT_MAX_SR_PROFILES];
|
||||
UINT16 next_handle; /* next available handle */
|
||||
@ -510,8 +509,8 @@ typedef struct {
|
||||
tGATT_SRV_LIST_INFO srv_list_info;
|
||||
tGATT_SRV_LIST_ELEM srv_list[GATT_MAX_SR_PROFILES];
|
||||
#endif ///GATTS_INCLUDED == TRUE
|
||||
BUFFER_Q srv_chg_clt_q; /* service change clients queue */
|
||||
BUFFER_Q pending_new_srv_start_q; /* pending new service start queue */
|
||||
fixed_queue_t *srv_chg_clt_q; /* service change clients queue */
|
||||
fixed_queue_t *pending_new_srv_start_q; /* pending new service start queue */
|
||||
tGATT_REG cl_rcb[GATT_MAX_APPS];
|
||||
tGATT_CLCB clcb[GATT_CL_MAX_LCB]; /* connection link control block*/
|
||||
tGATT_SCCB sccb[GATT_MAX_SCCB]; /* sign complete callback function GATT_MAX_SCCB <= GATT_CL_MAX_LCB */
|
||||
@ -538,6 +537,9 @@ typedef struct {
|
||||
|
||||
} tGATT_CB;
|
||||
|
||||
typedef struct{
|
||||
UINT16 local_mtu;
|
||||
} tGATT_DEFAULT;
|
||||
|
||||
#define GATT_SIZE_OF_SRV_CHG_HNDL_RANGE 4
|
||||
|
||||
@ -545,6 +547,8 @@ typedef struct {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern tGATT_DEFAULT gatt_default;
|
||||
|
||||
/* Global GATT data */
|
||||
#if GATT_DYNAMIC_MEMORY == FALSE
|
||||
extern tGATT_CB gatt_cb;
|
||||
@ -742,4 +746,6 @@ extern void gatts_update_srv_list_elem(UINT8 i_sreg, UINT16 handle, BOOLEAN is_p
|
||||
extern tBT_UUID *gatts_get_service_uuid (tGATT_SVC_DB *p_db);
|
||||
|
||||
extern void gatt_reset_bgdev_list(void);
|
||||
extern uint16_t gatt_get_local_mtu(void);
|
||||
extern void gatt_set_local_mtu(uint16_t mtu);
|
||||
#endif
|
||||
|
@ -1,132 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef _GKI_H_
|
||||
#define _GKI_H_
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "bt_types.h"
|
||||
#include "gki_common.h"
|
||||
#include "gki_int.h"
|
||||
#include "allocator.h"
|
||||
|
||||
#define ALIGN_POOL(pl_size) ( (((pl_size) + 3) / sizeof(UINT32)) * sizeof(UINT32))
|
||||
#define BUFFER_HDR_SIZE (sizeof(BUFFER_HDR_T)) /* Offset past header */
|
||||
#define BUFFER_PADDING_SIZE (sizeof(BUFFER_HDR_T) + sizeof(UINT32)) /* Header + Magic Number */
|
||||
#define MAGIC_NO 0xDDBADDBA
|
||||
|
||||
#define BUF_STATUS_FREE 0
|
||||
#define BUF_STATUS_UNLINKED 1
|
||||
#define BUF_STATUS_QUEUED 2
|
||||
|
||||
/* Timer list entry callback type
|
||||
*/
|
||||
typedef void (TIMER_CBACK)(void *p_tle);
|
||||
#ifndef TIMER_PARAM_TYPE
|
||||
#define TIMER_PARAM_TYPE UINT32
|
||||
#endif
|
||||
/* Define a timer list entry
|
||||
*/
|
||||
typedef struct _tle {
|
||||
struct _tle *p_next;
|
||||
struct _tle *p_prev;
|
||||
TIMER_CBACK *p_cback;
|
||||
INT32 ticks;
|
||||
INT32 ticks_initial;
|
||||
TIMER_PARAM_TYPE param;
|
||||
TIMER_PARAM_TYPE data;
|
||||
UINT16 event;
|
||||
UINT8 in_use;
|
||||
} TIMER_LIST_ENT;
|
||||
|
||||
/***********************************************************************
|
||||
** This queue is a general purpose buffer queue, for application use.
|
||||
*/
|
||||
typedef struct {
|
||||
void *_p_first;
|
||||
void *_p_last;
|
||||
UINT16 _count;
|
||||
} BUFFER_Q;
|
||||
|
||||
#define GKI_PUBLIC_POOL 0 /* General pool accessible to GKI_getbuf() */
|
||||
#define GKI_RESTRICTED_POOL 1 /* Inaccessible pool to GKI_getbuf() */
|
||||
|
||||
/***********************************************************************
|
||||
** Function prototypes
|
||||
*/
|
||||
|
||||
/* To get and release buffers, change owner and get size
|
||||
*/
|
||||
void *GKI_getbuf_func(UINT16);
|
||||
void *GKI_getpoolbuf_func(UINT8);
|
||||
void GKI_freebuf(void *);
|
||||
UINT16 GKI_get_buf_size (void *);
|
||||
void *GKI_getpoolbuf (UINT8);
|
||||
UINT16 GKI_poolcount (UINT8);
|
||||
UINT16 GKI_poolfreecount (UINT8);
|
||||
UINT16 GKI_poolutilization (UINT8);
|
||||
|
||||
#ifdef CONFIG_BLUEDROID_MEM_DEBUG
|
||||
|
||||
#define GKI_getbuf(_size) \
|
||||
({ \
|
||||
BUFFER_HDR_T *header = osi_malloc((_size) + BUFFER_HDR_SIZE); \
|
||||
header->status = BUF_STATUS_UNLINKED; \
|
||||
header->p_next = NULL; \
|
||||
header->Type = 0; \
|
||||
header->size = (_size); \
|
||||
(void *)(header + 1); \
|
||||
})
|
||||
|
||||
#define GKI_getpoolbuf(_pool_id) \
|
||||
({ \
|
||||
(void *)GKI_getbuf(gki_cb.com.pool_size[(_pool_id)]); \
|
||||
})
|
||||
|
||||
#else
|
||||
#define GKI_getbuf GKI_getbuf_func
|
||||
#define GKI_getpoolbuf GKI_getpoolbuf_func
|
||||
|
||||
#endif /* CONFIG_BLUEDROID_MEM_DEBUG */
|
||||
|
||||
/* User buffer queue management
|
||||
*/
|
||||
void *GKI_dequeue (BUFFER_Q *);
|
||||
void GKI_enqueue (BUFFER_Q *, void *);
|
||||
void *GKI_getfirst (BUFFER_Q *);
|
||||
void *GKI_getlast (BUFFER_Q *);
|
||||
void *GKI_getnext (void *);
|
||||
void GKI_init_q (BUFFER_Q *);
|
||||
UINT16 GKI_queue_length(BUFFER_Q *);
|
||||
BOOLEAN GKI_queue_is_empty(BUFFER_Q *);
|
||||
void *GKI_remove_from_queue (BUFFER_Q *, void *);
|
||||
UINT16 GKI_get_pool_bufsize (UINT8);
|
||||
|
||||
/* Timer management
|
||||
*/
|
||||
void GKI_delay(UINT32);
|
||||
|
||||
/* Disable Interrupts, Enable Interrupts
|
||||
*/
|
||||
void GKI_enable(void);
|
||||
void GKI_disable(void);
|
||||
|
||||
/* os timer operation */
|
||||
UINT32 GKI_get_os_tick_count(void);
|
||||
|
||||
#endif /*_GKI_H_*/
|
@ -1,65 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef _GKI_COMMON_H_
|
||||
#define _GKI_COMMON_H_
|
||||
|
||||
#include "gki.h"
|
||||
|
||||
typedef struct _buffer_hdr {
|
||||
struct _buffer_hdr *p_next; /* next buffer in the queue */
|
||||
UINT8 q_id; /* id of the queue */
|
||||
UINT8 status; /* FREE, UNLINKED or QUEUED */
|
||||
UINT8 Type;
|
||||
UINT16 size;
|
||||
} BUFFER_HDR_T;
|
||||
|
||||
typedef struct _free_queue {
|
||||
BUFFER_HDR_T *_p_first; /* first buffer in the queue */
|
||||
BUFFER_HDR_T *_p_last; /* last buffer in the queue */
|
||||
UINT16 size; /* size of the buffers in the pool */
|
||||
UINT16 total; /* toatal number of buffers */
|
||||
UINT16 cur_cnt; /* number of buffers currently allocated */
|
||||
UINT16 max_cnt; /* maximum number of buffers allocated at any time */
|
||||
} FREE_QUEUE_T;
|
||||
|
||||
/* Put all GKI variables into one control block
|
||||
*/
|
||||
typedef struct {
|
||||
/* Define the buffer pool management variables
|
||||
*/
|
||||
FREE_QUEUE_T freeq[GKI_NUM_TOTAL_BUF_POOLS];
|
||||
|
||||
UINT16 pool_buf_size[GKI_NUM_TOTAL_BUF_POOLS];
|
||||
|
||||
/* Define the buffer pool start addresses
|
||||
*/
|
||||
UINT8 *pool_start[GKI_NUM_TOTAL_BUF_POOLS]; /* array of pointers to the start of each buffer pool */
|
||||
UINT8 *pool_end[GKI_NUM_TOTAL_BUF_POOLS]; /* array of pointers to the end of each buffer pool */
|
||||
UINT16 pool_size[GKI_NUM_TOTAL_BUF_POOLS]; /* actual size of the buffers in a pool */
|
||||
|
||||
/* Define the buffer pool access control variables */
|
||||
UINT16 pool_access_mask; /* Bits are set if the corresponding buffer pool is a restricted pool */
|
||||
} tGKI_COM_CB;
|
||||
|
||||
/* Internal GKI function prototypes
|
||||
*/
|
||||
void gki_buffer_init(void);
|
||||
void gki_buffer_cleanup(void);
|
||||
|
||||
#endif /*_GKI_COMMON_H_*/
|
@ -1,244 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-2012 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef _GKI_TARGET_H_
|
||||
#define _GKI_TARGET_H_
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Buffer configuration
|
||||
**
|
||||
******************************************************************************/
|
||||
|
||||
/* The size of the buffers in pool 0. */
|
||||
#ifndef GKI_BUF0_SIZE
|
||||
#define GKI_BUF0_SIZE 64
|
||||
#endif
|
||||
|
||||
/* The number of buffers in buffer pool 0. */
|
||||
#ifndef GKI_BUF0_MAX
|
||||
#define GKI_BUF0_MAX 96
|
||||
#endif
|
||||
|
||||
/* The ID of buffer pool 0. */
|
||||
#ifndef GKI_POOL_ID_0
|
||||
#define GKI_POOL_ID_0 0
|
||||
#endif
|
||||
|
||||
/* The size of the buffers in pool 1. */
|
||||
#ifndef GKI_BUF1_SIZE
|
||||
#define GKI_BUF1_SIZE 288
|
||||
#endif
|
||||
|
||||
/* The number of buffers in buffer pool 1. */
|
||||
#ifndef GKI_BUF1_MAX
|
||||
#define GKI_BUF1_MAX 52
|
||||
#endif
|
||||
|
||||
/* The ID of buffer pool 1. */
|
||||
#ifndef GKI_POOL_ID_1
|
||||
#define GKI_POOL_ID_1 1
|
||||
#endif
|
||||
|
||||
/* The size of the buffers in pool 2. */
|
||||
#ifndef GKI_BUF2_SIZE
|
||||
#define GKI_BUF2_SIZE 660
|
||||
#endif
|
||||
|
||||
/* The number of buffers in buffer pool 2. */
|
||||
#ifndef GKI_BUF2_MAX
|
||||
#define GKI_BUF2_MAX 90
|
||||
#endif
|
||||
|
||||
/* The ID of buffer pool 2. */
|
||||
#ifndef GKI_POOL_ID_2
|
||||
#define GKI_POOL_ID_2 2
|
||||
#endif
|
||||
|
||||
/* The size of the buffers in pool 3. */
|
||||
#ifndef GKI_BUF3_SIZE
|
||||
#define GKI_BUF3_SIZE (4096+16)
|
||||
#endif
|
||||
|
||||
/* The number of buffers in buffer pool 3. */
|
||||
#ifndef GKI_BUF3_MAX
|
||||
#define GKI_BUF3_MAX 400
|
||||
#endif
|
||||
|
||||
/* The ID of buffer pool 3. */
|
||||
#ifndef GKI_POOL_ID_3
|
||||
#define GKI_POOL_ID_3 3
|
||||
#endif
|
||||
|
||||
/* The size of the largest PUBLIC fixed buffer in system. */
|
||||
#ifndef GKI_MAX_BUF_SIZE
|
||||
#define GKI_MAX_BUF_SIZE GKI_BUF3_SIZE
|
||||
#endif
|
||||
|
||||
/* The pool ID of the largest PUBLIC fixed buffer in system. */
|
||||
#ifndef GKI_MAX_BUF_SIZE_POOL_ID
|
||||
#define GKI_MAX_BUF_SIZE_POOL_ID GKI_POOL_ID_3
|
||||
#endif
|
||||
|
||||
/* Pool 4 is used for BluetoothSocket L2CAP connections */
|
||||
/* The size of the buffers in pool 4. */
|
||||
#ifndef GKI_BUF4_SIZE
|
||||
#define GKI_BUF4_SIZE (8080+26)
|
||||
#endif
|
||||
|
||||
/* The number of buffers in buffer pool 4. */
|
||||
#ifndef GKI_BUF4_MAX
|
||||
#define GKI_BUF4_MAX (OBX_NUM_SERVERS + OBX_NUM_CLIENTS)
|
||||
#endif
|
||||
|
||||
/* The ID of buffer pool 4. */
|
||||
#ifndef GKI_POOL_ID_4
|
||||
#define GKI_POOL_ID_4 4
|
||||
#endif
|
||||
|
||||
/* The number of fixed GKI buffer pools.
|
||||
eL2CAP requires Pool ID 5
|
||||
If BTM_SCO_HCI_INCLUDED is FALSE, Pool ID 6 is unnecessary, otherwise set to 7
|
||||
If BTA_HL_INCLUDED is FALSE then Pool ID 7 is uncessary and set the following to 7, otherwise set to 8
|
||||
If BLE_INCLUDED is FALSE then Pool ID 8 is uncessary and set the following to 8, otherwise set to 9
|
||||
POOL_ID 9 is a public pool meant for large buffer needs such as SDP_DB
|
||||
*/
|
||||
#ifndef GKI_NUM_FIXED_BUF_POOLS
|
||||
#define GKI_NUM_FIXED_BUF_POOLS 10
|
||||
#endif
|
||||
|
||||
/* The buffer pool usage mask. */
|
||||
#ifndef GKI_DEF_BUFPOOL_PERM_MASK
|
||||
/* Setting POOL_ID 9 as a public pool meant for large buffers such as SDP_DB */
|
||||
#define GKI_DEF_BUFPOOL_PERM_MASK 0xfdf0
|
||||
#endif
|
||||
|
||||
/* The following is intended to be a reserved pool for L2CAP
|
||||
Flow control and retransmissions and intentionally kept out
|
||||
of order */
|
||||
|
||||
/* The number of buffers in buffer pool 5. */
|
||||
#ifndef GKI_BUF5_MAX
|
||||
#define GKI_BUF5_MAX 64
|
||||
#endif
|
||||
|
||||
/* The ID of buffer pool 5. */
|
||||
#ifndef GKI_POOL_ID_5
|
||||
#define GKI_POOL_ID_5 5
|
||||
#endif
|
||||
|
||||
/* The size of the buffers in pool 5
|
||||
** Special pool used by L2CAP retransmissions only. This size based on segment
|
||||
** that will fit into both DH5 and 2-DH3 packet types after accounting for GKI
|
||||
** header. 13 bytes of max headers allows us a 339 payload max. (in btui_app.txt)
|
||||
** Note: 748 used for insight scriptwrapper with CAT-2 scripts.
|
||||
*/
|
||||
#ifndef GKI_BUF5_SIZE
|
||||
#define GKI_BUF5_SIZE 748
|
||||
#endif
|
||||
|
||||
/* The following is intended to be a reserved pool for SCO
|
||||
over HCI data and intentionally kept out of order */
|
||||
|
||||
/* The ID of buffer pool 6. */
|
||||
#ifndef GKI_POOL_ID_6
|
||||
#define GKI_POOL_ID_6 6
|
||||
#endif
|
||||
|
||||
/* The size of the buffers in pool 6,
|
||||
BUF_SIZE = max SCO data 255 + sizeof(BT_HDR) = 8 + SCO packet header 3 + padding 2 = 268 */
|
||||
#ifndef GKI_BUF6_SIZE
|
||||
#define GKI_BUF6_SIZE 268
|
||||
#endif
|
||||
|
||||
/* The number of buffers in buffer pool 6. */
|
||||
#ifndef GKI_BUF6_MAX
|
||||
#define GKI_BUF6_MAX 60
|
||||
#endif
|
||||
|
||||
|
||||
/* The following pool is a dedicated pool for HDP
|
||||
If a shared pool is more desirable then
|
||||
1. set BTA_HL_LRG_DATA_POOL_ID to the desired Gki Pool ID
|
||||
2. make sure that the shared pool size is larger than 9472
|
||||
3. adjust GKI_NUM_FIXED_BUF_POOLS accordingly since
|
||||
POOL ID 7 is not needed
|
||||
*/
|
||||
|
||||
/* The ID of buffer pool 7. */
|
||||
#ifndef GKI_POOL_ID_7
|
||||
#define GKI_POOL_ID_7 7
|
||||
#endif
|
||||
|
||||
/* The size of the buffers in pool 7 */
|
||||
#ifndef GKI_BUF7_SIZE
|
||||
#define GKI_BUF7_SIZE (10240 + 24)
|
||||
#endif
|
||||
|
||||
/* The number of buffers in buffer pool 7. */
|
||||
#ifndef GKI_BUF7_MAX
|
||||
#define GKI_BUF7_MAX 2
|
||||
#endif
|
||||
|
||||
/* The following pool is a dedicated pool for GATT
|
||||
If a shared pool is more desirable then
|
||||
1. set GATT_DB_POOL_ID to the desired Gki Pool ID
|
||||
2. make sure that the shared pool size fit a common GATT database needs
|
||||
3. adjust GKI_NUM_FIXED_BUF_POOLS accordingly since
|
||||
POOL ID 8 is not needed
|
||||
*/
|
||||
|
||||
/* The ID of buffer pool 8. */
|
||||
#ifndef GKI_POOL_ID_8
|
||||
#define GKI_POOL_ID_8 8
|
||||
#endif
|
||||
|
||||
/* The size of the buffers in pool 8 */
|
||||
#ifndef GKI_BUF8_SIZE
|
||||
#define GKI_BUF8_SIZE 128
|
||||
#endif
|
||||
|
||||
/* The number of buffers in buffer pool 8. */
|
||||
#ifndef GKI_BUF8_MAX
|
||||
#define GKI_BUF8_MAX 30
|
||||
#endif
|
||||
|
||||
/* The following pool is meant for large allocations such as SDP_DB */
|
||||
#ifndef GKI_POOL_ID_9
|
||||
#define GKI_POOL_ID_9 9
|
||||
#endif
|
||||
|
||||
#ifndef GKI_BUF9_SIZE
|
||||
#define GKI_BUF9_SIZE 8192
|
||||
#endif
|
||||
|
||||
#ifndef GKI_BUF9_MAX
|
||||
#define GKI_BUF9_MAX 5
|
||||
#endif
|
||||
|
||||
/* The number of fixed and dynamic buffer pools */
|
||||
#ifndef GKI_NUM_TOTAL_BUF_POOLS
|
||||
#define GKI_NUM_TOTAL_BUF_POOLS 10
|
||||
#endif
|
||||
|
||||
int gki_init(void);
|
||||
void gki_clean_up(void);
|
||||
|
||||
//void LogMsg (UINT32 trace_set_mask, const char *fmt_str, ...);
|
||||
|
||||
#endif /*_GKI_TARGET_H_*/
|
@ -77,9 +77,6 @@ typedef struct hci_t {
|
||||
// Do the postload sequence (call after the rest of the BT stack initializes).
|
||||
void (*do_postload)(void);
|
||||
|
||||
// Set the queue to receive ACL data in
|
||||
void (*set_data_queue)(fixed_queue_t *queue);
|
||||
|
||||
// Send a command through the HCI layer
|
||||
void (*transmit_command)(
|
||||
BT_HDR *command,
|
||||
|
@ -306,10 +306,10 @@ typedef struct {
|
||||
typedef struct {
|
||||
UINT8 preferred_mode;
|
||||
UINT8 allowed_modes;
|
||||
UINT8 user_rx_pool_id;
|
||||
UINT8 user_tx_pool_id;
|
||||
UINT8 fcr_rx_pool_id;
|
||||
UINT8 fcr_tx_pool_id;
|
||||
UINT16 user_rx_buf_size;
|
||||
UINT16 user_tx_buf_size;
|
||||
UINT16 fcr_rx_buf_size;
|
||||
UINT16 fcr_tx_buf_size;
|
||||
|
||||
} tL2CAP_ERTM_INFO;
|
||||
|
||||
|
@ -27,10 +27,10 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "btm_api.h"
|
||||
#include "gki.h"
|
||||
#include "l2c_api.h"
|
||||
#include "l2cdefs.h"
|
||||
#include "list.h"
|
||||
#include "fixed_queue.h"
|
||||
|
||||
#define L2CAP_MIN_MTU 48 /* Minimum acceptable MTU is 48 bytes */
|
||||
|
||||
@ -176,9 +176,9 @@ typedef struct {
|
||||
|
||||
UINT16 rx_sdu_len; /* Length of the SDU being received */
|
||||
BT_HDR *p_rx_sdu; /* Buffer holding the SDU being received */
|
||||
BUFFER_Q waiting_for_ack_q; /* Buffers sent and waiting for peer to ack */
|
||||
BUFFER_Q srej_rcv_hold_q; /* Buffers rcvd but held pending SREJ rsp */
|
||||
BUFFER_Q retrans_q; /* Buffers being retransmitted */
|
||||
fixed_queue_t *waiting_for_ack_q; /* Buffers sent and waiting for peer to ack */
|
||||
fixed_queue_t *srej_rcv_hold_q; /* Buffers rcvd but held pending SREJ rsp */
|
||||
fixed_queue_t *retrans_q; /* Buffers being retransmitted */
|
||||
|
||||
TIMER_LIST_ENT ack_timer; /* Timer delaying RR */
|
||||
TIMER_LIST_ENT mon_retrans_timer; /* Timer Monitor or Retransmission */
|
||||
@ -241,6 +241,9 @@ typedef struct {
|
||||
} tL2C_RCB;
|
||||
|
||||
|
||||
#ifndef L2CAP_CBB_DEFAULT_DATA_RATE_BUFF_QUOTA
|
||||
#define L2CAP_CBB_DEFAULT_DATA_RATE_BUFF_QUOTA 100
|
||||
#endif
|
||||
/* Define a channel control block (CCB). There may be many channel control blocks
|
||||
** between the same two Bluetooth devices (i.e. on the same link).
|
||||
** Each CCB has unique local and remote CIDs. All channel control blocks on
|
||||
@ -279,7 +282,7 @@ typedef struct t_l2c_ccb {
|
||||
tL2CAP_CH_CFG_BITS peer_cfg_bits; /* Store what peer wants to configure */
|
||||
tL2CAP_CFG_INFO peer_cfg; /* Peer's saved configuration options */
|
||||
|
||||
BUFFER_Q xmit_hold_q; /* Transmit data hold queue */
|
||||
fixed_queue_t *xmit_hold_q; /* Transmit data hold queue */
|
||||
BOOLEAN cong_sent; /* Set when congested status sent */
|
||||
UINT16 buff_quota; /* Buffer quota before sending congestion */
|
||||
|
||||
@ -379,8 +382,8 @@ typedef struct t_l2c_linkcb {
|
||||
UINT8 peer_chnl_mask[L2CAP_FIXED_CHNL_ARRAY_SIZE];
|
||||
#if (L2CAP_UCD_INCLUDED == TRUE)
|
||||
UINT16 ucd_mtu; /* peer MTU on UCD */
|
||||
BUFFER_Q ucd_out_sec_pending_q; /* Security pending outgoing UCD packet */
|
||||
BUFFER_Q ucd_in_sec_pending_q; /* Security pending incoming UCD packet */
|
||||
fixed_queue_t *ucd_out_sec_pending_q; /* Security pending outgoing UCD packet */
|
||||
fixed_queue_t *ucd_in_sec_pending_q; /* Security pending incoming UCD packet */
|
||||
#endif
|
||||
|
||||
BT_HDR *p_hcit_rcv_acl; /* Current HCIT ACL buf being rcvd */
|
||||
@ -402,14 +405,24 @@ typedef struct t_l2c_linkcb {
|
||||
#define L2C_BLE_NEW_CONN_PARAM 0x2 /* new connection parameter to be set */
|
||||
#define L2C_BLE_UPDATE_PENDING 0x4 /* waiting for connection update finished */
|
||||
#define L2C_BLE_NOT_DEFAULT_PARAM 0x8 /* not using default connection parameters */
|
||||
#define L2C_BLE_UPDATE_PARAM_FULL 0x10 /* update connection parameters full, can not update */
|
||||
UINT8 conn_update_mask;
|
||||
|
||||
UINT16 min_interval; /* parameters as requested by peripheral */
|
||||
UINT16 max_interval;
|
||||
UINT16 conn_int;
|
||||
UINT16 latency;
|
||||
UINT16 timeout;
|
||||
|
||||
/* cache connection parameters that wait to update */
|
||||
UINT16 waiting_update_conn_min_interval;
|
||||
UINT16 waiting_update_conn_max_interval;
|
||||
UINT16 waiting_update_conn_latency;
|
||||
UINT16 waiting_update_conn_timeout;
|
||||
/* cache parameters that is being updated */
|
||||
UINT16 updating_conn_min_interval;
|
||||
UINT16 updating_conn_max_interval;
|
||||
bool updating_param_flag;
|
||||
/* current connection parameters that current connection is using */
|
||||
UINT16 current_used_conn_interval;
|
||||
UINT16 current_used_conn_latency;
|
||||
UINT16 current_used_conn_timeout;
|
||||
/* connection parameters update order:
|
||||
waiting_update_conn_xx -> updating_conn_xx -> current_used_conn_xx
|
||||
*/
|
||||
#endif
|
||||
|
||||
#if (L2CAP_ROUND_ROBIN_CHANNEL_SERVICE == TRUE)
|
||||
@ -706,7 +719,7 @@ extern void l2c_fcr_proc_pdu (tL2C_CCB *p_ccb, BT_HDR *p_buf);
|
||||
extern void l2c_fcr_proc_tout (tL2C_CCB *p_ccb);
|
||||
extern void l2c_fcr_proc_ack_tout (tL2C_CCB *p_ccb);
|
||||
extern void l2c_fcr_send_S_frame (tL2C_CCB *p_ccb, UINT16 function_code, UINT16 pf_bit);
|
||||
extern BT_HDR *l2c_fcr_clone_buf (BT_HDR *p_buf, UINT16 new_offset, UINT16 no_of_bytes, UINT8 pool);
|
||||
extern BT_HDR *l2c_fcr_clone_buf (BT_HDR *p_buf, UINT16 new_offset, UINT16 no_of_bytes);
|
||||
extern BOOLEAN l2c_fcr_is_flow_controlled (tL2C_CCB *p_ccb);
|
||||
extern BT_HDR *l2c_fcr_get_next_xmit_sdu_seg (tL2C_CCB *p_ccb, UINT16 max_packet_length);
|
||||
extern void l2c_fcr_start_timer (tL2C_CCB *p_ccb);
|
||||
@ -733,6 +746,7 @@ extern void l2cble_notify_le_connection (BD_ADDR bda);
|
||||
extern void l2c_ble_link_adjust_allocation (void);
|
||||
extern void l2cble_process_conn_update_evt (UINT16 handle, UINT8 status, UINT16 conn_interval,
|
||||
UINT16 conn_latency, UINT16 conn_timeout);
|
||||
extern void l2cble_get_conn_param_format_err_from_contoller(UINT8 status, UINT16 handle);
|
||||
|
||||
#if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE)
|
||||
extern void l2cble_process_rc_param_request_evt(UINT16 handle, UINT16 int_min, UINT16 int_max,
|
||||
@ -745,6 +759,7 @@ extern void l2cble_set_fixed_channel_tx_data_length(BD_ADDR remote_bda, UINT16 f
|
||||
extern void l2c_send_update_conn_params_cb(tL2C_LCB *p_lcb, UINT8 status);
|
||||
extern void l2cble_process_data_length_change_event(UINT16 handle, UINT16 tx_data_len,
|
||||
UINT16 rx_data_len);
|
||||
extern UINT32 CalConnectParamTimeout(tL2C_LCB *p_lcb);
|
||||
|
||||
#endif
|
||||
extern void l2cu_process_fixed_disc_cback (tL2C_LCB *p_lcb);
|
||||
|
@ -258,8 +258,9 @@
|
||||
#define L2CAP_BLE_EXTFEA_MASK 0
|
||||
#endif
|
||||
|
||||
/* Define a value that tells L2CAP to use the default HCI ACL buffer pool */
|
||||
#define L2CAP_DEFAULT_ERM_POOL_ID 0xFF
|
||||
/* Define a value that tells L2CAP to use the default HCI ACL buffer size */
|
||||
#define L2CAP_INVALID_ERM_BUF_SIZE 0
|
||||
|
||||
/* Define a value that tells L2CAP to use the default MPS */
|
||||
#define L2CAP_DEFAULT_ERM_MPS 0x0000
|
||||
|
||||
@ -273,7 +274,8 @@
|
||||
/* To optimize this, it must be a multiplum of the L2CAP PDU length AND match the 3DH5 air
|
||||
* including the l2cap headers in each packet - to match the latter - the -5 is added
|
||||
*/
|
||||
#define L2CAP_MAX_SDU_LENGTH (GKI_BUF4_SIZE - (L2CAP_MIN_OFFSET + L2CAP_MAX_HEADER_FCS) -5)
|
||||
#define L2CAP_MAX_SDU_LENGTH (8080 + 26 - (L2CAP_MIN_OFFSET + 6))
|
||||
#define L2CAP_MAX_BUF_SIZE (10240 + 24)
|
||||
|
||||
/* Part of L2CAP_MIN_OFFSET that is not part of L2CAP
|
||||
*/
|
||||
|
@ -10,7 +10,7 @@ struct list_t;
|
||||
typedef struct list_t list_t;
|
||||
|
||||
typedef void (*list_free_cb)(void *data);
|
||||
typedef bool (*list_iter_cb)(void *data);
|
||||
typedef bool (*list_iter_cb)(void *data, void *context);
|
||||
|
||||
// Returns a new, empty list. Returns NULL if not enough memory could be allocated
|
||||
// for the list structure. The returned list must be freed with |list_free|. The
|
||||
@ -22,7 +22,6 @@ list_t *list_new(list_free_cb callback);
|
||||
|
||||
|
||||
list_node_t *list_free_node(list_t *list, list_node_t *node);
|
||||
//list_node_t *list_free_node(list_t *list, list_node_t *node);
|
||||
// Frees the list. This function accepts NULL as an argument, in which case it
|
||||
// behaves like a no-op.
|
||||
void list_free(list_t *list);
|
||||
@ -44,7 +43,8 @@ void *list_front(const list_t *list);
|
||||
|
||||
// Returns the last element in the list without removing it. |list| may not
|
||||
// be NULL or empty.
|
||||
//void *list_back(const list_t *list);
|
||||
void *list_back(const list_t *list);
|
||||
list_node_t *list_back_node(const list_t *list);
|
||||
|
||||
// Inserts |data| after |prev_node| in |list|. |data|, |list|, and |prev_node|
|
||||
// may not be NULL. This function does not make a copy of |data| so the pointer
|
||||
@ -84,7 +84,7 @@ void list_clear(list_t *list);
|
||||
// list inside the callback. If an element is added before the node being visited,
|
||||
// there will be no callback for the newly-inserted node. Neither |list| nor
|
||||
// |callback| may be NULL.
|
||||
void list_foreach(const list_t *list, list_iter_cb callback);
|
||||
list_node_t *list_foreach(const list_t *list, list_iter_cb callback, void *context);
|
||||
|
||||
// Returns an iterator to the first element in |list|. |list| may not be NULL.
|
||||
// The returned iterator is valid as long as it does not equal the value returned
|
||||
|
53
tools/sdk/include/bluedroid/mutex.h
Normal file
53
tools/sdk/include/bluedroid/mutex.h
Normal file
@ -0,0 +1,53 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2015 Google, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __MUTEX_H__
|
||||
#define __MUTEX_H__
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
||||
|
||||
#define OSI_MUTEX_MAX_TIMEOUT 0xffffffffUL
|
||||
|
||||
#define osi_mutex_valid( x ) ( ( ( *x ) == NULL) ? pdFALSE : pdTRUE )
|
||||
#define osi_mutex_set_invalid( x ) ( ( *x ) = NULL )
|
||||
|
||||
typedef xSemaphoreHandle osi_mutex_t;
|
||||
|
||||
int osi_mutex_new(osi_mutex_t *mutex);
|
||||
|
||||
int osi_mutex_lock(osi_mutex_t *mutex, uint32_t timeout);
|
||||
|
||||
void osi_mutex_unlock(osi_mutex_t *mutex);
|
||||
|
||||
void osi_mutex_free(osi_mutex_t *mutex);
|
||||
|
||||
/* Just for a global mutex */
|
||||
int osi_mutex_global_init(void);
|
||||
|
||||
void osi_mutex_global_deinit(void);
|
||||
|
||||
void osi_mutex_global_lock(void);
|
||||
|
||||
void osi_mutex_global_unlock(void);
|
||||
|
||||
#endif /* __MUTEX_H__ */
|
||||
|
@ -6,21 +6,11 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#define UNUSED_ATTR __attribute__((unused))
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#define INVALID_FD (-1)
|
||||
|
||||
#define CONCAT(a, b) a##b
|
||||
#define COMPILE_ASSERT(x)
|
||||
|
||||
// Use during compile time to check conditional values
|
||||
// NOTE: The the failures will present as a generic error
|
||||
// "error: initialization makes pointer from integer without a cast"
|
||||
// but the file and line number will present the condition that
|
||||
// failed.
|
||||
#define DUMMY_COUNTER(c) CONCAT(__osi_dummy_, c)
|
||||
#define DUMMY_PTR DUMMY_COUNTER(__COUNTER__)
|
||||
|
||||
#define COMPILE_ASSERT(x) char * DUMMY_PTR = !(x)
|
||||
|
||||
typedef uint32_t timeout_t;
|
||||
int osi_init(void);
|
||||
void osi_deinit(void);
|
||||
|
||||
#endif /*_OSI_H_*/
|
||||
|
@ -1,45 +0,0 @@
|
||||
#ifndef __os_ARCH_H__
|
||||
#define __os_ARCH_H__
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
||||
#define OSI_ARCH_TIMEOUT 0xffffffffUL
|
||||
|
||||
typedef xSemaphoreHandle osi_sem_t;
|
||||
typedef xSemaphoreHandle osi_mutex_t;
|
||||
|
||||
#define osi_mutex_valid( x ) ( ( ( *x ) == NULL) ? pdFALSE : pdTRUE )
|
||||
#define osi_mutex_set_invalid( x ) ( ( *x ) = NULL )
|
||||
#define osi_sem_valid( x ) ( ( ( *x ) == NULL) ? pdFALSE : pdTRUE )
|
||||
#define osi_sem_set_invalid( x ) ( ( *x ) = NULL )
|
||||
|
||||
int osi_mutex_new(osi_mutex_t *pxMutex);
|
||||
|
||||
void osi_mutex_lock(osi_mutex_t *pxMutex);
|
||||
|
||||
int osi_mutex_trylock(osi_mutex_t *pxMutex);
|
||||
|
||||
void osi_mutex_unlock(osi_mutex_t *pxMutex);
|
||||
|
||||
void osi_mutex_free(osi_mutex_t *pxMutex);
|
||||
|
||||
int osi_sem_new(osi_sem_t *sem, uint32_t max_count, uint32_t init_count);
|
||||
|
||||
void osi_sem_signal(osi_sem_t *sem);
|
||||
|
||||
uint32_t osi_sem_wait(osi_sem_t *sem, uint32_t timeout);
|
||||
|
||||
void osi_sem_free(osi_sem_t *sem);
|
||||
|
||||
void osi_arch_init(void);
|
||||
|
||||
uint32_t osi_now(void);
|
||||
|
||||
void osi_delay_ms(uint32_t ms);
|
||||
|
||||
|
||||
#endif /* __os_ARCH_H__ */
|
||||
|
@ -25,7 +25,6 @@
|
||||
#ifndef PORTEXT_H
|
||||
#define PORTEXT_H
|
||||
|
||||
#include "gki.h"
|
||||
|
||||
/* Port emulation entity Entry Points */
|
||||
extern void rfcomm_process_timeout (TIMER_LIST_ENT *p_tle);
|
||||
|
@ -26,7 +26,6 @@
|
||||
#define PORT_INT_H
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "gki.h"
|
||||
#include "rfcdefs.h"
|
||||
#include "port_api.h"
|
||||
|
||||
@ -52,7 +51,7 @@
|
||||
** Define Port Data Transfere control block
|
||||
*/
|
||||
typedef struct {
|
||||
BUFFER_Q queue; /* Queue of buffers waiting to be sent */
|
||||
fixed_queue_t *queue; /* Queue of buffers waiting to be sent */
|
||||
BOOLEAN peer_fc; /* TRUE if flow control is set based on peer's request */
|
||||
BOOLEAN user_fc; /* TRUE if flow control is set based on user's request */
|
||||
UINT32 queue_size; /* Number of data bytes in the queue */
|
||||
@ -88,7 +87,7 @@ typedef struct {
|
||||
*/
|
||||
typedef struct {
|
||||
TIMER_LIST_ENT tle; /* Timer list entry */
|
||||
BUFFER_Q cmd_q; /* Queue for command messages on this mux */
|
||||
fixed_queue_t *cmd_q; /* Queue for command messages on this mux */
|
||||
UINT8 port_inx[RFCOMM_MAX_DLCI + 1]; /* Array for quick access to */
|
||||
/* tPORT based on dlci */
|
||||
BD_ADDR bd_addr; /* BD ADDR of the peer if initiator */
|
||||
|
@ -26,6 +26,7 @@
|
||||
#define SDP_INT_H
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "bt_defs.h"
|
||||
#include "sdp_api.h"
|
||||
#include "l2c_api.h"
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-2012 Broadcom Corporation
|
||||
* Copyright (C) 2015 Google, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -16,19 +16,28 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef _GKI_INT_H_
|
||||
#define _GKI_INT_H_
|
||||
#ifndef __SEMAPHORE_H__
|
||||
#define __SEMAPHORE_H__
|
||||
|
||||
//#include <pthread.h>
|
||||
#include "bt_defs.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
||||
#include "gki_common.h"
|
||||
#define OSI_SEM_MAX_TIMEOUT 0xffffffffUL
|
||||
|
||||
typedef struct {
|
||||
pthread_mutex_t lock;
|
||||
tGKI_COM_CB com;
|
||||
} tGKI_CB;
|
||||
typedef xSemaphoreHandle osi_sem_t;
|
||||
|
||||
extern tGKI_CB gki_cb;
|
||||
#define osi_sem_valid( x ) ( ( ( *x ) == NULL) ? pdFALSE : pdTRUE )
|
||||
#define osi_sem_set_invalid( x ) ( ( *x ) = NULL )
|
||||
|
||||
#endif /*_GKI_INT_H_*/
|
||||
int osi_sem_new(osi_sem_t *sem, uint32_t max_count, uint32_t init_count);
|
||||
|
||||
void osi_sem_free(osi_sem_t *sem);
|
||||
|
||||
int osi_sem_take(osi_sem_t *sem, uint32_t timeout);
|
||||
|
||||
void osi_sem_give(osi_sem_t *sem);
|
||||
|
||||
|
||||
#endif /* __SEMAPHORE_H__ */
|
@ -35,12 +35,27 @@ typedef struct bt_task_evt BtTaskEvt_t;
|
||||
|
||||
typedef bt_status_t (* BtTaskCb_t)(void *arg);
|
||||
|
||||
enum {
|
||||
SIG_PRF_START_UP = 0xfc,
|
||||
SIG_PRF_WORK = 0xfd,
|
||||
SIG_BTU_START_UP = 0xfe,
|
||||
SIG_BTU_WORK = 0xff,
|
||||
};
|
||||
typedef enum {
|
||||
SIG_HCI_HAL_RECV_PACKET = 0,
|
||||
SIG_HCI_HAL_NUM,
|
||||
} SIG_HCI_HAL_t;
|
||||
|
||||
|
||||
typedef enum {
|
||||
SIG_HCI_HOST_SEND_AVAILABLE = 0,
|
||||
SIG_HCI_HOST_NUM,
|
||||
} SIG_HCI_HOST_t;
|
||||
|
||||
typedef enum {
|
||||
SIG_BTU_START_UP = 0,
|
||||
SIG_BTU_HCI_MSG,
|
||||
SIG_BTU_BTA_MSG,
|
||||
SIG_BTU_BTA_ALARM,
|
||||
SIG_BTU_GENERAL_ALARM,
|
||||
SIG_BTU_ONESHOT_ALARM,
|
||||
SIG_BTU_L2CAP_ALARM,
|
||||
SIG_BTU_NUM,
|
||||
} SIG_BTU_t;
|
||||
|
||||
#define HCI_HOST_TASK_STACK_SIZE (2048 + BT_TASK_EXTRA_STACK_SIZE)
|
||||
#define HCI_HOST_TASK_PRIO (configMAX_PRIORITIES - 3)
|
||||
@ -67,9 +82,13 @@ enum {
|
||||
#define TASK_POST_BLOCKING (portMAX_DELAY)
|
||||
typedef uint32_t task_post_t; /* Timeout of task post return, unit TICK */
|
||||
|
||||
void btu_task_post(uint32_t sig, task_post_t timeout);
|
||||
void hci_host_task_post(task_post_t timeout);
|
||||
void hci_hal_h4_task_post(task_post_t timeout);
|
||||
typedef enum {
|
||||
TASK_POST_SUCCESS = 0,
|
||||
TASK_POST_FAIL,
|
||||
} task_post_status_t;
|
||||
|
||||
task_post_status_t btu_task_post(uint32_t sig, void *param, task_post_t timeout);
|
||||
task_post_status_t hci_host_task_post(task_post_t timeout);
|
||||
task_post_status_t hci_hal_h4_task_post(task_post_t timeout);
|
||||
|
||||
#endif /* __THREAD_H__ */
|
||||
|
@ -105,7 +105,7 @@ extern UINT8 utl_itoa(UINT16 i, char *p_s);
|
||||
**
|
||||
** Function utl_freebuf
|
||||
**
|
||||
** Description This function calls GKI_freebuf to free the buffer passed
|
||||
** Description This function calls osi_free to free the buffer passed
|
||||
** in, if buffer pointer is not NULL, and also initializes
|
||||
** buffer pointer to NULL.
|
||||
**
|
||||
|
@ -48,6 +48,16 @@ void esp_efuse_burn_new_values(void);
|
||||
*/
|
||||
void esp_efuse_reset(void);
|
||||
|
||||
/* @brief Disable BASIC ROM Console via efuse
|
||||
*
|
||||
* By default, if booting from flash fails the ESP32 will boot a
|
||||
* BASIC console in ROM.
|
||||
*
|
||||
* Call this function (from bootloader or app) to permanently
|
||||
* disable the console on this chip.
|
||||
*/
|
||||
void esp_efuse_disable_basic_rom_console(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -6,45 +6,60 @@
|
||||
*/
|
||||
#define CONFIG_GATTC_ENABLE 1
|
||||
#define CONFIG_ESP32_PHY_MAX_TX_POWER 20
|
||||
#define CONFIG_PHY_ENABLED 1
|
||||
#define CONFIG_TRACEMEM_RESERVE_DRAM 0x0
|
||||
#define CONFIG_FREERTOS_MAX_TASK_NAME_LEN 16
|
||||
#define CONFIG_BLE_SMP_ENABLE 1
|
||||
#define CONFIG_TCP_RECVMBOX_SIZE 6
|
||||
#define CONFIG_TCP_WND_DEFAULT 5744
|
||||
#define CONFIG_SW_COEXIST_ENABLE 1
|
||||
#define CONFIG_SPIFFS_USE_MAGIC_LENGTH 1
|
||||
#define CONFIG_ESPTOOLPY_FLASHSIZE_4MB 1
|
||||
#define CONFIG_IPC_TASK_STACK_SIZE 1024
|
||||
#define CONFIG_ESPTOOLPY_FLASHFREQ "40m"
|
||||
#define CONFIG_NEWLIB_STDOUT_ADDCR 1
|
||||
#define CONFIG_MBEDTLS_KEY_EXCHANGE_RSA 1
|
||||
#define CONFIG_UDP_RECVMBOX_SIZE 6
|
||||
#define CONFIG_TASK_WDT_CHECK_IDLE_TASK 1
|
||||
#define CONFIG_MBEDTLS_AES_C 1
|
||||
#define CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED 1
|
||||
#define CONFIG_MBEDTLS_GCM_C 1
|
||||
#define CONFIG_ESPTOOLPY_FLASHSIZE "4MB"
|
||||
#define CONFIG_SPIFFS_CACHE_WR 1
|
||||
#define CONFIG_BROWNOUT_DET_LVL_SEL_0 1
|
||||
#define CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER 1
|
||||
#define CONFIG_ETHERNET 1
|
||||
#define CONFIG_EMAC_L2_TO_L3_RX_BUF_MODE 1
|
||||
#define CONFIG_SPIFFS_CACHE 1
|
||||
#define CONFIG_INT_WDT 1
|
||||
#define CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL 1
|
||||
#define CONFIG_MBEDTLS_SSL_PROTO_TLS1 1
|
||||
#define CONFIG_MBEDTLS_ECDSA_C 1
|
||||
#define CONFIG_ESPTOOLPY_FLASHFREQ_40M 1
|
||||
#define CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS 1
|
||||
#define CONFIG_MBEDTLS_ECDH_C 1
|
||||
#define CONFIG_MBEDTLS_KEY_EXCHANGE_ELLIPTIC_CURVE 1
|
||||
#define CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM 10
|
||||
#define CONFIG_MBEDTLS_SSL_ALPN 1
|
||||
#define CONFIG_MBEDTLS_PEM_WRITE_C 1
|
||||
#define CONFIG_BT_RESERVE_DRAM 0x10000
|
||||
#define CONFIG_IP_LOST_TIMER_INTERVAL 120
|
||||
#define CONFIG_ESP32_PANIC_PRINT_REBOOT 1
|
||||
#define CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED 1
|
||||
#define CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED 1
|
||||
#define CONFIG_CONSOLE_UART_BAUDRATE 115200
|
||||
#define CONFIG_LWIP_MAX_SOCKETS 10
|
||||
#define CONFIG_EMAC_TASK_PRIORITY 20
|
||||
#define CONFIG_TIMER_TASK_STACK_DEPTH 2048
|
||||
#define CONFIG_TCP_MSS 1436
|
||||
#define CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED 1
|
||||
#define CONFIG_FATFS_CODEPAGE 850
|
||||
#define CONFIG_ULP_COPROC_RESERVE_MEM 512
|
||||
#define CONFIG_ESPTOOLPY_BAUD 921600
|
||||
#define CONFIG_INT_WDT_CHECK_CPU1 1
|
||||
#define CONFIG_FLASHMODE_DIO 1
|
||||
#define CONFIG_ESPTOOLPY_AFTER_RESET 1
|
||||
#define CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED 1
|
||||
#define CONFIG_TOOLPREFIX "xtensa-esp32-elf-"
|
||||
#define CONFIG_MBEDTLS_ECP_C 1
|
||||
#define CONFIG_FREERTOS_IDLE_TASK_STACKSIZE 1024
|
||||
#define CONFIG_MBEDTLS_RC4_DISABLED 1
|
||||
#define CONFIG_FATFS_LFN_STACK 1
|
||||
#define CONFIG_ESP32_WIFI_AMPDU_ENABLED 1
|
||||
#define CONFIG_CONSOLE_UART_NUM 0
|
||||
@ -59,44 +74,69 @@
|
||||
#define CONFIG_ESPTOOLPY_FLASHSIZE_DETECT 1
|
||||
#define CONFIG_AUTOSTART_ARDUINO 1
|
||||
#define CONFIG_LOG_DEFAULT_LEVEL_ERROR 1
|
||||
#define CONFIG_TIMER_TASK_STACK_SIZE 4096
|
||||
#define CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE 1
|
||||
#define CONFIG_BTDM_CONTROLLER_RUN_CPU 0
|
||||
#define CONFIG_MBEDTLS_X509_CRL_PARSE_C 1
|
||||
#define CONFIG_SPIFFS_USE_MAGIC 1
|
||||
#define CONFIG_TCPIP_TASK_STACK_SIZE 2560
|
||||
#define CONFIG_FATFS_CODEPAGE_850 1
|
||||
#define CONFIG_TASK_WDT 1
|
||||
#define CONFIG_MAIN_TASK_STACK_SIZE 4096
|
||||
#define CONFIG_SPIFFS_PAGE_CHECK 1
|
||||
#define CONFIG_TASK_WDT_TIMEOUT_S 5
|
||||
#define CONFIG_INT_WDT_TIMEOUT_MS 300
|
||||
#define CONFIG_ESPTOOLPY_FLASHMODE "dio"
|
||||
#define CONFIG_BTC_TASK_STACK_SIZE 8192
|
||||
#define CONFIG_BLUEDROID_ENABLED 1
|
||||
#define CONFIG_NEWLIB_STDIN_LINE_ENDING_CR 1
|
||||
#define CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA 1
|
||||
#define CONFIG_ESPTOOLPY_BEFORE "default_reset"
|
||||
#define CONFIG_LOG_DEFAULT_LEVEL 1
|
||||
#define CONFIG_TIMER_QUEUE_LENGTH 10
|
||||
#define CONFIG_MAKE_WARN_UNDEFINED_VARIABLES 1
|
||||
#define CONFIG_BOOTLOADER_SPI_WP_PIN 7
|
||||
#define CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM 0
|
||||
#define CONFIG_MBEDTLS_CCM_C 1
|
||||
#define CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER 20
|
||||
#define CONFIG_ESP32_RTC_CLK_CAL_CYCLES 1024
|
||||
#define CONFIG_ESP32_WIFI_TX_BA_WIN 6
|
||||
#define CONFIG_ESP32_WIFI_NVS_ENABLED 1
|
||||
#define CONFIG_ULP_COPROC_ENABLED 1
|
||||
#define CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED 1
|
||||
#define CONFIG_DMA_RX_BUF_NUM 10
|
||||
#define CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED 1
|
||||
#define CONFIG_TCP_SYNMAXRTX 6
|
||||
#define CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA 1
|
||||
#define CONFIG_HEAP_POISONING_LIGHT 1
|
||||
#define CONFIG_PYTHON "python"
|
||||
#define CONFIG_MBEDTLS_ECP_NIST_OPTIM 1
|
||||
#define CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1 1
|
||||
#define CONFIG_ESPTOOLPY_COMPRESSED 1
|
||||
#define CONFIG_PARTITION_TABLE_FILENAME "partitions_singleapp.csv"
|
||||
#define CONFIG_TCP_SND_BUF_DEFAULT 5744
|
||||
#define CONFIG_LWIP_DHCP_MAX_NTP_SERVERS 1
|
||||
#define CONFIG_TCP_MSL 60000
|
||||
#define CONFIG_MBEDTLS_SSL_PROTO_TLS1_1 1
|
||||
#define CONFIG_PARTITION_TABLE_SINGLE_APP 1
|
||||
#define CONFIG_ESP32_WIFI_RX_BA_WIN 6
|
||||
#define CONFIG_WIFI_ENABLED 1
|
||||
#define CONFIG_MBEDTLS_X509_CSR_PARSE_C 1
|
||||
#define CONFIG_FLASHMODE_QIO 1
|
||||
#define CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA 1
|
||||
#define CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE 2048
|
||||
#define CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY 2000
|
||||
#define CONFIG_BROWNOUT_DET_LVL 0
|
||||
#define CONFIG_MBEDTLS_PEM_PARSE_C 1
|
||||
#define CONFIG_SPIFFS_GC_MAX_RUNS 10
|
||||
#define CONFIG_ESP32_APPTRACE_DEST_NONE 1
|
||||
#define CONFIG_PARTITION_TABLE_CUSTOM_APP_BIN_OFFSET 0x10000
|
||||
#define CONFIG_MBEDTLS_SSL_PROTO_TLS1_2 1
|
||||
#define CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA 1
|
||||
#define CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM 32
|
||||
#define CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED 1
|
||||
#define CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED 1
|
||||
#define CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ 240
|
||||
#define CONFIG_MBEDTLS_HARDWARE_AES 1
|
||||
#define CONFIG_FREERTOS_HZ 1000
|
||||
#define CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE 1
|
||||
#define CONFIG_FREERTOS_ASSERT_FAIL_ABORT 1
|
||||
@ -104,10 +144,16 @@
|
||||
#define CONFIG_ESP32_XTAL_FREQ 0
|
||||
#define CONFIG_MONITOR_BAUD_115200B 1
|
||||
#define CONFIG_LOG_BOOTLOADER_LEVEL 0
|
||||
#define CONFIG_MBEDTLS_TLS_ENABLED 1
|
||||
#define CONFIG_SMP_ENABLE 1
|
||||
#define CONFIG_MBEDTLS_SSL_SESSION_TICKETS 1
|
||||
#define CONFIG_SPIFFS_MAX_PARTITIONS 3
|
||||
#define CONFIG_MBEDTLS_SSL_RENEGOTIATION 1
|
||||
#define CONFIG_ESPTOOLPY_BEFORE_RESET 1
|
||||
#define CONFIG_ESPTOOLPY_BAUD_OTHER_VAL 115200
|
||||
#define CONFIG_ENABLE_ARDUINO_DEPENDS 1
|
||||
#define CONFIG_SPIFFS_OBJ_NAME_LEN 32
|
||||
#define CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT 5
|
||||
#define CONFIG_LOG_BOOTLOADER_LEVEL_NONE 1
|
||||
#define CONFIG_ESP32_DEFAULT_CPU_FREQ_240 1
|
||||
#define CONFIG_ESP32_XTAL_FREQ_AUTO 1
|
||||
@ -115,9 +161,12 @@
|
||||
#define CONFIG_ESPTOOLPY_AFTER "hard_reset"
|
||||
#define CONFIG_LWIP_SO_REUSE 1
|
||||
#define CONFIG_DMA_TX_BUF_NUM 10
|
||||
#define CONFIG_FREERTOS_INTERRUPT_BACKTRACE 1
|
||||
#define CONFIG_WL_SECTOR_SIZE 4096
|
||||
#define CONFIG_TIMER_TASK_PRIORITY 1
|
||||
#define CONFIG_MBEDTLS_TLS_CLIENT 1
|
||||
#define CONFIG_BT_ENABLED 1
|
||||
#define CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED 1
|
||||
#define CONFIG_MONITOR_BAUD 115200
|
||||
#define CONFIG_FREERTOS_CORETIMER_0 1
|
||||
#define CONFIG_PARTITION_TABLE_CUSTOM_FILENAME "partitions.csv"
|
||||
@ -125,12 +174,17 @@
|
||||
#define CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY 1
|
||||
#define CONFIG_TCP_QUEUE_OOSEQ 1
|
||||
#define CONFIG_GATTS_ENABLE 1
|
||||
#define CONFIG_MBEDTLS_TLS_SERVER 1
|
||||
#define CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT 1
|
||||
#define CONFIG_FREERTOS_ISR_STACKSIZE 1536
|
||||
#define CONFIG_CLASSIC_BT_ENABLED 1
|
||||
#define CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK 1
|
||||
#define CONFIG_OPENSSL_ASSERT_DO_NOTHING 1
|
||||
#define CONFIG_WL_SECTOR_SIZE_4096 1
|
||||
#define CONFIG_OPTIMIZATION_LEVEL_DEBUG 1
|
||||
#define CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED 1
|
||||
#define CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED 1
|
||||
#define CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA 1
|
||||
#define CONFIG_SYSTEM_EVENT_QUEUE_SIZE 32
|
||||
#define CONFIG_BT_ACL_CONNECTIONS 4
|
||||
#define CONFIG_FATFS_MAX_LFN 255
|
||||
@ -139,7 +193,10 @@
|
||||
#define CONFIG_APP_OFFSET 0x10000
|
||||
#define CONFIG_MEMMAP_SMP 1
|
||||
#define CONFIG_SPI_FLASH_ROM_DRIVER_PATCH 1
|
||||
#define CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED 1
|
||||
#define CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT 2048
|
||||
#define CONFIG_LWIP_SO_RCVBUF 1
|
||||
#define CONFIG_MONITOR_BAUD_OTHER_VAL 115200
|
||||
#define CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF 1
|
||||
#define CONFIG_ESPTOOLPY_PORT "/dev/cu.usbserial-DO00EAB0"
|
||||
#define CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_ERROR 1
|
||||
|
306
tools/sdk/include/console/argtable3/argtable3.h
Normal file
306
tools/sdk/include/console/argtable3/argtable3.h
Normal file
@ -0,0 +1,306 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the argtable3 library.
|
||||
*
|
||||
* Copyright (C) 1998-2001,2003-2011,2013 Stewart Heitmann
|
||||
* <sheitmann@users.sourceforge.net>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the name of STEWART HEITMANN nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 STEWART HEITMANN 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.
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef ARGTABLE3
|
||||
#define ARGTABLE3
|
||||
|
||||
#include <stdio.h> /* FILE */
|
||||
#include <time.h> /* struct tm */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ARG_REX_ICASE 1
|
||||
|
||||
/* bit masks for arg_hdr.flag */
|
||||
enum
|
||||
{
|
||||
ARG_TERMINATOR=0x1,
|
||||
ARG_HASVALUE=0x2,
|
||||
ARG_HASOPTVALUE=0x4
|
||||
};
|
||||
|
||||
typedef void (arg_resetfn)(void *parent);
|
||||
typedef int (arg_scanfn)(void *parent, const char *argval);
|
||||
typedef int (arg_checkfn)(void *parent);
|
||||
typedef void (arg_errorfn)(void *parent, FILE *fp, int error, const char *argval, const char *progname);
|
||||
|
||||
|
||||
/*
|
||||
* The arg_hdr struct defines properties that are common to all arg_xxx structs.
|
||||
* The argtable library requires each arg_xxx struct to have an arg_hdr
|
||||
* struct as its first data member.
|
||||
* The argtable library functions then use this data to identify the
|
||||
* properties of the command line option, such as its option tags,
|
||||
* datatype string, and glossary strings, and so on.
|
||||
* Moreover, the arg_hdr struct contains pointers to custom functions that
|
||||
* are provided by each arg_xxx struct which perform the tasks of parsing
|
||||
* that particular arg_xxx arguments, performing post-parse checks, and
|
||||
* reporting errors.
|
||||
* These functions are private to the individual arg_xxx source code
|
||||
* and are the pointer to them are initiliased by that arg_xxx struct's
|
||||
* constructor function. The user could alter them after construction
|
||||
* if desired, but the original intention is for them to be set by the
|
||||
* constructor and left unaltered.
|
||||
*/
|
||||
struct arg_hdr
|
||||
{
|
||||
char flag; /* Modifier flags: ARG_TERMINATOR, ARG_HASVALUE. */
|
||||
const char *shortopts; /* String defining the short options */
|
||||
const char *longopts; /* String defiing the long options */
|
||||
const char *datatype; /* Description of the argument data type */
|
||||
const char *glossary; /* Description of the option as shown by arg_print_glossary function */
|
||||
int mincount; /* Minimum number of occurences of this option accepted */
|
||||
int maxcount; /* Maximum number of occurences if this option accepted */
|
||||
void *parent; /* Pointer to parent arg_xxx struct */
|
||||
arg_resetfn *resetfn; /* Pointer to parent arg_xxx reset function */
|
||||
arg_scanfn *scanfn; /* Pointer to parent arg_xxx scan function */
|
||||
arg_checkfn *checkfn; /* Pointer to parent arg_xxx check function */
|
||||
arg_errorfn *errorfn; /* Pointer to parent arg_xxx error function */
|
||||
void *priv; /* Pointer to private header data for use by arg_xxx functions */
|
||||
};
|
||||
|
||||
struct arg_rem
|
||||
{
|
||||
struct arg_hdr hdr; /* The mandatory argtable header struct */
|
||||
};
|
||||
|
||||
struct arg_lit
|
||||
{
|
||||
struct arg_hdr hdr; /* The mandatory argtable header struct */
|
||||
int count; /* Number of matching command line args */
|
||||
};
|
||||
|
||||
struct arg_int
|
||||
{
|
||||
struct arg_hdr hdr; /* The mandatory argtable header struct */
|
||||
int count; /* Number of matching command line args */
|
||||
int *ival; /* Array of parsed argument values */
|
||||
};
|
||||
|
||||
struct arg_dbl
|
||||
{
|
||||
struct arg_hdr hdr; /* The mandatory argtable header struct */
|
||||
int count; /* Number of matching command line args */
|
||||
double *dval; /* Array of parsed argument values */
|
||||
};
|
||||
|
||||
struct arg_str
|
||||
{
|
||||
struct arg_hdr hdr; /* The mandatory argtable header struct */
|
||||
int count; /* Number of matching command line args */
|
||||
const char **sval; /* Array of parsed argument values */
|
||||
};
|
||||
|
||||
struct arg_rex
|
||||
{
|
||||
struct arg_hdr hdr; /* The mandatory argtable header struct */
|
||||
int count; /* Number of matching command line args */
|
||||
const char **sval; /* Array of parsed argument values */
|
||||
};
|
||||
|
||||
struct arg_file
|
||||
{
|
||||
struct arg_hdr hdr; /* The mandatory argtable header struct */
|
||||
int count; /* Number of matching command line args*/
|
||||
const char **filename; /* Array of parsed filenames (eg: /home/foo.bar) */
|
||||
const char **basename; /* Array of parsed basenames (eg: foo.bar) */
|
||||
const char **extension; /* Array of parsed extensions (eg: .bar) */
|
||||
};
|
||||
|
||||
struct arg_date
|
||||
{
|
||||
struct arg_hdr hdr; /* The mandatory argtable header struct */
|
||||
const char *format; /* strptime format string used to parse the date */
|
||||
int count; /* Number of matching command line args */
|
||||
struct tm *tmval; /* Array of parsed time values */
|
||||
};
|
||||
|
||||
enum {ARG_ELIMIT=1, ARG_EMALLOC, ARG_ENOMATCH, ARG_ELONGOPT, ARG_EMISSARG};
|
||||
struct arg_end
|
||||
{
|
||||
struct arg_hdr hdr; /* The mandatory argtable header struct */
|
||||
int count; /* Number of errors encountered */
|
||||
int *error; /* Array of error codes */
|
||||
void **parent; /* Array of pointers to offending arg_xxx struct */
|
||||
const char **argval; /* Array of pointers to offending argv[] string */
|
||||
};
|
||||
|
||||
|
||||
/**** arg_xxx constructor functions *********************************/
|
||||
|
||||
struct arg_rem* arg_rem(const char* datatype, const char* glossary);
|
||||
|
||||
struct arg_lit* arg_lit0(const char* shortopts,
|
||||
const char* longopts,
|
||||
const char* glossary);
|
||||
struct arg_lit* arg_lit1(const char* shortopts,
|
||||
const char* longopts,
|
||||
const char *glossary);
|
||||
struct arg_lit* arg_litn(const char* shortopts,
|
||||
const char* longopts,
|
||||
int mincount,
|
||||
int maxcount,
|
||||
const char *glossary);
|
||||
|
||||
struct arg_key* arg_key0(const char* keyword,
|
||||
int flags,
|
||||
const char* glossary);
|
||||
struct arg_key* arg_key1(const char* keyword,
|
||||
int flags,
|
||||
const char* glossary);
|
||||
struct arg_key* arg_keyn(const char* keyword,
|
||||
int flags,
|
||||
int mincount,
|
||||
int maxcount,
|
||||
const char* glossary);
|
||||
|
||||
struct arg_int* arg_int0(const char* shortopts,
|
||||
const char* longopts,
|
||||
const char* datatype,
|
||||
const char* glossary);
|
||||
struct arg_int* arg_int1(const char* shortopts,
|
||||
const char* longopts,
|
||||
const char* datatype,
|
||||
const char *glossary);
|
||||
struct arg_int* arg_intn(const char* shortopts,
|
||||
const char* longopts,
|
||||
const char *datatype,
|
||||
int mincount,
|
||||
int maxcount,
|
||||
const char *glossary);
|
||||
|
||||
struct arg_dbl* arg_dbl0(const char* shortopts,
|
||||
const char* longopts,
|
||||
const char* datatype,
|
||||
const char* glossary);
|
||||
struct arg_dbl* arg_dbl1(const char* shortopts,
|
||||
const char* longopts,
|
||||
const char* datatype,
|
||||
const char *glossary);
|
||||
struct arg_dbl* arg_dbln(const char* shortopts,
|
||||
const char* longopts,
|
||||
const char *datatype,
|
||||
int mincount,
|
||||
int maxcount,
|
||||
const char *glossary);
|
||||
|
||||
struct arg_str* arg_str0(const char* shortopts,
|
||||
const char* longopts,
|
||||
const char* datatype,
|
||||
const char* glossary);
|
||||
struct arg_str* arg_str1(const char* shortopts,
|
||||
const char* longopts,
|
||||
const char* datatype,
|
||||
const char *glossary);
|
||||
struct arg_str* arg_strn(const char* shortopts,
|
||||
const char* longopts,
|
||||
const char* datatype,
|
||||
int mincount,
|
||||
int maxcount,
|
||||
const char *glossary);
|
||||
|
||||
struct arg_rex* arg_rex0(const char* shortopts,
|
||||
const char* longopts,
|
||||
const char* pattern,
|
||||
const char* datatype,
|
||||
int flags,
|
||||
const char* glossary);
|
||||
struct arg_rex* arg_rex1(const char* shortopts,
|
||||
const char* longopts,
|
||||
const char* pattern,
|
||||
const char* datatype,
|
||||
int flags,
|
||||
const char *glossary);
|
||||
struct arg_rex* arg_rexn(const char* shortopts,
|
||||
const char* longopts,
|
||||
const char* pattern,
|
||||
const char* datatype,
|
||||
int mincount,
|
||||
int maxcount,
|
||||
int flags,
|
||||
const char *glossary);
|
||||
|
||||
struct arg_file* arg_file0(const char* shortopts,
|
||||
const char* longopts,
|
||||
const char* datatype,
|
||||
const char* glossary);
|
||||
struct arg_file* arg_file1(const char* shortopts,
|
||||
const char* longopts,
|
||||
const char* datatype,
|
||||
const char *glossary);
|
||||
struct arg_file* arg_filen(const char* shortopts,
|
||||
const char* longopts,
|
||||
const char* datatype,
|
||||
int mincount,
|
||||
int maxcount,
|
||||
const char *glossary);
|
||||
|
||||
struct arg_date* arg_date0(const char* shortopts,
|
||||
const char* longopts,
|
||||
const char* format,
|
||||
const char* datatype,
|
||||
const char* glossary);
|
||||
struct arg_date* arg_date1(const char* shortopts,
|
||||
const char* longopts,
|
||||
const char* format,
|
||||
const char* datatype,
|
||||
const char *glossary);
|
||||
struct arg_date* arg_daten(const char* shortopts,
|
||||
const char* longopts,
|
||||
const char* format,
|
||||
const char* datatype,
|
||||
int mincount,
|
||||
int maxcount,
|
||||
const char *glossary);
|
||||
|
||||
struct arg_end* arg_end(int maxerrors);
|
||||
|
||||
|
||||
/**** other functions *******************************************/
|
||||
int arg_nullcheck(void **argtable);
|
||||
int arg_parse(int argc, char **argv, void **argtable);
|
||||
void arg_print_option(FILE *fp, const char *shortopts, const char *longopts, const char *datatype, const char *suffix);
|
||||
void arg_print_syntax(FILE *fp, void **argtable, const char *suffix);
|
||||
void arg_print_syntaxv(FILE *fp, void **argtable, const char *suffix);
|
||||
void arg_print_glossary(FILE *fp, void **argtable, const char *format);
|
||||
void arg_print_glossary_gnu(FILE *fp, void **argtable);
|
||||
void arg_print_errors(FILE* fp, struct arg_end* end, const char* progname);
|
||||
void arg_freetable(void **argtable, size_t n);
|
||||
void arg_print_formatted(FILE *fp, const unsigned lmargin, const unsigned rmargin, const char *text);
|
||||
|
||||
/**** deprecated functions, for back-compatibility only ********/
|
||||
void arg_free(void **argtable);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
181
tools/sdk/include/console/esp_console.h
Normal file
181
tools/sdk/include/console/esp_console.h
Normal file
@ -0,0 +1,181 @@
|
||||
// Copyright 2016-2017 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
// Forward declaration. Definition in linenoise/linenoise.h.
|
||||
typedef struct linenoiseCompletions linenoiseCompletions;
|
||||
|
||||
/**
|
||||
* @brief Parameters for console initialization
|
||||
*/
|
||||
typedef struct {
|
||||
size_t max_cmdline_length; //!< length of command line buffer, in bytes
|
||||
size_t max_cmdline_args; //!< maximum number of command line arguments to parse
|
||||
int hint_color; //!< ASCII color code of hint text
|
||||
int hint_bold; //!< Set to 1 to print hint text in bold
|
||||
} esp_console_config_t;
|
||||
|
||||
/**
|
||||
* @brief initialize console module
|
||||
* Call this once before using other console module features
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_NO_MEM if out of memory
|
||||
* - ESP_ERR_INVALID_STATE if already initialized
|
||||
*/
|
||||
esp_err_t esp_console_init(const esp_console_config_t* config);
|
||||
|
||||
|
||||
/**
|
||||
* @brief de-initialize console module
|
||||
* Call this once when done using console module functions
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_STATE if not initialized yet
|
||||
*/
|
||||
esp_err_t esp_console_deinit();
|
||||
|
||||
|
||||
/**
|
||||
* @brief Console command main function
|
||||
* @param argc number of arguments
|
||||
* @param argv array with argc entries, each pointing to a zero-terminated string argument
|
||||
* @return console command return code, 0 indicates "success"
|
||||
*/
|
||||
typedef int (*esp_console_cmd_func_t)(int argc, char** argv);
|
||||
|
||||
/**
|
||||
* @brief Console command description
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* Command name. Must not be NULL, must not contain spaces.
|
||||
* The pointer must be valid until the call to esp_console_deinit.
|
||||
*/
|
||||
const char* command; //!< command name
|
||||
/**
|
||||
* Help text for the command, shown by help command.
|
||||
* If set, the pointer must be valid until the call to esp_console_deinit.
|
||||
* If not set, the command will not be listed in 'help' output.
|
||||
*/
|
||||
const char* help;
|
||||
/**
|
||||
* Hint text, usually lists possible arguments.
|
||||
* If set to NULL, and 'argtable' field is non-NULL, hint will be generated
|
||||
* automatically
|
||||
*/
|
||||
const char* hint;
|
||||
/**
|
||||
* Pointer to a function which implements the command.
|
||||
*/
|
||||
esp_console_cmd_func_t func;
|
||||
/**
|
||||
* Array or structure of pointers to arg_xxx structures, may be NULL.
|
||||
* Used to generate hint text if 'hint' is set to NULL.
|
||||
* Array/structure which this field points to must end with an arg_end.
|
||||
* Only used for the duration of esp_console_cmd_register call.
|
||||
*/
|
||||
void* argtable;
|
||||
} esp_console_cmd_t;
|
||||
|
||||
/**
|
||||
* @brief Register console command
|
||||
* @param cmd pointer to the command description; can point to a temporary value
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_NO_MEM if out of memory
|
||||
*/
|
||||
esp_err_t esp_console_cmd_register(const esp_console_cmd_t *cmd);
|
||||
|
||||
/**
|
||||
* @brief Run command line
|
||||
* @param cmdline command line (command name followed by a number of arguments)
|
||||
* @param[out] cmd_ret return code from the command (set if command was run)
|
||||
* @return
|
||||
* - ESP_OK, if command was run
|
||||
* - ESP_ERR_NOT_FOUND, if command with given name wasn't registered
|
||||
* - ESP_ERR_INVALID_STATE, if esp_console_init wasn't called
|
||||
*/
|
||||
esp_err_t esp_console_run(const char* cmdline, int* cmd_ret);
|
||||
|
||||
/**
|
||||
* @brief Split command line into arguments in place
|
||||
*
|
||||
* - This function finds whitespace-separated arguments in the given input line.
|
||||
*
|
||||
* 'abc def 1 20 .3' -> [ 'abc', 'def', '1', '20', '.3' ]
|
||||
*
|
||||
* - Argument which include spaces may be surrounded with quotes. In this case
|
||||
* spaces are preserved and quotes are stripped.
|
||||
*
|
||||
* 'abc "123 456" def' -> [ 'abc', '123 456', 'def' ]
|
||||
*
|
||||
* - Escape sequences may be used to produce backslash, double quote, and space:
|
||||
*
|
||||
* 'a\ b\\c\"' -> [ 'a b\c"' ]
|
||||
*
|
||||
* Pointers to at most argv_size - 1 arguments are returned in argv array.
|
||||
* The pointer after the last one (i.e. argv[argc]) is set to NULL.
|
||||
*
|
||||
* @param line pointer to buffer to parse; it is modified in place
|
||||
* @param argv array where the pointers to arguments are written
|
||||
* @param argv_size number of elements in argv_array (max. number of arguments)
|
||||
* @return number of arguments found (argc)
|
||||
*/
|
||||
size_t esp_console_split_argv(char *line, char **argv, size_t argv_size);
|
||||
|
||||
/**
|
||||
* @brief Callback which provides command completion for linenoise library
|
||||
*
|
||||
* When using linenoise for line editing, command completion support
|
||||
* can be enabled like this:
|
||||
*
|
||||
* linenoiseSetCompletionCallback(&esp_console_get_completion);
|
||||
*
|
||||
* @param buf the string typed by the user
|
||||
* @param lc linenoiseCompletions to be filled in
|
||||
*/
|
||||
void esp_console_get_completion(const char *buf, linenoiseCompletions *lc);
|
||||
|
||||
/**
|
||||
* @brief Callback which provides command hints for linenoise library
|
||||
*
|
||||
* When using linenoise for line editing, hints support can be enabled as
|
||||
* follows:
|
||||
*
|
||||
* linenoiseSetHintsCallback((linenoiseHintsCallback*) &esp_console_get_hint);
|
||||
*
|
||||
* The extra cast is needed because linenoiseHintsCallback is defined as
|
||||
* returning a char* instead of const char*.
|
||||
*
|
||||
* @param buf line typed by the user
|
||||
* @param[out] color ANSI color code to be used when displaying the hint
|
||||
* @param[out] bold set to 1 if hint has to be displayed in bold
|
||||
* @return string containing the hint text. This string is persistent and should
|
||||
* not be freed (i.e. linenoiseSetFreeHintsCallback should not be used).
|
||||
*/
|
||||
const char *esp_console_get_hint(const char *buf, int *color, int *bold);
|
||||
|
||||
/**
|
||||
* @brief Register a 'help' command
|
||||
* Default 'help' command prints the list of registered commands along with
|
||||
* hints and help strings.
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_STATE, if esp_console_init wasn't called
|
||||
*/
|
||||
esp_err_t esp_console_register_help_command();
|
76
tools/sdk/include/console/linenoise/linenoise.h
Normal file
76
tools/sdk/include/console/linenoise/linenoise.h
Normal file
@ -0,0 +1,76 @@
|
||||
/* linenoise.h -- VERSION 1.0
|
||||
*
|
||||
* Guerrilla line editing library against the idea that a line editing lib
|
||||
* needs to be 20,000 lines of C code.
|
||||
*
|
||||
* See linenoise.c for more information.
|
||||
*
|
||||
* ------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 2010-2014, Salvatore Sanfilippo <antirez at gmail dot com>
|
||||
* Copyright (c) 2010-2013, Pieter Noordhuis <pcnoordhuis at gmail dot com>
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 THE COPYRIGHT
|
||||
* HOLDER 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.
|
||||
*/
|
||||
|
||||
#ifndef __LINENOISE_H
|
||||
#define __LINENOISE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct linenoiseCompletions {
|
||||
size_t len;
|
||||
char **cvec;
|
||||
} linenoiseCompletions;
|
||||
|
||||
typedef void(linenoiseCompletionCallback)(const char *, linenoiseCompletions *);
|
||||
typedef char*(linenoiseHintsCallback)(const char *, int *color, int *bold);
|
||||
typedef void(linenoiseFreeHintsCallback)(void *);
|
||||
void linenoiseSetCompletionCallback(linenoiseCompletionCallback *);
|
||||
void linenoiseSetHintsCallback(linenoiseHintsCallback *);
|
||||
void linenoiseSetFreeHintsCallback(linenoiseFreeHintsCallback *);
|
||||
void linenoiseAddCompletion(linenoiseCompletions *, const char *);
|
||||
|
||||
int linenoiseProbe(void);
|
||||
char *linenoise(const char *prompt);
|
||||
void linenoiseFree(void *ptr);
|
||||
int linenoiseHistoryAdd(const char *line);
|
||||
int linenoiseHistorySetMaxLen(int len);
|
||||
int linenoiseHistorySave(const char *filename);
|
||||
int linenoiseHistoryLoad(const char *filename);
|
||||
void linenoiseHistoryFree();
|
||||
void linenoiseClearScreen(void);
|
||||
void linenoiseSetMultiLine(int ml);
|
||||
void linenoiseSetDumbMode(int set);
|
||||
void linenoisePrintKeyCodes(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __LINENOISE_H */
|
@ -21,6 +21,8 @@ extern "C" {
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "soc/adc_channel.h"
|
||||
|
||||
typedef enum {
|
||||
ADC_ATTEN_0db = 0, /*!<The input voltage of ADC will be reduced to about 1/1 */
|
||||
@ -48,6 +50,20 @@ typedef enum {
|
||||
ADC1_CHANNEL_MAX,
|
||||
} adc1_channel_t;
|
||||
|
||||
typedef enum {
|
||||
ADC2_CHANNEL_0 = 0, /*!< ADC2 channel 0 is GPIO4 */
|
||||
ADC2_CHANNEL_1, /*!< ADC2 channel 1 is GPIO0 */
|
||||
ADC2_CHANNEL_2, /*!< ADC2 channel 2 is GPIO2 */
|
||||
ADC2_CHANNEL_3, /*!< ADC2 channel 3 is GPIO15 */
|
||||
ADC2_CHANNEL_4, /*!< ADC2 channel 4 is GPIO13 */
|
||||
ADC2_CHANNEL_5, /*!< ADC2 channel 5 is GPIO12 */
|
||||
ADC2_CHANNEL_6, /*!< ADC2 channel 6 is GPIO14 */
|
||||
ADC2_CHANNEL_7, /*!< ADC2 channel 7 is GPIO27 */
|
||||
ADC2_CHANNEL_8, /*!< ADC2 channel 8 is GPIO25 */
|
||||
ADC2_CHANNEL_9, /*!< ADC2 channel 9 is GPIO26 */
|
||||
ADC2_CHANNEL_MAX,
|
||||
} adc2_channel_t;
|
||||
|
||||
/**
|
||||
* @brief Configure ADC1 capture width.
|
||||
*
|
||||
@ -66,7 +82,7 @@ esp_err_t adc1_config_width(adc_bits_width_t width_bit);
|
||||
*
|
||||
* @note This function also configures the input GPIO pin mux to
|
||||
* connect it to the ADC1 channel. It must be called before calling
|
||||
* adc1_get_voltage() for this channel.
|
||||
* adc1_get_raw() for this channel.
|
||||
*
|
||||
* The default ADC full-scale voltage is 1.1V. To read higher voltages (up to the pin maximum voltage,
|
||||
* usually 3.3V) requires setting >0dB signal attenuation for that ADC channel.
|
||||
@ -107,13 +123,22 @@ esp_err_t adc1_config_channel_atten(adc1_channel_t channel, adc_atten_t atten);
|
||||
* - -1: Parameter error
|
||||
* - Other: ADC1 channel reading.
|
||||
*/
|
||||
int adc1_get_voltage(adc1_channel_t channel);
|
||||
int adc1_get_raw(adc1_channel_t channel);
|
||||
|
||||
/** @cond */ //Doxygen command to hide deprecated function from API Reference
|
||||
/*
|
||||
* @deprecated This function returns an ADC1 reading but is deprecated due to
|
||||
* a misleading name and has been changed to directly call the new function.
|
||||
* Use the new function adc1_get_raw() instead
|
||||
*/
|
||||
int adc1_get_voltage(adc1_channel_t channel) __attribute__((deprecated));
|
||||
/** @endcond */
|
||||
|
||||
/**
|
||||
* @brief Configure ADC1 to be usable by the ULP
|
||||
*
|
||||
* This function reconfigures ADC1 to be controlled by the ULP.
|
||||
* Effect of this function can be reverted using adc1_get_voltage function.
|
||||
* Effect of this function can be reverted using adc1_get_raw function.
|
||||
*
|
||||
* Note that adc1_config_channel_atten, adc1_config_width functions need
|
||||
* to be called to configure ADC1 channels, before ADC1 is used by the ULP.
|
||||
@ -136,6 +161,22 @@ void adc1_ulp_enable();
|
||||
*/
|
||||
int hall_sensor_read();
|
||||
|
||||
/**
|
||||
* @brief Output ADC2 reference voltage to gpio 25 or 26 or 27
|
||||
*
|
||||
* This function utilizes the testing mux exclusive to ADC 2 to route the
|
||||
* reference voltage one of ADC2's channels. Supported gpios are gpios
|
||||
* 25, 26, and 27. This refernce voltage can be manually read from the pin
|
||||
* and used in the esp_adc_cal component.
|
||||
*
|
||||
* @param[in] gpio GPIO number (gpios 25,26,27 supported)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: v_ref successfully routed to selected gpio
|
||||
* - ESP_ERR_INVALID_ARG: Unsupported gpio
|
||||
*/
|
||||
esp_err_t adc2_vref_to_gpio(gpio_num_t gpio);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -21,6 +21,7 @@ extern "C" {
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
#include "soc/dac_channel.h"
|
||||
|
||||
typedef enum {
|
||||
DAC_CHANNEL_1 = 1, /*!< DAC channel 1 is GPIO25 */
|
||||
|
@ -162,7 +162,7 @@ typedef enum {
|
||||
GPIO_NUM_27 = 27, /*!< GPIO27, input and output */
|
||||
|
||||
GPIO_NUM_32 = 32, /*!< GPIO32, input and output */
|
||||
GPIO_NUM_33 = 33, /*!< GPIO32, input and output */
|
||||
GPIO_NUM_33 = 33, /*!< GPIO33, input and output */
|
||||
GPIO_NUM_34 = 34, /*!< GPIO34, input mode only */
|
||||
GPIO_NUM_35 = 35, /*!< GPIO35, input mode only */
|
||||
GPIO_NUM_36 = 36, /*!< GPIO36, input mode only */
|
||||
|
@ -44,6 +44,11 @@ typedef enum {
|
||||
PERIPH_SPI_MODULE,
|
||||
PERIPH_HSPI_MODULE,
|
||||
PERIPH_VSPI_MODULE,
|
||||
PERIPH_SPI_DMA_MODULE,
|
||||
PERIPH_SDMMC_MODULE,
|
||||
PERIPH_SDIO_SLAVE_MODULE,
|
||||
PERIPH_CAN_MODULE,
|
||||
PERIPH_EMAC_MODULE,
|
||||
} periph_module_t;
|
||||
|
||||
/**
|
||||
|
@ -677,11 +677,15 @@ esp_err_t rmt_write_items(rmt_channel_t channel, const rmt_item32_t* rmt_item, i
|
||||
*
|
||||
* @param channel RMT channel (0 - 7)
|
||||
*
|
||||
* @param wait_time Maximum time to wait for transmission to be complete
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK RMT Tx done successfully
|
||||
* - ESP_ERR_TIMEOUT Crossed the 'wait_time' given
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Driver not installed
|
||||
*/
|
||||
esp_err_t rmt_wait_tx_done(rmt_channel_t channel);
|
||||
esp_err_t rmt_wait_tx_done(rmt_channel_t channel, TickType_t wait_time);
|
||||
|
||||
/**
|
||||
* @brief Get ringbuffer from UART.
|
||||
@ -690,13 +694,13 @@ esp_err_t rmt_wait_tx_done(rmt_channel_t channel);
|
||||
*
|
||||
* @param channel RMT channel (0 - 7)
|
||||
*
|
||||
* @param buf_handler Pointer to buffer handler to accept RX ringbuffer handler.
|
||||
* @param buf_handle Pointer to buffer handler to accept RX ringbuffer handler.
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_OK Success
|
||||
*/
|
||||
esp_err_t rmt_get_ringbuf_handler(rmt_channel_t channel, RingbufHandle_t* buf_handler);
|
||||
esp_err_t rmt_get_ringbuf_handle(rmt_channel_t channel, RingbufHandle_t* buf_handle);
|
||||
|
||||
/***************************EXAMPLE**********************************
|
||||
*
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "soc/rtc_gpio_channel.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -294,23 +294,67 @@
|
||||
#define SCR_CMD_SUPPORT_CMD20(scr) MMC_RSP_BITS((scr), 32, 1)
|
||||
#define SCR_RESERVED2(scr) MMC_RSP_BITS((scr), 0, 32)
|
||||
|
||||
/* Status of Switch Function */
|
||||
#define SFUNC_STATUS_GROUP(status, group) \
|
||||
(__bitfield((uint32_t *)(status), 400 + (group - 1) * 16, 16))
|
||||
/* Max supply current in SWITCH_FUNC response (in mA) */
|
||||
#define SD_SFUNC_I_MAX(status) (MMC_RSP_BITS((uint32_t *)(status), 496, 16))
|
||||
|
||||
#define SD_ACCESS_MODE_SDR12 0
|
||||
#define SD_ACCESS_MODE_SDR25 1
|
||||
#define SD_ACCESS_MODE_SDR50 2
|
||||
#define SD_ACCESS_MODE_SDR104 3
|
||||
#define SD_ACCESS_MODE_DDR50 4
|
||||
/* Supported flags in SWITCH_FUNC response */
|
||||
#define SD_SFUNC_SUPPORTED(status, group) \
|
||||
(MMC_RSP_BITS((uint32_t *)(status), 400 + (group - 1) * 16, 16))
|
||||
|
||||
/* Selected function in SWITCH_FUNC response */
|
||||
#define SD_SFUNC_SELECTED(status, group) \
|
||||
(MMC_RSP_BITS((uint32_t *)(status), 376 + (group - 1) * 4, 4))
|
||||
|
||||
/* Busy flags in SWITCH_FUNC response */
|
||||
#define SD_SFUNC_BUSY(status, group) \
|
||||
(MMC_RSP_BITS((uint32_t *)(status), 272 + (group - 1) * 16, 16))
|
||||
|
||||
/* Version of SWITCH_FUNC response */
|
||||
#define SD_SFUNC_VER(status) (MMC_RSP_BITS((uint32_t *)(status), 368, 8))
|
||||
|
||||
#define SD_SFUNC_GROUP_MAX 6
|
||||
#define SD_SFUNC_FUNC_MAX 15
|
||||
|
||||
#define SD_ACCESS_MODE 1 /* Function group 1, Access Mode */
|
||||
|
||||
#define SD_ACCESS_MODE_SDR12 0 /* 25 MHz clock */
|
||||
#define SD_ACCESS_MODE_SDR25 1 /* 50 MHz clock */
|
||||
#define SD_ACCESS_MODE_SDR50 2 /* UHS-I, 100 MHz clock */
|
||||
#define SD_ACCESS_MODE_SDR104 3 /* UHS-I, 208 MHz clock */
|
||||
#define SD_ACCESS_MODE_DDR50 4 /* UHS-I, 50 MHz clock, DDR */
|
||||
|
||||
/**
|
||||
* @brief Extract up to 32 sequential bits from an array of 32-bit words
|
||||
*
|
||||
* Bits within the word are numbered in the increasing order from LSB to MSB.
|
||||
*
|
||||
* As an example, consider 2 32-bit words:
|
||||
*
|
||||
* 0x01234567 0x89abcdef
|
||||
*
|
||||
* On a little-endian system, the bytes are stored in memory as follows:
|
||||
*
|
||||
* 67 45 23 01 ef cd ab 89
|
||||
*
|
||||
* MMC_RSP_BITS will extact bits as follows:
|
||||
*
|
||||
* start=0 len=4 -> result=0x00000007
|
||||
* start=0 len=12 -> result=0x00000567
|
||||
* start=28 len=8 -> result=0x000000f0
|
||||
* start=59 len=5 -> result=0x00000011
|
||||
*
|
||||
* @param src array of words to extract bits from
|
||||
* @param start index of the first bit to extract
|
||||
* @param len number of bits to extract, 1 to 32
|
||||
* @return 32-bit word where requested bits start from LSB
|
||||
*/
|
||||
static inline uint32_t MMC_RSP_BITS(uint32_t *src, int start, int len)
|
||||
{
|
||||
uint32_t mask = (len % 32 == 0) ? UINT_MAX : UINT_MAX >> (32 - (len % 32));
|
||||
size_t word = 3 - start / 32;
|
||||
size_t word = start / 32;
|
||||
size_t shift = start % 32;
|
||||
uint32_t right = src[word] >> shift;
|
||||
uint32_t left = (len + shift <= 32) ? 0 : src[word - 1] << ((32 - shift) % 32);
|
||||
uint32_t left = (len + shift <= 32) ? 0 : src[word + 1] << ((32 - shift) % 32);
|
||||
return (left | right) & mask;
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,13 @@ typedef struct {
|
||||
*/
|
||||
typedef uint32_t sdmmc_response_t[4];
|
||||
|
||||
/**
|
||||
* SD SWITCH_FUNC response buffer
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t data[512 / 8 / sizeof(uint32_t)]; /*!< response data */
|
||||
} sdmmc_switch_func_rsp_t;
|
||||
|
||||
/**
|
||||
* SD/MMC command information
|
||||
*/
|
||||
|
@ -74,11 +74,30 @@ bool spicommon_periph_claim(spi_host_device_t host);
|
||||
/**
|
||||
* @brief Return the SPI peripheral so another driver can claim it.
|
||||
*
|
||||
* @param host Peripheral to claim
|
||||
* @param host Peripheral to return
|
||||
* @return True if peripheral is returned successfully; false if peripheral was free to claim already.
|
||||
*/
|
||||
bool spicommon_periph_free(spi_host_device_t host);
|
||||
|
||||
/**
|
||||
* @brief Try to claim a SPI DMA channel
|
||||
*
|
||||
* Call this if your driver wants to use SPI with a DMA channnel.
|
||||
*
|
||||
* @param dma_chan channel to claim
|
||||
*
|
||||
* @return True if success; false otherwise.
|
||||
*/
|
||||
bool spicommon_dma_chan_claim(int dma_chan);
|
||||
|
||||
/**
|
||||
* @brief Return the SPI DMA channel so other driver can claim it, or just to power down DMA.
|
||||
*
|
||||
* @param dma_chan channel to return
|
||||
*
|
||||
* @return True if success; false otherwise.
|
||||
*/
|
||||
bool spicommon_dma_chan_free(int dma_chan);
|
||||
|
||||
#define SPICOMMON_BUSFLAG_SLAVE 0 ///< Initialize I/O in slave mode
|
||||
#define SPICOMMON_BUSFLAG_MASTER (1<<0) ///< Initialize I/O in master mode
|
||||
@ -170,9 +189,6 @@ spi_dev_t *spicommon_hw_for_host(spi_host_device_t host);
|
||||
*/
|
||||
int spicommon_irqsource_for_host(spi_host_device_t host);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Callback, to be called when a DMA engine reset is completed
|
||||
*/
|
||||
|
@ -30,7 +30,7 @@ extern "C"
|
||||
|
||||
#define SPI_DEVICE_TXBIT_LSBFIRST (1<<0) ///< Transmit command/address/data LSB first instead of the default MSB first
|
||||
#define SPI_DEVICE_RXBIT_LSBFIRST (1<<1) ///< Receive data LSB first instead of the default MSB first
|
||||
#define SPI_DEVICE_BIT_LSBFIRST (SPI_TXBIT_LSBFIRST|SPI_RXBIT_LSBFIRST); ///< Transmit and receive LSB first
|
||||
#define SPI_DEVICE_BIT_LSBFIRST (SPI_DEVICE_TXBIT_LSBFIRST|SPI_DEVICE_RXBIT_LSBFIRST); ///< Transmit and receive LSB first
|
||||
#define SPI_DEVICE_3WIRE (1<<2) ///< Use MOSI (=spid) for both sending and receiving data
|
||||
#define SPI_DEVICE_POSITIVE_CS (1<<3) ///< Make CS positive during a transaction instead of negative
|
||||
#define SPI_DEVICE_HALFDUPLEX (1<<4) ///< Transmit data before receiving it, instead of simultaneously
|
||||
@ -67,24 +67,28 @@ typedef struct {
|
||||
#define SPI_TRANS_USE_TXDATA (1<<3) ///< Transmit tx_data member of spi_transaction_t instead of data at tx_buffer. Do not set tx_buffer when using this.
|
||||
|
||||
/**
|
||||
* This structure describes one SPI transaction
|
||||
* This structure describes one SPI transaction. The descriptor should not be modified until the transaction finishes.
|
||||
*/
|
||||
struct spi_transaction_t {
|
||||
uint32_t flags; ///< Bitwise OR of SPI_TRANS_* flags
|
||||
uint16_t command; ///< Command data. Specific length was given when device was added to the bus.
|
||||
uint64_t address; ///< Address. Specific length was given when device was added to the bus.
|
||||
uint16_t cmd; ///< Command data, of which the length is set in the ``command_bits`` of spi_device_interface_config_t.
|
||||
///< <b>NOTE: this field, used to be "command" in ESP-IDF 2.1 and before, is re-written to be used in a new way in ESP-IDF 3.0.</b>
|
||||
///< - Example: write 0x0123 and command_bits=12 to send command 0x12, 0x3_ (in previous version, you may have to write 0x3_12).
|
||||
uint64_t addr; ///< Address data, of which the length is set in the ``address_bits`` of spi_device_interface_config_t.
|
||||
///< <b>NOTE: this field, used to be "address" in ESP-IDF 2.1 and before, is re-written to be used in a new way in ESP-IDF3.0.</b>
|
||||
///< - Example: write 0x123400 and address_bits=24 to send address of 0x12, 0x34, 0x00 (in previous version, you may have to write 0x12340000).
|
||||
size_t length; ///< Total data length, in bits
|
||||
size_t rxlength; ///< Total data length received, if different from length. (0 defaults this to the value of ``length``)
|
||||
size_t rxlength; ///< Total data length received, should be not greater than ``length`` in full-duplex mode (0 defaults this to the value of ``length``).
|
||||
void *user; ///< User-defined variable. Can be used to store eg transaction ID.
|
||||
union {
|
||||
const void *tx_buffer; ///< Pointer to transmit buffer, or NULL for no MOSI phase
|
||||
uint8_t tx_data[4]; ///< If SPI_USE_TXDATA is set, data set here is sent directly from this variable.
|
||||
};
|
||||
union {
|
||||
void *rx_buffer; ///< Pointer to receive buffer, or NULL for no MISO phase
|
||||
void *rx_buffer; ///< Pointer to receive buffer, or NULL for no MISO phase. Written by 4 bytes-unit if DMA is used.
|
||||
uint8_t rx_data[4]; ///< If SPI_USE_RXDATA is set, data is received directly to this variable
|
||||
};
|
||||
};
|
||||
} ; //the rx data should start from a 32-bit aligned address to get around dma issue.
|
||||
|
||||
|
||||
typedef struct spi_device_t* spi_device_handle_t; ///< Handle for a device on a SPI bus
|
||||
@ -182,8 +186,9 @@ esp_err_t spi_device_queue_trans(spi_device_handle_t handle, spi_transaction_t *
|
||||
* re-use the buffers.
|
||||
*
|
||||
* @param handle Device handle obtained using spi_host_add_dev
|
||||
* @param trans_desc Pointer to variable able to contain a pointer to the description of the
|
||||
* transaction that is executed
|
||||
* @param trans_desc Pointer to variable able to contain a pointer to the description of the transaction
|
||||
that is executed. The descriptor should not be modified until the descriptor is returned by
|
||||
spi_device_get_trans_result.
|
||||
* @param ticks_to_wait Ticks to wait until there's a returned item; use portMAX_DELAY to never time
|
||||
out.
|
||||
* @return
|
||||
@ -201,8 +206,7 @@ esp_err_t spi_device_get_trans_result(spi_device_handle_t handle, spi_transactio
|
||||
* using spi_device_get_trans_result.
|
||||
*
|
||||
* @param handle Device handle obtained using spi_host_add_dev
|
||||
* @param trans_desc Pointer to variable able to contain a pointer to the description of the
|
||||
* transaction that is executed
|
||||
* @param trans_desc Description of transaction to execute
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_OK on success
|
||||
|
@ -20,150 +20,480 @@ extern "C" {
|
||||
#include "esp_intr.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#define TOUCH_PAD_SLEEP_CYCLE_CONFIG (0x1000)//The Time is 150Khz,the Max value is 0xffff
|
||||
#define TOUCH_PAD_MEASURE_CYCLE_CONFIG (0xffff)//The Time is 8Mhz,the Max value is 0xffff
|
||||
#include "soc/touch_channel.h"
|
||||
|
||||
typedef enum {
|
||||
TOUCH_PAD_NUM0 = 0, /*!< Touch pad channel 0 is GPIO4 */
|
||||
TOUCH_PAD_NUM1, /*!< Touch pad channel 0 is GPIO0 */
|
||||
TOUCH_PAD_NUM2, /*!< Touch pad channel 0 is GPIO2 */
|
||||
TOUCH_PAD_NUM3, /*!< Touch pad channel 0 is GPIO15 */
|
||||
TOUCH_PAD_NUM4, /*!< Touch pad channel 0 is GPIO13 */
|
||||
TOUCH_PAD_NUM5, /*!< Touch pad channel 0 is GPIO12 */
|
||||
TOUCH_PAD_NUM6, /*!< Touch pad channel 0 is GPIO14 */
|
||||
TOUCH_PAD_NUM7, /*!< Touch pad channel 0 is GPIO27*/
|
||||
TOUCH_PAD_NUM8, /*!< Touch pad channel 0 is GPIO33*/
|
||||
TOUCH_PAD_NUM9, /*!< Touch pad channel 0 is GPIO32*/
|
||||
TOUCH_PAD_NUM1, /*!< Touch pad channel 1 is GPIO0 */
|
||||
TOUCH_PAD_NUM2, /*!< Touch pad channel 2 is GPIO2 */
|
||||
TOUCH_PAD_NUM3, /*!< Touch pad channel 3 is GPIO15*/
|
||||
TOUCH_PAD_NUM4, /*!< Touch pad channel 4 is GPIO13*/
|
||||
TOUCH_PAD_NUM5, /*!< Touch pad channel 5 is GPIO12*/
|
||||
TOUCH_PAD_NUM6, /*!< Touch pad channel 6 is GPIO14*/
|
||||
TOUCH_PAD_NUM7, /*!< Touch pad channel 7 is GPIO27*/
|
||||
TOUCH_PAD_NUM8, /*!< Touch pad channel 8 is GPIO32*/
|
||||
TOUCH_PAD_NUM9, /*!< Touch pad channel 9 is GPIO33*/
|
||||
TOUCH_PAD_MAX,
|
||||
} touch_pad_t;
|
||||
|
||||
typedef enum {
|
||||
TOUCH_HVOLT_KEEP = -1, /*!<Touch sensor high reference voltage, no change */
|
||||
TOUCH_HVOLT_2V4 = 0, /*!<Touch sensor high reference voltage, 2.4V */
|
||||
TOUCH_HVOLT_2V5, /*!<Touch sensor high reference voltage, 2.5V */
|
||||
TOUCH_HVOLT_2V6, /*!<Touch sensor high reference voltage, 2.6V */
|
||||
TOUCH_HVOLT_2V7, /*!<Touch sensor high reference voltage, 2.7V */
|
||||
TOUCH_HVOLT_MAX,
|
||||
} touch_high_volt_t;
|
||||
|
||||
typedef enum {
|
||||
TOUCH_LVOLT_KEEP = -1, /*!<Touch sensor low reference voltage, no change */
|
||||
TOUCH_LVOLT_0V5 = 0, /*!<Touch sensor low reference voltage, 0.5V */
|
||||
TOUCH_LVOLT_0V6, /*!<Touch sensor low reference voltage, 0.6V */
|
||||
TOUCH_LVOLT_0V7, /*!<Touch sensor low reference voltage, 0.7V */
|
||||
TOUCH_LVOLT_0V8, /*!<Touch sensor low reference voltage, 0.8V */
|
||||
TOUCH_LVOLT_MAX,
|
||||
} touch_low_volt_t;
|
||||
|
||||
typedef enum {
|
||||
TOUCH_HVOLT_ATTEN_KEEP = -1, /*!<Touch sensor high reference voltage attenuation, no change */
|
||||
TOUCH_HVOLT_ATTEN_1V5 = 0, /*!<Touch sensor high reference voltage attenuation, 1.5V attenuation */
|
||||
TOUCH_HVOLT_ATTEN_1V, /*!<Touch sensor high reference voltage attenuation, 1.0V attenuation */
|
||||
TOUCH_HVOLT_ATTEN_0V5, /*!<Touch sensor high reference voltage attenuation, 0.5V attenuation */
|
||||
TOUCH_HVOLT_ATTEN_0V, /*!<Touch sensor high reference voltage attenuation, 0V attenuation */
|
||||
TOUCH_HVOLT_ATTEN_MAX,
|
||||
} touch_volt_atten_t;
|
||||
|
||||
typedef enum {
|
||||
TOUCH_PAD_SLOPE_0 = 0, /*!<Touch sensor charge / discharge speed, always zero */
|
||||
TOUCH_PAD_SLOPE_1 = 1, /*!<Touch sensor charge / discharge speed, slowest */
|
||||
TOUCH_PAD_SLOPE_2 = 2, /*!<Touch sensor charge / discharge speed */
|
||||
TOUCH_PAD_SLOPE_3 = 3, /*!<Touch sensor charge / discharge speed */
|
||||
TOUCH_PAD_SLOPE_4 = 4, /*!<Touch sensor charge / discharge speed */
|
||||
TOUCH_PAD_SLOPE_5 = 5, /*!<Touch sensor charge / discharge speed */
|
||||
TOUCH_PAD_SLOPE_6 = 6, /*!<Touch sensor charge / discharge speed */
|
||||
TOUCH_PAD_SLOPE_7 = 7, /*!<Touch sensor charge / discharge speed, fast */
|
||||
TOUCH_PAD_SLOPE_MAX,
|
||||
} touch_cnt_slope_t;
|
||||
|
||||
typedef enum {
|
||||
TOUCH_TRIGGER_BELOW = 0, /*!<Touch interrupt will happen if counter value is less than threshold.*/
|
||||
TOUCH_TRIGGER_ABOVE = 1, /*!<Touch interrupt will happen if counter value is larger than threshold.*/
|
||||
TOUCH_TRIGGER_MAX,
|
||||
} touch_trigger_mode_t;
|
||||
|
||||
typedef enum {
|
||||
TOUCH_TRIGGER_SOURCE_BOTH = 0, /*!< wakeup interrupt is generated if both SET1 and SET2 are "touched"*/
|
||||
TOUCH_TRIGGER_SOURCE_SET1 = 1, /*!< wakeup interrupt is generated if SET1 is "touched"*/
|
||||
TOUCH_TRIGGER_SOURCE_MAX,
|
||||
} touch_trigger_src_t;
|
||||
|
||||
typedef enum {
|
||||
TOUCH_PAD_TIE_OPT_LOW = 0, /*!<Initial level of charging voltage, low level */
|
||||
TOUCH_PAD_TIE_OPT_HIGH = 1, /*!<Initial level of charging voltage, high level */
|
||||
TOUCH_PAD_TIE_OPT_MAX,
|
||||
} touch_tie_opt_t;
|
||||
|
||||
typedef enum {
|
||||
TOUCH_FSM_MODE_TIMER = 0, /*!<To start touch FSM by timer */
|
||||
TOUCH_FSM_MODE_SW, /*!<To start touch FSM by software trigger */
|
||||
TOUCH_FSM_MODE_MAX,
|
||||
} touch_fsm_mode_t;
|
||||
|
||||
|
||||
typedef intr_handle_t touch_isr_handle_t;
|
||||
|
||||
#define TOUCH_PAD_SLEEP_CYCLE_DEFAULT (0x1000) /*!<The timer frequency is RTC_SLOW_CLK (can be 150k or 32k depending on the options), max value is 0xffff */
|
||||
#define TOUCH_PAD_MEASURE_CYCLE_DEFAULT (0xffff) /*!<The timer frequency is 8Mhz, the max value is 0xffff */
|
||||
#define TOUCH_FSM_MODE_DEFAULT (TOUCH_FSM_MODE_TIMER) /*!<The touch FSM my be started by the software or timer */
|
||||
#define TOUCH_TRIGGER_MODE_DEFAULT (TOUCH_TRIGGER_BELOW) /*!<Interrupts can be triggered if sensor value gets below or above threshold */
|
||||
#define TOUCH_TRIGGER_SOURCE_DEFAULT (TOUCH_TRIGGER_SOURCE_SET1) /*!<The wakeup trigger source can be SET1 or both SET1 and SET2 */
|
||||
#define TOUCH_PAD_BIT_MASK_MAX (0x3ff)
|
||||
|
||||
/**
|
||||
* @brief Initialize touch module.
|
||||
*
|
||||
*This function int touch pad module ,enable touch module
|
||||
*
|
||||
* @brief Initialize touch module.
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Touch pad init error
|
||||
*
|
||||
*/
|
||||
esp_err_t touch_pad_init();
|
||||
|
||||
/**
|
||||
* @brief Uninstall TouchPad driver.
|
||||
*
|
||||
* @brief Un-install touch pad driver.
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Touch pad deinit error
|
||||
* - ESP_FAIL Touch pad driver not initialized
|
||||
*/
|
||||
esp_err_t touch_pad_deinit();
|
||||
|
||||
/**
|
||||
* @brief Configure touch pad interrupt threshold.
|
||||
*
|
||||
*
|
||||
* @param[in] touch_num : config touch num
|
||||
*
|
||||
* @param[in] threshold : interrupt threshold ,When the touch_pad_register less than threshold,
|
||||
* will trigger the touch interrupt.User can use touch_pad_read function
|
||||
* to determine the threshold.
|
||||
*
|
||||
* @return - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Touch pad error
|
||||
* - ESP_FAIL Touch pad not initialized
|
||||
*
|
||||
* @brief Configure touch pad interrupt threshold.
|
||||
* @param touch_num touch pad index
|
||||
* @param threshold interrupt threshold,
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG if argument wrong
|
||||
* - ESP_FAIL if touch pad not initialized
|
||||
*/
|
||||
esp_err_t touch_pad_config(touch_pad_t touch_num, uint16_t threshold);
|
||||
|
||||
/**
|
||||
* @brief get touch pad touch_pad_register counter.
|
||||
*
|
||||
*User can use this function to determine the the interrupt threshold .When you do not touch the
|
||||
*pad ,read the touch_pad_read number(NumNotTouch) by the touch_pad_register.When you touch the pad ,read the touch_pad_register
|
||||
*number(NumTouch) by the touch_pad_read.Normal NumNotTouch>NumTouch,so you can select a interrupt threshold.
|
||||
*
|
||||
* @param[in] touch_num : touch num
|
||||
* @param[out] touch_value : touch output value
|
||||
*
|
||||
* @return - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Touch pad error
|
||||
* - ESP_FAIL Touch pad not initialized
|
||||
* @brief get touch sensor counter value.
|
||||
* Each touch sensor has a counter to count the number of charge/discharge cycles.
|
||||
* When the pad is not 'touched', we can get a number of the counter.
|
||||
* When the pad is 'touched', the value in counter will get smaller because of the larger equivalent capacitance.
|
||||
* User can use this function to determine the interrupt trigger threshold.
|
||||
*
|
||||
* @param touch_num touch pad index
|
||||
* @param touch_value pointer to accept touch sensor value
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Touch pad error
|
||||
* - ESP_FAIL Touch pad not initialized
|
||||
*/
|
||||
esp_err_t touch_pad_read(touch_pad_t touch_num, uint16_t * touch_value);
|
||||
|
||||
/**
|
||||
* @brief register TouchPad interrupt handler, the handler is an ISR.
|
||||
* The handler will be attached to the same CPU core that this function is running on.
|
||||
*
|
||||
* @param fn Interrupt handler function.
|
||||
* @param arg Parameter for handler function
|
||||
* @param intr_alloc_flags Flags used to allocate the interrupt. One or multiple (ORred)
|
||||
* ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info.
|
||||
* @param handle Pointer to return handle. If non-NULL, a handle for the interrupt will
|
||||
* be returned here.
|
||||
* @brief get filtered touch sensor counter value by IIR filter.
|
||||
* @note touch_pad_filter_start has to be called before calling touch_pad_read_filtered.
|
||||
* This function can be called from ISR
|
||||
*
|
||||
* @param touch_num touch pad index
|
||||
* @param touch_value pointer to accept touch sensor value
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Touch pad error
|
||||
* - ESP_FAIL Touch pad not initialized
|
||||
*/
|
||||
esp_err_t touch_pad_read_filtered(touch_pad_t touch_num, uint16_t *touch_value);
|
||||
|
||||
/**
|
||||
* @brief Register touch-pad ISR,
|
||||
* @note Deprecated function, users should replace this with touch_pad_isr_register,
|
||||
* because RTC modules share a same interrupt index.
|
||||
* @param fn Pointer to ISR handler
|
||||
* @param arg Parameter for ISR
|
||||
* @param unused Reserved, not used
|
||||
* @param handle_unused Reserved, not used
|
||||
* @return
|
||||
* - ESP_OK Success ;
|
||||
* - ESP_ERR_INVALID_ARG GPIO error
|
||||
*/
|
||||
esp_err_t touch_pad_isr_handler_register(void(*fn)(void *), void *arg, int intr_alloc_flags, touch_isr_handle_t *handle);
|
||||
|
||||
esp_err_t touch_pad_isr_handler_register(void(*fn)(void *), void *arg, int unused, intr_handle_t *handle_unused) __attribute__ ((deprecated));
|
||||
|
||||
/**
|
||||
* *************** ATTENTION ********************/
|
||||
/**
|
||||
*@attention
|
||||
*Touch button is through the body's capacitive characteristics,
|
||||
*there is a charge discharge circuit inside the. When the hands touch,
|
||||
*the charge and discharge time will be slow.
|
||||
*Because of the different hardware, each pad needs to be calibrated at the factory.
|
||||
*We use touch_pad_read to determine factory parameters.
|
||||
* @brief Register touch-pad ISR.
|
||||
* The handler will be attached to the same CPU core that this function is running on.
|
||||
* @param fn Pointer to ISR handler
|
||||
* @param arg Parameter for ISR
|
||||
* @return
|
||||
* - ESP_OK Success ;
|
||||
* - ESP_ERR_INVALID_ARG GPIO error
|
||||
*/
|
||||
esp_err_t touch_pad_isr_register(intr_handler_t fn, void* arg);
|
||||
|
||||
/**
|
||||
*----------EXAMPLE TO CONFIGURE GPIO AS OUTPUT ------------ *
|
||||
* @code{c}
|
||||
* touch_pad_init();
|
||||
* void taskA(void* arg)
|
||||
* {
|
||||
* for(;;){
|
||||
* vtaskDelay(20/portTICK_PERIOD_MS);
|
||||
* ets_printf("touch pad value %u\n",touch_pad_read(0));//Take the touched status and untouched status value
|
||||
* }
|
||||
* }
|
||||
* @endcode
|
||||
**/
|
||||
/**
|
||||
*----------EXAMPLE TO SET ISR HANDLER ----------------------
|
||||
* @code{c}
|
||||
* touch_pad_isr_handler_register(rtc_intr,NULL, 0, NULL) //hook the isr handler for TouchPad interrupt
|
||||
* @endcode
|
||||
* @brief Deregister the handler previously registered using touch_pad_isr_handler_register
|
||||
* @param fn handler function to call (as passed to touch_pad_isr_handler_register)
|
||||
* @param arg argument of the handler (as passed to touch_pad_isr_handler_register)
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_STATE if a handler matching both fn and
|
||||
* arg isn't registered
|
||||
*/
|
||||
esp_err_t touch_pad_isr_deregister(void(*fn)(void *), void *arg);
|
||||
|
||||
/**
|
||||
*----------EXAMPLE TO USE TOUCH_PAD------------ *
|
||||
* @code{c}
|
||||
* touch_pad_init();//only init one time
|
||||
* touch_pad_config(0,300);//set the intr threshold,use touch_pad_read to determine this threshold
|
||||
* touch_pad_isr_handler_register(rtc_intr,NULL, 0, NULL)
|
||||
* #include "esp_attr.h"
|
||||
* void rtc_intr(void * arg)
|
||||
* {
|
||||
* uint32_t pad_intr = READ_PERI_REG(SARADC_SAR_TOUCH_CTRL2_REG) & 0x3ff;
|
||||
* uint8_t i = 0;
|
||||
* uint32_t rtc_intr = READ_PERI_REG(RTC_CNTL_INT_ST_REG);
|
||||
* WRITE_PERI_REG(RTC_CNTL_INT_CLR_REG, rtc_intr);
|
||||
* SET_PERI_REG_MASK(SARADC_SAR_TOUCH_CTRL2_REG, SARADC_TOUCH_MEAS_EN_CLR);
|
||||
* if (rtc_intr & RTC_CNTL_TOUCH_INT_ST) {
|
||||
* for (i = 0; i < TOUCH_PAD_MAX; ++i) {
|
||||
* if ((pad_intr >> i) & 0x01) {
|
||||
* ets_printf("touch pad intr %u\n",i);
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* @endcode
|
||||
**/
|
||||
* @brief Set touch sensor measurement and sleep time
|
||||
* @param sleep_cycle The touch sensor will sleep after each measurement.
|
||||
* sleep_cycle decide the interval between each measurement.
|
||||
* t_sleep = sleep_cycle / (RTC_SLOW_CLK frequency).
|
||||
* The approximate frequency value of RTC_SLOW_CLK can be obtained using rtc_clk_slow_freq_get_hz function.
|
||||
* @param meas_cycle The duration of the touch sensor measurement.
|
||||
* t_meas = meas_cycle / 8M, the maximum measure time is 0xffff / 8M = 8.19 ms
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t touch_pad_set_meas_time(uint16_t sleep_cycle, uint16_t meas_cycle);
|
||||
|
||||
/**
|
||||
* @brief Get touch sensor measurement and sleep time
|
||||
* @param sleep_cycle Pointer to accept sleep cycle number
|
||||
* @param meas_cycle Pointer to accept measurement cycle count.
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t touch_pad_get_meas_time(uint16_t *sleep_cycle, uint16_t *meas_cycle);
|
||||
|
||||
/**
|
||||
* @brief Set touch sensor reference voltage, if the voltage gap between high and low reference voltage get less,
|
||||
* the charging and discharging time would be faster, accordingly, the counter value would be larger.
|
||||
* In the case of detecting very slight change of capacitance, we can narrow down the gap so as to increase
|
||||
* the sensitivity. On the other hand, narrow voltage gap would also introduce more noise, but we can use a
|
||||
* software filter to pre-process the counter value.
|
||||
* @param refh the value of DREFH
|
||||
* @param refl the value of DREFL
|
||||
* @param atten the attenuation on DREFH
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_set_voltage(touch_high_volt_t refh, touch_low_volt_t refl, touch_volt_atten_t atten);
|
||||
|
||||
/**
|
||||
* @brief Get touch sensor reference voltage,
|
||||
* @param refh pointer to accept DREFH value
|
||||
* @param refl pointer to accept DREFL value
|
||||
* @param atten pointer to accept the attenuation on DREFH
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t touch_pad_get_voltage(touch_high_volt_t *refh, touch_low_volt_t *refl, touch_volt_atten_t *atten);
|
||||
|
||||
/**
|
||||
* @brief Set touch sensor charge/discharge speed for each pad.
|
||||
* If the slope is 0, the counter would always be zero.
|
||||
* If the slope is 1, the charging and discharging would be slow, accordingly, the counter value would be small.
|
||||
* If the slope is set 7, which is the maximum value, the charging and discharging would be fast, accordingly, the
|
||||
* counter value would be larger.
|
||||
* @param touch_num touch pad index
|
||||
* @param slope touch pad charge/discharge speed
|
||||
* @param opt the initial voltage
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_set_cnt_mode(touch_pad_t touch_num, touch_cnt_slope_t slope, touch_tie_opt_t opt);
|
||||
|
||||
/**
|
||||
* @brief Get touch sensor charge/discharge speed for each pad
|
||||
* @param touch_num touch pad index
|
||||
* @param slope pointer to accept touch pad charge/discharge slope
|
||||
* @param opt pointer to accept the initial voltage
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_get_cnt_mode(touch_pad_t touch_num, touch_cnt_slope_t *slope, touch_tie_opt_t *opt);
|
||||
|
||||
/**
|
||||
* @brief Initialize touch pad GPIO
|
||||
* @param touch_num touch pad index
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_io_init(touch_pad_t touch_num);
|
||||
|
||||
/**
|
||||
* @brief Set touch sensor FSM mode, the test action can be triggered by the timer,
|
||||
* as well as by the software.
|
||||
* @param mode FSM mode
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_set_fsm_mode(touch_fsm_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief Get touch sensor FSM mode
|
||||
* @param mode pointer to accept FSM mode
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t touch_pad_get_fsm_mode(touch_fsm_mode_t *mode);
|
||||
|
||||
/**
|
||||
* @brief Trigger a touch sensor measurement, only support in SW mode of FSM
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t touch_pad_sw_start();
|
||||
|
||||
/**
|
||||
* @brief Set touch sensor interrupt threshold
|
||||
* @param touch_num touch pad index
|
||||
* @param threshold threshold of touchpad count, refer to touch_pad_set_trigger_mode to see how to set trigger mode.
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_set_thresh(touch_pad_t touch_num, uint16_t threshold);
|
||||
|
||||
/**
|
||||
* @brief Get touch sensor interrupt threshold
|
||||
* @param touch_num touch pad index
|
||||
* @param threshold pointer to accept threshold
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_get_thresh(touch_pad_t touch_num, uint16_t *threshold);
|
||||
|
||||
/**
|
||||
* @brief Set touch sensor interrupt trigger mode.
|
||||
* Interrupt can be triggered either when counter result is less than
|
||||
* threshold or when counter result is more than threshold.
|
||||
* @param mode touch sensor interrupt trigger mode
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_set_trigger_mode(touch_trigger_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief Get touch sensor interrupt trigger mode
|
||||
* @param mode pointer to accept touch sensor interrupt trigger mode
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t touch_pad_get_trigger_mode(touch_trigger_mode_t *mode);
|
||||
|
||||
/**
|
||||
* @brief Set touch sensor interrupt trigger source. There are two sets of touch signals.
|
||||
* Set1 and set2 can be mapped to several touch signals. Either set will be triggered
|
||||
* if at least one of its touch signal is 'touched'. The interrupt can be configured to be generated
|
||||
* if set1 is triggered, or only if both sets are triggered.
|
||||
* @param src touch sensor interrupt trigger source
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_set_trigger_source(touch_trigger_src_t src);
|
||||
|
||||
/**
|
||||
* @brief Get touch sensor interrupt trigger source
|
||||
* @param src pointer to accept touch sensor interrupt trigger source
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t touch_pad_get_trigger_source(touch_trigger_src_t *src);
|
||||
|
||||
/**
|
||||
* @brief Set touch sensor group mask.
|
||||
* Touch pad module has two sets of signals, 'Touched' signal is triggered only if
|
||||
* at least one of touch pad in this group is "touched".
|
||||
* This function will set the register bits according to the given bitmask.
|
||||
* @param set1_mask bitmask of touch sensor signal group1, it's a 10-bit value
|
||||
* @param set2_mask bitmask of touch sensor signal group2, it's a 10-bit value
|
||||
* @param en_mask bitmask of touch sensor work enable, it's a 10-bit value
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_set_group_mask(uint16_t set1_mask, uint16_t set2_mask, uint16_t en_mask);
|
||||
|
||||
/**
|
||||
* @brief Get touch sensor group mask.
|
||||
* @param set1_mask pointer to accept bitmask of touch sensor signal group1, it's a 10-bit value
|
||||
* @param set2_mask pointer to accept bitmask of touch sensor signal group2, it's a 10-bit value
|
||||
* @param en_mask pointer to accept bitmask of touch sensor work enable, it's a 10-bit value
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t touch_pad_get_group_mask(uint16_t *set1_mask, uint16_t *set2_mask, uint16_t *en_mask);
|
||||
|
||||
/**
|
||||
* @brief Clear touch sensor group mask.
|
||||
* Touch pad module has two sets of signals, Interrupt is triggered only if
|
||||
* at least one of touch pad in this group is "touched".
|
||||
* This function will clear the register bits according to the given bitmask.
|
||||
* @param set1_mask bitmask touch sensor signal group1, it's a 10-bit value
|
||||
* @param set2_mask bitmask touch sensor signal group2, it's a 10-bit value
|
||||
* @param en_mask bitmask of touch sensor work enable, it's a 10-bit value
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_clear_group_mask(uint16_t set1_mask, uint16_t set2_mask, uint16_t en_mask);
|
||||
|
||||
/**
|
||||
* @brief To clear the touch status register, usually use this function in touch ISR to clear status.
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t touch_pad_clear_status();
|
||||
|
||||
/**
|
||||
* @brief Get the touch sensor status, usually used in ISR to decide which pads are 'touched'.
|
||||
* @return
|
||||
* - touch status
|
||||
*/
|
||||
uint32_t touch_pad_get_status();
|
||||
|
||||
/**
|
||||
* @brief To enable touch pad interrupt
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t touch_pad_intr_enable();
|
||||
|
||||
/**
|
||||
* @brief To disable touch pad interrupt
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t touch_pad_intr_disable();
|
||||
|
||||
/**
|
||||
* @brief set touch pad filter calibration period, in ms.
|
||||
* Need to call touch_pad_filter_start before all touch filter APIs
|
||||
* @param new_period_ms filter period, in ms
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_STATE driver state error
|
||||
* - ESP_ERR_INVALID_ARG parameter error
|
||||
*/
|
||||
esp_err_t touch_pad_set_filter_period(uint32_t new_period_ms);
|
||||
|
||||
/**
|
||||
* @brief get touch pad filter calibration period, in ms
|
||||
* Need to call touch_pad_filter_start before all touch filter APIs
|
||||
* @param p_period_ms pointer to accept period
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_STATE driver state error
|
||||
* - ESP_ERR_INVALID_ARG parameter error
|
||||
*/
|
||||
esp_err_t touch_pad_get_filter_period(uint32_t* p_period_ms);
|
||||
|
||||
/**
|
||||
* @brief start touch pad filter function
|
||||
* This API will start a filter to process the noise in order to prevent false triggering
|
||||
* when detecting slight change of capacitance.
|
||||
* Need to call touch_pad_filter_start before all touch filter APIs
|
||||
*
|
||||
* If filter is not initialized, this API will initialize the filter with given period.
|
||||
* If filter is already initialized, this API will update the filter period.
|
||||
* @note This filter uses FreeRTOS timer, which is dispatched from a task with
|
||||
* priority 1 by default on CPU 0. So if some application task with higher priority
|
||||
* takes a lot of CPU0 time, then the quality of data obtained from this filter will be affected.
|
||||
* You can adjust FreeRTOS timer task priority in menuconfig.
|
||||
* @param filter_period_ms filter calibration period, in ms
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG parameter error
|
||||
* - ESP_ERR_NO_MEM No memory for driver
|
||||
* - ESP_ERR_INVALID_STATE driver state error
|
||||
*/
|
||||
esp_err_t touch_pad_filter_start(uint32_t filter_period_ms);
|
||||
|
||||
/**
|
||||
* @brief stop touch pad filter function
|
||||
* Need to call touch_pad_filter_start before all touch filter APIs
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_STATE driver state error
|
||||
*/
|
||||
esp_err_t touch_pad_filter_stop();
|
||||
|
||||
/**
|
||||
* @brief delete touch pad filter driver and release the memory
|
||||
* Need to call touch_pad_filter_start before all touch filter APIs
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_STATE driver state error
|
||||
*/
|
||||
esp_err_t touch_pad_filter_delete();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ extern "C" {
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/ringbuf.h"
|
||||
#include <esp_types.h>
|
||||
#include "soc/uart_channel.h"
|
||||
|
||||
#define UART_FIFO_LEN (128) /*!< Length of the hardware FIFO buffers */
|
||||
#define UART_INTR_MASK 0x1ff /*!< mask of all UART interrupts */
|
||||
|
@ -54,3 +54,11 @@ uint32_t esp_clk_slowclk_cal_get();
|
||||
*/
|
||||
void esp_clk_slowclk_cal_set(uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Disables clock of some peripherals
|
||||
*
|
||||
* Called from cpu_start.c, not intended to be called from other places.
|
||||
* This function disables clock of useless peripherals when cpu starts.
|
||||
*/
|
||||
void esp_perip_clk_init(void);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@ -14,281 +14,81 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/touch_pad.h"
|
||||
/**
|
||||
* @file esp_deep_sleep.h
|
||||
* @brief legacy definitions of esp_deep_sleep APIs
|
||||
*
|
||||
* This file provides compatibility for applications using esp_deep_sleep_* APIs.
|
||||
* New applications should use functions defined in "esp_sleep.h" instead.
|
||||
* These functions and types will be deprecated at some point.
|
||||
*/
|
||||
|
||||
#warning esp_deep_sleep.h will be deprecated in the next release. Use esp_sleep.h instead.
|
||||
|
||||
#include "esp_sleep.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief Logic function used for EXT1 wakeup mode.
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_EXT1_WAKEUP_ALL_LOW = 0, //!< Wake the chip when all selected GPIOs go low
|
||||
ESP_EXT1_WAKEUP_ANY_HIGH = 1 //!< Wake the chip when any of the selected GPIOs go high
|
||||
} esp_ext1_wakeup_mode_t;
|
||||
typedef esp_sleep_pd_domain_t esp_deep_sleep_pd_domain_t;
|
||||
typedef esp_sleep_pd_option_t esp_deep_sleep_pd_option_t;
|
||||
typedef esp_sleep_ext1_wakeup_mode_t esp_ext1_wakeup_mode_t;
|
||||
typedef esp_sleep_wakeup_cause_t esp_deep_sleep_wakeup_cause_t;
|
||||
|
||||
/**
|
||||
* @brief Power domains which can be powered down in deep sleep
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_PD_DOMAIN_RTC_PERIPH, //!< RTC IO, sensors and ULP co-processor
|
||||
ESP_PD_DOMAIN_RTC_SLOW_MEM, //!< RTC slow memory
|
||||
ESP_PD_DOMAIN_RTC_FAST_MEM, //!< RTC fast memory
|
||||
ESP_PD_DOMAIN_MAX //!< Number of domains
|
||||
} esp_deep_sleep_pd_domain_t;
|
||||
inline static esp_err_t esp_deep_sleep_enable_ulp_wakeup(void)
|
||||
{
|
||||
return esp_sleep_enable_ulp_wakeup();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Power down options
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_PD_OPTION_OFF, //!< Power down the power domain in deep sleep
|
||||
ESP_PD_OPTION_ON, //!< Keep power domain enabled during deep sleep
|
||||
ESP_PD_OPTION_AUTO //!< Keep power domain enabled in deep sleep, if it is needed by one of the wakeup options. Otherwise power it down.
|
||||
} esp_deep_sleep_pd_option_t;
|
||||
inline static esp_err_t esp_deep_sleep_enable_timer_wakeup(uint64_t time_in_us)
|
||||
{
|
||||
return esp_sleep_enable_timer_wakeup(time_in_us);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Deep sleep wakeup cause
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_DEEP_SLEEP_WAKEUP_UNDEFINED, //! Wakeup was not caused by deep sleep
|
||||
ESP_DEEP_SLEEP_WAKEUP_EXT0, //! Wakeup caused by external signal using RTC_IO
|
||||
ESP_DEEP_SLEEP_WAKEUP_EXT1, //! Wakeup caused by external signal using RTC_CNTL
|
||||
ESP_DEEP_SLEEP_WAKEUP_TIMER, //! Wakeup caused by timer
|
||||
ESP_DEEP_SLEEP_WAKEUP_TOUCHPAD, //! Wakeup caused by touchpad
|
||||
ESP_DEEP_SLEEP_WAKEUP_ULP, //! Wakeup caused by ULP program
|
||||
} esp_deep_sleep_wakeup_cause_t;
|
||||
inline static esp_err_t esp_deep_sleep_enable_touchpad_wakeup(void)
|
||||
{
|
||||
return esp_sleep_enable_touchpad_wakeup();
|
||||
}
|
||||
|
||||
inline static touch_pad_t esp_deep_sleep_get_touchpad_wakeup_status()
|
||||
{
|
||||
return esp_sleep_get_touchpad_wakeup_status();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable wakeup by ULP coprocessor
|
||||
* @note In revisions 0 and 1 of the ESP32, ULP wakeup source
|
||||
* can not be used when RTC_PERIPH power domain is forced
|
||||
* to be powered on (ESP_PD_OPTION_ON) or when ext0 wakeup
|
||||
* source is used.
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_STATE if ULP co-processor is not enabled or if wakeup triggers conflict
|
||||
*/
|
||||
esp_err_t esp_deep_sleep_enable_ulp_wakeup();
|
||||
inline static esp_err_t esp_deep_sleep_enable_ext0_wakeup(gpio_num_t gpio_num, int level)
|
||||
{
|
||||
return esp_sleep_enable_ext0_wakeup(gpio_num, level);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable wakeup by timer
|
||||
* @param time_in_us time before wakeup, in microseconds
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if value is out of range (TBD)
|
||||
*/
|
||||
esp_err_t esp_deep_sleep_enable_timer_wakeup(uint64_t time_in_us);
|
||||
inline static esp_err_t esp_deep_sleep_enable_ext1_wakeup(uint64_t mask, esp_ext1_wakeup_mode_t mode)
|
||||
{
|
||||
return esp_sleep_enable_ext1_wakeup(mask, mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable wakeup by touch sensor
|
||||
*
|
||||
* @note In revisions 0 and 1 of the ESP32, touch wakeup source
|
||||
* can not be used when RTC_PERIPH power domain is forced
|
||||
* to be powered on (ESP_PD_OPTION_ON) or when ext0 wakeup
|
||||
* source is used.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_STATE if wakeup triggers conflict
|
||||
*/
|
||||
esp_err_t esp_deep_sleep_enable_touchpad_wakeup();
|
||||
inline static esp_err_t esp_deep_sleep_pd_config(
|
||||
esp_deep_sleep_pd_domain_t domain,
|
||||
esp_deep_sleep_pd_option_t option)
|
||||
{
|
||||
return esp_sleep_pd_config(domain, option);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the touch pad which caused wakeup
|
||||
*
|
||||
* If wakeup was caused by another source, this function will return TOUCH_PAD_MAX;
|
||||
*
|
||||
* @return touch pad which caused wakeup
|
||||
*/
|
||||
touch_pad_t esp_deep_sleep_get_touchpad_wakeup_status();
|
||||
inline static esp_deep_sleep_wakeup_cause_t esp_deep_sleep_get_wakeup_cause()
|
||||
{
|
||||
return esp_sleep_get_wakeup_cause();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable wakeup using a pin
|
||||
*
|
||||
* This function uses external wakeup feature of RTC_IO peripheral.
|
||||
* It will work only if RTC peripherals are kept on during deep sleep.
|
||||
*
|
||||
* This feature can monitor any pin which is an RTC IO. Once the pin transitions
|
||||
* into the state given by level argument, the chip will be woken up.
|
||||
*
|
||||
* @note This function does not modify pin configuration. The pin is
|
||||
* configured in esp_deep_sleep_start, immediately before
|
||||
* entering deep sleep.
|
||||
*
|
||||
* @note In revisions 0 and 1 of the ESP32, ext0 wakeup source
|
||||
* can not be used together with touch or ULP wakeup sources.
|
||||
*
|
||||
* @param gpio_num GPIO number used as wakeup source. Only GPIOs which are have RTC
|
||||
* functionality can be used: 0,2,4,12-15,25-27,32-39.
|
||||
* @param level input level which will trigger wakeup (0=low, 1=high)
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if the selected GPIO is not an RTC GPIO,
|
||||
* or the mode is invalid
|
||||
* - ESP_ERR_INVALID_STATE if wakeup triggers conflict
|
||||
*/
|
||||
esp_err_t esp_deep_sleep_enable_ext0_wakeup(gpio_num_t gpio_num, int level);
|
||||
#define ESP_DEEP_SLEEP_WAKEUP_UNDEFINED ESP_SLEEP_WAKEUP_UNDEFINED
|
||||
#define ESP_DEEP_SLEEP_WAKEUP_EXT0 ESP_SLEEP_WAKEUP_EXT0
|
||||
#define ESP_DEEP_SLEEP_WAKEUP_EXT1 ESP_SLEEP_WAKEUP_EXT1
|
||||
#define ESP_DEEP_SLEEP_WAKEUP_TIMER ESP_SLEEP_WAKEUP_TIMER
|
||||
#define ESP_DEEP_SLEEP_WAKEUP_TOUCHPAD ESP_SLEEP_WAKEUP_TOUCHPAD
|
||||
#define ESP_DEEP_SLEEP_WAKEUP_ULP ESP_SLEEP_WAKEUP_ULP
|
||||
|
||||
/**
|
||||
* @brief Enable wakeup using multiple pins
|
||||
*
|
||||
* This function uses external wakeup feature of RTC controller.
|
||||
* It will work even if RTC peripherals are shut down during deep sleep.
|
||||
*
|
||||
* This feature can monitor any number of pins which are in RTC IOs.
|
||||
* Once any of the selected pins goes into the state given by mode argument,
|
||||
* the chip will be woken up.
|
||||
*
|
||||
* @note This function does not modify pin configuration. The pins are
|
||||
* configured in esp_deep_sleep_start, immediately before
|
||||
* entering deep sleep.
|
||||
*
|
||||
* @note internal pullups and pulldowns don't work when RTC peripherals are
|
||||
* shut down. In this case, external resistors need to be added.
|
||||
* Alternatively, RTC peripherals (and pullups/pulldowns) may be
|
||||
* kept enabled using esp_deep_sleep_pd_config function.
|
||||
*
|
||||
* @param mask bit mask of GPIO numbers which will cause wakeup. Only GPIOs
|
||||
* which are have RTC functionality can be used in this bit map:
|
||||
* 0,2,4,12-15,25-27,32-39.
|
||||
* @param mode select logic function used to determine wakeup condition:
|
||||
* - ESP_EXT1_WAKEUP_ALL_LOW: wake up when all selected GPIOs are low
|
||||
* - ESP_EXT1_WAKEUP_ANY_HIGH: wake up when any of the selected GPIOs is high
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if any of the selected GPIOs is not an RTC GPIO,
|
||||
* or mode is invalid
|
||||
*/
|
||||
esp_err_t esp_deep_sleep_enable_ext1_wakeup(uint64_t mask, esp_ext1_wakeup_mode_t mode);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the bit mask of GPIOs which caused wakeup (ext1)
|
||||
*
|
||||
* If wakeup was caused by another source, this function will return 0.
|
||||
*
|
||||
* @return bit mask, if GPIOn caused wakeup, BIT(n) will be set
|
||||
*/
|
||||
uint64_t esp_deep_sleep_get_ext1_wakeup_status();
|
||||
|
||||
/**
|
||||
* @brief Set power down mode for an RTC power domain in deep sleep
|
||||
*
|
||||
* If not set set using this API, all power domains default to ESP_PD_OPTION_AUTO.
|
||||
*
|
||||
* @param domain power domain to configure
|
||||
* @param option power down option (ESP_PD_OPTION_OFF, ESP_PD_OPTION_ON, or ESP_PD_OPTION_AUTO)
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if either of the arguments is out of range
|
||||
*/
|
||||
esp_err_t esp_deep_sleep_pd_config(esp_deep_sleep_pd_domain_t domain,
|
||||
esp_deep_sleep_pd_option_t option);
|
||||
|
||||
/**
|
||||
* @brief Enter deep sleep with the configured wakeup options
|
||||
*
|
||||
* This function does not return.
|
||||
*/
|
||||
void esp_deep_sleep_start() __attribute__((noreturn));
|
||||
|
||||
/**
|
||||
* @brief Enter deep-sleep mode
|
||||
*
|
||||
* The device will automatically wake up after the deep-sleep time
|
||||
* Upon waking up, the device calls deep sleep wake stub, and then proceeds
|
||||
* to load application.
|
||||
*
|
||||
* Call to this function is equivalent to a call to esp_deep_sleep_enable_timer_wakeup
|
||||
* followed by a call to esp_deep_sleep_start.
|
||||
*
|
||||
* esp_deep_sleep does not shut down WiFi, BT, and higher level protocol
|
||||
* connections gracefully.
|
||||
* Make sure relevant WiFi and BT stack functions are called to close any
|
||||
* connections and deinitialize the peripherals. These include:
|
||||
* - esp_bluedroid_disable
|
||||
* - esp_bt_controller_disable
|
||||
* - esp_wifi_stop
|
||||
*
|
||||
* This function does not return.
|
||||
*
|
||||
* @param time_in_us deep-sleep time, unit: microsecond
|
||||
*/
|
||||
void esp_deep_sleep(uint64_t time_in_us) __attribute__((noreturn));
|
||||
|
||||
/**
|
||||
* @brief Enter deep-sleep mode
|
||||
*
|
||||
* Function has been renamed to esp_deep_sleep.
|
||||
* This name is deprecated and will be removed in a future version.
|
||||
*
|
||||
* @param time_in_us deep-sleep time, unit: microsecond
|
||||
*/
|
||||
void system_deep_sleep(uint64_t time_in_us) __attribute__((noreturn, deprecated));
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the source which caused deep sleep wakeup
|
||||
*
|
||||
* @return wakeup cause, or ESP_DEEP_SLEEP_WAKEUP_UNDEFINED if reset reason is other than deep sleep reset.
|
||||
*/
|
||||
esp_deep_sleep_wakeup_cause_t esp_deep_sleep_get_wakeup_cause();
|
||||
|
||||
|
||||
/**
|
||||
* @brief Default stub to run on wake from deep sleep.
|
||||
*
|
||||
* Allows for executing code immediately on wake from sleep, before
|
||||
* the software bootloader or ESP-IDF app has started up.
|
||||
*
|
||||
* This function is weak-linked, so you can implement your own version
|
||||
* to run code immediately when the chip wakes from
|
||||
* sleep.
|
||||
*
|
||||
* See docs/deep-sleep-stub.rst for details.
|
||||
*/
|
||||
void esp_wake_deep_sleep(void);
|
||||
|
||||
/**
|
||||
* @brief Function type for stub to run on wake from sleep.
|
||||
*
|
||||
*/
|
||||
typedef void (*esp_deep_sleep_wake_stub_fn_t)(void);
|
||||
|
||||
/**
|
||||
* @brief Install a new stub at runtime to run on wake from deep sleep
|
||||
*
|
||||
* If implementing esp_wake_deep_sleep() then it is not necessary to
|
||||
* call this function.
|
||||
*
|
||||
* However, it is possible to call this function to substitute a
|
||||
* different deep sleep stub. Any function used as a deep sleep stub
|
||||
* must be marked RTC_IRAM_ATTR, and must obey the same rules given
|
||||
* for esp_wake_deep_sleep().
|
||||
*/
|
||||
void esp_set_deep_sleep_wake_stub(esp_deep_sleep_wake_stub_fn_t new_stub);
|
||||
|
||||
/**
|
||||
* @brief Get current wake from deep sleep stub
|
||||
* @return Return current wake from deep sleep stub, or NULL if
|
||||
* no stub is installed.
|
||||
*/
|
||||
esp_deep_sleep_wake_stub_fn_t esp_get_deep_sleep_wake_stub(void);
|
||||
|
||||
/**
|
||||
* @brief The default esp-idf-provided esp_wake_deep_sleep() stub.
|
||||
*
|
||||
* See docs/deep-sleep-stub.rst for details.
|
||||
*/
|
||||
void esp_default_wake_deep_sleep(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1,2 +1,2 @@
|
||||
#warning esp_deepsleep.h has been renamed to esp_deep_sleep.h, please update include directives
|
||||
#include "esp_deep_sleep.h"
|
||||
#warning esp_deepsleep.h has been renamed to esp_sleep.h, please update include directives
|
||||
#include "esp_sleep.h"
|
||||
|
@ -12,6 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <sdkconfig.h>
|
||||
|
||||
#ifndef _ESP_DPORT_ACCESS_H_
|
||||
#define _ESP_DPORT_ACCESS_H_
|
||||
|
||||
@ -22,7 +24,8 @@ extern "C" {
|
||||
void esp_dport_access_stall_other_cpu_start(void);
|
||||
void esp_dport_access_stall_other_cpu_end(void);
|
||||
void esp_dport_access_int_init(void);
|
||||
void esp_dport_access_int_deinit(void);
|
||||
void esp_dport_access_int_pause(void);
|
||||
void esp_dport_access_int_resume(void);
|
||||
|
||||
#if defined(BOOTLOADER_BUILD) || defined(CONFIG_FREERTOS_UNICORE) || !defined(ESP_PLATFORM)
|
||||
#define DPORT_STALL_OTHER_CPU_START()
|
||||
|
@ -35,6 +35,7 @@ typedef enum {
|
||||
SYSTEM_EVENT_STA_DISCONNECTED, /**< ESP32 station disconnected from AP */
|
||||
SYSTEM_EVENT_STA_AUTHMODE_CHANGE, /**< the auth mode of AP connected by ESP32 station changed */
|
||||
SYSTEM_EVENT_STA_GOT_IP, /**< ESP32 station got IP from connected AP */
|
||||
SYSTEM_EVENT_STA_LOST_IP, /**< ESP32 station lost IP and the IP is reset to 0 */
|
||||
SYSTEM_EVENT_STA_WPS_ER_SUCCESS, /**< ESP32 station wps succeeds in enrollee mode */
|
||||
SYSTEM_EVENT_STA_WPS_ER_FAILED, /**< ESP32 station wps fails in enrollee mode */
|
||||
SYSTEM_EVENT_STA_WPS_ER_TIMEOUT, /**< ESP32 station wps timeout in enrollee mode */
|
||||
@ -86,6 +87,7 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
tcpip_adapter_ip_info_t ip_info;
|
||||
bool ip_changed;
|
||||
} system_event_sta_got_ip_t;
|
||||
|
||||
typedef struct {
|
||||
@ -116,7 +118,7 @@ typedef union {
|
||||
system_event_sta_disconnected_t disconnected; /**< ESP32 station disconnected to AP */
|
||||
system_event_sta_scan_done_t scan_done; /**< ESP32 station scan (APs) done */
|
||||
system_event_sta_authmode_change_t auth_change; /**< the auth mode of AP ESP32 station connected to changed */
|
||||
system_event_sta_got_ip_t got_ip; /**< ESP32 station got IP */
|
||||
system_event_sta_got_ip_t got_ip; /**< ESP32 station got IP, first time got IP or when IP is changed */
|
||||
system_event_sta_wps_er_pin_t sta_er_pin; /**< ESP32 station WPS enrollee mode PIN code received */
|
||||
system_event_sta_wps_fail_reason_t sta_er_fail_reason;/**< ESP32 station WPS enrollee mode failed reason code received */
|
||||
system_event_ap_staconnected_t sta_connected; /**< a station connected to ESP32 soft-AP */
|
||||
@ -159,6 +161,17 @@ esp_err_t esp_event_send(system_event_t *event);
|
||||
*/
|
||||
esp_err_t esp_event_process_default(system_event_t *event);
|
||||
|
||||
/**
|
||||
* @brief Install default event handlers for Ethernet interface
|
||||
*
|
||||
*/
|
||||
void esp_event_set_default_eth_handlers();
|
||||
|
||||
/**
|
||||
* @brief Install default event handlers for Wi-Fi interfaces (station and AP)
|
||||
*
|
||||
*/
|
||||
void esp_event_set_default_wifi_handlers();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ typedef intr_handle_data_t* intr_handle_t ;
|
||||
esp_err_t esp_intr_mark_shared(int intno, int cpu, bool is_in_iram);
|
||||
|
||||
/**
|
||||
* @brief Reserve an interrupt to be used outside of this framewoek
|
||||
* @brief Reserve an interrupt to be used outside of this framework
|
||||
*
|
||||
* This will mark a certain interrupt on the specified CPU as
|
||||
* reserved, not to be allocated for any reason.
|
||||
@ -197,6 +197,11 @@ esp_err_t esp_intr_alloc_intrstatus(int source, int flags, uint32_t intrstatusre
|
||||
* Use an interrupt handle to disable the interrupt and release the resources
|
||||
* associated with it.
|
||||
*
|
||||
* @note
|
||||
* When the handler shares its source with other handlers, the interrupt status
|
||||
* bits it's responsible for should be managed properly before freeing it. see
|
||||
* ``esp_intr_disable`` for more details.
|
||||
*
|
||||
* @param handle The handle, as obtained by esp_intr_alloc or esp_intr_alloc_intrstatus
|
||||
*
|
||||
* @return ESP_ERR_INVALID_ARG if handle is invalid, or esp_intr_free runs on another core than
|
||||
@ -227,8 +232,13 @@ int esp_intr_get_intno(intr_handle_t handle);
|
||||
/**
|
||||
* @brief Disable the interrupt associated with the handle
|
||||
*
|
||||
* @note For local interrupts (ESP_INTERNAL_* sources), this function has to be called on the
|
||||
* CPU the interrupt is allocated on. Other interrupts have no such restriction.
|
||||
* @note
|
||||
* 1. For local interrupts (ESP_INTERNAL_* sources), this function has to be called on the
|
||||
* CPU the interrupt is allocated on. Other interrupts have no such restriction.
|
||||
* 2. When several handlers sharing a same interrupt source, interrupt status bits, which are
|
||||
* handled in the handler to be disabled, should be masked before the disabling, or handled
|
||||
* in other enabled interrupts properly. Miss of interrupt status handling will cause infinite
|
||||
* interrupt calls and finally system crash.
|
||||
*
|
||||
* @param handle The handle, as obtained by esp_intr_alloc or esp_intr_alloc_intrstatus
|
||||
*
|
||||
|
301
tools/sdk/include/esp32/esp_sleep.h
Normal file
301
tools/sdk/include/esp32/esp_sleep.h
Normal file
@ -0,0 +1,301 @@
|
||||
// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/touch_pad.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Logic function used for EXT1 wakeup mode.
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_EXT1_WAKEUP_ALL_LOW = 0, //!< Wake the chip when all selected GPIOs go low
|
||||
ESP_EXT1_WAKEUP_ANY_HIGH = 1 //!< Wake the chip when any of the selected GPIOs go high
|
||||
} esp_sleep_ext1_wakeup_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Power domains which can be powered down in sleep mode
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_PD_DOMAIN_RTC_PERIPH, //!< RTC IO, sensors and ULP co-processor
|
||||
ESP_PD_DOMAIN_RTC_SLOW_MEM, //!< RTC slow memory
|
||||
ESP_PD_DOMAIN_RTC_FAST_MEM, //!< RTC fast memory
|
||||
ESP_PD_DOMAIN_MAX //!< Number of domains
|
||||
} esp_sleep_pd_domain_t;
|
||||
|
||||
/**
|
||||
* @brief Power down options
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_PD_OPTION_OFF, //!< Power down the power domain in sleep mode
|
||||
ESP_PD_OPTION_ON, //!< Keep power domain enabled during sleep mode
|
||||
ESP_PD_OPTION_AUTO //!< Keep power domain enabled in sleep mode, if it is needed by one of the wakeup options. Otherwise power it down.
|
||||
} esp_sleep_pd_option_t;
|
||||
|
||||
/**
|
||||
* @brief Sleep wakeup cause
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_SLEEP_WAKEUP_UNDEFINED, //! In case of deep sleep, reset was not caused by exit from deep sleep
|
||||
ESP_SLEEP_WAKEUP_EXT0, //! Wakeup caused by external signal using RTC_IO
|
||||
ESP_SLEEP_WAKEUP_EXT1, //! Wakeup caused by external signal using RTC_CNTL
|
||||
ESP_SLEEP_WAKEUP_TIMER, //! Wakeup caused by timer
|
||||
ESP_SLEEP_WAKEUP_TOUCHPAD, //! Wakeup caused by touchpad
|
||||
ESP_SLEEP_WAKEUP_ULP, //! Wakeup caused by ULP program
|
||||
} esp_sleep_wakeup_cause_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Enable wakeup by ULP coprocessor
|
||||
* @note In revisions 0 and 1 of the ESP32, ULP wakeup source
|
||||
* can not be used when RTC_PERIPH power domain is forced
|
||||
* to be powered on (ESP_PD_OPTION_ON) or when ext0 wakeup
|
||||
* source is used.
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_STATE if ULP co-processor is not enabled or if wakeup triggers conflict
|
||||
*/
|
||||
esp_err_t esp_sleep_enable_ulp_wakeup();
|
||||
|
||||
/**
|
||||
* @brief Enable wakeup by timer
|
||||
* @param time_in_us time before wakeup, in microseconds
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if value is out of range (TBD)
|
||||
*/
|
||||
esp_err_t esp_sleep_enable_timer_wakeup(uint64_t time_in_us);
|
||||
|
||||
/**
|
||||
* @brief Enable wakeup by touch sensor
|
||||
*
|
||||
* @note In revisions 0 and 1 of the ESP32, touch wakeup source
|
||||
* can not be used when RTC_PERIPH power domain is forced
|
||||
* to be powered on (ESP_PD_OPTION_ON) or when ext0 wakeup
|
||||
* source is used.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_STATE if wakeup triggers conflict
|
||||
*/
|
||||
esp_err_t esp_sleep_enable_touchpad_wakeup();
|
||||
|
||||
/**
|
||||
* @brief Get the touch pad which caused wakeup
|
||||
*
|
||||
* If wakeup was caused by another source, this function will return TOUCH_PAD_MAX;
|
||||
*
|
||||
* @return touch pad which caused wakeup
|
||||
*/
|
||||
touch_pad_t esp_sleep_get_touchpad_wakeup_status();
|
||||
|
||||
/**
|
||||
* @brief Enable wakeup using a pin
|
||||
*
|
||||
* This function uses external wakeup feature of RTC_IO peripheral.
|
||||
* It will work only if RTC peripherals are kept on during sleep.
|
||||
*
|
||||
* This feature can monitor any pin which is an RTC IO. Once the pin transitions
|
||||
* into the state given by level argument, the chip will be woken up.
|
||||
*
|
||||
* @note This function does not modify pin configuration. The pin is
|
||||
* configured in esp_sleep_start, immediately before entering sleep mode.
|
||||
*
|
||||
* @note In revisions 0 and 1 of the ESP32, ext0 wakeup source
|
||||
* can not be used together with touch or ULP wakeup sources.
|
||||
*
|
||||
* @param gpio_num GPIO number used as wakeup source. Only GPIOs which are have RTC
|
||||
* functionality can be used: 0,2,4,12-15,25-27,32-39.
|
||||
* @param level input level which will trigger wakeup (0=low, 1=high)
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if the selected GPIO is not an RTC GPIO,
|
||||
* or the mode is invalid
|
||||
* - ESP_ERR_INVALID_STATE if wakeup triggers conflict
|
||||
*/
|
||||
esp_err_t esp_sleep_enable_ext0_wakeup(gpio_num_t gpio_num, int level);
|
||||
|
||||
/**
|
||||
* @brief Enable wakeup using multiple pins
|
||||
*
|
||||
* This function uses external wakeup feature of RTC controller.
|
||||
* It will work even if RTC peripherals are shut down during sleep.
|
||||
*
|
||||
* This feature can monitor any number of pins which are in RTC IOs.
|
||||
* Once any of the selected pins goes into the state given by mode argument,
|
||||
* the chip will be woken up.
|
||||
*
|
||||
* @note This function does not modify pin configuration. The pins are
|
||||
* configured in esp_sleep_start, immediately before
|
||||
* entering sleep mode.
|
||||
*
|
||||
* @note internal pullups and pulldowns don't work when RTC peripherals are
|
||||
* shut down. In this case, external resistors need to be added.
|
||||
* Alternatively, RTC peripherals (and pullups/pulldowns) may be
|
||||
* kept enabled using esp_sleep_pd_config function.
|
||||
*
|
||||
* @param mask bit mask of GPIO numbers which will cause wakeup. Only GPIOs
|
||||
* which are have RTC functionality can be used in this bit map:
|
||||
* 0,2,4,12-15,25-27,32-39.
|
||||
* @param mode select logic function used to determine wakeup condition:
|
||||
* - ESP_EXT1_WAKEUP_ALL_LOW: wake up when all selected GPIOs are low
|
||||
* - ESP_EXT1_WAKEUP_ANY_HIGH: wake up when any of the selected GPIOs is high
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if any of the selected GPIOs is not an RTC GPIO,
|
||||
* or mode is invalid
|
||||
*/
|
||||
esp_err_t esp_sleep_enable_ext1_wakeup(uint64_t mask, esp_sleep_ext1_wakeup_mode_t mode);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the bit mask of GPIOs which caused wakeup (ext1)
|
||||
*
|
||||
* If wakeup was caused by another source, this function will return 0.
|
||||
*
|
||||
* @return bit mask, if GPIOn caused wakeup, BIT(n) will be set
|
||||
*/
|
||||
uint64_t esp_sleep_get_ext1_wakeup_status();
|
||||
|
||||
/**
|
||||
* @brief Set power down mode for an RTC power domain in sleep mode
|
||||
*
|
||||
* If not set set using this API, all power domains default to ESP_PD_OPTION_AUTO.
|
||||
*
|
||||
* @param domain power domain to configure
|
||||
* @param option power down option (ESP_PD_OPTION_OFF, ESP_PD_OPTION_ON, or ESP_PD_OPTION_AUTO)
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if either of the arguments is out of range
|
||||
*/
|
||||
esp_err_t esp_sleep_pd_config(esp_sleep_pd_domain_t domain,
|
||||
esp_sleep_pd_option_t option);
|
||||
|
||||
/**
|
||||
* @brief Enter deep sleep with the configured wakeup options
|
||||
*
|
||||
* This function does not return.
|
||||
*/
|
||||
void esp_deep_sleep_start() __attribute__((noreturn));
|
||||
|
||||
/**
|
||||
* @brief Enter light sleep with the configured wakeup options
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success (returned after wakeup)
|
||||
* - ESP_ERR_INVALID_STATE if WiFi or BT is not stopped
|
||||
*/
|
||||
esp_err_t esp_light_sleep_start();
|
||||
|
||||
/**
|
||||
* @brief Enter deep-sleep mode
|
||||
*
|
||||
* The device will automatically wake up after the deep-sleep time
|
||||
* Upon waking up, the device calls deep sleep wake stub, and then proceeds
|
||||
* to load application.
|
||||
*
|
||||
* Call to this function is equivalent to a call to esp_deep_sleep_enable_timer_wakeup
|
||||
* followed by a call to esp_deep_sleep_start.
|
||||
*
|
||||
* esp_deep_sleep does not shut down WiFi, BT, and higher level protocol
|
||||
* connections gracefully.
|
||||
* Make sure relevant WiFi and BT stack functions are called to close any
|
||||
* connections and deinitialize the peripherals. These include:
|
||||
* - esp_bluedroid_disable
|
||||
* - esp_bt_controller_disable
|
||||
* - esp_wifi_stop
|
||||
*
|
||||
* This function does not return.
|
||||
*
|
||||
* @param time_in_us deep-sleep time, unit: microsecond
|
||||
*/
|
||||
void esp_deep_sleep(uint64_t time_in_us) __attribute__((noreturn));
|
||||
|
||||
/**
|
||||
* @brief Enter deep-sleep mode
|
||||
*
|
||||
* Function has been renamed to esp_deep_sleep.
|
||||
* This name is deprecated and will be removed in a future version.
|
||||
*
|
||||
* @param time_in_us deep-sleep time, unit: microsecond
|
||||
*/
|
||||
void system_deep_sleep(uint64_t time_in_us) __attribute__((noreturn, deprecated));
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the source which caused wakeup from sleep
|
||||
*
|
||||
* @return wakeup cause, or ESP_DEEP_SLEEP_WAKEUP_UNDEFINED if reset happened for reason other than deep sleep wakeup
|
||||
*/
|
||||
esp_sleep_wakeup_cause_t esp_sleep_get_wakeup_cause();
|
||||
|
||||
|
||||
/**
|
||||
* @brief Default stub to run on wake from deep sleep.
|
||||
*
|
||||
* Allows for executing code immediately on wake from sleep, before
|
||||
* the software bootloader or ESP-IDF app has started up.
|
||||
*
|
||||
* This function is weak-linked, so you can implement your own version
|
||||
* to run code immediately when the chip wakes from
|
||||
* sleep.
|
||||
*
|
||||
* See docs/deep-sleep-stub.rst for details.
|
||||
*/
|
||||
void esp_wake_deep_sleep(void);
|
||||
|
||||
/**
|
||||
* @brief Function type for stub to run on wake from sleep.
|
||||
*
|
||||
*/
|
||||
typedef void (*esp_deep_sleep_wake_stub_fn_t)(void);
|
||||
|
||||
/**
|
||||
* @brief Install a new stub at runtime to run on wake from deep sleep
|
||||
*
|
||||
* If implementing esp_wake_deep_sleep() then it is not necessary to
|
||||
* call this function.
|
||||
*
|
||||
* However, it is possible to call this function to substitute a
|
||||
* different deep sleep stub. Any function used as a deep sleep stub
|
||||
* must be marked RTC_IRAM_ATTR, and must obey the same rules given
|
||||
* for esp_wake_deep_sleep().
|
||||
*/
|
||||
void esp_set_deep_sleep_wake_stub(esp_deep_sleep_wake_stub_fn_t new_stub);
|
||||
|
||||
/**
|
||||
* @brief Get current wake from deep sleep stub
|
||||
* @return Return current wake from deep sleep stub, or NULL if
|
||||
* no stub is installed.
|
||||
*/
|
||||
esp_deep_sleep_wake_stub_fn_t esp_get_deep_sleep_wake_stub(void);
|
||||
|
||||
/**
|
||||
* @brief The default esp-idf-provided esp_wake_deep_sleep() stub.
|
||||
*
|
||||
* See docs/deep-sleep-stub.rst for details.
|
||||
*/
|
||||
void esp_default_wake_deep_sleep(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
61
tools/sdk/include/esp32/esp_spiram.h
Normal file
61
tools/sdk/include/esp32/esp_spiram.h
Normal file
@ -0,0 +1,61 @@
|
||||
// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
|
||||
#ifndef __ESP_SPIRAM_H
|
||||
#define __ESP_SPIRAM_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
/**
|
||||
* @brief Initialize spiram interface/hardware. Normally called from cpu_start.c.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_spiram_init();
|
||||
|
||||
|
||||
/**
|
||||
* @brief Memory test for SPI RAM. Should be called after SPI RAM is initialized and
|
||||
* (in case of a dual-core system) the app CPU is online. This test overwrites the
|
||||
* memory with crap, so do not call after e.g. the heap allocator has stored important
|
||||
* stuff in SPI RAM.
|
||||
*
|
||||
* @return true on success, false on failed memory test
|
||||
*/
|
||||
bool esp_spiram_test();
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the size of the attached SPI RAM chip selected in menuconfig
|
||||
*
|
||||
* @return Size in bytes, or 0 if no external RAM chip support compiled in.
|
||||
*/
|
||||
size_t esp_spiram_get_size();
|
||||
|
||||
|
||||
/**
|
||||
* @brief Force a writeback of the data in the SPI RAM cache. This is to be called whenever
|
||||
* cache is disabled, because disabling cache on the ESP32 discards the data in the SPI
|
||||
* RAM cache.
|
||||
*
|
||||
* This is meant for use from within the SPI flash code.
|
||||
*/
|
||||
void esp_spiram_writeback_cache();
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -18,7 +18,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_deep_sleep.h"
|
||||
#include "esp_sleep.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -49,6 +49,15 @@ void system_init(void) __attribute__ ((deprecated));
|
||||
*/
|
||||
void system_restore(void) __attribute__ ((deprecated));
|
||||
|
||||
typedef void (*shutdown_handler_t)(void);
|
||||
/**
|
||||
* @brief Register shutdown handler
|
||||
*
|
||||
* This function allows you to register a handler that gets invoked before a
|
||||
* systematic shutdown of the chip.
|
||||
*/
|
||||
esp_err_t esp_register_shutdown_handler(shutdown_handler_t handle);
|
||||
|
||||
/**
|
||||
* @brief Restart PRO and APP CPUs.
|
||||
*
|
||||
|
@ -43,6 +43,8 @@
|
||||
|
||||
|
||||
/* idf task */
|
||||
#define ESP_TASK_TIMER_PRIO (ESP_TASK_PRIO_MAX - 3)
|
||||
#define ESP_TASK_TIMER_STACK CONFIG_TIMER_TASK_STACK_SIZE
|
||||
#define ESP_TASKD_EVENT_PRIO (ESP_TASK_PRIO_MAX - 5)
|
||||
#define ESP_TASKD_EVENT_STACK CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE
|
||||
#define ESP_TASK_TCPIP_PRIO (ESP_TASK_PRIO_MAX - 7)
|
||||
|
@ -144,7 +144,15 @@ typedef struct {
|
||||
extern const wpa_crypto_funcs_t g_wifi_default_wpa_crypto_funcs;
|
||||
|
||||
#define WIFI_INIT_CONFIG_MAGIC 0x1F2F3F4F
|
||||
#ifdef CONFIG_WIFI_ENABLED
|
||||
|
||||
#ifdef CONFIG_ESP32_WIFI_AMPDU_ENABLED
|
||||
#define WIFI_DEFAULT_TX_BA_WIN CONFIG_ESP32_WIFI_TX_BA_WIN
|
||||
#define WIFI_DEFAULT_RX_BA_WIN CONFIG_ESP32_WIFI_RX_BA_WIN
|
||||
#else
|
||||
#define WIFI_DEFAULT_TX_BA_WIN 0 /* unused if ampdu_enable == false */
|
||||
#define WIFI_DEFAULT_RX_BA_WIN 0
|
||||
#endif
|
||||
|
||||
#define WIFI_INIT_CONFIG_DEFAULT() { \
|
||||
.event_handler = &esp_event_send, \
|
||||
.wpa_crypto_funcs = g_wifi_default_wpa_crypto_funcs, \
|
||||
@ -156,13 +164,10 @@ extern const wpa_crypto_funcs_t g_wifi_default_wpa_crypto_funcs;
|
||||
.ampdu_enable = WIFI_AMPDU_ENABLED,\
|
||||
.nvs_enable = WIFI_NVS_ENABLED,\
|
||||
.nano_enable = WIFI_NANO_FORMAT_ENABLED,\
|
||||
.tx_ba_win = CONFIG_ESP32_WIFI_TX_BA_WIN,\
|
||||
.rx_ba_win = CONFIG_ESP32_WIFI_RX_BA_WIN,\
|
||||
.tx_ba_win = WIFI_DEFAULT_TX_BA_WIN,\
|
||||
.rx_ba_win = WIFI_DEFAULT_RX_BA_WIN,\
|
||||
.magic = WIFI_INIT_CONFIG_MAGIC\
|
||||
};
|
||||
#else
|
||||
#define WIFI_INIT_CONFIG_DEFAULT() {0}; _Static_assert(0, "please enable wifi in menuconfig to use esp_wifi.h");
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Init WiFi
|
||||
|
@ -40,6 +40,26 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Initialize Wi-Fi Driver
|
||||
* Alloc resource for WiFi driver, such as WiFi control structure, RX/TX buffer,
|
||||
* WiFi NVS structure among others.
|
||||
*
|
||||
* For the most part, you need not call this function directly. It gets called
|
||||
* from esp_wifi_init().
|
||||
*
|
||||
* This function may be called, if you only need to initialize the Wi-Fi driver
|
||||
* without having to use the network stack on top.
|
||||
*
|
||||
* @param config provide WiFi init configuration
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - ESP_ERR_WIFI_NO_MEM: out of memory
|
||||
* - others: refer to error code esp_err.h
|
||||
*/
|
||||
esp_err_t esp_wifi_init_internal(wifi_init_config_t *config);
|
||||
|
||||
/**
|
||||
* @brief get whether the wifi driver is allowed to transmit data or not
|
||||
*
|
||||
|
@ -38,11 +38,6 @@ extern "C" {
|
||||
#define ERR_ESP_AES_INVALID_KEY_LENGTH -0x0020 /**< Invalid key length. */
|
||||
#define ERR_ESP_AES_INVALID_INPUT_LENGTH -0x0022 /**< Invalid data input length. */
|
||||
|
||||
typedef struct {
|
||||
enum AES_BITS aesbits;
|
||||
uint8_t key[32];
|
||||
} key_context, KEY_CTX;
|
||||
|
||||
/**
|
||||
* \brief AES context structure
|
||||
*
|
||||
@ -52,10 +47,8 @@ typedef struct {
|
||||
* generating an extra round key
|
||||
*/
|
||||
typedef struct {
|
||||
int nr; /*!< number of rounds */
|
||||
uint32_t *rk; /*!< AES round keys */
|
||||
KEY_CTX enc;
|
||||
KEY_CTX dec;
|
||||
uint8_t key_bytes;
|
||||
uint8_t key[32];
|
||||
} esp_aes_context;
|
||||
|
||||
/**
|
||||
@ -94,7 +87,7 @@ void esp_aes_init( esp_aes_context *ctx );
|
||||
void esp_aes_free( esp_aes_context *ctx );
|
||||
|
||||
/**
|
||||
* \brief AES key schedule (encryption)
|
||||
* \brief AES set key schedule (encryption or decryption)
|
||||
*
|
||||
* \param ctx AES context to be initialized
|
||||
* \param key encryption key
|
||||
@ -102,18 +95,7 @@ void esp_aes_free( esp_aes_context *ctx );
|
||||
*
|
||||
* \return 0 if successful, or ERR_AES_INVALID_KEY_LENGTH
|
||||
*/
|
||||
int esp_aes_setkey_enc( esp_aes_context *ctx, const unsigned char *key, unsigned int keybits );
|
||||
|
||||
/**
|
||||
* \brief AES key schedule (decryption)
|
||||
*
|
||||
* \param ctx AES context to be initialized
|
||||
* \param key decryption key
|
||||
* \param keybits must be 128, 192 or 256
|
||||
*
|
||||
* \return 0 if successful, or ERR_AES_INVALID_KEY_LENGTH
|
||||
*/
|
||||
int esp_aes_setkey_dec( esp_aes_context *ctx, const unsigned char *key, unsigned int keybits );
|
||||
int esp_aes_setkey( esp_aes_context *ctx, const unsigned char *key, unsigned int keybits );
|
||||
|
||||
/**
|
||||
* \brief AES-ECB block encryption/decryption
|
||||
|
@ -267,7 +267,7 @@ void uart_tx_flush(uint8_t uart_no);
|
||||
* The function defined in ROM code has a bug, so we define the correct version
|
||||
* here for compatibility.
|
||||
*/
|
||||
static inline void uart_tx_wait_idle(uint8_t uart_no) {
|
||||
static inline void IRAM_ATTR uart_tx_wait_idle(uint8_t uart_no) {
|
||||
while(REG_GET_FIELD(UART_STATUS_REG(uart_no), UART_ST_UTX_OUT)) {
|
||||
;
|
||||
}
|
||||
|
153
tools/sdk/include/esp_adc_cal/esp_adc_cal.h
Normal file
153
tools/sdk/include/esp_adc_cal/esp_adc_cal.h
Normal file
@ -0,0 +1,153 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __ESP_ADC_CAL_H__
|
||||
#define __ESP_ADC_CAL_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include "driver/adc.h"
|
||||
|
||||
/** @cond */
|
||||
#define ADC_CAL_GAIN_SCALE 16
|
||||
#define ADC_CAL_OFFSET_SCALE 10
|
||||
|
||||
#define ADC_CAL_IDEAL_V_REF 1100 //In mV
|
||||
#define ADC_CAL_LOW_V_REF 1000
|
||||
#define ADC_CAL_HIGH_V_REF 1200
|
||||
#define ADC_CAL_MIN 0
|
||||
#define ADC_CAL_MAX 4095
|
||||
/** @endcond */
|
||||
|
||||
/**
|
||||
* @brief Structure storing Lookup Table
|
||||
*
|
||||
* The Lookup Tables (LUT) of a given attenuation contains 33 equally spaced
|
||||
* points. The Gain and Offset curves are used to find the appopriate gain and
|
||||
* offset factor given a reference voltage v_ref.
|
||||
*
|
||||
* @note A seperate LUT is provided for each attenuation and are defined in
|
||||
* esp_adc_cal_lookup_tables.c
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t gain_m; /**<Gradient of Gain Curve */
|
||||
uint32_t gain_c; /**<Offset of Gain Curve */
|
||||
uint32_t offset_m; /**<Gradient of Offset Curve */
|
||||
uint32_t offset_c; /**<Offset of Offset Curve */
|
||||
uint32_t bit_shift; /**<Bit shift used find corresponding LUT points
|
||||
given an ADC reading*/
|
||||
uint32_t voltage[]; /**<Array of voltages in mV representing the
|
||||
ADC-Voltage curve */
|
||||
} esp_adc_cal_lookup_table_t;
|
||||
|
||||
/**
|
||||
* @brief Structure storing ADC characteristics of given v_ref
|
||||
*
|
||||
* The ADC Characteristics structure stores the gain and offset factors of an
|
||||
* ESP32 module's ADC. These factors are calculated using the reference voltage,
|
||||
* and the Gain and Offset curves provided in the lookup tables.
|
||||
*
|
||||
* @note Call esp_adc_cal_get_characteristics() to initialize the structure
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t v_ref; /**<Reference Voltage of current ESP32 Module in mV*/
|
||||
uint32_t gain; /**<Scaling factor used to correct LUT voltages to
|
||||
current v_ref. Bit shifted by << ADC_CAL_GAIN_SCALE
|
||||
for uint32 arithmetic */
|
||||
uint32_t offset; /**<Offset in mV used to correct LUT Voltages to current v_ref */
|
||||
uint32_t ideal_offset; /**<Offset in mV at the ideal reference voltage */
|
||||
adc_bits_width_t bit_width; /**<Bit width of ADC e.g. ADC_WIDTH_12Bit */
|
||||
const esp_adc_cal_lookup_table_t *table; /**<Pointer to LUT */
|
||||
} esp_adc_cal_characteristics_t;
|
||||
|
||||
extern const esp_adc_cal_lookup_table_t esp_adc_cal_table_atten_0; /**<LUT for atten0 */
|
||||
extern const esp_adc_cal_lookup_table_t esp_adc_cal_table_atten_1; /**<LUT for atten1 */
|
||||
extern const esp_adc_cal_lookup_table_t esp_adc_cal_table_atten_2; /**<LUT for atten2 */
|
||||
extern const esp_adc_cal_lookup_table_t esp_adc_cal_table_atten_3; /**<LUT for atten3 */
|
||||
|
||||
/**
|
||||
* @brief Calculate characteristics of ADC
|
||||
*
|
||||
* This function will calculate the gain and offset factors based on the
|
||||
* reference voltage parameter and the Gain and Offset curve provided in the LUT.
|
||||
*
|
||||
* @note reference voltage of the ADCs can be routed to GPIO using
|
||||
* adc2_vref_to_gpio() from the ADC driver
|
||||
*
|
||||
* @note The LUT members have been bit shifted by ADC_CAL_GAIN_SCALE or
|
||||
* ADC_CAL_OFFSET_SCALE to make them uint32_t compatible. This bit shifting will
|
||||
* accounted for in this function
|
||||
*
|
||||
* @param[in] v_ref true reference voltage of the ADC in mV (1000 to 1200mV). Nominal
|
||||
* value for reference voltage is 1100mV.
|
||||
* @param[in] atten attenuation setting used to select the corresponding lookup table
|
||||
* @param[in] bit_width bit width of ADC
|
||||
* @param[out] chars pointer to structure used to store ADC characteristics of module
|
||||
*/
|
||||
void esp_adc_cal_get_characteristics(uint32_t v_ref,
|
||||
adc_atten_t atten,
|
||||
adc_bits_width_t bit_width,
|
||||
esp_adc_cal_characteristics_t *chars);
|
||||
|
||||
/**
|
||||
* @brief Convert raw ADC reading to voltage in mV
|
||||
*
|
||||
* This function converts a raw ADC reading to a voltage in mV. This conversion
|
||||
* is based on the ADC's characteristics. The raw ADC reading is referenced
|
||||
* against the LUT (pointed to inside characteristics struct) to obtain a voltage.
|
||||
* Gain and offset factors are then applied to the voltage in order to obtain
|
||||
* the final result.
|
||||
*
|
||||
* @param[in] adc ADC reading (different bit widths will be handled)
|
||||
* @param[in] chars pointer to structure containing ADC characteristics of
|
||||
* the module. Structure also contains pointer to the
|
||||
* corresponding LUT
|
||||
*
|
||||
* @return Calculated voltage in mV
|
||||
*
|
||||
* @note characteristics structure must be initialized using
|
||||
* esp_adc_cal_get_characteristics() before this function is used
|
||||
*/
|
||||
uint32_t esp_adc_cal_raw_to_voltage(uint32_t adc,
|
||||
const esp_adc_cal_characteristics_t *chars);
|
||||
|
||||
/**
|
||||
* @brief Reads ADC1 and returns voltage in mV
|
||||
*
|
||||
* This function reads the ADC1 using adc1_get_raw() to obtain a raw ADC
|
||||
* reading. The reading is then converted into a voltage value using
|
||||
* esp_adc_cal_raw_to_voltage().
|
||||
*
|
||||
* @param[in] channel Channel of ADC1 to measure
|
||||
* @param[in] chars Pointer to ADC characteristics struct
|
||||
*
|
||||
* @return voltage Calculated voltage in mV
|
||||
*
|
||||
* @note ADC must be initialized using adc1_config_width() and
|
||||
* adc1_config_channel_atten() before this function is used
|
||||
*
|
||||
* @note characteristics structure must be initialized using
|
||||
* esp_adc_cal_get_characteristics() before this function is used
|
||||
*/
|
||||
uint32_t adc1_to_voltage(adc1_channel_t channel, const esp_adc_cal_characteristics_t *chars);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_ADC_CAL_H__ */
|
@ -117,6 +117,24 @@ typedef struct {
|
||||
*/
|
||||
esp_err_t esp_eth_init(eth_config_t *config);
|
||||
|
||||
/**
|
||||
* @brief Init Ethernet mac driver only
|
||||
*
|
||||
* For the most part, you need not call this function directly. It gets called
|
||||
* from esp_eth_init().
|
||||
*
|
||||
* This function may be called, if you only need to initialize the Ethernet
|
||||
* driver without having to use the network stack on top.
|
||||
*
|
||||
* @note config can not be NULL,and phy chip must be suitable to phy init func.
|
||||
* @param[in] config mac init data.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_eth_init_internal(eth_config_t *config);
|
||||
|
||||
/**
|
||||
* @brief Send packet from tcp/ip to mac
|
||||
*
|
||||
|
@ -189,11 +189,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef INCLUDE_pcTaskGetTaskName
|
||||
#if ( configENABLE_MEMORY_DEBUG == 1)
|
||||
#define INCLUDE_pcTaskGetTaskName 1
|
||||
#else
|
||||
#define INCLUDE_pcTaskGetTaskName 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef configUSE_APPLICATION_TASK_TAG
|
||||
@ -978,13 +974,14 @@ typedef struct xSTATIC_QUEUE
|
||||
uint8_t ucDummy9;
|
||||
#endif
|
||||
|
||||
struct {
|
||||
volatile uint32_t ucDummy10;
|
||||
#ifdef CONFIG_FREERTOS_PORTMUX_DEBUG
|
||||
void *pvDummy8;
|
||||
UBaseType_t uxDummy11;
|
||||
#endif
|
||||
} sDummy12;
|
||||
struct {
|
||||
volatile uint32_t ucDummy10;
|
||||
uint32_t ucDummy11;
|
||||
#ifdef CONFIG_FREERTOS_PORTMUX_DEBUG
|
||||
void *pvDummy8;
|
||||
UBaseType_t uxDummy12;
|
||||
#endif
|
||||
} sDummy1;
|
||||
|
||||
} StaticQueue_t;
|
||||
typedef StaticQueue_t StaticSemaphore_t;
|
||||
|
@ -231,12 +231,6 @@
|
||||
#define INCLUDE_pcTaskGetTaskName 1
|
||||
#define INCLUDE_xTaskGetIdleTaskHandle 1
|
||||
|
||||
#if CONFIG_ENABLE_MEMORY_DEBUG
|
||||
#define configENABLE_MEMORY_DEBUG 1
|
||||
#else
|
||||
#define configENABLE_MEMORY_DEBUG 0
|
||||
#endif
|
||||
|
||||
#define INCLUDE_xSemaphoreGetMutexHolder 1
|
||||
|
||||
/* The priority at which the tick interrupt runs. This should probably be
|
||||
|
@ -123,6 +123,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include "mpu_wrappers.h"
|
||||
#include "esp_system.h"
|
||||
|
||||
/*
|
||||
* Setup the stack of a new task so it is ready to be placed under the
|
||||
@ -143,11 +144,10 @@ extern "C" {
|
||||
* non-FreeRTOS-specific code, and behave the same as
|
||||
* pvPortMalloc()/vPortFree().
|
||||
*/
|
||||
void *pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION;
|
||||
void vPortFree( void *pv ) PRIVILEGED_FUNCTION;
|
||||
void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION;
|
||||
size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION;
|
||||
size_t xPortGetMinimumEverFreeHeapSize( void ) PRIVILEGED_FUNCTION;
|
||||
#define pvPortMalloc malloc
|
||||
#define vPortFree free
|
||||
#define xPortGetFreeHeapSize esp_get_free_heap_size
|
||||
#define xPortGetMinimumEverFreeHeapSize esp_get_minimum_free_heap_size
|
||||
|
||||
/*
|
||||
* Setup the hardware ready for the scheduler to take control. This generally
|
||||
@ -197,9 +197,9 @@ BaseType_t xPortInIsrContext();
|
||||
#endif
|
||||
|
||||
/* Multi-core: get current core ID */
|
||||
static inline uint32_t xPortGetCoreID() {
|
||||
static inline uint32_t IRAM_ATTR xPortGetCoreID() {
|
||||
int id;
|
||||
asm volatile(
|
||||
asm (
|
||||
"rsr.prid %0\n"
|
||||
" extui %0,%0,13,1"
|
||||
:"=r"(id));
|
||||
|
@ -121,12 +121,14 @@ typedef unsigned portBASE_TYPE UBaseType_t;
|
||||
#include "portbenchmark.h"
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_attr.h"
|
||||
|
||||
#define portFIRST_TASK_HOOK CONFIG_FREERTOS_BREAK_ON_SCHEDULER_START_JTAG
|
||||
|
||||
|
||||
typedef struct {
|
||||
volatile uint32_t mux;
|
||||
uint32_t owner;
|
||||
uint32_t count;
|
||||
#ifdef CONFIG_FREERTOS_PORTMUX_DEBUG
|
||||
const char *lastLockedFn;
|
||||
int lastLockedLine;
|
||||
@ -142,24 +144,23 @@ typedef struct {
|
||||
* The magic number in the top 16 bits is there so we can detect uninitialized and corrupted muxes.
|
||||
*/
|
||||
|
||||
#define portMUX_MAGIC_VAL 0xB33F0000
|
||||
#define portMUX_FREE_VAL 0xB33FFFFF
|
||||
#define portMUX_MAGIC_MASK 0xFFFF0000
|
||||
#define portMUX_MAGIC_SHIFT 16
|
||||
#define portMUX_CNT_MASK 0x0000FF00
|
||||
#define portMUX_CNT_SHIFT 8
|
||||
#define portMUX_VAL_MASK 0x000000FF
|
||||
#define portMUX_VAL_SHIFT 0
|
||||
|
||||
/* Special constants for vPortCPUAcquireMutexTimeout() */
|
||||
#define portMUX_NO_TIMEOUT (-1) /* When passed for 'timeout_cycles', spin forever if necessary */
|
||||
#define portMUX_TRY_LOCK 0 /* Try to acquire the spinlock a single time only */
|
||||
|
||||
//Keep this in sync with the portMUX_TYPE struct definition please.
|
||||
#ifndef CONFIG_FREERTOS_PORTMUX_DEBUG
|
||||
#define portMUX_INITIALIZER_UNLOCKED { \
|
||||
.mux = portMUX_MAGIC_VAL|portMUX_FREE_VAL \
|
||||
#define portMUX_INITIALIZER_UNLOCKED { \
|
||||
.owner = portMUX_FREE_VAL, \
|
||||
.count = 0, \
|
||||
}
|
||||
#else
|
||||
#define portMUX_INITIALIZER_UNLOCKED { \
|
||||
.mux = portMUX_MAGIC_VAL|portMUX_FREE_VAL, \
|
||||
.lastLockedFn = "(never locked)", \
|
||||
#define portMUX_INITIALIZER_UNLOCKED { \
|
||||
.owner = portMUX_FREE_VAL, \
|
||||
.count = 0, \
|
||||
.lastLockedFn = "(never locked)", \
|
||||
.lastLockedLine = -1 \
|
||||
}
|
||||
#endif
|
||||
@ -172,8 +173,7 @@ typedef struct {
|
||||
#define portASSERT_IF_IN_ISR() vPortAssertIfInISR()
|
||||
void vPortAssertIfInISR();
|
||||
|
||||
|
||||
#define portCRITICAL_NESTING_IN_TCB 1
|
||||
#define portCRITICAL_NESTING_IN_TCB 1
|
||||
|
||||
/*
|
||||
Modifications to portENTER_CRITICAL:
|
||||
@ -202,7 +202,10 @@ behaviour; please keep this in mind if you need any compatibility with other Fre
|
||||
void vPortCPUInitializeMutex(portMUX_TYPE *mux);
|
||||
#ifdef CONFIG_FREERTOS_PORTMUX_DEBUG
|
||||
void vPortCPUAcquireMutex(portMUX_TYPE *mux, const char *function, int line);
|
||||
bool vPortCPUAcquireMutexTimeout(portMUX_TYPE *mux, int timeout_cycles, const char *function, int line);
|
||||
portBASE_TYPE vPortCPUReleaseMutex(portMUX_TYPE *mux, const char *function, int line);
|
||||
|
||||
|
||||
void vTaskEnterCritical( portMUX_TYPE *mux, const char *function, int line );
|
||||
void vTaskExitCritical( portMUX_TYPE *mux, const char *function, int line );
|
||||
#define portENTER_CRITICAL(mux) vTaskEnterCritical(mux, __FUNCTION__, __LINE__)
|
||||
@ -213,7 +216,18 @@ void vTaskExitCritical( portMUX_TYPE *mux, const char *function, int line );
|
||||
void vTaskExitCritical( portMUX_TYPE *mux );
|
||||
void vTaskEnterCritical( portMUX_TYPE *mux );
|
||||
void vPortCPUAcquireMutex(portMUX_TYPE *mux);
|
||||
portBASE_TYPE vPortCPUReleaseMutex(portMUX_TYPE *mux);
|
||||
|
||||
/** @brief Acquire a portmux spinlock with a timeout
|
||||
*
|
||||
* @param mux Pointer to portmux to acquire.
|
||||
* @param timeout_cycles Timeout to spin, in CPU cycles. Pass portMUX_NO_TIMEOUT to wait forever,
|
||||
* portMUX_TRY_LOCK to try a single time to acquire the lock.
|
||||
*
|
||||
* @return true if mutex is successfully acquired, false on timeout.
|
||||
*/
|
||||
bool vPortCPUAcquireMutexTimeout(portMUX_TYPE *mux, int timeout_cycles);
|
||||
void vPortCPUReleaseMutex(portMUX_TYPE *mux);
|
||||
|
||||
#define portENTER_CRITICAL(mux) vTaskEnterCritical(mux)
|
||||
#define portEXIT_CRITICAL(mux) vTaskExitCritical(mux)
|
||||
#define portENTER_CRITICAL_ISR(mux) vTaskEnterCritical(mux)
|
||||
@ -242,9 +256,8 @@ static inline unsigned portENTER_CRITICAL_NESTED() { unsigned state = XTOS_SET_I
|
||||
* ESP32, though. (Would show up directly if it did because the magic wouldn't match.)
|
||||
*/
|
||||
static inline void uxPortCompareSet(volatile uint32_t *addr, uint32_t compare, uint32_t *set) {
|
||||
__asm__ __volatile__(
|
||||
__asm__ __volatile__ (
|
||||
"WSR %2,SCOMPARE1 \n"
|
||||
"ISYNC \n"
|
||||
"S32C1I %0, %1, 0 \n"
|
||||
:"=r"(*set)
|
||||
:"r"(addr), "r"(compare), "0"(*set)
|
||||
|
@ -314,11 +314,10 @@ STRUCT_END(XtSolFrame)
|
||||
|
||||
/*
|
||||
Macro to get the current core ID. Only uses the reg given as an argument.
|
||||
Reading PRID on the ESP108 architecture gives us 0xCDCD on the PRO processor
|
||||
and 0xABAB on the APP CPU. We distinguish between the two by simply checking
|
||||
bit 1: it's 1 on the APP and 0 on the PRO processor.
|
||||
Reading PRID on the ESP32 gives us 0xCDCD on the PRO processor (0)
|
||||
and 0xABAB on the APP CPU (1). We distinguish between the two by simply checking
|
||||
bit 13: it's 1 on the APP and 0 on the PRO processor.
|
||||
*/
|
||||
|
||||
#ifdef __ASSEMBLER__
|
||||
.macro getcoreid reg
|
||||
rsr.prid \reg
|
||||
@ -326,7 +325,8 @@ STRUCT_END(XtSolFrame)
|
||||
.endm
|
||||
#endif
|
||||
|
||||
|
||||
#define CORE_ID_PRO 0xCDCD
|
||||
#define CORE_ID_APP 0xABAB
|
||||
|
||||
/*
|
||||
-------------------------------------------------------------------------------
|
||||
|
@ -126,13 +126,17 @@ esp_err_t esp_ota_set_boot_partition(const esp_partition_t* partition);
|
||||
*
|
||||
* If esp_ota_set_boot_partition() has been called, the partition which was set by that function will be returned.
|
||||
*
|
||||
* If esp_ota_set_boot_partition() has not been called, the result is
|
||||
* equivalent to esp_ota_get_running_partition().
|
||||
* If esp_ota_set_boot_partition() has not been called, the result is usually the same as esp_ota_get_running_partition().
|
||||
* The two results are not equal if the configured boot partition does not contain a valid app (meaning that the running partition
|
||||
* will be an app that the bootloader chose via fallback).
|
||||
*
|
||||
* If the OTA data partition is not present or not valid then the result is the first app partition found in the
|
||||
* partition table. In priority order, this means: the factory app, the first OTA app slot, or the test app partition.
|
||||
*
|
||||
* Note that there is no guarantee the returned partition is a valid app. Use esp_image_load(ESP_IMAGE_VERIFY, ...) to verify if the
|
||||
* partition contains a bootable image.
|
||||
* returned partition contains a bootable image.
|
||||
*
|
||||
* @return Pointer to info for partition structure, or NULL if no partition is found or flash read operation failed. Returned pointer is valid for the lifetime of the application.
|
||||
* @return Pointer to info for partition structure, or NULL if partition table is invalid or a flash read operation failed. Any returned pointer is valid for the lifetime of the application.
|
||||
*/
|
||||
const esp_partition_t* esp_ota_get_boot_partition(void);
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user