Update IDF to 1c3dd23
* Update mDNS and LEDC * update toolchain * Update IDF to 1c3dd23 * Advertise the board variant for Arduino OTA * Add generic variant definition for mDNS
This commit is contained in:
parent
70d0d46487
commit
600f4c4130
@ -17,7 +17,7 @@
|
||||
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BLUEDROID_ENABLED)
|
||||
|
||||
|
||||
#include "bt.h"
|
||||
#include "esp_bt.h"
|
||||
#include "esp_bt_defs.h"
|
||||
#include "esp_bt_main.h"
|
||||
|
||||
|
@ -68,8 +68,8 @@ static void _ledcSetupTimer(uint8_t chan, uint32_t div_num, uint8_t bit_num, boo
|
||||
#endif
|
||||
}
|
||||
LEDC_MUTEX_LOCK();
|
||||
LEDC_TIMER(group, timer).conf.div_num = div_num;//18 bit (10.8) This register is used to configure parameter for divider in timer the least significant eight bits represent the decimal part.
|
||||
LEDC_TIMER(group, timer).conf.bit_num = bit_num;//5 bit This register controls the range of the counter in timer. the counter range is [0 2**bit_num] the max bit width for counter is 20.
|
||||
LEDC_TIMER(group, timer).conf.clock_divider = div_num;//18 bit (10.8) This register is used to configure parameter for divider in timer the least significant eight bits represent the decimal part.
|
||||
LEDC_TIMER(group, timer).conf.duty_resolution = bit_num;//5 bit This register controls the range of the counter in timer. the counter range is [0 2**bit_num] the max bit width for counter is 20.
|
||||
LEDC_TIMER(group, timer).conf.tick_sel = apb_clk;//apb clock
|
||||
if(group) {
|
||||
LEDC_TIMER(group, timer).conf.low_speed_update = 1;//This bit is only useful for low speed timer channels, reserved for high speed timers
|
||||
@ -111,8 +111,8 @@ static double _ledcTimerRead(uint8_t chan)
|
||||
bool apb_clk;
|
||||
uint8_t group=(chan/8), timer=((chan/2)%4);
|
||||
LEDC_MUTEX_LOCK();
|
||||
div_num = LEDC_TIMER(group, timer).conf.div_num;//18 bit (10.8) This register is used to configure parameter for divider in timer the least significant eight bits represent the decimal part.
|
||||
bit_num = LEDC_TIMER(group, timer).conf.bit_num;//5 bit This register controls the range of the counter in timer. the counter range is [0 2**bit_num] the max bit width for counter is 20.
|
||||
div_num = LEDC_TIMER(group, timer).conf.clock_divider;//18 bit (10.8) This register is used to configure parameter for divider in timer the least significant eight bits represent the decimal part.
|
||||
bit_num = LEDC_TIMER(group, timer).conf.duty_resolution;//5 bit This register controls the range of the counter in timer. the counter range is [0 2**bit_num] the max bit width for counter is 20.
|
||||
apb_clk = LEDC_TIMER(group, timer).conf.tick_sel;//apb clock
|
||||
LEDC_MUTEX_UNLOCK();
|
||||
uint64_t clk_freq = 1000000;
|
||||
|
@ -39,22 +39,27 @@ License (MIT license):
|
||||
#endif
|
||||
|
||||
#include "ESPmDNS.h"
|
||||
#include "WiFi.h"
|
||||
#include <functional>
|
||||
#include "esp_wifi.h"
|
||||
|
||||
MDNSResponder::MDNSResponder() : mdns(NULL), _if(TCPIP_ADAPTER_IF_STA) {}
|
||||
static void _on_sys_event(system_event_t *event){
|
||||
mdns_handle_system_event(NULL, event);
|
||||
}
|
||||
|
||||
MDNSResponder::MDNSResponder() :results(NULL) {}
|
||||
MDNSResponder::~MDNSResponder() {
|
||||
end();
|
||||
}
|
||||
|
||||
bool MDNSResponder::begin(const char* hostName, tcpip_adapter_if_t tcpip_if, uint32_t ttl){
|
||||
_if = tcpip_if;
|
||||
if(!mdns && mdns_init(_if, &mdns)){
|
||||
bool MDNSResponder::begin(const char* hostName){
|
||||
if(mdns_init()){
|
||||
log_e("Failed starting MDNS");
|
||||
return false;
|
||||
}
|
||||
WiFi.onEvent(_on_sys_event);
|
||||
_hostname = hostName;
|
||||
if(mdns_set_hostname(mdns, hostName)) {
|
||||
if(mdns_hostname_set(hostName)) {
|
||||
log_e("Failed setting MDNS hostname");
|
||||
return false;
|
||||
}
|
||||
@ -62,121 +67,182 @@ bool MDNSResponder::begin(const char* hostName, tcpip_adapter_if_t tcpip_if, uin
|
||||
}
|
||||
|
||||
void MDNSResponder::end() {
|
||||
if(!mdns){
|
||||
return;
|
||||
}
|
||||
mdns_free(mdns);
|
||||
mdns = NULL;
|
||||
mdns_free();
|
||||
}
|
||||
|
||||
void MDNSResponder::setInstanceName(String name) {
|
||||
if (name.length() > 63) return;
|
||||
if(mdns_set_instance(mdns, name.c_str())){
|
||||
if(mdns_instance_name_set(name.c_str())){
|
||||
log_e("Failed setting MDNS instance");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MDNSResponder::enableArduino(uint16_t port, bool auth){
|
||||
const char * arduTxtData[4] = {
|
||||
"board=" ARDUINO_BOARD,
|
||||
"tcp_check=no",
|
||||
"ssh_upload=no",
|
||||
"auth_upload=no"
|
||||
mdns_txt_item_t arduTxtData[4] = {
|
||||
{(char*)"board" ,(char*)ARDUINO_VARIANT},
|
||||
{(char*)"tcp_check" ,(char*)"no"},
|
||||
{(char*)"ssh_upload" ,(char*)"no"},
|
||||
{(char*)"auth_upload" ,(char*)"no"}
|
||||
};
|
||||
if(auth){
|
||||
arduTxtData[3] = "auth_upload=yes";
|
||||
|
||||
if(mdns_service_add(NULL, "_arduino", "_tcp", port, arduTxtData, 4)) {
|
||||
log_e("Failed adding Arduino service");
|
||||
}
|
||||
|
||||
if(mdns_service_add(mdns, "_arduino", "_tcp", port)) {
|
||||
log_e("Failed adding Arduino service");
|
||||
} else if(mdns_service_txt_set(mdns, "_arduino", "_tcp", 4, arduTxtData)) {
|
||||
log_e("Failed setting Arduino service TXT");
|
||||
if(auth && mdns_service_txt_item_set("_arduino", "_tcp", "auth_upload", "yes")){
|
||||
log_e("Failed setting Arduino txt item");
|
||||
}
|
||||
}
|
||||
|
||||
void MDNSResponder::disableArduino(){
|
||||
if(mdns_service_remove(mdns, "_arduino", "_tcp")) {
|
||||
if(mdns_service_remove("_arduino", "_tcp")) {
|
||||
log_w("Failed removing Arduino service");
|
||||
}
|
||||
}
|
||||
|
||||
void MDNSResponder::enableWorkstation(){
|
||||
void MDNSResponder::enableWorkstation(wifi_interface_t interface){
|
||||
char winstance[21+_hostname.length()];
|
||||
uint8_t mac[6];
|
||||
esp_wifi_get_mac((wifi_interface_t)_if, mac);
|
||||
esp_wifi_get_mac(interface, mac);
|
||||
sprintf(winstance, "%s [%02x:%02x:%02x:%02x:%02x:%02x]", _hostname.c_str(), mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
|
||||
if(mdns_service_add(mdns, "_workstation", "_tcp", 9)) {
|
||||
if(mdns_service_add(NULL, "_workstation", "_tcp", 9, NULL, 0)) {
|
||||
log_e("Failed adding Workstation service");
|
||||
} else if(mdns_service_instance_set(mdns, "_workstation", "_tcp", winstance)) {
|
||||
} else if(mdns_service_instance_name_set("_workstation", "_tcp", winstance)) {
|
||||
log_e("Failed setting Workstation service instance name");
|
||||
}
|
||||
}
|
||||
|
||||
void MDNSResponder::disableWorkstation(){
|
||||
if(mdns_service_remove(mdns, "_workstation", "_tcp")) {
|
||||
if(mdns_service_remove("_workstation", "_tcp")) {
|
||||
log_w("Failed removing Workstation service");
|
||||
}
|
||||
}
|
||||
|
||||
void MDNSResponder::addService(char *name, char *proto, uint16_t port){
|
||||
if(mdns_service_add(mdns, name, proto, port)) {
|
||||
if(mdns_service_add(NULL, name, proto, port, NULL, 0)) {
|
||||
log_e("Failed adding service %s.%s.\n", name, proto);
|
||||
}
|
||||
}
|
||||
|
||||
bool MDNSResponder::addServiceTxt(char *name, char *proto, char *key, char *value){
|
||||
//ToDo: implement it in IDF. This will set the TXT to one record currently
|
||||
String txt = String(key) + "=" + String(value);
|
||||
const char * txt_chr[1] = {txt.c_str()};
|
||||
if(mdns_service_txt_set(mdns, name, proto, 1, txt_chr)) {
|
||||
if(mdns_service_txt_item_set(name, proto, key, value)) {
|
||||
log_e("Failed setting service TXT");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
IPAddress MDNSResponder::queryHost(char *host, uint32_t timeout){
|
||||
struct ip4_addr addr;
|
||||
addr.addr = 0;
|
||||
|
||||
esp_err_t err = mdns_query_a(host, timeout, &addr);
|
||||
if(err){
|
||||
if(err == ESP_ERR_NOT_FOUND){
|
||||
log_w("Host was not found!");
|
||||
return IPAddress();
|
||||
}
|
||||
log_e("Query Failed");
|
||||
return IPAddress();
|
||||
}
|
||||
return IPAddress(addr.addr);
|
||||
}
|
||||
|
||||
|
||||
int MDNSResponder::queryService(char *service, char *proto) {
|
||||
mdns_result_free(mdns);
|
||||
if(proto){
|
||||
if(!service || !service[0] || !proto || !proto[0]){
|
||||
log_e("Bad Parameters");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(results){
|
||||
mdns_query_results_free(results);
|
||||
results = NULL;
|
||||
}
|
||||
|
||||
char srv[strlen(service)+2];
|
||||
char prt[strlen(proto)+2];
|
||||
sprintf(srv, "_%s", service);
|
||||
sprintf(prt, "_%s", proto);
|
||||
return mdns_query(mdns, srv, prt, 2000);
|
||||
|
||||
esp_err_t err = mdns_query_ptr(srv, prt, 3000, 20, &results);
|
||||
if(err){
|
||||
log_e("Query Failed");
|
||||
return 0;
|
||||
}
|
||||
return mdns_query(mdns, service, NULL, 2000);
|
||||
if(!results){
|
||||
log_w("No results found!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
IPAddress MDNSResponder::queryHost(char *host){
|
||||
mdns_result_free(mdns);
|
||||
if(!mdns_query(mdns, host, NULL, 2000)){
|
||||
return IPAddress();
|
||||
mdns_result_t * r = results;
|
||||
int i = 0;
|
||||
while(r){
|
||||
i++;
|
||||
r = r->next;
|
||||
}
|
||||
return IP(0);
|
||||
return i;
|
||||
}
|
||||
|
||||
mdns_result_t * MDNSResponder::_getResult(int idx){
|
||||
mdns_result_t * result = results;
|
||||
int i = 0;
|
||||
while(result){
|
||||
if(i == idx){
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
result = result->next;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
String MDNSResponder::hostname(int idx) {
|
||||
const mdns_result_t * result = mdns_result_get(mdns, idx);
|
||||
mdns_result_t * result = _getResult(idx);
|
||||
if(!result){
|
||||
log_e("Result %d not found", idx);
|
||||
return String();
|
||||
}
|
||||
return String(result->host);
|
||||
return String(result->hostname);
|
||||
}
|
||||
|
||||
IPAddress MDNSResponder::IP(int idx) {
|
||||
const mdns_result_t * result = mdns_result_get(mdns, idx);
|
||||
mdns_result_t * result = _getResult(idx);
|
||||
if(!result){
|
||||
log_e("Result %d not found", idx);
|
||||
return IPAddress();
|
||||
}
|
||||
return IPAddress(result->addr.addr);
|
||||
mdns_ip_addr_t * addr = result->addr;
|
||||
while(addr){
|
||||
if(addr->addr.type == MDNS_IP_PROTOCOL_V4){
|
||||
return IPAddress(addr->addr.u_addr.ip4.addr);
|
||||
}
|
||||
addr = addr->next;
|
||||
}
|
||||
return IPAddress();
|
||||
}
|
||||
|
||||
IPv6Address MDNSResponder::IPv6(int idx) {
|
||||
mdns_result_t * result = _getResult(idx);
|
||||
if(!result){
|
||||
log_e("Result %d not found", idx);
|
||||
return IPv6Address();
|
||||
}
|
||||
mdns_ip_addr_t * addr = result->addr;
|
||||
while(addr){
|
||||
if(addr->addr.type == MDNS_IP_PROTOCOL_V6){
|
||||
return IPv6Address(addr->addr.u_addr.ip6.addr);
|
||||
}
|
||||
addr = addr->next;
|
||||
}
|
||||
return IPv6Address();
|
||||
}
|
||||
|
||||
uint16_t MDNSResponder::port(int idx) {
|
||||
const mdns_result_t * result = mdns_result_get(mdns, idx);
|
||||
mdns_result_t * result = _getResult(idx);
|
||||
if(!result){
|
||||
log_e("Result %d not found", idx);
|
||||
return 0;
|
||||
|
@ -42,18 +42,19 @@ License (MIT license):
|
||||
#define ESP32MDNS_H
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "IPv6Address.h"
|
||||
#include "mdns.h"
|
||||
|
||||
//this should be defined at build time
|
||||
#ifndef ARDUINO_BOARD
|
||||
#define ARDUINO_BOARD "esp32"
|
||||
#ifndef ARDUINO_VARIANT
|
||||
#define ARDUINO_VARIANT "esp32"
|
||||
#endif
|
||||
|
||||
class MDNSResponder {
|
||||
public:
|
||||
MDNSResponder();
|
||||
~MDNSResponder();
|
||||
bool begin(const char* hostName, tcpip_adapter_if_t tcpip_if=TCPIP_ADAPTER_IF_STA, uint32_t ttl=120);
|
||||
bool begin(const char* hostName);
|
||||
void end();
|
||||
|
||||
void setInstanceName(String name);
|
||||
@ -83,15 +84,15 @@ public:
|
||||
void enableArduino(uint16_t port=3232, bool auth=false);
|
||||
void disableArduino();
|
||||
|
||||
void enableWorkstation();
|
||||
void enableWorkstation(wifi_interface_t interface=ESP_IF_WIFI_STA);
|
||||
void disableWorkstation();
|
||||
|
||||
IPAddress queryHost(char *host);
|
||||
IPAddress queryHost(const char *host){
|
||||
return queryHost((char *)host);
|
||||
IPAddress queryHost(char *host, uint32_t timeout=2000);
|
||||
IPAddress queryHost(const char *host, uint32_t timeout=2000){
|
||||
return queryHost((char *)host, timeout);
|
||||
}
|
||||
IPAddress queryHost(String host){
|
||||
return queryHost(host.c_str());
|
||||
IPAddress queryHost(String host, uint32_t timeout=2000){
|
||||
return queryHost(host.c_str(), timeout);
|
||||
}
|
||||
|
||||
int queryService(char *service, char *proto);
|
||||
@ -104,12 +105,13 @@ public:
|
||||
|
||||
String hostname(int idx);
|
||||
IPAddress IP(int idx);
|
||||
IPv6Address IPv6(int idx);
|
||||
uint16_t port(int idx);
|
||||
|
||||
private:
|
||||
mdns_server_t * mdns;
|
||||
tcpip_adapter_if_t _if;
|
||||
String _hostname;
|
||||
mdns_result_t * results;
|
||||
mdns_result_t * _getResult(int idx);
|
||||
};
|
||||
|
||||
extern MDNSResponder MDNS;
|
||||
|
@ -30,7 +30,6 @@ extern void tcpipInit();
|
||||
static int _eth_phy_mdc_pin = -1;
|
||||
static int _eth_phy_mdio_pin = -1;
|
||||
static int _eth_phy_power_pin = -1;
|
||||
static eth_clock_mode_t _eth_clk_mode = ETH_CLOCK_GPIO0_IN;
|
||||
static eth_phy_power_enable_func _eth_phy_power_enable_orig = NULL;
|
||||
|
||||
static void _eth_phy_config_gpio(void)
|
||||
|
@ -65,10 +65,8 @@ static TaskHandle_t _network_event_task_handle = NULL;
|
||||
static void _network_event_task(void * arg){
|
||||
system_event_t *event = NULL;
|
||||
for (;;) {
|
||||
if(xQueueReceive(_network_event_queue, &event, 0) == pdTRUE){
|
||||
WiFiGenericClass::_eventCallback(NULL, event);
|
||||
} else {
|
||||
vTaskDelay(1);
|
||||
if(xQueueReceive(_network_event_queue, &event, portMAX_DELAY) == pdTRUE){
|
||||
WiFiGenericClass::_eventCallback(arg, event);
|
||||
}
|
||||
}
|
||||
vTaskDelete(NULL);
|
||||
@ -173,6 +171,7 @@ static bool espWiFiStop(){
|
||||
typedef struct {
|
||||
WiFiEventCb cb;
|
||||
WiFiEventFullCb fcb;
|
||||
WiFiEventSysCb scb;
|
||||
system_event_id_t event;
|
||||
} WiFiEventCbList_t;
|
||||
|
||||
@ -200,6 +199,7 @@ void WiFiGenericClass::onEvent(WiFiEventCb cbEvent, system_event_id_t event)
|
||||
WiFiEventCbList_t newEventHandler;
|
||||
newEventHandler.cb = cbEvent;
|
||||
newEventHandler.fcb = NULL;
|
||||
newEventHandler.scb = NULL;
|
||||
newEventHandler.event = event;
|
||||
cbEventList.push_back(newEventHandler);
|
||||
}
|
||||
@ -212,6 +212,20 @@ void WiFiGenericClass::onEvent(WiFiEventFullCb cbEvent, system_event_id_t event)
|
||||
WiFiEventCbList_t newEventHandler;
|
||||
newEventHandler.cb = NULL;
|
||||
newEventHandler.fcb = cbEvent;
|
||||
newEventHandler.scb = NULL;
|
||||
newEventHandler.event = event;
|
||||
cbEventList.push_back(newEventHandler);
|
||||
}
|
||||
|
||||
void WiFiGenericClass::onEvent(WiFiEventSysCb cbEvent, system_event_id_t event)
|
||||
{
|
||||
if(!cbEvent) {
|
||||
return;
|
||||
}
|
||||
WiFiEventCbList_t newEventHandler;
|
||||
newEventHandler.cb = NULL;
|
||||
newEventHandler.fcb = NULL;
|
||||
newEventHandler.scb = cbEvent;
|
||||
newEventHandler.event = event;
|
||||
cbEventList.push_back(newEventHandler);
|
||||
}
|
||||
@ -249,12 +263,26 @@ void WiFiGenericClass::removeEvent(WiFiEventFullCb cbEvent, system_event_id_t ev
|
||||
}
|
||||
}
|
||||
|
||||
void WiFiGenericClass::removeEvent(WiFiEventSysCb cbEvent, system_event_id_t event)
|
||||
{
|
||||
if(!cbEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
for(uint32_t i = 0; i < cbEventList.size(); i++) {
|
||||
WiFiEventCbList_t entry = cbEventList[i];
|
||||
if(entry.scb == cbEvent && entry.event == event) {
|
||||
cbEventList.erase(cbEventList.begin() + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* callback for WiFi events
|
||||
* @param arg
|
||||
*/
|
||||
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
|
||||
const char * system_event_names[] = { "WIFI_READY", "SCAN_DONE", "STA_START", "STA_STOP", "STA_CONNECTED", "STA_DISCONNECTED", "STA_AUTHMODE_CHANGE", "STA_GOT_IP", "STA_WPS_ER_SUCCESS", "STA_WPS_ER_FAILED", "STA_WPS_ER_TIMEOUT", "STA_WPS_ER_PIN", "AP_START", "AP_STOP", "AP_STACONNECTED", "AP_STADISCONNECTED", "AP_PROBEREQRECVED", "AP_STA_GOT_IP6", "ETH_START", "ETH_STOP", "ETH_CONNECTED", "ETH_DISCONNECTED", "ETH_GOT_IP", "MAX"};
|
||||
const char * system_event_names[] = { "WIFI_READY", "SCAN_DONE", "STA_START", "STA_STOP", "STA_CONNECTED", "STA_DISCONNECTED", "STA_AUTHMODE_CHANGE", "STA_GOT_IP", "STA_LOST_IP", "STA_WPS_ER_SUCCESS", "STA_WPS_ER_FAILED", "STA_WPS_ER_TIMEOUT", "STA_WPS_ER_PIN", "AP_START", "AP_STOP", "AP_STACONNECTED", "AP_STADISCONNECTED", "AP_PROBEREQRECVED", "GOT_IP6", "ETH_START", "ETH_STOP", "ETH_CONNECTED", "ETH_DISCONNECTED", "ETH_GOT_IP", "MAX"};
|
||||
#endif
|
||||
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_WARN
|
||||
const char * system_event_reasons[] = { "UNSPECIFIED", "AUTH_EXPIRE", "AUTH_LEAVE", "ASSOC_EXPIRE", "ASSOC_TOOMANY", "NOT_AUTHED", "NOT_ASSOCED", "ASSOC_LEAVE", "ASSOC_NOT_AUTHED", "DISASSOC_PWRCAP_BAD", "DISASSOC_SUPCHAN_BAD", "IE_INVALID", "MIC_FAILURE", "4WAY_HANDSHAKE_TIMEOUT", "GROUP_KEY_UPDATE_TIMEOUT", "IE_IN_4WAY_DIFFERS", "GROUP_CIPHER_INVALID", "PAIRWISE_CIPHER_INVALID", "AKMP_INVALID", "UNSUPP_RSN_IE_VERSION", "INVALID_RSN_IE_CAP", "802_1X_AUTH_FAILED", "CIPHER_SUITE_REJECTED", "BEACON_TIMEOUT", "NO_AP_FOUND", "AUTH_FAIL", "ASSOC_FAIL", "HANDSHAKE_TIMEOUT" };
|
||||
@ -291,12 +319,14 @@ esp_err_t WiFiGenericClass::_eventCallback(void *arg, system_event_t *event)
|
||||
|
||||
for(uint32_t i = 0; i < cbEventList.size(); i++) {
|
||||
WiFiEventCbList_t entry = cbEventList[i];
|
||||
if(entry.cb || entry.fcb) {
|
||||
if(entry.cb || entry.fcb || entry.scb) {
|
||||
if(entry.event == (system_event_id_t) event->event_id || entry.event == SYSTEM_EVENT_MAX) {
|
||||
if(entry.cb){
|
||||
entry.cb((system_event_id_t) event->event_id);
|
||||
} else {
|
||||
} else if(entry.fcb){
|
||||
entry.fcb((system_event_id_t) event->event_id, (system_event_info_t) event->event_info);
|
||||
} else {
|
||||
entry.scb(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
typedef void (*WiFiEventCb)(system_event_id_t event);
|
||||
typedef void (*WiFiEventFullCb)(system_event_id_t event, system_event_info_t info);
|
||||
typedef void (*WiFiEventSysCb)(system_event_t *event);
|
||||
|
||||
class WiFiGenericClass
|
||||
{
|
||||
@ -38,8 +39,10 @@ public:
|
||||
|
||||
void onEvent(WiFiEventCb cbEvent, system_event_id_t event = SYSTEM_EVENT_MAX);
|
||||
void onEvent(WiFiEventFullCb cbEvent, system_event_id_t event = SYSTEM_EVENT_MAX);
|
||||
void onEvent(WiFiEventSysCb cbEvent, system_event_id_t event = SYSTEM_EVENT_MAX);
|
||||
void removeEvent(WiFiEventCb cbEvent, system_event_id_t event = SYSTEM_EVENT_MAX);
|
||||
void removeEvent(WiFiEventFullCb cbEvent, system_event_id_t event = SYSTEM_EVENT_MAX);
|
||||
void removeEvent(WiFiEventSysCb cbEvent, system_event_id_t event = SYSTEM_EVENT_MAX);
|
||||
|
||||
int32_t channel(void);
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
{
|
||||
"packager": "esp32",
|
||||
"name": "xtensa-esp32-elf-gcc",
|
||||
"version": "1.22.0-75-gbaf03c2-5.2.0"
|
||||
"version": "1.22.0-80-g6c4433a-5.2.0"
|
||||
},
|
||||
{
|
||||
"packager": "esp32",
|
||||
@ -51,35 +51,35 @@
|
||||
"tools": [
|
||||
{
|
||||
"name": "xtensa-esp32-elf-gcc",
|
||||
"version": "1.22.0-75-gbaf03c2-5.2.0",
|
||||
"version": "1.22.0-80-g6c4433a-5.2.0",
|
||||
"systems": [
|
||||
{
|
||||
"host": "i686-mingw32",
|
||||
"url": "https://dl.espressif.com/dl/xtensa-esp32-elf-win32-1.22.0-75-gbaf03c2-5.2.0.zip",
|
||||
"archiveFileName": "xtensa-esp32-elf-win32-1.22.0-75-gbaf03c2-5.2.0.zip",
|
||||
"checksum": "SHA-256:b1735be3a24c3aa5edc672a67aeaa0bf0922c01d514a6bb905d5cd3d6fb86399",
|
||||
"size": "78900581"
|
||||
"url": "https://dl.espressif.com/dl/xtensa-esp32-elf-win32-1.22.0-80-g6c4433a-5.2.0.zip",
|
||||
"archiveFileName": "xtensa-esp32-elf-win32-1.22.0-80-g6c4433a-5.2.0.zip",
|
||||
"checksum": "SHA-256:f217fccbeaaa8c92db239036e0d6202458de4488b954a3a38f35ac2ec48058a4",
|
||||
"size": "125719261"
|
||||
},
|
||||
{
|
||||
"host": "x86_64-apple-darwin",
|
||||
"url": "https://dl.espressif.com/dl/xtensa-esp32-elf-osx-1.22.0-75-gbaf03c2-5.2.0.tar.gz",
|
||||
"archiveFileName": "xtensa-esp32-elf-osx-1.22.0-75-gbaf03c2-5.2.0.tar.gz",
|
||||
"checksum": "SHA-256:8bdaef8c88fa5e111837587e1ebd2af93125cba96a6ec7d717fe14803723a69b",
|
||||
"size": "39897281"
|
||||
"url": "https://dl.espressif.com/dl/xtensa-esp32-elf-osx-1.22.0-80-g6c4433a-5.2.0.tar.gz",
|
||||
"archiveFileName": "xtensa-esp32-elf-osx-1.22.0-80-g6c4433a-5.2.0.tar.gz",
|
||||
"checksum": "SHA-256:a4307a97945d2f2f2745f415fbe80d727750e19f91f9a1e7e2f8a6065652f9da",
|
||||
"size": "46517409"
|
||||
},
|
||||
{
|
||||
"host": "x86_64-pc-linux-gnu",
|
||||
"url": "https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-75-gbaf03c2-5.2.0.tar.gz",
|
||||
"archiveFileName": "xtensa-esp32-elf-linux64-1.22.0-75-gbaf03c2-5.2.0.tar.gz",
|
||||
"checksum": "SHA-256:c65a719545b773149cad7008c618053443f57a9c15e4ad60877ccce0a5eef82a",
|
||||
"size": "37642712"
|
||||
"url": "https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz",
|
||||
"archiveFileName": "xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz",
|
||||
"checksum": "SHA-256:3fe96c151d46c1d4e5edc6ed690851b8e53634041114bad04729bc16b0445156",
|
||||
"size": "44219107"
|
||||
},
|
||||
{
|
||||
"host": "i686-pc-linux-gnu",
|
||||
"url": "https://dl.espressif.com/dl/xtensa-esp32-elf-linux32-1.22.0-75-gbaf03c2-5.2.0.tar.gz",
|
||||
"archiveFileName": "xtensa-esp32-elf-linux32-1.22.0-75-gbaf03c2-5.2.0.tar.gz",
|
||||
"checksum": "SHA-256:040f7e230941c785e44936236913b1c0585594f140880e2c34758b7be8709cf6",
|
||||
"size": "38978071"
|
||||
"url": "https://dl.espressif.com/dl/xtensa-esp32-elf-linux32-1.22.0-80-g6c4433a-5.2.0.tar.gz",
|
||||
"archiveFileName": "xtensa-esp32-elf-linux32-1.22.0-80-g6c4433a-5.2.0.tar.gz",
|
||||
"checksum": "SHA-256:b4055695ffc2dfc0bcb6dafdc2572a6e01151c4179ef5fa972b3fcb2183eb155",
|
||||
"size": "45566336"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -22,7 +22,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/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/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/soc" "-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/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/coap" "-I{compiler.sdk.path}/include/console" "-I{compiler.sdk.path}/include/expat" "-I{compiler.sdk.path}/include/json" "-I{compiler.sdk.path}/include/lwip" "-I{compiler.sdk.path}/include/newlib" "-I{compiler.sdk.path}/include/nghttp" "-I{compiler.sdk.path}/include/soc" "-I{compiler.sdk.path}/include/wpa_supplicant"
|
||||
|
||||
compiler.c.cmd=xtensa-esp32-elf-gcc
|
||||
compiler.c.flags=-std=gnu99 -Os -g3 -fstack-protector -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
|
||||
@ -61,13 +61,13 @@ compiler.objcopy.eep.extra_flags=
|
||||
compiler.elf2hex.extra_flags=
|
||||
|
||||
## Compile c files
|
||||
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.cpreprocessor.flags} {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BOARD="{build.board}" {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
|
||||
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.cpreprocessor.flags} {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BOARD="{build.board}" -DARDUINO_VARIANT="{build.variant}" {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
|
||||
|
||||
## Compile c++ files
|
||||
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpreprocessor.flags} {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BOARD="{build.board}" {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
|
||||
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpreprocessor.flags} {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BOARD="{build.board}" -DARDUINO_VARIANT="{build.variant}" {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
|
||||
|
||||
## Compile S files
|
||||
recipe.S.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.cpreprocessor.flags} {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BOARD="{build.board}" {compiler.S.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
|
||||
recipe.S.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.cpreprocessor.flags} {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BOARD="{build.board}" -DARDUINO_VARIANT="{build.variant}" {compiler.S.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
|
||||
|
||||
## Create archives
|
||||
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{build.path}/arduino.ar" "{object_file}"
|
||||
|
@ -81,15 +81,15 @@ env.Prepend(
|
||||
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", "soc"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "newlib"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "coap"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "wpa_supplicant"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "console"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "expat"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "json"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "nghttp"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "lwip"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "newlib"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "nghttp"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "soc"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "include", "wpa_supplicant"),
|
||||
join(FRAMEWORK_DIR, "cores", env.BoardConfig().get("build.core"))
|
||||
],
|
||||
LIBPATH=[
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -57,6 +57,9 @@ void osi_alarm_free(osi_alarm_t *alarm);
|
||||
// |alarm| and |cb| may not be NULL.
|
||||
osi_alarm_err_t osi_alarm_set(osi_alarm_t *alarm, period_ms_t timeout);
|
||||
|
||||
// Sets an periodic alarm to fire |cb| each given |period|.
|
||||
osi_alarm_err_t osi_alarm_set_periodic(osi_alarm_t *alarm, period_ms_t period);
|
||||
|
||||
// This function cancels the |alarm| if it was previously set. When this call
|
||||
// returns, the caller has a guarantee that the callback is not in progress and
|
||||
// will not be called if it hasn't already been called. This function is idempotent.
|
||||
@ -65,6 +68,7 @@ osi_alarm_err_t osi_alarm_cancel(osi_alarm_t *alarm);
|
||||
|
||||
// Figure out how much time until next expiration.
|
||||
// Returns 0 if not armed. |alarm| may not be NULL.
|
||||
// only for oneshot alarm, not for periodic alarm
|
||||
// TODO: Remove this function once PM timers can be re-factored
|
||||
period_ms_t osi_alarm_get_remaining_ms(const osi_alarm_t *alarm);
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
#define __BLUFI_INT_H__
|
||||
|
||||
#define BTC_BLUFI_GREAT_VER 0x01 //Version + Subversion
|
||||
#define BTC_BLUFI_SUB_VER 0x00 //Version + Subversion
|
||||
#define BTC_BLUFI_SUB_VER 0x01 //Version + Subversion
|
||||
#define BTC_BLUFI_VERSION ((BTC_BLUFI_GREAT_VER<<8)|BTC_BLUFI_SUB_VER) //Version + Subversion
|
||||
|
||||
/* service engine control block */
|
||||
@ -93,6 +93,7 @@ typedef struct blufi_frag_hdr blufi_frag_hdr_t;
|
||||
#define BLUFI_TYPE_CTRL_SUBTYPE_DEAUTHENTICATE_STA 0x06
|
||||
#define BLUFI_TYPE_CTRL_SUBTYPE_GET_VERSION 0x07
|
||||
#define BLUFI_TYPE_CTRL_SUBTYPE_DISCONNECT_BLE 0x08
|
||||
#define BLUFI_TYPE_CTRL_SUBTYPE_GET_WIFI_LIST 0x09
|
||||
|
||||
#define BLUFI_TYPE_DATA 0x1
|
||||
#define BLUFI_TYPE_DATA_SUBTYPE_NEG 0x00
|
||||
@ -112,6 +113,7 @@ typedef struct blufi_frag_hdr blufi_frag_hdr_t;
|
||||
#define BLUFI_TYPE_DATA_SUBTYPE_SERVER_PRIV_KEY 0x0e
|
||||
#define BLUFI_TYPE_DATA_SUBTYPE_WIFI_REP 0x0f
|
||||
#define BLUFI_TYPE_DATA_SUBTYPE_REPLY_VERSION 0x10
|
||||
#define BLUFI_TYPE_DATA_SUBTYPE_WIFI_LIST 0x11
|
||||
#define BLUFI_TYPE_IS_CTRL(type) (BLUFI_GET_TYPE((type)) == BLUFI_TYPE_CTRL)
|
||||
#define BLUFI_TYPE_IS_DATA(type) (BLUFI_GET_TYPE((type)) == BLUFI_TYPE_DATA)
|
||||
|
||||
|
@ -90,6 +90,7 @@ typedef enum {
|
||||
BT_STATUS_UNACCEPT_CONN_INTERVAL,
|
||||
BT_STATUS_PARAM_OUT_OF_RANGE,
|
||||
BT_STATUS_TIMEOUT,
|
||||
BT_STATUS_MEMORY_FULL,
|
||||
} bt_status_t;
|
||||
|
||||
#ifndef CPU_LITTLE_ENDIAN
|
||||
|
@ -39,56 +39,57 @@
|
||||
|
||||
#include "dyn_mem.h" /* defines static and/or dynamic memory for components */
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Classic BT features
|
||||
**
|
||||
******************************************************************************/
|
||||
#if CONFIG_CLASSIC_BT_ENABLED
|
||||
#define CLASSIC_BT_INCLUDED TRUE
|
||||
#define BTC_SM_INCLUDED TRUE
|
||||
#define BTC_PRF_QUEUE_INCLUDED TRUE
|
||||
#define BTC_GAP_BT_INCLUDED TRUE
|
||||
#define BTA_SDP_INCLUDED TRUE
|
||||
#define BTA_PAN_INCLUDED FALSE
|
||||
#define BTA_HH_INCLUDED FALSE
|
||||
#define SDP_INCLUDED TRUE
|
||||
|
||||
#if CONFIG_A2DP_ENABLE
|
||||
#define BTA_AR_INCLUDED TRUE
|
||||
#define BTA_AV_INCLUDED TRUE
|
||||
#define BTA_AV_SINK_INCLUDED TRUE
|
||||
#define SDP_INCLUDED TRUE
|
||||
#define RFCOMM_INCLUDED FALSE
|
||||
#define PAN_INCLUDED FALSE
|
||||
#define HID_HOST_INCLUDED FALSE
|
||||
#define AVDT_INCLUDED TRUE
|
||||
#define A2D_INCLUDED TRUE
|
||||
#define AVCT_INCLUDED TRUE
|
||||
#define AVRC_INCLUDED TRUE
|
||||
#define SBC_DEC_INCLUDED TRUE
|
||||
#define SBC_ENC_INCLUDED FALSE
|
||||
#define MCA_INCLUDED FALSE
|
||||
#define BTC_SM_INCLUDED TRUE
|
||||
#define BTC_PRF_QUEUE_INCLUDED TRUE
|
||||
#define BTC_GAP_BT_INCLUDED TRUE
|
||||
#define BTC_AV_INCLUDED TRUE
|
||||
#endif /* CONFIG_A2DP_ENABLE */
|
||||
|
||||
#else /* #if CONFIG_CLASSIC_BT_ENABLED */
|
||||
#define CLASSIC_BT_INCLUDED FALSE
|
||||
#define BTA_SDP_INCLUDED FALSE
|
||||
#define BTA_PAN_INCLUDED FALSE
|
||||
#define BTA_HH_INCLUDED FALSE
|
||||
#define BTA_AR_INCLUDED FALSE
|
||||
#define BTA_AV_INCLUDED FALSE
|
||||
#define BTA_AV_SINK_INCLUDED FALSE
|
||||
#define SDP_INCLUDED FALSE
|
||||
#define RFCOMM_INCLUDED FALSE
|
||||
#define PAN_INCLUDED FALSE
|
||||
#define HID_HOST_INCLUDED FALSE
|
||||
#define AVDT_INCLUDED FALSE
|
||||
#define A2D_INCLUDED FALSE
|
||||
#define AVCT_INCLUDED FALSE
|
||||
#define AVRC_INCLUDED FALSE
|
||||
#define SBC_DEC_INCLUDED FALSE
|
||||
#define SBC_ENC_INCLUDED FALSE
|
||||
#define MCA_INCLUDED FALSE
|
||||
#define BTC_SM_INCLUDED FALSE
|
||||
#define BTC_PRF_QUEUE_INCLUDED FALSE
|
||||
#define BTC_GAP_BT_INCLUDED FALSE
|
||||
#define BTC_AV_INCLUDED FALSE
|
||||
#if CONFIG_A2DP_SINK_ENABLE
|
||||
#define BTA_AV_SINK_INCLUDED TRUE
|
||||
#define BTC_AV_SINK_INCLUDED TRUE
|
||||
#define SBC_DEC_INCLUDED TRUE
|
||||
#endif /* CONFIG_A2DP_SINK_ENABLE */
|
||||
|
||||
#if CONFIG_A2DP_SRC_ENABLE
|
||||
#define BTC_AV_SRC_INCLUDED TRUE
|
||||
#define SBC_ENC_INCLUDED TRUE
|
||||
#endif /* CONFIG_A2DP_SRC_ENABLE */
|
||||
|
||||
#if CONFIG_BT_SPP_ENABLED
|
||||
#define RFCOMM_INCLUDED TRUE
|
||||
#define BTA_JV_INCLUDED TRUE
|
||||
#define BTC_SPP_INCLUDED TRUE
|
||||
#endif /* CONFIG_BT_SPP_ENABLED */
|
||||
|
||||
#endif /* #if CONFIG_CLASSIC_BT_ENABLED */
|
||||
|
||||
#ifndef CLASSIC_BT_INCLUDED
|
||||
#define CLASSIC_BT_INCLUDED FALSE
|
||||
#endif /* CLASSIC_BT_INCLUDED */
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** BLE features
|
||||
**
|
||||
******************************************************************************/
|
||||
#if (CONFIG_GATTS_ENABLE)
|
||||
#define GATTS_INCLUDED TRUE
|
||||
#else
|
||||
@ -139,16 +140,62 @@
|
||||
#define BTIF_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** BTC-layer components
|
||||
**
|
||||
******************************************************************************/
|
||||
#ifndef BTC_GAP_BT_INCLUDED
|
||||
#define BTC_GAP_BT_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
#ifndef BTC_PRF_QUEUE_INCLUDED
|
||||
#define BTC_PRF_QUEUE_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
#ifndef BTC_SM_INCLUDED
|
||||
#define BTC_SM_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
#ifndef BTC_AV_INCLUDED
|
||||
#define BTC_AV_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
#ifndef BTC_AV_SINK_INCLUDED
|
||||
#define BTC_AV_SINK_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
#ifndef BTC_AV_SRC_INCLUDED
|
||||
#define BTC_AV_SRC_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
#ifndef BTC_SPP_INCLUDED
|
||||
#define BTC_SPP_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
#ifndef SBC_DEC_INCLUDED
|
||||
#define SBC_DEC_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
#ifndef SBC_ENC_INCLUDED
|
||||
#define SBC_ENC_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** BTA-layer components
|
||||
**
|
||||
******************************************************************************/
|
||||
#ifndef BTA_INCLUDED
|
||||
#define BTA_INCLUDED TRUE
|
||||
#endif
|
||||
|
||||
#ifndef BTA_PAN_INCLUDED
|
||||
#define BTA_PAN_INCLUDED FALSE//TRUE
|
||||
#define BTA_PAN_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
#ifndef BTA_HH_INCLUDED
|
||||
#define BTA_HH_INCLUDED FALSE//TRUE
|
||||
#define BTA_HH_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
#ifndef BTA_HH_ROLE
|
||||
@ -156,21 +203,47 @@
|
||||
#endif
|
||||
|
||||
#ifndef BTA_HH_LE_INCLUDED
|
||||
#define BTA_HH_LE_INCLUDED FALSE//TRUE
|
||||
#define BTA_HH_LE_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
#ifndef BTA_AR_INCLUDED
|
||||
#define BTA_AR_INCLUDED TRUE//TRUE
|
||||
#define BTA_AR_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
#ifndef BTA_AV_INCLUDED
|
||||
#define BTA_AV_INCLUDED TRUE//TRUE
|
||||
#define BTA_AV_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
#ifndef BTA_AV_SINK_INCLUDED
|
||||
#define BTA_AV_SINK_INCLUDED TRUE//FALSE
|
||||
#define BTA_AV_SINK_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
#ifndef BTA_JV_INCLUDED
|
||||
#define BTA_JV_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
#ifndef BTA_SDP_INCLUDED
|
||||
#define BTA_SDP_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Stack-layer components
|
||||
**
|
||||
******************************************************************************/
|
||||
#ifndef AVCT_INCLUDED
|
||||
#define AVCT_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
#ifndef AVDT_INCLUDED
|
||||
#define AVDT_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Parameter Configurations for components
|
||||
**
|
||||
******************************************************************************/
|
||||
#ifndef BTA_DISABLE_DELAY
|
||||
#define BTA_DISABLE_DELAY 200 /* in milliseconds */
|
||||
#endif
|
||||
@ -647,7 +720,8 @@
|
||||
|
||||
/* 4.1/4.2 secure connections feature */
|
||||
#ifndef SC_MODE_INCLUDED
|
||||
#define SC_MODE_INCLUDED TRUE
|
||||
// Disable AES-CCM (BT 4.1) for BT Classic to workaround controller AES issue. E0 encryption (BT 4.0) will be used.
|
||||
#define SC_MODE_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
/* Used for conformance testing ONLY */
|
||||
@ -1045,7 +1119,7 @@
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef SDP_INCLUDED
|
||||
#define SDP_INCLUDED FALSE //TRUE
|
||||
#define SDP_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
/* This is set to enable SDP server functionality. */
|
||||
@ -1432,7 +1506,7 @@ Range: 2 octets
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef PAN_INCLUDED
|
||||
#define PAN_INCLUDED FALSE//TRUE
|
||||
#define PAN_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
/* This will enable the PANU role */
|
||||
@ -1577,7 +1651,7 @@ Range: 2 octets
|
||||
** Definitions for HID-Host
|
||||
*/
|
||||
#ifndef HID_HOST_INCLUDED
|
||||
#define HID_HOST_INCLUDED FALSE//TRUE
|
||||
#define HID_HOST_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
#ifndef HID_HOST_MAX_DEVICES
|
||||
@ -1604,7 +1678,7 @@ Range: 2 octets
|
||||
* A2DP Definitions
|
||||
*/
|
||||
#ifndef A2D_INCLUDED
|
||||
#define A2D_INCLUDED FALSE//TRUE
|
||||
#define A2D_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
@ -1629,7 +1703,7 @@ Range: 2 octets
|
||||
**
|
||||
******************************************************************************/
|
||||
#ifndef AVRC_INCLUDED
|
||||
#define AVRC_INCLUDED TRUE
|
||||
#define AVRC_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
#ifndef AVRC_METADATA_INCLUDED
|
||||
|
@ -276,6 +276,7 @@ typedef struct {
|
||||
/********************************************************************************
|
||||
** Macros to get and put bytes to and from a stream (Big Endian format)
|
||||
*/
|
||||
#define UINT64_TO_BE_STREAM(p, u64) {*(p)++ = (UINT8)((u64) >> 56); *(p)++ = (UINT8)((u64) >> 48); *(p)++ = (UINT8)((u64) >> 40); *(p)++ = (UINT8)((u64) >> 32); *(p)++ = (UINT8)((u64) >> 24); *(p)++ = (UINT8)((u64) >> 16); *(p)++ = (UINT8)((u64) >> 8); *(p)++ = (UINT8)(u64); }
|
||||
#define UINT32_TO_BE_STREAM(p, u32) {*(p)++ = (UINT8)((u32) >> 24); *(p)++ = (UINT8)((u32) >> 16); *(p)++ = (UINT8)((u32) >> 8); *(p)++ = (UINT8)(u32); }
|
||||
#define UINT24_TO_BE_STREAM(p, u24) {*(p)++ = (UINT8)((u24) >> 16); *(p)++ = (UINT8)((u24) >> 8); *(p)++ = (UINT8)(u24);}
|
||||
#define UINT16_TO_BE_STREAM(p, u16) {*(p)++ = (UINT8)((u16) >> 8); *(p)++ = (UINT8)(u16);}
|
||||
|
@ -1,46 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2009-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 BT_UTILS_H
|
||||
#define BT_UTILS_H
|
||||
|
||||
// static const char BT_UTILS_MODULE[] = "bt_utils_module";
|
||||
|
||||
/*******************************************************************************
|
||||
** Type definitions
|
||||
********************************************************************************/
|
||||
|
||||
typedef enum {
|
||||
TASK_HIGH_MEDIA = 0,
|
||||
TASK_HIGH_GKI_TIMER,
|
||||
TASK_HIGH_BTU,
|
||||
TASK_HIGH_HCI_WORKER,
|
||||
TASK_HIGH_USERIAL_READ,
|
||||
TASK_UIPC_READ,
|
||||
TASK_JAVA_ALARM,
|
||||
TASK_HIGH_MAX
|
||||
} tHIGH_PRIORITY_TASK;
|
||||
|
||||
/*******************************************************************************
|
||||
** Functions
|
||||
********************************************************************************/
|
||||
|
||||
void raise_priority_a2dp(tHIGH_PRIORITY_TASK high_task);
|
||||
void adjust_priority_a2dp(int start);
|
||||
#define UNUSED(x) (void)(x)
|
||||
#endif /* BT_UTILS_H */
|
@ -400,7 +400,10 @@ typedef struct {
|
||||
|
||||
typedef void (tBTA_SET_ADV_DATA_CMPL_CBACK) (tBTA_STATUS status);
|
||||
|
||||
typedef void (tBTA_START_ADV_CMPL_CBACK) (tBTA_STATUS status);
|
||||
typedef tBTM_START_ADV_CMPL_CBACK tBTA_START_ADV_CMPL_CBACK;
|
||||
|
||||
typedef tBTM_START_STOP_ADV_CMPL_CBACK tBTA_START_STOP_ADV_CMPL_CBACK;
|
||||
|
||||
|
||||
typedef tBTM_ADD_WHITELIST_CBACK tBTA_ADD_WHITELIST_CBACK;
|
||||
|
||||
@ -782,6 +785,7 @@ typedef struct {
|
||||
typedef struct {
|
||||
BD_ADDR bd_addr; /* BD address peer device. */
|
||||
UINT8 status; /* connection open/closed */
|
||||
UINT8 reason; /* link down reason */
|
||||
BOOLEAN is_removed; /* TRUE if device is removed when link is down */
|
||||
#if BLE_INCLUDED == TRUE
|
||||
tBTA_TRANSPORT link_type;
|
||||
|
@ -375,6 +375,7 @@ typedef struct {
|
||||
/* data associated with BTA_AV_RC_OPEN_EVT */
|
||||
typedef struct {
|
||||
UINT8 rc_handle;
|
||||
BOOLEAN sdp_disc_done;
|
||||
tBTA_AV_FEAT peer_features;
|
||||
BD_ADDR peer_addr;
|
||||
tBTA_AV_STATUS status;
|
||||
|
884
tools/sdk/include/bluedroid/bta_jv_api.h
Normal file
884
tools/sdk/include/bluedroid/bta_jv_api.h
Normal file
@ -0,0 +1,884 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2006-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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This is the public interface file the BTA Java I/F
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef BTA_JV_API_H
|
||||
#define BTA_JV_API_H
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "bt_types.h"
|
||||
#include "bta_api.h"
|
||||
#include "btm_api.h"
|
||||
#include "l2c_api.h"
|
||||
#include "rfcdefs.h"
|
||||
#include "sdp_api.h"
|
||||
|
||||
#if (defined BTA_JV_INCLUDED && BTA_JV_INCLUDED == TRUE)
|
||||
/*****************************************************************************
|
||||
** Constants and data types
|
||||
*****************************************************************************/
|
||||
/* status values */
|
||||
#define BTA_JV_SUCCESS 0 /* Successful operation. */
|
||||
#define BTA_JV_FAILURE 1 /* Generic failure. */
|
||||
#define BTA_JV_BUSY 2 /* Temporarily can not handle this request. */
|
||||
#define BTA_JV_NO_DATA 3 /* no data. */
|
||||
#define BTA_JV_NO_RESOURCE 4 /* No more set pm control block */
|
||||
|
||||
typedef UINT8 tBTA_JV_STATUS;
|
||||
#define BTA_JV_INTERNAL_ERR (-1) /* internal error. */
|
||||
|
||||
#define BTA_JV_MAX_UUIDS SDP_MAX_UUID_FILTERS
|
||||
#define BTA_JV_MAX_ATTRS SDP_MAX_ATTR_FILTERS
|
||||
#define BTA_JV_MAX_SDP_REC SDP_MAX_RECORDS
|
||||
#define BTA_JV_MAX_L2C_CONN GAP_MAX_CONNECTIONS /* GAP handle is used as index, hence do not change this value */
|
||||
#define BTA_JV_MAX_SCN PORT_MAX_RFC_PORTS /* same as BTM_MAX_SCN (in btm_int.h) */
|
||||
#define BTA_JV_MAX_RFC_CONN MAX_RFC_PORTS
|
||||
|
||||
#ifndef BTA_JV_DEF_RFC_MTU
|
||||
#define BTA_JV_DEF_RFC_MTU (3*330)
|
||||
#endif
|
||||
|
||||
#ifndef BTA_JV_MAX_RFC_SR_SESSION
|
||||
#define BTA_JV_MAX_RFC_SR_SESSION MAX_BD_CONNECTIONS
|
||||
#endif
|
||||
|
||||
/* BTA_JV_MAX_RFC_SR_SESSION can not be bigger than MAX_BD_CONNECTIONS */
|
||||
#if (BTA_JV_MAX_RFC_SR_SESSION > MAX_BD_CONNECTIONS)
|
||||
#undef BTA_JV_MAX_RFC_SR_SESSION
|
||||
#define BTA_JV_MAX_RFC_SR_SESSION MAX_BD_CONNECTIONS
|
||||
#endif
|
||||
|
||||
#define BTA_JV_FIRST_SERVICE_ID BTA_FIRST_JV_SERVICE_ID
|
||||
#define BTA_JV_LAST_SERVICE_ID BTA_LAST_JV_SERVICE_ID
|
||||
#define BTA_JV_NUM_SERVICE_ID (BTA_LAST_JV_SERVICE_ID - BTA_FIRST_JV_SERVICE_ID + 1)
|
||||
|
||||
/* Discoverable modes */
|
||||
enum {
|
||||
BTA_JV_DISC_NONE,
|
||||
BTA_JV_DISC_LIMITED,
|
||||
BTA_JV_DISC_GENERAL
|
||||
};
|
||||
typedef UINT16 tBTA_JV_DISC;
|
||||
|
||||
#define BTA_JV_ROLE_SLAVE BTM_ROLE_SLAVE
|
||||
#define BTA_JV_ROLE_MASTER BTM_ROLE_MASTER
|
||||
typedef UINT32 tBTA_JV_ROLE;
|
||||
|
||||
#define BTA_JV_SERVICE_LMTD_DISCOVER BTM_COD_SERVICE_LMTD_DISCOVER /* 0x0020 */
|
||||
#define BTA_JV_SERVICE_POSITIONING BTM_COD_SERVICE_POSITIONING /* 0x0100 */
|
||||
#define BTA_JV_SERVICE_NETWORKING BTM_COD_SERVICE_NETWORKING /* 0x0200 */
|
||||
#define BTA_JV_SERVICE_RENDERING BTM_COD_SERVICE_RENDERING /* 0x0400 */
|
||||
#define BTA_JV_SERVICE_CAPTURING BTM_COD_SERVICE_CAPTURING /* 0x0800 */
|
||||
#define BTA_JV_SERVICE_OBJ_TRANSFER BTM_COD_SERVICE_OBJ_TRANSFER /* 0x1000 */
|
||||
#define BTA_JV_SERVICE_AUDIO BTM_COD_SERVICE_AUDIO /* 0x2000 */
|
||||
#define BTA_JV_SERVICE_TELEPHONY BTM_COD_SERVICE_TELEPHONY /* 0x4000 */
|
||||
#define BTA_JV_SERVICE_INFORMATION BTM_COD_SERVICE_INFORMATION /* 0x8000 */
|
||||
|
||||
/* JV ID type */
|
||||
#define BTA_JV_PM_ID_1 1 /* PM example profile 1 */
|
||||
#define BTA_JV_PM_ID_2 2 /* PM example profile 2 */
|
||||
#define BTA_JV_PM_ID_CLEAR 0 /* Special JV ID used to clear PM profile */
|
||||
#define BTA_JV_PM_ALL 0xFF /* Generic match all id, see bta_dm_cfg.c */
|
||||
typedef UINT8 tBTA_JV_PM_ID;
|
||||
|
||||
#define BTA_JV_PM_HANDLE_CLEAR 0xFF /* Special JV ID used to clear PM profile */
|
||||
|
||||
/* define maximum number of registered PM entities. should be in sync with bta pm! */
|
||||
#ifndef BTA_JV_PM_MAX_NUM
|
||||
#define BTA_JV_PM_MAX_NUM 5
|
||||
#endif
|
||||
|
||||
/* JV pm connection states */
|
||||
enum {
|
||||
BTA_JV_CONN_OPEN = 0, /* Connection opened state */
|
||||
BTA_JV_CONN_CLOSE, /* Connection closed state */
|
||||
BTA_JV_APP_OPEN, /* JV Application opened state */
|
||||
BTA_JV_APP_CLOSE, /* JV Application closed state */
|
||||
BTA_JV_SCO_OPEN, /* SCO connection opened state */
|
||||
BTA_JV_SCO_CLOSE, /* SCO connection opened state */
|
||||
BTA_JV_CONN_IDLE, /* Connection idle state */
|
||||
BTA_JV_CONN_BUSY, /* Connection busy state */
|
||||
BTA_JV_MAX_CONN_STATE /* Max number of connection state */
|
||||
};
|
||||
typedef UINT8 tBTA_JV_CONN_STATE;
|
||||
|
||||
/* JV Connection types */
|
||||
#define BTA_JV_CONN_TYPE_RFCOMM 0
|
||||
#define BTA_JV_CONN_TYPE_L2CAP 1
|
||||
#define BTA_JV_CONN_TYPE_L2CAP_LE 2
|
||||
|
||||
/* Java I/F callback events */
|
||||
/* events received by tBTA_JV_DM_CBACK */
|
||||
#define BTA_JV_ENABLE_EVT 0 /* JV enabled */
|
||||
#define BTA_JV_GET_SCN_EVT 6 /* Reserved an SCN */
|
||||
#define BTA_JV_GET_PSM_EVT 7 /* Reserved a PSM */
|
||||
#define BTA_JV_DISCOVERY_COMP_EVT 8 /* SDP discovery complete */
|
||||
#define BTA_JV_CREATE_RECORD_EVT 11 /* the result for BTA_JvCreateRecord */
|
||||
/* events received by tBTA_JV_L2CAP_CBACK */
|
||||
#define BTA_JV_L2CAP_OPEN_EVT 16 /* open status of L2CAP connection */
|
||||
#define BTA_JV_L2CAP_CLOSE_EVT 17 /* L2CAP connection closed */
|
||||
#define BTA_JV_L2CAP_START_EVT 18 /* L2CAP server started */
|
||||
#define BTA_JV_L2CAP_CL_INIT_EVT 19 /* L2CAP client initiated a connection */
|
||||
#define BTA_JV_L2CAP_DATA_IND_EVT 20 /* L2CAP connection received data */
|
||||
#define BTA_JV_L2CAP_CONG_EVT 21 /* L2CAP connection congestion status changed */
|
||||
#define BTA_JV_L2CAP_READ_EVT 22 /* the result for BTA_JvL2capRead */
|
||||
#define BTA_JV_L2CAP_RECEIVE_EVT 23 /* the result for BTA_JvL2capReceive*/
|
||||
#define BTA_JV_L2CAP_WRITE_EVT 24 /* the result for BTA_JvL2capWrite*/
|
||||
#define BTA_JV_L2CAP_WRITE_FIXED_EVT 25 /* the result for BTA_JvL2capWriteFixed */
|
||||
|
||||
/* events received by tBTA_JV_RFCOMM_CBACK */
|
||||
#define BTA_JV_RFCOMM_OPEN_EVT 26 /* open status of RFCOMM Client connection */
|
||||
#define BTA_JV_RFCOMM_CLOSE_EVT 27 /* RFCOMM connection closed */
|
||||
#define BTA_JV_RFCOMM_START_EVT 28 /* RFCOMM server started */
|
||||
#define BTA_JV_RFCOMM_CL_INIT_EVT 29 /* RFCOMM client initiated a connection */
|
||||
#define BTA_JV_RFCOMM_DATA_IND_EVT 30 /* RFCOMM connection received data */
|
||||
#define BTA_JV_RFCOMM_CONG_EVT 31 /* RFCOMM connection congestion status changed */
|
||||
#define BTA_JV_RFCOMM_READ_EVT 32 /* the result for BTA_JvRfcommRead */
|
||||
#define BTA_JV_RFCOMM_WRITE_EVT 33 /* the result for BTA_JvRfcommWrite*/
|
||||
#define BTA_JV_RFCOMM_SRV_OPEN_EVT 34 /* open status of Server RFCOMM connection */
|
||||
#define BTA_JV_MAX_EVT 35 /* max number of JV events */
|
||||
|
||||
typedef UINT16 tBTA_JV_EVT;
|
||||
|
||||
/* data associated with BTA_JV_SET_DISCOVER_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
tBTA_JV_DISC disc_mode; /* The current discoverable mode */
|
||||
} tBTA_JV_SET_DISCOVER;
|
||||
|
||||
/* data associated with BTA_JV_DISCOVERY_COMP_EVT_ */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
UINT8 scn_num; /* num of channel */
|
||||
UINT8 scn[BTA_JV_MAX_SCN]; /* channel # */
|
||||
} tBTA_JV_DISCOVERY_COMP;
|
||||
|
||||
/* data associated with BTA_JV_CREATE_RECORD_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
UINT32 handle; /* The SDP handle */
|
||||
} tBTA_JV_CREATE_RECORD;
|
||||
|
||||
/* data associated with BTA_JV_L2CAP_OPEN_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
UINT32 handle; /* The connection handle */
|
||||
BD_ADDR rem_bda; /* The peer address */
|
||||
INT32 tx_mtu; /* The transmit MTU */
|
||||
} tBTA_JV_L2CAP_OPEN;
|
||||
|
||||
/* data associated with BTA_JV_L2CAP_OPEN_EVT for LE sockets */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
UINT32 handle; /* The connection handle */
|
||||
BD_ADDR rem_bda; /* The peer address */
|
||||
INT32 tx_mtu; /* The transmit MTU */
|
||||
void **p_p_cback; /* set them for new socket */
|
||||
void **p_user_data;/* set them for new socket */
|
||||
|
||||
} tBTA_JV_L2CAP_LE_OPEN;
|
||||
|
||||
|
||||
/* data associated with BTA_JV_L2CAP_CLOSE_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
UINT32 handle; /* The connection handle */
|
||||
BOOLEAN async; /* FALSE, if local initiates disconnect */
|
||||
} tBTA_JV_L2CAP_CLOSE;
|
||||
|
||||
/* data associated with BTA_JV_L2CAP_START_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
UINT32 handle; /* The connection handle */
|
||||
UINT8 sec_id; /* security ID used by this server */
|
||||
} tBTA_JV_L2CAP_START;
|
||||
|
||||
/* data associated with BTA_JV_L2CAP_CL_INIT_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
UINT32 handle; /* The connection handle */
|
||||
UINT8 sec_id; /* security ID used by this client */
|
||||
} tBTA_JV_L2CAP_CL_INIT;
|
||||
|
||||
/* data associated with BTA_JV_L2CAP_CONG_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
UINT32 handle; /* The connection handle */
|
||||
BOOLEAN cong; /* TRUE, congested. FALSE, uncongested */
|
||||
} tBTA_JV_L2CAP_CONG;
|
||||
|
||||
/* data associated with BTA_JV_L2CAP_READ_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
UINT32 handle; /* The connection handle */
|
||||
UINT32 req_id; /* The req_id in the associated BTA_JvL2capRead() */
|
||||
UINT8 *p_data; /* This points the same location as the p_data
|
||||
* parameter in BTA_JvL2capRead () */
|
||||
UINT16 len; /* The length of the data read. */
|
||||
} tBTA_JV_L2CAP_READ;
|
||||
|
||||
/* data associated with BTA_JV_L2CAP_RECEIVE_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
UINT32 handle; /* The connection handle */
|
||||
UINT32 req_id; /* The req_id in the associated BTA_JvL2capReceive() */
|
||||
UINT8 *p_data; /* This points the same location as the p_data
|
||||
* parameter in BTA_JvL2capReceive () */
|
||||
UINT16 len; /* The length of the data read. */
|
||||
} tBTA_JV_L2CAP_RECEIVE;
|
||||
|
||||
/* data associated with BTA_JV_L2CAP_WRITE_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
UINT32 handle; /* The connection handle */
|
||||
UINT32 req_id; /* The req_id in the associated BTA_JvL2capWrite() */
|
||||
UINT16 len; /* The length of the data written. */
|
||||
BOOLEAN cong; /* congestion status */
|
||||
} tBTA_JV_L2CAP_WRITE;
|
||||
|
||||
|
||||
/* data associated with BTA_JV_L2CAP_WRITE_FIXED_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
UINT16 channel; /* The connection channel */
|
||||
BD_ADDR addr; /* The peer address */
|
||||
UINT32 req_id; /* The req_id in the associated BTA_JvL2capWrite() */
|
||||
UINT16 len; /* The length of the data written. */
|
||||
BOOLEAN cong; /* congestion status */
|
||||
} tBTA_JV_L2CAP_WRITE_FIXED;
|
||||
|
||||
/* data associated with BTA_JV_RFCOMM_OPEN_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
UINT32 handle; /* The connection handle */
|
||||
BD_ADDR rem_bda; /* The peer address */
|
||||
} tBTA_JV_RFCOMM_OPEN;
|
||||
/* data associated with BTA_JV_RFCOMM_SRV_OPEN_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
UINT32 handle; /* The connection handle */
|
||||
UINT32 new_listen_handle; /* The new listen handle */
|
||||
BD_ADDR rem_bda; /* The peer address */
|
||||
} tBTA_JV_RFCOMM_SRV_OPEN;
|
||||
|
||||
|
||||
/* data associated with BTA_JV_RFCOMM_CLOSE_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
UINT32 port_status; /* PORT status */
|
||||
UINT32 handle; /* The connection handle */
|
||||
BOOLEAN async; /* FALSE, if local initiates disconnect */
|
||||
} tBTA_JV_RFCOMM_CLOSE;
|
||||
|
||||
/* data associated with BTA_JV_RFCOMM_START_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
UINT32 handle; /* The connection handle */
|
||||
UINT8 sec_id; /* security ID used by this server */
|
||||
BOOLEAN use_co; /* TRUE to use co_rfc_data */
|
||||
} tBTA_JV_RFCOMM_START;
|
||||
|
||||
/* data associated with BTA_JV_RFCOMM_CL_INIT_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
UINT32 handle; /* The connection handle */
|
||||
UINT8 sec_id; /* security ID used by this client */
|
||||
BOOLEAN use_co; /* TRUE to use co_rfc_data */
|
||||
} tBTA_JV_RFCOMM_CL_INIT;
|
||||
/*data associated with BTA_JV_L2CAP_DATA_IND_EVT & BTA_JV_RFCOMM_DATA_IND_EVT */
|
||||
typedef struct {
|
||||
UINT32 handle; /* The connection handle */
|
||||
BT_HDR *p_buf; /* The incoming data */
|
||||
} tBTA_JV_DATA_IND;
|
||||
|
||||
/*data associated with BTA_JV_L2CAP_DATA_IND_EVT if used for LE */
|
||||
typedef struct {
|
||||
UINT32 handle; /* The connection handle */
|
||||
BT_HDR *p_buf; /* The incoming data */
|
||||
} tBTA_JV_LE_DATA_IND;
|
||||
|
||||
|
||||
/* data associated with BTA_JV_RFCOMM_CONG_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
UINT32 handle; /* The connection handle */
|
||||
BOOLEAN cong; /* TRUE, congested. FALSE, uncongested */
|
||||
} tBTA_JV_RFCOMM_CONG;
|
||||
|
||||
/* data associated with BTA_JV_RFCOMM_READ_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
UINT32 handle; /* The connection handle */
|
||||
UINT32 req_id; /* The req_id in the associated BTA_JvRfcommRead() */
|
||||
UINT8 *p_data; /* This points the same location as the p_data
|
||||
* parameter in BTA_JvRfcommRead () */
|
||||
UINT16 len; /* The length of the data read. */
|
||||
} tBTA_JV_RFCOMM_READ;
|
||||
|
||||
/* data associated with BTA_JV_RFCOMM_WRITE_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
UINT32 handle; /* The connection handle */
|
||||
UINT32 req_id; /* The req_id in the associated BTA_JvRfcommWrite() */
|
||||
int len; /* The length of the data written. */
|
||||
BOOLEAN cong; /* congestion status */
|
||||
} tBTA_JV_RFCOMM_WRITE;
|
||||
|
||||
/* data associated with BTA_JV_API_SET_PM_PROFILE_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Status of the operation */
|
||||
UINT32 handle; /* Connection handle */
|
||||
tBTA_JV_PM_ID app_id; /* JV app ID */
|
||||
} tBTA_JV_SET_PM_PROFILE;
|
||||
|
||||
/* data associated with BTA_JV_API_NOTIFY_PM_STATE_CHANGE_EVT */
|
||||
typedef struct {
|
||||
UINT32 handle; /* Connection handle */
|
||||
tBTA_JV_CONN_STATE state; /* JV connection stata */
|
||||
} tBTA_JV_NOTIFY_PM_STATE_CHANGE;
|
||||
|
||||
|
||||
/* union of data associated with JV callback */
|
||||
typedef union {
|
||||
tBTA_JV_STATUS status; /* BTA_JV_ENABLE_EVT */
|
||||
tBTA_JV_DISCOVERY_COMP disc_comp; /* BTA_JV_DISCOVERY_COMP_EVT */
|
||||
tBTA_JV_SET_DISCOVER set_discover; /* BTA_JV_SET_DISCOVER_EVT */
|
||||
UINT8 scn; /* BTA_JV_GET_SCN_EVT */
|
||||
UINT16 psm; /* BTA_JV_GET_PSM_EVT */
|
||||
tBTA_JV_CREATE_RECORD create_rec; /* BTA_JV_CREATE_RECORD_EVT */
|
||||
tBTA_JV_L2CAP_OPEN l2c_open; /* BTA_JV_L2CAP_OPEN_EVT */
|
||||
tBTA_JV_L2CAP_CLOSE l2c_close; /* BTA_JV_L2CAP_CLOSE_EVT */
|
||||
tBTA_JV_L2CAP_START l2c_start; /* BTA_JV_L2CAP_START_EVT */
|
||||
tBTA_JV_L2CAP_CL_INIT l2c_cl_init; /* BTA_JV_L2CAP_CL_INIT_EVT */
|
||||
tBTA_JV_L2CAP_CONG l2c_cong; /* BTA_JV_L2CAP_CONG_EVT */
|
||||
tBTA_JV_L2CAP_READ l2c_read; /* BTA_JV_L2CAP_READ_EVT */
|
||||
tBTA_JV_L2CAP_WRITE l2c_write; /* BTA_JV_L2CAP_WRITE_EVT */
|
||||
tBTA_JV_RFCOMM_OPEN rfc_open; /* BTA_JV_RFCOMM_OPEN_EVT */
|
||||
tBTA_JV_RFCOMM_SRV_OPEN rfc_srv_open; /* BTA_JV_RFCOMM_SRV_OPEN_EVT */
|
||||
tBTA_JV_RFCOMM_CLOSE rfc_close; /* BTA_JV_RFCOMM_CLOSE_EVT */
|
||||
tBTA_JV_RFCOMM_START rfc_start; /* BTA_JV_RFCOMM_START_EVT */
|
||||
tBTA_JV_RFCOMM_CL_INIT rfc_cl_init; /* BTA_JV_RFCOMM_CL_INIT_EVT */
|
||||
tBTA_JV_RFCOMM_CONG rfc_cong; /* BTA_JV_RFCOMM_CONG_EVT */
|
||||
tBTA_JV_RFCOMM_READ rfc_read; /* BTA_JV_RFCOMM_READ_EVT */
|
||||
tBTA_JV_RFCOMM_WRITE rfc_write; /* BTA_JV_RFCOMM_WRITE_EVT */
|
||||
tBTA_JV_DATA_IND data_ind; /* BTA_JV_L2CAP_DATA_IND_EVT
|
||||
BTA_JV_RFCOMM_DATA_IND_EVT */
|
||||
tBTA_JV_LE_DATA_IND le_data_ind; /* BTA_JV_L2CAP_LE_DATA_IND_EVT */
|
||||
tBTA_JV_L2CAP_LE_OPEN l2c_le_open; /* BTA_JV_L2CAP_OPEN_EVT */
|
||||
tBTA_JV_L2CAP_WRITE_FIXED l2c_write_fixed; /* BTA_JV_L2CAP_WRITE_FIXED_EVT */
|
||||
} tBTA_JV;
|
||||
|
||||
/* JAVA DM Interface callback */
|
||||
typedef void (tBTA_JV_DM_CBACK)(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_data);
|
||||
|
||||
/* JAVA RFCOMM interface callback */
|
||||
typedef void *(tBTA_JV_RFCOMM_CBACK)(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_data);
|
||||
|
||||
/* JAVA L2CAP interface callback */
|
||||
typedef void (tBTA_JV_L2CAP_CBACK)(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_Data);
|
||||
|
||||
/* JV configuration structure */
|
||||
typedef struct {
|
||||
UINT16 sdp_raw_size; /* The size of p_sdp_raw_data */
|
||||
UINT16 sdp_db_size; /* The size of p_sdp_db */
|
||||
UINT8 *p_sdp_raw_data; /* The data buffer to keep raw data */
|
||||
tSDP_DISCOVERY_DB *p_sdp_db; /* The data buffer to keep SDP database */
|
||||
} tBTA_JV_CFG;
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvEnable
|
||||
**
|
||||
** Description Enable the Java I/F service. When the enable
|
||||
** operation is complete the callback function will be
|
||||
** called with a BTA_JV_ENABLE_EVT. This function must
|
||||
** be called before other functions in the JV API are
|
||||
** called.
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS if successful.
|
||||
** BTA_JV_FAIL if internal failure.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvEnable(tBTA_JV_DM_CBACK *p_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvDisable
|
||||
**
|
||||
** Description Disable the Java I/F
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_JvDisable(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvIsEnable
|
||||
**
|
||||
** Description Get the JV registration status.
|
||||
**
|
||||
** Returns TRUE, if registered
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN BTA_JvIsEnable(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvIsEncrypted
|
||||
**
|
||||
** Description This function checks if the link to peer device is encrypted
|
||||
**
|
||||
** Returns TRUE if encrypted.
|
||||
** FALSE if not.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN BTA_JvIsEncrypted(BD_ADDR bd_addr);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvGetChannelId
|
||||
**
|
||||
** Description This function reserves a SCN/PSM for applications running
|
||||
** over RFCOMM or L2CAP. It is primarily called by
|
||||
** server profiles/applications to register their SCN/PSM into the
|
||||
** SDP database. The SCN is reported by the tBTA_JV_DM_CBACK
|
||||
** callback with a BTA_JV_GET_SCN_EVT.
|
||||
** If the SCN/PSM reported is 0, that means all SCN resources are
|
||||
** exhausted.
|
||||
** The channel parameter can be used to request a specific
|
||||
** channel. If the request on the specific channel fails, the
|
||||
** SCN/PSM returned in the EVT will be 0 - no attempt to request
|
||||
** a new channel will be made. set channel to <= 0 to automatically
|
||||
** assign an channel ID.
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvGetChannelId(int conn_type, void *user_data,
|
||||
INT32 channel);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvFreeChannel
|
||||
**
|
||||
** Description This function frees a SCN/PSM that was used
|
||||
** by an application running over RFCOMM or L2CAP.
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvFreeChannel(UINT16 channel, int conn_type);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvStartDiscovery
|
||||
**
|
||||
** Description This function performs service discovery for the services
|
||||
** provided by the given peer device. When the operation is
|
||||
** complete the tBTA_JV_DM_CBACK callback function will be
|
||||
** called with a BTA_JV_DISCOVERY_COMP_EVT.
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvStartDiscovery(BD_ADDR bd_addr, UINT16 num_uuid,
|
||||
tSDP_UUID *p_uuid_list, void *user_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvCreateRecordByUser
|
||||
**
|
||||
** Description Create a service record in the local SDP database by user in
|
||||
** tBTA_JV_DM_CBACK callback with a BTA_JV_CREATE_RECORD_EVT.
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvCreateRecordByUser(const char *name, UINT32 channel, void *user_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvDeleteRecord
|
||||
**
|
||||
** Description Delete a service record in the local SDP database.
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvDeleteRecord(UINT32 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvL2capConnectLE
|
||||
**
|
||||
** Description Initiate a connection as an LE L2CAP client to the given BD
|
||||
** Address.
|
||||
** When the connection is initiated or failed to initiate,
|
||||
** tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_CL_INIT_EVT
|
||||
** When the connection is established or failed,
|
||||
** tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvL2capConnectLE(tBTA_SEC sec_mask, tBTA_JV_ROLE role,
|
||||
const tL2CAP_ERTM_INFO *ertm_info, UINT16 remote_chan,
|
||||
UINT16 rx_mtu, tL2CAP_CFG_INFO *cfg,
|
||||
BD_ADDR peer_bd_addr, tBTA_JV_L2CAP_CBACK *p_cback, void *user_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvL2capConnect
|
||||
**
|
||||
** Description Initiate a connection as a L2CAP client to the given BD
|
||||
** Address.
|
||||
** When the connection is initiated or failed to initiate,
|
||||
** tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_CL_INIT_EVT
|
||||
** When the connection is established or failed,
|
||||
** tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvL2capConnect(tBTA_SEC sec_mask, tBTA_JV_ROLE role,
|
||||
const tL2CAP_ERTM_INFO *ertm_info, UINT16 remote_psm,
|
||||
UINT16 rx_mtu, tL2CAP_CFG_INFO *cfg,
|
||||
BD_ADDR peer_bd_addr, tBTA_JV_L2CAP_CBACK *p_cback, void *user_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvL2capClose
|
||||
**
|
||||
** Description This function closes an L2CAP client connection
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvL2capClose(UINT32 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvL2capCloseLE
|
||||
**
|
||||
** Description This function closes an L2CAP client connection for Fixed Channels
|
||||
** Function is idempotent and no callbacks are called!
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvL2capCloseLE(UINT32 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvL2capStartServer
|
||||
**
|
||||
** Description This function starts an L2CAP server and listens for an L2CAP
|
||||
** connection from a remote Bluetooth device. When the server
|
||||
** is started successfully, tBTA_JV_L2CAP_CBACK is called with
|
||||
** BTA_JV_L2CAP_START_EVT. When the connection is established,
|
||||
** tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT.
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvL2capStartServer(tBTA_SEC sec_mask, tBTA_JV_ROLE role,
|
||||
const tL2CAP_ERTM_INFO *ertm_info,
|
||||
UINT16 local_psm, UINT16 rx_mtu, tL2CAP_CFG_INFO *cfg,
|
||||
tBTA_JV_L2CAP_CBACK *p_cback, void *user_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvL2capStartServerLE
|
||||
**
|
||||
** Description This function starts an LE L2CAP server and listens for an L2CAP
|
||||
** connection from a remote Bluetooth device on a fixed channel
|
||||
** over an LE link. When the server
|
||||
** is started successfully, tBTA_JV_L2CAP_CBACK is called with
|
||||
** BTA_JV_L2CAP_START_EVT. When the connection is established,
|
||||
** tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT.
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvL2capStartServerLE(tBTA_SEC sec_mask, tBTA_JV_ROLE role,
|
||||
const tL2CAP_ERTM_INFO *ertm_info,
|
||||
UINT16 local_chan, UINT16 rx_mtu, tL2CAP_CFG_INFO *cfg,
|
||||
tBTA_JV_L2CAP_CBACK *p_cback, void *user_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvL2capStopServerLE
|
||||
**
|
||||
** Description This function stops the LE L2CAP server. If the server has an
|
||||
** active connection, it would be closed.
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvL2capStopServerLE(UINT16 local_chan, void *user_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvL2capStopServerLE
|
||||
**
|
||||
** Description This function stops the LE L2CAP server. If the server has an
|
||||
** active connection, it would be closed.
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvL2capStopServer(UINT16 local_psm, void *user_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvL2capRead
|
||||
**
|
||||
** Description This function reads data from an L2CAP connection
|
||||
** When the operation is complete, tBTA_JV_L2CAP_CBACK is
|
||||
** called with BTA_JV_L2CAP_READ_EVT.
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvL2capRead(UINT32 handle, UINT32 req_id,
|
||||
UINT8 *p_data, UINT16 len);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvL2capReceive
|
||||
**
|
||||
** Description This function reads data from an L2CAP connection
|
||||
** When the operation is complete, tBTA_JV_L2CAP_CBACK is
|
||||
** called with BTA_JV_L2CAP_RECEIVE_EVT.
|
||||
** If there are more data queued in L2CAP than len, the extra data will be discarded.
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvL2capReceive(UINT32 handle, UINT32 req_id,
|
||||
UINT8 *p_data, UINT16 len);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvL2capReady
|
||||
**
|
||||
** Description This function determined if there is data to read from
|
||||
** an L2CAP connection
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if data queue size is in *p_data_size.
|
||||
** BTA_JV_FAILURE, if error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvL2capReady(UINT32 handle, UINT32 *p_data_size);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvL2capWrite
|
||||
**
|
||||
** Description This function writes data to an L2CAP connection
|
||||
** When the operation is complete, tBTA_JV_L2CAP_CBACK is
|
||||
** called with BTA_JV_L2CAP_WRITE_EVT. Works for
|
||||
** PSM-based connections
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvL2capWrite(UINT32 handle, UINT32 req_id,
|
||||
UINT8 *p_data, UINT16 len, void *user_data);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvL2capWriteFixed
|
||||
**
|
||||
** Description This function writes data to an L2CAP connection
|
||||
** When the operation is complete, tBTA_JV_L2CAP_CBACK is
|
||||
** called with BTA_JV_L2CAP_WRITE_FIXED_EVT. Works for
|
||||
** fixed-channel connections
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvL2capWriteFixed(UINT16 channel, BD_ADDR *addr, UINT32 req_id,
|
||||
tBTA_JV_L2CAP_CBACK *p_cback,
|
||||
UINT8 *p_data, UINT16 len, void *user_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvRfcommConnect
|
||||
**
|
||||
** Description This function makes an RFCOMM conection to a remote BD
|
||||
** Address.
|
||||
** When the connection is initiated or failed to initiate,
|
||||
** tBTA_JV_RFCOMM_CBACK is called with BTA_JV_RFCOMM_CL_INIT_EVT
|
||||
** When the connection is established or failed,
|
||||
** tBTA_JV_RFCOMM_CBACK is called with BTA_JV_RFCOMM_OPEN_EVT
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvRfcommConnect(tBTA_SEC sec_mask,
|
||||
tBTA_JV_ROLE role, UINT8 remote_scn, BD_ADDR peer_bd_addr,
|
||||
tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvRfcommClose
|
||||
**
|
||||
** Description This function closes an RFCOMM connection
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, void *user_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvRfcommStartServer
|
||||
**
|
||||
** Description This function starts listening for an RFCOMM connection
|
||||
** request from a remote Bluetooth device. When the server is
|
||||
** started successfully, tBTA_JV_RFCOMM_CBACK is called
|
||||
** with BTA_JV_RFCOMM_START_EVT.
|
||||
** When the connection is established, tBTA_JV_RFCOMM_CBACK
|
||||
** is called with BTA_JV_RFCOMM_OPEN_EVT.
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvRfcommStartServer(tBTA_SEC sec_mask,
|
||||
tBTA_JV_ROLE role, UINT8 local_scn, UINT8 max_session,
|
||||
tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvRfcommStopServer
|
||||
**
|
||||
** Description This function stops the RFCOMM server. If the server has an
|
||||
** active connection, it would be closed.
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvRfcommStopServer(UINT32 handle, void *user_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvRfcommRead
|
||||
**
|
||||
** Description This function reads data from an RFCOMM connection
|
||||
** When the operation is complete, tBTA_JV_RFCOMM_CBACK is
|
||||
** called with BTA_JV_RFCOMM_READ_EVT.
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvRfcommRead(UINT32 handle, UINT32 req_id,
|
||||
UINT8 *p_data, UINT16 len);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvRfcommReady
|
||||
**
|
||||
** Description This function determined if there is data to read from
|
||||
** an RFCOMM connection
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if data queue size is in *p_data_size.
|
||||
** BTA_JV_FAILURE, if error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvRfcommReady(UINT32 handle, UINT32 *p_data_size);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvRfcommWrite
|
||||
**
|
||||
** Description This function writes data to an RFCOMM connection
|
||||
** When the operation is complete, tBTA_JV_RFCOMM_CBACK is
|
||||
** called with BTA_JV_RFCOMM_WRITE_EVT.
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
// extern tBTA_JV_STATUS BTA_JvRfcommWrite(UINT32 handle, UINT32 req_id);
|
||||
extern tBTA_JV_STATUS BTA_JvRfcommWrite(UINT32 handle, UINT32 req_id, int len, UINT8 *p_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JVSetPmProfile
|
||||
**
|
||||
** Description This function set or free power mode profile for different JV application
|
||||
**
|
||||
** Parameters: handle, JV handle from RFCOMM or L2CAP
|
||||
** app_id: app specific pm ID, can be BTA_JV_PM_ALL, see bta_dm_cfg.c for details
|
||||
** BTA_JV_PM_ID_CLEAR: removes pm management on the handle. init_st is ignored and
|
||||
** BTA_JV_CONN_CLOSE is called implicitely
|
||||
** init_st: state after calling this API. typically it should be BTA_JV_CONN_OPEN
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
** NOTE: BTA_JV_PM_ID_CLEAR: In general no need to be called as jv pm calls automatically
|
||||
** BTA_JV_CONN_CLOSE to remove in case of connection close!
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvSetPmProfile(UINT32 handle, tBTA_JV_PM_ID app_id,
|
||||
tBTA_JV_CONN_STATE init_st);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvRfcommGetPortHdl
|
||||
**
|
||||
** Description This function fetches the rfcomm port handle
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
UINT16 BTA_JvRfcommGetPortHdl(UINT32 handle);
|
||||
|
||||
#endif ///defined BTA_JV_INCLUDED && BTA_JV_INCLUDED == TRUE
|
||||
#endif /* BTA_JV_API_H */
|
55
tools/sdk/include/bluedroid/bta_jv_co.h
Normal file
55
tools/sdk/include/bluedroid/bta_jv_co.h
Normal file
@ -0,0 +1,55 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2007-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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This is the interface file for java interface call-out functions.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef BTA_JV_CO_H
|
||||
#define BTA_JV_CO_H
|
||||
|
||||
#include "bta_jv_api.h"
|
||||
|
||||
#if (defined BTA_JV_INCLUDED && BTA_JV_INCLUDED == TRUE)
|
||||
/*****************************************************************************
|
||||
** Function Declarations
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_jv_co_rfc_data
|
||||
**
|
||||
** Description This function is called by JV to send data to the java glue
|
||||
** code when the RX data path is configured to use a call-out
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
|
||||
extern int bta_co_rfc_data_incoming(void *user_data, BT_HDR *p_buf);
|
||||
extern int bta_co_rfc_data_outgoing_size(void *user_data, int *size);
|
||||
extern int bta_co_rfc_data_outgoing(void *user_data, UINT8 *buf, UINT16 size);
|
||||
|
||||
extern int bta_co_l2cap_data_incoming(void *user_data, BT_HDR *p_buf);
|
||||
extern int bta_co_l2cap_data_outgoing_size(void *user_data, int *size);
|
||||
extern int bta_co_l2cap_data_outgoing(void *user_data, UINT8 *buf, UINT16 size);
|
||||
|
||||
#endif ///defined BTA_JV_INCLUDED && BTA_JV_INCLUDED == TRUE
|
||||
#endif /* BTA_DG_CO_H */
|
108
tools/sdk/include/bluedroid/btc_a2dp.h
Normal file
108
tools/sdk/include/bluedroid/btc_a2dp.h
Normal file
@ -0,0 +1,108 @@
|
||||
// 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.
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Filename: btc_a2dp.h
|
||||
*
|
||||
* Description: Common definitions for A2DP
|
||||
*
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef __BTC_A2DP_H__
|
||||
#define __BTC_A2DP_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "bt_target.h"
|
||||
#include "bta_api.h"
|
||||
#include "btc_av_api.h"
|
||||
#include "esp_a2dp_api.h"
|
||||
|
||||
#if BTC_AV_INCLUDED
|
||||
|
||||
/*******************************************************************************
|
||||
** Constants
|
||||
*******************************************************************************/
|
||||
#define BTC_AV_SUCCESS (0)
|
||||
/**
|
||||
* AV (Audio Video source) Errors
|
||||
*/
|
||||
#define BTC_ERROR_SRV_AV_NOT_ENABLED 700 /* AV is not enabled */
|
||||
#define BTC_ERROR_SRV_AV_FEEDING_NOT_SUPPORTED 701 /* Requested Feeding not supported */
|
||||
#define BTC_ERROR_SRV_AV_BUSY 702 /* Another operation ongoing */
|
||||
#define BTC_ERROR_SRV_AV_NOT_OPENED 703 /* No AV link opened */
|
||||
#define BTC_ERROR_SRV_AV_NOT_STARTED 704 /* AV is not started */
|
||||
#define BTC_ERROR_SRV_AV_CP_NOT_SUPPORTED 705 /* Content protection is not supported by all headsets */
|
||||
|
||||
/* Transcoding definition for TxTranscoding and RxTranscoding */
|
||||
#define BTC_MEDIA_TRSCD_OFF 0
|
||||
#define BTC_MEDIA_TRSCD_PCM_2_SBC 1 /* Tx */
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Data types
|
||||
*******************************************************************************/
|
||||
typedef int tBTC_AV_STATUS;
|
||||
|
||||
/*******************************************************************************
|
||||
** Public functions
|
||||
*******************************************************************************/
|
||||
|
||||
void btc_a2dp_on_init(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_a2dp_on_idle
|
||||
**
|
||||
** Description Process 'idle' request from BTC AV state machine during
|
||||
** initialization
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btc_a2dp_on_idle(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_a2dp_on_started
|
||||
**
|
||||
** Description Process 'start' request from BTC AV state machine to prepare
|
||||
** for A2DP streaming
|
||||
**
|
||||
** Return TRUE if an ACK for the local command is sent
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN btc_a2dp_on_started(tBTA_AV_START *p_av, BOOLEAN pending_start);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_a2dp_on_stopped
|
||||
**
|
||||
** Description Process 'stop' request from BTC AV state machine to stop
|
||||
** A2DP streaming
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btc_a2dp_on_stopped(tBTA_AV_SUSPEND *p_av);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_a2dp_on_suspended
|
||||
**
|
||||
** Description Process 'stop' request from BTC AV state machine to suspend
|
||||
** A2DP streaming
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btc_a2dp_on_suspended(tBTA_AV_SUSPEND *p_av);
|
||||
|
||||
#endif /* #if BTC_AV_INCLUDED */
|
||||
|
||||
#endif /* __BTC_A2DP_H__ */
|
110
tools/sdk/include/bluedroid/btc_a2dp_control.h
Normal file
110
tools/sdk/include/bluedroid/btc_a2dp_control.h
Normal file
@ -0,0 +1,110 @@
|
||||
// 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.
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Filename: btc_a2dp_control.h
|
||||
*
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef __BTC_A2DP_CONTROL_H__
|
||||
#define __BTC_A2DP_CONTROL_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "bt_target.h"
|
||||
#include "bta_api.h"
|
||||
#include "btc_av_api.h"
|
||||
#include "esp_a2dp_api.h"
|
||||
|
||||
#if BTC_AV_INCLUDED
|
||||
/*******************************************************************************
|
||||
** Public functions
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_a2dp_control_media_ctrl
|
||||
**
|
||||
** Description Handle the media_ctrl command
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_a2dp_control_datapath_ctrl
|
||||
**
|
||||
** Description Handle the media datapath event, which is adapted from UIPC
|
||||
** data channel from bluedroid
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btc_a2dp_control_datapath_ctrl(uint32_t dp_evt);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_a2dp_control_command_ack
|
||||
**
|
||||
** Description Acknowledge the pending media_ctrl command
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btc_a2dp_control_command_ack(int status);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_a2dp_control_get_datachnl_stat
|
||||
**
|
||||
** Description Check whether the data channel state is open
|
||||
**
|
||||
** Return TRUE if the data channel state is open
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN btc_a2dp_control_get_datachnl_stat(void);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_a2dp_control_set_datachnl_stat
|
||||
**
|
||||
** Description Set the data channel state flag
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btc_a2dp_control_set_datachnl_stat(BOOLEAN open);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_a2dp_control_init
|
||||
**
|
||||
** Description Initialize the A2DP control module. It should be called during
|
||||
** the startup stage of A2DP streaming.
|
||||
**
|
||||
*******************************************************************************/
|
||||
bool btc_a2dp_control_init(void);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_a2dp_control_cleanup
|
||||
**
|
||||
** Description Cleanup the A2DP control module
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btc_a2dp_control_cleanup(void);
|
||||
|
||||
#endif /* #if BTC_AV_INCLUDED */
|
||||
|
||||
#endif /* __BTC_A2DP_CONTROL_H__ */
|
139
tools/sdk/include/bluedroid/btc_a2dp_sink.h
Normal file
139
tools/sdk/include/bluedroid/btc_a2dp_sink.h
Normal file
@ -0,0 +1,139 @@
|
||||
// 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.
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Filename: btc_a2dp_sink.h
|
||||
*
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef __BTC_A2DP_SINK_H__
|
||||
#define __BTC_A2DP_SINK_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "bt_target.h"
|
||||
#include "bta_api.h"
|
||||
#include "btc_av_api.h"
|
||||
#include "esp_a2dp_api.h"
|
||||
|
||||
#if BTC_AV_SINK_INCLUDED
|
||||
/*******************************************************************************
|
||||
** Data types
|
||||
*******************************************************************************/
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT8 codec_info[AVDT_CODEC_SIZE];
|
||||
} tBTC_MEDIA_SINK_CFG_UPDATE;
|
||||
|
||||
/*******************************************************************************
|
||||
** Public functions
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_a2dp_sink_startup
|
||||
**
|
||||
** Description Initialize and startup the A2DP sink module. This function
|
||||
** should be called by the BTC AV state machine prior to using
|
||||
** the module.
|
||||
**
|
||||
** Returns true if success
|
||||
**
|
||||
*******************************************************************************/
|
||||
bool btc_a2dp_sink_startup(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_a2dp_sink_shutdown
|
||||
**
|
||||
** Description Shutdown and cleanup the A2DP sink module
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btc_a2dp_sink_shutdown(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_a2dp_sink_rx_flush_req
|
||||
**
|
||||
** Description Request to flush audio decoding pipe
|
||||
**
|
||||
** Returns TRUE if success
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN btc_a2dp_sink_rx_flush_req(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_a2dp_sink_enque_buf
|
||||
**
|
||||
** Description Enqueue a Advance Audio media buffer to be processed by btc media task.
|
||||
**
|
||||
** Returns size of the queue
|
||||
**
|
||||
*******************************************************************************/
|
||||
UINT8 btc_a2dp_sink_enque_buf(BT_HDR *p_buf);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_a2dp_sink_on_idle
|
||||
**
|
||||
** Description Process 'idle' request from the BTC AV state machine during
|
||||
** initialization
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btc_a2dp_sink_on_idle(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_a2dp_sink_on_stopped
|
||||
**
|
||||
** Description Process 'stop' request from the BTC AV state machine to stop
|
||||
** A2DP streaming
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btc_a2dp_sink_on_stopped(tBTA_AV_SUSPEND *p_av);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_a2dp_sink_on_suspended
|
||||
**
|
||||
** Description Process 'suspend' request from the BTC AV state machine to
|
||||
** suspend A2DP streaming
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btc_a2dp_sink_on_suspended(tBTA_AV_SUSPEND *p_av);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_a2dp_sink_set_rx_flush
|
||||
**
|
||||
** Description enable/disabel discarding of received A2DP frames
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btc_a2dp_sink_set_rx_flush(BOOLEAN enable);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_a2dp_sink_reset_decoder
|
||||
**
|
||||
** Description Reset decoder parameters according to configuration from remote
|
||||
** device
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btc_a2dp_sink_reset_decoder(UINT8 *p_av);
|
||||
|
||||
#endif /* #if BTC_AV_SINK_INCLUDED */
|
||||
|
||||
#endif /* __BTC_A2DP_SINK_H__ */
|
@ -14,46 +14,24 @@
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Filename: btc_media.h
|
||||
*
|
||||
* Description: This is the audio module for the BTC system.
|
||||
* Filename: btc_a2dp_source.h
|
||||
*
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef __BTC_MEDIA_H__
|
||||
#define __BTC_MEDIA_H__
|
||||
#ifndef __BTC_A2DP_SOURCE_H__
|
||||
#define __BTC_A2DP_SOURCE_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "bt_target.h"
|
||||
#include "bta_api.h"
|
||||
#include "btc_av_api.h"
|
||||
#include "esp_a2dp_api.h"
|
||||
|
||||
#if (BTA_AV_INCLUDED == TRUE)
|
||||
|
||||
/*******************************************************************************
|
||||
** Constants
|
||||
*******************************************************************************/
|
||||
#define BTC_SUCCESS (0)
|
||||
/**
|
||||
* AV (Audio Video source) Errors
|
||||
*/
|
||||
#define BTC_ERROR_SRV_AV_NOT_ENABLED 700 /* AV is not enabled */
|
||||
#define BTC_ERROR_SRV_AV_FEEDING_NOT_SUPPORTED 701 /* Requested Feeding not supported */
|
||||
#define BTC_ERROR_SRV_AV_BUSY 702 /* Another operation ongoing */
|
||||
#define BTC_ERROR_SRV_AV_NOT_OPENED 703 /* No AV link opened */
|
||||
#define BTC_ERROR_SRV_AV_NOT_STARTED 704 /* AV is not started */
|
||||
#define BTC_ERROR_SRV_AV_CP_NOT_SUPPORTED 705 /* Content protection is not supported by all headsets */
|
||||
|
||||
/* Transcoding definition for TxTranscoding and RxTranscoding */
|
||||
#define BTC_MEDIA_TRSCD_OFF 0
|
||||
#define BTC_MEDIA_TRSCD_PCM_2_SBC 1 /* Tx */
|
||||
|
||||
|
||||
#if BTC_AV_SRC_INCLUDED
|
||||
/*******************************************************************************
|
||||
** Data types
|
||||
*******************************************************************************/
|
||||
|
||||
typedef int tBTC_STATUS;
|
||||
|
||||
/* tBTC_MEDIA_INIT_AUDIO msg structure */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
@ -65,7 +43,6 @@ typedef struct {
|
||||
UINT16 MtuSize; /* peer mtu size */
|
||||
} tBTC_MEDIA_INIT_AUDIO;
|
||||
|
||||
#if (BTA_AV_INCLUDED == TRUE)
|
||||
/* tBTC_MEDIA_UPDATE_AUDIO msg structure */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
@ -81,187 +58,187 @@ typedef struct {
|
||||
tBTC_AV_MEDIA_FEEDINGS feeding;
|
||||
} tBTC_MEDIA_INIT_AUDIO_FEEDING;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT8 codec_info[AVDT_CODEC_SIZE];
|
||||
} tBTC_MEDIA_SINK_CFG_UPDATE;
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
** Public functions
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_av_task
|
||||
** Function btc_a2dp_source_startup
|
||||
**
|
||||
** Description
|
||||
** Description Initialize and startup the A2DP source module. This function
|
||||
** should be called by the BTC AV state machine prior to using
|
||||
** the module
|
||||
**
|
||||
** Returns void
|
||||
** Returns TRUE is success
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void btc_media_task(void);
|
||||
bool btc_a2dp_source_startup(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_media_task_enc_init_req
|
||||
** Function btc_a2dp_source_shutdown
|
||||
**
|
||||
** Description Shutdown and cleanup the A2DP source module.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btc_a2dp_source_shutdown(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_a2dp_source_enc_init_req
|
||||
**
|
||||
** Description Request to initialize the media task encoder
|
||||
**
|
||||
** Returns TRUE is success
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN btc_media_task_enc_init_req(tBTC_MEDIA_INIT_AUDIO *p_msg);
|
||||
BOOLEAN btc_a2dp_source_enc_init_req(tBTC_MEDIA_INIT_AUDIO *p_msg);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_media_task_enc_update_req
|
||||
** Function btc_a2dp_source_enc_udpate_req
|
||||
**
|
||||
** Description Request to update the media task encoder
|
||||
**
|
||||
** Returns TRUE is success
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (BTA_AV_INCLUDED == TRUE)
|
||||
extern BOOLEAN btc_media_task_enc_update_req(tBTC_MEDIA_UPDATE_AUDIO *p_msg);
|
||||
#endif
|
||||
BOOLEAN btc_a2dp_source_enc_update_req(tBTC_MEDIA_UPDATE_AUDIO *p_msg);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_media_task_start_aa_req
|
||||
** Function btc_a2dp_source_start_audio_req
|
||||
**
|
||||
** Description Request to start audio encoding task
|
||||
**
|
||||
** Returns TRUE is success
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN btc_media_task_start_aa_req(void);
|
||||
BOOLEAN btc_a2dp_source_start_audio_req(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_media_task_stop_aa_req
|
||||
** Function btc_a2dp_source_stop_audio_req
|
||||
**
|
||||
** Description Request to stop audio encoding task
|
||||
**
|
||||
** Returns TRUE is success
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN btc_media_task_stop_aa_req(void);
|
||||
BOOLEAN btc_a2dp_source_stop_audio_req(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_media_task_aa_rx_flush_req
|
||||
**
|
||||
** Description Request to flush audio decoding pipe
|
||||
**
|
||||
** Returns TRUE is success
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN btc_media_task_aa_rx_flush_req(void);
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_media_task_aa_tx_flush_req
|
||||
** Function btc_a2dp_source_tx_flush_req
|
||||
**
|
||||
** Description Request to flush audio encoding pipe
|
||||
**
|
||||
** Returns TRUE is success
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN btc_media_task_aa_tx_flush_req(void);
|
||||
BOOLEAN btc_a2dp_source_tx_flush_req(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_media_aa_readbuf
|
||||
** Function btc_a2dp_source_audio_readbuf
|
||||
**
|
||||
** Description Read an audio buffer from the BTC media TX queue
|
||||
**
|
||||
** Returns pointer on a aa buffer ready to send
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BT_HDR *btc_media_aa_readbuf(void);
|
||||
BT_HDR *btc_a2dp_source_audio_readbuf(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_media_sink_enque_buf
|
||||
**
|
||||
** Description This function is called by the av_co to fill A2DP Sink Queue
|
||||
**
|
||||
**
|
||||
** Returns size of the queue
|
||||
*******************************************************************************/
|
||||
UINT8 btc_media_sink_enque_buf(BT_HDR *p_buf);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_media_aa_writebuf
|
||||
**
|
||||
** Description Enqueue a Advance Audio media buffer to be processed by btc media task.
|
||||
**
|
||||
** Returns TRUE is success
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void btc_media_aa_writebuf(BT_HDR *pBuf, UINT32 timestamp, UINT16 seq_num);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_media_av_writebuf
|
||||
**
|
||||
** Description Enqueue a video media buffer to be processed by btc media task.
|
||||
**
|
||||
** Returns TRUE is success
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN btc_media_av_writebuf(UINT8 *p_media, UINT32 media_len,
|
||||
UINT32 timestamp, UINT16 seq_num);
|
||||
|
||||
#if (BTA_AV_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_media_task_audio_feeding_init_req
|
||||
** Function btc_a2dp_source_audio_feeding_init_req
|
||||
**
|
||||
** Description Request to initialize audio feeding
|
||||
**
|
||||
** Returns TRUE is success
|
||||
** Returns TRUE if success
|
||||
**
|
||||
*******************************************************************************/
|
||||
|
||||
extern BOOLEAN btc_media_task_audio_feeding_init_req(tBTC_MEDIA_INIT_AUDIO_FEEDING *p_msg);
|
||||
#endif
|
||||
BOOLEAN btc_a2dp_source_audio_feeding_init_req(tBTC_MEDIA_INIT_AUDIO_FEEDING *p_msg);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function dump_codec_info
|
||||
** Function btc_a2dp_source_is_streaming
|
||||
**
|
||||
** Description Decode and display codec_info (for debug)
|
||||
**
|
||||
** Returns void
|
||||
** Description Check whether A2DP source is in streaming state
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void dump_codec_info(unsigned char *p_codec);
|
||||
bool btc_a2dp_source_is_streaming(void);
|
||||
|
||||
/**
|
||||
* Local adaptation helper functions between btc and media task
|
||||
*/
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_a2dp_source_is_task_shutting_down
|
||||
**
|
||||
** Description Check whether A2DP source media task is shutting down
|
||||
**
|
||||
*******************************************************************************/
|
||||
bool btc_a2dp_source_is_task_shutting_down(void);
|
||||
|
||||
bool btc_a2dp_start_media_task(void);
|
||||
void btc_a2dp_stop_media_task(void);
|
||||
|
||||
void btc_a2dp_on_init(void);
|
||||
void btc_a2dp_setup_codec(void);
|
||||
void btc_a2dp_on_idle(void);
|
||||
BOOLEAN btc_a2dp_on_started(tBTA_AV_START *p_av, BOOLEAN pending_start);
|
||||
void btc_a2dp_on_stop_req(void);
|
||||
void btc_a2dp_on_stopped(tBTA_AV_SUSPEND *p_av);
|
||||
void btc_a2dp_on_suspend(void);
|
||||
void btc_a2dp_on_suspended(tBTA_AV_SUSPEND *p_av);
|
||||
void btc_a2dp_set_rx_flush(BOOLEAN enable);
|
||||
void btc_media_check_iop_exceptions(UINT8 *peer_bda);
|
||||
void btc_reset_decoder(UINT8 *p_av);
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_a2dp_source_on_idle
|
||||
**
|
||||
** Description Request 'idle' request from BTC AV state machine during
|
||||
** initialization
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btc_a2dp_source_on_idle(void);
|
||||
|
||||
int btc_a2dp_get_track_frequency(UINT8 frequency);
|
||||
int btc_a2dp_get_track_channel_count(UINT8 channeltype);
|
||||
void btc_a2dp_set_peer_sep(UINT8 sep);
|
||||
#endif ///BTA_AV_INCLUDED == TRUE
|
||||
#endif
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_a2dp_source_on_stopped
|
||||
**
|
||||
** Description Process 'stop' request from the BTC AV state machine to stop
|
||||
** A2DP streaming
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btc_a2dp_source_on_stopped(tBTA_AV_SUSPEND *p_av);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_a2dp_source_on_suspended
|
||||
**
|
||||
** Description Process 'suspend' request from the BTC AV state machine to stop
|
||||
** A2DP streaming
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btc_a2dp_source_on_suspended(tBTA_AV_SUSPEND *p_av);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_a2dp_source_setup_codec
|
||||
**
|
||||
** Description initialize the encoder parameters
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btc_a2dp_source_setup_codec(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_a2dp_source_set_tx_flush
|
||||
**
|
||||
** Description enable/disable discarding of transmitted frames
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btc_a2dp_source_set_tx_flush(BOOLEAN enable);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_a2dp_source_encoder_update
|
||||
**
|
||||
** Description update changed SBC encoder parameters
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btc_a2dp_source_encoder_update(void);
|
||||
|
||||
#endif /* #if BTC_AV_SRC_INCLUDED */
|
||||
|
||||
#endif /* __BTC_A2DP_SOURCE_H__ */
|
@ -25,17 +25,23 @@
|
||||
#ifndef __BTC_AV_H__
|
||||
#define __BTC_AV_H__
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "esp_a2dp_api.h"
|
||||
#include "btc_task.h"
|
||||
#include "btc_common.h"
|
||||
#include "btc_sm.h"
|
||||
#include "bta_av_api.h"
|
||||
|
||||
#if (BTA_AV_INCLUDED == TRUE)
|
||||
#if (BTC_AV_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
** Type definitions for callback functions
|
||||
********************************************************************************/
|
||||
|
||||
enum {
|
||||
BTC_AV_DATAPATH_OPEN_EVT, // original UIPC_OPEN_EVT for data channel in bluedroid
|
||||
BTC_AV_DATAPATH_MAX_EVT,
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
BTC_AV_CONNECT_REQ_EVT = BTA_AV_MAX_EVT,
|
||||
BTC_AV_DISCONNECT_REQ_EVT,
|
||||
@ -46,21 +52,44 @@ typedef enum {
|
||||
} btc_av_sm_event_t;
|
||||
|
||||
typedef enum {
|
||||
#if BTC_AV_SINK_INCLUDED
|
||||
BTC_AV_SINK_API_INIT_EVT = 0,
|
||||
BTC_AV_SINK_API_DEINIT_EVT,
|
||||
BTC_AV_SINK_API_CONNECT_EVT,
|
||||
BTC_AV_SINK_API_DISCONNECT_EVT,
|
||||
BTC_AV_SINK_API_REG_DATA_CB_EVT,
|
||||
#endif /* BTC_AV_SINK_INCLUDED */
|
||||
#if BTC_AV_SRC_INCLUDED
|
||||
BTC_AV_SRC_API_INIT_EVT,
|
||||
BTC_AV_SRC_API_DEINIT_EVT,
|
||||
BTC_AV_SRC_API_CONNECT_EVT,
|
||||
BTC_AV_SRC_API_DISCONNECT_EVT,
|
||||
BTC_AV_SRC_API_REG_DATA_CB_EVT,
|
||||
#endif /* BTC_AV_SRC_INCLUDED */
|
||||
BTC_AV_API_MEDIA_CTRL_EVT,
|
||||
BTC_AV_DATAPATH_CTRL_EVT,
|
||||
} btc_av_act_t;
|
||||
|
||||
/* btc_av_args_t */
|
||||
typedef union {
|
||||
#if BTC_AV_SINK_INCLUDED
|
||||
// BTC_AV_SINK_CONFIG_REQ_EVT -- internal event
|
||||
esp_a2d_mcc_t mcc;
|
||||
// BTC_AV_SINK_API_CONNECT_EVT
|
||||
bt_bdaddr_t connect;
|
||||
// BTC_AV_SINK_API_REG_DATA_CB_EVT
|
||||
esp_a2d_data_cb_t data_cb;
|
||||
esp_a2d_sink_data_cb_t data_cb;
|
||||
#endif /* BTC_AV_SINK_INCLUDED */
|
||||
#if BTC_AV_SRC_INCLUDED
|
||||
// BTC_AV_SRC_API_REG_DATA_CB_EVT
|
||||
esp_a2d_source_data_cb_t src_data_cb;
|
||||
// BTC_AV_SRC_API_CONNECT
|
||||
bt_bdaddr_t src_connect;
|
||||
#endif /* BTC_AV_SRC_INCLUDED */
|
||||
// BTC_AV_API_MEDIA_CTRL_EVT
|
||||
esp_a2d_media_ctrl_t ctrl;
|
||||
// BTC_AV_DATAPATH_CTRL_EVT
|
||||
uint32_t dp_evt;
|
||||
} btc_av_args_t;
|
||||
|
||||
/*******************************************************************************
|
||||
@ -71,7 +100,9 @@ void btc_a2dp_call_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_a2dp_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_a2dp_sink_reg_data_cb(esp_a2d_data_cb_t callback);
|
||||
void btc_a2dp_sink_reg_data_cb(esp_a2d_sink_data_cb_t callback);
|
||||
|
||||
void btc_a2dp_src_reg_data_cb(esp_a2d_source_data_cb_t callback);
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_av_get_sm_handle
|
||||
@ -121,18 +152,6 @@ BOOLEAN btc_av_stream_started_ready(void);
|
||||
/* used to pass events to AV statemachine from other tasks */
|
||||
void btc_dispatch_sm_event(btc_av_sm_event_t event, void *p_data, int len);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_av_init
|
||||
**
|
||||
** Description Initializes btc AV if not already done
|
||||
**
|
||||
** Returns bt_status_t
|
||||
**
|
||||
*******************************************************************************/
|
||||
|
||||
bt_status_t btc_av_init(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_av_is_connected
|
||||
@ -146,6 +165,19 @@ bt_status_t btc_av_init(void);
|
||||
BOOLEAN btc_av_is_connected(void);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Function btc_av_get_peer_sep
|
||||
*
|
||||
* Description Get the stream endpoint type.
|
||||
*
|
||||
* Returns The stream endpoint type: either AVDT_TSEP_SRC or
|
||||
* AVDT_TSEP_SNK.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
uint8_t btc_av_get_peer_sep(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_av_is_peer_edr
|
||||
@ -171,6 +203,6 @@ BOOLEAN btc_av_is_peer_edr(void);
|
||||
********************************************************************************/
|
||||
void btc_av_clear_remote_suspend_flag(void);
|
||||
|
||||
#endif ///BTA_AV_INCLUDED == TRUE
|
||||
#endif ///BTC_AV_INCLUDED == TRUE
|
||||
|
||||
#endif /* __BTC_AV_H__ */
|
||||
|
@ -27,8 +27,6 @@
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "bta_av_api.h"
|
||||
|
||||
#include "btc_media.h"
|
||||
#include "a2d_api.h"
|
||||
#include "a2d_sbc.h"
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
#ifndef __BTC_AV_CO_H__
|
||||
#define __BTC_AV_CO_H__
|
||||
|
||||
#include "btc_media.h"
|
||||
#include "btc_a2dp.h"
|
||||
|
||||
#if (BTA_AV_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
@ -93,7 +93,7 @@ void bta_av_co_audio_codec_reset(void);
|
||||
** Returns TRUE if all opened devices support this codec, FALSE otherwise
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN bta_av_co_audio_codec_supported(tBTC_STATUS *p_status);
|
||||
BOOLEAN bta_av_co_audio_codec_supported(tBTC_AV_STATUS *p_status);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -106,7 +106,7 @@ BOOLEAN bta_av_co_audio_codec_supported(tBTC_STATUS *p_status);
|
||||
** Returns TRUE if successful, FALSE otherwise
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN bta_av_co_audio_set_codec(const tBTC_AV_MEDIA_FEEDINGS *p_feeding, tBTC_STATUS *p_status);
|
||||
BOOLEAN bta_av_co_audio_set_codec(const tBTC_AV_MEDIA_FEEDINGS *p_feeding, tBTC_AV_STATUS *p_status);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -28,18 +28,14 @@
|
||||
#define BTC_AVRC_TGT_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
/* Macros */
|
||||
typedef enum {
|
||||
BTRC_FEAT_NONE = 0x00, /* AVRCP 1.0 */
|
||||
BTRC_FEAT_METADATA = 0x01, /* AVRCP 1.3 */
|
||||
BTRC_FEAT_ABSOLUTE_VOLUME = 0x02, /* Supports TG role and volume sync */
|
||||
BTRC_FEAT_BROWSE = 0x04, /* AVRCP 1.4 and up, with Browsing support */
|
||||
} btrc_remote_features_t;
|
||||
|
||||
typedef enum {
|
||||
BTC_AVRC_CTRL_API_INIT_EVT = 0,
|
||||
BTC_AVRC_CTRL_API_DEINIT_EVT,
|
||||
BTC_AVRC_CTRL_API_SND_PTCMD_EVT
|
||||
BTC_AVRC_CTRL_API_SND_PTCMD_EVT,
|
||||
BTC_AVRC_STATUS_API_SND_META_EVT,
|
||||
BTC_AVRC_STATUS_API_SND_PLAY_STATUS_EVT,
|
||||
BTC_AVRC_NOTIFY_API_SND_REG_NOTIFY_EVT,
|
||||
BTC_AVRC_CTRL_API_SET_PLAYER_SETTING_EVT
|
||||
} btc_avrc_act_t;
|
||||
|
||||
typedef struct {
|
||||
@ -48,14 +44,29 @@ typedef struct {
|
||||
uint8_t key_state;
|
||||
} pt_cmd_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t tl;
|
||||
uint8_t attr_mask;
|
||||
} md_cmd_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t tl;
|
||||
uint8_t event_id;
|
||||
uint32_t event_parameter;
|
||||
} rn_cmd_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t tl;
|
||||
uint8_t attr_id;
|
||||
uint8_t value_id;
|
||||
} ps_cmd_t;
|
||||
|
||||
/* btc_avrc_args_t */
|
||||
typedef union {
|
||||
// BTC_AVRC_CTRL_API_SND_PT_CMD_EVT
|
||||
struct {
|
||||
uint8_t tl;
|
||||
uint8_t key_code;
|
||||
uint8_t key_state;
|
||||
} pt_cmd;
|
||||
pt_cmd_t pt_cmd;
|
||||
md_cmd_t md_cmd;
|
||||
rn_cmd_t rn_cmd;
|
||||
ps_cmd_t ps_cmd;
|
||||
} btc_avrc_args_t;
|
||||
|
||||
/** BT-RC Controller callback structure. */
|
||||
|
@ -23,6 +23,7 @@ typedef enum {
|
||||
BTC_BLUFI_ACT_INIT = 0,
|
||||
BTC_BLUFI_ACT_DEINIT,
|
||||
BTC_BLUFI_ACT_SEND_CFG_REPORT,
|
||||
BTC_BLUFI_ACT_SEND_WIFI_LIST,
|
||||
} btc_blufi_act_t;
|
||||
|
||||
typedef union {
|
||||
@ -33,6 +34,13 @@ typedef union {
|
||||
esp_blufi_extra_info_t *extra_info;
|
||||
int extra_info_len;
|
||||
} wifi_conn_report;
|
||||
/*
|
||||
BTC_BLUFI_ACT_SEND_WIFI_LIST
|
||||
*/
|
||||
struct blufi_wifi_list {
|
||||
uint16_t apCount;
|
||||
esp_blufi_ap_record_t *list;
|
||||
} wifi_list;
|
||||
} btc_blufi_args_t;
|
||||
|
||||
void btc_blufi_cb_handler(btc_msg_t *msg);
|
||||
|
@ -15,12 +15,23 @@
|
||||
#ifndef __BTC_GAP_BT_H__
|
||||
#define __BTC_GAP_BT_H__
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "esp_bt_defs.h"
|
||||
#include "esp_gap_bt_api.h"
|
||||
#include "btc_task.h"
|
||||
|
||||
#if (BTC_GAP_BT_INCLUDED == TRUE)
|
||||
|
||||
typedef enum {
|
||||
BTC_GAP_BT_ACT_SET_SCAN_MODE = 0,
|
||||
BTC_GAP_BT_ACT_REG_CB,
|
||||
BTC_GAP_BT_ACT_START_DISCOVERY,
|
||||
BTC_GAP_BT_ACT_SEARCH_DEVICES,
|
||||
BTC_GAP_BT_ACT_CANCEL_DISCOVERY,
|
||||
BTC_GAP_BT_ACT_GET_REMOTE_SERVICES,
|
||||
BTC_GAP_BT_ACT_SEARCH_SERVICES,
|
||||
BTC_GAP_BT_ACT_GET_REMOTE_SERVICE_RECORD,
|
||||
BTC_GAP_BT_ACT_SEARCH_SERVICE_RECORD,
|
||||
} btc_gap_bt_act_t;
|
||||
|
||||
/* btc_bt_gap_args_t */
|
||||
@ -29,10 +40,28 @@ typedef union {
|
||||
struct set_bt_scan_mode_args {
|
||||
esp_bt_scan_mode_t mode;
|
||||
} set_scan_mode;
|
||||
|
||||
// BTC_GAP_BT_ACT_START_DISCOVERY
|
||||
struct start_disc_args {
|
||||
esp_bt_inq_mode_t mode;
|
||||
uint8_t inq_len;
|
||||
uint8_t num_rsps;
|
||||
} start_disc;
|
||||
|
||||
// BTC_BT_GAP_ACT_GET_REMOTE_SERVICES
|
||||
bt_bdaddr_t bda;
|
||||
|
||||
// BTC_BT_GAP_ACT_GET_REMTOE_SERVICE_RECORD
|
||||
struct get_rmt_srv_rcd_args {
|
||||
bt_bdaddr_t bda;
|
||||
esp_bt_uuid_t uuid;
|
||||
} get_rmt_srv_rcd;
|
||||
} btc_gap_bt_args_t;
|
||||
|
||||
void btc_gap_bt_call_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_gap_bt_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
void btc_gap_bt_busy_level_updated(uint8_t bl_flags);
|
||||
|
||||
#endif /* #if BTC_GAP_BT_INCLUDED */
|
||||
|
||||
#endif /* __BTC_GAP_BT_H__ */
|
||||
|
89
tools/sdk/include/bluedroid/btc_spp.h
Normal file
89
tools/sdk/include/bluedroid/btc_spp.h
Normal file
@ -0,0 +1,89 @@
|
||||
// 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 __BTC_SPP_H__
|
||||
#define __BTC_SPP_H__
|
||||
|
||||
#include "btc_task.h"
|
||||
#include "esp_bt_defs.h"
|
||||
#include "esp_spp_api.h"
|
||||
#include "bt_target.h"
|
||||
#include "bta_jv_api.h"
|
||||
|
||||
#if (defined BTC_SPP_INCLUDED && BTC_SPP_INCLUDED == TRUE)
|
||||
|
||||
#define ESP_SPP_MAX_SESSION BTA_JV_MAX_RFC_SR_SESSION
|
||||
#define ESP_SPP_SERVER_NAME_MAX 32
|
||||
|
||||
typedef enum {
|
||||
BTC_SPP_ACT_INIT = 0,
|
||||
BTC_SPP_ACT_UNINIT,
|
||||
BTC_SPP_ACT_START_DISCOVERY,
|
||||
BTC_SPP_ACT_CONNECT,
|
||||
BTC_SPP_ACT_DISCONNECT,
|
||||
BTC_SPP_ACT_START_SRV,
|
||||
BTC_SPP_ACT_WRITE,
|
||||
} btc_spp_act_t;
|
||||
|
||||
/* btc_spp_args_t */
|
||||
typedef union {
|
||||
//BTC_SPP_ACT_INIT
|
||||
struct init_arg {
|
||||
} init;
|
||||
//BTC_SPP_ACT_UNINIT
|
||||
struct uninit_arg {
|
||||
} uninit;
|
||||
|
||||
//BTC_SPP_ACT_START_DISCOVERY
|
||||
struct start_discovery_arg {
|
||||
BD_ADDR bd_addr;
|
||||
UINT16 num_uuid;
|
||||
tSDP_UUID *p_uuid_list;
|
||||
} start_discovery;
|
||||
//BTC_SPP_ACT_CONNECT
|
||||
struct connect_arg {
|
||||
esp_spp_sec_t sec_mask;
|
||||
esp_spp_role_t role;
|
||||
UINT8 remote_scn;
|
||||
esp_bd_addr_t peer_bd_addr;
|
||||
} connect;
|
||||
//BTC_SPP_ACT_DISCONNECT
|
||||
struct disconnect_arg {
|
||||
UINT32 handle;
|
||||
} disconnect;
|
||||
//BTC_SPP_ACT_START_SRV
|
||||
struct start_srv_arg {
|
||||
esp_spp_sec_t sec_mask;
|
||||
esp_spp_role_t role;
|
||||
UINT8 local_scn;
|
||||
UINT8 max_session;
|
||||
char name[ESP_SPP_SERVER_NAME_MAX + 1];
|
||||
} start_srv;
|
||||
//BTC_SPP_ACT_WRITE
|
||||
struct write_arg {
|
||||
UINT32 handle;
|
||||
int len;
|
||||
UINT8 *p_data;
|
||||
} write;
|
||||
|
||||
} btc_spp_args_t;
|
||||
|
||||
|
||||
void btc_spp_call_handler(btc_msg_t *msg);
|
||||
void btc_spp_cb_handler(btc_msg_t *msg);
|
||||
void btc_spp_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
|
||||
#endif ///defined BTC_SPP_INCLUDED && BTC_SPP_INCLUDED == TRUE
|
||||
#endif ///__BTC_SPP_H__
|
@ -52,6 +52,7 @@ typedef enum {
|
||||
BTC_PID_PRF_QUE,
|
||||
BTC_PID_A2DP,
|
||||
BTC_PID_AVRC,
|
||||
BTC_PID_SPP,
|
||||
#endif /* CONFIG_CLASSIC_BT_ENABLED */
|
||||
BTC_PID_NUM,
|
||||
} btc_pid_t; //btc profile id
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <stdbool.h>
|
||||
#include "bt_types.h"
|
||||
#include "bt_defs.h"
|
||||
#include "esp_bt_defs.h"
|
||||
|
||||
/*******************************************************************************
|
||||
** Constants & Macros
|
||||
@ -39,9 +40,8 @@ const char *dump_rc_pdu(UINT8 pdu);
|
||||
|
||||
UINT32 devclass2uint(DEV_CLASS dev_class);
|
||||
void uint2devclass(UINT32 dev, DEV_CLASS dev_class);
|
||||
void uuid16_to_uuid128(uint16_t uuid16, bt_uuid_t *uuid128);
|
||||
void uuid128_be_to_esp_uuid(esp_bt_uuid_t *u, uint8_t* uuid128);
|
||||
|
||||
void uuid_to_string_legacy(bt_uuid_t *p_uuid, char *str);
|
||||
void string_to_uuid(char *str, bt_uuid_t *p_uuid);
|
||||
|
||||
#endif /* __BTC_UTIL_H__ */
|
||||
|
@ -852,6 +852,11 @@ typedef void (*tBLE_SCAN_PARAM_SETUP_CBACK)(tGATT_IF client_if, tBTM_STATUS stat
|
||||
|
||||
tBTM_BLE_SCAN_SETUP_CBACK bta_ble_scan_setup_cb;
|
||||
|
||||
typedef void (tBTM_START_ADV_CMPL_CBACK) (UINT8 status);
|
||||
typedef void (tBTM_START_STOP_ADV_CMPL_CBACK) (UINT8 status);
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** EXTERNAL FUNCTION DECLARATIONS
|
||||
*****************************************************************************/
|
||||
@ -943,7 +948,7 @@ tBTM_STATUS BTM_BleSetAdvParams(UINT16 adv_int_min, UINT16 adv_int_max,
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_BleSetAdvParamsStartAdv(UINT16 adv_int_min, UINT16 adv_int_max, UINT8 adv_type,
|
||||
tBLE_ADDR_TYPE own_bda_type, tBLE_BD_ADDR *p_dir_bda,
|
||||
tBTM_BLE_ADV_CHNL_MAP chnl_map, tBTM_BLE_AFP afp);
|
||||
tBTM_BLE_ADV_CHNL_MAP chnl_map, tBTM_BLE_AFP afp, tBTM_START_ADV_CMPL_CBACK *adv_cb);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@ -1610,7 +1615,7 @@ BOOLEAN BTM_ReadConnectedTransportAddress(BD_ADDR remote_bda,
|
||||
**
|
||||
*******************************************************************************/
|
||||
//extern
|
||||
tBTM_STATUS BTM_BleBroadcast(BOOLEAN start);
|
||||
tBTM_STATUS BTM_BleBroadcast(BOOLEAN start, tBTM_START_STOP_ADV_CMPL_CBACK *p_stop_adv_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -147,7 +147,8 @@ typedef struct {
|
||||
UINT16 adv_interval_max;
|
||||
tBTM_BLE_AFP afp; /* advertising filter policy */
|
||||
tBTM_BLE_SFP sfp; /* scanning filter policy */
|
||||
|
||||
tBTM_START_ADV_CMPL_CBACK *p_adv_cb;
|
||||
tBTM_START_STOP_ADV_CMPL_CBACK *p_stop_adv_cb;
|
||||
tBLE_ADDR_TYPE adv_addr_type;
|
||||
UINT8 evt_type;
|
||||
UINT8 adv_mode;
|
||||
@ -319,7 +320,6 @@ typedef struct {
|
||||
UINT32 scan_int;
|
||||
UINT32 scan_win;
|
||||
tBTM_BLE_SEL_CBACK *p_select_cback;
|
||||
|
||||
/* white list information */
|
||||
UINT8 white_list_avail_size;
|
||||
tBTM_ADD_WHITELIST_CBACK *add_wl_cb;
|
||||
|
@ -234,6 +234,7 @@ extern const BD_ADDR BT_BD_ANY;
|
||||
*/
|
||||
void btu_start_timer (TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout);
|
||||
void btu_stop_timer (TIMER_LIST_ENT *p_tle);
|
||||
void btu_free_timer (TIMER_LIST_ENT *p_tle);
|
||||
void btu_start_timer_oneshot(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout);
|
||||
void btu_stop_timer_oneshot(TIMER_LIST_ENT *p_tle);
|
||||
|
||||
|
@ -69,6 +69,7 @@ typedef struct controller_t {
|
||||
uint16_t (*get_acl_packet_size_ble)(void);
|
||||
|
||||
uint16_t (*get_ble_default_data_packet_length)(void);
|
||||
uint16_t (*get_ble_default_data_packet_txtime)(void);
|
||||
|
||||
// Get the number of acl packets the controller can buffer.
|
||||
uint16_t (*get_acl_buffer_count_classic)(void);
|
||||
|
@ -67,11 +67,28 @@ typedef enum {
|
||||
ESP_A2D_AUDIO_STATE_STARTED, /*!< audio stream datapath started */
|
||||
} esp_a2d_audio_state_t;
|
||||
|
||||
/// A2DP media control command acknowledgement code
|
||||
typedef enum {
|
||||
ESP_A2D_MEDIA_CTRL_ACK_SUCCESS = 0, /*!< media control command is acknowledged with success */
|
||||
ESP_A2D_MEDIA_CTRL_ACK_FAILURE, /*!< media control command is acknowledged with failure */
|
||||
ESP_A2D_MEDIA_CTRL_ACK_BUSY, /*!< media control command is rejected, as previous command is not yet acknowledged */
|
||||
} esp_a2d_media_ctrl_ack_t;
|
||||
|
||||
/// A2DP media control commands
|
||||
typedef enum {
|
||||
ESP_A2D_MEDIA_CTRL_NONE = 0, /*!< dummy command */
|
||||
ESP_A2D_MEDIA_CTRL_CHECK_SRC_RDY, /*!< check whether AVDTP is connected, only used in A2DP source */
|
||||
ESP_A2D_MEDIA_CTRL_START, /*!< command to set up media transmission channel */
|
||||
ESP_A2D_MEDIA_CTRL_STOP, /*!< command to stop media transmission */
|
||||
ESP_A2D_MEDIA_CTRL_SUSPEND, /*!< command to suspend media transmission */
|
||||
} esp_a2d_media_ctrl_t;
|
||||
|
||||
/// A2DP callback events
|
||||
typedef enum {
|
||||
ESP_A2D_CONNECTION_STATE_EVT = 0, /*!< connection state changed event */
|
||||
ESP_A2D_AUDIO_STATE_EVT = 1, /*!< audio stream transmission state changed event */
|
||||
ESP_A2D_AUDIO_CFG_EVT = 2 /*!< audio codec is configured */
|
||||
ESP_A2D_AUDIO_STATE_EVT, /*!< audio stream transmission state changed event */
|
||||
ESP_A2D_AUDIO_CFG_EVT, /*!< audio codec is configured, only used for A2DP SINK */
|
||||
ESP_A2D_MEDIA_CTRL_ACK_EVT, /*!< acknowledge event in response to media control commands */
|
||||
} esp_a2d_cb_event_t;
|
||||
|
||||
/// A2DP state callback parameters
|
||||
@ -100,32 +117,52 @@ typedef union {
|
||||
esp_bd_addr_t remote_bda; /*!< remote bluetooth device address */
|
||||
esp_a2d_mcc_t mcc; /*!< A2DP media codec capability information */
|
||||
} audio_cfg; /*!< media codec configuration infomation */
|
||||
|
||||
/**
|
||||
* @brief ESP_A2D_MEDIA_CTRL_ACK_EVT
|
||||
*/
|
||||
struct media_ctrl_stat_param {
|
||||
esp_a2d_media_ctrl_t cmd; /*!< media control commands to acknowledge */
|
||||
esp_a2d_media_ctrl_ack_t status; /*!< acknowledgement to media control commands */
|
||||
} media_ctrl_stat; /*!< status in acknowledgement to media control commands */
|
||||
} esp_a2d_cb_param_t;
|
||||
|
||||
/**
|
||||
* @brief A2DP profile callback function type
|
||||
*
|
||||
* @param event : Event type
|
||||
*
|
||||
* @param param : Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_a2d_cb_t)(esp_a2d_cb_event_t event, esp_a2d_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief A2DP profile data callback function
|
||||
*
|
||||
* @param[in] buf : data received from A2DP source device and is PCM format decoder from SBC decoder;
|
||||
* buf references to a static memory block and can be overwritten by upcoming data
|
||||
*
|
||||
* @param[in] len : size(in bytes) in buf
|
||||
*/
|
||||
typedef void (* esp_a2d_sink_data_cb_t)(const uint8_t *buf, uint32_t len);
|
||||
|
||||
/**
|
||||
* @brief A2DP source data read callback function
|
||||
*
|
||||
* @param[in] buf : buffer to be filled with PCM data stream from higer layer
|
||||
*
|
||||
* @param[in] len : size(in bytes) of data block to be copied to buf. -1 is an indication to user
|
||||
* that data buffer shall be flushed
|
||||
*
|
||||
* @return size of bytes read successfully, if the argumetn len is -1, this value is ignored.
|
||||
*
|
||||
*/
|
||||
typedef void (* esp_a2d_data_cb_t)(const uint8_t *buf, uint32_t len);
|
||||
|
||||
typedef int32_t (* esp_a2d_source_data_cb_t)(uint8_t *buf, int32_t len);
|
||||
|
||||
/**
|
||||
* @brief Register application callback function to A2DP module. This function should be called
|
||||
* only after esp_bluedroid_enable() completes successfully
|
||||
* only after esp_bluedroid_enable() completes successfully, used by both A2DP source
|
||||
* and sink.
|
||||
*
|
||||
* @param[in] callback: A2DP sink event callback function
|
||||
* @param[in] callback: A2DP event callback function
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
@ -139,9 +176,9 @@ esp_err_t esp_a2d_register_callback(esp_a2d_cb_t callback);
|
||||
/**
|
||||
* @brief Register A2DP sink data output function; For now the output is PCM data stream decoded
|
||||
* from SBC format. This function should be called only after esp_bluedroid_enable()
|
||||
* completes successfully
|
||||
* completes successfully, used only by A2DP sink.
|
||||
*
|
||||
* @param[in] callback: A2DP data callback function
|
||||
* @param[in] callback: A2DP sink data callback function
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
@ -149,7 +186,7 @@ esp_err_t esp_a2d_register_callback(esp_a2d_cb_t callback);
|
||||
* - ESP_FAIL: if callback is a NULL function pointer
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_a2d_register_data_callback(esp_a2d_data_cb_t callback);
|
||||
esp_err_t esp_a2d_sink_register_data_callback(esp_a2d_sink_data_cb_t callback);
|
||||
|
||||
|
||||
/**
|
||||
@ -182,7 +219,7 @@ esp_err_t esp_a2d_sink_deinit(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Connect the remote bluetooth device bluetooth, must after esp_a2d_sink_init()
|
||||
* @brief Connect to remote bluetooth A2DP source device, must after esp_a2d_sink_init()
|
||||
*
|
||||
* @param[in] remote_bda: remote bluetooth device address
|
||||
*
|
||||
@ -197,7 +234,7 @@ esp_err_t esp_a2d_sink_connect(esp_bd_addr_t remote_bda);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Disconnect the remote bluetooth device
|
||||
* @brief Disconnect from the remote A2DP source device
|
||||
*
|
||||
* @param[in] remote_bda: remote bluetooth device address
|
||||
* @return
|
||||
@ -208,6 +245,93 @@ esp_err_t esp_a2d_sink_connect(esp_bd_addr_t remote_bda);
|
||||
*/
|
||||
esp_err_t esp_a2d_sink_disconnect(esp_bd_addr_t remote_bda);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief media control commands; this API can be used for both A2DP sink and source
|
||||
*
|
||||
* @param[in] ctrl: control commands for A2DP data channel
|
||||
* @return
|
||||
* - ESP_OK: control command is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_a2d_media_ctrl(esp_a2d_media_ctrl_t ctrl);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Initialize the bluetooth A2DP source module. This function should be called
|
||||
* after esp_bluedroid_enable() completes successfully
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: if the initialization request is sent successfully
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_a2d_source_init(void);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief De-initialize for A2DP source module. This function
|
||||
* should be called only after esp_bluedroid_enable() completes successfully
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_a2d_source_deinit(void);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Register A2DP source data input function; For now the input is PCM data stream.
|
||||
* This function should be called only after esp_bluedroid_enable() completes
|
||||
* successfully
|
||||
*
|
||||
* @param[in] callback: A2DP source data callback function
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: if callback is a NULL function pointer
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_a2d_source_register_data_callback(esp_a2d_source_data_cb_t callback);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Connect to remote A2DP sink device, must after esp_a2d_source_init()
|
||||
*
|
||||
* @param[in] remote_bda: remote bluetooth device address
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: connect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_a2d_source_connect(esp_bd_addr_t remote_bda);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Disconnect from the remote A2DP sink device
|
||||
*
|
||||
* @param[in] remote_bda: remote bluetooth device address
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_a2d_source_disconnect(esp_bd_addr_t remote_bda);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -40,7 +40,9 @@ typedef enum {
|
||||
ESP_AVRC_PT_CMD_STOP = 0x45, /*!< stop */
|
||||
ESP_AVRC_PT_CMD_PAUSE = 0x46, /*!< pause */
|
||||
ESP_AVRC_PT_CMD_FORWARD = 0x4B, /*!< forward */
|
||||
ESP_AVRC_PT_CMD_BACKWARD = 0x4C /*!< backward */
|
||||
ESP_AVRC_PT_CMD_BACKWARD = 0x4C, /*!< backward */
|
||||
ESP_AVRC_PT_CMD_REWIND = 0x48, /*!< rewind */
|
||||
ESP_AVRC_PT_CMD_FAST_FORWARD = 0x49 /*!< fast forward */
|
||||
} esp_avrc_pt_cmd_t;
|
||||
|
||||
/// AVRC passthrough command state
|
||||
@ -53,9 +55,73 @@ typedef enum {
|
||||
typedef enum {
|
||||
ESP_AVRC_CT_CONNECTION_STATE_EVT = 0, /*!< connection state changed event */
|
||||
ESP_AVRC_CT_PASSTHROUGH_RSP_EVT = 1, /*!< passthrough response event */
|
||||
ESP_AVRC_CT_MAX_EVT
|
||||
ESP_AVRC_CT_METADATA_RSP_EVT = 2, /*!< metadata response event */
|
||||
ESP_AVRC_CT_PLAY_STATUS_RSP_EVT = 3, /*!< play status response event */
|
||||
ESP_AVRC_CT_CHANGE_NOTIFY_EVT = 4, /*!< notification event */
|
||||
ESP_AVRC_CT_REMOTE_FEATURES_EVT = 5, /*!< feature of remote device indication event */
|
||||
} esp_avrc_ct_cb_event_t;
|
||||
|
||||
/// AVRC metadata attribute mask
|
||||
typedef enum {
|
||||
ESP_AVRC_MD_ATTR_TITLE = 0x1, /*!< title of the playing track */
|
||||
ESP_AVRC_MD_ATTR_ARTIST = 0x2, /*!< track artist */
|
||||
ESP_AVRC_MD_ATTR_ALBUM = 0x4, /*!< album name */
|
||||
ESP_AVRC_MD_ATTR_TRACK_NUM = 0x8, /*!< track position on the album */
|
||||
ESP_AVRC_MD_ATTR_NUM_TRACKS = 0x10, /*!< number of tracks on the album */
|
||||
ESP_AVRC_MD_ATTR_GENRE = 0x20, /*!< track genre */
|
||||
ESP_AVRC_MD_ATTR_PLAYING_TIME = 0x40 /*!< total album playing time in miliseconds */
|
||||
} esp_avrc_md_attr_mask_t;
|
||||
|
||||
/// AVRC event notification ids
|
||||
typedef enum {
|
||||
ESP_AVRC_RN_PLAY_STATUS_CHANGE = 0x01, /*!< track status change, eg. from playing to paused */
|
||||
ESP_AVRC_RN_TRACK_CHANGE = 0x02, /*!< new track is loaded */
|
||||
ESP_AVRC_RN_TRACK_REACHED_END = 0x03, /*!< current track reached end */
|
||||
ESP_AVRC_RN_TRACK_REACHED_START = 0x04, /*!< current track reached start position */
|
||||
ESP_AVRC_RN_PLAY_POS_CHANGED = 0x05, /*!< track playing position changed */
|
||||
ESP_AVRC_RN_BATTERY_STATUS_CHANGE = 0x06, /*!< battery status changed */
|
||||
ESP_AVRC_RN_SYSTEM_STATUS_CHANGE = 0x07, /*!< system status changed */
|
||||
ESP_AVRC_RN_APP_SETTING_CHANGE = 0x08, /*!< application settings changed */
|
||||
ESP_AVRC_RN_MAX_EVT
|
||||
} esp_avrc_rn_event_ids_t;
|
||||
|
||||
/// AVRC player setting ids
|
||||
typedef enum {
|
||||
ESP_AVRC_PS_EQUALIZER = 0x01, /*!< equalizer, on or off */
|
||||
ESP_AVRC_PS_REPEAT_MODE = 0x02, /*!< repeat mode */
|
||||
ESP_AVRC_PS_SHUFFLE_MODE = 0x03, /*!< shuffle mode */
|
||||
ESP_AVRC_PS_SCAN_MODE = 0x04, /*!< scan mode on or off */
|
||||
ESP_AVRC_PS_MAX_ATTR
|
||||
} esp_avrc_ps_attr_ids_t;
|
||||
|
||||
/// AVRC equalizer modes
|
||||
typedef enum {
|
||||
ESP_AVRC_PS_EQUALIZER_OFF = 0x1, /*!< equalizer OFF */
|
||||
ESP_AVRC_PS_EQUALIZER_ON = 0x2 /*!< equalizer ON */
|
||||
} esp_avrc_ps_eq_value_ids_t;
|
||||
|
||||
/// AVRC repeat modes
|
||||
typedef enum {
|
||||
ESP_AVRC_PS_REPEAT_OFF = 0x1, /*!< repeat mode off */
|
||||
ESP_AVRC_PS_REPEAT_SINGLE = 0x2, /*!< single track repeat */
|
||||
ESP_AVRC_PS_REPEAT_GROUP = 0x3 /*!< group repeat */
|
||||
} esp_avrc_ps_rpt_value_ids_t;
|
||||
|
||||
|
||||
/// AVRC shuffle modes
|
||||
typedef enum {
|
||||
ESP_AVRC_PS_SHUFFLE_OFF = 0x1, /*<! shuffle off */
|
||||
ESP_AVRC_PS_SHUFFLE_ALL = 0x2, /*<! all trackes shuffle */
|
||||
ESP_AVRC_PS_SHUFFLE_GROUP = 0x3 /*<! group shuffle */
|
||||
} esp_avrc_ps_shf_value_ids_t;
|
||||
|
||||
/// AVRC scan modes
|
||||
typedef enum {
|
||||
ESP_AVRC_PS_SCAN_OFF = 0x1, /*!< scan off */
|
||||
ESP_AVRC_PS_SCAN_ALL = 0x2, /*!< all tracks scan */
|
||||
ESP_AVRC_PS_SCAN_GROUP = 0x3 /*!< group scan */
|
||||
} esp_avrc_ps_scn_value_ids_t;
|
||||
|
||||
/// AVRC controller callback parameters
|
||||
typedef union {
|
||||
/**
|
||||
@ -63,7 +129,6 @@ typedef union {
|
||||
*/
|
||||
struct avrc_ct_conn_stat_param {
|
||||
bool connected; /*!< whether AVRC connection is set up */
|
||||
uint32_t feat_mask; /*!< AVRC feature mask of remote device */
|
||||
esp_bd_addr_t remote_bda; /*!< remote bluetooth device address */
|
||||
} conn_stat; /*!< AVRC connection status */
|
||||
|
||||
@ -75,6 +140,32 @@ typedef union {
|
||||
uint8_t key_code; /*!< passthrough command code */
|
||||
uint8_t key_state; /*!< 0 for PRESSED, 1 for RELEASED */
|
||||
} psth_rsp; /*!< passthrough command response */
|
||||
|
||||
/**
|
||||
* @brief ESP_AVRC_CT_METADATA_RSP_EVT
|
||||
*/
|
||||
struct avrc_ct_meta_rsp_param {
|
||||
uint8_t attr_id; /*!< id of metadata attribute */
|
||||
uint8_t *attr_text; /*!< attribute itself */
|
||||
int attr_length; /*!< attribute character length */
|
||||
} meta_rsp; /*!< metadata attributes response */
|
||||
|
||||
/**
|
||||
* @brief ESP_AVRC_CT_CHANGE_NOTIFY_EVT
|
||||
*/
|
||||
struct avrc_ct_change_notify_param {
|
||||
uint8_t event_id; /*!< id of AVRC event notification */
|
||||
uint32_t event_parameter; /*!< event notification parameter */
|
||||
} change_ntf; /*!< notifications */
|
||||
|
||||
/**
|
||||
* @brief ESP_AVRC_CT_REMOTE_FEATURES_EVT
|
||||
*/
|
||||
struct avrc_ct_rmt_feats_param {
|
||||
uint32_t feat_mask; /*!< AVRC feature mask of remote device */
|
||||
esp_bd_addr_t remote_bda; /*!< remote bluetooth device address */
|
||||
} rmt_feats; /*!< AVRC features discovered from remote SDP server */
|
||||
|
||||
} esp_avrc_ct_cb_param_t;
|
||||
|
||||
|
||||
@ -128,6 +219,50 @@ esp_err_t esp_avrc_ct_init(void);
|
||||
*/
|
||||
esp_err_t esp_avrc_ct_deinit(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Send player application settings command to AVRCP target. This function should be called
|
||||
* after ESP_AVRC_CT_CONNECTION_STATE_EVT is received and AVRCP connection is established.
|
||||
*
|
||||
* @param[in] tl : transaction label, 0 to 15, consecutive commands should use different values.
|
||||
* @param[in] attr_id : player application setting attribute IDs from one of esp_avrc_ps_attr_ids_t
|
||||
* @param[in] value_id : attribute value defined for the specific player application setting attribute
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*/
|
||||
esp_err_t esp_avrc_ct_send_set_player_value_cmd(uint8_t tl, uint8_t attr_id, uint8_t value_id);
|
||||
|
||||
/**
|
||||
* @brief Send register notification command to AVRCP target, This function should be called after
|
||||
* ESP_AVRC_CT_CONNECTION_STATE_EVT is received and AVRCP connection is established
|
||||
*
|
||||
* @param[in] tl : transaction label, 0 to 15, consecutive commands should use different values.
|
||||
* @param[in] event_id : id of events, e.g. ESP_AVRC_RN_PLAY_STATUS_CHANGE, ESP_AVRC_RN_TRACK_CHANGE, etc.
|
||||
* @param[in] event_parameter : special parameters, eg. playback interval for ESP_AVRC_RN_PLAY_POS_CHANGED
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*/
|
||||
esp_err_t esp_avrc_ct_send_register_notification_cmd(uint8_t tl, uint8_t event_id, uint32_t event_parameter);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Send metadata command to AVRCP target, This function should be called after
|
||||
* ESP_AVRC_CT_CONNECTION_STATE_EVT is received and AVRCP connection is established
|
||||
*
|
||||
* @param[in] tl : transaction label, 0 to 15, consecutive commands should use different values.
|
||||
* @param[in] attr_mask : mask of attributes, e.g. ESP_AVRC_MD_ATTR_ID_TITLE | ESP_AVRC_MD_ATTR_ID_ARTIST.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*/
|
||||
esp_err_t esp_avrc_ct_send_metadata_cmd(uint8_t tl, uint8_t attr_mask);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Send passthrough command to AVRCP target, This function should be called after
|
||||
|
@ -50,6 +50,7 @@ typedef enum {
|
||||
ESP_BLUFI_EVENT_RECV_CLIENT_PRIV_KEY, /*<! When Phone send Client Private key to ESP32, this event happen */
|
||||
ESP_BLUFI_EVENT_RECV_SERVER_PRIV_KEY, /*<! When Phone send Server Private key to ESP32, this event happen */
|
||||
ESP_BLUFI_EVENT_RECV_SLAVE_DISCONNECT_BLE, /*<! When Phone send Disconnect key to ESP32, this event happen */
|
||||
ESP_BLUFI_EVENT_GET_WIFI_LIST, /*<! When Phone send get wifi list command to ESP32, this event happen */
|
||||
} esp_blufi_cb_event_t;
|
||||
|
||||
/// BLUFI config status
|
||||
@ -61,13 +62,13 @@ typedef enum {
|
||||
/// BLUFI init status
|
||||
typedef enum {
|
||||
ESP_BLUFI_INIT_OK = 0,
|
||||
ESP_BLUFI_INIT_FAILED = 0,
|
||||
ESP_BLUFI_INIT_FAILED,
|
||||
} esp_blufi_init_state_t;
|
||||
|
||||
/// BLUFI deinit status
|
||||
typedef enum {
|
||||
ESP_BLUFI_DEINIT_OK = 0,
|
||||
ESP_BLUFI_DEINIT_FAILED = 0,
|
||||
ESP_BLUFI_DEINIT_FAILED,
|
||||
} esp_blufi_deinit_state_t;
|
||||
|
||||
/**
|
||||
@ -93,6 +94,12 @@ typedef struct {
|
||||
bool softap_channel_set; /*!< is channel of softap interface set */
|
||||
} esp_blufi_extra_info_t;
|
||||
|
||||
/** @brief Description of an WiFi AP */
|
||||
typedef struct {
|
||||
uint8_t ssid[33]; /**< SSID of AP */
|
||||
int8_t rssi; /**< signal strength of AP */
|
||||
} esp_blufi_ap_record_t;
|
||||
|
||||
/**
|
||||
* @brief BLUFI callback parameters union
|
||||
*/
|
||||
@ -347,6 +354,17 @@ esp_err_t esp_blufi_profile_deinit(void);
|
||||
*/
|
||||
esp_err_t esp_blufi_send_wifi_conn_report(wifi_mode_t opmode, esp_blufi_sta_conn_state_t sta_conn_state, uint8_t softap_conn_num, esp_blufi_extra_info_t *extra_info);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief This function is called to send wifi list
|
||||
* @param apCount : wifi list count
|
||||
* @param list : wifi list
|
||||
*
|
||||
* @return ESP_OK - success, other - failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_blufi_send_wifi_list(uint16_t apCount, esp_blufi_ap_record_t *list);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Get BLUFI profile version
|
||||
|
@ -51,6 +51,7 @@ typedef enum {
|
||||
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_MEMORY_FULL, /* relate to BT_STATUS_MEMORY_FULL in bt_def.h */
|
||||
} esp_bt_status_t;
|
||||
|
||||
|
||||
|
@ -97,9 +97,11 @@ typedef enum {
|
||||
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_READ_RSSI_COMPLETE_EVT, /*!< When read the rssi complete, the event comes */
|
||||
ESP_GAP_BLE_ADD_WHITELIST_COMPLETE_EVT, /*!< When add or remove whitelist complete, the event comes */
|
||||
ESP_GAP_BLE_UPDATE_WHITELIST_COMPLETE_EVT, /*!< When add or remove whitelist complete, the event comes */
|
||||
ESP_GAP_BLE_EVT_MAX,
|
||||
} esp_gap_ble_cb_event_t;
|
||||
/// This is the old name, just for backwards compatibility
|
||||
#define ESP_GAP_BLE_ADD_WHITELIST_COMPLETE_EVT ESP_GAP_BLE_UPDATE_WHITELIST_COMPLETE_EVT
|
||||
|
||||
/// Advertising data maximum length
|
||||
#define ESP_BLE_ADV_DATA_LEN_MAX 31
|
||||
@ -476,7 +478,7 @@ typedef enum {
|
||||
typedef enum{
|
||||
ESP_BLE_WHITELIST_REMOVE = 0X00, /*!< remove mac from whitelist */
|
||||
ESP_BLE_WHITELIST_ADD = 0X01, /*!< add address to whitelist */
|
||||
}esp_ble_wl_opration;
|
||||
}esp_ble_wl_opration_t;
|
||||
/**
|
||||
* @brief Gap callback parameters union
|
||||
*/
|
||||
@ -616,12 +618,12 @@ typedef union {
|
||||
esp_bd_addr_t remote_addr; /*!< The remote device address */
|
||||
} read_rssi_cmpl; /*!< Event parameter of ESP_GAP_BLE_READ_RSSI_COMPLETE_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_ADD_WHITELIST_COMPLETE_EVT
|
||||
* @brief ESP_GAP_BLE_UPDATE_WHITELIST_COMPLETE_EVT
|
||||
*/
|
||||
struct ble_add_whitelist_cmpl_evt_param {
|
||||
struct ble_update_whitelist_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate the add or remove whitelist operation success status */
|
||||
esp_ble_wl_opration wl_opration; /*!< The value is ESP_BLE_WHITELIST_ADD if add address to whitelist operation success, ESP_BLE_WHITELIST_REMOVE if remove address from the whitelist operation success */
|
||||
} add_whitelist_cmpl; /*!< Event parameter of ESP_GAP_BLE_ADD_WHITELIST_COMPLETE_EVT */
|
||||
esp_ble_wl_opration_t wl_opration; /*!< The value is ESP_BLE_WHITELIST_ADD if add address to whitelist operation success, ESP_BLE_WHITELIST_REMOVE if remove address from the whitelist operation success */
|
||||
} update_whitelist_cmpl; /*!< Event parameter of ESP_GAP_BLE_UPDATE_WHITELIST_COMPLETE_EVT */
|
||||
} esp_ble_gap_cb_param_t;
|
||||
|
||||
/**
|
||||
|
@ -28,9 +28,227 @@ extern "C" {
|
||||
typedef enum {
|
||||
ESP_BT_SCAN_MODE_NONE = 0, /*!< Neither discoverable nor connectable */
|
||||
ESP_BT_SCAN_MODE_CONNECTABLE, /*!< Connectable but not discoverable */
|
||||
ESP_BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE /*!< both discoverable and connectaable */
|
||||
ESP_BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE /*!< both discoverable and connectable */
|
||||
} esp_bt_scan_mode_t;
|
||||
|
||||
/// Bluetooth Device Property type
|
||||
typedef enum {
|
||||
ESP_BT_GAP_DEV_PROP_BDNAME = 1, /*!< Bluetooth device name, value type is int8_t [] */
|
||||
ESP_BT_GAP_DEV_PROP_COD, /*!< Class of Device, value type is uint32_t */
|
||||
ESP_BT_GAP_DEV_PROP_RSSI, /*!< Received Signal strength Indication, value type is int8_t, ranging from -128 to 127 */
|
||||
ESP_BT_GAP_DEV_PROP_EIR, /*!< Extended Inquiry Response, value type is uint8_t [] */
|
||||
} esp_bt_gap_dev_prop_type_t;
|
||||
|
||||
/// Maximum bytes of Bluetooth device name
|
||||
#define ESP_BT_GAP_MAX_BDNAME_LEN (248)
|
||||
|
||||
/// Maximum size of EIR Significant part
|
||||
#define ESP_BT_GAP_EIR_DATA_LEN (240)
|
||||
|
||||
/// Bluetooth Device Property Descriptor
|
||||
typedef struct {
|
||||
esp_bt_gap_dev_prop_type_t type; /*!< device property type */
|
||||
int len; /*!< device property value length */
|
||||
void *val; /*!< devlice prpoerty value */
|
||||
} esp_bt_gap_dev_prop_t;
|
||||
|
||||
/// Extended Inquiry Response data type
|
||||
typedef enum {
|
||||
ESP_BT_EIR_TYPE_FLAGS = 0x01, /*!< Flag with information such as BR/EDR and LE support */
|
||||
ESP_BT_EIR_TYPE_INCMPL_16BITS_UUID = 0x02, /*!< Incomplete list of 16-bit service UUIDs */
|
||||
ESP_BT_EIR_TYPE_CMPL_16BITS_UUID = 0x03, /*!< Complete list of 16-bit service UUIDs */
|
||||
ESP_BT_EIR_TYPE_INCMPL_32BITS_UUID = 0x04, /*!< Incomplete list of 32-bit service UUIDs */
|
||||
ESP_BT_EIR_TYPE_CMPL_32BITS_UUID = 0x05, /*!< Complete list of 32-bit service UUIDs */
|
||||
ESP_BT_EIR_TYPE_INCMPL_128BITS_UUID = 0x06, /*!< Incomplete list of 128-bit service UUIDs */
|
||||
ESP_BT_EIR_TYPE_CMPL_128BITS_UUID = 0x07, /*!< Complete list of 128-bit service UUIDs */
|
||||
ESP_BT_EIR_TYPE_SHORT_LOCAL_NAME = 0x08, /*!< Shortened Local Name */
|
||||
ESP_BT_EIR_TYPE_CMPL_LOCAL_NAME = 0x09, /*!< Complete Local Name */
|
||||
ESP_BT_EIR_TYPE_TX_POWER_LEVEL = 0x0a, /*!< Tx power level, value is 1 octet ranging from -127 to 127, unit is dBm*/
|
||||
ESP_BT_EIR_TYPE_MANU_SPECIFIC = 0xff, /*!< Manufacturer specific data */
|
||||
} esp_bt_eir_type_t;
|
||||
|
||||
/// Major service class field of Class of Device, mutiple bits can be set
|
||||
typedef enum {
|
||||
ESP_BT_COD_SRVC_NONE = 0, /*!< None indicates an invalid value */
|
||||
ESP_BT_COD_SRVC_LMTD_DISCOVER = 0x1, /*!< Limited Discoverable Mode */
|
||||
ESP_BT_COD_SRVC_POSITIONING = 0x8, /*!< Positioning (Location identification) */
|
||||
ESP_BT_COD_SRVC_NETWORKING = 0x10, /*!< Networking, e.g. LAN, Ad hoc */
|
||||
ESP_BT_COD_SRVC_RENDERING = 0x20, /*!< Rendering, e.g. Printing, Speakers */
|
||||
ESP_BT_COD_SRVC_CAPTURING = 0x40, /*!< Capturing, e.g. Scanner, Microphone */
|
||||
ESP_BT_COD_SRVC_OBJ_TRANSFER = 0x80, /*!< Object Transfer, e.g. v-Inbox, v-Folder */
|
||||
ESP_BT_COD_SRVC_AUDIO = 0x100, /*!< Audio, e.g. Speaker, Microphone, Headerset service */
|
||||
ESP_BT_COD_SRVC_TELEPHONY = 0x200, /*!< Telephony, e.g. Cordless telephony, Modem, Headset service */
|
||||
ESP_BT_COD_SRVC_INFORMATION = 0x400, /*!< Information, e.g., WEB-server, WAP-server */
|
||||
} esp_bt_cod_srvc_t;
|
||||
|
||||
/// Bits of major service class field
|
||||
#define ESP_BT_COD_SRVC_BIT_MASK (0xffe000) /*!< Major service bit mask */
|
||||
#define ESP_BT_COD_SRVC_BIT_OFFSET (13) /*!< Major service bit offset */
|
||||
|
||||
/// Major device class field of Class of Device
|
||||
typedef enum {
|
||||
ESP_BT_COD_MAJOR_DEV_MISC = 0, /*!< Miscellaneous */
|
||||
ESP_BT_COD_MAJOR_DEV_COMPUTER = 1, /*!< Computer */
|
||||
ESP_BT_COD_MAJOR_DEV_PHONE = 2, /*!< Phone(cellular, cordless, pay phone, modem */
|
||||
ESP_BT_COD_MAJOR_DEV_LAN_NAP = 3, /*!< LAN, Network Access Point */
|
||||
ESP_BT_COD_MAJOR_DEV_AV = 4, /*!< Audio/Video(headset, speaker, stereo, video display, VCR */
|
||||
ESP_BT_COD_MAJOR_DEV_PERIPHERAL = 5, /*!< Peripheral(mouse, joystick, keyboard) */
|
||||
ESP_BT_COD_MAJOR_DEV_IMAGING = 6, /*!< Imaging(printer, scanner, camera, display */
|
||||
ESP_BT_COD_MAJOR_DEV_WEARABLE = 7, /*!< Wearable */
|
||||
ESP_BT_COD_MAJOR_DEV_TOY = 8, /*!< Toy */
|
||||
ESP_BT_COD_MAJOR_DEV_HEALTH = 9, /*!< Health */
|
||||
ESP_BT_COD_MAJOR_DEV_UNCATEGORIZED = 31, /*!< Uncategorized: device not specified */
|
||||
} esp_bt_cod_major_dev_t;
|
||||
|
||||
/// Bits of major device class field
|
||||
#define ESP_BT_COD_MAJOR_DEV_BIT_MASK (0x1f00) /*!< Major device bit mask */
|
||||
#define ESP_BT_COD_MAJOR_DEV_BIT_OFFSET (8) /*!< Major device bit offset */
|
||||
|
||||
/// Bits of minor device class field
|
||||
#define ESP_BT_COD_MINOR_DEV_BIT_MASK (0xfc) /*!< Minor device bit mask */
|
||||
#define ESP_BT_COD_MINOR_DEV_BIT_OFFSET (2) /*!< Minor device bit offset */
|
||||
|
||||
/// Bits of format type
|
||||
#define ESP_BT_COD_FORMAT_TYPE_BIT_MASK (0x03) /*!< Format type bit mask */
|
||||
#define ESP_BT_COD_FORMAT_TYPE_BIT_OFFSET (0) /*!< Format type bit offset */
|
||||
|
||||
/// Class of device format type 1
|
||||
#define ESP_BT_COD_FORMAT_TYPE_1 (0x00)
|
||||
|
||||
/** Bluetooth Device Discovery state */
|
||||
typedef enum {
|
||||
ESP_BT_GAP_DISCOVERY_STOPPED, /*!< device discovery stopped */
|
||||
ESP_BT_GAP_DISCOVERY_STARTED, /*!< device discovery started */
|
||||
} esp_bt_gap_discovery_state_t;
|
||||
|
||||
/// BT GAP callback events
|
||||
typedef enum {
|
||||
ESP_BT_GAP_DISC_RES_EVT = 0, /*!< device discovery result event */
|
||||
ESP_BT_GAP_DISC_STATE_CHANGED_EVT, /*!< discovery state changed event */
|
||||
ESP_BT_GAP_RMT_SRVCS_EVT, /*!< get remote services event */
|
||||
ESP_BT_GAP_RMT_SRVC_REC_EVT, /*!< get remote service record event */
|
||||
} esp_bt_gap_cb_event_t;
|
||||
|
||||
/** Inquiry Mode */
|
||||
typedef enum {
|
||||
ESP_BT_INQ_MODE_GENERAL_INQUIRY, /*!< General inquiry mode */
|
||||
ESP_BT_INQ_MODE_LIMITED_INQIURY, /*!< Limited inquiry mode */
|
||||
} esp_bt_inq_mode_t;
|
||||
|
||||
/** Minimum and Maximum inquiry length*/
|
||||
#define ESP_BT_GAP_MIN_INQ_LEN (0x01) /*!< Minimum inquiry duration, unit is 1.28s */
|
||||
#define ESP_BT_GAP_MAX_INQ_LEN (0x30) /*!< Maximum inquiry duration, unit is 1.28s */
|
||||
|
||||
/// A2DP state callback parameters
|
||||
typedef union {
|
||||
/**
|
||||
* @brief ESP_BT_GAP_DISC_RES_EVT
|
||||
*/
|
||||
struct disc_res_param {
|
||||
esp_bd_addr_t bda; /*!< remote bluetooth device address*/
|
||||
int num_prop; /*!< number of properties got */
|
||||
esp_bt_gap_dev_prop_t *prop; /*!< properties discovered from the new device */
|
||||
} disc_res; /*!< discovery result paramter struct */
|
||||
|
||||
/**
|
||||
* @brief ESP_BT_GAP_DISC_STATE_CHANGED_EVT
|
||||
*/
|
||||
struct disc_state_changed_param {
|
||||
esp_bt_gap_discovery_state_t state; /*!< discovery state */
|
||||
} disc_st_chg; /*!< discovery state changed parameter struct */
|
||||
|
||||
/**
|
||||
* @brief ESP_BT_GAP_RMT_SRVCS_EVT
|
||||
*/
|
||||
struct rmt_srvcs_param {
|
||||
esp_bd_addr_t bda; /*!< remote bluetooth device address*/
|
||||
esp_bt_status_t stat; /*!< service search status */
|
||||
int num_uuids; /*!< number of UUID in uuid_list */
|
||||
esp_bt_uuid_t *uuid_list; /*!< list of service UUIDs of remote device */
|
||||
} rmt_srvcs; /*!< services of remote device parameter struct */
|
||||
|
||||
/**
|
||||
* @brief ESP_BT_GAP_RMT_SRVC_REC_EVT
|
||||
*/
|
||||
struct rmt_srvc_rec_param {
|
||||
esp_bd_addr_t bda; /*!< remote bluetooth device address*/
|
||||
esp_bt_status_t stat; /*!< service search status */
|
||||
} rmt_srvc_rec; /*!< specific service record from remote device parameter struct */
|
||||
} esp_bt_gap_cb_param_t;
|
||||
|
||||
/**
|
||||
* @brief bluetooth GAP callback function type
|
||||
* @param event : Event type
|
||||
* @param param : Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_bt_gap_cb_t)(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief get major service field of COD
|
||||
* @param[in] cod: Class of Device
|
||||
* @return major service bits
|
||||
*/
|
||||
inline uint32_t esp_bt_gap_get_cod_srvc(uint32_t cod)
|
||||
{
|
||||
return (cod & ESP_BT_COD_SRVC_BIT_MASK) >> ESP_BT_COD_SRVC_BIT_OFFSET;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get major device field of COD
|
||||
* @param[in] cod: Class of Device
|
||||
* @return major device bits
|
||||
*/
|
||||
inline uint32_t esp_bt_gap_get_cod_major_dev(uint32_t cod)
|
||||
{
|
||||
return (cod & ESP_BT_COD_MAJOR_DEV_BIT_MASK) >> ESP_BT_COD_MAJOR_DEV_BIT_OFFSET;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get minor service field of COD
|
||||
* @param[in] cod: Class of Device
|
||||
* @return minor service bits
|
||||
*/
|
||||
inline uint32_t esp_bt_gap_get_cod_minor_dev(uint32_t cod)
|
||||
{
|
||||
return (cod & ESP_BT_COD_MINOR_DEV_BIT_MASK) >> ESP_BT_COD_MINOR_DEV_BIT_OFFSET;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get format type of COD
|
||||
* @param[in] cod: Class of Device
|
||||
* @return format type
|
||||
*/
|
||||
inline uint32_t esp_bt_gap_get_cod_format_type(uint32_t cod)
|
||||
{
|
||||
return (cod & ESP_BT_COD_FORMAT_TYPE_BIT_MASK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief decide the integrity of COD
|
||||
* @param[in] cod: Class of Device
|
||||
* @return
|
||||
* - true if cod is valid
|
||||
* - false otherise
|
||||
*/
|
||||
inline bool esp_bt_gap_is_valid_cod(uint32_t cod)
|
||||
{
|
||||
if (esp_bt_gap_get_cod_format_type(cod) == ESP_BT_COD_FORMAT_TYPE_1 &&
|
||||
esp_bt_gap_get_cod_srvc(cod) != ESP_BT_COD_SRVC_NONE) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief register callback function. This function should be called after esp_bluedroid_enable() completes successfully
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Succeed
|
||||
* - ESP_FAIL: others
|
||||
*/
|
||||
esp_err_t esp_bt_gap_register_callback(esp_bt_gap_cb_t callback);
|
||||
|
||||
/**
|
||||
* @brief Set discoverability and connectability mode for legacy bluetooth. This function should
|
||||
* be called after esp_bluedroid_enable() completes successfully
|
||||
@ -45,6 +263,69 @@ typedef enum {
|
||||
*/
|
||||
esp_err_t esp_bt_gap_set_scan_mode(esp_bt_scan_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief Start device discovery. This function should be called after esp_bluedroid_enable() completes successfully.
|
||||
* esp_bt_gap_cb_t will is called with ESP_BT_GAP_DISC_STATE_CHANGED_EVT if discovery is started or halted.
|
||||
* esp_bt_gap_cb_t will is called with ESP_BT_GAP_DISC_RES_EVT if discovery result is got.
|
||||
*
|
||||
* @param[in] mode - inquiry mode
|
||||
* @param[in] inq_len - inquiry duration in 1.28 sec units, ranging from 0x01 to 0x30
|
||||
* @param[in] num_rsps - number of inquiry responses that can be received, value 0 indicates an unlimited number of responses
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Succeed
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_ERR_INVALID_ARG: if invalid parameters are provided
|
||||
* - ESP_FAIL: others
|
||||
*/
|
||||
esp_err_t esp_bt_gap_start_discovery(esp_bt_inq_mode_t mode, uint8_t inq_len, uint8_t num_rsps);
|
||||
|
||||
/**
|
||||
* @brief Cancel device discovery. This function should be called after esp_bluedroid_enable() completes successfully
|
||||
* esp_bt_gap_cb_t will is called with ESP_BT_GAP_DISC_STATE_CHANGED_EVT if discovery is stopped.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Succeed
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*/
|
||||
esp_err_t esp_bt_gap_cancel_discovery(void);
|
||||
|
||||
/**
|
||||
* @brief Start SDP to get remote services. This function should be called after esp_bluedroid_enable() completes successfully.
|
||||
* esp_bt_gap_cb_t will is called with ESP_BT_GAP_RMT_SRVCS_EVT after service discovery ends
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Succeed
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*/
|
||||
esp_err_t esp_bt_gap_get_remote_services(esp_bd_addr_t remote_bda);
|
||||
|
||||
/**
|
||||
* @brief Start SDP to look up the service matching uuid on the remote device. This function should be called after
|
||||
* esp_bluedroid_enable() completes successfully
|
||||
*
|
||||
* esp_bt_gap_cb_t will is called with ESP_BT_GAP_RMT_SRVC_REC_EVT after service discovery ends
|
||||
* @return
|
||||
* - ESP_OK : Succeed
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*/
|
||||
esp_err_t esp_bt_gap_get_remote_service_record(esp_bd_addr_t remote_bda, esp_bt_uuid_t *uuid);
|
||||
|
||||
/**
|
||||
* @brief This function is called to get EIR data for a specific type.
|
||||
*
|
||||
* @param[in] eir - pointer of raw eir data to be resolved
|
||||
* @param[in] type - specific EIR data type
|
||||
* @param[out] length - return the length of EIR data excluding fields of length and data type
|
||||
*
|
||||
* @return pointer of starting position of eir data excluding eir data type, NULL if not found
|
||||
*
|
||||
*/
|
||||
uint8_t *esp_bt_gap_resolve_eir_data(uint8_t *eir, esp_bt_eir_type_t type, uint8_t *length);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
294
tools/sdk/include/bluedroid/esp_spp_api.h
Normal file
294
tools/sdk/include/bluedroid/esp_spp_api.h
Normal file
@ -0,0 +1,294 @@
|
||||
// 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_SPP_API_H__
|
||||
#define __ESP_SPP_API_H__
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_bt_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
ESP_SPP_SUCCESS = 0, /*!< Successful operation. */
|
||||
ESP_SPP_FAILURE, /*!< Generic failure. */
|
||||
ESP_SPP_BUSY, /*!< Temporarily can not handle this request. */
|
||||
ESP_SPP_NO_DATA, /*!< no data. */
|
||||
ESP_SPP_NO_RESOURCE /*!< No more set pm control block */
|
||||
} esp_spp_status_t;
|
||||
|
||||
/* Security Setting Mask */
|
||||
#define ESP_SPP_SEC_NONE 0x0000 /*!< No security. relate to BTA_SEC_NONE in bta_api.h */
|
||||
#define ESP_SPP_SEC_AUTHORIZE 0x0001 /*!< Authorization required (only needed for out going connection ) relate to BTA_SEC_AUTHORIZE in bta_api.h*/
|
||||
#define ESP_SPP_SEC_AUTHENTICATE 0x0012 /*!< Authentication required. relate to BTA_SEC_AUTHENTICATE in bta_api.h*/
|
||||
#define ESP_SPP_SEC_ENCRYPT 0x0024 /*!< Encryption required. relate to BTA_SEC_ENCRYPT in bta_api.h*/
|
||||
#define ESP_SPP_SEC_MODE4_LEVEL4 0x0040 /*!< Mode 4 level 4 service, i.e. incoming/outgoing MITM and P-256 encryption relate to BTA_SEC_MODE4_LEVEL4 in bta_api.h*/
|
||||
#define ESP_SPP_SEC_MITM 0x3000 /*!< Man-In-The_Middle protection relate to BTA_SEC_MITM in bta_api.h*/
|
||||
#define ESP_SPP_SEC_IN_16_DIGITS 0x4000 /*!< Min 16 digit for pin code relate to BTA_SEC_IN_16_DIGITS in bta_api.h*/
|
||||
typedef uint16_t esp_spp_sec_t;
|
||||
|
||||
typedef enum {
|
||||
ESP_SPP_ROLE_MASTER = 0, /*!< Role: master */
|
||||
ESP_SPP_ROLE_SLAVE = 1, /*!< Role: slave */
|
||||
} esp_spp_role_t;
|
||||
|
||||
typedef enum {
|
||||
ESP_SPP_MODE_CB = 0, /*!< When data is coming, a callback will come with data */
|
||||
ESP_SPP_MODE_VFS = 1, /*!< Use VFS to write/read data */
|
||||
} esp_spp_mode_t;
|
||||
|
||||
#define ESP_SPP_MAX_MTU (3*330) /*!< SPP max MTU */
|
||||
#define ESP_SPP_MAX_SCN 31 /*!< SPP max SCN */
|
||||
/**
|
||||
* @brief SPP callback function events
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_SPP_INIT_EVT = 0, /*!< When SPP is inited, the event comes */
|
||||
ESP_SPP_DISCOVERY_COMP_EVT = 8, /*!< When SDP discovery complete, the event comes */
|
||||
ESP_SPP_OPEN_EVT = 26, /*!< When SPP Client connection open, the event comes */
|
||||
ESP_SPP_CLOSE_EVT = 27, /*!< When SPP connection closed, the event comes */
|
||||
ESP_SPP_START_EVT = 28, /*!< When SPP server started, the event comes */
|
||||
ESP_SPP_CL_INIT_EVT = 29, /*!< When SPP client initiated a connection, the event comes */
|
||||
ESP_SPP_DATA_IND_EVT = 30, /*!< When SPP connection received data, the event comes */
|
||||
ESP_SPP_CONG_EVT = 31, /*!< When SPP connection congestion status changed, the event comes */
|
||||
ESP_SPP_WRITE_EVT = 33, /*!< When SPP write operation completes, the event comes */
|
||||
ESP_SPP_SRV_OPEN_EVT = 34, /*!< When SPP Server connection open, the event comes */
|
||||
} esp_spp_cb_event_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief SPP callback parameters union
|
||||
*/
|
||||
typedef union {
|
||||
/**
|
||||
* @brief SPP_INIT_EVT
|
||||
*/
|
||||
struct spp_init_evt_param {
|
||||
esp_spp_status_t status; /*!< status */
|
||||
} init; /*!< SPP callback param of SPP_INIT_EVT */
|
||||
|
||||
/**
|
||||
* @brief SPP_DISCOVERY_COMP_EVT
|
||||
*/
|
||||
struct spp_discovery_comp_evt_param {
|
||||
esp_spp_status_t status; /*!< status */
|
||||
uint8_t scn_num; /*!< The num of scn_num */
|
||||
uint8_t scn[ESP_SPP_MAX_SCN]; /*!< channel # */
|
||||
} disc_comp; /*!< SPP callback param of SPP_DISCOVERY_COMP_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_SPP_OPEN_EVT
|
||||
*/
|
||||
struct spp_open_evt_param {
|
||||
esp_spp_status_t status; /*!< status */
|
||||
uint32_t handle; /*!< The connection handle */
|
||||
esp_bd_addr_t rem_bda; /*!< The peer address */
|
||||
} open; /*!< SPP callback param of ESP_SPP_OPEN_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_SPP_SRV_OPEN_EVT
|
||||
*/
|
||||
struct spp_srv_open_evt_param {
|
||||
esp_spp_status_t status; /*!< status */
|
||||
uint32_t handle; /*!< The connection handle */
|
||||
uint32_t new_listen_handle; /*!< The new listen handle */
|
||||
esp_bd_addr_t rem_bda; /*!< The peer address */
|
||||
} srv_open; /*!< SPP callback param of ESP_SPP_SRV_OPEN_EVT */
|
||||
/**
|
||||
* @brief ESP_SPP_CLOSE_EVT
|
||||
*/
|
||||
struct spp_close_evt_param {
|
||||
esp_spp_status_t status; /*!< status */
|
||||
uint32_t port_status; /*!< PORT status */
|
||||
uint32_t handle; /*!< The connection handle */
|
||||
bool async; /*!< FALSE, if local initiates disconnect */
|
||||
} close; /*!< SPP callback param of ESP_SPP_CLOSE_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_SPP_START_EVT
|
||||
*/
|
||||
struct spp_start_evt_param {
|
||||
esp_spp_status_t status; /*!< status */
|
||||
uint32_t handle; /*!< The connection handle */
|
||||
uint8_t sec_id; /*!< security ID used by this server */
|
||||
bool use_co; /*!< TRUE to use co_rfc_data */
|
||||
} start; /*!< SPP callback param of ESP_SPP_START_EVT */
|
||||
/**
|
||||
* @brief ESP_SPP_CL_INIT_EVT
|
||||
*/
|
||||
struct spp_cl_init_evt_param {
|
||||
esp_spp_status_t status; /*!< status */
|
||||
uint32_t handle; /*!< The connection handle */
|
||||
uint8_t sec_id; /*!< security ID used by this server */
|
||||
bool use_co; /*!< TRUE to use co_rfc_data */
|
||||
} cl_init; /*!< SPP callback param of ESP_SPP_CL_INIT_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_SPP_WRITE_EVT
|
||||
*/
|
||||
struct spp_write_evt_param {
|
||||
esp_spp_status_t status; /*!< status */
|
||||
uint32_t handle; /*!< The connection handle */
|
||||
uint32_t req_id; /*!< The req_id in the associated BTA_JvRfcommWrite() */
|
||||
int len; /*!< The length of the data written. */
|
||||
bool cong; /*!< congestion status */
|
||||
} write; /*!< SPP callback param of ESP_SPP_WRITE_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_SPP_DATA_IND_EVT
|
||||
*/
|
||||
struct spp_data_ind_evt_param {
|
||||
esp_spp_status_t status; /*!< status */
|
||||
uint32_t handle; /*!< The connection handle */
|
||||
uint16_t len; /*!< The length of data */
|
||||
uint8_t *data; /*!< The data recived */
|
||||
} data_ind; /*!< SPP callback param of ESP_SPP_DATA_IND_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_SPP_CONG_EVT
|
||||
*/
|
||||
struct spp_cong_evt_param {
|
||||
esp_spp_status_t status; /*!< status */
|
||||
uint32_t handle; /*!< The connection handle */
|
||||
bool cong; /*!< TRUE, congested. FALSE, uncongested */
|
||||
} cong; /*!< SPP callback param of ESP_SPP_CONG_EVT */
|
||||
} esp_spp_cb_param_t; /*!< SPP callback parameter union type */
|
||||
|
||||
/**
|
||||
* @brief SPP callback function type
|
||||
* @param event: Event type
|
||||
* @param param: Point to callback parameter, currently is union type
|
||||
*/
|
||||
typedef void (esp_spp_cb_t)(esp_spp_cb_event_t event, esp_spp_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief This function is called to init callbacks
|
||||
* with SPP module.
|
||||
*
|
||||
* @param[in] callback: pointer to the init callback function.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*/
|
||||
esp_err_t esp_spp_register_callback(esp_spp_cb_t callback);
|
||||
|
||||
/**
|
||||
* @brief This function is called to init SPP.
|
||||
*
|
||||
* @param[in] mode: Choose the mode of SPP, ESP_SPP_MODE_CB or ESP_SPP_MODE_CB.
|
||||
* Now only supports ESP_SPP_MODE_CB mode, we will continue to update.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*/
|
||||
esp_err_t esp_spp_init(esp_spp_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief This function is called to uninit SPP.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*/
|
||||
esp_err_t esp_spp_deinit();
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called to performs service discovery for
|
||||
* the services provided by the given peer device. When the
|
||||
* operation is complete the callback function will be called
|
||||
* with a ESP_SPP_DISCOVERY_COMP_EVT.
|
||||
*
|
||||
* @param[in] bd_addr: Remote device bluetooth device address.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*/
|
||||
esp_err_t esp_spp_start_discovery(esp_bd_addr_t bd_addr);
|
||||
|
||||
/**
|
||||
* @brief This function makes an SPP conection to a remote BD Address.
|
||||
* When the connection is initiated or failed to initiate,
|
||||
* the callback is called with ESP_SPP_CL_INIT_EVT.
|
||||
* When the connection is established or failed,
|
||||
* the callback is called with ESP_SPP_OPEN_EVT.
|
||||
*
|
||||
* @param[in] sec_mask: Security Setting Mask .
|
||||
* @param[in] role: Msater or slave.
|
||||
* @param[in] remote_scn: Remote device bluetooth device SCN.
|
||||
* @param[in] peer_bd_addr: Remote device bluetooth device address.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*/
|
||||
esp_err_t esp_spp_connect(esp_spp_sec_t sec_mask,
|
||||
esp_spp_role_t role, uint8_t remote_scn, esp_bd_addr_t peer_bd_addr);
|
||||
|
||||
/**
|
||||
* @brief This function closes an SPP connection.
|
||||
*
|
||||
* @param[in] handle: The connection handle.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*/
|
||||
esp_err_t esp_spp_disconnect(uint32_t handle);
|
||||
|
||||
/**
|
||||
* @brief This function create a SPP server and starts listening for an
|
||||
* SPP connection request from a remote Bluetooth device.
|
||||
* When the server is started successfully, the callback is called
|
||||
* with ESP_SPP_START_EVT.
|
||||
* When the connection is established, the callback is called
|
||||
* with ESP_SPP_SRV_OPEN_EVT.
|
||||
*
|
||||
* @param[in] sec_mask: Security Setting Mask .
|
||||
* @param[in] role: Msater or slave.
|
||||
* @param[in] local_scn: The specific channel you want to get.
|
||||
* If channel is 0, means get any channel.
|
||||
* @param[in] name: Server's name.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*/
|
||||
esp_err_t esp_spp_start_srv(esp_spp_sec_t sec_mask,
|
||||
esp_spp_role_t role, uint8_t local_scn, const char *name);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function closes an SPP connection.
|
||||
*
|
||||
* @param[in] handle: The connection handle.
|
||||
* @param[in] len: The length of the data written.
|
||||
* @param[in] p_data: The data written.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*/
|
||||
esp_err_t esp_spp_write(uint32_t handle, int len, uint8_t *p_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif ///__ESP_SPP_API_H__
|
@ -90,7 +90,8 @@ typedef struct {
|
||||
|
||||
void (*parse_ble_read_suggested_default_data_length_response)(
|
||||
BT_HDR *response,
|
||||
uint16_t *ble_default_packet_length_ptr
|
||||
uint16_t *ble_default_packet_length_ptr,
|
||||
uint16_t *ble_default_packet_txtime_ptr
|
||||
);
|
||||
} hci_packet_parser_t;
|
||||
|
||||
|
@ -598,7 +598,7 @@ extern int PORT_WriteData (UINT16 handle, char *p_data, UINT16 max_len,
|
||||
** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern int PORT_WriteDataCO (UINT16 handle, int *p_len);
|
||||
extern int PORT_WriteDataCO (UINT16 handle, int *p_len, int len, UINT8 *p_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -28,6 +28,8 @@
|
||||
#include "bt_target.h"
|
||||
#include "rfcdefs.h"
|
||||
#include "port_api.h"
|
||||
#include "fixed_queue.h"
|
||||
#include "bt_defs.h"
|
||||
|
||||
/* Local events passed when application event is sent from the api to PORT */
|
||||
/* ???*/
|
||||
|
@ -84,10 +84,10 @@ typedef enum {
|
||||
#define BTC_TASK_QUEUE_LEN 60
|
||||
|
||||
#define BTC_MEDIA_TASK_PINNED_TO_CORE (TASK_PINNED_TO_CORE)
|
||||
#define BTC_MEDIA_TASK_STACK_SIZE (CONFIG_BTC_TASK_STACK_SIZE + BT_TASK_EXTRA_STACK_SIZE)
|
||||
#define BTC_MEDIA_TASK_STACK_SIZE (2048 + BT_TASK_EXTRA_STACK_SIZE)
|
||||
#define BTC_MEDIA_TASK_NAME "BtcMediaT"
|
||||
#define BTC_MEDIA_TASK_PRIO (configMAX_PRIORITIES - 3)
|
||||
#define BTC_MEDIA_DATA_QUEUE_LEN (1)
|
||||
#define BTC_MEDIA_DATA_QUEUE_LEN (3)
|
||||
#define BTC_MEDIA_CTRL_QUEUE_LEN (5)
|
||||
#define BTC_MEDIA_TASK_QUEUE_SET_LEN (BTC_MEDIA_DATA_QUEUE_LEN + BTC_MEDIA_CTRL_QUEUE_LEN)
|
||||
|
||||
|
21
tools/sdk/include/bootloader_support/bootloader_clock.h
Normal file
21
tools/sdk/include/bootloader_support/bootloader_clock.h
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright 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
|
||||
|
||||
/** @brief Configure clocks for early boot
|
||||
*
|
||||
* Called by bootloader, or by the app if the bootloader version is old (pre v2.1).
|
||||
*/
|
||||
void bootloader_clock_configure(void);
|
@ -1,244 +1,3 @@
|
||||
// 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 __BT_H__
|
||||
#define __BT_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_task.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Controller config options, depend on config mask.
|
||||
* Config mask indicate which functions enabled, this means
|
||||
* some options or parameters of some functions enabled by config mask.
|
||||
*/
|
||||
typedef struct {
|
||||
uint16_t controller_task_stack_size; /*!< Bluetooth controller task stack size */
|
||||
uint8_t controller_task_prio; /*!< Bluetooth controller task priority */
|
||||
uint8_t hci_uart_no; /*!< If use UART1/2 as HCI IO interface, indicate UART number */
|
||||
uint32_t hci_uart_baudrate; /*!< If use UART1/2 as HCI IO interface, indicate UART baudrate */
|
||||
} esp_bt_controller_config_t;
|
||||
|
||||
#ifdef CONFIG_BT_ENABLED
|
||||
|
||||
#ifdef CONFIG_BT_HCI_UART_NO
|
||||
#define BT_HCI_UART_NO_DEFAULT CONFIG_BT_HCI_UART_NO
|
||||
#else
|
||||
#define BT_HCI_UART_NO_DEFAULT 1
|
||||
#endif /* BT_HCI_UART_NO_DEFAULT */
|
||||
|
||||
#ifdef CONFIG_BT_HCI_UART_BAUDRATE
|
||||
#define BT_HCI_UART_BAUDRATE_DEFAULT CONFIG_BT_HCI_UART_BAUDRATE
|
||||
#else
|
||||
#define BT_HCI_UART_BAUDRATE_DEFAULT 921600
|
||||
#endif /* BT_HCI_UART_BAUDRATE_DEFAULT */
|
||||
|
||||
#define BT_CONTROLLER_INIT_CONFIG_DEFAULT() { \
|
||||
.controller_task_stack_size = ESP_TASK_BT_CONTROLLER_STACK, \
|
||||
.controller_task_prio = ESP_TASK_BT_CONTROLLER_PRIO, \
|
||||
.hci_uart_no = BT_HCI_UART_NO_DEFAULT, \
|
||||
.hci_uart_baudrate = BT_HCI_UART_BAUDRATE_DEFAULT, \
|
||||
};
|
||||
#else
|
||||
#define BT_CONTROLLER_INIT_CONFIG_DEFAULT() {0}; _Static_assert(0, "please enable bluetooth in menuconfig to use bt.h");
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Bluetooth mode for controller enable/disable
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_BT_MODE_IDLE = 0x00, /*!< Bluetooth is not running */
|
||||
ESP_BT_MODE_BLE = 0x01, /*!< Run BLE mode */
|
||||
ESP_BT_MODE_CLASSIC_BT = 0x02, /*!< Run Classic BT mode */
|
||||
ESP_BT_MODE_BTDM = 0x03, /*!< Run dual mode */
|
||||
} esp_bt_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Bluetooth controller enable/disable/initialised/de-initialised status
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_BT_CONTROLLER_STATUS_IDLE = 0,
|
||||
ESP_BT_CONTROLLER_STATUS_INITED,
|
||||
ESP_BT_CONTROLLER_STATUS_ENABLED,
|
||||
ESP_BT_CONTROLLER_STATUS_NUM,
|
||||
} esp_bt_controller_status_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief BLE tx power type
|
||||
* ESP_BLE_PWR_TYPE_CONN_HDL0-8: for each connection, and only be set after connetion completed.
|
||||
* when disconnect, the correspond TX power is not effected.
|
||||
* ESP_BLE_PWR_TYPE_ADV : for advertising/scan response.
|
||||
* ESP_BLE_PWR_TYPE_SCAN : for scan.
|
||||
* ESP_BLE_PWR_TYPE_DEFAULT : if each connection's TX power is not set, it will use this default value.
|
||||
* if neither in scan mode nor in adv mode, it will use this default value.
|
||||
* If none of power type is set, system will use ESP_PWR_LVL_P1 as default for ADV/SCAN/CONN0-9.
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_BLE_PWR_TYPE_CONN_HDL0 = 0, /*!< For connection handle 0 */
|
||||
ESP_BLE_PWR_TYPE_CONN_HDL1 = 1, /*!< For connection handle 1 */
|
||||
ESP_BLE_PWR_TYPE_CONN_HDL2 = 2, /*!< For connection handle 2 */
|
||||
ESP_BLE_PWR_TYPE_CONN_HDL3 = 3, /*!< For connection handle 3 */
|
||||
ESP_BLE_PWR_TYPE_CONN_HDL4 = 4, /*!< For connection handle 4 */
|
||||
ESP_BLE_PWR_TYPE_CONN_HDL5 = 5, /*!< For connection handle 5 */
|
||||
ESP_BLE_PWR_TYPE_CONN_HDL6 = 6, /*!< For connection handle 6 */
|
||||
ESP_BLE_PWR_TYPE_CONN_HDL7 = 7, /*!< For connection handle 7 */
|
||||
ESP_BLE_PWR_TYPE_CONN_HDL8 = 8, /*!< For connection handle 8 */
|
||||
ESP_BLE_PWR_TYPE_ADV = 9, /*!< For advertising */
|
||||
ESP_BLE_PWR_TYPE_SCAN = 10, /*!< For scan */
|
||||
ESP_BLE_PWR_TYPE_DEFAULT = 11, /*!< For default, if not set other, it will use default value */
|
||||
ESP_BLE_PWR_TYPE_NUM = 12, /*!< TYPE numbers */
|
||||
} esp_ble_power_type_t;
|
||||
|
||||
/**
|
||||
* @brief Bluetooth TX power level(index), it's just a index corresponding to power(dbm).
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_PWR_LVL_N14 = 0, /*!< Corresponding to -14dbm */
|
||||
ESP_PWR_LVL_N11 = 1, /*!< Corresponding to -11dbm */
|
||||
ESP_PWR_LVL_N8 = 2, /*!< Corresponding to -8dbm */
|
||||
ESP_PWR_LVL_N5 = 3, /*!< Corresponding to -5dbm */
|
||||
ESP_PWR_LVL_N2 = 4, /*!< Corresponding to -2dbm */
|
||||
ESP_PWR_LVL_P1 = 5, /*!< Corresponding to 1dbm */
|
||||
ESP_PWR_LVL_P4 = 6, /*!< Corresponding to 4dbm */
|
||||
ESP_PWR_LVL_P7 = 7, /*!< Corresponding to 7dbm */
|
||||
} esp_power_level_t;
|
||||
|
||||
/**
|
||||
* @brief Set BLE TX power
|
||||
* Connection Tx power should only be set after connection created.
|
||||
* @param power_type : The type of which tx power, could set Advertising/Connection/Default and etc
|
||||
* @param power_level: Power level(index) corresponding to absolute value(dbm)
|
||||
* @return ESP_OK - success, other - failed
|
||||
*/
|
||||
esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_t power_level);
|
||||
|
||||
/**
|
||||
* @brief Get BLE TX power
|
||||
* Connection Tx power should only be get after connection created.
|
||||
* @param power_type : The type of which tx power, could set Advertising/Connection/Default and etc
|
||||
* @return >= 0 - Power level, < 0 - Invalid
|
||||
*/
|
||||
esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initialize BT controller to allocate task and other resource.
|
||||
* @param cfg: Initial configuration of BT controller.
|
||||
* This function should be called only once, before any other BT functions are called.
|
||||
* @return ESP_OK - success, other - failed
|
||||
*/
|
||||
esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg);
|
||||
|
||||
/**
|
||||
* @brief De-initialize BT controller to free resource and delete task.
|
||||
*
|
||||
* This function should be called only once, after any other BT functions are called.
|
||||
* This function is not whole completed, esp_bt_controller_init cannot called after this function.
|
||||
* @return ESP_OK - success, other - failed
|
||||
*/
|
||||
esp_err_t esp_bt_controller_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief Enable BT controller.
|
||||
* Due to a known issue, you cannot call esp_bt_controller_enable() a second time
|
||||
* to change the controller mode dynamically. To change controller mode, call
|
||||
* esp_bt_controller_disable() and then call esp_bt_controller_enable() with the new mode.
|
||||
* @param mode : the mode(BLE/BT/BTDM) to enable.
|
||||
* @return ESP_OK - success, other - failed
|
||||
*/
|
||||
esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief Disable BT controller
|
||||
* @return ESP_OK - success, other - failed
|
||||
*/
|
||||
esp_err_t esp_bt_controller_disable(void);
|
||||
|
||||
/**
|
||||
* @brief Get BT controller is initialised/de-initialised/enabled/disabled
|
||||
* @return status value
|
||||
*/
|
||||
esp_bt_controller_status_t esp_bt_controller_get_status(void);
|
||||
|
||||
/** @brief esp_vhci_host_callback
|
||||
* used for vhci call host function to notify what host need to do
|
||||
*/
|
||||
typedef struct esp_vhci_host_callback {
|
||||
void (*notify_host_send_available)(void); /*!< callback used to notify that the host can send packet to controller */
|
||||
int (*notify_host_recv)(uint8_t *data, uint16_t len); /*!< callback used to notify that the controller has a packet to send to the host*/
|
||||
} esp_vhci_host_callback_t;
|
||||
|
||||
/** @brief esp_vhci_host_check_send_available
|
||||
* used for check actively if the host can send packet to controller or not.
|
||||
* @return true for ready to send, false means cannot send packet
|
||||
*/
|
||||
bool esp_vhci_host_check_send_available(void);
|
||||
|
||||
/** @brief esp_vhci_host_send_packet
|
||||
* host send packet to controller
|
||||
* @param data the packet point
|
||||
*,@param len the packet length
|
||||
*/
|
||||
void esp_vhci_host_send_packet(uint8_t *data, uint16_t len);
|
||||
|
||||
/** @brief esp_vhci_host_register_callback
|
||||
* register the vhci referece callback, the call back
|
||||
* struct defined by vhci_host_callback structure.
|
||||
* @param callback esp_vhci_host_callback type variable
|
||||
*/
|
||||
void esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callback);
|
||||
|
||||
/** @brief esp_bt_controller_mem_release
|
||||
* release the memory by mode, if never use the bluetooth mode
|
||||
* it can release the .bbs, .data and other section to heap.
|
||||
* The total size is about 70k bytes.
|
||||
*
|
||||
* If esp_bt_controller_enable(mode) has already been called, calling
|
||||
* esp_bt_controller_mem_release(ESP_BT_MODE_BTDM) will automatically
|
||||
* release all memory which is not needed for the currently enabled
|
||||
* Bluetooth controller mode.
|
||||
*
|
||||
* For example, calling esp_bt_controller_enable(ESP_BT_MODE_BLE) then
|
||||
* esp_bt_controller_mem_release(ESP_BT_MODE_BTDM) will enable BLE modes
|
||||
* and release memory only used by BT Classic. Also, call esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT)
|
||||
* is the same.
|
||||
*
|
||||
* Note that once BT controller memory is released, the process cannot be reversed.
|
||||
* If your firmware will later upgrade the Bluetooth controller mode (BLE -> BT Classic or disabled -> enabled)
|
||||
* then do not call this function.
|
||||
*
|
||||
* If user never use bluetooth controller, could call esp_bt_controller_mem_release(ESP_BT_MODE_BTDM)
|
||||
* before esp_bt_controller_init or after esp_bt_controller_deinit.
|
||||
*
|
||||
* For example, user only use bluetooth to config SSID and PASSWORD of WIFI, after config, will never use bluetooth.
|
||||
* Then, could call esp_bt_controller_mem_release(ESP_BT_MODE_BTDM) after esp_bt_controller_deinit.
|
||||
*
|
||||
* @param mode : the mode want to release memory
|
||||
* @return ESP_OK - success, other - failed
|
||||
*/
|
||||
esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __BT_H__ */
|
||||
#pragma once
|
||||
#warning "This header is deprecated, please use functions defined in esp_bt.h instead."
|
||||
#include "esp_bt.h"
|
||||
|
242
tools/sdk/include/bt/esp_bt.h
Normal file
242
tools/sdk/include/bt/esp_bt.h
Normal file
@ -0,0 +1,242 @@
|
||||
// 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_BT_H__
|
||||
#define __ESP_BT_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_task.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Controller config options, depend on config mask.
|
||||
* Config mask indicate which functions enabled, this means
|
||||
* some options or parameters of some functions enabled by config mask.
|
||||
*/
|
||||
typedef struct {
|
||||
uint16_t controller_task_stack_size; /*!< Bluetooth controller task stack size */
|
||||
uint8_t controller_task_prio; /*!< Bluetooth controller task priority */
|
||||
uint8_t hci_uart_no; /*!< If use UART1/2 as HCI IO interface, indicate UART number */
|
||||
uint32_t hci_uart_baudrate; /*!< If use UART1/2 as HCI IO interface, indicate UART baudrate */
|
||||
} esp_bt_controller_config_t;
|
||||
|
||||
#ifdef CONFIG_BT_ENABLED
|
||||
|
||||
#ifdef CONFIG_BT_HCI_UART_NO
|
||||
#define BT_HCI_UART_NO_DEFAULT CONFIG_BT_HCI_UART_NO
|
||||
#else
|
||||
#define BT_HCI_UART_NO_DEFAULT 1
|
||||
#endif /* BT_HCI_UART_NO_DEFAULT */
|
||||
|
||||
#ifdef CONFIG_BT_HCI_UART_BAUDRATE
|
||||
#define BT_HCI_UART_BAUDRATE_DEFAULT CONFIG_BT_HCI_UART_BAUDRATE
|
||||
#else
|
||||
#define BT_HCI_UART_BAUDRATE_DEFAULT 921600
|
||||
#endif /* BT_HCI_UART_BAUDRATE_DEFAULT */
|
||||
|
||||
#define BT_CONTROLLER_INIT_CONFIG_DEFAULT() { \
|
||||
.controller_task_stack_size = ESP_TASK_BT_CONTROLLER_STACK, \
|
||||
.controller_task_prio = ESP_TASK_BT_CONTROLLER_PRIO, \
|
||||
.hci_uart_no = BT_HCI_UART_NO_DEFAULT, \
|
||||
.hci_uart_baudrate = BT_HCI_UART_BAUDRATE_DEFAULT, \
|
||||
};
|
||||
#else
|
||||
#define BT_CONTROLLER_INIT_CONFIG_DEFAULT() {0}; _Static_assert(0, "please enable bluetooth in menuconfig to use bt.h");
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Bluetooth mode for controller enable/disable
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_BT_MODE_IDLE = 0x00, /*!< Bluetooth is not running */
|
||||
ESP_BT_MODE_BLE = 0x01, /*!< Run BLE mode */
|
||||
ESP_BT_MODE_CLASSIC_BT = 0x02, /*!< Run Classic BT mode */
|
||||
ESP_BT_MODE_BTDM = 0x03, /*!< Run dual mode */
|
||||
} esp_bt_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Bluetooth controller enable/disable/initialised/de-initialised status
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_BT_CONTROLLER_STATUS_IDLE = 0,
|
||||
ESP_BT_CONTROLLER_STATUS_INITED,
|
||||
ESP_BT_CONTROLLER_STATUS_ENABLED,
|
||||
ESP_BT_CONTROLLER_STATUS_NUM,
|
||||
} esp_bt_controller_status_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief BLE tx power type
|
||||
* ESP_BLE_PWR_TYPE_CONN_HDL0-8: for each connection, and only be set after connetion completed.
|
||||
* when disconnect, the correspond TX power is not effected.
|
||||
* ESP_BLE_PWR_TYPE_ADV : for advertising/scan response.
|
||||
* ESP_BLE_PWR_TYPE_SCAN : for scan.
|
||||
* ESP_BLE_PWR_TYPE_DEFAULT : if each connection's TX power is not set, it will use this default value.
|
||||
* if neither in scan mode nor in adv mode, it will use this default value.
|
||||
* If none of power type is set, system will use ESP_PWR_LVL_P1 as default for ADV/SCAN/CONN0-9.
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_BLE_PWR_TYPE_CONN_HDL0 = 0, /*!< For connection handle 0 */
|
||||
ESP_BLE_PWR_TYPE_CONN_HDL1 = 1, /*!< For connection handle 1 */
|
||||
ESP_BLE_PWR_TYPE_CONN_HDL2 = 2, /*!< For connection handle 2 */
|
||||
ESP_BLE_PWR_TYPE_CONN_HDL3 = 3, /*!< For connection handle 3 */
|
||||
ESP_BLE_PWR_TYPE_CONN_HDL4 = 4, /*!< For connection handle 4 */
|
||||
ESP_BLE_PWR_TYPE_CONN_HDL5 = 5, /*!< For connection handle 5 */
|
||||
ESP_BLE_PWR_TYPE_CONN_HDL6 = 6, /*!< For connection handle 6 */
|
||||
ESP_BLE_PWR_TYPE_CONN_HDL7 = 7, /*!< For connection handle 7 */
|
||||
ESP_BLE_PWR_TYPE_CONN_HDL8 = 8, /*!< For connection handle 8 */
|
||||
ESP_BLE_PWR_TYPE_ADV = 9, /*!< For advertising */
|
||||
ESP_BLE_PWR_TYPE_SCAN = 10, /*!< For scan */
|
||||
ESP_BLE_PWR_TYPE_DEFAULT = 11, /*!< For default, if not set other, it will use default value */
|
||||
ESP_BLE_PWR_TYPE_NUM = 12, /*!< TYPE numbers */
|
||||
} esp_ble_power_type_t;
|
||||
|
||||
/**
|
||||
* @brief Bluetooth TX power level(index), it's just a index corresponding to power(dbm).
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_PWR_LVL_N14 = 0, /*!< Corresponding to -14dbm */
|
||||
ESP_PWR_LVL_N11 = 1, /*!< Corresponding to -11dbm */
|
||||
ESP_PWR_LVL_N8 = 2, /*!< Corresponding to -8dbm */
|
||||
ESP_PWR_LVL_N5 = 3, /*!< Corresponding to -5dbm */
|
||||
ESP_PWR_LVL_N2 = 4, /*!< Corresponding to -2dbm */
|
||||
ESP_PWR_LVL_P1 = 5, /*!< Corresponding to 1dbm */
|
||||
ESP_PWR_LVL_P4 = 6, /*!< Corresponding to 4dbm */
|
||||
ESP_PWR_LVL_P7 = 7, /*!< Corresponding to 7dbm */
|
||||
} esp_power_level_t;
|
||||
|
||||
/**
|
||||
* @brief Set BLE TX power
|
||||
* Connection Tx power should only be set after connection created.
|
||||
* @param power_type : The type of which tx power, could set Advertising/Connection/Default and etc
|
||||
* @param power_level: Power level(index) corresponding to absolute value(dbm)
|
||||
* @return ESP_OK - success, other - failed
|
||||
*/
|
||||
esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_t power_level);
|
||||
|
||||
/**
|
||||
* @brief Get BLE TX power
|
||||
* Connection Tx power should only be get after connection created.
|
||||
* @param power_type : The type of which tx power, could set Advertising/Connection/Default and etc
|
||||
* @return >= 0 - Power level, < 0 - Invalid
|
||||
*/
|
||||
esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initialize BT controller to allocate task and other resource.
|
||||
* @param cfg: Initial configuration of BT controller.
|
||||
* This function should be called only once, before any other BT functions are called.
|
||||
* @return ESP_OK - success, other - failed
|
||||
*/
|
||||
esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg);
|
||||
|
||||
/**
|
||||
* @brief De-initialize BT controller to free resource and delete task.
|
||||
*
|
||||
* This function should be called only once, after any other BT functions are called.
|
||||
* This function is not whole completed, esp_bt_controller_init cannot called after this function.
|
||||
* @return ESP_OK - success, other - failed
|
||||
*/
|
||||
esp_err_t esp_bt_controller_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief Enable BT controller.
|
||||
* Due to a known issue, you cannot call esp_bt_controller_enable() a second time
|
||||
* to change the controller mode dynamically. To change controller mode, call
|
||||
* esp_bt_controller_disable() and then call esp_bt_controller_enable() with the new mode.
|
||||
* @param mode : the mode(BLE/BT/BTDM) to enable.
|
||||
* @return ESP_OK - success, other - failed
|
||||
*/
|
||||
esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief Disable BT controller
|
||||
* @return ESP_OK - success, other - failed
|
||||
*/
|
||||
esp_err_t esp_bt_controller_disable(void);
|
||||
|
||||
/**
|
||||
* @brief Get BT controller is initialised/de-initialised/enabled/disabled
|
||||
* @return status value
|
||||
*/
|
||||
esp_bt_controller_status_t esp_bt_controller_get_status(void);
|
||||
|
||||
/** @brief esp_vhci_host_callback
|
||||
* used for vhci call host function to notify what host need to do
|
||||
*/
|
||||
typedef struct esp_vhci_host_callback {
|
||||
void (*notify_host_send_available)(void); /*!< callback used to notify that the host can send packet to controller */
|
||||
int (*notify_host_recv)(uint8_t *data, uint16_t len); /*!< callback used to notify that the controller has a packet to send to the host*/
|
||||
} esp_vhci_host_callback_t;
|
||||
|
||||
/** @brief esp_vhci_host_check_send_available
|
||||
* used for check actively if the host can send packet to controller or not.
|
||||
* @return true for ready to send, false means cannot send packet
|
||||
*/
|
||||
bool esp_vhci_host_check_send_available(void);
|
||||
|
||||
/** @brief esp_vhci_host_send_packet
|
||||
* host send packet to controller
|
||||
* @param data the packet point
|
||||
*,@param len the packet length
|
||||
*/
|
||||
void esp_vhci_host_send_packet(uint8_t *data, uint16_t len);
|
||||
|
||||
/** @brief esp_vhci_host_register_callback
|
||||
* register the vhci referece callback, the call back
|
||||
* struct defined by vhci_host_callback structure.
|
||||
* @param callback esp_vhci_host_callback type variable
|
||||
*/
|
||||
void esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callback);
|
||||
|
||||
/** @brief esp_bt_controller_mem_release
|
||||
* release the memory by mode, if never use the bluetooth mode
|
||||
* it can release the .bbs, .data and other section to heap.
|
||||
* The total size is about 70k bytes.
|
||||
*
|
||||
* esp_bt_controller_mem_release(mode) should be called only before esp_bt_controller_init()
|
||||
* or after esp_bt_controller_deinit().
|
||||
*
|
||||
* Note that once BT controller memory is released, the process cannot be reversed. It means you can not use the bluetooth
|
||||
* mode which you have released by this function.
|
||||
*
|
||||
* If your firmware will later upgrade the Bluetooth controller mode (BLE -> BT Classic or disabled -> enabled)
|
||||
* then do not call this function.
|
||||
*
|
||||
* If the app calls esp_bt_controller_enable(ESP_BT_MODE_BLE) to use BLE only then it is safe to call
|
||||
* esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT) at initialisation time to free unused BT Classic memory.
|
||||
*
|
||||
* If user never use bluetooth controller, could call esp_bt_controller_mem_release(ESP_BT_MODE_BTDM)
|
||||
* before esp_bt_controller_init or after esp_bt_controller_deinit.
|
||||
*
|
||||
* For example, user only use bluetooth to config SSID and PASSWORD of WIFI, after config, will never use bluetooth.
|
||||
* Then, could call esp_bt_controller_mem_release(ESP_BT_MODE_BTDM) after esp_bt_controller_deinit.
|
||||
*
|
||||
* @param mode : the mode want to release memory
|
||||
* @return ESP_OK - success, other - failed
|
||||
*/
|
||||
esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_BT_H__ */
|
@ -45,8 +45,10 @@
|
||||
#define CONFIG_MBEDTLS_SSL_ALPN 1
|
||||
#define CONFIG_MBEDTLS_PEM_WRITE_C 1
|
||||
#define CONFIG_BT_RESERVE_DRAM 0x10000
|
||||
#define CONFIG_CXX_EXCEPTIONS 1
|
||||
#define CONFIG_FATFS_FS_LOCK 0
|
||||
#define CONFIG_IP_LOST_TIMER_INTERVAL 120
|
||||
#define CONFIG_SPIFFS_META_LENGTH 4
|
||||
#define CONFIG_ESP32_PANIC_PRINT_REBOOT 1
|
||||
#define CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED 1
|
||||
#define CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED 1
|
||||
@ -65,6 +67,7 @@
|
||||
#define CONFIG_FLASHMODE_DIO 1
|
||||
#define CONFIG_ESPTOOLPY_AFTER_RESET 1
|
||||
#define CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED 1
|
||||
#define CONFIG_LWIP_DHCPS_MAX_STATION_NUM 8
|
||||
#define CONFIG_TOOLPREFIX "xtensa-esp32-elf-"
|
||||
#define CONFIG_MBEDTLS_ECP_C 1
|
||||
#define CONFIG_FREERTOS_IDLE_TASK_STACKSIZE 1024
|
||||
@ -84,6 +87,7 @@
|
||||
#define CONFIG_TIMER_TASK_STACK_SIZE 4096
|
||||
#define CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE 1
|
||||
#define CONFIG_MBEDTLS_X509_CRL_PARSE_C 1
|
||||
#define CONFIG_LWIP_DHCPS_LEASE_UNIT 60
|
||||
#define CONFIG_SPIFFS_USE_MAGIC 1
|
||||
#define CONFIG_TCPIP_TASK_STACK_SIZE 2560
|
||||
#define CONFIG_BLUEDROID_PINNED_TO_CORE_0 1
|
||||
@ -131,6 +135,7 @@
|
||||
#define CONFIG_PARTITION_TABLE_SINGLE_APP 1
|
||||
#define CONFIG_ESP32_WIFI_RX_BA_WIN 6
|
||||
#define CONFIG_MBEDTLS_X509_CSR_PARSE_C 1
|
||||
#define CONFIG_SPIFFS_USE_MTIME 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
|
||||
@ -177,6 +182,7 @@
|
||||
#define CONFIG_LWIP_MAX_LISTENING_TCP 16
|
||||
#define CONFIG_FREERTOS_INTERRUPT_BACKTRACE 1
|
||||
#define CONFIG_WL_SECTOR_SIZE 4096
|
||||
#define CONFIG_ESP32_DEBUG_OCDAWARE 1
|
||||
#define CONFIG_TIMER_TASK_PRIORITY 1
|
||||
#define CONFIG_MBEDTLS_TLS_CLIENT 1
|
||||
#define CONFIG_BTDM_CONTROLLER_HCI_MODE_VHCI 1
|
||||
@ -189,6 +195,7 @@
|
||||
#define CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY 1
|
||||
#define CONFIG_TCP_QUEUE_OOSEQ 1
|
||||
#define CONFIG_GATTS_ENABLE 1
|
||||
#define CONFIG_CXX_EXCEPTIONS_EMG_POOL_SIZE 0
|
||||
#define CONFIG_MBEDTLS_TLS_SERVER 1
|
||||
#define CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT 1
|
||||
#define CONFIG_FREERTOS_ISR_STACKSIZE 1536
|
||||
|
@ -69,6 +69,13 @@ typedef enum {
|
||||
I2C_ADDR_BIT_MAX,
|
||||
} i2c_addr_mode_t;
|
||||
|
||||
typedef enum {
|
||||
I2C_MASTER_ACK = 0x0, /*!< I2C ack for each byte read */
|
||||
I2C_MASTER_NACK = 0x1, /*!< I2C nack for each byte read */
|
||||
I2C_MASTER_LAST_NACK = 0x2, /*!< I2C nack for the last byte*/
|
||||
I2C_MASTER_ACK_MAX,
|
||||
} i2c_ack_type_t;
|
||||
|
||||
/**
|
||||
* @brief I2C initialization parameters
|
||||
*/
|
||||
@ -288,7 +295,7 @@ esp_err_t i2c_master_write(i2c_cmd_handle_t cmd_handle, uint8_t* data, size_t da
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t i2c_master_read_byte(i2c_cmd_handle_t cmd_handle, uint8_t* data, int ack);
|
||||
esp_err_t i2c_master_read_byte(i2c_cmd_handle_t cmd_handle, uint8_t* data, i2c_ack_type_t ack);
|
||||
|
||||
/**
|
||||
* @brief Queue command for I2C master to read data from I2C bus
|
||||
@ -305,7 +312,7 @@ esp_err_t i2c_master_read_byte(i2c_cmd_handle_t cmd_handle, uint8_t* data, int a
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t i2c_master_read(i2c_cmd_handle_t cmd_handle, uint8_t* data, size_t data_len, int ack);
|
||||
esp_err_t i2c_master_read(i2c_cmd_handle_t cmd_handle, uint8_t* data, size_t data_len, i2c_ack_type_t ack);
|
||||
|
||||
/**
|
||||
* @brief Queue command for I2C master to generate a stop signal
|
||||
|
@ -50,10 +50,10 @@ typedef enum {
|
||||
} ledc_clk_src_t;
|
||||
|
||||
typedef enum {
|
||||
LEDC_TIMER_0 = 0, /*!< LEDC source timer TIMER0 */
|
||||
LEDC_TIMER_1, /*!< LEDC source timer TIMER1 */
|
||||
LEDC_TIMER_2, /*!< LEDC source timer TIMER2 */
|
||||
LEDC_TIMER_3, /*!< LEDC source timer TIMER3 */
|
||||
LEDC_TIMER_0 = 0, /*!< LEDC timer 0 */
|
||||
LEDC_TIMER_1, /*!< LEDC timer 1 */
|
||||
LEDC_TIMER_2, /*!< LEDC timer 2 */
|
||||
LEDC_TIMER_3, /*!< LEDC timer 3 */
|
||||
} ledc_timer_t;
|
||||
|
||||
typedef enum {
|
||||
@ -69,12 +69,12 @@ typedef enum {
|
||||
} ledc_channel_t;
|
||||
|
||||
typedef enum {
|
||||
LEDC_TIMER_10_BIT = 10, /*!< LEDC PWM depth 10Bit */
|
||||
LEDC_TIMER_11_BIT = 11, /*!< LEDC PWM depth 11Bit */
|
||||
LEDC_TIMER_12_BIT = 12, /*!< LEDC PWM depth 12Bit */
|
||||
LEDC_TIMER_13_BIT = 13, /*!< LEDC PWM depth 13Bit */
|
||||
LEDC_TIMER_14_BIT = 14, /*!< LEDC PWM depth 14Bit */
|
||||
LEDC_TIMER_15_BIT = 15, /*!< LEDC PWM depth 15Bit */
|
||||
LEDC_TIMER_10_BIT = 10, /*!< LEDC PWM duty resolution of 10 bits */
|
||||
LEDC_TIMER_11_BIT = 11, /*!< LEDC PWM duty resolution of 11 bits */
|
||||
LEDC_TIMER_12_BIT = 12, /*!< LEDC PWM duty resolution of 12 bits */
|
||||
LEDC_TIMER_13_BIT = 13, /*!< LEDC PWM duty resolution of 13 bits */
|
||||
LEDC_TIMER_14_BIT = 14, /*!< LEDC PWM duty resolution of 14 bits */
|
||||
LEDC_TIMER_15_BIT = 15, /*!< LEDC PWM duty resolution of 15 bits */
|
||||
} ledc_timer_bit_t;
|
||||
|
||||
typedef enum {
|
||||
@ -82,6 +82,7 @@ typedef enum {
|
||||
LEDC_FADE_WAIT_DONE, /*!< LEDC fade function will block until fading to the target duty */
|
||||
LEDC_FADE_MAX,
|
||||
} ledc_fade_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Configuration parameters of LEDC channel for ledc_channel_config function
|
||||
*/
|
||||
@ -91,7 +92,7 @@ typedef struct {
|
||||
ledc_channel_t channel; /*!< LEDC channel (0 - 7) */
|
||||
ledc_intr_type_t intr_type; /*!< configure interrupt, Fade interrupt enable or Fade interrupt disable */
|
||||
ledc_timer_t timer_sel; /*!< Select the timer source of channel (0 - 3) */
|
||||
uint32_t duty; /*!< LEDC channel duty, the duty range is [0, (2**bit_num) - 1], */
|
||||
uint32_t duty; /*!< LEDC channel duty, the range of duty setting is [0, (2**duty_resolution) - 1] */
|
||||
} ledc_channel_config_t;
|
||||
|
||||
/**
|
||||
@ -99,7 +100,10 @@ typedef struct {
|
||||
*/
|
||||
typedef struct {
|
||||
ledc_mode_t speed_mode; /*!< LEDC speed speed_mode, high-speed mode or low-speed mode */
|
||||
ledc_timer_bit_t bit_num; /*!< LEDC channel duty depth*/
|
||||
union {
|
||||
ledc_timer_bit_t duty_resolution; /*!< LEDC channel duty resolution */
|
||||
ledc_timer_bit_t bit_num __attribute__((deprecated)); /*!< Deprecated in ESP-IDF 3.0. This is an alias to 'duty_resolution' for backward compatibility with ESP-IDF 2.1 */
|
||||
};
|
||||
ledc_timer_t timer_num; /*!< The timer source of channel (0 - 3) */
|
||||
uint32_t freq_hz; /*!< LEDC timer frequency (Hz) */
|
||||
} ledc_timer_config_t;
|
||||
@ -108,7 +112,7 @@ typedef intr_handle_t ledc_isr_handle_t;
|
||||
|
||||
/**
|
||||
* @brief LEDC channel configuration
|
||||
* Configure LEDC channel with the given channel/output gpio_num/interrupt/source timer/frequency(Hz)/LEDC depth
|
||||
* Configure LEDC channel with the given channel/output gpio_num/interrupt/source timer/frequency(Hz)/LEDC duty resolution
|
||||
*
|
||||
* @param ledc_conf Pointer of LEDC channel configure struct
|
||||
*
|
||||
@ -120,14 +124,14 @@ esp_err_t ledc_channel_config(const ledc_channel_config_t* ledc_conf);
|
||||
|
||||
/**
|
||||
* @brief LEDC timer configuration
|
||||
* Configure LEDC timer with the given source timer/frequency(Hz)/bit_num
|
||||
* Configure LEDC timer with the given source timer/frequency(Hz)/duty_resolution
|
||||
*
|
||||
* @param timer_conf Pointer of LEDC timer configure struct
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_FAIL Can not find a proper pre-divider number base on the given frequency and the current bit_num.
|
||||
* - ESP_FAIL Can not find a proper pre-divider number base on the given frequency and the current duty_resolution.
|
||||
*/
|
||||
esp_err_t ledc_timer_config(const ledc_timer_config_t* timer_conf);
|
||||
|
||||
@ -170,7 +174,7 @@ esp_err_t ledc_stop(ledc_mode_t speed_mode, ledc_channel_t channel, uint32_t idl
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_FAIL Can not find a proper pre-divider number base on the given frequency and the current bit_num.
|
||||
* - ESP_FAIL Can not find a proper pre-divider number base on the given frequency and the current duty_resolution.
|
||||
*/
|
||||
esp_err_t ledc_set_freq(ledc_mode_t speed_mode, ledc_timer_t timer_num, uint32_t freq_hz);
|
||||
|
||||
@ -192,7 +196,7 @@ uint32_t ledc_get_freq(ledc_mode_t speed_mode, ledc_timer_t timer_num);
|
||||
*
|
||||
* @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode
|
||||
* @param channel LEDC channel (0-7), select from ledc_channel_t
|
||||
* @param duty Set the LEDC duty, the duty range is [0, (2**bit_num) - 1]
|
||||
* @param duty Set the LEDC duty, the range of duty setting is [0, (2**duty_resolution) - 1]
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
@ -218,7 +222,7 @@ uint32_t ledc_get_duty(ledc_mode_t speed_mode, ledc_channel_t channel);
|
||||
*
|
||||
* @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode
|
||||
* @param channel LEDC channel (0-7), select from ledc_channel_t
|
||||
* @param duty Set the start of the gradient duty, the duty range is [0, (2**bit_num) - 1]
|
||||
* @param duty Set the start of the gradient duty, the range of duty setting is [0, (2**duty_resolution) - 1]
|
||||
* @param gradule_direction Set the direction of the gradient
|
||||
* @param step_num Set the number of the gradient
|
||||
* @param duty_cyle_num Set how many LEDC tick each time the gradient lasts
|
||||
@ -254,15 +258,15 @@ esp_err_t ledc_isr_register(void (*fn)(void*), void * arg, int intr_alloc_flags,
|
||||
*
|
||||
* @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode
|
||||
* @param timer_sel Timer index (0-3), there are 4 timers in LEDC module
|
||||
* @param div_num Timer clock divide number, the timer clock is divided from the selected clock source
|
||||
* @param bit_num The count number of one period, counter range is 0 ~ ((2 ** bit_num) - 1)
|
||||
* @param clock_divider Timer clock divide value, the timer clock is divided from the selected clock source
|
||||
* @param duty_resolution Resolution of duty setting in number of bits. The range of duty values is [0, (2**duty_resolution) - 1]
|
||||
* @param clk_src Select LEDC source clock.
|
||||
*
|
||||
* @return
|
||||
* - (-1) Parameter error
|
||||
* - Other Current LEDC duty
|
||||
*/
|
||||
esp_err_t ledc_timer_set(ledc_mode_t speed_mode, ledc_timer_t timer_sel, uint32_t div_num, uint32_t bit_num, ledc_clk_src_t clk_src);
|
||||
esp_err_t ledc_timer_set(ledc_mode_t speed_mode, ledc_timer_t timer_sel, uint32_t clock_divider, uint32_t duty_resolution, ledc_clk_src_t clk_src);
|
||||
|
||||
/**
|
||||
* @brief Reset LEDC timer
|
||||
@ -320,7 +324,7 @@ esp_err_t ledc_bind_channel_timer(ledc_mode_t speed_mode, uint32_t channel, uint
|
||||
*
|
||||
* @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode,
|
||||
* @param channel LEDC channel index (0-7), select from ledc_channel_t
|
||||
* @param target_duty Target duty of fading.( 0 - (2 ** bit_num - 1)))
|
||||
* @param target_duty Target duty of fading [0, (2**duty_resolution) - 1]
|
||||
* @param scale Controls the increase or decrease step scale.
|
||||
* @param cycle_num increase or decrease the duty every cycle_num cycles
|
||||
*
|
||||
@ -338,7 +342,7 @@ esp_err_t ledc_set_fade_with_step(ledc_mode_t speed_mode, ledc_channel_t channel
|
||||
*
|
||||
* @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode,
|
||||
* @param channel LEDC channel index (0-7), select from ledc_channel_t
|
||||
* @param target_duty Target duty of fading.( 0 - (2 ** bit_num - 1)))
|
||||
* @param target_duty Target duty of fading.( 0 - (2 ** duty_resolution - 1)))
|
||||
* @param max_fade_time_ms The maximum time of the fading ( ms ).
|
||||
*
|
||||
* @return
|
||||
|
@ -51,7 +51,7 @@ typedef enum {
|
||||
}rmt_mem_owner_t;
|
||||
|
||||
typedef enum {
|
||||
RMT_BASECLK_REF = 0, /*!< RMT source clock system reference tick, 1MHz by default(Not supported in this version) */
|
||||
RMT_BASECLK_REF = 0, /*!< RMT source clock system reference tick, 1MHz by default (not supported in this version) */
|
||||
RMT_BASECLK_APB, /*!< RMT source clock is APB CLK, 80Mhz by default */
|
||||
RMT_BASECLK_MAX,
|
||||
} rmt_source_clk_t;
|
||||
@ -84,10 +84,10 @@ typedef enum {
|
||||
* @brief Data struct of RMT TX configure parameters
|
||||
*/
|
||||
typedef struct {
|
||||
bool loop_en; /*!< RMT loop output mode*/
|
||||
bool loop_en; /*!< Enable sending RMT items in a loop */
|
||||
uint32_t carrier_freq_hz; /*!< RMT carrier frequency */
|
||||
uint8_t carrier_duty_percent; /*!< RMT carrier duty (%) */
|
||||
rmt_carrier_level_t carrier_level; /*!< RMT carrier level */
|
||||
rmt_carrier_level_t carrier_level; /*!< Level of the RMT output, when the carrier is applied */
|
||||
bool carrier_en; /*!< RMT carrier enable */
|
||||
rmt_idle_level_t idle_level; /*!< RMT idle level */
|
||||
bool idle_output_en; /*!< RMT idle level output enable */
|
||||
@ -97,7 +97,7 @@ typedef struct {
|
||||
* @brief Data struct of RMT RX configure parameters
|
||||
*/
|
||||
typedef struct {
|
||||
bool filter_en; /*!< RMT receiver filer enable*/
|
||||
bool filter_en; /*!< RMT receiver filter enable */
|
||||
uint8_t filter_ticks_thresh; /*!< RMT filter tick number */
|
||||
uint16_t idle_threshold; /*!< RMT RX idle threshold */
|
||||
}rmt_rx_config_t;
|
||||
@ -119,6 +119,16 @@ typedef struct {
|
||||
|
||||
typedef intr_handle_t rmt_isr_handle_t;
|
||||
|
||||
typedef void (*rmt_tx_end_fn_t)(rmt_channel_t channel, void *arg);
|
||||
|
||||
/**
|
||||
* @brief Structure encapsulating a RMT TX end callback
|
||||
*/
|
||||
typedef struct {
|
||||
rmt_tx_end_fn_t function; /*!< Function which is called on RMT TX end */
|
||||
void *arg; /*!< Optional argument passed to function */
|
||||
} rmt_tx_end_callback_t;
|
||||
|
||||
/**
|
||||
* @brief Set RMT clock divider, channel clock is divided from source clock.
|
||||
*
|
||||
@ -186,10 +196,12 @@ esp_err_t rmt_get_rx_idle_thresh(rmt_channel_t channel, uint16_t *thresh);
|
||||
* The 8 channels share a 512x32-bit RAM block which can be read and written
|
||||
* by the processor cores over the APB bus, as well as read by the transmitters
|
||||
* and written by the receivers.
|
||||
*
|
||||
* The RAM address range for channel n is start_addr_CHn to end_addr_CHn, which are defined by:
|
||||
* Memory block start address is RMT_CHANNEL_MEM(n) (in soc/rmt_reg.h),
|
||||
* that is, start_addr_chn = RMT base address + 0x800 + 64 ∗ 4 ∗ n, and
|
||||
* end_addr_chn = RMT base address + 0x800 + 64 ∗ 4 ∗ n + 64 ∗ 4 ∗ RMT_MEM_SIZE_CHn mod 512 ∗ 4
|
||||
*
|
||||
* @note
|
||||
* If memory block number of one channel is set to a value greater than 1, this channel will occupy the memory
|
||||
* block of the next channel.
|
||||
@ -233,10 +245,8 @@ esp_err_t rmt_get_mem_block_num(rmt_channel_t channel, uint8_t* rmt_mem_num);
|
||||
* @param low_level Low level duration of carrier.
|
||||
*
|
||||
* @param carrier_level Configure the way carrier wave is modulated for channel 0-7.
|
||||
*
|
||||
* 1'b1:transmit on low output level
|
||||
*
|
||||
* 1'b0:transmit on high output level
|
||||
* - 1'b1:transmit on low output level
|
||||
* - 1'b0:transmit on high output level
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
@ -364,10 +374,9 @@ esp_err_t rmt_get_memory_owner(rmt_channel_t channel, rmt_mem_owner_t* owner);
|
||||
*
|
||||
* @param channel RMT channel (0-7)
|
||||
*
|
||||
* @param loop_en To enable RMT transmitter loop sending mode.
|
||||
*
|
||||
* @param loop_en Enable RMT transmitter loop sending mode.
|
||||
* If set true, transmitter will continue sending from the first data
|
||||
* to the last data in channel0-7 again and again.
|
||||
* to the last data in channel 0-7 over and over again in a loop.
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
@ -409,7 +418,7 @@ esp_err_t rmt_set_rx_filter(rmt_channel_t channel, bool rx_filter_en, uint8_t th
|
||||
/**
|
||||
* @brief Set RMT source clock
|
||||
*
|
||||
* RMT module has two source clock:
|
||||
* RMT module has two clock sources:
|
||||
* 1. APB clock which is 80Mhz
|
||||
* 2. REF tick clock, which would be 1Mhz (not supported in this version).
|
||||
*
|
||||
@ -426,7 +435,7 @@ esp_err_t rmt_set_source_clk(rmt_channel_t channel, rmt_source_clk_t base_clk);
|
||||
/**
|
||||
* @brief Get RMT source clock
|
||||
*
|
||||
* RMT module has two source clock:
|
||||
* RMT module has two clock sources:
|
||||
* 1. APB clock which is 80Mhz
|
||||
* 2. REF tick clock, which would be 1Mhz (not supported in this version).
|
||||
*
|
||||
@ -526,7 +535,7 @@ esp_err_t rmt_set_tx_intr_en(rmt_channel_t channel, bool en);
|
||||
/**
|
||||
* @brief Set RMT TX threshold event interrupt enable
|
||||
*
|
||||
* Causes an interrupt when a threshold number of items have been transmitted.
|
||||
* An interrupt will be triggered when the number of transmitted items reaches the threshold value
|
||||
*
|
||||
* @param channel RMT channel (0 - 7)
|
||||
*
|
||||
@ -541,7 +550,7 @@ esp_err_t rmt_set_tx_intr_en(rmt_channel_t channel, bool en);
|
||||
esp_err_t rmt_set_tx_thr_intr_en(rmt_channel_t channel, bool en, uint16_t evt_thresh);
|
||||
|
||||
/**
|
||||
* @brief Set RMT pins
|
||||
* @brief Set RMT pin
|
||||
*
|
||||
* @param channel RMT channel (0 - 7)
|
||||
*
|
||||
@ -558,7 +567,7 @@ esp_err_t rmt_set_pin(rmt_channel_t channel, rmt_mode_t mode, gpio_num_t gpio_nu
|
||||
/**
|
||||
* @brief Configure RMT parameters
|
||||
*
|
||||
* @param rmt_param RMT parameter structor
|
||||
* @param rmt_param RMT parameter struct
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
@ -567,14 +576,15 @@ esp_err_t rmt_set_pin(rmt_channel_t channel, rmt_mode_t mode, gpio_num_t gpio_nu
|
||||
esp_err_t rmt_config(const rmt_config_t* rmt_param);
|
||||
|
||||
/**
|
||||
* @brief register RMT interrupt handler, the handler is an ISR.
|
||||
* @brief Register RMT interrupt handler, the handler is an ISR.
|
||||
*
|
||||
* The handler will be attached to the same CPU core that this function is running on.
|
||||
*
|
||||
* @note If you already called rmt_driver_install to use system RMT driver,
|
||||
* please do not register ISR handler again.
|
||||
*
|
||||
* @param fn Interrupt handler function.
|
||||
* @param arg Parameter for handler function
|
||||
* @param arg Parameter for the 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 If non-zero, a handle to later clean up the ISR gets stored here.
|
||||
@ -653,9 +663,9 @@ esp_err_t rmt_driver_uninstall(rmt_channel_t channel);
|
||||
*
|
||||
* @param item_num RMT data item number.
|
||||
*
|
||||
* @param wait_tx_done If set 1, it will block the task and wait for sending done.
|
||||
*
|
||||
* If set 0, it will not wait and return immediately.
|
||||
* @param wait_tx_done
|
||||
* - If set 1, it will block the task and wait for sending done.
|
||||
* - If set 0, it will not wait and return immediately.
|
||||
*
|
||||
* @note
|
||||
* This function will not copy data, instead, it will point to the original items,
|
||||
@ -677,24 +687,24 @@ 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
|
||||
* @param wait_time Maximum time in ticks to wait for transmission to be complete
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK RMT Tx done successfully
|
||||
* - ESP_ERR_TIMEOUT Crossed the 'wait_time' given
|
||||
* - ESP_ERR_TIMEOUT Exceeded the 'wait_time' given
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_FAIL Driver not installed
|
||||
*/
|
||||
esp_err_t rmt_wait_tx_done(rmt_channel_t channel, TickType_t wait_time);
|
||||
|
||||
/**
|
||||
* @brief Get ringbuffer from UART.
|
||||
* @brief Get ringbuffer from RMT.
|
||||
*
|
||||
* Users can get the RMT RX ringbuffer handler, and process the RX data.
|
||||
* Users can get the RMT RX ringbuffer handle, and process the RX data.
|
||||
*
|
||||
* @param channel RMT channel (0 - 7)
|
||||
*
|
||||
* @param buf_handle Pointer to buffer handler to accept RX ringbuffer handler.
|
||||
* @param buf_handle Pointer to buffer handle to accept RX ringbuffer handle.
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
@ -702,62 +712,22 @@ esp_err_t rmt_wait_tx_done(rmt_channel_t channel, TickType_t wait_time);
|
||||
*/
|
||||
esp_err_t rmt_get_ringbuf_handle(rmt_channel_t channel, RingbufHandle_t* buf_handle);
|
||||
|
||||
/***************************EXAMPLE**********************************
|
||||
/**
|
||||
* @brief Registers a callback that will be called when transmission ends.
|
||||
*
|
||||
* @note
|
||||
* You can also refer to example/09_rmt_nec_tx_rx to have more information about how to use RMT module.
|
||||
* Called by rmt_driver_isr_default in interrupt context.
|
||||
*
|
||||
* ----------------EXAMPLE OF RMT SETTING ---------------------
|
||||
* @code{c}
|
||||
* //1. enable RMT
|
||||
* //enable RMT module, or you can not set any register of it.
|
||||
* //this will be done in rmt_config API.
|
||||
* periph_module_enable(PERIPH_RMT_MODULE);
|
||||
* @endcode
|
||||
* @note Requires rmt_driver_install to install the default ISR handler.
|
||||
*
|
||||
* @code{c}
|
||||
* //2. set RMT transmitter
|
||||
* void rmt_tx_init()
|
||||
* {
|
||||
* rmt_config_t rmt_tx;
|
||||
* rmt_tx.channel = 0;
|
||||
* rmt_tx.gpio_num = 16;
|
||||
* rmt_tx.mem_block_num = 1;
|
||||
* rmt_tx.clk_div = 100;
|
||||
* rmt_tx.tx_config.loop_en = false;
|
||||
* rmt_tx.tx_config.carrier_duty_percent = 50;
|
||||
* rmt_tx.tx_config.carrier_freq_hz = 38000;
|
||||
* rmt_tx.tx_config.carrier_level = 1;
|
||||
* rmt_tx.tx_config.carrier_en = RMT_TX_CARRIER_EN;
|
||||
* rmt_tx.tx_config.idle_level = 0;
|
||||
* rmt_tx.tx_config.idle_output_en = true;
|
||||
* rmt_tx.rmt_mode = 0;
|
||||
* rmt_config(&rmt_tx);
|
||||
*
|
||||
* //install system RMT driver, disable rx ringbuffer for transmitter.
|
||||
* rmt_driver_install(rmt_tx.channel, 0, 0);
|
||||
* }
|
||||
*
|
||||
* @endcode
|
||||
* @code{c}
|
||||
* //3. set RMT receiver
|
||||
* void rmt_rx_init()
|
||||
* {
|
||||
* rmt_config_t rmt_rx;
|
||||
* rmt_rx.channel = 1;
|
||||
* rmt_rx.gpio_num = 19;
|
||||
* rmt_rx.clk_div = 100;
|
||||
* rmt_rx.mem_block_num = 1;
|
||||
* rmt_rx.rmt_mode = RMT_MODE_RX;
|
||||
* rmt_rx.rx_config.filter_en = true;
|
||||
* rmt_rx.rx_config.filter_ticks_thresh = 100;
|
||||
* rmt_rx.rx_config.idle_threshold = 0xffff;
|
||||
* rmt_config(&rmt_rx);
|
||||
*
|
||||
* //install system RMT driver.
|
||||
* rmt_driver_install(rmt_rx.channel, 1000, 0);
|
||||
* }
|
||||
* @param function Function to be called from the default interrupt handler or NULL.
|
||||
* @param arg Argument which will be provided to the callback when it is called.
|
||||
*
|
||||
* @return the previous callback settings (members will be set to NULL if there was none)
|
||||
*/
|
||||
rmt_tx_end_callback_t rmt_register_tx_end_callback(rmt_tx_end_fn_t function, void *arg);
|
||||
|
||||
|
||||
/*
|
||||
* ----------------EXAMPLE OF RMT INTERRUPT ------------------
|
||||
* @code{c}
|
||||
*
|
||||
@ -774,7 +744,7 @@ esp_err_t rmt_get_ringbuf_handle(rmt_channel_t channel, RingbufHandle_t* buf_han
|
||||
* //read RMT interrupt status.
|
||||
* uint32_t intr_st = RMT.int_st.val;
|
||||
*
|
||||
* //you will find which channels have triggered fade_end interrupt here,
|
||||
* //you will find which channels have triggered an interrupt here,
|
||||
* //then, you can post some event to RTOS queue to process the event.
|
||||
* //later we will add a queue in the driver code.
|
||||
*
|
||||
@ -788,8 +758,6 @@ esp_err_t rmt_get_ringbuf_handle(rmt_channel_t channel, RingbufHandle_t* buf_han
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -47,9 +47,9 @@ typedef struct {
|
||||
} rtc_gpio_desc_t;
|
||||
|
||||
typedef enum {
|
||||
RTC_GPIO_MODE_INPUT_ONLY , /*!< Pad output */
|
||||
RTC_GPIO_MODE_OUTPUT_ONLY, /*!< Pad input */
|
||||
RTC_GPIO_MODE_INPUT_OUTUT, /*!< Pad pull output + input */
|
||||
RTC_GPIO_MODE_INPUT_ONLY , /*!< Pad input */
|
||||
RTC_GPIO_MODE_OUTPUT_ONLY, /*!< Pad output */
|
||||
RTC_GPIO_MODE_INPUT_OUTPUT, /*!< Pad pull input + output */
|
||||
RTC_GPIO_MODE_DISABLED, /*!< Pad (output + input) disable */
|
||||
} rtc_gpio_mode_t;
|
||||
|
||||
|
@ -228,6 +228,17 @@ esp_err_t spi_device_get_trans_result(spi_device_handle_t handle, spi_transactio
|
||||
*/
|
||||
esp_err_t spi_device_transmit(spi_device_handle_t handle, spi_transaction_t *trans_desc);
|
||||
|
||||
/**
|
||||
* @brief Calculate the working frequency that is most close to desired frequency, and also the register value.
|
||||
*
|
||||
* @param fapb The frequency of apb clock, should be ``APB_CLK_FREQ``.
|
||||
* @param hz Desired working frequency
|
||||
* @param duty_cycle Duty cycle of the spi clock
|
||||
* @param reg_o Output of value to be set in clock register, or NULL if not needed.
|
||||
* @return Actual working frequency that most fit.
|
||||
*/
|
||||
int spi_cal_clock(int fapb, int hz, int duty_cycle, uint32_t* reg_o);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -37,13 +37,13 @@ extern "C" {
|
||||
*/
|
||||
|
||||
//Keep the LEVELx values as they are here; they match up with (1<<level)
|
||||
#define ESP_INTR_FLAG_LEVEL1 (1<<1) ///< Accept a Level 1 interrupt vector
|
||||
#define ESP_INTR_FLAG_LEVEL1 (1<<1) ///< Accept a Level 1 interrupt vector (lowest priority)
|
||||
#define ESP_INTR_FLAG_LEVEL2 (1<<2) ///< Accept a Level 2 interrupt vector
|
||||
#define ESP_INTR_FLAG_LEVEL3 (1<<3) ///< Accept a Level 3 interrupt vector
|
||||
#define ESP_INTR_FLAG_LEVEL4 (1<<4) ///< Accept a Level 4 interrupt vector
|
||||
#define ESP_INTR_FLAG_LEVEL5 (1<<5) ///< Accept a Level 5 interrupt vector
|
||||
#define ESP_INTR_FLAG_LEVEL6 (1<<6) ///< Accept a Level 6 interrupt vector
|
||||
#define ESP_INTR_FLAG_NMI (1<<7) ///< Accept a Level 7 interrupt vector
|
||||
#define ESP_INTR_FLAG_NMI (1<<7) ///< Accept a Level 7 interrupt vector (highest priority)
|
||||
#define ESP_INTR_FLAG_SHARED (1<<8) ///< Interrupt can be shared between ISRs
|
||||
#define ESP_INTR_FLAG_EDGE (1<<9) ///< Edge-triggered interrupt
|
||||
#define ESP_INTR_FLAG_IRAM (1<<10) ///< ISR can be called if cache is disabled
|
||||
@ -248,7 +248,7 @@ int esp_intr_get_intno(intr_handle_t handle);
|
||||
esp_err_t esp_intr_disable(intr_handle_t handle);
|
||||
|
||||
/**
|
||||
* @brief Ensable the interrupt associated with the handle
|
||||
* @brief Enable 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.
|
||||
@ -260,6 +260,19 @@ esp_err_t esp_intr_disable(intr_handle_t handle);
|
||||
*/
|
||||
esp_err_t esp_intr_enable(intr_handle_t handle);
|
||||
|
||||
/**
|
||||
* @brief Set the "in IRAM" status of the handler.
|
||||
*
|
||||
* @note Does not work on shared interrupts.
|
||||
*
|
||||
* @param handle The handle, as obtained by esp_intr_alloc or esp_intr_alloc_intrstatus
|
||||
* @param is_in_iram Whether the handler associated with this handle resides in IRAM.
|
||||
* Handlers residing in IRAM can be called when cache is disabled.
|
||||
*
|
||||
* @return ESP_ERR_INVALID_ARG if the combination of arguments is invalid.
|
||||
* ESP_OK otherwise
|
||||
*/
|
||||
esp_err_t esp_intr_set_in_iram(intr_handle_t handle, bool is_in_iram);
|
||||
|
||||
/**
|
||||
* @brief Disable interrupts that aren't specifically marked as running from IRAM
|
||||
|
@ -20,11 +20,11 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @cond */
|
||||
typedef void (*esp_ipc_func_t)(void* arg);
|
||||
|
||||
/**
|
||||
* @brief Inter-processor call APIs
|
||||
/** @endcond */
|
||||
/*
|
||||
* Inter-processor call APIs
|
||||
*
|
||||
* FreeRTOS provides several APIs which can be used to communicate between
|
||||
* different tasks, including tasks running on different CPUs.
|
||||
@ -34,8 +34,9 @@ typedef void (*esp_ipc_func_t)(void* arg);
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initialize inter-processor call module.
|
||||
/*
|
||||
* Initialize inter-processor call module. This function is called automatically
|
||||
* on CPU start and should not be called from the application.
|
||||
*
|
||||
* This function start two tasks, one on each CPU. These tasks are started
|
||||
* with high priority. These tasks are normally inactive, waiting until one of
|
||||
@ -43,51 +44,59 @@ typedef void (*esp_ipc_func_t)(void* arg);
|
||||
* woken up to execute the callback provided to esp_ipc_call_nonblocking or
|
||||
* esp_ipc_call_blocking.
|
||||
*/
|
||||
/** @cond */
|
||||
void esp_ipc_init();
|
||||
|
||||
/** @endcond */
|
||||
|
||||
/**
|
||||
* @brief Execute function on the given CPU
|
||||
* @brief Execute a function on the given CPU
|
||||
*
|
||||
* This will wake a high-priority task on CPU indicated by cpu_id argument,
|
||||
* and run func(arg) in the context of that task.
|
||||
* This function returns as soon as the high-priority task is woken up.
|
||||
* If another IPC call is already being executed, this function will also wait
|
||||
* for it to complete.
|
||||
* Run a given function on a particular CPU. The given function must accept a
|
||||
* void* argument and return void. The given function is run in the context of
|
||||
* the IPC task of the CPU specified by the cpu_id parameter. The calling task
|
||||
* will be blocked until the IPC task begins executing the given function. If
|
||||
* another IPC call is ongoing, the calling task will block until the other IPC
|
||||
* call completes. The stack size allocated for the IPC task can be configured
|
||||
* in the "Inter-Processor Call (IPC) task stack size" setting in menuconfig.
|
||||
* Increase this setting if the given function requires more stack than default.
|
||||
*
|
||||
* In single-core mode, returns ESP_ERR_INVALID_ARG for cpu_id 1.
|
||||
* @note In single-core mode, returns ESP_ERR_INVALID_ARG for cpu_id 1.
|
||||
*
|
||||
* For complex functions, you may need to increase the stack size of the "IPC task"
|
||||
* which runs the function must be sufficient. See the "Inter-Processor Call (IPC)
|
||||
* task stack size" setting in menuconfig.
|
||||
* @param[in] cpu_id CPU where the given function should be executed (0 or 1)
|
||||
* @param[in] func Pointer to a function of type void func(void* arg) to be executed
|
||||
* @param[in] arg Arbitrary argument of type void* to be passed into the function
|
||||
*
|
||||
* @param cpu_id CPU where function should be executed (0 or 1)
|
||||
* @param func pointer to a function which should be executed
|
||||
* @param arg arbitrary argument to be passed into function
|
||||
*
|
||||
* @return ESP_ERR_INVALID_ARG if cpu_id is invalid
|
||||
* ESP_ERR_INVALID_STATE if FreeRTOS scheduler is not running
|
||||
* ESP_OK otherwise
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if cpu_id is invalid
|
||||
* - ESP_ERR_INVALID_STATE if the FreeRTOS scheduler is not running
|
||||
* - ESP_OK otherwise
|
||||
*/
|
||||
esp_err_t esp_ipc_call(uint32_t cpu_id, esp_ipc_func_t func, void* arg);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Execute function on the given CPU and wait for it to finish
|
||||
* @brief Execute a function on the given CPU and blocks until it completes
|
||||
*
|
||||
* This will wake a high-priority task on CPU indicated by cpu_id argument,
|
||||
* and run func(arg) in the context of that task.
|
||||
* This function waits for func to return.
|
||||
* Run a given function on a particular CPU. The given function must accept a
|
||||
* void* argument and return void. The given function is run in the context of
|
||||
* the IPC task of the CPU specified by the cpu_id parameter. The calling task
|
||||
* will be blocked until the IPC task completes execution of the given function.
|
||||
* If another IPC call is ongoing, the calling task will block until the other
|
||||
* IPC call completes. The stack size allocated for the IPC task can be
|
||||
* configured in the "Inter-Processor Call (IPC) task stack size" setting in
|
||||
* menuconfig. Increase this setting if the given function requires more stack
|
||||
* than default.
|
||||
*
|
||||
* In single-core mode, returns ESP_ERR_INVALID_ARG for cpu_id 1.
|
||||
* @note In single-core mode, returns ESP_ERR_INVALID_ARG for cpu_id 1.
|
||||
*
|
||||
* @param cpu_id CPU where function should be executed (0 or 1)
|
||||
* @param func pointer to a function which should be executed
|
||||
* @param arg arbitrary argument to be passed into function
|
||||
* @param[in] cpu_id CPU where the given function should be executed (0 or 1)
|
||||
* @param[in] func Pointer to a function of type void func(void* arg) to be executed
|
||||
* @param[in] arg Arbitrary argument of type void* to be passed into the function
|
||||
*
|
||||
* @return ESP_ERR_INVALID_ARG if cpu_id is invalid
|
||||
* ESP_ERR_INVALID_STATE if FreeRTOS scheduler is not running
|
||||
* ESP_OK otherwise
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if cpu_id is invalid
|
||||
* - ESP_ERR_INVALID_STATE if the FreeRTOS scheduler is not running
|
||||
* - ESP_OK otherwise
|
||||
*/
|
||||
esp_err_t esp_ipc_call_blocking(uint32_t cpu_id, esp_ipc_func_t func, void* arg);
|
||||
|
||||
|
@ -29,11 +29,11 @@
|
||||
* use RTOS notification mechanisms (queues, semaphores, event groups, etc.) to
|
||||
* pass information to other tasks.
|
||||
*
|
||||
* <to be implemented> It should be possible to request the callback to be called
|
||||
* To be implemented: it should be possible to request the callback to be called
|
||||
* directly from the ISR. This reduces the latency, but has potential impact on
|
||||
* all other callbacks which need to be dispatched. This option should only be
|
||||
* used for simple callback functions, which do not take longer than a few
|
||||
* microseconds to run. </to be implemented>
|
||||
* microseconds to run.
|
||||
*
|
||||
* Implementation note: on the ESP32, esp_timer APIs use the "legacy" FRC2
|
||||
* timer. Timer callbacks are called from a task running on the PRO CPU.
|
||||
|
@ -250,6 +250,27 @@ static inline esp_err_t esp_eth_smi_wait_set(uint32_t reg_num, uint16_t value_ma
|
||||
*/
|
||||
void esp_eth_free_rx_buf(void *buf);
|
||||
|
||||
/**
|
||||
* @brief Get mac of ethernet interface.
|
||||
*
|
||||
* @param[out] mac: store mac of the interface.
|
||||
*
|
||||
*/
|
||||
void esp_eth_get_mac(uint8_t mac[6]);
|
||||
|
||||
/**
|
||||
* @brief Set mac of ethernet interface.
|
||||
*
|
||||
* @note user can call this function after emac_init,and the new mac address will be enabled after emac_enable.
|
||||
*
|
||||
* @param[in] mac: the Mac address.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - ESP_ERR_INVALID_MAC: invalid mac address
|
||||
*/
|
||||
esp_err_t esp_eth_set_mac(const uint8_t mac[6]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -974,18 +974,73 @@ typedef struct xSTATIC_QUEUE
|
||||
uint8_t ucDummy9;
|
||||
#endif
|
||||
|
||||
struct {
|
||||
volatile uint32_t ucDummy10;
|
||||
uint32_t ucDummy11;
|
||||
#ifdef CONFIG_FREERTOS_PORTMUX_DEBUG
|
||||
void *pvDummy8;
|
||||
UBaseType_t uxDummy12;
|
||||
#endif
|
||||
} sDummy1;
|
||||
portMUX_TYPE muxDummy; //Mutex required due to SMP
|
||||
|
||||
} StaticQueue_t;
|
||||
typedef StaticQueue_t StaticSemaphore_t;
|
||||
|
||||
/*
|
||||
* In line with software engineering best practice, especially when supplying a
|
||||
* library that is likely to change in future versions, FreeRTOS implements a
|
||||
* strict data hiding policy. This means the event group structure used
|
||||
* internally by FreeRTOS is not accessible to application code. However, if
|
||||
* the application writer wants to statically allocate the memory required to
|
||||
* create an event group then the size of the event group object needs to be
|
||||
* know. The StaticEventGroup_t structure below is provided for this purpose.
|
||||
* Its sizes and alignment requirements are guaranteed to match those of the
|
||||
* genuine structure, no matter which architecture is being used, and no matter
|
||||
* how the values in FreeRTOSConfig.h are set. Its contents are somewhat
|
||||
* obfuscated in the hope users will recognise that it would be unwise to make
|
||||
* direct use of the structure members.
|
||||
*/
|
||||
typedef struct xSTATIC_EVENT_GROUP
|
||||
{
|
||||
TickType_t xDummy1;
|
||||
StaticList_t xDummy2;
|
||||
|
||||
#if( configUSE_TRACE_FACILITY == 1 )
|
||||
UBaseType_t uxDummy3;
|
||||
#endif
|
||||
|
||||
#if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
|
||||
uint8_t ucDummy4;
|
||||
#endif
|
||||
|
||||
portMUX_TYPE muxDummy; //Mutex required due to SMP
|
||||
|
||||
} StaticEventGroup_t;
|
||||
|
||||
/*
|
||||
* In line with software engineering best practice, especially when supplying a
|
||||
* library that is likely to change in future versions, FreeRTOS implements a
|
||||
* strict data hiding policy. This means the software timer structure used
|
||||
* internally by FreeRTOS is not accessible to application code. However, if
|
||||
* the application writer wants to statically allocate the memory required to
|
||||
* create a software timer then the size of the queue object needs to be know.
|
||||
* The StaticTimer_t structure below is provided for this purpose. Its sizes
|
||||
* and alignment requirements are guaranteed to match those of the genuine
|
||||
* structure, no matter which architecture is being used, and no matter how the
|
||||
* values in FreeRTOSConfig.h are set. Its contents are somewhat obfuscated in
|
||||
* the hope users will recognise that it would be unwise to make direct use of
|
||||
* the structure members.
|
||||
*/
|
||||
typedef struct xSTATIC_TIMER
|
||||
{
|
||||
void *pvDummy1;
|
||||
StaticListItem_t xDummy2;
|
||||
TickType_t xDummy3;
|
||||
UBaseType_t uxDummy4;
|
||||
void *pvDummy5[ 2 ];
|
||||
#if( configUSE_TRACE_FACILITY == 1 )
|
||||
UBaseType_t uxDummy6;
|
||||
#endif
|
||||
|
||||
#if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
|
||||
uint8_t ucDummy7;
|
||||
#endif
|
||||
|
||||
} StaticTimer_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -104,7 +104,6 @@ extern "C" {
|
||||
* used to create a synchronisation point between multiple tasks (a
|
||||
* 'rendezvous').
|
||||
*
|
||||
* \defgroup EventGroup
|
||||
*/
|
||||
|
||||
|
||||
@ -116,7 +115,6 @@ extern "C" {
|
||||
* xEventGroupCreate() returns an EventGroupHandle_t variable that can then
|
||||
* be used as a parameter to other event group functions.
|
||||
*
|
||||
* \defgroup EventGroupHandle_t EventGroupHandle_t
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
typedef void * EventGroupHandle_t;
|
||||
@ -126,18 +124,22 @@ typedef void * EventGroupHandle_t;
|
||||
* number of bits it holds is set by configUSE_16_BIT_TICKS (16 bits if set to 1,
|
||||
* 32 bits if set to 0.
|
||||
*
|
||||
* \defgroup EventBits_t EventBits_t
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
typedef TickType_t EventBits_t;
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
*<pre>
|
||||
EventGroupHandle_t xEventGroupCreate( void );
|
||||
</pre>
|
||||
* Create a new event group.
|
||||
*
|
||||
* Create a new event group. This function cannot be called from an interrupt.
|
||||
* Internally, within the FreeRTOS implementation, event groups use a [small]
|
||||
* block of memory, in which the event group's structure is stored. If an event
|
||||
* groups is created using xEventGroupCreate() then the required memory is
|
||||
* automatically dynamically allocated inside the xEventGroupCreate() function.
|
||||
* (see http://www.freertos.org/a00111.html). If an event group is created
|
||||
* using xEventGropuCreateStatic() then the application writer must instead
|
||||
* provide the memory that will get used by the event group.
|
||||
* xEventGroupCreateStatic() therefore allows an event group to be created
|
||||
* without using any dynamic memory allocation.
|
||||
*
|
||||
* Although event groups are not related to ticks, for internal implementation
|
||||
* reasons the number of bits available for use in an event group is dependent
|
||||
@ -152,39 +154,79 @@ typedef TickType_t EventBits_t;
|
||||
* event group then NULL is returned. See http://www.freertos.org/a00111.html
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
// Declare a variable to hold the created event group.
|
||||
EventGroupHandle_t xCreatedEventGroup;
|
||||
|
||||
// Attempt to create the event group.
|
||||
xCreatedEventGroup = xEventGroupCreate();
|
||||
|
||||
// Was the event group created successfully?
|
||||
if( xCreatedEventGroup == NULL )
|
||||
{
|
||||
// The event group was not created because there was insufficient
|
||||
// FreeRTOS heap available.
|
||||
}
|
||||
else
|
||||
{
|
||||
// The event group was created.
|
||||
}
|
||||
</pre>
|
||||
* \defgroup xEventGroupCreate xEventGroupCreate
|
||||
* @code{c}
|
||||
* // Declare a variable to hold the created event group.
|
||||
* EventGroupHandle_t xCreatedEventGroup;
|
||||
*
|
||||
* // Attempt to create the event group.
|
||||
* xCreatedEventGroup = xEventGroupCreate();
|
||||
*
|
||||
* // Was the event group created successfully?
|
||||
* if( xCreatedEventGroup == NULL )
|
||||
* {
|
||||
* // The event group was not created because there was insufficient
|
||||
* // FreeRTOS heap available.
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* // The event group was created.
|
||||
* }
|
||||
* @endcode
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
|
||||
EventGroupHandle_t xEventGroupCreate( void ) PRIVILEGED_FUNCTION;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
*<pre>
|
||||
EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup,
|
||||
const EventBits_t uxBitsToWaitFor,
|
||||
const BaseType_t xClearOnExit,
|
||||
const BaseType_t xWaitForAllBits,
|
||||
const TickType_t xTicksToWait );
|
||||
</pre>
|
||||
* Create a new event group.
|
||||
*
|
||||
* Internally, within the FreeRTOS implementation, event groups use a [small]
|
||||
* block of memory, in which the event group's structure is stored. If an event
|
||||
* groups is created using xEventGropuCreate() then the required memory is
|
||||
* automatically dynamically allocated inside the xEventGroupCreate() function.
|
||||
* (see http://www.freertos.org/a00111.html). If an event group is created
|
||||
* using xEventGropuCreateStatic() then the application writer must instead
|
||||
* provide the memory that will get used by the event group.
|
||||
* xEventGroupCreateStatic() therefore allows an event group to be created
|
||||
* without using any dynamic memory allocation.
|
||||
*
|
||||
* Although event groups are not related to ticks, for internal implementation
|
||||
* reasons the number of bits available for use in an event group is dependent
|
||||
* on the configUSE_16_BIT_TICKS setting in FreeRTOSConfig.h. If
|
||||
* configUSE_16_BIT_TICKS is 1 then each event group contains 8 usable bits (bit
|
||||
* 0 to bit 7). If configUSE_16_BIT_TICKS is set to 0 then each event group has
|
||||
* 24 usable bits (bit 0 to bit 23). The EventBits_t type is used to store
|
||||
* event bits within an event group.
|
||||
*
|
||||
* @param pxEventGroupBuffer pxEventGroupBuffer must point to a variable of type
|
||||
* StaticEventGroup_t, which will be then be used to hold the event group's data
|
||||
* structures, removing the need for the memory to be allocated dynamically.
|
||||
*
|
||||
* @return If the event group was created then a handle to the event group is
|
||||
* returned. If pxEventGroupBuffer was NULL then NULL is returned.
|
||||
*
|
||||
* Example usage:
|
||||
* @code{c}
|
||||
* // StaticEventGroup_t is a publicly accessible structure that has the same
|
||||
* // size and alignment requirements as the real event group structure. It is
|
||||
* // provided as a mechanism for applications to know the size of the event
|
||||
* // group (which is dependent on the architecture and configuration file
|
||||
* // settings) without breaking the strict data hiding policy by exposing the
|
||||
* // real event group internals. This StaticEventGroup_t variable is passed
|
||||
* // into the xSemaphoreCreateEventGroupStatic() function and is used to store
|
||||
* // the event group's data structures
|
||||
* StaticEventGroup_t xEventGroupBuffer;
|
||||
*
|
||||
* // Create the event group without dynamically allocating any memory.
|
||||
* xEventGroup = xEventGroupCreateStatic( &xEventGroupBuffer );
|
||||
* @endcode
|
||||
*/
|
||||
#if( configSUPPORT_STATIC_ALLOCATION == 1 )
|
||||
EventGroupHandle_t xEventGroupCreateStatic( StaticEventGroup_t *pxEventGroupBuffer ) PRIVILEGED_FUNCTION;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* [Potentially] block to wait for one or more bits to be set within a
|
||||
* previously created event group.
|
||||
*
|
||||
@ -227,54 +269,48 @@ EventGroupHandle_t xEventGroupCreate( void ) PRIVILEGED_FUNCTION;
|
||||
* pdTRUE.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
#define BIT_0 ( 1 << 0 )
|
||||
#define BIT_4 ( 1 << 4 )
|
||||
|
||||
void aFunction( EventGroupHandle_t xEventGroup )
|
||||
{
|
||||
EventBits_t uxBits;
|
||||
const TickType_t xTicksToWait = 100 / portTICK_PERIOD_MS;
|
||||
|
||||
// Wait a maximum of 100ms for either bit 0 or bit 4 to be set within
|
||||
// the event group. Clear the bits before exiting.
|
||||
uxBits = xEventGroupWaitBits(
|
||||
xEventGroup, // The event group being tested.
|
||||
BIT_0 | BIT_4, // The bits within the event group to wait for.
|
||||
pdTRUE, // BIT_0 and BIT_4 should be cleared before returning.
|
||||
pdFALSE, // Don't wait for both bits, either bit will do.
|
||||
xTicksToWait ); // Wait a maximum of 100ms for either bit to be set.
|
||||
|
||||
if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) )
|
||||
{
|
||||
// xEventGroupWaitBits() returned because both bits were set.
|
||||
}
|
||||
else if( ( uxBits & BIT_0 ) != 0 )
|
||||
{
|
||||
// xEventGroupWaitBits() returned because just BIT_0 was set.
|
||||
}
|
||||
else if( ( uxBits & BIT_4 ) != 0 )
|
||||
{
|
||||
// xEventGroupWaitBits() returned because just BIT_4 was set.
|
||||
}
|
||||
else
|
||||
{
|
||||
// xEventGroupWaitBits() returned because xTicksToWait ticks passed
|
||||
// without either BIT_0 or BIT_4 becoming set.
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
* \defgroup xEventGroupWaitBits xEventGroupWaitBits
|
||||
* @code{c}
|
||||
* #define BIT_0 ( 1 << 0 )
|
||||
* #define BIT_4 ( 1 << 4 )
|
||||
*
|
||||
* void aFunction( EventGroupHandle_t xEventGroup )
|
||||
* {
|
||||
* EventBits_t uxBits;
|
||||
* const TickType_t xTicksToWait = 100 / portTICK_PERIOD_MS;
|
||||
*
|
||||
* // Wait a maximum of 100ms for either bit 0 or bit 4 to be set within
|
||||
* // the event group. Clear the bits before exiting.
|
||||
* uxBits = xEventGroupWaitBits(
|
||||
* xEventGroup, // The event group being tested.
|
||||
* BIT_0 | BIT_4, // The bits within the event group to wait for.
|
||||
* pdTRUE, // BIT_0 and BIT_4 should be cleared before returning.
|
||||
* pdFALSE, // Don't wait for both bits, either bit will do.
|
||||
* xTicksToWait ); // Wait a maximum of 100ms for either bit to be set.
|
||||
*
|
||||
* if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) )
|
||||
* {
|
||||
* // xEventGroupWaitBits() returned because both bits were set.
|
||||
* }
|
||||
* else if( ( uxBits & BIT_0 ) != 0 )
|
||||
* {
|
||||
* // xEventGroupWaitBits() returned because just BIT_0 was set.
|
||||
* }
|
||||
* else if( ( uxBits & BIT_4 ) != 0 )
|
||||
* {
|
||||
* // xEventGroupWaitBits() returned because just BIT_4 was set.
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* // xEventGroupWaitBits() returned because xTicksToWait ticks passed
|
||||
* // without either BIT_0 or BIT_4 becoming set.
|
||||
* }
|
||||
* }
|
||||
* @endcode{c}
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToWaitFor, const BaseType_t xClearOnExit, const BaseType_t xWaitForAllBits, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
*<pre>
|
||||
EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear );
|
||||
</pre>
|
||||
*
|
||||
* Clear bits within an event group. This function cannot be called from an
|
||||
* interrupt.
|
||||
*
|
||||
@ -287,51 +323,45 @@ EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup, const EventBits
|
||||
* @return The value of the event group before the specified bits were cleared.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
#define BIT_0 ( 1 << 0 )
|
||||
#define BIT_4 ( 1 << 4 )
|
||||
|
||||
void aFunction( EventGroupHandle_t xEventGroup )
|
||||
{
|
||||
EventBits_t uxBits;
|
||||
|
||||
// Clear bit 0 and bit 4 in xEventGroup.
|
||||
uxBits = xEventGroupClearBits(
|
||||
xEventGroup, // The event group being updated.
|
||||
BIT_0 | BIT_4 );// The bits being cleared.
|
||||
|
||||
if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) )
|
||||
{
|
||||
// Both bit 0 and bit 4 were set before xEventGroupClearBits() was
|
||||
// called. Both will now be clear (not set).
|
||||
}
|
||||
else if( ( uxBits & BIT_0 ) != 0 )
|
||||
{
|
||||
// Bit 0 was set before xEventGroupClearBits() was called. It will
|
||||
// now be clear.
|
||||
}
|
||||
else if( ( uxBits & BIT_4 ) != 0 )
|
||||
{
|
||||
// Bit 4 was set before xEventGroupClearBits() was called. It will
|
||||
// now be clear.
|
||||
}
|
||||
else
|
||||
{
|
||||
// Neither bit 0 nor bit 4 were set in the first place.
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
* \defgroup xEventGroupClearBits xEventGroupClearBits
|
||||
* @code{c}
|
||||
* #define BIT_0 ( 1 << 0 )
|
||||
* #define BIT_4 ( 1 << 4 )
|
||||
*
|
||||
* void aFunction( EventGroupHandle_t xEventGroup )
|
||||
* {
|
||||
* EventBits_t uxBits;
|
||||
*
|
||||
* // Clear bit 0 and bit 4 in xEventGroup.
|
||||
* uxBits = xEventGroupClearBits(
|
||||
* xEventGroup, // The event group being updated.
|
||||
* BIT_0 | BIT_4 );// The bits being cleared.
|
||||
*
|
||||
* if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) )
|
||||
* {
|
||||
* // Both bit 0 and bit 4 were set before xEventGroupClearBits() was
|
||||
* // called. Both will now be clear (not set).
|
||||
* }
|
||||
* else if( ( uxBits & BIT_0 ) != 0 )
|
||||
* {
|
||||
* // Bit 0 was set before xEventGroupClearBits() was called. It will
|
||||
* // now be clear.
|
||||
* }
|
||||
* else if( ( uxBits & BIT_4 ) != 0 )
|
||||
* {
|
||||
* // Bit 4 was set before xEventGroupClearBits() was called. It will
|
||||
* // now be clear.
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* // Neither bit 0 nor bit 4 were set in the first place.
|
||||
* }
|
||||
* }
|
||||
* @endcode
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
*<pre>
|
||||
BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet );
|
||||
</pre>
|
||||
*
|
||||
* A version of xEventGroupClearBits() that can be called from an interrupt.
|
||||
*
|
||||
* Setting bits in an event group is not a deterministic operation because there
|
||||
@ -355,28 +385,27 @@ EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBit
|
||||
* if the timer service queue was full.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
#define BIT_0 ( 1 << 0 )
|
||||
#define BIT_4 ( 1 << 4 )
|
||||
|
||||
// An event group which it is assumed has already been created by a call to
|
||||
// xEventGroupCreate().
|
||||
EventGroupHandle_t xEventGroup;
|
||||
|
||||
void anInterruptHandler( void )
|
||||
{
|
||||
// Clear bit 0 and bit 4 in xEventGroup.
|
||||
xResult = xEventGroupClearBitsFromISR(
|
||||
xEventGroup, // The event group being updated.
|
||||
BIT_0 | BIT_4 ); // The bits being set.
|
||||
|
||||
if( xResult == pdPASS )
|
||||
{
|
||||
// The message was posted successfully.
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
* \defgroup xEventGroupSetBitsFromISR xEventGroupSetBitsFromISR
|
||||
* @code{c}
|
||||
* #define BIT_0 ( 1 << 0 )
|
||||
* #define BIT_4 ( 1 << 4 )
|
||||
*
|
||||
* // An event group which it is assumed has already been created by a call to
|
||||
* // xEventGroupCreate().
|
||||
* EventGroupHandle_t xEventGroup;
|
||||
*
|
||||
* void anInterruptHandler( void )
|
||||
* {
|
||||
* // Clear bit 0 and bit 4 in xEventGroup.
|
||||
* xResult = xEventGroupClearBitsFromISR(
|
||||
* xEventGroup, // The event group being updated.
|
||||
* BIT_0 | BIT_4 ); // The bits being set.
|
||||
*
|
||||
* if( xResult == pdPASS )
|
||||
* {
|
||||
* // The message was posted successfully.
|
||||
* }
|
||||
* }
|
||||
* @endcode
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
#if( configUSE_TRACE_FACILITY == 1 )
|
||||
@ -386,11 +415,6 @@ EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBit
|
||||
#endif
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
*<pre>
|
||||
EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet );
|
||||
</pre>
|
||||
*
|
||||
* Set bits within an event group.
|
||||
* This function cannot be called from an interrupt. xEventGroupSetBitsFromISR()
|
||||
* is a version that can be called from an interrupt.
|
||||
@ -415,56 +439,50 @@ EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBit
|
||||
* event group value before the call to xEventGroupSetBits() returns.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
#define BIT_0 ( 1 << 0 )
|
||||
#define BIT_4 ( 1 << 4 )
|
||||
|
||||
void aFunction( EventGroupHandle_t xEventGroup )
|
||||
{
|
||||
EventBits_t uxBits;
|
||||
|
||||
// Set bit 0 and bit 4 in xEventGroup.
|
||||
uxBits = xEventGroupSetBits(
|
||||
xEventGroup, // The event group being updated.
|
||||
BIT_0 | BIT_4 );// The bits being set.
|
||||
|
||||
if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) )
|
||||
{
|
||||
// Both bit 0 and bit 4 remained set when the function returned.
|
||||
}
|
||||
else if( ( uxBits & BIT_0 ) != 0 )
|
||||
{
|
||||
// Bit 0 remained set when the function returned, but bit 4 was
|
||||
// cleared. It might be that bit 4 was cleared automatically as a
|
||||
// task that was waiting for bit 4 was removed from the Blocked
|
||||
// state.
|
||||
}
|
||||
else if( ( uxBits & BIT_4 ) != 0 )
|
||||
{
|
||||
// Bit 4 remained set when the function returned, but bit 0 was
|
||||
// cleared. It might be that bit 0 was cleared automatically as a
|
||||
// task that was waiting for bit 0 was removed from the Blocked
|
||||
// state.
|
||||
}
|
||||
else
|
||||
{
|
||||
// Neither bit 0 nor bit 4 remained set. It might be that a task
|
||||
// was waiting for both of the bits to be set, and the bits were
|
||||
// cleared as the task left the Blocked state.
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
* \defgroup xEventGroupSetBits xEventGroupSetBits
|
||||
* @code{c}
|
||||
* #define BIT_0 ( 1 << 0 )
|
||||
* #define BIT_4 ( 1 << 4 )
|
||||
*
|
||||
* void aFunction( EventGroupHandle_t xEventGroup )
|
||||
* {
|
||||
* EventBits_t uxBits;
|
||||
*
|
||||
* // Set bit 0 and bit 4 in xEventGroup.
|
||||
* uxBits = xEventGroupSetBits(
|
||||
* xEventGroup, // The event group being updated.
|
||||
* BIT_0 | BIT_4 );// The bits being set.
|
||||
*
|
||||
* if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) )
|
||||
* {
|
||||
* // Both bit 0 and bit 4 remained set when the function returned.
|
||||
* }
|
||||
* else if( ( uxBits & BIT_0 ) != 0 )
|
||||
* {
|
||||
* // Bit 0 remained set when the function returned, but bit 4 was
|
||||
* // cleared. It might be that bit 4 was cleared automatically as a
|
||||
* // task that was waiting for bit 4 was removed from the Blocked
|
||||
* // state.
|
||||
* }
|
||||
* else if( ( uxBits & BIT_4 ) != 0 )
|
||||
* {
|
||||
* // Bit 4 remained set when the function returned, but bit 0 was
|
||||
* // cleared. It might be that bit 0 was cleared automatically as a
|
||||
* // task that was waiting for bit 0 was removed from the Blocked
|
||||
* // state.
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* // Neither bit 0 nor bit 4 remained set. It might be that a task
|
||||
* // was waiting for both of the bits to be set, and the bits were
|
||||
* // cleared as the task left the Blocked state.
|
||||
* }
|
||||
* }
|
||||
* @endcode{c}
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
*<pre>
|
||||
BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken );
|
||||
</pre>
|
||||
*
|
||||
* A version of xEventGroupSetBits() that can be called from an interrupt.
|
||||
*
|
||||
* Setting bits in an event group is not a deterministic operation because there
|
||||
@ -496,39 +514,38 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_
|
||||
* if the timer service queue was full.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
#define BIT_0 ( 1 << 0 )
|
||||
#define BIT_4 ( 1 << 4 )
|
||||
|
||||
// An event group which it is assumed has already been created by a call to
|
||||
// xEventGroupCreate().
|
||||
EventGroupHandle_t xEventGroup;
|
||||
|
||||
void anInterruptHandler( void )
|
||||
{
|
||||
BaseType_t xHigherPriorityTaskWoken, xResult;
|
||||
|
||||
// xHigherPriorityTaskWoken must be initialised to pdFALSE.
|
||||
xHigherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
// Set bit 0 and bit 4 in xEventGroup.
|
||||
xResult = xEventGroupSetBitsFromISR(
|
||||
xEventGroup, // The event group being updated.
|
||||
BIT_0 | BIT_4 // The bits being set.
|
||||
&xHigherPriorityTaskWoken );
|
||||
|
||||
// Was the message posted successfully?
|
||||
if( xResult == pdPASS )
|
||||
{
|
||||
// If xHigherPriorityTaskWoken is now set to pdTRUE then a context
|
||||
// switch should be requested. The macro used is port specific and
|
||||
// will be either portYIELD_FROM_ISR() or portEND_SWITCHING_ISR() -
|
||||
// refer to the documentation page for the port being used.
|
||||
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
* \defgroup xEventGroupSetBitsFromISR xEventGroupSetBitsFromISR
|
||||
* @code{c}
|
||||
* #define BIT_0 ( 1 << 0 )
|
||||
* #define BIT_4 ( 1 << 4 )
|
||||
*
|
||||
* // An event group which it is assumed has already been created by a call to
|
||||
* // xEventGroupCreate().
|
||||
* EventGroupHandle_t xEventGroup;
|
||||
*
|
||||
* void anInterruptHandler( void )
|
||||
* {
|
||||
* BaseType_t xHigherPriorityTaskWoken, xResult;
|
||||
*
|
||||
* // xHigherPriorityTaskWoken must be initialised to pdFALSE.
|
||||
* xHigherPriorityTaskWoken = pdFALSE;
|
||||
*
|
||||
* // Set bit 0 and bit 4 in xEventGroup.
|
||||
* xResult = xEventGroupSetBitsFromISR(
|
||||
* xEventGroup, // The event group being updated.
|
||||
* BIT_0 | BIT_4 // The bits being set.
|
||||
* &xHigherPriorityTaskWoken );
|
||||
*
|
||||
* // Was the message posted successfully?
|
||||
* if( xResult == pdPASS )
|
||||
* {
|
||||
* // If xHigherPriorityTaskWoken is now set to pdTRUE then a context
|
||||
* // switch should be requested. The macro used is port specific and
|
||||
* // will be either portYIELD_FROM_ISR() or portEND_SWITCHING_ISR() -
|
||||
* // refer to the documentation page for the port being used.
|
||||
* portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
|
||||
* }
|
||||
* }
|
||||
* @endcode
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
#if( configUSE_TRACE_FACILITY == 1 )
|
||||
@ -538,14 +555,6 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_
|
||||
#endif
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
*<pre>
|
||||
EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup,
|
||||
const EventBits_t uxBitsToSet,
|
||||
const EventBits_t uxBitsToWaitFor,
|
||||
TickType_t xTicksToWait );
|
||||
</pre>
|
||||
*
|
||||
* Atomically set bits within an event group, then wait for a combination of
|
||||
* bits to be set within the same event group. This functionality is typically
|
||||
* used to synchronise multiple tasks, where each task has to wait for the other
|
||||
@ -583,93 +592,87 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_
|
||||
* automatically cleared.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
// Bits used by the three tasks.
|
||||
#define TASK_0_BIT ( 1 << 0 )
|
||||
#define TASK_1_BIT ( 1 << 1 )
|
||||
#define TASK_2_BIT ( 1 << 2 )
|
||||
|
||||
#define ALL_SYNC_BITS ( TASK_0_BIT | TASK_1_BIT | TASK_2_BIT )
|
||||
|
||||
// Use an event group to synchronise three tasks. It is assumed this event
|
||||
// group has already been created elsewhere.
|
||||
EventGroupHandle_t xEventBits;
|
||||
|
||||
void vTask0( void *pvParameters )
|
||||
{
|
||||
EventBits_t uxReturn;
|
||||
TickType_t xTicksToWait = 100 / portTICK_PERIOD_MS;
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
// Perform task functionality here.
|
||||
|
||||
// Set bit 0 in the event flag to note this task has reached the
|
||||
// sync point. The other two tasks will set the other two bits defined
|
||||
// by ALL_SYNC_BITS. All three tasks have reached the synchronisation
|
||||
// point when all the ALL_SYNC_BITS are set. Wait a maximum of 100ms
|
||||
// for this to happen.
|
||||
uxReturn = xEventGroupSync( xEventBits, TASK_0_BIT, ALL_SYNC_BITS, xTicksToWait );
|
||||
|
||||
if( ( uxReturn & ALL_SYNC_BITS ) == ALL_SYNC_BITS )
|
||||
{
|
||||
// All three tasks reached the synchronisation point before the call
|
||||
// to xEventGroupSync() timed out.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void vTask1( void *pvParameters )
|
||||
{
|
||||
for( ;; )
|
||||
{
|
||||
// Perform task functionality here.
|
||||
|
||||
// Set bit 1 in the event flag to note this task has reached the
|
||||
// synchronisation point. The other two tasks will set the other two
|
||||
// bits defined by ALL_SYNC_BITS. All three tasks have reached the
|
||||
// synchronisation point when all the ALL_SYNC_BITS are set. Wait
|
||||
// indefinitely for this to happen.
|
||||
xEventGroupSync( xEventBits, TASK_1_BIT, ALL_SYNC_BITS, portMAX_DELAY );
|
||||
|
||||
// xEventGroupSync() was called with an indefinite block time, so
|
||||
// this task will only reach here if the syncrhonisation was made by all
|
||||
// three tasks, so there is no need to test the return value.
|
||||
}
|
||||
}
|
||||
|
||||
void vTask2( void *pvParameters )
|
||||
{
|
||||
for( ;; )
|
||||
{
|
||||
// Perform task functionality here.
|
||||
|
||||
// Set bit 2 in the event flag to note this task has reached the
|
||||
// synchronisation point. The other two tasks will set the other two
|
||||
// bits defined by ALL_SYNC_BITS. All three tasks have reached the
|
||||
// synchronisation point when all the ALL_SYNC_BITS are set. Wait
|
||||
// indefinitely for this to happen.
|
||||
xEventGroupSync( xEventBits, TASK_2_BIT, ALL_SYNC_BITS, portMAX_DELAY );
|
||||
|
||||
// xEventGroupSync() was called with an indefinite block time, so
|
||||
// this task will only reach here if the syncrhonisation was made by all
|
||||
// three tasks, so there is no need to test the return value.
|
||||
}
|
||||
}
|
||||
|
||||
</pre>
|
||||
* \defgroup xEventGroupSync xEventGroupSync
|
||||
* @code{c}
|
||||
* // Bits used by the three tasks.
|
||||
* #define TASK_0_BIT ( 1 << 0 )
|
||||
* #define TASK_1_BIT ( 1 << 1 )
|
||||
* #define TASK_2_BIT ( 1 << 2 )
|
||||
*
|
||||
* #define ALL_SYNC_BITS ( TASK_0_BIT | TASK_1_BIT | TASK_2_BIT )
|
||||
*
|
||||
* // Use an event group to synchronise three tasks. It is assumed this event
|
||||
* // group has already been created elsewhere.
|
||||
* EventGroupHandle_t xEventBits;
|
||||
*
|
||||
* void vTask0( void *pvParameters )
|
||||
* {
|
||||
* EventBits_t uxReturn;
|
||||
* TickType_t xTicksToWait = 100 / portTICK_PERIOD_MS;
|
||||
*
|
||||
* for( ;; )
|
||||
* {
|
||||
* // Perform task functionality here.
|
||||
*
|
||||
* // Set bit 0 in the event flag to note this task has reached the
|
||||
* // sync point. The other two tasks will set the other two bits defined
|
||||
* // by ALL_SYNC_BITS. All three tasks have reached the synchronisation
|
||||
* // point when all the ALL_SYNC_BITS are set. Wait a maximum of 100ms
|
||||
* // for this to happen.
|
||||
* uxReturn = xEventGroupSync( xEventBits, TASK_0_BIT, ALL_SYNC_BITS, xTicksToWait );
|
||||
*
|
||||
* if( ( uxReturn & ALL_SYNC_BITS ) == ALL_SYNC_BITS )
|
||||
* {
|
||||
* // All three tasks reached the synchronisation point before the call
|
||||
* // to xEventGroupSync() timed out.
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* void vTask1( void *pvParameters )
|
||||
* {
|
||||
* for( ;; )
|
||||
* {
|
||||
* // Perform task functionality here.
|
||||
*
|
||||
* // Set bit 1 in the event flag to note this task has reached the
|
||||
* // synchronisation point. The other two tasks will set the other two
|
||||
* // bits defined by ALL_SYNC_BITS. All three tasks have reached the
|
||||
* // synchronisation point when all the ALL_SYNC_BITS are set. Wait
|
||||
* // indefinitely for this to happen.
|
||||
* xEventGroupSync( xEventBits, TASK_1_BIT, ALL_SYNC_BITS, portMAX_DELAY );
|
||||
*
|
||||
* // xEventGroupSync() was called with an indefinite block time, so
|
||||
* // this task will only reach here if the syncrhonisation was made by all
|
||||
* // three tasks, so there is no need to test the return value.
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* void vTask2( void *pvParameters )
|
||||
* {
|
||||
* for( ;; )
|
||||
* {
|
||||
* // Perform task functionality here.
|
||||
*
|
||||
* // Set bit 2 in the event flag to note this task has reached the
|
||||
* // synchronisation point. The other two tasks will set the other two
|
||||
* // bits defined by ALL_SYNC_BITS. All three tasks have reached the
|
||||
* // synchronisation point when all the ALL_SYNC_BITS are set. Wait
|
||||
* // indefinitely for this to happen.
|
||||
* xEventGroupSync( xEventBits, TASK_2_BIT, ALL_SYNC_BITS, portMAX_DELAY );
|
||||
*
|
||||
* // xEventGroupSync() was called with an indefinite block time, so
|
||||
* // this task will only reach here if the syncrhonisation was made by all
|
||||
* // three tasks, so there is no need to test the return value.
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* @endcode
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
|
||||
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
*<pre>
|
||||
EventBits_t xEventGroupGetBits( EventGroupHandle_t xEventGroup );
|
||||
</pre>
|
||||
*
|
||||
* Returns the current value of the bits in an event group. This function
|
||||
* cannot be used from an interrupt.
|
||||
*
|
||||
@ -677,33 +680,22 @@ EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t u
|
||||
*
|
||||
* @return The event group bits at the time xEventGroupGetBits() was called.
|
||||
*
|
||||
* \defgroup xEventGroupGetBits xEventGroupGetBits
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
#define xEventGroupGetBits( xEventGroup ) xEventGroupClearBits( xEventGroup, 0 )
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
*<pre>
|
||||
EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup );
|
||||
</pre>
|
||||
*
|
||||
* A version of xEventGroupGetBits() that can be called from an ISR.
|
||||
*
|
||||
* @param xEventGroup The event group being queried.
|
||||
*
|
||||
* @return The event group bits at the time xEventGroupGetBitsFromISR() was called.
|
||||
*
|
||||
* \defgroup xEventGroupGetBitsFromISR xEventGroupGetBitsFromISR
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup );
|
||||
|
||||
/**
|
||||
* event_groups.h
|
||||
*<pre>
|
||||
void xEventGroupDelete( EventGroupHandle_t xEventGroup );
|
||||
</pre>
|
||||
*
|
||||
* Delete an event group that was previously created by a call to
|
||||
* xEventGroupCreate(). Tasks that are blocked on the event group will be
|
||||
@ -713,6 +705,8 @@ EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup );
|
||||
*/
|
||||
void vEventGroupDelete( EventGroupHandle_t xEventGroup );
|
||||
|
||||
/** @cond */
|
||||
|
||||
/* For internal use only. */
|
||||
void vEventGroupSetBitsCallback( void *pvEventGroup, const uint32_t ulBitsToSet );
|
||||
void vEventGroupClearBitsCallback( void *pvEventGroup, const uint32_t ulBitsToClear );
|
||||
@ -721,6 +715,8 @@ void vEventGroupClearBitsCallback( void *pvEventGroup, const uint32_t ulBitsToCl
|
||||
UBaseType_t uxEventGroupGetNumber( void* xEventGroup );
|
||||
#endif
|
||||
|
||||
/** @endcond */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -264,7 +264,7 @@ static inline unsigned portENTER_CRITICAL_NESTED() {
|
||||
|
||||
//xTaskCreateStatic uses these functions to check incoming memory.
|
||||
#define portVALID_TCB_MEM(ptr) (esp_ptr_internal(ptr) && esp_ptr_byte_accessible(ptr))
|
||||
#ifndef CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
|
||||
#ifdef CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
|
||||
#define portVALID_STACK_MEM(ptr) esp_ptr_byte_accessible(ptr)
|
||||
#else
|
||||
#define portVALID_STACK_MEM(ptr) (esp_ptr_internal(ptr) && esp_ptr_byte_accessible(ptr))
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -9,50 +9,58 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
Header definitions for a FreeRTOS ringbuffer object
|
||||
|
||||
A ringbuffer instantiated by these functions essentially acts like a FreeRTOS queue, with the
|
||||
difference that it's strictly FIFO and with the main advantage that you can put in randomly-sized
|
||||
items. The capacity, accordingly, isn't measured in the amount of items, but the amount of memory
|
||||
that is used for storing the items. Dependent on the size of the items, more or less of them will
|
||||
fit in the ring buffer.
|
||||
|
||||
This ringbuffer tries to be efficient with memory: when inserting an item, the item data will
|
||||
be copied to the ringbuffer memory. When retrieving an item, however, a reference to ringbuffer
|
||||
memory will be returned. The returned memory is guaranteed to be 32-bit aligned and contiguous.
|
||||
The application can use this memory, but as long as it does, ringbuffer writes that would write
|
||||
to this bit of memory will block.
|
||||
|
||||
The requirement for items to be contiguous is slightly problematic when the only way to place
|
||||
the next item would involve a wraparound from the end to the beginning of the ringbuffer. This can
|
||||
be solved (or not) in a few ways:
|
||||
- type = RINGBUF_TYPE_ALLOWSPLIT: The insertion code will split the item in two items; one which fits
|
||||
in the space left at the end of the ringbuffer, one that contains the remaining data which is placed
|
||||
in the beginning. Two xRingbufferReceive calls will be needed to retrieve the data.
|
||||
- type = RINGBUF_TYPE_NOSPLIT: The insertion code will leave the room at the end of the ringbuffer
|
||||
unused and instead will put the entire item at the start of the ringbuffer, as soon as there is
|
||||
enough free space.
|
||||
- type = RINGBUF_TYPE_BYTEBUF: This is your conventional byte-based ringbuffer. It does have no
|
||||
overhead, but it has no item contiguousness either: a read will just give you the entire written
|
||||
buffer space, or the space up to the end of the buffer, and writes can be broken up in any way
|
||||
possible. Note that this type cannot do a 2nd read before returning the memory of the 1st.
|
||||
|
||||
The maximum size of an item will be affected by this decision. When split items are allowed, it's
|
||||
acceptable to push items of (buffer_size)-16 bytes into the buffer. When it's not allowed, the
|
||||
maximum size is (buffer_size/2)-8 bytes. The bytebuf can fill the entire buffer with data, it has
|
||||
no overhead.
|
||||
*/
|
||||
|
||||
#include <freertos/queue.h>
|
||||
|
||||
//An opaque handle for a ringbuff object.
|
||||
typedef void * RingbufHandle_t;
|
||||
|
||||
//The various types of buffer
|
||||
/**
|
||||
* @brief The various types of buffer
|
||||
*
|
||||
* A ringbuffer instantiated by these functions essentially acts like a
|
||||
* FreeRTOS queue, with the difference that it's strictly FIFO and with
|
||||
* the main advantage that you can put in randomly-sized items. The capacity,
|
||||
* accordingly, isn't measured in the amount of items, but the amount of
|
||||
* memory that is used for storing the items. Dependent on the size of
|
||||
* the items, more or less of them will fit in the ring buffer.
|
||||
*
|
||||
* This ringbuffer tries to be efficient with memory: when inserting an item,
|
||||
* the item data will be copied to the ringbuffer memory. When retrieving
|
||||
* an item, however, a reference to ringbuffer memory will be returned.
|
||||
* The returned memory is guaranteed to be 32-bit aligned and contiguous.
|
||||
* The application can use this memory, but as long as it does, ringbuffer
|
||||
* writes that would write to this bit of memory will block.
|
||||
*
|
||||
* The requirement for items to be contiguous is slightly problematic when
|
||||
* the only way to place the next item would involve a wraparound from the end
|
||||
* to the beginning of the ringbuffer. This can be solved (or not) in a few ways,
|
||||
* see descriptions of possible ringbuf_type_t types below.
|
||||
*
|
||||
* The maximum size of an item will be affected by ringbuffer type.
|
||||
* When split items are allowed, it is acceptable to push items of
|
||||
* (buffer_size)-16 bytes into the buffer.
|
||||
* When it's not allowed, the maximum size is (buffer_size/2)-8 bytes.
|
||||
* The bytebuf can fill the entire buffer with data, it has no overhead.
|
||||
*/
|
||||
typedef enum {
|
||||
/** The insertion code will leave the room at the end of the ringbuffer
|
||||
* unused and instead will put the entire item at the start of the ringbuffer,
|
||||
* as soon as there is enough free space.
|
||||
*/
|
||||
RINGBUF_TYPE_NOSPLIT = 0,
|
||||
/** The insertion code will split the item in two items; one which fits
|
||||
* in the space left at the end of the ringbuffer, one that contains
|
||||
* the remaining data which is placed in the beginning.
|
||||
* Two xRingbufferReceive calls will be needed to retrieve the data.
|
||||
*/
|
||||
RINGBUF_TYPE_ALLOWSPLIT,
|
||||
/** This is your conventional byte-based ringbuffer. It does have no
|
||||
* overhead, but it has no item contiguousness either: a read will just
|
||||
* give you the entire written buffer space, or the space up to the end
|
||||
* of the buffer, and writes can be broken up in any way possible.
|
||||
* Note that this type cannot do a 2nd read before returning the memory
|
||||
* of the 1st.
|
||||
*/
|
||||
RINGBUF_TYPE_BYTEBUF
|
||||
} ringbuf_type_t;
|
||||
|
||||
@ -60,22 +68,32 @@ typedef enum {
|
||||
/**
|
||||
* @brief Create a ring buffer
|
||||
*
|
||||
* @param buf_length : Length of circular buffer, in bytes. Each entry will take up its own length, plus a header
|
||||
* that at the moment is equal to sizeof(size_t).
|
||||
* @param allow_split_items : pdTRUE if it is acceptable that item data is inserted as two
|
||||
* items instead of one.
|
||||
* @param buf_length Length of circular buffer, in bytes. Each entry will
|
||||
* take up its own length, plus a header that at the moment
|
||||
* is equal to sizeof(size_t).
|
||||
* @param type Type of ring buffer, see ringbuf_type_t.
|
||||
*
|
||||
* @return A RingbufHandle_t handle to the created ringbuffer, or NULL in case of error.
|
||||
*/
|
||||
RingbufHandle_t xRingbufferCreate(size_t buf_length, ringbuf_type_t type);
|
||||
|
||||
/**
|
||||
* @brief Create a ring buffer of type RINGBUF_TYPE_NOSPLIT for a fixed item_size
|
||||
*
|
||||
* This API is similar to xRingbufferCreate(), but it will internally allocate
|
||||
* additional space for the headers.
|
||||
*
|
||||
* @param item_size Size of each item to be put into the ring buffer
|
||||
* @param num_item Maximum number of items the buffer needs to hold simultaneously
|
||||
*
|
||||
* @return A RingbufHandle_t handle to the created ringbuffer, or NULL in case of error.
|
||||
*/
|
||||
RingbufHandle_t xRingbufferCreateNoSplit(size_t item_size, size_t num_item);
|
||||
|
||||
/**
|
||||
* @brief Delete a ring buffer
|
||||
*
|
||||
* @param ringbuf - Ring buffer to delete
|
||||
*
|
||||
* @return void
|
||||
* @param ringbuf Ring buffer to delete
|
||||
*/
|
||||
void vRingbufferDelete(RingbufHandle_t ringbuf);
|
||||
|
||||
@ -83,23 +101,57 @@ void vRingbufferDelete(RingbufHandle_t ringbuf);
|
||||
/**
|
||||
* @brief Get maximum size of an item that can be placed in the ring buffer
|
||||
*
|
||||
* @param ringbuf - Ring buffer to query
|
||||
* @param ringbuf Ring buffer to query
|
||||
*
|
||||
* @return Maximum size, in bytes, of an item that can be placed in a ring buffer.
|
||||
*/
|
||||
size_t xRingbufferGetMaxItemSize(RingbufHandle_t ringbuf);
|
||||
|
||||
/**
|
||||
* @brief Get current free size available in the buffer
|
||||
*
|
||||
* This gives the real time free space available in the ring buffer. So basically,
|
||||
* this will be the maximum size of the entry that can be sent into the buffer.
|
||||
*
|
||||
* @note This API is not thread safe. So, if multiple threads are accessing the same
|
||||
* ring buffer, it is the application's responsibility to ensure atomic access to this
|
||||
* API and the subsequent Send
|
||||
*
|
||||
* @param ringbuf - Ring buffer to query
|
||||
*
|
||||
* @return Current free size, in bytes, available for an entry
|
||||
*/
|
||||
size_t xRingbufferGetCurFreeSize(RingbufHandle_t ringbuf);
|
||||
|
||||
/**
|
||||
* @brief Check if the next item is wrapped
|
||||
*
|
||||
* This API tells if the next item that is available for a Receive is wrapped
|
||||
* or not. This is valid only if the ring buffer type is RINGBUF_TYPE_ALLOWSPLIT
|
||||
*
|
||||
* @note This API is not thread safe. So, if multiple threads are accessing the same
|
||||
* ring buffer, it is the application's responsibility to ensure atomic access to this
|
||||
* API and the subsequent Receive
|
||||
*
|
||||
* @param ringbuf - Ring buffer to query
|
||||
*
|
||||
* @return true if the next item is wrapped around
|
||||
* @return false if the next item is not wrapped
|
||||
*/
|
||||
bool xRingbufferIsNextItemWrapped(RingbufHandle_t ringbuf);
|
||||
|
||||
/**
|
||||
* @brief Insert an item into the ring buffer
|
||||
*
|
||||
* @param ringbuf - Ring buffer to insert the item into
|
||||
* @param data - Pointer to data to insert. NULL is allowed if data_size is 0.
|
||||
* @param data_size - Size of data to insert. A value of 0 is allowed.
|
||||
* @param xTicksToWait - Ticks to wait for room in the ringbuffer.
|
||||
* @param ringbuf Ring buffer to insert the item into
|
||||
* @param data Pointer to data to insert. NULL is allowed if data_size is 0.
|
||||
* @param data_size Size of data to insert. A value of 0 is allowed.
|
||||
* @param ticks_to_wait Ticks to wait for room in the ringbuffer.
|
||||
*
|
||||
* @return pdTRUE if succeeded, pdFALSE on time-out or when the buffer is larger
|
||||
* than indicated by xRingbufferGetMaxItemSize(ringbuf).
|
||||
* @return
|
||||
* - pdTRUE if succeeded
|
||||
* - pdFALSE on time-out or when the buffer is larger than indicated
|
||||
* by xRingbufferGetMaxItemSize(ringbuf).
|
||||
*/
|
||||
BaseType_t xRingbufferSend(RingbufHandle_t ringbuf, void *data, size_t data_size, TickType_t ticks_to_wait);
|
||||
|
||||
@ -107,11 +159,11 @@ BaseType_t xRingbufferSend(RingbufHandle_t ringbuf, void *data, size_t data_size
|
||||
/**
|
||||
* @brief Insert an item into the ring buffer from an ISR
|
||||
*
|
||||
* @param ringbuf - Ring buffer to insert the item into
|
||||
* @param data - Pointer to data to insert. NULL is allowed if data_size is 0.
|
||||
* @param data_size - Size of data to insert. A value of 0 is allowed.
|
||||
* @param higher_prio_task_awoken - Value pointed to will be set to pdTRUE if the push woke up a higher
|
||||
* priority task.
|
||||
* @param ringbuf Ring buffer to insert the item into
|
||||
* @param data Pointer to data to insert. NULL is allowed if data_size is 0.
|
||||
* @param data_size Size of data to insert. A value of 0 is allowed.
|
||||
* @param[out] higher_prio_task_awoken Value pointed to will be set to pdTRUE
|
||||
* if the push woke up a higher priority task.
|
||||
*
|
||||
* @return pdTRUE if succeeded, pdFALSE when the ring buffer does not have space.
|
||||
*/
|
||||
@ -120,14 +172,18 @@ BaseType_t xRingbufferSendFromISR(RingbufHandle_t ringbuf, void *data, size_t da
|
||||
/**
|
||||
* @brief Retrieve an item from the ring buffer
|
||||
*
|
||||
* @note A call to vRingbufferReturnItem() is required after this to free up the data received.
|
||||
* @note A call to vRingbufferReturnItem() is required after this to free up
|
||||
* the data received.
|
||||
*
|
||||
* @param ringbuf - Ring buffer to retrieve the item from
|
||||
* @param item_size - Pointer to a variable to which the size of the retrieved item will be written.
|
||||
* @param xTicksToWait - Ticks to wait for items in the ringbuffer.
|
||||
* @param ringbuf Ring buffer to retrieve the item from
|
||||
* @param[out] item_size Pointer to a variable to which the size of the
|
||||
* retrieved item will be written.
|
||||
* @param ticks_to_wait Ticks to wait for items in the ringbuffer.
|
||||
*
|
||||
* @return Pointer to the retrieved item on success; *item_size filled with the length of the
|
||||
* item. NULL on timeout, *item_size is untouched in that case.
|
||||
* @return
|
||||
* - pointer to the retrieved item on success; *item_size filled with
|
||||
* the length of the item.
|
||||
* - NULL on timeout, *item_size is untouched in that case.
|
||||
*/
|
||||
void *xRingbufferReceive(RingbufHandle_t ringbuf, size_t *item_size, TickType_t ticks_to_wait);
|
||||
|
||||
@ -135,44 +191,58 @@ void *xRingbufferReceive(RingbufHandle_t ringbuf, size_t *item_size, TickType_t
|
||||
/**
|
||||
* @brief Retrieve an item from the ring buffer from an ISR
|
||||
*
|
||||
* @note A call to vRingbufferReturnItemFromISR() is required after this to free up the data received
|
||||
* @note A call to vRingbufferReturnItemFromISR() is required after this to
|
||||
* free up the data received
|
||||
*
|
||||
* @param ringbuf - Ring buffer to retrieve the item from
|
||||
* @param item_size - Pointer to a variable to which the size of the retrieved item will be written.
|
||||
* @param ringbuf Ring buffer to retrieve the item from
|
||||
* @param[out] item_size Pointer to a variable to which the size of the
|
||||
* retrieved item will be written.
|
||||
*
|
||||
* @return Pointer to the retrieved item on success; *item_size filled with the length of the
|
||||
* item. NULL when the ringbuffer is empty, *item_size is untouched in that case.
|
||||
* @return
|
||||
* - Pointer to the retrieved item on success; *item_size filled with
|
||||
* the length of the item.
|
||||
* - NULL when the ringbuffer is empty, *item_size is untouched in that case.
|
||||
*/
|
||||
void *xRingbufferReceiveFromISR(RingbufHandle_t ringbuf, size_t *item_size);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Retrieve bytes from a ByteBuf type of ring buffer, specifying the maximum amount of bytes
|
||||
* to return
|
||||
|
||||
* @note A call to vRingbufferReturnItem() is required after this to free up the data received.
|
||||
* @brief Retrieve bytes from a ByteBuf type of ring buffer,
|
||||
* specifying the maximum amount of bytes to return
|
||||
*
|
||||
* @param ringbuf - Ring buffer to retrieve the item from
|
||||
* @param item_size - Pointer to a variable to which the size of the retrieved item will be written.
|
||||
* @param xTicksToWait - Ticks to wait for items in the ringbuffer.
|
||||
* @note A call to vRingbufferReturnItem() is required after this to free up
|
||||
* the data received.
|
||||
*
|
||||
* @return Pointer to the retrieved item on success; *item_size filled with the length of the
|
||||
* item. NULL on timeout, *item_size is untouched in that case.
|
||||
* @param ringbuf Ring buffer to retrieve the item from
|
||||
* @param[out] item_size Pointer to a variable to which the size
|
||||
* of the retrieved item will be written.
|
||||
* @param ticks_to_wait Ticks to wait for items in the ringbuffer.
|
||||
* @param wanted_size Maximum number of bytes to return.
|
||||
*
|
||||
* @return
|
||||
* - Pointer to the retrieved item on success; *item_size filled with
|
||||
* the length of the item.
|
||||
* - NULL on timeout, *item_size is untouched in that case.
|
||||
*/
|
||||
void *xRingbufferReceiveUpTo(RingbufHandle_t ringbuf, size_t *item_size, TickType_t ticks_to_wait, size_t wanted_size);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Retrieve bytes from a ByteBuf type of ring buffer, specifying the maximum amount of bytes
|
||||
* to return. Call this from an ISR.
|
||||
* @brief Retrieve bytes from a ByteBuf type of ring buffer,
|
||||
* specifying the maximum amount of bytes to return. Call this from an ISR.
|
||||
*
|
||||
* @note A call to vRingbufferReturnItemFromISR() is required after this to free up the data received
|
||||
* @note A call to vRingbufferReturnItemFromISR() is required after this
|
||||
* to free up the data received.
|
||||
*
|
||||
* @param ringbuf - Ring buffer to retrieve the item from
|
||||
* @param item_size - Pointer to a variable to which the size of the retrieved item will be written.
|
||||
* @param ringbuf Ring buffer to retrieve the item from
|
||||
* @param[out] item_size Pointer to a variable to which the size of the
|
||||
* retrieved item will be written.
|
||||
* @param wanted_size Maximum number of bytes to return.
|
||||
*
|
||||
* @return Pointer to the retrieved item on success; *item_size filled with the length of the
|
||||
* item. NULL when the ringbuffer is empty, *item_size is untouched in that case.
|
||||
* @return
|
||||
* - Pointer to the retrieved item on success; *item_size filled with
|
||||
* the length of the item.
|
||||
* - NULL when the ringbuffer is empty, *item_size is untouched in that case.
|
||||
*/
|
||||
void *xRingbufferReceiveUpToFromISR(RingbufHandle_t ringbuf, size_t *item_size, size_t wanted_size);
|
||||
|
||||
@ -181,10 +251,8 @@ void *xRingbufferReceiveUpToFromISR(RingbufHandle_t ringbuf, size_t *item_size,
|
||||
/**
|
||||
* @brief Return a previously-retrieved item to the ringbuffer
|
||||
*
|
||||
* @param ringbuf - Ring buffer the item was retrieved from
|
||||
* @param item - Item that was received earlier
|
||||
*
|
||||
* @return void
|
||||
* @param ringbuf Ring buffer the item was retrieved from
|
||||
* @param item Item that was received earlier
|
||||
*/
|
||||
void vRingbufferReturnItem(RingbufHandle_t ringbuf, void *item);
|
||||
|
||||
@ -193,34 +261,37 @@ void vRingbufferReturnItem(RingbufHandle_t ringbuf, void *item);
|
||||
/**
|
||||
* @brief Return a previously-retrieved item to the ringbuffer from an ISR
|
||||
*
|
||||
* @param ringbuf - Ring buffer the item was retrieved from
|
||||
* @param item - Item that was received earlier
|
||||
* @param higher_prio_task_awoken - Value pointed to will be set to pdTRUE if the push woke up a higher
|
||||
* priority task.
|
||||
*
|
||||
* @return void
|
||||
* @param ringbuf Ring buffer the item was retrieved from
|
||||
* @param item Item that was received earlier
|
||||
* @param[out] higher_prio_task_awoken Value pointed to will be set to pdTRUE
|
||||
* if the push woke up a higher priority task.
|
||||
*/
|
||||
void vRingbufferReturnItemFromISR(RingbufHandle_t ringbuf, void *item, BaseType_t *higher_prio_task_awoken);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Add the ringbuffer to a queue set. This specifically adds the semaphore that indicates
|
||||
* more space has become available in the ringbuffer.
|
||||
* @brief Add the ringbuffer to a queue set.
|
||||
*
|
||||
* @param ringbuf - Ring buffer to add to the queue set
|
||||
* @param xQueueSet - Queue set to add the ringbuffer to
|
||||
* This specifically adds the semaphore that indicates more space
|
||||
* has become available in the ringbuffer.
|
||||
*
|
||||
* @return pdTRUE on success, pdFALSE otherwise
|
||||
* @param ringbuf Ring buffer to add to the queue set
|
||||
* @param xQueueSet Queue set to add the ringbuffer to
|
||||
*
|
||||
* @return
|
||||
* - pdTRUE on success, pdFALSE otherwise
|
||||
*/
|
||||
BaseType_t xRingbufferAddToQueueSetRead(RingbufHandle_t ringbuf, QueueSetHandle_t xQueueSet);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Add the ringbuffer to a queue set. This specifically adds the semaphore that indicates
|
||||
* something has been written into the ringbuffer.
|
||||
* @brief Add the ringbuffer to a queue set.
|
||||
*
|
||||
* @param ringbuf - Ring buffer to add to the queue set
|
||||
* @param xQueueSet - Queue set to add the ringbuffer to
|
||||
* This specifically adds the semaphore that indicates something has been
|
||||
* written into the ringbuffer.
|
||||
*
|
||||
* @param ringbuf Ring buffer to add to the queue set
|
||||
* @param xQueueSet Queue set to add the ringbuffer to
|
||||
*
|
||||
* @return pdTRUE on success, pdFALSE otherwise
|
||||
*/
|
||||
@ -228,11 +299,13 @@ BaseType_t xRingbufferAddToQueueSetWrite(RingbufHandle_t ringbuf, QueueSetHandle
|
||||
|
||||
|
||||
/**
|
||||
* @brief Remove the ringbuffer from a queue set. This specifically removes the semaphore that indicates
|
||||
* more space has become available in the ringbuffer.
|
||||
* @brief Remove the ringbuffer from a queue set.
|
||||
*
|
||||
* @param ringbuf - Ring buffer to remove from the queue set
|
||||
* @param xQueueSet - Queue set to remove the ringbuffer from
|
||||
* This specifically removes the semaphore that indicates more space
|
||||
* has become available in the ringbuffer.
|
||||
*
|
||||
* @param ringbuf Ring buffer to remove from the queue set
|
||||
* @param xQueueSet Queue set to remove the ringbuffer from
|
||||
*
|
||||
* @return pdTRUE on success, pdFALSE otherwise
|
||||
*/
|
||||
@ -240,11 +313,13 @@ BaseType_t xRingbufferRemoveFromQueueSetRead(RingbufHandle_t ringbuf, QueueSetHa
|
||||
|
||||
|
||||
/**
|
||||
* @brief Remove the ringbuffer from a queue set. This specifically removes the semaphore that indicates
|
||||
* something has been written to the ringbuffer.
|
||||
* @brief Remove the ringbuffer from a queue set.
|
||||
*
|
||||
* @param ringbuf - Ring buffer to remove from the queue set
|
||||
* @param xQueueSet - Queue set to remove the ringbuffer from
|
||||
* This specifically removes the semaphore that indicates something
|
||||
* has been written to the ringbuffer.
|
||||
*
|
||||
* @param ringbuf Ring buffer to remove from the queue set
|
||||
* @param xQueueSet Queue set to remove the ringbuffer from
|
||||
*
|
||||
* @return pdTRUE on success, pdFALSE otherwise
|
||||
*/
|
||||
@ -254,9 +329,7 @@ BaseType_t xRingbufferRemoveFromQueueSetWrite(RingbufHandle_t ringbuf, QueueSetH
|
||||
/**
|
||||
* @brief Debugging function to print the internal pointers in the ring buffer
|
||||
*
|
||||
* @param ringbuf - Ring buffer to show
|
||||
*
|
||||
* @return void
|
||||
* @param ringbuf Ring buffer to show
|
||||
*/
|
||||
void xRingbufferPrintInfo(RingbufHandle_t ringbuf);
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -117,27 +117,29 @@ or interrupt version of the queue send function should be used. */
|
||||
*/
|
||||
typedef void * TimerHandle_t;
|
||||
|
||||
/*
|
||||
/**
|
||||
* Defines the prototype to which timer callback functions must conform.
|
||||
*/
|
||||
typedef void (*TimerCallbackFunction_t)( TimerHandle_t xTimer );
|
||||
|
||||
/*
|
||||
/**
|
||||
* Defines the prototype to which functions used with the
|
||||
* xTimerPendFunctionCallFromISR() function must conform.
|
||||
*/
|
||||
typedef void (*PendedFunction_t)( void *, uint32_t );
|
||||
|
||||
/**
|
||||
* TimerHandle_t xTimerCreate( const char * const pcTimerName,
|
||||
* TickType_t xTimerPeriodInTicks,
|
||||
* UBaseType_t uxAutoReload,
|
||||
* void * pvTimerID,
|
||||
* TimerCallbackFunction_t pxCallbackFunction );
|
||||
* Creates a new software timer instance, and returns a handle by which the
|
||||
* created software timer can be referenced.
|
||||
*
|
||||
* Creates a new software timer instance. This allocates the storage required
|
||||
* by the new timer, initialises the new timers internal state, and returns a
|
||||
* handle by which the new timer can be referenced.
|
||||
* Internally, within the FreeRTOS implementation, software timers use a block
|
||||
* of memory, in which the timer data structure is stored. If a software timer
|
||||
* is created using xTimerCreate() then the required memory is automatically
|
||||
* dynamically allocated inside the xTimerCreate() function. (see
|
||||
* http://www.freertos.org/a00111.html). If a software timer is created using
|
||||
* xTimerCreateStatic() then the application writer must provide the memory that
|
||||
* will get used by the software timer. xTimerCreateStatic() therefore allows a
|
||||
* software timer to be created without using any dynamic memory allocation.
|
||||
*
|
||||
* Timers are created in the dormant state. The xTimerStart(), xTimerReset(),
|
||||
* xTimerStartFromISR(), xTimerResetFromISR(), xTimerChangePeriod() and
|
||||
@ -176,7 +178,7 @@ typedef void (*PendedFunction_t)( void *, uint32_t );
|
||||
* structures, or the timer period was set to 0) then NULL is returned.
|
||||
*
|
||||
* Example usage:
|
||||
* @verbatim
|
||||
* @code{c}
|
||||
* #define NUM_TIMERS 5
|
||||
*
|
||||
* // An array to hold handles to the created timers.
|
||||
@ -250,18 +252,146 @@ typedef void (*PendedFunction_t)( void *, uint32_t );
|
||||
*
|
||||
* // Starting the scheduler will start the timers running as they have already
|
||||
* // been set into the active state.
|
||||
* xTaskStartScheduler();
|
||||
* vTaskStartScheduler();
|
||||
*
|
||||
* // Should not reach here.
|
||||
* for( ;; );
|
||||
* }
|
||||
* @endverbatim
|
||||
* @endcode
|
||||
*/
|
||||
TimerHandle_t xTimerCreate( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
|
||||
#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
|
||||
TimerHandle_t xTimerCreate( const char * const pcTimerName,
|
||||
const TickType_t xTimerPeriodInTicks,
|
||||
const UBaseType_t uxAutoReload,
|
||||
void * const pvTimerID,
|
||||
TimerCallbackFunction_t pxCallbackFunction ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* void *pvTimerGetTimerID( TimerHandle_t xTimer );
|
||||
* Creates a new software timer instance, and returns a handle by which the
|
||||
* created software timer can be referenced.
|
||||
*
|
||||
* Internally, within the FreeRTOS implementation, software timers use a block
|
||||
* of memory, in which the timer data structure is stored. If a software timer
|
||||
* is created using xTimerCreate() then the required memory is automatically
|
||||
* dynamically allocated inside the xTimerCreate() function. (see
|
||||
* http://www.freertos.org/a00111.html). If a software timer is created using
|
||||
* xTimerCreateStatic() then the application writer must provide the memory that
|
||||
* will get used by the software timer. xTimerCreateStatic() therefore allows a
|
||||
* software timer to be created without using any dynamic memory allocation.
|
||||
*
|
||||
* Timers are created in the dormant state. The xTimerStart(), xTimerReset(),
|
||||
* xTimerStartFromISR(), xTimerResetFromISR(), xTimerChangePeriod() and
|
||||
* xTimerChangePeriodFromISR() API functions can all be used to transition a
|
||||
* timer into the active state.
|
||||
*
|
||||
* @param pcTimerName A text name that is assigned to the timer. This is done
|
||||
* purely to assist debugging. The kernel itself only ever references a timer
|
||||
* by its handle, and never by its name.
|
||||
*
|
||||
* @param xTimerPeriodInTicks The timer period. The time is defined in tick
|
||||
* periods so the constant portTICK_PERIOD_MS can be used to convert a time that
|
||||
* has been specified in milliseconds. For example, if the timer must expire
|
||||
* after 100 ticks, then xTimerPeriodInTicks should be set to 100.
|
||||
* Alternatively, if the timer must expire after 500ms, then xPeriod can be set
|
||||
* to ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than or
|
||||
* equal to 1000.
|
||||
*
|
||||
* @param uxAutoReload If uxAutoReload is set to pdTRUE then the timer will
|
||||
* expire repeatedly with a frequency set by the xTimerPeriodInTicks parameter.
|
||||
* If uxAutoReload is set to pdFALSE then the timer will be a one-shot timer and
|
||||
* enter the dormant state after it expires.
|
||||
*
|
||||
* @param pvTimerID An identifier that is assigned to the timer being created.
|
||||
* Typically this would be used in the timer callback function to identify which
|
||||
* timer expired when the same callback function is assigned to more than one
|
||||
* timer.
|
||||
*
|
||||
* @param pxCallbackFunction The function to call when the timer expires.
|
||||
* Callback functions must have the prototype defined by TimerCallbackFunction_t,
|
||||
* which is "void vCallbackFunction( TimerHandle_t xTimer );".
|
||||
*
|
||||
* @param pxTimerBuffer Must point to a variable of type StaticTimer_t, which
|
||||
* will be then be used to hold the software timer's data structures, removing
|
||||
* the need for the memory to be allocated dynamically.
|
||||
*
|
||||
* @return If the timer is created then a handle to the created timer is
|
||||
* returned. If pxTimerBuffer was NULL then NULL is returned.
|
||||
*
|
||||
* Example usage:
|
||||
* @code{c}
|
||||
*
|
||||
* // The buffer used to hold the software timer's data structure.
|
||||
* static StaticTimer_t xTimerBuffer;
|
||||
*
|
||||
* // A variable that will be incremented by the software timer's callback
|
||||
* // function.
|
||||
* UBaseType_t uxVariableToIncrement = 0;
|
||||
*
|
||||
* // A software timer callback function that increments a variable passed to
|
||||
* // it when the software timer was created. After the 5th increment the
|
||||
* // callback function stops the software timer.
|
||||
* static void prvTimerCallback( TimerHandle_t xExpiredTimer )
|
||||
* {
|
||||
* UBaseType_t *puxVariableToIncrement;
|
||||
* BaseType_t xReturned;
|
||||
*
|
||||
* // Obtain the address of the variable to increment from the timer ID.
|
||||
* puxVariableToIncrement = ( UBaseType_t * ) pvTimerGetTimerID( xExpiredTimer );
|
||||
*
|
||||
* // Increment the variable to show the timer callback has executed.
|
||||
* ( *puxVariableToIncrement )++;
|
||||
*
|
||||
* // If this callback has executed the required number of times, stop the
|
||||
* // timer.
|
||||
* if( *puxVariableToIncrement == 5 )
|
||||
* {
|
||||
* // This is called from a timer callback so must not block.
|
||||
* xTimerStop( xExpiredTimer, staticDONT_BLOCK );
|
||||
* }
|
||||
* }
|
||||
*
|
||||
*
|
||||
* void main( void )
|
||||
* {
|
||||
* // Create the software time. xTimerCreateStatic() has an extra parameter
|
||||
* // than the normal xTimerCreate() API function. The parameter is a pointer
|
||||
* // to the StaticTimer_t structure that will hold the software timer
|
||||
* // structure. If the parameter is passed as NULL then the structure will be
|
||||
* // allocated dynamically, just as if xTimerCreate() had been called.
|
||||
* xTimer = xTimerCreateStatic( "T1", // Text name for the task. Helps debugging only. Not used by FreeRTOS.
|
||||
* xTimerPeriod, // The period of the timer in ticks.
|
||||
* pdTRUE, // This is an auto-reload timer.
|
||||
* ( void * ) &uxVariableToIncrement, // A variable incremented by the software timer's callback function
|
||||
* prvTimerCallback, // The function to execute when the timer expires.
|
||||
* &xTimerBuffer ); // The buffer that will hold the software timer structure.
|
||||
*
|
||||
* // The scheduler has not started yet so a block time is not used.
|
||||
* xReturned = xTimerStart( xTimer, 0 );
|
||||
*
|
||||
* // ...
|
||||
* // Create tasks here.
|
||||
* // ...
|
||||
*
|
||||
* // Starting the scheduler will start the timers running as they have already
|
||||
* // been set into the active state.
|
||||
* vTaskStartScheduler();
|
||||
*
|
||||
* // Should not reach here.
|
||||
* for( ;; );
|
||||
* }
|
||||
* @endcode
|
||||
*/
|
||||
#if( configSUPPORT_STATIC_ALLOCATION == 1 )
|
||||
TimerHandle_t xTimerCreateStatic( const char * const pcTimerName,
|
||||
const TickType_t xTimerPeriodInTicks,
|
||||
const UBaseType_t uxAutoReload,
|
||||
void * const pvTimerID,
|
||||
TimerCallbackFunction_t pxCallbackFunction,
|
||||
StaticTimer_t *pxTimerBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
|
||||
#endif /* configSUPPORT_STATIC_ALLOCATION */
|
||||
|
||||
/**
|
||||
* Returns the ID assigned to the timer.
|
||||
*
|
||||
* IDs are assigned to timers using the pvTimerID parameter of the call to
|
||||
@ -282,12 +412,31 @@ TimerHandle_t xTimerCreate( const char * const pcTimerName, const TickType_t xTi
|
||||
void *pvTimerGetTimerID( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/**
|
||||
* BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer );
|
||||
* Sets the ID assigned to the timer.
|
||||
*
|
||||
* IDs are assigned to timers using the pvTimerID parameter of the call to
|
||||
* xTimerCreated() that was used to create the timer.
|
||||
*
|
||||
* If the same callback function is assigned to multiple timers then the timer
|
||||
* ID can be used as time specific (timer local) storage.
|
||||
*
|
||||
* @param xTimer The timer being updated.
|
||||
*
|
||||
* @param pvNewID The ID to assign to the timer.
|
||||
*
|
||||
* Example usage:
|
||||
*
|
||||
* See the xTimerCreate() API function example usage scenario.
|
||||
*/
|
||||
void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/**
|
||||
* Queries a timer to see if it is active or dormant.
|
||||
*
|
||||
* A timer will be dormant if:
|
||||
*
|
||||
* 1) It has been created but not started, or
|
||||
*
|
||||
* 2) It is an expired one-shot timer that has not been restarted.
|
||||
*
|
||||
* Timers are created in the dormant state. The xTimerStart(), xTimerReset(),
|
||||
@ -301,7 +450,7 @@ void *pvTimerGetTimerID( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
|
||||
* pdFALSE will be returned if the timer is active.
|
||||
*
|
||||
* Example usage:
|
||||
* @verbatim
|
||||
* @code{c}
|
||||
* // This function assumes xTimer has already been created.
|
||||
* void vAFunction( TimerHandle_t xTimer )
|
||||
* {
|
||||
@ -314,13 +463,11 @@ void *pvTimerGetTimerID( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
|
||||
* // xTimer is not active, do something else.
|
||||
* }
|
||||
* }
|
||||
* @endverbatim
|
||||
* @endcode
|
||||
*/
|
||||
BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/**
|
||||
* TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
*
|
||||
* xTimerGetTimerDaemonTaskHandle() is only available if
|
||||
* INCLUDE_xTimerGetTimerDaemonTaskHandle is set to 1 in FreeRTOSConfig.h.
|
||||
*
|
||||
@ -330,8 +477,28 @@ BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
|
||||
TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
|
||||
/**
|
||||
* BaseType_t xTimerStart( TimerHandle_t xTimer, TickType_t xTicksToWait );
|
||||
* Returns the period of a timer.
|
||||
*
|
||||
* @param xTimer The handle of the timer being queried.
|
||||
*
|
||||
* @return The period of the timer in ticks.
|
||||
*/
|
||||
TickType_t xTimerGetPeriod( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/**
|
||||
* Returns the time in ticks at which the timer will expire. If this is less
|
||||
* than the current tick count then the expiry time has overflowed from the
|
||||
* current time.
|
||||
*
|
||||
* @param xTimer The handle of the timer being queried.
|
||||
*
|
||||
* @return If the timer is running then the time in ticks at which the timer
|
||||
* will next expire is returned. If the timer is not running then the return
|
||||
* value is undefined.
|
||||
*/
|
||||
TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/**
|
||||
* Timer functionality is provided by a timer service/daemon task. Many of the
|
||||
* public FreeRTOS timer API functions send commands to the timer service task
|
||||
* through a queue called the timer command queue. The timer command queue is
|
||||
@ -382,8 +549,6 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
#define xTimerStart( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START, ( xTaskGetTickCount() ), NULL, ( xTicksToWait ) )
|
||||
|
||||
/**
|
||||
* BaseType_t xTimerStop( TimerHandle_t xTimer, TickType_t xTicksToWait );
|
||||
*
|
||||
* Timer functionality is provided by a timer service/daemon task. Many of the
|
||||
* public FreeRTOS timer API functions send commands to the timer service task
|
||||
* through a queue called the timer command queue. The timer command queue is
|
||||
@ -424,10 +589,6 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
#define xTimerStop( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP, 0U, NULL, ( xTicksToWait ) )
|
||||
|
||||
/**
|
||||
* BaseType_t xTimerChangePeriod( TimerHandle_t xTimer,
|
||||
* TickType_t xNewPeriod,
|
||||
* TickType_t xTicksToWait );
|
||||
*
|
||||
* Timer functionality is provided by a timer service/daemon task. Many of the
|
||||
* public FreeRTOS timer API functions send commands to the timer service task
|
||||
* through a queue called the timer command queue. The timer command queue is
|
||||
@ -469,7 +630,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
* configTIMER_TASK_PRIORITY configuration constant.
|
||||
*
|
||||
* Example usage:
|
||||
* @verbatim
|
||||
* @code{c}
|
||||
* // This function assumes xTimer has already been created. If the timer
|
||||
* // referenced by xTimer is already active when it is called, then the timer
|
||||
* // is deleted. If the timer referenced by xTimer is not active when it is
|
||||
@ -499,13 +660,11 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* @endverbatim
|
||||
* @endcode
|
||||
*/
|
||||
#define xTimerChangePeriod( xTimer, xNewPeriod, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD, ( xNewPeriod ), NULL, ( xTicksToWait ) )
|
||||
|
||||
/**
|
||||
* BaseType_t xTimerDelete( TimerHandle_t xTimer, TickType_t xTicksToWait );
|
||||
*
|
||||
* Timer functionality is provided by a timer service/daemon task. Many of the
|
||||
* public FreeRTOS timer API functions send commands to the timer service task
|
||||
* through a queue called the timer command queue. The timer command queue is
|
||||
@ -542,8 +701,6 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
#define xTimerDelete( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_DELETE, 0U, NULL, ( xTicksToWait ) )
|
||||
|
||||
/**
|
||||
* BaseType_t xTimerReset( TimerHandle_t xTimer, TickType_t xTicksToWait );
|
||||
*
|
||||
* Timer functionality is provided by a timer service/daemon task. Many of the
|
||||
* public FreeRTOS timer API functions send commands to the timer service task
|
||||
* through a queue called the timer command queue. The timer command queue is
|
||||
@ -589,7 +746,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
* configuration constant.
|
||||
*
|
||||
* Example usage:
|
||||
* @verbatim
|
||||
* @code{c}
|
||||
* // When a key is pressed, an LCD back-light is switched on. If 5 seconds pass
|
||||
* // without a key being pressed, then the LCD back-light is switched off. In
|
||||
* // this case, the timer is a one-shot timer.
|
||||
@ -661,14 +818,11 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
* // Should not reach here.
|
||||
* for( ;; );
|
||||
* }
|
||||
* @endverbatim
|
||||
* @endcode
|
||||
*/
|
||||
#define xTimerReset( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_RESET, ( xTaskGetTickCount() ), NULL, ( xTicksToWait ) )
|
||||
|
||||
/**
|
||||
* BaseType_t xTimerStartFromISR( TimerHandle_t xTimer,
|
||||
* BaseType_t *pxHigherPriorityTaskWoken );
|
||||
*
|
||||
* A version of xTimerStart() that can be called from an interrupt service
|
||||
* routine.
|
||||
*
|
||||
@ -696,7 +850,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
* configuration constant.
|
||||
*
|
||||
* Example usage:
|
||||
* @verbatim
|
||||
* @code{c}
|
||||
* // This scenario assumes xBacklightTimer has already been created. When a
|
||||
* // key is pressed, an LCD back-light is switched on. If 5 seconds pass
|
||||
* // without a key being pressed, then the LCD back-light is switched off. In
|
||||
@ -747,14 +901,11 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
* // depends on the FreeRTOS port being used).
|
||||
* }
|
||||
* }
|
||||
* @endverbatim
|
||||
* @endcode
|
||||
*/
|
||||
#define xTimerStartFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START_FROM_ISR, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U )
|
||||
|
||||
/**
|
||||
* BaseType_t xTimerStopFromISR( TimerHandle_t xTimer,
|
||||
* BaseType_t *pxHigherPriorityTaskWoken );
|
||||
*
|
||||
* A version of xTimerStop() that can be called from an interrupt service
|
||||
* routine.
|
||||
*
|
||||
@ -780,7 +931,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
* priority is set by the configTIMER_TASK_PRIORITY configuration constant.
|
||||
*
|
||||
* Example usage:
|
||||
* @verbatim
|
||||
* @code{c}
|
||||
* // This scenario assumes xTimer has already been created and started. When
|
||||
* // an interrupt occurs, the timer should be simply stopped.
|
||||
*
|
||||
@ -810,15 +961,11 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
* // depends on the FreeRTOS port being used).
|
||||
* }
|
||||
* }
|
||||
* @endverbatim
|
||||
* @endcode
|
||||
*/
|
||||
#define xTimerStopFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP_FROM_ISR, 0, ( pxHigherPriorityTaskWoken ), 0U )
|
||||
|
||||
/**
|
||||
* BaseType_t xTimerChangePeriodFromISR( TimerHandle_t xTimer,
|
||||
* TickType_t xNewPeriod,
|
||||
* BaseType_t *pxHigherPriorityTaskWoken );
|
||||
*
|
||||
* A version of xTimerChangePeriod() that can be called from an interrupt
|
||||
* service routine.
|
||||
*
|
||||
@ -853,7 +1000,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
* priority is set by the configTIMER_TASK_PRIORITY configuration constant.
|
||||
*
|
||||
* Example usage:
|
||||
* @verbatim
|
||||
* @code{c}
|
||||
* // This scenario assumes xTimer has already been created and started. When
|
||||
* // an interrupt occurs, the period of xTimer should be changed to 500ms.
|
||||
*
|
||||
@ -883,14 +1030,11 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
* // depends on the FreeRTOS port being used).
|
||||
* }
|
||||
* }
|
||||
* @endverbatim
|
||||
* @endcode
|
||||
*/
|
||||
#define xTimerChangePeriodFromISR( xTimer, xNewPeriod, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD_FROM_ISR, ( xNewPeriod ), ( pxHigherPriorityTaskWoken ), 0U )
|
||||
|
||||
/**
|
||||
* BaseType_t xTimerResetFromISR( TimerHandle_t xTimer,
|
||||
* BaseType_t *pxHigherPriorityTaskWoken );
|
||||
*
|
||||
* A version of xTimerReset() that can be called from an interrupt service
|
||||
* routine.
|
||||
*
|
||||
@ -918,7 +1062,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
* task priority is set by the configTIMER_TASK_PRIORITY configuration constant.
|
||||
*
|
||||
* Example usage:
|
||||
* @verbatim
|
||||
* @code{c}
|
||||
* // This scenario assumes xBacklightTimer has already been created. When a
|
||||
* // key is pressed, an LCD back-light is switched on. If 5 seconds pass
|
||||
* // without a key being pressed, then the LCD back-light is switched off. In
|
||||
@ -969,18 +1113,12 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
* // depends on the FreeRTOS port being used).
|
||||
* }
|
||||
* }
|
||||
* @endverbatim
|
||||
* @endcode
|
||||
*/
|
||||
#define xTimerResetFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_RESET_FROM_ISR, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U )
|
||||
|
||||
|
||||
/**
|
||||
* BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend,
|
||||
* void *pvParameter1,
|
||||
* uint32_t ulParameter2,
|
||||
* BaseType_t *pxHigherPriorityTaskWoken );
|
||||
*
|
||||
*
|
||||
* Used from application interrupt service routines to defer the execution of a
|
||||
* function to the RTOS daemon task (the timer service task, hence this function
|
||||
* is implemented in timers.c and is prefixed with 'Timer').
|
||||
@ -1022,7 +1160,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
* timer daemon task, otherwise pdFALSE is returned.
|
||||
*
|
||||
* Example usage:
|
||||
* @verbatim
|
||||
* @code{c}
|
||||
*
|
||||
* // The callback function that will execute in the context of the daemon task.
|
||||
* // Note callback functions must all use this same prototype.
|
||||
@ -1060,17 +1198,11 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
||||
* portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
|
||||
*
|
||||
* }
|
||||
* @endverbatim
|
||||
* @endcode
|
||||
*/
|
||||
BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, BaseType_t *pxHigherPriorityTaskWoken );
|
||||
|
||||
/**
|
||||
* BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend,
|
||||
* void *pvParameter1,
|
||||
* uint32_t ulParameter2,
|
||||
* TickType_t xTicksToWait );
|
||||
*
|
||||
*
|
||||
* Used to defer the execution of a function to the RTOS daemon task (the timer
|
||||
* service task, hence this function is implemented in timers.c and is prefixed
|
||||
* with 'Timer').
|
||||
@ -1099,8 +1231,6 @@ BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend, void
|
||||
BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait );
|
||||
|
||||
/**
|
||||
* const char * const pcTimerGetTimerName( TimerHandle_t xTimer );
|
||||
*
|
||||
* Returns the name that was assigned to a timer when the timer was created.
|
||||
*
|
||||
* @param xTimer The handle of the timer being queried.
|
||||
@ -1109,6 +1239,7 @@ BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvPar
|
||||
*/
|
||||
const char * pcTimerGetTimerName( TimerHandle_t xTimer ); /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
|
||||
|
||||
/** @cond */
|
||||
/*
|
||||
* Functions beyond this part are not part of the public API and are intended
|
||||
* for use by the kernel only.
|
||||
@ -1116,6 +1247,8 @@ const char * pcTimerGetTimerName( TimerHandle_t xTimer ); /*lint !e971 Unqualifi
|
||||
BaseType_t xTimerCreateTimerTask( void ) PRIVILEGED_FUNCTION;
|
||||
BaseType_t xTimerGenericCommand( TimerHandle_t xTimer, const BaseType_t xCommandID, const TickType_t xOptionalValue, BaseType_t * const pxHigherPriorityTaskWoken, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
|
||||
|
||||
/** @endcond */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -24,11 +24,11 @@ extern "C" {
|
||||
/* Please use heap_caps_malloc() instead of this function */
|
||||
void *pvPortMallocCaps(size_t xWantedSize, uint32_t caps) asm("heap_caps_malloc") __attribute__((deprecated));
|
||||
|
||||
/* Please use heap_caps_get_minimum_free_heap_size() instead of this function */
|
||||
size_t xPortGetMinimumEverFreeHeapSizeCaps( uint32_t caps ) asm("heap_caps_get_minimum_free_heap_size") __attribute__((deprecated));
|
||||
/* Please use heap_caps_get_minimum_free_size() instead of this function */
|
||||
size_t xPortGetMinimumEverFreeHeapSizeCaps( uint32_t caps ) asm("heap_caps_get_minimum_free_size") __attribute__((deprecated));
|
||||
|
||||
/* Please use heap_caps_get_free_size() instead of this function */
|
||||
size_t xPortGetFreeHeapSizeCaps( uint32_t caps ) asm("heap_caps_get_free_heap_size") __attribute__((deprecated));
|
||||
size_t xPortGetFreeHeapSizeCaps( uint32_t caps ) asm("heap_caps_get_free_size") __attribute__((deprecated));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2009 Dave Gamble
|
||||
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@ -28,108 +28,211 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* project version */
|
||||
#define CJSON_VERSION_MAJOR 1
|
||||
#define CJSON_VERSION_MINOR 6
|
||||
#define CJSON_VERSION_PATCH 0
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/* cJSON Types: */
|
||||
#define cJSON_False 0
|
||||
#define cJSON_True 1
|
||||
#define cJSON_NULL 2
|
||||
#define cJSON_Number 3
|
||||
#define cJSON_String 4
|
||||
#define cJSON_Array 5
|
||||
#define cJSON_Object 6
|
||||
#define cJSON_Invalid (0)
|
||||
#define cJSON_False (1 << 0)
|
||||
#define cJSON_True (1 << 1)
|
||||
#define cJSON_NULL (1 << 2)
|
||||
#define cJSON_Number (1 << 3)
|
||||
#define cJSON_String (1 << 4)
|
||||
#define cJSON_Array (1 << 5)
|
||||
#define cJSON_Object (1 << 6)
|
||||
#define cJSON_Raw (1 << 7) /* raw json */
|
||||
|
||||
#define cJSON_IsReference 256
|
||||
#define cJSON_StringIsConst 512
|
||||
|
||||
/* The cJSON structure: */
|
||||
typedef struct cJSON {
|
||||
struct cJSON *next,*prev; /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
|
||||
struct cJSON *child; /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
|
||||
typedef struct cJSON
|
||||
{
|
||||
/* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
|
||||
struct cJSON *next;
|
||||
struct cJSON *prev;
|
||||
/* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
|
||||
struct cJSON *child;
|
||||
|
||||
int type; /* The type of the item, as above. */
|
||||
/* The type of the item, as above. */
|
||||
int type;
|
||||
|
||||
char *valuestring; /* The item's string, if type==cJSON_String */
|
||||
int valueint; /* The item's number, if type==cJSON_Number */
|
||||
double valuedouble; /* The item's number, if type==cJSON_Number */
|
||||
/* The item's string, if type==cJSON_String and type == cJSON_Raw */
|
||||
char *valuestring;
|
||||
/* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead */
|
||||
int valueint;
|
||||
/* The item's number, if type==cJSON_Number */
|
||||
double valuedouble;
|
||||
|
||||
char *string; /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
|
||||
/* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
|
||||
char *string;
|
||||
} cJSON;
|
||||
|
||||
typedef struct cJSON_Hooks {
|
||||
typedef struct cJSON_Hooks
|
||||
{
|
||||
void *(*malloc_fn)(size_t sz);
|
||||
void (*free_fn)(void *ptr);
|
||||
} cJSON_Hooks;
|
||||
|
||||
typedef int cJSON_bool;
|
||||
|
||||
#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32))
|
||||
#define __WINDOWS__
|
||||
#endif
|
||||
#ifdef __WINDOWS__
|
||||
|
||||
/* When compiling for windows, we specify a specific calling convention to avoid issues where we are being called from a project with a different default calling convention. For windows you have 2 define options:
|
||||
|
||||
CJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever dllexport symbols
|
||||
CJSON_EXPORT_SYMBOLS - Define this on library build when you want to dllexport symbols (default)
|
||||
CJSON_IMPORT_SYMBOLS - Define this if you want to dllimport symbol
|
||||
|
||||
For *nix builds that support visibility attribute, you can define similar behavior by
|
||||
|
||||
setting default visibility to hidden by adding
|
||||
-fvisibility=hidden (for gcc)
|
||||
or
|
||||
-xldscope=hidden (for sun cc)
|
||||
to CFLAGS
|
||||
|
||||
then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJSON_EXPORT_SYMBOLS does
|
||||
|
||||
*/
|
||||
|
||||
/* export symbols by default, this is necessary for copy pasting the C and header file */
|
||||
#if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS)
|
||||
#define CJSON_EXPORT_SYMBOLS
|
||||
#endif
|
||||
|
||||
#if defined(CJSON_HIDE_SYMBOLS)
|
||||
#define CJSON_PUBLIC(type) type __stdcall
|
||||
#elif defined(CJSON_EXPORT_SYMBOLS)
|
||||
#define CJSON_PUBLIC(type) __declspec(dllexport) type __stdcall
|
||||
#elif defined(CJSON_IMPORT_SYMBOLS)
|
||||
#define CJSON_PUBLIC(type) __declspec(dllimport) type __stdcall
|
||||
#endif
|
||||
#else /* !WIN32 */
|
||||
#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY)
|
||||
#define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type
|
||||
#else
|
||||
#define CJSON_PUBLIC(type) type
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Limits how deeply nested arrays/objects can be before cJSON rejects to parse them.
|
||||
* This is to prevent stack overflows. */
|
||||
#ifndef CJSON_NESTING_LIMIT
|
||||
#define CJSON_NESTING_LIMIT 1000
|
||||
#endif
|
||||
|
||||
/* returns the version of cJSON as a string */
|
||||
CJSON_PUBLIC(const char*) cJSON_Version(void);
|
||||
|
||||
/* Supply malloc, realloc and free functions to cJSON */
|
||||
extern void cJSON_InitHooks(cJSON_Hooks* hooks);
|
||||
CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks);
|
||||
|
||||
/* Memory Management: the caller is always responsible to free the results from all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print (with stdlib free, cJSON_Hooks.free_fn, or cJSON_free as appropriate). The exception is cJSON_PrintPreallocated, where the caller has full responsibility of the buffer. */
|
||||
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value);
|
||||
/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
|
||||
/* If you supply a ptr in return_parse_end and parsing fails, then return_parse_end will contain a pointer to the error so will match cJSON_GetErrorPtr(). */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated);
|
||||
|
||||
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. Call cJSON_Delete when finished. */
|
||||
extern cJSON *cJSON_Parse(const char *value);
|
||||
/* Render a cJSON entity to text for transfer/storage. Free the char* when finished. */
|
||||
extern char *cJSON_Print(cJSON *item);
|
||||
/* Render a cJSON entity to text for transfer/storage without any formatting. Free the char* when finished. */
|
||||
extern char *cJSON_PrintUnformatted(cJSON *item);
|
||||
/* Render a cJSON entity to text for transfer/storage. */
|
||||
CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item);
|
||||
/* Render a cJSON entity to text for transfer/storage without any formatting. */
|
||||
CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item);
|
||||
/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted */
|
||||
extern char *cJSON_PrintBuffered(cJSON *item,int prebuffer,int fmt);
|
||||
CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt);
|
||||
/* Render a cJSON entity to text using a buffer already allocated in memory with given length. Returns 1 on success and 0 on failure. */
|
||||
/* NOTE: cJSON is not always 100% accurate in estimating how much memory it will use, so to be safe allocate 5 bytes more than you actually need */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format);
|
||||
/* Delete a cJSON entity and all subentities. */
|
||||
extern void cJSON_Delete(cJSON *c);
|
||||
CJSON_PUBLIC(void) cJSON_Delete(cJSON *c);
|
||||
|
||||
/* Returns the number of items in an array (or object). */
|
||||
extern int cJSON_GetArraySize(cJSON *array);
|
||||
CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array);
|
||||
/* Retrieve item number "item" from array "array". Returns NULL if unsuccessful. */
|
||||
extern cJSON *cJSON_GetArrayItem(cJSON *array,int item);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index);
|
||||
/* Get item "string" from object. Case insensitive. */
|
||||
extern cJSON *cJSON_GetObjectItem(cJSON *object,const char *string);
|
||||
|
||||
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string);
|
||||
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
|
||||
extern const char *cJSON_GetErrorPtr(void);
|
||||
CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void);
|
||||
|
||||
/* These functions check the type of an item */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item);
|
||||
|
||||
/* These calls create a cJSON item of the appropriate type. */
|
||||
extern cJSON *cJSON_CreateNull(void);
|
||||
extern cJSON *cJSON_CreateTrue(void);
|
||||
extern cJSON *cJSON_CreateFalse(void);
|
||||
extern cJSON *cJSON_CreateBool(int b);
|
||||
extern cJSON *cJSON_CreateNumber(double num);
|
||||
extern cJSON *cJSON_CreateDouble(double num,int i_num);
|
||||
extern cJSON *cJSON_CreateString(const char *string);
|
||||
extern cJSON *cJSON_CreateArray(void);
|
||||
extern cJSON *cJSON_CreateObject(void);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string);
|
||||
/* raw json */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void);
|
||||
|
||||
/* These utilities create an Array of count items. */
|
||||
extern cJSON *cJSON_CreateIntArray(const int *numbers,int count);
|
||||
extern cJSON *cJSON_CreateFloatArray(const float *numbers,int count);
|
||||
extern cJSON *cJSON_CreateDoubleArray(const double *numbers,int count);
|
||||
extern cJSON *cJSON_CreateStringArray(const char **strings,int count);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char **strings, int count);
|
||||
|
||||
/* Append item to the specified array/object. */
|
||||
extern void cJSON_AddItemToArray(cJSON *array, cJSON *item);
|
||||
extern void cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item);
|
||||
extern void cJSON_AddItemToObjectCS(cJSON *object,const char *string,cJSON *item); /* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object */
|
||||
CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item);
|
||||
CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item);
|
||||
/* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object.
|
||||
* WARNING: When this function was used, make sure to always check that (item->type & cJSON_StringIsConst) is zero before
|
||||
* writing to `item->string` */
|
||||
CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item);
|
||||
/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
|
||||
extern void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
|
||||
extern void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item);
|
||||
CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
|
||||
CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item);
|
||||
|
||||
/* Remove/Detatch items from Arrays/Objects. */
|
||||
extern cJSON *cJSON_DetachItemFromArray(cJSON *array,int which);
|
||||
extern void cJSON_DeleteItemFromArray(cJSON *array,int which);
|
||||
extern cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string);
|
||||
extern void cJSON_DeleteItemFromObject(cJSON *object,const char *string);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which);
|
||||
CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string);
|
||||
CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string);
|
||||
CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string);
|
||||
|
||||
/* Update array items. */
|
||||
extern void cJSON_InsertItemInArray(cJSON *array,int which,cJSON *newitem); /* Shifts pre-existing items to the right. */
|
||||
extern void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem);
|
||||
extern void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
|
||||
CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement);
|
||||
CJSON_PUBLIC(void) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem);
|
||||
CJSON_PUBLIC(void) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
|
||||
CJSON_PUBLIC(void) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,const char *string,cJSON *newitem);
|
||||
|
||||
/* Duplicate a cJSON item */
|
||||
extern cJSON *cJSON_Duplicate(cJSON *item,int recurse);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse);
|
||||
/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
|
||||
need to be released. With recurse!=0, it will duplicate any children connected to the item.
|
||||
The item->next and ->prev pointers are always zero on return from Duplicate. */
|
||||
/* Recursively compare two cJSON items for equality. If either a or b is NULL or invalid, they will be considered unequal.
|
||||
* case_sensitive determines if object keys are treated case sensitive (1) or case insensitive (0) */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive);
|
||||
|
||||
/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
|
||||
extern cJSON *cJSON_ParseWithOpts(const char *value,const char **return_parse_end,int require_null_terminated);
|
||||
|
||||
extern void cJSON_Minify(char *json);
|
||||
CJSON_PUBLIC(void) cJSON_Minify(char *json);
|
||||
|
||||
/* Macros for creating things quickly. */
|
||||
#define cJSON_AddNullToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateNull())
|
||||
@ -138,10 +241,20 @@ extern void cJSON_Minify(char *json);
|
||||
#define cJSON_AddBoolToObject(object,name,b) cJSON_AddItemToObject(object, name, cJSON_CreateBool(b))
|
||||
#define cJSON_AddNumberToObject(object,name,n) cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n))
|
||||
#define cJSON_AddStringToObject(object,name,s) cJSON_AddItemToObject(object, name, cJSON_CreateString(s))
|
||||
#define cJSON_AddRawToObject(object,name,s) cJSON_AddItemToObject(object, name, cJSON_CreateRaw(s))
|
||||
|
||||
/* When assigning an integer value, it needs to be propagated to valuedouble too. */
|
||||
#define cJSON_SetIntValue(object,val) ((object)?(object)->valueint=(object)->valuedouble=(val):(val))
|
||||
#define cJSON_SetNumberValue(object,val) ((object)?(object)->valueint=(object)->valuedouble=(val):(val))
|
||||
#define cJSON_SetIntValue(object, number) ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number))
|
||||
/* helper for the cJSON_SetNumberValue macro */
|
||||
CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number);
|
||||
#define cJSON_SetNumberValue(object, number) ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number))
|
||||
|
||||
/* Macro for iterating over an array or object */
|
||||
#define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
|
||||
|
||||
/* malloc/free objects using the malloc/free functions that have been set with cJSON_InitHooks */
|
||||
CJSON_PUBLIC(void *) cJSON_malloc(size_t size);
|
||||
CJSON_PUBLIC(void) cJSON_free(void *object);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1,12 +1,40 @@
|
||||
/*
|
||||
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "cJSON.h"
|
||||
|
||||
/* Implement RFC6901 (https://tools.ietf.org/html/rfc6901) JSON Pointer spec. */
|
||||
cJSON *cJSONUtils_GetPointer(cJSON *object,const char *pointer);
|
||||
CJSON_PUBLIC(cJSON *) cJSONUtils_GetPointer(cJSON * const object, const char *pointer);
|
||||
CJSON_PUBLIC(cJSON *) cJSONUtils_GetPointerCaseSensitive(cJSON * const object, const char *pointer);
|
||||
|
||||
/* Implement RFC6902 (https://tools.ietf.org/html/rfc6902) JSON Patch spec. */
|
||||
cJSON* cJSONUtils_GeneratePatches(cJSON *from,cJSON *to);
|
||||
void cJSONUtils_AddPatchToArray(cJSON *array,const char *op,const char *path,cJSON *val); /* Utility for generating patch array entries. */
|
||||
int cJSONUtils_ApplyPatches(cJSON *object,cJSON *patches); /* Returns 0 for success. */
|
||||
/* NOTE: This modifies objects in 'from' and 'to' by sorting the elements by their key */
|
||||
CJSON_PUBLIC(cJSON *) cJSONUtils_GeneratePatches(cJSON * const from, cJSON * const to);
|
||||
CJSON_PUBLIC(cJSON *) cJSONUtils_GeneratePatchesCaseSensitive(cJSON * const from, cJSON * const to);
|
||||
/* Utility for generating patch array entries. */
|
||||
CJSON_PUBLIC(void) cJSONUtils_AddPatchToArray(cJSON * const array, const char * const operation, const char * const path, const cJSON * const value);
|
||||
/* Returns 0 for success. */
|
||||
CJSON_PUBLIC(int) cJSONUtils_ApplyPatches(cJSON * const object, const cJSON * const patches);
|
||||
CJSON_PUBLIC(int) cJSONUtils_ApplyPatchesCaseSensitive(cJSON * const object, const cJSON * const patches);
|
||||
|
||||
/*
|
||||
// Note that ApplyPatches is NOT atomic on failure. To implement an atomic ApplyPatches, use:
|
||||
@ -14,17 +42,33 @@ int cJSONUtils_ApplyPatches(cJSON *object,cJSON *patches); /* Returns 0 for succ
|
||||
//{
|
||||
// cJSON *modme = cJSON_Duplicate(*object, 1);
|
||||
// int error = cJSONUtils_ApplyPatches(modme, patches);
|
||||
// if (!error) {cJSON_Delete(*object);*object=modme;}
|
||||
// else cJSON_Delete(modme);
|
||||
// if (!error)
|
||||
// {
|
||||
// cJSON_Delete(*object);
|
||||
// *object = modme;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// cJSON_Delete(modme);
|
||||
// }
|
||||
//
|
||||
// return error;
|
||||
//}
|
||||
// Code not added to library since this strategy is a LOT slower.
|
||||
*/
|
||||
|
||||
/* Implement RFC7386 (https://tools.ietf.org/html/rfc7396) JSON Merge Patch spec. */
|
||||
cJSON* cJSONUtils_MergePatch(cJSON *target, cJSON *patch); /* target will be modified by patch. return value is new ptr for target. */
|
||||
cJSON *cJSONUtils_GenerateMergePatch(cJSON *from,cJSON *to); /* generates a patch to move from -> to */
|
||||
/* target will be modified by patch. return value is new ptr for target. */
|
||||
CJSON_PUBLIC(cJSON *) cJSONUtils_MergePatch(cJSON *target, const cJSON * const patch);
|
||||
CJSON_PUBLIC(cJSON *) cJSONUtils_MergePatchCaseSensitive(cJSON *target, const cJSON * const patch);
|
||||
/* generates a patch to move from -> to */
|
||||
/* NOTE: This modifies objects in 'from' and 'to' by sorting the elements by their key */
|
||||
CJSON_PUBLIC(cJSON *) cJSONUtils_GenerateMergePatch(cJSON * const from, cJSON * const to);
|
||||
CJSON_PUBLIC(cJSON *) cJSONUtils_GenerateMergePatchCaseSensitive(cJSON * const from, cJSON * const to);
|
||||
|
||||
char *cJSONUtils_FindPointerFromObjectTo(cJSON *object,cJSON *target); /* Given a root object and a target object, construct a pointer from one to the other. */
|
||||
/* Given a root object and a target object, construct a pointer from one to the other. */
|
||||
CJSON_PUBLIC(char *) cJSONUtils_FindPointerFromObjectTo(const cJSON * const object, const cJSON * const target);
|
||||
|
||||
void cJSONUtils_SortObject(cJSON *object); /* Sorts the members of the object into alphabetical order. */
|
||||
/* Sorts the members of the object into alphabetical order. */
|
||||
CJSON_PUBLIC(void) cJSONUtils_SortObject(cJSON * const object);
|
||||
CJSON_PUBLIC(void) cJSONUtils_SortObjectCaseSensitive(cJSON * const object);
|
||||
|
@ -100,8 +100,16 @@ void esp_log_write(esp_log_level_t level, const char* tag, const char* format, .
|
||||
|
||||
#include "esp_log_internal.h"
|
||||
|
||||
#ifndef LOG_LOCAL_LEVEL
|
||||
#ifndef BOOTLOADER_BUILD
|
||||
#define LOG_LOCAL_LEVEL CONFIG_LOG_DEFAULT_LEVEL
|
||||
#else
|
||||
#define LOG_LOCAL_LEVEL CONFIG_LOG_BOOTLOADER_LEVEL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Log a buffer of hex bytes at specified level, seprated into 16 bytes each line.
|
||||
* @brief Log a buffer of hex bytes at specified level, separated into 16 bytes each line.
|
||||
*
|
||||
* @param tag description tag
|
||||
*
|
||||
@ -116,7 +124,7 @@ void esp_log_write(esp_log_level_t level, const char* tag, const char* format, .
|
||||
if ( LOG_LOCAL_LEVEL >= level ) esp_log_buffer_hex_internal( tag, buffer, buff_len, level ); } while(0)
|
||||
|
||||
/**
|
||||
* @brief Log a buffer of characters at specified level, seprated into 16 bytes each line. Buffer should contain only printable characters.
|
||||
* @brief Log a buffer of characters at specified level, separated into 16 bytes each line. Buffer should contain only printable characters.
|
||||
*
|
||||
* @param tag description tag
|
||||
*
|
||||
@ -219,14 +227,6 @@ void esp_log_write(esp_log_level_t level, const char* tag, const char* format, .
|
||||
|
||||
#define LOG_FORMAT(letter, format) LOG_COLOR_ ## letter #letter " (%d) %s: " format LOG_RESET_COLOR "\n"
|
||||
|
||||
#ifndef LOG_LOCAL_LEVEL
|
||||
#ifndef BOOTLOADER_BUILD
|
||||
#define LOG_LOCAL_LEVEL ((esp_log_level_t) CONFIG_LOG_DEFAULT_LEVEL)
|
||||
#else
|
||||
#define LOG_LOCAL_LEVEL ((esp_log_level_t) CONFIG_LOG_BOOTLOADER_LEVEL)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/// macro to output logs in startup code, before heap allocator and syscalls have been initialized. log at ``ESP_LOG_ERROR`` level. @see ``printf``,``ESP_LOGE``
|
||||
#define ESP_EARLY_LOGE( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_ERROR) { ets_printf(LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
|
||||
/// macro to output logs in startup code at ``ESP_LOG_WARN`` level. @see ``ESP_EARLY_LOGE``,``ESP_LOGE``, ``printf``
|
||||
@ -263,7 +263,7 @@ void esp_log_write(esp_log_level_t level, const char* tag, const char* format, .
|
||||
#define ESP_LOGV( tag, format, ... ) ESP_EARLY_LOGV(tag, format, ##__VA_ARGS__)
|
||||
#endif // BOOTLOADER_BUILD
|
||||
|
||||
/** runtime macro to output logs at a speicfied level.
|
||||
/** runtime macro to output logs at a specified level.
|
||||
*
|
||||
* @param tag tag of the log, which can be used to change the log level by ``esp_log_level_set`` at runtime.
|
||||
*
|
||||
@ -282,7 +282,7 @@ void esp_log_write(esp_log_level_t level, const char* tag, const char* format, .
|
||||
else if (level==ESP_LOG_VERBOSE ) { esp_log_write(ESP_LOG_VERBOSE, tag, LOG_FORMAT(V, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }\
|
||||
else { esp_log_write(ESP_LOG_INFO, tag, LOG_FORMAT(I, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }}while(0)
|
||||
|
||||
/** runtime macro to output logs at a speicfied level. Also check the level with ``LOG_LOCAL_LEVEL``.
|
||||
/** runtime macro to output logs at a specified level. Also check the level with ``LOG_LOCAL_LEVEL``.
|
||||
*
|
||||
* @see ``printf``, ``ESP_LOG_LEVEL``
|
||||
*/
|
||||
|
@ -15,7 +15,7 @@
|
||||
#ifndef __ESP_LOG_INTERNAL_H__
|
||||
#define __ESP_LOG_INTERNAL_H__
|
||||
|
||||
//these two functions do not check level versus ESP_LOCAL_LEVEL, this should be done in esp_log.h
|
||||
//these functions do not check level versus ESP_LOCAL_LEVEL, this should be done in esp_log.h
|
||||
void esp_log_buffer_hex_internal(const char *tag, const void *buffer, uint16_t buff_len, esp_log_level_t level);
|
||||
void esp_log_buffer_char_internal(const char *tag, const void *buffer, uint16_t buff_len, esp_log_level_t level);
|
||||
void esp_log_buffer_hexdump_internal( const char *tag, const void *buffer, uint16_t buff_len, esp_log_level_t log_level);
|
||||
|
@ -14,6 +14,7 @@
|
||||
#ifndef __DHCPS_H__
|
||||
#define __DHCPS_H__
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
|
||||
typedef struct dhcps_state{
|
||||
@ -51,6 +52,7 @@ enum dhcps_offer_option{
|
||||
#define DHCPS_COARSE_TIMER_SECS 1
|
||||
#define DHCPS_MAX_LEASE 0x64
|
||||
#define DHCPS_LEASE_TIME_DEF (120)
|
||||
#define DHCPS_LEASE_UNIT CONFIG_LWIP_DHCPS_LEASE_UNIT
|
||||
|
||||
struct dhcps_pool{
|
||||
ip4_addr_t ip;
|
||||
|
@ -558,62 +558,110 @@ int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptse
|
||||
int lwip_ioctl_r(int s, long cmd, void *argp);
|
||||
int lwip_fcntl_r(int s, int cmd, int val);
|
||||
|
||||
#define accept(s,addr,addrlen) lwip_accept_r(s,addr,addrlen)
|
||||
#define bind(s,name,namelen) lwip_bind_r(s,name,namelen)
|
||||
#define shutdown(s,how) lwip_shutdown_r(s,how)
|
||||
#define getpeername(s,name,namelen) lwip_getpeername_r(s,name,namelen)
|
||||
#define getsockname(s,name,namelen) lwip_getsockname_r(s,name,namelen)
|
||||
#define setsockopt(s,level,optname,opval,optlen) lwip_setsockopt_r(s,level,optname,opval,optlen)
|
||||
#define getsockopt(s,level,optname,opval,optlen) lwip_getsockopt_r(s,level,optname,opval,optlen)
|
||||
#define closesocket(s) lwip_close_r(s)
|
||||
#define connect(s,name,namelen) lwip_connect_r(s,name,namelen)
|
||||
#define listen(s,backlog) lwip_listen_r(s,backlog)
|
||||
#define recv(s,mem,len,flags) lwip_recv_r(s,mem,len,flags)
|
||||
#define recvfrom(s,mem,len,flags,from,fromlen) lwip_recvfrom_r(s,mem,len,flags,from,fromlen)
|
||||
#define send(s,dataptr,size,flags) lwip_send_r(s,dataptr,size,flags)
|
||||
#define sendmsg(s,message,flags) lwip_sendmsg_r(s,message,flags)
|
||||
#define sendto(s,dataptr,size,flags,to,tolen) lwip_sendto_r(s,dataptr,size,flags,to,tolen)
|
||||
#define socket(domain,type,protocol) lwip_socket(domain,type,protocol)
|
||||
#define select(maxfdp1,readset,writeset,exceptset,timeout) lwip_select(maxfdp1,readset,writeset,exceptset,timeout)
|
||||
#define ioctlsocket(s,cmd,argp) lwip_ioctl_r(s,cmd,argp)
|
||||
static inline int accept(int s,struct sockaddr *addr,socklen_t *addrlen)
|
||||
{ return lwip_accept_r(s,addr,addrlen); }
|
||||
static inline int bind(int s,const struct sockaddr *name, socklen_t namelen)
|
||||
{ return lwip_bind_r(s,name,namelen); }
|
||||
static inline int shutdown(int s,int how)
|
||||
{ return lwip_shutdown_r(s,how); }
|
||||
static inline int getpeername(int s,struct sockaddr *name,socklen_t *namelen)
|
||||
{ return lwip_getpeername_r(s,name,namelen); }
|
||||
static inline int getsockname(int s,struct sockaddr *name,socklen_t *namelen)
|
||||
{ return lwip_getsockname_r(s,name,namelen); }
|
||||
static inline int setsockopt(int s,int level,int optname,const void *opval,socklen_t optlen)
|
||||
{ return lwip_setsockopt_r(s,level,optname,opval,optlen); }
|
||||
static inline int getsockopt(int s,int level,int optname,void *opval,socklen_t *optlen)
|
||||
{ return lwip_getsockopt_r(s,level,optname,opval,optlen); }
|
||||
static inline int closesocket(int s)
|
||||
{ return lwip_close_r(s); }
|
||||
static inline int connect(int s,const struct sockaddr *name,socklen_t namelen)
|
||||
{ return lwip_connect_r(s,name,namelen); }
|
||||
static inline int listen(int s,int backlog)
|
||||
{ return lwip_listen_r(s,backlog); }
|
||||
static inline int recv(int s,void *mem,size_t len,int flags)
|
||||
{ return lwip_recv_r(s,mem,len,flags); }
|
||||
static inline int recvfrom(int s,void *mem,size_t len,int flags,struct sockaddr *from,socklen_t *fromlen)
|
||||
{ return lwip_recvfrom_r(s,mem,len,flags,from,fromlen); }
|
||||
static inline int send(int s,const void *dataptr,size_t size,int flags)
|
||||
{ return lwip_send_r(s,dataptr,size,flags); }
|
||||
static inline int sendmsg(int s,const struct msghdr *message,int flags)
|
||||
{ return lwip_sendmsg_r(s,message,flags); }
|
||||
static inline int sendto(int s,const void *dataptr,size_t size,int flags,const struct sockaddr *to,socklen_t tolen)
|
||||
{ return lwip_sendto_r(s,dataptr,size,flags,to,tolen); }
|
||||
static inline int socket(int domain,int type,int protocol)
|
||||
{ return lwip_socket(domain,type,protocol); }
|
||||
static inline int select(int maxfdp1,fd_set *readset,fd_set *writeset,fd_set *exceptset,struct timeval *timeout)
|
||||
{ return lwip_select(maxfdp1,readset,writeset,exceptset,timeout); }
|
||||
static inline int ioctlsocket(int s,long cmd,void *argp)
|
||||
{ return lwip_ioctl_r(s,cmd,argp); }
|
||||
|
||||
#if LWIP_POSIX_SOCKETS_IO_NAMES
|
||||
#define read(s,mem,len) lwip_read_r(s,mem,len)
|
||||
#define write(s,dataptr,len) lwip_write_r(s,dataptr,len)
|
||||
#define writev(s,iov,iovcnt) lwip_writev_r(s,iov,iovcnt)
|
||||
#define close(s) lwip_close_r(s)
|
||||
#define fcntl(s,cmd,val) lwip_fcntl_r(s,cmd,val)
|
||||
#define ioctl(s,cmd,argp) lwip_ioctl_r(s,cmd,argp)
|
||||
#endif /* LWIP_POSIX_SOCKETS_IO_NAMES */
|
||||
static inline int read(int s,void *mem,size_t len)
|
||||
{ return lwip_read_r(s,mem,len); }
|
||||
static inline int write(int s,const void *dataptr,size_t len)
|
||||
{ return lwip_write_r(s,dataptr,len); }
|
||||
static inline int writev(int s,const struct iovec *iov,int iovcnt)
|
||||
{ return lwip_writev_r(s,iov,iovcnt); }
|
||||
static inline int close(int s)
|
||||
{ return lwip_close_r(s); }
|
||||
static inline int fcntl(int s,int cmd,int val)
|
||||
{ return lwip_fcntl_r(s,cmd,val); }
|
||||
static inline int ioctl(int s,long cmd,void *argp)
|
||||
{ return lwip_ioctl_r(s,cmd,argp); }
|
||||
#endif /* { RETURN LWIP_POSIX_SOCKETS_IO_NAMES */
|
||||
|
||||
#else
|
||||
|
||||
#define accept(s,addr,addrlen) lwip_accept(s,addr,addrlen)
|
||||
#define bind(s,name,namelen) lwip_bind(s,name,namelen)
|
||||
#define shutdown(s,how) lwip_shutdown(s,how)
|
||||
#define getpeername(s,name,namelen) lwip_getpeername(s,name,namelen)
|
||||
#define getsockname(s,name,namelen) lwip_getsockname(s,name,namelen)
|
||||
#define setsockopt(s,level,optname,opval,optlen) lwip_setsockopt(s,level,optname,opval,optlen)
|
||||
#define getsockopt(s,level,optname,opval,optlen) lwip_getsockopt(s,level,optname,opval,optlen)
|
||||
#define closesocket(s) lwip_close(s)
|
||||
#define connect(s,name,namelen) lwip_connect(s,name,namelen)
|
||||
#define listen(s,backlog) lwip_listen(s,backlog)
|
||||
#define recv(s,mem,len,flags) lwip_recv(s,mem,len,flags)
|
||||
#define recvfrom(s,mem,len,flags,from,fromlen) lwip_recvfrom(s,mem,len,flags,from,fromlen)
|
||||
#define send(s,dataptr,size,flags) lwip_send(s,dataptr,size,flags)
|
||||
#define sendmsg(s,message,flags) lwip_sendmsg(s,message,flags)
|
||||
#define sendto(s,dataptr,size,flags,to,tolen) lwip_sendto(s,dataptr,size,flags,to,tolen)
|
||||
#define socket(domain,type,protocol) lwip_socket(domain,type,protocol)
|
||||
#define select(maxfdp1,readset,writeset,exceptset,timeout) lwip_select(maxfdp1,readset,writeset,exceptset,timeout)
|
||||
#define ioctlsocket(s,cmd,argp) lwip_ioctl(s,cmd,argp)
|
||||
static inline int accept(int s,struct sockaddr *addr,socklen_t *addrlen)
|
||||
{ return lwip_accept(s,addr,addrlen); }
|
||||
static inline int bind(int s,const struct sockaddr *name,socklen_t namelen)
|
||||
{ return lwip_bind(s,name,namelen); }
|
||||
static inline int shutdown(int s,int how)
|
||||
{ return lwip_shutdown(s,how); }
|
||||
static inline int getpeername(int s,struct sockaddr *name,socklen_t *namelen)
|
||||
{ return lwip_getpeername(s,name,namelen); }
|
||||
static inline int getsockname(int s,struct sockaddr *name,socklen_t *namelen)
|
||||
{ return lwip_getsockname(s,name,namelen); }
|
||||
static inline int setsockopt(int s,int level,int optname,const void *opval,socklen_t optlen)
|
||||
{ return lwip_setsockopt(s,level,optname,opval,optlen); }
|
||||
static inline int getsockopt(int s,int level,int optname,void *opval,socklen_t *optlen)
|
||||
{ return lwip_getsockopt(s,level,optname,opval,optlen); }
|
||||
static inline int closesocket(int s)
|
||||
{ return lwip_close(s); }
|
||||
static inline int connect(int s,const struct sockaddr *name,socklen_t namelen)
|
||||
{ return lwip_connect(s,name,namelen); }
|
||||
static inline int listen(int s,int backlog)
|
||||
{ return lwip_listen(s,backlog); }
|
||||
static inline int recv(int s,void *mem,size_t len,int flags)
|
||||
{ return lwip_recv(s,mem,len,flags); }
|
||||
static inline int recvfrom(int s,void *mem,size_t len,int flags,struct sockaddr *from,socklen_t *fromlen)
|
||||
{ return lwip_recvfrom(s,mem,len,flags,from,fromlen); }
|
||||
static inline int send(int s,const void *dataptr,size_t size,int flags)
|
||||
{ return lwip_send(s,dataptr,size,flags); }
|
||||
static inline int sendmsg(int s,const struct msghdr *message,int flags)
|
||||
{ return lwip_sendmsg(s,message,flags); }
|
||||
static inline int sendto(int s,const void *dataptr,size_t size,int flags,const struct sockaddr *to,socklen_t tolen)
|
||||
{ return lwip_sendto(s,dataptr,size,flags,to,tolen); }
|
||||
static inline int socket(int domain,int type,int protocol)
|
||||
{ return lwip_socket(domain,type,protocol); }
|
||||
static inline int select(int maxfdp1,fd_set t*readset,fd_set *writeset,fd_set *exceptset,struct timeval *timeout)
|
||||
{ return lwip_select(maxfdp1,readset,writeset,exceptset,timeout); }
|
||||
static inline int ioctlsocket(int s,long cmd,void *argp)
|
||||
{ return lwip_ioctl(s,cmd,argp); }
|
||||
|
||||
#if LWIP_POSIX_SOCKETS_IO_NAMES
|
||||
#define read(s,mem,len) lwip_read(s,mem,len)
|
||||
#define write(s,dataptr,len) lwip_write(s,dataptr,len)
|
||||
#define writev(s,iov,iovcnt) lwip_writev(s,iov,iovcnt)
|
||||
#define close(s) lwip_close(s)
|
||||
#define fcntl(s,cmd,val) lwip_fcntl(s,cmd,val)
|
||||
#define ioctl(s,cmd,argp) lwip_ioctl(s,cmd,argp)
|
||||
static inline int read(int s,void *mem,size_t len)
|
||||
{ return lwip_read(s,mem,len); }
|
||||
static inline int write(int s,const void *dataptr,size_t len)
|
||||
{ return lwip_write(s,dataptr,len); }
|
||||
static inline int writev(int s,const struct iovec *iov,int iovcnt)
|
||||
{ return lwip_writev(s,iov,iovcnt); }
|
||||
static inline int close(int s)
|
||||
{ return lwip_close(s); }
|
||||
static inline int fcntl(int s,long cmd,void *val)
|
||||
{ return lwip_fcntl(s,cmd,val); }
|
||||
static inline int ioctl(int s,int cmd,int argp)
|
||||
{ return lwip_ioctl(s,cmd,argp); }
|
||||
#endif /* LWIP_POSIX_SOCKETS_IO_NAMES */
|
||||
#endif /* ESP_THREAD_SAFE */
|
||||
|
||||
|
@ -11,6 +11,12 @@
|
||||
// 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_DEBUG_H_
|
||||
#define _ESP_DEBUG_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#ifdef CONFIG_MBEDTLS_DEBUG
|
||||
@ -43,3 +49,9 @@ void mbedtls_esp_disable_debug_log(mbedtls_ssl_config *conf);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_DEBUG_H__ */
|
||||
|
@ -20,35 +20,69 @@ extern "C" {
|
||||
|
||||
#ifndef MDNS_TEST_MODE
|
||||
#include <tcpip_adapter.h>
|
||||
#include "esp_event.h"
|
||||
#else
|
||||
#include "esp32_compat.h"
|
||||
#endif
|
||||
|
||||
struct mdns_server_s;
|
||||
typedef struct mdns_server_s mdns_server_t;
|
||||
#define MDNS_TYPE_A 0x0001
|
||||
#define MDNS_TYPE_PTR 0x000C
|
||||
#define MDNS_TYPE_TXT 0x0010
|
||||
#define MDNS_TYPE_AAAA 0x001C
|
||||
#define MDNS_TYPE_SRV 0x0021
|
||||
#define MDNS_TYPE_OPT 0x0029
|
||||
#define MDNS_TYPE_NSEC 0x002F
|
||||
#define MDNS_TYPE_ANY 0x00FF
|
||||
|
||||
/**
|
||||
* @brief mDNS enum to specify the ip_protocol type
|
||||
*/
|
||||
typedef enum {
|
||||
MDNS_IP_PROTOCOL_V4,
|
||||
MDNS_IP_PROTOCOL_V6,
|
||||
MDNS_IP_PROTOCOL_MAX
|
||||
} mdns_ip_protocol_t;
|
||||
|
||||
/**
|
||||
* @brief mDNS basic text item structure
|
||||
* Used in mdns_service_add()
|
||||
*/
|
||||
typedef struct {
|
||||
char * key; /*!< item key name */
|
||||
char * value; /*!< item value string */
|
||||
} mdns_txt_item_t;
|
||||
|
||||
/**
|
||||
* @brief mDNS query linked list IP item
|
||||
*/
|
||||
typedef struct mdns_ip_addr_s {
|
||||
ip_addr_t addr; /*!< IP address */
|
||||
struct mdns_ip_addr_s * next; /*!< next IP, or NULL for the last IP in the list */
|
||||
} mdns_ip_addr_t;
|
||||
|
||||
/**
|
||||
* @brief mDNS query result structure
|
||||
*
|
||||
*/
|
||||
typedef struct mdns_result_s {
|
||||
const char * host; /*!< hostname */
|
||||
const char * instance; /*!< instance */
|
||||
const char * txt; /*!< txt data */
|
||||
uint16_t priority; /*!< service priority */
|
||||
uint16_t weight; /*!< service weight */
|
||||
struct mdns_result_s * next; /*!< next result, or NULL for the last result in the list */
|
||||
|
||||
tcpip_adapter_if_t tcpip_if; /*!< interface on which the result came (AP/STA/ETH) */
|
||||
mdns_ip_protocol_t ip_protocol; /*!< ip_protocol type of the interface (v4/v6) */
|
||||
// PTR
|
||||
char * instance_name; /*!< instance name */
|
||||
// SRV
|
||||
char * hostname; /*!< hostname */
|
||||
uint16_t port; /*!< service port */
|
||||
struct ip4_addr addr; /*!< ip4 address */
|
||||
struct ip6_addr addrv6; /*!< ip6 address */
|
||||
const struct mdns_result_s * next; /*!< next result, or NULL for the last result in the list */
|
||||
// TXT
|
||||
mdns_txt_item_t * txt; /*!< txt record */
|
||||
size_t txt_count; /*!< number of txt items */
|
||||
// A and AAAA
|
||||
mdns_ip_addr_t * addr; /*!< linked list of IP addreses found */
|
||||
} mdns_result_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize mDNS on given interface
|
||||
*
|
||||
* @param tcpip_if Interface that the server will listen on
|
||||
* @param server Server pointer to populate on success
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG when bad tcpip_if is given
|
||||
@ -56,20 +90,18 @@ typedef struct mdns_result_s {
|
||||
* - ESP_ERR_NO_MEM on memory error
|
||||
* - ESP_ERR_WIFI_NOT_INIT when WiFi is not initialized by eps_wifi_init
|
||||
*/
|
||||
esp_err_t mdns_init(tcpip_adapter_if_t tcpip_if, mdns_server_t ** server);
|
||||
esp_err_t mdns_init();
|
||||
|
||||
/**
|
||||
* @brief Stop and free mDNS server
|
||||
*
|
||||
* @param server mDNS Server to free
|
||||
*
|
||||
*/
|
||||
void mdns_free(mdns_server_t * server);
|
||||
void mdns_free();
|
||||
|
||||
/**
|
||||
* @brief Set the hostname for mDNS server
|
||||
* required if you want to advertise services
|
||||
*
|
||||
* @param server mDNS Server
|
||||
* @param hostname Hostname to set
|
||||
*
|
||||
* @return
|
||||
@ -77,41 +109,42 @@ void mdns_free(mdns_server_t * server);
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_ERR_NO_MEM memory error
|
||||
*/
|
||||
esp_err_t mdns_set_hostname(mdns_server_t * server, const char * hostname);
|
||||
esp_err_t mdns_hostname_set(const char * hostname);
|
||||
|
||||
/**
|
||||
* @brief Set the default instance name for mDNS server
|
||||
*
|
||||
* @param server mDNS Server
|
||||
* @param instance Instance name to set
|
||||
* @param instance_name Instance name to set
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_ERR_NO_MEM memory error
|
||||
*/
|
||||
esp_err_t mdns_set_instance(mdns_server_t * server, const char * instance);
|
||||
esp_err_t mdns_instance_name_set(const char * instance_name);
|
||||
|
||||
/**
|
||||
* @brief Add service to mDNS server
|
||||
*
|
||||
* @param server mDNS Server
|
||||
* @param service service type (_http, _ftp, etc)
|
||||
* @param instance_name instance name to set. If NULL,
|
||||
* global instance name or hostname will be used
|
||||
* @param service_type service type (_http, _ftp, etc)
|
||||
* @param proto service protocol (_tcp, _udp)
|
||||
* @param port service port
|
||||
* @param num_items number of items in TXT data
|
||||
* @param txt string array of TXT data (eg. {{"var","val"},{"other","2"}})
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_ERR_NO_MEM memory error
|
||||
*/
|
||||
esp_err_t mdns_service_add(mdns_server_t * server, const char * service, const char * proto, uint16_t port);
|
||||
esp_err_t mdns_service_add(const char * instance_name, const char * service_type, const char * proto, uint16_t port, mdns_txt_item_t txt[], size_t num_items);
|
||||
|
||||
/**
|
||||
* @brief Remove service from mDNS server
|
||||
*
|
||||
* @param server mDNS Server
|
||||
* @param service service type (_http, _ftp, etc)
|
||||
* @param service_type service type (_http, _ftp, etc)
|
||||
* @param proto service protocol (_tcp, _udp)
|
||||
*
|
||||
* @return
|
||||
@ -120,15 +153,14 @@ esp_err_t mdns_service_add(mdns_server_t * server, const char * service, const c
|
||||
* - ESP_ERR_NOT_FOUND Service not found
|
||||
* - ESP_FAIL unknown error
|
||||
*/
|
||||
esp_err_t mdns_service_remove(mdns_server_t * server, const char * service, const char * proto);
|
||||
esp_err_t mdns_service_remove(const char * service_type, const char * proto);
|
||||
|
||||
/**
|
||||
* @brief Set instance name for service
|
||||
*
|
||||
* @param server mDNS Server
|
||||
* @param service service type (_http, _ftp, etc)
|
||||
* @param service_type service type (_http, _ftp, etc)
|
||||
* @param proto service protocol (_tcp, _udp)
|
||||
* @param instance instance name to set
|
||||
* @param instance_name instance name to set
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
@ -136,30 +168,12 @@ esp_err_t mdns_service_remove(mdns_server_t * server, const char * service, cons
|
||||
* - ESP_ERR_NOT_FOUND Service not found
|
||||
* - ESP_ERR_NO_MEM memory error
|
||||
*/
|
||||
esp_err_t mdns_service_instance_set(mdns_server_t * server, const char * service, const char * proto, const char * instance);
|
||||
|
||||
/**
|
||||
* @brief Set TXT data for service
|
||||
*
|
||||
* @param server mDNS Server
|
||||
* @param service service type (_http, _ftp, etc)
|
||||
* @param proto service protocol (_tcp, _udp)
|
||||
* @param num_items number of items in TXT data
|
||||
* @param txt string array of TXT data (eg. {"var=val","other=2"})
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_ERR_NOT_FOUND Service not found
|
||||
* - ESP_ERR_NO_MEM memory error
|
||||
*/
|
||||
esp_err_t mdns_service_txt_set(mdns_server_t * server, const char * service, const char * proto, uint8_t num_items, const char ** txt);
|
||||
esp_err_t mdns_service_instance_name_set(const char * service_type, const char * proto, const char * instance_name);
|
||||
|
||||
/**
|
||||
* @brief Set service port
|
||||
*
|
||||
* @param server mDNS Server
|
||||
* @param service service type (_http, _ftp, etc)
|
||||
* @param service_type service type (_http, _ftp, etc)
|
||||
* @param proto service protocol (_tcp, _udp)
|
||||
* @param port service port
|
||||
*
|
||||
@ -168,69 +182,182 @@ esp_err_t mdns_service_txt_set(mdns_server_t * server, const char * service, con
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_ERR_NOT_FOUND Service not found
|
||||
*/
|
||||
esp_err_t mdns_service_port_set(mdns_server_t * server, const char * service, const char * proto, uint16_t port);
|
||||
esp_err_t mdns_service_port_set(const char * service_type, const char * proto, uint16_t port);
|
||||
|
||||
/**
|
||||
* @brief Replace all TXT items for service
|
||||
*
|
||||
* @param service_type service type (_http, _ftp, etc)
|
||||
* @param proto service protocol (_tcp, _udp)
|
||||
* @param num_items number of items in TXT data
|
||||
* @param txt array of TXT data (eg. {{"var","val"},{"other","2"}})
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_ERR_NOT_FOUND Service not found
|
||||
* - ESP_ERR_NO_MEM memory error
|
||||
*/
|
||||
esp_err_t mdns_service_txt_set(const char * service_type, const char * proto, mdns_txt_item_t txt[], uint8_t num_items);
|
||||
|
||||
/**
|
||||
* @brief Set/Add TXT item for service TXT record
|
||||
*
|
||||
* @param service_type service type (_http, _ftp, etc)
|
||||
* @param proto service protocol (_tcp, _udp)
|
||||
* @param key the key that you want to add/update
|
||||
* @param value the new value of the key
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_ERR_NOT_FOUND Service not found
|
||||
* - ESP_ERR_NO_MEM memory error
|
||||
*/
|
||||
esp_err_t mdns_service_txt_item_set(const char * service_type, const char * proto, const char * key, const char * value);
|
||||
|
||||
/**
|
||||
* @brief Remove TXT item for service TXT record
|
||||
*
|
||||
* @param service_type service type (_http, _ftp, etc)
|
||||
* @param proto service protocol (_tcp, _udp)
|
||||
* @param key the key that you want to remove
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_ERR_NOT_FOUND Service not found
|
||||
* - ESP_ERR_NO_MEM memory error
|
||||
*/
|
||||
esp_err_t mdns_service_txt_item_remove(const char * service_type, const char * proto, const char * key);
|
||||
|
||||
/**
|
||||
* @brief Remove and free all services from mDNS server
|
||||
*
|
||||
* @param server mDNS Server
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t mdns_service_remove_all(mdns_server_t * server);
|
||||
esp_err_t mdns_service_remove_all();
|
||||
|
||||
/**
|
||||
* @brief Query mDNS for host or service
|
||||
* All following query methods are derived from this one
|
||||
*
|
||||
* @param server mDNS Server
|
||||
* @param service service type or host name
|
||||
* @param proto service protocol or NULL if searching for host
|
||||
* @param timeout time to wait for answers. If 0, mdns_query_end MUST be called to end the search
|
||||
*
|
||||
* @return the number of results found
|
||||
*/
|
||||
size_t mdns_query(mdns_server_t * server, const char * service, const char * proto, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* @brief Stop mDNS Query started with timeout = 0
|
||||
*
|
||||
* @param server mDNS Server
|
||||
*
|
||||
* @return the number of results found
|
||||
*/
|
||||
size_t mdns_query_end(mdns_server_t * server);
|
||||
|
||||
/**
|
||||
* @brief get the number of results currently in memoty
|
||||
*
|
||||
* @param server mDNS Server
|
||||
*
|
||||
* @return the number of results
|
||||
*/
|
||||
size_t mdns_result_get_count(mdns_server_t * server);
|
||||
|
||||
/**
|
||||
* @brief Get mDNS Search result with given index
|
||||
*
|
||||
* @param server mDNS Server
|
||||
* @param num the index of the result
|
||||
*
|
||||
* @return the result or NULL if error
|
||||
*/
|
||||
const mdns_result_t * mdns_result_get(mdns_server_t * server, size_t num);
|
||||
|
||||
/**
|
||||
* @brief Remove and free all search results from mDNS server
|
||||
*
|
||||
* @param server mDNS Server
|
||||
* @param name service instance or host name (NULL for PTR queries)
|
||||
* @param service_type service type (_http, _arduino, _ftp etc.) (NULL for host queries)
|
||||
* @param proto service protocol (_tcp, _udp, etc.) (NULL for host queries)
|
||||
* @param type type of query (MDNS_TYPE_*)
|
||||
* @param timeout time in milliseconds to wait for answers.
|
||||
* @param max_results maximum results to be collected
|
||||
* @param results pointer to the results of the query
|
||||
* results must be freed using mdns_query_results_free below
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_ERR_INVALID_STATE mDNS is not running
|
||||
* - ESP_ERR_NO_MEM memory error
|
||||
* - ESP_ERR_INVALID_ARG timeout was not given
|
||||
*/
|
||||
esp_err_t mdns_result_free(mdns_server_t * server);
|
||||
esp_err_t mdns_query(const char * name, const char * service_type, const char * proto, uint16_t type, uint32_t timeout, size_t max_results, mdns_result_t ** results);
|
||||
|
||||
/**
|
||||
* @brief Free query results
|
||||
*
|
||||
* @param results linked list of results to be freed
|
||||
*/
|
||||
void mdns_query_results_free(mdns_result_t * results);
|
||||
|
||||
/**
|
||||
* @brief Query mDNS for service
|
||||
*
|
||||
* @param service_type service type (_http, _arduino, _ftp etc.)
|
||||
* @param proto service protocol (_tcp, _udp, etc.)
|
||||
* @param timeout time in milliseconds to wait for answer.
|
||||
* @param max_results maximum results to be collected
|
||||
* @param results pointer to the results of the query
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
* - ESP_ERR_INVALID_STATE mDNS is not running
|
||||
* - ESP_ERR_NO_MEM memory error
|
||||
* - ESP_ERR_INVALID_ARG parameter error
|
||||
*/
|
||||
esp_err_t mdns_query_ptr(const char * service_type, const char * proto, uint32_t timeout, size_t max_results, mdns_result_t ** results);
|
||||
|
||||
/**
|
||||
* @brief Query mDNS for SRV record
|
||||
*
|
||||
* @param instance_name service instance name
|
||||
* @param service_type service type (_http, _arduino, _ftp etc.)
|
||||
* @param proto service protocol (_tcp, _udp, etc.)
|
||||
* @param timeout time in milliseconds to wait for answer.
|
||||
* @param result pointer to the result of the query
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
* - ESP_ERR_INVALID_STATE mDNS is not running
|
||||
* - ESP_ERR_NO_MEM memory error
|
||||
* - ESP_ERR_INVALID_ARG parameter error
|
||||
*/
|
||||
esp_err_t mdns_query_srv(const char * instance_name, const char * service_type, const char * proto, uint32_t timeout, mdns_result_t ** result);
|
||||
|
||||
/**
|
||||
* @brief Query mDNS for TXT record
|
||||
*
|
||||
* @param instance_name service instance name
|
||||
* @param service_type service type (_http, _arduino, _ftp etc.)
|
||||
* @param proto service protocol (_tcp, _udp, etc.)
|
||||
* @param timeout time in milliseconds to wait for answer.
|
||||
* @param result pointer to the result of the query
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
* - ESP_ERR_INVALID_STATE mDNS is not running
|
||||
* - ESP_ERR_NO_MEM memory error
|
||||
* - ESP_ERR_INVALID_ARG parameter error
|
||||
*/
|
||||
esp_err_t mdns_query_txt(const char * instance_name, const char * service_type, const char * proto, uint32_t timeout, mdns_result_t ** result);
|
||||
|
||||
/**
|
||||
* @brief Query mDNS for A record
|
||||
*
|
||||
* @param host_name host name to look for
|
||||
* @param timeout time in milliseconds to wait for answer.
|
||||
* @param addr pointer to the resulting IP4 address
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
* - ESP_ERR_INVALID_STATE mDNS is not running
|
||||
* - ESP_ERR_NO_MEM memory error
|
||||
* - ESP_ERR_INVALID_ARG parameter error
|
||||
*/
|
||||
esp_err_t mdns_query_a(const char * host_name, uint32_t timeout, ip4_addr_t * addr);
|
||||
|
||||
/**
|
||||
* @brief Query mDNS for A record
|
||||
*
|
||||
* @param host_name host name to look for
|
||||
* @param timeout time in milliseconds to wait for answer. If 0, max_results needs to be defined
|
||||
* @param addr pointer to the resulting IP6 address
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
* - ESP_ERR_INVALID_STATE mDNS is not running
|
||||
* - ESP_ERR_NO_MEM memory error
|
||||
* - ESP_ERR_INVALID_ARG parameter error
|
||||
*/
|
||||
esp_err_t mdns_query_aaaa(const char * host_name, uint32_t timeout, ip6_addr_t * addr);
|
||||
|
||||
/**
|
||||
* @brief System event handler
|
||||
* This method controls the service state on all active interfaces and applications are required
|
||||
* to call it from the system event handler for normal operation of mDNS service.
|
||||
*
|
||||
* @param ctx The system event context
|
||||
* @param event The system event
|
||||
*/
|
||||
esp_err_t mdns_handle_system_event(void *ctx, system_event_t *event);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
22
tools/sdk/include/mdns/mdns_console.h
Normal file
22
tools/sdk/include/mdns/mdns_console.h
Normal file
@ -0,0 +1,22 @@
|
||||
// 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 _MDNS_CONSOLE_H_
|
||||
#define _MDNS_CONSOLE_H_
|
||||
|
||||
/**
|
||||
* @brief Register MDNS functions with the console component
|
||||
*/
|
||||
void mdns_console_register();
|
||||
|
||||
#endif /* _MDNS_CONSOLE_H_ */
|
@ -69,14 +69,19 @@ typedef volatile struct {
|
||||
struct {
|
||||
union {
|
||||
struct {
|
||||
uint32_t bit_num: 5; /*This register controls the range of the counter in high speed timer. the counter range is [0 2**reg_hstimer0_lim] the max bit width for counter is 20.*/
|
||||
uint32_t div_num: 18; /*This register is used to configure parameter for divider in high speed timer the least significant eight bits represent the decimal part.*/
|
||||
uint32_t duty_resolution: 5; /*This register controls resolution of PWN duty by defining the bit width of timer's counter. The max bit width of the counter is 20.*/
|
||||
uint32_t clock_divider: 18; /*This register is used to configure the divider of clock at the entry of timer. The least significant eight bits represent the decimal part.*/
|
||||
uint32_t pause: 1; /*This bit is used to pause the counter in high speed timer*/
|
||||
uint32_t rst: 1; /*This bit is used to reset high speed timer the counter will be 0 after reset.*/
|
||||
uint32_t tick_sel: 1; /*This bit is used to choose apb_clk or ref_tick for high speed timer. 1'b1:apb_clk 0:ref_tick*/
|
||||
uint32_t low_speed_update: 1; /*This bit is only useful for low speed timer channels, reserved for high speed timers*/
|
||||
uint32_t reserved26: 5;
|
||||
};
|
||||
struct {
|
||||
uint32_t bit_num: 5 __attribute__((deprecated)); /*Deprecated in ESP-IDF 3.0. This is an alias to 'duty_resolution' for backward compatibility with ESP-IDF 2.1.*/
|
||||
uint32_t div_num: 18 __attribute__((deprecated)); /*Deprecated in ESP-IDF 3.0. This is an alias to 'clock_divider' for backward compatibility with ESP-IDF 2.1.*/
|
||||
uint32_t place_holder: 9 __attribute__((deprecated)); /*A place holder to accommodate deprecated members*/
|
||||
};
|
||||
uint32_t val;
|
||||
} conf;
|
||||
union {
|
||||
|
@ -149,13 +149,24 @@ void rtc_clk_init(rtc_clk_config_t cfg);
|
||||
/**
|
||||
* @brief Get main XTAL frequency
|
||||
*
|
||||
* This is the value passed to rtc_clk_init function, or if the value was
|
||||
* RTC_XTAL_FREQ_AUTO, the detected XTAL frequency.
|
||||
* This is the value stored in RTC register RTC_XTAL_FREQ_REG by the bootloader. As passed to
|
||||
* rtc_clk_init function, or if the value was RTC_XTAL_FREQ_AUTO, the detected
|
||||
* XTAL frequency.
|
||||
*
|
||||
* @return XTAL frequency, one of rtc_xtal_freq_t
|
||||
*/
|
||||
rtc_xtal_freq_t rtc_clk_xtal_freq_get();
|
||||
|
||||
/**
|
||||
* @brief Update XTAL frequency
|
||||
*
|
||||
* Updates the XTAL value stored in RTC_XTAL_FREQ_REG. Usually this value is ignored
|
||||
* after startup.
|
||||
*
|
||||
* @param xtal_freq New frequency value
|
||||
*/
|
||||
void rtc_clk_xtal_freq_update(rtc_xtal_freq_t xtal_freq);
|
||||
|
||||
/**
|
||||
* @brief Enable or disable 32 kHz XTAL oscillator
|
||||
* @param en true to enable, false to disable
|
||||
|
@ -1830,7 +1830,16 @@
|
||||
#define RTC_CNTL_SCRATCH7_V 0xFFFFFFFF
|
||||
#define RTC_CNTL_SCRATCH7_S 0
|
||||
|
||||
#define RTC_CNTL_DIAG0_REG (DR_REG_RTCCNTL_BASE + 0xc0)
|
||||
#define RTC_CNTL_LOW_POWER_ST_REG (DR_REG_RTCCNTL_BASE + 0xc0)
|
||||
/* RTC_CNTL_RDY_FOR_WAKEUP : R/0; bitpos:[19]; default: 0 */
|
||||
/*description: 1 if RTC controller is ready to execute WAKE instruction, 0 otherwise */
|
||||
#define RTC_CNTL_RDY_FOR_WAKEUP (BIT(19))
|
||||
#define RTC_CNTL_RDY_FOR_WAKEUP_M (BIT(19))
|
||||
#define RTC_CNTL_RDY_FOR_WAKEUP_V 0x1
|
||||
#define RTC_CNTL_RDY_FOR_WAKEUP_S 19
|
||||
|
||||
/* Compatibility definition */
|
||||
#define RTC_CNTL_DIAG0_REG RTC_CNTL_LOW_POWER_ST_REG
|
||||
/* RTC_CNTL_LOW_POWER_DIAG0 : RO ;bitpos:[31:0] ;default: 0 ; */
|
||||
/*description: */
|
||||
#define RTC_CNTL_LOW_POWER_DIAG0 0xFFFFFFFF
|
||||
|
288
tools/sdk/include/soc/soc/rtc_i2c_reg.h
Normal file
288
tools/sdk/include/soc/soc/rtc_i2c_reg.h
Normal file
@ -0,0 +1,288 @@
|
||||
// Copyright 2016-2018 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 "soc.h"
|
||||
|
||||
/**
|
||||
* This file lists peripheral registers of an I2C controller which is part of the RTC.
|
||||
* ULP coprocessor uses this controller to implement I2C_RD and I2C_WR instructions.
|
||||
*
|
||||
* Part of the functionality of this controller (such as slave mode, and multi-byte
|
||||
* transfers) is not wired to the ULP, and is such, is not available to the
|
||||
* ULP programs.
|
||||
*/
|
||||
|
||||
#define RTC_I2C_SCL_LOW_PERIOD_REG (DR_REG_RTC_I2C_BASE + 0x000)
|
||||
/* RTC_I2C_SCL_LOW_PERIOD : R/W ;bitpos:[18:0] ;default: 19'b0 ; */
|
||||
/*description: number of cycles that scl == 0 */
|
||||
#define RTC_I2C_SCL_LOW_PERIOD 0x1FFFFFF
|
||||
#define RTC_I2C_SCL_LOW_PERIOD_M ((RTC_I2C_SCL_LOW_PERIOD_V)<<(RTC_I2C_SCL_LOW_PERIOD_S))
|
||||
#define RTC_I2C_SCL_LOW_PERIOD_V 0x1FFFFFF
|
||||
#define RTC_I2C_SCL_LOW_PERIOD_S 0
|
||||
|
||||
#define RTC_I2C_CTRL_REG (DR_REG_RTC_I2C_BASE + 0x004)
|
||||
/* RTC_I2C_RX_LSB_FIRST : R/W ;bitpos:[7] ;default: 1'b0 ; */
|
||||
/*description: Send LSB first */
|
||||
#define RTC_I2C_RX_LSB_FIRST BIT(7)
|
||||
#define RTC_I2C_RX_LSB_FIRST_M BIT(7)
|
||||
#define RTC_I2C_RX_LSB_FIRST_V (1)
|
||||
#define RTC_I2C_RX_LSB_FIRST_S (7)
|
||||
/* RTC_I2C_TX_LSB_FIRST : R/W ;bitpos:[6] ;default: 1'b0 ; */
|
||||
/*description: Receive LSB first */
|
||||
#define RTC_I2C_TX_LSB_FIRST BIT(6)
|
||||
#define RTC_I2C_TX_LSB_FIRST_M BIT(6)
|
||||
#define RTC_I2C_TX_LSB_FIRST_V (1)
|
||||
#define RTC_I2C_TX_LSB_FIRST_S (6)
|
||||
/* RTC_I2C_TRANS_START : R/W ;bitpos:[5] ;default: 1'b0 ; */
|
||||
/*description: Force to generate start condition */
|
||||
#define RTC_I2C_TRANS_START BIT(5)
|
||||
#define RTC_I2C_TRANS_START_M BIT(5)
|
||||
#define RTC_I2C_TRANS_START_V (1)
|
||||
#define RTC_I2C_TRANS_START_S (5)
|
||||
/* RTC_I2C_MS_MODE : R/W ;bitpos:[4] ;default: 1'b0 ; */
|
||||
/*description: Master (1) or slave (0) */
|
||||
#define RTC_I2C_MS_MODE BIT(4)
|
||||
#define RTC_I2C_MS_MODE_M BIT(4)
|
||||
#define RTC_I2C_MS_MODE_V (1)
|
||||
#define RTC_I2C_MS_MODE_S (4)
|
||||
/* RTC_I2C_SCL_FORCE_OUT : R/W ;bitpos:[1] ;default: 1'b0 ; */
|
||||
/*description: SCL is push-pull (1) or open-drain (0) */
|
||||
#define RTC_I2C_SCL_FORCE_OUT BIT(1)
|
||||
#define RTC_I2C_SCL_FORCE_OUT_M BIT(1)
|
||||
#define RTC_I2C_SCL_FORCE_OUT_V (1)
|
||||
#define RTC_I2C_SCL_FORCE_OUT_S (1)
|
||||
/* RTC_I2C_SDA_FORCE_OUT : R/W ;bitpos:[0] ;default: 1'b0 ; */
|
||||
/*description: SDA is push-pull (1) or open-drain (0) */
|
||||
#define RTC_I2C_SDA_FORCE_OUT BIT(0)
|
||||
#define RTC_I2C_SDA_FORCE_OUT_M BIT(0)
|
||||
#define RTC_I2C_SDA_FORCE_OUT_V (1)
|
||||
#define RTC_I2C_SDA_FORCE_OUT_S (0)
|
||||
|
||||
#define RTC_I2C_DEBUG_STATUS_REG (DR_REG_RTC_I2C_BASE + 0x008)
|
||||
/* RTC_I2C_SCL_STATE : R/W ;bitpos:[30:28] ;default: 3'b0 ; */
|
||||
/*description: state of SCL state machine */
|
||||
#define RTC_I2C_SCL_STATE 0x7
|
||||
#define RTC_I2C_SCL_STATE_M ((RTC_I2C_SCL_STATE_V)<<(RTC_I2C_SCL_STATE_S))
|
||||
#define RTC_I2C_SCL_STATE_V 0x7
|
||||
#define RTC_I2C_SCL_STATE_S 28
|
||||
/* RTC_I2C_MAIN_STATE : R/W ;bitpos:[27:25] ;default: 3'b0 ; */
|
||||
/*description: state of the main state machine */
|
||||
#define RTC_I2C_MAIN_STATE 0x7
|
||||
#define RTC_I2C_MAIN_STATE_M ((RTC_I2C_MAIN_STATE_V)<<(RTC_I2C_MAIN_STATE_S))
|
||||
#define RTC_I2C_MAIN_STATE_V 0x7
|
||||
#define RTC_I2C_MAIN_STATE_S 25
|
||||
/* RTC_I2C_BYTE_TRANS : R/W ;bitpos:[6] ;default: 1'b0 ; */
|
||||
/*description: 8 bit transmit done */
|
||||
#define RTC_I2C_BYTE_TRANS BIT(6)
|
||||
#define RTC_I2C_BYTE_TRANS_M BIT(6)
|
||||
#define RTC_I2C_BYTE_TRANS_V (1)
|
||||
#define RTC_I2C_BYTE_TRANS_S (6)
|
||||
/* RTC_I2C_SLAVE_ADDR_MATCH : R/W ;bitpos:[5] ;default: 1'b0 ; */
|
||||
/*description: When working as a slave, whether address was matched */
|
||||
#define RTC_I2C_SLAVE_ADDR_MATCH BIT(5)
|
||||
#define RTC_I2C_SLAVE_ADDR_MATCH_M BIT(5)
|
||||
#define RTC_I2C_SLAVE_ADDR_MATCH_V (1)
|
||||
#define RTC_I2C_SLAVE_ADDR_MATCH_S (5)
|
||||
/* RTC_I2C_BUS_BUSY : R/W ;bitpos:[4] ;default: 1'b0 ; */
|
||||
/*description: operation is in progress */
|
||||
#define RTC_I2C_BUS_BUSY BIT(4)
|
||||
#define RTC_I2C_BUS_BUSY_M BIT(4)
|
||||
#define RTC_I2C_BUS_BUSY_V (1)
|
||||
#define RTC_I2C_BUS_BUSY_S (4)
|
||||
/* RTC_I2C_ARB_LOST : R/W ;bitpos:[3] ;default: 1'b0 ; */
|
||||
/*description: When working as a master, lost control of I2C bus */
|
||||
#define RTC_I2C_ARB_LOST BIT(3)
|
||||
#define RTC_I2C_ARB_LOST_M BIT(3)
|
||||
#define RTC_I2C_ARB_LOST_V (1)
|
||||
#define RTC_I2C_ARB_LOST_S (3)
|
||||
/* RTC_I2C_TIMED_OUT : R/W ;bitpos:[2] ;default: 1'b0 ; */
|
||||
/*description: Transfer has timed out */
|
||||
#define RTC_I2C_TIMED_OUT BIT(2)
|
||||
#define RTC_I2C_TIMED_OUT_M BIT(2)
|
||||
#define RTC_I2C_TIMED_OUT_V (1)
|
||||
#define RTC_I2C_TIMED_OUT_S (2)
|
||||
/* RTC_I2C_SLAVE_RW : R/W ;bitpos:[1] ;default: 1'b0 ; */
|
||||
/*description: When working as a slave, the value of R/W bit received */
|
||||
#define RTC_I2C_SLAVE_RW BIT(1)
|
||||
#define RTC_I2C_SLAVE_RW_M BIT(1)
|
||||
#define RTC_I2C_SLAVE_RW_V (1)
|
||||
#define RTC_I2C_SLAVE_RW_S (1)
|
||||
/* RTC_I2C_ACK_VAL : R/W ;bitpos:[0] ;default: 1'b0 ; */
|
||||
/*description: The value of an acknowledge signal on the bus */
|
||||
#define RTC_I2C_ACK_VAL BIT(0)
|
||||
#define RTC_I2C_ACK_VAL_M BIT(0)
|
||||
#define RTC_I2C_ACK_VAL_V (1)
|
||||
#define RTC_I2C_ACK_VAL_S (0)
|
||||
|
||||
#define RTC_I2C_TIMEOUT_REG (DR_REG_RTC_I2C_BASE + 0x00c)
|
||||
/* RTC_I2C_TIMEOUT : R/W ;bitpos:[19:0] ;default: 20'b0 ; */
|
||||
/*description: Maximum number of FAST_CLK cycles that the transmission can take */
|
||||
#define RTC_I2C_TIMEOUT 0xFFFFF
|
||||
#define RTC_I2C_TIMEOUT_M ((RTC_I2C_TIMEOUT_V)<<(RTC_I2C_TIMEOUT_S))
|
||||
#define RTC_I2C_TIMEOUT_V 0xFFFFF
|
||||
#define RTC_I2C_TIMEOUT_S 0
|
||||
|
||||
#define RTC_I2C_SLAVE_ADDR_REG (DR_REG_RTC_I2C_BASE + 0x010)
|
||||
/* RTC_I2C_SLAVE_ADDR_10BIT : R/W ;bitpos:[31] ;default: 1'b0 ; */
|
||||
/*description: Set if local slave address is 10-bit */
|
||||
#define RTC_I2C_SLAVE_ADDR_10BIT BIT(31)
|
||||
#define RTC_I2C_SLAVE_ADDR_10BIT_M BIT(31)
|
||||
#define RTC_I2C_SLAVE_ADDR_10BIT_V (1)
|
||||
#define RTC_I2C_SLAVE_ADDR_10BIT_S (31)
|
||||
/* RTC_I2C_SLAVE_ADDR : R/W ;bitpos:[14:0] ;default: 15'b0 ; */
|
||||
/*description: local slave address */
|
||||
#define RTC_I2C_SLAVE_ADDR 0x7FFF
|
||||
#define RTC_I2C_SLAVE_ADDR_M ((RTC_I2C_SLAVE_ADDR_V)<<(RTC_I2C_SLAVE_ADDR_S))
|
||||
#define RTC_I2C_SLAVE_ADDR_V 0x7FFF
|
||||
#define RTC_I2C_SLAVE_ADDR_S 0
|
||||
|
||||
/* Result of last read operation. Not used directly as the data will be
|
||||
* returned to the ULP. Listed for debugging purposes.
|
||||
*/
|
||||
#define RTC_I2C_DATA_REG (DR_REG_RTC_I2C_BASE + 0x01c)
|
||||
|
||||
/* Interrupt registers; since the interrupt from RTC_I2C is not connected,
|
||||
* these registers are only listed for debugging purposes.
|
||||
*/
|
||||
|
||||
/* Interrupt raw status register */
|
||||
#define RTC_I2C_INT_RAW_REG (DR_REG_RTC_I2C_BASE + 0x020)
|
||||
/* RTC_I2C_TIME_OUT_INT_RAW : R/O ;bitpos:[7] ;default: 1'b0 ; */
|
||||
/*description: time out interrupt raw status */
|
||||
#define RTC_I2C_TIME_OUT_INT_RAW BIT(7)
|
||||
#define RTC_I2C_TIME_OUT_INT_RAW_M BIT(7)
|
||||
#define RTC_I2C_TIME_OUT_INT_RAW_V (1)
|
||||
#define RTC_I2C_TIME_OUT_INT_RAW_S (7)
|
||||
/* RTC_I2C_TRANS_COMPLETE_INT_RAW : R/W ;bitpos:[6] ;default: 1'b0 ; */
|
||||
/*description: Stop condition has been detected interrupt raw status */
|
||||
#define RTC_I2C_TRANS_COMPLETE_INT_RAW BIT(6)
|
||||
#define RTC_I2C_TRANS_COMPLETE_INT_RAW_M BIT(6)
|
||||
#define RTC_I2C_TRANS_COMPLETE_INT_RAW_V (1)
|
||||
#define RTC_I2C_TRANS_COMPLETE_INT_RAW_S (6)
|
||||
/* RTC_I2C_MASTER_TRANS_COMPLETE_INT_RAW : R/W ;bitpos:[5] ;default: 1'b0 ; */
|
||||
/*description: */
|
||||
#define RTC_I2C_MASTER_TRANS_COMPLETE_INT_RAW BIT(5)
|
||||
#define RTC_I2C_MASTER_TRANS_COMPLETE_INT_RAW_M BIT(5)
|
||||
#define RTC_I2C_MASTER_TRANS_COMPLETE_INT_RAW_V (1)
|
||||
#define RTC_I2C_MASTER_TRANS_COMPLETE_INT_RAW_S (5)
|
||||
/* RTC_I2C_ARBITRATION_LOST_INT_RAW : R/W ;bitpos:[4] ;default: 1'b0 ; */
|
||||
/*description: Master lost arbitration */
|
||||
#define RTC_I2C_ARBITRATION_LOST_INT_RAW BIT(4)
|
||||
#define RTC_I2C_ARBITRATION_LOST_INT_RAW_M BIT(4)
|
||||
#define RTC_I2C_ARBITRATION_LOST_INT_RAW_V (1)
|
||||
#define RTC_I2C_ARBITRATION_LOST_INT_RAW_S (4)
|
||||
/* RTC_I2C_SLAVE_TRANS_COMPLETE_INT_RAW : R/W ;bitpos:[3] ;default: 1'b0 ; */
|
||||
/*description: Slave accepted 1 byte and address matched */
|
||||
#define RTC_I2C_SLAVE_TRANS_COMPLETE_INT_RAW BIT(3)
|
||||
#define RTC_I2C_SLAVE_TRANS_COMPLETE_INT_RAW_M BIT(3)
|
||||
#define RTC_I2C_SLAVE_TRANS_COMPLETE_INT_RAW_V (1)
|
||||
#define RTC_I2C_SLAVE_TRANS_COMPLETE_INT_RAW_S (3)
|
||||
|
||||
/* Interrupt clear register */
|
||||
#define RTC_I2C_INT_CLR_REG (DR_REG_RTC_I2C_BASE + 0x024)
|
||||
/* RTC_I2C_TIME_OUT_INT_CLR : W/O ;bitpos:[8] ;default: 1'b0 ; */
|
||||
/*description: */
|
||||
#define RTC_I2C_TIME_OUT_INT_CLR BIT(8)
|
||||
#define RTC_I2C_TIME_OUT_INT_CLR_M BIT(8)
|
||||
#define RTC_I2C_TIME_OUT_INT_CLR_V (1)
|
||||
#define RTC_I2C_TIME_OUT_INT_CLR_S (8)
|
||||
/* RTC_I2C_TRANS_COMPLETE_INT_CLR : R/W ;bitpos:[7] ;default: 1'b0 ; */
|
||||
/*description: */
|
||||
#define RTC_I2C_TRANS_COMPLETE_INT_CLR BIT(7)
|
||||
#define RTC_I2C_TRANS_COMPLETE_INT_CLR_M BIT(7)
|
||||
#define RTC_I2C_TRANS_COMPLETE_INT_CLR_V (1)
|
||||
#define RTC_I2C_TRANS_COMPLETE_INT_CLR_S (7)
|
||||
/* RTC_I2C_MASTER_TRANS_COMPLETE_INT_CLR : R/W ;bitpos:[6] ;default: 1'b0 ; */
|
||||
/*description: */
|
||||
#define RTC_I2C_MASTER_TRANS_COMPLETE_INT_CLR BIT(6)
|
||||
#define RTC_I2C_MASTER_TRANS_COMPLETE_INT_CLR_M BIT(6)
|
||||
#define RTC_I2C_MASTER_TRANS_COMPLETE_INT_CLR_V (1)
|
||||
#define RTC_I2C_MASTER_TRANS_COMPLETE_INT_CLR_S (6)
|
||||
/* RTC_I2C_ARBITRATION_LOST_INT_CLR : R/W ;bitpos:[5] ;default: 1'b0 ; */
|
||||
/*description: */
|
||||
#define RTC_I2C_ARBITRATION_LOST_INT_CLR BIT(5)
|
||||
#define RTC_I2C_ARBITRATION_LOST_INT_CLR_M BIT(5)
|
||||
#define RTC_I2C_ARBITRATION_LOST_INT_CLR_V (1)
|
||||
#define RTC_I2C_ARBITRATION_LOST_INT_CLR_S (5)
|
||||
/* RTC_I2C_SLAVE_TRANS_COMPLETE_INT_CLR : R/W ;bitpos:[4] ;default: 1'b0 ; */
|
||||
/*description: */
|
||||
#define RTC_I2C_SLAVE_TRANS_COMPLETE_INT_CLR BIT(4)
|
||||
#define RTC_I2C_SLAVE_TRANS_COMPLETE_INT_CLR_M BIT(4)
|
||||
#define RTC_I2C_SLAVE_TRANS_COMPLETE_INT_CLR_V (1)
|
||||
#define RTC_I2C_SLAVE_TRANS_COMPLETE_INT_CLR_S (4)
|
||||
|
||||
/* Interrupt enable register.
|
||||
* Bit definitions are not given here, because interrupt functionality
|
||||
* of RTC_I2C is not used.
|
||||
*/
|
||||
#define RTC_I2C_INT_EN_REG (DR_REG_RTC_I2C_BASE + 0x028)
|
||||
|
||||
/* Masked interrupt status register.
|
||||
* Bit definitions are not given here, because interrupt functionality
|
||||
* of RTC_I2C is not used.
|
||||
*/
|
||||
#define RTC_I2C_INT_ST_REG (DR_REG_RTC_I2C_BASE + 0x02c)
|
||||
|
||||
#define RTC_I2C_SDA_DUTY_REG (DR_REG_RTC_I2C_BASE + 0x030)
|
||||
/* RTC_I2C_SDA_DUTY : R/W ;bitpos:[19:0] ;default: 20'b0 ; */
|
||||
/*description: Number of FAST_CLK cycles SDA will switch after falling edge of SCL */
|
||||
#define RTC_I2C_SDA_DUTY 0xFFFFF
|
||||
#define RTC_I2C_SDA_DUTY_M ((RTC_I2C_SDA_DUTY_V)<<(RTC_I2C_SDA_DUTY_S))
|
||||
#define RTC_I2C_SDA_DUTY_V 0xFFFFF
|
||||
#define RTC_I2C_SDA_DUTY_S 0
|
||||
|
||||
#define RTC_I2C_SCL_HIGH_PERIOD_REG (DR_REG_RTC_I2C_BASE + 0x038)
|
||||
/* RTC_I2C_SCL_HIGH_PERIOD : R/W ;bitpos:[19:0] ;default: 20'b0 ; */
|
||||
/*description: Number of FAST_CLK cycles for SCL to be high */
|
||||
#define RTC_I2C_SCL_HIGH_PERIOD 0xFFFFF
|
||||
#define RTC_I2C_SCL_HIGH_PERIOD_M ((RTC_I2C_SCL_HIGH_PERIOD_V)<<(RTC_I2C_SCL_HIGH_PERIOD_S))
|
||||
#define RTC_I2C_SCL_HIGH_PERIOD_V 0xFFFFF
|
||||
#define RTC_I2C_SCL_HIGH_PERIOD_S 0
|
||||
|
||||
#define RTC_I2C_SCL_START_PERIOD_REG (DR_REG_RTC_I2C_BASE + 0x040)
|
||||
/* RTC_I2C_SCL_START_PERIOD : R/W ;bitpos:[19:0] ;default: 20'b0 ; */
|
||||
/*description: Number of FAST_CLK cycles to wait before generating start condition */
|
||||
#define RTC_I2C_SCL_START_PERIOD 0xFFFFF
|
||||
#define RTC_I2C_SCL_START_PERIOD_M ((RTC_I2C_SCL_START_PERIOD_V)<<(RTC_I2C_SCL_START_PERIOD_S))
|
||||
#define RTC_I2C_SCL_START_PERIOD_V 0xFFFFF
|
||||
#define RTC_I2C_SCL_START_PERIOD_S 0
|
||||
|
||||
#define RTC_I2C_SCL_STOP_PERIOD_REG (DR_REG_RTC_I2C_BASE + 0x044)
|
||||
/* RTC_I2C_SCL_STOP_PERIOD : R/W ;bitpos:[19:0] ;default: 20'b0 ; */
|
||||
/*description: Number of FAST_CLK cycles to wait before generating stop condition */
|
||||
#define RTC_I2C_SCL_STOP_PERIOD 0xFFFFF
|
||||
#define RTC_I2C_SCL_STOP_PERIOD_M ((RTC_I2C_SCL_STOP_PERIOD_V)<<(RTC_I2C_SCL_STOP_PERIOD_S))
|
||||
#define RTC_I2C_SCL_STOP_PERIOD_V 0xFFFFF
|
||||
#define RTC_I2C_SCL_STOP_PERIOD_S 0
|
||||
|
||||
/* A block of 16 RTC_I2C_CMD registers which describe I2C operation to be
|
||||
* performed. Unused when ULP is controlling RTC_I2C.
|
||||
*/
|
||||
#define RTC_I2C_CMD_REG_COUNT 16
|
||||
#define RTC_I2C_CMD_REG(i) (DR_REG_RTC_I2C_BASE + 0x048 + (i) * 4)
|
||||
/* RTC_I2C_CMD_DONE : R/W ;bitpos:[31] ;default: 1'b0 ; */
|
||||
/*description: Bit is set by HW when command is done */
|
||||
#define RTC_I2C_CMD_DONE BIT(31)
|
||||
#define RTC_I2C_CMD_DONE_M BIT(31)
|
||||
#define RTC_I2C_CMD_DONE_V (1)
|
||||
#define RTC_I2C_CMD_DONE_S (31)
|
||||
/* RTC_I2C_VAL : R/W ;bitpos:[13:0] ;default: 14'b0 ; */
|
||||
/*description: Command content */
|
||||
#define RTC_I2C_VAL 0
|
||||
#define RTC_I2C_VAL_M ((RTC_I2C_VAL_V)<<(RTC_I2C_VAL_S))
|
||||
#define RTC_I2C_VAL_V 0x3FFF
|
||||
#define RTC_I2C_VAL_S 0
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2010-2017 Espressif Systems (Shanghai) PTE LTD
|
||||
// Copyright 2010-2018 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.
|
||||
@ -75,7 +75,9 @@
|
||||
#define DR_REG_AES_BASE 0x3ff01000
|
||||
#define DR_REG_RSA_BASE 0x3ff02000
|
||||
#define DR_REG_SHA_BASE 0x3ff03000
|
||||
#define DR_REG_DPORT_END 0x3ff03FFC
|
||||
#define DR_REG_FLASH_MMU_TABLE_PRO 0x3ff10000
|
||||
#define DR_REG_FLASH_MMU_TABLE_APP 0x3ff12000
|
||||
#define DR_REG_DPORT_END 0x3ff13FFC
|
||||
#define DR_REG_UART_BASE 0x3ff40000
|
||||
#define DR_REG_SPI1_BASE 0x3ff42000
|
||||
#define DR_REG_SPI0_BASE 0x3ff43000
|
||||
@ -87,11 +89,8 @@
|
||||
#define DR_REG_RTCCNTL_BASE 0x3ff48000
|
||||
#define DR_REG_RTCIO_BASE 0x3ff48400
|
||||
#define DR_REG_SENS_BASE 0x3ff48800
|
||||
#define DR_REG_RTC_I2C_BASE 0x3ff48C00
|
||||
#define DR_REG_IO_MUX_BASE 0x3ff49000
|
||||
#define DR_REG_RTCMEM0_BASE 0x3ff61000
|
||||
#define DR_REG_RTCMEM1_BASE 0x3ff62000
|
||||
#define DR_REG_RTCMEM2_BASE 0x3ff63000
|
||||
#define DR_REG_SYSCON_BASE 0x3ff66000
|
||||
#define DR_REG_HINF_BASE 0x3ff4B000
|
||||
#define DR_REG_UHCI1_BASE 0x3ff4C000
|
||||
#define DR_REG_I2S_BASE 0x3ff4F000
|
||||
@ -111,9 +110,13 @@
|
||||
#define DR_REG_PWM_BASE 0x3ff5E000
|
||||
#define DR_REG_TIMERGROUP0_BASE 0x3ff5F000
|
||||
#define DR_REG_TIMERGROUP1_BASE 0x3ff60000
|
||||
#define DR_REG_RTCMEM0_BASE 0x3ff61000
|
||||
#define DR_REG_RTCMEM1_BASE 0x3ff62000
|
||||
#define DR_REG_RTCMEM2_BASE 0x3ff63000
|
||||
#define DR_REG_SPI2_BASE 0x3ff64000
|
||||
#define DR_REG_SPI3_BASE 0x3ff65000
|
||||
#define DR_REG_APB_CTRL_BASE 0x3ff66000
|
||||
#define DR_REG_SYSCON_BASE 0x3ff66000
|
||||
#define DR_REG_APB_CTRL_BASE 0x3ff66000 /* Old name for SYSCON, to be removed */
|
||||
#define DR_REG_I2C1_EXT_BASE 0x3ff67000
|
||||
#define DR_REG_SDMMC_BASE 0x3ff68000
|
||||
#define DR_REG_EMAC_BASE 0x3ff69000
|
||||
|
@ -26,7 +26,7 @@
|
||||
#define MASK_TO_WIDTH_HELPER32(m, i) (MASK_TO_WIDTH_HELPER16(m, i) + MASK_TO_WIDTH_HELPER16(m, i + 16))
|
||||
|
||||
// Peripheral register access macros, build around REG_RD and REG_WR instructions.
|
||||
// Registers defined in rtc_cntl_reg.h, rtc_io_reg.h, and sens_reg.h are usable with these macros.
|
||||
// Registers defined in rtc_cntl_reg.h, rtc_io_reg.h, sens_reg.h, and rtc_i2c_reg.h are usable with these macros.
|
||||
|
||||
// Read from rtc_reg[low_bit + bit_width - 1 : low_bit] into R0, bit_width <= 16
|
||||
#define READ_RTC_REG(rtc_reg, low_bit, bit_width) \
|
||||
|
@ -1105,11 +1105,24 @@
|
||||
|
||||
#define UART_MEM_RX_STATUS_REG(i) (REG_UART_BASE(i) + 0x60)
|
||||
/* UART_MEM_RX_STATUS : RO ;bitpos:[23:0] ;default: 24'h0 ; */
|
||||
/*description: */
|
||||
/*description: This register stores the current uart rx mem read address
|
||||
and rx mem write address */
|
||||
#define UART_MEM_RX_STATUS 0x00FFFFFF
|
||||
#define UART_MEM_RX_STATUS_M ((UART_MEM_RX_STATUS_V)<<(UART_MEM_RX_STATUS_S))
|
||||
#define UART_MEM_RX_STATUS_V 0xFFFFFF
|
||||
#define UART_MEM_RX_STATUS_S 0
|
||||
/* UART_MEM_RX_RD_ADDR : RO ;bitpos:[12:2] ;default: 11'h0 ; */
|
||||
/*description: This register stores the rx mem read address */
|
||||
#define UART_MEM_RX_RD_ADDR 0x000007FF
|
||||
#define UART_MEM_RX_RD_ADDR_M ((UART_MEM_RX_RD_ADDR_V)<<(UART_MEM_RX_RD_ADDR_S))
|
||||
#define UART_MEM_RX_RD_ADDR_V (0x7FF)
|
||||
#define UART_MEM_RX_RD_ADDR_S (2)
|
||||
/* UART_MEM_RX_WR_ADDR : RO ;bitpos:[23:13] ;default: 11'h0 ; */
|
||||
/*description: This register stores the rx mem write address */
|
||||
#define UART_MEM_RX_WR_ADDR 0x000007FF
|
||||
#define UART_MEM_RX_WR_ADDR_M ((UART_MEM_RX_WR_ADDR_V)<<(UART_MEM_RX_WR_ADDR_S))
|
||||
#define UART_MEM_RX_WR_ADDR_V (0x7FF)
|
||||
#define UART_MEM_RX_WR_ADDR_S (13)
|
||||
|
||||
#define UART_MEM_CNT_STATUS_REG(i) (REG_UART_BASE(i) + 0x64)
|
||||
/* UART_TX_MEM_CNT : RO ;bitpos:[5:3] ;default: 3'b0 ; */
|
||||
|
@ -335,6 +335,12 @@ typedef volatile struct {
|
||||
uint32_t status: 24;
|
||||
uint32_t reserved24: 8;
|
||||
};
|
||||
struct {
|
||||
uint32_t reserved0: 2;
|
||||
uint32_t rd_addr: 11; /*This register stores the rx mem read address.*/
|
||||
uint32_t wr_addr: 11; /*This register stores the rx mem write address.*/
|
||||
uint32_t reserved: 8;
|
||||
};
|
||||
uint32_t val;
|
||||
} mem_rx_status;
|
||||
union {
|
||||
|
@ -158,7 +158,7 @@ extern void spiffs_api_unlock(struct spiffs_t *fs);
|
||||
// This is derived from following:
|
||||
// logical_page_size - (SPIFFS_OBJ_NAME_LEN + sizeof(spiffs_page_header) +
|
||||
// spiffs_object_ix_header fields + at least some LUT entries)
|
||||
#define SPIFFS_OBJ_META_LEN (0)
|
||||
#define SPIFFS_OBJ_META_LEN (CONFIG_SPIFFS_META_LENGTH)
|
||||
|
||||
// Size of buffer allocated on stack used when copying data.
|
||||
// Lower value generates more read/writes. No meaning having it bigger
|
||||
|
@ -603,6 +603,18 @@ esp_err_t tcpip_adapter_set_hostname(tcpip_adapter_if_t tcpip_if, const char *ho
|
||||
*/
|
||||
esp_err_t tcpip_adapter_get_hostname(tcpip_adapter_if_t tcpip_if, const char **hostname);
|
||||
|
||||
/**
|
||||
* @brief Get the LwIP netif* that is assigned to the interface
|
||||
*
|
||||
* @param[in] tcpip_if: the interface which we will get the hostname
|
||||
* @param[out] void ** netif: pointer to fill the resulting interface
|
||||
*
|
||||
* @return ESP_OK:success
|
||||
* ESP_ERR_TCPIP_ADAPTER_IF_NOT_READY:interface status error
|
||||
* ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS:parameter error
|
||||
*/
|
||||
esp_err_t tcpip_adapter_get_netif(tcpip_adapter_if_t tcpip_if, void ** netif);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2016 Espressif Systems (Shanghai) PTE LTD
|
||||
// Copyright 2016-2018 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.
|
||||
@ -50,6 +50,7 @@ extern "C" {
|
||||
#define RD_REG_PERIPH_RTC_CNTL 0 /*!< Identifier of RTC_CNTL peripheral for RD_REG and WR_REG instructions */
|
||||
#define RD_REG_PERIPH_RTC_IO 1 /*!< Identifier of RTC_IO peripheral for RD_REG and WR_REG instructions */
|
||||
#define RD_REG_PERIPH_SENS 2 /*!< Identifier of SARADC peripheral for RD_REG and WR_REG instructions */
|
||||
#define RD_REG_PERIPH_RTC_I2C 3 /*!< Identifier of RTC_I2C peripheral for RD_REG and WR_REG instructions */
|
||||
|
||||
#define OPCODE_I2C 3 /*!< Instruction: read/write I2C (not implemented yet) */
|
||||
|
||||
@ -266,9 +267,9 @@ _Static_assert(sizeof(ulp_insn_t) == 4, "ULP coprocessor instruction size should
|
||||
* Delay (nop) for a given number of cycles
|
||||
*/
|
||||
#define I_DELAY(cycles_) { .delay = {\
|
||||
.opcode = OPCODE_DELAY, \
|
||||
.cycles = cycles_, \
|
||||
.unused = 0, \
|
||||
.cycles = cycles_ } }
|
||||
.opcode = OPCODE_DELAY } }
|
||||
|
||||
/**
|
||||
* Halt the coprocessor.
|
||||
@ -286,7 +287,7 @@ _Static_assert(sizeof(ulp_insn_t) == 4, "ULP coprocessor instruction size should
|
||||
* Map SoC peripheral register to periph_sel field of RD_REG and WR_REG
|
||||
* instructions.
|
||||
*
|
||||
* @param reg peripheral register in RTC_CNTL_, RTC_IO_, SENS_ peripherals.
|
||||
* @param reg peripheral register in RTC_CNTL_, RTC_IO_, SENS_, RTC_I2C peripherals.
|
||||
* @return periph_sel value for the peripheral to which this register belongs.
|
||||
*/
|
||||
static inline uint32_t SOC_REG_TO_ULP_PERIPH_SEL(uint32_t reg) {
|
||||
@ -297,8 +298,10 @@ static inline uint32_t SOC_REG_TO_ULP_PERIPH_SEL(uint32_t reg) {
|
||||
ret = RD_REG_PERIPH_RTC_CNTL;
|
||||
} else if (reg < DR_REG_SENS_BASE) {
|
||||
ret = RD_REG_PERIPH_RTC_IO;
|
||||
} else if (reg < DR_REG_RTCMEM0_BASE){
|
||||
} else if (reg < DR_REG_RTC_I2C_BASE){
|
||||
ret = RD_REG_PERIPH_SENS;
|
||||
} else if (reg < DR_REG_IO_MUX_BASE){
|
||||
ret = RD_REG_PERIPH_RTC_I2C;
|
||||
} else {
|
||||
assert(0 && "invalid register base");
|
||||
}
|
||||
@ -309,7 +312,7 @@ static inline uint32_t SOC_REG_TO_ULP_PERIPH_SEL(uint32_t reg) {
|
||||
* Write literal value to a peripheral register
|
||||
*
|
||||
* reg[high_bit : low_bit] = val
|
||||
* This instruction can access RTC_CNTL_, RTC_IO_, and SENS_ peripheral registers.
|
||||
* This instruction can access RTC_CNTL_, RTC_IO_, SENS_, and RTC_I2C peripheral registers.
|
||||
*/
|
||||
#define I_WR_REG(reg, low_bit, high_bit, val) {.wr_reg = {\
|
||||
.addr = (reg & 0xff) / sizeof(uint32_t), \
|
||||
@ -323,7 +326,7 @@ static inline uint32_t SOC_REG_TO_ULP_PERIPH_SEL(uint32_t reg) {
|
||||
* Read from peripheral register into R0
|
||||
*
|
||||
* R0 = reg[high_bit : low_bit]
|
||||
* This instruction can access RTC_CNTL_, RTC_IO_, and SENS_ peripheral registers.
|
||||
* This instruction can access RTC_CNTL_, RTC_IO_, SENS_, and RTC_I2C peripheral registers.
|
||||
*/
|
||||
#define I_RD_REG(reg, low_bit, high_bit) {.rd_reg = {\
|
||||
.addr = (reg & 0xff) / sizeof(uint32_t), \
|
||||
@ -337,7 +340,7 @@ static inline uint32_t SOC_REG_TO_ULP_PERIPH_SEL(uint32_t reg) {
|
||||
* Set or clear a bit in the peripheral register.
|
||||
*
|
||||
* Sets bit (1 << shift) of register reg to value val.
|
||||
* This instruction can access RTC_CNTL_, RTC_IO_, and SENS_ peripheral registers.
|
||||
* This instruction can access RTC_CNTL_, RTC_IO_, SENS_, and RTC_I2C peripheral registers.
|
||||
*/
|
||||
#define I_WR_REG_BIT(reg, shift, val) I_WR_REG(reg, shift, shift, val)
|
||||
|
||||
|
@ -45,9 +45,13 @@ MEMORY
|
||||
|
||||
Enabling Bluetooth & Trace Memory features in menuconfig will decrease
|
||||
the amount of RAM available.
|
||||
|
||||
Note: Length of this section *should* be 0x50000, and this extra DRAM is available
|
||||
in heap at runtime. However due to static ROM memory usage at this 176KB mark, the
|
||||
additional static memory temporarily cannot be used.
|
||||
*/
|
||||
dram0_0_seg (RW) : org = 0x3FFB0000 + CONFIG_BT_RESERVE_DRAM,
|
||||
len = 0x50000 - CONFIG_TRACEMEM_RESERVE_DRAM - CONFIG_BT_RESERVE_DRAM
|
||||
len = 0x2c200 - CONFIG_BT_RESERVE_DRAM
|
||||
|
||||
/* Flash mapped constant data */
|
||||
drom0_0_seg (R) : org = 0x3F400018, len = 0x400000-0x18
|
||||
|
@ -40,9 +40,13 @@ MEMORY
|
||||
|
||||
Enabling Bluetooth & Trace Memory features in menuconfig will decrease
|
||||
the amount of RAM available.
|
||||
|
||||
Note: Length of this section *should* be 0x50000, and this extra DRAM is available
|
||||
in heap at runtime. However due to static ROM memory usage at this 176KB mark, the
|
||||
additional static memory temporarily cannot be used.
|
||||
*/
|
||||
dram0_0_seg (RW) : org = 0x3FFB0000 + 0x10000,
|
||||
len = 0x50000 - 0x0 - 0x10000
|
||||
len = 0x2c200 - 0x10000
|
||||
/* Flash mapped constant data */
|
||||
drom0_0_seg (R) : org = 0x3F400018, len = 0x400000-0x18
|
||||
/* (See iram0_2_seg for meaning of 0x18 offset in the above.) */
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user