diff --git a/cores/esp32/esp32-hal-bt.c b/cores/esp32/esp32-hal-bt.c index d701bbbfdb646d236ddc956c490791103202f050..0591ace38af075a0d2b2e82048cb76df62303868 100644 --- a/cores/esp32/esp32-hal-bt.c +++ b/cores/esp32/esp32-hal-bt.c @@ -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" diff --git a/cores/esp32/esp32-hal-ledc.c b/cores/esp32/esp32-hal-ledc.c index 1deb3300586b256c3edf5045b2459d3c0a347911..64f4dc01fef8dcaa23c30ea5ef507026fadd906e 100644 --- a/cores/esp32/esp32-hal-ledc.c +++ b/cores/esp32/esp32-hal-ledc.c @@ -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; diff --git a/libraries/ESPmDNS/src/ESPmDNS.cpp b/libraries/ESPmDNS/src/ESPmDNS.cpp index e18da71e56f535a22aebea196e466fa06a615bb2..bc355663ad72ac4e5a0e08df1235ec31ac669a65 100644 --- a/libraries/ESPmDNS/src/ESPmDNS.cpp +++ b/libraries/ESPmDNS/src/ESPmDNS.cpp @@ -39,22 +39,27 @@ License (MIT license): #endif #include "ESPmDNS.h" +#include "WiFi.h" #include #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(mdns, "_arduino", "_tcp", port)) { + if(mdns_service_add(NULL, "_arduino", "_tcp", port, arduTxtData, 4)) { 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; } -int MDNSResponder::queryService(char *service, char *proto) { - mdns_result_free(mdns); - if(proto){ - 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); +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 mdns_query(mdns, service, NULL, 2000); + return IPAddress(addr.addr); } -IPAddress MDNSResponder::queryHost(char *host){ - mdns_result_free(mdns); - if(!mdns_query(mdns, host, NULL, 2000)){ - return IPAddress(); + +int MDNSResponder::queryService(char *service, char *proto) { + if(!service || !service[0] || !proto || !proto[0]){ + log_e("Bad Parameters"); + return 0; + } + + if(results){ + mdns_query_results_free(results); + results = NULL; } - return IP(0); + + char srv[strlen(service)+2]; + char prt[strlen(proto)+2]; + sprintf(srv, "_%s", service); + sprintf(prt, "_%s", proto); + + esp_err_t err = mdns_query_ptr(srv, prt, 3000, 20, &results); + if(err){ + log_e("Query Failed"); + return 0; + } + if(!results){ + log_w("No results found!"); + return 0; + } + + mdns_result_t * r = results; + int i = 0; + while(r){ + i++; + r = r->next; + } + 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; diff --git a/libraries/ESPmDNS/src/ESPmDNS.h b/libraries/ESPmDNS/src/ESPmDNS.h index 7c0cd65b0fb9a3f0a9592e53a18e5d187027e21d..083ec17eeac19d54de7159f2a08486b46cff1219 100644 --- a/libraries/ESPmDNS/src/ESPmDNS.h +++ b/libraries/ESPmDNS/src/ESPmDNS.h @@ -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; diff --git a/libraries/WiFi/src/ETH.cpp b/libraries/WiFi/src/ETH.cpp index b4d404d3d1cbb4006a847c7399077dab3955ab8e..b9caddb1130dc08526dad5ea99c72595ec95352f 100644 --- a/libraries/WiFi/src/ETH.cpp +++ b/libraries/WiFi/src/ETH.cpp @@ -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) diff --git a/libraries/WiFi/src/WiFiGeneric.cpp b/libraries/WiFi/src/WiFiGeneric.cpp index 13ffc6ed8245218ad5a091b3dd6572f9147ad414..0ef7522cb4fac702276844ebf03e714ce715e828 100644 --- a/libraries/WiFi/src/WiFiGeneric.cpp +++ b/libraries/WiFi/src/WiFiGeneric.cpp @@ -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); } } } diff --git a/libraries/WiFi/src/WiFiGeneric.h b/libraries/WiFi/src/WiFiGeneric.h index 356f44e72891658fefd3a465e3873a048f7713e3..415bb68176ef36a5576617f221df139ce27c1c93 100644 --- a/libraries/WiFi/src/WiFiGeneric.h +++ b/libraries/WiFi/src/WiFiGeneric.h @@ -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); diff --git a/package/package_esp32_index.template.json b/package/package_esp32_index.template.json index abf8f4d94cda9741734b6b7d99c25e817c1bed22..84774162e963bc7be54a8cdb5a64f397d0435aa8 100644 --- a/package/package_esp32_index.template.json +++ b/package/package_esp32_index.template.json @@ -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" } ] }, diff --git a/platform.txt b/platform.txt index 71126842f333276be3221a415b38ee94f88f04b8..7f1a5fb418cfc9e86739dd7346b39c0f6cd2682b 100644 --- a/platform.txt +++ b/platform.txt @@ -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}" diff --git a/tools/platformio-build.py b/tools/platformio-build.py index a7d266ded12eded02cd018270853b5415f028c9f..3724f374557f66939f3c2bda8574f11ea50b54b3 100644 --- a/tools/platformio-build.py +++ b/tools/platformio-build.py @@ -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=[ diff --git a/tools/sdk/bin/bootloader_dio_40m.bin b/tools/sdk/bin/bootloader_dio_40m.bin index 381423dcb2544ef2a4fc359371c6cc052e6cf01c..e537abfdecad5979d90df53a79b7d935fe82c7a1 100644 Binary files a/tools/sdk/bin/bootloader_dio_40m.bin and b/tools/sdk/bin/bootloader_dio_40m.bin differ diff --git a/tools/sdk/bin/bootloader_dio_80m.bin b/tools/sdk/bin/bootloader_dio_80m.bin index 7e4e663c41666c7d1c32f8044860aaa1b42cd6d3..7c64bdb595c9b559abbe9c69204dc5ed7640fc67 100644 Binary files a/tools/sdk/bin/bootloader_dio_80m.bin and b/tools/sdk/bin/bootloader_dio_80m.bin differ diff --git a/tools/sdk/bin/bootloader_dout_40m.bin b/tools/sdk/bin/bootloader_dout_40m.bin index bf8c83b96e9e203d550b6e7e2f36093db90f69f1..a056c96a5b8a72979be643b4c5d57862d4e1f5e6 100644 Binary files a/tools/sdk/bin/bootloader_dout_40m.bin and b/tools/sdk/bin/bootloader_dout_40m.bin differ diff --git a/tools/sdk/bin/bootloader_dout_80m.bin b/tools/sdk/bin/bootloader_dout_80m.bin index 7ee7fdc418f3c4f97334bd804bf67679852fdcc9..f179cecc7d219e8bca840793ca8a8e77ac94e735 100644 Binary files a/tools/sdk/bin/bootloader_dout_80m.bin and b/tools/sdk/bin/bootloader_dout_80m.bin differ diff --git a/tools/sdk/bin/bootloader_qio_40m.bin b/tools/sdk/bin/bootloader_qio_40m.bin index 67f8ab51974899e2aed1dab3c3a2336e04b21468..fccc9abe88ab7f2b71fe3fc96f4d32db0aedc9ae 100644 Binary files a/tools/sdk/bin/bootloader_qio_40m.bin and b/tools/sdk/bin/bootloader_qio_40m.bin differ diff --git a/tools/sdk/bin/bootloader_qio_80m.bin b/tools/sdk/bin/bootloader_qio_80m.bin index 12180e8031e306a597342e4a9d25f7acbe6df7cd..bd461f51a9a3e3f23ddad2a21470c4bf912d74a3 100644 Binary files a/tools/sdk/bin/bootloader_qio_80m.bin and b/tools/sdk/bin/bootloader_qio_80m.bin differ diff --git a/tools/sdk/bin/bootloader_qout_40m.bin b/tools/sdk/bin/bootloader_qout_40m.bin index 67f8ab51974899e2aed1dab3c3a2336e04b21468..2d5a747c84275f0073f82ef9c5cd4d49c998625b 100644 Binary files a/tools/sdk/bin/bootloader_qout_40m.bin and b/tools/sdk/bin/bootloader_qout_40m.bin differ diff --git a/tools/sdk/bin/bootloader_qout_80m.bin b/tools/sdk/bin/bootloader_qout_80m.bin index 12180e8031e306a597342e4a9d25f7acbe6df7cd..7c64bdb595c9b559abbe9c69204dc5ed7640fc67 100644 Binary files a/tools/sdk/bin/bootloader_qout_80m.bin and b/tools/sdk/bin/bootloader_qout_80m.bin differ diff --git a/tools/sdk/include/bluedroid/alarm.h b/tools/sdk/include/bluedroid/alarm.h index e71168ea0d2344c3705244f140691f3eee9fc855..3dc177c7a1dfc44d1067c206ed73ab0b651e5348 100644 --- a/tools/sdk/include/bluedroid/alarm.h +++ b/tools/sdk/include/bluedroid/alarm.h @@ -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); diff --git a/tools/sdk/include/bluedroid/blufi_int.h b/tools/sdk/include/bluedroid/blufi_int.h index bfac5294229705883a9782642911e5d732ef23a9..024e1de794c9e80c6460a9e236d9af3a04134ac2 100644 --- a/tools/sdk/include/bluedroid/blufi_int.h +++ b/tools/sdk/include/bluedroid/blufi_int.h @@ -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 @@ -111,7 +112,8 @@ typedef struct blufi_frag_hdr blufi_frag_hdr_t; #define BLUFI_TYPE_DATA_SUBTYPE_CLIENT_PRIV_KEY 0x0d #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_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) diff --git a/tools/sdk/include/bluedroid/bt_defs.h b/tools/sdk/include/bluedroid/bt_defs.h index bb0ca6de5a0a825a863441676d68530bd7dc8ddf..db3ce4bff46f649bd0c8102e8608972d4e85ce2d 100644 --- a/tools/sdk/include/bluedroid/bt_defs.h +++ b/tools/sdk/include/bluedroid/bt_defs.h @@ -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 diff --git a/tools/sdk/include/bluedroid/bt_target.h b/tools/sdk/include/bluedroid/bt_target.h index fe39f8b9bd687785b96f5c0c975bfed851552e16..5be76cc0a1d651e696e9116c7ee9dfa98e2a69cf 100644 --- a/tools/sdk/include/bluedroid/bt_target.h +++ b/tools/sdk/include/bluedroid/bt_target.h @@ -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 diff --git a/tools/sdk/include/bluedroid/bt_types.h b/tools/sdk/include/bluedroid/bt_types.h index c60fd354272fc38ebfb8862709eb86410c0847e0..1f3f60d8caa9b80c12e28c7b2a1ab63347ebd5a7 100644 --- a/tools/sdk/include/bluedroid/bt_types.h +++ b/tools/sdk/include/bluedroid/bt_types.h @@ -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);} diff --git a/tools/sdk/include/bluedroid/bt_utils.h b/tools/sdk/include/bluedroid/bt_utils.h deleted file mode 100644 index 39e2535513cddef38e344896c5d2fd5f5ee9ba64..0000000000000000000000000000000000000000 --- a/tools/sdk/include/bluedroid/bt_utils.h +++ /dev/null @@ -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 */ diff --git a/tools/sdk/include/bluedroid/bta_api.h b/tools/sdk/include/bluedroid/bta_api.h index f0a3f8f9d86c24bc8dd40dbef45fe0c54ce55df8..a5a7edd269f233c36db549c0ded322e05a85d3d9 100644 --- a/tools/sdk/include/bluedroid/bta_api.h +++ b/tools/sdk/include/bluedroid/bta_api.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; diff --git a/tools/sdk/include/bluedroid/bta_av_api.h b/tools/sdk/include/bluedroid/bta_av_api.h index 24c359910ca4da91b119a13cb4d49b3c2ca8e2ce..a7560c9ebc493acfd9ba5c702133ac0426fb1ecf 100644 --- a/tools/sdk/include/bluedroid/bta_av_api.h +++ b/tools/sdk/include/bluedroid/bta_av_api.h @@ -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; diff --git a/tools/sdk/include/bluedroid/bta_jv_api.h b/tools/sdk/include/bluedroid/bta_jv_api.h new file mode 100644 index 0000000000000000000000000000000000000000..a9279a846b461f4c5b1fe62071e0f18fdad1507e --- /dev/null +++ b/tools/sdk/include/bluedroid/bta_jv_api.h @@ -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 */ diff --git a/tools/sdk/include/bluedroid/bta_jv_co.h b/tools/sdk/include/bluedroid/bta_jv_co.h new file mode 100644 index 0000000000000000000000000000000000000000..e68096c15ce4a5a1a28171252e55e50c61d45fa5 --- /dev/null +++ b/tools/sdk/include/bluedroid/bta_jv_co.h @@ -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 */ diff --git a/tools/sdk/include/bluedroid/btc_a2dp.h b/tools/sdk/include/bluedroid/btc_a2dp.h new file mode 100644 index 0000000000000000000000000000000000000000..6243eb43bd7a64b3e1eb265d11b11460ab544a4a --- /dev/null +++ b/tools/sdk/include/bluedroid/btc_a2dp.h @@ -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 +#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__ */ diff --git a/tools/sdk/include/bluedroid/btc_a2dp_control.h b/tools/sdk/include/bluedroid/btc_a2dp_control.h new file mode 100644 index 0000000000000000000000000000000000000000..e1d5e2ff66cd1ad6a67512d37296621edcda323d --- /dev/null +++ b/tools/sdk/include/bluedroid/btc_a2dp_control.h @@ -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 +#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__ */ diff --git a/tools/sdk/include/bluedroid/btc_a2dp_sink.h b/tools/sdk/include/bluedroid/btc_a2dp_sink.h new file mode 100644 index 0000000000000000000000000000000000000000..772ffea6d842725c1b37524aab55566804d650db --- /dev/null +++ b/tools/sdk/include/bluedroid/btc_a2dp_sink.h @@ -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 +#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__ */ diff --git a/tools/sdk/include/bluedroid/btc_media.h b/tools/sdk/include/bluedroid/btc_a2dp_source.h similarity index 56% rename from tools/sdk/include/bluedroid/btc_media.h rename to tools/sdk/include/bluedroid/btc_a2dp_source.h index 66ad366fbfcbe62797fb68230da8844d165d6fda..214c9e723551561854cdc25d1727d6f0cc4bd530 100644 --- a/tools/sdk/include/bluedroid/btc_media.h +++ b/tools/sdk/include/bluedroid/btc_a2dp_source.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 +#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 Request to initialize the media task encoder - ** - ** Returns TRUE is success + ** Description Shutdown and cleanup the A2DP source module. ** *******************************************************************************/ -extern BOOLEAN btc_media_task_enc_init_req(tBTC_MEDIA_INIT_AUDIO *p_msg); +void btc_a2dp_source_shutdown(void); /******************************************************************************* ** - ** Function btc_media_task_enc_update_req + ** Function btc_a2dp_source_enc_init_req ** - ** Description Request to update the media task encoder + ** Description Request to initialize 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_init_req(tBTC_MEDIA_INIT_AUDIO *p_msg); /******************************************************************************* ** - ** Function btc_media_task_start_aa_req + ** Function btc_a2dp_source_enc_udpate_req ** - ** Description Request to start audio encoding task + ** Description Request to update the media task encoder ** ** Returns TRUE is success ** *******************************************************************************/ -extern BOOLEAN btc_media_task_start_aa_req(void); +BOOLEAN btc_a2dp_source_enc_update_req(tBTC_MEDIA_UPDATE_AUDIO *p_msg); + /******************************************************************************* ** - ** Function btc_media_task_stop_aa_req + ** Function btc_a2dp_source_start_audio_req ** - ** Description Request to stop audio encoding task + ** Description Request to start audio encoding task ** ** Returns TRUE is success ** *******************************************************************************/ -extern BOOLEAN btc_media_task_stop_aa_req(void); +BOOLEAN btc_a2dp_source_start_audio_req(void); /******************************************************************************* ** - ** Function btc_media_task_aa_rx_flush_req + ** Function btc_a2dp_source_stop_audio_req ** - ** Description Request to flush audio decoding pipe + ** Description Request to stop audio encoding task ** ** Returns TRUE is success ** *******************************************************************************/ -extern BOOLEAN btc_media_task_aa_rx_flush_req(void); +BOOLEAN btc_a2dp_source_stop_audio_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 + ** Function btc_a2dp_source_audio_feeding_init_req ** - ** Description This function is called by the av_co to fill A2DP Sink Queue + ** Description Request to initialize audio feeding ** + ** Returns TRUE if success ** - ** Returns size of the queue *******************************************************************************/ -UINT8 btc_media_sink_enque_buf(BT_HDR *p_buf); - +BOOLEAN btc_a2dp_source_audio_feeding_init_req(tBTC_MEDIA_INIT_AUDIO_FEEDING *p_msg); /******************************************************************************* ** - ** Function btc_media_aa_writebuf - ** - ** Description Enqueue a Advance Audio media buffer to be processed by btc media task. + ** Function btc_a2dp_source_is_streaming ** - ** Returns TRUE is success + ** Description Check whether A2DP source is in streaming state ** *******************************************************************************/ -extern void btc_media_aa_writebuf(BT_HDR *pBuf, UINT32 timestamp, UINT16 seq_num); +bool btc_a2dp_source_is_streaming(void); /******************************************************************************* ** - ** Function btc_media_av_writebuf - ** - ** Description Enqueue a video media buffer to be processed by btc media task. + ** Function btc_a2dp_source_is_task_shutting_down ** - ** Returns TRUE is success + ** Description Check whether A2DP source media task is shutting down ** *******************************************************************************/ -extern BOOLEAN btc_media_av_writebuf(UINT8 *p_media, UINT32 media_len, - UINT32 timestamp, UINT16 seq_num); +bool btc_a2dp_source_is_task_shutting_down(void); + -#if (BTA_AV_INCLUDED == TRUE) /******************************************************************************* ** - ** Function btc_media_task_audio_feeding_init_req + ** Function btc_a2dp_source_on_idle ** - ** Description Request to initialize audio feeding - ** - ** Returns TRUE is success + ** Description Request 'idle' request from BTC AV state machine during + ** initialization ** *******************************************************************************/ +void btc_a2dp_source_on_idle(void); -extern BOOLEAN btc_media_task_audio_feeding_init_req(tBTC_MEDIA_INIT_AUDIO_FEEDING *p_msg); -#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 dump_codec_info + ** Function btc_a2dp_source_on_suspended ** - ** Description Decode and display codec_info (for debug) + ** Description Process 'suspend' request from the BTC AV state machine to stop + ** A2DP streaming ** - ** Returns void + *******************************************************************************/ +void btc_a2dp_source_on_suspended(tBTA_AV_SUSPEND *p_av); + +/******************************************************************************* + ** + ** Function btc_a2dp_source_setup_codec + ** + ** Description initialize the encoder parameters ** *******************************************************************************/ -extern void dump_codec_info(unsigned char *p_codec); +void btc_a2dp_source_setup_codec(void); -/** - * Local adaptation helper functions between btc and media task - */ +/******************************************************************************* + ** + ** Function btc_a2dp_source_set_tx_flush + ** + ** Description enable/disable discarding of transmitted frames + ** + *******************************************************************************/ +void btc_a2dp_source_set_tx_flush(BOOLEAN enable); -bool btc_a2dp_start_media_task(void); -void btc_a2dp_stop_media_task(void); +/******************************************************************************* + ** + ** Function btc_a2dp_source_encoder_update + ** + ** Description update changed SBC encoder parameters + ** + *******************************************************************************/ +void btc_a2dp_source_encoder_update(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); +#endif /* #if BTC_AV_SRC_INCLUDED */ -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 +#endif /* __BTC_A2DP_SOURCE_H__ */ diff --git a/tools/sdk/include/bluedroid/btc_av.h b/tools/sdk/include/bluedroid/btc_av.h index 8a8664cd219bc70b23ff4e04918049e1e383a30f..312958b0c95357704a80751c96d3e4dc6b2a21d8 100644 --- a/tools/sdk/include/bluedroid/btc_av.h +++ b/tools/sdk/include/bluedroid/btc_av.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__ */ diff --git a/tools/sdk/include/bluedroid/btc_av_api.h b/tools/sdk/include/bluedroid/btc_av_api.h index c7672a07534dc007ac8ed11e1efe1bc9155febfb..7d5f376d6fa6ff95d41496149fc1dc5802755fec 100644 --- a/tools/sdk/include/bluedroid/btc_av_api.h +++ b/tools/sdk/include/bluedroid/btc_av_api.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" diff --git a/tools/sdk/include/bluedroid/btc_av_co.h b/tools/sdk/include/bluedroid/btc_av_co.h index 9ec9b5d4488f43f2279b6899cae3aebbecdb43fc..cacaa01d8ff5bcc97b48eac0ed434ffcda8ac89f 100644 --- a/tools/sdk/include/bluedroid/btc_av_co.h +++ b/tools/sdk/include/bluedroid/btc_av_co.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); /******************************************************************************* ** diff --git a/tools/sdk/include/bluedroid/btc_avrc.h b/tools/sdk/include/bluedroid/btc_avrc.h index 3f16d10f3cca7362d7c72e2ebead6e17537475c5..836696433ff2e33a37feab008be434a8d35b99c6 100644 --- a/tools/sdk/include/bluedroid/btc_avrc.h +++ b/tools/sdk/include/bluedroid/btc_avrc.h @@ -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. */ diff --git a/tools/sdk/include/bluedroid/btc_blufi_prf.h b/tools/sdk/include/bluedroid/btc_blufi_prf.h index 1d82d0c9a5b0bba652fcce7e5f33204314a6a88a..93fe6bf2e9e48bf3b68cbeeb131c90f49a8b8eb9 100644 --- a/tools/sdk/include/bluedroid/btc_blufi_prf.h +++ b/tools/sdk/include/bluedroid/btc_blufi_prf.h @@ -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); diff --git a/tools/sdk/include/bluedroid/btc_gap_bt.h b/tools/sdk/include/bluedroid/btc_gap_bt.h index d77a4b9f65d25555d57816b0c2798b90830a7c8f..01b070965261dff22c26b9d2a56cd097d7bf873c 100644 --- a/tools/sdk/include/bluedroid/btc_gap_bt.h +++ b/tools/sdk/include/bluedroid/btc_gap_bt.h @@ -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__ */ diff --git a/tools/sdk/include/bluedroid/btc_spp.h b/tools/sdk/include/bluedroid/btc_spp.h new file mode 100644 index 0000000000000000000000000000000000000000..631c69646e78c093d31c61f10283a38fec436c4b --- /dev/null +++ b/tools/sdk/include/bluedroid/btc_spp.h @@ -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__ \ No newline at end of file diff --git a/tools/sdk/include/bluedroid/btc_task.h b/tools/sdk/include/bluedroid/btc_task.h index c91aaad547f61e88a2018f7df8f12ae3abb07ba3..f19c266991a7932a5dc59dc8c1b13f51a6b442c0 100644 --- a/tools/sdk/include/bluedroid/btc_task.h +++ b/tools/sdk/include/bluedroid/btc_task.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 diff --git a/tools/sdk/include/bluedroid/btc_util.h b/tools/sdk/include/bluedroid/btc_util.h index 23a8fe309dd21e6b8f986496e706fe2e03bacc41..d2bfdcca8771b19ef0a60d4f3da37673e5de799d 100644 --- a/tools/sdk/include/bluedroid/btc_util.h +++ b/tools/sdk/include/bluedroid/btc_util.h @@ -18,6 +18,7 @@ #include #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__ */ diff --git a/tools/sdk/include/bluedroid/btm_ble_api.h b/tools/sdk/include/bluedroid/btm_ble_api.h index fa6c575eac5c61ba96cf2ab3bc74399a4b1f97d1..0587b65be2d00c4db8160b31f9fdda6bb6dc4087 100644 --- a/tools/sdk/include/bluedroid/btm_ble_api.h +++ b/tools/sdk/include/bluedroid/btm_ble_api.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); /******************************************************************************* ** diff --git a/tools/sdk/include/bluedroid/btm_ble_int.h b/tools/sdk/include/bluedroid/btm_ble_int.h index b690db1bb17f120dc3112ea2f6bab38749ae9ed1..f5b6c90b1526e2c04e75987f05bf3c6347d67569 100644 --- a/tools/sdk/include/bluedroid/btm_ble_int.h +++ b/tools/sdk/include/bluedroid/btm_ble_int.h @@ -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; diff --git a/tools/sdk/include/bluedroid/btu.h b/tools/sdk/include/bluedroid/btu.h index 862ccec135b5488a4442b2470da47019c3c51040..0401e471c681d2373126931b1cb16ee9e2c96cb9 100644 --- a/tools/sdk/include/bluedroid/btu.h +++ b/tools/sdk/include/bluedroid/btu.h @@ -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); diff --git a/tools/sdk/include/bluedroid/controller.h b/tools/sdk/include/bluedroid/controller.h index 6d6e5a8ca34781c32ec40e38dabe7d5764c53d2a..bffa714f4330897fa252c48cadd1d7a8d6a97a35 100644 --- a/tools/sdk/include/bluedroid/controller.h +++ b/tools/sdk/include/bluedroid/controller.h @@ -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); diff --git a/tools/sdk/include/bluedroid/esp_a2dp_api.h b/tools/sdk/include/bluedroid/esp_a2dp_api.h index 7f6868dde14a0edae1a0dc5c379e16cb48493d43..ab11871467150c2a878811fa8a1b1580664aae33 100644 --- a/tools/sdk/include/bluedroid/esp_a2dp_api.h +++ b/tools/sdk/include/bluedroid/esp_a2dp_api.h @@ -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 @@ -84,7 +101,7 @@ typedef union { esp_bd_addr_t remote_bda; /*!< remote bluetooth device address */ esp_a2d_disc_rsn_t disc_rsn; /*!< reason of disconnection for "DISCONNECTED" */ } conn_stat; /*!< A2DP connection status */ - + /** * @brief ESP_A2D_AUDIO_STATE_EVT */ @@ -92,7 +109,7 @@ typedef union { esp_a2d_audio_state_t state; /*!< one of the values from esp_a2d_audio_state_t */ esp_bd_addr_t remote_bda; /*!< remote bluetooth device address */ } audio_stat; /*!< audio stream playing state */ - + /** * @brief ESP_A2D_AUDIO_CFG_EVT */ @@ -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_data_cb_t)(const uint8_t *buf, uint32_t len); +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 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 - * - * @param[in] callback: A2DP sink event callback function + * only after esp_bluedroid_enable() completes successfully, used by both A2DP source + * and sink. + * + * @param[in] callback: A2DP event callback function * * @return * - ESP_OK: success @@ -138,10 +175,10 @@ 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 - * - * @param[in] callback: A2DP data callback function + * from SBC format. This function should be called only after esp_bluedroid_enable() + * completes successfully, used only by A2DP sink. + * + * @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); /** @@ -157,7 +194,7 @@ esp_err_t esp_a2d_register_data_callback(esp_a2d_data_cb_t callback); * @brief Initialize the bluetooth A2DP sink module. This function should be called * after esp_bluedroid_enable() completes successfully * - * @return + * @return * - ESP_OK: if the initialization request is sent successfully * - ESP_INVALID_STATE: if bluetooth stack is not yet enabled * - ESP_FAIL: others @@ -168,10 +205,10 @@ esp_err_t esp_a2d_sink_init(void); /** * - * @brief De-initialize for A2DP sink module. This function + * @brief De-initialize for A2DP sink module. This function * should be called only after esp_bluedroid_enable() completes successfully * - * @return + * @return * - ESP_OK: success * - ESP_INVALID_STATE: if bluetooth stack is not yet enabled * - ESP_FAIL: others @@ -182,11 +219,11 @@ 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 * - * @return + * @return * - ESP_OK: connect request is sent to lower layer * - ESP_INVALID_STATE: if bluetooth stack is not yet enabled * - ESP_FAIL: others @@ -197,10 +234,10 @@ 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 + * @return * - ESP_OK: disconnect request is sent to lower layer * - ESP_INVALID_STATE: if bluetooth stack is not yet enabled * - ESP_FAIL: others @@ -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 diff --git a/tools/sdk/include/bluedroid/esp_avrc_api.h b/tools/sdk/include/bluedroid/esp_avrc_api.h index e30742098f851ac5b8864ea0d39dade60c1828d1..228beb8ae67cfb5568c6a7441a9f849695fc85a8 100644 --- a/tools/sdk/include/bluedroid/esp_avrc_api.h +++ b/tools/sdk/include/bluedroid/esp_avrc_api.h @@ -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, /*> 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 diff --git a/tools/sdk/include/bluedroid/esp_spp_api.h b/tools/sdk/include/bluedroid/esp_spp_api.h new file mode 100644 index 0000000000000000000000000000000000000000..5a6bb7d463b1c4fe9567001444a35e304251b032 --- /dev/null +++ b/tools/sdk/include/bluedroid/esp_spp_api.h @@ -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__ \ No newline at end of file diff --git a/tools/sdk/include/bluedroid/hci_packet_parser.h b/tools/sdk/include/bluedroid/hci_packet_parser.h index 916ea313f6741dc3d879b004fa77879dab5cf9d2..7090708f0d0a2b7e6b1d3b489e794e8c46a7c37d 100644 --- a/tools/sdk/include/bluedroid/hci_packet_parser.h +++ b/tools/sdk/include/bluedroid/hci_packet_parser.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; diff --git a/tools/sdk/include/bluedroid/port_api.h b/tools/sdk/include/bluedroid/port_api.h index d5420f56b958760cfa1408bd3c697a077b4b4e72..f37a56c9abaf3b6801d167671bb851a633985ffb 100644 --- a/tools/sdk/include/bluedroid/port_api.h +++ b/tools/sdk/include/bluedroid/port_api.h @@ -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); /******************************************************************************* ** diff --git a/tools/sdk/include/bluedroid/port_int.h b/tools/sdk/include/bluedroid/port_int.h index aa6d48e7fcd8ae868684331bcf5c27d541f1c520..7b1065c6c05f8b1b057db0862b0ec9d136316dd7 100644 --- a/tools/sdk/include/bluedroid/port_int.h +++ b/tools/sdk/include/bluedroid/port_int.h @@ -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 */ /* ???*/ diff --git a/tools/sdk/include/bluedroid/thread.h b/tools/sdk/include/bluedroid/thread.h index 9ac5da6bd98f5b44b7528b4a92665f8749f15c97..afd3f08d03a4503c9fcd90f338f1a0076d379624 100644 --- a/tools/sdk/include/bluedroid/thread.h +++ b/tools/sdk/include/bluedroid/thread.h @@ -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) diff --git a/tools/sdk/include/bootloader_support/bootloader_clock.h b/tools/sdk/include/bootloader_support/bootloader_clock.h new file mode 100644 index 0000000000000000000000000000000000000000..9eaba46a8cd7ebd2260b88e83e17e2f561da3a9c --- /dev/null +++ b/tools/sdk/include/bootloader_support/bootloader_clock.h @@ -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); diff --git a/tools/sdk/include/bt/bt.h b/tools/sdk/include/bt/bt.h index 0c0355b60d3b46cc664199a7fe0ffc5da47b96d4..a957698fb0c8bfa36ea492bbc06d4f4ba6084e37 100644 --- a/tools/sdk/include/bt/bt.h +++ b/tools/sdk/include/bt/bt.h @@ -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 -#include -#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" diff --git a/tools/sdk/include/bt/esp_bt.h b/tools/sdk/include/bt/esp_bt.h new file mode 100644 index 0000000000000000000000000000000000000000..dcd531b6d035bbc8847bd7c2c7d07aa1ca47b4eb --- /dev/null +++ b/tools/sdk/include/bt/esp_bt.h @@ -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 +#include +#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__ */ diff --git a/tools/sdk/include/config/sdkconfig.h b/tools/sdk/include/config/sdkconfig.h index c998fd64a0bae41032cf6f0f9cd2ef99d370a778..b79a1dbd818882a8ef00d93998fdebff3f52b0fc 100644 --- a/tools/sdk/include/config/sdkconfig.h +++ b/tools/sdk/include/config/sdkconfig.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 diff --git a/tools/sdk/include/driver/driver/i2c.h b/tools/sdk/include/driver/driver/i2c.h index 765eab01cf9e3eb8e7ff9da30d01ebcfabafff13..b7aceb7b131771c25b92023ab484d63422e59c6b 100644 --- a/tools/sdk/include/driver/driver/i2c.h +++ b/tools/sdk/include/driver/driver/i2c.h @@ -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 diff --git a/tools/sdk/include/driver/driver/ledc.h b/tools/sdk/include/driver/driver/ledc.h index 55c0c8d2ac30e79f58612c77c8e9e0d3204f0aa7..c5250213d6c441fe5fc17b340b74a0901113bdff 100644 --- a/tools/sdk/include/driver/driver/ledc.h +++ b/tools/sdk/include/driver/driver/ledc.h @@ -30,7 +30,7 @@ extern "C" { typedef enum { LEDC_HIGH_SPEED_MODE = 0, /*!< LEDC high speed speed_mode */ - LEDC_LOW_SPEED_MODE, /*!< LEDC low speed speed_mode */ + LEDC_LOW_SPEED_MODE, /*!< LEDC low speed speed_mode */ LEDC_SPEED_MODE_MAX, /*!< LEDC speed limit */ } ledc_mode_t; @@ -45,15 +45,15 @@ typedef enum { } ledc_duty_direction_t; typedef enum { - LEDC_REF_TICK = 0, /*!< LEDC timer clock divided from reference tick(1Mhz) */ - LEDC_APB_CLK, /*!< LEDC timer clock divided from APB clock(80Mhz)*/ + LEDC_REF_TICK = 0, /*!< LEDC timer clock divided from reference tick (1Mhz) */ + LEDC_APB_CLK, /*!< LEDC timer clock divided from APB clock (80Mhz) */ } 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,46 +69,50 @@ 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 { LEDC_FADE_NO_WAIT = 0, /*!< LEDC fade function will return immediately */ - LEDC_FADE_WAIT_DONE, /*!< LEDC fade function will block until fading to the target duty*/ + 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 */ typedef struct { - int gpio_num; /*!< the LEDC output gpio_num, if you want to use gpio16, gpio_num = 16*/ - ledc_mode_t speed_mode; /*!< LEDC speed speed_mode, high-speed mode or low-speed mode*/ - 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], */ + int gpio_num; /*!< the LEDC output gpio_num, if you want to use gpio16, gpio_num = 16 */ + ledc_mode_t speed_mode; /*!< LEDC speed speed_mode, high-speed mode or low-speed mode */ + 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 range of duty setting is [0, (2**duty_resolution) - 1] */ } ledc_channel_config_t; /** * @brief Configuration parameters of LEDC Timer timer for ledc_timer_config function */ 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*/ - ledc_timer_t timer_num; /*!< The timer source of channel (0 - 3)*/ - uint32_t freq_hz; /*!< LEDC timer frequency(Hz)*/ + ledc_mode_t speed_mode; /*!< LEDC speed speed_mode, high-speed mode or low-speed mode */ + 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; 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); @@ -137,7 +141,7 @@ esp_err_t ledc_timer_config(const ledc_timer_config_t* timer_conf); * After ledc_set_duty, ledc_set_fade, we need to call this function to update the settings. * * @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 channel LEDC channel (0-7), select from ledc_channel_t * * @return * - ESP_OK Success @@ -151,7 +155,7 @@ esp_err_t ledc_update_duty(ledc_mode_t speed_mode, ledc_channel_t channel); * Disable LEDC output, and set idle level * * @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 channel LEDC channel (0-7), select from ledc_channel_t * @param idle_level Set output idle level after LEDC stops. * * @return @@ -161,24 +165,24 @@ esp_err_t ledc_update_duty(ledc_mode_t speed_mode, ledc_channel_t channel); esp_err_t ledc_stop(ledc_mode_t speed_mode, ledc_channel_t channel, uint32_t idle_level); /** - * @brief LEDC set channel frequency(Hz) + * @brief LEDC set channel frequency (Hz) * * @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode - * @param timer_num LEDC timer index(0-3), select from ledc_timer_t + * @param timer_num LEDC timer index (0-3), select from ledc_timer_t * @param freq_hz Set the LEDC frequency * * @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); /** - * @brief LEDC get channel frequency(Hz) + * @brief LEDC get channel frequency (Hz) * * @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode - * @param timer_num LEDC timer index(0-3), select from ledc_timer_t + * @param timer_num LEDC timer index (0-3), select from ledc_timer_t * * @return * - 0 error @@ -191,8 +195,8 @@ uint32_t ledc_get_freq(ledc_mode_t speed_mode, ledc_timer_t timer_num); * Only after calling ledc_update_duty will the duty update. * * @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 channel LEDC channel (0-7), select from ledc_channel_t + * @param duty Set the LEDC duty, the range of duty setting is [0, (2**duty_resolution) - 1] * * @return * - ESP_OK Success @@ -204,7 +208,7 @@ esp_err_t ledc_set_duty(ledc_mode_t speed_mode, ledc_channel_t channel, uint32_t * @brief LEDC get duty * * @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 channel LEDC channel (0-7), select from ledc_channel_t * * @return * - LEDC_ERR_DUTY if parameter error @@ -217,8 +221,8 @@ uint32_t ledc_get_duty(ledc_mode_t speed_mode, ledc_channel_t channel); * Set LEDC gradient, After the function calls the ledc_update_duty function, the function can take effect. * * @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 channel LEDC channel (0-7), select from ledc_channel_t + * @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 @@ -253,22 +257,22 @@ esp_err_t ledc_isr_register(void (*fn)(void*), void * arg, int intr_alloc_flags, * @brief Configure LEDC settings * * @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 timer_sel Timer index (0-3), there are 4 timers in LEDC module + * @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 * * @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode - * @param timer_sel LEDC timer index(0-3), select from ledc_timer_t + * @param timer_sel LEDC timer index (0-3), select from ledc_timer_t * * @return * - ESP_ERR_INVALID_ARG Parameter error @@ -280,7 +284,7 @@ esp_err_t ledc_timer_rst(ledc_mode_t speed_mode, uint32_t timer_sel); * @brief Pause LEDC timer counter * * @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode - * @param timer_sel LEDC timer index(0-3), select from ledc_timer_t + * @param timer_sel LEDC timer index (0-3), select from ledc_timer_t * * @return * - ESP_ERR_INVALID_ARG Parameter error @@ -293,7 +297,7 @@ esp_err_t ledc_timer_pause(ledc_mode_t speed_mode, uint32_t timer_sel); * @brief Resume LEDC timer * * @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode - * @param timer_sel LEDC timer index(0-3), select from ledc_timer_t + * @param timer_sel LEDC timer index (0-3), select from ledc_timer_t * * @return * - ESP_ERR_INVALID_ARG Parameter error @@ -305,8 +309,8 @@ esp_err_t ledc_timer_resume(ledc_mode_t speed_mode, uint32_t timer_sel); * @brief Bind LEDC channel with the selected timer * * @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 timer_idx LEDC timer index(0-3), select from ledc_timer_t + * @param channel LEDC channel index (0-7), select from ledc_channel_t + * @param timer_idx LEDC timer index (0-3), select from ledc_timer_t * * @return * - ESP_ERR_INVALID_ARG Parameter error @@ -319,8 +323,8 @@ esp_err_t ledc_bind_channel_timer(ledc_mode_t speed_mode, uint32_t channel, uint * Call ledc_fade_start() after this to start fading. * * @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 channel LEDC channel index (0-7), select from ledc_channel_t + * @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 * @@ -337,8 +341,8 @@ esp_err_t ledc_set_fade_with_step(ledc_mode_t speed_mode, ledc_channel_t channel * Call ledc_fade_start() after this to start fading. * * @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 channel LEDC channel index (0-7), select from ledc_channel_t + * @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 diff --git a/tools/sdk/include/driver/driver/rmt.h b/tools/sdk/include/driver/driver/rmt.h index 56c5ed4952d098163ea79bfa5bdae53fdca909e2..13d97b91cd1f1c39f32234ad3fe4f019d2873581 100644 --- a/tools/sdk/include/driver/driver/rmt.h +++ b/tools/sdk/include/driver/driver/rmt.h @@ -33,14 +33,14 @@ extern "C" { #define RMT_MEM_ITEM_NUM (RMT_MEM_BLOCK_BYTE_NUM/4) typedef enum { - RMT_CHANNEL_0=0, /*!< RMT Channel0 */ - RMT_CHANNEL_1, /*!< RMT Channel1 */ - RMT_CHANNEL_2, /*!< RMT Channel2 */ - RMT_CHANNEL_3, /*!< RMT Channel3 */ - RMT_CHANNEL_4, /*!< RMT Channel4 */ - RMT_CHANNEL_5, /*!< RMT Channel5 */ - RMT_CHANNEL_6, /*!< RMT Channel6 */ - RMT_CHANNEL_7, /*!< RMT Channel7 */ + RMT_CHANNEL_0 = 0, /*!< RMT Channel 0 */ + RMT_CHANNEL_1, /*!< RMT Channel 1 */ + RMT_CHANNEL_2, /*!< RMT Channel 2 */ + RMT_CHANNEL_3, /*!< RMT Channel 3 */ + RMT_CHANNEL_4, /*!< RMT Channel 4 */ + RMT_CHANNEL_5, /*!< RMT Channel 5 */ + RMT_CHANNEL_6, /*!< RMT Channel 6 */ + RMT_CHANNEL_7, /*!< RMT Channel 7 */ RMT_CHANNEL_MAX } rmt_channel_t; @@ -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; @@ -63,20 +63,20 @@ typedef enum { } rmt_data_mode_t; typedef enum { - RMT_MODE_TX=0, /*!< RMT TX mode */ - RMT_MODE_RX, /*!< RMT RX mode */ + RMT_MODE_TX = 0, /*!< RMT TX mode */ + RMT_MODE_RX, /*!< RMT RX mode */ RMT_MODE_MAX } rmt_mode_t; typedef enum { - RMT_IDLE_LEVEL_LOW=0, /*!< RMT TX idle level: low Level */ - RMT_IDLE_LEVEL_HIGH, /*!< RMT TX idle level: high Level */ + RMT_IDLE_LEVEL_LOW = 0, /*!< RMT TX idle level: low Level */ + RMT_IDLE_LEVEL_HIGH, /*!< RMT TX idle level: high Level */ RMT_IDLE_LEVEL_MAX, } rmt_idle_level_t; typedef enum { - RMT_CARRIER_LEVEL_LOW=0, /*!< RMT carrier wave is modulated for low Level output */ - RMT_CARRIER_LEVEL_HIGH, /*!< RMT carrier wave is modulated for high Level output */ + RMT_CARRIER_LEVEL_LOW = 0, /*!< RMT carrier wave is modulated for low Level output */ + RMT_CARRIER_LEVEL_HIGH, /*!< RMT carrier wave is modulated for high Level output */ RMT_CARRIER_LEVEL_MAX } rmt_carrier_level_t; @@ -84,21 +84,21 @@ 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*/ + bool idle_output_en; /*!< RMT idle level output enable */ }rmt_tx_config_t; /** * @brief Data struct of RMT RX configure parameters */ typedef struct { - bool filter_en; /*!< RMT receiver filer enable*/ - uint8_t filter_ticks_thresh; /*!< RMT filter tick number */ + 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,14 +196,16 @@ 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. - * Channel0 can use at most 8 blocks of memory, accordingly channel7 can only use one memory block. + * Channel 0 can use at most 8 blocks of memory, accordingly channel 7 can only use one memory block. * * @param channel RMT channel (0-7) * @@ -232,11 +244,9 @@ 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 channel0-7. - * - * 1'b1:transmit on low output level - * - * 1'b0:transmit on high output level + * @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 * * @return * - ESP_ERR_INVALID_ARG Parameter error @@ -278,7 +288,7 @@ esp_err_t rmt_get_mem_pd(rmt_channel_t channel, bool* pd_en); * @param channel RMT channel (0-7) * * @param tx_idx_rst Set true to reset memory index for TX. - * Otherwise, transmitter will continue sending from the last index in memory. + * Otherwise, transmitter will continue sending from the last index in memory. * * @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 @@ -391,7 +400,7 @@ esp_err_t rmt_get_tx_loop_mode(rmt_channel_t channel, bool* loop_en); /** * @brief Set RMT RX filter. * - * In receive mode, channel0-7 will ignore input pulse when the pulse width is smaller than threshold. + * In receive mode, channel 0-7 will ignore input pulse when the pulse width is smaller than threshold. * Counted in source clock, not divided counter clock. * * @param channel RMT channel (0-7) @@ -409,9 +418,9 @@ 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). + * 2. REF tick clock, which would be 1Mhz (not supported in this version). * * @param channel RMT channel (0-7) * @@ -426,9 +435,9 @@ 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). + * 2. REF tick clock, which would be 1Mhz (not supported in this version). * * @param channel RMT channel (0-7) * @@ -447,7 +456,7 @@ esp_err_t rmt_get_source_clk(rmt_channel_t channel, rmt_source_clk_t* src_clk); * * @param idle_out_en To enable idle level output. * - * @param level To set the output signal's level for channel0-7 in idle state. + * @param level To set the output signal's level for channel 0-7 in idle state. * * @return * - ESP_ERR_INVALID_ARG Parameter error @@ -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,17 +576,18 @@ 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. + * 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 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. + * @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. * * @return * - ESP_OK Success @@ -653,18 +663,18 @@ 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, - * and send the waveform items. - * If wait_tx_done is set to true, this function will block and will not return until - * all items have been sent out. - * If wait_tx_done is set to false, this function will return immediately, and the driver - * interrupt will continue sending the items. We must make sure the item data will not be - * damaged when the driver is still sending items in driver interrupt. + * @note + * This function will not copy data, instead, it will point to the original items, + * and send the waveform items. + * If wait_tx_done is set to true, this function will block and will not return until + * all items have been sent out. + * If wait_tx_done is set to false, this function will return immediately, and the driver + * interrupt will continue sending the items. We must make sure the item data will not be + * damaged when the driver is still sending items in driver interrupt. * * @return * - ESP_ERR_INVALID_ARG Parameter error @@ -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 diff --git a/tools/sdk/include/driver/driver/rtc_io.h b/tools/sdk/include/driver/driver/rtc_io.h index 831a07fdb3b6f4795e41940bf5b3faa63cbb85ac..c7219d3eb3f65630030c5c753e8a2a3a785f543d 100644 --- a/tools/sdk/include/driver/driver/rtc_io.h +++ b/tools/sdk/include/driver/driver/rtc_io.h @@ -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; diff --git a/tools/sdk/include/driver/driver/spi_master.h b/tools/sdk/include/driver/driver/spi_master.h index 4e5b66f62886dddd3c249e6fe55fccc6e47e772f..2e17e85696d5a07ff893c8537ad920aa73c6c9ab 100644 --- a/tools/sdk/include/driver/driver/spi_master.h +++ b/tools/sdk/include/driver/driver/spi_master.h @@ -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 } diff --git a/tools/sdk/include/esp32/esp_intr_alloc.h b/tools/sdk/include/esp32/esp_intr_alloc.h index ad121abb39255745e42dcb165d851f14a89ca242..b5420f798173f4a9818562775e87d0f17741fd8c 100644 --- a/tools/sdk/include/esp32/esp_intr_alloc.h +++ b/tools/sdk/include/esp32/esp_intr_alloc.h @@ -37,13 +37,13 @@ extern "C" { */ //Keep the LEVELx values as they are here; they match up with (1< 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. + * 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. diff --git a/tools/sdk/include/ethernet/esp_eth.h b/tools/sdk/include/ethernet/esp_eth.h index 0a9f3e770fbb827837be00a8875a979fe8b0aff5..f4622d0ee7bafad4a9b3a2e732680f3ce3de6d62 100644 --- a/tools/sdk/include/ethernet/esp_eth.h +++ b/tools/sdk/include/ethernet/esp_eth.h @@ -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 diff --git a/tools/sdk/include/freertos/freertos/FreeRTOS.h b/tools/sdk/include/freertos/freertos/FreeRTOS.h index 50ceae18d8952c854903c82445786739f278d8bd..1bc931757c8d4748ee722e12cf21824ed8e16139 100644 --- a/tools/sdk/include/freertos/freertos/FreeRTOS.h +++ b/tools/sdk/include/freertos/freertos/FreeRTOS.h @@ -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 diff --git a/tools/sdk/include/freertos/freertos/event_groups.h b/tools/sdk/include/freertos/freertos/event_groups.h index c7d0156abe43c893a716b0ff414db27ff87e593a..eda2456388d668290f4a85e5597551f57199f786 100644 --- a/tools/sdk/include/freertos/freertos/event_groups.h +++ b/tools/sdk/include/freertos/freertos/event_groups.h @@ -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 - *
- EventGroupHandle_t xEventGroupCreate( void );
- 
- * - * Create a new event group. This function cannot be called from an interrupt. + * 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 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: -
-	// 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.
-	}
-   
- * \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 */ -EventGroupHandle_t xEventGroupCreate( void ) PRIVILEGED_FUNCTION; +#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + EventGroupHandle_t xEventGroupCreate( void ) PRIVILEGED_FUNCTION; +#endif /** - * event_groups.h - *
-	EventBits_t xEventGroupWaitBits( 	EventGroupHandle_t xEventGroup,
-										const EventBits_t uxBitsToWaitFor,
-										const BaseType_t xClearOnExit,
-										const BaseType_t xWaitForAllBits,
-										const TickType_t xTicksToWait );
- 
+ * 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: -
-   #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.
-		}
-   }
-   
- * \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 - *
-	EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear );
- 
- * * 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: -
-   #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.
-		}
-   }
-   
- * \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 - *
-	BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet );
- 
- * * 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: -
-   #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.
-		}
-  }
-   
- * \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 - *
-	EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet );
- 
- * * 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: -
-   #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.
-		}
-   }
-   
- * \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 - *
-	BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken );
- 
- * * 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: -
-   #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 );
-		}
-  }
-   
- * \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 - *
-	EventBits_t xEventGroupSync(	EventGroupHandle_t xEventGroup,
-									const EventBits_t uxBitsToSet,
-									const EventBits_t uxBitsToWaitFor,
-									TickType_t xTicksToWait );
- 
- * * 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: -
- // 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.
-	}
- }
-
- 
- * \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 - *
-	EventBits_t xEventGroupGetBits( EventGroupHandle_t xEventGroup );
- 
- * * 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 - *
-	EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup );
- 
- * * 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 - *
-	void xEventGroupDelete( EventGroupHandle_t xEventGroup );
- 
* * 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 diff --git a/tools/sdk/include/freertos/freertos/portmacro.h b/tools/sdk/include/freertos/freertos/portmacro.h index 5632cd56209e9b0ee14f1b7cf3e3e62ce0334908..93d2071ba540a0a7d0c542e95b8935e0e6c240f5 100644 --- a/tools/sdk/include/freertos/freertos/portmacro.h +++ b/tools/sdk/include/freertos/freertos/portmacro.h @@ -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)) diff --git a/tools/sdk/include/freertos/freertos/queue.h b/tools/sdk/include/freertos/freertos/queue.h index 638157765acc9f8b1c9cf6f8f887fcaa0f8aa6ba..e15152ee975a192a488a25755c1ae854bf38a821 100644 --- a/tools/sdk/include/freertos/freertos/queue.h +++ b/tools/sdk/include/freertos/freertos/queue.h @@ -101,6 +101,7 @@ typedef void * QueueSetHandle_t; */ typedef void * QueueSetMemberHandle_t; +/** @cond */ /* For internal use only. */ #define queueSEND_TO_BACK ( ( BaseType_t ) 0 ) #define queueSEND_TO_FRONT ( ( BaseType_t ) 1 ) @@ -114,15 +115,9 @@ typedef void * QueueSetMemberHandle_t; #define queueQUEUE_TYPE_BINARY_SEMAPHORE ( ( uint8_t ) 3U ) #define queueQUEUE_TYPE_RECURSIVE_MUTEX ( ( uint8_t ) 4U ) +/** @endcond */ + /** - * queue. h - *
- QueueHandle_t xQueueCreate(
-							  UBaseType_t uxQueueLength,
-							  UBaseType_t uxItemSize
-						  );
- * 
- * * Creates a new queue instance. This allocates the storage required by the * new queue and returns a handle for the queue. * @@ -138,36 +133,35 @@ typedef void * QueueSetMemberHandle_t; * returned. * * Example usage: -
- struct AMessage
- {
-	char ucMessageID;
-	char ucData[ 20 ];
- };
-
- void vATask( void *pvParameters )
- {
- QueueHandle_t xQueue1, xQueue2;
-
-	// Create a queue capable of containing 10 uint32_t values.
-	xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
-	if( xQueue1 == 0 )
-	{
-		// Queue was not created and must not be used.
-	}
-
-	// Create a queue capable of containing 10 pointers to AMessage structures.
-	// These should be passed by pointer as they contain a lot of data.
-	xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
-	if( xQueue2 == 0 )
-	{
-		// Queue was not created and must not be used.
-	}
-
-	// ... Rest of task code.
- }
- 
- * \defgroup xQueueCreate xQueueCreate + * @code{c} + * struct AMessage + * { + * char ucMessageID; + * char ucData[ 20 ]; + * }; + * + * void vATask( void *pvParameters ) + * { + * QueueHandle_t xQueue1, xQueue2; + * + * // Create a queue capable of containing 10 uint32_t values. + * xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) ); + * if( xQueue1 == 0 ) + * { + * // Queue was not created and must not be used. + * } + * + * // Create a queue capable of containing 10 pointers to AMessage structures. + * // These should be passed by pointer as they contain a lot of data. + * xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) ); + * if( xQueue2 == 0 ) + * { + * // Queue was not created and must not be used. + * } + * + * // ... Rest of task code. + * } + * @endcode * \ingroup QueueManagement */ #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) @@ -175,16 +169,6 @@ typedef void * QueueSetMemberHandle_t; #endif /** - * queue. h - *
- QueueHandle_t xQueueCreateStatic(
-							  UBaseType_t uxQueueLength,
-							  UBaseType_t uxItemSize,
-							  uint8_t *pucQueueStorageBuffer,
-							  StaticQueue_t *pxQueueBuffer
-						  );
- * 
- * * Creates a new queue instance, and returns a handle by which the new queue * can be referenced. * @@ -207,7 +191,7 @@ typedef void * QueueSetMemberHandle_t; * that will be copied for each posted item. Each item on the queue must be * the same size. * - * @param pucQueueStorageBuffer If uxItemSize is not zero then + * @param pucQueueStorage If uxItemSize is not zero then * pucQueueStorageBuffer must point to a uint8_t array that is at least large * enough to hold the maximum number of items that can be in the queue at any * one time - which is ( uxQueueLength * uxItemsSize ) bytes. If uxItemSize is @@ -220,40 +204,39 @@ typedef void * QueueSetMemberHandle_t; * returned. If pxQueueBuffer is NULL then NULL is returned. * * Example usage: -
- struct AMessage
- {
-	char ucMessageID;
-	char ucData[ 20 ];
- };
-
- #define QUEUE_LENGTH 10
- #define ITEM_SIZE sizeof( uint32_t )
-
- // xQueueBuffer will hold the queue structure.
- StaticQueue_t xQueueBuffer;
-
- // ucQueueStorage will hold the items posted to the queue.  Must be at least
- // [(queue length) * ( queue item size)] bytes long.
- uint8_t ucQueueStorage[ QUEUE_LENGTH * ITEM_SIZE ];
-
- void vATask( void *pvParameters )
- {
- QueueHandle_t xQueue1;
-
-	// Create a queue capable of containing 10 uint32_t values.
-	xQueue1 = xQueueCreate( QUEUE_LENGTH, // The number of items the queue can hold.
-							ITEM_SIZE	  // The size of each item in the queue
-							&( ucQueueStorage[ 0 ] ), // The buffer that will hold the items in the queue.
-							&xQueueBuffer ); // The buffer that will hold the queue structure.
-
-	// The queue is guaranteed to be created successfully as no dynamic memory
-	// allocation is used.  Therefore xQueue1 is now a handle to a valid queue.
-
-	// ... Rest of task code.
- }
- 
- * \defgroup xQueueCreateStatic xQueueCreateStatic + * @code{c} + * struct AMessage + * { + * char ucMessageID; + * char ucData[ 20 ]; + * }; + * + * #define QUEUE_LENGTH 10 + * #define ITEM_SIZE sizeof( uint32_t ) + * + * // xQueueBuffer will hold the queue structure. + * StaticQueue_t xQueueBuffer; + * + * // ucQueueStorage will hold the items posted to the queue. Must be at least + * // [(queue length) * ( queue item size)] bytes long. + * uint8_t ucQueueStorage[ QUEUE_LENGTH * ITEM_SIZE ]; + * + * void vATask( void *pvParameters ) + * { + * QueueHandle_t xQueue1; + * + * // Create a queue capable of containing 10 uint32_t values. + * xQueue1 = xQueueCreate( QUEUE_LENGTH, // The number of items the queue can hold. + * ITEM_SIZE // The size of each item in the queue + * &( ucQueueStorage[ 0 ] ), // The buffer that will hold the items in the queue. + * &xQueueBuffer ); // The buffer that will hold the queue structure. + * + * // The queue is guaranteed to be created successfully as no dynamic memory + * // allocation is used. Therefore xQueue1 is now a handle to a valid queue. + * + * // ... Rest of task code. + * } + * @endcode * \ingroup QueueManagement */ #if( configSUPPORT_STATIC_ALLOCATION == 1 ) @@ -261,15 +244,6 @@ typedef void * QueueSetMemberHandle_t; #endif /* configSUPPORT_STATIC_ALLOCATION */ /** - * queue. h - *
- BaseType_t xQueueSendToToFront(
-								   QueueHandle_t	xQueue,
-								   const void		*pvItemToQueue,
-								   TickType_t		xTicksToWait
-							   );
- * 
- * * This is a macro that calls xQueueGenericSend(). * * Post an item to the front of a queue. The item is queued by copy, not by @@ -293,65 +267,55 @@ typedef void * QueueSetMemberHandle_t; * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL. * * Example usage: -
- struct AMessage
- {
-	char ucMessageID;
-	char ucData[ 20 ];
- } xMessage;
-
- uint32_t ulVar = 10UL;
-
- void vATask( void *pvParameters )
- {
- QueueHandle_t xQueue1, xQueue2;
- struct AMessage *pxMessage;
-
-	// Create a queue capable of containing 10 uint32_t values.
-	xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
-
-	// Create a queue capable of containing 10 pointers to AMessage structures.
-	// These should be passed by pointer as they contain a lot of data.
-	xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
-
-	// ...
-
-	if( xQueue1 != 0 )
-	{
-		// Send an uint32_t.  Wait for 10 ticks for space to become
-		// available if necessary.
-		if( xQueueSendToFront( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS )
-		{
-			// Failed to post the message, even after 10 ticks.
-		}
-	}
-
-	if( xQueue2 != 0 )
-	{
-		// Send a pointer to a struct AMessage object.  Don't block if the
-		// queue is already full.
-		pxMessage = & xMessage;
-		xQueueSendToFront( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0 );
-	}
-
-	// ... Rest of task code.
- }
- 
- * \defgroup xQueueSend xQueueSend + * @code{c} + * struct AMessage + * { + * char ucMessageID; + * char ucData[ 20 ]; + * } xMessage; + * + * uint32_t ulVar = 10UL; + * + * void vATask( void *pvParameters ) + * { + * QueueHandle_t xQueue1, xQueue2; + * struct AMessage *pxMessage; + * + * // Create a queue capable of containing 10 uint32_t values. + * xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) ); + * + * // Create a queue capable of containing 10 pointers to AMessage structures. + * // These should be passed by pointer as they contain a lot of data. + * xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) ); + * + * // ... + * + * if( xQueue1 != 0 ) + * { + * // Send an uint32_t. Wait for 10 ticks for space to become + * // available if necessary. + * if( xQueueSendToFront( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS ) + * { + * // Failed to post the message, even after 10 ticks. + * } + * } + * + * if( xQueue2 != 0 ) + * { + * // Send a pointer to a struct AMessage object. Don't block if the + * // queue is already full. + * pxMessage = & xMessage; + * xQueueSendToFront( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0 ); + * } + * + * // ... Rest of task code. + * } + * @endcode * \ingroup QueueManagement */ #define xQueueSendToFront( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_FRONT ) /** - * queue. h - *
- BaseType_t xQueueSendToBack(
-								   QueueHandle_t	xQueue,
-								   const void		*pvItemToQueue,
-								   TickType_t		xTicksToWait
-							   );
- * 
- * * This is a macro that calls xQueueGenericSend(). * * Post an item to the back of a queue. The item is queued by copy, not by @@ -375,65 +339,55 @@ typedef void * QueueSetMemberHandle_t; * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL. * * Example usage: -
- struct AMessage
- {
-	char ucMessageID;
-	char ucData[ 20 ];
- } xMessage;
-
- uint32_t ulVar = 10UL;
-
- void vATask( void *pvParameters )
- {
- QueueHandle_t xQueue1, xQueue2;
- struct AMessage *pxMessage;
-
-	// Create a queue capable of containing 10 uint32_t values.
-	xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
-
-	// Create a queue capable of containing 10 pointers to AMessage structures.
-	// These should be passed by pointer as they contain a lot of data.
-	xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
-
-	// ...
-
-	if( xQueue1 != 0 )
-	{
-		// Send an uint32_t.  Wait for 10 ticks for space to become
-		// available if necessary.
-		if( xQueueSendToBack( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS )
-		{
-			// Failed to post the message, even after 10 ticks.
-		}
-	}
-
-	if( xQueue2 != 0 )
-	{
-		// Send a pointer to a struct AMessage object.  Don't block if the
-		// queue is already full.
-		pxMessage = & xMessage;
-		xQueueSendToBack( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0 );
-	}
-
-	// ... Rest of task code.
- }
- 
- * \defgroup xQueueSend xQueueSend + * @code{c} + * struct AMessage + * { + * char ucMessageID; + * char ucData[ 20 ]; + * } xMessage; + * + * uint32_t ulVar = 10UL; + * + * void vATask( void *pvParameters ) + * { + * QueueHandle_t xQueue1, xQueue2; + * struct AMessage *pxMessage; + * + * // Create a queue capable of containing 10 uint32_t values. + * xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) ); + * + * // Create a queue capable of containing 10 pointers to AMessage structures. + * // These should be passed by pointer as they contain a lot of data. + * xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) ); + * + * // ... + * + * if( xQueue1 != 0 ) + * { + * // Send an uint32_t. Wait for 10 ticks for space to become + * // available if necessary. + * if( xQueueSendToBack( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS ) + * { + * // Failed to post the message, even after 10 ticks. + * } + * } + * + * if( xQueue2 != 0 ) + * { + * // Send a pointer to a struct AMessage object. Don't block if the + * // queue is already full. + * pxMessage = & xMessage; + * xQueueSendToBack( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0 ); + * } + * + * // ... Rest of task code. + * } + * @endcode * \ingroup QueueManagement */ #define xQueueSendToBack( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK ) /** - * queue. h - *
- BaseType_t xQueueSend(
-							  QueueHandle_t xQueue,
-							  const void * pvItemToQueue,
-							  TickType_t xTicksToWait
-						 );
- * 
- * * This is a macro that calls xQueueGenericSend(). It is included for * backward compatibility with versions of FreeRTOS.org that did not * include the xQueueSendToFront() and xQueueSendToBack() macros. It is @@ -459,64 +413,55 @@ typedef void * QueueSetMemberHandle_t; * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL. * * Example usage: -
- struct AMessage
- {
-	char ucMessageID;
-	char ucData[ 20 ];
- } xMessage;
-
- uint32_t ulVar = 10UL;
-
- void vATask( void *pvParameters )
- {
- QueueHandle_t xQueue1, xQueue2;
- struct AMessage *pxMessage;
-
-	// Create a queue capable of containing 10 uint32_t values.
-	xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
-
-	// Create a queue capable of containing 10 pointers to AMessage structures.
-	// These should be passed by pointer as they contain a lot of data.
-	xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
-
-	// ...
-
-	if( xQueue1 != 0 )
-	{
-		// Send an uint32_t.  Wait for 10 ticks for space to become
-		// available if necessary.
-		if( xQueueSend( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS )
-		{
-			// Failed to post the message, even after 10 ticks.
-		}
-	}
-
-	if( xQueue2 != 0 )
-	{
-		// Send a pointer to a struct AMessage object.  Don't block if the
-		// queue is already full.
-		pxMessage = & xMessage;
-		xQueueSend( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0 );
-	}
-
-	// ... Rest of task code.
- }
- 
- * \defgroup xQueueSend xQueueSend + * @code{c} + * struct AMessage + * { + * char ucMessageID; + * char ucData[ 20 ]; + * } xMessage; + * + * uint32_t ulVar = 10UL; + * + * void vATask( void *pvParameters ) + * { + * QueueHandle_t xQueue1, xQueue2; + * struct AMessage *pxMessage; + * + * // Create a queue capable of containing 10 uint32_t values. + * xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) ); + * + * // Create a queue capable of containing 10 pointers to AMessage structures. + * // These should be passed by pointer as they contain a lot of data. + * xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) ); + * + * // ... + * + * if( xQueue1 != 0 ) + * { + * // Send an uint32_t. Wait for 10 ticks for space to become + * // available if necessary. + * if( xQueueSend( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS ) + * { + * // Failed to post the message, even after 10 ticks. + * } + * } + * + * if( xQueue2 != 0 ) + * { + * // Send a pointer to a struct AMessage object. Don't block if the + * // queue is already full. + * pxMessage = & xMessage; + * xQueueSend( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0 ); + * } + * + * // ... Rest of task code. + * } + * @endcode * \ingroup QueueManagement */ #define xQueueSend( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK ) /** - * queue. h - *
- BaseType_t xQueueOverwrite(
-							  QueueHandle_t xQueue,
-							  const void * pvItemToQueue
-						 );
- * 
- * * Only for use with queues that have a length of one - so the queue is either * empty or full. * @@ -539,70 +484,59 @@ typedef void * QueueSetMemberHandle_t; * to the queue even when the queue is already full. * * Example usage: -
-
- void vFunction( void *pvParameters )
- {
- QueueHandle_t xQueue;
- uint32_t ulVarToSend, ulValReceived;
-
-	// Create a queue to hold one uint32_t value.  It is strongly
-	// recommended *not* to use xQueueOverwrite() on queues that can
-	// contain more than one value, and doing so will trigger an assertion
-	// if configASSERT() is defined.
-	xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
-
-	// Write the value 10 to the queue using xQueueOverwrite().
-	ulVarToSend = 10;
-	xQueueOverwrite( xQueue, &ulVarToSend );
-
-	// Peeking the queue should now return 10, but leave the value 10 in
-	// the queue.  A block time of zero is used as it is known that the
-	// queue holds a value.
-	ulValReceived = 0;
-	xQueuePeek( xQueue, &ulValReceived, 0 );
-
-	if( ulValReceived != 10 )
-	{
-		// Error unless the item was removed by a different task.
-	}
-
-	// The queue is still full.  Use xQueueOverwrite() to overwrite the
-	// value held in the queue with 100.
-	ulVarToSend = 100;
-	xQueueOverwrite( xQueue, &ulVarToSend );
-
-	// This time read from the queue, leaving the queue empty once more.
-	// A block time of 0 is used again.
-	xQueueReceive( xQueue, &ulValReceived, 0 );
-
-	// The value read should be the last value written, even though the
-	// queue was already full when the value was written.
-	if( ulValReceived != 100 )
-	{
-		// Error!
-	}
-
-	// ...
-}
- 
- * \defgroup xQueueOverwrite xQueueOverwrite + * @code{c} + * + * void vFunction( void *pvParameters ) + * { + * QueueHandle_t xQueue; + * uint32_t ulVarToSend, ulValReceived; + * + * // Create a queue to hold one uint32_t value. It is strongly + * // recommended *not* to use xQueueOverwrite() on queues that can + * // contain more than one value, and doing so will trigger an assertion + * // if configASSERT() is defined. + * xQueue = xQueueCreate( 1, sizeof( uint32_t ) ); + * + * // Write the value 10 to the queue using xQueueOverwrite(). + * ulVarToSend = 10; + * xQueueOverwrite( xQueue, &ulVarToSend ); + * + * // Peeking the queue should now return 10, but leave the value 10 in + * // the queue. A block time of zero is used as it is known that the + * // queue holds a value. + * ulValReceived = 0; + * xQueuePeek( xQueue, &ulValReceived, 0 ); + * + * if( ulValReceived != 10 ) + * { + * // Error unless the item was removed by a different task. + * } + * + * // The queue is still full. Use xQueueOverwrite() to overwrite the + * // value held in the queue with 100. + * ulVarToSend = 100; + * xQueueOverwrite( xQueue, &ulVarToSend ); + * + * // This time read from the queue, leaving the queue empty once more. + * // A block time of 0 is used again. + * xQueueReceive( xQueue, &ulValReceived, 0 ); + * + * // The value read should be the last value written, even though the + * // queue was already full when the value was written. + * if( ulValReceived != 100 ) + * { + * // Error! + * } + * + * // ... + * } + * @endcode * \ingroup QueueManagement */ #define xQueueOverwrite( xQueue, pvItemToQueue ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), 0, queueOVERWRITE ) /** - * queue. h - *
- BaseType_t xQueueGenericSend(
-									QueueHandle_t xQueue,
-									const void * pvItemToQueue,
-									TickType_t xTicksToWait
-									BaseType_t xCopyPosition
-								);
- * 
- * * It is preferred that the macros xQueueSend(), xQueueSendToFront() and * xQueueSendToBack() are used in place of calling this function directly. * @@ -630,64 +564,55 @@ typedef void * QueueSetMemberHandle_t; * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL. * * Example usage: -
- struct AMessage
- {
-	char ucMessageID;
-	char ucData[ 20 ];
- } xMessage;
-
- uint32_t ulVar = 10UL;
-
- void vATask( void *pvParameters )
- {
- QueueHandle_t xQueue1, xQueue2;
- struct AMessage *pxMessage;
-
-	// Create a queue capable of containing 10 uint32_t values.
-	xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
-
-	// Create a queue capable of containing 10 pointers to AMessage structures.
-	// These should be passed by pointer as they contain a lot of data.
-	xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
-
-	// ...
-
-	if( xQueue1 != 0 )
-	{
-		// Send an uint32_t.  Wait for 10 ticks for space to become
-		// available if necessary.
-		if( xQueueGenericSend( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10, queueSEND_TO_BACK ) != pdPASS )
-		{
-			// Failed to post the message, even after 10 ticks.
-		}
-	}
-
-	if( xQueue2 != 0 )
-	{
-		// Send a pointer to a struct AMessage object.  Don't block if the
-		// queue is already full.
-		pxMessage = & xMessage;
-		xQueueGenericSend( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0, queueSEND_TO_BACK );
-	}
-
-	// ... Rest of task code.
- }
- 
- * \defgroup xQueueSend xQueueSend + * @code{c} + * struct AMessage + * { + * char ucMessageID; + * char ucData[ 20 ]; + * } xMessage; + * + * uint32_t ulVar = 10UL; + * + * void vATask( void *pvParameters ) + * { + * QueueHandle_t xQueue1, xQueue2; + * struct AMessage *pxMessage; + * + * // Create a queue capable of containing 10 uint32_t values. + * xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) ); + * + * // Create a queue capable of containing 10 pointers to AMessage structures. + * // These should be passed by pointer as they contain a lot of data. + * xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) ); + * + * // ... + * + * if( xQueue1 != 0 ) + * { + * // Send an uint32_t. Wait for 10 ticks for space to become + * // available if necessary. + * if( xQueueGenericSend( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10, queueSEND_TO_BACK ) != pdPASS ) + * { + * // Failed to post the message, even after 10 ticks. + * } + * } + * + * if( xQueue2 != 0 ) + * { + * // Send a pointer to a struct AMessage object. Don't block if the + * // queue is already full. + * pxMessage = & xMessage; + * xQueueGenericSend( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0, queueSEND_TO_BACK ); + * } + * + * // ... Rest of task code. + * } + * @endcode * \ingroup QueueManagement */ BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, const BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION; /** - * queue. h - *
- BaseType_t xQueuePeek(
-							 QueueHandle_t xQueue,
-							 void *pvBuffer,
-							 TickType_t xTicksToWait
-						 );
- * * This is a macro that calls the xQueueGenericReceive() function. * * Receive an item from a queue without removing the item from the queue. @@ -719,70 +644,62 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQ * otherwise pdFALSE. * * Example usage: -
- struct AMessage
- {
-	char ucMessageID;
-	char ucData[ 20 ];
- } xMessage;
-
- QueueHandle_t xQueue;
-
- // Task to create a queue and post a value.
- void vATask( void *pvParameters )
- {
- struct AMessage *pxMessage;
-
-	// Create a queue capable of containing 10 pointers to AMessage structures.
-	// These should be passed by pointer as they contain a lot of data.
-	xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );
-	if( xQueue == 0 )
-	{
-		// Failed to create the queue.
-	}
-
-	// ...
-
-	// Send a pointer to a struct AMessage object.  Don't block if the
-	// queue is already full.
-	pxMessage = & xMessage;
-	xQueueSend( xQueue, ( void * ) &pxMessage, ( TickType_t ) 0 );
-
-	// ... Rest of task code.
- }
-
- // Task to peek the data from the queue.
- void vADifferentTask( void *pvParameters )
- {
- struct AMessage *pxRxedMessage;
-
-	if( xQueue != 0 )
-	{
-		// Peek a message on the created queue.  Block for 10 ticks if a
-		// message is not immediately available.
-		if( xQueuePeek( xQueue, &( pxRxedMessage ), ( TickType_t ) 10 ) )
-		{
-			// pcRxedMessage now points to the struct AMessage variable posted
-			// by vATask, but the item still remains on the queue.
-		}
-	}
-
-	// ... Rest of task code.
- }
- 
- * \defgroup xQueueReceive xQueueReceive + * @code{c} + * struct AMessage + * { + * char ucMessageID; + * char ucData[ 20 ]; + * } xMessage; + * + * QueueHandle_t xQueue; + * + * // Task to create a queue and post a value. + * void vATask( void *pvParameters ) + * { + * struct AMessage *pxMessage; + * + * // Create a queue capable of containing 10 pointers to AMessage structures. + * // These should be passed by pointer as they contain a lot of data. + * xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) ); + * if( xQueue == 0 ) + * { + * // Failed to create the queue. + * } + * + * // ... + * + * // Send a pointer to a struct AMessage object. Don't block if the + * // queue is already full. + * pxMessage = & xMessage; + * xQueueSend( xQueue, ( void * ) &pxMessage, ( TickType_t ) 0 ); + * + * // ... Rest of task code. + * } + * + * // Task to peek the data from the queue. + * void vADifferentTask( void *pvParameters ) + * { + * struct AMessage *pxRxedMessage; + * + * if( xQueue != 0 ) + * { + * // Peek a message on the created queue. Block for 10 ticks if a + * // message is not immediately available. + * if( xQueuePeek( xQueue, &( pxRxedMessage ), ( TickType_t ) 10 ) ) + * { + * // pcRxedMessage now points to the struct AMessage variable posted + * // by vATask, but the item still remains on the queue. + * } + * } + * + * // ... Rest of task code. + * } + * @endcode * \ingroup QueueManagement */ #define xQueuePeek( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdTRUE ) /** - * queue. h - *
- BaseType_t xQueuePeekFromISR(
-									QueueHandle_t xQueue,
-									void *pvBuffer,
-								);
- * * A version of xQueuePeek() that can be called from an interrupt service * routine (ISR). * @@ -803,7 +720,6 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQ * @return pdTRUE if an item was successfully received from the queue, * otherwise pdFALSE. * - * \defgroup xQueuePeekFromISR xQueuePeekFromISR * \ingroup QueueManagement */ BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, void * const pvBuffer ) PRIVILEGED_FUNCTION; @@ -845,73 +761,63 @@ BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, void * const pvBuffer ) PRIV * otherwise pdFALSE. * * Example usage: -
- struct AMessage
- {
-	char ucMessageID;
-	char ucData[ 20 ];
- } xMessage;
-
- QueueHandle_t xQueue;
-
- // Task to create a queue and post a value.
- void vATask( void *pvParameters )
- {
- struct AMessage *pxMessage;
-
-	// Create a queue capable of containing 10 pointers to AMessage structures.
-	// These should be passed by pointer as they contain a lot of data.
-	xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );
-	if( xQueue == 0 )
-	{
-		// Failed to create the queue.
-	}
-
-	// ...
-
-	// Send a pointer to a struct AMessage object.  Don't block if the
-	// queue is already full.
-	pxMessage = & xMessage;
-	xQueueSend( xQueue, ( void * ) &pxMessage, ( TickType_t ) 0 );
-
-	// ... Rest of task code.
- }
-
- // Task to receive from the queue.
- void vADifferentTask( void *pvParameters )
- {
- struct AMessage *pxRxedMessage;
-
-	if( xQueue != 0 )
-	{
-		// Receive a message on the created queue.  Block for 10 ticks if a
-		// message is not immediately available.
-		if( xQueueReceive( xQueue, &( pxRxedMessage ), ( TickType_t ) 10 ) )
-		{
-			// pcRxedMessage now points to the struct AMessage variable posted
-			// by vATask.
-		}
-	}
-
-	// ... Rest of task code.
- }
- 
- * \defgroup xQueueReceive xQueueReceive + * @code{c} + * struct AMessage + * { + * char ucMessageID; + * char ucData[ 20 ]; + * } xMessage; + * + * QueueHandle_t xQueue; + * + * // Task to create a queue and post a value. + * void vATask( void *pvParameters ) + * { + * struct AMessage *pxMessage; + * + * // Create a queue capable of containing 10 pointers to AMessage structures. + * // These should be passed by pointer as they contain a lot of data. + * xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) ); + * if( xQueue == 0 ) + * { + * // Failed to create the queue. + * } + * + * // ... + * + * // Send a pointer to a struct AMessage object. Don't block if the + * // queue is already full. + * pxMessage = & xMessage; + * xQueueSend( xQueue, ( void * ) &pxMessage, ( TickType_t ) 0 ); + * + * // ... Rest of task code. + * } + * + * // Task to receive from the queue. + * void vADifferentTask( void *pvParameters ) + * { + * struct AMessage *pxRxedMessage; + * + * if( xQueue != 0 ) + * { + * // Receive a message on the created queue. Block for 10 ticks if a + * // message is not immediately available. + * if( xQueueReceive( xQueue, &( pxRxedMessage ), ( TickType_t ) 10 ) ) + * { + * // pcRxedMessage now points to the struct AMessage variable posted + * // by vATask. + * } + * } + * + * // ... Rest of task code. + * } + * @endcode * \ingroup QueueManagement */ #define xQueueReceive( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdFALSE ) /** - * queue. h - *
- BaseType_t xQueueGenericReceive(
-									   QueueHandle_t	xQueue,
-									   void	*pvBuffer,
-									   TickType_t	xTicksToWait
-									   BaseType_t	xJustPeek
-									);
- * * It is preferred that the macro xQueueReceive() be used rather than calling * this function directly. * @@ -944,81 +850,73 @@ BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, void * const pvBuffer ) PRIV * otherwise pdFALSE. * * Example usage: -
- struct AMessage
- {
-	char ucMessageID;
-	char ucData[ 20 ];
- } xMessage;
-
- QueueHandle_t xQueue;
-
- // Task to create a queue and post a value.
- void vATask( void *pvParameters )
- {
- struct AMessage *pxMessage;
-
-	// Create a queue capable of containing 10 pointers to AMessage structures.
-	// These should be passed by pointer as they contain a lot of data.
-	xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );
-	if( xQueue == 0 )
-	{
-		// Failed to create the queue.
-	}
-
-	// ...
-
-	// Send a pointer to a struct AMessage object.  Don't block if the
-	// queue is already full.
-	pxMessage = & xMessage;
-	xQueueSend( xQueue, ( void * ) &pxMessage, ( TickType_t ) 0 );
-
-	// ... Rest of task code.
- }
-
- // Task to receive from the queue.
- void vADifferentTask( void *pvParameters )
- {
- struct AMessage *pxRxedMessage;
-
-	if( xQueue != 0 )
-	{
-		// Receive a message on the created queue.  Block for 10 ticks if a
-		// message is not immediately available.
-		if( xQueueGenericReceive( xQueue, &( pxRxedMessage ), ( TickType_t ) 10 ) )
-		{
-			// pcRxedMessage now points to the struct AMessage variable posted
-			// by vATask.
-		}
-	}
-
-	// ... Rest of task code.
- }
- 
- * \defgroup xQueueReceive xQueueReceive + * @code{c} + * struct AMessage + * { + * char ucMessageID; + * char ucData[ 20 ]; + * } xMessage; + * + * QueueHandle_t xQueue; + * + * // Task to create a queue and post a value. + * void vATask( void *pvParameters ) + * { + * struct AMessage *pxMessage; + * + * // Create a queue capable of containing 10 pointers to AMessage structures. + * // These should be passed by pointer as they contain a lot of data. + * xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) ); + * if( xQueue == 0 ) + * { + * // Failed to create the queue. + * } + * + * // ... + * + * // Send a pointer to a struct AMessage object. Don't block if the + * // queue is already full. + * pxMessage = & xMessage; + * xQueueSend( xQueue, ( void * ) &pxMessage, ( TickType_t ) 0 ); + * + * // ... Rest of task code. + * } + * + * // Task to receive from the queue. + * void vADifferentTask( void *pvParameters ) + * { + * struct AMessage *pxRxedMessage; + * + * if( xQueue != 0 ) + * { + * // Receive a message on the created queue. Block for 10 ticks if a + * // message is not immediately available. + * if( xQueueGenericReceive( xQueue, &( pxRxedMessage ), ( TickType_t ) 10 ) ) + * { + * // pcRxedMessage now points to the struct AMessage variable posted + * // by vATask. + * } + * } + * + * // ... Rest of task code. + * } + * @endcode * \ingroup QueueManagement */ BaseType_t xQueueGenericReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait, const BaseType_t xJustPeek ) PRIVILEGED_FUNCTION; /** - * queue. h - *
UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue );
- * * Return the number of messages stored in a queue. * * @param xQueue A handle to the queue being queried. * * @return The number of messages available in the queue. * - * \defgroup uxQueueMessagesWaiting uxQueueMessagesWaiting * \ingroup QueueManagement */ UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; /** - * queue. h - *
UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue );
- * * Return the number of free spaces available in a queue. This is equal to the * number of items that can be sent to the queue before the queue becomes full * if no items are removed. @@ -1027,35 +925,21 @@ UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue ) PRIVILEGED_FUNC * * @return The number of spaces available in the queue. * - * \defgroup uxQueueMessagesWaiting uxQueueMessagesWaiting * \ingroup QueueManagement */ UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; /** - * queue. h - *
void vQueueDelete( QueueHandle_t xQueue );
- * * Delete a queue - freeing all the memory allocated for storing of items * placed on the queue. * * @param xQueue A handle to the queue to be deleted. * - * \defgroup vQueueDelete vQueueDelete * \ingroup QueueManagement */ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; /** - * queue. h - *
- BaseType_t xQueueSendToFrontFromISR(
-										 QueueHandle_t xQueue,
-										 const void *pvItemToQueue,
-										 BaseType_t *pxHigherPriorityTaskWoken
-									  );
- 
- * * This is a macro that calls xQueueGenericSendFromISR(). * * Post an item to the front of a queue. It is safe to use this macro from @@ -1072,7 +956,7 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; * queue was created, so this many bytes will be copied from pvItemToQueue * into the queue storage area. * - * @param pxHigherPriorityTaskWoken xQueueSendToFrontFromISR() will set + * @param[out] pxHigherPriorityTaskWoken xQueueSendToFrontFromISR() will set * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task * to unblock, and the unblocked task has a priority higher than the currently * running task. If xQueueSendToFromFromISR() sets this value to pdTRUE then @@ -1083,50 +967,39 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; * * Example usage for buffered IO (where the ISR can obtain more than one value * per call): -
- void vBufferISR( void )
- {
- char cIn;
- BaseType_t xHigherPrioritTaskWoken;
-
-	// We have not woken a task at the start of the ISR.
-	xHigherPriorityTaskWoken = pdFALSE;
-
-	// Loop until the buffer is empty.
-	do
-	{
-		// Obtain a byte from the buffer.
-		cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
-
-		// Post the byte.
-		xQueueSendToFrontFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );
-
-	} while( portINPUT_BYTE( BUFFER_COUNT ) );
-
-	// Now the buffer is empty we can switch context if necessary.
-	if( xHigherPriorityTaskWoken )
-	{
-		portYIELD_FROM_ISR ();
-	}
- }
- 
- * - * \defgroup xQueueSendFromISR xQueueSendFromISR + * @code{c} + * void vBufferISR( void ) + * { + * char cIn; + * BaseType_t xHigherPrioritTaskWoken; + * + * // We have not woken a task at the start of the ISR. + * xHigherPriorityTaskWoken = pdFALSE; + * + * // Loop until the buffer is empty. + * do + * { + * // Obtain a byte from the buffer. + * cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS ); + * + * // Post the byte. + * xQueueSendToFrontFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken ); + * + * } while( portINPUT_BYTE( BUFFER_COUNT ) ); + * + * // Now the buffer is empty we can switch context if necessary. + * if( xHigherPriorityTaskWoken ) + * { + * portYIELD_FROM_ISR (); + * } + * } + * @endcode * \ingroup QueueManagement */ #define xQueueSendToFrontFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_FRONT ) /** - * queue. h - *
- BaseType_t xQueueSendToBackFromISR(
-										 QueueHandle_t xQueue,
-										 const void *pvItemToQueue,
-										 BaseType_t *pxHigherPriorityTaskWoken
-									  );
- 
- * * This is a macro that calls xQueueGenericSendFromISR(). * * Post an item to the back of a queue. It is safe to use this macro from @@ -1143,7 +1016,7 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; * queue was created, so this many bytes will be copied from pvItemToQueue * into the queue storage area. * - * @param pxHigherPriorityTaskWoken xQueueSendToBackFromISR() will set + * @param[out] pxHigherPriorityTaskWoken xQueueSendToBackFromISR() will set * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task * to unblock, and the unblocked task has a priority higher than the currently * running task. If xQueueSendToBackFromISR() sets this value to pdTRUE then @@ -1154,49 +1027,38 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; * * Example usage for buffered IO (where the ISR can obtain more than one value * per call): -
- void vBufferISR( void )
- {
- char cIn;
- BaseType_t xHigherPriorityTaskWoken;
-
-	// We have not woken a task at the start of the ISR.
-	xHigherPriorityTaskWoken = pdFALSE;
-
-	// Loop until the buffer is empty.
-	do
-	{
-		// Obtain a byte from the buffer.
-		cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
-
-		// Post the byte.
-		xQueueSendToBackFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );
-
-	} while( portINPUT_BYTE( BUFFER_COUNT ) );
-
-	// Now the buffer is empty we can switch context if necessary.
-	if( xHigherPriorityTaskWoken )
-	{
-		portYIELD_FROM_ISR ();
-	}
- }
- 
- * - * \defgroup xQueueSendFromISR xQueueSendFromISR + * @code{c} + * void vBufferISR( void ) + * { + * char cIn; + * BaseType_t xHigherPriorityTaskWoken; + * + * // We have not woken a task at the start of the ISR. + * xHigherPriorityTaskWoken = pdFALSE; + * + * // Loop until the buffer is empty. + * do + * { + * // Obtain a byte from the buffer. + * cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS ); + * + * // Post the byte. + * xQueueSendToBackFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken ); + * + * } while( portINPUT_BYTE( BUFFER_COUNT ) ); + * + * // Now the buffer is empty we can switch context if necessary. + * if( xHigherPriorityTaskWoken ) + * { + * portYIELD_FROM_ISR (); + * } + * } + * @endcode * \ingroup QueueManagement */ #define xQueueSendToBackFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK ) /** - * queue. h - *
- BaseType_t xQueueOverwriteFromISR(
-							  QueueHandle_t xQueue,
-							  const void * pvItemToQueue,
-							  BaseType_t *pxHigherPriorityTaskWoken
-						 );
- * 
- * * A version of xQueueOverwrite() that can be used in an interrupt service * routine (ISR). * @@ -1213,7 +1075,7 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; * queue was created, so this many bytes will be copied from pvItemToQueue * into the queue storage area. * - * @param pxHigherPriorityTaskWoken xQueueOverwriteFromISR() will set + * @param[out] pxHigherPriorityTaskWoken xQueueOverwriteFromISR() will set * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task * to unblock, and the unblocked task has a priority higher than the currently * running task. If xQueueOverwriteFromISR() sets this value to pdTRUE then @@ -1226,64 +1088,53 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; * the queue is already full. * * Example usage: -
-
- QueueHandle_t xQueue;
-
- void vFunction( void *pvParameters )
- {
- 	// Create a queue to hold one uint32_t value.  It is strongly
-	// recommended *not* to use xQueueOverwriteFromISR() on queues that can
-	// contain more than one value, and doing so will trigger an assertion
-	// if configASSERT() is defined.
-	xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
-}
-
-void vAnInterruptHandler( void )
-{
-// xHigherPriorityTaskWoken must be set to pdFALSE before it is used.
-BaseType_t xHigherPriorityTaskWoken = pdFALSE;
-uint32_t ulVarToSend, ulValReceived;
-
-	// Write the value 10 to the queue using xQueueOverwriteFromISR().
-	ulVarToSend = 10;
-	xQueueOverwriteFromISR( xQueue, &ulVarToSend, &xHigherPriorityTaskWoken );
-
-	// The queue is full, but calling xQueueOverwriteFromISR() again will still
-	// pass because the value held in the queue will be overwritten with the
-	// new value.
-	ulVarToSend = 100;
-	xQueueOverwriteFromISR( xQueue, &ulVarToSend, &xHigherPriorityTaskWoken );
-
-	// Reading from the queue will now return 100.
-
-	// ...
-
-	if( xHigherPrioritytaskWoken == pdTRUE )
-	{
-		// Writing to the queue caused a task to unblock and the unblocked task
-		// has a priority higher than or equal to the priority of the currently
-		// executing task (the task this interrupt interrupted).  Perform a context
-		// switch so this interrupt returns directly to the unblocked task.
-		portYIELD_FROM_ISR(); // or portEND_SWITCHING_ISR() depending on the port.
-	}
-}
- 
- * \defgroup xQueueOverwriteFromISR xQueueOverwriteFromISR + * @code{c} + * QueueHandle_t xQueue; + * + * void vFunction( void *pvParameters ) + * { + * // Create a queue to hold one uint32_t value. It is strongly + * // recommended *not* to use xQueueOverwriteFromISR() on queues that can + * // contain more than one value, and doing so will trigger an assertion + * // if configASSERT() is defined. + * xQueue = xQueueCreate( 1, sizeof( uint32_t ) ); + * } + * + * void vAnInterruptHandler( void ) + * { + * // xHigherPriorityTaskWoken must be set to pdFALSE before it is used. + * BaseType_t xHigherPriorityTaskWoken = pdFALSE; + * uint32_t ulVarToSend, ulValReceived; + * + * // Write the value 10 to the queue using xQueueOverwriteFromISR(). + * ulVarToSend = 10; + * xQueueOverwriteFromISR( xQueue, &ulVarToSend, &xHigherPriorityTaskWoken ); + * + * // The queue is full, but calling xQueueOverwriteFromISR() again will still + * // pass because the value held in the queue will be overwritten with the + * // new value. + * ulVarToSend = 100; + * xQueueOverwriteFromISR( xQueue, &ulVarToSend, &xHigherPriorityTaskWoken ); + * + * // Reading from the queue will now return 100. + * + * // ... + * + * if( xHigherPrioritytaskWoken == pdTRUE ) + * { + * // Writing to the queue caused a task to unblock and the unblocked task + * // has a priority higher than or equal to the priority of the currently + * // executing task (the task this interrupt interrupted). Perform a context + * // switch so this interrupt returns directly to the unblocked task. + * portYIELD_FROM_ISR(); // or portEND_SWITCHING_ISR() depending on the port. + * } + * } + * @endcode * \ingroup QueueManagement */ #define xQueueOverwriteFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueOVERWRITE ) /** - * queue. h - *
- BaseType_t xQueueSendFromISR(
-									 QueueHandle_t xQueue,
-									 const void *pvItemToQueue,
-									 BaseType_t *pxHigherPriorityTaskWoken
-								);
- 
- * * This is a macro that calls xQueueGenericSendFromISR(). It is included * for backward compatibility with versions of FreeRTOS.org that did not * include the xQueueSendToBackFromISR() and xQueueSendToFrontFromISR() @@ -1303,7 +1154,7 @@ uint32_t ulVarToSend, ulValReceived; * queue was created, so this many bytes will be copied from pvItemToQueue * into the queue storage area. * - * @param pxHigherPriorityTaskWoken xQueueSendFromISR() will set + * @param[out] pxHigherPriorityTaskWoken xQueueSendFromISR() will set * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task * to unblock, and the unblocked task has a priority higher than the currently * running task. If xQueueSendFromISR() sets this value to pdTRUE then @@ -1314,51 +1165,41 @@ uint32_t ulVarToSend, ulValReceived; * * Example usage for buffered IO (where the ISR can obtain more than one value * per call): -
- void vBufferISR( void )
- {
- char cIn;
- BaseType_t xHigherPriorityTaskWoken;
-
-	// We have not woken a task at the start of the ISR.
-	xHigherPriorityTaskWoken = pdFALSE;
-
-	// Loop until the buffer is empty.
-	do
-	{
-		// Obtain a byte from the buffer.
-		cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
-
-		// Post the byte.
-		xQueueSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );
-
-	} while( portINPUT_BYTE( BUFFER_COUNT ) );
-
-	// Now the buffer is empty we can switch context if necessary.
-	if( xHigherPriorityTaskWoken )
-	{
-		// Actual macro used here is port specific.
-		portYIELD_FROM_ISR ();
-	}
- }
- 
- * - * \defgroup xQueueSendFromISR xQueueSendFromISR + * @code{c} + * void vBufferISR( void ) + * { + * char cIn; + * BaseType_t xHigherPriorityTaskWoken; + * + * // We have not woken a task at the start of the ISR. + * xHigherPriorityTaskWoken = pdFALSE; + * + * // Loop until the buffer is empty. + * do + * { + * // Obtain a byte from the buffer. + * cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS ); + * + * // Post the byte. + * xQueueSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken ); + * + * } while( portINPUT_BYTE( BUFFER_COUNT ) ); + * + * // Now the buffer is empty we can switch context if necessary. + * if( xHigherPriorityTaskWoken ) + * { + * // Actual macro used here is port specific. + * portYIELD_FROM_ISR (); + * } + * } + * @endcode + * * \ingroup QueueManagement */ #define xQueueSendFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK ) +/**@{*/ /** - * queue. h - *
- BaseType_t xQueueGenericSendFromISR(
-										   QueueHandle_t		xQueue,
-										   const	void	*pvItemToQueue,
-										   BaseType_t	*pxHigherPriorityTaskWoken,
-										   BaseType_t	xCopyPosition
-									   );
- 
- * * It is preferred that the macros xQueueSendFromISR(), * xQueueSendToFrontFromISR() and xQueueSendToBackFromISR() be used in place * of calling this function directly. xQueueGiveFromISR() is an @@ -1378,7 +1219,7 @@ uint32_t ulVarToSend, ulValReceived; * queue was created, so this many bytes will be copied from pvItemToQueue * into the queue storage area. * - * @param pxHigherPriorityTaskWoken xQueueGenericSendFromISR() will set + * @param[out] pxHigherPriorityTaskWoken xQueueGenericSendFromISR() will set * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task * to unblock, and the unblocked task has a priority higher than the currently * running task. If xQueueGenericSendFromISR() sets this value to pdTRUE then @@ -1393,51 +1234,41 @@ uint32_t ulVarToSend, ulValReceived; * * Example usage for buffered IO (where the ISR can obtain more than one value * per call): -
- void vBufferISR( void )
- {
- char cIn;
- BaseType_t xHigherPriorityTaskWokenByPost;
-
-	// We have not woken a task at the start of the ISR.
-	xHigherPriorityTaskWokenByPost = pdFALSE;
-
-	// Loop until the buffer is empty.
-	do
-	{
-		// Obtain a byte from the buffer.
-		cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
-
-		// Post each byte.
-		xQueueGenericSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWokenByPost, queueSEND_TO_BACK );
-
-	} while( portINPUT_BYTE( BUFFER_COUNT ) );
-
-	// Now the buffer is empty we can switch context if necessary.  Note that the
-	// name of the yield function required is port specific.
-	if( xHigherPriorityTaskWokenByPost )
-	{
-		taskYIELD_YIELD_FROM_ISR();
-	}
- }
- 
- * - * \defgroup xQueueSendFromISR xQueueSendFromISR + * @code{c} + * void vBufferISR( void ) + * { + * char cIn; + * BaseType_t xHigherPriorityTaskWokenByPost; + * + * // We have not woken a task at the start of the ISR. + * xHigherPriorityTaskWokenByPost = pdFALSE; + * + * // Loop until the buffer is empty. + * do + * { + * // Obtain a byte from the buffer. + * cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS ); + * + * // Post each byte. + * xQueueGenericSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWokenByPost, queueSEND_TO_BACK ); + * + * } while( portINPUT_BYTE( BUFFER_COUNT ) ); + * + * // Now the buffer is empty we can switch context if necessary. Note that the + * // name of the yield function required is port specific. + * if( xHigherPriorityTaskWokenByPost ) + * { + * taskYIELD_YIELD_FROM_ISR(); + * } + * } + * @endcode * \ingroup QueueManagement */ BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue, const void * const pvItemToQueue, BaseType_t * const pxHigherPriorityTaskWoken, const BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION; BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue, BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; +/**@}*/ /** - * queue. h - *
- BaseType_t xQueueReceiveFromISR(
-									   QueueHandle_t	xQueue,
-									   void	*pvBuffer,
-									   BaseType_t *pxTaskWoken
-								   );
- * 
- * * Receive an item from a queue. It is safe to use this function from within an * interrupt service routine. * @@ -1447,7 +1278,7 @@ BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue, BaseType_t * const pxHigherP * @param pvBuffer Pointer to the buffer into which the received item will * be copied. * - * @param pxTaskWoken A task may be blocked waiting for space to become + * @param[out] pxHigherPriorityTaskWoken A task may be blocked waiting for space to become * available on the queue. If xQueueReceiveFromISR causes such a task to * unblock *pxTaskWoken will get set to pdTRUE, otherwise *pxTaskWoken will * remain unchanged. @@ -1456,77 +1287,77 @@ BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue, BaseType_t * const pxHigherP * otherwise pdFALSE. * * Example usage: -
-
- QueueHandle_t xQueue;
-
- // Function to create a queue and post some values.
- void vAFunction( void *pvParameters )
- {
- char cValueToPost;
- const TickType_t xTicksToWait = ( TickType_t )0xff;
-
-	// Create a queue capable of containing 10 characters.
-	xQueue = xQueueCreate( 10, sizeof( char ) );
-	if( xQueue == 0 )
-	{
-		// Failed to create the queue.
-	}
-
-	// ...
-
-	// Post some characters that will be used within an ISR.  If the queue
-	// is full then this task will block for xTicksToWait ticks.
-	cValueToPost = 'a';
-	xQueueSend( xQueue, ( void * ) &cValueToPost, xTicksToWait );
-	cValueToPost = 'b';
-	xQueueSend( xQueue, ( void * ) &cValueToPost, xTicksToWait );
-
-	// ... keep posting characters ... this task may block when the queue
-	// becomes full.
-
-	cValueToPost = 'c';
-	xQueueSend( xQueue, ( void * ) &cValueToPost, xTicksToWait );
- }
-
- // ISR that outputs all the characters received on the queue.
- void vISR_Routine( void )
- {
- BaseType_t xTaskWokenByReceive = pdFALSE;
- char cRxedChar;
-
-	while( xQueueReceiveFromISR( xQueue, ( void * ) &cRxedChar, &xTaskWokenByReceive) )
-	{
-		// A character was received.  Output the character now.
-		vOutputCharacter( cRxedChar );
-
-		// If removing the character from the queue woke the task that was
-		// posting onto the queue cTaskWokenByReceive will have been set to
-		// pdTRUE.  No matter how many times this loop iterates only one
-		// task will be woken.
-	}
-
-	if( cTaskWokenByPost != ( char ) pdFALSE;
-	{
-		taskYIELD ();
-	}
- }
- 
- * \defgroup xQueueReceiveFromISR xQueueReceiveFromISR + * @code{c} + * QueueHandle_t xQueue; + * + * // Function to create a queue and post some values. + * void vAFunction( void *pvParameters ) + * { + * char cValueToPost; + * const TickType_t xTicksToWait = ( TickType_t )0xff; + * + * // Create a queue capable of containing 10 characters. + * xQueue = xQueueCreate( 10, sizeof( char ) ); + * if( xQueue == 0 ) + * { + * // Failed to create the queue. + * } + * + * // ... + * + * // Post some characters that will be used within an ISR. If the queue + * // is full then this task will block for xTicksToWait ticks. + * cValueToPost = 'a'; + * xQueueSend( xQueue, ( void * ) &cValueToPost, xTicksToWait ); + * cValueToPost = 'b'; + * xQueueSend( xQueue, ( void * ) &cValueToPost, xTicksToWait ); + * + * // ... keep posting characters ... this task may block when the queue + * // becomes full. + * + * cValueToPost = 'c'; + * xQueueSend( xQueue, ( void * ) &cValueToPost, xTicksToWait ); + * } + * + * // ISR that outputs all the characters received on the queue. + * void vISR_Routine( void ) + * { + * BaseType_t xTaskWokenByReceive = pdFALSE; + * char cRxedChar; + * + * while( xQueueReceiveFromISR( xQueue, ( void * ) &cRxedChar, &xTaskWokenByReceive) ) + * { + * // A character was received. Output the character now. + * vOutputCharacter( cRxedChar ); + * + * // If removing the character from the queue woke the task that was + * // posting onto the queue cTaskWokenByReceive will have been set to + * // pdTRUE. No matter how many times this loop iterates only one + * // task will be woken. + * } + * + * if( cTaskWokenByPost != ( char ) pdFALSE; + * { + * taskYIELD (); + * } + * } + * @endcode * \ingroup QueueManagement */ BaseType_t xQueueReceiveFromISR( QueueHandle_t xQueue, void * const pvBuffer, BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; -/* +/**@{*/ +/** * Utilities to query queues that are safe to use from an ISR. These utilities * should be used only from witin an ISR, or within a critical section. */ BaseType_t xQueueIsQueueEmptyFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; UBaseType_t uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; +/**@}*/ - -/* +/** @cond */ +/** * xQueueAltGenericSend() is an alternative version of xQueueGenericSend(). * Likewise xQueueAltGenericReceive() is an alternative version of * xQueueGenericReceive(). @@ -1578,16 +1409,20 @@ void* xQueueGetMutexHolder( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION; */ BaseType_t xQueueTakeMutexRecursive( QueueHandle_t xMutex, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; BaseType_t xQueueGiveMutexRecursive( QueueHandle_t pxMutex ) PRIVILEGED_FUNCTION; +/** @endcond */ -/* +/** * Reset a queue back to its original empty state. pdPASS is returned if the * queue is successfully reset. pdFAIL is returned if the queue could not be * reset because there are tasks blocked on the queue waiting to either * receive from the queue or send to the queue. + * + * @param xQueue The queue to reset + * @return always returns pdPASS */ #define xQueueReset( xQueue ) xQueueGenericReset( xQueue, pdFALSE ) -/* +/** * The registry is provided as a means for kernel aware debuggers to * locate queues, semaphores and mutexes. Call vQueueAddToRegistry() add * a queue, semaphore or mutex handle to the registry if you want the handle @@ -1613,7 +1448,7 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t pxMutex ) PRIVILEGED_FUNCTION void vQueueAddToRegistry( QueueHandle_t xQueue, const char *pcName ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ #endif -/* +/** * The registry is provided as a means for kernel aware debuggers to * locate queues, semaphores and mutexes. Call vQueueAddToRegistry() add * a queue, semaphore or mutex handle to the registry if you want the handle @@ -1627,7 +1462,7 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t pxMutex ) PRIVILEGED_FUNCTION void vQueueUnregisterQueue( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; #endif -/* +/** * @note This function has been back ported from FreeRTOS v9.0.0 * * The queue registry is provided as a means for kernel aware debuggers to @@ -1641,10 +1476,10 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t pxMutex ) PRIVILEGED_FUNCTION * returned. */ #if( configQUEUE_REGISTRY_SIZE > 0 ) - const char *pcQueueGetName( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + const char *pcQueueGetName( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ #endif -/* +/** * Generic version of the function used to creaet a queue using dynamic memory * allocation. This is called by other functions and macros that create other * RTOS objects that use the queue structure as their base. @@ -1653,7 +1488,7 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t pxMutex ) PRIVILEGED_FUNCTION QueueHandle_t xQueueGenericCreate( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, const uint8_t ucQueueType ) PRIVILEGED_FUNCTION; #endif -/* +/** * Generic version of the function used to creaet a queue using dynamic memory * allocation. This is called by other functions and macros that create other * RTOS objects that use the queue structure as their base. @@ -1662,7 +1497,7 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t pxMutex ) PRIVILEGED_FUNCTION QueueHandle_t xQueueGenericCreateStatic( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, uint8_t *pucQueueStorage, StaticQueue_t *pxStaticQueue, const uint8_t ucQueueType ) PRIVILEGED_FUNCTION; #endif -/* +/** * Queue sets provide a mechanism to allow a task to block (pend) on a read * operation from multiple queues or semaphores simultaneously. * @@ -1712,7 +1547,7 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t pxMutex ) PRIVILEGED_FUNCTION */ QueueSetHandle_t xQueueCreateSet( const UBaseType_t uxEventQueueLength ) PRIVILEGED_FUNCTION; -/* +/** * Adds a queue or semaphore to a queue set that was previously created by a * call to xQueueCreateSet(). * @@ -1736,7 +1571,7 @@ QueueSetHandle_t xQueueCreateSet( const UBaseType_t uxEventQueueLength ) PRIVILE */ BaseType_t xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION; -/* +/** * Removes a queue or semaphore from a queue set. A queue or semaphore can only * be removed from a set if the queue or semaphore is empty. * @@ -1755,7 +1590,7 @@ BaseType_t xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHan */ BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION; -/* +/** * xQueueSelectFromSet() selects from the members of a queue set a queue or * semaphore that either contains data (in the case of a queue) or is available * to take (in the case of a semaphore). xQueueSelectFromSet() effectively @@ -1791,18 +1626,19 @@ BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueS */ QueueSetMemberHandle_t xQueueSelectFromSet( QueueSetHandle_t xQueueSet, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; -/* +/** * A version of xQueueSelectFromSet() that can be used from an ISR. */ QueueSetMemberHandle_t xQueueSelectFromSetFromISR( QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION; +/** @cond */ /* Not public API functions. */ void vQueueWaitForMessageRestricted( QueueHandle_t xQueue, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; BaseType_t xQueueGenericReset( QueueHandle_t xQueue, BaseType_t xNewQueue ) PRIVILEGED_FUNCTION; void vQueueSetQueueNumber( QueueHandle_t xQueue, UBaseType_t uxQueueNumber ) PRIVILEGED_FUNCTION; UBaseType_t uxQueueGetQueueNumber( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; uint8_t ucQueueGetQueueType( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; - +/** @endcond */ #ifdef __cplusplus } diff --git a/tools/sdk/include/freertos/freertos/ringbuf.h b/tools/sdk/include/freertos/freertos/ringbuf.h index 23ea8686808e93b2d57c6f5fc3ede551c039869c..0f23a44e6b61e72a876ebbdcc5f389b49afcaefd 100644 --- a/tools/sdk/include/freertos/freertos/ringbuf.h +++ b/tools/sdk/include/freertos/freertos/ringbuf.h @@ -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 //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. - * - * @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. - * - * @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. + * @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. + * + * @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. + * + * 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 + * @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); diff --git a/tools/sdk/include/freertos/freertos/semphr.h b/tools/sdk/include/freertos/freertos/semphr.h index 6343d0190a0ea264cbfb25d7fc5f7a0ff604de24..abe3819f8f33e2344e5c8dd521a64862c48fc0a2 100644 --- a/tools/sdk/include/freertos/freertos/semphr.h +++ b/tools/sdk/include/freertos/freertos/semphr.h @@ -82,11 +82,8 @@ typedef QueueHandle_t SemaphoreHandle_t; #define semSEMAPHORE_QUEUE_ITEM_LENGTH ( ( uint8_t ) 0U ) #define semGIVE_BLOCK_TIME ( ( TickType_t ) 0U ) - +/** @cond */ /** - * semphr. h - *
vSemaphoreCreateBinary( SemaphoreHandle_t xSemaphore )
- * * This old vSemaphoreCreateBinary() macro is now deprecated in favour of the * xSemaphoreCreateBinary() function. Note that binary semaphores created using * the vSemaphoreCreateBinary() macro are created in a state such that the @@ -109,23 +106,22 @@ typedef QueueHandle_t SemaphoreHandle_t; * @param xSemaphore Handle to the created semaphore. Should be of type SemaphoreHandle_t. * * Example usage: -
- SemaphoreHandle_t xSemaphore = NULL;
-
- void vATask( void * pvParameters )
- {
-    // Semaphore cannot be used before a call to vSemaphoreCreateBinary ().
-    // This is a macro so pass the variable in directly.
-    vSemaphoreCreateBinary( xSemaphore );
-
-    if( xSemaphore != NULL )
-    {
-        // The semaphore was created successfully.
-        // The semaphore can now be used.
-    }
- }
- 
- * \defgroup vSemaphoreCreateBinary vSemaphoreCreateBinary + * @code{c} + * SemaphoreHandle_t xSemaphore = NULL; + * + * void vATask( void * pvParameters ) + * { + * // Semaphore cannot be used before a call to vSemaphoreCreateBinary (). + * // This is a macro so pass the variable in directly. + * vSemaphoreCreateBinary( xSemaphore ); + * + * if( xSemaphore != NULL ) + * { + * // The semaphore was created successfully. + * // The semaphore can now be used. + * } + * } + * @endcode * \ingroup Semaphores */ #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) @@ -138,11 +134,9 @@ typedef QueueHandle_t SemaphoreHandle_t; } \ } #endif +/** @endcond */ /** - * semphr. h - *
SemaphoreHandle_t xSemaphoreCreateBinary( void )
- * * Creates a new binary semaphore instance, and returns a handle by which the * new semaphore can be referenced. * @@ -181,23 +175,22 @@ typedef QueueHandle_t SemaphoreHandle_t; * @return Handle to the created semaphore. * * Example usage: -
- SemaphoreHandle_t xSemaphore = NULL;
-
- void vATask( void * pvParameters )
- {
-    // Semaphore cannot be used before a call to vSemaphoreCreateBinary ().
-    // This is a macro so pass the variable in directly.
-    xSemaphore = xSemaphoreCreateBinary();
-
-    if( xSemaphore != NULL )
-    {
-        // The semaphore was created successfully.
-        // The semaphore can now be used.
-    }
- }
- 
- * \defgroup vSemaphoreCreateBinary vSemaphoreCreateBinary + * @code{c} + * SemaphoreHandle_t xSemaphore = NULL; + * + * void vATask( void * pvParameters ) + * { + * // Semaphore cannot be used before a call to vSemaphoreCreateBinary (). + * // This is a macro so pass the variable in directly. + * xSemaphore = xSemaphoreCreateBinary(); + * + * if( xSemaphore != NULL ) + * { + * // The semaphore was created successfully. + * // The semaphore can now be used. + * } + * } + * @endcode * \ingroup Semaphores */ #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) @@ -205,9 +198,6 @@ typedef QueueHandle_t SemaphoreHandle_t; #endif /** - * semphr. h - *
SemaphoreHandle_t xSemaphoreCreateBinaryStatic( StaticSemaphore_t *pxSemaphoreBuffer )
- * * Creates a new binary semaphore instance, and returns a handle by which the * new semaphore can be referenced. * @@ -231,7 +221,7 @@ typedef QueueHandle_t SemaphoreHandle_t; * semaphore does not use a priority inheritance mechanism. For an alternative * that does use priority inheritance see xSemaphoreCreateMutex(). * - * @param pxSemaphoreBuffer Must point to a variable of type StaticSemaphore_t, + * @param pxStaticSemaphore Must point to a variable of type StaticSemaphore_t, * which will then be used to hold the semaphore's data structure, removing the * need for the memory to be allocated dynamically. * @@ -239,24 +229,23 @@ typedef QueueHandle_t SemaphoreHandle_t; * returned. If pxSemaphoreBuffer is NULL then NULL is returned. * * Example usage: -
- SemaphoreHandle_t xSemaphore = NULL;
- StaticSemaphore_t xSemaphoreBuffer;
-
- void vATask( void * pvParameters )
- {
-    // Semaphore cannot be used before a call to xSemaphoreCreateBinary().
-    // The semaphore's data structures will be placed in the xSemaphoreBuffer
-    // variable, the address of which is passed into the function.  The
-    // function's parameter is not NULL, so the function will not attempt any
-    // dynamic memory allocation, and therefore the function will not return
-    // return NULL.
-    xSemaphore = xSemaphoreCreateBinary( &xSemaphoreBuffer );
-
-    // Rest of task code goes here.
- }
- 
- * \defgroup xSemaphoreCreateBinaryStatic xSemaphoreCreateBinaryStatic + * @code{c} + * SemaphoreHandle_t xSemaphore = NULL; + * StaticSemaphore_t xSemaphoreBuffer; + * + * void vATask( void * pvParameters ) + * { + * // Semaphore cannot be used before a call to xSemaphoreCreateBinary(). + * // The semaphore's data structures will be placed in the xSemaphoreBuffer + * // variable, the address of which is passed into the function. The + * // function's parameter is not NULL, so the function will not attempt any + * // dynamic memory allocation, and therefore the function will not return + * // return NULL. + * xSemaphore = xSemaphoreCreateBinary( &xSemaphoreBuffer ); + * + * // Rest of task code goes here. + * } + * @endcode * \ingroup Semaphores */ #if( configSUPPORT_STATIC_ALLOCATION == 1 ) @@ -264,12 +253,6 @@ typedef QueueHandle_t SemaphoreHandle_t; #endif /* configSUPPORT_STATIC_ALLOCATION */ /** - * semphr. h - *
xSemaphoreTake(
- *                   SemaphoreHandle_t xSemaphore,
- *                   TickType_t xBlockTime
- *               )
- * * Macro to obtain a semaphore. The semaphore must have previously been * created with a call to vSemaphoreCreateBinary(), xSemaphoreCreateMutex() or * xSemaphoreCreateCounting(). @@ -287,56 +270,49 @@ typedef QueueHandle_t SemaphoreHandle_t; * if xBlockTime expired without the semaphore becoming available. * * Example usage: -
- SemaphoreHandle_t xSemaphore = NULL;
-
- // A task that creates a semaphore.
- void vATask( void * pvParameters )
- {
-    // Create the semaphore to guard a shared resource.
-    vSemaphoreCreateBinary( xSemaphore );
- }
-
- // A task that uses the semaphore.
- void vAnotherTask( void * pvParameters )
- {
-    // ... Do other things.
-
-    if( xSemaphore != NULL )
-    {
-        // See if we can obtain the semaphore.  If the semaphore is not available
-        // wait 10 ticks to see if it becomes free.
-        if( xSemaphoreTake( xSemaphore, ( TickType_t ) 10 ) == pdTRUE )
-        {
-            // We were able to obtain the semaphore and can now access the
-            // shared resource.
-
-            // ...
-
-            // We have finished accessing the shared resource.  Release the
-            // semaphore.
-            xSemaphoreGive( xSemaphore );
-        }
-        else
-        {
-            // We could not obtain the semaphore and can therefore not access
-            // the shared resource safely.
-        }
-    }
- }
- 
- * \defgroup xSemaphoreTake xSemaphoreTake + * @code{c} + * SemaphoreHandle_t xSemaphore = NULL; + * + * // A task that creates a semaphore. + * void vATask( void * pvParameters ) + * { + * // Create the semaphore to guard a shared resource. + * vSemaphoreCreateBinary( xSemaphore ); + * } + * + * // A task that uses the semaphore. + * void vAnotherTask( void * pvParameters ) + * { + * // ... Do other things. + * + * if( xSemaphore != NULL ) + * { + * // See if we can obtain the semaphore. If the semaphore is not available + * // wait 10 ticks to see if it becomes free. + * if( xSemaphoreTake( xSemaphore, ( TickType_t ) 10 ) == pdTRUE ) + * { + * // We were able to obtain the semaphore and can now access the + * // shared resource. + * + * // ... + * + * // We have finished accessing the shared resource. Release the + * // semaphore. + * xSemaphoreGive( xSemaphore ); + * } + * else + * { + * // We could not obtain the semaphore and can therefore not access + * // the shared resource safely. + * } + * } + * } + * @endcode * \ingroup Semaphores */ #define xSemaphoreTake( xSemaphore, xBlockTime ) xQueueGenericReceive( ( QueueHandle_t ) ( xSemaphore ), NULL, ( xBlockTime ), pdFALSE ) /** - * semphr. h - * xSemaphoreTakeRecursive( - * SemaphoreHandle_t xMutex, - * TickType_t xBlockTime - * ) - * * Macro to recursively obtain, or 'take', a mutex type semaphore. * The mutex must have previously been created using a call to * xSemaphoreCreateRecursiveMutex(); @@ -366,64 +342,63 @@ typedef QueueHandle_t SemaphoreHandle_t; * expired without the semaphore becoming available. * * Example usage: -
- SemaphoreHandle_t xMutex = NULL;
-
- // A task that creates a mutex.
- void vATask( void * pvParameters )
- {
-    // Create the mutex to guard a shared resource.
-    xMutex = xSemaphoreCreateRecursiveMutex();
- }
-
- // A task that uses the mutex.
- void vAnotherTask( void * pvParameters )
- {
-    // ... Do other things.
-
-    if( xMutex != NULL )
-    {
-        // See if we can obtain the mutex.  If the mutex is not available
-        // wait 10 ticks to see if it becomes free.
-        if( xSemaphoreTakeRecursive( xSemaphore, ( TickType_t ) 10 ) == pdTRUE )
-        {
-            // We were able to obtain the mutex and can now access the
-            // shared resource.
-
-            // ...
-            // For some reason due to the nature of the code further calls to
-			// xSemaphoreTakeRecursive() are made on the same mutex.  In real
-			// code these would not be just sequential calls as this would make
-			// no sense.  Instead the calls are likely to be buried inside
-			// a more complex call structure.
-            xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );
-            xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );
-
-            // The mutex has now been 'taken' three times, so will not be
-			// available to another task until it has also been given back
-			// three times.  Again it is unlikely that real code would have
-			// these calls sequentially, but instead buried in a more complex
-			// call structure.  This is just for illustrative purposes.
-            xSemaphoreGiveRecursive( xMutex );
-			xSemaphoreGiveRecursive( xMutex );
-			xSemaphoreGiveRecursive( xMutex );
-
-			// Now the mutex can be taken by other tasks.
-        }
-        else
-        {
-            // We could not obtain the mutex and can therefore not access
-            // the shared resource safely.
-        }
-    }
- }
- 
- * \defgroup xSemaphoreTakeRecursive xSemaphoreTakeRecursive + * @code{c} + * SemaphoreHandle_t xMutex = NULL; + * + * // A task that creates a mutex. + * void vATask( void * pvParameters ) + * { + * // Create the mutex to guard a shared resource. + * xMutex = xSemaphoreCreateRecursiveMutex(); + * } + * + * // A task that uses the mutex. + * void vAnotherTask( void * pvParameters ) + * { + * // ... Do other things. + * + * if( xMutex != NULL ) + * { + * // See if we can obtain the mutex. If the mutex is not available + * // wait 10 ticks to see if it becomes free. + * if( xSemaphoreTakeRecursive( xSemaphore, ( TickType_t ) 10 ) == pdTRUE ) + * { + * // We were able to obtain the mutex and can now access the + * // shared resource. + * + * // ... + * // For some reason due to the nature of the code further calls to + * // xSemaphoreTakeRecursive() are made on the same mutex. In real + * // code these would not be just sequential calls as this would make + * // no sense. Instead the calls are likely to be buried inside + * // a more complex call structure. + * xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 ); + * xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 ); + * + * // The mutex has now been 'taken' three times, so will not be + * // available to another task until it has also been given back + * // three times. Again it is unlikely that real code would have + * // these calls sequentially, but instead buried in a more complex + * // call structure. This is just for illustrative purposes. + * xSemaphoreGiveRecursive( xMutex ); + * xSemaphoreGiveRecursive( xMutex ); + * xSemaphoreGiveRecursive( xMutex ); + * + * // Now the mutex can be taken by other tasks. + * } + * else + * { + * // We could not obtain the mutex and can therefore not access + * // the shared resource safely. + * } + * } + * } + * @endcode * \ingroup Semaphores */ #define xSemaphoreTakeRecursive( xMutex, xBlockTime ) xQueueTakeMutexRecursive( ( xMutex ), ( xBlockTime ) ) - +/** @cond */ /* * xSemaphoreAltTake() is an alternative version of xSemaphoreTake(). * @@ -437,11 +412,9 @@ typedef QueueHandle_t SemaphoreHandle_t; * sacrifices execution speed to ensure better interrupt responsiveness. */ #define xSemaphoreAltTake( xSemaphore, xBlockTime ) xQueueAltGenericReceive( ( QueueHandle_t ) ( xSemaphore ), NULL, ( xBlockTime ), pdFALSE ) +/** @endcond */ /** - * semphr. h - *
xSemaphoreGive( SemaphoreHandle_t xSemaphore )
- * * Macro to release a semaphore. The semaphore must have previously been * created with a call to vSemaphoreCreateBinary(), xSemaphoreCreateMutex() or * xSemaphoreCreateCounting(). and obtained using sSemaphoreTake(). @@ -461,50 +434,46 @@ typedef QueueHandle_t SemaphoreHandle_t; * semaphore was not first obtained correctly. * * Example usage: -
- SemaphoreHandle_t xSemaphore = NULL;
-
- void vATask( void * pvParameters )
- {
-    // Create the semaphore to guard a shared resource.
-    vSemaphoreCreateBinary( xSemaphore );
-
-    if( xSemaphore != NULL )
-    {
-        if( xSemaphoreGive( xSemaphore ) != pdTRUE )
-        {
-            // We would expect this call to fail because we cannot give
-            // a semaphore without first "taking" it!
-        }
-
-        // Obtain the semaphore - don't block if the semaphore is not
-        // immediately available.
-        if( xSemaphoreTake( xSemaphore, ( TickType_t ) 0 ) )
-        {
-            // We now have the semaphore and can access the shared resource.
-
-            // ...
-
-            // We have finished accessing the shared resource so can free the
-            // semaphore.
-            if( xSemaphoreGive( xSemaphore ) != pdTRUE )
-            {
-                // We would not expect this call to fail because we must have
-                // obtained the semaphore to get here.
-            }
-        }
-    }
- }
- 
- * \defgroup xSemaphoreGive xSemaphoreGive + * @code{c} + * SemaphoreHandle_t xSemaphore = NULL; + * + * void vATask( void * pvParameters ) + * { + * // Create the semaphore to guard a shared resource. + * vSemaphoreCreateBinary( xSemaphore ); + * + * if( xSemaphore != NULL ) + * { + * if( xSemaphoreGive( xSemaphore ) != pdTRUE ) + * { + * // We would expect this call to fail because we cannot give + * // a semaphore without first "taking" it! + * } + * + * // Obtain the semaphore - don't block if the semaphore is not + * // immediately available. + * if( xSemaphoreTake( xSemaphore, ( TickType_t ) 0 ) ) + * { + * // We now have the semaphore and can access the shared resource. + * + * // ... + * + * // We have finished accessing the shared resource so can free the + * // semaphore. + * if( xSemaphoreGive( xSemaphore ) != pdTRUE ) + * { + * // We would not expect this call to fail because we must have + * // obtained the semaphore to get here. + * } + * } + * } + * } + * @endcode * \ingroup Semaphores */ #define xSemaphoreGive( xSemaphore ) xQueueGenericSend( ( QueueHandle_t ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK ) /** - * semphr. h - *
xSemaphoreGiveRecursive( SemaphoreHandle_t xMutex )
- * * Macro to recursively release, or 'give', a mutex type semaphore. * The mutex must have previously been created using a call to * xSemaphoreCreateRecursiveMutex(); @@ -527,64 +496,64 @@ typedef QueueHandle_t SemaphoreHandle_t; * @return pdTRUE if the semaphore was given. * * Example usage: -
- SemaphoreHandle_t xMutex = NULL;
-
- // A task that creates a mutex.
- void vATask( void * pvParameters )
- {
-    // Create the mutex to guard a shared resource.
-    xMutex = xSemaphoreCreateRecursiveMutex();
- }
-
- // A task that uses the mutex.
- void vAnotherTask( void * pvParameters )
- {
-    // ... Do other things.
-
-    if( xMutex != NULL )
-    {
-        // See if we can obtain the mutex.  If the mutex is not available
-        // wait 10 ticks to see if it becomes free.
-        if( xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 ) == pdTRUE )
-        {
-            // We were able to obtain the mutex and can now access the
-            // shared resource.
-
-            // ...
-            // For some reason due to the nature of the code further calls to
-			// xSemaphoreTakeRecursive() are made on the same mutex.  In real
-			// code these would not be just sequential calls as this would make
-			// no sense.  Instead the calls are likely to be buried inside
-			// a more complex call structure.
-            xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );
-            xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );
-
-            // The mutex has now been 'taken' three times, so will not be
-			// available to another task until it has also been given back
-			// three times.  Again it is unlikely that real code would have
-			// these calls sequentially, it would be more likely that the calls
-			// to xSemaphoreGiveRecursive() would be called as a call stack
-			// unwound.  This is just for demonstrative purposes.
-            xSemaphoreGiveRecursive( xMutex );
-			xSemaphoreGiveRecursive( xMutex );
-			xSemaphoreGiveRecursive( xMutex );
-
-			// Now the mutex can be taken by other tasks.
-        }
-        else
-        {
-            // We could not obtain the mutex and can therefore not access
-            // the shared resource safely.
-        }
-    }
- }
- 
- * \defgroup xSemaphoreGiveRecursive xSemaphoreGiveRecursive + * @code{c} + * SemaphoreHandle_t xMutex = NULL; + * + * // A task that creates a mutex. + * void vATask( void * pvParameters ) + * { + * // Create the mutex to guard a shared resource. + * xMutex = xSemaphoreCreateRecursiveMutex(); + * } + * + * // A task that uses the mutex. + * void vAnotherTask( void * pvParameters ) + * { + * // ... Do other things. + * + * if( xMutex != NULL ) + * { + * // See if we can obtain the mutex. If the mutex is not available + * // wait 10 ticks to see if it becomes free. + * if( xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 ) == pdTRUE ) + * { + * // We were able to obtain the mutex and can now access the + * // shared resource. + * + * // ... + * // For some reason due to the nature of the code further calls to + * // xSemaphoreTakeRecursive() are made on the same mutex. In real + * // code these would not be just sequential calls as this would make + * // no sense. Instead the calls are likely to be buried inside + * // a more complex call structure. + * xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 ); + * xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 ); + * + * // The mutex has now been 'taken' three times, so will not be + * // available to another task until it has also been given back + * // three times. Again it is unlikely that real code would have + * // these calls sequentially, it would be more likely that the calls + * // to xSemaphoreGiveRecursive() would be called as a call stack + * // unwound. This is just for demonstrative purposes. + * xSemaphoreGiveRecursive( xMutex ); + * xSemaphoreGiveRecursive( xMutex ); + * xSemaphoreGiveRecursive( xMutex ); + * + * // Now the mutex can be taken by other tasks. + * } + * else + * { + * // We could not obtain the mutex and can therefore not access + * // the shared resource safely. + * } + * } + * } + * @endcode * \ingroup Semaphores */ #define xSemaphoreGiveRecursive( xMutex ) xQueueGiveMutexRecursive( ( xMutex ) ) +/** @cond */ /* * xSemaphoreAltGive() is an alternative version of xSemaphoreGive(). * @@ -599,14 +568,9 @@ typedef QueueHandle_t SemaphoreHandle_t; */ #define xSemaphoreAltGive( xSemaphore ) xQueueAltGenericSend( ( QueueHandle_t ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK ) +/** @endcond */ + /** - * semphr. h - *
- xSemaphoreGiveFromISR(
-                          SemaphoreHandle_t xSemaphore,
-                          BaseType_t *pxHigherPriorityTaskWoken
-                      )
- * * Macro to release a semaphore. The semaphore must have previously been * created with a call to vSemaphoreCreateBinary() or xSemaphoreCreateCounting(). * @@ -618,7 +582,7 @@ typedef QueueHandle_t SemaphoreHandle_t; * @param xSemaphore A handle to the semaphore being released. This is the * handle returned when the semaphore was created. * - * @param pxHigherPriorityTaskWoken xSemaphoreGiveFromISR() will set + * @param[out] pxHigherPriorityTaskWoken xSemaphoreGiveFromISR() will set * *pxHigherPriorityTaskWoken to pdTRUE if giving the semaphore caused a task * to unblock, and the unblocked task has a priority higher than the currently * running task. If xSemaphoreGiveFromISR() sets this value to pdTRUE then @@ -627,77 +591,69 @@ typedef QueueHandle_t SemaphoreHandle_t; * @return pdTRUE if the semaphore was successfully given, otherwise errQUEUE_FULL. * * Example usage: -
- \#define LONG_TIME 0xffff
- \#define TICKS_TO_WAIT	10
- SemaphoreHandle_t xSemaphore = NULL;
-
- // Repetitive task.
- void vATask( void * pvParameters )
- {
-    for( ;; )
-    {
-        // We want this task to run every 10 ticks of a timer.  The semaphore
-        // was created before this task was started.
-
-        // Block waiting for the semaphore to become available.
-        if( xSemaphoreTake( xSemaphore, LONG_TIME ) == pdTRUE )
-        {
-            // It is time to execute.
-
-            // ...
-
-            // We have finished our task.  Return to the top of the loop where
-            // we will block on the semaphore until it is time to execute
-            // again.  Note when using the semaphore for synchronisation with an
-			// ISR in this manner there is no need to 'give' the semaphore back.
-        }
-    }
- }
-
- // Timer ISR
- void vTimerISR( void * pvParameters )
- {
- static uint8_t ucLocalTickCount = 0;
- static BaseType_t xHigherPriorityTaskWoken;
-
-    // A timer tick has occurred.
-
-    // ... Do other time functions.
-
-    // Is it time for vATask () to run?
-	xHigherPriorityTaskWoken = pdFALSE;
-    ucLocalTickCount++;
-    if( ucLocalTickCount >= TICKS_TO_WAIT )
-    {
-        // Unblock the task by releasing the semaphore.
-        xSemaphoreGiveFromISR( xSemaphore, &xHigherPriorityTaskWoken );
-
-        // Reset the count so we release the semaphore again in 10 ticks time.
-        ucLocalTickCount = 0;
-    }
-
-    if( xHigherPriorityTaskWoken != pdFALSE )
-    {
-        // We can force a context switch here.  Context switching from an
-        // ISR uses port specific syntax.  Check the demo task for your port
-        // to find the syntax required.
-    }
- }
- 
- * \defgroup xSemaphoreGiveFromISR xSemaphoreGiveFromISR + * @code{c} + * \#define LONG_TIME 0xffff + * \#define TICKS_TO_WAIT 10 + * SemaphoreHandle_t xSemaphore = NULL; + * + * // Repetitive task. + * void vATask( void * pvParameters ) + * { + * for( ;; ) + * { + * // We want this task to run every 10 ticks of a timer. The semaphore + * // was created before this task was started. + * + * // Block waiting for the semaphore to become available. + * if( xSemaphoreTake( xSemaphore, LONG_TIME ) == pdTRUE ) + * { + * // It is time to execute. + * + * // ... + * + * // We have finished our task. Return to the top of the loop where + * // we will block on the semaphore until it is time to execute + * // again. Note when using the semaphore for synchronisation with an + * // ISR in this manner there is no need to 'give' the semaphore back. + * } + * } + * } + * + * // Timer ISR + * void vTimerISR( void * pvParameters ) + * { + * static uint8_t ucLocalTickCount = 0; + * static BaseType_t xHigherPriorityTaskWoken; + * + * // A timer tick has occurred. + * + * // ... Do other time functions. + * + * // Is it time for vATask () to run? + * xHigherPriorityTaskWoken = pdFALSE; + * ucLocalTickCount++; + * if( ucLocalTickCount >= TICKS_TO_WAIT ) + * { + * // Unblock the task by releasing the semaphore. + * xSemaphoreGiveFromISR( xSemaphore, &xHigherPriorityTaskWoken ); + * + * // Reset the count so we release the semaphore again in 10 ticks time. + * ucLocalTickCount = 0; + * } + * + * if( xHigherPriorityTaskWoken != pdFALSE ) + * { + * // We can force a context switch here. Context switching from an + * // ISR uses port specific syntax. Check the demo task for your port + * // to find the syntax required. + * } + * } + * @endcode * \ingroup Semaphores */ #define xSemaphoreGiveFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueGiveFromISR( ( QueueHandle_t ) ( xSemaphore ), ( pxHigherPriorityTaskWoken ) ) /** - * semphr. h - *
- xSemaphoreTakeFromISR(
-                          SemaphoreHandle_t xSemaphore,
-                          BaseType_t *pxHigherPriorityTaskWoken
-                      )
- * * Macro to take a semaphore from an ISR. The semaphore must have * previously been created with a call to vSemaphoreCreateBinary() or * xSemaphoreCreateCounting(). @@ -713,7 +669,7 @@ typedef QueueHandle_t SemaphoreHandle_t; * @param xSemaphore A handle to the semaphore being taken. This is the * handle returned when the semaphore was created. * - * @param pxHigherPriorityTaskWoken xSemaphoreTakeFromISR() will set + * @param[out] pxHigherPriorityTaskWoken xSemaphoreTakeFromISR() will set * *pxHigherPriorityTaskWoken to pdTRUE if taking the semaphore caused a task * to unblock, and the unblocked task has a priority higher than the currently * running task. If xSemaphoreTakeFromISR() sets this value to pdTRUE then @@ -725,9 +681,6 @@ typedef QueueHandle_t SemaphoreHandle_t; #define xSemaphoreTakeFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueReceiveFromISR( ( QueueHandle_t ) ( xSemaphore ), NULL, ( pxHigherPriorityTaskWoken ) ) /** - * semphr. h - *
SemaphoreHandle_t xSemaphoreCreateMutex( void )
- * * Macro that implements a mutex semaphore by using the existing queue * mechanism. * @@ -760,23 +713,22 @@ typedef QueueHandle_t SemaphoreHandle_t; * data structures then NULL is returned. * * Example usage: -
- SemaphoreHandle_t xSemaphore;
-
- void vATask( void * pvParameters )
- {
-    // Semaphore cannot be used before a call to xSemaphoreCreateMutex().
-    // This is a macro so pass the variable in directly.
-    xSemaphore = xSemaphoreCreateMutex();
-
-    if( xSemaphore != NULL )
-    {
-        // The semaphore was created successfully.
-        // The semaphore can now be used.
-    }
- }
- 
- * \defgroup vSemaphoreCreateMutex vSemaphoreCreateMutex + * @code{c} + * SemaphoreHandle_t xSemaphore; + * + * void vATask( void * pvParameters ) + * { + * // Semaphore cannot be used before a call to xSemaphoreCreateMutex(). + * // This is a macro so pass the variable in directly. + * xSemaphore = xSemaphoreCreateMutex(); + * + * if( xSemaphore != NULL ) + * { + * // The semaphore was created successfully. + * // The semaphore can now be used. + * } + * } + * @endcode * \ingroup Semaphores */ #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) @@ -784,9 +736,6 @@ typedef QueueHandle_t SemaphoreHandle_t; #endif /** - * semphr. h - *
SemaphoreHandle_t xSemaphoreCreateMutexStatic( StaticSemaphore_t *pxMutexBuffer )
- * * Creates a new mutex type semaphore instance, and returns a handle by which * the new mutex can be referenced. * @@ -822,22 +771,21 @@ typedef QueueHandle_t SemaphoreHandle_t; * mutex is returned. If pxMutexBuffer was NULL then NULL is returned. * * Example usage: -
- SemaphoreHandle_t xSemaphore;
- StaticSemaphore_t xMutexBuffer;
-
- void vATask( void * pvParameters )
- {
-    // A mutex cannot be used before it has been created.  xMutexBuffer is
-    // into xSemaphoreCreateMutexStatic() so no dynamic memory allocation is
-    // attempted.
-    xSemaphore = xSemaphoreCreateMutexStatic( &xMutexBuffer );
-
-    // As no dynamic memory allocation was performed, xSemaphore cannot be NULL,
-    // so there is no need to check it.
- }
- 
- * \defgroup xSemaphoreCreateMutexStatic xSemaphoreCreateMutexStatic + * @code + * SemaphoreHandle_t xSemaphore; + * StaticSemaphore_t xMutexBuffer; + * + * void vATask( void * pvParameters ) + * { + * // A mutex cannot be used before it has been created. xMutexBuffer is + * // into xSemaphoreCreateMutexStatic() so no dynamic memory allocation is + * // attempted. + * xSemaphore = xSemaphoreCreateMutexStatic( &xMutexBuffer ); + * + * // As no dynamic memory allocation was performed, xSemaphore cannot be NULL, + * // so there is no need to check it. + * } + * @endcode * \ingroup Semaphores */ #if( configSUPPORT_STATIC_ALLOCATION == 1 ) @@ -846,9 +794,6 @@ typedef QueueHandle_t SemaphoreHandle_t; /** - * semphr. h - *
SemaphoreHandle_t xSemaphoreCreateRecursiveMutex( void )
- * * Creates a new recursive mutex type semaphore instance, and returns a handle * by which the new recursive mutex can be referenced. * @@ -889,23 +834,22 @@ typedef QueueHandle_t SemaphoreHandle_t; * SemaphoreHandle_t. * * Example usage: -
- SemaphoreHandle_t xSemaphore;
-
- void vATask( void * pvParameters )
- {
-    // Semaphore cannot be used before a call to xSemaphoreCreateMutex().
-    // This is a macro so pass the variable in directly.
-    xSemaphore = xSemaphoreCreateRecursiveMutex();
-
-    if( xSemaphore != NULL )
-    {
-        // The semaphore was created successfully.
-        // The semaphore can now be used.
-    }
- }
- 
- * \defgroup vSemaphoreCreateMutex vSemaphoreCreateMutex + * @code{c} + * SemaphoreHandle_t xSemaphore; + * + * void vATask( void * pvParameters ) + * { + * // Semaphore cannot be used before a call to xSemaphoreCreateMutex(). + * // This is a macro so pass the variable in directly. + * xSemaphore = xSemaphoreCreateRecursiveMutex(); + * + * if( xSemaphore != NULL ) + * { + * // The semaphore was created successfully. + * // The semaphore can now be used. + * } + * } + * @endcode * \ingroup Semaphores */ #if( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_RECURSIVE_MUTEXES == 1 ) ) @@ -913,9 +857,6 @@ typedef QueueHandle_t SemaphoreHandle_t; #endif /** - * semphr. h - *
SemaphoreHandle_t xSemaphoreCreateRecursiveMutexStatic( StaticSemaphore_t *pxMutexBuffer )
- * * Creates a new recursive mutex type semaphore instance, and returns a handle * by which the new recursive mutex can be referenced. * @@ -952,7 +893,7 @@ typedef QueueHandle_t SemaphoreHandle_t; * semaphore and another always 'takes' the semaphore) and from within interrupt * service routines. * - * @param pxMutexBuffer Must point to a variable of type StaticSemaphore_t, + * @param pxStaticSemaphore Must point to a variable of type StaticSemaphore_t, * which will then be used to hold the recursive mutex's data structure, * removing the need for the memory to be allocated dynamically. * @@ -961,24 +902,23 @@ typedef QueueHandle_t SemaphoreHandle_t; * returned. * * Example usage: -
- SemaphoreHandle_t xSemaphore;
- StaticSemaphore_t xMutexBuffer;
-
- void vATask( void * pvParameters )
- {
-    // A recursive semaphore cannot be used before it is created.  Here a
-    // recursive mutex is created using xSemaphoreCreateRecursiveMutexStatic().
-    // The address of xMutexBuffer is passed into the function, and will hold
-    // the mutexes data structures - so no dynamic memory allocation will be
-    // attempted.
-    xSemaphore = xSemaphoreCreateRecursiveMutexStatic( &xMutexBuffer );
-
-    // As no dynamic memory allocation was performed, xSemaphore cannot be NULL,
-    // so there is no need to check it.
- }
- 
- * \defgroup xSemaphoreCreateRecursiveMutexStatic xSemaphoreCreateRecursiveMutexStatic + * @code + * SemaphoreHandle_t xSemaphore; + * StaticSemaphore_t xMutexBuffer; + * + * void vATask( void * pvParameters ) + * { + * // A recursive semaphore cannot be used before it is created. Here a + * // recursive mutex is created using xSemaphoreCreateRecursiveMutexStatic(). + * // The address of xMutexBuffer is passed into the function, and will hold + * // the mutexes data structures - so no dynamic memory allocation will be + * // attempted. + * xSemaphore = xSemaphoreCreateRecursiveMutexStatic( &xMutexBuffer ); + * + * // As no dynamic memory allocation was performed, xSemaphore cannot be NULL, + * // so there is no need to check it. + * } + * @endcode * \ingroup Semaphores */ #if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_RECURSIVE_MUTEXES == 1 ) ) @@ -986,9 +926,6 @@ typedef QueueHandle_t SemaphoreHandle_t; #endif /* configSUPPORT_STATIC_ALLOCATION */ /** - * semphr. h - *
SemaphoreHandle_t xSemaphoreCreateCounting( UBaseType_t uxMaxCount, UBaseType_t uxInitialCount )
- * * Creates a new counting semaphore instance, and returns a handle by which the * new counting semaphore can be referenced. * @@ -1039,26 +976,25 @@ typedef QueueHandle_t SemaphoreHandle_t; * created. * * Example usage: -
- SemaphoreHandle_t xSemaphore;
-
- void vATask( void * pvParameters )
- {
- SemaphoreHandle_t xSemaphore = NULL;
-
-    // Semaphore cannot be used before a call to xSemaphoreCreateCounting().
-    // The max value to which the semaphore can count should be 10, and the
-    // initial value assigned to the count should be 0.
-    xSemaphore = xSemaphoreCreateCounting( 10, 0 );
-
-    if( xSemaphore != NULL )
-    {
-        // The semaphore was created successfully.
-        // The semaphore can now be used.
-    }
- }
- 
- * \defgroup xSemaphoreCreateCounting xSemaphoreCreateCounting + * @code{c} + * SemaphoreHandle_t xSemaphore; + * + * void vATask( void * pvParameters ) + * { + * SemaphoreHandle_t xSemaphore = NULL; + * + * // Semaphore cannot be used before a call to xSemaphoreCreateCounting(). + * // The max value to which the semaphore can count should be 10, and the + * // initial value assigned to the count should be 0. + * xSemaphore = xSemaphoreCreateCounting( 10, 0 ); + * + * if( xSemaphore != NULL ) + * { + * // The semaphore was created successfully. + * // The semaphore can now be used. + * } + * } + * @endcode * \ingroup Semaphores */ #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) @@ -1066,9 +1002,6 @@ typedef QueueHandle_t SemaphoreHandle_t; #endif /** - * semphr. h - *
SemaphoreHandle_t xSemaphoreCreateCountingStatic( UBaseType_t uxMaxCount, UBaseType_t uxInitialCount, StaticSemaphore_t *pxSemaphoreBuffer )
- * * Creates a new counting semaphore instance, and returns a handle by which the * new counting semaphore can be referenced. * @@ -1123,27 +1056,26 @@ typedef QueueHandle_t SemaphoreHandle_t; * then NULL is returned. * * Example usage: -
- SemaphoreHandle_t xSemaphore;
- StaticSemaphore_t xSemaphoreBuffer;
-
- void vATask( void * pvParameters )
- {
- SemaphoreHandle_t xSemaphore = NULL;
-
-    // Counting semaphore cannot be used before they have been created.  Create
-    // a counting semaphore using xSemaphoreCreateCountingStatic().  The max
-    // value to which the semaphore can count is 10, and the initial value
-    // assigned to the count will be 0.  The address of xSemaphoreBuffer is
-    // passed in and will be used to hold the semaphore structure, so no dynamic
-    // memory allocation will be used.
-    xSemaphore = xSemaphoreCreateCounting( 10, 0, &xSemaphoreBuffer );
-
-    // No memory allocation was attempted so xSemaphore cannot be NULL, so there
-    // is no need to check its value.
- }
- 
- * \defgroup xSemaphoreCreateCountingStatic xSemaphoreCreateCountingStatic + * @code{c} + * SemaphoreHandle_t xSemaphore; + * StaticSemaphore_t xSemaphoreBuffer; + * + * void vATask( void * pvParameters ) + * { + * SemaphoreHandle_t xSemaphore = NULL; + * + * // Counting semaphore cannot be used before they have been created. Create + * // a counting semaphore using xSemaphoreCreateCountingStatic(). The max + * // value to which the semaphore can count is 10, and the initial value + * // assigned to the count will be 0. The address of xSemaphoreBuffer is + * // passed in and will be used to hold the semaphore structure, so no dynamic + * // memory allocation will be used. + * xSemaphore = xSemaphoreCreateCounting( 10, 0, &xSemaphoreBuffer ); + * + * // No memory allocation was attempted so xSemaphore cannot be NULL, so there + * // is no need to check its value. + * } + * @endcode * \ingroup Semaphores */ #if( configSUPPORT_STATIC_ALLOCATION == 1 ) @@ -1151,23 +1083,16 @@ typedef QueueHandle_t SemaphoreHandle_t; #endif /* configSUPPORT_STATIC_ALLOCATION */ /** - * semphr. h - *
void vSemaphoreDelete( SemaphoreHandle_t xSemaphore );
- * * Delete a semaphore. This function must be used with care. For example, * do not delete a mutex type semaphore if the mutex is held by a task. * * @param xSemaphore A handle to the semaphore to be deleted. * - * \defgroup vSemaphoreDelete vSemaphoreDelete * \ingroup Semaphores */ #define vSemaphoreDelete( xSemaphore ) vQueueDelete( ( QueueHandle_t ) ( xSemaphore ) ) /** - * semphr.h - *
TaskHandle_t xSemaphoreGetMutexHolder( SemaphoreHandle_t xMutex );
- * * If xMutex is indeed a mutex type semaphore, return the current mutex holder. * If xMutex is not a mutex type semaphore, or the mutex is available (not held * by a task), return NULL. @@ -1179,6 +1104,15 @@ typedef QueueHandle_t SemaphoreHandle_t; */ #define xSemaphoreGetMutexHolder( xSemaphore ) xQueueGetMutexHolder( ( xSemaphore ) ) +/** + * If the semaphore is a counting semaphore then uxSemaphoreGetCount() returns + * its current count value. If the semaphore is a binary semaphore then + * uxSemaphoreGetCount() returns 1 if the semaphore is available, and 0 if the + * semaphore is not available. + * + */ +#define uxSemaphoreGetCount( xSemaphore ) uxQueueMessagesWaiting( ( QueueHandle_t ) ( xSemaphore ) ) + #endif /* SEMAPHORE_H */ diff --git a/tools/sdk/include/freertos/freertos/task.h b/tools/sdk/include/freertos/freertos/task.h index 073267445f6915e18ecc9a6b43a185d4e6a06323..ab45f1c43e7a645ec482a60162ae92a837ebf68f 100644 --- a/tools/sdk/include/freertos/freertos/task.h +++ b/tools/sdk/include/freertos/freertos/task.h @@ -102,38 +102,38 @@ extern "C" { * returns (via a pointer parameter) an TaskHandle_t variable that can then * be used as a parameter to vTaskDelete to delete the task. * - * \defgroup TaskHandle_t TaskHandle_t * \ingroup Tasks */ typedef void * TaskHandle_t; -/* +/** * Defines the prototype to which the application task hook function must * conform. */ typedef BaseType_t (*TaskHookFunction_t)( void * ); -/* Task states returned by eTaskGetState. */ +/** Task states returned by eTaskGetState. */ typedef enum { - eRunning = 0, /* A task is querying the state of itself, so must be running. */ - eReady, /* The task being queried is in a read or pending ready list. */ - eBlocked, /* The task being queried is in the Blocked state. */ - eSuspended, /* The task being queried is in the Suspended state, or is in the Blocked state with an infinite time out. */ - eDeleted /* The task being queried has been deleted, but its TCB has not yet been freed. */ + eRunning = 0, /*!< A task is querying the state of itself, so must be running. */ + eReady, /*!< The task being queried is in a read or pending ready list. */ + eBlocked, /*!< The task being queried is in the Blocked state. */ + eSuspended, /*!< The task being queried is in the Suspended state, or is in the Blocked state with an infinite time out. */ + eDeleted /*!< The task being queried has been deleted, but its TCB has not yet been freed. */ } eTaskState; -/* Actions that can be performed when vTaskNotify() is called. */ +/** Actions that can be performed when vTaskNotify() is called. */ typedef enum { - eNoAction = 0, /* Notify the task without updating its notify value. */ - eSetBits, /* Set bits in the task's notification value. */ - eIncrement, /* Increment the task's notification value. */ - eSetValueWithOverwrite, /* Set the task's notification value to a specific value even if the previous value has not yet been read by the task. */ - eSetValueWithoutOverwrite /* Set the task's notification value if the previous value has been read by the task. */ + eNoAction = 0, /*!< Notify the task without updating its notify value. */ + eSetBits, /*!< Set bits in the task's notification value. */ + eIncrement, /*!< Increment the task's notification value. */ + eSetValueWithOverwrite, /*!< Set the task's notification value to a specific value even if the previous value has not yet been read by the task. */ + eSetValueWithoutOverwrite /*!< Set the task's notification value if the previous value has been read by the task. */ } eNotifyAction; -/* +/** @cond */ +/** * Used internally only. */ typedef struct xTIME_OUT @@ -142,7 +142,7 @@ typedef struct xTIME_OUT TickType_t xTimeOnEntering; } TimeOut_t; -/* +/** * Defines the memory ranges allocated to the task when an MPU is used. */ typedef struct xMEMORY_REGION @@ -152,7 +152,7 @@ typedef struct xMEMORY_REGION uint32_t ulParameters; } MemoryRegion_t; -/* +/** * Parameters required to create an MPU protected task. */ typedef struct xTASK_PARAMETERS @@ -165,40 +165,44 @@ typedef struct xTASK_PARAMETERS StackType_t *puxStackBuffer; MemoryRegion_t xRegions[ portNUM_CONFIGURABLE_REGIONS ]; } TaskParameters_t; +/** @endcond */ -/* Used with the uxTaskGetSystemState() function to return the state of each task -in the system. */ +/** + * Used with the uxTaskGetSystemState() function to return the state of each task in the system. +*/ typedef struct xTASK_STATUS { - TaskHandle_t xHandle; /* The handle of the task to which the rest of the information in the structure relates. */ - const char *pcTaskName; /* A pointer to the task's name. This value will be invalid if the task was deleted since the structure was populated! */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ - UBaseType_t xTaskNumber; /* A number unique to the task. */ - eTaskState eCurrentState; /* The state in which the task existed when the structure was populated. */ - UBaseType_t uxCurrentPriority; /* The priority at which the task was running (may be inherited) when the structure was populated. */ - UBaseType_t uxBasePriority; /* The priority to which the task will return if the task's current priority has been inherited to avoid unbounded priority inversion when obtaining a mutex. Only valid if configUSE_MUTEXES is defined as 1 in FreeRTOSConfig.h. */ - uint32_t ulRunTimeCounter; /* The total run time allocated to the task so far, as defined by the run time stats clock. See http://www.freertos.org/rtos-run-time-stats.html. Only valid when configGENERATE_RUN_TIME_STATS is defined as 1 in FreeRTOSConfig.h. */ - StackType_t *pxStackBase; /* Points to the lowest address of the task's stack area. */ - uint32_t usStackHighWaterMark; /* The minimum amount of stack space that has remained for the task since the task was created. The closer this value is to zero the closer the task has come to overflowing its stack. */ + TaskHandle_t xHandle; /*!< The handle of the task to which the rest of the information in the structure relates. */ + const char *pcTaskName; /*!< A pointer to the task's name. This value will be invalid if the task was deleted since the structure was populated! */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + UBaseType_t xTaskNumber; /*!< A number unique to the task. */ + eTaskState eCurrentState; /*!< The state in which the task existed when the structure was populated. */ + UBaseType_t uxCurrentPriority; /*!< The priority at which the task was running (may be inherited) when the structure was populated. */ + UBaseType_t uxBasePriority; /*!< The priority to which the task will return if the task's current priority has been inherited to avoid unbounded priority inversion when obtaining a mutex. Only valid if configUSE_MUTEXES is defined as 1 in FreeRTOSConfig.h. */ + uint32_t ulRunTimeCounter; /*!< The total run time allocated to the task so far, as defined by the run time stats clock. See http://www.freertos.org/rtos-run-time-stats.html. Only valid when configGENERATE_RUN_TIME_STATS is defined as 1 in FreeRTOSConfig.h. */ + StackType_t *pxStackBase; /*!< Points to the lowest address of the task's stack area. */ + uint32_t usStackHighWaterMark; /*!< The minimum amount of stack space that has remained for the task since the task was created. The closer this value is to zero the closer the task has come to overflowing its stack. */ } TaskStatus_t; -/* +/** * Used with the uxTaskGetSnapshotAll() function to save memory snapshot of each task in the system. * We need this struct because TCB_t is defined (hidden) in tasks.c. */ typedef struct xTASK_SNAPSHOT { - void *pxTCB; /* Address of task control block. */ - StackType_t *pxTopOfStack; /* Points to the location of the last item placed on the tasks stack. */ - StackType_t *pxEndOfStack; /* Points to the end of the stack. pxTopOfStack < pxEndOfStack, stack grows hi2lo - pxTopOfStack > pxEndOfStack, stack grows lo2hi*/ + void *pxTCB; /*!< Address of task control block. */ + StackType_t *pxTopOfStack; /*!< Points to the location of the last item placed on the tasks stack. */ + StackType_t *pxEndOfStack; /*!< Points to the end of the stack. pxTopOfStack < pxEndOfStack, stack grows hi2lo + pxTopOfStack > pxEndOfStack, stack grows lo2hi*/ } TaskSnapshot_t; -/* Possible return values for eTaskConfirmSleepModeStatus(). */ +/** + * Possible return values for eTaskConfirmSleepModeStatus(). + */ typedef enum { - eAbortSleep = 0, /* A task has been made ready or a context switch pended since portSUPPORESS_TICKS_AND_SLEEP() was called - abort entering a sleep mode. */ - eStandardSleep, /* Enter a sleep mode that will not last any longer than the expected idle time. */ - eNoTasksWaitingTimeout /* No tasks are waiting for a timeout so it is safe to enter a sleep mode that can only be exited by an external interrupt. */ + eAbortSleep = 0, /*!< A task has been made ready or a context switch pended since portSUPPORESS_TICKS_AND_SLEEP() was called - abort entering a sleep mode. */ + eStandardSleep, /*!< Enter a sleep mode that will not last any longer than the expected idle time. */ + eNoTasksWaitingTimeout /*!< No tasks are waiting for a timeout so it is safe to enter a sleep mode that can only be exited by an external interrupt. */ } eSleepModeStatus; @@ -214,7 +218,6 @@ typedef enum * * Macro for forcing a context switch. * - * \defgroup taskYIELD taskYIELD * \ingroup SchedulerControl */ #define taskYIELD() portYIELD() @@ -225,10 +228,9 @@ typedef enum * Macro to mark the start of a critical code region. Preemptive context * switches cannot occur when in a critical region. * - * NOTE: This may alter the stack (depending on the portable implementation) + * @note This may alter the stack (depending on the portable implementation) * so must be used with care! * - * \defgroup taskENTER_CRITICAL taskENTER_CRITICAL * \ingroup SchedulerControl */ #define taskENTER_CRITICAL(mux) portENTER_CRITICAL(mux) @@ -240,10 +242,9 @@ typedef enum * Macro to mark the end of a critical code region. Preemptive context * switches cannot occur when in a critical region. * - * NOTE: This may alter the stack (depending on the portable implementation) + * @note This may alter the stack (depending on the portable implementation) * so must be used with care! * - * \defgroup taskEXIT_CRITICAL taskEXIT_CRITICAL * \ingroup SchedulerControl */ #define taskEXIT_CRITICAL(mux) portEXIT_CRITICAL(mux) @@ -254,7 +255,6 @@ typedef enum * * Macro to disable all maskable interrupts. * - * \defgroup taskDISABLE_INTERRUPTS taskDISABLE_INTERRUPTS * \ingroup SchedulerControl */ #define taskDISABLE_INTERRUPTS() portDISABLE_INTERRUPTS() @@ -264,7 +264,6 @@ typedef enum * * Macro to enable microcontroller interrupts. * - * \defgroup taskENABLE_INTERRUPTS taskENABLE_INTERRUPTS * \ingroup SchedulerControl */ #define taskENABLE_INTERRUPTS() portENABLE_INTERRUPTS() @@ -282,17 +281,58 @@ is used in assert() statements. */ *----------------------------------------------------------*/ /** - * task. h - *
- BaseType_t xTaskCreate(
-							  TaskFunction_t pvTaskCode,
-							  const char * const pcName,
-							  uint32_t usStackDepth,
-							  void *pvParameters,
-							  UBaseType_t uxPriority,
-							  TaskHandle_t *pvCreatedTask
-						  );
+ * Create a new task with a specified affinity. + * + * This function is similar to xTaskCreate, but allows setting task affinity + * in SMP system. + * + * @param pvTaskCode Pointer to the task entry function. Tasks + * must be implemented to never return (i.e. continuous loop). + * + * @param pcName A descriptive name for the task. This is mainly used to + * facilitate debugging. Max length defined by configMAX_TASK_NAME_LEN - default + * is 16. + * + * @param usStackDepth The size of the task stack specified as the number of + * variables the stack can hold - not the number of bytes. For example, if + * the stack is 16 bits wide and usStackDepth is defined as 100, 200 bytes + * will be allocated for stack storage. + * + * @param pvParameters Pointer that will be used as the parameter for the task + * being created. + * + * @param uxPriority The priority at which the task should run. Systems that + * include MPU support can optionally create tasks in a privileged (system) + * mode by setting bit portPRIVILEGE_BIT of the priority parameter. For + * example, to create a privileged task at priority 2 the uxPriority parameter + * should be set to ( 2 | portPRIVILEGE_BIT ). * + * @param pvCreatedTask Used to pass back a handle by which the created task + * can be referenced. + * + * @param xCoreID If the value is tskNO_AFFINITY, the created task is not + * pinned to any CPU, and the scheduler can run it on any core available. + * Other values indicate the index number of the CPU which the task should + * be pinned to. Specifying values larger than (portNUM_PROCESSORS - 1) will + * cause the function to fail. + * + * @return pdPASS if the task was successfully created and added to a ready + * list, otherwise an error code defined in the file projdefs.h + * + * \ingroup Tasks + */ +#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + BaseType_t xTaskCreatePinnedToCore( TaskFunction_t pvTaskCode, + const char * const pcName, + const uint32_t usStackDepth, + void * const pvParameters, + UBaseType_t uxPriority, + TaskHandle_t * const pvCreatedTask, + const BaseType_t xCoreID); + +#endif + +/** * Create a new task and add it to the list of tasks that are ready to run. * * Internally, within the FreeRTOS implementation, tasks use two blocks of @@ -341,64 +381,113 @@ is used in assert() statements. */ * list, otherwise an error code defined in the file projdefs.h * * Example usage: -
- // Task to be created.
- void vTaskCode( void * pvParameters )
- {
-	 for( ;; )
-	 {
-		 // Task code goes here.
-	 }
- }
-
- // Function that creates a task.
- void vOtherFunction( void )
- {
- static uint8_t ucParameterToPass;
- TaskHandle_t xHandle = NULL;
-
-	 // Create the task, storing the handle.  Note that the passed parameter ucParameterToPass
-	 // must exist for the lifetime of the task, so in this case is declared static.  If it was just an
-	 // an automatic stack variable it might no longer exist, or at least have been corrupted, by the time
-	 // the new task attempts to access it.
-	 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, &ucParameterToPass, tskIDLE_PRIORITY, &xHandle );
-     configASSERT( xHandle );
-
-	 // Use the handle to delete the task.
-     if( xHandle != NULL )
-     {
-	     vTaskDelete( xHandle );
-     }
- }
-   
- * \defgroup xTaskCreate xTaskCreate + * @code{c} + * // Task to be created. + * void vTaskCode( void * pvParameters ) + * { + * for( ;; ) + * { + * // Task code goes here. + * } + * } + * + * // Function that creates a task. + * void vOtherFunction( void ) + * { + * static uint8_t ucParameterToPass; + * TaskHandle_t xHandle = NULL; + * + * // Create the task, storing the handle. Note that the passed parameter ucParameterToPass + * // must exist for the lifetime of the task, so in this case is declared static. If it was just an + * // an automatic stack variable it might no longer exist, or at least have been corrupted, by the time + * // the new task attempts to access it. + * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, &ucParameterToPass, tskIDLE_PRIORITY, &xHandle ); + * configASSERT( xHandle ); + * + * // Use the handle to delete the task. + * if( xHandle != NULL ) + * { + * vTaskDelete( xHandle ); + * } + * } + * @endcode * \ingroup Tasks */ + #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - BaseType_t xTaskCreatePinnedToCore( TaskFunction_t pxTaskCode, - const char * const pcName, - const uint32_t usStackDepth, - void * const pvParameters, - UBaseType_t uxPriority, - TaskHandle_t * const pxCreatedTask, - const BaseType_t xCoreID); - -#define xTaskCreate( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask ) xTaskCreatePinnedToCore( ( pvTaskCode ), ( pcName ), ( usStackDepth ), ( pvParameters ), ( uxPriority ), ( pxCreatedTask ), tskNO_AFFINITY ) + + static inline IRAM_ATTR BaseType_t xTaskCreate( + TaskFunction_t pvTaskCode, + const char * const pcName, + const uint32_t usStackDepth, + void * const pvParameters, + UBaseType_t uxPriority, + TaskHandle_t * const pvCreatedTask) + { + return xTaskCreatePinnedToCore( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pvCreatedTask, tskNO_AFFINITY ); + } + #endif -/** - * task. h - *
- TaskHandle_t xTaskCreateStatic( TaskFunction_t pvTaskCode,
-								 const char * const pcName,
-								 uint32_t ulStackDepth,
-								 void *pvParameters,
-								 UBaseType_t uxPriority,
-								 StackType_t *pxStackBuffer,
-								 StaticTask_t *pxTaskBuffer,
-                                 const BaseType_t xCoreID );
+ + +/** + * Create a new task with a specified affinity. + * + * This function is similar to xTaskCreateStatic, but allows specifying + * task affinity in an SMP system. + * + * @param pvTaskCode Pointer to the task entry function. Tasks + * must be implemented to never return (i.e. continuous loop). + * + * @param pcName A descriptive name for the task. This is mainly used to + * facilitate debugging. The maximum length of the string is defined by + * configMAX_TASK_NAME_LEN in FreeRTOSConfig.h. + * + * @param ulStackDepth The size of the task stack specified as the number of + * variables the stack can hold - not the number of bytes. For example, if + * the stack is 32-bits wide and ulStackDepth is defined as 100 then 400 bytes + * will be allocated for stack storage. + * + * @param pvParameters Pointer that will be used as the parameter for the task + * being created. + * + * @param uxPriority The priority at which the task will run. + * + * @param pxStackBuffer Must point to a StackType_t array that has at least + * ulStackDepth indexes - the array will then be used as the task's stack, + * removing the need for the stack to be allocated dynamically. * + * @param pxTaskBuffer Must point to a variable of type StaticTask_t, which will + * then be used to hold the task's data structures, removing the need for the + * memory to be allocated dynamically. + * + * @param xCoreID If the value is tskNO_AFFINITY, the created task is not + * pinned to any CPU, and the scheduler can run it on any core available. + * Other values indicate the index number of the CPU which the task should + * be pinned to. Specifying values larger than (portNUM_PROCESSORS - 1) will + * cause the function to fail. + * + * @return If neither pxStackBuffer or pxTaskBuffer are NULL, then the task will + * be created and pdPASS is returned. If either pxStackBuffer or pxTaskBuffer + * are NULL then the task will not be created and + * errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY is returned. + * + * \ingroup Tasks + */ +#if( configSUPPORT_STATIC_ALLOCATION == 1 ) + TaskHandle_t xTaskCreateStaticPinnedToCore( TaskFunction_t pvTaskCode, + const char * const pcName, + const uint32_t ulStackDepth, + void * const pvParameters, + UBaseType_t uxPriority, + StackType_t * const pxStackBuffer, + StaticTask_t * const pxTaskBuffer, + const BaseType_t xCoreID ); +#endif /* configSUPPORT_STATIC_ALLOCATION */ + +/** * Create a new task and add it to the list of tasks that are ready to run. * * Internally, within the FreeRTOS implementation, tasks use two blocks of @@ -442,77 +531,75 @@ is used in assert() statements. */ * errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY is returned. * * Example usage: -
-
-    // Dimensions the buffer that the task being created will use as its stack.
-    // NOTE:  This is the number of words the stack will hold, not the number of
-    // bytes.  For example, if each stack item is 32-bits, and this is set to 100,
-    // then 400 bytes (100 * 32-bits) will be allocated.
-    #define STACK_SIZE 200
-
-    // Structure that will hold the TCB of the task being created.
-    StaticTask_t xTaskBuffer;
-
-    // Buffer that the task being created will use as its stack.  Note this is
-    // an array of StackType_t variables.  The size of StackType_t is dependent on
-    // the RTOS port.
-    StackType_t xStack[ STACK_SIZE ];
-
-    // Function that implements the task being created.
-    void vTaskCode( void * pvParameters )
-    {
-        // The parameter value is expected to be 1 as 1 is passed in the
-        // pvParameters value in the call to xTaskCreateStatic().
-        configASSERT( ( uint32_t ) pvParameters == 1UL );
-
-        for( ;; )
-        {
-            // Task code goes here.
-        }
-    }
-
-    // Function that creates a task.
-    void vOtherFunction( void )
-    {
-        TaskHandle_t xHandle = NULL;
-
-        // Create the task without using any dynamic memory allocation.
-        xHandle = xTaskCreateStatic(
-                      vTaskCode,       // Function that implements the task.
-                      "NAME",          // Text name for the task.
-                      STACK_SIZE,      // Stack size in words, not bytes.
-                      ( void * ) 1,    // Parameter passed into the task.
-                      tskIDLE_PRIORITY,// Priority at which the task is created.
-                      xStack,          // Array to use as the task's stack.
-                      &xTaskBuffer );  // Variable to hold the task's data structure.
-
-        // puxStackBuffer and pxTaskBuffer were not NULL, so the task will have
-        // been created, and xHandle will be the task's handle.  Use the handle
-        // to suspend the task.
-        vTaskSuspend( xHandle );
-    }
-   
- * \defgroup xTaskCreateStatic xTaskCreateStatic + * @code{c} + * + * // Dimensions the buffer that the task being created will use as its stack. + * // NOTE: This is the number of words the stack will hold, not the number of + * // bytes. For example, if each stack item is 32-bits, and this is set to 100, + * // then 400 bytes (100 * 32-bits) will be allocated. + * #define STACK_SIZE 200 + * + * // Structure that will hold the TCB of the task being created. + * StaticTask_t xTaskBuffer; + * + * // Buffer that the task being created will use as its stack. Note this is + * // an array of StackType_t variables. The size of StackType_t is dependent on + * // the RTOS port. + * StackType_t xStack[ STACK_SIZE ]; + * + * // Function that implements the task being created. + * void vTaskCode( void * pvParameters ) + * { + * // The parameter value is expected to be 1 as 1 is passed in the + * // pvParameters value in the call to xTaskCreateStatic(). + * configASSERT( ( uint32_t ) pvParameters == 1UL ); + * + * for( ;; ) + * { + * // Task code goes here. + * } + * } + * + * // Function that creates a task. + * void vOtherFunction( void ) + * { + * TaskHandle_t xHandle = NULL; + * + * // Create the task without using any dynamic memory allocation. + * xHandle = xTaskCreateStatic( + * vTaskCode, // Function that implements the task. + * "NAME", // Text name for the task. + * STACK_SIZE, // Stack size in words, not bytes. + * ( void * ) 1, // Parameter passed into the task. + * tskIDLE_PRIORITY,// Priority at which the task is created. + * xStack, // Array to use as the task's stack. + * &xTaskBuffer ); // Variable to hold the task's data structure. + * + * // puxStackBuffer and pxTaskBuffer were not NULL, so the task will have + * // been created, and xHandle will be the task's handle. Use the handle + * // to suspend the task. + * vTaskSuspend( xHandle ); + * } + * @endcode * \ingroup Tasks */ + #if( configSUPPORT_STATIC_ALLOCATION == 1 ) - TaskHandle_t xTaskCreateStaticPinnedToCore( TaskFunction_t pxTaskCode, - const char * const pcName, - const uint32_t ulStackDepth, - void * const pvParameters, - UBaseType_t uxPriority, - StackType_t * const puxStackBuffer, - StaticTask_t * const pxTaskBuffer, - const BaseType_t xCoreID ); - -#define xTaskCreateStatic( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxStackBuffer, pxTaskBuffer ) xTaskCreateStaticPinnedToCore( ( pvTaskCode ), ( pcName ), ( usStackDepth ), ( pvParameters ), ( uxPriority ), ( pxStackBuffer ), ( pxTaskBuffer ), tskNO_AFFINITY ) + static inline IRAM_ATTR TaskHandle_t xTaskCreateStatic( + TaskFunction_t pvTaskCode, + const char * const pcName, + const uint32_t ulStackDepth, + void * const pvParameters, + UBaseType_t uxPriority, + StackType_t * const pxStackBuffer, + StaticTask_t * const pxTaskBuffer) + { + return xTaskCreateStaticPinnedToCore( pvTaskCode, pcName, ulStackDepth, pvParameters, uxPriority, pxStackBuffer, pxTaskBuffer, tskNO_AFFINITY ); + } #endif /* configSUPPORT_STATIC_ALLOCATION */ +/** @cond */ /** - * task. h - *
- BaseType_t xTaskCreateRestricted( TaskParameters_t *pxTaskDefinition, TaskHandle_t *pxCreatedTask );
- * * xTaskCreateRestricted() should only be used in systems that include an MPU * implementation. * @@ -532,58 +619,54 @@ is used in assert() statements. */ * list, otherwise an error code defined in the file projdefs.h * * Example usage: -
-// Create an TaskParameters_t structure that defines the task to be created.
-static const TaskParameters_t xCheckTaskParameters =
-{
-	vATask,		// pvTaskCode - the function that implements the task.
-	"ATask",	// pcName - just a text name for the task to assist debugging.
-	100,		// usStackDepth	- the stack size DEFINED IN WORDS.
-	NULL,		// pvParameters - passed into the task function as the function parameters.
-	( 1UL | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state.
-	cStackBuffer,// puxStackBuffer - the buffer to be used as the task stack.
-
-	// xRegions - Allocate up to three separate memory regions for access by
-	// the task, with appropriate access permissions.  Different processors have
-	// different memory alignment requirements - refer to the FreeRTOS documentation
-	// for full information.
-	{
-		// Base address					Length	Parameters
-        { cReadWriteArray,				32,		portMPU_REGION_READ_WRITE },
-        { cReadOnlyArray,				32,		portMPU_REGION_READ_ONLY },
-        { cPrivilegedOnlyAccessArray,	128,	portMPU_REGION_PRIVILEGED_READ_WRITE }
-	}
-};
-
-int main( void )
-{
-TaskHandle_t xHandle;
-
-	// Create a task from the const structure defined above.  The task handle
-	// is requested (the second parameter is not NULL) but in this case just for
-	// demonstration purposes as its not actually used.
-	xTaskCreateRestricted( &xRegTest1Parameters, &xHandle );
-
-	// Start the scheduler.
-	vTaskStartScheduler();
-
-	// Will only get here if there was insufficient memory to create the idle
-	// and/or timer task.
-	for( ;; );
-}
-   
- * \defgroup xTaskCreateRestricted xTaskCreateRestricted + * @code{c} + * // Create an TaskParameters_t structure that defines the task to be created. + * static const TaskParameters_t xCheckTaskParameters = + * { + * vATask, // pvTaskCode - the function that implements the task. + * "ATask", // pcName - just a text name for the task to assist debugging. + * 100, // usStackDepth - the stack size DEFINED IN WORDS. + * NULL, // pvParameters - passed into the task function as the function parameters. + * ( 1UL | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state. + * cStackBuffer,// puxStackBuffer - the buffer to be used as the task stack. + * + * // xRegions - Allocate up to three separate memory regions for access by + * // the task, with appropriate access permissions. Different processors have + * // different memory alignment requirements - refer to the FreeRTOS documentation + * // for full information. + * { + * // Base address Length Parameters + * { cReadWriteArray, 32, portMPU_REGION_READ_WRITE }, + * { cReadOnlyArray, 32, portMPU_REGION_READ_ONLY }, + * { cPrivilegedOnlyAccessArray, 128, portMPU_REGION_PRIVILEGED_READ_WRITE } + * } + * }; + * + * int main( void ) + * { + * TaskHandle_t xHandle; + * + * // Create a task from the const structure defined above. The task handle + * // is requested (the second parameter is not NULL) but in this case just for + * // demonstration purposes as its not actually used. + * xTaskCreateRestricted( &xRegTest1Parameters, &xHandle ); + * + * // Start the scheduler. + * vTaskStartScheduler(); + * + * // Will only get here if there was insufficient memory to create the idle + * // and/or timer task. + * for( ;; ); + * } + * @endcode * \ingroup Tasks */ #if( portUSING_MPU_WRAPPERS == 1 ) BaseType_t xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ) PRIVILEGED_FUNCTION; #endif + /** - * task. h - *
- void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions );
- * * Memory regions are assigned to a restricted task when the task is created by * a call to xTaskCreateRestricted(). These regions can be redefined using * vTaskAllocateMPURegions(). @@ -594,50 +677,51 @@ TaskHandle_t xHandle; * new memory region definitions. * * Example usage: -
-// Define an array of MemoryRegion_t structures that configures an MPU region
-// allowing read/write access for 1024 bytes starting at the beginning of the
-// ucOneKByte array.  The other two of the maximum 3 definable regions are
-// unused so set to zero.
-static const MemoryRegion_t xAltRegions[ portNUM_CONFIGURABLE_REGIONS ] =
-{
-	// Base address		Length		Parameters
-	{ ucOneKByte,		1024,		portMPU_REGION_READ_WRITE },
-	{ 0,				0,			0 },
-	{ 0,				0,			0 }
-};
-
-void vATask( void *pvParameters )
-{
-	// This task was created such that it has access to certain regions of
-	// memory as defined by the MPU configuration.  At some point it is
-	// desired that these MPU regions are replaced with that defined in the
-	// xAltRegions const struct above.  Use a call to vTaskAllocateMPURegions()
-	// for this purpose.  NULL is used as the task handle to indicate that this
-	// function should modify the MPU regions of the calling task.
-	vTaskAllocateMPURegions( NULL, xAltRegions );
-
-	// Now the task can continue its function, but from this point on can only
-	// access its stack and the ucOneKByte array (unless any other statically
-	// defined or shared regions have been declared elsewhere).
-}
-   
- * \defgroup xTaskCreateRestricted xTaskCreateRestricted + * + * @code{c} + * // Define an array of MemoryRegion_t structures that configures an MPU region + * // allowing read/write access for 1024 bytes starting at the beginning of the + * // ucOneKByte array. The other two of the maximum 3 definable regions are + * // unused so set to zero. + * static const MemoryRegion_t xAltRegions[ portNUM_CONFIGURABLE_REGIONS ] = + * { + * // Base address Length Parameters + * { ucOneKByte, 1024, portMPU_REGION_READ_WRITE }, + * { 0, 0, 0 }, + * { 0, 0, 0 } + * }; + * + * void vATask( void *pvParameters ) + * { + * // This task was created such that it has access to certain regions of + * // memory as defined by the MPU configuration. At some point it is + * // desired that these MPU regions are replaced with that defined in the + * // xAltRegions const struct above. Use a call to vTaskAllocateMPURegions() + * // for this purpose. NULL is used as the task handle to indicate that this + * // function should modify the MPU regions of the calling task. + * vTaskAllocateMPURegions( NULL, xAltRegions ); + * + * // Now the task can continue its function, but from this point on can only + * // access its stack and the ucOneKByte array (unless any other statically + * // defined or shared regions have been declared elsewhere). + * } + * @endcode * \ingroup Tasks */ void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions ) PRIVILEGED_FUNCTION; +/** @endcond */ + /** - * task. h - *
void vTaskDelete( TaskHandle_t xTask );
+ * Remove a task from the RTOS real time kernel's management. + * + * The task being deleted will be removed from all ready, blocked, suspended + * and event lists. * * INCLUDE_vTaskDelete must be defined as 1 for this function to be available. * See the configuration section for more information. * - * Remove a task from the RTOS real time kernel's management. The task being - * deleted will be removed from all ready, blocked, suspended and event lists. - * - * NOTE: The idle task is responsible for freeing the kernel allocated + * @note The idle task is responsible for freeing the kernel allocated * memory from tasks that have been deleted. It is therefore important that * the idle task is not starved of microcontroller processing time if your * application makes any calls to vTaskDelete (). Memory allocated by the @@ -647,23 +731,22 @@ void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const p * See the demo application file death.c for sample code that utilises * vTaskDelete (). * - * @param xTask The handle of the task to be deleted. Passing NULL will + * @param xTaskToDelete The handle of the task to be deleted. Passing NULL will * cause the calling task to be deleted. * * Example usage: -
- void vOtherFunction( void )
- {
- TaskHandle_t xHandle;
-
-	 // Create the task, storing the handle.
-	 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
-
-	 // Use the handle to delete the task.
-	 vTaskDelete( xHandle );
- }
-   
- * \defgroup vTaskDelete vTaskDelete + * @code{c} + * void vOtherFunction( void ) + * { + * TaskHandle_t xHandle; + * + * // Create the task, storing the handle. + * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle ); + * + * // Use the handle to delete the task. + * vTaskDelete( xHandle ); + * } + * @endcode * \ingroup Tasks */ void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION; @@ -673,18 +756,15 @@ void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION; *----------------------------------------------------------*/ /** - * task. h - *
void vTaskDelay( const TickType_t xTicksToDelay );
+ * Delay a task for a given number of ticks. * - * Delay a task for a given number of ticks. The actual time that the - * task remains blocked depends on the tick rate. The constant - * portTICK_PERIOD_MS can be used to calculate real time from the tick - * rate - with the resolution of one tick period. + * The actual time that the task remains blocked depends on the tick rate. + * The constant portTICK_PERIOD_MS can be used to calculate real time from + * the tick rate - with the resolution of one tick period. * * INCLUDE_vTaskDelay must be defined as 1 for this function to be available. * See the configuration section for more information. * - * * vTaskDelay() specifies a time at which the task wishes to unblock relative to * the time at which vTaskDelay() is called. For example, specifying a block * period of 100 ticks will cause the task to unblock 100 ticks after @@ -701,34 +781,31 @@ void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION; * the calling task should block. * * Example usage: - - void vTaskFunction( void * pvParameters ) - { - // Block for 500ms. - const TickType_t xDelay = 500 / portTICK_PERIOD_MS; - - for( ;; ) - { - // Simply toggle the LED every 500ms, blocking between each toggle. - vToggleLED(); - vTaskDelay( xDelay ); - } - } - - * \defgroup vTaskDelay vTaskDelay + * @code{c} + * void vTaskFunction( void * pvParameters ) + * { + * // Block for 500ms. + * const TickType_t xDelay = 500 / portTICK_PERIOD_MS; + * + * for( ;; ) + * { + * // Simply toggle the LED every 500ms, blocking between each toggle. + * vToggleLED(); + * vTaskDelay( xDelay ); + * } + * } + * @endcode * \ingroup TaskCtrl */ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION; /** - * task. h - *
void vTaskDelayUntil( TickType_t *pxPreviousWakeTime, const TickType_t xTimeIncrement );
+ * Delay a task until a specified time. * * INCLUDE_vTaskDelayUntil must be defined as 1 for this function to be available. * See the configuration section for more information. * - * Delay a task until a specified time. This function can be used by periodic - * tasks to ensure a constant execution frequency. + * This function can be used by periodic tasks to ensure a constant execution frequency. * * This function differs from vTaskDelay () in one important aspect: vTaskDelay () will * cause a task to block for the specified number of ticks from the time vTaskDelay () is @@ -756,94 +833,90 @@ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION; * a fixed interface period. * * Example usage: -
- // Perform an action every 10 ticks.
- void vTaskFunction( void * pvParameters )
- {
- TickType_t xLastWakeTime;
- const TickType_t xFrequency = 10;
-
-	 // Initialise the xLastWakeTime variable with the current time.
-	 xLastWakeTime = xTaskGetTickCount ();
-	 for( ;; )
-	 {
-		 // Wait for the next cycle.
-		 vTaskDelayUntil( &xLastWakeTime, xFrequency );
-
-		 // Perform action here.
-	 }
- }
-   
- * \defgroup vTaskDelayUntil vTaskDelayUntil + * @code{c} + * // Perform an action every 10 ticks. + * void vTaskFunction( void * pvParameters ) + * { + * TickType_t xLastWakeTime; + * const TickType_t xFrequency = 10; + * + * // Initialise the xLastWakeTime variable with the current time. + * xLastWakeTime = xTaskGetTickCount (); + * for( ;; ) + * { + * // Wait for the next cycle. + * vTaskDelayUntil( &xLastWakeTime, xFrequency ); + * + * // Perform action here. + * } + * } + * @endcode * \ingroup TaskCtrl */ void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION; /** - * task. h - *
UBaseType_t uxTaskPriorityGet( TaskHandle_t xTask );
+ * Obtain the priority of any task. * * INCLUDE_uxTaskPriorityGet must be defined as 1 for this function to be available. * See the configuration section for more information. * - * Obtain the priority of any task. - * * @param xTask Handle of the task to be queried. Passing a NULL * handle results in the priority of the calling task being returned. * * @return The priority of xTask. * * Example usage: -
- void vAFunction( void )
- {
- TaskHandle_t xHandle;
-
-	 // Create a task, storing the handle.
-	 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
-
-	 // ...
-
-	 // Use the handle to obtain the priority of the created task.
-	 // It was created with tskIDLE_PRIORITY, but may have changed
-	 // it itself.
-	 if( uxTaskPriorityGet( xHandle ) != tskIDLE_PRIORITY )
-	 {
-		 // The task has changed it's priority.
-	 }
-
-	 // ...
-
-	 // Is our priority higher than the created task?
-	 if( uxTaskPriorityGet( xHandle ) < uxTaskPriorityGet( NULL ) )
-	 {
-		 // Our priority (obtained using NULL handle) is higher.
-	 }
- }
-   
- * \defgroup uxTaskPriorityGet uxTaskPriorityGet + * @code{c} + * void vAFunction( void ) + * { + * TaskHandle_t xHandle; + * + * // Create a task, storing the handle. + * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle ); + * + * // ... + * + * // Use the handle to obtain the priority of the created task. + * // It was created with tskIDLE_PRIORITY, but may have changed + * // it itself. + * if( uxTaskPriorityGet( xHandle ) != tskIDLE_PRIORITY ) + * { + * // The task has changed it's priority. + * } + * + * // ... + * + * // Is our priority higher than the created task? + * if( uxTaskPriorityGet( xHandle ) < uxTaskPriorityGet( NULL ) ) + * { + * // Our priority (obtained using NULL handle) is higher. + * } + * } + * @endcode * \ingroup TaskCtrl */ UBaseType_t uxTaskPriorityGet( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; /** - * task. h - *
UBaseType_t uxTaskPriorityGetFromISR( TaskHandle_t xTask );
- * * A version of uxTaskPriorityGet() that can be used from an ISR. + * + * @param xTask Handle of the task to be queried. Passing a NULL + * handle results in the priority of the calling task being returned. + * + * @return The priority of xTask. + * */ UBaseType_t uxTaskPriorityGetFromISR( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; /** - * task. h - *
eTaskState eTaskGetState( TaskHandle_t xTask );
+ * Obtain the state of any task. + * + * States are encoded by the eTaskState enumerated type. * * INCLUDE_eTaskGetState must be defined as 1 for this function to be available. * See the configuration section for more information. * - * Obtain the state of any task. States are encoded by the eTaskState - * enumerated type. - * * @param xTask Handle of the task to be queried. * * @return The state of xTask at the time the function was called. Note the @@ -853,14 +926,11 @@ UBaseType_t uxTaskPriorityGetFromISR( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; eTaskState eTaskGetState( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; /** - * task. h - *
void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority );
+ * Set the priority of any task. * * INCLUDE_vTaskPrioritySet must be defined as 1 for this function to be available. * See the configuration section for more information. * - * Set the priority of any task. - * * A context switch will occur before the function returns if the priority * being set is higher than the currently executing task. * @@ -870,39 +940,37 @@ eTaskState eTaskGetState( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; * @param uxNewPriority The priority to which the task will be set. * * Example usage: -
- void vAFunction( void )
- {
- TaskHandle_t xHandle;
-
-	 // Create a task, storing the handle.
-	 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
-
-	 // ...
-
-	 // Use the handle to raise the priority of the created task.
-	 vTaskPrioritySet( xHandle, tskIDLE_PRIORITY + 1 );
-
-	 // ...
-
-	 // Use a NULL handle to raise our priority to the same value.
-	 vTaskPrioritySet( NULL, tskIDLE_PRIORITY + 1 );
- }
-   
- * \defgroup vTaskPrioritySet vTaskPrioritySet + * @code{c} + * void vAFunction( void ) + * { + * TaskHandle_t xHandle; + * + * // Create a task, storing the handle. + * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle ); + * + * // ... + * + * // Use the handle to raise the priority of the created task. + * vTaskPrioritySet( xHandle, tskIDLE_PRIORITY + 1 ); + * + * // ... + * + * // Use a NULL handle to raise our priority to the same value. + * vTaskPrioritySet( NULL, tskIDLE_PRIORITY + 1 ); + * } + * @endcode * \ingroup TaskCtrl */ void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority ) PRIVILEGED_FUNCTION; /** - * task. h - *
void vTaskSuspend( TaskHandle_t xTaskToSuspend );
+ * Suspend a task. * * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available. * See the configuration section for more information. * - * Suspend any task. When suspended a task will never get any microcontroller - * processing time, no matter what its priority. + * When suspended, a task will never get any microcontroller processing time, + * no matter what its priority. * * Calls to vTaskSuspend are not accumulative - * i.e. calling vTaskSuspend () twice on the same task still only requires one @@ -912,48 +980,44 @@ void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority ) PRIVILEGE * handle will cause the calling task to be suspended. * * Example usage: -
- void vAFunction( void )
- {
- TaskHandle_t xHandle;
-
-	 // Create a task, storing the handle.
-	 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
-
-	 // ...
-
-	 // Use the handle to suspend the created task.
-	 vTaskSuspend( xHandle );
-
-	 // ...
-
-	 // The created task will not run during this period, unless
-	 // another task calls vTaskResume( xHandle ).
-
-	 //...
-
-
-	 // Suspend ourselves.
-	 vTaskSuspend( NULL );
-
-	 // We cannot get here unless another task calls vTaskResume
-	 // with our handle as the parameter.
- }
-   
- * \defgroup vTaskSuspend vTaskSuspend + * @code{c} + * void vAFunction( void ) + * { + * TaskHandle_t xHandle; + * + * // Create a task, storing the handle. + * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle ); + * + * // ... + * + * // Use the handle to suspend the created task. + * vTaskSuspend( xHandle ); + * + * // ... + * + * // The created task will not run during this period, unless + * // another task calls vTaskResume( xHandle ). + * + * //... + * + * + * // Suspend ourselves. + * vTaskSuspend( NULL ); + * + * // We cannot get here unless another task calls vTaskResume + * // with our handle as the parameter. + * } + * @endcode * \ingroup TaskCtrl */ void vTaskSuspend( TaskHandle_t xTaskToSuspend ) PRIVILEGED_FUNCTION; /** - * task. h - *
void vTaskResume( TaskHandle_t xTaskToResume );
+ * Resumes a suspended task. * * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available. * See the configuration section for more information. * - * Resumes a suspended task. - * * A task that has been suspended by one or more calls to vTaskSuspend () * will be made available for running again by a single call to * vTaskResume (). @@ -961,48 +1025,44 @@ void vTaskSuspend( TaskHandle_t xTaskToSuspend ) PRIVILEGED_FUNCTION; * @param xTaskToResume Handle to the task being readied. * * Example usage: -
- void vAFunction( void )
- {
- TaskHandle_t xHandle;
-
-	 // Create a task, storing the handle.
-	 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
-
-	 // ...
-
-	 // Use the handle to suspend the created task.
-	 vTaskSuspend( xHandle );
-
-	 // ...
-
-	 // The created task will not run during this period, unless
-	 // another task calls vTaskResume( xHandle ).
-
-	 //...
-
-
-	 // Resume the suspended task ourselves.
-	 vTaskResume( xHandle );
-
-	 // The created task will once again get microcontroller processing
-	 // time in accordance with its priority within the system.
- }
-   
- * \defgroup vTaskResume vTaskResume + * @code{c} + * void vAFunction( void ) + * { + * TaskHandle_t xHandle; + * + * // Create a task, storing the handle. + * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle ); + * + * // ... + * + * // Use the handle to suspend the created task. + * vTaskSuspend( xHandle ); + * + * // ... + * + * // The created task will not run during this period, unless + * // another task calls vTaskResume( xHandle ). + * + * //... + * + * + * // Resume the suspended task ourselves. + * vTaskResume( xHandle ); + * + * // The created task will once again get microcontroller processing + * // time in accordance with its priority within the system. + * } + * @endcode * \ingroup TaskCtrl */ void vTaskResume( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION; /** - * task. h - *
void xTaskResumeFromISR( TaskHandle_t xTaskToResume );
+ * An implementation of vTaskResume() that can be called from within an ISR. * * INCLUDE_xTaskResumeFromISR must be defined as 1 for this function to be * available. See the configuration section for more information. * - * An implementation of vTaskResume() that can be called from within an ISR. - * * A task that has been suspended by one or more calls to vTaskSuspend () * will be made available for running again by a single call to * xTaskResumeFromISR (). @@ -1018,7 +1078,6 @@ void vTaskResume( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION; * otherwise pdFALSE. This is used by the ISR to determine if a context switch * may be required following the ISR. * - * \defgroup vTaskResumeFromISR vTaskResumeFromISR * \ingroup TaskCtrl */ BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION; @@ -1026,46 +1085,42 @@ BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION; /*----------------------------------------------------------- * SCHEDULER CONTROL *----------------------------------------------------------*/ - +/** @cond */ /** - * task. h - *
void vTaskStartScheduler( void );
+ * Starts the real time kernel tick processing. * - * Starts the real time kernel tick processing. After calling the kernel - * has control over which tasks are executed and when. + * After calling the kernel has control over which tasks are executed and when. * * See the demo application file main.c for an example of creating * tasks and starting the kernel. * * Example usage: -
- void vAFunction( void )
- {
-	 // Create at least one task before starting the kernel.
-	 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
-
-	 // Start the real time kernel with preemption.
-	 vTaskStartScheduler ();
-
-	 // Will not get here unless a task calls vTaskEndScheduler ()
- }
-   
+ * @code{c} + * void vAFunction( void ) + * { + * // Create at least one task before starting the kernel. + * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL ); + * + * // Start the real time kernel with preemption. + * vTaskStartScheduler (); + * + * // Will not get here unless a task calls vTaskEndScheduler () + * } + * @endcode * - * \defgroup vTaskStartScheduler vTaskStartScheduler * \ingroup SchedulerControl */ void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION; /** - * task. h - *
void vTaskEndScheduler( void );
+ * Stops the real time kernel tick. * - * NOTE: At the time of writing only the x86 real mode port, which runs on a PC + * @note At the time of writing only the x86 real mode port, which runs on a PC * in place of DOS, implements this function. * - * Stops the real time kernel tick. All created tasks will be automatically - * deleted and multitasking (either preemptive or cooperative) will - * stop. Execution then resumes from the point where vTaskStartScheduler () + * All created tasks will be automatically deleted and multitasking + * (either preemptive or cooperative) will stop. + * Execution then resumes from the point where vTaskStartScheduler () * was called, as if vTaskStartScheduler () had just returned. * * See the demo application file main. c in the demo/PC directory for an @@ -1080,44 +1135,42 @@ void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION; * tasks. * * Example usage: -
- void vTaskCode( void * pvParameters )
- {
-	 for( ;; )
-	 {
-		 // Task code goes here.
-
-		 // At some point we want to end the real time kernel processing
-		 // so call ...
-		 vTaskEndScheduler ();
-	 }
- }
-
- void vAFunction( void )
- {
-	 // Create at least one task before starting the kernel.
-	 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
-
-	 // Start the real time kernel with preemption.
-	 vTaskStartScheduler ();
-
-	 // Will only get here when the vTaskCode () task has called
-	 // vTaskEndScheduler ().  When we get here we are back to single task
-	 // execution.
- }
-   
- * - * \defgroup vTaskEndScheduler vTaskEndScheduler + * @code{c} + * void vTaskCode( void * pvParameters ) + * { + * for( ;; ) + * { + * // Task code goes here. + * + * // At some point we want to end the real time kernel processing + * // so call ... + * vTaskEndScheduler (); + * } + * } + * + * void vAFunction( void ) + * { + * // Create at least one task before starting the kernel. + * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL ); + * + * // Start the real time kernel with preemption. + * vTaskStartScheduler (); + * + * // Will only get here when the vTaskCode () task has called + * // vTaskEndScheduler (). When we get here we are back to single task + * // execution. + * } + * @endcode * \ingroup SchedulerControl */ void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION; +/** @endcond */ + /** - * task. h - *
void vTaskSuspendAll( void );
+ * Suspends the scheduler without disabling interrupts. * - * Suspends the scheduler without disabling interrupts. Context switches will - * not occur while the scheduler is suspended. + * Context switches will not occur while the scheduler is suspended. * * After calling vTaskSuspendAll () the calling task will continue to execute * without risk of being swapped out until a call to xTaskResumeAll () has been @@ -1128,45 +1181,41 @@ void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION; * is suspended. * * Example usage: -
- void vTask1( void * pvParameters )
- {
-	 for( ;; )
-	 {
-		 // Task code goes here.
-
-		 // ...
-
-		 // At some point the task wants to perform a long operation during
-		 // which it does not want to get swapped out.  It cannot use
-		 // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
-		 // operation may cause interrupts to be missed - including the
-		 // ticks.
-
-		 // Prevent the real time kernel swapping out the task.
-		 vTaskSuspendAll ();
-
-		 // Perform the operation here.  There is no need to use critical
-		 // sections as we have all the microcontroller processing time.
-		 // During this time interrupts will still operate and the kernel
-		 // tick count will be maintained.
-
-		 // ...
-
-		 // The operation is complete.  Restart the kernel.
-		 xTaskResumeAll ();
-	 }
- }
-   
- * \defgroup vTaskSuspendAll vTaskSuspendAll + * @code{c} + * void vTask1( void * pvParameters ) + * { + * for( ;; ) + * { + * // Task code goes here. + * + * // ... + * + * // At some point the task wants to perform a long operation during + * // which it does not want to get swapped out. It cannot use + * // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the + * // operation may cause interrupts to be missed - including the + * // ticks. + * + * // Prevent the real time kernel swapping out the task. + * vTaskSuspendAll (); + * + * // Perform the operation here. There is no need to use critical + * // sections as we have all the microcontroller processing time. + * // During this time interrupts will still operate and the kernel + * // tick count will be maintained. + * + * // ... + * + * // The operation is complete. Restart the kernel. + * xTaskResumeAll (); + * } + * } + * @endcode * \ingroup SchedulerControl */ void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION; /** - * task. h - *
BaseType_t xTaskResumeAll( void );
- * * Resumes scheduler activity after it was suspended by a call to * vTaskSuspendAll(). * @@ -1177,42 +1226,41 @@ void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION; * returned, otherwise pdFALSE is returned. * * Example usage: -
- void vTask1( void * pvParameters )
- {
-	 for( ;; )
-	 {
-		 // Task code goes here.
-
-		 // ...
-
-		 // At some point the task wants to perform a long operation during
-		 // which it does not want to get swapped out.  It cannot use
-		 // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
-		 // operation may cause interrupts to be missed - including the
-		 // ticks.
-
-		 // Prevent the real time kernel swapping out the task.
-		 vTaskSuspendAll ();
-
-		 // Perform the operation here.  There is no need to use critical
-		 // sections as we have all the microcontroller processing time.
-		 // During this time interrupts will still operate and the real
-		 // time kernel tick count will be maintained.
-
-		 // ...
-
-		 // The operation is complete.  Restart the kernel.  We want to force
-		 // a context switch - but there is no point if resuming the scheduler
-		 // caused a context switch already.
-		 if( !xTaskResumeAll () )
-		 {
-			  taskYIELD ();
-		 }
-	 }
- }
-   
- * \defgroup xTaskResumeAll xTaskResumeAll + * @code{c} + * void vTask1( void * pvParameters ) + * { + * for( ;; ) + * { + * // Task code goes here. + * + * // ... + * + * // At some point the task wants to perform a long operation during + * // which it does not want to get swapped out. It cannot use + * // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the + * // operation may cause interrupts to be missed - including the + * // ticks. + * + * // Prevent the real time kernel swapping out the task. + * vTaskSuspendAll (); + * + * // Perform the operation here. There is no need to use critical + * // sections as we have all the microcontroller processing time. + * // During this time interrupts will still operate and the real + * // time kernel tick count will be maintained. + * + * // ... + * + * // The operation is complete. Restart the kernel. We want to force + * // a context switch - but there is no point if resuming the scheduler + * // caused a context switch already. + * if( !xTaskResumeAll () ) + * { + * taskYIELD (); + * } + * } + * } + * @endcode * \ingroup SchedulerControl */ BaseType_t xTaskResumeAll( void ) PRIVILEGED_FUNCTION; @@ -1222,19 +1270,16 @@ BaseType_t xTaskResumeAll( void ) PRIVILEGED_FUNCTION; *----------------------------------------------------------*/ /** - * task. h - *
TickType_t xTaskGetTickCount( void );
+ * Get tick count * * @return The count of ticks since vTaskStartScheduler was called. * - * \defgroup xTaskGetTickCount xTaskGetTickCount * \ingroup TaskUtils */ TickType_t xTaskGetTickCount( void ) PRIVILEGED_FUNCTION; /** - * task. h - *
TickType_t xTaskGetTickCountFromISR( void );
+ * Get tick count from ISR * * @return The count of ticks since vTaskStartScheduler was called. * @@ -1243,50 +1288,43 @@ TickType_t xTaskGetTickCount( void ) PRIVILEGED_FUNCTION; * microcontroller being used or interrupt nesting is either not supported or * not being used. * - * \defgroup xTaskGetTickCountFromISR xTaskGetTickCountFromISR * \ingroup TaskUtils */ TickType_t xTaskGetTickCountFromISR( void ) PRIVILEGED_FUNCTION; /** - * task. h - *
UBaseType_t uxTaskGetNumberOfTasks( void );
+ * Get current number of tasks * * @return The number of tasks that the real time kernel is currently managing. * This includes all ready, blocked and suspended tasks. A task that * has been deleted but not yet freed by the idle task will also be * included in the count. * - * \defgroup uxTaskGetNumberOfTasks uxTaskGetNumberOfTasks * \ingroup TaskUtils */ UBaseType_t uxTaskGetNumberOfTasks( void ) PRIVILEGED_FUNCTION; /** - * task. h - *
char *pcTaskGetTaskName( TaskHandle_t xTaskToQuery );
+ * Get task name * * @return The text (human readable) name of the task referenced by the handle * xTaskToQuery. A task can query its own name by either passing in its own * handle, or by setting xTaskToQuery to NULL. INCLUDE_pcTaskGetTaskName must be * set to 1 in FreeRTOSConfig.h for pcTaskGetTaskName() to be available. * - * \defgroup pcTaskGetTaskName pcTaskGetTaskName * \ingroup TaskUtils */ char *pcTaskGetTaskName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ /** - * task.h - *
UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask );
+ * Returns the high water mark of the stack associated with xTask. * * INCLUDE_uxTaskGetStackHighWaterMark must be set to 1 in FreeRTOSConfig.h for * this function to be available. * - * Returns the high water mark of the stack associated with xTask. That is, - * the minimum free stack space there has been (in words, so on a 32 bit machine - * a value of 1 means 4 bytes) since the task started. The smaller the returned - * number the closer the task has come to overflowing its stack. + * High water mark is the minimum free stack space there has been (in words, + * so on a 32 bit machine a value of 1 means 4 bytes) since the task started. + * The smaller the returned number the closer the task has come to overflowing its stack. * * @param xTask Handle of the task associated with the stack to be checked. * Set xTask to NULL to check the stack of the calling task. @@ -1298,14 +1336,12 @@ char *pcTaskGetTaskName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION; /*lint UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; /** - * task.h - *
uint8_t* pxTaskGetStackStart( TaskHandle_t xTask);
+ * Returns the start of the stack associated with xTask. * * INCLUDE_pxTaskGetStackStart must be set to 1 in FreeRTOSConfig.h for * this function to be available. * - * Returns the start of the stack associated with xTask. That is, - * the highest stack memory address on architectures where the stack grows down + * Returns the highest stack memory address on architectures where the stack grows down * from high memory, and the lowest memory address on architectures where the * stack grows up from low memory. * @@ -1325,73 +1361,130 @@ constant. */ #ifdef configUSE_APPLICATION_TASK_TAG #if configUSE_APPLICATION_TASK_TAG == 1 /** - * task.h - *
void vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction );
- * * Sets pxHookFunction to be the task hook function used by the task xTask. - * Passing xTask as NULL has the effect of setting the calling tasks hook - * function. + * @param xTask Handle of the task to set the hook function for + * Passing xTask as NULL has the effect of setting the calling + * tasks hook function. + * @param pxHookFunction Pointer to the hook function. */ void vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction ) PRIVILEGED_FUNCTION; /** - * task.h - *
void xTaskGetApplicationTaskTag( TaskHandle_t xTask );
- * - * Returns the pxHookFunction value assigned to the task xTask. + * Get the hook function assigned to given task. + * @param xTask Handle of the task to get the hook function for + * Passing xTask as NULL has the effect of getting the calling + * tasks hook function. + * @return The pxHookFunction value assigned to the task xTask. */ TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; #endif /* configUSE_APPLICATION_TASK_TAG ==1 */ #endif /* ifdef configUSE_APPLICATION_TASK_TAG */ #if( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) - /* Each task contains an array of pointers that is dimensioned by the - configNUM_THREAD_LOCAL_STORAGE_POINTERS setting in FreeRTOSConfig.h. The - kernel does not use the pointers itself, so the application writer can use - the pointers for any purpose they wish. The following two functions are - used to set and query a pointer respectively. */ + /** + * Set local storage pointer specific to the given task. + * + * Each task contains an array of pointers that is dimensioned by the + * configNUM_THREAD_LOCAL_STORAGE_POINTERS setting in FreeRTOSConfig.h. + * The kernel does not use the pointers itself, so the application writer + * can use the pointers for any purpose they wish. + * + * @param xTaskToSet Task to set thread local storage pointer for + * @param xIndex The index of the pointer to set, from 0 to + * configNUM_THREAD_LOCAL_STORAGE_POINTERS - 1. + * @param pvValue Pointer value to set. + */ void vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue ) PRIVILEGED_FUNCTION; + + + /** + * Get local storage pointer specific to the given task. + * + * Each task contains an array of pointers that is dimensioned by the + * configNUM_THREAD_LOCAL_STORAGE_POINTERS setting in FreeRTOSConfig.h. + * The kernel does not use the pointers itself, so the application writer + * can use the pointers for any purpose they wish. + * + * @param xTaskToQuery Task to get thread local storage pointer for + * @param xIndex The index of the pointer to get, from 0 to + * configNUM_THREAD_LOCAL_STORAGE_POINTERS - 1. + * @return Pointer value + */ void *pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, BaseType_t xIndex ) PRIVILEGED_FUNCTION; - #if ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS ) - typedef void (*TlsDeleteCallbackFunction_t)( int, void * ); - void vTaskSetThreadLocalStoragePointerAndDelCallback( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue , TlsDeleteCallbackFunction_t xDelCallback); + #if ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS ) + + /** + * Prototype of local storage pointer deletion callback. + */ + typedef void (*TlsDeleteCallbackFunction_t)( int, void * ); + + /** + * Set local storage pointer and deletion callback. + * + * Each task contains an array of pointers that is dimensioned by the + * configNUM_THREAD_LOCAL_STORAGE_POINTERS setting in FreeRTOSConfig.h. + * The kernel does not use the pointers itself, so the application writer + * can use the pointers for any purpose they wish. + * + * Local storage pointers set for a task can reference dynamically + * allocated resources. This function is similar to + * vTaskSetThreadLocalStoragePointer, but provides a way to release + * these resources when the task gets deleted. For each pointer, + * a callback function can be set. This function will be called + * when task is deleted, with the local storage pointer index + * and value as arguments. + * + * @param xTaskToSet Task to set thread local storage pointer for + * @param xIndex The index of the pointer to set, from 0 to + * configNUM_THREAD_LOCAL_STORAGE_POINTERS - 1. + * @param pvValue Pointer value to set. + * @param pvDelCallback Function to call to dispose of the local + * storage pointer when the task is deleted. + */ + void vTaskSetThreadLocalStoragePointerAndDelCallback( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue, TlsDeleteCallbackFunction_t pvDelCallback); #endif #endif /** - * task.h - *
BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter );
- * - * Calls the hook function associated with xTask. Passing xTask as NULL has + * Calls the hook function associated with xTask. Passing xTask as NULL has * the effect of calling the Running tasks (the calling task) hook function. * - * pvParameter is passed to the hook function for the task to interpret as it + * @param xTask Handle of the task to call the hook for. + * @param pvParameter Parameter passed to the hook function for the task to interpret as it * wants. The return value is the value returned by the task hook function * registered by the user. */ BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter ) PRIVILEGED_FUNCTION; /** + * Get the handle of idle task for the current CPU. + * * xTaskGetIdleTaskHandle() is only available if * INCLUDE_xTaskGetIdleTaskHandle is set to 1 in FreeRTOSConfig.h. * - * Simply returns the handle of the idle task. It is not valid to call + * @return The handle of the idle task. It is not valid to call * xTaskGetIdleTaskHandle() before the scheduler has been started. */ TaskHandle_t xTaskGetIdleTaskHandle( void ); /** + * Get the handle of idle task for the given CPU. + * * xTaskGetIdleTaskHandleForCPU() is only available if * INCLUDE_xTaskGetIdleTaskHandle is set to 1 in FreeRTOSConfig.h. * - * Simply returns the idle task handle of a given cpu. It is not valid to call + * @param cpuid The CPU to get the handle for + * + * @return Idle task handle of a given cpu. It is not valid to call * xTaskGetIdleTaskHandleForCPU() before the scheduler has been started. */ TaskHandle_t xTaskGetIdleTaskHandleForCPU( UBaseType_t cpuid ); /** + * Get the state of tasks in the system. + * * configUSE_TRACE_FACILITY must be defined as 1 in FreeRTOSConfig.h for * uxTaskGetSystemState() to be available. * @@ -1401,7 +1494,7 @@ TaskHandle_t xTaskGetIdleTaskHandleForCPU( UBaseType_t cpuid ); * of run time consumed by the task. See the TaskStatus_t structure * definition in this file for the full member list. * - * NOTE: This function is intended for debugging use only as its use results in + * @note This function is intended for debugging use only as its use results in * the scheduler remaining suspended for an extended period. * * @param pxTaskStatusArray A pointer to an array of TaskStatus_t structures. @@ -1426,79 +1519,78 @@ TaskHandle_t xTaskGetIdleTaskHandleForCPU( UBaseType_t cpuid ); * in the uxArraySize parameter was too small. * * Example usage: -
-    // This example demonstrates how a human readable table of run time stats
-	// information is generated from raw data provided by uxTaskGetSystemState().
-	// The human readable table is written to pcWriteBuffer
-	void vTaskGetRunTimeStats( char *pcWriteBuffer )
-	{
-	TaskStatus_t *pxTaskStatusArray;
-	volatile UBaseType_t uxArraySize, x;
-	uint32_t ulTotalRunTime, ulStatsAsPercentage;
-
-		// Make sure the write buffer does not contain a string.
-		*pcWriteBuffer = 0x00;
-
-		// Take a snapshot of the number of tasks in case it changes while this
-		// function is executing.
-		uxArraySize = uxTaskGetNumberOfTasks();
-
-		// Allocate a TaskStatus_t structure for each task.  An array could be
-		// allocated statically at compile time.
-		pxTaskStatusArray = pvPortMalloc( uxArraySize * sizeof( TaskStatus_t ) );
-
-		if( pxTaskStatusArray != NULL )
-		{
-			// Generate raw status information about each task.
-			uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, &ulTotalRunTime );
-
-			// For percentage calculations.
-			ulTotalRunTime /= 100UL;
-
-			// Avoid divide by zero errors.
-			if( ulTotalRunTime > 0 )
-			{
-				// For each populated position in the pxTaskStatusArray array,
-				// format the raw data as human readable ASCII data
-				for( x = 0; x < uxArraySize; x++ )
-				{
-					// What percentage of the total run time has the task used?
-					// This will always be rounded down to the nearest integer.
-					// ulTotalRunTimeDiv100 has already been divided by 100.
-					ulStatsAsPercentage = pxTaskStatusArray[ x ].ulRunTimeCounter / ulTotalRunTime;
-
-					if( ulStatsAsPercentage > 0UL )
-					{
-						sprintf( pcWriteBuffer, "%s\t\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage );
-					}
-					else
-					{
-						// If the percentage is zero here then the task has
-						// consumed less than 1% of the total run time.
-						sprintf( pcWriteBuffer, "%s\t\t%lu\t\t<1%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter );
-					}
-
-					pcWriteBuffer += strlen( ( char * ) pcWriteBuffer );
-				}
-			}
-
-			// The array is no longer needed, free the memory it consumes.
-			vPortFree( pxTaskStatusArray );
-		}
-	}
-	
+ * @code{c} + * // This example demonstrates how a human readable table of run time stats + * // information is generated from raw data provided by uxTaskGetSystemState(). + * // The human readable table is written to pcWriteBuffer + * void vTaskGetRunTimeStats( char *pcWriteBuffer ) + * { + * TaskStatus_t *pxTaskStatusArray; + * volatile UBaseType_t uxArraySize, x; + * uint32_t ulTotalRunTime, ulStatsAsPercentage; + * + * // Make sure the write buffer does not contain a string. + * *pcWriteBuffer = 0x00; + * + * // Take a snapshot of the number of tasks in case it changes while this + * // function is executing. + * uxArraySize = uxTaskGetNumberOfTasks(); + * + * // Allocate a TaskStatus_t structure for each task. An array could be + * // allocated statically at compile time. + * pxTaskStatusArray = pvPortMalloc( uxArraySize * sizeof( TaskStatus_t ) ); + * + * if( pxTaskStatusArray != NULL ) + * { + * // Generate raw status information about each task. + * uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, &ulTotalRunTime ); + * + * // For percentage calculations. + * ulTotalRunTime /= 100UL; + * + * // Avoid divide by zero errors. + * if( ulTotalRunTime > 0 ) + * { + * // For each populated position in the pxTaskStatusArray array, + * // format the raw data as human readable ASCII data + * for( x = 0; x < uxArraySize; x++ ) + * { + * // What percentage of the total run time has the task used? + * // This will always be rounded down to the nearest integer. + * // ulTotalRunTimeDiv100 has already been divided by 100. + * ulStatsAsPercentage = pxTaskStatusArray[ x ].ulRunTimeCounter / ulTotalRunTime; + * + * if( ulStatsAsPercentage > 0UL ) + * { + * sprintf( pcWriteBuffer, "%s\t\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage ); + * } + * else + * { + * // If the percentage is zero here then the task has + * // consumed less than 1% of the total run time. + * sprintf( pcWriteBuffer, "%s\t\t%lu\t\t<1%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter ); + * } + * + * pcWriteBuffer += strlen( ( char * ) pcWriteBuffer ); + * } + * } + * + * // The array is no longer needed, free the memory it consumes. + * vPortFree( pxTaskStatusArray ); + * } + * } + * @endcode */ UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const UBaseType_t uxArraySize, uint32_t * const pulTotalRunTime ); /** - * task. h - *
void vTaskList( char *pcWriteBuffer );
+ * List all the current tasks. * * configUSE_TRACE_FACILITY and configUSE_STATS_FORMATTING_FUNCTIONS must * both be defined as 1 for this function to be available. See the * configuration section of the FreeRTOS.org website for more information. * - * NOTE 1: This function will disable interrupts for its duration. It is + * @note This function will disable interrupts for its duration. It is * not intended for normal application runtime use but as a debug aid. * * Lists all the current tasks, along with their current state and stack @@ -1507,9 +1599,7 @@ UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const * Tasks are reported as blocked ('B'), ready ('R'), deleted ('D') or * suspended ('S'). * - * PLEASE NOTE: - * - * This function is provided for convenience only, and is used by many of the + * @note This function is provided for convenience only, and is used by many of the * demo applications. Do not consider it to be part of the scheduler. * * vTaskList() calls uxTaskGetSystemState(), then formats part of the @@ -1532,14 +1622,12 @@ UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const * enough to contain the generated report. Approximately 40 bytes per * task should be sufficient. * - * \defgroup vTaskList vTaskList * \ingroup TaskUtils */ void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ /** - * task. h - *
void vTaskGetRunTimeStats( char *pcWriteBuffer );
+ * Get the state of running tasks as a string * * configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS * must both be defined as 1 for this function to be available. The application @@ -1549,7 +1637,7 @@ void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unquali * value respectively. The counter should be at least 10 times the frequency of * the tick count. * - * NOTE 1: This function will disable interrupts for its duration. It is + * @note This function will disable interrupts for its duration. It is * not intended for normal application runtime use but as a debug aid. * * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total @@ -1560,9 +1648,7 @@ void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unquali * task into a buffer, both as an absolute count value and as a percentage * of the total system execution time. * - * NOTE 2: - * - * This function is provided for convenience only, and is used by many of the + * @note This function is provided for convenience only, and is used by many of the * demo applications. Do not consider it to be part of the scheduler. * * vTaskGetRunTimeStats() calls uxTaskGetSystemState(), then formats part of the @@ -1586,14 +1672,12 @@ void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unquali * contain the generated report. Approximately 40 bytes per task should * be sufficient. * - * \defgroup vTaskGetRunTimeStats vTaskGetRunTimeStats * \ingroup TaskUtils */ void vTaskGetRunTimeStats( char *pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ /** - * task. h - *
BaseType_t xTaskNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction );
+ * Send task notification. * * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this * function to be available. @@ -1634,43 +1718,40 @@ void vTaskGetRunTimeStats( char *pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e9 * * @param eAction Specifies how the notification updates the task's notification * value, if at all. Valid values for eAction are as follows: - * - * eSetBits - - * The task's notification value is bitwise ORed with ulValue. xTaskNofify() - * always returns pdPASS in this case. - * - * eIncrement - - * The task's notification value is incremented. ulValue is not used and - * xTaskNotify() always returns pdPASS in this case. - * - * eSetValueWithOverwrite - - * The task's notification value is set to the value of ulValue, even if the - * task being notified had not yet processed the previous notification (the - * task already had a notification pending). xTaskNotify() always returns - * pdPASS in this case. - * - * eSetValueWithoutOverwrite - - * If the task being notified did not already have a notification pending then - * the task's notification value is set to ulValue and xTaskNotify() will - * return pdPASS. If the task being notified already had a notification - * pending then no action is performed and pdFAIL is returned. - * - * eNoAction - - * The task receives a notification without its notification value being - * updated. ulValue is not used and xTaskNotify() always returns pdPASS in - * this case. + * - eSetBits: + * The task's notification value is bitwise ORed with ulValue. xTaskNofify() + * always returns pdPASS in this case. + * + * - eIncrement: + * The task's notification value is incremented. ulValue is not used and + * xTaskNotify() always returns pdPASS in this case. + * + * - eSetValueWithOverwrite: + * The task's notification value is set to the value of ulValue, even if the + * task being notified had not yet processed the previous notification (the + * task already had a notification pending). xTaskNotify() always returns + * pdPASS in this case. + * + * - eSetValueWithoutOverwrite: + * If the task being notified did not already have a notification pending then + * the task's notification value is set to ulValue and xTaskNotify() will + * return pdPASS. If the task being notified already had a notification + * pending then no action is performed and pdFAIL is returned. + * + * - eNoAction: + * The task receives a notification without its notification value being + *   updated. ulValue is not used and xTaskNotify() always returns pdPASS in + * this case. * * @return Dependent on the value of eAction. See the description of the * eAction parameter. * - * \defgroup xTaskNotify xTaskNotify * \ingroup TaskNotifications */ BaseType_t xTaskNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction ); /** - * task. h - *
BaseType_t xTaskNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken );
+ * Send task notification from an ISR. * * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this * function to be available. @@ -1714,31 +1795,30 @@ BaseType_t xTaskNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAct * * @param eAction Specifies how the notification updates the task's notification * value, if at all. Valid values for eAction are as follows: - * - * eSetBits - - * The task's notification value is bitwise ORed with ulValue. xTaskNofify() - * always returns pdPASS in this case. - * - * eIncrement - - * The task's notification value is incremented. ulValue is not used and - * xTaskNotify() always returns pdPASS in this case. - * - * eSetValueWithOverwrite - - * The task's notification value is set to the value of ulValue, even if the - * task being notified had not yet processed the previous notification (the - * task already had a notification pending). xTaskNotify() always returns - * pdPASS in this case. - * - * eSetValueWithoutOverwrite - - * If the task being notified did not already have a notification pending then - * the task's notification value is set to ulValue and xTaskNotify() will - * return pdPASS. If the task being notified already had a notification - * pending then no action is performed and pdFAIL is returned. - * - * eNoAction - - * The task receives a notification without its notification value being - * updated. ulValue is not used and xTaskNotify() always returns pdPASS in - * this case. + * - eSetBits: + * The task's notification value is bitwise ORed with ulValue. xTaskNofify() + * always returns pdPASS in this case. + * + * - eIncrement: + * The task's notification value is incremented. ulValue is not used and + * xTaskNotify() always returns pdPASS in this case. + * + * - eSetValueWithOverwrite: + * The task's notification value is set to the value of ulValue, even if the + * task being notified had not yet processed the previous notification (the + * task already had a notification pending). xTaskNotify() always returns + * pdPASS in this case. + * + * - eSetValueWithoutOverwrite: + * If the task being notified did not already have a notification pending then + * the task's notification value is set to ulValue and xTaskNotify() will + * return pdPASS. If the task being notified already had a notification + * pending then no action is performed and pdFAIL is returned. + * + * - eNoAction: + * The task receives a notification without its notification value being + * updated. ulValue is not used and xTaskNotify() always returns pdPASS in + * this case. * * @param pxHigherPriorityTaskWoken xTaskNotifyFromISR() will set * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the @@ -1752,14 +1832,12 @@ BaseType_t xTaskNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAct * @return Dependent on the value of eAction. See the description of the * eAction parameter. * - * \defgroup xTaskNotify xTaskNotify * \ingroup TaskNotifications */ BaseType_t xTaskNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken ); /** - * task. h - *
BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait );
+ * Wait for task notification * * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this * function to be available. @@ -1827,14 +1905,12 @@ BaseType_t xTaskNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNo * already pending when xTaskNotifyWait was called) then pdPASS is * returned. Otherwise pdFAIL is returned. * - * \defgroup xTaskNotifyWait xTaskNotifyWait * \ingroup TaskNotifications */ BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ); /** - * task. h - *
BaseType_t xTaskNotifyGive( TaskHandle_t xTaskToNotify );
+ * Simplified macro for sending task notification. * * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this macro * to be available. @@ -1873,14 +1949,12 @@ BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClea * @return xTaskNotifyGive() is a macro that calls xTaskNotify() with the * eAction parameter set to eIncrement - so pdPASS is always returned. * - * \defgroup xTaskNotifyGive xTaskNotifyGive * \ingroup TaskNotifications */ #define xTaskNotifyGive( xTaskToNotify ) xTaskNotify( ( xTaskToNotify ), 0, eIncrement ); /** - * task. h - *
void vTaskNotifyGiveFromISR( TaskHandle_t xTaskHandle, BaseType_t *pxHigherPriorityTaskWoken );
+ * Simplified macro for sending task notification from ISR.
  *
  * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this macro
  * to be available.
@@ -1928,14 +2002,12 @@ BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClea
  * requested from an ISR is dependent on the port - see the documentation page
  * for the port in use.
  *
- * \defgroup xTaskNotifyWait xTaskNotifyWait
  * \ingroup TaskNotifications
  */
 void vTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPriorityTaskWoken );
 
 /**
- * task. h
- * 
uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait );
+ * Simplified macro for receiving task notification. * * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this * function to be available. @@ -1997,7 +2069,6 @@ void vTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPri * @return The task's notification count before it is either cleared to zero or * decremented (see the xClearCountOnExit parameter). * - * \defgroup ulTaskNotifyTake ulTaskNotifyTake * \ingroup TaskNotifications */ uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait ); @@ -2005,7 +2076,7 @@ uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait /*----------------------------------------------------------- * SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES *----------------------------------------------------------*/ - +/** @cond */ /* * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS @@ -2224,6 +2295,8 @@ void *pvTaskIncrementMutexHeldCount( void ); */ UBaseType_t uxTaskGetSnapshotAll( TaskSnapshot_t * const pxTaskSnapshotArray, const UBaseType_t uxArraySize, UBaseType_t * const pxTcbSz ); +/** @endcond */ + #ifdef __cplusplus } #endif diff --git a/tools/sdk/include/freertos/freertos/timers.h b/tools/sdk/include/freertos/freertos/timers.h index f89cd1d70ec12d8f1ce10e8b8f1c9b149f59701e..17492e64c66eb307ee329b93fbbaf05c2dad09fa 100644 --- a/tools/sdk/include/freertos/freertos/timers.h +++ b/tools/sdk/include/freertos/freertos/timers.h @@ -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. 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. + * 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 @@ -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 + + /** + * 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 */ /** - * void *pvTimerGetTimerID( TimerHandle_t xTimer ); - * * 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 diff --git a/tools/sdk/include/heap/esp_heap_alloc_caps.h b/tools/sdk/include/heap/esp_heap_alloc_caps.h index f92e92e352a9e6ffedf1635f640517933cf50772..7e6e25d6a85214d5287152d921f7eaa154359565 100644 --- a/tools/sdk/include/heap/esp_heap_alloc_caps.h +++ b/tools/sdk/include/heap/esp_heap_alloc_caps.h @@ -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 } diff --git a/tools/sdk/include/json/cJSON.h b/tools/sdk/include/json/cJSON.h index 92ed8c3b48582b16bef6d7775ec7d4ddbed9e6ce..7c4f8e7cdbea2108496f3fb5be8819977bcdfe3d 100644 --- a/tools/sdk/include/json/cJSON.h +++ b/tools/sdk/include/json/cJSON.h @@ -1,16 +1,16 @@ /* - 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 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 @@ -28,120 +28,233 @@ extern "C" { #endif +/* project version */ +#define CJSON_VERSION_MAJOR 1 +#define CJSON_VERSION_MINOR 6 +#define CJSON_VERSION_PATCH 0 + +#include + /* 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()) -#define cJSON_AddTrueToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateTrue()) -#define cJSON_AddFalseToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateFalse()) -#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_AddNullToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateNull()) +#define cJSON_AddTrueToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateTrue()) +#define cJSON_AddFalseToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateFalse()) +#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 } diff --git a/tools/sdk/include/json/cJSON_Utils.h b/tools/sdk/include/json/cJSON_Utils.h index b129b0625249d691a43347da9df3724df730d398..03ec10c9e2c12bf0e6882d8cb6479f3396f0444a 100644 --- a/tools/sdk/include/json/cJSON_Utils.h +++ b/tools/sdk/include/json/cJSON_Utils.h @@ -1,30 +1,74 @@ +/* + 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); +/* Implement RFC6901 (https://tools.ietf.org/html/rfc6901) JSON Pointer spec. */ +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. */ +/* Implement RFC6902 (https://tools.ietf.org/html/rfc6902) JSON Patch spec. */ +/* 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: //int cJSONUtils_AtomicApplyPatches(cJSON **object, cJSON *patches) //{ -// cJSON *modme=cJSON_Duplicate(*object,1); -// int error=cJSONUtils_ApplyPatches(modme,patches); -// if (!error) {cJSON_Delete(*object);*object=modme;} -// else cJSON_Delete(modme); -// return error; +// cJSON *modme = cJSON_Duplicate(*object, 1); +// int error = cJSONUtils_ApplyPatches(modme, patches); +// 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); diff --git a/tools/sdk/include/log/esp_log.h b/tools/sdk/include/log/esp_log.h index e525bca3c0a042557ed3055279c84d6b80da6629..2f251c6b86922c8d17c4c34ec05137f79f641c42 100644 --- a/tools/sdk/include/log/esp_log.h +++ b/tools/sdk/include/log/esp_log.h @@ -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`` */ diff --git a/tools/sdk/include/log/esp_log_internal.h b/tools/sdk/include/log/esp_log_internal.h index a41243881e8e38659278e2e8cdcde005d10b3cd1..94ec34632276740fea5bb0c9c5a4b0d78e95a70e 100644 --- a/tools/sdk/include/log/esp_log_internal.h +++ b/tools/sdk/include/log/esp_log_internal.h @@ -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); diff --git a/tools/sdk/include/lwip/apps/dhcpserver.h b/tools/sdk/include/lwip/apps/dhcpserver.h index 943f02a917119299e26fbd5145a36861a2598a88..015ffe6e0987d627973e213d9e0644d7173df522 100644 --- a/tools/sdk/include/lwip/apps/dhcpserver.h +++ b/tools/sdk/include/lwip/apps/dhcpserver.h @@ -14,6 +14,7 @@ #ifndef __DHCPS_H__ #define __DHCPS_H__ +#include "sdkconfig.h" #include "lwip/ip_addr.h" typedef struct dhcps_state{ @@ -50,7 +51,8 @@ enum dhcps_offer_option{ #define DHCPS_COARSE_TIMER_SECS 1 #define DHCPS_MAX_LEASE 0x64 -#define DHCPS_LEASE_TIME_DEF (120) +#define DHCPS_LEASE_TIME_DEF (120) +#define DHCPS_LEASE_UNIT CONFIG_LWIP_DHCPS_LEASE_UNIT struct dhcps_pool{ ip4_addr_t ip; diff --git a/tools/sdk/include/lwip/lwip/sockets.h b/tools/sdk/include/lwip/lwip/sockets.h index cb458988a6e21f8ce3153206b65a8ee95fb6e774..4dd013bcfcdd8d53d0fa11cdb77d4beca02364ae 100755 --- a/tools/sdk/include/lwip/lwip/sockets.h +++ b/tools/sdk/include/lwip/lwip/sockets.h @@ -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 */ diff --git a/tools/sdk/include/mbedtls_port/mbedtls/esp_debug.h b/tools/sdk/include/mbedtls_port/mbedtls/esp_debug.h index bf39cc73ba67e5d17cb08948a2fdc4cb034ce91d..8e23a5ea3228d130a72d2ef243d4cd6ec4a27289 100644 --- a/tools/sdk/include/mbedtls_port/mbedtls/esp_debug.h +++ b/tools/sdk/include/mbedtls_port/mbedtls/esp_debug.h @@ -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__ */ diff --git a/tools/sdk/include/mdns/mdns.h b/tools/sdk/include/mdns/mdns.h index c0855466a7e2c69202209f1828615abc18b0e993..db0e3b522a2eda6e0861f7fe322fc9c906b76b34 100644 --- a/tools/sdk/include/mdns/mdns.h +++ b/tools/sdk/include/mdns/mdns.h @@ -20,35 +20,69 @@ extern "C" { #ifndef MDNS_TEST_MODE #include +#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 query result structure - * + * @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 */ - 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 */ + 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 */ + // 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 proto service protocol (_tcp, _udp) - * @param port service port + * @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 proto service protocol (_tcp, _udp) - * @param instance instance name to set + * @param service_type service type (_http, _ftp, etc) + * @param proto service protocol (_tcp, _udp) + * @param instance_name instance name to set * * @return * - ESP_OK success @@ -136,16 +168,29 @@ 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); +esp_err_t mdns_service_instance_name_set(const char * service_type, const char * proto, const char * instance_name); + +/** + * @brief Set service port + * + * @param service_type service type (_http, _ftp, etc) + * @param proto service protocol (_tcp, _udp) + * @param port service port + * + * @return + * - ESP_OK success + * - ESP_ERR_INVALID_ARG Parameter error + * - ESP_ERR_NOT_FOUND Service not found + */ +esp_err_t mdns_service_port_set(const char * service_type, const char * proto, uint16_t port); /** - * @brief Set TXT data for service + * @brief Replace all TXT items 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 num_items number of items in TXT data - * @param txt string array of TXT data (eg. {"var=val","other=2"}) + * @param txt array of TXT data (eg. {{"var","val"},{"other","2"}}) * * @return * - ESP_OK success @@ -153,84 +198,166 @@ esp_err_t mdns_service_instance_set(mdns_server_t * server, const char * service * - 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_txt_set(const char * service_type, const char * proto, mdns_txt_item_t txt[], uint8_t num_items); /** - * @brief Set service port + * @brief Set/Add TXT item for service TXT record * - * @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 + * @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_port_set(mdns_server_t * server, const char * service, const char * proto, uint16_t port); +esp_err_t mdns_service_txt_item_set(const char * service_type, const char * proto, const char * key, const char * value); /** - * @brief Remove and free all services from mDNS server + * @brief Remove TXT item for service TXT record * - * @param server mDNS Server + * @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 * * @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 + * @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 the number of results found + * @return + * - ESP_OK success + * - 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_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 */ -size_t mdns_query(mdns_server_t * server, const char * service, const char * proto, uint32_t timeout); +void mdns_query_results_free(mdns_result_t * results); /** - * @brief Stop mDNS Query started with timeout = 0 + * @brief Query mDNS for service * - * @param server mDNS Server + * @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 the number of results found + * @return + * - ESP_OK success + * - ESP_ERR_INVALID_STATE mDNS is not running + * - ESP_ERR_NO_MEM memory error + * - ESP_ERR_INVALID_ARG parameter error */ -size_t mdns_query_end(mdns_server_t * server); +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 get the number of results currently in memoty + * @brief Query mDNS for SRV record * - * @param server mDNS Server + * @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 the number of results + * @return + * - ESP_OK success + * - ESP_ERR_INVALID_STATE mDNS is not running + * - ESP_ERR_NO_MEM memory error + * - ESP_ERR_INVALID_ARG parameter error */ -size_t mdns_result_get_count(mdns_server_t * server); +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 Get mDNS Search result with given index + * @brief Query mDNS for TXT record * - * @param server mDNS Server - * @param num the index of the result + * @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 the result or NULL if error + * @return + * - ESP_OK success + * - ESP_ERR_INVALID_STATE mDNS is not running + * - ESP_ERR_NO_MEM memory error + * - ESP_ERR_INVALID_ARG parameter error */ -const mdns_result_t * mdns_result_get(mdns_server_t * server, size_t num); +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 Remove and free all search results from mDNS server + * @brief Query mDNS for A record * - * @param server mDNS Server + * @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_ARG Parameter error + * - 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_result_free(mdns_server_t * server); +esp_err_t mdns_handle_system_event(void *ctx, system_event_t *event); #ifdef __cplusplus } diff --git a/tools/sdk/include/mdns/mdns_console.h b/tools/sdk/include/mdns/mdns_console.h new file mode 100644 index 0000000000000000000000000000000000000000..5c8b0b5a49ed4630e48e62285875135b8d898983 --- /dev/null +++ b/tools/sdk/include/mdns/mdns_console.h @@ -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_ */ diff --git a/tools/sdk/include/soc/soc/ledc_struct.h b/tools/sdk/include/soc/soc/ledc_struct.h index dd3c364bd4a021c20fd3446caf1a7d39b1bf0eef..4c87dfc2654995b5d0b1461d44abed0143194b6e 100644 --- a/tools/sdk/include/soc/soc/ledc_struct.h +++ b/tools/sdk/include/soc/soc/ledc_struct.h @@ -69,13 +69,18 @@ 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 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; + 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; diff --git a/tools/sdk/include/soc/soc/rtc.h b/tools/sdk/include/soc/soc/rtc.h index 1b64d0073db8d5fda88002737d5f046380a7fa70..fa34caaa8f13a99c00f28bd2c025c3e9ae4442e5 100644 --- a/tools/sdk/include/soc/soc/rtc.h +++ b/tools/sdk/include/soc/soc/rtc.h @@ -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 diff --git a/tools/sdk/include/soc/soc/rtc_cntl_reg.h b/tools/sdk/include/soc/soc/rtc_cntl_reg.h index ffcbb3c0338294b4ffd074e2456238b7eaf120d9..d54a7dde7cf44c45ebd6a0b333086bf76f3c6efe 100644 --- a/tools/sdk/include/soc/soc/rtc_cntl_reg.h +++ b/tools/sdk/include/soc/soc/rtc_cntl_reg.h @@ -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 diff --git a/tools/sdk/include/soc/soc/rtc_i2c_reg.h b/tools/sdk/include/soc/soc/rtc_i2c_reg.h new file mode 100644 index 0000000000000000000000000000000000000000..be7b64c6b1c1e92365ca59483150ef6198822c3f --- /dev/null +++ b/tools/sdk/include/soc/soc/rtc_i2c_reg.h @@ -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 + diff --git a/tools/sdk/include/soc/soc/soc.h b/tools/sdk/include/soc/soc/soc.h index 8121e33b06203e8c5848c5cf9eb84aa6cd1ee5d1..7c7517d463ada69a3884471e3712fd915aef3827 100644 --- a/tools/sdk/include/soc/soc/soc.h +++ b/tools/sdk/include/soc/soc/soc.h @@ -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 diff --git a/tools/sdk/include/soc/soc/soc_ulp.h b/tools/sdk/include/soc/soc/soc_ulp.h index ad1f4f50cdfbbe59166b39bcc0e70f7d064ea450..e8c20d2b565fcaea5fe23971b9839915631b8b58 100644 --- a/tools/sdk/include/soc/soc/soc_ulp.h +++ b/tools/sdk/include/soc/soc/soc_ulp.h @@ -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) \ diff --git a/tools/sdk/include/soc/soc/uart_reg.h b/tools/sdk/include/soc/soc/uart_reg.h index 9d5ba2fb19059fcb57171d8eb11c6c01fc73df56..33b6e998edfd9c2c82825d4f72d2ffdcbda10693 100644 --- a/tools/sdk/include/soc/soc/uart_reg.h +++ b/tools/sdk/include/soc/soc/uart_reg.h @@ -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 ; */ diff --git a/tools/sdk/include/soc/soc/uart_struct.h b/tools/sdk/include/soc/soc/uart_struct.h index eb14620aa10fb3343965e818d3e1877006674d0f..59b84d2afc28244df04a3211fb7a2c9b5d57ebb6 100644 --- a/tools/sdk/include/soc/soc/uart_struct.h +++ b/tools/sdk/include/soc/soc/uart_struct.h @@ -332,8 +332,14 @@ typedef volatile struct { } mem_tx_status; union { struct { - uint32_t status:24; - uint32_t reserved24: 8; + 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; diff --git a/tools/sdk/include/spiffs/spiffs_config.h b/tools/sdk/include/spiffs/spiffs_config.h index e412bfd0cfaa85c0dd2c8fddd3066ca871204350..28414facf9f302226a82a064a86f28ffbd833726 100755 --- a/tools/sdk/include/spiffs/spiffs_config.h +++ b/tools/sdk/include/spiffs/spiffs_config.h @@ -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 diff --git a/tools/sdk/include/tcpip_adapter/tcpip_adapter.h b/tools/sdk/include/tcpip_adapter/tcpip_adapter.h index d7ee00ea0990b8bdeb5956ce6cd05a8adf9a6682..ab095c87aeb447366af1cf87b8aeb5721db62e69 100644 --- a/tools/sdk/include/tcpip_adapter/tcpip_adapter.h +++ b/tools/sdk/include/tcpip_adapter/tcpip_adapter.h @@ -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 diff --git a/tools/sdk/include/ulp/esp32/ulp.h b/tools/sdk/include/ulp/esp32/ulp.h index 302a47a0ca8f7a08f3bcd316e1c3d2a11539ce8f..64bfff8c4591304f163b2ffeae537c1b43c7b42d 100644 --- a/tools/sdk/include/ulp/esp32/ulp.h +++ b/tools/sdk/include/ulp/esp32/ulp.h @@ -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) diff --git a/tools/sdk/ld/esp32.ld b/tools/sdk/ld/esp32.ld index 2df1b3e891f8a0c1a9f4cf21578ab5f0d13d2b54..ee41f7479316f0705a3a3620f918bd978f4eee82 100644 --- a/tools/sdk/ld/esp32.ld +++ b/tools/sdk/ld/esp32.ld @@ -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 diff --git a/tools/sdk/ld/esp32_out.ld b/tools/sdk/ld/esp32_out.ld index a62f4e47e0fc81683ffeac185d5231387fab654b..f82b39fcad969dc4589d531bfadf580f16051100 100644 --- a/tools/sdk/ld/esp32_out.ld +++ b/tools/sdk/ld/esp32_out.ld @@ -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.) */ diff --git a/tools/sdk/lib/libapp_trace.a b/tools/sdk/lib/libapp_trace.a index 6fca2e6331167e8f684344e3607e1b04ddcd21b3..4e0a660214dbd2dbde4aa8e579a743f83354349a 100644 Binary files a/tools/sdk/lib/libapp_trace.a and b/tools/sdk/lib/libapp_trace.a differ diff --git a/tools/sdk/lib/libapp_update.a b/tools/sdk/lib/libapp_update.a index b30314108bb9c990dc4d1cd35afcaf10b874e28a..f46914f2bcb2b8a49bc9eb573e687bf86e40f908 100644 Binary files a/tools/sdk/lib/libapp_update.a and b/tools/sdk/lib/libapp_update.a differ diff --git a/tools/sdk/lib/libbootloader_support.a b/tools/sdk/lib/libbootloader_support.a index 2c2fc15e0c2c668bf4891c33d7a6e41485dc0335..4ba1836e837f55d7d84e53a4c36ca8367c3d10fa 100644 Binary files a/tools/sdk/lib/libbootloader_support.a and b/tools/sdk/lib/libbootloader_support.a differ diff --git a/tools/sdk/lib/libbt.a b/tools/sdk/lib/libbt.a index b2bd9943f18d0af3a1e6be5561689730281f4f1d..20c4efca108d910bcb08a7cb4a5f70adc324b420 100644 Binary files a/tools/sdk/lib/libbt.a and b/tools/sdk/lib/libbt.a differ diff --git a/tools/sdk/lib/libbtdm_app.a b/tools/sdk/lib/libbtdm_app.a old mode 100644 new mode 100755 index 60ba1203185a262a7878452bfb3159014a192315..dcd39cf786494598f6ce29d99be3f91fab8257b0 Binary files a/tools/sdk/lib/libbtdm_app.a and b/tools/sdk/lib/libbtdm_app.a differ diff --git a/tools/sdk/lib/libcoap.a b/tools/sdk/lib/libcoap.a index 2b793045e66096ad840b52fa5953c9af9c9a0c46..fe7c3c1954b427ee0cb1d0602f7d012385e2a8fb 100644 Binary files a/tools/sdk/lib/libcoap.a and b/tools/sdk/lib/libcoap.a differ diff --git a/tools/sdk/lib/libcoexist.a b/tools/sdk/lib/libcoexist.a index b49186ac82de87c6eba794b6a6c5cafa35f461cb..ae6dd2e007cb0716a52cdb0218ad5858861c6129 100644 Binary files a/tools/sdk/lib/libcoexist.a and b/tools/sdk/lib/libcoexist.a differ diff --git a/tools/sdk/lib/libconsole.a b/tools/sdk/lib/libconsole.a index 0266c64cf679e0c83285b3d43fba48eed87b31fc..db306970315cb982029dcb2aeb88cd290010f389 100644 Binary files a/tools/sdk/lib/libconsole.a and b/tools/sdk/lib/libconsole.a differ diff --git a/tools/sdk/lib/libcore.a b/tools/sdk/lib/libcore.a index 8e3eadeafc4dd2445e0c2b6087666502a70e6fb1..eb422ca05ccb0ec8d092ccd2622c9c7fbc866022 100644 Binary files a/tools/sdk/lib/libcore.a and b/tools/sdk/lib/libcore.a differ diff --git a/tools/sdk/lib/libcxx.a b/tools/sdk/lib/libcxx.a index 8b4e5df76160d7f2cfa90d64267a5887d97a6828..47f2e8b06d9b7013d08d791fbd7276c371b855c6 100644 Binary files a/tools/sdk/lib/libcxx.a and b/tools/sdk/lib/libcxx.a differ diff --git a/tools/sdk/lib/libdriver.a b/tools/sdk/lib/libdriver.a index 2156e98644125486df08e883a8ea6e68ec8e0380..c5a92ccf2c1614791af7a1bd8088e8a0cb25b802 100644 Binary files a/tools/sdk/lib/libdriver.a and b/tools/sdk/lib/libdriver.a differ diff --git a/tools/sdk/lib/libesp32.a b/tools/sdk/lib/libesp32.a index 4cfe844095dac1d6f3ea3b7cc6c6ba96cc9eceba..85489a5a622ed6051db55b5e998fbb235db75c58 100644 Binary files a/tools/sdk/lib/libesp32.a and b/tools/sdk/lib/libesp32.a differ diff --git a/tools/sdk/lib/libesp_adc_cal.a b/tools/sdk/lib/libesp_adc_cal.a index cba11fe3842f89ab1c4933f24a4c0faf502f690b..c2a90f3f3624d42f9b63afe3038b3f8921f0c260 100644 Binary files a/tools/sdk/lib/libesp_adc_cal.a and b/tools/sdk/lib/libesp_adc_cal.a differ diff --git a/tools/sdk/lib/libespnow.a b/tools/sdk/lib/libespnow.a index a6816e490774199f0fc61ff45de5193ddbacaec6..e493e8ff87c6765b621eeaf953316fafa87cacf4 100644 Binary files a/tools/sdk/lib/libespnow.a and b/tools/sdk/lib/libespnow.a differ diff --git a/tools/sdk/lib/libethernet.a b/tools/sdk/lib/libethernet.a index 08d425fe7e0454fecb1d96fcc633bb5dcf7dbdaa..6fe908d5db9ce9ea3788245c954b616f6ff88b3b 100644 Binary files a/tools/sdk/lib/libethernet.a and b/tools/sdk/lib/libethernet.a differ diff --git a/tools/sdk/lib/libexpat.a b/tools/sdk/lib/libexpat.a index 7aaba1a315a0d423984c960d585fb62eaeb06890..891639bc2d5c12bcd543af71181b4251c098d491 100644 Binary files a/tools/sdk/lib/libexpat.a and b/tools/sdk/lib/libexpat.a differ diff --git a/tools/sdk/lib/libfatfs.a b/tools/sdk/lib/libfatfs.a index bdf3fcbc993e2e11dd9f293bd60a3a3afbacfad7..9cf48b25a3856d58793aac9180b279eada7fc1da 100644 Binary files a/tools/sdk/lib/libfatfs.a and b/tools/sdk/lib/libfatfs.a differ diff --git a/tools/sdk/lib/libfreertos.a b/tools/sdk/lib/libfreertos.a index 545916a7bb77dbd80dd6fe265394b2879df746af..e164855a7552f15d8fdf5e62c5be940ffa977c03 100644 Binary files a/tools/sdk/lib/libfreertos.a and b/tools/sdk/lib/libfreertos.a differ diff --git a/tools/sdk/lib/libheap.a b/tools/sdk/lib/libheap.a index 32d461e6abf532d8fa50d7ca2817b9cd96c41f41..a1d55f831ce20412cb0a24f541baa47d7cb7e847 100644 Binary files a/tools/sdk/lib/libheap.a and b/tools/sdk/lib/libheap.a differ diff --git a/tools/sdk/lib/libjsmn.a b/tools/sdk/lib/libjsmn.a index b222f17abd14ac982df0b05bb3fd387d182fa65a..3f2c9cbd27b26098428971f8d8737486b6a7d1e8 100644 Binary files a/tools/sdk/lib/libjsmn.a and b/tools/sdk/lib/libjsmn.a differ diff --git a/tools/sdk/lib/libjson.a b/tools/sdk/lib/libjson.a index 3c6e1d3c058e5901db038e50fd5c190f0cd9243f..2e2ab6718d496da99741525e4924dd94da17d34f 100644 Binary files a/tools/sdk/lib/libjson.a and b/tools/sdk/lib/libjson.a differ diff --git a/tools/sdk/lib/liblog.a b/tools/sdk/lib/liblog.a index 8d762d5e016a04b1ab778595267836c6187ee365..25372e128d17babfdbd7c9fc8d750ffde4b97c64 100644 Binary files a/tools/sdk/lib/liblog.a and b/tools/sdk/lib/liblog.a differ diff --git a/tools/sdk/lib/liblwip.a b/tools/sdk/lib/liblwip.a index 2417a2080d51d91bec82396aee5b4f5d6f4f025b..3c5a76557cacb1d34e21ecc743341f27584b4025 100644 Binary files a/tools/sdk/lib/liblwip.a and b/tools/sdk/lib/liblwip.a differ diff --git a/tools/sdk/lib/libmbedtls.a b/tools/sdk/lib/libmbedtls.a index 3b00c14bbc5ab5f288f8f49cfc96c09b510f4344..dbb6941f5514bf16091b42a1dfd8a1a527751953 100644 Binary files a/tools/sdk/lib/libmbedtls.a and b/tools/sdk/lib/libmbedtls.a differ diff --git a/tools/sdk/lib/libmdns.a b/tools/sdk/lib/libmdns.a index d4be71550550723bc2b599d66ac9e4f82ce93903..9366fba3f883d7409d24f10a0720310c50641dd9 100644 Binary files a/tools/sdk/lib/libmdns.a and b/tools/sdk/lib/libmdns.a differ diff --git a/tools/sdk/lib/libmicro-ecc.a b/tools/sdk/lib/libmicro-ecc.a index 749321b1679725db36589dcee0e46c869f08c8fb..5cf419baf1bc8cb2f187506024278f7e62a822ee 100644 Binary files a/tools/sdk/lib/libmicro-ecc.a and b/tools/sdk/lib/libmicro-ecc.a differ diff --git a/tools/sdk/lib/libnet80211.a b/tools/sdk/lib/libnet80211.a index bd1cfeba67093c2f66e2104114bb8185972650fa..bbe5fa2f0ec47ee11945c39f2f851d35573909c3 100644 Binary files a/tools/sdk/lib/libnet80211.a and b/tools/sdk/lib/libnet80211.a differ diff --git a/tools/sdk/lib/libnewlib.a b/tools/sdk/lib/libnewlib.a index 034dade34b8c0b369fd90c929c4f47d7230bddcb..87859426055b9669d3308fb5478b64b2a3ac0ddd 100644 Binary files a/tools/sdk/lib/libnewlib.a and b/tools/sdk/lib/libnewlib.a differ diff --git a/tools/sdk/lib/libnghttp.a b/tools/sdk/lib/libnghttp.a index c6ec119679075794aaafea8d6e8bb574db18b6d2..0400061e48379c82481b234c2f102d628a7e1eda 100644 Binary files a/tools/sdk/lib/libnghttp.a and b/tools/sdk/lib/libnghttp.a differ diff --git a/tools/sdk/lib/libnvs_flash.a b/tools/sdk/lib/libnvs_flash.a index 2933b77c360dec5a175055f16f6d2c3220460313..eb94e5f1279bfca3c907725b22b6326f205854ea 100644 Binary files a/tools/sdk/lib/libnvs_flash.a and b/tools/sdk/lib/libnvs_flash.a differ diff --git a/tools/sdk/lib/libopenssl.a b/tools/sdk/lib/libopenssl.a index 30b96881cf97e91f48bd891e4b4c6f5967aa81ce..4b2409c94d943c7c40b6bdd4784b971274695e5f 100644 Binary files a/tools/sdk/lib/libopenssl.a and b/tools/sdk/lib/libopenssl.a differ diff --git a/tools/sdk/lib/libphy.a b/tools/sdk/lib/libphy.a old mode 100755 new mode 100644 index 457c60cac74a4a6d7b94c90297c5d56cf8eae9fc..a81ce42a2c38929060977b3d9712f364ac0a5b39 Binary files a/tools/sdk/lib/libphy.a and b/tools/sdk/lib/libphy.a differ diff --git a/tools/sdk/lib/libpp.a b/tools/sdk/lib/libpp.a index baa26928c928a2b79fa1d7b6e86c46f05590735e..8b7783c9e9077575d1856d173d9dead34b9acf53 100644 Binary files a/tools/sdk/lib/libpp.a and b/tools/sdk/lib/libpp.a differ diff --git a/tools/sdk/lib/libpthread.a b/tools/sdk/lib/libpthread.a index 221569e327007972e563e9ac0454b82ae3f946f7..8e7e3f555745f8c910fea0f16d4aa172494b5361 100644 Binary files a/tools/sdk/lib/libpthread.a and b/tools/sdk/lib/libpthread.a differ diff --git a/tools/sdk/lib/librtc.a b/tools/sdk/lib/librtc.a old mode 100755 new mode 100644 index 7998bdca3b8c681ac559a8e5ad9fe04df7e0f25b..b1c0a7454db8f1be5b3d4e6fa7770a08c15b2b51 Binary files a/tools/sdk/lib/librtc.a and b/tools/sdk/lib/librtc.a differ diff --git a/tools/sdk/lib/libsdmmc.a b/tools/sdk/lib/libsdmmc.a index dba1a57526665407440a291ce46f2fb9e128d66e..a483ffc649fda13192ec703f34042ca9f57012b9 100644 Binary files a/tools/sdk/lib/libsdmmc.a and b/tools/sdk/lib/libsdmmc.a differ diff --git a/tools/sdk/lib/libsmartconfig.a b/tools/sdk/lib/libsmartconfig.a index 2738eb017c9004bd759b7e0d0029ed0272f56ef1..1d9be7eb536b0d96ab5cf2aa74ccd4c48a401890 100644 Binary files a/tools/sdk/lib/libsmartconfig.a and b/tools/sdk/lib/libsmartconfig.a differ diff --git a/tools/sdk/lib/libsoc.a b/tools/sdk/lib/libsoc.a index f867b9e12a47658970c77549dfc4e71cf5e732ba..f0fcdde8d2a2cb2df602206d127a9defe70aa714 100644 Binary files a/tools/sdk/lib/libsoc.a and b/tools/sdk/lib/libsoc.a differ diff --git a/tools/sdk/lib/libspi_flash.a b/tools/sdk/lib/libspi_flash.a index 067d943cd6ba465e107a3d9de7c3b563b2676e4e..9c663b1f49b90e6d26d53e890883518b7e2f6edb 100644 Binary files a/tools/sdk/lib/libspi_flash.a and b/tools/sdk/lib/libspi_flash.a differ diff --git a/tools/sdk/lib/libspiffs.a b/tools/sdk/lib/libspiffs.a index a0c14037ec1d1ec0bc2cb0e2babe4ce8f45a31a8..ff0bb884452b03c311e87d261acc0be0e0cbe1b4 100644 Binary files a/tools/sdk/lib/libspiffs.a and b/tools/sdk/lib/libspiffs.a differ diff --git a/tools/sdk/lib/libtcpip_adapter.a b/tools/sdk/lib/libtcpip_adapter.a index bd173c64fd5a91fa31f0a0827743920c76e6b770..eef9a4dd49a4ffd6580f2dbbfee66fbb246834da 100644 Binary files a/tools/sdk/lib/libtcpip_adapter.a and b/tools/sdk/lib/libtcpip_adapter.a differ diff --git a/tools/sdk/lib/libulp.a b/tools/sdk/lib/libulp.a index 34be65afd1758a8f685d3a0c3b0686c086e6aabb..7221e560fda5ce058abf6b3fb45763764e6a5a08 100644 Binary files a/tools/sdk/lib/libulp.a and b/tools/sdk/lib/libulp.a differ diff --git a/tools/sdk/lib/libvfs.a b/tools/sdk/lib/libvfs.a index 4340da531e61f09488b48b5aee697e86074df3ae..ad6aa5518f53082febe9bbf7ab57026aaa1cbcf6 100644 Binary files a/tools/sdk/lib/libvfs.a and b/tools/sdk/lib/libvfs.a differ diff --git a/tools/sdk/lib/libwear_levelling.a b/tools/sdk/lib/libwear_levelling.a index 65bc9194046b0a53ccd6246ad936b7c7411bb877..1d88fafffed342cb7e68b65f8ee20320eeedae45 100644 Binary files a/tools/sdk/lib/libwear_levelling.a and b/tools/sdk/lib/libwear_levelling.a differ diff --git a/tools/sdk/lib/libwpa.a b/tools/sdk/lib/libwpa.a index a2ce6e2cb9f0a53b42c894f63eff307c3eebe0e1..6379272d1b45720a99ef60ffb06198182490594c 100644 Binary files a/tools/sdk/lib/libwpa.a and b/tools/sdk/lib/libwpa.a differ diff --git a/tools/sdk/lib/libwpa2.a b/tools/sdk/lib/libwpa2.a index c9f98aa8a5ec8f42e953fe850ef4181b8900f3be..04aa7e937bff3b4e97a5c08204f027454938c1dc 100644 Binary files a/tools/sdk/lib/libwpa2.a and b/tools/sdk/lib/libwpa2.a differ diff --git a/tools/sdk/lib/libwpa_supplicant.a b/tools/sdk/lib/libwpa_supplicant.a index 7373f73743b31100be0b59185fe2b8527c8be5ce..b850776e712f25043b365f1f5d414d3ce0e1adcb 100644 Binary files a/tools/sdk/lib/libwpa_supplicant.a and b/tools/sdk/lib/libwpa_supplicant.a differ diff --git a/tools/sdk/lib/libwps.a b/tools/sdk/lib/libwps.a index bbf2b54cff7cfa7631bd21c9e5da42813318b127..6a3f9aa9c565eb1c74e7dfd60472cba641afbcaa 100644 Binary files a/tools/sdk/lib/libwps.a and b/tools/sdk/lib/libwps.a differ diff --git a/tools/sdk/lib/libxtensa-debug-module.a b/tools/sdk/lib/libxtensa-debug-module.a index 3b66bd419a0f9be3c2966123161a56cfa7670716..b7fa7aa6ceb4960cadc13fde0b09a9f50aff980b 100644 Binary files a/tools/sdk/lib/libxtensa-debug-module.a and b/tools/sdk/lib/libxtensa-debug-module.a differ diff --git a/tools/sdk/sdkconfig b/tools/sdk/sdkconfig index 09f3b3c59f45dc1408499e423be5256694613bd1..8f879fa8c3d6cf1658020e8b82a12054ca807cfe 100644 --- a/tools/sdk/sdkconfig +++ b/tools/sdk/sdkconfig @@ -92,7 +92,8 @@ CONFIG_OPTIMIZATION_LEVEL_RELEASE= CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED=y CONFIG_OPTIMIZATION_ASSERTIONS_SILENT= CONFIG_OPTIMIZATION_ASSERTIONS_DISABLED= -CONFIG_CXX_EXCEPTIONS= +CONFIG_CXX_EXCEPTIONS=y +CONFIG_CXX_EXCEPTIONS_EMG_POOL_SIZE=0 CONFIG_STACK_CHECK_NONE= CONFIG_STACK_CHECK_NORM=y CONFIG_STACK_CHECK_STRONG= @@ -204,7 +205,7 @@ CONFIG_ESP32_PANIC_PRINT_HALT= CONFIG_ESP32_PANIC_PRINT_REBOOT=y CONFIG_ESP32_PANIC_SILENT_REBOOT= CONFIG_ESP32_PANIC_GDBSTUB= -CONFIG_ESP32_DEBUG_OCDAWARE= +CONFIG_ESP32_DEBUG_OCDAWARE=y CONFIG_INT_WDT=y CONFIG_INT_WDT_TIMEOUT_MS=300 CONFIG_INT_WDT_CHECK_CPU1=y @@ -223,8 +224,8 @@ CONFIG_BROWNOUT_DET_LVL_SEL_5= CONFIG_BROWNOUT_DET_LVL_SEL_6= CONFIG_BROWNOUT_DET_LVL_SEL_7= CONFIG_BROWNOUT_DET_LVL=0 -CONFIG_ESP32_TIME_SYSCALL_USE_RTC= CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1=y +CONFIG_ESP32_TIME_SYSCALL_USE_RTC= CONFIG_ESP32_TIME_SYSCALL_USE_FRC1= CONFIG_ESP32_TIME_SYSCALL_USE_NONE= CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC=y @@ -236,6 +237,8 @@ CONFIG_ESP32_XTAL_FREQ_26= CONFIG_ESP32_XTAL_FREQ_AUTO=y CONFIG_ESP32_XTAL_FREQ=0 CONFIG_DISABLE_BASIC_ROM_CONSOLE= +CONFIG_ESP_TIMER_PROFILING= +CONFIG_COMPATIBLE_PRE_V2_1_BOOTLOADERS= # # Wi-Fi @@ -378,6 +381,12 @@ CONFIG_LWIP_STATS= CONFIG_LWIP_ETHARP_TRUST_IP_MAC=y CONFIG_TCPIP_RECVMBOX_SIZE=32 CONFIG_LWIP_DHCP_DOES_ARP_CHECK= + +# +# DHCP server +# +CONFIG_LWIP_DHCPS_LEASE_UNIT=60 +CONFIG_LWIP_DHCPS_MAX_STATION_NUM=8 CONFIG_LWIP_AUTOIP= CONFIG_LWIP_NETIF_LOOPBACK=y CONFIG_LWIP_LOOPBACK_MAX_PBUFS=8 @@ -511,6 +520,7 @@ CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT=2048 # # SPI Flash driver # +CONFIG_SPI_FLASH_VERIFY_WRITE= CONFIG_SPI_FLASH_ENABLE_COUNTERS= CONFIG_SPI_FLASH_ROM_DRIVER_PATCH=y CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS=y @@ -534,6 +544,8 @@ CONFIG_SPIFFS_GC_STATS= CONFIG_SPIFFS_OBJ_NAME_LEN=32 CONFIG_SPIFFS_USE_MAGIC=y CONFIG_SPIFFS_USE_MAGIC_LENGTH=y +CONFIG_SPIFFS_META_LENGTH=4 +CONFIG_SPIFFS_USE_MTIME=y # # Debug Configuration