diff --git a/CMakeLists.txt b/CMakeLists.txt index cd228a07def..56dc43fb186 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -174,7 +174,7 @@ set(includedirs set(srcs ${CORE_SRCS} ${LIBRARY_SRCS} ${BLE_SRCS}) set(priv_includes cores/esp32/libb64) set(requires spi_flash mbedtls mdns esp_adc_cal wifi_provisioning nghttp) -set(priv_requires fatfs nvs_flash app_update spiffs bootloader_support openssl bt esp_ipc) +set(priv_requires fatfs nvs_flash app_update spiffs bootloader_support openssl bt esp_ipc esp_hid) idf_component_register(INCLUDE_DIRS ${includedirs} PRIV_INCLUDE_DIRS ${priv_includes} SRCS ${srcs} REQUIRES ${requires} PRIV_REQUIRES ${priv_requires}) diff --git a/cores/esp32/FirmwareMSC.cpp b/cores/esp32/FirmwareMSC.cpp index 473e220bd83..e4703f96e27 100644 --- a/cores/esp32/FirmwareMSC.cpp +++ b/cores/esp32/FirmwareMSC.cpp @@ -227,7 +227,7 @@ static esp_err_t msc_update_write(const esp_partition_t *partition, uint32_t off //called when error was encountered while updating static void msc_update_error(){ log_e("UPDATE_ERROR: %u", msc_update_bytes_written); - arduino_firmware_msc_event_data_t p = {0}; + arduino_firmware_msc_event_data_t p; p.error.size = msc_update_bytes_written; arduino_usb_event_post(ARDUINO_FIRMWARE_MSC_EVENTS, ARDUINO_FIRMWARE_MSC_ERROR_EVENT, &p, sizeof(arduino_firmware_msc_event_data_t), portMAX_DELAY); msc_update_state = MSC_UPDATE_IDLE; @@ -251,7 +251,7 @@ static void msc_update_end(){ msc_update_error(); return; } - arduino_firmware_msc_event_data_t p = {0}; + arduino_firmware_msc_event_data_t p; p.end.size = msc_update_entry->file_size; arduino_usb_event_post(ARDUINO_FIRMWARE_MSC_EVENTS, ARDUINO_FIRMWARE_MSC_END_EVENT, &p, sizeof(arduino_firmware_msc_event_data_t), portMAX_DELAY); } @@ -289,7 +289,7 @@ static int32_t msc_write(uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_ } } else if(msc_ota_partition && lba >= msc_update_start_sector){ //handle writes to the region where the new firmware will be uploaded - arduino_firmware_msc_event_data_t p = {0}; + arduino_firmware_msc_event_data_t p; if(msc_update_state <= MSC_UPDATE_STARTING && buffer[0] == 0xE9){ msc_update_state = MSC_UPDATE_RUNNING; msc_update_start_sector = lba; @@ -345,7 +345,7 @@ static int32_t msc_read(uint32_t lba, uint32_t offset, void* buffer, uint32_t bu static bool msc_start_stop(uint8_t power_condition, bool start, bool load_eject){ //log_d("power: %u, start: %u, eject: %u", power_condition, start, load_eject); - arduino_firmware_msc_event_data_t p = {0}; + arduino_firmware_msc_event_data_t p; p.power.power_condition = power_condition; p.power.start = start; p.power.load_eject = load_eject; diff --git a/cores/esp32/HWCDC.cpp b/cores/esp32/HWCDC.cpp index f2639a1f008..3f6927dda27 100644 --- a/cores/esp32/HWCDC.cpp +++ b/cores/esp32/HWCDC.cpp @@ -169,7 +169,7 @@ void HWCDC::begin(unsigned long baud) usb_serial_jtag_ll_clr_intsts_mask(USB_SERIAL_JTAG_INTR_SERIAL_IN_EMPTY | USB_SERIAL_JTAG_INTR_SERIAL_OUT_RECV_PKT | USB_SERIAL_JTAG_INTR_BUS_RESET); usb_serial_jtag_ll_ena_intr_mask(USB_SERIAL_JTAG_INTR_SERIAL_IN_EMPTY | USB_SERIAL_JTAG_INTR_SERIAL_OUT_RECV_PKT | USB_SERIAL_JTAG_INTR_BUS_RESET); - if(!intr_handle && esp_intr_alloc(ETS_USB_INTR_SOURCE/*ETS_USB_SERIAL_JTAG_INTR_SOURCE*/, 0, hw_cdc_isr_handler, NULL, &intr_handle) != ESP_OK){ + if(!intr_handle && esp_intr_alloc(ETS_USB_SERIAL_JTAG_INTR_SOURCE, 0, hw_cdc_isr_handler, NULL, &intr_handle) != ESP_OK){ isr_log_e("HW USB CDC failed to init interrupts"); end(); return; diff --git a/cores/esp32/USB.cpp b/cores/esp32/USB.cpp index 1f652c6232b..5bf78b3bc27 100644 --- a/cores/esp32/USB.cpp +++ b/cores/esp32/USB.cpp @@ -86,14 +86,14 @@ static bool tinyusb_device_suspended = false; // Invoked when device is mounted (configured) void tud_mount_cb(void){ tinyusb_device_mounted = true; - arduino_usb_event_data_t p = {0}; + arduino_usb_event_data_t p; arduino_usb_event_post(ARDUINO_USB_EVENTS, ARDUINO_USB_STARTED_EVENT, &p, sizeof(arduino_usb_event_data_t), portMAX_DELAY); } // Invoked when device is unmounted void tud_umount_cb(void){ tinyusb_device_mounted = false; - arduino_usb_event_data_t p = {0}; + arduino_usb_event_data_t p; arduino_usb_event_post(ARDUINO_USB_EVENTS, ARDUINO_USB_STOPPED_EVENT, &p, sizeof(arduino_usb_event_data_t), portMAX_DELAY); } @@ -101,7 +101,7 @@ void tud_umount_cb(void){ // Within 7ms, device must draw an average of current less than 2.5 mA from bus void tud_suspend_cb(bool remote_wakeup_en){ tinyusb_device_suspended = true; - arduino_usb_event_data_t p = {0}; + arduino_usb_event_data_t p; p.suspend.remote_wakeup_en = remote_wakeup_en; arduino_usb_event_post(ARDUINO_USB_EVENTS, ARDUINO_USB_SUSPEND_EVENT, &p, sizeof(arduino_usb_event_data_t), portMAX_DELAY); } @@ -109,7 +109,7 @@ void tud_suspend_cb(bool remote_wakeup_en){ // Invoked when usb bus is resumed void tud_resume_cb(void){ tinyusb_device_suspended = false; - arduino_usb_event_data_t p = {0}; + arduino_usb_event_data_t p; arduino_usb_event_post(ARDUINO_USB_EVENTS, ARDUINO_USB_RESUME_EVENT, &p, sizeof(arduino_usb_event_data_t), portMAX_DELAY); } diff --git a/cores/esp32/USBCDC.cpp b/cores/esp32/USBCDC.cpp index bb3140035cd..a7b75eada4f 100644 --- a/cores/esp32/USBCDC.cpp +++ b/cores/esp32/USBCDC.cpp @@ -156,7 +156,7 @@ void USBCDC::_onUnplugged(void){ connected = false; dtr = false; rts = false; - arduino_usb_cdc_event_data_t p = {0}; + arduino_usb_cdc_event_data_t p; arduino_usb_event_post(ARDUINO_USB_CDC_EVENTS, ARDUINO_USB_CDC_DISCONNECTED_EVENT, &p, sizeof(arduino_usb_cdc_event_data_t), portMAX_DELAY); } } @@ -178,7 +178,7 @@ void USBCDC::_onLineState(bool _dtr, bool _rts){ lineState++; if(connected){ connected = false; - arduino_usb_cdc_event_data_t p = {0}; + arduino_usb_cdc_event_data_t p; arduino_usb_event_post(ARDUINO_USB_CDC_EVENTS, ARDUINO_USB_CDC_DISCONNECTED_EVENT, &p, sizeof(arduino_usb_cdc_event_data_t), portMAX_DELAY); } } else { @@ -208,14 +208,14 @@ void USBCDC::_onLineState(bool _dtr, bool _rts){ if(lineState == CDC_LINE_IDLE){ if(dtr && rts && !connected){ connected = true; - arduino_usb_cdc_event_data_t p = {0}; + arduino_usb_cdc_event_data_t p; arduino_usb_event_post(ARDUINO_USB_CDC_EVENTS, ARDUINO_USB_CDC_CONNECTED_EVENT, &p, sizeof(arduino_usb_cdc_event_data_t), portMAX_DELAY); } else if(!dtr && connected){ connected = false; - arduino_usb_cdc_event_data_t p = {0}; + arduino_usb_cdc_event_data_t p; arduino_usb_event_post(ARDUINO_USB_CDC_EVENTS, ARDUINO_USB_CDC_DISCONNECTED_EVENT, &p, sizeof(arduino_usb_cdc_event_data_t), portMAX_DELAY); } - arduino_usb_cdc_event_data_t l = {0}; + arduino_usb_cdc_event_data_t l; l.line_state.dtr = dtr; l.line_state.rts = rts; arduino_usb_event_post(ARDUINO_USB_CDC_EVENTS, ARDUINO_USB_CDC_LINE_STATE_EVENT, &l, sizeof(arduino_usb_cdc_event_data_t), portMAX_DELAY); @@ -233,7 +233,7 @@ void USBCDC::_onLineCoding(uint32_t _bit_rate, uint8_t _stop_bits, uint8_t _pari data_bits = _data_bits; stop_bits = _stop_bits; parity = _parity; - arduino_usb_cdc_event_data_t p = {0}; + arduino_usb_cdc_event_data_t p; p.line_coding.bit_rate = bit_rate; p.line_coding.data_bits = data_bits; p.line_coding.stop_bits = stop_bits; @@ -251,13 +251,13 @@ void USBCDC::_onRX(){ return; } } - arduino_usb_cdc_event_data_t p = {0}; + arduino_usb_cdc_event_data_t p; p.rx.len = count; arduino_usb_event_post(ARDUINO_USB_CDC_EVENTS, ARDUINO_USB_CDC_RX_EVENT, &p, sizeof(arduino_usb_cdc_event_data_t), portMAX_DELAY); } void USBCDC::_onTX(){ - arduino_usb_cdc_event_data_t p = {0}; + arduino_usb_cdc_event_data_t p; arduino_usb_event_post(ARDUINO_USB_CDC_EVENTS, ARDUINO_USB_CDC_TX_EVENT, &p, sizeof(arduino_usb_cdc_event_data_t), portMAX_DELAY); } diff --git a/cores/esp32/esp32-hal-timer.c b/cores/esp32/esp32-hal-timer.c index 13669efcdaa..2375ac60a8d 100644 --- a/cores/esp32/esp32-hal-timer.c +++ b/cores/esp32/esp32-hal-timer.c @@ -90,17 +90,10 @@ typedef void (*voidFuncPtr)(void); static voidFuncPtr __timerInterruptHandlers[4] = {0,0,0,0}; void ARDUINO_ISR_ATTR __timerISR(void * arg){ -#if CONFIG_IDF_TARGET_ESP32 uint32_t s0 = TIMERG0.int_st_timers.val; uint32_t s1 = TIMERG1.int_st_timers.val; TIMERG0.int_clr_timers.val = s0; TIMERG1.int_clr_timers.val = s1; -#else - uint32_t s0 = TIMERG0.int_st.val; - uint32_t s1 = TIMERG1.int_st.val; - TIMERG0.int_clr.val = s0; - TIMERG1.int_clr.val = s1; -#endif uint8_t status = (s1 & 3) << 2 | (s0 & 3); uint8_t i = 4; //restart the timers that should autoreload @@ -239,19 +232,19 @@ hw_timer_t * timerBegin(uint8_t num, uint16_t divider, bool countUp){ } timer->dev->config.enable = 0; if(timer->group) { - TIMERG1.int_ena.val &= ~BIT(timer->timer); #if CONFIG_IDF_TARGET_ESP32 - TIMERG1.int_clr_timers.val |= BIT(timer->timer); + TIMERG1.int_ena.val &= ~BIT(timer->timer); #else - TIMERG1.int_clr.val = BIT(timer->timer); + TIMERG1.int_ena_timers.val &= ~BIT(timer->timer); #endif + TIMERG1.int_clr_timers.val |= BIT(timer->timer); } else { - TIMERG0.int_ena.val &= ~BIT(timer->timer); #if CONFIG_IDF_TARGET_ESP32 - TIMERG0.int_clr_timers.val |= BIT(timer->timer); + TIMERG0.int_ena.val &= ~BIT(timer->timer); #else - TIMERG0.int_clr.val = BIT(timer->timer); + TIMERG0.int_ena_timers.val &= ~BIT(timer->timer); #endif + TIMERG0.int_clr_timers.val |= BIT(timer->timer); } #ifdef TIMER_GROUP_SUPPORTS_XTAL_CLOCK timer->dev->config.use_xtal = 0; @@ -289,19 +282,19 @@ void timerAttachInterrupt(hw_timer_t *timer, void (*fn)(void), bool edge){ timer->dev->config.edge_int_en = 0; timer->dev->config.alarm_en = 0; if(timer->num & 2){ - TIMERG1.int_ena.val &= ~BIT(timer->timer); #if CONFIG_IDF_TARGET_ESP32 - TIMERG1.int_clr_timers.val |= BIT(timer->timer); + TIMERG1.int_ena.val &= ~BIT(timer->timer); #else - TIMERG1.int_clr.val = BIT(timer->timer); + TIMERG1.int_ena_timers.val &= ~BIT(timer->timer); #endif + TIMERG1.int_clr_timers.val |= BIT(timer->timer); } else { - TIMERG0.int_ena.val &= ~BIT(timer->timer); #if CONFIG_IDF_TARGET_ESP32 - TIMERG0.int_clr_timers.val |= BIT(timer->timer); + TIMERG0.int_ena.val &= ~BIT(timer->timer); #else - TIMERG0.int_clr.val = BIT(timer->timer); + TIMERG0.int_ena_timers.val &= ~BIT(timer->timer); #endif + TIMERG0.int_clr_timers.val |= BIT(timer->timer); } __timerInterruptHandlers[timer->num] = NULL; } else { @@ -333,9 +326,17 @@ void timerAttachInterrupt(hw_timer_t *timer, void (*fn)(void), bool edge){ intr_matrix_set(esp_intr_get_cpu(intr_handle), intr_source, esp_intr_get_intno(intr_handle)); } if(timer->group){ +#if CONFIG_IDF_TARGET_ESP32 TIMERG1.int_ena.val |= BIT(timer->timer); +#else + TIMERG1.int_ena_timers.val |= BIT(timer->timer); +#endif } else { +#if CONFIG_IDF_TARGET_ESP32 TIMERG0.int_ena.val |= BIT(timer->timer); +#else + TIMERG0.int_ena_timers.val |= BIT(timer->timer); +#endif } } if(intr_handle){ diff --git a/libraries/USB/src/USBHID.cpp b/libraries/USB/src/USBHID.cpp index 2d497f2266e..cf66d661319 100644 --- a/libraries/USB/src/USBHID.cpp +++ b/libraries/USB/src/USBHID.cpp @@ -230,7 +230,7 @@ uint8_t const * tud_hid_descriptor_report_cb(uint8_t instance){ // protocol is either HID_PROTOCOL_BOOT (0) or HID_PROTOCOL_REPORT (1) void tud_hid_set_protocol_cb(uint8_t instance, uint8_t protocol){ log_v("instance: %u, protocol:%u", instance, protocol); - arduino_usb_hid_event_data_t p = {0}; + arduino_usb_hid_event_data_t p; p.instance = instance; p.set_protocol.protocol = protocol; arduino_usb_event_post(ARDUINO_USB_HID_EVENTS, ARDUINO_USB_HID_SET_PROTOCOL_EVENT, &p, sizeof(arduino_usb_hid_event_data_t), portMAX_DELAY); @@ -241,7 +241,7 @@ void tud_hid_set_protocol_cb(uint8_t instance, uint8_t protocol){ // - Idle Rate > 0 : skip duplication, but send at least 1 report every idle rate (in unit of 4 ms). bool tud_hid_set_idle_cb(uint8_t instance, uint8_t idle_rate){ log_v("instance: %u, idle_rate:%u", instance, idle_rate); - arduino_usb_hid_event_data_t p = {0}; + arduino_usb_hid_event_data_t p; p.instance = instance; p.set_idle.idle_rate = idle_rate; arduino_usb_event_post(ARDUINO_USB_HID_EVENTS, ARDUINO_USB_HID_SET_IDLE_EVENT, &p, sizeof(arduino_usb_hid_event_data_t), portMAX_DELAY); diff --git a/libraries/USB/src/USBHIDKeyboard.cpp b/libraries/USB/src/USBHIDKeyboard.cpp index 9a9445ded89..d7cd5e5e2b1 100644 --- a/libraries/USB/src/USBHIDKeyboard.cpp +++ b/libraries/USB/src/USBHIDKeyboard.cpp @@ -61,7 +61,7 @@ void USBHIDKeyboard::onEvent(arduino_usb_hid_keyboard_event_t event, esp_event_h void USBHIDKeyboard::_onOutput(uint8_t report_id, const uint8_t* buffer, uint16_t len){ if(report_id == HID_REPORT_ID_KEYBOARD){ - arduino_usb_hid_keyboard_event_data_t p = {0}; + arduino_usb_hid_keyboard_event_data_t p; p.leds = buffer[0]; arduino_usb_event_post(ARDUINO_USB_HID_KEYBOARD_EVENTS, ARDUINO_USB_HID_KEYBOARD_LED_EVENT, &p, sizeof(arduino_usb_hid_keyboard_event_data_t), portMAX_DELAY); } diff --git a/libraries/USB/src/USBHIDVendor.cpp b/libraries/USB/src/USBHIDVendor.cpp index 53b0e999d44..aa5b9f0ac7d 100644 --- a/libraries/USB/src/USBHIDVendor.cpp +++ b/libraries/USB/src/USBHIDVendor.cpp @@ -124,7 +124,7 @@ uint16_t USBHIDVendor::_onGetFeature(uint8_t report_id, uint8_t* buffer, uint16_ return 0; } memcpy(buffer, feature, len); - arduino_usb_hid_vendor_event_data_t p = {0}; + arduino_usb_hid_vendor_event_data_t p; p.buffer = feature; p.len = len; arduino_usb_event_post(ARDUINO_USB_HID_VENDOR_EVENTS, ARDUINO_USB_HID_VENDOR_GET_FEATURE_EVENT, &p, sizeof(arduino_usb_hid_vendor_event_data_t), portMAX_DELAY); @@ -136,7 +136,7 @@ void USBHIDVendor::_onSetFeature(uint8_t report_id, const uint8_t* buffer, uint1 return; } memcpy(feature, buffer, len); - arduino_usb_hid_vendor_event_data_t p = {0}; + arduino_usb_hid_vendor_event_data_t p; p.buffer = feature; p.len = len; arduino_usb_event_post(ARDUINO_USB_HID_VENDOR_EVENTS, ARDUINO_USB_HID_VENDOR_SET_FEATURE_EVENT, &p, sizeof(arduino_usb_hid_vendor_event_data_t), portMAX_DELAY); @@ -153,7 +153,7 @@ void USBHIDVendor::_onOutput(uint8_t report_id, const uint8_t* buffer, uint16_t break; } } - arduino_usb_hid_vendor_event_data_t p = {0}; + arduino_usb_hid_vendor_event_data_t p; p.buffer = buffer; p.len = len; arduino_usb_event_post(ARDUINO_USB_HID_VENDOR_EVENTS, ARDUINO_USB_HID_VENDOR_OUTPUT_EVENT, &p, sizeof(arduino_usb_hid_vendor_event_data_t), portMAX_DELAY); diff --git a/libraries/USB/src/USBVendor.cpp b/libraries/USB/src/USBVendor.cpp index 0a91fac9354..c68568d57ae 100644 --- a/libraries/USB/src/USBVendor.cpp +++ b/libraries/USB/src/USBVendor.cpp @@ -146,7 +146,7 @@ void USBVendor::_onRX(const uint8_t* buffer, size_t len){ break; } } - arduino_usb_vendor_event_data_t p = {0}; + arduino_usb_vendor_event_data_t p; p.data.len = len; arduino_usb_event_post(ARDUINO_USB_VENDOR_EVENTS, ARDUINO_USB_VENDOR_DATA_EVENT, &p, sizeof(arduino_usb_vendor_event_data_t), portMAX_DELAY); } diff --git a/platform.txt b/platform.txt index 625acc54600..1b92b64efa8 100644 --- a/platform.txt +++ b/platform.txt @@ -23,12 +23,12 @@ compiler.prefix={build.tarch}-{build.target}-elf- # # ESP32 Support Start # -compiler.cpreprocessor.flags.esp32=-DHAVE_CONFIG_H -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h" -DUNITY_INCLUDE_CONFIG_H -DWITH_POSIX -D_GNU_SOURCE -DIDF_VER="v4.4-dev-2313-gc69f0ec32" -DESP_PLATFORM "-I{compiler.sdk.path}/include/config" "-I{compiler.sdk.path}/include/newlib/platform_include" "-I{compiler.sdk.path}/include/freertos/include" "-I{compiler.sdk.path}/include/freertos/port/xtensa/include" "-I{compiler.sdk.path}/include/esp_hw_support/include" "-I{compiler.sdk.path}/include/esp_hw_support/include/soc" "-I{compiler.sdk.path}/include/esp_hw_support/include/soc/esp32" "-I{compiler.sdk.path}/include/esp_hw_support/port/esp32" "-I{compiler.sdk.path}/include/heap/include" "-I{compiler.sdk.path}/include/log/include" "-I{compiler.sdk.path}/include/lwip/include/apps" "-I{compiler.sdk.path}/include/lwip/include/apps/sntp" "-I{compiler.sdk.path}/include/lwip/lwip/src/include" "-I{compiler.sdk.path}/include/lwip/port/esp32/include" "-I{compiler.sdk.path}/include/lwip/port/esp32/include/arch" "-I{compiler.sdk.path}/include/soc/include" "-I{compiler.sdk.path}/include/soc/esp32" "-I{compiler.sdk.path}/include/soc/esp32/include" "-I{compiler.sdk.path}/include/hal/esp32/include" "-I{compiler.sdk.path}/include/hal/include" "-I{compiler.sdk.path}/include/hal/platform_port/include" "-I{compiler.sdk.path}/include/esp_rom/include" "-I{compiler.sdk.path}/include/esp_rom/esp32" "-I{compiler.sdk.path}/include/esp_rom/include/esp32" "-I{compiler.sdk.path}/include/esp_common/include" "-I{compiler.sdk.path}/include/esp_system/include" "-I{compiler.sdk.path}/include/esp_system/port/soc" "-I{compiler.sdk.path}/include/esp_system/port/public_compat" "-I{compiler.sdk.path}/include/esp32/include" "-I{compiler.sdk.path}/include/xtensa/include" "-I{compiler.sdk.path}/include/xtensa/esp32/include" "-I{compiler.sdk.path}/include/driver/include" "-I{compiler.sdk.path}/include/driver/esp32/include" "-I{compiler.sdk.path}/include/esp_pm/include" "-I{compiler.sdk.path}/include/esp_ringbuf/include" "-I{compiler.sdk.path}/include/efuse/include" "-I{compiler.sdk.path}/include/efuse/esp32/include" "-I{compiler.sdk.path}/include/vfs/include" "-I{compiler.sdk.path}/include/esp_wifi/include" "-I{compiler.sdk.path}/include/esp_event/include" "-I{compiler.sdk.path}/include/esp_netif/include" "-I{compiler.sdk.path}/include/esp_eth/include" "-I{compiler.sdk.path}/include/tcpip_adapter/include" "-I{compiler.sdk.path}/include/esp_phy/include" "-I{compiler.sdk.path}/include/esp_phy/esp32/include" "-I{compiler.sdk.path}/include/app_trace/include" "-I{compiler.sdk.path}/include/esp_timer/include" "-I{compiler.sdk.path}/include/esp_ipc/include" "-I{compiler.sdk.path}/include/mbedtls/port/include" "-I{compiler.sdk.path}/include/mbedtls/mbedtls/include" "-I{compiler.sdk.path}/include/mbedtls/esp_crt_bundle/include" "-I{compiler.sdk.path}/include/app_update/include" "-I{compiler.sdk.path}/include/spi_flash/include" "-I{compiler.sdk.path}/include/bootloader_support/include" "-I{compiler.sdk.path}/include/nvs_flash/include" "-I{compiler.sdk.path}/include/pthread/include" "-I{compiler.sdk.path}/include/esp_gdbstub/include" "-I{compiler.sdk.path}/include/esp_gdbstub/xtensa" "-I{compiler.sdk.path}/include/esp_gdbstub/esp32" "-I{compiler.sdk.path}/include/espcoredump/include" "-I{compiler.sdk.path}/include/espcoredump/include/port/xtensa" "-I{compiler.sdk.path}/include/wpa_supplicant/include" "-I{compiler.sdk.path}/include/wpa_supplicant/port/include" "-I{compiler.sdk.path}/include/wpa_supplicant/include/esp_supplicant" "-I{compiler.sdk.path}/include/ieee802154/include" "-I{compiler.sdk.path}/include/asio/asio/asio/include" "-I{compiler.sdk.path}/include/asio/port/include" "-I{compiler.sdk.path}/include/bt/common/osi/include" "-I{compiler.sdk.path}/include/bt/include/esp32/include" "-I{compiler.sdk.path}/include/bt/common/api/include/api" "-I{compiler.sdk.path}/include/bt/common/btc/profile/esp/blufi/include" "-I{compiler.sdk.path}/include/bt/common/btc/profile/esp/include" "-I{compiler.sdk.path}/include/bt/host/bluedroid/api/include/api" "-I{compiler.sdk.path}/include/cbor/port/include" "-I{compiler.sdk.path}/include/unity/include" "-I{compiler.sdk.path}/include/unity/unity/src" "-I{compiler.sdk.path}/include/cmock/CMock/src" "-I{compiler.sdk.path}/include/coap/port/include" "-I{compiler.sdk.path}/include/coap/port/include/coap" "-I{compiler.sdk.path}/include/coap/libcoap/include" "-I{compiler.sdk.path}/include/coap/libcoap/include/coap2" "-I{compiler.sdk.path}/include/console" "-I{compiler.sdk.path}/include/nghttp/port/include" "-I{compiler.sdk.path}/include/nghttp/nghttp2/lib/includes" "-I{compiler.sdk.path}/include/esp-tls" "-I{compiler.sdk.path}/include/esp-tls/esp-tls-crypto" "-I{compiler.sdk.path}/include/esp_adc_cal/include" "-I{compiler.sdk.path}/include/esp_hid/include" "-I{compiler.sdk.path}/include/tcp_transport/include" "-I{compiler.sdk.path}/include/esp_http_client/include" "-I{compiler.sdk.path}/include/esp_http_server/include" "-I{compiler.sdk.path}/include/esp_https_ota/include" "-I{compiler.sdk.path}/include/esp_lcd/include" "-I{compiler.sdk.path}/include/esp_lcd/interface" "-I{compiler.sdk.path}/include/protobuf-c/protobuf-c" "-I{compiler.sdk.path}/include/protocomm/include/common" "-I{compiler.sdk.path}/include/protocomm/include/security" "-I{compiler.sdk.path}/include/protocomm/include/transports" "-I{compiler.sdk.path}/include/mdns/include" "-I{compiler.sdk.path}/include/esp_local_ctrl/include" "-I{compiler.sdk.path}/include/sdmmc/include" "-I{compiler.sdk.path}/include/esp_serial_slave_link/include" "-I{compiler.sdk.path}/include/esp_websocket_client/include" "-I{compiler.sdk.path}/include/expat/expat/expat/lib" "-I{compiler.sdk.path}/include/expat/port/include" "-I{compiler.sdk.path}/include/wear_levelling/include" "-I{compiler.sdk.path}/include/fatfs/diskio" "-I{compiler.sdk.path}/include/fatfs/vfs" "-I{compiler.sdk.path}/include/fatfs/src" "-I{compiler.sdk.path}/include/freemodbus/common/include" "-I{compiler.sdk.path}/include/idf_test/include" "-I{compiler.sdk.path}/include/idf_test/include/esp32" "-I{compiler.sdk.path}/include/jsmn/include" "-I{compiler.sdk.path}/include/json/cJSON" "-I{compiler.sdk.path}/include/libsodium/libsodium/src/libsodium/include" "-I{compiler.sdk.path}/include/libsodium/port_include" "-I{compiler.sdk.path}/include/mqtt/esp-mqtt/include" "-I{compiler.sdk.path}/include/openssl/include" "-I{compiler.sdk.path}/include/perfmon/include" "-I{compiler.sdk.path}/include/spiffs/include" "-I{compiler.sdk.path}/include/ulp/include" "-I{compiler.sdk.path}/include/wifi_provisioning/include" "-I{compiler.sdk.path}/include/button/button/include" "-I{compiler.sdk.path}/include/json_parser" "-I{compiler.sdk.path}/include/json_parser/jsmn/include" "-I{compiler.sdk.path}/include/json_generator" "-I{compiler.sdk.path}/include/esp_schedule/include" "-I{compiler.sdk.path}/include/esp_rainmaker/include" "-I{compiler.sdk.path}/include/qrcode/include" "-I{compiler.sdk.path}/include/ws2812_led" "-I{compiler.sdk.path}/include/esp_littlefs/src" "-I{compiler.sdk.path}/include/esp_littlefs/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/dotprod/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/support/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/hann/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman_harris/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman_nuttall/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/nuttall/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/flat_top/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/iir/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/fir/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/add/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/sub/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/mul/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/addc/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/mulc/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/sqrt/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/matrix/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/fft/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/dct/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/conv/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/common/include" "-I{compiler.sdk.path}/include/esp-face/face_detection/include" "-I{compiler.sdk.path}/include/esp-face/face_recognition/include" "-I{compiler.sdk.path}/include/esp-face/object_detection/include" "-I{compiler.sdk.path}/include/esp-face/image_util/include" "-I{compiler.sdk.path}/include/esp-face/pose_estimation/include" "-I{compiler.sdk.path}/include/esp-face/lib/include" "-I{compiler.sdk.path}/include/esp32-camera/driver/include" "-I{compiler.sdk.path}/include/esp32-camera/conversions/include" "-I{compiler.sdk.path}/include/fb_gfx/include" -compiler.c.elf.libs.esp32=-lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lasio -lbt -lcbor -lunity -lcmock -lcoap -lconsole -lnghttp -lesp-tls -lesp_adc_cal -lesp_hid -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lesp_lcd -lprotobuf-c -lprotocomm -lmdns -lesp_local_ctrl -lsdmmc -lesp_serial_slave_link -lesp_websocket_client -lexpat -lwear_levelling -lfatfs -lfreemodbus -ljsmn -ljson -llibsodium -lmqtt -lopenssl -lperfmon -lspiffs -lulp -lwifi_provisioning -lbutton -ljson_parser -ljson_generator -lesp_schedule -lesp_rainmaker -lqrcode -lws2812_led -lesp-dsp -lesp-face -lesp32-camera -lesp_littlefs -lfb_gfx -lasio -lcbor -lcmock -lunity -lcoap -lesp_hid -lesp_lcd -lesp_local_ctrl -lesp_websocket_client -lexpat -lfreemodbus -ljsmn -llibsodium -lperfmon -lesp_adc_cal -lfatfs -lwear_levelling -lopenssl -lspiffs -lesp_rainmaker -lmqtt -lwifi_provisioning -lprotocomm -lbt -lbtdm_app -lprotobuf-c -lmdns -lconsole -ljson -ljson_parser -ljson_generator -lesp_schedule -lqrcode -lpe -lfd -lfr -ldetection_cat_face -ldetection -ldl -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lphy -lesp_phy -lphy -lesp_phy -lphy -lrtc -lxt_hal -lm -lnewlib -lstdc++ -lpthread -lgcc -lcxx -lapp_trace -lgcov -lapp_trace -lgcov -lc +compiler.cpreprocessor.flags.esp32=-DHAVE_CONFIG_H -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h" -DUNITY_INCLUDE_CONFIG_H -DWITH_POSIX -D_GNU_SOURCE -DIDF_VER="v4.4-dev-3235-g3e370c4296" -DESP_PLATFORM "-I{compiler.sdk.path}/include/config" "-I{compiler.sdk.path}/include/newlib/platform_include" "-I{compiler.sdk.path}/include/freertos/include" "-I{compiler.sdk.path}/include/freertos/include/esp_additions/freertos" "-I{compiler.sdk.path}/include/freertos/port/xtensa/include" "-I{compiler.sdk.path}/include/freertos/include/esp_additions" "-I{compiler.sdk.path}/include/esp_hw_support/include" "-I{compiler.sdk.path}/include/esp_hw_support/include/soc" "-I{compiler.sdk.path}/include/esp_hw_support/include/soc/esp32" "-I{compiler.sdk.path}/include/esp_hw_support/port/esp32" "-I{compiler.sdk.path}/include/heap/include" "-I{compiler.sdk.path}/include/log/include" "-I{compiler.sdk.path}/include/lwip/include/apps" "-I{compiler.sdk.path}/include/lwip/include/apps/sntp" "-I{compiler.sdk.path}/include/lwip/lwip/src/include" "-I{compiler.sdk.path}/include/lwip/port/esp32/include" "-I{compiler.sdk.path}/include/lwip/port/esp32/include/arch" "-I{compiler.sdk.path}/include/soc/include" "-I{compiler.sdk.path}/include/soc/esp32" "-I{compiler.sdk.path}/include/soc/esp32/include" "-I{compiler.sdk.path}/include/hal/esp32/include" "-I{compiler.sdk.path}/include/hal/include" "-I{compiler.sdk.path}/include/hal/platform_port/include" "-I{compiler.sdk.path}/include/esp_rom/include" "-I{compiler.sdk.path}/include/esp_rom/include/esp32" "-I{compiler.sdk.path}/include/esp_rom/esp32" "-I{compiler.sdk.path}/include/esp_common/include" "-I{compiler.sdk.path}/include/esp_system/include" "-I{compiler.sdk.path}/include/esp_system/port/soc" "-I{compiler.sdk.path}/include/esp_system/port/public_compat" "-I{compiler.sdk.path}/include/esp32/include" "-I{compiler.sdk.path}/include/xtensa/include" "-I{compiler.sdk.path}/include/xtensa/esp32/include" "-I{compiler.sdk.path}/include/driver/include" "-I{compiler.sdk.path}/include/driver/esp32/include" "-I{compiler.sdk.path}/include/esp_pm/include" "-I{compiler.sdk.path}/include/esp_ringbuf/include" "-I{compiler.sdk.path}/include/efuse/include" "-I{compiler.sdk.path}/include/efuse/esp32/include" "-I{compiler.sdk.path}/include/vfs/include" "-I{compiler.sdk.path}/include/esp_wifi/include" "-I{compiler.sdk.path}/include/esp_event/include" "-I{compiler.sdk.path}/include/esp_netif/include" "-I{compiler.sdk.path}/include/esp_eth/include" "-I{compiler.sdk.path}/include/tcpip_adapter/include" "-I{compiler.sdk.path}/include/esp_phy/include" "-I{compiler.sdk.path}/include/esp_phy/esp32/include" "-I{compiler.sdk.path}/include/esp_ipc/include" "-I{compiler.sdk.path}/include/app_trace/include" "-I{compiler.sdk.path}/include/esp_timer/include" "-I{compiler.sdk.path}/include/mbedtls/port/include" "-I{compiler.sdk.path}/include/mbedtls/mbedtls/include" "-I{compiler.sdk.path}/include/mbedtls/esp_crt_bundle/include" "-I{compiler.sdk.path}/include/app_update/include" "-I{compiler.sdk.path}/include/spi_flash/include" "-I{compiler.sdk.path}/include/bootloader_support/include" "-I{compiler.sdk.path}/include/nvs_flash/include" "-I{compiler.sdk.path}/include/pthread/include" "-I{compiler.sdk.path}/include/esp_gdbstub/include" "-I{compiler.sdk.path}/include/esp_gdbstub/xtensa" "-I{compiler.sdk.path}/include/esp_gdbstub/esp32" "-I{compiler.sdk.path}/include/espcoredump/include" "-I{compiler.sdk.path}/include/espcoredump/include/port/xtensa" "-I{compiler.sdk.path}/include/wpa_supplicant/include" "-I{compiler.sdk.path}/include/wpa_supplicant/port/include" "-I{compiler.sdk.path}/include/wpa_supplicant/esp_supplicant/include" "-I{compiler.sdk.path}/include/ieee802154/include" "-I{compiler.sdk.path}/include/asio/asio/asio/include" "-I{compiler.sdk.path}/include/asio/port/include" "-I{compiler.sdk.path}/include/bt/common/osi/include" "-I{compiler.sdk.path}/include/bt/include/esp32/include" "-I{compiler.sdk.path}/include/bt/common/api/include/api" "-I{compiler.sdk.path}/include/bt/common/btc/profile/esp/blufi/include" "-I{compiler.sdk.path}/include/bt/common/btc/profile/esp/include" "-I{compiler.sdk.path}/include/bt/host/bluedroid/api/include/api" "-I{compiler.sdk.path}/include/cbor/port/include" "-I{compiler.sdk.path}/include/unity/include" "-I{compiler.sdk.path}/include/unity/unity/src" "-I{compiler.sdk.path}/include/cmock/CMock/src" "-I{compiler.sdk.path}/include/coap/port/include" "-I{compiler.sdk.path}/include/coap/libcoap/include" "-I{compiler.sdk.path}/include/console" "-I{compiler.sdk.path}/include/nghttp/port/include" "-I{compiler.sdk.path}/include/nghttp/nghttp2/lib/includes" "-I{compiler.sdk.path}/include/esp-tls" "-I{compiler.sdk.path}/include/esp-tls/esp-tls-crypto" "-I{compiler.sdk.path}/include/esp_adc_cal/include" "-I{compiler.sdk.path}/include/esp_hid/include" "-I{compiler.sdk.path}/include/tcp_transport/include" "-I{compiler.sdk.path}/include/esp_http_client/include" "-I{compiler.sdk.path}/include/esp_http_server/include" "-I{compiler.sdk.path}/include/esp_https_ota/include" "-I{compiler.sdk.path}/include/esp_lcd/include" "-I{compiler.sdk.path}/include/esp_lcd/interface" "-I{compiler.sdk.path}/include/protobuf-c/protobuf-c" "-I{compiler.sdk.path}/include/protocomm/include/common" "-I{compiler.sdk.path}/include/protocomm/include/security" "-I{compiler.sdk.path}/include/protocomm/include/transports" "-I{compiler.sdk.path}/include/mdns/include" "-I{compiler.sdk.path}/include/esp_local_ctrl/include" "-I{compiler.sdk.path}/include/sdmmc/include" "-I{compiler.sdk.path}/include/esp_serial_slave_link/include" "-I{compiler.sdk.path}/include/esp_websocket_client/include" "-I{compiler.sdk.path}/include/expat/expat/expat/lib" "-I{compiler.sdk.path}/include/expat/port/include" "-I{compiler.sdk.path}/include/wear_levelling/include" "-I{compiler.sdk.path}/include/fatfs/diskio" "-I{compiler.sdk.path}/include/fatfs/vfs" "-I{compiler.sdk.path}/include/fatfs/src" "-I{compiler.sdk.path}/include/freemodbus/common/include" "-I{compiler.sdk.path}/include/idf_test/include" "-I{compiler.sdk.path}/include/idf_test/include/esp32" "-I{compiler.sdk.path}/include/jsmn/include" "-I{compiler.sdk.path}/include/json/cJSON" "-I{compiler.sdk.path}/include/libsodium/libsodium/src/libsodium/include" "-I{compiler.sdk.path}/include/libsodium/port_include" "-I{compiler.sdk.path}/include/mqtt/esp-mqtt/include" "-I{compiler.sdk.path}/include/openssl/include" "-I{compiler.sdk.path}/include/perfmon/include" "-I{compiler.sdk.path}/include/spiffs/include" "-I{compiler.sdk.path}/include/ulp/include" "-I{compiler.sdk.path}/include/wifi_provisioning/include" "-I{compiler.sdk.path}/include/button/button/include" "-I{compiler.sdk.path}/include/json_parser" "-I{compiler.sdk.path}/include/json_parser/jsmn/include" "-I{compiler.sdk.path}/include/json_generator" "-I{compiler.sdk.path}/include/esp_schedule/include" "-I{compiler.sdk.path}/include/esp_rainmaker/include" "-I{compiler.sdk.path}/include/qrcode/include" "-I{compiler.sdk.path}/include/ws2812_led" "-I{compiler.sdk.path}/include/esp_littlefs/src" "-I{compiler.sdk.path}/include/esp_littlefs/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/dotprod/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/support/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/hann/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman_harris/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman_nuttall/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/nuttall/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/flat_top/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/iir/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/fir/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/add/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/sub/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/mul/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/addc/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/mulc/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/sqrt/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/matrix/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/fft/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/dct/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/conv/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/common/include" "-I{compiler.sdk.path}/include/esp-face/include" "-I{compiler.sdk.path}/include/esp-face/include/tool" "-I{compiler.sdk.path}/include/esp-face/include/typedef" "-I{compiler.sdk.path}/include/esp-face/include/image" "-I{compiler.sdk.path}/include/esp-face/include/math" "-I{compiler.sdk.path}/include/esp-face/include/nn" "-I{compiler.sdk.path}/include/esp-face/include/layer" "-I{compiler.sdk.path}/include/esp-face/include/detect" "-I{compiler.sdk.path}/include/esp-face/include/model_zoo" "-I{compiler.sdk.path}/include/esp32-camera/driver/include" "-I{compiler.sdk.path}/include/esp32-camera/conversions/include" "-I{compiler.sdk.path}/include/fb_gfx/include" +compiler.c.elf.libs.esp32=-lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lasio -lbt -lcbor -lunity -lcmock -lcoap -lconsole -lnghttp -lesp-tls -lesp_adc_cal -lesp_hid -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lesp_lcd -lprotobuf-c -lprotocomm -lmdns -lesp_local_ctrl -lsdmmc -lesp_serial_slave_link -lesp_websocket_client -lexpat -lwear_levelling -lfatfs -lfreemodbus -ljsmn -ljson -llibsodium -lmqtt -lopenssl -lperfmon -lspiffs -lulp -lwifi_provisioning -lbutton -ljson_parser -ljson_generator -lesp_schedule -lesp_rainmaker -lqrcode -lws2812_led -lesp-dsp -lesp32-camera -lesp_littlefs -lfb_gfx -lasio -lcbor -lcmock -lunity -lcoap -lesp_lcd -lesp_local_ctrl -lesp_websocket_client -lexpat -lfreemodbus -ljsmn -llibsodium -lperfmon -lesp_adc_cal -lesp_hid -lfatfs -lwear_levelling -lopenssl -lspiffs -lesp_rainmaker -lmqtt -lwifi_provisioning -lprotocomm -lbt -lbtdm_app -lprotobuf-c -lmdns -lconsole -ljson -ljson_parser -ljson_generator -lesp_schedule -lqrcode -lcat_face_detect -lhuman_face_detect -ldl -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lphy -lrtc -lesp_phy -lphy -lrtc -lesp_phy -lphy -lrtc -lxt_hal -lm -lnewlib -lstdc++ -lpthread -lgcc -lcxx -lapp_trace -lgcov -lapp_trace -lgcov -lc compiler.c.flags.esp32=-mlongcalls -Wno-frame-address -ffunction-sections -fdata-sections -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -ggdb -O2 -Wwrite-strings -fstack-protector -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -std=gnu99 -Wno-old-style-declaration -MMD -c compiler.cpp.flags.esp32=-mlongcalls -Wno-frame-address -ffunction-sections -fdata-sections -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -ggdb -O2 -Wwrite-strings -fstack-protector -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -std=gnu++11 -fexceptions -fno-rtti -MMD -c compiler.S.flags.esp32=-ffunction-sections -fdata-sections -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -ggdb -O2 -Wwrite-strings -fstack-protector -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -x assembler-with-cpp -MMD -c -compiler.c.elf.flags.esp32=-T esp32.rom.redefined.ld -T memory.ld -T sections.ld -T esp32.rom.ld -T esp32.rom.api.ld -T esp32.rom.libgcc.ld -T esp32.rom.newlib-data.ld -T esp32.rom.syscalls.ld -T esp32.peripherals.ld -mlongcalls -Wno-frame-address -Wl,--cref -Wl,--gc-sections -fno-rtti -fno-lto -u _Z5setupv -u _Z4loopv -Wl,--wrap=mbedtls_mpi_exp_mod -u esp_app_desc -u pthread_include_pthread_impl -u pthread_include_pthread_cond_impl -u pthread_include_pthread_local_storage_impl -u ld_include_panic_highint_hdl -u start_app -u start_app_other_cores -u __ubsan_include -Wl,--wrap=longjmp -u __assert_func -u vfs_include_syscalls_impl -Wl,--undefined=uxTopUsedPriority -u app_main -u newlib_include_heap_impl -u newlib_include_syscalls_impl -u newlib_include_pthread_impl -u __cxa_guard_dummy +compiler.c.elf.flags.esp32=-T esp32.rom.redefined.ld -T memory.ld -T sections.ld -T esp32.rom.ld -T esp32.rom.api.ld -T esp32.rom.libgcc.ld -T esp32.rom.newlib-data.ld -T esp32.rom.syscalls.ld -T esp32.peripherals.ld -mlongcalls -Wno-frame-address -Wl,--cref -Wl,--gc-sections -fno-rtti -fno-lto -u ld_include_hli_vectors_bt -u _Z5setupv -u _Z4loopv -Wl,--wrap=mbedtls_mpi_exp_mod -u esp_app_desc -u pthread_include_pthread_impl -u pthread_include_pthread_cond_impl -u pthread_include_pthread_local_storage_impl -u ld_include_highint_hdl -u start_app -u start_app_other_cores -u __ubsan_include -Wl,--wrap=longjmp -u __assert_func -u vfs_include_syscalls_impl -Wl,--undefined=uxTopUsedPriority -u app_main -u newlib_include_heap_impl -u newlib_include_syscalls_impl -u newlib_include_pthread_impl -u newlib_include_assert_impl -u __cxa_guard_dummy compiler.ar.flags.esp32=cr build.extra_flags.esp32=-DARDUINO_USB_CDC_ON_BOOT=0 # @@ -38,12 +38,12 @@ build.extra_flags.esp32=-DARDUINO_USB_CDC_ON_BOOT=0 # # ESP32S2 Support Start # -compiler.cpreprocessor.flags.esp32s2=-DHAVE_CONFIG_H -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h" -DUNITY_INCLUDE_CONFIG_H -DWITH_POSIX -D_GNU_SOURCE -DIDF_VER="v4.4-dev-2313-gc69f0ec32" -DESP_PLATFORM "-I{compiler.sdk.path}/include/config" "-I{compiler.sdk.path}/include/newlib/platform_include" "-I{compiler.sdk.path}/include/freertos/include" "-I{compiler.sdk.path}/include/freertos/port/xtensa/include" "-I{compiler.sdk.path}/include/esp_hw_support/include" "-I{compiler.sdk.path}/include/esp_hw_support/include/soc" "-I{compiler.sdk.path}/include/esp_hw_support/include/soc/esp32s2" "-I{compiler.sdk.path}/include/esp_hw_support/port/esp32s2" "-I{compiler.sdk.path}/include/esp_hw_support/port/esp32s2/private_include" "-I{compiler.sdk.path}/include/heap/include" "-I{compiler.sdk.path}/include/log/include" "-I{compiler.sdk.path}/include/lwip/include/apps" "-I{compiler.sdk.path}/include/lwip/include/apps/sntp" "-I{compiler.sdk.path}/include/lwip/lwip/src/include" "-I{compiler.sdk.path}/include/lwip/port/esp32/include" "-I{compiler.sdk.path}/include/lwip/port/esp32/include/arch" "-I{compiler.sdk.path}/include/soc/include" "-I{compiler.sdk.path}/include/soc/esp32s2" "-I{compiler.sdk.path}/include/soc/esp32s2/include" "-I{compiler.sdk.path}/include/hal/esp32s2/include" "-I{compiler.sdk.path}/include/hal/include" "-I{compiler.sdk.path}/include/hal/platform_port/include" "-I{compiler.sdk.path}/include/esp_rom/include" "-I{compiler.sdk.path}/include/esp_rom/esp32s2" "-I{compiler.sdk.path}/include/esp_rom/include/esp32s2" "-I{compiler.sdk.path}/include/esp_common/include" "-I{compiler.sdk.path}/include/esp_system/include" "-I{compiler.sdk.path}/include/esp_system/port/soc" "-I{compiler.sdk.path}/include/esp_system/port/public_compat" "-I{compiler.sdk.path}/include/xtensa/include" "-I{compiler.sdk.path}/include/xtensa/esp32s2/include" "-I{compiler.sdk.path}/include/driver/include" "-I{compiler.sdk.path}/include/driver/esp32s2/include" "-I{compiler.sdk.path}/include/esp_pm/include" "-I{compiler.sdk.path}/include/esp_ringbuf/include" "-I{compiler.sdk.path}/include/efuse/include" "-I{compiler.sdk.path}/include/efuse/esp32s2/include" "-I{compiler.sdk.path}/include/vfs/include" "-I{compiler.sdk.path}/include/esp_wifi/include" "-I{compiler.sdk.path}/include/esp_event/include" "-I{compiler.sdk.path}/include/esp_netif/include" "-I{compiler.sdk.path}/include/esp_eth/include" "-I{compiler.sdk.path}/include/tcpip_adapter/include" "-I{compiler.sdk.path}/include/esp_phy/include" "-I{compiler.sdk.path}/include/esp_phy/esp32s2/include" "-I{compiler.sdk.path}/include/app_trace/include" "-I{compiler.sdk.path}/include/esp_timer/include" "-I{compiler.sdk.path}/include/esp_ipc/include" "-I{compiler.sdk.path}/include/mbedtls/port/include" "-I{compiler.sdk.path}/include/mbedtls/mbedtls/include" "-I{compiler.sdk.path}/include/mbedtls/esp_crt_bundle/include" "-I{compiler.sdk.path}/include/app_update/include" "-I{compiler.sdk.path}/include/spi_flash/include" "-I{compiler.sdk.path}/include/bootloader_support/include" "-I{compiler.sdk.path}/include/nvs_flash/include" "-I{compiler.sdk.path}/include/pthread/include" "-I{compiler.sdk.path}/include/esp_gdbstub/include" "-I{compiler.sdk.path}/include/esp_gdbstub/xtensa" "-I{compiler.sdk.path}/include/esp_gdbstub/esp32s2" "-I{compiler.sdk.path}/include/espcoredump/include" "-I{compiler.sdk.path}/include/espcoredump/include/port/xtensa" "-I{compiler.sdk.path}/include/wpa_supplicant/include" "-I{compiler.sdk.path}/include/wpa_supplicant/port/include" "-I{compiler.sdk.path}/include/wpa_supplicant/include/esp_supplicant" "-I{compiler.sdk.path}/include/ieee802154/include" "-I{compiler.sdk.path}/include/asio/asio/asio/include" "-I{compiler.sdk.path}/include/asio/port/include" "-I{compiler.sdk.path}/include/cbor/port/include" "-I{compiler.sdk.path}/include/unity/include" "-I{compiler.sdk.path}/include/unity/unity/src" "-I{compiler.sdk.path}/include/cmock/CMock/src" "-I{compiler.sdk.path}/include/coap/port/include" "-I{compiler.sdk.path}/include/coap/port/include/coap" "-I{compiler.sdk.path}/include/coap/libcoap/include" "-I{compiler.sdk.path}/include/coap/libcoap/include/coap2" "-I{compiler.sdk.path}/include/console" "-I{compiler.sdk.path}/include/nghttp/port/include" "-I{compiler.sdk.path}/include/nghttp/nghttp2/lib/includes" "-I{compiler.sdk.path}/include/esp-tls" "-I{compiler.sdk.path}/include/esp-tls/esp-tls-crypto" "-I{compiler.sdk.path}/include/esp_adc_cal/include" "-I{compiler.sdk.path}/include/esp_hid/include" "-I{compiler.sdk.path}/include/tcp_transport/include" "-I{compiler.sdk.path}/include/esp_http_client/include" "-I{compiler.sdk.path}/include/esp_http_server/include" "-I{compiler.sdk.path}/include/esp_https_ota/include" "-I{compiler.sdk.path}/include/esp_https_server/include" "-I{compiler.sdk.path}/include/esp_lcd/include" "-I{compiler.sdk.path}/include/esp_lcd/interface" "-I{compiler.sdk.path}/include/protobuf-c/protobuf-c" "-I{compiler.sdk.path}/include/protocomm/include/common" "-I{compiler.sdk.path}/include/protocomm/include/security" "-I{compiler.sdk.path}/include/protocomm/include/transports" "-I{compiler.sdk.path}/include/mdns/include" "-I{compiler.sdk.path}/include/esp_local_ctrl/include" "-I{compiler.sdk.path}/include/sdmmc/include" "-I{compiler.sdk.path}/include/esp_serial_slave_link/include" "-I{compiler.sdk.path}/include/esp_websocket_client/include" "-I{compiler.sdk.path}/include/expat/expat/expat/lib" "-I{compiler.sdk.path}/include/expat/port/include" "-I{compiler.sdk.path}/include/wear_levelling/include" "-I{compiler.sdk.path}/include/fatfs/diskio" "-I{compiler.sdk.path}/include/fatfs/vfs" "-I{compiler.sdk.path}/include/fatfs/src" "-I{compiler.sdk.path}/include/freemodbus/common/include" "-I{compiler.sdk.path}/include/idf_test/include" "-I{compiler.sdk.path}/include/idf_test/include/esp32s2" "-I{compiler.sdk.path}/include/jsmn/include" "-I{compiler.sdk.path}/include/json/cJSON" "-I{compiler.sdk.path}/include/libsodium/libsodium/src/libsodium/include" "-I{compiler.sdk.path}/include/libsodium/port_include" "-I{compiler.sdk.path}/include/mqtt/esp-mqtt/include" "-I{compiler.sdk.path}/include/openssl/include" "-I{compiler.sdk.path}/include/perfmon/include" "-I{compiler.sdk.path}/include/spiffs/include" "-I{compiler.sdk.path}/include/touch_element/include" "-I{compiler.sdk.path}/include/ulp/include" "-I{compiler.sdk.path}/include/wifi_provisioning/include" "-I{compiler.sdk.path}/include/freertos/include/freertos" "-I{compiler.sdk.path}/include/arduino_tinyusb/tinyusb/src" "-I{compiler.sdk.path}/include/arduino_tinyusb/include" "-I{compiler.sdk.path}/include/esp_littlefs/src" "-I{compiler.sdk.path}/include/esp_littlefs/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/dotprod/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/support/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/hann/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman_harris/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman_nuttall/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/nuttall/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/flat_top/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/iir/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/fir/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/add/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/sub/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/mul/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/addc/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/mulc/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/sqrt/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/matrix/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/fft/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/dct/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/conv/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/common/include" "-I{compiler.sdk.path}/include/esp-face/face_detection/include" "-I{compiler.sdk.path}/include/esp-face/face_recognition/include" "-I{compiler.sdk.path}/include/esp-face/object_detection/include" "-I{compiler.sdk.path}/include/esp-face/image_util/include" "-I{compiler.sdk.path}/include/esp-face/pose_estimation/include" "-I{compiler.sdk.path}/include/esp-face/lib/include" "-I{compiler.sdk.path}/include/esp32-camera/driver/include" "-I{compiler.sdk.path}/include/esp32-camera/conversions/include" "-I{compiler.sdk.path}/include/fb_gfx/include" -compiler.c.elf.libs.esp32s2=-lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lasio -lcbor -lunity -lcmock -lcoap -lconsole -lnghttp -lesp-tls -lesp_adc_cal -lesp_hid -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lesp_https_server -lesp_lcd -lprotobuf-c -lprotocomm -lmdns -lesp_local_ctrl -lsdmmc -lesp_serial_slave_link -lesp_websocket_client -lexpat -lwear_levelling -lfatfs -lfreemodbus -ljsmn -ljson -llibsodium -lmqtt -lopenssl -lperfmon -lspiffs -ltouch_element -lulp -lusb -lwifi_provisioning -lesp-dsp -lesp-face -lesp32-camera -lesp_littlefs -lfb_gfx -lasio -lcbor -lcmock -lunity -lcoap -lesp_hid -lesp_lcd -lesp_local_ctrl -lesp_https_server -lesp_websocket_client -lexpat -lfreemodbus -ljsmn -llibsodium -lmqtt -lperfmon -ltouch_element -lusb -lesp_adc_cal -lfatfs -lwear_levelling -lopenssl -lspiffs -lwifi_provisioning -lprotocomm -lprotobuf-c -lmdns -lconsole -ljson -larduino_tinyusb -lpe -lfd -lfr -ldetection_cat_face -ldetection -ldl -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lphy -lesp_phy -lphy -lesp_phy -lphy -lxt_hal -lm -lnewlib -lstdc++ -lpthread -lgcc -lcxx -lapp_trace -lgcov -lapp_trace -lgcov -lc +compiler.cpreprocessor.flags.esp32s2=-DHAVE_CONFIG_H -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h" -DUNITY_INCLUDE_CONFIG_H -DWITH_POSIX -D_GNU_SOURCE -DIDF_VER="v4.4-dev-3235-g3e370c4296" -DESP_PLATFORM "-I{compiler.sdk.path}/include/config" "-I{compiler.sdk.path}/include/newlib/platform_include" "-I{compiler.sdk.path}/include/freertos/include" "-I{compiler.sdk.path}/include/freertos/include/esp_additions/freertos" "-I{compiler.sdk.path}/include/freertos/port/xtensa/include" "-I{compiler.sdk.path}/include/freertos/include/esp_additions" "-I{compiler.sdk.path}/include/esp_hw_support/include" "-I{compiler.sdk.path}/include/esp_hw_support/include/soc" "-I{compiler.sdk.path}/include/esp_hw_support/include/soc/esp32s2" "-I{compiler.sdk.path}/include/esp_hw_support/port/esp32s2" "-I{compiler.sdk.path}/include/esp_hw_support/port/esp32s2/private_include" "-I{compiler.sdk.path}/include/heap/include" "-I{compiler.sdk.path}/include/log/include" "-I{compiler.sdk.path}/include/lwip/include/apps" "-I{compiler.sdk.path}/include/lwip/include/apps/sntp" "-I{compiler.sdk.path}/include/lwip/lwip/src/include" "-I{compiler.sdk.path}/include/lwip/port/esp32/include" "-I{compiler.sdk.path}/include/lwip/port/esp32/include/arch" "-I{compiler.sdk.path}/include/soc/include" "-I{compiler.sdk.path}/include/soc/esp32s2" "-I{compiler.sdk.path}/include/soc/esp32s2/include" "-I{compiler.sdk.path}/include/hal/esp32s2/include" "-I{compiler.sdk.path}/include/hal/include" "-I{compiler.sdk.path}/include/hal/platform_port/include" "-I{compiler.sdk.path}/include/esp_rom/include" "-I{compiler.sdk.path}/include/esp_rom/include/esp32s2" "-I{compiler.sdk.path}/include/esp_rom/esp32s2" "-I{compiler.sdk.path}/include/esp_common/include" "-I{compiler.sdk.path}/include/esp_system/include" "-I{compiler.sdk.path}/include/esp_system/port/soc" "-I{compiler.sdk.path}/include/esp_system/port/public_compat" "-I{compiler.sdk.path}/include/xtensa/include" "-I{compiler.sdk.path}/include/xtensa/esp32s2/include" "-I{compiler.sdk.path}/include/driver/include" "-I{compiler.sdk.path}/include/driver/esp32s2/include" "-I{compiler.sdk.path}/include/esp_pm/include" "-I{compiler.sdk.path}/include/esp_ringbuf/include" "-I{compiler.sdk.path}/include/efuse/include" "-I{compiler.sdk.path}/include/efuse/esp32s2/include" "-I{compiler.sdk.path}/include/vfs/include" "-I{compiler.sdk.path}/include/esp_wifi/include" "-I{compiler.sdk.path}/include/esp_event/include" "-I{compiler.sdk.path}/include/esp_netif/include" "-I{compiler.sdk.path}/include/esp_eth/include" "-I{compiler.sdk.path}/include/tcpip_adapter/include" "-I{compiler.sdk.path}/include/esp_phy/include" "-I{compiler.sdk.path}/include/esp_phy/esp32s2/include" "-I{compiler.sdk.path}/include/esp_ipc/include" "-I{compiler.sdk.path}/include/app_trace/include" "-I{compiler.sdk.path}/include/esp_timer/include" "-I{compiler.sdk.path}/include/mbedtls/port/include" "-I{compiler.sdk.path}/include/mbedtls/mbedtls/include" "-I{compiler.sdk.path}/include/mbedtls/esp_crt_bundle/include" "-I{compiler.sdk.path}/include/app_update/include" "-I{compiler.sdk.path}/include/spi_flash/include" "-I{compiler.sdk.path}/include/bootloader_support/include" "-I{compiler.sdk.path}/include/nvs_flash/include" "-I{compiler.sdk.path}/include/pthread/include" "-I{compiler.sdk.path}/include/esp_gdbstub/include" "-I{compiler.sdk.path}/include/esp_gdbstub/xtensa" "-I{compiler.sdk.path}/include/esp_gdbstub/esp32s2" "-I{compiler.sdk.path}/include/espcoredump/include" "-I{compiler.sdk.path}/include/espcoredump/include/port/xtensa" "-I{compiler.sdk.path}/include/wpa_supplicant/include" "-I{compiler.sdk.path}/include/wpa_supplicant/port/include" "-I{compiler.sdk.path}/include/wpa_supplicant/esp_supplicant/include" "-I{compiler.sdk.path}/include/ieee802154/include" "-I{compiler.sdk.path}/include/asio/asio/asio/include" "-I{compiler.sdk.path}/include/asio/port/include" "-I{compiler.sdk.path}/include/cbor/port/include" "-I{compiler.sdk.path}/include/unity/include" "-I{compiler.sdk.path}/include/unity/unity/src" "-I{compiler.sdk.path}/include/cmock/CMock/src" "-I{compiler.sdk.path}/include/coap/port/include" "-I{compiler.sdk.path}/include/coap/libcoap/include" "-I{compiler.sdk.path}/include/console" "-I{compiler.sdk.path}/include/nghttp/port/include" "-I{compiler.sdk.path}/include/nghttp/nghttp2/lib/includes" "-I{compiler.sdk.path}/include/esp-tls" "-I{compiler.sdk.path}/include/esp-tls/esp-tls-crypto" "-I{compiler.sdk.path}/include/esp_adc_cal/include" "-I{compiler.sdk.path}/include/esp_hid/include" "-I{compiler.sdk.path}/include/tcp_transport/include" "-I{compiler.sdk.path}/include/esp_http_client/include" "-I{compiler.sdk.path}/include/esp_http_server/include" "-I{compiler.sdk.path}/include/esp_https_ota/include" "-I{compiler.sdk.path}/include/esp_https_server/include" "-I{compiler.sdk.path}/include/esp_lcd/include" "-I{compiler.sdk.path}/include/esp_lcd/interface" "-I{compiler.sdk.path}/include/protobuf-c/protobuf-c" "-I{compiler.sdk.path}/include/protocomm/include/common" "-I{compiler.sdk.path}/include/protocomm/include/security" "-I{compiler.sdk.path}/include/protocomm/include/transports" "-I{compiler.sdk.path}/include/mdns/include" "-I{compiler.sdk.path}/include/esp_local_ctrl/include" "-I{compiler.sdk.path}/include/sdmmc/include" "-I{compiler.sdk.path}/include/esp_serial_slave_link/include" "-I{compiler.sdk.path}/include/esp_websocket_client/include" "-I{compiler.sdk.path}/include/expat/expat/expat/lib" "-I{compiler.sdk.path}/include/expat/port/include" "-I{compiler.sdk.path}/include/wear_levelling/include" "-I{compiler.sdk.path}/include/fatfs/diskio" "-I{compiler.sdk.path}/include/fatfs/vfs" "-I{compiler.sdk.path}/include/fatfs/src" "-I{compiler.sdk.path}/include/freemodbus/common/include" "-I{compiler.sdk.path}/include/idf_test/include" "-I{compiler.sdk.path}/include/idf_test/include/esp32s2" "-I{compiler.sdk.path}/include/jsmn/include" "-I{compiler.sdk.path}/include/json/cJSON" "-I{compiler.sdk.path}/include/libsodium/libsodium/src/libsodium/include" "-I{compiler.sdk.path}/include/libsodium/port_include" "-I{compiler.sdk.path}/include/mqtt/esp-mqtt/include" "-I{compiler.sdk.path}/include/openssl/include" "-I{compiler.sdk.path}/include/perfmon/include" "-I{compiler.sdk.path}/include/spiffs/include" "-I{compiler.sdk.path}/include/usb/include" "-I{compiler.sdk.path}/include/touch_element/include" "-I{compiler.sdk.path}/include/ulp/include" "-I{compiler.sdk.path}/include/wifi_provisioning/include" "-I{compiler.sdk.path}/include/freertos/include/freertos" "-I{compiler.sdk.path}/include/arduino_tinyusb/tinyusb/src" "-I{compiler.sdk.path}/include/arduino_tinyusb/include" "-I{compiler.sdk.path}/include/esp_littlefs/src" "-I{compiler.sdk.path}/include/esp_littlefs/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/dotprod/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/support/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/hann/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman_harris/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman_nuttall/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/nuttall/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/flat_top/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/iir/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/fir/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/add/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/sub/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/mul/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/addc/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/mulc/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/sqrt/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/matrix/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/fft/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/dct/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/conv/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/common/include" "-I{compiler.sdk.path}/include/esp-face/include" "-I{compiler.sdk.path}/include/esp-face/include/tool" "-I{compiler.sdk.path}/include/esp-face/include/typedef" "-I{compiler.sdk.path}/include/esp-face/include/image" "-I{compiler.sdk.path}/include/esp-face/include/math" "-I{compiler.sdk.path}/include/esp-face/include/nn" "-I{compiler.sdk.path}/include/esp-face/include/layer" "-I{compiler.sdk.path}/include/esp-face/include/detect" "-I{compiler.sdk.path}/include/esp-face/include/model_zoo" "-I{compiler.sdk.path}/include/esp32-camera/driver/include" "-I{compiler.sdk.path}/include/esp32-camera/conversions/include" "-I{compiler.sdk.path}/include/fb_gfx/include" +compiler.c.elf.libs.esp32s2=-lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lasio -lcbor -lunity -lcmock -lcoap -lconsole -lnghttp -lesp-tls -lesp_adc_cal -lesp_hid -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lesp_https_server -lesp_lcd -lprotobuf-c -lprotocomm -lmdns -lesp_local_ctrl -lsdmmc -lesp_serial_slave_link -lesp_websocket_client -lexpat -lwear_levelling -lfatfs -lfreemodbus -ljsmn -ljson -llibsodium -lmqtt -lopenssl -lperfmon -lspiffs -lusb -ltouch_element -lulp -lwifi_provisioning -lesp-dsp -lesp32-camera -lesp_littlefs -lfb_gfx -lasio -lcbor -lcmock -lunity -lcoap -lesp_lcd -lesp_local_ctrl -lesp_https_server -lesp_websocket_client -lexpat -lfreemodbus -ljsmn -llibsodium -lmqtt -lperfmon -lusb -ltouch_element -lesp_adc_cal -lesp_hid -lfatfs -lwear_levelling -lopenssl -lspiffs -lwifi_provisioning -lprotocomm -lprotobuf-c -lmdns -lconsole -ljson -larduino_tinyusb -lcat_face_detect -lhuman_face_detect -ldl -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lphy -lesp_phy -lphy -lesp_phy -lphy -lxt_hal -lm -lnewlib -lstdc++ -lpthread -lgcc -lcxx -lapp_trace -lgcov -lapp_trace -lgcov -lc compiler.c.flags.esp32s2=-mlongcalls -ffunction-sections -fdata-sections -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -ggdb -O2 -Wwrite-strings -fstack-protector -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -std=gnu99 -Wno-old-style-declaration -MMD -c compiler.cpp.flags.esp32s2=-mlongcalls -ffunction-sections -fdata-sections -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -ggdb -O2 -Wwrite-strings -fstack-protector -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -std=gnu++11 -fexceptions -fno-rtti -MMD -c compiler.S.flags.esp32s2=-ffunction-sections -fdata-sections -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -ggdb -O2 -Wwrite-strings -fstack-protector -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -x assembler-with-cpp -MMD -c -compiler.c.elf.flags.esp32s2=-T memory.ld -T sections.ld -T esp32s2.rom.ld -T esp32s2.rom.api.ld -T esp32s2.rom.libgcc.ld -T esp32s2.rom.newlib-funcs.ld -T esp32s2.rom.newlib-data.ld -T esp32s2.rom.spiflash.ld -T esp32s2.peripherals.ld -mlongcalls -Wl,--cref -Wl,--gc-sections -fno-rtti -fno-lto -u _Z5setupv -u _Z4loopv -u esp_app_desc -u pthread_include_pthread_impl -u pthread_include_pthread_cond_impl -u pthread_include_pthread_local_storage_impl -u ld_include_panic_highint_hdl -u start_app -u __ubsan_include -Wl,--wrap=longjmp -u __assert_func -u vfs_include_syscalls_impl -Wl,--undefined=uxTopUsedPriority -u app_main -u newlib_include_heap_impl -u newlib_include_syscalls_impl -u newlib_include_pthread_impl -u __cxa_guard_dummy +compiler.c.elf.flags.esp32s2=-T memory.ld -T sections.ld -T esp32s2.rom.ld -T esp32s2.rom.api.ld -T esp32s2.rom.libgcc.ld -T esp32s2.rom.newlib-funcs.ld -T esp32s2.rom.newlib-data.ld -T esp32s2.rom.spiflash.ld -T esp32s2.peripherals.ld -mlongcalls -Wl,--cref -Wl,--gc-sections -fno-rtti -fno-lto -u _Z5setupv -u _Z4loopv -u esp_app_desc -u pthread_include_pthread_impl -u pthread_include_pthread_cond_impl -u pthread_include_pthread_local_storage_impl -u ld_include_highint_hdl -u start_app -u __ubsan_include -Wl,--wrap=longjmp -u __assert_func -u vfs_include_syscalls_impl -Wl,--undefined=uxTopUsedPriority -u app_main -u newlib_include_heap_impl -u newlib_include_syscalls_impl -u newlib_include_pthread_impl -u newlib_include_assert_impl -u __cxa_guard_dummy compiler.ar.flags.esp32s2=cr build.extra_flags.esp32s2=-DARDUINO_USB_CDC_ON_BOOT={build.cdc_on_boot} -DARDUINO_USB_MSC_ON_BOOT={build.msc_on_boot} -DARDUINO_USB_DFU_ON_BOOT={build.dfu_on_boot} # @@ -53,12 +53,12 @@ build.extra_flags.esp32s2=-DARDUINO_USB_CDC_ON_BOOT={build.cdc_on_boot} -DARDUIN # # ESP32C3 Support Start # -compiler.cpreprocessor.flags.esp32c3=-DHAVE_CONFIG_H -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h" -DUNITY_INCLUDE_CONFIG_H -DWITH_POSIX -D_GNU_SOURCE -DIDF_VER="v4.4-dev-2313-gc69f0ec32" -DESP_PLATFORM "-I{compiler.sdk.path}/include/config" "-I{compiler.sdk.path}/include/newlib/platform_include" "-I{compiler.sdk.path}/include/freertos/include" "-I{compiler.sdk.path}/include/freertos/port/riscv/include" "-I{compiler.sdk.path}/include/esp_hw_support/include" "-I{compiler.sdk.path}/include/esp_hw_support/include/soc" "-I{compiler.sdk.path}/include/esp_hw_support/include/soc/esp32c3" "-I{compiler.sdk.path}/include/esp_hw_support/port/esp32c3" "-I{compiler.sdk.path}/include/esp_hw_support/port/esp32c3/private_include" "-I{compiler.sdk.path}/include/heap/include" "-I{compiler.sdk.path}/include/log/include" "-I{compiler.sdk.path}/include/lwip/include/apps" "-I{compiler.sdk.path}/include/lwip/include/apps/sntp" "-I{compiler.sdk.path}/include/lwip/lwip/src/include" "-I{compiler.sdk.path}/include/lwip/port/esp32/include" "-I{compiler.sdk.path}/include/lwip/port/esp32/include/arch" "-I{compiler.sdk.path}/include/soc/include" "-I{compiler.sdk.path}/include/soc/esp32c3" "-I{compiler.sdk.path}/include/soc/esp32c3/include" "-I{compiler.sdk.path}/include/hal/esp32c3/include" "-I{compiler.sdk.path}/include/hal/include" "-I{compiler.sdk.path}/include/hal/platform_port/include" "-I{compiler.sdk.path}/include/esp_rom/include" "-I{compiler.sdk.path}/include/esp_rom/esp32c3" "-I{compiler.sdk.path}/include/esp_rom/include/esp32c3" "-I{compiler.sdk.path}/include/esp_common/include" "-I{compiler.sdk.path}/include/esp_system/include" "-I{compiler.sdk.path}/include/esp_system/port/soc" "-I{compiler.sdk.path}/include/esp_system/port/include/riscv" "-I{compiler.sdk.path}/include/esp_system/port/public_compat" "-I{compiler.sdk.path}/include/riscv/include" "-I{compiler.sdk.path}/include/driver/include" "-I{compiler.sdk.path}/include/driver/esp32c3/include" "-I{compiler.sdk.path}/include/esp_pm/include" "-I{compiler.sdk.path}/include/esp_ringbuf/include" "-I{compiler.sdk.path}/include/efuse/include" "-I{compiler.sdk.path}/include/efuse/esp32c3/include" "-I{compiler.sdk.path}/include/vfs/include" "-I{compiler.sdk.path}/include/esp_wifi/include" "-I{compiler.sdk.path}/include/esp_event/include" "-I{compiler.sdk.path}/include/esp_netif/include" "-I{compiler.sdk.path}/include/esp_eth/include" "-I{compiler.sdk.path}/include/tcpip_adapter/include" "-I{compiler.sdk.path}/include/esp_phy/include" "-I{compiler.sdk.path}/include/esp_phy/esp32c3/include" "-I{compiler.sdk.path}/include/app_trace/include" "-I{compiler.sdk.path}/include/esp_timer/include" "-I{compiler.sdk.path}/include/esp_ipc/include" "-I{compiler.sdk.path}/include/mbedtls/port/include" "-I{compiler.sdk.path}/include/mbedtls/mbedtls/include" "-I{compiler.sdk.path}/include/mbedtls/esp_crt_bundle/include" "-I{compiler.sdk.path}/include/app_update/include" "-I{compiler.sdk.path}/include/spi_flash/include" "-I{compiler.sdk.path}/include/bootloader_support/include" "-I{compiler.sdk.path}/include/nvs_flash/include" "-I{compiler.sdk.path}/include/pthread/include" "-I{compiler.sdk.path}/include/esp_gdbstub/include" "-I{compiler.sdk.path}/include/esp_gdbstub/riscv" "-I{compiler.sdk.path}/include/esp_gdbstub/esp32c3" "-I{compiler.sdk.path}/include/espcoredump/include" "-I{compiler.sdk.path}/include/espcoredump/include/port/riscv" "-I{compiler.sdk.path}/include/wpa_supplicant/include" "-I{compiler.sdk.path}/include/wpa_supplicant/port/include" "-I{compiler.sdk.path}/include/wpa_supplicant/include/esp_supplicant" "-I{compiler.sdk.path}/include/ieee802154/include" "-I{compiler.sdk.path}/include/asio/asio/asio/include" "-I{compiler.sdk.path}/include/asio/port/include" "-I{compiler.sdk.path}/include/bt/common/osi/include" "-I{compiler.sdk.path}/include/bt/include/esp32c3/include" "-I{compiler.sdk.path}/include/bt/common/api/include/api" "-I{compiler.sdk.path}/include/bt/common/btc/profile/esp/blufi/include" "-I{compiler.sdk.path}/include/bt/common/btc/profile/esp/include" "-I{compiler.sdk.path}/include/bt/host/bluedroid/api/include/api" "-I{compiler.sdk.path}/include/cbor/port/include" "-I{compiler.sdk.path}/include/unity/include" "-I{compiler.sdk.path}/include/unity/unity/src" "-I{compiler.sdk.path}/include/cmock/CMock/src" "-I{compiler.sdk.path}/include/coap/port/include" "-I{compiler.sdk.path}/include/coap/port/include/coap" "-I{compiler.sdk.path}/include/coap/libcoap/include" "-I{compiler.sdk.path}/include/coap/libcoap/include/coap2" "-I{compiler.sdk.path}/include/console" "-I{compiler.sdk.path}/include/nghttp/port/include" "-I{compiler.sdk.path}/include/nghttp/nghttp2/lib/includes" "-I{compiler.sdk.path}/include/esp-tls" "-I{compiler.sdk.path}/include/esp-tls/esp-tls-crypto" "-I{compiler.sdk.path}/include/esp_adc_cal/include" "-I{compiler.sdk.path}/include/esp_hid/include" "-I{compiler.sdk.path}/include/tcp_transport/include" "-I{compiler.sdk.path}/include/esp_http_client/include" "-I{compiler.sdk.path}/include/esp_http_server/include" "-I{compiler.sdk.path}/include/esp_https_ota/include" "-I{compiler.sdk.path}/include/esp_https_server/include" "-I{compiler.sdk.path}/include/esp_lcd/include" "-I{compiler.sdk.path}/include/esp_lcd/interface" "-I{compiler.sdk.path}/include/protobuf-c/protobuf-c" "-I{compiler.sdk.path}/include/protocomm/include/common" "-I{compiler.sdk.path}/include/protocomm/include/security" "-I{compiler.sdk.path}/include/protocomm/include/transports" "-I{compiler.sdk.path}/include/mdns/include" "-I{compiler.sdk.path}/include/esp_local_ctrl/include" "-I{compiler.sdk.path}/include/sdmmc/include" "-I{compiler.sdk.path}/include/esp_serial_slave_link/include" "-I{compiler.sdk.path}/include/esp_websocket_client/include" "-I{compiler.sdk.path}/include/expat/expat/expat/lib" "-I{compiler.sdk.path}/include/expat/port/include" "-I{compiler.sdk.path}/include/wear_levelling/include" "-I{compiler.sdk.path}/include/fatfs/diskio" "-I{compiler.sdk.path}/include/fatfs/vfs" "-I{compiler.sdk.path}/include/fatfs/src" "-I{compiler.sdk.path}/include/freemodbus/common/include" "-I{compiler.sdk.path}/include/idf_test/include" "-I{compiler.sdk.path}/include/idf_test/include/esp32c3" "-I{compiler.sdk.path}/include/jsmn/include" "-I{compiler.sdk.path}/include/json/cJSON" "-I{compiler.sdk.path}/include/libsodium/libsodium/src/libsodium/include" "-I{compiler.sdk.path}/include/libsodium/port_include" "-I{compiler.sdk.path}/include/mqtt/esp-mqtt/include" "-I{compiler.sdk.path}/include/openssl/include" "-I{compiler.sdk.path}/include/spiffs/include" "-I{compiler.sdk.path}/include/wifi_provisioning/include" "-I{compiler.sdk.path}/include/esp_littlefs/src" "-I{compiler.sdk.path}/include/esp_littlefs/include" "-I{compiler.sdk.path}/include/fb_gfx/include" -compiler.c.elf.libs.esp32c3=-lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lriscv -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lasio -lbt -lcbor -lunity -lcmock -lcoap -lconsole -lnghttp -lesp-tls -lesp_adc_cal -lesp_hid -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lesp_https_server -lesp_lcd -lprotobuf-c -lprotocomm -lmdns -lesp_local_ctrl -lsdmmc -lesp_serial_slave_link -lesp_websocket_client -lexpat -lwear_levelling -lfatfs -lfreemodbus -ljsmn -ljson -llibsodium -lmqtt -lopenssl -lspiffs -lwifi_provisioning -lesp_littlefs -lfb_gfx -lasio -lcbor -lcmock -lunity -lcoap -lesp_hid -lesp_lcd -lesp_local_ctrl -lesp_https_server -lesp_websocket_client -lexpat -lfreemodbus -ljsmn -llibsodium -lmqtt -lesp_adc_cal -lfatfs -lwear_levelling -lopenssl -lspiffs -lwifi_provisioning -lprotocomm -lbt -lbtdm_app -lprotobuf-c -lmdns -lconsole -ljson -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lriscv -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lriscv -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lriscv -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lriscv -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lriscv -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lriscv -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lphy -lesp_phy -lphy -lesp_phy -lphy -lbtbb -lm -lnewlib -lstdc++ -lpthread -lgcc -lcxx -lapp_trace -lgcov -lapp_trace -lgcov -lc +compiler.cpreprocessor.flags.esp32c3=-DHAVE_CONFIG_H -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h" -DUNITY_INCLUDE_CONFIG_H -DWITH_POSIX -D_GNU_SOURCE -DIDF_VER="v4.4-dev-3235-g3e370c4296" -DESP_PLATFORM "-I{compiler.sdk.path}/include/config" "-I{compiler.sdk.path}/include/newlib/platform_include" "-I{compiler.sdk.path}/include/freertos/include" "-I{compiler.sdk.path}/include/freertos/include/esp_additions/freertos" "-I{compiler.sdk.path}/include/freertos/port/riscv/include" "-I{compiler.sdk.path}/include/freertos/include/esp_additions" "-I{compiler.sdk.path}/include/esp_hw_support/include" "-I{compiler.sdk.path}/include/esp_hw_support/include/soc" "-I{compiler.sdk.path}/include/esp_hw_support/include/soc/esp32c3" "-I{compiler.sdk.path}/include/esp_hw_support/port/esp32c3" "-I{compiler.sdk.path}/include/esp_hw_support/port/esp32c3/private_include" "-I{compiler.sdk.path}/include/heap/include" "-I{compiler.sdk.path}/include/log/include" "-I{compiler.sdk.path}/include/lwip/include/apps" "-I{compiler.sdk.path}/include/lwip/include/apps/sntp" "-I{compiler.sdk.path}/include/lwip/lwip/src/include" "-I{compiler.sdk.path}/include/lwip/port/esp32/include" "-I{compiler.sdk.path}/include/lwip/port/esp32/include/arch" "-I{compiler.sdk.path}/include/soc/include" "-I{compiler.sdk.path}/include/soc/esp32c3" "-I{compiler.sdk.path}/include/soc/esp32c3/include" "-I{compiler.sdk.path}/include/hal/esp32c3/include" "-I{compiler.sdk.path}/include/hal/include" "-I{compiler.sdk.path}/include/hal/platform_port/include" "-I{compiler.sdk.path}/include/esp_rom/include" "-I{compiler.sdk.path}/include/esp_rom/include/esp32c3" "-I{compiler.sdk.path}/include/esp_rom/esp32c3" "-I{compiler.sdk.path}/include/esp_common/include" "-I{compiler.sdk.path}/include/esp_system/include" "-I{compiler.sdk.path}/include/esp_system/port/soc" "-I{compiler.sdk.path}/include/esp_system/port/include/riscv" "-I{compiler.sdk.path}/include/esp_system/port/public_compat" "-I{compiler.sdk.path}/include/riscv/include" "-I{compiler.sdk.path}/include/driver/include" "-I{compiler.sdk.path}/include/driver/esp32c3/include" "-I{compiler.sdk.path}/include/esp_pm/include" "-I{compiler.sdk.path}/include/esp_ringbuf/include" "-I{compiler.sdk.path}/include/efuse/include" "-I{compiler.sdk.path}/include/efuse/esp32c3/include" "-I{compiler.sdk.path}/include/vfs/include" "-I{compiler.sdk.path}/include/esp_wifi/include" "-I{compiler.sdk.path}/include/esp_event/include" "-I{compiler.sdk.path}/include/esp_netif/include" "-I{compiler.sdk.path}/include/esp_eth/include" "-I{compiler.sdk.path}/include/tcpip_adapter/include" "-I{compiler.sdk.path}/include/esp_phy/include" "-I{compiler.sdk.path}/include/esp_phy/esp32c3/include" "-I{compiler.sdk.path}/include/esp_ipc/include" "-I{compiler.sdk.path}/include/app_trace/include" "-I{compiler.sdk.path}/include/esp_timer/include" "-I{compiler.sdk.path}/include/mbedtls/port/include" "-I{compiler.sdk.path}/include/mbedtls/mbedtls/include" "-I{compiler.sdk.path}/include/mbedtls/esp_crt_bundle/include" "-I{compiler.sdk.path}/include/app_update/include" "-I{compiler.sdk.path}/include/spi_flash/include" "-I{compiler.sdk.path}/include/bootloader_support/include" "-I{compiler.sdk.path}/include/nvs_flash/include" "-I{compiler.sdk.path}/include/pthread/include" "-I{compiler.sdk.path}/include/esp_gdbstub/include" "-I{compiler.sdk.path}/include/esp_gdbstub/riscv" "-I{compiler.sdk.path}/include/esp_gdbstub/esp32c3" "-I{compiler.sdk.path}/include/espcoredump/include" "-I{compiler.sdk.path}/include/espcoredump/include/port/riscv" "-I{compiler.sdk.path}/include/wpa_supplicant/include" "-I{compiler.sdk.path}/include/wpa_supplicant/port/include" "-I{compiler.sdk.path}/include/wpa_supplicant/esp_supplicant/include" "-I{compiler.sdk.path}/include/ieee802154/include" "-I{compiler.sdk.path}/include/asio/asio/asio/include" "-I{compiler.sdk.path}/include/asio/port/include" "-I{compiler.sdk.path}/include/bt/common/osi/include" "-I{compiler.sdk.path}/include/bt/include/esp32c3/include" "-I{compiler.sdk.path}/include/bt/common/api/include/api" "-I{compiler.sdk.path}/include/bt/common/btc/profile/esp/blufi/include" "-I{compiler.sdk.path}/include/bt/common/btc/profile/esp/include" "-I{compiler.sdk.path}/include/bt/host/bluedroid/api/include/api" "-I{compiler.sdk.path}/include/cbor/port/include" "-I{compiler.sdk.path}/include/unity/include" "-I{compiler.sdk.path}/include/unity/unity/src" "-I{compiler.sdk.path}/include/cmock/CMock/src" "-I{compiler.sdk.path}/include/coap/port/include" "-I{compiler.sdk.path}/include/coap/libcoap/include" "-I{compiler.sdk.path}/include/console" "-I{compiler.sdk.path}/include/nghttp/port/include" "-I{compiler.sdk.path}/include/nghttp/nghttp2/lib/includes" "-I{compiler.sdk.path}/include/esp-tls" "-I{compiler.sdk.path}/include/esp-tls/esp-tls-crypto" "-I{compiler.sdk.path}/include/esp_adc_cal/include" "-I{compiler.sdk.path}/include/esp_hid/include" "-I{compiler.sdk.path}/include/tcp_transport/include" "-I{compiler.sdk.path}/include/esp_http_client/include" "-I{compiler.sdk.path}/include/esp_http_server/include" "-I{compiler.sdk.path}/include/esp_https_ota/include" "-I{compiler.sdk.path}/include/esp_https_server/include" "-I{compiler.sdk.path}/include/esp_lcd/include" "-I{compiler.sdk.path}/include/esp_lcd/interface" "-I{compiler.sdk.path}/include/protobuf-c/protobuf-c" "-I{compiler.sdk.path}/include/protocomm/include/common" "-I{compiler.sdk.path}/include/protocomm/include/security" "-I{compiler.sdk.path}/include/protocomm/include/transports" "-I{compiler.sdk.path}/include/mdns/include" "-I{compiler.sdk.path}/include/esp_local_ctrl/include" "-I{compiler.sdk.path}/include/sdmmc/include" "-I{compiler.sdk.path}/include/esp_serial_slave_link/include" "-I{compiler.sdk.path}/include/esp_websocket_client/include" "-I{compiler.sdk.path}/include/expat/expat/expat/lib" "-I{compiler.sdk.path}/include/expat/port/include" "-I{compiler.sdk.path}/include/wear_levelling/include" "-I{compiler.sdk.path}/include/fatfs/diskio" "-I{compiler.sdk.path}/include/fatfs/vfs" "-I{compiler.sdk.path}/include/fatfs/src" "-I{compiler.sdk.path}/include/freemodbus/common/include" "-I{compiler.sdk.path}/include/idf_test/include" "-I{compiler.sdk.path}/include/idf_test/include/esp32c3" "-I{compiler.sdk.path}/include/jsmn/include" "-I{compiler.sdk.path}/include/json/cJSON" "-I{compiler.sdk.path}/include/libsodium/libsodium/src/libsodium/include" "-I{compiler.sdk.path}/include/libsodium/port_include" "-I{compiler.sdk.path}/include/mqtt/esp-mqtt/include" "-I{compiler.sdk.path}/include/openssl/include" "-I{compiler.sdk.path}/include/spiffs/include" "-I{compiler.sdk.path}/include/wifi_provisioning/include" "-I{compiler.sdk.path}/include/esp_littlefs/src" "-I{compiler.sdk.path}/include/esp_littlefs/include" "-I{compiler.sdk.path}/include/fb_gfx/include" +compiler.c.elf.libs.esp32c3=-lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lriscv -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lasio -lbt -lcbor -lunity -lcmock -lcoap -lconsole -lnghttp -lesp-tls -lesp_adc_cal -lesp_hid -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lesp_https_server -lesp_lcd -lprotobuf-c -lprotocomm -lmdns -lesp_local_ctrl -lsdmmc -lesp_serial_slave_link -lesp_websocket_client -lexpat -lwear_levelling -lfatfs -lfreemodbus -ljsmn -ljson -llibsodium -lmqtt -lopenssl -lspiffs -lwifi_provisioning -lesp_littlefs -lfb_gfx -lasio -lcbor -lcmock -lunity -lcoap -lesp_lcd -lesp_local_ctrl -lesp_https_server -lesp_websocket_client -lexpat -lfreemodbus -ljsmn -llibsodium -lmqtt -lesp_adc_cal -lesp_hid -lfatfs -lwear_levelling -lopenssl -lspiffs -lwifi_provisioning -lprotocomm -lbt -lbtdm_app -lprotobuf-c -lmdns -lconsole -ljson -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lriscv -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lriscv -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lriscv -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lriscv -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lriscv -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -llwip -llog -lheap -lsoc -lesp_hw_support -lriscv -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lphy -lbtbb -lesp_phy -lphy -lbtbb -lesp_phy -lphy -lbtbb -lm -lnewlib -lstdc++ -lpthread -lgcc -lcxx -lapp_trace -lgcov -lapp_trace -lgcov -lc compiler.c.flags.esp32c3=-march=rv32imc -ffunction-sections -fdata-sections -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -ggdb -Wno-error=format= -nostartfiles -Wno-format -Og -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -std=gnu99 -Wno-old-style-declaration -MMD -c compiler.cpp.flags.esp32c3=-march=rv32imc -ffunction-sections -fdata-sections -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -ggdb -Wno-error=format= -nostartfiles -Wno-format -Og -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -std=gnu++11 -fno-exceptions -fno-rtti -MMD -c compiler.S.flags.esp32c3=-ffunction-sections -fdata-sections -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -ggdb -Wno-error=format= -nostartfiles -Wno-format -Og -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -x assembler-with-cpp -MMD -c -compiler.c.elf.flags.esp32c3=-T memory.ld -T sections.ld -T esp32c3.rom.ld -T esp32c3.rom.api.ld -T esp32c3.rom.libgcc.ld -T esp32c3.rom.newlib.ld -T esp32c3.rom.version.ld -T esp32c3.peripherals.ld -nostartfiles -march=rv32imc --specs=nosys.specs -Wl,--cref -Wl,--gc-sections -fno-rtti -fno-lto -u _Z5setupv -u _Z4loopv -Wl,--wrap=mbedtls_mpi_exp_mod -u esp_app_desc -u pthread_include_pthread_impl -u pthread_include_pthread_cond_impl -u pthread_include_pthread_local_storage_impl -u start_app -u __ubsan_include -u __assert_func -u vfs_include_syscalls_impl -Wl,--undefined=uxTopUsedPriority -u app_main -u newlib_include_heap_impl -u newlib_include_syscalls_impl -u newlib_include_pthread_impl -Wl,--wrap=_Unwind_SetEnableExceptionFdeSorting -Wl,--wrap=__register_frame_info_bases -Wl,--wrap=__register_frame_info -Wl,--wrap=__register_frame -Wl,--wrap=__register_frame_info_table_bases -Wl,--wrap=__register_frame_info_table -Wl,--wrap=__register_frame_table -Wl,--wrap=__deregister_frame_info_bases -Wl,--wrap=__deregister_frame_info -Wl,--wrap=_Unwind_Find_FDE -Wl,--wrap=_Unwind_GetGR -Wl,--wrap=_Unwind_GetCFA -Wl,--wrap=_Unwind_GetIP -Wl,--wrap=_Unwind_GetIPInfo -Wl,--wrap=_Unwind_GetRegionStart -Wl,--wrap=_Unwind_GetDataRelBase -Wl,--wrap=_Unwind_GetTextRelBase -Wl,--wrap=_Unwind_SetIP -Wl,--wrap=_Unwind_SetGR -Wl,--wrap=_Unwind_GetLanguageSpecificData -Wl,--wrap=_Unwind_FindEnclosingFunction -Wl,--wrap=_Unwind_Resume -Wl,--wrap=_Unwind_RaiseException -Wl,--wrap=_Unwind_DeleteException -Wl,--wrap=_Unwind_ForcedUnwind -Wl,--wrap=_Unwind_Resume_or_Rethrow -Wl,--wrap=_Unwind_Backtrace -Wl,--wrap=__cxa_call_unexpected -Wl,--wrap=__gxx_personality_v0 -u __cxa_guard_dummy -u __cxx_fatal_exception +compiler.c.elf.flags.esp32c3=-T memory.ld -T sections.ld -T esp32c3.rom.ld -T esp32c3.rom.api.ld -T esp32c3.rom.libgcc.ld -T esp32c3.rom.newlib.ld -T esp32c3.rom.version.ld -T esp32c3.peripherals.ld -nostartfiles -march=rv32imc --specs=nosys.specs -Wl,--cref -Wl,--gc-sections -fno-rtti -fno-lto -u _Z5setupv -u _Z4loopv -Wl,--wrap=mbedtls_mpi_exp_mod -u esp_app_desc -u pthread_include_pthread_impl -u pthread_include_pthread_cond_impl -u pthread_include_pthread_local_storage_impl -u start_app -u __ubsan_include -u __assert_func -u vfs_include_syscalls_impl -Wl,--undefined=uxTopUsedPriority -u app_main -u newlib_include_heap_impl -u newlib_include_syscalls_impl -u newlib_include_pthread_impl -u newlib_include_assert_impl -Wl,--wrap=_Unwind_SetEnableExceptionFdeSorting -Wl,--wrap=__register_frame_info_bases -Wl,--wrap=__register_frame_info -Wl,--wrap=__register_frame -Wl,--wrap=__register_frame_info_table_bases -Wl,--wrap=__register_frame_info_table -Wl,--wrap=__register_frame_table -Wl,--wrap=__deregister_frame_info_bases -Wl,--wrap=__deregister_frame_info -Wl,--wrap=_Unwind_Find_FDE -Wl,--wrap=_Unwind_GetGR -Wl,--wrap=_Unwind_GetCFA -Wl,--wrap=_Unwind_GetIP -Wl,--wrap=_Unwind_GetIPInfo -Wl,--wrap=_Unwind_GetRegionStart -Wl,--wrap=_Unwind_GetDataRelBase -Wl,--wrap=_Unwind_GetTextRelBase -Wl,--wrap=_Unwind_SetIP -Wl,--wrap=_Unwind_SetGR -Wl,--wrap=_Unwind_GetLanguageSpecificData -Wl,--wrap=_Unwind_FindEnclosingFunction -Wl,--wrap=_Unwind_Resume -Wl,--wrap=_Unwind_RaiseException -Wl,--wrap=_Unwind_DeleteException -Wl,--wrap=_Unwind_ForcedUnwind -Wl,--wrap=_Unwind_Resume_or_Rethrow -Wl,--wrap=_Unwind_Backtrace -Wl,--wrap=__cxa_call_unexpected -Wl,--wrap=__gxx_personality_v0 -u __cxa_guard_dummy -u __cxx_fatal_exception compiler.ar.flags.esp32c3=cr build.extra_flags.esp32c3=-DARDUINO_HW_CDC_ON_BOOT={build.cdc_on_boot} # diff --git a/tools/esptool.py b/tools/esptool.py index f615db23960..7b8a32fc8d3 100755 --- a/tools/esptool.py +++ b/tools/esptool.py @@ -27,6 +27,7 @@ import io import itertools import os +import re import shlex import string import struct @@ -227,6 +228,8 @@ class ESPLoader(object): CHIP_NAME = "Espressif device" IS_STUB = False + FPGA_SLOW_BOOT = False + DEFAULT_PORT = "/dev/ttyUSB0" # Commands supported by ESP8266 ROM bootloader @@ -353,38 +356,53 @@ def detect_chip(port=DEFAULT_PORT, baud=ESP_ROM_BAUD, connect_mode='default_rese connect_attempts=DEFAULT_CONNECT_ATTEMPTS): """ Use serial access to detect the chip type. - We use the UART's datecode register for this, it's mapped at - the same address on ESP8266 & ESP32 so we can use one - memory read and compare to the datecode register for each chip - type. + First, get_security_info command is sent to detect the ID of the chip + (supported only by ESP32-C3 and later, works even in the Secure Download Mode). + If this fails, we reconnect and fall-back to reading the magic number. + It's mapped at a specific ROM address and has a different value on each chip model. + This way we can use one memory read and compare it to the magic number for each chip type. This routine automatically performs ESPLoader.connect() (passing connect_mode parameter) as part of querying the chip. """ + inst = None detect_port = ESPLoader(port, baud, trace_enabled=trace_enabled) detect_port.connect(connect_mode, connect_attempts, detecting=True) try: print('Detecting chip type...', end='') - sys.stdout.flush() - chip_magic_value = detect_port.read_reg(ESPLoader.CHIP_DETECT_MAGIC_REG_ADDR) + res = detect_port.check_command('get security info', ESPLoader.ESP_GET_SECURITY_INFO, b'') + res = struct.unpack(" 0 else itertools.count(): - last_error = self._connect_attempt(mode=mode, esp32r0_delay=False, usb_jtag_serial=usb_jtag_serial) - if last_error is None: - break - last_error = self._connect_attempt(mode=mode, esp32r0_delay=True, usb_jtag_serial=usb_jtag_serial) + for _, extra_delay in zip(range(attempts) if attempts > 0 else itertools.count(), itertools.cycle((False, True))): + last_error = self._connect_attempt(mode=mode, usb_jtag_serial=usb_jtag_serial, extra_delay=extra_delay) if last_error is None: break finally: print('') # end 'Connecting...' line if last_error is not None: - raise FatalError('Failed to connect to %s: %s' % (self.CHIP_NAME, last_error)) + raise FatalError('Failed to connect to %s: %s' + '\nFor troubleshooting steps visit: https://github.com/espressif/esptool#troubleshooting' % (self.CHIP_NAME, last_error)) if not detecting: try: @@ -663,7 +677,7 @@ def connect(self, mode='default_reset', attempts=DEFAULT_CONNECT_ATTEMPTS, detec if chip_magic_value in cls.CHIP_DETECT_MAGIC_VALUE: actually = cls break - if actually is None: + if warnings and actually is None: print(("WARNING: This chip doesn't appear to be a %s (chip magic value 0x%08x). " "Probably it is unsupported by this version of esptool.") % (self.CHIP_NAME, chip_magic_value)) else: @@ -814,20 +828,23 @@ def flash_id(self): return self.run_spiflash_command(SPIFLASH_RDID, b"", 24) def get_security_info(self): - # TODO: this only works on the ESP32S2 ROM code loader and needs to work in stub loader also res = self.check_command('get security info', self.ESP_GET_SECURITY_INFO, b'') - res = struct.unpack("LOW if self.uses_usb(): # Give the chip some time to come out of reset, to be able to handle further DTR/RTS transitions @@ -1900,6 +1922,8 @@ class ESP32S3ROM(ESP32ROM): CHIP_DETECT_MAGIC_VALUE = [0x9] + FPGA_SLOW_BOOT = False + IROM_MAP_START = 0x42000000 IROM_MAP_END = 0x44000000 DROM_MAP_START = 0x3c000000 @@ -1943,9 +1967,17 @@ class ESP32S3ROM(ESP32ROM): PURPOSE_VAL_XTS_AES256_KEY_2 = 3 PURPOSE_VAL_XTS_AES128_KEY = 4 - UART_CLKDIV_REG = 0x60000014 + UARTDEV_BUF_NO = 0x3fcef14c # Variable in ROM .bss which indicates the port in use + UARTDEV_BUF_NO_USB = 3 # Value of the above variable indicating that USB is in use + + USB_RAM_BLOCK = 0x800 # Max block size USB CDC is used GPIO_STRAP_REG = 0x60004038 + GPIO_STRAP_SPI_BOOT_MASK = 0x8 # Not download mode + RTC_CNTL_OPTION1_REG = 0x6000812C + RTC_CNTL_FORCE_DOWNLOAD_BOOT_MASK = 0x1 # Is download mode forced over USB? + + UART_CLKDIV_REG = 0x60000014 MEMORY_MAP = [[0x00000000, 0x00010000, "PADDING"], [0x3C000000, 0x3D000000, "DROM"], @@ -2007,6 +2039,49 @@ def read_mac(self): except TypeError: # Python 3, bitstring elements are already bytes return tuple(bitstring) + def uses_usb(self, _cache=[]): + if self.secure_download_mode: + return False # can't detect native USB in secure download mode + if not _cache: + buf_no = self.read_reg(self.UARTDEV_BUF_NO) & 0xff + _cache.append(buf_no == self.UARTDEV_BUF_NO_USB) + return _cache[0] + + def _post_connect(self): + if self.uses_usb(): + self.ESP_RAM_BLOCK = self.USB_RAM_BLOCK + + def _check_if_can_reset(self): + """ + Check the strapping register to see if we can reset out of download mode. + """ + if os.getenv("ESPTOOL_TESTING") is not None: + print("ESPTOOL_TESTING is set, ignoring strapping mode check") + # Esptool tests over USB CDC run with GPIO0 strapped low, don't complain in this case. + return + strap_reg = self.read_reg(self.GPIO_STRAP_REG) + force_dl_reg = self.read_reg(self.RTC_CNTL_OPTION1_REG) + if strap_reg & self.GPIO_STRAP_SPI_BOOT_MASK == 0 and force_dl_reg & self.RTC_CNTL_FORCE_DOWNLOAD_BOOT_MASK == 0: + print("WARNING: {} chip was placed into download mode using GPIO0.\n" + "esptool.py can not exit the download mode over USB. " + "To run the app, reset the chip manually.\n" + "To suppress this note, set --after option to 'no_reset'.".format(self.get_chip_description())) + raise SystemExit(1) + + def hard_reset(self): + if self.uses_usb(): + self._check_if_can_reset() + + print('Hard resetting via RTS pin...') + self._setRTS(True) # EN->LOW + if self.uses_usb(): + # Give the chip some time to come out of reset, to be able to handle further DTR/RTS transitions + time.sleep(0.2) + self._setRTS(False) + time.sleep(0.2) + else: + self._setRTS(False) + class ESP32S3BETA2ROM(ESP32S3ROM): CHIP_NAME = "ESP32-S3(beta2)" @@ -2024,6 +2099,8 @@ class ESP32C3ROM(ESP32ROM): CHIP_NAME = "ESP32-C3" IMAGE_CHIP_ID = 5 + FPGA_SLOW_BOOT = False + IROM_MAP_START = 0x42000000 IROM_MAP_END = 0x42800000 DROM_MAP_START = 0x3c000000 @@ -2354,6 +2431,10 @@ def __init__(self, rom_loader): self._trace_enabled = rom_loader._trace_enabled self.flush_input() # resets _slip_reader + if rom_loader.uses_usb(): + self.ESP_RAM_BLOCK = self.USB_RAM_BLOCK + self.FLASH_WRITE_SIZE = self.USB_RAM_BLOCK + ESP32S3ROM.STUB_CLASS = ESP32S3StubLoader @@ -3215,13 +3296,17 @@ def slip_reader(port, trace_function): """ partial_packet = None in_escape = False + successful_slip = False while True: waiting = port.inWaiting() read_bytes = port.read(1 if waiting == 0 else waiting) if read_bytes == b'': - waiting_for = "header" if partial_packet is None else "content" - trace_function("Timed out waiting for packet %s", waiting_for) - raise FatalError("Timed out waiting for packet %s" % waiting_for) + if partial_packet is None: # fail due to no data + msg = "Serial data stream stopped: Possible serial noise or corruption." if successful_slip else "No serial data received." + else: # fail during packet transfer + msg = "Packet content transfer stopped (received {} bytes)".format(len(partial_packet)) + trace_function(msg) + raise FatalError(msg) trace_function("Read %d bytes: %s", len(read_bytes), HexFormatter(read_bytes)) for b in read_bytes: if type(b) is int: @@ -3233,7 +3318,7 @@ def slip_reader(port, trace_function): else: trace_function("Read invalid data: %s", HexFormatter(read_bytes)) trace_function("Remaining data in serial buffer: %s", HexFormatter(port.read(port.inWaiting()))) - raise FatalError('Invalid head of packet (0x%s)' % hexify(b)) + raise FatalError('Invalid head of packet (0x%s): Possible serial noise or corruption.' % hexify(b)) elif in_escape: # part-way through escape sequence in_escape = False if b == b'\xdc': @@ -3250,6 +3335,7 @@ def slip_reader(port, trace_function): trace_function("Received full packet: %s", HexFormatter(partial_packet)) yield partial_packet partial_packet = None + successful_slip = True else: # normal byte in packet partial_packet += b @@ -3923,11 +4009,14 @@ def write_flash_status(esp, args): def get_security_info(esp, args): - (flags, flash_crypt_cnt, key_purposes) = esp.get_security_info() - # TODO: better display - print('Flags: 0x%08x (%s)' % (flags, bin(flags))) - print('Flash_Crypt_Cnt: 0x%x' % flash_crypt_cnt) - print('Key_Purposes: %s' % (key_purposes,)) + si = esp.get_security_info() + # TODO: better display and tests + print('Flags: {:#010x} ({})'.format(si["flags"], bin(si["flags"]))) + print('Flash_Crypt_Cnt: {:#x}'.format(si["flash_crypt_cnt"])) + print('Key_Purposes: {}'.format(si["key_purposes"])) + if si["chip_id"] is not None and si["api_version"] is not None: + print('Chip_ID: {}'.format(si["chip_id"])) + print('Api_Version: {}'.format(si["api_version"])) def merge_bin(args): @@ -4492,329 +4581,340 @@ def __call__(self, parser, namespace, values, option_string=None): # Binary stub code (see flasher_stub dir for source & details) ESP8266ROM.STUB_CODE = eval(zlib.decompress(base64.b64decode(b""" -eNq9PGtD3Da2f8U2BBgCjWTP2HIezTDAJGmTbUI3NO2lLfIr3dymJRO2YbvJ/e3X5yXLngGSbbcfBvyQpaPzPkdH+vfmeX1xvnk7KDZPLqw5udDq5EKpaftHn1w0Dfzm5/Co++Xtz+Db++0DI03bG6PoJy3N2L+f\ -TuXq4R5/kI9dV/A3pyF1fHJRwr0KAhg7tu2fpH02ObmoGxivbWABtrrtIl3A22ft3Rg+h65TuNDypO1ETQCQL563fagAIPgJvpm1Q00QMkVtdbEPQMIlt5s9h7+3U/cg2se/8mU7SF3QIPBd1sIT3w/bhwICXbRA\ -1Ti523EfhGfS4mQTpkJzN2kf4fLjD0ftnw7Cb6GbOWCp1+jbXiP4JGmhqRDW2y34qmScUoP4iIcBagj+W15YABXolcU7xwTGZwLhiPr+Vw/3HhEn2ZLf2rG72WpBUNDx9HE7cYtXDAv2eyo815+4XoEMQP2qZ6bs\ -8yCNMGjYDTJ4ybMg5LmbdvxNr8fxKnAZ5N7MlfE6KXpvepJiRgPpavwOEr4BLLgb6Mn1lpcsD8196KEScTTuMRFMFwNUmG4mTsiftn9q70bHcnPXA7NQ3vjF2Lup4MbizR3vg6anNUofMuiq9lSIKvqkdy+xpcxu\ -JQOoPoQkpAyA7jNW7tMDb6xMpxR6TgmJ7sZ2Ny+QitODOf7beYz/Lh46nvqCr4rxI74qy8/4qjI5XrWtK+ka5lbjlKaPN2Rs/jYkmAD6HFQfySZ+ojXIcGTXIpRQml1sWy1VxrZVcFVsQfnEFvRabBlvNWva0uEL\ -hohZZxUJY6okOVCpj20AKf4yyqC1IaVcAJo1QwACqMr97bZHULuWDQS2g850+J4H17/zgBbV0vaOU0ftBWAoDun7Dhh8qv2nR9R9tTQjaIWqNSKMIRDUPVApCdaDvn5E+APuLhl2x8/jj33+RgSxVfF5zUaALrRc\ -FAyZ4unFDGW1gjo5MoAmTK05yA19ptO38g0jsOI3A0Wfd091HO0Bj0Wo1wGOch2fTGbP9mMbbSC3tXpBl0kGzQM2TcYXNPo6ifEfGC80jlpFQQP2VW/turG3oEVkoz5H6TKKnu0TgxCzCCONCU7QedpGhy04Bb1e\ -PWIctGjKUKtkxM064a4QkxOysK7/uoa5tg8nDMyEOEbpVqar0tcWHoqAix+QHCIi2w9ylOaTzfE+UBSeluAwsBZr0kXQcGuTvpGHM0Ak8Ca1P4bn7bgl+DoKUCe9mwyfHHU9W+4ZiFGir9CSysT/Is/HuLG6lgB2\ -7oMNLw1Or+nPxSb8Rdrxny7X3afz9zxXtIiApH63n8tr0uIl2IPhuDwEgF5kguKGSNaO8KWMCqa2G/gFY6jAz2dEw0o/AM78CUcEXahL7xPjt1TY8itGoXM55HXcg/IWOkX8Kslcj+0FQDxpLyyCvjNjEavRg0sE\ -k6+w1U12FkUzA7sZn8eVOpQnJAE5Xxt37aSBwQHx0yhEBdgU+swA2+hj5tvKwYS6RNVzlh1xJAG1CczzR54MygCyUdLxWe544ZSkQ+l/LKu/xlKHeRnRZ6bnvQU7e/BhM/zwGKixBkaJjGCDPsIONSnLWwDdP3hY\ -FaCDfkxQg9df65vUISokhBM9cATyhxVjVaC9atW9cWM12efki3pdEczfLPXTCiHOZBnmY4lI5t8B0IxJw2ze91UaZmJgp6ryzBvQK+40lkkvVn92wHhJPYdcPlR6Q9pBizPkwF2wnSAdGY1Wxx1PuhFj4ODC0f8X\ -NC/fg/42k99QLd4VelwynEmR9DEOF9KELh8ucxKP7ubWPTZLJVAKkBfT6OXkLYwD7ltG1Cdf4BF0VSU3wZ1ZA1s+ZvZNv/PsZpN439QzL1ASQFr61BnFojTzF9zAHG3twgPoAcW4FG2BBg3Gy8HCgIxp8wQ+L9i0\ -ND7dj9iNAqVWHDxtw9q/QxfZDXBKyYxNjvAf22IQIuBErSXY1E/3g2kc0OusYxe0fQqsbbABfcqcdEBw5yjl+z4bhewsOZzEV+DEcQPqdTAtromhJtqx2l3qo45nDn/w+Hanzk3cQU6kBpbresic7YFoZNLsd0YD\ -ve7JHGeggvFqgUF4nA6ntqA4wKlpKVNXrA/j98QXSCK0BFufx+IjqiVX7uFnreei6wLd92AdnO84BL5HqtbOvzkiv31fPT3AuDPqO5gpBWCgKwHnZU1efJPdJWyi7sQghSY+J/2B2gFMFsLV+MJNKROM86HzXtrA\ -snZzZH7IbhfgfeLYGkS1nt4AyVE/wN+nEYG1xArxl63vUjDn1BVj2RA/utZ5Zj7HqHHcJw1AT3JCEUI16cBR6rtt9A2/fI65jS8PxEF9SkawlZUJjanTFoOVfeQ5XjB6+pJxY5KOZeoJU4g4reOYdDl4XKWh2J1G\ -VvyR4ya8LSc/wO3hr2hzH2MA5juIDbnL+mQTZHgizhz6HUCOsbiJACVSc7wRd20akU6gae6FwuVa1vko2BtgX/yCKsZRD9lzSpwszEUJzqW/kLQdEtLcg093veiDuaYffcTysIs64DEmN4I1YpkalBHIeKXuBYck\ -c0qDWsf+S+pfWKj0Qgh0O2t2fYp02IC5ECfx4vuHT8y9iAEuJ68Y7ymb95o8twVFdC5EQG0aJIFjfKe3Dx/xvFNPMbqhj6TZkV2/PNSJiGvaXu02Mxz6JudoCN9Bp28o+oDeizhCCWWcGuG9Ft5N6jmPw214YdEk\ -8/xbfGzmHktbkCpqEUPcYiY5IzAO0zevofOjcL0It8++ZK/KHrx6Tn6jGR/ZGzjCDkcYzvqBHRu3IBfIpPPH9A7EEATQAim1OoK/k63XAKrdQkA2juzo7tegyj6APO2SDoAUQeuPbnouD8RdkI08AQjJO96iwREL\ -aIr0zFddog4ocQFGCf6bZAT2f8Tc00LArm+Nd1ue84uaRi1CCVp0cgYO8/g9WPHTfejzNaYXiu8BP4twveMoxV6wieFpS5kbIbsUEApAVq9CmTRi4S9yoimaLdbJNuax19QrwN97ctsRlvEpyEoPgDml0VTSQnLU\ -DrgFA35D4VJVHLEPoAi9Jv6WBNSoWxIEgch/F82sPoLsK/EHGJ8qAz75V6erdDIL9VE4Jq45Zp1BQUcQPAdYjykaoSReMBZeN8GE85G+jRVfVsf2s06WdDNlYbL6m7TLlqoG8+2KNAkSG2QEOTRRTQBRxbwTKLVC\ -c1ctWULWu/XOPiOQ7QPGPPygAAdF10yXWhgCKMHcIJCfrgk90F9J6BPKJXJnMOrci4Eq9tpa7iB5KirKtiPS4W2xG3V+FqnzqSg/Tbgr0fOtA4a1HgMIzRsnRGB+1kfABUG41/4vM+LQOtkjmpQY/B2TOdNkvtZP\ -Nu9uzcWXRAbmSUMC8ap5fw3rGNhjXnwAnYcx4biTCPpdjRGLGLGCEf2fYoRnQjlSvOFU55RxgDwUcRRmAg5yFQVrYtrBRcqZy0zqrzx8PDvw5zWHUjBvRkGf+rX62LnKHA17h2AAwUeqIYYqOaB39AVeAHVC9rCC\ -XKBzuRETZm/V5JjyIvWO+KQCxzJFIG35lq3heGmKQE5IFTcElKNr1Y5ZgehWsawSNTb6IhLABBGaVUSTftW5QJRrC8nANNV7XsGLSRlpyCvgRRU06hTWXMatu5c34vvBm04XIKA7OANeZyF0Bqw+mo+j9N2E2he9\ -POAnSX/+n0u/0P81AYzMrc7F2Doq93gCgXALgXf3Gbds1x1qwv91BpmXU1uagv0tfoXLQ6HXc5IWZKTsmBFhWBWWXlox8dKd8VUICm1vZOtbyOsJslOyAsr7yziXyl8FFhpSYjB6BcutpXoKWlO95MSDxo5fEjvT\ -XfOEIAIP9umNoLWehZ2IAUXfSsTRCVYRTpz9fAXkfvX89FdMCQGf53Na8sSoEtGwwc4ChiHjlRPB5bEk/NXTvRgMZAPdi+tUG87PDzqNEr0Ejb/DeRiDg8/gWSzacEJzW4Dv1E0PV0x601uECc2N5gnefMYpyVzS\ -IcrM9iFpUoCkFgmkyWjZRZ0Jk0B6FR18avOO2hAr5eMFAP0C6PVc0pcXc19gfm+/yi2GF6hRdgkTusC0LShCHb6CT/WrLv9pemtXM6eKIg6jmmyOadPwJX3TaqxOSsHW6Gru+SrKc+XYgNorDSj7vOnfB2o0RNeX\ -BizCGy9XeQv34j6tWV/AmBhq1YGXtiH1kaF1DGG0au/vbgSvnXjR2GHSKaDpV0xHIA665FrSxI4Rkp6hfYgJxV00QOsK1qNVVLLz6VT8fU/FYyYwfIB8yDaPVqY8B1Xpn4bcR7yPfO6EbN5f12Xf3NHEXEOTWjQ7\ -asaFE7octQf69JlY73f4avOTbDd6bhgigFHU8QreantX69sHoRqY9haXPUsOfh2hMyQYW/MaYWx/n5YodZlAyhHMObJNxgZDiVFEzn/sZQkoj6kPfM2GOkDp/ZWijxkpmECJ8z3lKh+II+I9cqhbuLdwhkJTDhEw\ -1xNbVLV3hp0j0cCNgZQEMQVWC13elQKqDzuBFEjZUGcQOWwjK0bEisYSK7bR6W5kP3vCbNRqMqfVWA8njBnVvOg4WFNwGkfC2IRsHYefTW9hViqm8h1avB3BuxHr0cpbZ4XoVO1TJznW1hx8QWkeXOFpvtjbHnFK\ -gscZUfCcQ4hvOeVXT6ScqIQCHsOy3KTbN0N2vsoZafBKTR9wDArDmReQTDCstYtyex3pchPBO8dc6MzmEWX79j/G19lJOmPs6cWbOOAvQl7wDtGHMBRwaYjzrbrgJeuCE/q5Zx1NtxLO+IismYXmLMDsuL3FctBM\ -o+Dszd7xj12aAEYzWXbn7IIxrd6hQXwHt2dnehaqBX6PuZM3nGdiT0YbLgSCIhCrAV/jM4I85+IVWOfSekHZBrf05NTCLLwFX0ezF92yWPv5JqkTXABOA5KqPCAhwuo3S8JkWT4L1QqVzQkyi31MBY4FMwyo5fJl\ -DAOVHygjRUmtOhjtkUOJMJYc/IxdDglJw6OrcSfKZQt+/p7oQc8Ugzbmyh1DL6xaCcw7Aka9dfk1zGuFGTtmpAiyWchLF4VpI1gaGpBQmgDpG7wDUN6jAgjzs9/V74tI4N9+B44MaJsSmuUY0HwD3c2A74CbcvS4\ -D2b25iL8jFQ5ukycLS14qa2Fa3djy1vmzHll2XhmEjP0boUKGnZR1A2QsBHntdNIrNwNzpUK7mtsPt77ALfba1NwYRTHMhSbxZg+DDSnBnF4NQIVkMa41AZOSOvYrXfr/Tru+38wGMKZHFASBYjSlO/JWfcs9ym8\ -huipRfOW2t5Af8rBlIuuKt6SLkFcpDdL9Pdekt8LJmYpqfURnpCWEpT0t3561XlEnhdURxJA6uLe9fZWaIXmD3Hh5ccr2y2fUH6O8/RscF3OjnwhLK1yw1exrBatgGItcImJWFIN4T97dLdfEd1PEcexT/ekR3dL\ -dM819GnG85PzYU3iz6yogN5jFlNdSOwwRvpCCZnGEttxcLKpUMfb6LRP4CeEpByY1hGi79k5vy+CUJOWM042IcM/CW8DHAvMRra0/4GgkpKkxUxW78Y9G7/VUJYU8tUQ6Wfk9bto1k/qeTEQLWKAUiVuTjGZl0J5\ -b62/JtR2aXchU2Q32HPnjutPZVUorUonH8Gnq6P7RbhxXYD/jrNYLW429JSQmFMMXnareGyRGvo+RxetaNzyBZALIj8MF/2Y0PSoud2EbEuMI+z2LXGuGlqNUaUsXMHP7qOfVd4euxAEg+JhLPyI2g8D4VckcuRb\ -LVUyl5zRxJLx1l2B5d8WjfAvflVJKB5z7QOGERmXbWV9i9tjla/nVDEoiYE2GoT+Q2BzVGHNCn93MpxA6xSKn03FEFoThPFtrJtUww/8wFhTSqMptohEbSw1YmJpCn2b4oJ81SrlhQMql9IFWBSnyKTyyqIrVu+x\ -o1I8HcvzNTQKT2RlTBSeZ61M+hnzPTdG27THqbYCM8mgo3o2qVhhk2g1gG3SkWeTYOD1rlRMJyuKcPvmiU1S7nkk/03z9DHJXN3LdFYflVT6k8wTBsXF0Dwt1Rua4u6lJuomd/sxtmmPE+NXkh79baiiUkx9quQK\ -RlpKncghLH14kchok4qOsLpY61GXLAs7ndhVxi5yk6DCmHJ1M+frMbmLxIUbqMZz6rif8A+cterW7Bt2p4lJp53v1I/hpViIIuke1cN/IKq8HGlDiVEOr3XxfE4bP/ruIrBUTgnwzo+Qtee14DJ2YUJ21JLQtaMW\ -hhZq2YMkkimNNKpSr5imJGroYv0yN0Hl6jYs22XMGMYm04R9FSz8QXchZuc04TRA5dmbS2jxDlD7nkuhsOIiA8jsbAkzBwj+enC5IPlemMfOZ8vYIYae+djB7qeBnj4S7MQednBJVELbdEkLjVothDsPilWe1Gte\ -Fme/vakkc+7hWhAz9RCjOPuLCXZEZjzvc2aLAOhK34SleinrbgA0M25oaaRXO4L4wvTaNqSJMF+DqAFG1a8irrrekOLoonVRXhUcH3DZEFYATMAx0ZRmX3xaXk2XUmr2P50i9ZSol1urqHRy9cpI66ZtXL8+YinT\ -WWBbP6WZ+t/4yczTQTIz7TtJ3bJ1vWRI2TPAmA80Qi/oKyno20tWq1ZgXtVcEfIp37zOeubViHkth1Hf6sgPFjqKvyTs+xSmQCDTm5da1wFj/FnWVf211tVy3ULHAqd9Frgi+jP96K9vXQ2WORd/deiH3nMh0qO3\ -E4NZJruhuf6ZVoI3ttdYuWyhGvmFl/wzLLSYf0qVhebFEqx/y7q83PUOWXWZLsk/SpfkGUdjrHp8dWK7zwpaIu00yjZFGr/0EMjljojDwm694Y1WluLgs3+S9mgB25FUrsXAjNUK2XZ1O1rY0T1SBrK3Cl2hPd5S\ -BK6BRczhRhdcJXZKIiSt0NidryFiLtPXuBwMxRxQsNzYDycLDKVLmG7683WpXin+s84dImSNWpQswp3TbWQYWuRs7BkhZ82jA1DH4vYd0vB2xNZPFb8eMz9VfjEoSyJ9XzBPsH2V51jnqJw5j+9E+CC+A1Y15WJB\ -LUrLtVPUC6yZqonAqMnevnruV61INvY9JaiNi1oW3p4tSSrWkvUDQUDTkZFicjuEMgkdsYol8JYVP06b7rDXxVtXOvG4uiJhoF7z/271zXuYjau8aflsPijXgvU0v2ahZaN1qDS0nPHnugeM3jFrDpDQxRPc62fH\ -3nq127slK5cQjLcxfBuMB1RlqF3KAZhh57K6n08gQp70y0j+7MVDKfzAoOm8jy1X9qFSWWP5uLTWDlYTgJzZvJgPgeecFlYWxl1lYQv/3imveqAl3ZIVOil6HdEDKuUxc1nk9fsOv0NNtJYXXXWfcfk+aYXpvQ2S\ -Vz35EjYylAt/P84l7GOYfcyQfcBwQvbVis8LfEQXkCe6EGaS+gdapOTE1kS23MmiIuXm2D4An8GCQY2pjHDEZIl5p3L8E1zg6iIwt1uzLsIJF3YDIbEVRA94MeH67YysAC7VTLgOW+QY9wfWmAi21EllsKb6kCYm\ -O6yxBHr8RFbQ+Df5wOgvLxAQXEW/MawO891w0auU1MKq27grEYdngARYnwQ5Q5hqT+Ul9E5+GNpb2vXq2oyveDe54l16xbus/w5gq/neFNFtmMWDHFA7XYO8GrBywSjP1WkvEIt9Cwafdp1t56RPVfwA1mUb/TdA\ -Ae6kmLWuwgqmog1UCsomAFe0e2JXdrX8RuuH2i1KT9/xBrCW//Yg422Jf2TTBeQusl0ua8VaIimRT5cPT8CVbNCoyvDolnIaQNUq7pisKo9FLTMz1bwcV3MNGi4PJkvxqpfb5XBBydIjGnesA7dH4fbWWgE11BXt\ -pYKL53wBDSve1t7Y0ZpBJ7y4dWS33/A+MhBd+3VwKyjs+rcniwCy2JOziWwYBLBnlMsxWGiMm9NoZwsXfsomJ97rSyQDqCfbbtP5ArG+TdBg9WvOWsXABjXop4hF3m5p2UkAc8CgkAmB66YFx1SNtwu0zEbfe7ui\ -lDoG7VlD32g24/kzrn+QTVZdDl0e5tAFFuq3DsduVwqg0ses9FAoeTcAam+7vGVd18vPTfqAHxoBCPMBhwKTt00D8+eD70vl2VYIaBsr+2uopOP9nLee2Ms76e3XSZYDuBI0XwMANmongLAJ4qGSkVBy3Xdj51CA\ -XqCYJbJfxEwSb2dvNxpvlzMYgowwV//hp9e012Rrt2NuxdmVJu/DXPv1HjFJSxlLUuQGB3Ee9pvJcidukLQLs8ihB8nNH35vdh/xxhvaJ5R7G8EsHzGATn4uZRSGt4e5TXsMF+6dUJD9QzOT3+tG1yW+cg27BD/A\ -01tflaRgKQBUJCMRSX/JNYtI7Djc759eUcYhnk8R4vkUIZ5PEd4nxa21f/LM8KiSrv4UbjoddOqfFHMa8npW70Ah0nreURDMz/HJOTzLeXMk6svGDI5UKNnRQIWD5bgl6YhKs92Bak+/phNPoWjGvX4gkGwD6gWe\ -bVR6G0xoP7ckorg8lj4OOQvd8Ak9HfDMAqUJ6cgHrT0JXXmOj7MLckCEw1vsYzReQi+M7SHV3wqm1PrxPgNKpzjtCUv2T56QTbzd40e94ynwZI7j8yWEuVIqKhRR0dKUzNIRMNPudB5nE8f+nD2uQMqX+gzBP9db\ -j4UPSOWjg2EOuzlpydwYaMqr5PB/AWEyri+WWzsq6mKQFnS2TgkFyxVwkMYjXGCznHAb7nBERFZyWEhdLyOyj//jt9y0ypZ5LQjWj2fowWPaIaPyKZwcb8vSaVekIRqsUmugvszjAKmTPzY722ujHeTKc1lNxIoa\ -3G8PvgS6dFCzWPUBjirRY3nveVz0jqzyZsK8rzzKIdv7XL6Kux/LqTvyEvUwiGapD5g1cc+igVg23zs5fwOEftYpcMyoJKyjOa2oWR/D/HD0kkpLII+NlCz3Vu1NOuSlgQZYxEqCZry1gyxSccEPb2wVpspjjrU0\ -Zuyae5xF67GBO1sBVIgpY3EMxqOTE/z04V022A2sgZRQrKTLR5DsNG8AjQC8ecbhZNOd+RWsVBSNXwT9bER49KTnXPaSjWeYXlGP9x7dcAoA2k5GE1wtH38Rba8FO3ujQzFQUS1HS/zPCoNotBiuSbBG1vQqpabu\ -DMiPwLldyFz2reVIjarwDHoz3JGKhF3S5/65IIVsx5Uz8NLL+uFS3M4S9OZ4naZeUlSsms61rI3dBkPa88ujzhGTkFmOGBEdBroiF80FTgXqYbyIrxYz+L3wje1Z/4w2qNbF4kCkRYkHukzH3jMMOHM5+cojwZLc\ -gpCizDpJ7U69EqmNutihlOVJcbGGh5XoLgw3Lo0iIQsupzR8olNF20EWIIF6txPDRq0Uw6acSWMPHiVRxACOSs4f4mvKGR/z1s0qpN3rDR40wl1hNbKRPrMVR0TVuttToRI5JWYimNjtvMu+okIuLYkQch4Je2Gf\ -pDA6Pu2OXTrnUxUK+x+w/s8+W/3k35z7Nxf+zfs+K5rB8YH58N4/3s2Ud1bYD+RPpiFZj8r3whvmVGDO8zfMsT6TtmRwvg9q9x1e87AJOj97HU9VPr3tgXfMijqqRJpfUy3dal60kqSQXXpYedfAYZPpS7+c9RFt\ -o1l4e+6XDoRLxAFB/tne62Cefz44a4JO89N8Lk7TDYrfsE+KnsRGd1YHQQNZ0Diwwnv32Hm1DZxhidvRawy2+Wg2a1ac9FYZPukTh3tBY0FcXMiy23j2mn25yjsyYymPsUcEwFNrxNezB3yaJsqSFiDr3e6oJtyL\ -2RwKRRBonkildhny3K6glvhENR+j1M77hay7JAIALeKjuwZzAs7Ewsfm6Y7wGK3RdWfqCDrnMhHZq6VmT34O+RiGZqBWilXHNNGBKFY+iU4WKJfgpKHlg+yA24/OCx94Wk/6Nylg0w6TAM042u+Whmo+kYPw6g52\ -zWSrxMbfRuG/WTrUvaAH8P+t0CkTLrZrwt+WtOGhlAQfigbd6ZKalhOr/XyInHgEGwaaBo89sH2JggyU+eaut/AsXm7qRW3e+uCnq1fIGMXu6CF06h/w2gdgr/QSDyrtiOG2pSgo0Kpj6kz2C2YbER/TsrQgImei\ -FcDhExwKN4tEIxasXkbGOUt4AtoEowOEBlvjWVB91S7d407fWGZS9D7rXDT3KbYeGokiXcOqLDgqpknxNIEENr8Uk9HTA+8Iu3G3fU4Qk+EGTMUMpIvI7TlRGhz64uCY0yl1lkouLfIBMFT2gk+y1EuhxKvcOPod\ -PDrujnvkVu0ktgD+2IcfcieXTYGSMJR5bIGdMZzNMVfYNX4DGaUsv74OkCG4OCYkldvuzwPeDSZrhEvfxD52u9ebOwGeMv3j23O7gLOmtcrGZpykY9O+qX85X/zLeziJ24eVPbd8KHXvDF2UxYnnk0uJsnB8wj+O\ -LEFjgZuLhwDXjXcDBeLo4uIZrdbd/MSnSGGbml1tNT13V5zszZda48E3cqQxqivrf1AMPuiuXlBZbu9ZxlVS4izXdJLxHXe1qiOa3lIDUus1uhXTWharppzNTfCGFx01uulg7i8ZYtVVQSzSe/aNN3rOHjZhqfHw\ -blM3GJ1V2eGvXIljcKV5LP2R0H36VeTg+NGDqKg9WJfOHh76EcNy6GEMOdi/6viXfv0NIIuBTA7G9o+IQretl3zseTY9j2147HXvpHG94rBtPWivB+/jwX0yuB8P7tPBvRncl4P1iuH6Ra994N/0WvonfOvTq8+M\ -/lN/+pr7+BN56Dqeuo7HhvfpNffZNffmyvvzK+5+ueKud/r3yvvyyvvFVbJz7e9T5Tb9JBydf8K8h5A312iBAeR6AMnw6Hfd62/Nv7np3/S6vePf9A6V7HkWPYK8HWiaAZx2cF8O7utkhZTov1CK/9ta4I9qiT+q\ -Rf6olvmjWui6+0/8adWlLZ0EZih5lO6TUGPsFpj5ND/J7zlJW2XjLp3pJnutvpObZLEaG/Ph/wFCW8dM\ +eNq9Pftj1DbS/4rthCQbkiLZXq/Mo2w2yQItXCEcKddL28gvelxpwzZXcj34/vbP85Jl7yaB67U/LFl5ZWk0M5q3xH8265/OF//evB1oNUlNmmTjeCfYrOy5bZ8VmycXypxcGH1y0dT328aYP2n7Ue0nbj9J+5lw\ +O+FPQe0iP7mo2t+0mp5c1I3X0FXbMNworGv80PZzfer2cY6Nc/ft5KJUruH3Ni0sleVG03gNfKEYvNB9e9n+Wg6etf9WDb8OC6kVNu64b6sGouUtdWjX1w5Va2y0S6pjfmxbTNUJNtr56xS/tf/W40unWPWtXVmd\ +DZ597c2ew/IrwVLj4d1mbrK2Ufj4K1fiuC7dXPojofv0b5GD43sPoqL2YFWa+U15fOi3k0E7HbTHg/ak1z7vtRb9vnowt879dug3ej33/Ibtj2EGY5bD9en+ms2gjd/jQTsZtNNBOxu0zaBd9tt6AI/u9Q/8Rq/n\ +1G+cDtb1R370Ne34E3noOp66jseG7eya9uSatrmyfX5F66crWk52X9our2wvrto7134+dd9mn4Sj809Y9xDy5hopMIBcDyDRAyzq3nhrfuOm3+gNe8dv7PuN536jR5BfBpJmAKcdtMtBu05W7BL9J+7iP1oK/F4p\ +8XulyO+VMr9XCl3X/sSP5r2hY28HTnDnZbjjxrzTUpYcCe406F0z9pvVOm+JMr2VbrZW63l9cc5WqzWisNhaAIOwaeZ9CYCmERq3zX0GVRpG0cftm9RvT51Se7jHL+SpGwr+zWlKQAMo80YFAcwdWyJxOSZ7WEEH\ +C7C1q88zQEXyrG2l8DoMncEXLU/aQQCBRn3xAsxaVLo/wDuzdiqk3FRRX13sA5DwlfvNXsC/tzP3IEIJEsmbYNAVNAm818qvPL4fkr2HINCXFqgaF3c77oPwTHqcbMJSaO0mW80m/OKIyMitv8Ew824PeY/T3iuJ\ +JoO+BSJybCQd4iPhPN3hX6NAb0To9cR7bnwmUM7d+erh3iPiJFvyrzZ1ja0WBLL0H7cLFyu1k72nwnPL++NaGcXPTNnnQeeN+J9ukumyTUlOW+o12vk3vRHTVeAyyL2V99zAovdLb6eY0WB3Nf4ACTe08howkhst\ +L3k/NPdhhEq2o3GPiWBDfdpp+tNOzT9lqSINJ5TUXQ/MQnnzF6nXqKBhsXHHe6HpSY3ShwyGqj0R4hsV2v8Re8rqrlOoAKH2BHOj+4yV+/TAhpXllELPKSHRNWzXeIlUnB7M8c/OY/xz8dDx1Bf8rUgf8bey/Iy/\ +VQbdn+lDcpiVOJw1Lmn6eEPm5ndDggmgz0H0sWORs9ooVWTXItyhrE5tK6XK2LYCrootCJ/YglyLLeOtZklb+i5YEbPMKhLGVMkKI/OxDSDFX0YT6G1IKBeAZs0QwAZU5f52SHrLsoLAfjCYDt/z5Po3ntCiWNre\ +ceKo/QIYikN6vwMGn2r/6RENXy2tSJOr3jQRYQyBoOGBSkmwHvTlI8If8HDJcDh+Hn/s87eyEVsRn9esBOiLli8FQyYOAZuJZbWCOjkygCZMrTnIDb2ms1/kHUZgxb8MBH3ePdVxtAc8FqFcR+d1HZ+MZ8/2Yxtt\ +ILe1ckGXCQQZ4oBVU88/oLeTWCwSg8pRqyhoQL/qrV039xb0iGzU5yhdRtGzfWIQYhZhJLZ2QOZpGx224BT08+oZ46BF0wSlyoS4WSc8VMlGWp5549c1rLV9OGZgxsQxSs8puNVJCw9FwMUPaB8iItsXcgpmbKb7\ +QFF4WoLBwFKsyRZBw71N9lYezgCRwJvU/xiet/OWGOQA1MnoBp2i5qgb2fLIQIwSbYUNiOT9mywf4+bqegLYuQ82/GhweU1/Lc61yTr+0+W6e3X+nteKGhGQ1B/2c/mZpDhExJbm5SkA9MJ5fA2RrJ3hS5kVVG03\ +8UvGUIGvz4iGlX4AnPkDzogmdOm9YvyeCnt+xSh0Jof8HPegvIVGEf+UTNyI7ReAeNx+sQj6zoy3WI0WXCKYfI29brKxKJIZ2M34PK7UoTyhHZDzd+O+u93A4MD207iJCtAp9JoBttHHzLeVgwlliarnvHfEkCzJ\ +9zbZ97wY3APIRknHZ7njhVP2QfQ/lsVfY2nAvIzoNdOz3oIdiOHpZvjiMVBjDZQSKcEGbYQd6lKWtwC6f4hrFaCBfkxQg9Vf65s0IAokhBMtcATyuxVzVSC9atX94uZqJp+TLeoNRTB/vTTOEcUgVsB8LB7J/BsA\ +mjFpmM37tkrDTAzsVFWeegN6xZ3EMtnF6tcOGC+ZZ5DLi0pvSD/ocYYcuAu6U1OABWar444n3YwxcHDh6I+RHvMtyG8z/hXF4t3O1V05ncmQ9DFOF9KCLp9u4nY8mptb91gtlQFFUExMs5djCMfA5ga5DtQnW+AR\ +DFUlN8GcWQNdnjL7Zt94erNJvHfqmecoCSAZBdHBF6WVv+QO5mhrN6boToPbuBRpgQoN5stBw8Ae0+YJvF6waml8uh91frcuDp62bu1fYYjJDTBKSY2Nj/AP62LYRMCJFC9D7fZ0P5jGAf086dgFdZ8CbRtswJiy\ +JggtA9w57vL9QbAdjSWHk/gKnDhuQLkOqsV1MZx7cKx2l4Nf8czhDx7f7sS5iTvIidTAct0IE6d7wBsZN/ud0kCrezzHFaggXb1hEB4nw6kvCA4waiDhU7E8jN8TXyCJUBNsfR6LjaiWTLmHn21BXq1A8z1YB+M7\ +DoHvkaq1s2+OyG7fV08PKCfTNzAzcsBAVgLOy5qs+GZyl7CJshOdFFr4nOQHSgdQWQhX429uCpmgnw+DZ4NkCUo3R+aHbHYB3seOrWGr1tMbsHPUd/Dv04jAWmKF+Mu3lJtE+VsxlilS1fXOJ+Zz9BrTPmkAeton\ +5CFU4w4cpb7ZRtvwyxcY2/jyQAzUp6QE270ypjl1hgm3R57hBbNnrxg3JulYph53ETNdehyTLTuPqyQUm9PIit+z34TNcvwdNA9/Rp37GB0w30BsyFzWJ5uwh8dizKHdAeRIxUwEKJGa6Ubc9Wlkd2b9PJku1yad\ +jYKjAfbFLqhinPWQLafE7YW5CMG5jBeStENCmnvw6q7nfTDX9L2PWB52Xgc8xuBGsEYsU4Mwwoyyuhcc0p5TGsQ6jl/S+MJCpedCUFaXTZ8iG3ZgLsRFvPz24RNzL2KAy/HrLjFXC78rEqpJ1LkIKE2DJHCM7+T2\ +4SNed+YJRjf1kXQ7suuXuzoRcU07qt1mhkPb5BwV4TsY9C15HzB6EUe4QxmnRnivhXeTRs7jcBt+sKiSef0tPjZzj6Ut7CrqEYPfYsY5IzAOs7dvYPCjcL0It8++ZKvKHrx+QXajSY/sDZxhhz0Mp/1Aj6UtyAUy\ +6fwx/QbbEDagBVJqdQT/jrfeAKh2CwHZOLKju89BlH2A/bRLMgBCBK09uumZPOB3QTTyBCAk63iLJrcuF6BnvugScUCBC1BK8NckI9D/I+aeFgI2fbFcAKByxi+lvBahOC06OQODOX0PWvx0H8Z8g+GF4lvAzyJc\ +7zhKkgsmhqctZW6EbFKAKwBRvQr3pBENf5ETTVFtsUy2Mc+9pl4D/t6T2Y6wpKewV3oAzCmMppIWkqN2wi2Y8Gtyl6riqMvZAXpN/DfaoEbdEicItvw30czqI4i+En+A8oFaCzP+dyerdDIL9VGYEtccs8wgpyMI\ +XgCsx+SNUBAvSIXXTTDmeKSvY8WW1bH9rNtLupnyZrL668xLVzQYb1ckSZDYsEeQQxPVBOBVzLsNpVZI7qolS8hyt97ZZwSyfkCfhx8UYKBAdQzSpRaGAEowNwjkp2tCD7RXEnqFYok8GMw693ygiq22ljtoPxUV\ +l88UZOOrYjfqJ7p0ORXhpwl3JVq+dcCw1imA0Lx1mwjUz/oIuCAI99q/JRfO1Mke0aRE5++Yq2VIfa2fbN7dmne51zyWRUMA8ap1Pw+pdqWp8uIDyDz0CdNhuu1qjFjEiBWM6P8WI7wSipFig0OdU8YB8lDEXpgJ\ +2MlV5KyJagcTKWcuM9kwDf9x7MCv1+xKwboZBX3q1+pj1yprNGwdggI0WNwUCk09+gIvgDghfVhBLNCZ3IgJs7dqcUx52fWO+CQCU1kikLb8hbVhurREIGdItVkAlKNr1c5ZwdatYskSNTb6IhLABBGaRUSTfdWZ\ +QBRrC0nBNNV7zuDFJIw0xBXwSxU06hRyLmlr7uWN2H5UFyeyAAHdwRVwnoXQGbD4aD6O0ncT6l/04oCftPvz/373C/3fEMDI3OpclK2jco8nEAiXCLy7z7hlve5QE/7TKWROp7Y0Bf1b/AxfD4VeL2i3ICNNjhkR\ +hkVh6YUVEy/cGV+FoND2Zra+hryeIDslC6C8n8a5dP9VoKEhJAazV5BuLdVTkJrqFQceNA78itiZWs0Tgggs2Kc3glZ7FnYsChRtK9mObmMV4djpz9dA7tcvTn/GkBDweT6nlCd6lYiGDTYW0A1JVy4E02NJ+LMn\ +e9EZmAxkL+apNpydH3QSJXoFEn+H4zAGJ5/Bs1ik4ZjWtgDbqVseZkx6y1uECa2N1gnW/IRDkrmEQ5SZ7UPQpICdWiQQJqO0izoTJoHwKhr41Ocd9SFWytMFAP0S6PVCwpcXc3/D/Na+lVt0L1Ci7BImdIFhWxCE\ +OnwNr+rXXfzT9HJXMyeKInajmskcw6bhK3qnlVjdLgVdo6v5chGT9RSovVKBss2b/XUgRkM0fWnCIrzxapW1cC/u05rlBcyJrlYdeGEbEh8T1I4hzFbt/dXN4PUTK5pqrzoBNP2K6QjEQZNcS5jYMULSU7QPMaC4\ +iwpoXUE+WkUlG59OxN/3RDxGAsMHyIes8ygz5RmoSv8w5D7ifeRzt8nm/bwu2+aOJuYamtQi2VEyLtymy1F6oE0vBcnFO/xp85N0N1pu6CKAUtTxCt5qR1fr2wehGqj2Fpc9TQ52HaEzJBhb9Rqhb3+fUpS6TCDk\ +COoc2WbCCkOJUkTOf+xFCSiOqQ98yYYyQOn9lVsfI1KwgBLXe8pVPuBHxHtkULdwb+EKhabsImCsJ7Yoau8MB0eigRkDIQliCqwWunwoBVQfDgIhkLKhwcBz2EZWjIgVjSVWbL3T3ch+9oTZqJVkTqqxHE4YM6p5\ +2XGwJuc0joSxCdk6Dj+b3sKoVEzlO5S8HcFvI5ajlZdnBe8UKg9hkBxraw6+oDAPZniaL/a2RxyS4HlG5Dzn4OJbDvnVYyknKqGAx/BebrLtmyEbX+WMJHilpg/YB4XpzEsIJhiW2kW5vY50uYngnWMsdGbziKJ9\ ++x9j6+wknTL25OJNnPAnIS9Yh2hDGHK4NPj5Vl1wyrrggH7uaUfTZcIZH5E1s9CcBRgdt7d4HzTTKDh7u3f8fRcmgNnMZHLn7IIxrd6hQnwHzbMzPQvVAt/H2MlbjjOxJaMNFwJBEYjVgK/0jCDPuXgF8lxaLyja\ +4FJPTizMwlvwdjR72aXF2tc3SZxgAjgLaFflAW0irH6ztJks788CSt5tTpBZHGMqcCyYYUAsl69imKj8QBEpCmrVwWiPDEqEsWTnJ3UxJCQNz67SbiuXLfj5e6IHPVMMWsqVO4Z+sGolMO8IGPWLi69hXCucsGFG\ +gmAyCzl1UZjWg6WpAQmlCZC+wTsA5T0KgDA/+039togE/u13YMiAtCmhW44Ozdcw3Az4DrgpR4v7YGZvLsLPSJSjycTR0oJTbS1cuxtbXpoz58yy8dQkRuhdhgo6dl7UDdhhI45rZ5FouRscKxXc19g93fsAze01\ +OKKRK/ZlyDeLMXwYaA4N4vRqBCIgizHVBkZIa9itd/l+HfftP5gM4UwOKIgCRGnK92Sse5r7FH4G76lF85ba3kB7ysGUi6wqfiFZgrjIbpZo770iuxdUzFJQ6yMsIS0lKNmv/fCqs4g8K6iOxIHUxb3r9a3QCtUf\ +4sKLj1e2S59QfI7j9KxwXcyObCEsrXLTV7Fki1ZAsRa4wEQsoYbwXz2626+I7qeI49ine9KjuyW65xrGNOl8UHHfauAfWVABvVPeproQ3yFF+kIJmcYS2zQ42VQo42102ifwE0JSDkzrCNG37JzdF4GrSemMk02I\ +8I/D2wDHAqORLe2/I6ikJGkxk+xd2tPxWw1FSSFeDZ7+hKx+5836QT3PB6IkBghV4uYMg3kZlPfW+jmhtgu7C5kiu8GWOw9cfyqrQmlVNv4IPl3t3S/Cjesc/HccxWpxs6H52FhOPnjZZfFYIzX0fo4mWtG49AWQ\ +Czw/dBd9n9D0qLndhKxLjCPs9i0xrhrKxqhSElfwsftoZ5W3U+eCoFM89IUfUf+hI/yathzZVkuVzCVHNLFkvDVXIP3bohH+xK8rccVjrn1AN2LCZVuTvsbtscrzOVUMSmCg9QZh/BDYHEVYs8LeHQ8X0BqFYmdT\ +MYTWBGF8+z6f0Oq/4DvGmkIaTbHF50GKaMTE0uT6NsUF2apVxokDKpfSBWgUJ8ik8sqiKVbvsaFSPE3l+RoqhSeSGROB52krk33GfM+db/BhOgy1FRhJBhnV00nFCp1E2QDWSUeeToKJ17tSseFJnhXqiVVS7lkk\ +f6R6+phgru5FOquPCir9j9QTOsXFUD0t1Rua4u6lKuomD/sxummPA+NXkh7tbaiiUkx9quQKRlpKncggLH14kciok4qOsLpY61GXNAsbnTjUhE3kJkGBwaePc47XY3AXiQsNqMZz4rgf8A+ctupy9g2b08Sk0852\ +6vvwUixEnnSP6uE/EFVejLShwCi717p4MaeDH31zEVgqpwB4Z0dI7nktuIxdmJAdtcR17aiFroVatiCJZEojjarMK6YpiRq6WL/MTFC5ug1puwkzhrHJNGFbBQt/0FyI2ThNOAxQefrmElq8A9S+51IorLiYAGR2\ +toSZAwR/Pbh8I/lWmMfOZ8vYIYae+djB4aeBnj4S7MQedjAlKq5ttiSFRq0UwpMHxSpL6g2nxdlubyqJnHu4FsRMPcQojv5igB2RGc+HB+Cg1Fnpm5Cql7LuBkAzaUOpkV7tCOILw2vbECbCeA2iBhhVv4646npD\ +iqOL1kR5XbB/wGVDWAEwBsNEU5h98WlxNV1KqdnfO0HqCVEvtlbxJQErMyOtmbZxfX7EUqSzwL5+SDPz3/GDmaeDYGbWN5K6tHW9pEjZMkCfDyRCz+kryenbS1aLVmBe1Vzh8ilfvc566tWIei2HXt9qzw8SHcWf\ +4vZ9ClMgkNnNS7XrgDH+V9pV/bna1XLdQscCp30WuML7M33vr69dDZY5F3+264fWcyG7R28nBqNMdkNz/TNlgje211i4bKEY+YlT/hMstJh/SpWF5mQJ1r9Nurjc9QZZdZksyT9KluQT9sZY9PjixHavFZQi7STK\ +NnkaP/UQyOWOiMPCbr3lg1aW/OCzf5H0aAHbkVCuRceMxQrpdnU7WtjRPRIGcrYKTaE9PlIEpoFFzOFBF8wSOyERklRo7M5z8JjL7A2mg6GYAwqWG/vhZIGudAnLzX68LtQrxX/WmUOErFGLkkW4c7qNDENJzsae\ +EXLWPDoAdSwe3yEJb0es/VTx8zHzU+UXg/JOpPcL5gnWr/Ic6xyVU+fxnQgfxHdAq2ZcLKhFaLl+ikaBnKkaC4ya9O3rF37VikRj31OA2jivZeGd2ZKgYi1RP9gIqDomJJjcCaGJuI5YxRJ4acWPk6Y7bHXx0ZVu\ +e1xdkTAQr/kfW33zHlbjKm9aPpsPyrUgn+bXLLRstP6ObjLCiD/XPaD3jlFzgIS+PMGzfjb18tXu7JZkLsEZb3341hkPqMpQu5ADMMPOZXU/n0CEPOmXkfyvk4dS+IFO03kfW67sgy8F+Oiw1g5WE8A+s3kxHwLP\ +MS2sLIy7ysIW/r1TznqgJt2SDJ0UvY7oAZXymLkkef2xw29QEq3lRVfdZ1y8T3pheG+D9qsefwkHGcqFfx7nEvYxzD5myD6gOCH6asXmBT6iLxAnuhBmkvoHSlJyYGssR+4kqUixOdYPwGeQMKgxlBGOmCwxn1SO\ +f4AvmF0E5nY56yIcc2E3EBJ7gfeAX8Zcvz0hLYCpmjHXYcs+xvOBNQaCLQ1SGaypPqSFyQlrLIFOn0gGjT/jD4z+8gIBwSz6jWF1mG+Gi1yloBZW3cZdiTg8AyRAfhL2GcJUeyIvod/kg669pVOvrk96xW/jK37L\ +rvht0v8NYKu5bYroNqziQQ6ona5BXA1YuWCU5+q054jFvgaDV7vBtnOSpyp+AHnZRv8FUIAnKWatqbCCqegAlYKyCcAVnZ7YlVMtv1L+ULuk9PQdHwBr+W8PIt6W+EcOXUDsYrLLZa1YSyQl8tny5QmYyQaJqgzP\ +bimmAVSt4o7JqvJYxDIzU83puJpr0DA9mMxXXNgigpbdBSWpR1TuWAduj8LtrbUCaqgrOksFX17wF+hY8bH2xo7WzMniLaGnfRFq6kv7/G8nizPeF+60dEn7p1F4gqWw60FwfixG9YxCO0bR+RYu/4y928LGQjgY\ +b7ztjp4vEPfbBBPWwOYsWwwcU4Nxilh23S0t5wlgJegaMjkwe1qwZ9V4Z0HLyehb72yUUscgQ2sYG5VnPH/GVRBy1KqLpMvDHIbAcv3W7NjtCgJU9phFH25NPhOAMtwuH1zX9fJzkz3gh0YAwqjAocDkHdZA7A/e\ +L/0LrsCtbaycsqHCjvdzPoBiLx+kd2onWXbjSpB/DQDYqJ0AnCfwikpGQsnV342dQxl6gZstkVMjZpx453u72fjQnEFHZIQR+w8/vKETJ1u7HYsrjrE0eR/m2q/6iGnPlLGERm6wK+dhvxkvD+ImyTpni8x62L/5\ +w2/N7iM+fkOnhXLvOJjliwbQ1M9loxg+JOaO7jFceIJCQQwQlU1+r5tdl/iT69iF+QGeXpZVQoOlAFDRHolIBpRcuYjEjsP9/h0WZRziLRUh3lIR4i0V4X0S31r7988MLyzpqlBV74K8U/++mNOQs1q9a4VI9nkX\ +QjA/xyfn8CznI5IoNRszuFihZHMDZS4W5ZYkIyrN2gdqPvsXLbm7iHp3IbRu9QJvOCr9O6zQFpRwFBfJ0sshx6IbvqenA55ZoDQhX1SpvR268jYfpx3kmgiHt9jHaLyEXpjbQ6p/IEyp9eN9BpTuctoTluzfPyFH\ +ebvHj3qXVOD9HMfnSwhzBVVULqKipSWZpYtgpt0dPU4zpv6aPa5Aypf6DME/11uPhQ9I5KOZYQ67NWmJ3xjoyrly+LsAZxmzjOXWjoo6T6QFnZVSQi5zBRxE93/BkTnhNjzniIis5MqQul5GZB//x79w12qyzGtB\ +sH48Qzt+R8vphSlVnPHhLJ11pRoiwSq4ZS9PzOMAqZM/Njvba6Md5MpzySliXQ2eugeLAg07qFys+gBHlcixvPc8LnoXV3krYd5XHuWQ7X0uX8Xdj+XuHfkR5TBszVIfMGviyUUDHm2+d3L+Fgj9rBPgGFdJWEZz\ +cFGzPIb14ewlFZhANBspWe6tOqF0yAmCBljESpgm3dpBFqm47IePtwpT5TF7XBrjds297qa3jg3cDQsgQkwZi2GQjk5O8NWHd1lhN5AJKaFkSZePIORp3gIa8QLhZ+xUNt3NX8FKQdH4pdDPRoRHb/ecy4mydIZB\ +FvV479ENJwCg73g0xpx5+kW0vRbs7I0ORUFFtVww8fcVCtFoUVzjYI206VVCjW58nA6Ac2eRufhby8UaVeEp9GZ4LhUJO19xRaC7HaSQQ7lyE1522ThckNtpgt4ar5PUS4KKRdO5lgzZbVCkPes86gwxcZzlohGR\ +YSArcpFcYFSgHMYv8dXbDD4vfWV71r+pDWp2sUQQaVHitS7T1HuGbmcu9195JFjat7BJcc+6ndrdfSW7Nuo8iFKSlGJiDa8s0Z0zblwwRRwXTKo0fK9TRYdCFrAD9W63DRu1chs25Uw6e/Ao8SIGcFRyCxF/p8jx\ +MR/grEI6w97gdSM8FNYkGxlzsuKiqFp3JytUInfFjAUTu5112RdUyKUlEUJuJWEr7JMERsen3eVL53y3QmH/C9b/0WerH/zGud+48Bvv+6xoBpcI5sO2f8mbKe+s0B/In0xD0h6Vb4U3zKnAnOdvmWN9Jm3J4Gwf\ +lO47nPmwCRo/ex1PVT697YF32Yo6qmQ3v6GKutW8aCVUIWf1sP6ugSsns1d+UesjOkyz8E7eL10Ll4gBgvyzvdfBPP98cOME3emn+XacppsU32GbFC2Jje7GDoIGYqFxYIX37rHxahu4yRIPpdfobPMFbdasuO+t\ +MnzfJ073kuYCv7iQ5Fs6e8O2XOVdnLEUzdgjAuDdNWLr2QO+UxP3khYg693uwiY8kdkcCkUQaF5IpXYZ8tyuoJbYRDVfptSu+6VkXxIBgFL5aK7BmoAzsfyxebojPEaZuu5mHUHnXBYiJ7bU7MmPIV/G0AzESrHq\ +sia6FsXKK9HJAvclGGmo+SA64E6lc/oD7+zJ/iJlbNphEqBJo/0uQVTzvRyEV3e960QOTGz8ZRT+h3eHuhf0AP6/FTJlzCV3TfjrkjQ8lMLgQ5GgO11o03J4tR8PkXuP4NhA0+DlB7a/oyAwZb6+66WfxcrNPK/N\ +yxJ+uniFiFHsLiBCo/4BZ0AAe6UXeFCZd623HE5RUKZVxzSYnBqcbER8WctSWkRuRiuAw8c4FR4ZiUa8sXoRGWcs4T1oY/QOEBrsjTdC9UW7DI/nfWNZSdF7rTPR3KvYe6gkimwNa7PgwpgmwzsFEjgCU4xHTw+8\ +i+zS7hCdIGaCxzAVM5AuInfyRGkw6IuDYw6n1JNMYmmRD4Ch4hd8Msm8EEq8yoyjz8Gj4y6Myb3aRWwB/LEPP8ROLlsCBWEo8tgCO2M4m2Ous2v8DjJLWT6/DpCl66mxzCDD4c+DRP7nBcoULr0T+9jtfpa7pr//\ +5dwuzr3/OyU1/H+n+L8kk1ilxnz4f3giyVw=\ """))) ESP32ROM.STUB_CODE = eval(zlib.decompress(base64.b64decode(b""" -eNqVWm1z2zYS/iu0EtmRL+kAFEUCvutEdh3ZTtKp3Tayk1PvSoJgk7uMR3Z0Y9lN/vthX0CAlJrefZBNguBid7H77Av4+97Krld7B0m1t1gL5X5isW6y54u1NNENXLQ3ZbZY28rd1DAtPMkP4XLHXZfu1yzWRiQw\ -AlRT96zRneEn7k+WJKvFWrulbOpuc/ebhNWEgLcm9JaS7n/eoeBYAdqOHaWI+xLGhCNpRRBHVIMGWHCjhZsKNDKgA5zKDkFN02TtRkUktUpY9EbFojrO4f26x5RjxnEAM5V4PD+lpziz/F9m9leHnxRJuxNJb0/w\ -pzxHFtRlvHgVkRSGtBEWZkmRqypSsO5xqNP3dBFGUNXz+01RHMXPbjQFaQYiSWhrtokjxJT4tZ5ZN8/tiy4DK7aOFGf6bOmeQF2utq9Jmu6PCUlvG8EWDQT8DydkSc+8kRt1BDw/IqstQesqCGJKsmQFs0D7oFjc\ -hbEbdFZY8r1SA7c86w99yQ1KDazCn7EQKxsMB5cZs47wTUkKb5opk5BA370qWXVejQbojnmM1VnCddPfSL24ph2o5f+pdQPWjAIotjE9/pZecYpgIQ0+OkIBDpQehN3SItoFoaZ8pXobp7L4fjr1V6c0jO/orCXl\ -HaOSfosSxgjQZlWwJG7TrN+0CGl0dN2Ci2bRVewXVTqKMIE3ye9sZ6YGiGFs0vwDRJLOEY0mxg2PtS+Z9IrfcFzqKsbA9KzvotEC6Epl4MYv5rWK1wXs7YwnZ0FyO4kMhc0b14+NwCCIVdGrSA/teEYwI8RnIgBP\ -pCNg5QxtJdrWngEGverFqiXTHb/uvrUipuuIUUQlNMtIOazILkicPwNPZlhyfyrQTXOVnY8NuTRsqRi7d2X27qfzxeKQQgm9bTkiol8eO4XlvAMYmx6zz0/IWUGrdryJehDMJOx5TThR1SS2ap28G9dae1TmYEC3\ -Jhv9/ASoHAxG8O9JBgSM0DEQq24EQQdaUgRuyuenj1ERMHdAKilDZKk9ctQEnCoC58Dat7AziAMpgY31WyHJOMs0WL8HPgxJkrRkZeR9abBB71a9AFriVRKPpx+8V+6wsiKsQ67FNoU+AszdkgBAKPDhQHhEATLK\ -e0tKbJCEpzAB5DOHPoSmcQqAI3KkkMMMLGCwPxZ/O+QYkY6u9GkcVJ4hJINCS7/Rkz6XT4mJNrSCEniu4A1L2TVhmqVdgOd1xSqptqjEzzFs7uMubXzX01RMp/gKnZrnZJtzNqM2SXLgU8M0PEML4ntZDRiqUADm\ -psn+KJXy11fxjQOoGvF/CgjyDfsAoFg7DBkxyOtu8p0d4gFipGRb8FE6lsnp7Dpe/yIktOje8vw7wx6fRbskw7StHt+Y/fBWxc64wc8GZrwcTMdgD/Mxpa3oFLzrVfQ2QHRZdvOwDh9RPMA6oQrv4EYUZLVkLjmx\ -F5SANmz+eMODuRgWxVR/Zi4f4818H98s45tVfLOOb0CpvzEe1qJ1JljvPbvVThky5DhblmVzRnJKBLoqaBL9OXu6uH4LhI4anhJlFUGki1CPoMw+MS7fQMSaXLo9Umz1ud+ImtbF+dvMr93AG3fRsgtMPlwgS7Pd\ -aCZu6fQT6V0yaPvaisxsufb2WnTt1civRijgz/FQN1FFMvkRI+DDDQpxG3n3xNv/ElK0JAQcjJ1oDMPgIp4diWle8ivE34S4qja0/DB4OC4Ido3lRBfpnK+2y60KkHRM+GfjwsCAb5fp7COTEbF+4cmToNt6I97M\ -OTGzlDyVPsvE/f1IZKrKUkRC+yw4RwXDyF8sVu8ofy3TVx4I33B9Ow4+XTa8RkGZhlHNC2Dhx11YAjQBFXd6SSqBHAS8W6OOfwUFJqRYxAMWRm9ggg1Aga/n28DBhrwHozwa+FNfblTm6z6OKbF5/sPp4Rnx2fYg\ -QNmQMohqShkUkoAbEZoYWE9kz3u1Xa8QxN0y3XpDimmncu2nrcgVIXF74xS2F1HIou6JTzw8Cx1JhIqIVKEe+vyel7aMUVc++5x+3MdYpVIOWdKhDV0ZQ1ev6R+kohMmA9iiSZw1xTpBtu1i21WLfa8pzgP2kX9j\ -+Vvb1oWvByXCGuc+HkZsfyPhLQQfSeEUX2/DwhHEVPFqUKRs4xN6lxZ5RS5hZOI8vi7Y9em5rznsjr9w8aPGsLf/qN/VqdqSdoe9xLKB4O/dWcAyj1JBgkNCmab5kQwcOI/7WM6KzwchAx1x6i+/bMdkX6N0VGTy\ -jf5YSltVleRKJptCvQwB1KSUHGIchQ4FdOUQKdjl4go+Xh6UVrF8teSek4kGEYwUqQdqglLGcBdHpg735L6HDN52fwxRMPuLT2lbsU4pK5D5qiPtFScLhmugoMfx0SHIfMS9QYmT9nBQ3l4sVqOLXSr4MQSY4o4o\ -SMs2hgz6t8e3fIFdqmOgsTxOGrw4HXaYzM4uZt3MRZrHRxcL7hzUaYhkEPHJSAkrwYINbvHX170hx3FhbgnocEIoLdNuAoTUxiE6wDj4WBmN4xzcwFkUZMVtR2nohLqgH3KSU3wQ4k7Pm998ckGZABpLfpc0PNlw\ -nkHjJ6DZBlEunf3GOsox4DUnOOiWQbhpLgNdg0g4e9xaFPaUYpZglbIglkCZzV0YN0SPKg7i3/cgcooVAZkbT3IWmjywXtVZb+ZhkNM37Te6x5XIz4ml/YbJIUu/+OmL1Z0OYAJ5oeXUqKvu44jd1qho3e5ytrW4\ -k3j497aqQB/3zR6srNK+IqdBi9E0QVNk8fdoUPrBD8ScyLpRrp047kt0GVX1MCHrT5hz9wD1cesNfkam7crWs94z4xnMgtlg6ilGFz7QYEaYJtzCy3xTL4UQQbeWQ2e44GyIISv2VlEdW58pzrk0rX1e3P5gm4o5\ -BFclt5VEmOaO2YDrfnqxS60C1CtS4r4xbuLREOWHv+MlYFkSenVVNiejbeyQPMOhxTFlKNhjK4mS7z63aTe0HpS82sg6D0C6Ww6lUByVnLg4VN8L1USbird9wjm1tBo7C/ZR8q/BtunFxmL7VJQr+Veua8Qd77A8\ -4PSelgczhQhuoh5DT5TTraLoTVHmrCfY+nzJMEim5beBsU+Z2DjZgQuGupL3DQ0K4DU3ES0h+VFLK/cdpyGJUOJFaskcOOVpm57byMS61/DAxY8hH0DYNPFSpCdkEfTKF15WvYGwPQz2BSGhFL51feutcx3Zswav\ -yJ6evqAoL31c7/gjLlf65VCA9SQsuFxRlghAbiHoasuJAB6M1dQttnJUH2FCcP+Y6AJiqPEX1Ej+76h1rugtvyfOU1fxHubYNL0Gy1+/BeLDI4orDSS2mvvncfzU4gFOInwG46EK0l3VbyuVVA8BVGDdoqgtj+N4\ -AiJO9qmzgnUaBKSJj/HcVYe5Uk7hIvGP8sjGKPqzaWftlIITA+zkiOOkFYZBD9BK4+kDlqI/cVaKiXCkLkzds02FrQhRtcr8uJpT0xVPhVKMTOufgdfXccZDc2IHkUUXoE1+yl6kYOfVfyC9fQMLvAArmbBZKr+3\ -tgucjvR1a6Czoxhtd4/9Cs99rTTstcXFJkEM5E1UrpWgj16MmbOD2yl4wCGlcHry/eL6M3W00TJsZBl4nKWp0ATvg/2ANKHmNjjWcD1WNBem0Lcxcj3iHr/GAoAb1yU3Lky6s7jdJUMQNupl2/QZtrE+wzXgp0So\ -K+N+d6mhfSKrYzIAw0G/KjKqFER7zNAcB8jSapu/i9mjziYEfDKUbkEtxPiq1Zv1kA8GQYtYwth7uPsSMM1/SgCVBdYtNlgSpMmial2YegsinXIage3KW7hY0jKyn0uYfP42nNthFWL9I1K0246Tb19OaUxmsQ1g\ -9HSs+vOKpj1peqD0VasPr+5w5WtmDWIWMGBgSmlOCrqV+YgSbzzZrajbhuV8/hAKBVk0FIFkcchxwa4ZOvBx65yjKFkoD4lsY5eEO2o8avkmZSz9dw8pNogs1fq4uXgCYsgwac7En1sMGXIh7QG7q3RbZfn41GA5\ -NT1Bhyfjmd1jgl2HxLxAd9uNoiEeFFm69s7ozGDvjks1nPYJxoEyQi3KHz0X+QEWC46YL9Y9ptUpcvWDv83w9tOMqzLbS14Rg8BNsRV2NQyOrHyry/aKfeX5h0k1JxNRbeh9e7qCzMBDOlV2YnqCCdwxH5Ogos65\ -5cjApdNNtMCYNeaD0pbdTXDDTmskY42JBvCBF1mcg6jhkJAOU+7KhDcrH7/GR3FpCj1Hjl9VldA07L4zg3jwpOy/QhMHE2f7J4Uu5NV17OV4aCSO+XAVUj/IhUGpkhuVYAfaH6LF5z8abRwL4J/96dtOe6S1x0cp\ -ufduBN09AlrwIgDqcvJ6y/krvQyim8yLPqEkQIFD9DdD5i97J23gx/qSDzWLl9xI1iSUUsX0FKzljFNM7Y0s3ao8/0XHEk83jyJmUm4veJDGFCOJLF5eAuWbt6D1K/zGSN+cY+p9X653Pazc8YkCdgcOiFEsBdk7\ -Sgxz9vtwPG3kzTnxXPrjWvkD95f5NArxiE+6scJSdOqHebUfM7426Wj0F8CzSu3CWjckfS1DFC3ZOA2e/u/6c18eoIBawuG74qMomCwqqhIx1E4S+p6Ab7HfuQxEsStaEojgwabXr6W6ueRmvPQfi/gTmGKL7ibv\ -2DaZe5Lm3n+lAElAU681QU2pnFp1I89DBlvnIz4lwGCbEwyWEz4pkhl7FNpdcfZmFn0hA4ai21rmI+kZuIYBzc1BaJEECursavYhoIPmjlGYoM/ezho/4XQ4z4jVcASUbUE0mXgY/WbzqZKyPzj7R7sC2HrO3YSw\ -yNM/g83dLRmmiBoa+SVro3N62H7P5xdqy4cn4ZstzHLwU6o0fN6gWKs+YRL4GdD4M/VOQxa5S9NFsTugrVC9SnfjVF2MHvl10WMHnnADbStac9Cezu+Fz7OINZz9jI+wtp3c1/5jPS9a3nl1EFjp6mrvaYIfjf7z\ -06q8hU9HpSiySeqUmLkn9np1e98OyonM3WBdrsroG1M+4djjJzGhcS4mkyz78l9OLzRi\ +eNqVWm1z2zYS/iuyEtmRL+kAFEUCvutEdh3ZTtKp3TaKk1PvSoJkk7uMx3Z0Y8VN/vth3wiQUtO7D7JJEFzsLnaffQF/31vV69XewaDcW66V8T+1XDfp0+Vau+gGLtqbIl2u69LfVDAtPMkO4XLHXxf+1yzXTg1g\ +BKgm/lljO8OP/J90MFgt19YvVSf+NvO/aVhNKXhrSm8Z7f9nHQqeFaDt2TGGuC9gTHmStQriqHLYAAt+NPdTgUYKdIBT3SFoaZqu/KiKpDYDFr0xsaiec3i/6jHlmfEcwEyjHi5O6SnOLP6Xmf3V4afVoN2JQW9P\ +8GeEoxrU5US8kkgqR9oIC7OkyFUZKdj2OLTJO7oII6jqxadNUTzFz340AWmGajCgrdkmjlIz4rcWZv08vy+2CKzUVaQ412fL9gTqcrV9TdJ0f0xpetsptmggID+ckA565o3cmCPg+QFZbQFaN0EQV5AlG5gF2gfF\ +4i5M/KC3woLvjRn65Vl/6Et+UFtgFf5MlFrVwXBwmQnrCN/UpPCmmTEJDfT9q5pVJ2p0QHfCY6zOAq6b/kba5RXtQKX/T607sGYUwLCN2cm39IpXBAvp8NERCnBg7DDsllXRLigz4yvT2ziTxvezmVyd0jC+Y9OW\ +lDhGqWWLBowRoM0yZ0n8ptWyaRHS2Oi6BRfLopvYL8pkHGECb5LsbGemBYhhbLL8A0TS3hGdJcYdj7UvueSS3/Bc2jLGwOSs76LRAuhKReBGFhOt4nUOezvnyWmQvJ5GhsLmjevHRuAQxMroVaSHdjwnmFHqMxGA\ +J9oTqPUcbSXa1p4BBr3a5aol0x2/6r61IqariFFEJTTLSDmsyC5InD8BT2ZY8n9K0E1zmZ5PHLk0bKma+Hd1+van8+XykEIJvV1zRES/PPYKy3gHMDY9ZJ+fkrOCVuvJJupBMNOw5xXhRFmR2KZ18m5ca+3RuIMh\ +3bp0/PMjoHIwHMO/RykQcMrGQGy6EQQd6JoicFM8PX2IioC5Q1JJESJLJchREXCaCJwDa9/CziAOJAQ2tWyFJuMskmD9AnwYkjRpqdaR9yXBBsWtegG0wKtBPJ68F6/cYWVFWIdcq20KfQCYuyUBgFAg4UAJogAZ\ +I96SEBsk4SlMAPncoYTQJE4BcESPDXKYggUM9yfqb4ccI5LxpT2Ng8oThGRQaCEbPe1z+ZiYaEMrKIHnKt6whF0TptW0C/C8Klkl5RaVyBzH5j7p0sZ3haZhOvlX6FQ8J92csxm1SZIDSQ2T8AwtiO91OWSoQgGY\ +myb9o1RKri/jGw9QFeL/DBDkG/YBQLF2GDJikNffZDs7xAPESM22IFE6lsnr7Cpe/yIktOje+vw7xx6fRrukw7StHt+4/fBWyc64wc8GZjwfziZgD4sJpa3oFLzrZfQ2QHRRdPOwDh9RPMA6oQzv4EbkZLVkLhmx\ +F5SANuz+eMODuTgWxZV/Zi4f4s18F99cxzer+GYd34BSf2M8rFTrTLDeO3arnSJkyHG2rIvmjOTUCHRl0CT6c/p4efUGCB01PCXKKoJIF6EeQZklMS5eQcSavvZ7ZNjqM9mIitbF+dvMr93AG3/RsgtM3l8gS/Pd\ +aCZu6ewj6V0zaEttRWZ2vRZ7zbv26vRXIxTw53momqgimf6IEfD+BoW4jbx7KvZ/DSnaIAQcjJ1oDKPgIsKOxjRv8CvE3wFxVW5o+X54f5wT7LqaE12kc77aLrfJQdIJ4V8dFwYOfLtI5h+YjIr1C08eBd1WG/Fm\ +wYlZTclTIVkm7u8HIlOWNUUktM+cc1QwjOzZcvWW8tcieSFA+Irr20nw6aLhNXLKNJxpngELP+7CEqAJqLiT16QSyEHAuy3q+FdQ4IAUi3jAwtgNTKgDUODr2TZwqEPeg1EeDfyxlBul+7qPY0rsnv5wenhGfLY9\ +CFA2pAyqnFEGhSTgRoUmBtYT6dNebdcrBHG3XLfe0GrWqVz7aStyRUjc3niF7UUU0qh7IomHsNCRRJmISBnqoc/veOmaMepSss/Zh32MVSbhkKU92tCVc3T1kv5BKjplMoAtlsRZU6xTZNs+tl222PeS4jxgH/k3\ +lr9V3brw1bBAWOPcR2Ck7m8kvIXgoymc4uttWDiCmKpeDPOEbXxK79IiL8glnB54j69ydn16LjVHvSMXPn5UGPb2H/S7OmVb0u6wl9RsIPh7exawTFAqSHBIKNM0P5KBA+dxH8tb8fkwZKBjTv31l+2YLDVKR0Uu\ +2+iPJbRVZUGu5NIZ1MsQQF1CySHGUehQQFcOkYJdLq7g4+VBaSXLV2nuObloEMHIkHqgJih0DHdxZOpwT+57yOBd708gCqZ/kZS2FeuUsgKdrTrSXnKy4LgGCnqcHB2CzEfcG9Q4aQ8H9e3FcjW+2KWCH0OAy++I\ +gq7ZxpBBeXtyyxfYpToGGtfHgwYvTkcdJtOzi3k3c9Hu4dHFkjsHVRIiGUR8MlLCSrBgh1v89XVvyHF8mLsGdDghlNZJNwFCapMQHWAcfKyIxnEObuA8CrLqtqM0dEKb0w85ySg+KHVnF81vklxQJoDGkt0NGp7s\ +OM+g8RPQbIMol8x/Yx1lGPCaExz0yyDcNK8DXYdIOH/YWhT2lGKWYJUiJ5ZAmc1dGHdEjyoO4l96EBnFioDMjZCchyYPrFd21psLDHL6ZmWje1yp7JxY2m+YHLL0i0xfru5sABPIC2tOjbrqPo7YbY2K1u0uV7cW\ +dxIP/95WFejj0uzByirpK3IWtBhNUzRF53+PBrUMvifmVNqNcu3ESV+i11FVDxPS/oQFdw9QH7di8HMybV+2nvWeOWEwDWaDqacaX0igwYwwGXALL5WmXgIhgm5rDp3hgrMhhqzYW1V5XEumuODStJK8uP3BNuUL\ +CK5GbyuJMM2dsAFX/fRil1oFqFekxH1j3MSjEcoPfyfXgGWD0Ksr0wUZbVOPyDM8WhxThoI9toIoSfe5Tbuh9WD05UbWeQDS3XIoheKo4MTFo/peqCbaVLztEy6opdXU82AfBf8abJtebCy2T0W50X/lukbd8Q7r\ +A07vaXkwU4jgLuox9EQ53SqK3RRlwXqCrc+uGQbJtGQbGPuMi42THThnqCt439CgAF4zF9FSmh+1tDLpOI1IhAIvkprMgVOetum5jUysewsPfPwY8QFEnQxEiuSELIJe+cLLmlcQtkfBviAkFEpa17dinevIni14\ +Rfr49BlFeS1xveOPuFwhy6EA62lY8HpFWSIAeQ1B19acCODBWEXd4lqPqyNMCD49JLqAGGbyBTWS/TtqnRt6S/bEe+oq3sMMm6ZXYPnrN0B8dERxpYHE1nL/PI6fVt3DSYRkMAJVkO6aflupoHoIoALrFkNteRzH\ +ExB1sk+dFazTICBNJcZzVx3maj2Di4E8yiIbo+jPpp22U3JODLCTo44HrTAMeoBWFk8fsBT9ibNSTIQjdWHqnm4qbEWIak0q42ZBTVc8FUowMq1/Bl5fxhkPzYkdROddgHbZKXuRgZ03/4H09hUs8AysZMpmaWRv\ +6y5wetJXrYHOj2K03T2WFZ5KrTTqtcXVJkEM5E1UrhWgj16MWbCD1zPwgENK4ez0++XVZ+poo2XUkWXgcZalQhO8D/YD0oSK2+BYw/VYsVyYQt/G6fWYe/wWCwBuXBfcuHDJzvJ2lwxB1VEvu06eYBvrM1wDfmqE\ +uiLudxcW2ie6PCYDcBz0yzylSkG1xwzNcYAsa7b5u5o/6GxCwCdH6RbUQoyv1rxaj/hgELSIJUz9Ce6+BEyTTwmgssC6pQ6WBGmyKlsXpt6CSmacRmC78hYurmkZ3c8lXLZ4E87tsAqp5REp2m/HybfPZzSm09gG\ +MHp6VuW8omlPmu4pfbXm/Ys7XPmKWYOYBQw4mFK4k5xudTamxBtPdkvqtmE5n92HQkHnDUUgnR9yXKjXDB34uHXOcZQsFIdEtqmvCXfMZNzyTcq4lu8eEmwQ1VTr4+biCYgjw6Q5Uzm3GDHkQtoDdlfatsqS+NRg\ +OTU7QYcn45l/wgS7Col5ju62G0VDPCiq6Vqc0ZvB3h2XajjtI4wDZYRalD96rrIDLBY8MSnWBdOqBLn6QW5TvP0456qs7iWviEHgptgKuxwFRzbS6qp7xb4R/mFSxclEVBuKb89WkBkIpFNlp2YnmMAd8zEJKuqc\ +W44MXDbZRAuMWRM+KG3Z3QQ37LRGMlaYaAAfeJHGOYgZjQjpMOUuXXizlPg1OYpLU+g5cvwqywFNw+47M4gHT6b+V2jiYOJc/0mhC3l1FXs5HhqpYz5chdQPcmFQquZGJdiBlUO0+PzHoo1jAfyznL7ttEdae3yU\ +kol3I+juEdCCFwFQF9OXW85f6WUQ3aUi+pSSAAMO0d8MnT3vnbSBH9vXfKiZP+dGsiWhjMlnp2AtZ5xiWjGyZKvy5IuOazzdPIqYSbi9ICCNKcYgsnj9GijfvAGtX+I3RvbmHFPvT8V6V2Dljk8UsDtwQIxiKcje\ +UWCYq78Px9NO35wTz4Uc1+ofWDEV8V7yqVQjFZahUz/Mq2XMSW3S0egvgGel2YW1bkj6SocoWrBxOjz935VzXx6ggFrA4bvhJjlko5i5lZEXFtxRL20bgdXqOlB27p5gBI82uWKWl7R8JiJnL/kWrU3fslUy3yTH\ +J/k+AcJ/U60tgUxhPE+20echd62yMZ8PYJjNCACLKZ8R6ZR9CS0uP3s1j76NAROxbRXzgTQMXMOA5bYgNEcCBXN2OX8fcMFyryhMsGdv5o1MOB0tUmI1HP6kW7BMDwRAv9l8arTuD87/0a4AVp5xHyEs8vjPAHN3\ +S26polZG9pq10Tk3bL/kk4XawuFR+FoL8xv8iCoJHzYY1qqkSgo/AJp8pq5pyB93abrKd4e0FaZX426cp6vxA1kXfXUohBtoWNGaw/Zcfi98mEWs4ewnfHi17cy+ks/0RLSs8+owsNLV1d7jAX4u+s+Pq+IWPhrV\ +Kk+niVdi6p/UV6vbT+2gnurMD1bFqoi+LuWzjT1+EhOaZGo6TdMv/wXshTKs\ """))) ESP32S2ROM.STUB_CODE = eval(zlib.decompress(base64.b64decode(b""" -eNqVW3l31EYS/yrjAV8YXro1GqnFJusxxzwTXhIgYAjx21hqSTY81ms7DtgE8tm361KXNILs/jFYavVRXeevqps/Ny+bq8vNu5Nq8/DKuPAz8Ds6vLJevdADv5R+5/CqbXZDn9ic7cGftfChDL/28MqbCbTAlEn4\ -1ha95q3wTzoJj0UafmGpJgktWfjN9WowcE4DnQ1/s94kgRSYPszgHFFfQpu5DNMZtZ1q2gIVoTUPXWGOFOYBYm1vwoK62Tq0djQ8nyx2n5vFLu0wUAtj6gEhgYCwqoMnc/Ngn75iz/J/6dlfEX63w6rwl/+onxNC\ -GuCMl51UNJPxtPG4Hm8KiakUL4sBYUVyQg+xBbl6cL26gzDjp9CawCamBuQIUljdBfwWRG8jxIZ+QQRFGUlpasUvPySrGGyoT9X4msTgYZuxPNqw/sIE8sMO6UTkvCakuHtA8A3SzhJY7uIufEka66AXsB64iiKY\ -hcagbSW/OzcNazPz0GxCoy2ATvhnZsxlE5UFl5kxg3CkJW637YKnsDB/GGqZb8JDD/POuI15WcJzO5RicXhK7K/t/8lyDxqMG3CsYMXsOxoSGMGb9PjpHm7griumUVSFUSLAQfBS74pVKCGm+n2xkKd9mh7HgAPh\ -2cQwKitSmog7mLNLgOWD3BqRm3IqhXru/EjBu3faLqpkW7kClpMIt9ezAG/CGlfwD5yPDYboC9qF57ZukE9e8YhAZVFpd5c8GpqoWgBNqYzUyGLCVXzOQbxL7pzGnTdzpSus4bi+1gOPvqtSQ3E+VOUluRljPtEE\ -8MWGCRq7RHVRYh3oYORrcXjZTdNvP+2PuiSia0UoeiXUTMUcZuTQSaByoHGA0qWwnl2wJCyqWlg0VS+FoT6kYcqtF37KUWjWd6s6AJUJ/URI4kF6QSojHzraPxuZU685X/2ut9waCdhV9+S8VTtai45Xa5F3JI2S\ -w2uldu5UPOlthAOQGwRTm0rY3F3sqKV5JnZfLpGZ2i2MkzYGaQnyzpPOl/NIdVj19MsCIBq2+suWNRC4JhY8FcVrpxwtAS3wupdgslvbondNpoItBMGSnGZnn7ANYB4yufP02+DpJ/B0SY4afXvZLm6Ff0vyOg7D\ -AW0S1BvtkglBHUlGYh2Q1HxdB+jXsTyh1XzHBzbl5PCC9S98qSsdk6TRL0nzehR0I7p5gn9tojS60TVvyY2FbyLvbrK6VTQHfrfVtAMTvFabjk8VF8adzqMt6d6lE6soU3kyRrxCw5aCew7qU7KTA/n2eDe7EzqW\ -bBJ+gGXFXlEbwq+qCY+gyuarsoN220bmGavAl/uKL5itzgXqCq4YmB/oOtWyA7WabUTQ4pku43eS8uvqhaiAt0AhA4MLahBS2dKyximTUbHsfh9tiES8P1d2uvcQxr1Kn8w8QS7YoJm9Aofy+ucnh4d7BOk7Pgee\ -10YM90FoyDhCYppwk2EZaEKyTkF4CEmBePBWyIoZiyph9iYjrljAgvN3p6xt6fbzLZjl7nQb/mylMIE3RaenZ5TytCViIIXyFwJ9Kta/kp9I8YBmpEG5OouYZwJkoHtRXjrS+QPKHZiYEDKsJGhasiGJOBqlohO3\ -DalzB5KSCBXkeZDeoCdzk5WgXfF6ZR01VpBpn6U3yQ2uRG7Q13bFnVmSMVLIBk/b2ocOsCm/JxlOohMzbLHbDmEGpKLl9NbMfLsnvn37VbHfiLu6gzEGWFiKnOfjGUhMjF/pl3fPWMLOX7B0nZc243+mdGltjYQB\ -uNyaL8kT1b5nyk8jEiDv8uS+Zy1Olav6AmDotLj1t+IocVMr9KzYwffTBbgPczCjaI5Akp1hpUaDR4BgpxO/Hh0KgGINoopjSobxIArypln0jPRDwfgxqbzTkjjRL2f65VK/XOkXBlLomtbKQTZdiSlCg7mHKrr3\ -ONonpQZV5AMglgvBfL9w+SJBl9kebtLWIFL6aiz43ya4szPk31Oxp3OSIS5fvgAcPH8ZBJHTJD77ToGgjPbgq/EwRFI8jz7couf4+JSNJEXql0i00ZnF4neKu5Y9jcQu9ldnV6KeOeRpCbsub7/qYgMHy3NCGh0E\ -mz9DF/7xfAnBRxsihgMk+wx2P+EdW/6CZK5LF6GmoxCKXRmTVa2A8I/Tjw9ychswLqbSTy7H9+1yCD1mGX0eA+ZT2P7yHe/fay7Dl63I2FUZHTBcbwiel5nCDNk7mqaqaL8FB0oI1GHQBcChh4enr0kxyuSxAKwX\ -XCebRTLBhsuWF8opWvq8fQh0PNuAdYAXgHiSl8QUaABrLirllLK+ByhWPAAEmyYGmCIfuALDgzES+lgvIW23tATB+RnBeRIpOoWyIWYMDYpQ4kRhmebvoDRzst79aX/vESDQLrNyNI1JFvvfors4o1gWGlSa5I4I\ -ZWB9A7/EgqtbLHYHlalBGYuDzKa0bsGaw1IhJv6+X1KxZtErzo1uKaai+GJTVf1tTZ+yuHHZGo6pVJHnkOIFrlbrHLvUOXbNefgrAd5g9E0qVKZn3GzMHxI7HeVIFFLNIwHsbt5B939I14532ExzvTuXKb08uXQb\ -n67eS1/zgZ+K9H1HAfHupJsz41QPEmkpp4FdTxH+3mNEIs5xxZOsiSrb6LVjaLsH+M88nuYQc/OGDIlWeEyq6+1EKTZYQ0XTfQQBrOG/e4RW2vbWjX69e421u3nEb5j1NWTxnBLvVGu0B2j3ErkbBvoJW9dcAbpm\ -tSpQ+G/JhmOyXo/4evBilRSnk8g6zuS4KOCbv6+zoO9oRmZPI9AXSOTLL9RY+DtCxubL3/1KDrfH/nJw6PFkGmHxNhtaD8hVKotEn4C/1xyF6rFlEC49I4cJOqPXC0hhZEknqWezGu8rN6KfpV3ZSkJaC3kEeGef\ -LqDICwgMMxTHWpFOyNAdZ7+gAbjMiOzBACQNQ6Ak2bRqr+wNpjvhHRutUqUfoZ7G7k1g4K3ZM3A2O0vK+saKKRVHAN5sJTMdHQE6zN4zolbqxj2n+zLJ8Yi6AM8VZizacby12n5Ovq5tubbKq51QZMN5pVZlGG9y\ -lzfUBactvrDcirg1GitGahNKB2bMxIRSlP4XlLaE3qz7eg1fqz2gs2LvgQWHLWyDzSRPDy+vn24wYAE85vMPNIetubaSi2Rg/OyCHxJhgT1rJy2I2JxMewzL3jzt5w3Wb1RPMWmdkzzF8EBW5F0ZdszZB0qdEleu\ -9MpyOHOE6W8JStAeHcXSO4BIm+iq1DrVz3WNDGotgPwFN+FzG6NC3UXfHvvCB2BSweIA/FZh9DzOD7B7siS/jYaWvZ+0qqeTeJ8tsXKzIXnCsZSnEYS2S56HjtHaAyYgo0qKMcubyt8PySk9kYNp0ntZgU/RMHHq\ -OsuBA0u8V6+iKZcU5GSxKi62jIdCCDcLkbOmx2RPiJidlsRCxPxL+oKGHefRA7fy3PY29UDRaeJYq5fqmBi+bPZI+KtL5Cku4gwXXClNegsthHWmlQ4GTeKlvFp8PeHp0uF0s950cKZv5VMaWfeLKuLLQi1IHW3O\ -3F4OvnlzzOU1UQME3f+mKk1bYI74IeaZoMtO9B3bGtUw50Mr8JyF+ZIlXki0DbbjEAYcAMfJ4bpsI27B5pAduTtgr6Bj8N2OVPDAaBuIHZDwuxmoVlfg3uD8LZUpaSMVeo8KTw0uMNk4Y72V47YqPYiRBG0Yg9BZ\ -S5/x1KzkdMVFPI2pLlSrnN1YyfXuArq+AEvnGmKZ8SGil5pBrxjanfwdcIGsWapjJv618365Wa13iyobjkM1MhjUzpsIH9qmo+ODI8SONMxW9sMF3P4S34OarG7pgPJHWMBgwNXK7DupsGcpEq23n0n7QGULkSEK\ -AtLE7ETrB38RT+TYo1R4oOGmlcDPRrlp857ADA5wiixj1XROyaKrdTWoMCnlQ2VvS8nxYGwipDxDUmIYRV1KFUDMmagCifocT4aJKHBwzsjKSEvCovsKFcsrLIAlkYKz90QVAImaj4wRFrflEdX85OwPogP0cAVo\ -T53tXG/Q/HiUPvuMp7RZr3hZvlZTcBkXo3RHWkZOuCiER2+RwAOI73Le1hqO/15xwJuja2AOC7NRgabLeUvqHn6XZCmCPAuDc+bfELcKiftzhQE4iwfKEL7g80R1yOK+jIkXOOhyge6YRxBhrJTiJ2pP3cGdPboi\ -gbvsAPm3x65BeOU6BjJjHYMwPt1wLhv6ckcctp1B/CSne0ti9fKHGOKc3hTa0rEe+r2ctF+ABwYtAC3ykAuLcamMZoCUA72ngulb81HM7f4ArZMF78uSC8nKpoNEIx3JRzPyd1ImKcW/q8jG3ChF3+5K93qPQhIo\ -gwukfiIvidxu9JFfQScojY1GA5mt5+QLs7xm9VANTQdD0tU2H0cVcvkC3alUKPGEeQP15kKdtWBNxJ/92YEEdKulPo6Re0mg5rAUbAUQnDXHMCklpVcFFgzafeVoZ8rvRFZp2DdwqmuoncQIjB/u2dWUT5YyLnG2\ -zbWyEo6wgvuQWyxCUbjaRWQGETnaPyMPB7gEiIV6Uw52PDtrGTz0vEn2C8Tyv2B6+VRQkoXqk//zRzZovMIw0I2ieMg0jPiUoqxO2sfQ6c3hKZNVmL/YN5WEf/AOF4QGjIwZndGScK4ZFEL065UBcc98H8KW5X+A\ -9ivmWUYlQWXRXF4mdr/lqk0R2W0zjrlF8MunwuIzOQxC3OTXsYYHCAAKRIiHpSJfzn8V9PYbYrEPAMZVZiIuy/B1IZvdP0Yf1C5FrzBkdTkKFgrMhmB5rM03yxujGNpnHzpgXI1i70U0+JoLWH2MbbPfVoEwDEBT\ -WXLNvRlWCRCKdZUBSZhACbxAUdy5fQBvFKQ6DPpyaPhr+9RS2Ee90gPXWcgbTMCXAYaBGgsFEKy4THYwRHAcRFidH1H9zmN56sVIMQJ6zviqln282gEsBM881M7rZEqhzyeMJqqEC+3B667/EXPUKhnUEId5MhQr\ -MU+uqgmTWrFWMdl0xefXOCdWdpq/T/thQw+GGzoP4/HWSMXGj6EV423ro/mVfFyDTqVkJIZldLlnYOO1WkwZ5rfi7aSGjtI3uT4kyWeKbn2TiimwQoO3YKYjVw9oMPDFZ5MoQotSmo+cS1CgjdcOXsK1g/wtXjvI\ -t/IjvD74BktA34yHwUJbBbFVIZKEET8Bmw+TSgiSLEzdZTXk7NWZPKYIa3Qa0OItbywjXJTk5hssFhqskmdb691Mm3xSiXWNkSDacBDteEhRc402hpvky1dYH+Q2OX9CBMln2J5vDtR8Ou6lzfMOipEQjeikcusg\ -zHOdPZJae7yyCF8lVarkenqJVWc+/4K+oMrgjTGsA2asCnWTHRR/PomzQrkVz90SvmolzK/jVS7HJTnELbYr5YnvKcLDxfrjgc4i+6A07LZSyoIAYyD8bG28EgJr1FQJOmAbz8hBYzg3jLB9/uZ5PxFFhfCPaGr0\ -CVCBENeCsBTAdT6NcSsOl8ZiG2cFj9BsTQ8YsWfrs3haiLGiVsfW9Wq9s81W2032YujjtxJFWNpYVaPr3Gb4O1udDJ/lGCL7cTV4jN9UK+SCRpe2bMV75KizeL07ibd4XFcH7a6rwIhPlOC5Do5uUHeTb0xpTzo/\ -H73CZ7ZvyLp4N2wqE7eYCuRKLDVWHuQSF5GGve/wobdaq1ujlv89IFvLekOnkZQ+rzZvT/A/rPz2+2V5Af9txZp8Vph5lqXhS3N6eXHdNebz1ITGurwsB/+/pa13N/lLb6IsSYxJP/8XjDX+9Q==\ +eNqVW3t33TQS/yo3TvNsu0i2ry13YfMALild6AvSwuacxZbtcvb05CRpIEkp+9lX87LG9i2wf9zGlqXRSDP6zUv9bee6u73eebRods5ujQs/A7+fzm6tVy/0wC+1v39223cHoU9sLo7gz0b4UIdff3brzQJagGQa\ +vvXVqHk3/JMvwmOVh1+YqktDSxF+Sz0bDFzSQGfD32JEJLAC5AMF54j7GtrMdSBn1HKapAcuQmsZugKNHOgAs3ZEsKJutg2tAw/fLQ4PvjOHB7TCwC2MaSeMBAbCrA6ezL3TE/qKPeu/0nM8I/wehFnhL/9RPyeM\ +dLAzXlbSECXjaeFxPl4UMtOovawmjFXpz/QQW3BXT+/mKwgUP4TWFBaRGJAjSGG+CvgdEr+dMBv6BRFUdWSla9V++Slb1WRBY67Wz0kbPG0zlkcb1l8gID/skC9EzhvCijsGhjdJO2vYchdX4WvSWAe9YOthV1EE\ +WWgM2lbzu3NJmJs3D49NaLQV8An/ZMZcd1FZcJqMNwhHWtrtvj9kEhboh6GW90320APdjNt4L2t47qdSrM7Oaftb+39uuQcNxgU4VrAq+4yGhI3gRXr8dIwLeOSqJIqqMkoEOAhe2gM5FUqIuX4/PJSnEyKPYwBA\ +mJocjMaKlBYMB7ChXcaLCXLrRG4KVCr1POBIxat3+lw06Z6CApaTCHfUswI0YY2r+AfgY8NB9BWtwnPbMMinr3lE4LJqNNylj6dHVE2AR6mO3Mhksqv4XIJ4V9w5jyvvlkpXWMNxfq0HHrGrUUORHqryimDGmA9E\ +AL7YQKCzK1QXJdaJDsZ9rc6uBzLj9vPxqGtiulWMIiqhZqrN4Y0cg8RPnwAUHIq2oA50RCiajQSmtE4OagJioX6EsAtSfJc9pBFTHEL9w/MHep2nOGVYSk5GJ2gzCEiaUQesQkuN7gpqUjvGHyIAirGpFlNOFwMd\ +6If7WrCpVezq70gjX0PDMa4prY/fV1Pb/QDxBbAv5TFmThOssbHqxCvY0v1ke3sjvkczPDlvlUA34rYhMWbUO9qtmj2FRtlmp0zjyHFgW+pGfsHhfTVbFx0UkEddqy1MmXq6y42eNEpLNkxxPrbH61ZNu7OrJ96K\ +MrDF1yQYPMeVzLoXJYuLt2iN+OTIEef54aBXCYOL4xG4rYOZIlvmMgJHB+DoPR07VB6wTHWdDOeC1tu7LmqsK+LhHilfS+1O2an5NgznNSUWvB5ZIhReMS/hS9uwGRWTKu1+RZs1chbUICaFyowEqgmBdis2jgVE\ +HD4STzYdHy95t00y+EI8V5+vJxVn9YIIxXzi2slJqHN5MgO0dHw6cM1Be2rGaJDwaPuy+6Ah4mFPXHE5+6gP4de0pFEfwxtot2ncOTnj4qj/dVwJzwVZkrZdgbIaA3qbbUdHyzMzDW+WSavIXdfNKVZOfXciiAr1\ +BxnsaUaDHWZBR/r52E+aYr/3l+qkHuEEr/NnmSeQgDWaLJgmm//48tnZ2RGfDMOA4lvx/L4ggdghyrnHXuWS4AU0wi/nTjUswua8MRlLKx3D0kgC4u44/yhhhcv3vtsFKo+SPfizmwMBb6pBVS8oaOtr9OJUnHIo\ +zlvDKljzU1FH09agWBTuWXTcFsBJtmBW6ymr36ACeNItsBONWH5LJ0lsmHa1Eb5tOLU+U55eGv0deZ7EaIhzYOgnnkcjaNpGvV0HW7W5R0A48w1AgfvpUQcyhq1QJZqMyzqBDrAofyRhWqqjS2yxew59JYin62Q/\ +M58e8QlJ915XJwMMPxSzbGsR9XJ9GBWj+9f65e0LFrLzVyxg56XN+JfkxWxskDAguLDmY/JEzT/X0z6PBpUw5tnnnhU5H1sK6bZWkXu/H0cJWM34mR2Fr5NDwBNzmlGMj94wy6RRowEcwNbr6HXEhzKxmEhp4hiM\ +RQyJgjB14gOB8xlW4ddJ5a2WxM/65UK/XOuXW/3CLhSi00Y9SQk0chShwRyjih6zJvKqnWviNqA48h9g3ccImXDIkMhzFcCCo847bevvwSVfvuJThKbSKS+g4P5mvUmhY3YZhUIsvX/+A0esxfY0Fjp8R9bTMlKI\ +BSKluLgV7SrH2uXLP4RJ8MeBDauyLssXCMPvL9l8Dgm0LYlUgoyacsETASK1RQz4W55RuGFAhIRbwYDYzDzj98n7L0o69b7jvUM6z67XL9uVsNCMTI6gFnmBdbp6yySyiMkS09aDG6tSBpGR09BYU4AErnXtle0v\ +WGubhkmF1VYla2PJ0TgAVPElHJUfYZdg6BNxmL4nzRCNol39QFoAXcHu+WUPo92LbVg07Am4L+kr2hwwo3Aoa1SssKcN7CnqcM0RMgPETOhgY/toLCof4aA2YzjAvgIHSxKJqAceDhHgzCK0B09Pjh6DJzhENY5N\ +Qnp48ulgSMmghDYVpbifyNpjpgS/xNStOzw8mOS4JgkxRvqdIcqAaadJR8fhixuZh8NRmm9OHvMzJlcvNld5ZIkHhbO4dlkajmlUuuiMQBtna40KpWsdV7ccbr8WHxjk1OXCZX7Bzcb8IgbM0RElu2Yei+/sloMX\ +/XfpOuwdRPDgHnAHovr2Uoh7eXL5Hj7d/ip9zY2Mz38deKFd/HmgXnAEBhGt4CEc1KQ+O1eg7FTyJurthgCxpTBt8OlxFKwvfZKUKTkF6I8NUPCEY0a7y19QoTvpcnQDotjAf624n/v3Bi8JaW/Qmeg7jJw78kjJ\ +S92Hs7zBkUZHa0TPhHuhTYAKw+AxdPOovPKfklGN8fMckgiJmkpBNP8qNt2+/+NMCfSp+jkLSHcZfW3iOayOU4q+/kj2hI0LgN+Upv4+Nz4ATv2sgpI9S6J7ujd4E8qhQixuBsOC3vOPbEzadZOgnF4Q1EGDnu3B\ +2fmaCYEWuNjTBeEcbo1i1na2kJS0FLx5cJd8Bi6QNZJ1kzQcBAZouzgSBQ3AadbIHjRf4qHWbvOUqrGxG8x0yss1Wp9qv4Z1GhucGwvI3u1/Ac7Q8v6Ks3HTGoTlmKMbFpsKMfLRinfs1+r0HPVMToTI2zXKAnuu\ +PLeqX+8vzdsvCez6ntO0qkxXMl1WPgfCtWZUHCuZbPWR6WbiBoGlC6X1k1G6HBhTmnDsUb7liME8xn7cegetyRFoTcLqj0mr3TuYEj+0kN55TgGX9eUNjAfl8l/h4yZGW1syOrviByptQaHlIln0WAPa3Rzr7B7r\ +vsr1IBtuqgqg0WnCPACk1nnEJBAj4S3pPn5Po49BbFGOijjb6EVA5FJhLQgk0CygEidpfhhsU51CCkpUdeNsVtdtSeNWnBecrbYVyzzaWfAvbzhDltJaPa1zp/weAgiTrrgMBoewuFr0qutQ+imOMc2SYH8sD6z2\ +MbVzzBRqNNeARIbzae1SIsZtZQg0M2DgGsfMgEvZX8UPbcGpI9zIdMUJc1MsuF1T8crWNNMpxPLCMxRyBocIVYp60moCG4akajURU7wfmLS8q/14V58zU80w5I2a1OpJz3ZGpEmj6FOkuXqucv+De3jFKc10NPc/\ +I3O59DCjPVjowXY0eFNqAbnuk0VGoIJipT0fse5V2r1MxFln6Y+r448n3UAHAV8wVQb645EYRNjlHTvS/obQCOKkTqqDAE5w5Jxy2ys7fx5yi258XE1zQ36/w1N5yulQjGVnJehEsjoQLblPyLp5yUjAcca6EnoD\ +CJr7a8Kspv4bY4pGDggyZQ140qq4mTaFYe4h2ekOE59baxDc8cfic830NgePCn1BIA0qYQLyTq/g3+wCztYi1hub/JQ9AAQZNJ0XCX3DmmHNYZ2LMQCG2JDmwgTyzMycPoK9veIgF3IeuAGG694lH4AiEqPC5+ku\ +cLGK0UjNv345zlVPpmpUogjUBo6BN6qc1Q0s3DiOMYo4y5A9V6u6XjtRNV9T2Lya/URf/DI2J0rvRTwMTpXVvR6SDTUKelGgKBXIGRCsDHq5HfMyTiFJg+XFTOqM4NBXjarpuJmCb+sET5QIFm073kykJQgzjPVc\ +j2gqNZzNa+NewtHY3KKy/xBal5LpRBI7UMxY/f5HPHlGYGGCOUMx/xlDvvgVXYAs8rPYJR4RMBC0Lp8yCAwlxDco4ft7GGnzOaox2s5W57I7X6tRmAKh0rlwUtzQOSL5/AfZ+AHcrk0CKDBboJYNFyf8pFxWwXxV\ +FvPL3awq955rd+yoAp5agDg8tLC2poQV9Kk4SkvlmuR8RMgjAbgdPhURY4JLdas/lQwZmFa/4Jy7W7cEG7dmWIorTsUBxYtZw16xZUHd/P3smqvoFSUhKr4uoE6SuyHEIRk/lSsE6Ibvvl59M9hbKigwHyLKaHxg\ +9NdyCeAdeNngNIGmePc56EyGOsNRxiy6/J1LHOcX+yQKP4ZjmXL7RCY7lABycxwVSYQ9Cp4LujKkEzu1QLtClRuG53T1SGWA8iPChCoLXH4gfAwbfSUMVNHCgOxaDr89l9qqds4QhAzQj4zP7h4Xryq5bFJzSI75\ +QyxKb+O6r1RZBjM3fnEfHRUMHMGy17pyI/ewUJdBL1ARDOdDfc4KgzF9f8I+hMYYtTereyM5aFTZwDjxNwY49/J2U24PbLyHxruYKxBsgwAFPTP7q7pfUsqqxgdbtM1xjrjh0wEHoWXkW0jla4QaDnACTlffSXuF\ +ESAUtMp/fEu0MKGZay2o6i8fDkW3frids//u9s2T5A6DZeClX/wXBuxTbruBzBLURSxXLwHzSQR3ePsRIHRISOKaeua6vsSUzy7nwItE458bUtUYjF5iPlBIy2HEBDsWtAfGTRkvgv2LE/HhdQuft/6NjtsLcFiu\ +YqgjoGP4lpMtD8DE22X/1ciL799E41vikrZLFUhwYoTDjBgl7nAKHAkhyN+ksbweZDzq8Bl71ZJNGFm2Fjvb8qm85/T+jh01hJjbDOChXn6Bi90n5Kkts+fst+sSOAfUWMnD+AqoG4J7dPaWDNZ8O3FUgaXo9IKO\ +iks5cEXLar9Zk95IKc+D98js8bwDhmGt3gvYhk0yR15senRbaO2/xHCiruLgGGUnOviX4HoBDws+hw2dQ/TQID3itlAHObuK8XP3x7kEWNGn0xVd0np7Lxkv3Dw0jAnfGsAApOA9LenOjkslNX80vkolKBwckh25\ +TMC4jMpiuCSC9g7NoegboG/Xbi3WXCqgkbAfPpX9yOh8O/twLiS6l2TEeOfVK2R9PwPoLV25wHzKHuWUdtbbKleKnK7WpUIm/kYiHF1xDlVdtDUEzqrW7jiFXfN9rI4qXFf1GV4gx0JwCkYwd9tCp6SCE+VC1pi7\ +Ds2dbB8ZN44gwbHr+FpVrdrkckbFl1YoJrxHUYcEh626a2DtGjOKud0GGAUJVjZKvJbThjcpoYNEMY3cmsebAO4o4g8Us5ohvV4ZSoeCN9JUo5v2irb378mFbrnM16phlu/wGDtc8Ei56leFB/C5l08mmoqbh9NB\ +GQa8KIR1EF+vAAbmbotdiY4zuiQF6R60vIPxKPe+n+fmnH9MpBt0Ul+JtimL4+FKgy++m36qiN4LNFebYD/AX+iWWawVYi2w5RpNyiowLWl383YDORiNbRRuWA6FqnRLXa2KQMkl2AkxfJaCBlRYx4Q/dvOskmL4\ +ED/sxmvtqKt42zxVTknBVtgMF09gxAdaO37tOP7EJEK5nfCaij+5kmf2NmVePImJEO7BTaM5xfh5RDLWUmINe/M9XT3XMEcr/5lBllaMhiaRlfFe7TxY4P+f+fe76/oK/heNNWVWmWVR5OFLd359dTc0lstlGhrb\ ++rqe/Hebvj3Y4S8jQkWaGpP//j8geRE3\ """))) ESP32S3BETA2ROM.STUB_CODE = eval(zlib.decompress(base64.b64decode(b""" -eNqVW2131DYW/iuTCUkIhF3LnrGlbFuSQqehpadJCCHQ9Gxl2S7sYdkQpmWgdH/76r5Jsj3pYT8ksWW93aur5z73SvljZ9muljv7k3rncqVmlyudXa6y4hf/K0te7Ozu5crV9/1rrFMeci11uepq/9P5d/fIV8wm\ -9MUY/1f7gpIaQllooalFqGw1VcaPFX20UJ4tfSF/bDP6m2UbvkY56AJr5ZdelBbq+o5U46tkceQstIcfL5lyyUusBV/iC0m6EcXkEXE4/62zveLbIO3EPxovs/EDtLkvAR3M0zEOowQgcztfp5BZlD0oo02FqKcd\ -Cr1qvc409DeDfmCyqtehoWp9jZzhp1/OUjn9nKFlM1buktZeZ7fOj+gr1rSfU3O8EnuToPbJaAFAQpkOasaJVMHS2LbCqCygScwRbckMpmfyl/QQS1DD5x/WmtMnX5qDKNMM1hRWZK1VZQc031Ym6+v55TA2WeIm\ -0ZobTssMBOrPajim4b+0KzXp29n7ovhkt83S94MDeTqCsbiNmYXeROt12KQTtDsvV2t57JKf56ziMpGrHGxdw6LoVON1vpuYWsHNWee9mgZsVkeZ4QdMXPkldoZF4LLQyOUX3MLP0tTppsofDRc/GQAXycbZyGCi\ -UnyuYK0WXHkWJZcNbBXhD5ZbEj7ODPdGnTTF/rwxKOgTDDjLPlEH8EVZALIFNEqtLbX6N6lezeUydNMvf9NvtaRJN8lE0d4dfEmUw4rsm98eq2x+sAxPhEtqji8lqQdru+9pt4Ioqa+IMOa7yyqCSHVjKz1sdXX2\ -IMIAVvXtG5j0nPqB7Qaa0OYQfilYtw1D3xAtFAzMWKIbcAZ7PLKFpuUr++qE17kbjt6r2LecWOlF8WJ6/JAMtC3Jw9YVz3oExn+ltLYYTwB9V8k/rue+RqqxfdWQxKanJF/FmhNQEqprg5QEtZuhspzjKWr+2p8a\ -iQzCR7Fdc5PYXiXsJ7PZQY9UtMOOp2DFSmQyU9jpBKUk7ITmrIt71KI/0DFjahwFfLxSgG/z6PG0g1Ey991N5rrOAUxGfVtRbOJM0z5wSPFTMBhPZitWp2GCSnJCVZd2XiGAXQOw0dem7ksTyh3gQtGHEZ004q4Q\ -1O08OqjQQbOVeLa+4eIM94Xl5HEAaCzvqp4G38hjdbP1XcVRnfh/cxON6Du78KN4QcRFdl38wQozIR2G94eHrZfhieYR2M10kz0/WHN+ufSqaMro5GvLPljzvoPpirWDYi28t6DwTWYp7OsUeyDLc9bZLtjvZLIk\ -uRtkwjAcs7lab7K7QWE87OqaIa0CnN8jgVC7tWftNXpbPwAsvXss8HLAX9jR96CmvgFq8gUJEXSM3aUt9TqUBI0tcEtl0ec3vBQOP3NZmzhQNSRj6MG0+uL/pE3oz3ASgg5G0MGv1oRWweEAD+Bl887t3c1oZ63Q\ -d7+xLbN2WoqL2XHBTseAbusLALoXT44vLw+JiZO8W0LJX3pUtCW1yGYvb/3K+yxvgYQNGeMKevNPDg0gewam4X/V5b95PTOOqYL+X40c5PGSjQu9yvErENSPWhessoYQoWYwQVBhP4xID7vDlcB663xy5StUk1Mv\ -PvMcg95h/2krLOL44jDxOkm8A8buDOg6t3HVlNoS+2buAZwOthVsBHgWMqiRR8JuUf+CWfxCKvAKwZAQZlkwLs7j/AY+9GRsm3oQk92kEPRyszUQHsJTtz9lvJrtnt2Gpduf7sKf2zPoyGU5d93Hrysyrs7eZ++V\ -REHI071NNWR9q/BU2uhAatyrSZSjcENP4HMxYeczoiU/kIOjnQcWXgv7U2wweVw4QSliTIRKdZcQ/jzuWnkehIIWnyYjAlrzkJaVcxPTstktAMUx+uMyd0PfAd1oMdIEW01+BBVALncocWCeBrFYonZ1ICV2eqfI\ -vhCzzncvzFErXPQeAhLalyz+fL2DiqmEi/QFGv0Okh8QDgLH8+sLaqLig/f4p9zYoCUB4FHZTavK9hwA+iQNzN7gBn3g9snpo6XP2NKRAOUT8SBg8wkkOd6QPY+rYnph7Ybo3J3hIGMR2hG/+256gBv5fJOIAnoC\ -Rog6aQ072orTMWvmkcRX6Lrq2AYhoqAFJEI0EhCX090U5/MPbpHX6Xq+TF+u0pdV+rJMX46OeM2B1aIvmx2cHTGR3LCysTlCUrY7RXOvRRenbN4ZlGOwOKclC+mPLMbjsL6wjTRmlwQeRsD2Vhb/W45WAGvLrxNa\ -y5GKW6N6XBLkeG/j2iAC64+01WJW8B66pXcM3WofKl8tezZaRfNB67SXS7LWlj4gAgxJZ8K86+YvrNS4F9Fh6Rz975/0lvIRhH8bJQEBtCUrswhkfuNdJ/6e9HIF2pvwdMDXOclqzjEPQLuLhWTchlxryQtTZ8Op\ -f5x+fApKmBPU4BIgXF5v08wU4zilDK9+Y2ZTVQRUgA+tGwAjEtDFaxI58BD20WgpkqvRSYU4qXNWTktM0nQxbMjK1zSnmoMSzVgN/B+iZQX7sPw2QoLLU4MRQT6S9w+5G1W/XwgAfSIrMxURJ5eB1WaaNFKJAb8n\ -rZmWVg3ZcQc0ApQNgyOa8CTMaEdscY6J3ZxuIyTZLIUkX7HGj210kuin5+ynrZPtjG03iTz2LFZ9TrzJhMXe//Ho8BHsZkrQP4Q+KggKIF2dOc5j6wzKVEzpn0lZzBv8og+Yf/TCpEFMNSqbsWn13N3BuGLs9GCt\ -HPGEAF/8XHeSHmdJYr7L+lMU2aO6sIc6TZB2+gfEVE3Q+nqfURfTywpfrihXgcXgO7h4Ffg/zZBfjujrS0qp4FcgDB3lAC4vyUFjOeRduHzvjN19634ijPfzU3y4IKk4vyRvphhQfh23aJo+7h2CkCtLCKoLkQfs\ -lvz7aQXGrttoWZS4AoRVAKNWGNdcMOcQNNZu4G9FGNV1d24F/oYdbzDdazjv3kreoCMrr+1G9BCKaThMwY1OfriHjPM4iLejIFQR6JEA3/QOW2AH4RbpjqeRZe4G976MGW2XuENnJzHRILnsRq0ZmPb0KUdSajQ4\ -9jFZM7hW/1zvIsc4ugFoNDpHyokaAkEHHboCyInKJPMlqTDg+hDh64LVWPMwa9KGCEO85o3a5SGTwjp5bkP4SIbJGNWumb1t2BIh4d61dx4CSSnuxkRIcmqGqZR3PWlXSTxb9PQ4gzM2hRZSMQq521gGWJyfXC53\ -T7Y5CgdX6iR3DhFDy/wAZyldFMQwMiE3GJlh9qWYdA/gWQP8JBMuzMmij4DKbcLQZPji9dB8a9ldBLn4HXXzOcOzC2IrjAcPFYVLgIQxN9aSl07TdG27JYVbMu4i5luG2b+oUUrkoh/VvB9L4ixYtzIX3UvhgrGv\ -rlxN0QohOSQJt648ulx2aL6LPyU0uS0Dd0exG1tjyQV30FipfStNM5FA6dQA5Oo2TA0UDRkT+dRQt+FE2Hco5y8ledOoh056XTAb4yHrNdqwgq3QixE7GFWME7vbcZSLE3sXkmlLnrZAXmd+5lg06UiXz5NJZzET\ -p0Yj/hFscjBjo5LQsE5ycJLVHY35NNFqlhBFPD6AXaVfJIVKCl/yGLM1YxTDMf6TpBoycl39Cq+hB1ZJy7XIjtEe944G31wWt7yI3uBUdk8E4CsJc2FDaiMnmxhK0GtLx0DJQ5Jr0/1dndXFFu31rjvnM8xm8Y8B\ -t4HFmp8/EYL7dF0w8gRge/HVkBVtM5oLJjKQuZzyCDu6wvOcSTyprGfnfBoDGGCRD5x/JGruBuuvEfjbY/DVh88YWyjYejPK7N6mPkaphoIxFTlIxqlBlSUHDVp9vYbNljFkwJCk6WOTExdQyjH3sRzFnj+nxIBL\ -jrzAxJURaaDa/BltX9WKQC7JmNo03a5I7KF4wxsrBuI3OicteERJgdmnXD0XkfP1IptE5MbF0FIhFaggIp7vzxdxnfwwb/qLZPi4Yd0iAab0xQjrEFaGZzo8BVK31s+4tdF4XJsuUkW81+HHt8yjw14U02WQ122y\ -m3HVuE/t2NAhI91h4qLh+dICdZysrnEf7gS2BU+QNreBzZ3SkHiaOecMRZLZbcOa82hhbnnkZFlOTnoHT4dOJ4lIeRVxXJf/ZT6pn+EtnR0ivibyd7Q8y+P6zf1xDSxoFG5Pf8veHq1wCGu5ZOQQ036TE46qN7hB\ -CMkJxVpO0RqJONHUGnKFrdp1uF/vPt/klFCeKE5zyC4KweR8I54pj8YR5ofHGY8486QvcJSdnHmn3KFxiS9wTGgwZi/kvoGcQ0LyVw+yOXguXeGy8+EvHA0AIaC0clbtUiRihM7M5YFvbtBhAz5M5FMp5ijcC0G0\ -CN8rpmXopjwtC6KIHIrlKEgOXZ5JrNAlSkPzKtYp7Yjv26Hy5Ys+p/BIIUN8wO30E5jwD9H/a51sJjC1vuv7Ttr9ChHCe4gsn0G/kM7Dw0i0GlzgYgx91OfPoOxowdDtgzXRP9bdfiAE5364ubYTT1FCuDMcqGSv\ -lnFWXmezkVs/Zw7XZmeH5G5N9SX08YkcQZp5SzKAeM5naJmAnzWM9RhBDuaB93M4LsV6epcu34FTacIBBpYAWPl210n02uIrEnU8rE6PTDCxNOmHutdgwAWZq0Pm+qygwZGvIRHpHkSEMpg1HClmcau3BBHVXLnB\ -lgiODoQ1sPyaoAKwpFB8WsPEJyviNZAs4ceYzmuoHkEWz7MOO5wqZDmr0fAxHJi9KZLdN+RyrjznycxPWMQ2+UqK9x+xWfXlY1ammvUpH86KrmxgA1em50EMZFbI5avvaWkMHiXjxDnEAukd17UOXDGUIE8xlAfG\ -M6Wapon5ipowjBLZqxT5Oz6rqjhnjZJpDvt4w8YdL1kK9OOKmoqFWtx7u2GF3ogWw01QPE+Fo6P5GaY/6KbemSQeLySIx2TgOXneuhjEfV2Il7+qMMTswobGuKJzib/EeGK7iLGWm0WSoDoBqdt8oSSA0u9IGyRf\ -wdbUr/JlpJaYYGjXXFTJZao/JoUzKXy3oFQJWjZCHZ6Kt6fEGOQAGtfztyESqF95u8hDGv6L/8yWQFOi04CHDEMLTWE9hRTHtB8dwt/rMeZYvpGB1/xojmNwtKavhIaoyRz73eGztUiLmIh84kjJzmLrOmQeemkH\ -Ssyja6zrCVVzNe1rjHUqWiY7fx5PWgwuzeemMn4ainaCOcMUQICneUXyXQqwf2FTcJkQb1AW7J+d3KxQ8RqBU1uPmYozkNt8i5l+yfd54FlvMY8AktRsTcdXdKkdsuRCtMEa0OrxeI0UedprOfn/8BTO+eb77z/A\ -n9UclOIyg4nFxRpyrvO4QjpRqBksEroTJafxcAUjTCvndKpgIVzyUgEA1d9hgLcEO3ieKrZs3sKk38P8PtjVtuDP+3gmn+ExHBNKy67Uzh+yqlDVb8HiAiKqCHMeyPhL3QSLpdDZEVnDZ3C44YqFWhOFYZxT620Y\ -8K1sQVJ3XRNk12ZbmCAXyBwgMLOaT32hOmA2ZKbRm7sJM+uCC0Br86vYMUSh0BpsFe/HZZFvQS7EtnyY6ijXHy6LsM6chxowjfkjTnMGegHfr53cL8OrdivuyApd7jhXbfiKc1Pu8mEbBgolXZSxTg76IRCSINdV\ -5ukiwU73BV+vBHssT0nPuNcqOuwKt75CD9pcLH4U6zzhm13hq/H9P06xyUPPOQGaybeSgzI8vG7Ya6wJs7G8Hm2Nb/q45/uv2BsjELR/S1KeAUT5UKjpj4DPhQT1Xw07vun6oWkifyeywal+uv1NzMG5PF6jwSRz\ -FTlZhqemxSdm0OFmxjZXn29P+Vwrich79zEzuIdG48Hgbioddux5abip3O9kfheu9mD1e8ltrNkNlz8b+RcHka3sdTGNc+ora2dvgv8+9M93S3sN/0SksqoqKpNVuf/Svllef5BCv71V6Qsbu7T830bJYd0Of0k7\ -8rTPzE3+5/8AACNy+Q==\ +eNqVW3t33Lax/yqrlWU9bLcEd5cEnDaWkliWk+ZWThzFcXVODYKknRxfHVne3JVcu5+9nBcwfMg3/UMSCeIxM5jHbwbQv3bXzfV69+Gs2j2/Nsvza5udX2eLV92vTL34cO/8OlSPutfUpzjiXub8uq26n7Z7D0+7\ +jtmMvjjX/bVdQ0EDoS2OsDQidvaWOuPHkj56aM/WXSN/bDL6m2VbXY9iMAX2ys87Vhro201k6q5LllbO4nj46TgzQb2kXvAlvRCnW4lNXhGX6761vte8B9zOukfX8ey6BZq8awEZrPQaR4kD4LlZTQlkmXiPwmg0\ +E9W8Raavm05mFuZbwjxArOlN6KhbXyLP8dOr55rPjmYYWY+Fu6a9t9mdsxP6ij39H+k53on7syj22WgDgEMhByUThKuoaaxbcVVm0Cl1RF1yA/Jc/oYeUgtK+OxmUp0+dq05sDLPYE9hRya1KjskehshtuvXbYfz\ +aotrJbUwJMsNGOpTNVzT8V+ySkvyDv6RCF5Z21K/Hx7K0wmsxWPcMs4mUq+ikc5Y73y3DwZUufviOtYaTyqNUi4Ua8XAeh1zY7XQq3xfaduCh7PYez0dqK1NbMMPaLnpdjk45oLb4qCQv+ARHZWu0naVPx3uv1oA\ +98knamQxkSo+l7Bdx9x5mTgXG/aGXBC2e2I+UYbmUamhOF+nDwbmBB3Oso80AXwxHnzZMQzSCqcV/0LL1Z2v4zT99ov+qDURXStCUeUDfFHCYUH2NfA+i2x1uI5P5JrMCl8KEg/2Dt+RwQIrOlwkT9ZNl5XkJc2t\ +o+xw1OXzr5MnwK7d+BqIXtE8YHEgCeuO4Bcortty9A0dhoGF2Z3YGuLBfV7Zw9DiV//rM97ndrh6r2Nfc1Knl4uX89NvSEGbgoJsVTLVI3/8OaE1izEBGL4K/gm9CDYSje+Lhjh2PSF1Xbx7BkJCcW2RkKB3PRRW\ +CEyi5a990ohlYD6xHerb2O5EwqEyWx72cEUznHgOWmyEJzcHS6doRczOiGa7eEAjBvLVc5d/cO7wx+ZWP2h7p+TWQvOIbMy1yN7JCf4h6+e25yc9ztGNsCb58FsMYkeJaBvAgzJIWNzGECvnEhVk3W/BEauJEXrG\ +5fD7seq4SsE1RTegKZuR87cL/sFpZxwQc+Vom/H6gGEy0weLY7NKwm8zwaZVfIJ+rlEy3UoBF+cTaESAMWLPSsGZaT+VbMr2ANUpx+vBJuYJCHivVI/bbb7HjYEUL0GdJgVFGG28rP7tbc5QSJkNSGlYTjjTt7S5\ +TgUoK4HY5ywRA25AwkNTRsDVWYeFaObmHEEtjwhGbIY329HGoxIAAgBvAbEFlvDtIUhjHq2JLN/ZncTVGC0zTPT57HbVAekJxjLFgVJTOwWiojPIidIg1pFzSAZNbZjo7ltd8Qax0sf2cNzPb6LqqoFxQkuphTGz\ +Pm1xtnrn8wQ/lGwiTyvBYHk31XxHtIgXbZe38e4V78jbarywt2JXfklPz6PnOoxPBDRhLtA8zyAGtKMn08UDQ0PQ/gbbLL4HdQk8XE3aeJt3i3kT75L4jXG6OPBrE6G0YSura6TrQm8lcLi4y7a/4EiGOn8v9593\ +Z84mFsjiEDyeX4nXadm4scMwo/X51/3sYBhy7FT4MbyspAdtm36ww1ISLsfAoMNrb+IT6UZ0hfNtznoKhP9rEnnVJOdUeXaJljEHWIhEeth18AdgSTbf5iSNN8kw+vZMts32wSPMZpxuBHZcuCKbXWW32TMhS6B4\ +FSO6EnrdZ38Cel/dg7DAoRIV62/iRw/5C6c6PaRV3YK08mPiI0oap9Mj7XTAMN1IpVEIu8UGAmVV2Nao/MEM01EE8FaGNv9F7oiIHukQDOMEw3R7NqO9CLjG1/CyfbC3v52UrZEahhh2pyA1kvdiebpg2O1AvNUL\ +gHovfzw9Pz/iUI4s7wiWeNPhQl/QiGz55s5rdoJ516NaDNPma5itewpo+9nPoCDdr6r4X97SjB2v2oIsjLKE0zVrGbqH01+B19e0HkqtJquu2E+hv+JkBE0fLCUUkP1X+eyy61DOfugkwK7SIUR++NMOxcG2PX1x\ +pKC3cnGg9cGBuMVrOIbXqN+sEOi8ILetGQnBsyTFGE1hd435DQh5RYLoxILuDggF/wRKKhY6zqOWpD4j1KU88W0yQfVbTqDGWKkLD+ccUpb7z/dgAx/O9+HP3hImClnOU/dd2SWpWOsfMdJWBSEsWXSaVZMOXscn\ +0kZw/kiSqvYYNOsZULVgxNCOQOT3aJNsf6DklaTAhhUmTxsn7orSRlJbb1XVI0+2K8+DkhjCIeBtkIVXArrqFKKm0k2f3SG8NIwCuM3tVJJjRUmVk3U5pBvIVziSeliui3nYYvZtzMz8/GCR/UXUOt9/4U4aQSkP\ +0C2hfsnOr6Zzo1RSfaFfYND/AeeH5A0h0UVAEbj5cIN/iq0t2hLwPSa7bVdZmaObfqarUxdooF+HhwxeORkioBHxZUnRJiuVVwqDvCRiefMZa2jDwXCRMQtj2PDt/BCt+GybgJxXOLxSo8GivYQeN0GHKjJhAKtk\ +zA6JGnaPENeIO9zLMLWRb/XmvdEvl/rlWr+s+xsOuQ4GLUhStnzKtIxvf1HljFUlzJ6Cxc1+wC7g3FCv30kcesJFFYTGj1SiywWVOpsGj2So75K5oY+0H8gY0vnFAwwc7zlHMJCIt5frnhaVCq6W6ErWok/g3X2p\ +MhuN3AUcG/CYn1ElF16q5DPHOPmJ3pyuJRoaL8wAD5C0+ZjUddZxJes3FC86ZkCAMybHNBLKiPYg7oz5ZOcKB0MFO9dqhM4/zD/8VNJGBS4SU8S8ukuUGXa2BNYvf2cEUpbkTcCImzDwXggXj98yWsqSr3eSeUoy\ +i/Ic+dCzbpSn6Aegzxcp98qKt0RTVTXJ8wNah+qDASkVT5LRBqsVRrj4QME5lphNtTkWF/GRbNSVhG5CBlqbWRJHKQq8IZFB9cKzCrYtRHmQNCyO9s5EuBFQbSiISSByq+Q0fKadRkNhBzsqcE04YYdR2cS5Q/CP\ +/n5y9BRQBOWC3wApJeSBGLXDK9o+T9b9HNJC+BrRsIUOUJDBrijODDqYdOD4XNpSSfOVPWRI0EtkBlnPqG2J8+6qojWVVwdnTZZLMLYXrA7HE6bFJz7iSYrUAfDFLNWBYpv1iRcBJtngmEof7LT2exSjpQLhXkyw\ +oTAYU++3D7kN81iDL5eUTULB0fBXsJeK2u5zOkRPToYvz8/5EY85KlWp5GmvYyZArPLLG1I1bAbA0FIBCqaDAB2X5/b7zzncN+EfFAR4AdCLkE74LuYwOHyVrF9nyb3D4FAwAgylitc4Cmwx/25eghezDfEbgTEW\ +vQxiyDJ5PAJ2R+xK6y15MJKSHtyJKA6n36IEqMU6OSQztonYyFA1odh6zGkbGGbNVQuuQMZshkOBa4cYXTnZSj0byeC5Sp1KBy6ByTAFJs1DWOIHlXybL8eJAa7FmivE4pT+ltIxfi/GE/UGj6IFOONqdIq+OJ0n\ +tLyfkIqxKrG0LqWNeCSZm+S+pL4FSVal2lWFJaiMh+mr3BR9RtTmcZ9I+DQHhqepXSdBupBORoOfJfLkGNW3EwtTLvwD569mtDiV3CcWhxmNn0j2DIWRkRG5fLQFOQFFCCqgamEBwNBkcjYihyWQZHku92eMNHGZ\ +iUobWKnlza5Vxh5Ue6Wem5i6xyq0oQg5YsDiVM/+DTwffAPgcXXvmKsNw+Ks+UevipLLNARWi/fk4Lzchahjz/mJApD8qW9ZnxIWc2YaeY7b330QlGB7N0ygfma4kmMxcc56lzo4K7fV9EJ2tNG6jG4nsgZ9jYVl\ +l7MfD7Seom6ZMmhuvYHW+dGdOVsA7vDeDVrJEdhr/ozwlAnlBkaCQoUnG5rECN4zrUywuOIHuoYBxnw5n7VfgST2tvvaus+qotIZE+ZzXLFJQsLDz0q8/50mCQIcMa1K2J4W3nop8gd8yNVGEHA1g7KQXAqAwcb0\ +q+rgceyy742aZkc1rgg94vyFFAGvtPSw4LFL2BGLkFgayjb5L+1ryXr4VBfvX2y2W+npWfUBvF60CIW4u5UjpeJer9b9hCVdcBKctT/zXI24yuKuroHifkXqKPKiN+0IhD1qN6kdz5ozvvPQTbotNMwG9fbEapvW\ +qfpSqFZ8JAkVMtrqrzQhttgnKv7McXJEpm0SmeyI8v4MLdNTxVH/SkUGk1RMjwLpCmAxQdPcigA1tuWqST1Y2UfSltIj668y16NNn7c7clq71J0WihZIHo18WPZnvlZnnSX3kewVChHqFtfTQTfQeZgIYzRqDahx\ +Bhl0ecPWGTbkg5q13C+iNPk9vO5cp98KGNlorRBdNtD9d+hyxkdD9fHjgUAzcwZJzorNFkvfchIdcoo3ks6ZqZPo+vzi7IMUbkpZnwflmBXuvE9o0w+zElS5s71F7M1rFRNrAYKEDqE4g5a7nFFq91oIqL3e3sOi\ +ZjlL95Kq5Rlf5WkIwiIcbc8+UAuWxCqFoaFnDbXscLShVNBQBeNi6lijHEc5nHHB4oZ6bJt1PqvG8sCxfOJ8a6KugTd1GJuIY9BpXVBcY2oBxSW6jHX2C1XFtBXFi0zIE3Rbbch/wc4SW0GdGHh96GTIoQ45HF5b\ +dVJaabAiyouW0rDhEep+w1SlPZ5uMOO1upeAYmzOdwEArA7AJNNJJOJmN9614tZdwxJFPby9gfsytVPZMMWaILxhwsEPcFLBfqPOjjcTTiNETeaQ4ha61wPGEwUJE/UeyxJQNSp+7Rkzf5KJbC33CLcFB/PhImi/\ +bVNATRd+p+bCUGjTDlecmdFZ5fJKXLkwlKv6sAxnJansj+BetvsxHbdE3fjy5MUXnejL9nOUheKjOAc+gnWcxbTN/0dWIBcOvkeomu3BTI2cCbzj8lGtr7S8RsW4t484gS3QA7Kyi+PLJCNXqIHkGNeamGJDOk57\ +9RYp+QUqRNvk0FEz+fDV8Q1OfQvDwZKgKVL4a2QrY+X0A18tkisVFott5Asd+IkuYO9COBcgtVJ4Du9zbgTGbWbqU5FuEHQw81p/Ktnb4mnNJR/l2CkWTBJNZMUWL8S+ID2oo6zSvZAs+3SOucdTukXp+DqmMie7\ +oVs2tMfPpCSKGcnei+O/p8Nq6xIRspUpLsNoPgpv7XuIBwAyQVMCHOJXeHsHtguThHroDT7xydnF5QHtQygeTwW/uyey2FdSBdjuJ4h2wkVmxVa/NuclDiq/suG6R378F1XEWx4RsHeLjsSPdK4QinQ65vHKkURj\ +hw9YfvGsDebDmB6HwTmPUXpvn8oZsBEh3p7i2zRYHMd+YMsZ3yGK9YY6v4852D3Ec5hLA/7xs2HpJrBCg3KA3zdSHK/4zqfDqNqeKN+aq7vxSVLHd3pboh0MynnrBXs8++P1tlxs2/oZGm+Yg6CyDPa7wfzIsYCV\ +rLYRpEcDF8WzjKBqthJQmQr9oF3M5Gy15z0s+AvzPSwh7Q5hC5yXll/+DzkPLO0stU44//hBPNZt40Xog/fXr7+b32DxAGhpZ/+GAQd04lFBbRAQCF7Us3QJiHbhBi9DF2uFTpAnPqg3/h0Wzfb4ZKSHyYOVggXO\ +Vb5zXPRzyizx1IVuRgndWSlX7pvVF3w60702X0jC+IiBL+AF36hUUTyQZFim/HIDVK4kq8sofZG0EXMgNLS7KivCI89mkJWNcpzfOT+5mEqusuJLBhy+VntIOY4pn/XyDlP+TgrsWUAdQMGgThF9Z4vZpfvJlEMY\ +vvZlzf50gQtoQmCmntO5u1y8jMdvCKH5xhE5/8GxP2X7l2Q9NudCAMbdKRI83zhqrEowJi5duFJYBulsU6AKEvATuCFU8VtKw9wiDUxFi7kulUitAi6uVDO2zIosE3MZKMLY5iSlMFg/az5feGF+7JCfdwzig9QG\ +UXoYNOd4R4jLeJZzDag/2FwOX46GAV42il11s3oo11U5U3L2Cd8lciQ1qkJkHOfAjBu8A8NKpf8bx1NXg5mgSGZBXGHGYqfw77dcJ6TbLe5nZORgAc657JIxLEXtczkuy6fi2qXs2VzWgxMOk11NFZ0GIOWK6+bi\ +gtxxr2ayxf8hUEt2V/E1sPyGi894czFzR/auzCCnjohXXIyHO/LfOBT3DN1gBcDn+PILBbiMVsp4YzGdqyW3vk+n65Iv1/puSxgnWw5zmApo83wT28oiXoxNjj+hg4OeIJ+QpYjm7VG6Peo9DSMXDMYMZ2YYehhB\ +kXalU3a1Tgi/kX/Fy7tUfInjESx5uVwUUYRflT3B5Zhww2lQxoPQ0YNat8q9wHJ1scfn07iJkBcWNzqUlPs/HSuzgP+zxP8BQMx6qNRKAk8IAOaKvw4/uf2fwNS+wKi1fUaowXLRwKhLTJ7TRytJUT12spSQDrV8\ +lTwT/UAaAuaH3jLskE7HgqjyknitYzBfk6mkuvjTcO7bbjY78ewxr+DzEvrvLYqRIeQJpCD2L1V6itBu8ZFOINKlorvcfXV3zke8hap36DvfGdyipPVg8TCXCVuOtLScBMOAEdSlW2nY/YG6SLi85YJ5Lf+lKLwV\ +vSnmiaa+sHbvz/A/gP/5fu2v4P+ATVaWi9JlZd59aS7WVzfSaM3SFV1j7dee/2FYnVvv8hc9UZaXrijsp/8AQ2z1qA==\ """))) ESP32S3ROM.STUB_CODE = eval(zlib.decompress(base64.b64decode(b""" -eNqVW3tX3DYW/yrDEF557Fr2jC2xbQMlnZI2PQVCCMnSs5Flu8meLEvIdEPSdD/76r4k2R56sn8AtqzXff3uQ+L3rWV7s9zandRbFzdqdnGjs4ubrHjlf2XJi53du7hx9UP/GvuU+9xLXdx0tf/p/Lt77DtmE/pi\ -jP+rfUNJA6EtjNA0InS2mjrjx4o+WmjPlr6RP7YZ/c2yNd+jHEyBvfILT0oLff1EqvFdsrhyFsbDj6dMueQl9oIv8YUoXYtk8oq4nP/W2V7zNlA78Y/G02z8Am3uW4AH83SN/UgB0NzOVzFkFmkPzGhTIupph0Tf\ -tJ5nGuabwTywWdWb0FC3PkdO8dOr05ROv2cY2YyZuyTZ6+zO2SF9xZ72S3qOJXF/Etg+GQkAKJTtIGecUBU0jXUrrMoEmkQdUZfMYHsmf00PsQU5fPZxpTp99q05kDLNQKYgkZVale3RflvZrO/nxWFsIuIm4Zob\ -bssMCOrvarim4b9klZr47exDYXxibbP0fW9Png5hLR5jZmE24XodjHSCeufpai2vXfLznFlcJnSVA9M1TIpOOV7nO4mqFTyced7raUBndaQZfkDFlRexM0wCt4VBLj/nEX6Xpk6NKn88FH6yAArJxt3IYsJSfK5A\ -VgvuPIuUiwFbRfiD7ZaIjztD26iToTifVwYFc4ICZ9lnmgC+KAtAtoBBqbalWn+Z8tVcLMM0/fbL/qglbbpJNor67uBLwhxm5FD9Wi0YtEdsCS91/FISk3CM+5FsFghKPUYEs/v+V0VAqW4dpYejrk4PIhhgVz++\ -ga3PaR4wOuCHNvvwS4H01gx9Q8xQsDAjim7AJdznlS0MLd/YN8cs7W64eq9jX39ip5fFy+nRI1LTtiQ/W1e86xEk/xnT2mK8AfRgJf+4nhMbscb2WUMUmx6TfBdrjoFJyK41YhL0bobMco63qPlrf2tEMhAfyXbN\ -bWRfXLD4BUdZ4O1w2iloshKKzBSsneCUSJ3QjnXxgEasBM6ytxC4eqUA5ubR8WkHC2Xuh9v0dZUfOBzNbYWziU9N58AlxV3BYryZjdidlglcyQlcXTp5hTh2DfhGX5u6T01odwAPRR9NdDKIp0Jst/Pop8IEzUbi\ -4PqaizvclWAnjwvAYHlX9TS4SF6rm62eKq7qJAwwt0UTfZ8XfhT7UfGUXRd/sMMsxB6OQJb84zIRYohxpuvs/0Gb84ul50RTRldfW/bEmu0OdivaDny18N4Cv9c5VmGPp9gPWd6yznZAgyeTJZHdYDwMy3FMV+t1\ -djpIi9+zrhnSKkD7++RTkLm1j91r9Ll+AZC8eyLwssdf2N33oKa+BWryBRERWIzTpSP1KpQEji3QorLo+RuWhMPP3NYmblQNQzL0Y1p99X8GTyRbWEXwwQg+eGlNSAoOFziAl/W72zvrUc08dF2SQliO3EkQ57Oj\ -gl2OAc7W59D35dOji4t9isaJ2g0Jy197TLQljchmr+/8ykaWtxCIDaPGG5jNPzkUf/YcFMP/qst/sTQzzqsC99+M3OPRklULfcrRGyDTr1oXzLCG4KBmJEFEYS+MOA+m4UqIfOt8cuU7VJMTTz7HOgZ9w+6zViKJ\ -o/P9xOckOQ+oujPA6dxGmSm1IdrN8QfEdWBUYAbwLAGhxlgSbEX9E3bxiljgGYJpIeyyYFCcx/0NPOjxWDP1IC+7jSHo42Yr8DukqG53ymA12zndBtHtTnfgz/YMJnJZzlP3weuK8sPOPmTvlWRCHKvXjtUP48dU\ -E4naGm01yXUUGvQEPhcT9j2jsOQn8m9kea0j/CIZsMrkUXSCUhQxESrVXRL259Fq5XmQEFp8mozC0JqXtMye2yItm90BUByDPwq6G7oOmEaLmibYanJw0kiX25dsME9TWWxROxpZDym8nd4tsq9EsfOdc3PYSiz6\ -AAEJNUzEP1/tn2JB4Tx9gcCHqhB7E5bt69CyDE/l2hpJBJBHZbcJlRU64PNxmp1dooUeuF1y+ajqM1Z1DH/yiTgQUPoEkxxbZM/fqlhjWGkRnbs7XGRMQjsK8H6Y7qEln61TmICOgCGiTkaDSVvxOWbFPpIkC5lY\ -xzGIEQXJj8KhEYEoTXdbss8/aCFvU3G+Tl+u0peb9GXZUwHM0QHtvKBfhRCSLI+by/01KwbOmZKy3QmqfS1MOWE1z6AdU8c5yS4UQ7KYnYOgwZw01poEJkYQ90604HvOWgB1y2+T6JYzFrdCBigbDPXeRSEhFutP\ -ZHKxRvgAHdR7BnG1C52vlj1lraIeoZraiyWpbUsfEAmGsWcSgNfNn6ircS+j69I5euI/6C2NS9AR2EgJEKAtqZtFQPMWeJ14fuLLFXBvwtsBr+ekxjlHVCczYyIZv6HyWrJg6my49U/TT8+ACXOCHBQBwub1Ju1M\ -MZ5TAfHqN45wqooAC4CidQOAxEB08ZZIDhEJe2vUFKnc6KRD3NQZM6eliNJ0MXvIyre0p5pzE82YDWkAZM0KDLL8PmKDy1OFEUI+URwQKjmq/rAQJPpMWmYqCqFcBlqbaeJIJQr8gbhmWpIaRskdBBTAbFgcYYU3\ -YUYWscEVJ3Z3uo3YZLMUm3zHGj+20Vmiv56zv7ZOzBnHrlMY2dNY9SVpJ4cu9uHPh/uPwZqpXP8I5qggOYDidea4qq0zaFOxwH8qbbF+8ErvcSTSy5YGqdWobcaq1XN7e+OOcdK9lXTE8wJ88XvdSmacJWX6Lutv\ -UWiP7MIZ6rRcitujWsNNAFhAZNlRKwHXUQi8TEwPuyRT1KFDliXAbXXy4sGd+r8N44xkmNtJ5ayJg/xvp/jQQUp0XjiXU0wxv43GmpaVe4cj5N2SoNWFbATsJv9xWoHa6zbqGJWyAGsVAKqVGGwu6LMPCXS7hr8V\ -oVXX3b0TIjqceI0DwIbr8a0UEjrS99quRV+hODSHLbjRiRDPkHFtB5F3lJYqgj8i4LveIQzYEhpLdzSNcedO8PjLWOl2iWN0dhIrD1LjbtSKhcm6Tzi7UqPFcY7JisW1+sdqZzlG1DXApdH5Uk5JM4TswENXQLyi\ -MqmGSXkMon/I+XXBbKx5mRWFRAQklnmjdnjJpLFOntuQUpJiMlq1K3ZvG9ZEKMR37d1HEK4U92JpJDlNw+LK+x61N0mOW/T4OIOzN4UaUjEeuW1sA1TOjy+WO8ebnJmDU3VSU4ccomVbw13KFAXFGpmEOZitYT2m\ -mHQH8KwBiJINF+Z40cdC5dZhaVJ88X+ovrVYF4EvfkfefMny7IxYC+OBREUJFGBiLJa15K/Tul3bbkjjhqy7iBWYYTkwcpRKu+hRNdtjSdEL9q3MefdaosI4V1feTFELoVwkFbiuPLxYdqi+iz8kW9mWhbvDOI1F\ -TO7OeYLGSu87aeGJCEq3BiBXt2FrwGioosinhqYNJ8V+QjmXKcmvRj50MuuC4zJesl7BDVtG/FdG9GDUMW7sXsd5L27sfSivLXnbAnmd+YWz02QiXb5INp3F2pwarfh70MnBjo1KssU6qcpJmXe05rOEq1kSMuKB\ -AliVfpk0Kml8zWvMVqxRDNf4d1J8yMh19Tu8hRmYJS33Ij1Gfbx/OPjmsmjyQnqDW9k5FoCvJPMFg9RGTjwxqaDXlg6Gkoek/qb7Vp3VxQbZeted8dlms/jbIMoBYc3Pnkqo+2xVWvIUYHvxzTA+2mQ0F0xkIHM5\ -VRa2dIUnPJN4glnPzvh8BjDAYjxw9omCdDeQv0bgb4/AV+8/Z2yhtOtyVOvdpjlG1YeCMRVjkIzLhSpLTh60+nZFXFvG5AGTk6aPTU5cQCnH30dyRHv2gmoFLjkEAxVXRqiBbvPnZL6qFYJcUkW1aQFeEdlD8oY3\ -WQxkcnR+WvCKUhSzz7h7LiTnq0k2CcmNi0mmwlCggtx4vjtfRDn5ZS77QjJ8ALFKSIApfTKCHIJkeKfDYyF1Z/WOWxuVx7WpkCo6XHT48R0fFQdbFNVlkNdtYs0oNZ5TO1Z0qFJ3WMJoeL8koI4L2DXa4VaItuAJ\ -Suk2RHMntCSeb865VpFUe9sgc14t7C2PMVmWk5PewuOik0lCUl5FHNflfzme1M8xA9iiwNfE+B01z/K63rg/rYAFjcTd19+zt0ctHMJaLkU6xLTf5Myj6i1uEEJyQrGWi7ZGck9UtYZcYat2HNrrvRfrXBzKE8Zp\ -Tt6FIViwb8Qz5VE5wv7wiOMx16D0Oa6ylXPcKXdrXOILHAc0mL0XchonB5NQDtaDug6eVFcodj4QhkQOAgIqNGfVDmUiRsKZuTzwjQ46gMCHiXwqRR0l9kIQLcL3isMydFM+LAukCB2K6SiIDl2eSq7QJUxD9SpW\ -Me2Q7+Eh8+WLPqP0SGGEeCBXMJ7Chn+K/l/rxJhA1fqu7wcZ9ytkCB8gs3wO80JhD48nUWtQwMUY+mjOX4DZUYNh2oMVdQDsu3kgAc7DcKNtK56shHRnuFDJXi3jOr3OZiO3fsYxXJud7pO7NdXXMMdncgRpDS6p\ -BeLJnyExQXzWMNZjBjnYB97b4bwU++kdSuzBqTThSANbAKz8uOske23xFQN1PL1OD1GwxDTpp7rXoMAFqavDyPV5QYtjvIaBSHcQEcpg/XDEmMWdnggiqrlyjTURHB0Qa0D8mqACsKRQfH7DgU9WxIshWRIfY2Gv\ -oX4EWbzPOlg4dchyZqPhozlQe1Mk1jeM5Vx5xpuZHzOJbfLVcJFkjsOqr58wM8Fi0pAPd0V3OHCAK9MTIgYyK8Hlmx9JNAYPl3HjnGIB9Y77WgeuGFowTjFUEcZTppq2ifWKmjCMSto3KfJ3fHpVcfUaKdOc9rHB\ -RouXKgX6cUVDRUMt2t5OkNClcDHcEMUzVrh5Oj/F8gfd4DuVEuS5JPFYFjwjz1sXg7yvC/nyNxWmmF0waMwrOpf4S8wnNouYa7lZDBJUJyC1zTdMAij9B8MGqVewNvW7fB1DSywwtCturuSy1Z+Txpk0vl9QqQQ1\ -G6EOT8rbE4oY5FAa5fnbEAnUr2wu8pCm/+I/syWEKdFpwEOGqYWmtJ5SiiOyR4fw93aMOZbvaOD1P9rjGByt6TOhodBkjvNu8XFbDIs4EPnMmZKdxdF1qDz0yg5UokfXWNcT6uZqsmvMdSoSk52/iGcuBkXzpaWM\ -vw9JO8aaYQogEKd5RvL9CtB/iabUnG9WFuyfndy2UPFqgVMbTzgUZyC3+QZH+iVFJvisNziOgCCp2ZiOr+7SOIySC+EGc0CrJ2MZKfK013Ib4OMzqDLPdz98hD83c2CKywwWFhcrgnOdRwnphKFmICR0J0rO5+Fa\ -RthWzuVUwUK49aUCAKq/wgLvCHbwiFV02byDTX+A/X20N5uCPx/iKX2GB3IcUFp2pXb+iFmFrH4HGhcQUUWY80DGX+omaCylzo6CNXwGhxuuXagVWRjmObXehAXfiQkSu+uaILs2mxIJcoPsARIzq/kgGLoDZkNl\ -Gr25m3BkXXADcG1+FSeGLBRGg67ihbksxltQC7EtH6s6Op8PF0iYZ85DDajG/DGXOUN4Ad+vndw4w7t3NzyRlXC541q14avPTbnDx26YKJR0ecY6OfuHREiSXFeZZ4sEO91XdEsM9bE8IT6jrVV07BXugYUZtDlf\ -/Czaecx3vcJX4+d/kmKTh54zAjSTbyRHZniM3bDXWJFmY3s9Mo3v+rjn56/YGyMQtH9JSp4BRPl4qOmvgM+FJPXfDCe+7T6iaWL8TsEGl/rpVjhFDs7l8WINFpmrGJNleH5afOYIOlzW2OTu880pn3AlGXnvgmYG\ -N9NoPVjcTWXCjj0vLTeVC58c34XLPtj9QXJDa3bLbdBG/vVBaCt7U0zjnvrM2ro/wX8r+sf7pb2Gfy5SWVUVlcmq3H9pL5fXH6XRm7cqfWNjl5b/Cyk5ttviL+lEPuwzc5P/8T9O/npU\ +eNqVW3t31Eay/yrj8QPbwF21ZkbqJnuDnQTjJPuAhDiE63MurZYEyWF9jJmcsb2wn31Vr+7Sw2z2D8OM1I/qev6quuaf99bN9freo1l17/zaLM+vbXZ+nS1ed/9k6osP98+vQ/W4+5rGFMc8ypxft1X313bfw7fd\ +wGxGb5zr/rfdg4ImwrM4w9KMONhbGowvS3rp4Xm27h7yyyaj/7NsqxtRDJbAUfl5d5QGxnYLmbobkqWdszgf/rqTmaC+pFHwJn2hk26lY/KOuF33rvW9x/tw2ln30XVndt0GTd49AR6s9B7H6QRw5mY1xZBlOntk\ +RqMPUc1bPPR10/HMwnpLWAeINb0FHQ3rc+QFvnr9Qp+zoxlm1mPmrkn2Nts5O6W3ONL/kZFjSTyYRbbPRgKAEwo5yJkgp4qaxroVd+UDOqWOqEtuQJ7L39KH9AQ5fHYzqU4fu6c5HGWegUxBIpNalR0RvY0Q243r\ +xOG8EnGtuBaGZLnBgfpUDfd0/D9ZpSV+B/9YGK+sbam/Hx3Jp1PYi+e4ZVxNuF5FI52x3vlODgZUuXvjuqM1nlQauVyooxUD63V8GquZXuUHStsWPJ3Z3hvpQG1tOjb8gZabTsrB8Sn4WZwU8pc8o6PSVdqu8m+H\ +8lcboJx8okY2E67i5xLEdcKDl+nkYsPekAvC554OnyhD86jUVFyv0wcDa4IOZ9lHWgDeGA++7AQmaYXTin+h+erO13GZ/vOL/qw1EV0rQlHlA7xRzGFGDjWwseKGjogt8UuV3hTEJJwTviezhQPpoJH82YPun5J8\ +pblzlh3OunzxdfIHOLSbXwPpK1oH7A74Yd0x/APq67YcvUO3YWBjdiq2hqjwgHf2MLX41f/6nKXdDnfvDezrTxr0avFq/uwbUtOmoFBblUz1yCt/jmnNYkwABrGC/0Ivjo1Y4/usoRO7HpO6Id49ByYhu7aISTC6\ +HjIrBCbR8ts+aXRkOHw6dqjvOvb5OYtfXCkLvBkuOwdNNnIiNwdrp4hFR50RxXbxkGYMuKvXLv/g2uGPra3+2P4q8fMNuGa7xyZi2X/hF7eUx+Bt+HEv+rFC+fBbjGjHiXobwJ0yYljcdTLW0SXqybr/BGesJmbo\ +FZfD9ydq4CpF2hTqgKZsRpHALvgPl51xdMyV123G+wOgyUwfOY6tK0mhzQSoVvxpf09xcyvFXVxJEBLhxghBK4Vqph1VMio7wFUYl4uxBPMECbxXCsjPbb7PDwOpXwI9TQqPMNt4IeC7uxyiUHM6IKVhJuFK35Fk\ +nQpVVkKyz5kpBlyBBIqmjNCrsxELcc3NOZZanhGMWA5L2pHUUQMAC4DHgCgDW/j2CLgxjzZFYdDZ3XSqMW5mwOjz2d16A9wTtGWKQ6WjdgpORZeQE6VBTCPn4Axq2jDR3bu6YgGxxsfn4aSf6US9VRPjgpaSDGNm\ +fdriavXu5wl+JHlFnnaCyfLdVPNd0SLetF3edXavzo5nW4039lbMyy/p0xGZV3Rgdcb25hnFgFL0WLl4CPGXw2gYSFf8DaoQeLWalPAujxYTJxaO+IpxvjjwZRNRtGHjqmuk60JLEBRxscdWv+Aghqp+P/efd2HO\ +piOQoSF6PL8Sf9OyTeOAYUrr86/76cEw3tip2GN4W8kP2jb94YBlzLgChQLKCtbKWUQfON/mrKdA+L8mjldNckmVZ19oGW2AXUiMB6GDFwD7sfk2J2ksI8Po2zPVNjsAPzCbcboR2F3hjmxsld1mf4QngmBaMZYr\ +YdQD9iKg7dV9iAQcHVGv/iLe84jfcKrTw1jVHRgrP6FzREbjcnqmnY4UppupFApht5hAoKwKnzUqfzDDdBQBvJWpzX+RO5KQMbKwr3WCXzqZzUgWAff4Gr5sH+4fbCdd62DbhbLqTj1qJO7l8tmC4bYD5lYvYeyr\ +H5+dnx9z7MYD7wp4eNvhQV/QjGz5ducNO768G1EthknzNazWfQpo+NnPoB7dP1XxDxZoxs5WCSALo+zg2Zp1DH3Ds1/hpG9oP+RZTSZdsZNCZ8VJCNo9mEkoIPev8tllN6Cc/dBxgN2jQ2j86Kddin1t++zlsYLc\ +yr+BzgcHzBaX4RhWo3azOqDnAghYM/SBz5ISYwQF2RrzGxDymhjRsQV9HRAKzglUVOxznD8tSXlGMEu54bt4gsq3nICJsU4XHs05jCwPXuyDAB/ND+C//SUsFLKcl+77sUsqkrX+MWNsVQ46ikD6gr92MUXrI/h+\ +JEpVewya9QzoWjBOaEe48a+4DNtfE8iRWfbXqDJ5Ep24K0oYSXG9VVWPPNmufB6UxBAEwekGWXglUKtOEWoq0fTZDqGkYRBAQbdTCY4VNVVO1uUADPFc4VjqYbku5uETc2CR71DE9PPDRfZnUez84KU7bQSbPES3\ +hBomsl9N50WppPpSf4G8j+qwRzMW7Nv4ZB0/FVtbJBFwPia7S6iszdFLP9fFqQu00K/DI0asnP4QzIigsqRgk5XKLYVBJhIBvPmMObThcLjJ+Ahj0PDd/AjN+Gyb0JtX4LtSs8GkvUQeN0GHqjEhEyuZs0txB4RH\ +eGt0OhRlmJLjOy27t/rLpf5yrb+se/V0lZZs+ZReGd/+oooYq0pO+gysbfYDDgHXhjr9XqLQUy6lIBh+rPJaLqPU2TRuJCN9n0wNPaS9JUNIdxcPMWx84KzAQN7dXq57KlQqpFqiG1mLMoFv96XKZTRWF1xswF9+\ +Ro9ceKUyzhyj5Cf65nQd0dB8OQycAdI0H9O4zjSuZP+GokV3GGDgjMkxjQQyoj2IK+NzsmOFS6GCHWs1Aua389ufShJU4AIxxcurPaLMsKMlnH75O6OPsiRPAhbchIHnQqh48o6RUpb8vJNcU9JX5OfIf551szzF\ +PgB8vkjZVla8I5qqqkleH4A6FBsMcKl4miw2WK0wcopbCs2xvGyqzYn4h49koK4kbBMy0NrMEjtKUeANscw1JDKHJg0xHjgNm6OxMxFuBFIbCmAShNwqeQyfaY/RUMjBgQpYE0rYZUw2cecQ/OO/nx5/CxiCsr9v\ +gJQS6lYYs8NrjPRo2i+gxgWvIgy2r4H4LRmHcAYGmHTT+EKepSrma3vEPqOXwAyyndGzJa57L941SUV1cMlkueJie1HqaLxg2nziJV6hSNqPX8xSObs26xMv3Eu8wTmVvtFBgqgWeq0qhRUXEOu9GByFqEbw0bOI\ +k7JUi4IAgNZxtENcQcnsy9xlHLhmTi2PMI2S5LBVeaKNG3irNrBLHvIuDnWSUu6r24E6TSoozcHCXEgXexdzwHXhq2T4Ojfu3QGHgoFfKFWcxllghvn38xIcmG0oCY2IGCtcBqFjmZwd4blj9qL1lnwwkoke7kTw\ +hstvUebTYmEcshjbREhkqIZQbD3hbA1ssuZaBVccYxrDUcC1Q3Cu/GulPhtG9BkXplPBwCUMGaYwpHkEW/ygcm7z5TgjwL1Yb4VYXNLfUSTG98V4od7kUaAAP1yNLs8Xz+YJJB8khGKsyiitS/ki3kTmJnkuKWZB\ +dlWp56quElSqw/RVboo+I2rzpE8kvJrDgaepXSdGupAuRIOfJfLk9tS3ExtTEvwDJ65mtDkV1yc2hxWNn8jyDEWQkRG5fCSCnAAixBNQtbAAQGgyuQ6R+xHIrTwX9jNGmLjNRH0NrNSysGuVqgf1vFKfm5izx5Kz\ +oeA4OoDFpZ7/C858+A3gxtX9Ey4zDCux5v96xZNcliGQWnwgT+6lBaKOI+enCjvyq75lfUowzJlp0Dl+/v5WAILtNZZA2cxwAcdixpz1ejk4HbfV9EZ2JGhdM7cT2YLuXmHe5ZRgoWTLHnXLlDjz0xt4Oj/embMF\ +oIT3b9BKjsFe8+cEpUwoNzATFCo83dAiRqCeaWWBxRV/oO4LMObL+az9Cjixv93X1gNWFZXGmDCf445NYhLedlbi/XeaxAhwxLQrwXraeOuV8B+gIRcZgcHVDOpB0gsAk43pl9DB49hl3xs1za56uCLgiOsXUvu7\ +0tzrHmI3kyu59og1oWyT/9K+kYSHr3Gx7WKz3cpIz6oPuPWixZDPw63cHxX3exXup8zpgpPfrP2Z12rEVRZ7uvSJ8orUUeRFb9oRCDJqN+k5Xi5n3OrQLbotNMwGVfZ01DbtU/W5UK348pFgEYj6K02ILQ6Iij9x\ +nByRaZtEJjuivL9Cy/RUcdY/U3HBJBXTs4C7AlhM0DS3wkCNbLlYUg929pG0pYzI+rvM9WzTP9uO3Msu9aCFogXyRiMvlv2Vr9XdZsljJHFtyl7z1reDYaDzsBDGaNQaUOMMkufyhq0zbMgHNWtpK6IM+QN83b1O\ +/ypgZKO1QnTZwPDfYcgZXwjVJ08GDM3MGQDlFZstVrzlzjnkFG8kkzNTd871+cXZrRRsStmfJ+WYEO5+SGjTD3MSVLmz/UUczXsVE3sBgoQBoTiDJ3ucTGr3Wgiovd7ex1pmOUvtSNXyjDt4GoKwCEfbs1t6gqWw\ +SmFoGFlDETscbygLNFS8uJi6zSjHUQ5XXDC7awgQWeezaqwMnMgrySEmrlGKlIWLY9BJXVCndisuKlEP1tkvVA3TVhT7l/BMMGy1If8FkqVjBXVV4PVdkyGHOjzhsFvVSVWlwUIob1rKgw3PUJ0MUyX2eK3BB69V\ +HwKysTm/BwBgdQgmme4fETe7sdSKO6WG1Yl62KeBcpmSVDZMsSYIb5hw8AOcVLDfqLOTzYTTCFGTOaS4hR71kPFEQcxEvceKBBSMil97xsyvZCFbS/vgtuBgvlME7bdtCqipz3dqLQyFNkm44syMriiXV+LK5UC5\ +qgvLdFaSyv4I7mW7H9NRJKrFy5MXX3SsL9vPURaKj+Ic+ObVcRbTNv+JrEAuHHyPUDXbh5UauQp4z5WjWrewvEHFuH+AOIEt0AOysouTy8QjV6iJ5BjXmphiQzpOsnqHlPwCxaFtcuiomXzn6rhxU7dcONgSNEVq\ +fo2IMhZNb7mJSPonLNbZyBc68BNdwL4H4VyA1ErhOWzj3AiM28zUqyL1DXQw81q/Ktnb4iXNJd/g2KkjmMSaeBRbvBT7gvSgjrxKTSBZ9ukcc48uphpw4dyFqczJbqilhmT8XKqhmJHsvzz5e7qjti4RIaJMcRlm\ +8w14az9APACQCZoS4O6+wlYdEBcmCfXQG3ziC7OLy0OSQyieTAW/vVPZ7CupAmz3E0Q74SKzYqtfmfMSB5Vf2XDdIz/5syrhLY8J2LtFR+JHulIIRboU89hfJNHY4Qcsv3jWBnM7psdhcM5jlN4/oHIGCCLEVilu\ +ncG6OI4DW864YSjWG+r8AeZg9xHPYS4N+MfPhqWbwAoNygF+30hdvOImT4dRtT1VvjVXLfGJUyc7PZFoB4N83nrJHs/+eL0tjWxbP8PDGz5BUFkG+91gfuRYwEpW2wjSo4GL4llGUDVbCahMhX7QLmZypdrzHhb8\ +hfkrbCHPHcIWuCYtv/wbOQ8s7Sy1Tjj/5GG8zW1j//Phh+s3389vsHgAtLSzf8GEQ7rsqKA2CAgEu/Istf6QFG6wB7pYK3SCZ+IbeuPfY9Fsny9Fepg8WClY4Frle8dFP6fMEi9cqB9K6M5K6bRvVl/wxUz3tflC\ +EsbHDHwBL/hGpYrigSTDMuWXG6ByJVldRumLpI2YA6Gh7amsCK86m0FWNspxfuf85GIqucqKLxlw+FrJkHIcUz7v5R2m/J0U2DODOoCCQZ0i+u4WH5cakimHMNzsZc3BdIELaEJgpj6n63bpsow3bwihudGInP/g\ +tp+y/UuyHptzIQDj7hQJnhuNGqsSjIluC1fKkYE72xSoggT8BG4IVfyW0jC3SBNT0WKuSyVSq4COlWrGllmRZWIuA0UY25ymFAbrZ83nCy98Hjs8z3sG8UFqg8g9DJpzbA7iMp7lXAPqDzaXq5fjYYAXQbGrblaP\ +pDeVMyVnn3ITkSOuURUi4zgHZtxg8wsrlf4RjqehBjNB4cyCToUZi53Cv99xnZDaWtzPeJDDBTjnskvGsBR1wOW4LJ+Ka5cis7nsBzccJruaKjoNQMoV183FBbmTXs1ki38SUEt2V3H3V37DxWfsV8zcsd2TFeTC\ +EfGKi/FwV36EQ3HPULsqAD7HPS8U4OS3HyxYTOdqya0f0MW65Mu1bmkJ42TLYQ6D11qeO6+tbOLF2OTmEwY4GAn8CVmKaN4ep55R72kauWAwZh849DCCIu1KF+xqnxB+I/+KnbpUfInzESx56SmKKMKvyh7jcky4\ +4TYo40no6EGtW+VeYLu62OeraRQi5IXFjQ4l5cFPJ8os4OeV2O2PmPVIqZUEnhAAzBX/O3zlDn4CU/sCo9b2GaEGy0UDo3qXPKePVpKieuxkKSEdavkqeSb6gzQEzA+9ZdglnY4FUeUlsaNjsF6jfkRhi/8Zrn1X\ +G7MTzx7zCr4voR9tUYwMIU8gBbF/qdJThHaLj3QDkZqJ9nj4am/OF7yFqnfoBu8MmidpP9g8zGXBliMtbSfBMGAEdakZDYc/VB2Eyzu6yWv5caKcregtMU809Zl178EMf/j7/x/W/gp+/muyslyULivz7k1zsb66\ +kYfWLF3RPaz92vPvhNWt9T1+oxfK8tIVhf30bx8B7is=\ """))) ESP32C3ROM.STUB_CODE = eval(zlib.decompress(base64.b64decode(b""" -eNqVWn1/E8cR/iqObezAL7S70r2tSYxEJGQZTGkKIVDRcLd750ISNRgRTFt99+4zM3t7ki2Z/mFLutvbnZ155pmXvf8cLurLxeHRTnU4nF1qvTu7tMmB/9ebXarMf/q/Ks/9j+QN7k9ml67wl6s8kWtVPvK/i/uz\ -2WB2afTssqj4s/ZPVb3Brr9teiM/u8JNP2+h/PfCjy76s8uS5vZ//qLuf5xdNqn/0fBI42+6FGvw01rLd/ypN6dY2H/DNMY/QVchfPkEkv+Avcg2amzMytO0nBe9cS/zUxb+0qrHEGDhryYkwIXfgZep6Q2q0Z5f\ -oNhnGare1AvVGz2Y7vpnVVrGTRWyqcPZfOOGlv6qX6D2MmvjvzT+jvXCV03un4Nc/33kxznWI55tmjzfcCMsPWTVBIM5l9NOeT4In4nOeq3yYAI/HWzZx+f3S5GleEFmg/DjuI7yn4VZMeL6oub+UpbmFQYdGcJK\ -8be238MAPLtf7+rUBEUCl/H2MX2e11vU28jYR2FlAWvpH7bN61yzOnWf7czDdXHiF3EevIUeeRS4jOFJakhGuAfr8SpVwiZS6gzrpvch7KirOM3zG6xP1/yUud9GnfEAAlkmQPd/xjCWwnWeJOjiKZsAS+Kzyg9a\ -lT0gowwn4lB4LJ1gKLZTsn9oyzDHIkUt8xRbXE/3O1ux0OXQ/9ceVHXKVwvx3gKLGcyvv4IHAEmKsYBhjXlxjEEdr04nlv0waLcwD3HFq9fJlca9YMNDG9C3zmVKHWWrFPzPapmsz1CDfE2NSSfBaTrA8I9gH5l4\ -nBLM6Tgk7LjRcXXYw9FqJBgt1WPWaezVKSDYb7xwlY8Jm+IHGFGkY8CNgfnX+3YqOyMSnXSQjF3ZoKJ+x0GFzhxG40eHQR5gyJDHa5GcdKdwJ8Od3h4MLlMXGQCyx4uUYfvdyY0+j+LQ8klcBLr0um4CbWBOYspg\ -oyB/iVkCGtXaZgLkaeebdUC/hUhUgqVbdxL64i0JAl34gc3yUl/xHY9JNqISHMCI6/QiU7rulLUI7AiZa9xmREz4FfiKnEOcm6QEVRZpCBADbzOdQlMpf1FqG3PaNOcLHmgX4664WjTK656Lvvuggi+S0JOIq6Fy\ -iZ827c7uxIOuZd849SpfwDZlpAq6mQaHdfp+vGTpUpy8NgyHVR8nh6uib1udxynEMdPWJFfTkzteYs94lfB9lQofYxojecXmLAR2C9kHeWoCzq9dR9I07PxzNw+hdOLa4ET5B75OQupBKcaTjjIlLoGJEEZkhbKW\ -rRjSnRfu9kjuIMcwB8zxuv+SyY/Ub0/scz+NCj9H9mc4AXwWiLxHIflkcCDuVTNMN6OlWUtaAmp4hwPizxk9iHSvZOTNSODZiM2APZh8MOKwRPmTJEySPK3kTFV6r2YYhgRvJV/T5p5kbLa+/2sXcyMWfZtrulpi\ -GHywJuxPeCvEavnOMRnl4l43LZkE0hpcsxrCQtFI0KX8drxZBGKqCkrJJXCGfFLCZkcRw5DcBoakQM8Q3+PAHhiqw50LFg9EZrsxjyLq+ZK9AGq0QiK4A3QU7oiBB2jhs9Ic9gsMrvb4Bnv9EJ5gOAyyMp5yGF3n\ -jY/vgXS9/IAxb2HA9ECWrtkYDpFV8i9Xyv7y5YI5xcQ4u+DFi5DjiNcAWk15zJ7NXrHLqgzOc70tdjigrE6u0ndxBQJuORmy+3Gmdd7JHOgPghrhBBZlg4hGRFx9vLNaDa3v3uCM2soIq4GylOILCCu1UWFVObgD\ -bitHs7n3rSZ72byCgl9NW2zB+Y39gEGB6d6eMiHAEEX65AZBwGdXWKF2K3Ns3QzDn8BYMosxUewP33aZFqJlz8EG+v3yw49+6j72ov+B1N47knWSrzW7oLUDuNcp4tgT+MAPcE9UMNU7+NC89YOgrIzhrdeMQrl+\ -ITG0cZ9CMnMsvhc8oSkEc+WfuAarevKp763lmL3oMW25ioiljr9AS0gJ03OL0PiJqatIHWoYiBkgWIQ6Nu9UAitegkFtUXy6bd0dGHX577DE5gVoj/aIKYQwbK8O9lJcMNJplDxa6OmxVK/petKZx5V5OGFjItTS\ -vwvuxUpN5jNvVYUEHkGu/xxKKyXpbFHoLTLsS8wrKRBuVcAA9TrFslI+ebm3nH1VImxlUCg1PRFd7qj83lBCTUIR/ZOkgXRlRYgfb7BCZVb87Iyz0f9LYXvfsCUAVl/rgunPKGVchOvNdggSDMulJBH9ccLf6lI0\ -647tQLKiHmdvdY8NS5UZeds6jPIujOQir/8DlyhzLlBI6JQFDdlim9AD3SGhpz4ULqIWqhPp2dDaSVx7lbirrAPiDoF/EXGHh7+MuJtmSd4/poFT8xp21WadDJgk6vUCtXd80/R2LQY05dN3zxBRn52+hJpf3nkF\ -LL+azf+Om4/ePcbNx6dnuHl2u5t95S+G05fvo62QGEETPtAcS74oFA8Iu0Qqpx4zuVM8xkpstxLb6V7JolMBkjFMkBCiXkL6DkRZNecBm/ySVuWkqLiff1qrHoPKAqOTk5Zgzoqn0L1bBioa/xOooOQyFTO05exq\ -KfrV+TFBckdyxFDC5sWgbRXyEwBbRePK0PU5FflK6IBGlawLEXLOfUHLBAEQatU2yeybMVLPgtO5Ih2Px1v0UtciWIqeo9IPQwMiVCzbn25iS9c+yqM/h1q8phaBkkS3ukGQTVyCKqapxYDc0kJ5Elo5waNJ88Dy\ -Ws0MBhvfwFRUNZ/nj0Tz6CvpfLVm5YDaDJugsdjFo3TKEDn6TS7Alr/kj4OZt1QW1BTDzqsQFRn8bT9HUh3gB1tEXUXXk3jdVybciJhLG4L4WUvp1me9cCNytsBQqmLkftlfHY8/l92m9ltobmZn9LNtbtw9hsLG\ -X0MlJpPOQp5EqW2+L9vTyLBU/pqrndbf8BAQgS3VcqHbAfgtWS3/n3d+U05df/72doZCugm9xNAA0vzdaa7hr8V2zTLr9Iaiq1bxjGA2m6wV8r0AcYGKovpVipyqCapIYsOs1Usp7SZ0TqgMDHEIVVctEcxY5OP2\ -+2NY5KWwjQkGDAZDxzkuFgydUrcUrJHfsXPkIFAaRKMbFQkGf6Qbxewijkfr0/4qd5LZgu6kQXg9jZGOugVtoS+nHd+G3wj7TUqtlG8l8hbxuVVxvyOA0d4f2HegzISUYjnC1MjJtYkofDa7WFMY6IPmTK/DoRZK\ -44gk+k8lLXJSkqL6Q8yGa0CrRtPWtTT4kKKmD2XVlC+Csi1sp9KxZcMT29diPVec7O0HZt/b5WBFMHVcA5RpsIfLdxFwrCiecqGHohWHVn6pw+KNLJ512yk9ieNN8K8eh1DtRsRP73v08Zx60keogY6iF8thktO9\ -YEnYWSHvKwXMJSPHkqQITeuqIM3BRDBzIwcKzj6GjZA34KzBqBPwG9LJYrTd9wqFjpwBi3PLgxp0d+EGZxHDkBvVHIN1SDfMFRQjOLbySsO2IdYXFCnJWMhQXYhLp38h3sfWEv2rZBpAaLognHAQELBSkl132NxI\ -6KamYr6/x3BRVWzalwkp/xbvnA8XduhQIoBRYwLgtMVKvz0RuhBPdgKEcEu3bVJT812AsSST0WFGAE46vhM8ZXomrkBzyNzgrfxBuDhoZxW11MWaErJYaXinGMZutOzT8mp1NwmLqvd7nsRNEOXASWD0WlyNqfVZ\ -1+9HITZPu/GH7zkBXe/KnYV04tfYmQoExcquO71XLRKWQhgqHY2lFSsAozZZB9i1+r2fBEBPpV0JTTjROCU71P88Z2YKGjGU+ujvMN/do7vIUIZojRm3FN5xy1CQuIFUBIVkJiX1oaUzt0k2peYAlJszNGsJnlX/\ -0y0mTSqa8uHbuAwiS0F4Xn6OVz+D925YrFC/SBgzp7xe25zf/NjgXQh9ZID9oXRGGiFhOodIW0YeSdQRbNN8LfWUGvSXdp6ODyTxAWNPrERkdiE/xYlMoXFoVLiQY4SnhYMpn+WnXYy/ZNwwhfS4CynkmpQOlIht\ -+Lgqkb6QHKVWuZxuNW1O8VD8S0vKnksHtpbDBxeoHKlOKfoxErFEYCcCl7KvNlm+3nDNd+G89JOQhoosCAFqStZeTzqhN4nwJnEa9xrP/MEyueZktA2Xf6MDiZ+A6mSwhE8KDYVjFKOEjmzg8YYTpKIJmWchDp/O\ -FkP23nBqxdoQFy76t07lmI0OfrjCQFrfrESGN/D829LSwYsaRLnE63UWc1qvo66CpAHoiLO+Ds9Iako8VwULU5IpPtUUA8uNjLozmwqHzgUSC8cpxr60GZU4fbWGGK2exBzZBBaktCbE+VVwiEIp6e7vR5G1HC61\ -XQ/iQr/+XFId+kT0bg9R4GzVihbRMLRnDNmVsMuzvZXmXPeOoTugTjOdSKSjDNxSNktheRzCcnh5qNyWi68AVF/NzalkcJIj0Bss02uiufe+i/iShu3bEc4KtP2JXxsJleTvpCU2Um060Oj2h/rRPApFHiTixyUL\ -kK6EapvQMQgLW+HdE9plcjUdRkRMXnMutzlQncX3oXiTQ8q1PlARsMu8X6MVseAGdgzoihhdC1+wohYU6H+MJ4xBgRw+7FOC6BwdBYz5M1T4kfNzmjgNExdZbFAEi12/iTdT8tvVM0dRfWO6Ukwl8JbyngP0vToi\ -6IB74YdDqrdvb1sdQX4itYRn9LpTO6bvO6oN5lGjbZxrVl5Xg88/Wn8LSIoYUs8LYTRNUP7IOK7kja+Aa+lGHwqTgPRxiU4mJSJtUOxR3EyhjjcN28neMw6vy/zZzH/x/yopYW24yFxL0urwgswf4TAzoCZjr97S\ -gJMXmZpj7ii2eKN4irfn/IRz7jzySYPPKMOZSBJXUOmJHK83nI1dnDxAH/JImpBhH1W5O+mdyJs8oU+PhoBWMXsNnR0d/vpCtarabH0L6xe9F7T7Q8k4gAr0zyshp4ZyPicbps5z7wWiAWUBXEqFrrMczqrO6wY2\ -VqWFs8/jKTO9kxOCO3VrMun7tzt3mbRgTHDHlNMMih81lEohUbrsxGx1XFsCx6pf1uHEx0pWhf4YPdmBSdFwjbHuWxtQe3sb231T84KUnxGtcbQpw3L/6rwOuB33b8il4D3JZ0Fp9vTgGSpPlCjo5DTZtMF5Y3b6\ -EH6cPTpAlZw9pl4bToZe121v/fCbHXq19ucPi/ICL9hqleeJ1kWi/J16vrj43F7sJ0XhL7pyUdKbuNDsgLzjUC53Z1E6S4xKlv8Diz+ELA==\ +eNqVWmt7EzcW/itpEkjhaXcley4aaINNbZwLsNCHkg1rtsxoZlJomy3BLGG3+e+r91xGYwcb9kNiW9LoHJ3re47mv3uL5nKxd2er2hvPL63dnl/65Gb4N5hfmix8hr8qz8OP5BXmZ/PL2oXhKk9krMon4be7N5+P\ +5peFnV+6ij+b8FQ1GG2H6WIwCbsbTIZ9nQnfXVjthvPLkvYOf2HQDt/PL9s0/Gh5ZREm6xQ0+Glr5Tv+zKsjEA7fsE0RnqBRMF8+Buc/4ixyjAYH8/I0kQust/VpfsTMX3rzEAwswmhCDFyEEwSe2sGomuwEAm6X\ +eagGh4GpweT+4XZ41qRlPJSTQ+3Nz9ce6CqMBgJN4NkW4UsbZnxgvmrz8Bz4+vM4rKtZjni2bfN8zYSSHrNoVGF1ndNJeT8wn4nMBp3woIKwHXQ5xOcPV8KLOyG1gflppGPCpyuWlLhKtLh3JaSZwqjHg1KKv63/\ +AQrg3QO961uTKZJxFUE/xZD3DRoNOir8sVIWYy3Dw759mVsWpx2ynnm5dQeBSB2M19lJsII6Y/MkMSQTzEF7TKVKWEXGPALd9B6YnfQFZ3n/AvRpLGyZh2M0GS8gI8vE0MNfUbAt6ThvorJ4wioASXxW+c1OZPdJ\ +KeOZOBQeS2dYiuOU7B/Ws5mDiGtkH7fB9eywdxQPWY7DfxuMqkl51In3OhArsL/9Ch4ASzJsC1jWFif7WNTz6nTm2Q9Vuq54gJEg3lpG2vqEFQ9pQN42ly1t5K0y8D9vZbMhmxr4axtsOlOn6RlGeATnyMTjjNic\ +jUv0xK2N1KGPmqgRY0RqwFGn9de3AGO/M+Eqn5Jtih9ghUunMDc2zKf3/KGcjILorGfJOJVXEQ17DirhrMZq/OhFkPtYMub1Vjgn2RnMZJgZ7EDhsrXLYCA7TKTU4/c3L+xZZIfIJ5EIZBlk3WrYwJ4UKVVHyn+J\ +XdQazcph1OTp5OtlQL8lkJgEpDt3kvDFRxILrPUHDsukvuKZYJOsRCN2ACWuhhfZsu5v2QjDNVnmSmwrhE34FeIVOYc4N3GJUOlSTRCjoDObQlIpfzFmU+T0ac4DwdAupn12rUiU6Z6JvIcIBV/EYQgidQORS/70\ +aX/3Wjzok9E3br0cL6CbMoYKmkzVYWt7Lw55GoqbNwWbw7KPk8NV0be9zeMW4phpp5Lr8OR24DhEvErifZVKPMY2heCK9SgEelP0QZ6aIOY3dY/TVE/+sY9DCE58MjkR/sDXmUIPghiPe8KUvIRIhDQiFMpGjlKQ\ +7AJztyYyA4xR3OQYb4enHPxI/P7A/xS2Mfpz4n+GE8BnYZF3KSUfjG6KezVspuutpV0BLWo1fMIRxc85PQi4V7LlzYnh+YTVgDMU+WjCaYnwkwAmAU9LmKlK7zZshgrwlvCaLe4KYvPNvd/6Njdh1je5Zt1IDoMP\ +NmT7Mz4KRbV8a5+UcnG3D0tmGrRGn6CGtOBaSbqEb6frWaBIVUEouSROxZOSNnuCGCu41QhJiZ5NfIcTu0aoXuxcMHsIZL6f8yijnl2xF0CMXoIIZmAdrr7DhgfTwmdlOe07LK52eIK9fgxPKDgNsjCecBpdjRvv\ +38LS7dU7rHkNBaY3hXTDyqiRWQV/1aWcL79acEwpYp5dMHGnGEe8BqbVlvvs2ewV2yxKdZ5P62KLE8ry5iZ9EymQ4ZazMbsfI62zHnKgPzBaSExgVtawWAiLy4/3qDWQ+vZnnNF6WeEtrCyl/IKAlfoosKoc3UZs\ +Kyfz8+BbbXbavoCAXxx2tgXnL/w7LNJI9/qIAwIU4dLHn2EE8exaVGjqpT02HobNn4yx5CjGgWJ3/LofacFa9hOigX179e552HqIs9h/AtoHR/K14LV2G2HtJtzrCHnsMXzgR7gnKpjqDXzovPMDFVbG5m1XlEJY\ +30kObesPCmb2xffUE1onNlf+hWuwaiCf9u4KxhxEj+nKVWQss/8FUgIkTM88UuMHDl0urVHDgE01Qad1bN6rBJa8BIu6ovhoE90tKPXqP0piPQE6o7/DIYRs2F9fHLi4YEunVfKos4f7Ur2mq6Azj5R5OdnGTELL\ +8FvEXlBqs4C8TaUAHklu+BOEVgro7KwwaGQ8lJxXUiLcKIAR6nXKZaV8MrnXjL4qYbYqUCi1A2FdZkx+dyypJqGM/kFgII0sMfH8M1qoiiU/e8Ro9P8S2M43rAkYa6h1EekfEWRc6Hi72QTJDMsrARHDacLfmlIk\ +W+/7kaCiAaO3ZsCKpcqMvG3VjPK+Gckg0/+RS5RzLlCI6ZQZVbTYAXpYtwJ66kNhELVQk0jPhmgnkfZy4K6ynhH3AvgXBW59+MsCd9tekfdPaeFh8RJ6tcVqMOAg0awWqIP9z23vV3JAWz558wwZ9dnRKcR8evsF\ +bPnF/PwfmDx+8xCTD48eYfLRrT76yk/Gh+DjbVQXsBGEEXLNvkDGjA28lPRdSvpGMKduYCMpHfNJ73tJEJ5rkIYtBWgEJROehVHhdE2zqYgZMWGGRu5e/mGlhlTBaVwnVy09b99QgL9RQFDTX2AbBDFTUUZX1C4X\ +pF+d7ZNhbglS1EI2d6OuYchPwOQqWldq7+dI+CshBlolohImz7k76GPVYQddq8y/mgKAOgZ1Lp1OpxvkAsERYyk6j8Y+0DaE1i2bn25jY9cf59GrtSJvqFFgBO5Wn2FkXURBLdM2okBubKFI0YaO+jVJHha9Ujkj\ +jk0/E6+odj7Lj0Xy6C7ZfLly5bTajluVWOzlEagqKESGQy4QM3/NH6qaN9QX1BrDySvNjWzfXVdHAA/sB0dEdUXjSRwP9Qm3I86lGQEFIL9RATdkuXA7cr7AUhyqkXkkvv56Qw74iJpwqVYMT+nnUH/ews+i6bXo\ +iEgS+0M+35W6U7oraBRQ1WPp2TQ+W3hgT//DPujafahiesDC9ul3ul3SJyR7FxYgzuQveevOmdFNgbkhFzQCK/pNhrfJcofhtPebYHszRiBPE0D5XDuWyq4VklW6xnEa5tmm080GXTfxGmI+n630CgbqP2KHhkrk\ +XIrQGmaqqmTVlVwCL+s71dapz7/x5wAkOB6iNU1QCZrBLWnCzS9oWNp/1vnfZCaZL2gGUZaay/Ywpj1qHXRVP119fJ/oT0CA9gZqLSiTsnAWH1vm9nsyMyS0fOJ/ReDM1GLAU5M/A+f0k9ptz+cXksQL6cYjiNCe\ +6acMxkpg49QkxpkKRKqlPEXaRP6uLcu5sHRyavbtwnQfCMmUAyyitgeYMOnUcyBuWWFs2rU72NnV4L6zzTnFGMmFZapyDbsj4XiROCEimkMGzL+GXyjlVihn/abKwHNAJOKNOnL4Xk8oPtFh7XQK5aYA4PUg+ppc\ +KXk7UBVCwQbor5QWX1n0OEVqWpUDEBfpCr045aL2D9FQAHrAjUNhDhDfACrdZAM+cQZNuQIhnLse1KP7lj2uZo1oExciQ7tNDDWcLioMRi1pXKVasVQLnoYx+k6w0gghg04n0kOm9E2XHBCVPSOngBN4gwYVRsNh\ +pGvlBJoVNkHg8ASaqVucSKVn2ClwLN95YcdKJ9WKBxvfWddEryZyBPooxMp+B3yuiDXbokuM7oCwC7qFzGJUkRuki868eog3I9u9WFYuBFiScunyQ68Z0qn0Tsu6z4HsTGZ6XwdH3Z657InUNZxxxhSFUl1SkueM\ +Y++6TA4lpINW0wdrSbyScXYWj0AqJOHV8kSjqeRZPzJMNIcf9lMJz9VinINrMwvp268kNyonHIu6SSKHVjgEyKDuMnqBBF7aPwRWUFNGQQpsBCCgnzFIhWXEPDVhUTzbtHxcggZOvJYDdN3R+z22OrGWmnhLEOj3\ +YdLrMGpuG7JqnYiZLL4annG4VCUUhMpQiLSU4Qe3EF3GaN8V9RWXKG19pUVTPZKqxcmRKcLk0j1cx2Fp3nBwbutzLrAaYbIafrjB8Zxqu3z8OlJCznPU6L76GEc/IipvpLf1iwTT4oiJdRcIm3hsTBuv/0CrNWQB\ +u2PpZOTkRXK7ZNiRmmQlnbI9Pw3LK/F92DBCsAaCeJ3ZahrwB14sQTK8xiU85VhfVS5XZG2H1B7wAHVJUqlTrfSKa7nTVhdlU/BtD5jKFQKWNsMdcbIq3kGK436v1x7UuZ+yHmGYheTNXnkuwYY471D7p4Xt1XTg\ +9h8kLBlmiyxx+HLWS/xJtGPipK1fgu6Cd6nrg8km/3hCVyN/h+0moyv4u1xT64VOYSTUeSmA8TygmWsVoDoJJul8MWZd6/0ZCUIzrRveOJILP7qCEo+ne5R2yVhecVyhC0cr741QRKfasFGUTTjhgwJYeWHCDL/W\ +tQJfQwAVH2kBaSu1Fr0Pa4oYfBspG6iXmgHW1AxwdqXbKTVVVa3YnDWPFURDZiqRB9KuacVDolFIBq4pfu9Glq3ccXXNF3KbQP9cgBZ9AkF0dzmptNuiANG39GOW3pITOg3ZqbQJ+5OFZhyaPIyoFTbiBf2YZKrg\ +VColdIDWV0pLNmqvV05UXNTSR6bXaQ5XPZFZuohvjPihn+DiwvoTfodFC9o/SFasqqaIKi20XdtrYPFpT5kjflwgRiX20HXEY44v9OUtOWVyHY8j4SYvGf+s97vj+HIWHxJekfh39CrVtgi+u5SpTD/wGAreVrZi\ +US0ISTyPF54qQk4T/gmZ6nlMq3A5b96zl9Heqe7tstgsUbWtO4kxM+oOLF+Eigraos/LoYSxUl6+gNyXV6gsuEG/N6by/9YmBkZTdO4CHG16dWb6tidcVZBZGwa38qVX55BEj1ffSJIiigRzIv13yob5ezbjSt4+\ +U7OWzvgec0J4AEN0S6pYeq1IXTyMM/vrV3rsjcAHu/5UIaLKpk8noUszqvkX52Kkfn5r5996w6q2k3FrekM/UN6uavfltkufpJIAr/SFDc+518nXHyHp60VNEimY9EDu/FtGYBcH99H5vMMa7J+jyrdngwN5w0jv\ +D/6UylRgsraarP4NJfSaap00X+H/4IQOvyfAAnbjNWUgvxDGq+W8CCrV4ASpgUAF13baCZc2hOm9AuFjpqKIJy8Q0FtCFF1KzkpNJjcRemzgrzqRjk2hHikoWLLJgpvHhNU1DflIXNJI3y9fyr2Dn8TgRo+VSvlv\ +5JDXfGuNG0Fs62Hu7adMjrA2RTYnWccpub9K0+Tzpr91Q1xIarSKCuEnLVr92bMHaPVnpzfR6s9ewCLQ7M+OW5Tr2cMHCBnZo/mi6/bvfbNFL/v+/G5RXuCVX2vyPLHWJSbMNOeLi4/d4DBxLgzW5aKkd4Mh1hG5\ +xp4M93cxNksKk1z9D2WAtrU=\ """))) ESP32C6BETAROM.STUB_CODE = eval(zlib.decompress(base64.b64decode(b""" -eNrFWmt700YW/itpEpKWvc3Iug0tiU3tOA6XZftAKTymRRpJWWjrXYKB0F3/9533XCQ5iQ3f9oMTezSaOXPOe95zkf5zuKwvl4d3dsrD+aWx80sbPmUWvuNjXp3NL30evg3ml4WbX+Y0ehAGi0fhT/pD+BOHoTT8\ -r3fDHy93x3T3/LKpnme0xnH4Yx6E9QfLMIrLzfxiflmb8CsaluO9sEG+zzKU0Wx+WUXje7PdcK9JirBxFD5hbp4Pw5/B/HC+wA5Y731YIaH1aJbLVmE0bFAHma0LX5pwxQfhyyabH5Jc/70f5lVhfsn3Nk2Wbbig\ -W49YNXTS8KmqjE7K60H4VHQWtcoLn6A6Fz5+gP/fr0SW/BnOOITwk24fE/7nbsQquHlTd7ySrXmHYU8G3an7bf33MACvHva7vjQsFmdjqCfYxw143WDRYCPn7+vOsHe4qQg3++ZlZlmddsB25uk2Pw2bVNOwth0H\ -FFThzlrVEI9xDdbjXcqYTWTMQ+ybHEPYcV9xltd32J/GwpJZOEad8gQCWcqYwG/nGEs6zouoLh6zCbAl/pfZQauye2SUUZDbWV7CJFNMxXEKwAmyMcyxSV7LOjnpdDeczEXjNdWKavQoHrochb82gKpOeDS3rJ4c\ -mzmsb7+CBwBJhrGAaY17doRJ3dJBOs9+qNrN3QlGgnorGWmqZ2x4aAP6tpksaTvZSgP/81YWGzDUIF9TY9GpOk0PGOEWnCMVjzOCOdtN0RM3ttsd9qhoNxKMtgqnqbCVv74EBPudNy6zCWFT/AAz8mQCuDEw/3Hs\ -Z3KyFLOnPSTjVF5VNOg5qNBZhdn40WOQe5gy4vlWJCfdGVxJcSXag8Fl6TwFQPZ4k0KP31/c2fNOHNo+7jaBLoOuG6UNrElMqTZS+Qusomg0Vw6jkKeTb9YB/RYiMTG2bt1J6IuPJAis9AcOy1t9xVcCJtmIRnAA\ -I16lF1my6i9Zi8CVIJPDDUWNGzmIwgy+TjXCUCR5xGfo0w8AB7YQUBYAcLhUOsJs0Ng3Y7mCUOIO2JXt4DljnOKIP/VPwzJGf479LzgrTIM4cpeY93R4IFqs2S2daBd0AJolnzZMJLW/Ep5wYJ/oIYfkKXO6dz5k\ -fYXl5iTzHIw54GO4bDhmAqJIKaFRwmQ/Ol4kNfuNBvJeXH7/rYRlXx//pqETt49Z8E0HocOUQlQ2YYYooymfgqCb7RyxSWr7bT/6TBWbwxv2g/fnjXArvD6abBJiJ3wBE4XQxuSoOYNQY08FI01g1AuIzJks9pi8\ -FYU9/1iybACr7/Maseb5ijkAqQ2Ch5crgEZe3WHUAVf4X1qm9hyTyz2+wLw4QiBxTHWsicdMlTdG5i7or8cSQMpIGIl0ISXzTTbEWDXoZnua3e1rhVX4vvMejUVX4wWRd97Fia1b2m5L5n9ot8y61EMSCz7qbXFa\ -8esykbAP6VwsYX9TxDXIpIzMooAQTxDWiGrevwVx2NU7XHqNnZMDMWY4QlXzQSvJWqpCJMpWAEbBmYEQ05KVkWtmIMJC8KY4YkGZZHYZnMpFNyvq1cHVlU3yplueGKCYjpjKODk57wVb+kBKJ2pmOTbI50S+9dt7\ -u8Geye52YivMnszwdoIvcDJ8M4nvtFUWw9uwUzGeLwJJNenz5gW0+2LWuiqI1Pl3mKRWe33G5Aor5MmjzwmiCLvCsHW1tszu54kaQRiRxjkl3f3RayYvxi+kS58ytyqiNdO50XkIW/bt29W7H0EEL8BGPwNSpVAM\ -xcZd0OABfPMMZ0Fga1BRVSgSBm+YK2qBaCFmVRWvyRH9lWuWEqotUyYgEISPPnP0HOo59xj9yIvmSaWQyrWU2w753c9bymarPzavSYj0d5hUCYb++uSw8QXfQtSr2ZCdHUnNllxNtbIrnkSJhJV0sEIgwj5NHLJN\ -U/q37GXEJBC5SDKN88BqMoJ/JdkjBlfxJeDSqIdVHCpm5/yH14yXUnnVoTZoIpG7vfKnEds9JxkHH6U0ppE1GX78PMD9up885BzsSxWGMObZDg3gYmeIfGGRAnOcXmk+L0cZrSSnglKSmH/UBd9ZuyP/9w7UCDV1\ -dFeK8M2y0iAh4QfOxheci5OsCXhVi5E2c0UBp5mrtVMehEaRZ1Bz4v9Ns4Se/GnSce37b9/ever1WzImKoLXKfnx7SeA4ZP54jnEn70B6xRnZ/dx8f7tB7j4YL54CL5++bDXdCmzZ6PZ87edAZD24ayB+I/ER4Rv\ -CwTSWJL/iGm1MjzHS6D1EmjpWsGyA+mUQkac6aIwAXcBG94seMI2Nyu8pn35MZhsrQbS/ElzGYyVhecV8LHRLRjDTv7JyWHOek4YN21dtl5TfXV+RIDbkTxYa7EkH2oPDd/6QoBujT3RUlZt2bbIbDKh5SQkbkga\ -wo9ei24+n17HRUlLqg7oiBmljnOWfiNummIrkS9Ey9w9QYlEJynYmqLjRduck44CpIO/kd4ASEuDCX/hfshkO3UU1CM5z+7LsdDesNl6eozMOE+aUaOG6JpJlKIEUZcIx/ibV79mD9Ssm9RcSARwpcYoRm/bU8jk\ -3DmfD4GbxuNuPBROXAwvpBQmtrRsJkyGUrgZNl9iKhVZcr0YrM/Hp0q/oRaQwNfED+mn9ttQRUIphZ18zSoprTJuFney+2xfQGabXejwJRdkLVxBIKjOmlI3+rJ6Y4fpb73Y2Khi16tLKMGttycSLpovBwjVmbbK\ -tL9h+TuRfaJnjLtipj1wIR2NykkJqhEArQ7sRT7gkb/674+g8Nec+nmn9mF7zHh43YjJiRjHZ7c9XDVlK9i2TRekAjhwIQDkopuP1pr/Va7E8+WJV7qhxvisCzTUpmg0qFM3fZbqT8fXyuTotRNxzVUp7xJmyLL3\ -/O8gsJgU4SUUZz9A4g5YT+YXqiThk3bN5CZQWeE3jhKi80TyjkoykuTud9KnJPKl48bSNEICmJzIltJJgl08jGWSiefWARFvLeaq8tO9fWVPlCm1cFIpJXrBxqkp+Yb/NKJsRNLqRFRSoT1cWN1cmmFN3m/cRNi/\ -kv1TdUyMjZVstoAYqqJJPvnOWbCkeis/u7hIV2JjGN3YsdQmDZ7CKF6ofiiqk84sJCaCJ9kRsaaR7nXlEd3zBwjOpzjTKYhsjI78eHtczSvU5Q5czb0XKdMtVdYPVWeMLF8peEd0wbWo/k0uwBityGLrhjqcAi8j\ -6QUZsQ/5trNc8bMEz7ZsBC/xTPEpIR11Uz6YMt97OVDGxV7L3U56DNRfyPb3GEym7NrERUwWuCXsQ23PHWqDo89TUVD1TNgtkgbtMwiaV4iIaXfJts0U5/kqoFqQ3YzvwSqZ3FYnmq3EUWgNWZu6/vd0cNiuKk8D\ -6vyKEtIuDwkuM+rKVzmnuGDdT5h6ys/ttDsEARRNTpi9Fkdkpn3Sp4SxhuFZP87wtUqQF127spQq4ApZU6Zes7LruJPQ6qMWy/AwyXgiXWGBGDXtWnQPV4NYIS08TmqoRN24wVAT9pzVrOpwlP5YqktuRX8BIEfo\ -KblqxQ2+plppmVANeajOxd8L8hppEt4s2Ks/AKVqwaCsJQUtBx9vMZNS3ZKNXnd7+IWUYWb1qRv9BD7cuhMC7kcJEO6M92u0Q7fttsJ80DBI2t8fMaFTjARCYKwyacl6LFWXAJuWFPL5HUlO0ru1mx13s50/lWxH\ -o6n3p0JeVZKzgTjl07sLvruu27uVm2qxrC4hXXbKeZAAuJwL3qU+GomltyKP7cpMisWmTS5OxLOsJPWZdIJr6UBWyuTJhJ+jc8CbyggJLMGEimGcq82IbzbcxV19NvdR6EJKZgQKCMDO8XLai8dxh20Sp6le4p4P\ -LFPVnI637fgzPRX5CZCOhyt4o6Qn+izHGSEirxzecKaUN5pb5uLqoSwfsd9W+ozRSnOGnhMPbp1Rz1y6v1xGIHdv1qLCK2nBad8O7wUQ3xKp1/2UePCxryPpyldEWF/rPVKbEcmVamQqIsStmnzouUlQ91Yz+owz\ -R85RcfaxL71/I05fXgGNNY+6nNUpBVLGo5F+HR+iU8qRB/udyFYecrU9CCLCsP9CsiD6j/jd9uXhb+WaItEw8J+kAdaPurza8xuuOKP32NlUwhzVmd6Xgsh4Mu0wWWf8CHNzXr6GUXs9T6fKpJIUgV6YmN0QyoMD\ -XnTvBPiBH+8gs/U/8VsKWjH+m7TERqpdDxqN+G/adXD4qAVLxLdLCqClkdfxLgJLFMU6dMr4epqMcBi/5GxuQ5R60b17wyccUZ71jgqCXeZ9wmCE4+G9ii6YG+J0Kw0l1tOSgvyP3YNO1R8HEP+YELqQ1Nj8ix4d\ -ctpOCye6cJ52TQw12Cbu8OYpOe/6o09RfuP6gswk9BbyYB0aX5+hiuDe4+GIiutvtgtgzBMJpaGqqnvdkuRtT79qILORBl9N1l6Ogsvfv/rOidQ2pJ5nwmmWkPyeYVzK+0UK65IL7kMhEtA+hugBadZ1+W4Ax0l3\ -ktwcbTv+PVTM/ubsny19DN77xBDiEa4isVZu9XWMD/pYVVGTslNv6ZLJazPNETf/WrxRRMW7WmHBBTcJucMfskl9/BB3O5jkVJ7yN5yMXZzeQ8vwjvQLReScHp3sTqNTeXWEIRRQOufEQZNXbeNY/QyEbJH836zI\ -HcSG6Bmd/lByDmzph2JEhHBK+So5MLWBo2cIBpQHUPGkjzgSKftN760HEYoeZ1R4H0Gfd9MbIEqliEl1Kv12PvnfABjpiDh1x4QTDQofNZRKEXHAyidiq7u9JW6sOyVJHUl5rWWm3mm2ZSg+FFDXXG1zchFvdLlc\ -3kOKJG0jtmskBhVbpRimX+ggufbWXPyQtyrTxwfolqeoZFL0y9NZg355enYCl0/vH6CiTh/gMjrm0cu61zEnKjCHf96h1yt/ebcsLvCSpTVZFlubxyZcqRfLi0/t4GAQ5WGwKpaFvo0JXAWHOpTh/irGprEz8ep/\ -TB3fMw==\ +eNrFWmt7E8cV/ivGNnZC87Qz0t6GBCOBjGzAlKQE11S07M7uuuSiJxg5mDb67533XDQr2ZL51g+ypdndmTPnvOc9l9n/7s+aq9n+/a1qf3Jl7OTKhk+Vh+/4mHdPJ1e+CN/6k6vSTa4KGt0Lg+WL8Cf7IfxJwlAW\ +/jfb4Y+XpxN6enLV1mc5zfEw/DHPw/z9WRjF5XZyMblqTPjVG1SjnbBAscsyVL3jyVXdGz063g7PmrQMC/fCJ9xbFIPwpz/Zn0yxAua7DDOkNB/d5fJ5GA0LNEFm68KXNlzxQfiqzSf7JNcfz8J9dbi/4mfbNs/X\ +XNClh6wa2mn41HVOO+X5IHwmOustlBc+QXUufHwf/x/PRZbiFHscQPjDuI4J/ws3ZBXcvKh7OJeleYVBRwZdKf62/jEMwLOH9a5PDYsl+QjqCfZxfZ43WDTYyPlnujLsHR4qw8O+fZtbVqfts535dlschUXqcZjb\ +jgIK6vBko2pIRrgG6/EqVcImMuYE66YPIeyoqzjL8zusT2Nhyjxso8n4BgJZxpjAb+cYSzrOk6guXrIJsCT+V/neQmWPyCjDILezPIVJx7gV2ykBJ8jGMMciRSPzFKTT7bAz1xstqVZUo1vx0OUw/LUBVE3Ko4Vl\ +9RRYzGF+ewceACQZxgJua93pAW6KUwfpPPuhardwTzAS1FvLSFufsuGhDejb5jKljbJVBv7nrUzWZ6hBvrbBpGN1mg4wwiPYRyYeZwRzNt6iO25tXB32qGk1EoyWCrupsZS/PgUE+5UXrvJDwqb4Ae4o0kPAjYH5\ +/UN/LDvLcPe4g2TsyquK+h0HFTqrcTd+dBjkEW4Z8v1WJCfdGVzJcKW3A4PL1EUGgOzwIqVuvzu5s+dRHFo+iYtAl0HXrdIG5iSmVBup/CVmUTSalc0o5Gnn63VAv4VITIKlF+4k9MVbEgTW+gOb5aXu8JWASTai\ +ERzAiKv0IlPW3SkbEbgWZHK4oahxIwdRmMHXsUYYiiQveA9d+gHgwBYCyhIADpcqR5gNGvt6JFcQStweu7LtnzHGKY74I/9jmMboz5H/F/YK0yCOPCDmPRrsiRYbdksn2gUdgGbJpw0TSeNXwhM27FPd5IA8ZULP\ +TgasrzDdhGSegDH7vA2XD0ZMQBQpJTRKmOxGx4u0Yb/RQN6Jy5ffSlj2zcNfNHTi8RELvm4jtJlKiMqmzBBVb8y7IOjmWwdsksZ+240+Y8Xm4Ib14P1FK9wKr+8drhNiK3wBE4XQxuSoOYNQY0cFQ01g1AuIzJks\ +dpi8FYUd/5ixbACr7/Iaseb5nDkAqQ2Ch5crgEZR32fUAVf4X1mm9gI3Vzt8gXlxiEDimOpYEy+ZKm+MzDHoL8cSQMpIGOnpRErm62yIsbof7/Z0d1zXCqvwc+cdGuutxgsi7yLGiY1L2rgk8z+0W+Ux9ZDEgrd6\ +T5xW/LpKJexDOpdI2F8XcQ0yKSN3UUBIDhHWiGouP4A47PwjLr3HyumeGDNsoW54o7VkLXUpEuVzAKPkzECIacbKKDQzEGEheFsesKBMMtsMTuWimxX1bm91ZpP+FKcnBijHQ6YyTk7OO8GWPpDSiZpZjjXyOZFv\ ++fHOarBnur2Z2EqzI3d4e4gvcDJ8M6mP2qrKwT3YqRxNpoGk2uysfQPtvjleuCqI1PmPuEmt9v4pkyusUKQvbhNEEbbCsE29NM327USNIIxI45yS7u7wPZMX4xfSZT8ytyqiNdO50XkIW/bDh/nH1yCCN2CjfwJS\ +lVAMxcZt0OAefPMp9oLA1qKiqlEk9H9irmgEoqWYVVW8JEfvz1yzVFBtlTEBgSB875atF1DPucfoJ560SGuFVKGl3GbIb99uKZvP/7N+TkKkv8+kSjD0128OC1/wI0S9mg3Z4wOp2dLVVCtf8SRKJKykgzUCEdZp\ +k5Btmsp/YC8jJoHIZZprnAdW0yH8K81fMLjKLwGXRj3M4lAxO+d/f894qZRXHWqDtidyL678ach2L0jG/icpjWlkSYbXtwPcL/vJCedgX6owhDHPdmgBF3uMyBcmKXGP0yvt7XJUvbnkVFBKmvCPpuQnG3fg/xpB\ +jVDT9B5IEb5eVhokJPzA2fiUc3GSNQWvajGyyFxRwGnmau2YB6FR5BnUnPh/0yyhp/gxjVx7+e2HB6tevyFjoiJ4mZJf3nsFGL6aTM8g/vFPYJ3y6dNnuPjs3nNcfD6ZnoCv3550mi5Vfjo8RvbyIdoAmR+2G7j/\ +QNwkE6KSWFpKLAWz1oXE2kxibdL5XlJ6QM/inqbHyRZqEzwLeGB7IEKfbXa20mvyVzwEny1VQppFaUaDsaqUlTCLTe7CJPbw35wiFqztlNGzqM6WK6s75wcEuy3JhrUiS4uBdtLwrSsESNfYJ1rQqkUXjTKbHtJ0\ +EhjXpA7hR6dRN5mMr6OjoilVB7TFnBLICUu/Fj1tuZHOp6Jl7qGgUKKdiLFFx9NFi076CpAOXkd6AywtDab8hbsih5sJpKROyXn+TLaFJofNl5Nk5MdF2g5bNURsKVGiEkSdISjjb1H/nD9Xs65TcylxwFUaqRig\ +i85CLvsueH8I3zSexPFQPnFJPJWCGOYBL+E/bva5tsQmM9yKHTVyHTzbvd+QB51QI6iSiib7nn46/fk1frqm0yaiRZKY3Pt8V5xGKvzaSUlm6dk0Pus8kjn/+IA916KYKO3hEZT9QOlc5y66czvbbmP2tzz1wgvA\ +Tij9WpXwC4uZATckliuZTSTaTZUogd5QtKBX4MBEqeV+ZZVrP04VYSkUcHXinRqKDXPJgFu2ZkrNOSR0+TcAQ5sxQi137cBpeeYrvhCQckHD4iW28L/IlWQyoysQM/+K8p4Yd6hr0WqM5+Z62MCBjjgeKdODMycR\ +0MiT1+D3IMJq5H8FqWUKCfB9k7+C8GORsslfTy4kgDrp8bQKgvQmRFjhPA4egr5UMpJacpX07nfSaSBCpp2jc4RJXPpE1ku5ZgdZeURxkx56JpOWaY6BWxdHO7tKp6heGvp2yWuXqeq1zvcQDFrROKJrTddQGELn\ +pdWVW1k56zZzel7QkHNJYXrqLiOlnnWYhobojqZO7kABAJp6GJ1n2IO52BmGN3YkUR1m7TSAd5HZqpQ9kRJmIwOCdFW62iPgF88h4xGMdwRWG0HRo825fOFRqjsQN7djpHK3EihrGzUKh/NchwuMAyzo8qI76Nkg\ +qvOqjtbmXrNfqF2mJDWko277lJrs0JY99z9jDAW+QdsMo2FL0ksrhGtM+h2ntTNtgCZSQRl2Z+zMs2KrjigL3Yp8jV9gbxSxN42qvExQThTaCd+iDvpid4AMHYEp4PqL44sLofO6068yTB4Xy/aF9kqyr6liEhKc\ +QexSpl0JZGYkYOi68uBgMWcicyJm9cccJ4XBNHUJTjWMdW+ZHAuXMz10cqwkVsmFHcctkP0aiaL0RKMx5FWXMUYauY+7MYSv1YLP3rUrMykfVqJaI7wDVTdJlNCqhE56TukIoGja3ySVoOaGei/gAalXE5Pwf8aM\ +VVP6yE26nngqfPZiMf2vsePaGmkmLk33uZ90Op3iVaTrWnjTCLqr/jl7vurcUVpm73JD3NdoRrb1EE0vV8+5A9nWc61j6gEPNYXssaJSSbqY6yQ0Bq0CuHQ9Zcg0ImTV/3SXaZ3Kq3z4Pq7kp1ItmvnnOPoZ/HzL\ +eoWZieTuKa/XaiNx/WODjxLpZK3WkMF3h9JlyMlp5CTDst80yUpgZfii/1aJn/uaSVedPh6dtRoQ/FE3jDSRg+YFG6vKpdxsF+nYEx6g7kQqjQHL+QHtte64I+PAt53sUw4xQLNNf0ccqoqHXeKkD/TghQ4ODtmI\ +HGLHMrIoj4VYKBos8vIb1PwbvxnAh32fhH8My9RSTvJ23In8SUQwidHWb7HoJc9S10ejdSu9Q9Vi/ejvwGwymMOt5ShUT5MczumcpDOtPA02L1pNQAvhjHQyG7KNaz3lhA5K+VH07z6lrr30n6WEoROcdgkk76Qg\ +qMVieDeBSiFqXjeaRVOm8EnTSDmUN/2v9F6pCANPKl6pflSgaDO8cZFjCbl6vpohsak5xdmVcwcj+6lW4GbNC01lOaiyRp7IOUsrnhHxYAQPBNXdKLKVA7ZF/4PcJaw/lVSL/iNRWJwJ1NLfigrckmOQVPpvXf8r\ +9AD9povOdJ60x936x3qvoTA51PRUqvyq2FQMLYHUXi+OqIKpeYzf2jhe9UNOjS/iiwm+70dbIAl/yq9KaMH6G6mLrdW4aFW0/IgCOm0k3u0ZS8SPSzKhJaDX8RjN5S0DzEO7TK5n5AityVvOcteHpNP4DhBvEo6R\ ++I/0xs62KL5PZcaMo2SkHUOkbYXLWVUzyhlexwNXVSFHCP+S0DoVHpXyxpeXjCCaO9W5iyx2UtRsayjkb1T6Lx/Biv5b1xXkWEislAN+KH35DlUE90D3h1Tef71pdcT07+WtilDONZ1+Tfqho1+1kRltCsGPl97T\ +QhR9tvr6ixRTpJ5T6X1bwvMlg7mSV50U3BWX5/vCK5QQ9OWsNo8Nx5sh8jjupzAHm5TwkBmw8jfXHmpyEC36A8hfgWAdL1tWUmH1LZHf9bRXQZTx6xIb2nbyNk97IOdE+iSVAKjww4RTbkzywUMgeD0VSeIKJj2S\ +lw9azsIujh6hTXmfRWSR/wJDbI97R/I6C8OpSP+QIlU4XHtKVj994WBE8nXa9NB70WP/3Jf8goo0DR+Upw041tN+kUBVvVOECTofpfpND15SObw2nXcxfIxaRH3yGgO9lUI0U3KEajI5A1BL4X/dkx6KU9eUnIMi\ +C9EF9V/1LCGPpz8mX4SUZR+lkN2T8l6JTp8065MVfLLrnrceqWsBv5V9ZgBQGt4QQigmFbcIYEzyRX4y0AZ/Iq0oKpFftq+A11dPQhyosrO9NwhrbwCff+DysxblfPb8yQkun0xmnSY+UYLZ/2aL3vj818dZeYH3\ +Pq3J88TaIjHhSjOdXXxeDPb7vSIM1uWs1BdEAargTPsy3J3F2CxxJpn/D+2ZEsk=\ """))) ESP32H2ROM.STUB_CODE = eval(zlib.decompress(base64.b64decode(b""" -eNrFWmt700YW/itpEpKWvc3Iug0tiU3tOE6AZftAKTymRRpJWWib3QQDobv+7zvvuUhyEhu+7Qcn9mg0c+ac97znIv1nf1FfLfbvbZX78ytj51c2fMosfMfHvD6ZX/k8fBvMrwo3v8ppdC8MFo/Dn/SH8CcOQ2n4\ -X2+HP17ujunu+VVTvchojcPwxzwM6w8WYRSXm/nl/Ko24Vc0LMc7YYN8l2Uoo9n8qorGD2bb4V6TFGHjKHzC3Dwfhj+D+f78HDtgvfdhhYTWo1kuW4bRsEEdZLYufGnCFR+EL5tsvk9y/fc0zKvC/JLvbZosW3NB\ -tx6xauik4VNVGZ2U14PwqegsapUXPkF1Lnz8AP+/X4os+XOccQjhJ90+JvzP3YhVcPum7nApW/MOw54MulP32/rvYQBePex3c2lYLM7GUE+wjxvwusGiwUbOn+rOsHe4qQg3++ZVZlmddsB25uk2Pw6bVNOwth0H\ -FFThzlrVEI9xDdbjXcqYTWTMI+ybHELYcV9xltd32J/GwpJZOEad8gQCWcqYwG/nGEs6zouoLp6wCbAl/pfZXquyB2SUUZDbWV7CJFNMxXEKwAmyMcyxSV7LOjnpdDuczEXjFdWKavQoHrochb82gKpOeDS3rJ4c\ -mzmsb7+CBwBJhrGAaY17foBJ3dJBOs9+qNrN3RFGgnorGWmq52x4aAP6tpksaTvZSgP/81YWGzDUIF9TY9GpOk0PGOEWnCMVjzOCOdtN0RM3ttsd9qhoNxKMtgqnqbCVv7kEBPudNy6zCWFT/AAz8mQCuDEw/3Ho\ -Z3KyFLOnPSTjVF5VNOg5qNBZhdn40WOQB5gy4vlWJCfdGVxJcSXagcFl6TwFQHZ4k0KP31/c2bNOHNo+7jaBLoOuG6UNrElMqTZS+Qusomg01w6jkKeTr9cB/RYiMTG2bt1J6IuPJAis9AcOy1t9xVcCJtmIRnAA\ -I16nF1my6i9Zi8CVIJPDDUWNWzmIwgy+TjXCUCR5zGfo0w8AB7YQUBYAcLhUOsJs0Ng3Y7mCUOL22JXt4AVjnOKIP/bPwjJGf479LzgrTIM4cp+Y93i4J1qs2S2daBd0AJolnzZMJLW/Fp5wYJ/oIYfkKXO6dz5k\ -fYXl5iTzHIw54GO4bDhmAqJIKaFRwmQ/Ol4mNfuNBvJeXH7/rYRlXx/+pqFTfEdi5Lqz0HlK4SqbMEmU0ZQPQujNtg7YKrX9th+ApgrP4e1bggPyRhgWvh9N1smxFb6Aj0KAY4rUzEEIsqeIkaYx6gtE6UwZO0zh\ -isWelyxYPEDW99mNuPNsyUyABAchxMsVACSv7jH2gC78Ly0TfI7J5Q5fYHYcIZw4JjxWxhMmzFvjcxf6VyMKgGUkmESdVpnS15kRY9Wgm+1pdrevFW7h+856ZBZdjxpE4XkXLTZuabstOQpAu2XWJSCSXvBR74rr\ -ineXiQR/SOdiCf7r4q5BPmVkFuNsguBGhPP+AvRhl+9w6Q12TvbEmOEIVc0HrSR3qQqRKFsCGAXnB0JPC1ZGrvmBCAvBm+KABWWq2WZwKiOtg/b+9aVN8rZbn4igmI6Y0ThHOevFXPpATCd6ZkHWCOhEwNXbe7vB\ -oMn2Jn57vSuXvZ3gC1wM30ziO12VxfAurFSM5+eBqJr0RfMSun05ax0VZOr8O0xSm705YYKFDfLk8WaWLVp8XWPZulpZZvvzyyAaIto4p8S7O3rD7MXohXTpM+bXlsYk27nVdQhZ9uJi+e5H0MBLcNHPAFQpBEPx\ -cRskuAfPPMFZENwaVFUV5Bm8ZaaoBaCF2FRVvCJH9FeuW0qotkyZfkAPPvrM0cFhyZnH6EdeNE8qxVOu5dxmwG/GC+hi+cf6BQmL/h7zKQHQ35wcdr3kW4h1NR2yswMp2pLruVZ2zYcok7CSD1ZjLITUIQ7ppin9\ -BfsXkQj0UiSZBnoANRnBs5LsMSOr+BJkeYl5WMWhZHbOf3jDYCmVUh2KgyYSudsrfxqx0XOScfBRamMaWZHhx8+nIn7VSR5xEvalCkME8xK0c4S2GYJeWKTAHKdXms/LUUZLSaqglCTmH3XBd9buwP+9QzSiTB3d\ -lyp8vaw0SEj4gdPxc07GSdYEjKrVSJu6ooLT1NXaKQ9Co0gxqDvx/yXY4XzxLOk49v23F/eve/tmRVMNvMrGT+4+BQifzs9fQPjZWxBOcXJyioundx/i4sP5+SNQ9atHvZ5LmT0fzV5cdOpHyoeTBs4/EA8Rqi0Q\ -QWPJ/SNm1MrwHC8R1kuEpWsFiw+cU/oYcaKLugS0BWR4c84TNmUZhdd8Lz8Eia2UQJo4aRKDsbLwvAI+NroDU9jJPzkrzFnVCaOmLctWS6qvzg4IbluSA2spluRDbaHhW18I5EzGHmklq+ZsO2Q2mdByEg3XJsKN\ -7zp08/n0JjRKWlJ1QEfMKGecs/SboNMUG2jclKJnbp+gRqKzFGxP0fJ5252TlgLkg7+R3ICkpcGEv3BDZLJZrIKaJGfZqRwM/Q2brWbGSIrzpBk1aoqum0T5SRB1gViMv3n1a/ZQDbvuuIVEAFdqjGL8tk2FTM6d\ -8/kQtWk87sZD2cTV8LnUwsSWlg2FyVAKd8PmC0ylEkuuF4PV+fhU6TfUAxIAm/gR/dSGG8pIKKWwk69ZJaVVxs3iTnaf7QrMbLMNHb7iWqwFLCgEhVlT6kZfVmpsMf2t1hlrVex6JQkxV705W3HRfDFAqM60V6YN\ -DsvfiewTPWPc1THtgQtpaVROqk+NAOh1YC9yAY/k1X9/AIW/4bzPO7UP22PGw6tGTI7EOD6769ECT9kKtu3TBakADlwIALns5qO35n+VK/F8ceSVcKgzPusCDfUpGg3q1E6fpfrT8bUyOXjjRFxzXcr7hBmy7AP/\ -OygsJkV4CcXZD5C4A9bT+aUqSRilXTO5DVRWGI7jhOg8kbyjkowkuf+dNCqJfum4sXSNkAAmR7KltJJgFw9jmWTiuWtA1FuLuar8eGdX+XNnm+MHVYxSnRdsnJoyb/hPI8pGOK2ORCUV+sOF1c2lG9bk/c5NhP0r\ -2T9Vx8TYWMlmA4ihKprkk++cBUuqt/LDi8t0KTaG0Y0dS2HS4DGM4oWKh6I66sxCYiJ8kh0RbRppX1ce8T1/iPB8jDMdg8jGaMmPN0fWvEJJ7sDV3HaRCt1SUf1IdcbI8pWCd0QXXIvq3+QCjNGKLLZuqMUp8DKS\ -YJAR+5BvW8sVP0zwbMtG8BLPFJ8S1FE05YMp872XA2Xccm2520l7gVoL2e4OgwlRTvvERUwWuCPsQ33PLeqDo8VTUVj1TNgtkgbtQwiaV4iIaXfJtn0U5/kqoFqQ3YzvwSqZ3FUnmi3FUWgNWZva/g90cNiuKo8D\ -6vyaEtIuEwkuM+pqVzmnuGDdT5l6ys/ttDsEARRdTpi9Fkdkpn3ap4SxhuFZP87wtUqQF924spAq4BpZU6Zes7LruJPQ6rMWy/AwyXgibWGBGPXruhR7OYgV0sLjpIZK1E3VG3Vhz1jNqg5H6Y+luuRO9BcAcoR2\ -kquWXEs31VLLhGrIQ3Uu/l6Q10h/8HbBXv8BKFXnDMpaktBy8PEOMynVLdnoTbeHP5cyzCw/daOfwIcbd0LA/SgBwp3wfo025zbdVpgPGgZJ+7sjJnSKkUAIjFUmLVmPpeoSYNOSQj6/I8lJerd2s+NutvPHku1o\ -NPX+WMirSnI2EKd8enfBd9d1e7dyUy2W1SWkzU45DxIAl3PBu9BnI7E0VuS5XZlJsdi0ycWReJaVtD6TJnAtzcdKmTyZ8IN0DnhTGSGBJZhQMYxztRnx7Ya7vK8P5z4KXUjJjEABAdg5Xk178TjusE3iNNUr3POB\ -Zaqa4/GmHX+mxyI/AdLxcAlvlPREH+Y4I0TklcMbzpTyRnPLXFw9lOUj9ttKHzJaac7Qg+LBnRNql0vjl8sI5O7NSlR4Lf03bdrhxQDiWyL1up8SDz72dSQN+YoI62u9R6ozIrlSjUxFhLhVkw89Nwnq3mpGH3Lm\ -yDkqzj52pe1vxOnLa6Cx5nGXszqlQMp4NNKv4kN0SjnyYLcT2bquz0Q9CCLCsP+5ZEH0H/G7bcnD38oVRW7hnk/SAOtHXV7txS1XnNF77GwqYY4qTe9LQWQ8mXaYrDN+hrk+L1/BqL2Zp1NlUkmKQG9MzG4J5cEB\ -L7uXAvzAj7eQ2fqf+DUFrRj/TVpiI9WuB41G/DftOjh81IIl4tslBdDSyOt4F4ElimIdOmV8M01GOIxfcTa3Jkq97F6+4ROOKM96RwXBNvM+YTDC8fBiRRfMDXG6lad4rKcFBfkfuyedqj8OIP4JIfRcUmPzL3p2\ -yGk7LZzownnatTHUYOu4w5tn5Lyrzz5F+Y3rCzKT0FvIk3VofHWGKoJ7j/sjKq6/2SyAMU8llIaqqu71S5KLnn7VQGYtDb6erLwdBZc/vf7SidQ2pJ7nwmmWkPyeYVzKC0YK65IL7n0hEtA+hujZaNa1+m4Bx1F3\ -ktwcbDr+A1TM/vbsny19CN77xBDiEa4isVZu9X2MD/pEVVGTslNv6JPJezPNAbf/WrxRRMXLWmHBc24Tcoc/ZJP67CHudjDJsTzmbzgZuzx+gKbhPekYisg5PTfZnkbH8u4IQyigdM6Jgyav2sax+hkI2SL5v12R\ -W4gN0XM6/b7kHNjSD8WICOGU8lVyYGoDR88RDCgPoOJJH3EkUvab3msPIhQ9zqjwQoI+6qZXQJRKEZPqVPrtfPK/ATDSEXHqjgknGhQ+aiiVIuKAlU/EVnd7S9xYdUqSOpLyWstMvdNsylB8KKBuuNr65CJe63K5\ -vIgUSdpGbNdIDCo2SjFMv9BBcu2tufgRb1WmT/bQL09RyaTomKezBh3z9OQILp+e7qGiTh/iMnrm0au61zMnKjD7f96i9yt/ebcoLvGWpTVZFlubxyZcqc8Xl5/awcEgysNgVSwKfR0TuAoOtS/D/VWMTWNn4uX/\ -AE/V398=\ +eNrFWmtbG8cV/isYMCRunnZG2ts4MUi2QFyM66SOKa7cend2lzoXnoBFjNvov3fec9GsAMn+1g8CaXZ35sw573nPZfa/29PmZrr9eK3antwYO7mx4VPl4Ts+5t3R5MYX4Vt/clO6yU1Bo1thsHwR/mQ/hD9JGMrC\ +/2Y9/PHydEJPT27a+iynOXbDH/M8zN+fhlFcbidXk5vGhF+9QTXaCAsUmyxD1Tuc3NS90dPD9fCsScuwcC98wr1FMQh/+pPtyQVWwHzXYYaU5qO7XD4Lo2GBJshsXfjShis+CF+1+WSb5PrjONxXh/srfrZt83zJ\ +BV16yKqhnYZPXee0U54Pwmeis95ceeETVOfCx/fx/9lMZClOsccBhN+L65jwv3BDVsH9i7rdmSzNKww6MuhK8bf1z2AAnj2sd3dqWCzJR1BPsI/r87zBosFGzh/ryrB3eKgMD/v2bW5ZnbbPdubbbXEQFqnHYW47\ +Ciiow5ONqiEZ4Rqsx6tUCZvImBOsm+5C2FFXcZbnd1ifxsKUedhGk/ENBLKMMYHfzjGWdJwnUV28ZBNgSfyv8q25yp6SUYZBbmd5CpOOcSu2UwJOkI1hjkWKRuYpSKfrYWeuN1pQrahGt+Khy2H4awOompRHC8vq\ +KbCYw/z2ATwASDKMBdzWutMd3BSnDtJ59kPVbuH2MRLUW8tIW5+y4aEN6NvmMqWNslUG/uetTNZnqEG+tsGkY3WaDjDCI9hHJh5nBHM23qI7bm1cHfaoaTUSjJYKu6mxlL87BQT7lReu8j3CpvgB7ijSPcCNgfn9\ +rj+UnWW4e9xBMnblVUX9joMKndW4Gz86DPIUtwz5fiuSk+4MrmS40tuAwWXqIgNANniRUrffndzZ8ygOLZ/ERaDLoOtWaQNzElOqjVT+ErMoGs2tzSjkaefLdUC/hUhMgqXn7iT0xVsSBNb6A5vlpR7wlYBJNqIR\ +HMCIt+lFpqy7UzYicC3I5HBDUeNeDqIwg69jjTAUSV7wHrr0A8CBLQSUJQAcLlWOMBs09vVIriCUuC12Zds/Y4xTHPEH/scwjdGfI/8v7BWmQRx5Qsx7MNgSLTbslk60CzoAzZJPGyaSxt8KT9iwT3WTA/KUCT07\ +GbC+wnQTknkCxuzzNlw+GDEBUaSU0Chhshsdr9KG/UYDeScuX38rYdk3u79o6BTfkRi5bC+0n0q4yqZMElVvzBsh9OZrO2yVxn7bDUBjhefg/iXBAUUrDAvf7+0tk2MtfAEfhQDHFKmZgxBkRxFDTWPUF4jSmTI2\ +mMIVix0vmbJ4gKzvshtx5/mMmQAJDkKIlysASFE/ZuwBXfhfWSb4AjdXG3yB2XGIcOKY8FgZL5kw743PMfQvRhQAy0gw6UWtMqUvMyPG6n6829PdcV0r3MLPnXfIrHc7ahCFFzFarFzSxiU5CkC7VR4TEEkveKuP\ +xHXFu6tUgj+kc4kE/2Vx1yCfMnIX42wPwY0I5/oS9GFnH3DpPVZOt8SYYQt1wxutJXepS5EonwEYJecHQk9TVkah+YEIC8HbcocFZapZZ3AqIy2D9vbtqU36U5yfiKAcD5nROEc578Rc+kBMJ3pmQZYI6ETAxcc7\ +q8Gg6foqfnu3KZe93cMXuBi+mdRHXVXl4BGsVI4mF4Go2uysfQPdvjmcOyrI1PkPuElt9v6ICRY2KNIXq1m2nOPrFss29cI065+fBtEQ0cY5Jd7N4XtmL0YvpMt+ZH6d05hkO/e6DiHLXl7OPrwGDbwBF/0TgKqE\ +YCg+roMEt+CZR9gLgluLqqqGPP2fmCkaAWgpNlUVL8jR+zPXLRVUW2VMP6AH3/vM1sFh6bnH6EeetEhrxVOh5dxqwK/GC+hi9p/lExIW/WPmUwKgv3tzWPWKHyHW1XTIHu5I0ZbezrXyWz5EmYSVfLAeYSKkDklI\ +N03lL9m/iESglzLNNdADqOkQnpXmLxhZ5Zcgy0vMwywOJbNz/vf3DJZKKdWhOGh7Ivf8yp+GbPSCZOx/lNqYRhZkeP35VMQvOskJJ2FfqjBEMC9Bu0BoO0TQC5OUuMfplfbzclS9mSRVUEqa8I+m5Ccbt+P/GhGN\ +KNP0nkgVvlxWGiQk/MDp+AUn4yRrCkbVamSeuqKC09TV2jEPQqNIMag78f8l2MFk+mMaOfb628snt719taKpBl5k45ePXgGEryYXZxD+8CcQTnl0dIyLx4+e4+LzycUJqPrtSafnUuWnw0PQxGW0ALI+bDbQ/o44\ +SSYcJUG0lCAKUq0LCbKZBNmk872kvICexT1Nj7MslCZ4FuDADsGBPluda5Res75iF1S2UAhp+qSpDMaqUlbCLDZ5CIPYvX9zbliwwlPGzrw4WyysHpzvEOjWJBPWgiwtBtpIw7euEMicjN3XelaNOu+T2XSPppOY\ +uDQdbn3s000m47sAqWhK1QFtMafMccLSrwJQW64gc1OJnrmJgkqJ9iLmFi1fzHt00liAfPA6khvAtDSY8hdui+ytFqukVsl5fiwbQ5fD5ov5MVLjIm2HrZoi9pQoSwmiThGR8beof86fq2GXbbeUOOAqjVQM0Xlr\ +IZd9F7w/xG4aT+J4KJ64Jr6QihgGAi/hP272ufbEJlPcih01ch08273fkA+dUCeokmIm+55+Ov35NX66ptMnokWSmNf7fFPcRkr82kk1ZunZND7rPDI5/2yHfdeijijt3gGU/UTpXOcuunM7265j9rc89dwPwE+o\ ++lqV8AvrmAF3JBaLmFWVazdPImZsVodrBy5KLTcsq1wbcqoIS6GACxPv1FBsmGsG3KI1U+rOIZvLvwEY2owRarltB1bLM1/xhYCUKxoWL7GF/0WuJJMpXYGY+VeU98S4Q22LVmM8d9fDBnZ0xPFIme6cOYmARp68\ +A78nEVYj/ytoLVNIgPGb/BWEH4uUTf56ciUB1EmTp1UQpPchwgrrcfgQ9KWSkdSSq6QPv5M+A1Ey7RytI0zi0n1ZL+VyHVzlEcVNuueZTFomOgZuXRxsbCqhbqxzTDHmmtcuU9VrnW8hHLSicYTYmq6hJoTOS6sr\ +t7Jy1u3m9LygIefGnumpu4yUepZhGhqiO5o6eQAFAGjqYXSgYXdmYmcY3tiRxHWYtdMB3kRmq1L2REqYjQwI0lXpao+QXzyHjAcw3gFYbQRFj1YXDIVHle5A3NyJkaLdSqisbdQoHM5zCS4wDrCgy/P2oGeDqM6r\ +Olqbm81+rnaZktSQjrr9U+qyQ1v23P+MMdT2Bn0zjIYtSTOtEK4x6Xec1k61A5pI+WTYnbEzz4qtOqLMdSvyNX6OvVHE3kVU5XWCcqLQVvgatdDnuwNkKNwq4Prz84srofO606oyTB5Xi/aF9kqyLwKzpiHBGcQu\ +ZdqVQGZGCoa2Kw8O5nMmMidiVn/McVIYTJOX4FTDWPSWyaFwOdNDJ8tKYolc2HHcAtmvkShKTzQaQ151GWOkkfuwG0P4Wi347N25MpXy4VZUa4R3oOomiRJaldBJuykdARRN+5ukEtTZUO+1hnvGi4nJlJ4AHVH2\ +yM25nrgpHPZqPvevsdnaGmkiLsz1qZ90OpziUqToWkjTCLSr/jm7vSrcUU5mH3I73NdoQrb1EM0uV8+40m/rmRYx9YCHmkI2WFGdJN3LZRIagyYB/Lm+YLw0ImTV//iQOZ1qq3z4Pq7kL6RUNLNPcfQTyPkz6xVm\ +KpK7I16v1Qbi8scGHyTMyVqtIWtvDqXFkJPHyDmGZadpkltRlbGLtlslTu5rZlz1+Hhw1mo08AfdGNJEApoVbKwql1qznedi+zxArYlUugKWkwPaa93xRcaBbzuppxxhgGOb/oZ4UxWPusRDn+ixCx0b7LEROb6O\ +ZWReGwurUCiYJ+X3qPk3fi+Aj/o+Cvl0XMT23447YT+JCCYx2votFr3mWer6YLRspXcoWqwf/R2YTQYz+LQchOpZksMpnZNcppWnQeVFq9lnIYSRTqZDtnGtZ5zQQSk/iv7DI+rWS99Z6hc6v2kXQPJOqoFaLIY3\ +E6gOoqZ1oyk0pQkfNYeUI3nT/0rvlYIwkKTilcpHBYo2wRsXCZaQq6erGbKamvObTTlvMLKf6hbcrHmheSxHVNbIvpyvtOIZEQ9G8EBQ3YwiWxcbXNT8IHcJ619InkX/kSXMzwJqaW5FBa7J8Ucqzbeu/xV6fH7f\ +RWc6T9rDbvFjvdc4mOxpbipFflWsqoQWQGrvVkZUvtQ8xu9sHN72Q86Lr+JrCb7vR2sgCX/KL0potfobqYut1bhoVfT7iAI6PSTe7RlLxI9LJqH1n9fxGMrlHQPMQ7tM7qbjiKvJW05xl4ek0/gGEG8SjpH4D/S+\ +zroovk81xpQzqEg7hkjbCpezqqaUMLyOx62qQo4Q/iWh9UJ4VGobX14zgmjuVOcusthIUbMtoZC/Ud2/eAAr+m9dV5BDIbFSjveh9MU7VBHcAN0eUm3/9arVEdO/l3cqQi3XdNo16WVHv2ojM1oVgp8tvKWFKHp8\ +++UXqaRIPafS+LaE52sGcyUvOim4K67Nt4VXKCHoyxltHluO90PkWdxPYXZWKWGXGbDy9xceanIQLZoDSF6BYB0vW1ZSYfUdkd/1lFdBlPHLEiu6dvIuT7sjJ0T6JOX/KO/DhBfcl+RTh0Dweh6SxBVMeiCvHrSc\ +hV0dPEWX8jGLyCL/BYZYH/cO5GUWhlOR/iEVqnC4NpSsfvrCwYjky7Tpofeix/65LfkFVWgaPihPG3Csp/0igap6pwgTdC5KxZueuqRyaG06b2L4GLWI+uQlBnonhWim5AjVZHIAoJbC/7onDRSnrik5B0UWogtq\ +v+pBQh6Pfkw+DymLPkohuye1vRKdPmmWJyv4ZHc9bzlSlwJ+LfvEAKA0vCGEUEwqPiOAMckX+clAW/yJ9KGoPn7ZvgJeX+2HOFBlZ1tvENbeAD7/wOXjFrV89nz/BJdPJtNOD58owWx/s0bve/7rw7S8wluf1uR5\ +Ym2RmHCluZhefZoP9vu9IgzW5bTU10MBquBM2zLcncXYLHEmmf0PTRUSUg==\ """))) diff --git a/tools/gen_esp32part.py b/tools/gen_esp32part.py index 36efbfb0e35..f1423a310e9 100755 --- a/tools/gen_esp32part.py +++ b/tools/gen_esp32part.py @@ -73,6 +73,7 @@ def get_ptype_as_int(ptype): 'coredump': 0x03, 'nvs_keys': 0x04, 'efuse': 0x05, + 'undefined': 0x06, 'esphttpd': 0x80, 'fat': 0x81, 'spiffs': 0x82, @@ -91,6 +92,19 @@ def get_subtype_as_int(ptype, subtype): return subtype +ALIGNMENT = { + APP_TYPE: 0x10000, + DATA_TYPE: 0x4, +} + + +STRICT_DATA_ALIGNMENT = 0x1000 + + +def get_alignment_for_type(ptype): + return ALIGNMENT.get(ptype, ALIGNMENT[DATA_TYPE]) + + quiet = False md5sum = True secure = False @@ -143,8 +157,8 @@ def expand_vars(f): continue try: res.append(PartitionDefinition.from_csv(line, line_no + 1)) - except InputError as e: - raise InputError('Error at line %d: %s' % (line_no + 1, e)) + except InputError as err: + raise InputError('Error at line %d: %s' % (line_no + 1, err)) except Exception: critical('Unexpected error parsing CSV line %d: %s' % (line_no + 1, line)) raise @@ -160,7 +174,7 @@ def expand_vars(f): raise InputError('CSV Error: Partitions overlap. Partition at line %d sets offset 0x%x. Previous partition ends 0x%x' % (e.line_no, e.offset, last_end)) if e.offset is None: - pad_to = 0x10000 if e.type == APP_TYPE else 4 + pad_to = get_alignment_for_type(e.type) if last_end % pad_to != 0: last_end += pad_to - (last_end % pad_to) e.offset = last_end @@ -210,10 +224,10 @@ def verify(self): # print sorted duplicate partitions by name if len(duplicates) != 0: - print('A list of partitions that have the same name:') + critical('A list of partitions that have the same name:') for p in sorted(self, key=lambda x:x.name): if len(duplicates.intersection([p.name])) != 0: - print('%s' % (p.to_csv())) + critical('%s' % (p.to_csv())) raise InputError('Partition names must be unique') # check for overlaps @@ -225,6 +239,18 @@ def verify(self): raise InputError('Partition at 0x%x overlaps 0x%x-0x%x' % (p.offset, last.offset, last.offset + last.size - 1)) last = p + # check that otadata should be unique + otadata_duplicates = [p for p in self if p.type == TYPES['data'] and p.subtype == SUBTYPES[DATA_TYPE]['ota']] + if len(otadata_duplicates) > 1: + for p in otadata_duplicates: + critical('%s' % (p.to_csv())) + raise InputError('Found multiple otadata partitions. Only one partition can be defined with type="data"(1) and subtype="ota"(0).') + + if len(otadata_duplicates) == 1 and otadata_duplicates[0].size != 0x2000: + p = otadata_duplicates[0] + critical('%s' % (p.to_csv())) + raise InputError('otadata partition must have size = 0x2000') + def flash_size(self): """ Return the size that partitions will occupy in flash (ie the offset the last partition ends at) @@ -274,11 +300,6 @@ def to_csv(self, simple_formatting=False): class PartitionDefinition(object): MAGIC_BYTES = b'\xAA\x50' - ALIGNMENT = { - APP_TYPE: 0x10000, - DATA_TYPE: 0x04, - } - # dictionary maps flag name (as used in CSV flags list, property name) # to bit set in flags words in binary format FLAGS = { @@ -358,7 +379,9 @@ def parse_type(self, strval): def parse_subtype(self, strval): if strval == '': - return 0 # default + if self.type == TYPES['app']: + raise InputError('App partition cannot have an empty subtype') + return SUBTYPES[DATA_TYPE]['undefined'] return parse_int(strval, SUBTYPES.get(self.type, {})) def parse_address(self, strval): @@ -373,10 +396,15 @@ def verify(self): raise ValidationError(self, 'Subtype field is not set') if self.offset is None: raise ValidationError(self, 'Offset field is not set') - align = self.ALIGNMENT.get(self.type, 4) + align = get_alignment_for_type(self.type) if self.offset % align: raise ValidationError(self, 'Offset 0x%x is not aligned to 0x%x' % (self.offset, align)) - if self.size % align and secure: + # The alignment requirement for non-app partition is 4 bytes, but it should be 4 kB. + # Print a warning for now, make it an error in IDF 5.0 (IDF-3742). + if self.type != APP_TYPE and self.offset % STRICT_DATA_ALIGNMENT: + critical('WARNING: Partition %s not aligned to 0x%x.' + 'This is deprecated and will be considered an error in the future release.' % (self.name, STRICT_DATA_ALIGNMENT)) + if self.size % align and secure and self.type == APP_TYPE: raise ValidationError(self, 'Size 0x%x is not aligned to 0x%x' % (self.size, align)) if self.size is None: raise ValidationError(self, 'Size field is not set') diff --git a/tools/platformio-build-esp32.py b/tools/platformio-build-esp32.py index 05ba58ff981..083169f60d9 100644 --- a/tools/platformio-build-esp32.py +++ b/tools/platformio-build-esp32.py @@ -92,13 +92,14 @@ "-T", "esp32.rom.newlib-data.ld", "-T", "esp32.rom.syscalls.ld", "-T", "esp32.peripherals.ld", + "-u", "ld_include_hli_vectors_bt", "-u", "_Z5setupv", "-u", "_Z4loopv", "-u", "esp_app_desc", "-u", "pthread_include_pthread_impl", "-u", "pthread_include_pthread_cond_impl", "-u", "pthread_include_pthread_local_storage_impl", - "-u", "ld_include_panic_highint_hdl", + "-u", "ld_include_highint_hdl", "-u", "start_app", "-u", "start_app_other_cores", "-u", "__ubsan_include", @@ -108,6 +109,7 @@ "-u", "newlib_include_heap_impl", "-u", "newlib_include_syscalls_impl", "-u", "newlib_include_pthread_impl", + "-u", "newlib_include_assert_impl", "-u", "__cxa_guard_dummy", '-Wl,-Map="%s"' % join("$BUILD_DIR", basename(env.subst("${PROJECT_DIR}.map"))) ], @@ -116,7 +118,9 @@ join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "config"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "newlib", "platform_include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "freertos", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "freertos", "include", "esp_additions", "freertos"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "freertos", "port", "xtensa", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "freertos", "include", "esp_additions"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp_hw_support", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp_hw_support", "include", "soc"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp_hw_support", "include", "soc", "esp32"), @@ -135,8 +139,8 @@ join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "hal", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "hal", "platform_port", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp_rom", "include"), - join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp_rom", "esp32"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp_rom", "include", "esp32"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp_rom", "esp32"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp_common", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp_system", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp_system", "port", "soc"), @@ -158,9 +162,9 @@ join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "tcpip_adapter", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp_phy", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp_phy", "esp32", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp_ipc", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "app_trace", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp_timer", "include"), - join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp_ipc", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "mbedtls", "port", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "mbedtls", "mbedtls", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "mbedtls", "esp_crt_bundle", "include"), @@ -176,7 +180,7 @@ join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "espcoredump", "include", "port", "xtensa"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "wpa_supplicant", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "wpa_supplicant", "port", "include"), - join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "wpa_supplicant", "include", "esp_supplicant"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "wpa_supplicant", "esp_supplicant", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "ieee802154", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "asio", "asio", "asio", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "asio", "port", "include"), @@ -191,9 +195,7 @@ join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "unity", "unity", "src"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "cmock", "CMock", "src"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "coap", "port", "include"), - join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "coap", "port", "include", "coap"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "coap", "libcoap", "include"), - join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "coap", "libcoap", "include", "coap2"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "console"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "nghttp", "port", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "nghttp", "nghttp2", "lib", "includes"), @@ -268,12 +270,15 @@ join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp-dsp", "modules", "dct", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp-dsp", "modules", "conv", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp-dsp", "modules", "common", "include"), - join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp-face", "face_detection", "include"), - join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp-face", "face_recognition", "include"), - join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp-face", "object_detection", "include"), - join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp-face", "image_util", "include"), - join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp-face", "pose_estimation", "include"), - join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp-face", "lib", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp-face", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp-face", "include", "tool"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp-face", "include", "typedef"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp-face", "include", "image"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp-face", "include", "math"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp-face", "include", "nn"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp-face", "include", "layer"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp-face", "include", "detect"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp-face", "include", "model_zoo"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp32-camera", "driver", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp32-camera", "conversions", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "fb_gfx", "include"), @@ -286,7 +291,7 @@ ], LIBS=[ - "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lasio", "-lbt", "-lcbor", "-lunity", "-lcmock", "-lcoap", "-lconsole", "-lnghttp", "-lesp-tls", "-lesp_adc_cal", "-lesp_hid", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lesp_lcd", "-lprotobuf-c", "-lprotocomm", "-lmdns", "-lesp_local_ctrl", "-lsdmmc", "-lesp_serial_slave_link", "-lesp_websocket_client", "-lexpat", "-lwear_levelling", "-lfatfs", "-lfreemodbus", "-ljsmn", "-ljson", "-llibsodium", "-lmqtt", "-lopenssl", "-lperfmon", "-lspiffs", "-lulp", "-lwifi_provisioning", "-lbutton", "-ljson_parser", "-ljson_generator", "-lesp_schedule", "-lesp_rainmaker", "-lqrcode", "-lws2812_led", "-lesp-dsp", "-lesp-face", "-lesp32-camera", "-lesp_littlefs", "-lfb_gfx", "-lasio", "-lcbor", "-lcmock", "-lunity", "-lcoap", "-lesp_hid", "-lesp_lcd", "-lesp_local_ctrl", "-lesp_websocket_client", "-lexpat", "-lfreemodbus", "-ljsmn", "-llibsodium", "-lperfmon", "-lesp_adc_cal", "-lfatfs", "-lwear_levelling", "-lopenssl", "-lspiffs", "-lesp_rainmaker", "-lmqtt", "-lwifi_provisioning", "-lprotocomm", "-lbt", "-lbtdm_app", "-lprotobuf-c", "-lmdns", "-lconsole", "-ljson", "-ljson_parser", "-ljson_generator", "-lesp_schedule", "-lqrcode", "-lpe", "-lfd", "-lfr", "-ldetection_cat_face", "-ldetection", "-ldl", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lphy", "-lesp_phy", "-lphy", "-lesp_phy", "-lphy", "-lrtc", "-lxt_hal", "-lm", "-lnewlib", "-lstdc++", "-lpthread", "-lgcc", "-lcxx", "-lapp_trace", "-lgcov", "-lapp_trace", "-lgcov", "-lc" + "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lasio", "-lbt", "-lcbor", "-lunity", "-lcmock", "-lcoap", "-lconsole", "-lnghttp", "-lesp-tls", "-lesp_adc_cal", "-lesp_hid", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lesp_lcd", "-lprotobuf-c", "-lprotocomm", "-lmdns", "-lesp_local_ctrl", "-lsdmmc", "-lesp_serial_slave_link", "-lesp_websocket_client", "-lexpat", "-lwear_levelling", "-lfatfs", "-lfreemodbus", "-ljsmn", "-ljson", "-llibsodium", "-lmqtt", "-lopenssl", "-lperfmon", "-lspiffs", "-lulp", "-lwifi_provisioning", "-lbutton", "-ljson_parser", "-ljson_generator", "-lesp_schedule", "-lesp_rainmaker", "-lqrcode", "-lws2812_led", "-lesp-dsp", "-lesp32-camera", "-lesp_littlefs", "-lfb_gfx", "-lasio", "-lcbor", "-lcmock", "-lunity", "-lcoap", "-lesp_lcd", "-lesp_local_ctrl", "-lesp_websocket_client", "-lexpat", "-lfreemodbus", "-ljsmn", "-llibsodium", "-lperfmon", "-lesp_adc_cal", "-lesp_hid", "-lfatfs", "-lwear_levelling", "-lopenssl", "-lspiffs", "-lesp_rainmaker", "-lmqtt", "-lwifi_provisioning", "-lprotocomm", "-lbt", "-lbtdm_app", "-lprotobuf-c", "-lmdns", "-lconsole", "-ljson", "-ljson_parser", "-ljson_generator", "-lesp_schedule", "-lqrcode", "-lcat_face_detect", "-lhuman_face_detect", "-ldl", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lphy", "-lrtc", "-lesp_phy", "-lphy", "-lrtc", "-lesp_phy", "-lphy", "-lrtc", "-lxt_hal", "-lm", "-lnewlib", "-lstdc++", "-lpthread", "-lgcc", "-lcxx", "-lapp_trace", "-lgcov", "-lapp_trace", "-lgcov", "-lc" ], CPPDEFINES=[ @@ -295,7 +300,7 @@ "UNITY_INCLUDE_CONFIG_H", "WITH_POSIX", "_GNU_SOURCE", - ("IDF_VER", '\\"v4.4-dev-2313-gc69f0ec32\\"'), + ("IDF_VER", '\\"v4.4-dev-3235-g3e370c4296\\"'), "ESP_PLATFORM", "ARDUINO_ARCH_ESP32", "ESP32", diff --git a/tools/platformio-build-esp32c3.py b/tools/platformio-build-esp32c3.py index 7dec32b11ab..63680ad42a9 100644 --- a/tools/platformio-build-esp32c3.py +++ b/tools/platformio-build-esp32c3.py @@ -133,6 +133,7 @@ "-u", "newlib_include_heap_impl", "-u", "newlib_include_syscalls_impl", "-u", "newlib_include_pthread_impl", + "-u", "newlib_include_assert_impl", "-u", "__cxa_guard_dummy", "-u", "__cxx_fatal_exception", '-Wl,-Map="%s"' % join("$BUILD_DIR", basename(env.subst("${PROJECT_DIR}.map"))) @@ -142,7 +143,9 @@ join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "config"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "newlib", "platform_include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "freertos", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "freertos", "include", "esp_additions", "freertos"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "freertos", "port", "riscv", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "freertos", "include", "esp_additions"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "esp_hw_support", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "esp_hw_support", "include", "soc"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "esp_hw_support", "include", "soc", "esp32c3"), @@ -162,8 +165,8 @@ join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "hal", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "hal", "platform_port", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "esp_rom", "include"), - join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "esp_rom", "esp32c3"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "esp_rom", "include", "esp32c3"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "esp_rom", "esp32c3"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "esp_common", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "esp_system", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "esp_system", "port", "soc"), @@ -184,9 +187,9 @@ join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "tcpip_adapter", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "esp_phy", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "esp_phy", "esp32c3", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "esp_ipc", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "app_trace", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "esp_timer", "include"), - join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "esp_ipc", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "mbedtls", "port", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "mbedtls", "mbedtls", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "mbedtls", "esp_crt_bundle", "include"), @@ -202,7 +205,7 @@ join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "espcoredump", "include", "port", "riscv"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "wpa_supplicant", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "wpa_supplicant", "port", "include"), - join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "wpa_supplicant", "include", "esp_supplicant"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "wpa_supplicant", "esp_supplicant", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "ieee802154", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "asio", "asio", "asio", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "asio", "port", "include"), @@ -217,9 +220,7 @@ join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "unity", "unity", "src"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "cmock", "CMock", "src"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "coap", "port", "include"), - join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "coap", "port", "include", "coap"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "coap", "libcoap", "include"), - join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "coap", "libcoap", "include", "coap2"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "console"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "nghttp", "port", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "nghttp", "nghttp2", "lib", "includes"), @@ -272,7 +273,7 @@ ], LIBS=[ - "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lriscv", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lasio", "-lbt", "-lcbor", "-lunity", "-lcmock", "-lcoap", "-lconsole", "-lnghttp", "-lesp-tls", "-lesp_adc_cal", "-lesp_hid", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lesp_https_server", "-lesp_lcd", "-lprotobuf-c", "-lprotocomm", "-lmdns", "-lesp_local_ctrl", "-lsdmmc", "-lesp_serial_slave_link", "-lesp_websocket_client", "-lexpat", "-lwear_levelling", "-lfatfs", "-lfreemodbus", "-ljsmn", "-ljson", "-llibsodium", "-lmqtt", "-lopenssl", "-lspiffs", "-lwifi_provisioning", "-lesp_littlefs", "-lfb_gfx", "-lasio", "-lcbor", "-lcmock", "-lunity", "-lcoap", "-lesp_hid", "-lesp_lcd", "-lesp_local_ctrl", "-lesp_https_server", "-lesp_websocket_client", "-lexpat", "-lfreemodbus", "-ljsmn", "-llibsodium", "-lmqtt", "-lesp_adc_cal", "-lfatfs", "-lwear_levelling", "-lopenssl", "-lspiffs", "-lwifi_provisioning", "-lprotocomm", "-lbt", "-lbtdm_app", "-lprotobuf-c", "-lmdns", "-lconsole", "-ljson", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lriscv", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lriscv", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lriscv", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lriscv", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lriscv", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lriscv", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lphy", "-lesp_phy", "-lphy", "-lesp_phy", "-lphy", "-lbtbb", "-lm", "-lnewlib", "-lstdc++", "-lpthread", "-lgcc", "-lcxx", "-lapp_trace", "-lgcov", "-lapp_trace", "-lgcov", "-lc" + "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lriscv", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lasio", "-lbt", "-lcbor", "-lunity", "-lcmock", "-lcoap", "-lconsole", "-lnghttp", "-lesp-tls", "-lesp_adc_cal", "-lesp_hid", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lesp_https_server", "-lesp_lcd", "-lprotobuf-c", "-lprotocomm", "-lmdns", "-lesp_local_ctrl", "-lsdmmc", "-lesp_serial_slave_link", "-lesp_websocket_client", "-lexpat", "-lwear_levelling", "-lfatfs", "-lfreemodbus", "-ljsmn", "-ljson", "-llibsodium", "-lmqtt", "-lopenssl", "-lspiffs", "-lwifi_provisioning", "-lesp_littlefs", "-lfb_gfx", "-lasio", "-lcbor", "-lcmock", "-lunity", "-lcoap", "-lesp_lcd", "-lesp_local_ctrl", "-lesp_https_server", "-lesp_websocket_client", "-lexpat", "-lfreemodbus", "-ljsmn", "-llibsodium", "-lmqtt", "-lesp_adc_cal", "-lesp_hid", "-lfatfs", "-lwear_levelling", "-lopenssl", "-lspiffs", "-lwifi_provisioning", "-lprotocomm", "-lbt", "-lbtdm_app", "-lprotobuf-c", "-lmdns", "-lconsole", "-ljson", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lriscv", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lriscv", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lriscv", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lriscv", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lriscv", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lriscv", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lphy", "-lbtbb", "-lesp_phy", "-lphy", "-lbtbb", "-lesp_phy", "-lphy", "-lbtbb", "-lm", "-lnewlib", "-lstdc++", "-lpthread", "-lgcc", "-lcxx", "-lapp_trace", "-lgcov", "-lapp_trace", "-lgcov", "-lc" ], CPPDEFINES=[ @@ -281,7 +282,7 @@ "UNITY_INCLUDE_CONFIG_H", "WITH_POSIX", "_GNU_SOURCE", - ("IDF_VER", '\\"v4.4-dev-2313-gc69f0ec32\\"'), + ("IDF_VER", '\\"v4.4-dev-3235-g3e370c4296\\"'), "ESP_PLATFORM", "ARDUINO_ARCH_ESP32", "ESP32", diff --git a/tools/platformio-build-esp32s2.py b/tools/platformio-build-esp32s2.py index 700ec502d2d..dac966a52b0 100644 --- a/tools/platformio-build-esp32s2.py +++ b/tools/platformio-build-esp32s2.py @@ -94,7 +94,7 @@ "-u", "pthread_include_pthread_impl", "-u", "pthread_include_pthread_cond_impl", "-u", "pthread_include_pthread_local_storage_impl", - "-u", "ld_include_panic_highint_hdl", + "-u", "ld_include_highint_hdl", "-u", "start_app", "-u", "__ubsan_include", "-u", "__assert_func", @@ -103,6 +103,7 @@ "-u", "newlib_include_heap_impl", "-u", "newlib_include_syscalls_impl", "-u", "newlib_include_pthread_impl", + "-u", "newlib_include_assert_impl", "-u", "__cxa_guard_dummy", '-Wl,-Map="%s"' % join("$BUILD_DIR", basename(env.subst("${PROJECT_DIR}.map"))) ], @@ -111,7 +112,9 @@ join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "config"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "newlib", "platform_include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "freertos", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "freertos", "include", "esp_additions", "freertos"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "freertos", "port", "xtensa", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "freertos", "include", "esp_additions"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_hw_support", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_hw_support", "include", "soc"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_hw_support", "include", "soc", "esp32s2"), @@ -131,8 +134,8 @@ join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "hal", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "hal", "platform_port", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_rom", "include"), - join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_rom", "esp32s2"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_rom", "include", "esp32s2"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_rom", "esp32s2"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_common", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_system", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_system", "port", "soc"), @@ -153,9 +156,9 @@ join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "tcpip_adapter", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_phy", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_phy", "esp32s2", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_ipc", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "app_trace", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_timer", "include"), - join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_ipc", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "mbedtls", "port", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "mbedtls", "mbedtls", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "mbedtls", "esp_crt_bundle", "include"), @@ -171,7 +174,7 @@ join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "espcoredump", "include", "port", "xtensa"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "wpa_supplicant", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "wpa_supplicant", "port", "include"), - join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "wpa_supplicant", "include", "esp_supplicant"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "wpa_supplicant", "esp_supplicant", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "ieee802154", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "asio", "asio", "asio", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "asio", "port", "include"), @@ -180,9 +183,7 @@ join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "unity", "unity", "src"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "cmock", "CMock", "src"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "coap", "port", "include"), - join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "coap", "port", "include", "coap"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "coap", "libcoap", "include"), - join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "coap", "libcoap", "include", "coap2"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "console"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "nghttp", "port", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "nghttp", "nghttp2", "lib", "includes"), @@ -223,6 +224,7 @@ join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "openssl", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "perfmon", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "spiffs", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "usb", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "touch_element", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "ulp", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "wifi_provisioning", "include"), @@ -254,12 +256,15 @@ join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-dsp", "modules", "dct", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-dsp", "modules", "conv", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-dsp", "modules", "common", "include"), - join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-face", "face_detection", "include"), - join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-face", "face_recognition", "include"), - join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-face", "object_detection", "include"), - join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-face", "image_util", "include"), - join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-face", "pose_estimation", "include"), - join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-face", "lib", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-face", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-face", "include", "tool"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-face", "include", "typedef"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-face", "include", "image"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-face", "include", "math"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-face", "include", "nn"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-face", "include", "layer"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-face", "include", "detect"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-face", "include", "model_zoo"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp32-camera", "driver", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp32-camera", "conversions", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "fb_gfx", "include"), @@ -272,7 +277,7 @@ ], LIBS=[ - "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lasio", "-lcbor", "-lunity", "-lcmock", "-lcoap", "-lconsole", "-lnghttp", "-lesp-tls", "-lesp_adc_cal", "-lesp_hid", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lesp_https_server", "-lesp_lcd", "-lprotobuf-c", "-lprotocomm", "-lmdns", "-lesp_local_ctrl", "-lsdmmc", "-lesp_serial_slave_link", "-lesp_websocket_client", "-lexpat", "-lwear_levelling", "-lfatfs", "-lfreemodbus", "-ljsmn", "-ljson", "-llibsodium", "-lmqtt", "-lopenssl", "-lperfmon", "-lspiffs", "-ltouch_element", "-lulp", "-lusb", "-lwifi_provisioning", "-lesp-dsp", "-lesp-face", "-lesp32-camera", "-lesp_littlefs", "-lfb_gfx", "-lasio", "-lcbor", "-lcmock", "-lunity", "-lcoap", "-lesp_hid", "-lesp_lcd", "-lesp_local_ctrl", "-lesp_https_server", "-lesp_websocket_client", "-lexpat", "-lfreemodbus", "-ljsmn", "-llibsodium", "-lmqtt", "-lperfmon", "-ltouch_element", "-lusb", "-lesp_adc_cal", "-lfatfs", "-lwear_levelling", "-lopenssl", "-lspiffs", "-lwifi_provisioning", "-lprotocomm", "-lprotobuf-c", "-lmdns", "-lconsole", "-ljson", "-larduino_tinyusb", "-lpe", "-lfd", "-lfr", "-ldetection_cat_face", "-ldetection", "-ldl", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lphy", "-lesp_phy", "-lphy", "-lesp_phy", "-lphy", "-lxt_hal", "-lm", "-lnewlib", "-lstdc++", "-lpthread", "-lgcc", "-lcxx", "-lapp_trace", "-lgcov", "-lapp_trace", "-lgcov", "-lc" + "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lasio", "-lcbor", "-lunity", "-lcmock", "-lcoap", "-lconsole", "-lnghttp", "-lesp-tls", "-lesp_adc_cal", "-lesp_hid", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lesp_https_server", "-lesp_lcd", "-lprotobuf-c", "-lprotocomm", "-lmdns", "-lesp_local_ctrl", "-lsdmmc", "-lesp_serial_slave_link", "-lesp_websocket_client", "-lexpat", "-lwear_levelling", "-lfatfs", "-lfreemodbus", "-ljsmn", "-ljson", "-llibsodium", "-lmqtt", "-lopenssl", "-lperfmon", "-lspiffs", "-lusb", "-ltouch_element", "-lulp", "-lwifi_provisioning", "-lesp-dsp", "-lesp32-camera", "-lesp_littlefs", "-lfb_gfx", "-lasio", "-lcbor", "-lcmock", "-lunity", "-lcoap", "-lesp_lcd", "-lesp_local_ctrl", "-lesp_https_server", "-lesp_websocket_client", "-lexpat", "-lfreemodbus", "-ljsmn", "-llibsodium", "-lmqtt", "-lperfmon", "-lusb", "-ltouch_element", "-lesp_adc_cal", "-lesp_hid", "-lfatfs", "-lwear_levelling", "-lopenssl", "-lspiffs", "-lwifi_provisioning", "-lprotocomm", "-lprotobuf-c", "-lmdns", "-lconsole", "-ljson", "-larduino_tinyusb", "-lcat_face_detect", "-lhuman_face_detect", "-ldl", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lphy", "-lesp_phy", "-lphy", "-lesp_phy", "-lphy", "-lxt_hal", "-lm", "-lnewlib", "-lstdc++", "-lpthread", "-lgcc", "-lcxx", "-lapp_trace", "-lgcov", "-lapp_trace", "-lgcov", "-lc" ], CPPDEFINES=[ @@ -281,7 +286,7 @@ "UNITY_INCLUDE_CONFIG_H", "WITH_POSIX", "_GNU_SOURCE", - ("IDF_VER", '\\"v4.4-dev-2313-gc69f0ec32\\"'), + ("IDF_VER", '\\"v4.4-dev-3235-g3e370c4296\\"'), "ESP_PLATFORM", "ARDUINO_ARCH_ESP32", "ESP32", diff --git a/tools/sdk/esp32/bin/bootloader_dio_40m.bin b/tools/sdk/esp32/bin/bootloader_dio_40m.bin index 90cfc391b36..97c4c99695b 100644 Binary files a/tools/sdk/esp32/bin/bootloader_dio_40m.bin and b/tools/sdk/esp32/bin/bootloader_dio_40m.bin differ diff --git a/tools/sdk/esp32/bin/bootloader_dio_80m.bin b/tools/sdk/esp32/bin/bootloader_dio_80m.bin index 05f670d0c3d..30a2681f021 100644 Binary files a/tools/sdk/esp32/bin/bootloader_dio_80m.bin and b/tools/sdk/esp32/bin/bootloader_dio_80m.bin differ diff --git a/tools/sdk/esp32/bin/bootloader_dout_40m.bin b/tools/sdk/esp32/bin/bootloader_dout_40m.bin index 0024c2e51d6..bd7c316fcd2 100644 Binary files a/tools/sdk/esp32/bin/bootloader_dout_40m.bin and b/tools/sdk/esp32/bin/bootloader_dout_40m.bin differ diff --git a/tools/sdk/esp32/bin/bootloader_dout_80m.bin b/tools/sdk/esp32/bin/bootloader_dout_80m.bin index aa6c6b72aac..44ee9d6cfc9 100644 Binary files a/tools/sdk/esp32/bin/bootloader_dout_80m.bin and b/tools/sdk/esp32/bin/bootloader_dout_80m.bin differ diff --git a/tools/sdk/esp32/bin/bootloader_qio_40m.bin b/tools/sdk/esp32/bin/bootloader_qio_40m.bin index 804bcf06fcd..958ddfe8135 100644 Binary files a/tools/sdk/esp32/bin/bootloader_qio_40m.bin and b/tools/sdk/esp32/bin/bootloader_qio_40m.bin differ diff --git a/tools/sdk/esp32/bin/bootloader_qio_80m.bin b/tools/sdk/esp32/bin/bootloader_qio_80m.bin index 186c11d9ed5..bf18af59925 100644 Binary files a/tools/sdk/esp32/bin/bootloader_qio_80m.bin and b/tools/sdk/esp32/bin/bootloader_qio_80m.bin differ diff --git a/tools/sdk/esp32/bin/bootloader_qout_40m.bin b/tools/sdk/esp32/bin/bootloader_qout_40m.bin index 29e1ee58cab..93d6ff461aa 100644 Binary files a/tools/sdk/esp32/bin/bootloader_qout_40m.bin and b/tools/sdk/esp32/bin/bootloader_qout_40m.bin differ diff --git a/tools/sdk/esp32/bin/bootloader_qout_80m.bin b/tools/sdk/esp32/bin/bootloader_qout_80m.bin index c49f5d3d73e..1edaf34822d 100644 Binary files a/tools/sdk/esp32/bin/bootloader_qout_80m.bin and b/tools/sdk/esp32/bin/bootloader_qout_80m.bin differ diff --git a/tools/sdk/esp32/include/app_update/include/esp_ota_ops.h b/tools/sdk/esp32/include/app_update/include/esp_ota_ops.h index 6278ab7905c..ba07c013d90 100644 --- a/tools/sdk/esp32/include/app_update/include/esp_ota_ops.h +++ b/tools/sdk/esp32/include/app_update/include/esp_ota_ops.h @@ -244,6 +244,14 @@ const esp_partition_t* esp_ota_get_next_update_partition(const esp_partition_t * */ esp_err_t esp_ota_get_partition_description(const esp_partition_t *partition, esp_app_desc_t *app_desc); +/** + * @brief Returns number of ota partitions provided in partition table. + * + * @return + * - Number of OTA partitions + */ +uint8_t esp_ota_get_app_partition_count(void); + /** * @brief This function is called to indicate that the running app is working well. * diff --git a/tools/sdk/esp32/include/bootloader_support/include/bootloader_common.h b/tools/sdk/esp32/include/bootloader_support/include/bootloader_common.h index 2ff0e595a27..2f4e9062200 100644 --- a/tools/sdk/esp32/include/bootloader_support/include/bootloader_common.h +++ b/tools/sdk/esp32/include/bootloader_support/include/bootloader_common.h @@ -119,6 +119,15 @@ bool bootloader_common_label_search(const char *list, char *label); */ void bootloader_configure_spi_pins(int drv); +/** + * @brief Get flash CS IO + * + * Can be determined by eFuse values, or the default value + * + * @return Flash CS IO + */ +uint8_t bootloader_flash_get_cs_io(void); + /** * @brief Calculates a sha-256 for a given partition or returns a appended digest. * diff --git a/tools/sdk/esp32/include/bootloader_support/include/bootloader_flash.h b/tools/sdk/esp32/include/bootloader_support/include/bootloader_flash.h index 73aa48923d0..49e457f372e 100644 --- a/tools/sdk/esp32/include/bootloader_support/include/bootloader_flash.h +++ b/tools/sdk/esp32/include/bootloader_support/include/bootloader_flash.h @@ -10,6 +10,18 @@ #include "sdkconfig.h" #include "soc/soc_caps.h" +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Read flash ID by sending RDID command (0x9F) + * @return flash raw ID + * mfg_id = (ID >> 16) & 0xFF; + flash_id = ID & 0xffff; + */ +uint32_t bootloader_read_flash_id(void); + #if SOC_CACHE_SUPPORT_WRAP /** * @brief Set the burst mode setting command for specified wrap mode. @@ -19,3 +31,22 @@ */ esp_err_t bootloader_flash_wrap_set(spi_flash_wrap_mode_t mode); #endif + +/** + * @brief Unlock Flash write protect. + * Please do not call this function in SDK. + * + * @note This can be overridden because it's attribute weak. + */ +esp_err_t bootloader_flash_unlock(void); + +/** + * @brief Startup flow recommended by XMC. Call at startup before any erase/write operation. + * + * @return ESP_OK When startup successfully, otherwise ESP_FAIL (indiciating you should reboot before erase/write). + */ +esp_err_t bootloader_flash_xmc_startup(void); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32/include/bt/common/osi/include/osi/alarm.h b/tools/sdk/esp32/include/bt/common/osi/include/osi/alarm.h index a1d3fa8961b..fe8344cdb9f 100644 --- a/tools/sdk/esp32/include/bt/common/osi/include/osi/alarm.h +++ b/tools/sdk/esp32/include/bt/common/osi/include/osi/alarm.h @@ -77,4 +77,8 @@ period_ms_t osi_alarm_get_remaining_ms(const osi_alarm_t *alarm); uint32_t osi_time_get_os_boottime_ms(void); +// This function returns whether the given |alarm| is active or not. +// Return true if active, false otherwise. +bool osi_alarm_is_active(osi_alarm_t *alarm); + #endif /*_ALARM_H_*/ diff --git a/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h b/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h index ce309935853..dd48ab982dd 100644 --- a/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h +++ b/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h @@ -467,7 +467,7 @@ typedef struct { uint16_t rx_len; /*!< pkt rx data length value */ uint16_t tx_len; /*!< pkt tx data length value */ -}esp_ble_pkt_data_length_params_t; +} esp_ble_pkt_data_length_params_t; /** * @brief BLE encryption keys @@ -648,7 +648,7 @@ typedef enum { typedef enum{ ESP_BLE_WHITELIST_REMOVE = 0X00, /*!< remove mac from whitelist */ ESP_BLE_WHITELIST_ADD = 0X01, /*!< add address to whitelist */ -}esp_ble_wl_opration_t; +} esp_ble_wl_opration_t; #if (BLE_42_FEATURE_SUPPORT == TRUE) typedef enum { ESP_BLE_DUPLICATE_EXCEPTIONAL_LIST_ADD = 0, /*!< Add device info into duplicate scan exceptional list */ @@ -998,7 +998,7 @@ typedef union { uint16_t conn_int; /*!< Current connection interval */ uint16_t timeout; /*!< Supervision timeout for the LE Link. Range: 0x000A to 0x0C80. Mandatory Range: 0x000A to 0x0C80 Time = N * 10 msec */ - }update_conn_params; /*!< Event parameter of ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT */ + } update_conn_params; /*!< Event parameter of ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT */ /** * @brief ESP_GAP_BLE_SET_PKT_LENGTH_COMPLETE_EVT */ @@ -1018,13 +1018,13 @@ typedef union { struct ble_remove_bond_dev_cmpl_evt_param { esp_bt_status_t status; /*!< Indicate the remove bond device operation success status */ esp_bd_addr_t bd_addr; /*!< The device address which has been remove from the bond list */ - }remove_bond_dev_cmpl; /*!< Event parameter of ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT */ + } remove_bond_dev_cmpl; /*!< Event parameter of ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT */ /** * @brief ESP_GAP_BLE_CLEAR_BOND_DEV_COMPLETE_EVT */ struct ble_clear_bond_dev_cmpl_evt_param { esp_bt_status_t status; /*!< Indicate the clear bond device operation success status */ - }clear_bond_dev_cmpl; /*!< Event parameter of ESP_GAP_BLE_CLEAR_BOND_DEV_COMPLETE_EVT */ + } clear_bond_dev_cmpl; /*!< Event parameter of ESP_GAP_BLE_CLEAR_BOND_DEV_COMPLETE_EVT */ /** * @brief ESP_GAP_BLE_GET_BOND_DEV_COMPLETE_EVT */ @@ -1032,7 +1032,7 @@ typedef union { esp_bt_status_t status; /*!< Indicate the get bond device operation success status */ uint8_t dev_num; /*!< Indicate the get number device in the bond list */ esp_ble_bond_dev_t *bond_dev; /*!< the pointer to the bond device Structure */ - }get_bond_dev_cmpl; /*!< Event parameter of ESP_GAP_BLE_GET_BOND_DEV_COMPLETE_EVT */ + } get_bond_dev_cmpl; /*!< Event parameter of ESP_GAP_BLE_GET_BOND_DEV_COMPLETE_EVT */ /** * @brief ESP_GAP_BLE_READ_RSSI_COMPLETE_EVT */ diff --git a/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_gattc_api.h b/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_gattc_api.h index 077cca38507..40719096345 100644 --- a/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_gattc_api.h +++ b/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_gattc_api.h @@ -380,7 +380,7 @@ esp_err_t esp_ble_gattc_search_service(esp_gatt_if_t gattc_if, uint16_t conn_id, /** * @brief Find all the service with the given service uuid in the gattc cache, if the svc_uuid is NULL, find all the service. * Note: It just get service from local cache, won't get from remote devices. If want to get it from remote device, need - * to used the esp_ble_gattc_search_service. + * to used the esp_ble_gattc_cache_refresh, then call esp_ble_gattc_get_service again. * * @param[in] gattc_if: Gatt client access interface. * @param[in] conn_id: connection ID which identify the server. diff --git a/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_hidd_api.h b/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_hidd_api.h new file mode 100644 index 00000000000..de90ff8efc6 --- /dev/null +++ b/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_hidd_api.h @@ -0,0 +1,379 @@ +// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD +// Copyright 2019 Blake Felt +// +// 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_HIDD_API_H__ +#define __ESP_HIDD_API_H__ + +#include "esp_bt_defs.h" +#include "esp_err.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* sub_class of hid device */ +#define ESP_HID_CLASS_UNKNOWN (0x00<<2) +#define ESP_HID_CLASS_JOS (0x01<<2) /* joy stick */ +#define ESP_HID_CLASS_GPD (0x02<<2) /* game pad */ +#define ESP_HID_CLASS_RMC (0x03<<2) /* remote control */ +#define ESP_HID_CLASS_SED (0x04<<2) /* sensing device */ +#define ESP_HID_CLASS_DGT (0x05<<2) /* Digitizer tablet */ +#define ESP_HID_CLASS_CDR (0x06<<2) /* card reader */ +#define ESP_HID_CLASS_KBD (0x10<<2) /* keyboard */ +#define ESP_HID_CLASS_MIC (0x20<<2) /* pointing device */ +#define ESP_HID_CLASS_COM (0x30<<2) /* Combo keyboard/pointing */ + +/** + * @brief HIDD handshake error + */ +typedef enum { + ESP_HID_PAR_HANDSHAKE_RSP_SUCCESS = 0, + ESP_HID_PAR_HANDSHAKE_RSP_NOT_READY = 1, + ESP_HID_PAR_HANDSHAKE_RSP_ERR_INVALID_REP_ID = 2, + ESP_HID_PAR_HANDSHAKE_RSP_ERR_UNSUPPORTED_REQ = 3, + ESP_HID_PAR_HANDSHAKE_RSP_ERR_INVALID_PARAM = 4, + ESP_HID_PAR_HANDSHAKE_RSP_ERR_UNKNOWN = 14, + ESP_HID_PAR_HANDSHAKE_RSP_ERR_FATAL = 15 +} esp_hidd_handshake_error_t; + +/** + * @brief HIDD report types + */ +typedef enum { + ESP_HIDD_REPORT_TYPE_OTHER = 0, + ESP_HIDD_REPORT_TYPE_INPUT, + ESP_HIDD_REPORT_TYPE_OUTPUT, + ESP_HIDD_REPORT_TYPE_FEATURE, + // special value for reports to be sent on INTR(INPUT is assumed) + ESP_HIDD_REPORT_TYPE_INTRDATA +} esp_hidd_report_type_t; + +/** + * @brief HIDD connection state + */ +typedef enum { + ESP_HIDD_CONN_STATE_CONNECTED, + ESP_HIDD_CONN_STATE_CONNECTING, + ESP_HIDD_CONN_STATE_DISCONNECTED, + ESP_HIDD_CONN_STATE_DISCONNECTING, + ESP_HIDD_CONN_STATE_UNKNOWN +} esp_hidd_connection_state_t; + +/** + * @brief HID device protocol modes + */ +typedef enum { + ESP_HIDD_REPORT_MODE = 0x00, + ESP_HIDD_BOOT_MODE = 0x01, + ESP_HIDD_UNSUPPORTED_MODE = 0xff +} esp_hidd_protocol_mode_t; + + +/** + * @brief HIDD characteristics for SDP report + */ +typedef struct { + const char *name; + const char *description; + const char *provider; + uint8_t subclass; + uint8_t *desc_list; + int desc_list_len; +} esp_hidd_app_param_t; + +/** + * @brief HIDD Quality of Service parameters + */ +typedef struct { + uint8_t service_type; + uint32_t token_rate; + uint32_t token_bucket_size; + uint32_t peak_bandwidth; + uint32_t access_latency; + uint32_t delay_variation; +} esp_hidd_qos_param_t; + +/** + * @brief HID device callback function events + */ +typedef enum { + ESP_HIDD_INIT_EVT = 0, /*!< When HID device is inited, the event comes */ + ESP_HIDD_DEINIT_EVT, /*!< When HID device is deinited, the event comes */ + ESP_HIDD_REGISTER_APP_EVT, /*!< When HID device application registered, the event comes */ + ESP_HIDD_UNREGISTER_APP_EVT, /*!< When HID device application unregistered, the event comes */ + ESP_HIDD_OPEN_EVT, /*!< When HID device connection to host opened, the event comes */ + ESP_HIDD_CLOSE_EVT, /*!< When HID device connection to host closed, the event comes */ + ESP_HIDD_SEND_REPORT_EVT, /*!< When HID device send report to lower layer, the event comes */ + ESP_HIDD_REPORT_ERR_EVT, /*!< When HID device report handshanke error to lower layer, the event comes */ + ESP_HIDD_GET_REPORT_EVT, /*!< When HID device receives GET_REPORT request from host, the event comes */ + ESP_HIDD_SET_REPORT_EVT, /*!< When HID device receives SET_REPORT request from host, the event comes */ + ESP_HIDD_SET_PROTOCOL_EVT, /*!< When HID device receives SET_PROTOCOL request from host, the event comes */ + ESP_HIDD_INTR_DATA_EVT, /*!< When HID device receives DATA from host on intr, the event comes */ + ESP_HIDD_VC_UNPLUG_EVT, /*!< When HID device initiates Virtual Cable Unplug, the event comes */ + ESP_HIDD_API_ERR_EVT /*!< When HID device has API error, the event comes */ +} esp_hidd_cb_event_t; + +typedef enum { + ESP_HIDD_SUCCESS, + ESP_HIDD_ERROR, /*!< general ESP HD error */ + ESP_HIDD_NO_RES, /*!< out of system resources */ + ESP_HIDD_BUSY, /*!< Temporarily can not handle this request. */ + ESP_HIDD_NO_DATA, /*!< No data. */ + ESP_HIDD_NEED_INIT, /*!< HIDD module shall init first */ + ESP_HIDD_NEED_DEINIT, /*!< HIDD module shall deinit first */ + ESP_HIDD_NEED_REG, /*!< HIDD module shall register first */ + ESP_HIDD_NEED_DEREG, /*!< HIDD module shall deregister first */ + ESP_HIDD_NO_CONNECTION, /*!< connection may have been closed */ +} esp_hidd_status_t; + +/** + * @brief HID device callback parameters union + */ +typedef union { + /** + * @brief ESP_HIDD_INIT_EVT + */ + struct hidd_init_evt_param { + esp_hidd_status_t status; /*!< operation status */ + } init; /*!< HIDD callback param of ESP_HIDD_INIT_EVT */ + + /** + * @brief ESP_HIDD_DEINIT_EVT + */ + struct hidd_deinit_evt_param { + esp_hidd_status_t status; /*!< operation status */ + } deinit; /*!< HIDD callback param of ESP_HIDD_DEINIT_EVT */ + + /** + * @brief ESP_HIDD_REGISTER_APP_EVT + */ + struct hidd_register_app_evt_param { + esp_hidd_status_t status; /*!< operation status */ + bool in_use; /*!< indicate whether use virtual cable plug host address */ + esp_bd_addr_t bd_addr; /*!< host address */ + } register_app; /*!< HIDD callback param of ESP_HIDD_REGISTER_APP_EVT */ + + /** + * @brief ESP_HIDD_UNREGISTER_APP_EVT + */ + struct hidd_unregister_app_evt_param { + esp_hidd_status_t status; /*!< operation status */ + } unregister_app; /*!< HIDD callback param of ESP_HIDD_UNREGISTER_APP_EVT */ + + /** + * @brief ESP_HIDD_OPEN_EVT + */ + struct hidd_open_evt_param { + esp_hidd_status_t status; /*!< operation status */ + esp_hidd_connection_state_t conn_status; /*!< connection status */ + esp_bd_addr_t bd_addr; /*!< host address */ + } open; /*!< HIDD callback param of ESP_HIDD_OPEN_EVT */ + + /** + * @brief ESP_HIDD_CLOSE_EVT + */ + struct hidd_close_evt_param { + esp_hidd_status_t status; /*!< operation status */ + esp_hidd_connection_state_t conn_status; /*!< connection status */ + } close; /*!< HIDD callback param of ESP_HIDD_CLOSE_EVT */ + + /** + * @brief ESP_HIDD_SEND_REPORT_EVT + */ + struct hidd_send_report_evt_param { + esp_hidd_status_t status; /*!< operation status */ + uint8_t reason; /*!< lower layer failed reason(ref hiddefs.h) */ + esp_hidd_report_type_t report_type; /*!< report type */ + uint8_t report_id; /*!< report id */ + } send_report; /*!< HIDD callback param of ESP_HIDD_SEND_REPORT_EVT */ + + /** + * @brief ESP_HIDD_REPORT_ERR_EVT + */ + struct hidd_report_err_evt_param { + esp_hidd_status_t status; /*!< operation status */ + uint8_t reason; /*!< lower layer failed reason(ref hiddefs.h) */ + } report_err; /*!< HIDD callback param of ESP_HIDD_REPORT_ERR_EVT */ + + /** + * @brief ESP_HIDD_GET_REPORT_EVT + */ + struct hidd_get_report_evt_param { + esp_hidd_report_type_t report_type; /*!< report type */ + uint8_t report_id; /*!< report id */ + uint16_t buffer_size; /*!< buffer size */ + } get_report; /*!< HIDD callback param of ESP_HIDD_GET_REPORT_EVT */ + + /** + * @brief ESP_HIDD_SET_REPORT_EVT + */ + struct hidd_set_report_evt_param { + esp_hidd_report_type_t report_type; /*!< report type */ + uint8_t report_id; /*!< report id */ + uint16_t len; /*!< set_report data length */ + uint8_t *data; /*!< set_report data pointer */ + } set_report; /*!< HIDD callback param of ESP_HIDD_SET_REPORT_EVT */ + + /** + * @brief ESP_HIDD_SET_PROTOCOL_EVT + */ + struct hidd_set_protocol_evt_param { + esp_hidd_protocol_mode_t protocol_mode; /*!< protocol mode */ + } set_protocol; /*!< HIDD callback param of ESP_HIDD_SET_PROTOCOL_EVT */ + + /** + * @brief ESP_HIDD_INTR_DATA_EVT + */ + struct hidd_intr_data_evt_param { + uint8_t report_id; /*!< interrupt channel report id */ + uint16_t len; /*!< interrupt channel report data length */ + uint8_t *data; /*!< interrupt channel report data pointer */ + } intr_data; /*!< HIDD callback param of ESP_HIDD_INTR_DATA_EVT */ + + /** + * @brief ESP_HIDD_VC_UNPLUG_EVT + */ + struct hidd_vc_unplug_param { + esp_hidd_status_t status; /*!< operation status */ + esp_hidd_connection_state_t conn_status; /*!< connection status */ + } vc_unplug; /*!< HIDD callback param of ESP_HIDD_VC_UNPLUG_EVT */ +} esp_hidd_cb_param_t; + +/** + * @brief HID device callback function type. + * @param event: Event type + * @param param: Point to callback parameter, currently is union type + */ +typedef void (esp_hd_cb_t)(esp_hidd_cb_event_t event, esp_hidd_cb_param_t *param); + +/** + * @brief This function is called to init callbacks with HID device module. + * + * @param[in] callback: pointer to the init callback function. + * + * @return + * - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_device_register_callback(esp_hd_cb_t callback); + +/** + * @brief This function initializes HIDD. This function should be called after esp_bluedroid_enable and + * esp_blueroid_init success, and should be called after esp_bt_hid_device_register_callback. + * When the operation is complete the callback function will be called with ESP_HIDD_INIT_EVT. + * + * @return + * - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_device_init(void); + +/** + * @brief This function de-initializes HIDD interface. This function should be called after esp_bluedroid_enable() and + * esp_blueroid_init() success, and should be called after esp_bt_hid_device_init(). When the operation is complete the callback + * function will be called with ESP_HIDD_DEINIT_EVT. + * + * @return - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_device_deinit(void); + +/** + * @brief Registers HIDD parameters with SDP and sets l2cap Quality of Service. This function should be called after + * esp_bluedroid_enable and esp_blueroid_init success, and must be done after esp_bt_hid_device_init. When the operation is complete the callback + * function will be called with ESP_HIDD_REGISTER_APP_EVT. + * + * @param[in] app_param: HIDD parameters + * @param[in] in_qos: incoming QoS parameters + * @param[in] out_qos: outgoing QoS parameters + * + * @return - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_device_register_app(esp_hidd_app_param_t *app_param, esp_hidd_qos_param_t *in_qos, + esp_hidd_qos_param_t *out_qos); + +/** + * @brief Removes HIDD parameters from SDP and resets l2cap Quality of Service. This function should be called after esp_bluedroid_enable and + * esp_blueroid_init success, and should be called after esp_bt_hid_device_init. When the operation is complete the callback + * function will be called with ESP_HIDD_UNREGISTER_APP_EVT. + * + * @return - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_device_unregister_app(void); + +/** + * @brief This function connects HIDD interface to connected bluetooth device, if not done already. When the operation is complete the callback + * function will be called with ESP_HIDD_OPEN_EVT. + * + * @param[in] bd_addr: Remote host bluetooth device address. + * + * @return + * - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_device_connect(esp_bd_addr_t bd_addr); + +/** + * @brief This function disconnects HIDD interface. When the operation is complete the callback + * function will be called with ESP_HIDD_CLOSE_EVT. + * + * @return + * - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_device_disconnect(void); + +/** + * @brief Send HIDD report. When the operation is complete the callback + * function will be called with ESP_HIDD_SEND_REPORT_EVT. + * + * @param[in] type: type of report + * @param[in] id: report id as defined by descriptor + * @param[in] len: length of report + * @param[in] data: report data + * + * @return + * - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_device_send_report(esp_hidd_report_type_t type, uint8_t id, uint16_t len, uint8_t *data); + +/** + * @brief Sends HIDD handshake with error info for invalid set_report. When the operation is complete the callback + * function will be called with ESP_HIDD_REPORT_ERR_EVT. + * + * @param[in] error: type of error + * + * @return - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_device_report_error(esp_hidd_handshake_error_t error); + +/** + * @brief Unplug virtual cable of HIDD. When the operation is complete the callback + * function will be called with ESP_HIDD_VC_UNPLUG_EVT. + * + * @return - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_device_virtual_cable_unplug(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_hidh_api.h b/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_hidh_api.h new file mode 100644 index 00000000000..07abdece2d0 --- /dev/null +++ b/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_hidh_api.h @@ -0,0 +1,465 @@ +// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD +// Copyright 2019 Blake Felt +// +// 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_HIDH_API_H__ +#define __ESP_HIDH_API_H__ + +#include "esp_bt_defs.h" +#include "esp_err.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define BTHH_MAX_DSC_LEN 884 + +/** + * @brief HID host connection state + */ +typedef enum { + ESP_HIDH_CONN_STATE_CONNECTED = 0, /*!< connected state */ + ESP_HIDH_CONN_STATE_CONNECTING, /*!< connecting state */ + ESP_HIDH_CONN_STATE_DISCONNECTED, /*!< disconnected state */ + ESP_HIDH_CONN_STATE_DISCONNECTING, /*!< disconnecting state */ + ESP_HIDH_CONN_STATE_UNKNOWN /*!< unknown state(initial state) */ +} esp_hidh_connection_state_t; + +typedef enum { + ESP_HIDH_OK, + ESP_HIDH_HS_HID_NOT_READY, /*!< handshake error : device not ready */ + ESP_HIDH_HS_INVALID_RPT_ID, /*!< handshake error : invalid report ID */ + ESP_HIDH_HS_TRANS_NOT_SPT, /*!< handshake error : transaction not spt */ + ESP_HIDH_HS_INVALID_PARAM, /*!< handshake error : invalid paremter */ + ESP_HIDH_HS_ERROR, /*!< handshake error : unspecified HS error */ + ESP_HIDH_ERR, /*!< general ESP HH error */ + ESP_HIDH_ERR_SDP, /*!< SDP error */ + ESP_HIDH_ERR_PROTO, /*!< SET_Protocol error, + only used in ESP_HIDH_OPEN_EVT callback */ + + ESP_HIDH_ERR_DB_FULL, /*!< device database full error, used in + ESP_HIDH_OPEN_EVT/ESP_HIDH_ADD_DEV_EVT */ + ESP_HIDH_ERR_TOD_UNSPT, /*!< type of device not supported */ + ESP_HIDH_ERR_NO_RES, /*!< out of system resources */ + ESP_HIDH_ERR_AUTH_FAILED, /*!< authentication fail */ + ESP_HIDH_ERR_HDL, /*!< connection handle error */ + ESP_HIDH_ERR_SEC, /*!< encryption error */ + // self_defined + ESP_HIDH_BUSY, /*!< Temporarily can not handle this request. */ + ESP_HIDH_NO_DATA, /*!< No data. */ + ESP_HIDH_NEED_INIT, /*!< HIDH module shall init first */ + ESP_HIDH_NEED_DEINIT, /*!< HIDH module shall deinit first */ + ESP_HIDH_NO_CONNECTION, /*!< connection may have been closed */ +} esp_hidh_status_t; + +/** + * @brief HID host protocol modes + */ +typedef enum { + ESP_HIDH_BOOT_MODE = 0x00, /*!< boot protocol mode */ + ESP_HIDH_REPORT_MODE = 0x01, /*!< report protocol mode */ + ESP_HIDH_UNSUPPORTED_MODE = 0xff /*!< unsupported protocol mode */ +} esp_hidh_protocol_mode_t; + +/** + * @brief HID host report types + */ +typedef enum { + ESP_HIDH_REPORT_TYPE_OTHER = 0, /*!< unsupported report type */ + ESP_HIDH_REPORT_TYPE_INPUT, /*!< input report type */ + ESP_HIDH_REPORT_TYPE_OUTPUT, /*!< output report type */ + ESP_HIDH_REPORT_TYPE_FEATURE, /*!< feature report type */ +} esp_hidh_report_type_t; + +/** + * @brief HID host callback function events + */ +typedef enum { + ESP_HIDH_INIT_EVT = 0, /*!< When HID host is inited, the event comes */ + ESP_HIDH_DEINIT_EVT, /*!< When HID host is deinited, the event comes */ + ESP_HIDH_OPEN_EVT, /*!< When HID host connection opened, the event comes */ + ESP_HIDH_CLOSE_EVT, /*!< When HID host connection closed, the event comes */ + ESP_HIDH_GET_RPT_EVT, /*!< When Get_Report command is called, the event comes */ + ESP_HIDH_SET_RPT_EVT, /*!< When Set_Report command is called, the event comes */ + ESP_HIDH_GET_PROTO_EVT, /*!< When Get_Protocol command is called, the event comes */ + ESP_HIDH_SET_PROTO_EVT, /*!< When Set_Protocol command is called, the event comes */ + ESP_HIDH_GET_IDLE_EVT, /*!< When Get_Idle command is called, the event comes */ + ESP_HIDH_SET_IDLE_EVT, /*!< When Set_Idle command is called, the event comes */ + ESP_HIDH_GET_DSCP_EVT, /*!< When HIDH is inited, the event comes */ + ESP_HIDH_ADD_DEV_EVT, /*!< When a device is added, the event comes */ + ESP_HIDH_RMV_DEV_EVT, /*!< When a device is removed, the event comes */ + ESP_HIDH_VC_UNPLUG_EVT, /*!< When virtually unplugged, the event comes */ + ESP_HIDH_DATA_EVT, /*!< When send data on interrupt channel, the event comes */ + ESP_HIDH_DATA_IND_EVT, /*!< When receive data on interrupt channel, the event comes */ + ESP_HIDH_SET_INFO_EVT /*!< When set the HID device descriptor, the event comes */ +} esp_hidh_cb_event_t; + +typedef struct { + int attr_mask; + uint8_t sub_class; + uint8_t app_id; + int vendor_id; + int product_id; + int version; + uint8_t ctry_code; + int dl_len; + uint8_t dsc_list[BTHH_MAX_DSC_LEN]; +} esp_hidh_hid_info_t; + +/** + * @brief HID host callback parameters union + */ +typedef union { + /** + * @brief ESP_HIDH_INIT_EVT + */ + struct hidh_init_evt_param { + esp_hidh_status_t status; /*!< status */ + } init; /*!< HIDH callback param of ESP_HIDH_INIT_EVT */ + + /** + * @brief ESP_HIDH_DEINIT_EVT + */ + struct hidh_uninit_evt_param { + esp_hidh_status_t status; /*!< status */ + } deinit; /*!< HIDH callback param of ESP_HIDH_DEINIT_EVT */ + + /** + * @brief ESP_HIDH_OPEN_EVT + */ + struct hidh_open_evt_param { + esp_hidh_status_t status; /*!< operation status */ + esp_hidh_connection_state_t conn_status; /*!< connection status */ + bool is_orig; /*!< indicate if host intiate the connection */ + uint8_t handle; /*!< device handle */ + esp_bd_addr_t bd_addr; /*!< device address */ + } open; /*!< HIDH callback param of ESP_HIDH_OPEN_EVT */ + + /** + * @brief ESP_HIDH_CLOSE_EVT + */ + struct hidh_close_evt_param { + esp_hidh_status_t status; /*!< operation status */ + uint8_t reason; /*!< lower layer failed reason(ref hiddefs.h) */ + esp_hidh_connection_state_t conn_status; /*!< connection status */ + uint8_t handle; /*!< device handle */ + } close; /*!< HIDH callback param of ESP_HIDH_CLOSE_EVT */ + + /** + * @brief ESP_HIDH_VC_UNPLUG_EVT + */ + struct hidh_unplug_evt_param { + esp_hidh_status_t status; /*!< operation status */ + esp_hidh_connection_state_t conn_status; /*!< connection status */ + uint8_t handle; /*!< device handle */ + } unplug; /*!< HIDH callback param of ESP_HIDH_VC_UNPLUG_EVT */ + + /** + * @brief ESP_HIDH_GET_PROTO_EVT + */ + struct hidh_get_proto_evt_param { + esp_hidh_status_t status; /*!< operation status */ + uint8_t handle; /*!< device handle */ + esp_hidh_protocol_mode_t proto_mode; /*!< protocol mode */ + } get_proto; /*!< HIDH callback param of ESP_HIDH_GET_PROTO_EVT */ + + /** + * @brief ESP_HIDH_SET_PROTO_EVT + */ + struct hidh_set_proto_evt_param { + esp_hidh_status_t status; /*!< operation status */ + uint8_t handle; /*!< device handle */ + } set_proto; /*!< HIDH callback param of ESP_HIDH_SET_PROTO_EVT */ + + /** + * @brief ESP_HIDH_GET_RPT_EVT + */ + struct hidh_get_rpt_evt_param { + esp_hidh_status_t status; /*!< operation status */ + uint8_t handle; /*!< device handle */ + uint16_t len; /*!< data length */ + uint8_t *data; /*!< data pointer */ + } get_rpt; /*!< HIDH callback param of ESP_HIDH_GET_RPT_EVT */ + + /** + * @brief ESP_HIDH_SET_RPT_EVT + */ + struct hidh_set_rpt_evt_param { + esp_hidh_status_t status; /*!< operation status */ + uint8_t handle; /*!< device handle */ + } set_rpt; /*!< HIDH callback param of ESP_HIDH_SET_RPT_EVT */ + + /** + * @brief ESP_HIDH_DATA_EVT + */ + struct hidh_send_data_evt_param { + esp_hidh_status_t status; /*!< operation status */ + uint8_t handle; /*!< device handle */ + uint8_t reason; /*!< lower layer failed reason(ref hiddefs.h) */ + } send_data; /*!< HIDH callback param of ESP_HIDH_DATA_EVT */ + + /** + * @brief ESP_HIDH_GET_IDLE_EVT + */ + struct hidh_get_idle_evt_param { + esp_hidh_status_t status; /*!< operation status */ + uint8_t handle; /*!< device handle */ + uint8_t idle_rate; /*!< idle rate */ + } get_idle; /*!< HIDH callback param of ESP_HIDH_GET_IDLE_EVT */ + + /** + * @brief ESP_HIDH_SET_IDLE_EVT + */ + struct hidh_set_idle_evt_param { + esp_hidh_status_t status; /*!< operation status */ + uint8_t handle; /*!< device handle */ + } set_idle; /*!< HIDH callback param of ESP_HIDH_SET_IDLE_EVT */ + + /** + * @brief ESP_HIDH_DATA_IND_EVT + */ + struct hidh_data_ind_evt_param { + esp_hidh_status_t status; /*!< operation status */ + uint8_t handle; /*!< device handle */ + esp_hidh_protocol_mode_t proto_mode; /*!< protocol mode */ + uint16_t len; /*!< data length */ + uint8_t *data; /*!< data pointer */ + } data_ind; /*!< HIDH callback param of ESP_HIDH_DATA_IND_EVT */ + + /** + * @brief ESP_HIDH_ADD_DEV_EVT + */ + struct hidh_add_dev_evt_param { + esp_hidh_status_t status; /*!< operation status */ + uint8_t handle; /*!< device handle */ + esp_bd_addr_t bd_addr; /*!< device address */ + } add_dev; /*!< HIDH callback param of ESP_HIDH_ADD_DEV_EVT */ + + /** + * @brief ESP_HIDH_RMV_DEV_EVT + */ + struct hidh_rmv_dev_evt_param { + esp_hidh_status_t status; /*!< operation status */ + uint8_t handle; /*!< device handle */ + esp_bd_addr_t bd_addr; /*!< device address */ + } rmv_dev; /*!< HIDH callback param of ESP_HIDH_RMV_DEV_EVT */ + + /** + * @brief ESP_HIDH_GET_DSCP_EVT + */ + struct hidh_get_dscp_evt_param { + esp_hidh_status_t status; /*!< operation status */ + uint8_t handle; /*!< device handle */ + bool added; /*!< Indicate if added */ + uint16_t vendor_id; /*!< Vendor ID */ + uint16_t product_id; /*!< Product ID */ + uint16_t version; /*!< Version */ + uint16_t ssr_max_latency; /*!< SSR max latency */ + uint16_t ssr_min_tout; /*!< SSR min timeout */ + uint8_t ctry_code; /*!< Country Code */ + uint16_t dl_len; /*!< Device descriptor length */ + uint8_t *dsc_list; /*!< Device descriptor pointer */ + } dscp; /*!< HIDH callback param of ESP_HIDH_GET_DSCP_EVT */ + + /** + * @brief ESP_HIDH_SET_INFO_EVT + */ + struct hidh_set_info_evt_param { + esp_hidh_status_t status; /*!< operation status */ + uint8_t handle; /*!< device handle */ + esp_bd_addr_t bd_addr; /*!< device address */ + } set_info; /*!< HIDH callback param of ESP_HIDH_SET_INFO_EVT */ +} esp_hidh_cb_param_t; + +/** + * @brief HID host callback function type + * @param event: Event type + * @param param: Point to callback parameter, currently is union type + */ +typedef void (esp_hh_cb_t)(esp_hidh_cb_event_t event, esp_hidh_cb_param_t *param); + +/** + * @brief This function is called to init callbacks with HID host module. + * + * @param[in] callback: pointer to the init callback function. + * + * @return + * - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_host_register_callback(esp_hh_cb_t callback); + +/** + * @brief This function initializes HID host. This function should be called after esp_bluedroid_enable() and + * esp_blueroid_init() success, and should be called after esp_bt_hid_host_register_callback(). + * When the operation is complete the callback function will be called with ESP_HIDH_INIT_EVT. + * + * @return + * - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_host_init(void); + +/** + * @brief Closes the interface. This function should be called after esp_bluedroid_enable() and + * esp_blueroid_init() success, and should be called after esp_bt_hid_host_init(). + * When the operation is complete the callback function will be called with ESP_HIDH_DEINIT_EVT. + * + * @return - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_host_deinit(void); + +/** + * @brief Connect to hid device. When the operation is complete the callback + * function will be called with ESP_HIDH_OPEN_EVT. + * + * @param[in] bd_addr: Remote device bluetooth device address. + * + * @return - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_host_connect(esp_bd_addr_t bd_addr); + +/** + * @brief Disconnect from hid device. When the operation is complete the callback + * function will be called with ESP_HIDH_CLOSE_EVT. + * + * @param[in] bd_addr: Remote device bluetooth device address. + * + * @return - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_host_disconnect(esp_bd_addr_t bd_addr); + +/** + * @brief Virtual UnPlug (VUP) the specified HID device. When the operation is complete the callback + * function will be called with ESP_HIDH_VC_UNPLUG_EVT. + * + * @param[in] bd_addr: Remote device bluetooth device address. + * + * @return - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_host_virtual_cable_unplug(esp_bd_addr_t bd_addr); + +/** + * @brief Set the HID device descriptor for the specified HID device. When the operation is complete the callback + * function will be called with ESP_HIDH_SET_INFO_EVT. + * + * @param[in] bd_addr: Remote device bluetooth device address. + * @param[in] hid_info: HID device descriptor structure. + * + * @return - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_host_set_info(esp_bd_addr_t bd_addr, esp_hidh_hid_info_t *hid_info); + +/** + * @brief Get the HID proto mode. When the operation is complete the callback + * function will be called with ESP_HIDH_GET_PROTO_EVT. + * + * @param[in] bd_addr: Remote device bluetooth device address. + * + * @return + * - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_host_get_protocol(esp_bd_addr_t bd_addr); + +/** + * @brief Set the HID proto mode. When the operation is complete the callback + * function will be called with ESP_HIDH_SET_PROTO_EVT. + * + * @param[in] bd_addr: Remote device bluetooth device address. + * @param[in] protocol_mode: Protocol mode type. + * + * @return + * - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_host_set_protocol(esp_bd_addr_t bd_addr, esp_hidh_protocol_mode_t protocol_mode); + +/** + * @brief Get the HID Idle Time. When the operation is complete the callback + * function will be called with ESP_HIDH_GET_IDLE_EVT. + * + * @param[in] bd_addr: Remote device bluetooth device address. + * + * @return + * - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_host_get_idle(esp_bd_addr_t bd_addr); + +/** + * @brief Set the HID Idle Time. When the operation is complete the callback + * function will be called with ESP_HIDH_SET_IDLE_EVT. + * + * @param[in] bd_addr: Remote device bluetooth device address. + * @param[in] idle_time: Idle time rate + * + * @return - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_host_set_idle(esp_bd_addr_t bd_addr, uint16_t idle_time); + +/** + * @brief Send a GET_REPORT to HID device. When the operation is complete the callback + * function will be called with ESP_HIDH_GET_RPT_EVT. + * + * @param[in] bd_addr: Remote device bluetooth device address. + * @param[in] report_type: Report type + * @param[in] report_id: Report id + * @param[in] buffer_size: Buffer size + * + * @return - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_host_get_report(esp_bd_addr_t bd_addr, esp_hidh_report_type_t report_type, uint8_t report_id, + int buffer_size); + +/** + * @brief Send a SET_REPORT to HID device. When the operation is complete the callback + * function will be called with ESP_HIDH_SET_RPT_EVT. + * + * @param[in] bd_addr: Remote device bluetooth device address. + * @param[in] report_type: Report type + * @param[in] report: Report data pointer + * @param[in] len: Report data length + * + * @return - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_host_set_report(esp_bd_addr_t bd_addr, esp_hidh_report_type_t report_type, uint8_t *report, + size_t len); + +/** + * @brief Send data to HID device. When the operation is complete the callback + * function will be called with ESP_HIDH_DATA_EVT. + * + * @param[in] bd_addr: Remote device bluetooth device address. + * @param[in] data: Data pointer + * @param[in] len: Data length + * + * @return - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_host_send_data(esp_bd_addr_t bd_addr, uint8_t *data, size_t len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/tools/sdk/esp32/include/bt/include/esp32/include/esp_bt.h b/tools/sdk/esp32/include/bt/include/esp32/include/esp_bt.h index c80dab202aa..7c8f2ea744d 100644 --- a/tools/sdk/esp32/include/bt/include/esp32/include/esp_bt.h +++ b/tools/sdk/esp32/include/bt/include/esp32/include/esp_bt.h @@ -149,6 +149,12 @@ the adv packet will be discarded until the memory is restored. */ #define BTDM_CTRL_AUTO_LATENCY_EFF false #endif +#ifdef CONFIG_BTDM_CTRL_HLI +#define BTDM_CTRL_HLI CONFIG_BTDM_CTRL_HLI +#else +#define BTDM_CTRL_HLI false +#endif + #ifdef CONFIG_BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT_EFF #define BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT_EFF CONFIG_BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT_EFF #else @@ -183,6 +189,7 @@ the adv packet will be discarded until the memory is restored. */ .ble_sca = CONFIG_BTDM_BLE_SLEEP_CLOCK_ACCURACY_INDEX_EFF, \ .pcm_role = CONFIG_BTDM_CTRL_PCM_ROLE_EFF, \ .pcm_polar = CONFIG_BTDM_CTRL_PCM_POLAR_EFF, \ + .hli = BTDM_CTRL_HLI, \ .magic = ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL, \ }; @@ -224,6 +231,7 @@ typedef struct { uint8_t ble_sca; /*!< BLE low power crystal accuracy index */ uint8_t pcm_role; /*!< PCM role (master & slave)*/ uint8_t pcm_polar; /*!< PCM polar trig (falling clk edge & rising clk edge) */ + bool hli; /*!< Using high level interrupt or not */ uint32_t magic; /*!< Magic number */ } esp_bt_controller_config_t; @@ -383,12 +391,6 @@ esp_err_t esp_bt_controller_disable(void); */ esp_bt_controller_status_t esp_bt_controller_get_status(void); -/** - * @brief Get BT MAC address. - * @return Array pointer of length 6 storing MAC address value. - */ -uint8_t* esp_bt_get_mac(void); - /** @brief esp_vhci_host_callback * used for vhci call host function to notify what host need to do */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap2/async.h b/tools/sdk/esp32/include/coap/libcoap/include/coap2/async.h deleted file mode 100644 index e399929677d..00000000000 --- a/tools/sdk/esp32/include/coap/libcoap/include/coap2/async.h +++ /dev/null @@ -1,148 +0,0 @@ -/* - * async.h -- state management for asynchronous messages - * - * Copyright (C) 2010-2011 Olaf Bergmann - * - * This file is part of the CoAP library libcoap. Please see README for terms - * of use. - */ - -/** - * @file async.h - * @brief State management for asynchronous messages - */ - -#ifndef COAP_ASYNC_H_ -#define COAP_ASYNC_H_ - -#include "net.h" - -#ifndef WITHOUT_ASYNC - -/** - * @defgroup coap_async Asynchronous Messaging - * @{ - * Structure for managing asynchronous state of CoAP resources. A - * coap_resource_t object holds a list of coap_async_state_t objects that can be - * used to generate a separate response in case a result of an operation cannot - * be delivered in time, or the resource has been explicitly subscribed to with - * the option @c observe. - */ -typedef struct coap_async_state_t { - unsigned char flags; /**< holds the flags to control behaviour */ - - /** - * Holds the internal time when the object was registered with a - * resource. This field will be updated whenever - * coap_register_async() is called for a specific resource. - */ - coap_tick_t created; - - /** - * This field can be used to register opaque application data with the - * asynchronous state object. - */ - void *appdata; - coap_session_t *session; /**< transaction session */ - coap_tid_t id; /**< transaction id */ - struct coap_async_state_t *next; /**< internally used for linking */ - size_t tokenlen; /**< length of the token */ - uint8_t token[8]; /**< the token to use in a response */ -} coap_async_state_t; - -/* Definitions for Async Status Flags These flags can be used to control the - * behaviour of asynchronous response generation. - */ -#define COAP_ASYNC_CONFIRM 0x01 /**< send confirmable response */ -#define COAP_ASYNC_SEPARATE 0x02 /**< send separate response */ -#define COAP_ASYNC_OBSERVED 0x04 /**< the resource is being observed */ - -/** release application data on destruction */ -#define COAP_ASYNC_RELEASE_DATA 0x08 - -/** - * Allocates a new coap_async_state_t object and fills its fields according to - * the given @p request. The @p flags are used to control generation of empty - * ACK responses to stop retransmissions and to release registered @p data when - * the resource is deleted by coap_free_async(). This function returns a pointer - * to the registered coap_async_t object or @c NULL on error. Note that this - * function will return @c NULL in case that an object with the same identifier - * is already registered. - * - * @param context The context to use. - * @param session The session that is used for asynchronous transmissions. - * @param request The request that is handled asynchronously. - * @param flags Flags to control state management. - * @param data Opaque application data to register. Note that the - * storage occupied by @p data is released on destruction - * only if flag COAP_ASYNC_RELEASE_DATA is set. - * - * @return A pointer to the registered coap_async_state_t object or @c - * NULL in case of an error. - */ -coap_async_state_t * -coap_register_async(coap_context_t *context, - coap_session_t *session, - coap_pdu_t *request, - unsigned char flags, - void *data); - -/** - * Removes the state object identified by @p id from @p context. The removed - * object is returned in @p s, if found. Otherwise, @p s is undefined. This - * function returns @c 1 if the object was removed, @c 0 otherwise. Note that - * the storage allocated for the stored object is not released by this - * functions. You will have to call coap_free_async() to do so. - * - * @param context The context where the async object is registered. - * @param session The session that is used for asynchronous transmissions. - * @param id The identifier of the asynchronous transaction. - * @param s Will be set to the object identified by @p id after removal. - * - * @return @c 1 if object was removed and @p s updated, or @c 0 if no - * object was found with the given id. @p s is valid only if the - * return value is @c 1. - */ -int coap_remove_async(coap_context_t *context, - coap_session_t *session, - coap_tid_t id, - coap_async_state_t **s); - -/** - * Releases the memory that was allocated by coap_async_state_init() for the - * object @p s. The registered application data will be released automatically - * if COAP_ASYNC_RELEASE_DATA is set. - * - * @param state The object to delete. - */ -void -coap_free_async(coap_async_state_t *state); - -/** - * Retrieves the object identified by @p id from the list of asynchronous - * transactions that are registered with @p context. This function returns a - * pointer to that object or @c NULL if not found. - * - * @param context The context where the asynchronous objects are registered - * with. - * @param session The session that is used for asynchronous transmissions. - * @param id The id of the object to retrieve. - * - * @return A pointer to the object identified by @p id or @c NULL if - * not found. - */ -coap_async_state_t *coap_find_async(coap_context_t *context, coap_session_t *session, coap_tid_t id); - -/** - * Updates the time stamp of @p s. - * - * @param s The state object to update. - */ -COAP_STATIC_INLINE void -coap_touch_async(coap_async_state_t *s) { coap_ticks(&s->created); } - -/** @} */ - -#endif /* WITHOUT_ASYNC */ - -#endif /* COAP_ASYNC_H_ */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap2/bits.h b/tools/sdk/esp32/include/coap/libcoap/include/coap2/bits.h deleted file mode 100644 index 3b1871487c9..00000000000 --- a/tools/sdk/esp32/include/coap/libcoap/include/coap2/bits.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * bits.h -- bit vector manipulation - * - * Copyright (C) 2010-2011 Olaf Bergmann - * - * This file is part of the CoAP library libcoap. Please see README for terms - * of use. - */ - -/** - * @file bits.h - * @brief Bit vector manipulation - */ - -#ifndef COAP_BITS_H_ -#define COAP_BITS_H_ - -#include - -/** - * Sets the bit @p bit in bit-vector @p vec. This function returns @c 1 if bit - * was set or @c -1 on error (i.e. when the given bit does not fit in the - * vector). - * - * @param vec The bit-vector to change. - * @param size The size of @p vec in bytes. - * @param bit The bit to set in @p vec. - * - * @return @c -1 if @p bit does not fit into @p vec, @c 1 otherwise. - */ -COAP_STATIC_INLINE int -bits_setb(uint8_t *vec, size_t size, uint8_t bit) { - if (size <= ((size_t)bit >> 3)) - return -1; - - *(vec + (bit >> 3)) |= (uint8_t)(1 << (bit & 0x07)); - return 1; -} - -/** - * Clears the bit @p bit from bit-vector @p vec. This function returns @c 1 if - * bit was cleared or @c -1 on error (i.e. when the given bit does not fit in - * the vector). - * - * @param vec The bit-vector to change. - * @param size The size of @p vec in bytes. - * @param bit The bit to clear from @p vec. - * - * @return @c -1 if @p bit does not fit into @p vec, @c 1 otherwise. - */ -COAP_STATIC_INLINE int -bits_clrb(uint8_t *vec, size_t size, uint8_t bit) { - if (size <= ((size_t)bit >> 3)) - return -1; - - *(vec + (bit >> 3)) &= (uint8_t)(~(1 << (bit & 0x07))); - return 1; -} - -/** - * Gets the status of bit @p bit from bit-vector @p vec. This function returns - * @c 1 if the bit is set, @c 0 otherwise (even in case of an error). - * - * @param vec The bit-vector to read from. - * @param size The size of @p vec in bytes. - * @param bit The bit to get from @p vec. - * - * @return @c 1 if the bit is set, @c 0 otherwise. - */ -COAP_STATIC_INLINE int -bits_getb(const uint8_t *vec, size_t size, uint8_t bit) { - if (size <= ((size_t)bit >> 3)) - return -1; - - return (*(vec + (bit >> 3)) & (1 << (bit & 0x07))) != 0; -} - -#endif /* COAP_BITS_H_ */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap2/block.h b/tools/sdk/esp32/include/coap/libcoap/include/coap2/block.h deleted file mode 100644 index 848897639c9..00000000000 --- a/tools/sdk/esp32/include/coap/libcoap/include/coap2/block.h +++ /dev/null @@ -1,173 +0,0 @@ -/* - * block.h -- block transfer - * - * Copyright (C) 2010-2012,2014-2015 Olaf Bergmann - * - * This file is part of the CoAP library libcoap. Please see README for terms - * of use. - */ - -#ifndef COAP_BLOCK_H_ -#define COAP_BLOCK_H_ - -#include "encode.h" -#include "option.h" -#include "pdu.h" - -struct coap_resource_t; -struct coap_session_t; - -/** - * @defgroup block Block Transfer - * API functions for handling PDUs using CoAP BLOCK options - * @{ - */ - -#ifndef COAP_MAX_BLOCK_SZX -/** - * The largest value for the SZX component in a Block option. - */ -#define COAP_MAX_BLOCK_SZX 6 -#endif /* COAP_MAX_BLOCK_SZX */ - -/** - * Structure of Block options. - */ -typedef struct { - unsigned int num; /**< block number */ - unsigned int m:1; /**< 1 if more blocks follow, 0 otherwise */ - unsigned int szx:3; /**< block size */ -} coap_block_t; - -/** - * Returns the value of the least significant byte of a Block option @p opt. - * For zero-length options (i.e. num == m == szx == 0), COAP_OPT_BLOCK_LAST - * returns @c NULL. - */ -#define COAP_OPT_BLOCK_LAST(opt) \ - (coap_opt_length(opt) ? (coap_opt_value(opt) + (coap_opt_length(opt)-1)) : 0) - -/** Returns the value of the More-bit of a Block option @p opt. */ -#define COAP_OPT_BLOCK_MORE(opt) \ - (coap_opt_length(opt) ? (*COAP_OPT_BLOCK_LAST(opt) & 0x08) : 0) - -/** Returns the value of the SZX-field of a Block option @p opt. */ -#define COAP_OPT_BLOCK_SZX(opt) \ - (coap_opt_length(opt) ? (*COAP_OPT_BLOCK_LAST(opt) & 0x07) : 0) - -/** - * Returns the value of field @c num in the given block option @p block_opt. - */ -unsigned int coap_opt_block_num(const coap_opt_t *block_opt); - -/** - * Checks if more than @p num blocks are required to deliver @p data_len - * bytes of data for a block size of 1 << (@p szx + 4). - */ -COAP_STATIC_INLINE int -coap_more_blocks(size_t data_len, unsigned int num, uint16_t szx) { - return ((num+1) << (szx + 4)) < data_len; -} - -#if 0 -/** Sets the More-bit in @p block_opt */ -COAP_STATIC_INLINE void -coap_opt_block_set_m(coap_opt_t *block_opt, int m) { - if (m) - *(coap_opt_value(block_opt) + (coap_opt_length(block_opt) - 1)) |= 0x08; - else - *(coap_opt_value(block_opt) + (coap_opt_length(block_opt) - 1)) &= ~0x08; -} -#endif - -/** - * Initializes @p block from @p pdu. @p type must be either COAP_OPTION_BLOCK1 - * or COAP_OPTION_BLOCK2. When option @p type was found in @p pdu, @p block is - * initialized with values from this option and the function returns the value - * @c 1. Otherwise, @c 0 is returned. - * - * @param pdu The pdu to search for option @p type. - * @param type The option to search for (must be COAP_OPTION_BLOCK1 or - * COAP_OPTION_BLOCK2). - * @param block The block structure to initilize. - * - * @return @c 1 on success, @c 0 otherwise. - */ -int coap_get_block(coap_pdu_t *pdu, uint16_t type, coap_block_t *block); - -/** - * Writes a block option of type @p type to message @p pdu. If the requested - * block size is too large to fit in @p pdu, it is reduced accordingly. An - * exception is made for the final block when less space is required. The actual - * length of the resource is specified in @p data_length. - * - * This function may change *block to reflect the values written to @p pdu. As - * the function takes into consideration the remaining space @p pdu, no more - * options should be added after coap_write_block_opt() has returned. - * - * @param block The block structure to use. On return, this object is - * updated according to the values that have been written to - * @p pdu. - * @param type COAP_OPTION_BLOCK1 or COAP_OPTION_BLOCK2. - * @param pdu The message where the block option should be written. - * @param data_length The length of the actual data that will be added the @p - * pdu by calling coap_add_block(). - * - * @return @c 1 on success, or a negative value on error. - */ -int coap_write_block_opt(coap_block_t *block, - uint16_t type, - coap_pdu_t *pdu, - size_t data_length); - -/** - * Adds the @p block_num block of size 1 << (@p block_szx + 4) from source @p - * data to @p pdu. - * - * @param pdu The message to add the block. - * @param len The length of @p data. - * @param data The source data to fill the block with. - * @param block_num The actual block number. - * @param block_szx Encoded size of block @p block_number. - * - * @return @c 1 on success, @c 0 otherwise. - */ -int coap_add_block(coap_pdu_t *pdu, - unsigned int len, - const uint8_t *data, - unsigned int block_num, - unsigned char block_szx); - -/** - * Adds the appropriate part of @p data to the @p response pdu. If blocks are - * required, then the appropriate block will be added to the PDU and sent. - * Adds a ETAG option that is the hash of the entire data if the data is to be - * split into blocks - * Used by a GET request handler. - * - * @param resource The resource the data is associated with. - * @param session The coap session. - * @param request The requesting pdu. - * @param response The response pdu. - * @param token The token taken from the (original) requesting pdu. - * @param media_type The format of the data. - * @param maxage The maxmimum life of the data. If @c -1, then there - * is no maxage. - * @param length The total length of the data. - * @param data The entire data block to transmit. - * - */ -void -coap_add_data_blocked_response(struct coap_resource_t *resource, - struct coap_session_t *session, - coap_pdu_t *request, - coap_pdu_t *response, - const coap_binary_t *token, - uint16_t media_type, - int maxage, - size_t length, - const uint8_t* data); - -/**@}*/ - -#endif /* COAP_BLOCK_H_ */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap2/coap_dtls.h b/tools/sdk/esp32/include/coap/libcoap/include/coap2/coap_dtls.h deleted file mode 100644 index f0554f3dfea..00000000000 --- a/tools/sdk/esp32/include/coap/libcoap/include/coap2/coap_dtls.h +++ /dev/null @@ -1,611 +0,0 @@ -/* - * coap_dtls.h -- (Datagram) Transport Layer Support for libcoap - * - * Copyright (C) 2016 Olaf Bergmann - * Copyright (C) 2017 Jean-Claude Michelou - * - * This file is part of the CoAP library libcoap. Please see README for terms - * of use. - */ - -#ifndef COAP_DTLS_H_ -#define COAP_DTLS_H_ - -#include "coap_time.h" - -struct coap_context_t; -struct coap_session_t; -struct coap_dtls_pki_t; - -/** - * @defgroup dtls DTLS Support - * API functions for interfacing with DTLS libraries. - * @{ - */ - -/** - * Check whether DTLS is available. - * - * @return @c 1 if support for DTLS is enabled, or @c 0 otherwise. - */ -int coap_dtls_is_supported(void); - -/** - * Check whether TLS is available. - * - * @return @c 1 if support for TLS is enabled, or @c 0 otherwise. - */ -int coap_tls_is_supported(void); - -#define COAP_TLS_LIBRARY_NOTLS 0 /**< No DTLS library */ -#define COAP_TLS_LIBRARY_TINYDTLS 1 /**< Using TinyDTLS library */ -#define COAP_TLS_LIBRARY_OPENSSL 2 /**< Using OpenSSL library */ -#define COAP_TLS_LIBRARY_GNUTLS 3 /**< Using GnuTLS library */ - -/** - * The structure used for returning the underlying (D)TLS library - * information. - */ -typedef struct coap_tls_version_t { - uint64_t version; /**< (D)TLS runtime Library Version */ - int type; /**< Library type. One of COAP_TLS_LIBRARY_* */ - uint64_t built_version; /**< (D)TLS Built against Library Version */ -} coap_tls_version_t; - -/** - * Determine the type and version of the underlying (D)TLS library. - * - * @return The version and type of library libcoap was compiled against. - */ -coap_tls_version_t *coap_get_tls_library_version(void); - -/** - * Additional Security setup handler that can be set up by - * coap_context_set_pki(). - * Invoked when libcoap has done the validation checks at the TLS level, - * but the application needs to do some additional checks/changes/updates. - * - * @param tls_session The security session definition - e.g. SSL * for OpenSSL. - * NULL if server call-back. - * This will be dependent on the underlying TLS library - - * see coap_get_tls_library_version() - * @param setup_data A structure containing setup data originally passed into - * coap_context_set_pki() or coap_new_client_session_pki(). - * - * @return @c 1 if successful, else @c 0. - */ -typedef int (*coap_dtls_security_setup_t)(void* tls_session, - struct coap_dtls_pki_t *setup_data); - -/** - * CN Validation call-back that can be set up by coap_context_set_pki(). - * Invoked when libcoap has done the validation checks at the TLS level, - * but the application needs to check that the CN is allowed. - * CN is the SubjectAltName in the cert, if not present, then the leftmost - * Common Name (CN) component of the subject name. - * - * @param cn The determined CN from the certificate - * @param asn1_public_cert The ASN.1 DER encoded X.509 certificate - * @param asn1_length The ASN.1 length - * @param coap_session The CoAP session associated with the certificate update - * @param depth Depth in cert chain. If 0, then client cert, else a CA - * @param validated TLS layer can find no issues if 1 - * @param arg The same as was passed into coap_context_set_pki() - * in setup_data->cn_call_back_arg - * - * @return @c 1 if accepted, else @c 0 if to be rejected. - */ -typedef int (*coap_dtls_cn_callback_t)(const char *cn, - const uint8_t *asn1_public_cert, - size_t asn1_length, - struct coap_session_t *coap_session, - unsigned depth, - int validated, - void *arg); - -/** - * The enum used for determining the provided PKI ASN.1 (DER) Private Key - * formats. - */ -typedef enum coap_asn1_privatekey_type_t { - COAP_ASN1_PKEY_NONE, /**< NONE */ - COAP_ASN1_PKEY_RSA, /**< RSA type */ - COAP_ASN1_PKEY_RSA2, /**< RSA2 type */ - COAP_ASN1_PKEY_DSA, /**< DSA type */ - COAP_ASN1_PKEY_DSA1, /**< DSA1 type */ - COAP_ASN1_PKEY_DSA2, /**< DSA2 type */ - COAP_ASN1_PKEY_DSA3, /**< DSA3 type */ - COAP_ASN1_PKEY_DSA4, /**< DSA4 type */ - COAP_ASN1_PKEY_DH, /**< DH type */ - COAP_ASN1_PKEY_DHX, /**< DHX type */ - COAP_ASN1_PKEY_EC, /**< EC type */ - COAP_ASN1_PKEY_HMAC, /**< HMAC type */ - COAP_ASN1_PKEY_CMAC, /**< CMAC type */ - COAP_ASN1_PKEY_TLS1_PRF, /**< TLS1_PRF type */ - COAP_ASN1_PKEY_HKDF /**< HKDF type */ -} coap_asn1_privatekey_type_t; - -/** - * The enum used for determining the PKI key formats. - */ -typedef enum coap_pki_key_t { - COAP_PKI_KEY_PEM = 0, /**< The PKI key type is PEM */ - COAP_PKI_KEY_ASN1, /**< The PKI key type is ASN.1 (DER) */ -} coap_pki_key_t; - -/** - * The structure that holds the PKI PEM definitions. - */ -typedef struct coap_pki_key_pem_t { - const char *ca_file; /**< File location of Common CA in PEM format */ - const char *public_cert; /**< File location of Public Cert in PEM format */ - const char *private_key; /**< File location of Private Key in PEM format */ -} coap_pki_key_pem_t; - -/** - * The structure that holds the PKI ASN.1 (DER) definitions. - */ -typedef struct coap_pki_key_asn1_t { - const uint8_t *ca_cert; /**< ASN1 (DER) Common CA Cert */ - const uint8_t *public_cert; /**< ASN1 (DER) Public Cert */ - const uint8_t *private_key; /**< ASN1 (DER) Private Key */ - size_t ca_cert_len; /**< ASN1 CA Cert length */ - size_t public_cert_len; /**< ASN1 Public Cert length */ - size_t private_key_len; /**< ASN1 Private Key length */ - coap_asn1_privatekey_type_t private_key_type; /**< Private Key Type */ -} coap_pki_key_asn1_t; - -/** - * The structure that holds the PKI key information. - */ -typedef struct coap_dtls_key_t { - coap_pki_key_t key_type; /**< key format type */ - union { - coap_pki_key_pem_t pem; /**< for PEM keys */ - coap_pki_key_asn1_t asn1; /**< for ASN.1 (DER) keys */ - } key; -} coap_dtls_key_t; - -/** - * Server Name Indication (SNI) Validation call-back that can be set up by - * coap_context_set_pki(). - * Invoked if the SNI is not previously seen and prior to sending a certificate - * set back to the client so that the appropriate certificate set can be used - * based on the requesting SNI. - * - * @param sni The requested SNI - * @param arg The same as was passed into coap_context_set_pki() - * in setup_data->sni_call_back_arg - * - * @return New set of certificates to use, or @c NULL if SNI is to be rejected. - */ -typedef coap_dtls_key_t *(*coap_dtls_sni_callback_t)(const char *sni, - void* arg); - - -#define COAP_DTLS_PKI_SETUP_VERSION 1 /**< Latest PKI setup version */ - -/** - * The structure used for defining the PKI setup data to be used. - */ -typedef struct coap_dtls_pki_t { - uint8_t version; /** Set to 1 to support this version of the struct */ - - /* Options to enable different TLS functionality in libcoap */ - uint8_t verify_peer_cert; /**< 1 if peer cert is to be verified */ - uint8_t require_peer_cert; /**< 1 if peer cert is required */ - uint8_t allow_self_signed; /**< 1 if self signed certs are allowed */ - uint8_t allow_expired_certs; /**< 1 if expired certs are allowed */ - uint8_t cert_chain_validation; /**< 1 if to check cert_chain_verify_depth */ - uint8_t cert_chain_verify_depth; /**< recommended depth is 3 */ - uint8_t check_cert_revocation; /**< 1 if revocation checks wanted */ - uint8_t allow_no_crl; /**< 1 ignore if CRL not there */ - uint8_t allow_expired_crl; /**< 1 if expired crl is allowed */ - uint8_t reserved[6]; /**< Reserved - must be set to 0 for - future compatibility */ - /* Size of 6 chosen to align to next - * parameter, so if newly defined option - * it can use one of the reserverd slot so - * no need to change - * COAP_DTLS_PKI_SETUP_VERSION and just - * decrement the reserved[] count. - */ - - /** CN check call-back function. - * If not NULL, is called when the TLS connection has passed the configured - * TLS options above for the application to verify if the CN is valid. - */ - coap_dtls_cn_callback_t validate_cn_call_back; - void *cn_call_back_arg; /**< Passed in to the CN call-back function */ - - /** SNI check call-back function. - * If not @p NULL, called if the SNI is not previously seen and prior to - * sending a certificate set back to the client so that the appropriate - * certificate set can be used based on the requesting SNI. - */ - coap_dtls_sni_callback_t validate_sni_call_back; - void *sni_call_back_arg; /**< Passed in to the sni call-back function */ - - /** Additional Security call-back handler that is invoked when libcoap has - * done the standerd, defined validation checks at the TLS level, - * If not @p NULL, called from within the TLS Client Hello connection - * setup. - */ - coap_dtls_security_setup_t additional_tls_setup_call_back; - - char* client_sni; /**< If not NULL, SNI to use in client TLS setup. - Owned by the client app and must remain valid - during the call to coap_new_client_session_pki() */ - - coap_dtls_key_t pki_key; /**< PKI key definition */ -} coap_dtls_pki_t; - -/** @} */ - -/** - * @defgroup dtls_internal DTLS Support (Internal) - * Internal API functions for interfacing with DTLS libraries. - * @{ - */ - -/** - * Creates a new DTLS context for the given @p coap_context. This function - * returns a pointer to a new DTLS context object or @c NULL on error. - * - * Internal function. - * - * @param coap_context The CoAP context where the DTLS object shall be used. - * - * @return A DTLS context object or @c NULL on error. - */ -void * -coap_dtls_new_context(struct coap_context_t *coap_context); - -typedef enum coap_dtls_role_t { - COAP_DTLS_ROLE_CLIENT, /**< Internal function invoked for client */ - COAP_DTLS_ROLE_SERVER /**< Internal function invoked for server */ -} coap_dtls_role_t; - -/** - * Set the DTLS context's default PSK information. - * This does the PSK specifics following coap_dtls_new_context(). - * If @p COAP_DTLS_ROLE_SERVER, then identity hint will also get set. - * If @p COAP_DTLS_ROLE_SERVER, then the information will get put into the - * TLS library's context (from which sessions are derived). - * If @p COAP_DTLS_ROLE_CLIENT, then the information will get put into the - * TLS library's session. - * - * Internal function. - * - * @param coap_context The CoAP context. - * @param identity_hint The default PSK server identity hint sent to a client. - * Required parameter. If @p NULL, will be set to "". - * Empty string is a valid hint. - * This parameter is ignored if COAP_DTLS_ROLE_CLIENT - * @param role One of @p COAP_DTLS_ROLE_CLIENT or @p COAP_DTLS_ROLE_SERVER - * - * @return @c 1 if successful, else @c 0. - */ - -int -coap_dtls_context_set_psk(struct coap_context_t *coap_context, - const char *identity_hint, - coap_dtls_role_t role); - -/** - * Set the DTLS context's default server PKI information. - * This does the PKI specifics following coap_dtls_new_context(). - * If @p COAP_DTLS_ROLE_SERVER, then the information will get put into the - * TLS library's context (from which sessions are derived). - * If @p COAP_DTLS_ROLE_CLIENT, then the information will get put into the - * TLS library's session. - * - * Internal function. - * - * @param coap_context The CoAP context. - * @param setup_data Setup information defining how PKI is to be setup. - * Required parameter. If @p NULL, PKI will not be - * set up. - * @param role One of @p COAP_DTLS_ROLE_CLIENT or @p COAP_DTLS_ROLE_SERVER - * - * @return @c 1 if successful, else @c 0. - */ - -int -coap_dtls_context_set_pki(struct coap_context_t *coap_context, - coap_dtls_pki_t *setup_data, - coap_dtls_role_t role); - -/** - * Set the dtls context's default Root CA information for a client or server. - * - * Internal function. - * - * @param coap_context The current coap_context_t object. - * @param ca_file If not @p NULL, is the full path name of a PEM encoded - * file containing all the Root CAs to be used. - * @param ca_dir If not @p NULL, points to a directory containing PEM - * encoded files containing all the Root CAs to be used. - * - * @return @c 1 if successful, else @c 0. - */ - -int -coap_dtls_context_set_pki_root_cas(struct coap_context_t *coap_context, - const char *ca_file, - const char *ca_dir); - -/** - * Check whether one of the coap_dtls_context_set_{psk|pki}() functions have - * been called. - * - * Internal function. - * - * @param coap_context The current coap_context_t object. - * - * @return @c 1 if coap_dtls_context_set_{psk|pki}() called, else @c 0. - */ - -int coap_dtls_context_check_keys_enabled(struct coap_context_t *coap_context); - -/** - * Releases the storage allocated for @p dtls_context. - * - * Internal function. - * - * @param dtls_context The DTLS context as returned by coap_dtls_new_context(). - */ -void coap_dtls_free_context(void *dtls_context); - -/** - * Create a new client-side session. This should send a HELLO to the server. - * - * Internal function. - * - * @param coap_session The CoAP session. - * - * @return Opaque handle to underlying TLS library object containing security - * parameters for the session. -*/ -void *coap_dtls_new_client_session(struct coap_session_t *coap_session); - -/** - * Create a new DTLS server-side session. - * Called after coap_dtls_hello() has returned @c 1, signalling that a validated - * HELLO was received from a client. - * This should send a HELLO to the server. - * - * Internal function. - * - * @param coap_session The CoAP session. - * - * @return Opaque handle to underlying TLS library object containing security - * parameters for the DTLS session. - */ -void *coap_dtls_new_server_session(struct coap_session_t *coap_session); - -/** - * Terminates the DTLS session (may send an ALERT if necessary) then frees the - * underlying TLS library object containing security parameters for the session. - * - * Internal function. - * - * @param coap_session The CoAP session. - */ -void coap_dtls_free_session(struct coap_session_t *coap_session); - -/** - * Notify of a change in the CoAP session's MTU, for example after - * a PMTU update. - * - * Internal function. - * - * @param coap_session The CoAP session. - */ -void coap_dtls_session_update_mtu(struct coap_session_t *coap_session); - -/** - * Send data to a DTLS peer. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param data pointer to data. - * @param data_len Number of bytes to send. - * - * @return @c 0 if this would be blocking, @c -1 if there is an error or the - * number of cleartext bytes sent. - */ -int coap_dtls_send(struct coap_session_t *coap_session, - const uint8_t *data, - size_t data_len); - -/** - * Check if timeout is handled per CoAP session or per CoAP context. - * - * Internal function. - * - * @return @c 1 of timeout and retransmit is per context, @c 0 if it is - * per session. - */ -int coap_dtls_is_context_timeout(void); - -/** - * Do all pending retransmits and get next timeout - * - * Internal function. - * - * @param dtls_context The DTLS context. - * - * @return @c 0 if no event is pending or date of the next retransmit. - */ -coap_tick_t coap_dtls_get_context_timeout(void *dtls_context); - -/** - * Get next timeout for this session. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param now The current time in ticks. - * - * @return @c 0 If no event is pending or ticks time of the next retransmit. - */ -coap_tick_t coap_dtls_get_timeout(struct coap_session_t *coap_session, - coap_tick_t now); - -/** - * Handle a DTLS timeout expiration. - * - * Internal function. - * - * @param coap_session The CoAP session. - */ -void coap_dtls_handle_timeout(struct coap_session_t *coap_session); - -/** - * Handling incoming data from a DTLS peer. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param data Encrypted datagram. - * @param data_len Encrypted datagram size. - * - * @return Result of coap_handle_dgram on the decrypted CoAP PDU - * or @c -1 for error. - */ -int coap_dtls_receive(struct coap_session_t *coap_session, - const uint8_t *data, - size_t data_len); - -/** - * Handling client HELLO messages from a new candiate peer. - * Note that session->tls is empty. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param data Encrypted datagram. - * @param data_len Encrypted datagram size. - * - * @return @c 0 if a cookie verification message has been sent, @c 1 if the - * HELLO contains a valid cookie and a server session should be created, - * @c -1 if the message is invalid. - */ -int coap_dtls_hello(struct coap_session_t *coap_session, - const uint8_t *data, - size_t data_len); - -/** - * Get DTLS overhead over cleartext PDUs. - * - * Internal function. - * - * @param coap_session The CoAP session. - * - * @return Maximum number of bytes added by DTLS layer. - */ -unsigned int coap_dtls_get_overhead(struct coap_session_t *coap_session); - -/** - * Create a new TLS client-side session. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param connected Updated with whether the connection is connected yet or not. - * @c 0 is not connected, @c 1 is connected. - * - * @return Opaque handle to underlying TLS library object containing security - * parameters for the session. -*/ -void *coap_tls_new_client_session(struct coap_session_t *coap_session, int *connected); - -/** - * Create a TLS new server-side session. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param connected Updated with whether the connection is connected yet or not. - * @c 0 is not connected, @c 1 is connected. - * - * @return Opaque handle to underlying TLS library object containing security - * parameters for the session. - */ -void *coap_tls_new_server_session(struct coap_session_t *coap_session, int *connected); - -/** - * Terminates the TLS session (may send an ALERT if necessary) then frees the - * underlying TLS library object containing security parameters for the session. - * - * Internal function. - * - * @param coap_session The CoAP session. - */ -void coap_tls_free_session( struct coap_session_t *coap_session ); - -/** - * Send data to a TLS peer, with implicit flush. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param data Pointer to data. - * @param data_len Number of bytes to send. - * - * @return @c 0 if this should be retried, @c -1 if there is an error - * or the number of cleartext bytes sent. - */ -ssize_t coap_tls_write(struct coap_session_t *coap_session, - const uint8_t *data, - size_t data_len - ); - -/** - * Read some data from a TLS peer. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param data Pointer to data. - * @param data_len Maximum number of bytes to read. - * - * @return @c 0 if this should be retried, @c -1 if there is an error - * or the number of cleartext bytes read. - */ -ssize_t coap_tls_read(struct coap_session_t *coap_session, - uint8_t *data, - size_t data_len - ); - -/** - * Initialize the underlying (D)TLS Library layer. - * - * Internal function. - * - */ -void coap_dtls_startup(void); - -/** @} */ - -/** - * @ingroup logging - * Sets the (D)TLS logging level to the specified @p level. - * Note: coap_log_level() will influence output if at a specified level. - * - * @param level The logging level to use - LOG_* - */ -void coap_dtls_set_log_level(int level); - -/** - * @ingroup logging - * Get the current (D)TLS logging. - * - * @return The current log level (one of LOG_*). - */ -int coap_dtls_get_log_level(void); - - -#endif /* COAP_DTLS_H */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap2/coap_session.h b/tools/sdk/esp32/include/coap/libcoap/include/coap2/coap_session.h deleted file mode 100644 index 1dc0103e3e7..00000000000 --- a/tools/sdk/esp32/include/coap/libcoap/include/coap2/coap_session.h +++ /dev/null @@ -1,492 +0,0 @@ -/* coap_session.h -- Session management for libcoap -* -* Copyright (C) 2017 Jean-Claue Michelou -* -* This file is part of the CoAP library libcoap. Please see -* README for terms of use. -*/ - -#ifndef COAP_SESSION_H_ -#define COAP_SESSION_H_ - - -#include "coap_io.h" -#include "coap_time.h" -#include "pdu.h" - -struct coap_endpoint_t; -struct coap_context_t; -struct coap_queue_t; - -/** -* Abstraction of a fixed point number that can be used where necessary instead -* of a float. 1,000 fractional bits equals one integer -*/ -typedef struct coap_fixed_point_t { - uint16_t integer_part; /**< Integer part of fixed point variable */ - uint16_t fractional_part; /**< Fractional part of fixed point variable - 1/1000 (3 points) precision */ -} coap_fixed_point_t; - -#define COAP_DEFAULT_SESSION_TIMEOUT 300 -#define COAP_PARTIAL_SESSION_TIMEOUT_TICKS (30 * COAP_TICKS_PER_SECOND) -#define COAP_DEFAULT_MAX_HANDSHAKE_SESSIONS 100 - -#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS) -#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS) - -typedef uint8_t coap_session_type_t; -/** - * coap_session_type_t values - */ -#define COAP_SESSION_TYPE_CLIENT 1 /**< client-side */ -#define COAP_SESSION_TYPE_SERVER 2 /**< server-side */ -#define COAP_SESSION_TYPE_HELLO 3 /**< server-side ephemeral session for responding to a client hello */ - -typedef uint8_t coap_session_state_t; -/** - * coap_session_state_t values - */ -#define COAP_SESSION_STATE_NONE 0 -#define COAP_SESSION_STATE_CONNECTING 1 -#define COAP_SESSION_STATE_HANDSHAKE 2 -#define COAP_SESSION_STATE_CSM 3 -#define COAP_SESSION_STATE_ESTABLISHED 4 - -typedef struct coap_session_t { - struct coap_session_t *next; - coap_proto_t proto; /**< protocol used */ - coap_session_type_t type; /**< client or server side socket */ - coap_session_state_t state; /**< current state of relationaship with peer */ - unsigned ref; /**< reference count from queues */ - unsigned tls_overhead; /**< overhead of TLS layer */ - unsigned mtu; /**< path or CSM mtu */ - coap_address_t local_if; /**< optional local interface address */ - coap_address_t remote_addr; /**< remote address and port */ - coap_address_t local_addr; /**< local address and port */ - int ifindex; /**< interface index */ - coap_socket_t sock; /**< socket object for the session, if any */ - struct coap_endpoint_t *endpoint; /**< session's endpoint */ - struct coap_context_t *context; /**< session's context */ - void *tls; /**< security parameters */ - uint16_t tx_mid; /**< the last message id that was used in this session */ - uint8_t con_active; /**< Active CON request sent */ - struct coap_queue_t *delayqueue; /**< list of delayed messages waiting to be sent */ - size_t partial_write; /**< if > 0 indicates number of bytes already written from the pdu at the head of sendqueue */ - uint8_t read_header[8]; /**< storage space for header of incoming message header */ - size_t partial_read; /**< if > 0 indicates number of bytes already read for an incoming message */ - coap_pdu_t *partial_pdu; /**< incomplete incoming pdu */ - coap_tick_t last_rx_tx; - coap_tick_t last_tx_rst; - coap_tick_t last_ping; - coap_tick_t last_pong; - coap_tick_t csm_tx; - uint8_t *psk_identity; - size_t psk_identity_len; - uint8_t *psk_key; - size_t psk_key_len; - void *app; /**< application-specific data */ - unsigned int max_retransmit; /**< maximum re-transmit count (default 4) */ - coap_fixed_point_t ack_timeout; /**< timeout waiting for ack (default 2 secs) */ - coap_fixed_point_t ack_random_factor; /**< ack random factor backoff (default 1.5) */ - unsigned int dtls_timeout_count; /**< dtls setup retry counter */ - int dtls_event; /**< Tracking any (D)TLS events on this sesison */ -} coap_session_t; - -/** -* Increment reference counter on a session. -* -* @param session The CoAP session. -* @return same as session -*/ -coap_session_t *coap_session_reference(coap_session_t *session); - -/** -* Decrement reference counter on a session. -* Note that the session may be deleted as a result and should not be used -* after this call. -* -* @param session The CoAP session. -*/ -void coap_session_release(coap_session_t *session); - -/** -* Stores @p data with the given session. This function overwrites any value -* that has previously been stored with @p session. -*/ -void coap_session_set_app_data(coap_session_t *session, void *data); - -/** -* Returns any application-specific data that has been stored with @p -* session using the function coap_session_set_app_data(). This function will -* return @c NULL if no data has been stored. -*/ -void *coap_session_get_app_data(const coap_session_t *session); - -/** -* Notify session that it has failed. -* -* @param session The CoAP session. -* @param reason The reason why the session was disconnected. -*/ -void coap_session_disconnected(coap_session_t *session, coap_nack_reason_t reason); - -/** -* Notify session transport has just connected and CSM exchange can now start. -* -* @param session The CoAP session. -*/ -void coap_session_send_csm(coap_session_t *session); - -/** -* Notify session that it has just connected or reconnected. -* -* @param session The CoAP session. -*/ -void coap_session_connected(coap_session_t *session); - -/** -* Set the session MTU. This is the maximum message size that can be sent, -* excluding IP and UDP overhead. -* -* @param session The CoAP session. -* @param mtu maximum message size -*/ -void coap_session_set_mtu(coap_session_t *session, unsigned mtu); - -/** - * Get maximum acceptable PDU size - * - * @param session The CoAP session. - * @return maximum PDU size, not including header (but including token). - */ -size_t coap_session_max_pdu_size(const coap_session_t *session); - -/** -* Creates a new client session to the designated server. -* @param ctx The CoAP context. -* @param local_if Address of local interface. It is recommended to use NULL to let the operating system choose a suitable local interface. If an address is specified, the port number should be zero, which means that a free port is automatically selected. -* @param server The server's address. If the port number is zero, the default port for the protocol will be used. -* @param proto Protocol. -* -* @return A new CoAP session or NULL if failed. Call coap_session_release to free. -*/ -coap_session_t *coap_new_client_session( - struct coap_context_t *ctx, - const coap_address_t *local_if, - const coap_address_t *server, - coap_proto_t proto -); - -/** -* Creates a new client session to the designated server with PSK credentials -* @param ctx The CoAP context. -* @param local_if Address of local interface. It is recommended to use NULL to let the operating system choose a suitable local interface. If an address is specified, the port number should be zero, which means that a free port is automatically selected. -* @param server The server's address. If the port number is zero, the default port for the protocol will be used. -* @param proto Protocol. -* @param identity PSK client identity -* @param key PSK shared key -* @param key_len PSK shared key length -* -* @return A new CoAP session or NULL if failed. Call coap_session_release to free. -*/ -coap_session_t *coap_new_client_session_psk( - struct coap_context_t *ctx, - const coap_address_t *local_if, - const coap_address_t *server, - coap_proto_t proto, - const char *identity, - const uint8_t *key, - unsigned key_len -); - -struct coap_dtls_pki_t; - -/** -* Creates a new client session to the designated server with PKI credentials -* @param ctx The CoAP context. -* @param local_if Address of local interface. It is recommended to use NULL to -* let the operating system choose a suitable local interface. -* If an address is specified, the port number should be zero, -* which means that a free port is automatically selected. -* @param server The server's address. If the port number is zero, the default -* port for the protocol will be used. -* @param proto CoAP Protocol. -* @param setup_data PKI parameters. -* -* @return A new CoAP session or NULL if failed. Call coap_session_release() -* to free. -*/ -coap_session_t *coap_new_client_session_pki( - struct coap_context_t *ctx, - const coap_address_t *local_if, - const coap_address_t *server, - coap_proto_t proto, - struct coap_dtls_pki_t *setup_data -); - -/** -* Creates a new server session for the specified endpoint. -* @param ctx The CoAP context. -* @param ep An endpoint where an incoming connection request is pending. -* -* @return A new CoAP session or NULL if failed. Call coap_session_release to free. -*/ -coap_session_t *coap_new_server_session( - struct coap_context_t *ctx, - struct coap_endpoint_t *ep -); - -/** -* Function interface for datagram data transmission. This function returns -* the number of bytes that have been transmitted, or a value less than zero -* on error. -* -* @param session Session to send data on. -* @param data The data to send. -* @param datalen The actual length of @p data. -* -* @return The number of bytes written on success, or a value -* less than zero on error. -*/ -ssize_t coap_session_send(coap_session_t *session, - const uint8_t *data, size_t datalen); - -/** -* Function interface for stream data transmission. This function returns -* the number of bytes that have been transmitted, or a value less than zero -* on error. The number of bytes written may be less than datalen because of -* congestion control. -* -* @param session Session to send data on. -* @param data The data to send. -* @param datalen The actual length of @p data. -* -* @return The number of bytes written on success, or a value -* less than zero on error. -*/ -ssize_t coap_session_write(coap_session_t *session, - const uint8_t *data, size_t datalen); - -/** -* Send a pdu according to the session's protocol. This function returns -* the number of bytes that have been transmitted, or a value less than zero -* on error. -* -* @param session Session to send pdu on. -* @param pdu The pdu to send. -* -* @return The number of bytes written on success, or a value -* less than zero on error. -*/ -ssize_t coap_session_send_pdu(coap_session_t *session, coap_pdu_t *pdu); - - -/** - * @ingroup logging - * Get session description. - * - * @param session The CoAP session. - * @return description string. - */ -const char *coap_session_str(const coap_session_t *session); - -ssize_t -coap_session_delay_pdu(coap_session_t *session, coap_pdu_t *pdu, - struct coap_queue_t *node); -/** -* Abstraction of virtual endpoint that can be attached to coap_context_t. The -* tuple (handle, addr) must uniquely identify this endpoint. -*/ -typedef struct coap_endpoint_t { - struct coap_endpoint_t *next; - struct coap_context_t *context; /**< endpoint's context */ - coap_proto_t proto; /**< protocol used on this interface */ - uint16_t default_mtu; /**< default mtu for this interface */ - coap_socket_t sock; /**< socket object for the interface, if any */ - coap_address_t bind_addr; /**< local interface address */ - coap_session_t *sessions; /**< list of active sessions */ -} coap_endpoint_t; - -/** -* Create a new endpoint for communicating with peers. -* -* @param context The coap context that will own the new endpoint -* @param listen_addr Address the endpoint will listen for incoming requests on or originate outgoing requests from. Use NULL to specify that no incoming request will be accepted and use a random endpoint. -* @param proto Protocol used on this endpoint -*/ - -coap_endpoint_t *coap_new_endpoint(struct coap_context_t *context, const coap_address_t *listen_addr, coap_proto_t proto); - -/** -* Set the endpoint's default MTU. This is the maximum message size that can be -* sent, excluding IP and UDP overhead. -* -* @param endpoint The CoAP endpoint. -* @param mtu maximum message size -*/ -void coap_endpoint_set_default_mtu(coap_endpoint_t *endpoint, unsigned mtu); - -void coap_free_endpoint(coap_endpoint_t *ep); - - -/** - * @ingroup logging -* Get endpoint description. -* -* @param endpoint The CoAP endpoint. -* @return description string. -*/ -const char *coap_endpoint_str(const coap_endpoint_t *endpoint); - -/** -* Lookup the server session for the packet received on an endpoint, or create -* a new one. -* -* @param endpoint Active endpoint the packet was received on. -* @param packet Received packet. -* @param now The current time in ticks. -* @return The CoAP session or @c NULL if error. -*/ -coap_session_t *coap_endpoint_get_session(coap_endpoint_t *endpoint, - const struct coap_packet_t *packet, coap_tick_t now); - -/** - * Create a new DTLS session for the @p session. - * Note: the @p session is released if no DTLS server session can be created. - * - * @ingroup dtls_internal - * - * @param session Session to add DTLS session to - * @param now The current time in ticks. - * - * @return CoAP session or @c NULL if error. - */ -coap_session_t *coap_session_new_dtls_session(coap_session_t *session, - coap_tick_t now); - -coap_session_t *coap_session_get_by_peer(struct coap_context_t *ctx, - const struct coap_address_t *remote_addr, int ifindex); - -void coap_session_free(coap_session_t *session); -void coap_session_mfree(coap_session_t *session); - - /** - * @defgroup cc Rate Control - * The transmission parameters for CoAP rate control ("Congestion - * Control" in stream-oriented protocols) are defined in - * https://tools.ietf.org/html/rfc7252#section-4.8 - * @{ - */ - - /** - * Number of seconds when to expect an ACK or a response to an - * outstanding CON message. - * RFC 7252, Section 4.8 Default value of ACK_TIMEOUT is 2 - */ -#define COAP_DEFAULT_ACK_TIMEOUT ((coap_fixed_point_t){2,0}) - - /** - * A factor that is used to randomize the wait time before a message - * is retransmitted to prevent synchronization effects. - * RFC 7252, Section 4.8 Default value of ACK_RANDOM_FACTOR is 1.5 - */ -#define COAP_DEFAULT_ACK_RANDOM_FACTOR ((coap_fixed_point_t){1,500}) - - /** - * Number of message retransmissions before message sending is stopped - * RFC 7252, Section 4.8 Default value of MAX_RETRANSMIT is 4 - */ -#define COAP_DEFAULT_MAX_RETRANSMIT 4 - - /** - * The number of simultaneous outstanding interactions that a client - * maintains to a given server. - * RFC 7252, Section 4.8 Default value of NSTART is 1 - */ -#define COAP_DEFAULT_NSTART 1 - - /** @} */ - -/** -* Set the CoAP maximum retransmit count before failure -* -* Number of message retransmissions before message sending is stopped -* -* @param session The CoAP session. -* @param value The value to set to. The default is 4 and should not normally -* get changed. -*/ -void coap_session_set_max_retransmit(coap_session_t *session, - unsigned int value); - -/** -* Set the CoAP initial ack response timeout before the next re-transmit -* -* Number of seconds when to expect an ACK or a response to an -* outstanding CON message. -* -* @param session The CoAP session. -* @param value The value to set to. The default is 2 and should not normally -* get changed. -*/ -void coap_session_set_ack_timeout(coap_session_t *session, - coap_fixed_point_t value); - -/** -* Set the CoAP ack randomize factor -* -* A factor that is used to randomize the wait time before a message -* is retransmitted to prevent synchronization effects. -* -* @param session The CoAP session. -* @param value The value to set to. The default is 1.5 and should not normally -* get changed. -*/ -void coap_session_set_ack_random_factor(coap_session_t *session, - coap_fixed_point_t value); - -/** -* Get the CoAP maximum retransmit before failure -* -* Number of message retransmissions before message sending is stopped -* -* @param session The CoAP session. -* -* @return Current maximum retransmit value -*/ -unsigned int coap_session_get_max_transmit(coap_session_t *session); - -/** -* Get the CoAP initial ack response timeout before the next re-transmit -* -* Number of seconds when to expect an ACK or a response to an -* outstanding CON message. -* -* @param session The CoAP session. -* -* @return Current ack response timeout value -*/ -coap_fixed_point_t coap_session_get_ack_timeout(coap_session_t *session); - -/** -* Get the CoAP ack randomize factor -* -* A factor that is used to randomize the wait time before a message -* is retransmitted to prevent synchronization effects. -* -* @param session The CoAP session. -* -* @return Current ack randomize value -*/ -coap_fixed_point_t coap_session_get_ack_random_factor(coap_session_t *session); - -/** - * Send a ping message for the session. - * @param session The CoAP session. - * - * @return COAP_INVALID_TID if there is an error - */ -coap_tid_t coap_session_send_ping(coap_session_t *session); - -#endif /* COAP_SESSION_H */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap2/net.h b/tools/sdk/esp32/include/coap/libcoap/include/coap2/net.h deleted file mode 100644 index 7fccf3326c7..00000000000 --- a/tools/sdk/esp32/include/coap/libcoap/include/coap2/net.h +++ /dev/null @@ -1,746 +0,0 @@ -/* - * net.h -- CoAP network interface - * - * Copyright (C) 2010-2015 Olaf Bergmann - * - * This file is part of the CoAP library libcoap. Please see README for terms - * of use. - */ - -#ifndef COAP_NET_H_ -#define COAP_NET_H_ - -#include -#include -#include -#ifndef _WIN32 -#include -#endif -#include - -#ifdef WITH_LWIP -#include -#endif - -#include "coap_io.h" -#include "coap_dtls.h" -#include "coap_event.h" -#include "coap_time.h" -#include "option.h" -#include "pdu.h" -#include "prng.h" -#include "coap_session.h" - -struct coap_queue_t; - -/** - * Queue entry - */ -typedef struct coap_queue_t { - struct coap_queue_t *next; - coap_tick_t t; /**< when to send PDU for the next time */ - unsigned char retransmit_cnt; /**< retransmission counter, will be removed - * when zero */ - unsigned int timeout; /**< the randomized timeout value */ - coap_session_t *session; /**< the CoAP session */ - coap_tid_t id; /**< CoAP transaction id */ - coap_pdu_t *pdu; /**< the CoAP PDU to send */ -} coap_queue_t; - -/** - * Adds @p node to given @p queue, ordered by variable t in @p node. - * - * @param queue Queue to add to. - * @param node Node entry to add to Queue. - * - * @return @c 1 added to queue, @c 0 failure. - */ -int coap_insert_node(coap_queue_t **queue, coap_queue_t *node); - -/** - * Destroys specified @p node. - * - * @param node Node entry to remove. - * - * @return @c 1 node deleted from queue, @c 0 failure. - */ -int coap_delete_node(coap_queue_t *node); - -/** - * Removes all items from given @p queue and frees the allocated storage. - * - * @param queue The queue to delete. - */ -void coap_delete_all(coap_queue_t *queue); - -/** - * Creates a new node suitable for adding to the CoAP sendqueue. - * - * @return New node entry, or @c NULL if failure. - */ -coap_queue_t *coap_new_node(void); - -struct coap_resource_t; -struct coap_context_t; -#ifndef WITHOUT_ASYNC -struct coap_async_state_t; -#endif - -/** - * Response handler that is used as call-back in coap_context_t. - * - * @param context CoAP session. - * @param session CoAP session. - * @param sent The PDU that was transmitted. - * @param received The PDU that was received. - * @param id CoAP transaction ID. - */ -typedef void (*coap_response_handler_t)(struct coap_context_t *context, - coap_session_t *session, - coap_pdu_t *sent, - coap_pdu_t *received, - const coap_tid_t id); - -/** - * Negative Acknowedge handler that is used as call-back in coap_context_t. - * - * @param context CoAP session. - * @param session CoAP session. - * @param sent The PDU that was transmitted. - * @param reason The reason for the NACK. - * @param id CoAP transaction ID. - */ -typedef void (*coap_nack_handler_t)(struct coap_context_t *context, - coap_session_t *session, - coap_pdu_t *sent, - coap_nack_reason_t reason, - const coap_tid_t id); - -/** - * Recieved Ping handler that is used as call-back in coap_context_t. - * - * @param context CoAP session. - * @param session CoAP session. - * @param received The PDU that was received. - * @param id CoAP transaction ID. - */ -typedef void (*coap_ping_handler_t)(struct coap_context_t *context, - coap_session_t *session, - coap_pdu_t *received, - const coap_tid_t id); - -/** - * Recieved Pong handler that is used as call-back in coap_context_t. - * - * @param context CoAP session. - * @param session CoAP session. - * @param received The PDU that was received. - * @param id CoAP transaction ID. - */ -typedef void (*coap_pong_handler_t)(struct coap_context_t *context, - coap_session_t *session, - coap_pdu_t *received, - const coap_tid_t id); - -/** - * The CoAP stack's global state is stored in a coap_context_t object. - */ -typedef struct coap_context_t { - coap_opt_filter_t known_options; - struct coap_resource_t *resources; /**< hash table or list of known - resources */ - struct coap_resource_t *unknown_resource; /**< can be used for handling - unknown resources */ - -#ifndef WITHOUT_ASYNC - /** - * list of asynchronous transactions */ - struct coap_async_state_t *async_state; -#endif /* WITHOUT_ASYNC */ - - /** - * The time stamp in the first element of the sendqeue is relative - * to sendqueue_basetime. */ - coap_tick_t sendqueue_basetime; - coap_queue_t *sendqueue; - coap_endpoint_t *endpoint; /**< the endpoints used for listening */ - coap_session_t *sessions; /**< client sessions */ - -#ifdef WITH_CONTIKI - struct uip_udp_conn *conn; /**< uIP connection object */ - struct etimer retransmit_timer; /**< fires when the next packet must be sent */ - struct etimer notify_timer; /**< used to check resources periodically */ -#endif /* WITH_CONTIKI */ - -#ifdef WITH_LWIP - uint8_t timer_configured; /**< Set to 1 when a retransmission is - * scheduled using lwIP timers for this - * context, otherwise 0. */ -#endif /* WITH_LWIP */ - - coap_response_handler_t response_handler; - coap_nack_handler_t nack_handler; - coap_ping_handler_t ping_handler; - coap_pong_handler_t pong_handler; - - /** - * Callback function that is used to signal events to the - * application. This field is set by coap_set_event_handler(). - */ - coap_event_handler_t handle_event; - - ssize_t (*network_send)(coap_socket_t *sock, const coap_session_t *session, const uint8_t *data, size_t datalen); - - ssize_t (*network_read)(coap_socket_t *sock, struct coap_packet_t *packet); - - size_t(*get_client_psk)(const coap_session_t *session, const uint8_t *hint, size_t hint_len, uint8_t *identity, size_t *identity_len, size_t max_identity_len, uint8_t *psk, size_t max_psk_len); - size_t(*get_server_psk)(const coap_session_t *session, const uint8_t *identity, size_t identity_len, uint8_t *psk, size_t max_psk_len); - size_t(*get_server_hint)(const coap_session_t *session, uint8_t *hint, size_t max_hint_len); - - void *dtls_context; - uint8_t *psk_hint; - size_t psk_hint_len; - uint8_t *psk_key; - size_t psk_key_len; - - unsigned int session_timeout; /**< Number of seconds of inactivity after which an unused session will be closed. 0 means use default. */ - unsigned int max_idle_sessions; /**< Maximum number of simultaneous unused sessions per endpoint. 0 means no maximum. */ - unsigned int max_handshake_sessions; /**< Maximum number of simultaneous negotating sessions per endpoint. 0 means use default. */ - unsigned int ping_timeout; /**< Minimum inactivity time before sending a ping message. 0 means disabled. */ - unsigned int csm_timeout; /**< Timeout for waiting for a CSM from the remote side. 0 means disabled. */ - - void *app; /**< application-specific data */ -} coap_context_t; - -/** - * Registers a new message handler that is called whenever a response was - * received that matches an ongoing transaction. - * - * @param context The context to register the handler for. - * @param handler The response handler to register. - */ -COAP_STATIC_INLINE void -coap_register_response_handler(coap_context_t *context, - coap_response_handler_t handler) { - context->response_handler = handler; -} - -/** - * Registers a new message handler that is called whenever a confirmable - * message (request or response) is dropped after all retries have been - * exhausted, or a rst message was received, or a network or TLS level - * event was received that indicates delivering the message is not possible. - * - * @param context The context to register the handler for. - * @param handler The nack handler to register. - */ -COAP_STATIC_INLINE void -coap_register_nack_handler(coap_context_t *context, - coap_nack_handler_t handler) { - context->nack_handler = handler; -} - -/** - * Registers a new message handler that is called whenever a CoAP Ping - * message is received. - * - * @param context The context to register the handler for. - * @param handler The ping handler to register. - */ -COAP_STATIC_INLINE void -coap_register_ping_handler(coap_context_t *context, - coap_ping_handler_t handler) { - context->ping_handler = handler; -} - -/** - * Registers a new message handler that is called whenever a CoAP Pong - * message is received. - * - * @param context The context to register the handler for. - * @param handler The pong handler to register. - */ -COAP_STATIC_INLINE void -coap_register_pong_handler(coap_context_t *context, - coap_pong_handler_t handler) { - context->pong_handler = handler; -} - -/** - * Registers the option type @p type with the given context object @p ctx. - * - * @param ctx The context to use. - * @param type The option type to register. - */ -COAP_STATIC_INLINE void -coap_register_option(coap_context_t *ctx, uint16_t type) { - coap_option_setb(ctx->known_options, type); -} - -/** - * Set sendqueue_basetime in the given context object @p ctx to @p now. This - * function returns the number of elements in the queue head that have timed - * out. - */ -unsigned int coap_adjust_basetime(coap_context_t *ctx, coap_tick_t now); - -/** - * Returns the next pdu to send without removing from sendqeue. - */ -coap_queue_t *coap_peek_next( coap_context_t *context ); - -/** - * Returns the next pdu to send and removes it from the sendqeue. - */ -coap_queue_t *coap_pop_next( coap_context_t *context ); - -/** - * Creates a new coap_context_t object that will hold the CoAP stack status. - */ -coap_context_t *coap_new_context(const coap_address_t *listen_addr); - -/** - * Set the context's default PSK hint and/or key for a server. - * - * @param context The current coap_context_t object. - * @param hint The default PSK server hint sent to a client. If @p NULL, PSK - * authentication is disabled. Empty string is a valid hint. - * @param key The default PSK key. If @p NULL, PSK authentication will fail. - * @param key_len The default PSK key's length. If @p 0, PSK authentication will - * fail. - * - * @return @c 1 if successful, else @c 0. - */ -int coap_context_set_psk( coap_context_t *context, const char *hint, - const uint8_t *key, size_t key_len ); - -/** - * Set the context's default PKI information for a server. - * - * @param context The current coap_context_t object. - * @param setup_data If @p NULL, PKI authentication will fail. Certificate - * information required. - * - * @return @c 1 if successful, else @c 0. - */ -int -coap_context_set_pki(coap_context_t *context, - coap_dtls_pki_t *setup_data); - -/** - * Set the context's default Root CA information for a client or server. - * - * @param context The current coap_context_t object. - * @param ca_file If not @p NULL, is the full path name of a PEM encoded - * file containing all the Root CAs to be used. - * @param ca_dir If not @p NULL, points to a directory containing PEM - * encoded files containing all the Root CAs to be used. - * - * @return @c 1 if successful, else @c 0. - */ -int -coap_context_set_pki_root_cas(coap_context_t *context, - const char *ca_file, - const char *ca_dir); - -/** - * Set the context keepalive timer for sessions. - * A keepalive message will be sent after if a session has been inactive, - * i.e. no packet sent or received, for the given number of seconds. - * For reliable protocols, a PING message will be sent. If a PONG has not - * been received before the next PING is due to be sent, the session will - * considered as disconnected. - * - * @param context The coap_context_t object. - * @param seconds Number of seconds for the inactivity timer, or zero - * to disable CoAP-level keepalive messages. - * - * @return 1 if successful, else 0 - */ -void coap_context_set_keepalive(coap_context_t *context, unsigned int seconds); - -/** - * Returns a new message id and updates @p session->tx_mid accordingly. The - * message id is returned in network byte order to make it easier to read in - * tracing tools. - * - * @param session The current coap_session_t object. - * - * @return Incremented message id in network byte order. - */ -COAP_STATIC_INLINE uint16_t -coap_new_message_id(coap_session_t *session) { - return ++session->tx_mid; -} - -/** - * CoAP stack context must be released with coap_free_context(). This function - * clears all entries from the receive queue and send queue and deletes the - * resources that have been registered with @p context, and frees the attached - * endpoints. - * - * @param context The current coap_context_t object to free off. - */ -void coap_free_context(coap_context_t *context); - -/** - * Stores @p data with the given CoAP context. This function - * overwrites any value that has previously been stored with @p - * context. - * - * @param context The CoAP context. - * @param data The data to store with wih the context. Note that this data - * must be valid during the lifetime of @p context. - */ -void coap_set_app_data(coap_context_t *context, void *data); - -/** - * Returns any application-specific data that has been stored with @p - * context using the function coap_set_app_data(). This function will - * return @c NULL if no data has been stored. - * - * @param context The CoAP context. - * - * @return The data previously stored or @c NULL if not data stored. - */ -void *coap_get_app_data(const coap_context_t *context); - -/** - * Creates a new ACK PDU with specified error @p code. The options specified by - * the filter expression @p opts will be copied from the original request - * contained in @p request. Unless @c SHORT_ERROR_RESPONSE was defined at build - * time, the textual reason phrase for @p code will be added as payload, with - * Content-Type @c 0. - * This function returns a pointer to the new response message, or @c NULL on - * error. The storage allocated for the new message must be relased with - * coap_free(). - * - * @param request Specification of the received (confirmable) request. - * @param code The error code to set. - * @param opts An option filter that specifies which options to copy from - * the original request in @p node. - * - * @return A pointer to the new message or @c NULL on error. - */ -coap_pdu_t *coap_new_error_response(coap_pdu_t *request, - unsigned char code, - coap_opt_filter_t opts); - -/** - * Sends an error response with code @p code for request @p request to @p dst. - * @p opts will be passed to coap_new_error_response() to copy marked options - * from the request. This function returns the transaction id if the message was - * sent, or @c COAP_INVALID_TID otherwise. - * - * @param session The CoAP session. - * @param request The original request to respond to. - * @param code The response code. - * @param opts A filter that specifies the options to copy from the - * @p request. - * - * @return The transaction id if the message was sent, or @c - * COAP_INVALID_TID otherwise. - */ -coap_tid_t coap_send_error(coap_session_t *session, - coap_pdu_t *request, - unsigned char code, - coap_opt_filter_t opts); - -/** - * Helper funktion to create and send a message with @p type (usually ACK or - * RST). This function returns @c COAP_INVALID_TID when the message was not - * sent, a valid transaction id otherwise. - * - * @param session The CoAP session. - * @param request The request that should be responded to. - * @param type Which type to set. - * @return transaction id on success or @c COAP_INVALID_TID - * otherwise. - */ -coap_tid_t -coap_send_message_type(coap_session_t *session, coap_pdu_t *request, unsigned char type); - -/** - * Sends an ACK message with code @c 0 for the specified @p request to @p dst. - * This function returns the corresponding transaction id if the message was - * sent or @c COAP_INVALID_TID on error. - * - * @param session The CoAP session. - * @param request The request to be acknowledged. - * - * @return The transaction id if ACK was sent or @c - * COAP_INVALID_TID on error. - */ -coap_tid_t coap_send_ack(coap_session_t *session, coap_pdu_t *request); - -/** - * Sends an RST message with code @c 0 for the specified @p request to @p dst. - * This function returns the corresponding transaction id if the message was - * sent or @c COAP_INVALID_TID on error. - * - * @param session The CoAP session. - * @param request The request to be reset. - * - * @return The transaction id if RST was sent or @c - * COAP_INVALID_TID on error. - */ -COAP_STATIC_INLINE coap_tid_t -coap_send_rst(coap_session_t *session, coap_pdu_t *request) { - return coap_send_message_type(session, request, COAP_MESSAGE_RST); -} - -/** -* Sends a CoAP message to given peer. The memory that is -* allocated by pdu will be released by coap_send(). -* The caller must not use the pdu after calling coap_send(). -* -* @param session The CoAP session. -* @param pdu The CoAP PDU to send. -* -* @return The message id of the sent message or @c -* COAP_INVALID_TID on error. -*/ -coap_tid_t coap_send( coap_session_t *session, coap_pdu_t *pdu ); - -/** - * Handles retransmissions of confirmable messages - * - * @param context The CoAP context. - * @param node The node to retransmit. - * - * @return The message id of the sent message or @c - * COAP_INVALID_TID on error. - */ -coap_tid_t coap_retransmit(coap_context_t *context, coap_queue_t *node); - -/** -* For applications with their own message loop, send all pending retransmits and -* return the list of sockets with events to wait for and the next timeout -* The application should call coap_read, then coap_write again when any condition below is true: -* - data is available on any of the sockets with the COAP_SOCKET_WANT_READ -* - an incoming connection is pending in the listen queue and the COAP_SOCKET_WANT_ACCEPT flag is set -* - at least some data can be written without blocking on any of the sockets with the COAP_SOCKET_WANT_WRITE flag set -* - a connection event occured (success or failure) and the COAP_SOCKET_WANT_CONNECT flag is set -* - the timeout has expired -* Before calling coap_read or coap_write again, the application should position COAP_SOCKET_CAN_READ and COAP_SOCKET_CAN_WRITE flags as applicable. -* -* @param ctx The CoAP context -* @param sockets array of socket descriptors, filled on output -* @param max_sockets size of socket array. -* @param num_sockets pointer to the number of valid entries in the socket arrays on output -* @param now Current time. -* -* @return timeout as maxmimum number of milliseconds that the application should wait for network events or 0 if the application should wait forever. -*/ - -unsigned int -coap_write(coap_context_t *ctx, - coap_socket_t *sockets[], - unsigned int max_sockets, - unsigned int *num_sockets, - coap_tick_t now -); - -/** - * For applications with their own message loop, reads all data from the network. - * - * @param ctx The CoAP context - * @param now Current time - */ -void coap_read(coap_context_t *ctx, coap_tick_t now); - -/** - * The main message processing loop. - * - * @param ctx The CoAP context - * @param timeout_ms Minimum number of milliseconds to wait for new messages before returning. If zero the call will block until at least one packet is sent or received. - * - * @return number of milliseconds spent or @c -1 if there was an error - */ - -int coap_run_once( coap_context_t *ctx, unsigned int timeout_ms ); - -/** - * Parses and interprets a CoAP datagram with context @p ctx. This function - * returns @c 0 if the datagram was handled, or a value less than zero on - * error. - * - * @param ctx The current CoAP context. - * @param session The current CoAP session. - * @param data The received packet'd data. - * @param data_len The received packet'd data length. - * - * @return @c 0 if message was handled successfully, or less than zero on - * error. - */ -int coap_handle_dgram(coap_context_t *ctx, coap_session_t *session, uint8_t *data, size_t data_len); - -/** - * Invokes the event handler of @p context for the given @p event and - * @p data. - * - * @param context The CoAP context whose event handler is to be called. - * @param event The event to deliver. - * @param session The session related to @p event. - * @return The result from the associated event handler or 0 if none was - * registered. - */ -int coap_handle_event(coap_context_t *context, - coap_event_t event, - coap_session_t *session); -/** - * This function removes the element with given @p id from the list given list. - * If @p id was found, @p node is updated to point to the removed element. Note - * that the storage allocated by @p node is @b not released. The caller must do - * this manually using coap_delete_node(). This function returns @c 1 if the - * element with id @p id was found, @c 0 otherwise. For a return value of @c 0, - * the contents of @p node is undefined. - * - * @param queue The queue to search for @p id. - * @param session The session to look for. - * @param id The transaction id to look for. - * @param node If found, @p node is updated to point to the removed node. You - * must release the storage pointed to by @p node manually. - * - * @return @c 1 if @p id was found, @c 0 otherwise. - */ -int coap_remove_from_queue(coap_queue_t **queue, - coap_session_t *session, - coap_tid_t id, - coap_queue_t **node); - -coap_tid_t -coap_wait_ack( coap_context_t *context, coap_session_t *session, - coap_queue_t *node); - -/** - * Retrieves transaction from the queue. - * - * @param queue The transaction queue to be searched. - * @param session The session to find. - * @param id The transaction id to find. - * - * @return A pointer to the transaction object or @c NULL if not found. - */ -coap_queue_t *coap_find_transaction(coap_queue_t *queue, coap_session_t *session, coap_tid_t id); - -/** - * Cancels all outstanding messages for session @p session that have the specified - * token. - * - * @param context The context in use. - * @param session Session of the messages to remove. - * @param token Message token. - * @param token_length Actual length of @p token. - */ -void coap_cancel_all_messages(coap_context_t *context, - coap_session_t *session, - const uint8_t *token, - size_t token_length); - -/** -* Cancels all outstanding messages for session @p session. -* -* @param context The context in use. -* @param session Session of the messages to remove. -* @param reason The reasion for the session cancellation -*/ -void -coap_cancel_session_messages(coap_context_t *context, - coap_session_t *session, - coap_nack_reason_t reason); - -/** - * Dispatches the PDUs from the receive queue in given context. - */ -void coap_dispatch(coap_context_t *context, coap_session_t *session, - coap_pdu_t *pdu); - -/** - * Returns 1 if there are no messages to send or to dispatch in the context's - * queues. */ -int coap_can_exit(coap_context_t *context); - -/** - * Returns the current value of an internal tick counter. The counter counts \c - * COAP_TICKS_PER_SECOND ticks every second. - */ -void coap_ticks(coap_tick_t *); - -/** - * Verifies that @p pdu contains no unknown critical options. Options must be - * registered at @p ctx, using the function coap_register_option(). A basic set - * of options is registered automatically by coap_new_context(). This function - * returns @c 1 if @p pdu is ok, @c 0 otherwise. The given filter object @p - * unknown will be updated with the unknown options. As only @c COAP_MAX_OPT - * options can be signalled this way, remaining options must be examined - * manually. - * - * @code - coap_opt_filter_t f = COAP_OPT_NONE; - coap_opt_iterator_t opt_iter; - - if (coap_option_check_critical(ctx, pdu, f) == 0) { - coap_option_iterator_init(pdu, &opt_iter, f); - - while (coap_option_next(&opt_iter)) { - if (opt_iter.type & 0x01) { - ... handle unknown critical option in opt_iter ... - } - } - } - @endcode - * - * @param ctx The context where all known options are registered. - * @param pdu The PDU to check. - * @param unknown The output filter that will be updated to indicate the - * unknown critical options found in @p pdu. - * - * @return @c 1 if everything was ok, @c 0 otherwise. - */ -int coap_option_check_critical(coap_context_t *ctx, - coap_pdu_t *pdu, - coap_opt_filter_t unknown); - -/** - * Creates a new response for given @p request with the contents of @c - * .well-known/core. The result is NULL on error or a newly allocated PDU that - * must be either sent with coap_sent() or released by coap_delete_pdu(). - * - * @param context The current coap context to use. - * @param session The CoAP session. - * @param request The request for @c .well-known/core . - * - * @return A new 2.05 response for @c .well-known/core or NULL on error. - */ -coap_pdu_t *coap_wellknown_response(coap_context_t *context, - coap_session_t *session, - coap_pdu_t *request); - -/** - * Calculates the initial timeout based on the session CoAP transmission - * parameters 'ack_timeout', 'ack_random_factor', and COAP_TICKS_PER_SECOND. - * The calculation requires 'ack_timeout' and 'ack_random_factor' to be in - * Qx.FRAC_BITS fixed point notation, whereas the passed parameter @p r - * is interpreted as the fractional part of a Q0.MAX_BITS random value. - * - * @param session session timeout is associated with - * @param r random value as fractional part of a Q0.MAX_BITS fixed point - * value - * @return COAP_TICKS_PER_SECOND * 'ack_timeout' * - * (1 + ('ack_random_factor' - 1) * r) - */ -unsigned int coap_calc_timeout(coap_session_t *session, unsigned char r); - -/** - * Function interface for joining a multicast group for listening - * - * @param ctx The current context - * @param groupname The name of the group that is to be joined for listening - * - * @return 0 on success, -1 on error - */ -int -coap_join_mcast_group(coap_context_t *ctx, const char *groupname); - -#endif /* COAP_NET_H_ */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap2/pdu.h b/tools/sdk/esp32/include/coap/libcoap/include/coap2/pdu.h deleted file mode 100644 index 206e2643543..00000000000 --- a/tools/sdk/esp32/include/coap/libcoap/include/coap2/pdu.h +++ /dev/null @@ -1,543 +0,0 @@ -/* - * pdu.h -- CoAP message structure - * - * Copyright (C) 2010-2014 Olaf Bergmann - * - * This file is part of the CoAP library libcoap. Please see README for terms - * of use. - */ - -/** - * @file pdu.h - * @brief Pre-defined constants that reflect defaults for CoAP - */ - -#ifndef COAP_PDU_H_ -#define COAP_PDU_H_ - -#include "uri.h" - -struct coap_session_t; - -#ifdef WITH_LWIP -#include -#endif - -#include - -#define COAP_DEFAULT_PORT 5683 /* CoAP default UDP/TCP port */ -#define COAPS_DEFAULT_PORT 5684 /* CoAP default UDP/TCP port for secure transmission */ -#define COAP_DEFAULT_MAX_AGE 60 /* default maximum object lifetime in seconds */ -#ifndef COAP_DEFAULT_MTU -#define COAP_DEFAULT_MTU 1152 -#endif /* COAP_DEFAULT_MTU */ - -/* TCP Message format constants, do not modify */ -#define COAP_MESSAGE_SIZE_OFFSET_TCP8 13 -#define COAP_MESSAGE_SIZE_OFFSET_TCP16 269 /* 13 + 256 */ -#define COAP_MESSAGE_SIZE_OFFSET_TCP32 65805 /* 269 + 65536 */ - -/* Derived message size limits */ -#define COAP_MAX_MESSAGE_SIZE_TCP0 (COAP_MESSAGE_SIZE_OFFSET_TCP8-1) /* 12 */ -#define COAP_MAX_MESSAGE_SIZE_TCP8 (COAP_MESSAGE_SIZE_OFFSET_TCP16-1) /* 268 */ -#define COAP_MAX_MESSAGE_SIZE_TCP16 (COAP_MESSAGE_SIZE_OFFSET_TCP32-1) /* 65804 */ -#define COAP_MAX_MESSAGE_SIZE_TCP32 (COAP_MESSAGE_SIZE_OFFSET_TCP32+0xFFFFFFFF) - -#ifndef COAP_DEFAULT_MAX_PDU_RX_SIZE -#if defined(WITH_CONTIKI) || defined(WITH_LWIP) -#define COAP_DEFAULT_MAX_PDU_RX_SIZE (COAP_MAX_MESSAGE_SIZE_TCP16+4) -#else -/* 8 MiB max-message-size plus some space for options */ -#define COAP_DEFAULT_MAX_PDU_RX_SIZE (8*1024*1024+256) -#endif -#endif /* COAP_DEFAULT_MAX_PDU_RX_SIZE */ - -#ifndef COAP_DEBUG_BUF_SIZE -#if defined(WITH_CONTIKI) || defined(WITH_LWIP) -#define COAP_DEBUG_BUF_SIZE 128 -#else /* defined(WITH_CONTIKI) || defined(WITH_LWIP) */ -/* 1024 derived from RFC7252 4.6. Message Size max payload */ -#define COAP_DEBUG_BUF_SIZE (8 + 1024 * 2) -#endif /* defined(WITH_CONTIKI) || defined(WITH_LWIP) */ -#endif /* COAP_DEBUG_BUF_SIZE */ - -#define COAP_DEFAULT_VERSION 1 /* version of CoAP supported */ -#define COAP_DEFAULT_SCHEME "coap" /* the default scheme for CoAP URIs */ - -/** well-known resources URI */ -#define COAP_DEFAULT_URI_WELLKNOWN ".well-known/core" - -/* CoAP message types */ - -#define COAP_MESSAGE_CON 0 /* confirmable message (requires ACK/RST) */ -#define COAP_MESSAGE_NON 1 /* non-confirmable message (one-shot message) */ -#define COAP_MESSAGE_ACK 2 /* used to acknowledge confirmable messages */ -#define COAP_MESSAGE_RST 3 /* indicates error in received messages */ - -/* CoAP request methods */ - -#define COAP_REQUEST_GET 1 -#define COAP_REQUEST_POST 2 -#define COAP_REQUEST_PUT 3 -#define COAP_REQUEST_DELETE 4 -#define COAP_REQUEST_FETCH 5 /* RFC 8132 */ -#define COAP_REQUEST_PATCH 6 /* RFC 8132 */ -#define COAP_REQUEST_IPATCH 7 /* RFC 8132 */ - -/* - * CoAP option types (be sure to update coap_option_check_critical() when - * adding options - */ - -#define COAP_OPTION_IF_MATCH 1 /* C, opaque, 0-8 B, (none) */ -#define COAP_OPTION_URI_HOST 3 /* C, String, 1-255 B, destination address */ -#define COAP_OPTION_ETAG 4 /* E, opaque, 1-8 B, (none) */ -#define COAP_OPTION_IF_NONE_MATCH 5 /* empty, 0 B, (none) */ -#define COAP_OPTION_URI_PORT 7 /* C, uint, 0-2 B, destination port */ -#define COAP_OPTION_LOCATION_PATH 8 /* E, String, 0-255 B, - */ -#define COAP_OPTION_URI_PATH 11 /* C, String, 0-255 B, (none) */ -#define COAP_OPTION_CONTENT_FORMAT 12 /* E, uint, 0-2 B, (none) */ -#define COAP_OPTION_CONTENT_TYPE COAP_OPTION_CONTENT_FORMAT -#define COAP_OPTION_MAXAGE 14 /* E, uint, 0--4 B, 60 Seconds */ -#define COAP_OPTION_URI_QUERY 15 /* C, String, 1-255 B, (none) */ -#define COAP_OPTION_ACCEPT 17 /* C, uint, 0-2 B, (none) */ -#define COAP_OPTION_LOCATION_QUERY 20 /* E, String, 0-255 B, (none) */ -#define COAP_OPTION_SIZE2 28 /* E, uint, 0-4 B, (none) */ -#define COAP_OPTION_PROXY_URI 35 /* C, String, 1-1034 B, (none) */ -#define COAP_OPTION_PROXY_SCHEME 39 /* C, String, 1-255 B, (none) */ -#define COAP_OPTION_SIZE1 60 /* E, uint, 0-4 B, (none) */ - -/* option types from RFC 7641 */ - -#define COAP_OPTION_OBSERVE 6 /* E, empty/uint, 0 B/0-3 B, (none) */ -#define COAP_OPTION_SUBSCRIPTION COAP_OPTION_OBSERVE - -/* selected option types from RFC 7959 */ - -#define COAP_OPTION_BLOCK2 23 /* C, uint, 0--3 B, (none) */ -#define COAP_OPTION_BLOCK1 27 /* C, uint, 0--3 B, (none) */ - -/* selected option types from RFC 7967 */ - -#define COAP_OPTION_NORESPONSE 258 /* N, uint, 0--1 B, 0 */ - -#define COAP_MAX_OPT 65535 /**< the highest option number we know */ - -/* CoAP result codes (HTTP-Code / 100 * 40 + HTTP-Code % 100) */ - -/* As of draft-ietf-core-coap-04, response codes are encoded to base - * 32, i.e. the three upper bits determine the response class while - * the remaining five fine-grained information specific to that class. - */ -#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100) - -/* Determines the class of response code C */ -#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF) - -#ifndef SHORT_ERROR_RESPONSE -/** - * Returns a human-readable response phrase for the specified CoAP response @p - * code. This function returns @c NULL if not found. - * - * @param code The response code for which the literal phrase should be - * retrieved. - * - * @return A zero-terminated string describing the error, or @c NULL if not - * found. - */ -const char *coap_response_phrase(unsigned char code); - -#define COAP_ERROR_PHRASE_LENGTH 32 /**< maximum length of error phrase */ - -#else -#define coap_response_phrase(x) ((char *)NULL) - -#define COAP_ERROR_PHRASE_LENGTH 0 /**< maximum length of error phrase */ -#endif /* SHORT_ERROR_RESPONSE */ - -/* The following definitions exist for backwards compatibility */ -#if 0 /* this does not exist any more */ -#define COAP_RESPONSE_100 40 /* 100 Continue */ -#endif -#define COAP_RESPONSE_200 COAP_RESPONSE_CODE(200) /* 2.00 OK */ -#define COAP_RESPONSE_201 COAP_RESPONSE_CODE(201) /* 2.01 Created */ -#define COAP_RESPONSE_304 COAP_RESPONSE_CODE(203) /* 2.03 Valid */ -#define COAP_RESPONSE_400 COAP_RESPONSE_CODE(400) /* 4.00 Bad Request */ -#define COAP_RESPONSE_404 COAP_RESPONSE_CODE(404) /* 4.04 Not Found */ -#define COAP_RESPONSE_405 COAP_RESPONSE_CODE(405) /* 4.05 Method Not Allowed */ -#define COAP_RESPONSE_415 COAP_RESPONSE_CODE(415) /* 4.15 Unsupported Media Type */ -#define COAP_RESPONSE_500 COAP_RESPONSE_CODE(500) /* 5.00 Internal Server Error */ -#define COAP_RESPONSE_501 COAP_RESPONSE_CODE(501) /* 5.01 Not Implemented */ -#define COAP_RESPONSE_503 COAP_RESPONSE_CODE(503) /* 5.03 Service Unavailable */ -#define COAP_RESPONSE_504 COAP_RESPONSE_CODE(504) /* 5.04 Gateway Timeout */ -#if 0 /* these response codes do not have a valid code any more */ -# define COAP_RESPONSE_X_240 240 /* Token Option required by server */ -# define COAP_RESPONSE_X_241 241 /* Uri-Authority Option required by server */ -#endif -#define COAP_RESPONSE_X_242 COAP_RESPONSE_CODE(402) /* Critical Option not supported */ - -#define COAP_SIGNALING_CODE(N) (((N)/100 << 5) | (N)%100) -#define COAP_SIGNALING_CSM COAP_SIGNALING_CODE(701) -#define COAP_SIGNALING_PING COAP_SIGNALING_CODE(702) -#define COAP_SIGNALING_PONG COAP_SIGNALING_CODE(703) -#define COAP_SIGNALING_RELEASE COAP_SIGNALING_CODE(704) -#define COAP_SIGNALING_ABORT COAP_SIGNALING_CODE(705) - -/* Applies to COAP_SIGNALING_CSM */ -#define COAP_SIGNALING_OPTION_MAX_MESSAGE_SIZE 2 -#define COAP_SIGNALING_OPTION_BLOCK_WISE_TRANSFER 4 -/* Applies to COAP_SIGNALING_PING / COAP_SIGNALING_PONG */ -#define COAP_SIGNALING_OPTION_CUSTODY 2 -/* Applies to COAP_SIGNALING_RELEASE */ -#define COAP_SIGNALING_OPTION_ALTERNATIVE_ADDRESS 2 -#define COAP_SIGNALING_OPTION_HOLD_OFF 4 -/* Applies to COAP_SIGNALING_ABORT */ -#define COAP_SIGNALING_OPTION_BAD_CSM_OPTION 2 - -/* CoAP media type encoding */ - -#define COAP_MEDIATYPE_TEXT_PLAIN 0 /* text/plain (UTF-8) */ -#define COAP_MEDIATYPE_APPLICATION_LINK_FORMAT 40 /* application/link-format */ -#define COAP_MEDIATYPE_APPLICATION_XML 41 /* application/xml */ -#define COAP_MEDIATYPE_APPLICATION_OCTET_STREAM 42 /* application/octet-stream */ -#define COAP_MEDIATYPE_APPLICATION_RDF_XML 43 /* application/rdf+xml */ -#define COAP_MEDIATYPE_APPLICATION_EXI 47 /* application/exi */ -#define COAP_MEDIATYPE_APPLICATION_JSON 50 /* application/json */ -#define COAP_MEDIATYPE_APPLICATION_CBOR 60 /* application/cbor */ - -/* Content formats from RFC 8152 */ -#define COAP_MEDIATYPE_APPLICATION_COSE_SIGN 98 /* application/cose; cose-type="cose-sign" */ -#define COAP_MEDIATYPE_APPLICATION_COSE_SIGN1 18 /* application/cose; cose-type="cose-sign1" */ -#define COAP_MEDIATYPE_APPLICATION_COSE_ENCRYPT 96 /* application/cose; cose-type="cose-encrypt" */ -#define COAP_MEDIATYPE_APPLICATION_COSE_ENCRYPT0 16 /* application/cose; cose-type="cose-encrypt0" */ -#define COAP_MEDIATYPE_APPLICATION_COSE_MAC 97 /* application/cose; cose-type="cose-mac" */ -#define COAP_MEDIATYPE_APPLICATION_COSE_MAC0 17 /* application/cose; cose-type="cose-mac0" */ - -#define COAP_MEDIATYPE_APPLICATION_COSE_KEY 101 /* application/cose-key */ -#define COAP_MEDIATYPE_APPLICATION_COSE_KEY_SET 102 /* application/cose-key-set */ - -/* Content formats from RFC 8428 */ -#define COAP_MEDIATYPE_APPLICATION_SENML_JSON 110 /* application/senml+json */ -#define COAP_MEDIATYPE_APPLICATION_SENSML_JSON 111 /* application/sensml+json */ -#define COAP_MEDIATYPE_APPLICATION_SENML_CBOR 112 /* application/senml+cbor */ -#define COAP_MEDIATYPE_APPLICATION_SENSML_CBOR 113 /* application/sensml+cbor */ -#define COAP_MEDIATYPE_APPLICATION_SENML_EXI 114 /* application/senml-exi */ -#define COAP_MEDIATYPE_APPLICATION_SENSML_EXI 115 /* application/sensml-exi */ -#define COAP_MEDIATYPE_APPLICATION_SENML_XML 310 /* application/senml+xml */ -#define COAP_MEDIATYPE_APPLICATION_SENSML_XML 311 /* application/sensml+xml */ - -/* Note that identifiers for registered media types are in the range 0-65535. We - * use an unallocated type here and hope for the best. */ -#define COAP_MEDIATYPE_ANY 0xff /* any media type */ - -/** - * coap_tid_t is used to store CoAP transaction id, i.e. a hash value - * built from the remote transport address and the message id of a - * CoAP PDU. Valid transaction ids are greater or equal zero. - */ -typedef int coap_tid_t; - -/** Indicates an invalid transaction id. */ -#define COAP_INVALID_TID -1 - -/** - * Indicates that a response is suppressed. This will occur for error - * responses if the request was received via IP multicast. - */ -#define COAP_DROPPED_RESPONSE -2 - -#define COAP_PDU_DELAYED -3 - -#define COAP_OPT_LONG 0x0F /* OC == 0b1111 indicates that the option list - * in a CoAP message is limited by 0b11110000 - * marker */ - -#define COAP_OPT_END 0xF0 /* end marker */ - -#define COAP_PAYLOAD_START 0xFF /* payload marker */ - -/** - * @deprecated Use coap_optlist_t instead. - * - * Structures for more convenient handling of options. (To be used with ordered - * coap_list_t.) The option's data will be added to the end of the coap_option - * structure (see macro COAP_OPTION_DATA). - */ -COAP_DEPRECATED typedef struct { - uint16_t key; /* the option key (no delta coding) */ - unsigned int length; -} coap_option; - -#define COAP_OPTION_KEY(option) (option).key -#define COAP_OPTION_LENGTH(option) (option).length -#define COAP_OPTION_DATA(option) ((unsigned char *)&(option) + sizeof(coap_option)) - -/** - * structure for CoAP PDUs - * token, if any, follows the fixed size header, then options until - * payload marker (0xff), then the payload if stored inline. - * Memory layout is: - * <---header--->|<---token---><---options--->0xff<---payload---> - * header is addressed with a negative offset to token, its maximum size is - * max_hdr_size. - * options starts at token + token_length - * payload starts at data, its length is used_size - (data - token) - */ - -typedef struct coap_pdu_t { - uint8_t type; /**< message type */ - uint8_t code; /**< request method (value 1--10) or response code (value 40-255) */ - uint8_t max_hdr_size; /**< space reserved for protocol-specific header */ - uint8_t hdr_size; /**< actaul size used for protocol-specific header */ - uint8_t token_length; /**< length of Token */ - uint16_t tid; /**< transaction id, if any, in regular host byte order */ - uint16_t max_delta; /**< highest option number */ - size_t alloc_size; /**< allocated storage for token, options and payload */ - size_t used_size; /**< used bytes of storage for token, options and payload */ - size_t max_size; /**< maximum size for token, options and payload, or zero for variable size pdu */ - uint8_t *token; /**< first byte of token, if any, or options */ - uint8_t *data; /**< first byte of payload, if any */ -#ifdef WITH_LWIP - struct pbuf *pbuf; /**< lwIP PBUF. The package data will always reside - * inside the pbuf's payload, but this pointer - * has to be kept because no exact offset can be - * given. This field must not be accessed from - * outside, because the pbuf's reference count - * is checked to be 1 when the pbuf is assigned - * to the pdu, and the pbuf stays exclusive to - * this pdu. */ -#endif -} coap_pdu_t; - -#define COAP_PDU_IS_EMPTY(pdu) ((pdu)->code == 0) -#define COAP_PDU_IS_REQUEST(pdu) (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32) -#define COAP_PDU_IS_RESPONSE(pdu) ((pdu)->code >= 64 && (pdu)->code < 224) -#define COAP_PDU_IS_SIGNALING(pdu) ((pdu)->code >= 224) - -#define COAP_PDU_MAX_UDP_HEADER_SIZE 4 -#define COAP_PDU_MAX_TCP_HEADER_SIZE 6 - -#ifdef WITH_LWIP -/** - * Creates a CoAP PDU from an lwIP @p pbuf, whose reference is passed on to this - * function. - * - * The pbuf is checked for being contiguous, and for having only one reference. - * The reference is stored in the PDU and will be freed when the PDU is freed. - * - * (For now, these are fatal errors; in future, a new pbuf might be allocated, - * the data copied and the passed pbuf freed). - * - * This behaves like coap_pdu_init(0, 0, 0, pbuf->tot_len), and afterwards - * copying the contents of the pbuf to the pdu. - * - * @return A pointer to the new PDU object or @c NULL on error. - */ -coap_pdu_t * coap_pdu_from_pbuf(struct pbuf *pbuf); -#endif - -typedef uint8_t coap_proto_t; -/** -* coap_proto_t values -*/ -#define COAP_PROTO_NONE 0 -#define COAP_PROTO_UDP 1 -#define COAP_PROTO_DTLS 2 -#define COAP_PROTO_TCP 3 -#define COAP_PROTO_TLS 4 - -/** - * Creates a new CoAP PDU with at least enough storage space for the given - * @p size maximum message size. The function returns a pointer to the - * node coap_pdu_t object on success, or @c NULL on error. The storage allocated - * for the result must be released with coap_delete_pdu() if coap_send() is not - * called. - * - * @param type The type of the PDU (one of COAP_MESSAGE_CON, COAP_MESSAGE_NON, - * COAP_MESSAGE_ACK, COAP_MESSAGE_RST). - * @param code The message code. - * @param tid The transcation id to set or 0 if unknown / not applicable. - * @param size The maximum allowed number of byte for the message. - * @return A pointer to the new PDU object or @c NULL on error. - */ -coap_pdu_t * -coap_pdu_init(uint8_t type, uint8_t code, uint16_t tid, size_t size); - -/** - * Dynamically grows the size of @p pdu to @p new_size. The new size - * must not exceed the PDU's configure maximum size. On success, this - * function returns 1, otherwise 0. - * - * @param pdu The PDU to resize. - * @param new_size The new size in bytes. - * @return 1 if the operation succeeded, 0 otherwise. - */ -int coap_pdu_resize(coap_pdu_t *pdu, size_t new_size); - -/** - * Clears any contents from @p pdu and resets @c used_size, - * and @c data pointers. @c max_size is set to @p size, any - * other field is set to @c 0. Note that @p pdu must be a valid - * pointer to a coap_pdu_t object created e.g. by coap_pdu_init(). - */ -void coap_pdu_clear(coap_pdu_t *pdu, size_t size); - -/** - * Creates a new CoAP PDU. - */ -coap_pdu_t *coap_new_pdu(const struct coap_session_t *session); - -/** - * Dispose of an CoAP PDU and frees associated storage. - * Not that in general you should not call this function directly. - * When a PDU is sent with coap_send(), coap_delete_pdu() will be - * called automatically for you. - */ - -void coap_delete_pdu(coap_pdu_t *); - -/** -* Interprets @p data to determine the number of bytes in the header. -* This function returns @c 0 on error or a number greater than zero on success. -* -* @param proto Session's protocol -* @param data The first byte of raw data to parse as CoAP PDU. -* -* @return A value greater than zero on success or @c 0 on error. -*/ -size_t coap_pdu_parse_header_size(coap_proto_t proto, - const uint8_t *data); - -/** - * Parses @p data to extract the message size. - * @p length must be at least coap_pdu_parse_header_size(proto, data). - * This function returns @c 0 on error or a number greater than zero on success. - * - * @param proto Session's protocol - * @param data The raw data to parse as CoAP PDU. - * @param length The actual size of @p data. - * - * @return A value greater than zero on success or @c 0 on error. - */ -size_t coap_pdu_parse_size(coap_proto_t proto, - const uint8_t *data, - size_t length); - -/** - * Decode the protocol specific header for the specified PDU. - * @param pdu A newly received PDU. - * @param proto The target wire protocol. - * @return 1 for success or 0 on error. - */ - -int coap_pdu_parse_header(coap_pdu_t *pdu, coap_proto_t proto); - -/** - * Verify consistency in the given CoAP PDU structure and locate the data. - * This function returns @c 0 on error or a number greater than zero on - * success. - * This function only parses the token and options, up to the payload start - * marker. - * - * @param pdu The PDU structure to. - * - * @return 1 on success or @c 0 on error. - */ -int coap_pdu_parse_opt(coap_pdu_t *pdu); - -/** -* Parses @p data into the CoAP PDU structure given in @p result. -* The target pdu must be large enough to -* This function returns @c 0 on error or a number greater than zero on success. -* -* @param proto Session's protocol -* @param data The raw data to parse as CoAP PDU. -* @param length The actual size of @p data. -* @param pdu The PDU structure to fill. Note that the structure must -* provide space to hold at least the token and options -* part of the message. -* -* @return 1 on success or @c 0 on error. -*/ -int coap_pdu_parse(coap_proto_t proto, - const uint8_t *data, - size_t length, - coap_pdu_t *pdu); -/** - * Adds token of length @p len to @p pdu. - * Adding the token destroys any following contents of the pdu. Hence options - * and data must be added after coap_add_token() has been called. In @p pdu, - * length is set to @p len + @c 4, and max_delta is set to @c 0. This function - * returns @c 0 on error or a value greater than zero on success. - * - * @param pdu The PDU where the token is to be added. - * @param len The length of the new token. - * @param data The token to add. - * - * @return A value greater than zero on success, or @c 0 on error. - */ -int coap_add_token(coap_pdu_t *pdu, - size_t len, - const uint8_t *data); - -/** - * Adds option of given type to pdu that is passed as first - * parameter. - * coap_add_option() destroys the PDU's data, so coap_add_data() must be called - * after all options have been added. As coap_add_token() destroys the options - * following the token, the token must be added before coap_add_option() is - * called. This function returns the number of bytes written or @c 0 on error. - */ -size_t coap_add_option(coap_pdu_t *pdu, - uint16_t type, - size_t len, - const uint8_t *data); - -/** - * Adds option of given type to pdu that is passed as first parameter, but does - * not write a value. It works like coap_add_option with respect to calling - * sequence (i.e. after token and before data). This function returns a memory - * address to which the option data has to be written before the PDU can be - * sent, or @c NULL on error. - */ -uint8_t *coap_add_option_later(coap_pdu_t *pdu, - uint16_t type, - size_t len); - -/** - * Adds given data to the pdu that is passed as first parameter. Note that the - * PDU's data is destroyed by coap_add_option(). coap_add_data() must be called - * only once per PDU, otherwise the result is undefined. - */ -int coap_add_data(coap_pdu_t *pdu, - size_t len, - const uint8_t *data); - -/** - * Adds given data to the pdu that is passed as first parameter but does not - * copyt it. Note that the PDU's data is destroyed by coap_add_option(). - * coap_add_data() must be have been called once for this PDU, otherwise the - * result is undefined. - * The actual data must be copied at the returned location. - */ -uint8_t *coap_add_data_after(coap_pdu_t *pdu, size_t len); - -/** - * Retrieves the length and data pointer of specified PDU. Returns 0 on error or - * 1 if *len and *data have correct values. Note that these values are destroyed - * with the pdu. - */ -int coap_get_data(const coap_pdu_t *pdu, - size_t *len, - uint8_t **data); - -/** - * Compose the protocol specific header for the specified PDU. - * @param pdu A newly composed PDU. - * @param proto The target wire protocol. - * @return Number of header bytes prepended before pdu->token or 0 on error. - */ - -size_t coap_pdu_encode_header(coap_pdu_t *pdu, coap_proto_t proto); - -#endif /* COAP_PDU_H_ */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap2/prng.h b/tools/sdk/esp32/include/coap/libcoap/include/coap2/prng.h deleted file mode 100644 index c9510bf5602..00000000000 --- a/tools/sdk/esp32/include/coap/libcoap/include/coap2/prng.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * prng.h -- Pseudo Random Numbers - * - * Copyright (C) 2010-2011 Olaf Bergmann - * - * This file is part of the CoAP library libcoap. Please see README for terms - * of use. - */ - -/** - * @file prng.h - * @brief Pseudo Random Numbers - */ - -#ifndef COAP_PRNG_H_ -#define COAP_PRNG_H_ - -/** - * @defgroup prng Pseudo Random Numbers - * API functions for gerating pseudo random numbers - * @{ - */ - -#if defined(WITH_CONTIKI) -#include - -/** - * Fills \p buf with \p len random bytes. This is the default implementation for - * prng(). You might want to change prng() to use a better PRNG on your specific - * platform. - */ -COAP_STATIC_INLINE int -contiki_prng_impl(unsigned char *buf, size_t len) { - uint16_t v = random_rand(); - while (len > sizeof(v)) { - memcpy(buf, &v, sizeof(v)); - len -= sizeof(v); - buf += sizeof(v); - v = random_rand(); - } - - memcpy(buf, &v, len); - return 1; -} - -#define prng(Buf,Length) contiki_prng_impl((Buf), (Length)) -#define prng_init(Value) random_init((uint16_t)(Value)) -#elif defined(WITH_LWIP) && defined(LWIP_RAND) -COAP_STATIC_INLINE int -lwip_prng_impl(unsigned char *buf, size_t len) { - u32_t v = LWIP_RAND(); - while (len > sizeof(v)) { - memcpy(buf, &v, sizeof(v)); - len -= sizeof(v); - buf += sizeof(v); - v = LWIP_RAND(); - } - - memcpy(buf, &v, len); - return 1; -} - -#define prng(Buf,Length) lwip_prng_impl((Buf), (Length)) -#define prng_init(Value) -#elif defined(_WIN32) -#define prng_init(Value) -errno_t __cdecl rand_s( _Out_ unsigned int* _RandomValue ); - /** - * Fills \p buf with \p len random bytes. This is the default implementation for - * prng(). You might want to change prng() to use a better PRNG on your specific - * platform. - */ -COAP_STATIC_INLINE int -coap_prng_impl( unsigned char *buf, size_t len ) { - while ( len != 0 ) { - uint32_t r = 0; - size_t i; - if ( rand_s( &r ) != 0 ) - return 0; - for ( i = 0; i < len && i < 4; i++ ) { - *buf++ = (uint8_t)r; - r >>= 8; - } - len -= i; - } - return 1; -} - -#else -#include - - /** - * Fills \p buf with \p len random bytes. This is the default implementation for - * prng(). You might want to change prng() to use a better PRNG on your specific - * platform. - */ -COAP_STATIC_INLINE int -coap_prng_impl( unsigned char *buf, size_t len ) { - while ( len-- ) - *buf++ = rand() & 0xFF; - return 1; -} -#endif - - -#ifndef prng -/** - * Fills \p Buf with \p Length bytes of random data. - * - * @hideinitializer - */ -#define prng(Buf,Length) coap_prng_impl((Buf), (Length)) -#endif - -#ifndef prng_init -/** - * Called to set the PRNG seed. You may want to re-define this to allow for a - * better PRNG. - * - * @hideinitializer - */ -#define prng_init(Value) srand((unsigned long)(Value)) -#endif - -/** @} */ - -#endif /* COAP_PRNG_H_ */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap2/str.h b/tools/sdk/esp32/include/coap/libcoap/include/coap2/str.h deleted file mode 100644 index 6c1488c982d..00000000000 --- a/tools/sdk/esp32/include/coap/libcoap/include/coap2/str.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - * str.h -- strings to be used in the CoAP library - * - * Copyright (C) 2010-2011 Olaf Bergmann - * - * This file is part of the CoAP library libcoap. Please see README for terms - * of use. - */ - -#ifndef COAP_STR_H_ -#define COAP_STR_H_ - -#include - - -/** - * @defgroup string String handling support - * API functions for handling strings - * @{ - */ - -/** - * Coap string data definition - */ -typedef struct coap_string_t { - size_t length; /**< length of string */ - uint8_t *s; /**< string data */ -} coap_string_t; - -/** - * Coap string data definition with const data - */ -typedef struct coap_str_const_t { - size_t length; /**< length of string */ - const uint8_t *s; /**< string data */ -} coap_str_const_t; - -#define COAP_SET_STR(st,l,v) { (st)->length = (l), (st)->s = (v); } - -/** - * Coap binary data definition - */ -typedef struct coap_binary_t { - size_t length; /**< length of binary data */ - uint8_t *s; /**< binary data */ -} coap_binary_t; - -/** - * Returns a new string object with at least size+1 bytes storage allocated. - * The string must be released using coap_delete_string(). - * - * @param size The size to allocate for the binary string data. - * - * @return A pointer to the new object or @c NULL on error. - */ -coap_string_t *coap_new_string(size_t size); - -/** - * Deletes the given string and releases any memory allocated. - * - * @param string The string to free off. - */ -void coap_delete_string(coap_string_t *string); - -/** - * Returns a new const string object with at least size+1 bytes storage - * allocated, and the provided data copied into the string object. - * The string must be released using coap_delete_str_const(). - * - * @param data The data to put in the new string object. - * @param size The size to allocate for the binary string data. - * - * @return A pointer to the new object or @c NULL on error. - */ -coap_str_const_t *coap_new_str_const(const uint8_t *data, size_t size); - -/** - * Deletes the given const string and releases any memory allocated. - * - * @param string The string to free off. - */ -void coap_delete_str_const(coap_str_const_t *string); - -/** - * Take the specified byte array (text) and create a coap_str_const_t * - * - * WARNING: The byte array must be in the local scope and not a - * parameter in the function call as sizeof() will return the size of the - * pointer, not the size of the byte array, leading to unxepected results. - * - * @param string The const byte array to convert to a coap_str_const_t * - */ -#ifdef __cplusplus -namespace libcoap { - struct CoAPStrConst : coap_str_const_t { - operator coap_str_const_t *() { return this; } - }; -} -#define coap_make_str_const(CStr) \ - libcoap::CoAPStrConst{sizeof(CStr)-1, reinterpret_cast(CStr)} -#else /* __cplusplus */ -#define coap_make_str_const(string) \ - (&(coap_str_const_t){sizeof(string)-1,(const uint8_t *)(string)}) -#endif /* __cplusplus */ - -/** - * Compares the two strings for equality - * - * @param string1 The first string. - * @param string2 The second string. - * - * @return @c 1 if the strings are equal - * @c 0 otherwise. - */ -#define coap_string_equal(string1,string2) \ - ((string1)->length == (string2)->length && ((string1)->length == 0 || \ - memcmp((string1)->s, (string2)->s, (string1)->length) == 0)) - -/** @} */ - -#endif /* COAP_STR_H_ */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap2/subscribe.h b/tools/sdk/esp32/include/coap/libcoap/include/coap2/subscribe.h deleted file mode 100644 index ed635a6182a..00000000000 --- a/tools/sdk/esp32/include/coap/libcoap/include/coap2/subscribe.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * subscribe.h -- subscription handling for CoAP - * see RFC7641 - * - * Copyright (C) 2010-2012,2014-2015 Olaf Bergmann - * - * This file is part of the CoAP library libcoap. Please see README for terms - * of use. - */ - - -#ifndef COAP_SUBSCRIBE_H_ -#define COAP_SUBSCRIBE_H_ - -#include "address.h" -#include "coap_io.h" -#include "block.h" - -/** - * @defgroup observe Resource observation - * API functions for interfacing with the observe handling (RFC7641) - * @{ - */ - -/** - * The value COAP_OBSERVE_ESTABLISH in a GET request indicates a new observe - * relationship for (sender address, token) is requested. - */ -#define COAP_OBSERVE_ESTABLISH 0 - -/** - * The value COAP_OBSERVE_CANCEL in a GET request indicates that the observe - * relationship for (sender address, token) must be cancelled. - */ -#define COAP_OBSERVE_CANCEL 1 - -#ifndef COAP_OBS_MAX_NON -/** - * Number of notifications that may be sent non-confirmable before a confirmable - * message is sent to detect if observers are alive. The maximum allowed value - * here is @c 15. - */ -#define COAP_OBS_MAX_NON 5 -#endif /* COAP_OBS_MAX_NON */ - -#ifndef COAP_OBS_MAX_FAIL -/** - * Number of confirmable notifications that may fail (i.e. time out without - * being ACKed) before an observer is removed. The maximum value for - * COAP_OBS_MAX_FAIL is @c 3. - */ -#define COAP_OBS_MAX_FAIL 3 -#endif /* COAP_OBS_MAX_FAIL */ - -/** Subscriber information */ -typedef struct coap_subscription_t { - struct coap_subscription_t *next; /**< next element in linked list */ - coap_session_t *session; /**< subscriber session */ - - unsigned int non_cnt:4; /**< up to 15 non-confirmable notifies allowed */ - unsigned int fail_cnt:2; /**< up to 3 confirmable notifies can fail */ - unsigned int dirty:1; /**< set if the notification temporarily could not be - * sent (in that case, the resource's partially - * dirty flag is set too) */ - unsigned int has_block2:1; /**< GET request had Block2 definition */ - uint16_t tid; /**< transaction id, if any, in regular host byte order */ - coap_block_t block2; /**< GET request Block2 definition */ - size_t token_length; /**< actual length of token */ - unsigned char token[8]; /**< token used for subscription */ - coap_string_t *query; /**< query string used for subscription, if any */ -} coap_subscription_t; - -void coap_subscription_init(coap_subscription_t *); - -/** @} */ - -#endif /* COAP_SUBSCRIBE_H_ */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap2/address.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/address.h similarity index 81% rename from tools/sdk/esp32/include/coap/libcoap/include/coap2/address.h rename to tools/sdk/esp32/include/coap/libcoap/include/coap3/address.h index a51236d5a60..8b8d9a24fae 100644 --- a/tools/sdk/esp32/include/coap/libcoap/include/coap2/address.h +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/address.h @@ -3,6 +3,8 @@ * * Copyright (C) 2010-2011,2015-2016 Olaf Bergmann * + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ @@ -30,6 +32,22 @@ typedef struct coap_address_t { ip_addr_t addr; } coap_address_t; +/** + * Returns the port from @p addr in host byte order. + */ +COAP_STATIC_INLINE uint16_t +coap_address_get_port(const coap_address_t *addr) { + return ntohs(addr->port); +} + +/** + * Sets the port field of @p addr to @p port (in host byte order). + */ +COAP_STATIC_INLINE void +coap_address_set_port(coap_address_t *addr, uint16_t port) { + addr->port = htons(port); +} + #define _coap_address_equals_impl(A, B) \ ((A)->port == (B)->port \ && (!!ip_addr_cmp(&(A)->addr,&(B)->addr))) @@ -47,6 +65,22 @@ typedef struct coap_address_t { uint16_t port; } coap_address_t; +/** + * Returns the port from @p addr in host byte order. + */ +COAP_STATIC_INLINE uint16_t +coap_address_get_port(const coap_address_t *addr) { + return uip_ntohs(addr->port); +} + +/** + * Sets the port field of @p addr to @p port (in host byte order). + */ +COAP_STATIC_INLINE void +coap_address_set_port(coap_address_t *addr, uint16_t port) { + addr->port = uip_htons(port); +} + #define _coap_address_equals_impl(A,B) \ ((A)->port == (B)->port \ && uip_ipaddr_cmp(&((A)->addr),&((B)->addr))) @@ -68,6 +102,16 @@ typedef struct coap_address_t { } addr; } coap_address_t; +/** + * Returns the port from @p addr in host byte order. + */ +uint16_t coap_address_get_port(const coap_address_t *addr); + +/** + * Set the port field of @p addr to @p port (in host byte order). + */ +void coap_address_set_port(coap_address_t *addr, uint16_t port); + /** * Compares given address objects @p a and @p b. This function returns @c 1 if * addresses are equal, @c 0 otherwise. The parameters @p a and @p b must not be @@ -100,15 +144,7 @@ _coap_address_isany_impl(const coap_address_t *a) { * * @param addr The coap_address_t object to initialize. */ -COAP_STATIC_INLINE void -coap_address_init(coap_address_t *addr) { - assert(addr); - memset(addr, 0, sizeof(coap_address_t)); -#if !defined(WITH_LWIP) && !defined(WITH_CONTIKI) - /* lwip and Contiki have constant address sizes and doesn't need the .size part */ - addr->size = sizeof(addr->addr); -#endif -} +void coap_address_init(coap_address_t *addr); /* Convenience function to copy IPv6 addresses without garbage. */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap3/async.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/async.h new file mode 100644 index 00000000000..a61e0c09828 --- /dev/null +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/async.h @@ -0,0 +1,116 @@ +/* + * async.h -- state management for asynchronous messages + * + * Copyright (C) 2010-2011 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file async.h + * @brief State management for asynchronous messages + */ + +#ifndef COAP_ASYNC_H_ +#define COAP_ASYNC_H_ + +#include "net.h" + +/** + * @defgroup coap_async Asynchronous Messaging + * @{ + * API functions for Async "separate" messages. + * A coap_context_t object holds a list of coap_async_t objects that can + * be used to generate a separate response in the case a result of a request + * cannot be delivered immediately. + */ + +/** + * Returns @c 1 if libcoap was built with separate messages enabled, + * @c 0 otherwise. + */ +int coap_async_is_supported(void); + +/** + * Allocates a new coap_async_t object and fills its fields according to + * the given @p request. This function returns a pointer to the registered + * coap_async_t object or @c NULL on error. Note that this function will + * return @c NULL in case that an object with the same identifier is already + * registered. + * + * When the delay expires, a copy of the @p request will get sent to the + * appropriate request handler. + * + * @param session The session that is used for asynchronous transmissions. + * @param request The request that is handled asynchronously. + * @param delay The amount of time to delay before sending response, 0 means + * wait forever. + * + * @return A pointer to the registered coap_async_t object or @c + * NULL in case of an error. + */ +coap_async_t * +coap_register_async(coap_session_t *session, + const coap_pdu_t *request, + coap_tick_t delay); + +/** + * Update the delay timeout, so changing when the registered @p async triggers. + * + * When the new delay expires, a copy of the original request will get sent to + * the appropriate request handler. + * + * @param async The object to update. + * @param delay The amount of time to delay before sending response, 0 means + * wait forever. + */ +void +coap_async_set_delay(coap_async_t *async, coap_tick_t delay); + +/** + * Releases the memory that was allocated by coap_register_async() for the + * object @p async. + * + * @param session The session to use. + * @param async The object to delete. + */ +void +coap_free_async(coap_session_t *session, coap_async_t *async); + +/** + * Retrieves the object identified by @p token from the list of asynchronous + * transactions that are registered with @p context. This function returns a + * pointer to that object or @c NULL if not found. + * + * @param session The session that is used for asynchronous transmissions. + * @param token The PDU's token of the object to retrieve. + * + * @return A pointer to the object identified by @p token or @c NULL if + * not found. + */ +coap_async_t *coap_find_async(coap_session_t *session, coap_bin_const_t token); + +/** + * Set the application data pointer held in @p async. This overwrites any + * existing data pointer. + * + * @param async The async state object. + * @param app_data The pointer to the data. + */ +void coap_async_set_app_data(coap_async_t *async, void *app_data); + +/** + * Gets the application data pointer held in @p async. + * + * @param async The async state object. + * + * @return The applicaton data pointer. + */ +void *coap_async_get_app_data(const coap_async_t *async); + +/** @} */ + +#endif /* COAP_ASYNC_H_ */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap3/block.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/block.h new file mode 100644 index 00000000000..a2aac00fdc6 --- /dev/null +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/block.h @@ -0,0 +1,348 @@ +/* + * block.h -- block transfer + * + * Copyright (C) 2010-2012,2014-2015 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +#ifndef COAP_BLOCK_H_ +#define COAP_BLOCK_H_ + +#include "encode.h" +#include "option.h" +#include "pdu.h" + +/** + * @defgroup block Block Transfer + * API functions for handling PDUs using CoAP BLOCK options + * @{ + */ + +#ifndef COAP_MAX_BLOCK_SZX +/** + * The largest value for the SZX component in a Block option. + */ +#define COAP_MAX_BLOCK_SZX 6 +#endif /* COAP_MAX_BLOCK_SZX */ + +/** + * Structure of Block options. + */ +typedef struct { + unsigned int num; /**< block number */ + unsigned int m:1; /**< 1 if more blocks follow, 0 otherwise */ + unsigned int szx:3; /**< block size */ +} coap_block_t; + +#define COAP_BLOCK_USE_LIBCOAP 0x01 /* Use libcoap to do block requests */ +#define COAP_BLOCK_SINGLE_BODY 0x02 /* Deliver the data as a single body */ + +/** + * Returns the value of the least significant byte of a Block option @p opt. + * For zero-length options (i.e. num == m == szx == 0), COAP_OPT_BLOCK_LAST + * returns @c NULL. + */ +#define COAP_OPT_BLOCK_LAST(opt) \ + (coap_opt_length(opt) ? (coap_opt_value(opt) + (coap_opt_length(opt)-1)) : 0) + +/** Returns the value of the More-bit of a Block option @p opt. */ +#define COAP_OPT_BLOCK_MORE(opt) \ + (coap_opt_length(opt) ? (*COAP_OPT_BLOCK_LAST(opt) & 0x08) : 0) + +/** Returns the value of the SZX-field of a Block option @p opt. */ +#define COAP_OPT_BLOCK_SZX(opt) \ + (coap_opt_length(opt) ? (*COAP_OPT_BLOCK_LAST(opt) & 0x07) : 0) + +/** + * Returns the value of field @c num in the given block option @p block_opt. + */ +unsigned int coap_opt_block_num(const coap_opt_t *block_opt); + +/** + * Checks if more than @p num blocks are required to deliver @p data_len + * bytes of data for a block size of 1 << (@p szx + 4). + */ +COAP_STATIC_INLINE int +coap_more_blocks(size_t data_len, unsigned int num, uint16_t szx) { + return ((num+1) << (szx + 4)) < data_len; +} + +#if 0 +/** Sets the More-bit in @p block_opt */ +COAP_STATIC_INLINE void +coap_opt_block_set_m(coap_opt_t *block_opt, int m) { + if (m) + *(coap_opt_value(block_opt) + (coap_opt_length(block_opt) - 1)) |= 0x08; + else + *(coap_opt_value(block_opt) + (coap_opt_length(block_opt) - 1)) &= ~0x08; +} +#endif + +/** + * Initializes @p block from @p pdu. @p number must be either COAP_OPTION_BLOCK1 + * or COAP_OPTION_BLOCK2. When option @p number was found in @p pdu, @p block is + * initialized with values from this option and the function returns the value + * @c 1. Otherwise, @c 0 is returned. + * + * @param pdu The pdu to search for option @p number. + * @param number The option number to search for (must be COAP_OPTION_BLOCK1 or + * COAP_OPTION_BLOCK2). + * @param block The block structure to initilize. + * + * @return @c 1 on success, @c 0 otherwise. + */ +int coap_get_block(const coap_pdu_t *pdu, coap_option_num_t number, + coap_block_t *block); + +/** + * Writes a block option of type @p number to message @p pdu. If the requested + * block size is too large to fit in @p pdu, it is reduced accordingly. An + * exception is made for the final block when less space is required. The actual + * length of the resource is specified in @p data_length. + * + * This function may change *block to reflect the values written to @p pdu. As + * the function takes into consideration the remaining space @p pdu, no more + * options should be added after coap_write_block_opt() has returned. + * + * @param block The block structure to use. On return, this object is + * updated according to the values that have been written to + * @p pdu. + * @param number COAP_OPTION_BLOCK1 or COAP_OPTION_BLOCK2. + * @param pdu The message where the block option should be written. + * @param data_length The length of the actual data that will be added the @p + * pdu by calling coap_add_block(). + * + * @return @c 1 on success, or a negative value on error. + */ +int coap_write_block_opt(coap_block_t *block, + coap_option_num_t number, + coap_pdu_t *pdu, + size_t data_length); + +/** + * Adds the @p block_num block of size 1 << (@p block_szx + 4) from source @p + * data to @p pdu. + * + * @param pdu The message to add the block. + * @param len The length of @p data. + * @param data The source data to fill the block with. + * @param block_num The actual block number. + * @param block_szx Encoded size of block @p block_number. + * + * @return @c 1 on success, @c 0 otherwise. + */ +int coap_add_block(coap_pdu_t *pdu, + size_t len, + const uint8_t *data, + unsigned int block_num, + unsigned char block_szx); + +/** + * Re-assemble payloads into a body + * + * @param body_data The pointer to the data for the body holding the + * representation so far or NULL if the first time. + * @param length The length of @p data. + * @param data The payload data to update the body with. + * @param offset The offset of the @p data into the body. + * @param total The estimated total size of the body. + * + * @return The current representation of the body or @c NULL if error. + * If NULL, @p body_data will have been de-allocated. + */ +coap_binary_t * +coap_block_build_body(coap_binary_t *body_data, size_t length, + const uint8_t *data, size_t offset, size_t total); + +/** + * Adds the appropriate part of @p data to the @p response pdu. If blocks are + * required, then the appropriate block will be added to the PDU and sent. + * Adds a ETAG option that is the hash of the entire data if the data is to be + * split into blocks + * Used by a request handler. + * + * Note: The application will get called for every packet of a large body to + * process. Consider using coap_add_data_response_large() instead. + * + * @param request The requesting pdu. + * @param response The response pdu. + * @param media_type The format of the data. + * @param maxage The maxmimum life of the data. If @c -1, then there + * is no maxage. + * @param length The total length of the data. + * @param data The entire data block to transmit. + * + */ +void +coap_add_data_blocked_response(const coap_pdu_t *request, + coap_pdu_t *response, + uint16_t media_type, + int maxage, + size_t length, + const uint8_t* data); + +/** + * Callback handler for de-allocating the data based on @p app_ptr provided to + * coap_add_data_large_*() functions following transmission of the supplied + * data. + * + * @param session The session that this data is associated with + * @param app_ptr The application provided pointer provided to the + * coap_add_data_large_* functions. + */ +typedef void (*coap_release_large_data_t)(coap_session_t *session, + void *app_ptr); + +/** + * Associates given data with the @p pdu that is passed as second parameter. + * + * If all the data can be transmitted in a single PDU, this is functionally + * the same as coap_add_data() except @p release_func (if not NULL) will get + * invoked after data transmission. + * + * Used for a client request. + * + * If the data spans multiple PDUs, then the data will get transmitted using + * BLOCK1 option with the addition of the SIZE1 option. + * The underlying library will handle the transmission of the individual blocks. + * Once the body of data has been transmitted (or a failure occurred), then + * @p release_func (if not NULL) will get called so the application can + * de-allocate the @p data based on @p app_data. It is the responsibility of + * the application not to change the contents of @p data until the data + * transfer has completed. + * + * There is no need for the application to include the BLOCK1 option in the + * @p pdu. + * + * coap_add_data_large_request() (or the alternative coap_add_data_large_*() + * functions) must be called only once per PDU and must be the last PDU update + * before the PDU is transmitted. The (potentially) initial data will get + * transmitted when coap_send() is invoked. + * + * Note: COAP_BLOCK_USE_LIBCOAP must be set by coap_context_set_block_mode() + * for libcoap to work correctly when using this function. + * + * @param session The session to associate the data with. + * @param pdu The PDU to associate the data with. + * @param length The length of data to transmit. + * @param data The data to transmit. + * @param release_func The function to call to de-allocate @p data or @c NULL + * if the function is not required. + * @param app_ptr A Pointer that the application can provide for when + * release_func() is called. + * + * @return @c 1 if addition is successful, else @c 0. + */ +int coap_add_data_large_request(coap_session_t *session, + coap_pdu_t *pdu, + size_t length, + const uint8_t *data, + coap_release_large_data_t release_func, + void *app_ptr); + +/** + * Associates given data with the @p response pdu that is passed as fourth + * parameter. + * + * If all the data can be transmitted in a single PDU, this is functionally + * the same as coap_add_data() except @p release_func (if not NULL) will get + * invoked after data transmission. The MEDIA_TYPE, MAXAGE and ETAG options may + * be added in as appropriate. + * + * Used by a server request handler to create the response. + * + * If the data spans multiple PDUs, then the data will get transmitted using + * BLOCK2 (response) option with the addition of the SIZE2 and ETAG + * options. The underlying library will handle the transmission of the + * individual blocks. Once the body of data has been transmitted (or a + * failure occurred), then @p release_func (if not NULL) will get called so the + * application can de-allocate the @p data based on @p app_data. It is the + * responsibility of the application not to change the contents of @p data + * until the data transfer has completed. + * + * There is no need for the application to include the BLOCK2 option in the + * @p pdu. + * + * coap_add_data_large_response() (or the alternative coap_add_data_large*() + * functions) must be called only once per PDU and must be the last PDU update + * before returning from the request handler function. + * + * Note: COAP_BLOCK_USE_LIBCOAP must be set by coap_context_set_block_mode() + * for libcoap to work correctly when using this function. + * + * @param resource The resource the data is associated with. + * @param session The coap session. + * @param request The requesting pdu. + * @param response The response pdu. + * @param query The query taken from the (original) requesting pdu. + * @param media_type The format of the data. + * @param maxage The maxmimum life of the data. If @c -1, then there + * is no maxage. + * @param etag ETag to use if not 0. + * @param length The total length of the data. + * @param data The entire data block to transmit. + * @param release_func The function to call to de-allocate @p data or NULL if + * the function is not required. + * @param app_ptr A Pointer that the application can provide for when + * release_func() is called. + * + * @return @c 1 if addition is successful, else @c 0. + */ +int +coap_add_data_large_response(coap_resource_t *resource, + coap_session_t *session, + const coap_pdu_t *request, + coap_pdu_t *response, + const coap_string_t *query, + uint16_t media_type, + int maxage, + uint64_t etag, + size_t length, + const uint8_t *data, + coap_release_large_data_t release_func, + void *app_ptr); + +/** + * Set the context level CoAP block handling bits for handling RFC7959. + * These bits flow down to a session when a session is created and if the peer + * does not support something, an appropriate bit may get disabled in the + * session block_mode. + * The session block_mode then flows down into coap_crcv_t or coap_srcv_t where + * again an appropriate bit may get disabled. + * + * Note: This function must be called before the session is set up. + * + * Note: COAP_BLOCK_USE_LIBCOAP must be set if libcoap is to do all the + * block tracking and requesting, otherwise the application will have to do + * all of this work (the default if coap_context_set_block_mode() is not + * called). + * + * @param context The coap_context_t object. + * @param block_mode Zero or more COAP_BLOCK_ or'd options + */ +void coap_context_set_block_mode(coap_context_t *context, + uint8_t block_mode); + +/** + * Cancel an observe that is being tracked by the client large receive logic. + * (coap_context_set_block_mode() has to be called) + * This will trigger the sending of an observe cancel pdu to the server. + * + * @param session The session that is being used for the observe. + * @param token The original token used to initiate the observation. + * @param message_type The COAP_MESSAGE_ type (NON or CON) to send the observe + * cancel pdu as. + * + * @return @c 1 if observe cancel transmission initiation is successful, + * else @c 0. + */ +int coap_cancel_observe(coap_session_t *session, coap_binary_t *token, + coap_pdu_type_t message_type); + +/**@}*/ + +#endif /* COAP_BLOCK_H_ */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_asn1_internal.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_asn1_internal.h new file mode 100644 index 00000000000..5bb4e2a8dbe --- /dev/null +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_asn1_internal.h @@ -0,0 +1,89 @@ +/* + * coap_asn1_internal.h -- ASN.1 functions for libcoap + * + * Copyright (C) 2020 Jon Shallow + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_asn1_internal.h + * @brief COAP ASN.1 internal information + */ + +#ifndef COAP_ASN1_INTERNAL_H_ +#define COAP_ASN1_INTERNAL_H_ + + +/** + * @defgroup asn1 ASN.1 Support (Internal) + * CoAP ASN.1 Structures, Enums and Functions that are not exposed to + * applications + * @{ + */ + +typedef enum { + COAP_ASN1_NONE = 0, + COAP_ASN1_INTEGER = 2, + COAP_ASN1_BITSTRING = 3, + COAP_ASN1_OCTETSTRING = 4, + COAP_ASN1_IDENTIFIER = 6, +} coap_asn1_tag_t; + +/** + * Callback to validate the asn1 tag and data. + * + * Internal function. + * + * @param data The start of the tag and data + * @param size The size of the tag and data + * + * @return @c 1 if pass, else @c 0 if fail + */ +typedef int (*asn1_validate)(const uint8_t *data, size_t size); + +/** + * Get the asn1 length from the current @p ptr. + * + * Internal function. + * + * @param ptr The current asn.1 object length pointer + * + * @return The length of the asn.1 object. @p ptr is updated to be after the length. + */ +size_t asn1_len(const uint8_t **ptr); + +/** + * Get the asn1 tag from the current @p ptr. + * + * Internal function. + * + * @param ptr The current asn.1 object tag pointer + * @param constructed 1 if current tag is constructed + * @param class The current class of the tag + * + * @return The tag value.@p ptr is updated to be after the tag. + */ +coap_asn1_tag_t asn1_tag_c(const uint8_t **ptr, int *constructed, int *class); + +/** + * Get the asn1 tag and data from the current @p ptr. + * + * Internal function. + * + * @param ltag The tag to look for + * @param ptr The current asn.1 object pointer + * @param tlen The remaining size oof the asn.1 data + * @param validate Call validate to verify tag data or @c NULL + * + * @return The asn.1 tag and data or @c NULL if not found + */ +coap_binary_t *get_asn1_tag(coap_asn1_tag_t ltag, const uint8_t *ptr, + size_t tlen, asn1_validate validate); + +/** @} */ + +#endif /* COAP_ASN1_INTERNAL_H_ */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_async_internal.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_async_internal.h new file mode 100644 index 00000000000..a23b1c8e697 --- /dev/null +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_async_internal.h @@ -0,0 +1,67 @@ +/* + * coap_async_internal.h -- state management for asynchronous messages + * + * Copyright (C) 2010-2021 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_async_internal.h + * @brief CoAP async internal information + */ + +#ifndef COAP_ASYNC_INTERNAL_H_ +#define COAP_ASYNC_INTERNAL_H_ + +#include "coap3/net.h" + +#ifndef WITHOUT_ASYNC + +/** + * @defgroup coap_async_internal Asynchronous Messaging (Internal) + * @{ + * CoAP Async Structures, Enums and Functions that are not exposed to + * applications. + * A coap_context_t object holds a list of coap_async_t objects that can be + * used to generate a separate response in the case a result of a request cannot + * be delivered immediately. + */ +struct coap_async_t { + struct coap_async_t *next; /**< internally used for linking */ + coap_tick_t delay; /**< When to delay to before triggering the response + 0 indicates never trigger */ + coap_session_t *session; /**< transaction session */ + coap_pdu_t *pdu; /**< copy of request pdu */ + void* appdata; /** User definable data pointer */ +}; + +/** + * Checks if there are any pending Async requests - if so, send them off. + * Otherewise return the time remaining for the next Async to be triggered + * or 0 if nothing to do. + * + * @param context The current context. + * @param now The current time in ticks. + * + * @return The tick time before the next Async needs to go, else 0 if + * nothing to do. + */ +coap_tick_t coap_check_async(coap_context_t *context, coap_tick_t now); + +/** + * Removes and frees off all of the async entries for the given context. + * + * @param context The context to remove all async entries from. + */ +void +coap_delete_all_async(coap_context_t *context); + +/** @} */ + +#endif /* WITHOUT_ASYNC */ + +#endif /* COAP_ASYNC_INTERNAL_H_ */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_block_internal.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_block_internal.h new file mode 100644 index 00000000000..9abe81557fa --- /dev/null +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_block_internal.h @@ -0,0 +1,239 @@ +/* + * coap_block_internal.h -- Structures, Enums & Functions that are not + * exposed to application programming + * + * Copyright (C) 2010-2021 Olaf Bergmann + * Copyright (C) 2021 Jon Shallow + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_block_internal.h + * @brief COAP block internal information + */ + +#ifndef COAP_BLOCK_INTERNAL_H_ +#define COAP_BLOCK_INTERNAL_H_ + +#include "coap_pdu_internal.h" +#include "resource.h" + +/** + * @defgroup block_internal Block (Internal) + * Structures, Enums and Functions that are not exposed to applications + * @{ + */ + +typedef enum { + COAP_RECURSE_OK, + COAP_RECURSE_NO +} coap_recurse_t; + +struct coap_lg_range { + uint32_t begin; + uint32_t end; +}; + +#define COAP_RBLOCK_CNT 4 +/** + * Structure to keep track of received blocks + */ +typedef struct coap_rblock_t { + uint32_t used; + uint32_t retry; + struct coap_lg_range range[COAP_RBLOCK_CNT]; + coap_tick_t last_seen; +} coap_rblock_t; + +/** + * Structure to keep track of block1 specific information + * (Requests) + */ +typedef struct coap_l_block1_t { + coap_binary_t *app_token; /**< original PDU token */ + uint8_t token[8]; /**< last used token */ + size_t token_length; /**< length of token */ + uint32_t count; /**< the number of packets sent for payload */ +} coap_l_block1_t; + +/** + * Structure to keep track of block2 specific information + * (Responses) + */ +typedef struct coap_l_block2_t { + coap_resource_t *resource; /**< associated resource */ + coap_string_t *query; /**< Associated query for the resource */ + uint64_t etag; /**< ETag value */ + coap_time_t maxage_expire; /**< When this entry expires */ +} coap_l_block2_t; + +/** + * Structure to hold large body (many blocks) transmission information + */ +struct coap_lg_xmit_t { + struct coap_lg_xmit_t *next; + uint8_t blk_size; /**< large block transmission size */ + uint16_t option; /**< large block transmisson CoAP option */ + int last_block; /**< last acknowledged block number */ + const uint8_t *data; /**< large data ptr */ + size_t length; /**< large data length */ + size_t offset; /**< large data next offset to transmit */ + union { + coap_l_block1_t b1; + coap_l_block2_t b2; + } b; + coap_pdu_t pdu; /**< skeletal PDU */ + coap_tick_t last_payload; /**< Last time MAX_PAYLOAD was sent or 0 */ + coap_tick_t last_used; /**< Last time all data sent or 0 */ + coap_release_large_data_t release_func; /**< large data de-alloc function */ + void *app_ptr; /**< applicaton provided ptr for de-alloc function */ +}; + +/** + * Structure to hold large body (many blocks) client receive information + */ +struct coap_lg_crcv_t { + struct coap_lg_crcv_t *next; + uint8_t observe[3]; /**< Observe data (if set) (only 24 bits) */ + uint8_t observe_length;/**< Length of observe data */ + uint8_t observe_set; /**< Set if this is an observe receive PDU */ + uint8_t etag_set; /**< Set if ETag is in receive PDU */ + uint8_t etag_length; /**< ETag length */ + uint8_t etag[8]; /**< ETag for block checking */ + uint16_t content_format; /**< Content format for the set of blocks */ + uint8_t last_type; /**< Last request type (CON/NON) */ + uint8_t initial; /**< If set, has not been used yet */ + uint8_t szx; /**< size of individual blocks */ + size_t total_len; /**< Length as indicated by SIZE2 option */ + coap_binary_t *body_data; /**< Used for re-assembling entire body */ + coap_binary_t *app_token; /**< app requesting PDU token */ + uint8_t base_token[8]; /**< established base PDU token */ + size_t base_token_length; /**< length of token */ + uint8_t token[8]; /**< last used token */ + size_t token_length; /**< length of token */ + coap_pdu_t pdu; /**< skeletal PDU */ + coap_rblock_t rec_blocks; /** < list of received blocks */ + coap_tick_t last_used; /**< Last time all data sent or 0 */ + uint16_t block_option; /**< Block option in use */ +}; + +/** + * Structure to hold large body (many blocks) server receive information + */ +struct coap_lg_srcv_t { + struct coap_lg_srcv_t *next; + uint8_t observe[3]; /**< Observe data (if set) (only 24 bits) */ + uint8_t observe_length;/**< Length of observe data */ + uint8_t observe_set; /**< Set if this is an observe receive PDU */ + uint8_t rtag_set; /**< Set if RTag is in receive PDU */ + uint8_t rtag_length; /**< RTag length */ + uint8_t rtag[8]; /**< RTag for block checking */ + uint16_t content_format; /**< Content format for the set of blocks */ + uint8_t last_type; /**< Last request type (CON/NON) */ + uint8_t szx; /**< size of individual blocks */ + size_t total_len; /**< Length as indicated by SIZE1 option */ + coap_binary_t *body_data; /**< Used for re-assembling entire body */ + size_t amount_so_far; /**< Amount of data seen so far */ + coap_resource_t *resource; /**< associated resource */ + coap_str_const_t *uri_path; /** set to uri_path if unknown resource */ + coap_rblock_t rec_blocks; /** < list of received blocks */ + uint8_t last_token[8]; /**< last used token */ + size_t last_token_length; /**< length of token */ + coap_mid_t last_mid; /**< Last received mid for this set of packets */ + coap_tick_t last_used; /**< Last time data sent or 0 */ + uint16_t block_option; /**< Block option in use */ +}; + +coap_lg_crcv_t * coap_block_new_lg_crcv(coap_session_t *session, + coap_pdu_t *pdu); + +void coap_block_delete_lg_crcv(coap_session_t *session, + coap_lg_crcv_t *lg_crcv); + +coap_tick_t coap_block_check_lg_crcv_timeouts(coap_session_t *session, + coap_tick_t now); + +void coap_block_delete_lg_srcv(coap_session_t *session, + coap_lg_srcv_t *lg_srcv); + +coap_tick_t coap_block_check_lg_srcv_timeouts(coap_session_t *session, + coap_tick_t now); + +int coap_handle_request_send_block(coap_session_t *session, + coap_pdu_t *pdu, + coap_pdu_t *response, + coap_resource_t *resource, + coap_string_t *query); + +int coap_handle_request_put_block(coap_context_t *context, + coap_session_t *session, + coap_pdu_t *pdu, + coap_pdu_t *response, + coap_resource_t *resource, + coap_string_t *uri_path, + coap_opt_t *observe, + coap_string_t *query, + coap_method_handler_t h, + int *added_block); + +int coap_handle_response_send_block(coap_session_t *session, coap_pdu_t *rcvd); + +int coap_handle_response_get_block(coap_context_t *context, + coap_session_t *session, + coap_pdu_t *sent, + coap_pdu_t *rcvd, + coap_recurse_t recursive); + +void coap_block_delete_lg_xmit(coap_session_t *session, + coap_lg_xmit_t *lg_xmit); + +/** + * The function that does all the work for the coap_add_data_large*() + * functions. + * + * @param session The session to associate the data with. + * @param pdu The PDU to associate the data with. + * @param resource The resource to associate the data with (BLOCK2). + * @param query The query to associate the data with (BLOCK2). + * @param maxage The maxmimum life of the data. If @c -1, then there + * is no maxage (BLOCK2). + * @param etag ETag to use if not 0 (BLOCK2). + * @param length The length of data to transmit. + * @param data The data to transmit. + * @param release_func The function to call to de-allocate @p data or NULL if + * the function is not required. + * @param app_ptr A Pointer that the application can provide for when + * release_func() is called. + * + * @return @c 1 if transmission initiation is successful, else @c 0. + */ +int coap_add_data_large_internal(coap_session_t *session, + coap_pdu_t *pdu, + coap_resource_t *resource, + const coap_string_t *query, + int maxage, + uint64_t etag, + size_t length, + const uint8_t *data, + coap_release_large_data_t release_func, + void *app_ptr); + +/** + * The function checks that the code in a newly formed lg_xmit created by + * coap_add_data_large_response() is updated. + * + * @param session The session + * @param response The response PDU to to check + * @param resource The requested resource + * @param query The requested query + */ +void coap_check_code_lg_xmit(coap_session_t *session, coap_pdu_t *response, + coap_resource_t *resource, coap_string_t *query); + +/** @} */ + +#endif /* COAP_BLOCK_INTERNAL_H_ */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_cache.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_cache.h new file mode 100644 index 00000000000..a8d2fd7a84e --- /dev/null +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_cache.h @@ -0,0 +1,232 @@ +/* coap_cache.h -- Caching of CoAP requests +* +* Copyright (C) 2020 Olaf Bergmann +* + * SPDX-License-Identifier: BSD-2-Clause + * +* This file is part of the CoAP library libcoap. Please see +* README for terms of use. +*/ + +/** + * @file coap_cache.h + * @brief Provides a simple cache request storage for CoAP requests + */ + +#ifndef COAP_CACHE_H_ +#define COAP_CACHE_H_ + +#include "coap_forward_decls.h" + +/** + * @defgroup cache Cache Support + * API functions for CoAP Caching + * @{ + */ + +/** + * Callback to free off the app data when the cache-entry is + * being deleted / freed off. + * + * @param data The app data to be freed off. + */ +typedef void (*coap_cache_app_data_free_callback_t)(void *data); + +typedef enum coap_cache_session_based_t { + COAP_CACHE_NOT_SESSION_BASED, + COAP_CACHE_IS_SESSION_BASED +} coap_cache_session_based_t; + +typedef enum coap_cache_record_pdu_t { + COAP_CACHE_NOT_RECORD_PDU, + COAP_CACHE_RECORD_PDU +} coap_cache_record_pdu_t; + +/** + * Calculates a cache-key for the given CoAP PDU. See + * https://tools.ietf.org/html/rfc7252#section-5.6 + * for an explanation of CoAP cache keys. + * + * Specific CoAP options can be removed from the cache-key. Examples of + * this are the BLOCK1 and BLOCK2 options - which make no real sense including + * them in a client or server environment, but should be included in a proxy + * caching environment where things are cached on a per block basis. + * This is done globally by calling the coap_cache_ignore_options() + * function. + * + * NOTE: The returned cache-key needs to be freed off by the caller by + * calling coap_cache_delete_key(). + * + * @param session The session to add into cache-key if @p session_based + * is set. + * @param pdu The CoAP PDU for which a cache-key is to be + * calculated. + * @param session_based COAP_CACHE_IS_SESSION_BASED if session based + * cache-key, else COAP_CACHE_NOT_SESSION_BASED. + * + * @return The returned cache-key or @c NULL if failure. + */ +coap_cache_key_t *coap_cache_derive_key(const coap_session_t *session, + const coap_pdu_t *pdu, + coap_cache_session_based_t session_based); + +/** + * Calculates a cache-key for the given CoAP PDU. See + * https://tools.ietf.org/html/rfc7252#section-5.6 + * for an explanation of CoAP cache keys. + * + * Specific CoAP options can be removed from the cache-key. Examples of + * this are the BLOCK1 and BLOCK2 options - which make no real sense including + * them in a client or server environment, but should be included in a proxy + * caching environment where things are cached on a per block basis. + * This is done individually by specifying @p cache_ignore_count and + * @p cache_ignore_options . + * + * NOTE: The returned cache-key needs to be freed off by the caller by + * calling coap_cache_delete_key(). + * + * @param session The session to add into cache-key if @p session_based + * is set. + * @param pdu The CoAP PDU for which a cache-key is to be + * calculated. + * @param session_based COAP_CACHE_IS_SESSION_BASED if session based + * cache-key, else COAP_CACHE_NOT_SESSION_BASED. + * @param ignore_options The array of options to ignore. + * @param ignore_count The number of options to ignore. + * + * @return The returned cache-key or @c NULL if failure. + */ +coap_cache_key_t *coap_cache_derive_key_w_ignore(const coap_session_t *session, + const coap_pdu_t *pdu, + coap_cache_session_based_t session_based, + const uint16_t *ignore_options, + size_t ignore_count); + +/** + * Delete the cache-key. + * + * @param cache_key The cache-key to delete. + */ +void coap_delete_cache_key(coap_cache_key_t *cache_key); + +/** + * Define the CoAP options that are not to be included when calculating + * the cache-key. Options that are defined as Non-Cache and the Observe + * option are always ignored. + * + * @param context The context to save the ignored options information in. + * @param options The array of options to ignore. + * @param count The number of options to ignore. Use 0 to reset the + * options matching. + * + * @return @return @c 1 if successful, else @c 0. + */ +int coap_cache_ignore_options(coap_context_t *context, + const uint16_t *options, size_t count); + +/** + * Create a new cache-entry hash keyed by cache-key derived from the PDU. + * + * If @p session_based is set, then this cache-entry will get deleted when + * the session is freed off. + * If @p record_pdu is set, then the copied PDU will get freed off when + * this cache-entry is deleted. + * + * The cache-entry is maintained on a context hash list. + * + * @param session The session to use to derive the context from. + * @param pdu The pdu to use to generate the cache-key. + * @param record_pdu COAP_CACHE_RECORD_PDU if to take a copy of the PDU for + * later use, else COAP_CACHE_NOT_RECORD_PDU. + * @param session_based COAP_CACHE_IS_SESSION_BASED if to associate this + * cache-entry with the the session (which is embedded + * in the cache-entry), else COAP_CACHE_NOT_SESSION_BASED. + * @param idle_time Idle time in seconds before cache-entry is expired. + * If set to 0, it does not expire (but will get + * deleted if the session is deleted and it is session_based). + * + * @return The returned cache-key or @c NULL if failure. + */ +coap_cache_entry_t *coap_new_cache_entry(coap_session_t *session, + const coap_pdu_t *pdu, + coap_cache_record_pdu_t record_pdu, + coap_cache_session_based_t session_based, + unsigned int idle_time); + +/** + * Remove a cache-entry from the hash list and free off all the appropriate + * contents apart from app_data. + * + * @param context The context to use. + * @param cache_entry The cache-entry to remove. + */ +void coap_delete_cache_entry(coap_context_t *context, + coap_cache_entry_t *cache_entry); + +/** + * Searches for a cache-entry identified by @p cache_key. This + * function returns the corresponding cache-entry or @c NULL + * if not found. + * + * @param context The context to use. + * @param cache_key The cache-key to get the hashed coap-entry. + * + * @return The cache-entry for @p cache_key or @c NULL if not found. + */ +coap_cache_entry_t *coap_cache_get_by_key(coap_context_t *context, + const coap_cache_key_t *cache_key); + +/** + * Searches for a cache-entry corresponding to @p pdu. This + * function returns the corresponding cache-entry or @c NULL if not + * found. + * + * @param session The session to use. + * @param pdu The CoAP request to search for. + * @param session_based COAP_CACHE_IS_SESSION_BASED if session based + * cache-key to be used, else COAP_CACHE_NOT_SESSION_BASED. + * + * @return The cache-entry for @p request or @c NULL if not found. + */ +coap_cache_entry_t *coap_cache_get_by_pdu(coap_session_t *session, + const coap_pdu_t *pdu, + coap_cache_session_based_t session_based); + +/** + * Returns the PDU information stored in the @p coap_cache entry. + * + * @param cache_entry The CoAP cache entry. + * + * @return The PDU information stored in the cache_entry or NULL + * if the PDU was not initially copied. + */ +const coap_pdu_t *coap_cache_get_pdu(const coap_cache_entry_t *cache_entry); + +/** + * Stores @p data with the given cache entry. This function + * overwrites any value that has previously been stored with @p + * cache_entry. + * + * @param cache_entry The CoAP cache entry. + * @param data The data pointer to store with wih the cache entry. Note that + * this data must be valid during the lifetime of @p cache_entry. + * @param callback The callback to call to free off this data when the + * cache-entry is deleted, or @c NULL if not required. + */ +void coap_cache_set_app_data(coap_cache_entry_t *cache_entry, void *data, + coap_cache_app_data_free_callback_t callback); + +/** + * Returns any application-specific data that has been stored with @p + * cache_entry using the function coap_cache_set_app_data(). This function will + * return @c NULL if no data has been stored. + * + * @param cache_entry The CoAP cache entry. + * + * @return The data pointer previously stored or @c NULL if no data stored. + */ +void *coap_cache_get_app_data(const coap_cache_entry_t *cache_entry); + +/** @} */ + +#endif /* COAP_CACHE_H */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_cache_internal.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_cache_internal.h new file mode 100644 index 00000000000..29c0756875c --- /dev/null +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_cache_internal.h @@ -0,0 +1,111 @@ +/* + * coap_cache_internal.h -- Cache functions for libcoap + * + * Copyright (C) 2019--2020 Olaf Bergmann and others + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_cache_internal.h + * @brief COAP cache internal information + */ + +#ifndef COAP_CACHE_INTERNAL_H_ +#define COAP_CACHE_INTERNAL_H_ + +#include "coap_io.h" + +/** + * @defgroup cache_internal Cache Support (Internal) + * CoAP Cache Structures, Enums and Functions that are not exposed to + * applications + * @{ + */ + +/* Holds a digest in binary typically sha256 except for notls */ +typedef struct coap_digest_t { + uint8_t key[32]; +} coap_digest_t; + +struct coap_cache_key_t { + uint8_t key[32]; +}; + +struct coap_cache_entry_t { + UT_hash_handle hh; + coap_cache_key_t *cache_key; + coap_session_t *session; + coap_pdu_t *pdu; + void* app_data; + coap_tick_t expire_ticks; + unsigned int idle_timeout; + coap_cache_app_data_free_callback_t callback; +}; + +/** + * Expire coap_cache_entry_t entries + * + * Internal function. + * + * @param context The context holding the coap-entries to exire + */ +void coap_expire_cache_entries(coap_context_t *context); + +typedef void coap_digest_ctx_t; + +/** + * Initialize a coap_digest + * + * Internal function. + * + * @return The digest context or @c NULL if failure. + */ +coap_digest_ctx_t *coap_digest_setup(void); + +/** + * Free off coap_digest_ctx_t. Always done by + * coap_digest_final() + * + * Internal function. + * + * @param digest_ctx The coap_digest context. + */ +void coap_digest_free(coap_digest_ctx_t *digest_ctx); + +/** + * Update the coap_digest information with the next chunk of data + * + * Internal function. + * + * @param digest_ctx The coap_digest context. + * @param data Pointer to data. + * @param data_len Number of bytes. + * + * @return @c 1 success, @c 0 failure. + */ +int coap_digest_update(coap_digest_ctx_t *digest_ctx, + const uint8_t *data, + size_t data_len + ); + +/** + * Finalize the coap_digest information into the provided + * @p digest_buffer. + * + * Internal function. + * + * @param digest_ctx The coap_digest context. + * @param digest_buffer Pointer to digest buffer to update + * + * @return @c 1 success, @c 0 failure. + */ +int coap_digest_final(coap_digest_ctx_t *digest_ctx, + coap_digest_t *digest_buffer); + +/** @} */ + +#endif /* COAP_CACHE_INTERNAL_H_ */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/coap_debug.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_debug.h similarity index 78% rename from tools/sdk/esp32s2/include/coap/libcoap/include/coap2/coap_debug.h rename to tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_debug.h index e4631b71f2b..f8f70f64495 100644 --- a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/coap_debug.h +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_debug.h @@ -3,6 +3,8 @@ * * Copyright (C) 2010-2011,2014 Olaf Bergmann * + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ @@ -36,8 +38,16 @@ * Logging type. One of LOG_* from @b syslog. */ typedef short coap_log_t; -#else -/** Pre-defined log levels akin to what is used in \b syslog. */ +/* + LOG_DEBUG+2 gives ciphers in GnuTLS + Use COAP_LOG_CIPHERS to output Cipher Info in OpenSSL etc. + */ +#define COAP_LOG_CIPHERS (LOG_DEBUG+2) +#else /* !HAVE_SYSLOG_H */ +/** Pre-defined log levels akin to what is used in \b syslog + with LOG_CIPHERS added. */ + +#if !defined(RIOT_VERSION) typedef enum { LOG_EMERG=0, /**< Emergency */ LOG_ALERT, /**< Alert */ @@ -46,9 +56,29 @@ typedef enum { LOG_WARNING, /**< Warning */ LOG_NOTICE, /**< Notice */ LOG_INFO, /**< Information */ - LOG_DEBUG /**< Debug */ + LOG_DEBUG, /**< Debug */ + COAP_LOG_CIPHERS=LOG_DEBUG+2 /**< CipherInfo */ } coap_log_t; -#endif +#else /* RIOT_VERSION */ +/* RIOT defines a subset of the syslog levels in log.h with different + * numeric values. The remaining levels are defined here. Note that + * output granularity differs from what would be expected when + * adhering to the syslog levels. + */ +#include +typedef short coap_log_t; +#define LOG_EMERG (0) +#define LOG_ALERT (1) +#define LOG_CRIT (2) +#define LOG_ERR (3) +/* LOG_WARNING (4) */ +#define LOG_NOTICE (5) +/* LOG_INFO (6) */ +/* LOG_DEBUG (7) */ +#define COAP_LOG_CIPHERS (9) +#endif /* RIOT_VERSION */ + +#endif /* !HAVE_SYSLOG_H */ /** * Get the current logging level. @@ -65,7 +95,7 @@ coap_log_t coap_get_log_level(void); void coap_set_log_level(coap_log_t level); /** - * Logging call-back handler definition. + * Logging callback handler definition. * * @param level One of the LOG_* values. * @param message Zero-terminated string message to log. @@ -163,7 +193,15 @@ void coap_show_tls_version(coap_log_t level); */ char *coap_string_tls_version(char *buffer, size_t bufsize); -struct coap_address_t; +/** + * Build a string containing the current (D)TLS library support + * + * @param buffer The buffer to put the string into. + * @param bufsize The size of the buffer to put the string into. + * + * @return A pointer to the provided buffer. + */ +char *coap_string_tls_support(char *buffer, size_t bufsize); /** * Print the address into the defined buffer. @@ -176,7 +214,7 @@ struct coap_address_t; * * @return The amount written into the buffer. */ -size_t coap_print_addr(const struct coap_address_t *address, +size_t coap_print_addr(const coap_address_t *address, unsigned char *buffer, size_t size); /** @} */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_dtls.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_dtls.h new file mode 100644 index 00000000000..cbd369dfce6 --- /dev/null +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_dtls.h @@ -0,0 +1,479 @@ +/* + * coap_dtls.h -- (Datagram) Transport Layer Support for libcoap + * + * Copyright (C) 2016 Olaf Bergmann + * Copyright (C) 2017 Jean-Claude Michelou + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +#ifndef COAP_DTLS_H_ +#define COAP_DTLS_H_ + +#include "coap_time.h" +#include "str.h" + +/** + * @defgroup dtls DTLS Support + * API functions for interfacing with DTLS libraries. + * @{ + */ + +typedef struct coap_dtls_pki_t coap_dtls_pki_t; + +#ifndef COAP_DTLS_HINT_LENGTH +#define COAP_DTLS_HINT_LENGTH 128 +#endif + +typedef enum coap_dtls_role_t { + COAP_DTLS_ROLE_CLIENT, /**< Internal function invoked for client */ + COAP_DTLS_ROLE_SERVER /**< Internal function invoked for server */ +} coap_dtls_role_t; + +#define COAP_DTLS_RPK_CERT_CN "RPK" + +/** + * Check whether DTLS is available. + * + * @return @c 1 if support for DTLS is enabled, or @c 0 otherwise. + */ +int coap_dtls_is_supported(void); + +/** + * Check whether TLS is available. + * + * @return @c 1 if support for TLS is enabled, or @c 0 otherwise. + */ +int coap_tls_is_supported(void); + +typedef enum coap_tls_library_t { + COAP_TLS_LIBRARY_NOTLS = 0, /**< No DTLS library */ + COAP_TLS_LIBRARY_TINYDTLS, /**< Using TinyDTLS library */ + COAP_TLS_LIBRARY_OPENSSL, /**< Using OpenSSL library */ + COAP_TLS_LIBRARY_GNUTLS, /**< Using GnuTLS library */ + COAP_TLS_LIBRARY_MBEDTLS, /**< Using Mbed TLS library */ +} coap_tls_library_t; + +/** + * The structure used for returning the underlying (D)TLS library + * information. + */ +typedef struct coap_tls_version_t { + uint64_t version; /**< (D)TLS runtime Library Version */ + coap_tls_library_t type; /**< Library type. One of COAP_TLS_LIBRARY_* */ + uint64_t built_version; /**< (D)TLS Built against Library Version */ +} coap_tls_version_t; + +/** + * Determine the type and version of the underlying (D)TLS library. + * + * @return The version and type of library libcoap was compiled against. + */ +coap_tls_version_t *coap_get_tls_library_version(void); + +/** + * Additional Security setup handler that can be set up by + * coap_context_set_pki(). + * Invoked when libcoap has done the validation checks at the TLS level, + * but the application needs to do some additional checks/changes/updates. + * + * @param tls_session The security session definition - e.g. SSL * for OpenSSL. + * NULL if server callback. + * This will be dependent on the underlying TLS library - + * see coap_get_tls_library_version() + * @param setup_data A structure containing setup data originally passed into + * coap_context_set_pki() or coap_new_client_session_pki(). + * + * @return @c 1 if successful, else @c 0. + */ +typedef int (*coap_dtls_security_setup_t)(void* tls_session, + coap_dtls_pki_t *setup_data); + +/** + * CN Validation callback that can be set up by coap_context_set_pki(). + * Invoked when libcoap has done the validation checks at the TLS level, + * but the application needs to check that the CN is allowed. + * CN is the SubjectAltName in the cert, if not present, then the leftmost + * Common Name (CN) component of the subject name. + * NOTE: If using RPK, then the Public Key does not contain a CN, but the + * content of COAP_DTLS_RPK_CERT_CN is presented for the @p cn parameter. + * + * @param cn The determined CN from the certificate + * @param asn1_public_cert The ASN.1 DER encoded X.509 certificate + * @param asn1_length The ASN.1 length + * @param coap_session The CoAP session associated with the certificate update + * @param depth Depth in cert chain. If 0, then client cert, else a CA + * @param validated TLS layer can find no issues if 1 + * @param arg The same as was passed into coap_context_set_pki() + * in setup_data->cn_call_back_arg + * + * @return @c 1 if accepted, else @c 0 if to be rejected. + */ +typedef int (*coap_dtls_cn_callback_t)(const char *cn, + const uint8_t *asn1_public_cert, + size_t asn1_length, + coap_session_t *coap_session, + unsigned int depth, + int validated, + void *arg); + +/** + * The enum used for determining the provided PKI ASN.1 (DER) Private Key + * formats. + */ +typedef enum coap_asn1_privatekey_type_t { + COAP_ASN1_PKEY_NONE, /**< NONE */ + COAP_ASN1_PKEY_RSA, /**< RSA type */ + COAP_ASN1_PKEY_RSA2, /**< RSA2 type */ + COAP_ASN1_PKEY_DSA, /**< DSA type */ + COAP_ASN1_PKEY_DSA1, /**< DSA1 type */ + COAP_ASN1_PKEY_DSA2, /**< DSA2 type */ + COAP_ASN1_PKEY_DSA3, /**< DSA3 type */ + COAP_ASN1_PKEY_DSA4, /**< DSA4 type */ + COAP_ASN1_PKEY_DH, /**< DH type */ + COAP_ASN1_PKEY_DHX, /**< DHX type */ + COAP_ASN1_PKEY_EC, /**< EC type */ + COAP_ASN1_PKEY_HMAC, /**< HMAC type */ + COAP_ASN1_PKEY_CMAC, /**< CMAC type */ + COAP_ASN1_PKEY_TLS1_PRF, /**< TLS1_PRF type */ + COAP_ASN1_PKEY_HKDF /**< HKDF type */ +} coap_asn1_privatekey_type_t; + +/** + * The enum used for determining the PKI key formats. + */ +typedef enum coap_pki_key_t { + COAP_PKI_KEY_PEM = 0, /**< The PKI key type is PEM file */ + COAP_PKI_KEY_ASN1, /**< The PKI key type is ASN.1 (DER) buffer */ + COAP_PKI_KEY_PEM_BUF, /**< The PKI key type is PEM buffer */ + COAP_PKI_KEY_PKCS11, /**< The PKI key type is PKCS11 (DER) */ +} coap_pki_key_t; + +/** + * The structure that holds the PKI PEM definitions. + */ +typedef struct coap_pki_key_pem_t { + const char *ca_file; /**< File location of Common CA in PEM format */ + const char *public_cert; /**< File location of Public Cert */ + const char *private_key; /**< File location of Private Key in PEM format */ +} coap_pki_key_pem_t; + +/** + * The structure that holds the PKI PEM buffer definitions. + * The certificates and private key data must be in PEM format. + * + * Note: The Certs and Key should be NULL terminated strings for + * performance reasons (to save a potential buffer copy) and the length include + * this NULL terminator. It is not a requirement to have the NULL terminator + * though and the length must then reflect the actual data size. + */ +typedef struct coap_pki_key_pem_buf_t { + const uint8_t *ca_cert; /**< PEM buffer Common CA Cert */ + const uint8_t *public_cert; /**< PEM buffer Public Cert, or Public Key if RPK */ + const uint8_t *private_key; /**< PEM buffer Private Key + If RPK and 'EC PRIVATE KEY' this can be used + for both the public_cert and private_key */ + size_t ca_cert_len; /**< PEM buffer CA Cert length */ + size_t public_cert_len; /**< PEM buffer Public Cert length */ + size_t private_key_len; /**< PEM buffer Private Key length */ +} coap_pki_key_pem_buf_t; + +/** + * The structure that holds the PKI ASN.1 (DER) definitions. + */ +typedef struct coap_pki_key_asn1_t { + const uint8_t *ca_cert; /**< ASN1 (DER) Common CA Cert */ + const uint8_t *public_cert; /**< ASN1 (DER) Public Cert, or Public Key if RPK */ + const uint8_t *private_key; /**< ASN1 (DER) Private Key */ + size_t ca_cert_len; /**< ASN1 CA Cert length */ + size_t public_cert_len; /**< ASN1 Public Cert length */ + size_t private_key_len; /**< ASN1 Private Key length */ + coap_asn1_privatekey_type_t private_key_type; /**< Private Key Type */ +} coap_pki_key_asn1_t; + +/** + * The structure that holds the PKI PKCS11 definitions. + */ +typedef struct coap_pki_key_pkcs11_t { + const char *ca; /**< pkcs11: URI for Common CA Certificate */ + const char *public_cert; /**< pkcs11: URI for Public Cert */ + const char *private_key; /**< pkcs11: URI for Private Key */ + const char *user_pin; /**< User pin to access PKCS11. If NULL, then + pin-value= parameter must be set in + pkcs11: URI as a query. */ +} coap_pki_key_pkcs11_t; + +/** + * The structure that holds the PKI key information. + */ +typedef struct coap_dtls_key_t { + coap_pki_key_t key_type; /**< key format type */ + union { + coap_pki_key_pem_t pem; /**< for PEM file keys */ + coap_pki_key_pem_buf_t pem_buf; /**< for PEM memory keys */ + coap_pki_key_asn1_t asn1; /**< for ASN.1 (DER) memory keys */ + coap_pki_key_pkcs11_t pkcs11; /**< for PKCS11 keys */ + } key; +} coap_dtls_key_t; + +/** + * Server Name Indication (SNI) Validation callback that can be set up by + * coap_context_set_pki(). + * Invoked if the SNI is not previously seen and prior to sending a certificate + * set back to the client so that the appropriate certificate set can be used + * based on the requesting SNI. + * + * @param sni The requested SNI + * @param arg The same as was passed into coap_context_set_pki() + * in setup_data->sni_call_back_arg + * + * @return New set of certificates to use, or @c NULL if SNI is to be rejected. + */ +typedef coap_dtls_key_t *(*coap_dtls_pki_sni_callback_t)(const char *sni, + void* arg); + + +#define COAP_DTLS_PKI_SETUP_VERSION 1 /**< Latest PKI setup version */ + +/** + * The structure used for defining the PKI setup data to be used. + */ +struct coap_dtls_pki_t { + uint8_t version; /** Set to COAP_DTLS_PKI_SETUP_VERSION + to support this version of the struct */ + + /* Options to enable different TLS functionality in libcoap */ + uint8_t verify_peer_cert; /**< 1 if peer cert is to be verified */ + uint8_t check_common_ca; /**< 1 if peer cert is to be signed by + * the same CA as the local cert */ + uint8_t allow_self_signed; /**< 1 if self-signed certs are allowed. + * Ignored if check_common_ca set */ + uint8_t allow_expired_certs; /**< 1 if expired certs are allowed */ + uint8_t cert_chain_validation; /**< 1 if to check cert_chain_verify_depth */ + uint8_t cert_chain_verify_depth; /**< recommended depth is 3 */ + uint8_t check_cert_revocation; /**< 1 if revocation checks wanted */ + uint8_t allow_no_crl; /**< 1 ignore if CRL not there */ + uint8_t allow_expired_crl; /**< 1 if expired crl is allowed */ + uint8_t allow_bad_md_hash; /**< 1 if unsupported MD hashes are allowed */ + uint8_t allow_short_rsa_length; /**< 1 if small RSA keysizes are allowed */ + uint8_t is_rpk_not_cert; /**< 1 is RPK instead of Public Certificate. + * If set, PKI key format type cannot be + * COAP_PKI_KEY_PEM */ + uint8_t reserved[3]; /**< Reserved - must be set to 0 for + future compatibility */ + /* Size of 3 chosen to align to next + * parameter, so if newly defined option + * it can use one of the reserverd slot so + * no need to change + * COAP_DTLS_PKI_SETUP_VERSION and just + * decrement the reserved[] count. + */ + + /** CN check callback function. + * If not NULL, is called when the TLS connection has passed the configured + * TLS options above for the application to verify if the CN is valid. + */ + coap_dtls_cn_callback_t validate_cn_call_back; + void *cn_call_back_arg; /**< Passed in to the CN callback function */ + + /** SNI check callback function. + * If not @p NULL, called if the SNI is not previously seen and prior to + * sending a certificate set back to the client so that the appropriate + * certificate set can be used based on the requesting SNI. + */ + coap_dtls_pki_sni_callback_t validate_sni_call_back; + void *sni_call_back_arg; /**< Passed in to the sni callback function */ + + /** Additional Security callback handler that is invoked when libcoap has + * done the standard, defined validation checks at the TLS level, + * If not @p NULL, called from within the TLS Client Hello connection + * setup. + */ + coap_dtls_security_setup_t additional_tls_setup_call_back; + + char* client_sni; /**< If not NULL, SNI to use in client TLS setup. + Owned by the client app and must remain valid + during the call to coap_new_client_session_pki() */ + + coap_dtls_key_t pki_key; /**< PKI key definition */ +}; + +/** + * The structure that holds the Client PSK information. + */ +typedef struct coap_dtls_cpsk_info_t { + coap_bin_const_t identity; + coap_bin_const_t key; +} coap_dtls_cpsk_info_t; + +/** + * Identity Hint Validation callback that can be set up by + * coap_new_client_session_psk2(). + * Invoked when libcoap has done the validation checks at the TLS level, + * but the application needs to check that the Identity Hint is allowed, + * and thus needs to use the appropriate PSK information for the Identity + * Hint for the (D)TLS session. + * Note: Identity Hint is not supported in (D)TLS1.3. + * + * @param hint The server provided Identity Hint + * @param coap_session The CoAP session associated with the Identity Hint + * @param arg The same as was passed into coap_new_client_session_psk2() + * in setup_data->ih_call_back_arg + * + * @return New coap_dtls_cpsk_info_t object or @c NULL on error. + */ +typedef const coap_dtls_cpsk_info_t *(*coap_dtls_ih_callback_t)( + coap_str_const_t *hint, + coap_session_t *coap_session, + void *arg); + +#define COAP_DTLS_CPSK_SETUP_VERSION 1 /**< Latest CPSK setup version */ + +/** + * The structure used for defining the Client PSK setup data to be used. + */ +typedef struct coap_dtls_cpsk_t { + uint8_t version; /** Set to COAP_DTLS_CPSK_SETUP_VERSION + to support this version of the struct */ + + /* Options to enable different TLS functionality in libcoap */ + uint8_t reserved[7]; /**< Reserved - must be set to 0 for + future compatibility */ + /* Size of 7 chosen to align to next + * parameter, so if newly defined option + * it can use one of the reserverd slot so + * no need to change + * COAP_DTLS_CPSK_SETUP_VERSION and just + * decrement the reserved[] count. + */ + + /** Identity Hint check callback function. + * If not NULL, is called when the Identity Hint (TLS1.2 or earlier) is + * provided by the server. + * The appropriate Identity and Pre-shared Key to use can then be returned. + */ + coap_dtls_ih_callback_t validate_ih_call_back; + void *ih_call_back_arg; /**< Passed in to the Identity Hint callback + function */ + + char* client_sni; /**< If not NULL, SNI to use in client TLS setup. + Owned by the client app and must remain valid + during the call to coap_new_client_session_psk2() + Note: Not supported by TinyDTLS. */ + + coap_dtls_cpsk_info_t psk_info; /**< Client PSK definition */ +} coap_dtls_cpsk_t; + +/** + * The structure that holds the Server Pre-Shared Key and Identity + * Hint information. + */ +typedef struct coap_dtls_spsk_info_t { + coap_bin_const_t hint; + coap_bin_const_t key; +} coap_dtls_spsk_info_t; + + +/** + * Identity Validation callback that can be set up by + * coap_context_set_psk2(). + * Invoked when libcoap has done the validation checks at the TLS level, + * but the application needs to check that the Identity is allowed, + * and needs to use the appropriate Pre-Shared Key for the (D)TLS session. + * + * @param identity The client provided Identity + * @param coap_session The CoAP session associated with the Identity Hint + * @param arg The value as passed into coap_context_set_psk2() + * in setup_data->id_call_back_arg + * + * @return New coap_bin_const_t object containing the Pre-Shared Key or + @c NULL on error. + * Note: This information will be duplicated into an internal + * structure. + */ +typedef const coap_bin_const_t *(*coap_dtls_id_callback_t)( + coap_bin_const_t *identity, + coap_session_t *coap_session, + void *arg); +/** + * PSK SNI callback that can be set up by coap_context_set_psk2(). + * Invoked when libcoap has done the validation checks at the TLS level + * and the application needs to:- + * a) check that the SNI is allowed + * b) provide the appropriate PSK information for the (D)TLS session. + * + * @param sni The client provided SNI + * @param coap_session The CoAP session associated with the SNI + * @param arg The same as was passed into coap_context_set_psk2() + * in setup_data->sni_call_back_arg + * + * @return New coap_dtls_spsk_info_t object or @c NULL on error. + */ +typedef const coap_dtls_spsk_info_t *(*coap_dtls_psk_sni_callback_t)( + const char *sni, + coap_session_t *coap_session, + void *arg); + +#define COAP_DTLS_SPSK_SETUP_VERSION 1 /**< Latest SPSK setup version */ + +/** + * The structure used for defining the Server PSK setup data to be used. + */ +typedef struct coap_dtls_spsk_t { + uint8_t version; /** Set to COAP_DTLS_SPSK_SETUP_VERSION + to support this version of the struct */ + + /* Options to enable different TLS functionality in libcoap */ + uint8_t reserved[7]; /**< Reserved - must be set to 0 for + future compatibility */ + /* Size of 7 chosen to align to next + * parameter, so if newly defined option + * it can use one of the reserverd slot so + * no need to change + * COAP_DTLS_SPSK_SETUP_VERSION and just + * decrement the reserved[] count. + */ + + /** Identity check callback function. + * If not @p NULL, is called when the Identity is provided by the client. + * The appropriate Pre-Shared Key to use can then be returned. + */ + coap_dtls_id_callback_t validate_id_call_back; + void *id_call_back_arg; /**< Passed in to the Identity callback function */ + + /** SNI check callback function. + * If not @p NULL, called if the SNI is not previously seen and prior to + * sending PSK information back to the client so that the appropriate + * PSK information can be used based on the requesting SNI. + */ + coap_dtls_psk_sni_callback_t validate_sni_call_back; + void *sni_call_back_arg; /**< Passed in to the SNI callback function */ + + coap_dtls_spsk_info_t psk_info; /**< Server PSK definition */ +} coap_dtls_spsk_t; + + +/** @} */ + +/** + * @ingroup logging + * Sets the (D)TLS logging level to the specified @p level. + * Note: coap_log_level() will influence output if at a specified level. + * + * @param level The logging level to use - LOG_* + */ +void coap_dtls_set_log_level(int level); + +/** + * @ingroup logging + * Get the current (D)TLS logging. + * + * @return The current log level (one of LOG_*). + */ +int coap_dtls_get_log_level(void); + + +#endif /* COAP_DTLS_H */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_dtls_internal.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_dtls_internal.h new file mode 100644 index 00000000000..8ea09a4eb3e --- /dev/null +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_dtls_internal.h @@ -0,0 +1,345 @@ +/* + * coap_dtls_internal.h -- (Datagram) Transport Layer Support for libcoap + * + * Copyright (C) 2016 Olaf Bergmann + * Copyright (C) 2017 Jean-Claude Michelou + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +#ifndef COAP_DTLS_INTERNAL_H_ +#define COAP_DTLS_INTERNAL_H_ + +/** + * @defgroup dtls_internal DTLS Support (Internal) + * CoAP DTLS Structures, Enums and Functions that are not exposed to + * applications + * @{ + */ + +/* https://tools.ietf.org/html/rfc6347#section-4.2.4.1 */ +#ifndef COAP_DTLS_RETRANSMIT_MS +#define COAP_DTLS_RETRANSMIT_MS 1000 +#endif +#ifndef COAP_DTLS_RETRANSMIT_TOTAL_MS +#define COAP_DTLS_RETRANSMIT_TOTAL_MS 60000 +#endif + +#define COAP_DTLS_RETRANSMIT_COAP_TICKS (COAP_DTLS_RETRANSMIT_MS * COAP_TICKS_PER_SECOND / 1000) + +/** + * Creates a new DTLS context for the given @p coap_context. This function + * returns a pointer to a new DTLS context object or @c NULL on error. + * + * @param coap_context The CoAP context where the DTLS object shall be used. + * + * @return A DTLS context object or @c NULL on error. + */ +void * +coap_dtls_new_context(coap_context_t *coap_context); + +/** + * Set the DTLS context's default server PSK information. + * This does the PSK specifics following coap_dtls_new_context(). + * + * @param coap_context The CoAP context. + * @param setup_data A structure containing setup data originally passed into + * coap_context_set_psk2(). + * + * @return @c 1 if successful, else @c 0. + */ + +int +coap_dtls_context_set_spsk(coap_context_t *coap_context, + coap_dtls_spsk_t *setup_data); + +/** + * Set the DTLS context's default client PSK information. + * This does the PSK specifics following coap_dtls_new_context(). + * + * @param coap_context The CoAP context. + * @param setup_data A structure containing setup data originally passed into + * coap_new_client_session_psk2(). + * + * @return @c 1 if successful, else @c 0. + */ + +int +coap_dtls_context_set_cpsk(coap_context_t *coap_context, + coap_dtls_cpsk_t *setup_data); + +/** + * Set the DTLS context's default server PKI information. + * This does the PKI specifics following coap_dtls_new_context(). + * If @p COAP_DTLS_ROLE_SERVER, then the information will get put into the + * TLS library's context (from which sessions are derived). + * If @p COAP_DTLS_ROLE_CLIENT, then the information will get put into the + * TLS library's session. + * + * @param coap_context The CoAP context. + * @param setup_data Setup information defining how PKI is to be setup. + * Required parameter. If @p NULL, PKI will not be + * set up. + * @param role One of @p COAP_DTLS_ROLE_CLIENT or @p COAP_DTLS_ROLE_SERVER + * + * @return @c 1 if successful, else @c 0. + */ + +int +coap_dtls_context_set_pki(coap_context_t *coap_context, + const coap_dtls_pki_t *setup_data, + const coap_dtls_role_t role); + +/** + * Set the dtls context's default Root CA information for a client or server. + * + * @param coap_context The current coap_context_t object. + * @param ca_file If not @p NULL, is the full path name of a PEM encoded + * file containing all the Root CAs to be used. + * @param ca_dir If not @p NULL, points to a directory containing PEM + * encoded files containing all the Root CAs to be used. + * + * @return @c 1 if successful, else @c 0. + */ + +int +coap_dtls_context_set_pki_root_cas(coap_context_t *coap_context, + const char *ca_file, + const char *ca_dir); + +/** + * Check whether one of the coap_dtls_context_set_{psk|pki}() functions have + * been called. + * + * @param coap_context The current coap_context_t object. + * + * @return @c 1 if coap_dtls_context_set_{psk|pki}() called, else @c 0. + */ + +int coap_dtls_context_check_keys_enabled(coap_context_t *coap_context); + +/** + * Releases the storage allocated for @p dtls_context. + * + * @param dtls_context The DTLS context as returned by coap_dtls_new_context(). + */ +void coap_dtls_free_context(void *dtls_context); + +/** + * Create a new client-side session. This should send a HELLO to the server. + * + * @param coap_session The CoAP session. + * + * @return Opaque handle to underlying TLS library object containing security + * parameters for the session. +*/ +void *coap_dtls_new_client_session(coap_session_t *coap_session); + +/** + * Create a new DTLS server-side session. + * Called after coap_dtls_hello() has returned @c 1, signalling that a validated + * HELLO was received from a client. + * This should send a HELLO to the server. + * + * @param coap_session The CoAP session. + * + * @return Opaque handle to underlying TLS library object containing security + * parameters for the DTLS session. + */ +void *coap_dtls_new_server_session(coap_session_t *coap_session); + +/** + * Terminates the DTLS session (may send an ALERT if necessary) then frees the + * underlying TLS library object containing security parameters for the session. + * + * @param coap_session The CoAP session. + */ +void coap_dtls_free_session(coap_session_t *coap_session); + +/** + * Notify of a change in the CoAP session's MTU, for example after + * a PMTU update. + * + * @param coap_session The CoAP session. + */ +void coap_dtls_session_update_mtu(coap_session_t *coap_session); + +/** + * Send data to a DTLS peer. + * + * @param coap_session The CoAP session. + * @param data pointer to data. + * @param data_len Number of bytes to send. + * + * @return @c 0 if this would be blocking, @c -1 if there is an error or the + * number of cleartext bytes sent. + */ +int coap_dtls_send(coap_session_t *coap_session, + const uint8_t *data, + size_t data_len); + +/** + * Check if timeout is handled per CoAP session or per CoAP context. + * + * @return @c 1 of timeout and retransmit is per context, @c 0 if it is + * per session. + */ +int coap_dtls_is_context_timeout(void); + +/** + * Do all pending retransmits and get next timeout + * + * @param dtls_context The DTLS context. + * + * @return @c 0 if no event is pending or date of the next retransmit. + */ +coap_tick_t coap_dtls_get_context_timeout(void *dtls_context); + +/** + * Get next timeout for this session. + * + * @param coap_session The CoAP session. + * @param now The current time in ticks. + * + * @return @c 0 If no event is pending or ticks time of the next retransmit. + */ +coap_tick_t coap_dtls_get_timeout(coap_session_t *coap_session, + coap_tick_t now); + +/** + * Handle a DTLS timeout expiration. + * + * @param coap_session The CoAP session. + */ +void coap_dtls_handle_timeout(coap_session_t *coap_session); + +/** + * Handling incoming data from a DTLS peer. + * + * @param coap_session The CoAP session. + * @param data Encrypted datagram. + * @param data_len Encrypted datagram size. + * + * @return Result of coap_handle_dgram on the decrypted CoAP PDU + * or @c -1 for error. + */ +int coap_dtls_receive(coap_session_t *coap_session, + const uint8_t *data, + size_t data_len); + +/** + * Handling client HELLO messages from a new candiate peer. + * Note that session->tls is empty. + * + * @param coap_session The CoAP session. + * @param data Encrypted datagram. + * @param data_len Encrypted datagram size. + * + * @return @c 0 if a cookie verification message has been sent, @c 1 if the + * HELLO contains a valid cookie and a server session should be created, + * @c -1 if the message is invalid. + */ +int coap_dtls_hello(coap_session_t *coap_session, + const uint8_t *data, + size_t data_len); + +/** + * Get DTLS overhead over cleartext PDUs. + * + * @param coap_session The CoAP session. + * + * @return Maximum number of bytes added by DTLS layer. + */ +unsigned int coap_dtls_get_overhead(coap_session_t *coap_session); + +/** + * Create a new TLS client-side session. + * + * @param coap_session The CoAP session. + * @param connected Updated with whether the connection is connected yet or not. + * @c 0 is not connected, @c 1 is connected. + * + * @return Opaque handle to underlying TLS library object containing security + * parameters for the session. +*/ +void *coap_tls_new_client_session(coap_session_t *coap_session, int *connected); + +/** + * Create a TLS new server-side session. + * + * @param coap_session The CoAP session. + * @param connected Updated with whether the connection is connected yet or not. + * @c 0 is not connected, @c 1 is connected. + * + * @return Opaque handle to underlying TLS library object containing security + * parameters for the session. + */ +void *coap_tls_new_server_session(coap_session_t *coap_session, int *connected); + +/** + * Terminates the TLS session (may send an ALERT if necessary) then frees the + * underlying TLS library object containing security parameters for the session. + * + * @param coap_session The CoAP session. + */ +void coap_tls_free_session( coap_session_t *coap_session ); + +/** + * Send data to a TLS peer, with implicit flush. + * + * @param coap_session The CoAP session. + * @param data Pointer to data. + * @param data_len Number of bytes to send. + * + * @return @c 0 if this should be retried, @c -1 if there is an error + * or the number of cleartext bytes sent. + */ +ssize_t coap_tls_write(coap_session_t *coap_session, + const uint8_t *data, + size_t data_len + ); + +/** + * Read some data from a TLS peer. + * + * @param coap_session The CoAP session. + * @param data Pointer to data. + * @param data_len Maximum number of bytes to read. + * + * @return @c 0 if this should be retried, @c -1 if there is an error + * or the number of cleartext bytes read. + */ +ssize_t coap_tls_read(coap_session_t *coap_session, + uint8_t *data, + size_t data_len + ); + +/** + * Initialize the underlying (D)TLS Library layer. + * + */ +void coap_dtls_startup(void); + +/** + * Close down the underlying (D)TLS Library layer. + * + */ +void coap_dtls_shutdown(void); + +/** + * Get the actual (D)TLS object for the session. + * + * @param session The session. + * @param tls_lib Updated with the library type. + * + * @return The TLS information. + */ +void *coap_dtls_get_tls(const coap_session_t *session, + coap_tls_library_t *tls_lib); + +/** @} */ + +#endif /* COAP_DTLS_INTERNAL_H */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/coap_event.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_event.h similarity index 79% rename from tools/sdk/esp32s2/include/coap/libcoap/include/coap2/coap_event.h rename to tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_event.h index 81a3b0511fd..89b2a63967c 100644 --- a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/coap_event.h +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_event.h @@ -3,6 +3,8 @@ * * Copyright (C) 2016 Olaf Bergmann * + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ @@ -12,9 +14,6 @@ #include "libcoap.h" -struct coap_context_t; -struct coap_session_t; - /** * @defgroup events Event API * API functions for event delivery from lower-layer library functions. @@ -49,17 +48,20 @@ struct coap_session_t; #define COAP_EVENT_SESSION_CLOSED 0x2002 #define COAP_EVENT_SESSION_FAILED 0x2003 +/** + * BLOCK2 receive errors + */ +#define COAP_EVENT_PARTIAL_BLOCK 0x3001 + /** * Type for event handler functions that can be registered with a CoAP * context using the unction coap_set_event_handler(). When called by - * the library, the first argument will be the coap_context_t object - * where the handler function has been registered. The second argument - * is the event type that may be complemented by event-specific data - * passed as the third argument. + * the library, the first argument will be the current coap_session_t object + * which is associated with the original CoAP context. The second parameter + * is the event type. */ -typedef int (*coap_event_handler_t)(struct coap_context_t *, - coap_event_t event, - struct coap_session_t *session); +typedef int (*coap_event_handler_t)(coap_session_t *session, + const coap_event_t event); /** * Registers the function @p hnd as callback for events from the given @@ -70,9 +72,11 @@ typedef int (*coap_event_handler_t)(struct coap_context_t *, * @param hnd The event handler to be registered. @c NULL if to be * de-registered. */ -void coap_register_event_handler(struct coap_context_t *context, +void coap_register_event_handler(coap_context_t *context, coap_event_handler_t hnd); +/** @} */ + /** * Registers the function @p hnd as callback for events from the given * CoAP context @p context. Any event handler that has previously been @@ -84,7 +88,7 @@ void coap_register_event_handler(struct coap_context_t *context, * @param hnd The event handler to be registered. */ COAP_DEPRECATED -void coap_set_event_handler(struct coap_context_t *context, +void coap_set_event_handler(coap_context_t *context, coap_event_handler_t hnd); /** @@ -95,8 +99,6 @@ void coap_set_event_handler(struct coap_context_t *context, * @param context The CoAP context whose event handler is to be removed. */ COAP_DEPRECATED -void coap_clear_event_handler(struct coap_context_t *context); - -/** @} */ +void coap_clear_event_handler(coap_context_t *context); #endif /* COAP_EVENT_H */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_forward_decls.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_forward_decls.h new file mode 100644 index 00000000000..3bedbf7899a --- /dev/null +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_forward_decls.h @@ -0,0 +1,107 @@ +/* + * coap_forward_decls.h -- Forward declarations of structures that are + * opaque to application programming that use libcoap. + * + * Copyright (C) 2019-2021 Jon Shallow + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_forward_decls.h + * @brief COAP forward definitions + */ + +#ifndef COAP_FORWARD_DECLS_H_ +#define COAP_FORWARD_DECLS_H_ + +/* + * Define the forward declations for the structures (even non-opaque) + * so that applications (using coap.h) as well as libcoap builds + * can reference them (and makes .h file dependencies a lot simpler). + */ +struct coap_address_t; +struct coap_bin_const_t; +struct coap_dtls_pki_t; +struct coap_str_const_t; +struct coap_string_t; + +/* + * typedef all the opaque structures that are defined in coap_*_internal.h + */ + +/* ************* coap_async_internal.h ***************** */ + +/** + * Async Entry information. + */ +typedef struct coap_async_t coap_async_t; + +/* ************* coap_block_internal.h ***************** */ + +/* + * Block handling information. + */ +typedef struct coap_lg_xmit_t coap_lg_xmit_t; +typedef struct coap_lg_crcv_t coap_lg_crcv_t; +typedef struct coap_lg_srcv_t coap_lg_srcv_t; + +/* ************* coap_cache_internal.h ***************** */ + +/* + * Cache Entry information. + */ +typedef struct coap_cache_entry_t coap_cache_entry_t; +typedef struct coap_cache_key_t coap_cache_key_t; + +/* ************* coap_io_internal.h ***************** */ + +/** + * coap_socket_t and coap_packet_t information. + */ +typedef struct coap_packet_t coap_packet_t; +typedef struct coap_socket_t coap_socket_t; + +/* ************* coap_net_internal.h ***************** */ + +/* + * Net information. + */ +typedef struct coap_context_t coap_context_t; +typedef struct coap_queue_t coap_queue_t; + +/* ************* coap_pdu_internal.h ***************** */ + +/** + * PDU information. + */ +typedef struct coap_pdu_t coap_pdu_t; + +/* ************* coap_resource_internal.h ***************** */ + +/* + * Resource information. + */ +typedef struct coap_attr_t coap_attr_t; +typedef struct coap_resource_t coap_resource_t; + +/* ************* coap_session_internal.h ***************** */ + +/* + * Session information. + */ +typedef struct coap_addr_hash_t coap_addr_hash_t; +typedef struct coap_endpoint_t coap_endpoint_t; +typedef struct coap_session_t coap_session_t; + +/* ************* coap_subscribe_internal.h ***************** */ + +/* + * Observe subscriber information. + */ +typedef struct coap_subscription_t coap_subscription_t; + +#endif /* COAP_FORWARD_DECLS_H_ */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/coap_hashkey.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_hashkey.h similarity index 93% rename from tools/sdk/esp32s2/include/coap/libcoap/include/coap2/coap_hashkey.h rename to tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_hashkey.h index 252f34822d4..11a797bde7a 100644 --- a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/coap_hashkey.h +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_hashkey.h @@ -3,6 +3,8 @@ * * Copyright (C) 2010-2011 Olaf Bergmann * + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ @@ -31,7 +33,7 @@ typedef unsigned char coap_key_t[4]; * @param len The length of @p s. * @param h The result buffer to store the calculated hash key. */ -void coap_hash_impl(const unsigned char *s, unsigned int len, coap_key_t h); +void coap_hash_impl(const unsigned char *s, size_t len, coap_key_t h); #define coap_hash(String,Length,Result) \ coap_hash_impl((String),(Length),(Result)) diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_internal.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_internal.h new file mode 100644 index 00000000000..5eee5c12867 --- /dev/null +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_internal.h @@ -0,0 +1,65 @@ +/* + * coap_internal.h -- Structures, Enums & Functions that are not exposed to + * application programming + * + * Copyright (C) 2019-2021 Jon Shallow + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/* + * All libcoap library files should include this file which then pulls in all + * of the other appropriate header files. + * + * Note: This file should never be included in application code (with the + * possible exception of internal test suites). + */ + +/** + * @file coap_internal.h + * @brief Pulls together all the internal only header files + */ + +#ifndef COAP_INTERNAL_H_ +#define COAP_INTERNAL_H_ + +#include "coap_config.h" + +/* + * Correctly set up assert() based on NDEBUG for libcoap + */ +#if defined(HAVE_ASSERT_H) && !defined(assert) +# include +#endif + +#include "coap3/coap.h" + +/* + * Include all the header files that are for internal use only. + */ + +/* Not defined in coap.h - internal usage .h files */ +#include "utlist.h" +#include "uthash.h" +#include "coap_hashkey.h" +#include "coap_mutex.h" + +/* Specifically defined internal .h files */ +#include "coap_asn1_internal.h" +#include "coap_async_internal.h" +#include "coap_block_internal.h" +#include "coap_cache_internal.h" +#include "coap_dtls_internal.h" +#include "coap_io_internal.h" +#include "coap_net_internal.h" +#include "coap_pdu_internal.h" +#include "coap_session_internal.h" +#include "coap_resource_internal.h" +#include "coap_session_internal.h" +#include "coap_subscribe_internal.h" +#include "coap_tcp_internal.h" + +#endif /* COAP_INTERNAL_H_ */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_io.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_io.h new file mode 100644 index 00000000000..b27921f8be1 --- /dev/null +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_io.h @@ -0,0 +1,72 @@ +/* + * coap_io.h -- Default network I/O functions for libcoap + * + * Copyright (C) 2012-2013 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +#ifndef COAP_IO_H_ +#define COAP_IO_H_ + +#include + +#include "address.h" + +#ifdef RIOT_VERSION +#include "net/gnrc.h" +#endif /* RIOT_VERSION */ + +#ifndef COAP_RXBUFFER_SIZE +#define COAP_RXBUFFER_SIZE 1472 +#endif /* COAP_RXBUFFER_SIZE */ + +/* + * It may may make sense to define this larger on busy systems + * (lots of sessions, large number of which are active), by using + * -DCOAP_MAX_EPOLL_EVENTS=nn at compile time. + */ +#ifndef COAP_MAX_EPOLL_EVENTS +#define COAP_MAX_EPOLL_EVENTS 10 +#endif /* COAP_MAX_EPOLL_EVENTS */ + +#ifdef _WIN32 +typedef SOCKET coap_fd_t; +#define coap_closesocket closesocket +#define COAP_SOCKET_ERROR SOCKET_ERROR +#define COAP_INVALID_SOCKET INVALID_SOCKET +#else +typedef int coap_fd_t; +#define coap_closesocket close +#define COAP_SOCKET_ERROR (-1) +#define COAP_INVALID_SOCKET (-1) +#endif + +typedef uint16_t coap_socket_flags_t; + +typedef struct coap_addr_tuple_t { + coap_address_t remote; /**< remote address and port */ + coap_address_t local; /**< local address and port */ +} coap_addr_tuple_t; + +const char *coap_socket_strerror( void ); + +/** + * Check whether TCP is available. + * + * @return @c 1 if support for TCP is enabled, or @c 0 otherwise. + */ +int coap_tcp_is_supported(void); + +typedef enum { + COAP_NACK_TOO_MANY_RETRIES, + COAP_NACK_NOT_DELIVERABLE, + COAP_NACK_RST, + COAP_NACK_TLS_FAILED, + COAP_NACK_ICMP_ISSUE +} coap_nack_reason_t; + +#endif /* COAP_IO_H_ */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/coap_io.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_io_internal.h similarity index 62% rename from tools/sdk/esp32s2/include/coap/libcoap/include/coap2/coap_io.h rename to tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_io_internal.h index 1854501be89..241ef7f9955 100644 --- a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/coap_io.h +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_io_internal.h @@ -3,41 +3,24 @@ * * Copyright (C) 2012-2013 Olaf Bergmann * + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ -#ifndef COAP_IO_H_ -#define COAP_IO_H_ +#ifndef COAP_IO_INTERNAL_H_ +#define COAP_IO_INTERNAL_H_ -#include #include #include "address.h" -#ifndef COAP_RXBUFFER_SIZE -#define COAP_RXBUFFER_SIZE 1472 -#endif /* COAP_RXBUFFER_SIZE */ - -#ifdef _WIN32 -typedef SOCKET coap_fd_t; -#define coap_closesocket closesocket -#define COAP_SOCKET_ERROR SOCKET_ERROR -#define COAP_INVALID_SOCKET INVALID_SOCKET -#else -typedef int coap_fd_t; -#define coap_closesocket close -#define COAP_SOCKET_ERROR (-1) -#define COAP_INVALID_SOCKET (-1) -#endif - -struct coap_packet_t; -struct coap_session_t; -struct coap_pdu_t; +#ifdef RIOT_VERSION +#include "net/gnrc.h" +#endif /* RIOT_VERSION */ -typedef uint16_t coap_socket_flags_t; - -typedef struct coap_socket_t { +struct coap_socket_t { #if defined(WITH_LWIP) struct udp_pcb *pcb; #elif defined(WITH_CONTIKI) @@ -45,8 +28,14 @@ typedef struct coap_socket_t { #else coap_fd_t fd; #endif /* WITH_LWIP */ +#if defined(RIOT_VERSION) + gnrc_pktsnip_t *pkt; /* pointer to received packet for processing */ +#endif /* RIOT_VERSION */ coap_socket_flags_t flags; -} coap_socket_t; + coap_session_t *session; /* Used by the epoll logic for an active session. */ + coap_endpoint_t *endpoint; /* Used by the epoll logic for a listening + endpoint. */ +}; /** * coap_socket_flags_t values @@ -65,8 +54,10 @@ typedef struct coap_socket_t { #define COAP_SOCKET_CAN_CONNECT 0x0800 /**< non blocking client socket can now connect without blocking */ #define COAP_SOCKET_MULTICAST 0x1000 /**< socket is used for multicast communication */ -struct coap_endpoint_t *coap_malloc_endpoint( void ); -void coap_mfree_endpoint( struct coap_endpoint_t *ep ); +coap_endpoint_t *coap_malloc_endpoint( void ); +void coap_mfree_endpoint( coap_endpoint_t *ep ); + +const char *coap_socket_format_errno(int error); int coap_socket_connect_udp(coap_socket_t *sock, @@ -81,34 +72,10 @@ coap_socket_bind_udp(coap_socket_t *sock, const coap_address_t *listen_addr, coap_address_t *bound_addr ); -int -coap_socket_connect_tcp1(coap_socket_t *sock, - const coap_address_t *local_if, - const coap_address_t *server, - int default_port, - coap_address_t *local_addr, - coap_address_t *remote_addr); - -int -coap_socket_connect_tcp2(coap_socket_t *sock, - coap_address_t *local_addr, - coap_address_t *remote_addr); - -int -coap_socket_bind_tcp(coap_socket_t *sock, - const coap_address_t *listen_addr, - coap_address_t *bound_addr); - -int -coap_socket_accept_tcp(coap_socket_t *server, - coap_socket_t *new_client, - coap_address_t *local_addr, - coap_address_t *remote_addr); - void coap_socket_close(coap_socket_t *sock); ssize_t -coap_socket_send( coap_socket_t *sock, struct coap_session_t *session, +coap_socket_send( coap_socket_t *sock, coap_session_t *session, const uint8_t *data, size_t data_len ); ssize_t @@ -117,14 +84,15 @@ coap_socket_write(coap_socket_t *sock, const uint8_t *data, size_t data_len); ssize_t coap_socket_read(coap_socket_t *sock, uint8_t *data, size_t data_len); +void +coap_epoll_ctl_mod(coap_socket_t *sock, uint32_t events, const char *func); + #ifdef WITH_LWIP ssize_t -coap_socket_send_pdu( coap_socket_t *sock, struct coap_session_t *session, - struct coap_pdu_t *pdu ); +coap_socket_send_pdu( coap_socket_t *sock, coap_session_t *session, + coap_pdu_t *pdu ); #endif -const char *coap_socket_strerror( void ); - /** * Function interface for data transmission. This function returns the number of * bytes that have been transmitted, or a value less than zero on error. @@ -137,7 +105,7 @@ const char *coap_socket_strerror( void ); * @return The number of bytes written on success, or a value * less than zero on error. */ -ssize_t coap_network_send( coap_socket_t *sock, const struct coap_session_t *session, const uint8_t *data, size_t datalen ); +ssize_t coap_network_send( coap_socket_t *sock, const coap_session_t *session, const uint8_t *data, size_t datalen ); /** * Function interface for reading data. This function returns the number of @@ -150,7 +118,7 @@ ssize_t coap_network_send( coap_socket_t *sock, const struct coap_session_t *ses * @return The number of bytes received on success, or a value less than * zero on error. */ -ssize_t coap_network_read( coap_socket_t *sock, struct coap_packet_t *packet ); +ssize_t coap_network_read( coap_socket_t *sock, coap_packet_t *packet ); #ifndef coap_mcast_interface # define coap_mcast_interface(Local) 0 @@ -160,7 +128,7 @@ ssize_t coap_network_read( coap_socket_t *sock, struct coap_packet_t *packet ); * Given a packet, set msg and msg_len to an address and length of the packet's * data in memory. * */ -void coap_packet_get_memmapped(struct coap_packet_t *packet, +void coap_packet_get_memmapped(coap_packet_t *packet, unsigned char **address, size_t *length); @@ -169,7 +137,7 @@ void coap_packet_get_memmapped(struct coap_packet_t *packet, * Get the pbuf of a packet. The caller takes over responsibility for freeing * the pbuf. */ -struct pbuf *coap_packet_extract_pbuf(struct coap_packet_t *packet); +struct pbuf *coap_packet_extract_pbuf(coap_packet_t *packet); #endif #if defined(WITH_LWIP) @@ -183,28 +151,18 @@ struct pbuf *coap_packet_extract_pbuf(struct coap_packet_t *packet); */ struct coap_packet_t { struct pbuf *pbuf; - const struct coap_endpoint_t *local_interface; - coap_address_t src; /**< the packet's source address */ - coap_address_t dst; /**< the packet's destination address */ + const coap_endpoint_t *local_interface; + coap_addr_tuple_t addr_info; /**< local and remote addresses */ int ifindex; /**< the interface index */ // uint16_t srcport; }; #else struct coap_packet_t { - coap_address_t src; /**< the packet's source address */ - coap_address_t dst; /**< the packet's destination address */ + coap_addr_tuple_t addr_info; /**< local and remote addresses */ int ifindex; /**< the interface index */ size_t length; /**< length of payload */ unsigned char payload[COAP_RXBUFFER_SIZE]; /**< payload */ }; #endif -typedef struct coap_packet_t coap_packet_t; - -typedef enum { - COAP_NACK_TOO_MANY_RETRIES, - COAP_NACK_NOT_DELIVERABLE, - COAP_NACK_RST, - COAP_NACK_TLS_FAILED -} coap_nack_reason_t; -#endif /* COAP_IO_H_ */ +#endif /* COAP_IO_INTERNAL_H_ */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/coap_mutex.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_mutex.h similarity index 63% rename from tools/sdk/esp32c3/include/coap/libcoap/include/coap2/coap_mutex.h rename to tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_mutex.h index 99d7d335e47..44084fecb1c 100644 --- a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/coap_mutex.h +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_mutex.h @@ -2,6 +2,9 @@ * coap_mutex.h -- mutex utilities * * Copyright (C) 2019 Jon Shallow + * 2019 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause * * This file is part of the CoAP library libcoap. Please see README for terms * of use. @@ -15,8 +18,24 @@ #ifndef COAP_MUTEX_H_ #define COAP_MUTEX_H_ -#if defined(RIOT_VERSION) +/* + * Mutexes are currently only used if there is a constrained stack, + * and large static variables (instead of the large variable being on + * the stack) need to be protected. + */ +#if COAP_CONSTRAINED_STACK + +#if defined(HAVE_PTHREAD_H) && defined(HAVE_PTHREAD_MUTEX_LOCK) +#include + +typedef pthread_mutex_t coap_mutex_t; +#define COAP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER +#define coap_mutex_lock(a) pthread_mutex_lock(a) +#define coap_mutex_trylock(a) pthread_mutex_trylock(a) +#define coap_mutex_unlock(a) pthread_mutex_unlock(a) +#elif defined(RIOT_VERSION) +/* use RIOT's mutex API */ #include typedef mutex_t coap_mutex_t; @@ -25,26 +44,16 @@ typedef mutex_t coap_mutex_t; #define coap_mutex_trylock(a) mutex_trylock(a) #define coap_mutex_unlock(a) mutex_unlock(a) -#elif defined(WITH_CONTIKI) - -/* CONTIKI does not support mutex */ - +#else +/* define stub mutex functions */ typedef int coap_mutex_t; #define COAP_MUTEX_INITIALIZER 0 #define coap_mutex_lock(a) *(a) = 1 #define coap_mutex_trylock(a) *(a) = 1 #define coap_mutex_unlock(a) *(a) = 0 -#else /* ! RIOT_VERSION && ! WITH_CONTIKI */ - -#include - -typedef pthread_mutex_t coap_mutex_t; -#define COAP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER -#define coap_mutex_lock(a) pthread_mutex_lock(a) -#define coap_mutex_trylock(a) pthread_mutex_trylock(a) -#define coap_mutex_unlock(a) pthread_mutex_unlock(a) +#endif /* !RIOT_VERSION && !HAVE_PTHREAD_H && !HAVE_PTHREAD_MUTEX_LOCK */ -#endif /* ! RIOT_VERSION && ! WITH_CONTIKI */ +#endif /* COAP_CONSTRAINED_STACK */ #endif /* COAP_MUTEX_H_ */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_net_internal.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_net_internal.h new file mode 100644 index 00000000000..bf243f3d022 --- /dev/null +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_net_internal.h @@ -0,0 +1,366 @@ +/* + * coap_context_internal.h -- Structures, Enums & Functions that are not + * exposed to application programming + * + * Copyright (C) 2010-2021 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_net_internal.h + * @brief COAP net internal information + */ + +#ifndef COAP_NET_INTERNAL_H_ +#define COAP_NET_INTERNAL_H_ + +/** + * @defgroup context_internal Context Handling (Internal) + * CoAP Context Structures, Enums and Functions that are not exposed to + * applications + * @{ + */ + +/** + * Queue entry + */ +struct coap_queue_t { + struct coap_queue_t *next; + coap_tick_t t; /**< when to send PDU for the next time */ + unsigned char retransmit_cnt; /**< retransmission counter, will be removed + * when zero */ + unsigned int timeout; /**< the randomized timeout value */ + coap_session_t *session; /**< the CoAP session */ + coap_mid_t id; /**< CoAP message id */ + coap_pdu_t *pdu; /**< the CoAP PDU to send */ +}; + +/** + * The CoAP stack's global state is stored in a coap_context_t object. + */ +struct coap_context_t { + coap_opt_filter_t known_options; + coap_resource_t *resources; /**< hash table or list of known + resources */ + coap_resource_t *unknown_resource; /**< can be used for handling + unknown resources */ + coap_resource_t *proxy_uri_resource; /**< can be used for handling + proxy URI resources */ + coap_resource_release_userdata_handler_t release_userdata; + /**< function to release user_data + when resource is deleted */ + +#ifndef WITHOUT_ASYNC + /** + * list of asynchronous message ids */ + coap_async_t *async_state; +#endif /* WITHOUT_ASYNC */ + + /** + * The time stamp in the first element of the sendqeue is relative + * to sendqueue_basetime. */ + coap_tick_t sendqueue_basetime; + coap_queue_t *sendqueue; + coap_endpoint_t *endpoint; /**< the endpoints used for listening */ + coap_session_t *sessions; /**< client sessions */ + +#ifdef WITH_CONTIKI + struct uip_udp_conn *conn; /**< uIP connection object */ + struct etimer retransmit_timer; /**< fires when the next packet must be + sent */ + struct etimer notify_timer; /**< used to check resources periodically */ +#endif /* WITH_CONTIKI */ + +#ifdef WITH_LWIP + uint8_t timer_configured; /**< Set to 1 when a retransmission is + * scheduled using lwIP timers for this + * context, otherwise 0. */ +#endif /* WITH_LWIP */ + + coap_response_handler_t response_handler; + coap_nack_handler_t nack_handler; + coap_ping_handler_t ping_handler; + coap_pong_handler_t pong_handler; + + /** + * Callback function that is used to signal events to the + * application. This field is set by coap_set_event_handler(). + */ + coap_event_handler_t handle_event; + + ssize_t (*network_send)(coap_socket_t *sock, const coap_session_t *session, + const uint8_t *data, size_t datalen); + + ssize_t (*network_read)(coap_socket_t *sock, coap_packet_t *packet); + + size_t(*get_client_psk)(const coap_session_t *session, const uint8_t *hint, + size_t hint_len, uint8_t *identity, + size_t *identity_len, size_t max_identity_len, + uint8_t *psk, size_t max_psk_len); + size_t(*get_server_psk)(const coap_session_t *session, + const uint8_t *identity, size_t identity_len, + uint8_t *psk, size_t max_psk_len); + size_t(*get_server_hint)(const coap_session_t *session, uint8_t *hint, + size_t max_hint_len); + + void *dtls_context; + + coap_dtls_spsk_t spsk_setup_data; /**< Contains the initial PSK server setup + data */ + + unsigned int session_timeout; /**< Number of seconds of inactivity after + which an unused session will be closed. + 0 means use default. */ + unsigned int max_idle_sessions; /**< Maximum number of simultaneous unused + sessions per endpoint. 0 means no + maximum. */ + unsigned int max_handshake_sessions; /**< Maximum number of simultaneous + negotating sessions per endpoint. 0 + means use default. */ + unsigned int ping_timeout; /**< Minimum inactivity time before + sending a ping message. 0 means + disabled. */ + unsigned int csm_timeout; /**< Timeout for waiting for a CSM from + the remote side. 0 means disabled. */ + uint8_t observe_pending; /**< Observe response pending */ + uint8_t block_mode; /**< Zero or more COAP_BLOCK_ or'd options */ + uint64_t etag; /**< Next ETag to use */ + + coap_cache_entry_t *cache; /**< CoAP cache-entry cache */ + uint16_t *cache_ignore_options; /**< CoAP options to ignore when creating a + cache-key */ + size_t cache_ignore_count; /**< The number of CoAP options to ignore + when creating a cache-key */ + void *app; /**< application-specific data */ +#ifdef COAP_EPOLL_SUPPORT + int epfd; /**< External FD for epoll */ + int eptimerfd; /**< Internal FD for timeout */ + coap_tick_t next_timeout; /**< When the next timeout is to occur */ +#endif /* COAP_EPOLL_SUPPORT */ +}; + +/** + * Adds @p node to given @p queue, ordered by variable t in @p node. + * + * @param queue Queue to add to. + * @param node Node entry to add to Queue. + * + * @return @c 1 added to queue, @c 0 failure. + */ +int coap_insert_node(coap_queue_t **queue, coap_queue_t *node); + +/** + * Destroys specified @p node. + * + * @param node Node entry to remove. + * + * @return @c 1 node deleted from queue, @c 0 failure. + */ +int coap_delete_node(coap_queue_t *node); + +/** + * Removes all items from given @p queue and frees the allocated storage. + * + * Internal function. + * + * @param queue The queue to delete. + */ +void coap_delete_all(coap_queue_t *queue); + +/** + * Creates a new node suitable for adding to the CoAP sendqueue. + * + * @return New node entry, or @c NULL if failure. + */ +coap_queue_t *coap_new_node(void); + +/** + * Set sendqueue_basetime in the given context object @p ctx to @p now. This + * function returns the number of elements in the queue head that have timed + * out. + */ +unsigned int coap_adjust_basetime(coap_context_t *ctx, coap_tick_t now); + +/** + * Returns the next pdu to send without removing from sendqeue. + */ +coap_queue_t *coap_peek_next( coap_context_t *context ); + +/** + * Returns the next pdu to send and removes it from the sendqeue. + */ +coap_queue_t *coap_pop_next( coap_context_t *context ); + +/** + * Handles retransmissions of confirmable messages + * + * @param context The CoAP context. + * @param node The node to retransmit. + * + * @return The message id of the sent message or @c + * COAP_INVALID_MID on error. + */ +coap_mid_t coap_retransmit(coap_context_t *context, coap_queue_t *node); + +/** + * Parses and interprets a CoAP datagram with context @p ctx. This function + * returns @c 0 if the datagram was handled, or a value less than zero on + * error. + * + * @param ctx The current CoAP context. + * @param session The current CoAP session. + * @param data The received packet'd data. + * @param data_len The received packet'd data length. + * + * @return @c 0 if message was handled successfully, or less than zero on + * error. + */ +int coap_handle_dgram(coap_context_t *ctx, coap_session_t *session, uint8_t *data, size_t data_len); + +/** + * This function removes the element with given @p id from the list given list. + * If @p id was found, @p node is updated to point to the removed element. Note + * that the storage allocated by @p node is @b not released. The caller must do + * this manually using coap_delete_node(). This function returns @c 1 if the + * element with id @p id was found, @c 0 otherwise. For a return value of @c 0, + * the contents of @p node is undefined. + * + * @param queue The queue to search for @p id. + * @param session The session to look for. + * @param id The message id to look for. + * @param node If found, @p node is updated to point to the removed node. You + * must release the storage pointed to by @p node manually. + * + * @return @c 1 if @p id was found, @c 0 otherwise. + */ +int coap_remove_from_queue(coap_queue_t **queue, + coap_session_t *session, + coap_mid_t id, + coap_queue_t **node); + +coap_mid_t +coap_wait_ack( coap_context_t *context, coap_session_t *session, + coap_queue_t *node); + +/** + * Cancels all outstanding messages for session @p session that have the specified + * token. + * + * @param context The context in use. + * @param session Session of the messages to remove. + * @param token Message token. + * @param token_length Actual length of @p token. + */ +void coap_cancel_all_messages(coap_context_t *context, + coap_session_t *session, + const uint8_t *token, + size_t token_length); + +/** +* Cancels all outstanding messages for session @p session. +* +* @param context The context in use. +* @param session Session of the messages to remove. +* @param reason The reasion for the session cancellation +*/ +void +coap_cancel_session_messages(coap_context_t *context, + coap_session_t *session, + coap_nack_reason_t reason); + +/** + * Dispatches the PDUs from the receive queue in given context. + */ +void coap_dispatch(coap_context_t *context, coap_session_t *session, + coap_pdu_t *pdu); + +/** + * Verifies that @p pdu contains no unknown critical options. Options must be + * registered at @p ctx, using the function coap_register_option(). A basic set + * of options is registered automatically by coap_new_context(). This function + * returns @c 1 if @p pdu is ok, @c 0 otherwise. The given filter object @p + * unknown will be updated with the unknown options. As only @c COAP_MAX_OPT + * options can be signalled this way, remaining options must be examined + * manually. + * + * @code + coap_opt_filter_t f = COAP_OPT_NONE; + coap_opt_iterator_t opt_iter; + + if (coap_option_check_critical(ctx, pdu, f) == 0) { + coap_option_iterator_init(pdu, &opt_iter, f); + + while (coap_option_next(&opt_iter)) { + if (opt_iter.type & 0x01) { + ... handle unknown critical option in opt_iter ... + } + } + } + @endcode + * + * @param ctx The context where all known options are registered. + * @param pdu The PDU to check. + * @param unknown The output filter that will be updated to indicate the + * unknown critical options found in @p pdu. + * + * @return @c 1 if everything was ok, @c 0 otherwise. + */ +int coap_option_check_critical(coap_context_t *ctx, + coap_pdu_t *pdu, + coap_opt_filter_t *unknown); + +/** + * Creates a new response for given @p request with the contents of @c + * .well-known/core. The result is NULL on error or a newly allocated PDU that + * must be either sent with coap_sent() or released by coap_delete_pdu(). + * + * @param context The current coap context to use. + * @param session The CoAP session. + * @param request The request for @c .well-known/core . + * + * @return A new 2.05 response for @c .well-known/core or NULL on error. + */ +coap_pdu_t *coap_wellknown_response(coap_context_t *context, + coap_session_t *session, + coap_pdu_t *request); + +/** + * Calculates the initial timeout based on the session CoAP transmission + * parameters 'ack_timeout', 'ack_random_factor', and COAP_TICKS_PER_SECOND. + * The calculation requires 'ack_timeout' and 'ack_random_factor' to be in + * Qx.FRAC_BITS fixed point notation, whereas the passed parameter @p r + * is interpreted as the fractional part of a Q0.MAX_BITS random value. + * + * @param session session timeout is associated with + * @param r random value as fractional part of a Q0.MAX_BITS fixed point + * value + * @return COAP_TICKS_PER_SECOND * 'ack_timeout' * + * (1 + ('ack_random_factor' - 1) * r) + */ +unsigned int coap_calc_timeout(coap_session_t *session, unsigned char r); + +/** + * Sends a CoAP message to given peer. The memory that is + * allocated for the pdu will be released by coap_send_internal(). + * The caller must not use the pdu after calling coap_send_internal(). + * + * If the response body is split into multiple payloads using blocks, libcoap + * will handle asking for the subsequent blocks and any necessary recovery + * needed. + * + * @param session The CoAP session. + * @param pdu The CoAP PDU to send. + * + * @return The message id of the sent message or @c + * COAP_INVALID_MID on error. + */ +coap_mid_t coap_send_internal(coap_session_t *session, coap_pdu_t *pdu); + +/** @} */ + +#endif /* COAP_NET_INTERNAL_H_ */ + diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_pdu_internal.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_pdu_internal.h new file mode 100644 index 00000000000..0d8446c0d4c --- /dev/null +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_pdu_internal.h @@ -0,0 +1,300 @@ +/* + * coap_pdu_internal.h -- CoAP PDU structure + * + * Copyright (C) 2010-2021 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_pdu_internal.h + * @brief CoAP PDU internal information + */ + +#ifndef COAP_COAP_PDU_INTERNAL_H_ +#define COAP_COAP_PDU_INTERNAL_H_ + +#ifdef WITH_LWIP +#include +#endif + +#include + +/** + * @defgroup pdu_internal PDU (Internal) + * CoAP PDU Structures, Enums and Functions that are not exposed to + * applications + * @{ + */ + +#define COAP_DEFAULT_VERSION 1 /* version of CoAP supported */ + +/* TCP Message format constants, do not modify */ +#define COAP_MESSAGE_SIZE_OFFSET_TCP8 13 +#define COAP_MESSAGE_SIZE_OFFSET_TCP16 269 /* 13 + 256 */ +#define COAP_MESSAGE_SIZE_OFFSET_TCP32 65805 /* 269 + 65536 */ + +/* Derived message size limits */ +#define COAP_MAX_MESSAGE_SIZE_TCP0 (COAP_MESSAGE_SIZE_OFFSET_TCP8-1) /* 12 */ +#define COAP_MAX_MESSAGE_SIZE_TCP8 (COAP_MESSAGE_SIZE_OFFSET_TCP16-1) /* 268 */ +#define COAP_MAX_MESSAGE_SIZE_TCP16 (COAP_MESSAGE_SIZE_OFFSET_TCP32-1) /* 65804 */ +#define COAP_MAX_MESSAGE_SIZE_TCP32 (COAP_MESSAGE_SIZE_OFFSET_TCP32+0xFFFFFFFF) + +#ifndef COAP_DEBUG_BUF_SIZE +#if defined(WITH_CONTIKI) || defined(WITH_LWIP) +#define COAP_DEBUG_BUF_SIZE 128 +#else /* defined(WITH_CONTIKI) || defined(WITH_LWIP) */ +/* 1024 derived from RFC7252 4.6. Message Size max payload */ +#define COAP_DEBUG_BUF_SIZE (8 + 1024 * 2) +#endif /* defined(WITH_CONTIKI) || defined(WITH_LWIP) */ +#endif /* COAP_DEBUG_BUF_SIZE */ + +#ifndef COAP_DEFAULT_MAX_PDU_RX_SIZE +#if defined(WITH_CONTIKI) || defined(WITH_LWIP) +#define COAP_DEFAULT_MAX_PDU_RX_SIZE (COAP_MAX_MESSAGE_SIZE_TCP16+4UL) +#else +/* 8 MiB max-message-size plus some space for options */ +#define COAP_DEFAULT_MAX_PDU_RX_SIZE (8UL*1024*1024+256) +#endif +#endif /* COAP_DEFAULT_MAX_PDU_RX_SIZE */ + +/** + * Indicates that a response is suppressed. This will occur for error + * responses if the request was received via IP multicast. + */ +#define COAP_DROPPED_RESPONSE -2 + +#define COAP_PDU_DELAYED -3 + +#define COAP_PAYLOAD_START 0xFF /* payload marker */ + +#define COAP_PDU_IS_EMPTY(pdu) ((pdu)->code == 0) +#define COAP_PDU_IS_REQUEST(pdu) (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32) +#define COAP_PDU_IS_RESPONSE(pdu) ((pdu)->code >= 64 && (pdu)->code < 224) +#define COAP_PDU_IS_SIGNALING(pdu) ((pdu)->code >= 224) + +#define COAP_PDU_MAX_UDP_HEADER_SIZE 4 +#define COAP_PDU_MAX_TCP_HEADER_SIZE 6 + +/** + * structure for CoAP PDUs + * token, if any, follows the fixed size header, then options until + * payload marker (0xff), then the payload if stored inline. + * Memory layout is: + * <---header--->|<---token---><---options--->0xff<---payload---> + * header is addressed with a negative offset to token, its maximum size is + * max_hdr_size. + * options starts at token + token_length + * payload starts at data, its length is used_size - (data - token) + */ + +struct coap_pdu_t { + coap_pdu_type_t type; /**< message type */ + coap_pdu_code_t code; /**< request method (value 1--31) or response code + (value 64-255) */ + coap_mid_t mid; /**< message id, if any, in regular host byte + order */ + uint8_t max_hdr_size; /**< space reserved for protocol-specific header */ + uint8_t hdr_size; /**< actual size used for protocol-specific + header */ + uint8_t token_length; /**< length of Token */ + uint16_t max_opt; /**< highest option number in PDU */ + size_t alloc_size; /**< allocated storage for token, options and + payload */ + size_t used_size; /**< used bytes of storage for token, options and + payload */ + size_t max_size; /**< maximum size for token, options and payload, + or zero for variable size pdu */ + uint8_t *token; /**< first byte of token, if any, or options */ + uint8_t *data; /**< first byte of payload, if any */ +#ifdef WITH_LWIP + struct pbuf *pbuf; /**< lwIP PBUF. The package data will always reside + * inside the pbuf's payload, but this pointer + * has to be kept because no exact offset can be + * given. This field must not be accessed from + * outside, because the pbuf's reference count + * is checked to be 1 when the pbuf is assigned + * to the pdu, and the pbuf stays exclusive to + * this pdu. */ +#endif + const uint8_t *body_data; /**< Holds ptr to re-assembled data or NULL */ + size_t body_length; /**< Holds body data length */ + size_t body_offset; /**< Holds body data offset */ + size_t body_total; /**< Holds body data total size */ + coap_lg_xmit_t *lg_xmit; /**< Holds ptr to lg_xmit if sending a set of + blocks */ +}; + +/** + * Dynamically grows the size of @p pdu to @p new_size. The new size + * must not exceed the PDU's configure maximum size. On success, this + * function returns 1, otherwise 0. + * + * @param pdu The PDU to resize. + * @param new_size The new size in bytes. + * @return 1 if the operation succeeded, 0 otherwise. + */ +int coap_pdu_resize(coap_pdu_t *pdu, size_t new_size); + +/** + * Dynamically grows the size of @p pdu to @p new_size if needed. The new size + * must not exceed the PDU's configured maximum size. On success, this + * function returns 1, otherwise 0. + * + * @param pdu The PDU to resize. + * @param new_size The new size in bytes. + * @return 1 if the operation succeeded, 0 otherwise. + */ +int coap_pdu_check_resize(coap_pdu_t *pdu, size_t new_size); + +/** +* Interprets @p data to determine the number of bytes in the header. +* This function returns @c 0 on error or a number greater than zero on success. +* +* @param proto Session's protocol +* @param data The first byte of raw data to parse as CoAP PDU. +* +* @return A value greater than zero on success or @c 0 on error. +*/ +size_t coap_pdu_parse_header_size(coap_proto_t proto, + const uint8_t *data); + +/** + * Parses @p data to extract the message size. + * @p length must be at least coap_pdu_parse_header_size(proto, data). + * This function returns @c 0 on error or a number greater than zero on success. + * + * @param proto Session's protocol + * @param data The raw data to parse as CoAP PDU. + * @param length The actual size of @p data. + * + * @return A value greater than zero on success or @c 0 on error. + */ +size_t coap_pdu_parse_size(coap_proto_t proto, + const uint8_t *data, + size_t length); + +/** + * Decode the protocol specific header for the specified PDU. + * @param pdu A newly received PDU. + * @param proto The target wire protocol. + * @return 1 for success or 0 on error. + */ + +int coap_pdu_parse_header(coap_pdu_t *pdu, coap_proto_t proto); + +/** + * Verify consistency in the given CoAP PDU structure and locate the data. + * This function returns @c 0 on error or a number greater than zero on + * success. + * This function only parses the token and options, up to the payload start + * marker. + * + * @param pdu The PDU structure to check. + * + * @return 1 on success or @c 0 on error. + */ +int coap_pdu_parse_opt(coap_pdu_t *pdu); + +/** +* Parses @p data into the CoAP PDU structure given in @p result. +* The target pdu must be large enough to +* This function returns @c 0 on error or a number greater than zero on success. +* +* @param proto Session's protocol +* @param data The raw data to parse as CoAP PDU. +* @param length The actual size of @p data. +* @param pdu The PDU structure to fill. Note that the structure must +* provide space to hold at least the token and options +* part of the message. +* +* @return 1 on success or @c 0 on error. +*/ +int coap_pdu_parse(coap_proto_t proto, + const uint8_t *data, + size_t length, + coap_pdu_t *pdu); + +/** + * Clears any contents from @p pdu and resets @c used_size, + * and @c data pointers. @c max_size is set to @p size, any + * other field is set to @c 0. Note that @p pdu must be a valid + * pointer to a coap_pdu_t object created e.g. by coap_pdu_init(). + * + * @param pdu The PDU to clear. + * @param size The maximum size of the PDU. + */ +void coap_pdu_clear(coap_pdu_t *pdu, size_t size); + +/** + * Removes (first) option of given number from the @p pdu. + * + * @param pdu The PDU to remove the option from. + * @param number The number of the CoAP option to remove (first only removed). + * + * @return @c 1 if success else @c 0 if error. + */ +int coap_remove_option(coap_pdu_t *pdu, coap_option_num_t number); + +/** + * Inserts option of given number in the @p pdu with the appropriate data. + * The option will be inserted in the appropriate place in the options in + * the pdu. + * + * @param pdu The PDU where the option is to be inserted. + * @param number The number of the new option. + * @param len The length of the new option. + * @param data The data of the new option. + * + * @return The overall length of the option or @c 0 on failure. + */ +size_t coap_insert_option(coap_pdu_t *pdu, coap_option_num_t number, + size_t len, const uint8_t *data); + +/** + * Updates existing first option of given number in the @p pdu with the new + * data. + * + * @param pdu The PDU where the option is to be updated. + * @param number The number of the option to update (first only updated). + * @param len The length of the updated option. + * @param data The data of the updated option. + * + * @return The overall length of the updated option or @c 0 on failure. + */ +size_t coap_update_option(coap_pdu_t *pdu, + coap_option_num_t number, + size_t len, + const uint8_t *data); + +/** + * Compose the protocol specific header for the specified PDU. + * + * @param pdu A newly composed PDU. + * @param proto The target wire protocol. + * + * @return Number of header bytes prepended before pdu->token or 0 on error. + */ + +size_t coap_pdu_encode_header(coap_pdu_t *pdu, coap_proto_t proto); + + /** + * Updates token in @p pdu with length @p len and @p data. + * This function returns @c 0 on error or a value greater than zero on success. + * + * @param pdu The PDU where the token is to be updated. + * @param len The length of the new token. + * @param data The token to add. + * + * @return A value greater than zero on success, or @c 0 on error. + */ +int coap_update_token(coap_pdu_t *pdu, + size_t len, + const uint8_t *data); + +/** @} */ + +#endif /* COAP_COAP_PDU_INTERNAL_H_ */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_prng.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_prng.h new file mode 100644 index 00000000000..6d297afaec3 --- /dev/null +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_prng.h @@ -0,0 +1,113 @@ +/* + * coap_prng.h -- Pseudo Random Numbers + * + * Copyright (C) 2010-2020 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_prng.h + * @brief Pseudo Random Numbers + */ + +#ifndef COAP_PRNG_H_ +#define COAP_PRNG_H_ + +/** + * @defgroup coap_prng Pseudo Random Numbers + * API functions for gerating pseudo random numbers + * @{ + */ + +#if defined(WITH_CONTIKI) +#include + +/** + * Fills \p buf with \p len random bytes. This is the default implementation for + * coap_prng(). You might want to change contiki_prng_impl() to use a better + * PRNG on your specific platform. + */ +COAP_STATIC_INLINE int +contiki_prng_impl(unsigned char *buf, size_t len) { + uint16_t v = random_rand(); + while (len > sizeof(v)) { + memcpy(buf, &v, sizeof(v)); + len -= sizeof(v); + buf += sizeof(v); + v = random_rand(); + } + + memcpy(buf, &v, len); + return 1; +} + +#define coap_prng(Buf,Length) contiki_prng_impl((Buf), (Length)) +#define coap_prng_init(Value) random_init((uint16_t)(Value)) + +#elif defined(WITH_LWIP) && defined(LWIP_RAND) + +COAP_STATIC_INLINE int +lwip_prng_impl(unsigned char *buf, size_t len) { + u32_t v = LWIP_RAND(); + while (len > sizeof(v)) { + memcpy(buf, &v, sizeof(v)); + len -= sizeof(v); + buf += sizeof(v); + v = LWIP_RAND(); + } + + memcpy(buf, &v, len); + return 1; +} + +#define coap_prng(Buf,Length) lwip_prng_impl((Buf), (Length)) +#define coap_prng_init(Value) (void)Value + +#else + +/** + * Data type for random number generator function. The function must + * fill @p len bytes of random data into the buffer starting at @p + * out. On success, the function should return 1, zero otherwise. + */ +typedef int (*coap_rand_func_t)(void *out, size_t len); + +/** + * Replaces the current random number generation function with the + * default function @p rng. + * + * @param rng The random number generation function to use. + */ +void coap_set_prng(coap_rand_func_t rng); + +/** + * Seeds the default random number generation function with the given + * @p seed. The default random number generation function will use + * getrandom() if available, ignoring the seed. + * + * @param seed The seed for the pseudo random number generator. + */ +void coap_prng_init(unsigned int seed); + +/** + * Fills @p buf with @p len random bytes using the default pseudo + * random number generator. The default PRNG can be changed with + * coap_set_prng(). This function returns 1 when @p len random bytes + * have been written to @p buf, zero otherwise. + * + * @param buf The buffer to fill with random bytes. + * @param len The number of random bytes to write into @p buf. + * + * @return 1 on success, 0 otherwise. + */ +int coap_prng(void *buf, size_t len); + +#endif /* POSIX */ + +/** @} */ + +#endif /* COAP_PRNG_H_ */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_resource_internal.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_resource_internal.h new file mode 100644 index 00000000000..cbcc36a664c --- /dev/null +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_resource_internal.h @@ -0,0 +1,141 @@ +/* + * coap_resource_internal.h -- generic resource handling + * + * Copyright (C) 2010,2011,2014-2021 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_resource_internal.h + * @brief Generic resource internal handling + */ + +#ifndef COAP_RESOURCE_INTERNAL_H_ +#define COAP_RESOURCE_INTERNAL_H_ + +#include "uthash.h" + +/** + * @defgroup coap_resource_internal Resources (Internal) + * Structures, Enums and Functions that are not exposed to applications + * @{ + */ + +/** +* Abstraction of attribute associated with a resource. +*/ +struct coap_attr_t { + struct coap_attr_t *next; /**< Pointer to next in chain or NULL */ + coap_str_const_t *name; /**< Name of the attribute */ + coap_str_const_t *value; /**< Value of the attribute (can be NULL) */ + int flags; +}; + +/** +* Abstraction of resource that can be attached to coap_context_t. +* The key is uri_path. +*/ +struct coap_resource_t { + unsigned int dirty:1; /**< set to 1 if resource has changed */ + unsigned int partiallydirty:1; /**< set to 1 if some subscribers have not yet + * been notified of the last change */ + unsigned int observable:1; /**< can be observed */ + unsigned int cacheable:1; /**< can be cached */ + unsigned int is_unknown:1; /**< resource created for unknown handler */ + unsigned int is_proxy_uri:1; /**< resource created for proxy URI handler */ + + /** + * Used to store handlers for the seven coap methods @c GET, @c POST, @c PUT, + * @c DELETE, @c FETCH, @c PATCH and @c IPATCH. + * coap_dispatch() will pass incoming requests to handle_request() and then + * to the handler that corresponds to its request method or generate a 4.05 + * response if no handler is available. + */ + coap_method_handler_t handler[7]; + + UT_hash_handle hh; + + coap_attr_t *link_attr; /**< attributes to be included with the link format */ + coap_subscription_t *subscribers; /**< list of observers for this resource */ + + /** + * Request URI Path for this resource. This field will point into static + * or allocated memory which must remain there for the duration of the + * resource. + */ + coap_str_const_t *uri_path; /**< the key used for hash lookup for this + resource */ + int flags; /**< zero or more COAP_RESOURCE_FLAGS_* or'd together */ + + /** + * The next value for the Observe option. This field must be increased each + * time the resource changes. Only the lower 24 bits are sent. + */ + unsigned int observe; + + /** + * Pointer back to the context that 'owns' this resource. + */ + coap_context_t *context; + + /** + * Count of valid names this host is known by (proxy support) + */ + size_t proxy_name_count; + + /** + * Array valid names this host is known by (proxy support) + */ + coap_str_const_t ** proxy_name_list; + + /** + * This pointer is under user control. It can be used to store context for + * the coap handler. + */ + void *user_data; + +}; + +/** + * Deletes all resources from given @p context and frees their storage. + * + * @param context The CoAP context with the resources to be deleted. + */ +void coap_delete_all_resources(coap_context_t *context); + +#define RESOURCES_ADD(r, obj) \ + HASH_ADD(hh, (r), uri_path->s[0], (obj)->uri_path->length, (obj)) + +#define RESOURCES_DELETE(r, obj) \ + HASH_DELETE(hh, (r), (obj)) + +#define RESOURCES_ITER(r,tmp) \ + coap_resource_t *tmp, *rtmp; \ + HASH_ITER(hh, (r), tmp, rtmp) + +#define RESOURCES_FIND(r, k, res) { \ + HASH_FIND(hh, (r), (k)->s, (k)->length, (res)); \ + } + +/** + * Deletes an attribute. + * Note: This is for internal use only, as it is not deleted from its chain. + * + * @param attr Pointer to a previously created attribute. + * + */ +void coap_delete_attr(coap_attr_t *attr); + +coap_print_status_t coap_print_wellknown(coap_context_t *, + unsigned char *, + size_t *, size_t, + coap_opt_t *); + + +/** @} */ + +#endif /* COAP_RESOURCE_INTERNAL_H_ */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_riot.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_riot.h new file mode 100644 index 00000000000..fc4bfa2e655 --- /dev/null +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_riot.h @@ -0,0 +1,34 @@ +/* coap_riot.h -- RIOT-specific definitions for libcoap + * + * Copyright (C) 2019 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see + * README for terms of use. + */ + +#ifndef COAP_RIOT_H_ +#define COAP_RIOT_H_ + +#ifndef LIBCOAP_MSG_QUEUE_SIZE +/** + * Size of the queue for passing messages between the network + * interface and the coap stack. */ +#define LIBCOAP_MSG_QUEUE_SIZE (32U) +#endif /* LIBCOAP_MSG_QUEUE_SIZE */ + +#ifndef LIBCOAP_MAX_SOCKETS +/** + * Maximum number of sockets that are simultaneously considered for + * reading or writing. */ +#define LIBCOAP_MAX_SOCKETS (16U) +#endif /* LIBCOAP_MAX_SOCKETS */ + +/** + * This function must be called in the RIOT CoAP thread for + * RIOT-specific initialization. + */ +void coap_riot_startup(void); + +#endif /* COAP_RIOT_H_ */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_session.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_session.h new file mode 100644 index 00000000000..6c49b78e97d --- /dev/null +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_session.h @@ -0,0 +1,591 @@ +/* coap_session.h -- Session management for libcoap +* +* Copyright (C) 2017 Jean-Claue Michelou +* + * SPDX-License-Identifier: BSD-2-Clause + * +* This file is part of the CoAP library libcoap. Please see +* README for terms of use. +*/ + +/** + * @file coap_session.h + * @brief Defines the application visible session information + */ + +#ifndef COAP_SESSION_H_ +#define COAP_SESSION_H_ + +/** + * @defgroup session Sessions + * API functions for CoAP Sessions + * @{ + */ + +/** +* Abstraction of a fixed point number that can be used where necessary instead +* of a float. 1,000 fractional bits equals one integer +*/ +typedef struct coap_fixed_point_t { + uint16_t integer_part; /**< Integer part of fixed point variable */ + uint16_t fractional_part; /**< Fractional part of fixed point variable + 1/1000 (3 points) precision */ +} coap_fixed_point_t; + +#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS) +#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS) + +/** + * coap_session_type_t values + */ +typedef enum coap_session_type_t { + COAP_SESSION_TYPE_NONE = 0, /**< Not defined */ + COAP_SESSION_TYPE_CLIENT, /**< client-side */ + COAP_SESSION_TYPE_SERVER, /**< server-side */ + COAP_SESSION_TYPE_HELLO, /**< server-side ephemeral session for + responding to a client hello */ +} coap_session_type_t; + +/** + * coap_session_state_t values + */ +typedef enum coap_session_state_t { + COAP_SESSION_STATE_NONE = 0, + COAP_SESSION_STATE_CONNECTING, + COAP_SESSION_STATE_HANDSHAKE, + COAP_SESSION_STATE_CSM, + COAP_SESSION_STATE_ESTABLISHED, +} coap_session_state_t; + +/** + * Increment reference counter on a session. + * + * @param session The CoAP session. + * @return same as session + */ +coap_session_t *coap_session_reference(coap_session_t *session); + +/** + * Decrement reference counter on a session. + * Note that the session may be deleted as a result and should not be used + * after this call. + * + * @param session The CoAP session. + */ +void coap_session_release(coap_session_t *session); + +/** + * Notify session that it has failed. This cleans up any outstanding / queued + * transmissions, observations etc.. + * + * @param session The CoAP session. + * @param reason The reason why the session was disconnected. + */ +void coap_session_disconnected(coap_session_t *session, + coap_nack_reason_t reason); + +/** + * Stores @p data with the given session. This function overwrites any value + * that has previously been stored with @p session. + * + * @param session The CoAP session. + * @param data The pointer to the data to store. + */ +void coap_session_set_app_data(coap_session_t *session, void *data); + +/** + * Returns any application-specific data that has been stored with @p + * session using the function coap_session_set_app_data(). This function will + * return @c NULL if no data has been stored. + * + * @param session The CoAP session. + * + * @return Pointer to the stored data or @c NULL. + */ +void *coap_session_get_app_data(const coap_session_t *session); + +/** + * Get the remote IP address from the session. + * + * @param session The CoAP session. + * + * @return The session's remote address or @c NULL on failure. + */ +const coap_address_t *coap_session_get_addr_remote( + const coap_session_t *session); + +/** + * Get the local IP address from the session. + * + * @param session The CoAP session. + * + * @return The session's local address or @c NULL on failure. + */ +const coap_address_t *coap_session_get_addr_local( + const coap_session_t *session); + +/** + * Get the session protocol type + * + * @param session The CoAP session. + * + * @return The session's protocol type + */ +coap_proto_t coap_session_get_proto(const coap_session_t *session); + +/** + * Get the session type + * + * @param session The CoAP session. + * + * @return The session's type + */ +coap_session_type_t coap_session_get_type(const coap_session_t *session); + +/** + * Get the session state + * + * @param session The CoAP session. + * + * @return The session's state + */ +coap_session_state_t coap_session_get_state(const coap_session_t *session); + +/** + * Get the session if index + * + * @param session The CoAP session. + * + * @return The session's if index, or @c -1 on error. + */ +int coap_session_get_ifindex(const coap_session_t *session); + +/** + * Get the session TLS security ptr (TLS type dependent) + * + * OpenSSL: SSL* + * GnuTLS: gnutls_session_t (implicit *) + * Mbed TLS: mbedtls_ssl_context* + * TinyDTLS: struct dtls_context* + * + * @param session The CoAP session. + * @param tls_lib Updated with the library type. + * + * @return The session TLS ptr or @c NULL if not set up + */ +void *coap_session_get_tls(const coap_session_t *session, + coap_tls_library_t *tls_lib); + +/** + * Get the session context + * + * @param session The CoAP session. + * + * @return The session's context + */ +coap_context_t *coap_session_get_context(const coap_session_t *session); + +/** + * Set the session type to client. Typically used in a call-home server. + * The session needs to be of type COAP_SESSION_TYPE_SERVER. + * Note: If this function is successful, the session reference count is + * incremented and a subsequent coap_session_release() taking the + * reference count to 0 will cause the session to be freed off. + * + * @param session The CoAP session. + * + * @return @c 1 if updated, @c 0 on failure. + */ +int coap_session_set_type_client(coap_session_t *session); + +/** + * Set the session MTU. This is the maximum message size that can be sent, + * excluding IP and UDP overhead. + * + * @param session The CoAP session. + * @param mtu maximum message size + */ +void coap_session_set_mtu(coap_session_t *session, unsigned mtu); + +/** + * Get maximum acceptable PDU size + * + * @param session The CoAP session. + * @return maximum PDU size, not including header (but including token). + */ +size_t coap_session_max_pdu_size(const coap_session_t *session); + +/** +* Creates a new client session to the designated server. +* @param ctx The CoAP context. +* @param local_if Address of local interface. It is recommended to use NULL to let the operating system choose a suitable local interface. If an address is specified, the port number should be zero, which means that a free port is automatically selected. +* @param server The server's address. If the port number is zero, the default port for the protocol will be used. +* @param proto Protocol. +* +* @return A new CoAP session or NULL if failed. Call coap_session_release to free. +*/ +coap_session_t *coap_new_client_session( + coap_context_t *ctx, + const coap_address_t *local_if, + const coap_address_t *server, + coap_proto_t proto +); + +/** +* Creates a new client session to the designated server with PSK credentials +* @param ctx The CoAP context. +* @param local_if Address of local interface. It is recommended to use NULL to let the operating system choose a suitable local interface. If an address is specified, the port number should be zero, which means that a free port is automatically selected. +* @param server The server's address. If the port number is zero, the default port for the protocol will be used. +* @param proto Protocol. +* @param identity PSK client identity +* @param key PSK shared key +* @param key_len PSK shared key length +* +* @return A new CoAP session or NULL if failed. Call coap_session_release to free. +*/ +coap_session_t *coap_new_client_session_psk( + coap_context_t *ctx, + const coap_address_t *local_if, + const coap_address_t *server, + coap_proto_t proto, + const char *identity, + const uint8_t *key, + unsigned key_len +); + +/** +* Creates a new client session to the designated server with PSK credentials +* @param ctx The CoAP context. +* @param local_if Address of local interface. It is recommended to use NULL to +* let the operating system choose a suitable local interface. +* If an address is specified, the port number should be zero, +* which means that a free port is automatically selected. +* @param server The server's address. If the port number is zero, the default +* port for the protocol will be used. +* @param proto CoAP Protocol. +* @param setup_data PSK parameters. +* +* @return A new CoAP session or NULL if failed. Call coap_session_release() +* to free. +*/ +coap_session_t *coap_new_client_session_psk2( + coap_context_t *ctx, + const coap_address_t *local_if, + const coap_address_t *server, + coap_proto_t proto, + coap_dtls_cpsk_t *setup_data +); + +/** + * Get the server session's current Identity Hint (PSK). + * + * @param session The current coap_session_t object. + * + * @return @c hint if successful, else @c NULL. + */ +const coap_bin_const_t * coap_session_get_psk_hint( + const coap_session_t *session); + +/** + * Get the session's current pre-shared key (PSK). + * + * @param session The current coap_session_t object. + * + * @return @c psk_key if successful, else @c NULL. + */ +const coap_bin_const_t * coap_session_get_psk_key( + const coap_session_t *session); + +/** +* Creates a new client session to the designated server with PKI credentials +* @param ctx The CoAP context. +* @param local_if Address of local interface. It is recommended to use NULL to +* let the operating system choose a suitable local interface. +* If an address is specified, the port number should be zero, +* which means that a free port is automatically selected. +* @param server The server's address. If the port number is zero, the default +* port for the protocol will be used. +* @param proto CoAP Protocol. +* @param setup_data PKI parameters. +* +* @return A new CoAP session or NULL if failed. Call coap_session_release() +* to free. +*/ +coap_session_t *coap_new_client_session_pki( + coap_context_t *ctx, + const coap_address_t *local_if, + const coap_address_t *server, + coap_proto_t proto, + coap_dtls_pki_t *setup_data +); + +/** + * Initializes the token value to use as a starting point. + * + * @param session The current coap_session_t object. + * @param length The length of the token (0 - 8 bytes). + * @param token The token data. + * + */ +void coap_session_init_token(coap_session_t *session, size_t length, + const uint8_t *token); + +/** + * Creates a new token for use. + * + * @param session The current coap_session_t object. + * @param length Updated with the length of the new token. + * @param token Updated with the new token data (must be 8 bytes long). + * + */ +void coap_session_new_token(coap_session_t *session, size_t *length, + uint8_t *token); + +/** + * @ingroup logging + * Get session description. + * + * @param session The CoAP session. + * @return description string. + */ +const char *coap_session_str(const coap_session_t *session); + +/** +* Create a new endpoint for communicating with peers. +* +* @param context The coap context that will own the new endpoint +* @param listen_addr Address the endpoint will listen for incoming requests on or originate outgoing requests from. Use NULL to specify that no incoming request will be accepted and use a random endpoint. +* @param proto Protocol used on this endpoint +*/ + +coap_endpoint_t *coap_new_endpoint(coap_context_t *context, const coap_address_t *listen_addr, coap_proto_t proto); + +/** +* Set the endpoint's default MTU. This is the maximum message size that can be +* sent, excluding IP and UDP overhead. +* +* @param endpoint The CoAP endpoint. +* @param mtu maximum message size +*/ +void coap_endpoint_set_default_mtu(coap_endpoint_t *endpoint, unsigned mtu); + +void coap_free_endpoint(coap_endpoint_t *ep); + +/** @} */ + +/** + * @ingroup logging +* Get endpoint description. +* +* @param endpoint The CoAP endpoint. +* @return description string. +*/ +const char *coap_endpoint_str(const coap_endpoint_t *endpoint); + +coap_session_t *coap_session_get_by_peer(const coap_context_t *ctx, + const coap_address_t *remote_addr, int ifindex); + + /** + * @defgroup cc Rate Control + * The transmission parameters for CoAP rate control ("Congestion + * Control" in stream-oriented protocols) are defined in + * https://tools.ietf.org/html/rfc7252#section-4.8 + * @{ + */ + + /** + * Number of seconds when to expect an ACK or a response to an + * outstanding CON message. + * RFC 7252, Section 4.8 Default value of ACK_TIMEOUT is 2 + * + * Configurable using coap_session_set_ack_timeout() + */ +#define COAP_DEFAULT_ACK_TIMEOUT ((coap_fixed_point_t){2,0}) + + /** + * A factor that is used to randomize the wait time before a message + * is retransmitted to prevent synchronization effects. + * RFC 7252, Section 4.8 Default value of ACK_RANDOM_FACTOR is 1.5 + * + * Configurable using coap_session_set_ack_random_factor() + */ +#define COAP_DEFAULT_ACK_RANDOM_FACTOR ((coap_fixed_point_t){1,500}) + + /** + * Number of message retransmissions before message sending is stopped + * RFC 7252, Section 4.8 Default value of MAX_RETRANSMIT is 4 + * + * Configurable using coap_session_set_max_retransmit() + */ +#define COAP_DEFAULT_MAX_RETRANSMIT 4 + + /** + * The number of simultaneous outstanding interactions that a client + * maintains to a given server. + * RFC 7252, Section 4.8 Default value of NSTART is 1 + */ +#define COAP_DEFAULT_NSTART 1 + + /** + * The maximum number of seconds before sending back a response to a + * multicast request. + * RFC 7252, Section 4.8 DEFAULT_LEISURE is 5. + */ +#ifndef COAP_DEFAULT_LEISURE +#define COAP_DEFAULT_LEISURE (5U) +#endif /* COAP_DEFAULT_LEISURE */ + + /** + * The MAX_TRANSMIT_SPAN definition for the session (s). + * + * RFC 7252, Section 4.8.2 Calculation of MAX_TRAMSMIT_SPAN + * ACK_TIMEOUT * ((2 ** (MAX_RETRANSMIT)) - 1) * ACK_RANDOM_FACTOR + */ +#define COAP_MAX_TRANSMIT_SPAN(s) \ + ((s->ack_timeout.integer_part * 1000 + s->ack_timeout.fractional_part) * \ + ((1 << (s->max_retransmit)) -1) * \ + (s->ack_random_factor.integer_part * 1000 + \ + s->ack_random_factor.fractional_part) \ + / 1000000) + + /** + * The MAX_TRANSMIT_WAIT definition for the session (s). + * + * RFC 7252, Section 4.8.2 Calculation of MAX_TRAMSMIT_WAIT + * ACK_TIMEOUT * ((2 ** (MAX_RETRANSMIT + 1)) - 1) * ACK_RANDOM_FACTOR + */ +#define COAP_MAX_TRANSMIT_WAIT(s) \ + ((s->ack_timeout.integer_part * 1000 + s->ack_timeout.fractional_part) * \ + ((1 << (s->max_retransmit + 1)) -1) * \ + (s->ack_random_factor.integer_part * 1000 + \ + s->ack_random_factor.fractional_part) \ + / 1000000) + + /** + * The MAX_LATENCY definition. + * RFC 7252, Section 4.8.2 MAX_LATENCY is 100. + */ +#define COAP_MAX_LATENCY 100 + + /** + * The PROCESSING_DELAY definition for the session (s). + * + * RFC 7252, Section 4.8.2 Calculation of PROCESSING_DELAY + * PROCESSING_DELAY set to ACK_TIMEOUT + */ +#define COAP_PROCESSING_DELAY(s) \ + ((s->ack_timeout.integer_part * 1000 + s->ack_timeout.fractional_part + 500) \ + / 1000) + + /** + * The MAX_RTT definition for the session (s). + * + * RFC 7252, Section 4.8.2 Calculation of MAX_RTT + * (2 * MAX_LATENCY) + PROCESSING_DELAY + */ +#define COAP_MAX_RTT(s) \ + ((2 * COAP_MAX_LATENCY) + COAP_PROCESSING_DELAY(s)) + + /** + * The EXCHANGE_LIFETIME definition for the session (s). + * + * RFC 7252, Section 4.8.2 Calculation of EXCHANGE_LIFETIME + * MAX_TRANSMIT_SPAN + (2 * MAX_LATENCY) + PROCESSING_DELAY + */ +#define COAP_EXCHANGE_LIFETIME(s) \ + (COAP_MAX_TRANSMIT_SPAN(s) + (2 * COAP_MAX_LATENCY) + COAP_PROCESSING_DELAY(s)) + + /** + * The NON_LIFETIME definition for the session (s). + * + * RFC 7252, Section 4.8.2 Calculation of NON_LIFETIME + * MAX_TRANSMIT_SPAN + MAX_LATENCY + */ +#define COAP_NON_LIFETIME(s) \ + (COAP_MAX_TRANSMIT_SPAN(s) + COAP_MAX_LATENCY) + + /** @} */ + +/** +* Set the CoAP maximum retransmit count before failure +* +* Number of message retransmissions before message sending is stopped +* +* @param session The CoAP session. +* @param value The value to set to. The default is 4 and should not normally +* get changed. +*/ +void coap_session_set_max_retransmit(coap_session_t *session, + unsigned int value); + +/** +* Set the CoAP initial ack response timeout before the next re-transmit +* +* Number of seconds when to expect an ACK or a response to an +* outstanding CON message. +* +* @param session The CoAP session. +* @param value The value to set to. The default is 2 and should not normally +* get changed. +*/ +void coap_session_set_ack_timeout(coap_session_t *session, + coap_fixed_point_t value); + +/** +* Set the CoAP ack randomize factor +* +* A factor that is used to randomize the wait time before a message +* is retransmitted to prevent synchronization effects. +* +* @param session The CoAP session. +* @param value The value to set to. The default is 1.5 and should not normally +* get changed. +*/ +void coap_session_set_ack_random_factor(coap_session_t *session, + coap_fixed_point_t value); + +/** +* Get the CoAP maximum retransmit before failure +* +* Number of message retransmissions before message sending is stopped +* +* @param session The CoAP session. +* +* @return Current maximum retransmit value +*/ +unsigned int coap_session_get_max_retransmit(const coap_session_t *session); + +/** +* Get the CoAP initial ack response timeout before the next re-transmit +* +* Number of seconds when to expect an ACK or a response to an +* outstanding CON message. +* +* @param session The CoAP session. +* +* @return Current ack response timeout value +*/ +coap_fixed_point_t coap_session_get_ack_timeout(const coap_session_t *session); + +/** +* Get the CoAP ack randomize factor +* +* A factor that is used to randomize the wait time before a message +* is retransmitted to prevent synchronization effects. +* +* @param session The CoAP session. +* +* @return Current ack randomize value +*/ +coap_fixed_point_t coap_session_get_ack_random_factor( + const coap_session_t *session); + +/** + * Send a ping message for the session. + * @param session The CoAP session. + * + * @return COAP_INVALID_MID if there is an error + */ +coap_mid_t coap_session_send_ping(coap_session_t *session); + +#endif /* COAP_SESSION_H */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_session_internal.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_session_internal.h new file mode 100644 index 00000000000..1fd2de9ecf1 --- /dev/null +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_session_internal.h @@ -0,0 +1,295 @@ +/* + * coap_session_internal.h -- Structures, Enums & Functions that are not + * exposed to application programming + * + * Copyright (C) 2010-2019 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_session_internal.h + * @brief COAP session internal information + */ + +#ifndef COAP_SESSION_INTERNAL_H_ +#define COAP_SESSION_INTERNAL_H_ + +#include "coap_io_internal.h" + +#define COAP_DEFAULT_SESSION_TIMEOUT 300 +#define COAP_PARTIAL_SESSION_TIMEOUT_TICKS (30 * COAP_TICKS_PER_SECOND) +#define COAP_DEFAULT_MAX_HANDSHAKE_SESSIONS 100 + +/** + * @defgroup session_internal Sessions (Internal) + * CoAP Session Structures, Enums and Functions that are not exposed to + * applications + * @{ + */ + +/** + * Only used for servers for hashing incoming packets. Cannot have local IP + * address as this may be an initial multicast and subsequent unicast address + */ +struct coap_addr_hash_t { + coap_address_t remote; /**< remote address and port */ + uint16_t lport; /**< local port */ + coap_proto_t proto; /**< CoAP protocol */ +}; + +/** + * Abstraction of virtual session that can be attached to coap_context_t + * (client) or coap_endpoint_t (server). + */ +struct coap_session_t { + coap_proto_t proto; /**< protocol used */ + coap_session_type_t type; /**< client or server side socket */ + coap_session_state_t state; /**< current state of relationaship with + peer */ + unsigned ref; /**< reference count from queues */ + size_t tls_overhead; /**< overhead of TLS layer */ + size_t mtu; /**< path or CSM mtu */ + coap_addr_hash_t addr_hash; /**< Address hash for server incoming packets */ + UT_hash_handle hh; + coap_addr_tuple_t addr_info; /**< key: remote/local address info */ + int ifindex; /**< interface index */ + coap_socket_t sock; /**< socket object for the session, if + any */ + coap_endpoint_t *endpoint; /**< session's endpoint */ + coap_context_t *context; /**< session's context */ + void *tls; /**< security parameters */ + uint16_t tx_mid; /**< the last message id that was used in + this session */ + uint8_t con_active; /**< Active CON request sent */ + uint8_t csm_block_supported; /**< CSM TCP blocks supported */ + coap_mid_t last_ping_mid; /**< the last keepalive message id that was + used in this session */ + coap_queue_t *delayqueue; /**< list of delayed messages waiting to + be sent */ + coap_lg_xmit_t *lg_xmit; /**< list of large transmissions */ + coap_lg_crcv_t *lg_crcv; /**< Client list of expected large receives */ + coap_lg_srcv_t *lg_srcv; /**< Server list of expected large receives */ + size_t partial_write; /**< if > 0 indicates number of bytes + already written from the pdu at the + head of sendqueue */ + uint8_t read_header[8]; /**< storage space for header of incoming + message header */ + size_t partial_read; /**< if > 0 indicates number of bytes + already read for an incoming message */ + coap_pdu_t *partial_pdu; /**< incomplete incoming pdu */ + coap_tick_t last_rx_tx; + coap_tick_t last_tx_rst; + coap_tick_t last_ping; + coap_tick_t last_pong; + coap_tick_t csm_tx; + coap_dtls_cpsk_t cpsk_setup_data; /**< client provided PSK initial setup + data */ + coap_bin_const_t *psk_identity; /**< If client, this field contains the + current identity for server; When this + field is NULL, the current identity is + contained in cpsk_setup_data + + If server, this field contains the client + provided identity. + + Value maintained internally */ + coap_bin_const_t *psk_key; /**< If client, this field contains the + current pre-shared key for server; + When this field is NULL, the current + key is contained in cpsk_setup_data + + If server, this field contains the + client's current key. + + Value maintained internally */ + coap_bin_const_t *psk_hint; /**< If client, this field contains the + server provided identity hint. + + If server, this field contains the + current hint for the client; When this + field is NULL, the current hint is + contained in context->spsk_setup_data + + Value maintained internally */ + void *app; /**< application-specific data */ + unsigned int max_retransmit; /**< maximum re-transmit count (default + 4) */ + coap_fixed_point_t ack_timeout; /**< timeout waiting for ack (default 2 + secs) */ + coap_fixed_point_t ack_random_factor; /**< ack random factor backoff (default + 1.5) */ + unsigned int dtls_timeout_count; /**< dtls setup retry counter */ + int dtls_event; /**< Tracking any (D)TLS events on this + sesison */ + uint8_t block_mode; /**< Zero or more COAP_BLOCK_ or'd options */ + uint64_t tx_token; /**< Next token number to use */ +}; + +/** + * Abstraction of virtual endpoint that can be attached to coap_context_t. The + * keys (port, bind_addr) must uniquely identify this endpoint. + */ +struct coap_endpoint_t { + struct coap_endpoint_t *next; + coap_context_t *context; /**< endpoint's context */ + coap_proto_t proto; /**< protocol used on this interface */ + uint16_t default_mtu; /**< default mtu for this interface */ + coap_socket_t sock; /**< socket object for the interface, if + any */ + coap_address_t bind_addr; /**< local interface address */ + coap_session_t *sessions; /**< hash table or list of active sessions */ +}; + +/** + * Notify session transport has just connected and CSM exchange can now start. + * + * @param session The CoAP session. + */ +void coap_session_send_csm(coap_session_t *session); + +/** + * Notify session that it has just connected or reconnected. + * + * @param session The CoAP session. + */ +void coap_session_connected(coap_session_t *session); + +/** + * Refresh the session's current Identity Hint (PSK). + * Note: A copy of @p psk_hint is maintained in the session by libcoap. + * + * @param session The current coap_session_t object. + * @param psk_hint If NULL, the Identity Hint will revert to the + * initial Identity Hint used at session setup. + * + * @return @c 1 if successful, else @c 0. + */ +int coap_session_refresh_psk_hint(coap_session_t *session, + const coap_bin_const_t *psk_hint); + +/** + * Refresh the session's current pre-shared key (PSK). + * Note: A copy of @p psk_key is maintained in the session by libcoap. + * + * @param session The current coap_session_t object. + * @param psk_key If NULL, the pre-shared key will revert to the + * initial pre-shared key used as session setup. + * + * @return @c 1 if successful, else @c 0. + */ +int coap_session_refresh_psk_key(coap_session_t *session, + const coap_bin_const_t *psk_key); + +/** + * Creates a new server session for the specified endpoint. + * @param ctx The CoAP context. + * @param ep An endpoint where an incoming connection request is pending. + * + * @return A new CoAP session or NULL if failed. Call coap_session_release to + * add to unused queue. + */ +coap_session_t *coap_new_server_session( + coap_context_t *ctx, + coap_endpoint_t *ep +); + +/** + * Function interface for datagram data transmission. This function returns + * the number of bytes that have been transmitted, or a value less than zero + * on error. + * + * @param session Session to send data on. + * @param data The data to send. + * @param datalen The actual length of @p data. + * + * @return The number of bytes written on success, or a value + * less than zero on error. + */ +ssize_t coap_session_send(coap_session_t *session, + const uint8_t *data, size_t datalen); + +/** + * Function interface for stream data transmission. This function returns + * the number of bytes that have been transmitted, or a value less than zero + * on error. The number of bytes written may be less than datalen because of + * congestion control. + * + * @param session Session to send data on. + * @param data The data to send. + * @param datalen The actual length of @p data. + * + * @return The number of bytes written on success, or a value + * less than zero on error. + */ +ssize_t coap_session_write(coap_session_t *session, + const uint8_t *data, size_t datalen); + +/** + * Send a pdu according to the session's protocol. This function returns + * the number of bytes that have been transmitted, or a value less than zero + * on error. + * + * @param session Session to send pdu on. + * @param pdu The pdu to send. + * + * @return The number of bytes written on success, or a value + * less than zero on error. + */ +ssize_t coap_session_send_pdu(coap_session_t *session, coap_pdu_t *pdu); + +ssize_t +coap_session_delay_pdu(coap_session_t *session, coap_pdu_t *pdu, + coap_queue_t *node); + +/** + * Lookup the server session for the packet received on an endpoint, or create + * a new one. + * + * @param endpoint Active endpoint the packet was received on. + * @param packet Received packet. + * @param now The current time in ticks. + * @return The CoAP session or @c NULL if error. + */ +coap_session_t *coap_endpoint_get_session(coap_endpoint_t *endpoint, + const coap_packet_t *packet, coap_tick_t now); + +/** + * Create a new DTLS session for the @p session. + * Note: the @p session is released if no DTLS server session can be created. + * + * @ingroup dtls_internal + * + * @param session Session to add DTLS session to + * @param now The current time in ticks. + * + * @return CoAP session or @c NULL if error. + */ +coap_session_t *coap_session_new_dtls_session(coap_session_t *session, + coap_tick_t now); + +void coap_session_free(coap_session_t *session); +void coap_session_mfree(coap_session_t *session); + +/** @} */ + +#define SESSIONS_ADD(e, obj) \ + HASH_ADD(hh, (e), addr_hash, sizeof((obj)->addr_hash), (obj)) + +#define SESSIONS_DELETE(e, obj) \ + HASH_DELETE(hh, (e), (obj)) + +#define SESSIONS_ITER(e, el, rtmp) \ + HASH_ITER(hh, (e), el, rtmp) + +#define SESSIONS_ITER_SAFE(e, el, rtmp) \ +for ((el) = (e); (el) && ((rtmp) = (el)->hh.next, 1); (el) = (rtmp)) + +#define SESSIONS_FIND(e, k, res) { \ + HASH_FIND(hh, (e), &(k), sizeof(k), (res)); \ + } + +#endif /* COAP_SESSION_INTERNAL_H_ */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_subscribe_internal.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_subscribe_internal.h new file mode 100644 index 00000000000..b7702362bee --- /dev/null +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_subscribe_internal.h @@ -0,0 +1,151 @@ +/* + * coap_subscribe_internal.h -- Structures, Enums & Functions that are not + * exposed to application programming + * + * Copyright (C) 2010-2021 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_subscribe_internal.h + * @brief COAP subscribe internal information + */ + +#ifndef COAP_SUBSCRIBE_INTERNAL_H_ +#define COAP_SUBSCRIBE_INTERNAL_H_ + +/** + * @defgroup subscribe_internal Observe Subscription (Internal) + * CoAP Observe Subscription Structures, Enums and Functions that are not + * exposed to applications + * @{ + */ + +#ifndef COAP_OBS_MAX_NON +/** + * Number of notifications that may be sent non-confirmable before a confirmable + * message is sent to detect if observers are alive. The maximum allowed value + * here is @c 15. + */ +#define COAP_OBS_MAX_NON 5 +#endif /* COAP_OBS_MAX_NON */ + +#ifndef COAP_OBS_MAX_FAIL +/** + * Number of confirmable notifications that may fail (i.e. time out without + * being ACKed) before an observer is removed. The maximum value for + * COAP_OBS_MAX_FAIL is @c 3. + */ +#define COAP_OBS_MAX_FAIL 3 +#endif /* COAP_OBS_MAX_FAIL */ + +/** Subscriber information */ +struct coap_subscription_t { + struct coap_subscription_t *next; /**< next element in linked list */ + struct coap_session_t *session; /**< subscriber session */ + + unsigned int non_cnt:4; /**< up to 15 non-confirmable notifies allowed */ + unsigned int fail_cnt:2; /**< up to 3 confirmable notifies can fail */ + unsigned int dirty:1; /**< set if the notification temporarily could not be + * sent (in that case, the resource's partially + * dirty flag is set too) */ + coap_cache_key_t *cache_key; /** cache_key to identify requester */ + coap_pdu_t *pdu; /**< PDU to use for additional requests */ +}; + +void coap_subscription_init(coap_subscription_t *); + +/** + * Handles a failed observe notify. + * + * @param context The context holding the resource. + * @param session The session that the observe notify failed on. + * @param token The token used when the observe notify failed. + */ +void +coap_handle_failed_notify(coap_context_t *context, + coap_session_t *session, + const coap_binary_t *token); + +/** + * Checks all known resources to see if they are dirty and then notifies + * subscribed observers. + * + * @param context The context to check for dirty resources. + */ +void coap_check_notify(coap_context_t *context); + +/** + * Adds the specified peer as observer for @p resource. The subscription is + * identified by the given @p token. This function returns the registered + * subscription information if the @p observer has been added, or @c NULL on + * error. + * + * @param resource The observed resource. + * @param session The observer's session + * @param token The token that identifies this subscription. + * @param pdu The requesting pdu. + * + * @return A pointer to the added/updated subscription + * information or @c NULL on error. + */ +coap_subscription_t *coap_add_observer(coap_resource_t *resource, + coap_session_t *session, + const coap_binary_t *token, + const coap_pdu_t *pdu); + +/** + * Returns a subscription object for given @p peer. + * + * @param resource The observed resource. + * @param session The observer's session + * @param token The token that identifies this subscription or @c NULL for + * any token. + * @return A valid subscription if exists or @c NULL otherwise. + */ +coap_subscription_t *coap_find_observer(coap_resource_t *resource, + coap_session_t *session, + const coap_binary_t *token); + +/** + * Flags that data is ready to be sent to observers. + * + * @param context The CoAP context to use. + * @param session The observer's session + * @param token The corresponding token that has been used for the + * subscription. + */ +void coap_touch_observer(coap_context_t *context, + coap_session_t *session, + const coap_binary_t *token); + +/** + * Removes any subscription for @p observer from @p resource and releases the + * allocated storage. The result is @c 1 if an observation relationship with @p + * observer and @p token existed, @c 0 otherwise. + * + * @param resource The observed resource. + * @param session The observer's session. + * @param token The token that identifies this subscription or @c NULL for + * any token. + * @return @c 1 if the observer has been deleted, @c 0 otherwise. + */ +int coap_delete_observer(coap_resource_t *resource, + coap_session_t *session, + const coap_binary_t *token); + +/** + * Removes any subscription for @p session and releases the allocated storage. + * + * @param context The CoAP context to use. + * @param session The observer's session. + */ +void coap_delete_observers(coap_context_t *context, coap_session_t *session); + +/** @} */ + +#endif /* COAP_SUBSCRIBE_INTERNAL_H_ */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_tcp_internal.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_tcp_internal.h new file mode 100644 index 00000000000..4fd31b38d01 --- /dev/null +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_tcp_internal.h @@ -0,0 +1,111 @@ +/* + * coap_tcp_internal.h -- TCP functions for libcoap + * + * Copyright (C) 2019--2020 Olaf Bergmann and others + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_tcp_internal.h + * @brief COAP tcp internal information + */ + +#ifndef COAP_TCP_INTERNAL_H_ +#define COAP_TCP_INTERNAL_H_ + +#include "coap_io.h" + +/** + * @defgroup tcp TCP Support (Internal) + * CoAP TCP Structures, Enums and Functions that are not exposed to + * applications + * @{ + */ + +#if !COAP_DISABLE_TCP + +/** + * Create a new TCP socket and initiate the connection + * + * Internal function. + * + * @param sock Where socket information is to be filled in + * @param local_if The local address to use or NULL + * @param server The address to connect to + * @param default_port The port to use if not set in @p server + * @param local_addr Filled in after connection initiation with + * the local address + * @param remote_addr Filled in after connection initiation with + * the remote address + * + * @return @c 1 if succesful, @c 0 if failure of some sort +*/ +int +coap_socket_connect_tcp1(coap_socket_t *sock, + const coap_address_t *local_if, + const coap_address_t *server, + int default_port, + coap_address_t *local_addr, + coap_address_t *remote_addr); + +/** + * Complete the TCP Connection + * + * Internal function. + * + * @param sock The socket information to use + * @param local_addr Filled in with the final local address + * @param remote_addr Filled in with the final remote address + * + * @return @c 1 if succesful, @c 0 if failure of some sort +*/ +int +coap_socket_connect_tcp2(coap_socket_t *sock, + coap_address_t *local_addr, + coap_address_t *remote_addr); + +/** + * Create a new TCP socket and then listen for new incoming TCP sessions + * + * Internal function. + * + * @param sock Where socket information is to be filled in + * @param listen_addr The address to be listening for new incoming sessions + * @param bound_addr Filled in with the address that the TCP layer + * is listening on for new incoming TCP sessions + * + * @return @c 1 if succesful, @c 0 if failure of some sort +*/ +int +coap_socket_bind_tcp(coap_socket_t *sock, + const coap_address_t *listen_addr, + coap_address_t *bound_addr); + +/** + * Accept a new incoming TCP session + * + * Internal function. + * + * @param server The socket information to use to accept the TCP connection + * @param new_client Filled in socket information with the new incoming + * session information + * @param local_addr Filled in with the local address + * @param remote_addr Filled in with the remote address + * + * @return @c 1 if succesful, @c 0 if failure of some sort +*/ +int +coap_socket_accept_tcp(coap_socket_t *server, + coap_socket_t *new_client, + coap_address_t *local_addr, + coap_address_t *remote_addr); + +#endif /* !COAP_DISABLE_TCP */ + +/** @} */ + +#endif /* COAP_TCP_INTERNAL_H_ */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/coap_time.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_time.h similarity index 80% rename from tools/sdk/esp32s2/include/coap/libcoap/include/coap2/coap_time.h rename to tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_time.h index e4a8e7c7c73..baa8650eaff 100644 --- a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/coap_time.h +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/coap_time.h @@ -3,6 +3,8 @@ * * Copyright (C) 2010-2019 Olaf Bergmann * + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ @@ -47,6 +49,10 @@ COAP_STATIC_INLINE coap_time_t coap_ticks_to_rt(coap_tick_t t) { return t / COAP_TICKS_PER_SECOND; } +COAP_STATIC_INLINE uint64_t coap_ticks_to_rt_us(coap_tick_t t) { + return (uint64_t)t * 1000000 / COAP_TICKS_PER_SECOND; +} + #elif defined(WITH_CONTIKI) #include "clock.h" @@ -75,7 +81,38 @@ COAP_STATIC_INLINE coap_time_t coap_ticks_to_rt(coap_tick_t t) { return t / COAP_TICKS_PER_SECOND; } -#else +COAP_STATIC_INLINE uint64_t coap_ticks_to_rt_us(coap_tick_t t) { + return (uint64_t)t * 1000000 / COAP_TICKS_PER_SECOND; +} + +#elif defined(RIOT_VERSION) +#include + +#define COAP_TICKS_PER_SECOND (XTIMER_HZ) + +typedef uint64_t coap_tick_t; +typedef int64_t coap_tick_diff_t; +typedef uint32_t coap_time_t; + +static inline void coap_clock_init(void) {} + +static inline void coap_ticks(coap_tick_t *t) { + *t = xtimer_now_usec64(); +} + +static inline coap_time_t coap_ticks_to_rt(coap_tick_t t) { + return t / 1000000UL; +} + +static inline uint64_t coap_ticks_to_rt_us(coap_tick_t t) { + return t; +} + +static inline coap_tick_t coap_ticks_from_rt_us(uint64_t t) { + return t / 1000000UL; +} +#else /* !WITH_LWIP && !WITH_CONTIKI && !RIOT_VERSION */ + #include /** diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/encode.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/encode.h similarity index 61% rename from tools/sdk/esp32s2/include/coap/libcoap/include/coap2/encode.h rename to tools/sdk/esp32/include/coap/libcoap/include/coap3/encode.h index b6d1524443c..a79146fc862 100644 --- a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/encode.h +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/encode.h @@ -3,6 +3,8 @@ * * Copyright (C) 2010-2012 Olaf Bergmann * + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ @@ -18,15 +20,6 @@ #include -#define Nn 8 /* duplicate definition of N if built on sky motes */ -#define ENCODE_HEADER_SIZE 4 -#define HIBIT (1 << (Nn - 1)) -#define EMASK ((1 << ENCODE_HEADER_SIZE) - 1) -#define MMASK ((1 << Nn) - 1 - EMASK) -#define MAX_VALUE ( (1 << Nn) - (1 << ENCODE_HEADER_SIZE) ) * (1 << ((1 << ENCODE_HEADER_SIZE) - 1)) - -#define COAP_PSEUDOFP_DECODE_8_4(r) (r < HIBIT ? r : (r & MMASK) << (r & EMASK)) - #ifndef HAVE_FLS /* include this only if fls() is not available */ extern int coap_fls(unsigned int i); @@ -41,28 +34,41 @@ extern int coap_flsll(long long i); #define coap_flsll(i) flsll(i) #endif -/* ls and s must be integer variables */ -#define COAP_PSEUDOFP_ENCODE_8_4_DOWN(v,ls) (v < HIBIT ? v : (ls = coap_fls(v) - Nn, (v >> ls) & MMASK) + ls) -#define COAP_PSEUDOFP_ENCODE_8_4_UP(v,ls,s) (v < HIBIT ? v : (ls = coap_fls(v) - Nn, (s = (((v + ((1<> ls) & MMASK)), s == 0 ? HIBIT + ls + 1 : s + ls)) +/** + * @defgroup encode Encode / Decode API + * API functions for endoding/decoding CoAP options. + * @{ + */ + +/** + * Decodes multiple-length byte sequences. @p buf points to an input byte + * sequence of length @p length. Returns the up to 4 byte decoded value. + * + * @param buf The input byte sequence to decode from + * @param length The length of the input byte sequence + * + * @return The decoded value + */ +unsigned int coap_decode_var_bytes(const uint8_t *buf, size_t length); /** * Decodes multiple-length byte sequences. @p buf points to an input byte - * sequence of length @p length. Returns the decoded value. + * sequence of length @p length. Returns the up to 8 byte decoded value. * * @param buf The input byte sequence to decode from * @param length The length of the input byte sequence * * @return The decoded value */ -unsigned int coap_decode_var_bytes(const uint8_t *buf, unsigned int length); +uint64_t coap_decode_var_bytes8(const uint8_t *buf, size_t length); /** * Encodes multiple-length byte sequences. @p buf points to an output buffer of - * sufficient length to store the encoded bytes. @p value is the value to - * encode. + * sufficient length to store the encoded bytes. @p value is the 4 byte value + * to encode. * Returns the number of bytes used to encode @p value or 0 on error. * - * @param buf The output buffer to decode into + * @param buf The output buffer to encode into * @param length The output buffer size to encode into (must be sufficient) * @param value The value to encode into the buffer * @@ -72,6 +78,24 @@ unsigned int coap_encode_var_safe(uint8_t *buf, size_t length, unsigned int value); +/** + * Encodes multiple-length byte sequences. @p buf points to an output buffer of + * sufficient length to store the encoded bytes. @p value is the 8 byte value + * to encode. + * Returns the number of bytes used to encode @p value or 0 on error. + * + * @param buf The output buffer to encode into + * @param length The output buffer size to encode into (must be sufficient) + * @param value The value to encode into the buffer + * + * @return The number of bytes used to encode @p value or @c 0 on error. + */ +unsigned int coap_encode_var_safe8(uint8_t *buf, + size_t length, + uint64_t value); + +/** @} */ + /** * @deprecated Use coap_encode_var_safe() instead. * Provided for backward compatibility. As @p value has a diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap2/libcoap.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/libcoap.h similarity index 86% rename from tools/sdk/esp32/include/coap/libcoap/include/coap2/libcoap.h rename to tools/sdk/esp32/include/coap/libcoap/include/coap3/libcoap.h index 77ba5db23e2..60ca3b64b90 100644 --- a/tools/sdk/esp32/include/coap/libcoap/include/coap2/libcoap.h +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/libcoap.h @@ -3,6 +3,8 @@ * * Copyright (C) 2015 Carsten Schoenert * + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ @@ -46,6 +48,13 @@ typedef USHORT in_port_t; # define COAP_DEPRECATED __attribute__ ((deprecated)) # endif #endif +#ifndef COAP_UNUSED +# ifdef __GNUC__ +# define COAP_UNUSED __attribute__((unused)) +# else /* __GNUC__ */ +# define COAP_UNUSED +# endif /* __GNUC__ */ +#endif /* COAP_UNUSED */ void coap_startup(void); diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/lwippools.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/lwippools.h similarity index 66% rename from tools/sdk/esp32s2/include/coap/libcoap/include/coap2/lwippools.h rename to tools/sdk/esp32/include/coap/libcoap/include/coap3/lwippools.h index cb90d8099db..445bce4a94a 100644 --- a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/lwippools.h +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/lwippools.h @@ -1,4 +1,6 @@ /* + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ @@ -9,10 +11,10 @@ * include this or include something more generic which includes this), and * MEMP_USE_CUSTOM_POOLS has to be set in lwipopts.h. */ -#include "coap_config.h" -#include -#include -#include +#include "coap_internal.h" +#include "net.h" +#include "resource.h" +#include "subscribe.h" #ifndef MEMP_NUM_COAPCONTEXT #define MEMP_NUM_COAPCONTEXT 1 @@ -67,6 +69,34 @@ #define MEMP_LEN_COAPSTRING 32 #endif +#ifndef MEMP_NUM_COAPCACHE_KEYS +#define MEMP_NUM_COAPCACHE_KEYS (2U) +#endif /* MEMP_NUM_COAPCACHE_KEYS */ + +#ifndef MEMP_NUM_COAPCACHE_ENTRIES +#define MEMP_NUM_COAPCACHE_ENTRIES (2U) +#endif /* MEMP_NUM_COAPCACHE_ENTRIES */ + +#ifndef MEMP_NUM_COAPPDUBUF +#define MEMP_NUM_COAPPDUBUF 2 +#endif + +#ifndef MEMP_LEN_COAPPDUBUF +#define MEMP_LEN_COAPPDUBUF 32 +#endif + +#ifndef MEMP_NUM_COAPLGXMIT +#define MEMP_NUM_COAPLGXMIT 2 +#endif + +#ifndef MEMP_NUM_COAPLGCRCV +#define MEMP_NUM_COAPLGCRCV 2 +#endif + +#ifndef MEMP_NUM_COAPLGSRCV +#define MEMP_NUM_COAPLGSRCV 2 +#endif + LWIP_MEMPOOL(COAP_CONTEXT, MEMP_NUM_COAPCONTEXT, sizeof(coap_context_t), "COAP_CONTEXT") LWIP_MEMPOOL(COAP_ENDPOINT, MEMP_NUM_COAPENDPOINT, sizeof(coap_endpoint_t), "COAP_ENDPOINT") LWIP_MEMPOOL(COAP_PACKET, MEMP_NUM_COAPPACKET, sizeof(coap_packet_t), "COAP_PACKET") @@ -78,4 +108,10 @@ LWIP_MEMPOOL(COAP_RESOURCE, MEMP_NUM_COAPRESOURCE, sizeof(coap_resource_t), "COA LWIP_MEMPOOL(COAP_RESOURCEATTR, MEMP_NUM_COAPRESOURCEATTR, sizeof(coap_attr_t), "COAP_RESOURCEATTR") LWIP_MEMPOOL(COAP_OPTLIST, MEMP_NUM_COAPOPTLIST, sizeof(coap_optlist_t)+MEMP_LEN_COAPOPTLIST, "COAP_OPTLIST") LWIP_MEMPOOL(COAP_STRING, MEMP_NUM_COAPSTRING, sizeof(coap_string_t)+MEMP_LEN_COAPSTRING, "COAP_STRING") +LWIP_MEMPOOL(COAP_CACHE_KEY, MEMP_NUM_COAPCACHE_KEYS, sizeof(coap_cache_key_t), "COAP_CACHE_KEY") +LWIP_MEMPOOL(COAP_CACHE_ENTRY, MEMP_NUM_COAPCACHE_ENTRIES, sizeof(coap_cache_entry_t), "COAP_CACHE_ENTRY") +LWIP_MEMPOOL(COAP_PDU_BUF, MEMP_NUM_COAPPDUBUF, MEMP_LEN_COAPPDUBUF, "COAP_PDU_BUF") +LWIP_MEMPOOL(COAP_LG_XMIT, MEMP_NUM_COAPLGXMIT, sizeof(coap_lg_xmit_t), "COAP_LG_XMIT") +LWIP_MEMPOOL(COAP_LG_CRCV, MEMP_NUM_COAPLGCRCV, sizeof(coap_lg_crcv_t), "COAP_LG_CRCV") +LWIP_MEMPOOL(COAP_LG_SRCV, MEMP_NUM_COAPLGSRCV, sizeof(coap_lg_srcv_t), "COAP_LG_SRCV") diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/mem.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/mem.h similarity index 81% rename from tools/sdk/esp32s2/include/coap/libcoap/include/coap2/mem.h rename to tools/sdk/esp32/include/coap/libcoap/include/coap3/mem.h index ea3c619fd30..c42008963da 100644 --- a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/mem.h +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/mem.h @@ -3,6 +3,8 @@ * * Copyright (C) 2010-2011,2014-2015 Olaf Bergmann * + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ @@ -43,6 +45,11 @@ typedef enum { #endif COAP_SESSION, COAP_OPTLIST, + COAP_CACHE_KEY, + COAP_CACHE_ENTRY, + COAP_LG_XMIT, + COAP_LG_CRCV, + COAP_LG_SRCV, } coap_memory_tag_t; #ifndef WITH_LWIP @@ -59,6 +66,22 @@ typedef enum { */ void *coap_malloc_type(coap_memory_tag_t type, size_t size); +/** + * Reallocates a chunk @p p of bytes created by coap_malloc_type() or + * coap_realloc_type() and returns a pointer to the newly allocated memory of + * @p size. + * Only COAP_STRING type is supported. + * + * Note: If there is an error, @p p will separately need to be released by + * coap_free_type(). + * + * @param type The type of object to be stored. + * @param p A pointer to memory that was allocated by coap_malloc_type(). + * @param size The number of bytes requested. + * @return A pointer to the allocated storage or @c NULL on error. + */ +void *coap_realloc_type(coap_memory_tag_t type, void *p, size_t size); + /** * Releases the memory that was allocated by coap_malloc_type(). The type tag @p * type must be the same that was used for allocating the object pointed to by diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap3/net.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/net.h new file mode 100644 index 00000000000..577a0b5d5a5 --- /dev/null +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/net.h @@ -0,0 +1,779 @@ +/* + * net.h -- CoAP network interface + * + * Copyright (C) 2010-2021 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +#ifndef COAP_NET_H_ +#define COAP_NET_H_ + +#include +#include +#ifndef _WIN32 +#include +#endif +#include + +#ifdef WITH_LWIP +#include +#endif + +#include "coap_io.h" +#include "coap_dtls.h" +#include "coap_event.h" +#include "pdu.h" +#include "coap_session.h" + +/** + * @defgroup context Context Handling + * API functions for handling PDUs using CoAP Contexts + * @{ + */ + +typedef enum coap_response_t { + COAP_RESPONSE_FAIL, /**< Response not liked - send CoAP RST packet */ + COAP_RESPONSE_OK /**< Response is fine */ +} coap_response_t; + +/** + * Response handler that is used as callback in coap_context_t. + * + * @param session CoAP session. + * @param sent The PDU that was transmitted. + * @param received The PDU that was received. + * @param mid CoAP transaction ID. + + * @return @c COAP_RESPONSE_OK if successful, else @c COAP_RESPONSE_FAIL which + * triggers sending a RST packet. + */ +typedef coap_response_t (*coap_response_handler_t)(coap_session_t *session, + const coap_pdu_t *sent, + const coap_pdu_t *received, + const coap_mid_t mid); + +/** + * Negative Acknowedge handler that is used as callback in coap_context_t. + * + * @param session CoAP session. + * @param sent The PDU that was transmitted. + * @param reason The reason for the NACK. + * @param mid CoAP message ID. + */ +typedef void (*coap_nack_handler_t)(coap_session_t *session, + const coap_pdu_t *sent, + const coap_nack_reason_t reason, + const coap_mid_t mid); + +/** + * Received Ping handler that is used as callback in coap_context_t. + * + * @param session CoAP session. + * @param received The PDU that was received. + * @param mid CoAP message ID. + */ +typedef void (*coap_ping_handler_t)(coap_session_t *session, + const coap_pdu_t *received, + const coap_mid_t mid); + +/** + * Received Pong handler that is used as callback in coap_context_t. + * + * @param session CoAP session. + * @param received The PDU that was received. + * @param mid CoAP message ID. + */ +typedef void (*coap_pong_handler_t)(coap_session_t *session, + const coap_pdu_t *received, + const coap_mid_t mid); + +/** + * Registers a new message handler that is called whenever a response is + * received. + * + * @param context The context to register the handler for. + * @param handler The response handler to register. + */ +void +coap_register_response_handler(coap_context_t *context, + coap_response_handler_t handler); + +/** + * Registers a new message handler that is called whenever a confirmable + * message (request or response) is dropped after all retries have been + * exhausted, or a rst message was received, or a network or TLS level + * event was received that indicates delivering the message is not possible. + * + * @param context The context to register the handler for. + * @param handler The nack handler to register. + */ +void +coap_register_nack_handler(coap_context_t *context, + coap_nack_handler_t handler); + +/** + * Registers a new message handler that is called whenever a CoAP Ping + * message is received. + * + * @param context The context to register the handler for. + * @param handler The ping handler to register. + */ +void +coap_register_ping_handler(coap_context_t *context, + coap_ping_handler_t handler); + +/** + * Registers a new message handler that is called whenever a CoAP Pong + * message is received. + * + * @param context The context to register the handler for. + * @param handler The pong handler to register. + */ +void +coap_register_pong_handler(coap_context_t *context, + coap_pong_handler_t handler); + +/** + * Registers the option type @p type with the given context object @p ctx. + * + * @param ctx The context to use. + * @param type The option type to register. + */ +void +coap_register_option(coap_context_t *ctx, uint16_t type); + +/** + * Creates a new coap_context_t object that will hold the CoAP stack status. + */ +coap_context_t *coap_new_context(const coap_address_t *listen_addr); + +/** + * Set the context's default PSK hint and/or key for a server. + * + * @param context The current coap_context_t object. + * @param hint The default PSK server hint sent to a client. If NULL, PSK + * authentication is disabled. Empty string is a valid hint. + * @param key The default PSK key. If NULL, PSK authentication will fail. + * @param key_len The default PSK key's length. If @p 0, PSK authentication will + * fail. + * + * @return @c 1 if successful, else @c 0. + */ +int coap_context_set_psk( coap_context_t *context, const char *hint, + const uint8_t *key, size_t key_len ); + +/** + * Set the context's default PSK hint and/or key for a server. + * + * @param context The current coap_context_t object. + * @param setup_data If NULL, PSK authentication will fail. PSK + * information required. + * + * @return @c 1 if successful, else @c 0. + */ +int coap_context_set_psk2(coap_context_t *context, + coap_dtls_spsk_t *setup_data); + +/** + * Set the context's default PKI information for a server. + * + * @param context The current coap_context_t object. + * @param setup_data If NULL, PKI authentication will fail. Certificate + * information required. + * + * @return @c 1 if successful, else @c 0. + */ +int +coap_context_set_pki(coap_context_t *context, + const coap_dtls_pki_t *setup_data); + +/** + * Set the context's default Root CA information for a client or server. + * + * @param context The current coap_context_t object. + * @param ca_file If not NULL, is the full path name of a PEM encoded + * file containing all the Root CAs to be used. + * @param ca_dir If not NULL, points to a directory containing PEM + * encoded files containing all the Root CAs to be used. + * + * @return @c 1 if successful, else @c 0. + */ +int +coap_context_set_pki_root_cas(coap_context_t *context, + const char *ca_file, + const char *ca_dir); + +/** + * Set the context keepalive timer for sessions. + * A keepalive message will be sent after if a session has been inactive, + * i.e. no packet sent or received, for the given number of seconds. + * For unreliable protocols, a CoAP Empty message will be sent. If a + * CoAP RST is not received, the CoAP Empty messages will get resent based + * on the Confirmable retry parameters until there is a failure timeout, + * at which point the session will be considered as disconnected. + * For reliable protocols, a CoAP PING message will be sent. If a CoAP PONG + * has not been received before the next PING is due to be sent, the session + * will be considered as disconnected. + * + * @param context The coap_context_t object. + * @param seconds Number of seconds for the inactivity timer, or zero + * to disable CoAP-level keepalive messages. + */ +void coap_context_set_keepalive(coap_context_t *context, unsigned int seconds); + +/** + * Get the libcoap internal file descriptor for using in an application's + * select() or returned as an event in an application's epoll_wait() call. + * + * @param context The coap_context_t object. + * + * @return The libcoap file descriptor or @c -1 if epoll is not available. + */ +int coap_context_get_coap_fd(const coap_context_t *context); + +/** + * Set the maximum idle sessions count. The number of server sessions that + * are currently not in use. If this number is exceeded, the least recently + * used server session is completely removed. + * 0 (the default) means that the number is not monitored. + * + * @param context The coap_context_t object. + * @param max_idle_sessions The maximum idle session count. + */ +void +coap_context_set_max_idle_sessions(coap_context_t *context, + unsigned int max_idle_sessions); + +/** + * Get the maximum idle sessions count. + * + * @param context The coap_context_t object. + * + * @return The count of max idle sessions. + */ +unsigned int +coap_context_get_max_idle_sessions(const coap_context_t *context); + +/** + * Set the session timeout value. The number of seconds of inactivity after + * which an unused server session will be closed. + * 0 means use default (300 secs). + * + * @param context The coap_context_t object. + * @param session_timeout The session timeout value. + */ +void +coap_context_set_session_timeout(coap_context_t *context, + unsigned int session_timeout); + +/** + * Get the session timeout value + * + * @param context The coap_context_t object. + * + * @return The session timeout value. + */ +unsigned int +coap_context_get_session_timeout(const coap_context_t *context); + +/** + * Set the CSM timeout value. The number of seconds to wait for a (TCP) CSM + * negotiation response from the peer. + * 0 (the default) means use wait forever. + * + * @param context The coap_context_t object. + * @param csm_tmeout The CSM timeout value. + */ +void +coap_context_set_csm_timeout(coap_context_t *context, + unsigned int csm_tmeout); + +/** + * Get the CSM timeout value + * + * @param context The coap_context_t object. + * + * @return The CSM timeout value. + */ +unsigned int +coap_context_get_csm_timeout(const coap_context_t *context); + +/** + * Set the maximum number of sessions in (D)TLS handshake value. If this number + * is exceeded, the least recently used server session in handshake is + * completely removed. + * 0 (the default) means that the number is not monitored. + * + * @param context The coap_context_t object. + * @param max_handshake_sessions The maximum number of sessions in handshake. + */ +void +coap_context_set_max_handshake_sessions(coap_context_t *context, + unsigned int max_handshake_sessions); + +/** + * Get the session timeout value + * + * @param context The coap_context_t object. + * + * @return The maximim number of sessions in (D)TLS handshake value. + */ +unsigned int +coap_context_get_max_handshake_sessions(const coap_context_t *context); + +/** + * Returns a new message id and updates @p session->tx_mid accordingly. The + * message id is returned in network byte order to make it easier to read in + * tracing tools. + * + * @param session The current coap_session_t object. + * + * @return Incremented message id in network byte order. + */ +uint16_t coap_new_message_id(coap_session_t *session); + +/** + * CoAP stack context must be released with coap_free_context(). This function + * clears all entries from the receive queue and send queue and deletes the + * resources that have been registered with @p context, and frees the attached + * endpoints. + * + * @param context The current coap_context_t object to free off. + */ +void coap_free_context(coap_context_t *context); + +/** + * Stores @p data with the given CoAP context. This function + * overwrites any value that has previously been stored with @p + * context. + * + * @param context The CoAP context. + * @param data The data to store with wih the context. Note that this data + * must be valid during the lifetime of @p context. + */ +void coap_set_app_data(coap_context_t *context, void *data); + +/** + * Returns any application-specific data that has been stored with @p + * context using the function coap_set_app_data(). This function will + * return @c NULL if no data has been stored. + * + * @param context The CoAP context. + * + * @return The data previously stored or @c NULL if not data stored. + */ +void *coap_get_app_data(const coap_context_t *context); + +/** + * Creates a new ACK PDU with specified error @p code. The options specified by + * the filter expression @p opts will be copied from the original request + * contained in @p request. Unless @c SHORT_ERROR_RESPONSE was defined at build + * time, the textual reason phrase for @p code will be added as payload, with + * Content-Type @c 0. + * This function returns a pointer to the new response message, or @c NULL on + * error. The storage allocated for the new message must be released with + * coap_free(). + * + * @param request Specification of the received (confirmable) request. + * @param code The error code to set. + * @param opts An option filter that specifies which options to copy from + * the original request in @p node. + * + * @return A pointer to the new message or @c NULL on error. + */ +coap_pdu_t *coap_new_error_response(const coap_pdu_t *request, + coap_pdu_code_t code, + coap_opt_filter_t *opts); + +/** + * Sends an error response with code @p code for request @p request to @p dst. + * @p opts will be passed to coap_new_error_response() to copy marked options + * from the request. This function returns the message id if the message was + * sent, or @c COAP_INVALID_MID otherwise. + * + * @param session The CoAP session. + * @param request The original request to respond to. + * @param code The response code. + * @param opts A filter that specifies the options to copy from the + * @p request. + * + * @return The message id if the message was sent, or @c + * COAP_INVALID_MID otherwise. + */ +coap_mid_t coap_send_error(coap_session_t *session, + const coap_pdu_t *request, + coap_pdu_code_t code, + coap_opt_filter_t *opts); + +/** + * Helper function to create and send a message with @p type (usually ACK or + * RST). This function returns @c COAP_INVALID_MID when the message was not + * sent, a valid transaction id otherwise. + * + * @param session The CoAP session. + * @param request The request that should be responded to. + * @param type Which type to set. + * @return message id on success or @c COAP_INVALID_MID + * otherwise. + */ +coap_mid_t +coap_send_message_type(coap_session_t *session, const coap_pdu_t *request, + coap_pdu_type_t type); + +/** + * Sends an ACK message with code @c 0 for the specified @p request to @p dst. + * This function returns the corresponding message id if the message was + * sent or @c COAP_INVALID_MID on error. + * + * @param session The CoAP session. + * @param request The request to be acknowledged. + * + * @return The message id if ACK was sent or @c + * COAP_INVALID_MID on error. + */ +coap_mid_t coap_send_ack(coap_session_t *session, const coap_pdu_t *request); + +/** + * Sends an RST message with code @c 0 for the specified @p request to @p dst. + * This function returns the corresponding message id if the message was + * sent or @c COAP_INVALID_MID on error. + * + * @param session The CoAP session. + * @param request The request to be reset. + * + * @return The message id if RST was sent or @c + * COAP_INVALID_MID on error. + */ +COAP_STATIC_INLINE coap_mid_t +coap_send_rst(coap_session_t *session, const coap_pdu_t *request) { + return coap_send_message_type(session, request, COAP_MESSAGE_RST); +} + +/** +* Sends a CoAP message to given peer. The memory that is +* allocated for the pdu will be released by coap_send(). +* The caller must not use the pdu after calling coap_send(). +* +* @param session The CoAP session. +* @param pdu The CoAP PDU to send. +* +* @return The message id of the sent message or @c +* COAP_INVALID_MID on error. +*/ +coap_mid_t coap_send( coap_session_t *session, coap_pdu_t *pdu ); + +#define coap_send_large(session, pdu) coap_send(session, pdu) + +/** + * Invokes the event handler of @p context for the given @p event and + * @p data. + * + * @param context The CoAP context whose event handler is to be called. + * @param event The event to deliver. + * @param session The session related to @p event. + * @return The result from the associated event handler or 0 if none was + * registered. + */ +int coap_handle_event(coap_context_t *context, + coap_event_t event, + coap_session_t *session); +/** + * Returns 1 if there are no messages to send or to dispatch in the context's + * queues. */ +int coap_can_exit(coap_context_t *context); + +/** + * Returns the current value of an internal tick counter. The counter counts \c + * COAP_TICKS_PER_SECOND ticks every second. + */ +void coap_ticks(coap_tick_t *); + +/** + * Function interface for joining a multicast group for listening for the + * currently defined endpoints that are UDP. + * + * @param ctx The current context. + * @param groupname The name of the group that is to be joined for listening. + * @param ifname Network interface to join the group on, or NULL if first + * appropriate interface is to be chosen by the O/S. + * + * @return 0 on success, -1 on error + */ +int +coap_join_mcast_group_intf(coap_context_t *ctx, const char *groupname, + const char *ifname); + +#define coap_join_mcast_group(ctx, groupname) \ + (coap_join_mcast_group_intf(ctx, groupname, NULL)) + +/** + * Function interface for defining the hop count (ttl) for sending + * multicast traffic + * + * @param session The current contexsion. + * @param hops The number of hops (ttl) to use before the multicast + * packet expires. + * + * @return 1 on success, 0 on error + */ +int +coap_mcast_set_hops(coap_session_t *session, size_t hops); + +/**@}*/ + +/** + * @defgroup app_io Application I/O Handling + * API functions for Application Input / Output + * @{ + */ + +#define COAP_IO_WAIT 0 +#define COAP_IO_NO_WAIT ((uint32_t)-1) + +/** + * The main I/O processing function. All pending network I/O is completed, + * and then optionally waits for the next input packet. + * + * This internally calls coap_io_prepare_io(), then select() for the appropriate + * sockets, updates COAP_SOCKET_CAN_xxx where appropriate and then calls + * coap_io_do_io() before returning with the time spent in the function. + * + * Alternatively, if libcoap is compiled with epoll support, this internally + * calls coap_io_prepare_epoll(), then epoll_wait() for waiting for any file + * descriptors that have (internally) been set up with epoll_ctl() and + * finally coap_io_do_epoll() before returning with the time spent in the + * function. + * + * @param ctx The CoAP context + * @param timeout_ms Minimum number of milliseconds to wait for new packets + * before returning after doing any processing. + * If COAP_IO_WAIT, the call will block until the next + * internal action (e.g. packet retransmit) if any, or block + * until the next packet is received whichever is the sooner + * and do the necessary processing. + * If COAP_IO_NO_WAIT, the function will return immediately + * after processing without waiting for any new input + * packets to arrive. + * + * @return Number of milliseconds spent in function or @c -1 if there was + * an error + */ +int coap_io_process(coap_context_t *ctx, uint32_t timeout_ms); + +#ifndef RIOT_VERSION +/** + * The main message processing loop with additional fds for internal select. + * + * @param ctx The CoAP context + * @param timeout_ms Minimum number of milliseconds to wait for new packets + * before returning after doing any processing. + * If COAP_IO_WAIT, the call will block until the next + * internal action (e.g. packet retransmit) if any, or block + * until the next packet is received whichever is the sooner + * and do the necessary processing. + * If COAP_IO_NO_WAIT, the function will return immediately + * after processing without waiting for any new input + * packets to arrive. + * @param nfds The maximum FD set in readfds, writefds or exceptfds + * plus one, + * @param readfds Read FDs to additionally check for in internal select() + * or NULL if not required. + * @param writefds Write FDs to additionally check for in internal select() + * or NULL if not required. + * @param exceptfds Except FDs to additionally check for in internal select() + * or NULL if not required. + * + * + * @return Number of milliseconds spent in coap_io_process_with_fds, or @c -1 + * if there was an error. If defined, readfds, writefds, exceptfds + * are updated as returned by the internal select() call. + */ +int coap_io_process_with_fds(coap_context_t *ctx, uint32_t timeout_ms, + int nfds, fd_set *readfds, fd_set *writefds, + fd_set *exceptfds); +#endif /* !RIOT_VERSION */ + +/**@}*/ + +/** + * @defgroup app_io_internal Application I/O Handling (Internal) + * Internal API functions for Application Input / Output + * @{ + */ + +/** +* Iterates through all the coap_socket_t structures embedded in endpoints or +* sessions associated with the @p ctx to determine which are wanting any +* read, write, accept or connect I/O (COAP_SOCKET_WANT_xxx is set). If set, +* the coap_socket_t is added to the @p sockets. +* +* Any now timed out delayed packet is transmitted, along with any packets +* associated with requested observable response. +* +* In addition, it returns when the next expected I/O is expected to take place +* (e.g. a packet retransmit). +* +* Prior to calling coap_io_do_io(), the @p sockets must be tested to see +* if any of the COAP_SOCKET_WANT_xxx have the appropriate information and if +* so, COAP_SOCKET_CAN_xxx is set. This typically will be done after using a +* select() call. +* +* Note: If epoll support is compiled into libcoap, coap_io_prepare_epoll() must +* be used instead of coap_io_prepare_io(). +* +* Internal function. +* +* @param ctx The CoAP context +* @param sockets Array of socket descriptors, filled on output +* @param max_sockets Size of socket array. +* @param num_sockets Pointer to the number of valid entries in the socket +* arrays on output. +* @param now Current time. +* +* @return timeout Maxmimum number of milliseconds that can be used by a +* select() to wait for network events or 0 if wait should be +* forever. +*/ +unsigned int +coap_io_prepare_io(coap_context_t *ctx, + coap_socket_t *sockets[], + unsigned int max_sockets, + unsigned int *num_sockets, + coap_tick_t now +); + +/** + * Processes any outstanding read, write, accept or connect I/O as indicated + * in the coap_socket_t structures (COAP_SOCKET_CAN_xxx set) embedded in + * endpoints or sessions associated with @p ctx. + * + * Note: If epoll support is compiled into libcoap, coap_io_do_epoll() must + * be used instead of coap_io_do_io(). + * + * Internal function. + * + * @param ctx The CoAP context + * @param now Current time + */ +void coap_io_do_io(coap_context_t *ctx, coap_tick_t now); + +/** + * Any now timed out delayed packet is transmitted, along with any packets + * associated with requested observable response. + * + * In addition, it returns when the next expected I/O is expected to take place + * (e.g. a packet retransmit). + * + * Note: If epoll support is compiled into libcoap, coap_io_prepare_epoll() must + * be used instead of coap_io_prepare_io(). + * + * Internal function. + * + * @param ctx The CoAP context + * @param now Current time. + * + * @return timeout Maxmimum number of milliseconds that can be used by a + * epoll_wait() to wait for network events or 0 if wait should be + * forever. + */ +unsigned int +coap_io_prepare_epoll(coap_context_t *ctx, coap_tick_t now); + +struct epoll_event; + +/** + * Process all the epoll events + * + * Note: If epoll support is compiled into libcoap, coap_io_do_epoll() must + * be used instead of coap_io_do_io(). + * + * Internal function + * + * @param ctx The current CoAP context. + * @param events The list of events returned from an epoll_wait() call. + * @param nevents The number of events. + * + */ +void coap_io_do_epoll(coap_context_t *ctx, struct epoll_event* events, + size_t nevents); + +/**@}*/ + +/** + * @deprecated Use coap_io_process() instead. + * + * This function just calls coap_io_process(). + * + * @param ctx The CoAP context + * @param timeout_ms Minimum number of milliseconds to wait for new packets + * before returning after doing any processing. + * If COAP_IO_WAIT, the call will block until the next + * internal action (e.g. packet retransmit) if any, or block + * until the next packet is received whichever is the sooner + * and do the necessary processing. + * If COAP_IO_NO_WAIT, the function will return immediately + * after processing without waiting for any new input + * packets to arrive. + * + * @return Number of milliseconds spent in function or @c -1 if there was + * an error + */ +COAP_STATIC_INLINE COAP_DEPRECATED int +coap_run_once(coap_context_t *ctx, uint32_t timeout_ms) +{ + return coap_io_process(ctx, timeout_ms); +} + +/** +* @deprecated Use coap_io_prepare_io() instead. +* +* This function just calls coap_io_prepare_io(). +* +* Internal function. +* +* @param ctx The CoAP context +* @param sockets Array of socket descriptors, filled on output +* @param max_sockets Size of socket array. +* @param num_sockets Pointer to the number of valid entries in the socket +* arrays on output. +* @param now Current time. +* +* @return timeout Maxmimum number of milliseconds that can be used by a +* select() to wait for network events or 0 if wait should be +* forever. +*/ +COAP_STATIC_INLINE COAP_DEPRECATED unsigned int +coap_write(coap_context_t *ctx, + coap_socket_t *sockets[], + unsigned int max_sockets, + unsigned int *num_sockets, + coap_tick_t now +) { + return coap_io_prepare_io(ctx, sockets, max_sockets, num_sockets, now); +} + +/** + * @deprecated Use coap_io_do_io() instead. + * + * This function just calls coap_io_do_io(). + * + * Internal function. + * + * @param ctx The CoAP context + * @param now Current time + */ +COAP_STATIC_INLINE COAP_DEPRECATED void +coap_read(coap_context_t *ctx, coap_tick_t now +) { + coap_io_do_io(ctx, now); +} + +/* Old definitions which may be hanging around in old code - be helpful! */ +#define COAP_RUN_NONBLOCK COAP_RUN_NONBLOCK_deprecated_use_COAP_IO_NO_WAIT +#define COAP_RUN_BLOCK COAP_RUN_BLOCK_deprecated_use_COAP_IO_WAIT + +#endif /* COAP_NET_H_ */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/option.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/option.h similarity index 77% rename from tools/sdk/esp32c3/include/coap/libcoap/include/coap2/option.h rename to tools/sdk/esp32/include/coap/libcoap/include/coap3/option.h index 3af9e71e706..c01e8f6688b 100644 --- a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/option.h +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/option.h @@ -3,6 +3,8 @@ * * Copyright (C) 2010-2013 Olaf Bergmann * + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ @@ -15,8 +17,7 @@ #ifndef COAP_OPTION_H_ #define COAP_OPTION_H_ -#include "bits.h" -#include "pdu.h" +typedef uint16_t coap_option_num_t; /** * Use byte-oriented access methods here because sliding a complex struct @@ -89,134 +90,66 @@ size_t coap_opt_size(const coap_opt_t *opt); #error COAP_OPT_FILTER_SHORT + COAP_OPT_FILTER_LONG must be less or equal 16 #endif /* (COAP_OPT_FILTER_SHORT + COAP_OPT_FILTER_LONG > 16) */ -/** The number of elements in coap_opt_filter_t. */ -#define COAP_OPT_FILTER_SIZE \ - (((COAP_OPT_FILTER_SHORT + 1) >> 1) + COAP_OPT_FILTER_LONG) +1 - -/** - * Fixed-size vector we use for option filtering. It is large enough - * to hold COAP_OPT_FILTER_SHORT entries with an option number between - * 0 and 255, and COAP_OPT_FILTER_LONG entries with an option number - * between 256 and 65535. Its internal structure is - * - * @code -struct { +/* + * mask contains a bit vector that indicates which fields in the long_opts[] + * and subsequent short_opts[] are used. The first COAP_OPT_FILTER_LONG bits + * correspond to the long option types that are stored in long_opts[] + * elements. The next COAP_OPT_FILTER_SHORT bits correspond to the short + * option types that are stored in short_opts[]. + */ +typedef struct coap_opt_filter_t { uint16_t mask; uint16_t long_opts[COAP_OPT_FILTER_LONG]; uint8_t short_opts[COAP_OPT_FILTER_SHORT]; -} - * @endcode - * - * The first element contains a bit vector that indicates which fields - * in the remaining array are used. The first COAP_OPT_FILTER_LONG - * bits correspond to the long option types that are stored in the - * elements from index 1 to COAP_OPT_FILTER_LONG. The next - * COAP_OPT_FILTER_SHORT bits correspond to the short option types - * that are stored in the elements from index COAP_OPT_FILTER_LONG + 1 - * to COAP_OPT_FILTER_LONG + COAP_OPT_FILTER_SHORT. The latter - * elements are treated as bytes. - */ -typedef uint16_t coap_opt_filter_t[COAP_OPT_FILTER_SIZE]; +} coap_opt_filter_t; /** Pre-defined filter that includes all options. */ #define COAP_OPT_ALL NULL /** - * Clears filter @p f. + * Clears filter @p filter. * - * @param f The filter to clear. + * @param filter The filter to clear. */ -COAP_STATIC_INLINE void -coap_option_filter_clear(coap_opt_filter_t f) { - memset(f, 0, sizeof(coap_opt_filter_t)); -} +void +coap_option_filter_clear(coap_opt_filter_t *filter); /** - * Sets the corresponding entry for @p type in @p filter. This + * Sets the corresponding entry for @p number in @p filter. This * function returns @c 1 if bit was set or @c 0 on error (i.e. when - * the given type does not fit in the filter). + * the given number does not fit in the filter). * * @param filter The filter object to change. - * @param type The type for which the bit should be set. + * @param number The option number for which the bit should be set. * * @return @c 1 if bit was set, @c 0 otherwise. */ -int coap_option_filter_set(coap_opt_filter_t filter, uint16_t type); +int coap_option_filter_set(coap_opt_filter_t *filter, coap_option_num_t number); /** - * Clears the corresponding entry for @p type in @p filter. This + * Clears the corresponding entry for @p number in @p filter. This * function returns @c 1 if bit was set or @c 0 on error (i.e. when - * the given type does not fit in the filter). + * the given number does not fit in the filter). * * @param filter The filter object to change. - * @param type The type that should be cleared from the filter. + * @param number The option number that should be cleared from the filter. * * @return @c 1 if bit was set, @c 0 otherwise. */ -int coap_option_filter_unset(coap_opt_filter_t filter, uint16_t type); +int coap_option_filter_unset(coap_opt_filter_t *filter, + coap_option_num_t number); /** - * Checks if @p type is contained in @p filter. This function returns + * Checks if @p number is contained in @p filter. This function returns * @c 1 if found, @c 0 if not, or @c -1 on error (i.e. when the given - * type does not fit in the filter). + * number does not fit in the filter). * * @param filter The filter object to search. - * @param type The type to search for. + * @param number The option number to search for. * - * @return @c 1 if @p type was found, @c 0 otherwise, or @c -1 on error. + * @return @c 1 if @p number was found, @c 0 otherwise, or @c -1 on error. */ -int coap_option_filter_get(coap_opt_filter_t filter, uint16_t type); - -/** - * Sets the corresponding bit for @p type in @p filter. This function returns @c - * 1 if bit was set or @c -1 on error (i.e. when the given type does not fit in - * the filter). - * - * @deprecated Use coap_option_filter_set() instead. - * - * @param filter The filter object to change. - * @param type The type for which the bit should be set. - * - * @return @c 1 if bit was set, @c -1 otherwise. - */ -COAP_STATIC_INLINE int -coap_option_setb(coap_opt_filter_t filter, uint16_t type) { - return coap_option_filter_set(filter, type) ? 1 : -1; -} - -/** - * Clears the corresponding bit for @p type in @p filter. This function returns - * @c 1 if bit was cleared or @c -1 on error (i.e. when the given type does not - * fit in the filter). - * - * @deprecated Use coap_option_filter_unset() instead. - * - * @param filter The filter object to change. - * @param type The type for which the bit should be cleared. - * - * @return @c 1 if bit was set, @c -1 otherwise. - */ -COAP_STATIC_INLINE int -coap_option_clrb(coap_opt_filter_t filter, uint16_t type) { - return coap_option_filter_unset(filter, type) ? 1 : -1; -} - -/** - * Gets the corresponding bit for @p type in @p filter. This function returns @c - * 1 if the bit is set @c 0 if not, or @c -1 on error (i.e. when the given type - * does not fit in the filter). - * - * @deprecated Use coap_option_filter_get() instead. - * - * @param filter The filter object to read bit from. - * @param type The type for which the bit should be read. - * - * @return @c 1 if bit was set, @c 0 if not, @c -1 on error. - */ -COAP_STATIC_INLINE int -coap_option_getb(coap_opt_filter_t filter, uint16_t type) { - return coap_option_filter_get(filter, type); -} +int coap_option_filter_get(coap_opt_filter_t *filter, coap_option_num_t number); /** * Iterator to run through PDU options. This object must be @@ -236,7 +169,7 @@ coap_option_getb(coap_opt_filter_t filter, uint16_t type) { */ typedef struct { size_t length; /**< remaining length of PDU */ - uint16_t type; /**< decoded option type */ + coap_option_num_t number; /**< decoded option number */ unsigned int bad:1; /**< iterator object is ok if not set */ unsigned int filtered:1; /**< denotes whether or not filter is used */ coap_opt_t *next_option; /**< pointer to the unparsed next option */ @@ -251,8 +184,8 @@ typedef struct { * * @param pdu The PDU the options of which should be walked through. * @param oi An iterator object that will be initilized. - * @param filter An optional option type filter. - * With @p type != @c COAP_OPT_ALL, coap_option_next() + * @param filter An optional option number filter. + * With @p number != @c COAP_OPT_ALL, coap_option_next() * will return only options matching this bitmask. * Fence-post options @c 14, @c 28, @c 42, ... are always * skipped. @@ -261,18 +194,18 @@ typedef struct { */ coap_opt_iterator_t *coap_option_iterator_init(const coap_pdu_t *pdu, coap_opt_iterator_t *oi, - const coap_opt_filter_t filter); + const coap_opt_filter_t *filter); /** * Updates the iterator @p oi to point to the next option. This function returns * a pointer to that option or @c NULL if no more options exist. The contents of * @p oi will be updated. In particular, @c oi->n specifies the current option's - * ordinal number (counted from @c 1), @c oi->type is the option's type code, - * and @c oi->option points to the beginning of the current option itself. When - * advanced past the last option, @c oi->option will be @c NULL. + * ordinal number (counted from @c 1), @c oi->number is the option's number + * value, and @c oi->option points to the beginning of the current option + * itself. When * advanced past the last option, @c oi->option will be @c NULL. * * Note that options are skipped whose corresponding bits in the filter - * specified with coap_option_iterator_init() are @c 0. Options with type codes + * specified with coap_option_iterator_init() are @c 0. Options with numbers * that do not fit in this filter hence will always be returned. * * @param oi The option iterator to update. @@ -282,20 +215,20 @@ coap_opt_iterator_t *coap_option_iterator_init(const coap_pdu_t *pdu, coap_opt_t *coap_option_next(coap_opt_iterator_t *oi); /** - * Retrieves the first option of type @p type from @p pdu. @p oi must point to a - * coap_opt_iterator_t object that will be initialized by this function to - * filter only options with code @p type. This function returns the first option - * with this type, or @c NULL if not found. + * Retrieves the first option of number @p number from @p pdu. @p oi must + * point to a coap_opt_iterator_t object that will be initialized by this + * function to filter only options with number @p number. This function returns + * the first option with this number, or @c NULL if not found. * * @param pdu The PDU to parse for options. - * @param type The option type code to search for. + * @param number The option number to search for. * @param oi An iterator object to use. * - * @return A pointer to the first option of type @p type, or @c NULL if + * @return A pointer to the first option of number @p number, or @c NULL if * not found. */ -coap_opt_t *coap_check_option(coap_pdu_t *pdu, - uint16_t type, +coap_opt_t *coap_check_option(const coap_pdu_t *pdu, + coap_option_num_t number, coap_opt_iterator_t *oi); /** @@ -349,18 +282,6 @@ size_t coap_opt_encode(coap_opt_t *opt, const uint8_t *val, size_t length); -/** - * Decodes the delta value of the next option. This function returns the number - * of bytes read or @c 0 on error. The caller of this function must ensure that - * it does not read over the boundaries of @p opt (e.g. by calling - * coap_opt_check_delta(). - * - * @param opt The option to examine. - * - * @return The number of bytes read or @c 0 on error. - */ -uint16_t coap_opt_delta(const coap_opt_t *opt); - /** * Returns the length of the given option. @p opt must point to an option jump * or the beginning of the option. This function returns @c 0 when @p opt is not @@ -374,7 +295,7 @@ uint16_t coap_opt_delta(const coap_opt_t *opt); * * @return The option's length or @c 0 when undefined. */ -uint16_t coap_opt_length(const coap_opt_t *opt); +uint32_t coap_opt_length(const coap_opt_t *opt); /** * Returns a pointer to the value of the given option. @p opt must point to an @@ -387,8 +308,6 @@ uint16_t coap_opt_length(const coap_opt_t *opt); */ const uint8_t *coap_opt_value(const coap_opt_t *opt); -/** @} */ - /** * Representation of chained list of CoAP options to install. * @@ -415,6 +334,12 @@ typedef struct coap_optlist_t { /** * Create a new optlist entry. * + * Note: Where possible, the option data needs to be stripped of leading zeros + * (big endian) to reduce the amount of data needed in the PDU, as well as in + * some cases the maximum data size of an opton can be exceeded if not stripped + * and hence be illegal. This is done by using coap_encode_var_safe() or + * coap_encode_var_safe8(). + * * @param number The option number (COAP_OPTION_*) * @param length The option length * @param data The option value data @@ -458,4 +383,57 @@ int coap_insert_optlist(coap_optlist_t **optlist_chain, */ void coap_delete_optlist(coap_optlist_t *optlist_chain); +/** @} */ + +/** + * Sets the corresponding bit for @p type in @p filter. This function returns @c + * 1 if bit was set or @c -1 on error (i.e. when the given type does not fit in + * the filter). + * + * @deprecated Use coap_option_filter_set() instead. + * + * @param filter The filter object to change. + * @param type The type for which the bit should be set. + * + * @return @c 1 if bit was set, @c -1 otherwise. + */ +COAP_STATIC_INLINE COAP_DEPRECATED int +coap_option_setb(coap_opt_filter_t *filter, uint16_t type) { + return coap_option_filter_set(filter, type) ? 1 : -1; +} + +/** + * Clears the corresponding bit for @p type in @p filter. This function returns + * @c 1 if bit was cleared or @c -1 on error (i.e. when the given type does not + * fit in the filter). + * + * @deprecated Use coap_option_filter_unset() instead. + * + * @param filter The filter object to change. + * @param type The type for which the bit should be cleared. + * + * @return @c 1 if bit was set, @c -1 otherwise. + */ +COAP_STATIC_INLINE COAP_DEPRECATED int +coap_option_clrb(coap_opt_filter_t *filter, uint16_t type) { + return coap_option_filter_unset(filter, type) ? 1 : -1; +} + +/** + * Gets the corresponding bit for @p type in @p filter. This function returns @c + * 1 if the bit is set @c 0 if not, or @c -1 on error (i.e. when the given type + * does not fit in the filter). + * + * @deprecated Use coap_option_filter_get() instead. + * + * @param filter The filter object to read bit from. + * @param type The type for which the bit should be read. + * + * @return @c 1 if bit was set, @c 0 if not, @c -1 on error. + */ +COAP_STATIC_INLINE COAP_DEPRECATED int +coap_option_getb(coap_opt_filter_t *filter, uint16_t type) { + return coap_option_filter_get(filter, type); +} + #endif /* COAP_OPTION_H_ */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap3/pdu.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/pdu.h new file mode 100644 index 00000000000..a22869b69ed --- /dev/null +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/pdu.h @@ -0,0 +1,572 @@ +/* + * pdu.h -- CoAP message structure + * + * Copyright (C) 2010-2014 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file pdu.h + * @brief Pre-defined constants that reflect defaults for CoAP + */ + +#ifndef COAP_PDU_H_ +#define COAP_PDU_H_ + +#include "uri.h" +#include "option.h" + +#ifdef WITH_LWIP +#include +#endif + +#include + +/** + * @defgroup pdu PDU + * API functions for PDUs + * @{ + */ + +#define COAP_DEFAULT_PORT 5683 /* CoAP default UDP/TCP port */ +#define COAPS_DEFAULT_PORT 5684 /* CoAP default UDP/TCP port for secure transmission */ +#define COAP_DEFAULT_MAX_AGE 60 /* default maximum object lifetime in seconds */ +#ifndef COAP_DEFAULT_MTU +#define COAP_DEFAULT_MTU 1152 +#endif /* COAP_DEFAULT_MTU */ + +#ifndef COAP_DEFAULT_HOP_LIMIT +#define COAP_DEFAULT_HOP_LIMIT 16 +#endif /* COAP_DEFAULT_HOP_LIMIT */ + +#define COAP_DEFAULT_SCHEME "coap" /* the default scheme for CoAP URIs */ + +/** well-known resources URI */ +#define COAP_DEFAULT_URI_WELLKNOWN ".well-known/core" + +/* CoAP message types */ + +/** + * CoAP PDU message type definitions + */ +typedef enum coap_pdu_type_t { + COAP_MESSAGE_CON, /* 0 confirmable message (requires ACK/RST) */ + COAP_MESSAGE_NON, /* 1 non-confirmable message (one-shot message) */ + COAP_MESSAGE_ACK, /* 2 used to acknowledge confirmable messages */ + COAP_MESSAGE_RST /* 3 indicates error in received messages */ +} coap_pdu_type_t; + +/** + * CoAP PDU Request methods + */ +typedef enum coap_request_t { + COAP_REQUEST_GET = 1, + COAP_REQUEST_POST, /* 2 */ + COAP_REQUEST_PUT, /* 3 */ + COAP_REQUEST_DELETE, /* 4 */ + COAP_REQUEST_FETCH, /* 5 RFC 8132 */ + COAP_REQUEST_PATCH, /* 6 RFC 8132 */ + COAP_REQUEST_IPATCH, /* 7 RFC 8132 */ +} coap_request_t; + +/* + * CoAP option numbers (be sure to update coap_option_check_critical() and + * coap_add_option() when adding options + */ + +/* + * The C, U, and N flags indicate the properties + * Critical, Unsafe, and NoCacheKey, respectively. + * If U is set, then N has no meaning as per + * https://tools.ietf.org/html/rfc7252#section-5.10 + * and is set to a -. + * + * Separately, R is for the options that can be repeated + * + * The least significant byte of the option is set as followed + * as per https://tools.ietf.org/html/rfc7252#section-5.4.6 + * + * 0 1 2 3 4 5 6 7 + * --+---+---+---+---+---+---+---+ + * | NoCacheKey| U | C | + * --+---+---+---+---+---+---+---+ + * + * https://tools.ietf.org/html/rfc8613#section-4 goes on to define E, I and U + * properties Encrypted and Integrity Protected, Integrity Protected Only, and + * Unprotected respectively. Integrity Protected Only is not currently used. + * + * An Option is tagged with CUNREIU with any of the letters replaced with _ if + * not set, or - for N if U is set (see above) for aiding understanding of the + * Option. + */ + +#define COAP_OPTION_IF_MATCH 1 /* C__RE__, opaque, 0-8 B, RFC7252 */ +#define COAP_OPTION_URI_HOST 3 /* CU-___U, String, 1-255 B, RFC7252 */ +#define COAP_OPTION_ETAG 4 /* ___RE__, opaque, 1-8 B, RFC7252 */ +#define COAP_OPTION_IF_NONE_MATCH 5 /* C___E__, empty, 0 B, RFC7252 */ +#define COAP_OPTION_OBSERVE 6 /* _U-_E_U, empty/uint,0/0-3 B, RFC7641 */ +#define COAP_OPTION_URI_PORT 7 /* CU-___U, uint, 0-2 B, RFC7252 */ +#define COAP_OPTION_LOCATION_PATH 8 /* ___RE__, String, 0-255 B, RFC7252 */ +#define COAP_OPTION_OSCORE 9 /* C_____U, *, 0-255 B, RFC8613 */ +#define COAP_OPTION_URI_PATH 11 /* CU-RE__, String, 0-255 B, RFC7252 */ +#define COAP_OPTION_CONTENT_FORMAT 12 /* ____E__, uint, 0-2 B, RFC7252 */ +#define COAP_OPTION_CONTENT_TYPE COAP_OPTION_CONTENT_FORMAT +/* COAP_OPTION_MAXAGE default 60 seconds if not set */ +#define COAP_OPTION_MAXAGE 14 /* _U-_E_U, uint, 0-4 B, RFC7252 */ +#define COAP_OPTION_URI_QUERY 15 /* CU-RE__, String, 1-255 B, RFC7252 */ +#define COAP_OPTION_HOP_LIMIT 16 /* ______U, uint, 1 B, RFC8768 */ +#define COAP_OPTION_ACCEPT 17 /* C___E__, uint, 0-2 B, RFC7252 */ +#define COAP_OPTION_LOCATION_QUERY 20 /* ___RE__, String, 0-255 B, RFC7252 */ +#define COAP_OPTION_BLOCK2 23 /* CU-_E_U, uint, 0-3 B, RFC7959 */ +#define COAP_OPTION_BLOCK1 27 /* CU-_E_U, uint, 0-3 B, RFC7959 */ +#define COAP_OPTION_SIZE2 28 /* __N_E_U, uint, 0-4 B, RFC7959 */ +#define COAP_OPTION_PROXY_URI 35 /* CU-___U, String, 1-1034 B, RFC7252 */ +#define COAP_OPTION_PROXY_SCHEME 39 /* CU-___U, String, 1-255 B, RFC7252 */ +#define COAP_OPTION_SIZE1 60 /* __N_E_U, uint, 0-4 B, RFC7252 */ +#define COAP_OPTION_NORESPONSE 258 /* _U-_E_U, uint, 0-1 B, RFC7967 */ + +#define COAP_MAX_OPT 65535 /**< the highest option number we know */ + +/* CoAP result codes (HTTP-Code / 100 * 40 + HTTP-Code % 100) */ + +/* As of draft-ietf-core-coap-04, response codes are encoded to base + * 32, i.e. the three upper bits determine the response class while + * the remaining five fine-grained information specific to that class. + */ +#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100) + +/* Determines the class of response code C */ +#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF) + +#ifndef SHORT_ERROR_RESPONSE +/** + * Returns a human-readable response phrase for the specified CoAP response @p + * code. This function returns @c NULL if not found. + * + * @param code The response code for which the literal phrase should be + * retrieved. + * + * @return A zero-terminated string describing the error, or @c NULL if not + * found. + */ +const char *coap_response_phrase(unsigned char code); + +#define COAP_ERROR_PHRASE_LENGTH 32 /**< maximum length of error phrase */ + +#else +#define coap_response_phrase(x) ((char *)NULL) + +#define COAP_ERROR_PHRASE_LENGTH 0 /**< maximum length of error phrase */ +#endif /* SHORT_ERROR_RESPONSE */ + +#define COAP_SIGNALING_CODE(N) (((N)/100 << 5) | (N)%100) + +typedef enum coap_pdu_signaling_proto_t { + COAP_SIGNALING_CSM = COAP_SIGNALING_CODE(701), + COAP_SIGNALING_PING = COAP_SIGNALING_CODE(702), + COAP_SIGNALING_PONG = COAP_SIGNALING_CODE(703), + COAP_SIGNALING_RELEASE = COAP_SIGNALING_CODE(704), + COAP_SIGNALING_ABORT = COAP_SIGNALING_CODE(705), +} coap_pdu_signaling_proto_t; + +/* Applies to COAP_SIGNALING_CSM */ +#define COAP_SIGNALING_OPTION_MAX_MESSAGE_SIZE 2 +#define COAP_SIGNALING_OPTION_BLOCK_WISE_TRANSFER 4 +/* Applies to COAP_SIGNALING_PING / COAP_SIGNALING_PONG */ +#define COAP_SIGNALING_OPTION_CUSTODY 2 +/* Applies to COAP_SIGNALING_RELEASE */ +#define COAP_SIGNALING_OPTION_ALTERNATIVE_ADDRESS 2 +#define COAP_SIGNALING_OPTION_HOLD_OFF 4 +/* Applies to COAP_SIGNALING_ABORT */ +#define COAP_SIGNALING_OPTION_BAD_CSM_OPTION 2 + +/* CoAP media type encoding */ + +#define COAP_MEDIATYPE_TEXT_PLAIN 0 /* text/plain (UTF-8) */ +#define COAP_MEDIATYPE_APPLICATION_LINK_FORMAT 40 /* application/link-format */ +#define COAP_MEDIATYPE_APPLICATION_XML 41 /* application/xml */ +#define COAP_MEDIATYPE_APPLICATION_OCTET_STREAM 42 /* application/octet-stream */ +#define COAP_MEDIATYPE_APPLICATION_RDF_XML 43 /* application/rdf+xml */ +#define COAP_MEDIATYPE_APPLICATION_EXI 47 /* application/exi */ +#define COAP_MEDIATYPE_APPLICATION_JSON 50 /* application/json */ +#define COAP_MEDIATYPE_APPLICATION_CBOR 60 /* application/cbor */ +#define COAP_MEDIATYPE_APPLICATION_CWT 61 /* application/cwt, RFC 8392 */ + +/* Content formats from RFC 8152 */ +#define COAP_MEDIATYPE_APPLICATION_COSE_SIGN 98 /* application/cose; cose-type="cose-sign" */ +#define COAP_MEDIATYPE_APPLICATION_COSE_SIGN1 18 /* application/cose; cose-type="cose-sign1" */ +#define COAP_MEDIATYPE_APPLICATION_COSE_ENCRYPT 96 /* application/cose; cose-type="cose-encrypt" */ +#define COAP_MEDIATYPE_APPLICATION_COSE_ENCRYPT0 16 /* application/cose; cose-type="cose-encrypt0" */ +#define COAP_MEDIATYPE_APPLICATION_COSE_MAC 97 /* application/cose; cose-type="cose-mac" */ +#define COAP_MEDIATYPE_APPLICATION_COSE_MAC0 17 /* application/cose; cose-type="cose-mac0" */ + +#define COAP_MEDIATYPE_APPLICATION_COSE_KEY 101 /* application/cose-key */ +#define COAP_MEDIATYPE_APPLICATION_COSE_KEY_SET 102 /* application/cose-key-set */ + +/* Content formats from RFC 8428 */ +#define COAP_MEDIATYPE_APPLICATION_SENML_JSON 110 /* application/senml+json */ +#define COAP_MEDIATYPE_APPLICATION_SENSML_JSON 111 /* application/sensml+json */ +#define COAP_MEDIATYPE_APPLICATION_SENML_CBOR 112 /* application/senml+cbor */ +#define COAP_MEDIATYPE_APPLICATION_SENSML_CBOR 113 /* application/sensml+cbor */ +#define COAP_MEDIATYPE_APPLICATION_SENML_EXI 114 /* application/senml-exi */ +#define COAP_MEDIATYPE_APPLICATION_SENSML_EXI 115 /* application/sensml-exi */ +#define COAP_MEDIATYPE_APPLICATION_SENML_XML 310 /* application/senml+xml */ +#define COAP_MEDIATYPE_APPLICATION_SENSML_XML 311 /* application/sensml+xml */ + +/* Content formats from RFC 8782 */ +#define COAP_MEDIATYPE_APPLICATION_DOTS_CBOR 271 /* application/dots+cbor */ + +/* Note that identifiers for registered media types are in the range 0-65535. We + * use an unallocated type here and hope for the best. */ +#define COAP_MEDIATYPE_ANY 0xff /* any media type */ + +/** + * coap_mid_t is used to store the CoAP Message ID of a CoAP PDU. + * Valid message ids are 0 to 2^16. Negative values are error codes. + */ +typedef int coap_mid_t; + +/** Indicates an invalid message id. */ +#define COAP_INVALID_MID -1 + +/** + * Indicates an invalid message id. + * @deprecated Use COAP_INVALID_MID instead. + */ +#define COAP_INVALID_TID COAP_INVALID_MID + +/** + * @deprecated Use coap_optlist_t instead. + * + * Structures for more convenient handling of options. (To be used with ordered + * coap_list_t.) The option's data will be added to the end of the coap_option + * structure (see macro COAP_OPTION_DATA). + */ +COAP_DEPRECATED typedef struct { + uint16_t key; /* the option key (no delta coding) */ + unsigned int length; +} coap_option; + +#define COAP_OPTION_KEY(option) (option).key +#define COAP_OPTION_LENGTH(option) (option).length +#define COAP_OPTION_DATA(option) ((unsigned char *)&(option) + sizeof(coap_option)) + +#ifdef WITH_LWIP +/** + * Creates a CoAP PDU from an lwIP @p pbuf, whose reference is passed on to this + * function. + * + * The pbuf is checked for being contiguous, and for having only one reference. + * The reference is stored in the PDU and will be freed when the PDU is freed. + * + * (For now, these are fatal errors; in future, a new pbuf might be allocated, + * the data copied and the passed pbuf freed). + * + * This behaves like coap_pdu_init(0, 0, 0, pbuf->tot_len), and afterwards + * copying the contents of the pbuf to the pdu. + * + * @return A pointer to the new PDU object or @c NULL on error. + */ +coap_pdu_t * coap_pdu_from_pbuf(struct pbuf *pbuf); +#endif + +/** +* CoAP protocol types +*/ +typedef enum coap_proto_t { + COAP_PROTO_NONE = 0, + COAP_PROTO_UDP, + COAP_PROTO_DTLS, + COAP_PROTO_TCP, + COAP_PROTO_TLS, +} coap_proto_t; + +/** + * Set of codes available for a PDU. + */ +typedef enum coap_pdu_code_t { + COAP_EMPTY_CODE = 0, + + COAP_REQUEST_CODE_GET = COAP_REQUEST_GET, + COAP_REQUEST_CODE_POST = COAP_REQUEST_POST, + COAP_REQUEST_CODE_PUT = COAP_REQUEST_PUT, + COAP_REQUEST_CODE_DELETE = COAP_REQUEST_DELETE, + COAP_REQUEST_CODE_FETCH = COAP_REQUEST_FETCH, + COAP_REQUEST_CODE_PATCH = COAP_REQUEST_PATCH, + COAP_REQUEST_CODE_IPATCH = COAP_REQUEST_IPATCH, + + COAP_RESPONSE_CODE_OK = COAP_RESPONSE_CODE(200), + COAP_RESPONSE_CODE_CREATED = COAP_RESPONSE_CODE(201), + COAP_RESPONSE_CODE_DELETED = COAP_RESPONSE_CODE(202), + COAP_RESPONSE_CODE_VALID = COAP_RESPONSE_CODE(203), + COAP_RESPONSE_CODE_CHANGED = COAP_RESPONSE_CODE(204), + COAP_RESPONSE_CODE_CONTENT = COAP_RESPONSE_CODE(205), + COAP_RESPONSE_CODE_CONTINUE = COAP_RESPONSE_CODE(231), + COAP_RESPONSE_CODE_BAD_REQUEST = COAP_RESPONSE_CODE(400), + COAP_RESPONSE_CODE_UNAUTHORIZED = COAP_RESPONSE_CODE(401), + COAP_RESPONSE_CODE_BAD_OPTION = COAP_RESPONSE_CODE(402), + COAP_RESPONSE_CODE_FORBIDDEN = COAP_RESPONSE_CODE(403), + COAP_RESPONSE_CODE_NOT_FOUND = COAP_RESPONSE_CODE(404), + COAP_RESPONSE_CODE_NOT_ALLOWED = COAP_RESPONSE_CODE(405), + COAP_RESPONSE_CODE_NOT_ACCEPTABLE = COAP_RESPONSE_CODE(406), + COAP_RESPONSE_CODE_INCOMPLETE = COAP_RESPONSE_CODE(408), + COAP_RESPONSE_CODE_CONFLICT = COAP_RESPONSE_CODE(409), + COAP_RESPONSE_CODE_PRECONDITION_FAILED = COAP_RESPONSE_CODE(412), + COAP_RESPONSE_CODE_REQUEST_TOO_LARGE = COAP_RESPONSE_CODE(413), + COAP_RESPONSE_CODE_UNSUPPORTED_CONTENT_FORMAT = COAP_RESPONSE_CODE(415), + COAP_RESPONSE_CODE_UNPROCESSABLE = COAP_RESPONSE_CODE(422), + COAP_RESPONSE_CODE_TOO_MANY_REQUESTS = COAP_RESPONSE_CODE(429), + COAP_RESPONSE_CODE_INTERNAL_ERROR = COAP_RESPONSE_CODE(500), + COAP_RESPONSE_CODE_NOT_IMPLEMENTED = COAP_RESPONSE_CODE(501), + COAP_RESPONSE_CODE_BAD_GATEWAY = COAP_RESPONSE_CODE(502), + COAP_RESPONSE_CODE_SERVICE_UNAVAILABLE = COAP_RESPONSE_CODE(503), + COAP_RESPONSE_CODE_GATEWAY_TIMEOUT = COAP_RESPONSE_CODE(504), + COAP_RESPONSE_CODE_PROXYING_NOT_SUPPORTED = COAP_RESPONSE_CODE(505), + COAP_RESPONSE_CODE_HOP_LIMIT_REACHED = COAP_RESPONSE_CODE(508), + + COAP_SIGNALING_CODE_CSM = COAP_SIGNALING_CSM, + COAP_SIGNALING_CODE_PING = COAP_SIGNALING_PING, + COAP_SIGNALING_CODE_PONG = COAP_SIGNALING_PONG, + COAP_SIGNALING_CODE_RELEASE = COAP_SIGNALING_RELEASE, + COAP_SIGNALING_CODE_ABORT = COAP_SIGNALING_ABORT +} coap_pdu_code_t; + +/** + * Creates a new CoAP PDU with at least enough storage space for the given + * @p size maximum message size. The function returns a pointer to the + * node coap_pdu_t object on success, or @c NULL on error. The storage allocated + * for the result must be released with coap_delete_pdu() if coap_send() + * is not called. + * + * @param type The type of the PDU (one of COAP_MESSAGE_CON, COAP_MESSAGE_NON, + * COAP_MESSAGE_ACK, COAP_MESSAGE_RST). + * @param code The message code of the PDU. + * @param mid The message id to set or 0 if unknown / not applicable. + * @param size The maximum allowed number of byte for the message. + * @return A pointer to the new PDU object or @c NULL on error. + */ +coap_pdu_t *coap_pdu_init(coap_pdu_type_t type, coap_pdu_code_t code, + coap_mid_t mid, size_t size); + +/** + * Creates a new CoAP PDU. + * + * @param type The type of the PDU (one of COAP_MESSAGE_CON, COAP_MESSAGE_NON, + * COAP_MESSAGE_ACK, COAP_MESSAGE_RST). + * @param code The message code of the PDU. + * @param session The session that will be using this PDU + * + * @return The skeletal PDU or @c NULL if failure. + */ +coap_pdu_t *coap_new_pdu(coap_pdu_type_t type, coap_pdu_code_t code, + coap_session_t *session); + +/** + * Dispose of an CoAP PDU and frees associated storage. + * Not that in general you should not call this function directly. + * When a PDU is sent with coap_send(), coap_delete_pdu() will be called + * automatically for you. + * + * @param pdu The PDU for free off. + */ +void coap_delete_pdu(coap_pdu_t *pdu); + +/** + * Duplicate an existing PDU. Specific options can be ignored and not copied + * across. The PDU data payload is not copied across. + * + * @param old_pdu The PDU to duplicate + * @param session The session that will be using this PDU. + * @param token_length The length of the token to use in this duplicated PDU. + * @param token The token to use in this duplicated PDU. + * @param drop_options A list of options not to copy into the duplicated PDU. + * If @c NULL, then all options are copied across. + * + * @return The duplicated PDU or @c NULL if failure. + */ +coap_pdu_t * +coap_pdu_duplicate(const coap_pdu_t *old_pdu, + coap_session_t *session, + size_t token_length, + const uint8_t *token, + coap_opt_filter_t *drop_options); + +/** + * Adds token of length @p len to @p pdu. + * Adding the token destroys any following contents of the pdu. Hence options + * and data must be added after coap_add_token() has been called. In @p pdu, + * length is set to @p len + @c 4, and max_delta is set to @c 0. This function + * returns @c 0 on error or a value greater than zero on success. + * + * @param pdu The PDU where the token is to be added. + * @param len The length of the new token. + * @param data The token to add. + * + * @return A value greater than zero on success, or @c 0 on error. + */ +int coap_add_token(coap_pdu_t *pdu, + size_t len, + const uint8_t *data); + +/** + * Adds option of given number to pdu that is passed as first + * parameter. + * coap_add_option() destroys the PDU's data, so coap_add_data() must be called + * after all options have been added. As coap_add_token() destroys the options + * following the token, the token must be added before coap_add_option() is + * called. This function returns the number of bytes written or @c 0 on error. + * + * Note: Where possible, the option data needs to be stripped of leading zeros + * (big endian) to reduce the amount of data needed in the PDU, as well as in + * some cases the maximum data size of an opton can be exceeded if not stripped + * and hence be illegal. This is done by using coap_encode_var_safe() or + * coap_encode_var_safe8(). + * + * @param pdu The PDU where the option is to be added. + * @param number The number of the new option. + * @param len The length of the new option. + * @param data The data of the new option. + * + * @return The overall length of the option or @c 0 on failure. + */ +size_t coap_add_option(coap_pdu_t *pdu, + coap_option_num_t number, + size_t len, + const uint8_t *data); + +/** + * Adds given data to the pdu that is passed as first parameter. Note that the + * PDU's data is destroyed by coap_add_option(). coap_add_data() must be called + * only once per PDU, otherwise the result is undefined. + * + * @param pdu The PDU where the data is to be added. + * @param len The length of the data. + * @param data The data to add. + * + * @return @c 1 if success, else @c 0 if failure. + */ +int coap_add_data(coap_pdu_t *pdu, + size_t len, + const uint8_t *data); + +/** + * Adds given data to the pdu that is passed as first parameter but does not + * copy it. Note that the PDU's data is destroyed by coap_add_option(). + * coap_add_data() must be have been called once for this PDU, otherwise the + * result is undefined. + * The actual data must be copied at the returned location. + * + * @param pdu The PDU where the data is to be added. + * @param len The length of the data. + * + * @return Where to copy the data of len to, or @c NULL is error. + */ +uint8_t *coap_add_data_after(coap_pdu_t *pdu, size_t len); + +/** + * Retrieves the length and data pointer of specified PDU. Returns 0 on error or + * 1 if *len and *data have correct values. Note that these values are destroyed + * with the pdu. + * + * @param pdu The specified PDU. + * @param len Returns the length of the current data + * @param data Returns the ptr to the current data + * + * @return @c 1 if len and data are correctly filled in, else + * @c 0 if there is no data. + */ +int coap_get_data(const coap_pdu_t *pdu, + size_t *len, + const uint8_t **data); + +/** + * Retrieves the data from a PDU, with support for large bodies of data that + * spans multiple PDUs. + * + * Note: The data pointed to on return is destroyed when the PDU is destroyed. + * + * @param pdu The specified PDU. + * @param len Returns the length of the current data + * @param data Returns the ptr to the current data + * @param offset Returns the offset of the current data from the start of the + * body comprising of many blocks (RFC7959) + * @param total Returns the total size of the body. + * If offset + length < total, then there is more data to follow. + * + * @return @c 1 if len, data, offset and total are correctly filled in, else + * @c 0 if there is no data. + */ +int coap_get_data_large(const coap_pdu_t *pdu, + size_t *len, + const uint8_t **data, + size_t *offset, + size_t *total); + +/** + * Gets the PDU code associated with @p pdu. + * + * @param pdu The PDU object. + * + * @return The PDU code. + */ +coap_pdu_code_t coap_pdu_get_code(const coap_pdu_t *pdu); + +/** + * Sets the PDU code in the @p pdu. + * + * @param pdu The PDU object. + * @param code The code to set in the PDU. + */ +void coap_pdu_set_code(coap_pdu_t *pdu, coap_pdu_code_t code); + +/** + * Gets the PDU type associated with @p pdu. + * + * @param pdu The PDU object. + * + * @return The PDU type. + */ +coap_pdu_type_t coap_pdu_get_type(const coap_pdu_t *pdu); + +/** + * Sets the PDU type in the @p pdu. + * + * @param pdu The PDU object. + * @param type The type to set for the PDU. + */ +void coap_pdu_set_type(coap_pdu_t *pdu, coap_pdu_type_t type); + +/** + * Gets the token associated with @p pdu. + * + * @param pdu The PDU object. + * + * @return The token information. + */ +coap_bin_const_t coap_pdu_get_token(const coap_pdu_t *pdu); + +/** + * Gets the message id associated with @p pdu. + * + * @param pdu The PDU object. + * + * @return The message id. + */ +coap_mid_t coap_pdu_get_mid(const coap_pdu_t *pdu); + +/** + * Sets the message id in the @p pdu. + * + * @param pdu The PDU object. + * @param mid The message id value to set in the PDU. + * + */ +void coap_pdu_set_mid(coap_pdu_t *pdu, coap_mid_t mid); + +/** @} */ + +#endif /* COAP_PDU_H_ */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/resource.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/resource.h similarity index 55% rename from tools/sdk/esp32s2/include/coap/libcoap/include/coap2/resource.h rename to tools/sdk/esp32/include/coap/libcoap/include/coap3/resource.h index 58018720e4e..2cd9aea48fa 100644 --- a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/resource.h +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/resource.h @@ -1,7 +1,9 @@ /* * resource.h -- generic resource handling * - * Copyright (C) 2010,2011,2014,2015 Olaf Bergmann + * Copyright (C) 2010,2011,2014-2021 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause * * This file is part of the CoAP library libcoap. Please see README for terms * of use. @@ -15,100 +17,62 @@ #ifndef COAP_RESOURCE_H_ #define COAP_RESOURCE_H_ -# include - #ifndef COAP_RESOURCE_CHECK_TIME /** The interval in seconds to check if resources have changed. */ #define COAP_RESOURCE_CHECK_TIME 2 #endif /* COAP_RESOURCE_CHECK_TIME */ -#include "uthash.h" #include "async.h" +#include "block.h" #include "str.h" #include "pdu.h" #include "net.h" #include "subscribe.h" /** - * Definition of message handler function (@sa coap_resource_t). + * @defgroup coap_resource Resource Configuraton + * API functions for setting up resources + * @{ + */ + +/** + * Definition of message handler function */ typedef void (*coap_method_handler_t) - (coap_context_t *, - struct coap_resource_t *, + (coap_resource_t *, coap_session_t *, - coap_pdu_t *, - coap_binary_t * /* token */, - coap_string_t * /* query string */, + const coap_pdu_t * /* request */, + const coap_string_t * /* query string */, coap_pdu_t * /* response */); #define COAP_ATTR_FLAGS_RELEASE_NAME 0x1 #define COAP_ATTR_FLAGS_RELEASE_VALUE 0x2 -typedef struct coap_attr_t { - struct coap_attr_t *next; - coap_str_const_t *name; - coap_str_const_t *value; - int flags; -} coap_attr_t; - /** The URI passed to coap_resource_init() is free'd by coap_delete_resource(). */ #define COAP_RESOURCE_FLAGS_RELEASE_URI 0x1 /** * Notifications will be sent non-confirmable by default. RFC 7641 Section 4.5 * https://tools.ietf.org/html/rfc7641#section-4.5 + * Libcoap will always send every fifth packet as confirmable. */ #define COAP_RESOURCE_FLAGS_NOTIFY_NON 0x0 /** - * Notifications will be sent confirmable by default. RFC 7641 Section 4.5 + * Notifications will be sent confirmable. RFC 7641 Section 4.5 * https://tools.ietf.org/html/rfc7641#section-4.5 */ #define COAP_RESOURCE_FLAGS_NOTIFY_CON 0x2 -typedef struct coap_resource_t { - unsigned int dirty:1; /**< set to 1 if resource has changed */ - unsigned int partiallydirty:1; /**< set to 1 if some subscribers have not yet - * been notified of the last change */ - unsigned int observable:1; /**< can be observed */ - unsigned int cacheable:1; /**< can be cached */ - unsigned int is_unknown:1; /**< resource created for unknown handler */ - - /** - * Used to store handlers for the seven coap methods @c GET, @c POST, @c PUT, - * @c DELETE, @c FETCH, @c PATCH and @c IPATCH. - * coap_dispatch() will pass incoming requests to the handler - * that corresponds to its request method or generate a 4.05 response if no - * handler is available. - */ - coap_method_handler_t handler[7]; - - UT_hash_handle hh; - - coap_attr_t *link_attr; /**< attributes to be included with the link format */ - coap_subscription_t *subscribers; /**< list of observers for this resource */ - - /** - * Request URI Path for this resource. This field will point into static - * or allocated memory which must remain there for the duration of the - * resource. - */ - coap_str_const_t *uri_path; /**< the key used for hash lookup for this resource */ - int flags; - - /** - * The next value for the Observe option. This field must be increased each - * time the resource changes. Only the lower 24 bits are sent. - */ - unsigned int observe; - - /** - * This pointer is under user control. It can be used to store context for - * the coap handler. - */ - void *user_data; - -} coap_resource_t; +/** + * Notifications will always be sent non-confirmable. This is in + * violation of RFC 7641 Section 4.5 + * https://tools.ietf.org/html/rfc7641#section-4.5 + * but required by the DOTS signal channel protocol which needs to operate in + * lossy DDoS attack environments. + * https://tools.ietf.org/html/rfc8782#section-4.4.2.1 + */ +#define COAP_RESOURCE_FLAGS_NOTIFY_NON_ALWAYS 0x4 /** * Creates a new resource object and initializes the link field to the string @@ -173,6 +137,45 @@ coap_resource_t *coap_resource_init(coap_str_const_t *uri_path, */ coap_resource_t *coap_resource_unknown_init(coap_method_handler_t put_handler); +/** + * Creates a new resource object for handling proxy URIs. + * This function returns the new coap_resource_t object. + * + * Note: There can only be one proxy resource handler per context - attaching + * a new one overrides the previous definition. + * + * @param handler The PUT/POST/GET etc. handler that handles all request types. + * @param host_name_count The number of provided host_name_list entries. A + * minimum of 1 must be provided. + * @param host_name_list Array of depth host_name_count names that this proxy + * is known by. + * + * @return A pointer to the new object or @c NULL on error. + */ +coap_resource_t *coap_resource_proxy_uri_init(coap_method_handler_t handler, + size_t host_name_count, const char *host_name_list[]); + +/** + * Returns the resource identified by the unique string @p uri_path. If no + * resource was found, this function returns @c NULL. + * + * @param context The context to look for this resource. + * @param uri_path The unique string uri of the resource. + * + * @return A pointer to the resource or @c NULL if not found. + */ +coap_resource_t *coap_get_resource_from_uri_path(coap_context_t *context, + coap_str_const_t *uri_path); + +/** + * Get the uri_path from a @p resource. + * + * @param resource The CoAP resource to check. + * + * @return The uri_path if it exists or @c NULL otherwise. + */ +coap_str_const_t* coap_resource_get_uri_path(coap_resource_t *resource); + /** * Sets the notification message type of resource @p resource to given * @p mode @@ -181,38 +184,43 @@ coap_resource_t *coap_resource_unknown_init(coap_method_handler_t put_handler); * @param mode Must be one of @c COAP_RESOURCE_FLAGS_NOTIFY_NON * or @c COAP_RESOURCE_FLAGS_NOTIFY_CON. */ -COAP_STATIC_INLINE void -coap_resource_set_mode(coap_resource_t *resource, int mode) { - resource->flags = (resource->flags & - ~(COAP_RESOURCE_FLAGS_NOTIFY_CON|COAP_RESOURCE_FLAGS_NOTIFY_NON)) | - (mode & (COAP_RESOURCE_FLAGS_NOTIFY_CON|COAP_RESOURCE_FLAGS_NOTIFY_NON)); -} +void coap_resource_set_mode(coap_resource_t *resource, int mode); /** * Sets the user_data. The user_data is exclusively used by the library-user - * and can be used as context in the handler functions. + * and can be used as user defined context in the handler functions. * - * @param r Resource to attach the data to - * @param data Data to attach to the user_data field. This pointer is only used for - * storage, the data remains under user control + * @param resource Resource to attach the data to + * @param data Data to attach to the user_data field. This pointer is + * only used for storage, the data remains under user control */ -COAP_STATIC_INLINE void -coap_resource_set_userdata(coap_resource_t *r, void *data) { - r->user_data = data; -} +void coap_resource_set_userdata(coap_resource_t *resource, void *data); /** * Gets the user_data. The user_data is exclusively used by the library-user * and can be used as context in the handler functions. * - * @param r Resource to retrieve the user_darta from + * @param resource Resource to retrieve the user_data from * * @return The user_data pointer */ -COAP_STATIC_INLINE void * -coap_resource_get_userdata(coap_resource_t *r) { - return r->user_data; -} +void *coap_resource_get_userdata(coap_resource_t *resource); + +/** + * Definition of release resource user_data callback function + */ +typedef void (*coap_resource_release_userdata_handler_t)(void *user_data); + +/** + * Defines the context wide callback to use to when the resource is deleted + * to release the data held in the resource's user_data. + * + * @param context The context to associate the release callback with + * @param callback The callback to invoke when the resource is deleted or NULL + * + */ +void coap_resource_release_userdata_handler(coap_context_t *context, + coap_resource_release_userdata_handler_t callback); /** * Registers the given @p resource for @p context. The resource must have been @@ -237,11 +245,16 @@ void coap_add_resource(coap_context_t *context, coap_resource_t *resource); int coap_delete_resource(coap_context_t *context, coap_resource_t *resource); /** - * Deletes all resources from given @p context and frees their storage. + * Registers the specified @p handler as message handler for the request type @p + * method * - * @param context The CoAP context with the resources to be deleted. + * @param resource The resource for which the handler shall be registered. + * @param method The CoAP request method to handle. + * @param handler The handler to register with @p resource. */ -void coap_delete_all_resources(coap_context_t *context); +void coap_register_handler(coap_resource_t *resource, + coap_request_t method, + coap_method_handler_t handler); /** * Registers a new attribute with the given @p resource. As the @@ -291,13 +304,13 @@ coap_attr_t *coap_find_attr(coap_resource_t *resource, coap_str_const_t *name); /** - * Deletes an attribute. - * Note: This is for internal use only, as it is not deleted from its chain. + * Returns @p attribute's value. * - * @param attr Pointer to a previously created attribute. + * @param attribute Pointer to attribute. * + * @return Attribute's value or @c NULL. */ -void coap_delete_attr(coap_attr_t *attr); +coap_str_const_t *coap_attr_get_value(coap_attr_t *attribute); /** * Status word to encode the result of conditional print or copy operations such @@ -341,17 +354,7 @@ coap_print_status_t coap_print_link(const coap_resource_t *resource, size_t *len, size_t *offset); -/** - * Registers the specified @p handler as message handler for the request type @p - * method - * - * @param resource The resource for which the handler shall be registered. - * @param method The CoAP request method to handle. - * @param handler The handler to register with @p resource. - */ -void coap_register_handler(coap_resource_t *resource, - unsigned char method, - coap_method_handler_t handler); +/** @} */ /** * Returns the resource identified by the unique string @p uri_path. If no @@ -365,155 +368,6 @@ void coap_register_handler(coap_resource_t *resource, coap_resource_t *coap_get_resource_from_uri_path(coap_context_t *context, coap_str_const_t *uri_path); -/** - * @addtogroup observe - */ - -/** - * Adds the specified peer as observer for @p resource. The subscription is - * identified by the given @p token. This function returns the registered - * subscription information if the @p observer has been added, or @c NULL on - * error. - * - * @param resource The observed resource. - * @param session The observer's session - * @param token The token that identifies this subscription. - * @param query The query string, if any. subscription will - take ownership of the string. - * @param has_block2 If Option Block2 defined. - * @param block2 Contents of Block2 if Block 2 defined. - * @return A pointer to the added/updated subscription - * information or @c NULL on error. - */ -coap_subscription_t *coap_add_observer(coap_resource_t *resource, - coap_session_t *session, - const coap_binary_t *token, - coap_string_t *query, - int has_block2, - coap_block_t block2); - -/** - * Returns a subscription object for given @p peer. - * - * @param resource The observed resource. - * @param session The observer's session - * @param token The token that identifies this subscription or @c NULL for - * any token. - * @return A valid subscription if exists or @c NULL otherwise. - */ -coap_subscription_t *coap_find_observer(coap_resource_t *resource, - coap_session_t *session, - const coap_binary_t *token); - -/** - * Marks an observer as alive. - * - * @param context The CoAP context to use. - * @param session The observer's session - * @param token The corresponding token that has been used for the - * subscription. - */ -void coap_touch_observer(coap_context_t *context, - coap_session_t *session, - const coap_binary_t *token); - -/** - * Removes any subscription for @p observer from @p resource and releases the - * allocated storage. The result is @c 1 if an observation relationship with @p - * observer and @p token existed, @c 0 otherwise. - * - * @param resource The observed resource. - * @param session The observer's session. - * @param token The token that identifies this subscription or @c NULL for - * any token. - * @return @c 1 if the observer has been deleted, @c 0 otherwise. - */ -int coap_delete_observer(coap_resource_t *resource, - coap_session_t *session, - const coap_binary_t *token); - -/** - * Removes any subscription for @p session and releases the allocated storage. - * - * @param context The CoAP context to use. - * @param session The observer's session. - */ -void coap_delete_observers(coap_context_t *context, coap_session_t *session); - -/** - * Checks for all known resources, if they are dirty and notifies subscribed - * observers. - */ -void coap_check_notify(coap_context_t *context); - -#define RESOURCES_ADD(r, obj) \ - HASH_ADD(hh, (r), uri_path->s[0], (obj)->uri_path->length, (obj)) - -#define RESOURCES_DELETE(r, obj) \ - HASH_DELETE(hh, (r), (obj)) - -#define RESOURCES_ITER(r,tmp) \ - coap_resource_t *tmp, *rtmp; \ - HASH_ITER(hh, (r), tmp, rtmp) - -#define RESOURCES_FIND(r, k, res) { \ - HASH_FIND(hh, (r), (k)->s, (k)->length, (res)); \ - } - -/** @} */ - -coap_print_status_t coap_print_wellknown(coap_context_t *, - unsigned char *, - size_t *, size_t, - coap_opt_t *); - -void -coap_handle_failed_notify(coap_context_t *, - coap_session_t *, - const coap_binary_t *); - -/** - * Set whether a @p resource is observable. If the resource is observable - * and the client has set the COAP_OPTION_OBSERVE in a request packet, then - * whenever the state of the resource changes (a call to - * coap_resource_trigger_observe()), an Observer response will get sent. - * - * @param resource The CoAP resource to use. - * @param mode @c 1 if Observable is to be set, @c 0 otherwise. - * - */ -COAP_STATIC_INLINE void -coap_resource_set_get_observable(coap_resource_t *resource, int mode) { - resource->observable = mode ? 1 : 0; -} - -/** - * Initiate the sending of an Observe packet for all observers of @p resource, - * optionally matching @p query if not NULL - * - * @param resource The CoAP resource to use. - * @param query The Query to match against or NULL - * - * @return @c 1 if the Observe has been triggered, @c 0 otherwise. - */ -int -coap_resource_notify_observers(coap_resource_t *resource, - const coap_string_t *query); - -/** - * Get the UriPath from a @p resource. - * - * @param resource The CoAP resource to check. - * - * @return The UriPath if it exists or @c NULL otherwise. - */ -COAP_STATIC_INLINE coap_str_const_t* -coap_resource_get_uri_path(coap_resource_t *resource) { - if (resource) - return resource->uri_path; - return NULL; -} - /** * @deprecated use coap_resource_notify_observers() instead. */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap3/str.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/str.h new file mode 100644 index 00000000000..dbf53d0c475 --- /dev/null +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/str.h @@ -0,0 +1,204 @@ +/* + * str.h -- strings to be used in the CoAP library + * + * Copyright (C) 2010-2011 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +#ifndef COAP_STR_H_ +#define COAP_STR_H_ + +#include + + +/** + * @defgroup string String handling support + * API functions for handling strings and binary data + * @{ + */ + +/* + * Note: string and binary use equivalent objects. + * string is likely to contain readable textual information, binary will not. + */ + +/** + * CoAP string data definition + */ +typedef struct coap_string_t { + size_t length; /**< length of string */ + uint8_t *s; /**< string data */ +} coap_string_t; + +/** + * CoAP string data definition with const data + */ +typedef struct coap_str_const_t { + size_t length; /**< length of string */ + const uint8_t *s; /**< read-only string data */ +} coap_str_const_t; + +#define COAP_SET_STR(st,l,v) { (st)->length = (l), (st)->s = (v); } + +/** + * CoAP binary data definition + */ +typedef struct coap_binary_t { + size_t length; /**< length of binary data */ + uint8_t *s; /**< binary data */ +} coap_binary_t; + +/** + * CoAP binary data definition with const data + */ +typedef struct coap_bin_const_t { + size_t length; /**< length of binary data */ + const uint8_t *s; /**< read-only binary data */ +} coap_bin_const_t; + +/** + * Returns a new string object with at least size+1 bytes storage allocated. + * It is the responsibility of the caller to fill in all the appropriate + * information. + * The string must be released using coap_delete_string(). + * + * @param size The size to allocate for the string data. + * + * @return A pointer to the new object or @c NULL on error. + */ +coap_string_t *coap_new_string(size_t size); + +/** + * Deletes the given string and releases any memory allocated. + * + * @param string The string to free off. + */ +void coap_delete_string(coap_string_t *string); + +/** + * Returns a new const string object with at least size+1 bytes storage + * allocated, and the provided data copied into the string object. + * The string must be released using coap_delete_str_const(). + * + * @param data The data to put in the new string object. + * @param size The size to allocate for the binary string data. + * + * @return A pointer to the new object or @c NULL on error. + */ +coap_str_const_t *coap_new_str_const(const uint8_t *data, size_t size); + +/** + * Deletes the given const string and releases any memory allocated. + * + * @param string The string to free off. + */ +void coap_delete_str_const(coap_str_const_t *string); + +/** + * Returns a new binary object with at least size bytes storage allocated. + * It is the responsibility of the caller to fill in all the appropriate + * information. + * The coap_binary_t object must be released using coap_delete_binary(). + * + * @param size The size to allocate for the binary data. + * + * @return A pointer to the new object or @c NULL on error. + */ +coap_binary_t *coap_new_binary(size_t size); + +/** + * Deletes the given coap_binary_t object and releases any memory allocated. + * + * @param binary The coap_binary_t object to free off. + */ +void coap_delete_binary(coap_binary_t *binary); + +/** + * Resizes the given coap_binary_t object. + * It is the responsibility of the caller to fill in all the appropriate + * additional information. + * + * Note: If there is an error, @p binary will separately need to be released by + * coap_delete_binary(). + * + * @param binary The coap_binary_t object to resize. + * @param new_size The new size to allocate for the binary data. + * + * @return A pointer to the new object or @c NULL on error. + */ +coap_binary_t *coap_resize_binary(coap_binary_t *binary, size_t new_size); + +/** + * Take the specified byte array (text) and create a coap_bin_const_t * + * Returns a new const binary object with at least size bytes storage + * allocated, and the provided data copied into the binary object. + * The binary data must be released using coap_delete_bin_const(). + * + * @param data The data to put in the new string object. + * @param size The size to allocate for the binary data. + * + * @return A pointer to the new object or @c NULL on error. + */ +coap_bin_const_t *coap_new_bin_const(const uint8_t *data, size_t size); + +/** + * Deletes the given const binary data and releases any memory allocated. + * + * @param binary The binary data to free off. + */ +void coap_delete_bin_const(coap_bin_const_t *binary); + +#ifndef COAP_MAX_STR_CONST_FUNC +#define COAP_MAX_STR_CONST_FUNC 2 +#endif /* COAP_MAX_STR_CONST_FUNC */ + +/** + * Take the specified byte array (text) and create a coap_str_const_t * + * + * Note: the array is 2 deep as there are up to two callings of + * coap_make_str_const in a function call. e.g. coap_add_attr(). + * Caution: If there are local variable assignments, these will cycle around + * the var[COAP_MAX_STR_CONST_FUNC] set. No current examples do this. + * + * @param string The const string to convert to a coap_str_const_t * + * + * @return A pointer to one of two static variables containing the + * coap_str_const_t * result + */ +coap_str_const_t *coap_make_str_const(const char *string); + +/** + * Compares the two strings for equality + * + * @param string1 The first string. + * @param string2 The second string. + * + * @return @c 1 if the strings are equal + * @c 0 otherwise. + */ +#define coap_string_equal(string1,string2) \ + ((string1)->length == (string2)->length && ((string1)->length == 0 || \ + ((string1)->s && (string2)->s && \ + memcmp((string1)->s, (string2)->s, (string1)->length) == 0))) + +/** + * Compares the two binary data for equality + * + * @param binary1 The first binary data. + * @param binary2 The second binary data. + * + * @return @c 1 if the binary data is equal + * @c 0 otherwise. + */ +#define coap_binary_equal(binary1,binary2) \ + ((binary1)->length == (binary2)->length && ((binary1)->length == 0 || \ + ((binary1)->s && (binary2)->s && \ + memcmp((binary1)->s, (binary2)->s, (binary1)->length) == 0))) + +/** @} */ + +#endif /* COAP_STR_H_ */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap3/subscribe.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/subscribe.h new file mode 100644 index 00000000000..c3aabc2db04 --- /dev/null +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/subscribe.h @@ -0,0 +1,68 @@ +/* + * subscribe.h -- subscription handling for CoAP + * see RFC7641 + * + * Copyright (C) 2010-2012,2014-2021 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file subscribe.h + * @brief Defines the application visible subscribe information + */ + +#ifndef COAP_SUBSCRIBE_H_ +#define COAP_SUBSCRIBE_H_ + +/** + * @defgroup observe Resource Observation + * API functions for interfacing with the observe handling (RFC7641) + * @{ + */ + +/** + * The value COAP_OBSERVE_ESTABLISH in a GET/FETCH request option + * COAP_OPTION_OBSERVE indicates a new observe relationship for (sender + * address, token) is requested. + */ +#define COAP_OBSERVE_ESTABLISH 0 + +/** + * The value COAP_OBSERVE_CANCEL in a GET/FETCH request option + * COAP_OPTION_OBSERVE indicates that the observe relationship for (sender + * address, token) must be cancelled. + */ +#define COAP_OBSERVE_CANCEL 1 + +/** + * Set whether a @p resource is observable. If the resource is observable + * and the client has set the COAP_OPTION_OBSERVE in a request packet, then + * whenever the state of the resource changes (a call to + * coap_resource_trigger_observe()), an Observer response will get sent. + * + * @param resource The CoAP resource to use. + * @param mode @c 1 if Observable is to be set, @c 0 otherwise. + * + */ +void coap_resource_set_get_observable(coap_resource_t *resource, int mode); + +/** + * Initiate the sending of an Observe packet for all observers of @p resource, + * optionally matching @p query if not NULL + * + * @param resource The CoAP resource to use. + * @param query The Query to match against or NULL + * + * @return @c 1 if the Observe has been triggered, @c 0 otherwise. + */ +int +coap_resource_notify_observers(coap_resource_t *resource, + const coap_string_t *query); + +/** @} */ + +#endif /* COAP_SUBSCRIBE_H_ */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/uri.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/uri.h similarity index 67% rename from tools/sdk/esp32s2/include/coap/libcoap/include/coap2/uri.h rename to tools/sdk/esp32/include/coap/libcoap/include/coap3/uri.h index 4d1670115eb..8084483b500 100644 --- a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/uri.h +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/uri.h @@ -1,7 +1,9 @@ /* * uri.h -- helper functions for URI treatment * - * Copyright (C) 2010-2011,2016 Olaf Bergmann + * Copyright (C) 2010-2020 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause * * This file is part of the CoAP library libcoap. Please see README for terms * of use. @@ -13,25 +15,27 @@ #include #include "str.h" -struct coap_pdu_t; /** * The scheme specifiers. Secure schemes have an odd numeric value, * others are even. */ -enum coap_uri_scheme_t { - COAP_URI_SCHEME_COAP=0, - COAP_URI_SCHEME_COAPS=1, - COAP_URI_SCHEME_COAP_TCP=2, - COAP_URI_SCHEME_COAPS_TCP=3 -}; +typedef enum coap_uri_scheme_t { + COAP_URI_SCHEME_COAP = 0, + COAP_URI_SCHEME_COAPS, /* 1 */ + COAP_URI_SCHEME_COAP_TCP, /* 2 */ + COAP_URI_SCHEME_COAPS_TCP, /* 3 */ + COAP_URI_SCHEME_HTTP, /* 4 Proxy-Uri only */ + COAP_URI_SCHEME_HTTPS /* 5 Proxy-Uri only */ +} coap_uri_scheme_t; /** This mask can be used to check if a parsed URI scheme is secure. */ #define COAP_URI_SCHEME_SECURE_MASK 0x01 /** * Representation of parsed URI. Components may be filled from a string with - * coap_split_uri() and can be used as input for option-creation functions. + * coap_split_uri() or coap_split_proxy_uri() and can be used as input for + * option-creation functions. */ typedef struct { coap_str_const_t host; /**< host part of the URI */ @@ -79,17 +83,36 @@ coap_uri_t *coap_clone_uri(const coap_uri_t *uri); * Parses a given string into URI components. The identified syntactic * components are stored in the result parameter @p uri. Optional URI * components that are not specified will be set to { 0, 0 }, except for the - * port which is set to @c COAP_DEFAULT_PORT. This function returns @p 0 if - * parsing succeeded, a value less than zero otherwise. + * port which is set to the default port for the protocol. This function + * returns @p 0 if parsing succeeded, a value less than zero otherwise. * * @param str_var The string to split up. * @param len The actual length of @p str_var * @param uri The coap_uri_t object to store the result. + * * @return @c 0 on success, or < 0 on error. * */ int coap_split_uri(const uint8_t *str_var, size_t len, coap_uri_t *uri); +/** + * Parses a given string into URI components. The identified syntactic + * components are stored in the result parameter @p uri. Optional URI + * components that are not specified will be set to { 0, 0 }, except for the + * port which is set to default port for the protocol. This function returns + * @p 0 if parsing succeeded, a value less than zero otherwise. + * Note: This function enforces that the given string is in Proxy-Uri format + * as well as supports different schema such as http. + * + * @param str_var The string to split up. + * @param len The actual length of @p str_var + * @param uri The coap_uri_t object to store the result. + * + * @return @c 0 on success, or < 0 on error. + * + */ +int coap_split_proxy_uri(const uint8_t *str_var, size_t len, coap_uri_t *uri); + /** * Splits the given URI path into segments. Each segment is preceded * by an option pseudo-header with delta-value 0 and the actual length @@ -131,16 +154,22 @@ int coap_split_query(const uint8_t *s, /** * Extract query string from request PDU according to escape rules in 6.5.8. * @param request Request PDU. - * @return Reconstructed and escaped query string part. + * @return Reconstructed and escaped query string part or @c NULL if + * no query was contained in @p request. The coap_string_t + * object returned by this function must be released with + * coap_delete_string. */ -coap_string_t *coap_get_query(const struct coap_pdu_t *request); +coap_string_t *coap_get_query(const coap_pdu_t *request); /** * Extract uri_path string from request PDU * @param request Request PDU. - * @return Reconstructed and escaped uri path string part. + * @return Reconstructed and escaped uri path string part or @c NULL + * if no URI-Path was contained in @p request. The + * coap_string_t object returned by this function must be + * released with coap_delete_string. */ -coap_string_t *coap_get_uri_path(const struct coap_pdu_t *request); +coap_string_t *coap_get_uri_path(const coap_pdu_t *request); /** @} */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap2/uthash.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/uthash.h similarity index 81% rename from tools/sdk/esp32/include/coap/libcoap/include/coap2/uthash.h rename to tools/sdk/esp32/include/coap/libcoap/include/coap3/uthash.h index 156eb8210c1..9a396b6179f 100644 --- a/tools/sdk/esp32/include/coap/libcoap/include/coap2/uthash.h +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/uthash.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2017, Troy D. Hanson http://troydhanson.github.com/uthash/ +Copyright (c) 2003-2021, Troy D. Hanson http://troydhanson.github.io/uthash/ All rights reserved. Redistribution and use in source and binary forms, with or without @@ -24,12 +24,22 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef UTHASH_H #define UTHASH_H -#define UTHASH_VERSION 2.0.2 +#define UTHASH_VERSION 2.3.0 #include /* memcmp, memset, strlen */ #include /* ptrdiff_t */ #include /* exit */ +#if defined(HASH_DEFINE_OWN_STDINT) && HASH_DEFINE_OWN_STDINT +/* This codepath is provided for backward compatibility, but I plan to remove it. */ +#warning "HASH_DEFINE_OWN_STDINT is deprecated; please use HASH_NO_STDINT instead" +typedef unsigned int uint32_t; +typedef unsigned char uint8_t; +#elif defined(HASH_NO_STDINT) && HASH_NO_STDINT +#else +#include /* uint8_t, uint32_t */ +#endif + /* These macros use decltype or the earlier __typeof GNU extension. As decltype is only available in newer compilers (VS2010 or gcc 4.3+ when compiling c++ source) this code uses whatever method is needed @@ -62,26 +72,6 @@ do { } while (0) #endif -/* a number of the hash function use uint32_t which isn't defined on Pre VS2010 */ -#if defined(_WIN32) -#if defined(_MSC_VER) && _MSC_VER >= 1600 -#include -#elif defined(__WATCOMC__) || defined(__MINGW32__) || defined(__CYGWIN__) -#include -#else -typedef unsigned int uint32_t; -typedef unsigned char uint8_t; -#endif -#elif defined(__GNUC__) && !defined(__VXWORKS__) -#include -#else -typedef unsigned int uint32_t; -typedef unsigned char uint8_t; -#endif - -#ifndef uthash_fatal -#define uthash_fatal(msg) exit(-1) /* fatal error (out of memory,etc) */ -#endif #ifndef uthash_malloc #define uthash_malloc(sz) malloc(sz) /* malloc fcn */ #endif @@ -91,13 +81,18 @@ typedef unsigned char uint8_t; #ifndef uthash_bzero #define uthash_bzero(a,n) memset(a,'\0',n) #endif -#ifndef uthash_memcmp -#define uthash_memcmp(a,b,n) memcmp(a,b,n) -#endif #ifndef uthash_strlen #define uthash_strlen(s) strlen(s) #endif +#ifndef HASH_FUNCTION +#define HASH_FUNCTION(keyptr,keylen,hashv) HASH_JEN(keyptr, keylen, hashv) +#endif + +#ifndef HASH_KEYCMP +#define HASH_KEYCMP(a,b,n) memcmp(a,b,n) +#endif + #ifndef uthash_noexpand_fyi #define uthash_noexpand_fyi(tbl) /* can be defined to log noexpand */ #endif @@ -105,6 +100,32 @@ typedef unsigned char uint8_t; #define uthash_expand_fyi(tbl) /* can be defined to log expands */ #endif +#ifndef HASH_NONFATAL_OOM +#define HASH_NONFATAL_OOM 0 +#endif + +#if HASH_NONFATAL_OOM +/* malloc failures can be recovered from */ + +#ifndef uthash_nonfatal_oom +#define uthash_nonfatal_oom(obj) do {} while (0) /* non-fatal OOM error */ +#endif + +#define HASH_RECORD_OOM(oomed) do { (oomed) = 1; } while (0) +#define IF_HASH_NONFATAL_OOM(x) x + +#else +/* malloc failures result in lost memory, hash tables are unusable */ + +#ifndef uthash_fatal +#define uthash_fatal(msg) exit(-1) /* fatal OOM error */ +#endif + +#define HASH_RECORD_OOM(oomed) uthash_fatal("out of memory") +#define IF_HASH_NONFATAL_OOM(x) + +#endif + /* initial number of buckets */ #define HASH_INITIAL_NUM_BUCKETS 32U /* initial number of buckets */ #define HASH_INITIAL_NUM_BUCKETS_LOG2 5U /* lg2 of initial number of buckets */ @@ -113,11 +134,21 @@ typedef unsigned char uint8_t; /* calculate the element whose hash handle address is hhp */ #define ELMT_FROM_HH(tbl,hhp) ((void*)(((char*)(hhp)) - ((tbl)->hho))) /* calculate the hash handle from element address elp */ -#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle *)(((char*)(elp)) + ((tbl)->hho))) +#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle*)(void*)(((char*)(elp)) + ((tbl)->hho))) + +#define HASH_ROLLBACK_BKT(hh, head, itemptrhh) \ +do { \ + struct UT_hash_handle *_hd_hh_item = (itemptrhh); \ + unsigned _hd_bkt; \ + HASH_TO_BKT(_hd_hh_item->hashv, (head)->hh.tbl->num_buckets, _hd_bkt); \ + (head)->hh.tbl->buckets[_hd_bkt].count++; \ + _hd_hh_item->hh_next = NULL; \ + _hd_hh_item->hh_prev = NULL; \ +} while (0) #define HASH_VALUE(keyptr,keylen,hashv) \ do { \ - HASH_FCN(keyptr, keylen, hashv); \ + HASH_FUNCTION(keyptr, keylen, hashv); \ } while (0) #define HASH_FIND_BYHASHVALUE(hh,head,keyptr,keylen,hashval,out) \ @@ -134,23 +165,27 @@ do { #define HASH_FIND(hh,head,keyptr,keylen,out) \ do { \ - unsigned _hf_hashv; \ - HASH_VALUE(keyptr, keylen, _hf_hashv); \ - HASH_FIND_BYHASHVALUE(hh, head, keyptr, keylen, _hf_hashv, out); \ + (out) = NULL; \ + if (head) { \ + unsigned _hf_hashv; \ + HASH_VALUE(keyptr, keylen, _hf_hashv); \ + HASH_FIND_BYHASHVALUE(hh, head, keyptr, keylen, _hf_hashv, out); \ + } \ } while (0) #ifdef HASH_BLOOM #define HASH_BLOOM_BITLEN (1UL << HASH_BLOOM) #define HASH_BLOOM_BYTELEN (HASH_BLOOM_BITLEN/8UL) + (((HASH_BLOOM_BITLEN%8UL)!=0UL) ? 1UL : 0UL) -#define HASH_BLOOM_MAKE(tbl) \ +#define HASH_BLOOM_MAKE(tbl,oomed) \ do { \ (tbl)->bloom_nbits = HASH_BLOOM; \ (tbl)->bloom_bv = (uint8_t*)uthash_malloc(HASH_BLOOM_BYTELEN); \ if (!(tbl)->bloom_bv) { \ - uthash_fatal("out of memory"); \ + HASH_RECORD_OOM(oomed); \ + } else { \ + uthash_bzero((tbl)->bloom_bv, HASH_BLOOM_BYTELEN); \ + (tbl)->bloom_sig = HASH_BLOOM_SIGNATURE; \ } \ - uthash_bzero((tbl)->bloom_bv, HASH_BLOOM_BYTELEN); \ - (tbl)->bloom_sig = HASH_BLOOM_SIGNATURE; \ } while (0) #define HASH_BLOOM_FREE(tbl) \ @@ -162,39 +197,49 @@ do { #define HASH_BLOOM_BITTEST(bv,idx) (bv[(idx)/8U] & (1U << ((idx)%8U))) #define HASH_BLOOM_ADD(tbl,hashv) \ - HASH_BLOOM_BITSET((tbl)->bloom_bv, (hashv & (uint32_t)((1UL << (tbl)->bloom_nbits) - 1U))) + HASH_BLOOM_BITSET((tbl)->bloom_bv, ((hashv) & (uint32_t)((1UL << (tbl)->bloom_nbits) - 1U))) #define HASH_BLOOM_TEST(tbl,hashv) \ - HASH_BLOOM_BITTEST((tbl)->bloom_bv, (hashv & (uint32_t)((1UL << (tbl)->bloom_nbits) - 1U))) + HASH_BLOOM_BITTEST((tbl)->bloom_bv, ((hashv) & (uint32_t)((1UL << (tbl)->bloom_nbits) - 1U))) #else -#define HASH_BLOOM_MAKE(tbl) +#define HASH_BLOOM_MAKE(tbl,oomed) #define HASH_BLOOM_FREE(tbl) #define HASH_BLOOM_ADD(tbl,hashv) #define HASH_BLOOM_TEST(tbl,hashv) (1) #define HASH_BLOOM_BYTELEN 0U #endif -#define HASH_MAKE_TABLE(hh,head) \ +#define HASH_MAKE_TABLE(hh,head,oomed) \ do { \ (head)->hh.tbl = (UT_hash_table*)uthash_malloc(sizeof(UT_hash_table)); \ if (!(head)->hh.tbl) { \ - uthash_fatal("out of memory"); \ - } \ - uthash_bzero((head)->hh.tbl, sizeof(UT_hash_table)); \ - (head)->hh.tbl->tail = &((head)->hh); \ - (head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \ - (head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \ - (head)->hh.tbl->hho = (char*)(&(head)->hh) - (char*)(head); \ - (head)->hh.tbl->buckets = (UT_hash_bucket*)uthash_malloc( \ - HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \ - if (!(head)->hh.tbl->buckets) { \ - uthash_fatal("out of memory"); \ + HASH_RECORD_OOM(oomed); \ + } else { \ + uthash_bzero((head)->hh.tbl, sizeof(UT_hash_table)); \ + (head)->hh.tbl->tail = &((head)->hh); \ + (head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \ + (head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \ + (head)->hh.tbl->hho = (char*)(&(head)->hh) - (char*)(head); \ + (head)->hh.tbl->buckets = (UT_hash_bucket*)uthash_malloc( \ + HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \ + (head)->hh.tbl->signature = HASH_SIGNATURE; \ + if (!(head)->hh.tbl->buckets) { \ + HASH_RECORD_OOM(oomed); \ + uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \ + } else { \ + uthash_bzero((head)->hh.tbl->buckets, \ + HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \ + HASH_BLOOM_MAKE((head)->hh.tbl, oomed); \ + IF_HASH_NONFATAL_OOM( \ + if (oomed) { \ + uthash_free((head)->hh.tbl->buckets, \ + HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket)); \ + uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \ + } \ + ) \ + } \ } \ - uthash_bzero((head)->hh.tbl->buckets, \ - HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \ - HASH_BLOOM_MAKE((head)->hh.tbl); \ - (head)->hh.tbl->signature = HASH_SIGNATURE; \ } while (0) #define HASH_REPLACE_BYHASHVALUE_INORDER(hh,head,fieldname,keylen_in,hashval,add,replaced,cmpfcn) \ @@ -264,17 +309,58 @@ do { } while (0) #endif -#define HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh,head,keyptr,keylen_in,hashval,add,cmpfcn) \ +#if HASH_NONFATAL_OOM + +#define HASH_ADD_TO_TABLE(hh,head,keyptr,keylen_in,hashval,add,oomed) \ +do { \ + if (!(oomed)) { \ + unsigned _ha_bkt; \ + (head)->hh.tbl->num_items++; \ + HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt); \ + HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], hh, &(add)->hh, oomed); \ + if (oomed) { \ + HASH_ROLLBACK_BKT(hh, head, &(add)->hh); \ + HASH_DELETE_HH(hh, head, &(add)->hh); \ + (add)->hh.tbl = NULL; \ + uthash_nonfatal_oom(add); \ + } else { \ + HASH_BLOOM_ADD((head)->hh.tbl, hashval); \ + HASH_EMIT_KEY(hh, head, keyptr, keylen_in); \ + } \ + } else { \ + (add)->hh.tbl = NULL; \ + uthash_nonfatal_oom(add); \ + } \ +} while (0) + +#else + +#define HASH_ADD_TO_TABLE(hh,head,keyptr,keylen_in,hashval,add,oomed) \ do { \ unsigned _ha_bkt; \ + (head)->hh.tbl->num_items++; \ + HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt); \ + HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], hh, &(add)->hh, oomed); \ + HASH_BLOOM_ADD((head)->hh.tbl, hashval); \ + HASH_EMIT_KEY(hh, head, keyptr, keylen_in); \ +} while (0) + +#endif + + +#define HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh,head,keyptr,keylen_in,hashval,add,cmpfcn) \ +do { \ + IF_HASH_NONFATAL_OOM( int _ha_oomed = 0; ) \ (add)->hh.hashv = (hashval); \ (add)->hh.key = (char*) (keyptr); \ (add)->hh.keylen = (unsigned) (keylen_in); \ if (!(head)) { \ (add)->hh.next = NULL; \ (add)->hh.prev = NULL; \ - (head) = (add); \ - HASH_MAKE_TABLE(hh, head); \ + HASH_MAKE_TABLE(hh, add, _ha_oomed); \ + IF_HASH_NONFATAL_OOM( if (!_ha_oomed) { ) \ + (head) = (add); \ + IF_HASH_NONFATAL_OOM( } ) \ } else { \ void *_hs_iter = (head); \ (add)->hh.tbl = (head)->hh.tbl; \ @@ -291,11 +377,7 @@ do { HASH_APPEND_LIST(hh, head, add); \ } \ } \ - (head)->hh.tbl->num_items++; \ - HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt); \ - HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], &(add)->hh); \ - HASH_BLOOM_ADD((head)->hh.tbl, hashval); \ - HASH_EMIT_KEY(hh, head, keyptr, keylen_in); \ + HASH_ADD_TO_TABLE(hh, head, keyptr, keylen_in, hashval, add, _ha_oomed); \ HASH_FSCK(hh, head, "HASH_ADD_KEYPTR_BYHASHVALUE_INORDER"); \ } while (0) @@ -314,24 +396,22 @@ do { #define HASH_ADD_KEYPTR_BYHASHVALUE(hh,head,keyptr,keylen_in,hashval,add) \ do { \ - unsigned _ha_bkt; \ + IF_HASH_NONFATAL_OOM( int _ha_oomed = 0; ) \ (add)->hh.hashv = (hashval); \ - (add)->hh.key = (const void *) (keyptr); \ + (add)->hh.key = (const void*) (keyptr); \ (add)->hh.keylen = (unsigned) (keylen_in); \ if (!(head)) { \ (add)->hh.next = NULL; \ (add)->hh.prev = NULL; \ - (head) = (add); \ - HASH_MAKE_TABLE(hh, head); \ + HASH_MAKE_TABLE(hh, add, _ha_oomed); \ + IF_HASH_NONFATAL_OOM( if (!_ha_oomed) { ) \ + (head) = (add); \ + IF_HASH_NONFATAL_OOM( } ) \ } else { \ (add)->hh.tbl = (head)->hh.tbl; \ HASH_APPEND_LIST(hh, head, add); \ } \ - (head)->hh.tbl->num_items++; \ - HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt); \ - HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], &(add)->hh); \ - HASH_BLOOM_ADD((head)->hh.tbl, hashval); \ - HASH_EMIT_KEY(hh, head, keyptr, keylen_in); \ + HASH_ADD_TO_TABLE(hh, head, keyptr, keylen_in, hashval, add, _ha_oomed); \ HASH_FSCK(hh, head, "HASH_ADD_KEYPTR_BYHASHVALUE"); \ } while (0) @@ -394,17 +474,25 @@ do { HASH_DEL_IN_BKT((head)->hh.tbl->buckets[_hd_bkt], _hd_hh_del); \ (head)->hh.tbl->num_items--; \ } \ - HASH_FSCK(hh, head, "HASH_DELETE"); \ + HASH_FSCK(hh, head, "HASH_DELETE_HH"); \ } while (0) - /* convenience forms of HASH_FIND/HASH_ADD/HASH_DEL */ #define HASH_FIND_STR(head,findstr,out) \ - HASH_FIND(hh,head,findstr,(unsigned)uthash_strlen(findstr),out) +do { \ + unsigned _uthash_hfstr_keylen = (unsigned)uthash_strlen(findstr); \ + HASH_FIND(hh, head, findstr, _uthash_hfstr_keylen, out); \ +} while (0) #define HASH_ADD_STR(head,strfield,add) \ - HASH_ADD(hh,head,strfield[0],(unsigned)uthash_strlen(add->strfield),add) +do { \ + unsigned _uthash_hastr_keylen = (unsigned)uthash_strlen((add)->strfield); \ + HASH_ADD(hh, head, strfield[0], _uthash_hastr_keylen, add); \ +} while (0) #define HASH_REPLACE_STR(head,strfield,add,replaced) \ - HASH_REPLACE(hh,head,strfield[0],(unsigned)uthash_strlen(add->strfield),add,replaced) +do { \ + unsigned _uthash_hrstr_keylen = (unsigned)uthash_strlen((add)->strfield); \ + HASH_REPLACE(hh, head, strfield[0], _uthash_hrstr_keylen, add, replaced); \ +} while (0) #define HASH_FIND_INT(head,findint,out) \ HASH_FIND(hh,head,findint,sizeof(int),out) #define HASH_ADD_INT(head,intfield,add) \ @@ -424,7 +512,8 @@ do { * This is for uthash developer only; it compiles away if HASH_DEBUG isn't defined. */ #ifdef HASH_DEBUG -#define HASH_OOPS(...) do { fprintf(stderr,__VA_ARGS__); exit(-1); } while (0) +#include /* fprintf, stderr */ +#define HASH_OOPS(...) do { fprintf(stderr, __VA_ARGS__); exit(-1); } while (0) #define HASH_FSCK(hh,head,where) \ do { \ struct UT_hash_handle *_thh; \ @@ -491,13 +580,6 @@ do { #define HASH_EMIT_KEY(hh,head,keyptr,fieldlen) #endif -/* default to Jenkin's hash unless overridden e.g. DHASH_FUNCTION=HASH_SAX */ -#ifdef HASH_FUNCTION -#define HASH_FCN HASH_FUNCTION -#else -#define HASH_FCN HASH_JEN -#endif - /* The Bernstein hash function, used in Perl prior to v5.6. Note (x<<5+x)=x*33. */ #define HASH_BER(key,keylen,hashv) \ do { \ @@ -596,8 +678,8 @@ do { case 4: _hj_i += ( (unsigned)_hj_key[3] << 24 ); /* FALLTHROUGH */ \ case 3: _hj_i += ( (unsigned)_hj_key[2] << 16 ); /* FALLTHROUGH */ \ case 2: _hj_i += ( (unsigned)_hj_key[1] << 8 ); /* FALLTHROUGH */ \ - case 1: _hj_i += _hj_key[0]; \ - default: ; /* does not happen */ \ + case 1: _hj_i += _hj_key[0]; /* FALLTHROUGH */ \ + default: ; \ } \ HASH_JEN_MIX(_hj_i, _hj_j, hashv); \ } while (0) @@ -645,6 +727,8 @@ do { case 1: hashv += *_sfh_key; \ hashv ^= hashv << 10; \ hashv += hashv >> 1; \ + break; \ + default: ; \ } \ \ /* Force "avalanching" of final 127 bits */ \ @@ -656,87 +740,6 @@ do { hashv += hashv >> 6; \ } while (0) -#ifdef HASH_USING_NO_STRICT_ALIASING -/* The MurmurHash exploits some CPU's (x86,x86_64) tolerance for unaligned reads. - * For other types of CPU's (e.g. Sparc) an unaligned read causes a bus error. - * MurmurHash uses the faster approach only on CPU's where we know it's safe. - * - * Note the preprocessor built-in defines can be emitted using: - * - * gcc -m64 -dM -E - < /dev/null (on gcc) - * cc -## a.c (where a.c is a simple test file) (Sun Studio) - */ -#if (defined(__i386__) || defined(__x86_64__) || defined(_M_IX86)) -#define MUR_GETBLOCK(p,i) p[i] -#else /* non intel */ -#define MUR_PLUS0_ALIGNED(p) (((unsigned long)p & 3UL) == 0UL) -#define MUR_PLUS1_ALIGNED(p) (((unsigned long)p & 3UL) == 1UL) -#define MUR_PLUS2_ALIGNED(p) (((unsigned long)p & 3UL) == 2UL) -#define MUR_PLUS3_ALIGNED(p) (((unsigned long)p & 3UL) == 3UL) -#define WP(p) ((uint32_t*)((unsigned long)(p) & ~3UL)) -#if (defined(__BIG_ENDIAN__) || defined(SPARC) || defined(__ppc__) || defined(__ppc64__)) -#define MUR_THREE_ONE(p) ((((*WP(p))&0x00ffffff) << 8) | (((*(WP(p)+1))&0xff000000) >> 24)) -#define MUR_TWO_TWO(p) ((((*WP(p))&0x0000ffff) <<16) | (((*(WP(p)+1))&0xffff0000) >> 16)) -#define MUR_ONE_THREE(p) ((((*WP(p))&0x000000ff) <<24) | (((*(WP(p)+1))&0xffffff00) >> 8)) -#else /* assume little endian non-intel */ -#define MUR_THREE_ONE(p) ((((*WP(p))&0xffffff00) >> 8) | (((*(WP(p)+1))&0x000000ff) << 24)) -#define MUR_TWO_TWO(p) ((((*WP(p))&0xffff0000) >>16) | (((*(WP(p)+1))&0x0000ffff) << 16)) -#define MUR_ONE_THREE(p) ((((*WP(p))&0xff000000) >>24) | (((*(WP(p)+1))&0x00ffffff) << 8)) -#endif -#define MUR_GETBLOCK(p,i) (MUR_PLUS0_ALIGNED(p) ? ((p)[i]) : \ - (MUR_PLUS1_ALIGNED(p) ? MUR_THREE_ONE(p) : \ - (MUR_PLUS2_ALIGNED(p) ? MUR_TWO_TWO(p) : \ - MUR_ONE_THREE(p)))) -#endif -#define MUR_ROTL32(x,r) (((x) << (r)) | ((x) >> (32 - (r)))) -#define MUR_FMIX(_h) \ -do { \ - _h ^= _h >> 16; \ - _h *= 0x85ebca6bu; \ - _h ^= _h >> 13; \ - _h *= 0xc2b2ae35u; \ - _h ^= _h >> 16; \ -} while (0) - -#define HASH_MUR(key,keylen,hashv) \ -do { \ - const uint8_t *_mur_data = (const uint8_t*)(key); \ - const int _mur_nblocks = (int)(keylen) / 4; \ - uint32_t _mur_h1 = 0xf88D5353u; \ - uint32_t _mur_c1 = 0xcc9e2d51u; \ - uint32_t _mur_c2 = 0x1b873593u; \ - uint32_t _mur_k1 = 0; \ - const uint8_t *_mur_tail; \ - const uint32_t *_mur_blocks = (const uint32_t*)(_mur_data+(_mur_nblocks*4)); \ - int _mur_i; \ - for (_mur_i = -_mur_nblocks; _mur_i != 0; _mur_i++) { \ - _mur_k1 = MUR_GETBLOCK(_mur_blocks,_mur_i); \ - _mur_k1 *= _mur_c1; \ - _mur_k1 = MUR_ROTL32(_mur_k1,15); \ - _mur_k1 *= _mur_c2; \ - \ - _mur_h1 ^= _mur_k1; \ - _mur_h1 = MUR_ROTL32(_mur_h1,13); \ - _mur_h1 = (_mur_h1*5U) + 0xe6546b64u; \ - } \ - _mur_tail = (const uint8_t*)(_mur_data + (_mur_nblocks*4)); \ - _mur_k1=0; \ - switch ((keylen) & 3U) { \ - case 0: break; \ - case 3: _mur_k1 ^= (uint32_t)_mur_tail[2] << 16; /* FALLTHROUGH */ \ - case 2: _mur_k1 ^= (uint32_t)_mur_tail[1] << 8; /* FALLTHROUGH */ \ - case 1: _mur_k1 ^= (uint32_t)_mur_tail[0]; \ - _mur_k1 *= _mur_c1; \ - _mur_k1 = MUR_ROTL32(_mur_k1,15); \ - _mur_k1 *= _mur_c2; \ - _mur_h1 ^= _mur_k1; \ - } \ - _mur_h1 ^= (uint32_t)(keylen); \ - MUR_FMIX(_mur_h1); \ - hashv = _mur_h1; \ -} while (0) -#endif /* HASH_USING_NO_STRICT_ALIASING */ - /* iterate over items in a known bucket to find desired item */ #define HASH_FIND_IN_BKT(tbl,hh,head,keyptr,keylen_in,hashval,out) \ do { \ @@ -747,7 +750,7 @@ do { } \ while ((out) != NULL) { \ if ((out)->hh.hashv == (hashval) && (out)->hh.keylen == (keylen_in)) { \ - if (uthash_memcmp((out)->hh.key, keyptr, keylen_in) == 0) { \ + if (HASH_KEYCMP((out)->hh.key, keyptr, keylen_in) == 0) { \ break; \ } \ } \ @@ -760,7 +763,7 @@ do { } while (0) /* add an item to a bucket */ -#define HASH_ADD_TO_BKT(head,addhh) \ +#define HASH_ADD_TO_BKT(head,hh,addhh,oomed) \ do { \ UT_hash_bucket *_ha_head = &(head); \ _ha_head->count++; \ @@ -772,7 +775,12 @@ do { _ha_head->hh_head = (addhh); \ if ((_ha_head->count >= ((_ha_head->expand_mult + 1U) * HASH_BKT_CAPACITY_THRESH)) \ && !(addhh)->tbl->noexpand) { \ - HASH_EXPAND_BUCKETS((addhh)->tbl); \ + HASH_EXPAND_BUCKETS(addhh,(addhh)->tbl, oomed); \ + IF_HASH_NONFATAL_OOM( \ + if (oomed) { \ + HASH_DEL_IN_BKT(head,addhh); \ + } \ + ) \ } \ } while (0) @@ -821,53 +829,56 @@ do { * ceil(n/b) = (n>>lb) + ( (n & (b-1)) ? 1:0) * */ -#define HASH_EXPAND_BUCKETS(tbl) \ +#define HASH_EXPAND_BUCKETS(hh,tbl,oomed) \ do { \ unsigned _he_bkt; \ unsigned _he_bkt_i; \ struct UT_hash_handle *_he_thh, *_he_hh_nxt; \ UT_hash_bucket *_he_new_buckets, *_he_newbkt; \ _he_new_buckets = (UT_hash_bucket*)uthash_malloc( \ - 2UL * (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \ + sizeof(struct UT_hash_bucket) * (tbl)->num_buckets * 2U); \ if (!_he_new_buckets) { \ - uthash_fatal("out of memory"); \ - } \ - uthash_bzero(_he_new_buckets, \ - 2UL * (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \ - (tbl)->ideal_chain_maxlen = \ - ((tbl)->num_items >> ((tbl)->log2_num_buckets+1U)) + \ - ((((tbl)->num_items & (((tbl)->num_buckets*2U)-1U)) != 0U) ? 1U : 0U); \ - (tbl)->nonideal_items = 0; \ - for (_he_bkt_i = 0; _he_bkt_i < (tbl)->num_buckets; _he_bkt_i++) { \ - _he_thh = (tbl)->buckets[ _he_bkt_i ].hh_head; \ - while (_he_thh != NULL) { \ - _he_hh_nxt = _he_thh->hh_next; \ - HASH_TO_BKT(_he_thh->hashv, (tbl)->num_buckets * 2U, _he_bkt); \ - _he_newbkt = &(_he_new_buckets[_he_bkt]); \ - if (++(_he_newbkt->count) > (tbl)->ideal_chain_maxlen) { \ - (tbl)->nonideal_items++; \ - _he_newbkt->expand_mult = _he_newbkt->count / (tbl)->ideal_chain_maxlen; \ - } \ - _he_thh->hh_prev = NULL; \ - _he_thh->hh_next = _he_newbkt->hh_head; \ - if (_he_newbkt->hh_head != NULL) { \ - _he_newbkt->hh_head->hh_prev = _he_thh; \ + HASH_RECORD_OOM(oomed); \ + } else { \ + uthash_bzero(_he_new_buckets, \ + sizeof(struct UT_hash_bucket) * (tbl)->num_buckets * 2U); \ + (tbl)->ideal_chain_maxlen = \ + ((tbl)->num_items >> ((tbl)->log2_num_buckets+1U)) + \ + ((((tbl)->num_items & (((tbl)->num_buckets*2U)-1U)) != 0U) ? 1U : 0U); \ + (tbl)->nonideal_items = 0; \ + for (_he_bkt_i = 0; _he_bkt_i < (tbl)->num_buckets; _he_bkt_i++) { \ + _he_thh = (tbl)->buckets[ _he_bkt_i ].hh_head; \ + while (_he_thh != NULL) { \ + _he_hh_nxt = _he_thh->hh_next; \ + HASH_TO_BKT(_he_thh->hashv, (tbl)->num_buckets * 2U, _he_bkt); \ + _he_newbkt = &(_he_new_buckets[_he_bkt]); \ + if (++(_he_newbkt->count) > (tbl)->ideal_chain_maxlen) { \ + (tbl)->nonideal_items++; \ + if (_he_newbkt->count > _he_newbkt->expand_mult * (tbl)->ideal_chain_maxlen) { \ + _he_newbkt->expand_mult++; \ + } \ + } \ + _he_thh->hh_prev = NULL; \ + _he_thh->hh_next = _he_newbkt->hh_head; \ + if (_he_newbkt->hh_head != NULL) { \ + _he_newbkt->hh_head->hh_prev = _he_thh; \ + } \ + _he_newbkt->hh_head = _he_thh; \ + _he_thh = _he_hh_nxt; \ } \ - _he_newbkt->hh_head = _he_thh; \ - _he_thh = _he_hh_nxt; \ } \ + uthash_free((tbl)->buckets, (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \ + (tbl)->num_buckets *= 2U; \ + (tbl)->log2_num_buckets++; \ + (tbl)->buckets = _he_new_buckets; \ + (tbl)->ineff_expands = ((tbl)->nonideal_items > ((tbl)->num_items >> 1)) ? \ + ((tbl)->ineff_expands+1U) : 0U; \ + if ((tbl)->ineff_expands > 1U) { \ + (tbl)->noexpand = 1; \ + uthash_noexpand_fyi(tbl); \ + } \ + uthash_expand_fyi(tbl); \ } \ - uthash_free((tbl)->buckets, (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \ - (tbl)->num_buckets *= 2U; \ - (tbl)->log2_num_buckets++; \ - (tbl)->buckets = _he_new_buckets; \ - (tbl)->ineff_expands = ((tbl)->nonideal_items > ((tbl)->num_items >> 1)) ? \ - ((tbl)->ineff_expands+1U) : 0U; \ - if ((tbl)->ineff_expands > 1U) { \ - (tbl)->noexpand = 1; \ - uthash_noexpand_fyi(tbl); \ - } \ - uthash_expand_fyi(tbl); \ } while (0) @@ -977,7 +988,8 @@ do { _src_hh = _src_hh->hh_next) { \ _elt = ELMT_FROM_HH((src)->hh_src.tbl, _src_hh); \ if (cond(_elt)) { \ - _dst_hh = (UT_hash_handle*)(((char*)_elt) + _dst_hho); \ + IF_HASH_NONFATAL_OOM( int _hs_oomed = 0; ) \ + _dst_hh = (UT_hash_handle*)(void*)(((char*)_elt) + _dst_hho); \ _dst_hh->key = _src_hh->key; \ _dst_hh->keylen = _src_hh->keylen; \ _dst_hh->hashv = _src_hh->hashv; \ @@ -988,14 +1000,30 @@ do { } \ if ((dst) == NULL) { \ DECLTYPE_ASSIGN(dst, _elt); \ - HASH_MAKE_TABLE(hh_dst, dst); \ + HASH_MAKE_TABLE(hh_dst, dst, _hs_oomed); \ + IF_HASH_NONFATAL_OOM( \ + if (_hs_oomed) { \ + uthash_nonfatal_oom(_elt); \ + (dst) = NULL; \ + continue; \ + } \ + ) \ } else { \ _dst_hh->tbl = (dst)->hh_dst.tbl; \ } \ HASH_TO_BKT(_dst_hh->hashv, _dst_hh->tbl->num_buckets, _dst_bkt); \ - HASH_ADD_TO_BKT(_dst_hh->tbl->buckets[_dst_bkt], _dst_hh); \ - HASH_BLOOM_ADD(_dst_hh->tbl, _dst_hh->hashv); \ + HASH_ADD_TO_BKT(_dst_hh->tbl->buckets[_dst_bkt], hh_dst, _dst_hh, _hs_oomed); \ (dst)->hh_dst.tbl->num_items++; \ + IF_HASH_NONFATAL_OOM( \ + if (_hs_oomed) { \ + HASH_ROLLBACK_BKT(hh_dst, dst, _dst_hh); \ + HASH_DELETE_HH(hh_dst, dst, _dst_hh); \ + _dst_hh->tbl = NULL; \ + uthash_nonfatal_oom(_elt); \ + continue; \ + } \ + ) \ + HASH_BLOOM_ADD(_dst_hh->tbl, _dst_hh->hashv); \ _last_elt = _elt; \ _last_elt_hh = _dst_hh; \ } \ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/utlist.h b/tools/sdk/esp32/include/coap/libcoap/include/coap3/utlist.h similarity index 98% rename from tools/sdk/esp32s2/include/coap/libcoap/include/coap2/utlist.h rename to tools/sdk/esp32/include/coap/libcoap/include/coap3/utlist.h index 2f4c08406f4..1979448a7b9 100644 --- a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/utlist.h +++ b/tools/sdk/esp32/include/coap/libcoap/include/coap3/utlist.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2007-2017, Troy D. Hanson http://troydhanson.github.com/uthash/ +Copyright (c) 2007-2021, Troy D. Hanson http://troydhanson.github.io/uthash/ All rights reserved. Redistribution and use in source and binary forms, with or without @@ -24,7 +24,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef UTLIST_H #define UTLIST_H -#define UTLIST_VERSION 2.0.2 +#define UTLIST_VERSION 2.3.0 #include @@ -358,8 +358,8 @@ do { do { \ LDECLTYPE(head) _tmp; \ if (head) { \ - LL_LOWER_BOUND(head, _tmp, add, cmp); \ - LL_APPEND_ELEM(head, _tmp, add); \ + LL_LOWER_BOUND2(head, _tmp, add, cmp, next); \ + LL_APPEND_ELEM2(head, _tmp, add, next); \ } else { \ (head) = (add); \ (head)->next = NULL; \ @@ -651,14 +651,14 @@ do { } while (0) #define DL_INSERT_INORDER(head,add,cmp) \ - DL_INSERT_INORDER2(head,add,cmp,next) + DL_INSERT_INORDER2(head,add,cmp,prev,next) -#define DL_INSERT_INORDER2(head,add,cmp,next) \ +#define DL_INSERT_INORDER2(head,add,cmp,prev,next) \ do { \ LDECLTYPE(head) _tmp; \ if (head) { \ - DL_LOWER_BOUND(head, _tmp, add, cmp); \ - DL_APPEND_ELEM(head, _tmp, add); \ + DL_LOWER_BOUND2(head, _tmp, add, cmp, next); \ + DL_APPEND_ELEM2(head, _tmp, add, prev, next); \ } else { \ (head) = (add); \ (head)->prev = (head); \ @@ -825,7 +825,7 @@ do { /* Here are VS2008 / NO_DECLTYPE replacements for a few functions */ #undef DL_INSERT_INORDER2 -#define DL_INSERT_INORDER2(head,add,cmp,next) \ +#define DL_INSERT_INORDER2(head,add,cmp,prev,next) \ do { \ if ((head) == NULL) { \ (add)->prev = (add); \ @@ -838,7 +838,7 @@ do { (head) = (add); \ } else { \ char *_tmp = (char*)(head); \ - while ((char*)(head)->next != _tmp && (cmp((head)->next, add)) < 0) { \ + while ((head)->next && (cmp((head)->next, add)) < 0) { \ (head) = (head)->next; \ } \ (add)->prev = (head); \ @@ -892,14 +892,14 @@ do { } while (0) #define CDL_INSERT_INORDER(head,add,cmp) \ - CDL_INSERT_INORDER2(head,add,cmp,next) + CDL_INSERT_INORDER2(head,add,cmp,prev,next) -#define CDL_INSERT_INORDER2(head,add,cmp,next) \ +#define CDL_INSERT_INORDER2(head,add,cmp,prev,next) \ do { \ LDECLTYPE(head) _tmp; \ if (head) { \ - CDL_LOWER_BOUND(head, _tmp, add, cmp); \ - CDL_APPEND_ELEM(head, _tmp, add); \ + CDL_LOWER_BOUND2(head, _tmp, add, cmp, next); \ + CDL_APPEND_ELEM2(head, _tmp, add, prev, next); \ } else { \ (head) = (add); \ (head)->next = (head); \ @@ -1044,7 +1044,7 @@ do { /* Here are VS2008 / NO_DECLTYPE replacements for a few functions */ #undef CDL_INSERT_INORDER2 -#define CDL_INSERT_INORDER2(head,add,cmp,next) \ +#define CDL_INSERT_INORDER2(head,add,cmp,prev,next) \ do { \ if ((head) == NULL) { \ (add)->prev = (add); \ diff --git a/tools/sdk/esp32/include/coap/port/include/coap/coap_dtls.h b/tools/sdk/esp32/include/coap/port/include/coap/coap_dtls.h deleted file mode 100644 index 2dd0e88d2e5..00000000000 --- a/tools/sdk/esp32/include/coap/port/include/coap/coap_dtls.h +++ /dev/null @@ -1,631 +0,0 @@ -/* - * coap_dtls.h -- (Datagram) Transport Layer Support for libcoap - * - * Copyright (C) 2016 Olaf Bergmann - * Copyright (C) 2017 Jean-Claude Michelou - * - * This file is part of the CoAP library libcoap. Please see README for terms - * of use. - */ - -#ifndef COAP_DTLS_H_ -#define COAP_DTLS_H_ - -#include "coap_time.h" -#include "str.h" - -struct coap_context_t; -struct coap_session_t; -struct coap_dtls_pki_t; - -/** - * @defgroup dtls DTLS Support - * API functions for interfacing with DTLS libraries. - * @{ - */ - -/** - * Check whether DTLS is available. - * - * @return @c 1 if support for DTLS is enabled, or @c 0 otherwise. - */ -int coap_dtls_is_supported(void); - -/** - * Check whether TLS is available. - * - * @return @c 1 if support for TLS is enabled, or @c 0 otherwise. - */ -int coap_tls_is_supported(void); - -typedef enum coap_tls_library_t { - COAP_TLS_LIBRARY_NOTLS = 0, /**< No DTLS library */ - COAP_TLS_LIBRARY_TINYDTLS, /**< Using TinyDTLS library */ - COAP_TLS_LIBRARY_OPENSSL, /**< Using OpenSSL library */ - COAP_TLS_LIBRARY_GNUTLS, /**< Using GnuTLS library */ - COAP_TLS_LIBRARY_MBEDTLS, /**< Using MbedTLS library */ -} coap_tls_library_t; - -/** - * The structure used for returning the underlying (D)TLS library - * information. - */ -typedef struct coap_tls_version_t { - uint64_t version; /**< (D)TLS runtime Library Version */ - coap_tls_library_t type; /**< Library type. One of COAP_TLS_LIBRARY_* */ - uint64_t built_version; /**< (D)TLS Built against Library Version */ -} coap_tls_version_t; - -/** - * Determine the type and version of the underlying (D)TLS library. - * - * @return The version and type of library libcoap was compiled against. - */ -coap_tls_version_t *coap_get_tls_library_version(void); - -/** - * Additional Security setup handler that can be set up by - * coap_context_set_pki(). - * Invoked when libcoap has done the validation checks at the TLS level, - * but the application needs to do some additional checks/changes/updates. - * - * @param tls_session The security session definition - e.g. SSL * for OpenSSL. - * NULL if server call-back. - * This will be dependent on the underlying TLS library - - * see coap_get_tls_library_version() - * @param setup_data A structure containing setup data originally passed into - * coap_context_set_pki() or coap_new_client_session_pki(). - * - * @return @c 1 if successful, else @c 0. - */ -typedef int (*coap_dtls_security_setup_t)(void* tls_session, - struct coap_dtls_pki_t *setup_data); - -/** - * CN Validation call-back that can be set up by coap_context_set_pki(). - * Invoked when libcoap has done the validation checks at the TLS level, - * but the application needs to check that the CN is allowed. - * CN is the SubjectAltName in the cert, if not present, then the leftmost - * Common Name (CN) component of the subject name. - * - * @param cn The determined CN from the certificate - * @param asn1_public_cert The ASN.1 DER encoded X.509 certificate - * @param asn1_length The ASN.1 length - * @param coap_session The CoAP session associated with the certificate update - * @param depth Depth in cert chain. If 0, then client cert, else a CA - * @param validated TLS layer can find no issues if 1 - * @param arg The same as was passed into coap_context_set_pki() - * in setup_data->cn_call_back_arg - * - * @return @c 1 if accepted, else @c 0 if to be rejected. - */ -typedef int (*coap_dtls_cn_callback_t)(const char *cn, - const uint8_t *asn1_public_cert, - size_t asn1_length, - struct coap_session_t *coap_session, - unsigned depth, - int validated, - void *arg); - -/** - * The enum used for determining the provided PKI ASN.1 (DER) Private Key - * formats. - */ -typedef enum coap_asn1_privatekey_type_t { - COAP_ASN1_PKEY_NONE, /**< NONE */ - COAP_ASN1_PKEY_RSA, /**< RSA type */ - COAP_ASN1_PKEY_RSA2, /**< RSA2 type */ - COAP_ASN1_PKEY_DSA, /**< DSA type */ - COAP_ASN1_PKEY_DSA1, /**< DSA1 type */ - COAP_ASN1_PKEY_DSA2, /**< DSA2 type */ - COAP_ASN1_PKEY_DSA3, /**< DSA3 type */ - COAP_ASN1_PKEY_DSA4, /**< DSA4 type */ - COAP_ASN1_PKEY_DH, /**< DH type */ - COAP_ASN1_PKEY_DHX, /**< DHX type */ - COAP_ASN1_PKEY_EC, /**< EC type */ - COAP_ASN1_PKEY_HMAC, /**< HMAC type */ - COAP_ASN1_PKEY_CMAC, /**< CMAC type */ - COAP_ASN1_PKEY_TLS1_PRF, /**< TLS1_PRF type */ - COAP_ASN1_PKEY_HKDF /**< HKDF type */ -} coap_asn1_privatekey_type_t; - -/** - * The enum used for determining the PKI key formats. - */ -typedef enum coap_pki_key_t { - COAP_PKI_KEY_PEM = 0, /**< The PKI key type is PEM file */ - COAP_PKI_KEY_ASN1, /**< The PKI key type is ASN.1 (DER) */ - COAP_PKI_KEY_PEM_BUF, /**< The PKI key type is PEM buffer */ -} coap_pki_key_t; - -/** - * The structure that holds the PKI PEM definitions. - */ -typedef struct coap_pki_key_pem_t { - const char *ca_file; /**< File location of Common CA in PEM format */ - const char *public_cert; /**< File location of Public Cert in PEM format */ - const char *private_key; /**< File location of Private Key in PEM format */ -} coap_pki_key_pem_t; - -/** - * The structure that holds the PKI PEM buffer definitions. - */ -typedef struct coap_pki_key_pem_buf_t { - const uint8_t *ca_cert; /**< PEM buffer Common CA Cert */ - const uint8_t *public_cert; /**< PEM buffer Public Cert */ - const uint8_t *private_key; /**< PEM buffer Private Key */ - size_t ca_cert_len; /**< PEM buffer CA Cert length */ - size_t public_cert_len; /**< PEM buffer Public Cert length */ - size_t private_key_len; /**< PEM buffer Private Key length */ -} coap_pki_key_pem_buf_t; - -/** - * The structure that holds the PKI ASN.1 (DER) definitions. - */ -typedef struct coap_pki_key_asn1_t { - const uint8_t *ca_cert; /**< ASN1 (DER) Common CA Cert */ - const uint8_t *public_cert; /**< ASN1 (DER) Public Cert */ - const uint8_t *private_key; /**< ASN1 (DER) Private Key */ - size_t ca_cert_len; /**< ASN1 CA Cert length */ - size_t public_cert_len; /**< ASN1 Public Cert length */ - size_t private_key_len; /**< ASN1 Private Key length */ - coap_asn1_privatekey_type_t private_key_type; /**< Private Key Type */ -} coap_pki_key_asn1_t; - -/** - * The structure that holds the PKI key information. - */ -typedef struct coap_dtls_key_t { - coap_pki_key_t key_type; /**< key format type */ - union { - coap_pki_key_pem_t pem; /**< for PEM file keys */ - coap_pki_key_pem_buf_t pem_buf; /**< for PEM memory keys */ - coap_pki_key_asn1_t asn1; /**< for ASN.1 (DER) file keys */ - } key; -} coap_dtls_key_t; - -/** - * Server Name Indication (SNI) Validation call-back that can be set up by - * coap_context_set_pki(). - * Invoked if the SNI is not previously seen and prior to sending a certificate - * set back to the client so that the appropriate certificate set can be used - * based on the requesting SNI. - * - * @param sni The requested SNI - * @param arg The same as was passed into coap_context_set_pki() - * in setup_data->sni_call_back_arg - * - * @return New set of certificates to use, or @c NULL if SNI is to be rejected. - */ -typedef coap_dtls_key_t *(*coap_dtls_sni_callback_t)(const char *sni, - void* arg); - - -#define COAP_DTLS_PKI_SETUP_VERSION 1 /**< Latest PKI setup version */ - -/** - * The structure used for defining the PKI setup data to be used. - */ -typedef struct coap_dtls_pki_t { - uint8_t version; /** Set to 1 to support this version of the struct */ - - /* Options to enable different TLS functionality in libcoap */ - uint8_t verify_peer_cert; /**< 1 if peer cert is to be verified */ - uint8_t require_peer_cert; /**< 1 if peer cert is required */ - uint8_t allow_self_signed; /**< 1 if self signed certs are allowed */ - uint8_t allow_expired_certs; /**< 1 if expired certs are allowed */ - uint8_t cert_chain_validation; /**< 1 if to check cert_chain_verify_depth */ - uint8_t cert_chain_verify_depth; /**< recommended depth is 3 */ - uint8_t check_cert_revocation; /**< 1 if revocation checks wanted */ - uint8_t allow_no_crl; /**< 1 ignore if CRL not there */ - uint8_t allow_expired_crl; /**< 1 if expired crl is allowed */ - uint8_t allow_bad_md_hash; /**< 1 if expired certs are allowed */ - uint8_t allow_short_rsa_length; /**< 1 if expired certs are allowed */ - uint8_t reserved[4]; /**< Reserved - must be set to 0 for - future compatibility */ - /* Size of 4 chosen to align to next - * parameter, so if newly defined option - * it can use one of the reserverd slot so - * no need to change - * COAP_DTLS_PKI_SETUP_VERSION and just - * decrement the reserved[] count. - */ - - /** CN check call-back function. - * If not NULL, is called when the TLS connection has passed the configured - * TLS options above for the application to verify if the CN is valid. - */ - coap_dtls_cn_callback_t validate_cn_call_back; - void *cn_call_back_arg; /**< Passed in to the CN call-back function */ - - /** SNI check call-back function. - * If not @p NULL, called if the SNI is not previously seen and prior to - * sending a certificate set back to the client so that the appropriate - * certificate set can be used based on the requesting SNI. - */ - coap_dtls_sni_callback_t validate_sni_call_back; - void *sni_call_back_arg; /**< Passed in to the sni call-back function */ - - /** Additional Security call-back handler that is invoked when libcoap has - * done the standerd, defined validation checks at the TLS level, - * If not @p NULL, called from within the TLS Client Hello connection - * setup. - */ - coap_dtls_security_setup_t additional_tls_setup_call_back; - - char* client_sni; /**< If not NULL, SNI to use in client TLS setup. - Owned by the client app and must remain valid - during the call to coap_new_client_session_pki() */ - - coap_dtls_key_t pki_key; /**< PKI key definition */ -} coap_dtls_pki_t; - -/** @} */ - -/** - * @defgroup dtls_internal DTLS Support (Internal) - * Internal API functions for interfacing with DTLS libraries. - * @{ - */ - -/** - * Creates a new DTLS context for the given @p coap_context. This function - * returns a pointer to a new DTLS context object or @c NULL on error. - * - * Internal function. - * - * @param coap_context The CoAP context where the DTLS object shall be used. - * - * @return A DTLS context object or @c NULL on error. - */ -void * -coap_dtls_new_context(struct coap_context_t *coap_context); - -typedef enum coap_dtls_role_t { - COAP_DTLS_ROLE_CLIENT, /**< Internal function invoked for client */ - COAP_DTLS_ROLE_SERVER /**< Internal function invoked for server */ -} coap_dtls_role_t; - -/** - * Set the DTLS context's default PSK information. - * This does the PSK specifics following coap_dtls_new_context(). - * If @p COAP_DTLS_ROLE_SERVER, then identity hint will also get set. - * If @p COAP_DTLS_ROLE_SERVER, then the information will get put into the - * TLS library's context (from which sessions are derived). - * If @p COAP_DTLS_ROLE_CLIENT, then the information will get put into the - * TLS library's session. - * - * Internal function. - * - * @param coap_context The CoAP context. - * @param identity_hint The default PSK server identity hint sent to a client. - * Required parameter. If @p NULL, will be set to "". - * Empty string is a valid hint. - * This parameter is ignored if COAP_DTLS_ROLE_CLIENT - * @param role One of @p COAP_DTLS_ROLE_CLIENT or @p COAP_DTLS_ROLE_SERVER - * - * @return @c 1 if successful, else @c 0. - */ - -int -coap_dtls_context_set_psk(struct coap_context_t *coap_context, - const char *identity_hint, - coap_dtls_role_t role); - -/** - * Set the DTLS context's default server PKI information. - * This does the PKI specifics following coap_dtls_new_context(). - * If @p COAP_DTLS_ROLE_SERVER, then the information will get put into the - * TLS library's context (from which sessions are derived). - * If @p COAP_DTLS_ROLE_CLIENT, then the information will get put into the - * TLS library's session. - * - * Internal function. - * - * @param coap_context The CoAP context. - * @param setup_data Setup information defining how PKI is to be setup. - * Required parameter. If @p NULL, PKI will not be - * set up. - * @param role One of @p COAP_DTLS_ROLE_CLIENT or @p COAP_DTLS_ROLE_SERVER - * - * @return @c 1 if successful, else @c 0. - */ - -int -coap_dtls_context_set_pki(struct coap_context_t *coap_context, - coap_dtls_pki_t *setup_data, - coap_dtls_role_t role); - -/** - * Set the dtls context's default Root CA information for a client or server. - * - * Internal function. - * - * @param coap_context The current coap_context_t object. - * @param ca_file If not @p NULL, is the full path name of a PEM encoded - * file containing all the Root CAs to be used. - * @param ca_dir If not @p NULL, points to a directory containing PEM - * encoded files containing all the Root CAs to be used. - * - * @return @c 1 if successful, else @c 0. - */ - -int -coap_dtls_context_set_pki_root_cas(struct coap_context_t *coap_context, - const char *ca_file, - const char *ca_dir); - -/** - * Check whether one of the coap_dtls_context_set_{psk|pki}() functions have - * been called. - * - * Internal function. - * - * @param coap_context The current coap_context_t object. - * - * @return @c 1 if coap_dtls_context_set_{psk|pki}() called, else @c 0. - */ - -int coap_dtls_context_check_keys_enabled(struct coap_context_t *coap_context); - -/** - * Releases the storage allocated for @p dtls_context. - * - * Internal function. - * - * @param dtls_context The DTLS context as returned by coap_dtls_new_context(). - */ -void coap_dtls_free_context(void *dtls_context); - -/** - * Create a new client-side session. This should send a HELLO to the server. - * - * Internal function. - * - * @param coap_session The CoAP session. - * - * @return Opaque handle to underlying TLS library object containing security - * parameters for the session. -*/ -void *coap_dtls_new_client_session(struct coap_session_t *coap_session); - -/** - * Create a new DTLS server-side session. - * Called after coap_dtls_hello() has returned @c 1, signalling that a validated - * HELLO was received from a client. - * This should send a HELLO to the server. - * - * Internal function. - * - * @param coap_session The CoAP session. - * - * @return Opaque handle to underlying TLS library object containing security - * parameters for the DTLS session. - */ -void *coap_dtls_new_server_session(struct coap_session_t *coap_session); - -/** - * Terminates the DTLS session (may send an ALERT if necessary) then frees the - * underlying TLS library object containing security parameters for the session. - * - * Internal function. - * - * @param coap_session The CoAP session. - */ -void coap_dtls_free_session(struct coap_session_t *coap_session); - -/** - * Notify of a change in the CoAP session's MTU, for example after - * a PMTU update. - * - * Internal function. - * - * @param coap_session The CoAP session. - */ -void coap_dtls_session_update_mtu(struct coap_session_t *coap_session); - -/** - * Send data to a DTLS peer. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param data pointer to data. - * @param data_len Number of bytes to send. - * - * @return @c 0 if this would be blocking, @c -1 if there is an error or the - * number of cleartext bytes sent. - */ -int coap_dtls_send(struct coap_session_t *coap_session, - const uint8_t *data, - size_t data_len); - -/** - * Check if timeout is handled per CoAP session or per CoAP context. - * - * Internal function. - * - * @return @c 1 of timeout and retransmit is per context, @c 0 if it is - * per session. - */ -int coap_dtls_is_context_timeout(void); - -/** - * Do all pending retransmits and get next timeout - * - * Internal function. - * - * @param dtls_context The DTLS context. - * - * @return @c 0 if no event is pending or date of the next retransmit. - */ -coap_tick_t coap_dtls_get_context_timeout(void *dtls_context); - -/** - * Get next timeout for this session. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param now The current time in ticks. - * - * @return @c 0 If no event is pending or ticks time of the next retransmit. - */ -coap_tick_t coap_dtls_get_timeout(struct coap_session_t *coap_session, - coap_tick_t now); - -/** - * Handle a DTLS timeout expiration. - * - * Internal function. - * - * @param coap_session The CoAP session. - */ -void coap_dtls_handle_timeout(struct coap_session_t *coap_session); - -/** - * Handling incoming data from a DTLS peer. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param data Encrypted datagram. - * @param data_len Encrypted datagram size. - * - * @return Result of coap_handle_dgram on the decrypted CoAP PDU - * or @c -1 for error. - */ -int coap_dtls_receive(struct coap_session_t *coap_session, - const uint8_t *data, - size_t data_len); - -/** - * Handling client HELLO messages from a new candiate peer. - * Note that session->tls is empty. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param data Encrypted datagram. - * @param data_len Encrypted datagram size. - * - * @return @c 0 if a cookie verification message has been sent, @c 1 if the - * HELLO contains a valid cookie and a server session should be created, - * @c -1 if the message is invalid. - */ -int coap_dtls_hello(struct coap_session_t *coap_session, - const uint8_t *data, - size_t data_len); - -/** - * Get DTLS overhead over cleartext PDUs. - * - * Internal function. - * - * @param coap_session The CoAP session. - * - * @return Maximum number of bytes added by DTLS layer. - */ -unsigned int coap_dtls_get_overhead(struct coap_session_t *coap_session); - -/** - * Create a new TLS client-side session. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param connected Updated with whether the connection is connected yet or not. - * @c 0 is not connected, @c 1 is connected. - * - * @return Opaque handle to underlying TLS library object containing security - * parameters for the session. -*/ -void *coap_tls_new_client_session(struct coap_session_t *coap_session, int *connected); - -/** - * Create a TLS new server-side session. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param connected Updated with whether the connection is connected yet or not. - * @c 0 is not connected, @c 1 is connected. - * - * @return Opaque handle to underlying TLS library object containing security - * parameters for the session. - */ -void *coap_tls_new_server_session(struct coap_session_t *coap_session, int *connected); - -/** - * Terminates the TLS session (may send an ALERT if necessary) then frees the - * underlying TLS library object containing security parameters for the session. - * - * Internal function. - * - * @param coap_session The CoAP session. - */ -void coap_tls_free_session( struct coap_session_t *coap_session ); - -/** - * Send data to a TLS peer, with implicit flush. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param data Pointer to data. - * @param data_len Number of bytes to send. - * - * @return @c 0 if this should be retried, @c -1 if there is an error - * or the number of cleartext bytes sent. - */ -ssize_t coap_tls_write(struct coap_session_t *coap_session, - const uint8_t *data, - size_t data_len - ); - -/** - * Read some data from a TLS peer. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param data Pointer to data. - * @param data_len Maximum number of bytes to read. - * - * @return @c 0 if this should be retried, @c -1 if there is an error - * or the number of cleartext bytes read. - */ -ssize_t coap_tls_read(struct coap_session_t *coap_session, - uint8_t *data, - size_t data_len - ); - -/** - * Initialize the underlying (D)TLS Library layer. - * - * Internal function. - * - */ -void coap_dtls_startup(void); - -/** @} */ - -/** - * @ingroup logging - * Sets the (D)TLS logging level to the specified @p level. - * Note: coap_log_level() will influence output if at a specified level. - * - * @param level The logging level to use - LOG_* - */ -void coap_dtls_set_log_level(int level); - -/** - * @ingroup logging - * Get the current (D)TLS logging. - * - * @return The current log level (one of LOG_*). - */ -int coap_dtls_get_log_level(void); - - -#endif /* COAP_DTLS_H */ diff --git a/tools/sdk/esp32s2/include/coap/port/include/coap/coap.h b/tools/sdk/esp32/include/coap/port/include/coap3/coap.h similarity index 53% rename from tools/sdk/esp32s2/include/coap/port/include/coap/coap.h rename to tools/sdk/esp32/include/coap/port/include/coap3/coap.h index f048ca85714..c69d2734b3a 100644 --- a/tools/sdk/esp32s2/include/coap/port/include/coap/coap.h +++ b/tools/sdk/esp32/include/coap/port/include/coap3/coap.h @@ -21,27 +21,28 @@ extern "C" { #endif -#include "libcoap.h" +#include "coap3/libcoap.h" -#include "address.h" -#include "async.h" -#include "bits.h" -#include "block.h" -#include "coap_dtls.h" -#include "coap_event.h" -#include "coap_io.h" -#include "coap_time.h" -#include "coap_debug.h" -#include "encode.h" -#include "mem.h" -#include "net.h" -#include "option.h" -#include "pdu.h" -#include "prng.h" -#include "resource.h" -#include "str.h" -#include "subscribe.h" -#include "uri.h" +#include "coap3/coap_forward_decls.h" +#include "coap3/address.h" +#include "coap3/async.h" +#include "coap3/block.h" +#include "coap3/coap_cache.h" +#include "coap3/coap_dtls.h" +#include "coap3/coap_event.h" +#include "coap3/coap_io.h" +#include "coap3/coap_time.h" +#include "coap3/coap_debug.h" +#include "coap3/encode.h" +#include "coap3/mem.h" +#include "coap3/net.h" +#include "coap3/option.h" +#include "coap3/pdu.h" +#include "coap3/coap_prng.h" +#include "coap3/resource.h" +#include "coap3/str.h" +#include "coap3/subscribe.h" +#include "coap3/uri.h" #ifdef __cplusplus } diff --git a/tools/sdk/esp32/include/coap/port/include/coap_config_posix.h b/tools/sdk/esp32/include/coap/port/include/coap_config_posix.h index 3f6b7c605fc..b24335ad156 100644 --- a/tools/sdk/esp32/include/coap/port/include/coap_config_posix.h +++ b/tools/sdk/esp32/include/coap/port/include/coap_config_posix.h @@ -30,6 +30,7 @@ #define HAVE_NETDB_H #define HAVE_NETINET_IN_H #define HAVE_STRUCT_CMSGHDR +#define COAP_DISABLE_TCP 0 #define ipi_spec_dst ipi_addr struct in6_pktinfo { @@ -53,8 +54,6 @@ struct in6_pktinfo { #define COAP_CONSTRAINED_STACK 1 #define ESPIDF_VERSION -#define _POSIX_TIMERS 1 - #define gai_strerror(x) "gai_strerror() not supported" #endif /* WITH_POSIX */ diff --git a/tools/sdk/esp32/include/config/sdkconfig.h b/tools/sdk/esp32/include/config/sdkconfig.h index e883798747b..b57d1022057 100644 --- a/tools/sdk/esp32/include/config/sdkconfig.h +++ b/tools/sdk/esp32/include/config/sdkconfig.h @@ -23,6 +23,7 @@ #define CONFIG_BOOTLOADER_WDT_ENABLE 1 #define CONFIG_BOOTLOADER_WDT_TIME_MS 9000 #define CONFIG_BOOTLOADER_RESERVE_RTC_SIZE 0x0 +#define CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT 1 #define CONFIG_ESPTOOLPY_BAUD_OTHER_VAL 115200 #define CONFIG_ESPTOOLPY_FLASHMODE_DIO 1 #define CONFIG_ESPTOOLPY_FLASHMODE "dio" @@ -86,7 +87,6 @@ #define CONFIG_APPTRACE_DEST_NONE 1 #define CONFIG_APPTRACE_LOCK_ENABLE 1 #define CONFIG_BT_ENABLED 1 -#define CONFIG_BT_CTRL_ESP32 1 #define CONFIG_BTDM_CTRL_MODE_BTDM 1 #define CONFIG_BTDM_CTRL_BLE_MAX_CONN 3 #define CONFIG_BTDM_CTRL_BR_EDR_MAX_ACL_CONN 2 @@ -119,24 +119,8 @@ #define CONFIG_BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP 1 #define CONFIG_BTDM_BLE_ADV_REPORT_FLOW_CTRL_NUM 100 #define CONFIG_BTDM_BLE_ADV_REPORT_DISCARD_THRSHOLD 20 -#define CONFIG_BT_CTRL_MODE_EFF 1 -#define CONFIG_BT_CTRL_BLE_MAX_ACT 10 -#define CONFIG_BT_CTRL_BLE_MAX_ACT_EFF 10 -#define CONFIG_BT_CTRL_BLE_STATIC_ACL_TX_BUF_NB 0 -#define CONFIG_BT_CTRL_PINNED_TO_CORE 0 -#define CONFIG_BT_CTRL_HCI_TL 1 -#define CONFIG_BT_CTRL_ADV_DUP_FILT_MAX 30 -#define CONFIG_BT_CTRL_HW_CCA_EFF 0 -#define CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_EFF 0 -#define CONFIG_BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP 1 -#define CONFIG_BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_NUM 100 -#define CONFIG_BT_CTRL_BLE_ADV_REPORT_DISCARD_THRSHOLD 20 -#define CONFIG_BT_CTRL_BLE_SCAN_DUPL 1 -#define CONFIG_BT_CTRL_SCAN_DUPL_TYPE 0 -#define CONFIG_BT_CTRL_SCAN_DUPL_CACHE_SIZE 100 -#define CONFIG_BT_CTRL_SLEEP_MODE_EFF 0 -#define CONFIG_BT_CTRL_SLEEP_CLOCK_EFF 0 -#define CONFIG_BT_CTRL_HCI_TL_EFF 1 +#define CONFIG_BTDM_RESERVE_DRAM 0xdb5c +#define CONFIG_BTDM_CTRL_HLI 1 #define CONFIG_BT_BLUEDROID_ENABLED 1 #define CONFIG_BT_BTC_TASK_STACK_SIZE 8192 #define CONFIG_BT_BLUEDROID_PINNED_TO_CORE_0 1 @@ -164,8 +148,6 @@ #define CONFIG_BT_BLE_DYNAMIC_ENV_MEMORY 1 #define CONFIG_BT_SMP_ENABLE 1 #define CONFIG_BT_BLE_ESTAB_LINK_CONN_TOUT 30 -#define CONFIG_BT_RESERVE_DRAM 0xdb5c -#define CONFIG_BT_NIMBLE_USE_ESP_TIMER 1 #define CONFIG_COAP_MBEDTLS_PSK 1 #define CONFIG_COAP_LOG_DEFAULT_LEVEL 0 #define CONFIG_ADC_DISABLE_DAC 1 @@ -254,6 +236,11 @@ #define CONFIG_ESP_MAC_ADDR_UNIVERSE_ETH 1 #define CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_FOUR 1 #define CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES 4 +#define CONFIG_ESP_SLEEP_RTC_BUS_ISO_WORKAROUND 1 +#define CONFIG_ESP_IPC_TASK_STACK_SIZE 1024 +#define CONFIG_ESP_IPC_USES_CALLERS_PRIORITY 1 +#define CONFIG_ESP_IPC_ISR_ENABLE 1 +#define CONFIG_LCD_PANEL_IO_FORMAT_BUF_SIZE 32 #define CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL 120 #define CONFIG_ESP_NETIF_TCPIP_LWIP 1 #define CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER 1 @@ -280,8 +267,7 @@ #define CONFIG_ESP_TASK_WDT_PANIC 1 #define CONFIG_ESP_TASK_WDT_TIMEOUT_S 5 #define CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0 1 -#define CONFIG_ESP_IPC_TASK_STACK_SIZE 1024 -#define CONFIG_ESP_IPC_USES_CALLERS_PRIORITY 1 +#define CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_5 1 #define CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER 1 #define CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER 1 #define CONFIG_ESP_TIMER_TASK_STACK_SIZE 4096 @@ -336,8 +322,12 @@ #define CONFIG_FMB_TIMER_PORT_ENABLED 1 #define CONFIG_FMB_TIMER_GROUP 0 #define CONFIG_FMB_TIMER_INDEX 0 +#define CONFIG_FMB_MASTER_TIMER_GROUP 0 +#define CONFIG_FMB_MASTER_TIMER_INDEX 0 #define CONFIG_FREERTOS_NO_AFFINITY 0x7FFFFFFF +#define CONFIG_FREERTOS_TICK_SUPPORT_CORETIMER 1 #define CONFIG_FREERTOS_CORETIMER_0 1 +#define CONFIG_FREERTOS_SYSTICK_USES_CCOUNT 1 #define CONFIG_FREERTOS_HZ 1000 #define CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY 1 #define CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK 1 @@ -354,6 +344,7 @@ #define CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE 0 #define CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER 1 #define CONFIG_FREERTOS_DEBUG_OCDAWARE 1 +#define CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT 1 #define CONFIG_HAL_ASSERTION_EQUALS_SYSTEM 1 #define CONFIG_HAL_DEFAULT_ASSERTION_LEVEL 2 #define CONFIG_HEAP_POISONING_LIGHT 1 @@ -383,7 +374,6 @@ #define CONFIG_LWIP_DHCPS_MAX_STATION_NUM 8 #define CONFIG_LWIP_IPV6 1 #define CONFIG_LWIP_IPV6_NUM_ADDRESSES 3 -#define CONFIG_LWIP_IPV6_RDNSS_MAX_DNS_SERVERS 0 #define CONFIG_LWIP_NETIF_LOOPBACK 1 #define CONFIG_LWIP_LOOPBACK_MAX_PBUFS 8 #define CONFIG_LWIP_MAX_ACTIVE_TCP 16 @@ -416,7 +406,7 @@ #define CONFIG_LWIP_PPP_MPPE_SUPPORT 1 #define CONFIG_LWIP_ICMP 1 #define CONFIG_LWIP_MAX_RAW_PCBS 16 -#define CONFIG_LWIP_DHCP_MAX_NTP_SERVERS 1 +#define CONFIG_LWIP_SNTP_MAX_SERVERS 1 #define CONFIG_LWIP_SNTP_UPDATE_DELAY 3600000 #define CONFIG_LWIP_ESP_LWIP_ASSERT 1 #define CONFIG_LWIP_HOOK_TCP_ISN_DEFAULT 1 @@ -549,11 +539,6 @@ #define CONFIG_DSP_OPTIMIZATION 1 #define CONFIG_DSP_MAX_FFT_SIZE_4096 1 #define CONFIG_DSP_MAX_FFT_SIZE 4096 -#define CONFIG_XTENSA_IMPL 1 -#define CONFIG_MTMN_LITE_QUANT 1 -#define CONFIG_MFN56_1X 1 -#define CONFIG_HD_NANO1 1 -#define CONFIG_HP_NANO1 1 #define CONFIG_OV7670_SUPPORT 1 #define CONFIG_OV7725_SUPPORT 1 #define CONFIG_NT99141_SUPPORT 1 @@ -690,5 +675,5 @@ #define CONFIG_ULP_COPROC_ENABLED CONFIG_ESP32_ULP_COPROC_ENABLED #define CONFIG_ULP_COPROC_RESERVE_MEM CONFIG_ESP32_ULP_COPROC_RESERVE_MEM #define CONFIG_WARN_WRITE_STRINGS CONFIG_COMPILER_WARN_WRITE_STRINGS -#define CONFIG_ARDUINO_IDF_COMMIT "c69f0ec32" +#define CONFIG_ARDUINO_IDF_COMMIT "3e370c4296" #define CONFIG_ARDUINO_IDF_BRANCH "master" diff --git a/tools/sdk/esp32/include/driver/include/driver/i2s.h b/tools/sdk/esp32/include/driver/include/driver/i2s.h index 4ee73b594d7..aa649ed479c 100644 --- a/tools/sdk/esp32/include/driver/include/driver/i2s.h +++ b/tools/sdk/esp32/include/driver/include/driver/i2s.h @@ -13,12 +13,11 @@ #include "soc/i2s_periph.h" #include "soc/rtc_periph.h" #include "soc/soc_caps.h" -#include "hal/i2s_hal.h" #include "hal/i2s_types.h" #include "driver/periph_ctrl.h" #include "esp_intr_alloc.h" -#if SOC_I2S_SUPPORTS_ADC_DAC +#if SOC_I2S_SUPPORTS_ADC #include "driver/adc.h" #endif @@ -28,7 +27,119 @@ extern "C" { #define I2S_PIN_NO_CHANGE (-1) /*!< Use in i2s_pin_config_t for pins which should not be changed */ -typedef intr_handle_t i2s_isr_handle_t; +/** + * @brief I2S port number, the max port number is (I2S_NUM_MAX -1). + */ +typedef enum { + I2S_NUM_0 = 0, /*!< I2S port 0 */ +#if SOC_I2S_NUM > 1 + I2S_NUM_1 = 1, /*!< I2S port 1 */ +#endif + I2S_NUM_MAX, /*!< I2S port max */ +} i2s_port_t; + +#if SOC_I2S_SUPPORTS_PCM +/** + * @brief I2S PCM configuration + * + */ +typedef struct { + i2s_pcm_compress_t pcm_type; /*!< I2S PCM a/u-law decompress or compress type */ +} i2s_pcm_cfg_t; +#endif + +#if SOC_I2S_SUPPORTS_PDM_TX +/** + * @brief Default I2S PDM Up-Sampling Rate configuration + */ +#define I2S_PDM_DEFAULT_UPSAMPLE_CONFIG(rate) { \ + .sample_rate = rate, \ + .fp = 960, \ + .fs = (rate) / 100, \ + } + +/** + * @brief I2S PDM up-sample rate configuration + * @note TX PDM can only be set to the following two upsampling rate configurations: + * 1: fp = 960, fs = sample_rate / 100, in this case, Fpdm = 128*48000 + * 2: fp = 960, fs = 480, in this case, Fpdm = 128*Fpcm = 128*sample_rate + * If the pdm receiver do not care the pdm serial clock, it's recommended set Fpdm = 128*48000. + * Otherwise, the second configuration should be applied. + */ +typedef struct { + int sample_rate; /*!< I2S PDM sample rate */ + int fp; /*!< I2S PDM TX upsampling paramater. Normally it should be set to 960 */ + int fs; /*!< I2S PDM TX upsampling paramater. When it is set to 480, the pdm clock frequency Fpdm = 128 * sample_rate, when it is set to sample_rate / 100, Fpdm will be fixed to 128*48000 */ +} i2s_pdm_tx_upsample_cfg_t; +#endif + +/** + * @brief I2S pin number for i2s_set_pin + * + */ +typedef struct { + int mck_io_num; /*!< MCK in out pin*/ + int bck_io_num; /*!< BCK in out pin*/ + int ws_io_num; /*!< WS in out pin*/ + int data_out_num; /*!< DATA out pin*/ + int data_in_num; /*!< DATA in pin*/ +} i2s_pin_config_t; + +/** + * @brief I2S driver configuration parameters + * + */ +typedef struct { + + i2s_mode_t mode; /*!< I2S work mode */ + uint32_t sample_rate; /*!< I2S sample rate */ + i2s_bits_per_sample_t bits_per_sample; /*!< I2S sample bits in one channel */ + i2s_channel_fmt_t channel_format; /*!< I2S channel format.*/ + i2s_comm_format_t communication_format; /*!< I2S communication format */ + int 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 */ + int dma_buf_count; /*!< I2S DMA Buffer Count */ + int dma_buf_len; /*!< I2S DMA Buffer Length */ + bool use_apll; /*!< I2S using APLL as main I2S clock, enable it to get accurate clock */ + bool tx_desc_auto_clear; /*!< I2S auto clear tx descriptor if there is underflow condition (helps in avoiding noise in case of data unavailability) */ + int fixed_mclk; /*!< I2S using fixed MCLK output. If use_apll = true and fixed_mclk > 0, then the clock output for i2s is fixed and equal to the fixed_mclk value. If fixed_mclk set, mclk_multiple won't take effect */ + i2s_mclk_multiple_t mclk_multiple; /*!< The multiple of I2S master clock(MCLK) to sample rate */ + i2s_bits_per_chan_t bits_per_chan; /*!< I2S total bits in one channel, only take effect when larger than 'bits_per_sample', default '0' means equal to 'bits_per_sample' */ + +#if SOC_I2S_SUPPORTS_TDM + i2s_channel_t chan_mask; /*!< I2S active channel bit mask, set value in `i2s_channel_t` to enable specific channel, the bit map of active channel can not exceed (0x1< 4 + PCNT_UNIT_4, /*!< PCNT unit 4 */ + PCNT_UNIT_5, /*!< PCNT unit 5 */ + PCNT_UNIT_6, /*!< PCNT unit 6 */ + PCNT_UNIT_7, /*!< PCNT unit 7 */ +#endif + PCNT_UNIT_MAX, +} pcnt_unit_t; + +/** + * @brief Selection of channels available for a single PCNT unit + */ +typedef enum { + PCNT_CHANNEL_0, /*!< PCNT channel 0 */ + PCNT_CHANNEL_1, /*!< PCNT channel 1 */ + PCNT_CHANNEL_MAX, +} pcnt_channel_t; + +/** + * @brief Selection of counter's events the may trigger an interrupt + */ +typedef enum { + PCNT_EVT_THRES_1 = 1 << 2, /*!< PCNT watch point event: threshold1 value event */ + PCNT_EVT_THRES_0 = 1 << 3, /*!< PCNT watch point event: threshold0 value event */ + PCNT_EVT_L_LIM = 1 << 4, /*!< PCNT watch point event: Minimum counter value */ + PCNT_EVT_H_LIM = 1 << 5, /*!< PCNT watch point event: Maximum counter value */ + PCNT_EVT_ZERO = 1 << 6, /*!< PCNT watch point event: counter value zero event */ + PCNT_EVT_MAX +} pcnt_evt_type_t; + +/** + * @brief Selection of available modes that determine the counter's action depending on the state of the control signal's input GPIO + * @note Configuration covers two actions, one for high, and one for low level on the control input + */ +typedef pcnt_channel_level_action_t pcnt_ctrl_mode_t; +#define PCNT_MODE_KEEP PCNT_CHANNEL_LEVEL_ACTION_KEEP /*!< Control mode: won't change counter mode*/ +#define PCNT_MODE_REVERSE PCNT_CHANNEL_LEVEL_ACTION_INVERSE /*!< Control mode: invert counter mode(increase -> decrease, decrease -> increase) */ +#define PCNT_MODE_DISABLE PCNT_CHANNEL_LEVEL_ACTION_HOLD /*!< Control mode: Inhibit counter(counter value will not change in this condition) */ +#define PCNT_MODE_MAX 3 + +/** + * @brief Selection of available modes that determine the counter's action on the edge of the pulse signal's input GPIO + * @note Configuration covers two actions, one for positive, and one for negative edge on the pulse input + */ +typedef pcnt_channel_edge_action_t pcnt_count_mode_t; +#define PCNT_COUNT_DIS PCNT_CHANNEL_EDGE_ACTION_HOLD /*!< Counter mode: Inhibit counter(counter value will not change in this condition) */ +#define PCNT_COUNT_INC PCNT_CHANNEL_EDGE_ACTION_INCREASE /*!< Counter mode: Increase counter value */ +#define PCNT_COUNT_DEC PCNT_CHANNEL_EDGE_ACTION_DECREASE /*!< Counter mode: Decrease counter value */ +#define PCNT_COUNT_MAX 3 + +/** + * @brief Pulse Counter configuration for a single channel + */ +typedef struct { + int pulse_gpio_num; /*!< Pulse input GPIO number, if you want to use GPIO16, enter pulse_gpio_num = 16, a negative value will be ignored */ + int ctrl_gpio_num; /*!< Control signal input GPIO number, a negative value will be ignored */ + pcnt_ctrl_mode_t lctrl_mode; /*!< PCNT low control mode */ + pcnt_ctrl_mode_t hctrl_mode; /*!< PCNT high control mode */ + pcnt_count_mode_t pos_mode; /*!< PCNT positive edge count mode */ + pcnt_count_mode_t neg_mode; /*!< PCNT negative edge count mode */ + int16_t counter_h_lim; /*!< Maximum counter value */ + int16_t counter_l_lim; /*!< Minimum counter value */ + pcnt_unit_t unit; /*!< PCNT unit number */ + pcnt_channel_t channel; /*!< the PCNT channel */ +} pcnt_config_t; + /** * @brief Configure Pulse Counter unit * @note @@ -173,7 +257,6 @@ esp_err_t pcnt_get_event_value(pcnt_unit_t unit, pcnt_evt_type_t evt_type, int16 * @param unit PCNT unit number * @param status Pointer to accept event status word * @return - * * - ESP_OK Success * - ESP_ERR_INVALID_STATE pcnt driver has not been initialized * - ESP_ERR_INVALID_ARG Parameter error @@ -363,42 +446,6 @@ void pcnt_isr_service_uninstall(void); */ esp_err_t pcnt_isr_handler_remove(pcnt_unit_t unit); -/** - * @addtogroup pcnt-examples - * - * @{ - * - * EXAMPLE OF PCNT CONFIGURATION - * ============================== - * @code{c} - * //1. Config PCNT unit - * pcnt_config_t pcnt_config = { - * .pulse_gpio_num = 4, //set gpio4 as pulse input gpio - * .ctrl_gpio_num = 5, //set gpio5 as control gpio - * .channel = PCNT_CHANNEL_0, //use unit 0 channel 0 - * .lctrl_mode = PCNT_MODE_REVERSE, //when control signal is low, reverse the primary counter mode(inc->dec/dec->inc) - * .hctrl_mode = PCNT_MODE_KEEP, //when control signal is high, keep the primary counter mode - * .pos_mode = PCNT_COUNT_INC, //increment the counter - * .neg_mode = PCNT_COUNT_DIS, //keep the counter value - * .counter_h_lim = 10, - * .counter_l_lim = -10, - * }; - * pcnt_unit_config(&pcnt_config); //init unit - * @endcode - * - * EXAMPLE OF PCNT EVENT SETTING - * ============================== - * @code{c} - * //2. Configure PCNT watchpoint event. - * pcnt_set_event_value(PCNT_UNIT_0, PCNT_EVT_THRES_1, 5); //set thres1 value - * pcnt_event_enable(PCNT_UNIT_0, PCNT_EVT_THRES_1); //enable thres1 event - * @endcode - * - * For more examples please refer to PCNT example code in IDF_PATH/examples - * - * @} - */ - #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32/include/driver/include/driver/spi_common.h b/tools/sdk/esp32/include/driver/include/driver/spi_common.h index f6b12255a53..830b8efd8c2 100644 --- a/tools/sdk/esp32/include/driver/include/driver/spi_common.h +++ b/tools/sdk/esp32/include/driver/include/driver/spi_common.h @@ -63,7 +63,8 @@ extern "C" #define SPICOMMON_BUSFLAG_DUAL (1<<6) ///< Check MOSI and MISO pins can output. Or indicates bus able to work under DIO mode. #define SPICOMMON_BUSFLAG_WPHD (1<<7) ///< Check existing of WP and HD pins. Or indicates WP & HD pins initialized. #define SPICOMMON_BUSFLAG_QUAD (SPICOMMON_BUSFLAG_DUAL|SPICOMMON_BUSFLAG_WPHD) ///< Check existing of MOSI/MISO/WP/HD pins as output. Or indicates bus able to work under QIO mode. - +#define SPICOMMON_BUSFLAG_IO4_IO7 (1<<8) ///< Check existing of IO4~IO7 pins. Or indicates IO4~IO7 pins initialized. +#define SPICOMMON_BUSFLAG_OCTAL (SPICOMMON_BUSFLAG_QUAD|SPICOMMON_BUSFLAG_IO4_IO7) ///< Check existing of MOSI/MISO/WP/HD/SPIIO4/SPIIO5/SPIIO6/SPIIO7 pins as output. Or indicates bus able to work under octal mode. #define SPICOMMON_BUSFLAG_NATIVE_PINS SPICOMMON_BUSFLAG_IOMUX_PINS /** @@ -95,18 +96,34 @@ typedef spi_common_dma_t spi_dma_chan_t; * @note Be advised that the slave driver does not use the quadwp/quadhd lines and fields in spi_bus_config_t refering to these lines will be ignored and can thus safely be left uninitialized. */ typedef struct { - int mosi_io_num; ///< GPIO pin for Master Out Slave In (=spi_d) signal, or -1 if not used. - int miso_io_num; ///< GPIO pin for Master In Slave Out (=spi_q) signal, or -1 if not used. - int sclk_io_num; ///< GPIO pin for Spi CLocK signal, or -1 if not used. - int quadwp_io_num; ///< GPIO pin for WP (Write Protect) signal which is used as D2 in 4-bit communication modes, or -1 if not used. - int quadhd_io_num; ///< GPIO pin for HD (HolD) signal which is used as D3 in 4-bit communication modes, or -1 if not used. - int max_transfer_sz; ///< Maximum transfer size, in bytes. Defaults to 4092 if 0 when DMA enabled, or to `SOC_SPI_MAXIMUM_BUFFER_SIZE` if DMA is disabled. - uint32_t flags; ///< Abilities of bus to be checked by the driver. Or-ed value of ``SPICOMMON_BUSFLAG_*`` flags. - int intr_flags; /**< Interrupt flag for the bus to set the priority, and IRAM attribute, see - * ``esp_intr_alloc.h``. Note that the EDGE, INTRDISABLED attribute are ignored - * by the driver. Note that if ESP_INTR_FLAG_IRAM is set, ALL the callbacks of - * the driver, and their callee functions, should be put in the IRAM. - */ + union { + int mosi_io_num; ///< GPIO pin for Master Out Slave In (=spi_d) signal, or -1 if not used. + int data0_io_num; ///< GPIO pin for spi data0 signal in quad/octal mode, or -1 if not used. + }; + union { + int miso_io_num; ///< GPIO pin for Master In Slave Out (=spi_q) signal, or -1 if not used. + int data1_io_num; ///< GPIO pin for spi data1 signal in quad/octal mode, or -1 if not used. + }; + int sclk_io_num; ///< GPIO pin for SPI Clock signal, or -1 if not used. + union { + int quadwp_io_num; ///< GPIO pin for WP (Write Protect) signal, or -1 if not used. + int data2_io_num; ///< GPIO pin for spi data2 signal in quad/octal mode, or -1 if not used. + }; + union { + int quadhd_io_num; ///< GPIO pin for HD (Hold) signal, or -1 if not used. + int data3_io_num; ///< GPIO pin for spi data3 signal in quad/octal mode, or -1 if not used. + }; + int data4_io_num; ///< GPIO pin for spi data4 signal in octal mode, or -1 if not used. + int data5_io_num; ///< GPIO pin for spi data5 signal in octal mode, or -1 if not used. + int data6_io_num; ///< GPIO pin for spi data6 signal in octal mode, or -1 if not used. + int data7_io_num; ///< GPIO pin for spi data7 signal in octal mode, or -1 if not used. + int max_transfer_sz; ///< Maximum transfer size, in bytes. Defaults to 4092 if 0 when DMA enabled, or to `SOC_SPI_MAXIMUM_BUFFER_SIZE` if DMA is disabled. + uint32_t flags; ///< Abilities of bus to be checked by the driver. Or-ed value of ``SPICOMMON_BUSFLAG_*`` flags. + int intr_flags; /**< Interrupt flag for the bus to set the priority, and IRAM attribute, see + * ``esp_intr_alloc.h``. Note that the EDGE, INTRDISABLED attribute are ignored + * by the driver. Note that if ESP_INTR_FLAG_IRAM is set, ALL the callbacks of + * the driver, and their callee functions, should be put in the IRAM. + */ } spi_bus_config_t; diff --git a/tools/sdk/esp32/include/driver/include/driver/spi_common_internal.h b/tools/sdk/esp32/include/driver/include/driver/spi_common_internal.h index 31baaa75d70..90826c0a8e9 100644 --- a/tools/sdk/esp32/include/driver/include/driver/spi_common_internal.h +++ b/tools/sdk/esp32/include/driver/include/driver/spi_common_internal.h @@ -155,6 +155,8 @@ esp_err_t spicommon_slave_free_dma(spi_host_device_t host_id); * - ``SPICOMMON_BUSFLAG_DUAL``: Make sure both MISO and MOSI are output capable so that DIO mode is capable. * - ``SPICOMMON_BUSFLAG_WPHD`` Make sure WP and HD are set to valid output GPIOs. * - ``SPICOMMON_BUSFLAG_QUAD``: Combination of ``SPICOMMON_BUSFLAG_DUAL`` and ``SPICOMMON_BUSFLAG_WPHD``. + * - ``SPICOMMON_BUSFLAG_IO4_IO7``: Make sure spi data4 ~ spi data7 are set to valid output GPIOs. + * - ``SPICOMMON_BUSFLAG_OCTAL``: Combination of ``SPICOMMON_BUSFLAG_QUAL`` and ``SPICOMMON_BUSFLAG_IO4_IO7``. * @param[out] flags_o A SPICOMMON_BUSFLAG_* flag combination of bus abilities will be written to this address. * Leave to NULL if not needed. * - ``SPICOMMON_BUSFLAG_IOMUX_PINS``: The bus is connected to iomux pins. @@ -163,6 +165,8 @@ esp_err_t spicommon_slave_free_dma(spi_host_device_t host_id); * - ``SPICOMMON_BUSFLAG_DUAL``: The bus is capable with DIO mode. * - ``SPICOMMON_BUSFLAG_WPHD`` The bus has WP and HD connected. * - ``SPICOMMON_BUSFLAG_QUAD``: Combination of ``SPICOMMON_BUSFLAG_DUAL`` and ``SPICOMMON_BUSFLAG_WPHD``. + * - ``SPICOMMON_BUSFLAG_IO4_IO7``: The bus has spi data4 ~ spi data7 connected. + * - ``SPICOMMON_BUSFLAG_OCTAL``: Combination of ``SPICOMMON_BUSFLAG_QUAL`` and ``SPICOMMON_BUSFLAG_IO4_IO7``. * @return * - ESP_ERR_INVALID_ARG if parameter is invalid * - ESP_OK on success diff --git a/tools/sdk/esp32/include/driver/include/driver/spi_master.h b/tools/sdk/esp32/include/driver/include/driver/spi_master.h index 8582a332766..d6a202f848a 100644 --- a/tools/sdk/esp32/include/driver/include/driver/spi_master.h +++ b/tools/sdk/esp32/include/driver/include/driver/spi_master.h @@ -104,8 +104,11 @@ typedef struct { #define SPI_TRANS_VARIABLE_CMD (1<<5) ///< Use the ``command_bits`` in ``spi_transaction_ext_t`` rather than default value in ``spi_device_interface_config_t``. #define SPI_TRANS_VARIABLE_ADDR (1<<6) ///< Use the ``address_bits`` in ``spi_transaction_ext_t`` rather than default value in ``spi_device_interface_config_t``. #define SPI_TRANS_VARIABLE_DUMMY (1<<7) ///< Use the ``dummy_bits`` in ``spi_transaction_ext_t`` rather than default value in ``spi_device_interface_config_t``. -#define SPI_TRANS_SET_CD (1<<7) ///< Set the CD pin #define SPI_TRANS_CS_KEEP_ACTIVE (1<<8) ///< Keep CS active after data transfer +#define SPI_TRANS_MULTILINE_CMD (1<<9) ///< The data lines used at command phase is the same as data phase (otherwise, only one data line is used at command phase) +#define SPI_TRANS_MODE_OCT (1<<10) ///< Transmit/receive data in 8-bit mode +#define SPI_TRANS_MULTILINE_ADDR SPI_TRANS_MODE_DIOQIO_ADDR ///< The data lines used at address phase is the same as data phase (otherwise, only one data line is used at address phase) + /** * This structure describes one SPI transaction. The descriptor should not be modified until the transaction finishes. */ @@ -148,7 +151,7 @@ typedef struct { } spi_transaction_ext_t ; -typedef struct spi_device_t* spi_device_handle_t; ///< Handle for a device on a SPI bus +typedef struct spi_device_t *spi_device_handle_t; ///< Handle for a device on a SPI bus /** * @brief Allocate a device on a SPI bus * @@ -341,7 +344,7 @@ void spi_device_release_bus(spi_device_handle_t dev); * * @return Actual working frequency that most fit. */ -int spi_cal_clock(int fapb, int hz, int duty_cycle, uint32_t* reg_o) __attribute__((deprecated)); +int spi_cal_clock(int fapb, int hz, int duty_cycle, uint32_t *reg_o) __attribute__((deprecated)); /** * @brief Calculate the working frequency that is most close to desired frequency. @@ -368,7 +371,7 @@ int spi_get_actual_clock(int fapb, int hz, int duty_cycle); * * @note If **dummy_o* is not zero, it means dummy bits should be applied in half duplex mode, and full duplex mode may not work. */ -void spi_get_timing(bool gpio_is_used, int input_delay_ns, int eff_clk, int* dummy_o, int* cycles_remain_o); +void spi_get_timing(bool gpio_is_used, int input_delay_ns, int eff_clk, int *dummy_o, int *cycles_remain_o); /** * @brief Get the frequency limit of current configurations. diff --git a/tools/sdk/esp32/include/driver/include/driver/timer.h b/tools/sdk/esp32/include/driver/include/driver/timer.h index 204fc9db27d..a3ab39267cd 100644 --- a/tools/sdk/esp32/include/driver/include/driver/timer.h +++ b/tools/sdk/esp32/include/driver/include/driver/timer.h @@ -130,8 +130,9 @@ esp_err_t timer_set_counter_mode(timer_group_t group_num, timer_idx_t timer_num, esp_err_t timer_set_auto_reload(timer_group_t group_num, timer_idx_t timer_num, timer_autoreload_t reload); /** - * @brief Set hardware timer source clock divider. Timer groups clock are divider from APB clock. - * + * @brief Set hardware divider of the source clock to the timer group. + * By default, the source clock is APB clock running at 80 MHz. + * For more information, please check Chapter Reset and Clock in Chip Technical Reference Manual. * @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1 * @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1] * @param divider Timer clock divider value. The divider's range is from from 2 to 65536. diff --git a/tools/sdk/esp32/include/driver/include/driver/twai.h b/tools/sdk/esp32/include/driver/include/driver/twai.h index ce616fe1251..70f88a4da10 100644 --- a/tools/sdk/esp32/include/driver/include/driver/twai.h +++ b/tools/sdk/esp32/include/driver/include/driver/twai.h @@ -47,23 +47,24 @@ extern "C" { */ #define TWAI_ALERT_TX_IDLE 0x00000001 /**< Alert(1): No more messages to transmit */ #define TWAI_ALERT_TX_SUCCESS 0x00000002 /**< Alert(2): The previous transmission was successful */ -#define TWAI_ALERT_BELOW_ERR_WARN 0x00000004 /**< Alert(4): Both error counters have dropped below error warning limit */ -#define TWAI_ALERT_ERR_ACTIVE 0x00000008 /**< Alert(8): TWAI controller has become error active */ -#define TWAI_ALERT_RECOVERY_IN_PROGRESS 0x00000010 /**< Alert(16): TWAI controller is undergoing bus recovery */ -#define TWAI_ALERT_BUS_RECOVERED 0x00000020 /**< Alert(32): TWAI controller has successfully completed bus recovery */ -#define TWAI_ALERT_ARB_LOST 0x00000040 /**< Alert(64): The previous transmission lost arbitration */ -#define TWAI_ALERT_ABOVE_ERR_WARN 0x00000080 /**< Alert(128): One of the error counters have exceeded the error warning limit */ -#define TWAI_ALERT_BUS_ERROR 0x00000100 /**< Alert(256): A (Bit, Stuff, CRC, Form, ACK) error has occurred on the bus */ -#define TWAI_ALERT_TX_FAILED 0x00000200 /**< Alert(512): The previous transmission has failed (for single shot transmission) */ -#define TWAI_ALERT_RX_QUEUE_FULL 0x00000400 /**< Alert(1024): The RX queue is full causing a frame to be lost */ -#define TWAI_ALERT_ERR_PASS 0x00000800 /**< Alert(2048): TWAI controller has become error passive */ -#define TWAI_ALERT_BUS_OFF 0x00001000 /**< Alert(4096): Bus-off condition occurred. TWAI controller can no longer influence bus */ -#define TWAI_ALERT_RX_FIFO_OVERRUN 0x00002000 /**< Alert(8192): An RX FIFO overrun has occurred */ -#define TWAI_ALERT_TX_RETRIED 0x00004000 /**< Alert(16384): An message transmission was cancelled and retried due to an errata workaround */ -#define TWAI_ALERT_PERIPH_RESET 0x00008000 /**< Alert(32768): The TWAI controller was reset */ -#define TWAI_ALERT_ALL 0x0000FFFF /**< Bit mask to enable all alerts during configuration */ +#define TWAI_ALERT_RX_DATA 0x00000004 /**< Alert(4): A frame has been received and added to the RX queue */ +#define TWAI_ALERT_BELOW_ERR_WARN 0x00000008 /**< Alert(8): Both error counters have dropped below error warning limit */ +#define TWAI_ALERT_ERR_ACTIVE 0x00000010 /**< Alert(16): TWAI controller has become error active */ +#define TWAI_ALERT_RECOVERY_IN_PROGRESS 0x00000020 /**< Alert(32): TWAI controller is undergoing bus recovery */ +#define TWAI_ALERT_BUS_RECOVERED 0x00000040 /**< Alert(64): TWAI controller has successfully completed bus recovery */ +#define TWAI_ALERT_ARB_LOST 0x00000080 /**< Alert(128): The previous transmission lost arbitration */ +#define TWAI_ALERT_ABOVE_ERR_WARN 0x00000100 /**< Alert(256): One of the error counters have exceeded the error warning limit */ +#define TWAI_ALERT_BUS_ERROR 0x00000200 /**< Alert(512): A (Bit, Stuff, CRC, Form, ACK) error has occurred on the bus */ +#define TWAI_ALERT_TX_FAILED 0x00000400 /**< Alert(1024): The previous transmission has failed (for single shot transmission) */ +#define TWAI_ALERT_RX_QUEUE_FULL 0x00000800 /**< Alert(2048): The RX queue is full causing a frame to be lost */ +#define TWAI_ALERT_ERR_PASS 0x00001000 /**< Alert(4096): TWAI controller has become error passive */ +#define TWAI_ALERT_BUS_OFF 0x00002000 /**< Alert(8192): Bus-off condition occurred. TWAI controller can no longer influence bus */ +#define TWAI_ALERT_RX_FIFO_OVERRUN 0x00004000 /**< Alert(16384): An RX FIFO overrun has occurred */ +#define TWAI_ALERT_TX_RETRIED 0x00008000 /**< Alert(32768): An message transmission was cancelled and retried due to an errata workaround */ +#define TWAI_ALERT_PERIPH_RESET 0x00010000 /**< Alert(65536): The TWAI controller was reset */ +#define TWAI_ALERT_ALL 0x0001FFFF /**< Bit mask to enable all alerts during configuration */ #define TWAI_ALERT_NONE 0x00000000 /**< Bit mask to disable all alerts during configuration */ -#define TWAI_ALERT_AND_LOG 0x00010000 /**< Bit mask to enable alerts to also be logged when they occur. Note that logging from the ISR is disabled if CONFIG_TWAI_ISR_IN_IRAM is enabled (see docs). */ +#define TWAI_ALERT_AND_LOG 0x00020000 /**< Bit mask to enable alerts to also be logged when they occur. Note that logging from the ISR is disabled if CONFIG_TWAI_ISR_IN_IRAM is enabled (see docs). */ /** @endcond */ diff --git a/tools/sdk/esp32/include/driver/include/driver/uart.h b/tools/sdk/esp32/include/driver/include/driver/uart.h index 311f21a8334..76aa424fa27 100644 --- a/tools/sdk/esp32/include/driver/include/driver/uart.h +++ b/tools/sdk/esp32/include/driver/include/driver/uart.h @@ -28,7 +28,10 @@ extern "C" { #endif #define UART_NUM_MAX (SOC_UART_NUM) /*!< UART port max */ -#define UART_PIN_NO_CHANGE (-1) /*!< Constant for uart_set_pin function which indicates that UART pin should not be changed */ +/* @brief When calling `uart_set_pin`, instead of GPIO number, `UART_PIN_NO_CHANGE` + * can be provided to keep the currently allocated pin. + */ +#define UART_PIN_NO_CHANGE (-1) #define UART_FIFO_LEN SOC_UART_FIFO_LEN ///< Length of the UART HW FIFO #define UART_BITRATE_MAX SOC_UART_BITRATE_MAX ///< Maximum configurable bitrate @@ -380,14 +383,23 @@ esp_err_t uart_isr_register(uart_port_t uart_num, void (*fn)(void*), void * arg, esp_err_t uart_isr_free(uart_port_t uart_num); /** - * @brief Set UART pin number + * @brief Assign signals of a UART peripheral to GPIO pins + * + * @note If the GPIO number configured for a UART signal matches one of the + * IOMUX signals for that GPIO, the signal will be connected directly + * via the IOMUX. Otherwise the GPIO and signal will be connected via + * the GPIO Matrix. For example, if on an ESP32 the call + * `uart_set_pin(0, 1, 3, -1, -1)` is performed, as GPIO1 is UART0's + * default TX pin and GPIO3 is UART0's default RX pin, both will be + * connected to respectively U0TXD and U0RXD through the IOMUX, totally + * bypassing the GPIO matrix. + * The check is performed on a per-pin basis. Thus, it is possible to have + * RX pin binded to a GPIO through the GPIO matrix, whereas TX is binded + * to its GPIO through the IOMUX. * * @note Internal signal can be output to multiple GPIO pads. * Only one GPIO pad can connect with input signal. * - * @note Instead of GPIO number a macro 'UART_PIN_NO_CHANGE' may be provided - to keep the currently allocated pin. - * * @param uart_num UART port number, the max port number is (UART_NUM_MAX -1). * @param tx_io_num UART TX pin GPIO number. * @param rx_io_num UART RX pin GPIO number. diff --git a/tools/sdk/esp32/include/driver/include/esp_private/i2s_platform.h b/tools/sdk/esp32/include/driver/include/esp_private/i2s_platform.h new file mode 100644 index 00000000000..ff1ebdf17a6 --- /dev/null +++ b/tools/sdk/esp32/include/driver/include/esp_private/i2s_platform.h @@ -0,0 +1,48 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +// DO NOT USE THESE APIS IN YOUR APPLICATIONS +// The following APIs are for internal use, public to other IDF components, but not for users' applications. + +#pragma once + +#include "esp_err.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Register an I2S or I2S variant driver object to platform + * + * @note This private API is used to avoid applications from using the same I2S instance for different purpose. + * @note This function will help enable the peripheral APB clock as well. + * + * @param driver_obj Driver object + * @param port_id I2S port number + * @return + * - ESP_OK: The specific I2S port is free and register the new device object successfully + * - ESP_ERR_INVALID_ARG: Invalid argument, e.g. wrong port_id + * - ESP_ERR_NOT_FOUND: Specific I2S port is not available + */ +esp_err_t i2s_priv_register_object(void *driver_obj, int port_id); + +/** + * @brief Deregister I2S or I2S variant driver object from platform + * + * @note This function will help disable the peripheral APB clock as well. + * + * @param port_id I2S port number + * @return + * - ESP_OK: Deregister I2S port successfully (i.e. that I2S port can used used by other users after this function returns) + * - ESP_ERR_INVALID_ARG: Invalid argument, e.g. wrong port_id + * - ESP_ERR_INVALID_STATE: Specific I2S port is free already + */ +esp_err_t i2s_priv_deregister_object(int port_id); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32/include/esp-dsp/modules/fft/include/dsps_fft2r.h b/tools/sdk/esp32/include/esp-dsp/modules/fft/include/dsps_fft2r.h index 01e9e03d620..da306bf13b3 100644 --- a/tools/sdk/esp32/include/esp-dsp/modules/fft/include/dsps_fft2r.h +++ b/tools/sdk/esp32/include/esp-dsp/modules/fft/include/dsps_fft2r.h @@ -72,8 +72,8 @@ esp_err_t dsps_fft2r_init_sc16(int16_t *fft_table_buff, int table_size); * * @return */ -void dsps_fft2r_deinit_fc32(); -void dsps_fft2r_deinit_sc16(); +void dsps_fft2r_deinit_fc32(void); +void dsps_fft2r_deinit_sc16(void); /**@}*/ /**@{*/ diff --git a/tools/sdk/esp32/include/esp-dsp/modules/fft/include/dsps_fft4r.h b/tools/sdk/esp32/include/esp-dsp/modules/fft/include/dsps_fft4r.h index c7d91408b04..0f87b6f0f5d 100644 --- a/tools/sdk/esp32/include/esp-dsp/modules/fft/include/dsps_fft4r.h +++ b/tools/sdk/esp32/include/esp-dsp/modules/fft/include/dsps_fft4r.h @@ -67,7 +67,7 @@ esp_err_t dsps_fft4r_init_fc32(float *fft_table_buff, int max_fft_size); * * @return */ -void dsps_fft4r_deinit_fc32(); +void dsps_fft4r_deinit_fc32(void); /**@}*/ /**@{*/ diff --git a/tools/sdk/esp32/include/esp-face/face_detection/include/fd_forward.h b/tools/sdk/esp32/include/esp-face/face_detection/include/fd_forward.h deleted file mode 100644 index 878c8c481c8..00000000000 --- a/tools/sdk/esp32/include/esp-face/face_detection/include/fd_forward.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * ESPRESSIF MIT License - * - * Copyright (c) 2018 - * - * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, - * it is 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. - * - */ -#pragma once - -#if __cplusplus -extern "C" -{ -#endif - -#include "image_util.h" -#include "dl_lib_matrix3d.h" -#include "mtmn.h" - - typedef enum - { - FAST = 0, /*!< fast resize type */ - NORMAL = 1, /*!< normal resize type */ - } mtmn_resize_type; - - typedef struct - { - float score; /*!< score threshold for filter candidates by score */ - float nms; /*!< nms threshold for nms process */ - int candidate_number; /*!< candidate number limitation for each net */ - } threshold_config_t; - - typedef struct - { - int w; /*!< net width */ - int h; /*!< net height */ - threshold_config_t threshold; /*!< threshold of net */ - } net_config_t; - - typedef struct - { - float min_face; /*!< The minimum size of a detectable face */ - float pyramid; /*!< The scale of the gradient scaling for the input images */ - int pyramid_times; /*!< The pyramid resizing times */ - threshold_config_t p_threshold; /*!< The thresholds for P-Net. For details, see the definition of threshold_config_t */ - threshold_config_t r_threshold; /*!< The thresholds for R-Net. For details, see the definition of threshold_config_t */ - threshold_config_t o_threshold; /*!< The thresholds for O-Net. For details, see the definition of threshold_config_t */ - mtmn_resize_type type; /*!< The image resize type. 'pyramid' will lose efficacy, when 'type'==FAST. */ - } mtmn_config_t; - - /** - * @brief Get the initial MTMN model configuration - * - * @return mtmn_config_t MTMN configuration - */ - static inline mtmn_config_t mtmn_init_config() - { - mtmn_config_t mtmn_config; - mtmn_config.type = FAST; - mtmn_config.min_face = 80; - mtmn_config.pyramid = 0.707; - mtmn_config.pyramid_times = 4; - mtmn_config.p_threshold.score = 0.6; - mtmn_config.p_threshold.nms = 0.7; - mtmn_config.p_threshold.candidate_number = 20; - mtmn_config.r_threshold.score = 0.7; - mtmn_config.r_threshold.nms = 0.7; - mtmn_config.r_threshold.candidate_number = 10; - mtmn_config.o_threshold.score = 0.7; - mtmn_config.o_threshold.nms = 0.7; - mtmn_config.o_threshold.candidate_number = 1; - - return mtmn_config; - } - - /** - * @brief Do MTMN face detection, return box and landmark infomation. - * - * @param image_matrix Image matrix, rgb888 format - * @param config Configuration of MTMN i.e. score threshold, nms threshold, candidate number threshold, pyramid, min face size - * @return box_array_t* A list of boxes and score. - */ - box_array_t *face_detect(dl_matrix3du_t *image_matrix, - mtmn_config_t *config); - -#if __cplusplus -} -#endif diff --git a/tools/sdk/esp32/include/esp-face/face_recognition/include/fr_flash.h b/tools/sdk/esp32/include/esp-face/face_recognition/include/fr_flash.h deleted file mode 100644 index 5da0ddcc182..00000000000 --- a/tools/sdk/esp32/include/esp-face/face_recognition/include/fr_flash.h +++ /dev/null @@ -1,82 +0,0 @@ -#pragma once - -#if __cplusplus -extern "C" -{ -#endif - -#include "fr_forward.h" - -#define FR_FLASH_TYPE 32 -#define FR_FLASH_SUBTYPE 32 -#define FR_FLASH_PARTITION_NAME "fr" -#define FR_FLASH_INFO_FLAG 12138 - - /** - * @brief Produce face id according to the input aligned face, and save it to dest_id and flash. - * - * @param l Face id list - * @param aligned_face An aligned face - * @return -2 Flash partition not found - * @return 0 Enrollment finish - * @return >=1 The left piece of aligned faces should be input - */ - int8_t enroll_face_id_to_flash(face_id_list *l, - dl_matrix3du_t *aligned_face); - - /** - * @brief Produce face id according to the input aligned face, and save the id-name pairs to dest_id and flash. - * - * @param l Face id list - * @param new_id An aligned face - * @param name name corresponding to face id - * @return -2 Flash partition not found - * @return 0 Enrollment finish - * @return >=1 The left piece of aligned faces should be input - */ - int8_t enroll_face_id_to_flash_with_name(face_id_name_list *l, - dl_matrix3d_t *new_id, - char *name); - /** - * @brief Read the enrolled face IDs from the flash. - * - * @param l Face id list - * @return int8_t The number of IDs remaining in flash - */ - int8_t read_face_id_from_flash(face_id_list *l); - - /** - * @brief Read the enrolled face IDs and their corresponding names from the flash. - * - * @param l Face id list - * @return int8_t The number of IDs remaining in flash - */ - int8_t read_face_id_from_flash_with_name(face_id_name_list *l); - - /** - * @brief Delete the enrolled face IDs in the flash. - * - * @param l Face id list - * @return int8_t The number of IDs remaining in flash - */ - int8_t delete_face_id_in_flash(face_id_list *l); - - /** - * @brief Delete the enrolled face ID corresponding to the name in the flash. - * - * @param l Face id list - * @param name The name that needs to be deleted - * @return int8_t The number of IDs remaining in flash - */ - int8_t delete_face_id_in_flash_with_name(face_id_name_list *l, char *name); - - /** - * @brief Delete all the enrolled face IDs and names paris in the flash. - * - * @param l Face id list - */ - void delete_face_all_in_flash_with_name(face_id_name_list *l); - -#if __cplusplus -} -#endif diff --git a/tools/sdk/esp32/include/esp-face/face_recognition/include/fr_forward.h b/tools/sdk/esp32/include/esp-face/face_recognition/include/fr_forward.h deleted file mode 100644 index 32c55168eb6..00000000000 --- a/tools/sdk/esp32/include/esp-face/face_recognition/include/fr_forward.h +++ /dev/null @@ -1,194 +0,0 @@ -#pragma once - -#if __cplusplus -extern "C" -{ -#endif - -#include "image_util.h" -#include "dl_lib_matrix3d.h" -#include "frmn.h" - -#define FACE_WIDTH 56 -#define FACE_HEIGHT 56 -#define FACE_ID_SIZE 512 -#define FACE_REC_THRESHOLD 0.55 - -#define LEFT_EYE_X 0 -#define LEFT_EYE_Y 1 -#define RIGHT_EYE_X 6 -#define RIGHT_EYE_Y 7 -#define NOSE_X 4 -#define NOSE_Y 5 -#define LEFT_MOUTH_X 2 -#define LEFT_MOUTH_Y 3 -#define RIGHT_MOUTH_X 8 -#define RIGHT_MOUTH_Y 9 - -#define EYE_DIST_SET 16.5f -#define NOSE_EYE_RATIO_THRES_MIN 0.49f -#define NOSE_EYE_RATIO_THRES_MAX 2.04f - - -#define ENROLL_NAME_LEN 16 - typedef struct tag_face_id_node - { - struct tag_face_id_node *next; /*!< next face id node */ - char id_name[ENROLL_NAME_LEN]; /*!< name corresponding to the face id */ - dl_matrix3d_t *id_vec; /*!< face id */ - } face_id_node; - - typedef struct - { - face_id_node *head; /*!< head pointer of the id list */ - face_id_node *tail; /*!< tail pointer of the id list */ - uint8_t count; /*!< number of enrolled ids */ - uint8_t confirm_times; /*!< images needed for one enrolling */ - } face_id_name_list; - - typedef struct - { - uint8_t head; /*!< head index of the id list */ - uint8_t tail; /*!< tail index of the id list */ - uint8_t count; /*!< number of enrolled ids */ - uint8_t size; /*!< max len of id list */ - uint8_t confirm_times; /*!< images needed for one enrolling */ - dl_matrix3d_t **id_list; /*!< stores face id vectors */ - } face_id_list; - - /** - * @brief Initialize face id list. - * - * @param l Face id list - * @param size Size of list, one list contains one vector - * @param confirm_times Enroll times for one id - */ - void face_id_init(face_id_list *l, uint8_t size, uint8_t confirm_times); - - /** - * @brief Initialize face id list with name. - * - * @param l Face id list - * @param size Size of list, one list contains one vector - * @param confirm_times Enroll times for one id - */ - void face_id_name_init(face_id_name_list *l, uint8_t size, uint8_t confirm_times); - - /** - * @brief Alloc memory for aligned face. - * - * @return dl_matrix3du_t* Size: 1xFACE_WIDTHxFACE_HEIGHTx3 - */ - dl_matrix3du_t *aligned_face_alloc(); - - /**@{*/ - /** - * @brief Align detected face to average face according to landmark. - * - * @param onet_boxes Output of MTMN with box and landmark - * @param src Image matrix, rgb888 format - * @param dest Output image - * @return ESP_OK Input face is good for recognition - * @return ESP_FAIL Input face is not good for recognition - */ - int8_t align_face_rot(box_array_t *onet_boxes, - dl_matrix3du_t *src, - dl_matrix3du_t *dest); - - int8_t align_face_sim(box_array_t *onet_boxes, - dl_matrix3du_t *src, - dl_matrix3du_t *dest); - - inline int8_t align_face(box_array_t *onet_boxes, - dl_matrix3du_t *src, - dl_matrix3du_t *dest) - { - return align_face_sim(onet_boxes, src, dest); - } - /**@}*/ - - /** - * @brief Run the face recognition model to get the face feature - * - * @param aligned_face A 56x56x3 image, the variable need to do align_face first - * @return face_id A 512 vector, size (1, 1, 1, 512) - */ - dl_matrix3d_t *get_face_id(dl_matrix3du_t *aligned_face); - - /** - * @brief Add src_id to dest_id - * - * @param dest_id Face id after accumulation - * @param src_id Face id to be added - */ - void add_face_id(dl_matrix3d_t *dest_id, - dl_matrix3d_t *src_id); - - /** - * @brief Match face with the id_list, and return matched_id. - * - * @param l An ID list - * @param algined_face An aligned face - * @return int8_t Matched face id - */ - int8_t recognize_face(face_id_list *l, dl_matrix3du_t *algined_face); - - /** - * @brief Match face id with the id_list, and return matched face id node. - * - * @param l - * @param face_id - * @return face_id_node* - */ - face_id_node *recognize_face_with_name(face_id_name_list *l, dl_matrix3d_t *face_id); - - /** - * @brief Produce face id according to the input aligned face, and save it to dest_id. - * - * @param l Face id list - * @param aligned_face An aligned face - * @param enroll_confirm_times Confirm times for each face id enrollment - * @return -1 Wrong input enroll_confirm_times - * @return 0 Enrollment finish - * @return >=1 The left piece of aligned faces should be input - */ - int8_t enroll_face(face_id_list *l, dl_matrix3du_t *aligned_face); - - /** - * @brief Produce face id according to the input aligned face, and save the id-name pairs to dest_id - * - * @param l Face id list with name - * @param new_id A face id that need to be enrolled - * @param name name corresponding to the face id - * @return int8_t The left piece of aligned faces should be input - */ - int8_t enroll_face_with_name(face_id_name_list *l, - dl_matrix3d_t *new_id, - char *name); - - /** - * @brief Delete the enrolled face IDs - * - * @param l Face id list - * @return uint8_t The number of IDs remaining in face id list - */ - uint8_t delete_face(face_id_list *l); - - /** - * @brief Delete the enrolled face IDs and associated names - * - * @param l Face id list - * @param name The name that needs to be deleted - * @return int8_t The number of IDs remaining in face id list - */ - int8_t delete_face_with_name(face_id_name_list *l, char *name); - - /** - * @brief Delete all the enrolled face IDs and names paris - * - * @param l Face id list with names - */ - void delete_face_all_with_name(face_id_name_list *l); -#if __cplusplus -} -#endif diff --git a/tools/sdk/esp32/include/esp-face/image_util/include/esp_image.hpp b/tools/sdk/esp32/include/esp-face/image_util/include/esp_image.hpp deleted file mode 100644 index f5f924d6b6a..00000000000 --- a/tools/sdk/esp32/include/esp-face/image_util/include/esp_image.hpp +++ /dev/null @@ -1,344 +0,0 @@ -/* - * ESPRESSIF MIT License - * - * Copyright (c) 2018 - * - * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, - * it is 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. - * - */ -#pragma once - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -#include -#include - -#ifdef __cplusplus -} -#endif - -typedef enum -{ - IMAGE_RESIZE_BILINEAR = 0, /* -class Image -{ -public: - /** - * @brief Convert a RGB565 pixel to RGB888 - * - * @param input Pixel value in RGB565 - * @param output Pixel value in RGB888 - */ - static inline void pixel_rgb565_to_rgb888(uint16_t input, T *output) - { - output[2] = (input & 0x1F00) >> 5; //blue - output[1] = ((input & 0x7) << 5) | ((input & 0xE000) >> 11); //green - output[0] = input & 0xF8; //red - }; - - /** - * @brief Resize a RGB565 image to a RGB88 image - * - * @param dst_image The destination image - * @param y_start The start y index of where resized image located - * @param y_end The end y index of where resized image located - * @param x_start The start x index of where resized image located - * @param x_end The end x index of where resized image located - * @param channel The channel number of image - * @param src_image The source image - * @param src_h The height of source image - * @param src_w The width of source image - * @param dst_w The width of destination image - * @param shift_left The bit number of left shifting - * @param type The resize type - */ - static void resize_to_rgb888(T *dst_image, int y_start, int y_end, int x_start, int x_end, int channel, uint16_t *src_image, int src_h, int src_w, int dst_w, int shift_left, image_resize_t type); - - /** - * @brief Resize a RGB888 image to a RGB88 image - * - * @param dst_image The destination image - * @param y_start The start y index of where resized image located - * @param y_end The end y index of where resized image located - * @param x_start The start x index of where resized image located - * @param x_end The end x index of where resized image located - * @param channel The channel number of image - * @param src_image The source image - * @param src_h The height of source image - * @param src_w The width of source image - * @param dst_w The width of destination image - * @param shift_left The bit number of left shifting - * @param type The resize type - */ - static void resize_to_rgb888(T *dst_image, int y_start, int y_end, int x_start, int x_end, int channel, uint8_t *src_image, int src_h, int src_w, int dst_w, int shift_left, image_resize_t type); - // static void resize_to_rgb565(uint16_t *dst_image, int y_start, int y_end, int x_start, int x_end, int channel, uint16_t *src_image, int src_h, int src_w, int dst_w, int shift_left, image_resize_t type); - // static void resize_to_rgb565(uint16_t *dst_image, int y_start, int y_end, int x_start, int x_end, int channel, uint8_t *src_image, int src_h, int src_w, int dst_w, int shift_left, image_resize_t type); -}; - -template -void Image::resize_to_rgb888(T *dst_image, int y_start, int y_end, int x_start, int x_end, int channel, uint16_t *src_image, int src_h, int src_w, int dst_w, int shift_left, image_resize_t type) -{ - assert(channel == 3); - float scale_y = (float)src_h / (y_end - y_start); - float scale_x = (float)src_w / (x_end - x_start); - int temp[13]; - - switch (type) - { - case IMAGE_RESIZE_BILINEAR: - for (size_t y = y_start; y < y_end; y++) - { - float ratio_y[2]; - ratio_y[0] = (float)((y + 0.5) * scale_y - 0.5); // y - int src_y = (int)ratio_y[0]; // y1 - ratio_y[0] -= src_y; // y - y1 - - if (src_y < 0) - { - ratio_y[0] = 0; - src_y = 0; - } - if (src_y > src_h - 2) - { - ratio_y[0] = 0; - src_y = src_h - 2; - } - ratio_y[1] = 1 - ratio_y[0]; // y2 - y - - int _dst_i = y * dst_w; - - int _src_row_0 = src_y * src_w; - int _src_row_1 = _src_row_0 + src_w; - - for (size_t x = x_start; x < x_end; x++) - { - float ratio_x[2]; - ratio_x[0] = (float)((x + 0.5) * scale_x - 0.5); // x - int src_x = (int)ratio_x[0]; // x1 - ratio_x[0] -= src_x; // x - x1 - - if (src_x < 0) - { - ratio_x[0] = 0; - src_x = 0; - } - if (src_x > src_w - 2) - { - ratio_x[0] = 0; - src_x = src_w - 2; - } - ratio_x[1] = 1 - ratio_x[0]; // x2 - x - - int dst_i = (_dst_i + x) * channel; - - int src_row_0 = _src_row_0 + src_x; - int src_row_1 = _src_row_1 + src_x; - - Image::pixel_rgb565_to_rgb888(src_image[src_row_0], temp); - Image::pixel_rgb565_to_rgb888(src_image[src_row_0 + 1], temp + 3); - Image::pixel_rgb565_to_rgb888(src_image[src_row_1], temp + 6); - Image::pixel_rgb565_to_rgb888(src_image[src_row_1 + 1], temp + 9); - - for (int c = 0; c < channel; c++) - { - temp[12] = round(temp[c] * ratio_x[1] * ratio_y[1] + temp[channel + c] * ratio_x[0] * ratio_y[1] + temp[channel + channel + c] * ratio_x[1] * ratio_y[0] + src_image[channel + channel + channel + c] * ratio_x[0] * ratio_y[0]); - dst_image[dst_i + c] = (shift_left > 0) ? (temp[12] << shift_left) : (temp[12] >> -shift_left); - } - } - } - break; - - case IMAGE_RESIZE_MEAN: - shift_left -= 2; - for (int y = y_start; y < y_end; y++) - { - int _dst_i = y * dst_w; - - float _src_row_0 = rintf(y * scale_y) * src_w; - float _src_row_1 = _src_row_0 + src_w; - - for (int x = x_start; x < x_end; x++) - { - int dst_i = (_dst_i + x) * channel; - - int src_row_0 = (_src_row_0 + rintf(x * scale_x)); - int src_row_1 = (_src_row_1 + rintf(x * scale_x)); - - Image::pixel_rgb565_to_rgb888(src_image[src_row_0], temp); - Image::pixel_rgb565_to_rgb888(src_image[src_row_0 + 1], temp + 3); - Image::pixel_rgb565_to_rgb888(src_image[src_row_1], temp + 6); - Image::pixel_rgb565_to_rgb888(src_image[src_row_1 + 1], temp + 9); - - dst_image[dst_i] = (shift_left > 0) ? ((temp[0] + temp[3] + temp[6] + temp[9]) << shift_left) : ((temp[0] + temp[3] + temp[6] + temp[9]) >> -shift_left); - dst_image[dst_i + 1] = (shift_left > 0) ? ((temp[1] + temp[4] + temp[7] + temp[10]) << shift_left) : ((temp[1] + temp[4] + temp[7] + temp[10]) >> -shift_left); - dst_image[dst_i + 2] = (shift_left > 0) ? ((temp[2] + temp[5] + temp[8] + temp[11]) << shift_left) : ((temp[1] + temp[4] + temp[7] + temp[10]) >> -shift_left); - } - } - - break; - - case IMAGE_RESIZE_NEAREST: - for (size_t y = y_start; y < y_end; y++) - { - int _dst_i = y * dst_w; - float _src_i = rintf(y * scale_y) * src_w; - - for (size_t x = x_start; x < x_end; x++) - { - int dst_i = (_dst_i + x) * channel; - int src_i = _src_i + rintf(x * scale_x); - - Image::pixel_rgb565_to_rgb888(src_image[src_i], temp); - - dst_image[dst_i] = (shift_left > 0) ? (temp[0] << shift_left) : (temp[0] >> -shift_left); - dst_image[dst_i + 1] = (shift_left > 0) ? (temp[1] << shift_left) : (temp[1] >> -shift_left); - dst_image[dst_i + 2] = (shift_left > 0) ? (temp[2] << shift_left) : (temp[2] >> -shift_left); - } - } - break; - - default: - break; - } -} - -template -void Image::resize_to_rgb888(T *dst_image, int y_start, int y_end, int x_start, int x_end, int channel, uint8_t *src_image, int src_h, int src_w, int dst_w, int shift_left, image_resize_t type) -{ - float scale_y = (float)src_h / (y_end - y_start); - float scale_x = (float)src_w / (x_end - x_start); - int temp; - - switch (type) - { - case IMAGE_RESIZE_BILINEAR: - for (size_t y = y_start; y < y_end; y++) - { - float ratio_y[2]; - ratio_y[0] = (float)((y + 0.5) * scale_y - 0.5); // y - int src_y = (int)ratio_y[0]; // y1 - ratio_y[0] -= src_y; // y - y1 - - if (src_y < 0) - { - ratio_y[0] = 0; - src_y = 0; - } - if (src_y > src_h - 2) - { - ratio_y[0] = 0; - src_y = src_h - 2; - } - ratio_y[1] = 1 - ratio_y[0]; // y2 - y - - int _dst_i = y * dst_w; - - int _src_row_0 = src_y * src_w; - int _src_row_1 = _src_row_0 + src_w; - - for (size_t x = x_start; x < x_end; x++) - { - float ratio_x[2]; - ratio_x[0] = (float)((x + 0.5) * scale_x - 0.5); // x - int src_x = (int)ratio_x[0]; // x1 - ratio_x[0] -= src_x; // x - x1 - - if (src_x < 0) - { - ratio_x[0] = 0; - src_x = 0; - } - if (src_x > src_w - 2) - { - ratio_x[0] = 0; - src_x = src_w - 2; - } - ratio_x[1] = 1 - ratio_x[0]; // x2 - x - - int dst_i = (_dst_i + x) * channel; - - int src_row_0 = (_src_row_0 + src_x) * channel; - int src_row_1 = (_src_row_1 + src_x) * channel; - - for (int c = 0; c < channel; c++) - { - temp = round(src_image[src_row_0 + c] * ratio_x[1] * ratio_y[1] + src_image[src_row_0 + channel + c] * ratio_x[0] * ratio_y[1] + src_image[src_row_1 + c] * ratio_x[1] * ratio_y[0] + src_image[src_row_1 + channel + c] * ratio_x[0] * ratio_y[0]); - dst_image[dst_i + c] = (shift_left > 0) ? (temp << shift_left) : (temp >> -shift_left); - } - } - } - break; - - case IMAGE_RESIZE_MEAN: - shift_left -= 2; - - for (size_t y = y_start; y < y_end; y++) - { - int _dst_i = y * dst_w; - - float _src_row_0 = rintf(y * scale_y) * src_w; - float _src_row_1 = _src_row_0 + src_w; - - for (size_t x = x_start; x < x_end; x++) - { - int dst_i = (_dst_i + x) * channel; - - int src_row_0 = (_src_row_0 + rintf(x * scale_x)) * channel; - int src_row_1 = (_src_row_1 + rintf(x * scale_x)) * channel; - - for (size_t c = 0; c < channel; c++) - { - temp = (int)src_image[src_row_0 + c] + (int)src_image[src_row_0 + channel + c] + (int)src_image[src_row_1 + c] + (int)src_image[src_row_1 + channel + c]; - dst_image[dst_i + c] = (shift_left > 0) ? (temp << shift_left) : (temp >> -shift_left); - } - } - } - break; - - case IMAGE_RESIZE_NEAREST: - for (size_t y = y_start; y < y_end; y++) - { - int _dst_i = y * dst_w; - float _src_i = rintf(y * scale_y) * src_w; - - for (size_t x = x_start; x < x_end; x++) - { - int dst_i = (_dst_i + x) * channel; - int src_i = (_src_i + rintf(x * scale_x)) * channel; - - for (size_t c = 0; c < channel; c++) - { - dst_image[dst_i + c] = (shift_left > 0) ? ((T)src_image[src_i + c] << shift_left) : ((T)src_image[src_i + c] >> -shift_left); - } - } - } - break; - - default: - break; - } -} \ No newline at end of file diff --git a/tools/sdk/esp32/include/esp-face/image_util/include/image_util.h b/tools/sdk/esp32/include/esp-face/image_util/include/image_util.h deleted file mode 100644 index f997b34154b..00000000000 --- a/tools/sdk/esp32/include/esp-face/image_util/include/image_util.h +++ /dev/null @@ -1,548 +0,0 @@ -/* - * ESPRESSIF MIT License - * - * Copyright (c) 2018 - * - * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, - * it is 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. - * - */ -#pragma once -#ifdef __cplusplus -extern "C" -{ -#endif -#include -#include -#include "mtmn.h" - -#define LANDMARKS_NUM (10) - -#define MAX_VALID_COUNT_PER_IMAGE (30) - -#define DL_IMAGE_MIN(A, B) ((A) < (B) ? (A) : (B)) -#define DL_IMAGE_MAX(A, B) ((A) < (B) ? (B) : (A)) - -#define RGB565_MASK_RED 0xF800 -#define RGB565_MASK_GREEN 0x07E0 -#define RGB565_MASK_BLUE 0x001F - - typedef enum - { - BINARY, /*!< binary */ - } en_threshold_mode; - - typedef struct - { - fptp_t landmark_p[LANDMARKS_NUM]; /*!< landmark struct */ - } landmark_t; - - typedef struct - { - fptp_t box_p[4]; /*!< box struct */ - } box_t; - - typedef struct tag_box_list - { - uint8_t *category; /*!< The category of the corresponding box */ - fptp_t *score; /*!< The confidence score of the class corresponding to the box */ - box_t *box; /*!< Anchor boxes or predicted boxes*/ - landmark_t *landmark; /*!< The landmarks corresponding to the box */ - int len; /*!< The num of the boxes */ - } box_array_t; - - typedef struct tag_image_box - { - struct tag_image_box *next; /*!< Next image_box_t */ - uint8_t category; - fptp_t score; /*!< The confidence score of the class corresponding to the box */ - box_t box; /*!< Anchor boxes or predicted boxes */ - box_t offset; /*!< The predicted anchor-based offset */ - landmark_t landmark; /*!< The landmarks corresponding to the box */ - } image_box_t; - - typedef struct tag_image_list - { - image_box_t *head; /*!< The current head of the image_list */ - image_box_t *origin_head; /*!< The original head of the image_list */ - int len; /*!< Length of the image_list */ - } image_list_t; - - /** - * @brief Get the width and height of the box. - * - * @param box Input box - * @param w Resulting width of the box - * @param h Resulting height of the box - */ - static inline void image_get_width_and_height(box_t *box, float *w, float *h) - { - *w = box->box_p[2] - box->box_p[0] + 1; - *h = box->box_p[3] - box->box_p[1] + 1; - } - - /** - * @brief Get the area of the box. - * - * @param box Input box - * @param area Resulting area of the box - */ - static inline void image_get_area(box_t *box, float *area) - { - float w, h; - image_get_width_and_height(box, &w, &h); - *area = w * h; - } - - /** - * @brief calibrate the boxes by offset - * - * @param image_list Input boxes - * @param image_height Height of the original image - * @param image_width Width of the original image - */ - static inline void image_calibrate_by_offset(image_list_t *image_list, int image_height, int image_width) - { - for (image_box_t *head = image_list->head; head; head = head->next) - { - float w, h; - image_get_width_and_height(&(head->box), &w, &h); - head->box.box_p[0] = DL_IMAGE_MAX(0, head->box.box_p[0] + head->offset.box_p[0] * w); - head->box.box_p[1] = DL_IMAGE_MAX(0, head->box.box_p[1] + head->offset.box_p[1] * w); - head->box.box_p[2] += head->offset.box_p[2] * w; - if (head->box.box_p[2] > image_width) - { - head->box.box_p[2] = image_width - 1; - head->box.box_p[0] = image_width - w; - } - head->box.box_p[3] += head->offset.box_p[3] * h; - if (head->box.box_p[3] > image_height) - { - head->box.box_p[3] = image_height - 1; - head->box.box_p[1] = image_height - h; - } - } - } - - /** - * @brief calibrate the landmarks - * - * @param image_list Input landmarks - */ - static inline void image_landmark_calibrate(image_list_t *image_list) - { - for (image_box_t *head = image_list->head; head; head = head->next) - { - float w, h; - image_get_width_and_height(&(head->box), &w, &h); - head->landmark.landmark_p[0] = head->box.box_p[0] + head->landmark.landmark_p[0] * w; - head->landmark.landmark_p[1] = head->box.box_p[1] + head->landmark.landmark_p[1] * h; - - head->landmark.landmark_p[2] = head->box.box_p[0] + head->landmark.landmark_p[2] * w; - head->landmark.landmark_p[3] = head->box.box_p[1] + head->landmark.landmark_p[3] * h; - - head->landmark.landmark_p[4] = head->box.box_p[0] + head->landmark.landmark_p[4] * w; - head->landmark.landmark_p[5] = head->box.box_p[1] + head->landmark.landmark_p[5] * h; - - head->landmark.landmark_p[6] = head->box.box_p[0] + head->landmark.landmark_p[6] * w; - head->landmark.landmark_p[7] = head->box.box_p[1] + head->landmark.landmark_p[7] * h; - - head->landmark.landmark_p[8] = head->box.box_p[0] + head->landmark.landmark_p[8] * w; - head->landmark.landmark_p[9] = head->box.box_p[1] + head->landmark.landmark_p[9] * h; - } - } - - /** - * @brief Convert a rectangular box into a square box - * - * @param boxes Input box - * @param width Width of the orignal image - * @param height height of the orignal image - */ - static inline void image_rect2sqr(box_array_t *boxes, int width, int height) - { - for (int i = 0; i < boxes->len; i++) - { - box_t *box = &(boxes->box[i]); - - int x1 = round(box->box_p[0]); - int y1 = round(box->box_p[1]); - int x2 = round(box->box_p[2]); - int y2 = round(box->box_p[3]); - - int w = x2 - x1 + 1; - int h = y2 - y1 + 1; - int l = DL_IMAGE_MAX(w, h); - - box->box_p[0] = DL_IMAGE_MAX(round(DL_IMAGE_MAX(0, x1) + 0.5 * (w - l)), 0); - box->box_p[1] = DL_IMAGE_MAX(round(DL_IMAGE_MAX(0, y1) + 0.5 * (h - l)), 0); - - box->box_p[2] = box->box_p[0] + l - 1; - if (box->box_p[2] > width) - { - box->box_p[2] = width - 1; - box->box_p[0] = width - l; - } - box->box_p[3] = box->box_p[1] + l - 1; - if (box->box_p[3] > height) - { - box->box_p[3] = height - 1; - box->box_p[1] = height - l; - } - } - } - - /**@{*/ - /** - * @brief Convert RGB565 image to RGB888 image - * - * @param in Input RGB565 image - * @param dst Resulting RGB888 image - */ - static inline void rgb565_to_888(uint16_t in, uint8_t *dst) - { /*{{{*/ - in = (in & 0xFF) << 8 | (in & 0xFF00) >> 8; - dst[2] = (in & RGB565_MASK_BLUE) << 3; // blue - dst[1] = (in & RGB565_MASK_GREEN) >> 3; // green - dst[0] = (in & RGB565_MASK_RED) >> 8; // red - - // dst[0] = (in & 0x1F00) >> 5; - // dst[1] = ((in & 0x7) << 5) | ((in & 0xE000) >> 11); - // dst[2] = in & 0xF8; - } /*}}}*/ - - static inline void rgb565_to_888_q16(uint16_t in, int16_t *dst) - { /*{{{*/ - in = (in & 0xFF) << 8 | (in & 0xFF00) >> 8; - dst[2] = (in & RGB565_MASK_BLUE) << 3; // blue - dst[1] = (in & RGB565_MASK_GREEN) >> 3; // green - dst[0] = (in & RGB565_MASK_RED) >> 8; // red - - // dst[0] = (in & 0x1F00) >> 5; - // dst[1] = ((in & 0x7) << 5) | ((in & 0xE000) >> 11); - // dst[2] = in & 0xF8; - } /*}}}*/ - /**@}*/ - - /** - * @brief Convert RGB888 image to RGB565 image - * - * @param in Resulting RGB565 image - * @param r The red channel of the Input RGB888 image - * @param g The green channel of the Input RGB888 image - * @param b The blue channel of the Input RGB888 image - */ - static inline void rgb888_to_565(uint16_t *in, uint8_t r, uint8_t g, uint8_t b) - { /*{{{*/ - uint16_t rgb565 = 0; - rgb565 = ((r >> 3) << 11); - rgb565 |= ((g >> 2) << 5); - rgb565 |= (b >> 3); - rgb565 = (rgb565 & 0xFF) << 8 | (rgb565 & 0xFF00) >> 8; - *in = rgb565; - } /*}}}*/ - - /** - * @brief Filter out the resulting boxes whose confidence score is lower than the threshold and convert the boxes to the actual boxes on the original image.((x, y, w, h) -> (x1, y1, x2, y2)) - * - * @param score Confidence score of the boxes - * @param offset The predicted anchor-based offset - * @param landmark The landmarks corresponding to the box - * @param width Height of the original image - * @param height Width of the original image - * @param anchor_number Anchor number of the detection output feature map - * @param anchors_size The anchor size - * @param score_threshold Threshold of the confidence score - * @param stride - * @param resized_height_scale - * @param resized_width_scale - * @param do_regression - * @return image_list_t* - */ - image_list_t *image_get_valid_boxes(fptp_t *score, - fptp_t *offset, - fptp_t *landmark, - int width, - int height, - int anchor_number, - int *anchors_size, - fptp_t score_threshold, - int stride, - fptp_t resized_height_scale, - fptp_t resized_width_scale, - bool do_regression); - /** - * @brief Sort the resulting box lists by their confidence score. - * - * @param image_sorted_list The sorted box list. - * @param insert_list The box list that have not been sorted. - */ - void image_sort_insert_by_score(image_list_t *image_sorted_list, const image_list_t *insert_list); - - /** - * @brief Run NMS algorithm - * - * @param image_list The input boxes list - * @param nms_threshold NMS threshold - * @param same_area The flag of boxes with same area - */ - void image_nms_process(image_list_t *image_list, fptp_t nms_threshold, int same_area); - - /** - * @brief Resize an image to half size - * - * @param dimage The output image - * @param dw Width of the output image - * @param dh Height of the output image - * @param dc Channel of the output image - * @param simage Source image - * @param sw Width of the source image - * @param sc Channel of the source image - */ - void image_zoom_in_twice(uint8_t *dimage, - int dw, - int dh, - int dc, - uint8_t *simage, - int sw, - int sc); - - /** - * @brief Resize the image in RGB888 format via bilinear interpolation - * - * @param dst_image The output image - * @param src_image Source image - * @param dst_w Width of the output image - * @param dst_h Height of the output image - * @param dst_c Channel of the output image - * @param src_w Width of the source image - * @param src_h Height of the source image - */ - void image_resize_linear(uint8_t *dst_image, uint8_t *src_image, int dst_w, int dst_h, int dst_c, int src_w, int src_h); - - /** - * @brief Crop, rotate and zoom the image in RGB888 format, - * - * @param corp_image The output image - * @param src_image Source image - * @param rotate_angle Rotate angle - * @param ratio scaling ratio - * @param center Center of rotation - */ - void image_cropper(uint8_t *corp_image, uint8_t *src_image, int dst_w, int dst_h, int dst_c, int src_w, int src_h, float rotate_angle, float ratio, float *center); - - /** - * @brief Convert the rgb565 image to the rgb888 image - * - * @param m The output rgb888 image - * @param bmp The input rgb565 image - * @param count Total pixels of the rgb565 image - */ - void image_rgb565_to_888(uint8_t *m, uint16_t *bmp, int count); - - /** - * @brief Convert the rgb888 image to the rgb565 image - * - * @param bmp The output rgb565 image - * @param m The input rgb888 image - * @param count Total pixels of the rgb565 image - */ - void image_rgb888_to_565(uint16_t *bmp, uint8_t *m, int count); - - /** - * @brief draw rectangle on the rgb565 image - * - * @param buf Input image - * @param boxes Rectangle Boxes - * @param width Width of the input image - */ - void draw_rectangle_rgb565(uint16_t *buf, box_array_t *boxes, int width); - - /** - * @brief draw rectangle on the rgb888 image - * - * @param buf Input image - * @param boxes Rectangle Boxes - * @param width Width of the input image - */ - void draw_rectangle_rgb888(uint8_t *buf, box_array_t *boxes, int width); - - /** - * @brief Get the pixel difference of two images - * - * @param dst The output pixel difference - * @param src1 Input image 1 - * @param src2 Input image 2 - * @param count Total pixels of the input image - */ - void image_abs_diff(uint8_t *dst, uint8_t *src1, uint8_t *src2, int count); - - /** - * @brief Binarize an image to 0 and value. - * - * @param dst The output image - * @param src Source image - * @param threshold Threshold of binarization - * @param value The value of binarization - * @param count Total pixels of the input image - * @param mode Threshold mode - */ - void image_threshold(uint8_t *dst, uint8_t *src, int threshold, int value, int count, en_threshold_mode mode); - - /** - * @brief Erode the image - * - * @param dst The output image - * @param src Source image - * @param src_w Width of the source image - * @param src_h Height of the source image - * @param src_c Channel of the source image - */ - void image_erode(uint8_t *dst, uint8_t *src, int src_w, int src_h, int src_c); - - typedef float matrixType; - typedef struct - { - int w; /*!< width */ - int h; /*!< height */ - matrixType **array; /*!< array */ - } Matrix; - - /** - * @brief Allocate a 2d matrix - * - * @param h Height of matrix - * @param w Width of matrix - * @return Matrix* 2d matrix - */ - Matrix *matrix_alloc(int h, int w); - - /** - * @brief Free a 2d matrix - * - * @param m 2d matrix - */ - void matrix_free(Matrix *m); - - /** - * @brief Get the similarity matrix of similarity transformation - * - * @param srcx Source x coordinates - * @param srcy Source y coordinates - * @param dstx Destination x coordinates - * @param dsty Destination y coordinates - * @param num The number of the coordinates - * @return Matrix* The resulting transformation matrix - */ - Matrix *get_similarity_matrix(float *srcx, float *srcy, float *dstx, float *dsty, int num); - - /** - * @brief Get the affine transformation matrix - * - * @param srcx Source x coordinates - * @param srcy Source y coordinates - * @param dstx Destination x coordinates - * @param dsty Destination y coordinates - * @return Matrix* The resulting transformation matrix - */ - Matrix *get_affine_transform(float *srcx, float *srcy, float *dstx, float *dsty); - - /** - * @brief Applies an affine transformation to an image - * - * @param img Input image - * @param crop Dst output image that has the size dsize and the same type as src - * @param M Affine transformation matrix - */ - void warp_affine(dl_matrix3du_t *img, dl_matrix3du_t *crop, Matrix *M); - - /** - * @brief Resize the image in RGB888 format via bilinear interpolation, and quantify the output image - * - * @param dst_image Quantized output image - * @param src_image Input image - * @param dst_w Width of the output image - * @param dst_h Height of the output image - * @param dst_c Channel of the output image - * @param src_w Width of the input image - * @param src_h Height of the input image - * @param shift Shift parameter of quantization. - */ - void image_resize_linear_q(qtp_t *dst_image, uint8_t *src_image, int dst_w, int dst_h, int dst_c, int src_w, int src_h, int shift); - - /** - * @brief Preprocess the input image of object detection model. The process is like this: resize -> normalize -> quantify - * - * @param image Input image, RGB888 format. - * @param input_w Width of the input image. - * @param input_h Height of the input image. - * @param target_size Target size of the model input image. - * @param exponent Exponent of the quantized model input image. - * @param process_mode Process mode. 0: resize with padding to keep height == width. 1: resize without padding, height != width. - * @return dl_matrix3dq_t* The resulting preprocessed image. - */ - dl_matrix3dq_t *image_resize_normalize_quantize(uint8_t *image, int input_w, int input_h, int target_size, int exponent, int process_mode); - - /** - * @brief Resize the image in RGB565 format via mean neighbour interpolation, and quantify the output image - * - * @param dimage Quantized output image. - * @param simage Input image. - * @param dw Width of the allocated output image memory. - * @param dc Channel of the allocated output image memory. - * @param sw Width of the input image. - * @param sh Height of the input image. - * @param tw Target width of the output image. - * @param th Target height of the output image. - * @param shift Shift parameter of quantization. - */ - void image_resize_shift_fast(qtp_t *dimage, uint16_t *simage, int dw, int dc, int sw, int sh, int tw, int th, int shift); - - /** - * @brief Resize the image in RGB565 format via nearest neighbour interpolation, and quantify the output image - * - * @param dimage Quantized output image. - * @param simage Input image. - * @param dw Width of the allocated output image memory. - * @param dc Channel of the allocated output image memory. - * @param sw Width of the input image. - * @param sh Height of the input image. - * @param tw Target width of the output image. - * @param th Target height of the output image. - * @param shift Shift parameter of quantization. - */ - void image_resize_nearest_shift(qtp_t *dimage, uint16_t *simage, int dw, int dc, int sw, int sh, int tw, int th, int shift); - - /** - * @brief Crop the image in RGB565 format and resize it to target size, then quantify the output image - * - * @param dimage Quantized output image. - * @param simage Input image. - * @param dw Target size of the output image. - * @param sw Width of the input image. - * @param sh Height of the input image. - * @param x1 The x coordinate of the upper left corner of the cropped area - * @param y1 The y coordinate of the upper left corner of the cropped area - * @param x2 The x coordinate of the lower right corner of the cropped area - * @param y2 The y coordinate of the lower right corner of the cropped area - * @param shift Shift parameter of quantization. - */ - void image_crop_shift_fast(qtp_t *dimage, uint16_t *simage, int dw, int sw, int sh, int x1, int y1, int x2, int y2, int shift); - -#ifdef __cplusplus -} -#endif diff --git a/tools/sdk/esp32/include/esp-face/include/detect/dl_detect_define.hpp b/tools/sdk/esp32/include/esp-face/include/detect/dl_detect_define.hpp new file mode 100644 index 00000000000..cc53050cb9b --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/detect/dl_detect_define.hpp @@ -0,0 +1,17 @@ +#pragma once + +#include + +namespace dl +{ + namespace detect + { + typedef struct + { + int category; /* box; /* keypoint; /* +#include "sdkconfig.h" + +#define DL_LOG_LATENCY_UNIT 0 /* (high)) ? (high) : (x)) +#endif + +#ifndef DL_ABS +#define DL_ABS(x) ((x) < 0 ? (-(x)) : (x)) +#endif + +#ifndef DL_RIGHT_SHIFT +#define DL_RIGHT_SHIFT(x, shift) ((shift) > 0) ? ((x) >> (shift)) : ((x) << -(shift)) +#endif + +#ifndef DL_LEFT_SHIFT +#define DL_LEFT_SHIFT(x, shift) ((shift) > 0) ? ((x) << (shift)) : ((x) >> -(shift)) +#endif + +namespace dl +{ + typedef enum + { + Linear, /**/ + ReLU, /**/ + LeakyReLU, /**/ + PReLU, /**/ + // TODO: Sigmoid, /**/ + // TODO: Softmax, /**/ + PADDING_SAME, /**/ + PADDING_SAME_MXNET /**/ + } padding_type_t; +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32/include/esp-face/include/image/dl_image.hpp b/tools/sdk/esp32/include/esp-face/include/image/dl_image.hpp new file mode 100644 index 00000000000..c7fecdc49cc --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/image/dl_image.hpp @@ -0,0 +1,380 @@ +#pragma once + +#include +#include +#include +#include +#include "dl_define.hpp" +#include "dl_variable.hpp" +#include "dl_math_matrix.hpp" + +namespace dl +{ + namespace image + { + typedef enum + { + IMAGE_RESIZE_BILINEAR = 0, /*> 7; + return DL_CLIP(temp, 0, 255); + } + + /** + * @brief Convert RGB565 pixel to RGB888. + * + * @tparam T supports all integer types + * @param input pixel value in RGB565 + * @param output pixel value in RGB888 + */ + template + inline void convert_pixel_rgb565_to_rgb888(uint16_t input, T *output) + { + output[0] = (input & 0x1F00) >> 5; // blue + output[1] = ((input & 0x7) << 5) | ((input & 0xE000) >> 11); // green + output[2] = input & 0xF8; // red + } + + /** + * @brief Convert RGB565 pixel to Gray. + * + * @param input pixel value in RGB565 + * @return pixel value in Gray + */ + inline uint8_t convert_pixel_rgb565_to_gray(uint16_t input) + { + int blue = (input & 0x1F00) >> 5; // blue + int green = ((input & 0x7) << 5) | ((input & 0xE000) >> 11); // green + int red = input & 0xF8; // red + + return convert_pixel_rgb888_to_gray(red, green, blue); + } + + /** + * @brief Crop a patch from image and resize and store to destination image. + * If the cropping box is out of image, destination image will be padded with edge. + * + * The outer rectangle is the entire output image. + * The inner rectangle is where the resized image will be stored. + * In other world, this function could help you do padding while resize image. + * ___________________________(dst_w)__________________ + * | ___________________________ | + * | |(x_start, y_start) | | + * | | | | + * | | | | + * (dst_h)| | | | + * | | | | + * | | | | + * | |___________________________|(x_end, y_end) | + * |____________________________________________________| + * + * @tparam T suppot all integer types + * @param dst_image pointer of destination(output) image + * @param dst_width destination image width + * @param dst_channel destination image channel number + * @param dst_y_start start y of resized image in destination image + * @param dst_y_end end y of resized image in destination image + * @param dst_x_start start x of resized image in destination image + * @param dst_x_end end x of resized image in destination image + * @param src_image pointer of source image + * @param src_height source image height + * @param src_width source image width + * @param src_channel source image channel + * @param src_y_start start y of resized image in source image + * @param src_y_end end y of resized image in source image + * @param src_x_start start x of resized image in source image + * @param src_x_end end x of resized image in source image + * @param resize_type one of IMAGE_RESIZE_BILINEAR or IMAGE_RESIZE_MEAN or IMAGE_RESIZE_NEAREST + * @param shift_left bit left shift number implemented on output + */ + template + void crop_and_resize(T *dst_image, + int dst_width, + int dst_channel, + int dst_y_start, int dst_y_end, + int dst_x_start, int dst_x_end, + uint16_t *src_image, + int src_height, + int src_width, + int src_channel, + int src_y_start, int src_y_end, + int src_x_start, int src_x_end, + resize_type_t resize_type = IMAGE_RESIZE_NEAREST, + int shift_left = 0); + + /** + * @brief Crop a patch from image and resize and store to destination image. + * If the cropping box is out of image, destination image will be padded with edge. + * + * The outer rectangle is the entire output image. + * The inner rectangle is where the resized image will be stored. + * In other world, this function could help you do padding while resize image. + * ___________________________(dst_w)__________________ + * | ___________________________ | + * | |(x_start, y_start) | | + * | | | | + * | | | | + * (dst_h)| | | | + * | | | | + * | | | | + * | |___________________________|(x_end, y_end) | + * |____________________________________________________| + * + * @tparam T suppot all integer types + * @param dst_image pointer of destination(output) image + * @param dst_width destination image width + * @param dst_channel destination image channel number + * @param dst_y_start start y of resized image in destination image + * @param dst_y_end end y of resized image in destination image + * @param dst_x_start start x of resized image in destination image + * @param dst_x_end end x of resized image in destination image + * @param src_image pointer of source image + * @param src_height source image height + * @param src_width source image width + * @param src_channel source image channel + * @param src_y_start start y of resized image in source image + * @param src_y_end end y of resized image in source image + * @param src_x_start start x of resized image in source image + * @param src_x_end end x of resized image in source image + * @param resize_type one of IMAGE_RESIZE_BILINEAR or IMAGE_RESIZE_MEAN or IMAGE_RESIZE_NEAREST + * @param shift_left bit left shift number implemented on output + */ + template + void crop_and_resize(T *dst_image, + int dst_width, + int dst_channel, + int dst_y_start, int dst_y_end, + int dst_x_start, int dst_x_end, + uint8_t *src_image, + int src_height, + int src_width, + int src_channel, + int src_y_start, int src_y_end, + int src_x_start, int src_x_end, + resize_type_t resize_type = IMAGE_RESIZE_NEAREST, + int shift_left = 0); + + /** + * @brief Draw a filled rectangle on RGB888 image. + * + * @param image pointer of input image + * @param image_height height of input image + * @param image_width width of input image + * @param x1 left up corner x + * @param y1 left up corner y + * @param x2 right bottom corner x + * @param y2 right bottom corner y + * @param color 0x 00| 00| 00| 00 + * reserved|channel 0|channel 1|channel 2 + */ + void draw_filled_rectangle(uint8_t *image, const uint32_t image_height, const uint32_t image_width, + uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2, + const uint32_t color = 0x00FF0000); + + /** + * @brief Draw a filled rectangle on RGB565 image. + * + * @param image pointer of input image + * @param image_height height of input image + * @param image_width width of input image + * @param x1 left up corner x + * @param y1 left up corner y + * @param x2 right bottom corner x + * @param y2 right bottom corner y + * @param color 0b 000| 00000| 00000| 000 + * channel 1[2:0]|channel 0|channel 2|channel 1[5:3] + */ + void draw_filled_rectangle(uint16_t *image, const uint32_t image_height, const uint32_t image_width, + uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2, + const uint16_t color = 0b0001111100000000); + + /** + * @brief Draw a point on RGB888 image. + * + * @param image pointer of input image + * @param image_height height of input image + * @param image_width width of input image + * @param x point x + * @param y point y + * @param size size of point + * @param color 0x 00| 00| 00| 00 + * reserved|channel 0|channel 1|channel 2 + */ + void draw_point(uint8_t *image, const uint32_t image_height, const uint32_t image_width, + const uint32_t x, const uint32_t y, const uint32_t size, + const uint32_t color = 0x00FF0000); + + /** + * @brief Draw a point on RGB565 image. + * + * @param image pointer of input image + * @param image_height height of input image + * @param image_width width of input image + * @param x point x + * @param y point y + * @param size size of point + * @param color 0b 000| 00000| 00000| 000 + * channel 1[2:0]|channel 0|channel 2|channel 1[5:3] + */ + void draw_point(uint16_t *image, const uint32_t image_height, const uint32_t image_width, + const uint32_t x, const uint32_t y, const uint32_t size, + uint16_t color = 0b0001111100000000); + + /** + * @brief Draw a hollow rectangle on RGB888 image. + * + * @param image pointer of input image + * @param image_height height of input image + * @param image_width width of input image + * @param x1 left up corner x + * @param y1 left up corner y + * @param x2 right bottom corner x + * @param y2 right bottom corner y + * @param color 0x 00| 00| 00| 00 + * reserved|channel 0|channel 1|channel 2 + */ + void draw_hollow_rectangle(uint8_t *image, const uint32_t image_height, const uint32_t image_width, + uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2, + uint32_t color = 0x00FF0000); + + /** + * @brief Draw a hollow rectangle on RGB565 image. + * + * @param image pointer of input image + * @param image_height height of input image + * @param image_width width of input image + * @param x1 left up corner x + * @param y1 left up corner y + * @param x2 right bottom corner x + * @param y2 right bottom corner y + * @param color 0b 000| 00000| 00000| 000 + * channel 1[2:0]|channel 0|channel 2|channel 1[5:3] + */ + void draw_hollow_rectangle(uint16_t *image, const uint32_t image_height, const uint32_t image_width, + uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2, + const uint16_t color = 0b0001111100000000); + + /** + * @brief Detect target moving by activated detection point number. Each cross in the figure below is a detection point. + * Once abs(frame_1_detection_point[i] - frame_2_detection_point[i]) > threshold, this detection point is activated. + * This function will return the number of activated detection point. + * + * __stride__________________________ + * | | | | | + * stride | | | | | + * | | | | | + * |________|________|________| | + * | | | | | + * | | | | | + * | | | | | + * |________|________|________| height + * | | | | | + * | | | | | + * | | | | | + * |________|________|________| | + * | | | | | + * | | | | | + * | | | | | + * |________|________|________|___|___ + * | | + * |__________width___________| + * | | + * + * Time consumption: + * Frame shape = (240, 240) + * Both frame are in PSRAM + * On ESP32-S3 with CPU 240MHz, QSPI 80MHz + * + * stride latency + * 1 28316us + * 2 8770us + * 4 3622us + * 8 1990us + * 16 880us + * 32 260us + * + * + * In a application, outside this function, threshold of activated detection point number is needed. + * Once activated detection point number > number_threshold, this two frame are judged target moved. + * How to determine the number_threshold? + * Let's assume that the minimize shape of target is (target_min_height, target_max_width). + * Then, the number_threshold = [target_min_height / stride] * [target_max_width / stride] * ratio, + * where ratio is in (0, 1), the smaller the ratio is, the more sensitive the detector is, the more false detected. + * + * + * @param f1 one frame in RGB565 + * @param f2 another frame in RGB565 + * @param height height of frame + * @param width width of frame + * @param stride stride of detection point, the smaller the stride is, the more reliable the detector is. + * @param threshold activation threshold of each detection point + * @return activated detection point number + */ + uint32_t get_moving_point_number(uint16_t *f1, uint16_t *f2, const uint32_t height, const uint32_t width, const uint32_t stride, const uint32_t threshold = 5); + + /** + * @brief Detect target moving by activated detection point number. Each cross in the figure below is a detection point. + * Once abs(frame_1_detection_point[i] - frame_2_detection_point[i]) > threshold, this detection point is activated. + * This function will return the number of activated detection point. + * + * __stride__________________________ + * | | | | | + * stride | | | | | + * | | | | | + * |________|________|________| | + * | | | | | + * | | | | | + * | | | | | + * |________|________|________| height + * | | | | | + * | | | | | + * | | | | | + * |________|________|________| | + * | | | | | + * | | | | | + * | | | | | + * |________|________|________|___|___ + * | | + * |__________width___________| + * | | + * + * + * In a application, outside this function, threshold of activated detection point number is needed. + * Once activated detection point number > number_threshold, this two frame are judged target moved. + * How to determine the number_threshold? + * Let's assume that the minimize shape of target is (target_min_height, target_max_width). + * Then, the number_threshold = [target_min_height / stride] * [target_max_width / stride] * ratio, + * where ratio is in (0, 1), the smaller the ratio is, the more sensitive the detector is, the more false detected. + * + * + * @param f1 one frame in RGB888 + * @param f2 another frame in RGB888 + * @param height height of frame + * @param width width of frame + * @param stride stride of detection point, the smaller the stride is, the more reliable the detector is. + * @param threshold activation threshold of each detection point + * @return activated detection point number + */ + uint32_t get_moving_point_number(uint8_t *f1, uint8_t *f2, const uint32_t height, const uint32_t width, const uint32_t stride, const uint32_t threshold = 5); + + + template + void warp_affine(dl::Tensor *input, dl::Tensor *output, dl::math::Matrix *M_inv); + template + void warp_affine(uint16_t *input, std::vector shape, dl::Tensor *output, dl::math::Matrix *M_inv); + + } // namespace image +} // namespace dl diff --git a/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_add2d.hpp b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_add2d.hpp new file mode 100644 index 00000000000..f0c5964b3d1 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_add2d.hpp @@ -0,0 +1,127 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn_add2d.hpp" +#include "dl_layer_base.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief Activation(Add2D(input0, input1)). + * NOTE: addition is element-wise, i.e., output[i,j,k] = input0[i,j,k] + input1[i,j,k] + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class Add2D : public Layer + { + private: + const Activation *activation; /**/ + const int output_exponent; /**/ + Tensor *output; /**/ + bool inplace; /**/ + + public: + /** + * @brief Construct a new Add2D object. + * + * @param output_exponent exponent of output + * @param activation activation of add2d, if you don't specify anything, no activation is applied + * @param name name of add2d + * @param inplace true: the output will store to input0 + * false: the output will store to a seperate memeory + */ + Add2D(const int output_exponent, const Activation *activation = NULL, const char *name = NULL, bool inplace = false) : Layer(name), activation(activation), output_exponent(output_exponent), output(NULL) + { + this->inplace = inplace; + } + + /** + * @brief Destroy the Add2D object + */ + ~Add2D() + { + if((!this->inplace) && (this->output != NULL)) + { + delete this->output; + } + } + + /** + * @brief Update output shape. + * NOTE: input0.shape must equal to input1.shape. + * + * @param input0 as one input + * @param input1 as another input + */ + void build(Tensor &input0, Tensor &input1) + { + assert(input0.is_same_shape(input1)); + + if (!this->inplace) + { + if (this->output == NULL) + { + this->output = new Tensor; + } + this->output->set_exponent(this->output_exponent); + this->output->set_shape(input0.shape); + this->output->free_element(); + } + else + { + this->output = &input0; + } + } + + /** + * @brief Get the output + * + * @return Tensor& Add2D result + */ + Tensor &get_output() + { + return *this->output; + } + + /** + * @brief Call Add2D operation. + * + * @param input0 as one input + * @param input1 as another input + * @param assign_core not effective yet + * @return Tensor& added result + */ + Tensor &call(Tensor &input0, Tensor &input1, const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_LAYER_LATENCY_INIT(); + + if (!this->inplace) + { + DL_LOG_LAYER_LATENCY_START(); + this->output->apply_element(); + this->output->set_exponent(this->output_exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + DL_LOG_LAYER_LATENCY_START(); + nn::add2d(*this->output, input0, input1, this->activation, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "add2d"); + } + else + { + DL_LOG_LAYER_LATENCY_START(); + nn::add2d(*this->output, input0, input1, this->activation, assign_core, this->output_exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "add2d"); + } + + return *this->output; + } + }; + } // namespace layer +} // namespace dl diff --git a/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_avg_pool2d.hpp b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_avg_pool2d.hpp new file mode 100644 index 00000000000..f78b262beb9 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_avg_pool2d.hpp @@ -0,0 +1,137 @@ +#pragma once + +#include +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn_avg_pool2d.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief AvgPool2D(input). + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class AvgPool2D : public Layer + { + private: + const int output_exponent; /**/ + std::vector filter_shape; /**/ + const int stride_y; /**/ + const int stride_x; /**/ + const padding_type_t padding_type; /**/ + std::vector padding; /**/ + Tensor *output; /**/ + + public: + + /** + * @brief Construct a new AvgPool2D object. + * + * @param output_exponent exponent of output + * @param filter_shape filter shape in [filter_height, filter_width] + * @param padding_type one of PADDING_VALID or PADDING_SAME or PADDING_SAME_MXNET, + * - PADDING_VALID means no padding + * PADDING_SAME and PADDING_SAME_MXNET results in padding with zeros evenly to the left/right or up/down of the input + * such that output has the same height/width dimension as the input, + * - PADDING_SAME results padding in TensorFlow style + * - PADDING_SAME_MXNET results padding in MXNET style + * @param stride_y stride in height + * @param stride_x stride in width + * @param name name of layer + */ + AvgPool2D(const int output_exponent, + const std::vector filter_shape, + const padding_type_t padding_type = PADDING_VALID, + const int stride_y = 1, + const int stride_x = 1, + const char *name = NULL) : Layer(name), + output_exponent(output_exponent), + filter_shape(filter_shape), + stride_y(stride_y), + stride_x(stride_x), + padding_type(padding_type) + { + this->output = new Tensor; + } + + /** + * @brief Destroy the AvgPool2D object. + * + */ + ~AvgPool2D() + { + if(this->output != NULL) + { + delete this->output; + } + } + + /** + * @brief Update output shape and padding. + * + * @param input as an input + */ + void build(Tensor &input) + { + assert(input.shape[0] > 0); + assert(input.shape[1] > 0); + std::vector output_shape = nn::get_output_shape(input.shape, filter_shape, this->stride_y, this->stride_x, this->padding_type); + this->output->set_shape(output_shape); + this->output->set_exponent(this->output_exponent); + + this->padding = nn::get_pad_size(output_shape, input.shape, filter_shape, this->stride_y, this->stride_x, this->padding_type); + input.set_padding_size(this->padding); + this->output->free_element(); + } + + + /** + * @brief Get the output + * + * @return Tensor& AvgPool2D result + */ + Tensor &get_output() + { + return *this->output; + } + + /** + * @brief Call AvgPool2D operation + * + * @param input as an input + * @param autoload_enable one of true or false, + * - true: load input and output from PSRAM to CACHE automatically + * - false: do not + * @param assign_core not effective yet + * @return AvgPool2D result + */ + Tensor &call(Tensor &input, uint8_t autoload_enable = 0) + { + DL_LOG_LAYER_LATENCY_INIT(); + + DL_LOG_LAYER_LATENCY_START(); + this->output->apply_element(); + this->output->set_exponent(this->output_exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + if (autoload_enable) + { + dl::tool::cache::autoload_func((uint32_t)(this->output->element), this->output->get_size() * sizeof(feature_t), + (uint32_t)(input.element), input.get_size() * sizeof(feature_t)); + } + + DL_LOG_LAYER_LATENCY_START(); + nn::avg_pool2d(*this->output, input, this->padding, this->filter_shape, this->stride_y, this->stride_x); + DL_LOG_LAYER_LATENCY_END(this->name, "avg_pool2d"); + + return *this->output; + } + }; + } // namespace layer +} // namespace dl diff --git a/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_base.hpp b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_base.hpp new file mode 100644 index 00000000000..5c7d28d52b1 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_base.hpp @@ -0,0 +1,55 @@ +#pragma once +#include "dl_tool.hpp" +#include "dl_tool_cache.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief Base class for layer. + * + */ + class Layer + { + public: + char *name; /**/ + + /** + * @brief Construct a new Layer object. + * + * @param name name of layer. + */ + Layer(const char *name = NULL); + + /** + * @brief Destroy the Layer object. Return resource. + * + */ + ~Layer(); + }; + } // namespace layer +} // namespace dl + +#if DL_LOG_LAYER_LATENCY +/** + * @brief Initialize. + */ +#define DL_LOG_LAYER_LATENCY_INIT() dl::tool::Latency latency + +/** + * @brief Time starts. + */ +#define DL_LOG_LAYER_LATENCY_START() latency.start() + +/** + * @brief Time ends and printed. + */ +#define DL_LOG_LAYER_LATENCY_END(prefix, key) \ + latency.end(); \ + latency.print(prefix, key) +#else +#define DL_LOG_LAYER_LATENCY_INIT() +#define DL_LOG_LAYER_LATENCY_START() +#define DL_LOG_LAYER_LATENCY_END(prefix, key) +#endif diff --git a/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_concat2d.hpp b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_concat2d.hpp new file mode 100644 index 00000000000..a086f1ccfde --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_concat2d.hpp @@ -0,0 +1,179 @@ +#pragma once + +#include +#include + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_tool.hpp" +#include "dl_layer_base.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief Concat2D(input1, input2, input3, ...). + * + * @tparam feature_t support all kinds of integer and float data type + */ + template + class Concat2D : Layer + { + private: + std::vector *> output_vec; /**/ + std::vector offset; /**/ + std::vector channel; /**/ + Tensor *output; /**/ + int output_exponent; /**/ + public: + + /** + * @brief Construct a new Concat2D object. + * + * @param name name of layer + */ + Concat2D(const char *name = NULL) : Layer(name) { + this->output = new Tensor; + } + + /** + * @brief Destroy the Concat2D object + */ + ~Concat2D() + { + if (this->output != NULL) + { + delete this->output; + } + } + + /** + * @brief Collect inputs' channel and memory offset, called in Model.build(). + * + * @param args pointers of concatenated Tensor + */ + void build(std::vector *> args) + { + assert(args.size() > 0); + + this->output_vec = args; + + this->offset = std::vector(args.size()); + this->channel = std::vector(args.size()); + + this->output_exponent = args[0]->exponent; + this->offset[0] = 0; + this->channel[0] = args[0]->shape[2]; + std::vector output_shape = args[0]->shape; + + for (int i = 1; i < args.size(); i++) + { + assert(output_shape[0] == args[i]->shape[0]); // height + assert(output_shape[1] == args[i]->shape[1]); // width + // assert(this->output_exponent == args[i]->exponent); // exponent + + this->offset[i] = output_shape[2]; + this->channel[i] = args[i]->shape[2]; + output_shape[2] += args[i]->shape[2]; + } + this->output->set_shape(output_shape); + this->output->set_exponent(this->output_exponent); + this->output->free_element(); + } + + /** + * @brief Get the output + * + * @return Tensor& Concat2d result + */ + Tensor &get_output() + { + return *this->output; + } + + /** + * @brief Get the maximum padding among inputs and output-> Then, set to this->output. Called at the end of Model.build(). + * NOTE: Some special situations like C = Concat2D_1(A, B), E = Concat2D_2(C, D), where A, B, C, D, E are Tensor. + * For avoiding memory copy, we apply an entire element for E, and take it apart for A, B, D. + * A, B, C, D and E will become other layer's inputs so that result different size of padding. + * For get the maximum padding, we should call at the end of Model.build(), + * Concat2D_1.backward(); // max_padding_temp = get_max_padding(A, B, C), padding of A, B and C are set to max_padding_temp. + * Concat2D_2.backward(); // max_padding = get_max_padding(max_padding_temp, get_max_padding(D, E)) , padding of C, D and E are set to max_padding. + * However, padding of A and B is still max_padding_temp. + * Concat2D_1.backward(); // padding of A and B are set to max_padding. + * Or, + * Concat2D_2.backward(); + * Concat2D_1.backward(); + * Concat2D_2.backward(); + */ + void backward() + { + std::vector max_padding = this->output->padding; + int max_channel_with_padding = this->output->shape_with_padding[2]; + for (int i = 0; i < this->output_vec.size(); i++) + { + for (int j = 0; j < max_padding.size(); j++) + { + max_padding[j] = DL_MAX(max_padding[j], this->output_vec[i]->padding[j]); + } + max_channel_with_padding = DL_MAX(max_channel_with_padding, this->output_vec[i]->shape_with_padding[2]); + } + + this->output->set_padding_size(max_padding); + this->output->shape_with_padding[2] = max_channel_with_padding; + for (int i = 0; i < this->output_vec.size(); i++) + { + this->output_vec[i]->set_padding_size(max_padding); + this->output_vec[i]->shape_with_padding[2] = max_channel_with_padding; +#if CONFIG_DEBUG_MODE + assert(this->output->shape_with_padding[0] == this->output_vec[i]->shape_with_padding[0]); + assert(this->output->shape_with_padding[1] == this->output_vec[i]->shape_with_padding[1]); + assert(this->output->shape_with_padding[2] == this->output_vec[i]->shape_with_padding[2]); +#endif + } + } + + /** + * @brief Calloc an entire element for concatnate result. Take the entire element apart and deliver element pointers to concatenated layer. + * NOTE: For example, C = Concat2D(A, B). We apply an entire element for C and deliver two element pointers to A and B. + * Let's assume that A result is produced first. We should call Concat2D.calloc_element() just before A result is produced + * to make sure the element of A is ready and could be filled. + */ + void calloc_element() + { + DL_LOG_LAYER_LATENCY_INIT(); + + DL_LOG_LAYER_LATENCY_START(); + this->output->calloc_element(); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + DL_LOG_LAYER_LATENCY_START(); + for (int i = 0; i < this->offset.size(); i++) + { + this->output_vec[i]->element = this->output->element + this->offset[i]; + this->output_vec[i]->set_auto_free(false); + } + DL_LOG_LAYER_LATENCY_END(this->name, "deliver"); + } + + void apply_element() + { + DL_LOG_LAYER_LATENCY_INIT(); + + DL_LOG_LAYER_LATENCY_START(); + this->output->apply_element(); + this->output->set_exponent(this->output_exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + DL_LOG_LAYER_LATENCY_START(); + for (int i = 0; i < this->offset.size(); i++) + { + this->output_vec[i]->element = this->output->element + this->offset[i]; + this->output_vec[i]->set_auto_free(false); + } + DL_LOG_LAYER_LATENCY_END(this->name, "deliver"); + } + }; + } // namespace layer +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_conv2d.hpp b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_conv2d.hpp new file mode 100644 index 00000000000..a7c2229db09 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_conv2d.hpp @@ -0,0 +1,157 @@ +#pragma once + +#include "dl_nn_conv2d.hpp" +#include "dl_layer_base.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief Activation(Conv2D(input, filter) + bias). + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class Conv2D : public Layer + { + private: + const int output_exponent; /**/ + const Filter *filter; /**/ + const int stride_y; /**/ + const int stride_x; /**/ + const padding_type_t padding_type; /**/ + const Bias *bias; /**/ + const Activation *activation; /**/ + std::vector padding; /**/ + Tensor *output; /**/ + + public: + + /** + * @brief Construct a new Conv2D object. + * + * @param output_exponent exponent of output + * @param filter filter of Conv2D + * @param bias bias of Conv2D, if you don't specify anything, no bias is added + * @param activation activation of Conv2D, if you don't specify anything, no activation is applied + * @param padding_type one of PADDING_VALID or PADDING_SAME or PADDING_SAME_MXNET, + * - PADDING_VALID means no padding + * PADDING_SAME and PADDING_SAME_MXNET results in padding with zeros evenly to the left/right or up/down of the input + * such that output has the same height/width dimension as the input, + * - PADDING_SAME results padding in TensorFlow style + * - PADDING_SAME_MXNET results padding in MXNET style + * @param stride_y stride in height + * @param stride_x stride in width + * @param name name of layer + */ + Conv2D(const int output_exponent, + const Filter *filter, + const Bias *bias = NULL, + const Activation *activation = NULL, + const padding_type_t padding_type = PADDING_VALID, + const int stride_y = 1, + const int stride_x = 1, + const char *name = NULL) : Layer(name), + output_exponent(output_exponent), + filter(filter), + stride_y(stride_y), + stride_x(stride_x), + padding_type(padding_type), + bias(bias), + activation(activation) + { + this->output = new Tensor; + } + + /** + * @brief Destroy the Conv2D object. + * + */ + ~Conv2D() + { + if (this->output != NULL) + { + delete this->output; + } + } + + /** + * @brief Update output padding and input padding. + * + * @param input as an input + */ + void build(Tensor &input) + { + assert(input.shape[0] > 0); + assert(input.shape[1] > 0); + + std::vector output_shape = nn::get_output_shape(input.shape, this->filter->shape_with_dilation, this->stride_y, this->stride_x, this->padding_type, true); + this->output->set_shape(output_shape); + this->output->set_exponent(this->output_exponent); + this->output->free_element(); + + this->padding = nn::get_pad_size(output_shape, input.shape, this->filter->shape_with_dilation, this->stride_y, this->stride_x, this->padding_type); + input.set_padding_size(this->padding); + } + + /** + * @brief Get the output + * + * @return Tensor& Conv2D result + */ + Tensor &get_output() + { + return *this->output; + } + + /** + * @brief Call Conv2D operation + * + * @param input as an input. + * @param autoload_enable one of true or false, + * - true: load input and output from PSRAM to CACHE automatically + * - false: do not + * @param assign_core not effective yet + * @return Conv2D result + */ + Tensor &call(Tensor &input, bool autoload_enable = false, const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_LAYER_LATENCY_INIT(); + + DL_LOG_LAYER_LATENCY_START(); + this->output->apply_element(); + this->output->set_exponent(this->output_exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + if (autoload_enable) + { + dl::tool::cache::autoload_func((uint32_t)(this->output->element), this->output->get_size() * sizeof(feature_t), + (uint32_t)(input.element), input.get_size() * sizeof(feature_t)); + } + + DL_LOG_LAYER_LATENCY_START(); + nn::conv2d(*this->output, input, this->padding, *(this->filter), this->stride_y, this->stride_x, this->bias, this->activation, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "conv2d"); + return *this->output; + } + + /** + * @brief Preload the filter to Cache. + * NOTE: Call this layer's preload() before previous layer's call() such that filter could be loaded while previous layer is doing calculation. + */ + void preload() + { + size_t size = sizeof(feature_t); + int shape_size = this->filter->shape.size(); + for (int i = 0; i < shape_size; ++i) + { + size *= filter->shape[i]; + } + dl::tool::cache::preload_func((uint32_t)(this->filter->element), size); + } + }; + } // namespace layer +} // namespace dl diff --git a/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_depthwise_conv2d.hpp b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_depthwise_conv2d.hpp new file mode 100644 index 00000000000..37475353209 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_depthwise_conv2d.hpp @@ -0,0 +1,158 @@ +#pragma once + +#include "dl_nn_depthwise_conv2d.hpp" +#include "dl_layer_base.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief Activation(DepthwiseConv2D(filter, input) + bias). + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class DepthwiseConv2D : public Layer + { + private: + const int output_exponent; /**/ + const Filter *filter; /**/ + const int stride_y; /**/ + const int stride_x; /**/ + const padding_type_t padding_type; /**/ + const Bias *bias; /**/ + const Activation *activation; /**/ + std::vector padding; /**/ + Tensor *output; /**/ + + public: + + /** + * @brief Construct a new DepthwiseConv2D object. + * + * @param output_exponent exponent of output + * @param filter filter of DepthwiseConv2D + * @param bias bias of DepthwiseConv2D, if you don't specify anything, no bias is added + * @param activation activation of DepthwiseConv2D, if you don't specify anything, no activation is applied + * @param padding_type one of PADDING_VALID or PADDING_SAME or PADDING_SAME_MXNET, + * - PADDING_VALID means no padding + * PADDING_SAME and PADDING_SAME_MXNET results in padding with zeros evenly to the left/right or up/down of the input + * such that output has the same height/width dimension as the input + * - PADDING_SAME results padding in TensorFlow style + * - PADDING_SAME_MXNET results padding in MXNET style + * @param stride_y - stride in height + * @param stride_x - stride in width + * @param name name of layer + */ + DepthwiseConv2D(const int output_exponent, + const Filter *filter, + const Bias *bias = NULL, + const Activation *activation = NULL, + const padding_type_t padding_type = PADDING_VALID, + const int stride_y = 1, + const int stride_x = 1, + const char *name = NULL) : Layer(name), + output_exponent(output_exponent), + filter(filter), + stride_y(stride_y), + stride_x(stride_x), + padding_type(padding_type), + bias(bias), + activation(activation) + { + this->output = new Tensor; + } + + /** + * @brief Destroy the DepthwiseConv2D object. + * + */ + ~DepthwiseConv2D() + { + if (this->output != NULL) + { + delete this->output; + } + } + + /** + * @brief Update output shape and padding. + * + * @param input as an input + */ + void build(Tensor &input) + { + assert(input.shape[0] > 0); + assert(input.shape[1] > 0); + + std::vector output_shape = nn::get_output_shape(input.shape, this->filter->shape_with_dilation, this->stride_y, this->stride_x, this->padding_type); + this->output->set_shape(output_shape); + this->output->set_exponent(this->output_exponent); + + this->padding = nn::get_pad_size(output_shape, input.shape, this->filter->shape_with_dilation, this->stride_y, this->stride_x, this->padding_type); + input.set_padding_size(this->padding); + this->output->free_element(); + } + + /** + * @brief Get the output + * + * @return Tensor& DepthwiseConv2D result + */ + Tensor &get_output() + { + return *this->output; + } + + /** + * @brief Call DepthwiseConv2D operation. + * + * @param input as an input + * @param autoload_enable one of true or false, + * - true: load input and output from PSRAM to CACHE automatically + * - false: do not + * @param assign_core not effective yet + * @return DepthwiseConv2D result + */ + Tensor &call(Tensor &input, bool autoload_enable = false, const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_LAYER_LATENCY_INIT(); + + DL_LOG_LAYER_LATENCY_START(); + this->output->apply_element(); + this->output->set_exponent(this->output_exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + if (autoload_enable) + { + dl::tool::cache::autoload_func((uint32_t)(this->output->element), this->output->get_size() * sizeof(feature_t), + (uint32_t)(input.element), input.get_size() * sizeof(feature_t)); + } + + DL_LOG_LAYER_LATENCY_START(); + nn::depthwise_conv2d(*this->output, input, this->padding, *(this->filter), this->stride_y, this->stride_x, this->bias, this->activation, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "depthwise_conv2d"); + + return *this->output; + } + + /** + * @brief Preload the filter to Cache. + * NOTE: Call this layer's preload() before previous layer's call() such that filter could be loaded while previous layer is calculating. + */ + void preload() + { + size_t size = sizeof(feature_t); + int shape_size = this->filter->shape.size(); + for (int i = 0; i < shape_size; ++i) + { + size *= filter->shape[i]; + } + dl::tool::cache::preload_func((uint32_t)(this->filter->element), size); + } + }; + } // namespace layer +} // namespace dl diff --git a/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_global_avg_pool2d.hpp b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_global_avg_pool2d.hpp new file mode 100644 index 00000000000..044c5f61847 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_global_avg_pool2d.hpp @@ -0,0 +1,111 @@ +#pragma once + +#include +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn_global_avg_pool2d.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief GlobalAveragePool2D(input). + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class GlobalAveragePool2D : public Layer + { + private: + const int output_exponent; /**/ + Tensor *output; /**/ + public: + /** + * @brief Construct a new GlobalAveragePool2D object. + * + * @param output_exponent exponent of output + * @param name name of layer + */ + GlobalAveragePool2D(const int output_exponent, const char *name = NULL) : Layer(name), + output_exponent(output_exponent) + + { + this->output = new Tensor; + } + + /** + * @brief Destroy the GlobalAveragePool2D object. + * + */ + ~GlobalAveragePool2D() + { + if (this->output != NULL) + { + delete this->output; + } + } + + /** + * @brief Update output shape. + * + * @param input as an input + */ + void build(Tensor &input) + { + assert(input.shape[0] > 0); + assert(input.shape[1] > 0); + + std::vector output_shape(input.shape.size(), 1); + output_shape[2] = input.shape[2]; + this->output->set_shape(output_shape); + this->output->set_exponent(this->output_exponent); + this->output->free_element(); + } + + /** + * @brief Get the output + * + * @return Tensor& GlobalAveragePool2D result + */ + Tensor &get_output() + { + return *this->output; + } + + /** + * @brief Call GlobalAveragePool2D operation + * + * @param input as an input + * @param autoload_enable one of true or false, + * - true: load input and output from PSRAM to CACHE automatically + * - false: do not + * @param assign_core not effective yet + * @return GlobalAveragePool2D result + */ + Tensor &call(Tensor &input, uint8_t autoload_enable = 0) + { + DL_LOG_LAYER_LATENCY_INIT(); + + DL_LOG_LAYER_LATENCY_START(); + this->output->apply_element(); + this->output->set_exponent(this->output_exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + if (autoload_enable) + { + dl::tool::cache::autoload_func((uint32_t)(this->output->element), this->output->get_size() * sizeof(feature_t), + (uint32_t)(input.element), input.get_size() * sizeof(feature_t)); + } + + DL_LOG_LAYER_LATENCY_START(); + nn::global_avg_pool2d(*this->output, input); + DL_LOG_LAYER_LATENCY_END(this->name, "global_avg_pool2d"); + + return *this->output; + } + }; + } // namespace layer +} // namespace dl diff --git a/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_global_max_pool2d.hpp b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_global_max_pool2d.hpp new file mode 100644 index 00000000000..aa146823b78 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_global_max_pool2d.hpp @@ -0,0 +1,108 @@ +#pragma once + +#include +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn_global_max_pool2d.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief GlobalMaxPool2D(input). + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class GlobalMaxPool2D : public Layer + { + private: + Tensor *output; /**/ + public: + + /** + * @brief Construct a new GlobalMaxPool2D object. + * + * @param name name of layer + */ + GlobalMaxPool2D(const char *name = NULL) : Layer(name) + { + this->output = new Tensor; + } + + /** + * @brief Destroy the GlobalMaxPool2D object. + * + */ + ~GlobalMaxPool2D() + { + if (this->output != NULL) + { + delete this->output; + } + } + + /** + * @brief Update output shape and exponent. + * + * @param input as an input + */ + void build(Tensor &input) + { + assert(input.shape[0] > 0); + assert(input.shape[1] > 0); + this->output->set_exponent(input.exponent); + + std::vector output_shape(input.shape.size(), 1); + output_shape[2] = input.shape[2]; + this->output->set_shape(output_shape); + this->output->free_element(); + } + + /** + * @brief Get the output + * + * @return Tensor& GlobalMaxPool2D result + */ + Tensor &get_output() + { + return *this->output; + } + + /** + * @brief Call GlobalMaxPool2D operation + * + * @param input as an input + * @param autoload_enable one of true or false, + * - true: load input and output from PSRAM to CACHE automatically + * - false: do not + * @param assign_core not effective yet + * @return GlobalMaxPool2D result + */ + Tensor &call(Tensor &input, uint8_t autoload_enable = 0) + { + DL_LOG_LAYER_LATENCY_INIT(); + + DL_LOG_LAYER_LATENCY_START(); + this->output->apply_element(); + this->output->set_exponent(input.exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + if (autoload_enable) + { + dl::tool::cache::autoload_func((uint32_t)(this->output->element), this->output->get_size() * sizeof(feature_t), + (uint32_t)(input.element), input.get_size() * sizeof(feature_t)); + } + + DL_LOG_LAYER_LATENCY_START(); + nn::global_max_pool2d(*this->output, input); + DL_LOG_LAYER_LATENCY_END(this->name, "global_max_pool2d"); + + return *this->output; + } + }; + } // namespace layer +} // namespace dl diff --git a/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_leakyrelu.hpp b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_leakyrelu.hpp new file mode 100644 index 00000000000..f18d9b1c522 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_leakyrelu.hpp @@ -0,0 +1,125 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn_LeakyReLU.hpp" +#include "dl_layer_base.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief LeakyReLU(input). + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class LeakyReLU : public Layer + { + private: + feature_t activation_alpha; /**/ + int activation_exponent; /**/ + Tensor *output; /**/ + bool inplace; /**/ + public: + + /** + * @brief Construct a new LeakyReLU object + * + * @param activation_alpha quantized alpha + * @param activation_exponent exponent of quantized alpha + * @param name name of leakyrelu + * @param inplace true: the output will store to input0 + * false: the output will store to a seperate memeory + */ + LeakyReLU(const int activation_alpha, const int activation_exponent, const char *name = NULL, bool inplace = false) : Layer(name), output(NULL) + { + this->activation_alpha = activation_alpha; + this->activation_exponent = activation_exponent; + this->inplace = inplace; + } + + /** + * @brief Destroy the LeakyReLU object + * + */ + ~LeakyReLU() + { + if ((!this->inplace) && (this->output != NULL)) + { + delete this->output; + } + } + + /** + * @brief Update output shape and exponent + * + * @param input as an input + */ + void build(Tensor &input) + { + if(!this->inplace) + { + if(this->output != NULL) + { + this->output = new Tensor; + } + this->output->set_shape(input.shape); + this->output->set_exponent(input.exponent); + this->output->free_element(); + } + else + { + this->output = &input; + } + + } + + /** + * @brief Get the output + * + * @return Tensor& LeakyReLU result + */ + Tensor &get_output() + { + return *this->output; + } + + /** + * @brief Call LeakyReLU operation. + * + * @param input as an input + * @param assign_core not effective yet + * @return LeakyReLU result + */ + Tensor &call(Tensor &input, const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_LAYER_LATENCY_INIT(); + + if(!this->inplace) + { + DL_LOG_LAYER_LATENCY_START(); + this->output->apply_element(); + this->output->set_exponent(input.exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + DL_LOG_LAYER_LATENCY_START(); + nn::leakyrelu(*this->output, input, this->activation_alpha, this->activation_exponent, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "leakyrelu"); + } + else + { + DL_LOG_LAYER_LATENCY_START(); + nn::leakyrelu(*this->output, input, this->activation_alpha, this->activation_exponent, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "leakyrelu"); + } + + return *this->output; + } + }; + } // namespace layer +} // namespace dl diff --git a/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_max2d.hpp b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_max2d.hpp new file mode 100644 index 00000000000..8a775a2e0f0 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_max2d.hpp @@ -0,0 +1,125 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_tool.hpp" +#include "dl_nn_max2d.hpp" +#include "dl_layer_base.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief Max2D(input0, input1). + * NOTE: maximum is element-wise, i.e., output[i,j,k] = max(input0[i,j,k], input1[i,j,k]) + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class Max2D : public Layer + { + private: + Tensor *output; /**/ + bool inplace; /**/ + public: + + /** + * @brief Construct a new Max2D object. + * + * @param name name of max2d + * @param inplace true: the output will store to input0 + * false: the output will store to a seperate memeory + */ + Max2D(const char *name = NULL, bool inplace = false) : Layer(name), output(NULL) + { + this->inplace = inplace; + } + + /** + * @brief Destroy the Max2D object + * + */ + ~Max2D() + { + if ((!this->inplace) && (this->output != NULL)) + { + delete this->output; + } + } + + /** + * @brief Update output shape and exponent + * NOTE: input0.shape must equal to input1.shape. + * input0.exponent must equal to input1.exponent. + * + * @param input0 as one input + * @param input1 as another input + */ + void build(Tensor &input0, Tensor &input1) + { + assert(input0.is_same_shape(input1)); + assert(input0.exponent == input1.exponent); + + if(!this->inplace) + { + if(this->output != NULL) + { + this->output = new Tensor; + } + this->output->set_exponent(this->output_exponent); + this->output->set_shape(input0.shape); + this->output->free_element(); + } + else + this->output = &input0; + } + + /** + * @brief Get the output + * + * @return Tensor& Max2D result + */ + Tensor &get_output() + { + return *this->output; + } + + /** + * @brief Call Max2D operation. + * + * @param input0 as one input + * @param input1 as another input + * @param assign_core not effective yet + * @return Max2D result + */ + Tensor &call(Tensor &input0, Tensor &input1, const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_LAYER_LATENCY_INIT(); + + if(!this->inplace) + { + DL_LOG_LAYER_LATENCY_START(); + this->output->apply_element(); + this->output->set_exponent(input0.exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + DL_LOG_LAYER_LATENCY_START(); + nn::max2d(*this->output, input0, input1, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "max2d"); + } + else + { + DL_LOG_LAYER_LATENCY_START(); + nn::max2d(*this->output, input0, input1, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "max2d"); + } + + return *this->output; + } + }; + } // namespace layer +} // namespace dl diff --git a/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_max_pool2d.hpp b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_max_pool2d.hpp new file mode 100644 index 00000000000..f836a983b34 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_max_pool2d.hpp @@ -0,0 +1,132 @@ +#pragma once + +#include +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn_max_pool2d.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief MaxPool2D(input). + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class MaxPool2D : public Layer + { + private: + std::vector filter_shape; /**/ + const int stride_y; /**/ + const int stride_x; /**/ + const padding_type_t padding_type; /**/ + std::vector padding; /**/ + Tensor *output; /**/ + + public: + + /** + * @brief Construct a new MaxPool2D object. + * + * @param filter_shape filter shape in [filter_height, filter_width] + * @param padding_type one of PADDING_VALID or PADDING_SAME or PADDING_SAME_MXNET, + * - PADDING_VALID means no padding + * PADDING_SAME and PADDING_SAME_MXNET results in padding with zeros evenly to the left/right or up/down of the input + * such that output has the same height/width dimension as the input, + * - PADDING_SAME results padding in TensorFlow style + * - PADDING_SAME_MXNET results padding in MXNET style + * @param stride_y stride in height + * @param stride_x stride in width + * @param name name of layer + */ + MaxPool2D(const std::vector filter_shape, + const padding_type_t padding_type = PADDING_VALID, + const int stride_y = 1, + const int stride_x = 1, + const char *name = NULL) : Layer(name), + filter_shape(filter_shape), + stride_y(stride_y), + stride_x(stride_x), + padding_type(padding_type) + { + this->output = new Tensor; + } + + /** + * @brief Destroy the MaxPool2D object. + * + */ + ~MaxPool2D() + { + if (this->output != NULL) + { + delete this->output; + } + } + + /** + * @brief Update output shape and padding. + * + * @param input as an input + */ + void build(Tensor &input) + { + assert(input.shape[0] > 0); + assert(input.shape[1] > 0); + this->output->set_exponent(input.exponent); + std::vector output_shape = nn::get_output_shape(input.shape, filter_shape, this->stride_y, this->stride_x, this->padding_type); + this->output->set_shape(output_shape); + + this->padding = nn::get_pad_size(output_shape, input.shape, filter_shape, this->stride_y, this->stride_x, this->padding_type); + input.set_padding_size(this->padding); + this->output->free_element(); + } + + /** + * @brief Get the output + * + * @return Tensor& MaxPool2D result + */ + Tensor &get_output() + { + return *this->output; + } + + /** + * @brief Call MaxPool2D operation + * + * @param input as an input + * @param autoload_enable one of true or false, + * - true: load input and output from PSRAM to CACHE automatically + * - false: do not + * @param assign_core not effective yet + * @return MaxPool2D result + */ + Tensor &call(Tensor &input, uint8_t autoload_enable = 0) + { + DL_LOG_LAYER_LATENCY_INIT(); + + DL_LOG_LAYER_LATENCY_START(); + this->output->apply_element(); + this->output->set_exponent(input.exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + if (autoload_enable) + { + dl::tool::cache::autoload_func((uint32_t)(this->output->element), this->output->get_size() * sizeof(feature_t), + (uint32_t)(input.element), input.get_size() * sizeof(feature_t)); + } + + DL_LOG_LAYER_LATENCY_START(); + nn::max_pool2d(*this->output, input, this->padding, this->filter_shape, this->stride_y, this->stride_x); + DL_LOG_LAYER_LATENCY_END(this->name, "max_pool2d"); + + return *this->output; + } + }; + } // namespace layer +} // namespace dl diff --git a/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_min2d.hpp b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_min2d.hpp new file mode 100644 index 00000000000..71d39c9b285 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_min2d.hpp @@ -0,0 +1,126 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_tool.hpp" +#include "dl_nn_min2d.hpp" +#include "dl_layer_base.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief Min2D(input0, input1). + * NOTE: minimum is element-wise, i.e., output[i,j,k] = min(input0[i,j,k], input1[i,j,k]) + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class Min2D : public Layer + { + private: + Tensor *output; /**/ + bool inplace; /**/ + public: + + /** + * @brief Construct a new Min2D object + * + * @param name name of min2d + * @param inplace true: the output will store to input0 + * false: the output will store to a seperate memeory + */ + Min2D(const char *name = NULL, bool inplace = false) : Layer(name), output(NULL) + { + this->inplace = inplace; + } + + /** + * @brief Destroy the Min2D object + * + */ + ~Min2D() + { + if ((!this->inplace) && (this->output != NULL)) + { + delete this->output; + } + } + + /** + * @brief Update output shape and exponent + * NOTE: input0.shape must equal to input1.shape. + * input0.exponent must equal to input1.exponent. + * + * @param input0 as one input + * @param input1 as another input + */ + void build(Tensor &input0, Tensor &input1) + { + assert(input0.is_same_shape(input1)); + assert(input0.exponent == input1.exponent); + + if(!this->inplace) + { + if(this->output != NULL) + { + this->output = new Tensor; + } + this->output->set_shape(input0.shape); + this->output->set_exponent(input0.exponent); + this->output->free_element(); + } + else + this->output = &input0; + + } + + /** + * @brief Get the output + * + * @return Tensor& Min2D result + */ + Tensor &get_output() + { + return *this->output; + } + + /** + * @brief Call Min2D operation + * + * @param input0 as one input + * @param input1 as another input + * @param assign_core not effective yet + * @return Min2D result + */ + Tensor &call(Tensor &input0, Tensor &input1, const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_LAYER_LATENCY_INIT(); + + if(!this->inplace) + { + DL_LOG_LAYER_LATENCY_START(); + this->output->apply_element(); + this->output->set_exponent(input0.exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + DL_LOG_LAYER_LATENCY_START(); + nn::min2d(*this->output, input0, input1, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "min2d"); + } + else + { + DL_LOG_LAYER_LATENCY_START(); + nn::min2d(*this->output, input0, input1, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "min2d"); + } + + return *this->output; + } + }; + } // namespace layer +} // namespace dl diff --git a/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_model.hpp b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_model.hpp new file mode 100644 index 00000000000..2064ef2d33a --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_model.hpp @@ -0,0 +1,52 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief Neural Network Model. + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class Model + { + private: + std::vector input_shape; /**/ + + public: + /** + * @brief Destroy the Model object. + * + */ + virtual ~Model() {} + + /** + * @brief Build a model including update output shape and input padding of each layer. + * + * @param input as an input + */ + virtual void build(Tensor &input) = 0; + + /** + * @brief Call the model layer by layer. + * + * @param input as an input. + */ + virtual void call(Tensor &input) = 0; + + /** + * @brief If input.shape changes, call Model.build(), otherwise, do not. Then call Model.call(). + * + * @param input as an input + */ + void forward(Tensor &input); + }; + } // namespace layer +} // namespace dl diff --git a/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_mul2d.hpp b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_mul2d.hpp new file mode 100644 index 00000000000..0edfc9a93f0 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_mul2d.hpp @@ -0,0 +1,128 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn_mul2d.hpp" +#include "dl_layer_base.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief Activation(Multiply2D(input0, input1)). + * NOTE: multiplication is element-wise, i.e., output[i,j,k] = input0[i,j,k] * input1[i,j,k] + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class Mul2D : public Layer + { + private: + const int output_exponent; /**/ + const Activation *activation; /**/ + Tensor *output; /**/ + bool inplace; /**/ + public: + const int output_exponent; /**/ + + /** + * @brief Construct a new Mul2D object. + * + * @param output_exponent exponent of output + * @param activation activation of Mul2D, if you don't specify anything, no activation is applied + * @param name name of layer + * @param inplace true: the output will store to input0 + * false: the output will store to a seperate memeory + */ + Mul2D(const int output_exponent, const Activation *activation = NULL, const char *name = NULL, bool inplace = false) : Layer(name), + output_exponent(output_exponent),activation(activation), output(NULL) + { + this->inplace = inplace; + } + + /** + * @brief Destroy the Multiply2D object. + */ + ~Mul2D() + { + if ((!this->inplace) && (this->output != NULL)) + { + delete this->output; + } + } + + /** + * @brief Update output shape. + * NOTE: input0.shape must equal to input1.shape. + * + * @param input0 as one input + * @param input1 as another input + */ + void build(Tensor &input0, Tensor &input1) + { + assert(input0.is_same_shape(input1)); + + if (!this->inplace) + { + if(this->output != NULL) + { + this->output = new Tensor; + } + this->output->set_exponent(this->output_exponent); + this->output->set_shape(input0.shape); + this->output->free_element(); + } + + else + this->output = &input0; + } + + /** + * @brief Get the output + * + * @return Tensor& Mul2D result + */ + Tensor &get_output() + { + return *this->output; + } + + /** + * @brief Call Mul2D operation. + * + * @param input0 as one input + * @param input1 as another input + * @param assign_core not effective yet + * @return Mul2D result + */ + Tensor &call(Tensor &input0, Tensor &input1, const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_LAYER_LATENCY_INIT(); + + if (!this->inplace) + { + DL_LOG_LAYER_LATENCY_START(); + this->output->apply_element(); + this->output->set_exponent(this->output_exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + DL_LOG_LAYER_LATENCY_START(); + nn::mul2d(*this->output, input0, input1, this->activation, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "mul2d"); + } + else + { + DL_LOG_LAYER_LATENCY_START(); + nn::mul2d(*this->output, input0, input1, this->activation, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "mul2d"); + } + + return *this->output; + } + }; + } // namespace layer +} // namespace dl diff --git a/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_prelu.hpp b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_prelu.hpp new file mode 100644 index 00000000000..4781a669130 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_prelu.hpp @@ -0,0 +1,124 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn_prelu.hpp" +#include "dl_layer_base.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief PReLU(input). + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class PReLU : public Layer + { + private: + feature_t *activation_element; /**/ + int activation_exponent; /**/ + Tensor *output; /**/ + bool inplace; /**/ + public: + + /** + * @brief Construct a new PReLU object + * + * @param activation_element quantized alpha elements along channel axis + * @param activation_exponent exponent of quantized alpha elements + * @param name name of prelu + * @param inplace true: the output will store to input0 + * false: the output will store to a seperate memeory + */ + PReLU(const feature_t *activation_element, const int activation_exponent = 0, const char *name = NULL, bool inplace = false) : Layer(name), output(NULL) + { + this->activation_element = activation_element; + this->activation_exponent = activation_exponent; + this->inplace = inplace; + } + + /** + * @brief Destroy the PReLU object + * + */ + ~PReLU() + { + if ((!this->inplace) && (this->output != NULL)) + { + delete this->output; + } + } + + /** + * @brief Update output shape and exponent + * + * @param input as an input + */ + void build(Tensor &input) + { + if(!this->inplace) + { + if(this->output != NULL) + { + this->output = new Tensor; + } + this->output->set_exponent(input.exponent); + this->output->set_shape(input.shape); + this->output->free_element(); + } + else + { + this->output = &input; + } + } + + /** + * @brief Get the output + * + * @return Tensor& PReLU result + */ + Tensor &get_output() + { + return *this->output; + } + + /** + * @brief Call PReLU operation. + * + * @param input as an input + * @param assign_core not effective yet + * @return PReLU result + */ + Tensor &call(Tensor &input, const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_LAYER_LATENCY_INIT(); + + if(!this->inplace) + { + DL_LOG_LAYER_LATENCY_START(); + this->output->set_exponent(input.exponent); + this->output->apply_element(); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + DL_LOG_LAYER_LATENCY_START(); + nn::prelu(*this->output, input, this->activation_element, this->activation_exponent, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "leakyrelu"); + } + else + { + DL_LOG_LAYER_LATENCY_START(); + nn::prelu(*this->output, input, this->activation_element, this->activation_exponent, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "leakyrelu"); + } + + return *this->output; + } + }; + } // namespace layer +} // namespace dl diff --git a/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_relu.hpp b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_relu.hpp new file mode 100644 index 00000000000..e70663b798c --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_relu.hpp @@ -0,0 +1,120 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_tool.hpp" +#include "dl_nn_relu.hpp" +#include "dl_layer_base.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief ReLU(input). + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class ReLU : public Layer + { + private: + Tensor *output; /**/ + bool inplace; /**/ + public: + + + /** + * @brief Construct a new ReLU object + * + * @param name name of relu + * @param inplace true: the output will store to input0 + * false: the output will store to a seperate memeory + */ + ReLU(const char *name = NULL, bool inplace = false) : Layer(name), output(NULL) + { + this->inplace = inplace; + } + + /** + * @brief Destroy the ReLU object + * + */ + ~ReLU() + { + if ((!this->inplace) && (this->output != NULL)) + { + delete this->output; + } + } + + /** + * @brief Update output shape and exponent + * + * @param input as an input + */ + void build(Tensor &input) + { + if(!this->inplace) + { + if(this->output != NULL) + { + this->output = new Tensor; + } + this->output->set_exponent(input.exponent); + this->output->set_shape(input.shape); + this->output->free_element(); + } + else + { + this->output = &input; + } + } + + /** + * @brief Get the output + * + * @return Tensor& ReLU result + */ + Tensor &get_output() + { + return *this->output; + } + + /** + * @brief Call ReLU operation. + * + * @param input as an input + * @param assign_core not effective yet + * @return ReLU result + */ + Tensor &call(Tensor &input, const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_LAYER_LATENCY_INIT(); + + if(!this->inplace) + { + DL_LOG_LAYER_LATENCY_START(); + this->output->apply_element(); + this->output->set_exponent(input.exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + DL_LOG_LAYER_LATENCY_START(); + nn::relu(*this->output, input, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "relu"); + } + else + { + DL_LOG_LAYER_LATENCY_START(); + nn::relu(*this->output, input, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "relu"); + } + + return *this->output; + } + }; + } // namespace layer +} // namespace dl diff --git a/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_sub2d.hpp b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_sub2d.hpp new file mode 100644 index 00000000000..e3453c08b97 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/layer/dl_layer_sub2d.hpp @@ -0,0 +1,124 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn_sub2d.hpp" +#include "dl_layer_base.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief Activation(Sub2D(input0, input1)). + * NOTE: subtraction is element-wise, i.e., output[i,j,k] = input0[i,j,k] - input1[i,j,k] + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class Sub2D : public Layer + { + private: + const int output_exponent; /**/ + const Activation *activation; /**/ + Tensor *output; /**/ + bool inplace; /**/ + public: + + /** + * @brief Construct a new Sub2D object. + * + * @param output_exponent exponent of output + * @param activation activation of Mul2D, if you don't specify anything, no activation is applied + * @param name name of layer + * @param inplace true: the output will store to input0 + * false: the output will store to a seperate memeory + */ + Sub2D(const int output_exponent, const Activation *activation = NULL, const char *name = NULL, bool inplace = false) : Layer(name), + output_exponent(output_exponent), activation(activation), output(NULL) + { + this->inplace = inplace; + } + + /** + * @brief Destroy the Sub2D object. + */ + ~Sub2D() + { + if ((!this->inplace) && (this->output != NULL)) + { + delete this->output; + } + } + + /** + * @brief Update output shape. + * NOTE: input0.shape must equal to input1.shape. + * + * @param input0 as one input + * @param input1 as another input + */ + void build(Tensor &input0, Tensor &input1) + { + assert(input0.is_same_shape(input1)); + if (!this->inplace) + { + if(this->output != NULL) + { + this->output = new Tensor; + } + this->output->set_exponent(this->output_exponent); + this->output->set_shape(input0.shape); + this->output->free_element(); + } + else + this->output = &input0; + } + + /** + * @brief Get the output + * + * @return Tensor& Sub2D result + */ + Tensor &get_output() + { + return *this->output; + } + + /** + * @brief Call Sub2D operation. + * + * @param input0 as one input + * @param input1 as another input + * @param assign_core not effective yet + * @return Sub2D result + */ + Tensor &call(Tensor &input0, Tensor &input1, const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_LAYER_LATENCY_INIT(); + + if (!this->inplace) + { + DL_LOG_LAYER_LATENCY_START(); + this->output.apply_element(); + this->output->set_exponent(input0.exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + DL_LOG_LAYER_LATENCY_START(); + nn::sub2d(this->output, input0, input1, this->activation, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "sub2d"); + } + else + { + DL_LOG_LAYER_LATENCY_START(); + nn::sub2d(this->output, input0, input1, this->activation, assign_core, this->output_exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "sub2d"); + } + return *this->output; + } + }; + } // namespace layer +} // namespace dl diff --git a/tools/sdk/esp32/include/esp-face/include/math/dl_math.hpp b/tools/sdk/esp32/include/esp-face/include/math/dl_math.hpp new file mode 100644 index 00000000000..d3f2b94d3de --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/math/dl_math.hpp @@ -0,0 +1,188 @@ +#pragma once + +#include "dl_define.hpp" + +namespace dl +{ + namespace math + { + /** + * @brief x^a. + * + * @param x as a base + * @param a as an exponent + * @return x^a + */ + inline float power(float x, int a) + { + if (a > 0) + { + return x * power(x, a - 1); + } + else if (a < 0) + { + return 1 / (x * power(x, -a - 1)); + } + else + { + return 1.f; + } + } + + /** + * @brief sqrt(x). + * + * @param x as a base + * @return sqrt(x) + */ + inline float sqrt_quick(float x) + { + const int result = 0x1fbb4000 + (*(int *)&x >> 1); + return *(float *)&result; + } + + /** + * @brief 1/sqrt(x). + * + * @param x as a base + * @return 1/sqrt(x) + */ + inline float sqrt_reciprocal_quick(float x) + { + float xhalf = 0.5f * x; + int i = *(int *)&x; // get bits for floating value + i = 0x5f375a86 - (i >> 1); // gives initial guess y0 + x = *(float *)&i; // convert bits back to float + x = x * (1.5f - xhalf * x * x); // Newton step, repeating increases accuracy + return x; + } + + static const float EN = 0.00001f; + + /** + * @brief sqrt(x). + * + * @param x as a base + * @return sqrt(x) + */ + inline float sqrt_newton(float x) + { + /** + * Use Newton iteration method to find the square root + * */ + if (x == 0.f) + return 0.f; + float result = x; + float last_value; + do + { + last_value = result; + result = (last_value + x / last_value) * 0.5; + } while (DL_ABS(result - last_value) > EN); + return result; + } + + /** + * @brief n-th root of x. + * + * @param x as a base + * @param n root times + * @return n-th root of x + */ + inline float root_newton(float x, int n) + { + if (n == 2) + return sqrt_newton(x); + if (n == 0) + return 1.f; + if (n == 1) + return x; + if (x == 0.f) + return 0.f; + float result = x; + float last_value; + float _n = (float)((n - 1) * n); + do + { + last_value = result; + result = _n * last_value + x / (n * power(last_value, n - 1)); + } while (DL_ABS(result - last_value) > EN); + return result; + } + + /** + * @brief atan(x). + * + * @param x as an input + * @return atan(x) in range [-pi/2, pi/2] + */ + inline float atan(float x) + { + return x * (0.78539816 - (DL_ABS(x) - 1) * (0.2447 + 0.0663 * DL_ABS(x))); + // float s = x*x; + // return ((-0.0464964749 * s + 0.15931422) * s - 0.327622764) * s * x + x; + } + + // TODO:@yuanjiong + /** + * @brief + * + * @param x + * @param y + * @return in range [-pi, pi] + */ + inline float atan2(float x, float y) + { + float ax = DL_ABS(x); + float ay = DL_ABS(y); + float eps = 1e-8; + float a = DL_MIN(ax, ay) / (DL_MAX(ax, ay) + eps); + float r = atan(a); //[0, pi/2] + if (ay > ax) + r = 1.57079633 - r; + if (x < 0) + r = 3.14159265 - r; + if (y < 0) + r = -r; + + return r; + } + + /** + * @brief acos(x). + * + * @param x as an input + * @return acos(x) in range [-pi/2, pi/2] + */ + inline float acos(float x) + { + return atan2(x, sqrt_newton(1.0 - x * x)); + } + + /** + * @brief asin(x). + * + * @param x as an input + * @return asin(x) in range [0, pi] + */ + inline float asin(float x) + { + return atan2(sqrt_newton(1.0 - x * x), x); + } + + /** + * @brief e^x + * + * @param x exponent + * @param steps iteration steps + * @return e^x + */ + inline float exp_fast(double x, int steps) + { + x = 1.0 + x / (1 << steps); + for (int i = 0; i < steps; i++) + x *= x; + return x; + } + } +} \ No newline at end of file diff --git a/tools/sdk/esp32/include/esp-face/include/math/dl_math_matrix.hpp b/tools/sdk/esp32/include/esp-face/include/math/dl_math_matrix.hpp new file mode 100644 index 00000000000..30718f85c32 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/math/dl_math_matrix.hpp @@ -0,0 +1,397 @@ +#pragma once + +#include +#include +#include +#include +#include "dl_define.hpp" +#include "dl_tool.hpp" +#include "dl_variable.hpp" +#include "esp_timer.h" + +namespace dl +{ + namespace math + { + /** + * @brief the Matrix class + * + * @tparam T + */ + template + class Matrix + { + public: + T **array; + int h; + int w; + Matrix() : h(0), w(0) + { + this->array = NULL; + } + + Matrix(int h, int w) : h(h), w(w) + { + this->calloc_element(); + } + + Matrix(int h, int w, T s) : h(h), w(w) + { + this->calloc_element(); + this->set_value(s); + } + + Matrix(const Matrix &mat) : h(mat.h), w(mat.w) + { + this->calloc_element(); + this->set_value(mat); + } + virtual ~Matrix() + { + if (this->array != NULL) + { + for (int i = 0; i < this->h; i++) + { + free(this->array[i]); + } + free(this->array); + this->array = NULL; + } + } + + /** + * @brief calloc the matrix element + * + */ + void calloc_element() + { + if ((this->h > 0) && (this->w > 0)) + { + this->array = (T **)calloc(this->h, sizeof(T *)); + for (int i = 0; i < this->h; i++) + { + this->array[i] = (T *)calloc(this->w, sizeof(T)); + } + } + else + { + this->array = NULL; + } + } + + /** + * @brief Set the matrix element to random number. + * + * @param thresh the max abs value of the element. + */ + void set_random(T thresh = 1) + { + unsigned int seed = esp_timer_get_time(); + srand(seed); + for (int i = 0; i < this->h; i++) + { + for (int j = 0; j < this->w; j++) + { + this->array[i][j] = ((T)rand()) / (T)(RAND_MAX)*thresh; + } + } + } + + /** + * @brief Set the small value to zero + * + * @param thresh the threshold of small value + */ + void set_zero(T thresh = 1e-8) + { + for (int i = 0; i < this->h; i++) + { + for (int j = 0; j < this->w; j++) + { + if (DL_ABS(this->array[i][j]) < thresh) + { + this->array[i][j] = 0; + } + } + } + } + + /** + * @brief Set the matrix value from a vector + * + * @tparam TT + * @param mat the input vector + */ + template + void set_value(std::vector mat) + { + int area = this->w * this->h; + assert(area == mat.size()); + int index = 0; + for (int i = 0; i < this->h; i++) + { + for (int j = 0; j < this->w; j++) + { + this->array[i][j] = (T)(mat[index++]); + } + } + } + + /** + * @brief Set the matrix value from another matrix. + * + * @tparam TT + * @param mat the input matrix. + */ + template + void set_value(const Matrix &mat) + { + assert((this->h == mat.h) && (this->w == mat.w)); + for (int i = 0; i < this->h; i++) + { + for (int j = 0; j < this->w; j++) + { + this->array[i][j] = (T)(mat.array[i][j]); + } + } + } + + /** + * @brief Set a part of the matrix value from another matrix. + * + * @param h_start the start index of height + * @param h_end the end index of height + * @param w_start the start index of width + * @param w_end the end index of width + * @param mat the input matrix + */ + void set_value(int h_start, int h_end, int w_start, int w_end, const Matrix &mat) + { + int h = h_end - h_start; + int w = w_end - w_start; + + assert((h == mat.h) && (w == mat.w)); + assert((h_end <= this->h) && (w_end <= this->w) && (h_start >= 0) && (w_start >= 0)); + for (int i = 0; i < h; i++) + { + for (int j = 0; j < w; j++) + { + this->array[i + h_start][j + w_start] = mat.array[i][j]; + } + } + } + + /** + * @brief Set the matrix value to a constant. + * + * @tparam TT + * @param s the input value. + */ + template + void set_value(TT s) + { + for (int i = 0; i < this->h; i++) + { + for (int j = 0; j < this->w; j++) + { + this->array[i][j] = (T)s; + } + } + } + + /** + * @brief print the matrix element. + * + */ + void print_value() const + { + printf("h: %d, w: %d\n", this->h, this->w); + for (int i = 0; i < this->h; i++) + { + for (int j = 0; j < this->w; j++) + { + printf("%f ", (float)(this->array[i][j])); + } + printf("\n"); + } + } + + /** + * @brief do matrix multiply + * + * @param input the input matrix + * @return Matrix the output matrix + */ + Matrix matmul(const Matrix &input) const; + + /** + * @brief transpose the matrix + * + * @return Matrix the transposed matrix + */ + Matrix transpose() const; + + /** + * @brief get the inverse matrix + * + * @return Matrix the output matrix + */ + Matrix inverse() const; + + /** + * @brief get the diagonal of the matrix + * + * @return Matrix the diagonal + */ + Matrix diagonal() const; + + /** + * @brief slice the matrix + * + * @param h_start the start index of height + * @param h_end the end index of height + * @param w_start the start index of width + * @param w_end the end index of width + * @return Matrix the output. + */ + Matrix slice(int h_start, int h_end, int w_start, int w_end) const; + + /** + * @brief get an identity matrix + * + * @param n the dim of the identity matrix + * @return Matrix the output + */ + static Matrix identity(int n) + { + Matrix A(n, n); + for (int i = 0; i < n; ++i) + { + A.array[i][i] = 1; + } + return A; + } + + /** + * @brief get a diag matrix + * + * @param d the diagonal value. + * @return Matrix the output + */ + static Matrix diag(const Matrix &d) + { + assert(d.h == 1); + Matrix A(d.w, d.w); + for (int i = 0; i < d.w; ++i) + { + A.array[i][i] = d.array[0][i]; + } + return A; + } + + + static Matrix arange(uint32_t n) + { + Matrix A(1, n); + for (int i = 0; i < n; ++i) + { + A.array[0][i] = i; + } + return A; + } + + static Matrix arange(uint32_t n1, uint32_t n2) + { + int len = n2 - n1; + assert(len > 0); + Matrix A(1, len); + for (int i = 0; i < len; ++i) + { + A.array[0][i] = n1 + i; + } + + return A; + } + + /** + * @brief get the F_norm of the matrix + * + * @return T the output F_norm + */ + T F_norm() const + { + T f_n = 0.0; + for (int i = 0; i < this->h; ++i) + { + for (int j = 0; j < this->w; ++j) + { + f_n += (this->array[i][j] * this->array[i][j]); + } + } + f_n = sqrt_newton(f_n); + return f_n; + } + + Matrix &operator=(const Matrix &A) + { + if ((A.h == this->h) && (A.w == this->w)) + { + for (int i = 0; i < A.h; ++i) + { + for (int j = 0; j < A.w; ++j) + { + this->array[i][j] = A.array[i][j]; + } + } + } + else + { + if (this->array != NULL) + { + for (int i = 0; i < this->h; ++i) + { + free(this->array[i]); + } + free(this->array); + this->array = NULL; + } + this->h = A.h; + this->w = A.w; + if ((A.h > 0) && (A.w > 0)) + { + this->calloc_element(); + this->set_value(A); + } + } + return *this; + } + }; + + /** + * @brief Get the affine transform matrix + * + * @param source_coord the source coordinates + * @param dest_coord the target coordinates + * @return Matrix the output matrix + */ + Matrix get_affine_transform(Matrix &source_coord, Matrix &dest_coord); + + /** + * @brief Get the similarity transform matrix + * + * @param source_coord the source coordinates + * @param dest_coord the target coordinates + * @return Matrix the output matrix + */ + Matrix get_similarity_transform(Matrix &source_coord, Matrix &dest_coord); + + /** + * @brief Get the perspective transform matrix + * + * @param source_coord the source coordinates + * @param dest_coord the target coordinates + * @return Matrix the output matrix + */ + Matrix get_perspective_transform(Matrix &source_coord, Matrix &dest_coord); + } // namespace math +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32/include/esp-face/include/model_zoo/cat_face_detect_mn03.hpp b/tools/sdk/esp32/include/esp-face/include/model_zoo/cat_face_detect_mn03.hpp new file mode 100644 index 00000000000..6d952dc44ab --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/model_zoo/cat_face_detect_mn03.hpp @@ -0,0 +1,47 @@ +#pragma once + +#include +#include +#include +#include "dl_detect_define.hpp" + +/** + * @brief Hardware Requirement. + * - flash 310kB + */ + +class CatFaceDetectMN03 +{ +private: + void *model; + +public: + /** + * @brief Construct a new Cat Face Detect MN03 object. + * + * @param score_threshold predicted boxes with score lower than the threshold will be filtered out + * @param nms_threshold predicted boxes with IoU higher than the threshold will be filtered out + * @param top_k first k highest score boxes will be remained + * @param resize_scale resize scale to implement on input image + */ + CatFaceDetectMN03(const float score_threshold, const float nms_threshold, const int top_k, const float resize_scale); + + /** + * @brief Destroy the Cat Face Detect MN03 object. + * + */ + ~CatFaceDetectMN03(); + + /** + * @brief Inference. + * + * @tparam T supports uint8_t and uint16_t + * - uint8_t: input image is RGB888 + * - uint16_t: input image is RGB565 + * @param input_element pointer of input image + * @param input_shape shape of input image + * @return detection result + */ + template + std::list &infer(T *input_element, std::vector input_shape); +}; diff --git a/tools/sdk/esp32/include/esp-face/include/model_zoo/face_recognition_112_v1_s16.hpp b/tools/sdk/esp32/include/esp-face/include/model_zoo/face_recognition_112_v1_s16.hpp new file mode 100644 index 00000000000..91f7747fe3f --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/model_zoo/face_recognition_112_v1_s16.hpp @@ -0,0 +1,30 @@ +#pragma once + +#include "dl_variable.hpp" +#include "face_recognition_tool.hpp" +#include "face_recognizer.hpp" +#include + +using namespace dl; + +/** + * @brief face recognition model v1 + * input size: 112 x 112 x 3 + * quantization mode: S16 + * + */ +class FaceRecognition112V1S16 : public FaceRecognizer +{ + public: + /** + * @brief Construct a new Face_Recognition_112_V1_S16 object + * + */ + FaceRecognition112V1S16(); + + /** + * @brief Destroy the Face_Recognition_112_V1_S16 object + * + */ + ~FaceRecognition112V1S16(); +}; \ No newline at end of file diff --git a/tools/sdk/esp32/include/esp-face/include/model_zoo/face_recognition_112_v1_s8.hpp b/tools/sdk/esp32/include/esp-face/include/model_zoo/face_recognition_112_v1_s8.hpp new file mode 100644 index 00000000000..ba377713ca2 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/model_zoo/face_recognition_112_v1_s8.hpp @@ -0,0 +1,30 @@ +#pragma once + +#include "dl_variable.hpp" +#include "face_recognition_tool.hpp" +#include "face_recognizer.hpp" +#include + +using namespace dl; + +/** + * @brief face recognition model v1 + * input size: 112 x 112 x 3 + * quantization mode: S8 + * + */ +class FaceRecognition112V1S8 : public FaceRecognizer +{ + public: + /** + * @brief Construct a new Face_Recognition_112_V1_S8 object + * + */ + FaceRecognition112V1S8(); + + /** + * @brief Destroy the Face Recognition_112_V1_S8 object + * + */ + ~FaceRecognition112V1S8(); +}; \ No newline at end of file diff --git a/tools/sdk/esp32/include/esp-face/include/model_zoo/face_recognition_tool.hpp b/tools/sdk/esp32/include/esp-face/include/model_zoo/face_recognition_tool.hpp new file mode 100644 index 00000000000..12fe8a842a2 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/model_zoo/face_recognition_tool.hpp @@ -0,0 +1,162 @@ +#pragma once + +#include "dl_variable.hpp" +#include "dl_define.hpp" +#include "dl_tool.hpp" +#include "dl_math.hpp" +#include "dl_math_matrix.hpp" +#include +#include +#include +#include +#include + +/** + * @brief struct of face similarity + * + */ +typedef struct +{ + int id; + std::string name; + float similarity; +} face_info_t; + + +/** + * @brief Face ID + * + * @tparam feature_t + */ +template +class FaceID +{ +public: + int id; /**/ + dl::Tensor id_emb; /**/ + std::string name; /**/ + + /** + * @brief Construct a new Face ID object + * + * @param id id index + * @param id_emb id embedding + * @param name id name + */ + FaceID(int id, dl::Tensor &id_emb, std::string name = ""); + + /** + * @brief Destroy the Face ID object + * + */ + ~FaceID() {} + + /** + * @brief print the face id information + * + */ + void print(); +}; + +namespace face_recognition_tool +{ + /** + * @brief l2 normalize the feautre + * + * @param feature + */ + void l2_norm(dl::Tensor &feature); + + /** + * @brief calculate the cosine distance of the input ids + * + * @param id_1 id 1 + * @param id_2 id 2 + * @param normalized_ids true: the input ids have been normalized. + * false: the input ids have not been normlized + * @param type 0: cos dist: [-1, 1] + * 1: normalzied cos dist: [0, 1] + * @return float the cosine distance + */ + float cos_distance(dl::Tensor &id_1, dl::Tensor &id_2, bool normalized_ids = true, int8_t type = 0); + + /** + * @brief transform the image to the input of a mfn model + * + * @tparam T + * @param image the input image. + * @param free_input true: free the input image. + * false: do not free the input image. + * @param do_padding true: pad the result. + * false: do not pad the result. + * @return dl::Tensor* + */ + template + dl::Tensor *transform_mfn_input(dl::Tensor &image, bool free_input = false, bool do_padding = true); + + /** + * @brief transform the image to the input of a mfn model + * + * @tparam T + * @param image the input image. + * @param output the preprocessed image. + * @param free_input true: free the input image. + * false: do not free the input image. + * @param do_padding true: pad the result. + * false: do not pad the result + */ + template + void transform_mfn_input(dl::Tensor &image, dl::Tensor &output, bool free_input = false, bool do_padding = true); + + /** + * @brief transform the mfn output embedding to a floating embedding + * + * @tparam T + * @param input the input embedding. + * @param norm true: normalize the output embedding. + * false: do not normalize the output embedding. + * @param free_input true: free the input embedding. + * false: do not free the input embedding. + * @return dl::Tensor* + */ + template + dl::Tensor *transform_mfn_output(dl::Tensor &input, bool norm = true, bool free_input = false); + + /** + * @brief transform the mfn output embedding to a floating embedding + * + * @tparam T + * @param input the input embedding. + * @param output the output embedding. + * @param norm true: normalize the output embedding. + * false: do not normalize the output embedding. + * @param free_input true: free the input embedding. + * false: do not free the input embedding. + */ + template + void transform_mfn_output(dl::Tensor &input, dl::Tensor &output, bool norm = true, bool free_input = false); + + /** + * @brief get the aligned face. + * + * @tparam T + * @param input input tensor + * @param output the output aligned face. + * @param landmarks the landmarks of the face. + */ + template + void align_face(dl::Tensor *input, dl::Tensor *output, std::vector &landmarks); + + /** + * @brief get the aligned face. + * + * @tparam T + * @param input input image with rgb565 format. + * @param shape the shape of the input image. + * @param output the output aligned face. + * @param landmarks the landmarks of the face. + */ + template + void align_face(uint16_t *input, std::vector shape, dl::Tensor *output, std::vector &landmarks); + +} // namespace face_recognition_tool diff --git a/tools/sdk/esp32/include/esp-face/include/model_zoo/face_recognizer.hpp b/tools/sdk/esp32/include/esp-face/include/model_zoo/face_recognizer.hpp new file mode 100644 index 00000000000..864881c984a --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/model_zoo/face_recognizer.hpp @@ -0,0 +1,220 @@ +#pragma once + +#include "dl_variable.hpp" +#include "face_recognition_tool.hpp" +#include + +using namespace dl; + +/** + * @brief + * + * @tparam feature_t + */ +template +class FaceRecognizer +{ + public: + /** + * @brief Construct a new Face Recognizer object + * + */ + FaceRecognizer(); + + /** + * @brief Destroy the Face Recognizer object + * + */ + virtual ~FaceRecognizer(); + + void *model; + + /** + * @brief Set the face recognition threshold [-1, 1], default thresh: 0.55 + * Note: If the similarity of two faces is greater than the threshold, they will be judged as the same person + * + * @param thresh + */ + void set_thresh(float thresh); + + /** + * @brief Get the current threshold of recognizer. + * + * @return float current threshold. + */ + float get_thresh(); + + /** + * @brief Get the input shape of the recognizer. + * + * @return std::vector the input shape of the recognizer. + */ + std::vector get_input_shape(); + + /** + * @brief do forward + * + * @param model_input the input data of the face recognition model. + * Note: the input data should have been preprocessed. + * @return Tensor& the output of the face recognition model. + */ + Tensor &forward(Tensor &model_input); + + /** + * @brief recognize face + * + * @param image_input the pointer of the input image with format bgr565. + * @param shape the shape of the input image + * @param landmarks face landmarks coordinates + * @return face_info_t the recognition result. + */ + face_info_t recognize(uint16_t *image_input, std::vector shape, std::vector &landmarks); + + /** + * @brief recognize face + * + * @param image_input the pointer of the input image with format bgr565. + * @param shape the shape of the input image + * @param aligned_face the Tensor to store the intermeidate aligned face. + * @param landmarks face landmarks coordinates + * @return face_info_t the recognition result. + */ + face_info_t recognize(uint16_t *image_input, std::vector shape, Tensor &aligned_face, std::vector &landmarks); + + /** + * @brief recognize face + * + * @param image_input the Tensor of input image with format bgr888. + * @param landmarks face landmarks coordinates + * @return face_info_t the recognition result. + */ + face_info_t recognize(Tensor &image_input, std::vector &landmarks); + + /** + * @brief recognize face + * + * @param image_input the Tensor of input image with format bgr888. + * @param aligned_face the Tensor to store the intermeidate aligned face. + * @param landmarks face landmarks coordinates + * @return face_info_t the recognition result. + */ + face_info_t recognize(Tensor &image_input, Tensor &aligned_face, std::vector &landmarks); + + /** + * @brief recognize face + * + * @param aligned_face the Tensor of the input aligned face with format bgr888. + * @return face_info_t the recognition result. + */ + face_info_t recognize(Tensor &aligned_face); + + /** + * @brief recognize the face embedding. + * + * @param emb the normalized face embbeding. + * @return face_info_t the recognition result. + */ + face_info_t recognize(Tensor &emb); + + /** + * @brief Get the index of the enrolled ids + * + * @return std::vector a vector of face ids index + */ + std::vector get_enrolled_ids(); + + /** + * @brief Get the face embedding + * + * @param id the face id index + * @return Tensor the face embedding of the face id index. + * if there is no matched id return the embedding of last input image. + */ + Tensor &get_face_emb(int id=-1); + + /** + * @brief Get the number of enrolled id + * + * @return int the number of enrolled id + */ + int get_enrolled_id_num(); + + /** + * @brief enroll face id + * + * @param image_input the pointer of the input image with format bgr565. + * @param shape the shape of the input image + * @param landmarks face landmarks coordinates + * @param name name of the face id. + * @return int the face id index of the enrolled embedding. + */ + int enroll_id(uint16_t *image_input, std::vector shape, std::vector &landmarks, std::string name=""); + + /** + * @brief enroll face id + * + * @param image_input the pointer of the input image with format bgr565. + * @param shape the shape of the input image + * @param aligned_face the Tensor to store the intermeidate aligned face. + * @param landmarks face landmarks coordinates + * @param name name of the face id. + * @return int the face id index of the enrolled embedding. + */ + int enroll_id(uint16_t *image_input, std::vector shape, Tensor &aligned_face, std::vector &landmarks, std::string name=""); + + /** + * @brief enroll face id + * + * @param image_input the Tensor of input image with format bgr888. + * @param landmarks face landmarks coordinates + * @param name name of the face id. + * @return int the face id index of the enrolled embedding. + */ + int enroll_id(Tensor &image_input, std::vector &landmarks, std::string name=""); + + /** + * @brief enroll face id + * + * @param image_input the Tensor of input image with format bgr888. + * @param aligned_face the Tensor to store the intermeidate aligned face. + * @param landmarks face landmarks coordinates + * @param name name of the face id. + * @return int the face id index of the enrolled embedding. + */ + int enroll_id(Tensor &image_input, Tensor &aligned_face, std::vector &landmarks, std::string name=""); + + /** + * @brief enroll face id + * + * @param aligned_face the Tensor of the input aligned face with format bgr888. + * @param name name of the face id. + * @return int the face id index of the enrolled embedding. + */ + int enroll_id(Tensor &aligned_face, std::string name=""); + + /** + * @brief enroll the normalzied face embedding. + * + * @param emb the normalized face embbeding. + * @param name name of the face id. + * @return int the face id index of the enrolled embedding. + */ + int enroll_id(Tensor &emb, std::string name=""); + + /** + * @brief delete the last enrolled face id. + * + * @return int the number of remained face ids. + * if the face ids list is empty, return -1 + */ + int delete_id(); + + /** + * @brief delete the face id with id index. + * + * @param id face id index. + * @return int the number of remained face ids. + * if there is no matched id return -1 + */ + int delete_id(int id); +}; \ No newline at end of file diff --git a/tools/sdk/esp32/include/esp-face/include/model_zoo/human_face_detect_mnp01.hpp b/tools/sdk/esp32/include/esp-face/include/model_zoo/human_face_detect_mnp01.hpp new file mode 100644 index 00000000000..62a25f0350c --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/model_zoo/human_face_detect_mnp01.hpp @@ -0,0 +1,41 @@ +#pragma once + +#include +#include +#include "dl_detect_define.hpp" + +class HumanFaceDetectMNP01 +{ +private: + void *model; + +public: + /** + * @brief Construct a new Human Face Detect MNP01 object. + * + * @param score_threshold predicted boxes with score lower than the threshold will be filtered out + * @param nms_threshold predicted boxes with IoU higher than the threshold will be filtered out + * @param top_k first k highest score boxes will be remained + */ + HumanFaceDetectMNP01(const float score_threshold, const float nms_threshold, const int top_k); + + /** + * @brief Destroy the Human Face Detect MNP01 object. + * + */ + ~HumanFaceDetectMNP01(); + + /** + * @brief Inference. + * + * @tparam T supports uint16_t and uint8_t, + * - uint16_t: input image is RGB565 + * - uint8_t: input image is RGB888 + * @param input_element pointer of input image + * @param input_shape shape of input image + * @param candidates candidate boxes on input image + * @return detection result + */ + template + std::list &infer(T *input_element, std::vector input_shape, std::list &candidates); +}; diff --git a/tools/sdk/esp32/include/esp-face/include/model_zoo/human_face_detect_msr01.hpp b/tools/sdk/esp32/include/esp-face/include/model_zoo/human_face_detect_msr01.hpp new file mode 100644 index 00000000000..94ba6ac909a --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/model_zoo/human_face_detect_msr01.hpp @@ -0,0 +1,40 @@ +#pragma once + +#include +#include +#include "dl_detect_define.hpp" + +class HumanFaceDetectMSR01 +{ +private: + void *model; + +public: + /** + * @brief Construct a new Human Face Detect MSR01 object + * + * @param score_threshold predicted boxes with score lower than the threshold will be filtered out + * @param nms_threshold predicted boxes with IoU higher than the threshold will be filtered out + * @param top_k first k highest score boxes will be remained + * @param resize_scale resize scale to implement on input image + */ + HumanFaceDetectMSR01(const float score_threshold, const float nms_threshold, const int top_k, float resize_scale); + + /** + * @brief Destroy the Human Face Detect MSR01 object + */ + ~HumanFaceDetectMSR01(); + + /** + * @brief Inference. + * + * @tparam T supports uint8_t and uint16_t + * - uint8_t: input image is RGB888 + * - uint16_t: input image is RGB565 + * @param input_element pointer of input image + * @param input_shape shape of input image + * @return detection result + */ + template + std::list &infer(T *input_element, std::vector input_shape); +}; diff --git a/tools/sdk/esp32/include/esp-face/include/nn/dl_nn.hpp b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn.hpp new file mode 100644 index 00000000000..6dba8016f26 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn.hpp @@ -0,0 +1,61 @@ +#pragma once +#include +#include "dl_define.hpp" +#include "dl_tool.hpp" + +namespace dl +{ + namespace nn + { + /** + * @brief Get the output shape object + * + * @param input_shape input shape + * @param filter_shape filter shape with dilation + * @param stride_y stride in height + * @param stride_x stride in width + * @param pad_type one of PADDING_VALID or PADDING_SAME or PADDING_SAME_MXNET + * @param is_conv2d one of true or false, + * - true: serve for Conv2D + * - false: serve for other operations + * @return std::vector + */ + std::vector get_output_shape(const std::vector &input_shape, const std::vector &filter_shape, const int stride_y, const int stride_x, const padding_type_t pad_type, const bool is_conv2d = false); + + /** + * @brief Get the pad size object + * + * @param output_shape output shape + * @param input_shape input shape + * @param filter_shape filter shape with dilation + * @param stride_y stride in height + * @param stride_x stride in width + * @param padding_type one of PADDING_VALID or PADDING_SAME or PADDING_SAME_MXNET + * @return padding size + */ + std::vector get_pad_size(const std::vector &output_shape, const std::vector &input_shape, const std::vector &filter_shape, const int stride_y, const int stride_x, const padding_type_t padding_type); + } // namespace nn +} // namespace dl + +#if DL_LOG_NN_LATENCY +/** + * @brief Initialize. + */ +#define DL_LOG_NN_LATENCY_INIT() dl::tool::Latency latency + +/** + * @brief Time starts. + */ +#define DL_LOG_NN_LATENCY_START() latency.start() + +/** + * @brief Time ends and printed. + */ +#define DL_LOG_NN_LATENCY_END(key) \ + latency.end(); \ + latency.print("nn", key) +#else +#define DL_LOG_NN_LATENCY_INIT() +#define DL_LOG_NN_LATENCY_START() +#define DL_LOG_NN_LATENCY_END(key) +#endif diff --git a/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_add2d.hpp b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_add2d.hpp new file mode 100644 index 00000000000..d296be5350b --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_add2d.hpp @@ -0,0 +1,91 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn.hpp" + +namespace dl +{ + namespace nn + { + /** + * @brief activation(add2d(input0, input1)). + * + * @param output as an output + * @param input0 as one input + * @param input1 as another input + * @param activation activation of add2d, if you don't specify anything, no activation is applied + * @param assign_core not effective yet + * @param output_exponent exponent of output, only and must specify if inplace operation happens + */ + void add2d(Tensor &output, + Tensor &input0, + Tensor &input1, + const Activation *const activation = NULL, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE, + const int output_exponent = INT_MIN); + + /** + * @brief activation(add2d(input0, input1)). + * + * @param output as an output + * @param input0 as one input + * @param input1 as another input + * @param activation activation of add2d, if you don't specify anything, no activation is applied + * @param assign_core not effective yet + * @param output_exponent exponent of output, only and must specify if inplace operation happens + */ + void add2d(Tensor &output, + Tensor &input0, + Tensor &input1, + const Activation *const activation = NULL, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE, const int output_exponent = INT_MIN); + + /** + * @brief activation(add2d(input0, input1)) + * + * @tparam inplace: whether directly store the output to input0 + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + * @param output_exponent exponent of output + * @param input0 as one input + * @param input1 as another input + * @param activation activation of add2d, if you don't specify anything, no activation is applied + * @param assign_core not effective yet + * @param inplace whether directly store the output to input0 + * @return add2d result or no return(result store to input0) + */ + template + auto add2d(const int output_exponent, + Tensor &input0, + Tensor &input1, + const Activation *activation, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) -> typename std::conditional>::type + { + assert(input0.is_same_shape(input1)); + + DL_LOG_NN_LATENCY_INIT(); + + Tensor output; + if constexpr(!inplace) + { + DL_LOG_NN_LATENCY_START(); + output.set_exponent(output_exponent).set_shape(input0.shape).apply_element(); + DL_LOG_NN_LATENCY_END("apply"); + + DL_LOG_NN_LATENCY_START(); + add2d(output, input0, input1, activation, assign_core); + DL_LOG_NN_LATENCY_END("add2d"); + return output; + } + else + { + DL_LOG_NN_LATENCY_START(); + add2d(input0, input0, input1, activation, assign_core, output_exponent); + input0.set_exponent(output_exponent); + DL_LOG_NN_LATENCY_END("add2d"); + } + } + } // namespace nn +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_avg_pool2d.hpp b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_avg_pool2d.hpp new file mode 100644 index 00000000000..5b298d98c44 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_avg_pool2d.hpp @@ -0,0 +1,102 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn.hpp" +#include + +namespace dl +{ + namespace nn + { + /** + * @brief avg_pool2d(input). + * + * @param output as an output + * @param input as an input + * @param padding padding size needed in [top, bottom, left, right] of this operation + * @param filter_shape filter_shape in [filter_height, filter_width] + * @param stride_y stride in height + * @param stride_x stride in width + * @param assign_core not effective yet + */ + void avg_pool2d(Tensor &output, + Tensor &input, + std::vector &padding, + std::vector &filter_shape, + const int stride_y, + const int stride_x, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief avg_pool2d(input). + * + * @param output as an output + * @param input as an input + * @param padding padding size needed in [top, bottom, left, right] of this operation + * @param filter_shape filter_shape in [filter_height, filter_width] + * @param stride_y stride in height + * @param stride_x stride in width + * @param assign_core not effective yet + */ + void avg_pool2d(Tensor &output, + Tensor &input, + std::vector &padding, + std::vector &filter_shape, + const int stride_y, + const int stride_x, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief avg_pool2d(input). + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + * @param output_exponent exponent of output + * @param input as an input + * @param filter_shape filter_shape in [filter_height, filter_width] + * @param stride_y stride in height + * @param stride_x stride in width + * @param padding_type one of PADDING_VALID or PADDING_SAME or PADDING_SAME_MXNET, + * - PADDING_VALID: no padding + * PADDING_SAME and PADDING_SAME_MXNET results in padding with zeros evenly to the left/right or up/down of the input + * such that output has the same height/width dimension as the input, + * - PADDING_SAME results padding in TensorFlow style + * - PADDING_SAME_MXNET results padding in MXNET style + * @param assign_core not effective yet + * @return avg_pool2d result + */ + template + Tensor avg_pool2d(const int output_exponent, + Tensor &input, + std::vector filter_shape, + const int stride_y, + const int stride_x, + const padding_type_t padding_type, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_NN_LATENCY_INIT(); + + DL_LOG_NN_LATENCY_START(); + std::vector output_shape = get_output_shape(input.shape, filter_shape, stride_y, stride_x, padding_type); + Tensor output; + output.set_exponent(output_exponent).set_shape(output_shape).apply_element(); + DL_LOG_NN_LATENCY_END("apply"); + + DL_LOG_NN_LATENCY_START(); + if (padding_type == PADDING_SAME || padding_type == PADDING_SAME_MXNET) + { + std::vector padding = get_pad_size(output_shape, input.shape, filter_shape, stride_y, stride_x, padding_type); + input.set_padding_size(padding); + } + DL_LOG_NN_LATENCY_END("padding"); + + DL_LOG_NN_LATENCY_START(); + avg_pool2d(output, input, input.padding, filter_shape, stride_y, stride_x, assign_core); + DL_LOG_NN_LATENCY_END("avg_pool2d"); + + return output; + } + } // namespace nn +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_concat2d.hpp b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_concat2d.hpp new file mode 100644 index 00000000000..adcae1e7a7d --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_concat2d.hpp @@ -0,0 +1,22 @@ +#pragma once + +#include +#include "dl_variable.hpp" + +namespace dl +{ + namespace nn + { + /** + * @brief concat2d(input_1, input_2, ...) + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + * @param output as an output + * @param inputs a bundle of inputs to be concatenated + */ + template + void concat2d(Tensor &output, std::vector> inputs); + } // namespace nn +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_conv2d.hpp b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_conv2d.hpp new file mode 100644 index 00000000000..77e2c617d04 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_conv2d.hpp @@ -0,0 +1,116 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn.hpp" + +namespace dl +{ + namespace nn + { + /** + * @brief activation(conv2d(input, filter) + bias). + * NOTE: When padding_type is SAME, make sure padding is already added in input. + * + * @param output as an output + * @param input as an input + * @param padding padding size needed in [top, bottom, left, right] of this operation + * @param filter filter of conv2d + * @param stride_y stride in height + * @param stride_x stride in width + * @param bias bias of conv2d, if you don't specify anything, no bias is added + * @param activation activation of conv2d, if you don't specify anything, no activation is applied + * @param assign_core not effective yet + */ + void conv2d(Tensor &output, + Tensor &input, + std::vector &padding, + const Filter &filter, + const int stride_y, + const int stride_x, + const Bias *const bias = NULL, + const Activation *const activation = NULL, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief activation(conv2d(input, filter) + bias). + * NOTE: When padding_type is SAME, make sure padding is already added in input. + * + * @param output as an output + * @param input as an input + * @param padding padding size needed in [top, bottom, left, right] of this operation + * @param filter filter of conv2d + * @param stride_y stride in height + * @param stride_x stride in width + * @param bias bias of conv2d, if you don't specify anything, no bias is added + * @param activation activation of conv2d, if you don't specify anything, no activation is applied + * @param assign_core not effective yet + */ + void conv2d(Tensor &output, + Tensor &input, + std::vector &padding, + const Filter &filter, + const int stride_y, + const int stride_x, + const Bias *const bias = NULL, + const Activation *const activation = NULL, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief activation(conv2d(input, filter) + bias). + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + * @param output_exponent exponent of output + * @param input as an input + * @param filter Filter of conv2d + * @param stride_y stride in height + * @param stride_x stride in width + * @param padding_type one of PADDING_VALID or PADDING_SAME or PADDING_SAME_MXNET, + * - PADDING_VALID: no padding + * PADDING_SAME and PADDING_SAME_MXNET results in padding with zeros evenly to the left/right or up/down of the input + * such that output has the same height/width dimension as the input, + * - PADDING_SAME results padding in TensorFlow style + * - PADDING_SAME_MXNET results padding in MXNET style + * @param bias bias of conv2d, if you don't specify anything, no bias is added + * @param activation activation of conv2d, if you don't specify anything, no activation is applied + * @param assign_core not effective yet + * @return conv2d result + */ + template + Tensor conv2d(const int output_exponent, + Tensor &input, + const Filter &filter, + const int stride_y, + const int stride_x, + const padding_type_t padding_type, + const Bias *bias, + const Activation *activation, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_NN_LATENCY_INIT(); + + DL_LOG_NN_LATENCY_START(); + std::vector output_shape = get_output_shape(input.shape, filter.shape_with_dilation, stride_y, stride_x, padding_type, true); + Tensor output; + output.set_exponent(output_exponent).set_shape(output_shape).apply_element(); + DL_LOG_NN_LATENCY_END("apply"); + + DL_LOG_NN_LATENCY_START(); + if (padding_type == PADDING_SAME || padding_type == PADDING_SAME_MXNET) + { + std::vector padding = get_pad_size(output_shape, input.shape, filter.shape_with_dilation, stride_y, stride_x, padding_type); + input.set_padding_size(padding); + input.set_padding_value(padding, 0); + } + DL_LOG_NN_LATENCY_END("padding"); + + DL_LOG_NN_LATENCY_START(); + conv2d(output, input, input.padding, filter, stride_y, stride_x, bias, activation, assign_core); + DL_LOG_NN_LATENCY_END("conv2d"); + + return output; + } + } // namespace nn +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_depthwise_conv2d.hpp b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_depthwise_conv2d.hpp new file mode 100644 index 00000000000..6e972bfd81b --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_depthwise_conv2d.hpp @@ -0,0 +1,116 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn.hpp" + +namespace dl +{ + namespace nn + { + /** + * @brief activate(depthwise_conv2d(input, filter) + bias) + * NOTE: When padding_type is SAME, make sure padding is already added in input + * + * @param output as an output + * @param input as an input + * @param padding padding size needed in [top, bottom, left, right] of this operation + * @param filter Filter of depthwise_conv2d + * @param stride_y stride in height + * @param stride_x stride in width + * @param bias bias of depthwise_conv2d, if you don't specify anything, no bias is added + * @param activation activation of depthwise_conv2d, if you don't specify anything, no activation is applied + * @param assign_core not effective yet + */ + void depthwise_conv2d(Tensor &output, + Tensor &input, + std::vector &padding, + const Filter &filter, + const int stride_y, + const int stride_x, + const Bias *bias = NULL, + const Activation *activation = NULL, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief activate(depthwise_conv2d(input, filter) + bias) + * NOTE: When padding_type is SAME, make sure padding is already added in input + * + * @param output as an output + * @param input as an input + * @param padding padding size needed in [top, bottom, left, right] of this operation + * @param filter filter of depthwise_conv2d + * @param stride_y stride in height + * @param stride_x stride in width + * @param bias bias of depthwise_conv2d, if you don't specify anything, no bias is added + * @param activation activation of depthwise_conv2d, if you don't specify anything, no activation is applied + * @param assign_core not effective yet + */ + void depthwise_conv2d(Tensor &output, + Tensor &input, + std::vector &padding, + const Filter &filter, + const int stride_y, + const int stride_x, + const Bias *bias = NULL, + const Activation *activation = NULL, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief activation(depthwise_conv2d(input, filter) + bias) + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + * @param output_exponent exponent of output + * @param input as an input + * @param filter filter of depthwise_conv2d + * @param stride_y stride in height + * @param stride_x stride in width + * @param pad_type one of PADDING_VALID or PADDING_SAME or PADDING_SAME_MXNET, + * - PADDING_VALID means no padding + * PADDING_SAME and PADDING_SAME_MXNET results in padding with zeros evenly to the left/right or up/down of the input + * such that output has the same height/width dimension as the input, + * - PADDING_SAME results padding in TensorFlow style + * - PADDING_SAME_MXNET results padding in MXNET style + * @param bias bias of depthwise_conv2d, if you don't specify anything, no bias is added + * @param activation activation of depthwise_conv2d, if you don't specify anything, no activation is applied + * @param assign_core not effective yet + * @return depthwise_conv2d result + */ + template + Tensor depthwise_conv2d(const int output_exponent, + Tensor &input, + const Filter &filter, + const int stride_y, + const int stride_x, + const padding_type_t padding_type, + const Bias *bias, + const Activation *activation, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_NN_LATENCY_INIT(); + + DL_LOG_NN_LATENCY_START(); + std::vector output_shape = get_output_shape(input.shape, filter.shape_with_dilation, stride_y, stride_x, padding_type); + Tensor output; + output.set_exponent(output_exponent).set_shape(output_shape).apply_element(); + DL_LOG_NN_LATENCY_END("apply"); + + DL_LOG_NN_LATENCY_START(); + if (padding_type == PADDING_SAME || padding_type == PADDING_SAME_MXNET) + { + std::vector padding = get_pad_size(output_shape, input.shape, filter.shape_with_dilation, stride_y, stride_x, padding_type); + input.set_padding_size(padding); + input.set_padding_value(padding, 0); + } + DL_LOG_NN_LATENCY_END("padding"); + + DL_LOG_NN_LATENCY_START(); + depthwise_conv2d(output, input, input.padding, filter, stride_y, stride_x, bias, activation, assign_core); + DL_LOG_NN_LATENCY_END("depthwise_conv2d"); + + return output; + } + } // namespace nn +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_global_avg_pool2d.hpp b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_global_avg_pool2d.hpp new file mode 100644 index 00000000000..723ca9eddc4 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_global_avg_pool2d.hpp @@ -0,0 +1,66 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn.hpp" +#include + +namespace dl +{ + namespace nn + { + /** + * @brief global_avg_pool2d(input). + * + * @param output as an output + * @param input as an input + * @param assign_core not effective yet + */ + void global_avg_pool2d(Tensor &output, + Tensor &input, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief global_avg_pool2d(input). + * + * @param output as an output + * @param input as an input + * @param assign_core not effective yet + */ + void global_avg_pool2d(Tensor &output, + Tensor &input, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief global_avg_pool2d(input). + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + * @param output_exponent exponent of output + * @param input as an input + * @param assign_core not effective yet + * @return global_avg_pool2d result + */ + template + Tensor global_avg_pool2d(const int output_exponent, + Tensor &input, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_NN_LATENCY_INIT(); + + DL_LOG_NN_LATENCY_START(); + std::vector output_shape(input.shape.size(), 1); + output_shape[2] = input.shape[2]; + Tensor output; + output.set_exponent(output_exponent).set_shape(output_shape).apply_element(); + DL_LOG_NN_LATENCY_END("apply"); + + DL_LOG_NN_LATENCY_START(); + global_avg_pool2d(output, input, assign_core); + DL_LOG_NN_LATENCY_END("global_avg_pool2d"); + + return output; + } + } // namespace nn +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_global_max_pool2d.hpp b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_global_max_pool2d.hpp new file mode 100644 index 00000000000..945645cfd55 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_global_max_pool2d.hpp @@ -0,0 +1,64 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn.hpp" +#include + +namespace dl +{ + namespace nn + { + /** + * @brief global_max_pool2d(input). + * + * @param output as an output + * @param input as an input + * @param assign_core not effective yet + */ + void global_max_pool2d(Tensor &output, + Tensor &input, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief global_max_pool2d(input). + * + * @param output as an output + * @param input as an input + * @param assign_core not effective yet + */ + void global_max_pool2d(Tensor &output, + Tensor &input, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief global_max_pool2d(input). + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + * @param input as an input + * @param assign_core not effective yet + * @return global_max_pool2d result + */ + template + Tensor global_max_pool2d(Tensor &input, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_NN_LATENCY_INIT(); + + DL_LOG_NN_LATENCY_START(); + std::vector output_shape(input.shape.size(), 1); + output_shape[2] = input.shape[2]; + Tensor output; + output.set_exponent(input.exponent).set_shape(output_shape).apply_element(); + DL_LOG_NN_LATENCY_END("apply"); + + DL_LOG_NN_LATENCY_START(); + global_max_pool2d(output, input, assign_core); + DL_LOG_NN_LATENCY_END("global_max_pool2d"); + + return output; + } + } // namespace nn +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_leakyrelu.hpp b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_leakyrelu.hpp new file mode 100644 index 00000000000..d3738fc44ca --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_leakyrelu.hpp @@ -0,0 +1,82 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn.hpp" + +namespace dl +{ + namespace nn + { + /** + * @brief leakyrelu(input). + * + * @param output as an output + * @param input as an input + * @param activation_alpha quantized alpha + * @param activation_exponent exponent of quantized alpha + * @param assign_core not effective yet + */ + void leakyrelu(Tensor &output, + Tensor &input, + const int16_t activation_alpha, + const int activation_exponent, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief leakyrelu(input). + * + * @param output as an output + * @param input as an input + * @param activation_alpha quantized alpha + * @param activation_exponent exponent of quantized alpha + * @param assign_core not effective yet + */ + void leakyrelu(Tensor &output, + Tensor &input, + const int8_t activation_alpha, + const int activation_exponent, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief leakyrelu(input) + * + * @tparam inplace: whether directly store the output to input + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + * @param input as an input + * @param activation_alpha quantized alpha + * @param activation_exponent exponent of quantized alpha + * @param assign_core not effective yet + * @return leakyrelu result or no return(result store to input) + */ + template + auto leakyrelu(Tensor &input, + const int activation_alpha, + const int activation_exponent, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) -> typename std::conditional>::type + { + DL_LOG_NN_LATENCY_INIT(); + Tensor output; + if constexpr(!inplace) + { + DL_LOG_NN_LATENCY_START(); + output.set_exponent(input.exponent).set_shape(input.shape).apply_element(); + DL_LOG_NN_LATENCY_END("apply"); + + DL_LOG_NN_LATENCY_START(); + leakyrelu(output, input, activation_alpha, activation_exponent, assign_core); + DL_LOG_NN_LATENCY_END("leakyrelu"); + + return output; + } + else + { + DL_LOG_NN_LATENCY_START(); + leakyrelu(input, input, activation_alpha, activation_exponent, assign_core); + DL_LOG_NN_LATENCY_END("leakyrelu"); + } + } + } // namespace nn +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_max2d.hpp b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_max2d.hpp new file mode 100644 index 00000000000..0a5e8f43221 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_max2d.hpp @@ -0,0 +1,81 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn.hpp" + +namespace dl +{ + namespace nn + { + /** + * @brief max2d(input0, input1) + * + * @param output as an output + * @param input0 as one input + * @param input1 as another input + * @param assign_core not effective yet + */ + void max2d(Tensor &output, + Tensor &input0, + Tensor &input1, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief max2d(input0, input1) + * + * @param output as an output + * @param input0 as one input + * @param input1 as another input + * @param assign_core not effective yet + * @param output_exponent exponent of output, only and must specify if inplace operation happens + */ + void max2d(Tensor &output, + Tensor &input0, + Tensor &input1, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief max2d(input0, input1) + * + * @tparam inplace: whether directly store the output to input0 + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + * @param input0 as one input + * @param input1 as another input + * @param assign_core not effective yet + * @return max2d result or no return(result store to input0) + */ + template + auto max2d(Tensor &input0, + Tensor &input1, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) -> typename std::conditional>::type + { + assert(input0.is_same_shape(input1)); + assert(input0.exponent == input1.exponent); + + DL_LOG_NN_LATENCY_INIT(); + Tensor output; + + if constexpr(!inplace) + { + DL_LOG_NN_LATENCY_START(); + output.set_exponent(input0.exponent).set_shape(input0.shape).apply_element(); + DL_LOG_NN_LATENCY_END("apply"); + + DL_LOG_NN_LATENCY_START(); + max2d(output, input0, input1, assign_core); + DL_LOG_NN_LATENCY_END("max2d"); + + return output; + } + else + { + DL_LOG_NN_LATENCY_START(); + max2d(input0, input0, input1, assign_core); + DL_LOG_NN_LATENCY_END("max2d"); + } + } + } // namespace nn +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_max_pool2d.hpp b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_max_pool2d.hpp new file mode 100644 index 00000000000..7f95f3d4278 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_max_pool2d.hpp @@ -0,0 +1,101 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn.hpp" +#include + +namespace dl +{ + namespace nn + { + /** + * @brief max_pool2d(input). + * + * @param output as an output + * @param input as an input + * @param padding padding size needed in [top, bottom, left, right] of this operation + * @param filter_shape filter shape in [filter_height, filter_width] + * @param stride_y stride in height + * @param stride_x stride in width + * @param assign_core not effective yet + */ + void max_pool2d(Tensor &output, + Tensor &input, + std::vector &padding, + std::vector &filter_shape, + const int stride_y, + const int stride_x, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief max_pool2d(input). + * + * @param output as an output + * @param input as an input + * @param padding padding size needed in [top, bottom, left, right] of this operation + * @param filter_shape filter shape in [filter_height, filter_width] + * @param stride_y stride in height + * @param stride_x stride in width + * @param assign_core not effective yet + */ + void max_pool2d(Tensor &output, + Tensor &input, + std::vector &padding, + std::vector &filter_shape, + const int stride_y, + const int stride_x, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief max_pool2d(input). + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + * @param input as an input + * @param filter_shape filter shape in [filter_height, filter_width] + * @param stride_y stride in height + * @param stride_x stride in width + * @param padding_type one of PADDING_VALID or PADDING_SAME or PADDING_SAME_MXNET, + * - PADDING_VALID: no padding + * PADDING_SAME and PADDING_SAME_MXNET results in padding with zeros evenly to the left/right or up/down of the input + * such that output has the same height/width dimension as the input, + * - PADDING_SAME results padding in TensorFlow style + * - PADDING_SAME_MXNET results padding in MXNET style + * @param assign_core not effective yet + * @return max_pool2d result + */ + template + Tensor max_pool2d(Tensor &input, + std::vector filter_shape, + const int stride_y, + const int stride_x, + const padding_type_t padding_type, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_NN_LATENCY_INIT(); + + DL_LOG_NN_LATENCY_START(); + std::vector output_shape = get_output_shape(input.shape, filter_shape, stride_y, stride_x, padding_type); + Tensor output; + output.set_exponent(input.exponent).set_shape(output_shape).apply_element(); + DL_LOG_NN_LATENCY_END("apply"); + + DL_LOG_NN_LATENCY_START(); + if (padding_type == PADDING_SAME || padding_type == PADDING_SAME_MXNET) + { + std::vector padding = get_pad_size(output_shape, input.shape, filter_shape, stride_y, stride_x, padding_type); + input.set_padding_size(padding); + input.set_padding_value(padding, 0); + } + DL_LOG_NN_LATENCY_END("padding"); + + DL_LOG_NN_LATENCY_START(); + max_pool2d(output, input, input.padding, filter_shape, stride_y, stride_x, assign_core); + DL_LOG_NN_LATENCY_END("max_pool2d"); + + return output; + } + } // namespace nn +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_min2d.hpp b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_min2d.hpp new file mode 100644 index 00000000000..71cb87d50d5 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_min2d.hpp @@ -0,0 +1,80 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn.hpp" + +namespace dl +{ + namespace nn + { + /** + * @brief min2d(input0, input1) + * + * @param output as an output + * @param input0 as one input + * @param input1 as another input + * @param assign_core + */ + void min2d(Tensor &output, + Tensor &input0, + Tensor &input1, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief min2d(input0, input1) + * + * @param output as an output + * @param input0 as one input + * @param input1 as another input + * @param assign_core + */ + void min2d(Tensor &output, + Tensor &input0, + Tensor &input1, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief min2d(input0, input1) + * + * @tparam inplace: whether directly store the output to input0 + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + * @param input0 as one input + * @param input1 as another input + * @param assign_core not effective yet + * @return min2d result or no return(result store to input0) + */ + template + auto min2d(Tensor &input0, + Tensor &input1, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) -> typename std::conditional>::type + { + assert(input0.is_same_shape(input1)); + assert(input0.exponent == input1.exponent); + + DL_LOG_NN_LATENCY_INIT(); + Tensor output; + + if constexpr(!inplace) + { + DL_LOG_NN_LATENCY_START(); + output.set_exponent(input0.exponent).set_shape(input0.shape).apply_element(); + DL_LOG_NN_LATENCY_END("apply"); + + DL_LOG_NN_LATENCY_START(); + min2d(output, input0, input1, assign_core); + DL_LOG_NN_LATENCY_END("min2d"); + + return output; + } + else + { + DL_LOG_NN_LATENCY_START(); + min2d(input0, input0, input1, assign_core); + DL_LOG_NN_LATENCY_END("min2d"); + } + } + } // namespace nn +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_mul2d.hpp b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_mul2d.hpp new file mode 100644 index 00000000000..410528a05a3 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_mul2d.hpp @@ -0,0 +1,91 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn.hpp" + +namespace dl +{ + namespace nn + { + /** + * @brief activation(mul2d(input0, input1)). + * + * @param output as an output + * @param input0 as one input + * @param input1 as another input + * @param activation activation of mul2d, if you don't specify anything, no activation is applied + * @param assign_core not effective yet + * @param output_exponent exponent of output, only and must specify if inplace operation happens + */ + void mul2d(Tensor &output, + Tensor &input0, + Tensor &input1, + const Activation *const activation = NULL, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE, + const int output_exponent = INT_MIN); + + /** + * @brief activation(mul2d(input0, input1)). + * + * @param output as an output + * @param input0 as one input + * @param input1 as another input + * @param activation activation of mul2d, if you don't specify anything, no activation is applied + * @param assign_core not effective yet + * @param output_exponent exponent of output, only and must specify if inplace operation happens + */ + void mul2d(Tensor &output, + Tensor &input0, + Tensor &input1, + const Activation *const activation = NULL, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE, + const int output_exponent = INT_MIN); + + /** + * @brief activation(mul2d(input0, input1)). + * + * @tparam inplace: whether directly store the output to input0 + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + * @param output_exponent exponent of output + * @param input0 as one input + * @param input1 as another input + * @param activation activation of mul2d, if you don't specify anything, no activation is applied + * @param assign_core not effective yet + * @return mul2d result or no return(result store to input0) + */ + template + auto mul2d(const int output_exponent, + Tensor &input0, + Tensor &input1, + const Activation *activation, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) -> typename std::conditional>::type + { + assert(input0.is_same_shape(input1)); + + DL_LOG_NN_LATENCY_INIT(); + Tensor output; + + if constexpr(!inplace) + { + DL_LOG_NN_LATENCY_START(); + output.set_exponent(output_exponent).set_shape(input0.shape).apply_element(); + DL_LOG_NN_LATENCY_END("apply"); + + DL_LOG_NN_LATENCY_START(); + mul2d(output, input0, input1, activation, assign_core); + DL_LOG_NN_LATENCY_END("mul2d"); + + return output; + } + else + { + DL_LOG_NN_LATENCY_START(); + mul2d(input0, input0, input1, activation, assign_core, output_exponent); + DL_LOG_NN_LATENCY_END("mul2d"); + } + } + } // namespace nn +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_prelu.hpp b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_prelu.hpp new file mode 100644 index 00000000000..fb4315d9fc3 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_prelu.hpp @@ -0,0 +1,82 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn.hpp" + +namespace dl +{ + namespace nn + { + /** + * @brief prelu(input). + * + * @param output as an output + * @param input as an input + * @param activation_element quantized alpha elements along channel axis + * @param activation_exponent exponent of quantized alpha elements + * @param assign_core not effective yet + */ + void prelu(Tensor &output, + Tensor &input, + const int16_t *activation_element, + const int activation_exponent, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief prelu(input). + * + * @param output as an output + * @param input as an input + * @param activation_element quantized alpha elements along channel axis + * @param activation_exponent exponent of quantized alpha elements + * @param assign_core not effective yet + */ + void prelu(Tensor &output, + Tensor &input, + const int8_t *activation_element, + const int activation_exponent, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief prelu(input) + * + * @tparam inplace: whether directly store the output to input + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + * @param input as an input + * @param activation_element quantized alpha elements along channel axis + * @param activation_exponent exponent of quantized alpha elements + * @param assign_core not effective yet + * @return prelu result or no return(result store to input) + */ + template + auto prelu(Tensor &input, + const feature_t *activation_element, + const int activation_exponent, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) -> typename std::conditional>::type + { + DL_LOG_NN_LATENCY_INIT(); + Tensor output; + if constexpr(!inplace) + { + DL_LOG_NN_LATENCY_START(); + output.set_exponent(input.exponent).set_shape(input.shape).apply_element(); + DL_LOG_NN_LATENCY_END("apply"); + + DL_LOG_NN_LATENCY_START(); + prelu(output, input, activation_element, activation_exponent, assign_core); + DL_LOG_NN_LATENCY_END("prelu"); + + return output; + } + else + { + DL_LOG_NN_LATENCY_START(); + prelu(input, input, activation_element, activation_exponent, assign_core); + DL_LOG_NN_LATENCY_END("prelu"); + } + } + } // namespace nn +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_relu.hpp b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_relu.hpp new file mode 100644 index 00000000000..e4159fdf898 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_relu.hpp @@ -0,0 +1,70 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn.hpp" + +namespace dl +{ + namespace nn + { + /** + * @brief relu(input). + * + * @param output as an output + * @param input as an input + * @param assign_core not effective yet + */ + void relu(Tensor &output, + Tensor &input, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief relu(input). + * + * @param output as an output + * @param input as an input + * @param assign_core not effective yet + */ + void relu(Tensor &output, + Tensor &input, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief relu(input) + * + * @tparam inplace: whether directly store the output to input + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + * @param input as an input + * @param assign_core not effective yet + * @return relu result or no return(result store to input) + */ + template + auto relu(Tensor &input, const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) -> typename std::conditional>::type + { + DL_LOG_NN_LATENCY_INIT(); + Tensor output; + + if constexpr(!inplace) + { + DL_LOG_NN_LATENCY_START(); + output.set_exponent(input.exponent).set_shape(input.shape).apply_element(); + DL_LOG_NN_LATENCY_END("apply"); + + DL_LOG_NN_LATENCY_START(); + relu(output, input, assign_core); + DL_LOG_NN_LATENCY_END("relu"); + + return output; + } + else + { + DL_LOG_NN_LATENCY_START(); + relu(input, input, assign_core); + DL_LOG_NN_LATENCY_END("relu"); + } + } + } // namespace nn +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_sub2d.hpp b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_sub2d.hpp new file mode 100644 index 00000000000..385188e4ba2 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/nn/dl_nn_sub2d.hpp @@ -0,0 +1,90 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn.hpp" + +namespace dl +{ + namespace nn + { + /** + * @brief activation(sub2d(input0, input1)). + * + * @param output as an output + * @param input0 as one input + * @param input1 as another input + * @param activation activation of sub2d, if you don't specify anything, no activation is applied + * @param assign_core not effective yet + * @param output_exponent exponent of output, only and must specify if inplace operation happens + */ + void sub2d(Tensor &output, + Tensor &input0, + Tensor &input1, + const Activation *const activation = NULL, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE, + const int output_exponent = INT_MIN); + + /** + * @brief activation(sub2d(input0, input1)). + * + * @param output as an output + * @param input0 as one input + * @param input1 as another input + * @param activation activation of sub2d, if you don't specify anything, no activation is applied + * @param assign_core not effective yet + * @param output_exponent exponent of output, only and must specify if inplace operation happens + */ + void sub2d(Tensor &output, + Tensor &input0, + Tensor &input1, + const Activation *const activation = NULL, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE, + const int output_exponent = INT_MIN); + + /** + * @brief activation(sub2d(input0, input1)). + * + * @tparam inplace: whether directly store the output to input0 + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + * @param output_exponent exponent of output + * @param input0 as one input + * @param input1 as another input + * @param activation activation of sub2d, if you don't specify anything, no activation is applied + * @param assign_core not effective yet + * @return sub2d result or no return(result store to input0) + */ + template + auto sub2d(const int output_exponent, + Tensor &input0, + Tensor &input1, + const Activation *activation, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) -> typename std::conditional>::type + { + assert(input0.is_same_shape(input1)); + + DL_LOG_NN_LATENCY_INIT(); + Tensor output; + if constexpr(!inplace) + { + DL_LOG_NN_LATENCY_START(); + output.set_exponent(output_exponent).set_shape(input0.shape).apply_element(); + DL_LOG_NN_LATENCY_END("apply"); + + DL_LOG_NN_LATENCY_START(); + sub2d(output, input0, input1, activation, assign_core); + DL_LOG_NN_LATENCY_END("sub2d"); + + return output; + } + else + { + DL_LOG_NN_LATENCY_START(); + sub2d(input0, input0, input1, activation, assign_core, output_exponent); + DL_LOG_NN_LATENCY_END("sub2d"); + } + } + } // namespace nn +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32/include/esp-face/include/tool/dl_tool.hpp b/tools/sdk/esp32/include/esp-face/include/tool/dl_tool.hpp new file mode 100644 index 00000000000..f8e0871a04f --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/tool/dl_tool.hpp @@ -0,0 +1,377 @@ +#pragma once + +#include +#include +#include +#include + +#include "esp_system.h" +#include "esp_timer.h" +#include "freertos/FreeRTOS.h" + +#include "dl_define.hpp" + +extern "C" +{ +#if CONFIG_TIE728_BOOST + void dl_tie728_memset_8b(void *ptr, const int value, const int n); + void dl_tie728_memset_16b(void *ptr, const int value, const int n); + void dl_tie728_memset_32b(void *ptr, const int value, const int n); +#endif +} + +namespace dl +{ + namespace tool + { + /** + * @brief Set memory zero. + * + * @param ptr pointer of memory + * @param n byte number + */ + void set_zero(void *ptr, const int n); + + /** + * @brief Set array value. + * + * @tparam T supports all data type, sizeof(T) equals to 1, 2 and 4 will boost by instruction + * @param ptr pointer of array + * @param value value to set + * @param len length of array + */ + template + void set_value(T *ptr, const T value, const int len) + { +#if CONFIG_TIE728_BOOST + int *temp = (int *)&value; + if (sizeof(T) == 1) + dl_tie728_memset_8b(ptr, *temp, len); + else if (sizeof(T) == 2) + dl_tie728_memset_16b(ptr, *temp, len); + else if (sizeof(T) == 4) + dl_tie728_memset_32b(ptr, *temp, len); + else +#endif + for (size_t i = 0; i < len; i++) + ptr[i] = value; + } + + /** + * @brief Copy memory. + * + * @param dst pointer of destination + * @param src pointer of source + * @param n byte number + */ + void copy_memory(void *dst, void *src, const int n); + + /** + * @brief Apply memory without initialized. Must use free_aligned() to free the memory. + * + * @param number number of elements + * @param size size of element + * @param align number of aligned, e.g., 16 means 16-byte aligned + * @return pointer of allocated memory. NULL for failed + */ + inline void *malloc_aligned(int number, int size, int align = 0) + { + int n = number * size; + n >>= 4; + n += 2; + n <<= 4; + int total_size = n + align + sizeof(void *) + sizeof(int); + void *res = malloc(total_size); +#if DL_SPIRAM_SUPPORT + if (NULL == res) + res = heap_caps_malloc(total_size, MALLOC_CAP_SPIRAM); +#endif + if (NULL == res) + { + printf("Fail to malloc %d bytes from DRAM(%d bytyes) and PSRAM(%d bytes), PSRAM is %s.\n", + total_size, + heap_caps_get_free_size(MALLOC_CAP_INTERNAL), + heap_caps_get_free_size(MALLOC_CAP_SPIRAM), + DL_SPIRAM_SUPPORT ? "on" : "off"); + return NULL; + } + void **data = (void **)res + 2; // 4-byte for pointer, 4-bytes for n + void **aligned; + if (align) + aligned = (void **)(((size_t)data + (align - 1)) & -align); + else + aligned = data; + + aligned[-1] = res; + int *temp = (int *)aligned; + temp[-2] = n; + + return (void *)aligned; + } + + /** + * @brief Apply memory with zero-initialized. Must use dl_lib_free() to free the memory. + * + * @param number number of elements + * @param size size of element + * @param align number of aligned, e.g., 16 means 16-byte aligned + * @return pointer of allocated memory. NULL for failed + */ + inline void *calloc_aligned(int number, int size, int align = 0) + { + + void *aligned = malloc_aligned(number, size, align); + int n = *((int *)aligned - 2); + set_zero(aligned, n); + + return (void *)aligned; + } + + /** + * @brief Free the calloc_aligned() and malloc_aligned() memory + * + * @param address pointer of memory to free + */ + inline void free_aligned(void *address) + { + if (NULL == address) + return; + + free(((void **)address)[-1]); + } + + /** + * @brief Truncate the input into int8_t range. + * + * @tparam T supports all integer types + * @param output as an output + * @param input as an input + */ + template + void truncate(int8_t &output, T input) + { + if (input >= DL_Q8_MAX) + output = DL_Q8_MAX; + else if (input <= DL_Q8_MIN) + output = DL_Q8_MIN; + else + output = input; + } + + /** + * @brief Truncate the input into int16_t range. + * + * @tparam T supports all integer types + * @param output as an output + * @param input as an input + */ + template + void truncate(int16_t &output, T input) + { + if (input >= DL_Q16_MAX) + output = DL_Q16_MAX; + else if (input <= DL_Q16_MIN) + output = DL_Q16_MIN; + else + output = input; + } + + /** + * @brief Calculate the exponent of quantizing 1/n into max_value range. + * + * @param n 1/n: value to be quantized + * @param max_value the max_range + */ + inline int calculate_exponent(int n, int max_value) + { + int exp = 0; + int tmp = 1 / n; + while (tmp < max_value) + { + exp += 1; + tmp = (1 << exp) / n; + } + exp -= 1; + + return exp; + } + + /** + * @brief Print vector in format "[x1, x2, ...]\n". + * + * @param array to print + */ + inline void print_vector(std::vector &array, const char *message = NULL) + { + if (message) + printf("%s: ", message); + + printf("["); + for (int i = 0; i < array.size(); i++) + { + printf(", %d" + (i ? 0 : 2), array[i]); + } + printf("]\n"); + } + + /** + * @brief Get the cycle object + * + * @return cycle count + */ + inline uint32_t get_cycle() + { + uint32_t ccount; + __asm__ __volatile__("rsr %0, ccount" + : "=a"(ccount) + : + : "memory"); + return ccount; + } + + class Latency + { + private: + const uint32_t size; /**/ + + public: + /** + * @brief Construct a new Latency object. + * + * @param size + */ + Latency(const uint32_t size = 1) : size(size), + period(0), + sum(0), + count(0), + next(0) + { + this->queue = (this->size > 1) ? (uint32_t *)calloc(this->size, sizeof(uint32_t)) : NULL; + } + + /** + * @brief Destroy the Latency object. + * + */ + ~Latency() + { + if (this->queue) + free(this->queue); + } + + /** + * @brief Record the start timestamp. + * + */ + void start() + { +#if DL_LOG_LATENCY_UNIT + this->timestamp = get_cycle(); +#else + this->timestamp = esp_timer_get_time(); +#endif + } + + /** + * @brief Record the period. + * + */ + void end() + { +#if DL_LOG_LATENCY_UNIT + this->period = get_cycle() - this->timestamp; +#else + this->period = esp_timer_get_time() - this->timestamp; +#endif + if (this->queue) + { + this->sum -= this->queue[this->next]; + this->queue[this->next] = this->period; + this->sum += this->queue[this->next]; + this->next++; + this->next = this->next % this->size; + if (this->count < this->size) + { + this->count++; + } + } + } + + /** + * @brief Return the period. + * + * @return this->timestamp_end - this->timestamp + */ + uint32_t get_period() + { + return this->period; + } + + /** + * @brief Get the average period. + * + * @return average latency + */ + uint32_t get_average_period() + { + return this->queue ? (this->sum / this->count) : this->period; + } + + /** + * @brief Clear the period + * + */ + void clear_period() + { + this->period = 0; + } + + /** + * @brief Print in format "latency: {this->period} {unit}\n". + */ + void print() + { +#if DL_LOG_LATENCY_UNIT + printf("latency: %15u cycle\n", this->get_average_period()); +#else + printf("latency: %15u us\n", this->get_average_period()); +#endif + } + + /** + * @brief Print in format "{message}: {this->period} {unit}\n". + * + * @param message message of print + */ + void print(const char *message) + { +#if DL_LOG_LATENCY_UNIT + printf("%s: %15u cycle\n", message, this->get_average_period()); +#else + printf("%s: %15u us\n", message, this->get_average_period()); +#endif + } + + /** + * @brief Print in format "{prefix}::{key}: {this->period} {unit}\n". + * + * @param prefix prefix of print + * @param key key of print + */ + void print(const char *prefix, const char *key) + { +#if DL_LOG_LATENCY_UNIT + printf("%s::%s: %u cycle\n", prefix, key, this->get_average_period()); +#else + printf("%s::%s: %u us\n", prefix, key, this->get_average_period()); +#endif + } + }; + } // namespace tool +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32/include/esp-face/include/tool/dl_tool_cache.hpp b/tools/sdk/esp32/include/esp-face/include/tool/dl_tool_cache.hpp new file mode 100644 index 00000000000..74c81717a58 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/tool/dl_tool_cache.hpp @@ -0,0 +1,74 @@ +#pragma once + +#include + +#if CONFIG_IDF_TARGET_ESP32S3 +#include "esp32s3/rom/cache.h" +#include "soc/extmem_reg.h" +#endif + +namespace dl +{ + namespace tool + { + namespace cache + { + /** + * @brief Initialize preload. + * + * @param preload One of 1 or 0, + * - 1: turn on the preload + * - 0: turn off the preload + * @return + * - 1: Initialize successfully + * - 0: Initialize successfully, autoload has been turned off + * - -1: Initialize failed, the chip does not support preload + */ + int8_t preload_init(uint8_t preload = 1); + + /** + * @brief Preload memory. + * + * @param addr the start address of data to be preloaded + * @param size the size of the data in byte to be preloaded + */ + void preload_func(uint32_t addr, uint32_t size); + + /** + * @brief Initialize autoload. + * + * @param autoload One of 1 or 0, + * - 1: turn on the autoload + * - 0: turn off the autoload + * @param trigger One of 0 or 1 or 2, + * - 0: miss, TODO:@yuanjiong + * - 1: hit, TODO:@yuanjiong + * - 2: both,TODO:@yuanjiong + * @param line_size the number of cache lines to be autoloaded + * @return status, + * - 1: Initialize sucessfully + * - 0: Initialize suceesfully, preload has been turned off + * - -1: Initialize failed, the chip does not support autoload + */ + int8_t autoload_init(uint8_t autoload = 1, uint8_t trigger = 2, uint8_t line_size = 0); + + /** + * @brief Autoload memory. + * + * @param addr1 the start address of data1 to be autoloaded + * @param size1 the size of the data1 in byte to be preloaded + * @param addr2 the start address of data2 to be autoloaded + * @param size2 the size of the data2 in byte to be preloaded + */ + void autoload_func(uint32_t addr1, uint32_t size1, uint32_t addr2, uint32_t size2); + + /** + * @brief Autoload memory. + * + * @param addr1 the start address of data1 to be autoloaded + * @param size1 the size of the data1 in byte to be preloaded + */ + void autoload_func(uint32_t addr1, uint32_t size1); + } + } // namespace tool +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32/include/esp-face/include/typedef/dl_constant.hpp b/tools/sdk/esp32/include/esp-face/include/typedef/dl_constant.hpp new file mode 100644 index 00000000000..73e3b0832e7 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/typedef/dl_constant.hpp @@ -0,0 +1,125 @@ +#pragma once + +#include "dl_define.hpp" +#include + +namespace dl +{ + /** + * @brief Base class of Filter, Bias, Activation. + * + * @tparam T supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize, + * - int8_t: stands for operation in int8_t quantize. + */ + template + class Constant + { + public: + const T *element; /**/ + const int exponent; /**/ + const std::vector shape; /**/ + + /** + * @brief Construct a new Constant object. + * + * @param element point to element. + * @param exponent exponent of element. + * @param shape shape of Constant. + */ + Constant(const T *element, const int exponent, const std::vector shape); + }; + + /** + * @brief Filter. + * NOTE: The shape format of filter is fixed, but the element sequence depands on optimization method. + * - 1D: reserved + * - 2D: shape format is [filter_height, filter_width, input_channel, output_channel]. dilation format is [height, width] + * + * @tparam T supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize, + * - int8_t: stands for operation in int8_t quantize. + */ + template + class Filter : public Constant + { + public: + const std::vector dilation; /**/ + /**/ + std::vector shape_with_dilation; /**/ + /**/ + std::vector channel_exponent; /**/ + + /** + * @brief Construct a new Filter object. + * + * @param element point to element + * @param exponent exponent of element + * @param shape shape of Filter, + * - 1D: reserved + * - 2D: [filter_height, filter_width, input_channel, output_channel] + * @param dilation dilation of Filter + * - 1D: reserved + * - 2D: [dilation_in_height, dilation_in_width] + */ + Filter(const T *element, const int exponent, const std::vector shape, const std::vector dilation = {1, 1}); + + /** + * @brief Construct a new Filter object. + * + * @param element point to element + * @param channel_exponent exponent for per-channel + * @param shape shape of element + * @param dilation dilation of Filter + * - 1D: reserved + * - 2D: [dilation_in_height, dilation_in_width] + */ + Filter(const T *element, const std::vector channel_exponent, const std::vector shape, const std::vector dilation = {1, 1}); + + /** + * @brief Print the n-th filter. + * + * @param n index of output_channel + * @param message to print + */ + void print2d_n(const int n, const char *message) const; + }; + + /** + * @brief Bias. + * + * @tparam T supports int16_t and int8_t + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class Bias : public Constant + { + public: + using Constant::Constant; + }; + + /** + * @brief Activation. + * + * @tparam T supports int16_t and int8_t + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class Activation : public Constant + { + public: + const activation_type_t type; /* shape = {0}); + }; +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32/include/esp-face/include/typedef/dl_variable.hpp b/tools/sdk/esp32/include/esp-face/include/typedef/dl_variable.hpp new file mode 100644 index 00000000000..bf6e8630856 --- /dev/null +++ b/tools/sdk/esp32/include/esp-face/include/typedef/dl_variable.hpp @@ -0,0 +1,734 @@ +#pragma once + +#include +#include +#include + +#include "dl_tool.hpp" + +namespace dl +{ + /** + * @brief Tensor + * + * @tparam T support uint8_t, int8_t, int16_t and float. + */ + template + class Tensor + { + private: + int size; /* shape; /* shape_with_padding; /* padding; /*element + */ + Tensor(Tensor &input, bool deep) : size(input.size), + auto_free(input.auto_free), + exponent(input.exponent), + shape(input.shape), + shape_with_padding(input.shape_with_padding), + padding(input.padding) + { + if (deep) + { + int size_real = input.shape_with_padding.size() ? input.shape_with_padding[0] * input.shape_with_padding[1] * input.shape_with_padding[2] : 0; + T *new_element = (T *)tool::calloc_aligned(size_real, sizeof(T), 16); + tool::copy_memory(new_element, input.element, size_real * sizeof(T)); + this->element = new_element; + } + else + { + this->element = input.element; + } + } + + /** + * @brief Destroy the Tensor object + * + */ + ~Tensor() + { + if (this->auto_free) + this->free_element(); + } + + /** + * @brief Set the auto free object. + * + * @param auto_free one of true or false + * - true: free element when object destroyed + * - false: do not + * @return self + */ + Tensor &set_auto_free(const bool auto_free) + { + this->auto_free = auto_free; + return *this; + } + + /** + * @brief Set the element. + * + * @param element point to element memory + * @return self + */ + Tensor &set_element(T *element, const bool auto_free = false) + { + assert(this->element == NULL); + this->element = element; + this->auto_free = auto_free; + + return *this; + } + + /** + * @brief Set the exponent. + * + * @param exponent exponent of element + * @return self + */ + Tensor &set_exponent(const int exponent) + { + this->exponent = exponent; + + return *this; + } + + /** + * @brief Set the shape of Tensor. Initial this->padding = {0}. Initial this->size = -1. + * + * @param shape shape in + * - 2D: [height, width] + * @return self + */ + Tensor &set_shape(const std::vector shape) + { + for (int i = 0; i < shape.size(); ++i) + { + assert(shape[i] > 0); + } + this->shape = shape; + this->shape_with_padding = shape; + this->size = -1; + this->padding = std::vector(((this->shape.size() - 1) << 1), 0); + return *this; + } + + /** + * @brief Set the padding size object. + * + * @param padding padding size in + * - 2D: [top, bottom, left, right] + * @return self + */ + Tensor &set_padding_size(std::vector &padding) + { + assert(this->shape.size()); // call Tensor.set_shape() first + assert(this->shape.size() == 3); // TODO: || this->shape.size() == 2 + + if (this->shape.size() == 3) + { + std::vector new_padding = this->padding; + bool dont_update = true; + + if (padding[0] > this->padding[0]) + { + new_padding[0] = padding[0]; + dont_update = false; + } + + if (padding[1] > this->padding[1]) + { + new_padding[1] = padding[1]; + dont_update = false; + } + + if (padding[2] > this->padding[2]) + { + new_padding[2] = padding[2]; + dont_update = false; + } + + if (padding[3] > this->padding[3]) + { + new_padding[3] = padding[3]; + dont_update = false; + } + + if (dont_update) + { + return *this; + } + + std::vector new_shape_with_padding = this->shape; + + new_shape_with_padding[0] += (new_padding[0] + new_padding[1]); + new_shape_with_padding[1] += (new_padding[2] + new_padding[3]); + int new_size = new_shape_with_padding[0] * new_shape_with_padding[1] * new_shape_with_padding[2]; + + if (this->element) // if this->element != NULL, do padding by copy memory + { + T *new_element = (T *)tool::malloc_aligned(new_size, sizeof(T), 16); + T *dst = new_element + ((new_padding[0] * new_shape_with_padding[1]) + new_padding[2]) * new_shape_with_padding[2]; + T *src = this->get_element_ptr(); + int offset_dst_next_y = new_shape_with_padding[1] * new_shape_with_padding[2]; // width * channel + int src_copy_length = this->shape[1] * this->shape[2]; // width * channel + int offset_src_next_y = this->shape_with_padding[1] * this->shape_with_padding[2]; // width * channel + for (int y = 0; y < this->shape[0]; y++) + { + tool::copy_memory(dst, src, src_copy_length * sizeof(T)); + dst += offset_dst_next_y; + src += offset_src_next_y; + } + + if (this->auto_free) + tool::free_aligned(this->element); + this->element = new_element; + this->auto_free = true; + } + this->padding = new_padding; + this->shape_with_padding = new_shape_with_padding; + this->size = new_size; + } + else if (this->shape.size() == 2) + { + printf("Tensor.set_padding_size with this->shape.size() == 2 not implement yet.\n"); + } + + return *this; + } + + /** + * @brief Set the padding value object. + * + * @param padding padding size in + * - 2D: [top, bottom, left, right] + * @param value value to set + * @return self + */ + Tensor &set_padding_value(std::vector &padding, T value); + + /** + * @brief Get the element pointer. + * + * @param padding padding size in + * - 2D: [top, bottom, left, right] + * @return pointer to memory with padding + */ + T *get_element_ptr(const std::vector padding = {0, 0, 0, 0}) + { + assert(this->shape.size() == 3); // TODO: || this->shape.size() == 2 + + if (this->shape.size() == 3) + { + return this->element + ((this->padding[0] - padding[0]) * this->shape_with_padding[1] + (this->padding[2] - padding[2])) * this->shape_with_padding[2]; + } + else if (this->shape.size() == 2) + { + printf("Tensor.get_element_ptr with this->shape.size() == 2 is not implemented.\n"); + } + + return NULL; + } + + /** + * @brief Get the element value. + * + * @param index index in + * - 2D: [y, x, c] + * @param with_padding one of true or false, + * - true: make padding size in count + * - false: do not + * @return element value + */ + T &get_element_value(const std::vector index, const bool with_padding = false) + { + assert(index.size() == this->shape.size()); + assert(this->shape.size() == 3); // TODO: || this->shape() == 2 + + int i = 0; + if (this->shape.size() == 3) + { + int y = index[0]; + int x = index[1]; + int c = index[2]; + i = with_padding ? (y * this->shape_with_padding[1] + x) * this->shape_with_padding[2] + c : ((y + this->padding[0]) * this->shape_with_padding[1] + x + this->padding[2]) * this->shape_with_padding[2] + c; + } + else if (this->shape.size() == 2) + { + printf("Tensor.get_element_value with this->shape.size() == 2 is not implemented.\n"); + } + + return this->element[i]; + } + + /** + * @brief Get the size of element. + * + * @return size of element including padding + */ + int get_size() + { + if (this->size == -1) // didn't call Tensor.set_padding_size() before + { + this->size = 1; + for (std::vector::iterator d = this->shape.begin(); d != this->shape.end(); d++) + this->size *= *d; + } + + return this->size; + } + + /** + * @brief Apply memory with zero-initialized only if this->element is NULL. + * + * @param auto_free one of true or false + * - true: free element when object destroyed + * - false: do not + * @return + * - true: on success + * - false: if applying failed + */ + bool calloc_element(const bool auto_free = true) + { + if (this->element != NULL) + return false; + + this->element = (T *)dl::tool::calloc_aligned(this->get_size(), sizeof(T), 16); + this->auto_free = auto_free; + + return true; + } + + /** + * @brief Apply memory without initialized only if this->element is NULL. + * + * @param auto_free one of true or false + * - true: free element when object destroyed + * - false: do not + * @return + * - true: on success + * - false: if applying failed + */ + bool malloc_element(const bool auto_free = true) + { + if (this->element != NULL) + return false; + + this->element = (T *)tool::malloc_aligned(this->get_size(), sizeof(T), 16); + this->auto_free = auto_free; + + return true; + } + + /** + * @brief If this->element != NULL no memory will be applied and no value will be set in padding. + * Else apply memory without initialized and set value to padding. + * + * @param padding_value value to set in padding + * @param auto_free one of true of false + * - true: free element when object destroyed + * - false: do not + * @return + * - true: apply memory and set padding value successfully + * - false: no memory applied and no padding value set + */ + bool apply_element(const T padding_value = 0, const bool auto_free = true) + { + if (this->element != NULL) + return false; + + this->element = (T *)tool::malloc_aligned(this->get_size(), sizeof(T), 16); + this->set_padding_value(this->padding, padding_value); + this->auto_free = auto_free; + + return true; + } + + /** + * @brief free element only if this->element != NULL + * set this->element to NULL, after free + * @brief Free element if this->element is not NULL. + */ + void free_element() + { + if (this->auto_free && this->element) + { + tool::free_aligned(this->element); + this->element = NULL; + } + } + + /** + * @brief Print the shape of Tensor in format "shape = ({top_padding} + {height} + {bottom_padding}, {left_padding} + {width} + {right_padding}, {channel}(channel_with_padding))\n". + */ + void print_shape() + { + printf("shape = (%d + %d + %d, %d + %d + %d, %d(%d))\n", + this->padding[0], this->shape[0], this->padding[1], + this->padding[2], this->shape[1], this->padding[3], + this->shape[2], this->shape_with_padding[2]); + } + + /** + * @brief Take numpy for example, this function print Tensor[y_start:y_end, x_start:x_end, c_start:c_end]. + * + * inner box is effective value of Tensor, "0" around is padding. + * + * (with padding) + * 00000000000000000000000000000000000000000000000000 + * 00000000000000000000000000000000000000000000000000 + * 00000000000000000000000000000000000000000000000000 + * 000000(without padding) 00000000 + * 000000 00000000 + * 000000 00000000 + * 000000 effective value 00000000 + * 000000 00000000 + * 000000 00000000 + * 00000000000000000000000000000000000000000000000000 + * 00000000000000000000000000000000000000000000000000 + * 00000000000000000000000000000000000000000000000000 + * + * @param y_start start index in height + * @param y_end end index in height + * @param x_start start index in width + * @param x_end end index in width + * @param c_start start index in channel + * @param c_end end index in channel + * @param message to print + * @param axis print aligned this axis, effective only if all y_end - y_start, x_end - x_start and c_end - c_start equals to 1 + * @param with_padding one of true or false, + * - true: count from (with padding) in upper image + * - false: count from (without padding) in upper image + */ + void print(int y_start, int y_end, + int x_start, int x_end, + int c_start, int c_end, + const char *message, int axis = 0, const bool with_padding = false) + { + assert(y_end > y_start); + assert(x_end > x_start); + assert(c_end > c_start); + + y_start = DL_MAX(y_start, 0); + x_start = DL_MAX(x_start, 0); + c_start = DL_MAX(c_start, 0); + if (with_padding) + { + y_end = DL_MIN(y_end, this->shape_with_padding[0]); + x_end = DL_MIN(x_end, this->shape_with_padding[1]); + c_end = DL_MIN(c_end, this->shape_with_padding[2]); + } + else + { + y_end = DL_MIN(y_end, this->shape[0]); + x_end = DL_MIN(x_end, this->shape[1]); + c_end = DL_MIN(c_end, this->shape[2]); + } + + printf("%s[%d:%d, %d:%d, %d:%d] | ", message, y_start, y_end, x_start, x_end, c_start, c_end); + this->print_shape(); + + if (y_end - y_start == 1) + { + if (x_end - x_start == 1) + { + for (int c = c_start; c < c_end; c++) + printf("%7d", c); + printf("\n"); + + for (int c = c_start; c < c_end; c++) + printf("%7d", this->get_element_value({y_start, x_start, c}, with_padding)); + printf("\n"); + + return; + } + else + { + if (c_end - c_start == 1) + { + for (int x = x_start; x < x_end; x++) + printf("%7d", x); + printf("\n"); + + for (int x = x_start; x < x_end; x++) + printf("%7d", this->get_element_value({y_start, x, c_start}, with_padding)); + printf("\n"); + + return; + } + } + } + else + { + if (x_end - x_start == 1) + { + if (c_end - c_start == 1) + { + for (int y = y_start; y < y_end; y++) + printf("%7d", y); + printf("\n"); + + for (int y = y_start; y < y_end; y++) + printf("%7d", this->get_element_value({y, x_start, c_start}, with_padding)); + printf("\n"); + + return; + } + } + } + + if (y_end - y_start == 1) + axis = 0; + + if (x_end - x_start == 1) + axis = 1; + + if (c_end - c_start == 1) + axis = 2; + + if (axis == 0) + { + // ______c + // | + // | + // x + // + for (int y = y_start; y < y_end; y++) + { + printf("y = %d\n ", y); + + for (int c = c_start; c < c_end; c++) + printf("%7d", c); + printf("\n"); + + for (int x = x_start; x < x_end; x++) + { + printf("%5d", x); + for (int c = c_start; c < c_end; c++) + printf("%7d", this->get_element_value({y, x, c}, with_padding)); + printf("\n"); + } + printf("\n"); + } + } + else if (axis == 1) + { + // ______c + // | + // | + // y + // + for (int x = x_start; x < x_end; x++) + { + printf("x = %d\n ", x); + + for (int c = c_start; c < c_end; c++) + printf("%7d", c); + printf("\n"); + + for (int y = y_start; y < y_end; y++) + { + printf("%5d", y); + for (int c = c_start; c < c_end; c++) + printf("%7d", this->get_element_value({y, x, c}, with_padding)); + printf("\n"); + } + printf("\n"); + } + } + else + { + // ______x + // | + // | + // y + // + for (int c = c_start; c < c_end; c++) + { + printf("c = %d\n ", c); + + for (int x = x_start; x < x_end; x++) + printf("%7d", x); + printf("\n"); + + for (int y = y_start; y < y_end; y++) + { + printf("%5d", y); + for (int x = x_start; x < x_end; x++) + printf("%7d", this->get_element_value({y, x, c}, with_padding)); + printf("\n"); + } + printf("\n"); + } + } + + return; + } + + /** + * @brief print all the element of the Tensor. + * + * @param message to print + * @param with_padding one of true or false, + * - true: the padding element will also be printed + * - false: the padding element will not be printed + */ + void print_all(const char *message, const bool with_padding = false) + { + int y_end; + int x_end; + int c_end; + if (with_padding) + { + y_end = this->shape_with_padding[0]; + x_end = this->shape_with_padding[1]; + c_end = this->shape_with_padding[2]; + } + else + { + y_end = this->shape[0]; + x_end = this->shape[1]; + c_end = this->shape[2]; + } + + printf("\n%s | ", message); + this->print_shape(); + + for (int y = 0; y < y_end; y++) + { + for (int x = 0; x < x_end; x++) + { + for (int c = 0; c < c_end; c++) + printf("%d ", this->get_element_value({y, x, c}, with_padding)); + } + } + printf("\n"); + return; + } + + /** + * @brief Check the element value with input ground-truth. + * + * @param gt_element ground-truth value of element + * @param bias permissible error + * @param info one of true or false + * - true: print shape and result + * - false: do not + * @return + * - true: in permissible error + * - false: not + */ + bool check_element(T *gt_element, int bias = 2, bool info = true) + { + if (info) + this->print_shape(); + int i = 0; + for (int y = 0; y < this->shape[0]; y++) + { + for (int x = 0; x < this->shape[1]; x++) + { + for (int c = 0; c < this->shape[2]; c++) + { + int a = this->get_element_value({y, x, c}); + int b = gt_element[i]; + int offset = DL_ABS(a - b); + if (offset > bias) + { + printf("element[%d, %d, %d]: %d v.s. %d\n", y, x, c, a, b); + return false; + } + i++; + } + } + } + + if (info) + printf("PASS\n"); + + return true; + } + + /** + * @brief Check the shape is the same as the shape of input. + * + * @param input an input tensor + * @return + * - true: same shape + * - false: not + */ + bool is_same_shape(Tensor &input) + { + if (input.shape.size() != this->shape.size()) + { + return false; + } + for (int i = 0; i < this->shape.size(); i++) + { + if (input.shape[i] != this->shape[i]) + { + return false; + } + } + return true; + } + + Tensor &operator=(const Tensor &input) + { + this->size = input.size; + this->auto_free = input.auto_free; + this->exponent = input.exponent; + this->shape = input.shape; + this->padding = input.padding; + int size_real_tmp = this->shape_with_padding.size() ? this->shape_with_padding[0] * this->shape_with_padding[1] * this->shape_with_padding[2] : 0; + int size_input_real = input.shape_with_padding.size() ? input.shape_with_padding[0] * input.shape_with_padding[1] * input.shape_with_padding[2] : 0; + this->shape_with_padding = input.shape_with_padding; + if (this->element) + { + if (size_real_tmp != size_input_real) + { + tool::free_aligned(this->element); + T *new_element = (T *)tool::calloc_aligned(size_input_real, sizeof(T), 16); + tool::copy_memory(new_element, input.element, size_input_real * sizeof(T)); + this->element = new_element; + } + else + { + tool::copy_memory(this->element, input.element, size_input_real * sizeof(T)); + } + } + else + { + T *new_element = (T *)tool::calloc_aligned(size_input_real, sizeof(T), 16); + tool::copy_memory(new_element, input.element, size_input_real * sizeof(T)); + this->element = new_element; + } + return *this; + } + }; +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32/include/esp-face/lib/include/cat_face_3.h b/tools/sdk/esp32/include/esp-face/lib/include/cat_face_3.h deleted file mode 100644 index 42d6fa85821..00000000000 --- a/tools/sdk/esp32/include/esp-face/lib/include/cat_face_3.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * ESPRESSIF MIT License - * - * Copyright (c) 2018 - * - * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, - * it is free of charge, to any person_body 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. - * - */ - -#pragma once - -#ifdef __cplusplus -extern "C" -{ -#endif -#include "dl_lib_matrix3d.h" -#include "dl_lib_matrix3dq.h" -#include "freertos/FreeRTOS.h" -#include "detection.h" - - extern detection_model_t cat_face_3_model; - -#ifdef __cplusplus -} -#endif diff --git a/tools/sdk/esp32/include/esp-face/lib/include/detection.h b/tools/sdk/esp32/include/esp-face/lib/include/detection.h deleted file mode 100644 index 0bba4f49b6f..00000000000 --- a/tools/sdk/esp32/include/esp-face/lib/include/detection.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * ESPRESSIF MIT License - * - * Copyright (c) 2018 - * - * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, - * it is 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. - * - */ -#pragma once - -#ifdef __cplusplus -extern "C" -{ -#endif -#include "dl_lib_matrix3d.h" -#include "dl_lib_matrix3dq.h" -#include "freertos/FreeRTOS.h" - - typedef enum - { - Anchor_Point, /* -#include -#include -#include -#include -#include - -#if CONFIG_SPIRAM_SUPPORT || CONFIG_ESP32_SPIRAM_SUPPORT -#include "freertos/FreeRTOS.h" -#define DL_SPIRAM_SUPPORT 1 -#else -#define DL_SPIRAM_SUPPORT 0 -#endif - - -#ifndef max -#define max(x, y) (((x) < (y)) ? (y) : (x)) -#endif - -#ifndef min -#define min(x, y) (((x) < (y)) ? (x) : (y)) -#endif - -typedef float fptp_t; -typedef uint8_t uc_t; - -typedef enum -{ - DL_SUCCESS = 0, - DL_FAIL = 1, -} dl_error_type; - -typedef enum -{ - PADDING_VALID = 0, /*!< Valid padding */ - PADDING_SAME = 1, /*!< Same padding, from right to left, free input */ - PADDING_SAME_DONT_FREE_INPUT = 2, /*!< Same padding, from right to left, do not free input */ - PADDING_SAME_MXNET = 3, /*!< Same padding, from left to right */ -} dl_padding_type; - -typedef enum -{ - DL_POOLING_MAX = 0, /*!< Max pooling */ - DL_POOLING_AVG = 1, /*!< Average pooling */ -} dl_pooling_type; -/* - * Matrix for 3d - * @Warning: the sequence of variables is fixed, cannot be modified, otherwise there will be errors in esp_dsp_dot_float - */ -typedef struct -{ - int w; /*!< Width */ - int h; /*!< Height */ - int c; /*!< Channel */ - int n; /*!< Number of filter, input and output must be 1 */ - int stride; /*!< Step between lines */ - fptp_t *item; /*!< Data */ -} dl_matrix3d_t; - -typedef struct -{ - int w; /*!< Width */ - int h; /*!< Height */ - int c; /*!< Channel */ - int n; /*!< Number of filter, input and output must be 1 */ - int stride; /*!< Step between lines */ - uc_t *item; /*!< Data */ -} dl_matrix3du_t; - -typedef enum -{ - UPSAMPLE_NEAREST_NEIGHBOR = 0, /*!< Use nearest neighbor interpolation as the upsample method*/ - UPSAMPLE_BILINEAR = 1, /*!< Use nearest bilinear interpolation as the upsample method*/ -} dl_upsample_type; - -typedef struct -{ - int stride_x; /*!< Strides of width */ - int stride_y; /*!< Strides of height */ - dl_padding_type padding; /*!< Padding type */ -} dl_matrix3d_mobilenet_config_t; - -/* - * @brief Allocate a zero-initialized space. Must use 'dl_lib_free' to free the memory. - * - * @param cnt Count of units. - * @param size Size of unit. - * @param align Align of memory. If not required, set 0. - * @return Pointer of allocated memory. Null for failed. - */ -static void *dl_lib_calloc(int cnt, int size, int align) -{ - int total_size = cnt * size + align + sizeof(void *); - void *res = malloc(total_size); - if (NULL == res) - { -#if DL_SPIRAM_SUPPORT - res = heap_caps_malloc(total_size, MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM); - } - if (NULL == res) - { - printf("Item psram alloc failed. Size: %d x %d\n", cnt, size); -#else - printf("Item alloc failed. Size: %d x %d, SPIRAM_FLAG: %d\n", cnt, size, DL_SPIRAM_SUPPORT); -#endif - return NULL; - } - bzero(res, total_size); - void **data = (void **)res + 1; - void **aligned; - if (align) - aligned = (void **)(((size_t)data + (align - 1)) & -align); - else - aligned = data; - - aligned[-1] = res; - return (void *)aligned; -} - -/** - * @brief Free the memory space allocated by 'dl_lib_calloc' - * - */ -static inline void dl_lib_free(void *d) -{ - if (NULL == d) - return; - - free(((void **)d)[-1]); -} - -/* - * @brief Allocate a 3D matrix with float items, the access sequence is NHWC - * - * @param n Number of matrix3d, for filters it is out channels, for others it is 1 - * @param w Width of matrix3d - * @param h Height of matrix3d - * @param c Channel of matrix3d - * @return 3d matrix - */ -static inline dl_matrix3d_t *dl_matrix3d_alloc(int n, int w, int h, int c) -{ - dl_matrix3d_t *r = (dl_matrix3d_t *)dl_lib_calloc(1, sizeof(dl_matrix3d_t), 0); - if (NULL == r) - { - printf("internal r failed.\n"); - return NULL; - } - fptp_t *items = (fptp_t *)dl_lib_calloc(n * w * h * c, sizeof(fptp_t), 0); - if (NULL == items) - { - printf("matrix3d item alloc failed.\n"); - dl_lib_free(r); - return NULL; - } - - r->w = w; - r->h = h; - r->c = c; - r->n = n; - r->stride = w * c; - r->item = items; - - return r; -} - -/* - * @brief Allocate a 3D matrix with 8-bits items, the access sequence is NHWC - * - * @param n Number of matrix3d, for filters it is out channels, for others it is 1 - * @param w Width of matrix3d - * @param h Height of matrix3d - * @param c Channel of matrix3d - * @return 3d matrix - */ -static inline dl_matrix3du_t *dl_matrix3du_alloc(int n, int w, int h, int c) -{ - dl_matrix3du_t *r = (dl_matrix3du_t *)dl_lib_calloc(1, sizeof(dl_matrix3du_t), 0); - if (NULL == r) - { - printf("internal r failed.\n"); - return NULL; - } - uc_t *items = (uc_t *)dl_lib_calloc(n * w * h * c, sizeof(uc_t), 0); - if (NULL == items) - { - printf("matrix3du item alloc failed.\n"); - dl_lib_free(r); - return NULL; - } - - r->w = w; - r->h = h; - r->c = c; - r->n = n; - r->stride = w * c; - r->item = items; - - return r; -} - -/* - * @brief Free a matrix3d - * - * @param m matrix3d with float items - */ -static inline void dl_matrix3d_free(dl_matrix3d_t *m) -{ - if (NULL == m) - return; - if (NULL == m->item) - { - dl_lib_free(m); - return; - } - dl_lib_free(m->item); - dl_lib_free(m); -} - -/* - * @brief Free a matrix3d - * - * @param m matrix3d with 8-bits items - */ -static inline void dl_matrix3du_free(dl_matrix3du_t *m) -{ - if (NULL == m) - return; - if (NULL == m->item) - { - dl_lib_free(m); - return; - } - dl_lib_free(m->item); - dl_lib_free(m); -} - - -/* - * @brief Dot product with a vector and matrix - * - * @param out Space to put the result - * @param in input vector - * @param f filter matrix - */ -void dl_matrix3dff_dot_product(dl_matrix3d_t *out, dl_matrix3d_t *in, dl_matrix3d_t *f); - -/** - * @brief Do a softmax operation on a matrix3d - * - * @param in Input matrix3d - */ -void dl_matrix3d_softmax(dl_matrix3d_t *m); - -/** - * @brief Copy a range of float items from an existing matrix to a preallocated matrix - * - * @param dst The destination slice matrix - * @param src The source matrix to slice - * @param x X-offset of the origin of the returned matrix within the sliced matrix - * @param y Y-offset of the origin of the returned matrix within the sliced matrix - * @param w Width of the resulting matrix - * @param h Height of the resulting matrix - */ -void dl_matrix3d_slice_copy(dl_matrix3d_t *dst, - dl_matrix3d_t *src, - int x, - int y, - int w, - int h); - -/** - * @brief Copy a range of 8-bits items from an existing matrix to a preallocated matrix - * - * @param dst The destination slice matrix - * @param src The source matrix to slice - * @param x X-offset of the origin of the returned matrix within the sliced matrix - * @param y Y-offset of the origin of the returned matrix within the sliced matrix - * @param w Width of the resulting matrix - * @param h Height of the resulting matrix - */ -void dl_matrix3du_slice_copy(dl_matrix3du_t *dst, - dl_matrix3du_t *src, - int x, - int y, - int w, - int h); - -/** - * @brief Transform a sliced matrix block from nhwc to nchw, the block needs to be memory continous. - * - * @param out The destination sliced matrix in nchw - * @param in The source sliced matrix in nhwc - */ -void dl_matrix3d_sliced_transform_nchw(dl_matrix3d_t *out, - dl_matrix3d_t *in); - -/** - * @brief Do a general CNN layer pass, dimension is (number, width, height, channel) - * - * @param in Input matrix3d - * @param filter Weights of the neurons - * @param bias Bias for the CNN layer - * @param stride_x The step length of the convolution window in x(width) direction - * @param stride_y The step length of the convolution window in y(height) direction - * @param padding One of VALID or SAME - * @param mode Do convolution using C implement or xtensa implement, 0 or 1, with respect - * If ESP_PLATFORM is not defined, this value is not used. Default is 0 - * @return dl_matrix3d_t* The result of CNN layer - */ -dl_matrix3d_t *dl_matrix3d_conv(dl_matrix3d_t *in, - dl_matrix3d_t *filter, - dl_matrix3d_t *bias, - int stride_x, - int stride_y, - int padding, - int mode); - -/** - * @brief Do a global average pooling layer pass, dimension is (number, width, height, channel) - * - * @param in Input matrix3d - * - * @return The result of global average pooling layer - */ -dl_matrix3d_t *dl_matrix3d_global_pool(dl_matrix3d_t *in); - -/** - * @brief Calculate pooling layer of a feature map - * - * @param in Input matrix, size (1, w, h, c) - * @param f_w Window width - * @param f_h Window height - * @param stride_x Stride in horizontal direction - * @param stride_y Stride in vertical direction - * @param padding Padding type: PADDING_VALID and PADDING_SAME - * @param pooling_type Pooling type: DL_POOLING_MAX and POOLING_AVG - * @return dl_matrix3d_t* Resulting matrix, size (1, w', h', c) - */ -dl_matrix3d_t *dl_matrix3d_pooling(dl_matrix3d_t *in, - int f_w, - int f_h, - int stride_x, - int stride_y, - dl_padding_type padding, - dl_pooling_type pooling_type); -/** - * @brief Do a batch normalization operation, update the input matrix3d: input = input * scale + offset - * - * @param m Input matrix3d - * @param scale scale matrix3d, scale = gamma/((moving_variance+sigma)^(1/2)) - * @param Offset Offset matrix3d, offset = beta-(moving_mean*gamma/((moving_variance+sigma)^(1/2))) - */ -void dl_matrix3d_batch_normalize(dl_matrix3d_t *m, - dl_matrix3d_t *scale, - dl_matrix3d_t *offset); - -/** - * @brief Add a pair of matrix3d item-by-item: res=in_1+in_2 - * - * @param in_1 First Floating point input matrix3d - * @param in_2 Second Floating point input matrix3d - * - * @return dl_matrix3d_t* Added data - */ -dl_matrix3d_t *dl_matrix3d_add(dl_matrix3d_t *in_1, dl_matrix3d_t *in_2); - -/** - * @brief Concatenate the channels of two matrix3ds into a new matrix3d - * - * @param in_1 First Floating point input matrix3d - * @param in_2 Second Floating point input matrix3d - * - * @return dl_matrix3d_t* A newly allocated matrix3d with as avlues in_1|in_2 - */ -dl_matrix3d_t *dl_matrix3d_concat(dl_matrix3d_t *in_1, dl_matrix3d_t *in_2); - -/** - * @brief Concatenate the channels of four matrix3ds into a new matrix3d - * - * @param in_1 First Floating point input matrix3d - * @param in_2 Second Floating point input matrix3d - * @param in_3 Third Floating point input matrix3d - * @param in_4 Fourth Floating point input matrix3d - * - * @return A newly allocated matrix3d with as avlues in_1|in_2|in_3|in_4 - */ -dl_matrix3d_t *dl_matrix3d_concat_4(dl_matrix3d_t *in_1, - dl_matrix3d_t *in_2, - dl_matrix3d_t *in_3, - dl_matrix3d_t *in_4); - -/** - * @brief Concatenate the channels of eight matrix3ds into a new matrix3d - * - * @param in_1 First Floating point input matrix3d - * @param in_2 Second Floating point input matrix3d - * @param in_3 Third Floating point input matrix3d - * @param in_4 Fourth Floating point input matrix3d - * @param in_5 Fifth Floating point input matrix3d - * @param in_6 Sixth Floating point input matrix3d - * @param in_7 Seventh Floating point input matrix3d - * @param in_8 eighth Floating point input matrix3d - * - * @return A newly allocated matrix3d with as avlues in_1|in_2|in_3|in_4|in_5|in_6|in_7|in_8 - */ -dl_matrix3d_t *dl_matrix3d_concat_8(dl_matrix3d_t *in_1, - dl_matrix3d_t *in_2, - dl_matrix3d_t *in_3, - dl_matrix3d_t *in_4, - dl_matrix3d_t *in_5, - dl_matrix3d_t *in_6, - dl_matrix3d_t *in_7, - dl_matrix3d_t *in_8); - -/** - * @brief Do a mobilefacenet block forward, dimension is (number, width, height, channel) - * - * @param in Input matrix3d - * @param pw Weights of the pointwise conv layer - * @param pw_bn_scale The scale params of the batch_normalize layer after the pointwise conv layer - * @param pw_bn_offset The offset params of the batch_normalize layer after the pointwise conv layer - * @param dw Weights of the depthwise conv layer - * @param dw_bn_scale The scale params of the batch_normalize layer after the depthwise conv layer - * @param dw_bn_offset The offset params of the batch_normalize layer after the depthwise conv layer - * @param pw_linear Weights of the pointwise linear conv layer - * @param pw_linear_bn_scale The scale params of the batch_normalize layer after the pointwise linear conv layer - * @param pw_linear_bn_offset The offset params of the batch_normalize layer after the pointwise linear conv layer - * @param stride_x The step length of the convolution window in x(width) direction - * @param stride_y The step length of the convolution window in y(height) direction - * @param padding One of VALID or SAME - * @param mode Do convolution using C implement or xtensa implement, 0 or 1, with respect - * If ESP_PLATFORM is not defined, this value is not used. Default is 0 - * @return The result of a mobilefacenet block - */ -dl_matrix3d_t *dl_matrix3d_mobilefaceblock(dl_matrix3d_t *in, - dl_matrix3d_t *pw, - dl_matrix3d_t *pw_bn_scale, - dl_matrix3d_t *pw_bn_offset, - dl_matrix3d_t *dw, - dl_matrix3d_t *dw_bn_scale, - dl_matrix3d_t *dw_bn_offset, - dl_matrix3d_t *pw_linear, - dl_matrix3d_t *pw_linear_bn_scale, - dl_matrix3d_t *pw_linear_bn_offset, - int stride_x, - int stride_y, - int padding, - int mode, - int shortcut); - -/** - * @brief Do a mobilefacenet block forward with 1x1 split conv, dimension is (number, width, height, channel) - * - * @param in Input matrix3d - * @param pw_1 Weights of the pointwise conv layer 1 - * @param pw_2 Weights of the pointwise conv layer 2 - * @param pw_bn_scale The scale params of the batch_normalize layer after the pointwise conv layer - * @param pw_bn_offset The offset params of the batch_normalize layer after the pointwise conv layer - * @param dw Weights of the depthwise conv layer - * @param dw_bn_scale The scale params of the batch_normalize layer after the depthwise conv layer - * @param dw_bn_offset The offset params of the batch_normalize layer after the depthwise conv layer - * @param pw_linear_1 Weights of the pointwise linear conv layer 1 - * @param pw_linear_2 Weights of the pointwise linear conv layer 2 - * @param pw_linear_bn_scale The scale params of the batch_normalize layer after the pointwise linear conv layer - * @param pw_linear_bn_offset The offset params of the batch_normalize layer after the pointwise linear conv layer - * @param stride_x The step length of the convolution window in x(width) direction - * @param stride_y The step length of the convolution window in y(height) direction - * @param padding One of VALID or SAME - * @param mode Do convolution using C implement or xtensa implement, 0 or 1, with respect - * If ESP_PLATFORM is not defined, this value is not used. Default is 0 - * @return The result of a mobilefacenet block - */ -dl_matrix3d_t *dl_matrix3d_mobilefaceblock_split(dl_matrix3d_t *in, - dl_matrix3d_t *pw_1, - dl_matrix3d_t *pw_2, - dl_matrix3d_t *pw_bn_scale, - dl_matrix3d_t *pw_bn_offset, - dl_matrix3d_t *dw, - dl_matrix3d_t *dw_bn_scale, - dl_matrix3d_t *dw_bn_offset, - dl_matrix3d_t *pw_linear_1, - dl_matrix3d_t *pw_linear_2, - dl_matrix3d_t *pw_linear_bn_scale, - dl_matrix3d_t *pw_linear_bn_offset, - int stride_x, - int stride_y, - int padding, - int mode, - int shortcut); - -/** - * @brief Initialize the matrix3d feature map to bias - * - * @param out The matrix3d feature map needs to be initialized - * @param bias The bias of a convlotion operation - */ -void dl_matrix3d_init_bias(dl_matrix3d_t *out, dl_matrix3d_t *bias); - -/** - * @brief Do a elementwise multiplication of two matrix3ds - * - * @param out Preallocated matrix3d, size (n, w, h, c) - * @param in1 Input matrix 1, size (n, w, h, c) - * @param in2 Input matrix 2, size (n, w, h, c) - */ -void dl_matrix3d_multiply(dl_matrix3d_t *out, dl_matrix3d_t *in1, dl_matrix3d_t *in2); - -// -// Activation -// - -/** - * @brief Do a standard relu operation, update the input matrix3d - * - * @param m Floating point input matrix3d - */ -void dl_matrix3d_relu(dl_matrix3d_t *m); - -/** - * @brief Do a relu (Rectifier Linear Unit) operation, update the input matrix3d - * - * @param in Floating point input matrix3d - * @param clip If value is higher than this, it will be clipped to this value - */ -void dl_matrix3d_relu_clip(dl_matrix3d_t *m, fptp_t clip); - -/** - * @brief Do a Prelu (Rectifier Linear Unit) operation, update the input matrix3d - * - * @param in Floating point input matrix3d - * @param alpha If value is less than zero, it will be updated by multiplying this factor - */ -void dl_matrix3d_p_relu(dl_matrix3d_t *in, dl_matrix3d_t *alpha); - -/** - * @brief Do a leaky relu (Rectifier Linear Unit) operation, update the input matrix3d - * - * @param in Floating point input matrix3d - * @param alpha If value is less than zero, it will be updated by multiplying this factor - */ -void dl_matrix3d_leaky_relu(dl_matrix3d_t *m, fptp_t alpha); - -// -// Conv 1x1 -// -/** - * @brief Do 1x1 convolution with a matrix3d - * - * @param out Preallocated matrix3d, size (1, w, h, n) - * @param in Input matrix, size (1, w, h, c) - * @param filter 1x1 filter, size (n, 1, 1, c) - */ -void dl_matrix3dff_conv_1x1(dl_matrix3d_t *out, - dl_matrix3d_t *in, - dl_matrix3d_t *filter); - -/** - * @brief Do 1x1 convolution with a matrix3d, with bias adding - * - * @param out Preallocated matrix3d, size (1, w, h, n) - * @param in Input matrix, size (1, w, h, c) - * @param filter 1x1 filter, size (n, 1, 1, c) - * @param bias Bias, size (1, 1, 1, n) - */ -void dl_matrix3dff_conv_1x1_with_bias(dl_matrix3d_t *out, - dl_matrix3d_t *in, - dl_matrix3d_t *filter, - dl_matrix3d_t *bias); - -/** - * @brief Do 1x1 convolution with an 8-bit fixed point matrix - * - * @param out Preallocated matrix3d, size (1, w, h, n) - * @param in Input matrix, size (1, w, h, c) - * @param filter 1x1 filter, size (n, 1, 1, c) - */ -void dl_matrix3duf_conv_1x1(dl_matrix3d_t *out, - dl_matrix3du_t *in, - dl_matrix3d_t *filter); - -/** - * @brief Do 1x1 convolution with an 8-bit fixed point matrix, with bias adding - * - * @param out Preallocated matrix3d, size (1, w, h, n) - * @param in Input matrix, size (1, w, h, c) - * @param filter 1x1 filter, size (n, 1, 1, c) - * @param bias Bias, size (1, 1, 1, n) - */ -void dl_matrix3duf_conv_1x1_with_bias(dl_matrix3d_t *out, - dl_matrix3du_t *in, - dl_matrix3d_t *filter, - dl_matrix3d_t *bias); - -// -// Conv 3x3 -// - -/** - * @brief Do 3x3 convolution with a matrix3d, without padding - * - * @param out Preallocated matrix3d, size (1, w, h, n) - * @param in Input matrix, size (1, w, h, c) - * @param f 3x3 filter, size (n, 3, 3, c) - * @param step_x Stride of width - * @param step_y Stride of height - */ -void dl_matrix3dff_conv_3x3_op(dl_matrix3d_t *out, - dl_matrix3d_t *in, - dl_matrix3d_t *f, - int step_x, - int step_y); - -/** - * @brief Do 3x3 convolution with a matrix3d, with bias adding - * - * @param input Input matrix, size (1, w, h, c) - * @param filter 3x3 filter, size (n, 3, 3, c) - * @param bias Bias, size (1, 1, 1, n) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type - * @return dl_matrix3d_t* Resulting matrix3d - */ -dl_matrix3d_t *dl_matrix3dff_conv_3x3(dl_matrix3d_t *in, - dl_matrix3d_t *filter, - dl_matrix3d_t *bias, - int stride_x, - int stride_y, - dl_padding_type padding); - -// -// Conv Common -// - -/** - * @brief Do a general convolution layer pass with an 8-bit fixed point matrix, size is (number, width, height, channel) - * - * @param in Input image - * @param filter Weights of the neurons - * @param bias Bias for the CNN layer - * @param stride_x The step length of the convolution window in x(width) direction - * @param stride_y The step length of the convolution window in y(height) direction - * @param padding Padding type - * @return dl_matrix3d_t* Resulting matrix3d - */ -dl_matrix3d_t *dl_matrix3duf_conv_common(dl_matrix3du_t *in, - dl_matrix3d_t *filter, - dl_matrix3d_t *bias, - int stride_x, - int stride_y, - dl_padding_type padding); - -/** - * @brief Do a general convolution layer pass, size is (number, width, height, channel) - * - * @param in Input image - * @param filter Weights of the neurons - * @param bias Bias for the CNN layer - * @param stride_x The step length of the convolution window in x(width) direction - * @param stride_y The step length of the convolution window in y(height) direction - * @param padding Padding type - * @return dl_matrix3d_t* Resulting matrix3d - */ -dl_matrix3d_t *dl_matrix3dff_conv_common(dl_matrix3d_t *in, - dl_matrix3d_t *filter, - dl_matrix3d_t *bias, - int stride_x, - int stride_y, - dl_padding_type padding); - -// -// Depthwise 3x3 -// - -/** - * @brief Do 3x3 depthwise convolution with a float matrix3d - * - * @param in Input matrix, size (1, w, h, c) - * @param filter 3x3 filter, size (1, 3, 3, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type, 0: valid, 1: same - * @return dl_matrix3d_t* Resulting float matrix3d - */ -dl_matrix3d_t *dl_matrix3dff_depthwise_conv_3x3(dl_matrix3d_t *in, - dl_matrix3d_t *filter, - int stride_x, - int stride_y, - int padding); - -/** - * @brief Do 3x3 depthwise convolution with a 8-bit fixed point matrix - * - * @param in Input matrix, size (1, w, h, c) - * @param filter 3x3 filter, size (1, 3, 3, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type, 0: valid, 1: same - * @return dl_matrix3d_t* Resulting float matrix3d - */ -dl_matrix3d_t *dl_matrix3duf_depthwise_conv_3x3(dl_matrix3du_t *in, - dl_matrix3d_t *filter, - int stride_x, - int stride_y, - int padding); - -/** - * @brief Do 3x3 depthwise convolution with a float matrix3d, without padding - * - * @param out Preallocated matrix3d, size (1, w, h, n) - * @param in Input matrix, size (1, w, h, c) - * @param f 3x3 filter, size (1, 3, 3, c) - * @param step_x Stride of width - * @param step_y Stride of height - */ -void dl_matrix3dff_depthwise_conv_3x3_op(dl_matrix3d_t *out, - dl_matrix3d_t *in, - dl_matrix3d_t *f, - int step_x, - int step_y); - -// -// Depthwise Common -// - -/** - * @brief Do a depthwise CNN layer pass, dimension is (number, width, height, channel) - * - * @param in Input matrix3d - * @param filter Weights of the neurons - * @param stride_x The step length of the convolution window in x(width) direction - * @param stride_y The step length of the convolution window in y(height) direction - * @param padding One of VALID or SAME - * @param mode Do convolution using C implement or xtensa implement, 0 or 1, with respect - * If ESP_PLATFORM is not defined, this value is not used. Default is 0 - * @return The result of depthwise CNN layer - */ -dl_matrix3d_t *dl_matrix3dff_depthwise_conv_common(dl_matrix3d_t *in, - dl_matrix3d_t *filter, - int stride_x, - int stride_y, - dl_padding_type padding); - -// -// FC -// -/** - * @brief Do a general fully connected layer pass, dimension is (number, width, height, channel) - * - * @param in Input matrix3d, size is (1, w, 1, 1) - * @param filter Weights of the neurons, size is (1, w, h, 1) - * @param bias Bias for the fc layer, size is (1, 1, 1, h) - * @return The result of fc layer, size is (1, 1, 1, h) - */ -void dl_matrix3dff_fc(dl_matrix3d_t *out, - dl_matrix3d_t *in, - dl_matrix3d_t *filter); - -/** - * @brief Do fully connected layer forward, with bias adding - * - * @param out Preallocated resulting matrix, size (1, 1, 1, h) - * @param in Input matrix, size (1, 1, 1, w) - * @param filter Filter matrix, size (1, w, h, 1) - * @param bias Bias matrix, size (1, 1, 1, h) - */ -void dl_matrix3dff_fc_with_bias(dl_matrix3d_t *out, - dl_matrix3d_t *in, - dl_matrix3d_t *filter, - dl_matrix3d_t *bias); - -// -// Mobilenet -// - -/** - * @brief Do a mobilenet block forward, dimension is (number, width, height, channel) - * - * @param in Input matrix3d - * @param filter Weights of the neurons - * @param stride_x The step length of the convolution window in x(width) direction - * @param stride_y The step length of the convolution window in y(height) direction - * @param padding One of VALID or SAME - * @param mode Do convolution using C implement or xtensa implement, 0 or 1, with respect - * If ESP_PLATFORM is not defined, this value is not used. Default is 0 - * @return The result of depthwise CNN layer - */ -dl_matrix3d_t *dl_matrix3dff_mobilenet(dl_matrix3d_t *in, - dl_matrix3d_t *dilate_filter, - dl_matrix3d_t *dilate_prelu, - dl_matrix3d_t *depthwise_filter, - dl_matrix3d_t *depthwise_prelu, - dl_matrix3d_t *compress_filter, - dl_matrix3d_t *bias, - dl_matrix3d_mobilenet_config_t config); - -/** - * @brief Do a mobilenet block forward, dimension is (number, width, height, channel) - * - * @param in Input matrix3du - * @param filter Weights of the neurons - * @param stride_x The step length of the convolution window in x(width) direction - * @param stride_y The step length of the convolution window in y(height) direction - * @param padding One of VALID or SAME - * @param mode Do convolution using C implement or xtensa implement, 0 or 1, with respect - * If ESP_PLATFORM is not defined, this value is not used. Default is 0 - * @return The result of depthwise CNN layer - */ -dl_matrix3d_t *dl_matrix3duf_mobilenet(dl_matrix3du_t *in, - dl_matrix3d_t *dilate_filter, - dl_matrix3d_t *dilate_prelu, - dl_matrix3d_t *depthwise_filter, - dl_matrix3d_t *depthwise_prelu, - dl_matrix3d_t *compress_filter, - dl_matrix3d_t *bias, - dl_matrix3d_mobilenet_config_t config); diff --git a/tools/sdk/esp32/include/esp-face/lib/include/dl_lib_matrix3dq.h b/tools/sdk/esp32/include/esp-face/lib/include/dl_lib_matrix3dq.h deleted file mode 100644 index 0d982b4a0e0..00000000000 --- a/tools/sdk/esp32/include/esp-face/lib/include/dl_lib_matrix3dq.h +++ /dev/null @@ -1,1441 +0,0 @@ -#pragma once -#include "dl_lib_matrix3d.h" - -typedef int16_t qtp_t; - -/** - * Matrix for input, filter, and output - * @Warning: the sequence of variables is fixed, cannot be modified, otherwise there will be errors in - * some handwrite xtensa instruction functions - */ -typedef struct -{ - /******* fix start *******/ - int w; /*!< Width */ - int h; /*!< Height */ - int c; /*!< Channel */ - int n; /*!< Number of filter, input and output must be 1 */ - int stride; /*!< Step between lines */ - int exponent; /*!< Exponent for quantization */ - qtp_t *item; /*!< Data */ - /******* fix end *******/ -} dl_matrix3dq_t; - -#ifndef DL_QTP_SHIFT -#define DL_QTP_SHIFT 15 -#define DL_ITMQ(m, x, y) m->itemq[(y) + (x)*m->stride] -#define DL_QTP_RANGE ((1 << DL_QTP_SHIFT) - 1) -#define DL_QTP_MAX 32767 -#define DL_QTP_MIN -32768 - -#define DL_QTP_EXP_NA 255 //non-applicable exponent because matrix is null - -#define DL_SHIFT_AUTO 32 -#endif - -/** - * Implementation of matrix relative operations - */ -typedef enum -{ - DL_C_IMPL = 0, /*!< ANSI C */ - DL_XTENSA_IMPL = 1 /*!< Handwrite xtensa instruction */ -} dl_conv_mode; - -/** - * Configuration of mobilenet operation - */ -typedef struct -{ - int stride_x; /*!< Strides of width */ - int stride_y; /*!< Strides of height */ - dl_padding_type padding; /*!< Padding type */ - dl_conv_mode mode; /*!< Implementation mode */ - int dilate_exponent; /*!< Exponent of dilation filter */ - int depthwise_exponent; /*!< Exponent of depthwise filter */ - int compress_exponent; /*!< Exponent of compress filter */ -} dl_matrix3dq_mobilenet_config_t; - -typedef struct -{ - int stride_x; /*!< Strides of width */ - int stride_y; /*!< Strides of height */ - dl_padding_type padding; /*!< Padding type */ - dl_conv_mode mode; /*!< Implementation mode */ - int dw1_exponent; /*!< Exponent of dw1 filter */ - int pw1_exponent; /*!< Exponent of pw1 filter */ - int dw2_exponent; /*!< Exponent of dw2 filter */ - int pw2_exponent; /*!< Exponent of pw2 filter */ - int shortcut; /*!< Shortcut connection flag */ - int save_input; /*!< Input save flag */ -} dl_matrix3dq_blazeblock_config_t; - -// -// Utility -// - -/* - * @brief Allocate a 3d quantised matrix - * - * @param n Number of filters, for input and output, should be 1 - * @param w Width of matrix - * @param h Height of matrix - * @param c Channel of matrix - * @param e Exponent of matrix data - * @return 3d quantized matrix - */ -static inline dl_matrix3dq_t *dl_matrix3dq_alloc(int n, int w, int h, int c, int e) -{ - dl_matrix3dq_t *r = (dl_matrix3dq_t *)dl_lib_calloc(1, sizeof(dl_matrix3dq_t), 0); - if (NULL == r) - { - printf("dl_matrix3dq alloc failed.\n"); - return NULL; - } - - qtp_t *items = (qtp_t *)dl_lib_calloc(n * w * h * c, sizeof(qtp_t), 16); - if (NULL == items) - { - printf("matrix3dq item alloc failed.\n"); - dl_lib_free(r); - return NULL; - } - - r->w = w; - r->h = h; - r->c = c; - r->n = n; - r->exponent = e; - r->stride = w * c; - r->item = items; - - return r; -} - -/* - * @brief Free a 3d quantized matrix - * - * @param m 3d quantised matrix - */ -static inline void dl_matrix3dq_free(dl_matrix3dq_t *m) -{ - if (NULL == m) - return; - if (NULL == m->item) - { - dl_lib_free(m); - return; - } - dl_lib_free(m->item); - dl_lib_free(m); -} - - -/** - * @brief Copy a range of items from an existing matrix to a preallocated matrix - * - * @param dst The resulting slice matrix - * @param src Old matrix to slice. - * @param x X-offset of the origin of the returned matrix within the sliced matrix - * @param y Y-offset of the origin of the returned matrix within the sliced matrix - * @param w Width of the resulting matrix - * @param h Height of the resulting matrix - */ -void dl_matrix3dq_slice_copy(dl_matrix3dq_t *dst, dl_matrix3dq_t *src, int x, int y, int w, int h); - -/** - * @brief Transform a sliced matrix block from nhwc to nchw, the block needs to be memory continous. - * - * @param out The destination sliced matrix in nchw - * @param in The source sliced matrix in nhwc - */ -void dl_matrix3dq_sliced_transform_nchw(dl_matrix3dq_t *out, - dl_matrix3dq_t *in); - -/** - * @brief Transform a fixed point matrix to a float point matrix - * - * @param m Quantized matrix - * @return Float point matrix - */ -dl_matrix3d_t *dl_matrix3d_from_matrixq(dl_matrix3dq_t *m); - -/** - * @brief Transform a float point matrix to a fixed point matrix with pre-defined exponent - * - * @param m Float point matrix - * @param exponent Exponent for resulting matrix - * @return Fixed point matrix - */ -dl_matrix3dq_t *dl_matrixq_from_matrix3d_qmf(dl_matrix3d_t *m, int exponent); - -/** - * @brief Transform a float point matrix to a fixed point matrix. The exponent is defined by the distribution of the input matrix. - * - * @param m Float point matrix - * @return Fixed point matrix - */ -dl_matrix3dq_t *dl_matrixq_from_matrix3d(dl_matrix3d_t *m); - -/** - * @brief Truncate the overflowed 16bit number - * - * @param value Input value - * @param location Location tag - * @return qtp_t Truncated value - */ -qtp_t dl_matrix3dq_quant_range_exceeded_checking(int64_t value, char *location); - -/** - * @brief Reform a quantized matrix with exponent - * - * @param out Preallocated resulting matrix - * @param in Input matrix - * @param exponent Exponent for resulting matrix - */ -void dl_matrix3dq_shift_exponent(dl_matrix3dq_t *out, dl_matrix3dq_t *in, int exponent); - -/** - * @brief Do batch normalization for a quantized matrix - * - * @param m Input and output quantized matrix, data will be updated - * @param scale Scale of batch-norm - * @param offset Offset of batch-norm - */ -void dl_matrix3dq_batch_normalize(dl_matrix3dq_t *m, dl_matrix3dq_t *scale, dl_matrix3dq_t *offset); - -/** - * @brief Add two quantized matrix with a pre-defined exponent - * - * @param in_1 Adder 1 - * @param in_2 Adder 2 - * @param exponent Exponent for resulting matrix - * @return dl_matrix3dq_t* Result of accumulation of two matrix - */ -dl_matrix3dq_t *dl_matrix3dq_add(dl_matrix3dq_t *in_1, dl_matrix3dq_t *in_2, int exponent); - -/** - * @brief Add two quantized matrix with different channels - * - * @param in_1 Adder 1 - * @param in_2 Adder 2 - * @param exponent Exponent for resulting matrix - * @return dl_matrix3dq_t* Result of accumulation of two matrix - */ -dl_matrix3dq_t *dl_matrix3dq_add_channel_diff(dl_matrix3dq_t *in_1, dl_matrix3dq_t *in_2, int exponent); - -// -// Activation -// -/** - * @brief Do relu for a quantized matrix - * - * @param in Input and output quantized matrix, data will be updated - */ -void dl_matrix3dq_relu(dl_matrix3dq_t *in); - -/** - * @brief Do relu with clips for a quantized matrix - * - * @param in Input and output quantized matrix, data will be updated - * @param clip Float point value to limit the maximum data - */ -void dl_matrix3dq_relu_clip(dl_matrix3dq_t *in, fptp_t clip); - -/** - * @brief Do leaky relu for a quantized matrix - * - * @param in Input and output quantized matrix, data will be updated - * @param alpha Float point value to multiply for those less than zero - * @param clip Float point value to limit the maximum data - */ -void dl_matrix3dq_leaky_relu(dl_matrix3dq_t *in, fptp_t alpha, fptp_t clip); - -/** - * @brief Do prelu for a quantized matrix - * - * @param in Input and output quantized matrix, data will be updated - * @param alpha Quantized matrix to multiply for those less than zero - */ -void dl_matrix3dq_p_relu(dl_matrix3dq_t *in, dl_matrix3dq_t *alpha); - -// -// Concat -// -/** - * @brief Concatenate two quantized matrix in channel - * - * @param in_1 Quantized matrix to be concatenated - * @param in_2 Quantized matrix to be concatenated - * @return Quantized matrix with the same width and height of in_1 and in_2, and with the sum of channel number of in_1 and in_2 - */ -dl_matrix3dq_t *dl_matrix3dq_concat(dl_matrix3dq_t *in_1, - dl_matrix3dq_t *in_2); - -/** - * @brief Concatenate four quantized matrix in channel - * - * @param in_1 Quantized matrix to be concatenated - * @param in_2 Quantized matrix to be concatenated - * @param in_3 Quantized matrix to be concatenated - * @param in_4 Quantized matrix to be concatenated - * @return Quantized matrix with the same width and height of all inputs, and with the sum of channel number of all inputs - */ -dl_matrix3dq_t *dl_matrix3dq_concat_4(dl_matrix3dq_t *in_1, - dl_matrix3dq_t *in_2, - dl_matrix3dq_t *in_3, - dl_matrix3dq_t *in_4); - -/** - * @brief Concatenate four quantized matrix in channel - * - * @param in_1 Quantized matrix to be concatenated - * @param in_2 Quantized matrix to be concatenated - * @param in_3 Quantized matrix to be concatenated - * @param in_4 Quantized matrix to be concatenated - * @param in_5 Quantized matrix to be concatenated - * @param in_6 Quantized matrix to be concatenated - * @param in_7 Quantized matrix to be concatenated - * @param in_8 Quantized matrix to be concatenated - * @return Quantized matrix with the same width and height of all inputs, and with the sum of channel number of all inputs - */ -dl_matrix3dq_t *dl_matrix3dq_concat_8(dl_matrix3dq_t *in_1, - dl_matrix3dq_t *in_2, - dl_matrix3dq_t *in_3, - dl_matrix3dq_t *in_4, - dl_matrix3dq_t *in_5, - dl_matrix3dq_t *in_6, - dl_matrix3dq_t *in_7, - dl_matrix3dq_t *in_8); - -// -// Conv 1x1 -// -/** - * @brief Do 1x1 convolution with a quantized matrix - * - * @param out Preallocated quantized matrix, size (1, w, h, n) - * @param in Input matrix, size (1, w, h, c) - * @param filter 1x1 filter, size (n, 1, 1, c) - * @param mode Implementation mode - * @param name Layer name to debug - */ -void dl_matrix3dqq_conv_1x1(dl_matrix3dq_t *out, - dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - dl_conv_mode mode, - char *name); - -/** - * @brief Do 1x1 convolution with a quantized matrix, with relu activation - * - * @param out Preallocated quantized matrix, size (1, w, h, n) - * @param in Input matrix, size (1, w, h, c) - * @param filter 1x1 filter, size (n, 1, 1, c) - * @param mode Implementation mode - * @param name Layer name to debug - */ -void dl_matrix3dqq_conv_1x1_with_relu(dl_matrix3dq_t *out, - dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - dl_conv_mode mode, - char *name); - -/** - * @brief Do 1x1 convolution with a quantized matrix, with bias adding - * - * @param out Preallocated quantized matrix, size (1, w, h, n) - * @param in Input matrix, size (1, w, h, c) - * @param filter 1x1 filter, size (n, 1, 1, c) - * @param bias Bias, size (1, 1, 1, n) - * @param mode Implementation mode - * @param name Layer name to debug - */ -void dl_matrix3dqq_conv_1x1_with_bias(dl_matrix3dq_t *out, - dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *bias, - dl_conv_mode mode, - char *name); - -/** - * @brief Do 1x1 convolution with a quantized matrix, with bias adding - * - * @param out Preallocated quantized matrix, size (1, w, h, n) - * @param in Input matrix, size (1, w, h, c) - * @param filter 1x1 filter, size (n, 1, 1, c) - * @param bias Bias, size (1, 1, 1, n) - * @param mode Implementation mode - * @param name Layer name to debug - */ -void dl_matrix3dqq_conv_1x1_with_bias_relu(dl_matrix3dq_t *out, - dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *bias, - dl_conv_mode mode, - char *name); - -/** - * @brief Do 1x1 convolution with a quantized matrix, with prelu activation - * - * @param out Preallocated quantized matrix, size (1, w, h, n) - * @param in Input matrix, size (1, w, h, c) - * @param filter 1x1 filter, size (n, 1, 1, c) - * @param prelu prelu params, size (1, 1, 1, n) - * @param mode Implementation mode - * @param name Layer name to debug - */ -void dl_matrix3dqq_conv_1x1_with_prelu(dl_matrix3dq_t *out, - dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *prelu, - dl_conv_mode mode, - char *name); - -/** - * @brief Do 1x1 convolution with an 8-bit fixed point matrix - * - * @param out Preallocated quantized matrix, size (1, w, h, n) - * @param in Input matrix, size (1, w, h, c) - * @param filter 1x1 filter, size (n, 1, 1, c) - * @param mode Implementation mode - * @param name Layer name to debug - */ -void dl_matrix3duq_conv_1x1(dl_matrix3dq_t *out, - dl_matrix3du_t *in, - dl_matrix3dq_t *filter, - dl_conv_mode mode, - char *name); - -/** - * @brief Do 1x1 convolution with an 8-bit fixed point matrix, with bias adding - * - * @param out Preallocated quantized matrix, size (1, w, h, n) - * @param in Input matrix, size (1, w, h, c) - * @param filter 1x1 filter, size (n, 1, 1, c) - * @param bias Bias, size (1, 1, 1, n) - * @param mode Implementation mode - * @param name Layer name to debug - */ -void dl_matrix3duq_conv_1x1_with_bias(dl_matrix3dq_t *out, - dl_matrix3du_t *in, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *bias, - dl_conv_mode mode, - char *name); - -// -// Conv 3x3 -// - -/** - * @brief Do 3x3 convolution with a quantized matrix - * - * @param input Input matrix, size (1, w, h, c) - * @param filter 3x3 filter, size (n, 3, 3, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type, 0: valid, 1: same - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_conv_3x3(dl_matrix3dq_t *input, - dl_matrix3dq_t *filter, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); - -/** - * @brief Do 3x3 convolution with a quantized matrix, with bias adding - * - * @param input Input matrix, size (1, w, h, c) - * @param filter 3x3 filter, size (n, 3, 3, c) - * @param bias Bias, size (1, 1, 1, n) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_conv_3x3_with_bias(dl_matrix3dq_t *input, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *bias, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); - -/** - * @brief Do 3x3 convolution with a quantized matrix, with bias adding, relu activation - * - * @param input Input matrix, size (1, w, h, c) - * @param filter 3x3 filter, size (n, 3, 3, c) - * @param bias Bias, size (1, 1, 1, n) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_conv_3x3_with_bias_relu(dl_matrix3dq_t *input, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *bias, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); - -/** - * @brief Do 3x3 convolution with an 8-bit fixed point matrix, with bias adding - * - * @param input Input matrix, size (1, w, h, c) - * @param filter 3x3 filter, size (n, 3, 3, c) - * @param bias Bias, size (1, 1, 1, n) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3duq_conv_3x3_with_bias(dl_matrix3du_t *input, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *bias, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); - -/** - * @brief Do 3x3 convolution with an 8-bit fixed point matrix, with bias adding, prelu activation - * - * @param input Input matrix, size (1, w, h, c) - * @param filter 3x3 filter, size (n, 3, 3, c) - * @param bias Bias, size (1, 1, 1, n) - * @param prelu prelu params, size (1, 1, 1, n) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3duq_conv_3x3_with_bias_prelu(dl_matrix3du_t *input, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *bias, - dl_matrix3dq_t *prelu, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); - - -/** - * @brief Do 3x3 convolution with a quantized matrix, with bias adding, prelu activation - * - * @param input Input matrix, size (1, w, h, c) - * @param filter 3x3 filter, size (n, 3, 3, c) - * @param bias Bias, size (1, 1, 1, n) - * @param prelu prelu params, size (1, 1, 1, n) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_conv_3x3_with_bias_prelu(dl_matrix3dq_t *input, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *bias, - dl_matrix3dq_t *prelu, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); -// -// Conv common -// - -/** - * @brief Do a general convolution layer pass, size is (number, width, height, channel) - * - * @param in Input image - * @param filter Weights of the neurons - * @param bias Bias for the CNN layer. - * @param stride_x The step length of the convolution window in x(width) direction - * @param stride_y The step length of the convolution window in y(height) direction - * @param padding One of VALID or SAME - * @param mode Do convolution using C implement or xtensa implement, 0 or 1, with respect. - * If ESP_PLATFORM is not defined, this value is not used. - * @return The result of CNN layer. - */ -dl_matrix3dq_t *dl_matrix3dqq_conv_common(dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *bias, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - dl_conv_mode mode); - -/** - * @brief Do a general convolution layer pass for an 8-bit fixed point matrix, size is (number, width, height, channel) - * - * @param in Input image - * @param filter Weights of the neurons - * @param bias Bias for the CNN layer. - * @param stride_x The step length of the convolution window in x(width) direction - * @param stride_y The step length of the convolution window in y(height) direction - * @param padding One of VALID or SAME - * @param mode Do convolution using C implement or xtensa implement, 0 or 1, with respect. - * If ESP_PLATFORM is not defined, this value is not used. - * @return The result of CNN layer. - */ -dl_matrix3dq_t *dl_matrix3duq_conv_common(dl_matrix3du_t *in, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *bias, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - dl_conv_mode mode); - -// -// Depthwise 3x3 -// -/** - * @brief Do 3x3 depthwise convolution with an 8-bit fixed point matrix - * - * @param in Input matrix, size (1, w, h, c) - * @param filter 3x3 filter, size (1, 3, 3, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type, 0: valid, 1: same - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3duq_depthwise_conv_3x3(dl_matrix3du_t *in, - dl_matrix3dq_t *filter, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); - -/** - * @brief Do 3x3 depthwise convolution with a quantized matrix - * - * @param in Input matrix, size (1, w, h, c) - * @param filter 3x3 filter, size (1, 3, 3, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type, 0: valid, 1: same - * @param relu ReLU, 0: don't, 1: do - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_3x3(dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - int stride_x, - int stride_y, - dl_padding_type padding, - int relu, - int exponent, - char *name); - -#if CONFIG_DEVELOPING_CODE -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_3x3_2(dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); - -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_3x3_3(dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); -#endif - -/** - * @brief Do 3x3 depthwise convolution with a quantized matrix, with bias adding - * - * @param in Input matrix, size (1, w, h, c) - * @param f 3x3 filter, size (1, 3, 3, c) - * @param bias Bias, size (1, 1, 1, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type, 0: valid, 1: same - * @param exponent Exponent for resulting matrix - * @param relu Whether to use relu activation - * @param name Layer name to debug - * @return Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_3x3_with_bias(dl_matrix3dq_t *in, - dl_matrix3dq_t *f, - dl_matrix3dq_t *bias, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - int relu, - char *name); - -/** - * @brief Do 3x3 depthwise convolution with a quantized matrix, with bias adding and stride 1 - * - * @param in Input matrix, size (1, w, h, c) - * @param f 3x3 filter, size (1, 3, 3, c) - * @param bias Bias, size (1, 1, 1, c) - * @param padding Padding type, 0: valid, 1: same - * @param exponent Exponent for resulting matrix - * @param relu Whether to use relu activation - * @param name Layer name to debug - * @return Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_3x3s1_with_bias(dl_matrix3dq_t *in, - dl_matrix3dq_t *f, - dl_matrix3dq_t *bias, - dl_padding_type padding, - int exponent, - int relu, - char *name); - -/** - * @brief Do 3x3 depthwise convolution with a quantized matrix, with prelu activation - * - * @param in Input matrix, size (1, w, h, c) - * @param filter 3x3 filter, size (1, 3, 3, c) - * @param prelu prelu params, size (1, 1, 1, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_3x3_with_prelu(dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *prelu, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); - -/** - * @brief Do 3x3 depthwise convolution with a quantized matrix, with bias adding and prelu activation - * - * @param in Input matrix, size (1, w, h, c) - * @param f 3x3 filter, size (1, 3, 3, c) - * @param bias Bias, size (1, 1, 1, c) - * @param prelu prelu params, size (1, 1, 1, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_3x3_with_bias_prelu(dl_matrix3dq_t *in, - dl_matrix3dq_t *f, - dl_matrix3dq_t *bias, - dl_matrix3dq_t *prelu, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); - -/** - * @brief Do global depthwise convolution with a quantized matrix, with bias adding - * - * @param in Input matrix, size (1, w, h, c) - * @param filter filter, size (1, w, h, c) - * @param bias Bias, size (1, 1, 1, c) - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_global_depthwise_conv_with_bias(dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *bias, - int exponent, - char *name); - - - -// -// Depthwise 2x2 -// -/** - * @brief Do 2x2 depthwise convolution with a quantized matrix - * - * @param in Input matrix, size (1, w, h, c) - * @param filter 2x2 filter, size (1, 2, 2, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type, 0: valid, 1: same - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_2x2(dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); - -/** - * @brief Do 2x2 depthwise convolution with a quantized matrix, with bias adding - * - * @param in Input matrix, size (1, w, h, c) - * @param f 2x2 filter, size (1, 2, 2, c) - * @param bias Bias, size (1, 1, 1, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type, 0: valid, 1: same - * @param exponent Exponent for resulting matrix - * @param relu Whether to use relu activation - * @param name Layer name to debug - * @return Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_2x2_with_bias(dl_matrix3dq_t *in, - dl_matrix3dq_t *f, - dl_matrix3dq_t *bias, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - int relu, - char *name); - -/** - * @brief Do 2x2 depthwise convolution with a quantized matrix, with prelu activation - * - * @param in Input matrix, size (1, w, h, c) - * @param filter 2x2 filter, size (1, 2, 2, c) - * @param prelu prelu params, size (1, 1, 1, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_2x2_with_prelu(dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *prelu, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); - -/** - * @brief Do 2x2 depthwise convolution with a quantized matrix, with bias adding and prelu activation - * - * @param in Input matrix, size (1, w, h, c) - * @param f 2x2 filter, size (1, 2, 2, c) - * @param bias Bias, size (1, 1, 1, c) - * @param prelu prelu params, size (1, 1, 1, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_2x2_with_bias_prelu(dl_matrix3dq_t *in, - dl_matrix3dq_t *f, - dl_matrix3dq_t *bias, - dl_matrix3dq_t *prelu, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); - -// -// Depthwise 5x5 -// -/** - * @brief Do 5x5 depthwise convolution with a quantized matrix - * - * @param in Input matrix, size (1, w, h, c) - * @param filter 5x5 filter, size (1, 5, 5, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type, 0: valid, 1: same - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_5x5(dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); - -/** - * @brief Do 5x5 depthwise convolution with a quantized matrix, with bias adding - * - * @param in Input matrix, size (1, w, h, c) - * @param f 5x5 filter, size (1, 5, 5, c) - * @param bias Bias, size (1, 1, 1, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type, 0: valid, 1: same - * @param exponent Exponent for resulting matrix - * @param relu Whether to use relu activation - * @param name Layer name to debug - * @return Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_5x5_with_bias(dl_matrix3dq_t *in, - dl_matrix3dq_t *f, - dl_matrix3dq_t *bias, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - int relu, - char *name); - -/** - * @brief Do 5x5 depthwise convolution with a quantized matrix, with prelu activation - * - * @param in Input matrix, size (1, w, h, c) - * @param filter 5x5 filter, size (1, 5, 5, c) - * @param prelu prelu params, size (1, 1, 1, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_5x5_with_prelu(dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *prelu, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); - -/** - * @brief Do 5x5 depthwise convolution with a quantized matrix, with bias adding and prelu activation - * - * @param in Input matrix, size (1, w, h, c) - * @param f 5x5 filter, size (1, 5, 5, c) - * @param bias Bias, size (1, 1, 1, c) - * @param prelu prelu params, size (1, 1, 1, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_5x5_with_bias_prelu(dl_matrix3dq_t *in, - dl_matrix3dq_t *f, - dl_matrix3dq_t *bias, - dl_matrix3dq_t *prelu, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); - -// -// Depthwise Common -// -#if CONFIG_DEVELOPING_CODE -/** - * @brief Do a general depthwise convolution layer pass with a quantized matrix - * - * @param in Input matrix, size (1, w, h, c) - * @param filter Weights of the neurons, size (1, k_w, k_h, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type - * @param exponent Exponent for resulting matrix - * @param mode Implementation mode - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_common(dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - dl_conv_mode mode); - -/** - * @brief Do a general depthwise convolution layer pass with an 8-bit fixed point matrix - * - * @param in Input matrix, size (1, w, h, c) - * @param filter Weights of the neurons, size (1, k_w, k_h, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type - * @param exponent Exponent for resulting matrix - * @param mode Implementation mode - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3duq_depthwise_conv_common(dl_matrix3du_t *in, - dl_matrix3dq_t *filter, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - dl_conv_mode mode); -#endif - -// -// Dot Product -// - -/** - * @brief Do dot product operation with a quantized matrix - * - * @param out Preallocated resulting matrix, size (1, 1, 1, h) - * @param in Input matrix, size (1, 1, 1, w) - * @param filter Filter matrix, size (1, w, h, 1) - * @param mode Implementation mode - */ -void dl_matrix3dqq_dot_product(dl_matrix3dq_t *out, - dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - dl_conv_mode mode); - -// -// FC -// -/** - * @brief Do fully connected layer forward. - * - * @param out Preallocated resulting matrix, size (1, 1, 1, h) - * @param in Input matrix, size (1, 1, 1, w) - * @param filter Filter matrix, size (1, w, h, 1) - * @param mode Implementation mode - * @param name Layer name to debug - */ -void dl_matrix3dqq_fc(dl_matrix3dq_t *out, - dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - dl_conv_mode mode, - char *name); - -/** - * @brief Do fully connected layer forward, with bias adding - * - * @param out Preallocated resulting matrix, size (1, 1, 1, h) - * @param in Input matrix, size (1, 1, 1, w) - * @param filter Filter matrix, size (1, w, h, 1) - * @param bias Bias matrix, size (1, 1, 1, h) - * @param mode Implementation mode - * @param name Layer name to debug - */ -void dl_matrix3dqq_fc_with_bias(dl_matrix3dq_t *out, - dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *bias, - dl_conv_mode mode, - char *name); - -// -// Mobilefaceblock -// -/** - * @brief Do mobilefacenet process with splited pointwise 1x1 convolution, the process sequence is 1x1 pointwise->bn->relu->3x3 depthwise->bn->relu->1x1 pointwise->bn - * - * @param in Input matrix, size (1, w, h, c) - * @param pw_1 Pointwise 1x1 filter, size (n1/2, 1, 1, c) - * @param pw_2 Pointwise 1x1 filter, size (n1/2, 1, 1, c) - * @param pw_bias Pointwise bias, size (1, 1, 1, n1) - * @param dw Depthwise 3x3 filter, size (1, 3, 3, n1) - * @param dw_bias Depthwise bias, size (1, 1, 1, n1) - * @param pw_linear_1 Pointwise 1x1 filter, size (n2/2, 1, 1, n1) - * @param pw_linear_2 Pointwise 1x1 filter, size (n2/2, 1, 1, n1) - * @param pw_linear_bias Pointwise bias, size (1, 1, 1, n2) - * @param pw_exponent Exponent for pointwise resulting matrix - * @param dw_exponent Exponent for depthwise resulting matrix - * @param pw_linear_exponent Exponent for pointwise resulting matrix - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type, 0: valid, 1: same - * @param mode Implementation mode - * @param shortcut Whether has a shortcut at pointwise linear - * @return Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_mobilefaceblock_split(dl_matrix3dq_t *in, - dl_matrix3dq_t *pw_1, - dl_matrix3dq_t *pw_2, - dl_matrix3dq_t *pw_bias, - dl_matrix3dq_t *dw, - dl_matrix3dq_t *dw_bias, - dl_matrix3dq_t *pw_linear_1, - dl_matrix3dq_t *pw_linear_2, - dl_matrix3dq_t *pw_linear_bias, - int pw_exponent, - int dw_exponent, - int pw_linear_exponent, - int stride_x, - int stride_y, - dl_padding_type padding, - dl_conv_mode mode, - int shortcut); - -/** - * @brief Do mobilefacenet process, the process sequence is 1x1 pointwise->bn->relu->3x3 depthwise->bn->relu->1x1 pointwise->bn - * - * @param in Input matrix, size (1, w, h, c) - * @param pw Pointwise 1x1 filter, size (n1, 1, 1, c) - * @param pw_bias Pointwise bias, size (1, 1, 1, n1) - * @param dw Depthwise 3x3 filter, size (1, 3, 3, n1) - * @param dw_bias Depthwise bias, size (1, 1, 1, n1) - * @param pw_linear Pointwise 1x1 filter, size (n2, 1, 1, n1) - * @param pw_linear_bias Pointwise bias, size (1, 1, 1, n2) - * @param pw_exponent Exponent for pointwise resulting matrix - * @param dw_exponent Exponent for depthwise resulting matrix - * @param pw_linear_exponent Exponent for pointwise resulting matrix - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type, 0: valid, 1: same - * @param mode Implementation mode - * @param shortcut Whether has a shortcut at pointwise linear - * @return Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_mobilefaceblock(dl_matrix3dq_t *in, - dl_matrix3dq_t *pw, - dl_matrix3dq_t *pw_bias, - dl_matrix3dq_t *dw, - dl_matrix3dq_t *dw_bias, - dl_matrix3dq_t *pw_linear, - dl_matrix3dq_t *pw_linear_bias, - int pw_exponent, - int dw_exponent, - int pw_linear_exponent, - int stride_x, - int stride_y, - dl_padding_type padding, - dl_conv_mode mode, - int shortcut); - -/** - * @brief Do mobilefacenet process, the process sequence is 1x1 pointwise->bn->prelu->3x3 depthwise->bn->prelu->1x1 pointwise->bn - * - * @param in Input matrix, size (1, w, h, c) - * @param pw Pointwise 1x1 filter, size (n1, 1, 1, c) - * @param pw_bias Pointwise bias, size (1, 1, 1, n1) - * @param pw_prelu Pointwise prelu, size (1, 1, 1, n1) - * @param dw Depthwise 3x3 filter, size (1, 3, 3, n1) - * @param dw_bias Depthwise bias, size (1, 1, 1, n1) - * @param dw_prelu Depthwise prelu, size(1, 1, 1, n1) - * @param pw_linear Pointwise 1x1 filter, size (n2, 1, 1, n1) - * @param pw_linear_bias Pointwise bias, size (1, 1, 1, n2) - * @param pw_exponent Exponent for pointwise resulting matrix - * @param dw_exponent Exponent for depthwise resulting matrix - * @param pw_linear_exponent Exponent for pointwise resulting matrix - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Depthwise Convlution Padding type - * @param mode Implementation mode - * @param shortcut Whether has a shortcut at pointwise linear - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_mobilefaceblock_prelu(dl_matrix3dq_t *in, - dl_matrix3dq_t *pw, - dl_matrix3dq_t *pw_bias, - dl_matrix3dq_t *pw_prelu, - dl_matrix3dq_t *dw, - dl_matrix3dq_t *dw_bias, - dl_matrix3dq_t *dw_prelu, - dl_matrix3dq_t *pw_linear, - dl_matrix3dq_t *pw_linear_bias, - int pw_exponent, - int dw_exponent, - int pw_linear_exponent, - int stride_x, - int stride_y, - dl_padding_type padding, - dl_conv_mode mode, - int shortcut); - -/**@{*/ -/** - * @brief Do mobilefacenet process, the process sequence is 1x1 pointwise->bn->prelu->3x3 depthwise->bn->prelu->1x1 pointwise->bn - * - * Compared to ‘dl_matrix3dqq_mobilefaceblock_prelu’, this family of functions 'dl_matrix3dqq_mobilefaceblock_prelu_split_x1_x2' - * split the first pointwise convlution into x1 pointwise convlutions, and split the second pointwise convlution into x2 pointwise convlutions. - * - * - */ -dl_matrix3dq_t *dl_matrix3dqq_mobilefaceblock_prelu_split_2_2(dl_matrix3dq_t *in, - dl_matrix3dq_t *pw_1, - dl_matrix3dq_t *pw_2, - dl_matrix3dq_t *pw_bias, - dl_matrix3dq_t *pw_prelu, - dl_matrix3dq_t *dw, - dl_matrix3dq_t *dw_bias, - dl_matrix3dq_t *dw_prelu, - dl_matrix3dq_t *pw_linear_1, - dl_matrix3dq_t *pw_linear_2, - dl_matrix3dq_t *pw_linear_bias, - int pw_exponent, - int dw_exponent, - int pw_linear_exponent, - int stride_x, - int stride_y, - dl_padding_type padding, - dl_conv_mode mode, - int shortcut); - -dl_matrix3dq_t *dl_matrix3dqq_mobilefaceblock_prelu_split_4_4(dl_matrix3dq_t *in, - dl_matrix3dq_t *pw_1, - dl_matrix3dq_t *pw_2, - dl_matrix3dq_t *pw_3, - dl_matrix3dq_t *pw_4, - dl_matrix3dq_t *pw_bias, - dl_matrix3dq_t *pw_prelu, - dl_matrix3dq_t *dw, - dl_matrix3dq_t *dw_bias, - dl_matrix3dq_t *dw_prelu, - dl_matrix3dq_t *pw_linear_1, - dl_matrix3dq_t *pw_linear_2, - dl_matrix3dq_t *pw_linear_3, - dl_matrix3dq_t *pw_linear_4, - dl_matrix3dq_t *pw_linear_bias, - int pw_exponent, - int dw_exponent, - int pw_linear_exponent, - int stride_x, - int stride_y, - dl_padding_type padding, - dl_conv_mode mode, - int shortcut); - -dl_matrix3dq_t *dl_matrix3dqq_mobilefaceblock_prelu_split_1_2(dl_matrix3dq_t *in, - dl_matrix3dq_t *pw, - dl_matrix3dq_t *pw_bias, - dl_matrix3dq_t *pw_prelu, - dl_matrix3dq_t *dw, - dl_matrix3dq_t *dw_bias, - dl_matrix3dq_t *dw_prelu, - dl_matrix3dq_t *pw_linear_1, - dl_matrix3dq_t *pw_linear_2, - dl_matrix3dq_t *pw_linear_bias, - int pw_exponent, - int dw_exponent, - int pw_linear_exponent, - int stride_x, - int stride_y, - dl_padding_type padding, - dl_conv_mode mode, - int shortcut); -/**@}*/ - -// -// blazeblock -// - -/** - * @brief Do blazeblock process, the process sequence is depthwise->bn->1x1 pointwise->bn->shortcut->relu - * - * @param in Input matrix, size (1, w, h, c) - * @param dw1_kernel Depthwise filter, size (1, k, k, c) - * @param dw1_bias Depthwise bias, size (1, 1, 1, c) - * @param pw1_kernel Pointwise 1x1 filter, size (n, 1, 1, c) - * @param pw1_bias Pointwise bias, size (1, 1, 1, n) - * @param config blazeblock configuration - * @param name Layer name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_blazeblock(dl_matrix3dq_t *in, - dl_matrix3dq_t *dw1_kernel, - dl_matrix3dq_t *dw1_bias, - dl_matrix3dq_t *pw1_kernel, - dl_matrix3dq_t *pw1_bias, - dl_matrix3dq_blazeblock_config_t config, - char *name); - -/** - * @brief Do double blazeblock process, the process sequence is depthwise->bn->1x1 pointwise->bn->relu->depthwise->bn->1x1 pointwise->bn->shortcut->relu - * - * @param in Input matrix, size (1, w, h, c) - * @param dw1_kernel Depthwise filter, size (1, k, k, c) - * @param dw1_bias Depthwise bias, size (1, 1, 1, c) - * @param pw1_kernel Pointwise 1x1 filter, size (n1, 1, 1, c) - * @param pw1_bias Pointwise bias, size (1, 1, 1, n1) - * @param dw2_kernel Depthwise filter, size (1, k, k, n1) - * @param dw2_bias Depthwise bias, size (1, 1, 1, n1) - * @param pw2_kernel Pointwise 1x1 filter, size (n2, 1, 1, n1) - * @param pw2_bias Pointwise bias, size (1, 1, 1, n2) - * @param config blazeblock configuration - * @param name Layer name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_double_blazeblock(dl_matrix3dq_t *in, - dl_matrix3dq_t *dw1_kernel, - dl_matrix3dq_t *dw1_bias, - dl_matrix3dq_t *pw1_kernel, - dl_matrix3dq_t *pw1_bias, - dl_matrix3dq_t *dw2_kernel, - dl_matrix3dq_t *dw2_bias, - dl_matrix3dq_t *pw2_kernel, - dl_matrix3dq_t *pw2_bias, - dl_matrix3dq_blazeblock_config_t config, - char *name); -// -// Mobilenet -// - -/** - * @brief Do mobilenet process, the process sequence is 1x1 dilated->prelu->3x3 depthwise->prelu->1x1 compress->bias - * - * @param in Input matrix, size (1, w, h, c) - * @param dilate Pointwise 1x1 filter, size (n1, 1, 1, c) - * @param dilate_prelu Pointwise prelu, size (1, 1, 1, n1) - * @param depthwise Depthwise 3x3 filter, size (1, 3, 3, n1) - * @param depthwise_prelu Depthwise prelu, size (1, 1, 1, n1) - * @param compress Pointwise 1x1 filter, size (n2, 1, 1, n1) - * @param bias Pointwise bias, size (1, 1, 1, n2) - * @param config Mobilenet configuration - * @param name Block name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_mobilenet(dl_matrix3dq_t *in, - dl_matrix3dq_t *dilate, - dl_matrix3dq_t *dilate_prelu, - dl_matrix3dq_t *depthwise, - dl_matrix3dq_t *depth_prelu, - dl_matrix3dq_t *compress, - dl_matrix3dq_t *bias, - dl_matrix3dq_mobilenet_config_t config, - char *name); - -/** - * @brief Do mobilenet process, the process sequence is 1x1 dilated->prelu->3x3 depthwise->prelu->1x1 compress->bias - * - * @param in Input matrix, 8-bit fixed point, size (1, w, h, c) - * @param dilate Pointwise 1x1 filter, size (n1, 1, 1, c) - * @param dilate_prelu Pointwise prelu, size (1, 1, 1, n1) - * @param depthwise Depthwise 3x3 filter, size (1, 3, 3, n1) - * @param depthwise_prelu Depthwise prelu, size (1, 1, 1, n1) - * @param compress Pointwise 1x1 filter, size (n2, 1, 1, n1) - * @param bias Pointwise bias, size (1, 1, 1, n2) - * @param config Mobilenet configuration - * @param name Block name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3duq_mobilenet(dl_matrix3du_t *in, - dl_matrix3dq_t *dilate, - dl_matrix3dq_t *dilate_prelu, - dl_matrix3dq_t *depthwise, - dl_matrix3dq_t *depth_prelu, - dl_matrix3dq_t *compress, - dl_matrix3dq_t *bias, - dl_matrix3dq_mobilenet_config_t config, - char *name); - -// -// Padding -// - -/**@{*/ -/** - * @brief This family of functions do a padding operation before a convlution - * - * @param padded_input the padded result pointer - * @param output_height the output height pointer - * @param output_width the output width pointer - * @param input Input matrix, size (1, w, h, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param kernel_size Kernel size of the next convlution - * @param padding_type Padding type - * @return dl_error_type Return DL_SUCCESS if padding successfully, else return DL_FAIL - */ -dl_error_type dl_matrix3dqq_padding(dl_matrix3dq_t **padded_input, - int *output_height, - int *output_width, - dl_matrix3dq_t *input, - int stride_x, - int stride_y, - int kernel_size, - dl_padding_type padding_type); - -dl_error_type dl_matrix3duq_padding(dl_matrix3du_t **padded_input, - int *output_height, - int *output_width, - dl_matrix3du_t *input, - int stride_x, - int stride_y, - int kernel_size, - dl_padding_type padding_type); -/**@}*/ - -// -// Upsample -// -/** - * @brief Upsample a feature map to twice the size - * - * @param in Input matrix, size (1, w, h, c) - * @param upsample upsample type - * @return dl_matrix3dq_t* Resulting matrix, size (1, 2*w, 2*h, c) - */ -dl_matrix3dq_t *dl_matrix3dqq_upsample_2x(dl_matrix3dq_t *in, - dl_upsample_type upsample); - -// -// Pooling -// -/** - * @brief Calculate average value of a feature map - * - * @param in Input matrix, size (1, w, h, c) - * @return dl_matrix3dq_t* Resulting matrix, size (1, 1, 1, c) - */ -dl_matrix3dq_t *dl_matrix3dq_global_pool(dl_matrix3dq_t *in); - -/** - * @brief Calculate pooling layer of a feature map - * - * @param in Input matrix, size (1, w, h, c) - * @param f_w Window width - * @param f_h Window height - * @param stride_x Stride in horizontal direction - * @param stride_y Stride in vertical direction - * @param padding Padding type: PADDING_VALID and PADDING_SAME - * @param pooling_type Pooling type: DL_POOLING_MAX and POOLING_AVG - * @return dl_matrix3dq_t* Resulting matrix, size (1, w', h', c) - */ -dl_matrix3dq_t *dl_matrix3dq_pooling(dl_matrix3dq_t *in, - int f_w, - int f_h, - int stride_x, - int stride_y, - dl_padding_type padding, - dl_pooling_type pooling_type); diff --git a/tools/sdk/esp32/include/esp-face/lib/include/frmn.h b/tools/sdk/esp32/include/esp-face/lib/include/frmn.h deleted file mode 100644 index c1f08a0fadc..00000000000 --- a/tools/sdk/esp32/include/esp-face/lib/include/frmn.h +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once - -#if __cplusplus -extern "C" -{ -#endif - -#include "dl_lib_matrix3d.h" -#include "dl_lib_matrix3dq.h" - - /** - * @brief Forward the face recognition process with frmn model. Calculate in float. - * - * @param in Image matrix, rgb888 format, size is 56x56, normalized - * @return dl_matrix3d_t* Face ID feature vector, size is 512 - */ - dl_matrix3d_t *frmn(dl_matrix3d_t *in); - - /**@{*/ - /** - * @brief Forward the face recognition process with specified model. Calculate in quantization. - * - * @param in Image matrix, rgb888 format, size is 56x56, normalized - * @param mode 0: C implement; 1: handwrite xtensa instruction implement - * @return Face ID feature vector, size is 512 - */ - dl_matrix3dq_t *frmn_q(dl_matrix3dq_t *in, dl_conv_mode mode); - - dl_matrix3dq_t *frmn2p_q(dl_matrix3dq_t *in, dl_conv_mode mode); - - dl_matrix3dq_t *mfn56_42m_q(dl_matrix3dq_t *in, dl_conv_mode mode); - - dl_matrix3dq_t *mfn56_72m_q(dl_matrix3dq_t *in, dl_conv_mode mode); - - dl_matrix3dq_t *mfn56_112m_q(dl_matrix3dq_t *in, dl_conv_mode mode); - - dl_matrix3dq_t *mfn56_156m_q(dl_matrix3dq_t *in, dl_conv_mode mode); - - /**@}*/ - -#if __cplusplus -} -#endif diff --git a/tools/sdk/esp32/include/esp-face/lib/include/hd_model.h b/tools/sdk/esp32/include/esp-face/lib/include/hd_model.h deleted file mode 100644 index 0bc28d70ddc..00000000000 --- a/tools/sdk/esp32/include/esp-face/lib/include/hd_model.h +++ /dev/null @@ -1,66 +0,0 @@ -#pragma once - -#if __cplusplus -extern "C" -{ -#endif - -#include "dl_lib_matrix3d.h" -#include "dl_lib_matrix3dq.h" - - typedef struct - { - int num; /*!< The total number of the boxes */ - dl_matrix3d_t *cls; /*!< The class feature map corresponding to the box. size: (height, width, anchor_num, 1) */ - dl_matrix3d_t *score; /*!< The confidence score feature map of the class corresponding to the box. size: (height, width, anchor_num, 1) */ - dl_matrix3d_t *boxes; /*!< (x, y, w, h) of the boxes. x and y are the center coordinates. size:(height, width, anchor_num, 4) */ - } detection_result_t; - - /** - * @brief Forward the hand detection process with hd_nano1 model. Calculate in quantization. - * - * @param in A normalized image matrix in rgb888 format, its width and height must be integer multiples of 16. - * @param mode 0: C implement; 1: handwrite xtensa instruction implement - * @return detection_result_t** Detection results - */ - detection_result_t **hd_nano1_q(dl_matrix3dq_t *in, dl_conv_mode mode); - - /** - * @brief Forward the hand detection process with hd_lite1 model. Calculate in quantization. - * - * @param in A normalized image matrix in rgb888 format, its width and height must be integer multiples of 32. - * @param mode 0: C implement; 1: handwrite xtensa instruction implement. - * @return detection_result_t** Detection results. - */ - detection_result_t **hd_lite1_q(dl_matrix3dq_t *in, dl_conv_mode mode); - - /** - * @brief Free the single detection result. - * - * @param m The single detection result. - */ - void detection_result_free(detection_result_t *m); - - /** - * @brief Free the detection result group from different feature map. - * - * @param m The detection result group - * @param length The number of the detection results - */ - void detection_results_free(detection_result_t **m, int length); - - /** - * @brief Test the result of hand detection model. - * - */ - void hd_test(); - - /** - * @brief Test the forward time of hand detection model. - * - */ - void hd_time_test(); - -#if __cplusplus -} -#endif diff --git a/tools/sdk/esp32/include/esp-face/lib/include/hp_model.h b/tools/sdk/esp32/include/esp-face/lib/include/hp_model.h deleted file mode 100644 index ad9080c5473..00000000000 --- a/tools/sdk/esp32/include/esp-face/lib/include/hp_model.h +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once - -#if __cplusplus -extern "C" -{ -#endif - -#include "dl_lib_matrix3d.h" -#include "dl_lib_matrix3dq.h" - - /** - * @brief Forward the hand pose estimation process with hp_nano1_ls16 model. Calculate in quantization. - * - * @param in A normalized image matrix in rgb888 format, its size is (1, 128, 128, 3). - * @param mode 0: C implement; 1: handwrite xtensa instruction implement - * @return dl_matrix3d_t* The resulting hand joint point coordinates, the size is (1, 1, 21, 2) - */ - dl_matrix3d_t *hp_nano1_ls16_q(dl_matrix3dq_t *in, dl_conv_mode mode); - - /** - * @brief Forward the hand pose estimation process with hp_lite1 model. Calculate in quantization. - * - * @param in A normalized image matrix in rgb888 format, its size is (1, 128, 128, 3). - * @param mode 0: C implement; 1: handwrite xtensa instruction implement - * @return dl_matrix3d_t* The resulting hand joint point coordinates, the size is (1, 1, 21, 2) - */ - dl_matrix3d_t *hp_lite1_q(dl_matrix3dq_t *in, dl_conv_mode mode); - - /** - * @brief Test the result of hand pose estimation model. - * - */ - void hp_test(); - - /** - * @brief Test the forward time of hand pose estimation model. - * - */ - void hp_time_test(); - -#if __cplusplus -} -#endif \ No newline at end of file diff --git a/tools/sdk/esp32/include/esp-face/lib/include/lssh.h b/tools/sdk/esp32/include/esp-face/lib/include/lssh.h deleted file mode 100644 index 69c661c58e5..00000000000 --- a/tools/sdk/esp32/include/esp-face/lib/include/lssh.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * ESPRESSIF MIT License - * - * Copyright (c) 2018 - * - * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, - * it is 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. - * - */ -#pragma once - -#ifdef __cplusplus -extern "C" -{ -#endif -#include "dl_lib_matrix3d.h" -#include "dl_lib_matrix3dq.h" -#include "freertos/FreeRTOS.h" - - typedef struct - { - int resized_height; - int resized_width; - fptp_t y_resize_scale; - fptp_t x_resize_scale; - int enabled_top_k; - fptp_t score_threshold; - fptp_t nms_threshold; - - dl_conv_mode mode; - } lssh_config_t; - - typedef struct - { - int *anchor_size; - int stride; - int boundary; - } lssh_module_config_t; - - typedef struct - { - lssh_module_config_t *module_config; - int number; - } lssh_modules_config_t; - - typedef struct - { - dl_matrix3d_t *category; - dl_matrix3d_t *box_offset; - dl_matrix3d_t *landmark_offset; - } lssh_module_result_t; - - /** - * @brief - * - * @param value - */ - void lssh_module_result_free(lssh_module_result_t value); - - /** - * @brief - * - * @param values - * @param length - */ - void lssh_module_results_free(lssh_module_result_t *values, int length); - - ///////////////////////// - //////sparse_mn_5_q////// - ///////////////////////// - extern lssh_modules_config_t sparse_mn_5_modules_config; - lssh_module_result_t *sparse_mn_5_q_without_landmark(dl_matrix3du_t *image, bool free_image, int enabled_top_k, dl_conv_mode mode); - lssh_module_result_t *sparse_mn_5_q_with_landmark(dl_matrix3du_t *image, bool free_image, int enabled_top_k, dl_conv_mode mode); - -#ifdef __cplusplus -} -#endif diff --git a/tools/sdk/esp32/include/esp-face/lib/include/mtmn.h b/tools/sdk/esp32/include/esp-face/lib/include/mtmn.h deleted file mode 100644 index 609a82ea488..00000000000 --- a/tools/sdk/esp32/include/esp-face/lib/include/mtmn.h +++ /dev/null @@ -1,142 +0,0 @@ -/* - * ESPRESSIF MIT License - * - * Copyright (c) 2018 - * - * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, - * it is 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. - * - */ -#pragma once - -#ifdef __cplusplus -extern "C" -{ -#endif -#include "dl_lib_matrix3d.h" -#include "dl_lib_matrix3dq.h" - - /** - * Detection results with MTMN. - * - */ - typedef struct - { - dl_matrix3d_t *category; /*!< Classification result after softmax, channel is 2 */ - dl_matrix3d_t *offset; /*!< Bounding box offset of 2 points: top-left and bottom-right, channel is 4 */ - dl_matrix3d_t *landmark; /*!< Offsets of 5 landmarks: - * - Left eye - * - Mouth leftside - * - Nose - * - Right eye - * - Mouth rightside - * - * channel is 10 - * */ - } mtmn_net_t; - - - /** - * @brief Free a mtmn_net_t - * - * @param p A mtmn_net_t pointer - * - */ - - void mtmn_net_t_free(mtmn_net_t *p); - - /** - * @brief Forward the pnet process, coarse detection. Calculate in float. - * - * @param in Image matrix, rgb888 format, size is 320x240 - * @return Scores for every pixel, and box offset with respect. - */ - mtmn_net_t *pnet_lite_f(dl_matrix3du_t *in); - - /** - * @brief Forward the rnet process, fine determine the boxes from pnet. Calculate in float. - * - * @param in Image matrix, rgb888 format - * @param threshold Score threshold to detect human face - * @return Scores for every box, and box offset with respect. - */ - mtmn_net_t *rnet_lite_f_with_score_verify(dl_matrix3du_t *in, float threshold); - - /** - * @brief Forward the onet process, fine determine the boxes from rnet. Calculate in float. - * - * @param in Image matrix, rgb888 format - * @param threshold Score threshold to detect human face - * @return Scores for every box, box offset, and landmark with respect. - */ - mtmn_net_t *onet_lite_f_with_score_verify(dl_matrix3du_t *in, float threshold); - - /** - * @brief Forward the pnet process, coarse detection. Calculate in quantization. - * - * @param in Image matrix, rgb888 format, size is 320x240 - * @return Scores for every pixel, and box offset with respect. - */ - mtmn_net_t *pnet_lite_q(dl_matrix3du_t *in, dl_conv_mode mode); - - /** - * @brief Forward the rnet process, fine determine the boxes from pnet. Calculate in quantization. - * - * @param in Image matrix, rgb888 format - * @param threshold Score threshold to detect human face - * @return Scores for every box, and box offset with respect. - */ - mtmn_net_t *rnet_lite_q_with_score_verify(dl_matrix3du_t *in, float threshold, dl_conv_mode mode); - - /** - * @brief Forward the onet process, fine determine the boxes from rnet. Calculate in quantization. - * - * @param in Image matrix, rgb888 format - * @param threshold Score threshold to detect human face - * @return Scores for every box, box offset, and landmark with respect. - */ - mtmn_net_t *onet_lite_q_with_score_verify(dl_matrix3du_t *in, float threshold, dl_conv_mode mode); - - /** - * @brief Forward the pnet process, coarse detection. Calculate in quantization. - * - * @param in Image matrix, rgb888 format, size is 320x240 - * @return Scores for every pixel, and box offset with respect. - */ - mtmn_net_t *pnet_heavy_q(dl_matrix3du_t *in, dl_conv_mode mode); - - /** - * @brief Forward the rnet process, fine determine the boxes from pnet. Calculate in quantization. - * - * @param in Image matrix, rgb888 format - * @param threshold Score threshold to detect human face - * @return Scores for every box, and box offset with respect. - */ - mtmn_net_t *rnet_heavy_q_with_score_verify(dl_matrix3du_t *in, float threshold, dl_conv_mode mode); - - /** - * @brief Forward the onet process, fine determine the boxes from rnet. Calculate in quantization. - * - * @param in Image matrix, rgb888 format - * @param threshold Score threshold to detect human face - * @return Scores for every box, box offset, and landmark with respect. - */ - mtmn_net_t *onet_heavy_q_with_score_verify(dl_matrix3du_t *in, float threshold, dl_conv_mode mode); - -#ifdef __cplusplus -} -#endif diff --git a/tools/sdk/esp32/include/esp-face/object_detection/include/object_detection.h b/tools/sdk/esp32/include/esp-face/object_detection/include/object_detection.h deleted file mode 100644 index 8627a24684d..00000000000 --- a/tools/sdk/esp32/include/esp-face/object_detection/include/object_detection.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * ESPRESSIF MIT License - * - * Copyright (c) 2018 - * - * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, - * it is 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. - * - */ -#pragma once - -#if __cplusplus -extern "C" -{ -#endif - -#include "image_util.h" -#include "detection.h" -// Include models -#include "cat_face_3.h" - - /** - * @brief update detection hyperparameter - * - * @param model The detection model - * @param resize_scale The resize scale of input image - * @param score_threshold Score threshold, used to filter candidates by score - * @param nms_threshold NMS threshold, used to filter out overlapping boxes - * @param image_height Input image height - * @param image_width Input image width - */ - void update_detection_model(detection_model_t *model, fptp_t resize_scale, fptp_t score_threshold, fptp_t nms_threshold, int image_height, int image_width); - - /** - * @brief - * - * @param image The input image - * @param model A 'detection_model_t' type point of detection model - * @return box_array_t* The detection result with box and corresponding score and category - */ - box_array_t *detect_object(dl_matrix3du_t *image, detection_model_t *model); - -#if __cplusplus -} -#endif diff --git a/tools/sdk/esp32/include/esp-face/pose_estimation/include/pe_forward.h b/tools/sdk/esp32/include/esp-face/pose_estimation/include/pe_forward.h deleted file mode 100644 index 0d52b1f803e..00000000000 --- a/tools/sdk/esp32/include/esp-face/pose_estimation/include/pe_forward.h +++ /dev/null @@ -1,153 +0,0 @@ -/* - * ESPRESSIF MIT License - * - * Copyright (c) 2018 - * - * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, - * it is 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. - * - */ -#pragma once - -#if __cplusplus -extern "C" -{ -#endif - -#include "image_util.h" -#include "dl_lib_matrix3d.h" -#include "hd_model.h" -#include "hp_model.h" - -#define INPUT_EXPONENT -10 -#define SCORE_THRESHOLD 0.5 -#define NMS_THRESHOLD 0.45 - -#if CONFIG_HD_LITE1 - #define HP_TARGET_SIZE 128 -#else - #define HP_TARGET_SIZE 128 -#endif - - typedef struct - { - int target_size; /*!< The input size of hand detection network */ - fptp_t score_threshold; /*!< score threshold, used to filter candidates by score */ - fptp_t nms_threshold; /*!< nms threshold, used to filter out overlapping boxes */ - } hd_config_t; - - /** - * @brief Get the default hand detection network configuration - * - * @return hd_config_t The default configuration - */ - static inline hd_config_t hd_init_config() - { - hd_config_t hd_config; - hd_config.target_size = 96; - hd_config.score_threshold = SCORE_THRESHOLD; - hd_config.nms_threshold = NMS_THRESHOLD; - return hd_config; - } - - typedef struct tag_od_box_list - { - fptp_t *score; /*!< The confidence score of the class corresponding to the box */ - qtp_t *cls; /*!< The class corresponding to the box */ - box_t *box; /*!< (x1, y1, x2, y2) of the boxes */ - int len; /*!< The number of the boxes */ - } od_box_array_t; - - typedef struct tag_od_image_box - { - struct tag_od_image_box *next; /*!< Next od_image_box_t */ - fptp_t score; /*!< The confidence score of the class corresponding to the box */ - qtp_t cls; /*!< The class corresponding to the box */ - box_t box; /*!< (x1, y1, x2, y2) of the boxes */ - } od_image_box_t; - - typedef struct tag_od_image_list - { - od_image_box_t *head; /*!< The current head of the od_image_list */ - od_image_box_t *origin_head; /*!< The original head of the od_image_list */ - int len; /*!< Length of the od_image_list */ - } od_image_list_t; - - /** - * @brief Sort the resulting box lists by their confidence score. - * - * @param image_sorted_list The sorted box list. - * @param insert_list The box list that have not been sorted. - */ - void od_image_sort_insert_by_score(od_image_list_t *image_sorted_list, const od_image_list_t *insert_list); - - /** - * @brief Filter out the resulting boxes whose confidence score is lower than the threshold and convert the boxes to the actual boxes on the original image.((x, y, w, h) -> (x1, y1, x2, y2)) - * - * @param score Confidence score of the boxes. - * @param cls Class of the boxes. - * @param boxes (x, y, w, h) of the boxes. x and y are the center coordinates. - * @param height Height of the detection output feature map. - * @param width Width of the detection output feature map. - * @param anchor_number Anchor number of the detection output feature map. - * @param score_threshold Threshold of the confidence score. - * @param resize_scale Resize scale: target_size/orignal_size. - * @param padding_w Width padding in preporcess. - * @param padding_h Height padding in preporcess. - * @return od_image_list_t* Resulting valid boxes. - */ - od_image_list_t *od_image_get_valid_boxes(fptp_t *score, - fptp_t *cls, - fptp_t *boxes, - int height, - int width, - int anchor_number, - fptp_t score_threshold, - fptp_t resize_scale, - int padding_w, - int padding_h); - - /** - * @brief Run NMS algorithm - * - * @param image_list The input boxes list - * @param nms_threshold NMS threshold - */ - void od_image_nms_process(od_image_list_t *image_list, fptp_t nms_threshold); - - /** - * @brief Do hand detection, return box infomation. - * - * @param image Image matrix, rgb888 format - * @param hd_config Configuration of hand detection - * @return od_box_array_t* A list of boxes, score and class. - */ - od_box_array_t *hand_detection_forward(dl_matrix3du_t *image, hd_config_t hd_config); - - /** - * @brief Do hand pose estimation, return 21 landmarks of each hand. - * - * @param image Image matrix, rgb888 format - * @param od_boxes The output of the hand detection network - * @param target_size The input size of hand pose estimation network - * @return dl_matrix3d_t* The coordinates of 21 landmarks on the input image for each hand, size (n, 1, 21, 2) - */ - dl_matrix3d_t *handpose_estimation_forward(dl_matrix3du_t *image, od_box_array_t *od_boxes, int target_size); - -#if __cplusplus -} -#endif diff --git a/tools/sdk/esp32/include/esp-tls/esp_tls.h b/tools/sdk/esp32/include/esp-tls/esp_tls.h index 9330f9dd699..588f70d83f9 100644 --- a/tools/sdk/esp32/include/esp-tls/esp_tls.h +++ b/tools/sdk/esp32/include/esp-tls/esp_tls.h @@ -20,6 +20,9 @@ #include "mbedtls/ctr_drbg.h" #include "mbedtls/error.h" #include "mbedtls/certs.h" +#ifdef CONFIG_ESP_TLS_SERVER_SESSION_TICKETS +#include "mbedtls/ssl_ticket.h" +#endif #elif CONFIG_ESP_TLS_USING_WOLFSSL #include "wolfssl/wolfcrypt/settings.h" #include "wolfssl/ssl.h" @@ -54,6 +57,15 @@ typedef struct psk_key_hint { const char* hint; /*!< hint in PSK authentication mode in string format */ } psk_hint_key_t; +/** + * @brief esp-tls client session ticket ctx + */ +#ifdef CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS +typedef struct esp_tls_client_session { + mbedtls_ssl_session saved_session; +} esp_tls_client_session_t; +#endif /* CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS */ + /** * @brief Keep alive parameters structure */ @@ -168,9 +180,27 @@ typedef struct esp_tls_cfg { directly with esp_tls_plain_tcp_connect() API */ struct ifreq *if_name; /*!< The name of interface for data to go through. Use the default interface without setting */ + +#ifdef CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS + esp_tls_client_session_t *client_session; /*! Pointer for the client session ticket context. */ +#endif /* CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS */ } esp_tls_cfg_t; #ifdef CONFIG_ESP_TLS_SERVER +#if defined(CONFIG_ESP_TLS_SERVER_SESSION_TICKETS) +/** + * @brief Data structures necessary to support TLS session tickets according to RFC5077 + */ +typedef struct esp_tls_server_session_ticket_ctx { + mbedtls_entropy_context entropy; /*!< mbedTLS entropy context structure */ + + mbedtls_ctr_drbg_context ctr_drbg; /*!< mbedTLS ctr drbg context structure. + CTR_DRBG is deterministic random + bit generation based on AES-256 */ + mbedtls_ssl_ticket_context ticket_ctx; /*!< Session ticket generation context */ +} esp_tls_server_session_ticket_ctx_t; +#endif + typedef struct esp_tls_cfg_server { const char **alpn_protos; /*!< Application protocols required for HTTP2. If HTTP2/ALPN support is required, a list @@ -222,7 +252,39 @@ typedef struct esp_tls_cfg_server { unsigned int serverkey_password_len; /*!< String length of the password pointed to by serverkey_password */ +#if defined(CONFIG_ESP_TLS_SERVER_SESSION_TICKETS) + esp_tls_server_session_ticket_ctx_t * ticket_ctx; /*!< Session ticket generation context. + You have to call esp_tls_cfg_server_session_tickets_init + to use it. + Call esp_tls_cfg_server_session_tickets_free + to free the data associated with this context. */ +#endif } esp_tls_cfg_server_t; + +/** + * @brief Initialize the server side TLS session ticket context + * + * This function initializes the server side tls session ticket context + * which holds all necessary data structures to enable tls session tickets + * according to RFC5077. + * Use esp_tls_cfg_server_session_tickets_free to free the data. + * + * @param[in] cfg server configuration as esp_tls_cfg_server_t + * @return + * ESP_OK if setup succeeded + * ESP_ERR_INVALID_ARG if context is already initialized + * ESP_ERR_NO_MEM if memory allocation failed + * ESP_ERR_NOT_SUPPORTED if session tickets are not available due to build configuration + * ESP_FAIL if setup failed + */ +esp_err_t esp_tls_cfg_server_session_tickets_init(esp_tls_cfg_server_t *cfg); + +/** + * @brief Free the server side TLS session ticket context + * + * @param cfg server configuration as esp_tls_cfg_server_t + */ +void esp_tls_cfg_server_session_tickets_free(esp_tls_cfg_server_t *cfg); #endif /* ! CONFIG_ESP_TLS_SERVER */ /** @@ -404,6 +466,10 @@ int esp_tls_conn_http_new_async(const char *url, const esp_tls_cfg_t *cfg, esp_t * of bytes actually written to the TLS/SSL connection. * - <0 if write operation was not successful, because either an * error occured or an action must be taken by the calling process. + * - ESP_TLS_ERR_SSL_WANT_READ/ + * ESP_TLS_ERR_SSL_WANT_WRITE. + * if the handshake is incomplete and waiting for data to be available for reading. + * In this case this functions needs to be called again when the underlying transport is ready for operation. */ static inline ssize_t esp_tls_conn_write(esp_tls_t *tls, const void *data, size_t datalen) { @@ -609,6 +675,20 @@ void esp_tls_server_session_delete(esp_tls_t *tls); */ esp_err_t esp_tls_plain_tcp_connect(const char *host, int hostlen, int port, const esp_tls_cfg_t *cfg, esp_tls_error_handle_t error_handle, int *sockfd); +#ifdef CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS +/** + * @brief Obtain the client session ticket + * + * This function should be called when the TLS connection is already established. + * This can be passed again in the esp_tls_cfg_t structure, to appropriate tls session create (e.g. esp_tls_conn_http_new) API for session resumption. + * + * @param[in] esp_tls context as esp_tls_t + * @return + * Pointer to the saved client session. + * NULL on Failure + */ +esp_tls_client_session_t *esp_tls_get_client_session(esp_tls_t *tls); +#endif /* CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS */ #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32/include/esp-tls/esp_tls_errors.h b/tools/sdk/esp32/include/esp-tls/esp_tls_errors.h index 5dfe74791c5..ad104895aaf 100644 --- a/tools/sdk/esp32/include/esp-tls/esp_tls_errors.h +++ b/tools/sdk/esp32/include/esp-tls/esp_tls_errors.h @@ -14,35 +14,42 @@ extern "C" { #endif #define ESP_ERR_ESP_TLS_BASE 0x8000 /*!< Starting number of ESP-TLS error codes */ + +/* generic esp-tls error codes */ #define ESP_ERR_ESP_TLS_CANNOT_RESOLVE_HOSTNAME (ESP_ERR_ESP_TLS_BASE + 0x01) /*!< Error if hostname couldn't be resolved upon tls connection */ #define ESP_ERR_ESP_TLS_CANNOT_CREATE_SOCKET (ESP_ERR_ESP_TLS_BASE + 0x02) /*!< Failed to create socket */ #define ESP_ERR_ESP_TLS_UNSUPPORTED_PROTOCOL_FAMILY (ESP_ERR_ESP_TLS_BASE + 0x03) /*!< Unsupported protocol family */ #define ESP_ERR_ESP_TLS_FAILED_CONNECT_TO_HOST (ESP_ERR_ESP_TLS_BASE + 0x04) /*!< Failed to connect to host */ #define ESP_ERR_ESP_TLS_SOCKET_SETOPT_FAILED (ESP_ERR_ESP_TLS_BASE + 0x05) /*!< failed to set/get socket option */ -#define ESP_ERR_MBEDTLS_CERT_PARTLY_OK (ESP_ERR_ESP_TLS_BASE + 0x06) /*!< mbedtls parse certificates was partly successful */ -#define ESP_ERR_MBEDTLS_CTR_DRBG_SEED_FAILED (ESP_ERR_ESP_TLS_BASE + 0x07) /*!< mbedtls api returned error */ -#define ESP_ERR_MBEDTLS_SSL_SET_HOSTNAME_FAILED (ESP_ERR_ESP_TLS_BASE + 0x08) /*!< mbedtls api returned error */ -#define ESP_ERR_MBEDTLS_SSL_CONFIG_DEFAULTS_FAILED (ESP_ERR_ESP_TLS_BASE + 0x09) /*!< mbedtls api returned error */ -#define ESP_ERR_MBEDTLS_SSL_CONF_ALPN_PROTOCOLS_FAILED (ESP_ERR_ESP_TLS_BASE + 0x0A) /*!< mbedtls api returned error */ -#define ESP_ERR_MBEDTLS_X509_CRT_PARSE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x0B) /*!< mbedtls api returned error */ -#define ESP_ERR_MBEDTLS_SSL_CONF_OWN_CERT_FAILED (ESP_ERR_ESP_TLS_BASE + 0x0C) /*!< mbedtls api returned error */ -#define ESP_ERR_MBEDTLS_SSL_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x0D) /*!< mbedtls api returned error */ -#define ESP_ERR_MBEDTLS_SSL_WRITE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x0E) /*!< mbedtls api returned error */ -#define ESP_ERR_MBEDTLS_PK_PARSE_KEY_FAILED (ESP_ERR_ESP_TLS_BASE + 0x0F) /*!< mbedtls api returned failed */ -#define ESP_ERR_MBEDTLS_SSL_HANDSHAKE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x10) /*!< mbedtls api returned failed */ -#define ESP_ERR_MBEDTLS_SSL_CONF_PSK_FAILED (ESP_ERR_ESP_TLS_BASE + 0x11) /*!< mbedtls api returned failed */ -#define ESP_ERR_ESP_TLS_CONNECTION_TIMEOUT (ESP_ERR_ESP_TLS_BASE + 0x12) /*!< new connection in esp_tls_low_level_conn connection timeouted */ -#define ESP_ERR_WOLFSSL_SSL_SET_HOSTNAME_FAILED (ESP_ERR_ESP_TLS_BASE + 0x13) /*!< wolfSSL api returned error */ -#define ESP_ERR_WOLFSSL_SSL_CONF_ALPN_PROTOCOLS_FAILED (ESP_ERR_ESP_TLS_BASE + 0x14) /*!< wolfSSL api returned error */ -#define ESP_ERR_WOLFSSL_CERT_VERIFY_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x15) /*!< wolfSSL api returned error */ -#define ESP_ERR_WOLFSSL_KEY_VERIFY_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x16) /*!< wolfSSL api returned error */ -#define ESP_ERR_WOLFSSL_SSL_HANDSHAKE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x17) /*!< wolfSSL api returned failed */ -#define ESP_ERR_WOLFSSL_CTX_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x18) /*!< wolfSSL api returned failed */ -#define ESP_ERR_WOLFSSL_SSL_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x19) /*!< wolfSSL api returned failed */ -#define ESP_ERR_WOLFSSL_SSL_WRITE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x1A) /*!< wolfSSL api returned failed */ +#define ESP_ERR_ESP_TLS_CONNECTION_TIMEOUT (ESP_ERR_ESP_TLS_BASE + 0x06) /*!< new connection in esp_tls_low_level_conn connection timeouted */ +#define ESP_ERR_ESP_TLS_SE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x07) /*< esp-tls use Secure Element returned failed */ +#define ESP_ERR_ESP_TLS_TCP_CLOSED_FIN (ESP_ERR_ESP_TLS_BASE + 0x08) /*< esp-tls's TPC transport connection has benn closed (in a clean way) */ + +/* mbedtls specific error codes */ +#define ESP_ERR_MBEDTLS_CERT_PARTLY_OK (ESP_ERR_ESP_TLS_BASE + 0x10) /*!< mbedtls parse certificates was partly successful */ +#define ESP_ERR_MBEDTLS_CTR_DRBG_SEED_FAILED (ESP_ERR_ESP_TLS_BASE + 0x11) /*!< mbedtls api returned error */ +#define ESP_ERR_MBEDTLS_SSL_SET_HOSTNAME_FAILED (ESP_ERR_ESP_TLS_BASE + 0x12) /*!< mbedtls api returned error */ +#define ESP_ERR_MBEDTLS_SSL_CONFIG_DEFAULTS_FAILED (ESP_ERR_ESP_TLS_BASE + 0x13) /*!< mbedtls api returned error */ +#define ESP_ERR_MBEDTLS_SSL_CONF_ALPN_PROTOCOLS_FAILED (ESP_ERR_ESP_TLS_BASE + 0x14) /*!< mbedtls api returned error */ +#define ESP_ERR_MBEDTLS_X509_CRT_PARSE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x15) /*!< mbedtls api returned error */ +#define ESP_ERR_MBEDTLS_SSL_CONF_OWN_CERT_FAILED (ESP_ERR_ESP_TLS_BASE + 0x16) /*!< mbedtls api returned error */ +#define ESP_ERR_MBEDTLS_SSL_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x17) /*!< mbedtls api returned error */ +#define ESP_ERR_MBEDTLS_SSL_WRITE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x18) /*!< mbedtls api returned error */ +#define ESP_ERR_MBEDTLS_PK_PARSE_KEY_FAILED (ESP_ERR_ESP_TLS_BASE + 0x19) /*!< mbedtls api returned failed */ +#define ESP_ERR_MBEDTLS_SSL_HANDSHAKE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x1A) /*!< mbedtls api returned failed */ +#define ESP_ERR_MBEDTLS_SSL_CONF_PSK_FAILED (ESP_ERR_ESP_TLS_BASE + 0x1B) /*!< mbedtls api returned failed */ +#define ESP_ERR_MBEDTLS_SSL_TICKET_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x1C) /*!< mbedtls api returned failed */ + +/* wolfssl specific error codes */ +#define ESP_ERR_WOLFSSL_SSL_SET_HOSTNAME_FAILED (ESP_ERR_ESP_TLS_BASE + 0x31) /*!< wolfSSL api returned error */ +#define ESP_ERR_WOLFSSL_SSL_CONF_ALPN_PROTOCOLS_FAILED (ESP_ERR_ESP_TLS_BASE + 0x32) /*!< wolfSSL api returned error */ +#define ESP_ERR_WOLFSSL_CERT_VERIFY_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x33) /*!< wolfSSL api returned error */ +#define ESP_ERR_WOLFSSL_KEY_VERIFY_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x34) /*!< wolfSSL api returned error */ +#define ESP_ERR_WOLFSSL_SSL_HANDSHAKE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x35) /*!< wolfSSL api returned failed */ +#define ESP_ERR_WOLFSSL_CTX_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x36) /*!< wolfSSL api returned failed */ +#define ESP_ERR_WOLFSSL_SSL_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x37) /*!< wolfSSL api returned failed */ +#define ESP_ERR_WOLFSSL_SSL_WRITE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x38) /*!< wolfSSL api returned failed */ -#define ESP_ERR_ESP_TLS_SE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x1B) /*< esp-tls use Secure Element returned failed */ -#define ESP_ERR_ESP_TLS_TCP_CLOSED_FIN (ESP_ERR_ESP_TLS_BASE + 0x1C) /*< esp-tls's TPC transport connection has benn closed (in a clean way) */ /** * Definition of errors reported from IO API (potentially non-blocking) in case of error: diff --git a/tools/sdk/esp32/include/esp-tls/private_include/esp_tls_mbedtls.h b/tools/sdk/esp32/include/esp-tls/private_include/esp_tls_mbedtls.h index 78694fc858e..c1c5d4f3288 100644 --- a/tools/sdk/esp32/include/esp-tls/private_include/esp_tls_mbedtls.h +++ b/tools/sdk/esp32/include/esp-tls/private_include/esp_tls_mbedtls.h @@ -76,6 +76,22 @@ int esp_mbedtls_server_session_create(esp_tls_cfg_server_t *cfg, int sockfd, esp * /note :- The function can only be used with mbedtls ssl library */ void esp_mbedtls_server_session_delete(esp_tls_t *tls); + +#ifdef CONFIG_ESP_TLS_SERVER_SESSION_TICKETS +/** + * Internal function to setup server side session ticket context + * + * /note :- The function can only be used with mbedtls ssl library + */ +esp_err_t esp_mbedtls_server_session_ticket_ctx_init(esp_tls_server_session_ticket_ctx_t *cfg); + +/** + * Internal function to free server side session ticket context + * + * /note :- The function can only be used with mbedtls ssl library + */ +void esp_mbedtls_server_session_ticket_ctx_free(esp_tls_server_session_ticket_ctx_t *cfg); +#endif #endif /** @@ -83,6 +99,13 @@ void esp_mbedtls_server_session_delete(esp_tls_t *tls); */ esp_err_t set_client_config(const char *hostname, size_t hostlen, esp_tls_cfg_t *cfg, esp_tls_t *tls); +#ifdef CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS +/** + * Internal Callback for mbedtls_get_client_session + */ +esp_tls_client_session_t *esp_mbedtls_get_client_session(esp_tls_t *tls); +#endif + /** * Internal Callback for mbedtls_init_global_ca_store */ diff --git a/tools/sdk/esp32/include/esp32-camera/driver/include/esp_camera.h b/tools/sdk/esp32/include/esp32-camera/driver/include/esp_camera.h index bfb729b58b6..b6047d312ae 100755 --- a/tools/sdk/esp32/include/esp32-camera/driver/include/esp_camera.h +++ b/tools/sdk/esp32/include/esp32-camera/driver/include/esp_camera.h @@ -83,6 +83,14 @@ typedef enum { CAMERA_GRAB_LATEST /*!< Except when 1 frame buffer is used, queue will always contain the last 'fb_count' frames */ } camera_grab_mode_t; +/** + * @brief Camera frame buffer location + */ +typedef enum { + CAMERA_FB_IN_PSRAM, /*!< Frame buffer is placed in external PSRAM */ + CAMERA_FB_IN_DRAM /*!< Frame buffer is placed in internal DRAM */ +} camera_fb_location_t; + /** * @brief Configuration structure for camera initialization */ @@ -114,6 +122,7 @@ typedef struct { int jpeg_quality; /*!< Quality of JPEG output. 0-63 lower means higher quality */ size_t fb_count; /*!< Number of frame buffers to be allocated. If more than one, then each frame will be acquired (double speed) */ + camera_fb_location_t fb_location; /*!< The location where the frame buffer will be allocated */ camera_grab_mode_t grab_mode; /*!< When buffers should be filled */ } camera_config_t; diff --git a/tools/sdk/esp32/include/esp_adc_cal/include/esp_adc_cal.h b/tools/sdk/esp32/include/esp_adc_cal/include/esp_adc_cal.h index 9adf28078de..171b2ed8501 100644 --- a/tools/sdk/esp32/include/esp_adc_cal/include/esp_adc_cal.h +++ b/tools/sdk/esp32/include/esp_adc_cal/include/esp_adc_cal.h @@ -30,6 +30,7 @@ typedef enum { ESP_ADC_CAL_VAL_EFUSE_VREF = 0, /**< Characterization based on reference voltage stored in eFuse*/ ESP_ADC_CAL_VAL_EFUSE_TP = 1, /**< Characterization based on Two Point values stored in eFuse*/ ESP_ADC_CAL_VAL_DEFAULT_VREF = 2, /**< Characterization based on default reference voltage*/ + ESP_ADC_CAL_VAL_EFUSE_TP_FIT = 3, /**< Characterization based on Two Point values and fitting curve coefficients stored in eFuse */ ESP_ADC_CAL_VAL_MAX, ESP_ADC_CAL_VAL_NOT_SUPPORTED = ESP_ADC_CAL_VAL_MAX, } esp_adc_cal_value_t; @@ -48,6 +49,7 @@ typedef struct { uint32_t vref; /**< Vref used by lookup table*/ const uint32_t *low_curve; /**< Pointer to low Vref curve of lookup table (NULL if unused)*/ const uint32_t *high_curve; /**< Pointer to high Vref curve of lookup table (NULL if unused)*/ + uint8_t version; /**< ADC Calibration */ } esp_adc_cal_characteristics_t; /** @@ -129,8 +131,8 @@ uint32_t esp_adc_cal_raw_to_voltage(uint32_t adc_reading, const esp_adc_cal_char * * @return * - ESP_OK: ADC read and converted to mV - * - ESP_ERR_TIMEOUT: Error, timed out attempting to read ADC * - ESP_ERR_INVALID_ARG: Error due to invalid arguments + * - ESP_ERR_INVALID_STATE: Reading result is invalid. Try to read again. */ esp_err_t esp_adc_cal_get_voltage(adc_channel_t channel, const esp_adc_cal_characteristics_t *chars, uint32_t *voltage); diff --git a/tools/sdk/esp32/include/esp_common/include/esp_attr.h b/tools/sdk/esp32/include/esp_common/include/esp_attr.h index 21e52bd67bc..7b73af76634 100644 --- a/tools/sdk/esp32/include/esp_common/include/esp_attr.h +++ b/tools/sdk/esp32/include/esp_common/include/esp_attr.h @@ -89,6 +89,14 @@ extern "C" { // Forces data into noinit section to avoid initialization after restart. #define __NOINIT_ATTR _SECTION_ATTR_IMPL(".noinit", __COUNTER__) +#if CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY +// Forces data into external memory noinit section to avoid initialization after restart. +#define EXT_RAM_NOINIT_ATTR _SECTION_ATTR_IMPL(".ext_ram_noinit", __COUNTER__) +#else +// Place in internal noinit section +#define EXT_RAM_NOINIT_ATTR __NOINIT_ATTR +#endif + // Forces data into RTC slow memory of .noinit section. // Any variable marked with this attribute will keep its value // after restart or during a deep sleep / wake cycle. @@ -155,4 +163,3 @@ FORCE_INLINE_ATTR TYPE& operator<<=(TYPE& a, int b) { a <<= b; return a; } } #endif #endif /* __ESP_ATTR_H__ */ - diff --git a/tools/sdk/esp32/include/esp_eth/include/esp_eth.h b/tools/sdk/esp32/include/esp_eth/include/esp_eth.h index d204b50898a..6aea512a692 100644 --- a/tools/sdk/esp32/include/esp_eth/include/esp_eth.h +++ b/tools/sdk/esp32/include/esp_eth/include/esp_eth.h @@ -265,12 +265,24 @@ esp_err_t esp_eth_receive(esp_eth_handle_t hdl, uint8_t *buf, uint32_t *length) * * @param[in] hdl: handle of Ethernet driver * @param[in] cmd: IO control command -* @param[in] data: specificed data for command +* @param[in, out] data: address of data for `set` command or address where to store the data when used with `get` command * * @return * - ESP_OK: process io command successfully * - ESP_ERR_INVALID_ARG: process io command failed because of some invalid argument * - ESP_FAIL: process io command failed because some other error occurred +* +* The following IO control commands are supported: +* @li @c ETH_CMD_S_MAC_ADDR sets Ethernet interface MAC address. @c data argument is pointer to MAC address buffer with expected size of 6 bytes. +* @li @c ETH_CMD_G_MAC_ADDR gets Ethernet interface MAC address. @c data argument is pointer to a buffer to which MAC address is to be copied. The buffer size must be at least 6 bytes. +* @li @c ETH_CMD_S_PHY_ADDR sets PHY address in range of <0-31>. @c data argument is pointer to memory of uint32_t datatype from where the configuration option is read. +* @li @c ETH_CMD_G_PHY_ADDR gets PHY address. @c data argument is pointer to memory of uint32_t datatype to which the PHY address is to be stored. +* @li @c ETH_CMD_G_SPEED gets current Ethernet link speed. @c data argument is pointer to memory of eth_speed_t datatype to which the speed is to be stored. +* @li @c ETH_CMD_S_PROMISCUOUS sets/resets Ethernet interface promiscuous mode. @c data argument is pointer to memory of bool datatype from which the configuration option is read. +* @li @c ETH_CMD_S_FLOW_CTRL sets/resets Ethernet interface flow control. @c data argument is pointer to memory of bool datatype from which the configuration option is read. +* @li @c ETH_CMD_G_DUPLEX_MODE gets current Ethernet link duplex mode. @c data argument is pointer to memory of eth_duplex_t datatype to which the duplex mode is to be stored. +* @li @c ETH_CMD_S_PHY_LOOPBACK sets/resets PHY to/from loopback mode. @c data argument is pointer to memory of bool datatype from which the configuration option is read. +* */ esp_err_t esp_eth_ioctl(esp_eth_handle_t hdl, esp_eth_io_cmd_t cmd, void *data); diff --git a/tools/sdk/esp32/include/esp_eth/include/esp_eth_com.h b/tools/sdk/esp32/include/esp_eth/include/esp_eth_com.h index 46409ed710a..7ce0538fbe8 100644 --- a/tools/sdk/esp32/include/esp_eth/include/esp_eth_com.h +++ b/tools/sdk/esp32/include/esp_eth/include/esp_eth_com.h @@ -89,6 +89,7 @@ typedef enum { ETH_CMD_S_PROMISCUOUS, /*!< Set promiscuous mode */ ETH_CMD_S_FLOW_CTRL, /*!< Set flow control */ ETH_CMD_G_DUPLEX_MODE, /*!< Get Duplex mode */ + ETH_CMD_S_PHY_LOOPBACK,/*!< Set PHY loopback */ } esp_eth_io_cmd_t; /** diff --git a/tools/sdk/esp32/include/esp_eth/include/esp_eth_mac.h b/tools/sdk/esp32/include/esp_eth/include/esp_eth_mac.h index f1e790c756d..db462728a18 100644 --- a/tools/sdk/esp32/include/esp_eth/include/esp_eth_mac.h +++ b/tools/sdk/esp32/include/esp_eth/include/esp_eth_mac.h @@ -391,7 +391,7 @@ typedef struct { #define ETH_MAC_DEFAULT_CONFIG() \ { \ .sw_reset_timeout_ms = 100, \ - .rx_task_stack_size = 4096, \ + .rx_task_stack_size = 2048, \ .rx_task_prio = 15, \ .smi_mdc_gpio_num = 23, \ .smi_mdio_gpio_num = 18, \ diff --git a/tools/sdk/esp32/include/esp_eth/include/esp_eth_netif_glue.h b/tools/sdk/esp32/include/esp_eth/include/esp_eth_netif_glue.h index 5e88b5ba5e1..d577fc00b7b 100644 --- a/tools/sdk/esp32/include/esp_eth/include/esp_eth_netif_glue.h +++ b/tools/sdk/esp32/include/esp_eth/include/esp_eth_netif_glue.h @@ -19,6 +19,12 @@ extern "C" { #endif +/** + * @brief Handle of netif glue - an intermediate layer between netif and Ethernet driver + * + */ +typedef struct esp_eth_netif_glue_t* esp_eth_netif_glue_handle_t; + /** * @brief Create a netif glue for Ethernet driver * @note netif glue is used to attach io driver to TCP/IP netif @@ -26,20 +32,23 @@ extern "C" { * @param eth_hdl Ethernet driver handle * @return glue object, which inherits esp_netif_driver_base_t */ -void *esp_eth_new_netif_glue(esp_eth_handle_t eth_hdl); +esp_eth_netif_glue_handle_t esp_eth_new_netif_glue(esp_eth_handle_t eth_hdl); /** * @brief Delete netif glue of Ethernet driver * - * @param glue netif glue + * @param eth_netif_glue netif glue * @return -ESP_OK: delete netif glue successfully */ -esp_err_t esp_eth_del_netif_glue(void *glue); +esp_err_t esp_eth_del_netif_glue(esp_eth_netif_glue_handle_t eth_netif_glue); /** * @brief Register default IP layer handlers for Ethernet * * @note: Ethernet handle might not yet properly initialized when setting up these default handlers + * @warning: This function is deprecated and is kept here only for compatibility reasons. Registration + * of default IP layer handlers for Ethernet is now handled automatically. Do not call this + * function if you want to use multiple Ethernet instances at a time. * * @param[in] esp_netif esp network interface handle created for Ethernet driver * @return @@ -47,12 +56,15 @@ esp_err_t esp_eth_del_netif_glue(void *glue); * - ESP_OK: set default IP layer handlers successfully * - others: other failure occurred during register esp_event handler */ - -esp_err_t esp_eth_set_default_handlers(void *esp_netif); +esp_err_t esp_eth_set_default_handlers(void *esp_netif) __attribute__ ((deprecated)); /** * @brief Unregister default IP layer handlers for Ethernet * + * @warning: This function is deprecated and is kept here only for compatibility reasons. Unregistration + * of default IP layer handlers for Ethernet is now handled automatically if not registered + * by calling esp_eth_set_default_handlers. + * * @param[in] esp_netif esp network interface handle created for Ethernet driver * @return * - ESP_ERR_INVALID_ARG: invalid parameter (esp_netif is NULL) diff --git a/tools/sdk/esp32/include/esp_eth/include/esp_eth_phy.h b/tools/sdk/esp32/include/esp_eth/include/esp_eth_phy.h index c9d32b367c0..f85b7d43043 100644 --- a/tools/sdk/esp32/include/esp_eth/include/esp_eth_phy.h +++ b/tools/sdk/esp32/include/esp_eth/include/esp_eth_phy.h @@ -1,4 +1,4 @@ -// Copyright 2019 Espressif Systems (Shanghai) PTE LTD +// Copyright 2019-2021 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. @@ -173,6 +173,19 @@ struct esp_eth_phy_s { */ esp_err_t (*advertise_pause_ability)(esp_eth_phy_t *phy, uint32_t ability); + /** + * @brief + * + * @param[in] phy: Ethernet PHY instance + * @param[in] enable: enables or disables PHY loopback + * + * @return + * - ESP_OK: configures PHY instance loopback function successfully + * - ESP_FAIL: PHY instance loopback configuration failed because some error occurred + * + */ + esp_err_t (*loopback)(esp_eth_phy_t *phy, bool enable); + /** * @brief Free memory of Ethernet PHY instance * @@ -231,16 +244,32 @@ esp_eth_phy_t *esp_eth_phy_new_ip101(const eth_phy_config_t *config); */ esp_eth_phy_t *esp_eth_phy_new_rtl8201(const eth_phy_config_t *config); +/** +* @brief Create a PHY instance of LAN87xx +* +* @param[in] config: configuration of PHY +* +* @return +* - instance: create PHY instance successfully +* - NULL: create PHY instance failed because some error occurred +*/ +esp_eth_phy_t *esp_eth_phy_new_lan87xx(const eth_phy_config_t *config); + /** * @brief Create a PHY instance of LAN8720 * +* @note For ESP-IDF backwards compatibility reasons. In all other cases, use esp_eth_phy_new_lan87xx instead. +* * @param[in] config: configuration of PHY * * @return * - instance: create PHY instance successfully * - NULL: create PHY instance failed because some error occurred */ -esp_eth_phy_t *esp_eth_phy_new_lan8720(const eth_phy_config_t *config); +static inline esp_eth_phy_t *esp_eth_phy_new_lan8720(const eth_phy_config_t *config) +{ + return esp_eth_phy_new_lan87xx(config); +} /** * @brief Create a PHY instance of DP83848 diff --git a/tools/sdk/esp32/include/esp_event/include/esp_event.h b/tools/sdk/esp32/include/esp_event/include/esp_event.h index 2d39422db57..2c069b0c684 100644 --- a/tools/sdk/esp32/include/esp_event/include/esp_event.h +++ b/tools/sdk/esp32/include/esp_event/include/esp_event.h @@ -23,7 +23,10 @@ #include "freertos/semphr.h" #include "esp_event_base.h" +// Legacy event loop not implemented on Linux target +#if !CONFIG_IDF_TARGET_LINUX #include "esp_event_legacy.h" +#endif #ifdef __cplusplus extern "C" { diff --git a/tools/sdk/esp32/include/esp_hid/include/esp_hid_common.h b/tools/sdk/esp32/include/esp_hid/include/esp_hid_common.h index 9fd7a2c6375..d7582cbc841 100644 --- a/tools/sdk/esp32/include/esp_hid/include/esp_hid_common.h +++ b/tools/sdk/esp32/include/esp_hid/include/esp_hid_common.h @@ -126,6 +126,21 @@ typedef enum { ESP_HID_COD_MIN_MAX } esp_hid_cod_min_t; +/* HID transaction Types */ +typedef enum { + ESP_HID_TRANS_HANDSHAKE = 0, + ESP_HID_TRANS_CONTROL = 1, + ESP_HID_TRANS_GET_REPORT = 4, + ESP_HID_TRANS_SET_REPORT = 5, + ESP_HID_TRANS_GET_PROTOCOL = 6, + ESP_HID_TRANS_SET_PROTOCOL = 7, + ESP_HID_TRANS_GET_IDLE = 8, + ESP_HID_TRANS_SET_IDLE = 9, + ESP_HID_TRANS_DATA = 10, + ESP_HID_TRANS_DATAC = 11, + ESP_HID_TRANS_MAX +} esp_hid_trans_type_t; + /** * @brief HID report item structure */ diff --git a/tools/sdk/esp32/include/esp_hid/include/esp_hidd.h b/tools/sdk/esp32/include/esp_hid/include/esp_hidd.h index ef596c6b2ba..3e1bfc2c06f 100644 --- a/tools/sdk/esp32/include/esp_hid/include/esp_hidd.h +++ b/tools/sdk/esp32/include/esp_hid/include/esp_hidd.h @@ -53,11 +53,28 @@ typedef struct esp_hidd_dev_s esp_hidd_dev_t; * @brief HIDD callback parameters union */ typedef union { + /** + * @brief ESP_HIDD_START_EVENT + * @note Used only for Classic Bluetooth. + */ + struct { + esp_err_t status; /*!< HID device operation status */ + } start; /*!< HID callback param of ESP_HIDD_START_EVENT */ + + /** + * @brief ESP_HIDD_STOP_EVENT + * @note Used only for Classic Bluetooth. + */ + struct { + esp_err_t status; /*!< HID device operation status */ + } stop; /*!< HID callback param of ESP_HIDD_STOP_EVENT */ + /** * @brief ESP_HIDD_CONNECT_EVENT */ struct { esp_hidd_dev_t *dev; /*!< HID device structure */ + esp_err_t status; /*!< HID device operation status, used only for Classic Bluetooth */ } connect; /*!< HID callback param of ESP_HIDD_CONNECT_EVENT */ /** @@ -66,6 +83,7 @@ typedef union { struct { esp_hidd_dev_t *dev; /*!< HID device structure */ int reason; /*!< Indicate the reason of disconnection */ + esp_err_t status; /*!< HID device operation status, used only for Classic Bluetooth */ } disconnect; /*!< HID callback param of ESP_HIDD_DISCONNECT_EVENT */ /** @@ -90,6 +108,8 @@ typedef union { uint16_t length; /*!< data length */ uint8_t *data; /*!< The pointer to the data */ uint8_t map_index; /*!< HID config report map index */ + uint8_t trans_type; /*!< HID device feature transaction type, used only for Classic Bluetooth */ + uint8_t report_type; /*!< HID device feature report type, used only for Classic Bluetooth */ } feature; /*!< HID callback param of ESP_HIDD_FEATURE_EVENT */ /** diff --git a/tools/sdk/esp32/include/esp_hid/include/esp_hidh.h b/tools/sdk/esp32/include/esp_hid/include/esp_hidh.h index d3d10021034..d49f76e6807 100644 --- a/tools/sdk/esp32/include/esp_hid/include/esp_hidh.h +++ b/tools/sdk/esp32/include/esp_hid/include/esp_hidh.h @@ -42,6 +42,8 @@ typedef enum { ESP_HIDH_INPUT_EVENT, /*!< Received HID device INPUT report */ ESP_HIDH_FEATURE_EVENT, /*!< Received HID device FEATURE report */ ESP_HIDH_CLOSE_EVENT, /*!< HID device closed */ + ESP_HIDH_START_EVENT, /*!< HID host stack started, used only for Classic Bluetooth */ + ESP_HIDH_STOP_EVENT, /*!< HID host stack stopped, used only for Classic Bluetooth */ ESP_HIDH_MAX_EVENT, /*!< HID events end marker */ } esp_hidh_event_t; @@ -49,11 +51,28 @@ typedef enum { * @brief HIDH callback parameters union */ typedef union { + /** + * @brief ESP_HIDH_START_EVENT + * @note Used only for Classic Bluetooth. + */ + struct { + esp_err_t status; /*!< HID host operation status */ + } start; /*!< HID callback param of ESP_HIDH_START_EVENT */ + + /** + * @brief ESP_HIDH_STOP_EVENT + * @note Used only for Classic Bluetooth. + */ + struct { + esp_err_t status; /*!< HID host operation status */ + } stop; /*!< HID callback param of ESP_HIDH_STOP_EVENT */ + /** * @brief ESP_HIDH_OPEN_EVENT */ struct { esp_hidh_dev_t *dev; /*!< HID Remote bluetooth device */ + esp_err_t status; /*!< HID host operation status, used only for Classic Bluetooth */ } open; /*!< HID callback param of ESP_HIDH_OPEN_EVENT */ /** @@ -62,6 +81,7 @@ typedef union { struct { esp_hidh_dev_t *dev; /*!< HID Remote bluetooth device. */ int reason; /*!< Reason why the connection was closed. BLE Only */ + esp_err_t status; /*!< HID host operation status, used only for Classic Bluetooth */ } close; /*!< HID callback param of ESP_HIDH_CLOSE_EVENT */ /** @@ -70,6 +90,7 @@ typedef union { struct { esp_hidh_dev_t *dev; /*!< HID Remote bluetooth device */ uint8_t level; /*!< Battery Level (0-100%) */ + esp_err_t status; /*!< HID host operation status */ } battery; /*!< HID callback param of ESP_HIDH_BATTERY_EVENT */ /** @@ -80,7 +101,7 @@ typedef union { esp_hid_usage_t usage; /*!< HID report usage */ uint16_t report_id; /*!< HID report index */ uint16_t length; /*!< HID data length */ - uint8_t *data; /*!< The pointer to the HID data */ + uint8_t *data; /*!< The pointer to the HID data */ uint8_t map_index; /*!< HID report map index */ } input; /*!< HID callback param of ESP_HIDH_INPUT_EVENT */ @@ -92,8 +113,10 @@ typedef union { esp_hid_usage_t usage; /*!< HID report usage */ uint16_t report_id; /*!< HID report index */ uint16_t length; /*!< HID data length */ - uint8_t *data; /*!< The pointer to the HID data */ + uint8_t *data; /*!< The pointer to the HID data */ uint8_t map_index; /*!< HID report map index */ + esp_err_t status; /*!< HID host operation status, used only for Classic Bluetooth */ + esp_hid_trans_type_t trans_type; /*!< HID host feature transaction type, used only for Classic Bluetooth */ } feature; /*!< HID callback param of ESP_HIDH_FEATURE_EVENT */ } esp_hidh_event_data_t; @@ -101,6 +124,7 @@ typedef union { typedef struct { esp_event_handler_t callback; uint16_t event_stack_size; + void *callback_arg; } esp_hidh_config_t; /** @@ -136,6 +160,14 @@ esp_err_t esp_hidh_dev_close(esp_hidh_dev_t *dev); */ esp_err_t esp_hidh_dev_free(esp_hidh_dev_t *dev); +/** + * @brief Check if the device still exists. + * @param dev : pointer to the device + * + * @return: true if exists + */ +bool esp_hidh_dev_exists(esp_hidh_dev_t *dev); + /** * @brief Send an OUTPUT report to the device * @param dev : pointer to the device @@ -173,6 +205,79 @@ esp_err_t esp_hidh_dev_feature_set(esp_hidh_dev_t *dev, size_t map_index, size_t */ esp_err_t esp_hidh_dev_feature_get(esp_hidh_dev_t *dev, size_t map_index, size_t report_id, size_t max_len, uint8_t *data, size_t *length); +/** + * @brief Set_Report command. + * @note For now, this function used only for Classic Bluetooth. + * + * @param dev : pointer to the device + * @param map_index : index of the device report map + * @param report_id : id of the HID FEATURE report + * @param report_type : report type, defines in `esp_hid_common.h` + * @param data : pointer to the data to send + * @param length : length of the data to send + * + * @return: ESP_OK on success + */ +esp_err_t esp_hidh_dev_set_report(esp_hidh_dev_t *dev, size_t map_index, size_t report_id, int report_type, + uint8_t *data, size_t length); + +/** + * @brief Get_Report command. + * @note For now, this function used only for Classic Bluetooth. + * + * @param dev : pointer to the device + * @param map_index : index of the device report map + * @param report_id : id of the HID FEATURE report + * @param report_type : report type, defines in `esp_hid_common.h` + * @param max_len : size of the buffer that will hold the data + * + * @return: ESP_OK on success + */ +esp_err_t esp_hidh_dev_get_report(esp_hidh_dev_t *dev, size_t map_index, size_t report_id, int report_type, + size_t max_len); + +/** + * @brief Get_Idle Command. + * @note For now, this function used only for Classic Bluetooth. + * + * @param dev : pointer to the device + * + * @return: ESP_OK on success + */ +esp_err_t esp_hidh_dev_get_idle(esp_hidh_dev_t *dev); + +/** + * @brief Set_Idle Command. + * @note For now, this function used only for Classic Bluetooth. + * + * @param dev : pointer to the device + * @param idle_time : idle_time + * + * @return: ESP_OK on success + */ +esp_err_t esp_hidh_dev_set_idle(esp_hidh_dev_t *dev, uint8_t idle_time); + +/** + * @brief Get_Protocol Command. + * @note For now, this function used only for Classic Bluetooth. + * + * @param dev : pointer to the device + * + * @return: ESP_OK on success + */ +esp_err_t esp_hidh_dev_get_protocol(esp_hidh_dev_t *dev); + +/** + * @brief Set_Protocol Command. + * @note For now, this function used only for Classic Bluetooth. + * + * @param dev : pointer to the device + * @param protocol_mode : protocol_mode + * + * @return: ESP_OK on success + */ +esp_err_t esp_hidh_dev_set_protocol(esp_hidh_dev_t *dev, uint8_t protocol_mode); + /** * @brief Dump the properties of HID Device to UART * @param dev : pointer to the HID Device diff --git a/tools/sdk/esp32/include/esp_http_client/include/esp_http_client.h b/tools/sdk/esp32/include/esp_http_client/include/esp_http_client.h index ab7e3c2e328..820c4168f66 100644 --- a/tools/sdk/esp32/include/esp_http_client/include/esp_http_client.h +++ b/tools/sdk/esp32/include/esp_http_client/include/esp_http_client.h @@ -113,6 +113,8 @@ typedef struct { size_t client_cert_len; /*!< Length of the buffer pointed to by client_cert_pem. May be 0 for null-terminated pem */ const char *client_key_pem; /*!< SSL client key, PEM format as string, if the server requires to verify client */ size_t client_key_len; /*!< Length of the buffer pointed to by client_key_pem. May be 0 for null-terminated pem */ + const char *client_key_password; /*!< Client key decryption password string */ + size_t client_key_password_len; /*!< String length of the password pointed to by client_key_password */ const char *user_agent; /*!< The User Agent string to send with HTTP requests */ esp_http_client_method_t method; /*!< HTTP Method */ int timeout_ms; /*!< Network timeout in milliseconds */ diff --git a/tools/sdk/esp32/include/esp_http_server/include/esp_http_server.h b/tools/sdk/esp32/include/esp_http_server/include/esp_http_server.h index d14a943c108..1c8b78583ff 100644 --- a/tools/sdk/esp32/include/esp_http_server/include/esp_http_server.h +++ b/tools/sdk/esp32/include/esp_http_server/include/esp_http_server.h @@ -941,6 +941,24 @@ esp_err_t httpd_req_get_url_query_str(httpd_req_t *r, char *buf, size_t buf_len) */ esp_err_t httpd_query_key_value(const char *qry, const char *key, char *val, size_t val_size); +/** + * @brief Get the value string of a cookie value from the "Cookie" request headers by cookie name. + * + * @param[in] req Pointer to the HTTP request + * @param[in] cookie_name The cookie name to be searched in the request + * @param[out] val Pointer to the buffer into which the value of cookie will be copied if the cookie is found + * @param[inout] val_size Pointer to size of the user buffer "val". This variable will contain cookie length if + * ESP_OK is returned and required buffer length incase ESP_ERR_HTTPD_RESULT_TRUNC is returned. + * + * @return + * - ESP_OK : Key is found in the cookie string and copied to buffer + * - ESP_ERR_NOT_FOUND : Key not found + * - ESP_ERR_INVALID_ARG : Null arguments + * - ESP_ERR_HTTPD_RESULT_TRUNC : Value string truncated + * - ESP_ERR_NO_MEM : Memory allocation failure + */ +esp_err_t httpd_req_get_cookie_val(httpd_req_t *req, const char *cookie_name, char *val, size_t *val_size); + /** * @brief Test if a URI matches the given wildcard template. * @@ -1585,6 +1603,11 @@ typedef struct httpd_ws_frame { size_t len; /*!< Length of the WebSocket data */ } httpd_ws_frame_t; +/** + * @brief Transfer complete callback + */ +typedef void (*transfer_complete_cb)(esp_err_t err, int socket, void *arg); + /** * @brief Receive and parse a WebSocket frame * @@ -1645,6 +1668,35 @@ esp_err_t httpd_ws_send_frame_async(httpd_handle_t hd, int fd, httpd_ws_frame_t */ httpd_ws_client_info_t httpd_ws_get_fd_info(httpd_handle_t hd, int fd); +/** + * @brief Sends data to to specified websocket synchronously + * + * @param[in] handle Server instance data + * @param[in] socket Socket descriptor + * @param[in] frame Websocket frame + * @return + * - ESP_OK : On successful + * - ESP_FAIL : When socket errors occurs + * - ESP_ERR_NO_MEM : Unable to allocate memory + */ +esp_err_t httpd_ws_send_data(httpd_handle_t handle, int socket, httpd_ws_frame_t *frame); + +/** + * @brief Sends data to to specified websocket asynchronously + * + * @param[in] handle Server instance data + * @param[in] socket Socket descriptor + * @param[in] frame Websocket frame + * @param[in] callback Callback invoked after sending data + * @param[in] arg User data passed to provided callback + * @return + * - ESP_OK : On successful + * - ESP_FAIL : When socket errors occurs + * - ESP_ERR_NO_MEM : Unable to allocate memory + */ +esp_err_t httpd_ws_send_data_async(httpd_handle_t handle, int socket, httpd_ws_frame_t *frame, + transfer_complete_cb callback, void *arg); + #endif /* CONFIG_HTTPD_WS_SUPPORT */ /** End of WebSocket related stuff * @} diff --git a/tools/sdk/esp32/include/esp_hw_support/include/esp_async_memcpy.h b/tools/sdk/esp32/include/esp_hw_support/include/esp_async_memcpy.h index e95f9638e76..c45c61b2d15 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/esp_async_memcpy.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/esp_async_memcpy.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32/include/esp_hw_support/include/esp_chip_info.h b/tools/sdk/esp32/include/esp_hw_support/include/esp_chip_info.h index d04dcaf4245..69d23c08d36 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/esp_chip_info.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/esp_chip_info.h @@ -1,16 +1,8 @@ -// Copyright 2021 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. +/* + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once @@ -30,7 +22,7 @@ extern "C" { typedef enum { CHIP_ESP32 = 1, //!< ESP32 CHIP_ESP32S2 = 2, //!< ESP32-S2 - CHIP_ESP32S3 = 4, //!< ESP32-S3 + CHIP_ESP32S3 = 9, //!< ESP32-S3 CHIP_ESP32C3 = 5, //!< ESP32-C3 CHIP_ESP32H2 = 6, //!< ESP32-H2 } esp_chip_model_t; diff --git a/tools/sdk/esp32/include/esp_hw_support/include/esp_cpu.h b/tools/sdk/esp32/include/esp_hw_support/include/esp_cpu.h index e1536e979b8..2a810aba440 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/esp_cpu.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/esp_cpu.h @@ -1,16 +1,8 @@ -// Copyright 2010-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. +/* + * SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_CPU_H #define _ESP_CPU_H diff --git a/tools/sdk/esp32/include/esp_hw_support/include/esp_crc.h b/tools/sdk/esp32/include/esp_hw_support/include/esp_crc.h index 6294a7b6218..f12dcf767dd 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/esp_crc.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/esp_crc.h @@ -1,16 +1,8 @@ -// Copyright 2015-2019 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #ifdef __cplusplus diff --git a/tools/sdk/esp32/include/esp_hw_support/include/esp_fault.h b/tools/sdk/esp32/include/esp_hw_support/include/esp_fault.h index fe9de334259..910ba59d06c 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/esp_fault.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/esp_fault.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include "sdkconfig.h" #include "soc/rtc_cntl_reg.h" #include "esp_rom_sys.h" diff --git a/tools/sdk/esp32/include/esp_hw_support/include/esp_interface.h b/tools/sdk/esp32/include/esp_hw_support/include/esp_interface.h index 950c05bb22c..fdb4c0056ce 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/esp_interface.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/esp_interface.h @@ -1,16 +1,8 @@ -// 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef __ESP_INTERFACE_H__ diff --git a/tools/sdk/esp32/include/esp_hw_support/include/esp_intr.h b/tools/sdk/esp32/include/esp_hw_support/include/esp_intr.h index c29dc9bfd1a..0818ed3feab 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/esp_intr.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/esp_intr.h @@ -1,16 +1,8 @@ -// Copyright 2010-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. +/* + * SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #warning esp_intr.h is deprecated, please include esp_intr_alloc.h instead diff --git a/tools/sdk/esp32/include/esp_hw_support/include/esp_intr_alloc.h b/tools/sdk/esp32/include/esp_hw_support/include/esp_intr_alloc.h index 33f70b95970..a26fde9394f 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/esp_intr_alloc.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/esp_intr_alloc.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32/include/esp_hw_support/include/esp_mac.h b/tools/sdk/esp32/include/esp_hw_support/include/esp_mac.h index 75e01ebbd16..f0efddfc2f7 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/esp_mac.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/esp_mac.h @@ -1,16 +1,8 @@ -// Copyright 2021 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. +/* + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once @@ -79,6 +71,7 @@ esp_err_t esp_base_mac_addr_set(const uint8_t *mac); * 8 bytes for EUI-64(used for IEEE 802.15.4) * * @return ESP_OK on success + * ESP_ERR_INVALID_ARG mac is NULL * ESP_ERR_INVALID_MAC base MAC address has not been set */ esp_err_t esp_base_mac_addr_get(uint8_t *mac); @@ -100,8 +93,10 @@ esp_err_t esp_base_mac_addr_get(uint8_t *mac); * 8 bytes for EUI-64(used for IEEE 802.15.4) * * @return ESP_OK on success - * ESP_ERR_INVALID_VERSION An invalid MAC version field was read from BLK3 of EFUSE - * ESP_ERR_INVALID_CRC An invalid MAC CRC was read from BLK3 of EFUSE + * ESP_ERR_INVALID_ARG mac is NULL + * ESP_ERR_INVALID_MAC CUSTOM_MAC address has not been set, all zeros (for esp32-xx) + * ESP_ERR_INVALID_VERSION An invalid MAC version field was read from BLK3 of EFUSE (for esp32) + * ESP_ERR_INVALID_CRC An invalid MAC CRC was read from BLK3 of EFUSE (for esp32) */ esp_err_t esp_efuse_mac_get_custom(uint8_t *mac); @@ -113,6 +108,7 @@ esp_err_t esp_efuse_mac_get_custom(uint8_t *mac); * 8 bytes for EUI-64(used for IEEE 802.15.4) * * @return ESP_OK on success + * ESP_ERR_INVALID_ARG mac is NULL */ esp_err_t esp_efuse_mac_get_default(uint8_t *mac); diff --git a/tools/sdk/esp32/include/esp_hw_support/include/esp_private/esp_clk.h b/tools/sdk/esp32/include/esp_hw_support/include/esp_private/esp_clk.h index 14326898bd7..5a4666fdddf 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/esp_private/esp_clk.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/esp_private/esp_clk.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include diff --git a/tools/sdk/esp32/include/esp_hw_support/include/esp_private/sleep_gpio.h b/tools/sdk/esp32/include/esp_hw_support/include/esp_private/sleep_gpio.h new file mode 100644 index 00000000000..abab21871a4 --- /dev/null +++ b/tools/sdk/esp32/include/esp_hw_support/include/esp_private/sleep_gpio.h @@ -0,0 +1,46 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once +#include +#include "sdkconfig.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file sleep_gpio.h + * + * This file contains declarations of GPIO related functions in light sleep mode. + */ + +#if SOC_GPIO_SUPPORT_SLP_SWITCH && CONFIG_GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL + +/** + * @brief Save GPIO pull-up and pull-down configuration information in the wake-up state + * + * In light sleep mode, the pull-up and pull-down resistors of GPIO will cause + * leakage current when the system sleeps. In order to reduce the power + * consumption of system sleep, it needs to save the configuration information + * of all GPIO pull-up and pull-down resistors and disable the pull-up and + * pull-down resistors of GPIO before the system enters sleep. + */ +void gpio_sleep_mode_config_apply(void); + +/** + * @brief Restore GPIO pull-up and pull-down configuration information in the wake-up state + * + * In light sleep mode, after the system wakes up, it needs to restore all GPIO + * pull-up and pull-down configurations before the last sleep. + */ +void gpio_sleep_mode_config_unapply(void); + +#endif // SOC_GPIO_SUPPORT_SLP_SWITCH && CONFIG_GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32/include/esp_hw_support/include/esp_private/sleep_mac_bb.h b/tools/sdk/esp32/include/esp_hw_support/include/esp_private/sleep_mac_bb.h new file mode 100644 index 00000000000..6b4019639d8 --- /dev/null +++ b/tools/sdk/esp32/include/esp_hw_support/include/esp_private/sleep_mac_bb.h @@ -0,0 +1,43 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once +#include +#include "sdkconfig.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file sleep_mac_bb.h + * + * This file contains declarations of MAC and baseband power consumption related functions in light sleep mode. + */ + +#if CONFIG_MAC_BB_PD + +/** + * @brief A callback function completes MAC and baseband power down operation + * + * In light sleep mode, execute Wi-Fi and Bluetooth module MAC and baseband + * power down and backup register configuration information operations. + */ +void mac_bb_power_down_cb_execute(void); + +/** + * @brief A callback function completes MAC and baseband power up operation + * + * In light sleep mode, execute Wi-Fi and Bluetooth module MAC and baseband + * power up and restore register configuration information operations. + */ +void mac_bb_power_up_cb_execute(void); + +#endif // CONFIG_MAC_BB_PD + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32/include/esp_hw_support/include/esp_private/sleep_retention.h b/tools/sdk/esp32/include/esp_hw_support/include/esp_private/sleep_retention.h new file mode 100644 index 00000000000..001e559c0c7 --- /dev/null +++ b/tools/sdk/esp32/include/esp_hw_support/include/esp_private/sleep_retention.h @@ -0,0 +1,55 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once +#include +#include "sdkconfig.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file sleep_retention.h + * + * This file contains declarations of memory retention related functions in light sleeo mode. + */ + +#if SOC_PM_SUPPORT_CPU_PD + +/** + * @brief Whether to allow the cpu power domain to be powered off. + * + * In light sleep mode, only when the system can provide enough memory + * for cpu retention, the cpu power domain can be powered off. + */ +bool cpu_domain_pd_allowed(void); + +#endif + +#if SOC_PM_SUPPORT_CPU_PD || SOC_PM_SUPPORT_TAGMEM_PD + +/** + * @brief Enable memory retention of some modules. + * + * In light sleep mode, before the system goes to sleep, enable the memory + * retention of modules such as CPU and I/D-cache tag memory. + */ +void sleep_enable_memory_retention(void); + +/** + * @brief Disable memory retention of some modules. + * + * In light sleep mode, after the system exits sleep, disable the memory + * retention of moudles such as CPU and I/D-cache tag memory. + */ +void sleep_disable_memory_retention(void); + +#endif // SOC_PM_SUPPORT_CPU_PD || SOC_PM_SUPPORT_TAGMEM_PD + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32/include/esp_hw_support/include/esp_random.h b/tools/sdk/esp32/include/esp_hw_support/include/esp_random.h index cf4f408b513..a6b8a884b69 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/esp_random.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/esp_random.h @@ -1,16 +1,8 @@ -// Copyright 2021 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. +/* + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32/include/esp_hw_support/include/esp_sleep.h b/tools/sdk/esp32/include/esp_hw_support/include/esp_sleep.h index 000d020aebb..cfdfbc04186 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/esp_sleep.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/esp_sleep.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once @@ -49,7 +41,9 @@ typedef enum { ESP_PD_DOMAIN_RTC_SLOW_MEM, //!< RTC slow memory ESP_PD_DOMAIN_RTC_FAST_MEM, //!< RTC fast memory ESP_PD_DOMAIN_XTAL, //!< XTAL oscillator +#if SOC_PM_SUPPORT_CPU_PD ESP_PD_DOMAIN_CPU, //!< CPU core +#endif ESP_PD_DOMAIN_VDDSDIO, //!< VDD_SDIO ESP_PD_DOMAIN_MAX //!< Number of domains } esp_sleep_pd_domain_t; @@ -380,6 +374,8 @@ esp_err_t esp_light_sleep_start(void); * * This function does not return. * + * @note The device will wake up immediately if the deep-sleep time is set to 0 + * * @param time_in_us deep-sleep time, unit: microsecond */ void esp_deep_sleep(uint64_t time_in_us) __attribute__((noreturn)); diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/clk_ctrl_os.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/clk_ctrl_os.h index f4d769b8014..b5eff46930c 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/clk_ctrl_os.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/clk_ctrl_os.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include "soc/rtc.h" diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/compare_set.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/compare_set.h index ddbaeb7e3d6..b5a35fa701a 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/compare_set.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/compare_set.h @@ -1,16 +1,8 @@ -// Copyright 2015-2019 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/cpu.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/cpu.h index 0e4d1688ca3..526171bc1ce 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/cpu.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/cpu.h @@ -1,16 +1,8 @@ -// Copyright 2010-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. +/* + * SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _SOC_CPU_H #define _SOC_CPU_H diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32/clk.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32/clk.h index 31902ebad01..a9ed3028527 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32/clk.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32/clk.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include "esp_private/esp_clk.h" diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32/dport_access.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32/dport_access.h index 4f473940ad4..8e04674951a 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32/dport_access.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32/dport_access.h @@ -3,30 +3,28 @@ * * SPDX-License-Identifier: Apache-2.0 */ -#include - -#include -#ifndef _ESP_DPORT_ACCESS_H_ -#define _ESP_DPORT_ACCESS_H_ +#pragma once +#include +#include #include "xtensa/xtruntime.h" #ifdef __cplusplus extern "C" { #endif -void esp_dport_access_stall_other_cpu_start(void); -void esp_dport_access_stall_other_cpu_end(void); -void esp_dport_access_int_init(void); -void esp_dport_access_int_pause(void); -void esp_dport_access_int_resume(void); +void esp_dport_access_stall_other_cpu_start(void) __attribute__ ((deprecated)); +void esp_dport_access_stall_other_cpu_end(void) __attribute__ ((deprecated)); +void esp_dport_access_int_init(void) __attribute__ ((deprecated)); +void esp_dport_access_int_pause(void) __attribute__ ((deprecated)); +void esp_dport_access_int_resume(void) __attribute__ ((deprecated)); void esp_dport_access_read_buffer(uint32_t *buff_out, uint32_t address, uint32_t num_words); uint32_t esp_dport_access_reg_read(uint32_t reg); uint32_t esp_dport_access_sequence_reg_read(uint32_t reg); //This routine does not stop the dport routines in any way that is recoverable. Please //only call in case of panic(). -void esp_dport_access_int_abort(void); +void esp_dport_access_int_abort(void) __attribute__ ((deprecated)); #if defined(BOOTLOADER_BUILD) || !defined(CONFIG_ESP32_DPORT_WORKAROUND) || !defined(ESP_PLATFORM) #define DPORT_STALL_OTHER_CPU_START() @@ -34,8 +32,9 @@ void esp_dport_access_int_abort(void); #define DPORT_INTERRUPT_DISABLE() #define DPORT_INTERRUPT_RESTORE() #else -#define DPORT_STALL_OTHER_CPU_START() esp_dport_access_stall_other_cpu_start() -#define DPORT_STALL_OTHER_CPU_END() esp_dport_access_stall_other_cpu_end() +#include "esp_ipc_isr.h" +#define DPORT_STALL_OTHER_CPU_START() esp_ipc_isr_stall_other_cpu() +#define DPORT_STALL_OTHER_CPU_END() esp_ipc_isr_release_other_cpu() #define DPORT_INTERRUPT_DISABLE() unsigned int intLvl = XTOS_SET_INTLEVEL(CONFIG_ESP32_DPORT_DIS_INTERRUPT_LVL) #define DPORT_INTERRUPT_RESTORE() XTOS_RESTORE_JUST_INTLEVEL(intLvl) #endif @@ -43,5 +42,3 @@ void esp_dport_access_int_abort(void); #ifdef __cplusplus } #endif - -#endif /* _ESP_DPORT_ACCESS_H_ */ diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32/spiram.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32/spiram.h index e58712d1fa6..a6086f3d311 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32/spiram.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32/spiram.h @@ -85,6 +85,15 @@ size_t esp_spiram_get_size(void); */ void esp_spiram_writeback_cache(void); +/** + * @brief get psram CS IO + * + * This interface should be called after PSRAM is enabled, otherwise it will + * return an invalid value -1/0xff. + * + * @return psram CS IO or -1/0xff if psram not enabled + */ +uint8_t esp_spiram_get_cs_io(void); /** diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32c3/clk.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32c3/clk.h index 31902ebad01..a9ed3028527 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32c3/clk.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32c3/clk.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include "esp_private/esp_clk.h" diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32c3/dport_access.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32c3/dport_access.h index f3f7007a9cb..e5aedd2e1b1 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32c3/dport_access.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32c3/dport_access.h @@ -1,16 +1,8 @@ -// Copyright 2010-2020 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. +/* + * SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_DPORT_ACCESS_H_ #define _ESP_DPORT_ACCESS_H_ diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32c3/esp_crypto_lock.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32c3/esp_crypto_lock.h index 3149d34692b..67a08741b51 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32c3/esp_crypto_lock.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32c3/esp_crypto_lock.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32c3/esp_ds.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32c3/esp_ds.h index 911e44c8379..9d59aa71c6f 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32c3/esp_ds.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32c3/esp_ds.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32c3/esp_hmac.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32c3/esp_hmac.h index 391ba12fe15..26e2bc71a05 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32c3/esp_hmac.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32c3/esp_hmac.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_HMAC_H_ #define _ESP_HMAC_H_ @@ -60,6 +52,35 @@ esp_err_t esp_hmac_calculate(hmac_key_id_t key_id, size_t message_len, uint8_t *hmac); +/** + * @brief Use HMAC peripheral in Downstream mode to re-enable the JTAG, if it is not permanently disabled by HW. + * In downstream mode, HMAC calculations performed by peripheral are used internally and not provided back to user. + * + * @param key_id Determines which of the 6 key blocks in the efuses should be used for the HMAC calculation. + * The corresponding purpose field of the key block in the efuse must be set to HMAC downstream purpose. + * + * @param token Pre calculated HMAC value of the 32-byte 0x00 using SHA-256 and the known private HMAC key. The key is already + * programmed to a eFuse key block. The key block number is provided as the first parameter to this function. + * + * @return + * * ESP_OK, if the calculation was successful, + * if the calculated HMAC value matches with provided token, + * JTAG will be re-enable otherwise JTAG will remain disabled. + * Return value does not indicate the JTAG status. + * * ESP_FAIL, if the hmac calculation failed or JTAG is permanently disabled by EFUSE_HARD_DIS_JTAG eFuse parameter. + * * ESP_ERR_INVALID_ARG, invalid input arguments + */ +esp_err_t esp_hmac_jtag_enable(hmac_key_id_t key_id, const uint8_t *token); + +/** + * @brief Disable the JTAG which might be enabled using the HMAC downstream mode. This function just clears the result generated + * by calling esp_hmac_jtag_enable() API. + * + * @return + * * ESP_OK return ESP_OK after writing the HMAC_SET_INVALIDATE_JTAG_REG with value 1. + */ +esp_err_t esp_hmac_jtag_disable(void); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32c3/memprot.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32c3/memprot.h index 0d7e6ca40df..818cd677dc8 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32c3/memprot.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32c3/memprot.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /* INTERNAL API diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32c3/rtc.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32c3/rtc.h index b090ae5cfbe..4d46831ded3 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32c3/rtc.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32c3/rtc.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32h2/clk.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32h2/clk.h index 31902ebad01..a9ed3028527 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32h2/clk.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32h2/clk.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include "esp_private/esp_clk.h" diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32h2/dport_access.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32h2/dport_access.h index f3f7007a9cb..e5aedd2e1b1 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32h2/dport_access.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32h2/dport_access.h @@ -1,16 +1,8 @@ -// Copyright 2010-2020 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. +/* + * SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_DPORT_ACCESS_H_ #define _ESP_DPORT_ACCESS_H_ diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32h2/esp_crypto_lock.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32h2/esp_crypto_lock.h index 3149d34692b..67a08741b51 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32h2/esp_crypto_lock.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32h2/esp_crypto_lock.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32h2/esp_ds.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32h2/esp_ds.h index 79e963fc6bd..6bad7075587 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32h2/esp_ds.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32h2/esp_ds.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32h2/esp_hmac.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32h2/esp_hmac.h index 391ba12fe15..26e2bc71a05 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32h2/esp_hmac.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32h2/esp_hmac.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_HMAC_H_ #define _ESP_HMAC_H_ @@ -60,6 +52,35 @@ esp_err_t esp_hmac_calculate(hmac_key_id_t key_id, size_t message_len, uint8_t *hmac); +/** + * @brief Use HMAC peripheral in Downstream mode to re-enable the JTAG, if it is not permanently disabled by HW. + * In downstream mode, HMAC calculations performed by peripheral are used internally and not provided back to user. + * + * @param key_id Determines which of the 6 key blocks in the efuses should be used for the HMAC calculation. + * The corresponding purpose field of the key block in the efuse must be set to HMAC downstream purpose. + * + * @param token Pre calculated HMAC value of the 32-byte 0x00 using SHA-256 and the known private HMAC key. The key is already + * programmed to a eFuse key block. The key block number is provided as the first parameter to this function. + * + * @return + * * ESP_OK, if the calculation was successful, + * if the calculated HMAC value matches with provided token, + * JTAG will be re-enable otherwise JTAG will remain disabled. + * Return value does not indicate the JTAG status. + * * ESP_FAIL, if the hmac calculation failed or JTAG is permanently disabled by EFUSE_HARD_DIS_JTAG eFuse parameter. + * * ESP_ERR_INVALID_ARG, invalid input arguments + */ +esp_err_t esp_hmac_jtag_enable(hmac_key_id_t key_id, const uint8_t *token); + +/** + * @brief Disable the JTAG which might be enabled using the HMAC downstream mode. This function just clears the result generated + * by calling esp_hmac_jtag_enable() API. + * + * @return + * * ESP_OK return ESP_OK after writing the HMAC_SET_INVALIDATE_JTAG_REG with value 1. + */ +esp_err_t esp_hmac_jtag_disable(void); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32h2/memprot.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32h2/memprot.h index 2567b604b00..75228580ffd 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32h2/memprot.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32h2/memprot.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /* INTERNAL API diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32h2/rtc.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32h2/rtc.h index cca748df919..75460416c7d 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32h2/rtc.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32h2/rtc.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/clk.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/clk.h index 31902ebad01..a9ed3028527 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/clk.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/clk.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include "esp_private/esp_clk.h" diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/dport_access.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/dport_access.h index 6ba6fd65556..e5aedd2e1b1 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/dport_access.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/dport_access.h @@ -1,16 +1,8 @@ -// Copyright 2010-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. +/* + * SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_DPORT_ACCESS_H_ #define _ESP_DPORT_ACCESS_H_ diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/esp_crypto_lock.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/esp_crypto_lock.h index e1df0399f30..2c337c93714 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/esp_crypto_lock.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/esp_crypto_lock.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/esp_ds.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/esp_ds.h index 12906377ee5..2ef0bd00fbe 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/esp_ds.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/esp_ds.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/esp_hmac.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/esp_hmac.h index 5fa836c47d8..409217c06bc 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/esp_hmac.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/esp_hmac.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_HMAC_H_ #define _ESP_HMAC_H_ diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/memprot.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/memprot.h index c63fb395e6d..0ebd6474578 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/memprot.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/memprot.h @@ -1,17 +1,8 @@ -// Copyright 2020 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. - +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /* INTERNAL API * generic interface to MMU memory protection features @@ -21,6 +12,7 @@ #include #include #include "esp_attr.h" +#include "esp_err.h" #ifdef __cplusplus extern "C" { @@ -51,6 +43,8 @@ extern "C" { #define MEMPROT_UNLOCK false #define DEF_SPLIT_LINE NULL +#define MEMPROT_INVALID_ADDRESS -1 + //memory range types typedef enum { MEMPROT_NONE = 0x00000000, @@ -77,23 +71,27 @@ typedef enum { uint32_t *IRAM_ATTR esp_memprot_get_split_addr(mem_type_prot_t mem_type); /** - * @brief Initializes illegal memory access control (MMU) for required memory section. + * @brief Initializes illegal memory access control for required memory section. * * All memory access interrupts share ETS_MEMACCESS_ERR_INUM input channel, it is caller's * responsibility to properly detect actual intr. source as well as possible prioritization in case * of multiple source reported during one intr.handling routine run * - * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @param mem_type Memory protection area type (see mem_type_prot_t enum)\ + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_intr_init(mem_type_prot_t mem_type); +esp_err_t esp_memprot_intr_init(mem_type_prot_t mem_type); /** * @brief Enable/disable the memory protection interrupt * * @param mem_type Memory protection area type (see mem_type_prot_t enum) * @param enable enable/disable + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_intr_ena(mem_type_prot_t mem_type, bool enable); +esp_err_t esp_memprot_intr_ena(mem_type_prot_t mem_type, bool enable); /** * @brief Sets a request for clearing interrupt-on flag for specified memory region (register write) @@ -102,8 +100,10 @@ void esp_memprot_intr_ena(mem_type_prot_t mem_type, bool enable); * Should be used only after the real interrupt appears, typically as the last step in interrupt handler's routine. * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_clear_intr(mem_type_prot_t mem_type); +esp_err_t esp_memprot_clear_intr(mem_type_prot_t mem_type); /** * @brief Detects which memory protection interrupt is active @@ -122,10 +122,11 @@ mem_type_prot_t IRAM_ATTR esp_memprot_get_active_intr_memtype(void); * @brief Gets interrupt status register contents for specified memory region * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @param fault_reg_val Contents of status register * - * @return Contents of status register + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -uint32_t esp_memprot_get_fault_reg(mem_type_prot_t mem_type); +esp_err_t esp_memprot_get_fault_reg(mem_type_prot_t mem_type, uint32_t *fault_reg_val); /** * @brief Get details of given interrupt status @@ -138,8 +139,9 @@ uint32_t esp_memprot_get_fault_reg(mem_type_prot_t mem_type); * @param op_subtype Additional info for op_type [out] * IRAM0: 0 - instruction segment access, 1 - data segment access * DRAM0: 0 - non-atomic operation, 1 - atomic operation + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void IRAM_ATTR esp_memprot_get_fault_status(mem_type_prot_t mem_type, uint32_t **faulting_address, uint32_t *op_type, uint32_t *op_subtype); +esp_err_t IRAM_ATTR esp_memprot_get_fault_status(mem_type_prot_t mem_type, uint32_t **faulting_address, uint32_t *op_type, uint32_t *op_subtype); /** * @brief Gets string representation of required memory region identifier @@ -163,26 +165,30 @@ bool esp_memprot_is_locked_any(void); * Locks can be unlocked only by digital system reset * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_set_lock(mem_type_prot_t mem_type); +esp_err_t esp_memprot_set_lock(mem_type_prot_t mem_type); /** * @brief Gets lock status for required memory region * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @param locked Settings locked: true/false (locked/unlocked) * - * @return true/false (locked/unlocked) + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -bool esp_memprot_get_lock(mem_type_prot_t mem_type); +esp_err_t esp_memprot_get_lock(mem_type_prot_t mem_type, bool *locked); /** * @brief Gets permission control configuration register contents for required memory region * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @param conf_reg_val Permission control register contents * - * @return Permission control register contents + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -uint32_t esp_memprot_get_conf_reg(mem_type_prot_t mem_type); +esp_err_t esp_memprot_get_conf_reg(mem_type_prot_t mem_type, uint32_t *conf_reg_val); /** * @brief Gets interrupt permission settings for unified management block @@ -190,21 +196,23 @@ uint32_t esp_memprot_get_conf_reg(mem_type_prot_t mem_type); * Gets interrupt permission settings register contents for required memory region, returns settings for unified management blocks * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @param perm_reg Permission settings register contents * - * @return Permission settings register contents + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -uint32_t esp_memprot_get_perm_uni_reg(mem_type_prot_t mem_type); +esp_err_t esp_memprot_get_perm_uni_reg(mem_type_prot_t mem_type, uint32_t *perm_reg); /** * @brief Gets interrupt permission settings for split management block * - * Gets interrupt permission settings register contents for required memory region, returns settings for split management blocks + * Gets interrupt permission settings register contents for required memory region (unified management blocks) * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @return split_reg Unified management settings register contents * - * @return Permission settings register contents + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -uint32_t esp_memprot_get_perm_split_reg(mem_type_prot_t mem_type); +esp_err_t esp_memprot_get_perm_split_reg(mem_type_prot_t mem_type, uint32_t *split_reg); /** * @brief Detects whether any of the memory protection interrupts is enabled @@ -217,28 +225,30 @@ bool esp_memprot_is_intr_ena_any(void); * @brief Gets interrupt-enabled flag for given memory region * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @param enable_bit Interrupt-enabled flag * - * @return Interrupt-enabled value + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -uint32_t esp_memprot_get_intr_ena_bit(mem_type_prot_t mem_type); +esp_err_t esp_memprot_get_intr_ena_bit(mem_type_prot_t mem_type, uint32_t *enable_bit); /** * @brief Gets interrupt-active flag for given memory region * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @param intr_on_bit Interrupt-active flag * - * @return Interrupt-active value - */ -uint32_t esp_memprot_get_intr_on_bit(mem_type_prot_t mem_type); + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ +esp_err_t esp_memprot_get_intr_on_bit(mem_type_prot_t mem_type, uint32_t *intr_on_bit); /** * @brief Gets interrupt-clear request flag for given memory region * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @param clear_bit Interrupt-clear request flag * - * @return Interrupt-clear request value + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -uint32_t esp_memprot_get_intr_clr_bit(mem_type_prot_t mem_type); +esp_err_t esp_memprot_get_intr_clr_bit(mem_type_prot_t mem_type, uint32_t *clear_bit); /** * @brief Gets read permission value for specified block and memory region @@ -248,10 +258,11 @@ uint32_t esp_memprot_get_intr_clr_bit(mem_type_prot_t mem_type); * * @param mem_type Memory protection area type (see mem_type_prot_t enum) * @param block Memory block identifier (0-3) + * @param read_bit Read permission value for required block * - * @return Read permission value for required block + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -uint32_t esp_memprot_get_uni_block_read_bit(mem_type_prot_t mem_type, uint32_t block); +esp_err_t esp_memprot_get_uni_block_read_bit(mem_type_prot_t mem_type, uint32_t block, uint32_t *read_bit); /** * @brief Gets write permission value for specified block and memory region @@ -261,10 +272,11 @@ uint32_t esp_memprot_get_uni_block_read_bit(mem_type_prot_t mem_type, uint32_t b * * @param mem_type Memory protection area type (see mem_type_prot_t enum) * @param block Memory block identifier (0-3) + * @param write_bit Write permission value for required block * - * @return Write permission value for required block + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -uint32_t esp_memprot_get_uni_block_write_bit(mem_type_prot_t mem_type, uint32_t block); +esp_err_t esp_memprot_get_uni_block_write_bit(mem_type_prot_t mem_type, uint32_t block, uint32_t *write_bit); /** * @brief Gets execute permission value for specified block and memory region @@ -274,10 +286,11 @@ uint32_t esp_memprot_get_uni_block_write_bit(mem_type_prot_t mem_type, uint32_t * * @param mem_type Memory protection area type (see mem_type_prot_t enum) * @param block Memory block identifier (0-3) + * @param exec_bit Execute permission value for required block * - * @return Execute permission value for required block + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -uint32_t esp_memprot_get_uni_block_exec_bit(mem_type_prot_t mem_type, uint32_t block); +esp_err_t esp_memprot_get_uni_block_exec_bit(mem_type_prot_t mem_type, uint32_t block, uint32_t *exec_bit); /** * @brief Sets permissions for specified block in DRAM region @@ -289,8 +302,10 @@ uint32_t esp_memprot_get_uni_block_exec_bit(mem_type_prot_t mem_type, uint32_t b * @param block Memory block identifier (0-3) * @param write_perm Write permission flag * @param read_perm Read permission flag + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_set_uni_block_perm_dram(mem_type_prot_t mem_type, uint32_t block, bool write_perm, bool read_perm); +esp_err_t esp_memprot_set_uni_block_perm_dram(mem_type_prot_t mem_type, uint32_t block, bool write_perm, bool read_perm); /** * @brief Sets permissions for high and low memory segment in DRAM region @@ -305,8 +320,10 @@ void esp_memprot_set_uni_block_perm_dram(mem_type_prot_t mem_type, uint32_t bloc * @param lr Low segment Read permission flag * @param hw High segment Write permission flag * @param hr High segment Read permission flag + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_set_prot_dram(mem_type_prot_t mem_type, uint32_t *split_addr, bool lw, bool lr, bool hw, bool hr); +esp_err_t esp_memprot_set_prot_dram(mem_type_prot_t mem_type, uint32_t *split_addr, bool lw, bool lr, bool hw, bool hr); /** * @brief Sets permissions for specified block in IRAM region @@ -314,12 +331,17 @@ void esp_memprot_set_prot_dram(mem_type_prot_t mem_type, uint32_t *split_addr, b * Sets Read, Write and Execute permission for specified unified-management block (0-3) in given memory region. * Applicable only to IRAM memory types * - * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @param mem_type Memory protection area type (MEMPROT_IRAM0_SRAM) * @param block Memory block identifier (0-3) * @param write_perm Write permission flag + * @param read_perm Read permission flag * @param exec_perm Execute permission flag + * + * @return ESP_OK on success + * ESP_ERR_NOT_SUPPORTED on invalid mem_type + * ESP_ERR_INVALID_ARG on incorrect block number */ -void esp_memprot_set_uni_block_perm_iram(mem_type_prot_t mem_type, uint32_t block, bool write_perm, bool read_perm, bool exec_perm); +esp_err_t esp_memprot_set_uni_block_perm_iram(mem_type_prot_t mem_type, uint32_t block, bool write_perm, bool read_perm, bool exec_perm); /** * @brief Sets permissions for high and low memory segment in IRAM region @@ -336,8 +358,10 @@ void esp_memprot_set_uni_block_perm_iram(mem_type_prot_t mem_type, uint32_t bloc * @param hw High segment Write permission flag * @param hr High segment Read permission flag * @param hx High segment Execute permission flag + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_set_prot_iram(mem_type_prot_t mem_type, uint32_t *split_addr, bool lw, bool lr, bool lx, bool hw, bool hr, bool hx); +esp_err_t esp_memprot_set_prot_iram(mem_type_prot_t mem_type, uint32_t *split_addr, bool lw, bool lr, bool lx, bool hw, bool hr, bool hx); /** * @brief Activates memory protection for all supported memory region types @@ -347,8 +371,10 @@ void esp_memprot_set_prot_iram(mem_type_prot_t mem_type, uint32_t *split_addr, b * @param invoke_panic_handler map mem.prot interrupt to ETS_MEMACCESS_ERR_INUM and thus invokes panic handler when fired ('true' not suitable for testing) * @param lock_feature sets LOCK bit, see esp_memprot_set_lock() ('true' not suitable for testing) * @param mem_type_mask holds a set of required memory protection types (bitmask built of mem_type_prot_t). NULL means default (MEMPROT_ALL in this version) + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_set_prot(bool invoke_panic_handler, bool lock_feature, uint32_t *mem_type_mask); +esp_err_t esp_memprot_set_prot(bool invoke_panic_handler, bool lock_feature, uint32_t *mem_type_mask); /** * @brief Get permission settings bits for IRAM0 split mgmt. Only IRAM0 memory types allowed @@ -360,8 +386,10 @@ void esp_memprot_set_prot(bool invoke_panic_handler, bool lock_feature, uint32_t * @param hw High segment Write permission flag * @param hr High segment Read permission flag * @param hx High segment Execute permission flag + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_get_perm_split_bits_iram(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *lx, bool *hw, bool *hr, bool *hx); +esp_err_t esp_memprot_get_perm_split_bits_iram(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *lx, bool *hw, bool *hr, bool *hx); /** * @brief Get permission settings bits for DRAM0 split mgmt. Only DRAM0 memory types allowed @@ -371,8 +399,10 @@ void esp_memprot_get_perm_split_bits_iram(mem_type_prot_t mem_type, bool *lw, bo * @param lr Low segment Read permission flag * @param hw High segment Write permission flag * @param hr High segment Read permission flag + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_get_perm_split_bits_dram(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *hw, bool *hr); +esp_err_t esp_memprot_get_perm_split_bits_dram(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *hw, bool *hr); /** * @brief Sets permissions for high and low memory segment in PERIBUS1 region @@ -386,8 +416,10 @@ void esp_memprot_get_perm_split_bits_dram(mem_type_prot_t mem_type, bool *lw, bo * @param lr Low segment Read permission flag * @param hw High segment Write permission flag * @param hr High segment Read permission flag + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_set_prot_peri1(mem_type_prot_t mem_type, uint32_t *split_addr, bool lw, bool lr, bool hw, bool hr); +esp_err_t esp_memprot_set_prot_peri1(mem_type_prot_t mem_type, uint32_t *split_addr, bool lw, bool lr, bool hw, bool hr); /** * @brief Get permission settings bits for PERIBUS1 split mgmt. Only PERIBUS1 memory types allowed @@ -397,8 +429,10 @@ void esp_memprot_set_prot_peri1(mem_type_prot_t mem_type, uint32_t *split_addr, * @param lr Low segment Read permission flag * @param hw High segment Write permission flag * @param hr High segment Read permission flag + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_get_perm_split_bits_peri1(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *hw, bool *hr); +esp_err_t esp_memprot_get_perm_split_bits_peri1(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *hw, bool *hr); /** * @brief Get permission settings bits for PERIBUS2 split mgmt. Only PERIBUS2 memory types allowed @@ -410,25 +444,32 @@ void esp_memprot_get_perm_split_bits_peri1(mem_type_prot_t mem_type, bool *lw, b * @param hw High segment Write permission flag * @param hr High segment Read permission flag * @param hx High segment Execute permission flag + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_get_perm_split_bits_peri2(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *lx, bool *hw, bool *hr, bool *hx); +esp_err_t esp_memprot_get_perm_split_bits_peri2(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *lx, bool *hw, bool *hr, bool *hx); /** - * @brief Sets permissions for high and low memory segment in PERIBUS2 region + * @brief Configures the memory protection for high and low segment in PERIBUS2 region * * Sets Read Write permission for both low and high memory segments given by splitting address. * Applicable only to PERIBUS2 memory types * - * @param mem_type Memory protection area type (see mem_type_prot_t enum) - * @param split_addr Address to split the memory region to lower and higher segment + * @param mem_type Memory protection area type (MEMPROT_PERI2_RTCSLOW_0, MEMPROT_PERI2_RTCSLOW_1) + * @param split_addr Address to split the memory region to lower and higher segment (32bit aligned) * @param lw Low segment Write permission flag * @param lr Low segment Read permission flag * @param lx Low segment Execute permission flag * @param hw High segment Write permission flag * @param hr High segment Read permission flag * @param hx High segment Execute permission flag + * + * @return ESP_OK on success + * ESP_ERR_NOT_SUPPORTED on invalid mem_type + * ESP_ERR_INVALID_STATE on splitting address out of PERIBUS2 range + * ESP_ERR_INVALID_SIZE on splitting address not 32-bit aligned */ -void esp_memprot_set_prot_peri2(mem_type_prot_t mem_type, uint32_t *split_addr, bool lw, bool lr, bool lx, bool hw, bool hr, bool hx); +esp_err_t esp_memprot_set_prot_peri2(mem_type_prot_t mem_type, uint32_t *split_addr, bool lw, bool lr, bool lx, bool hw, bool hr, bool hx); /** * @brief Get permissions for specified memory type. Irrelevant bits are ignored @@ -440,8 +481,12 @@ void esp_memprot_set_prot_peri2(mem_type_prot_t mem_type, uint32_t *split_addr, * @param hw High segment Write permission flag * @param hr High segment Read permission flag * @param hx High segment Execute permission flag + * + * @return ESP_OK on success + * ESP_ERR_INVALID_ARG on NULL lw/lr/lx/hw/hr/hx args + * ESP_ERR_NOT_SUPPORTED on invalid mem_type */ -void esp_memprot_get_permissions(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *lx, bool *hw, bool *hr, bool *hx); +esp_err_t esp_memprot_get_permissions(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *lx, bool *hw, bool *hr, bool *hx); /** * @brief Get Read permission settings for low and high regions of given memory type @@ -449,8 +494,12 @@ void esp_memprot_get_permissions(mem_type_prot_t mem_type, bool *lw, bool *lr, b * @param mem_type Memory protection area type (see mem_type_prot_t enum) * @param lr Low segment Read permission flag * @param hr High segment Read permission flag + * + * @return ESP_OK on success + * ESP_ERR_INVALID_ARG on NULL lr/hr args + * ESP_ERR_NOT_SUPPORTED on invalid mem_type */ -void esp_memprot_get_perm_read(mem_type_prot_t mem_type, bool *lr, bool *hr); +esp_err_t esp_memprot_get_perm_read(mem_type_prot_t mem_type, bool *lr, bool *hr); /** * @brief Get Write permission settings for low and high regions of given memory type @@ -458,23 +507,33 @@ void esp_memprot_get_perm_read(mem_type_prot_t mem_type, bool *lr, bool *hr); * @param mem_type Memory protection area type (see mem_type_prot_t enum) * @param lr Low segment Write permission flag * @param hr High segment Write permission flag + * + * @return ESP_OK on success + * ESP_ERR_INVALID_ARG on NULL lw/hw args + * ESP_ERR_NOT_SUPPORTED on invalid mem_type */ -void esp_memprot_get_perm_write(mem_type_prot_t mem_type, bool *lw, bool *hw); +esp_err_t esp_memprot_get_perm_write(mem_type_prot_t mem_type, bool *lw, bool *hw); /** * @brief Get Execute permission settings for low and high regions of given memory type * Applicable only to IBUS-compatible memory types * - * @param mem_type Memory protection area type (see mem_type_prot_t enum) - * @param lr Low segment Exec permission flag - * @param hr High segment Exec permission flag + * @param mem_type Memory protection area type (MEMPROT_IRAM0_SRAM, MEMPROT_IRAM0_RTCFAST, MEMPROT_PERI2_RTCSLOW_0, MEMPROT_PERI2_RTCSLOW_1) + * @param lx Low segment Exec permission flag + * @param hx High segment Exec permission flag + * + * @return ESP_OK on success + * ESP_ERR_INVALID_ARG on NULL lx/hx args + * ESP_ERR_NOT_SUPPORTED on invalid mem_type */ -void esp_memprot_get_perm_exec(mem_type_prot_t mem_type, bool *lx, bool *hx); +esp_err_t esp_memprot_get_perm_exec(mem_type_prot_t mem_type, bool *lx, bool *hx); /** * @brief Returns the lowest address in required memory region * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * + * @return Required address or MEMPROT_INVALID_ADDRESS for invalid mem_type */ uint32_t esp_memprot_get_low_limit(mem_type_prot_t mem_type); @@ -482,6 +541,8 @@ uint32_t esp_memprot_get_low_limit(mem_type_prot_t mem_type); * @brief Returns the highest address in required memory region * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * + * @return Required address or MEMPROT_INVALID_ADDRESS for invalid mem_type */ uint32_t esp_memprot_get_high_limit(mem_type_prot_t mem_type); @@ -491,8 +552,11 @@ uint32_t esp_memprot_get_high_limit(mem_type_prot_t mem_type); * @param mem_type Memory protection area type (see mem_type_prot_t enum) * @param lr Low segment Read permission flag * @param hr High segment Read permission flag + * + * @return ESP_OK on success + * ESP_ERR_NOT_SUPPORTED on invalid mem_type */ -void esp_memprot_set_read_perm(mem_type_prot_t mem_type, bool lr, bool hr); +esp_err_t esp_memprot_set_read_perm(mem_type_prot_t mem_type, bool lr, bool hr); /** * @brief Sets WRITE permission bit for required memory region @@ -500,17 +564,23 @@ void esp_memprot_set_read_perm(mem_type_prot_t mem_type, bool lr, bool hr); * @param mem_type Memory protection area type (see mem_type_prot_t enum) * @param lr Low segment Write permission flag * @param hr High segment Write permission flag + * + * @return ESP_OK on success + * ESP_ERR_NOT_SUPPORTED on invalid mem_type */ -void esp_memprot_set_write_perm(mem_type_prot_t mem_type, bool lw, bool hw); +esp_err_t esp_memprot_set_write_perm(mem_type_prot_t mem_type, bool lw, bool hw); /** * @brief Sets EXECUTE permission bit for required memory region * - * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @param mem_type Memory protection area type (MEMPROT_IRAM0_SRAM, MEMPROT_IRAM0_RTCFAST, MEMPROT_PERI2_RTCSLOW_0, MEMPROT_PERI2_RTCSLOW_1) * @param lr Low segment Exec permission flag * @param hr High segment Exec permission flag + * + * @return ESP_OK on success + * ESP_ERR_NOT_SUPPORTED on invalid mem_type */ -void esp_memprot_set_exec_perm(mem_type_prot_t mem_type, bool lx, bool hx); +esp_err_t esp_memprot_set_exec_perm(mem_type_prot_t mem_type, bool lx, bool hx); #ifdef __cplusplus diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/rtc.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/rtc.h index 296292e21db..3ab96b37872 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/rtc.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/rtc.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/spiram.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/spiram.h index cc2b4c85497..70d07e61a85 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/spiram.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s2/spiram.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef __ESP_SPIRAM_H @@ -78,6 +70,15 @@ size_t esp_spiram_get_size(void); */ void esp_spiram_writeback_cache(void); +/** + * @brief get psram CS IO + * + * This interface should be called after PSRAM is enabled, otherwise it will + * return an invalid value -1/0xff. + * + * @return psram CS IO or -1/0xff if psram not enabled + */ +uint8_t esp_spiram_get_cs_io(void); /** @@ -91,6 +92,15 @@ void esp_spiram_writeback_cache(void); */ esp_err_t esp_spiram_reserve_dma_pool(size_t size); +/** + * @brief If SPI RAM(PSRAM) has been initialized + * + * @return + * - true SPI RAM has been initialized successfully + * - false SPI RAM hasn't been initialized or initialized failed + */ +bool esp_spiram_is_initialized(void); + #if CONFIG_SPIRAM_FETCH_INSTRUCTIONS extern int _instruction_reserved_start, _instruction_reserved_end; diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s3/clk.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s3/clk.h index 31902ebad01..a9ed3028527 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s3/clk.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s3/clk.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include "esp_private/esp_clk.h" diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s3/dport_access.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s3/dport_access.h index f3f7007a9cb..e5aedd2e1b1 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s3/dport_access.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s3/dport_access.h @@ -1,16 +1,8 @@ -// Copyright 2010-2020 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. +/* + * SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_DPORT_ACCESS_H_ #define _ESP_DPORT_ACCESS_H_ diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s3/esp_crypto_lock.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s3/esp_crypto_lock.h index 781ac077803..074754a86b2 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s3/esp_crypto_lock.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s3/esp_crypto_lock.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once @@ -26,6 +18,34 @@ extern "C" { * Other unrelated components must not use it. */ +/** + * @brief Acquire lock for Digital Signature(DS) cryptography peripheral + * + * Internally also takes the HMAC lock, as the DS depends on the HMAC peripheral + */ +void esp_crypto_ds_lock_acquire(void); + +/** + * @brief Release lock for Digital Signature(DS) cryptography peripheral + * + * Internally also releases the HMAC lock, as the DS depends on the HMAC peripheral + */ +void esp_crypto_ds_lock_release(void); + +/** + * @brief Acquire lock for HMAC cryptography peripheral + * + * Internally also takes the SHA & AES lock, as the HMAC depends on the SHA peripheral + */ +void esp_crypto_hmac_lock_acquire(void); + +/** + * @brief Release lock for HMAC cryptography peripheral + * + * Internally also releases the SHA & AES lock, as the HMAC depends on the SHA peripheral + */ +void esp_crypto_hmac_lock_release(void); + /** * @brief Acquire lock for the SHA and AES cryptography peripheral. * diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s3/esp_ds.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s3/esp_ds.h new file mode 100644 index 00000000000..46a1d22a543 --- /dev/null +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s3/esp_ds.h @@ -0,0 +1,192 @@ +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once +#include + +#include "esp_hmac.h" +#include "esp_err.h" +#include "soc/soc_caps.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ESP32S3_ERR_HW_CRYPTO_DS_HMAC_FAIL ESP_ERR_HW_CRYPTO_BASE + 0x1 /*!< HMAC peripheral problem */ +#define ESP32S3_ERR_HW_CRYPTO_DS_INVALID_KEY ESP_ERR_HW_CRYPTO_BASE + 0x2 /*!< given HMAC key isn't correct, + HMAC peripheral problem */ +#define ESP32S3_ERR_HW_CRYPTO_DS_INVALID_DIGEST ESP_ERR_HW_CRYPTO_BASE + 0x4 /*!< message digest check failed, + result is invalid */ +#define ESP32S3_ERR_HW_CRYPTO_DS_INVALID_PADDING ESP_ERR_HW_CRYPTO_BASE + 0x5 /*!< padding check failed, but result + is produced anyway and can be read*/ + +#define ESP_DS_IV_LEN 16 + +/* Length of parameter 'C' stored in flash */ +#define ESP_DS_C_LEN (12672 / 8) + +typedef struct esp_ds_context esp_ds_context_t; + +typedef enum { + ESP_DS_RSA_1024 = (1024 / 32) - 1, + ESP_DS_RSA_2048 = (2048 / 32) - 1, + ESP_DS_RSA_3072 = (3072 / 32) - 1, + ESP_DS_RSA_4096 = (4096 / 32) - 1 +} esp_digital_signature_length_t; + +/** + * Encrypted private key data. Recommended to store in flash in this format. + * + * @note This struct has to match to one from the ROM code! This documentation is mostly taken from there. + */ +typedef struct esp_digital_signature_data { + /** + * RSA LENGTH register parameters + * (number of words in RSA key & operands, minus one). + * + * Max value 127 (for RSA 4096). + * + * This value must match the length field encrypted and stored in 'c', + * or invalid results will be returned. (The DS peripheral will + * always use the value in 'c', not this value, so an attacker can't + * alter the DS peripheral results this way, it will just truncate or + * extend the message and the resulting signature in software.) + * + * @note In IDF, the enum type length is the same as of type unsigned, so they can be used interchangably. + * See the ROM code for the original declaration of struct \c ets_ds_data_t. + */ + esp_digital_signature_length_t rsa_length; + + /** + * IV value used to encrypt 'c' + */ + uint8_t iv[ESP_DS_IV_LEN]; + + /** + * Encrypted Digital Signature parameters. Result of AES-CBC encryption + * of plaintext values. Includes an encrypted message digest. + */ + uint8_t c[ESP_DS_C_LEN]; +} esp_ds_data_t; + +/** Plaintext parameters used by Digital Signature. + * + * Not used for signing with DS peripheral, but can be encrypted + * in-device by calling esp_ds_encrypt_params() + * + * @note This documentation is mostly taken from the ROM code. + */ +typedef struct { + uint32_t Y[SOC_RSA_MAX_BIT_LEN / 32]; //!< RSA exponent + uint32_t M[SOC_RSA_MAX_BIT_LEN / 32]; //!< RSA modulus + uint32_t Rb[SOC_RSA_MAX_BIT_LEN / 32]; //!< RSA r inverse operand + uint32_t M_prime; //!< RSA M prime operand + esp_digital_signature_length_t length; //!< RSA length +} esp_ds_p_data_t; + +/** + * Sign the message. + * + * This function is a wrapper around \c esp_ds_finish_sign() and \c esp_ds_start_sign(), so do not use them + * in parallel. + * It blocks until the signing is finished and then returns the signature. + * + * @note This function locks the HMAC, SHA, AES and RSA components during its entire execution time. + * + * @param message the message to be signed; its length is determined by data->rsa_length + * @param data the encrypted signing key data (AES encrypted RSA key + IV) + * @param key_id the HMAC key ID determining the HMAC key of the HMAC which will be used to decrypt the + * signing key data + * @param signature the destination of the signature, should be (data->rsa_length + 1)*4 bytes long + * + * @return + * - ESP_OK if successful, the signature was written to the parameter \c signature. + * - ESP_ERR_INVALID_ARG if one of the parameters is NULL or data->rsa_length is too long or 0 + * - ESP_ERR_HW_CRYPTO_DS_HMAC_FAIL if there was an HMAC failure during retrieval of the decryption key + * - ESP_ERR_NO_MEM if there hasn't been enough memory to allocate the context object + * - ESP_ERR_HW_CRYPTO_DS_INVALID_KEY if there's a problem with passing the HMAC key to the DS component + * - ESP_ERR_HW_CRYPTO_DS_INVALID_DIGEST if the message digest didn't match; the signature is invalid. + * - ESP_ERR_HW_CRYPTO_DS_INVALID_PADDING if the message padding is incorrect, the signature can be read though + * since the message digest matches. + */ +esp_err_t esp_ds_sign(const void *message, + const esp_ds_data_t *data, + hmac_key_id_t key_id, + void *signature); + +/** + * Start the signing process. + * + * This function yields a context object which needs to be passed to \c esp_ds_finish_sign() to finish the signing + * process. + * + * @note This function locks the HMAC, SHA, AES and RSA components, so the user has to ensure to call + * \c esp_ds_finish_sign() in a timely manner. + * + * @param message the message to be signed; its length is determined by data->rsa_length + * @param data the encrypted signing key data (AES encrypted RSA key + IV) + * @param key_id the HMAC key ID determining the HMAC key of the HMAC which will be used to decrypt the + * signing key data + * @param esp_ds_ctx the context object which is needed for finishing the signing process later + * + * @return + * - ESP_OK if successful, the ds operation was started now and has to be finished with \c esp_ds_finish_sign() + * - ESP_ERR_INVALID_ARG if one of the parameters is NULL or data->rsa_length is too long or 0 + * - ESP_ERR_HW_CRYPTO_DS_HMAC_FAIL if there was an HMAC failure during retrieval of the decryption key + * - ESP_ERR_NO_MEM if there hasn't been enough memory to allocate the context object + * - ESP_ERR_HW_CRYPTO_DS_INVALID_KEY if there's a problem with passing the HMAC key to the DS component + */ +esp_err_t esp_ds_start_sign(const void *message, + const esp_ds_data_t *data, + hmac_key_id_t key_id, + esp_ds_context_t **esp_ds_ctx); + +/** + * Return true if the DS peripheral is busy, otherwise false. + * + * @note Only valid if \c esp_ds_start_sign() was called before. + */ +bool esp_ds_is_busy(void); + +/** + * Finish the signing process. + * + * @param signature the destination of the signature, should be (data->rsa_length + 1)*4 bytes long + * @param esp_ds_ctx the context object retreived by \c esp_ds_start_sign() + * + * @return + * - ESP_OK if successful, the ds operation has been finished and the result is written to signature. + * - ESP_ERR_INVALID_ARG if one of the parameters is NULL + * - ESP_ERR_HW_CRYPTO_DS_INVALID_DIGEST if the message digest didn't match; the signature is invalid. + * - ESP_ERR_HW_CRYPTO_DS_INVALID_PADDING if the message padding is incorrect, the signature can be read though + * since the message digest matches. + */ +esp_err_t esp_ds_finish_sign(void *signature, esp_ds_context_t *esp_ds_ctx); + +/** + * Encrypt the private key parameters. + * + * @param data Output buffer to store encrypted data, suitable for later use generating signatures. + * The allocated memory must be in internal memory and word aligned since it's filled by DMA. Both is asserted + * at run time. + * @param iv Pointer to 16 byte IV buffer, will be copied into 'data'. Should be randomly generated bytes each time. + * @param p_data Pointer to input plaintext key data. The expectation is this data will be deleted after this process + * is done and 'data' is stored. + * @param key Pointer to 32 bytes of key data. Type determined by key_type parameter. The expectation is the + * corresponding HMAC key will be stored to efuse and then permanently erased. + * + * @return + * - ESP_OK if successful, the ds operation has been finished and the result is written to signature. + * - ESP_ERR_INVALID_ARG if one of the parameters is NULL or p_data->rsa_length is too long + */ +esp_err_t esp_ds_encrypt_params(esp_ds_data_t *data, + const void *iv, + const esp_ds_p_data_t *p_data, + const void *key); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s3/esp_hmac.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s3/esp_hmac.h new file mode 100644 index 00000000000..101dce556b6 --- /dev/null +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s3/esp_hmac.h @@ -0,0 +1,84 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "esp_err.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The possible efuse keys for the HMAC peripheral + */ +typedef enum { + HMAC_KEY0 = 0, + HMAC_KEY1, + HMAC_KEY2, + HMAC_KEY3, + HMAC_KEY4, + HMAC_KEY5, + HMAC_KEY_MAX +} hmac_key_id_t; + +/** + * @brief + * Calculate the HMAC of a given message. + * + * Calculate the HMAC \c hmac of a given message \c message with length \c message_len. + * SHA256 is used for the calculation (fixed on ESP32S3). + * + * @note Uses the HMAC peripheral in "upstream" mode. + * + * @param key_id Determines which of the 6 key blocks in the efuses should be used for the HMAC calcuation. + * The corresponding purpose field of the key block in the efuse must be set to the HMAC upstream purpose value. + * @param message the message for which to calculate the HMAC + * @param message_len message length + * @param [out] hmac the hmac result; the buffer behind the provided pointer must be 32 bytes long + * + * @return + * * ESP_OK, if the calculation was successful, + * * ESP_ERR_INVALID_ARG if message or hmac is a nullptr or if key_id out of range + * * ESP_FAIL, if the hmac calculation failed + */ +esp_err_t esp_hmac_calculate(hmac_key_id_t key_id, + const void *message, + size_t message_len, + uint8_t *hmac); + +/** + * @brief Use HMAC peripheral in Downstream mode to re-enable the JTAG, if it is not permanently disabled by HW. + * In downstream mode, HMAC calculations performed by peripheral are used internally and not provided back to user. + * + * @param key_id Determines which of the 6 key blocks in the efuses should be used for the HMAC calculation. + * The corresponding purpose field of the key block in the efuse must be set to HMAC downstream purpose. + * + * @param token Pre calculated HMAC value of the 32-byte 0x00 using SHA-256 and the known private HMAC key. The key is already + * programmed to a eFuse key block. The key block number is provided as the first parameter to this function. + * + * @return + * * ESP_OK, if the calculation was successful, + * if the calculated HMAC value matches with provided token, + * JTAG will be re-enable otherwise JTAG will remain disabled. + * Return value does not indicate the JTAG status. + * * ESP_FAIL, if the hmac calculation failed or JTAG is permanently disabled by EFUSE_HARD_DIS_JTAG eFuse parameter. + * * ESP_ERR_INVALID_ARG, invalid input arguments + */ +esp_err_t esp_hmac_jtag_enable(hmac_key_id_t key_id, const uint8_t *token); + +/** + * @brief Disable the JTAG which might be enabled using the HMAC downstream mode. This function just clears the result generated + * by calling esp_hmac_jtag_enable() API. + * + * @return + * * ESP_OK return ESP_OK after writing the HMAC_SET_INVALIDATE_JTAG_REG with value 1. + */ +esp_err_t esp_hmac_jtag_disable(void); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s3/memprot.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s3/memprot.h index 7e47a8cfa33..948e0676680 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s3/memprot.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s3/memprot.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /* INTERNAL API diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s3/rtc.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s3/rtc.h index 296292e21db..3ab96b37872 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s3/rtc.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s3/rtc.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s3/spiram.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s3/spiram.h index 105a60543e0..067c3d27bf8 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s3/spiram.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32s3/spiram.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef __ESP_SPIRAM_H @@ -78,7 +70,24 @@ size_t esp_spiram_get_size(void); */ void esp_spiram_writeback_cache(void); +/** + * @brief If SPI RAM(PSRAM) has been initialized + * + * @return + * - true SPI RAM has been initialized successfully + * - false SPI RAM hasn't been initialized or initialized failed + */ +bool esp_spiram_is_initialized(void); +/** + * @brief get psram CS IO + * + * This interface should be called after PSRAM is enabled, otherwise it will + * return an invalid value -1/0xff. + * + * @return psram CS IO or -1/0xff if psram not enabled + */ +uint8_t esp_spiram_get_cs_io(void); /** * @brief Reserve a pool of internal memory for specific DMA/internal allocations @@ -91,6 +100,15 @@ void esp_spiram_writeback_cache(void); */ esp_err_t esp_spiram_reserve_dma_pool(size_t size); +/** + * @brief If SPI RAM(PSRAM) has been initialized + * + * @return + * - true SPI RAM has been initialized successfully + * - false SPI RAM hasn't been initialized or initialized failed + */ +bool esp_spiram_is_initialized(void); + #if CONFIG_SPIRAM_FETCH_INSTRUCTIONS extern int _instruction_reserved_start, _instruction_reserved_end; diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/rtc_wdt.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/rtc_wdt.h index 7d13e6a4f75..97d1d8425bd 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/rtc_wdt.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/rtc_wdt.h @@ -1,16 +1,8 @@ -// Copyright 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. +/* + * SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /* Recommendation of using API RTC_WDT. 1) Setting and enabling rtc_wdt: diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/spinlock.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/spinlock.h index 66baa93066b..97cc9e514ab 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/spinlock.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/spinlock.h @@ -1,16 +1,8 @@ -// Copyright 2015-2019 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc_log.h b/tools/sdk/esp32/include/esp_hw_support/include/soc_log.h index ea2ecce8f80..64268433fb9 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc_log.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc_log.h @@ -1,16 +1,8 @@ -// Copyright 2016-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2016-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include "esp_rom_sys.h" diff --git a/tools/sdk/esp32/include/esp_hw_support/port/esp32/private_include/regi2c_apll.h b/tools/sdk/esp32/include/esp_hw_support/port/esp32/private_include/regi2c_apll.h index db490275466..f2651045aec 100644 --- a/tools/sdk/esp32/include/esp_hw_support/port/esp32/private_include/regi2c_apll.h +++ b/tools/sdk/esp32/include/esp_hw_support/port/esp32/private_include/regi2c_apll.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32/include/esp_hw_support/port/esp32/private_include/regi2c_bbpll.h b/tools/sdk/esp32/include/esp_hw_support/port/esp32/private_include/regi2c_bbpll.h index 8a9fcef3724..b2d07574ab4 100644 --- a/tools/sdk/esp32/include/esp_hw_support/port/esp32/private_include/regi2c_bbpll.h +++ b/tools/sdk/esp32/include/esp_hw_support/port/esp32/private_include/regi2c_bbpll.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32/include/esp_hw_support/port/esp32/regi2c_ctrl.h b/tools/sdk/esp32/include/esp_hw_support/port/esp32/regi2c_ctrl.h index 69f2919207f..ea2870e99b1 100644 --- a/tools/sdk/esp32/include/esp_hw_support/port/esp32/regi2c_ctrl.h +++ b/tools/sdk/esp32/include/esp_hw_support/port/esp32/regi2c_ctrl.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32/include/esp_hw_support/port/esp32/rtc_clk_common.h b/tools/sdk/esp32/include/esp_hw_support/port/esp32/rtc_clk_common.h index dec179e3bef..6721cf6f418 100644 --- a/tools/sdk/esp32/include/esp_hw_support/port/esp32/rtc_clk_common.h +++ b/tools/sdk/esp32/include/esp_hw_support/port/esp32/rtc_clk_common.h @@ -1,16 +1,8 @@ -// Copyright 2015-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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32/include/esp_hw_support/port/esp32/spiram_psram.h b/tools/sdk/esp32/include/esp_hw_support/port/esp32/spiram_psram.h index 263fb924dc2..abcc98f0ff3 100644 --- a/tools/sdk/esp32/include/esp_hw_support/port/esp32/spiram_psram.h +++ b/tools/sdk/esp32/include/esp_hw_support/port/esp32/spiram_psram.h @@ -63,6 +63,13 @@ psram_size_t psram_get_size(void); */ esp_err_t psram_enable(psram_cache_mode_t mode, psram_vaddr_mode_t vaddrmode); +/** + * @brief get psram CS IO + * + * @return psram CS IO + */ +uint8_t psram_get_cs_io(void); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32/include/esp_ipc/include/esp_ipc.h b/tools/sdk/esp32/include/esp_ipc/include/esp_ipc.h index 477b3d0af4e..5e02c460bce 100644 --- a/tools/sdk/esp32/include/esp_ipc/include/esp_ipc.h +++ b/tools/sdk/esp32/include/esp_ipc/include/esp_ipc.h @@ -20,6 +20,9 @@ #ifdef __cplusplus extern "C" { #endif + +#if !defined(CONFIG_FREERTOS_UNICORE) || defined(CONFIG_APPTRACE_GCOV_ENABLE) + /** @cond */ typedef void (*esp_ipc_func_t)(void* arg); /** @endcond */ @@ -85,6 +88,7 @@ esp_err_t esp_ipc_call(uint32_t cpu_id, esp_ipc_func_t func, void* arg); */ esp_err_t esp_ipc_call_blocking(uint32_t cpu_id, esp_ipc_func_t func, void* arg); +#endif // not CONFIG_FREERTOS_UNICORE or CONFIG_APPTRACE_GCOV_ENABLE #ifdef __cplusplus } diff --git a/tools/sdk/esp32/include/esp_ipc/include/esp_ipc_isr.h b/tools/sdk/esp32/include/esp_ipc/include/esp_ipc_isr.h new file mode 100644 index 00000000000..7b6e060f1d5 --- /dev/null +++ b/tools/sdk/esp32/include/esp_ipc/include/esp_ipc_isr.h @@ -0,0 +1,117 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "sdkconfig.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef CONFIG_ESP_IPC_ISR_ENABLE + +/** @cond */ +typedef void (*esp_ipc_isr_func_t)(void* arg); +/** @endcond */ + +/** + * @brief Initialize inter-processor call module which based on #4 high-interrupt. + * + * This function is called on CPU start and should not be called from the application. + * + * This function starts two tasks, one on each CPU. These tasks register + * #4 High-interrupt and after that, the tasks are deleted. + * The next API functions work with this functionality: + * esp_ipc_isr_asm_call + * esp_ipc_isr_asm_call_blocking + * They allow to run an asm function on other CPU. + */ +void esp_ipc_isr_init(void); + +/** + * @brief Execute an asm function on the other CPU (uses the #4 high-priority interrupt) + * + * @note In single-core mode, it is not available. + * This function calls the #4 high-priority interrupt on the other CPU. + * The given function is called in the context of the interrupt by CALLX0 command and + * operates with registers a2, a3, a4. + * + * @param[in] func Pointer to a function of type void func(void* arg) to be executed + * @param[in] arg Arbitrary argument of type void* to be passed into the function + */ +void esp_ipc_isr_asm_call(esp_ipc_isr_func_t func, void* arg); + +/** + * @brief Execute an asm function on the other CPU and blocks until it completes (uses the #4 high-priority interrupt) + * + * @note In single-core mode, it is not available. + * This function calls the #4 high-priority interrupt on the other CPU. + * The given function is called in the context of the interrupt by CALLX0 command. + * + * @param[in] func Pointer to a function of type void func(void* arg) to be executed + * @param[in] arg Arbitrary argument of type void* to be passed into the function + */ +void esp_ipc_isr_asm_call_blocking(esp_ipc_isr_func_t func, void* arg); + +/** + * @brief Stall the other CPU and the current CPU disables interrupts with level 3 and lower. + * + * @note In single-core mode, it is not available. + * This function calls the #4 high-priority interrupt on the other CPU. + * The esp_ipc_isr_finish_cmd() function is called on the other CPU in the context of the #4 high-priority interrupt. + * The esp_ipc_isr_finish_cmd is called by CALLX0 command. + * It is waiting for the end command. The command will be sent by esp_ipc_isr_release_other_cpu(). + * This function is used for DPORT workaround. + * + * This function blocks other CPU until the release call esp_ipc_isr_release_other_cpu(). + * + * This fucntion is used for the DPORT workaround: stall other cpu that this cpu is pending to access dport register start. + */ +void esp_ipc_isr_stall_other_cpu(void); + +/** + * @brief Release the other CPU + * + * @note In single-core mode, it is not available. + * This function will send the end command to release the stall other CPU. + * This function is used for DPORT workaround: stall other cpu that this cpu is pending to access dport register end. + * + */ +void esp_ipc_isr_release_other_cpu(void); + +/** + * @brief Pause stall the other CPU + */ +void esp_ipc_isr_stall_pause(void); + +/** + * @brief Abort stall the other CPU + * + * This routine does not stop the stall routines in any way that is recoverable. + * Please only call in case of panic(). + * Used in panic code: the enter_critical stuff may be messed up so we just stop everything without checking the mux. + */ +void esp_ipc_isr_stall_abort(void); + +/** + * @brief Resume stall the other CPU + */ +void esp_ipc_isr_stall_resume(void); + +#else // not CONFIG_ESP_IPC_ISR_ENABLE + +#define esp_ipc_isr_stall_other_cpu() +#define esp_ipc_isr_release_other_cpu() +#define esp_ipc_isr_stall_pause() +#define esp_ipc_isr_stall_abort() +#define esp_ipc_isr_stall_resume() + +#endif // CONFIG_ESP_IPC_ISR_ENABLE + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32/include/esp_lcd/include/esp_lcd_panel_io.h b/tools/sdk/esp32/include/esp_lcd/include/esp_lcd_panel_io.h index c362180f53e..eebcabf42b4 100644 --- a/tools/sdk/esp32/include/esp_lcd/include/esp_lcd_panel_io.h +++ b/tools/sdk/esp32/include/esp_lcd/include/esp_lcd_panel_io.h @@ -9,6 +9,7 @@ #include "esp_err.h" #include "esp_lcd_types.h" #include "soc/soc_caps.h" +#include "hal/lcd_types.h" #ifdef __cplusplus extern "C" { @@ -28,14 +29,13 @@ typedef struct esp_lcd_i80_bus_t *esp_lcd_i80_bus_handle_t; /*!< Type of LCD i * * @param[in] io LCD panel IO handle, which is created by other factory API like `esp_lcd_new_panel_io_spi()` * @param[in] lcd_cmd The specific LCD command - * @param[in] lcd_cmd_bits Length of LCD command, in bits (e.g. 8 bits or 16 bits) * @param[in] param Buffer that holds the command specific parameters, set to NULL if no parameter is needed for the command * @param[in] param_size Size of `param` in memory, in bytes, set to zero if no parameter is needed for the command * @return * - ESP_ERR_INVALID_ARG if parameter is invalid * - ESP_OK on success */ -esp_err_t esp_lcd_panel_io_tx_param(esp_lcd_panel_io_handle_t io, int lcd_cmd, int lcd_cmd_bits, const void *param, size_t param_size); +esp_err_t esp_lcd_panel_io_tx_param(esp_lcd_panel_io_handle_t io, int lcd_cmd, const void *param, size_t param_size); /** * @brief Transmit LCD RGB data @@ -47,14 +47,13 @@ esp_err_t esp_lcd_panel_io_tx_param(esp_lcd_panel_io_handle_t io, int lcd_cmd, i * * @param[in] io LCD panel IO handle, which is created by factory API like `esp_lcd_new_panel_io_spi()` * @param[in] lcd_cmd The specific LCD command - * @param[in] lcd_cmd_bits Length of LCD command, in bits (e.g. 8 bits or 16 bits) * @param[in] color Buffer that holds the RGB color data * @param[in] color_size Size of `color` in memory, in bytes * @return * - ESP_ERR_INVALID_ARG if parameter is invalid * - ESP_OK on success */ -esp_err_t esp_lcd_panel_io_tx_color(esp_lcd_panel_io_handle_t io, int lcd_cmd, int lcd_cmd_bits, const void *color, size_t color_size); +esp_err_t esp_lcd_panel_io_tx_color(esp_lcd_panel_io_handle_t io, int lcd_cmd, const void *color, size_t color_size); /** * @brief Destory LCD panel IO handle (deinitialize panel and free all corresponding resource) @@ -76,10 +75,13 @@ typedef struct { unsigned int pclk_hz; /*!< Frequency of pixel clock */ size_t trans_queue_depth; /*!< Size of internal transaction queue */ bool (*on_color_trans_done)(esp_lcd_panel_io_handle_t panel_io, void *user_data, void *event_data); /*!< Callback, invoked when color data transfer has finished */ - void *user_data; /*!< User private data, passed directly to on_trans_frame_done's user_data */ + void *user_data; /*!< User private data, passed directly to on_trans_frame_done's user_data */ + int lcd_cmd_bits; /*!< Bit-width of LCD command */ + int lcd_param_bits; /*!< Bit-width of LCD parameter */ struct { unsigned int dc_as_cmd_phase: 1; /*!< D/C line value is encoded into SPI transaction command phase */ unsigned int dc_low_on_data: 1; /*!< If this flag is enabled, DC line = 0 means transfer data, DC line = 1 means transfer command; vice versa */ + unsigned int octal_mode: 1; /*!< transmit with octal mode (8 data lines), this mode is used to simulate Intel 8080 timing */ } flags; } esp_lcd_panel_io_spi_config_t; @@ -102,6 +104,8 @@ typedef struct { void *user_data; /*!< User private data, passed directly to on_trans_frame_done's user_data */ size_t control_phase_bytes; /*!< I2C LCD panel will encode control information (e.g. D/C seclection) into control phase, in several bytes */ unsigned int dc_bit_offset; /*!< Offset of the D/C selection bit in control phase */ + int lcd_cmd_bits; /*!< Bit-width of LCD command */ + int lcd_param_bits; /*!< Bit-width of LCD parameter */ struct { unsigned int dc_low_on_data: 1; /*!< If this flag is enabled, DC line = 0 means transfer data, DC line = 1 means transfer command; vice versa */ } flags; @@ -127,8 +131,9 @@ esp_err_t esp_lcd_new_panel_io_i2c(esp_lcd_i2c_bus_handle_t bus, const esp_lcd_p typedef struct { int dc_gpio_num; /*!< GPIO used for D/C line */ int wr_gpio_num; /*!< GPIO used for WR line */ + lcd_clock_source_t clk_src; /*!< Clock source for the I80 LCD peripheral */ int data_gpio_nums[SOC_LCD_I80_BUS_WIDTH]; /*!< GPIOs used for data lines */ - size_t data_width; /*!< Number of data lines, 8 or 16 */ + size_t bus_width; /*!< Number of data lines, 8 or 16 */ size_t max_transfer_bytes; /*!< Maximum transfer size, this determines the length of internal DMA link */ } esp_lcd_i80_bus_config_t; @@ -160,11 +165,13 @@ esp_err_t esp_lcd_del_i80_bus(esp_lcd_i80_bus_handle_t bus); * @brief Panel IO configuration structure, for intel 8080 interface */ typedef struct { - int cs_gpio_num; /*!< GPIO used for CS line */ + int cs_gpio_num; /*!< GPIO used for CS line, set to -1 will declaim exclusively use of I80 bus */ unsigned int pclk_hz; /*!< Frequency of pixel clock */ size_t trans_queue_depth; /*!< Transaction queue size, larger queue, higher throughput */ bool (*on_color_trans_done)(esp_lcd_panel_io_handle_t panel_io, void *user_data, void *event_data); /*!< Callback, invoked when color data was tranferred done */ - void *user_data; /*!< User private data, passed directly to on_trans_done's user_data */ + void *user_data; /*!< User private data, passed directly to on_trans_done's user_data */ + int lcd_cmd_bits; /*!< Bit-width of LCD command */ + int lcd_param_bits; /*!< Bit-width of LCD parameter */ struct { unsigned int dc_idle_level: 1; /*!< Level of DC line in IDLE phase */ unsigned int dc_cmd_level: 1; /*!< Level of DC line in CMD phase */ @@ -172,7 +179,7 @@ typedef struct { unsigned int dc_data_level: 1; /*!< Level of DC line in DATA phase */ } dc_levels; /*!< Each i80 device might have its own D/C control logic */ struct { - unsigned int invert_cs: 1; /*!< Whether to invert the CS line */ + unsigned int cs_active_high: 1; /*!< If set, a high level of CS line will select the device, otherwise, CS line is low level active */ unsigned int reverse_color_bits: 1; /*!< Reverse the data bits, D[N:0] -> D[0:N] */ unsigned int swap_color_bytes: 1; /*!< Swap adjacent two color bytes */ unsigned int pclk_active_neg: 1; /*!< The display will write data lines when there's a falling edge on WR signal (a.k.a the PCLK) */ diff --git a/tools/sdk/esp32/include/esp_lcd/include/esp_lcd_panel_rgb.h b/tools/sdk/esp32/include/esp_lcd/include/esp_lcd_panel_rgb.h index 0847e84bd21..2ddd2b6b9a6 100644 --- a/tools/sdk/esp32/include/esp_lcd/include/esp_lcd_panel_rgb.h +++ b/tools/sdk/esp32/include/esp_lcd/include/esp_lcd_panel_rgb.h @@ -9,6 +9,7 @@ #include "esp_err.h" #include "esp_lcd_types.h" #include "soc/soc_caps.h" +#include "hal/lcd_types.h" #ifdef __cplusplus extern "C" { @@ -41,6 +42,7 @@ typedef struct { * @brief LCD RGB panel configuration structure */ typedef struct { + lcd_clock_source_t clk_src; /*!< Clock source for the RGB LCD peripheral */ esp_lcd_rgb_timing_t timings; /*!< RGB timing parameters */ size_t data_width; /*!< Number of data lines */ int hsync_gpio_num; /*!< GPIO used for HSYNC signal */ @@ -54,6 +56,7 @@ typedef struct { struct { unsigned int disp_active_low: 1; /*!< If this flag is enabled, a low level of display control signal can turn the screen on; vice versa */ unsigned int relax_on_idle: 1; /*!< If this flag is enabled, the host won't refresh the LCD if nothing changed in host's frame buffer (this is usefull for LCD with built-in GRAM) */ + unsigned int fb_in_psram: 1; /*!< If this flag is enabled, the frame buffer will be allocated from PSRAM preferentially */ } flags; } esp_lcd_rgb_panel_config_t; diff --git a/tools/sdk/esp32/include/esp_lcd/include/esp_lcd_panel_vendor.h b/tools/sdk/esp32/include/esp_lcd/include/esp_lcd_panel_vendor.h index ac98cc3913d..dde8be68d3b 100644 --- a/tools/sdk/esp32/include/esp_lcd/include/esp_lcd_panel_vendor.h +++ b/tools/sdk/esp32/include/esp_lcd/include/esp_lcd_panel_vendor.h @@ -39,6 +39,19 @@ typedef struct { */ esp_err_t esp_lcd_new_panel_st7789(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config, esp_lcd_panel_handle_t *ret_panel); +/** + * @brief Create LCD panel for model NT35510 + * + * @param[in] io LCD panel IO handle + * @param[in] panel_dev_config general panel device configuration + * @param[out] ret_panel Returned LCD panel handle + * @return + * - ESP_ERR_INVALID_ARG if parameter is invalid + * - ESP_ERR_NO_MEM if out of memory + * - ESP_OK on success + */ +esp_err_t esp_lcd_new_panel_nt35510(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config, esp_lcd_panel_handle_t *ret_panel); + /** * @brief Create LCD panel for model SSD1306 * diff --git a/tools/sdk/esp32/include/esp_lcd/interface/esp_lcd_panel_io_interface.h b/tools/sdk/esp32/include/esp_lcd/interface/esp_lcd_panel_io_interface.h index b6b85564cd5..2faa6fab268 100644 --- a/tools/sdk/esp32/include/esp_lcd/interface/esp_lcd_panel_io_interface.h +++ b/tools/sdk/esp32/include/esp_lcd/interface/esp_lcd_panel_io_interface.h @@ -25,14 +25,13 @@ struct esp_lcd_panel_io_t { * * @param[in] io LCD panel IO handle, which is created by other factory API like `esp_lcd_new_panel_io_spi()` * @param[in] lcd_cmd The specific LCD command - * @param[in] lcd_cmd_bits Length of LCD command, in bits (e.g. 8 bits or 16 bits) * @param[in] param Buffer that holds the command specific parameters, set to NULL if no parameter is needed for the command * @param[in] param_size Size of `param` in memory, in bytes, set to zero if no parameter is needed for the command * @return * - ESP_ERR_INVALID_ARG if parameter is invalid * - ESP_OK on success */ - esp_err_t (*tx_param)(esp_lcd_panel_io_t *io, int lcd_cmd, int lcd_cmd_bits, const void *param, size_t param_size); + esp_err_t (*tx_param)(esp_lcd_panel_io_t *io, int lcd_cmd, const void *param, size_t param_size); /** * @brief Transmit LCD RGB data @@ -41,14 +40,13 @@ struct esp_lcd_panel_io_t { * * @param[in] io LCD panel IO handle, which is created by other factory API like `esp_lcd_new_panel_io_spi()` * @param[in] lcd_cmd The specific LCD command - * @param[in] lcd_cmd_bits Length of LCD command, in bits (e.g. 8 bits or 16 bits) * @param[in] color Buffer that holds the RGB color data * @param[in] color_size Size of `color` in memory, in bytes * @return * - ESP_ERR_INVALID_ARG if parameter is invalid * - ESP_OK on success */ - esp_err_t (*tx_color)(esp_lcd_panel_io_t *io, int lcd_cmd, int lcd_cmd_bits, const void *color, size_t color_size); + esp_err_t (*tx_color)(esp_lcd_panel_io_t *io, int lcd_cmd, const void *color, size_t color_size); /** * @brief Destory LCD panel IO handle (deinitialize all and free resource) diff --git a/tools/sdk/esp32/include/esp_littlefs/src/littlefs/lfs.h b/tools/sdk/esp32/include/esp_littlefs/src/littlefs/lfs.h index 35bbbabfa7b..ad491627fe1 100644 --- a/tools/sdk/esp32/include/esp_littlefs/src/littlefs/lfs.h +++ b/tools/sdk/esp32/include/esp_littlefs/src/littlefs/lfs.h @@ -9,6 +9,7 @@ #include #include +#include "lfs_util.h" #ifdef __cplusplus extern "C" @@ -21,7 +22,7 @@ extern "C" // Software library version // Major (top-nibble), incremented on backwards incompatible changes // Minor (bottom-nibble), incremented on feature additions -#define LFS_VERSION 0x00020002 +#define LFS_VERSION 0x00020004 #define LFS_VERSION_MAJOR (0xffff & (LFS_VERSION >> 16)) #define LFS_VERSION_MINOR (0xffff & (LFS_VERSION >> 0)) @@ -123,20 +124,25 @@ enum lfs_type { enum lfs_open_flags { // open flags LFS_O_RDONLY = 1, // Open a file as read only +#ifndef LFS_READONLY LFS_O_WRONLY = 2, // Open a file as write only LFS_O_RDWR = 3, // Open a file as read and write LFS_O_CREAT = 0x0100, // Create a file if it does not exist LFS_O_EXCL = 0x0200, // Fail if a file already exists LFS_O_TRUNC = 0x0400, // Truncate the existing file to zero size LFS_O_APPEND = 0x0800, // Move to end of file on every write +#endif // internally used flags +#ifndef LFS_READONLY LFS_F_DIRTY = 0x010000, // File does not match storage LFS_F_WRITING = 0x020000, // File has been written since last flush +#endif LFS_F_READING = 0x040000, // File has been read since last flush - LFS_F_ERRED = 0x080000, // An error occured during write +#ifndef LFS_READONLY + LFS_F_ERRED = 0x080000, // An error occurred during write +#endif LFS_F_INLINE = 0x100000, // Currently inlined in directory entry - LFS_F_OPENED = 0x200000, // File has been opened }; // File seek flags @@ -174,6 +180,16 @@ struct lfs_config { // are propogated to the user. int (*sync)(const struct lfs_config *c); +#ifdef LFS_THREADSAFE + // Lock the underlying block device. Negative error codes + // are propogated to the user. + int (*lock)(const struct lfs_config *c); + + // Unlock the underlying block device. Negative error codes + // are propogated to the user. + int (*unlock)(const struct lfs_config *c); +#endif + // Minimum size of a block read. All read operations will be a // multiple of this value. lfs_size_t read_size; @@ -191,7 +207,7 @@ struct lfs_config { // Number of erasable blocks on the device. lfs_size_t block_count; - // Number of erase cycles before littlefs evicts metadata logs and moves + // Number of erase cycles before littlefs evicts metadata logs and moves // the metadata to another block. Suggested values are in the // range 100-1000, with large values having better performance at the cost // of less consistent wear distribution. @@ -240,6 +256,12 @@ struct lfs_config { // larger attributes size but must be <= LFS_ATTR_MAX. Defaults to // LFS_ATTR_MAX when zero. lfs_size_t attr_max; + + // Optional upper limit on total space given to metadata pairs in bytes. On + // devices with large blocks (e.g. 128kB) setting this to a low size (2-8kB) + // can help bound the metadata compaction time. Must be <= block_size. + // Defaults to block_size when zero. + lfs_size_t metadata_max; }; // File info structure @@ -399,6 +421,7 @@ typedef struct lfs { /// Filesystem functions /// +#ifndef LFS_READONLY // Format a block device with the littlefs // // Requires a littlefs object and config struct. This clobbers the littlefs @@ -407,6 +430,7 @@ typedef struct lfs { // // Returns a negative error code on failure. int lfs_format(lfs_t *lfs, const struct lfs_config *config); +#endif // Mounts a littlefs // @@ -426,12 +450,15 @@ int lfs_unmount(lfs_t *lfs); /// General operations /// +#ifndef LFS_READONLY // Removes a file or directory // // If removing a directory, the directory must be empty. // Returns a negative error code on failure. int lfs_remove(lfs_t *lfs, const char *path); +#endif +#ifndef LFS_READONLY // Rename or move a file or directory // // If the destination exists, it must match the source in type. @@ -439,6 +466,7 @@ int lfs_remove(lfs_t *lfs, const char *path); // // Returns a negative error code on failure. int lfs_rename(lfs_t *lfs, const char *oldpath, const char *newpath); +#endif // Find info about a file or directory // @@ -461,6 +489,7 @@ int lfs_stat(lfs_t *lfs, const char *path, struct lfs_info *info); lfs_ssize_t lfs_getattr(lfs_t *lfs, const char *path, uint8_t type, void *buffer, lfs_size_t size); +#ifndef LFS_READONLY // Set custom attributes // // Custom attributes are uniquely identified by an 8-bit type and limited @@ -470,13 +499,16 @@ lfs_ssize_t lfs_getattr(lfs_t *lfs, const char *path, // Returns a negative error code on failure. int lfs_setattr(lfs_t *lfs, const char *path, uint8_t type, const void *buffer, lfs_size_t size); +#endif +#ifndef LFS_READONLY // Removes a custom attribute // // If an attribute is not found, nothing happens. // // Returns a negative error code on failure. int lfs_removeattr(lfs_t *lfs, const char *path, uint8_t type); +#endif /// File operations /// @@ -525,6 +557,7 @@ int lfs_file_sync(lfs_t *lfs, lfs_file_t *file); lfs_ssize_t lfs_file_read(lfs_t *lfs, lfs_file_t *file, void *buffer, lfs_size_t size); +#ifndef LFS_READONLY // Write data to file // // Takes a buffer and size indicating the data to write. The file will not @@ -533,6 +566,7 @@ lfs_ssize_t lfs_file_read(lfs_t *lfs, lfs_file_t *file, // Returns the number of bytes written, or a negative error code on failure. lfs_ssize_t lfs_file_write(lfs_t *lfs, lfs_file_t *file, const void *buffer, lfs_size_t size); +#endif // Change the position of the file // @@ -541,10 +575,12 @@ lfs_ssize_t lfs_file_write(lfs_t *lfs, lfs_file_t *file, lfs_soff_t lfs_file_seek(lfs_t *lfs, lfs_file_t *file, lfs_soff_t off, int whence); +#ifndef LFS_READONLY // Truncates the size of the file to the specified size // // Returns a negative error code on failure. int lfs_file_truncate(lfs_t *lfs, lfs_file_t *file, lfs_off_t size); +#endif // Return the position of the file // @@ -567,10 +603,12 @@ lfs_soff_t lfs_file_size(lfs_t *lfs, lfs_file_t *file); /// Directory operations /// +#ifndef LFS_READONLY // Create a directory // // Returns a negative error code on failure. int lfs_mkdir(lfs_t *lfs, const char *path); +#endif // Open a directory // @@ -632,6 +670,7 @@ lfs_ssize_t lfs_fs_size(lfs_t *lfs); // Returns a negative error code on failure. int lfs_fs_traverse(lfs_t *lfs, int (*cb)(void*, lfs_block_t), void *data); +#ifndef LFS_READONLY #ifdef LFS_MIGRATE // Attempts to migrate a previous version of littlefs // @@ -646,6 +685,7 @@ int lfs_fs_traverse(lfs_t *lfs, int (*cb)(void*, lfs_block_t), void *data); // Returns a negative error code on failure. int lfs_migrate(lfs_t *lfs, const struct lfs_config *cfg); #endif +#endif #ifdef __cplusplus diff --git a/tools/sdk/esp32/include/esp_littlefs/src/littlefs/lfs_util.h b/tools/sdk/esp32/include/esp_littlefs/src/littlefs/lfs_util.h index dbb4c5ba866..fc1b0c2ae86 100644 --- a/tools/sdk/esp32/include/esp_littlefs/src/littlefs/lfs_util.h +++ b/tools/sdk/esp32/include/esp_littlefs/src/littlefs/lfs_util.h @@ -49,6 +49,7 @@ extern "C" // code footprint // Logging functions +#ifndef LFS_TRACE #ifdef LFS_YES_TRACE #define LFS_TRACE_(fmt, ...) \ printf("%s:%d:trace: " fmt "%s\n", __FILE__, __LINE__, __VA_ARGS__) @@ -56,7 +57,9 @@ extern "C" #else #define LFS_TRACE(...) #endif +#endif +#ifndef LFS_DEBUG #ifndef LFS_NO_DEBUG #define LFS_DEBUG_(fmt, ...) \ printf("%s:%d:debug: " fmt "%s\n", __FILE__, __LINE__, __VA_ARGS__) @@ -64,7 +67,9 @@ extern "C" #else #define LFS_DEBUG(...) #endif +#endif +#ifndef LFS_WARN #ifndef LFS_NO_WARN #define LFS_WARN_(fmt, ...) \ printf("%s:%d:warn: " fmt "%s\n", __FILE__, __LINE__, __VA_ARGS__) @@ -72,7 +77,9 @@ extern "C" #else #define LFS_WARN(...) #endif +#endif +#ifndef LFS_ERROR #ifndef LFS_NO_ERROR #define LFS_ERROR_(fmt, ...) \ printf("%s:%d:error: " fmt "%s\n", __FILE__, __LINE__, __VA_ARGS__) @@ -80,13 +87,16 @@ extern "C" #else #define LFS_ERROR(...) #endif +#endif // Runtime assertions +#ifndef LFS_ASSERT #ifndef LFS_NO_ASSERT #define LFS_ASSERT(test) assert(test) #else #define LFS_ASSERT(test) #endif +#endif // Builtin functions, these may be replaced by more efficient diff --git a/tools/sdk/esp32/include/esp_local_ctrl/include/esp_local_ctrl.h b/tools/sdk/esp32/include/esp_local_ctrl/include/esp_local_ctrl.h index 9f4f89daa31..8322412eb3a 100644 --- a/tools/sdk/esp32/include/esp_local_ctrl/include/esp_local_ctrl.h +++ b/tools/sdk/esp32/include/esp_local_ctrl/include/esp_local_ctrl.h @@ -228,6 +228,37 @@ typedef union { esp_local_ctrl_transport_config_httpd_t *httpd; } esp_local_ctrl_transport_config_t; +/** + * @brief Security types for esp_local_control + */ +typedef enum esp_local_ctrl_proto_sec { + PROTOCOM_SEC0 = 0, + PROTOCOM_SEC1, + PROTOCOM_SEC_CUSTOM, +} esp_local_ctrl_proto_sec_t; + +/** + * Protocom security configs + */ +typedef struct esp_local_ctrl_proto_sec_cfg { + /** + * This sets protocom security version, sec0/sec1 or custom + * If custom, user must provide handle via `proto_sec_custom_handle` below + */ + esp_local_ctrl_proto_sec_t version; + + /** + * Custom security handle if security is set custom via `proto_sec` above + * This handle must follow `protocomm_security_t` signature + */ + void *custom_handle; + + /** + * Proof of possession to be used for local control. Could be NULL. + */ + void *pop; +} esp_local_ctrl_proto_sec_cfg_t; + /** * @brief Configuration structure to pass to `esp_local_ctrl_start()` */ @@ -242,6 +273,11 @@ typedef struct esp_local_ctrl_config { */ esp_local_ctrl_transport_config_t transport_config; + /** + * Security version and POP + */ + esp_local_ctrl_proto_sec_cfg_t proto_sec; + /** * Register handlers for responding to get/set requests on properties */ diff --git a/tools/sdk/esp32/include/esp_netif/include/esp_netif_ppp.h b/tools/sdk/esp32/include/esp_netif/include/esp_netif_ppp.h index 413910c4331..159388e80ea 100644 --- a/tools/sdk/esp32/include/esp_netif/include/esp_netif_ppp.h +++ b/tools/sdk/esp32/include/esp_netif/include/esp_netif_ppp.h @@ -38,6 +38,11 @@ typedef struct esp_netif_ppp_config { */ #define NETIF_PP_PHASE_OFFSET (0x100) +/** @brief event id offset for internal errors + * + */ +#define NETIF_PPP_INTERNAL_ERR_OFFSET (0x200) + /** @brief event ids for different PPP related events * */ @@ -68,6 +73,7 @@ typedef enum { NETIF_PPP_PHASE_RUNNING = NETIF_PP_PHASE_OFFSET + 10, NETIF_PPP_PHASE_TERMINATE = NETIF_PP_PHASE_OFFSET + 11, NETIF_PPP_PHASE_DISCONNECT = NETIF_PP_PHASE_OFFSET + 12, + NETIF_PPP_CONNECT_FAILED = NETIF_PPP_INTERNAL_ERR_OFFSET + 0, } esp_netif_ppp_status_event_t; /** @brief definitions of different authorisation types @@ -89,7 +95,8 @@ typedef enum { * @param[in] user User name * @param[in] passwd Password * - * @return ESP_OK on success, ESP_ERR_ESP_NETIF_INVALID_PARAMS if netif null or not PPP + * @return ESP_OK on success, + * ESP_ERR_ESP_NETIF_INVALID_PARAMS if the supplied netif is not of PPP type, or netif is null */ esp_err_t esp_netif_ppp_set_auth(esp_netif_t *netif, esp_netif_auth_type_t authtype, const char *user, const char *passwd); @@ -98,10 +105,20 @@ esp_err_t esp_netif_ppp_set_auth(esp_netif_t *netif, esp_netif_auth_type_t autht * @param[in] esp_netif Handle to esp-netif instance * @param[in] config Pointer to PPP netif configuration structure * - * @return ESP_OK on success, ESP_ERR_ESP_NETIF_INVALID_PARAMS if netif null or not PPP + * @return ESP_OK on success, + * ESP_ERR_ESP_NETIF_INVALID_PARAMS if the supplied netif is not of PPP type, or netif is null */ esp_err_t esp_netif_ppp_set_params(esp_netif_t *netif, const esp_netif_ppp_config_t *config); +/** @brief Gets parameters configured in the supplied esp-netif. + * + * @param[in] esp_netif Handle to esp-netif instance + * @param[out] config Pointer to PPP netif configuration structure + * + * @return ESP_OK on success, + * ESP_ERR_ESP_NETIF_INVALID_PARAMS if the supplied netif is not of PPP type, or netif is null + */ +esp_err_t esp_netif_ppp_get_params(esp_netif_t *netif, esp_netif_ppp_config_t *config); #ifdef __cplusplus } diff --git a/tools/sdk/esp32/include/esp_phy/include/phy.h b/tools/sdk/esp32/include/esp_phy/include/phy.h index c0eadbf2ba4..51b972bb6ca 100644 --- a/tools/sdk/esp32/include/esp_phy/include/phy.h +++ b/tools/sdk/esp32/include/esp_phy/include/phy.h @@ -69,7 +69,7 @@ void phy_wakeup_init(void); */ void phy_close_rf(void); -#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2 +#if !CONFIG_IDF_TARGET_ESP32 /** * @brief Disable PHY temperature sensor. */ diff --git a/tools/sdk/esp32/include/esp_rom/include/esp32/rom/spi_flash.h b/tools/sdk/esp32/include/esp_rom/include/esp32/rom/spi_flash.h index 6d162343f34..500ba300cbb 100644 --- a/tools/sdk/esp32/include/esp_rom/include/esp32/rom/spi_flash.h +++ b/tools/sdk/esp32/include/esp_rom/include/esp32/rom/spi_flash.h @@ -260,7 +260,7 @@ esp_rom_spiflash_result_t esp_rom_spiflash_read_status(esp_rom_spiflash_chip_t * esp_rom_spiflash_result_t esp_rom_spiflash_read_statushigh(esp_rom_spiflash_chip_t *spi, uint32_t *status); /** - * @brief Write status to Falsh status register. + * @brief Write status to Flash status register. * Please do not call this function in SDK. * * @param esp_rom_spiflash_chip_t *spi : The information for Flash, which is exported from ld file. diff --git a/tools/sdk/esp32/include/esp_rom/include/esp32c3/rom/newlib.h b/tools/sdk/esp32/include/esp_rom/include/esp32c3/rom/newlib.h deleted file mode 100644 index a852bdb7f5b..00000000000 --- a/tools/sdk/esp32/include/esp_rom/include/esp32c3/rom/newlib.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2020 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 -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Global variables used by newlib in ROM - - Note that any of these symbols which are used by both ROM & IDF will have duplicate copies - in each "side" of the memory. However they're all pointers, and the pointers will be to the same - thing, so it's not a big memory waste and functionality is the same. - - Some variables which look like they should be here, but aren't: - - - __sf_fake_stdin, __sf_fake_stdout, __sf_fake_stderr - These are defined in ROM because ROM includes findfp.c, - but only used if _REENT_INIT or _REENT_INIT_PTR are ever called and ROM doesn't use these macros anywhere unless - printf() or similar is called without initializing reent first. ESP-IDF sets up its own minimal reent structures. - - - __lock___sinit_recursive_mutex, etc. - these are combined into common_recursive_mutex & common_mutex to save space -*/ -typedef struct { - _LOCK_T common_recursive_mutex; - _LOCK_T common_mutex; - struct _reent *global_reent; -} esp_rom_newlib_global_data_t; - -/* Called from IDF newlib component setup - to initialize common data shared between ROM and IDF -*/ -void esp_rom_newlib_init_global_data(const esp_rom_newlib_global_data_t *data); - -#ifdef __cplusplus -} -#endif diff --git a/tools/sdk/esp32/include/esp_rom/include/esp32c3/rom/rtc.h b/tools/sdk/esp32/include/esp_rom/include/esp32c3/rom/rtc.h index 76ece7e8194..2a7f6cb6140 100644 --- a/tools/sdk/esp32/include/esp_rom/include/esp32c3/rom/rtc.h +++ b/tools/sdk/esp32/include/esp_rom/include/esp32c3/rom/rtc.h @@ -85,8 +85,7 @@ typedef enum { NO_MEAN = 0, POWERON_RESET = 1, /**<1, Vbat power on reset*/ RTC_SW_SYS_RESET = 3, /**<3, Software reset digital core*/ - DEEPSLEEP_RESET = 5, /**<3, Deep Sleep reset digital core*/ - SDIO_RESET = 6, /**<6, Reset by SLC module, reset digital core*/ + DEEPSLEEP_RESET = 5, /**<5, Deep Sleep reset digital core*/ TG0WDT_SYS_RESET = 7, /**<7, Timer Group0 Watch dog reset digital core*/ TG1WDT_SYS_RESET = 8, /**<8, Timer Group1 Watch dog reset digital core*/ RTCWDT_SYS_RESET = 9, /**<9, RTC Watch dog Reset digital core*/ @@ -96,8 +95,13 @@ typedef enum { RTCWDT_CPU_RESET = 13, /**<13, RTC Watch dog Reset CPU*/ RTCWDT_BROWN_OUT_RESET = 15, /**<15, Reset when the vdd voltage is not stable*/ RTCWDT_RTC_RESET = 16, /**<16, RTC Watch dog reset digital core and rtc module*/ - TG1WDT_CPU_RESET = 17, /**<11, Time Group1 reset CPU*/ - SUPER_WDT_RESET = 18, /**<11, super watchdog reset digital core and rtc module*/ + TG1WDT_CPU_RESET = 17, /**<17, Time Group1 reset CPU*/ + SUPER_WDT_RESET = 18, /**<18, super watchdog reset digital core and rtc module*/ + GLITCH_RTC_RESET = 19, /**<19, glitch reset digital core and rtc module*/ + EFUSE_RESET = 20, /**<20, efuse reset digital core*/ + USB_UART_CHIP_RESET = 21, /**<21, usb uart reset digital core */ + USB_JTAG_CHIP_RESET = 22, /**<22, usb jtag reset digital core */ + POWER_GLITCH_RESET = 23, /**<23, power glitch reset digital core and rtc module*/ } RESET_REASON; // Check if the reset reason defined in ROM is compatible with soc/reset_reasons.h @@ -112,7 +116,13 @@ _Static_assert((soc_reset_reason_t)RTC_SW_CPU_RESET == RESET_REASON_CPU0_SW, "RT _Static_assert((soc_reset_reason_t)RTCWDT_CPU_RESET == RESET_REASON_CPU0_RTC_WDT, "RTCWDT_CPU_RESET != RESET_REASON_CPU0_RTC_WDT"); _Static_assert((soc_reset_reason_t)RTCWDT_BROWN_OUT_RESET == RESET_REASON_SYS_BROWN_OUT, "RTCWDT_BROWN_OUT_RESET != RESET_REASON_SYS_BROWN_OUT"); _Static_assert((soc_reset_reason_t)RTCWDT_RTC_RESET == RESET_REASON_SYS_RTC_WDT, "RTCWDT_RTC_RESET != RESET_REASON_SYS_RTC_WDT"); +_Static_assert((soc_reset_reason_t)TG1WDT_CPU_RESET == RESET_REASON_CPU0_MWDT1, "TG1WDT_CPU_RESET != RESET_REASON_CPU0_MWDT1"); _Static_assert((soc_reset_reason_t)SUPER_WDT_RESET == RESET_REASON_SYS_SUPER_WDT, "SUPER_WDT_RESET != RESET_REASON_SYS_SUPER_WDT"); +_Static_assert((soc_reset_reason_t)GLITCH_RTC_RESET == RESET_REASON_SYS_CLK_GLITCH, "GLITCH_RTC_RESET != RESET_REASON_SYS_CLK_GLITCH"); +_Static_assert((soc_reset_reason_t)EFUSE_RESET == RESET_REASON_CORE_EFUSE_CRC, "EFUSE_RESET != RESET_REASON_CORE_EFUSE_CRC"); +_Static_assert((soc_reset_reason_t)USB_UART_CHIP_RESET == RESET_REASON_CORE_USB_UART, "USB_UART_CHIP_RESET != RESET_REASON_CORE_USB_UART"); +_Static_assert((soc_reset_reason_t)USB_JTAG_CHIP_RESET == RESET_REASON_CORE_USB_JTAG, "USB_JTAG_CHIP_RESET != RESET_REASON_CORE_USB_JTAG"); +_Static_assert((soc_reset_reason_t)POWER_GLITCH_RESET == RESET_REASON_CORE_PWR_GLITCH, "POWER_GLITCH_RESET != RESET_REASON_CORE_PWR_GLITCH"); typedef enum { NO_SLEEP = 0, diff --git a/tools/sdk/esp32/include/esp_rom/include/esp32h2/rom/newlib.h b/tools/sdk/esp32/include/esp_rom/include/esp32h2/rom/newlib.h deleted file mode 100644 index a852bdb7f5b..00000000000 --- a/tools/sdk/esp32/include/esp_rom/include/esp32h2/rom/newlib.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2020 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 -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Global variables used by newlib in ROM - - Note that any of these symbols which are used by both ROM & IDF will have duplicate copies - in each "side" of the memory. However they're all pointers, and the pointers will be to the same - thing, so it's not a big memory waste and functionality is the same. - - Some variables which look like they should be here, but aren't: - - - __sf_fake_stdin, __sf_fake_stdout, __sf_fake_stderr - These are defined in ROM because ROM includes findfp.c, - but only used if _REENT_INIT or _REENT_INIT_PTR are ever called and ROM doesn't use these macros anywhere unless - printf() or similar is called without initializing reent first. ESP-IDF sets up its own minimal reent structures. - - - __lock___sinit_recursive_mutex, etc. - these are combined into common_recursive_mutex & common_mutex to save space -*/ -typedef struct { - _LOCK_T common_recursive_mutex; - _LOCK_T common_mutex; - struct _reent *global_reent; -} esp_rom_newlib_global_data_t; - -/* Called from IDF newlib component setup - to initialize common data shared between ROM and IDF -*/ -void esp_rom_newlib_init_global_data(const esp_rom_newlib_global_data_t *data); - -#ifdef __cplusplus -} -#endif diff --git a/tools/sdk/esp32/include/esp_rom/include/esp32h2/rom/rtc.h b/tools/sdk/esp32/include/esp_rom/include/esp32h2/rom/rtc.h index 76ece7e8194..ad4f45c2ca7 100644 --- a/tools/sdk/esp32/include/esp_rom/include/esp32h2/rom/rtc.h +++ b/tools/sdk/esp32/include/esp_rom/include/esp32h2/rom/rtc.h @@ -85,8 +85,7 @@ typedef enum { NO_MEAN = 0, POWERON_RESET = 1, /**<1, Vbat power on reset*/ RTC_SW_SYS_RESET = 3, /**<3, Software reset digital core*/ - DEEPSLEEP_RESET = 5, /**<3, Deep Sleep reset digital core*/ - SDIO_RESET = 6, /**<6, Reset by SLC module, reset digital core*/ + DEEPSLEEP_RESET = 5, /**<5, Deep Sleep reset digital core*/ TG0WDT_SYS_RESET = 7, /**<7, Timer Group0 Watch dog reset digital core*/ TG1WDT_SYS_RESET = 8, /**<8, Timer Group1 Watch dog reset digital core*/ RTCWDT_SYS_RESET = 9, /**<9, RTC Watch dog Reset digital core*/ @@ -96,8 +95,14 @@ typedef enum { RTCWDT_CPU_RESET = 13, /**<13, RTC Watch dog Reset CPU*/ RTCWDT_BROWN_OUT_RESET = 15, /**<15, Reset when the vdd voltage is not stable*/ RTCWDT_RTC_RESET = 16, /**<16, RTC Watch dog reset digital core and rtc module*/ - TG1WDT_CPU_RESET = 17, /**<11, Time Group1 reset CPU*/ - SUPER_WDT_RESET = 18, /**<11, super watchdog reset digital core and rtc module*/ + TG1WDT_CPU_RESET = 17, /**<17, Time Group1 reset CPU*/ + SUPER_WDT_RESET = 18, /**<18, super watchdog reset digital core and rtc module*/ + GLITCH_RTC_RESET = 19, /**<19, glitch reset digital core and rtc module*/ + EFUSE_RESET = 20, /**<20, efuse reset digital core*/ + USB_UART_CHIP_RESET = 21, /**<21, usb uart reset digital core */ + USB_JTAG_CHIP_RESET = 22, /**<22, usb jtag reset digital core */ + POWER_GLITCH_RESET = 23, /**<23, power glitch reset digital core and rtc module*/ + JTAG_RESET = 24, /**<24, jtag reset CPU*/ } RESET_REASON; // Check if the reset reason defined in ROM is compatible with soc/reset_reasons.h @@ -112,7 +117,14 @@ _Static_assert((soc_reset_reason_t)RTC_SW_CPU_RESET == RESET_REASON_CPU0_SW, "RT _Static_assert((soc_reset_reason_t)RTCWDT_CPU_RESET == RESET_REASON_CPU0_RTC_WDT, "RTCWDT_CPU_RESET != RESET_REASON_CPU0_RTC_WDT"); _Static_assert((soc_reset_reason_t)RTCWDT_BROWN_OUT_RESET == RESET_REASON_SYS_BROWN_OUT, "RTCWDT_BROWN_OUT_RESET != RESET_REASON_SYS_BROWN_OUT"); _Static_assert((soc_reset_reason_t)RTCWDT_RTC_RESET == RESET_REASON_SYS_RTC_WDT, "RTCWDT_RTC_RESET != RESET_REASON_SYS_RTC_WDT"); +_Static_assert((soc_reset_reason_t)TG1WDT_CPU_RESET == RESET_REASON_CPU0_MWDT1, "TG1WDT_CPU_RESET != RESET_REASON_CPU0_MWDT1"); _Static_assert((soc_reset_reason_t)SUPER_WDT_RESET == RESET_REASON_SYS_SUPER_WDT, "SUPER_WDT_RESET != RESET_REASON_SYS_SUPER_WDT"); +_Static_assert((soc_reset_reason_t)GLITCH_RTC_RESET == RESET_REASON_SYS_CLK_GLITCH, "GLITCH_RTC_RESET != RESET_REASON_SYS_CLK_GLITCH"); +_Static_assert((soc_reset_reason_t)EFUSE_RESET == RESET_REASON_CORE_EFUSE_CRC, "EFUSE_RESET != RESET_REASON_CORE_EFUSE_CRC"); +_Static_assert((soc_reset_reason_t)USB_UART_CHIP_RESET == RESET_REASON_CORE_USB_UART, "USB_UART_CHIP_RESET != RESET_REASON_CORE_USB_UART"); +_Static_assert((soc_reset_reason_t)USB_JTAG_CHIP_RESET == RESET_REASON_CORE_USB_JTAG, "USB_JTAG_CHIP_RESET != RESET_REASON_CORE_USB_JTAG"); +_Static_assert((soc_reset_reason_t)POWER_GLITCH_RESET == RESET_REASON_CORE_PWR_GLITCH, "POWER_GLITCH_RESET != RESET_REASON_CORE_PWR_GLITCH"); +_Static_assert((soc_reset_reason_t)JTAG_RESET == RESET_REASON_CPU_JTAG, "JTAG_RESET != RESET_REASON_CPU_JTAG"); typedef enum { NO_SLEEP = 0, diff --git a/tools/sdk/esp32/include/esp_rom/include/esp32s2/rom/opi_flash.h b/tools/sdk/esp32/include/esp_rom/include/esp32s2/rom/opi_flash.h index c985810b678..bb209f67f05 100644 --- a/tools/sdk/esp32/include/esp_rom/include/esp32s2/rom/opi_flash.h +++ b/tools/sdk/esp32/include/esp_rom/include/esp32s2/rom/opi_flash.h @@ -40,7 +40,6 @@ typedef struct { #define ESP_ROM_SPIFLASH_BP2 BIT4 #define ESP_ROM_SPIFLASH_WR_PROTECT (ESP_ROM_SPIFLASH_BP0|ESP_ROM_SPIFLASH_BP1|ESP_ROM_SPIFLASH_BP2) #define ESP_ROM_SPIFLASH_QE BIT9 -#define ESP_ROM_SPIFLASH_BP_MASK_ISSI (BIT7 | BIT5 | BIT4 | BIT3 | BIT2) #define FLASH_OP_MODE_RDCMD_DOUT 0x3B #define ESP_ROM_FLASH_SECTOR_SIZE 0x1000 diff --git a/tools/sdk/esp32/include/esp_rom/include/esp32s2/rom/spi_flash.h b/tools/sdk/esp32/include/esp_rom/include/esp32s2/rom/spi_flash.h index c93b4e27c18..beb2fcdf309 100644 --- a/tools/sdk/esp32/include/esp_rom/include/esp32s2/rom/spi_flash.h +++ b/tools/sdk/esp32/include/esp_rom/include/esp32s2/rom/spi_flash.h @@ -119,7 +119,6 @@ extern "C" { #define ESP_ROM_SPIFLASH_BP2 BIT4 #define ESP_ROM_SPIFLASH_WR_PROTECT (ESP_ROM_SPIFLASH_BP0|ESP_ROM_SPIFLASH_BP1|ESP_ROM_SPIFLASH_BP2) #define ESP_ROM_SPIFLASH_QE BIT9 -#define ESP_ROM_SPIFLASH_BP_MASK_ISSI (BIT7 | BIT5 | BIT4 | BIT3 | BIT2) #define FLASH_ID_GD25LQ32C 0xC86016 diff --git a/tools/sdk/esp32/include/esp_rom/include/esp32s2/rom/usb/cpio.h b/tools/sdk/esp32/include/esp_rom/include/esp32s2/rom/usb/cpio.h index 5603b3f541a..886b5080fb4 100644 --- a/tools/sdk/esp32/include/esp_rom/include/esp32s2/rom/usb/cpio.h +++ b/tools/sdk/esp32/include/esp_rom/include/esp32s2/rom/usb/cpio.h @@ -79,7 +79,7 @@ typedef enum { * The initial time with reason=CPIO_RSN_FILE_INITIAL, when more data is available with * CPIO_RSN_FILE_MORE and finally with CPIO_RSN_FILE_END. For these calls, fileinfo * will again contain file information. buff will be the information contained in the - * file at offset buff_offset, and the lenght of this buffer will be in buff_len. + * file at offset buff_offset, and the length of this buffer will be in buff_len. * * The library guarantees to feed all file data to the callback consequitively, so * within the same file, the buff_offset from a call will always be (buff_offset+buff_len) diff --git a/tools/sdk/esp32/include/esp_rom/include/esp32s3/rom/apb_backup_dma.h b/tools/sdk/esp32/include/esp_rom/include/esp32s3/rom/apb_backup_dma.h new file mode 100644 index 00000000000..324135cb836 --- /dev/null +++ b/tools/sdk/esp32/include/esp_rom/include/esp32s3/rom/apb_backup_dma.h @@ -0,0 +1,17 @@ +/* + * SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +void ets_apb_backup_init_lock_func(void(* _apb_backup_lock)(void), void(* _apb_backup_unlock)(void)); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32/include/esp_rom/include/esp32s3/rom/cache.h b/tools/sdk/esp32/include/esp_rom/include/esp32s3/rom/cache.h index 0ec6308f7cd..27780446fe0 100644 --- a/tools/sdk/esp32/include/esp_rom/include/esp32s3/rom/cache.h +++ b/tools/sdk/esp32/include/esp_rom/include/esp32s3/rom/cache.h @@ -103,6 +103,11 @@ typedef enum { CACHE_AUTOLOAD_NEGATIVE = 1, /*!< cache autoload step is negative */ } cache_autoload_order_t; +typedef enum { + CACHE_AUTOLOAD_REGION0 = 0, /*!< cache autoload region0 */ + CACHE_AUTOLOAD_REGION1 = 1, /*!< cache autoload region1 */ +} cache_autoload_region_t; + #define CACHE_AUTOLOAD_STEP(i) ((i) - 1) typedef enum { @@ -144,14 +149,17 @@ struct dcache_tag_item { }; struct autoload_config { + uint8_t ena; /*!< autoload enable */ uint8_t order; /*!< autoload step is positive or negative */ uint8_t trigger; /*!< autoload trigger */ - uint8_t ena0; /*!< autoload region0 enable */ - uint8_t ena1; /*!< autoload region1 enable */ - uint32_t addr0; /*!< autoload region0 start address */ - uint32_t size0; /*!< autoload region0 size */ - uint32_t addr1; /*!< autoload region1 start address */ - uint32_t size1; /*!< autoload region1 size */ + uint8_t size; /*!< autoload size */ +}; + +struct autoload_region_config { + uint8_t region; /*!< autoload region*/ + uint8_t ena; /*!< autoload region enable */ + uint32_t addr; /*!< autoload region start address */ + uint32_t size; /*!< autoload region size */ }; struct tag_group_info { @@ -160,6 +168,7 @@ struct tag_group_info { uint32_t vaddr_offset; /*!< virtual address offset of the cache ways */ uint32_t tag_addr[MAX_CACHE_WAYS]; /*!< tag memory address, only [0~mode.ways-1] is valid to use */ uint32_t cache_memory_offset[MAX_CACHE_WAYS]; /*!< cache memory address, only [0~mode.ways-1] is valid to use */ + uint8_t use_legacy; /*!< 1 for using legacy tag api, 0 for using 2rd tag api */ }; struct lock_config { @@ -168,6 +177,39 @@ struct lock_config { uint16_t group; /*!< manual lock group, 0 or 1*/ }; +struct cache_internal_stub_table { + uint32_t (* icache_line_size)(void); + uint32_t (* dcache_line_size)(void); + uint32_t (* icache_addr)(uint32_t addr); + uint32_t (* dcache_addr)(uint32_t addr); + void (* invalidate_icache_items)(uint32_t addr, uint32_t items); + void (* invalidate_dcache_items)(uint32_t addr, uint32_t items); + void (* clean_items)(uint32_t addr, uint32_t items); + void (* writeback_items)(uint32_t addr, uint32_t items); + void (* lock_icache_items)(uint32_t addr, uint32_t items); + void (* lock_dcache_items)(uint32_t addr, uint32_t items); + void (* unlock_icache_items)(uint32_t addr, uint32_t items); + void (* unlock_dcache_items)(uint32_t addr, uint32_t items); + void (* occupy_items)(uint32_t addr, uint32_t items); + uint32_t (* suspend_icache_autoload)(void); + void (* resume_icache_autoload)(uint32_t autoload); + uint32_t (* suspend_dcache_autoload)(void); + void (* resume_dcache_autoload)(uint32_t autoload); + void (* freeze_icache_enable)(cache_freeze_mode_t mode); + void (* freeze_icache_disable)(void); + void (* freeze_dcache_enable)(cache_freeze_mode_t mode); + void (* freeze_dcache_disable)(void); + int (* op_addr)(uint32_t op_icache, uint32_t start_addr, uint32_t size, uint32_t cache_line_size, uint32_t max_sync_num, void(* cache_Iop)(uint32_t, uint32_t), void(* cache_Dop)(uint32_t, uint32_t)); +}; + +typedef void (* cache_op_start)(void); +typedef void (* cache_op_end)(void); + +typedef struct { + cache_op_start start; + cache_op_end end; +} cache_op_cb_t; + #define ESP_ROM_ERR_INVALID_ARG 1 #define MMU_SET_ADDR_ALIGNED_ERROR 2 #define MMU_SET_PASE_SIZE_ERROR 3 @@ -190,7 +232,7 @@ void Cache_MMU_Init(void); * @brief Set ICache mmu mapping. * Please do not call this function in your SDK application. * - * @param uint32_t ext_ram : DPORT_MMU_ACCESS_FLASH for flash, DPORT_MMU_ACCESS_SPIRAM for spiram, DPORT_MMU_INVALID for invalid. + * @param uint32_t ext_ram : MMU_ACCESS_FLASH for flash, MMU_ACCESS_SPIRAM for spiram, MMU_INVALID for invalid. * * @param uint32_t vaddr : virtual address in CPU address space. * Can be Iram0,Iram1,Irom0,Drom0 and AHB buses address. @@ -217,7 +259,7 @@ int Cache_Ibus_MMU_Set(uint32_t ext_ram, uint32_t vaddr, uint32_t paddr, uint32 * @brief Set DCache mmu mapping. * Please do not call this function in your SDK application. * - * @param uint32_t ext_ram : DPORT_MMU_ACCESS_FLASH for flash, DPORT_MMU_ACCESS_SPIRAM for spiram, DPORT_MMU_INVALID for invalid. + * @param uint32_t ext_ram : MMU_ACCESS_FLASH for flash, MMU_ACCESS_SPIRAM for spiram, MMU_INVALID for invalid. * * @param uint32_t vaddr : virtual address in CPU address space. * Can be DRam0, DRam1, DRom0, DPort and AHB buses address. @@ -272,9 +314,9 @@ uint32_t Cache_Flash_To_SPIRAM_Copy(uint32_t bus, uint32_t bus_start_addr, uint3 * @brief allocate memory to used by ICache. * Please do not call this function in your SDK application. * - * @param cache_array_t icache_low : the data array bank used by icache low part, can be CACHE_MEMORY_INVALID, CACHE_MEMORY_IBANK0, CACHE_MEMORY_IBANK1 + * @param cache_array_t icache_low : the data array bank used by icache low part. Due to timing constraint, can only be CACHE_MEMORY_INVALID, CACHE_MEMORY_IBANK0 * - * @param cache_array_t icache_high : the data array bank used by icache high part, can be CACHE_MEMORY_INVALID, CACHE_MEMORY_IBANK0, CACHE_MEMORY_IBANK1 only if icache_low and icache_high is not CACHE_MEMORY_INVALID + * @param cache_array_t icache_high : the data array bank used by icache high part. Due to timing constraint, can only be CACHE_MEMORY_INVALID, or CACHE_MEMORY_IBANK1 only if icache_low and icache_high is CACHE_MEMORY_IBANK0 * * return none */ @@ -284,9 +326,9 @@ void Cache_Occupy_ICache_MEMORY(cache_array_t icache_low, cache_array_t icache_h * @brief allocate memory to used by DCache. * Please do not call this function in your SDK application. * - * @param cache_array_t dcache_low : the data array bank used by dcache low part, can be CACHE_MEMORY_INVALID, CACHE_MEMORY_DBANK0, CACHE_MEMORY_DBANK1 + * @param cache_array_t dcache_low : the data array bank used by dcache low part. Due to timing constraint, can only be CACHE_MEMORY_INVALID, CACHE_MEMORY_DBANK1 * - * @param cache_array_t dcache1_high : the data array bank used by dcache high part, can be CACHE_MEMORY_INVALID, CACHE_MEMORY_DBANK0, CACHE_MEMORY_DBANK1 only if dcache_low0 and dcache_low1 is not CACHE_MEMORY_INVALID + * @param cache_array_t dcache1_high : the data array bank used by dcache high part. Due to timing constraint, can only be CACHE_MEMORY_INVALID, or CACHE_MEMORY_DBANK0 only if dcache_low0 and dcache_low1 is CACHE_MEMORY_DBANK1 * * return none */ @@ -310,7 +352,7 @@ void Cache_Get_Mode(struct cache_mode *mode); * * @param cache_ways_t ways : the associate ways of cache, can be CACHE_4WAYS_ASSOC and CACHE_8WAYS_ASSOC * - * @param cache_line_size_t cache_line_size : the cache line size, can be CACHE_LINE_SIZE_16B, CACHE_LINE_SIZE_32B and CACHE_LINE_SIZE_64B + * @param cache_line_size_t cache_line_size : the cache line size, can be CACHE_LINE_SIZE_16B and CACHE_LINE_SIZE_32B * * return none */ @@ -320,9 +362,9 @@ void Cache_Set_ICache_Mode(cache_size_t cache_size, cache_ways_t ways, cache_lin * @brief set DCache modes: cache size, associate ways and cache line size. * Please do not call this function in your SDK application. * - * @param cache_size_t cache_size : the cache size, can be CACHE_SIZE_8KB and CACHE_SIZE_16KB + * @param cache_size_t cache_size : the cache size, can be CACHE_SIZE_HALF and CACHE_SIZE_FULL * - * @param cache_ways_t ways : the associate ways of cache, can be CACHE_4WAYS_ASSOC and CACHE_8WAYS_ASSOC + * @param cache_ways_t ways : the associate ways of cache, can be CACHE_4WAYS_ASSOC and CACHE_8WAYS_ASSOC, only CACHE_4WAYS_ASSOC works * * @param cache_line_size_t cache_line_size : the cache line size, can be CACHE_LINE_SIZE_16B, CACHE_LINE_SIZE_32B and CACHE_LINE_SIZE_64B * @@ -351,7 +393,7 @@ uint32_t Cache_Address_Through_ICache(uint32_t addr); uint32_t Cache_Address_Through_DCache(uint32_t addr); /** - * @brief Init mmu owner register to make i/d cache use half mmu entries. + * @brief Init Cache for ROM boot, including resetting the Dcache, initializing Owner, MMU, setting DCache mode, Enabling DCache, unmasking bus. * * @param None * @@ -636,6 +678,16 @@ void Cache_End_DCache_Preload(uint32_t autoload); */ void Cache_Config_ICache_Autoload(const struct autoload_config *config); +/** + * @brief Config region autoload parameters of ICache. + * Please do not call this function in your SDK application. + * + * @param struct autoload_region_config * config : region autoload parameters. + * + * @return ESP_ROM_ERR_INVALID_ARG : invalid param, 0 : success + */ +int Cache_Config_ICache_Region_Autoload(const struct autoload_region_config *config); + /** * @brief Enable auto preload for ICache. * Please do not call this function in your SDK application. @@ -666,6 +718,16 @@ void Cache_Disable_ICache_Autoload(void); */ void Cache_Config_DCache_Autoload(const struct autoload_config *config); +/** + * @brief Config region autoload parameters of DCache. + * Please do not call this function in your SDK application. + * + * @param struct autoload_region_config * config : region autoload parameters. + * + * @return ESP_ROM_ERR_INVALID_ARG : invalid param, 0 : success + */ +int Cache_Config_DCache_Region_Autoload(const struct autoload_region_config *config); + /** * @brief Enable auto preload for DCache. * Please do not call this function in your SDK application. @@ -1008,7 +1070,24 @@ void Cache_Freeze_DCache_Disable(void); * * @return None */ -void Cache_Travel_Tag_Memory(struct cache_mode *mode, uint32_t filter_addr, void (* process)(struct tag_group_info *)); +void Cache_Travel_Tag_Memory(struct cache_mode * mode, uint32_t filter_addr, void (* process)(struct tag_group_info *)); + +/** + * @brief Travel tag memory to run a call back function, using 2nd tag registers. + * ICache and DCache are suspend when doing this. + * The callback will get the parameter tag_group_info, which will include a group of tag memory addresses and cache memory addresses. + * Please do not call this function in your SDK application. + * + * @param struct cache_mode * mode : the cache to check and the cache mode. + * + * @param uint32_t filter_addr : only the cache lines which may include the filter_address will be returned to the call back function. + * 0 for do not filter, all cache lines will be returned. + * + * @param void (* process)(struct tag_group_info *) : call back function, which may be called many times, a group(the addresses in the group are in the same position in the cache ways) a time. + * + * @return None + */ +void Cache_Travel_Tag_Memory2(struct cache_mode * mode, uint32_t filter_addr, void (* process)(struct tag_group_info *)); /** * @brief Get the virtual address from cache mode, cache tag and the virtual address offset of cache ways. @@ -1092,6 +1171,8 @@ int flash2spiram_rodata_offset(void); uint32_t flash_instr_rodata_start_page(uint32_t bus); uint32_t flash_instr_rodata_end_page(uint32_t bus); +extern struct cache_internal_stub_table* rom_cache_internal_table_ptr; +extern cache_op_cb_t rom_cache_op_cb; #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32/include/esp_rom/include/esp32s3/rom/rsa_pss.h b/tools/sdk/esp32/include/esp_rom/include/esp32s3/rom/rsa_pss.h index b9ced67a1a2..71ae5892263 100644 --- a/tools/sdk/esp32/include/esp_rom/include/esp32s3/rom/rsa_pss.h +++ b/tools/sdk/esp32/include/esp_rom/include/esp32s3/rom/rsa_pss.h @@ -32,7 +32,7 @@ typedef struct { uint32_t mdash; } ets_rsa_pubkey_t; -bool ets_rsa_pss_verify(const ets_rsa_pubkey_t *key, const uint8_t *sig, const uint8_t *digest); +bool ets_rsa_pss_verify(const ets_rsa_pubkey_t *key, const uint8_t *sig, const uint8_t *digest, uint8_t *verified_digest); void ets_mgf1_sha256(const uint8_t *mgfSeed, size_t seedLen, size_t maskLen, uint8_t *mask); diff --git a/tools/sdk/esp32/include/esp_rom/include/esp32s3/rom/rtc.h b/tools/sdk/esp32/include/esp_rom/include/esp32s3/rom/rtc.h index 09d2376ef38..d928c4dee44 100644 --- a/tools/sdk/esp32/include/esp_rom/include/esp32s3/rom/rtc.h +++ b/tools/sdk/esp32/include/esp_rom/include/esp32s3/rom/rtc.h @@ -92,6 +92,9 @@ typedef enum { SUPER_WDT_RESET = 18, /**<18, super watchdog reset digital core and rtc module*/ GLITCH_RTC_RESET = 19, /**<19, glitch reset digital core and rtc module*/ EFUSE_RESET = 20, /**<20, efuse reset digital core*/ + USB_UART_CHIP_RESET = 21, /**<21, usb uart reset digital core */ + USB_JTAG_CHIP_RESET = 22, /**<22, usb jtag reset digital core */ + POWER_GLITCH_RESET = 23, /**<23, power glitch reset digital core and rtc module*/ } RESET_REASON; // Check if the reset reason defined in ROM is compatible with soc/reset_reasons.h @@ -106,9 +109,13 @@ _Static_assert((soc_reset_reason_t)RTC_SW_CPU_RESET == RESET_REASON_CPU0_SW, "RT _Static_assert((soc_reset_reason_t)RTCWDT_CPU_RESET == RESET_REASON_CPU0_RTC_WDT, "RTCWDT_CPU_RESET != RESET_REASON_CPU0_RTC_WDT"); _Static_assert((soc_reset_reason_t)RTCWDT_BROWN_OUT_RESET == RESET_REASON_SYS_BROWN_OUT, "RTCWDT_BROWN_OUT_RESET != RESET_REASON_SYS_BROWN_OUT"); _Static_assert((soc_reset_reason_t)RTCWDT_RTC_RESET == RESET_REASON_SYS_RTC_WDT, "RTCWDT_RTC_RESET != RESET_REASON_SYS_RTC_WDT"); +_Static_assert((soc_reset_reason_t)TG1WDT_CPU_RESET == RESET_REASON_CPU0_MWDT1, "TG1WDT_CPU_RESET != RESET_REASON_CPU0_MWDT1"); _Static_assert((soc_reset_reason_t)SUPER_WDT_RESET == RESET_REASON_SYS_SUPER_WDT, "SUPER_WDT_RESET != RESET_REASON_SYS_SUPER_WDT"); _Static_assert((soc_reset_reason_t)GLITCH_RTC_RESET == RESET_REASON_SYS_CLK_GLITCH, "GLITCH_RTC_RESET != RESET_REASON_SYS_CLK_GLITCH"); _Static_assert((soc_reset_reason_t)EFUSE_RESET == RESET_REASON_CORE_EFUSE_CRC, "EFUSE_RESET != RESET_REASON_CORE_EFUSE_CRC"); +_Static_assert((soc_reset_reason_t)USB_UART_CHIP_RESET == RESET_REASON_CORE_USB_UART, "USB_UART_CHIP_RESET != RESET_REASON_CORE_USB_UART"); +_Static_assert((soc_reset_reason_t)USB_JTAG_CHIP_RESET == RESET_REASON_CORE_USB_JTAG, "USB_JTAG_CHIP_RESET != RESET_REASON_CORE_USB_JTAG"); +_Static_assert((soc_reset_reason_t)POWER_GLITCH_RESET == RESET_REASON_CORE_PWR_GLITCH, "POWER_GLITCH_RESET != RESET_REASON_CORE_PWR_GLITCH"); typedef enum { NO_SLEEP = 0, diff --git a/tools/sdk/esp32/include/esp_rom/include/esp32s3/rom/spi_flash.h b/tools/sdk/esp32/include/esp_rom/include/esp32s3/rom/spi_flash.h index 8c5170b5a8e..293306c9b97 100644 --- a/tools/sdk/esp32/include/esp_rom/include/esp32s3/rom/spi_flash.h +++ b/tools/sdk/esp32/include/esp_rom/include/esp32s3/rom/spi_flash.h @@ -111,7 +111,6 @@ extern "C" { #define ESP_ROM_SPIFLASH_BP2 BIT4 #define ESP_ROM_SPIFLASH_WR_PROTECT (ESP_ROM_SPIFLASH_BP0|ESP_ROM_SPIFLASH_BP1|ESP_ROM_SPIFLASH_BP2) #define ESP_ROM_SPIFLASH_QE BIT9 -#define ESP_ROM_SPIFLASH_BP_MASK_ISSI (BIT7 | BIT5 | BIT4 | BIT3 | BIT2) #define FLASH_ID_GD25LQ32C 0xC86016 diff --git a/tools/sdk/esp32/include/esp_rom/include/esp32s3/rom/usb/cpio.h b/tools/sdk/esp32/include/esp_rom/include/esp32s3/rom/usb/cpio.h index 5603b3f541a..886b5080fb4 100644 --- a/tools/sdk/esp32/include/esp_rom/include/esp32s3/rom/usb/cpio.h +++ b/tools/sdk/esp32/include/esp_rom/include/esp32s3/rom/usb/cpio.h @@ -79,7 +79,7 @@ typedef enum { * The initial time with reason=CPIO_RSN_FILE_INITIAL, when more data is available with * CPIO_RSN_FILE_MORE and finally with CPIO_RSN_FILE_END. For these calls, fileinfo * will again contain file information. buff will be the information contained in the - * file at offset buff_offset, and the lenght of this buffer will be in buff_len. + * file at offset buff_offset, and the length of this buffer will be in buff_len. * * The library guarantees to feed all file data to the callback consequitively, so * within the same file, the buff_offset from a call will always be (buff_offset+buff_len) diff --git a/tools/sdk/esp32/include/esp_rom/include/esp_rom_sys.h b/tools/sdk/esp32/include/esp_rom/include/esp_rom_sys.h index 9bf73adea5c..946cb7af791 100644 --- a/tools/sdk/esp32/include/esp_rom/include/esp_rom_sys.h +++ b/tools/sdk/esp32/include/esp_rom/include/esp_rom_sys.h @@ -13,7 +13,7 @@ // limitations under the License. #pragma once - +#include "sdkconfig.h" #include #include "soc/reset_reasons.h" diff --git a/tools/sdk/esp32/include/esp_rom/include/esp_rom_tjpgd.h b/tools/sdk/esp32/include/esp_rom/include/esp_rom_tjpgd.h new file mode 100644 index 00000000000..318519ba749 --- /dev/null +++ b/tools/sdk/esp32/include/esp_rom/include/esp_rom_tjpgd.h @@ -0,0 +1,152 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/*-----------------------------------------------------------------------------/ +/ TJpgDec - Tiny JPEG Decompressor R0.01b (C)ChaN, 2012 +/-----------------------------------------------------------------------------/ +/ The TJpgDec is a generic JPEG decompressor module for tiny embedded systems. +/ This is a free software that opened for education, research and commercial +/ developments under license policy of following terms. +/ +/ Copyright (C) 2012, ChaN, all right reserved. +/ +/ * The TJpgDec module is a free software and there is NO WARRANTY. +/ * No restriction on use. You can use, modify and redistribute it for +/ personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY. +/ * Redistributions of source code must retain the above copyright notice. +/ +/-----------------------------------------------------------------------------*/ + +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Error code */ +typedef enum { + JDR_OK = 0, /* 0: Succeeded */ + JDR_INTR, /* 1: Interrupted by output function */ + JDR_INP, /* 2: Device error or wrong termination of input stream */ + JDR_MEM1, /* 3: Insufficient memory pool for the image */ + JDR_MEM2, /* 4: Insufficient stream input buffer */ + JDR_PAR, /* 5: Parameter error */ + JDR_FMT1, /* 6: Data format error (may be damaged data) */ + JDR_FMT2, /* 7: Right format but not supported */ + JDR_FMT3 /* 8: Not supported JPEG standard */ +} esp_rom_tjpgd_result_t; + +/* Rectangular structure */ +typedef struct { + uint16_t left; /* Left end */ + uint16_t right; /* Right end */ + uint16_t top; /* Top end */ + uint16_t bottom;/* Bottom end */ +} esp_rom_tjpgd_rect_t; + +typedef struct JDEC_s esp_rom_tjpgd_dec_t; + +/** + * @brief Type of user defined input function to read data from input stream + * @param dec Specifies the decompression object of the decompression session + * @param buffer Specifies the pointer to the read buffer to store the read data. A NULL specifies to remove the data from input stream + * @param ndata Specifies number of bytes to read/remove from the input stream + * + * @return number of bytes read/removed. When a zero is returned, the esp_rom_tjpgd_prepare and esp_rom_tjpgd_decomp function aborts with JDR_INP + */ +typedef uint32_t (*esp_rom_tjpgd_input_function_t)(esp_rom_tjpgd_dec_t *dec, uint8_t *buffer, uint32_t ndata); + +/** + * @brief User defined output function to write decompressed pixels to the output device + * + * This function is the data output interface of the TJpgDec module. + * The corresponding decompression session can be identified by the pointer to the device identifier jdec->device passed to the 5th argument of jd_prepare function. + * The bitmap is sent to the frame buffer or display device in this function. + * The first pixel in the bitmap is the left-top of the rectangular, the second one is next right and last pixel is the bottom-right of the rectangular. + * The size of rectangular varies from 1x1 to 16x16 depends on clipping, scaling and sampling factor of the image. + * If the rectangular is out of the frame buffer, it should be clipped in this function. + * + * The pixel format is currently configured to RGB888 + * + * @param dec Specifies the decompression object of the decompression session + * @param bitmap Specifies the RGB bitmap to be output + * @param rect Specifies rectangular region in the image to output the RGB bitmap + * + * @return Normally returns 1. It lets TJpgDec to continue the decompressing process. + * When a 0 is returned, the esp_rom_tjpgd_decomp function aborts with JDR_INTR. + * This is useful to interrupt the decompression process + */ +typedef uint32_t (*esp_rom_tjpgd_output_function_t)(esp_rom_tjpgd_dec_t *dec, void *bitmap, esp_rom_tjpgd_rect_t *rect); + +struct JDEC_s { + uint32_t dctr; /* Number of bytes available in the input buffer */ + uint8_t *dptr; /* Current data read ptr */ + uint8_t *inbuf; /* Bit stream input buffer */ + uint8_t dmsk; /* Current bit in the current read byte */ + uint8_t scale; /* Output scaling ratio */ + uint8_t msx, msy; /* MCU size in unit of block (width, height) */ + uint8_t qtid[3]; /* Quantization table ID of each component */ + int16_t dcv[3]; /* Previous DC element of each component */ + uint16_t nrst; /* Restart inverval */ + uint32_t width, height; /* Size of the input image (pixel) */ + uint8_t *huffbits[2][2]; /* Huffman bit distribution tables [id][dcac] */ + uint16_t *huffcode[2][2]; /* Huffman code word tables [id][dcac] */ + uint8_t *huffdata[2][2]; /* Huffman decoded data tables [id][dcac] */ + int32_t *qttbl[4]; /* Dequaitizer tables [id] */ + void *workbuf; /* Working buffer for IDCT and RGB output */ + uint8_t *mcubuf; /* Working buffer for the MCU */ + void *pool; /* Pointer to available memory pool */ + uint32_t sz_pool; /* Size of momory pool (bytes available) */ + esp_rom_tjpgd_input_function_t infunc; /* Pointer to jpeg stream input function */ + void *device; /* Pointer to I/O device identifiler for the session */ +}; + +/* TJpgDec API functions */ + +/** + * @brief Analyzes the JPEG data and create a decompression object for subsequent decompression process. + * @param dec Specifies the decompression object to be initialized. The decompression object is used for subsequent decompression process. + * @param infunc Specifies the user defined data input function. + * @param work Specifies pointer to the work area for this session. It should be aligned to word boundary or it can result an exception. + * @param sz_work Specifies size of the work area in unit of byte. + * TJpgDec requires upto 3092 bytes of work area depends on the built-in parameter tables of the JPEG image. + * Thus 3092 bytes of work area is sufficient for most case. + * @param dev Specifies pointer to the user defined device identifier for this session. + * It is stored to the member device in the decompression object. It can be referred by I/O functions to identify the current session. + * When I/O device is fixed in the project or this feature is not needed, set NULL and do not care about this. + * + * @return + * - JDR_OK Function succeeded and decompression object is valid. + * - JDR_INP An error occurred in input function due to hard error or wrong stream termination. + * - JDR_MEM1 Insufficient work area for this JPEG image. + * - JDR_MEM2 Insufficient input buffer for this JPEG image. JD_SZBUF may be too small. + * - JDR_PAR Parameter error. Given pointer to the work area is NULL. + * - JDR_FMT1 Data format error. The JPEG data can be collapsed. + * - JDR_FMT2 Right format but not supported. May be a grayscale image. + * - JDR_FMT3 Not supported JPEG standard. May be a progressive JPEG image. + */ +esp_rom_tjpgd_result_t esp_rom_tjpgd_prepare(esp_rom_tjpgd_dec_t *dec, esp_rom_tjpgd_input_function_t infunc, void *work, uint32_t sz_work, void *dev); + +/** + * @brief Decompress the JPEG image and output it as RGB data. + * @param dec Specifies the valid decompressor object. + * @param outfunc Specifies the user defined data output function. The esp_rom_tjpgd_decomp function calls this function to output the decompressed JPEG image in RGB form. + * @param scale Specifies scaling factor N for output. The output image is descaled to 1 / 2 ^ N (N = 0 to 3). + * + * @return + * - JDR_OK Function succeeded. + * - JDR_INTR The decompression process is interrupted by output function. + * - JDR_INP An error occured in input function due to hard error or wrong stream termination. + * - JDR_PAR Parameter error. Given scale factor is invalid. + * - JDR_FMT1 Data format error. The JPEG data can be collapted. + */ +esp_rom_tjpgd_result_t esp_rom_tjpgd_decomp(esp_rom_tjpgd_dec_t *dec, esp_rom_tjpgd_output_function_t outfunc, uint8_t scale); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32/include/esp_rom/include/linux/soc/reset_reasons.h b/tools/sdk/esp32/include/esp_rom/include/linux/soc/reset_reasons.h new file mode 100644 index 00000000000..7cc86ffddfb --- /dev/null +++ b/tools/sdk/esp32/include/esp_rom/include/linux/soc/reset_reasons.h @@ -0,0 +1,31 @@ +// Copyright 2021 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 + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Dummy to satisfy the requirement for this type on Linux targets. + * Look at other reset_reasons.h files in IDF. + */ +typedef enum { + RESET_REASON_CHIP_POWER_ON = 0x01, // Power on reset +} soc_reset_reason_t; + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32/include/esp_serial_slave_link/include/esp_serial_slave_link/essl.h b/tools/sdk/esp32/include/esp_serial_slave_link/include/esp_serial_slave_link/essl.h index 505edcdc2f6..f03274a4013 100644 --- a/tools/sdk/esp32/include/esp_serial_slave_link/include/esp_serial_slave_link/essl.h +++ b/tools/sdk/esp32/include/esp_serial_slave_link/include/esp_serial_slave_link/essl.h @@ -29,42 +29,48 @@ typedef struct essl_dev_t* essl_handle_t; * * @param handle Handle of an ESSL device. * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. - * @return ESP_OK if success, or other value returned from lower layer `init`. + * @return + * - ESP_OK: If success + * - ESP_ERR_NOT_SUPPORTED: Current device does not support this function. + * - Other value returned from lower layer `init`. */ esp_err_t essl_init(essl_handle_t handle, uint32_t wait_ms); -/** Wait for interrupt of an ESP slave device. +/** Wait for interrupt of an ESSL slave device. * * @param handle Handle of an ESSL device. * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. * * @return - * - ESP_OK if success + * - ESP_OK: If success + * - ESP_ERR_NOT_SUPPORTED: Current device does not support this function. * - One of the error codes from SDMMC host controller */ esp_err_t essl_wait_for_ready(essl_handle_t handle, uint32_t wait_ms); /** Get buffer num for the host to send data to the slave. The buffers are size of ``buffer_size``. * - * @param handle Handle of an ESSL device. - * @param out_tx_num Output of buffer num that host can send data to an ESP slave. + * @param handle Handle of a ESSL device. + * @param out_tx_num Output of buffer num that host can send data to ESSL slave. * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. * * @return - * - ESP_OK Success - * - One of the error codes from SDMMC host controller + * - ESP_OK: Success + * - ESP_ERR_NOT_SUPPORTED: This API is not supported in this mode + * - One of the error codes from SDMMC/SPI host controller */ esp_err_t essl_get_tx_buffer_num(essl_handle_t handle, uint32_t *out_tx_num, uint32_t wait_ms); -/** Get amount of data the ESP slave preparing to send to host. +/** Get the size, in bytes, of the data that the ESSL slave is ready to send * * @param handle Handle of an ESSL device. - * @param out_rx_size Output of data size to read from slave. + * @param out_rx_size Output of data size to read from slave, in bytes * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. * * @return - * - ESP_OK Success - * - One of the error codes from SDMMC host controller + * - ESP_OK: Success + * - ESP_ERR_NOT_SUPPORTED: This API is not supported in this mode + * - One of the error codes from SDMMC/SPI host controller */ esp_err_t essl_get_rx_data_size(essl_handle_t handle, uint32_t *out_rx_size, uint32_t wait_ms); @@ -72,10 +78,15 @@ esp_err_t essl_get_rx_data_size(essl_handle_t handle, uint32_t *out_rx_size, uin /** Reset the counters of this component. Usually you don't need to do this unless you know the slave is reset. * * @param handle Handle of an ESSL device. + * + * @return + * - ESP_OK: Success + * - ESP_ERR_NOT_SUPPORTED: This API is not supported in this mode + * - ESP_ERR_INVALID_ARG: Invalid argument, handle is not init. */ esp_err_t essl_reset_cnt(essl_handle_t handle); -/** Send a packet to the ESP slave. The slave receive the packet into buffers whose size is ``buffer_size`` (configured during initialization). +/** Send a packet to the ESSL Slave. The Slave receives the packet into buffers whose size is ``buffer_size`` (configured during initialization). * * @param handle Handle of an ESSL device. * @param start Start address of the packet to send @@ -84,12 +95,15 @@ esp_err_t essl_reset_cnt(essl_handle_t handle); * * @return * - ESP_OK Success - * - ESP_ERR_TIMEOUT No buffer to use, or error ftrom SDMMC host controller - * - One of the error codes from SDMMC host controller + * - ESP_ERR_INVALID_ARG: Invalid argument, handle is not init or other argument is not valid. + * - ESP_ERR_TIMEOUT: No buffer to use, or error ftrom SDMMC host controller. + * - ESP_ERR_NOT_FOUND: Slave is not ready for receiving. + * - ESP_ERR_NOT_SUPPORTED: This API is not supported in this mode + * - One of the error codes from SDMMC/SPI host controller. */ esp_err_t essl_send_packet(essl_handle_t handle, const void *start, size_t length, uint32_t wait_ms); -/** Get a packet from an ESP slave. +/** Get a packet from ESSL slave. * * @param handle Handle of an ESSL device. * @param[out] out_data Data output address @@ -98,16 +112,19 @@ esp_err_t essl_send_packet(essl_handle_t handle, const void *start, size_t lengt * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. * * @return - * - ESP_OK Success, all the data are read from the slave. - * - ESP_ERR_NOT_FINISHED Read success, while there're data remaining. - * - One of the error codes from SDMMC host controller + * - ESP_OK Success: All the data has been read from the slave. + * - ESP_ERR_INVALID_ARG: Invalid argument, The handle is not initialized or the other arguments are invalid. + * - ESP_ERR_NOT_FINISHED: Read was successful, but there is still data remaining. + * - ESP_ERR_NOT_FOUND: Slave is not ready to send data. + * - ESP_ERR_NOT_SUPPORTED: This API is not supported in this mode + * - One of the error codes from SDMMC/SPI host controller. */ esp_err_t essl_get_packet(essl_handle_t handle, void *out_data, size_t size, size_t *out_length, uint32_t wait_ms); -/** Write general purpose R/W registers (8-bit) of an ESP slave. +/** Write general purpose R/W registers (8-bit) of ESSL slave. * * @param handle Handle of an ESSL device. - * @param addr Address of register to write. Valid address: 0-59. + * @param addr Address of register to write. For SDIO, valid address: 0-59. For SPI, see ``essl_spi.h`` * @param value Value to write to the register. * @param value_o Output of the returned written value. * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. @@ -116,22 +133,20 @@ esp_err_t essl_get_packet(essl_handle_t handle, void *out_data, size_t size, siz * * @return * - ESP_OK Success - * - ESP_ERR_INVALID_ARG Address not valid. - * - One of the error codes from SDMMC host controller + * - One of the error codes from SDMMC/SPI host controller */ esp_err_t essl_write_reg(essl_handle_t handle, uint8_t addr, uint8_t value, uint8_t *value_o, uint32_t wait_ms); -/** Read general purpose R/W registers (8-bit) of an ESP slave. +/** Read general purpose R/W registers (8-bit) of ESSL slave. * - * @param handle Handle of an ESSL device. - * @param add Address of register to read. Valid address: 0-27, 32-63 (28-31 reserved, return interrupt bits on read). + * @param handle Handle of a ``essl`` device. + * @param add Address of register to read. For SDIO, Valid address: 0-27, 32-63 (28-31 reserved, return interrupt bits on read). For SPI, see ``essl_spi.h`` * @param value_o Output value read from the register. * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. * * @return * - ESP_OK Success - * - ESP_ERR_INVALID_ARG Address not valid. - * - One of the error codes from SDMMC host controller + * - One of the error codes from SDMMC/SPI host controller */ esp_err_t essl_read_reg(essl_handle_t handle, uint8_t add, uint8_t *value_o, uint32_t wait_ms); @@ -141,25 +156,26 @@ esp_err_t essl_read_reg(essl_handle_t handle, uint8_t add, uint8_t *value_o, uin * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. * * @return - * - ESP_ERR_NOT_SUPPORTED Currently our driver doesnot support SDIO with SPI interface. - * - ESP_OK If interrupt triggered. - * - ESP_ERR_TIMEOUT No interrupts before timeout. + * - ESP_OK: If interrupt is triggered. + * - ESP_ERR_NOT_SUPPORTED: Current device does not support this function. + * - ESP_ERR_TIMEOUT: No interrupts before timeout. */ esp_err_t essl_wait_int(essl_handle_t handle, uint32_t wait_ms); -/** Clear interrupt bits of an ESP slave. All the bits set in the mask will be cleared, while other bits will stay the same. +/** Clear interrupt bits of ESSL slave. All the bits set in the mask will be cleared, while other bits will stay the same. * * @param handle Handle of an ESSL device. * @param intr_mask Mask of interrupt bits to clear. * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. * * @return - * - ESP_OK Success - * - One of the error codes from SDMMC host controller + * - ESP_OK: Success + * - ESP_ERR_NOT_SUPPORTED: Current device does not support this function. + * - One of the error codes from SDMMC host controller */ esp_err_t essl_clear_intr(essl_handle_t handle, uint32_t intr_mask, uint32_t wait_ms); -/** Get interrupt bits of an ESP slave. +/** Get interrupt bits of ESSL slave. * * @param handle Handle of an ESSL device. * @param intr_raw Output of the raw interrupt bits. Set to NULL if only masked bits are read. @@ -167,25 +183,27 @@ esp_err_t essl_clear_intr(essl_handle_t handle, uint32_t intr_mask, uint32_t wai * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. * * @return - * - ESP_OK Success - * - ESP_INVALID_ARG if both ``intr_raw`` and ``intr_st`` are NULL. - * - One of the error codes from SDMMC host controller + * - ESP_OK: Success + * - ESP_INVALID_ARG: If both ``intr_raw`` and ``intr_st`` are NULL. + * - ESP_ERR_NOT_SUPPORTED: Current device does not support this function. + * - One of the error codes from SDMMC host controller */ esp_err_t essl_get_intr(essl_handle_t handle, uint32_t *intr_raw, uint32_t *intr_st, uint32_t wait_ms); -/** Set interrupt enable bits of an ESP slave. The slave only sends interrupt on the line when there is a bit both the raw status and the enable are set. +/** Set interrupt enable bits of ESSL slave. The slave only sends interrupt on the line when there is a bit both the raw status and the enable are set. * * @param handle Handle of an ESSL device. * @param ena_mask Mask of the interrupt bits to enable. * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. * * @return - * - ESP_OK Success - * - One of the error codes from SDMMC host controller + * - ESP_OK: Success + * - ESP_ERR_NOT_SUPPORTED: Current device does not support this function. + * - One of the error codes from SDMMC host controller */ esp_err_t essl_set_intr_ena(essl_handle_t handle, uint32_t ena_mask, uint32_t wait_ms); -/** Get interrupt enable bits of an ESP slave. +/** Get interrupt enable bits of ESSL slave. * * @param handle Handle of an ESSL device. * @param ena_mask_o Output of interrupt bit enable mask. @@ -204,7 +222,8 @@ esp_err_t essl_get_intr_ena(essl_handle_t handle, uint32_t *ena_mask_o, uint32_t * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. * * @return - * - ESP_OK Success - * - One of the error codes from SDMMC host controller + * - ESP_OK: Success + * - ESP_ERR_NOT_SUPPORTED: Current device does not support this function. + * - One of the error codes from SDMMC host controller */ esp_err_t essl_send_slave_intr(essl_handle_t handle, uint32_t intr_mask, uint32_t wait_ms); diff --git a/tools/sdk/esp32/include/esp_serial_slave_link/include/esp_serial_slave_link/essl_spi.h b/tools/sdk/esp32/include/esp_serial_slave_link/include/esp_serial_slave_link/essl_spi.h index a6c3c40c04f..22721d17ece 100644 --- a/tools/sdk/esp32/include/esp_serial_slave_link/include/esp_serial_slave_link/essl_spi.h +++ b/tools/sdk/esp32/include/esp_serial_slave_link/include/esp_serial_slave_link/essl_spi.h @@ -23,22 +23,141 @@ extern "C" { #endif +/// Configuration of ESSL SPI device +typedef struct { + spi_device_handle_t *spi; ///< Pointer to SPI device handle. + uint32_t tx_buf_size; ///< The pre-negotiated Master TX buffer size used by both the host and the slave. + uint8_t tx_sync_reg; ///< The pre-negotiated register ID for Master-TX-SLAVE-RX synchronization. 1 word (4 Bytes) will be reserved for the synchronization. + uint8_t rx_sync_reg; ///< The pre-negotiated register ID for Master-RX-Slave-TX synchronization. 1 word (4 Bytes) will be reserved for the synchronization. +} essl_spi_config_t; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// APIs for DMA Append Mode +// This mode has a better performance for continuous Half Duplex SPI transactions. +// +// * You can use the ``essl_spi_init_dev`` and ``essl_spi_deinit_dev`` together with APIs in ``essl.h`` to communicate +// with ESP SPI Slaves in Half Duplex DMA Append Mode. See example for SPI SLAVE HALFDUPLEX APPEND MODE. +// * You can also use the following APIs to create your own logic. +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Initialize the ESSL SPI device function list and get its handle + * + * @param[out] out_handle Output of the handle + * @param init_config Configuration for the ESSL SPI device + * @return + * - ESP_OK: On success + * - ESP_ERR_NO_MEM: Memory exhausted + * - ESP_ERR_INVALID_STATE: SPI driver is not initialized + * - ESP_ERR_INVALID_ARG: Wrong register ID + */ +esp_err_t essl_spi_init_dev(essl_handle_t *out_handle, const essl_spi_config_t *init_config); + +/** + * @brief Deinitialize the ESSL SPI device and free the memory used by the device + * + * @param handle Handle of the ESSL SPI device + * @return + * - ESP_OK: On success + * - ESP_ERR_INVALID_STATE: ESSL SPI is not in use + */ +esp_err_t essl_spi_deinit_dev(essl_handle_t handle); + +/** + * @brief Read from the shared registers + * + * @note The registers for Master/Slave synchronization are reserved. Do not use them. (see `rx_sync_reg` in `essl_spi_config_t`) + * + * @param arg Context of the component. (Member ``arg`` from ``essl_handle_t``) + * @param addr Address of the shared registers. (Valid: 0 ~ SOC_SPI_MAXIMUM_BUFFER_SIZE, registers for M/S sync are reserved, see note1). + * @param[out] out_value Read buffer for the shared registers. + * @param wait_ms Time to wait before timeout (reserved for future use, user should set this to 0). + * @return + * - ESP_OK: success + * - ESP_ERR_INVALID_STATE: ESSL SPI has not been initialized. + * - ESP_ERR_INVALID_ARG: The address argument is not valid. See note 1. + * - or other return value from :cpp:func:`spi_device_transmit`. + */ +esp_err_t essl_spi_read_reg(void *arg, uint8_t addr, uint8_t *out_value, uint32_t wait_ms); + +/** + * @brief Get a packet from Slave + * + * @param arg Context of the component. (Member ``arg`` from ``essl_handle_t``) + * @param[out] out_data Output data address + * @param size The size of the output data. + * @param wait_ms Time to wait before timeout (reserved for future use, user should set this to 0). + * @return + * - ESP_OK: On Success + * - ESP_ERR_INVALID_STATE: ESSL SPI has not been initialized. + * - ESP_ERR_INVALID_ARG: The output data address is neither DMA capable nor 4 byte-aligned + * - ESP_ERR_INVALID_SIZE: Master requires ``size`` bytes of data but Slave did not load enough bytes. + */ +esp_err_t essl_spi_get_packet(void *arg, void *out_data, size_t size, uint32_t wait_ms); + +/** + * @brief Write to the shared registers + * + * @note The registers for Master/Slave synchronization are reserved. Do not use them. (see `tx_sync_reg` in `essl_spi_config_t`) + * @note Feature of checking the actual written value (``out_value``) is not supported. + * + * @param arg Context of the component. (Member ``arg`` from ``essl_handle_t``) + * @param addr Address of the shared registers. (Valid: 0 ~ SOC_SPI_MAXIMUM_BUFFER_SIZE, registers for M/S sync are reserved, see note1) + * @param value Buffer for data to send, should be align to 4. + * @param[out] out_value Not supported, should be set to NULL. + * @param wait_ms Time to wait before timeout (reserved for future use, user should set this to 0). + * @return + * - ESP_OK: success + * - ESP_ERR_INVALID_STATE: ESSL SPI has not been initialized. + * - ESP_ERR_INVALID_ARG: The address argument is not valid. See note 1. + * - ESP_ERR_NOT_SUPPORTED: Should set ``out_value`` to NULL. See note 2. + * - or other return value from :cpp:func:`spi_device_transmit`. + * + */ +esp_err_t essl_spi_write_reg(void *arg, uint8_t addr, uint8_t value, uint8_t *out_value, uint32_t wait_ms); + +/** + * @brief Send a packet to Slave + * + * @param arg Context of the component. (Member ``arg`` from ``essl_handle_t``) + * @param data Address of the data to send + * @param size Size of the data to send. + * @param wait_ms Time to wait before timeout (reserved for future use, user should set this to 0). + * @return + * - ESP_OK: On success + * - ESP_ERR_INVALID_STATE: ESSL SPI has not been initialized. + * - ESP_ERR_INVALID_ARG: The data address is not DMA capable + * - ESP_ERR_INVALID_SIZE: Master will send ``size`` bytes of data but Slave did not load enough RX buffer + */ +esp_err_t essl_spi_send_packet(void *arg, const void *data, size_t size, uint32_t wait_ms); + +/** + * @brief Reset the counter in Master context + * + * @note Shall only be called if the slave has reset its counter. Else, Slave and Master would be desynchronized + * + * @param arg Context of the component. (Member ``arg`` from ``essl_handle_t``) + */ +void essl_spi_reset_cnt(void *arg); + //////////////////////////////////////////////////////////////////////////////// // Basic commands to communicate with the SPI Slave HD on ESP32-S2 //////////////////////////////////////////////////////////////////////////////// - /** * @brief Read the shared buffer from the slave in ISR way * + * @note The slave's HW doesn't guarantee the data in one SPI transaction is consistent. It sends data in unit of byte. + * In other words, if the slave SW attempts to update the shared register when a rdbuf SPI transaction is in-flight, + * the data got by the master will be the combination of bytes of different writes of slave SW. + * * @note ``out_data`` should be prepared in words and in the DRAM. The buffer may be written in words * by the DMA. When a byte is written, the remaining bytes in the same word will also be * overwritten, even the ``len`` is shorter than a word. * - * @param spi SPI device handle representing the slave - * @param out_data Buffer for read data, strongly suggested to be in the DRAM and align to 4 - * @param addr Address of the slave shared buffer - * @param len Length to read - * @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send. + * @param spi SPI device handle representing the slave + * @param[out] out_data Buffer for read data, strongly suggested to be in the DRAM and aligned to 4 + * @param addr Address of the slave shared buffer + * @param len Length to read + * @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send. * @return * - ESP_OK: on success * - or other return value from :cpp:func:`spi_device_transmit`. @@ -52,11 +171,11 @@ esp_err_t essl_spi_rdbuf(spi_device_handle_t spi, uint8_t *out_data, int addr, i * by the DMA. When a byte is written, the remaining bytes in the same word will also be * overwritten, even the ``len`` is shorter than a word. * - * @param spi SPI device handle representing the slave - * @param out_data Buffer for read data, strongly suggested to be in the DRAM and align to 4 - * @param addr Address of the slave shared buffer - * @param len Length to read - * @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send. + * @param spi SPI device handle representing the slave + * @param[out] out_data Buffer for read data, strongly suggested to be in the DRAM and aligned to 4 + * @param addr Address of the slave shared buffer + * @param len Length to read + * @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send. * @return * - ESP_OK: on success * - or other return value from :cpp:func:`spi_device_transmit`. @@ -71,7 +190,7 @@ esp_err_t essl_spi_rdbuf_polling(spi_device_handle_t spi, uint8_t *out_data, int * overwritten, even the ``len`` is shorter than a word. * * @param spi SPI device handle representing the slave - * @param data Buffer for data to send, strongly suggested to be in the DRAM and align to 4 + * @param data Buffer for data to send, strongly suggested to be in the DRAM * @param addr Address of the slave shared buffer, * @param len Length to write * @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send. @@ -89,7 +208,7 @@ esp_err_t essl_spi_wrbuf(spi_device_handle_t spi, const uint8_t *data, int addr, * overwritten, even the ``len`` is shorter than a word. * * @param spi SPI device handle representing the slave - * @param data Buffer for data to send, strongly suggested to be in the DRAM and align to 4 + * @param data Buffer for data to send, strongly suggested to be in the DRAM * @param addr Address of the slave shared buffer, * @param len Length to write * @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send. @@ -105,10 +224,10 @@ esp_err_t essl_spi_wrbuf_polling(spi_device_handle_t spi, const uint8_t *data, i * @note This function combines several :cpp:func:`essl_spi_rddma_seg` and one * :cpp:func:`essl_spi_rddma_done` at the end. Used when the slave is working in segment mode. * - * @param spi SPI device handle representing the slave - * @param out_data Buffer to hold the received data, strongly suggested to be in the DRAM and align to 4 - * @param len Total length of data to receive. - * @param seg_len Length of each segment, which is not larger than the maximum transaction length + * @param spi SPI device handle representing the slave + * @param[out] out_data Buffer to hold the received data, strongly suggested to be in the DRAM and aligned to 4 + * @param len Total length of data to receive. + * @param seg_len Length of each segment, which is not larger than the maximum transaction length * allowed for the spi device. Suggested to be multiples of 4. When set < 0, means send * all data in one segment (the ``rddma_done`` will still be sent.) * @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send. @@ -123,10 +242,10 @@ esp_err_t essl_spi_rddma(spi_device_handle_t spi, uint8_t *out_data, int len, in * * @note To read long buffer, call :cpp:func:`essl_spi_rddma` instead. * - * @param spi SPI device handle representing the slave - * @param out_data Buffer to hold the received data, strongly suggested to be in the DRAM and align to 4 - * @param seg_len Length of this segment - * @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send. + * @param spi SPI device handle representing the slave + * @param[out] out_data Buffer to hold the received data. strongly suggested to be in the DRAM and aligned to 4 + * @param seg_len Length of this segment + * @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send. * @return * - ESP_OK: success * - or other return value from :cpp:func:`spi_device_transmit`. @@ -155,7 +274,7 @@ esp_err_t essl_spi_rddma_done(spi_device_handle_t spi, uint32_t flags); * :cpp:func:`essl_spi_wrdma_done` at the end. Used when the slave is working in segment mode. * * @param spi SPI device handle representing the slave - * @param data Buffer for data to send, strongly suggested to be in the DRAM and align to 4 + * @param data Buffer for data to send, strongly suggested to be in the DRAM * @param len Total length of data to send. * @param seg_len Length of each segment, which is not larger than the maximum transaction length * allowed for the spi device. Suggested to be multiples of 4. When set < 0, means send @@ -173,7 +292,7 @@ esp_err_t essl_spi_wrdma(spi_device_handle_t spi, const uint8_t *data, int len, * @note To send long buffer, call :cpp:func:`essl_spi_wrdma` instead. * * @param spi SPI device handle representing the slave - * @param data Buffer for data to send, strongly suggested to be in the DRAM and align to 4 + * @param data Buffer for data to send, strongly suggested to be in the DRAM * @param seg_len Length of this segment * @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send. * @return diff --git a/tools/sdk/esp32/include/esp_system/include/esp_private/dbg_stubs.h b/tools/sdk/esp32/include/esp_system/include/esp_private/dbg_stubs.h index f3f5fba3b7b..ead23447bc7 100644 --- a/tools/sdk/esp32/include/esp_system/include/esp_private/dbg_stubs.h +++ b/tools/sdk/esp32/include/esp_system/include/esp_private/dbg_stubs.h @@ -24,13 +24,19 @@ extern "C" { * Debug stubs entries IDs */ typedef enum { - ESP_DBG_STUB_CONTROL_DATA, ///< stubs descriptor entry + ESP_DBG_STUB_MAGIC_NUM, + ESP_DBG_STUB_TABLE_SIZE, + ESP_DBG_STUB_CONTROL_DATA, ///< stubs descriptor entry ESP_DBG_STUB_ENTRY_FIRST, - ESP_DBG_STUB_ENTRY_GCOV ///< GCOV entry - = ESP_DBG_STUB_ENTRY_FIRST, + ESP_DBG_STUB_ENTRY_GCOV ///< GCOV entry + = ESP_DBG_STUB_ENTRY_FIRST, + ESP_DBG_STUB_ENTRY_CAPABILITIES, ESP_DBG_STUB_ENTRY_MAX } esp_dbg_stub_id_t; +#define ESP_DBG_STUB_MAGIC_NUM_VAL 0xFEEDBEEF +#define ESP_DBG_STUB_CAP_GCOV_TASK (1 << 0) + /** * @brief Initializes debug stubs. * @@ -45,12 +51,24 @@ void esp_dbg_stubs_init(void); * * @param id Stub ID. * @param entry Stub entry. Usually it is stub entry function address, - * but can be any value meaningfull for OpenOCD command/code. - * + * but can be any value meaningfull for OpenOCD command/code + * such as capabilities * @return ESP_OK on success, otherwise see esp_err_t */ esp_err_t esp_dbg_stub_entry_set(esp_dbg_stub_id_t id, uint32_t entry); +/** + * @brief Retrives the corresponding stub entry + * + * @param id Stub ID. + * @param entry Stub entry. Usually it is stub entry function address, + * but can be any value meaningfull for OpenOCD command/code + * such as capabilities + * + * @return ESP_OK on success, otherwise see esp_err_t + */ +esp_err_t esp_dbg_stub_entry_get(esp_dbg_stub_id_t id, uint32_t *entry); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32/include/esp_system/include/esp_task.h b/tools/sdk/esp32/include/esp_system/include/esp_task.h index 37d78bca6e8..adca9cde6bc 100644 --- a/tools/sdk/esp32/include/esp_system/include/esp_task.h +++ b/tools/sdk/esp32/include/esp_system/include/esp_task.h @@ -52,7 +52,11 @@ #define ESP_TASK_TIMER_PRIO (ESP_TASK_PRIO_MAX - 3) #define ESP_TASK_TIMER_STACK (CONFIG_ESP_TIMER_TASK_STACK_SIZE + TASK_EXTRA_STACK_SIZE) #define ESP_TASKD_EVENT_PRIO (ESP_TASK_PRIO_MAX - 5) +#if CONFIG_LWIP_TCPIP_CORE_LOCKING +#define ESP_TASKD_EVENT_STACK (CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE + TASK_EXTRA_STACK_SIZE + 2048) +#else #define ESP_TASKD_EVENT_STACK (CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE + TASK_EXTRA_STACK_SIZE) +#endif /* CONFIG_LWIP_TCPIP_CORE_LOCKING */ #define ESP_TASK_TCPIP_PRIO (ESP_TASK_PRIO_MAX - 7) #define ESP_TASK_TCPIP_STACK (CONFIG_LWIP_TCPIP_TASK_STACK_SIZE + TASK_EXTRA_STACK_SIZE) #define ESP_TASK_MAIN_PRIO (ESP_TASK_PRIO_MIN + 1) diff --git a/tools/sdk/esp32/include/esp_system/include/esp_xt_wdt.h b/tools/sdk/esp32/include/esp_system/include/esp_xt_wdt.h new file mode 100644 index 00000000000..3b39d8056dc --- /dev/null +++ b/tools/sdk/esp32/include/esp_system/include/esp_xt_wdt.h @@ -0,0 +1,63 @@ +/* + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include + +#include "esp_err.h" +#include "esp_intr_alloc.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief esp_xt_wdt configuration struct + * + */ +typedef struct { + uint8_t timeout; /*!< Watchdog timeout */ + bool auto_backup_clk_enable; /*!< Enable automatic switch to backup clock at timeout */ +} esp_xt_wdt_config_t; + +/* Callback function for WDT interrupt*/ +typedef void (*esp_xt_callback_t)(void *arg); + +/** + * @brief Initializes the xtal32k watchdog timer + * + * @param cfg Pointer to configuration struct + * @return esp_err_t + * - ESP_OK: XTWDT was successfully enabled + * - ESP_ERR_NO_MEM: Failed to allocate ISR + */ +esp_err_t esp_xt_wdt_init(const esp_xt_wdt_config_t *cfg); + +/** + * @brief Register a callback function that will be called when the watchdog + * times out. + * + * @note This function will be called from an interrupt context where the cache might be disabled. + * Thus the function should be placed in IRAM and must not perform any blocking operations. + * + * Only one callback function can be registered, any call to esp_xt_wdt_register_callback + * will override the previous callback function. + * + * @param func The callback function to register + * @param arg Pointer to argument that will be passed to the callback function + */ +void esp_xt_wdt_register_callback(esp_xt_callback_t func, void *arg); + +/** + * @brief Restores the xtal32k clock and re-enables the WDT + * + */ +void esp_xt_wdt_restore_clk(void); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32/include/esp_wifi/include/esp_mesh.h b/tools/sdk/esp32/include/esp_wifi/include/esp_mesh.h index ab8f8a4c86f..f146b5e730e 100644 --- a/tools/sdk/esp32/include/esp_wifi/include/esp_mesh.h +++ b/tools/sdk/esp32/include/esp_wifi/include/esp_mesh.h @@ -505,8 +505,13 @@ typedef struct { * @brief Mesh softAP configuration */ typedef struct { - uint8_t password[64]; /**< mesh softAP password */ - uint8_t max_connection; /**< max number of stations allowed to connect in, max 10 */ + uint8_t password[64]; /**< mesh softAP password */ + /** + * max number of stations allowed to connect in, default 6, max 10 + * = max_connection + nonmesh_max_connection + */ + uint8_t max_connection; /**< max mesh connections */ + uint8_t nonmesh_max_connection; /**< max non-mesh connections */ } mesh_ap_cfg_t; /** @@ -947,7 +952,8 @@ esp_err_t esp_mesh_set_ap_authmode(wifi_auth_mode_t authmode); wifi_auth_mode_t esp_mesh_get_ap_authmode(void); /** - * @brief Set mesh softAP max connection value + * @brief Set mesh max connection value + * - Set mesh softAP max connection = mesh max connection + non-mesh max connection * * @attention This API shall be called before mesh is started. * @@ -960,12 +966,19 @@ wifi_auth_mode_t esp_mesh_get_ap_authmode(void); esp_err_t esp_mesh_set_ap_connections(int connections); /** - * @brief Get mesh softAP max connection configuration + * @brief Get mesh max connection configuration * - * @return the number of max connections + * @return the number of mesh max connections */ int esp_mesh_get_ap_connections(void); +/** + * @brief Get non-mesh max connection configuration + * + * @return the number of non-mesh max connections + */ +int esp_mesh_get_non_mesh_connections(void); + /** * @brief Get current layer value over the mesh network * diff --git a/tools/sdk/esp32/include/esp_wifi/include/esp_wifi.h b/tools/sdk/esp32/include/esp_wifi/include/esp_wifi.h index dfd43bff440..51e03234841 100644 --- a/tools/sdk/esp32/include/esp_wifi/include/esp_wifi.h +++ b/tools/sdk/esp32/include/esp_wifi/include/esp_wifi.h @@ -1224,7 +1224,7 @@ esp_err_t esp_wifi_config_11b_rate(wifi_interface_t ifx, bool disable); * @attention 1. This API should be called after esp_wifi_init() and before esp_wifi_start(). * * @param ifx Interface to be configured. - * @param rate Only support 1M, 6M and MCS0_LGI + * @param rate Phy rate to be configured. * * @return * - ESP_OK: succeed @@ -1289,6 +1289,20 @@ esp_err_t esp_wifi_set_country_code(const char *country, bool ieee80211d_enabled */ esp_err_t esp_wifi_get_country_code(char *country); +/** + * @brief Config 80211 tx rate of specified interface + * + * @attention 1. This API should be called after esp_wifi_init() and before esp_wifi_start(). + * + * @param ifx Interface to be configured. + * @param rate Phy rate to be configured. + * + * @return + * - ESP_OK: succeed + * - others: failed + */ +esp_err_t esp_wifi_config_80211_tx_rate(wifi_interface_t ifx, wifi_phy_rate_t rate); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32/include/esp_wifi/include/esp_wifi_default.h b/tools/sdk/esp32/include/esp_wifi/include/esp_wifi_default.h index 958977bf25e..908ea2c113c 100644 --- a/tools/sdk/esp32/include/esp_wifi/include/esp_wifi_default.h +++ b/tools/sdk/esp32/include/esp_wifi/include/esp_wifi_default.h @@ -50,7 +50,7 @@ esp_err_t esp_netif_attach_wifi_ap(esp_netif_t *esp_netif); esp_err_t esp_wifi_set_default_wifi_sta_handlers(void); /** - * @brief Sets default wifi event handlers for STA interface + * @brief Sets default wifi event handlers for AP interface * * @return * - ESP_OK on success, error returned from esp_event_handler_register if failed diff --git a/tools/sdk/esp32/include/esp_wifi/include/esp_wifi_types.h b/tools/sdk/esp32/include/esp_wifi/include/esp_wifi_types.h index 03b8ae6a75e..503e8d7bb05 100644 --- a/tools/sdk/esp32/include/esp_wifi/include/esp_wifi_types.h +++ b/tools/sdk/esp32/include/esp_wifi/include/esp_wifi_types.h @@ -272,7 +272,8 @@ typedef struct { uint32_t phy_11g:1; /**< bit: 1 flag to identify if 11g mode is enabled or not */ uint32_t phy_11n:1; /**< bit: 2 flag to identify if 11n mode is enabled or not */ uint32_t phy_lr:1; /**< bit: 3 flag to identify if low rate is enabled or not */ - uint32_t reserved:28; /**< bit: 4..31 reserved */ + uint32_t is_mesh_child:1;/**< bit: 4 flag to identify mesh child */ + uint32_t reserved:27; /**< bit: 5..31 reserved */ } wifi_sta_info_t; #define ESP_WIFI_MAX_CONN_NUM (10) /**< max number of stations which can connect to ESP32 soft-AP */ @@ -669,12 +670,14 @@ typedef struct { typedef struct { uint8_t mac[6]; /**< MAC address of the station connected to ESP32 soft-AP */ uint8_t aid; /**< the aid that ESP32 soft-AP gives to the station connected to */ + bool is_mesh_child; /**< flag to identify mesh child */ } wifi_event_ap_staconnected_t; /** Argument structure for WIFI_EVENT_AP_STADISCONNECTED event */ typedef struct { uint8_t mac[6]; /**< MAC address of the station disconnects to ESP32 soft-AP */ uint8_t aid; /**< the aid that ESP32 soft-AP gave to the station disconnects to */ + bool is_mesh_child; /**< flag to identify mesh child */ } wifi_event_ap_stadisconnected_t; /** Argument structure for WIFI_EVENT_AP_PROBEREQRECVED event */ diff --git a/tools/sdk/esp32/include/freemodbus/common/include/esp_modbus_master.h b/tools/sdk/esp32/include/freemodbus/common/include/esp_modbus_master.h index 621348e1933..5d7539b08d9 100644 --- a/tools/sdk/esp32/include/freemodbus/common/include/esp_modbus_master.h +++ b/tools/sdk/esp32/include/freemodbus/common/include/esp_modbus_master.h @@ -232,7 +232,7 @@ esp_err_t mbc_master_get_cid_info(uint16_t cid, const mb_parameter_descriptor_t* * @return * - esp_err_t ESP_OK - request was successful and value buffer contains * representation of actual parameter data from slave - * - esp_err_t ESP_ERR_INVALID_ARG - invalid argument of function + * - esp_err_t ESP_ERR_INVALID_ARG - invalid argument of function or parameter descriptor * - esp_err_t ESP_ERR_INVALID_RESPONSE - an invalid response from slave * - esp_err_t ESP_ERR_INVALID_STATE - invalid state during data processing or allocation failure * - esp_err_t ESP_ERR_TIMEOUT - operation timed out and no response from slave @@ -253,7 +253,7 @@ esp_err_t mbc_master_get_parameter(uint16_t cid, char* name, uint8_t* value, uin * * @return * - esp_err_t ESP_OK - request was successful and value was saved in the slave device registers - * - esp_err_t ESP_ERR_INVALID_ARG - invalid argument of function + * - esp_err_t ESP_ERR_INVALID_ARG - invalid argument of function or parameter descriptor * - esp_err_t ESP_ERR_INVALID_RESPONSE - an invalid response from slave during processing of parameter * - esp_err_t ESP_ERR_INVALID_STATE - invalid state during data processing or allocation failure * - esp_err_t ESP_ERR_TIMEOUT - operation timed out and no response from slave diff --git a/tools/sdk/esp32s2/include/freertos/include/freertos/FreeRTOSConfig.h b/tools/sdk/esp32/include/freertos/include/esp_additions/freertos/FreeRTOSConfig.h similarity index 95% rename from tools/sdk/esp32s2/include/freertos/include/freertos/FreeRTOSConfig.h rename to tools/sdk/esp32/include/freertos/include/esp_additions/freertos/FreeRTOSConfig.h index c64cb980d85..a01a56e9fd4 100644 --- a/tools/sdk/esp32s2/include/freertos/include/freertos/FreeRTOSConfig.h +++ b/tools/sdk/esp32/include/freertos/include/esp_additions/freertos/FreeRTOSConfig.h @@ -71,10 +71,16 @@ #define FREERTOS_CONFIG_H #include "sdkconfig.h" -// The arch-specific FreeRTOSConfig.h in port//include. -#include_next "freertos/FreeRTOSConfig.h" -#if !(defined(FREERTOS_CONFIG_XTENSA_H) || defined(FREERTOS_CONFIG_RISCV_H)) +/* for likely and unlikely */ +#include "esp_compiler.h" + +// The arch-specific FreeRTOSConfig_arch.h in port//include. +#include "freertos/FreeRTOSConfig_arch.h" + +#if !(defined(FREERTOS_CONFIG_XTENSA_H) \ + || defined(FREERTOS_CONFIG_RISCV_H) \ + || defined(FREERTOS_CONFIG_LINUX_H)) #error "Needs architecture-speific FreeRTOSConfig.h!" #endif @@ -244,7 +250,9 @@ kept at 1. */ #define configKERNEL_INTERRUPT_PRIORITY 1 +#if !CONFIG_IDF_TARGET_LINUX #define configUSE_NEWLIB_REENTRANT 1 +#endif #define configSUPPORT_DYNAMIC_ALLOCATION 1 #define configSUPPORT_STATIC_ALLOCATION 1 @@ -273,11 +281,11 @@ extern void vPortCleanUpTCB ( void *pxTCB ); #endif //configUSE_TICKLESS_IDLE -#if CONFIG_ESP_COREDUMP_ENABLE +#if CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT #define configENABLE_TASK_SNAPSHOT 1 #endif #ifndef configENABLE_TASK_SNAPSHOT -#define configENABLE_TASK_SNAPSHOT 1 +#define configENABLE_TASK_SNAPSHOT 0 #endif #if CONFIG_SYSVIEW_ENABLE @@ -293,4 +301,9 @@ extern void vPortCleanUpTCB ( void *pxTCB ); #define configCHECK_MUTEX_GIVEN_BY_OWNER 0 #endif + +#define configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H 1 + +#define configTASK_NOTIFICATION_ARRAY_ENTRIES 1 + #endif /* FREERTOS_CONFIG_H */ diff --git a/tools/sdk/esp32/include/freertos/include/esp_additions/freertos/task_snapshot.h b/tools/sdk/esp32/include/freertos/include/esp_additions/freertos/task_snapshot.h new file mode 100644 index 00000000000..1ad04cce694 --- /dev/null +++ b/tools/sdk/esp32/include/freertos/include/esp_additions/freertos/task_snapshot.h @@ -0,0 +1,90 @@ +// Copyright 2015-2021 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 "freertos/FreeRTOS.h" +#include "freertos/task.h" + +#if ( configENABLE_TASK_SNAPSHOT == 1 ) + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Check `freertos_tasks_c_additions.h` file for more info + * about these functions declaration. + */ +UBaseType_t pxTCBGetSize ( void ); +ListItem_t* pxTCBGetStateListItem ( void *pxTCB ); +StackType_t* pxTCBGetStartOfStack ( void *pxTCB ); +StackType_t* pxTCBGetTopOfStack ( void *pxTCB ); +StackType_t* pxTCBGetEndOfStack ( void *pxTCB ); +List_t* pxListGetReadyTask ( UBaseType_t idx ); +List_t* pxListGetReadyPendingTask ( UBaseType_t idx ); +List_t* pxGetDelayedTaskList ( void ); +List_t* pxGetOverflowDelayedTaskList ( void ); +List_t* pxGetTasksWaitingTermination ( void ); +List_t* pxGetSuspendedTaskList ( void ); + +/** + * 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*/ +} TaskSnapshot_t; + + +/* + * This function fills array with TaskSnapshot_t structures for every task in the system. + * Used by panic handling code to get snapshots of all tasks in the system. + * Only available when configENABLE_TASK_SNAPSHOT is set to 1. + * @param pxTaskSnapshotArray Pointer to array of TaskSnapshot_t structures to store tasks snapshot data. + * @param uxArraySize Size of tasks snapshots array. + * @param pxTcbSz Pointer to store size of TCB. + * @return Number of elements stored in array. + */ +UBaseType_t uxTaskGetSnapshotAll( TaskSnapshot_t * const pxTaskSnapshotArray, const UBaseType_t uxArraySize, UBaseType_t * const pxTcbSz ); + +/* + * This function iterates over all tasks in the system. + * Used by panic handling code to iterate over tasks in the system. + * Only available when configENABLE_TASK_SNAPSHOT is set to 1. + * @note This function should not be used while FreeRTOS is running (as it doesn't acquire any locks). + * @param pxTask task handle. + * @return Handle for the next task. If pxTask is NULL, returns hadnle for the first task. + */ +TaskHandle_t pxTaskGetNext( TaskHandle_t pxTask ); + +/* + * This function fills TaskSnapshot_t structure for specified task. + * Used by panic handling code to get snapshot of a task. + * Only available when configENABLE_TASK_SNAPSHOT is set to 1. + * @note This function should not be used while FreeRTOS is running (as it doesn't acquire any locks). + * @param pxTask task handle. + * @param pxTaskSnapshot address of TaskSnapshot_t structure to fill. + */ +void vTaskGetSnapshot( TaskHandle_t pxTask, TaskSnapshot_t *pxTaskSnapshot ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/tools/sdk/esp32/include/freertos/include/esp_additions/freertos_tasks_c_additions.h b/tools/sdk/esp32/include/freertos/include/esp_additions/freertos_tasks_c_additions.h new file mode 100644 index 00000000000..464c0b3ffb9 --- /dev/null +++ b/tools/sdk/esp32/include/freertos/include/esp_additions/freertos_tasks_c_additions.h @@ -0,0 +1,80 @@ +// Copyright 2015-2021 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 + +/** + * This file will be included in `tasks.c` file, thus, it must NOT be included + * by any (other) file. + * The functions below only consist in getters for the static variables in + * `tasks.c` file. + * The only source files that should call these functions are the ones in + * `/additions` directory. + */ + +#if ( configENABLE_TASK_SNAPSHOT == 1 ) + + UBaseType_t pxTCBGetSize ( void ) + { + return sizeof(TCB_t); + } + + ListItem_t* pxTCBGetStateListItem ( void *pxTCB ) + { + return &(((TCB_t*)pxTCB)->xStateListItem); + } + + StackType_t* pxTCBGetStartOfStack ( void *pxTCB ) + { + return (StackType_t*) ((TCB_t*)pxTCB)->pxStack; + } + + StackType_t* pxTCBGetTopOfStack ( void *pxTCB ) + { + return (StackType_t*) ((TCB_t*)pxTCB)->pxTopOfStack; + } + + StackType_t* pxTCBGetEndOfStack ( void *pxTCB ) + { + return (StackType_t*) ((TCB_t*)pxTCB)->pxEndOfStack; + } + + + List_t* pxListGetReadyTask ( UBaseType_t idx ) + { + return &( pxReadyTasksLists[idx] ); + } + + List_t* pxListGetReadyPendingTask ( UBaseType_t idx ) + { + return &( xPendingReadyList[idx] ); + } + + List_t* pxGetDelayedTaskList ( void ) { + return pxDelayedTaskList; + } + + List_t* pxGetOverflowDelayedTaskList ( void ) { + return pxOverflowDelayedTaskList; + } + + List_t* pxGetTasksWaitingTermination ( void ) { + return &xTasksWaitingTermination; + } + + List_t* pxGetSuspendedTaskList ( void ) { + return &xSuspendedTaskList; + } + +#endif diff --git a/tools/sdk/esp32/include/freertos/include/freertos/FreeRTOS.h b/tools/sdk/esp32/include/freertos/include/freertos/FreeRTOS.h index 2c9c5b13d00..eb0ee6be357 100644 --- a/tools/sdk/esp32/include/freertos/include/freertos/FreeRTOS.h +++ b/tools/sdk/esp32/include/freertos/include/freertos/FreeRTOS.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ #ifndef INC_FREERTOS_H @@ -46,16 +45,16 @@ * contains the typedefs required to build FreeRTOS. Read the instructions * in FreeRTOS/source/stdint.readme for more information. */ -#include /* READ COMMENT ABOVE. */ +#include /* READ COMMENT ABOVE. */ +/* *INDENT-OFF* */ #ifdef __cplusplus -extern "C" { + extern "C" { #endif -/* for likely and unlikely */ -#include "esp_compiler.h" +/* *INDENT-ON* */ /* Application specific configuration options. */ -#include "freertos/FreeRTOSConfig.h" +#include "FreeRTOSConfig.h" /* Basic FreeRTOS definitions. */ #include "projdefs.h" @@ -65,13 +64,14 @@ extern "C" { /* Must be defaulted before configUSE_NEWLIB_REENTRANT is used below. */ #ifndef configUSE_NEWLIB_REENTRANT - #define configUSE_NEWLIB_REENTRANT 0 + #define configUSE_NEWLIB_REENTRANT 0 #endif /* Required if struct _reent is used. */ #if ( configUSE_NEWLIB_REENTRANT == 1 ) - #include + #include #endif + /* * Check all the required application specific macros have been defined. * These macros are application specific and (as downloaded) are defined @@ -79,503 +79,545 @@ extern "C" { */ #ifndef configMINIMAL_STACK_SIZE - #error Missing definition: configMINIMAL_STACK_SIZE must be defined in FreeRTOSConfig.h. configMINIMAL_STACK_SIZE defines the size (in words) of the stack allocated to the idle task. Refer to the demo project provided for your port for a suitable value. + #error Missing definition: configMINIMAL_STACK_SIZE must be defined in FreeRTOSConfig.h. configMINIMAL_STACK_SIZE defines the size (in words) of the stack allocated to the idle task. Refer to the demo project provided for your port for a suitable value. #endif #ifndef configMAX_PRIORITIES - #error Missing definition: configMAX_PRIORITIES must be defined in FreeRTOSConfig.h. See the Configuration section of the FreeRTOS API documentation for details. + #error Missing definition: configMAX_PRIORITIES must be defined in FreeRTOSConfig.h. See the Configuration section of the FreeRTOS API documentation for details. #endif #if configMAX_PRIORITIES < 1 - #error configMAX_PRIORITIES must be defined to be greater than or equal to 1. + #error configMAX_PRIORITIES must be defined to be greater than or equal to 1. #endif #ifndef configUSE_PREEMPTION - #error Missing definition: configUSE_PREEMPTION must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. + #error Missing definition: configUSE_PREEMPTION must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. #endif #ifndef configUSE_IDLE_HOOK - #error Missing definition: configUSE_IDLE_HOOK must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. + #error Missing definition: configUSE_IDLE_HOOK must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. #endif #ifndef configUSE_TICK_HOOK - #error Missing definition: configUSE_TICK_HOOK must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. + #error Missing definition: configUSE_TICK_HOOK must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. #endif #ifndef configUSE_16_BIT_TICKS - #error Missing definition: configUSE_16_BIT_TICKS must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. + #error Missing definition: configUSE_16_BIT_TICKS must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. #endif #ifndef configUSE_CO_ROUTINES - #define configUSE_CO_ROUTINES 0 + #define configUSE_CO_ROUTINES 0 #endif #ifndef INCLUDE_vTaskPrioritySet - #define INCLUDE_vTaskPrioritySet 0 + #define INCLUDE_vTaskPrioritySet 0 #endif #ifndef INCLUDE_uxTaskPriorityGet - #define INCLUDE_uxTaskPriorityGet 0 + #define INCLUDE_uxTaskPriorityGet 0 #endif #ifndef INCLUDE_vTaskDelete - #define INCLUDE_vTaskDelete 0 + #define INCLUDE_vTaskDelete 0 #endif #ifndef INCLUDE_vTaskSuspend - #define INCLUDE_vTaskSuspend 0 + #define INCLUDE_vTaskSuspend 0 +#endif + +#ifdef INCLUDE_xTaskDelayUntil + #ifdef INCLUDE_vTaskDelayUntil + /* INCLUDE_vTaskDelayUntil was replaced by INCLUDE_xTaskDelayUntil. Backward + * compatibility is maintained if only one or the other is defined, but + * there is a conflict if both are defined. */ + #error INCLUDE_vTaskDelayUntil and INCLUDE_xTaskDelayUntil are both defined. INCLUDE_vTaskDelayUntil is no longer required and should be removed + #endif #endif -#ifndef INCLUDE_vTaskDelayUntil - #define INCLUDE_vTaskDelayUntil 0 +#ifndef INCLUDE_xTaskDelayUntil + #ifdef INCLUDE_vTaskDelayUntil + /* If INCLUDE_vTaskDelayUntil is set but INCLUDE_xTaskDelayUntil is not then + * the project's FreeRTOSConfig.h probably pre-dates the introduction of + * xTaskDelayUntil and setting INCLUDE_xTaskDelayUntil to whatever + * INCLUDE_vTaskDelayUntil is set to will ensure backward compatibility. + */ + #define INCLUDE_xTaskDelayUntil INCLUDE_vTaskDelayUntil + #endif +#endif + +#ifndef INCLUDE_xTaskDelayUntil + #define INCLUDE_xTaskDelayUntil 0 #endif #ifndef INCLUDE_vTaskDelay - #define INCLUDE_vTaskDelay 0 + #define INCLUDE_vTaskDelay 0 #endif #ifndef INCLUDE_xTaskGetIdleTaskHandle - #define INCLUDE_xTaskGetIdleTaskHandle 0 + #define INCLUDE_xTaskGetIdleTaskHandle 0 #endif #ifndef INCLUDE_xTaskAbortDelay - #define INCLUDE_xTaskAbortDelay 0 + #define INCLUDE_xTaskAbortDelay 0 #endif #ifndef INCLUDE_xQueueGetMutexHolder - #define INCLUDE_xQueueGetMutexHolder 0 + #define INCLUDE_xQueueGetMutexHolder 0 #endif #ifndef INCLUDE_xSemaphoreGetMutexHolder - #define INCLUDE_xSemaphoreGetMutexHolder INCLUDE_xQueueGetMutexHolder + #define INCLUDE_xSemaphoreGetMutexHolder INCLUDE_xQueueGetMutexHolder #endif #ifndef INCLUDE_xTaskGetHandle - #define INCLUDE_xTaskGetHandle 0 + #define INCLUDE_xTaskGetHandle 0 #endif #ifndef INCLUDE_uxTaskGetStackHighWaterMark - #define INCLUDE_uxTaskGetStackHighWaterMark 0 + #define INCLUDE_uxTaskGetStackHighWaterMark 0 #endif #ifndef INCLUDE_uxTaskGetStackHighWaterMark2 - #define INCLUDE_uxTaskGetStackHighWaterMark2 0 + #define INCLUDE_uxTaskGetStackHighWaterMark2 0 #endif #ifndef INCLUDE_eTaskGetState - #define INCLUDE_eTaskGetState 0 + #define INCLUDE_eTaskGetState 0 #endif #ifndef INCLUDE_xTaskResumeFromISR - #define INCLUDE_xTaskResumeFromISR 1 + #define INCLUDE_xTaskResumeFromISR 1 #endif #ifndef INCLUDE_xTimerPendFunctionCall - #define INCLUDE_xTimerPendFunctionCall 0 + #define INCLUDE_xTimerPendFunctionCall 0 #endif #ifndef INCLUDE_xTaskGetSchedulerState - #define INCLUDE_xTaskGetSchedulerState 0 + #define INCLUDE_xTaskGetSchedulerState 0 #endif #ifndef INCLUDE_xTaskGetCurrentTaskHandle - #define INCLUDE_xTaskGetCurrentTaskHandle 0 + #define INCLUDE_xTaskGetCurrentTaskHandle 0 #endif #if configUSE_CO_ROUTINES != 0 - #ifndef configMAX_CO_ROUTINE_PRIORITIES - #error configMAX_CO_ROUTINE_PRIORITIES must be greater than or equal to 1. - #endif + #ifndef configMAX_CO_ROUTINE_PRIORITIES + #error configMAX_CO_ROUTINE_PRIORITIES must be greater than or equal to 1. + #endif #endif #ifndef configUSE_DAEMON_TASK_STARTUP_HOOK - #define configUSE_DAEMON_TASK_STARTUP_HOOK 0 + #define configUSE_DAEMON_TASK_STARTUP_HOOK 0 #endif #ifndef configUSE_APPLICATION_TASK_TAG - #define configUSE_APPLICATION_TASK_TAG 0 + #define configUSE_APPLICATION_TASK_TAG 0 #endif #ifndef configNUM_THREAD_LOCAL_STORAGE_POINTERS - #define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0 + #define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0 #endif #ifndef configUSE_RECURSIVE_MUTEXES - #define configUSE_RECURSIVE_MUTEXES 0 + #define configUSE_RECURSIVE_MUTEXES 0 #endif #ifndef configUSE_MUTEXES - #define configUSE_MUTEXES 0 + #define configUSE_MUTEXES 0 #endif #ifndef configUSE_TIMERS - #define configUSE_TIMERS 0 + #define configUSE_TIMERS 0 #endif #ifndef configUSE_COUNTING_SEMAPHORES - #define configUSE_COUNTING_SEMAPHORES 0 + #define configUSE_COUNTING_SEMAPHORES 0 #endif #ifndef configUSE_ALTERNATIVE_API - #define configUSE_ALTERNATIVE_API 0 + #define configUSE_ALTERNATIVE_API 0 #endif #ifndef portCRITICAL_NESTING_IN_TCB - #define portCRITICAL_NESTING_IN_TCB 0 + #define portCRITICAL_NESTING_IN_TCB 0 #endif #ifndef configMAX_TASK_NAME_LEN - #define configMAX_TASK_NAME_LEN 16 + #define configMAX_TASK_NAME_LEN 16 #endif #ifndef configIDLE_SHOULD_YIELD - #define configIDLE_SHOULD_YIELD 1 + #define configIDLE_SHOULD_YIELD 1 #endif #if configMAX_TASK_NAME_LEN < 1 - #error configMAX_TASK_NAME_LEN must be set to a minimum of 1 in FreeRTOSConfig.h + #error configMAX_TASK_NAME_LEN must be set to a minimum of 1 in FreeRTOSConfig.h #endif #ifndef configASSERT - #define configASSERT( x ) - #define configASSERT_DEFINED 0 + #define configASSERT( x ) + #define configASSERT_DEFINED 0 #else - #define configASSERT_DEFINED 1 + #define configASSERT_DEFINED 1 #endif -/* configPRECONDITION should be resolve to configASSERT. - The CBMC proofs need a way to track assumptions and assertions. - A configPRECONDITION statement should express an implicit invariant or assumption made. - A configASSERT statement should express an invariant that must hold explicit before calling - the code. */ +/* configPRECONDITION should be defined as configASSERT. + * The CBMC proofs need a way to track assumptions and assertions. + * A configPRECONDITION statement should express an implicit invariant or + * assumption made. A configASSERT statement should express an invariant that must + * hold explicit before calling the code. */ #ifndef configPRECONDITION - #define configPRECONDITION( X ) configASSERT(X) - #define configPRECONDITION_DEFINED 0 + #define configPRECONDITION( X ) configASSERT( X ) + #define configPRECONDITION_DEFINED 0 #else - #define configPRECONDITION_DEFINED 1 + #define configPRECONDITION_DEFINED 1 #endif #ifndef portMEMORY_BARRIER - #define portMEMORY_BARRIER() + #define portMEMORY_BARRIER() +#endif + +#ifndef portSOFTWARE_BARRIER + #define portSOFTWARE_BARRIER() #endif /* The timers module relies on xTaskGetSchedulerState(). */ #if configUSE_TIMERS == 1 - #ifndef configTIMER_TASK_PRIORITY - #error If configUSE_TIMERS is set to 1 then configTIMER_TASK_PRIORITY must also be defined. - #endif /* configTIMER_TASK_PRIORITY */ + #ifndef configTIMER_TASK_PRIORITY + #error If configUSE_TIMERS is set to 1 then configTIMER_TASK_PRIORITY must also be defined. + #endif /* configTIMER_TASK_PRIORITY */ - #ifndef configTIMER_QUEUE_LENGTH - #error If configUSE_TIMERS is set to 1 then configTIMER_QUEUE_LENGTH must also be defined. - #endif /* configTIMER_QUEUE_LENGTH */ + #ifndef configTIMER_QUEUE_LENGTH + #error If configUSE_TIMERS is set to 1 then configTIMER_QUEUE_LENGTH must also be defined. + #endif /* configTIMER_QUEUE_LENGTH */ - #ifndef configTIMER_TASK_STACK_DEPTH - #error If configUSE_TIMERS is set to 1 then configTIMER_TASK_STACK_DEPTH must also be defined. - #endif /* configTIMER_TASK_STACK_DEPTH */ + #ifndef configTIMER_TASK_STACK_DEPTH + #error If configUSE_TIMERS is set to 1 then configTIMER_TASK_STACK_DEPTH must also be defined. + #endif /* configTIMER_TASK_STACK_DEPTH */ #endif /* configUSE_TIMERS */ #ifndef portSET_INTERRUPT_MASK_FROM_ISR - #define portSET_INTERRUPT_MASK_FROM_ISR() 0 + #define portSET_INTERRUPT_MASK_FROM_ISR() 0 #endif #ifndef portCLEAR_INTERRUPT_MASK_FROM_ISR - #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusValue ) ( void ) uxSavedStatusValue + #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusValue ) ( void ) uxSavedStatusValue #endif #ifndef portCLEAN_UP_TCB - #define portCLEAN_UP_TCB( pxTCB ) ( void ) pxTCB + #define portCLEAN_UP_TCB( pxTCB ) ( void ) pxTCB #endif #ifndef portPRE_TASK_DELETE_HOOK - #define portPRE_TASK_DELETE_HOOK( pvTaskToDelete, pxYieldPending ) + #define portPRE_TASK_DELETE_HOOK( pvTaskToDelete, pxYieldPending ) #endif #ifndef portSETUP_TCB - #define portSETUP_TCB( pxTCB ) ( void ) pxTCB + #define portSETUP_TCB( pxTCB ) ( void ) pxTCB #endif #ifndef configQUEUE_REGISTRY_SIZE - #define configQUEUE_REGISTRY_SIZE 0U + #define configQUEUE_REGISTRY_SIZE 0U #endif #if ( configQUEUE_REGISTRY_SIZE < 1 ) - #define vQueueAddToRegistry( xQueue, pcName ) - #define vQueueUnregisterQueue( xQueue ) - #define pcQueueGetName( xQueue ) + #define vQueueAddToRegistry( xQueue, pcName ) + #define vQueueUnregisterQueue( xQueue ) + #define pcQueueGetName( xQueue ) #endif #ifndef portPOINTER_SIZE_TYPE - #define portPOINTER_SIZE_TYPE uint32_t + #define portPOINTER_SIZE_TYPE uint32_t #endif /* Remove any unused trace macros. */ #ifndef traceSTART - /* Used to perform any necessary initialisation - for example, open a file - into which trace is to be written. */ - #define traceSTART() + +/* Used to perform any necessary initialisation - for example, open a file + * into which trace is to be written. */ + #define traceSTART() #endif #ifndef traceEND - /* Use to close a trace, for example close a file into which trace has been - written. */ - #define traceEND() + +/* Use to close a trace, for example close a file into which trace has been + * written. */ + #define traceEND() #endif #ifndef traceTASK_SWITCHED_IN - /* Called after a task has been selected to run. pxCurrentTCB holds a pointer - to the task control block of the selected task. */ - #define traceTASK_SWITCHED_IN() + +/* Called after a task has been selected to run. pxCurrentTCB holds a pointer + * to the task control block of the selected task. */ + #define traceTASK_SWITCHED_IN() #endif #ifndef traceINCREASE_TICK_COUNT - /* Called before stepping the tick count after waking from tickless idle - sleep. */ - #define traceINCREASE_TICK_COUNT( x ) + +/* Called before stepping the tick count after waking from tickless idle + * sleep. */ + #define traceINCREASE_TICK_COUNT( x ) #endif #ifndef traceLOW_POWER_IDLE_BEGIN - /* Called immediately before entering tickless idle. */ - #define traceLOW_POWER_IDLE_BEGIN() + /* Called immediately before entering tickless idle. */ + #define traceLOW_POWER_IDLE_BEGIN() #endif -#ifndef traceLOW_POWER_IDLE_END - /* Called when returning to the Idle task after a tickless idle. */ - #define traceLOW_POWER_IDLE_END() +#ifndef traceLOW_POWER_IDLE_END + /* Called when returning to the Idle task after a tickless idle. */ + #define traceLOW_POWER_IDLE_END() #endif #ifndef traceTASK_SWITCHED_OUT - /* Called before a task has been selected to run. pxCurrentTCB holds a pointer - to the task control block of the task being switched out. */ - #define traceTASK_SWITCHED_OUT() + +/* Called before a task has been selected to run. pxCurrentTCB holds a pointer + * to the task control block of the task being switched out. */ + #define traceTASK_SWITCHED_OUT() #endif #ifndef traceTASK_PRIORITY_INHERIT - /* Called when a task attempts to take a mutex that is already held by a - lower priority task. pxTCBOfMutexHolder is a pointer to the TCB of the task - that holds the mutex. uxInheritedPriority is the priority the mutex holder - will inherit (the priority of the task that is attempting to obtain the - muted. */ - #define traceTASK_PRIORITY_INHERIT( pxTCBOfMutexHolder, uxInheritedPriority ) + +/* Called when a task attempts to take a mutex that is already held by a + * lower priority task. pxTCBOfMutexHolder is a pointer to the TCB of the task + * that holds the mutex. uxInheritedPriority is the priority the mutex holder + * will inherit (the priority of the task that is attempting to obtain the + * muted. */ + #define traceTASK_PRIORITY_INHERIT( pxTCBOfMutexHolder, uxInheritedPriority ) #endif #ifndef traceTASK_PRIORITY_DISINHERIT - /* Called when a task releases a mutex, the holding of which had resulted in - the task inheriting the priority of a higher priority task. - pxTCBOfMutexHolder is a pointer to the TCB of the task that is releasing the - mutex. uxOriginalPriority is the task's configured (base) priority. */ - #define traceTASK_PRIORITY_DISINHERIT( pxTCBOfMutexHolder, uxOriginalPriority ) + +/* Called when a task releases a mutex, the holding of which had resulted in + * the task inheriting the priority of a higher priority task. + * pxTCBOfMutexHolder is a pointer to the TCB of the task that is releasing the + * mutex. uxOriginalPriority is the task's configured (base) priority. */ + #define traceTASK_PRIORITY_DISINHERIT( pxTCBOfMutexHolder, uxOriginalPriority ) #endif #ifndef traceBLOCKING_ON_QUEUE_RECEIVE - /* Task is about to block because it cannot read from a - queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore - upon which the read was attempted. pxCurrentTCB points to the TCB of the - task that attempted the read. */ - #define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ) + +/* Task is about to block because it cannot read from a + * queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore + * upon which the read was attempted. pxCurrentTCB points to the TCB of the + * task that attempted the read. */ + #define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ) #endif #ifndef traceBLOCKING_ON_QUEUE_PEEK - /* Task is about to block because it cannot read from a - queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore - upon which the read was attempted. pxCurrentTCB points to the TCB of the - task that attempted the read. */ - #define traceBLOCKING_ON_QUEUE_PEEK( pxQueue ) + +/* Task is about to block because it cannot read from a + * queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore + * upon which the read was attempted. pxCurrentTCB points to the TCB of the + * task that attempted the read. */ + #define traceBLOCKING_ON_QUEUE_PEEK( pxQueue ) #endif #ifndef traceBLOCKING_ON_QUEUE_SEND - /* Task is about to block because it cannot write to a - queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore - upon which the write was attempted. pxCurrentTCB points to the TCB of the - task that attempted the write. */ - #define traceBLOCKING_ON_QUEUE_SEND( pxQueue ) + +/* Task is about to block because it cannot write to a + * queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore + * upon which the write was attempted. pxCurrentTCB points to the TCB of the + * task that attempted the write. */ + #define traceBLOCKING_ON_QUEUE_SEND( pxQueue ) #endif #ifndef configCHECK_FOR_STACK_OVERFLOW - #define configCHECK_FOR_STACK_OVERFLOW 0 + #define configCHECK_FOR_STACK_OVERFLOW 0 #endif #ifndef configRECORD_STACK_HIGH_ADDRESS - #define configRECORD_STACK_HIGH_ADDRESS 0 + #define configRECORD_STACK_HIGH_ADDRESS 0 #endif #ifndef configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H - #define configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H 0 + #define configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H 0 #endif /* The following event macros are embedded in the kernel API calls. */ #ifndef traceMOVED_TASK_TO_READY_STATE - #define traceMOVED_TASK_TO_READY_STATE( pxTCB ) + #define traceMOVED_TASK_TO_READY_STATE( pxTCB ) #endif #ifndef tracePOST_MOVED_TASK_TO_READY_STATE - #define tracePOST_MOVED_TASK_TO_READY_STATE( pxTCB ) + #define tracePOST_MOVED_TASK_TO_READY_STATE( pxTCB ) #endif #ifndef traceQUEUE_CREATE - #define traceQUEUE_CREATE( pxNewQueue ) + #define traceQUEUE_CREATE( pxNewQueue ) #endif #ifndef traceQUEUE_CREATE_FAILED - #define traceQUEUE_CREATE_FAILED( ucQueueType ) + #define traceQUEUE_CREATE_FAILED( ucQueueType ) #endif #ifndef traceCREATE_MUTEX - #define traceCREATE_MUTEX( pxNewQueue ) + #define traceCREATE_MUTEX( pxNewQueue ) #endif #ifndef traceCREATE_MUTEX_FAILED - #define traceCREATE_MUTEX_FAILED() + #define traceCREATE_MUTEX_FAILED() #endif #ifndef traceGIVE_MUTEX_RECURSIVE - #define traceGIVE_MUTEX_RECURSIVE( pxMutex ) + #define traceGIVE_MUTEX_RECURSIVE( pxMutex ) #endif #ifndef traceGIVE_MUTEX_RECURSIVE_FAILED - #define traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex ) + #define traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex ) #endif #ifndef traceTAKE_MUTEX_RECURSIVE - #define traceTAKE_MUTEX_RECURSIVE( pxMutex ) + #define traceTAKE_MUTEX_RECURSIVE( pxMutex ) #endif #ifndef traceTAKE_MUTEX_RECURSIVE_FAILED - #define traceTAKE_MUTEX_RECURSIVE_FAILED( pxMutex ) + #define traceTAKE_MUTEX_RECURSIVE_FAILED( pxMutex ) #endif #ifndef traceCREATE_COUNTING_SEMAPHORE - #define traceCREATE_COUNTING_SEMAPHORE() + #define traceCREATE_COUNTING_SEMAPHORE() #endif #ifndef traceCREATE_COUNTING_SEMAPHORE_FAILED - #define traceCREATE_COUNTING_SEMAPHORE_FAILED() + #define traceCREATE_COUNTING_SEMAPHORE_FAILED() #endif +#ifndef traceQUEUE_SET_SEND + #define traceQUEUE_SET_SEND traceQUEUE_SEND +#endif + +#ifdef ESP_PLATFORM #ifndef traceQUEUE_SEMAPHORE_RECEIVE - #define traceQUEUE_SEMAPHORE_RECEIVE( pxQueue ) + #define traceQUEUE_SEMAPHORE_RECEIVE( pxQueue ) #endif +#endif // ESP_PLATFORM #ifndef traceQUEUE_SEND - #define traceQUEUE_SEND( pxQueue ) + #define traceQUEUE_SEND( pxQueue ) #endif #ifndef traceQUEUE_SEND_FAILED - #define traceQUEUE_SEND_FAILED( pxQueue ) + #define traceQUEUE_SEND_FAILED( pxQueue ) #endif #ifndef traceQUEUE_RECEIVE - #define traceQUEUE_RECEIVE( pxQueue ) + #define traceQUEUE_RECEIVE( pxQueue ) #endif #ifndef traceQUEUE_PEEK - #define traceQUEUE_PEEK( pxQueue ) + #define traceQUEUE_PEEK( pxQueue ) #endif #ifndef traceQUEUE_PEEK_FAILED - #define traceQUEUE_PEEK_FAILED( pxQueue ) + #define traceQUEUE_PEEK_FAILED( pxQueue ) #endif #ifndef traceQUEUE_PEEK_FROM_ISR - #define traceQUEUE_PEEK_FROM_ISR( pxQueue ) + #define traceQUEUE_PEEK_FROM_ISR( pxQueue ) #endif #ifndef traceQUEUE_RECEIVE_FAILED - #define traceQUEUE_RECEIVE_FAILED( pxQueue ) + #define traceQUEUE_RECEIVE_FAILED( pxQueue ) #endif #ifndef traceQUEUE_SEND_FROM_ISR - #define traceQUEUE_SEND_FROM_ISR( pxQueue ) + #define traceQUEUE_SEND_FROM_ISR( pxQueue ) #endif #ifndef traceQUEUE_SEND_FROM_ISR_FAILED - #define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ) + #define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ) #endif #ifndef traceQUEUE_RECEIVE_FROM_ISR - #define traceQUEUE_RECEIVE_FROM_ISR( pxQueue ) + #define traceQUEUE_RECEIVE_FROM_ISR( pxQueue ) #endif #ifndef traceQUEUE_RECEIVE_FROM_ISR_FAILED - #define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue ) + #define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue ) #endif #ifndef traceQUEUE_PEEK_FROM_ISR_FAILED - #define traceQUEUE_PEEK_FROM_ISR_FAILED( pxQueue ) + #define traceQUEUE_PEEK_FROM_ISR_FAILED( pxQueue ) #endif #ifndef traceQUEUE_DELETE - #define traceQUEUE_DELETE( pxQueue ) + #define traceQUEUE_DELETE( pxQueue ) #endif +#ifdef ESP_PLATFORM #ifndef traceQUEUE_GIVE_FROM_ISR - #define traceQUEUE_GIVE_FROM_ISR( pxQueue ) + #define traceQUEUE_GIVE_FROM_ISR( pxQueue ) #endif #ifndef traceQUEUE_GIVE_FROM_ISR_FAILED - #define traceQUEUE_GIVE_FROM_ISR_FAILED( pxQueue ) + #define traceQUEUE_GIVE_FROM_ISR_FAILED( pxQueue ) #endif +#endif // ESP_PLATFORM #ifndef traceTASK_CREATE - #define traceTASK_CREATE( pxNewTCB ) + #define traceTASK_CREATE( pxNewTCB ) #endif #ifndef traceTASK_CREATE_FAILED - #define traceTASK_CREATE_FAILED() + #define traceTASK_CREATE_FAILED() #endif #ifndef traceTASK_DELETE - #define traceTASK_DELETE( pxTaskToDelete ) + #define traceTASK_DELETE( pxTaskToDelete ) #endif #ifndef traceTASK_DELAY_UNTIL - #define traceTASK_DELAY_UNTIL( x ) + #define traceTASK_DELAY_UNTIL( x ) #endif #ifndef traceTASK_DELAY - #define traceTASK_DELAY() + #define traceTASK_DELAY() #endif #ifndef traceTASK_PRIORITY_SET - #define traceTASK_PRIORITY_SET( pxTask, uxNewPriority ) + #define traceTASK_PRIORITY_SET( pxTask, uxNewPriority ) #endif #ifndef traceTASK_SUSPEND - #define traceTASK_SUSPEND( pxTaskToSuspend ) + #define traceTASK_SUSPEND( pxTaskToSuspend ) #endif #ifndef traceTASK_RESUME - #define traceTASK_RESUME( pxTaskToResume ) + #define traceTASK_RESUME( pxTaskToResume ) #endif #ifndef traceTASK_RESUME_FROM_ISR - #define traceTASK_RESUME_FROM_ISR( pxTaskToResume ) + #define traceTASK_RESUME_FROM_ISR( pxTaskToResume ) #endif #ifndef traceTASK_INCREMENT_TICK - #define traceTASK_INCREMENT_TICK( xTickCount ) + #define traceTASK_INCREMENT_TICK( xTickCount ) #endif #ifndef traceTIMER_CREATE - #define traceTIMER_CREATE( pxNewTimer ) + #define traceTIMER_CREATE( pxNewTimer ) #endif #ifndef traceTIMER_CREATE_FAILED - #define traceTIMER_CREATE_FAILED() + #define traceTIMER_CREATE_FAILED() #endif #ifndef traceTIMER_COMMAND_SEND - #define traceTIMER_COMMAND_SEND( xTimer, xMessageID, xMessageValueValue, xReturn ) + #define traceTIMER_COMMAND_SEND( xTimer, xMessageID, xMessageValueValue, xReturn ) #endif #ifndef traceTIMER_EXPIRED - #define traceTIMER_EXPIRED( pxTimer ) + #define traceTIMER_EXPIRED( pxTimer ) #endif #ifndef traceTIMER_COMMAND_RECEIVED - #define traceTIMER_COMMAND_RECEIVED( pxTimer, xMessageID, xMessageValue ) + #define traceTIMER_COMMAND_RECEIVED( pxTimer, xMessageID, xMessageValue ) #endif #ifndef traceMALLOC @@ -587,445 +629,470 @@ extern "C" { #endif #ifndef traceEVENT_GROUP_CREATE - #define traceEVENT_GROUP_CREATE( xEventGroup ) + #define traceEVENT_GROUP_CREATE( xEventGroup ) #endif #ifndef traceEVENT_GROUP_CREATE_FAILED - #define traceEVENT_GROUP_CREATE_FAILED() + #define traceEVENT_GROUP_CREATE_FAILED() #endif #ifndef traceEVENT_GROUP_SYNC_BLOCK - #define traceEVENT_GROUP_SYNC_BLOCK( xEventGroup, uxBitsToSet, uxBitsToWaitFor ) + #define traceEVENT_GROUP_SYNC_BLOCK( xEventGroup, uxBitsToSet, uxBitsToWaitFor ) #endif #ifndef traceEVENT_GROUP_SYNC_END - #define traceEVENT_GROUP_SYNC_END( xEventGroup, uxBitsToSet, uxBitsToWaitFor, xTimeoutOccurred ) ( void ) xTimeoutOccurred + #define traceEVENT_GROUP_SYNC_END( xEventGroup, uxBitsToSet, uxBitsToWaitFor, xTimeoutOccurred ) ( void ) xTimeoutOccurred #endif #ifndef traceEVENT_GROUP_WAIT_BITS_BLOCK - #define traceEVENT_GROUP_WAIT_BITS_BLOCK( xEventGroup, uxBitsToWaitFor ) + #define traceEVENT_GROUP_WAIT_BITS_BLOCK( xEventGroup, uxBitsToWaitFor ) #endif #ifndef traceEVENT_GROUP_WAIT_BITS_END - #define traceEVENT_GROUP_WAIT_BITS_END( xEventGroup, uxBitsToWaitFor, xTimeoutOccurred ) ( void ) xTimeoutOccurred + #define traceEVENT_GROUP_WAIT_BITS_END( xEventGroup, uxBitsToWaitFor, xTimeoutOccurred ) ( void ) xTimeoutOccurred #endif #ifndef traceEVENT_GROUP_CLEAR_BITS - #define traceEVENT_GROUP_CLEAR_BITS( xEventGroup, uxBitsToClear ) + #define traceEVENT_GROUP_CLEAR_BITS( xEventGroup, uxBitsToClear ) #endif #ifndef traceEVENT_GROUP_CLEAR_BITS_FROM_ISR - #define traceEVENT_GROUP_CLEAR_BITS_FROM_ISR( xEventGroup, uxBitsToClear ) + #define traceEVENT_GROUP_CLEAR_BITS_FROM_ISR( xEventGroup, uxBitsToClear ) #endif #ifndef traceEVENT_GROUP_SET_BITS - #define traceEVENT_GROUP_SET_BITS( xEventGroup, uxBitsToSet ) + #define traceEVENT_GROUP_SET_BITS( xEventGroup, uxBitsToSet ) #endif #ifndef traceEVENT_GROUP_SET_BITS_FROM_ISR - #define traceEVENT_GROUP_SET_BITS_FROM_ISR( xEventGroup, uxBitsToSet ) + #define traceEVENT_GROUP_SET_BITS_FROM_ISR( xEventGroup, uxBitsToSet ) #endif #ifndef traceEVENT_GROUP_DELETE - #define traceEVENT_GROUP_DELETE( xEventGroup ) + #define traceEVENT_GROUP_DELETE( xEventGroup ) #endif #ifndef tracePEND_FUNC_CALL - #define tracePEND_FUNC_CALL(xFunctionToPend, pvParameter1, ulParameter2, ret) + #define tracePEND_FUNC_CALL( xFunctionToPend, pvParameter1, ulParameter2, ret ) #endif #ifndef tracePEND_FUNC_CALL_FROM_ISR - #define tracePEND_FUNC_CALL_FROM_ISR(xFunctionToPend, pvParameter1, ulParameter2, ret) + #define tracePEND_FUNC_CALL_FROM_ISR( xFunctionToPend, pvParameter1, ulParameter2, ret ) #endif #ifndef traceQUEUE_REGISTRY_ADD - #define traceQUEUE_REGISTRY_ADD(xQueue, pcQueueName) + #define traceQUEUE_REGISTRY_ADD( xQueue, pcQueueName ) #endif #ifndef traceTASK_NOTIFY_TAKE_BLOCK - #define traceTASK_NOTIFY_TAKE_BLOCK() + #define traceTASK_NOTIFY_TAKE_BLOCK( uxIndexToWait ) #endif #ifndef traceTASK_NOTIFY_TAKE - #define traceTASK_NOTIFY_TAKE() + #define traceTASK_NOTIFY_TAKE( uxIndexToWait ) #endif #ifndef traceTASK_NOTIFY_WAIT_BLOCK - #define traceTASK_NOTIFY_WAIT_BLOCK() + #define traceTASK_NOTIFY_WAIT_BLOCK( uxIndexToWait ) #endif #ifndef traceTASK_NOTIFY_WAIT - #define traceTASK_NOTIFY_WAIT() + #define traceTASK_NOTIFY_WAIT( uxIndexToWait ) #endif #ifndef traceTASK_NOTIFY - #define traceTASK_NOTIFY() + #define traceTASK_NOTIFY( uxIndexToNotify ) #endif #ifndef traceTASK_NOTIFY_FROM_ISR - #define traceTASK_NOTIFY_FROM_ISR() + #define traceTASK_NOTIFY_FROM_ISR( uxIndexToNotify ) #endif #ifndef traceTASK_NOTIFY_GIVE_FROM_ISR - #define traceTASK_NOTIFY_GIVE_FROM_ISR() + #define traceTASK_NOTIFY_GIVE_FROM_ISR( uxIndexToNotify ) #endif #ifndef traceSTREAM_BUFFER_CREATE_FAILED - #define traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer ) + #define traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer ) #endif #ifndef traceSTREAM_BUFFER_CREATE_STATIC_FAILED - #define traceSTREAM_BUFFER_CREATE_STATIC_FAILED( xReturn, xIsMessageBuffer ) + #define traceSTREAM_BUFFER_CREATE_STATIC_FAILED( xReturn, xIsMessageBuffer ) #endif #ifndef traceSTREAM_BUFFER_CREATE - #define traceSTREAM_BUFFER_CREATE( pxStreamBuffer, xIsMessageBuffer ) + #define traceSTREAM_BUFFER_CREATE( pxStreamBuffer, xIsMessageBuffer ) #endif #ifndef traceSTREAM_BUFFER_DELETE - #define traceSTREAM_BUFFER_DELETE( xStreamBuffer ) + #define traceSTREAM_BUFFER_DELETE( xStreamBuffer ) #endif #ifndef traceSTREAM_BUFFER_RESET - #define traceSTREAM_BUFFER_RESET( xStreamBuffer ) + #define traceSTREAM_BUFFER_RESET( xStreamBuffer ) #endif #ifndef traceBLOCKING_ON_STREAM_BUFFER_SEND - #define traceBLOCKING_ON_STREAM_BUFFER_SEND( xStreamBuffer ) + #define traceBLOCKING_ON_STREAM_BUFFER_SEND( xStreamBuffer ) #endif #ifndef traceSTREAM_BUFFER_SEND - #define traceSTREAM_BUFFER_SEND( xStreamBuffer, xBytesSent ) + #define traceSTREAM_BUFFER_SEND( xStreamBuffer, xBytesSent ) #endif #ifndef traceSTREAM_BUFFER_SEND_FAILED - #define traceSTREAM_BUFFER_SEND_FAILED( xStreamBuffer ) + #define traceSTREAM_BUFFER_SEND_FAILED( xStreamBuffer ) #endif #ifndef traceSTREAM_BUFFER_SEND_FROM_ISR - #define traceSTREAM_BUFFER_SEND_FROM_ISR( xStreamBuffer, xBytesSent ) + #define traceSTREAM_BUFFER_SEND_FROM_ISR( xStreamBuffer, xBytesSent ) #endif #ifndef traceBLOCKING_ON_STREAM_BUFFER_RECEIVE - #define traceBLOCKING_ON_STREAM_BUFFER_RECEIVE( xStreamBuffer ) + #define traceBLOCKING_ON_STREAM_BUFFER_RECEIVE( xStreamBuffer ) #endif #ifndef traceSTREAM_BUFFER_RECEIVE - #define traceSTREAM_BUFFER_RECEIVE( xStreamBuffer, xReceivedLength ) + #define traceSTREAM_BUFFER_RECEIVE( xStreamBuffer, xReceivedLength ) #endif #ifndef traceSTREAM_BUFFER_RECEIVE_FAILED - #define traceSTREAM_BUFFER_RECEIVE_FAILED( xStreamBuffer ) + #define traceSTREAM_BUFFER_RECEIVE_FAILED( xStreamBuffer ) #endif #ifndef traceSTREAM_BUFFER_RECEIVE_FROM_ISR - #define traceSTREAM_BUFFER_RECEIVE_FROM_ISR( xStreamBuffer, xReceivedLength ) + #define traceSTREAM_BUFFER_RECEIVE_FROM_ISR( xStreamBuffer, xReceivedLength ) #endif +#ifdef ESP_PLATFORM #ifndef traceISR_EXIT_TO_SCHEDULER - #define traceISR_EXIT_TO_SCHEDULER() + #define traceISR_EXIT_TO_SCHEDULER() #endif #ifndef traceISR_EXIT - #define traceISR_EXIT() + #define traceISR_EXIT() #endif #ifndef traceISR_ENTER - #define traceISR_ENTER(_n_) + #define traceISR_ENTER(_n_) #endif +#endif // ESP_PLATFORM #ifndef configGENERATE_RUN_TIME_STATS - #define configGENERATE_RUN_TIME_STATS 0 + #define configGENERATE_RUN_TIME_STATS 0 #endif #if ( configGENERATE_RUN_TIME_STATS == 1 ) - #ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS - #error If configGENERATE_RUN_TIME_STATS is defined then portCONFIGURE_TIMER_FOR_RUN_TIME_STATS must also be defined. portCONFIGURE_TIMER_FOR_RUN_TIME_STATS should call a port layer function to setup a peripheral timer/counter that can then be used as the run time counter time base. - #endif /* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS */ + #ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS + #error If configGENERATE_RUN_TIME_STATS is defined then portCONFIGURE_TIMER_FOR_RUN_TIME_STATS must also be defined. portCONFIGURE_TIMER_FOR_RUN_TIME_STATS should call a port layer function to setup a peripheral timer/counter that can then be used as the run time counter time base. + #endif /* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS */ - #ifndef portGET_RUN_TIME_COUNTER_VALUE - #ifndef portALT_GET_RUN_TIME_COUNTER_VALUE - #error If configGENERATE_RUN_TIME_STATS is defined then either portGET_RUN_TIME_COUNTER_VALUE or portALT_GET_RUN_TIME_COUNTER_VALUE must also be defined. See the examples provided and the FreeRTOS web site for more information. - #endif /* portALT_GET_RUN_TIME_COUNTER_VALUE */ - #endif /* portGET_RUN_TIME_COUNTER_VALUE */ + #ifndef portGET_RUN_TIME_COUNTER_VALUE + #ifndef portALT_GET_RUN_TIME_COUNTER_VALUE + #error If configGENERATE_RUN_TIME_STATS is defined then either portGET_RUN_TIME_COUNTER_VALUE or portALT_GET_RUN_TIME_COUNTER_VALUE must also be defined. See the examples provided and the FreeRTOS web site for more information. + #endif /* portALT_GET_RUN_TIME_COUNTER_VALUE */ + #endif /* portGET_RUN_TIME_COUNTER_VALUE */ #endif /* configGENERATE_RUN_TIME_STATS */ #ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS - #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() + #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() #endif #ifndef configUSE_MALLOC_FAILED_HOOK - #define configUSE_MALLOC_FAILED_HOOK 0 + #define configUSE_MALLOC_FAILED_HOOK 0 #endif #ifndef portPRIVILEGE_BIT - #define portPRIVILEGE_BIT ( ( UBaseType_t ) 0x00 ) + #define portPRIVILEGE_BIT ( ( UBaseType_t ) 0x00 ) #endif #ifndef portYIELD_WITHIN_API - #define portYIELD_WITHIN_API portYIELD + #define portYIELD_WITHIN_API portYIELD #endif #ifndef portSUPPRESS_TICKS_AND_SLEEP - #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) + #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) #endif #ifndef configEXPECTED_IDLE_TIME_BEFORE_SLEEP - #define configEXPECTED_IDLE_TIME_BEFORE_SLEEP 2 + #define configEXPECTED_IDLE_TIME_BEFORE_SLEEP 2 #endif #if configEXPECTED_IDLE_TIME_BEFORE_SLEEP < 2 - #error configEXPECTED_IDLE_TIME_BEFORE_SLEEP must not be less than 2 + #error configEXPECTED_IDLE_TIME_BEFORE_SLEEP must not be less than 2 #endif #ifndef configUSE_TICKLESS_IDLE - #define configUSE_TICKLESS_IDLE 0 + #define configUSE_TICKLESS_IDLE 0 #endif #ifndef configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING - #define configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING( x ) + #define configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING( x ) #endif #ifndef configPRE_SLEEP_PROCESSING - #define configPRE_SLEEP_PROCESSING( x ) + #define configPRE_SLEEP_PROCESSING( x ) #endif #ifndef configPOST_SLEEP_PROCESSING - #define configPOST_SLEEP_PROCESSING( x ) + #define configPOST_SLEEP_PROCESSING( x ) #endif #ifndef configUSE_QUEUE_SETS - #define configUSE_QUEUE_SETS 0 + #define configUSE_QUEUE_SETS 0 #endif #ifndef portTASK_USES_FLOATING_POINT - #define portTASK_USES_FLOATING_POINT() + #define portTASK_USES_FLOATING_POINT() #endif #ifndef portALLOCATE_SECURE_CONTEXT - #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) #endif #ifndef portDONT_DISCARD - #define portDONT_DISCARD + #define portDONT_DISCARD #endif #ifndef configUSE_TIME_SLICING - #define configUSE_TIME_SLICING 1 + #define configUSE_TIME_SLICING 1 #endif #ifndef configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS - #define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS 0 + #define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS 0 #endif #ifndef configUSE_STATS_FORMATTING_FUNCTIONS - #define configUSE_STATS_FORMATTING_FUNCTIONS 0 + #define configUSE_STATS_FORMATTING_FUNCTIONS 0 #endif #ifndef portASSERT_IF_INTERRUPT_PRIORITY_INVALID - #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() + #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() #endif #ifndef configUSE_TRACE_FACILITY - #define configUSE_TRACE_FACILITY 0 + #define configUSE_TRACE_FACILITY 0 #endif #ifndef mtCOVERAGE_TEST_MARKER - #define mtCOVERAGE_TEST_MARKER() + #define mtCOVERAGE_TEST_MARKER() #endif #ifndef mtCOVERAGE_TEST_DELAY - #define mtCOVERAGE_TEST_DELAY() + #define mtCOVERAGE_TEST_DELAY() #endif #ifndef portASSERT_IF_IN_ISR - #define portASSERT_IF_IN_ISR() + #define portASSERT_IF_IN_ISR() #endif #ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION - #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 + #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 #endif #ifndef configAPPLICATION_ALLOCATED_HEAP - #define configAPPLICATION_ALLOCATED_HEAP 0 + #define configAPPLICATION_ALLOCATED_HEAP 0 #endif #ifndef configUSE_TASK_NOTIFICATIONS - #define configUSE_TASK_NOTIFICATIONS 1 + #define configUSE_TASK_NOTIFICATIONS 1 +#endif + +#ifndef configTASK_NOTIFICATION_ARRAY_ENTRIES + #define configTASK_NOTIFICATION_ARRAY_ENTRIES 1 +#endif + +#if configTASK_NOTIFICATION_ARRAY_ENTRIES < 1 + #error configTASK_NOTIFICATION_ARRAY_ENTRIES must be at least 1 #endif #ifndef configUSE_POSIX_ERRNO - #define configUSE_POSIX_ERRNO 0 + #define configUSE_POSIX_ERRNO 0 #endif #ifndef portTICK_TYPE_IS_ATOMIC - #define portTICK_TYPE_IS_ATOMIC 0 + #define portTICK_TYPE_IS_ATOMIC 0 #endif #ifndef configSUPPORT_STATIC_ALLOCATION - /* Defaults to 0 for backward compatibility. */ - #define configSUPPORT_STATIC_ALLOCATION 0 + /* Defaults to 0 for backward compatibility. */ + #define configSUPPORT_STATIC_ALLOCATION 0 #endif #ifndef configSUPPORT_DYNAMIC_ALLOCATION - /* Defaults to 1 for backward compatibility. */ - #define configSUPPORT_DYNAMIC_ALLOCATION 1 + /* Defaults to 1 for backward compatibility. */ + #define configSUPPORT_DYNAMIC_ALLOCATION 1 +#endif + +#ifndef configSTACK_ALLOCATION_FROM_SEPARATE_HEAP + /* Defaults to 0 for backward compatibility. */ + #define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0 #endif #ifndef configSTACK_DEPTH_TYPE - /* Defaults to uint16_t for backward compatibility, but can be overridden - in FreeRTOSConfig.h if uint16_t is too restrictive. */ - #define configSTACK_DEPTH_TYPE uint16_t + +/* Defaults to uint16_t for backward compatibility, but can be overridden + * in FreeRTOSConfig.h if uint16_t is too restrictive. */ + #define configSTACK_DEPTH_TYPE uint16_t #endif #ifndef configMESSAGE_BUFFER_LENGTH_TYPE - /* Defaults to size_t for backward compatibility, but can be overridden - in FreeRTOSConfig.h if lengths will always be less than the number of bytes - in a size_t. */ - #define configMESSAGE_BUFFER_LENGTH_TYPE size_t + +/* Defaults to size_t for backward compatibility, but can be overridden + * in FreeRTOSConfig.h if lengths will always be less than the number of bytes + * in a size_t. */ + #define configMESSAGE_BUFFER_LENGTH_TYPE size_t #endif /* Sanity check the configuration. */ -#if( configUSE_TICKLESS_IDLE != 0 ) - #if( INCLUDE_vTaskSuspend != 1 ) - #error INCLUDE_vTaskSuspend must be set to 1 if configUSE_TICKLESS_IDLE is not set to 0 - #endif /* INCLUDE_vTaskSuspend */ +#if ( configUSE_TICKLESS_IDLE != 0 ) + #if ( INCLUDE_vTaskSuspend != 1 ) + #error INCLUDE_vTaskSuspend must be set to 1 if configUSE_TICKLESS_IDLE is not set to 0 + #endif /* INCLUDE_vTaskSuspend */ #endif /* configUSE_TICKLESS_IDLE */ -#if( ( configSUPPORT_STATIC_ALLOCATION == 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 0 ) ) - #error configSUPPORT_STATIC_ALLOCATION and configSUPPORT_DYNAMIC_ALLOCATION cannot both be 0, but can both be 1. +#if ( ( configSUPPORT_STATIC_ALLOCATION == 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 0 ) ) + #error configSUPPORT_STATIC_ALLOCATION and configSUPPORT_DYNAMIC_ALLOCATION cannot both be 0, but can both be 1. #endif -#if( ( configUSE_RECURSIVE_MUTEXES == 1 ) && ( configUSE_MUTEXES != 1 ) ) - #error configUSE_MUTEXES must be set to 1 to use recursive mutexes +#if ( ( configUSE_RECURSIVE_MUTEXES == 1 ) && ( configUSE_MUTEXES != 1 ) ) + #error configUSE_MUTEXES must be set to 1 to use recursive mutexes #endif #ifndef configINITIAL_TICK_COUNT - #define configINITIAL_TICK_COUNT 0 + #define configINITIAL_TICK_COUNT 0 #endif -#if( portTICK_TYPE_IS_ATOMIC == 0 ) - /* Either variables of tick type cannot be read atomically, or - portTICK_TYPE_IS_ATOMIC was not set - map the critical sections used when - the tick count is returned to the standard critical section macros. */ - #define portTICK_TYPE_ENTER_CRITICAL(mux) portENTER_CRITICAL(mux) - #define portTICK_TYPE_EXIT_CRITICAL(mux) portEXIT_CRITICAL(mux) - #define portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR() portSET_INTERRUPT_MASK_FROM_ISR() - #define portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( x ) portCLEAR_INTERRUPT_MASK_FROM_ISR( ( x ) ) +#if ( portTICK_TYPE_IS_ATOMIC == 0 ) + +/* Either variables of tick type cannot be read atomically, or + * portTICK_TYPE_IS_ATOMIC was not set - map the critical sections used when + * the tick count is returned to the standard critical section macros. */ + #define portTICK_TYPE_ENTER_CRITICAL(mux) portENTER_CRITICAL(mux) + #define portTICK_TYPE_EXIT_CRITICAL(mux) portEXIT_CRITICAL(mux) + #define portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR() portSET_INTERRUPT_MASK_FROM_ISR() + #define portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( x ) portCLEAR_INTERRUPT_MASK_FROM_ISR( ( x ) ) #else - /* The tick type can be read atomically, so critical sections used when the - tick count is returned can be defined away. */ - #define portTICK_TYPE_ENTER_CRITICAL() - #define portTICK_TYPE_EXIT_CRITICAL() - #define portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR() 0 - #define portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( x ) ( void ) x -#endif + +/* The tick type can be read atomically, so critical sections used when the + * tick count is returned can be defined away. */ + #define portTICK_TYPE_ENTER_CRITICAL() + #define portTICK_TYPE_EXIT_CRITICAL() + #define portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR() 0 + #define portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( x ) ( void ) x +#endif /* if ( portTICK_TYPE_IS_ATOMIC == 0 ) */ /* Definitions to allow backward compatibility with FreeRTOS versions prior to -V8 if desired. */ + * V8 if desired. */ #ifndef configENABLE_BACKWARD_COMPATIBILITY - #define configENABLE_BACKWARD_COMPATIBILITY 1 + #define configENABLE_BACKWARD_COMPATIBILITY 1 #endif #ifndef configPRINTF - /* configPRINTF() was not defined, so define it away to nothing. To use - configPRINTF() then define it as follows (where MyPrintFunction() is - provided by the application writer): - void MyPrintFunction(const char *pcFormat, ... ); - #define configPRINTF( X ) MyPrintFunction X - - Then call like a standard printf() function, but placing brackets around - all parameters so they are passed as a single parameter. For example: - configPRINTF( ("Value = %d", MyVariable) ); */ - #define configPRINTF( X ) +/* configPRINTF() was not defined, so define it away to nothing. To use + * configPRINTF() then define it as follows (where MyPrintFunction() is + * provided by the application writer): + * + * void MyPrintFunction(const char *pcFormat, ... ); + #define configPRINTF( X ) MyPrintFunction X + * + * Then call like a standard printf() function, but placing brackets around + * all parameters so they are passed as a single parameter. For example: + * configPRINTF( ("Value = %d", MyVariable) ); */ + #define configPRINTF( X ) #endif #ifndef configMAX - /* The application writer has not provided their own MAX macro, so define - the following generic implementation. */ - #define configMAX( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) ) + +/* The application writer has not provided their own MAX macro, so define + * the following generic implementation. */ + #define configMAX( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) ) #endif #ifndef configMIN - /* The application writer has not provided their own MAX macro, so define - the following generic implementation. */ - #define configMIN( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) ) + +/* The application writer has not provided their own MIN macro, so define + * the following generic implementation. */ + #define configMIN( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) ) #endif #if configENABLE_BACKWARD_COMPATIBILITY == 1 - #define eTaskStateGet eTaskGetState - #define portTickType TickType_t - #define xTaskHandle TaskHandle_t - #define xQueueHandle QueueHandle_t - #define xSemaphoreHandle SemaphoreHandle_t - #define xQueueSetHandle QueueSetHandle_t - #define xQueueSetMemberHandle QueueSetMemberHandle_t - #define xTimeOutType TimeOut_t - #define xMemoryRegion MemoryRegion_t - #define xTaskParameters TaskParameters_t - #define xTaskStatusType TaskStatus_t - #define xTimerHandle TimerHandle_t - #define xCoRoutineHandle CoRoutineHandle_t - #define pdTASK_HOOK_CODE TaskHookFunction_t - #define portTICK_RATE_MS portTICK_PERIOD_MS - #define pcTaskGetTaskName pcTaskGetName - #define pcTimerGetTimerName pcTimerGetName - #define pcQueueGetQueueName pcQueueGetName - #define vTaskGetTaskInfo vTaskGetInfo - - /* Backward compatibility within the scheduler code only - these definitions - are not really required but are included for completeness. */ - #define tmrTIMER_CALLBACK TimerCallbackFunction_t - #define pdTASK_CODE TaskFunction_t - #define xListItem ListItem_t - #define xList List_t - - /* For libraries that break the list data hiding, and access list structure - members directly (which is not supposed to be done). */ - #define pxContainer pvContainer + #define eTaskStateGet eTaskGetState + #define portTickType TickType_t + #define xTaskHandle TaskHandle_t + #define xQueueHandle QueueHandle_t + #define xSemaphoreHandle SemaphoreHandle_t + #define xQueueSetHandle QueueSetHandle_t + #define xQueueSetMemberHandle QueueSetMemberHandle_t + #define xTimeOutType TimeOut_t + #define xMemoryRegion MemoryRegion_t + #define xTaskParameters TaskParameters_t + #define xTaskStatusType TaskStatus_t + #define xTimerHandle TimerHandle_t + #define xCoRoutineHandle CoRoutineHandle_t + #define pdTASK_HOOK_CODE TaskHookFunction_t + #define portTICK_RATE_MS portTICK_PERIOD_MS + #define pcTaskGetTaskName pcTaskGetName + #define pcTimerGetTimerName pcTimerGetName + #define pcQueueGetQueueName pcQueueGetName + #define vTaskGetTaskInfo vTaskGetInfo + #define xTaskGetIdleRunTimeCounter ulTaskGetIdleRunTimeCounter + +/* Backward compatibility within the scheduler code only - these definitions + * are not really required but are included for completeness. */ + #define tmrTIMER_CALLBACK TimerCallbackFunction_t + #define pdTASK_CODE TaskFunction_t + #define xListItem ListItem_t + #define xList List_t + +/* For libraries that break the list data hiding, and access list structure + * members directly (which is not supposed to be done). */ + #define pxContainer pvContainer #endif /* configENABLE_BACKWARD_COMPATIBILITY */ +#ifdef ESP_PLATFORM #ifndef configESP32_PER_TASK_DATA - #define configESP32_PER_TASK_DATA 1 + #define configESP32_PER_TASK_DATA 1 #endif +#endif // ESP_PLATFORM -#if( configUSE_ALTERNATIVE_API != 0 ) - #error The alternative API was deprecated some time ago, and was removed in FreeRTOS V9.0 0 +#if ( configUSE_ALTERNATIVE_API != 0 ) + #error The alternative API was deprecated some time ago, and was removed in FreeRTOS V9.0 0 #endif /* Set configUSE_TASK_FPU_SUPPORT to 0 to omit floating point support even -if floating point hardware is otherwise supported by the FreeRTOS port in use. -This constant is not supported by all FreeRTOS ports that include floating -point support. */ + * if floating point hardware is otherwise supported by the FreeRTOS port in use. + * This constant is not supported by all FreeRTOS ports that include floating + * point support. */ #ifndef configUSE_TASK_FPU_SUPPORT - #define configUSE_TASK_FPU_SUPPORT 1 + #define configUSE_TASK_FPU_SUPPORT 1 #endif /* Set configENABLE_MPU to 1 to enable MPU support and 0 to disable it. This is -currently used in ARMv8M ports. */ + * currently used in ARMv8M ports. */ #ifndef configENABLE_MPU - #define configENABLE_MPU 0 + #define configENABLE_MPU 0 #endif /* Set configENABLE_FPU to 1 to enable FPU support and 0 to disable it. This is -currently used in ARMv8M ports. */ + * currently used in ARMv8M ports. */ #ifndef configENABLE_FPU - #define configENABLE_FPU 1 + #define configENABLE_FPU 1 #endif /* Set configENABLE_TRUSTZONE to 1 enable TrustZone support and 0 to disable it. -This is currently used in ARMv8M ports. */ + * This is currently used in ARMv8M ports. */ #ifndef configENABLE_TRUSTZONE - #define configENABLE_TRUSTZONE 1 + #define configENABLE_TRUSTZONE 1 #endif /* Set configRUN_FREERTOS_SECURE_ONLY to 1 to run the FreeRTOS ARMv8M port on -the Secure Side only. */ + * the Secure Side only. */ #ifndef configRUN_FREERTOS_SECURE_ONLY - #define configRUN_FREERTOS_SECURE_ONLY 0 + #define configRUN_FREERTOS_SECURE_ONLY 0 #endif /* Sometimes the FreeRTOSConfig.h settings only allow a task to be created using @@ -1070,55 +1137,56 @@ the Secure Side only. */ * | | | | xTaskCreateRestrictedStatic | | | | * +-----+---------+--------+-----------------------------+-----------------------------------+------------------+-----------+ */ -#define tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE ( ( ( portUSING_MPU_WRAPPERS == 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) || \ - ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) ) +#define tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE \ + ( ( ( portUSING_MPU_WRAPPERS == 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) || \ + ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) ) /* * In line with software engineering best practice, FreeRTOS implements a strict * data hiding policy, so the real structures used by FreeRTOS to maintain the * state of tasks, queues, semaphores, etc. are not accessible to the application * code. However, if the application writer wants to statically allocate such - * an object then the size of the object needs to be know. Dummy structures + * an object then the size of the object needs to be known. Dummy structures * that are guaranteed to have the same size and alignment requirements of the * real objects are used for this purpose. The dummy list and list item * structures below are used for inclusion in such a dummy structure. */ struct xSTATIC_LIST_ITEM { - #if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) - TickType_t xDummy1; - #endif - TickType_t xDummy2; - void *pvDummy3[ 4 ]; - #if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) - TickType_t xDummy4; - #endif + #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) + TickType_t xDummy1; + #endif + TickType_t xDummy2; + void * pvDummy3[ 4 ]; + #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) + TickType_t xDummy4; + #endif }; typedef struct xSTATIC_LIST_ITEM StaticListItem_t; /* See the comments above the struct xSTATIC_LIST_ITEM definition. */ struct xSTATIC_MINI_LIST_ITEM { - #if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) - TickType_t xDummy1; - #endif - TickType_t xDummy2; - void *pvDummy3[ 2 ]; + #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) + TickType_t xDummy1; + #endif + TickType_t xDummy2; + void * pvDummy3[ 2 ]; }; typedef struct xSTATIC_MINI_LIST_ITEM StaticMiniListItem_t; /* See the comments above the struct xSTATIC_LIST_ITEM definition. */ typedef struct xSTATIC_LIST { - #if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) - TickType_t xDummy1; - #endif - UBaseType_t uxDummy2; - void *pvDummy3; - StaticMiniListItem_t xDummy4; - #if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) - TickType_t xDummy5; - #endif + #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) + TickType_t xDummy1; + #endif + UBaseType_t uxDummy2; + void * pvDummy3; + StaticMiniListItem_t xDummy4; + #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) + TickType_t xDummy5; + #endif } StaticList_t; /* @@ -1127,7 +1195,7 @@ typedef struct xSTATIC_LIST * strict data hiding policy. This means the Task 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 task then - * the size of the task object needs to be know. The StaticTask_t structure + * the size of the task object needs to be known. The StaticTask_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 @@ -1136,56 +1204,56 @@ typedef struct xSTATIC_LIST */ typedef struct xSTATIC_TCB { - void *pxDummy1; - #if ( portUSING_MPU_WRAPPERS == 1 ) - xMPU_SETTINGS xDummy2; - #endif - StaticListItem_t xDummy3[ 2 ]; - UBaseType_t uxDummy5; - void *pxDummy6; - uint8_t ucDummy7[ configMAX_TASK_NAME_LEN ]; - BaseType_t xDummyCore; - #if ( ( portSTACK_GROWTH > 0 ) || ( configRECORD_STACK_HIGH_ADDRESS == 1 ) ) - void *pxDummy8; - #endif - #if ( portCRITICAL_NESTING_IN_TCB == 1 ) - UBaseType_t uxDummy9; - #endif - #if ( configUSE_TRACE_FACILITY == 1 ) - UBaseType_t uxDummy10[ 2 ]; - #endif - #if ( configUSE_MUTEXES == 1 ) - UBaseType_t uxDummy12[ 2 ]; - #endif - #if ( configUSE_APPLICATION_TASK_TAG == 1 ) - void *pxDummy14; - #endif - #if( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) - void *pvDummy15[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ]; - #if ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS ) - void *pvDummyLocalStorageCallBack[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ]; - #endif - #endif - #if ( configGENERATE_RUN_TIME_STATS == 1 ) - uint32_t ulDummy16; - #endif - #if ( configUSE_NEWLIB_REENTRANT == 1 ) - struct _reent xDummy17; - #endif - #if ( configUSE_TASK_NOTIFICATIONS == 1 ) - uint32_t ulDummy18; - uint8_t ucDummy19; - #endif - #if ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) - uint8_t uxDummy20; - #endif - - #if( INCLUDE_xTaskAbortDelay == 1 ) - uint8_t ucDummy21; - #endif - #if ( configUSE_POSIX_ERRNO == 1 ) - int iDummy22; - #endif + void * pxDummy1; + #if ( portUSING_MPU_WRAPPERS == 1 ) + xMPU_SETTINGS xDummy2; + #endif + StaticListItem_t xDummy3[ 2 ]; + UBaseType_t uxDummy5; + void * pxDummy6; + uint8_t ucDummy7[ configMAX_TASK_NAME_LEN ]; + BaseType_t xDummyCore; + #if ( ( portSTACK_GROWTH > 0 ) || ( configRECORD_STACK_HIGH_ADDRESS == 1 ) ) + void * pxDummy8; + #endif + #if ( portCRITICAL_NESTING_IN_TCB == 1 ) + UBaseType_t uxDummy9; + #endif + #if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxDummy10[ 2 ]; + #endif + #if ( configUSE_MUTEXES == 1 ) + UBaseType_t uxDummy12[ 2 ]; + #endif + #if ( configUSE_APPLICATION_TASK_TAG == 1 ) + void * pxDummy14; + #endif + #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) + void * pvDummy15[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ]; + #if ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS ) + void *pvDummyLocalStorageCallBack[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ]; + #endif + #endif + #if ( configGENERATE_RUN_TIME_STATS == 1 ) + uint32_t ulDummy16; + #endif + #if ( configUSE_NEWLIB_REENTRANT == 1 ) + struct _reent xDummy17; + #endif + #if ( configUSE_TASK_NOTIFICATIONS == 1 ) + uint32_t ulDummy18[ configTASK_NOTIFICATION_ARRAY_ENTRIES ]; + uint8_t ucDummy19[ configTASK_NOTIFICATION_ARRAY_ENTRIES ]; + #endif + #if ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) + uint8_t uxDummy20; + #endif + + #if ( INCLUDE_xTaskAbortDelay == 1 ) + uint8_t ucDummy21; + #endif + #if ( configUSE_POSIX_ERRNO == 1 ) + int iDummy22; + #endif } StaticTask_t; /* @@ -1194,7 +1262,7 @@ typedef struct xSTATIC_TCB * strict data hiding policy. This means the Queue 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 queue - * then the size of the queue object needs to be know. The StaticQueue_t + * then the size of the queue object needs to be known. The StaticQueue_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 @@ -1204,33 +1272,31 @@ typedef struct xSTATIC_TCB */ typedef struct xSTATIC_QUEUE { - void *pvDummy1[ 3 ]; - - union - { - void *pvDummy2; - UBaseType_t uxDummy2; - } u; - - StaticList_t xDummy3[ 2 ]; - UBaseType_t uxDummy4[ 3 ]; - uint8_t ucDummy5[ 2 ]; - - #if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) - uint8_t ucDummy6; - #endif - - #if ( configUSE_QUEUE_SETS == 1 ) - void *pvDummy7; - #endif - - #if ( configUSE_TRACE_FACILITY == 1 ) - UBaseType_t uxDummy8; - uint8_t ucDummy9; - #endif - - portMUX_TYPE xDummy10; - + void * pvDummy1[ 3 ]; + + union + { + void * pvDummy2; + UBaseType_t uxDummy2; + } u; + + StaticList_t xDummy3[ 2 ]; + UBaseType_t uxDummy4[ 3 ]; + uint8_t ucDummy5[ 2 ]; + + #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) + uint8_t ucDummy6; + #endif + + #if ( configUSE_QUEUE_SETS == 1 ) + void * pvDummy7; + #endif + + #if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxDummy8; + uint8_t ucDummy9; + #endif + portMUX_TYPE xDummy10; } StaticQueue_t; typedef StaticQueue_t StaticSemaphore_t; @@ -1250,19 +1316,17 @@ typedef StaticQueue_t StaticSemaphore_t; */ typedef struct xSTATIC_EVENT_GROUP { - TickType_t xDummy1; - StaticList_t xDummy2; + 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 xDummy5; + #if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxDummy3; + #endif + #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) + uint8_t ucDummy4; + #endif + portMUX_TYPE xDummy5; } StaticEventGroup_t; /* @@ -1271,7 +1335,7 @@ typedef struct xSTATIC_EVENT_GROUP * 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. + * create a software timer then the size of the queue object needs to be known. * 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 @@ -1281,49 +1345,49 @@ typedef struct xSTATIC_EVENT_GROUP */ typedef struct xSTATIC_TIMER { - void *pvDummy1; - StaticListItem_t xDummy2; - TickType_t xDummy3; - void *pvDummy5; - TaskFunction_t pvDummy6; - #if( configUSE_TRACE_FACILITY == 1 ) - UBaseType_t uxDummy7; - #endif - uint8_t ucDummy8; + void * pvDummy1; + StaticListItem_t xDummy2; + TickType_t xDummy3; + void * pvDummy5; + TaskFunction_t pvDummy6; + #if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxDummy7; + #endif + uint8_t ucDummy8; } StaticTimer_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 stream buffer 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 stream buffer then the size of the stream buffer object needs to be -* know. The StaticStreamBuffer_t structure below is provided for this purpose. -* Its size 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. -*/ + * 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 stream buffer 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 stream buffer then the size of the stream buffer object needs to be + * known. The StaticStreamBuffer_t structure below is provided for this + * purpose. Its size 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_STREAM_BUFFER { - size_t uxDummy1[ 4 ]; - void * pvDummy2[ 3 ]; - uint8_t ucDummy3; - #if ( configUSE_TRACE_FACILITY == 1 ) - UBaseType_t uxDummy4; - #endif - - portMUX_TYPE xDummy5; - + size_t uxDummy1[ 4 ]; + void * pvDummy2[ 3 ]; + uint8_t ucDummy3; + #if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxDummy4; + #endif + portMUX_TYPE xDummy5; } StaticStreamBuffer_t; /* Message buffers are built on stream buffers. */ typedef StaticStreamBuffer_t StaticMessageBuffer_t; +/* *INDENT-OFF* */ #ifdef __cplusplus -} + } #endif +/* *INDENT-ON* */ #endif /* INC_FREERTOS_H */ diff --git a/tools/sdk/esp32/include/freertos/include/freertos/StackMacros.h b/tools/sdk/esp32/include/freertos/include/freertos/StackMacros.h new file mode 100644 index 00000000000..8d09f10cd1d --- /dev/null +++ b/tools/sdk/esp32/include/freertos/include/freertos/StackMacros.h @@ -0,0 +1,32 @@ +/* + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * 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. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + + +#ifndef _MSC_VER /* Visual Studio doesn't support #warning. */ + #warning The name of this file has changed to stack_macros.h. Please update your code accordingly. This source file (which has the original name) will be removed in future released. +#endif + +#include "stack_macros.h" diff --git a/tools/sdk/esp32/include/freertos/include/freertos/atomic.h b/tools/sdk/esp32/include/freertos/include/freertos/atomic.h index df52a0f01fd..a47b96723cc 100644 --- a/tools/sdk/esp32/include/freertos/include/freertos/atomic.h +++ b/tools/sdk/esp32/include/freertos/include/freertos/atomic.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,19 +19,18 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ /** * @file atomic.h * @brief FreeRTOS atomic operation support. * - * This file implements atomic by disabling interrupts globally. - * Implementation with architecture specific atomic instructions - * are to be provided under each compiler directory. + * This file implements atomic functions by disabling interrupts globally. + * Implementations with architecture specific atomic instructions can be + * provided under each compiler directory. */ #ifndef ATOMIC_H @@ -44,45 +43,50 @@ /* Standard includes. */ #include +/* *INDENT-OFF* */ #ifdef __cplusplus -extern "C" { + extern "C" { #endif +/* *INDENT-ON* */ -/* Port specific definitions -- entering/exiting critical section. +/* + * Port specific definitions -- entering/exiting critical section. * Refer template -- ./lib/FreeRTOS/portable/Compiler/Arch/portmacro.h * * Every call to ATOMIC_EXIT_CRITICAL() must be closely paired with * ATOMIC_ENTER_CRITICAL(). - * */ + * + */ #if defined( portSET_INTERRUPT_MASK_FROM_ISR ) - /* Nested interrupt scheme is supported in this port. */ - #define ATOMIC_ENTER_CRITICAL() \ - UBaseType_t uxCriticalSectionType = portSET_INTERRUPT_MASK_FROM_ISR() +/* Nested interrupt scheme is supported in this port. */ + #define ATOMIC_ENTER_CRITICAL() \ + UBaseType_t uxCriticalSectionType = portSET_INTERRUPT_MASK_FROM_ISR() - #define ATOMIC_EXIT_CRITICAL() \ - portCLEAR_INTERRUPT_MASK_FROM_ISR( uxCriticalSectionType ) + #define ATOMIC_EXIT_CRITICAL() \ + portCLEAR_INTERRUPT_MASK_FROM_ISR( uxCriticalSectionType ) #else - /* Nested interrupt scheme is NOT supported in this port. */ - #define ATOMIC_ENTER_CRITICAL() portENTER_CRITICAL() - #define ATOMIC_EXIT_CRITICAL() portEXIT_CRITICAL() +/* Nested interrupt scheme is NOT supported in this port. */ + #define ATOMIC_ENTER_CRITICAL() portENTER_CRITICAL() + #define ATOMIC_EXIT_CRITICAL() portEXIT_CRITICAL() #endif /* portSET_INTERRUPT_MASK_FROM_ISR() */ -/* Port specific definition -- "always inline". - * Inline is compiler specific, and may not always get inlined depending on your optimization level. - * Also, inline is considerred as performance optimization for atomic. - * Thus, if portFORCE_INLINE is not provided by portmacro.h, instead of resulting error, - * simply define it. +/* + * Port specific definition -- "always inline". + * Inline is compiler specific, and may not always get inlined depending on your + * optimization level. Also, inline is considered as performance optimization + * for atomic. Thus, if portFORCE_INLINE is not provided by portmacro.h, + * instead of resulting error, simply define it away. */ #ifndef portFORCE_INLINE #define portFORCE_INLINE #endif -#define ATOMIC_COMPARE_AND_SWAP_SUCCESS 0x1U /**< Compare and swap succeeded, swapped. */ -#define ATOMIC_COMPARE_AND_SWAP_FAILURE 0x0U /**< Compare and swap failed, did not swap. */ +#define ATOMIC_COMPARE_AND_SWAP_SUCCESS 0x1U /**< Compare and swap succeeded, swapped. */ +#define ATOMIC_COMPARE_AND_SWAP_FAILURE 0x0U /**< Compare and swap failed, did not swap. */ /*----------------------------- Swap && CAS ------------------------------*/ @@ -91,66 +95,67 @@ extern "C" { * * @brief Performs an atomic compare-and-swap operation on the specified values. * - * @param[in, out] pDestination Pointer to memory location from where value is + * @param[in, out] pulDestination Pointer to memory location from where value is * to be loaded and checked. * @param[in] ulExchange If condition meets, write this value to memory. * @param[in] ulComparand Swap condition. * * @return Unsigned integer of value 1 or 0. 1 for swapped, 0 for not swapped. * - * @note This function only swaps *pDestination with ulExchange, if previous - * *pDestination value equals ulComparand. + * @note This function only swaps *pulDestination with ulExchange, if previous + * *pulDestination value equals ulComparand. */ -static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32( - uint32_t volatile * pDestination, - uint32_t ulExchange, - uint32_t ulComparand ) +static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32( uint32_t volatile * pulDestination, + uint32_t ulExchange, + uint32_t ulComparand ) { - - uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE; + uint32_t ulReturnValue; ATOMIC_ENTER_CRITICAL(); - - if ( *pDestination == ulComparand ) { - *pDestination = ulExchange; - ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS; + if( *pulDestination == ulComparand ) + { + *pulDestination = ulExchange; + ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS; + } + else + { + ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE; + } } - ATOMIC_EXIT_CRITICAL(); return ulReturnValue; - } +/*-----------------------------------------------------------*/ /** * Atomic swap (pointers) * - * @brief Atomically sets the address pointed to by *ppDestination to the value - * of *pExchange. + * @brief Atomically sets the address pointed to by *ppvDestination to the value + * of *pvExchange. * - * @param[in, out] ppDestination Pointer to memory location from where a pointer - * value is to be loaded and written back to. - * @param[in] pExchange Pointer value to be written to *ppDestination. + * @param[in, out] ppvDestination Pointer to memory location from where a pointer + * value is to be loaded and written back to. + * @param[in] pvExchange Pointer value to be written to *ppvDestination. * - * @return The initial value of *ppDestination. + * @return The initial value of *ppvDestination. */ -static portFORCE_INLINE void * Atomic_SwapPointers_p32( - void * volatile * ppDestination, - void * pExchange ) +static portFORCE_INLINE void * Atomic_SwapPointers_p32( void * volatile * ppvDestination, + void * pvExchange ) { void * pReturnValue; ATOMIC_ENTER_CRITICAL(); - - pReturnValue = *ppDestination; - - *ppDestination = pExchange; - + { + pReturnValue = *ppvDestination; + *ppvDestination = pvExchange; + } ATOMIC_EXIT_CRITICAL(); return pReturnValue; } +/*-----------------------------------------------------------*/ /** * Atomic compare-and-swap (pointers) @@ -158,30 +163,30 @@ static portFORCE_INLINE void * Atomic_SwapPointers_p32( * @brief Performs an atomic compare-and-swap operation on the specified pointer * values. * - * @param[in, out] ppDestination Pointer to memory location from where a pointer - * value is to be loaded and checked. - * @param[in] pExchange If condition meets, write this value to memory. - * @param[in] pComparand Swap condition. + * @param[in, out] ppvDestination Pointer to memory location from where a pointer + * value is to be loaded and checked. + * @param[in] pvExchange If condition meets, write this value to memory. + * @param[in] pvComparand Swap condition. * * @return Unsigned integer of value 1 or 0. 1 for swapped, 0 for not swapped. * - * @note This function only swaps *ppDestination with pExchange, if previous - * *ppDestination value equals pComparand. + * @note This function only swaps *ppvDestination with pvExchange, if previous + * *ppvDestination value equals pvComparand. */ -static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32( - void * volatile * ppDestination, - void * pExchange, void * pComparand ) +static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32( void * volatile * ppvDestination, + void * pvExchange, + void * pvComparand ) { uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE; ATOMIC_ENTER_CRITICAL(); - - if ( *ppDestination == pComparand ) { - *ppDestination = pExchange; - ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS; + if( *ppvDestination == pvComparand ) + { + *ppvDestination = pvExchange; + ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS; + } } - ATOMIC_EXIT_CRITICAL(); return ulReturnValue; @@ -195,28 +200,27 @@ static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32( * * @brief Atomically adds count to the value of the specified pointer points to. * - * @param[in,out] pAddend Pointer to memory location from where value is to be + * @param[in,out] pulAddend Pointer to memory location from where value is to be * loaded and written back to. - * @param[in] ulCount Value to be added to *pAddend. + * @param[in] ulCount Value to be added to *pulAddend. * - * @return previous *pAddend value. + * @return previous *pulAddend value. */ -static portFORCE_INLINE uint32_t Atomic_Add_u32( - uint32_t volatile * pAddend, - uint32_t ulCount ) +static portFORCE_INLINE uint32_t Atomic_Add_u32( uint32_t volatile * pulAddend, + uint32_t ulCount ) { uint32_t ulCurrent; ATOMIC_ENTER_CRITICAL(); - - ulCurrent = *pAddend; - - *pAddend += ulCount; - + { + ulCurrent = *pulAddend; + *pulAddend += ulCount; + } ATOMIC_EXIT_CRITICAL(); return ulCurrent; } +/*-----------------------------------------------------------*/ /** * Atomic subtract @@ -224,74 +228,72 @@ static portFORCE_INLINE uint32_t Atomic_Add_u32( * @brief Atomically subtracts count from the value of the specified pointer * pointers to. * - * @param[in,out] pAddend Pointer to memory location from where value is to be + * @param[in,out] pulAddend Pointer to memory location from where value is to be * loaded and written back to. - * @param[in] ulCount Value to be subtract from *pAddend. + * @param[in] ulCount Value to be subtract from *pulAddend. * - * @return previous *pAddend value. + * @return previous *pulAddend value. */ -static portFORCE_INLINE uint32_t Atomic_Subtract_u32( - uint32_t volatile * pAddend, - uint32_t ulCount ) +static portFORCE_INLINE uint32_t Atomic_Subtract_u32( uint32_t volatile * pulAddend, + uint32_t ulCount ) { uint32_t ulCurrent; ATOMIC_ENTER_CRITICAL(); - - ulCurrent = *pAddend; - - *pAddend -= ulCount; - + { + ulCurrent = *pulAddend; + *pulAddend -= ulCount; + } ATOMIC_EXIT_CRITICAL(); return ulCurrent; } +/*-----------------------------------------------------------*/ /** * Atomic increment * * @brief Atomically increments the value of the specified pointer points to. * - * @param[in,out] pAddend Pointer to memory location from where value is to be + * @param[in,out] pulAddend Pointer to memory location from where value is to be * loaded and written back to. * - * @return *pAddend value before increment. + * @return *pulAddend value before increment. */ -static portFORCE_INLINE uint32_t Atomic_Increment_u32( uint32_t volatile * pAddend ) +static portFORCE_INLINE uint32_t Atomic_Increment_u32( uint32_t volatile * pulAddend ) { uint32_t ulCurrent; ATOMIC_ENTER_CRITICAL(); - - ulCurrent = *pAddend; - - *pAddend += 1; - + { + ulCurrent = *pulAddend; + *pulAddend += 1; + } ATOMIC_EXIT_CRITICAL(); return ulCurrent; } +/*-----------------------------------------------------------*/ /** * Atomic decrement * * @brief Atomically decrements the value of the specified pointer points to * - * @param[in,out] pAddend Pointer to memory location from where value is to be + * @param[in,out] pulAddend Pointer to memory location from where value is to be * loaded and written back to. * - * @return *pAddend value before decrement. + * @return *pulAddend value before decrement. */ -static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pAddend ) +static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pulAddend ) { uint32_t ulCurrent; ATOMIC_ENTER_CRITICAL(); - - ulCurrent = *pAddend; - - *pAddend -= 1; - + { + ulCurrent = *pulAddend; + *pulAddend -= 1; + } ATOMIC_EXIT_CRITICAL(); return ulCurrent; @@ -304,115 +306,112 @@ static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pAdde * * @brief Performs an atomic OR operation on the specified values. * - * @param [in, out] pDestination Pointer to memory location from where value is + * @param [in, out] pulDestination Pointer to memory location from where value is * to be loaded and written back to. - * @param [in] ulValue Value to be ORed with *pDestination. + * @param [in] ulValue Value to be ORed with *pulDestination. * - * @return The original value of *pDestination. + * @return The original value of *pulDestination. */ -static portFORCE_INLINE uint32_t Atomic_OR_u32( - uint32_t volatile * pDestination, - uint32_t ulValue ) +static portFORCE_INLINE uint32_t Atomic_OR_u32( uint32_t volatile * pulDestination, + uint32_t ulValue ) { uint32_t ulCurrent; ATOMIC_ENTER_CRITICAL(); - - ulCurrent = *pDestination; - - *pDestination |= ulValue; - + { + ulCurrent = *pulDestination; + *pulDestination |= ulValue; + } ATOMIC_EXIT_CRITICAL(); return ulCurrent; } +/*-----------------------------------------------------------*/ /** * Atomic AND * * @brief Performs an atomic AND operation on the specified values. * - * @param [in, out] pDestination Pointer to memory location from where value is + * @param [in, out] pulDestination Pointer to memory location from where value is * to be loaded and written back to. - * @param [in] ulValue Value to be ANDed with *pDestination. + * @param [in] ulValue Value to be ANDed with *pulDestination. * - * @return The original value of *pDestination. + * @return The original value of *pulDestination. */ -static portFORCE_INLINE uint32_t Atomic_AND_u32( - uint32_t volatile * pDestination, - uint32_t ulValue ) +static portFORCE_INLINE uint32_t Atomic_AND_u32( uint32_t volatile * pulDestination, + uint32_t ulValue ) { uint32_t ulCurrent; ATOMIC_ENTER_CRITICAL(); - - ulCurrent = *pDestination; - - *pDestination &= ulValue; - + { + ulCurrent = *pulDestination; + *pulDestination &= ulValue; + } ATOMIC_EXIT_CRITICAL(); return ulCurrent; } +/*-----------------------------------------------------------*/ /** * Atomic NAND * * @brief Performs an atomic NAND operation on the specified values. * - * @param [in, out] pDestination Pointer to memory location from where value is + * @param [in, out] pulDestination Pointer to memory location from where value is * to be loaded and written back to. - * @param [in] ulValue Value to be NANDed with *pDestination. + * @param [in] ulValue Value to be NANDed with *pulDestination. * - * @return The original value of *pDestination. + * @return The original value of *pulDestination. */ -static portFORCE_INLINE uint32_t Atomic_NAND_u32( - uint32_t volatile * pDestination, - uint32_t ulValue ) +static portFORCE_INLINE uint32_t Atomic_NAND_u32( uint32_t volatile * pulDestination, + uint32_t ulValue ) { uint32_t ulCurrent; ATOMIC_ENTER_CRITICAL(); - - ulCurrent = *pDestination; - - *pDestination = ~(ulCurrent & ulValue); - + { + ulCurrent = *pulDestination; + *pulDestination = ~( ulCurrent & ulValue ); + } ATOMIC_EXIT_CRITICAL(); return ulCurrent; } +/*-----------------------------------------------------------*/ /** * Atomic XOR * * @brief Performs an atomic XOR operation on the specified values. * - * @param [in, out] pDestination Pointer to memory location from where value is + * @param [in, out] pulDestination Pointer to memory location from where value is * to be loaded and written back to. - * @param [in] ulValue Value to be XORed with *pDestination. + * @param [in] ulValue Value to be XORed with *pulDestination. * - * @return The original value of *pDestination. + * @return The original value of *pulDestination. */ -static portFORCE_INLINE uint32_t Atomic_XOR_u32( - uint32_t volatile * pDestination, - uint32_t ulValue ) +static portFORCE_INLINE uint32_t Atomic_XOR_u32( uint32_t volatile * pulDestination, + uint32_t ulValue ) { uint32_t ulCurrent; ATOMIC_ENTER_CRITICAL(); - - ulCurrent = *pDestination; - - *pDestination ^= ulValue; - + { + ulCurrent = *pulDestination; + *pulDestination ^= ulValue; + } ATOMIC_EXIT_CRITICAL(); return ulCurrent; } +/* *INDENT-OFF* */ #ifdef __cplusplus -} + } #endif +/* *INDENT-ON* */ #endif /* ATOMIC_H */ diff --git a/tools/sdk/esp32/include/freertos/include/freertos/croutine.h b/tools/sdk/esp32/include/freertos/include/freertos/croutine.h index 8b3b41b9051..99322d219f2 100644 --- a/tools/sdk/esp32/include/freertos/include/freertos/croutine.h +++ b/tools/sdk/esp32/include/freertos/include/freertos/croutine.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,51 +19,56 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ #ifndef CO_ROUTINE_H #define CO_ROUTINE_H #ifndef INC_FREERTOS_H - #error "include FreeRTOS.h must appear in source files before include croutine.h" + #error "include FreeRTOS.h must appear in source files before include croutine.h" #endif #include "list.h" +/* *INDENT-OFF* */ #ifdef __cplusplus -extern "C" { + extern "C" { #endif +/* *INDENT-ON* */ /* Used to hide the implementation of the co-routine control block. The -control block structure however has to be included in the header due to -the macro implementation of the co-routine functionality. */ + * control block structure however has to be included in the header due to + * the macro implementation of the co-routine functionality. */ typedef void * CoRoutineHandle_t; /* Defines the prototype to which co-routine functions must conform. */ -typedef void (*crCOROUTINE_CODE)( CoRoutineHandle_t, UBaseType_t ); +typedef void (* crCOROUTINE_CODE)( CoRoutineHandle_t, + UBaseType_t ); typedef struct corCoRoutineControlBlock { - crCOROUTINE_CODE pxCoRoutineFunction; - ListItem_t xGenericListItem; /*< List item used to place the CRCB in ready and blocked queues. */ - ListItem_t xEventListItem; /*< List item used to place the CRCB in event lists. */ - UBaseType_t uxPriority; /*< The priority of the co-routine in relation to other co-routines. */ - UBaseType_t uxIndex; /*< Used to distinguish between co-routines when multiple co-routines use the same co-routine function. */ - uint16_t uxState; /*< Used internally by the co-routine implementation. */ -} CRCB_t; /* Co-routine control block. Note must be identical in size down to uxPriority with TCB_t. */ + crCOROUTINE_CODE pxCoRoutineFunction; + ListItem_t xGenericListItem; /*< List item used to place the CRCB in ready and blocked queues. */ + ListItem_t xEventListItem; /*< List item used to place the CRCB in event lists. */ + UBaseType_t uxPriority; /*< The priority of the co-routine in relation to other co-routines. */ + UBaseType_t uxIndex; /*< Used to distinguish between co-routines when multiple co-routines use the same co-routine function. */ + uint16_t uxState; /*< Used internally by the co-routine implementation. */ +} CRCB_t; /* Co-routine control block. Note must be identical in size down to uxPriority with TCB_t. */ /** + * @cond * croutine. h - *
- BaseType_t xCoRoutineCreate(
-                                 crCOROUTINE_CODE pxCoRoutineCode,
-                                 UBaseType_t uxPriority,
-                                 UBaseType_t uxIndex
-                               );
+ * @code{c} + * BaseType_t xCoRoutineCreate( + * crCOROUTINE_CODE pxCoRoutineCode, + * UBaseType_t uxPriority, + * UBaseType_t uxIndex + * ); + * @endcode + * @endcond * * Create a new co-routine and add it to the list of co-routines that are * ready to run. @@ -83,59 +88,65 @@ typedef struct corCoRoutineControlBlock * list, otherwise an error code defined with ProjDefs.h. * * Example usage: -
- // Co-routine to be created.
- void vFlashCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- // This may not be necessary for const variables.
- static const char cLedToFlash[ 2 ] = { 5, 6 };
- static const TickType_t uxFlashRates[ 2 ] = { 200, 400 };
-
-     // Must start every co-routine with a call to crSTART();
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-         // This co-routine just delays for a fixed period, then toggles
-         // an LED.  Two co-routines are created using this function, so
-         // the uxIndex parameter is used to tell the co-routine which
-         // LED to flash and how int32_t to delay.  This assumes xQueue has
-         // already been created.
-         vParTestToggleLED( cLedToFlash[ uxIndex ] );
-         crDELAY( xHandle, uxFlashRates[ uxIndex ] );
-     }
-
-     // Must end every co-routine with a call to crEND();
-     crEND();
- }
-
- // Function that creates two co-routines.
- void vOtherFunction( void )
- {
- uint8_t ucParameterToPass;
- TaskHandle_t xHandle;
-
-     // Create two co-routines at priority 0.  The first is given index 0
-     // so (from the code above) toggles LED 5 every 200 ticks.  The second
-     // is given index 1 so toggles LED 6 every 400 ticks.
-     for( uxIndex = 0; uxIndex < 2; uxIndex++ )
-     {
-         xCoRoutineCreate( vFlashCoRoutine, 0, uxIndex );
-     }
- }
-   
+ * @code{c} + * // Co-routine to be created. + * void vFlashCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) + * { + * // Variables in co-routines must be declared static if they must maintain value across a blocking call. + * // This may not be necessary for const variables. + * static const char cLedToFlash[ 2 ] = { 5, 6 }; + * static const TickType_t uxFlashRates[ 2 ] = { 200, 400 }; + * + * // Must start every co-routine with a call to crSTART(); + * crSTART( xHandle ); + * + * for( ;; ) + * { + * // This co-routine just delays for a fixed period, then toggles + * // an LED. Two co-routines are created using this function, so + * // the uxIndex parameter is used to tell the co-routine which + * // LED to flash and how int32_t to delay. This assumes xQueue has + * // already been created. + * vParTestToggleLED( cLedToFlash[ uxIndex ] ); + * crDELAY( xHandle, uxFlashRates[ uxIndex ] ); + * } + * + * // Must end every co-routine with a call to crEND(); + * crEND(); + * } + * + * // Function that creates two co-routines. + * void vOtherFunction( void ) + * { + * uint8_t ucParameterToPass; + * TaskHandle_t xHandle; + * + * // Create two co-routines at priority 0. The first is given index 0 + * // so (from the code above) toggles LED 5 every 200 ticks. The second + * // is given index 1 so toggles LED 6 every 400 ticks. + * for( uxIndex = 0; uxIndex < 2; uxIndex++ ) + * { + * xCoRoutineCreate( vFlashCoRoutine, 0, uxIndex ); + * } + * } + * @endcode + * @cond * \defgroup xCoRoutineCreate xCoRoutineCreate + * @endcond * \ingroup Tasks */ -BaseType_t xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, UBaseType_t uxPriority, UBaseType_t uxIndex ); +BaseType_t xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, + UBaseType_t uxPriority, + UBaseType_t uxIndex ); /** + * @cond * croutine. h - *
- void vCoRoutineSchedule( void );
- * + * @code{c} + * void vCoRoutineSchedule( void ); + * @endcode + * @endcond * Run a co-routine. * * vCoRoutineSchedule() executes the highest priority co-routine that is able @@ -148,103 +159,127 @@ BaseType_t xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, UBaseType_t uxPri * hook). * * Example usage: -
- // This idle task hook will schedule a co-routine each time it is called.
- // The rest of the idle task will execute between co-routine calls.
- void vApplicationIdleHook( void )
- {
-	vCoRoutineSchedule();
- }
-
- // Alternatively, if you do not require any other part of the idle task to
- // execute, the idle task hook can call vCoRoutineScheduler() within an
- // infinite loop.
- void vApplicationIdleHook( void )
- {
-    for( ;; )
-    {
-        vCoRoutineSchedule();
-    }
- }
- 
+ * @code{c} + * // This idle task hook will schedule a co-routine each time it is called. + * // The rest of the idle task will execute between co-routine calls. + * void vApplicationIdleHook( void ) + * { + * vCoRoutineSchedule(); + * } + * + * // Alternatively, if you do not require any other part of the idle task to + * // execute, the idle task hook can call vCoRoutineScheduler() within an + * // infinite loop. + * void vApplicationIdleHook( void ) + * { + * for( ;; ) + * { + * vCoRoutineSchedule(); + * } + * } + * @endcode + * @endcode + * @cond * \defgroup vCoRoutineSchedule vCoRoutineSchedule + * @endcond * \ingroup Tasks */ void vCoRoutineSchedule( void ); /** + * @cond * croutine. h - *
- crSTART( CoRoutineHandle_t xHandle );
+ * @code{c} + * crSTART( CoRoutineHandle_t xHandle ); + * @endcode + * @endcond * * This macro MUST always be called at the start of a co-routine function. * * Example usage: -
- // Co-routine to be created.
- void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- static int32_t ulAVariable;
-
-     // Must start every co-routine with a call to crSTART();
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-          // Co-routine functionality goes here.
-     }
-
-     // Must end every co-routine with a call to crEND();
-     crEND();
- }
+ * @code{c} + * // Co-routine to be created. + * void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) + * { + * // Variables in co-routines must be declared static if they must maintain value across a blocking call. + * static int32_t ulAVariable; + * + * // Must start every co-routine with a call to crSTART(); + * crSTART( xHandle ); + * + * for( ;; ) + * { + * // Co-routine functionality goes here. + * } + * + * // Must end every co-routine with a call to crEND(); + * crEND(); + * } + * @endcode + * @cond * \defgroup crSTART crSTART + * @endcond * \ingroup Tasks */ -#define crSTART( pxCRCB ) switch( ( ( CRCB_t * )( pxCRCB ) )->uxState ) { case 0: +#define crSTART( pxCRCB ) \ + switch( ( ( CRCB_t * ) ( pxCRCB ) )->uxState ) { \ + case 0: /** + * @cond * croutine. h - *
- crEND();
+ * @code{c} + * crEND(); + * @endcode + * @endcond * * This macro MUST always be called at the end of a co-routine function. * * Example usage: -
- // Co-routine to be created.
- void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- static int32_t ulAVariable;
-
-     // Must start every co-routine with a call to crSTART();
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-          // Co-routine functionality goes here.
-     }
-
-     // Must end every co-routine with a call to crEND();
-     crEND();
- }
+ * @code{c} + * // Co-routine to be created. + * void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) + * { + * // Variables in co-routines must be declared static if they must maintain value across a blocking call. + * static int32_t ulAVariable; + * + * // Must start every co-routine with a call to crSTART(); + * crSTART( xHandle ); + * + * for( ;; ) + * { + * // Co-routine functionality goes here. + * } + * + * // Must end every co-routine with a call to crEND(); + * crEND(); + * } + * @endcode + * @cond * \defgroup crSTART crSTART + * @endcond * \ingroup Tasks */ -#define crEND() } +#define crEND() } /* * These macros are intended for internal use by the co-routine implementation * only. The macros should not be used directly by application writers. */ -#define crSET_STATE0( xHandle ) ( ( CRCB_t * )( xHandle ) )->uxState = (__LINE__ * 2); return; case (__LINE__ * 2): -#define crSET_STATE1( xHandle ) ( ( CRCB_t * )( xHandle ) )->uxState = ((__LINE__ * 2)+1); return; case ((__LINE__ * 2)+1): +#define crSET_STATE0( xHandle ) \ + ( ( CRCB_t * ) ( xHandle ) )->uxState = ( __LINE__ * 2 ); return; \ + case ( __LINE__ * 2 ): +#define crSET_STATE1( xHandle ) \ + ( ( CRCB_t * ) ( xHandle ) )->uxState = ( ( __LINE__ * 2 ) + 1 ); return; \ + case ( ( __LINE__ * 2 ) + 1 ): /** + * @cond * croutine. h - *
- crDELAY( CoRoutineHandle_t xHandle, TickType_t xTicksToDelay );
+ * @code{c} + * crDELAY( CoRoutineHandle_t xHandle, TickType_t xTicksToDelay ); + * @endcode + * @endcond * * Delay a co-routine for a fixed period of time. * @@ -261,48 +296,54 @@ void vCoRoutineSchedule( void ); * can be used to convert ticks to milliseconds. * * Example usage: -
- // Co-routine to be created.
- void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- // This may not be necessary for const variables.
- // We are to delay for 200ms.
- static const xTickType xDelayTime = 200 / portTICK_PERIOD_MS;
-
-     // Must start every co-routine with a call to crSTART();
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-        // Delay for 200ms.
-        crDELAY( xHandle, xDelayTime );
-
-        // Do something here.
-     }
-
-     // Must end every co-routine with a call to crEND();
-     crEND();
- }
+ * @code{c} + * // Co-routine to be created. + * void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) + * { + * // Variables in co-routines must be declared static if they must maintain value across a blocking call. + * // This may not be necessary for const variables. + * // We are to delay for 200ms. + * static const xTickType xDelayTime = 200 / portTICK_PERIOD_MS; + * + * // Must start every co-routine with a call to crSTART(); + * crSTART( xHandle ); + * + * for( ;; ) + * { + * // Delay for 200ms. + * crDELAY( xHandle, xDelayTime ); + * + * // Do something here. + * } + * + * // Must end every co-routine with a call to crEND(); + * crEND(); + * } + * @endcode + * @cond * \defgroup crDELAY crDELAY + * @endcond * \ingroup Tasks */ -#define crDELAY( xHandle, xTicksToDelay ) \ - if( ( xTicksToDelay ) > 0 ) \ - { \ - vCoRoutineAddToDelayedList( ( xTicksToDelay ), NULL ); \ - } \ - crSET_STATE0( ( xHandle ) ); +#define crDELAY( xHandle, xTicksToDelay ) \ + if( ( xTicksToDelay ) > 0 ) \ + { \ + vCoRoutineAddToDelayedList( ( xTicksToDelay ), NULL ); \ + } \ + crSET_STATE0( ( xHandle ) ); /** - *
- crQUEUE_SEND(
-                  CoRoutineHandle_t xHandle,
-                  QueueHandle_t pxQueue,
-                  void *pvItemToQueue,
-                  TickType_t xTicksToWait,
-                  BaseType_t *pxResult
-             )
+ * @cond + * @code{c} + * crQUEUE_SEND( + * CoRoutineHandle_t xHandle, + * QueueHandle_t pxQueue, + * void *pvItemToQueue, + * TickType_t xTicksToWait, + * BaseType_t *pxResult + * ) + * @endcode + * @endcond * * The macro's crQUEUE_SEND() and crQUEUE_RECEIVE() are the co-routine * equivalent to the xQueueSend() and xQueueReceive() functions used by tasks. @@ -342,66 +383,72 @@ void vCoRoutineSchedule( void ); * error defined within ProjDefs.h. * * Example usage: -
- // Co-routine function that blocks for a fixed period then posts a number onto
- // a queue.
- static void prvCoRoutineFlashTask( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- static BaseType_t xNumberToPost = 0;
- static BaseType_t xResult;
-
-    // Co-routines must begin with a call to crSTART().
-    crSTART( xHandle );
-
-    for( ;; )
-    {
-        // This assumes the queue has already been created.
-        crQUEUE_SEND( xHandle, xCoRoutineQueue, &xNumberToPost, NO_DELAY, &xResult );
-
-        if( xResult != pdPASS )
-        {
-            // The message was not posted!
-        }
-
-        // Increment the number to be posted onto the queue.
-        xNumberToPost++;
-
-        // Delay for 100 ticks.
-        crDELAY( xHandle, 100 );
-    }
-
-    // Co-routines must end with a call to crEND().
-    crEND();
- }
+ * @code{c} + * // Co-routine function that blocks for a fixed period then posts a number onto + * // a queue. + * static void prvCoRoutineFlashTask( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) + * { + * // Variables in co-routines must be declared static if they must maintain value across a blocking call. + * static BaseType_t xNumberToPost = 0; + * static BaseType_t xResult; + * + * // Co-routines must begin with a call to crSTART(). + * crSTART( xHandle ); + * + * for( ;; ) + * { + * // This assumes the queue has already been created. + * crQUEUE_SEND( xHandle, xCoRoutineQueue, &xNumberToPost, NO_DELAY, &xResult ); + * + * if( xResult != pdPASS ) + * { + * // The message was not posted! + * } + * + * // Increment the number to be posted onto the queue. + * xNumberToPost++; + * + * // Delay for 100 ticks. + * crDELAY( xHandle, 100 ); + * } + * + * // Co-routines must end with a call to crEND(). + * crEND(); + * } + * @endcode + * @cond * \defgroup crQUEUE_SEND crQUEUE_SEND + * @endcond * \ingroup Tasks */ -#define crQUEUE_SEND( xHandle, pxQueue, pvItemToQueue, xTicksToWait, pxResult ) \ -{ \ - *( pxResult ) = xQueueCRSend( ( pxQueue) , ( pvItemToQueue) , ( xTicksToWait ) ); \ - if( *( pxResult ) == errQUEUE_BLOCKED ) \ - { \ - crSET_STATE0( ( xHandle ) ); \ - *pxResult = xQueueCRSend( ( pxQueue ), ( pvItemToQueue ), 0 ); \ - } \ - if( *pxResult == errQUEUE_YIELD ) \ - { \ - crSET_STATE1( ( xHandle ) ); \ - *pxResult = pdPASS; \ - } \ -} +#define crQUEUE_SEND( xHandle, pxQueue, pvItemToQueue, xTicksToWait, pxResult ) \ + { \ + *( pxResult ) = xQueueCRSend( ( pxQueue ), ( pvItemToQueue ), ( xTicksToWait ) ); \ + if( *( pxResult ) == errQUEUE_BLOCKED ) \ + { \ + crSET_STATE0( ( xHandle ) ); \ + *pxResult = xQueueCRSend( ( pxQueue ), ( pvItemToQueue ), 0 ); \ + } \ + if( *pxResult == errQUEUE_YIELD ) \ + { \ + crSET_STATE1( ( xHandle ) ); \ + *pxResult = pdPASS; \ + } \ + } /** + * @cond * croutine. h - *
-  crQUEUE_RECEIVE(
-                     CoRoutineHandle_t xHandle,
-                     QueueHandle_t pxQueue,
-                     void *pvBuffer,
-                     TickType_t xTicksToWait,
-                     BaseType_t *pxResult
-                 )
+ * @code{c} + * crQUEUE_RECEIVE( + * CoRoutineHandle_t xHandle, + * QueueHandle_t pxQueue, + * void *pvBuffer, + * TickType_t xTicksToWait, + * BaseType_t *pxResult + * ) + * @endcode + * @endcond * * The macro's crQUEUE_SEND() and crQUEUE_RECEIVE() are the co-routine * equivalent to the xQueueSend() and xQueueReceive() functions used by tasks. @@ -440,58 +487,64 @@ void vCoRoutineSchedule( void ); * an error code as defined within ProjDefs.h. * * Example usage: -
- // A co-routine receives the number of an LED to flash from a queue.  It
- // blocks on the queue until the number is received.
- static void prvCoRoutineFlashWorkTask( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- static BaseType_t xResult;
- static UBaseType_t uxLEDToFlash;
-
-    // All co-routines must start with a call to crSTART().
-    crSTART( xHandle );
-
-    for( ;; )
-    {
-        // Wait for data to become available on the queue.
-        crQUEUE_RECEIVE( xHandle, xCoRoutineQueue, &uxLEDToFlash, portMAX_DELAY, &xResult );
-
-        if( xResult == pdPASS )
-        {
-            // We received the LED to flash - flash it!
-            vParTestToggleLED( uxLEDToFlash );
-        }
-    }
-
-    crEND();
- }
+ * @code{c} + * // A co-routine receives the number of an LED to flash from a queue. It + * // blocks on the queue until the number is received. + * static void prvCoRoutineFlashWorkTask( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) + * { + * // Variables in co-routines must be declared static if they must maintain value across a blocking call. + * static BaseType_t xResult; + * static UBaseType_t uxLEDToFlash; + * + * // All co-routines must start with a call to crSTART(). + * crSTART( xHandle ); + * + * for( ;; ) + * { + * // Wait for data to become available on the queue. + * crQUEUE_RECEIVE( xHandle, xCoRoutineQueue, &uxLEDToFlash, portMAX_DELAY, &xResult ); + * + * if( xResult == pdPASS ) + * { + * // We received the LED to flash - flash it! + * vParTestToggleLED( uxLEDToFlash ); + * } + * } + * + * crEND(); + * } + * @endcode + * @cond * \defgroup crQUEUE_RECEIVE crQUEUE_RECEIVE + * @endcond * \ingroup Tasks */ -#define crQUEUE_RECEIVE( xHandle, pxQueue, pvBuffer, xTicksToWait, pxResult ) \ -{ \ - *( pxResult ) = xQueueCRReceive( ( pxQueue) , ( pvBuffer ), ( xTicksToWait ) ); \ - if( *( pxResult ) == errQUEUE_BLOCKED ) \ - { \ - crSET_STATE0( ( xHandle ) ); \ - *( pxResult ) = xQueueCRReceive( ( pxQueue) , ( pvBuffer ), 0 ); \ - } \ - if( *( pxResult ) == errQUEUE_YIELD ) \ - { \ - crSET_STATE1( ( xHandle ) ); \ - *( pxResult ) = pdPASS; \ - } \ -} +#define crQUEUE_RECEIVE( xHandle, pxQueue, pvBuffer, xTicksToWait, pxResult ) \ + { \ + *( pxResult ) = xQueueCRReceive( ( pxQueue ), ( pvBuffer ), ( xTicksToWait ) ); \ + if( *( pxResult ) == errQUEUE_BLOCKED ) \ + { \ + crSET_STATE0( ( xHandle ) ); \ + *( pxResult ) = xQueueCRReceive( ( pxQueue ), ( pvBuffer ), 0 ); \ + } \ + if( *( pxResult ) == errQUEUE_YIELD ) \ + { \ + crSET_STATE1( ( xHandle ) ); \ + *( pxResult ) = pdPASS; \ + } \ + } /** + * @cond * croutine. h - *
-  crQUEUE_SEND_FROM_ISR(
-                            QueueHandle_t pxQueue,
-                            void *pvItemToQueue,
-                            BaseType_t xCoRoutinePreviouslyWoken
-                       )
+ * @code{c} + * crQUEUE_SEND_FROM_ISR( + * QueueHandle_t pxQueue, + * void *pvItemToQueue, + * BaseType_t xCoRoutinePreviouslyWoken + * ) + * @endcode + * @endcond * * The macro's crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() are the * co-routine equivalent to the xQueueSendFromISR() and xQueueReceiveFromISR() @@ -526,69 +579,76 @@ void vCoRoutineSchedule( void ); * the ISR. * * Example usage: -
- // A co-routine that blocks on a queue waiting for characters to be received.
- static void vReceivingCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- char cRxedChar;
- BaseType_t xResult;
-
-     // All co-routines must start with a call to crSTART().
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-         // Wait for data to become available on the queue.  This assumes the
-         // queue xCommsRxQueue has already been created!
-         crQUEUE_RECEIVE( xHandle, xCommsRxQueue, &uxLEDToFlash, portMAX_DELAY, &xResult );
-
-         // Was a character received?
-         if( xResult == pdPASS )
-         {
-             // Process the character here.
-         }
-     }
-
-     // All co-routines must end with a call to crEND().
-     crEND();
- }
-
- // An ISR that uses a queue to send characters received on a serial port to
- // a co-routine.
- void vUART_ISR( void )
- {
- char cRxedChar;
- BaseType_t xCRWokenByPost = pdFALSE;
-
-     // We loop around reading characters until there are none left in the UART.
-     while( UART_RX_REG_NOT_EMPTY() )
-     {
-         // Obtain the character from the UART.
-         cRxedChar = UART_RX_REG;
-
-         // Post the character onto a queue.  xCRWokenByPost will be pdFALSE
-         // the first time around the loop.  If the post causes a co-routine
-         // to be woken (unblocked) then xCRWokenByPost will be set to pdTRUE.
-         // In this manner we can ensure that if more than one co-routine is
-         // blocked on the queue only one is woken by this ISR no matter how
-         // many characters are posted to the queue.
-         xCRWokenByPost = crQUEUE_SEND_FROM_ISR( xCommsRxQueue, &cRxedChar, xCRWokenByPost );
-     }
- }
+ * @code{c} + * // A co-routine that blocks on a queue waiting for characters to be received. + * static void vReceivingCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) + * { + * char cRxedChar; + * BaseType_t xResult; + * + * // All co-routines must start with a call to crSTART(). + * crSTART( xHandle ); + * + * for( ;; ) + * { + * // Wait for data to become available on the queue. This assumes the + * // queue xCommsRxQueue has already been created! + * crQUEUE_RECEIVE( xHandle, xCommsRxQueue, &uxLEDToFlash, portMAX_DELAY, &xResult ); + * + * // Was a character received? + * if( xResult == pdPASS ) + * { + * // Process the character here. + * } + * } + * + * // All co-routines must end with a call to crEND(). + * crEND(); + * } + * + * // An ISR that uses a queue to send characters received on a serial port to + * // a co-routine. + * void vUART_ISR( void ) + * { + * char cRxedChar; + * BaseType_t xCRWokenByPost = pdFALSE; + * + * // We loop around reading characters until there are none left in the UART. + * while( UART_RX_REG_NOT_EMPTY() ) + * { + * // Obtain the character from the UART. + * cRxedChar = UART_RX_REG; + * + * // Post the character onto a queue. xCRWokenByPost will be pdFALSE + * // the first time around the loop. If the post causes a co-routine + * // to be woken (unblocked) then xCRWokenByPost will be set to pdTRUE. + * // In this manner we can ensure that if more than one co-routine is + * // blocked on the queue only one is woken by this ISR no matter how + * // many characters are posted to the queue. + * xCRWokenByPost = crQUEUE_SEND_FROM_ISR( xCommsRxQueue, &cRxedChar, xCRWokenByPost ); + * } + * } + * @endcode + * @cond * \defgroup crQUEUE_SEND_FROM_ISR crQUEUE_SEND_FROM_ISR + * @endcond * \ingroup Tasks */ -#define crQUEUE_SEND_FROM_ISR( pxQueue, pvItemToQueue, xCoRoutinePreviouslyWoken ) xQueueCRSendFromISR( ( pxQueue ), ( pvItemToQueue ), ( xCoRoutinePreviouslyWoken ) ) +#define crQUEUE_SEND_FROM_ISR( pxQueue, pvItemToQueue, xCoRoutinePreviouslyWoken ) \ + xQueueCRSendFromISR( ( pxQueue ), ( pvItemToQueue ), ( xCoRoutinePreviouslyWoken ) ) /** + * @cond * croutine. h - *
-  crQUEUE_SEND_FROM_ISR(
-                            QueueHandle_t pxQueue,
-                            void *pvBuffer,
-                            BaseType_t * pxCoRoutineWoken
-                       )
+ * @code{c} + * crQUEUE_SEND_FROM_ISR( + * QueueHandle_t pxQueue, + * void *pvBuffer, + * BaseType_t * pxCoRoutineWoken + * ) + * @endcode + * @endcond * * The macro's crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() are the * co-routine equivalent to the xQueueSendFromISR() and xQueueReceiveFromISR() @@ -623,75 +683,79 @@ void vCoRoutineSchedule( void ); * pdFALSE. * * Example usage: -
- // A co-routine that posts a character to a queue then blocks for a fixed
- // period.  The character is incremented each time.
- static void vSendingCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // cChar holds its value while this co-routine is blocked and must therefore
- // be declared static.
- static char cCharToTx = 'a';
- BaseType_t xResult;
-
-     // All co-routines must start with a call to crSTART().
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-         // Send the next character to the queue.
-         crQUEUE_SEND( xHandle, xCoRoutineQueue, &cCharToTx, NO_DELAY, &xResult );
-
-         if( xResult == pdPASS )
-         {
-             // The character was successfully posted to the queue.
-         }
-		 else
-		 {
-			// Could not post the character to the queue.
-		 }
-
-         // Enable the UART Tx interrupt to cause an interrupt in this
-		 // hypothetical UART.  The interrupt will obtain the character
-		 // from the queue and send it.
-		 ENABLE_RX_INTERRUPT();
-
-		 // Increment to the next character then block for a fixed period.
-		 // cCharToTx will maintain its value across the delay as it is
-		 // declared static.
-		 cCharToTx++;
-		 if( cCharToTx > 'x' )
-		 {
-			cCharToTx = 'a';
-		 }
-		 crDELAY( 100 );
-     }
-
-     // All co-routines must end with a call to crEND().
-     crEND();
- }
-
- // An ISR that uses a queue to receive characters to send on a UART.
- void vUART_ISR( void )
- {
- char cCharToTx;
- BaseType_t xCRWokenByPost = pdFALSE;
-
-     while( UART_TX_REG_EMPTY() )
-     {
-         // Are there any characters in the queue waiting to be sent?
-		 // xCRWokenByPost will automatically be set to pdTRUE if a co-routine
-		 // is woken by the post - ensuring that only a single co-routine is
-		 // woken no matter how many times we go around this loop.
-         if( crQUEUE_RECEIVE_FROM_ISR( pxQueue, &cCharToTx, &xCRWokenByPost ) )
-		 {
-			 SEND_CHARACTER( cCharToTx );
-		 }
-     }
- }
+ * @code{c} + * // A co-routine that posts a character to a queue then blocks for a fixed + * // period. The character is incremented each time. + * static void vSendingCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) + * { + * // cChar holds its value while this co-routine is blocked and must therefore + * // be declared static. + * static char cCharToTx = 'a'; + * BaseType_t xResult; + * + * // All co-routines must start with a call to crSTART(). + * crSTART( xHandle ); + * + * for( ;; ) + * { + * // Send the next character to the queue. + * crQUEUE_SEND( xHandle, xCoRoutineQueue, &cCharToTx, NO_DELAY, &xResult ); + * + * if( xResult == pdPASS ) + * { + * // The character was successfully posted to the queue. + * } + * else + * { + * // Could not post the character to the queue. + * } + * + * // Enable the UART Tx interrupt to cause an interrupt in this + * // hypothetical UART. The interrupt will obtain the character + * // from the queue and send it. + * ENABLE_RX_INTERRUPT(); + * + * // Increment to the next character then block for a fixed period. + * // cCharToTx will maintain its value across the delay as it is + * // declared static. + * cCharToTx++; + * if( cCharToTx > 'x' ) + * { + * cCharToTx = 'a'; + * } + * crDELAY( 100 ); + * } + * + * // All co-routines must end with a call to crEND(). + * crEND(); + * } + * + * // An ISR that uses a queue to receive characters to send on a UART. + * void vUART_ISR( void ) + * { + * char cCharToTx; + * BaseType_t xCRWokenByPost = pdFALSE; + * + * while( UART_TX_REG_EMPTY() ) + * { + * // Are there any characters in the queue waiting to be sent? + * // xCRWokenByPost will automatically be set to pdTRUE if a co-routine + * // is woken by the post - ensuring that only a single co-routine is + * // woken no matter how many times we go around this loop. + * if( crQUEUE_RECEIVE_FROM_ISR( pxQueue, &cCharToTx, &xCRWokenByPost ) ) + * { + * SEND_CHARACTER( cCharToTx ); + * } + * } + * } + * @endcode + * @cond * \defgroup crQUEUE_RECEIVE_FROM_ISR crQUEUE_RECEIVE_FROM_ISR + * @endcond * \ingroup Tasks */ -#define crQUEUE_RECEIVE_FROM_ISR( pxQueue, pvBuffer, pxCoRoutineWoken ) xQueueCRReceiveFromISR( ( pxQueue ), ( pvBuffer ), ( pxCoRoutineWoken ) ) +#define crQUEUE_RECEIVE_FROM_ISR( pxQueue, pvBuffer, pxCoRoutineWoken ) \ + xQueueCRReceiveFromISR( ( pxQueue ), ( pvBuffer ), ( pxCoRoutineWoken ) ) /* * This function is intended for internal use by the co-routine macros only. @@ -702,7 +766,8 @@ void vCoRoutineSchedule( void ); * Removes the current co-routine from its ready list and places it in the * appropriate delayed list. */ -void vCoRoutineAddToDelayedList( TickType_t xTicksToDelay, List_t *pxEventList ); +void vCoRoutineAddToDelayedList( TickType_t xTicksToDelay, + List_t * pxEventList ); /* * This function is intended for internal use by the queue implementation only. @@ -711,10 +776,12 @@ void vCoRoutineAddToDelayedList( TickType_t xTicksToDelay, List_t *pxEventList ) * Removes the highest priority co-routine from the event list and places it in * the pending ready list. */ -BaseType_t xCoRoutineRemoveFromEventList( const List_t *pxEventList ); +BaseType_t xCoRoutineRemoveFromEventList( const List_t * pxEventList ); +/* *INDENT-OFF* */ #ifdef __cplusplus -} + } #endif +/* *INDENT-ON* */ #endif /* CO_ROUTINE_H */ diff --git a/tools/sdk/esp32/include/freertos/include/freertos/deprecated_definitions.h b/tools/sdk/esp32/include/freertos/include/freertos/deprecated_definitions.h index 70fc403bd28..d3b942666d0 100644 --- a/tools/sdk/esp32/include/freertos/include/freertos/deprecated_definitions.h +++ b/tools/sdk/esp32/include/freertos/include/freertos/deprecated_definitions.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ #ifndef DEPRECATED_DEFINITIONS_H @@ -30,158 +29,158 @@ /* Each FreeRTOS port has a unique portmacro.h header file. Originally a -pre-processor definition was used to ensure the pre-processor found the correct -portmacro.h file for the port being used. That scheme was deprecated in favour -of setting the compiler's include path such that it found the correct -portmacro.h file - removing the need for the constant and allowing the -portmacro.h file to be located anywhere in relation to the port being used. The -definitions below remain in the code for backward compatibility only. New -projects should not use them. */ + * pre-processor definition was used to ensure the pre-processor found the correct + * portmacro.h file for the port being used. That scheme was deprecated in favour + * of setting the compiler's include path such that it found the correct + * portmacro.h file - removing the need for the constant and allowing the + * portmacro.h file to be located anywhere in relation to the port being used. The + * definitions below remain in the code for backward compatibility only. New + * projects should not use them. */ #ifdef OPEN_WATCOM_INDUSTRIAL_PC_PORT - #include "..\..\Source\portable\owatcom\16bitdos\pc\portmacro.h" - typedef void ( __interrupt __far *pxISR )(); + #include "..\..\Source\portable\owatcom\16bitdos\pc\portmacro.h" + typedef void ( __interrupt __far * pxISR )(); #endif #ifdef OPEN_WATCOM_FLASH_LITE_186_PORT - #include "..\..\Source\portable\owatcom\16bitdos\flsh186\portmacro.h" - typedef void ( __interrupt __far *pxISR )(); + #include "..\..\Source\portable\owatcom\16bitdos\flsh186\portmacro.h" + typedef void ( __interrupt __far * pxISR )(); #endif #ifdef GCC_MEGA_AVR - #include "../portable/GCC/ATMega323/portmacro.h" + #include "../portable/GCC/ATMega323/portmacro.h" #endif #ifdef IAR_MEGA_AVR - #include "../portable/IAR/ATMega323/portmacro.h" + #include "../portable/IAR/ATMega323/portmacro.h" #endif #ifdef MPLAB_PIC24_PORT - #include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h" + #include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h" #endif #ifdef MPLAB_DSPIC_PORT - #include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h" + #include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h" #endif #ifdef MPLAB_PIC18F_PORT - #include "../../Source/portable/MPLAB/PIC18F/portmacro.h" + #include "../../Source/portable/MPLAB/PIC18F/portmacro.h" #endif #ifdef MPLAB_PIC32MX_PORT - #include "../../Source/portable/MPLAB/PIC32MX/portmacro.h" + #include "../../Source/portable/MPLAB/PIC32MX/portmacro.h" #endif #ifdef _FEDPICC - #include "libFreeRTOS/Include/portmacro.h" + #include "libFreeRTOS/Include/portmacro.h" #endif #ifdef SDCC_CYGNAL - #include "../../Source/portable/SDCC/Cygnal/portmacro.h" + #include "../../Source/portable/SDCC/Cygnal/portmacro.h" #endif #ifdef GCC_ARM7 - #include "../../Source/portable/GCC/ARM7_LPC2000/portmacro.h" + #include "../../Source/portable/GCC/ARM7_LPC2000/portmacro.h" #endif #ifdef GCC_ARM7_ECLIPSE - #include "portmacro.h" + #include "portmacro.h" #endif #ifdef ROWLEY_LPC23xx - #include "../../Source/portable/GCC/ARM7_LPC23xx/portmacro.h" + #include "../../Source/portable/GCC/ARM7_LPC23xx/portmacro.h" #endif #ifdef IAR_MSP430 - #include "..\..\Source\portable\IAR\MSP430\portmacro.h" + #include "..\..\Source\portable\IAR\MSP430\portmacro.h" #endif #ifdef GCC_MSP430 - #include "../../Source/portable/GCC/MSP430F449/portmacro.h" + #include "../../Source/portable/GCC/MSP430F449/portmacro.h" #endif #ifdef ROWLEY_MSP430 - #include "../../Source/portable/Rowley/MSP430F449/portmacro.h" + #include "../../Source/portable/Rowley/MSP430F449/portmacro.h" #endif #ifdef ARM7_LPC21xx_KEIL_RVDS - #include "..\..\Source\portable\RVDS\ARM7_LPC21xx\portmacro.h" + #include "..\..\Source\portable\RVDS\ARM7_LPC21xx\portmacro.h" #endif #ifdef SAM7_GCC - #include "../../Source/portable/GCC/ARM7_AT91SAM7S/portmacro.h" + #include "../../Source/portable/GCC/ARM7_AT91SAM7S/portmacro.h" #endif #ifdef SAM7_IAR - #include "..\..\Source\portable\IAR\AtmelSAM7S64\portmacro.h" + #include "..\..\Source\portable\IAR\AtmelSAM7S64\portmacro.h" #endif #ifdef SAM9XE_IAR - #include "..\..\Source\portable\IAR\AtmelSAM9XE\portmacro.h" + #include "..\..\Source\portable\IAR\AtmelSAM9XE\portmacro.h" #endif #ifdef LPC2000_IAR - #include "..\..\Source\portable\IAR\LPC2000\portmacro.h" + #include "..\..\Source\portable\IAR\LPC2000\portmacro.h" #endif #ifdef STR71X_IAR - #include "..\..\Source\portable\IAR\STR71x\portmacro.h" + #include "..\..\Source\portable\IAR\STR71x\portmacro.h" #endif #ifdef STR75X_IAR - #include "..\..\Source\portable\IAR\STR75x\portmacro.h" + #include "..\..\Source\portable\IAR\STR75x\portmacro.h" #endif #ifdef STR75X_GCC - #include "..\..\Source\portable\GCC\STR75x\portmacro.h" + #include "..\..\Source\portable\GCC\STR75x\portmacro.h" #endif #ifdef STR91X_IAR - #include "..\..\Source\portable\IAR\STR91x\portmacro.h" + #include "..\..\Source\portable\IAR\STR91x\portmacro.h" #endif #ifdef GCC_H8S - #include "../../Source/portable/GCC/H8S2329/portmacro.h" + #include "../../Source/portable/GCC/H8S2329/portmacro.h" #endif #ifdef GCC_AT91FR40008 - #include "../../Source/portable/GCC/ARM7_AT91FR40008/portmacro.h" + #include "../../Source/portable/GCC/ARM7_AT91FR40008/portmacro.h" #endif #ifdef RVDS_ARMCM3_LM3S102 - #include "../../Source/portable/RVDS/ARM_CM3/portmacro.h" + #include "../../Source/portable/RVDS/ARM_CM3/portmacro.h" #endif #ifdef GCC_ARMCM3_LM3S102 - #include "../../Source/portable/GCC/ARM_CM3/portmacro.h" + #include "../../Source/portable/GCC/ARM_CM3/portmacro.h" #endif #ifdef GCC_ARMCM3 - #include "../../Source/portable/GCC/ARM_CM3/portmacro.h" + #include "../../Source/portable/GCC/ARM_CM3/portmacro.h" #endif #ifdef IAR_ARM_CM3 - #include "../../Source/portable/IAR/ARM_CM3/portmacro.h" + #include "../../Source/portable/IAR/ARM_CM3/portmacro.h" #endif #ifdef IAR_ARMCM3_LM - #include "../../Source/portable/IAR/ARM_CM3/portmacro.h" + #include "../../Source/portable/IAR/ARM_CM3/portmacro.h" #endif #ifdef HCS12_CODE_WARRIOR - #include "../../Source/portable/CodeWarrior/HCS12/portmacro.h" + #include "../../Source/portable/CodeWarrior/HCS12/portmacro.h" #endif #ifdef MICROBLAZE_GCC - #include "../../Source/portable/GCC/MicroBlaze/portmacro.h" + #include "../../Source/portable/GCC/MicroBlaze/portmacro.h" #endif #ifdef TERN_EE - #include "..\..\Source\portable\Paradigm\Tern_EE\small\portmacro.h" + #include "..\..\Source\portable\Paradigm\Tern_EE\small\portmacro.h" #endif #ifdef GCC_HCS12 - #include "../../Source/portable/GCC/HCS12/portmacro.h" + #include "../../Source/portable/GCC/HCS12/portmacro.h" #endif #ifdef GCC_MCF5235 @@ -189,90 +188,92 @@ projects should not use them. */ #endif #ifdef COLDFIRE_V2_GCC - #include "../../../Source/portable/GCC/ColdFire_V2/portmacro.h" + #include "../../../Source/portable/GCC/ColdFire_V2/portmacro.h" #endif #ifdef COLDFIRE_V2_CODEWARRIOR - #include "../../Source/portable/CodeWarrior/ColdFire_V2/portmacro.h" + #include "../../Source/portable/CodeWarrior/ColdFire_V2/portmacro.h" #endif #ifdef GCC_PPC405 - #include "../../Source/portable/GCC/PPC405_Xilinx/portmacro.h" + #include "../../Source/portable/GCC/PPC405_Xilinx/portmacro.h" #endif #ifdef GCC_PPC440 - #include "../../Source/portable/GCC/PPC440_Xilinx/portmacro.h" + #include "../../Source/portable/GCC/PPC440_Xilinx/portmacro.h" #endif #ifdef _16FX_SOFTUNE - #include "..\..\Source\portable\Softune\MB96340\portmacro.h" + #include "..\..\Source\portable\Softune\MB96340\portmacro.h" #endif #ifdef BCC_INDUSTRIAL_PC_PORT - /* A short file name has to be used in place of the normal - FreeRTOSConfig.h when using the Borland compiler. */ - #include "frconfig.h" - #include "..\portable\BCC\16BitDOS\PC\prtmacro.h" - typedef void ( __interrupt __far *pxISR )(); + +/* A short file name has to be used in place of the normal + * FreeRTOSConfig.h when using the Borland compiler. */ + #include "frconfig.h" + #include "..\portable\BCC\16BitDOS\PC\prtmacro.h" + typedef void ( __interrupt __far * pxISR )(); #endif #ifdef BCC_FLASH_LITE_186_PORT - /* A short file name has to be used in place of the normal - FreeRTOSConfig.h when using the Borland compiler. */ - #include "frconfig.h" - #include "..\portable\BCC\16BitDOS\flsh186\prtmacro.h" - typedef void ( __interrupt __far *pxISR )(); + +/* A short file name has to be used in place of the normal + * FreeRTOSConfig.h when using the Borland compiler. */ + #include "frconfig.h" + #include "..\portable\BCC\16BitDOS\flsh186\prtmacro.h" + typedef void ( __interrupt __far * pxISR )(); #endif #ifdef __GNUC__ - #ifdef __AVR32_AVR32A__ - #include "portmacro.h" - #endif + #ifdef __AVR32_AVR32A__ + #include "portmacro.h" + #endif #endif #ifdef __ICCAVR32__ - #ifdef __CORE__ - #if __CORE__ == __AVR32A__ - #include "portmacro.h" - #endif - #endif + #ifdef __CORE__ + #if __CORE__ == __AVR32A__ + #include "portmacro.h" + #endif + #endif #endif #ifdef __91467D - #include "portmacro.h" + #include "portmacro.h" #endif #ifdef __96340 - #include "portmacro.h" + #include "portmacro.h" #endif #ifdef __IAR_V850ES_Fx3__ - #include "../../Source/portable/IAR/V850ES/portmacro.h" + #include "../../Source/portable/IAR/V850ES/portmacro.h" #endif #ifdef __IAR_V850ES_Jx3__ - #include "../../Source/portable/IAR/V850ES/portmacro.h" + #include "../../Source/portable/IAR/V850ES/portmacro.h" #endif #ifdef __IAR_V850ES_Jx3_L__ - #include "../../Source/portable/IAR/V850ES/portmacro.h" + #include "../../Source/portable/IAR/V850ES/portmacro.h" #endif #ifdef __IAR_V850ES_Jx2__ - #include "../../Source/portable/IAR/V850ES/portmacro.h" + #include "../../Source/portable/IAR/V850ES/portmacro.h" #endif #ifdef __IAR_V850ES_Hx2__ - #include "../../Source/portable/IAR/V850ES/portmacro.h" + #include "../../Source/portable/IAR/V850ES/portmacro.h" #endif #ifdef __IAR_78K0R_Kx3__ - #include "../../Source/portable/IAR/78K0R/portmacro.h" + #include "../../Source/portable/IAR/78K0R/portmacro.h" #endif #ifdef __IAR_78K0R_Kx3L__ - #include "../../Source/portable/IAR/78K0R/portmacro.h" + #include "../../Source/portable/IAR/78K0R/portmacro.h" #endif #endif /* DEPRECATED_DEFINITIONS_H */ diff --git a/tools/sdk/esp32/include/freertos/include/freertos/event_groups.h b/tools/sdk/esp32/include/freertos/include/freertos/event_groups.h index 5773e8d9071..84505ddaaa0 100644 --- a/tools/sdk/esp32/include/freertos/include/freertos/event_groups.h +++ b/tools/sdk/esp32/include/freertos/include/freertos/event_groups.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,25 +19,26 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ #ifndef EVENT_GROUPS_H #define EVENT_GROUPS_H #ifndef INC_FREERTOS_H - #error "include FreeRTOS.h" must appear in source files before "include event_groups.h" + #error "include FreeRTOS.h" must appear in source files before "include event_groups.h" #endif /* FreeRTOS includes. */ #include "timers.h" +/* *INDENT-OFF* */ #ifdef __cplusplus -extern "C" { + extern "C" { #endif +/* *INDENT-ON* */ /** * An event group is a collection of bits to which an application can assign a @@ -63,6 +64,9 @@ extern "C" { * used to create a synchronisation point between multiple tasks (a * 'rendezvous'). * + * @cond + * \defgroup EventGroup EventGroup + * @endcond */ @@ -74,34 +78,45 @@ extern "C" { * xEventGroupCreate() returns an EventGroupHandle_t variable that can then * be used as a parameter to other event group functions. * + * @cond * \defgroup EventGroupHandle_t EventGroupHandle_t + * @endcond * \ingroup EventGroup */ struct EventGroupDef_t; -//typedef struct EventGroupDef_t * EventGroupHandle_t; +#ifdef ESP_PLATFORM // IDF-3770 typedef void * EventGroupHandle_t; - +#else +typedef struct EventGroupDef_t * EventGroupHandle_t; +#endif // ESP_PLATFORM /* * The type that holds event bits always matches TickType_t - therefore the * number of bits it holds is set by configUSE_16_BIT_TICKS (16 bits if set to 1, * 32 bits if set to 0. * + * @cond * \defgroup EventBits_t EventBits_t + * @endcond * \ingroup EventGroup */ -typedef TickType_t EventBits_t; +typedef TickType_t EventBits_t; /** - * + * @cond + * event_groups.h + * @code{c} + * EventGroupHandle_t xEventGroupCreate( void ); + * @endcode + * @endcond * * 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 + * 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 + * (see https://www.FreeRTOS.org/a00111.html). If an event group is created + * using xEventGroupCreateStatic() 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. @@ -116,42 +131,52 @@ typedef TickType_t EventBits_t; * * @return If the event group was created then a handle to the event group is * returned. If there was insufficient FreeRTOS heap available to create the - * event group then NULL is returned. See http://www.freertos.org/a00111.html + * event group then NULL is returned. See https://www.FreeRTOS.org/a00111.html * * Example usage: * @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. - * } + * // 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 + * @cond + * \defgroup xEventGroupCreate xEventGroupCreate + * @endcond * \ingroup EventGroup */ -#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - EventGroupHandle_t xEventGroupCreate( void ) PRIVILEGED_FUNCTION; +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + EventGroupHandle_t xEventGroupCreate( void ) PRIVILEGED_FUNCTION; #endif /** + * @cond + * event_groups.h + * @code{c} + * EventGroupHandle_t xEventGroupCreateStatic( EventGroupHandle_t * pxEventGroupBuffer ); + * @endcode + * @endcond + * * 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 + * 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 + * (see https://www.FreeRTOS.org/a00111.html). If an event group is created + * using xEventGroupCreateStatic() 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. @@ -173,25 +198,36 @@ typedef TickType_t EventBits_t; * * 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 ); + * // 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; +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + EventGroupHandle_t xEventGroupCreateStatic( StaticEventGroup_t * pxEventGroupBuffer ) PRIVILEGED_FUNCTION; #endif /** + * @cond + * event_groups.h + * @code{c} + * EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup, + * const EventBits_t uxBitsToWaitFor, + * const BaseType_t xClearOnExit, + * const BaseType_t xWaitForAllBits, + * const TickType_t xTicksToWait ); + * @endcode + * @endcond + * * [Potentially] block to wait for one or more bits to be set within a * previously created event group. * @@ -235,47 +271,60 @@ typedef TickType_t EventBits_t; * * Example usage: * @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} + * #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 + * @cond + * \defgroup xEventGroupWaitBits xEventGroupWaitBits + * @endcond * \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; +EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup, + const EventBits_t uxBitsToWaitFor, + const BaseType_t xClearOnExit, + const BaseType_t xWaitForAllBits, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; /** + * @cond + * event_groups.h + * @code{c} + * EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear ); + * @endcode + * @endcond * * Clear bits within an event group. This function cannot be called from an * interrupt. @@ -290,44 +339,54 @@ EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup, const EventBits * * Example usage: * @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. - * } - * } + * #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 + * @cond + * \defgroup xEventGroupClearBits xEventGroupClearBits + * @endcond * \ingroup EventGroup */ -EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear ) PRIVILEGED_FUNCTION; +EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, + const EventBits_t uxBitsToClear ) PRIVILEGED_FUNCTION; /** + * @cond + * event_groups.h + * @code{c} + * BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ); + * @endcode + * @endcond * * A version of xEventGroupClearBits() that can be called from an interrupt. * @@ -353,35 +412,46 @@ EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBit * * Example usage: * @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. - * } - * } + * #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 + * @cond + * \defgroup xEventGroupClearBitsFromISR xEventGroupClearBitsFromISR + * @endcond * \ingroup EventGroup */ -#if( configUSE_TRACE_FACILITY == 1 ) - BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear ) PRIVILEGED_FUNCTION; +#if ( configUSE_TRACE_FACILITY == 1 ) + BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup, + const EventBits_t uxBitsToClear ) PRIVILEGED_FUNCTION; #else - #define xEventGroupClearBitsFromISR( xEventGroup, uxBitsToClear ) xTimerPendFunctionCallFromISR( vEventGroupClearBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToClear, NULL ) + #define xEventGroupClearBitsFromISR( xEventGroup, uxBitsToClear ) \ + xTimerPendFunctionCallFromISR( vEventGroupClearBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToClear, NULL ) #endif /** + * @cond + * event_groups.h + * @code{c} + * EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ); + * @endcode + * @endcond * * Set bits within an event group. * This function cannot be called from an interrupt. xEventGroupSetBitsFromISR() @@ -408,49 +478,59 @@ EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBit * * Example usage: * @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} + * #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 + * @cond + * \defgroup xEventGroupSetBits xEventGroupSetBits + * @endcond * \ingroup EventGroup */ -EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ) PRIVILEGED_FUNCTION; +EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, + const EventBits_t uxBitsToSet ) PRIVILEGED_FUNCTION; /** + * @cond + * event_groups.h + * @code{c} + * BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * @endcond * * A version of xEventGroupSetBits() that can be called from an interrupt. * @@ -484,46 +564,61 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_ * * Example usage: * @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 ); - * } - * } + * #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 + * @cond + * \defgroup xEventGroupSetBitsFromISR xEventGroupSetBitsFromISR + * @endcond * \ingroup EventGroup */ -#if( configUSE_TRACE_FACILITY == 1 ) - BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; +#if ( configUSE_TRACE_FACILITY == 1 ) + BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, + const EventBits_t uxBitsToSet, + BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; #else - #define xEventGroupSetBitsFromISR( xEventGroup, uxBitsToSet, pxHigherPriorityTaskWoken ) xTimerPendFunctionCallFromISR( vEventGroupSetBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToSet, pxHigherPriorityTaskWoken ) + #define xEventGroupSetBitsFromISR( xEventGroup, uxBitsToSet, pxHigherPriorityTaskWoken ) \ + xTimerPendFunctionCallFromISR( vEventGroupSetBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToSet, pxHigherPriorityTaskWoken ) #endif /** + * @cond + * event_groups.h + * @code{c} + * EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, + * const EventBits_t uxBitsToSet, + * const EventBits_t uxBitsToWaitFor, + * TickType_t xTicksToWait ); + * @endcode + * @endcond * * 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 @@ -563,86 +658,98 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_ * * Example usage: * @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. - * } - * } + * // 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. - * } + * } + * + * 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 synchronisation 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 synchronisation was made by all + * // three tasks, so there is no need to test the return value. * } + * } * * @endcode + * @cond + * \defgroup xEventGroupSync xEventGroupSync + * @endcond * \ingroup EventGroup */ -EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, + const EventBits_t uxBitsToSet, + const EventBits_t uxBitsToWaitFor, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; /** + * @cond + * event_groups.h + * @code{c} + * EventBits_t xEventGroupGetBits( EventGroupHandle_t xEventGroup ); + * @endcode + * @endcond * * Returns the current value of the bits in an event group. This function * cannot be used from an interrupt. @@ -651,11 +758,20 @@ EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t u * * @return The event group bits at the time xEventGroupGetBits() was called. * + * @cond + * \defgroup xEventGroupGetBits xEventGroupGetBits + * @endcond * \ingroup EventGroup */ -#define xEventGroupGetBits( xEventGroup ) xEventGroupClearBits( xEventGroup, 0 ) +#define xEventGroupGetBits( xEventGroup ) xEventGroupClearBits( xEventGroup, 0 ) /** + * @cond + * event_groups.h + * @code{c} + * EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup ); + * @endcode + * @endcond * * A version of xEventGroupGetBits() that can be called from an ISR. * @@ -663,11 +779,21 @@ EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t u * * @return The event group bits at the time xEventGroupGetBitsFromISR() was called. * + * @cond + * \defgroup xEventGroupGetBitsFromISR xEventGroupGetBitsFromISR + * @endcond * \ingroup EventGroup */ EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION; /** + * @cond + * event_groups.h + * @code{c} + * void xEventGroupDelete( EventGroupHandle_t xEventGroup ); + * @endcode + * @endcond + * * Delete an event group that was previously created by a call to * xEventGroupCreate(). Tasks that are blocked on the event group will be * unblocked and obtain 0 as the event group's value. @@ -679,19 +805,24 @@ void vEventGroupDelete( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION; /** @cond */ /* For internal use only. */ -void vEventGroupSetBitsCallback( void *pvEventGroup, const uint32_t ulBitsToSet ) PRIVILEGED_FUNCTION; -void vEventGroupClearBitsCallback( void *pvEventGroup, const uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION; +void vEventGroupSetBitsCallback( void * pvEventGroup, + const uint32_t ulBitsToSet ) PRIVILEGED_FUNCTION; +void vEventGroupClearBitsCallback( void * pvEventGroup, + const uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION; -#if (configUSE_TRACE_FACILITY == 1) - UBaseType_t uxEventGroupGetNumber( void* xEventGroup ) PRIVILEGED_FUNCTION; - void vEventGroupSetNumber( void* xEventGroup, UBaseType_t uxEventGroupNumber ) PRIVILEGED_FUNCTION; +#if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxEventGroupGetNumber( void * xEventGroup ) PRIVILEGED_FUNCTION; + void vEventGroupSetNumber( void * xEventGroup, + UBaseType_t uxEventGroupNumber ) PRIVILEGED_FUNCTION; #endif /** @endcond */ +/* *INDENT-OFF* */ #ifdef __cplusplus -} + } #endif +/* *INDENT-ON* */ #endif /* EVENT_GROUPS_H */ diff --git a/tools/sdk/esp32/include/freertos/include/freertos/list.h b/tools/sdk/esp32/include/freertos/include/freertos/list.h index d06481e29bf..f76328f8e03 100644 --- a/tools/sdk/esp32/include/freertos/include/freertos/list.h +++ b/tools/sdk/esp32/include/freertos/include/freertos/list.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ /* @@ -54,7 +53,7 @@ */ #ifndef INC_FREERTOS_H - #error FreeRTOS.h must be included before list.h + #error "FreeRTOS.h must be included before list.h" #endif #ifndef LIST_H @@ -89,47 +88,49 @@ * "#define configLIST_VOLATILE volatile" */ #ifndef configLIST_VOLATILE - #define configLIST_VOLATILE + #define configLIST_VOLATILE #endif /* configSUPPORT_CROSS_MODULE_OPTIMISATION */ +/* *INDENT-OFF* */ #ifdef __cplusplus -extern "C" { + extern "C" { #endif +/* *INDENT-ON* */ /* Macros that can be used to place known values within the list structures, -then check that the known values do not get corrupted during the execution of -the application. These may catch the list data structures being overwritten in -memory. They will not catch data errors caused by incorrect configuration or -use of FreeRTOS.*/ -#if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 0 ) - /* Define the macros to do nothing. */ - #define listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE - #define listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE - #define listFIRST_LIST_INTEGRITY_CHECK_VALUE - #define listSECOND_LIST_INTEGRITY_CHECK_VALUE - #define listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) - #define listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) - #define listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList ) - #define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList ) - #define listTEST_LIST_ITEM_INTEGRITY( pxItem ) - #define listTEST_LIST_INTEGRITY( pxList ) -#else - /* Define macros that add new members into the list structures. */ - #define listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE TickType_t xListItemIntegrityValue1; - #define listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE TickType_t xListItemIntegrityValue2; - #define listFIRST_LIST_INTEGRITY_CHECK_VALUE TickType_t xListIntegrityValue1; - #define listSECOND_LIST_INTEGRITY_CHECK_VALUE TickType_t xListIntegrityValue2; - - /* Define macros that set the new structure members to known values. */ - #define listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) ( pxItem )->xListItemIntegrityValue1 = pdINTEGRITY_CHECK_VALUE - #define listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) ( pxItem )->xListItemIntegrityValue2 = pdINTEGRITY_CHECK_VALUE - #define listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList ) ( pxList )->xListIntegrityValue1 = pdINTEGRITY_CHECK_VALUE - #define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList ) ( pxList )->xListIntegrityValue2 = pdINTEGRITY_CHECK_VALUE - - /* Define macros that will assert if one of the structure members does not - contain its expected value. */ - #define listTEST_LIST_ITEM_INTEGRITY( pxItem ) configASSERT( ( ( pxItem )->xListItemIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxItem )->xListItemIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) ) - #define listTEST_LIST_INTEGRITY( pxList ) configASSERT( ( ( pxList )->xListIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxList )->xListIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) ) + * then check that the known values do not get corrupted during the execution of + * the application. These may catch the list data structures being overwritten in + * memory. They will not catch data errors caused by incorrect configuration or + * use of FreeRTOS.*/ +#if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 0 ) + /* Define the macros to do nothing. */ + #define listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE + #define listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE + #define listFIRST_LIST_INTEGRITY_CHECK_VALUE + #define listSECOND_LIST_INTEGRITY_CHECK_VALUE + #define listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) + #define listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) + #define listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList ) + #define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList ) + #define listTEST_LIST_ITEM_INTEGRITY( pxItem ) + #define listTEST_LIST_INTEGRITY( pxList ) +#else /* if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 0 ) */ + /* Define macros that add new members into the list structures. */ + #define listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE TickType_t xListItemIntegrityValue1; + #define listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE TickType_t xListItemIntegrityValue2; + #define listFIRST_LIST_INTEGRITY_CHECK_VALUE TickType_t xListIntegrityValue1; + #define listSECOND_LIST_INTEGRITY_CHECK_VALUE TickType_t xListIntegrityValue2; + +/* Define macros that set the new structure members to known values. */ + #define listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) ( pxItem )->xListItemIntegrityValue1 = pdINTEGRITY_CHECK_VALUE + #define listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) ( pxItem )->xListItemIntegrityValue2 = pdINTEGRITY_CHECK_VALUE + #define listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList ) ( pxList )->xListIntegrityValue1 = pdINTEGRITY_CHECK_VALUE + #define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList ) ( pxList )->xListIntegrityValue2 = pdINTEGRITY_CHECK_VALUE + +/* Define macros that will assert if one of the structure members does not + * contain its expected value. */ + #define listTEST_LIST_ITEM_INTEGRITY( pxItem ) configASSERT( ( ( pxItem )->xListItemIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxItem )->xListItemIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) ) + #define listTEST_LIST_INTEGRITY( pxList ) configASSERT( ( ( pxList )->xListIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxList )->xListIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) ) #endif /* configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES */ @@ -139,22 +140,22 @@ use of FreeRTOS.*/ struct xLIST; struct xLIST_ITEM { - listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ - configLIST_VOLATILE TickType_t xItemValue; /*< The value being listed. In most cases this is used to sort the list in descending order. */ - struct xLIST_ITEM * configLIST_VOLATILE pxNext; /*< Pointer to the next ListItem_t in the list. */ - struct xLIST_ITEM * configLIST_VOLATILE pxPrevious; /*< Pointer to the previous ListItem_t in the list. */ - void * pvOwner; /*< Pointer to the object (normally a TCB) that contains the list item. There is therefore a two way link between the object containing the list item and the list item itself. */ - struct xLIST * configLIST_VOLATILE pxContainer; /*< Pointer to the list in which this list item is placed (if any). */ - listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ + listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ + configLIST_VOLATILE TickType_t xItemValue; /*< The value being listed. In most cases this is used to sort the list in descending order. */ + struct xLIST_ITEM * configLIST_VOLATILE pxNext; /*< Pointer to the next ListItem_t in the list. */ + struct xLIST_ITEM * configLIST_VOLATILE pxPrevious; /*< Pointer to the previous ListItem_t in the list. */ + void * pvOwner; /*< Pointer to the object (normally a TCB) that contains the list item. There is therefore a two way link between the object containing the list item and the list item itself. */ + struct xLIST * configLIST_VOLATILE pxContainer; /*< Pointer to the list in which this list item is placed (if any). */ + listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ }; -typedef struct xLIST_ITEM ListItem_t; /* For some reason lint wants this as two separate definitions. */ +typedef struct xLIST_ITEM ListItem_t; /* For some reason lint wants this as two separate definitions. */ struct xMINI_LIST_ITEM { - listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ - configLIST_VOLATILE TickType_t xItemValue; - struct xLIST_ITEM * configLIST_VOLATILE pxNext; - struct xLIST_ITEM * configLIST_VOLATILE pxPrevious; + listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ + configLIST_VOLATILE TickType_t xItemValue; + struct xLIST_ITEM * configLIST_VOLATILE pxNext; + struct xLIST_ITEM * configLIST_VOLATILE pxPrevious; }; typedef struct xMINI_LIST_ITEM MiniListItem_t; @@ -163,11 +164,11 @@ typedef struct xMINI_LIST_ITEM MiniListItem_t; */ typedef struct xLIST { - listFIRST_LIST_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ - volatile UBaseType_t uxNumberOfItems; - ListItem_t * configLIST_VOLATILE pxIndex; /*< Used to walk through the list. Points to the last item returned by a call to listGET_OWNER_OF_NEXT_ENTRY (). */ - MiniListItem_t xListEnd; /*< List item that contains the maximum possible item value meaning it is always at the end of the list and is therefore used as a marker. */ - listSECOND_LIST_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ + listFIRST_LIST_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ + volatile UBaseType_t uxNumberOfItems; + ListItem_t * configLIST_VOLATILE pxIndex; /*< Used to walk through the list. Points to the last item returned by a call to listGET_OWNER_OF_NEXT_ENTRY (). */ + MiniListItem_t xListEnd; /*< List item that contains the maximum possible item value meaning it is always at the end of the list and is therefore used as a marker. */ + listSECOND_LIST_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ } List_t; /* @@ -177,7 +178,7 @@ typedef struct xLIST * \page listSET_LIST_ITEM_OWNER listSET_LIST_ITEM_OWNER * \ingroup LinkedList */ -#define listSET_LIST_ITEM_OWNER( pxListItem, pxOwner ) ( ( pxListItem )->pvOwner = ( void * ) ( pxOwner ) ) +#define listSET_LIST_ITEM_OWNER( pxListItem, pxOwner ) ( ( pxListItem )->pvOwner = ( void * ) ( pxOwner ) ) /* * Access macro to get the owner of a list item. The owner of a list item @@ -186,7 +187,7 @@ typedef struct xLIST * \page listGET_LIST_ITEM_OWNER listSET_LIST_ITEM_OWNER * \ingroup LinkedList */ -#define listGET_LIST_ITEM_OWNER( pxListItem ) ( ( pxListItem )->pvOwner ) +#define listGET_LIST_ITEM_OWNER( pxListItem ) ( ( pxListItem )->pvOwner ) /* * Access macro to set the value of the list item. In most cases the value is @@ -195,7 +196,7 @@ typedef struct xLIST * \page listSET_LIST_ITEM_VALUE listSET_LIST_ITEM_VALUE * \ingroup LinkedList */ -#define listSET_LIST_ITEM_VALUE( pxListItem, xValue ) ( ( pxListItem )->xItemValue = ( xValue ) ) +#define listSET_LIST_ITEM_VALUE( pxListItem, xValue ) ( ( pxListItem )->xItemValue = ( xValue ) ) /* * Access macro to retrieve the value of the list item. The value can @@ -205,7 +206,7 @@ typedef struct xLIST * \page listGET_LIST_ITEM_VALUE listGET_LIST_ITEM_VALUE * \ingroup LinkedList */ -#define listGET_LIST_ITEM_VALUE( pxListItem ) ( ( pxListItem )->xItemValue ) +#define listGET_LIST_ITEM_VALUE( pxListItem ) ( ( pxListItem )->xItemValue ) /* * Access macro to retrieve the value of the list item at the head of a given @@ -214,7 +215,7 @@ typedef struct xLIST * \page listGET_LIST_ITEM_VALUE listGET_LIST_ITEM_VALUE * \ingroup LinkedList */ -#define listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxList ) ( ( ( pxList )->xListEnd ).pxNext->xItemValue ) +#define listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxList ) ( ( ( pxList )->xListEnd ).pxNext->xItemValue ) /* * Return the list item at the head of the list. @@ -222,7 +223,7 @@ typedef struct xLIST * \page listGET_HEAD_ENTRY listGET_HEAD_ENTRY * \ingroup LinkedList */ -#define listGET_HEAD_ENTRY( pxList ) ( ( ( pxList )->xListEnd ).pxNext ) +#define listGET_HEAD_ENTRY( pxList ) ( ( ( pxList )->xListEnd ).pxNext ) /* * Return the next list item. @@ -230,7 +231,7 @@ typedef struct xLIST * \page listGET_NEXT listGET_NEXT * \ingroup LinkedList */ -#define listGET_NEXT( pxListItem ) ( ( pxListItem )->pxNext ) +#define listGET_NEXT( pxListItem ) ( ( pxListItem )->pxNext ) /* * Return the list item that marks the end of the list @@ -238,7 +239,7 @@ typedef struct xLIST * \page listGET_END_MARKER listGET_END_MARKER * \ingroup LinkedList */ -#define listGET_END_MARKER( pxList ) ( ( ListItem_t const * ) ( &( ( pxList )->xListEnd ) ) ) +#define listGET_END_MARKER( pxList ) ( ( ListItem_t const * ) ( &( ( pxList )->xListEnd ) ) ) /* * Access macro to determine if a list contains any items. The macro will @@ -247,12 +248,12 @@ typedef struct xLIST * \page listLIST_IS_EMPTY listLIST_IS_EMPTY * \ingroup LinkedList */ -#define listLIST_IS_EMPTY( pxList ) ( ( ( pxList )->uxNumberOfItems == ( UBaseType_t ) 0 ) ? pdTRUE : pdFALSE ) +#define listLIST_IS_EMPTY( pxList ) ( ( ( pxList )->uxNumberOfItems == ( UBaseType_t ) 0 ) ? pdTRUE : pdFALSE ) /* * Access macro to return the number of items in the list. */ -#define listCURRENT_LIST_LENGTH( pxList ) ( ( pxList )->uxNumberOfItems ) +#define listCURRENT_LIST_LENGTH( pxList ) ( ( pxList )->uxNumberOfItems ) /* * Access function to obtain the owner of the next entry in a list. @@ -274,18 +275,18 @@ typedef struct xLIST * \page listGET_OWNER_OF_NEXT_ENTRY listGET_OWNER_OF_NEXT_ENTRY * \ingroup LinkedList */ -#define listGET_OWNER_OF_NEXT_ENTRY( pxTCB, pxList ) \ -{ \ -List_t * const pxConstList = ( pxList ); \ - /* Increment the index to the next item and return the item, ensuring */ \ - /* we don't return the marker used at the end of the list. */ \ - ( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \ - if( ( void * ) ( pxConstList )->pxIndex == ( void * ) &( ( pxConstList )->xListEnd ) ) \ - { \ - ( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \ - } \ - ( pxTCB ) = ( pxConstList )->pxIndex->pvOwner; \ -} +#define listGET_OWNER_OF_NEXT_ENTRY( pxTCB, pxList ) \ + { \ + List_t * const pxConstList = ( pxList ); \ + /* Increment the index to the next item and return the item, ensuring */ \ + /* we don't return the marker used at the end of the list. */ \ + ( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \ + if( ( void * ) ( pxConstList )->pxIndex == ( void * ) &( ( pxConstList )->xListEnd ) ) \ + { \ + ( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \ + } \ + ( pxTCB ) = ( pxConstList )->pxIndex->pvOwner; \ + } /* @@ -304,7 +305,7 @@ List_t * const pxConstList = ( pxList ); \ * \page listGET_OWNER_OF_HEAD_ENTRY listGET_OWNER_OF_HEAD_ENTRY * \ingroup LinkedList */ -#define listGET_OWNER_OF_HEAD_ENTRY( pxList ) ( (&( ( pxList )->xListEnd ))->pxNext->pvOwner ) +#define listGET_OWNER_OF_HEAD_ENTRY( pxList ) ( ( &( ( pxList )->xListEnd ) )->pxNext->pvOwner ) /* * Check to see if a list item is within a list. The list item maintains a @@ -315,7 +316,7 @@ List_t * const pxConstList = ( pxList ); \ * @param pxListItem The list item we want to know if is in the list. * @return pdTRUE if the list item is in the list, otherwise pdFALSE. */ -#define listIS_CONTAINED_WITHIN( pxList, pxListItem ) ( ( ( pxListItem )->pxContainer == ( pxList ) ) ? ( pdTRUE ) : ( pdFALSE ) ) +#define listIS_CONTAINED_WITHIN( pxList, pxListItem ) ( ( ( pxListItem )->pxContainer == ( pxList ) ) ? ( pdTRUE ) : ( pdFALSE ) ) /* * Return the list a list item is contained within (referenced from). @@ -323,14 +324,14 @@ List_t * const pxConstList = ( pxList ); \ * @param pxListItem The list item being queried. * @return A pointer to the List_t object that references the pxListItem */ -#define listLIST_ITEM_CONTAINER( pxListItem ) ( ( pxListItem )->pxContainer ) +#define listLIST_ITEM_CONTAINER( pxListItem ) ( ( pxListItem )->pxContainer ) /* * This provides a crude means of knowing if a list has been initialised, as * pxList->xListEnd.xItemValue is set to portMAX_DELAY by the vListInitialise() * function. */ -#define listLIST_IS_INITIALISED( pxList ) ( ( pxList )->xListEnd.xItemValue == portMAX_DELAY ) +#define listLIST_IS_INITIALISED( pxList ) ( ( pxList )->xListEnd.xItemValue == portMAX_DELAY ) /* * Must be called before a list is used! This initialises all the members @@ -366,7 +367,8 @@ void vListInitialiseItem( ListItem_t * const pxItem ) PRIVILEGED_FUNCTION; * \page vListInsert vListInsert * \ingroup LinkedList */ -void vListInsert( List_t * const pxList, ListItem_t * const pxNewListItem ) PRIVILEGED_FUNCTION; +void vListInsert( List_t * const pxList, + ListItem_t * const pxNewListItem ) PRIVILEGED_FUNCTION; /* * Insert a list item into a list. The item will be inserted in a position @@ -387,7 +389,8 @@ void vListInsert( List_t * const pxList, ListItem_t * const pxNewListItem ) PRIV * \page vListInsertEnd vListInsertEnd * \ingroup LinkedList */ -void vListInsertEnd( List_t * const pxList, ListItem_t * const pxNewListItem ) PRIVILEGED_FUNCTION; +void vListInsertEnd( List_t * const pxList, + ListItem_t * const pxNewListItem ) PRIVILEGED_FUNCTION; /* * Remove an item from a list. The list item has a pointer to the list that @@ -404,8 +407,10 @@ void vListInsertEnd( List_t * const pxList, ListItem_t * const pxNewListItem ) P */ UBaseType_t uxListRemove( ListItem_t * const pxItemToRemove ) PRIVILEGED_FUNCTION; +/* *INDENT-OFF* */ #ifdef __cplusplus -} + } #endif +/* *INDENT-ON* */ -#endif +#endif /* ifndef LIST_H */ diff --git a/tools/sdk/esp32/include/freertos/include/freertos/message_buffer.h b/tools/sdk/esp32/include/freertos/include/freertos/message_buffer.h index a49324da437..e57c589fbac 100644 --- a/tools/sdk/esp32/include/freertos/include/freertos/message_buffer.h +++ b/tools/sdk/esp32/include/freertos/include/freertos/message_buffer.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ @@ -63,15 +62,17 @@ #define FREERTOS_MESSAGE_BUFFER_H #ifndef INC_FREERTOS_H - #error "include FreeRTOS.h must appear in source files before include message_buffer.h" + #error "include FreeRTOS.h must appear in source files before include message_buffer.h" #endif /* Message buffers are built onto of stream buffers. */ #include "stream_buffer.h" +/* *INDENT-OFF* */ #if defined( __cplusplus ) -extern "C" { + extern "C" { #endif +/* *INDENT-ON* */ /** * Type by which message buffers are referenced. For example, a call to @@ -84,6 +85,14 @@ typedef void * MessageBufferHandle_t; /*-----------------------------------------------------------*/ /** + * @cond + * message_buffer.h + * + * @code{c} + * MessageBufferHandle_t xMessageBufferCreate( size_t xBufferSizeBytes ); + * @endcode + * @endcond + * * Creates a new message buffer using dynamically allocated memory. See * xMessageBufferCreateStatic() for a version that uses statically allocated * memory (memory that is allocated at compile time). @@ -113,28 +122,41 @@ typedef void * MessageBufferHandle_t; * MessageBufferHandle_t xMessageBuffer; * const size_t xMessageBufferSizeBytes = 100; * - * // Create a message buffer that can hold 100 bytes. The memory used to hold - * // both the message buffer structure and the messages themselves is allocated - * // dynamically. Each message added to the buffer consumes an additional 4 - * // bytes which are used to hold the lengh of the message. - * xMessageBuffer = xMessageBufferCreate( xMessageBufferSizeBytes ); - * - * if( xMessageBuffer == NULL ) - * { - * // There was not enough heap memory space available to create the - * // message buffer. - * } - * else - * { - * // The message buffer was created successfully and can now be used. - * } + * // Create a message buffer that can hold 100 bytes. The memory used to hold + * // both the message buffer structure and the messages themselves is allocated + * // dynamically. Each message added to the buffer consumes an additional 4 + * // bytes which are used to hold the lengh of the message. + * xMessageBuffer = xMessageBufferCreate( xMessageBufferSizeBytes ); + * + * if( xMessageBuffer == NULL ) + * { + * // There was not enough heap memory space available to create the + * // message buffer. + * } + * else + * { + * // The message buffer was created successfully and can now be used. + * } * * @endcode + * @cond + * \defgroup xMessageBufferCreate xMessageBufferCreate + * @endcond * \ingroup MessageBufferManagement */ -#define xMessageBufferCreate( xBufferSizeBytes ) ( MessageBufferHandle_t ) xStreamBufferGenericCreate( xBufferSizeBytes, ( size_t ) 0, pdTRUE ) +#define xMessageBufferCreate( xBufferSizeBytes ) \ + ( MessageBufferHandle_t ) xStreamBufferGenericCreate( xBufferSizeBytes, ( size_t ) 0, pdTRUE ) /** + * @cond + * message_buffer.h + * + * @code{c} + * MessageBufferHandle_t xMessageBufferCreateStatic( size_t xBufferSizeBytes, + * uint8_t *pucMessageBufferStorageArea, + * StaticMessageBuffer_t *pxStaticMessageBuffer ); + * @endcode + * @endcond * Creates a new message buffer using statically allocated memory. See * xMessageBufferCreate() for a version that uses dynamically allocated memory. * @@ -176,23 +198,38 @@ typedef void * MessageBufferHandle_t; * { * MessageBufferHandle_t xMessageBuffer; * - * xMessageBuffer = xMessageBufferCreateStatic( sizeof( ucBufferStorage ), - * ucBufferStorage, - * &xMessageBufferStruct ); + * xMessageBuffer = xMessageBufferCreateStatic( sizeof( ucBufferStorage ), + * ucBufferStorage, + * &xMessageBufferStruct ); * - * // As neither the pucMessageBufferStorageArea or pxStaticMessageBuffer - * // parameters were NULL, xMessageBuffer will not be NULL, and can be used to - * // reference the created message buffer in other message buffer API calls. + * // As neither the pucMessageBufferStorageArea or pxStaticMessageBuffer + * // parameters were NULL, xMessageBuffer will not be NULL, and can be used to + * // reference the created message buffer in other message buffer API calls. * - * // Other code that uses the message buffer can go here. + * // Other code that uses the message buffer can go here. * } * * @endcode + * @cond + * \defgroup xMessageBufferCreateStatic xMessageBufferCreateStatic + * @endcond * \ingroup MessageBufferManagement */ -#define xMessageBufferCreateStatic( xBufferSizeBytes, pucMessageBufferStorageArea, pxStaticMessageBuffer ) ( MessageBufferHandle_t ) xStreamBufferGenericCreateStatic( xBufferSizeBytes, 0, pdTRUE, pucMessageBufferStorageArea, pxStaticMessageBuffer ) +#define xMessageBufferCreateStatic( xBufferSizeBytes, pucMessageBufferStorageArea, pxStaticMessageBuffer ) \ + ( MessageBufferHandle_t ) xStreamBufferGenericCreateStatic( xBufferSizeBytes, 0, pdTRUE, pucMessageBufferStorageArea, pxStaticMessageBuffer ) /** + * @cond + * message_buffer.h + * + * @code{c} + * size_t xMessageBufferSend( MessageBufferHandle_t xMessageBuffer, + * const void *pvTxData, + * size_t xDataLengthBytes, + * TickType_t xTicksToWait ); + * @endcode + * @endcond + * * Sends a discrete message to the message buffer. The message can be any * length that fits within the buffer's free space, and is copied into the * buffer. @@ -256,32 +293,47 @@ typedef void * MessageBufferHandle_t; * char *pcStringToSend = "String to send"; * const TickType_t x100ms = pdMS_TO_TICKS( 100 ); * - * // Send an array to the message buffer, blocking for a maximum of 100ms to - * // wait for enough space to be available in the message buffer. - * xBytesSent = xMessageBufferSend( xMessageBuffer, ( void * ) ucArrayToSend, sizeof( ucArrayToSend ), x100ms ); - * - * if( xBytesSent != sizeof( ucArrayToSend ) ) - * { - * // The call to xMessageBufferSend() times out before there was enough - * // space in the buffer for the data to be written. - * } - * - * // Send the string to the message buffer. Return immediately if there is - * // not enough space in the buffer. - * xBytesSent = xMessageBufferSend( xMessageBuffer, ( void * ) pcStringToSend, strlen( pcStringToSend ), 0 ); - * - * if( xBytesSent != strlen( pcStringToSend ) ) - * { - * // The string could not be added to the message buffer because there was - * // not enough free space in the buffer. - * } + * // Send an array to the message buffer, blocking for a maximum of 100ms to + * // wait for enough space to be available in the message buffer. + * xBytesSent = xMessageBufferSend( xMessageBuffer, ( void * ) ucArrayToSend, sizeof( ucArrayToSend ), x100ms ); + * + * if( xBytesSent != sizeof( ucArrayToSend ) ) + * { + * // The call to xMessageBufferSend() times out before there was enough + * // space in the buffer for the data to be written. + * } + * + * // Send the string to the message buffer. Return immediately if there is + * // not enough space in the buffer. + * xBytesSent = xMessageBufferSend( xMessageBuffer, ( void * ) pcStringToSend, strlen( pcStringToSend ), 0 ); + * + * if( xBytesSent != strlen( pcStringToSend ) ) + * { + * // The string could not be added to the message buffer because there was + * // not enough free space in the buffer. + * } * } * @endcode + * @cond + * \defgroup xMessageBufferSend xMessageBufferSend + * @endcond * \ingroup MessageBufferManagement */ -#define xMessageBufferSend( xMessageBuffer, pvTxData, xDataLengthBytes, xTicksToWait ) xStreamBufferSend( ( StreamBufferHandle_t ) xMessageBuffer, pvTxData, xDataLengthBytes, xTicksToWait ) +#define xMessageBufferSend( xMessageBuffer, pvTxData, xDataLengthBytes, xTicksToWait ) \ + xStreamBufferSend( ( StreamBufferHandle_t ) xMessageBuffer, pvTxData, xDataLengthBytes, xTicksToWait ) /** + * @cond + * message_buffer.h + * + * @code{c} + * size_t xMessageBufferSendFromISR( MessageBufferHandle_t xMessageBuffer, + * const void *pvTxData, + * size_t xDataLengthBytes, + * BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * @endcond + * * Interrupt safe version of the API function that sends a discrete message to * the message buffer. The message can be any length that fits within the * buffer's free space, and is copied into the buffer. @@ -348,34 +400,49 @@ typedef void * MessageBufferHandle_t; * char *pcStringToSend = "String to send"; * BaseType_t xHigherPriorityTaskWoken = pdFALSE; // Initialised to pdFALSE. * - * // Attempt to send the string to the message buffer. - * xBytesSent = xMessageBufferSendFromISR( xMessageBuffer, - * ( void * ) pcStringToSend, - * strlen( pcStringToSend ), - * &xHigherPriorityTaskWoken ); - * - * if( xBytesSent != strlen( pcStringToSend ) ) - * { - * // The string could not be added to the message buffer because there was - * // not enough free space in the buffer. - * } - * - * // If xHigherPriorityTaskWoken was set to pdTRUE inside - * // xMessageBufferSendFromISR() then a task that has a priority above the - * // priority of the currently executing task was unblocked and a context - * // switch should be performed to ensure the ISR returns to the unblocked - * // task. In most FreeRTOS ports this is done by simply passing - * // xHigherPriorityTaskWoken into portYIELD_FROM_ISR(), which will test the - * // variables value, and perform the context switch if necessary. Check the - * // documentation for the port in use for port specific instructions. - * portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); + * // Attempt to send the string to the message buffer. + * xBytesSent = xMessageBufferSendFromISR( xMessageBuffer, + * ( void * ) pcStringToSend, + * strlen( pcStringToSend ), + * &xHigherPriorityTaskWoken ); + * + * if( xBytesSent != strlen( pcStringToSend ) ) + * { + * // The string could not be added to the message buffer because there was + * // not enough free space in the buffer. + * } + * + * // If xHigherPriorityTaskWoken was set to pdTRUE inside + * // xMessageBufferSendFromISR() then a task that has a priority above the + * // priority of the currently executing task was unblocked and a context + * // switch should be performed to ensure the ISR returns to the unblocked + * // task. In most FreeRTOS ports this is done by simply passing + * // xHigherPriorityTaskWoken into portYIELD_FROM_ISR(), which will test the + * // variables value, and perform the context switch if necessary. Check the + * // documentation for the port in use for port specific instructions. + * portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); * } * @endcode + * @cond + * \defgroup xMessageBufferSendFromISR xMessageBufferSendFromISR + * @endcond * \ingroup MessageBufferManagement */ -#define xMessageBufferSendFromISR( xMessageBuffer, pvTxData, xDataLengthBytes, pxHigherPriorityTaskWoken ) xStreamBufferSendFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pvTxData, xDataLengthBytes, pxHigherPriorityTaskWoken ) +#define xMessageBufferSendFromISR( xMessageBuffer, pvTxData, xDataLengthBytes, pxHigherPriorityTaskWoken ) \ + xStreamBufferSendFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pvTxData, xDataLengthBytes, pxHigherPriorityTaskWoken ) /** + * @cond + * message_buffer.h + * + * @code{c} + * size_t xMessageBufferReceive( MessageBufferHandle_t xMessageBuffer, + * void *pvRxData, + * size_t xBufferLengthBytes, + * TickType_t xTicksToWait ); + * @endcode + * @endcond + * * Receives a discrete message from a message buffer. Messages can be of * variable length and are copied out of the buffer. * @@ -434,27 +501,42 @@ typedef void * MessageBufferHandle_t; * size_t xReceivedBytes; * const TickType_t xBlockTime = pdMS_TO_TICKS( 20 ); * - * // Receive the next message from the message buffer. Wait in the Blocked - * // state (so not using any CPU processing time) for a maximum of 100ms for - * // a message to become available. - * xReceivedBytes = xMessageBufferReceive( xMessageBuffer, - * ( void * ) ucRxData, - * sizeof( ucRxData ), - * xBlockTime ); - * - * if( xReceivedBytes > 0 ) - * { - * // A ucRxData contains a message that is xReceivedBytes long. Process - * // the message here.... - * } + * // Receive the next message from the message buffer. Wait in the Blocked + * // state (so not using any CPU processing time) for a maximum of 100ms for + * // a message to become available. + * xReceivedBytes = xMessageBufferReceive( xMessageBuffer, + * ( void * ) ucRxData, + * sizeof( ucRxData ), + * xBlockTime ); + * + * if( xReceivedBytes > 0 ) + * { + * // A ucRxData contains a message that is xReceivedBytes long. Process + * // the message here.... + * } * } * @endcode + * @cond + * \defgroup xMessageBufferReceive xMessageBufferReceive + * @endcond * \ingroup MessageBufferManagement */ -#define xMessageBufferReceive( xMessageBuffer, pvRxData, xBufferLengthBytes, xTicksToWait ) xStreamBufferReceive( ( StreamBufferHandle_t ) xMessageBuffer, pvRxData, xBufferLengthBytes, xTicksToWait ) +#define xMessageBufferReceive( xMessageBuffer, pvRxData, xBufferLengthBytes, xTicksToWait ) \ + xStreamBufferReceive( ( StreamBufferHandle_t ) xMessageBuffer, pvRxData, xBufferLengthBytes, xTicksToWait ) /** + * @cond + * message_buffer.h + * + * @code{c} + * size_t xMessageBufferReceiveFromISR( MessageBufferHandle_t xMessageBuffer, + * void *pvRxData, + * size_t xBufferLengthBytes, + * BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * @endcond + * * An interrupt safe version of the API function that receives a discrete * message from a message buffer. Messages can be of variable length and are * copied out of the buffer. @@ -517,34 +599,46 @@ typedef void * MessageBufferHandle_t; * size_t xReceivedBytes; * BaseType_t xHigherPriorityTaskWoken = pdFALSE; // Initialised to pdFALSE. * - * // Receive the next message from the message buffer. - * xReceivedBytes = xMessageBufferReceiveFromISR( xMessageBuffer, - * ( void * ) ucRxData, - * sizeof( ucRxData ), - * &xHigherPriorityTaskWoken ); - * - * if( xReceivedBytes > 0 ) - * { - * // A ucRxData contains a message that is xReceivedBytes long. Process - * // the message here.... - * } - * - * // If xHigherPriorityTaskWoken was set to pdTRUE inside - * // xMessageBufferReceiveFromISR() then a task that has a priority above the - * // priority of the currently executing task was unblocked and a context - * // switch should be performed to ensure the ISR returns to the unblocked - * // task. In most FreeRTOS ports this is done by simply passing - * // xHigherPriorityTaskWoken into portYIELD_FROM_ISR(), which will test the - * // variables value, and perform the context switch if necessary. Check the - * // documentation for the port in use for port specific instructions. - * portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); + * // Receive the next message from the message buffer. + * xReceivedBytes = xMessageBufferReceiveFromISR( xMessageBuffer, + * ( void * ) ucRxData, + * sizeof( ucRxData ), + * &xHigherPriorityTaskWoken ); + * + * if( xReceivedBytes > 0 ) + * { + * // A ucRxData contains a message that is xReceivedBytes long. Process + * // the message here.... + * } + * + * // If xHigherPriorityTaskWoken was set to pdTRUE inside + * // xMessageBufferReceiveFromISR() then a task that has a priority above the + * // priority of the currently executing task was unblocked and a context + * // switch should be performed to ensure the ISR returns to the unblocked + * // task. In most FreeRTOS ports this is done by simply passing + * // xHigherPriorityTaskWoken into portYIELD_FROM_ISR(), which will test the + * // variables value, and perform the context switch if necessary. Check the + * // documentation for the port in use for port specific instructions. + * portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); * } * @endcode + * @cond + * \defgroup xMessageBufferReceiveFromISR xMessageBufferReceiveFromISR + * @endcond * \ingroup MessageBufferManagement */ -#define xMessageBufferReceiveFromISR( xMessageBuffer, pvRxData, xBufferLengthBytes, pxHigherPriorityTaskWoken ) xStreamBufferReceiveFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pvRxData, xBufferLengthBytes, pxHigherPriorityTaskWoken ) +#define xMessageBufferReceiveFromISR( xMessageBuffer, pvRxData, xBufferLengthBytes, pxHigherPriorityTaskWoken ) \ + xStreamBufferReceiveFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pvRxData, xBufferLengthBytes, pxHigherPriorityTaskWoken ) /** + * @cond + * message_buffer.h + * + * @code{c} + * void vMessageBufferDelete( MessageBufferHandle_t xMessageBuffer ); + * @endcode + * @endcond + * * Deletes a message buffer that was previously created using a call to * xMessageBufferCreate() or xMessageBufferCreateStatic(). If the message * buffer was created using dynamic memory (that is, by xMessageBufferCreate()), @@ -556,9 +650,17 @@ typedef void * MessageBufferHandle_t; * @param xMessageBuffer The handle of the message buffer to be deleted. * */ -#define vMessageBufferDelete( xMessageBuffer ) vStreamBufferDelete( ( StreamBufferHandle_t ) xMessageBuffer ) +#define vMessageBufferDelete( xMessageBuffer ) \ + vStreamBufferDelete( ( StreamBufferHandle_t ) xMessageBuffer ) /** + * @cond + * message_buffer.h + * @code{c} + * BaseType_t xMessageBufferIsFull( MessageBufferHandle_t xMessageBuffer ) ); + * @endcode + * @endcond + * * Tests to see if a message buffer is full. A message buffer is full if it * cannot accept any more messages, of any size, until space is made available * by a message being removed from the message buffer. @@ -568,9 +670,17 @@ typedef void * MessageBufferHandle_t; * @return If the message buffer referenced by xMessageBuffer is full then * pdTRUE is returned. Otherwise pdFALSE is returned. */ -#define xMessageBufferIsFull( xMessageBuffer ) xStreamBufferIsFull( ( StreamBufferHandle_t ) xMessageBuffer ) +#define xMessageBufferIsFull( xMessageBuffer ) \ + xStreamBufferIsFull( ( StreamBufferHandle_t ) xMessageBuffer ) /** + * @cond + * message_buffer.h + * @code{c} + * BaseType_t xMessageBufferIsEmpty( MessageBufferHandle_t xMessageBuffer ) ); + * @endcode + * @endcond + * * Tests to see if a message buffer is empty (does not contain any messages). * * @param xMessageBuffer The handle of the message buffer being queried. @@ -579,9 +689,17 @@ typedef void * MessageBufferHandle_t; * pdTRUE is returned. Otherwise pdFALSE is returned. * */ -#define xMessageBufferIsEmpty( xMessageBuffer ) xStreamBufferIsEmpty( ( StreamBufferHandle_t ) xMessageBuffer ) +#define xMessageBufferIsEmpty( xMessageBuffer ) \ + xStreamBufferIsEmpty( ( StreamBufferHandle_t ) xMessageBuffer ) /** + * @cond + * message_buffer.h + * @code{c} + * BaseType_t xMessageBufferReset( MessageBufferHandle_t xMessageBuffer ); + * @endcode + * @endcond + * * Resets a message buffer to its initial empty state, discarding any message it * contained. * @@ -594,12 +712,23 @@ typedef void * MessageBufferHandle_t; * the message queue to wait for space to become available, or to wait for a * a message to be available, then pdFAIL is returned. * + * @cond + * \defgroup xMessageBufferReset xMessageBufferReset + * @endcond * \ingroup MessageBufferManagement */ -#define xMessageBufferReset( xMessageBuffer ) xStreamBufferReset( ( StreamBufferHandle_t ) xMessageBuffer ) +#define xMessageBufferReset( xMessageBuffer ) \ + xStreamBufferReset( ( StreamBufferHandle_t ) xMessageBuffer ) /** + * @cond + * message_buffer.h + * @code{c} + * size_t xMessageBufferSpaceAvailable( MessageBufferHandle_t xMessageBuffer ) ); + * @endcode + * @endcond + * * Returns the number of bytes of free space in the message buffer. * * @param xMessageBuffer The handle of the message buffer being queried. @@ -611,12 +740,24 @@ typedef void * MessageBufferHandle_t; * architecture, so if xMessageBufferSpacesAvailable() returns 10, then the size * of the largest message that can be written to the message buffer is 6 bytes. * + * @cond + * \defgroup xMessageBufferSpaceAvailable xMessageBufferSpaceAvailable + * @endcond * \ingroup MessageBufferManagement */ -#define xMessageBufferSpaceAvailable( xMessageBuffer ) xStreamBufferSpacesAvailable( ( StreamBufferHandle_t ) xMessageBuffer ) -#define xMessageBufferSpacesAvailable( xMessageBuffer ) xStreamBufferSpacesAvailable( ( StreamBufferHandle_t ) xMessageBuffer ) /* Corrects typo in original macro name. */ +#define xMessageBufferSpaceAvailable( xMessageBuffer ) \ + xStreamBufferSpacesAvailable( ( StreamBufferHandle_t ) xMessageBuffer ) +#define xMessageBufferSpacesAvailable( xMessageBuffer ) \ + xStreamBufferSpacesAvailable( ( StreamBufferHandle_t ) xMessageBuffer ) /* Corrects typo in original macro name. */ /** + * @cond + * message_buffer.h + * @code{c} + * size_t xMessageBufferNextLengthBytes( MessageBufferHandle_t xMessageBuffer ) ); + * @endcode + * @endcond + * * Returns the length (in bytes) of the next message in a message buffer. * Useful if xMessageBufferReceive() returned 0 because the size of the buffer * passed into xMessageBufferReceive() was too small to hold the next message. @@ -626,11 +767,23 @@ typedef void * MessageBufferHandle_t; * @return The length (in bytes) of the next message in the message buffer, or 0 * if the message buffer is empty. * + * @cond + * \defgroup xMessageBufferNextLengthBytes xMessageBufferNextLengthBytes + * @endcond * \ingroup MessageBufferManagement */ -#define xMessageBufferNextLengthBytes( xMessageBuffer ) xStreamBufferNextMessageLengthBytes( ( StreamBufferHandle_t ) xMessageBuffer ) PRIVILEGED_FUNCTION; +#define xMessageBufferNextLengthBytes( xMessageBuffer ) \ + xStreamBufferNextMessageLengthBytes( ( StreamBufferHandle_t ) xMessageBuffer ) PRIVILEGED_FUNCTION; /** + * @cond + * message_buffer.h + * + * @code{c} + * BaseType_t xMessageBufferSendCompletedFromISR( MessageBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * @endcond + * * For advanced users only. * * The sbSEND_COMPLETED() macro is called from within the FreeRTOS APIs when @@ -658,11 +811,23 @@ typedef void * MessageBufferHandle_t; * @return If a task was removed from the Blocked state then pdTRUE is returned. * Otherwise pdFALSE is returned. * + * @cond + * \defgroup xMessageBufferSendCompletedFromISR xMessageBufferSendCompletedFromISR + * @endcond * \ingroup StreamBufferManagement */ -#define xMessageBufferSendCompletedFromISR( xMessageBuffer, pxHigherPriorityTaskWoken ) xStreamBufferSendCompletedFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pxHigherPriorityTaskWoken ) +#define xMessageBufferSendCompletedFromISR( xMessageBuffer, pxHigherPriorityTaskWoken ) \ + xStreamBufferSendCompletedFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pxHigherPriorityTaskWoken ) /** + * @cond + * message_buffer.h + * + * @code{c} + * BaseType_t xMessageBufferReceiveCompletedFromISR( MessageBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * @endcond + * * For advanced users only. * * The sbRECEIVE_COMPLETED() macro is called from within the FreeRTOS APIs when @@ -691,12 +856,18 @@ typedef void * MessageBufferHandle_t; * @return If a task was removed from the Blocked state then pdTRUE is returned. * Otherwise pdFALSE is returned. * + * @cond + * \defgroup xMessageBufferReceiveCompletedFromISR xMessageBufferReceiveCompletedFromISR + * @endcond * \ingroup StreamBufferManagement */ -#define xMessageBufferReceiveCompletedFromISR( xMessageBuffer, pxHigherPriorityTaskWoken ) xStreamBufferReceiveCompletedFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pxHigherPriorityTaskWoken ) +#define xMessageBufferReceiveCompletedFromISR( xMessageBuffer, pxHigherPriorityTaskWoken ) \ + xStreamBufferReceiveCompletedFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pxHigherPriorityTaskWoken ) +/* *INDENT-OFF* */ #if defined( __cplusplus ) -} /* extern "C" */ + } /* extern "C" */ #endif +/* *INDENT-ON* */ -#endif /* !defined( FREERTOS_MESSAGE_BUFFER_H ) */ +#endif /* !defined( FREERTOS_MESSAGE_BUFFER_H ) */ diff --git a/tools/sdk/esp32/include/freertos/include/freertos/mpu_prototypes.h b/tools/sdk/esp32/include/freertos/include/freertos/mpu_prototypes.h new file mode 100644 index 00000000000..ceb74f3e5bc --- /dev/null +++ b/tools/sdk/esp32/include/freertos/include/freertos/mpu_prototypes.h @@ -0,0 +1,257 @@ +/* + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * 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. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +/* + * When the MPU is used the standard (non MPU) API functions are mapped to + * equivalents that start "MPU_", the prototypes for which are defined in this + * header files. This will cause the application code to call the MPU_ version + * which wraps the non-MPU version with privilege promoting then demoting code, + * so the kernel code always runs will full privileges. + */ + + +#ifndef MPU_PROTOTYPES_H +#define MPU_PROTOTYPES_H + +/* MPU versions of tasks.h API functions. */ +BaseType_t MPU_xTaskCreate( TaskFunction_t pxTaskCode, + const char * const pcName, + const uint16_t usStackDepth, + void * const pvParameters, + UBaseType_t uxPriority, + TaskHandle_t * const pxCreatedTask ) FREERTOS_SYSTEM_CALL; +TaskHandle_t MPU_xTaskCreateStatic( 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 ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskDelete( TaskHandle_t xTaskToDelete ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskDelay( const TickType_t xTicksToDelay ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskDelayUntil( TickType_t * const pxPreviousWakeTime, + const TickType_t xTimeIncrement ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskAbortDelay( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxTaskPriorityGet( const TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +eTaskState MPU_eTaskGetState( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskGetInfo( TaskHandle_t xTask, + TaskStatus_t * pxTaskStatus, + BaseType_t xGetFreeStackSpace, + eTaskState eState ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskPrioritySet( TaskHandle_t xTask, + UBaseType_t uxNewPriority ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskSuspend( TaskHandle_t xTaskToSuspend ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskResume( TaskHandle_t xTaskToResume ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskStartScheduler( void ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskSuspendAll( void ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskResumeAll( void ) FREERTOS_SYSTEM_CALL; +TickType_t MPU_xTaskGetTickCount( void ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxTaskGetNumberOfTasks( void ) FREERTOS_SYSTEM_CALL; +char * MPU_pcTaskGetName( TaskHandle_t xTaskToQuery ) FREERTOS_SYSTEM_CALL; +TaskHandle_t MPU_xTaskGetHandle( const char * pcNameToQuery ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +configSTACK_DEPTH_TYPE MPU_uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskSetApplicationTaskTag( TaskHandle_t xTask, + TaskHookFunction_t pxHookFunction ) FREERTOS_SYSTEM_CALL; +TaskHookFunction_t MPU_xTaskGetApplicationTaskTag( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, + BaseType_t xIndex, + void * pvValue ) FREERTOS_SYSTEM_CALL; +void * MPU_pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, + BaseType_t xIndex ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask, + void * pvParameter ) FREERTOS_SYSTEM_CALL; +TaskHandle_t MPU_xTaskGetIdleTaskHandle( void ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, + const UBaseType_t uxArraySize, + uint32_t * const pulTotalRunTime ) FREERTOS_SYSTEM_CALL; +uint32_t MPU_ulTaskGetIdleRunTimeCounter( void ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskList( char * pcWriteBuffer ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskGetRunTimeStats( char * pcWriteBuffer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskGenericNotify( TaskHandle_t xTaskToNotify, + UBaseType_t uxIndexToNotify, + uint32_t ulValue, + eNotifyAction eAction, + uint32_t * pulPreviousNotificationValue ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskGenericNotifyWait( UBaseType_t uxIndexToWaitOn, + uint32_t ulBitsToClearOnEntry, + uint32_t ulBitsToClearOnExit, + uint32_t * pulNotificationValue, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +uint32_t MPU_ulTaskGenericNotifyTake( UBaseType_t uxIndexToWaitOn, + BaseType_t xClearCountOnExit, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskGenericNotifyStateClear( TaskHandle_t xTask, + UBaseType_t uxIndexToClear ) FREERTOS_SYSTEM_CALL; +uint32_t MPU_ulTaskGenericNotifyValueClear( TaskHandle_t xTask, + UBaseType_t uxIndexToClear, + uint32_t ulBitsToClear ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskIncrementTick( void ) FREERTOS_SYSTEM_CALL; +TaskHandle_t MPU_xTaskGetCurrentTaskHandle( void ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, + TickType_t * const pxTicksToWait ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskMissedYield( void ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskGetSchedulerState( void ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) FREERTOS_SYSTEM_CALL; + +/* MPU versions of queue.h API functions. */ +BaseType_t MPU_xQueueGenericSend( QueueHandle_t xQueue, + const void * const pvItemToQueue, + TickType_t xTicksToWait, + const BaseType_t xCopyPosition ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueReceive( QueueHandle_t xQueue, + void * const pvBuffer, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueuePeek( QueueHandle_t xQueue, + void * const pvBuffer, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueSemaphoreTake( QueueHandle_t xQueue, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxQueueMessagesWaiting( const QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxQueueSpacesAvailable( const QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; +void MPU_vQueueDelete( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; +QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType ) FREERTOS_SYSTEM_CALL; +QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType, + StaticQueue_t * pxStaticQueue ) FREERTOS_SYSTEM_CALL; +QueueHandle_t MPU_xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, + const UBaseType_t uxInitialCount ) FREERTOS_SYSTEM_CALL; +QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, + const UBaseType_t uxInitialCount, + StaticQueue_t * pxStaticQueue ) FREERTOS_SYSTEM_CALL; +TaskHandle_t MPU_xQueueGetMutexHolder( QueueHandle_t xSemaphore ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueTakeMutexRecursive( QueueHandle_t xMutex, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueGiveMutexRecursive( QueueHandle_t pxMutex ) FREERTOS_SYSTEM_CALL; +void MPU_vQueueAddToRegistry( QueueHandle_t xQueue, + const char * pcName ) FREERTOS_SYSTEM_CALL; +void MPU_vQueueUnregisterQueue( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; +const char * MPU_pcQueueGetName( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; +QueueHandle_t MPU_xQueueGenericCreate( const UBaseType_t uxQueueLength, + const UBaseType_t uxItemSize, + const uint8_t ucQueueType ) FREERTOS_SYSTEM_CALL; +QueueHandle_t MPU_xQueueGenericCreateStatic( const UBaseType_t uxQueueLength, + const UBaseType_t uxItemSize, + uint8_t * pucQueueStorage, + StaticQueue_t * pxStaticQueue, + const uint8_t ucQueueType ) FREERTOS_SYSTEM_CALL; +QueueSetHandle_t MPU_xQueueCreateSet( const UBaseType_t uxEventQueueLength ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, + QueueSetHandle_t xQueueSet ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, + QueueSetHandle_t xQueueSet ) FREERTOS_SYSTEM_CALL; +QueueSetMemberHandle_t MPU_xQueueSelectFromSet( QueueSetHandle_t xQueueSet, + const TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueGenericReset( QueueHandle_t xQueue, + BaseType_t xNewQueue ) FREERTOS_SYSTEM_CALL; +void MPU_vQueueSetQueueNumber( QueueHandle_t xQueue, + UBaseType_t uxQueueNumber ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxQueueGetQueueNumber( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; +uint8_t MPU_ucQueueGetQueueType( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; + +/* MPU versions of timers.h API functions. */ +TimerHandle_t MPU_xTimerCreate( const char * const pcTimerName, + const TickType_t xTimerPeriodInTicks, + const UBaseType_t uxAutoReload, + void * const pvTimerID, + TimerCallbackFunction_t pxCallbackFunction ) FREERTOS_SYSTEM_CALL; +TimerHandle_t MPU_xTimerCreateStatic( const char * const pcTimerName, + const TickType_t xTimerPeriodInTicks, + const UBaseType_t uxAutoReload, + void * const pvTimerID, + TimerCallbackFunction_t pxCallbackFunction, + StaticTimer_t * pxTimerBuffer ) FREERTOS_SYSTEM_CALL; +void * MPU_pvTimerGetTimerID( const TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL; +void MPU_vTimerSetTimerID( TimerHandle_t xTimer, + void * pvNewID ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTimerIsTimerActive( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL; +TaskHandle_t MPU_xTimerGetTimerDaemonTaskHandle( void ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, + void * pvParameter1, + uint32_t ulParameter2, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +const char * MPU_pcTimerGetName( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL; +void MPU_vTimerSetReloadMode( TimerHandle_t xTimer, + const UBaseType_t uxAutoReload ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxTimerGetReloadMode( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL; +TickType_t MPU_xTimerGetPeriod( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL; +TickType_t MPU_xTimerGetExpiryTime( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTimerCreateTimerTask( void ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTimerGenericCommand( TimerHandle_t xTimer, + const BaseType_t xCommandID, + const TickType_t xOptionalValue, + BaseType_t * const pxHigherPriorityTaskWoken, + const TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; + +/* MPU versions of event_group.h API functions. */ +EventGroupHandle_t MPU_xEventGroupCreate( void ) FREERTOS_SYSTEM_CALL; +EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t * pxEventGroupBuffer ) FREERTOS_SYSTEM_CALL; +EventBits_t MPU_xEventGroupWaitBits( EventGroupHandle_t xEventGroup, + const EventBits_t uxBitsToWaitFor, + const BaseType_t xClearOnExit, + const BaseType_t xWaitForAllBits, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +EventBits_t MPU_xEventGroupClearBits( EventGroupHandle_t xEventGroup, + const EventBits_t uxBitsToClear ) FREERTOS_SYSTEM_CALL; +EventBits_t MPU_xEventGroupSetBits( EventGroupHandle_t xEventGroup, + const EventBits_t uxBitsToSet ) FREERTOS_SYSTEM_CALL; +EventBits_t MPU_xEventGroupSync( EventGroupHandle_t xEventGroup, + const EventBits_t uxBitsToSet, + const EventBits_t uxBitsToWaitFor, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +void MPU_vEventGroupDelete( EventGroupHandle_t xEventGroup ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxEventGroupGetNumber( void * xEventGroup ) FREERTOS_SYSTEM_CALL; + +/* MPU versions of message/stream_buffer.h API functions. */ +size_t MPU_xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, + const void * pvTxData, + size_t xDataLengthBytes, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +size_t MPU_xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer, + void * pvRxData, + size_t xBufferLengthBytes, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +size_t MPU_xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +void MPU_vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +size_t MPU_xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +size_t MPU_xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, + size_t xTriggerLevel ) FREERTOS_SYSTEM_CALL; +StreamBufferHandle_t MPU_xStreamBufferGenericCreate( size_t xBufferSizeBytes, + size_t xTriggerLevelBytes, + BaseType_t xIsMessageBuffer ) FREERTOS_SYSTEM_CALL; +StreamBufferHandle_t MPU_xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes, + size_t xTriggerLevelBytes, + BaseType_t xIsMessageBuffer, + uint8_t * const pucStreamBufferStorageArea, + StaticStreamBuffer_t * const pxStaticStreamBuffer ) FREERTOS_SYSTEM_CALL; + + + +#endif /* MPU_PROTOTYPES_H */ diff --git a/tools/sdk/esp32/include/freertos/include/freertos/mpu_wrappers.h b/tools/sdk/esp32/include/freertos/include/freertos/mpu_wrappers.h index 7cbad5da080..c02dcd0c41e 100644 --- a/tools/sdk/esp32/include/freertos/include/freertos/mpu_wrappers.h +++ b/tools/sdk/esp32/include/freertos/include/freertos/mpu_wrappers.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,166 +19,165 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ #ifndef MPU_WRAPPERS_H #define MPU_WRAPPERS_H /* This file redefines API functions to be called through a wrapper macro, but -only for ports that are using the MPU. */ + * only for ports that are using the MPU. */ #if portUSING_MPU_WRAPPERS - /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE will be defined when this file is - included from queue.c or task.c to prevent it from having an effect within - those files. */ - #ifndef MPU_WRAPPERS_INCLUDED_FROM_API_FILE - - /* - * Map standard (non MPU) API functions to equivalents that start - * "MPU_". This will cause the application code to call the MPU_ - * version, which wraps the non-MPU version with privilege promoting - * then demoting code, so the kernel code always runs will full - * privileges. - */ - - /* Map standard tasks.h API functions to the MPU equivalents. */ - #define xTaskCreate MPU_xTaskCreate - #define xTaskCreateStatic MPU_xTaskCreateStatic - #define xTaskCreateRestricted MPU_xTaskCreateRestricted - #define vTaskAllocateMPURegions MPU_vTaskAllocateMPURegions - #define vTaskDelete MPU_vTaskDelete - #define vTaskDelay MPU_vTaskDelay - #define vTaskDelayUntil MPU_vTaskDelayUntil - #define xTaskAbortDelay MPU_xTaskAbortDelay - #define uxTaskPriorityGet MPU_uxTaskPriorityGet - #define eTaskGetState MPU_eTaskGetState - #define vTaskGetInfo MPU_vTaskGetInfo - #define vTaskPrioritySet MPU_vTaskPrioritySet - #define vTaskSuspend MPU_vTaskSuspend - #define vTaskResume MPU_vTaskResume - #define vTaskSuspendAll MPU_vTaskSuspendAll - #define xTaskResumeAll MPU_xTaskResumeAll - #define xTaskGetTickCount MPU_xTaskGetTickCount - #define uxTaskGetNumberOfTasks MPU_uxTaskGetNumberOfTasks - #define pcTaskGetName MPU_pcTaskGetName - #define xTaskGetHandle MPU_xTaskGetHandle - #define uxTaskGetStackHighWaterMark MPU_uxTaskGetStackHighWaterMark - #define uxTaskGetStackHighWaterMark2 MPU_uxTaskGetStackHighWaterMark2 - #define vTaskSetApplicationTaskTag MPU_vTaskSetApplicationTaskTag - #define xTaskGetApplicationTaskTag MPU_xTaskGetApplicationTaskTag - // #define vTaskSetThreadLocalStoragePointer MPU_vTaskSetThreadLocalStoragePointer - // #define pvTaskGetThreadLocalStoragePointer MPU_pvTaskGetThreadLocalStoragePointer - #define xTaskCallApplicationTaskHook MPU_xTaskCallApplicationTaskHook - #define xTaskGetIdleTaskHandle MPU_xTaskGetIdleTaskHandle - #define uxTaskGetSystemState MPU_uxTaskGetSystemState - #define vTaskList MPU_vTaskList - #define vTaskGetRunTimeStats MPU_vTaskGetRunTimeStats - #define ulTaskGetIdleRunTimeCounter MPU_ulTaskGetIdleRunTimeCounter - #define xTaskGenericNotify MPU_xTaskGenericNotify - #define xTaskNotifyWait MPU_xTaskNotifyWait - #define ulTaskNotifyTake MPU_ulTaskNotifyTake - #define xTaskNotifyStateClear MPU_xTaskNotifyStateClear - #define xTaskCatchUpTicks MPU_xTaskCatchUpTicks - - #define xTaskGetCurrentTaskHandle MPU_xTaskGetCurrentTaskHandle - #define vTaskSetTimeOutState MPU_vTaskSetTimeOutState - #define xTaskCheckForTimeOut MPU_xTaskCheckForTimeOut - #define xTaskGetSchedulerState MPU_xTaskGetSchedulerState - - /* Map standard queue.h API functions to the MPU equivalents. */ - #define xQueueGenericSend MPU_xQueueGenericSend - #define xQueueReceive MPU_xQueueReceive - #define xQueuePeek MPU_xQueuePeek - #define xQueueSemaphoreTake MPU_xQueueSemaphoreTake - #define uxQueueMessagesWaiting MPU_uxQueueMessagesWaiting - #define uxQueueSpacesAvailable MPU_uxQueueSpacesAvailable - #define vQueueDelete MPU_vQueueDelete - #define xQueueCreateMutex MPU_xQueueCreateMutex - #define xQueueCreateMutexStatic MPU_xQueueCreateMutexStatic - #define xQueueCreateCountingSemaphore MPU_xQueueCreateCountingSemaphore - #define xQueueCreateCountingSemaphoreStatic MPU_xQueueCreateCountingSemaphoreStatic - #define xQueueGetMutexHolder MPU_xQueueGetMutexHolder - #define xQueueTakeMutexRecursive MPU_xQueueTakeMutexRecursive - #define xQueueGiveMutexRecursive MPU_xQueueGiveMutexRecursive - #define xQueueGenericCreate MPU_xQueueGenericCreate - #define xQueueGenericCreateStatic MPU_xQueueGenericCreateStatic - #define xQueueCreateSet MPU_xQueueCreateSet - #define xQueueAddToSet MPU_xQueueAddToSet - #define xQueueRemoveFromSet MPU_xQueueRemoveFromSet - #define xQueueSelectFromSet MPU_xQueueSelectFromSet - #define xQueueGenericReset MPU_xQueueGenericReset - - #if( configQUEUE_REGISTRY_SIZE > 0 ) - #define vQueueAddToRegistry MPU_vQueueAddToRegistry - #define vQueueUnregisterQueue MPU_vQueueUnregisterQueue - #define pcQueueGetName MPU_pcQueueGetName - #endif - - /* Map standard timer.h API functions to the MPU equivalents. */ - #define xTimerCreate MPU_xTimerCreate - #define xTimerCreateStatic MPU_xTimerCreateStatic - #define pvTimerGetTimerID MPU_pvTimerGetTimerID - #define vTimerSetTimerID MPU_vTimerSetTimerID - #define xTimerIsTimerActive MPU_xTimerIsTimerActive - #define xTimerGetTimerDaemonTaskHandle MPU_xTimerGetTimerDaemonTaskHandle - #define xTimerPendFunctionCall MPU_xTimerPendFunctionCall - #define pcTimerGetName MPU_pcTimerGetName - #define vTimerSetReloadMode MPU_vTimerSetReloadMode - #define xTimerGetPeriod MPU_xTimerGetPeriod - #define xTimerGetExpiryTime MPU_xTimerGetExpiryTime - #define xTimerGenericCommand MPU_xTimerGenericCommand - - /* Map standard event_group.h API functions to the MPU equivalents. */ - #define xEventGroupCreate MPU_xEventGroupCreate - #define xEventGroupCreateStatic MPU_xEventGroupCreateStatic - #define xEventGroupWaitBits MPU_xEventGroupWaitBits - #define xEventGroupClearBits MPU_xEventGroupClearBits - #define xEventGroupSetBits MPU_xEventGroupSetBits - #define xEventGroupSync MPU_xEventGroupSync - #define vEventGroupDelete MPU_vEventGroupDelete - - /* Map standard message/stream_buffer.h API functions to the MPU - equivalents. */ - #define xStreamBufferSend MPU_xStreamBufferSend - #define xStreamBufferReceive MPU_xStreamBufferReceive - #define xStreamBufferNextMessageLengthBytes MPU_xStreamBufferNextMessageLengthBytes - #define vStreamBufferDelete MPU_vStreamBufferDelete - #define xStreamBufferIsFull MPU_xStreamBufferIsFull - #define xStreamBufferIsEmpty MPU_xStreamBufferIsEmpty - #define xStreamBufferReset MPU_xStreamBufferReset - #define xStreamBufferSpacesAvailable MPU_xStreamBufferSpacesAvailable - #define xStreamBufferBytesAvailable MPU_xStreamBufferBytesAvailable - #define xStreamBufferSetTriggerLevel MPU_xStreamBufferSetTriggerLevel - #define xStreamBufferGenericCreate MPU_xStreamBufferGenericCreate - #define xStreamBufferGenericCreateStatic MPU_xStreamBufferGenericCreateStatic - - - /* Remove the privileged function macro, but keep the PRIVILEGED_DATA - macro so applications can place data in privileged access sections - (useful when using statically allocated objects). */ - #define PRIVILEGED_FUNCTION - #define PRIVILEGED_DATA __attribute__((section("privileged_data"))) - #define FREERTOS_SYSTEM_CALL - - #else /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */ - - /* Ensure API functions go in the privileged execution section. */ - #define PRIVILEGED_FUNCTION __attribute__((section("privileged_functions"))) - #define PRIVILEGED_DATA __attribute__((section("privileged_data"))) - #define FREERTOS_SYSTEM_CALL __attribute__((section( "freertos_system_calls"))) - - #endif /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */ +/* MPU_WRAPPERS_INCLUDED_FROM_API_FILE will be defined when this file is + * included from queue.c or task.c to prevent it from having an effect within + * those files. */ + #ifndef MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/* + * Map standard (non MPU) API functions to equivalents that start + * "MPU_". This will cause the application code to call the MPU_ + * version, which wraps the non-MPU version with privilege promoting + * then demoting code, so the kernel code always runs will full + * privileges. + */ + +/* Map standard tasks.h API functions to the MPU equivalents. */ + #define xTaskCreate MPU_xTaskCreate + #define xTaskCreateStatic MPU_xTaskCreateStatic + #define xTaskCreateRestricted MPU_xTaskCreateRestricted + #define vTaskAllocateMPURegions MPU_vTaskAllocateMPURegions + #define vTaskDelete MPU_vTaskDelete + #define vTaskDelay MPU_vTaskDelay + #define vTaskDelayUntil MPU_vTaskDelayUntil + #define xTaskAbortDelay MPU_xTaskAbortDelay + #define uxTaskPriorityGet MPU_uxTaskPriorityGet + #define eTaskGetState MPU_eTaskGetState + #define vTaskGetInfo MPU_vTaskGetInfo + #define vTaskPrioritySet MPU_vTaskPrioritySet + #define vTaskSuspend MPU_vTaskSuspend + #define vTaskResume MPU_vTaskResume + #define vTaskSuspendAll MPU_vTaskSuspendAll + #define xTaskResumeAll MPU_xTaskResumeAll + #define xTaskGetTickCount MPU_xTaskGetTickCount + #define uxTaskGetNumberOfTasks MPU_uxTaskGetNumberOfTasks + #define pcTaskGetName MPU_pcTaskGetName + #define xTaskGetHandle MPU_xTaskGetHandle + #define uxTaskGetStackHighWaterMark MPU_uxTaskGetStackHighWaterMark + #define uxTaskGetStackHighWaterMark2 MPU_uxTaskGetStackHighWaterMark2 + #define vTaskSetApplicationTaskTag MPU_vTaskSetApplicationTaskTag + #define xTaskGetApplicationTaskTag MPU_xTaskGetApplicationTaskTag + // #define vTaskSetThreadLocalStoragePointer MPU_vTaskSetThreadLocalStoragePointer + // #define pvTaskGetThreadLocalStoragePointer MPU_pvTaskGetThreadLocalStoragePointer + #define xTaskCallApplicationTaskHook MPU_xTaskCallApplicationTaskHook + #define xTaskGetIdleTaskHandle MPU_xTaskGetIdleTaskHandle + #define uxTaskGetSystemState MPU_uxTaskGetSystemState + #define vTaskList MPU_vTaskList + #define vTaskGetRunTimeStats MPU_vTaskGetRunTimeStats + #define ulTaskGetIdleRunTimeCounter MPU_ulTaskGetIdleRunTimeCounter + #define xTaskGenericNotify MPU_xTaskGenericNotify + #define xTaskNotifyWait MPU_xTaskNotifyWait + #define ulTaskNotifyTake MPU_ulTaskNotifyTake + #define xTaskNotifyStateClear MPU_xTaskNotifyStateClear + #define xTaskCatchUpTicks MPU_xTaskCatchUpTicks + + #define xTaskGetCurrentTaskHandle MPU_xTaskGetCurrentTaskHandle + #define vTaskSetTimeOutState MPU_vTaskSetTimeOutState + #define xTaskCheckForTimeOut MPU_xTaskCheckForTimeOut + #define xTaskGetSchedulerState MPU_xTaskGetSchedulerState + + /* Map standard queue.h API functions to the MPU equivalents. */ + #define xQueueGenericSend MPU_xQueueGenericSend + #define xQueueReceive MPU_xQueueReceive + #define xQueuePeek MPU_xQueuePeek + #define xQueueSemaphoreTake MPU_xQueueSemaphoreTake + #define uxQueueMessagesWaiting MPU_uxQueueMessagesWaiting + #define uxQueueSpacesAvailable MPU_uxQueueSpacesAvailable + #define vQueueDelete MPU_vQueueDelete + #define xQueueCreateMutex MPU_xQueueCreateMutex + #define xQueueCreateMutexStatic MPU_xQueueCreateMutexStatic + #define xQueueCreateCountingSemaphore MPU_xQueueCreateCountingSemaphore + #define xQueueCreateCountingSemaphoreStatic MPU_xQueueCreateCountingSemaphoreStatic + #define xQueueGetMutexHolder MPU_xQueueGetMutexHolder + #define xQueueTakeMutexRecursive MPU_xQueueTakeMutexRecursive + #define xQueueGiveMutexRecursive MPU_xQueueGiveMutexRecursive + #define xQueueGenericCreate MPU_xQueueGenericCreate + #define xQueueGenericCreateStatic MPU_xQueueGenericCreateStatic + #define xQueueCreateSet MPU_xQueueCreateSet + #define xQueueAddToSet MPU_xQueueAddToSet + #define xQueueRemoveFromSet MPU_xQueueRemoveFromSet + #define xQueueSelectFromSet MPU_xQueueSelectFromSet + #define xQueueGenericReset MPU_xQueueGenericReset + + #if ( configQUEUE_REGISTRY_SIZE > 0 ) + #define vQueueAddToRegistry MPU_vQueueAddToRegistry + #define vQueueUnregisterQueue MPU_vQueueUnregisterQueue + #define pcQueueGetName MPU_pcQueueGetName + #endif + +/* Map standard timer.h API functions to the MPU equivalents. */ + #define xTimerCreate MPU_xTimerCreate + #define xTimerCreateStatic MPU_xTimerCreateStatic + #define pvTimerGetTimerID MPU_pvTimerGetTimerID + #define vTimerSetTimerID MPU_vTimerSetTimerID + #define xTimerIsTimerActive MPU_xTimerIsTimerActive + #define xTimerGetTimerDaemonTaskHandle MPU_xTimerGetTimerDaemonTaskHandle + #define xTimerPendFunctionCall MPU_xTimerPendFunctionCall + #define pcTimerGetName MPU_pcTimerGetName + #define vTimerSetReloadMode MPU_vTimerSetReloadMode + #define xTimerGetPeriod MPU_xTimerGetPeriod + #define xTimerGetExpiryTime MPU_xTimerGetExpiryTime + #define xTimerGenericCommand MPU_xTimerGenericCommand + +/* Map standard event_group.h API functions to the MPU equivalents. */ + #define xEventGroupCreate MPU_xEventGroupCreate + #define xEventGroupCreateStatic MPU_xEventGroupCreateStatic + #define xEventGroupWaitBits MPU_xEventGroupWaitBits + #define xEventGroupClearBits MPU_xEventGroupClearBits + #define xEventGroupSetBits MPU_xEventGroupSetBits + #define xEventGroupSync MPU_xEventGroupSync + #define vEventGroupDelete MPU_vEventGroupDelete + +/* Map standard message/stream_buffer.h API functions to the MPU + * equivalents. */ + #define xStreamBufferSend MPU_xStreamBufferSend + #define xStreamBufferReceive MPU_xStreamBufferReceive + #define xStreamBufferNextMessageLengthBytes MPU_xStreamBufferNextMessageLengthBytes + #define vStreamBufferDelete MPU_vStreamBufferDelete + #define xStreamBufferIsFull MPU_xStreamBufferIsFull + #define xStreamBufferIsEmpty MPU_xStreamBufferIsEmpty + #define xStreamBufferReset MPU_xStreamBufferReset + #define xStreamBufferSpacesAvailable MPU_xStreamBufferSpacesAvailable + #define xStreamBufferBytesAvailable MPU_xStreamBufferBytesAvailable + #define xStreamBufferSetTriggerLevel MPU_xStreamBufferSetTriggerLevel + #define xStreamBufferGenericCreate MPU_xStreamBufferGenericCreate + #define xStreamBufferGenericCreateStatic MPU_xStreamBufferGenericCreateStatic + + +/* Remove the privileged function macro, but keep the PRIVILEGED_DATA + * macro so applications can place data in privileged access sections + * (useful when using statically allocated objects). */ + #define PRIVILEGED_FUNCTION + #define PRIVILEGED_DATA __attribute__( ( section( "privileged_data" ) ) ) + #define FREERTOS_SYSTEM_CALL + + #else /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */ + +/* Ensure API functions go in the privileged execution section. */ + #define PRIVILEGED_FUNCTION __attribute__( ( section( "privileged_functions" ) ) ) + #define PRIVILEGED_DATA __attribute__( ( section( "privileged_data" ) ) ) + #define FREERTOS_SYSTEM_CALL __attribute__( ( section( "freertos_system_calls" ) ) ) + + #endif /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */ #else /* portUSING_MPU_WRAPPERS */ - #define PRIVILEGED_FUNCTION - #define PRIVILEGED_DATA - #define FREERTOS_SYSTEM_CALL - #define portUSING_MPU_WRAPPERS 0 + #define PRIVILEGED_FUNCTION + #define PRIVILEGED_DATA + #define FREERTOS_SYSTEM_CALL + #define portUSING_MPU_WRAPPERS 0 #endif /* portUSING_MPU_WRAPPERS */ diff --git a/tools/sdk/esp32/include/freertos/include/freertos/portable.h b/tools/sdk/esp32/include/freertos/include/freertos/portable.h index 0c39bb9f6d8..acc337cb968 100644 --- a/tools/sdk/esp32/include/freertos/include/freertos/portable.h +++ b/tools/sdk/esp32/include/freertos/include/freertos/portable.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ /*----------------------------------------------------------- @@ -33,68 +32,70 @@ #define PORTABLE_H /* Each FreeRTOS port has a unique portmacro.h header file. Originally a -pre-processor definition was used to ensure the pre-processor found the correct -portmacro.h file for the port being used. That scheme was deprecated in favour -of setting the compiler's include path such that it found the correct -portmacro.h file - removing the need for the constant and allowing the -portmacro.h file to be located anywhere in relation to the port being used. -Purely for reasons of backward compatibility the old method is still valid, but -to make it clear that new projects should not use it, support for the port -specific constants has been moved into the deprecated_definitions.h header -file. */ + * pre-processor definition was used to ensure the pre-processor found the correct + * portmacro.h file for the port being used. That scheme was deprecated in favour + * of setting the compiler's include path such that it found the correct + * portmacro.h file - removing the need for the constant and allowing the + * portmacro.h file to be located anywhere in relation to the port being used. + * Purely for reasons of backward compatibility the old method is still valid, but + * to make it clear that new projects should not use it, support for the port + * specific constants has been moved into the deprecated_definitions.h header + * file. */ #include "deprecated_definitions.h" /* If portENTER_CRITICAL is not defined then including deprecated_definitions.h -did not result in a portmacro.h header file being included - and it should be -included here. In this case the path to the correct portmacro.h header file -must be set in the compiler's include path. */ + * did not result in a portmacro.h header file being included - and it should be + * included here. In this case the path to the correct portmacro.h header file + * must be set in the compiler's include path. */ #ifndef portENTER_CRITICAL - #include "freertos/portmacro.h" + #include "freertos/portmacro.h" #endif #if portBYTE_ALIGNMENT == 32 - #define portBYTE_ALIGNMENT_MASK ( 0x001f ) + #define portBYTE_ALIGNMENT_MASK ( 0x001f ) #endif #if portBYTE_ALIGNMENT == 16 - #define portBYTE_ALIGNMENT_MASK ( 0x000f ) + #define portBYTE_ALIGNMENT_MASK ( 0x000f ) #endif #if portBYTE_ALIGNMENT == 8 - #define portBYTE_ALIGNMENT_MASK ( 0x0007 ) + #define portBYTE_ALIGNMENT_MASK ( 0x0007 ) #endif #if portBYTE_ALIGNMENT == 4 - #define portBYTE_ALIGNMENT_MASK ( 0x0003 ) + #define portBYTE_ALIGNMENT_MASK ( 0x0003 ) #endif #if portBYTE_ALIGNMENT == 2 - #define portBYTE_ALIGNMENT_MASK ( 0x0001 ) + #define portBYTE_ALIGNMENT_MASK ( 0x0001 ) #endif #if portBYTE_ALIGNMENT == 1 - #define portBYTE_ALIGNMENT_MASK ( 0x0000 ) + #define portBYTE_ALIGNMENT_MASK ( 0x0000 ) #endif #ifndef portBYTE_ALIGNMENT_MASK - #error "Invalid portBYTE_ALIGNMENT definition" + #error "Invalid portBYTE_ALIGNMENT definition" #endif #ifndef portNUM_CONFIGURABLE_REGIONS - #define portNUM_CONFIGURABLE_REGIONS 1 + #define portNUM_CONFIGURABLE_REGIONS 1 #endif #ifndef portHAS_STACK_OVERFLOW_CHECKING - #define portHAS_STACK_OVERFLOW_CHECKING 0 + #define portHAS_STACK_OVERFLOW_CHECKING 0 #endif #ifndef portARCH_NAME - #define portARCH_NAME NULL + #define portARCH_NAME NULL #endif +/* *INDENT-OFF* */ #ifdef __cplusplus -extern "C" { + extern "C" { #endif +/* *INDENT-ON* */ #include "mpu_wrappers.h" @@ -104,40 +105,52 @@ extern "C" { * the order that the port expects to find them. * */ -#if( portUSING_MPU_WRAPPERS == 1 ) - #if( portHAS_STACK_OVERFLOW_CHECKING == 1 ) - StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; - #else - StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; - #endif -#else - #if( portHAS_STACK_OVERFLOW_CHECKING == 1 ) - StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters ) PRIVILEGED_FUNCTION; - #else - StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) PRIVILEGED_FUNCTION; - #endif +#if ( portUSING_MPU_WRAPPERS == 1 ) + #if ( portHAS_STACK_OVERFLOW_CHECKING == 1 ) + StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, + StackType_t * pxEndOfStack, + TaskFunction_t pxCode, + void * pvParameters, + BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; + #else + StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, + TaskFunction_t pxCode, + void * pvParameters, + BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; + #endif +#else /* if ( portUSING_MPU_WRAPPERS == 1 ) */ + #if ( portHAS_STACK_OVERFLOW_CHECKING == 1 ) + StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, + StackType_t * pxEndOfStack, + TaskFunction_t pxCode, + void * pvParameters ) PRIVILEGED_FUNCTION; + #else + StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, + TaskFunction_t pxCode, + void * pvParameters ) PRIVILEGED_FUNCTION; + #endif #endif #ifdef configUSE_FREERTOS_PROVIDED_HEAP /* Used by heap_5.c to define the start address and size of each memory region -that together comprise the total FreeRTOS heap space. */ + * that together comprise the total FreeRTOS heap space. */ typedef struct HeapRegion { - uint8_t *pucStartAddress; - size_t xSizeInBytes; + uint8_t * pucStartAddress; + size_t xSizeInBytes; } HeapRegion_t; /* Used to pass information about the heap out of vPortGetHeapStats(). */ typedef struct xHeapStats { - size_t xAvailableHeapSpaceInBytes; /* The total heap size currently available - this is the sum of all the free blocks, not the largest block that can be allocated. */ - size_t xSizeOfLargestFreeBlockInBytes; /* The maximum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */ - size_t xSizeOfSmallestFreeBlockInBytes; /* The minimum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */ - size_t xNumberOfFreeBlocks; /* The number of free memory blocks within the heap at the time vPortGetHeapStats() is called. */ - size_t xMinimumEverFreeBytesRemaining; /* The minimum amount of total free memory (sum of all free blocks) there has been in the heap since the system booted. */ - size_t xNumberOfSuccessfulAllocations; /* The number of calls to pvPortMalloc() that have returned a valid memory block. */ - size_t xNumberOfSuccessfulFrees; /* The number of calls to vPortFree() that has successfully freed a block of memory. */ + size_t xAvailableHeapSpaceInBytes; /* The total heap size currently available - this is the sum of all the free blocks, not the largest block that can be allocated. */ + size_t xSizeOfLargestFreeBlockInBytes; /* The maximum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */ + size_t xSizeOfSmallestFreeBlockInBytes; /* The minimum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */ + size_t xNumberOfFreeBlocks; /* The number of free memory blocks within the heap at the time vPortGetHeapStats() is called. */ + size_t xMinimumEverFreeBytesRemaining; /* The minimum amount of total free memory (sum of all free blocks) there has been in the heap since the system booted. */ + size_t xNumberOfSuccessfulAllocations; /* The number of calls to pvPortMalloc() that have returned a valid memory block. */ + size_t xNumberOfSuccessfulFrees; /* The number of calls to vPortFree() that has successfully freed a block of memory. */ } HeapStats_t; /* @@ -157,16 +170,24 @@ void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) PRIVILEG * Returns a HeapStats_t structure filled with information about the current * heap state. */ -void vPortGetHeapStats( HeapStats_t *pxHeapStats ); +void vPortGetHeapStats( HeapStats_t * pxHeapStats ); + /* * Map to the memory management routines required for the port. */ -void *pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION; -void vPortFree( void *pv ) PRIVILEGED_FUNCTION; +void * pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION; +void vPortFree( void * pv ) PRIVILEGED_FUNCTION; void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION; size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION; size_t xPortGetMinimumEverFreeHeapSize( void ) PRIVILEGED_FUNCTION; +#if( configSTACK_ALLOCATION_FROM_SEPARATE_HEAP == 1 ) + void *pvPortMallocStack( size_t xSize ) PRIVILEGED_FUNCTION; + void vPortFreeStack( void *pv ) PRIVILEGED_FUNCTION; +#else + #define pvPortMallocStack pvPortMalloc + #define vPortFreeStack vPortFree +#endif #else // configUSE_FREERTOS_PROVIDED_HEAP /* @@ -196,8 +217,25 @@ BaseType_t xPortStartScheduler( void ) PRIVILEGED_FUNCTION; */ void vPortEndScheduler( void ) PRIVILEGED_FUNCTION; +/* + * The structures and methods of manipulating the MPU are contained within the + * port layer. + * + * Fills the xMPUSettings structure with the memory region information + * contained in xRegions. + */ +#if ( portUSING_MPU_WRAPPERS == 1 ) + struct xMEMORY_REGION; + void vPortStoreTaskMPUSettings( xMPU_SETTINGS * xMPUSettings, + const struct xMEMORY_REGION * const xRegions, + StackType_t * pxBottomOfStack, + uint32_t ulStackDepth ) PRIVILEGED_FUNCTION; +#endif + +/* *INDENT-OFF* */ #ifdef __cplusplus -} + } #endif +/* *INDENT-ON* */ #endif /* PORTABLE_H */ diff --git a/tools/sdk/esp32/include/freertos/include/freertos/projdefs.h b/tools/sdk/esp32/include/freertos/include/freertos/projdefs.h index ce647fb6fb1..ec8022ca0b0 100644 --- a/tools/sdk/esp32/include/freertos/include/freertos/projdefs.h +++ b/tools/sdk/esp32/include/freertos/include/freertos/projdefs.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ #ifndef PROJDEFS_H @@ -32,95 +31,95 @@ * Defines the prototype to which task functions must conform. Defined in this * file to ensure the type is known before portable.h is included. */ -typedef void (*TaskFunction_t)( void * ); +typedef void (* TaskFunction_t)( void * ); /* Converts a time in milliseconds to a time in ticks. This macro can be -overridden by a macro of the same name defined in FreeRTOSConfig.h in case the -definition here is not suitable for your application. */ + * overridden by a macro of the same name defined in FreeRTOSConfig.h in case the + * definition here is not suitable for your application. */ #ifndef pdMS_TO_TICKS - #define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000 ) ) + #define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000U ) ) #endif - +#ifdef ESP_PLATFORM #ifndef pdTICKS_TO_MS - #define pdTICKS_TO_MS( xTicks ) ( ( uint32_t ) ( xTicks ) * 1000 / configTICK_RATE_HZ ) + #define pdTICKS_TO_MS( xTicks ) ( ( uint32_t ) ( xTicks ) * 1000 / configTICK_RATE_HZ ) #endif +#endif // ESP_PLATFORM +#define pdFALSE ( ( BaseType_t ) 0 ) +#define pdTRUE ( ( BaseType_t ) 1 ) -#define pdFALSE ( ( BaseType_t ) 0 ) -#define pdTRUE ( ( BaseType_t ) 1 ) - -#define pdPASS ( pdTRUE ) -#define pdFAIL ( pdFALSE ) -#define errQUEUE_EMPTY ( ( BaseType_t ) 0 ) -#define errQUEUE_FULL ( ( BaseType_t ) 0 ) +#define pdPASS ( pdTRUE ) +#define pdFAIL ( pdFALSE ) +#define errQUEUE_EMPTY ( ( BaseType_t ) 0 ) +#define errQUEUE_FULL ( ( BaseType_t ) 0 ) /* FreeRTOS error definitions. */ -#define errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY ( -1 ) -#define errQUEUE_BLOCKED ( -4 ) -#define errQUEUE_YIELD ( -5 ) +#define errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY ( -1 ) +#define errQUEUE_BLOCKED ( -4 ) +#define errQUEUE_YIELD ( -5 ) /* Macros used for basic data corruption checks. */ #ifndef configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES - #define configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 0 + #define configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 0 #endif -#if( configUSE_16_BIT_TICKS == 1 ) - #define pdINTEGRITY_CHECK_VALUE 0x5a5a +#if ( configUSE_16_BIT_TICKS == 1 ) + #define pdINTEGRITY_CHECK_VALUE 0x5a5a #else - #define pdINTEGRITY_CHECK_VALUE 0x5a5a5a5aUL + #define pdINTEGRITY_CHECK_VALUE 0x5a5a5a5aUL #endif /* The following errno values are used by FreeRTOS+ components, not FreeRTOS -itself. */ -#define pdFREERTOS_ERRNO_NONE 0 /* No errors */ -#define pdFREERTOS_ERRNO_ENOENT 2 /* No such file or directory */ -#define pdFREERTOS_ERRNO_EINTR 4 /* Interrupted system call */ -#define pdFREERTOS_ERRNO_EIO 5 /* I/O error */ -#define pdFREERTOS_ERRNO_ENXIO 6 /* No such device or address */ -#define pdFREERTOS_ERRNO_EBADF 9 /* Bad file number */ -#define pdFREERTOS_ERRNO_EAGAIN 11 /* No more processes */ -#define pdFREERTOS_ERRNO_EWOULDBLOCK 11 /* Operation would block */ -#define pdFREERTOS_ERRNO_ENOMEM 12 /* Not enough memory */ -#define pdFREERTOS_ERRNO_EACCES 13 /* Permission denied */ -#define pdFREERTOS_ERRNO_EFAULT 14 /* Bad address */ -#define pdFREERTOS_ERRNO_EBUSY 16 /* Mount device busy */ -#define pdFREERTOS_ERRNO_EEXIST 17 /* File exists */ -#define pdFREERTOS_ERRNO_EXDEV 18 /* Cross-device link */ -#define pdFREERTOS_ERRNO_ENODEV 19 /* No such device */ -#define pdFREERTOS_ERRNO_ENOTDIR 20 /* Not a directory */ -#define pdFREERTOS_ERRNO_EISDIR 21 /* Is a directory */ -#define pdFREERTOS_ERRNO_EINVAL 22 /* Invalid argument */ -#define pdFREERTOS_ERRNO_ENOSPC 28 /* No space left on device */ -#define pdFREERTOS_ERRNO_ESPIPE 29 /* Illegal seek */ -#define pdFREERTOS_ERRNO_EROFS 30 /* Read only file system */ -#define pdFREERTOS_ERRNO_EUNATCH 42 /* Protocol driver not attached */ -#define pdFREERTOS_ERRNO_EBADE 50 /* Invalid exchange */ -#define pdFREERTOS_ERRNO_EFTYPE 79 /* Inappropriate file type or format */ -#define pdFREERTOS_ERRNO_ENMFILE 89 /* No more files */ -#define pdFREERTOS_ERRNO_ENOTEMPTY 90 /* Directory not empty */ -#define pdFREERTOS_ERRNO_ENAMETOOLONG 91 /* File or path name too long */ -#define pdFREERTOS_ERRNO_EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ -#define pdFREERTOS_ERRNO_ENOBUFS 105 /* No buffer space available */ -#define pdFREERTOS_ERRNO_ENOPROTOOPT 109 /* Protocol not available */ -#define pdFREERTOS_ERRNO_EADDRINUSE 112 /* Address already in use */ -#define pdFREERTOS_ERRNO_ETIMEDOUT 116 /* Connection timed out */ -#define pdFREERTOS_ERRNO_EINPROGRESS 119 /* Connection already in progress */ -#define pdFREERTOS_ERRNO_EALREADY 120 /* Socket already connected */ -#define pdFREERTOS_ERRNO_EADDRNOTAVAIL 125 /* Address not available */ -#define pdFREERTOS_ERRNO_EISCONN 127 /* Socket is already connected */ -#define pdFREERTOS_ERRNO_ENOTCONN 128 /* Socket is not connected */ -#define pdFREERTOS_ERRNO_ENOMEDIUM 135 /* No medium inserted */ -#define pdFREERTOS_ERRNO_EILSEQ 138 /* An invalid UTF-16 sequence was encountered. */ -#define pdFREERTOS_ERRNO_ECANCELED 140 /* Operation canceled. */ + * itself. */ +#define pdFREERTOS_ERRNO_NONE 0 /* No errors */ +#define pdFREERTOS_ERRNO_ENOENT 2 /* No such file or directory */ +#define pdFREERTOS_ERRNO_EINTR 4 /* Interrupted system call */ +#define pdFREERTOS_ERRNO_EIO 5 /* I/O error */ +#define pdFREERTOS_ERRNO_ENXIO 6 /* No such device or address */ +#define pdFREERTOS_ERRNO_EBADF 9 /* Bad file number */ +#define pdFREERTOS_ERRNO_EAGAIN 11 /* No more processes */ +#define pdFREERTOS_ERRNO_EWOULDBLOCK 11 /* Operation would block */ +#define pdFREERTOS_ERRNO_ENOMEM 12 /* Not enough memory */ +#define pdFREERTOS_ERRNO_EACCES 13 /* Permission denied */ +#define pdFREERTOS_ERRNO_EFAULT 14 /* Bad address */ +#define pdFREERTOS_ERRNO_EBUSY 16 /* Mount device busy */ +#define pdFREERTOS_ERRNO_EEXIST 17 /* File exists */ +#define pdFREERTOS_ERRNO_EXDEV 18 /* Cross-device link */ +#define pdFREERTOS_ERRNO_ENODEV 19 /* No such device */ +#define pdFREERTOS_ERRNO_ENOTDIR 20 /* Not a directory */ +#define pdFREERTOS_ERRNO_EISDIR 21 /* Is a directory */ +#define pdFREERTOS_ERRNO_EINVAL 22 /* Invalid argument */ +#define pdFREERTOS_ERRNO_ENOSPC 28 /* No space left on device */ +#define pdFREERTOS_ERRNO_ESPIPE 29 /* Illegal seek */ +#define pdFREERTOS_ERRNO_EROFS 30 /* Read only file system */ +#define pdFREERTOS_ERRNO_EUNATCH 42 /* Protocol driver not attached */ +#define pdFREERTOS_ERRNO_EBADE 50 /* Invalid exchange */ +#define pdFREERTOS_ERRNO_EFTYPE 79 /* Inappropriate file type or format */ +#define pdFREERTOS_ERRNO_ENMFILE 89 /* No more files */ +#define pdFREERTOS_ERRNO_ENOTEMPTY 90 /* Directory not empty */ +#define pdFREERTOS_ERRNO_ENAMETOOLONG 91 /* File or path name too long */ +#define pdFREERTOS_ERRNO_EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ +#define pdFREERTOS_ERRNO_ENOBUFS 105 /* No buffer space available */ +#define pdFREERTOS_ERRNO_ENOPROTOOPT 109 /* Protocol not available */ +#define pdFREERTOS_ERRNO_EADDRINUSE 112 /* Address already in use */ +#define pdFREERTOS_ERRNO_ETIMEDOUT 116 /* Connection timed out */ +#define pdFREERTOS_ERRNO_EINPROGRESS 119 /* Connection already in progress */ +#define pdFREERTOS_ERRNO_EALREADY 120 /* Socket already connected */ +#define pdFREERTOS_ERRNO_EADDRNOTAVAIL 125 /* Address not available */ +#define pdFREERTOS_ERRNO_EISCONN 127 /* Socket is already connected */ +#define pdFREERTOS_ERRNO_ENOTCONN 128 /* Socket is not connected */ +#define pdFREERTOS_ERRNO_ENOMEDIUM 135 /* No medium inserted */ +#define pdFREERTOS_ERRNO_EILSEQ 138 /* An invalid UTF-16 sequence was encountered. */ +#define pdFREERTOS_ERRNO_ECANCELED 140 /* Operation canceled. */ /* The following endian values are used by FreeRTOS+ components, not FreeRTOS -itself. */ -#define pdFREERTOS_LITTLE_ENDIAN 0 -#define pdFREERTOS_BIG_ENDIAN 1 + * itself. */ +#define pdFREERTOS_LITTLE_ENDIAN 0 +#define pdFREERTOS_BIG_ENDIAN 1 /* Re-defining endian values for generic naming. */ -#define pdLITTLE_ENDIAN pdFREERTOS_LITTLE_ENDIAN -#define pdBIG_ENDIAN pdFREERTOS_BIG_ENDIAN +#define pdLITTLE_ENDIAN pdFREERTOS_LITTLE_ENDIAN +#define pdBIG_ENDIAN pdFREERTOS_BIG_ENDIAN #endif /* PROJDEFS_H */ diff --git a/tools/sdk/esp32/include/freertos/include/freertos/queue.h b/tools/sdk/esp32/include/freertos/include/freertos/queue.h index 8c35465316e..81cccc05df3 100644 --- a/tools/sdk/esp32/include/freertos/include/freertos/queue.h +++ b/tools/sdk/esp32/include/freertos/include/freertos/queue.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ @@ -30,12 +29,14 @@ #define QUEUE_H #ifndef INC_FREERTOS_H - #error "include FreeRTOS.h" must appear in source files before "include queue.h" + #error "include FreeRTOS.h" must appear in source files before "include queue.h" #endif +/* *INDENT-OFF* */ #ifdef __cplusplus -extern "C" { + extern "C" { #endif +/* *INDENT-ON* */ #include "task.h" @@ -45,42 +46,64 @@ extern "C" { * xQueueSend(), xQueueReceive(), etc. */ struct QueueDefinition; /* Using old naming convention so as not to break kernel aware debuggers. */ -typedef struct QueueDefinition * QueueHandle_t; +typedef struct QueueDefinition * QueueHandle_t; /** * Type by which queue sets are referenced. For example, a call to * xQueueCreateSet() returns an xQueueSet variable that can then be used as a * parameter to xQueueSelectFromSet(), xQueueAddToSet(), etc. */ -typedef struct QueueDefinition * QueueSetHandle_t; +typedef struct QueueDefinition * QueueSetHandle_t; /** * Queue sets can contain both queues and semaphores, so the * QueueSetMemberHandle_t is defined as a type to be used where a parameter or * return value can be either an QueueHandle_t or an SemaphoreHandle_t. */ -typedef struct QueueDefinition * QueueSetMemberHandle_t; +typedef struct QueueDefinition * QueueSetMemberHandle_t; /** @cond */ /* For internal use only. */ -#define queueSEND_TO_BACK ( ( BaseType_t ) 0 ) -#define queueSEND_TO_FRONT ( ( BaseType_t ) 1 ) -#define queueOVERWRITE ( ( BaseType_t ) 2 ) +#define queueSEND_TO_BACK ( ( BaseType_t ) 0 ) +#define queueSEND_TO_FRONT ( ( BaseType_t ) 1 ) +#define queueOVERWRITE ( ( BaseType_t ) 2 ) /* For internal use only. These definitions *must* match those in queue.c. */ -#define queueQUEUE_TYPE_BASE ( ( uint8_t ) 0U ) -#define queueQUEUE_TYPE_SET ( ( uint8_t ) 0U ) -#define queueQUEUE_TYPE_MUTEX ( ( uint8_t ) 1U ) -#define queueQUEUE_TYPE_COUNTING_SEMAPHORE ( ( uint8_t ) 2U ) -#define queueQUEUE_TYPE_BINARY_SEMAPHORE ( ( uint8_t ) 3U ) -#define queueQUEUE_TYPE_RECURSIVE_MUTEX ( ( uint8_t ) 4U ) +#define queueQUEUE_TYPE_BASE ( ( uint8_t ) 0U ) +#define queueQUEUE_TYPE_SET ( ( uint8_t ) 0U ) +#define queueQUEUE_TYPE_MUTEX ( ( uint8_t ) 1U ) +#define queueQUEUE_TYPE_COUNTING_SEMAPHORE ( ( uint8_t ) 2U ) +#define queueQUEUE_TYPE_BINARY_SEMAPHORE ( ( uint8_t ) 3U ) +#define queueQUEUE_TYPE_RECURSIVE_MUTEX ( ( uint8_t ) 4U ) /** @endcond */ /** - * Creates a new queue instance. This allocates the storage required by the - * new queue and returns a handle for the queue. + * @cond + * queue. h + * @code{c} + * QueueHandle_t xQueueCreate( + * UBaseType_t uxQueueLength, + * UBaseType_t uxItemSize + * ); + * @endcode + * @endcond + * + * Creates a new queue instance, and returns a handle by which the new queue + * can be referenced. + * + * Internally, within the FreeRTOS implementation, queues use two blocks of + * memory. The first block is used to hold the queue's data structures. The + * second block is used to hold items placed into the queue. If a queue is + * created using xQueueCreate() then both blocks of memory are automatically + * dynamically allocated inside the xQueueCreate() function. (see + * https://www.FreeRTOS.org/a00111.html). If a queue is created using + * xQueueCreateStatic() then the application writer must provide the memory that + * will get used by the queue. xQueueCreateStatic() therefore allows a queue to + * be created without using any dynamic memory allocation. + * + * https://www.FreeRTOS.org/Embedded-RTOS-Queues.html * * @param uxQueueLength The maximum number of items that the queue can contain. * @@ -95,15 +118,15 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * * Example usage: * @code{c} - * struct AMessage - * { + * struct AMessage + * { * char ucMessageID; * char ucData[ 20 ]; - * }; + * }; * - * void vATask( void *pvParameters ) - * { - * QueueHandle_t xQueue1, xQueue2; + * void vATask( void *pvParameters ) + * { + * QueueHandle_t xQueue1, xQueue2; * * // Create a queue capable of containing 10 uint32_t values. * xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) ); @@ -121,15 +144,29 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * } * * // ... Rest of task code. - * } + * } * @endcode + * @cond + * \defgroup xQueueCreate xQueueCreate + * @endcond * \ingroup QueueManagement */ -#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - #define xQueueCreate( uxQueueLength, uxItemSize ) xQueueGenericCreate( ( uxQueueLength ), ( uxItemSize ), ( queueQUEUE_TYPE_BASE ) ) +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + #define xQueueCreate( uxQueueLength, uxItemSize ) xQueueGenericCreate( ( uxQueueLength ), ( uxItemSize ), ( queueQUEUE_TYPE_BASE ) ) #endif /** + * @cond + * queue. h + * @code{c} + * QueueHandle_t xQueueCreateStatic( + * UBaseType_t uxQueueLength, + * UBaseType_t uxItemSize, + * uint8_t *pucQueueStorageBuffer, + * StaticQueue_t *pxQueueBuffer + * ); + * @endcode + * @endcond * Creates a new queue instance, and returns a handle by which the new queue * can be referenced. * @@ -138,12 +175,12 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * second block is used to hold items placed into the queue. If a queue is * created using xQueueCreate() then both blocks of memory are automatically * dynamically allocated inside the xQueueCreate() function. (see - * http://www.freertos.org/a00111.html). If a queue is created using + * https://www.FreeRTOS.org/a00111.html). If a queue is created using * xQueueCreateStatic() then the application writer must provide the memory that * will get used by the queue. xQueueCreateStatic() therefore allows a queue to * be created without using any dynamic memory allocation. * - * http://www.FreeRTOS.org/Embedded-RTOS-Queues.html + * https://www.FreeRTOS.org/Embedded-RTOS-Queues.html * * @param uxQueueLength The maximum number of items that the queue can contain. * @@ -184,7 +221,7 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * * void vATask( void *pvParameters ) * { - * QueueHandle_t xQueue1; + * 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. @@ -198,13 +235,27 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * // ... Rest of task code. * } * @endcode + * @cond + * \defgroup xQueueCreateStatic xQueueCreateStatic + * @endcond * \ingroup QueueManagement */ -#if( configSUPPORT_STATIC_ALLOCATION == 1 ) - #define xQueueCreateStatic( uxQueueLength, uxItemSize, pucQueueStorage, pxQueueBuffer ) xQueueGenericCreateStatic( ( uxQueueLength ), ( uxItemSize ), ( pucQueueStorage ), ( pxQueueBuffer ), ( queueQUEUE_TYPE_BASE ) ) +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + #define xQueueCreateStatic( uxQueueLength, uxItemSize, pucQueueStorage, pxQueueBuffer ) xQueueGenericCreateStatic( ( uxQueueLength ), ( uxItemSize ), ( pucQueueStorage ), ( pxQueueBuffer ), ( queueQUEUE_TYPE_BASE ) ) #endif /* configSUPPORT_STATIC_ALLOCATION */ /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueSendToToFront( + * QueueHandle_t xQueue, + * const void *pvItemToQueue, + * TickType_t xTicksToWait + * ); + * @endcode + * @endcond + * * Post an item to the front of a queue. The item is queued by copy, not by * reference. This function must not be called from an interrupt service * routine. See xQueueSendFromISR () for an alternative which may be used @@ -227,18 +278,18 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * * Example usage: * @code{c} - * struct AMessage - * { + * struct AMessage + * { * char ucMessageID; * char ucData[ 20 ]; - * } xMessage; + * } xMessage; * - * uint32_t ulVar = 10UL; + * uint32_t ulVar = 10UL; * - * void vATask( void *pvParameters ) - * { - * QueueHandle_t xQueue1, xQueue2; - * struct AMessage *pxMessage; + * 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 ) ); @@ -268,13 +319,28 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * } * * // ... Rest of task code. - * } + * } * @endcode + * @cond + * \defgroup xQueueSend xQueueSend + * @endcond * \ingroup QueueManagement */ -#define xQueueSendToFront( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_FRONT ) +#define xQueueSendToFront( xQueue, pvItemToQueue, xTicksToWait ) \ + xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_FRONT ) /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueSendToBack( + * QueueHandle_t xQueue, + * const void *pvItemToQueue, + * TickType_t xTicksToWait + * ); + * @endcode + * @endcond + * * This is a macro that calls xQueueGenericSend(). * * Post an item to the back of a queue. The item is queued by copy, not by @@ -299,18 +365,18 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * * Example usage: * @code{c} - * struct AMessage - * { + * struct AMessage + * { * char ucMessageID; * char ucData[ 20 ]; - * } xMessage; + * } xMessage; * - * uint32_t ulVar = 10UL; + * uint32_t ulVar = 10UL; * - * void vATask( void *pvParameters ) - * { - * QueueHandle_t xQueue1, xQueue2; - * struct AMessage *pxMessage; + * 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 ) ); @@ -340,13 +406,28 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * } * * // ... Rest of task code. - * } + * } * @endcode + * @cond + * \defgroup xQueueSend xQueueSend + * @endcond * \ingroup QueueManagement */ -#define xQueueSendToBack( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK ) +#define xQueueSendToBack( xQueue, pvItemToQueue, xTicksToWait ) \ + xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK ) /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueSend( + * QueueHandle_t xQueue, + * const void * pvItemToQueue, + * TickType_t xTicksToWait + * ); + * @endcode + * @endcond + * * 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 @@ -373,18 +454,18 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * * Example usage: * @code{c} - * struct AMessage - * { + * struct AMessage + * { * char ucMessageID; * char ucData[ 20 ]; - * } xMessage; + * } xMessage; * - * uint32_t ulVar = 10UL; + * uint32_t ulVar = 10UL; * - * void vATask( void *pvParameters ) - * { - * QueueHandle_t xQueue1, xQueue2; - * struct AMessage *pxMessage; + * 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 ) ); @@ -414,13 +495,27 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * } * * // ... Rest of task code. - * } + * } * @endcode + * @cond + * \defgroup xQueueSend xQueueSend + * @endcond * \ingroup QueueManagement */ -#define xQueueSend( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK ) +#define xQueueSend( xQueue, pvItemToQueue, xTicksToWait ) \ + xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK ) /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueOverwrite( + * QueueHandle_t xQueue, + * const void * pvItemToQueue + * ); + * @endcode + * @endcond + * * Only for use with queues that have a length of one - so the queue is either * empty or full. * @@ -445,10 +540,10 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * Example usage: * @code{c} * - * void vFunction( void *pvParameters ) - * { - * QueueHandle_t xQueue; - * uint32_t ulVarToSend, ulValReceived; + * 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 @@ -490,12 +585,28 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * // ... * } * @endcode + * @cond + * \defgroup xQueueOverwrite xQueueOverwrite + * @endcond * \ingroup QueueManagement */ -#define xQueueOverwrite( xQueue, pvItemToQueue ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), 0, queueOVERWRITE ) +#define xQueueOverwrite( xQueue, pvItemToQueue ) \ + xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), 0, queueOVERWRITE ) /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueGenericSend( + * QueueHandle_t xQueue, + * const void * pvItemToQueue, + * TickType_t xTicksToWait + * BaseType_t xCopyPosition + * ); + * @endcode + * @endcond + * * It is preferred that the macros xQueueSend(), xQueueSendToFront() and * xQueueSendToBack() are used in place of calling this function directly. * @@ -524,18 +635,18 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * * Example usage: * @code{c} - * struct AMessage - * { + * struct AMessage + * { * char ucMessageID; * char ucData[ 20 ]; - * } xMessage; + * } xMessage; * - * uint32_t ulVar = 10UL; + * uint32_t ulVar = 10UL; * - * void vATask( void *pvParameters ) - * { - * QueueHandle_t xQueue1, xQueue2; - * struct AMessage *pxMessage; + * 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 ) ); @@ -565,13 +676,30 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * } * * // ... Rest of task code. - * } + * } * @endcode + * @cond + * \defgroup xQueueSend xQueueSend + * @endcond * \ingroup QueueManagement */ -BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, const BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION; +BaseType_t xQueueGenericSend( QueueHandle_t xQueue, + const void * const pvItemToQueue, + TickType_t xTicksToWait, + const BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION; /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueuePeek( + * QueueHandle_t xQueue, + * void * const pvBuffer, + * TickType_t xTicksToWait + * ); + * @endcode + * @endcond + * * Receive an item from a queue without removing the item from the queue. * The item is received by copy so a buffer of adequate size must be * provided. The number of bytes copied into the buffer was defined when @@ -592,7 +720,7 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQ * * @param xTicksToWait The maximum amount of time the task should block * waiting for an item to receive should the queue be empty at the time - * of the call. The time is defined in tick periods so the constant + * of the call. The time is defined in tick periods so the constant * portTICK_PERIOD_MS should be used to convert to real time if this is required. * xQueuePeek() will return immediately if xTicksToWait is 0 and the queue * is empty. @@ -602,18 +730,18 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQ * * Example usage: * @code{c} - * struct AMessage - * { + * struct AMessage + * { * char ucMessageID; * char ucData[ 20 ]; - * } xMessage; + * } xMessage; * - * QueueHandle_t xQueue; + * QueueHandle_t xQueue; * - * // Task to create a queue and post a value. - * void vATask( void *pvParameters ) - * { - * struct AMessage *pxMessage; + * // 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. @@ -631,12 +759,12 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQ * 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; + * // Task to peek the data from the queue. + * void vADifferentTask( void *pvParameters ) + * { + * struct AMessage *pxRxedMessage; * * if( xQueue != 0 ) * { @@ -650,13 +778,28 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQ * } * * // ... Rest of task code. - * } + * } * @endcode + * @cond + * \defgroup xQueuePeek xQueuePeek + * @endcond * \ingroup QueueManagement */ -BaseType_t xQueuePeek( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +BaseType_t xQueuePeek( QueueHandle_t xQueue, + void * const pvBuffer, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueuePeekFromISR( + * QueueHandle_t xQueue, + * void *pvBuffer, + * ); + * @endcode + * @endcond + * * A version of xQueuePeek() that can be called from an interrupt service * routine (ISR). * @@ -677,11 +820,26 @@ BaseType_t xQueuePeek( QueueHandle_t xQueue, void * const pvBuffer, TickType_t x * @return pdTRUE if an item was successfully received from the queue, * otherwise pdFALSE. * + * @cond + * \defgroup xQueuePeekFromISR xQueuePeekFromISR + * @endcond * \ingroup QueueManagement */ -BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, void * const pvBuffer ) PRIVILEGED_FUNCTION; +BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, + void * const pvBuffer ) PRIVILEGED_FUNCTION; /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueReceive( + * QueueHandle_t xQueue, + * void *pvBuffer, + * TickType_t xTicksToWait + * ); + * @endcode + * @endcond + * * Receive an item from a queue. The item is received by copy so a buffer of * adequate size must be provided. The number of bytes copied into the buffer * was defined when the queue was created. @@ -699,7 +857,7 @@ BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, void * const pvBuffer ) PRIV * * @param xTicksToWait The maximum amount of time the task should block * waiting for an item to receive should the queue be empty at the time - * of the call. xQueueReceive() will return immediately if xTicksToWait + * of the call. xQueueReceive() will return immediately if xTicksToWait * is zero and the queue is empty. The time is defined in tick periods so the * constant portTICK_PERIOD_MS should be used to convert to real time if this is * required. @@ -709,72 +867,94 @@ BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, void * const pvBuffer ) PRIV * * Example usage: * @code{c} - * struct AMessage - * { - * char ucMessageID; - * char ucData[ 20 ]; - * } xMessage; + * struct AMessage + * { + * char ucMessageID; + * char ucData[ 20 ]; + * } xMessage; + * + * QueueHandle_t xQueue; * - * QueueHandle_t xQueue; + * // Task to create a queue and post a value. + * void vATask( void *pvParameters ) + * { + * struct AMessage *pxMessage; * - * // Task to create a queue and post a value. - * void vATask( void *pvParameters ) + * // 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 ) * { - * struct AMessage *pxMessage; + * // Failed to create the queue. + * } * - * // 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 ); * - * // 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. + * } * - * // ... Rest of task code. - * } + * // Task to receive from the queue. + * void vADifferentTask( void *pvParameters ) + * { + * struct AMessage *pxRxedMessage; * - * // Task to receive from the queue. - * void vADifferentTask( void *pvParameters ) + * if( xQueue != 0 ) * { - * 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. + * // 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 + * @cond + * \defgroup xQueueReceive xQueueReceive + * @endcond * \ingroup QueueManagement */ -BaseType_t xQueueReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +BaseType_t xQueueReceive( QueueHandle_t xQueue, + void * const pvBuffer, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; /** + * @cond + * queue. h + * @code{c} + * UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue ); + * @endcode + * @endcond + * * 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. * + * @cond + * \defgroup uxQueueMessagesWaiting uxQueueMessagesWaiting + * @endcond * \ingroup QueueManagement */ UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; /** + * @cond + * queue. h + * @code{c} + * UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue ); + * @endcode + * @endcond + * * 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. @@ -783,21 +963,45 @@ UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue ) PRIVILEGED_FUNC * * @return The number of spaces available in the queue. * + * @cond + * \defgroup uxQueueMessagesWaiting uxQueueMessagesWaiting + * @endcond * \ingroup QueueManagement */ UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; /** + * @cond + * queue. h + * @code{c} + * void vQueueDelete( QueueHandle_t xQueue ); + * @endcode + * @endcond + * * 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. * + * @cond + * \defgroup vQueueDelete vQueueDelete + * @endcond * \ingroup QueueManagement */ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueSendToFrontFromISR( + * QueueHandle_t xQueue, + * const void *pvItemToQueue, + * BaseType_t *pxHigherPriorityTaskWoken + * ); + * @endcode + * @endcond + * * This is a macro that calls xQueueGenericSendFromISR(). * * Post an item to the front of a queue. It is safe to use this macro from @@ -826,38 +1030,54 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; * Example usage for buffered IO (where the ISR can obtain more than one value * per call): * @code{c} - * void vBufferISR( void ) - * { - * char cIn; - * BaseType_t xHigherPrioritTaskWoken; + * void vBufferISR( void ) + * { + * char cIn; + * BaseType_t xHigherPrioritTaskWoken; * - * // We have not woken a task at the start of the ISR. - * xHigherPriorityTaskWoken = pdFALSE; + * // 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 ); + * // 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 ); + * // Post the byte. + * xQueueSendToFrontFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken ); * - * } while( portINPUT_BYTE( BUFFER_COUNT ) ); + * } while( portINPUT_BYTE( BUFFER_COUNT ) ); * - * // Now the buffer is empty we can switch context if necessary. - * if( xHigherPriorityTaskWoken ) - * { - * portYIELD_FROM_ISR (); - * } + * // Now the buffer is empty we can switch context if necessary. + * if( xHigherPriorityTaskWoken ) + * { + * portYIELD_FROM_ISR (); * } + * } * @endcode + * + * @cond + * \defgroup xQueueSendFromISR xQueueSendFromISR + * @endcond * \ingroup QueueManagement */ -#define xQueueSendToFrontFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_FRONT ) +#define xQueueSendToFrontFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) \ + xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_FRONT ) /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueSendToBackFromISR( + * QueueHandle_t xQueue, + * const void *pvItemToQueue, + * BaseType_t *pxHigherPriorityTaskWoken + * ); + * @endcode + * @endcond + * * This is a macro that calls xQueueGenericSendFromISR(). * * Post an item to the back of a queue. It is safe to use this macro from @@ -886,37 +1106,53 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; * Example usage for buffered IO (where the ISR can obtain more than one value * per call): * @code{c} - * void vBufferISR( void ) - * { - * char cIn; - * BaseType_t xHigherPriorityTaskWoken; + * void vBufferISR( void ) + * { + * char cIn; + * BaseType_t xHigherPriorityTaskWoken; * - * // We have not woken a task at the start of the ISR. - * xHigherPriorityTaskWoken = pdFALSE; + * // 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 ); + * // 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 ); + * // Post the byte. + * xQueueSendToBackFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken ); * - * } while( portINPUT_BYTE( BUFFER_COUNT ) ); + * } while( portINPUT_BYTE( BUFFER_COUNT ) ); * - * // Now the buffer is empty we can switch context if necessary. - * if( xHigherPriorityTaskWoken ) - * { - * portYIELD_FROM_ISR (); - * } + * // Now the buffer is empty we can switch context if necessary. + * if( xHigherPriorityTaskWoken ) + * { + * portYIELD_FROM_ISR (); * } + * } * @endcode + * + * @cond + * \defgroup xQueueSendFromISR xQueueSendFromISR + * @endcond * \ingroup QueueManagement */ -#define xQueueSendToBackFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK ) +#define xQueueSendToBackFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) \ + xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK ) /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueOverwriteFromISR( + * QueueHandle_t xQueue, + * const void * pvItemToQueue, + * BaseType_t *pxHigherPriorityTaskWoken + * ); + * @endcode + * @endcond + * * A version of xQueueOverwrite() that can be used in an interrupt service * routine (ISR). * @@ -947,15 +1183,16 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; * * Example usage: * @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 ) ); + * 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 ) @@ -964,35 +1201,50 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; * BaseType_t xHigherPriorityTaskWoken = pdFALSE; * uint32_t ulVarToSend, ulValReceived; * - * // Write the value 10 to the queue using xQueueOverwriteFromISR(). - * ulVarToSend = 10; - * xQueueOverwriteFromISR( xQueue, &ulVarToSend, &xHigherPriorityTaskWoken ); + * // 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 ); + * // 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. + * // 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. - * } + * 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 + * @cond + * \defgroup xQueueOverwriteFromISR xQueueOverwriteFromISR + * @endcond * \ingroup QueueManagement */ -#define xQueueOverwriteFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueOVERWRITE ) +#define xQueueOverwriteFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) \ + xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueOVERWRITE ) /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueSendFromISR( + * QueueHandle_t xQueue, + * const void *pvItemToQueue, + * BaseType_t *pxHigherPriorityTaskWoken + * ); + * @endcode + * @endcond + * * 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() @@ -1024,40 +1276,57 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; * Example usage for buffered IO (where the ISR can obtain more than one value * per call): * @code{c} - * void vBufferISR( void ) - * { - * char cIn; - * BaseType_t xHigherPriorityTaskWoken; + * void vBufferISR( void ) + * { + * char cIn; + * BaseType_t xHigherPriorityTaskWoken; * - * // We have not woken a task at the start of the ISR. - * xHigherPriorityTaskWoken = pdFALSE; + * // 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 ); + * // 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 ); + * // Post the byte. + * xQueueSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken ); * - * } while( portINPUT_BYTE( BUFFER_COUNT ) ); + * } 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 (); - * } + * // Now the buffer is empty we can switch context if necessary. + * if( xHigherPriorityTaskWoken ) + * { + * // Actual macro used here is port specific. + * portYIELD_FROM_ISR (); * } + * } * @endcode * + * @cond + * \defgroup xQueueSendFromISR xQueueSendFromISR + * @endcond * \ingroup QueueManagement */ -#define xQueueSendFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK ) +#define xQueueSendFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) \ + xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK ) +/** @cond */ /**@{*/ /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueGenericSendFromISR( + * QueueHandle_t xQueue, + * const void *pvItemToQueue, + * BaseType_t *pxHigherPriorityTaskWoken, + * BaseType_t xCopyPosition + * ); + * @endcode + * @endcond + * * It is preferred that the macros xQueueSendFromISR(), * xQueueSendToFrontFromISR() and xQueueSendToBackFromISR() be used in place * of calling this function directly. xQueueGiveFromISR() is an @@ -1093,40 +1362,57 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; * Example usage for buffered IO (where the ISR can obtain more than one value * per call): * @code{c} - * void vBufferISR( void ) - * { - * char cIn; - * BaseType_t xHigherPriorityTaskWokenByPost; + * void vBufferISR( void ) + * { + * char cIn; + * BaseType_t xHigherPriorityTaskWokenByPost; * - * // We have not woken a task at the start of the ISR. - * xHigherPriorityTaskWokenByPost = pdFALSE; + * // 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 ); + * // 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 ); + * // Post each byte. + * xQueueGenericSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWokenByPost, queueSEND_TO_BACK ); * - * } while( portINPUT_BYTE( BUFFER_COUNT ) ); + * } 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(); - * } + * // 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; +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; /**@}*/ +/** @endcond */ /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueReceiveFromISR( + * QueueHandle_t xQueue, + * void *pvBuffer, + * BaseType_t *pxTaskWoken + * ); + * @endcode + * @endcond + * * Receive an item from a queue. It is safe to use this function from within an * interrupt service routine. * @@ -1146,63 +1432,69 @@ BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue, BaseType_t * const pxHigherP * * Example usage: * @code{c} - * QueueHandle_t xQueue; * - * // Function to create a queue and post some values. - * void vAFunction( void *pvParameters ) + * 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) ) * { - * 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 ); + * // 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. * } * - * // ISR that outputs all the characters received on the queue. - * void vISR_Routine( void ) + * if( cTaskWokenByPost != ( char ) pdFALSE; * { - * 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 (); - * } + * taskYIELD (); * } + * } * @endcode + * @cond + * \defgroup xQueueReceiveFromISR xQueueReceiveFromISR + * @endcond * \ingroup QueueManagement */ -BaseType_t xQueueReceiveFromISR( QueueHandle_t xQueue, void * const pvBuffer, BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; +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 @@ -1213,7 +1505,7 @@ BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUN UBaseType_t uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; /** @cond */ -/** +/* * The functions defined above are for passing data to and from tasks. The * functions below are the equivalents for passing data to and from * co-routines. @@ -1222,10 +1514,18 @@ UBaseType_t uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue ) PRIVILEG * should not be called directly from application code. Instead use the macro * wrappers defined within croutine.h. */ -BaseType_t xQueueCRSendFromISR( QueueHandle_t xQueue, const void *pvItemToQueue, BaseType_t xCoRoutinePreviouslyWoken ); -BaseType_t xQueueCRReceiveFromISR( QueueHandle_t xQueue, void *pvBuffer, BaseType_t *pxTaskWoken ); -BaseType_t xQueueCRSend( QueueHandle_t xQueue, const void *pvItemToQueue, TickType_t xTicksToWait ); -BaseType_t xQueueCRReceive( QueueHandle_t xQueue, void *pvBuffer, TickType_t xTicksToWait ); +BaseType_t xQueueCRSendFromISR( QueueHandle_t xQueue, + const void * pvItemToQueue, + BaseType_t xCoRoutinePreviouslyWoken ); +BaseType_t xQueueCRReceiveFromISR( QueueHandle_t xQueue, + void * pvBuffer, + BaseType_t * pxTaskWoken ); +BaseType_t xQueueCRSend( QueueHandle_t xQueue, + const void * pvItemToQueue, + TickType_t xTicksToWait ); +BaseType_t xQueueCRReceive( QueueHandle_t xQueue, + void * pvBuffer, + TickType_t xTicksToWait ); /** * For internal use only. Use xSemaphoreCreateMutex(), @@ -1233,10 +1533,15 @@ BaseType_t xQueueCRReceive( QueueHandle_t xQueue, void *pvBuffer, TickType_t xTi * these functions directly. */ QueueHandle_t xQueueCreateMutex( const uint8_t ucQueueType ) PRIVILEGED_FUNCTION; -QueueHandle_t xQueueCreateMutexStatic( const uint8_t ucQueueType, StaticQueue_t *pxStaticQueue ) PRIVILEGED_FUNCTION; -QueueHandle_t xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount ) PRIVILEGED_FUNCTION; -QueueHandle_t xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount, StaticQueue_t *pxStaticQueue ) PRIVILEGED_FUNCTION; -BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +QueueHandle_t xQueueCreateMutexStatic( const uint8_t ucQueueType, + StaticQueue_t * pxStaticQueue ) PRIVILEGED_FUNCTION; +QueueHandle_t xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, + const UBaseType_t uxInitialCount ) PRIVILEGED_FUNCTION; +QueueHandle_t xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, + const UBaseType_t uxInitialCount, + StaticQueue_t * pxStaticQueue ) PRIVILEGED_FUNCTION; +BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; TaskHandle_t xQueueGetMutexHolder( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION; TaskHandle_t xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION; @@ -1244,7 +1549,8 @@ TaskHandle_t xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore ) PRIVILEGED_ * For internal use only. Use xSemaphoreTakeMutexRecursive() or * xSemaphoreGiveMutexRecursive() instead of calling these functions directly. */ -BaseType_t xQueueTakeMutexRecursive( QueueHandle_t xMutex, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +BaseType_t xQueueTakeMutexRecursive( QueueHandle_t xMutex, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION; /** @endcond */ @@ -1253,7 +1559,7 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION; * Reset a queue back to its original empty state. The return value is now * obsolete and is always set to pdPASS. */ -#define xQueueReset( xQueue ) xQueueGenericReset( xQueue, pdFALSE ) +#define xQueueReset( xQueue ) xQueueGenericReset( xQueue, pdFALSE ) /** * The registry is provided as a means for kernel aware debuggers to @@ -1277,8 +1583,9 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION; * stores a pointer to the string - so the string must be persistent (global or * preferably in ROM/Flash), not on the stack. */ -#if( configQUEUE_REGISTRY_SIZE > 0 ) - void vQueueAddToRegistry( QueueHandle_t xQueue, const char *pcQueueName ) PRIVILEGED_FUNCTION; /**lint !e971 Unqualified char types are allowed for strings and single characters only. */ +#if ( configQUEUE_REGISTRY_SIZE > 0 ) + void vQueueAddToRegistry( QueueHandle_t xQueue, + const char * pcQueueName ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ #endif /** @@ -1291,8 +1598,8 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION; * * @param xQueue The handle of the queue being removed from the registry. */ -#if( configQUEUE_REGISTRY_SIZE > 0 ) - void vQueueUnregisterQueue( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; +#if ( configQUEUE_REGISTRY_SIZE > 0 ) + void vQueueUnregisterQueue( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; #endif /** @@ -1306,26 +1613,32 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION; * queue is returned. If the queue is not in the registry then NULL is * 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. */ +#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. */ #endif /** - * Generic version of the function used to creaet a queue using dynamic memory + * Generic version of the function used to create 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. */ -#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - QueueHandle_t xQueueGenericCreate( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, const uint8_t ucQueueType ) PRIVILEGED_FUNCTION; +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + 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 + * Generic version of the function used to create 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. */ -#if( configSUPPORT_STATIC_ALLOCATION == 1 ) - QueueHandle_t xQueueGenericCreateStatic( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, uint8_t *pucQueueStorage, StaticQueue_t *pxStaticQueue, const uint8_t ucQueueType ) PRIVILEGED_FUNCTION; +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + QueueHandle_t xQueueGenericCreateStatic( const UBaseType_t uxQueueLength, + const UBaseType_t uxItemSize, + uint8_t * pucQueueStorage, + StaticQueue_t * pxStaticQueue, + const uint8_t ucQueueType ) PRIVILEGED_FUNCTION; #endif /** @@ -1342,7 +1655,7 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION; * or semaphores contained in the set is in a state where a queue read or * semaphore take operation would be successful. * - * Note 1: See the documentation on http://wwwFreeRTOS.org/RTOS-queue-sets.html + * Note 1: See the documentation on https://www.FreeRTOS.org/RTOS-queue-sets.html * for reasons why queue sets are very rarely needed in practice as there are * simpler methods of blocking on multiple objects. * @@ -1400,7 +1713,8 @@ QueueSetHandle_t xQueueCreateSet( const UBaseType_t uxEventQueueLength ) PRIVILE * queue set because it is already a member of a different queue set then pdFAIL * is returned. */ -BaseType_t xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION; +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 @@ -1419,7 +1733,8 @@ BaseType_t xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHan * then pdPASS is returned. If the queue was not in the queue set, or the * queue (or semaphore) was not empty, then pdFAIL is returned. */ -BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION; +BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, + QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION; /** * xQueueSelectFromSet() selects from the members of a queue set a queue or @@ -1431,7 +1746,7 @@ BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueS * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this * function. * - * Note 1: See the documentation on http://wwwFreeRTOS.org/RTOS-queue-sets.html + * Note 1: See the documentation on https://www.FreeRTOS.org/RTOS-queue-sets.html * for reasons why queue sets are very rarely needed in practice as there are * simpler methods of blocking on multiple objects. * @@ -1455,7 +1770,8 @@ BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueS * in the queue set that is available, or NULL if no such queue or semaphore * exists before before the specified block time expires. */ -QueueSetMemberHandle_t xQueueSelectFromSet( QueueSetHandle_t xQueueSet, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +QueueSetMemberHandle_t xQueueSelectFromSet( QueueSetHandle_t xQueueSet, + const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; /** * A version of xQueueSelectFromSet() that can be used from an ISR. @@ -1465,16 +1781,22 @@ QueueSetMemberHandle_t xQueueSelectFromSetFromISR( QueueSetHandle_t xQueueSet ) /** @cond */ /* Not public API functions. */ -void vQueueWaitForMessageRestricted( QueueHandle_t xQueue, TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION; -BaseType_t xQueueGenericReset( QueueHandle_t xQueue, BaseType_t xNewQueue ) PRIVILEGED_FUNCTION; -void vQueueSetQueueNumber( QueueHandle_t xQueue, UBaseType_t uxQueueNumber ) PRIVILEGED_FUNCTION; +void vQueueWaitForMessageRestricted( QueueHandle_t xQueue, + TickType_t xTicksToWait, + const BaseType_t xWaitIndefinitely ) 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 */ +/* *INDENT-OFF* */ #ifdef __cplusplus -} + } #endif +/* *INDENT-ON* */ #endif /* QUEUE_H */ diff --git a/tools/sdk/esp32/include/freertos/include/freertos/semphr.h b/tools/sdk/esp32/include/freertos/include/freertos/semphr.h index 971d74d496c..7e99c0b396c 100644 --- a/tools/sdk/esp32/include/freertos/include/freertos/semphr.h +++ b/tools/sdk/esp32/include/freertos/include/freertos/semphr.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,35 +19,36 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ #ifndef SEMAPHORE_H #define SEMAPHORE_H #ifndef INC_FREERTOS_H - #error "include FreeRTOS.h" must appear in source files before "include semphr.h" + #error "include FreeRTOS.h" must appear in source files before "include semphr.h" #endif #include "queue.h" typedef QueueHandle_t SemaphoreHandle_t; -#define semBINARY_SEMAPHORE_QUEUE_LENGTH ( ( uint8_t ) 1U ) -#define semSEMAPHORE_QUEUE_ITEM_LENGTH ( ( uint8_t ) 0U ) -#define semGIVE_BLOCK_TIME ( ( TickType_t ) 0U ) +#define semBINARY_SEMAPHORE_QUEUE_LENGTH ( ( uint8_t ) 1U ) +#define semSEMAPHORE_QUEUE_ITEM_LENGTH ( ( uint8_t ) 0U ) +#define semGIVE_BLOCK_TIME ( ( TickType_t ) 0U ) /** @cond */ /** * semphr. h - *
vSemaphoreCreateBinary( SemaphoreHandle_t xSemaphore )
+ * @code{c} + * vSemaphoreCreateBinary( SemaphoreHandle_t xSemaphore ); + * @endcode * * In many usage scenarios it is faster and more memory efficient to use a * direct to task notification in place of a binary semaphore! - * http://www.freertos.org/RTOS-task-notifications.html + * https://www.FreeRTOS.org/RTOS-task-notifications.html * * This old vSemaphoreCreateBinary() macro is now deprecated in favour of the * xSemaphoreCreateBinary() function. Note that binary semaphores created using @@ -72,48 +73,58 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @code{c} - * SemaphoreHandle_t xSemaphore = NULL; + * 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 ); + * 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. - * } + * if( xSemaphore != NULL ) + * { + * // The semaphore was created successfully. + * // The semaphore can now be used. * } + * } * @endcode + * @cond + * \defgroup vSemaphoreCreateBinary vSemaphoreCreateBinary + * @endcond * \ingroup Semaphores */ -#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - #define vSemaphoreCreateBinary( xSemaphore ) \ - { \ - ( xSemaphore ) = xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE ); \ - if( ( xSemaphore ) != NULL ) \ - { \ - ( void ) xSemaphoreGive( ( xSemaphore ) ); \ - } \ - } +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + #define vSemaphoreCreateBinary( xSemaphore ) \ + { \ + ( xSemaphore ) = xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE ); \ + if( ( xSemaphore ) != NULL ) \ + { \ + ( void ) xSemaphoreGive( ( xSemaphore ) ); \ + } \ + } #endif /** @endcond */ /** + * @cond + * semphr. h + * @code{c} + * SemaphoreHandle_t xSemaphoreCreateBinary( void ); + * @endcode + * @endcond + * * Creates a new binary semaphore instance, and returns a handle by which the * new semaphore can be referenced. * * In many usage scenarios it is faster and more memory efficient to use a * direct to task notification in place of a binary semaphore! - * http://www.freertos.org/RTOS-task-notifications.html + * https://www.FreeRTOS.org/RTOS-task-notifications.html * * Internally, within the FreeRTOS implementation, binary semaphores use a block * of memory, in which the semaphore structure is stored. If a binary semaphore * is created using xSemaphoreCreateBinary() then the required memory is * automatically dynamically allocated inside the xSemaphoreCreateBinary() - * function. (see http://www.freertos.org/a00111.html). If a binary semaphore + * function. (see https://www.FreeRTOS.org/a00111.html). If a binary semaphore * is created using xSemaphoreCreateBinaryStatic() then the application writer * must provide the memory. xSemaphoreCreateBinaryStatic() therefore allows a * binary semaphore to be created without using any dynamic memory allocation. @@ -137,40 +148,50 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @code{c} - * SemaphoreHandle_t xSemaphore = NULL; + * 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(); + * 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. - * } + * if( xSemaphore != NULL ) + * { + * // The semaphore was created successfully. + * // The semaphore can now be used. * } + * } * @endcode + * @cond + * \defgroup xSemaphoreCreateBinary xSemaphoreCreateBinary + * @endcond * \ingroup Semaphores */ -#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - #define xSemaphoreCreateBinary() xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE ) +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + #define xSemaphoreCreateBinary() xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE ) #endif /** + * @cond + * semphr. h + * @code{c} + * SemaphoreHandle_t xSemaphoreCreateBinaryStatic( StaticSemaphore_t *pxSemaphoreBuffer ); + * @endcode + * @endcond + * * Creates a new binary semaphore instance, and returns a handle by which the * new semaphore can be referenced. * * NOTE: In many usage scenarios it is faster and more memory efficient to use a * direct to task notification in place of a binary semaphore! - * http://www.freertos.org/RTOS-task-notifications.html + * https://www.FreeRTOS.org/RTOS-task-notifications.html * * Internally, within the FreeRTOS implementation, binary semaphores use a block * of memory, in which the semaphore structure is stored. If a binary semaphore * is created using xSemaphoreCreateBinary() then the required memory is * automatically dynamically allocated inside the xSemaphoreCreateBinary() - * function. (see http://www.freertos.org/a00111.html). If a binary semaphore + * function. (see https://www.FreeRTOS.org/a00111.html). If a binary semaphore * is created using xSemaphoreCreateBinaryStatic() then the application writer * must provide the memory. xSemaphoreCreateBinaryStatic() therefore allows a * binary semaphore to be created without using any dynamic memory allocation. @@ -191,38 +212,51 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @code{c} - * SemaphoreHandle_t xSemaphore = NULL; - * StaticSemaphore_t xSemaphoreBuffer; - * - * void vATask( void * pvParameters ) - * { - * // Semaphore cannot be used before a call to xSemaphoreCreateBinary() or - * // xSemaphoreCreateBinaryStatic(). - * // 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 = xSemaphoreCreateBinaryStatic( &xSemaphoreBuffer ); - * - * // Rest of task code goes here. - * } + * SemaphoreHandle_t xSemaphore = NULL; + * StaticSemaphore_t xSemaphoreBuffer; + * + * void vATask( void * pvParameters ) + * { + * // Semaphore cannot be used before a call to xSemaphoreCreateBinary() or + * // xSemaphoreCreateBinaryStatic(). + * // 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 = xSemaphoreCreateBinaryStatic( &xSemaphoreBuffer ); + * + * // Rest of task code goes here. + * } * @endcode + * @cond + * \defgroup xSemaphoreCreateBinaryStatic xSemaphoreCreateBinaryStatic + * @endcond * \ingroup Semaphores */ -#if( configSUPPORT_STATIC_ALLOCATION == 1 ) - #define xSemaphoreCreateBinaryStatic( pxStaticSemaphore ) xQueueGenericCreateStatic( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, NULL, pxStaticSemaphore, queueQUEUE_TYPE_BINARY_SEMAPHORE ) +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + #define xSemaphoreCreateBinaryStatic( pxStaticSemaphore ) xQueueGenericCreateStatic( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, NULL, pxStaticSemaphore, queueQUEUE_TYPE_BINARY_SEMAPHORE ) #endif /* configSUPPORT_STATIC_ALLOCATION */ /** + * @cond + * semphr. h + * @code{c} + * xSemaphoreTake( + * SemaphoreHandle_t xSemaphore, + * TickType_t xBlockTime + * ); + * @endcode + * @endcond + * * Macro to obtain a semaphore. The semaphore must have previously been * created with a call to xSemaphoreCreateBinary(), xSemaphoreCreateMutex() or * xSemaphoreCreateCounting(). * - * @param xSemaphore A handle to the semaphore being taken - obtained when + * param xSemaphore A handle to the semaphore being taken - obtained when * the semaphore was created. * - * @param xBlockTime The time in ticks to wait for the semaphore to become + * param xBlockTime The time in ticks to wait for the semaphore to become * available. The macro portTICK_PERIOD_MS can be used to convert this to a * real time. A block time of zero can be used to poll the semaphore. A block * time of portMAX_DELAY can be used to block indefinitely (provided @@ -233,48 +267,61 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @code{c} - * SemaphoreHandle_t xSemaphore = NULL; + * 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 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. + * // 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. - * } - * } + * 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 + * @cond + * \defgroup xSemaphoreTake xSemaphoreTake + * @endcond * \ingroup Semaphores */ -#define xSemaphoreTake( xSemaphore, xBlockTime ) xQueueSemaphoreTake( ( xSemaphore ), ( xBlockTime ) ) +#define xSemaphoreTake( xSemaphore, xBlockTime ) xQueueSemaphoreTake( ( xSemaphore ), ( xBlockTime ) ) /** + * @cond + * semphr. h + * @code{c} + * xSemaphoreTakeRecursive( + * SemaphoreHandle_t xMutex, + * TickType_t xBlockTime + * ); + * @endcode + * @endcond + * * Macro to recursively obtain, or 'take', a mutex type semaphore. * The mutex must have previously been created using a call to * xSemaphoreCreateRecursiveMutex(); @@ -305,76 +352,63 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @code{c} - * SemaphoreHandle_t xMutex = NULL; + * 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 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. + * // 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. - * } - * } + * 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 + * @cond + * \defgroup xSemaphoreTakeRecursive xSemaphoreTakeRecursive + * @endcond * \ingroup Semaphores */ -#define xSemaphoreTakeRecursive( xMutex, xBlockTime ) xQueueTakeMutexRecursive( ( xMutex ), ( xBlockTime ) ) - -/** @cond */ -/* - * xSemaphoreAltTake() is an alternative version of xSemaphoreTake(). - * - * The source code that implements the alternative (Alt) API is much - * simpler because it executes everything from within a critical section. - * This is the approach taken by many other RTOSes, but FreeRTOS.org has the - * preferred fully featured API too. The fully featured API has more - * complex code that takes longer to execute, but makes much less use of - * critical sections. Therefore the alternative API sacrifices interrupt - * responsiveness to gain execution speed, whereas the fully featured API - * sacrifices execution speed to ensure better interrupt responsiveness. - */ -#define xSemaphoreAltTake( xSemaphore, xBlockTime ) xQueueAltGenericReceive( ( QueueHandle_t ) ( xSemaphore ), NULL, ( xBlockTime ), pdFALSE ) -/** @endcond */ +#define xSemaphoreTakeRecursive( xMutex, xBlockTime ) xQueueTakeMutexRecursive( ( xMutex ), ( xBlockTime ) ) /** * Macro to release a semaphore. The semaphore must have previously been @@ -397,47 +431,54 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @code{c} - * SemaphoreHandle_t xSemaphore = NULL; + * SemaphoreHandle_t xSemaphore = NULL; * - * void vATask( void * pvParameters ) - * { - * // Create the semaphore to guard a shared resource. - * vSemaphoreCreateBinary( xSemaphore ); + * 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. - * } - * } - * } + * 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 + * @cond + * \defgroup xSemaphoreGive xSemaphoreGive + * @endcond * \ingroup Semaphores */ -#define xSemaphoreGive( xSemaphore ) xQueueGenericSend( ( QueueHandle_t ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK ) +#define xSemaphoreGive( xSemaphore ) xQueueGenericSend( ( QueueHandle_t ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK ) /** + * @cond * semphr. h - *
xSemaphoreGiveRecursive( SemaphoreHandle_t xMutex )
+ * @code{c} + * xSemaphoreGiveRecursive( SemaphoreHandle_t xMutex ); + * @endcode + * @endcond * * Macro to recursively release, or 'give', a mutex type semaphore. * The mutex must have previously been created using a call to @@ -462,78 +503,64 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @code{c} - * SemaphoreHandle_t xMutex = NULL; + * 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 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. + * // 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. - * } - * } + * 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 + * @cond + * \defgroup xSemaphoreGiveRecursive xSemaphoreGiveRecursive + * @endcond * \ingroup Semaphores */ -#define xSemaphoreGiveRecursive( xMutex ) xQueueGiveMutexRecursive( ( xMutex ) ) - -/** @cond */ -/* - * xSemaphoreAltGive() is an alternative version of xSemaphoreGive(). - * - * The source code that implements the alternative (Alt) API is much - * simpler because it executes everything from within a critical section. - * This is the approach taken by many other RTOSes, but FreeRTOS.org has the - * preferred fully featured API too. The fully featured API has more - * complex code that takes longer to execute, but makes much less use of - * critical sections. Therefore the alternative API sacrifices interrupt - * responsiveness to gain execution speed, whereas the fully featured API - * sacrifices execution speed to ensure better interrupt responsiveness. - */ -#define xSemaphoreAltGive( xSemaphore ) xQueueAltGenericSend( ( QueueHandle_t ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK ) - -/** @endcond */ +#define xSemaphoreGiveRecursive( xMutex ) xQueueGiveMutexRecursive( ( xMutex ) ) /** * Macro to release a semaphore. The semaphore must have previously been @@ -557,68 +584,81 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @code{c} - * \#define LONG_TIME 0xffff - * \#define TICKS_TO_WAIT 10 - * SemaphoreHandle_t xSemaphore = NULL; - * - * // Repetitive task. - * void vATask( void * pvParameters ) + * #define LONG_TIME 0xffff + * #define TICKS_TO_WAIT 10 + * SemaphoreHandle_t xSemaphore = NULL; + * + * // Repetitive task. + * void vATask( void * pvParameters ) + * { + * for( ;; ) * { - * for( ;; ) - * { - * // We want this task to run every 10 ticks of a timer. The semaphore - * // was created before this task was started. + * // 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. + * // 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. - * } - * } + * // 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; + * // Timer ISR + * void vTimerISR( void * pvParameters ) + * { + * static uint8_t ucLocalTickCount = 0; + * static BaseType_t xHigherPriorityTaskWoken; * - * // A timer tick has occurred. + * // A timer tick has occurred. * - * // ... Do other time functions. + * // ... 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 ); + * // 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; - * } + * // 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. - * } + * 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 + * @cond + * \defgroup xSemaphoreGiveFromISR xSemaphoreGiveFromISR + * @endcond * \ingroup Semaphores */ -#define xSemaphoreGiveFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueGiveFromISR( ( QueueHandle_t ) ( xSemaphore ), ( pxHigherPriorityTaskWoken ) ) +#define xSemaphoreGiveFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueGiveFromISR( ( QueueHandle_t ) ( xSemaphore ), ( pxHigherPriorityTaskWoken ) ) /** + * @cond + * semphr. h + * @code{c} + * xSemaphoreTakeFromISR( + * SemaphoreHandle_t xSemaphore, + * BaseType_t *pxHigherPriorityTaskWoken + * ); + * @endcode + * @endcond + * * Macro to take a semaphore from an ISR. The semaphore must have * previously been created with a call to xSemaphoreCreateBinary() or * xSemaphoreCreateCounting(). @@ -643,17 +683,24 @@ typedef QueueHandle_t SemaphoreHandle_t; * @return pdTRUE if the semaphore was successfully taken, otherwise * pdFALSE */ -#define xSemaphoreTakeFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueReceiveFromISR( ( QueueHandle_t ) ( xSemaphore ), NULL, ( pxHigherPriorityTaskWoken ) ) +#define xSemaphoreTakeFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueReceiveFromISR( ( QueueHandle_t ) ( xSemaphore ), NULL, ( pxHigherPriorityTaskWoken ) ) /** - * Macro that implements a mutex semaphore by using the existing queue - * mechanism. + * @cond + * semphr. h + * @code{c} + * SemaphoreHandle_t xSemaphoreCreateMutex( void ); + * @endcode + * @endcond + * + * Creates a new mutex type semaphore instance, and returns a handle by which + * the new mutex can be referenced. * * Internally, within the FreeRTOS implementation, mutex semaphores use a block * of memory, in which the mutex structure is stored. If a mutex is created * using xSemaphoreCreateMutex() then the required memory is automatically * dynamically allocated inside the xSemaphoreCreateMutex() function. (see - * http://www.freertos.org/a00111.html). If a mutex is created using + * https://www.FreeRTOS.org/a00111.html). If a mutex is created using * xSemaphoreCreateMutexStatic() then the application writer must provided the * memory. xSemaphoreCreateMutexStatic() therefore allows a mutex to be created * without using any dynamic memory allocation. @@ -679,28 +726,38 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @code{c} - * SemaphoreHandle_t xSemaphore; + * 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(); + * 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. - * } + * if( xSemaphore != NULL ) + * { + * // The semaphore was created successfully. + * // The semaphore can now be used. * } + * } * @endcode + * @cond + * \defgroup xSemaphoreCreateMutex xSemaphoreCreateMutex + * @endcond * \ingroup Semaphores */ -#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - #define xSemaphoreCreateMutex() xQueueCreateMutex( queueQUEUE_TYPE_MUTEX ) +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + #define xSemaphoreCreateMutex() xQueueCreateMutex( queueQUEUE_TYPE_MUTEX ) #endif /** + * @cond + * semphr. h + * @code{c} + * SemaphoreHandle_t xSemaphoreCreateMutexStatic( StaticSemaphore_t *pxMutexBuffer ); + * @endcode + * @endcond + * * Creates a new mutex type semaphore instance, and returns a handle by which * the new mutex can be referenced. * @@ -708,7 +765,7 @@ typedef QueueHandle_t SemaphoreHandle_t; * of memory, in which the mutex structure is stored. If a mutex is created * using xSemaphoreCreateMutex() then the required memory is automatically * dynamically allocated inside the xSemaphoreCreateMutex() function. (see - * http://www.freertos.org/a00111.html). If a mutex is created using + * https://www.FreeRTOS.org/a00111.html). If a mutex is created using * xSemaphoreCreateMutexStatic() then the application writer must provided the * memory. xSemaphoreCreateMutexStatic() therefore allows a mutex to be created * without using any dynamic memory allocation. @@ -736,25 +793,28 @@ typedef QueueHandle_t SemaphoreHandle_t; * mutex is returned. If pxMutexBuffer was NULL then NULL is returned. * * Example usage: - * @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. - * } + * @code{c} + * 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 + * @cond + * \defgroup xSemaphoreCreateMutexStatic xSemaphoreCreateMutexStatic + * @endcond * \ingroup Semaphores */ - #if( configSUPPORT_STATIC_ALLOCATION == 1 ) - #define xSemaphoreCreateMutexStatic( pxMutexBuffer ) xQueueCreateMutexStatic( queueQUEUE_TYPE_MUTEX, ( pxMutexBuffer ) ) +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + #define xSemaphoreCreateMutexStatic( pxMutexBuffer ) xQueueCreateMutexStatic( queueQUEUE_TYPE_MUTEX, ( pxMutexBuffer ) ) #endif /* configSUPPORT_STATIC_ALLOCATION */ @@ -796,7 +856,7 @@ typedef QueueHandle_t SemaphoreHandle_t; * service routines. * * @return xSemaphore Handle to the created mutex semaphore. Should be of type - * SemaphoreHandle_t. + * SemaphoreHandle_t. * * Example usage: * @code{c} @@ -818,7 +878,7 @@ typedef QueueHandle_t SemaphoreHandle_t; * \ingroup Semaphores */ #if( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_RECURSIVE_MUTEXES == 1 ) ) - #define xSemaphoreCreateRecursiveMutex() xQueueCreateMutex( queueQUEUE_TYPE_RECURSIVE_MUTEX ) + #define xSemaphoreCreateRecursiveMutex() xQueueCreateMutex( queueQUEUE_TYPE_RECURSIVE_MUTEX ) #endif /** @@ -830,7 +890,7 @@ typedef QueueHandle_t SemaphoreHandle_t; * created using xSemaphoreCreateRecursiveMutex() then the required memory is * automatically dynamically allocated inside the * xSemaphoreCreateRecursiveMutex() function. (see - * http://www.freertos.org/a00111.html). If a recursive mutex is created using + * https://www.FreeRTOS.org/a00111.html). If a recursive mutex is created using * xSemaphoreCreateRecursiveMutexStatic() then the application writer must * provide the memory that will get used by the mutex. * xSemaphoreCreateRecursiveMutexStatic() therefore allows a recursive mutex to @@ -867,7 +927,7 @@ typedef QueueHandle_t SemaphoreHandle_t; * returned. * * Example usage: - * @code + * @code{c} * SemaphoreHandle_t xSemaphore; * StaticSemaphore_t xMutexBuffer; * @@ -886,24 +946,31 @@ typedef QueueHandle_t SemaphoreHandle_t; * @endcode * \ingroup Semaphores */ -#if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_RECURSIVE_MUTEXES == 1 ) ) - #define xSemaphoreCreateRecursiveMutexStatic( pxStaticSemaphore ) xQueueCreateMutexStatic( queueQUEUE_TYPE_RECURSIVE_MUTEX, pxStaticSemaphore ) +#if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_RECURSIVE_MUTEXES == 1 ) ) + #define xSemaphoreCreateRecursiveMutexStatic( pxStaticSemaphore ) xQueueCreateMutexStatic( queueQUEUE_TYPE_RECURSIVE_MUTEX, pxStaticSemaphore ) #endif /* configSUPPORT_STATIC_ALLOCATION */ /** + * @cond + * semphr. h + * @code{c} + * SemaphoreHandle_t xSemaphoreCreateCounting( UBaseType_t uxMaxCount, UBaseType_t uxInitialCount ); + * @endcode + * @endcond + * * Creates a new counting semaphore instance, and returns a handle by which the * new counting semaphore can be referenced. * * In many usage scenarios it is faster and more memory efficient to use a * direct to task notification in place of a counting semaphore! - * http://www.freertos.org/RTOS-task-notifications.html + * https://www.FreeRTOS.org/RTOS-task-notifications.html * * Internally, within the FreeRTOS implementation, counting semaphores use a * block of memory, in which the counting semaphore structure is stored. If a * counting semaphore is created using xSemaphoreCreateCounting() then the * required memory is automatically dynamically allocated inside the * xSemaphoreCreateCounting() function. (see - * http://www.freertos.org/a00111.html). If a counting semaphore is created + * https://www.FreeRTOS.org/a00111.html). If a counting semaphore is created * using xSemaphoreCreateCountingStatic() then the application writer can * instead optionally provide the memory that will get used by the counting * semaphore. xSemaphoreCreateCountingStatic() therefore allows a counting @@ -942,44 +1009,54 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @code{c} - * SemaphoreHandle_t xSemaphore; + * SemaphoreHandle_t xSemaphore; * - * void vATask( void * pvParameters ) - * { - * SemaphoreHandle_t xSemaphore = NULL; + * 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 ); + * // 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. - * } + * if( xSemaphore != NULL ) + * { + * // The semaphore was created successfully. + * // The semaphore can now be used. * } + * } * @endcode + * @cond + * \defgroup xSemaphoreCreateCounting xSemaphoreCreateCounting + * @endcond * \ingroup Semaphores */ -#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - #define xSemaphoreCreateCounting( uxMaxCount, uxInitialCount ) xQueueCreateCountingSemaphore( ( uxMaxCount ), ( uxInitialCount ) ) +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + #define xSemaphoreCreateCounting( uxMaxCount, uxInitialCount ) xQueueCreateCountingSemaphore( ( uxMaxCount ), ( uxInitialCount ) ) #endif /** + * @cond + * semphr. h + * @code{c} + * SemaphoreHandle_t xSemaphoreCreateCountingStatic( UBaseType_t uxMaxCount, UBaseType_t uxInitialCount, StaticSemaphore_t *pxSemaphoreBuffer ); + * @endcode + * @endcond + * * Creates a new counting semaphore instance, and returns a handle by which the * new counting semaphore can be referenced. * * In many usage scenarios it is faster and more memory efficient to use a * direct to task notification in place of a counting semaphore! - * http://www.freertos.org/RTOS-task-notifications.html + * https://www.FreeRTOS.org/RTOS-task-notifications.html * * Internally, within the FreeRTOS implementation, counting semaphores use a * block of memory, in which the counting semaphore structure is stored. If a * counting semaphore is created using xSemaphoreCreateCounting() then the * required memory is automatically dynamically allocated inside the * xSemaphoreCreateCounting() function. (see - * http://www.freertos.org/a00111.html). If a counting semaphore is created + * https://www.FreeRTOS.org/a00111.html). If a counting semaphore is created * using xSemaphoreCreateCountingStatic() then the application writer must * provide the memory. xSemaphoreCreateCountingStatic() therefore allows a * counting semaphore to be created without using any dynamic memory allocation. @@ -1022,42 +1099,62 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @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. - * } + * 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 + * @cond + * \defgroup xSemaphoreCreateCountingStatic xSemaphoreCreateCountingStatic + * @endcond * \ingroup Semaphores */ -#if( configSUPPORT_STATIC_ALLOCATION == 1 ) - #define xSemaphoreCreateCountingStatic( uxMaxCount, uxInitialCount, pxSemaphoreBuffer ) xQueueCreateCountingSemaphoreStatic( ( uxMaxCount ), ( uxInitialCount ), ( pxSemaphoreBuffer ) ) +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + #define xSemaphoreCreateCountingStatic( uxMaxCount, uxInitialCount, pxSemaphoreBuffer ) xQueueCreateCountingSemaphoreStatic( ( uxMaxCount ), ( uxInitialCount ), ( pxSemaphoreBuffer ) ) #endif /* configSUPPORT_STATIC_ALLOCATION */ /** + * @cond + * semphr. h + * @code{c} + * void vSemaphoreDelete( SemaphoreHandle_t xSemaphore ); + * @endcode + * @endcond + * * 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. * + * @cond + * \defgroup vSemaphoreDelete vSemaphoreDelete + * @endcond * \ingroup Semaphores */ -#define vSemaphoreDelete( xSemaphore ) vQueueDelete( ( QueueHandle_t ) ( xSemaphore ) ) +#define vSemaphoreDelete( xSemaphore ) vQueueDelete( ( QueueHandle_t ) ( xSemaphore ) ) /** + * @cond + * semphr.h + * @code{c} + * TaskHandle_t xSemaphoreGetMutexHolder( SemaphoreHandle_t xMutex ); + * @endcode + * @endcond + * * 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. @@ -1067,20 +1164,30 @@ typedef QueueHandle_t SemaphoreHandle_t; * the holder may change between the function exiting and the returned value * being tested. */ -#define xSemaphoreGetMutexHolder( xSemaphore ) xQueueGetMutexHolder( ( xSemaphore ) ) +#define xSemaphoreGetMutexHolder( xSemaphore ) xQueueGetMutexHolder( ( xSemaphore ) ) /** + * @cond + * semphr.h + * @code{c} + * TaskHandle_t xSemaphoreGetMutexHolderFromISR( SemaphoreHandle_t xMutex ); + * @endcode + * @endcond * * 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. * */ -#define xSemaphoreGetMutexHolderFromISR( xSemaphore ) xQueueGetMutexHolderFromISR( ( xSemaphore ) ) +#define xSemaphoreGetMutexHolderFromISR( xSemaphore ) xQueueGetMutexHolderFromISR( ( xSemaphore ) ) /** + * @cond * semphr.h - *
UBaseType_t uxSemaphoreGetCount( SemaphoreHandle_t xSemaphore );
+ * @code{c} + * UBaseType_t uxSemaphoreGetCount( SemaphoreHandle_t xSemaphore ); + * @endcode + * @endcond * * If the semaphore is a counting semaphore then uxSemaphoreGetCount() returns * its current count value. If the semaphore is a binary semaphore then @@ -1088,6 +1195,6 @@ typedef QueueHandle_t SemaphoreHandle_t; * semaphore is not available. * */ -#define uxSemaphoreGetCount( xSemaphore ) uxQueueMessagesWaiting( ( QueueHandle_t ) ( xSemaphore ) ) +#define uxSemaphoreGetCount( xSemaphore ) uxQueueMessagesWaiting( ( QueueHandle_t ) ( xSemaphore ) ) #endif /* SEMAPHORE_H */ diff --git a/tools/sdk/esp32/include/freertos/include/freertos/stack_macros.h b/tools/sdk/esp32/include/freertos/include/freertos/stack_macros.h index b8eca4246f9..249c4ef840d 100644 --- a/tools/sdk/esp32/include/freertos/include/freertos/stack_macros.h +++ b/tools/sdk/esp32/include/freertos/include/freertos/stack_macros.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ #ifndef STACK_MACROS_H @@ -46,94 +45,94 @@ #if( configCHECK_FOR_STACK_OVERFLOW == 0 ) - /* FreeRTOSConfig.h is not set to check for stack overflows. */ - #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() - #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() + /* FreeRTOSConfig.h is not set to check for stack overflows. */ + #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() + #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() #endif /* configCHECK_FOR_STACK_OVERFLOW == 0 */ /*-----------------------------------------------------------*/ #if( configCHECK_FOR_STACK_OVERFLOW == 1 ) - /* FreeRTOSConfig.h is only set to use the first method of - overflow checking. */ - #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() + /* FreeRTOSConfig.h is only set to use the first method of + overflow checking. */ + #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() #endif /*-----------------------------------------------------------*/ #if( ( configCHECK_FOR_STACK_OVERFLOW > 0 ) && ( portSTACK_GROWTH < 0 ) ) - /* Only the current stack state is to be checked. */ - #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() \ - { \ - /* Is the currently saved stack pointer within the stack limit? */ \ - if( pxCurrentTCB[ xPortGetCoreID() ]->pxTopOfStack <= pxCurrentTCB[ xPortGetCoreID() ]->pxStack ) \ - { \ - vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB[ xPortGetCoreID() ], pxCurrentTCB[ xPortGetCoreID() ]->pcTaskName ); \ - } \ - } +/* Only the current stack state is to be checked. */ + #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() \ + { \ + /* Is the currently saved stack pointer within the stack limit? */ \ + if( pxCurrentTCB[ xPortGetCoreID() ]->pxTopOfStack <= pxCurrentTCB[ xPortGetCoreID() ]->pxStack ) \ + { \ + vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB[ xPortGetCoreID() ], pxCurrentTCB[ xPortGetCoreID() ]->pcTaskName ); \ + } \ + } #endif /* configCHECK_FOR_STACK_OVERFLOW > 0 */ /*-----------------------------------------------------------*/ #if( ( configCHECK_FOR_STACK_OVERFLOW > 0 ) && ( portSTACK_GROWTH > 0 ) ) - /* Only the current stack state is to be checked. */ - #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() \ - { \ - \ - /* Is the currently saved stack pointer within the stack limit? */ \ - if( pxCurrentTCB[ xPortGetCoreID() ]->pxTopOfStack >= pxCurrentTCB[ xPortGetCoreID() ]->pxEndOfStack ) \ - { \ - vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB[ xPortGetCoreID() ], pxCurrentTCB[ xPortGetCoreID() ]->pcTaskName ); \ - } \ - } +/* Only the current stack state is to be checked. */ + #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() \ + { \ + \ + /* Is the currently saved stack pointer within the stack limit? */ \ + if( pxCurrentTCB[ xPortGetCoreID() ]->pxTopOfStack >= pxCurrentTCB[ xPortGetCoreID() ]->pxEndOfStack ) \ + { \ + vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB[ xPortGetCoreID() ], pxCurrentTCB[ xPortGetCoreID() ]->pcTaskName ); \ + } \ + } #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ /*-----------------------------------------------------------*/ -#if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) ) - - #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() \ - { \ - static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ - \ - \ - /* Has the extremity of the task stack ever been written over? */ \ - if( memcmp( ( void * ) pxCurrentTCB[ xPortGetCoreID() ]->pxStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ - { \ - vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB[ xPortGetCoreID() ], pxCurrentTCB[ xPortGetCoreID() ]->pcTaskName ); \ - } \ - } +#if ( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) ) + + #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() \ + { \ + static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ + \ + \ + /* Has the extremity of the task stack ever been written over? */ \ + if( memcmp( ( void * ) pxCurrentTCB[ xPortGetCoreID() ]->pxStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ + { \ + vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB[ xPortGetCoreID() ], pxCurrentTCB[ xPortGetCoreID() ]->pcTaskName ); \ + } \ + } #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ /*-----------------------------------------------------------*/ -#if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) ) - - #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() \ - { \ - int8_t *pcEndOfStack = ( int8_t * ) pxCurrentTCB[ xPortGetCoreID() ]->pxEndOfStack; \ - static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ - \ - \ - pcEndOfStack -= sizeof( ucExpectedStackBytes ); \ - \ - /* Has the extremity of the task stack ever been written over? */ \ - if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ - { \ - vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB[ xPortGetCoreID() ], pxCurrentTCB[ xPortGetCoreID() ]->pcTaskName ); \ - } \ - } +#if ( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) ) + + #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() \ + { \ + int8_t *pcEndOfStack = ( int8_t * ) pxCurrentTCB[ xPortGetCoreID() ]->pxEndOfStack; \ + static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ + \ + \ + pcEndOfStack -= sizeof( ucExpectedStackBytes ); \ + \ + /* Has the extremity of the task stack ever been written over? */ \ + if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ + { \ + vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB[ xPortGetCoreID() ], pxCurrentTCB[ xPortGetCoreID() ]->pcTaskName ); \ + } \ + } #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ diff --git a/tools/sdk/esp32/include/freertos/include/freertos/stream_buffer.h b/tools/sdk/esp32/include/freertos/include/freertos/stream_buffer.h index 1a3d8f5190c..9e58cff120c 100644 --- a/tools/sdk/esp32/include/freertos/include/freertos/stream_buffer.h +++ b/tools/sdk/esp32/include/freertos/include/freertos/stream_buffer.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ /* @@ -43,7 +42,7 @@ * (such as xStreamBufferSend()) inside a critical section and set the send * block time to 0. Likewise, if there are to be multiple different readers * then the application writer must place each call to a reading API function - * (such as xStreamBufferRead()) inside a critical section section and set the + * (such as xStreamBufferReceive()) inside a critical section section and set the * receive block time to 0. * */ @@ -52,12 +51,14 @@ #define STREAM_BUFFER_H #ifndef INC_FREERTOS_H - #error "include FreeRTOS.h must appear in source files before include stream_buffer.h" + #error "include FreeRTOS.h must appear in source files before include stream_buffer.h" #endif +/* *INDENT-OFF* */ #if defined( __cplusplus ) -extern "C" { + extern "C" { #endif +/* *INDENT-ON* */ /** * Type by which stream buffers are referenced. For example, a call to @@ -68,7 +69,16 @@ extern "C" { struct StreamBufferDef_t; typedef struct StreamBufferDef_t * StreamBufferHandle_t; + /** + * @cond + * message_buffer.h + * + * @code{c} + * StreamBufferHandle_t xStreamBufferCreate( size_t xBufferSizeBytes, size_t xTriggerLevelBytes ); + * @endcode + * @endcond + * * Creates a new stream buffer using dynamically allocated memory. See * xStreamBufferCreateStatic() for a version that uses statically allocated * memory (memory that is allocated at compile time). @@ -103,32 +113,46 @@ typedef struct StreamBufferDef_t * StreamBufferHandle_t; * Example use: * @code{c} * - * void vAFunction( void ) - * { - * StreamBufferHandle_t xStreamBuffer; - * const size_t xStreamBufferSizeBytes = 100, xTriggerLevel = 10; - * - * // Create a stream buffer that can hold 100 bytes. The memory used to hold - * // both the stream buffer structure and the data in the stream buffer is - * // allocated dynamically. - * xStreamBuffer = xStreamBufferCreate( xStreamBufferSizeBytes, xTriggerLevel ); - * - * if( xStreamBuffer == NULL ) - * { - * // There was not enough heap memory space available to create the - * // stream buffer. - * } - * else - * { - * // The stream buffer was created successfully and can now be used. - * } - * } + * void vAFunction( void ) + * { + * StreamBufferHandle_t xStreamBuffer; + * const size_t xStreamBufferSizeBytes = 100, xTriggerLevel = 10; + * + * // Create a stream buffer that can hold 100 bytes. The memory used to hold + * // both the stream buffer structure and the data in the stream buffer is + * // allocated dynamically. + * xStreamBuffer = xStreamBufferCreate( xStreamBufferSizeBytes, xTriggerLevel ); + * + * if( xStreamBuffer == NULL ) + * { + * // There was not enough heap memory space available to create the + * // stream buffer. + * } + * else + * { + * // The stream buffer was created successfully and can now be used. + * } + * } * @endcode + * @cond + * \defgroup xStreamBufferCreate xStreamBufferCreate + * @endcond * \ingroup StreamBufferManagement */ -#define xStreamBufferCreate( xBufferSizeBytes, xTriggerLevelBytes ) xStreamBufferGenericCreate( xBufferSizeBytes, xTriggerLevelBytes, pdFALSE ) +#define xStreamBufferCreate( xBufferSizeBytes, xTriggerLevelBytes ) xStreamBufferGenericCreate( xBufferSizeBytes, xTriggerLevelBytes, pdFALSE ) /** + * @cond + * stream_buffer.h + * + * @code{c} + * StreamBufferHandle_t xStreamBufferCreateStatic( size_t xBufferSizeBytes, + * size_t xTriggerLevelBytes, + * uint8_t *pucStreamBufferStorageArea, + * StaticStreamBuffer_t *pxStaticStreamBuffer ); + * @endcode + * @endcond + * * Creates a new stream buffer using statically allocated memory. See * xStreamBufferCreate() for a version that uses dynamically allocated memory. * @@ -167,40 +191,55 @@ typedef struct StreamBufferDef_t * StreamBufferHandle_t; * Example use: * @code{c} * - * // Used to dimension the array used to hold the streams. The available space - * // will actually be one less than this, so 999. - * #define STORAGE_SIZE_BYTES 1000 + * // Used to dimension the array used to hold the streams. The available space + * // will actually be one less than this, so 999. + * #define STORAGE_SIZE_BYTES 1000 * - * // Defines the memory that will actually hold the streams within the stream - * // buffer. - * static uint8_t ucStorageBuffer[ STORAGE_SIZE_BYTES ]; + * // Defines the memory that will actually hold the streams within the stream + * // buffer. + * static uint8_t ucStorageBuffer[ STORAGE_SIZE_BYTES ]; * - * // The variable used to hold the stream buffer structure. - * StaticStreamBuffer_t xStreamBufferStruct; + * // The variable used to hold the stream buffer structure. + * StaticStreamBuffer_t xStreamBufferStruct; * - * void MyFunction( void ) - * { - * StreamBufferHandle_t xStreamBuffer; - * const size_t xTriggerLevel = 1; + * void MyFunction( void ) + * { + * StreamBufferHandle_t xStreamBuffer; + * const size_t xTriggerLevel = 1; * - * xStreamBuffer = xStreamBufferCreateStatic( sizeof( ucBufferStorage ), - * xTriggerLevel, - * ucBufferStorage, - * &xStreamBufferStruct ); + * xStreamBuffer = xStreamBufferCreateStatic( sizeof( ucBufferStorage ), + * xTriggerLevel, + * ucBufferStorage, + * &xStreamBufferStruct ); * - * // As neither the pucStreamBufferStorageArea or pxStaticStreamBuffer - * // parameters were NULL, xStreamBuffer will not be NULL, and can be used to - * // reference the created stream buffer in other stream buffer API calls. + * // As neither the pucStreamBufferStorageArea or pxStaticStreamBuffer + * // parameters were NULL, xStreamBuffer will not be NULL, and can be used to + * // reference the created stream buffer in other stream buffer API calls. * - * // Other code that uses the stream buffer can go here. - * } + * // Other code that uses the stream buffer can go here. + * } * * @endcode + * @cond + * \defgroup xStreamBufferCreateStatic xStreamBufferCreateStatic + * @endcond * \ingroup StreamBufferManagement */ -#define xStreamBufferCreateStatic( xBufferSizeBytes, xTriggerLevelBytes, pucStreamBufferStorageArea, pxStaticStreamBuffer ) xStreamBufferGenericCreateStatic( xBufferSizeBytes, xTriggerLevelBytes, pdFALSE, pucStreamBufferStorageArea, pxStaticStreamBuffer ) +#define xStreamBufferCreateStatic( xBufferSizeBytes, xTriggerLevelBytes, pucStreamBufferStorageArea, pxStaticStreamBuffer ) \ + xStreamBufferGenericCreateStatic( xBufferSizeBytes, xTriggerLevelBytes, pdFALSE, pucStreamBufferStorageArea, pxStaticStreamBuffer ) /** + * @cond + * stream_buffer.h + * + * @code{c} + * size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, + * const void *pvTxData, + * size_t xDataLengthBytes, + * TickType_t xTicksToWait ); + * @endcode + * @endcond + * * Sends bytes to a stream buffer. The bytes are copied into the stream buffer. * * ***NOTE***: Uniquely among FreeRTOS objects, the stream buffer @@ -215,7 +254,7 @@ typedef struct StreamBufferDef_t * StreamBufferHandle_t; * (such as xStreamBufferSend()) inside a critical section and set the send * block time to 0. Likewise, if there are to be multiple different readers * then the application writer must place each call to a reading API function - * (such as xStreamBufferRead()) inside a critical section and set the receive + * (such as xStreamBufferReceive()) inside a critical section and set the receive * block time to 0. * * Use xStreamBufferSend() to write to a stream buffer from a task. Use @@ -250,44 +289,58 @@ typedef struct StreamBufferDef_t * StreamBufferHandle_t; * * Example use: * @code{c} - * void vAFunction( StreamBufferHandle_t xStreamBuffer ) - * { - * size_t xBytesSent; - * uint8_t ucArrayToSend[] = { 0, 1, 2, 3 }; - * char *pcStringToSend = "String to send"; - * const TickType_t x100ms = pdMS_TO_TICKS( 100 ); - * - * // Send an array to the stream buffer, blocking for a maximum of 100ms to - * // wait for enough space to be available in the stream buffer. - * xBytesSent = xStreamBufferSend( xStreamBuffer, ( void * ) ucArrayToSend, sizeof( ucArrayToSend ), x100ms ); - * - * if( xBytesSent != sizeof( ucArrayToSend ) ) - * { - * // The call to xStreamBufferSend() times out before there was enough - * // space in the buffer for the data to be written, but it did - * // successfully write xBytesSent bytes. - * } - * - * // Send the string to the stream buffer. Return immediately if there is not - * // enough space in the buffer. - * xBytesSent = xStreamBufferSend( xStreamBuffer, ( void * ) pcStringToSend, strlen( pcStringToSend ), 0 ); - * - * if( xBytesSent != strlen( pcStringToSend ) ) - * { - * // The entire string could not be added to the stream buffer because - * // there was not enough free space in the buffer, but xBytesSent bytes - * // were sent. Could try again to send the remaining bytes. - * } - * } + * void vAFunction( StreamBufferHandle_t xStreamBuffer ) + * { + * size_t xBytesSent; + * uint8_t ucArrayToSend[] = { 0, 1, 2, 3 }; + * char *pcStringToSend = "String to send"; + * const TickType_t x100ms = pdMS_TO_TICKS( 100 ); + * + * // Send an array to the stream buffer, blocking for a maximum of 100ms to + * // wait for enough space to be available in the stream buffer. + * xBytesSent = xStreamBufferSend( xStreamBuffer, ( void * ) ucArrayToSend, sizeof( ucArrayToSend ), x100ms ); + * + * if( xBytesSent != sizeof( ucArrayToSend ) ) + * { + * // The call to xStreamBufferSend() times out before there was enough + * // space in the buffer for the data to be written, but it did + * // successfully write xBytesSent bytes. + * } + * + * // Send the string to the stream buffer. Return immediately if there is not + * // enough space in the buffer. + * xBytesSent = xStreamBufferSend( xStreamBuffer, ( void * ) pcStringToSend, strlen( pcStringToSend ), 0 ); + * + * if( xBytesSent != strlen( pcStringToSend ) ) + * { + * // The entire string could not be added to the stream buffer because + * // there was not enough free space in the buffer, but xBytesSent bytes + * // were sent. Could try again to send the remaining bytes. + * } + * } * @endcode + * @cond + * \defgroup xStreamBufferSend xStreamBufferSend + * @endcond * \ingroup StreamBufferManagement */ size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, - const void *pvTxData, - size_t xDataLengthBytes, - TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; + const void * pvTxData, + size_t xDataLengthBytes, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer, + * const void *pvTxData, + * size_t xDataLengthBytes, + * BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * @endcond + * * Interrupt safe version of the API function that sends a stream of bytes to * the stream buffer. * @@ -303,7 +356,7 @@ size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, * (such as xStreamBufferSend()) inside a critical section and set the send * block time to 0. Likewise, if there are to be multiple different readers * then the application writer must place each call to a reading API function - * (such as xStreamBufferRead()) inside a critical section and set the receive + * (such as xStreamBufferReceive()) inside a critical section and set the receive * block time to 0. * * Use xStreamBufferSend() to write to a stream buffer from a task. Use @@ -339,46 +392,60 @@ size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, * * Example use: * @code{c} - * //A stream buffer that has already been created. - * StreamBufferHandle_t xStreamBuffer; - * - * void vAnInterruptServiceRoutine( void ) - * { - * size_t xBytesSent; - * char *pcStringToSend = "String to send"; - * BaseType_t xHigherPriorityTaskWoken = pdFALSE; // Initialised to pdFALSE. - * - * // Attempt to send the string to the stream buffer. - * xBytesSent = xStreamBufferSendFromISR( xStreamBuffer, - * ( void * ) pcStringToSend, - * strlen( pcStringToSend ), - * &xHigherPriorityTaskWoken ); - * - * if( xBytesSent != strlen( pcStringToSend ) ) - * { - * // There was not enough free space in the stream buffer for the entire - * // string to be written, ut xBytesSent bytes were written. - * } - * - * // If xHigherPriorityTaskWoken was set to pdTRUE inside - * // xStreamBufferSendFromISR() then a task that has a priority above the - * // priority of the currently executing task was unblocked and a context - * // switch should be performed to ensure the ISR returns to the unblocked - * // task. In most FreeRTOS ports this is done by simply passing - * // xHigherPriorityTaskWoken into taskYIELD_FROM_ISR(), which will test the - * // variables value, and perform the context switch if necessary. Check the - * // documentation for the port in use for port specific instructions. - * taskYIELD_FROM_ISR( xHigherPriorityTaskWoken ); - * } + * // A stream buffer that has already been created. + * StreamBufferHandle_t xStreamBuffer; + * + * void vAnInterruptServiceRoutine( void ) + * { + * size_t xBytesSent; + * char *pcStringToSend = "String to send"; + * BaseType_t xHigherPriorityTaskWoken = pdFALSE; // Initialised to pdFALSE. + * + * // Attempt to send the string to the stream buffer. + * xBytesSent = xStreamBufferSendFromISR( xStreamBuffer, + * ( void * ) pcStringToSend, + * strlen( pcStringToSend ), + * &xHigherPriorityTaskWoken ); + * + * if( xBytesSent != strlen( pcStringToSend ) ) + * { + * // There was not enough free space in the stream buffer for the entire + * // string to be written, ut xBytesSent bytes were written. + * } + * + * // If xHigherPriorityTaskWoken was set to pdTRUE inside + * // xStreamBufferSendFromISR() then a task that has a priority above the + * // priority of the currently executing task was unblocked and a context + * // switch should be performed to ensure the ISR returns to the unblocked + * // task. In most FreeRTOS ports this is done by simply passing + * // xHigherPriorityTaskWoken into taskYIELD_FROM_ISR(), which will test the + * // variables value, and perform the context switch if necessary. Check the + * // documentation for the port in use for port specific instructions. + * taskYIELD_FROM_ISR( xHigherPriorityTaskWoken ); + * } * @endcode + * @cond + * \defgroup xStreamBufferSendFromISR xStreamBufferSendFromISR + * @endcond * \ingroup StreamBufferManagement */ size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer, - const void *pvTxData, - size_t xDataLengthBytes, - BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; + const void * pvTxData, + size_t xDataLengthBytes, + BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * size_t xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer, + * void *pvRxData, + * size_t xBufferLengthBytes, + * TickType_t xTicksToWait ); + * @endcode + * @endcond + * * Receives bytes from a stream buffer. * * ***NOTE***: Uniquely among FreeRTOS objects, the stream buffer @@ -393,7 +460,7 @@ size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer, * (such as xStreamBufferSend()) inside a critical section and set the send * block time to 0. Likewise, if there are to be multiple different readers * then the application writer must place each call to a reading API function - * (such as xStreamBufferRead()) inside a critical section and set the receive + * (such as xStreamBufferReceive()) inside a critical section and set the receive * block time to 0. * * Use xStreamBufferReceive() to read from a stream buffer from a task. Use @@ -428,37 +495,50 @@ size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer, * * Example use: * @code{c} - * void vAFunction( StreamBuffer_t xStreamBuffer ) - * { - * uint8_t ucRxData[ 20 ]; - * size_t xReceivedBytes; - * const TickType_t xBlockTime = pdMS_TO_TICKS( 20 ); - * - * // Receive up to another sizeof( ucRxData ) bytes from the stream buffer. - * // Wait in the Blocked state (so not using any CPU processing time) for a - * // maximum of 100ms for the full sizeof( ucRxData ) number of bytes to be - * // available. - * xReceivedBytes = xStreamBufferReceive( xStreamBuffer, - * ( void * ) ucRxData, - * sizeof( ucRxData ), - * xBlockTime ); - * - * if( xReceivedBytes > 0 ) - * { - * // A ucRxData contains another xRecievedBytes bytes of data, which can - * // be processed here.... - * } - * } + * void vAFunction( StreamBuffer_t xStreamBuffer ) + * { + * uint8_t ucRxData[ 20 ]; + * size_t xReceivedBytes; + * const TickType_t xBlockTime = pdMS_TO_TICKS( 20 ); + * + * // Receive up to another sizeof( ucRxData ) bytes from the stream buffer. + * // Wait in the Blocked state (so not using any CPU processing time) for a + * // maximum of 100ms for the full sizeof( ucRxData ) number of bytes to be + * // available. + * xReceivedBytes = xStreamBufferReceive( xStreamBuffer, + * ( void * ) ucRxData, + * sizeof( ucRxData ), + * xBlockTime ); + * + * if( xReceivedBytes > 0 ) + * { + * // A ucRxData contains another xRecievedBytes bytes of data, which can + * // be processed here.... + * } + * } * @endcode + * @cond + * \defgroup xStreamBufferReceive xStreamBufferReceive + * @endcond * \ingroup StreamBufferManagement */ size_t xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer, - void *pvRxData, - size_t xBufferLengthBytes, - TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; - + void * pvRxData, + size_t xBufferLengthBytes, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * size_t xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer, + * void *pvRxData, + * size_t xBufferLengthBytes, + * BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * @endcond + * * An interrupt safe version of the API function that receives bytes from a * stream buffer. * @@ -495,46 +575,57 @@ size_t xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer, * * Example use: * @code{c} - * // A stream buffer that has already been created. - * StreamBuffer_t xStreamBuffer; - * - * void vAnInterruptServiceRoutine( void ) - * { - * uint8_t ucRxData[ 20 ]; - * size_t xReceivedBytes; - * BaseType_t xHigherPriorityTaskWoken = pdFALSE; // Initialised to pdFALSE. - * - * // Receive the next stream from the stream buffer. - * xReceivedBytes = xStreamBufferReceiveFromISR( xStreamBuffer, - * ( void * ) ucRxData, - * sizeof( ucRxData ), - * &xHigherPriorityTaskWoken ); - * - * if( xReceivedBytes > 0 ) - * { - * // ucRxData contains xReceivedBytes read from the stream buffer. - * // Process the stream here.... - * } - * - * // If xHigherPriorityTaskWoken was set to pdTRUE inside - * // xStreamBufferReceiveFromISR() then a task that has a priority above the - * // priority of the currently executing task was unblocked and a context - * // switch should be performed to ensure the ISR returns to the unblocked - * // task. In most FreeRTOS ports this is done by simply passing - * // xHigherPriorityTaskWoken into taskYIELD_FROM_ISR(), which will test the - * // variables value, and perform the context switch if necessary. Check the - * // documentation for the port in use for port specific instructions. - * taskYIELD_FROM_ISR( xHigherPriorityTaskWoken ); - * } + * // A stream buffer that has already been created. + * StreamBuffer_t xStreamBuffer; + * + * void vAnInterruptServiceRoutine( void ) + * { + * uint8_t ucRxData[ 20 ]; + * size_t xReceivedBytes; + * BaseType_t xHigherPriorityTaskWoken = pdFALSE; // Initialised to pdFALSE. + * + * // Receive the next stream from the stream buffer. + * xReceivedBytes = xStreamBufferReceiveFromISR( xStreamBuffer, + * ( void * ) ucRxData, + * sizeof( ucRxData ), + * &xHigherPriorityTaskWoken ); + * + * if( xReceivedBytes > 0 ) + * { + * // ucRxData contains xReceivedBytes read from the stream buffer. + * // Process the stream here.... + * } + * + * // If xHigherPriorityTaskWoken was set to pdTRUE inside + * // xStreamBufferReceiveFromISR() then a task that has a priority above the + * // priority of the currently executing task was unblocked and a context + * // switch should be performed to ensure the ISR returns to the unblocked + * // task. In most FreeRTOS ports this is done by simply passing + * // xHigherPriorityTaskWoken into taskYIELD_FROM_ISR(), which will test the + * // variables value, and perform the context switch if necessary. Check the + * // documentation for the port in use for port specific instructions. + * taskYIELD_FROM_ISR( xHigherPriorityTaskWoken ); + * } * @endcode + * @cond + * \defgroup xStreamBufferReceiveFromISR xStreamBufferReceiveFromISR + * @endcond * \ingroup StreamBufferManagement */ size_t xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer, - void *pvRxData, - size_t xBufferLengthBytes, - BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; + void * pvRxData, + size_t xBufferLengthBytes, + BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * void vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ); + * @endcode + * @endcond + * * Deletes a stream buffer that was previously created using a call to * xStreamBufferCreate() or xStreamBufferCreateStatic(). If the stream * buffer was created using dynamic memory (that is, by xStreamBufferCreate()), @@ -545,11 +636,22 @@ size_t xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer, * * @param xStreamBuffer The handle of the stream buffer to be deleted. * + * @cond + * \defgroup vStreamBufferDelete vStreamBufferDelete + * @endcond * \ingroup StreamBufferManagement */ void vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * BaseType_t xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ); + * @endcode + * @endcond + * * Queries a stream buffer to see if it is full. A stream buffer is full if it * does not have any free space, and therefore cannot accept any more data. * @@ -558,11 +660,22 @@ void vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTI * @return If the stream buffer is full then pdTRUE is returned. Otherwise * pdFALSE is returned. * + * @cond + * \defgroup xStreamBufferIsFull xStreamBufferIsFull + * @endcond * \ingroup StreamBufferManagement */ BaseType_t xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * BaseType_t xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ); + * @endcode + * @endcond + * * Queries a stream buffer to see if it is empty. A stream buffer is empty if * it does not contain any data. * @@ -571,11 +684,22 @@ BaseType_t xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_ * @return If the stream buffer is empty then pdTRUE is returned. Otherwise * pdFALSE is returned. * + * @cond + * \defgroup xStreamBufferIsEmpty xStreamBufferIsEmpty + * @endcond * \ingroup StreamBufferManagement */ BaseType_t xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * BaseType_t xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ); + * @endcode + * @endcond + * * Resets a stream buffer to its initial, empty, state. Any data that was in * the stream buffer is discarded. A stream buffer can only be reset if there * are no tasks blocked waiting to either send to or receive from the stream @@ -587,11 +711,22 @@ BaseType_t xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED * a task blocked waiting to send to or read from the stream buffer then the * stream buffer is not reset and pdFAIL is returned. * + * @cond + * \defgroup xStreamBufferReset xStreamBufferReset + * @endcond * \ingroup StreamBufferManagement */ BaseType_t xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * size_t xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ); + * @endcode + * @endcond + * * Queries a stream buffer to see how much free space it contains, which is * equal to the amount of data that can be sent to the stream buffer before it * is full. @@ -601,12 +736,22 @@ BaseType_t xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_F * @return The number of bytes that can be written to the stream buffer before * the stream buffer would be full. * + * @cond * \defgroup xStreamBufferSpacesAvailable xStreamBufferSpacesAvailable + * @endcond * \ingroup StreamBufferManagement */ size_t xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * size_t xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ); + * @endcode + * @endcond + * * Queries a stream buffer to see how much data it contains, which is equal to * the number of bytes that can be read from the stream buffer before the stream * buffer would be empty. @@ -616,12 +761,22 @@ size_t xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ) PRIVIL * @return The number of bytes that can be read from the stream buffer before * the stream buffer would be empty. * + * @cond * \defgroup xStreamBufferBytesAvailable xStreamBufferBytesAvailable + * @endcond * \ingroup StreamBufferManagement */ size_t xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, size_t xTriggerLevel ); + * @endcode + * @endcond + * * A stream buffer's trigger level is the number of bytes that must be in the * stream buffer before a task that is blocked on the stream buffer to * wait for data is moved out of the blocked state. For example, if a task is @@ -647,11 +802,23 @@ size_t xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ) PRIVILE * then the trigger level will be updated and pdTRUE is returned. Otherwise * pdFALSE is returned. * + * @cond + * \defgroup xStreamBufferSetTriggerLevel xStreamBufferSetTriggerLevel + * @endcond * \ingroup StreamBufferManagement */ -BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, size_t xTriggerLevel ) PRIVILEGED_FUNCTION; +BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, + size_t xTriggerLevel ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * BaseType_t xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * @endcond + * * For advanced users only. * * The sbSEND_COMPLETED() macro is called from within the FreeRTOS APIs when @@ -679,11 +846,23 @@ BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, siz * @return If a task was removed from the Blocked state then pdTRUE is returned. * Otherwise pdFALSE is returned. * + * @cond + * \defgroup xStreamBufferSendCompletedFromISR xStreamBufferSendCompletedFromISR + * @endcond * \ingroup StreamBufferManagement */ -BaseType_t xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; +BaseType_t xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer, + BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * BaseType_t xStreamBufferReceiveCompletedFromISR( StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * @endcond + * * For advanced users only. * * The sbRECEIVE_COMPLETED() macro is called from within the FreeRTOS APIs when @@ -712,34 +891,41 @@ BaseType_t xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer * @return If a task was removed from the Blocked state then pdTRUE is returned. * Otherwise pdFALSE is returned. * + * @cond + * \defgroup xStreamBufferReceiveCompletedFromISR xStreamBufferReceiveCompletedFromISR + * @endcond * \ingroup StreamBufferManagement */ -BaseType_t xStreamBufferReceiveCompletedFromISR( StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; +BaseType_t xStreamBufferReceiveCompletedFromISR( StreamBufferHandle_t xStreamBuffer, + BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; /** @cond */ /* Functions below here are not part of the public API. */ StreamBufferHandle_t xStreamBufferGenericCreate( size_t xBufferSizeBytes, - size_t xTriggerLevelBytes, - BaseType_t xIsMessageBuffer ) PRIVILEGED_FUNCTION; + size_t xTriggerLevelBytes, + BaseType_t xIsMessageBuffer ) PRIVILEGED_FUNCTION; StreamBufferHandle_t xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes, - size_t xTriggerLevelBytes, - BaseType_t xIsMessageBuffer, - uint8_t * const pucStreamBufferStorageArea, - StaticStreamBuffer_t * const pxStaticStreamBuffer ) PRIVILEGED_FUNCTION; + size_t xTriggerLevelBytes, + BaseType_t xIsMessageBuffer, + uint8_t * const pucStreamBufferStorageArea, + StaticStreamBuffer_t * const pxStaticStreamBuffer ) PRIVILEGED_FUNCTION; size_t xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; -#if( configUSE_TRACE_FACILITY == 1 ) - void vStreamBufferSetStreamBufferNumber( StreamBufferHandle_t xStreamBuffer, UBaseType_t uxStreamBufferNumber ) PRIVILEGED_FUNCTION; - UBaseType_t uxStreamBufferGetStreamBufferNumber( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; - uint8_t ucStreamBufferGetStreamBufferType( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; +#if ( configUSE_TRACE_FACILITY == 1 ) + void vStreamBufferSetStreamBufferNumber( StreamBufferHandle_t xStreamBuffer, + UBaseType_t uxStreamBufferNumber ) PRIVILEGED_FUNCTION; + UBaseType_t uxStreamBufferGetStreamBufferNumber( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; + uint8_t ucStreamBufferGetStreamBufferType( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; #endif /** @endcond */ +/* *INDENT-OFF* */ #if defined( __cplusplus ) -} + } #endif +/* *INDENT-ON* */ -#endif /* !defined( STREAM_BUFFER_H ) */ +#endif /* !defined( STREAM_BUFFER_H ) */ diff --git a/tools/sdk/esp32/include/freertos/include/freertos/task.h b/tools/sdk/esp32/include/freertos/include/freertos/task.h index 559945805ee..9135b76f014 100644 --- a/tools/sdk/esp32/include/freertos/include/freertos/task.h +++ b/tools/sdk/esp32/include/freertos/include/freertos/task.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ @@ -30,69 +29,89 @@ #define INC_TASK_H #ifndef INC_FREERTOS_H - #error "include FreeRTOS.h must appear in source files before include task.h" + #error "include FreeRTOS.h must appear in source files before include task.h" #endif #include "list.h" +#ifdef ESP_PLATFORM // IDF-3793 #include "freertos/portmacro.h" +#endif // ESP_PLATFORM +/* *INDENT-OFF* */ #ifdef __cplusplus -extern "C" { + extern "C" { #endif +/* *INDENT-ON* */ /*----------------------------------------------------------- * MACROS AND DEFINITIONS *----------------------------------------------------------*/ -#define tskKERNEL_VERSION_NUMBER "V10.2.1" -#define tskKERNEL_VERSION_MAJOR 10 -#define tskKERNEL_VERSION_MINOR 2 -#define tskKERNEL_VERSION_BUILD 1 +#define tskKERNEL_VERSION_NUMBER "V10.4.3" +#define tskKERNEL_VERSION_MAJOR 10 +#define tskKERNEL_VERSION_MINOR 4 +#define tskKERNEL_VERSION_BUILD 3 /* MPU region parameters passed in ulParameters * of MemoryRegion_t struct. */ -#define tskMPU_REGION_READ_ONLY ( 1UL << 0UL ) -#define tskMPU_REGION_READ_WRITE ( 1UL << 1UL ) -#define tskMPU_REGION_EXECUTE_NEVER ( 1UL << 2UL ) -#define tskMPU_REGION_NORMAL_MEMORY ( 1UL << 3UL ) -#define tskMPU_REGION_DEVICE_MEMORY ( 1UL << 4UL ) +#define tskMPU_REGION_READ_ONLY ( 1UL << 0UL ) +#define tskMPU_REGION_READ_WRITE ( 1UL << 1UL ) +#define tskMPU_REGION_EXECUTE_NEVER ( 1UL << 2UL ) +#define tskMPU_REGION_NORMAL_MEMORY ( 1UL << 3UL ) +#define tskMPU_REGION_DEVICE_MEMORY ( 1UL << 4UL ) + +/* The direct to task notification feature used to have only a single notification + * per task. Now there is an array of notifications per task that is dimensioned by + * configTASK_NOTIFICATION_ARRAY_ENTRIES. For backward compatibility, any use of the + * original direct to task notification defaults to using the first index in the + * array. */ +#define tskDEFAULT_INDEX_TO_NOTIFY ( 0 ) + +#define tskNO_AFFINITY ( 0x7FFFFFFF ) -#define tskNO_AFFINITY ( 0x7FFFFFFF ) /** + * task. h + * * Type by which tasks are referenced. For example, a call to xTaskCreate * returns (via a pointer parameter) an TaskHandle_t variable that can then * be used as a parameter to vTaskDelete to delete the task. * + * @cond + * \defgroup TaskHandle_t TaskHandle_t + * @endcond * \ingroup Tasks */ -struct tskTaskControlBlock; /* The old naming convention is used to prevent breaking kernel aware debuggers. */ -//typedef struct tskTaskControlBlock* TaskHandle_t; +struct tskTaskControlBlock; /* The old naming convention is used to prevent breaking kernel aware debuggers. */ +#ifdef ESP_PLATFORM // IDF-3769 typedef void* TaskHandle_t; +#else +typedef struct tskTaskControlBlock* TaskHandle_t; +#endif // ESP_PLATFORM /** * Defines the prototype to which the application task hook function must * conform. */ -typedef BaseType_t (*TaskHookFunction_t)( void * ); +typedef BaseType_t (* TaskHookFunction_t)( void * ); /** 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. */ - eInvalid /* Used as an 'invalid state' value. */ + 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. */ + eInvalid /* Used as an 'invalid state' value. */ } eTaskState; /* 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 */ @@ -101,8 +120,8 @@ typedef enum */ typedef struct xTIME_OUT { - BaseType_t xOverflowCount; - TickType_t xTimeOnEntering; + BaseType_t xOverflowCount; + TickType_t xTimeOnEntering; } TimeOut_t; /** @@ -110,9 +129,9 @@ typedef struct xTIME_OUT */ typedef struct xMEMORY_REGION { - void *pvBaseAddress; - uint32_t ulLengthInBytes; - uint32_t ulParameters; + void * pvBaseAddress; + uint32_t ulLengthInBytes; + uint32_t ulParameters; } MemoryRegion_t; /* @@ -120,50 +139,36 @@ typedef struct xMEMORY_REGION */ typedef struct xTASK_PARAMETERS { - TaskFunction_t pvTaskCode; - const char * const pcName; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ - configSTACK_DEPTH_TYPE usStackDepth; - void *pvParameters; - UBaseType_t uxPriority; - StackType_t *puxStackBuffer; - MemoryRegion_t xRegions[ portNUM_CONFIGURABLE_REGIONS ]; - #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) - StaticTask_t * const pxTaskBuffer; - #endif + TaskFunction_t pvTaskCode; + const char * const pcName; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + configSTACK_DEPTH_TYPE usStackDepth; + void * pvParameters; + UBaseType_t uxPriority; + StackType_t * puxStackBuffer; + MemoryRegion_t xRegions[ portNUM_CONFIGURABLE_REGIONS ]; + #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) + StaticTask_t * const pxTaskBuffer; + #endif } TaskParameters_t; - -/* - * 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. */ - configSTACK_DEPTH_TYPE 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 https://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. */ + configSTACK_DEPTH_TYPE 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. */ #if configTASKLIST_INCLUDE_COREID - BaseType_t xCoreID; /*!< Core this task is pinned to (0, 1, or -1 for tskNO_AFFINITY). This field is present if CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID is set. */ + BaseType_t xCoreID; /*!< Core this task is pinned to (0, 1, or -1 for tskNO_AFFINITY). This field is present if CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID is set. */ #endif } 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*/ -} TaskSnapshot_t; - /** @endcond */ /** @@ -171,9 +176,9 @@ typedef struct xTASK_SNAPSHOT */ 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; /** @@ -181,61 +186,104 @@ typedef enum * * \ingroup TaskUtils */ -#define tskIDLE_PRIORITY ( ( UBaseType_t ) 0U ) +#define tskIDLE_PRIORITY ( ( UBaseType_t ) 0U ) /** + * task. h + * * Macro for forcing a context switch. * + * @cond + * \defgroup taskYIELD taskYIELD + * @endcond * \ingroup SchedulerControl */ -#define taskYIELD() portYIELD() +#define taskYIELD() portYIELD() /** + * task. h + * * 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) * so must be used with care! * + * @cond + * \defgroup taskENTER_CRITICAL taskENTER_CRITICAL + * @endcond * \ingroup SchedulerControl */ -#define taskENTER_CRITICAL( x ) portENTER_CRITICAL( x ) +#ifdef ESP_PLATFORM +#define taskENTER_CRITICAL( x ) portENTER_CRITICAL( x ) +#else +#define taskENTER_CRITICAL( ) portENTER_CRITICAL( ) +#endif // ESP_PLATFORM #define taskENTER_CRITICAL_FROM_ISR( ) portSET_INTERRUPT_MASK_FROM_ISR() -#define taskENTER_CRITICAL_ISR(mux) portENTER_CRITICAL_ISR(mux) + +#ifdef ESP_PLATFORM +#define taskENTER_CRITICAL_ISR( x ) portENTER_CRITICAL_ISR( x ) +#else +#define taskENTER_CRITICAL_ISR( ) portENTER_CRITICAL_ISR( ) +#endif // ESP_PLATFORM /** + * task. h + * * 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) * so must be used with care! * + * @cond + * \defgroup taskEXIT_CRITICAL taskEXIT_CRITICAL + * @endcond * \ingroup SchedulerControl */ -#define taskEXIT_CRITICAL( x ) portEXIT_CRITICAL( x ) + +#ifdef ESP_PLATFORM +#define taskEXIT_CRITICAL( x ) portEXIT_CRITICAL( x ) +#else +#define taskEXIT_CRITICAL( ) portEXIT_CRITICAL( ) +#endif // ESP_PLATFORM #define taskEXIT_CRITICAL_FROM_ISR( x ) portCLEAR_INTERRUPT_MASK_FROM_ISR( x ) -#define taskEXIT_CRITICAL_ISR(mux) portEXIT_CRITICAL_ISR(mux) +#ifdef ESP_PLATFORM +#define taskEXIT_CRITICAL_ISR( x ) portEXIT_CRITICAL_ISR( x ) +#else +#define taskEXIT_CRITICAL_ISR( ) portEXIT_CRITICAL_ISR( ) +#endif // ESP_PLATFORM /** + * task. h + * * Macro to disable all maskable interrupts. * + * @cond + * \defgroup taskDISABLE_INTERRUPTS taskDISABLE_INTERRUPTS + * @endcond * \ingroup SchedulerControl */ -#define taskDISABLE_INTERRUPTS() portDISABLE_INTERRUPTS() +#define taskDISABLE_INTERRUPTS() portDISABLE_INTERRUPTS() /** + * task. h + * * Macro to enable microcontroller interrupts. * + * @cond + * \defgroup taskENABLE_INTERRUPTS taskENABLE_INTERRUPTS + * @endcond * \ingroup SchedulerControl */ -#define taskENABLE_INTERRUPTS() portENABLE_INTERRUPTS() +#define taskENABLE_INTERRUPTS() portENABLE_INTERRUPTS() /* Definitions returned by xTaskGetSchedulerState(). taskSCHEDULER_SUSPENDED is -0 to generate more optimal code when configASSERT() is defined as the constant -is used in assert() statements. */ -#define taskSCHEDULER_SUSPENDED ( ( BaseType_t ) 0 ) -#define taskSCHEDULER_NOT_STARTED ( ( BaseType_t ) 1 ) -#define taskSCHEDULER_RUNNING ( ( BaseType_t ) 2 ) + * 0 to generate more optimal code when configASSERT() is defined as the constant + * is used in assert() statements. */ +#define taskSCHEDULER_SUSPENDED ( ( BaseType_t ) 0 ) +#define taskSCHEDULER_NOT_STARTED ( ( BaseType_t ) 1 ) +#define taskSCHEDULER_RUNNING ( ( BaseType_t ) 2 ) /*----------------------------------------------------------- @@ -283,13 +331,13 @@ is used in assert() statements. */ * \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); + 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 @@ -301,7 +349,7 @@ is used in assert() statements. */ * second block is used by the task as its stack. If a task is created using * xTaskCreate() then both blocks of memory are automatically dynamically * allocated inside the xTaskCreate() function. (see - * http://www.freertos.org/a00111.html). If a task is created using + * https://www.FreeRTOS.org/a00111.html). If a task is created using * xTaskCreateStatic() then the application writer must provide the required * memory. xTaskCreateStatic() therefore allows a task to be created without * using any dynamic memory allocation. @@ -345,50 +393,52 @@ is used in assert() statements. */ * * Example usage: * @code{c} - * // Task to be created. - * void vTaskCode( void * pvParameters ) - * { + * // 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; + * // 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 ); + * configASSERT( xHandle ); * * // Use the handle to delete the task. - * if( xHandle != NULL ) - * { - * vTaskDelete( xHandle ); - * } - * } + * if( xHandle != NULL ) + * { + * vTaskDelete( xHandle ); + * } + * } * @endcode + * @cond + * \defgroup xTaskCreate xTaskCreate + * @endcond * \ingroup Tasks */ +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) -#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - - 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 ); - } + 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 @@ -439,14 +489,14 @@ is used in assert() statements. */ * \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 ); + 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 */ /** @@ -497,71 +547,80 @@ is used in assert() statements. */ * Example usage: * @code{c} * - * // Dimensions the buffer that the task being created will use as its stack. - * // NOTE: This is the number of bytes the stack will hold, not the number of - * // words as found in vanilla FreeRTOS. - * #define STACK_SIZE 200 + * // Dimensions the buffer that the task being created will use as its stack. + * // NOTE: This is the number of bytes the stack will hold, not the number of + * // words as found in vanilla FreeRTOS. + * #define STACK_SIZE 200 * - * // Structure that will hold the TCB of the task being created. - * StaticTask_t xTaskBuffer; + * // 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 ]; + * // 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 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 ); * - * // 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 bytes, not words. - * ( 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 ); - * } + * 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 bytes, not words. + * ( 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 ) - 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 ); - } + 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 + * @code{c} + * BaseType_t xTaskCreateRestricted( TaskParameters_t *pxTaskDefinition, TaskHandle_t *pxCreatedTask ); + * @endcode + * @endcond + * + * Only available when configSUPPORT_DYNAMIC_ALLOCATION is set to 1. + * * xTaskCreateRestricted() should only be used in systems that include an MPU * implementation. * @@ -572,12 +631,12 @@ is used in assert() statements. */ * See xTaskCreateRestrictedStatic() for a version that does not use any * dynamic memory allocation. * - * param pxTaskDefinition Pointer to a structure that contains a member + * @param pxTaskDefinition Pointer to a structure that contains a member * for each of the normal xTaskCreate() parameters (see the xTaskCreate() API * documentation) plus an optional stack buffer and the memory region * definitions. * - * param pxCreatedTask Used to pass back a handle by which the created task + * @param pxCreatedTask Used to pass back a handle by which the created task * can be referenced. * * return pdPASS if the task was successfully created and added to a ready @@ -588,54 +647,65 @@ is used in assert() statements. */ * // 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 } - * } + * 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 ); + * // 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(); + * // Start the scheduler. + * vTaskStartScheduler(); * - * // Will only get here if there was insufficient memory to create the idle - * // and/or timer task. - * for( ;; ); + * // Will only get here if there was insufficient memory to create the idle + * // and/or timer task. + * for( ;; ); * } * @endcode + * @cond + * \defgroup xTaskCreateRestricted xTaskCreateRestricted + * @endcond * \ingroup Tasks */ -#if( portUSING_MPU_WRAPPERS == 1 ) - BaseType_t xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ); +#if ( portUSING_MPU_WRAPPERS == 1 ) + BaseType_t xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition, + TaskHandle_t * pxCreatedTask ); #endif -/* - * xTaskCreateRestrictedStatic() should only be used in systems that include an - * MPU implementation. +/** + * @cond + * task. h + * @code{c} + * BaseType_t xTaskCreateRestrictedStatic( TaskParameters_t *pxTaskDefinition, TaskHandle_t *pxCreatedTask ); + * @endcode + * @endcond * * Only available when configSUPPORT_STATIC_ALLOCATION is set to 1. * + * xTaskCreateRestrictedStatic() should only be used in systems that include an + * MPU implementation. + * * Internally, within the FreeRTOS implementation, tasks use two blocks of * memory. The first block is used to hold the task's data structures. The * second block is used by the task as its stack. If a task is created using @@ -647,14 +717,14 @@ is used in assert() statements. */ * xTaskCreateRestrictedStatic() therefore allows a memory protected task to be * created without using any dynamic memory allocation. * - * param pxTaskDefinition Pointer to a structure that contains a member + * @param pxTaskDefinition Pointer to a structure that contains a member * for each of the normal xTaskCreate() parameters (see the xTaskCreate() API * documentation) plus an optional stack buffer and the memory region * definitions. If configSUPPORT_STATIC_ALLOCATION is set to 1 the structure * contains an additional member, which is used to point to a variable of type * StaticTask_t - which is then used to hold the task's data structure. * - * param pxCreatedTask Used to pass back a handle by which the created task + * @param pxCreatedTask Used to pass back a handle by which the created task * can be referenced. * * return pdPASS if the task was successfully created and added to a ready @@ -669,62 +739,72 @@ is used in assert() statements. */ * static PRIVILEGED_DATA StaticTask_t xTaskBuffer; * 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 BYTES. - * 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 } - * } - * - * &xTaskBuffer; // Holds the task's data structure. + * 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 BYTES. + * 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 } + * } + * + * &xTaskBuffer; // Holds the task's data structure. * }; * * 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 ); + * // 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(); + * // Start the scheduler. + * vTaskStartScheduler(); * - * // Will only get here if there was insufficient memory to create the idle - * // and/or timer task. - * for( ;; ); + * // Will only get here if there was insufficient memory to create the idle + * // and/or timer task. + * for( ;; ); * } * @endcode + * @cond + * \defgroup xTaskCreateRestrictedStatic xTaskCreateRestrictedStatic + * @endcond * \ingroup Tasks */ -#if( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) - BaseType_t xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ); +#if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) + BaseType_t xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition, + TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION; #endif -/* +/** + * @cond + * task. h + * @code{c} + * void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions ); + * @endcode + * @endcond + * * 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(). * - * param xTask The handle of the task being updated. + * @param xTask The handle of the task being updated. * - * param pxRegions A pointer to an MemoryRegion_t structure that contains the + * @param pxRegions A pointer to an MemoryRegion_t structure that contains the * new memory region definitions. * * Example usage: - * * @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 @@ -732,38 +812,49 @@ is used in assert() statements. */ * // 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 } + * // 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). + * // 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 + * @cond + * \defgroup xTaskCreateRestricted xTaskCreateRestricted + * @endcond * \ingroup Tasks */ -void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions ) PRIVILEGED_FUNCTION; +void vTaskAllocateMPURegions( TaskHandle_t xTask, + const MemoryRegion_t * const pxRegions ) PRIVILEGED_FUNCTION; /** - * 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. + * @cond + * task. h + * @code{c} + * void vTaskDelete( TaskHandle_t xTask ); + * @endcode + * @endcond * * 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 * memory from tasks that have been deleted. It is therefore important that * the idle task is not starved of microcontroller processing time if your @@ -779,17 +870,20 @@ void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const p * * Example usage: * @code{c} - * void vOtherFunction( void ) - * { - * TaskHandle_t xHandle; + * void vOtherFunction( void ) + * { + * TaskHandle_t xHandle; * - * // Create the task, storing the handle. - * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &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 ); - * } + * // Use the handle to delete the task. + * vTaskDelete( xHandle ); + * } * @endcode + * @cond + * \defgroup vTaskDelete vTaskDelete + * @endcond * \ingroup Tasks */ void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION; @@ -799,7 +893,10 @@ void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION; *----------------------------------------------------------*/ /** - * Delay a task for a given number of ticks. + * task. h + * @code{c} + * void vTaskDelay( const TickType_t xTicksToDelay ); + * @endcode * * Delay a task for a given number of ticks. The actual time that the * task remains blocked depends on the tick rate. The constant @@ -809,6 +906,7 @@ void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION; * 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 @@ -816,7 +914,7 @@ void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION; * of controlling the frequency of a periodic task as the path taken through the * code, as well as other task and interrupt activity, will effect the frequency * at which vTaskDelay() gets called and therefore the time at which the task - * next executes. See vTaskDelayUntil() for an alternative API function designed + * next executes. See xTaskDelayUntil() for an alternative API function designed * to facilitate fixed frequency execution. It does this by specifying an * absolute time (rather than a relative time) at which the calling task should * unblock. @@ -826,27 +924,34 @@ void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION; * * Example usage: * @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 ); - * } - * } + * 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 + * + * @cond + * \defgroup vTaskDelay vTaskDelay + * @endcond * \ingroup TaskCtrl */ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION; /** - * Delay a task until a specified time. + * task. h + * @code{c} + * BaseType_t xTaskDelayUntil( TickType_t *pxPreviousWakeTime, const TickType_t xTimeIncrement ); + * @endcode * - * INCLUDE_vTaskDelayUntil must be defined as 1 for this function to be available. + * INCLUDE_xTaskDelayUntil 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 @@ -861,46 +966,73 @@ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION; * each time it executes]. * * Whereas vTaskDelay () specifies a wake time relative to the time at which the function - * is called, vTaskDelayUntil () specifies the absolute (exact) time at which it wishes to + * is called, xTaskDelayUntil () specifies the absolute (exact) time at which it wishes to * unblock. * - * The constant portTICK_PERIOD_MS can be used to calculate real time from the tick - * rate - with the resolution of one tick period. + * The macro pdMS_TO_TICKS() can be used to calculate the number of ticks from a + * time specified in milliseconds with a resolution of one tick period. * * @param pxPreviousWakeTime Pointer to a variable that holds the time at which the * task was last unblocked. The variable must be initialised with the current time * prior to its first use (see the example below). Following this the variable is - * automatically updated within vTaskDelayUntil (). + * automatically updated within xTaskDelayUntil (). * * @param xTimeIncrement The cycle time period. The task will be unblocked at - * time *pxPreviousWakeTime + xTimeIncrement. Calling vTaskDelayUntil with the + * time *pxPreviousWakeTime + xTimeIncrement. Calling xTaskDelayUntil with the * same xTimeIncrement parameter value will cause the task to execute with * a fixed interface period. * + * @return Value which can be used to check whether the task was actually delayed. + * Will be pdTRUE if the task way delayed and pdFALSE otherwise. A task will not + * be delayed if the next expected wake time is in the past. + * * Example usage: * @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. - * } - * } + * // Perform an action every 10 ticks. + * void vTaskFunction( void * pvParameters ) + * { + * TickType_t xLastWakeTime; + * const TickType_t xFrequency = 10; + * BaseType_t xWasDelayed; + * + * // Initialise the xLastWakeTime variable with the current time. + * xLastWakeTime = xTaskGetTickCount (); + * for( ;; ) + * { + * // Wait for the next cycle. + * xWasDelayed = xTaskDelayUntil( &xLastWakeTime, xFrequency ); + * + * // Perform action here. xWasDelayed value can be used to determine + * // whether a deadline was missed if the code here took too long. + * } + * } * @endcode + * @cond + * \defgroup xTaskDelayUntil xTaskDelayUntil + * @endcond * \ingroup TaskCtrl */ -void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION; +BaseType_t xTaskDelayUntil( TickType_t * const pxPreviousWakeTime, + const TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION; + +/* + * vTaskDelayUntil() is the older version of xTaskDelayUntil() and does not + * return a value. + */ +#define vTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ) \ +{ \ + ( void ) xTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ); \ +} + /** + * @cond + * task. h + * @code{c} + * BaseType_t xTaskAbortDelay( TaskHandle_t xTask ); + * @endcode + * @endcond + * * INCLUDE_xTaskAbortDelay must be defined as 1 in FreeRTOSConfig.h for this * function to be available. * @@ -912,22 +1044,36 @@ void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xT * task will leave the Blocked state, and return from whichever function call * placed the task into the Blocked state. * + * There is no 'FromISR' version of this function as an interrupt would need to + * know which object a task was blocked on in order to know which actions to + * take. For example, if the task was blocked on a queue the interrupt handler + * would then need to know if the queue was locked. + * * @param xTask The handle of the task to remove from the Blocked state. * * @return If the task referenced by xTask was not in the Blocked state then * pdFAIL is returned. Otherwise pdPASS is returned. * + * @cond * \defgroup xTaskAbortDelay xTaskAbortDelay + * @endcond * \ingroup TaskCtrl */ BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; /** - * Obtain the priority of any task. + * @cond + * task. h + * @code{c} + * UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask ); + * @endcode + * @endcond * * 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. * @@ -935,9 +1081,9 @@ BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; * * Example usage: * @code{c} - * void vAFunction( void ) - * { - * TaskHandle_t xHandle; + * void vAFunction( void ) + * { + * TaskHandle_t xHandle; * * // Create a task, storing the handle. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle ); @@ -961,23 +1107,39 @@ BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; * } * } * @endcode + * @cond + * \defgroup uxTaskPriorityGet uxTaskPriorityGet + * @endcond * \ingroup TaskCtrl */ UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION; /** + * @cond + * task. h + * @code{c} + * UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask ); + * @endcode + * @endcond + * * A version of uxTaskPriorityGet() that can be used from an ISR. */ UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION; /** - * Obtain the state of any task. - * - * States are encoded by the eTaskState enumerated type. + * @cond + * task. h + * @code{c} + * eTaskState eTaskGetState( TaskHandle_t xTask ); + * @endcode + * @endcond * * 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 @@ -987,11 +1149,17 @@ UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask ) PRIVILEGED_FUNC eTaskState eTaskGetState( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; /** - * Populates a TaskStatus_t structure with information about a task. + * @cond + * task. h + * @code{c} + * void vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState ); + * @endcode + * @endcond * * configUSE_TRACE_FACILITY must be defined as 1 for this function to be * available. See the configuration section for more information. * + * Populates a TaskStatus_t structure with information about a task. * * @param xTask Handle of the task being queried. If xTask is NULL then * information will be returned about the calling task. @@ -1022,29 +1190,42 @@ eTaskState eTaskGetState( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; * TaskHandle_t xHandle; * TaskStatus_t xTaskDetails; * - * // Obtain the handle of a task from its name. - * xHandle = xTaskGetHandle( "Task_Name" ); + * // Obtain the handle of a task from its name. + * xHandle = xTaskGetHandle( "Task_Name" ); * - * // Check the handle is not NULL. - * configASSERT( xHandle ); + * // Check the handle is not NULL. + * configASSERT( xHandle ); * - * // Use the handle to obtain further information about the task. - * vTaskGetInfo( xHandle, - * &xTaskDetails, - * pdTRUE, // Include the high water mark in xTaskDetails. - * eInvalid ); // Include the task state in xTaskDetails. + * // Use the handle to obtain further information about the task. + * vTaskGetInfo( xHandle, + * &xTaskDetails, + * pdTRUE, // Include the high water mark in xTaskDetails. + * eInvalid ); // Include the task state in xTaskDetails. * } * @endcode + * @cond + * \defgroup vTaskGetInfo vTaskGetInfo + * @endcond * \ingroup TaskCtrl */ -void vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState ) PRIVILEGED_FUNCTION; +void vTaskGetInfo( TaskHandle_t xTask, + TaskStatus_t * pxTaskStatus, + BaseType_t xGetFreeStackSpace, + eTaskState eState ) PRIVILEGED_FUNCTION; /** - * Set the priority of any task. + * @cond + * task. h + * @code{c} + * void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority ); + * @endcode + * @endcond * * 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. * @@ -1055,9 +1236,9 @@ void vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xG * * Example usage: * @code{c} - * void vAFunction( void ) - * { - * TaskHandle_t xHandle; + * void vAFunction( void ) + * { + * TaskHandle_t xHandle; * * // Create a task, storing the handle. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle ); @@ -1071,14 +1252,23 @@ void vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xG * * // Use a NULL handle to raise our priority to the same value. * vTaskPrioritySet( NULL, tskIDLE_PRIORITY + 1 ); - * } + * } * @endcode + * @cond + * \defgroup vTaskPrioritySet vTaskPrioritySet + * @endcond * \ingroup TaskCtrl */ -void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority ) PRIVILEGED_FUNCTION; +void vTaskPrioritySet( TaskHandle_t xTask, + UBaseType_t uxNewPriority ) PRIVILEGED_FUNCTION; /** - * Suspend a task. + * @cond + * task. h + * @code{c} + * void vTaskSuspend( TaskHandle_t xTaskToSuspend ); + * @endcode + * @endcond * * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available. * See the configuration section for more information. @@ -1095,9 +1285,9 @@ void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority ) PRIVILEGE * * Example usage: * @code{c} - * void vAFunction( void ) - * { - * TaskHandle_t xHandle; + * void vAFunction( void ) + * { + * TaskHandle_t xHandle; * * // Create a task, storing the handle. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle ); @@ -1120,18 +1310,28 @@ void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority ) PRIVILEGE * * // We cannot get here unless another task calls vTaskResume * // with our handle as the parameter. - * } + * } * @endcode + * @cond + * \defgroup vTaskSuspend vTaskSuspend + * @endcond * \ingroup TaskCtrl */ void vTaskSuspend( TaskHandle_t xTaskToSuspend ) PRIVILEGED_FUNCTION; /** - * Resumes a suspended task. + * @cond + * task. h + * @code{c} + * void vTaskResume( TaskHandle_t xTaskToResume ); + * @endcode + * @endcond * * 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 (). @@ -1140,9 +1340,9 @@ void vTaskSuspend( TaskHandle_t xTaskToSuspend ) PRIVILEGED_FUNCTION; * * Example usage: * @code{c} - * void vAFunction( void ) - * { - * TaskHandle_t xHandle; + * void vAFunction( void ) + * { + * TaskHandle_t xHandle; * * // Create a task, storing the handle. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle ); @@ -1165,18 +1365,28 @@ void vTaskSuspend( TaskHandle_t xTaskToSuspend ) PRIVILEGED_FUNCTION; * * // The created task will once again get microcontroller processing * // time in accordance with its priority within the system. - * } + * } * @endcode + * @cond + * \defgroup vTaskResume vTaskResume + * @endcond * \ingroup TaskCtrl */ void vTaskResume( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION; /** - * An implementation of vTaskResume() that can be called from within an ISR. + * @cond + * task. h + * @code{c} + * void xTaskResumeFromISR( TaskHandle_t xTaskToResume ); + * @endcode + * @endcond * * 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 (). @@ -1192,6 +1402,9 @@ 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. * + * @cond + * \defgroup vTaskResumeFromISR vTaskResumeFromISR + * @endcond * \ingroup TaskCtrl */ BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION; @@ -1201,21 +1414,27 @@ BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION; *----------------------------------------------------------*/ /** @cond */ /** - * Starts the real time kernel tick processing. + * @cond + * task. h + * @code{c} + * void vTaskStartScheduler( void ); + * @endcode + * @endcond * + * Starts the real time kernel tick processing. After calling the kernel + * has control over which tasks are executed and when. + * NOTE: In ESP-IDF the scheduler is started automatically during * application startup, vTaskStartScheduler() should not be called from * ESP-IDF applications. * - * 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: * @code{c} - * void vAFunction( void ) - * { + * void vAFunction( void ) + * { * // Create at least one task before starting the kernel. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL ); * @@ -1223,15 +1442,23 @@ BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION; * vTaskStartScheduler (); * * // Will not get here unless a task calls vTaskEndScheduler () - * } + * } * @endcode * + * @cond + * \defgroup vTaskStartScheduler vTaskStartScheduler + * @endcond * \ingroup SchedulerControl */ void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION; /** - * Stops the real time kernel tick. + * @cond + * task. h + * @code{c} + * void vTaskEndScheduler( void ); + * @endcode + * @endcond * * NOTE: At the time of writing only the x86 real mode port, which runs on a PC * in place of DOS, implements this function. @@ -1254,8 +1481,8 @@ void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION; * * Example usage: * @code{c} - * void vTaskCode( void * pvParameters ) - * { + * void vTaskCode( void * pvParameters ) + * { * for( ;; ) * { * // Task code goes here. @@ -1264,10 +1491,10 @@ void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION; * // so call ... * vTaskEndScheduler (); * } - * } + * } * - * void vAFunction( void ) - * { + * void vAFunction( void ) + * { * // Create at least one task before starting the kernel. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL ); * @@ -1277,8 +1504,12 @@ void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION; * // Will only get here when the vTaskCode () task has called * // vTaskEndScheduler (). When we get here we are back to single task * // execution. - * } + * } * @endcode + * + * @cond + * \defgroup vTaskEndScheduler vTaskEndScheduler + * @endcond * \ingroup SchedulerControl */ void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION; @@ -1286,9 +1517,15 @@ void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION; /** @endcond */ /** - * Suspends the scheduler without disabling interrupts. + * @cond + * task. h + * @code{c} + * void vTaskSuspendAll( void ); + * @endcode + * @endcond * - * Context switches will not occur while the scheduler is suspended. + * Suspends the scheduler without disabling interrupts. 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 @@ -1300,8 +1537,8 @@ void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION; * * Example usage: * @code{c} - * void vTask1( void * pvParameters ) - * { + * void vTask1( void * pvParameters ) + * { * for( ;; ) * { * // Task code goes here. @@ -1327,13 +1564,23 @@ void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION; * // The operation is complete. Restart the kernel. * xTaskResumeAll (); * } - * } + * } * @endcode + * @cond + * \defgroup vTaskSuspendAll vTaskSuspendAll + * @endcond * \ingroup SchedulerControl */ void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION; /** + * @cond + * task. h + * @code{c} + * BaseType_t xTaskResumeAll( void ); + * @endcode + * @endcond + * * Resumes scheduler activity after it was suspended by a call to * vTaskSuspendAll(). * @@ -1341,12 +1588,12 @@ void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION; * that were previously suspended by a call to vTaskSuspend(). * * @return If resuming the scheduler caused a context switch then pdTRUE is - * returned, otherwise pdFALSE is returned. + * returned, otherwise pdFALSE is returned. * * Example usage: * @code{c} - * void vTask1( void * pvParameters ) - * { + * void vTask1( void * pvParameters ) + * { * for( ;; ) * { * // Task code goes here. @@ -1377,8 +1624,11 @@ void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION; * taskYIELD (); * } * } - * } + * } * @endcode + * @cond + * \defgroup xTaskResumeAll xTaskResumeAll + * @endcond * \ingroup SchedulerControl */ BaseType_t xTaskResumeAll( void ) PRIVILEGED_FUNCTION; @@ -1388,16 +1638,29 @@ BaseType_t xTaskResumeAll( void ) PRIVILEGED_FUNCTION; *----------------------------------------------------------*/ /** - * Get tick count + * @cond + * task. h + * @code{c} + * TickType_t xTaskGetTickCount( void ); + * @endcode + * @endcond * * @return The count of ticks since vTaskStartScheduler was called. * + * @cond + * \defgroup xTaskGetTickCount xTaskGetTickCount + * @endcond * \ingroup TaskUtils */ TickType_t xTaskGetTickCount( void ) PRIVILEGED_FUNCTION; /** - * Get tick count from ISR + * @cond + * task. h + * @code{c} + * TickType_t xTaskGetTickCountFromISR( void ); + * @endcode + * @endcond * * @return The count of ticks since vTaskStartScheduler was called. * @@ -1406,44 +1669,73 @@ TickType_t xTaskGetTickCount( void ) PRIVILEGED_FUNCTION; * microcontroller being used or interrupt nesting is either not supported or * not being used. * + * @cond + * \defgroup xTaskGetTickCountFromISR xTaskGetTickCountFromISR + * @endcond * \ingroup TaskUtils */ TickType_t xTaskGetTickCountFromISR( void ) PRIVILEGED_FUNCTION; /** - * Get current number of tasks + * @cond + * task. h + * @code{c} + * uint16_t uxTaskGetNumberOfTasks( void ); + * @endcode + * @endcond * * @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. * + * @cond + * \defgroup uxTaskGetNumberOfTasks uxTaskGetNumberOfTasks + * @endcond * \ingroup TaskUtils */ UBaseType_t uxTaskGetNumberOfTasks( void ) PRIVILEGED_FUNCTION; /** - * Get task name + * @cond + * task. h + * @code{c} + * char *pcTaskGetName( TaskHandle_t xTaskToQuery ); + * @endcode + * @endcond * * @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. * + * @cond + * \defgroup pcTaskGetName pcTaskGetName + * @endcond * \ingroup TaskUtils */ -char *pcTaskGetName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ +char * pcTaskGetName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ /** - * @note This function takes a relatively long time to complete and should be + * @cond + * task. h + * @code{c} + * TaskHandle_t xTaskGetHandle( const char *pcNameToQuery ); + * @endcode + * @endcond + * + * NOTE: This function takes a relatively long time to complete and should be * used sparingly. * * @return The handle of the task that has the human readable name pcNameToQuery. * NULL is returned if no matching name is found. INCLUDE_xTaskGetHandle * must be set to 1 in FreeRTOSConfig.h for pcTaskGetHandle() to be available. * + * @cond + * \defgroup pcTaskGetHandle pcTaskGetHandle + * @endcond * \ingroup TaskUtils */ -TaskHandle_t xTaskGetHandle( const char *pcNameToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ +TaskHandle_t xTaskGetHandle( const char * pcNameToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ /** * Returns the high water mark of the stack associated with xTask. @@ -1513,109 +1805,195 @@ configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) PRIVIL uint8_t* pxTaskGetStackStart( TaskHandle_t xTask) PRIVILEGED_FUNCTION; /* When using trace macros it is sometimes necessary to include task.h before -FreeRTOS.h. When this is done TaskHookFunction_t will not yet have been defined, -so the following two prototypes will cause a compilation error. This can be -fixed by simply guarding against the inclusion of these two prototypes unless -they are explicitly required by the configUSE_APPLICATION_TASK_TAG configuration -constant. */ + * FreeRTOS.h. When this is done TaskHookFunction_t will not yet have been defined, + * so the following two prototypes will cause a compilation error. This can be + * fixed by simply guarding against the inclusion of these two prototypes unless + * they are explicitly required by the configUSE_APPLICATION_TASK_TAG configuration + * constant. */ #ifdef configUSE_APPLICATION_TASK_TAG - #if configUSE_APPLICATION_TASK_TAG == 1 - /** - * Sets pxHookFunction to be the task hook function used by the task xTask. - * @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; - - /** - * - * Returns the pxHookFunction value assigned to the task xTask. Do not - * call from an interrupt service routine - call - * xTaskGetApplicationTaskTagFromISR() instead. - */ - TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; - - /** - * - * Returns the pxHookFunction value assigned to the task xTask. Can - * be called from an interrupt service routine. - */ - TaskHookFunction_t xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; - #endif /* configUSE_APPLICATION_TASK_TAG ==1 */ + #if configUSE_APPLICATION_TASK_TAG == 1 +/** + * @cond + * task.h + * @code{c} + * void vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction ); + * @endcode + * @endcond + * + * Sets pxHookFunction to be the task hook function used by the task xTask. + * @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; + +/** + * @cond + * task.h + * @code{c} + * void xTaskGetApplicationTaskTag( TaskHandle_t xTask ); + * @endcode + * @endcond + * + * Returns the pxHookFunction value assigned to the task xTask. Do not + * call from an interrupt service routine - call + * xTaskGetApplicationTaskTagFromISR() instead. + */ + TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; + +/** + * @cond + * task.h + * @code{c} + * void xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask ); + * @endcode + * @endcond + * + * Returns the pxHookFunction value assigned to the task xTask. Can + * be called from an interrupt service routine. + */ + TaskHookFunction_t xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; + #endif /* configUSE_APPLICATION_TASK_TAG ==1 */ #endif /* ifdef configUSE_APPLICATION_TASK_TAG */ -#if( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) - - /** - * 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 ) - - /** - * 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 +#if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) + + /** + * 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 ) + + /** + * 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 +#if ( configCHECK_FOR_STACK_OVERFLOW > 0 ) + + /** + * @cond + * task.h + * @code{c} + * void vApplicationStackOverflowHook( TaskHandle_t xTask char *pcTaskName); + * @endcode + * @endcond + * The application stack overflow hook is called when a stack overflow is detected for a task. + * + * Details on stack overflow detection can be found here: https://www.FreeRTOS.org/Stacks-and-stack-overflow-checking.html + * + * @param xTask the task that just exceeded its stack boundaries. + * @param pcTaskName A character string containing the name of the offending task. + */ + void vApplicationStackOverflowHook( TaskHandle_t xTask, + char * pcTaskName ); + +#endif + +#if ( configUSE_TICK_HOOK > 0 ) + /** + * @cond + * task.h + * @code{c} + * void vApplicationTickHook( void ); + * @endcode + * @endcond + * + * This hook function is called in the system tick handler after any OS work is completed. + */ + void vApplicationTickHook( void ); /*lint !e526 Symbol not defined as it is an application callback. */ + +#endif + +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + /** + * @cond + * task.h + * @code{c} + * void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ) + * @endcode + * @endcond + * This function is used to provide a statically allocated block of memory to FreeRTOS to hold the Idle Task TCB. This function is required when + * configSUPPORT_STATIC_ALLOCATION is set. For more information see this URI: https://www.FreeRTOS.org/a00110.html#configSUPPORT_STATIC_ALLOCATION + * + * @param ppxIdleTaskTCBBuffer A handle to a statically allocated TCB buffer + * @param ppxIdleTaskStackBuffer A handle to a statically allocated Stack buffer for thie idle task + * @param pulIdleTaskStackSize A pointer to the number of elements that will fit in the allocated stack buffer + */ + void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, + StackType_t ** ppxIdleTaskStackBuffer, + uint32_t * pulIdleTaskStackSize ); /*lint !e526 Symbol not defined as it is an application callback. */ +#endif + /** - * Calls the hook function associated with xTask. Passing xTask as NULL has + * @cond + * task.h + * @code{c} + * BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter ); + * @endcode + * @endcond + * + * Calls the hook function associated with xTask. Passing xTask as NULL has * the effect of calling the Running tasks (the calling task) hook function. * * @param xTask Handle of the task to call the hook for. @@ -1623,7 +2001,8 @@ constant. */ * 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; +BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, + void * pvParameter ) PRIVILEGED_FUNCTION; /** * xTaskGetIdleTaskHandle() is only available if @@ -1644,7 +2023,7 @@ TaskHandle_t xTaskGetIdleTaskHandle( void ) PRIVILEGED_FUNCTION; * 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. @@ -1660,7 +2039,7 @@ TaskHandle_t xTaskGetIdleTaskHandle( void ) PRIVILEGED_FUNCTION; * @param pulTotalRunTime If configGENERATE_RUN_TIME_STATS is set to 1 in * FreeRTOSConfig.h then *pulTotalRunTime is set by uxTaskGetSystemState() to the * total run time (as defined by the run time stats clock, see - * http://www.freertos.org/rtos-run-time-stats.html) since the target booted. + * https://www.FreeRTOS.org/rtos-run-time-stats.html) since the target booted. * pulTotalRunTime can be set to NULL to omit the total run time information. * * @return The number of TaskStatus_t structures that were populated by @@ -1670,68 +2049,70 @@ TaskHandle_t xTaskGetIdleTaskHandle( void ) PRIVILEGED_FUNCTION; * * Example usage: * @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; + * // 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; + * // 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(); + * // 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 ) ); + * // 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 ); + * if( pxTaskStatusArray != NULL ) + * { + * // Generate raw status information about each task. + * uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, &ulTotalRunTime ); * - * // For percentage calculations. - * ulTotalRunTime /= 100UL; + * // 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++ ) + * // Avoid divide by zero errors. + * if( ulTotalRunTime > 0 ) * { - * // 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 ) + * // For each populated position in the pxTaskStatusArray array, + * // format the raw data as human readable ASCII data + * for( x = 0; x < uxArraySize; x++ ) * { - * sprintf( pcWriteBuffer, "%s\t\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage ); + * // 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 ); * } - * 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 ); + * // The array is no longer needed, free the memory it consumes. + * vPortFree( pxTaskStatusArray ); + * } * } - * } - * @endcode + * @endcode */ -UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const UBaseType_t uxArraySize, uint32_t * const pulTotalRunTime ) PRIVILEGED_FUNCTION; +UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, + const UBaseType_t uxArraySize, + uint32_t * const pulTotalRunTime ) PRIVILEGED_FUNCTION; /** * List all the current tasks. @@ -1740,7 +2121,7 @@ UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const * both be defined as 1 for this function to be available. See the * configuration section of the FreeRTOS.org website for more information. * - * @note This function will disable interrupts for its duration. It is + * NOTE 1: 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 @@ -1749,7 +2130,9 @@ UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const * Tasks are reported as blocked ('B'), ready ('R'), deleted ('D') or * suspended ('S'). * - * @note This function is provided for convenience only, and is used by many of the + * PLEASE 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 @@ -1772,9 +2155,12 @@ UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const * enough to contain the generated report. Approximately 40 bytes per * task should be sufficient. * + * @cond + * \defgroup vTaskList vTaskList + * @endcond * \ingroup TaskUtils */ -void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ +void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ /** * Get the state of running tasks as a string @@ -1787,7 +2173,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 This function will disable interrupts for its duration. It is + * NOTE 1: 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 @@ -1798,7 +2184,9 @@ 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 This function is provided for convenience only, and is used by many of the + * NOTE 2: + * + * 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 @@ -1822,42 +2210,69 @@ void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unquali * contain the generated report. Approximately 40 bytes per task should * be sufficient. * + * @cond + * \defgroup vTaskGetRunTimeStats vTaskGetRunTimeStats + * @endcond + * \ingroup TaskUtils + */ +void vTaskGetRunTimeStats( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + +/** + * @cond + * task. h + * @code + * uint32_t ulTaskGetIdleRunTimeCounter( void ); + * @endcode + * @endcond + * + * configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS + * must both be defined as 1 for this function to be available. The application + * must also then provide definitions for + * portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE() + * to configure a peripheral timer/counter and return the timers current count + * value respectively. The counter should be at least 10 times the frequency of + * the tick count. + * + * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total + * accumulated execution time being stored for each task. The resolution + * of the accumulated time value depends on the frequency of the timer + * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro. + * While uxTaskGetSystemState() and vTaskGetRunTimeStats() writes the total + * execution time of each task into a buffer, ulTaskGetIdleRunTimeCounter() + * returns the total execution time of just the idle task. + * + * @return The total run time of the idle task. This is the amount of time the + * idle task has actually been executing. The unit of time is dependent on the + * frequency configured using the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and + * portGET_RUN_TIME_COUNTER_VALUE() macros. + * + * @cond + * \defgroup ulTaskGetIdleRunTimeCounter ulTaskGetIdleRunTimeCounter + * @endcond * \ingroup TaskUtils */ -void vTaskGetRunTimeStats( char *pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ - -/** -* configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS -* must both be defined as 1 for this function to be available. The application -* must also then provide definitions for -* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE() -* to configure a peripheral timer/counter and return the timers current count -* value respectively. The counter should be at least 10 times the frequency of -* the tick count. -* -* Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total -* accumulated execution time being stored for each task. The resolution -* of the accumulated time value depends on the frequency of the timer -* configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro. -* While uxTaskGetSystemState() and vTaskGetRunTimeStats() writes the total -* execution time of each task into a buffer, ulTaskGetIdleRunTimeCounter() -* returns the total execution time of just the idle task. -* -* @return The total run time of the idle task. This is the amount of time the -* idle task has actually been executing. The unit of time is dependent on the -* frequency configured using the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and -* portGET_RUN_TIME_COUNTER_VALUE() macros. -* -* \ingroup TaskUtils -*/ uint32_t ulTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION; /** - * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this - * function to be available. + * task. h + * @code{c} + * BaseType_t xTaskNotifyIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction ); + * BaseType_t xTaskNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction ); + * @endcode * - * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private - * "notification value", which is a 32-bit unsigned integer (uint32_t). + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * + * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these + * functions to be available. + * + * Sends a direct to task notification to a task, with an optional value and + * action. + * + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. * * Events can be sent to a task using an intermediary object. Examples of such * objects are queues, semaphores, mutexes and event groups. Task notifications @@ -1865,28 +2280,46 @@ uint32_t ulTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION; * an intermediary object. * * A notification sent to a task can optionally perform an action, such as - * update, overwrite or increment the task's notification value. In that way - * task notifications can be used to send data to a task, or be used as light - * weight and fast binary or counting semaphores. + * update, overwrite or increment one of the task's notification values. In + * that way task notifications can be used to send data to a task, or be used as + * light weight and fast binary or counting semaphores. * - * A notification sent to a task will remain pending until it is cleared by the - * task calling xTaskNotifyWait() or ulTaskNotifyTake(). If the task was - * already in the Blocked state to wait for a notification when the notification - * arrives then the task will automatically be removed from the Blocked state - * (unblocked) and the notification cleared. - * - * A task can use xTaskNotifyWait() to [optionally] block to wait for a - * notification to be pending, or ulTaskNotifyTake() to [optionally] block - * to wait for its notification value to have a non-zero value. The task does + * A task can use xTaskNotifyWaitIndexed() to [optionally] block to wait for a + * notification to be pending, or ulTaskNotifyTakeIndexed() to [optionally] block + * to wait for a notification value to have a non-zero value. The task does * not consume any CPU time while it is in the Blocked state. * - * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * A notification sent to a task will remain pending until it is cleared by the + * task calling xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() (or their + * un-indexed equivalents). If the task was already in the Blocked state to + * wait for a notification when the notification arrives then the task will + * automatically be removed from the Blocked state (unblocked) and the + * notification cleared. + * + * **NOTE** Each notification within the array operates independently - a task + * can only block on one notification within the array at a time and will not be + * unblocked by a notification sent to any other array index. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. xTaskNotify() is the original API function, and remains backward + * compatible by always operating on the notification value at index 0 in the + * array. Calling xTaskNotify() is equivalent to calling xTaskNotifyIndexed() + * with the uxIndexToNotify parameter set to 0. * * @param xTaskToNotify The handle of the task being notified. The handle to a * task can be returned from the xTaskCreate() API function used to create the * task, and the handle of the currently running task can be obtained by calling * xTaskGetCurrentTaskHandle(). * + * @param uxIndexToNotify The index within the target task's array of + * notification values to which the notification is to be sent. uxIndexToNotify + * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotify() does + * not have this parameter and always sends notifications to index 0. + * * @param ulValue Data that can be sent with the notification. How the data is * used depends on the value of the eAction parameter. * @@ -1894,54 +2327,100 @@ uint32_t ulTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION; * 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. + * The target notification value is bitwise ORed with ulValue. + * xTaskNotifyIndexed() 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. + * The target notification value is incremented. ulValue is not used and + * xTaskNotifyIndexed() 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. + * The target notification value is set to the value of ulValue, even if the + * task being notified had not yet processed the previous notification at the + * same array index (the task already had a notification pending at that index). + * xTaskNotifyIndexed() 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. + * If the task being notified did not already have a notification pending at the + * same array index then the target notification value is set to ulValue and + * xTaskNotifyIndexed() will return pdPASS. If the task being notified already + * had a notification pending at the same array index 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. + * The task receives a notification at the specified array index without the + * notification value at that index being updated. ulValue is not used and + * xTaskNotifyIndexed() always returns pdPASS in this case. * - * @param pulPreviousNotificationValue Can be used to pass out the subject - * task's notification value before any bits are modified by the notify - * function. + * pulPreviousNotificationValue - + * Can be used to pass out the subject task's notification value before any + * bits are modified by the notify function. * * @return Dependent on the value of eAction. See the description of the * eAction parameter. * + * \defgroup xTaskNotifyIndexed xTaskNotifyIndexed * \ingroup TaskNotifications */ -BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue ) PRIVILEGED_FUNCTION; -#define xTaskNotify( xTaskToNotify, ulValue, eAction ) xTaskGenericNotify( ( xTaskToNotify ), ( ulValue ), ( eAction ), NULL ) -#define xTaskNotifyAndQuery( xTaskToNotify, ulValue, eAction, pulPreviousNotifyValue ) xTaskGenericNotify( ( xTaskToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) ) +BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, + UBaseType_t uxIndexToNotify, + uint32_t ulValue, + eNotifyAction eAction, + uint32_t * pulPreviousNotificationValue ) PRIVILEGED_FUNCTION; +#define xTaskNotify( xTaskToNotify, ulValue, eAction ) \ + xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), NULL ) +#define xTaskNotifyIndexed( xTaskToNotify, uxIndexToNotify, ulValue, eAction ) \ + xTaskGenericNotify( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), NULL ) /** - * Send task notification from an ISR. + * task. h + * @code{c} + * BaseType_t xTaskNotifyAndQueryIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotifyValue ); + * BaseType_t xTaskNotifyAndQuery( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotifyValue ); + * @endcode * - * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this - * function to be available. + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. * - * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private - * "notification value", which is a 32-bit unsigned integer (uint32_t). + * xTaskNotifyAndQueryIndexed() performs the same operation as + * xTaskNotifyIndexed() with the addition that it also returns the subject + * task's prior notification value (the notification value at the time the + * function is called rather than when the function returns) in the additional + * pulPreviousNotifyValue parameter. * - * A version of xTaskNotify() that can be used from an interrupt service routine - * (ISR). + * xTaskNotifyAndQuery() performs the same operation as xTaskNotify() with the + * addition that it also returns the subject task's prior notification value + * (the notification value as it was at the time the function is called, rather + * than when the function returns) in the additional pulPreviousNotifyValue + * parameter. + * + * \defgroup xTaskNotifyAndQueryIndexed xTaskNotifyAndQueryIndexed + * \ingroup TaskNotifications + */ +#define xTaskNotifyAndQuery( xTaskToNotify, ulValue, eAction, pulPreviousNotifyValue ) \ + xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) ) +#define xTaskNotifyAndQueryIndexed( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pulPreviousNotifyValue ) \ + xTaskGenericNotify( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) ) + +/** + * task. h + * @code{c} + * BaseType_t xTaskNotifyIndexedFromISR( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken ); + * BaseType_t xTaskNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * + * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these + * functions to be available. + * + * A version of xTaskNotifyIndexed() that can be used from an interrupt service + * routine (ISR). + * + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. * * Events can be sent to a task using an intermediary object. Examples of such * objects are queues, semaphores, mutexes and event groups. Task notifications @@ -1949,22 +2428,40 @@ BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNo * an intermediary object. * * A notification sent to a task can optionally perform an action, such as - * update, overwrite or increment the task's notification value. In that way - * task notifications can be used to send data to a task, or be used as light - * weight and fast binary or counting semaphores. + * update, overwrite or increment one of the task's notification values. In + * that way task notifications can be used to send data to a task, or be used as + * light weight and fast binary or counting semaphores. * - * A notification sent to a task will remain pending until it is cleared by the - * task calling xTaskNotifyWait() or ulTaskNotifyTake(). If the task was - * already in the Blocked state to wait for a notification when the notification - * arrives then the task will automatically be removed from the Blocked state - * (unblocked) and the notification cleared. - * - * A task can use xTaskNotifyWait() to [optionally] block to wait for a - * notification to be pending, or ulTaskNotifyTake() to [optionally] block - * to wait for its notification value to have a non-zero value. The task does + * A task can use xTaskNotifyWaitIndexed() to [optionally] block to wait for a + * notification to be pending, or ulTaskNotifyTakeIndexed() to [optionally] block + * to wait for a notification value to have a non-zero value. The task does * not consume any CPU time while it is in the Blocked state. * - * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * A notification sent to a task will remain pending until it is cleared by the + * task calling xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() (or their + * un-indexed equivalents). If the task was already in the Blocked state to + * wait for a notification when the notification arrives then the task will + * automatically be removed from the Blocked state (unblocked) and the + * notification cleared. + * + * **NOTE** Each notification within the array operates independently - a task + * can only block on one notification within the array at a time and will not be + * unblocked by a notification sent to any other array index. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. xTaskNotifyFromISR() is the original API function, and remains + * backward compatible by always operating on the notification value at index 0 + * within the array. Calling xTaskNotifyFromISR() is equivalent to calling + * xTaskNotifyIndexedFromISR() with the uxIndexToNotify parameter set to 0. + * + * @param uxIndexToNotify The index within the target task's array of + * notification values to which the notification is to be sent. uxIndexToNotify + * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyFromISR() + * does not have this parameter and always sends notifications to index 0. * * @param xTaskToNotify The handle of the task being notified. The handle to a * task can be returned from the xTaskCreate() API function used to create the @@ -1978,7 +2475,7 @@ BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNo * value, if at all. Valid values for eAction are as follows: * * eSetBits - - * The task's notification value is bitwise ORed with ulValue. xTaskNofify() + * The task's notification value is bitwise ORed with ulValue. xTaskNotify() * always returns pdPASS in this case. * * eIncrement - @@ -2002,9 +2499,6 @@ BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNo * updated. ulValue is not used and xTaskNotify() always returns pdPASS in * this case. * - * @param pulPreviousNotificationValue Can be used to pass out the subject task's - * notification value before any bits are modified by the notify function. - * * @param pxHigherPriorityTaskWoken xTaskNotifyFromISR() will set * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the * task to which the notification was sent to leave the Blocked state, and the @@ -2017,20 +2511,70 @@ BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNo * @return Dependent on the value of eAction. See the description of the * eAction parameter. * + * \defgroup xTaskNotifyIndexedFromISR xTaskNotifyIndexedFromISR + * \ingroup TaskNotifications + */ +BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, + UBaseType_t uxIndexToNotify, + uint32_t ulValue, + eNotifyAction eAction, + uint32_t * pulPreviousNotificationValue, + BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; +#define xTaskNotifyFromISR( xTaskToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) \ + xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) ) +#define xTaskNotifyIndexedFromISR( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) \ + xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) ) + +/** + * task. h + * @code{c} + * BaseType_t xTaskNotifyAndQueryIndexedFromISR( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken ); + * BaseType_t xTaskNotifyAndQueryFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * + * xTaskNotifyAndQueryIndexedFromISR() performs the same operation as + * xTaskNotifyIndexedFromISR() with the addition that it also returns the + * subject task's prior notification value (the notification value at the time + * the function is called rather than at the time the function returns) in the + * additional pulPreviousNotifyValue parameter. + * + * xTaskNotifyAndQueryFromISR() performs the same operation as + * xTaskNotifyFromISR() with the addition that it also returns the subject + * task's prior notification value (the notification value at the time the + * function is called rather than at the time the function returns) in the + * additional pulPreviousNotifyValue parameter. + * + * \defgroup xTaskNotifyAndQueryIndexedFromISR xTaskNotifyAndQueryIndexedFromISR * \ingroup TaskNotifications */ -BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; -#define xTaskNotifyFromISR( xTaskToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) ) -#define xTaskNotifyAndQueryFromISR( xTaskToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) ) +#define xTaskNotifyAndQueryIndexedFromISR( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) \ + xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) ) +#define xTaskNotifyAndQueryFromISR( xTaskToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) \ + xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) ) /** - * Wait for task notification + * task. h + * @code{c} + * BaseType_t xTaskNotifyWaitIndexed( UBaseType_t uxIndexToWaitOn, uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ); + * + * BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ); + * @endcode + * + * Waits for a direct to task notification to be pending at a given index within + * an array of direct to task notifications. + * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. * * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this * function to be available. * - * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private - * "notification value", which is a 32-bit unsigned integer (uint32_t). + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. * * Events can be sent to a task using an intermediary object. Examples of such * objects are queues, semaphores, mutexes and event groups. Task notifications @@ -2038,22 +2582,41 @@ BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulVal * an intermediary object. * * A notification sent to a task can optionally perform an action, such as - * update, overwrite or increment the task's notification value. In that way - * task notifications can be used to send data to a task, or be used as light - * weight and fast binary or counting semaphores. + * update, overwrite or increment one of the task's notification values. In + * that way task notifications can be used to send data to a task, or be used as + * light weight and fast binary or counting semaphores. * * A notification sent to a task will remain pending until it is cleared by the - * task calling xTaskNotifyWait() or ulTaskNotifyTake(). If the task was - * already in the Blocked state to wait for a notification when the notification - * arrives then the task will automatically be removed from the Blocked state - * (unblocked) and the notification cleared. - * - * A task can use xTaskNotifyWait() to [optionally] block to wait for a - * notification to be pending, or ulTaskNotifyTake() to [optionally] block - * to wait for its notification value to have a non-zero value. The task does + * task calling xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() (or their + * un-indexed equivalents). If the task was already in the Blocked state to + * wait for a notification when the notification arrives then the task will + * automatically be removed from the Blocked state (unblocked) and the + * notification cleared. + * + * A task can use xTaskNotifyWaitIndexed() to [optionally] block to wait for a + * notification to be pending, or ulTaskNotifyTakeIndexed() to [optionally] block + * to wait for a notification value to have a non-zero value. The task does * not consume any CPU time while it is in the Blocked state. * - * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * **NOTE** Each notification within the array operates independently - a task + * can only block on one notification within the array at a time and will not be + * unblocked by a notification sent to any other array index. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. xTaskNotifyWait() is the original API function, and remains backward + * compatible by always operating on the notification value at index 0 in the + * array. Calling xTaskNotifyWait() is equivalent to calling + * xTaskNotifyWaitIndexed() with the uxIndexToWaitOn parameter set to 0. + * + * @param uxIndexToWaitOn The index within the calling task's array of + * notification values on which the calling task will wait for a notification to + * be received. uxIndexToWaitOn must be less than + * configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyWait() does + * not have this parameter and always waits for notifications on index 0. * * @param ulBitsToClearOnEntry Bits that are set in ulBitsToClearOnEntry value * will be cleared in the calling task's notification value before the task @@ -2092,18 +2655,39 @@ BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulVal * already pending when xTaskNotifyWait was called) then pdPASS is * returned. Otherwise pdFAIL is returned. * + * \defgroup xTaskNotifyWaitIndexed xTaskNotifyWaitIndexed * \ingroup TaskNotifications */ -BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +BaseType_t xTaskGenericNotifyWait( UBaseType_t uxIndexToWaitOn, + uint32_t ulBitsToClearOnEntry, + uint32_t ulBitsToClearOnExit, + uint32_t * pulNotificationValue, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +#define xTaskNotifyWait( ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait ) \ + xTaskGenericNotifyWait( tskDEFAULT_INDEX_TO_NOTIFY, ( ulBitsToClearOnEntry ), ( ulBitsToClearOnExit ), ( pulNotificationValue ), ( xTicksToWait ) ) +#define xTaskNotifyWaitIndexed( uxIndexToWaitOn, ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait ) \ + xTaskGenericNotifyWait( ( uxIndexToWaitOn ), ( ulBitsToClearOnEntry ), ( ulBitsToClearOnExit ), ( pulNotificationValue ), ( xTicksToWait ) ) /** - * Simplified macro for sending task notification. + * task. h + * @code{c} + * BaseType_t xTaskNotifyGiveIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify ); + * BaseType_t xTaskNotifyGive( TaskHandle_t xTaskToNotify ); + * @endcode * - * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this macro - * to be available. + * Sends a direct to task notification to a particular index in the target + * task's notification array in a manner similar to giving a counting semaphore. + * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for more details. * - * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private - * "notification value", which is a 32-bit unsigned integer (uint32_t). + * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these + * macros to be available. + * + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. * * Events can be sent to a task using an intermediary object. Examples of such * objects are queues, semaphores, mutexes and event groups. Task notifications @@ -2111,46 +2695,76 @@ BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClea * an intermediary object. * * A notification sent to a task can optionally perform an action, such as - * update, overwrite or increment the task's notification value. In that way - * task notifications can be used to send data to a task, or be used as light - * weight and fast binary or counting semaphores. + * update, overwrite or increment one of the task's notification values. In + * that way task notifications can be used to send data to a task, or be used as + * light weight and fast binary or counting semaphores. * - * xTaskNotifyGive() is a helper macro intended for use when task notifications - * are used as light weight and faster binary or counting semaphore equivalents. - * Actual FreeRTOS semaphores are given using the xSemaphoreGive() API function, - * the equivalent action that instead uses a task notification is - * xTaskNotifyGive(). + * xTaskNotifyGiveIndexed() is a helper macro intended for use when task + * notifications are used as light weight and faster binary or counting + * semaphore equivalents. Actual FreeRTOS semaphores are given using the + * xSemaphoreGive() API function, the equivalent action that instead uses a task + * notification is xTaskNotifyGiveIndexed(). * * When task notifications are being used as a binary or counting semaphore * equivalent then the task being notified should wait for the notification - * using the ulTaskNotificationTake() API function rather than the - * xTaskNotifyWait() API function. - * - * See http://www.FreeRTOS.org/RTOS-task-notifications.html for more details. + * using the ulTaskNotificationTakeIndexed() API function rather than the + * xTaskNotifyWaitIndexed() API function. + * + * **NOTE** Each notification within the array operates independently - a task + * can only block on one notification within the array at a time and will not be + * unblocked by a notification sent to any other array index. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. xTaskNotifyGive() is the original API function, and remains backward + * compatible by always operating on the notification value at index 0 in the + * array. Calling xTaskNotifyGive() is equivalent to calling + * xTaskNotifyGiveIndexed() with the uxIndexToNotify parameter set to 0. * * @param xTaskToNotify The handle of the task being notified. The handle to a * task can be returned from the xTaskCreate() API function used to create the * task, and the handle of the currently running task can be obtained by calling * xTaskGetCurrentTaskHandle(). * + * @param uxIndexToNotify The index within the target task's array of + * notification values to which the notification is to be sent. uxIndexToNotify + * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyGive() + * does not have this parameter and always sends notifications to index 0. + * * @return xTaskNotifyGive() is a macro that calls xTaskNotify() with the * eAction parameter set to eIncrement - so pdPASS is always returned. * + * \defgroup xTaskNotifyGiveIndexed xTaskNotifyGiveIndexed * \ingroup TaskNotifications */ -#define xTaskNotifyGive( xTaskToNotify ) xTaskGenericNotify( ( xTaskToNotify ), ( 0 ), eIncrement, NULL ) +#define xTaskNotifyGive( xTaskToNotify ) \ + xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( 0 ), eIncrement, NULL ) +#define xTaskNotifyGiveIndexed( xTaskToNotify, uxIndexToNotify ) \ + xTaskGenericNotify( ( xTaskToNotify ), ( uxIndexToNotify ), ( 0 ), eIncrement, NULL ) /** - * Simplified macro for sending task notification from ISR. + * task. h + * @code{c} + * void vTaskNotifyGiveIndexedFromISR( TaskHandle_t xTaskHandle, UBaseType_t uxIndexToNotify, BaseType_t *pxHigherPriorityTaskWoken ); + * void vTaskNotifyGiveFromISR( TaskHandle_t xTaskHandle, BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * + * A version of xTaskNotifyGiveIndexed() that can be called from an interrupt + * service routine (ISR). + * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for more details. * * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this macro * to be available. * - * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private - * "notification value", which is a 32-bit unsigned integer (uint32_t). - * - * A version of xTaskNotifyGive() that can be called from an interrupt service - * routine (ISR). + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. * * Events can be sent to a task using an intermediary object. Examples of such * objects are queues, semaphores, mutexes and event groups. Task notifications @@ -2158,28 +2772,46 @@ BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClea * an intermediary object. * * A notification sent to a task can optionally perform an action, such as - * update, overwrite or increment the task's notification value. In that way - * task notifications can be used to send data to a task, or be used as light - * weight and fast binary or counting semaphores. + * update, overwrite or increment one of the task's notification values. In + * that way task notifications can be used to send data to a task, or be used as + * light weight and fast binary or counting semaphores. * - * vTaskNotifyGiveFromISR() is intended for use when task notifications are - * used as light weight and faster binary or counting semaphore equivalents. + * vTaskNotifyGiveIndexedFromISR() is intended for use when task notifications + * are used as light weight and faster binary or counting semaphore equivalents. * Actual FreeRTOS semaphores are given from an ISR using the * xSemaphoreGiveFromISR() API function, the equivalent action that instead uses - * a task notification is vTaskNotifyGiveFromISR(). + * a task notification is vTaskNotifyGiveIndexedFromISR(). * * When task notifications are being used as a binary or counting semaphore * equivalent then the task being notified should wait for the notification - * using the ulTaskNotificationTake() API function rather than the - * xTaskNotifyWait() API function. - * - * See http://www.FreeRTOS.org/RTOS-task-notifications.html for more details. + * using the ulTaskNotificationTakeIndexed() API function rather than the + * xTaskNotifyWaitIndexed() API function. + * + * **NOTE** Each notification within the array operates independently - a task + * can only block on one notification within the array at a time and will not be + * unblocked by a notification sent to any other array index. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. xTaskNotifyFromISR() is the original API function, and remains + * backward compatible by always operating on the notification value at index 0 + * within the array. Calling xTaskNotifyGiveFromISR() is equivalent to calling + * xTaskNotifyGiveIndexedFromISR() with the uxIndexToNotify parameter set to 0. * * @param xTaskToNotify The handle of the task being notified. The handle to a * task can be returned from the xTaskCreate() API function used to create the * task, and the handle of the currently running task can be obtained by calling * xTaskGetCurrentTaskHandle(). * + * @param uxIndexToNotify The index within the target task's array of + * notification values to which the notification is to be sent. uxIndexToNotify + * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. + * xTaskNotifyGiveFromISR() does not have this parameter and always sends + * notifications to index 0. + * * @param pxHigherPriorityTaskWoken vTaskNotifyGiveFromISR() will set * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the * task to which the notification was sent to leave the Blocked state, and the @@ -2189,18 +2821,38 @@ 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 vTaskNotifyGiveIndexedFromISR vTaskNotifyGiveIndexedFromISR * \ingroup TaskNotifications */ -void vTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; +void vTaskGenericNotifyGiveFromISR( TaskHandle_t xTaskToNotify, + UBaseType_t uxIndexToNotify, + BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; +#define vTaskNotifyGiveFromISR( xTaskToNotify, pxHigherPriorityTaskWoken ) \ + vTaskGenericNotifyGiveFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( pxHigherPriorityTaskWoken ) ); +#define vTaskNotifyGiveIndexedFromISR( xTaskToNotify, uxIndexToNotify, pxHigherPriorityTaskWoken ) \ + vTaskGenericNotifyGiveFromISR( ( xTaskToNotify ), ( uxIndexToNotify ), ( pxHigherPriorityTaskWoken ) ); /** - * Simplified macro for receiving task notification. + * task. h + * @code{c} + * uint32_t ulTaskNotifyTakeIndexed( UBaseType_t uxIndexToWaitOn, BaseType_t xClearCountOnExit, TickType_t xTicksToWait ); + * + * uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait ); + * @endcode + * + * Waits for a direct to task notification on a particular index in the calling + * task's notification array in a manner similar to taking a counting semaphore. + * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. * * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this * function to be available. * - * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private - * "notification value", which is a 32-bit unsigned integer (uint32_t). + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. * * Events can be sent to a task using an intermediary object. Examples of such * objects are queues, semaphores, mutexes and event groups. Task notifications @@ -2208,35 +2860,54 @@ void vTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPri * an intermediary object. * * A notification sent to a task can optionally perform an action, such as - * update, overwrite or increment the task's notification value. In that way - * task notifications can be used to send data to a task, or be used as light - * weight and fast binary or counting semaphores. + * update, overwrite or increment one of the task's notification values. In + * that way task notifications can be used to send data to a task, or be used as + * light weight and fast binary or counting semaphores. * - * ulTaskNotifyTake() is intended for use when a task notification is used as a - * faster and lighter weight binary or counting semaphore alternative. Actual - * FreeRTOS semaphores are taken using the xSemaphoreTake() API function, the - * equivalent action that instead uses a task notification is - * ulTaskNotifyTake(). + * ulTaskNotifyTakeIndexed() is intended for use when a task notification is + * used as a faster and lighter weight binary or counting semaphore alternative. + * Actual FreeRTOS semaphores are taken using the xSemaphoreTake() API function, + * the equivalent action that instead uses a task notification is + * ulTaskNotifyTakeIndexed(). * * When a task is using its notification value as a binary or counting semaphore - * other tasks should send notifications to it using the xTaskNotifyGive() - * macro, or xTaskNotify() function with the eAction parameter set to + * other tasks should send notifications to it using the xTaskNotifyGiveIndexed() + * macro, or xTaskNotifyIndex() function with the eAction parameter set to * eIncrement. * - * ulTaskNotifyTake() can either clear the task's notification value to - * zero on exit, in which case the notification value acts like a binary - * semaphore, or decrement the task's notification value on exit, in which case - * the notification value acts like a counting semaphore. + * ulTaskNotifyTakeIndexed() can either clear the task's notification value at + * the array index specified by the uxIndexToWaitOn parameter to zero on exit, + * in which case the notification value acts like a binary semaphore, or + * decrement the notification value on exit, in which case the notification + * value acts like a counting semaphore. * - * A task can use ulTaskNotifyTake() to [optionally] block to wait for a + * A task can use ulTaskNotifyTakeIndexed() to [optionally] block to wait for * the task's notification value to be non-zero. The task does not consume any * CPU time while it is in the Blocked state. * - * Where as xTaskNotifyWait() will return when a notification is pending, - * ulTaskNotifyTake() will return when the task's notification value is + * Where as xTaskNotifyWaitIndexed() will return when a notification is pending, + * ulTaskNotifyTakeIndexed() will return when the task's notification value is * not zero. * - * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * **NOTE** Each notification within the array operates independently - a task + * can only block on one notification within the array at a time and will not be + * unblocked by a notification sent to any other array index. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. ulTaskNotifyTake() is the original API function, and remains backward + * compatible by always operating on the notification value at index 0 in the + * array. Calling ulTaskNotifyTake() is equivalent to calling + * ulTaskNotifyTakeIndexed() with the uxIndexToWaitOn parameter set to 0. + * + * @param uxIndexToWaitOn The index within the calling task's array of + * notification values on which the calling task will wait for a notification to + * be non-zero. uxIndexToWaitOn must be less than + * configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyTake() does + * not have this parameter and always waits for notifications on index 0. * * @param xClearCountOnExit if xClearCountOnExit is pdFALSE then the task's * notification value is decremented when the function exits. In this way the @@ -2256,23 +2927,289 @@ 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 ulTaskNotifyTakeIndexed ulTaskNotifyTakeIndexed * \ingroup TaskNotifications */ -uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +uint32_t ulTaskGenericNotifyTake( UBaseType_t uxIndexToWaitOn, + BaseType_t xClearCountOnExit, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +#define ulTaskNotifyTake( xClearCountOnExit, xTicksToWait ) \ + ulTaskGenericNotifyTake( ( tskDEFAULT_INDEX_TO_NOTIFY ), ( xClearCountOnExit ), ( xTicksToWait ) ) +#define ulTaskNotifyTakeIndexed( uxIndexToWaitOn, xClearCountOnExit, xTicksToWait ) \ + ulTaskGenericNotifyTake( ( uxIndexToWaitOn ), ( xClearCountOnExit ), ( xTicksToWait ) ) /** + * task. h + * @code{c} + * BaseType_t xTaskNotifyStateClearIndexed( TaskHandle_t xTask, UBaseType_t uxIndexToCLear ); * - * If the notification state of the task referenced by the handle xTask is - * eNotified, then set the task's notification state to eNotWaitingNotification. - * The task's notification value is not altered. Set xTask to NULL to clear the - * notification state of the calling task. + * BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask ); + * @endcode + * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * + * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these + * functions to be available. + * + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. + * + * If a notification is sent to an index within the array of notifications then + * the notification at that index is said to be 'pending' until it is read or + * explicitly cleared by the receiving task. xTaskNotifyStateClearIndexed() + * is the function that clears a pending notification without reading the + * notification value. The notification value at the same array index is not + * altered. Set xTask to NULL to clear the notification state of the calling + * task. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. xTaskNotifyStateClear() is the original API function, and remains + * backward compatible by always operating on the notification value at index 0 + * within the array. Calling xTaskNotifyStateClear() is equivalent to calling + * xTaskNotifyStateClearIndexed() with the uxIndexToNotify parameter set to 0. + * + * @param xTask The handle of the RTOS task that will have a notification state + * cleared. Set xTask to NULL to clear a notification state in the calling + * task. To obtain a task's handle create the task using xTaskCreate() and + * make use of the pxCreatedTask parameter, or create the task using + * xTaskCreateStatic() and store the returned value, or use the task's name in + * a call to xTaskGetHandle(). + * + * @param uxIndexToClear The index within the target task's array of + * notification values to act upon. For example, setting uxIndexToClear to 1 + * will clear the state of the notification at index 1 within the array. + * uxIndexToClear must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. + * ulTaskNotifyStateClear() does not have this parameter and always acts on the + * notification at index 0. * * @return pdTRUE if the task's notification state was set to * eNotWaitingNotification, otherwise pdFALSE. * + * \defgroup xTaskNotifyStateClearIndexed xTaskNotifyStateClearIndexed * \ingroup TaskNotifications */ -BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask ); +BaseType_t xTaskGenericNotifyStateClear( TaskHandle_t xTask, + UBaseType_t uxIndexToClear ) PRIVILEGED_FUNCTION; +#define xTaskNotifyStateClear( xTask ) \ + xTaskGenericNotifyStateClear( ( xTask ), ( tskDEFAULT_INDEX_TO_NOTIFY ) ) +#define xTaskNotifyStateClearIndexed( xTask, uxIndexToClear ) \ + xTaskGenericNotifyStateClear( ( xTask ), ( uxIndexToClear ) ) + +/** + * task. h + * @code{c} + * uint32_t ulTaskNotifyValueClearIndexed( TaskHandle_t xTask, UBaseType_t uxIndexToClear, uint32_t ulBitsToClear ); + * + * uint32_t ulTaskNotifyValueClear( TaskHandle_t xTask, uint32_t ulBitsToClear ); + * @endcode + * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * + * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these + * functions to be available. + * + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. + * + * ulTaskNotifyValueClearIndexed() clears the bits specified by the + * ulBitsToClear bit mask in the notification value at array index uxIndexToClear + * of the task referenced by xTask. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. ulTaskNotifyValueClear() is the original API function, and remains + * backward compatible by always operating on the notification value at index 0 + * within the array. Calling ulTaskNotifyValueClear() is equivalent to calling + * ulTaskNotifyValueClearIndexed() with the uxIndexToClear parameter set to 0. + * + * @param xTask The handle of the RTOS task that will have bits in one of its + * notification values cleared. Set xTask to NULL to clear bits in a + * notification value of the calling task. To obtain a task's handle create the + * task using xTaskCreate() and make use of the pxCreatedTask parameter, or + * create the task using xTaskCreateStatic() and store the returned value, or + * use the task's name in a call to xTaskGetHandle(). + * + * @param uxIndexToClear The index within the target task's array of + * notification values in which to clear the bits. uxIndexToClear + * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. + * ulTaskNotifyValueClear() does not have this parameter and always clears bits + * in the notification value at index 0. + * + * @param ulBitsToClear Bit mask of the bits to clear in the notification value of + * xTask. Set a bit to 1 to clear the corresponding bits in the task's notification + * value. Set ulBitsToClear to 0xffffffff (UINT_MAX on 32-bit architectures) to clear + * the notification value to 0. Set ulBitsToClear to 0 to query the task's + * notification value without clearing any bits. + * + * + * @return The value of the target task's notification value before the bits + * specified by ulBitsToClear were cleared. + * \defgroup ulTaskNotifyValueClear ulTaskNotifyValueClear + * \ingroup TaskNotifications + */ +uint32_t ulTaskGenericNotifyValueClear( TaskHandle_t xTask, + UBaseType_t uxIndexToClear, + uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION; +#define ulTaskNotifyValueClear( xTask, ulBitsToClear ) \ + ulTaskGenericNotifyValueClear( ( xTask ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulBitsToClear ) ) +#define ulTaskNotifyValueClearIndexed( xTask, uxIndexToClear, ulBitsToClear ) \ + ulTaskGenericNotifyValueClear( ( xTask ), ( uxIndexToClear ), ( ulBitsToClear ) ) + +/** + * @cond + * task.h + * @code{c} + * void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ); + * @endcode + * @endcond + * + * Capture the current time for future use with xTaskCheckForTimeOut(). + * + * @param pxTimeOut Pointer to a timeout object into which the current time + * is to be captured. The captured time includes the tick count and the number + * of times the tick count has overflowed since the system first booted. + * \defgroup vTaskSetTimeOutState vTaskSetTimeOutState + * @cond + * \ingroup TaskCtrl + * @endcond + */ +void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION; + +/** + * @cond + * task.h + * @code + * BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait ); + * @endcode + * @endcond + * + * Determines if pxTicksToWait ticks has passed since a time was captured + * using a call to vTaskSetTimeOutState(). The captured time includes the tick + * count and the number of times the tick count has overflowed. + * + * @param pxTimeOut The time status as captured previously using + * vTaskSetTimeOutState. If the timeout has not yet occurred, it is updated + * to reflect the current time status. + * @param pxTicksToWait The number of ticks to check for timeout i.e. if + * pxTicksToWait ticks have passed since pxTimeOut was last updated (either by + * vTaskSetTimeOutState() or xTaskCheckForTimeOut()), the timeout has occurred. + * If the timeout has not occurred, pxTicksToWait is updated to reflect the + * number of remaining ticks. + * + * @return If timeout has occurred, pdTRUE is returned. Otherwise pdFALSE is + * returned and pxTicksToWait is updated to reflect the number of remaining + * ticks. + * + * @see https://www.FreeRTOS.org/xTaskCheckForTimeOut.html + * + * Example Usage: + * @code + * // Driver library function used to receive uxWantedBytes from an Rx buffer + * // that is filled by a UART interrupt. If there are not enough bytes in the + * // Rx buffer then the task enters the Blocked state until it is notified that + * // more data has been placed into the buffer. If there is still not enough + * // data then the task re-enters the Blocked state, and xTaskCheckForTimeOut() + * // is used to re-calculate the Block time to ensure the total amount of time + * // spent in the Blocked state does not exceed MAX_TIME_TO_WAIT. This + * // continues until either the buffer contains at least uxWantedBytes bytes, + * // or the total amount of time spent in the Blocked state reaches + * // MAX_TIME_TO_WAIT – at which point the task reads however many bytes are + * // available up to a maximum of uxWantedBytes. + * + * size_t xUART_Receive( uint8_t *pucBuffer, size_t uxWantedBytes ) + * { + * size_t uxReceived = 0; + * TickType_t xTicksToWait = MAX_TIME_TO_WAIT; + * TimeOut_t xTimeOut; + * + * // Initialize xTimeOut. This records the time at which this function + * // was entered. + * vTaskSetTimeOutState( &xTimeOut ); + * + * // Loop until the buffer contains the wanted number of bytes, or a + * // timeout occurs. + * while( UART_bytes_in_rx_buffer( pxUARTInstance ) < uxWantedBytes ) + * { + * // The buffer didn't contain enough data so this task is going to + * // enter the Blocked state. Adjusting xTicksToWait to account for + * // any time that has been spent in the Blocked state within this + * // function so far to ensure the total amount of time spent in the + * // Blocked state does not exceed MAX_TIME_TO_WAIT. + * if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) != pdFALSE ) + * { + * //Timed out before the wanted number of bytes were available, + * // exit the loop. + * break; + * } + * + * // Wait for a maximum of xTicksToWait ticks to be notified that the + * // receive interrupt has placed more data into the buffer. + * ulTaskNotifyTake( pdTRUE, xTicksToWait ); + * } + * + * // Attempt to read uxWantedBytes from the receive buffer into pucBuffer. + * // The actual number of bytes read (which might be less than + * // uxWantedBytes) is returned. + * uxReceived = UART_read_from_receive_buffer( pxUARTInstance, + * pucBuffer, + * uxWantedBytes ); + * + * return uxReceived; + * } + * @endcode + * @cond + * \defgroup xTaskCheckForTimeOut xTaskCheckForTimeOut + * @endcond + * \ingroup TaskCtrl + */ +BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, + TickType_t * const pxTicksToWait ) PRIVILEGED_FUNCTION; + +/** + * @cond + * task.h + * @code{c} + * BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp ); + * @endcode + * @endcond + * + * This function corrects the tick count value after the application code has held + * interrupts disabled for an extended period resulting in tick interrupts having + * been missed. + * + * This function is similar to vTaskStepTick(), however, unlike + * vTaskStepTick(), xTaskCatchUpTicks() may move the tick count forward past a + * time at which a task should be removed from the blocked state. That means + * tasks may have to be removed from the blocked state as the tick count is + * moved. + * + * @param xTicksToCatchUp The number of tick interrupts that have been missed due to + * interrupts being disabled. Its value is not computed automatically, so must be + * computed by the application writer. + * + * @return pdTRUE if moving the tick count forward resulted in a task leaving the + * blocked state and a context switch being performed. Otherwise pdFALSE. + * + * \defgroup xTaskCatchUpTicks xTaskCatchUpTicks + * @cond + * \ingroup TaskCtrl + * @endcond + */ +BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) PRIVILEGED_FUNCTION; + /*----------------------------------------------------------- * SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES @@ -2299,7 +3236,6 @@ TaskHandle_t xTaskGetCurrentTaskHandleForCPU( BaseType_t cpuid ); */ TaskHandle_t xTaskGetIdleTaskHandleForCPU( UBaseType_t cpuid ); - /* * Get the current core affinity of a task */ @@ -2339,7 +3275,7 @@ BaseType_t xTaskIncrementTick( void ) PRIVILEGED_FUNCTION; * xItemValue value, and inserts the list item at the end of the list. * * The 'ordered' version uses the existing event list item value (which is the - * owning tasks priority) to insert the list item into the event list is task + * owning task's priority) to insert the list item into the event list in task * priority order. * * @param pxEventList The list containing tasks that are blocked waiting @@ -2349,12 +3285,15 @@ BaseType_t xTaskIncrementTick( void ) PRIVILEGED_FUNCTION; * event list is not ordered by task priority. * * @param xTicksToWait The maximum amount of time that the task should wait - * for the event to occur. This is specified in kernel ticks,the constant + * for the event to occur. This is specified in kernel ticks, the constant * portTICK_PERIOD_MS can be used to convert kernel ticks into a real time * period. */ -void vTaskPlaceOnEventList( List_t * const pxEventList, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; -void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, const TickType_t xItemValue, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +void vTaskPlaceOnEventList( List_t * const pxEventList, + const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, + const TickType_t xItemValue, + const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; /* * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN @@ -2367,7 +3306,9 @@ void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, const TickType_t xIte * indefinitely, whereas vTaskPlaceOnEventList() does. * */ -void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION; +void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, + TickType_t xTicksToWait, + const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION; /* * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN @@ -2394,7 +3335,8 @@ void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, TickType_t xTi * making the call, otherwise pdFALSE. */ BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList ) PRIVILEGED_FUNCTION; -BaseType_t xTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, const TickType_t xItemValue ) PRIVILEGED_FUNCTION; +BaseType_t xTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, + const TickType_t xItemValue ) PRIVILEGED_FUNCTION; /* * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY @@ -2404,7 +3346,7 @@ BaseType_t xTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, cons * Sets the pointer to the current TCB to the TCB of the highest priority task * that is ready to run. */ -void vTaskSwitchContext( void ) PRIVILEGED_FUNCTION; +portDONT_DISCARD void vTaskSwitchContext( void ) PRIVILEGED_FUNCTION; /* * THESE FUNCTIONS MUST NOT BE USED FROM APPLICATION CODE. THEY ARE USED BY @@ -2417,17 +3359,6 @@ TickType_t uxTaskResetEventItemValue( void ) PRIVILEGED_FUNCTION; */ TaskHandle_t xTaskGetCurrentTaskHandle( void ) PRIVILEGED_FUNCTION; -/* - * Capture the current time status for future reference. - */ -void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION; - -/* - * Compare the time status now with that previously captured to see if the - * timeout has expired. - */ -BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait ) PRIVILEGED_FUNCTION; - /* * Shortcut used by the queue implementation to prevent unnecessary call to * taskYIELD(); @@ -2460,7 +3391,8 @@ BaseType_t xTaskPriorityDisinherit( TaskHandle_t const pxMutexHolder ) PRIVILEGE * the highest priority task that is still waiting for the mutex (if there were * more than one task waiting for the mutex). */ -void vTaskPriorityDisinheritAfterTimeout( TaskHandle_t const pxMutexHolder, UBaseType_t uxHighestPriorityWaitingTask ) PRIVILEGED_FUNCTION; +void vTaskPriorityDisinheritAfterTimeout( TaskHandle_t const pxMutexHolder, + UBaseType_t uxHighestPriorityWaitingTask ) PRIVILEGED_FUNCTION; /* * Get the uxTCBNumber assigned to the task referenced by the xTask parameter. @@ -2476,7 +3408,8 @@ BaseType_t xTaskGetAffinity( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; * Set the uxTaskNumber of the task referenced by the xTask parameter to * uxHandle. */ -void vTaskSetTaskNumber( TaskHandle_t xTask, const UBaseType_t uxHandle ) PRIVILEGED_FUNCTION; +void vTaskSetTaskNumber( TaskHandle_t xTask, + const UBaseType_t uxHandle ) PRIVILEGED_FUNCTION; /* * Only available when configUSE_TICKLESS_IDLE is set to 1. @@ -2488,19 +3421,6 @@ void vTaskSetTaskNumber( TaskHandle_t xTask, const UBaseType_t uxHandle ) PRIVIL */ void vTaskStepTick( const TickType_t xTicksToJump ) PRIVILEGED_FUNCTION; -/* Correct the tick count value after the application code has held -interrupts disabled for an extended period. xTicksToCatchUp is the number -of tick interrupts that have been missed due to interrupts being disabled. -Its value is not computed automatically, so must be computed by the -application writer. - -This function is similar to vTaskStepTick(), however, unlike -vTaskStepTick(), xTaskCatchUpTicks() may move the tick count forward past a -time at which a task should be removed from the blocked state. That means -tasks may have to be removed from the blocked state as the tick count is -moved. */ -BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) PRIVILEGED_FUNCTION; - /* * Only available when configUSE_TICKLESS_IDLE is set to 1. * Provided for use within portSUPPRESS_TICKS_AND_SLEEP() to allow the port @@ -2524,44 +3444,20 @@ eSleepModeStatus eTaskConfirmSleepModeStatus( void ) PRIVILEGED_FUNCTION; TaskHandle_t pvTaskIncrementMutexHeldCount( void ) PRIVILEGED_FUNCTION; /* - * For internal use only. Same as vTaskSetTimeOutState(), but without a critial + * For internal use only. Same as vTaskSetTimeOutState(), but without a critical * section. */ void vTaskInternalSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION; -/* - * This function fills array with TaskSnapshot_t structures for every task in the system. - * Used by panic handling code to get snapshots of all tasks in the system. - * Only available when configENABLE_TASK_SNAPSHOT is set to 1. - * @param pxTaskSnapshotArray Pointer to array of TaskSnapshot_t structures to store tasks snapshot data. - * @param uxArraySize Size of tasks snapshots array. - * @param pxTcbSz Pointer to store size of TCB. - * @return Number of elements stored in array. - */ -UBaseType_t uxTaskGetSnapshotAll( TaskSnapshot_t * const pxTaskSnapshotArray, const UBaseType_t uxArraySize, UBaseType_t * const pxTcbSz ); - -/* - * This function iterates over all tasks in the system. - * Used by panic handling code to iterate over tasks in the system. - * Only available when configENABLE_TASK_SNAPSHOT is set to 1. - * @note This function should not be used while FreeRTOS is running (as it doesn't acquire any locks). - * @param pxTask task handle. - * @return Handle for the next task. If pxTask is NULL, returns hadnle for the first task. - */ -TaskHandle_t pxTaskGetNext( TaskHandle_t pxTask ); - -/* - * This function fills TaskSnapshot_t structure for specified task. - * Used by panic handling code to get snapshot of a task. - * Only available when configENABLE_TASK_SNAPSHOT is set to 1. - * @note This function should not be used while FreeRTOS is running (as it doesn't acquire any locks). - * @param pxTask task handle. - * @param pxTaskSnapshot address of TaskSnapshot_t structure to fill. - */ -void vTaskGetSnapshot( TaskHandle_t pxTask, TaskSnapshot_t *pxTaskSnapshot ); +#ifdef ESP_PLATFORM +/* TODO: IDF-3683 */ +#include "freertos/task_snapshot.h" +#endif // ESP_PLATFORM /** @endcond */ + #ifdef __cplusplus -} + } #endif +/* *INDENT-ON* */ #endif /* INC_TASK_H */ diff --git a/tools/sdk/esp32/include/freertos/include/freertos/timers.h b/tools/sdk/esp32/include/freertos/include/freertos/timers.h index 9a5e23385ff..a8bc4f38c78 100644 --- a/tools/sdk/esp32/include/freertos/include/freertos/timers.h +++ b/tools/sdk/esp32/include/freertos/include/freertos/timers.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ @@ -30,41 +29,43 @@ #define TIMERS_H #ifndef INC_FREERTOS_H - #error "include FreeRTOS.h must appear in source files before include timers.h" + #error "include FreeRTOS.h must appear in source files before include timers.h" #endif /*lint -save -e537 This headers are only multiply included if the application code -happens to also be including task.h. */ + * happens to also be including task.h. */ #include "task.h" /*lint -restore */ +/* *INDENT-OFF* */ #ifdef __cplusplus -extern "C" { + extern "C" { #endif +/* *INDENT-ON* */ /*----------------------------------------------------------- * MACROS AND DEFINITIONS *----------------------------------------------------------*/ /* IDs for commands that can be sent/received on the timer queue. These are to -be used solely through the macros that make up the public software timer API, -as defined below. The commands that are sent from interrupts must use the -highest numbers as tmrFIRST_FROM_ISR_COMMAND is used to determine if the task -or interrupt version of the queue send function should be used. */ -#define tmrCOMMAND_EXECUTE_CALLBACK_FROM_ISR ( ( BaseType_t ) -2 ) -#define tmrCOMMAND_EXECUTE_CALLBACK ( ( BaseType_t ) -1 ) -#define tmrCOMMAND_START_DONT_TRACE ( ( BaseType_t ) 0 ) -#define tmrCOMMAND_START ( ( BaseType_t ) 1 ) -#define tmrCOMMAND_RESET ( ( BaseType_t ) 2 ) -#define tmrCOMMAND_STOP ( ( BaseType_t ) 3 ) -#define tmrCOMMAND_CHANGE_PERIOD ( ( BaseType_t ) 4 ) -#define tmrCOMMAND_DELETE ( ( BaseType_t ) 5 ) + * be used solely through the macros that make up the public software timer API, + * as defined below. The commands that are sent from interrupts must use the + * highest numbers as tmrFIRST_FROM_ISR_COMMAND is used to determine if the task + * or interrupt version of the queue send function should be used. */ +#define tmrCOMMAND_EXECUTE_CALLBACK_FROM_ISR ( ( BaseType_t ) -2 ) +#define tmrCOMMAND_EXECUTE_CALLBACK ( ( BaseType_t ) -1 ) +#define tmrCOMMAND_START_DONT_TRACE ( ( BaseType_t ) 0 ) +#define tmrCOMMAND_START ( ( BaseType_t ) 1 ) +#define tmrCOMMAND_RESET ( ( BaseType_t ) 2 ) +#define tmrCOMMAND_STOP ( ( BaseType_t ) 3 ) +#define tmrCOMMAND_CHANGE_PERIOD ( ( BaseType_t ) 4 ) +#define tmrCOMMAND_DELETE ( ( BaseType_t ) 5 ) -#define tmrFIRST_FROM_ISR_COMMAND ( ( BaseType_t ) 6 ) -#define tmrCOMMAND_START_FROM_ISR ( ( BaseType_t ) 6 ) -#define tmrCOMMAND_RESET_FROM_ISR ( ( BaseType_t ) 7 ) -#define tmrCOMMAND_STOP_FROM_ISR ( ( BaseType_t ) 8 ) -#define tmrCOMMAND_CHANGE_PERIOD_FROM_ISR ( ( BaseType_t ) 9 ) +#define tmrFIRST_FROM_ISR_COMMAND ( ( BaseType_t ) 6 ) +#define tmrCOMMAND_START_FROM_ISR ( ( BaseType_t ) 6 ) +#define tmrCOMMAND_RESET_FROM_ISR ( ( BaseType_t ) 7 ) +#define tmrCOMMAND_STOP_FROM_ISR ( ( BaseType_t ) 8 ) +#define tmrCOMMAND_CHANGE_PERIOD_FROM_ISR ( ( BaseType_t ) 9 ) /** @@ -74,20 +75,30 @@ or interrupt version of the queue send function should be used. */ * (for example, xTimerStart(), xTimerReset(), etc.). */ struct tmrTimerControl; /* The old naming convention is used to prevent breaking kernel aware debuggers. */ -//typedef struct tmrTimerControl * TimerHandle_t; +#ifdef ESP_PLATFORM // IDF-3768 typedef void* TimerHandle_t; +#else +typedef struct tmrTimerControl * TimerHandle_t; +#endif // ESP_PLATFORM /* * Defines the prototype to which timer callback functions must conform. */ -typedef void (*TimerCallbackFunction_t)( TimerHandle_t xTimer ); +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 ); +typedef void (* PendedFunction_t)( void *, + uint32_t ); /** + * TimerHandle_t xTimerCreate( const char * const pcTimerName, + * TickType_t xTimerPeriodInTicks, + * UBaseType_t uxAutoReload, + * void * pvTimerID, + * TimerCallbackFunction_t pxCallbackFunction ); + * * Creates a new software timer instance, and returns a handle by which the * created software timer can be referenced. * @@ -95,7 +106,7 @@ typedef void (*PendedFunction_t)( void *, uint32_t ); * 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 + * https://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. @@ -115,7 +126,7 @@ typedef void (*PendedFunction_t)( void *, uint32_t ); * 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. + * equal to 1000. Time timer period must be greater than 0. * * @param uxAutoReload If uxAutoReload is set to pdTRUE then the timer will * expire repeatedly with a frequency set by the xTimerPeriodInTicks parameter. @@ -129,7 +140,7 @@ typedef void (*PendedFunction_t)( void *, uint32_t ); * * @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 );". + * which is "void vCallbackFunction( TimerHandle_t xTimer );". * * @return If the timer is successfully created then a handle to the newly * created timer is returned. If the timer cannot be created (because either @@ -137,7 +148,7 @@ typedef void (*PendedFunction_t)( void *, uint32_t ); * structures, or the timer period was set to 0) then NULL is returned. * * Example usage: - * @code{c} + * @verbatim * #define NUM_TIMERS 5 * * // An array to hold handles to the created timers. @@ -155,8 +166,8 @@ typedef void (*PendedFunction_t)( void *, uint32_t ); * int32_t lArrayIndex; * const int32_t xMaxExpiryCountBeforeStopping = 10; * - * // Optionally do something if the pxTimer parameter is NULL. - * configASSERT( pxTimer ); + * // Optionally do something if the pxTimer parameter is NULL. + * configASSERT( pxTimer ); * * // Which timer expired? * lArrayIndex = ( int32_t ) pvTimerGetTimerID( pxTimer ); @@ -216,138 +227,145 @@ typedef void (*PendedFunction_t)( void *, uint32_t ); * // Should not reach here. * for( ;; ); * } - * @endcode + * @endverbatim */ -#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - TimerHandle_t xTimerCreate( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ - const TickType_t xTimerPeriodInTicks, - const UBaseType_t uxAutoReload, - void * const pvTimerID, - TimerCallbackFunction_t pxCallbackFunction ) PRIVILEGED_FUNCTION; +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + TimerHandle_t xTimerCreate( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + const TickType_t xTimerPeriodInTicks, + const UBaseType_t uxAutoReload, + void * const pvTimerID, + TimerCallbackFunction_t pxCallbackFunction ) PRIVILEGED_FUNCTION; #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; +/** + * TimerHandle_t xTimerCreateStatic(const char * const pcTimerName, + * TickType_t xTimerPeriodInTicks, + * UBaseType_t uxAutoReload, + * void * pvTimerID, + * TimerCallbackFunction_t pxCallbackFunction, + * StaticTimer_t *pxTimerBuffer ); + * + * 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 + * https://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. The timer period must be greater than 0. + * + * @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: + * @verbatim + * + * // 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( ;; ); + * } + * @endverbatim + */ +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + TimerHandle_t xTimerCreateStatic( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + const TickType_t xTimerPeriodInTicks, + const UBaseType_t uxAutoReload, + void * const pvTimerID, + TimerCallbackFunction_t pxCallbackFunction, + StaticTimer_t * pxTimerBuffer ) PRIVILEGED_FUNCTION; #endif /* configSUPPORT_STATIC_ALLOCATION */ /** @@ -370,7 +388,7 @@ typedef void (*PendedFunction_t)( void *, uint32_t ); * * See the xTimerCreate() API function example usage scenario. */ -void *pvTimerGetTimerID( const TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; +void * pvTimerGetTimerID( const TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /** * void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ); @@ -391,7 +409,8 @@ void *pvTimerGetTimerID( const TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; * * See the xTimerCreate() API function example usage scenario. */ -void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ) PRIVILEGED_FUNCTION; +void vTimerSetTimerID( TimerHandle_t xTimer, + void * pvNewID ) PRIVILEGED_FUNCTION; /** * BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer ); @@ -413,7 +432,7 @@ void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ) PRIVILEGED_FUNCTION * pdFALSE will be returned if the timer is active. * * Example usage: - * @code{c} + * @verbatim * // This function assumes xTimer has already been created. * void vAFunction( TimerHandle_t xTimer ) * { @@ -426,11 +445,15 @@ void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ) PRIVILEGED_FUNCTION * // xTimer is not active, do something else. * } * } - * @endcode + * @endverbatim */ BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /** + * @cond + * TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ); + * @endcond + * * xTimerGetTimerDaemonTaskHandle() is only available if * INCLUDE_xTimerGetTimerDaemonTaskHandle is set to 1 in FreeRTOSConfig.h. * @@ -489,9 +512,12 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * See the xTimerCreate() API function example usage scenario. * */ -#define xTimerStart( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START, ( xTaskGetTickCount() ), NULL, ( xTicksToWait ) ) +#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 @@ -529,9 +555,14 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * See the xTimerCreate() API function example usage scenario. * */ -#define xTimerStop( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP, 0U, NULL, ( xTicksToWait ) ) +#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 @@ -573,7 +604,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * configTIMER_TASK_PRIORITY configuration constant. * * Example usage: - * @code{c} + * @verbatim * // 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 @@ -603,11 +634,14 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * } * } * } - * @endcode + * @endverbatim */ - #define xTimerChangePeriod( xTimer, xNewPeriod, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD, ( xNewPeriod ), NULL, ( xTicksToWait ) ) +#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 @@ -641,9 +675,12 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * * See the xTimerChangePeriod() API function example usage scenario. */ -#define xTimerDelete( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_DELETE, 0U, NULL, ( xTicksToWait ) ) +#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 @@ -689,7 +726,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * configuration constant. * * Example usage: - * @code{c} + * @verbatim * // 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. @@ -761,11 +798,15 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * // Should not reach here. * for( ;; ); * } - * @endcode + * @endverbatim */ -#define xTimerReset( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_RESET, ( xTaskGetTickCount() ), NULL, ( xTicksToWait ) ) +#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. * @@ -793,7 +834,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * configuration constant. * * Example usage: - * @code{c} + * @verbatim * // 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 @@ -844,11 +885,15 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * // depends on the FreeRTOS port being used). * } * } - * @endcode + * @endverbatim */ -#define xTimerStartFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START_FROM_ISR, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U ) +#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. * @@ -874,7 +919,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * priority is set by the configTIMER_TASK_PRIORITY configuration constant. * * Example usage: - * @code{c} + * @verbatim * // This scenario assumes xTimer has already been created and started. When * // an interrupt occurs, the timer should be simply stopped. * @@ -904,11 +949,16 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * // depends on the FreeRTOS port being used). * } * } - * @endcode + * @endverbatim */ -#define xTimerStopFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP_FROM_ISR, 0, ( pxHigherPriorityTaskWoken ), 0U ) +#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. * @@ -943,7 +993,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * priority is set by the configTIMER_TASK_PRIORITY configuration constant. * * Example usage: - * @code{c} + * @verbatim * // This scenario assumes xTimer has already been created and started. When * // an interrupt occurs, the period of xTimer should be changed to 500ms. * @@ -973,11 +1023,15 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * // depends on the FreeRTOS port being used). * } * } - * @endcode + * @endverbatim */ -#define xTimerChangePeriodFromISR( xTimer, xNewPeriod, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD_FROM_ISR, ( xNewPeriod ), ( pxHigherPriorityTaskWoken ), 0U ) +#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. * @@ -1005,7 +1059,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * task priority is set by the configTIMER_TASK_PRIORITY configuration constant. * * Example usage: - * @code{c} + * @verbatim * // 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 @@ -1056,12 +1110,19 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * // depends on the FreeRTOS port being used). * } * } - * @endcode + * @endverbatim */ -#define xTimerResetFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_RESET_FROM_ISR, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U ) +#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'). @@ -1103,75 +1164,87 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * timer daemon task, otherwise pdFALSE is returned. * * Example usage: - * @code{c} + * @verbatim * - * // The callback function that will execute in the context of the daemon task. + * // The callback function that will execute in the context of the daemon task. * // Note callback functions must all use this same prototype. * void vProcessInterface( void *pvParameter1, uint32_t ulParameter2 ) - * { - * BaseType_t xInterfaceToService; + * { + * BaseType_t xInterfaceToService; * - * // The interface that requires servicing is passed in the second + * // The interface that requires servicing is passed in the second * // parameter. The first parameter is not used in this case. - * xInterfaceToService = ( BaseType_t ) ulParameter2; + * xInterfaceToService = ( BaseType_t ) ulParameter2; * - * // ...Perform the processing here... - * } + * // ...Perform the processing here... + * } * - * // An ISR that receives data packets from multiple interfaces + * // An ISR that receives data packets from multiple interfaces * void vAnISR( void ) - * { - * BaseType_t xInterfaceToService, xHigherPriorityTaskWoken; + * { + * BaseType_t xInterfaceToService, xHigherPriorityTaskWoken; * - * // Query the hardware to determine which interface needs processing. - * xInterfaceToService = prvCheckInterfaces(); + * // Query the hardware to determine which interface needs processing. + * xInterfaceToService = prvCheckInterfaces(); * * // The actual processing is to be deferred to a task. Request the * // vProcessInterface() callback function is executed, passing in the - * // number of the interface that needs processing. The interface to - * // service is passed in the second parameter. The first parameter is - * // not used in this case. - * xHigherPriorityTaskWoken = pdFALSE; - * xTimerPendFunctionCallFromISR( vProcessInterface, NULL, ( uint32_t ) xInterfaceToService, &xHigherPriorityTaskWoken ); - * - * // 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 + * // number of the interface that needs processing. The interface to + * // service is passed in the second parameter. The first parameter is + * // not used in this case. + * xHigherPriorityTaskWoken = pdFALSE; + * xTimerPendFunctionCallFromISR( vProcessInterface, NULL, ( uint32_t ) xInterfaceToService, &xHigherPriorityTaskWoken ); + * + * // 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 ); + * + * } + * @endverbatim */ -BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; +BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend, + void * pvParameter1, + uint32_t ulParameter2, + BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; - /** - * 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'). - * - * @param xFunctionToPend The function to execute from the timer service/ - * daemon task. The function must conform to the PendedFunction_t - * prototype. - * - * @param pvParameter1 The value of the callback function's first parameter. - * The parameter has a void * type to allow it to be used to pass any type. - * For example, unsigned longs can be cast to a void *, or the void * can be - * used to point to a structure. - * - * @param ulParameter2 The value of the callback function's second parameter. - * - * @param xTicksToWait Calling this function will result in a message being - * sent to the timer daemon task on a queue. xTicksToWait is the amount of - * time the calling task should remain in the Blocked state (so not using any - * processing time) for space to become available on the timer queue if the - * queue is found to be full. - * - * @return pdPASS is returned if the message was successfully sent to the - * timer daemon task, otherwise pdFALSE is returned. - * - */ -BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +/** + * 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'). + * + * @param xFunctionToPend The function to execute from the timer service/ + * daemon task. The function must conform to the PendedFunction_t + * prototype. + * + * @param pvParameter1 The value of the callback function's first parameter. + * The parameter has a void * type to allow it to be used to pass any type. + * For example, unsigned longs can be cast to a void *, or the void * can be + * used to point to a structure. + * + * @param ulParameter2 The value of the callback function's second parameter. + * + * @param xTicksToWait Calling this function will result in a message being + * sent to the timer daemon task on a queue. xTicksToWait is the amount of + * time the calling task should remain in the Blocked state (so not using any + * processing time) for space to become available on the timer queue if the + * queue is found to be full. + * + * @return pdPASS is returned if the message was successfully sent to the + * timer daemon task, otherwise pdFALSE is returned. + * + */ +BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, + void * pvParameter1, + uint32_t ulParameter2, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; /** * const char * const pcTimerGetName( TimerHandle_t xTimer ); @@ -1187,8 +1260,8 @@ const char * pcTimerGetName( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /*lint /** * void vTimerSetReloadMode( TimerHandle_t xTimer, const UBaseType_t uxAutoReload ); * - * Updates a timer to be either an autoreload timer, in which case the timer - * automatically resets itself each time it expires, or a one shot timer, in + * Updates a timer to be either an auto-reload timer, in which case the timer + * automatically resets itself each time it expires, or a one-shot timer, in * which case the timer will only expire once unless it is manually restarted. * * @param xTimer The handle of the timer being updated. @@ -1199,7 +1272,22 @@ const char * pcTimerGetName( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /*lint * uxAutoReload is set to pdFALSE then the timer will be a one-shot timer and * enter the dormant state after it expires. */ -void vTimerSetReloadMode( TimerHandle_t xTimer, const UBaseType_t uxAutoReload ) PRIVILEGED_FUNCTION; +void vTimerSetReloadMode( TimerHandle_t xTimer, + const UBaseType_t uxAutoReload ) PRIVILEGED_FUNCTION; + +/** + * UBaseType_t uxTimerGetReloadMode( TimerHandle_t xTimer ); + * + * Queries a timer to determine if it is an auto-reload timer, in which case the timer + * automatically resets itself each time it expires, or a one-shot timer, in + * which case the timer will only expire once unless it is manually restarted. + * + * @param xTimer The handle of the timer being queried. + * + * @return If the timer is an auto-reload timer then pdTRUE is returned, otherwise + * pdFALSE is returned. + */ +UBaseType_t uxTimerGetReloadMode( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /** * TickType_t xTimerGetPeriod( TimerHandle_t xTimer ); @@ -1213,18 +1301,18 @@ void vTimerSetReloadMode( TimerHandle_t xTimer, const UBaseType_t uxAutoReload ) TickType_t xTimerGetPeriod( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /** -* TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer ); -* -* 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 ); + * + * 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; /** @cond */ @@ -1234,16 +1322,46 @@ TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; * for use by the kernel only. */ 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; +BaseType_t xTimerGenericCommand( TimerHandle_t xTimer, + const BaseType_t xCommandID, + const TickType_t xOptionalValue, + BaseType_t * const pxHigherPriorityTaskWoken, + const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; -#if( configUSE_TRACE_FACILITY == 1 ) - void vTimerSetTimerNumber( TimerHandle_t xTimer, UBaseType_t uxTimerNumber ) PRIVILEGED_FUNCTION; - UBaseType_t uxTimerGetTimerNumber( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; +#if ( configUSE_TRACE_FACILITY == 1 ) + void vTimerSetTimerNumber( TimerHandle_t xTimer, + UBaseType_t uxTimerNumber ) PRIVILEGED_FUNCTION; + UBaseType_t uxTimerGetTimerNumber( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; #endif /** @endcond */ +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + + /** + * @cond + * task.h + * @code{c} + * void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, StackType_t ** ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize ) + * @endcode + * @endcond + * + * This function is used to provide a statically allocated block of memory to FreeRTOS to hold the Timer Task TCB. This function is required when + * configSUPPORT_STATIC_ALLOCATION is set. For more information see this URI: https://www.FreeRTOS.org/a00110.html#configSUPPORT_STATIC_ALLOCATION + * + * @param ppxTimerTaskTCBBuffer A handle to a statically allocated TCB buffer + * @param ppxTimerTaskStackBuffer A handle to a statically allocated Stack buffer for thie idle task + * @param pulTimerTaskStackSize A pointer to the number of elements that will fit in the allocated stack buffer + */ + void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, + StackType_t ** ppxTimerTaskStackBuffer, + uint32_t * pulTimerTaskStackSize ); + +#endif + +/* *INDENT-OFF* */ #ifdef __cplusplus -} + } #endif +/* *INDENT-ON* */ #endif /* TIMERS_H */ diff --git a/tools/sdk/esp32/include/freertos/port/xtensa/include/freertos/FreeRTOSConfig.h b/tools/sdk/esp32/include/freertos/port/xtensa/include/freertos/FreeRTOSConfig_arch.h similarity index 100% rename from tools/sdk/esp32/include/freertos/port/xtensa/include/freertos/FreeRTOSConfig.h rename to tools/sdk/esp32/include/freertos/port/xtensa/include/freertos/FreeRTOSConfig_arch.h diff --git a/tools/sdk/esp32/include/freertos/port/xtensa/include/freertos/portmacro.h b/tools/sdk/esp32/include/freertos/port/xtensa/include/freertos/portmacro.h index eeabdf786a9..248c86d15c7 100644 --- a/tools/sdk/esp32/include/freertos/port/xtensa/include/freertos/portmacro.h +++ b/tools/sdk/esp32/include/freertos/port/xtensa/include/freertos/portmacro.h @@ -1,5 +1,5 @@ /* - * FreeRTOS Kernel V10.2.1 + * FreeRTOS Kernel V10.4.3 * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of diff --git a/tools/sdk/esp32/include/freertos/port/xtensa/include/freertos/xtensa_rtos.h b/tools/sdk/esp32/include/freertos/port/xtensa/include/freertos/xtensa_rtos.h index d1b40237990..b7793d68038 100644 --- a/tools/sdk/esp32/include/freertos/port/xtensa/include/freertos/xtensa_rtos.h +++ b/tools/sdk/esp32/include/freertos/port/xtensa/include/freertos/xtensa_rtos.h @@ -50,6 +50,7 @@ Should be included by all Xtensa generic and RTOS port-specific sources. #include #include +#include "sdkconfig.h" /* Include any RTOS specific definitions that are needed by this header. @@ -145,7 +146,9 @@ May be coded in or called from C or assembly, per ABI conventions. RTOS may optionally define XT_TICK_PER_SEC in its own way (eg. macro). */ // void XT_RTOS_TIMER_INT(void) +#ifdef CONFIG_FREERTOS_SYSTICK_USES_CCOUNT #define XT_RTOS_TIMER_INT _frxt_timer_int +#endif #define XT_TICK_PER_SEC configTICK_RATE_HZ /* diff --git a/tools/sdk/esp32/include/hal/esp32/include/hal/adc_ll.h b/tools/sdk/esp32/include/hal/esp32/include/hal/adc_ll.h index 587d7e7a340..1b5969ac433 100644 --- a/tools/sdk/esp32/include/hal/esp32/include/hal/adc_ll.h +++ b/tools/sdk/esp32/include/hal/esp32/include/hal/adc_ll.h @@ -3,7 +3,11 @@ #include "soc/adc_periph.h" #include "hal/adc_types.h" #include "soc/rtc_io_struct.h" +#include "soc/sens_struct.h" +#include "soc/syscon_struct.h" +#include "soc/rtc_cntl_struct.h" #include +#include "hal/misc.h" #ifdef __cplusplus extern "C" { @@ -52,11 +56,11 @@ typedef enum { static inline void adc_ll_digi_set_fsm_time(uint32_t rst_wait, uint32_t start_wait, uint32_t standby_wait) { // Internal FSM reset wait time - SYSCON.saradc_fsm.rstb_wait = rst_wait; + HAL_FORCE_MODIFY_U32_REG_FIELD(SYSCON.saradc_fsm, rstb_wait, rst_wait); // Internal FSM start wait time - SYSCON.saradc_fsm.start_wait = start_wait; + HAL_FORCE_MODIFY_U32_REG_FIELD(SYSCON.saradc_fsm, start_wait, start_wait); // Internal FSM standby wait time - SYSCON.saradc_fsm.standby_wait = standby_wait; + HAL_FORCE_MODIFY_U32_REG_FIELD(SYSCON.saradc_fsm, standby_wait, standby_wait); } /** @@ -67,7 +71,7 @@ static inline void adc_ll_digi_set_fsm_time(uint32_t rst_wait, uint32_t start_wa */ static inline void adc_ll_set_sample_cycle(uint32_t sample_cycle) { - SYSCON.saradc_fsm.sample_cycle = sample_cycle; + HAL_FORCE_MODIFY_U32_REG_FIELD(SYSCON.saradc_fsm, sample_cycle, sample_cycle); } /** @@ -78,7 +82,7 @@ static inline void adc_ll_set_sample_cycle(uint32_t sample_cycle) static inline void adc_ll_digi_set_clk_div(uint32_t div) { /* ADC clock divided from APB clk, e.g. 80 / 2 = 40Mhz, */ - SYSCON.saradc_ctrl.sar_clk_div = div; + HAL_FORCE_MODIFY_U32_REG_FIELD(SYSCON.saradc_ctrl, sar_clk_div, div); } /** @@ -99,7 +103,7 @@ static inline void adc_ll_digi_set_output_format(adc_digi_output_format_t format */ static inline void adc_ll_digi_set_convert_limit_num(uint32_t meas_num) { - SYSCON.saradc_ctrl2.max_meas_num = meas_num; + HAL_FORCE_MODIFY_U32_REG_FIELD(SYSCON.saradc_ctrl2, max_meas_num, meas_num); } /** @@ -320,7 +324,7 @@ static inline void adc_ll_rtc_disable_channel(adc_ll_num_t adc_n) static inline void adc_ll_rtc_start_convert(adc_ll_num_t adc_n, int channel) { if (adc_n == ADC_NUM_1) { - while (SENS.sar_slave_addr1.meas_status != 0); + while (HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_slave_addr1, meas_status) != 0) {} SENS.sar_meas_start1.meas1_start_sar = 0; SENS.sar_meas_start1.meas1_start_sar = 1; } else { // adc_n == ADC_NUM_2 @@ -359,9 +363,9 @@ static inline int adc_ll_rtc_get_convert_value(adc_ll_num_t adc_n) { int ret_val = 0; if (adc_n == ADC_NUM_1) { - ret_val = SENS.sar_meas_start1.meas1_data_sar; + ret_val = HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_meas_start1, meas1_data_sar); } else { // adc_n == ADC_NUM_2 - ret_val = SENS.sar_meas_start2.meas2_data_sar; + ret_val = HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_meas_start2, meas2_data_sar); } return ret_val; } @@ -444,9 +448,9 @@ static inline adc_ll_power_t adc_ll_get_power_manage(void) static inline void adc_ll_set_sar_clk_div(adc_ll_num_t adc_n, uint32_t div) { if (adc_n == ADC_NUM_1) { - SENS.sar_read_ctrl.sar1_clk_div = div; + HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.sar_read_ctrl, sar1_clk_div, div); } else { // adc_n == ADC_NUM_2 - SENS.sar_read_ctrl2.sar2_clk_div = div; + HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.sar_read_ctrl2, sar2_clk_div, div); } } @@ -563,9 +567,9 @@ static inline void adc_ll_amp_disable(void) SENS.sar_meas_ctrl.amp_rst_fb_fsm = 0; SENS.sar_meas_ctrl.amp_short_ref_fsm = 0; SENS.sar_meas_ctrl.amp_short_ref_gnd_fsm = 0; - SENS.sar_meas_wait1.sar_amp_wait1 = 1; - SENS.sar_meas_wait1.sar_amp_wait2 = 1; - SENS.sar_meas_wait2.sar_amp_wait3 = 1; + HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.sar_meas_wait1, sar_amp_wait1, 1); + HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.sar_meas_wait1, sar_amp_wait2, 1); + HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.sar_meas_wait2, sar_amp_wait3, 1); } /*--------------------------------------------------------------- diff --git a/tools/sdk/esp32/include/hal/esp32/include/hal/aes_ll.h b/tools/sdk/esp32/include/hal/esp32/include/hal/aes_ll.h index 8283397dded..b0142cbe685 100644 --- a/tools/sdk/esp32/include/hal/esp32/include/hal/aes_ll.h +++ b/tools/sdk/esp32/include/hal/esp32/include/hal/aes_ll.h @@ -1,4 +1,4 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD +// Copyright 2020-2021 Espressif Systems (Shanghai) CO LTD // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ #include "soc/hwcrypto_reg.h" #include "soc/dport_access.h" #include "hal/aes_types.h" +#include #ifdef __cplusplus extern "C" { @@ -46,10 +47,13 @@ static inline uint8_t aes_ll_write_key(const uint8_t *key, size_t key_word_len) { /* This variable is used for fault injection checks, so marked volatile to avoid optimisation */ volatile uint8_t key_bytes_in_hardware = 0; - uint32_t *key_words = (uint32_t *)key; + + /* Memcpy to avoid potential unaligned access */ + uint32_t key_word; for (int i = 0; i < key_word_len; i++) { - DPORT_REG_WRITE(AES_KEY_BASE + i * 4, *(key_words + i)); + memcpy(&key_word, key + 4 * i, 4); + DPORT_REG_WRITE(AES_KEY_BASE + i * 4, key_word); key_bytes_in_hardware += 4; } return key_bytes_in_hardware; diff --git a/tools/sdk/esp32/include/hal/esp32/include/hal/dac_ll.h b/tools/sdk/esp32/include/hal/esp32/include/hal/dac_ll.h index 5ea4da8978d..ec1c20c4fb3 100644 --- a/tools/sdk/esp32/include/hal/esp32/include/hal/dac_ll.h +++ b/tools/sdk/esp32/include/hal/esp32/include/hal/dac_ll.h @@ -21,7 +21,10 @@ #pragma once #include +#include "hal/misc.h" #include "soc/dac_periph.h" +#include "soc/rtc_io_struct.h" +#include "soc/sens_struct.h" #include "hal/dac_types.h" #ifdef __cplusplus @@ -62,10 +65,10 @@ static inline void dac_ll_update_output_value(dac_channel_t channel, uint8_t val { if (channel == DAC_CHANNEL_1) { SENS.sar_dac_ctrl2.dac_cw_en1 = 0; - RTCIO.pad_dac[channel].dac = value; + HAL_FORCE_MODIFY_U32_REG_FIELD(RTCIO.pad_dac[channel], dac, value); } else if (channel == DAC_CHANNEL_2) { SENS.sar_dac_ctrl2.dac_cw_en2 = 0; - RTCIO.pad_dac[channel].dac = value; + HAL_FORCE_MODIFY_U32_REG_FIELD(RTCIO.pad_dac[channel], dac, value); } } @@ -124,7 +127,7 @@ static inline void dac_ll_cw_set_channel(dac_channel_t channel, bool enable) static inline void dac_ll_cw_set_freq(uint32_t freq) { uint32_t sw_freq = freq * 0xFFFF / RTC_FAST_CLK_FREQ_APPROX; - SENS.sar_dac_ctrl1.sw_fstep = (sw_freq > 0xFFFF) ? 0xFFFF : sw_freq; + HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.sar_dac_ctrl1, sw_fstep, (sw_freq > 0xFFFF) ? 0xFFFF : sw_freq); } /** @@ -171,12 +174,12 @@ static inline void dac_ll_cw_set_dc_offset(dac_channel_t channel, int8_t offset) if (SENS.sar_dac_ctrl2.dac_inv1 == DAC_CW_PHASE_180) { offset = 0 - offset; } - SENS.sar_dac_ctrl2.dac_dc1 = offset ? offset : (-128 - offset); + HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.sar_dac_ctrl2, dac_dc1, offset ? offset : (-128 - offset)); } else if (channel == DAC_CHANNEL_2) { if (SENS.sar_dac_ctrl2.dac_inv2 == DAC_CW_PHASE_180) { offset = 0 - offset; } - SENS.sar_dac_ctrl2.dac_dc2 = offset ? offset : (-128 - offset); + HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.sar_dac_ctrl2, dac_dc2, offset ? offset : (-128 - offset)); } } diff --git a/tools/sdk/esp32/include/hal/esp32/include/hal/emac_ll.h b/tools/sdk/esp32/include/hal/esp32/include/hal/emac_ll.h index 36477e36f55..625687b6a09 100644 --- a/tools/sdk/esp32/include/hal/esp32/include/hal/emac_ll.h +++ b/tools/sdk/esp32/include/hal/esp32/include/hal/emac_ll.h @@ -23,6 +23,7 @@ #pragma once #include +#include "hal/misc.h" #include "hal/eth_types.h" #include "soc/emac_dma_struct.h" #include "soc/emac_mac_struct.h" @@ -136,7 +137,7 @@ extern "C" { #define EMAC_LL_INTR_OVERFLOW_ENABLE 0x00000010U #define EMAC_LL_INTR_UNDERFLOW_ENABLE 0x00000020U #define EMAC_LL_INTR_RECEIVE_ENABLE 0x00000040U -#define EMAC_LL_INTR_REVEIVE_BUFF_UNAVAILABLE_ENABLE 0x00000080U +#define EMAC_LL_INTR_RECEIVE_BUFF_UNAVAILABLE_ENABLE 0x00000080U #define EMAC_LL_INTR_RECEIVE_STOP_ENABLE 0x00000100U #define EMAC_LL_INTR_RECEIVE_TIMEOUT_ENABLE 0x00000200U #define EMAC_LL_INTR_TRANSMIT_FIRST_BYTE_ENABLE 0x00000400U @@ -310,7 +311,7 @@ static inline void emac_ll_promiscuous_mode_enable(emac_mac_dev_t *mac_regs, boo /* gmacfc */ static inline void emac_ll_set_pause_time(emac_mac_dev_t *mac_regs, uint32_t time) { - mac_regs->gmacfc.pause_time = time; + HAL_FORCE_MODIFY_U32_REG_FIELD(mac_regs->gmacfc, pause_time, time); } static inline void emac_ll_zero_quanta_pause_enable(emac_mac_dev_t *mac_regs, bool enable) @@ -346,18 +347,18 @@ static inline void emac_ll_clear(emac_mac_dev_t *mac_regs) /* emacmiidata */ static inline void emac_ll_set_phy_data(emac_mac_dev_t *mac_regs, uint32_t data) { - mac_regs->emacmiidata.mii_data = data; + HAL_FORCE_MODIFY_U32_REG_FIELD(mac_regs->emacmiidata, mii_data, data); } static inline uint32_t emac_ll_get_phy_data(emac_mac_dev_t *mac_regs) { - return mac_regs->emacmiidata.mii_data; + return HAL_FORCE_READ_U32_REG_FIELD(mac_regs->emacmiidata, mii_data); } /* emacaddr0 */ static inline void emac_ll_set_addr(emac_mac_dev_t *mac_regs, const uint8_t *addr) { - mac_regs->emacaddr0high.address0_hi = (addr[5] << 8) | addr[4]; + HAL_FORCE_MODIFY_U32_REG_FIELD(mac_regs->emacaddr0high, address0_hi, (addr[5] << 8) | addr[4]); mac_regs->emacaddr0low = (addr[3] << 24) | (addr[2] << 16) | (addr[1] << 8) | (addr[0]); } /*************** End of mac regs operation *********************/ @@ -405,7 +406,7 @@ static inline void emac_ll_flush_recv_frame_enable(emac_dma_dev_t *dma_regs, boo static inline void emac_ll_trans_store_forward_enable(emac_dma_dev_t *dma_regs, bool enable) { - dma_regs->dmaoperation_mode.tx_str_fwd = !enable; + dma_regs->dmaoperation_mode.tx_str_fwd = enable; } static inline void emac_ll_flush_trans_fifo_enable(emac_dma_dev_t *dma_regs, bool enable) diff --git a/tools/sdk/esp32/include/hal/esp32/include/hal/gpio_ll.h b/tools/sdk/esp32/include/hal/esp32/include/hal/gpio_ll.h index 8c1acb3a1cf..f5ac5909d5e 100644 --- a/tools/sdk/esp32/include/hal/esp32/include/hal/gpio_ll.h +++ b/tools/sdk/esp32/include/hal/esp32/include/hal/gpio_ll.h @@ -25,9 +25,11 @@ #include #include "soc/soc.h" #include "soc/gpio_periph.h" +#include "soc/gpio_struct.h" #include "soc/rtc_cntl_reg.h" #include "soc/rtc_io_reg.h" #include "hal/gpio_types.h" +#include "hal/misc.h" #ifdef __cplusplus extern "C" { @@ -245,7 +247,7 @@ static inline void gpio_ll_get_intr_status(gpio_dev_t *hw, uint32_t core_id, uin */ static inline void gpio_ll_get_intr_status_high(gpio_dev_t *hw, uint32_t core_id, uint32_t *status) { - *status = (core_id == 0) ? hw->pcpu_int1.intr : hw->acpu_int1.intr; + *status = (core_id == 0) ? HAL_FORCE_READ_U32_REG_FIELD(hw->pcpu_int1, intr) : HAL_FORCE_READ_U32_REG_FIELD(hw->pcpu_int1, intr); } /** @@ -267,7 +269,7 @@ static inline void gpio_ll_clear_intr_status(gpio_dev_t *hw, uint32_t mask) */ static inline void gpio_ll_clear_intr_status_high(gpio_dev_t *hw, uint32_t mask) { - hw->status1_w1tc.intr_st = mask; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->status1_w1tc, intr_st, mask); } /** @@ -330,7 +332,7 @@ static inline void gpio_ll_output_disable(gpio_dev_t *hw, gpio_num_t gpio_num) if (gpio_num < 32) { hw->enable_w1tc = (0x1 << gpio_num); } else { - hw->enable1_w1tc.data = (0x1 << (gpio_num - 32)); + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->enable1_w1tc, data, (0x1 << (gpio_num - 32))); } // Ensure no other output signal is routed via GPIO matrix to this pin @@ -349,7 +351,7 @@ static inline void gpio_ll_output_enable(gpio_dev_t *hw, gpio_num_t gpio_num) if (gpio_num < 32) { hw->enable_w1ts = (0x1 << gpio_num); } else { - hw->enable1_w1ts.data = (0x1 << (gpio_num - 32)); + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->enable1_w1ts, data, (0x1 << (gpio_num - 32))); } } @@ -432,13 +434,13 @@ static inline void gpio_ll_set_level(gpio_dev_t *hw, gpio_num_t gpio_num, uint32 if (gpio_num < 32) { hw->out_w1ts = (1 << gpio_num); } else { - hw->out1_w1ts.data = (1 << (gpio_num - 32)); + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->out1_w1ts, data, (1 << (gpio_num - 32))); } } else { if (gpio_num < 32) { hw->out_w1tc = (1 << gpio_num); } else { - hw->out1_w1tc.data = (1 << (gpio_num - 32)); + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->out1_w1tc, data, (1 << (gpio_num - 32))); } } } @@ -460,7 +462,7 @@ static inline int gpio_ll_get_level(gpio_dev_t *hw, gpio_num_t gpio_num) if (gpio_num < 32) { return (hw->in >> gpio_num) & 0x1; } else { - return (hw->in1.data >> (gpio_num - 32)) & 0x1; + return (HAL_FORCE_READ_U32_REG_FIELD(hw->in1, data) >> (gpio_num - 32)) & 0x1; } } diff --git a/tools/sdk/esp32/include/hal/esp32/include/hal/i2c_ll.h b/tools/sdk/esp32/include/hal/esp32/include/hal/i2c_ll.h index 550c1b76d25..650dbbaa048 100644 --- a/tools/sdk/esp32/include/hal/esp32/include/hal/i2c_ll.h +++ b/tools/sdk/esp32/include/hal/esp32/include/hal/i2c_ll.h @@ -15,7 +15,10 @@ // The LL layer for I2C register operations #pragma once + +#include "hal/misc.h" #include "soc/i2c_periph.h" +#include "soc/i2c_struct.h" #include "hal/i2c_types.h" #ifdef __cplusplus @@ -558,7 +561,7 @@ static inline void i2c_ll_write_txfifo(i2c_dev_t *hw, uint8_t *ptr, uint8_t len) static inline void i2c_ll_read_rxfifo(i2c_dev_t *hw, uint8_t *ptr, uint8_t len) { for(int i = 0; i < len; i++) { - ptr[i] = hw->fifo_data.data; + ptr[i] = HAL_FORCE_READ_U32_REG_FIELD(hw->fifo_data, data); } } diff --git a/tools/sdk/esp32/include/hal/esp32/include/hal/i2s_ll.h b/tools/sdk/esp32/include/hal/esp32/include/hal/i2s_ll.h index 96d4a3f8ec8..fd20c406cb6 100644 --- a/tools/sdk/esp32/include/hal/esp32/include/hal/i2s_ll.h +++ b/tools/sdk/esp32/include/hal/esp32/include/hal/i2s_ll.h @@ -1,4 +1,4 @@ -// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD +// Copyright 2020 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. @@ -23,10 +23,9 @@ #pragma once #include -#include "soc/rtc_periph.h" -#include "soc/rtc.h" -#include "soc/efuse_periph.h" +#include "hal/misc.h" #include "soc/i2s_periph.h" +#include "soc/i2s_struct.h" #include "hal/i2s_types.h" #ifdef __cplusplus @@ -36,813 +35,904 @@ extern "C" { // Get I2S hardware instance with giving i2s num #define I2S_LL_GET_HW(num) (((num) == 0) ? (&I2S0) : (((num) == 1) ? (&I2S1) : NULL)) -#define I2S_INTR_IN_SUC_EOF BIT(9) -#define I2S_INTR_OUT_EOF BIT(12) -#define I2S_INTR_IN_DSCR_ERR BIT(13) -#define I2S_INTR_OUT_DSCR_ERR BIT(14) -#define I2S_INTR_MAX (0xFFFFFFFF) +#define I2S_LL_AD_BCK_FACTOR (2) +#define I2S_LL_PDM_BCK_FACTOR (64) +#define I2S_LL_BASE_CLK (2 * APB_CLK_FREQ) + +#define I2S_LL_MCLK_DIVIDER_BIT_WIDTH (6) +#define I2S_LL_MCLK_DIVIDER_MAX ((1 << I2S_LL_MCLK_DIVIDER_BIT_WIDTH) - 1) + +#define I2S_LL_EVENT_TX_EOF (1 << 12) +#define I2S_LL_BCK_MAX_PRESCALE (64) + +/* I2S clock configuration structure */ +typedef struct { + uint16_t mclk_div; // I2S module clock devider, Fmclk = Fsclk /(mclk_div+b/a) + uint16_t a; + uint16_t b; // The decimal part of module clock devider, the decimal is: b/a +} i2s_ll_mclk_div_t; /** - * @brief Reset rx fifo + * @brief Enable DMA descriptor owner check * * @param hw Peripheral I2S hardware instance address. + * @param en whether to enable owner check */ -static inline void i2s_ll_reset_rx_fifo(i2s_dev_t *hw) +static inline void i2s_ll_dma_enable_owner_check(i2s_dev_t *hw, bool en) { - hw->conf.rx_fifo_reset = 1; - hw->conf.rx_fifo_reset = 0; + hw->lc_conf.check_owner = en; } /** - * @brief Reset tx fifo + * @brief Enable DMA descriptor write back * * @param hw Peripheral I2S hardware instance address. + * @param en whether to enable write back */ -static inline void i2s_ll_reset_tx_fifo(i2s_dev_t *hw) +static inline void i2s_ll_dma_enable_auto_write_back(i2s_dev_t *hw, bool en) { - hw->conf.tx_fifo_reset = 1; - hw->conf.tx_fifo_reset = 0; + hw->lc_conf.out_auto_wrback = en; } /** - * @brief Enable rx interrupt + * @brief I2S DMA generate EOF event on data in FIFO poped out * * @param hw Peripheral I2S hardware instance address. + * @param en True to enable, False to disable */ -static inline void i2s_ll_enable_rx_intr(i2s_dev_t *hw) +static inline void i2s_ll_dma_enable_eof_on_fifo_empty(i2s_dev_t *hw, bool en) { - hw->int_ena.in_suc_eof = 1; - hw->int_ena.in_dscr_err = 1; + hw->lc_conf.out_eof_mode = en; } /** - * @brief Disable rx interrupt + * @brief I2S module general init, enable I2S clock. * * @param hw Peripheral I2S hardware instance address. */ -static inline void i2s_ll_disable_rx_intr(i2s_dev_t *hw) +static inline void i2s_ll_enable_clock(i2s_dev_t *hw) { - hw->int_ena.in_suc_eof = 0; - hw->int_ena.in_dscr_err = 0; + if (hw->clkm_conf.clk_en == 0) { + hw->clkm_conf.clk_en = 1; + hw->conf2.val = 0; + } } /** - * @brief Disable tx interrupt + * @brief I2S module disable clock. * * @param hw Peripheral I2S hardware instance address. */ -static inline void i2s_ll_disable_tx_intr(i2s_dev_t *hw) +static inline void i2s_ll_disable_clock(i2s_dev_t *hw) { - hw->int_ena.out_eof = 0; - hw->int_ena.out_dscr_err = 0; + if (hw->clkm_conf.clk_en == 1) { + hw->clkm_conf.clk_en = 0; + } } /** - * @brief Enable tx interrupt + * @brief I2S tx msb right enable * * @param hw Peripheral I2S hardware instance address. + * @param enable Set true to enable tx msb right */ -static inline void i2s_ll_enable_tx_intr(i2s_dev_t *hw) +static inline void i2s_ll_tx_enable_msb_right(i2s_dev_t *hw, bool enable) { - hw->int_ena.out_eof = 1; - hw->int_ena.out_dscr_err = 1; + hw->conf.tx_msb_right = enable; } /** - * @brief Reset dma in + * @brief I2S rx msb right enable * * @param hw Peripheral I2S hardware instance address. + * @param enable Set true to enable rx msb right */ -static inline void i2s_ll_reset_dma_in(i2s_dev_t *hw) +static inline void i2s_ll_rx_enable_msb_right(i2s_dev_t *hw, bool enable) { - hw->lc_conf.in_rst = 1; - hw->lc_conf.in_rst = 0; + hw->conf.rx_msb_right = enable; } /** - * @brief Reset dma out + * @brief I2S tx right channel first * * @param hw Peripheral I2S hardware instance address. + * @param enable Set true to enable send right channel first */ -static inline void i2s_ll_reset_dma_out(i2s_dev_t *hw) +static inline void i2s_ll_tx_enable_right_first(i2s_dev_t *hw, bool enable) { - hw->lc_conf.out_rst = 1; - hw->lc_conf.out_rst = 0; + hw->conf.tx_right_first = enable; } /** - * @brief Reset tx + * @brief I2S rx right channel first * * @param hw Peripheral I2S hardware instance address. + * @param enable Set true to enable receive right channel first */ -static inline void i2s_ll_reset_tx(i2s_dev_t *hw) +static inline void i2s_ll_rx_enable_right_first(i2s_dev_t *hw, bool enable) { - hw->conf.tx_reset = 1; - hw->conf.tx_reset = 0; + hw->conf.rx_right_first = enable; } /** - * @brief Reset rx + * @brief I2S tx fifo module force enable * * @param hw Peripheral I2S hardware instance address. + * @param enable Set true to enable tx fifo module */ -static inline void i2s_ll_reset_rx(i2s_dev_t *hw) +static inline void i2s_ll_tx_force_enable_fifo_mod(i2s_dev_t *hw, bool enable) { - hw->conf.rx_reset = 1; - hw->conf.rx_reset = 0; + hw->fifo_conf.tx_fifo_mod_force_en = enable; } /** - * @brief Start out link + * @brief I2S rx fifo module force enable * * @param hw Peripheral I2S hardware instance address. + * @param enable Set true to enable rx fifo module */ -static inline void i2s_ll_start_out_link(i2s_dev_t *hw) +static inline void i2s_ll_rx_force_enable_fifo_mod(i2s_dev_t *hw, bool enable) { - hw->out_link.start = 1; + hw->fifo_conf.rx_fifo_mod_force_en = enable; } - /** - * @brief Start tx + * @brief Enable I2S TX slave mode * * @param hw Peripheral I2S hardware instance address. + * @param slave_en Set true to enable slave mode */ -static inline void i2s_ll_start_tx(i2s_dev_t *hw) +static inline void i2s_ll_tx_set_slave_mod(i2s_dev_t *hw, bool slave_en) { - hw->conf.tx_start = 1; + hw->conf.tx_slave_mod = slave_en; } /** - * @brief Start in link + * @brief Enable I2S RX slave mode * * @param hw Peripheral I2S hardware instance address. + * @param slave_en Set true to enable slave mode */ -static inline void i2s_ll_start_in_link(i2s_dev_t *hw) +static inline void i2s_ll_rx_set_slave_mod(i2s_dev_t *hw, bool slave_en) { - hw->in_link.start = 1; + hw->conf.rx_slave_mod = slave_en; } /** - * @brief Start rx + * @brief Reset I2S TX module * * @param hw Peripheral I2S hardware instance address. */ -static inline void i2s_ll_start_rx(i2s_dev_t *hw) +static inline void i2s_ll_tx_reset(i2s_dev_t *hw) { - hw->conf.rx_start = 1; + hw->conf.tx_reset = 1; + hw->conf.tx_reset = 0; } /** - * @brief Stop out link + * @brief Reset I2S RX module * * @param hw Peripheral I2S hardware instance address. */ -static inline void i2s_ll_stop_out_link(i2s_dev_t *hw) +static inline void i2s_ll_rx_reset(i2s_dev_t *hw) { - hw->out_link.stop = 1; + hw->conf.rx_reset = 1; + hw->conf.rx_reset = 0; } /** - * @brief Stop tx + * @brief Reset I2S TX FIFO * * @param hw Peripheral I2S hardware instance address. */ -static inline void i2s_ll_stop_tx(i2s_dev_t *hw) +static inline void i2s_ll_tx_reset_fifo(i2s_dev_t *hw) { - hw->conf.tx_start = 0; + hw->conf.tx_fifo_reset = 1; + hw->conf.tx_fifo_reset = 0; } /** - * @brief Stop in link + * @brief Reset I2S RX FIFO * * @param hw Peripheral I2S hardware instance address. */ -static inline void i2s_ll_stop_in_link(i2s_dev_t *hw) +static inline void i2s_ll_rx_reset_fifo(i2s_dev_t *hw) { - hw->in_link.stop = 1; + hw->conf.rx_fifo_reset = 1; + hw->conf.rx_fifo_reset = 0; } /** - * @brief Stop rx + * @brief Set TX source clock * * @param hw Peripheral I2S hardware instance address. + * @param src I2S source clock */ -static inline void i2s_ll_stop_rx(i2s_dev_t *hw) +static inline void i2s_ll_tx_clk_set_src(i2s_dev_t *hw, i2s_clock_src_t src) { - hw->conf.rx_start = 0; + //0: disable APLL clock, I2S module will using PLL_D2_CLK(160M) as source clock + //1: Enable APLL clock, I2S module will using APLL as source clock + hw->clkm_conf.clka_en = (src == I2S_CLK_APLL) ? 1 : 0; } /** - * @brief Enable dma + * @brief Set RX source clock * * @param hw Peripheral I2S hardware instance address. + * @param src I2S source clock */ -static inline void i2s_ll_enable_dma(i2s_dev_t *hw) +static inline void i2s_ll_rx_clk_set_src(i2s_dev_t *hw, i2s_clock_src_t src) { - //Enable and configure DMA - typeof(hw->lc_conf) lc_conf; - lc_conf.val = 0; - lc_conf.out_eof_mode = 1; - hw->lc_conf.val = lc_conf.val; + //0: disable APLL clock, I2S module will using PLL_D2_CLK(160M) as source clock + //1: Enable APLL clock, I2S module will using APLL as source clock + hw->clkm_conf.clka_en = (src == I2S_CLK_APLL) ? 1 : 0; } /** - * @brief Get I2S interrupt status + * @brief Set I2S tx bck div num * * @param hw Peripheral I2S hardware instance address. - * @param val value to get interrupt status + * @param val value to set tx bck div num */ -static inline void i2s_ll_get_intr_status(i2s_dev_t *hw, uint32_t *val) +static inline void i2s_ll_tx_set_bck_div_num(i2s_dev_t *hw, uint32_t val) { - *val = hw->int_st.val; + hw->sample_rate_conf.tx_bck_div_num = val; } /** - * @brief Clear I2S interrupt status + * @brief Configure I2S TX clock devider * * @param hw Peripheral I2S hardware instance address. - * @param val value to clear interrupt status + * @param set Pointer to I2S clock devider configuration paramater */ -static inline void i2s_ll_clear_intr_status(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_set_clk(i2s_dev_t *hw, i2s_ll_mclk_div_t *set) { - hw->int_clr.val = val; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->clkm_conf, clkm_div_num, set->mclk_div); + hw->clkm_conf.clkm_div_b = set->b; + hw->clkm_conf.clkm_div_a = set->a; } /** - * @brief Get I2S out eof des address + * @brief Set I2S rx bck div num * * @param hw Peripheral I2S hardware instance address. - * @param val value to get out eof des address + * @param val value to set rx bck div num */ -static inline void i2s_ll_get_out_eof_des_addr(i2s_dev_t *hw, uint32_t *val) +static inline void i2s_ll_rx_set_bck_div_num(i2s_dev_t *hw, uint32_t val) { - *val = hw->out_eof_des_addr; + hw->sample_rate_conf.rx_bck_div_num = val; } /** - * @brief Get I2S in eof des address + * @brief Configure I2S RX clock devider * * @param hw Peripheral I2S hardware instance address. - * @param val value to get in eof des address + * @param set Pointer to I2S clock devider configuration paramater */ -static inline void i2s_ll_get_in_eof_des_addr(i2s_dev_t *hw, uint32_t *val) +static inline void i2s_ll_rx_set_clk(i2s_dev_t *hw, i2s_ll_mclk_div_t *set) { - *val = hw->in_eof_des_addr; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->clkm_conf, clkm_div_num, set->mclk_div); + hw->clkm_conf.clkm_div_b = set->b; + hw->clkm_conf.clkm_div_a = set->a; } /** - * @brief Get I2S tx fifo mode + * @brief Enable interrupt by mask * * @param hw Peripheral I2S hardware instance address. - * @param val value to get tx fifo mode + * @param mask Interrupt event mask + * @param en true to enable, false to disable */ -static inline void i2s_ll_get_tx_fifo_mod(i2s_dev_t *hw, uint32_t *val) +static inline void i2s_ll_enable_intr(i2s_dev_t *hw, uint32_t mask, bool en) { - *val = hw->fifo_conf.tx_fifo_mod; + if (en) { + hw->int_ena.val |= mask; + } else { + hw->int_ena.val &= ~mask; + } } /** - * @brief Set I2S tx fifo mode + * @brief Enable TX interrupt * * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx fifo mode */ -static inline void i2s_ll_set_tx_fifo_mod(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_enable_intr(i2s_dev_t *hw) { - hw->fifo_conf.tx_fifo_mod = val; + hw->int_ena.out_eof = 1; + hw->int_ena.out_dscr_err = 1; } /** - * @brief Get I2S rx fifo mode + * @brief Disable TX interrupt * * @param hw Peripheral I2S hardware instance address. - * @param val value to get rx fifo mode */ -static inline void i2s_ll_get_rx_fifo_mod(i2s_dev_t *hw, uint32_t *val) +static inline void i2s_ll_tx_disable_intr(i2s_dev_t *hw) { - *val = hw->fifo_conf.rx_fifo_mod; + hw->int_ena.out_eof = 0; + hw->int_ena.out_dscr_err = 0; } /** - * @brief Set I2S rx fifo mode + * @brief Enable RX interrupt * * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx fifo mode */ -static inline void i2s_ll_set_rx_fifo_mod(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_enable_intr(i2s_dev_t *hw) { - hw->fifo_conf.rx_fifo_mod = val; + hw->int_ena.in_suc_eof = 1; + hw->int_ena.in_dscr_err = 1; } /** - * @brief Set I2S tx chan mode + * @brief Disable RX interrupt * * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx chan mode */ -static inline void i2s_ll_set_tx_chan_mod(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_disable_intr(i2s_dev_t *hw) { - hw->conf_chan.tx_chan_mod = val; + hw->int_ena.in_suc_eof = 0; + hw->int_ena.in_dscr_err = 0; } /** - * @brief Set I2S rx chan mode + * @brief Get interrupt status register address * * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx chan mode + * @return interrupt status register address */ -static inline void i2s_ll_set_rx_chan_mod(i2s_dev_t *hw, uint32_t val) +static inline volatile void *i2s_ll_get_intr_status_reg(i2s_dev_t *hw) { - hw->conf_chan.rx_chan_mod = val; + return &hw->int_st; } /** - * @brief Set I2S out link address + * @brief Get I2S interrupt status * * @param hw Peripheral I2S hardware instance address. - * @param val value to set out link address + * @return + * - module interrupt status */ -static inline void i2s_ll_set_out_link_addr(i2s_dev_t *hw, uint32_t val) +static inline uint32_t i2s_ll_get_intr_status(i2s_dev_t *hw) { - hw->out_link.addr = val; + return hw->int_st.val; } /** - * @brief Set I2S in link address + * @brief Clear I2S interrupt status * * @param hw Peripheral I2S hardware instance address. - * @param val value to set in link address + * @param clr_mask Interrupt mask to clear interrupt status */ -static inline void i2s_ll_set_in_link_addr(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_clear_intr_status(i2s_dev_t *hw, uint32_t clr_mask) { - hw->in_link.addr = val; + hw->int_clr.val = clr_mask; } /** - * @brief Set I2S rx eof num + * @brief Reset dma out * * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx eof num */ -static inline void i2s_ll_set_rx_eof_num(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_reset_dma(i2s_dev_t *hw) { - // On ESP32, the eof_num count in words. - hw->rx_eof_num = val / 4; + hw->lc_conf.out_rst = 1; + hw->lc_conf.out_rst = 0; } /** - * @brief Set I2S clkm div num + * @brief Reset dma in * * @param hw Peripheral I2S hardware instance address. - * @param val value to set clkm div num */ -static inline void i2s_ll_set_clkm_div_num(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_reset_dma(i2s_dev_t *hw) { - hw->clkm_conf.clkm_div_num = val; + hw->lc_conf.in_rst = 1; + hw->lc_conf.in_rst = 0; } /** - * @brief Set I2S clkm div b + * @brief Start out link * * @param hw Peripheral I2S hardware instance address. - * @param val value to set clkm div b */ -static inline void i2s_ll_set_clkm_div_b(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_start_out_link(i2s_dev_t *hw) { - hw->clkm_conf.clkm_div_b = val; + hw->out_link.start = 1; } /** - * @brief Set I2S clkm div a + * @brief Set I2S out link address * * @param hw Peripheral I2S hardware instance address. - * @param val value to set clkm div a + * @param val value to set out link address */ -static inline void i2s_ll_set_clkm_div_a(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_set_out_link_addr(i2s_dev_t *hw, uint32_t val) { - hw->clkm_conf.clkm_div_a = val; + hw->out_link.addr = val; } /** - * @brief Set I2S tx bck div num + * @brief Start TX module * * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx bck div num */ -static inline void i2s_ll_set_tx_bck_div_num(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_start(i2s_dev_t *hw) { - hw->sample_rate_conf.tx_bck_div_num = val; + hw->conf.tx_start = 1; } /** - * @brief Set I2S rx bck div num + * @brief Start RX module * * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx bck div num */ -static inline void i2s_ll_set_rx_bck_div_num(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_start(i2s_dev_t *hw) { - hw->sample_rate_conf.rx_bck_div_num = val; + hw->conf.rx_start = 1; } /** - * @brief Set I2S clk sel + * @brief Configure TX DMA descriptor address and start TX DMA * * @param hw Peripheral I2S hardware instance address. - * @param val value to set clk sel + * @param link_addr DMA descriptor link address. */ -static inline void i2s_ll_set_clk_sel(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_start_link(i2s_dev_t *hw, uint32_t link_addr) { - hw->clkm_conf.clka_en = (val == 1) ? 1 : 0; + i2s_ll_set_out_link_addr(hw, link_addr); + i2s_ll_start_out_link(hw); } /** - * @brief Set I2S tx bits mod + * @brief Configure RX DMA descriptor address and start RX DMA * * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx bits mod + * @param link_addr DMA descriptor link address. */ -static inline void i2s_ll_set_tx_bits_mod(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_start_link(i2s_dev_t *hw, uint32_t link_addr) { - hw->sample_rate_conf.tx_bits_mod = val; + hw->in_link.addr = link_addr; + hw->in_link.start = 1; } /** - * @brief Set I2S rx bits mod + * @brief Stop TX module * * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx bits mod */ -static inline void i2s_ll_set_rx_bits_mod(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_stop(i2s_dev_t *hw) { - hw->sample_rate_conf.rx_bits_mod = val; + hw->conf.tx_start = 0; } /** - * @brief Set I2S dscr en + * @brief Stop RX module * * @param hw Peripheral I2S hardware instance address. - * @param val value to set dscr en */ -static inline void i2s_ll_set_dscr_en(i2s_dev_t *hw, bool val) +static inline void i2s_ll_rx_stop(i2s_dev_t *hw) { - hw->fifo_conf.dscr_en = val; + hw->conf.rx_start = 0; } /** - * @brief Set I2S lcd en + * @brief Stop out link * * @param hw Peripheral I2S hardware instance address. - * @param val value to set lcd en */ -static inline void i2s_ll_set_lcd_en(i2s_dev_t *hw, bool val) +static inline void i2s_ll_tx_stop_link(i2s_dev_t *hw) { - hw->conf2.lcd_en = val; + hw->out_link.stop = 1; } /** - * @brief Set I2S camera en + * @brief Stop in link * * @param hw Peripheral I2S hardware instance address. - * @param val value to set camera en */ -static inline void i2s_ll_set_camera_en(i2s_dev_t *hw, bool val) +static inline void i2s_ll_rx_stop_link(i2s_dev_t *hw) { - hw->conf2.camera_en = val; + hw->in_link.stop = 1; } /** - * @brief Set I2S tx fifo mod force en + * @brief Get I2S out eof descriptor address * * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx fifo mod force en + * @param eof_addr Pointer to accept out eof des address */ -static inline void i2s_ll_set_tx_fifo_mod_force_en(i2s_dev_t *hw, bool val) +static inline void i2s_ll_tx_get_eof_des_addr(i2s_dev_t *hw, uint32_t *eof_addr) { - hw->fifo_conf.tx_fifo_mod_force_en = val; + *eof_addr = hw->out_eof_des_addr; } /** - * @brief Set I2S rx fifo mod force en + * @brief Get I2S in eof descriptor address * * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx fifo mod force en + * @param eof_addr Pointer to accept in eof des address */ -static inline void i2s_ll_set_rx_fifo_mod_force_en(i2s_dev_t *hw, bool val) +static inline void i2s_ll_rx_get_eof_des_addr(i2s_dev_t *hw, uint32_t *eof_addr) { - hw->fifo_conf.rx_fifo_mod_force_en = val; + *eof_addr = hw->in_eof_des_addr; } /** - * @brief Set I2S tx right first + * @brief Configure the received length to trigger in_suc_eof interrupt * * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx right first + * @param eof_num the byte length to trigger in_suc_eof interrupt */ -static inline void i2s_ll_set_tx_right_first(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_set_eof_num(i2s_dev_t *hw, int eof_num) { - hw->conf.tx_right_first = val; + // On ESP32, the eof_num count in words. + hw->rx_eof_num = eof_num / 4; } /** - * @brief Set I2S rx right first + * @brief Set I2S tx bits mod * * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx right first + * @param val value to set tx bits mod */ -static inline void i2s_ll_set_rx_right_first(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_set_bits_mod(i2s_dev_t *hw, uint32_t val) { - hw->conf.rx_right_first = val; + hw->sample_rate_conf.tx_bits_mod = val; } /** - * @brief Set I2S tx slave mod + * @brief Congfigure TX chan bit and audio data bit, on ESP32, sample_bit should equals to data_bit * * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx slave mod + * @param chan_bit The chan bit width + * @param data_bit The audio data bit width */ -static inline void i2s_ll_set_tx_slave_mod(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_set_sample_bit(i2s_dev_t *hw, uint8_t chan_bit, int data_bit) { - hw->conf.tx_slave_mod = val; + hw->fifo_conf.tx_fifo_mod = (chan_bit <= I2S_BITS_PER_SAMPLE_16BIT ? 0 : 2); + hw->sample_rate_conf.tx_bits_mod = data_bit; } /** - * @brief Set I2S rx slave mod + * @brief Congfigure RX chan bit and audio data bit, on ESP32, sample_bit should equals to data_bit * * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx slave mod + * @param chan_bit The chan bit width + * @param data_bit The audio data bit width */ -static inline void i2s_ll_set_rx_slave_mod(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_set_sample_bit(i2s_dev_t *hw, uint8_t chan_bit, int data_bit) { - hw->conf.rx_slave_mod = val; + hw->fifo_conf.rx_fifo_mod = (chan_bit <= I2S_BITS_PER_SAMPLE_16BIT ? 0 : 2); + hw->sample_rate_conf.rx_bits_mod = data_bit; } /** - * @brief Get I2S tx msb right + * @brief Set whether to continue I2S signal on bus when TX FIFO is empty * * @param hw Peripheral I2S hardware instance address. - * @param val value to get tx msb right + * @param en whether to stop when tx fifo is empty */ -static inline void i2s_ll_get_tx_msb_right(i2s_dev_t *hw, uint32_t *val) +static inline void i2s_ll_tx_stop_on_fifo_empty(i2s_dev_t *hw, bool en) { - *val = hw->conf.tx_msb_right; + hw->conf1.tx_stop_en = en; } /** - * @brief Get I2S rx msb right + * @brief Set whether to bypass the internal PCM module * * @param hw Peripheral I2S hardware instance address. - * @param val value to get rx msb right + * @param bypass whether to bypass the PCM module */ -static inline void i2s_ll_get_rx_msb_right(i2s_dev_t *hw, uint32_t *val) +static inline void i2s_ll_tx_bypass_pcm(i2s_dev_t *hw, bool bypass) { - *val = hw->conf.rx_msb_right; + hw->conf1.tx_pcm_bypass = bypass; } /** - * @brief Set I2S tx msb right + * @brief Enable I2S DMA * * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx msb right + * @param ena Set true to enable DMA */ -static inline void i2s_ll_set_tx_msb_right(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_enable_dma(i2s_dev_t *hw, bool ena) { - hw->conf.tx_msb_right = val; + hw->fifo_conf.dscr_en = ena; } /** - * @brief Set I2S rx msb right + * @brief Configure TX WS signal width * * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx msb right + * @param width WS width in BCK cycle */ -static inline void i2s_ll_set_rx_msb_right(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_set_ws_width(i2s_dev_t *hw, int width) { - hw->conf.rx_msb_right = val; + hw->conf.tx_short_sync = width == 1 ? 1 : 0; } /** - * @brief Set I2S tx mono + * @brief Configure RX WS signal width * * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx mono + * @param width WS width in BCK cycle */ -static inline void i2s_ll_set_tx_mono(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_set_ws_width(i2s_dev_t *hw, int width) { - hw->conf.tx_mono = val; + hw->conf.rx_short_sync = width == 1 ? 1 : 0; } /** - * @brief Set I2S rx mono + * @brief Enable TX MSB shift, the data will be launch at the first BCK clock * * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx mono + * @param msb_shift_enable Set true to enable MSB shift */ -static inline void i2s_ll_set_rx_mono(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_enable_msb_shift(i2s_dev_t *hw, bool msb_shift_enable) { - hw->conf.rx_mono = val; + hw->conf.tx_msb_shift = msb_shift_enable; } /** - * @brief Set I2S sig loopback + * @brief Enable RX MSB shift, the data will be launch at the first BCK clock * * @param hw Peripheral I2S hardware instance address. - * @param val value to set sig loopback + * @param msb_shift_enable Set true to enable MSB shift */ -static inline void i2s_ll_set_sig_loopback(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_enable_msb_shift(i2s_dev_t *hw, bool msb_shift_enable) { - hw->conf.sig_loopback = val; + hw->conf.rx_msb_shift = msb_shift_enable; } /** - * @brief Set I2S TX to philip standard + * @brief Set I2S tx chan mode * * @param hw Peripheral I2S hardware instance address. + * @param val value to set tx chan mode */ -static inline void i2s_ll_set_tx_format_philip(i2s_dev_t *hw) +static inline void i2s_ll_tx_set_chan_mod(i2s_dev_t *hw, uint32_t val) { - hw->conf.tx_short_sync = 0; - hw->conf.tx_msb_shift = 1; + hw->conf_chan.tx_chan_mod = val; } /** - * @brief Set I2S RX to philip standard + * @brief Enable TX mono mode * * @param hw Peripheral I2S hardware instance address. + * @param mono_ena Set true to enable mono mde. */ -static inline void i2s_ll_set_rx_format_philip(i2s_dev_t *hw) +static inline void i2s_ll_tx_enable_mono_mode(i2s_dev_t *hw, bool mono_ena) { - hw->conf.rx_short_sync = 0; - hw->conf.rx_msb_shift = 1; + int data_bit = hw->sample_rate_conf.tx_bits_mod; + hw->fifo_conf.tx_fifo_mod = data_bit <= I2S_BITS_PER_SAMPLE_16BIT ? mono_ena : 2 + mono_ena; + hw->conf_chan.tx_chan_mod = mono_ena; } /** - * @brief Set I2S TX to MSB Alignment Standard + * @brief Enable RX mono mode * * @param hw Peripheral I2S hardware instance address. + * @param mono_ena Set true to enable mono mde. */ -static inline void i2s_ll_set_tx_format_msb_align(i2s_dev_t *hw) +static inline void i2s_ll_rx_enable_mono_mode(i2s_dev_t *hw, bool mono_ena) { - hw->conf.tx_short_sync = 0; - hw->conf.tx_msb_shift = 0; + int data_bit = hw->sample_rate_conf.rx_bits_mod; + hw->fifo_conf.rx_fifo_mod = data_bit <= I2S_BITS_PER_SAMPLE_16BIT ? mono_ena : 2 + mono_ena; + hw->conf_chan.rx_chan_mod = mono_ena; } /** - * @brief Set I2S RX to MSB Alignment Standard + * @brief Enable I2S loopback mode * * @param hw Peripheral I2S hardware instance address. + * @param loopback_en Set true to share BCK and WS signal for tx module and rx module. */ -static inline void i2s_ll_set_rx_format_msb_align(i2s_dev_t *hw) +static inline void i2s_ll_share_bck_ws(i2s_dev_t *hw, bool loopback_en) { - hw->conf.rx_short_sync = 0; - hw->conf.rx_msb_shift = 0; + hw->conf.sig_loopback = loopback_en; } + + +/******************************I2S PDM Configurations*************************************/ /** - * @brief Set I2S TX to PCM short standard + * @brief Configure RX PDM downsample * * @param hw Peripheral I2S hardware instance address. + * @param dsr PDM downsample configuration paramater */ -static inline void i2s_ll_set_tx_pcm_short(i2s_dev_t *hw) +static inline void i2s_ll_rx_set_pdm_dsr(i2s_dev_t *hw, i2s_pdm_dsr_t dsr) { - hw->conf.tx_short_sync = 1; - hw->conf.tx_msb_shift = 0; + hw->pdm_conf.rx_sinc_dsr_16_en = dsr; } /** - * @brief Set I2S RX to PCM short standard + * @brief Get RX PDM downsample configuration * * @param hw Peripheral I2S hardware instance address. + * @param dsr Pointer to accept PDM downsample configuration */ -static inline void i2s_ll_set_rx_pcm_short(i2s_dev_t *hw) +static inline void i2s_ll_rx_get_pdm_dsr(i2s_dev_t *hw, i2s_pdm_dsr_t *dsr) { - hw->conf.rx_short_sync = 1; - hw->conf.rx_msb_shift = 0; + *dsr = hw->pdm_conf.rx_sinc_dsr_16_en; } /** - * @brief Set I2S TX to PCM long standard + * @brief Enable I2S TX PDM mode * * @param hw Peripheral I2S hardware instance address. + * @param pdm_ena Set true to enable TX PDM mode */ -static inline void i2s_ll_set_tx_pcm_long(i2s_dev_t *hw) +static inline void i2s_ll_tx_enable_pdm(i2s_dev_t *hw, bool pdm_ena) { - hw->conf.tx_short_sync = 0; - hw->conf.tx_msb_shift = 0; + hw->pdm_conf.tx_pdm_en = pdm_ena; + hw->pdm_conf.pcm2pdm_conv_en = pdm_ena; } /** - * @brief Set I2S RX to PCM long standard + * @brief Enable I2S RX PDM mode * * @param hw Peripheral I2S hardware instance address. + * @param pdm_ena Set true to enable RX PDM mode */ -static inline void i2s_ll_set_rx_pcm_long(i2s_dev_t *hw) +static inline void i2s_ll_rx_enable_pdm(i2s_dev_t *hw, bool pdm_ena) { - hw->conf.rx_short_sync = 0; - hw->conf.rx_msb_shift = 0; + hw->pdm_conf.rx_pdm_en = pdm_ena; + hw->pdm_conf.pdm2pcm_conv_en = pdm_ena; } /** - * @brief Enable I2S build in ADC mode + * @brief Set I2S TX PDM prescale * * @param hw Peripheral I2S hardware instance address. + * @param prescale I2S TX PDM prescale */ -static inline void i2s_ll_build_in_adc_ena(i2s_dev_t *hw) +static inline void i2s_ll_tx_set_pdm_prescale(i2s_dev_t *hw, bool prescale) { - hw->conf2.lcd_en = 1; - hw->conf2.camera_en = 0; - hw->conf.rx_msb_shift = 0; - hw->conf.rx_short_sync = 0; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->pdm_conf, tx_prescale, prescale); } /** - * @brief Enable I2S build in DAC mode + * @brief Set I2S TX PDM high pass filter scaling * * @param hw Peripheral I2S hardware instance address. + * @param sig_scale I2S TX PDM signal scaling before transmit to the filter */ -static inline void i2s_ll_build_in_dac_ena(i2s_dev_t *hw) +static inline void i2s_ll_tx_set_pdm_hp_scale(i2s_dev_t *hw, i2s_pdm_sig_scale_t sig_scale) { - hw->conf2.lcd_en = 1; - hw->conf2.camera_en = 0; - hw->conf.tx_right_first = 1; - hw->conf.tx_msb_shift = 0; - hw->conf.tx_short_sync = 0; + hw->pdm_conf.tx_hp_in_shift = sig_scale; } +/** + * @brief Set I2S TX PDM low pass filter scaling + * + * @param hw Peripheral I2S hardware instance address. + * @param sig_scale I2S TX PDM signal scaling before transmit to the filter + */ +static inline void i2s_ll_tx_set_pdm_lp_scale(i2s_dev_t *hw, i2s_pdm_sig_scale_t sig_scale) +{ + hw->pdm_conf.tx_lp_in_shift = sig_scale; +} /** - * @brief Enable I2S RX PDM mode + * @brief Set I2S TX PDM sinc filter scaling * * @param hw Peripheral I2S hardware instance address. - * @param pdm_en Set true to enable rx PDM mode + * @param sig_scale I2S TX PDM signal scaling before transmit to the filter */ -static inline void i2s_ll_set_rx_pdm_en(i2s_dev_t *hw, bool pdm_en) +static inline void i2s_ll_tx_set_pdm_sinc_scale(i2s_dev_t *hw, i2s_pdm_sig_scale_t sig_scale) { - hw->pdm_conf.rx_pdm_en = pdm_en; + hw->pdm_conf.tx_sinc_in_shift = sig_scale; } /** - * @brief Enable I2S tx pdm mode + * @brief Set I2S TX PDM sigma-delta filter scaling * * @param hw Peripheral I2S hardware instance address. - * @param pdm_en Set true to enable tx PDM mode + * @param sig_scale I2S TX PDM signal scaling before transmit to the filter */ -static inline void i2s_ll_set_tx_pdm_en(i2s_dev_t *hw, bool pdm_en) +static inline void i2s_ll_tx_set_pdm_sd_scale(i2s_dev_t *hw, i2s_pdm_sig_scale_t sig_scale) { - hw->pdm_conf.tx_pdm_en = pdm_en; + hw->pdm_conf.tx_sigmadelta_in_shift = sig_scale; } /** - * @brief Configure I2S tx PDM filter module group0 + * @brief Configure I2S TX PDM sample rate + * Fpdm = 64*Fpcm*fp/fs * * @param hw Peripheral I2S hardware instance address. * @param fp The fp value of TX PDM filter module group0. * @param fs The fs value of TX PDM filter module group0. */ -static inline void i2s_ll_tx_pdm_cfg(i2s_dev_t *hw, uint32_t fp, uint32_t fs) +static inline void i2s_ll_tx_set_pdm_fpfs(i2s_dev_t *hw, uint32_t fp, uint32_t fs) { hw->pdm_freq_conf.tx_pdm_fp = fp; hw->pdm_freq_conf.tx_pdm_fs = fs; - hw->pdm_conf.tx_sinc_osr2 = fp/fs; - hw->pdm_conf.pcm2pdm_conv_en = 1; - hw->pdm_conf.tx_pdm_en = 1; + hw->pdm_conf.tx_sinc_osr2 = fp / fs; } /** - * @brief Configure I2S rx PDM + * @brief Get I2S TX PDM fp configuration paramater * * @param hw Peripheral I2S hardware instance address. - * @param dsr Down-sampling rate value of rx PDM + * @return + * - fp configuration paramater */ -static inline void i2s_ll_rx_pdm_cfg(i2s_dev_t *hw, uint32_t dsr) +static inline uint32_t i2s_ll_tx_get_pdm_fp(i2s_dev_t *hw) { - hw->pdm_conf.rx_sinc_dsr_16_en = dsr; - hw->pdm_conf.pdm2pcm_conv_en = 1; - hw->pdm_conf.rx_pdm_en = 1; + return hw->pdm_freq_conf.tx_pdm_fp; } /** - * @brief Get I2S tx PDM configuration + * @brief Get I2S TX PDM fs configuration paramater * * @param hw Peripheral I2S hardware instance address. - * @param fp Pointer to store tx PDM fp configuration - * @param fs Pointer to store tx PDM fs configuration + * @return + * - fs configuration paramater */ -static inline void i2s_ll_get_tx_pdm(i2s_dev_t *hw, uint32_t *fp, uint32_t *fs) +static inline uint32_t i2s_ll_tx_get_pdm_fs(i2s_dev_t *hw) { - *fp = hw->pdm_freq_conf.tx_pdm_fp; - *fs = hw->pdm_freq_conf.tx_pdm_fs; + return hw->pdm_freq_conf.tx_pdm_fs; } + + + +/****************************I2S ADC/DAC Configurations***********************************/ /** - * @brief Get I2S rx PDM configuration + * @brief Enable I2S LCD mode + * @note Have to enable LCD mode to use build in ADC/DAC * * @param hw Peripheral I2S hardware instance address. - * @param dsr Pointer to stoe the rx PDM down-sample rate configuration + * @param enable Set true to enable LCD mode. */ -static inline void i2s_ll_get_rx_pdm(i2s_dev_t *hw, uint32_t *dsr) +static inline void i2s_ll_enable_lcd(i2s_dev_t *hw, bool enable) { - *dsr = hw->pdm_conf.rx_sinc_dsr_16_en; + hw->conf2.lcd_en = enable; +} + +/** + * @brief Enable I2S camera mode + * + * @param hw Peripheral I2S hardware instance address. + * @param enable Set true to enable camera mode. + */ +static inline void i2s_ll_enable_camera(i2s_dev_t *hw, bool enable) +{ + hw->conf2.camera_en = enable; +} + +/** + * @brief Enable I2S build in ADC mode + * + * @param hw Peripheral I2S hardware instance address. + * @param enable Set true to enable build in ADC + */ +static inline void i2s_ll_enable_builtin_adc(i2s_dev_t *hw, bool enable) +{ + hw->conf2.lcd_en = enable; + hw->conf2.camera_en = 0; + hw->conf.rx_right_first = 0; + hw->conf.rx_msb_shift = 0; + hw->conf.rx_mono = 0; + hw->conf.rx_short_sync = 0; + hw->fifo_conf.rx_fifo_mod = enable; + hw->conf_chan.rx_chan_mod = enable; +} + +/** + * @brief Enable I2S build in DAC mode + * + * @param hw Peripheral I2S hardware instance address. + * * @param enable Set true to enable build in DAC + */ +static inline void i2s_ll_enable_builtin_dac(i2s_dev_t *hw, bool enable) +{ + hw->conf2.lcd_en = enable; + hw->conf2.camera_en = 0; + hw->conf.tx_right_first = enable; + hw->conf.tx_msb_shift = 0; + hw->conf.tx_short_sync = 0; } #ifdef __cplusplus diff --git a/tools/sdk/esp32/include/hal/esp32/include/hal/ledc_ll.h b/tools/sdk/esp32/include/hal/esp32/include/hal/ledc_ll.h index f7331872b6e..1682c7c410f 100644 --- a/tools/sdk/esp32/include/hal/esp32/include/hal/ledc_ll.h +++ b/tools/sdk/esp32/include/hal/esp32/include/hal/ledc_ll.h @@ -19,6 +19,7 @@ #include "hal/ledc_types.h" #include "soc/ledc_periph.h" +#include "soc/ledc_struct.h" #define LEDC_LL_GET_HW() &LEDC diff --git a/tools/sdk/esp32/include/hal/esp32/include/hal/mcpwm_ll.h b/tools/sdk/esp32/include/hal/esp32/include/hal/mcpwm_ll.h index 09674c02dad..3e2b4b762c8 100644 --- a/tools/sdk/esp32/include/hal/esp32/include/hal/mcpwm_ll.h +++ b/tools/sdk/esp32/include/hal/esp32/include/hal/mcpwm_ll.h @@ -23,34 +23,40 @@ #pragma once #include +#include "hal/misc.h" #include "soc/soc_caps.h" #include "soc/mcpwm_struct.h" #include "hal/mcpwm_types.h" +#include "hal/assert.h" #ifdef __cplusplus extern "C" { #endif /// Get the address of peripheral registers -#define MCPWM_LL_GET_HW(ID) (((ID) == 0) ? &MCPWM0 : &MCPWM1) -#define MCPWM_LL_MAX_PRESCALE 255 +#define MCPWM_LL_GET_HW(ID) (((ID) == 0) ? &MCPWM0 : &MCPWM1) +#define MCPWM_LL_MAX_CAPTURE_PRESCALE 255 +#define MCPWM_LL_MAX_COMPARE_VALUE 65535 +#define MCPWM_LL_MAX_DEAD_DELAY 65535 +#define MCPWM_LL_MAX_PHASE_VALUE 65535 /********************* Group registers *******************/ // Set/Get group clock: PWM_clk = CLK_160M / (prescale + 1) -static inline void mcpwm_ll_group_set_clock(mcpwm_dev_t *mcpwm, unsigned long long group_clk_hz) +static inline void mcpwm_ll_group_set_clock_prescale(mcpwm_dev_t *mcpwm, int pre_scale) { - mcpwm->clk_cfg.prescale = (SOC_MCPWM_BASE_CLK_HZ / group_clk_hz) - 1; + HAL_FORCE_MODIFY_U32_REG_FIELD(mcpwm->clk_cfg, clk_prescale, pre_scale - 1); } -static inline unsigned long long mcpwm_ll_group_get_clock(mcpwm_dev_t *mcpwm) +static inline uint32_t mcpwm_ll_group_get_clock_prescale(mcpwm_dev_t *mcpwm) { - return SOC_MCPWM_BASE_CLK_HZ / (mcpwm->clk_cfg.prescale + 1); + return HAL_FORCE_READ_U32_REG_FIELD(mcpwm->clk_cfg, clk_prescale) + 1; } static inline void mcpwm_ll_group_enable_shadow_mode(mcpwm_dev_t *mcpwm) { mcpwm->update_cfg.global_up_en = 1; + // updating of active registers in MCPWM operators should be enabled mcpwm->update_cfg.op0_up_en = 1; mcpwm->update_cfg.op1_up_en = 1; mcpwm->update_cfg.op2_up_en = 1; @@ -58,7 +64,8 @@ static inline void mcpwm_ll_group_enable_shadow_mode(mcpwm_dev_t *mcpwm) static inline void mcpwm_ll_group_flush_shadow(mcpwm_dev_t *mcpwm) { - mcpwm->update_cfg.val ^= (1 << 1); + // a toggle can trigger a forced update of all active registers in MCPWM, i.e. shadow->active + mcpwm->update_cfg.global_force_up = ~mcpwm->update_cfg.global_force_up; } /********************* Interrupt registers *******************/ @@ -120,6 +127,7 @@ static inline uint32_t mcpwm_ll_intr_get_trip_ost_status(mcpwm_dev_t *mcpwm) return (mcpwm->int_st.val >> 24) & 0x07; } +__attribute__((always_inline)) static inline uint32_t mcpwm_ll_intr_get_capture_status(mcpwm_dev_t *mcpwm) { return (mcpwm->int_st.val >> 27) & 0x07; @@ -129,47 +137,48 @@ static inline uint32_t mcpwm_ll_intr_get_capture_status(mcpwm_dev_t *mcpwm) static inline void mcpwm_ll_intr_clear_timer_stop_status(mcpwm_dev_t *mcpwm, uint32_t timer_mask) { - mcpwm->int_clr.val |= (timer_mask & 0x07) << 0; + mcpwm->int_clr.val = (timer_mask & 0x07) << 0; } static inline void mcpwm_ll_intr_clear_timer_tez_status(mcpwm_dev_t *mcpwm, uint32_t timer_mask) { - mcpwm->int_clr.val |= (timer_mask & 0x07) << 3; + mcpwm->int_clr.val = (timer_mask & 0x07) << 3; } static inline void mcpwm_ll_intr_clear_timer_tep_status(mcpwm_dev_t *mcpwm, uint32_t timer_mask) { - mcpwm->int_clr.val |= (timer_mask & 0x07) << 6; + mcpwm->int_clr.val = (timer_mask & 0x07) << 6; } static inline void mcpwm_ll_intr_clear_fault_enter_status(mcpwm_dev_t *mcpwm, uint32_t fault_mask) { - mcpwm->int_clr.val |= (fault_mask & 0x07) << 9; + mcpwm->int_clr.val = (fault_mask & 0x07) << 9; } static inline void mcpwm_ll_intr_clear_fault_exit_status(mcpwm_dev_t *mcpwm, uint32_t fault_mask) { - mcpwm->int_clr.val |= (fault_mask & 0x07) << 12; + mcpwm->int_clr.val = (fault_mask & 0x07) << 12; } static inline void mcpwm_ll_intr_clear_compare_status(mcpwm_dev_t *mcpwm, uint32_t operator_mask, uint32_t cmp_id) { - mcpwm->int_clr.val |= (operator_mask & 0x07) << (15 + cmp_id * 3); + mcpwm->int_clr.val = (operator_mask & 0x07) << (15 + cmp_id * 3); } static inline void mcpwm_ll_intr_clear_trip_cbc_status(mcpwm_dev_t *mcpwm, uint32_t cbc_mask) { - mcpwm->int_clr.val |= (cbc_mask & 0x07) << 21; + mcpwm->int_clr.val = (cbc_mask & 0x07) << 21; } static inline void mcpwm_ll_intr_clear_trip_ost_status(mcpwm_dev_t *mcpwm, uint32_t ost_mask) { - mcpwm->int_clr.val |= (ost_mask & 0x07) << 24; + mcpwm->int_clr.val = (ost_mask & 0x07) << 24; } +__attribute__((always_inline)) static inline void mcpwm_ll_intr_clear_capture_status(mcpwm_dev_t *mcpwm, uint32_t capture_mask) { - mcpwm->int_clr.val |= (capture_mask & 0x07) << 27; + mcpwm->int_clr.val = (capture_mask & 0x07) << 27; } //////////// enable interrupt for each event //////////////// @@ -201,13 +210,20 @@ static inline void mcpwm_ll_intr_enable_timer_tep(mcpwm_dev_t *mcpwm, uint32_t t } } -static inline void mcpwm_ll_intr_enable_fault(mcpwm_dev_t *mcpwm, uint32_t fault_id, bool enable) +static inline void mcpwm_ll_intr_enable_fault_enter(mcpwm_dev_t *mcpwm, uint32_t fault_id, bool enable) { if (enable) { mcpwm->int_ena.val |= 1 << (9 + fault_id); // enter fault interrupt - mcpwm->int_ena.val |= 1 << (12 + fault_id); // exit fault interrupt } else { mcpwm->int_ena.val &= ~(1 << (9 + fault_id)); + } +} + +static inline void mcpwm_ll_intr_enable_fault_exit(mcpwm_dev_t *mcpwm, uint32_t fault_id, bool enable) +{ + if (enable) { + mcpwm->int_ena.val |= 1 << (12 + fault_id); // exit fault interrupt + } else { mcpwm->int_ena.val &= ~(1 << (12 + fault_id)); } } @@ -221,13 +237,20 @@ static inline void mcpwm_ll_intr_enable_compare(mcpwm_dev_t *mcpwm, uint32_t ope } } -static inline void mcpwm_ll_intr_enable_trip(mcpwm_dev_t *mcpwm, uint32_t operator_id, bool enable) +static inline void mcpwm_ll_intr_enable_trip_cbc(mcpwm_dev_t *mcpwm, uint32_t operator_id, bool enable) { if (enable) { mcpwm->int_ena.val |= (1 << (21 + operator_id)); - mcpwm->int_ena.val |= (1 << (24 + operator_id)); } else { mcpwm->int_ena.val &= ~(1 << (21 + operator_id)); + } +} + +static inline void mcpwm_ll_intr_enable_trip_ost(mcpwm_dev_t *mcpwm, uint32_t operator_id, bool enable) +{ + if (enable) { + mcpwm->int_ena.val |= (1 << (24 + operator_id)); + } else { mcpwm->int_ena.val &= ~(1 << (24 + operator_id)); } } @@ -243,22 +266,22 @@ static inline void mcpwm_ll_intr_enable_capture(mcpwm_dev_t *mcpwm, uint32_t cap /********************* Timer registers *******************/ -static inline void mcpwm_ll_timer_set_clock(mcpwm_dev_t *mcpwm, int timer_id, unsigned long long group_clock, unsigned long long timer_clock) +static inline void mcpwm_ll_timer_set_clock_prescale(mcpwm_dev_t *mcpwm, int timer_id, uint32_t prescale) { - mcpwm->timer[timer_id].period.prescale = group_clock / timer_clock - 1; + HAL_FORCE_MODIFY_U32_REG_FIELD(mcpwm->timer[timer_id].timer_cfg0, timer_prescale, prescale - 1); } -static inline unsigned long long mcpwm_ll_timer_get_clock(mcpwm_dev_t *mcpwm, int timer_id, unsigned long long group_clock) +static inline uint32_t mcpwm_ll_timer_get_clock_prescale(mcpwm_dev_t *mcpwm, int timer_id) { - return group_clock / (mcpwm->timer[timer_id].period.prescale + 1); + return HAL_FORCE_READ_U32_REG_FIELD(mcpwm->timer[timer_id].timer_cfg0, timer_prescale) + 1; } static inline void mcpwm_ll_timer_set_peak(mcpwm_dev_t *mcpwm, int timer_id, uint32_t peak, bool symmetric) { if (!symmetric) { // in asymmetric mode, period = [0,peak-1] - mcpwm->timer[timer_id].period.period = peak - 1; + HAL_FORCE_MODIFY_U32_REG_FIELD(mcpwm->timer[timer_id].timer_cfg0, timer_period, peak - 1); } else { // in symmetric mode, period = [0,peak-1] + [peak,1] - mcpwm->timer[timer_id].period.period = peak; + HAL_FORCE_MODIFY_U32_REG_FIELD(mcpwm->timer[timer_id].timer_cfg0, timer_period, peak); } } @@ -266,32 +289,32 @@ static inline uint32_t mcpwm_ll_timer_get_peak(mcpwm_dev_t *mcpwm, int timer_id, { // asymmetric mode if (!symmetric) { - return mcpwm->timer[timer_id].period.period + 1; + return HAL_FORCE_READ_U32_REG_FIELD(mcpwm->timer[timer_id].timer_cfg0, timer_period) + 1; } // symmetric mode - return mcpwm->timer[timer_id].period.period; + return HAL_FORCE_READ_U32_REG_FIELD(mcpwm->timer[timer_id].timer_cfg0, timer_period); } static inline void mcpwm_ll_timer_update_period_at_once(mcpwm_dev_t *mcpwm, int timer_id) { - mcpwm->timer[timer_id].period.upmethod = 0; + mcpwm->timer[timer_id].timer_cfg0.timer_period_upmethod = 0; } static inline void mcpwm_ll_timer_enable_update_period_on_tez(mcpwm_dev_t *mcpwm, int timer_id, bool enable) { if (enable) { - mcpwm->timer[timer_id].period.upmethod |= 0x01; + mcpwm->timer[timer_id].timer_cfg0.timer_period_upmethod |= 0x01; } else { - mcpwm->timer[timer_id].period.upmethod &= ~0x01; + mcpwm->timer[timer_id].timer_cfg0.timer_period_upmethod &= ~0x01; } } static inline void mcpwm_ll_timer_enable_update_period_on_sync(mcpwm_dev_t *mcpwm, int timer_id, bool enable) { if (enable) { - mcpwm->timer[timer_id].period.upmethod |= 0x02; + mcpwm->timer[timer_id].timer_cfg0.timer_period_upmethod |= 0x02; } else { - mcpwm->timer[timer_id].period.upmethod &= ~0x02; + mcpwm->timer[timer_id].timer_cfg0.timer_period_upmethod &= ~0x02; } } @@ -299,23 +322,23 @@ static inline void mcpwm_ll_timer_set_count_mode(mcpwm_dev_t *mcpwm, int timer_i { switch (mode) { case MCPWM_TIMER_COUNT_MODE_PAUSE: - mcpwm->timer[timer_id].mode.mode = 0; + mcpwm->timer[timer_id].timer_cfg1.timer_mod = 0; break; case MCPWM_TIMER_COUNT_MODE_UP: - mcpwm->timer[timer_id].mode.mode = 1; + mcpwm->timer[timer_id].timer_cfg1.timer_mod = 1; break; case MCPWM_TIMER_COUNT_MODE_DOWN: - mcpwm->timer[timer_id].mode.mode = 2; + mcpwm->timer[timer_id].timer_cfg1.timer_mod = 2; break; case MCPWM_TIMER_COUNT_MODE_UP_DOWN: - mcpwm->timer[timer_id].mode.mode = 3; + mcpwm->timer[timer_id].timer_cfg1.timer_mod = 3; break; } } static inline mcpwm_timer_count_mode_t mcpwm_ll_timer_get_count_mode(mcpwm_dev_t *mcpwm, int timer_id) { - switch (mcpwm->timer[timer_id].mode.mode) { + switch (mcpwm->timer[timer_id].timer_cfg1.timer_mod) { case 0: return MCPWM_TIMER_COUNT_MODE_PAUSE; case 1: @@ -324,106 +347,105 @@ static inline mcpwm_timer_count_mode_t mcpwm_ll_timer_get_count_mode(mcpwm_dev_t return MCPWM_TIMER_COUNT_MODE_DOWN; case 3: return MCPWM_TIMER_COUNT_MODE_UP_DOWN; + default: + HAL_ASSERT(false && "unknown count mode"); + return mcpwm->timer[timer_id].timer_cfg1.timer_mod; } } -static inline void mcpwm_ll_timer_set_operate_command(mcpwm_dev_t *mcpwm, int timer_id, mcpwm_timer_operate_cmd_t mode) +static inline void mcpwm_ll_timer_set_execute_command(mcpwm_dev_t *mcpwm, int timer_id, mcpwm_timer_execute_cmd_t cmd) { - switch (mode) { + switch (cmd) { case MCPWM_TIMER_STOP_AT_ZERO: - mcpwm->timer[timer_id].mode.start = 0; + mcpwm->timer[timer_id].timer_cfg1.timer_start = 0; break; case MCPWM_TIMER_STOP_AT_PEAK: - mcpwm->timer[timer_id].mode.start = 1; + mcpwm->timer[timer_id].timer_cfg1.timer_start = 1; break; case MCPWM_TIMER_START_NO_STOP: - mcpwm->timer[timer_id].mode.start = 2; + mcpwm->timer[timer_id].timer_cfg1.timer_start = 2; break; case MCPWM_TIMER_START_STOP_AT_ZERO: - mcpwm->timer[timer_id].mode.start = 3; + mcpwm->timer[timer_id].timer_cfg1.timer_start = 3; break; case MCPWM_TIMER_START_STOP_AT_PEAK: - mcpwm->timer[timer_id].mode.start = 4; + mcpwm->timer[timer_id].timer_cfg1.timer_start = 4; break; } } -static inline void mcpwm_ll_timer_set_count_value(mcpwm_dev_t *mcpwm, int timer_id, uint32_t value) -{ - // we use software sync to set count value - int previous_phase = mcpwm->timer[timer_id].sync.timer_phase; - mcpwm->timer[timer_id].sync.timer_phase = value; - mcpwm->timer[timer_id].sync.sync_sw = ~mcpwm->timer[timer_id].sync.sync_sw; - mcpwm->timer[timer_id].sync.timer_phase = previous_phase; -} - static inline uint32_t mcpwm_ll_timer_get_count_value(mcpwm_dev_t *mcpwm, int timer_id) { - return mcpwm->timer[timer_id].status.value; + return HAL_FORCE_READ_U32_REG_FIELD(mcpwm->timer[timer_id].timer_status, timer_value); } -static inline bool mcpwm_ll_is_timer_decreasing(mcpwm_dev_t *mcpwm, int timer_id) +static inline mcpwm_timer_direction_t mcpwm_ll_timer_get_count_direction(mcpwm_dev_t *mcpwm, int timer_id) { - return mcpwm->timer[timer_id].status.direction; + return mcpwm->timer[timer_id].timer_status.timer_direction ? MCPWM_TIMER_DIRECTION_DOWN : MCPWM_TIMER_DIRECTION_UP; } static inline void mcpwm_ll_timer_enable_sync_input(mcpwm_dev_t *mcpwm, int timer_id, bool enable) { - mcpwm->timer[timer_id].sync.in_en = enable; + mcpwm->timer[timer_id].timer_sync.timer_synci_en = enable; } -static inline void mcpwm_ll_timer_sync_out_same_in(mcpwm_dev_t *mcpwm, int timer_id) +static inline void mcpwm_ll_timer_sync_out_penetrate(mcpwm_dev_t *mcpwm, int timer_id) { - mcpwm->timer[timer_id].sync.out_sel = 0; + // sync_out is selected to sync_in + mcpwm->timer[timer_id].timer_sync.timer_synco_sel = 0; } static inline void mcpwm_ll_timer_sync_out_on_timer_event(mcpwm_dev_t *mcpwm, int timer_id, mcpwm_timer_event_t event) { if (event == MCPWM_TIMER_EVENT_ZERO) { - mcpwm->timer[timer_id].sync.out_sel = 1; + mcpwm->timer[timer_id].timer_sync.timer_synco_sel = 1; } else if (event == MCPWM_TIMER_EVENT_PEAK) { - mcpwm->timer[timer_id].sync.out_sel = 2; + mcpwm->timer[timer_id].timer_sync.timer_synco_sel = 2; + } else { + HAL_ASSERT(false && "unknown sync out event"); } } static inline void mcpwm_ll_timer_disable_sync_out(mcpwm_dev_t *mcpwm, int timer_id) { - mcpwm->timer[timer_id].sync.out_sel = 3; + // sync_out will always be zero + mcpwm->timer[timer_id].timer_sync.timer_synco_sel = 3; } -static inline void mcpwm_ll_timer_trigger_sw_sync(mcpwm_dev_t *mcpwm, int timer_id) +static inline void mcpwm_ll_timer_trigger_soft_sync(mcpwm_dev_t *mcpwm, int timer_id) { - mcpwm->timer[timer_id].sync.sync_sw = ~mcpwm->timer[timer_id].sync.sync_sw; + mcpwm->timer[timer_id].timer_sync.timer_sync_sw = ~mcpwm->timer[timer_id].timer_sync.timer_sync_sw; } -static inline void mcpwm_ll_timer_set_sync_phase_value(mcpwm_dev_t *mcpwm, int timer_id, uint32_t reload_val) +static inline void mcpwm_ll_timer_set_sync_phase_value(mcpwm_dev_t *mcpwm, int timer_id, uint32_t phase_value) { - mcpwm->timer[timer_id].sync.timer_phase = reload_val; + HAL_FORCE_MODIFY_U32_REG_FIELD(mcpwm->timer[timer_id].timer_sync, timer_phase, phase_value); } -static inline uint32_t mcpwm_ll_timer_get_sync_phase_value(mcpwm_dev_t *mcpwm, int timer_id) +static inline void mcpwm_ll_timer_set_sync_phase_direction(mcpwm_dev_t *mcpwm, int timer_id, mcpwm_timer_direction_t direction) { - return mcpwm->timer[timer_id].sync.timer_phase; + mcpwm->timer[timer_id].timer_sync.timer_phase_direction = direction; } -static inline void mcpwm_ll_timer_set_sync_phase_direction(mcpwm_dev_t *mcpwm, int timer_id, bool decrease) +static inline void mcpwm_ll_timer_set_gpio_synchro(mcpwm_dev_t *mcpwm, int timer, int gpio_sync_id) { - mcpwm->timer[timer_id].sync.phase_direct = decrease; + mcpwm->timer_synci_cfg.val &= ~(0x07 << (timer * 3)); + mcpwm->timer_synci_cfg.val |= (gpio_sync_id + 4) << (timer * 3); } -static inline void mcpwm_ll_timer_enable_sync_from_internal_timer(mcpwm_dev_t *mcpwm, int this_timer, int internal_sync_timer) +static inline void mcpwm_ll_timer_set_timer_synchro(mcpwm_dev_t *mcpwm, int timer, int timer_sync_id) { - mcpwm->timer_synci_cfg.val &= ~(0x07 << (this_timer * 3)); - mcpwm->timer_synci_cfg.val |= (internal_sync_timer + 1) << (this_timer * 3); + mcpwm->timer_synci_cfg.val &= ~(0x07 << (timer * 3)); + mcpwm->timer_synci_cfg.val |= (timer_sync_id + 1) << (timer * 3); } -static inline void mcpwm_ll_timer_enable_sync_from_external(mcpwm_dev_t *mcpwm, int this_timer, int extern_syncer) +static inline void mcpwm_ll_timer_set_soft_synchro(mcpwm_dev_t *mcpwm, int timer) { - mcpwm->timer_synci_cfg.val &= ~(0x07 << (this_timer * 3)); - mcpwm->timer_synci_cfg.val |= (extern_syncer + 4) << (this_timer * 3); + // no sync input is selected, but software sync can still work + mcpwm->timer_synci_cfg.val &= ~(0x07 << (timer * 3)); } -static inline void mcpwm_ll_invert_external_syncer(mcpwm_dev_t *mcpwm, int sync_id, bool invert) +static inline void mcpwm_ll_invert_gpio_synchro(mcpwm_dev_t *mcpwm, int sync_id, bool invert) { if (invert) { mcpwm->timer_synci_cfg.val |= 1 << (sync_id + 9); @@ -442,104 +464,117 @@ static inline void mcpwm_ll_operator_flush_shadow(mcpwm_dev_t *mcpwm, int operat static inline void mcpwm_ll_operator_select_timer(mcpwm_dev_t *mcpwm, int operator_id, int timer_id) { if (operator_id == 0) { - mcpwm->timer_sel.operator0_sel = timer_id; + mcpwm->operator_timersel.operator0_timersel = timer_id; } else if (operator_id == 1) { - mcpwm->timer_sel.operator1_sel = timer_id; + mcpwm->operator_timersel.operator1_timersel = timer_id; } else { - mcpwm->timer_sel.operator2_sel = timer_id; + mcpwm->operator_timersel.operator2_timersel = timer_id; } } static inline void mcpwm_ll_operator_update_compare_at_once(mcpwm_dev_t *mcpwm, int operator_id, int compare_id) { - mcpwm->channel[operator_id].cmpr_cfg.val &= ~(0x0F << (4 * compare_id)); + mcpwm->operators[operator_id].gen_stmp_cfg.val &= ~(0x0F << (4 * compare_id)); } static inline void mcpwm_ll_operator_enable_update_compare_on_tez(mcpwm_dev_t *mcpwm, int operator_id, int compare_id, bool enable) { if (enable) { - mcpwm->channel[operator_id].cmpr_cfg.val |= (1 << 0) << (4 * compare_id); + mcpwm->operators[operator_id].gen_stmp_cfg.val |= (1 << 0) << (4 * compare_id); } else { - mcpwm->channel[operator_id].cmpr_cfg.val &= ~((1 << 0) << (4 * compare_id)); + mcpwm->operators[operator_id].gen_stmp_cfg.val &= ~((1 << 0) << (4 * compare_id)); } } static inline void mcpwm_ll_operator_enable_update_compare_on_tep(mcpwm_dev_t *mcpwm, int operator_id, int compare_id, bool enable) { if (enable) { - mcpwm->channel[operator_id].cmpr_cfg.val |= (1 << 1) << (4 * compare_id); + mcpwm->operators[operator_id].gen_stmp_cfg.val |= (1 << 1) << (4 * compare_id); } else { - mcpwm->channel[operator_id].cmpr_cfg.val &= ~((1 << 1) << (4 * compare_id)); + mcpwm->operators[operator_id].gen_stmp_cfg.val &= ~((1 << 1) << (4 * compare_id)); } } static inline void mcpwm_ll_operator_enable_update_compare_on_sync(mcpwm_dev_t *mcpwm, int operator_id, int compare_id, bool enable) { if (enable) { - mcpwm->channel[operator_id].cmpr_cfg.val |= (1 << 2) << (4 * compare_id); + mcpwm->operators[operator_id].gen_stmp_cfg.val |= (1 << 2) << (4 * compare_id); } else { - mcpwm->channel[operator_id].cmpr_cfg.val &= ~((1 << 2) << (4 * compare_id)); + mcpwm->operators[operator_id].gen_stmp_cfg.val &= ~((1 << 2) << (4 * compare_id)); } } static inline void mcpwm_ll_operator_set_compare_value(mcpwm_dev_t *mcpwm, int operator_id, int compare_id, uint32_t compare_value) { - mcpwm->channel[operator_id].cmpr_value[compare_id].cmpr_val = compare_value; + HAL_FORCE_MODIFY_U32_REG_FIELD(mcpwm->operators[operator_id].timestamp[compare_id], gen, compare_value); } static inline uint32_t mcpwm_ll_operator_get_compare_value(mcpwm_dev_t *mcpwm, int operator_id, int compare_id) { - return mcpwm->channel[operator_id].cmpr_value[compare_id].cmpr_val; + return HAL_FORCE_READ_U32_REG_FIELD(mcpwm->operators[operator_id].timestamp[compare_id], gen); } static inline void mcpwm_ll_operator_update_action_at_once(mcpwm_dev_t *mcpwm, int operator_id) { - mcpwm->channel[operator_id].gen_cfg0.upmethod = 0; + mcpwm->operators[operator_id].gen_cfg0.gen_cfg_upmethod = 0; } static inline void mcpwm_ll_operator_enable_update_action_on_tez(mcpwm_dev_t *mcpwm, int operator_id, bool enable) { if (enable) { - mcpwm->channel[operator_id].gen_cfg0.upmethod |= 1 << 0; + mcpwm->operators[operator_id].gen_cfg0.gen_cfg_upmethod |= 1 << 0; } else { - mcpwm->channel[operator_id].gen_cfg0.upmethod &= ~(1 << 0); + mcpwm->operators[operator_id].gen_cfg0.gen_cfg_upmethod &= ~(1 << 0); } } static inline void mcpwm_ll_operator_enable_update_action_on_tep(mcpwm_dev_t *mcpwm, int operator_id, bool enable) { if (enable) { - mcpwm->channel[operator_id].gen_cfg0.upmethod |= 1 << 1; + mcpwm->operators[operator_id].gen_cfg0.gen_cfg_upmethod |= 1 << 1; } else { - mcpwm->channel[operator_id].gen_cfg0.upmethod &= ~(1 << 1); + mcpwm->operators[operator_id].gen_cfg0.gen_cfg_upmethod &= ~(1 << 1); } } static inline void mcpwm_ll_operator_enable_update_action_on_sync(mcpwm_dev_t *mcpwm, int operator_id, bool enable) { if (enable) { - mcpwm->channel[operator_id].gen_cfg0.upmethod |= 1 << 2; + mcpwm->operators[operator_id].gen_cfg0.gen_cfg_upmethod |= 1 << 2; } else { - mcpwm->channel[operator_id].gen_cfg0.upmethod &= ~(1 << 2); + mcpwm->operators[operator_id].gen_cfg0.gen_cfg_upmethod &= ~(1 << 2); } } +static inline void mcpwm_ll_operator_set_trigger_gpio_fault(mcpwm_dev_t *mcpwm, int operator_id, int trig_id, int fault_id) +{ + mcpwm->operators[operator_id].gen_cfg0.val &= ~(0x07 << (4 + 3 * trig_id)); + mcpwm->operators[operator_id].gen_cfg0.val |= (fault_id << (4 + 3 * trig_id)); +} + +static inline void mcpwm_ll_operator_set_trigger_timer_sync(mcpwm_dev_t *mcpwm, int operator_id, int trig_id) +{ + // the timer here is not selectable, must be the one connected with the operator + mcpwm->operators[operator_id].gen_cfg0.val &= ~(0x07 << (4 + 3 * trig_id)); + mcpwm->operators[operator_id].gen_cfg0.val |= (3 << (4 + 3 * trig_id)); +} + /********************* Generator registers *******************/ static inline void mcpwm_ll_generator_reset_actions(mcpwm_dev_t *mcpwm, int operator_id, int generator_id) { - mcpwm->channel[operator_id].generator[generator_id].val = 0; + mcpwm->operators[operator_id].generator[generator_id].val = 0; } static inline void mcpwm_ll_generator_set_action_on_timer_event(mcpwm_dev_t *mcpwm, int operator_id, int generator_id, mcpwm_timer_direction_t direction, mcpwm_timer_event_t event, mcpwm_generator_action_t action) { if (direction == MCPWM_TIMER_DIRECTION_UP) { // utez, utep - mcpwm->channel[operator_id].generator[generator_id].val &= ~(0x03 << (event * 2)); - mcpwm->channel[operator_id].generator[generator_id].val |= action << (event * 2); + mcpwm->operators[operator_id].generator[generator_id].val &= ~(0x03 << (event * 2)); + mcpwm->operators[operator_id].generator[generator_id].val |= action << (event * 2); } else if (direction == MCPWM_TIMER_DIRECTION_DOWN) { // dtez, dtep - mcpwm->channel[operator_id].generator[generator_id].val &= ~(0x03 << (event * 2 + 12)); - mcpwm->channel[operator_id].generator[generator_id].val |= action << (event * 2 + 12); + mcpwm->operators[operator_id].generator[generator_id].val &= ~(0x03 << (event * 2 + 12)); + mcpwm->operators[operator_id].generator[generator_id].val |= action << (event * 2 + 12); } } @@ -547,11 +582,11 @@ static inline void mcpwm_ll_generator_set_action_on_compare_event(mcpwm_dev_t *m mcpwm_timer_direction_t direction, int cmp_id, int action) { if (direction == MCPWM_TIMER_DIRECTION_UP) { // utea, uteb - mcpwm->channel[operator_id].generator[generator_id].val &= ~(0x03 << (cmp_id * 2 + 4)); - mcpwm->channel[operator_id].generator[generator_id].val |= action << (cmp_id * 2 + 4); + mcpwm->operators[operator_id].generator[generator_id].val &= ~(0x03 << (cmp_id * 2 + 4)); + mcpwm->operators[operator_id].generator[generator_id].val |= action << (cmp_id * 2 + 4); } else if (direction == MCPWM_TIMER_DIRECTION_DOWN) { // dtea, dteb - mcpwm->channel[operator_id].generator[generator_id].val &= ~(0x03 << (cmp_id * 2 + 16)); - mcpwm->channel[operator_id].generator[generator_id].val |= action << (cmp_id * 2 + 16); + mcpwm->operators[operator_id].generator[generator_id].val &= ~(0x03 << (cmp_id * 2 + 16)); + mcpwm->operators[operator_id].generator[generator_id].val |= action << (cmp_id * 2 + 16); } } @@ -559,149 +594,176 @@ static inline void mcpwm_ll_generator_set_action_on_trigger_event(mcpwm_dev_t *m mcpwm_timer_direction_t direction, int trig_id, int action) { if (direction == MCPWM_TIMER_DIRECTION_UP) { // ut0, ut1 - mcpwm->channel[operator_id].generator[generator_id].val &= ~(0x03 << (trig_id * 2 + 8)); - mcpwm->channel[operator_id].generator[generator_id].val |= action << (trig_id * 2 + 8); + mcpwm->operators[operator_id].generator[generator_id].val &= ~(0x03 << (trig_id * 2 + 8)); + mcpwm->operators[operator_id].generator[generator_id].val |= action << (trig_id * 2 + 8); } else if (direction == MCPWM_TIMER_DIRECTION_DOWN) { // dt0, dt1 - mcpwm->channel[operator_id].generator[generator_id].val &= ~(0x03 << (trig_id * 2 + 20)); - mcpwm->channel[operator_id].generator[generator_id].val |= action << (trig_id * 2 + 20); + mcpwm->operators[operator_id].generator[generator_id].val &= ~(0x03 << (trig_id * 2 + 20)); + mcpwm->operators[operator_id].generator[generator_id].val |= action << (trig_id * 2 + 20); } } -static inline void mcpwm_ll_gen_set_onetime_force_action(mcpwm_dev_t *mcpwm, int operator_id, int generator_id, int action) +static inline void mcpwm_ll_gen_trigger_noncontinue_force_action(mcpwm_dev_t *mcpwm, int operator_id, int generator_id) { if (generator_id == 0) { - mcpwm->channel[operator_id].gen_force.a_nciforce_mode = action; - mcpwm->channel[operator_id].gen_force.a_nciforce = ~mcpwm->channel[operator_id].gen_force.a_nciforce; + mcpwm->operators[operator_id].gen_force.gen_a_nciforce = ~mcpwm->operators[operator_id].gen_force.gen_a_nciforce; } else { - mcpwm->channel[operator_id].gen_force.b_nciforce_mode = action; - mcpwm->channel[operator_id].gen_force.b_nciforce = ~mcpwm->channel[operator_id].gen_force.b_nciforce; + mcpwm->operators[operator_id].gen_force.gen_b_nciforce = ~mcpwm->operators[operator_id].gen_force.gen_b_nciforce; } } -static inline void mcpwm_ll_gen_set_continuous_force_action(mcpwm_dev_t *mcpwm, int operator_id, int generator_id, int action) +static inline void mcpwm_ll_gen_disable_continue_force_action(mcpwm_dev_t *mcpwm, int operator_id, int generator_id) { - mcpwm->channel[operator_id].gen_force.cntu_force_upmethod = 0; // force action immediately + mcpwm->operators[operator_id].gen_force.gen_cntuforce_upmethod = 0; // update force method immediately if (generator_id == 0) { - mcpwm->channel[operator_id].gen_force.a_cntuforce_mode = action; + mcpwm->operators[operator_id].gen_force.gen_a_cntuforce_mode = 0; } else { - mcpwm->channel[operator_id].gen_force.b_cntuforce_mode = action; + mcpwm->operators[operator_id].gen_force.gen_b_cntuforce_mode = 0; + } +} + +static inline void mcpwm_ll_gen_disable_noncontinue_force_action(mcpwm_dev_t *mcpwm, int operator_id, int generator_id) +{ + if (generator_id == 0) { + mcpwm->operators[operator_id].gen_force.gen_a_nciforce_mode = 0; + } else { + mcpwm->operators[operator_id].gen_force.gen_b_nciforce_mode = 0; + } +} + +static inline void mcpwm_ll_gen_set_continue_force_level(mcpwm_dev_t *mcpwm, int operator_id, int generator_id, int level) +{ + mcpwm->operators[operator_id].gen_force.gen_cntuforce_upmethod = 0; // update force method immediately + if (generator_id == 0) { + mcpwm->operators[operator_id].gen_force.gen_a_cntuforce_mode = level + 1; + } else { + mcpwm->operators[operator_id].gen_force.gen_b_cntuforce_mode = level + 1; + } +} + +static inline void mcpwm_ll_gen_set_noncontinue_force_level(mcpwm_dev_t *mcpwm, int operator_id, int generator_id, int level) +{ + if (generator_id == 0) { + mcpwm->operators[operator_id].gen_force.gen_a_nciforce_mode = level + 1; + } else { + mcpwm->operators[operator_id].gen_force.gen_b_nciforce_mode = level + 1; } } /********************* Dead time registers *******************/ -static inline void mcpwm_ll_deadtime_set_resolution_same_to_timer(mcpwm_dev_t *mcpwm, int operator_id, bool same) +static inline void mcpwm_ll_deadtime_resolution_to_timer(mcpwm_dev_t *mcpwm, int operator_id, bool same) { - mcpwm->channel[operator_id].db_cfg.clk_sel = same; + // whether to make the resolution of dead time delay module the same to the timer connected with operator + mcpwm->operators[operator_id].dt_cfg.dt_clk_sel = same; } static inline void mcpwm_ll_deadtime_red_select_generator(mcpwm_dev_t *mcpwm, int operator_id, int generator) { - mcpwm->channel[operator_id].db_cfg.red_insel = generator; + mcpwm->operators[operator_id].dt_cfg.dt_red_insel = generator; } static inline void mcpwm_ll_deadtime_fed_select_generator(mcpwm_dev_t *mcpwm, int operator_id, int generator) { - mcpwm->channel[operator_id].db_cfg.fed_insel = generator; + mcpwm->operators[operator_id].dt_cfg.dt_fed_insel = generator; } static inline void mcpwm_ll_deadtime_bypass_path(mcpwm_dev_t *mcpwm, int operator_id, int path, bool bypass) { if (bypass) { - mcpwm->channel[operator_id].db_cfg.val |= 1 << (path + 15); + mcpwm->operators[operator_id].dt_cfg.val |= 1 << (path + 15); } else { - mcpwm->channel[operator_id].db_cfg.val &= ~(1 << (path + 15)); + mcpwm->operators[operator_id].dt_cfg.val &= ~(1 << (path + 15)); } } static inline void mcpwm_ll_deadtime_invert_outpath(mcpwm_dev_t *mcpwm, int operator_id, int path, bool invert) { if (invert) { - mcpwm->channel[operator_id].db_cfg.val |= 1 << (path + 13); + mcpwm->operators[operator_id].dt_cfg.val |= 1 << (path + 13); } else { - mcpwm->channel[operator_id].db_cfg.val &= ~(1 << (path + 13)); + mcpwm->operators[operator_id].dt_cfg.val &= ~(1 << (path + 13)); } } static inline void mcpwm_ll_deadtime_swap_out_path(mcpwm_dev_t *mcpwm, int operator_id, int path, bool swap) { if (swap) { - mcpwm->channel[operator_id].db_cfg.val |= 1 << (path + 9); + mcpwm->operators[operator_id].dt_cfg.val |= 1 << (path + 9); } else { - mcpwm->channel[operator_id].db_cfg.val &= ~(1 << (path + 9)); + mcpwm->operators[operator_id].dt_cfg.val &= ~(1 << (path + 9)); } } static inline void mcpwm_ll_deadtime_enable_deb(mcpwm_dev_t *mcpwm, int operator_id, bool enable) { - mcpwm->channel[operator_id].db_cfg.deb_mode = enable; + mcpwm->operators[operator_id].dt_cfg.dt_deb_mode = enable; } -static inline uint32_t mcpwm_ll_deadtime_get_topology_code(mcpwm_dev_t *mcpwm, int operator_id) +static inline uint32_t mcpwm_ll_deadtime_get_switch_topology(mcpwm_dev_t *mcpwm, int operator_id) { - return (mcpwm->channel[operator_id].db_cfg.deb_mode << 8) | (mcpwm->channel[operator_id].db_cfg.b_outswap << 7) | - (mcpwm->channel[operator_id].db_cfg.a_outswap << 6) | (mcpwm->channel[operator_id].db_cfg.fed_insel << 5) | - (mcpwm->channel[operator_id].db_cfg.red_insel << 4) | (mcpwm->channel[operator_id].db_cfg.fed_outinvert << 3) | - (mcpwm->channel[operator_id].db_cfg.red_outinvert << 2) | (mcpwm->channel[operator_id].db_cfg.a_outbypass << 1) | - (mcpwm->channel[operator_id].db_cfg.b_outbypass << 0); + return (mcpwm->operators[operator_id].dt_cfg.dt_deb_mode << 8) | (mcpwm->operators[operator_id].dt_cfg.dt_b_outswap << 7) | + (mcpwm->operators[operator_id].dt_cfg.dt_a_outswap << 6) | (mcpwm->operators[operator_id].dt_cfg.dt_fed_insel << 5) | + (mcpwm->operators[operator_id].dt_cfg.dt_red_insel << 4) | (mcpwm->operators[operator_id].dt_cfg.dt_fed_outinvert << 3) | + (mcpwm->operators[operator_id].dt_cfg.dt_red_outinvert << 2) | (mcpwm->operators[operator_id].dt_cfg.dt_a_outbypass << 1) | + (mcpwm->operators[operator_id].dt_cfg.dt_b_outbypass << 0); } static inline void mcpwm_ll_deadtime_set_falling_delay(mcpwm_dev_t *mcpwm, int operator_id, uint32_t fed) { - mcpwm->channel[operator_id].db_fed_cfg.fed = fed - 1; + HAL_FORCE_MODIFY_U32_REG_FIELD(mcpwm->operators[operator_id].dt_fed_cfg, dt_fed, fed - 1); } static inline uint32_t mcpwm_ll_deadtime_get_falling_delay(mcpwm_dev_t *mcpwm, int operator_id) { - return mcpwm->channel[operator_id].db_fed_cfg.fed + 1; + return HAL_FORCE_READ_U32_REG_FIELD(mcpwm->operators[operator_id].dt_fed_cfg, dt_fed) + 1; } static inline void mcpwm_ll_deadtime_set_rising_delay(mcpwm_dev_t *mcpwm, int operator_id, uint32_t red) { - mcpwm->channel[operator_id].db_red_cfg.red = red - 1; + HAL_FORCE_MODIFY_U32_REG_FIELD(mcpwm->operators[operator_id].dt_red_cfg, dt_red, red - 1); } static inline uint32_t mcpwm_ll_deadtime_get_rising_delay(mcpwm_dev_t *mcpwm, int operator_id) { - return mcpwm->channel[operator_id].db_red_cfg.red + 1; + return HAL_FORCE_READ_U32_REG_FIELD(mcpwm->operators[operator_id].dt_red_cfg, dt_red) + 1; } static inline void mcpwm_ll_deadtime_update_delay_at_once(mcpwm_dev_t *mcpwm, int operator_id) { - mcpwm->channel[operator_id].db_cfg.fed_upmethod = 0; - mcpwm->channel[operator_id].db_cfg.red_upmethod = 0; + mcpwm->operators[operator_id].dt_cfg.dt_fed_upmethod = 0; + mcpwm->operators[operator_id].dt_cfg.dt_red_upmethod = 0; } static inline void mcpwm_ll_deadtime_enable_update_delay_on_tez(mcpwm_dev_t *mcpwm, int operator_id, bool enable) { if (enable) { - mcpwm->channel[operator_id].db_cfg.fed_upmethod |= 1 << 0; - mcpwm->channel[operator_id].db_cfg.red_upmethod |= 1 << 0; + mcpwm->operators[operator_id].dt_cfg.dt_fed_upmethod |= 1 << 0; + mcpwm->operators[operator_id].dt_cfg.dt_red_upmethod |= 1 << 0; } else { - mcpwm->channel[operator_id].db_cfg.fed_upmethod &= ~(1 << 0); - mcpwm->channel[operator_id].db_cfg.red_upmethod &= ~(1 << 0); + mcpwm->operators[operator_id].dt_cfg.dt_fed_upmethod &= ~(1 << 0); + mcpwm->operators[operator_id].dt_cfg.dt_red_upmethod &= ~(1 << 0); } } static inline void mcpwm_ll_deadtime_enable_update_delay_on_tep(mcpwm_dev_t *mcpwm, int operator_id, bool enable) { if (enable) { - mcpwm->channel[operator_id].db_cfg.fed_upmethod |= 1 << 1; - mcpwm->channel[operator_id].db_cfg.red_upmethod |= 1 << 1; + mcpwm->operators[operator_id].dt_cfg.dt_fed_upmethod |= 1 << 1; + mcpwm->operators[operator_id].dt_cfg.dt_red_upmethod |= 1 << 1; } else { - mcpwm->channel[operator_id].db_cfg.fed_upmethod &= ~(1 << 1); - mcpwm->channel[operator_id].db_cfg.red_upmethod &= ~(1 << 1); + mcpwm->operators[operator_id].dt_cfg.dt_fed_upmethod &= ~(1 << 1); + mcpwm->operators[operator_id].dt_cfg.dt_red_upmethod &= ~(1 << 1); } } static inline void mcpwm_ll_deadtime_enable_update_delay_on_sync(mcpwm_dev_t *mcpwm, int operator_id, bool enable) { if (enable) { - mcpwm->channel[operator_id].db_cfg.fed_upmethod |= 1 << 2; - mcpwm->channel[operator_id].db_cfg.red_upmethod |= 1 << 2; + mcpwm->operators[operator_id].dt_cfg.dt_fed_upmethod |= 1 << 2; + mcpwm->operators[operator_id].dt_cfg.dt_red_upmethod |= 1 << 2; } else { - mcpwm->channel[operator_id].db_cfg.fed_upmethod &= ~(1 << 2); - mcpwm->channel[operator_id].db_cfg.red_upmethod &= ~(1 << 2); + mcpwm->operators[operator_id].dt_cfg.dt_fed_upmethod &= ~(1 << 2); + mcpwm->operators[operator_id].dt_cfg.dt_red_upmethod &= ~(1 << 2); } } @@ -709,47 +771,47 @@ static inline void mcpwm_ll_deadtime_enable_update_delay_on_sync(mcpwm_dev_t *mc static inline void mcpwm_ll_carrier_enable(mcpwm_dev_t *mcpwm, int operator_id, bool enable) { - mcpwm->channel[operator_id].carrier_cfg.en = enable; + mcpwm->operators[operator_id].carrier_cfg.carrier_en = enable; } static inline void mcpwm_ll_carrier_set_prescale(mcpwm_dev_t *mcpwm, int operator_id, uint8_t prescale) { - mcpwm->channel[operator_id].carrier_cfg.prescale = prescale - 1; + mcpwm->operators[operator_id].carrier_cfg.carrier_prescale = prescale - 1; } static inline uint8_t mcpwm_ll_carrier_get_prescale(mcpwm_dev_t *mcpwm, int operator_id) { - return mcpwm->channel[operator_id].carrier_cfg.prescale + 1; + return mcpwm->operators[operator_id].carrier_cfg.carrier_prescale + 1; } static inline void mcpwm_ll_carrier_set_duty(mcpwm_dev_t *mcpwm, int operator_id, uint8_t carrier_duty) { - mcpwm->channel[operator_id].carrier_cfg.duty = carrier_duty; + mcpwm->operators[operator_id].carrier_cfg.carrier_duty = carrier_duty; } static inline uint8_t mcpwm_ll_carrier_get_duty(mcpwm_dev_t *mcpwm, int operator_id) { - return mcpwm->channel[operator_id].carrier_cfg.duty; + return mcpwm->operators[operator_id].carrier_cfg.carrier_duty; } static inline void mcpwm_ll_carrier_out_invert(mcpwm_dev_t *mcpwm, int operator_id, bool invert) { - mcpwm->channel[operator_id].carrier_cfg.out_invert = invert; + mcpwm->operators[operator_id].carrier_cfg.carrier_out_invert = invert; } static inline void mcpwm_ll_carrier_in_invert(mcpwm_dev_t *mcpwm, int operator_id, bool invert) { - mcpwm->channel[operator_id].carrier_cfg.in_invert = invert; + mcpwm->operators[operator_id].carrier_cfg.carrier_in_invert = invert; } static inline void mcpwm_ll_carrier_set_oneshot_width(mcpwm_dev_t *mcpwm, int operator_id, uint8_t pulse_width) { - mcpwm->channel[operator_id].carrier_cfg.oshtwth = pulse_width - 1; + mcpwm->operators[operator_id].carrier_cfg.carrier_oshtwth = pulse_width - 1; } static inline uint8_t mcpwm_ll_carrier_get_oneshot_width(mcpwm_dev_t *mcpwm, int operator_id) { - return mcpwm->channel[operator_id].carrier_cfg.oshtwth + 1; + return mcpwm->operators[operator_id].carrier_cfg.carrier_oshtwth + 1; } /********************* Fault detector registers *******************/ @@ -775,150 +837,159 @@ static inline void mcpwm_ll_fault_set_active_level(mcpwm_dev_t *mcpwm, int fault static inline void mcpwm_ll_fault_clear_ost(mcpwm_dev_t *mcpwm, int operator_id) { // a posedge can clear the ost fault status - mcpwm->channel[operator_id].tz_cfg1.clr_ost = 0; - mcpwm->channel[operator_id].tz_cfg1.clr_ost = 1; + mcpwm->operators[operator_id].fh_cfg1.fh_clr_ost = 0; + mcpwm->operators[operator_id].fh_cfg1.fh_clr_ost = 1; } static inline void mcpwm_ll_fault_enable_oneshot_mode(mcpwm_dev_t *mcpwm, int operator_id, int fault_sig, bool enable) { - if (fault_sig == 0) { - mcpwm->channel[operator_id].tz_cfg0.f0_ost = enable; - } else if (fault_sig == 1) { - mcpwm->channel[operator_id].tz_cfg0.f1_ost = enable; + mcpwm->operators[operator_id].fh_cfg0.val &= ~(1 << (7 - fault_sig)); + mcpwm->operators[operator_id].fh_cfg0.val |= (enable << (7 - fault_sig)); +} + +static inline void mcpwm_ll_fault_enable_cbc_mode(mcpwm_dev_t *mcpwm, int operator_id, int fault_sig, bool enable) +{ + mcpwm->operators[operator_id].fh_cfg0.val &= ~(1 << (3 - fault_sig)); + mcpwm->operators[operator_id].fh_cfg0.val |= (enable << (3 - fault_sig)); +} + +static inline void mcpwm_ll_fault_enable_cbc_refresh_on_tez(mcpwm_dev_t *mcpwm, int operator_id, bool enable) +{ + if (enable) { + mcpwm->operators[operator_id].fh_cfg1.val |= 1 << 1; } else { - mcpwm->channel[operator_id].tz_cfg0.f2_ost = enable; + mcpwm->operators[operator_id].fh_cfg1.val &= ~(1 << 1); } } -static inline void mcpwm_ll_fault_enable_cbc_mode(mcpwm_dev_t *mcpwm, int operator_id, int fault_sig, bool enable) +static inline void mcpwm_ll_fault_enable_cbc_refresh_on_tep(mcpwm_dev_t *mcpwm, int operator_id, bool enable) { - if (fault_sig == 0) { - mcpwm->channel[operator_id].tz_cfg0.f0_cbc = enable; - } else if (fault_sig == 1) { - mcpwm->channel[operator_id].tz_cfg0.f1_cbc = enable; + if (enable) { + mcpwm->operators[operator_id].fh_cfg1.val |= 1 << 2; } else { - mcpwm->channel[operator_id].tz_cfg0.f2_cbc = enable; + mcpwm->operators[operator_id].fh_cfg1.val &= ~(1 << 2); } - mcpwm->channel[operator_id].tz_cfg1.cbcpulse = 1 << 0; } static inline void mcpwm_ll_fault_enable_sw_cbc(mcpwm_dev_t *mcpwm, int operator_id, bool enable) { - mcpwm->channel[operator_id].tz_cfg0.sw_cbc = enable; + mcpwm->operators[operator_id].fh_cfg0.fh_sw_cbc = enable; } static inline void mcpwm_ll_fault_enable_sw_oneshot(mcpwm_dev_t *mcpwm, int operator_id, bool enable) { - mcpwm->channel[operator_id].tz_cfg0.sw_ost = enable; + mcpwm->operators[operator_id].fh_cfg0.fh_sw_ost = enable; } static inline void mcpwm_ll_fault_trigger_sw_cbc(mcpwm_dev_t *mcpwm, int operator_id) { - mcpwm->channel[operator_id].tz_cfg1.force_cbc = ~mcpwm->channel[operator_id].tz_cfg1.force_cbc; + mcpwm->operators[operator_id].fh_cfg1.fh_force_cbc = ~mcpwm->operators[operator_id].fh_cfg1.fh_force_cbc; } -static inline void mcpwm_ll_fault_trigger_sw_oneshot(mcpwm_dev_t *mcpwm, int operator_id) +static inline void mcpwm_ll_fault_trigger_sw_ost(mcpwm_dev_t *mcpwm, int operator_id) { - mcpwm->channel[operator_id].tz_cfg1.force_ost = ~mcpwm->channel[operator_id].tz_cfg1.force_ost; + mcpwm->operators[operator_id].fh_cfg1.fh_force_ost = ~mcpwm->operators[operator_id].fh_cfg1.fh_force_ost; } -static inline void mcpwm_ll_generator_set_action_on_fault_event(mcpwm_dev_t *mcpwm, int operator_id, int generator_id, - mcpwm_timer_direction_t direction, mcpwm_fault_reaction_t reaction, int action) +static inline void mcpwm_ll_generator_set_action_on_trip_event(mcpwm_dev_t *mcpwm, int operator_id, int generator_id, + mcpwm_timer_direction_t direction, mcpwm_trip_type_t trip, int action) { if (direction == MCPWM_TIMER_DIRECTION_UP) { - mcpwm->channel[operator_id].tz_cfg0.val &= ~(0x03 << (8 + 8 * generator_id + 4 * reaction + 2)); - mcpwm->channel[operator_id].tz_cfg0.val |= action << (8 + 8 * generator_id + 4 * reaction + 2); + mcpwm->operators[operator_id].fh_cfg0.val &= ~(0x03 << (8 + 8 * generator_id + 4 * trip + 2)); + mcpwm->operators[operator_id].fh_cfg0.val |= action << (8 + 8 * generator_id + 4 * trip + 2); } else if (direction == MCPWM_TIMER_DIRECTION_DOWN) { - mcpwm->channel[operator_id].tz_cfg0.val &= ~(0x03 << (8 + 8 * generator_id + 4 * reaction)); - mcpwm->channel[operator_id].tz_cfg0.val |= action << (8 + 8 * generator_id + 4 * reaction); + mcpwm->operators[operator_id].fh_cfg0.val &= ~(0x03 << (8 + 8 * generator_id + 4 * trip)); + mcpwm->operators[operator_id].fh_cfg0.val |= action << (8 + 8 * generator_id + 4 * trip); } } static inline bool mcpwm_ll_fault_is_ost_on(mcpwm_dev_t *mcpwm, int op) { - return mcpwm->channel[op].tz_status.ost_on; + return mcpwm->operators[op].fh_status.fh_ost_on; } static inline bool mcpwm_ll_fault_is_cbc_on(mcpwm_dev_t *mcpwm, int op) { - return mcpwm->channel[op].tz_status.cbc_on; + return mcpwm->operators[op].fh_status.fh_cbc_on; } /********************* Capture registers *******************/ static inline void mcpwm_ll_capture_enable_timer(mcpwm_dev_t *mcpwm, bool enable) { - mcpwm->cap_timer_cfg.timer_en = enable; + mcpwm->cap_timer_cfg.cap_timer_en = enable; } static inline void mcpwm_ll_capture_enable_channel(mcpwm_dev_t *mcpwm, int channel, bool enable) { - mcpwm->cap_cfg_ch[channel].en = enable; + mcpwm->cap_chn_cfg[channel].capn_en = enable; } -static inline void mcpwm_ll_capture_set_sync_phase(mcpwm_dev_t *mcpwm, uint32_t phase_value) +static inline void mcpwm_ll_capture_set_sync_phase_value(mcpwm_dev_t *mcpwm, uint32_t phase_value) { - mcpwm->cap_timer_phase = phase_value; + mcpwm->cap_timer_phase.cap_timer_phase = phase_value; } -static inline uint32_t mcpwm_ll_capture_get_sync_phase(mcpwm_dev_t *mcpwm) +static inline uint32_t mcpwm_ll_capture_get_sync_phase_value(mcpwm_dev_t *mcpwm) { - return mcpwm->cap_timer_phase; + return mcpwm->cap_timer_phase.cap_timer_phase; } static inline void mcpwm_ll_capture_enable_timer_sync(mcpwm_dev_t *mcpwm, bool enable) { - mcpwm->cap_timer_cfg.synci_en = enable; + mcpwm->cap_timer_cfg.cap_synci_en = enable; } -static inline void mcpwm_ll_capture_set_internal_timer_syncer(mcpwm_dev_t *mcpwm, int sync_out_timer) +static inline void mcpwm_ll_capture_set_internal_timer_synchro(mcpwm_dev_t *mcpwm, int sync_out_timer) { - mcpwm->cap_timer_cfg.synci_sel = sync_out_timer + 1; + mcpwm->cap_timer_cfg.cap_synci_sel = sync_out_timer + 1; } -static inline void mcpwm_ll_capture_set_external_syncer(mcpwm_dev_t *mcpwm, int extern_syncer) +static inline void mcpwm_ll_capture_set_external_synchro(mcpwm_dev_t *mcpwm, int extern_synchro) { - mcpwm->cap_timer_cfg.synci_sel = extern_syncer + 4; + mcpwm->cap_timer_cfg.cap_synci_sel = extern_synchro + 4; } static inline void mcpwm_ll_capture_trigger_sw_sync(mcpwm_dev_t *mcpwm) { - mcpwm->cap_timer_cfg.sync_sw = 1; // auto clear + mcpwm->cap_timer_cfg.cap_sync_sw = 1; // auto clear } static inline void mcpwm_ll_capture_enable_posedge(mcpwm_dev_t *mcpwm, int channel, bool enable) { if (enable) { - mcpwm->cap_cfg_ch[channel].val |= 1 << 2; + mcpwm->cap_chn_cfg[channel].val |= 1 << 2; } else { - mcpwm->cap_cfg_ch[channel].val &= ~(1 << 2); + mcpwm->cap_chn_cfg[channel].val &= ~(1 << 2); } } static inline void mcpwm_ll_capture_enable_negedge(mcpwm_dev_t *mcpwm, int channel, bool enable) { if (enable) { - mcpwm->cap_cfg_ch[channel].val |= 1 << 1; + mcpwm->cap_chn_cfg[channel].val |= 1 << 1; } else { - mcpwm->cap_cfg_ch[channel].val &= ~(1 << 1); + mcpwm->cap_chn_cfg[channel].val &= ~(1 << 1); } } static inline void mcpwm_ll_invert_input(mcpwm_dev_t *mcpwm, int channel, bool invert) { - mcpwm->cap_cfg_ch[channel].in_invert = invert; + mcpwm->cap_chn_cfg[channel].capn_in_invert = invert; } static inline void mcpwm_ll_trigger_soft_capture(mcpwm_dev_t *mcpwm, int channel) { - mcpwm->cap_cfg_ch[channel].sw = 1; // auto clear + mcpwm->cap_chn_cfg[channel].capn_sw = 1; // auto clear } +__attribute__((always_inline)) static inline uint32_t mcpwm_ll_capture_get_value(mcpwm_dev_t *mcpwm, int channel) { - return mcpwm->cap_val_ch[channel]; + return mcpwm->cap_chn[channel].capn_value; } +__attribute__((always_inline)) static inline bool mcpwm_ll_capture_is_negedge(mcpwm_dev_t *mcpwm, int channel) { return mcpwm->cap_status.val & (1 << channel) ? true : false; @@ -926,12 +997,12 @@ static inline bool mcpwm_ll_capture_is_negedge(mcpwm_dev_t *mcpwm, int channel) static inline void mcpwm_ll_capture_set_prescale(mcpwm_dev_t *mcpwm, int channel, uint32_t prescale) { - mcpwm->cap_cfg_ch[channel].prescale = prescale - 1; + HAL_FORCE_MODIFY_U32_REG_FIELD(mcpwm->cap_chn_cfg[channel], capn_prescale, prescale - 1); } static inline uint32_t mcpwm_ll_capture_get_prescale(mcpwm_dev_t *mcpwm, int channel) { - return mcpwm->cap_cfg_ch[channel].prescale + 1; + return HAL_FORCE_READ_U32_REG_FIELD(mcpwm->cap_chn_cfg[channel], capn_prescale) + 1; } #ifdef __cplusplus diff --git a/tools/sdk/esp32/include/hal/esp32/include/hal/mwdt_ll.h b/tools/sdk/esp32/include/hal/esp32/include/hal/mwdt_ll.h index 9a981c68553..267f15ef2c1 100644 --- a/tools/sdk/esp32/include/hal/esp32/include/hal/mwdt_ll.h +++ b/tools/sdk/esp32/include/hal/esp32/include/hal/mwdt_ll.h @@ -23,7 +23,9 @@ extern "C" { #include #include +#include "hal/misc.h" #include "soc/timer_periph.h" +#include "soc/timer_group_struct.h" #include "hal/wdt_types.h" #include "esp_attr.h" @@ -201,7 +203,7 @@ FORCE_INLINE_ATTR void mwdt_ll_set_flashboot_en(timg_dev_t* hw, bool enable) */ FORCE_INLINE_ATTR void mwdt_ll_set_prescaler(timg_dev_t *hw, uint32_t prescaler) { - hw->wdt_config1.clk_prescale = prescaler; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->wdt_config1, clk_prescale, prescaler); } /** diff --git a/tools/sdk/esp32/include/hal/esp32/include/hal/pcnt_ll.h b/tools/sdk/esp32/include/hal/esp32/include/hal/pcnt_ll.h index b5b20ff49da..40d4aff973c 100644 --- a/tools/sdk/esp32/include/hal/esp32/include/hal/pcnt_ll.h +++ b/tools/sdk/esp32/include/hal/esp32/include/hal/pcnt_ll.h @@ -1,4 +1,4 @@ -// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD +// Copyright 2015-2021 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. @@ -22,323 +22,386 @@ #pragma once -#include "soc/pcnt_periph.h" +#include +#include +#include "soc/pcnt_struct.h" #include "hal/pcnt_types.h" #ifdef __cplusplus extern "C" { #endif -// Get PCNT hardware instance with giving pcnt num #define PCNT_LL_GET_HW(num) (((num) == 0) ? (&PCNT) : NULL) +#define PCNT_LL_MAX_GLITCH_WIDTH 1023 + +typedef enum { + PCNT_LL_EVENT_THRES1, + PCNT_LL_EVENT_THRES0, + PCNT_LL_EVENT_LOW_LIMIT, + PCNT_LL_EVENT_HIGH_LIMIT, + PCNT_LL_EVENT_ZERO_CROSS, + PCNT_LL_EVENT_MAX +} pcnt_ll_event_id_t; + +#define PCNT_LL_EVENT_MASK ((1 << PCNT_LL_EVENT_MAX) - 1) /** - * @brief Set PCNT channel edge mode + * @brief Set PCNT channel edge action * * @param hw Peripheral PCNT hardware instance address. * @param unit PCNT unit number * @param channel PCNT channel number - * @param pos_mode Counter mode when detecting positive edge - * @param neg_mode Counter mode when detecting negative edge + * @param pos_act Counter action when detecting positive edge + * @param neg_act Counter action when detecting negative edge */ -static inline void pcnt_ll_set_edge_mode(pcnt_dev_t *hw, pcnt_unit_t unit, pcnt_channel_t channel, pcnt_count_mode_t pos_mode, pcnt_count_mode_t neg_mode) +static inline void pcnt_ll_set_edge_action(pcnt_dev_t *hw, uint32_t unit, uint32_t channel, pcnt_channel_edge_action_t pos_act, pcnt_channel_edge_action_t neg_act) { - typeof(hw->conf_unit[unit].conf0) conf0_reg = hw->conf_unit[unit].conf0; if (channel == 0) { - conf0_reg.ch0_pos_mode = pos_mode; - conf0_reg.ch0_neg_mode = neg_mode; + hw->conf_unit[unit].conf0.ch0_pos_mode = pos_act; + hw->conf_unit[unit].conf0.ch0_neg_mode = neg_act; } else { - conf0_reg.ch1_pos_mode = pos_mode; - conf0_reg.ch1_neg_mode = neg_mode; + hw->conf_unit[unit].conf0.ch1_pos_mode = pos_act; + hw->conf_unit[unit].conf0.ch1_neg_mode = neg_act; } - hw->conf_unit[unit].conf0 = conf0_reg; } /** - * @brief Set PCNT channel level mode + * @brief Set PCNT channel level action * * @param hw Peripheral PCNT hardware instance address. * @param unit PCNT unit number * @param channel PCNT channel number - * @param hctrl_mode Counter mode when control signal is high level - * @param lctrl_mode Counter mode when control signal is low level + * @param high_act Counter action when control signal is high level + * @param low_act Counter action when control signal is low level */ -static inline void pcnt_ll_set_level_mode(pcnt_dev_t *hw, pcnt_unit_t unit, pcnt_channel_t channel, pcnt_ctrl_mode_t hctrl_mode, pcnt_ctrl_mode_t lctrl_mode) +static inline void pcnt_ll_set_level_action(pcnt_dev_t *hw, uint32_t unit, uint32_t channel, pcnt_channel_level_action_t high_act, pcnt_channel_level_action_t low_act) { - typeof(hw->conf_unit[unit].conf0) conf0_reg = hw->conf_unit[unit].conf0; if (channel == 0) { - conf0_reg.ch0_hctrl_mode = hctrl_mode; - conf0_reg.ch0_lctrl_mode = lctrl_mode; + hw->conf_unit[unit].conf0.ch0_hctrl_mode = high_act; + hw->conf_unit[unit].conf0.ch0_lctrl_mode = low_act; } else { - conf0_reg.ch1_hctrl_mode = hctrl_mode; - conf0_reg.ch1_lctrl_mode = lctrl_mode; + hw->conf_unit[unit].conf0.ch1_hctrl_mode = high_act; + hw->conf_unit[unit].conf0.ch1_lctrl_mode = low_act; } - hw->conf_unit[unit].conf0 = conf0_reg; } /** - * @brief Set PCNT counter mode + * @brief Get pulse counter value + * + * @param hw Peripheral PCNT hardware instance address. + * @param unit Pulse Counter unit number + * @return PCNT count value (a signed integer) + */ +static inline int pcnt_ll_get_count(pcnt_dev_t *hw, uint32_t unit) +{ + typeof(hw->cnt_unit[unit]) cnt_reg = hw->cnt_unit[unit]; + int16_t value = cnt_reg.cnt_val; + return value; +} + +/** + * @brief Pause PCNT counter of PCNT unit * * @param hw Peripheral PCNT hardware instance address. * @param unit PCNT unit number - * @param channel PCNT channel number - * @param pos_mode Counter mode when detecting positive edge - * @param neg_mode Counter mode when detecting negative edge - * @param hctrl_mode Counter mode when control signal is high level - * @param lctrl_mode Counter mode when control signal is low level */ -static inline void pcnt_ll_set_mode(pcnt_dev_t *hw, pcnt_unit_t unit, pcnt_channel_t channel, pcnt_count_mode_t pos_mode, pcnt_count_mode_t neg_mode, pcnt_ctrl_mode_t hctrl_mode, pcnt_ctrl_mode_t lctrl_mode) +static inline void pcnt_ll_stop_count(pcnt_dev_t *hw, uint32_t unit) { - pcnt_ll_set_edge_mode(hw, unit, channel, pos_mode, neg_mode); - pcnt_ll_set_level_mode(hw, unit, channel, hctrl_mode, lctrl_mode); + hw->ctrl.val |= 1 << (2 * unit + 1); } /** - * @brief Get pulse counter value + * @brief Resume counting for PCNT counter * * @param hw Peripheral PCNT hardware instance address. - * @param unit Pulse Counter unit number - * @param count Pointer to accept counter value + * @param unit PCNT unit number, select from uint32_t */ -static inline void pcnt_ll_get_counter_value(pcnt_dev_t *hw, pcnt_unit_t unit, int16_t *count) +static inline void pcnt_ll_start_count(pcnt_dev_t *hw, uint32_t unit) { - *count = (int16_t) hw->cnt_unit[unit].cnt_val; + hw->ctrl.val &= ~(1 << (2 * unit + 1)); } /** - * @brief Pause PCNT counter of PCNT unit + * @brief Clear PCNT counter value to zero * * @param hw Peripheral PCNT hardware instance address. - * @param unit PCNT unit number + * @param unit PCNT unit number, select from uint32_t */ -static inline void pcnt_ll_counter_pause(pcnt_dev_t *hw, pcnt_unit_t unit) +static inline void pcnt_ll_clear_count(pcnt_dev_t *hw, uint32_t unit) { - hw->ctrl.val |= BIT(PCNT_CNT_PAUSE_U0_S + (unit * 2)); + hw->ctrl.val |= 1 << (2 * unit); + hw->ctrl.val &= ~(1 << (2 * unit)); } /** - * @brief Resume counting for PCNT counter + * @brief Enable PCNT interrupt for PCNT unit + * @note Each PCNT unit has five watch point events that share the same interrupt bit. * * @param hw Peripheral PCNT hardware instance address. - * @param unit PCNT unit number, select from pcnt_unit_t + * @param unit_mask PCNT units mask + * @param enable True to enable interrupt, False to disable interrupt */ -static inline void pcnt_ll_counter_resume(pcnt_dev_t *hw, pcnt_unit_t unit) +static inline void pcnt_ll_enable_intr(pcnt_dev_t *hw, uint32_t unit_mask, bool enable) { - hw->ctrl.val &= (~(BIT(PCNT_CNT_PAUSE_U0_S + (unit * 2)))); + if (enable) { + hw->int_ena.val |= unit_mask; + } else { + hw->int_ena.val &= ~unit_mask; + } } /** - * @brief Clear and reset PCNT counter value to zero + * @brief Get PCNT interrupt status * * @param hw Peripheral PCNT hardware instance address. - * @param unit PCNT unit number, select from pcnt_unit_t + * @return Interrupt status word */ -static inline void pcnt_ll_counter_clear(pcnt_dev_t *hw, pcnt_unit_t unit) +__attribute__((always_inline)) static inline uint32_t pcnt_ll_get_intr_status(pcnt_dev_t *hw) { - uint32_t reset_bit = BIT(PCNT_PLUS_CNT_RST_U0_S + (unit * 2)); - hw->ctrl.val |= reset_bit; - hw->ctrl.val &= ~reset_bit; + return hw->int_st.val; } /** - * @brief Enable PCNT interrupt for PCNT unit - * @note - * Each Pulse counter unit has five watch point events that share the same interrupt. - * Configure events with pcnt_event_enable() and pcnt_event_disable() + * @brief Clear PCNT interrupt status * * @param hw Peripheral PCNT hardware instance address. - * @param unit PCNT unit number + * @param status value to clear interrupt status */ -static inline void pcnt_ll_intr_enable(pcnt_dev_t *hw, pcnt_unit_t unit) +__attribute__((always_inline)) static inline void pcnt_ll_clear_intr_status(pcnt_dev_t *hw, uint32_t status) { - hw->int_ena.val |= BIT(PCNT_CNT_THR_EVENT_U0_INT_ENA_S + unit); + hw->int_clr.val = status; } /** - * @brief Disable PCNT interrupt for PCNT unit + * @brief Enable PCNT high limit event * * @param hw Peripheral PCNT hardware instance address. * @param unit PCNT unit number + * @param enable true to enable, false to disable */ -static inline void pcnt_ll_intr_disable(pcnt_dev_t *hw, pcnt_unit_t unit) +static inline void pcnt_ll_enable_high_limit_event(pcnt_dev_t *hw, uint32_t unit, bool enable) { - hw->int_ena.val &= (~(BIT(PCNT_CNT_THR_EVENT_U0_INT_ENA_S + unit))); + hw->conf_unit[unit].conf0.thr_h_lim_en = enable; } /** - * @brief Get PCNT interrupt status + * @brief Enable PCNT low limit event * * @param hw Peripheral PCNT hardware instance address. - * @param status Pointer to accept value + * @param unit PCNT unit number + * @param enable true to enable, false to disable */ -static inline void pcnt_ll_get_intr_status(pcnt_dev_t *hw, uint32_t *status) +static inline void pcnt_ll_enable_low_limit_event(pcnt_dev_t *hw, uint32_t unit, bool enable) { - *status = hw->int_st.val; + hw->conf_unit[unit].conf0.thr_l_lim_en = enable; } /** - * @brief Clear PCNT interrupt status + * @brief Enable PCNT zero cross event * * @param hw Peripheral PCNT hardware instance address. - * @param status value to clear interrupt status + * @param unit PCNT unit number + * @param enable true to enable, false to disable */ -static inline void pcnt_ll_clear_intr_status(pcnt_dev_t *hw, uint32_t status) +static inline void pcnt_ll_enable_zero_cross_event(pcnt_dev_t *hw, uint32_t unit, bool enable) { - hw->int_clr.val = status; + hw->conf_unit[unit].conf0.thr_zero_en = enable; } /** - * @brief Enable PCNT event of PCNT unit + * @brief Enable PCNT threshold event * * @param hw Peripheral PCNT hardware instance address. * @param unit PCNT unit number - * @param evt_type Watch point event type. - * All enabled events share the same interrupt (one interrupt per pulse counter unit). + * @param thres Threshold ID + * @param enable true to enable, false to disable */ -static inline void pcnt_ll_event_enable(pcnt_dev_t *hw, pcnt_unit_t unit, pcnt_evt_type_t evt_type) +static inline void pcnt_ll_enable_thres_event(pcnt_dev_t *hw, uint32_t unit, uint32_t thres, bool enable) { - if (evt_type == PCNT_EVT_L_LIM) { - hw->conf_unit[unit].conf0.thr_l_lim_en = 1; - } else if (evt_type == PCNT_EVT_H_LIM) { - hw->conf_unit[unit].conf0.thr_h_lim_en = 1; - } else if (evt_type == PCNT_EVT_THRES_0) { - hw->conf_unit[unit].conf0.thr_thres0_en = 1; - } else if (evt_type == PCNT_EVT_THRES_1) { - hw->conf_unit[unit].conf0.thr_thres1_en = 1; - } else if (evt_type == PCNT_EVT_ZERO) { - hw->conf_unit[unit].conf0.thr_zero_en = 1; + if (thres == 0) { + hw->conf_unit[unit].conf0.thr_thres0_en = enable; + } else { + hw->conf_unit[unit].conf0.thr_thres1_en = enable; } } /** - * @brief Disable PCNT event of PCNT unit + * @brief Disable all PCNT threshold events + * + * @param hw Peripheral PCNT hardware instance address. + * @param unit unit number + */ +static inline void pcnt_ll_disable_all_events(pcnt_dev_t *hw, uint32_t unit) +{ + hw->conf_unit[unit].conf0.val &= ~(PCNT_LL_EVENT_MASK << 11); +} + +/** + * @brief Set PCNT high limit value * * @param hw Peripheral PCNT hardware instance address. * @param unit PCNT unit number - * @param evt_type Watch point event type. - * All enabled events share the same interrupt (one interrupt per pulse counter unit). + * @param value PCNT high limit value */ -static inline void pcnt_ll_event_disable(pcnt_dev_t *hw, pcnt_unit_t unit, pcnt_evt_type_t evt_type) +static inline void pcnt_ll_set_high_limit_value(pcnt_dev_t *hw, uint32_t unit, int value) { - if (evt_type == PCNT_EVT_L_LIM) { - hw->conf_unit[unit].conf0.thr_l_lim_en = 0; - } else if (evt_type == PCNT_EVT_H_LIM) { - hw->conf_unit[unit].conf0.thr_h_lim_en = 0; - } else if (evt_type == PCNT_EVT_THRES_0) { - hw->conf_unit[unit].conf0.thr_thres0_en = 0; - } else if (evt_type == PCNT_EVT_THRES_1) { - hw->conf_unit[unit].conf0.thr_thres1_en = 0; - } else if (evt_type == PCNT_EVT_ZERO) { - hw->conf_unit[unit].conf0.thr_zero_en = 0; - } + typeof(hw->conf_unit[unit].conf2) conf2_reg = hw->conf_unit[unit].conf2; + conf2_reg.cnt_h_lim = value; + hw->conf_unit[unit].conf2 = conf2_reg; } /** - * @brief Set PCNT event value of PCNT unit + * @brief Set PCNT low limit value * * @param hw Peripheral PCNT hardware instance address. * @param unit PCNT unit number - * @param evt_type Watch point event type. - * All enabled events share the same interrupt (one interrupt per pulse counter unit). + * @param value PCNT low limit value + */ +static inline void pcnt_ll_set_low_limit_value(pcnt_dev_t *hw, uint32_t unit, int value) +{ + typeof(hw->conf_unit[unit].conf2) conf2_reg = hw->conf_unit[unit].conf2; + conf2_reg.cnt_l_lim = value; + hw->conf_unit[unit].conf2 = conf2_reg; +} + +/** + * @brief Set PCNT threshold value * - * @param value Counter value for PCNT event + * @param hw Peripheral PCNT hardware instance address. + * @param unit PCNT unit number + * @param thres Threshold ID + * @param value PCNT threshold value */ -static inline void pcnt_ll_set_event_value(pcnt_dev_t *hw, pcnt_unit_t unit, pcnt_evt_type_t evt_type, int16_t value) +static inline void pcnt_ll_set_thres_value(pcnt_dev_t *hw, uint32_t unit, uint32_t thres, int value) { - if (evt_type == PCNT_EVT_L_LIM) { - hw->conf_unit[unit].conf2.cnt_l_lim = value; - } else if (evt_type == PCNT_EVT_H_LIM) { - hw->conf_unit[unit].conf2.cnt_h_lim = value; - } else if (evt_type == PCNT_EVT_THRES_0) { - hw->conf_unit[unit].conf1.cnt_thres0 = value; - } else if (evt_type == PCNT_EVT_THRES_1) { - hw->conf_unit[unit].conf1.cnt_thres1 = value; + typeof(hw->conf_unit[unit].conf1) conf1_reg = hw->conf_unit[unit].conf1; + if (thres == 0) { + conf1_reg.cnt_thres0 = value; + } else { + conf1_reg.cnt_thres1 = value; } + hw->conf_unit[unit].conf1 = conf1_reg; } /** - * @brief Get PCNT event value of PCNT unit + * @brief Get PCNT high limit value * * @param hw Peripheral PCNT hardware instance address. * @param unit PCNT unit number - * @param evt_type Watch point event type. - * All enabled events share the same interrupt (one interrupt per pulse counter unit). - * @param value Pointer to accept counter value for PCNT event + * @return PCNT high limit value */ -static inline void pcnt_ll_get_event_value(pcnt_dev_t *hw, pcnt_unit_t unit, pcnt_evt_type_t evt_type, int16_t *value) +static inline int pcnt_ll_get_high_limit_value(pcnt_dev_t *hw, uint32_t unit) { - if (evt_type == PCNT_EVT_L_LIM) { - *value = (int16_t) hw->conf_unit[unit].conf2.cnt_l_lim; - } else if (evt_type == PCNT_EVT_H_LIM) { - *value = (int16_t) hw->conf_unit[unit].conf2.cnt_h_lim; - } else if (evt_type == PCNT_EVT_THRES_0) { - *value = (int16_t) hw->conf_unit[unit].conf1.cnt_thres0; - } else if (evt_type == PCNT_EVT_THRES_1) { - *value = (int16_t) hw->conf_unit[unit].conf1.cnt_thres1; + typeof(hw->conf_unit[unit].conf2) conf2_reg = hw->conf_unit[unit].conf2; + int16_t value = conf2_reg.cnt_h_lim; + return value; +} + +/** + * @brief Get PCNT low limit value + * + * @param hw Peripheral PCNT hardware instance address. + * @param unit PCNT unit number + * @return PCNT high limit value + */ +static inline int pcnt_ll_get_low_limit_value(pcnt_dev_t *hw, uint32_t unit) +{ + typeof(hw->conf_unit[unit].conf2) conf2_reg = hw->conf_unit[unit].conf2; + int16_t value = conf2_reg.cnt_l_lim; + return value; +} + +/** + * @brief Get PCNT threshold value + * + * @param hw Peripheral PCNT hardware instance address. + * @param unit PCNT unit number + * @param thres Threshold ID + * @return PCNT threshold value + */ +static inline int pcnt_ll_get_thres_value(pcnt_dev_t *hw, uint32_t unit, uint32_t thres) +{ + int16_t value; + typeof(hw->conf_unit[unit].conf1) conf1_reg = hw->conf_unit[unit].conf1; + if (thres == 0) { + value = conf1_reg.cnt_thres0; } else { - *value = 0; + value = conf1_reg.cnt_thres1; } + return value; } /** - * @brief Get PCNT event status + * @brief Get PCNT unit runtime status * * @param hw Peripheral PCNT hardware instance address. * @param unit PCNT unit number - * @return event status word + * @return PCNT unit runtime status */ -static inline uint32_t pcnt_ll_get_event_status(pcnt_dev_t *hw, pcnt_unit_t unit) +static inline uint32_t pcnt_ll_get_unit_status(pcnt_dev_t *hw, uint32_t unit) { return hw->status_unit[unit].val; } /** - * @brief Set PCNT filter value + * @brief Get PCNT count sign * * @param hw Peripheral PCNT hardware instance address. * @param unit PCNT unit number - * @param filter_val PCNT signal filter value, counter in APB_CLK cycles. - * Any pulses lasting shorter than this will be ignored when the filter is enabled. - * @note - * filter_val is a 10-bit value, so the maximum filter_val should be limited to 1023. + * @return Count sign */ -static inline void pcnt_ll_set_filter_value(pcnt_dev_t *hw, pcnt_unit_t unit, uint16_t filter_val) +static inline pcnt_unit_count_sign_t pcnt_ll_get_count_sign(pcnt_dev_t *hw, uint32_t unit) { - hw->conf_unit[unit].conf0.filter_thres = filter_val; + return hw->status_unit[unit].val & 0x03; +} + +/** + * @brief Get PCNT event status + * + * @param hw Peripheral PCNT hardware instance address. + * @param unit PCNT unit number + * @return Event status word + */ +static inline uint32_t pcnt_ll_get_event_status(pcnt_dev_t *hw, uint32_t unit) +{ + return hw->status_unit[unit].val >> 2; } /** - * @brief Get PCNT filter value + * @brief Set PCNT glitch filter threshold * * @param hw Peripheral PCNT hardware instance address. * @param unit PCNT unit number - * @param filter_val Pointer to accept PCNT filter value. + * @param filter_val PCNT signal filter value, counter in APB_CLK cycles. + * Any pulses lasting shorter than this will be ignored when the filter is enabled. */ -static inline void pcnt_ll_get_filter_value(pcnt_dev_t *hw, pcnt_unit_t unit, uint16_t *filter_val) +static inline void pcnt_ll_set_glitch_filter_thres(pcnt_dev_t *hw, uint32_t unit, uint32_t filter_val) { - *filter_val = hw->conf_unit[unit].conf0.filter_thres; + hw->conf_unit[unit].conf0.filter_thres = filter_val; } /** - * @brief Enable PCNT input filter + * @brief Get PCNT glitch filter threshold * * @param hw Peripheral PCNT hardware instance address. * @param unit PCNT unit number + * @return glitch filter threshold */ -static inline void pcnt_ll_filter_enable(pcnt_dev_t *hw, pcnt_unit_t unit) +static inline uint32_t pcnt_ll_get_glitch_filter_thres(pcnt_dev_t *hw, uint32_t unit) { - hw->conf_unit[unit].conf0.filter_en = 1; + return hw->conf_unit[unit].conf0.filter_thres; } /** - * @brief Disable PCNT input filter + * @brief Enable PCNT glitch filter * * @param hw Peripheral PCNT hardware instance address. * @param unit PCNT unit number + * @param enable True to enable the filter, False to disable the filter */ -static inline void pcnt_ll_filter_disable(pcnt_dev_t *hw, pcnt_unit_t unit) +static inline void pcnt_ll_enable_glitch_filter(pcnt_dev_t *hw, uint32_t unit, bool enable) { - hw->conf_unit[unit].conf0.filter_en = 0; + hw->conf_unit[unit].conf0.filter_en = enable; } #ifdef __cplusplus diff --git a/tools/sdk/esp32/include/hal/esp32/include/hal/rmt_ll.h b/tools/sdk/esp32/include/hal/esp32/include/hal/rmt_ll.h index edd4f279126..dfd8199d5ba 100644 --- a/tools/sdk/esp32/include/hal/esp32/include/hal/rmt_ll.h +++ b/tools/sdk/esp32/include/hal/esp32/include/hal/rmt_ll.h @@ -15,6 +15,7 @@ #include #include +#include "hal/misc.h" #include "soc/rmt_struct.h" #ifdef __cplusplus @@ -119,23 +120,23 @@ static inline uint32_t rmt_ll_rx_get_mem_blocks(rmt_dev_t *dev, uint32_t channel static inline void rmt_ll_tx_set_channel_clock_div(rmt_dev_t *dev, uint32_t channel, uint32_t div) { - dev->conf_ch[channel].conf0.div_cnt = div; + HAL_FORCE_MODIFY_U32_REG_FIELD(dev->conf_ch[channel].conf0, div_cnt, div); } static inline void rmt_ll_rx_set_channel_clock_div(rmt_dev_t *dev, uint32_t channel, uint32_t div) { - dev->conf_ch[channel].conf0.div_cnt = div; + HAL_FORCE_MODIFY_U32_REG_FIELD(dev->conf_ch[channel].conf0, div_cnt, div); } static inline uint32_t rmt_ll_tx_get_channel_clock_div(rmt_dev_t *dev, uint32_t channel) { - uint32_t div = dev->conf_ch[channel].conf0.div_cnt; + uint32_t div = HAL_FORCE_READ_U32_REG_FIELD(dev->conf_ch[channel].conf0, div_cnt); return div == 0 ? 256 : div; } static inline uint32_t rmt_ll_rx_get_channel_clock_div(rmt_dev_t *dev, uint32_t channel) { - uint32_t div = dev->conf_ch[channel].conf0.div_cnt; + uint32_t div = HAL_FORCE_READ_U32_REG_FIELD(dev->conf_ch[channel].conf0, div_cnt); return div == 0 ? 256 : div; } @@ -146,12 +147,12 @@ static inline void rmt_ll_tx_enable_pingpong(rmt_dev_t *dev, uint32_t channel, b static inline void rmt_ll_rx_set_idle_thres(rmt_dev_t *dev, uint32_t channel, uint32_t thres) { - dev->conf_ch[channel].conf0.idle_thres = thres; + HAL_FORCE_MODIFY_U32_REG_FIELD(dev->conf_ch[channel].conf0, idle_thres, thres); } static inline uint32_t rmt_ll_rx_get_idle_thres(rmt_dev_t *dev, uint32_t channel) { - return dev->conf_ch[channel].conf0.idle_thres; + return HAL_FORCE_READ_U32_REG_FIELD(dev->conf_ch[channel].conf0, idle_thres); } static inline void rmt_ll_rx_set_mem_owner(rmt_dev_t *dev, uint32_t channel, uint8_t owner) @@ -186,7 +187,7 @@ static inline void rmt_ll_rx_enable_filter(rmt_dev_t *dev, uint32_t channel, boo static inline void rmt_ll_rx_set_filter_thres(rmt_dev_t *dev, uint32_t channel, uint32_t thres) { - dev->conf_ch[channel].conf1.rx_filter_thres = thres; + HAL_FORCE_MODIFY_U32_REG_FIELD(dev->conf_ch[channel].conf1, rx_filter_thres, thres); } static inline void rmt_ll_tx_enable_idle(rmt_dev_t *dev, uint32_t channel, bool enable) @@ -324,14 +325,14 @@ static inline uint32_t rmt_ll_get_tx_thres_interrupt_status(rmt_dev_t *dev) static inline void rmt_ll_tx_set_carrier_high_low_ticks(rmt_dev_t *dev, uint32_t channel, uint32_t high_ticks, uint32_t low_ticks) { - dev->carrier_duty_ch[channel].high = high_ticks; - dev->carrier_duty_ch[channel].low = low_ticks; + HAL_FORCE_MODIFY_U32_REG_FIELD(dev->carrier_duty_ch[channel], high, high_ticks); + HAL_FORCE_MODIFY_U32_REG_FIELD(dev->carrier_duty_ch[channel], low, low_ticks); } static inline void rmt_ll_tx_get_carrier_high_low_ticks(rmt_dev_t *dev, uint32_t channel, uint32_t *high_ticks, uint32_t *low_ticks) { - *high_ticks = dev->carrier_duty_ch[channel].high; - *low_ticks = dev->carrier_duty_ch[channel].low; + *high_ticks = HAL_FORCE_READ_U32_REG_FIELD(dev->carrier_duty_ch[channel], high); + *low_ticks = HAL_FORCE_READ_U32_REG_FIELD(dev->carrier_duty_ch[channel], low); } static inline void rmt_ll_tx_enable_carrier_modulation(rmt_dev_t *dev, uint32_t channel, bool enable) diff --git a/tools/sdk/esp32/include/hal/esp32/include/hal/rtc_io_ll.h b/tools/sdk/esp32/include/hal/esp32/include/hal/rtc_io_ll.h index 3e5a1af8ff6..f96452532e3 100644 --- a/tools/sdk/esp32/include/hal/esp32/include/hal/rtc_io_ll.h +++ b/tools/sdk/esp32/include/hal/esp32/include/hal/rtc_io_ll.h @@ -22,6 +22,7 @@ #include #include "soc/rtc_io_periph.h" +#include "soc/rtc_io_struct.h" #include "hal/rtc_io_types.h" #include "hal/gpio_types.h" diff --git a/tools/sdk/esp32/include/hal/esp32/include/hal/rwdt_ll.h b/tools/sdk/esp32/include/hal/esp32/include/hal/rwdt_ll.h index c1d2d60607a..e409eeaa8b1 100644 --- a/tools/sdk/esp32/include/hal/esp32/include/hal/rwdt_ll.h +++ b/tools/sdk/esp32/include/hal/esp32/include/hal/rwdt_ll.h @@ -25,6 +25,7 @@ extern "C" { #include #include "hal/wdt_types.h" #include "soc/rtc_cntl_periph.h" +#include "soc/rtc_cntl_struct.h" #include "esp_attr.h" //Type check wdt_stage_action_t diff --git a/tools/sdk/esp32/include/hal/esp32/include/hal/sigmadelta_ll.h b/tools/sdk/esp32/include/hal/esp32/include/hal/sigmadelta_ll.h index 929546fe0c2..9e151871d2e 100644 --- a/tools/sdk/esp32/include/hal/esp32/include/hal/sigmadelta_ll.h +++ b/tools/sdk/esp32/include/hal/esp32/include/hal/sigmadelta_ll.h @@ -22,7 +22,9 @@ #pragma once #include +#include "hal/misc.h" #include "soc/sigmadelta_periph.h" +#include "soc/gpio_sd_struct.h" #include "hal/sigmadelta_types.h" #ifdef __cplusplus @@ -53,7 +55,7 @@ static inline void sigmadelta_ll_set_en(gpio_sd_dev_t *hw, bool en) */ static inline void sigmadelta_ll_set_duty(gpio_sd_dev_t *hw, sigmadelta_channel_t channel, int8_t duty) { - hw->channel[channel].duty = duty; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->channel[channel], duty, (uint32_t)duty); } /** @@ -65,7 +67,7 @@ static inline void sigmadelta_ll_set_duty(gpio_sd_dev_t *hw, sigmadelta_channel_ */ static inline void sigmadelta_ll_set_prescale(gpio_sd_dev_t *hw, sigmadelta_channel_t channel, uint8_t prescale) { - hw->channel[channel].prescale = prescale; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->channel[channel], prescale, prescale); } #ifdef __cplusplus diff --git a/tools/sdk/esp32/include/hal/esp32/include/hal/spi_flash_ll.h b/tools/sdk/esp32/include/hal/esp32/include/hal/spi_flash_ll.h index 7c0862eddcc..3f18774a292 100644 --- a/tools/sdk/esp32/include/hal/esp32/include/hal/spi_flash_ll.h +++ b/tools/sdk/esp32/include/hal/esp32/include/hal/spi_flash_ll.h @@ -24,11 +24,13 @@ #include #include "soc/spi_periph.h" +#include "soc/spi_struct.h" #include "hal/spi_types.h" #include "hal/spi_flash_types.h" #include // For MIN/MAX #include #include +#include "hal/misc.h" #ifdef __cplusplus extern "C" { @@ -393,7 +395,7 @@ static inline void spi_flash_ll_set_address(spi_dev_t *dev, uint32_t addr) static inline void spi_flash_ll_set_dummy(spi_dev_t *dev, uint32_t dummy_n) { dev->user.usr_dummy = dummy_n ? 1 : 0; - dev->user1.usr_dummy_cyclelen = dummy_n - 1; + HAL_FORCE_MODIFY_U32_REG_FIELD(dev->user1, usr_dummy_cyclelen, dummy_n - 1); } static inline void spi_flash_ll_set_hold(spi_dev_t *dev, uint32_t hold_n) diff --git a/tools/sdk/esp32/include/hal/esp32/include/hal/spi_ll.h b/tools/sdk/esp32/include/hal/esp32/include/hal/spi_ll.h index 426d7208437..89b4dedae3d 100644 --- a/tools/sdk/esp32/include/hal/esp32/include/hal/spi_ll.h +++ b/tools/sdk/esp32/include/hal/esp32/include/hal/spi_ll.h @@ -27,7 +27,10 @@ #include "esp_types.h" #include "esp32/rom/lldesc.h" #include "soc/spi_periph.h" +#include "soc/spi_struct.h" #include "hal/misc.h" +#include "hal/spi_types.h" +#include "hal/assert.h" #ifdef __cplusplus extern "C" { @@ -37,6 +40,9 @@ extern "C" { #define SPI_LL_DMA_FIFO_RST_MASK (SPI_AHBM_RST | SPI_AHBM_FIFO_RST) /// Interrupt not used. Don't use in app. #define SPI_LL_UNUSED_INT_MASK (SPI_INT_EN | SPI_SLV_WR_STA_DONE | SPI_SLV_RD_STA_DONE | SPI_SLV_WR_BUF_DONE | SPI_SLV_RD_BUF_DONE) +/// These 2 masks together will set SPI transaction to one line mode +#define SPI_LL_ONE_LINE_CTRL_MASK (SPI_FREAD_DUAL | SPI_FREAD_QUAD | SPI_FREAD_DIO | SPI_FREAD_QIO) +#define SPI_LL_ONE_LINE_USER_MASK (SPI_FWRITE_DUAL | SPI_FWRITE_QUAD | SPI_FWRITE_DIO | SPI_FWRITE_QIO) /// Swap the bit order to its correct place to send #define HAL_SPI_SWAP_DATA_TX(data, len) HAL_SWAP32((uint32_t)(data) << (32 - len)) /// This is the expected clock frequency @@ -53,16 +59,6 @@ typedef uint32_t spi_ll_clock_val_t; //On ESP32-S2 and earlier chips, DMA registers are part of SPI registers. So set the registers of SPI peripheral to control DMA. typedef spi_dev_t spi_dma_dev_t; -/** IO modes supported by the master. */ -typedef enum { - SPI_LL_IO_MODE_NORMAL = 0, ///< 1-bit mode for all phases - SPI_LL_IO_MODE_DIO, ///< 2-bit mode for address and data phases, 1-bit mode for command phase - SPI_LL_IO_MODE_DUAL, ///< 2-bit mode for data phases only, 1-bit mode for command and address phases - SPI_LL_IO_MODE_QIO, ///< 4-bit mode for address and data phases, 1-bit mode for command phase - SPI_LL_IO_MODE_QUAD, ///< 4-bit mode for data phases only, 1-bit mode for command and address phases -} spi_ll_io_mode_t; - - /*------------------------------------------------------------------------------ * Control *----------------------------------------------------------------------------*/ @@ -449,37 +445,50 @@ static inline void spi_ll_set_sio_mode(spi_dev_t *hw, int sio_mode) } /** - * Configure the io mode for the master to work at. + * Configure the SPI transaction line mode for the master to use. * - * @param hw Beginning address of the peripheral registers. - * @param io_mode IO mode to work at, see ``spi_ll_io_mode_t``. + * @param hw Beginning address of the peripheral registers. + * @param line_mode SPI transaction line mode to use, see ``spi_line_mode_t``. */ -static inline void spi_ll_master_set_io_mode(spi_dev_t *hw, spi_ll_io_mode_t io_mode) +static inline void spi_ll_master_set_line_mode(spi_dev_t *hw, spi_line_mode_t line_mode) { - hw->ctrl.val &= ~(SPI_FREAD_DUAL | SPI_FREAD_QUAD | SPI_FREAD_DIO | SPI_FREAD_QIO); - hw->user.val &= ~(SPI_FWRITE_DUAL | SPI_FWRITE_QUAD | SPI_FWRITE_DIO | SPI_FWRITE_QIO); - switch (io_mode) { - case SPI_LL_IO_MODE_DIO: - hw->ctrl.fread_dio = 1; - hw->user.fwrite_dio = 1; - break; - case SPI_LL_IO_MODE_DUAL: - hw->ctrl.fread_dual = 1; - hw->user.fwrite_dual = 1; - break; - case SPI_LL_IO_MODE_QIO: - hw->ctrl.fread_qio = 1; - hw->user.fwrite_qio = 1; + hw->ctrl.val &= ~SPI_LL_ONE_LINE_CTRL_MASK; + hw->user.val &= ~SPI_LL_ONE_LINE_USER_MASK; + if (line_mode.cmd_lines > 1) { + HAL_ASSERT(false); + } + switch (line_mode.data_lines) { + case 2: + if (line_mode.addr_lines == 1) { + // 1-line-cmd + 1-line-addr + 2-line-data + hw->ctrl.fread_dual = 1; + hw->user.fwrite_dual = 1; + } else if (line_mode.addr_lines == 2) { + // 1-line-cmd + 2-line-addr + 2-line-data + hw->ctrl.fread_dio = 1; + hw->user.fwrite_dio = 1; + } else { + HAL_ASSERT(false); + } + hw->ctrl.fastrd_mode = 1; break; - case SPI_LL_IO_MODE_QUAD: - hw->ctrl.fread_quad = 1; - hw->user.fwrite_quad = 1; + case 4: + if (line_mode.addr_lines == 1) { + // 1-line-cmd + 1-line-addr + 4-line-data + hw->ctrl.fread_quad = 1; + hw->user.fwrite_quad = 1; + } else if (line_mode.addr_lines == 4) { + // 1-line-cmd + 4-line-addr + 4-line-data + hw->ctrl.fread_qio = 1; + hw->user.fwrite_qio = 1; + } else { + HAL_ASSERT(false); + } + hw->ctrl.fastrd_mode = 1; break; default: + // 1-line-cmd + 1-line-addr + 1-line-data break; - }; - if (io_mode != SPI_LL_IO_MODE_NORMAL) { - hw->ctrl.fastrd_mode = 1; } } @@ -502,7 +511,8 @@ static inline void spi_ll_master_select_cs(spi_dev_t *hw, int cs_id) * @param hw Beginning address of the peripheral registers. * @param keep_active if 0 don't keep CS activated, else keep CS activated */ -static inline void spi_ll_master_keep_cs(spi_dev_t *hw, int keep_active) { +static inline void spi_ll_master_keep_cs(spi_dev_t *hw, int keep_active) +{ hw->pin.cs_keep_active = (keep_active != 0) ? 1 : 0; } @@ -691,7 +701,7 @@ static inline void spi_ll_set_miso_delay(spi_dev_t *hw, int delay_mode, int dela static inline void spi_ll_set_dummy(spi_dev_t *hw, int dummy_n) { hw->user.usr_dummy = dummy_n ? 1 : 0; - hw->user1.usr_dummy_cyclelen = dummy_n - 1; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->user1, usr_dummy_cyclelen, dummy_n - 1); } /** @@ -849,13 +859,13 @@ static inline void spi_ll_set_command(spi_dev_t *hw, uint16_t cmd, int cmdlen, b { if (lsbfirst) { // The output command start from bit0 to bit 15, kept as is. - hw->user2.usr_command_value = cmd; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->user2, usr_command_value, cmd); } else { /* Output command will be sent from bit 7 to 0 of command_value, and * then bit 15 to 8 of the same register field. Shift and swap to send * more straightly. */ - hw->user2.usr_command_value = HAL_SPI_SWAP_DATA_TX(cmd, cmdlen); + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->user2, usr_command_value, HAL_SPI_SWAP_DATA_TX(cmd, cmdlen)); } } diff --git a/tools/sdk/esp32/include/hal/esp32/include/hal/timer_ll.h b/tools/sdk/esp32/include/hal/esp32/include/hal/timer_ll.h index f9efc82d22d..35ce7d10259 100644 --- a/tools/sdk/esp32/include/hal/esp32/include/hal/timer_ll.h +++ b/tools/sdk/esp32/include/hal/esp32/include/hal/timer_ll.h @@ -22,9 +22,11 @@ extern "C" { #endif #include +#include "hal/misc.h" #include "hal/assert.h" #include "hal/timer_types.h" #include "soc/timer_periph.h" +#include "soc/timer_group_struct.h" _Static_assert(TIMER_INTR_T0 == TIMG_T0_INT_CLR, "Add mapping to LL interrupt handling, since it's no longer naturally compatible with the timer_intr_t"); _Static_assert(TIMER_INTR_T1 == TIMG_T1_INT_CLR, "Add mapping to LL interrupt handling, since it's no longer naturally compatible with the timer_intr_t"); @@ -50,7 +52,7 @@ static inline void timer_ll_set_divider(timg_dev_t *hw, timer_idx_t timer_num, u } int timer_en = hw->hw_timer[timer_num].config.enable; hw->hw_timer[timer_num].config.enable = 0; - hw->hw_timer[timer_num].config.divider = divider; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->hw_timer[timer_num].config, divider, divider); hw->hw_timer[timer_num].config.enable = timer_en; } @@ -65,7 +67,7 @@ static inline void timer_ll_set_divider(timg_dev_t *hw, timer_idx_t timer_num, u */ static inline void timer_ll_get_divider(timg_dev_t *hw, timer_idx_t timer_num, uint32_t *divider) { - uint32_t d = hw->hw_timer[timer_num].config.divider; + uint32_t d = HAL_FORCE_READ_U32_REG_FIELD(hw->hw_timer[timer_num].config, divider); if (d == 0) { d = 65536; } else if (d == 1) { diff --git a/tools/sdk/esp32/include/hal/esp32/include/hal/touch_sensor_ll.h b/tools/sdk/esp32/include/hal/esp32/include/hal/touch_sensor_ll.h index 5642d28cc21..07f17d4b654 100644 --- a/tools/sdk/esp32/include/hal/esp32/include/hal/touch_sensor_ll.h +++ b/tools/sdk/esp32/include/hal/esp32/include/hal/touch_sensor_ll.h @@ -24,7 +24,11 @@ #include #include +#include "hal/misc.h" #include "soc/touch_sensor_periph.h" +#include "soc/sens_struct.h" +#include "soc/rtc_io_struct.h" +#include "soc/rtc_cntl_struct.h" #include "hal/touch_sensor_types.h" @@ -60,9 +64,9 @@ static inline touch_pad_t touch_ll_num_wrap(touch_pad_t touch_num) static inline void touch_ll_set_meas_time(uint16_t meas_time) { //touch sensor measure time= meas_cycle / 8Mhz - SENS.sar_touch_ctrl1.touch_meas_delay = meas_time; + HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.sar_touch_ctrl1, touch_meas_delay, meas_time); //the waiting cycles (in 8MHz) between TOUCH_START and TOUCH_XPD - SENS.sar_touch_ctrl1.touch_xpd_wait = SOC_TOUCH_PAD_MEASURE_WAIT_MAX; + HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.sar_touch_ctrl1, touch_xpd_wait, SOC_TOUCH_PAD_MEASURE_WAIT_MAX); } /** @@ -72,7 +76,7 @@ static inline void touch_ll_set_meas_time(uint16_t meas_time) */ static inline void touch_ll_get_meas_time(uint16_t *meas_time) { - *meas_time = SENS.sar_touch_ctrl1.touch_meas_delay; + *meas_time = HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_touch_ctrl1, touch_meas_delay); } /** @@ -86,7 +90,7 @@ static inline void touch_ll_get_meas_time(uint16_t *meas_time) static inline void touch_ll_set_sleep_time(uint16_t sleep_time) { //touch sensor sleep cycle Time = sleep_cycle / RTC_SLOW_CLK( can be 150k or 32k depending on the options) - SENS.sar_touch_ctrl2.touch_sleep_cycles = sleep_time; + HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.sar_touch_ctrl2, touch_sleep_cycles, sleep_time); } /** @@ -96,7 +100,7 @@ static inline void touch_ll_set_sleep_time(uint16_t sleep_time) */ static inline void touch_ll_get_sleep_time(uint16_t *sleep_time) { - *sleep_time = SENS.sar_touch_ctrl2.touch_sleep_cycles; + *sleep_time = HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_touch_ctrl2, touch_sleep_cycles); } /** @@ -291,9 +295,9 @@ static inline void touch_ll_set_threshold(touch_pad_t touch_num, uint16_t thresh { touch_pad_t tp_wrap = touch_ll_num_wrap(touch_num); if (tp_wrap & 0x1) { - SENS.touch_thresh[tp_wrap / 2].l_thresh = threshold; + HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.touch_thresh[tp_wrap / 2], l_thresh, threshold); } else { - SENS.touch_thresh[tp_wrap / 2].h_thresh = threshold; + HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.touch_thresh[tp_wrap / 2], h_thresh, threshold); } } @@ -308,8 +312,8 @@ static inline void touch_ll_get_threshold(touch_pad_t touch_num, uint16_t *thres touch_pad_t tp_wrap = touch_ll_num_wrap(touch_num); if (threshold) { *threshold = (tp_wrap & 0x1 ) ? - SENS.touch_thresh[tp_wrap / 2].l_thresh : - SENS.touch_thresh[tp_wrap / 2].h_thresh; + HAL_FORCE_READ_U32_REG_FIELD(SENS.touch_thresh[tp_wrap / 2], l_thresh) : + HAL_FORCE_READ_U32_REG_FIELD(SENS.touch_thresh[tp_wrap / 2], h_thresh); } } @@ -489,7 +493,8 @@ static inline void touch_ll_intr_clear(void) static inline uint32_t touch_ll_read_raw_data(touch_pad_t touch_num) { touch_pad_t tp_wrap = touch_ll_num_wrap(touch_num); - return ((tp_wrap & 0x1) ? SENS.touch_meas[tp_wrap / 2].l_val : SENS.touch_meas[tp_wrap / 2].h_val); + return ((tp_wrap & 0x1) ? HAL_FORCE_READ_U32_REG_FIELD(SENS.touch_meas[tp_wrap / 2], l_val) : + HAL_FORCE_READ_U32_REG_FIELD(SENS.touch_meas[tp_wrap / 2], h_val)); } /** diff --git a/tools/sdk/esp32/include/hal/esp32/include/hal/twai_ll.h b/tools/sdk/esp32/include/hal/esp32/include/hal/twai_ll.h index 0a37c616314..72949aa9cf9 100644 --- a/tools/sdk/esp32/include/hal/esp32/include/hal/twai_ll.h +++ b/tools/sdk/esp32/include/hal/esp32/include/hal/twai_ll.h @@ -32,6 +32,7 @@ extern "C" { #include "hal/misc.h" #include "hal/twai_types.h" #include "soc/twai_periph.h" +#include "soc/twai_struct.h" /* ------------------------- Defines and Typedefs --------------------------- */ @@ -491,7 +492,7 @@ static inline void twai_ll_parse_err_code_cap(twai_dev_t *hw, */ static inline void twai_ll_set_err_warn_lim(twai_dev_t *hw, uint32_t ewl) { - hw->error_warning_limit_reg.ewl = ewl; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->error_warning_limit_reg, ewl, ewl); } /** @@ -531,7 +532,7 @@ static inline uint32_t twai_ll_get_rec(twai_dev_t *hw) */ static inline void twai_ll_set_rec(twai_dev_t *hw, uint32_t rec) { - hw->rx_error_counter_reg.rxerr = rec; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->rx_error_counter_reg, rxerr, rec); } /* ------------------------ TX Error Count Register ------------------------- */ @@ -559,7 +560,7 @@ static inline uint32_t twai_ll_get_tec(twai_dev_t *hw) */ static inline void twai_ll_set_tec(twai_dev_t *hw, uint32_t tec) { - hw->tx_error_counter_reg.txerr = tec; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->tx_error_counter_reg, txerr, tec); } /* ---------------------- Acceptance Filter Registers ----------------------- */ @@ -578,8 +579,8 @@ static inline void twai_ll_set_acc_filter(twai_dev_t* hw, uint32_t code, uint32_ uint32_t code_swapped = HAL_SWAP32(code); uint32_t mask_swapped = HAL_SWAP32(mask); for (int i = 0; i < 4; i++) { - hw->acceptance_filter.acr[i].byte = ((code_swapped >> (i * 8)) & 0xFF); - hw->acceptance_filter.amr[i].byte = ((mask_swapped >> (i * 8)) & 0xFF); + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->acceptance_filter.acr[i], byte, ((code_swapped >> (i * 8)) & 0xFF)); + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->acceptance_filter.amr[i], byte, ((mask_swapped >> (i * 8)) & 0xFF)); } hw->mode_reg.afm = single_filter; } @@ -614,7 +615,7 @@ static inline void twai_ll_get_rx_buffer(twai_dev_t *hw, twai_ll_frame_buffer_t { //Copy RX buffer registers into frame for (int i = 0; i < 13; i++) { - rx_frame->bytes[i] = hw->tx_rx_buffer[i].byte; + rx_frame->bytes[i] = HAL_FORCE_READ_U32_REG_FIELD(hw->tx_rx_buffer[i], byte); } } @@ -794,8 +795,8 @@ static inline void twai_ll_save_reg(twai_dev_t *hw, twai_ll_reg_save_t *reg_save reg_save->bus_timing_1_reg = (uint8_t) hw->bus_timing_1_reg.val; reg_save->error_warning_limit_reg = (uint8_t) hw->error_warning_limit_reg.val; for (int i = 0; i < 4; i++) { - reg_save->acr_reg[i] = hw->acceptance_filter.acr[i].byte; - reg_save->amr_reg[i] = hw->acceptance_filter.amr[i].byte; + reg_save->acr_reg[i] = HAL_FORCE_READ_U32_REG_FIELD(hw->acceptance_filter.acr[i], byte); + reg_save->amr_reg[i] = HAL_FORCE_READ_U32_REG_FIELD(hw->acceptance_filter.amr[i], byte); } reg_save->rx_error_counter_reg = (uint8_t) hw->rx_error_counter_reg.val; reg_save->tx_error_counter_reg = (uint8_t) hw->tx_error_counter_reg.val; @@ -821,8 +822,8 @@ static inline void twai_ll_restore_reg(twai_dev_t *hw, twai_ll_reg_save_t *reg_s hw->bus_timing_1_reg.val = reg_save->bus_timing_1_reg; hw->error_warning_limit_reg.val = reg_save->error_warning_limit_reg; for (int i = 0; i < 4; i++) { - hw->acceptance_filter.acr[i].byte = reg_save->acr_reg[i]; - hw->acceptance_filter.amr[i].byte = reg_save->amr_reg[i]; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->acceptance_filter.acr[i], byte, reg_save->acr_reg[i]); + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->acceptance_filter.amr[i], byte, reg_save->amr_reg[i]); } hw->rx_error_counter_reg.val = reg_save->rx_error_counter_reg; hw->tx_error_counter_reg.val = reg_save->tx_error_counter_reg; diff --git a/tools/sdk/esp32/include/hal/esp32/include/hal/uart_ll.h b/tools/sdk/esp32/include/hal/esp32/include/hal/uart_ll.h index 324ad417fda..de8fc640ffc 100644 --- a/tools/sdk/esp32/include/hal/esp32/include/hal/uart_ll.h +++ b/tools/sdk/esp32/include/hal/esp32/include/hal/uart_ll.h @@ -17,8 +17,11 @@ #pragma once + +#include "hal/misc.h" #include "esp_attr.h" #include "soc/uart_periph.h" +#include "soc/uart_struct.h" #include "hal/uart_types.h" #ifdef __cplusplus @@ -249,7 +252,7 @@ FORCE_INLINE_ATTR void uart_ll_rxfifo_rst(uart_dev_t *hw) //Get the UART APB fifo addr uint32_t fifo_addr = (hw == &UART0) ? UART_FIFO_REG(0) : (hw == &UART1) ? UART_FIFO_REG(1) : UART_FIFO_REG(2); do { - fifo_cnt = hw->status.rxfifo_cnt; + fifo_cnt = HAL_FORCE_READ_U32_REG_FIELD(hw->status, rxfifo_cnt); rxmem_sta.val = hw->mem_rx_status.val; if(fifo_cnt != 0 || (rxmem_sta.rd_addr != rxmem_sta.wr_addr)) { READ_PERI_REG(fifo_addr); @@ -287,7 +290,7 @@ FORCE_INLINE_ATTR void uart_ll_txfifo_rst(uart_dev_t *hw) */ FORCE_INLINE_ATTR uint32_t uart_ll_get_rxfifo_len(uart_dev_t *hw) { - uint32_t fifo_cnt = hw->status.rxfifo_cnt; + uint32_t fifo_cnt = HAL_FORCE_READ_U32_REG_FIELD(hw->status, rxfifo_cnt); typeof(hw->mem_rx_status) rx_status = hw->mem_rx_status; uint32_t len = 0; @@ -313,7 +316,7 @@ FORCE_INLINE_ATTR uint32_t uart_ll_get_rxfifo_len(uart_dev_t *hw) */ FORCE_INLINE_ATTR uint32_t uart_ll_get_txfifo_len(uart_dev_t *hw) { - return UART_LL_FIFO_DEF_LEN - hw->status.txfifo_cnt; + return UART_LL_FIFO_DEF_LEN - HAL_FORCE_READ_U32_REG_FIELD(hw->status, txfifo_cnt); } /** @@ -453,7 +456,7 @@ FORCE_INLINE_ATTR void uart_ll_set_tx_idle_num(uart_dev_t *hw, uint32_t idle_num FORCE_INLINE_ATTR void uart_ll_tx_break(uart_dev_t *hw, uint32_t break_num) { if(break_num > 0) { - hw->idle_conf.tx_brk_num = break_num; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->idle_conf, tx_brk_num, break_num); hw->conf0.txd_brk = 1; } else { hw->conf0.txd_brk = 0; @@ -518,10 +521,10 @@ FORCE_INLINE_ATTR void uart_ll_set_sw_flow_ctrl(uart_dev_t *hw, uart_sw_flowctrl if(sw_flow_ctrl_en) { hw->flow_conf.xonoff_del = 1; hw->flow_conf.sw_flow_con_en = 1; - hw->swfc_conf.xon_threshold = flow_ctrl->xon_thrd; - hw->swfc_conf.xoff_threshold = flow_ctrl->xoff_thrd; - hw->swfc_conf.xon_char = flow_ctrl->xon_char; - hw->swfc_conf.xoff_char = flow_ctrl->xoff_char; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->swfc_conf, xon_threshold, flow_ctrl->xon_thrd); + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->swfc_conf, xoff_threshold, flow_ctrl->xoff_thrd); + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->swfc_conf, xon_char, flow_ctrl->xon_char); + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->swfc_conf, xoff_char, flow_ctrl->xoff_char); } else { hw->flow_conf.sw_flow_con_en = 0; hw->flow_conf.xonoff_del = 0; @@ -543,8 +546,8 @@ FORCE_INLINE_ATTR void uart_ll_set_sw_flow_ctrl(uart_dev_t *hw, uart_sw_flowctrl */ FORCE_INLINE_ATTR void uart_ll_set_at_cmd_char(uart_dev_t *hw, uart_at_cmd_t *cmd_char) { - hw->at_cmd_char.data = cmd_char->cmd_char; - hw->at_cmd_char.char_num = cmd_char->char_num; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->at_cmd_char, data, cmd_char->cmd_char); + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->at_cmd_char, char_num, cmd_char->char_num); hw->at_cmd_postcnt.post_idle_num = cmd_char->post_idle; hw->at_cmd_precnt.pre_idle_num = cmd_char->pre_idle; hw->at_cmd_gaptout.rx_gap_tout = cmd_char->gap_tout; @@ -729,8 +732,8 @@ FORCE_INLINE_ATTR void uart_ll_set_mode(uart_dev_t *hw, uart_mode_t mode) */ FORCE_INLINE_ATTR void uart_ll_get_at_cmd_char(uart_dev_t *hw, uint8_t *cmd_char, uint8_t *char_num) { - *cmd_char = hw->at_cmd_char.data; - *char_num = hw->at_cmd_char.char_num; + *cmd_char = HAL_FORCE_READ_U32_REG_FIELD(hw->at_cmd_char, data); + *char_num = HAL_FORCE_READ_U32_REG_FIELD(hw->at_cmd_char, char_num); } /** @@ -895,6 +898,67 @@ FORCE_INLINE_ATTR uint16_t uart_ll_max_tout_thrd(uart_dev_t *hw) return tout_thrd; } +/** + * @brief Configure the auto baudrate. + * + * @param hw Beginning address of the peripheral registers. + * @param enable Boolean marking whether the auto baudrate should be enabled or not. + */ +FORCE_INLINE_ATTR void uart_ll_set_autobaud_en(uart_dev_t *hw, bool enable) +{ + hw->auto_baud.en = enable ? 1 : 0; +} + +/** + * @brief Get the RXD edge count. + * + * @param hw Beginning address of the peripheral registers. + */ +FORCE_INLINE_ATTR uint32_t uart_ll_get_rxd_edge_cnt(uart_dev_t *hw) +{ + return hw->rxd_cnt.edge_cnt; +} + +/** + * @brief Get the positive pulse minimum count. + * + * @param hw Beginning address of the peripheral registers. + */ +FORCE_INLINE_ATTR uint32_t uart_ll_get_pos_pulse_cnt(uart_dev_t *hw) +{ + return hw->pospulse.min_cnt; +} + +/** + * @brief Get the negative pulse minimum count. + * + * @param hw Beginning address of the peripheral registers. + */ +FORCE_INLINE_ATTR uint32_t uart_ll_get_neg_pulse_cnt(uart_dev_t *hw) +{ + return hw->negpulse.min_cnt; +} + +/** + * @brief Get the high pulse minimum count. + * + * @param hw Beginning address of the peripheral registers. + */ +FORCE_INLINE_ATTR uint32_t uart_ll_get_high_pulse_cnt(uart_dev_t *hw) +{ + return hw->highpulse.min_cnt; +} + +/** + * @brief Get the low pulse minimum count. + * + * @param hw Beginning address of the peripheral registers. + */ +FORCE_INLINE_ATTR uint32_t uart_ll_get_low_pulse_cnt(uart_dev_t *hw) +{ + return hw->lowpulse.min_cnt; +} + /** * @brief Force UART xoff. * diff --git a/tools/sdk/esp32/include/hal/include/hal/adc_hal.h b/tools/sdk/esp32/include/hal/include/hal/adc_hal.h index 1c1a399a4d3..807d620c639 100644 --- a/tools/sdk/esp32/include/hal/include/hal/adc_hal.h +++ b/tools/sdk/esp32/include/hal/include/hal/adc_hal.h @@ -114,6 +114,22 @@ void adc_hal_init(void); #define adc_hal_amp_disable() adc_ll_amp_disable() #endif +#if SOC_ADC_ARBITER_SUPPORTED +//No ADC2 controller arbiter on ESP32 +/** + * Config ADC2 module arbiter. + * The arbiter is to improve the use efficiency of ADC2. After the control right is robbed by the high priority, + * the low priority controller will read the invalid ADC2 data, and the validity of the data can be judged by the flag bit in the data. + * + * @note Only ADC2 support arbiter. + * @note The arbiter's working clock is APB_CLK. When the APB_CLK clock drops below 8 MHz, the arbiter must be in shield mode. + * @note Default priority: Wi-Fi > RTC > Digital; + * + * @param config Refer to ``adc_arbiter_t``. + */ +void adc_hal_arbiter_config(adc_arbiter_t *config); +#endif //#if SOC_ADC_ARBITER_SUPPORTED + /*--------------------------------------------------------------- PWDET(Power detect) controller setting ---------------------------------------------------------------*/ @@ -260,7 +276,7 @@ esp_err_t adc_hal_convert(adc_ll_num_t adc_n, int channel, int *out_raw); /*--------------------------------------------------------------- ADC calibration setting ---------------------------------------------------------------*/ -#if SOC_ADC_HW_CALIBRATION_V1 +#if SOC_ADC_CALIBRATION_V1_SUPPORTED // ESP32-S2, C3 and H2 support HW offset calibration. /** @@ -296,7 +312,7 @@ void adc_hal_set_calibration_param(adc_ll_num_t adc_n, uint32_t param); */ uint32_t adc_hal_self_calibration(adc_ll_num_t adc_n, adc_channel_t channel, adc_atten_t atten, bool internal_gnd); -#endif //SOC_ADC_HW_CALIBRATION_V1 +#endif //SOC_ADC_CALIBRATION_V1_SUPPORTED #if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32H2 /*--------------------------------------------------------------- diff --git a/tools/sdk/esp32/include/hal/include/hal/ds_hal.h b/tools/sdk/esp32/include/hal/include/hal/ds_hal.h index 253fab9f962..40d5c358936 100644 --- a/tools/sdk/esp32/include/hal/include/hal/ds_hal.h +++ b/tools/sdk/esp32/include/hal/include/hal/ds_hal.h @@ -21,7 +21,7 @@ #pragma once #if CONFIG_IDF_TARGET_ESP32 - #error "ESP32 doesn't have a DS peripheral" +#error "ESP32 doesn't have a DS peripheral" #endif #include diff --git a/tools/sdk/esp32/include/hal/include/hal/i2s_hal.h b/tools/sdk/esp32/include/hal/include/hal/i2s_hal.h index 6964bfdf947..a08813db808 100644 --- a/tools/sdk/esp32/include/hal/include/hal/i2s_hal.h +++ b/tools/sdk/esp32/include/hal/include/hal/i2s_hal.h @@ -1,4 +1,4 @@ -// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD +// Copyright 2020 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. @@ -25,13 +25,47 @@ #include "soc/i2s_periph.h" #include "soc/soc_caps.h" -#include "hal/i2s_ll.h" #include "hal/i2s_types.h" +#include "hal/i2s_ll.h" #ifdef __cplusplus extern "C" { #endif +/** + * @brief I2S clock configuration + */ +typedef struct { + uint32_t sclk; /*!< I2S module clock */ + uint32_t mclk; /*!< I2S master clock */ + uint32_t bclk; /*!< I2S bit clock */ + uint16_t mclk_div; /*!< I2S master clock division */ + uint16_t bclk_div; /*!< I2S bit clock division*/ +} i2s_hal_clock_cfg_t; + + +/** + * @brief I2S HAL configurations + */ +typedef struct { + i2s_mode_t mode; /*!< I2S work mode, using ored mask of `i2s_mode_t`*/ + uint32_t sample_rate; /*!< I2S sample rate*/ + i2s_comm_format_t comm_fmt; /*!< I2S communication format */ + i2s_channel_fmt_t chan_fmt; /*!< I2S channel format, there are total 16 channels in TDM mode.*/ + uint32_t sample_bits; /*!< I2S sample bits in one channel */ + uint32_t chan_bits; /*!< I2S total bits in one channel. Should not be smaller than 'sample_bits', default '0' means equal to 'sample_bits' */ + uint32_t active_chan; /*!< I2S active channel number */ + uint32_t total_chan; /*!< Total number of I2S channels */ + +#if SOC_I2S_SUPPORTS_TDM + uint32_t chan_mask; /*!< Active channel bit mask, set value in `i2s_channel_t` to enable specific channel, the bit map of active channel can not exceed (0x1<dev, status) +#define i2s_hal_enable_module_clock(hal) i2s_ll_enable_clock((hal)->dev); /** - * @brief Clear I2S interrupt status + * @brief Disable I2S module clock * * @param hal Context of the HAL layer - * @param mask interrupt status mask */ -#define i2s_hal_clear_intr_status(hal, mask) i2s_ll_clear_intr_status((hal)->dev, mask) +#define i2s_hal_disable_module_clock(hal) i2s_ll_disable_clock((hal)->dev); /** - * @brief Get I2S out eof des address + * @brief Reset I2S TX channel * * @param hal Context of the HAL layer - * @param addr out eof des address */ -#define i2s_hal_get_out_eof_des_addr(hal, addr) i2s_ll_get_out_eof_des_addr((hal)->dev, addr) +#define i2s_hal_reset_tx(hal) i2s_ll_tx_reset((hal)->dev) /** - * @brief Get I2S in eof des address + * @brief Reset I2S TX fifo * * @param hal Context of the HAL layer - * @param addr in eof des address */ -#define i2s_hal_get_in_eof_des_addr(hal, addr) i2s_ll_get_in_eof_des_addr((hal)->dev, addr) +#define i2s_hal_reset_tx_fifo(hal) i2s_ll_tx_reset_fifo((hal)->dev) /** - * @brief Enable I2S rx interrupt + * @brief Reset I2S RX channel * * @param hal Context of the HAL layer */ -#define i2s_hal_enable_rx_intr(hal) i2s_ll_enable_rx_intr((hal)->dev) +#define i2s_hal_reset_rx(hal) i2s_ll_rx_reset((hal)->dev) /** - * @brief Disable I2S rx interrupt + * @brief Reset I2S RX fifo * * @param hal Context of the HAL layer */ -#define i2s_hal_disable_rx_intr(hal) i2s_ll_disable_rx_intr((hal)->dev) +#define i2s_hal_reset_rx_fifo(hal) i2s_ll_rx_reset_fifo((hal)->dev) /** - * @brief Disable I2S tx interrupt + * @brief Get I2S hardware instance and enable I2S module clock + * @note This function should be called first before other hal layer function is called * * @param hal Context of the HAL layer + * @param i2s_num The uart port number, the max port number is (I2S_NUM_MAX -1) */ -#define i2s_hal_disable_tx_intr(hal) i2s_ll_disable_tx_intr((hal)->dev) +void i2s_hal_init(i2s_hal_context_t *hal, int i2s_num); /** - * @brief Enable I2S tx interrupt + * @brief Configure I2S source clock * * @param hal Context of the HAL layer + * @param sel The source clock index */ -#define i2s_hal_enable_tx_intr(hal) i2s_ll_enable_tx_intr((hal)->dev) +void i2s_hal_set_clock_src(i2s_hal_context_t *hal, i2s_clock_src_t sel); /** - * @brief Set I2S tx mode + * @brief Set Tx channel style * * @param hal Context of the HAL layer - * @param ch i2s channel - * @param bits bits per sample + * @param hal_cfg I2S hal configuration structer, refer to `i2s_hal_config_t` */ -void i2s_hal_set_tx_mode(i2s_hal_context_t *hal, i2s_channel_t ch, i2s_bits_per_sample_t bits); +void i2s_hal_tx_set_channel_style(i2s_hal_context_t *hal, const i2s_hal_config_t *hal_cfg); /** - * @brief Set I2S rx mode + * @brief Set Rx channel style * * @param hal Context of the HAL layer - * @param ch i2s channel - * @param bits bits per sample + * @param hal_cfg I2S hal configuration structer, refer to `i2s_hal_config_t` */ -void i2s_hal_set_rx_mode(i2s_hal_context_t *hal, i2s_channel_t ch, i2s_bits_per_sample_t bits); +void i2s_hal_rx_set_channel_style(i2s_hal_context_t *hal, const i2s_hal_config_t *hal_cfg); /** - * @brief Set I2S out link address + * @brief Initialize I2S hardware * * @param hal Context of the HAL layer - * @param addr out link address + * @param hal_cfg I2S hal configuration structer, refer to `i2s_hal_config_t` */ -#define i2s_hal_set_out_link_addr(hal, addr) i2s_ll_set_out_link_addr((hal)->dev, addr) +void i2s_hal_config_param(i2s_hal_context_t *hal, const i2s_hal_config_t *hal_cfg); /** - * @brief Set I2S out link address + * @brief Enable I2S master full-duplex mode * * @param hal Context of the HAL layer - * @param addr out link address */ -#define i2s_hal_set_out_link_addr(hal, addr) i2s_ll_set_out_link_addr((hal)->dev, addr) +void i2s_hal_enable_master_fd_mode(i2s_hal_context_t *hal); /** - * @brief Set I2S out link address + * @brief Enable I2S slave full-duplex mode * * @param hal Context of the HAL layer - * @param addr out link address */ -#define i2s_hal_set_out_link_addr(hal, addr) i2s_ll_set_out_link_addr((hal)->dev, addr) +void i2s_hal_enable_slave_fd_mode(i2s_hal_context_t *hal); /** - * @brief Set I2S in link + * @brief Start I2S tx * * @param hal Context of the HAL layer - * @param rx_eof_num in link eof num - * @param addr in link address */ -void i2s_hal_set_in_link(i2s_hal_context_t *hal, uint32_t rx_eof_num, uint32_t addr); +#define i2s_hal_start_tx(hal) i2s_ll_tx_start((hal)->dev) /** - * @brief Set I2S clk div + * @brief Start I2S rx * * @param hal Context of the HAL layer - * @param div_num i2s clkm div num - * @param div_a i2s clkm div a - * @param div_b i2s clkm div b - * @param tx_bck_div tx bck div num - * @param rx_bck_div rx bck div num */ -void i2s_hal_set_clk_div(i2s_hal_context_t *hal, int div_num, int div_a, int div_b, int tx_bck_div, int rx_bck_div); +#define i2s_hal_start_rx(hal) i2s_ll_rx_start((hal)->dev) /** - * @brief Set I2S clock sel + * @brief Stop I2S tx * * @param hal Context of the HAL layer - * @param sel clock sel */ -#define i2s_hal_set_clock_sel(hal, sel) i2s_ll_set_clk_sel((hal)->dev, sel) +#define i2s_hal_stop_tx(hal) i2s_ll_tx_stop((hal)->dev) /** - * @brief Set I2S tx bits mod + * @brief Stop I2S rx * * @param hal Context of the HAL layer - * @param bits bit width per sample. */ -void i2s_hal_set_tx_bits_mod(i2s_hal_context_t *hal, i2s_bits_per_sample_t bits); +#define i2s_hal_stop_rx(hal) i2s_ll_rx_stop((hal)->dev) /** - * @brief Set I2S rx bits mod + * @brief Set the received data length to trigger `in_suc_eof` interrupt. * * @param hal Context of the HAL layer - * @param bits bit width per sample. + * @param eof_byte The byte length that trigger in_suc_eof interrupt. */ -void i2s_hal_set_rx_bits_mod(i2s_hal_context_t *hal, i2s_bits_per_sample_t bits); +#define i2s_hal_set_rx_eof_num(hal, eof_byte) i2s_ll_rx_set_eof_num((hal)->dev, eof_byte) /** - * @brief Reset I2S TX & RX module, including DMA and FIFO + * @brief Set I2S TX sample bit * * @param hal Context of the HAL layer + * @param chan_bit I2S TX chan bit + * @param data_bit The sample data bit length. */ -void i2s_hal_reset(i2s_hal_context_t *hal); +#define i2s_hal_set_tx_sample_bit(hal, chan_bit, data_bit) i2s_ll_tx_set_sample_bit((hal)->dev, chan_bit, data_bit) /** - * @brief Start I2S tx + * @brief Set I2S RX sample bit * * @param hal Context of the HAL layer + * @param chan_bit I2S RX chan bit + * @param data_bit The sample data bit length. */ -void i2s_hal_start_tx(i2s_hal_context_t *hal); +#define i2s_hal_set_rx_sample_bit(hal, chan_bit, data_bit) i2s_ll_rx_set_sample_bit((hal)->dev, chan_bit, data_bit) /** - * @brief Start I2S rx + * @brief Configure I2S TX module clock devider * * @param hal Context of the HAL layer + * @param clk_cfg I2S clock configuration */ -void i2s_hal_start_rx(i2s_hal_context_t *hal); +void i2s_hal_tx_clock_config(i2s_hal_context_t *hal, i2s_hal_clock_cfg_t *clk_cfg); /** - * @brief Stop I2S tx + * @brief Configure I2S RX module clock devider * * @param hal Context of the HAL layer + * @param clk_cfg I2S clock configuration */ -void i2s_hal_stop_tx(i2s_hal_context_t *hal); +void i2s_hal_rx_clock_config(i2s_hal_context_t *hal, i2s_hal_clock_cfg_t *clk_cfg); /** - * @brief Stop I2S rx + * @brief Set I2S tx clock source * * @param hal Context of the HAL layer + * @param clk_src i2s tx clock source (see 'i2s_clock_src_t') */ -void i2s_hal_stop_rx(i2s_hal_context_t *hal); +#define i2s_hal_tx_set_clock_source(hal, clk_src) i2s_ll_tx_clk_set_src((hal)->dev, clk_src) /** - * @brief Config I2S param + * @brief Set I2S rx clock source * * @param hal Context of the HAL layer - * @param i2s_config I2S configurations - see i2s_config_t struct + * @param clk_src i2s rx clock source (see 'i2s_clock_src_t') */ -void i2s_hal_config_param(i2s_hal_context_t *hal, const i2s_config_t *i2s_config); +#define i2s_hal_rx_set_clock_source(hal, clk_src) i2s_ll_rx_clk_set_src((hal)->dev, clk_src) /** - * @brief Enable I2S sig loopback + * @brief Enable I2S tx slave mode * * @param hal Context of the HAL layer + * @param enable set 'true' to enable tx slave mode */ -#define i2s_hal_enable_sig_loopback(hal) i2s_ll_set_sig_loopback((hal)->dev, 1) +#define i2s_hal_tx_enable_slave_mode(hal, enable) i2s_ll_tx_set_slave_mod((hal)->dev, enable) /** - * @brief Enable I2S master mode + * @brief Enable I2S rx slave mode * * @param hal Context of the HAL layer + * @param enable set 'true' to enable rx slave mode */ -void i2s_hal_enable_master_mode(i2s_hal_context_t *hal); +#define i2s_hal_rx_enable_slave_mode(hal, enable) i2s_ll_rx_set_slave_mod((hal)->dev, enable) /** - * @brief Enable I2S slave mode + * @brief Enable loopback mode * * @param hal Context of the HAL layer */ -void i2s_hal_enable_slave_mode(i2s_hal_context_t *hal); +#define i2s_hal_enable_sig_loopback(hal) i2s_ll_share_bck_ws((hal)->dev, true) /** - * @brief Init the I2S hal and set the I2S to the default configuration. This function should be called first before other hal layer function is called + * @brief Set I2S configuration for common TX mode + * @note Common mode is for non-PDM mode like philip/MSB/PCM * * @param hal Context of the HAL layer - * @param i2s_num The uart port number, the max port number is (I2S_NUM_MAX -1) + * @param hal_cfg hal configuration structure */ -void i2s_hal_init(i2s_hal_context_t *hal, int i2s_num); +void i2s_hal_tx_set_common_mode(i2s_hal_context_t *hal, const i2s_hal_config_t *hal_cfg); + +/** + * @brief Set I2S configuration for common RX mode + * @note Common mode is for non-PDM mode like philip/MSB/PCM + * + * @param hal Context of the HAL layer + * @param hal_cfg hal configuration structure + */ +void i2s_hal_rx_set_common_mode(i2s_hal_context_t *hal, const i2s_hal_config_t *hal_cfg); + +#if SOC_I2S_SUPPORTS_PCM +/** + * @brief Configure I2S TX PCM encoder or decoder. + * + * @param hal Context of the HAL layer + * @param cfg PCM configure paramater, refer to `i2s_pcm_compress_t` + */ +#define i2s_hal_tx_pcm_cfg(hal, cfg) i2s_ll_tx_set_pcm_type((hal)->dev, cfg) + +/** + * @brief Configure I2S RX PCM encoder or decoder. + * + * @param hal Context of the HAL layer + * @param cfg PCM configure paramater, refer to `i2s_pcm_compress_t` + */ +#define i2s_hal_rx_pcm_cfg(hal, cfg) i2s_ll_rx_set_pcm_type((hal)->dev, cfg) +#endif + +#if SOC_I2S_SUPPORTS_PDM_TX +/** + * @brief Configure I2S TX PDM sample rate + * Fpdm = 64*Fpcm*fp/fs + * + * @param hal Context of the HAL layer + * @param fp TX PDM fp paramater configuration + * @param fs TX PDM fs paramater configuration + */ +#define i2s_hal_set_tx_pdm_fpfs(hal, fp, fs) i2s_ll_tx_set_pdm_fpfs((hal)->dev, fp, fs) + +/** + * @brief Get I2S TX PDM fp + * + * @param hal Context of the HAL layer + * @return + * - fp configuration paramater + */ +#define i2s_hal_get_tx_pdm_fp(hal) i2s_ll_tx_get_pdm_fp((hal)->dev) + +/** + * @brief Get I2S TX PDM fs + * + * @param hal Context of the HAL layer + * @return + * - fs configuration paramater + */ +#define i2s_hal_get_tx_pdm_fs(hal) i2s_ll_tx_get_pdm_fs((hal)->dev) + +/** + * @brief Set I2S default configuration for PDM TX mode + * + * @param hal Context of the HAL layer + * @param sample_rate PDM sample rate + */ +void i2s_hal_tx_set_pdm_mode_default(i2s_hal_context_t *hal, uint32_t sample_rate); +#endif + +#if SOC_I2S_SUPPORTS_PDM_RX + +/** + * @brief Configure RX PDM downsample + * + * @param hal Context of the HAL layer + * @param dsr PDM downsample configuration paramater + */ +#define i2s_hal_set_rx_pdm_dsr(hal, dsr) i2s_ll_rx_set_pdm_dsr((hal)->dev, dsr) + +/** + * @brief Get RX PDM downsample configuration + * + * @param hal Context of the HAL layer + * @param dsr Pointer to accept PDM downsample configuration + */ +#define i2s_hal_get_rx_pdm_dsr(hal, dsr) i2s_ll_rx_get_pdm_dsr((hal)->dev, dsr) + +/** + * @brief Set I2S default configuration for PDM R mode + * + * @param hal Context of the HAL layer + */ +void i2s_hal_rx_set_pdm_mode_default(i2s_hal_context_t *hal); +#endif -#if SOC_I2S_SUPPORTS_PDM +#if !SOC_GDMA_SUPPORTED /** - * @brief Set I2S tx pdm + * @brief Enable I2S TX DMA * * @param hal Context of the HAL layer - * @param fp tx pdm fp - * @param fs tx pdm fs */ -void i2s_hal_tx_pdm_cfg(i2s_hal_context_t *hal, uint32_t fp, uint32_t fs); +#define i2s_hal_enable_tx_dma(hal) i2s_ll_enable_dma((hal)->dev,true) /** - * @brief Get I2S tx pdm + * @brief Enable I2S RX DMA * * @param hal Context of the HAL layer - * @param dsr rx pdm dsr */ -void i2s_hal_rx_pdm_cfg(i2s_hal_context_t *hal, uint32_t dsr); +#define i2s_hal_enable_rx_dma(hal) i2s_ll_enable_dma((hal)->dev,true) /** - * @brief Get I2S tx pdm configuration + * @brief Disable I2S TX DMA * * @param hal Context of the HAL layer - * @param fp Pointer to receive tx PDM fp configuration - * @param fs Pointer to receive tx PDM fs configuration */ -void i2s_hal_get_tx_pdm(i2s_hal_context_t *hal, uint32_t *fp, uint32_t *fs); +#define i2s_hal_disable_tx_dma(hal) i2s_ll_enable_dma((hal)->dev,false) + +/** + * @brief Disable I2S RX DMA + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_disable_rx_dma(hal) i2s_ll_enable_dma((hal)->dev,false) + +/** + * @brief Get I2S interrupt status + * + * @param hal Context of the HAL layer + * @return + * - module interrupt status + */ +#define i2s_hal_get_intr_status(hal) i2s_ll_get_intr_status((hal)->dev) + +/** + * @brief Get I2S interrupt status + * + * @param hal Context of the HAL layer + * @param mask Interrupt mask to be cleared. + */ +#define i2s_hal_clear_intr_status(hal, mask) i2s_ll_clear_intr_status((hal)->dev, mask) + +/** + * @brief Enable I2S RX interrupt + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_enable_rx_intr(hal) i2s_ll_rx_enable_intr((hal)->dev) + +/** + * @brief Disable I2S RX interrupt + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_disable_rx_intr(hal) i2s_ll_rx_disable_intr((hal)->dev) + +/** + * @brief Disable I2S TX interrupt + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_disable_tx_intr(hal) i2s_ll_tx_disable_intr((hal)->dev) + +/** + * @brief Enable I2S TX interrupt + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_enable_tx_intr(hal) i2s_ll_tx_enable_intr((hal)->dev) + +/** + * @brief Configure TX DMA descriptor address and start TX DMA + * + * @param hal Context of the HAL layer + * @param link_addr DMA descriptor link address. + */ +#define i2s_hal_start_tx_link(hal, link_addr) i2s_ll_tx_start_link((hal)->dev, link_addr) + +/** + * @brief Configure RX DMA descriptor address and start RX DMA + * + * @param hal Context of the HAL layer + * @param link_addr DMA descriptor link address. + */ +#define i2s_hal_start_rx_link(hal, link_addr) i2s_ll_rx_start_link((hal)->dev, link_addr) + +/** + * @brief Stop TX DMA link + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_stop_tx_link(hal) i2s_ll_tx_stop_link((hal)->dev) + +/** + * @brief Stop RX DMA link + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_stop_rx_link(hal) i2s_ll_rx_stop_link((hal)->dev) + +/** + * @brief Reset RX DMA + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_reset_rxdma(hal) i2s_ll_rx_reset_dma((hal)->dev) + +/** + * @brief Reset TX DMA + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_reset_txdma(hal) i2s_ll_tx_reset_dma((hal)->dev) + +/** + * @brief Get I2S out eof descriptor address + * + * @param hal Context of the HAL layer + * @param addr Pointer to accept out eof des address + */ +#define i2s_hal_get_out_eof_des_addr(hal, addr) i2s_ll_tx_get_eof_des_addr((hal)->dev, addr) + +/** + * @brief Get I2S in suc eof descriptor address + * + * @param hal Context of the HAL layer + * @param addr Pointer to accept in suc eof des address + */ +#define i2s_hal_get_in_eof_des_addr(hal, addr) i2s_ll_rx_get_eof_des_addr((hal)->dev, addr) +#endif + +#if SOC_I2S_SUPPORTS_ADC +/** + * @brief Enable Builtin DAC + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_enable_builtin_dac(hal) i2s_ll_enable_builtin_dac((hal)->dev, true); + +/** + * @brief Enable Builtin ADC + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_enable_builtin_adc(hal) i2s_ll_enable_builtin_adc((hal)->dev, true); + +/** + * @brief Disable Builtin ADC + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_disable_builtin_adc(hal) i2s_ll_enable_builtin_adc((hal)->dev, false); +#endif +#if SOC_I2S_SUPPORTS_DAC /** - * @brief Get I2S rx pdm configuration + * @brief Disable Builtin DAC * * @param hal Context of the HAL layer - * @param dsr rx pdm dsr */ -void i2s_hal_get_rx_pdm(i2s_hal_context_t *hal, uint32_t *dsr); +#define i2s_hal_disable_builtin_dac(hal) i2s_ll_enable_builtin_dac((hal)->dev, false); #endif #ifdef __cplusplus diff --git a/tools/sdk/esp32/include/hal/include/hal/i2s_types.h b/tools/sdk/esp32/include/hal/include/hal/i2s_types.h index ba150cc7b34..48d745eb2fa 100644 --- a/tools/sdk/esp32/include/hal/include/hal/i2s_types.h +++ b/tools/sdk/esp32/include/hal/include/hal/i2s_types.h @@ -1,4 +1,4 @@ -// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD +// Copyright 2020 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. @@ -16,6 +16,7 @@ #include #include +#include #include #include "soc/soc_caps.h" @@ -24,34 +25,59 @@ extern "C" { #endif /** - * @brief I2S port number, the max port number is (I2S_NUM_MAX -1). + * @brief I2S bit width per sample. + * */ typedef enum { - I2S_NUM_0 = 0, /*!< I2S port 0 */ -#if SOC_I2S_NUM > 1 - I2S_NUM_1 = 1, /*!< I2S port 1 */ -#endif - I2S_NUM_MAX, /*!< I2S port max */ -} i2s_port_t; + I2S_BITS_PER_SAMPLE_8BIT = 8, /*!< data bit-width: 8 */ + I2S_BITS_PER_SAMPLE_16BIT = 16, /*!< data bit-width: 16 */ + I2S_BITS_PER_SAMPLE_24BIT = 24, /*!< data bit-width: 24 */ + I2S_BITS_PER_SAMPLE_32BIT = 32, /*!< data bit-width: 32 */ +} i2s_bits_per_sample_t; /** - * @brief I2S bit width per sample. + * @brief I2S bit width per chan. * */ typedef enum { - I2S_BITS_PER_SAMPLE_8BIT = 8, /*!< I2S bits per sample: 8-bits*/ - I2S_BITS_PER_SAMPLE_16BIT = 16, /*!< I2S bits per sample: 16-bits*/ - I2S_BITS_PER_SAMPLE_24BIT = 24, /*!< I2S bits per sample: 24-bits*/ - I2S_BITS_PER_SAMPLE_32BIT = 32, /*!< I2S bits per sample: 32-bits*/ -} i2s_bits_per_sample_t; + I2S_BITS_PER_CHAN_DEFAULT = (0), /*!< channel bit-width equals to data bit-width */ + I2S_BITS_PER_CHAN_8BIT = (8), /*!< channel bit-width: 8 */ + I2S_BITS_PER_CHAN_16BIT = (16), /*!< channel bit-width: 16 */ + I2S_BITS_PER_CHAN_24BIT = (24), /*!< channel bit-width: 24 */ + I2S_BITS_PER_CHAN_32BIT = (32), /*!< channel bit-width: 32 */ +} i2s_bits_per_chan_t; /** * @brief I2S channel. * */ typedef enum { - I2S_CHANNEL_MONO = 1, /*!< I2S 1 channel (mono)*/ - I2S_CHANNEL_STEREO = 2 /*!< I2S 2 channel (stereo)*/ + I2S_CHANNEL_MONO = (0x01 << 31) | 0x03, /*!< I2S channel (mono), two channel enabled. In this mode, you only need to send one channel data but the fifo will copy same data for another channel automatically, then both channels will transmit same data. The highest bit is for differentiating I2S_CHANNEL_STEREO since they both use two channels */ + I2S_CHANNEL_STEREO = 0x03, /*!< I2S channel (stereo), two channel enabled. In this mode, two channels will transmit different data. */ +#if SOC_I2S_SUPPORTS_TDM + // Bit map of active chan. + // There are 16 channels in TDM mode. + // For TX module, only the active channel send the audio data, the inactive channel send a constant(configurable) or will be skiped if 'skip_msk' is set. + // For RX module, only receive the audio data in active channels, the data in inactive channels will be ignored. + // the bit map of active channel can not exceed (0x1< 0, then the clock output for i2s is fixed and equal to the fixed_mclk value.*/ -} i2s_config_t; - -/** - * @brief I2S event types - * + * @brief The multiple of mclk to sample rate */ typedef enum { - I2S_EVENT_DMA_ERROR, - I2S_EVENT_TX_DONE, /*!< I2S DMA finish sent 1 buffer*/ - I2S_EVENT_RX_DONE, /*!< I2S DMA finish received 1 buffer*/ - I2S_EVENT_MAX, /*!< I2S event max index*/ -} i2s_event_type_t; + I2S_MCLK_MULTIPLE_DEFAULT = 0, /*!< Default value. mclk = sample_rate * 256 */ + I2S_MCLK_MULTIPLE_128 = 128, /*!< mclk = sample_rate * 128 */ + I2S_MCLK_MULTIPLE_256 = 256, /*!< mclk = sample_rate * 256 */ + I2S_MCLK_MULTIPLE_384 = 384, /*!< mclk = sample_rate * 384 */ +} i2s_mclk_multiple_t; -#if SOC_I2S_SUPPORTS_ADC_DAC +#if SOC_I2S_SUPPORTS_DAC /** * @brief I2S DAC mode for i2s_set_dac_mode. * - * @note PDM and built-in DAC functions are only supported on I2S0 for current ESP32 chip. + * @note Built-in DAC functions are only supported on I2S0 for current ESP32 chip. */ typedef enum { I2S_DAC_CHANNEL_DISABLE = 0, /*!< Disable I2S built-in DAC signals*/ @@ -157,29 +167,23 @@ typedef enum { I2S_DAC_CHANNEL_BOTH_EN = 0x3, /*!< Enable both of the I2S built-in DAC channels.*/ I2S_DAC_CHANNEL_MAX = 0x4, /*!< I2S built-in DAC mode max index*/ } i2s_dac_mode_t; -#endif //SOC_I2S_SUPPORTS_ADC_DAC +#endif //SOC_I2S_SUPPORTS_DAC +#if SOC_I2S_SUPPORTS_PCM /** - * @brief Event structure used in I2S event queue + * @brief A/U-law decompress or compress configuration. * */ -typedef struct { - i2s_event_type_t type; /*!< I2S event type */ - size_t size; /*!< I2S data size for I2S_DATA event*/ -} i2s_event_t; +typedef enum { + I2S_PCM_DISABLE = 0, /*!< Disable A/U law decopress or compress*/ + I2S_PCM_A_DECOMPRESS, /*!< A-law decompress*/ + I2S_PCM_A_COMPRESS, /*!< A-law compress*/ + I2S_PCM_U_DECOMPRESS, /*!< U-law decompress*/ + I2S_PCM_U_COMPRESS, /*!< U-law compress*/ +} i2s_pcm_compress_t; +#endif -/** - * @brief I2S pin number for i2s_set_pin - * - */ -typedef struct { - int bck_io_num; /*!< BCK in out pin*/ - int ws_io_num; /*!< WS in out pin*/ - int data_out_num; /*!< DATA out pin*/ - int data_in_num; /*!< DATA in pin*/ -} i2s_pin_config_t; - -#if SOC_I2S_SUPPORTS_PDM +#if SOC_I2S_SUPPORTS_PDM_RX /** * @brief I2S PDM RX downsample mode */ @@ -188,18 +192,17 @@ typedef enum { I2S_PDM_DSR_16S, /*!< downsampling number is 16 for PDM RX mode*/ I2S_PDM_DSR_MAX, } i2s_pdm_dsr_t; +#endif -/** - * @brief PDM PCM convter enable/disable. - * - */ +#if SOC_I2S_SUPPORTS_PDM_TX typedef enum { - PDM_PCM_CONV_ENABLE, /*!< Enable PDM PCM convert*/ - PDM_PCM_CONV_DISABLE, /*!< Disable PDM PCM convert*/ -} pdm_pcm_conv_t; + I2S_PDM_SIG_SCALING_DIV_2 = 0, /*!< I2S TX PDM sigmadelta signal scaling: /2 */ + I2S_PDM_SIG_SCALING_MUL_1 = 1, /*!< I2S TX PDM sigmadelta signal scaling: x1 */ + I2S_PDM_SIG_SCALING_MUL_2 = 2, /*!< I2S TX PDM sigmadelta signal scaling: x2 */ + I2S_PDM_SIG_SCALING_MUL_4 = 3, /*!< I2S TX PDM sigmadelta signal scaling: x4 */ +} i2s_pdm_sig_scale_t; #endif - #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32/include/hal/include/hal/lcd_hal.h b/tools/sdk/esp32/include/hal/include/hal/lcd_hal.h index a6bcba166c6..76e28dda0e4 100644 --- a/tools/sdk/esp32/include/hal/include/hal/lcd_hal.h +++ b/tools/sdk/esp32/include/hal/include/hal/lcd_hal.h @@ -24,10 +24,10 @@ extern "C" { #endif -#include "soc/lcd_cam_struct.h" +typedef struct lcd_cam_dev_t *lcd_soc_handle_t; typedef struct { - lcd_cam_dev_t *dev; + lcd_soc_handle_t dev; } lcd_hal_context_t; void lcd_hal_init(lcd_hal_context_t *hal, int id); diff --git a/tools/sdk/esp32/include/hal/include/hal/lcd_types.h b/tools/sdk/esp32/include/hal/include/hal/lcd_types.h new file mode 100644 index 00000000000..69dab14801d --- /dev/null +++ b/tools/sdk/esp32/include/hal/include/hal/lcd_types.h @@ -0,0 +1,42 @@ +// Copyright 2021 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 + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief LCD clock source + * @note User should select the clock source based on the real requirement: + * ╔═════════════════════╦══════════════════════════╦════════════════════════════╗ + * ║ LCD clock source ║ Features ║ Power Management ║ + * ╠═════════════════════╬══════════════════════════╬════════════════════════════╣ + * ║ LCD_CLK_SRC_PLL160M ║ High resolution, fixed ║ ESP_PM_APB_FREQ_MAX lock ║ + * ╠═════════════════════╬══════════════════════════╬════════════════════════════╣ + * ║ LCD_CLK_SRC_APLL ║ Configurable resolution ║ ESP_PM_NO_LIGHT_SLEEP lock ║ + * ╠═════════════════════╬══════════════════════════╬════════════════════════════╣ + * ║ LCD_CLK_SRC_XTAL ║ Medium resolution, fixed ║ No PM lock ║ + * ╚═════════════════════╩══════════════════════════╩════════════════════════════╝ + */ +typedef enum { + LCD_CLK_SRC_PLL160M, /*!< Select PLL160M as the source clock */ + LCD_CLK_SRC_APLL, /*!< Select APLL as the source clock */ + LCD_CLK_SRC_XTAL, /*!< Select XTAL as the source clock */ +} lcd_clock_source_t; + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32/include/hal/include/hal/mcpwm_types.h b/tools/sdk/esp32/include/hal/include/hal/mcpwm_types.h index 77f9c80c12b..b9c37315bc4 100644 --- a/tools/sdk/esp32/include/hal/include/hal/mcpwm_types.h +++ b/tools/sdk/esp32/include/hal/include/hal/mcpwm_types.h @@ -37,7 +37,7 @@ typedef enum { MCPWM_TIMER_START_NO_STOP, /*!< MCPWM timer starts couting */ MCPWM_TIMER_START_STOP_AT_ZERO, /*!< MCPWM timer starts counting and stops when couting to zero */ MCPWM_TIMER_START_STOP_AT_PEAK, /*!< MCPWM timer starts counting and stops when counting to peak */ -} mcpwm_timer_operate_cmd_t; +} mcpwm_timer_execute_cmd_t; typedef enum { MCPWM_GEN_ACTION_KEEP, /*!< Generator action: Keep the same level */ @@ -47,6 +47,6 @@ typedef enum { } mcpwm_generator_action_t; typedef enum { - MCPWM_FAULT_REACTION_CBC, /*!< Reaction on fault signal: recover cycle by cycle */ - MCPWM_FAULT_REACTION_OST, /*!< Reaction on fault signal: one shot trip */ -} mcpwm_fault_reaction_t; + MCPWM_TRIP_TYPE_CBC, /*!< CBC trip type, shut down the operator cycle by cycle*/ + MCPWM_TRIP_TYPE_OST, /*!< OST trip type, shut down the operator in one shot */ +} mcpwm_trip_type_t; diff --git a/tools/sdk/esp32/include/hal/include/hal/memprot_types.h b/tools/sdk/esp32/include/hal/include/hal/memprot_types.h new file mode 100644 index 00000000000..42231f43eaf --- /dev/null +++ b/tools/sdk/esp32/include/hal/include/hal/memprot_types.h @@ -0,0 +1,35 @@ +// Copyright 2015-2021 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 + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Memprot LL error codes + * + */ +typedef enum { + MEMP_LL_OK = 0, + MEMP_LL_FAIL = 1, + MEMP_LL_ERR_SPLIT_ADDR_INVALID = 2, + MEMP_LL_ERR_SPLIT_ADDR_UNALIGNED = 3, + MEMP_LL_ERR_UNI_BLOCK_INVALID = 4 +} memprot_ll_err_t; + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32/include/hal/include/hal/pcnt_hal.h b/tools/sdk/esp32/include/hal/include/hal/pcnt_hal.h index 8d2253e46e3..3d10c8d8c68 100644 --- a/tools/sdk/esp32/include/hal/include/hal/pcnt_hal.h +++ b/tools/sdk/esp32/include/hal/include/hal/pcnt_hal.h @@ -23,10 +23,7 @@ #pragma once -#include -#include "soc/pcnt_periph.h" -#include "hal/pcnt_types.h" -#include "hal/pcnt_ll.h" +#include "soc/pcnt_struct.h" #ifdef __cplusplus extern "C" { @@ -35,188 +32,18 @@ extern "C" { /** * Context that should be maintained by both the driver and the HAL */ - typedef struct { - pcnt_dev_t *dev; + pcnt_dev_t *dev; /*!< PCNT peripheral register base address */ } pcnt_hal_context_t; /** - * @brief Set PCNT counter mode - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - * @param channel PCNT channel number - * @param pos_mode Counter mode when detecting positive edge - * @param neg_mode Counter mode when detecting negative edge - * @param hctrl_mode Counter mode when control signal is high level - * @param lctrl_mode Counter mode when control signal is low level - */ -#define pcnt_hal_set_mode(hal, unit, channel, pos_mode, neg_mode, hctrl_mode, lctrl_mode) pcnt_ll_set_mode((hal)->dev, unit, channel, pos_mode, neg_mode, hctrl_mode, lctrl_mode) - -/** - * @brief Get pulse counter value - * - * @param hal Context of the HAL layer - * @param unit Pulse Counter unit number - * @param count Pointer to accept counter value - */ -#define pcnt_hal_get_counter_value(hal, unit, count) pcnt_ll_get_counter_value((hal)->dev, unit, count) - -/** - * @brief Pause PCNT counter of PCNT unit - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - */ -#define pcnt_hal_counter_pause(hal, unit) pcnt_ll_counter_pause((hal)->dev, unit) - -/** - * @brief Resume counting for PCNT counter - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number, select from unit_t - */ -#define pcnt_hal_counter_resume(hal, unit) pcnt_ll_counter_resume((hal)->dev, unit) - -/** - * @brief Clear and reset PCNT counter value to zero - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number, select from unit_t - */ -#define pcnt_hal_counter_clear(hal, unit) pcnt_ll_counter_clear((hal)->dev, unit) - -/** - * @brief Enable PCNT interrupt for PCNT unit - * @note - * Each Pulse counter unit has five watch point events that share the same interrupt. - * Configure events with pcnt_event_enable() and pcnt_event_disable() - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - */ -#define pcnt_hal_intr_enable(hal, unit) pcnt_ll_intr_enable((hal)->dev, unit) - -/** - * @brief Disable PCNT interrupt for PCNT unit - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - */ -#define pcnt_hal_intr_disable(hal, unit) pcnt_ll_intr_disable((hal)->dev, unit) - -/** - * @brief Get PCNT interrupt status - * - * @param hal Context of the HAL layer - * @param mask The interrupt status mask to be cleared. Pointer to accept value interrupt status mask. - */ -#define pcnt_hal_get_intr_status(hal, mask) pcnt_ll_get_intr_status((hal)->dev, mask) - -/** - * @brief Clear PCNT interrupt status - * - * @param hal Context of the HAL layer - * @param mask The interrupt status mask to be cleared. - */ -#define pcnt_hal_clear_intr_status(hal, mask) pcnt_ll_clear_intr_status((hal)->dev, mask) - -/** - * @brief Enable PCNT event of PCNT unit - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - * @param evt_type Watch point event type. - * All enabled events share the same interrupt (one interrupt per pulse counter unit). - */ -#define pcnt_hal_event_enable(hal, unit, evt_type) pcnt_ll_event_enable((hal)->dev, unit, evt_type) - -/** - * @brief Disable PCNT event of PCNT unit - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - * @param evt_type Watch point event type. - * All enabled events share the same interrupt (one interrupt per pulse counter unit). - */ -#define pcnt_hal_event_disable(hal, unit, evt_type) pcnt_ll_event_disable((hal)->dev, unit, evt_type) - -/** - * @brief Set PCNT event value of PCNT unit - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - * @param evt_type Watch point event type. - * All enabled events share the same interrupt (one interrupt per pulse counter unit). - * - * @param value Counter value for PCNT event - */ -#define pcnt_hal_set_event_value(hal, unit, evt_type, value) pcnt_ll_set_event_value((hal)->dev, unit, evt_type, value) - -/** - * @brief Get PCNT event value of PCNT unit - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - * @param evt_type Watch point event type. - * All enabled events share the same interrupt (one interrupt per pulse counter unit). - * @param value Pointer to accept counter value for PCNT event - */ -#define pcnt_hal_get_event_value(hal, unit, evt_type, value) pcnt_ll_get_event_value((hal)->dev, unit, evt_type, value) - -/** - * @brief Get PCNT event status - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - * @return event status word - */ -#define pcnt_hal_get_event_status(hal, unit) pcnt_ll_get_event_status((hal)->dev, unit) - -/** - * @brief Set PCNT filter value - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - * @param filter_val PCNT signal filter value, counter in APB_CLK cycles. - * Any pulses lasting shorter than this will be ignored when the filter is enabled. - * @note - * filter_val is a 10-bit value, so the maximum filter_val should be limited to 1023. - */ -#define pcnt_hal_set_filter_value(hal, unit, filter_val) pcnt_ll_set_filter_value((hal)->dev, unit, filter_val) - -/** - * @brief Get PCNT filter value - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - * @param filter_val Pointer to accept PCNT filter value. - */ -#define pcnt_hal_get_filter_value(hal, unit, filter_val) pcnt_ll_get_filter_value((hal)->dev, unit, filter_val) - -/** - * @brief Enable PCNT input filter - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - */ -#define pcnt_hal_filter_enable(hal, unit) pcnt_ll_filter_enable((hal)->dev, unit) - -/** - * @brief Disable PCNT input filter - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - */ -#define pcnt_hal_filter_disable(hal, unit) pcnt_ll_filter_disable((hal)->dev, unit) - -/** - * @brief Init the PCNT hal and set the PCNT to the default configuration. This function should be called first before other hal layer function is called + * @brief Init the PCNT hal and set the PCNT to the default configuration. + * @note This function should be called first before other hal layer function is called. * * @param hal Context of the HAL layer - * @param pcnt_num The uart port number, the max port number is (PCNT_NUM_MAX -1) + * @param group_id PCNT group ID */ -void pcnt_hal_init(pcnt_hal_context_t *hal, int pcnt_num); +void pcnt_hal_init(pcnt_hal_context_t *hal, int group_id); #ifdef __cplusplus } diff --git a/tools/sdk/esp32/include/hal/include/hal/pcnt_types.h b/tools/sdk/esp32/include/hal/include/hal/pcnt_types.h index 6f09177b53a..0696e756cc9 100644 --- a/tools/sdk/esp32/include/hal/include/hal/pcnt_types.h +++ b/tools/sdk/esp32/include/hal/include/hal/pcnt_types.h @@ -1,4 +1,4 @@ -// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD +// Copyright 2015-2021 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. @@ -18,93 +18,36 @@ extern "C" { #endif -#include "soc/soc_caps.h" - -#define PCNT_PIN_NOT_USED (-1) /*!< When selected for a pin, this pin will not be used */ - -/** - * @brief PCNT port number, the max port number is (PCNT_PORT_MAX - 1). - */ -typedef enum { - PCNT_PORT_0 = 0, /*!< PCNT port 0 */ - PCNT_PORT_MAX, /*!< PCNT port max */ -} pcnt_port_t; - -/** - * @brief Selection of all available PCNT units - */ -typedef enum { - PCNT_UNIT_0 = 0, /*!< PCNT unit 0 */ - PCNT_UNIT_1 = 1, /*!< PCNT unit 1 */ - PCNT_UNIT_2 = 2, /*!< PCNT unit 2 */ - PCNT_UNIT_3 = 3, /*!< PCNT unit 3 */ -#if SOC_PCNT_UNIT_NUM > 4 - PCNT_UNIT_4 = 4, /*!< PCNT unit 4 */ - PCNT_UNIT_5 = 5, /*!< PCNT unit 5 */ - PCNT_UNIT_6 = 6, /*!< PCNT unit 6 */ - PCNT_UNIT_7 = 7, /*!< PCNT unit 7 */ -#endif - PCNT_UNIT_MAX, -} pcnt_unit_t; - /** - * @brief Selection of available modes that determine the counter's action depending on the state of the control signal's input GPIO - * @note Configuration covers two actions, one for high, and one for low level on the control input + * @brief PCNT channel action on control level + * */ typedef enum { - PCNT_MODE_KEEP = 0, /*!< Control mode: won't change counter mode*/ - PCNT_MODE_REVERSE = 1, /*!< Control mode: invert counter mode(increase -> decrease, decrease -> increase) */ - PCNT_MODE_DISABLE = 2, /*!< Control mode: Inhibit counter(counter value will not change in this condition) */ - PCNT_MODE_MAX -} pcnt_ctrl_mode_t; + PCNT_CHANNEL_LEVEL_ACTION_KEEP, /*!< Keep current count mode */ + PCNT_CHANNEL_LEVEL_ACTION_INVERSE, /*!< Invert current count mode (increase -> decrease, decrease -> increase) */ + PCNT_CHANNEL_LEVEL_ACTION_HOLD, /*!< Hold current count value */ +} pcnt_channel_level_action_t; /** - * @brief Selection of available modes that determine the counter's action on the edge of the pulse signal's input GPIO - * @note Configuration covers two actions, one for positive, and one for negative edge on the pulse input + * @brief PCNT channel action on signal edge + * */ typedef enum { - PCNT_COUNT_DIS = 0, /*!< Counter mode: Inhibit counter(counter value will not change in this condition) */ - PCNT_COUNT_INC = 1, /*!< Counter mode: Increase counter value */ - PCNT_COUNT_DEC = 2, /*!< Counter mode: Decrease counter value */ - PCNT_COUNT_MAX -} pcnt_count_mode_t; + PCNT_CHANNEL_EDGE_ACTION_HOLD, /*!< Hold current count value */ + PCNT_CHANNEL_EDGE_ACTION_INCREASE, /*!< Increase count value */ + PCNT_CHANNEL_EDGE_ACTION_DECREASE, /*!< Decrease count value */ +} pcnt_channel_edge_action_t; /** - * @brief Selection of channels available for a single PCNT unit + * @brief PCNT unit counter value's sign + * */ typedef enum { - PCNT_CHANNEL_0 = 0x00, /*!< PCNT channel 0 */ - PCNT_CHANNEL_1 = 0x01, /*!< PCNT channel 1 */ - PCNT_CHANNEL_MAX, -} pcnt_channel_t; - -/** - * @brief Selection of counter's events the may trigger an interrupt - */ -typedef enum { - PCNT_EVT_THRES_1 = BIT(2), /*!< PCNT watch point event: threshold1 value event */ - PCNT_EVT_THRES_0 = BIT(3), /*!< PCNT watch point event: threshold0 value event */ - PCNT_EVT_L_LIM = BIT(4), /*!< PCNT watch point event: Minimum counter value */ - PCNT_EVT_H_LIM = BIT(5), /*!< PCNT watch point event: Maximum counter value */ - PCNT_EVT_ZERO = BIT(6), /*!< PCNT watch point event: counter value zero event */ - PCNT_EVT_MAX -} pcnt_evt_type_t; - -/** - * @brief Pulse Counter configuration for a single channel - */ -typedef struct { - int pulse_gpio_num; /*!< Pulse input GPIO number, if you want to use GPIO16, enter pulse_gpio_num = 16, a negative value will be ignored */ - int ctrl_gpio_num; /*!< Control signal input GPIO number, a negative value will be ignored */ - pcnt_ctrl_mode_t lctrl_mode; /*!< PCNT low control mode */ - pcnt_ctrl_mode_t hctrl_mode; /*!< PCNT high control mode */ - pcnt_count_mode_t pos_mode; /*!< PCNT positive edge count mode */ - pcnt_count_mode_t neg_mode; /*!< PCNT negative edge count mode */ - int16_t counter_h_lim; /*!< Maximum counter value */ - int16_t counter_l_lim; /*!< Minimum counter value */ - pcnt_unit_t unit; /*!< PCNT unit number */ - pcnt_channel_t channel; /*!< the PCNT channel */ -} pcnt_config_t; + PCNT_UNIT_COUNT_SIGN_ZERO_POS, /*!< positive value to zero */ + PCNT_UNIT_COUNT_SIGN_ZERO_NEG, /*!< negative value to zero */ + PCNT_UNIT_COUNT_SIGN_NEG, /*!< counter value negative */ + PCNT_UNIT_COUNT_SIGN_POS, /*!< counter value positive */ +} pcnt_unit_count_sign_t; #ifdef __cplusplus } diff --git a/tools/sdk/esp32/include/hal/include/hal/rtc_hal.h b/tools/sdk/esp32/include/hal/include/hal/rtc_hal.h index 8d74f4c4cd8..90f965ed58c 100644 --- a/tools/sdk/esp32/include/hal/include/hal/rtc_hal.h +++ b/tools/sdk/esp32/include/hal/include/hal/rtc_hal.h @@ -14,12 +14,36 @@ #pragma once +#include "soc/soc_caps.h" #include "hal/gpio_types.h" #include "hal/rtc_cntl_ll.h" #if !CONFIG_IDF_TARGET_ESP32C3 && !CONFIG_IDF_TARGET_ESP32H2 #include "hal/rtc_io_ll.h" #endif +typedef struct rtc_cntl_sleep_retent { +#if SOC_PM_SUPPORT_CPU_PD + void *cpu_pd_mem; /* Internal ram address for cpu retention */ +#endif // SOC_PM_SUPPORT_CPU_PD +#if SOC_PM_SUPPORT_TAGMEM_PD + struct { + void *link_addr; /* Internal ram address for tagmem retention */ + struct { + uint32_t start_point: 8, /* the row of start for i-cache tag memory */ + vld_size: 8, /* valid size of i-cache tag memory, unit: 4 i-cache tagmem blocks */ + size: 8, /* i-cache tag memory size, unit: 4 i-cache tagmem blocks */ + enable: 1; /* enable or disable i-cache tagmem retention */ + } icache; + struct { + uint32_t start_point: 9, /* the row of start for d-cache tag memory */ + vld_size: 9, /* valid size of d-cache tag memory, unit: 4 d-cache tagmem blocks */ + size: 9, /* d-cache tag memory size, unit: 4 d-cache tagmem blocks */ + enable: 1; /* enable or disable d-cache tagmem retention */ + } dcache; + } tagmem; +#endif // SOC_PM_SUPPORT_TAGMEM_PD +} rtc_cntl_sleep_retent_t; + #define RTC_HAL_DMA_LINK_NODE_SIZE (16) #if SOC_PM_SUPPORT_EXT_WAKEUP @@ -46,9 +70,21 @@ void * rtc_cntl_hal_dma_link_init(void *elem, void *buff, int size, void *next); +#if SOC_PM_SUPPORT_CPU_PD + void rtc_cntl_hal_enable_cpu_retention(void *addr); -#define rtc_cntl_hal_disable_cpu_retention() rtc_cntl_ll_disable_cpu_retention() +void rtc_cntl_hal_disable_cpu_retention(void *addr); + +#endif + +#if SOC_PM_SUPPORT_TAGMEM_PD + +void rtc_cntl_hal_enable_tagmem_retention(void *addr); + +void rtc_cntl_hal_disable_tagmem_retention(void *addr); + +#endif /* * Enable wakeup from ULP coprocessor. diff --git a/tools/sdk/esp32/include/hal/include/hal/spi_flash_hal.h b/tools/sdk/esp32/include/hal/include/hal/spi_flash_hal.h index dbbb5ff53b5..ae37016fa2d 100644 --- a/tools/sdk/esp32/include/hal/include/hal/spi_flash_hal.h +++ b/tools/sdk/esp32/include/hal/include/hal/spi_flash_hal.h @@ -51,20 +51,41 @@ typedef struct { uint32_t flags; ///< Flags for configurations with one set of driver code. (e.g. QPI mode, auto-suspend mode, 64-bit address mode, etc.) #define SPI_FLASH_HOST_CONTEXT_FLAG_AUTO_SUSPEND BIT(0) ///< When the auto-suspend is setup in configuration. #define SPI_FLASH_HOST_CONTEXT_FLAG_AUTO_RESUME BIT(1) ///< Setup auto-resume feature. +#define SPI_FLASH_HOST_CONTEXT_FLAG_OCTAL_MODE BIT(2) ///< Flash works under octal spi mode. spi_flash_sus_cmd_conf sus_cfg; ///< To store suspend command/mask information. + uint32_t slicer_flags; /// Slicer flags for configuring how to slice data correctly while reading or writing. +#define SPI_FLASH_HOST_CONTEXT_SLICER_FLAG_DTR BIT(0) ///< Slice data according to DTR mode, the address and length must be even (A0=0). } spi_flash_hal_context_t; -_Static_assert(sizeof(spi_flash_hal_context_t) == 36, "size of spi_flash_hal_context_t incorrect. Please check data compatibility with the ROM"); +_Static_assert(sizeof(spi_flash_hal_context_t) == 40, "size of spi_flash_hal_context_t incorrect. Please check data compatibility with the ROM"); + +/// This struct provide MSPI Flash necessary timing related config, should be consistent with that in union in `spi_flash_hal_config_t`. +typedef struct { + uint32_t extra_dummy; + uint32_t cs_hold; + uint8_t cs_setup; + spi_flash_ll_clock_reg_t clock_config; +} spi_flash_hal_timing_config_t; /// Configuration structure for the SPI driver. typedef struct { - spi_host_device_t host_id; ///< SPI peripheral ID. - int cs_num; ///< Which cs pin is used, 0-(SOC_SPI_PERIPH_CS_NUM-1). + union { + struct { + uint32_t extra_dummy; ///< extra dummy for timing compensation. + uint32_t cs_hold; ///< CS hold time config used by the host + uint8_t cs_setup; ///< (cycles-1) of prepare phase by spi clock + spi_flash_ll_clock_reg_t clock_config; ///< (optional) Clock configuration for Octal flash. + }; + spi_flash_hal_timing_config_t timing_reg; ///< Reconfigure timing tuning regs. + }; bool iomux; ///< Whether the IOMUX is used, used for timing compensation. int input_delay_ns; ///< Input delay on the MISO pin after the launch clock, used for timing compensation. esp_flash_speed_t speed;///< SPI flash clock speed to work at. - uint32_t cs_hold; ///< CS hold time config used by the host - uint8_t cs_setup; ///< (cycles-1) of prepare phase by spi clock + spi_host_device_t host_id; ///< SPI peripheral ID. + int cs_num; ///< Which cs pin is used, 0-(SOC_SPI_PERIPH_CS_NUM-1). bool auto_sus_en; ///< Auto suspend feature enable bit 1: enable, 0: disable. + bool octal_mode_en; ///< Octal spi flash mode enable bit 1: enable, 0: disable. + bool using_timing_tuning; ///< System exist SPI0/1 timing tuning, using value from system directely if set to 1. + esp_flash_io_mode_t default_io_mode; ///< Default flash io mode. } spi_flash_hal_config_t; /** diff --git a/tools/sdk/esp32/include/hal/include/hal/spi_flash_types.h b/tools/sdk/esp32/include/hal/include/hal/spi_flash_types.h index 0cc605595f2..c9d5035e60e 100644 --- a/tools/sdk/esp32/include/hal/include/hal/spi_flash_types.h +++ b/tools/sdk/esp32/include/hal/include/hal/spi_flash_types.h @@ -37,6 +37,7 @@ typedef struct { #define SPI_FLASH_TRANS_FLAG_BYTE_SWAP BIT(2) ///< Used for DTR mode, to swap the bytes of a pair of rising/falling edge uint16_t command; ///< Command to send uint8_t dummy_bitlen; ///< Basic dummy bits to use + uint32_t io_mode; ///< Flash working mode when `SPI_FLASH_IGNORE_BASEIO` is specified. } spi_flash_trans_t; /** @@ -54,6 +55,7 @@ typedef enum { ESP_FLASH_26MHZ, ///< The flash runs under 26MHz ESP_FLASH_40MHZ, ///< The flash runs under 40MHz ESP_FLASH_80MHZ, ///< The flash runs under 80MHz + ESP_FLASH_120MHZ, ///< The flash runs under 120MHz, 120MHZ can only be used by main flash after timing tuning in system. Do not use this directely in any API. ESP_FLASH_SPEED_MAX, ///< The maximum frequency supported by the host is ``ESP_FLASH_SPEED_MAX-1``. } esp_flash_speed_t; @@ -71,7 +73,9 @@ typedef enum { SPI_FLASH_DIO, ///< Both address & data transferred using dual I/O SPI_FLASH_QOUT, ///< Data read using quad I/O SPI_FLASH_QIO, ///< Both address & data transferred using quad I/O - +#define SPI_FLASH_OPI_FLAG 16 ///< A flag for flash work in opi mode, the io mode below are opi, above are SPI/QSPI mode. DO NOT use this value in any API. + SPI_FLASH_OPI_STR = SPI_FLASH_OPI_FLAG,///< Only support on OPI flash, flash read and write under STR mode + SPI_FLASH_OPI_DTR,///< Only support on OPI flash, flash read and write under DTR mode SPI_FLASH_READ_MODE_MAX, ///< The fastest io mode supported by the host is ``ESP_FLASH_READ_MODE_MAX-1``. } esp_flash_io_mode_t; diff --git a/tools/sdk/esp32/include/hal/include/hal/spi_hal.h b/tools/sdk/esp32/include/hal/include/hal/spi_hal.h index b37c7c92504..5be7db32ea9 100644 --- a/tools/sdk/esp32/include/hal/include/hal/spi_hal.h +++ b/tools/sdk/esp32/include/hal/include/hal/spi_hal.h @@ -38,6 +38,7 @@ #include #include "soc/lldesc.h" #include "soc/soc_caps.h" +#include "hal/spi_types.h" /** * Input parameters to the ``spi_hal_cal_clock_conf`` to calculate the timing configuration @@ -100,7 +101,7 @@ typedef struct { uint64_t addr; ///< Address value to be sent uint8_t *send_buffer; ///< Data to be sent uint8_t *rcv_buffer; ///< Buffer to hold the receive data. - spi_ll_io_mode_t io_mode; ///< IO mode of the master + spi_line_mode_t line_mode; ///< SPI line mode of this transaction int cs_keep_active; ///< Keep CS active after transaction } spi_hal_trans_config_t; diff --git a/tools/sdk/esp32/include/hal/include/hal/spi_types.h b/tools/sdk/esp32/include/hal/include/hal/spi_types.h index 400b922a5c6..169069c5c62 100644 --- a/tools/sdk/esp32/include/hal/include/hal/spi_types.h +++ b/tools/sdk/esp32/include/hal/include/hal/spi_types.h @@ -14,8 +14,9 @@ #pragma once +#include #include "esp_attr.h" -#include +#include "esp_bit_defs.h" #include "soc/soc_caps.h" #include "sdkconfig.h" @@ -45,6 +46,15 @@ typedef enum { } spi_event_t; FLAG_ATTR(spi_event_t) +/** + * @brief Line mode of SPI transaction phases: CMD, ADDR, DOUT/DIN. + */ +typedef struct { + uint8_t cmd_lines; ///< The line width of command phase, e.g. 2-line-cmd-phase. + uint8_t addr_lines; ///< The line width of address phase, e.g. 1-line-addr-phase. + uint8_t data_lines; ///< The line width of data phase, e.g. 4-line-data-phase. +} spi_line_mode_t; + /** @cond */ //Doxy command to hide preprocessor definitions from docs */ diff --git a/tools/sdk/esp32/include/hal/include/hal/timer_hal.h b/tools/sdk/esp32/include/hal/include/hal/timer_hal.h index f8c91739d91..cb3d5e0671d 100644 --- a/tools/sdk/esp32/include/hal/include/hal/timer_hal.h +++ b/tools/sdk/esp32/include/hal/include/hal/timer_hal.h @@ -59,6 +59,15 @@ void timer_hal_init(timer_hal_context_t *hal, timer_group_t group_num, timer_idx */ void timer_hal_get_status_reg_mask_bit(timer_hal_context_t *hal, uint32_t *status_reg, uint32_t *mask_bit); +/** + * @brief Reset timer peripheral + * + * @param hal Context of the HAL layer + * + * @return None + */ +void timer_hal_reset_periph(timer_hal_context_t *hal); + /** * @brief Set timer clock prescale value * diff --git a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/uhci_types.h b/tools/sdk/esp32/include/hal/include/hal/uhci_types.h similarity index 100% rename from tools/sdk/esp32c3/include/hal/esp32c3/include/hal/uhci_types.h rename to tools/sdk/esp32/include/hal/include/hal/uhci_types.h index 7b7f41d0f94..7122e2a41a9 100644 --- a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/uhci_types.h +++ b/tools/sdk/esp32/include/hal/include/hal/uhci_types.h @@ -19,13 +19,13 @@ #pragma once +#include +#include + #ifdef __cplusplus extern "C" { #endif -#include -#include - /** * @brief UHCI escape sequence */ diff --git a/tools/sdk/esp32/include/hal/include/hal/usb_phy_hal.h b/tools/sdk/esp32/include/hal/include/hal/usb_phy_hal.h new file mode 100644 index 00000000000..fe77eb87446 --- /dev/null +++ b/tools/sdk/esp32/include/hal/include/hal/usb_phy_hal.h @@ -0,0 +1,81 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "usb_types_private.h" +#include "usb_phy_types.h" +#include "soc/soc_caps.h" +#include "soc/usb_wrap_struct.h" +#if SOC_USB_SERIAL_JTAG_SUPPORTED +#include "soc/usb_serial_jtag_struct.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Context that should be maintained by both the driver and the HAL + */ +typedef struct { + usb_wrap_dev_t *wrap_dev; /**< Pointer to base address of USB Wrapper registers */ +#if SOC_USB_SERIAL_JTAG_SUPPORTED + usb_serial_jtag_dev_t *jtag_dev; /**< Pointer to base address of USB Serial JTAG registers */ +#endif +} usb_phy_hal_context_t; + +/** + * @brief Init the USB PHY hal. This function should be called first before other hal layer function is called + * + * @param hal Context of the HAL layer + */ +void usb_phy_hal_init(usb_phy_hal_context_t *hal); + +/** + * @brief Configure internal/external PHY for USB_OTG + * + * @param hal Context of the HAL layer + * @param phy_target USB PHY target + */ +void usb_phy_hal_otg_conf(usb_phy_hal_context_t *hal, usb_phy_target_t phy_target); + +#if SOC_USB_SERIAL_JTAG_SUPPORTED +/** + * @brief Configure internal/external PHY for USB_Serial_JTAG + * + * @param hal Context of the HAL layer + * @param phy_target USB PHY target + */ +void usb_phy_hal_jtag_conf(usb_phy_hal_context_t *hal, usb_phy_target_t phy_target); +#endif + +/** + * @brief Configure pullup/pulldown loads for the D+/D- as a host + * + * @param hal Context of the HAL layer + */ +void usb_phy_hal_int_load_conf_host(usb_phy_hal_context_t *hal); + +/** + * @brief Configure pullup/pulldown loads for the D+/D- as a device + * + * @param hal Context of the HAL layer + * @param speed USB speed + */ +void usb_phy_hal_int_load_conf_dev(usb_phy_hal_context_t *hal, usb_priv_speed_t speed); + +/** + * @brief Enable/Disable test mode for internal PHY to mimick host-device disconnection + * + * @param hal Context of the HAL layer + * @param disconn Whether to disconnect + */ +void usb_phy_hal_int_mimick_disconn(usb_phy_hal_context_t *hal, bool disconn); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32/include/hal/include/hal/usb_phy_types.h b/tools/sdk/esp32/include/hal/include/hal/usb_phy_types.h new file mode 100644 index 00000000000..1f5ac431efa --- /dev/null +++ b/tools/sdk/esp32/include/hal/include/hal/usb_phy_types.h @@ -0,0 +1,63 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* +Note: This header file contains USB2.0 related types and macros that can be used by code specific to the DWC_OTG +controller (i.e., the HW specific layers of the USB host stack). Thus, this header is only meant to be used below (and +including) the HAL layer. For types and macros that are HW implementation agnostic (i.e., HCD layer and above), add them +to the "usb/usb_types_ch9.h" header instead. +*/ + +#pragma once + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** + * @brief USB PHY target + */ +typedef enum { + USB_PHY_TARGET_INT, /**< USB target is internal PHY */ + USB_PHY_TARGET_EXT, /**< USB target is external PHY */ + USB_PHY_TARGET_MAX, +} usb_phy_target_t; + +/** + * @brief USB PHY source + */ +typedef enum { + USB_PHY_CTRL_OTG, /**< PHY controller is USB OTG */ +#if SOC_USB_SERIAL_JTAG_SUPPORTED + USB_PHY_CTRL_SERIAL_JTAG, /**< PHY controller is USB Serial JTAG */ +#endif + USB_PHY_CTRL_MAX, +} usb_phy_controller_t; + +/** + * @brief USB OTG mode + */ +typedef enum { + USB_PHY_MODE_DEFAULT, /**< USB OTG default mode */ + USB_OTG_MODE_HOST, /**< USB OTG host mode */ + USB_OTG_MODE_DEVICE, /**< USB OTG device mode */ + USB_OTG_MODE_MAX, +} usb_otg_mode_t; + +/** + * @brief USB speed + */ +typedef enum { + USB_PHY_SPEED_UNDEFINED, + USB_PHY_SPEED_LOW, /**< USB Low Speed (1.5 Mbit/s) */ + USB_PHY_SPEED_FULL, /**< USB Full Speed (12 Mbit/s) */ + USB_PHY_SPEED_MAX, +} usb_phy_speed_t; + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32/include/hal/include/hal/usb_types_private.h b/tools/sdk/esp32/include/hal/include/hal/usb_types_private.h index 868fdee5891..5cce6b66af4 100644 --- a/tools/sdk/esp32/include/hal/include/hal/usb_types_private.h +++ b/tools/sdk/esp32/include/hal/include/hal/usb_types_private.h @@ -16,7 +16,7 @@ Note: This header file contains USB2.0 related types and macros that can be used by code specific to the DWC_OTG controller (i.e., the HW specific layers of the USB host stack). Thus, this header is only meant to be used below (and including) the HAL layer. For types and macros that are HW implementation agnostic (i.e., HCD layer and above), add them -to the "usb.h" header instead. +to the "usb/usb_types_ch9.h" header instead. */ #pragma once diff --git a/tools/sdk/esp32/include/hal/include/hal/usbh_hal.h b/tools/sdk/esp32/include/hal/include/hal/usbh_hal.h index 1ff721c373b..b315f6c0b14 100644 --- a/tools/sdk/esp32/include/hal/include/hal/usbh_hal.h +++ b/tools/sdk/esp32/include/hal/include/hal/usbh_hal.h @@ -151,7 +151,7 @@ typedef struct { //Channel control, status, and information union { struct { - uint32_t active: 1; /**< The channel is enabled */ + uint32_t active: 1; /**< Debugging bit to indicate whether channel is enabled */ uint32_t halt_requested: 1; /**< A halt has been requested */ uint32_t error_pending: 1; /**< The channel is waiting for the error to be handled */ uint32_t reserved: 1; @@ -811,6 +811,8 @@ usbh_hal_chan_t *usbh_hal_get_chan_pending_intr(usbh_hal_context_t *hal); * - Returns the corresponding event for that channel * * @param chan_obj Channel object + * @note If the host port has an error (e.g., a sudden disconnect or an port error), any active channels will not + * receive an interrupt. Each active channel must be manually halted. * @return usbh_hal_chan_event_t Channel event */ usbh_hal_chan_event_t usbh_hal_chan_decode_intr(usbh_hal_chan_t *chan_obj); diff --git a/tools/sdk/esp32/include/hal/include/hal/xt_wdt_hal.h b/tools/sdk/esp32/include/hal/include/hal/xt_wdt_hal.h new file mode 100644 index 00000000000..bd08f2a989f --- /dev/null +++ b/tools/sdk/esp32/include/hal/include/hal/xt_wdt_hal.h @@ -0,0 +1,61 @@ +/* + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include +#include + +#include "hal/xt_wdt_ll.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + rtc_cntl_dev_t *dev; /* Pointer to the RTC register struct */ +} xt_wdt_hal_context_t; /* HAL context struct */ + +typedef struct { + uint32_t timeout; /* Watchdog timer timeout in RTC_CLK cycles*/ +} xt_wdt_hal_config_t; /* HAL config parameter struct */ + +/* ---------------------------- Init and Config ----------------------------- */ + +/** + * @brief Initialize the WDTs associated HAL context + * + * Prepares the register for enabling the WDT and sets the timeout value + * + * @param hal Pointer to the HAL layer context + * @param config Pointer to config struct + */ +void xt_wdt_hal_init(xt_wdt_hal_context_t *hal, const xt_wdt_hal_config_t *config); + + +/** + * @brief Enable or disable the WDT + * + * @param hal Pointer to the HAL layer context + * @param enable true for enable WDT, false for disable + */ +void xt_wdt_hal_enable(xt_wdt_hal_context_t *hal, bool enable); + +/** + * @brief Enable the automatic RTC backup clock with the given frequency + * + * Calculates and sets the necessary hardware parameters to meet the desired + * backup clock frequency + * + * @param hal Pointer to the HAL layer context + * @param rtc_clk_frequency_khz desired frequency for the backup clock + * @return uint32_t the calculated clock factor value + */ +uint32_t xt_wdt_hal_enable_backup_clk(xt_wdt_hal_context_t *hal, uint32_t rtc_clk_frequency_khz); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32/include/hal/platform_port/include/hal/log.h b/tools/sdk/esp32/include/hal/platform_port/include/hal/log.h index 28bde429d49..6d5cbda3817 100644 --- a/tools/sdk/esp32/include/hal/platform_port/include/hal/log.h +++ b/tools/sdk/esp32/include/hal/platform_port/include/hal/log.h @@ -21,3 +21,9 @@ #define HAL_LOGI(...) ESP_LOGI(__VA_ARGS__) #define HAL_LOGD(...) ESP_LOGD(__VA_ARGS__) #define HAL_LOGV(...) ESP_LOGV(__VA_ARGS__) + +#define HAL_EARLY_LOGE(...) ESP_EARLY_LOGE(__VA_ARGS__) +#define HAL_EARLY_LOGW(...) ESP_EARLY_LOGW(__VA_ARGS__) +#define HAL_EARLY_LOGI(...) ESP_EARLY_LOGI(__VA_ARGS__) +#define HAL_EARLY_LOGD(...) ESP_EARLY_LOGD(__VA_ARGS__) +#define HAL_EARLY_LOGV(...) ESP_EARLY_LOGV(__VA_ARGS__) diff --git a/tools/sdk/esp32/include/hal/platform_port/include/hal/misc.h b/tools/sdk/esp32/include/hal/platform_port/include/hal/misc.h index 472ec8be2a3..4afb49653ff 100644 --- a/tools/sdk/esp32/include/hal/platform_port/include/hal/misc.h +++ b/tools/sdk/esp32/include/hal/platform_port/include/hal/misc.h @@ -16,3 +16,44 @@ #define HAL_SWAP16(d) __builtin_bswap16((d)) #define HAL_SWAP32(d) __builtin_bswap32((d)) #define HAL_SWAP64(d) __builtin_bswap64((d)) + +/** @cond */ //Doxy command to hide preprocessor definitions from docs */ + +/** + * @brief Macro to force a 32-bit read, modify, then write on a peripheral register + * + * Due to a GCC bug, the compiler may still try to optimize read/writes to peripheral register fields by using 8/16 bit + * access, even if they are marked volatile (i.e., -fstrict-volatile-bitfields has no effect). + * + * For ESP chips, the peripheral bus only allows 32-bit read/writes. The following macro works around the compiler issue + * by forcing a 32-bit read/modify/write. + * + * @note This macro should only be called on register fields of xxx_struct.h type headers, as it depends on the presence + * of a 'val' field of the register union. + * @note Current implementation reads into a uint32_t instead of copy base_reg direclty to temp_reg. The reason being + * that C++ does not create a copy constructor for volatile structs. + */ +#define HAL_FORCE_MODIFY_U32_REG_FIELD(base_reg, reg_field, field_val) \ +{ \ + uint32_t temp_val = base_reg.val; \ + typeof(base_reg) temp_reg; \ + temp_reg.val = temp_val; \ + temp_reg.reg_field = (field_val); \ + (base_reg).val = temp_reg.val; \ +} + +/** + * @brief Macro to force a 32-bit read on a peripheral register + * + * @note This macro should only be called on register fields of xxx_struct.h type headers. See description above for + * more details. + * @note Current implementation reads into a uint32_t. See description above for more details. + */ +#define HAL_FORCE_READ_U32_REG_FIELD(base_reg, reg_field) ({ \ + uint32_t temp_val = base_reg.val; \ + typeof(base_reg) temp_reg; \ + temp_reg.val = temp_val; \ + temp_reg.reg_field; \ +}) + +/** @endcond */ diff --git a/tools/sdk/esp32/include/idf_test/include/idf_performance.h b/tools/sdk/esp32/include/idf_test/include/idf_performance.h index 18816813a78..9d99070b953 100644 --- a/tools/sdk/esp32/include/idf_test/include/idf_performance.h +++ b/tools/sdk/esp32/include/idf_test/include/idf_performance.h @@ -50,6 +50,20 @@ #define IDF_PERFORMANCE_MIN_UDP_TX_THROUGHPUT 50 #endif +// throughput performance by ethernet iperf +#ifndef IDF_PERFORMANCE_MIN_TCP_RX_ETH_THROUGHPUT +#define IDF_PERFORMANCE_MIN_TCP_RX_ETH_THROUGHPUT 20 +#endif +#ifndef IDF_PERFORMANCE_MIN_TCP_TX_ETH_THROUGHPUT +#define IDF_PERFORMANCE_MIN_TCP_TX_ETH_THROUGHPUT 30 +#endif +#ifndef IDF_PERFORMANCE_MIN_UDP_RX_ETH_THROUGHPUT +#define IDF_PERFORMANCE_MIN_UDP_RX_ETH_THROUGHPUT 50 +#endif +#ifndef IDF_PERFORMANCE_MIN_UDP_TX_ETH_THROUGHPUT +#define IDF_PERFORMANCE_MIN_UDP_TX_ETH_THROUGHPUT 70 +#endif + // events dispatched per second by event loop library #ifndef IDF_PERFORMANCE_MIN_EVENT_DISPATCH #define IDF_PERFORMANCE_MIN_EVENT_DISPATCH 25000 diff --git a/tools/sdk/esp32/include/ieee802154/include/esp_ieee802154.h b/tools/sdk/esp32/include/ieee802154/include/esp_ieee802154.h index a8d4678e924..e31a5ca37e5 100644 --- a/tools/sdk/esp32/include/ieee802154/include/esp_ieee802154.h +++ b/tools/sdk/esp32/include/ieee802154/include/esp_ieee802154.h @@ -192,6 +192,24 @@ void esp_ieee802154_get_extended_address(uint8_t *ext_addr); */ void esp_ieee802154_set_extended_address(const uint8_t *ext_addr); +/** + * @brief Get the device coordinator. + * + * @return + * - True The coordinator is enabled. + * - False The coordinator is disabled. + * + */ +bool esp_ieee802154_get_coordinator(void); + +/** + * @brief Set the device coordinator role. + * + * @param[in] enable The coordinator role to be set. + * + */ +void esp_ieee802154_set_coordinator(bool enable); + /** * @brief Get the auto frame pending mode. * diff --git a/tools/sdk/esp32/include/ieee802154/include/esp_ieee802154_types.h b/tools/sdk/esp32/include/ieee802154/include/esp_ieee802154_types.h index 6979991cc32..823e3cdcf3f 100644 --- a/tools/sdk/esp32/include/ieee802154/include/esp_ieee802154_types.h +++ b/tools/sdk/esp32/include/ieee802154/include/esp_ieee802154_types.h @@ -41,6 +41,8 @@ typedef enum { ESP_IEEE802154_TX_ERR_NO_ACK, /*!< No Ack frame received until timeout */ ESP_IEEE802154_TX_ERR_INVALID_ACK, /*!< Invalid Ack frame */ ESP_IEEE802154_TX_ERR_COEXIST, /*!< Rejected by coexist system */ + ESP_IEEE802154_TX_ERR_COEXIST_REJ, /*!< Rejected by coexist system before transmitting frame */ + ESP_IEEE802154_TX_ERR_COEXIST_ACK, /*!< Rejected by coexist system when receiving ack */ } esp_ieee802154_tx_error_t; /** @@ -60,6 +62,7 @@ typedef enum { ESP_IEEE802154_AUTO_PENDING_DISABLE, /*!< Frame pending bit always set to 1 in the ack to Data Request */ ESP_IEEE802154_AUTO_PENDING_ENABLE, /*!< Frame pending bit set to 1 if src address matches, in the ack to Data Request */ ESP_IEEE802154_AUTO_PENDING_ENHANCED, /*!< Frame pending bit set to 1 if src address matches, in all ack frames */ + ESP_IEEE802154_AUTO_PENDING_ZIGBEE, /*!< Frame pending bit set to 0 only if src address is short address and matches in table, in the ack to Data Request */ } esp_ieee802154_pending_mode_t; /** diff --git a/tools/sdk/esp32/include/json/cJSON/cJSON.h b/tools/sdk/esp32/include/json/cJSON/cJSON.h index e97e5f4cdc4..92907a2cd38 100644 --- a/tools/sdk/esp32/include/json/cJSON/cJSON.h +++ b/tools/sdk/esp32/include/json/cJSON/cJSON.h @@ -81,7 +81,7 @@ then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJ /* project version */ #define CJSON_VERSION_MAJOR 1 #define CJSON_VERSION_MINOR 7 -#define CJSON_VERSION_PATCH 14 +#define CJSON_VERSION_PATCH 15 #include @@ -256,7 +256,7 @@ CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * cons /* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from strings. * The input pointer json cannot point to a read-only address area, such as a string constant, - * but should point to a readable and writable adress area. */ + * but should point to a readable and writable address area. */ CJSON_PUBLIC(void) cJSON_Minify(char *json); /* Helper functions for creating and adding items to an object at the same time. diff --git a/tools/sdk/esp32/include/log/include/esp_log.h b/tools/sdk/esp32/include/log/include/esp_log.h index cf7bcd601a2..0e3148f62dc 100644 --- a/tools/sdk/esp32/include/log/include/esp_log.h +++ b/tools/sdk/esp32/include/log/include/esp_log.h @@ -10,9 +10,7 @@ #include #include #include "sdkconfig.h" -#if !defined(CONFIG_IDF_TARGET_LINUX) #include "esp_rom_sys.h" -#endif // !CONFIG_IDF_TARGET_LINUX #if CONFIG_IDF_TARGET_ESP32 #include "esp32/rom/ets_sys.h" // will be removed in idf v5.0 #elif CONFIG_IDF_TARGET_ESP32S2 @@ -90,6 +88,9 @@ esp_log_level_t esp_log_level_get(const char* tag); * output to some other destination, such as file or network. Returns the original * log handler, which may be necessary to return output to the previous destination. * + * @note Please note that function callback here must be re-entrant as it can be + * invoked in parallel from multiple thread context. + * * @param func new Function used for output. Must have same signature as vprintf. * * @return func old Function used for output. diff --git a/tools/sdk/esp32/include/lwip/include/apps/dhcpserver/dhcpserver.h b/tools/sdk/esp32/include/lwip/include/apps/dhcpserver/dhcpserver.h index 39a58bbfa94..262ebf43d85 100644 --- a/tools/sdk/esp32/include/lwip/include/apps/dhcpserver/dhcpserver.h +++ b/tools/sdk/esp32/include/lwip/include/apps/dhcpserver/dhcpserver.h @@ -17,6 +17,10 @@ #include "sdkconfig.h" #include "lwip/ip_addr.h" +#ifdef __cplusplus +extern "C" { +#endif + typedef struct dhcps_state{ s16_t state; } dhcps_state; @@ -91,4 +95,8 @@ void dhcps_dns_setserver(const ip_addr_t *dnsserver); ip4_addr_t dhcps_dns_getserver(void); void dhcps_set_new_lease_cb(dhcps_cb_t cb); +#ifdef __cplusplus +} #endif + +#endif /* __DHCPS_H__ */ diff --git a/tools/sdk/esp32/include/lwip/include/apps/dhcpserver/dhcpserver_options.h b/tools/sdk/esp32/include/lwip/include/apps/dhcpserver/dhcpserver_options.h index 38d46f6bff2..31a67992831 100644 --- a/tools/sdk/esp32/include/lwip/include/apps/dhcpserver/dhcpserver_options.h +++ b/tools/sdk/esp32/include/lwip/include/apps/dhcpserver/dhcpserver_options.h @@ -13,6 +13,9 @@ // limitations under the License. #pragma once +#ifdef __cplusplus +extern "C" { +#endif /** DHCP Options This macros are not part of the public dhcpserver.h interface. @@ -132,3 +135,7 @@ typedef enum DOMAIN_SEARCH = 119, CLASSLESS_ROUTE = 121, } dhcp_msg_option; + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32/include/lwip/port/esp32/include/lwipopts.h b/tools/sdk/esp32/include/lwip/port/esp32/include/lwipopts.h index 72e2bc4a97a..4bc2ad13960 100644 --- a/tools/sdk/esp32/include/lwip/port/esp32/include/lwipopts.h +++ b/tools/sdk/esp32/include/lwip/port/esp32/include/lwipopts.h @@ -33,9 +33,7 @@ #define __LWIPOPTS_H__ #include -#include #include -#include #include #include #include @@ -44,6 +42,7 @@ #include "esp_system.h" #include "sdkconfig.h" #include "netif/dhcp_state.h" +#include "sntp/sntp_get_set_time.h" /* Enable all Espressif-only options */ @@ -595,7 +594,7 @@ * LWIP_TCPIP_CORE_LOCKING: (EXPERIMENTAL!) * Don't use it if you're not an active lwIP project member */ -#define LWIP_TCPIP_CORE_LOCKING 0 +#define LWIP_TCPIP_CORE_LOCKING CONFIG_LWIP_TCPIP_CORE_LOCKING /* ------------------------------------ @@ -910,6 +909,15 @@ #define TCP_DEBUG LWIP_DBG_OFF #endif +/** + * SNTP_DEBUG: Enable debugging for SNTP. + */ +#ifdef CONFIG_LWIP_SNTP_DEBUG +#define SNTP_DEBUG LWIP_DBG_ON +#else +#define SNTP_DEBUG LWIP_DBG_OFF +#endif + /** * MEMP_DEBUG: Enable debugging in memp.c. */ @@ -970,6 +978,8 @@ #define LWIP_ND6_RDNSS_MAX_DNS_SERVERS CONFIG_LWIP_IPV6_RDNSS_MAX_DNS_SERVERS +#define LWIP_IPV6_DHCP6 CONFIG_LWIP_IPV6_DHCP6 + /* Enable all Espressif-only options */ #define ESP_LWIP 1 @@ -1044,7 +1054,11 @@ #define CHECKSUM_CHECK_ICMP CONFIG_LWIP_CHECKSUM_CHECK_ICMP #define LWIP_NETCONN_FULLDUPLEX 1 +#if LWIP_TCPIP_CORE_LOCKING +#define LWIP_NETCONN_SEM_PER_THREAD 0 +#else #define LWIP_NETCONN_SEM_PER_THREAD 1 +#endif /* LWIP_TCPIP_CORE_LOCKING */ #define LWIP_DHCP_MAX_NTP_SERVERS CONFIG_LWIP_DHCP_MAX_NTP_SERVERS #define LWIP_TIMEVAL_PRIVATE 0 @@ -1054,25 +1068,15 @@ ------------ SNTP options ------------ -------------------------------------- */ -/* - * SNTP update delay - in milliseconds - */ - -/* - * Forward declarations of weak definitions from lwip's sntp.c which could - * be redefined by user application. This is needed to provide custom definition - * of the below macros in lwip's sntp.c. - * Full declaration is provided in IDF's port layer in esp_sntp.h - */ -#ifdef __cplusplus -#define LWIP_FORWARD_DECLARE_C_CXX extern "C" -#else -#define LWIP_FORWARD_DECLARE_C_CXX -#endif -LWIP_FORWARD_DECLARE_C_CXX void sntp_sync_time(struct timeval *tv); +// Max number of SNTP servers handled (default equal to LWIP_DHCP_MAX_NTP_SERVERS) +#if defined CONFIG_LWIP_SNTP_MAX_SERVERS +#define SNTP_MAX_SERVERS CONFIG_LWIP_SNTP_MAX_SERVERS +#endif // CONFIG_LWIP_SNTP_MAX_SERVERS -LWIP_FORWARD_DECLARE_C_CXX uint32_t sntp_get_sync_interval(void); +#ifdef CONFIG_LWIP_DHCP_GET_NTP_SRV +#define LWIP_DHCP_GET_NTP_SRV CONFIG_LWIP_DHCP_GET_NTP_SRV +#endif // CONFIG_LWIP_DHCP_GET_NTP_SRV /** Set this to 1 to support DNS names (or IP address strings) to set sntp servers * One server address/name can be defined as default if SNTP_SERVER_DNS == 1: @@ -1083,22 +1087,9 @@ LWIP_FORWARD_DECLARE_C_CXX uint32_t sntp_get_sync_interval(void); // It disables a check of SNTP_UPDATE_DELAY it is done in sntp_set_sync_interval #define SNTP_SUPPRESS_DELAY_CHECK -#define SNTP_UPDATE_DELAY (sntp_get_sync_interval()) - -#define SNTP_SET_SYSTEM_TIME_US(sec, us) \ - do { \ - struct timeval tv = { .tv_sec = sec, .tv_usec = us }; \ - sntp_sync_time(&tv); \ - } while (0); - -#define SNTP_GET_SYSTEM_TIME(sec, us) \ - do { \ - struct timeval tv = { .tv_sec = 0, .tv_usec = 0 }; \ - gettimeofday(&tv, NULL); \ - (sec) = tv.tv_sec; \ - (us) = tv.tv_usec; \ - sntp_set_sync_status(SNTP_SYNC_STATUS_RESET); \ - } while (0); +#define SNTP_UPDATE_DELAY (sntp_get_sync_interval()) +#define SNTP_SET_SYSTEM_TIME_US(sec, us) (sntp_set_system_time(sec, us)) +#define SNTP_GET_SYSTEM_TIME(sec, us) (sntp_get_system_time(&(sec), &(us))) #define SOC_SEND_LOG //printf diff --git a/tools/sdk/esp32/include/lwip/port/esp32/include/sntp/sntp_get_set_time.h b/tools/sdk/esp32/include/lwip/port/esp32/include/sntp/sntp_get_set_time.h new file mode 100644 index 00000000000..19916208044 --- /dev/null +++ b/tools/sdk/esp32/include/lwip/port/esp32/include/sntp/sntp_get_set_time.h @@ -0,0 +1,55 @@ +// Copyright 2021 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 __SNTP_GET_SET_TIME_H__ +#define __SNTP_GET_SET_TIME_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * Declarations of functions used in lwipopts.h to redefine + * default sntp macros, such as: + * - SNTP_UPDATE_DELAY() + * - SNTP_SET_SYSTEM_TIME_US() + * - SNTP_GET_SYSTEM_TIME() + */ + +/* + * @brief Get the sync interval of SNTP operation + * Full definition is provided in IDF's layer in esp_sntp.c + */ +uint32_t sntp_get_sync_interval(void); + +/** + * @brief system time setter used in the sntp module + * @note The lwip sntp uses u32_t types for sec and us arguments + */ +void sntp_set_system_time(uint32_t sec, uint32_t us); + +/** + * @brief system time getter used in the sntp module + * @note The lwip sntp uses u32_t types for sec and us arguments + */ +void sntp_get_system_time(uint32_t* sec, uint32_t* us); + +#ifdef __cplusplus +} +#endif + +#endif //__SNTP_GET_SET_TIME_H__ diff --git a/tools/sdk/esp32/include/mdns/include/mdns.h b/tools/sdk/esp32/include/mdns/include/mdns.h index 7089eabe6a9..4bb288d4174 100644 --- a/tools/sdk/esp32/include/mdns/include/mdns.h +++ b/tools/sdk/esp32/include/mdns/include/mdns.h @@ -75,10 +75,13 @@ typedef struct mdns_result_s { struct mdns_result_s * next; /*!< next result, or NULL for the last result in the list */ mdns_if_t tcpip_if; /*!< interface index */ + uint32_t ttl; /*!< time to live */ mdns_ip_protocol_t ip_protocol; /*!< ip_protocol type of the interface (v4/v6) */ // PTR char * instance_name; /*!< instance name */ + char * service_type; /*!< service type */ + char * proto; /*!< srevice protocol */ // SRV char * hostname; /*!< hostname */ uint16_t port; /*!< service port */ @@ -90,6 +93,8 @@ typedef struct mdns_result_s { mdns_ip_addr_t * addr; /*!< linked list of IP addresses found */ } mdns_result_t; +typedef void (*mdns_query_notify_t)(mdns_search_once_t *search); + /** * @brief Initialize mDNS on given interface * @@ -519,11 +524,13 @@ bool mdns_query_async_get_results(mdns_search_once_t* search, uint32_t timeout, * @param type type of query (MDNS_TYPE_*) * @param timeout time in milliseconds during which mDNS query is active * @param max_results maximum results to be collected + * @param notifier Notification function to be called when the result is ready, can be NULL * * @return mdns_search_once_s pointer to new search object if query initiated successfully. * NULL otherwise. */ -mdns_search_once_t* mdns_query_async_new(const char * name, const char * service_type, const char * proto, uint16_t type, uint32_t timeout, size_t max_results); +mdns_search_once_t *mdns_query_async_new(const char *name, const char *service_type, const char *proto, uint16_t type, + uint32_t timeout, size_t max_results, mdns_query_notify_t notifier); /** * @brief Query mDNS for host or service diff --git a/tools/sdk/esp32/include/newlib/platform_include/assert.h b/tools/sdk/esp32/include/newlib/platform_include/assert.h index 85222861480..39db39a6f04 100644 --- a/tools/sdk/esp32/include/newlib/platform_include/assert.h +++ b/tools/sdk/esp32/include/newlib/platform_include/assert.h @@ -19,6 +19,7 @@ #pragma once #include #include +#include #include_next @@ -31,16 +32,21 @@ */ #undef assert +/* __FILENAME__ points to the file name instead of path + filename + * e.g __FILE__ points to "/apps/test.c" where as __FILENAME__ points to "test.c" + */ +#define __FILENAME__ (__builtin_strrchr( "/" __FILE__, '/') + 1) + #if defined(NDEBUG) -# define assert(__e) ((void)(__e)) +#define assert(__e) ((void)(__e)) #elif CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT -#define assert(__e) __builtin_expect(!!(__e), 1) ? (void)0 : abort() +#define assert(__e) (__builtin_expect(!!(__e), 1) ? (void)0 : __assert_func(NULL, 0, NULL, NULL)) #else // !CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT -#define assert(__e) (__builtin_expect(!!(__e), 1) ? (void)0 : __assert_func (__FILE__, __LINE__, \ +#define assert(__e) (__builtin_expect(!!(__e), 1) ? (void)0 : __assert_func (__FILENAME__, __LINE__, \ __ASSERT_FUNC, #__e)) #endif diff --git a/tools/sdk/esp32/include/soc/esp32/include/soc/dport_reg.h b/tools/sdk/esp32/include/soc/esp32/include/soc/dport_reg.h index 727d181e1a4..367c9e43e02 100644 --- a/tools/sdk/esp32/include/soc/esp32/include/soc/dport_reg.h +++ b/tools/sdk/esp32/include/soc/esp32/include/soc/dport_reg.h @@ -1156,6 +1156,8 @@ #define DPORT_CPU_INTR_FROM_CPU_1_V 0x1 #define DPORT_CPU_INTR_FROM_CPU_1_S 0 +#define SYSTEM_CPU_INTR_FROM_CPU_2_REG DPORT_CPU_INTR_FROM_CPU_2_REG +#define SYSTEM_CPU_INTR_FROM_CPU_2 DPORT_CPU_INTR_FROM_CPU_2 #define DPORT_CPU_INTR_FROM_CPU_2_REG (DR_REG_DPORT_BASE + 0x0E4) /* DPORT_CPU_INTR_FROM_CPU_2 : R/W ;bitpos:[0] ;default: 1'b0 ; */ /*description: */ @@ -1164,6 +1166,8 @@ #define DPORT_CPU_INTR_FROM_CPU_2_V 0x1 #define DPORT_CPU_INTR_FROM_CPU_2_S 0 +#define SYSTEM_CPU_INTR_FROM_CPU_3_REG DPORT_CPU_INTR_FROM_CPU_3_REG +#define SYSTEM_CPU_INTR_FROM_CPU_3 DPORT_CPU_INTR_FROM_CPU_3 #define DPORT_CPU_INTR_FROM_CPU_3_REG (DR_REG_DPORT_BASE + 0x0E8) /* DPORT_CPU_INTR_FROM_CPU_3 : R/W ;bitpos:[0] ;default: 1'b0 ; */ /*description: */ diff --git a/tools/sdk/esp32/include/soc/esp32/include/soc/emac_dma_struct.h b/tools/sdk/esp32/include/soc/esp32/include/soc/emac_dma_struct.h index 35d13612818..1f9a9832e19 100644 --- a/tools/sdk/esp32/include/soc/esp32/include/soc/emac_dma_struct.h +++ b/tools/sdk/esp32/include/soc/esp32/include/soc/emac_dma_struct.h @@ -20,7 +20,7 @@ extern "C" #include -typedef volatile struct { +typedef volatile struct emac_dma_dev_s { union { struct { uint32_t sw_rst : 1; /*When this bit is set the MAC DMA Controller resets the logic and all internal registers of the MAC. It is cleared automatically after the reset operation is complete in all of the ETH_MAC clock domains. Before reprogramming any register of the ETH_MAC you should read a zero (0) value in this bit.*/ diff --git a/tools/sdk/esp32/include/soc/esp32/include/soc/emac_ext_struct.h b/tools/sdk/esp32/include/soc/esp32/include/soc/emac_ext_struct.h index 9b65c8d91c0..5d2e1fecf5c 100644 --- a/tools/sdk/esp32/include/soc/esp32/include/soc/emac_ext_struct.h +++ b/tools/sdk/esp32/include/soc/esp32/include/soc/emac_ext_struct.h @@ -19,7 +19,7 @@ extern "C" { #include -typedef volatile struct { +typedef volatile struct emac_ext_dev_s { union { struct { uint32_t div_num : 4; diff --git a/tools/sdk/esp32/include/soc/esp32/include/soc/emac_mac_struct.h b/tools/sdk/esp32/include/soc/esp32/include/soc/emac_mac_struct.h index b7f5b80ff50..a798b00f99f 100644 --- a/tools/sdk/esp32/include/soc/esp32/include/soc/emac_mac_struct.h +++ b/tools/sdk/esp32/include/soc/esp32/include/soc/emac_mac_struct.h @@ -19,7 +19,7 @@ extern "C" { #include -typedef volatile struct { +typedef volatile struct emac_mac_dev_s { union { struct { uint32_t pltf : 2; /*These bits control the number of preamble bytes that are added to the beginning of every Transmit frame. The preamble reduction occurs only when the MAC is operating in the full-duplex mode.2'b00: 7 bytes of preamble. 2'b01: 5 bytes of preamble. 2'b10: 3 bytes of preamble.*/ diff --git a/tools/sdk/esp32/include/soc/esp32/include/soc/gpio_sig_map.h b/tools/sdk/esp32/include/soc/esp32/include/soc/gpio_sig_map.h index b2114d85839..b079c9515e1 100644 --- a/tools/sdk/esp32/include/soc/esp32/include/soc/gpio_sig_map.h +++ b/tools/sdk/esp32/include/soc/esp32/include/soc/gpio_sig_map.h @@ -236,26 +236,8 @@ #define PWM1_CAP1_IN_IDX 113 #define PWM1_OUT2B_IDX 113 #define PWM1_CAP2_IN_IDX 114 -#define PWM2_OUT1H_IDX 114 -#define PWM2_FLTA_IDX 115 -#define PWM2_OUT1L_IDX 115 -#define PWM2_FLTB_IDX 116 -#define PWM2_OUT2H_IDX 116 -#define PWM2_CAP1_IN_IDX 117 -#define PWM2_OUT2L_IDX 117 -#define PWM2_CAP2_IN_IDX 118 -#define PWM2_OUT3H_IDX 118 -#define PWM2_CAP3_IN_IDX 119 -#define PWM2_OUT3L_IDX 119 -#define PWM3_FLTA_IDX 120 -#define PWM2_OUT4H_IDX 120 -#define PWM3_FLTB_IDX 121 -#define PWM2_OUT4L_IDX 121 -#define PWM3_CAP1_IN_IDX 122 -#define PWM3_CAP2_IN_IDX 123 #define TWAI_TX_IDX 123 #define CAN_TX_IDX TWAI_TX_IDX -#define PWM3_CAP3_IN_IDX 124 #define TWAI_BUS_OFF_ON_IDX 124 #define CAN_BUS_OFF_ON_IDX TWAI_BUS_OFF_ON_IDX #define TWAI_CLKOUT_IDX 125 @@ -369,19 +351,11 @@ #define I2S1O_DATA_OUT22_IDX 188 #define I2S1O_DATA_OUT23_IDX 189 #define I2S0I_H_SYNC_IDX 190 -#define PWM3_OUT1H_IDX 190 #define I2S0I_V_SYNC_IDX 191 -#define PWM3_OUT1L_IDX 191 #define I2S0I_H_ENABLE_IDX 192 -#define PWM3_OUT2H_IDX 192 #define I2S1I_H_SYNC_IDX 193 -#define PWM3_OUT2L_IDX 193 #define I2S1I_V_SYNC_IDX 194 -#define PWM3_OUT3H_IDX 194 #define I2S1I_H_ENABLE_IDX 195 -#define PWM3_OUT3L_IDX 195 -#define PWM3_OUT4H_IDX 196 -#define PWM3_OUT4L_IDX 197 #define U2RXD_IN_IDX 198 #define U2TXD_OUT_IDX 198 #define U2CTS_IN_IDX 199 diff --git a/tools/sdk/esp32/include/soc/esp32/include/soc/i2c_struct.h b/tools/sdk/esp32/include/soc/esp32/include/soc/i2c_struct.h index 3b17aeb463f..7e4afb06018 100644 --- a/tools/sdk/esp32/include/soc/esp32/include/soc/i2c_struct.h +++ b/tools/sdk/esp32/include/soc/esp32/include/soc/i2c_struct.h @@ -104,8 +104,8 @@ typedef volatile struct i2c_dev_s { } fifo_conf; union { struct { - uint8_t data; /*The register represent the byte data read from rx_fifo when use apb fifo access*/ - uint8_t reserved[3]; + uint32_t data: 8; /*The register represent the byte data read from rx_fifo when use apb fifo access*/ + uint32_t reserved: 24; }; uint32_t val; } fifo_data; diff --git a/tools/sdk/esp32/include/soc/esp32/include/soc/mcpwm_reg.h b/tools/sdk/esp32/include/soc/esp32/include/soc/mcpwm_reg.h index e919d16a704..6a370aa6910 100644 --- a/tools/sdk/esp32/include/soc/esp32/include/soc/mcpwm_reg.h +++ b/tools/sdk/esp32/include/soc/esp32/include/soc/mcpwm_reg.h @@ -1,3027 +1,3829 @@ -// 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 _SOC_MCPWM_REG_H_ -#define _SOC_MCPWM_REG_H_ -#include "soc.h" - -#define REG_MCPWM_BASE(i) (DR_REG_PWM0_BASE + i * (0xE000)) - -#define MCPWM_CLK_CFG_REG(i) (REG_MCPWM_BASE(i) + 0x0000) -/* MCPWM_CLK_PRESCALE : R/W ;bitpos:[7:0] ;default: 8'h0 ; */ -/*description: Period of PWM_clk = 6.25ns * (PWM_CLK_PRESCALE + 1)*/ -#define MCPWM_CLK_PRESCALE 0x000000FF -#define MCPWM_CLK_PRESCALE_M ((MCPWM_CLK_PRESCALE_V)<<(MCPWM_CLK_PRESCALE_S)) -#define MCPWM_CLK_PRESCALE_V 0xFF +/** + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#pragma once + +#include +#include "soc/soc.h" +#ifdef __cplusplus +extern "C" { +#endif + +#define DR_REG_MCPWM_BASE(i) (DR_REG_PWM0_BASE + i * (0xE000)) + +/** MCPWM_CLK_CFG_REG register + * PWM clock prescaler register. + */ +#define MCPWM_CLK_CFG_REG(i) (DR_REG_MCPWM_BASE(i) + 0x0) +/** MCPWM_CLK_PRESCALE : R/W; bitpos: [7:0]; default: 0; + * Period of PWM_clk = 6.25ns * (PWM_CLK_PRESCALE + 1) + */ +#define MCPWM_CLK_PRESCALE 0x000000FFU +#define MCPWM_CLK_PRESCALE_M (MCPWM_CLK_PRESCALE_V << MCPWM_CLK_PRESCALE_S) +#define MCPWM_CLK_PRESCALE_V 0x000000FFU #define MCPWM_CLK_PRESCALE_S 0 -#define MCPWM_TIMER0_CFG0_REG(i) (REG_MCPWM_BASE(i) + 0x0004) -/* MCPWM_TIMER0_PERIOD_UPMETHOD : R/W ;bitpos:[25:24] ;default: 2'd0 ; */ -/*description: Update method for active reg of PWM timer0 period 0: immediate - 1: TEZ 2: sync 3: TEZ or sync. TEZ here and below means timer equal zero event*/ -#define MCPWM_TIMER0_PERIOD_UPMETHOD 0x00000003 -#define MCPWM_TIMER0_PERIOD_UPMETHOD_M ((MCPWM_TIMER0_PERIOD_UPMETHOD_V)<<(MCPWM_TIMER0_PERIOD_UPMETHOD_S)) -#define MCPWM_TIMER0_PERIOD_UPMETHOD_V 0x3 -#define MCPWM_TIMER0_PERIOD_UPMETHOD_S 24 -/* MCPWM_TIMER0_PERIOD : R/W ;bitpos:[23:8] ;default: 16'h00ff ; */ -/*description: Period shadow reg of PWM timer0*/ -#define MCPWM_TIMER0_PERIOD 0x0000FFFF -#define MCPWM_TIMER0_PERIOD_M ((MCPWM_TIMER0_PERIOD_V)<<(MCPWM_TIMER0_PERIOD_S)) -#define MCPWM_TIMER0_PERIOD_V 0xFFFF -#define MCPWM_TIMER0_PERIOD_S 8 -/* MCPWM_TIMER0_PRESCALE : R/W ;bitpos:[7:0] ;default: 8'h0 ; */ -/*description: Period of PT0_clk = Period of PWM_clk * (PWM_TIMER0_PRESCALE + 1)*/ -#define MCPWM_TIMER0_PRESCALE 0x000000FF -#define MCPWM_TIMER0_PRESCALE_M ((MCPWM_TIMER0_PRESCALE_V)<<(MCPWM_TIMER0_PRESCALE_S)) -#define MCPWM_TIMER0_PRESCALE_V 0xFF +/** MCPWM_TIMER0_CFG0_REG register + * PWM timer0 period and update method configuration register. + */ +#define MCPWM_TIMER0_CFG0_REG(i) (DR_REG_MCPWM_BASE(i) + 0x4) +/** MCPWM_TIMER0_PRESCALE : R/W; bitpos: [7:0]; default: 0; + * Configure the divisor of PT0_clk, takes effect when PWM timer0 stops and starts + * agsin. period of PT0_clk = Period of PWM_clk * (PWM_TIMER0_PRESCALE + 1) + */ +#define MCPWM_TIMER0_PRESCALE 0x000000FFU +#define MCPWM_TIMER0_PRESCALE_M (MCPWM_TIMER0_PRESCALE_V << MCPWM_TIMER0_PRESCALE_S) +#define MCPWM_TIMER0_PRESCALE_V 0x000000FFU #define MCPWM_TIMER0_PRESCALE_S 0 +/** MCPWM_TIMER0_PERIOD : R/W; bitpos: [23:8]; default: 255; + * period shadow register of PWM timer0 + */ +#define MCPWM_TIMER0_PERIOD 0x0000FFFFU +#define MCPWM_TIMER0_PERIOD_M (MCPWM_TIMER0_PERIOD_V << MCPWM_TIMER0_PERIOD_S) +#define MCPWM_TIMER0_PERIOD_V 0x0000FFFFU +#define MCPWM_TIMER0_PERIOD_S 8 +/** MCPWM_TIMER0_PERIOD_UPMETHOD : R/W; bitpos: [25:24]; default: 0; + * Update method for active register of PWM timer0 period, 0: immediate, 1: TEZ, 2: + * sync, 3: TEZ or sync. TEZ here and below means timer equal zero event + */ +#define MCPWM_TIMER0_PERIOD_UPMETHOD 0x00000003U +#define MCPWM_TIMER0_PERIOD_UPMETHOD_M (MCPWM_TIMER0_PERIOD_UPMETHOD_V << MCPWM_TIMER0_PERIOD_UPMETHOD_S) +#define MCPWM_TIMER0_PERIOD_UPMETHOD_V 0x00000003U +#define MCPWM_TIMER0_PERIOD_UPMETHOD_S 24 -#define MCPWM_TIMER0_CFG1_REG(i) (REG_MCPWM_BASE(i) + 0x0008) -/* MCPWM_TIMER0_MOD : R/W ;bitpos:[4:3] ;default: 2'h0 ; */ -/*description: PWM timer0 working mode 0: freeze 1: increase mod 2: decrease - mod 3: up-down mod*/ -#define MCPWM_TIMER0_MOD 0x00000003 -#define MCPWM_TIMER0_MOD_M ((MCPWM_TIMER0_MOD_V)<<(MCPWM_TIMER0_MOD_S)) -#define MCPWM_TIMER0_MOD_V 0x3 -#define MCPWM_TIMER0_MOD_S 3 -/* MCPWM_TIMER0_START : R/W ;bitpos:[2:0] ;default: 3'h0 ; */ -/*description: PWM timer0 start and stop control. 0: stop @ TEZ 1: stop @ TEP - 2: free run 3: start and stop @ next TEZ 4: start and stop @ next TEP. TEP here and below means timer equal period event*/ -#define MCPWM_TIMER0_START 0x00000007 -#define MCPWM_TIMER0_START_M ((MCPWM_TIMER0_START_V)<<(MCPWM_TIMER0_START_S)) -#define MCPWM_TIMER0_START_V 0x7 +/** MCPWM_TIMER0_CFG1_REG register + * PWM timer0 working mode and start/stop control configuration register. + */ +#define MCPWM_TIMER0_CFG1_REG(i) (DR_REG_MCPWM_BASE(i) + 0x8) +/** MCPWM_TIMER0_START : R/W/SC; bitpos: [2:0]; default: 0; + * PWM timer0 start and stop control. 0: if PWM timer0 starts, then stops at TEZ, 1: + * if timer0 starts, then stops at TEP, 2: PWM timer0 starts and runs on, 3: timer0 + * starts and stops at the next TEZ, 4: timer0 starts and stops at the next TEP. TEP + * here and below means the event that happens when the timer equals to period + */ +#define MCPWM_TIMER0_START 0x00000007U +#define MCPWM_TIMER0_START_M (MCPWM_TIMER0_START_V << MCPWM_TIMER0_START_S) +#define MCPWM_TIMER0_START_V 0x00000007U #define MCPWM_TIMER0_START_S 0 +/** MCPWM_TIMER0_MOD : R/W; bitpos: [4:3]; default: 0; + * PWM timer0 working mode, 0: freeze, 1: increase mode, 2: decrease mode, 3: up-down + * mode + */ +#define MCPWM_TIMER0_MOD 0x00000003U +#define MCPWM_TIMER0_MOD_M (MCPWM_TIMER0_MOD_V << MCPWM_TIMER0_MOD_S) +#define MCPWM_TIMER0_MOD_V 0x00000003U +#define MCPWM_TIMER0_MOD_S 3 -#define MCPWM_TIMER0_SYNC_REG(i) (REG_MCPWM_BASE(i) + 0x000c) -/* MCPWM_TIMER0_PHASE : R/W ;bitpos:[20:4] ;default: 17'd0 ; */ -/*description: Phase for timer reload on sync event*/ -#define MCPWM_TIMER0_PHASE 0x0001FFFF -#define MCPWM_TIMER0_PHASE_M ((MCPWM_TIMER0_PHASE_V)<<(MCPWM_TIMER0_PHASE_S)) -#define MCPWM_TIMER0_PHASE_V 0x1FFFF -#define MCPWM_TIMER0_PHASE_S 4 -/* MCPWM_TIMER0_SYNCO_SEL : R/W ;bitpos:[3:2] ;default: 2'd0 ; */ -/*description: PWM timer0 synco selection 0: synci 1: TEZ 2: TEP else 0*/ -#define MCPWM_TIMER0_SYNCO_SEL 0x00000003 -#define MCPWM_TIMER0_SYNCO_SEL_M ((MCPWM_TIMER0_SYNCO_SEL_V)<<(MCPWM_TIMER0_SYNCO_SEL_S)) -#define MCPWM_TIMER0_SYNCO_SEL_V 0x3 -#define MCPWM_TIMER0_SYNCO_SEL_S 2 -/* MCPWM_TIMER0_SYNC_SW : R/W ;bitpos:[1] ;default: 1'h0 ; */ -/*description: Toggling this bit will trigger a software sync*/ -#define MCPWM_TIMER0_SYNC_SW (BIT(1)) -#define MCPWM_TIMER0_SYNC_SW_M (BIT(1)) -#define MCPWM_TIMER0_SYNC_SW_V 0x1 -#define MCPWM_TIMER0_SYNC_SW_S 1 -/* MCPWM_TIMER0_SYNCI_EN : R/W ;bitpos:[0] ;default: 1'h0 ; */ -/*description: When set timer reload with phase on sync input event is enabled*/ -#define MCPWM_TIMER0_SYNCI_EN (BIT(0)) -#define MCPWM_TIMER0_SYNCI_EN_M (BIT(0)) -#define MCPWM_TIMER0_SYNCI_EN_V 0x1 +/** MCPWM_TIMER0_SYNC_REG register + * PWM timer0 sync function configuration register. + */ +#define MCPWM_TIMER0_SYNC_REG(i) (DR_REG_MCPWM_BASE(i) + 0xc) +/** MCPWM_TIMER0_SYNCI_EN : R/W; bitpos: [0]; default: 0; + * When set, timer reloading with phase on sync input event is enabled. + */ +#define MCPWM_TIMER0_SYNCI_EN (BIT(0)) +#define MCPWM_TIMER0_SYNCI_EN_M (MCPWM_TIMER0_SYNCI_EN_V << MCPWM_TIMER0_SYNCI_EN_S) +#define MCPWM_TIMER0_SYNCI_EN_V 0x00000001U #define MCPWM_TIMER0_SYNCI_EN_S 0 - -#define MCPWM_TIMER0_STATUS_REG(i) (REG_MCPWM_BASE(i) + 0x0010) -/* MCPWM_TIMER0_DIRECTION : RO ;bitpos:[16] ;default: 1'd0 ; */ -/*description: Current PWM timer0 counter direction 0: increment 1: decrement*/ -#define MCPWM_TIMER0_DIRECTION (BIT(16)) -#define MCPWM_TIMER0_DIRECTION_M (BIT(16)) -#define MCPWM_TIMER0_DIRECTION_V 0x1 -#define MCPWM_TIMER0_DIRECTION_S 16 -/* MCPWM_TIMER0_VALUE : RO ;bitpos:[15:0] ;default: 16'd0 ; */ -/*description: Current PWM timer0 counter value*/ -#define MCPWM_TIMER0_VALUE 0x0000FFFF -#define MCPWM_TIMER0_VALUE_M ((MCPWM_TIMER0_VALUE_V)<<(MCPWM_TIMER0_VALUE_S)) -#define MCPWM_TIMER0_VALUE_V 0xFFFF +/** MCPWM_TIMER0_SYNC_SW : R/W; bitpos: [1]; default: 0; + * Toggling this bit will trigger a software sync. + */ +#define MCPWM_TIMER0_SYNC_SW (BIT(1)) +#define MCPWM_TIMER0_SYNC_SW_M (MCPWM_TIMER0_SYNC_SW_V << MCPWM_TIMER0_SYNC_SW_S) +#define MCPWM_TIMER0_SYNC_SW_V 0x00000001U +#define MCPWM_TIMER0_SYNC_SW_S 1 +/** MCPWM_TIMER0_SYNCO_SEL : R/W; bitpos: [3:2]; default: 0; + * PWM timer0 sync_out selection, 0: sync_in, 1: TEZ, 2: TEP, and sync out will always + * generate when toggling the reg_timer0_sync_sw bit + */ +#define MCPWM_TIMER0_SYNCO_SEL 0x00000003U +#define MCPWM_TIMER0_SYNCO_SEL_M (MCPWM_TIMER0_SYNCO_SEL_V << MCPWM_TIMER0_SYNCO_SEL_S) +#define MCPWM_TIMER0_SYNCO_SEL_V 0x00000003U +#define MCPWM_TIMER0_SYNCO_SEL_S 2 +/** MCPWM_TIMER0_PHASE : R/W; bitpos: [19:4]; default: 0; + * phase for timer reload on sync event + */ +#define MCPWM_TIMER0_PHASE 0x0000FFFFU +#define MCPWM_TIMER0_PHASE_M (MCPWM_TIMER0_PHASE_V << MCPWM_TIMER0_PHASE_S) +#define MCPWM_TIMER0_PHASE_V 0x0000FFFFU +#define MCPWM_TIMER0_PHASE_S 4 +/** MCPWM_TIMER0_PHASE_DIRECTION : R/W; bitpos: [20]; default: 0; + * Configure the PWM timer0's direction at the time sync event occurs when timer0 mode + * is up-down mode: 0-increase,1-decrease + */ +#define MCPWM_TIMER0_PHASE_DIRECTION (BIT(20)) +#define MCPWM_TIMER0_PHASE_DIRECTION_M (MCPWM_TIMER0_PHASE_DIRECTION_V << MCPWM_TIMER0_PHASE_DIRECTION_S) +#define MCPWM_TIMER0_PHASE_DIRECTION_V 0x00000001U +#define MCPWM_TIMER0_PHASE_DIRECTION_S 20 + +/** MCPWM_TIMER0_STATUS_REG register + * PWM timer0 status register. + */ +#define MCPWM_TIMER0_STATUS_REG(i) (DR_REG_MCPWM_BASE(i) + 0x10) +/** MCPWM_TIMER0_VALUE : RO; bitpos: [15:0]; default: 0; + * current PWM timer0 counter value + */ +#define MCPWM_TIMER0_VALUE 0x0000FFFFU +#define MCPWM_TIMER0_VALUE_M (MCPWM_TIMER0_VALUE_V << MCPWM_TIMER0_VALUE_S) +#define MCPWM_TIMER0_VALUE_V 0x0000FFFFU #define MCPWM_TIMER0_VALUE_S 0 +/** MCPWM_TIMER0_DIRECTION : RO; bitpos: [16]; default: 0; + * current PWM timer0 counter direction, 0: increment 1: decrement + */ +#define MCPWM_TIMER0_DIRECTION (BIT(16)) +#define MCPWM_TIMER0_DIRECTION_M (MCPWM_TIMER0_DIRECTION_V << MCPWM_TIMER0_DIRECTION_S) +#define MCPWM_TIMER0_DIRECTION_V 0x00000001U +#define MCPWM_TIMER0_DIRECTION_S 16 -#define MCPWM_TIMER1_CFG0_REG(i) (REG_MCPWM_BASE(i) + 0x0014) -/* MCPWM_TIMER1_PERIOD_UPMETHOD : R/W ;bitpos:[25:24] ;default: 2'd0 ; */ -/*description: Update method for active reg of PWM timer1 period 0: immediate - 1: TEZ 2: sync 3: TEZ or sync*/ -#define MCPWM_TIMER1_PERIOD_UPMETHOD 0x00000003 -#define MCPWM_TIMER1_PERIOD_UPMETHOD_M ((MCPWM_TIMER1_PERIOD_UPMETHOD_V)<<(MCPWM_TIMER1_PERIOD_UPMETHOD_S)) -#define MCPWM_TIMER1_PERIOD_UPMETHOD_V 0x3 -#define MCPWM_TIMER1_PERIOD_UPMETHOD_S 24 -/* MCPWM_TIMER1_PERIOD : R/W ;bitpos:[23:8] ;default: 16'h00ff ; */ -/*description: Period shadow reg of PWM timer1*/ -#define MCPWM_TIMER1_PERIOD 0x0000FFFF -#define MCPWM_TIMER1_PERIOD_M ((MCPWM_TIMER1_PERIOD_V)<<(MCPWM_TIMER1_PERIOD_S)) -#define MCPWM_TIMER1_PERIOD_V 0xFFFF -#define MCPWM_TIMER1_PERIOD_S 8 -/* MCPWM_TIMER1_PRESCALE : R/W ;bitpos:[7:0] ;default: 8'h0 ; */ -/*description: Period of PT1_clk = Period of PWM_clk * (PWM_TIMER1_PRESCALE + 1)*/ -#define MCPWM_TIMER1_PRESCALE 0x000000FF -#define MCPWM_TIMER1_PRESCALE_M ((MCPWM_TIMER1_PRESCALE_V)<<(MCPWM_TIMER1_PRESCALE_S)) -#define MCPWM_TIMER1_PRESCALE_V 0xFF +/** MCPWM_TIMER1_CFG0_REG register + * PWM timer1 period and update method configuration register. + */ +#define MCPWM_TIMER1_CFG0_REG(i) (DR_REG_MCPWM_BASE(i) + 0x14) +/** MCPWM_TIMER1_PRESCALE : R/W; bitpos: [7:0]; default: 0; + * Configure the divisor of PT1_clk, takes effect when PWM timer1 stops and starts + * agsin. period of PT1_clk = Period of PWM_clk * (PWM_TIMER1_PRESCALE + 1) + */ +#define MCPWM_TIMER1_PRESCALE 0x000000FFU +#define MCPWM_TIMER1_PRESCALE_M (MCPWM_TIMER1_PRESCALE_V << MCPWM_TIMER1_PRESCALE_S) +#define MCPWM_TIMER1_PRESCALE_V 0x000000FFU #define MCPWM_TIMER1_PRESCALE_S 0 +/** MCPWM_TIMER1_PERIOD : R/W; bitpos: [23:8]; default: 255; + * period shadow register of PWM timer1 + */ +#define MCPWM_TIMER1_PERIOD 0x0000FFFFU +#define MCPWM_TIMER1_PERIOD_M (MCPWM_TIMER1_PERIOD_V << MCPWM_TIMER1_PERIOD_S) +#define MCPWM_TIMER1_PERIOD_V 0x0000FFFFU +#define MCPWM_TIMER1_PERIOD_S 8 +/** MCPWM_TIMER1_PERIOD_UPMETHOD : R/W; bitpos: [25:24]; default: 0; + * Update method for active register of PWM timer1 period, 0: immediate, 1: TEZ, 2: + * sync, 3: TEZ | sync. TEZ here and below means timer equal zero event + */ +#define MCPWM_TIMER1_PERIOD_UPMETHOD 0x00000003U +#define MCPWM_TIMER1_PERIOD_UPMETHOD_M (MCPWM_TIMER1_PERIOD_UPMETHOD_V << MCPWM_TIMER1_PERIOD_UPMETHOD_S) +#define MCPWM_TIMER1_PERIOD_UPMETHOD_V 0x00000003U +#define MCPWM_TIMER1_PERIOD_UPMETHOD_S 24 -#define MCPWM_TIMER1_CFG1_REG(i) (REG_MCPWM_BASE(i) + 0x0018) -/* MCPWM_TIMER1_MOD : R/W ;bitpos:[4:3] ;default: 2'h0 ; */ -/*description: PWM timer1 working mode 0: freeze 1: increase mod 2: decrease - mod 3: up-down mod*/ -#define MCPWM_TIMER1_MOD 0x00000003 -#define MCPWM_TIMER1_MOD_M ((MCPWM_TIMER1_MOD_V)<<(MCPWM_TIMER1_MOD_S)) -#define MCPWM_TIMER1_MOD_V 0x3 -#define MCPWM_TIMER1_MOD_S 3 -/* MCPWM_TIMER1_START : R/W ;bitpos:[2:0] ;default: 3'h0 ; */ -/*description: PWM timer1 start and stop control. 0: stop @ TEZ 1: stop @ TEP - 2: free run 3: start and stop @ next TEZ 4: start and stop @ next TEP.*/ -#define MCPWM_TIMER1_START 0x00000007 -#define MCPWM_TIMER1_START_M ((MCPWM_TIMER1_START_V)<<(MCPWM_TIMER1_START_S)) -#define MCPWM_TIMER1_START_V 0x7 +/** MCPWM_TIMER1_CFG1_REG register + * PWM timer1 working mode and start/stop control configuration register. + */ +#define MCPWM_TIMER1_CFG1_REG(i) (DR_REG_MCPWM_BASE(i) + 0x18) +/** MCPWM_TIMER1_START : R/W/SC; bitpos: [2:0]; default: 0; + * PWM timer1 start and stop control. 0: if PWM timer1 starts, then stops at TEZ, 1: + * if timer1 starts, then stops at TEP, 2: PWM timer1 starts and runs on, 3: timer1 + * starts and stops at the next TEZ, 4: timer1 starts and stops at the next TEP. TEP + * here and below means the event that happens when the timer equals to period + */ +#define MCPWM_TIMER1_START 0x00000007U +#define MCPWM_TIMER1_START_M (MCPWM_TIMER1_START_V << MCPWM_TIMER1_START_S) +#define MCPWM_TIMER1_START_V 0x00000007U #define MCPWM_TIMER1_START_S 0 +/** MCPWM_TIMER1_MOD : R/W; bitpos: [4:3]; default: 0; + * PWM timer1 working mode, 0: freeze, 1: increase mode, 2: decrease mode, 3: up-down + * mode + */ +#define MCPWM_TIMER1_MOD 0x00000003U +#define MCPWM_TIMER1_MOD_M (MCPWM_TIMER1_MOD_V << MCPWM_TIMER1_MOD_S) +#define MCPWM_TIMER1_MOD_V 0x00000003U +#define MCPWM_TIMER1_MOD_S 3 -#define MCPWM_TIMER1_SYNC_REG(i) (REG_MCPWM_BASE(i) + 0x001c) -/* MCPWM_TIMER1_PHASE : R/W ;bitpos:[20:4] ;default: 17'd0 ; */ -/*description: Phase for timer reload on sync event*/ -#define MCPWM_TIMER1_PHASE 0x0001FFFF -#define MCPWM_TIMER1_PHASE_M ((MCPWM_TIMER1_PHASE_V)<<(MCPWM_TIMER1_PHASE_S)) -#define MCPWM_TIMER1_PHASE_V 0x1FFFF -#define MCPWM_TIMER1_PHASE_S 4 -/* MCPWM_TIMER1_SYNCO_SEL : R/W ;bitpos:[3:2] ;default: 2'd0 ; */ -/*description: PWM timer1 synco selection 0: synci 1: TEZ 2: TEP else 0*/ -#define MCPWM_TIMER1_SYNCO_SEL 0x00000003 -#define MCPWM_TIMER1_SYNCO_SEL_M ((MCPWM_TIMER1_SYNCO_SEL_V)<<(MCPWM_TIMER1_SYNCO_SEL_S)) -#define MCPWM_TIMER1_SYNCO_SEL_V 0x3 -#define MCPWM_TIMER1_SYNCO_SEL_S 2 -/* MCPWM_TIMER1_SYNC_SW : R/W ;bitpos:[1] ;default: 1'h0 ; */ -/*description: Toggling this bit will trigger a software sync*/ -#define MCPWM_TIMER1_SYNC_SW (BIT(1)) -#define MCPWM_TIMER1_SYNC_SW_M (BIT(1)) -#define MCPWM_TIMER1_SYNC_SW_V 0x1 -#define MCPWM_TIMER1_SYNC_SW_S 1 -/* MCPWM_TIMER1_SYNCI_EN : R/W ;bitpos:[0] ;default: 1'h0 ; */ -/*description: When set timer reload with phase on sync input event is enabled*/ -#define MCPWM_TIMER1_SYNCI_EN (BIT(0)) -#define MCPWM_TIMER1_SYNCI_EN_M (BIT(0)) -#define MCPWM_TIMER1_SYNCI_EN_V 0x1 +/** MCPWM_TIMER1_SYNC_REG register + * PWM timer1 sync function configuration register. + */ +#define MCPWM_TIMER1_SYNC_REG(i) (DR_REG_MCPWM_BASE(i) + 0x1c) +/** MCPWM_TIMER1_SYNCI_EN : R/W; bitpos: [0]; default: 0; + * When set, timer reloading with phase on sync input event is enabled. + */ +#define MCPWM_TIMER1_SYNCI_EN (BIT(0)) +#define MCPWM_TIMER1_SYNCI_EN_M (MCPWM_TIMER1_SYNCI_EN_V << MCPWM_TIMER1_SYNCI_EN_S) +#define MCPWM_TIMER1_SYNCI_EN_V 0x00000001U #define MCPWM_TIMER1_SYNCI_EN_S 0 - -#define MCPWM_TIMER1_STATUS_REG(i) (REG_MCPWM_BASE(i) + 0x0020) -/* MCPWM_TIMER1_DIRECTION : RO ;bitpos:[16] ;default: 1'd0 ; */ -/*description: Current PWM timer1 counter direction 0: increment 1: decrement*/ -#define MCPWM_TIMER1_DIRECTION (BIT(16)) -#define MCPWM_TIMER1_DIRECTION_M (BIT(16)) -#define MCPWM_TIMER1_DIRECTION_V 0x1 -#define MCPWM_TIMER1_DIRECTION_S 16 -/* MCPWM_TIMER1_VALUE : RO ;bitpos:[15:0] ;default: 16'd0 ; */ -/*description: Current PWM timer1 counter value*/ -#define MCPWM_TIMER1_VALUE 0x0000FFFF -#define MCPWM_TIMER1_VALUE_M ((MCPWM_TIMER1_VALUE_V)<<(MCPWM_TIMER1_VALUE_S)) -#define MCPWM_TIMER1_VALUE_V 0xFFFF +/** MCPWM_TIMER1_SYNC_SW : R/W; bitpos: [1]; default: 0; + * Toggling this bit will trigger a software sync. + */ +#define MCPWM_TIMER1_SYNC_SW (BIT(1)) +#define MCPWM_TIMER1_SYNC_SW_M (MCPWM_TIMER1_SYNC_SW_V << MCPWM_TIMER1_SYNC_SW_S) +#define MCPWM_TIMER1_SYNC_SW_V 0x00000001U +#define MCPWM_TIMER1_SYNC_SW_S 1 +/** MCPWM_TIMER1_SYNCO_SEL : R/W; bitpos: [3:2]; default: 0; + * PWM timer1 sync_out selection, 0: sync_in, 1: TEZ, 2: TEP, and sync out will always + * generate when toggling the reg_timer1_sync_sw bit + */ +#define MCPWM_TIMER1_SYNCO_SEL 0x00000003U +#define MCPWM_TIMER1_SYNCO_SEL_M (MCPWM_TIMER1_SYNCO_SEL_V << MCPWM_TIMER1_SYNCO_SEL_S) +#define MCPWM_TIMER1_SYNCO_SEL_V 0x00000003U +#define MCPWM_TIMER1_SYNCO_SEL_S 2 +/** MCPWM_TIMER1_PHASE : R/W; bitpos: [19:4]; default: 0; + * phase for timer reload on sync event + */ +#define MCPWM_TIMER1_PHASE 0x0000FFFFU +#define MCPWM_TIMER1_PHASE_M (MCPWM_TIMER1_PHASE_V << MCPWM_TIMER1_PHASE_S) +#define MCPWM_TIMER1_PHASE_V 0x0000FFFFU +#define MCPWM_TIMER1_PHASE_S 4 +/** MCPWM_TIMER1_PHASE_DIRECTION : R/W; bitpos: [20]; default: 0; + * Configure the PWM timer1's direction at the time sync event occurs when timer1 mode + * is up-down mode: 0-increase,1-decrease + */ +#define MCPWM_TIMER1_PHASE_DIRECTION (BIT(20)) +#define MCPWM_TIMER1_PHASE_DIRECTION_M (MCPWM_TIMER1_PHASE_DIRECTION_V << MCPWM_TIMER1_PHASE_DIRECTION_S) +#define MCPWM_TIMER1_PHASE_DIRECTION_V 0x00000001U +#define MCPWM_TIMER1_PHASE_DIRECTION_S 20 + +/** MCPWM_TIMER1_STATUS_REG register + * PWM timer1 status register. + */ +#define MCPWM_TIMER1_STATUS_REG(i) (DR_REG_MCPWM_BASE(i) + 0x20) +/** MCPWM_TIMER1_VALUE : RO; bitpos: [15:0]; default: 0; + * current PWM timer1 counter value + */ +#define MCPWM_TIMER1_VALUE 0x0000FFFFU +#define MCPWM_TIMER1_VALUE_M (MCPWM_TIMER1_VALUE_V << MCPWM_TIMER1_VALUE_S) +#define MCPWM_TIMER1_VALUE_V 0x0000FFFFU #define MCPWM_TIMER1_VALUE_S 0 +/** MCPWM_TIMER1_DIRECTION : RO; bitpos: [16]; default: 0; + * current PWM timer1 counter direction, 0: increment 1: decrement + */ +#define MCPWM_TIMER1_DIRECTION (BIT(16)) +#define MCPWM_TIMER1_DIRECTION_M (MCPWM_TIMER1_DIRECTION_V << MCPWM_TIMER1_DIRECTION_S) +#define MCPWM_TIMER1_DIRECTION_V 0x00000001U +#define MCPWM_TIMER1_DIRECTION_S 16 -#define MCPWM_TIMER2_CFG0_REG(i) (REG_MCPWM_BASE(i) + 0x0024) -/* MCPWM_TIMER2_PERIOD_UPMETHOD : R/W ;bitpos:[25:24] ;default: 2'd0 ; */ -/*description: Update method for active reg of PWM timer2 period 0: immediate - 1: TEZ 2: sync 3: TEZ or sync*/ -#define MCPWM_TIMER2_PERIOD_UPMETHOD 0x00000003 -#define MCPWM_TIMER2_PERIOD_UPMETHOD_M ((MCPWM_TIMER2_PERIOD_UPMETHOD_V)<<(MCPWM_TIMER2_PERIOD_UPMETHOD_S)) -#define MCPWM_TIMER2_PERIOD_UPMETHOD_V 0x3 -#define MCPWM_TIMER2_PERIOD_UPMETHOD_S 24 -/* MCPWM_TIMER2_PERIOD : R/W ;bitpos:[23:8] ;default: 16'h00ff ; */ -/*description: Period shadow reg of PWM timer2*/ -#define MCPWM_TIMER2_PERIOD 0x0000FFFF -#define MCPWM_TIMER2_PERIOD_M ((MCPWM_TIMER2_PERIOD_V)<<(MCPWM_TIMER2_PERIOD_S)) -#define MCPWM_TIMER2_PERIOD_V 0xFFFF -#define MCPWM_TIMER2_PERIOD_S 8 -/* MCPWM_TIMER2_PRESCALE : R/W ;bitpos:[7:0] ;default: 8'h0 ; */ -/*description: Period of PT2_clk = Period of PWM_clk * (PWM_TIMER2_PRESCALE + 1)*/ -#define MCPWM_TIMER2_PRESCALE 0x000000FF -#define MCPWM_TIMER2_PRESCALE_M ((MCPWM_TIMER2_PRESCALE_V)<<(MCPWM_TIMER2_PRESCALE_S)) -#define MCPWM_TIMER2_PRESCALE_V 0xFF +/** MCPWM_TIMER2_CFG0_REG register + * PWM timer2 period and update method configuration register. + */ +#define MCPWM_TIMER2_CFG0_REG(i) (DR_REG_MCPWM_BASE(i) + 0x24) +/** MCPWM_TIMER2_PRESCALE : R/W; bitpos: [7:0]; default: 0; + * Configure the divisor of PT2_clk, takes effect when PWM timer2 stops and starts + * agsin. period of PT2_clk = Period of PWM_clk * (PWM_TIMER2_PRESCALE + 1) + */ +#define MCPWM_TIMER2_PRESCALE 0x000000FFU +#define MCPWM_TIMER2_PRESCALE_M (MCPWM_TIMER2_PRESCALE_V << MCPWM_TIMER2_PRESCALE_S) +#define MCPWM_TIMER2_PRESCALE_V 0x000000FFU #define MCPWM_TIMER2_PRESCALE_S 0 +/** MCPWM_TIMER2_PERIOD : R/W; bitpos: [23:8]; default: 255; + * period shadow register of PWM timer2 + */ +#define MCPWM_TIMER2_PERIOD 0x0000FFFFU +#define MCPWM_TIMER2_PERIOD_M (MCPWM_TIMER2_PERIOD_V << MCPWM_TIMER2_PERIOD_S) +#define MCPWM_TIMER2_PERIOD_V 0x0000FFFFU +#define MCPWM_TIMER2_PERIOD_S 8 +/** MCPWM_TIMER2_PERIOD_UPMETHOD : R/W; bitpos: [25:24]; default: 0; + * Update method for active register of PWM timer2 period, 0: immediate, 1: TEZ, 2: + * sync, 3: TEZ | sync. TEZ here and below means timer equal zero event + */ +#define MCPWM_TIMER2_PERIOD_UPMETHOD 0x00000003U +#define MCPWM_TIMER2_PERIOD_UPMETHOD_M (MCPWM_TIMER2_PERIOD_UPMETHOD_V << MCPWM_TIMER2_PERIOD_UPMETHOD_S) +#define MCPWM_TIMER2_PERIOD_UPMETHOD_V 0x00000003U +#define MCPWM_TIMER2_PERIOD_UPMETHOD_S 24 -#define MCPWM_TIMER2_CFG1_REG(i) (REG_MCPWM_BASE(i) + 0x0028) -/* MCPWM_TIMER2_MOD : R/W ;bitpos:[4:3] ;default: 2'h0 ; */ -/*description: PWM timer2 working mode 0: freeze 1: increase mod 2: decrease - mod 3: up-down mod*/ -#define MCPWM_TIMER2_MOD 0x00000003 -#define MCPWM_TIMER2_MOD_M ((MCPWM_TIMER2_MOD_V)<<(MCPWM_TIMER2_MOD_S)) -#define MCPWM_TIMER2_MOD_V 0x3 -#define MCPWM_TIMER2_MOD_S 3 -/* MCPWM_TIMER2_START : R/W ;bitpos:[2:0] ;default: 3'h0 ; */ -/*description: PWM timer2 start and stop control. 0: stop @ TEZ 1: stop @ TEP - 2: free run 3: start and stop @ next TEZ 4: start and stop @ next TEP.*/ -#define MCPWM_TIMER2_START 0x00000007 -#define MCPWM_TIMER2_START_M ((MCPWM_TIMER2_START_V)<<(MCPWM_TIMER2_START_S)) -#define MCPWM_TIMER2_START_V 0x7 +/** MCPWM_TIMER2_CFG1_REG register + * PWM timer2 working mode and start/stop control configuration register. + */ +#define MCPWM_TIMER2_CFG1_REG(i) (DR_REG_MCPWM_BASE(i) + 0x28) +/** MCPWM_TIMER2_START : R/W/SC; bitpos: [2:0]; default: 0; + * PWM timer2 start and stop control. 0: if PWM timer2 starts, then stops at TEZ, 1: + * if timer2 starts, then stops at TEP, 2: PWM timer2 starts and runs on, 3: timer2 + * starts and stops at the next TEZ, 4: timer2 starts and stops at the next TEP. TEP + * here and below means the event that happens when the timer equals to period + */ +#define MCPWM_TIMER2_START 0x00000007U +#define MCPWM_TIMER2_START_M (MCPWM_TIMER2_START_V << MCPWM_TIMER2_START_S) +#define MCPWM_TIMER2_START_V 0x00000007U #define MCPWM_TIMER2_START_S 0 +/** MCPWM_TIMER2_MOD : R/W; bitpos: [4:3]; default: 0; + * PWM timer2 working mode, 0: freeze, 1: increase mode, 2: decrease mode, 3: up-down + * mode + */ +#define MCPWM_TIMER2_MOD 0x00000003U +#define MCPWM_TIMER2_MOD_M (MCPWM_TIMER2_MOD_V << MCPWM_TIMER2_MOD_S) +#define MCPWM_TIMER2_MOD_V 0x00000003U +#define MCPWM_TIMER2_MOD_S 3 -#define MCPWM_TIMER2_SYNC_REG(i) (REG_MCPWM_BASE(i) + 0x002c) -/* MCPWM_TIMER2_PHASE : R/W ;bitpos:[20:4] ;default: 17'd0 ; */ -/*description: Phase for timer reload on sync event*/ -#define MCPWM_TIMER2_PHASE 0x0001FFFF -#define MCPWM_TIMER2_PHASE_M ((MCPWM_TIMER2_PHASE_V)<<(MCPWM_TIMER2_PHASE_S)) -#define MCPWM_TIMER2_PHASE_V 0x1FFFF -#define MCPWM_TIMER2_PHASE_S 4 -/* MCPWM_TIMER2_SYNCO_SEL : R/W ;bitpos:[3:2] ;default: 2'd0 ; */ -/*description: PWM timer2 synco selection 0: synci 1: TEZ 2: TEP else 0*/ -#define MCPWM_TIMER2_SYNCO_SEL 0x00000003 -#define MCPWM_TIMER2_SYNCO_SEL_M ((MCPWM_TIMER2_SYNCO_SEL_V)<<(MCPWM_TIMER2_SYNCO_SEL_S)) -#define MCPWM_TIMER2_SYNCO_SEL_V 0x3 -#define MCPWM_TIMER2_SYNCO_SEL_S 2 -/* MCPWM_TIMER2_SYNC_SW : R/W ;bitpos:[1] ;default: 1'h0 ; */ -/*description: Toggling this bit will trigger a software sync*/ -#define MCPWM_TIMER2_SYNC_SW (BIT(1)) -#define MCPWM_TIMER2_SYNC_SW_M (BIT(1)) -#define MCPWM_TIMER2_SYNC_SW_V 0x1 -#define MCPWM_TIMER2_SYNC_SW_S 1 -/* MCPWM_TIMER2_SYNCI_EN : R/W ;bitpos:[0] ;default: 1'h0 ; */ -/*description: When set timer reload with phase on sync input event is enabled*/ -#define MCPWM_TIMER2_SYNCI_EN (BIT(0)) -#define MCPWM_TIMER2_SYNCI_EN_M (BIT(0)) -#define MCPWM_TIMER2_SYNCI_EN_V 0x1 +/** MCPWM_TIMER2_SYNC_REG register + * PWM timer2 sync function configuration register. + */ +#define MCPWM_TIMER2_SYNC_REG(i) (DR_REG_MCPWM_BASE(i) + 0x2c) +/** MCPWM_TIMER2_SYNCI_EN : R/W; bitpos: [0]; default: 0; + * When set, timer reloading with phase on sync input event is enabled. + */ +#define MCPWM_TIMER2_SYNCI_EN (BIT(0)) +#define MCPWM_TIMER2_SYNCI_EN_M (MCPWM_TIMER2_SYNCI_EN_V << MCPWM_TIMER2_SYNCI_EN_S) +#define MCPWM_TIMER2_SYNCI_EN_V 0x00000001U #define MCPWM_TIMER2_SYNCI_EN_S 0 - -#define MCPWM_TIMER2_STATUS_REG(i) (REG_MCPWM_BASE(i) + 0x0030) -/* MCPWM_TIMER2_DIRECTION : RO ;bitpos:[16] ;default: 1'd0 ; */ -/*description: Current PWM timer2 counter direction 0: increment 1: decrement*/ -#define MCPWM_TIMER2_DIRECTION (BIT(16)) -#define MCPWM_TIMER2_DIRECTION_M (BIT(16)) -#define MCPWM_TIMER2_DIRECTION_V 0x1 -#define MCPWM_TIMER2_DIRECTION_S 16 -/* MCPWM_TIMER2_VALUE : RO ;bitpos:[15:0] ;default: 16'd0 ; */ -/*description: Current PWM timer2 counter value*/ -#define MCPWM_TIMER2_VALUE 0x0000FFFF -#define MCPWM_TIMER2_VALUE_M ((MCPWM_TIMER2_VALUE_V)<<(MCPWM_TIMER2_VALUE_S)) -#define MCPWM_TIMER2_VALUE_V 0xFFFF +/** MCPWM_TIMER2_SYNC_SW : R/W; bitpos: [1]; default: 0; + * Toggling this bit will trigger a software sync. + */ +#define MCPWM_TIMER2_SYNC_SW (BIT(1)) +#define MCPWM_TIMER2_SYNC_SW_M (MCPWM_TIMER2_SYNC_SW_V << MCPWM_TIMER2_SYNC_SW_S) +#define MCPWM_TIMER2_SYNC_SW_V 0x00000001U +#define MCPWM_TIMER2_SYNC_SW_S 1 +/** MCPWM_TIMER2_SYNCO_SEL : R/W; bitpos: [3:2]; default: 0; + * PWM timer2 sync_out selection, 0: sync_in, 1: TEZ, 2: TEP, and sync out will always + * generate when toggling the reg_timer0_sync_sw bit + */ +#define MCPWM_TIMER2_SYNCO_SEL 0x00000003U +#define MCPWM_TIMER2_SYNCO_SEL_M (MCPWM_TIMER2_SYNCO_SEL_V << MCPWM_TIMER2_SYNCO_SEL_S) +#define MCPWM_TIMER2_SYNCO_SEL_V 0x00000003U +#define MCPWM_TIMER2_SYNCO_SEL_S 2 +/** MCPWM_TIMER2_PHASE : R/W; bitpos: [19:4]; default: 0; + * phase for timer reload on sync event + */ +#define MCPWM_TIMER2_PHASE 0x0000FFFFU +#define MCPWM_TIMER2_PHASE_M (MCPWM_TIMER2_PHASE_V << MCPWM_TIMER2_PHASE_S) +#define MCPWM_TIMER2_PHASE_V 0x0000FFFFU +#define MCPWM_TIMER2_PHASE_S 4 +/** MCPWM_TIMER2_PHASE_DIRECTION : R/W; bitpos: [20]; default: 0; + * Configure the PWM timer2's direction at the time sync event occurs when timer2 mode + * is up-down mode: 0-increase,1-decrease + */ +#define MCPWM_TIMER2_PHASE_DIRECTION (BIT(20)) +#define MCPWM_TIMER2_PHASE_DIRECTION_M (MCPWM_TIMER2_PHASE_DIRECTION_V << MCPWM_TIMER2_PHASE_DIRECTION_S) +#define MCPWM_TIMER2_PHASE_DIRECTION_V 0x00000001U +#define MCPWM_TIMER2_PHASE_DIRECTION_S 20 + +/** MCPWM_TIMER2_STATUS_REG register + * PWM timer2 status register. + */ +#define MCPWM_TIMER2_STATUS_REG(i) (DR_REG_MCPWM_BASE(i) + 0x30) +/** MCPWM_TIMER2_VALUE : RO; bitpos: [15:0]; default: 0; + * current PWM timer2 counter value + */ +#define MCPWM_TIMER2_VALUE 0x0000FFFFU +#define MCPWM_TIMER2_VALUE_M (MCPWM_TIMER2_VALUE_V << MCPWM_TIMER2_VALUE_S) +#define MCPWM_TIMER2_VALUE_V 0x0000FFFFU #define MCPWM_TIMER2_VALUE_S 0 +/** MCPWM_TIMER2_DIRECTION : RO; bitpos: [16]; default: 0; + * current PWM timer2 counter direction, 0: increment 1: decrement + */ +#define MCPWM_TIMER2_DIRECTION (BIT(16)) +#define MCPWM_TIMER2_DIRECTION_M (MCPWM_TIMER2_DIRECTION_V << MCPWM_TIMER2_DIRECTION_S) +#define MCPWM_TIMER2_DIRECTION_V 0x00000001U +#define MCPWM_TIMER2_DIRECTION_S 16 -#define MCPWM_TIMER_SYNCI_CFG_REG(i) (REG_MCPWM_BASE(i) + 0x0034) -/* MCPWM_EXTERNAL_SYNCI2_INVERT : R/W ;bitpos:[11] ;default: 1'd0 ; */ -/*description: Onvert SYNC2 from GPIO matrix*/ -#define MCPWM_EXTERNAL_SYNCI2_INVERT (BIT(11)) -#define MCPWM_EXTERNAL_SYNCI2_INVERT_M (BIT(11)) -#define MCPWM_EXTERNAL_SYNCI2_INVERT_V 0x1 -#define MCPWM_EXTERNAL_SYNCI2_INVERT_S 11 -/* MCPWM_EXTERNAL_SYNCI1_INVERT : R/W ;bitpos:[10] ;default: 1'd0 ; */ -/*description: Invert SYNC1 from GPIO matrix*/ -#define MCPWM_EXTERNAL_SYNCI1_INVERT (BIT(10)) -#define MCPWM_EXTERNAL_SYNCI1_INVERT_M (BIT(10)) -#define MCPWM_EXTERNAL_SYNCI1_INVERT_V 0x1 -#define MCPWM_EXTERNAL_SYNCI1_INVERT_S 10 -/* MCPWM_EXTERNAL_SYNCI0_INVERT : R/W ;bitpos:[9] ;default: 1'd0 ; */ -/*description: Invert SYNC0 from GPIO matrix*/ -#define MCPWM_EXTERNAL_SYNCI0_INVERT (BIT(9)) -#define MCPWM_EXTERNAL_SYNCI0_INVERT_M (BIT(9)) -#define MCPWM_EXTERNAL_SYNCI0_INVERT_V 0x1 -#define MCPWM_EXTERNAL_SYNCI0_INVERT_S 9 -/* MCPWM_TIMER2_SYNCISEL : R/W ;bitpos:[8:6] ;default: 3'd0 ; */ -/*description: Select sync input for PWM timer2 1: PWM timer0 synco 2: PWM - timer1 synco 3: PWM timer2 synco 4: SYNC0 from GPIO matrix 5: SYNC1 from GPIO matrix 6: SYNC2 from GPIO matrix other values: no sync input selected*/ -#define MCPWM_TIMER2_SYNCISEL 0x00000007 -#define MCPWM_TIMER2_SYNCISEL_M ((MCPWM_TIMER2_SYNCISEL_V)<<(MCPWM_TIMER2_SYNCISEL_S)) -#define MCPWM_TIMER2_SYNCISEL_V 0x7 -#define MCPWM_TIMER2_SYNCISEL_S 6 -/* MCPWM_TIMER1_SYNCISEL : R/W ;bitpos:[5:3] ;default: 3'd0 ; */ -/*description: Select sync input for PWM timer1 1: PWM timer0 synco 2: PWM - timer1 synco 3: PWM timer2 synco 4: SYNC0 from GPIO matrix 5: SYNC1 from GPIO matrix 6: SYNC2 from GPIO matrix other values: no sync input selected*/ -#define MCPWM_TIMER1_SYNCISEL 0x00000007 -#define MCPWM_TIMER1_SYNCISEL_M ((MCPWM_TIMER1_SYNCISEL_V)<<(MCPWM_TIMER1_SYNCISEL_S)) -#define MCPWM_TIMER1_SYNCISEL_V 0x7 -#define MCPWM_TIMER1_SYNCISEL_S 3 -/* MCPWM_TIMER0_SYNCISEL : R/W ;bitpos:[2:0] ;default: 3'd0 ; */ -/*description: Select sync input for PWM timer0 1: PWM timer0 synco 2: PWM - timer1 synco 3: PWM timer2 synco 4: SYNC0 from GPIO matrix 5: SYNC1 from GPIO matrix 6: SYNC2 from GPIO matrix other values: no sync input selected*/ -#define MCPWM_TIMER0_SYNCISEL 0x00000007 -#define MCPWM_TIMER0_SYNCISEL_M ((MCPWM_TIMER0_SYNCISEL_V)<<(MCPWM_TIMER0_SYNCISEL_S)) -#define MCPWM_TIMER0_SYNCISEL_V 0x7 +/** MCPWM_TIMER_SYNCI_CFG_REG register + * Synchronization input selection for three PWM timers. + */ +#define MCPWM_TIMER_SYNCI_CFG_REG(i) (DR_REG_MCPWM_BASE(i) + 0x34) +/** MCPWM_TIMER0_SYNCISEL : R/W; bitpos: [2:0]; default: 0; + * select sync input for PWM timer0, 1: PWM timer0 sync_out, 2: PWM timer1 sync_out, + * 3: PWM timer2 sync_out, 4: SYNC0 from GPIO matrix, 5: SYNC1 from GPIO matrix, 6: + * SYNC2 from GPIO matrix, other values: no sync input selected + */ +#define MCPWM_TIMER0_SYNCISEL 0x00000007U +#define MCPWM_TIMER0_SYNCISEL_M (MCPWM_TIMER0_SYNCISEL_V << MCPWM_TIMER0_SYNCISEL_S) +#define MCPWM_TIMER0_SYNCISEL_V 0x00000007U #define MCPWM_TIMER0_SYNCISEL_S 0 +/** MCPWM_TIMER1_SYNCISEL : R/W; bitpos: [5:3]; default: 0; + * select sync input for PWM timer1, 1: PWM timer0 sync_out, 2: PWM timer1 sync_out, + * 3: PWM timer2 sync_out, 4: SYNC0 from GPIO matrix, 5: SYNC1 from GPIO matrix, 6: + * SYNC2 from GPIO matrix, other values: no sync input selected + */ +#define MCPWM_TIMER1_SYNCISEL 0x00000007U +#define MCPWM_TIMER1_SYNCISEL_M (MCPWM_TIMER1_SYNCISEL_V << MCPWM_TIMER1_SYNCISEL_S) +#define MCPWM_TIMER1_SYNCISEL_V 0x00000007U +#define MCPWM_TIMER1_SYNCISEL_S 3 +/** MCPWM_TIMER2_SYNCISEL : R/W; bitpos: [8:6]; default: 0; + * select sync input for PWM timer2, 1: PWM timer0 sync_out, 2: PWM timer1 sync_out, + * 3: PWM timer2 sync_out, 4: SYNC0 from GPIO matrix, 5: SYNC1 from GPIO matrix, 6: + * SYNC2 from GPIO matrix, other values: no sync input selected + */ +#define MCPWM_TIMER2_SYNCISEL 0x00000007U +#define MCPWM_TIMER2_SYNCISEL_M (MCPWM_TIMER2_SYNCISEL_V << MCPWM_TIMER2_SYNCISEL_S) +#define MCPWM_TIMER2_SYNCISEL_V 0x00000007U +#define MCPWM_TIMER2_SYNCISEL_S 6 +/** MCPWM_EXTERNAL_SYNCI0_INVERT : R/W; bitpos: [9]; default: 0; + * invert SYNC0 from GPIO matrix + */ +#define MCPWM_EXTERNAL_SYNCI0_INVERT (BIT(9)) +#define MCPWM_EXTERNAL_SYNCI0_INVERT_M (MCPWM_EXTERNAL_SYNCI0_INVERT_V << MCPWM_EXTERNAL_SYNCI0_INVERT_S) +#define MCPWM_EXTERNAL_SYNCI0_INVERT_V 0x00000001U +#define MCPWM_EXTERNAL_SYNCI0_INVERT_S 9 +/** MCPWM_EXTERNAL_SYNCI1_INVERT : R/W; bitpos: [10]; default: 0; + * invert SYNC1 from GPIO matrix + */ +#define MCPWM_EXTERNAL_SYNCI1_INVERT (BIT(10)) +#define MCPWM_EXTERNAL_SYNCI1_INVERT_M (MCPWM_EXTERNAL_SYNCI1_INVERT_V << MCPWM_EXTERNAL_SYNCI1_INVERT_S) +#define MCPWM_EXTERNAL_SYNCI1_INVERT_V 0x00000001U +#define MCPWM_EXTERNAL_SYNCI1_INVERT_S 10 +/** MCPWM_EXTERNAL_SYNCI2_INVERT : R/W; bitpos: [11]; default: 0; + * invert SYNC2 from GPIO matrix + */ +#define MCPWM_EXTERNAL_SYNCI2_INVERT (BIT(11)) +#define MCPWM_EXTERNAL_SYNCI2_INVERT_M (MCPWM_EXTERNAL_SYNCI2_INVERT_V << MCPWM_EXTERNAL_SYNCI2_INVERT_S) +#define MCPWM_EXTERNAL_SYNCI2_INVERT_V 0x00000001U +#define MCPWM_EXTERNAL_SYNCI2_INVERT_S 11 -#define MCPWM_OPERATOR_TIMERSEL_REG(i) (REG_MCPWM_BASE(i) + 0x0038) -/* MCPWM_OPERATOR2_TIMERSEL : R/W ;bitpos:[5:4] ;default: 2'd0 ; */ -/*description: Select which PWM timer's is the timing reference for PWM operator2 - 0: timer0 1: timer1 2: timer2*/ -#define MCPWM_OPERATOR2_TIMERSEL 0x00000003 -#define MCPWM_OPERATOR2_TIMERSEL_M ((MCPWM_OPERATOR2_TIMERSEL_V)<<(MCPWM_OPERATOR2_TIMERSEL_S)) -#define MCPWM_OPERATOR2_TIMERSEL_V 0x3 -#define MCPWM_OPERATOR2_TIMERSEL_S 4 -/* MCPWM_OPERATOR1_TIMERSEL : R/W ;bitpos:[3:2] ;default: 2'd0 ; */ -/*description: Select which PWM timer's is the timing reference for PWM operator1 - 0: timer0 1: timer1 2: timer2*/ -#define MCPWM_OPERATOR1_TIMERSEL 0x00000003 -#define MCPWM_OPERATOR1_TIMERSEL_M ((MCPWM_OPERATOR1_TIMERSEL_V)<<(MCPWM_OPERATOR1_TIMERSEL_S)) -#define MCPWM_OPERATOR1_TIMERSEL_V 0x3 -#define MCPWM_OPERATOR1_TIMERSEL_S 2 -/* MCPWM_OPERATOR0_TIMERSEL : R/W ;bitpos:[1:0] ;default: 2'd0 ; */ -/*description: Select which PWM timer's is the timing reference for PWM operator0 - 0: timer0 1: timer1 2: timer2*/ -#define MCPWM_OPERATOR0_TIMERSEL 0x00000003 -#define MCPWM_OPERATOR0_TIMERSEL_M ((MCPWM_OPERATOR0_TIMERSEL_V)<<(MCPWM_OPERATOR0_TIMERSEL_S)) -#define MCPWM_OPERATOR0_TIMERSEL_V 0x3 +/** MCPWM_OPERATOR_TIMERSEL_REG register + * Select specific timer for PWM operators. + */ +#define MCPWM_OPERATOR_TIMERSEL_REG(i) (DR_REG_MCPWM_BASE(i) + 0x38) +/** MCPWM_OPERATOR0_TIMERSEL : R/W; bitpos: [1:0]; default: 0; + * Select which PWM timer is the timing reference for PWM operator0, 0: timer0, 1: + * timer1, 2: timer2 + */ +#define MCPWM_OPERATOR0_TIMERSEL 0x00000003U +#define MCPWM_OPERATOR0_TIMERSEL_M (MCPWM_OPERATOR0_TIMERSEL_V << MCPWM_OPERATOR0_TIMERSEL_S) +#define MCPWM_OPERATOR0_TIMERSEL_V 0x00000003U #define MCPWM_OPERATOR0_TIMERSEL_S 0 +/** MCPWM_OPERATOR1_TIMERSEL : R/W; bitpos: [3:2]; default: 0; + * Select which PWM timer is the timing reference for PWM operator1, 0: timer0, 1: + * timer1, 2: timer2 + */ +#define MCPWM_OPERATOR1_TIMERSEL 0x00000003U +#define MCPWM_OPERATOR1_TIMERSEL_M (MCPWM_OPERATOR1_TIMERSEL_V << MCPWM_OPERATOR1_TIMERSEL_S) +#define MCPWM_OPERATOR1_TIMERSEL_V 0x00000003U +#define MCPWM_OPERATOR1_TIMERSEL_S 2 +/** MCPWM_OPERATOR2_TIMERSEL : R/W; bitpos: [5:4]; default: 0; + * Select which PWM timer is the timing reference for PWM operator2, 0: timer0, 1: + * timer1, 2: timer2 + */ +#define MCPWM_OPERATOR2_TIMERSEL 0x00000003U +#define MCPWM_OPERATOR2_TIMERSEL_M (MCPWM_OPERATOR2_TIMERSEL_V << MCPWM_OPERATOR2_TIMERSEL_S) +#define MCPWM_OPERATOR2_TIMERSEL_V 0x00000003U +#define MCPWM_OPERATOR2_TIMERSEL_S 4 -#define MCPWM_GEN0_STMP_CFG_REG(i) (REG_MCPWM_BASE(i) + 0x003c) -/* MCPWM_GEN0_B_SHDW_FULL : RO ;bitpos:[9] ;default: 1'd0 ; */ -/*description: Set and reset by hardware. If set PWM generator 0 time stamp - B's shadow reg is filled and waiting to be transferred to B's active reg. If cleared B's active reg has been updated with shadow reg latest value*/ -#define MCPWM_GEN0_B_SHDW_FULL (BIT(9)) -#define MCPWM_GEN0_B_SHDW_FULL_M (BIT(9)) -#define MCPWM_GEN0_B_SHDW_FULL_V 0x1 -#define MCPWM_GEN0_B_SHDW_FULL_S 9 -/* MCPWM_GEN0_A_SHDW_FULL : RO ;bitpos:[8] ;default: 1'd0 ; */ -/*description: Set and reset by hardware. If set PWM generator 0 time stamp - A's shadow reg is filled and waiting to be transferred to A's active reg. If cleared A's active reg has been updated with shadow reg latest value*/ -#define MCPWM_GEN0_A_SHDW_FULL (BIT(8)) -#define MCPWM_GEN0_A_SHDW_FULL_M (BIT(8)) -#define MCPWM_GEN0_A_SHDW_FULL_V 0x1 -#define MCPWM_GEN0_A_SHDW_FULL_S 8 -/* MCPWM_GEN0_B_UPMETHOD : R/W ;bitpos:[7:4] ;default: 4'd0 ; */ -/*description: Update method for PWM generator 0 time stamp B's active reg. - 0: immediate bit0: TEZ bit1: TEP bit2: sync bit3: disable update*/ -#define MCPWM_GEN0_B_UPMETHOD 0x0000000F -#define MCPWM_GEN0_B_UPMETHOD_M ((MCPWM_GEN0_B_UPMETHOD_V)<<(MCPWM_GEN0_B_UPMETHOD_S)) -#define MCPWM_GEN0_B_UPMETHOD_V 0xF -#define MCPWM_GEN0_B_UPMETHOD_S 4 -/* MCPWM_GEN0_A_UPMETHOD : R/W ;bitpos:[3:0] ;default: 4'd0 ; */ -/*description: Update method for PWM generator 0 time stamp A's active reg. - 0: immediate bit0: TEZ bit1: TEP bit2: sync bit3: disable update*/ -#define MCPWM_GEN0_A_UPMETHOD 0x0000000F -#define MCPWM_GEN0_A_UPMETHOD_M ((MCPWM_GEN0_A_UPMETHOD_V)<<(MCPWM_GEN0_A_UPMETHOD_S)) -#define MCPWM_GEN0_A_UPMETHOD_V 0xF +/** MCPWM_GEN0_STMP_CFG_REG register + * Transfer status and update method for time stamp registers A and B + */ +#define MCPWM_GEN0_STMP_CFG_REG(i) (DR_REG_MCPWM_BASE(i) + 0x3c) +/** MCPWM_GEN0_A_UPMETHOD : R/W; bitpos: [3:0]; default: 0; + * Update method for PWM generator 0 time stamp A's active register. When all bits are + * set to 0: immediately, when bit0 is set to 1: TEZ, when bit1 is set to 1: TEP,when + * bit2 is set to 1: sync, when bit3 is set to 1: disable the update. + */ +#define MCPWM_GEN0_A_UPMETHOD 0x0000000FU +#define MCPWM_GEN0_A_UPMETHOD_M (MCPWM_GEN0_A_UPMETHOD_V << MCPWM_GEN0_A_UPMETHOD_S) +#define MCPWM_GEN0_A_UPMETHOD_V 0x0000000FU #define MCPWM_GEN0_A_UPMETHOD_S 0 +/** MCPWM_GEN0_B_UPMETHOD : R/W; bitpos: [7:4]; default: 0; + * Update method for PWM generator 0 time stamp B's active register. When all bits are + * set to 0: immediately, when bit0 is set to 1: TEZ, when bit1 is set to 1: TEP,when + * bit2 is set to 1: sync, when bit3 is set to 1: disable the update. + */ +#define MCPWM_GEN0_B_UPMETHOD 0x0000000FU +#define MCPWM_GEN0_B_UPMETHOD_M (MCPWM_GEN0_B_UPMETHOD_V << MCPWM_GEN0_B_UPMETHOD_S) +#define MCPWM_GEN0_B_UPMETHOD_V 0x0000000FU +#define MCPWM_GEN0_B_UPMETHOD_S 4 +/** MCPWM_GEN0_A_SHDW_FULL : R/W/WTC/SC; bitpos: [8]; default: 0; + * Set and reset by hardware. If set, PWM generator 0 time stamp A's shadow reg is + * filled and waiting to be transferred to A's active reg. If cleared, A's active reg + * has been updated with shadow register latest value + */ +#define MCPWM_GEN0_A_SHDW_FULL (BIT(8)) +#define MCPWM_GEN0_A_SHDW_FULL_M (MCPWM_GEN0_A_SHDW_FULL_V << MCPWM_GEN0_A_SHDW_FULL_S) +#define MCPWM_GEN0_A_SHDW_FULL_V 0x00000001U +#define MCPWM_GEN0_A_SHDW_FULL_S 8 +/** MCPWM_GEN0_B_SHDW_FULL : R/W/WTC/SC; bitpos: [9]; default: 0; + * Set and reset by hardware. If set, PWM generator 0 time stamp B's shadow reg is + * filled and waiting to be transferred to B's active reg. If cleared, B's active reg + * has been updated with shadow register latest value + */ +#define MCPWM_GEN0_B_SHDW_FULL (BIT(9)) +#define MCPWM_GEN0_B_SHDW_FULL_M (MCPWM_GEN0_B_SHDW_FULL_V << MCPWM_GEN0_B_SHDW_FULL_S) +#define MCPWM_GEN0_B_SHDW_FULL_V 0x00000001U +#define MCPWM_GEN0_B_SHDW_FULL_S 9 -#define MCPWM_GEN0_TSTMP_A_REG(i) (REG_MCPWM_BASE(i) + 0x0040) -/* MCPWM_GEN0_A : R/W ;bitpos:[15:0] ;default: 16'd0 ; */ -/*description: PWM generator 0 time stamp A's shadow reg*/ -#define MCPWM_GEN0_A 0x0000FFFF -#define MCPWM_GEN0_A_M ((MCPWM_GEN0_A_V)<<(MCPWM_GEN0_A_S)) -#define MCPWM_GEN0_A_V 0xFFFF +/** MCPWM_GEN0_TSTMP_A_REG register + * PWM generator 0 shadow register for timer stamp A. + */ +#define MCPWM_GEN0_TSTMP_A_REG(i) (DR_REG_MCPWM_BASE(i) + 0x40) +/** MCPWM_GEN0_A : R/W; bitpos: [15:0]; default: 0; + * PWM generator 0 time stamp A's shadow register + */ +#define MCPWM_GEN0_A 0x0000FFFFU +#define MCPWM_GEN0_A_M (MCPWM_GEN0_A_V << MCPWM_GEN0_A_S) +#define MCPWM_GEN0_A_V 0x0000FFFFU #define MCPWM_GEN0_A_S 0 -#define MCPWM_GEN0_TSTMP_B_REG(i) (REG_MCPWM_BASE(i) + 0x0044) -/* MCPWM_GEN0_B : R/W ;bitpos:[15:0] ;default: 16'd0 ; */ -/*description: PWM generator 0 time stamp B's shadow reg*/ -#define MCPWM_GEN0_B 0x0000FFFF -#define MCPWM_GEN0_B_M ((MCPWM_GEN0_B_V)<<(MCPWM_GEN0_B_S)) -#define MCPWM_GEN0_B_V 0xFFFF +/** MCPWM_GEN0_TSTMP_B_REG register + * PWM generator 0 shadow register for timer stamp B. + */ +#define MCPWM_GEN0_TSTMP_B_REG(i) (DR_REG_MCPWM_BASE(i) + 0x44) +/** MCPWM_GEN0_B : R/W; bitpos: [15:0]; default: 0; + * PWM generator 0 time stamp B's shadow register + */ +#define MCPWM_GEN0_B 0x0000FFFFU +#define MCPWM_GEN0_B_M (MCPWM_GEN0_B_V << MCPWM_GEN0_B_S) +#define MCPWM_GEN0_B_V 0x0000FFFFU #define MCPWM_GEN0_B_S 0 -#define MCPWM_GEN0_CFG0_REG(i) (REG_MCPWM_BASE(i) + 0x0048) -/* MCPWM_GEN0_T1_SEL : R/W ;bitpos:[9:7] ;default: 3'd0 ; */ -/*description: Source selection for PWM generator 0 event_t1 take effect immediately - 0: fault_event0 1: fault_event1 2: fault_event2 3: sync_taken 4: none*/ -#define MCPWM_GEN0_T1_SEL 0x00000007 -#define MCPWM_GEN0_T1_SEL_M ((MCPWM_GEN0_T1_SEL_V)<<(MCPWM_GEN0_T1_SEL_S)) -#define MCPWM_GEN0_T1_SEL_V 0x7 -#define MCPWM_GEN0_T1_SEL_S 7 -/* MCPWM_GEN0_T0_SEL : R/W ;bitpos:[6:4] ;default: 3'd0 ; */ -/*description: Source selection for PWM generator 0 event_t0 take effect immediately - 0: fault_event0 1: fault_event1 2: fault_event2 3: sync_taken 4: none*/ -#define MCPWM_GEN0_T0_SEL 0x00000007 -#define MCPWM_GEN0_T0_SEL_M ((MCPWM_GEN0_T0_SEL_V)<<(MCPWM_GEN0_T0_SEL_S)) -#define MCPWM_GEN0_T0_SEL_V 0x7 -#define MCPWM_GEN0_T0_SEL_S 4 -/* MCPWM_GEN0_CFG_UPMETHOD : R/W ;bitpos:[3:0] ;default: 4'd0 ; */ -/*description: Update method for PWM generator 0's active reg of configuration. - 0: immediate bit0: TEZ bit1: TEP bit2: sync. bit3: disable update*/ -#define MCPWM_GEN0_CFG_UPMETHOD 0x0000000F -#define MCPWM_GEN0_CFG_UPMETHOD_M ((MCPWM_GEN0_CFG_UPMETHOD_V)<<(MCPWM_GEN0_CFG_UPMETHOD_S)) -#define MCPWM_GEN0_CFG_UPMETHOD_V 0xF +/** MCPWM_GEN0_CFG0_REG register + * PWM generator 0 event T0 and T1 handling + */ +#define MCPWM_GEN0_CFG0_REG(i) (DR_REG_MCPWM_BASE(i) + 0x48) +/** MCPWM_GEN0_CFG_UPMETHOD : R/W; bitpos: [3:0]; default: 0; + * Update method for PWM generator 0's active register of configuration. When all bits + * are set to 0: immediately, when bit0 is set to 1: TEZ, when bit1 is set to + * 1:TEP,when bit2 is set to 1:sync,when bit3 is set to 1:disable the update + */ +#define MCPWM_GEN0_CFG_UPMETHOD 0x0000000FU +#define MCPWM_GEN0_CFG_UPMETHOD_M (MCPWM_GEN0_CFG_UPMETHOD_V << MCPWM_GEN0_CFG_UPMETHOD_S) +#define MCPWM_GEN0_CFG_UPMETHOD_V 0x0000000FU #define MCPWM_GEN0_CFG_UPMETHOD_S 0 +/** MCPWM_GEN0_T0_SEL : R/W; bitpos: [6:4]; default: 0; + * Source selection for PWM generator 0 event_t0, take effect immediately, 0: + * fault_event0, 1: fault_event1, 2: fault_event2, 3: sync_taken, 4: none + */ +#define MCPWM_GEN0_T0_SEL 0x00000007U +#define MCPWM_GEN0_T0_SEL_M (MCPWM_GEN0_T0_SEL_V << MCPWM_GEN0_T0_SEL_S) +#define MCPWM_GEN0_T0_SEL_V 0x00000007U +#define MCPWM_GEN0_T0_SEL_S 4 +/** MCPWM_GEN0_T1_SEL : R/W; bitpos: [9:7]; default: 0; + * Source selection for PWM generator 0 event_t1, take effect immediately, 0: + * fault_event0, 1: fault_event1, 2: fault_event2, 3: sync_taken, 4: none + */ +#define MCPWM_GEN0_T1_SEL 0x00000007U +#define MCPWM_GEN0_T1_SEL_M (MCPWM_GEN0_T1_SEL_V << MCPWM_GEN0_T1_SEL_S) +#define MCPWM_GEN0_T1_SEL_V 0x00000007U +#define MCPWM_GEN0_T1_SEL_S 7 -#define MCPWM_GEN0_FORCE_REG(i) (REG_MCPWM_BASE(i) + 0x004c) -/* MCPWM_GEN0_B_NCIFORCE_MODE : R/W ;bitpos:[15:14] ;default: 2'd0 ; */ -/*description: Non-continuous immediate software force mode for PWM0B 0: disabled - 1: low 2: high 3: disabled*/ -#define MCPWM_GEN0_B_NCIFORCE_MODE 0x00000003 -#define MCPWM_GEN0_B_NCIFORCE_MODE_M ((MCPWM_GEN0_B_NCIFORCE_MODE_V)<<(MCPWM_GEN0_B_NCIFORCE_MODE_S)) -#define MCPWM_GEN0_B_NCIFORCE_MODE_V 0x3 -#define MCPWM_GEN0_B_NCIFORCE_MODE_S 14 -/* MCPWM_GEN0_B_NCIFORCE : R/W ;bitpos:[13] ;default: 1'd0 ; */ -/*description: Non-continuous immediate software force trigger for PWM0B a - toggle will trigger a force event*/ -#define MCPWM_GEN0_B_NCIFORCE (BIT(13)) -#define MCPWM_GEN0_B_NCIFORCE_M (BIT(13)) -#define MCPWM_GEN0_B_NCIFORCE_V 0x1 -#define MCPWM_GEN0_B_NCIFORCE_S 13 -/* MCPWM_GEN0_A_NCIFORCE_MODE : R/W ;bitpos:[12:11] ;default: 2'd0 ; */ -/*description: Non-continuous immediate software force mode for PWM0A 0: disabled - 1: low 2: high 3: disabled*/ -#define MCPWM_GEN0_A_NCIFORCE_MODE 0x00000003 -#define MCPWM_GEN0_A_NCIFORCE_MODE_M ((MCPWM_GEN0_A_NCIFORCE_MODE_V)<<(MCPWM_GEN0_A_NCIFORCE_MODE_S)) -#define MCPWM_GEN0_A_NCIFORCE_MODE_V 0x3 -#define MCPWM_GEN0_A_NCIFORCE_MODE_S 11 -/* MCPWM_GEN0_A_NCIFORCE : R/W ;bitpos:[10] ;default: 1'd0 ; */ -/*description: Non-continuous immediate software force trigger for PWM0A a - toggle will trigger a force event*/ -#define MCPWM_GEN0_A_NCIFORCE (BIT(10)) -#define MCPWM_GEN0_A_NCIFORCE_M (BIT(10)) -#define MCPWM_GEN0_A_NCIFORCE_V 0x1 -#define MCPWM_GEN0_A_NCIFORCE_S 10 -/* MCPWM_GEN0_B_CNTUFORCE_MODE : R/W ;bitpos:[9:8] ;default: 2'd0 ; */ -/*description: Continuous software force mode for PWM0B. 0: disabled 1: low - 2: high 3: disabled*/ -#define MCPWM_GEN0_B_CNTUFORCE_MODE 0x00000003 -#define MCPWM_GEN0_B_CNTUFORCE_MODE_M ((MCPWM_GEN0_B_CNTUFORCE_MODE_V)<<(MCPWM_GEN0_B_CNTUFORCE_MODE_S)) -#define MCPWM_GEN0_B_CNTUFORCE_MODE_V 0x3 -#define MCPWM_GEN0_B_CNTUFORCE_MODE_S 8 -/* MCPWM_GEN0_A_CNTUFORCE_MODE : R/W ;bitpos:[7:6] ;default: 2'd0 ; */ -/*description: Continuous software force mode for PWM0A. 0: disabled 1: low - 2: high 3: disabled*/ -#define MCPWM_GEN0_A_CNTUFORCE_MODE 0x00000003 -#define MCPWM_GEN0_A_CNTUFORCE_MODE_M ((MCPWM_GEN0_A_CNTUFORCE_MODE_V)<<(MCPWM_GEN0_A_CNTUFORCE_MODE_S)) -#define MCPWM_GEN0_A_CNTUFORCE_MODE_V 0x3 -#define MCPWM_GEN0_A_CNTUFORCE_MODE_S 6 -/* MCPWM_GEN0_CNTUFORCE_UPMETHOD : R/W ;bitpos:[5:0] ;default: 6'h20 ; */ -/*description: Update method for continuous software force of PWM generator0. - 0: immediate bit0: TEZ bit1: TEP bit2: TEA bit3: TEB bit4: sync bit5: disable update. (TEA/B here and below means an event generated when timer value equals A/B register)*/ -#define MCPWM_GEN0_CNTUFORCE_UPMETHOD 0x0000003F -#define MCPWM_GEN0_CNTUFORCE_UPMETHOD_M ((MCPWM_GEN0_CNTUFORCE_UPMETHOD_V)<<(MCPWM_GEN0_CNTUFORCE_UPMETHOD_S)) -#define MCPWM_GEN0_CNTUFORCE_UPMETHOD_V 0x3F +/** MCPWM_GEN0_FORCE_REG register + * Permissives to force PWM0A and PWM0B outputs by software + */ +#define MCPWM_GEN0_FORCE_REG(i) (DR_REG_MCPWM_BASE(i) + 0x4c) +/** MCPWM_GEN0_CNTUFORCE_UPMETHOD : R/W; bitpos: [5:0]; default: 32; + * Updating method for continuous software force of PWM generator0. When all bits are + * set to 0: immediately, when bit0 is set to 1: TEZ,,when bit1 is set to 1: TEP, when + * bit2 is set to 1: TEA, when bit3 is set to 1: TEB, when bit4 is set to 1: sync, + * when bit5 is set to 1: disable update. (TEA/B here and below means an event + * generated when the timer's value equals to that of register A/B.) + */ +#define MCPWM_GEN0_CNTUFORCE_UPMETHOD 0x0000003FU +#define MCPWM_GEN0_CNTUFORCE_UPMETHOD_M (MCPWM_GEN0_CNTUFORCE_UPMETHOD_V << MCPWM_GEN0_CNTUFORCE_UPMETHOD_S) +#define MCPWM_GEN0_CNTUFORCE_UPMETHOD_V 0x0000003FU #define MCPWM_GEN0_CNTUFORCE_UPMETHOD_S 0 +/** MCPWM_GEN0_A_CNTUFORCE_MODE : R/W; bitpos: [7:6]; default: 0; + * Continuous software force mode for PWM0A. 0: disabled, 1: low, 2: high, 3: disabled + */ +#define MCPWM_GEN0_A_CNTUFORCE_MODE 0x00000003U +#define MCPWM_GEN0_A_CNTUFORCE_MODE_M (MCPWM_GEN0_A_CNTUFORCE_MODE_V << MCPWM_GEN0_A_CNTUFORCE_MODE_S) +#define MCPWM_GEN0_A_CNTUFORCE_MODE_V 0x00000003U +#define MCPWM_GEN0_A_CNTUFORCE_MODE_S 6 +/** MCPWM_GEN0_B_CNTUFORCE_MODE : R/W; bitpos: [9:8]; default: 0; + * Continuous software force mode for PWM0B. 0: disabled, 1: low, 2: high, 3: disabled + */ +#define MCPWM_GEN0_B_CNTUFORCE_MODE 0x00000003U +#define MCPWM_GEN0_B_CNTUFORCE_MODE_M (MCPWM_GEN0_B_CNTUFORCE_MODE_V << MCPWM_GEN0_B_CNTUFORCE_MODE_S) +#define MCPWM_GEN0_B_CNTUFORCE_MODE_V 0x00000003U +#define MCPWM_GEN0_B_CNTUFORCE_MODE_S 8 +/** MCPWM_GEN0_A_NCIFORCE : R/W; bitpos: [10]; default: 0; + * Trigger of non-continuous immediate software-force event for PWM0A, a toggle will + * trigger a force event. + */ +#define MCPWM_GEN0_A_NCIFORCE (BIT(10)) +#define MCPWM_GEN0_A_NCIFORCE_M (MCPWM_GEN0_A_NCIFORCE_V << MCPWM_GEN0_A_NCIFORCE_S) +#define MCPWM_GEN0_A_NCIFORCE_V 0x00000001U +#define MCPWM_GEN0_A_NCIFORCE_S 10 +/** MCPWM_GEN0_A_NCIFORCE_MODE : R/W; bitpos: [12:11]; default: 0; + * non-continuous immediate software force mode for PWM0A, 0: disabled, 1: low, 2: + * high, 3: disabled + */ +#define MCPWM_GEN0_A_NCIFORCE_MODE 0x00000003U +#define MCPWM_GEN0_A_NCIFORCE_MODE_M (MCPWM_GEN0_A_NCIFORCE_MODE_V << MCPWM_GEN0_A_NCIFORCE_MODE_S) +#define MCPWM_GEN0_A_NCIFORCE_MODE_V 0x00000003U +#define MCPWM_GEN0_A_NCIFORCE_MODE_S 11 +/** MCPWM_GEN0_B_NCIFORCE : R/W; bitpos: [13]; default: 0; + * Trigger of non-continuous immediate software-force event for PWM0B, a toggle will + * trigger a force event. + */ +#define MCPWM_GEN0_B_NCIFORCE (BIT(13)) +#define MCPWM_GEN0_B_NCIFORCE_M (MCPWM_GEN0_B_NCIFORCE_V << MCPWM_GEN0_B_NCIFORCE_S) +#define MCPWM_GEN0_B_NCIFORCE_V 0x00000001U +#define MCPWM_GEN0_B_NCIFORCE_S 13 +/** MCPWM_GEN0_B_NCIFORCE_MODE : R/W; bitpos: [15:14]; default: 0; + * non-continuous immediate software force mode for PWM0B, 0: disabled, 1: low, 2: + * high, 3: disabled + */ +#define MCPWM_GEN0_B_NCIFORCE_MODE 0x00000003U +#define MCPWM_GEN0_B_NCIFORCE_MODE_M (MCPWM_GEN0_B_NCIFORCE_MODE_V << MCPWM_GEN0_B_NCIFORCE_MODE_S) +#define MCPWM_GEN0_B_NCIFORCE_MODE_V 0x00000003U +#define MCPWM_GEN0_B_NCIFORCE_MODE_S 14 -#define MCPWM_GEN0_A_REG(i) (REG_MCPWM_BASE(i) + 0x0050) -/* MCPWM_GEN0_A_DT1 : R/W ;bitpos:[23:22] ;default: 2'd0 ; */ -/*description: Action on PWM0A triggered by event_t1 when timer decreasing. - 0: no change 1: low 2: high 3: toggle*/ -#define MCPWM_GEN0_A_DT1 0x00000003 -#define MCPWM_GEN0_A_DT1_M ((MCPWM_GEN0_A_DT1_V)<<(MCPWM_GEN0_A_DT1_S)) -#define MCPWM_GEN0_A_DT1_V 0x3 -#define MCPWM_GEN0_A_DT1_S 22 -/* MCPWM_GEN0_A_DT0 : R/W ;bitpos:[21:20] ;default: 2'd0 ; */ -/*description: Action on PWM0A triggered by event_t0 when timer decreasing*/ -#define MCPWM_GEN0_A_DT0 0x00000003 -#define MCPWM_GEN0_A_DT0_M ((MCPWM_GEN0_A_DT0_V)<<(MCPWM_GEN0_A_DT0_S)) -#define MCPWM_GEN0_A_DT0_V 0x3 -#define MCPWM_GEN0_A_DT0_S 20 -/* MCPWM_GEN0_A_DTEB : R/W ;bitpos:[19:18] ;default: 2'd0 ; */ -/*description: Action on PWM0A triggered by event TEB when timer decreasing*/ -#define MCPWM_GEN0_A_DTEB 0x00000003 -#define MCPWM_GEN0_A_DTEB_M ((MCPWM_GEN0_A_DTEB_V)<<(MCPWM_GEN0_A_DTEB_S)) -#define MCPWM_GEN0_A_DTEB_V 0x3 -#define MCPWM_GEN0_A_DTEB_S 18 -/* MCPWM_GEN0_A_DTEA : R/W ;bitpos:[17:16] ;default: 2'd0 ; */ -/*description: Action on PWM0A triggered by event TEA when timer decreasing*/ -#define MCPWM_GEN0_A_DTEA 0x00000003 -#define MCPWM_GEN0_A_DTEA_M ((MCPWM_GEN0_A_DTEA_V)<<(MCPWM_GEN0_A_DTEA_S)) -#define MCPWM_GEN0_A_DTEA_V 0x3 -#define MCPWM_GEN0_A_DTEA_S 16 -/* MCPWM_GEN0_A_DTEP : R/W ;bitpos:[15:14] ;default: 2'd0 ; */ -/*description: Action on PWM0A triggered by event TEP when timer decreasing*/ -#define MCPWM_GEN0_A_DTEP 0x00000003 -#define MCPWM_GEN0_A_DTEP_M ((MCPWM_GEN0_A_DTEP_V)<<(MCPWM_GEN0_A_DTEP_S)) -#define MCPWM_GEN0_A_DTEP_V 0x3 -#define MCPWM_GEN0_A_DTEP_S 14 -/* MCPWM_GEN0_A_DTEZ : R/W ;bitpos:[13:12] ;default: 2'd0 ; */ -/*description: Action on PWM0A triggered by event TEZ when timer decreasing*/ -#define MCPWM_GEN0_A_DTEZ 0x00000003 -#define MCPWM_GEN0_A_DTEZ_M ((MCPWM_GEN0_A_DTEZ_V)<<(MCPWM_GEN0_A_DTEZ_S)) -#define MCPWM_GEN0_A_DTEZ_V 0x3 -#define MCPWM_GEN0_A_DTEZ_S 12 -/* MCPWM_GEN0_A_UT1 : R/W ;bitpos:[11:10] ;default: 2'd0 ; */ -/*description: Action on PWM0A triggered by event_t1 when timer increasing*/ -#define MCPWM_GEN0_A_UT1 0x00000003 -#define MCPWM_GEN0_A_UT1_M ((MCPWM_GEN0_A_UT1_V)<<(MCPWM_GEN0_A_UT1_S)) -#define MCPWM_GEN0_A_UT1_V 0x3 -#define MCPWM_GEN0_A_UT1_S 10 -/* MCPWM_GEN0_A_UT0 : R/W ;bitpos:[9:8] ;default: 2'd0 ; */ -/*description: Action on PWM0A triggered by event_t0 when timer increasing*/ -#define MCPWM_GEN0_A_UT0 0x00000003 -#define MCPWM_GEN0_A_UT0_M ((MCPWM_GEN0_A_UT0_V)<<(MCPWM_GEN0_A_UT0_S)) -#define MCPWM_GEN0_A_UT0_V 0x3 -#define MCPWM_GEN0_A_UT0_S 8 -/* MCPWM_GEN0_A_UTEB : R/W ;bitpos:[7:6] ;default: 2'd0 ; */ -/*description: Action on PWM0A triggered by event TEB when timer increasing*/ -#define MCPWM_GEN0_A_UTEB 0x00000003 -#define MCPWM_GEN0_A_UTEB_M ((MCPWM_GEN0_A_UTEB_V)<<(MCPWM_GEN0_A_UTEB_S)) -#define MCPWM_GEN0_A_UTEB_V 0x3 -#define MCPWM_GEN0_A_UTEB_S 6 -/* MCPWM_GEN0_A_UTEA : R/W ;bitpos:[5:4] ;default: 2'd0 ; */ -/*description: Action on PWM0A triggered by event TEA when timer increasing*/ -#define MCPWM_GEN0_A_UTEA 0x00000003 -#define MCPWM_GEN0_A_UTEA_M ((MCPWM_GEN0_A_UTEA_V)<<(MCPWM_GEN0_A_UTEA_S)) -#define MCPWM_GEN0_A_UTEA_V 0x3 -#define MCPWM_GEN0_A_UTEA_S 4 -/* MCPWM_GEN0_A_UTEP : R/W ;bitpos:[3:2] ;default: 2'd0 ; */ -/*description: Action on PWM0A triggered by event TEP when timer increasing*/ -#define MCPWM_GEN0_A_UTEP 0x00000003 -#define MCPWM_GEN0_A_UTEP_M ((MCPWM_GEN0_A_UTEP_V)<<(MCPWM_GEN0_A_UTEP_S)) -#define MCPWM_GEN0_A_UTEP_V 0x3 -#define MCPWM_GEN0_A_UTEP_S 2 -/* MCPWM_GEN0_A_UTEZ : R/W ;bitpos:[1:0] ;default: 2'd0 ; */ -/*description: Action on PWM0A triggered by event TEZ when timer increasing*/ -#define MCPWM_GEN0_A_UTEZ 0x00000003 -#define MCPWM_GEN0_A_UTEZ_M ((MCPWM_GEN0_A_UTEZ_V)<<(MCPWM_GEN0_A_UTEZ_S)) -#define MCPWM_GEN0_A_UTEZ_V 0x3 +/** MCPWM_GEN0_A_REG register + * Actions triggered by events on PWM0A + */ +#define MCPWM_GEN0_A_REG(i) (DR_REG_MCPWM_BASE(i) + 0x50) +/** MCPWM_GEN0_A_UTEZ : R/W; bitpos: [1:0]; default: 0; + * Action on PWM0A triggered by event TEZ when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN0_A_UTEZ 0x00000003U +#define MCPWM_GEN0_A_UTEZ_M (MCPWM_GEN0_A_UTEZ_V << MCPWM_GEN0_A_UTEZ_S) +#define MCPWM_GEN0_A_UTEZ_V 0x00000003U #define MCPWM_GEN0_A_UTEZ_S 0 +/** MCPWM_GEN0_A_UTEP : R/W; bitpos: [3:2]; default: 0; + * Action on PWM0A triggered by event TEP when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN0_A_UTEP 0x00000003U +#define MCPWM_GEN0_A_UTEP_M (MCPWM_GEN0_A_UTEP_V << MCPWM_GEN0_A_UTEP_S) +#define MCPWM_GEN0_A_UTEP_V 0x00000003U +#define MCPWM_GEN0_A_UTEP_S 2 +/** MCPWM_GEN0_A_UTEA : R/W; bitpos: [5:4]; default: 0; + * Action on PWM0A triggered by event TEA when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN0_A_UTEA 0x00000003U +#define MCPWM_GEN0_A_UTEA_M (MCPWM_GEN0_A_UTEA_V << MCPWM_GEN0_A_UTEA_S) +#define MCPWM_GEN0_A_UTEA_V 0x00000003U +#define MCPWM_GEN0_A_UTEA_S 4 +/** MCPWM_GEN0_A_UTEB : R/W; bitpos: [7:6]; default: 0; + * Action on PWM0A triggered by event TEB when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN0_A_UTEB 0x00000003U +#define MCPWM_GEN0_A_UTEB_M (MCPWM_GEN0_A_UTEB_V << MCPWM_GEN0_A_UTEB_S) +#define MCPWM_GEN0_A_UTEB_V 0x00000003U +#define MCPWM_GEN0_A_UTEB_S 6 +/** MCPWM_GEN0_A_UT0 : R/W; bitpos: [9:8]; default: 0; + * Action on PWM0A triggered by event_t0 when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN0_A_UT0 0x00000003U +#define MCPWM_GEN0_A_UT0_M (MCPWM_GEN0_A_UT0_V << MCPWM_GEN0_A_UT0_S) +#define MCPWM_GEN0_A_UT0_V 0x00000003U +#define MCPWM_GEN0_A_UT0_S 8 +/** MCPWM_GEN0_A_UT1 : R/W; bitpos: [11:10]; default: 0; + * Action on PWM0A triggered by event_t1 when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN0_A_UT1 0x00000003U +#define MCPWM_GEN0_A_UT1_M (MCPWM_GEN0_A_UT1_V << MCPWM_GEN0_A_UT1_S) +#define MCPWM_GEN0_A_UT1_V 0x00000003U +#define MCPWM_GEN0_A_UT1_S 10 +/** MCPWM_GEN0_A_DTEZ : R/W; bitpos: [13:12]; default: 0; + * Action on PWM0A triggered by event TEZ when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN0_A_DTEZ 0x00000003U +#define MCPWM_GEN0_A_DTEZ_M (MCPWM_GEN0_A_DTEZ_V << MCPWM_GEN0_A_DTEZ_S) +#define MCPWM_GEN0_A_DTEZ_V 0x00000003U +#define MCPWM_GEN0_A_DTEZ_S 12 +/** MCPWM_GEN0_A_DTEP : R/W; bitpos: [15:14]; default: 0; + * Action on PWM0A triggered by event TEP when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN0_A_DTEP 0x00000003U +#define MCPWM_GEN0_A_DTEP_M (MCPWM_GEN0_A_DTEP_V << MCPWM_GEN0_A_DTEP_S) +#define MCPWM_GEN0_A_DTEP_V 0x00000003U +#define MCPWM_GEN0_A_DTEP_S 14 +/** MCPWM_GEN0_A_DTEA : R/W; bitpos: [17:16]; default: 0; + * Action on PWM0A triggered by event TEA when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN0_A_DTEA 0x00000003U +#define MCPWM_GEN0_A_DTEA_M (MCPWM_GEN0_A_DTEA_V << MCPWM_GEN0_A_DTEA_S) +#define MCPWM_GEN0_A_DTEA_V 0x00000003U +#define MCPWM_GEN0_A_DTEA_S 16 +/** MCPWM_GEN0_A_DTEB : R/W; bitpos: [19:18]; default: 0; + * Action on PWM0A triggered by event TEB when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN0_A_DTEB 0x00000003U +#define MCPWM_GEN0_A_DTEB_M (MCPWM_GEN0_A_DTEB_V << MCPWM_GEN0_A_DTEB_S) +#define MCPWM_GEN0_A_DTEB_V 0x00000003U +#define MCPWM_GEN0_A_DTEB_S 18 +/** MCPWM_GEN0_A_DT0 : R/W; bitpos: [21:20]; default: 0; + * Action on PWM0A triggered by event_t0 when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN0_A_DT0 0x00000003U +#define MCPWM_GEN0_A_DT0_M (MCPWM_GEN0_A_DT0_V << MCPWM_GEN0_A_DT0_S) +#define MCPWM_GEN0_A_DT0_V 0x00000003U +#define MCPWM_GEN0_A_DT0_S 20 +/** MCPWM_GEN0_A_DT1 : R/W; bitpos: [23:22]; default: 0; + * Action on PWM0A triggered by event_t1 when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN0_A_DT1 0x00000003U +#define MCPWM_GEN0_A_DT1_M (MCPWM_GEN0_A_DT1_V << MCPWM_GEN0_A_DT1_S) +#define MCPWM_GEN0_A_DT1_V 0x00000003U +#define MCPWM_GEN0_A_DT1_S 22 -#define MCPWM_GEN0_B_REG(i) (REG_MCPWM_BASE(i) + 0x0054) -/* MCPWM_GEN0_B_DT1 : R/W ;bitpos:[23:22] ;default: 2'd0 ; */ -/*description: Action on PWM0B triggered by event_t1 when timer decreasing. - 0: no change 1: low 2: high 3: toggle*/ -#define MCPWM_GEN0_B_DT1 0x00000003 -#define MCPWM_GEN0_B_DT1_M ((MCPWM_GEN0_B_DT1_V)<<(MCPWM_GEN0_B_DT1_S)) -#define MCPWM_GEN0_B_DT1_V 0x3 -#define MCPWM_GEN0_B_DT1_S 22 -/* MCPWM_GEN0_B_DT0 : R/W ;bitpos:[21:20] ;default: 2'd0 ; */ -/*description: Action on PWM0B triggered by event_t0 when timer decreasing*/ -#define MCPWM_GEN0_B_DT0 0x00000003 -#define MCPWM_GEN0_B_DT0_M ((MCPWM_GEN0_B_DT0_V)<<(MCPWM_GEN0_B_DT0_S)) -#define MCPWM_GEN0_B_DT0_V 0x3 -#define MCPWM_GEN0_B_DT0_S 20 -/* MCPWM_GEN0_B_DTEB : R/W ;bitpos:[19:18] ;default: 2'd0 ; */ -/*description: Action on PWM0B triggered by event TEB when timer decreasing*/ -#define MCPWM_GEN0_B_DTEB 0x00000003 -#define MCPWM_GEN0_B_DTEB_M ((MCPWM_GEN0_B_DTEB_V)<<(MCPWM_GEN0_B_DTEB_S)) -#define MCPWM_GEN0_B_DTEB_V 0x3 -#define MCPWM_GEN0_B_DTEB_S 18 -/* MCPWM_GEN0_B_DTEA : R/W ;bitpos:[17:16] ;default: 2'd0 ; */ -/*description: Action on PWM0B triggered by event TEA when timer decreasing*/ -#define MCPWM_GEN0_B_DTEA 0x00000003 -#define MCPWM_GEN0_B_DTEA_M ((MCPWM_GEN0_B_DTEA_V)<<(MCPWM_GEN0_B_DTEA_S)) -#define MCPWM_GEN0_B_DTEA_V 0x3 -#define MCPWM_GEN0_B_DTEA_S 16 -/* MCPWM_GEN0_B_DTEP : R/W ;bitpos:[15:14] ;default: 2'd0 ; */ -/*description: Action on PWM0B triggered by event TEP when timer decreasing*/ -#define MCPWM_GEN0_B_DTEP 0x00000003 -#define MCPWM_GEN0_B_DTEP_M ((MCPWM_GEN0_B_DTEP_V)<<(MCPWM_GEN0_B_DTEP_S)) -#define MCPWM_GEN0_B_DTEP_V 0x3 -#define MCPWM_GEN0_B_DTEP_S 14 -/* MCPWM_GEN0_B_DTEZ : R/W ;bitpos:[13:12] ;default: 2'd0 ; */ -/*description: Action on PWM0B triggered by event TEZ when timer decreasing*/ -#define MCPWM_GEN0_B_DTEZ 0x00000003 -#define MCPWM_GEN0_B_DTEZ_M ((MCPWM_GEN0_B_DTEZ_V)<<(MCPWM_GEN0_B_DTEZ_S)) -#define MCPWM_GEN0_B_DTEZ_V 0x3 -#define MCPWM_GEN0_B_DTEZ_S 12 -/* MCPWM_GEN0_B_UT1 : R/W ;bitpos:[11:10] ;default: 2'd0 ; */ -/*description: Action on PWM0B triggered by event_t1 when timer increasing*/ -#define MCPWM_GEN0_B_UT1 0x00000003 -#define MCPWM_GEN0_B_UT1_M ((MCPWM_GEN0_B_UT1_V)<<(MCPWM_GEN0_B_UT1_S)) -#define MCPWM_GEN0_B_UT1_V 0x3 -#define MCPWM_GEN0_B_UT1_S 10 -/* MCPWM_GEN0_B_UT0 : R/W ;bitpos:[9:8] ;default: 2'd0 ; */ -/*description: Action on PWM0B triggered by event_t0 when timer increasing*/ -#define MCPWM_GEN0_B_UT0 0x00000003 -#define MCPWM_GEN0_B_UT0_M ((MCPWM_GEN0_B_UT0_V)<<(MCPWM_GEN0_B_UT0_S)) -#define MCPWM_GEN0_B_UT0_V 0x3 -#define MCPWM_GEN0_B_UT0_S 8 -/* MCPWM_GEN0_B_UTEB : R/W ;bitpos:[7:6] ;default: 2'd0 ; */ -/*description: Action on PWM0B triggered by event TEB when timer increasing*/ -#define MCPWM_GEN0_B_UTEB 0x00000003 -#define MCPWM_GEN0_B_UTEB_M ((MCPWM_GEN0_B_UTEB_V)<<(MCPWM_GEN0_B_UTEB_S)) -#define MCPWM_GEN0_B_UTEB_V 0x3 -#define MCPWM_GEN0_B_UTEB_S 6 -/* MCPWM_GEN0_B_UTEA : R/W ;bitpos:[5:4] ;default: 2'd0 ; */ -/*description: Action on PWM0B triggered by event TEA when timer increasing*/ -#define MCPWM_GEN0_B_UTEA 0x00000003 -#define MCPWM_GEN0_B_UTEA_M ((MCPWM_GEN0_B_UTEA_V)<<(MCPWM_GEN0_B_UTEA_S)) -#define MCPWM_GEN0_B_UTEA_V 0x3 -#define MCPWM_GEN0_B_UTEA_S 4 -/* MCPWM_GEN0_B_UTEP : R/W ;bitpos:[3:2] ;default: 2'd0 ; */ -/*description: Action on PWM0B triggered by event TEP when timer increasing*/ -#define MCPWM_GEN0_B_UTEP 0x00000003 -#define MCPWM_GEN0_B_UTEP_M ((MCPWM_GEN0_B_UTEP_V)<<(MCPWM_GEN0_B_UTEP_S)) -#define MCPWM_GEN0_B_UTEP_V 0x3 -#define MCPWM_GEN0_B_UTEP_S 2 -/* MCPWM_GEN0_B_UTEZ : R/W ;bitpos:[1:0] ;default: 2'd0 ; */ -/*description: Action on PWM0B triggered by event TEZ when timer increasing*/ -#define MCPWM_GEN0_B_UTEZ 0x00000003 -#define MCPWM_GEN0_B_UTEZ_M ((MCPWM_GEN0_B_UTEZ_V)<<(MCPWM_GEN0_B_UTEZ_S)) -#define MCPWM_GEN0_B_UTEZ_V 0x3 +/** MCPWM_GEN0_B_REG register + * Actions triggered by events on PWM0B + */ +#define MCPWM_GEN0_B_REG(i) (DR_REG_MCPWM_BASE(i) + 0x54) +/** MCPWM_GEN0_B_UTEZ : R/W; bitpos: [1:0]; default: 0; + * Action on PWM0B triggered by event TEZ when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN0_B_UTEZ 0x00000003U +#define MCPWM_GEN0_B_UTEZ_M (MCPWM_GEN0_B_UTEZ_V << MCPWM_GEN0_B_UTEZ_S) +#define MCPWM_GEN0_B_UTEZ_V 0x00000003U #define MCPWM_GEN0_B_UTEZ_S 0 +/** MCPWM_GEN0_B_UTEP : R/W; bitpos: [3:2]; default: 0; + * Action on PWM0B triggered by event TEP when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN0_B_UTEP 0x00000003U +#define MCPWM_GEN0_B_UTEP_M (MCPWM_GEN0_B_UTEP_V << MCPWM_GEN0_B_UTEP_S) +#define MCPWM_GEN0_B_UTEP_V 0x00000003U +#define MCPWM_GEN0_B_UTEP_S 2 +/** MCPWM_GEN0_B_UTEA : R/W; bitpos: [5:4]; default: 0; + * Action on PWM0B triggered by event TEA when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN0_B_UTEA 0x00000003U +#define MCPWM_GEN0_B_UTEA_M (MCPWM_GEN0_B_UTEA_V << MCPWM_GEN0_B_UTEA_S) +#define MCPWM_GEN0_B_UTEA_V 0x00000003U +#define MCPWM_GEN0_B_UTEA_S 4 +/** MCPWM_GEN0_B_UTEB : R/W; bitpos: [7:6]; default: 0; + * Action on PWM0B triggered by event TEB when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN0_B_UTEB 0x00000003U +#define MCPWM_GEN0_B_UTEB_M (MCPWM_GEN0_B_UTEB_V << MCPWM_GEN0_B_UTEB_S) +#define MCPWM_GEN0_B_UTEB_V 0x00000003U +#define MCPWM_GEN0_B_UTEB_S 6 +/** MCPWM_GEN0_B_UT0 : R/W; bitpos: [9:8]; default: 0; + * Action on PWM0B triggered by event_t0 when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN0_B_UT0 0x00000003U +#define MCPWM_GEN0_B_UT0_M (MCPWM_GEN0_B_UT0_V << MCPWM_GEN0_B_UT0_S) +#define MCPWM_GEN0_B_UT0_V 0x00000003U +#define MCPWM_GEN0_B_UT0_S 8 +/** MCPWM_GEN0_B_UT1 : R/W; bitpos: [11:10]; default: 0; + * Action on PWM0B triggered by event_t1 when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN0_B_UT1 0x00000003U +#define MCPWM_GEN0_B_UT1_M (MCPWM_GEN0_B_UT1_V << MCPWM_GEN0_B_UT1_S) +#define MCPWM_GEN0_B_UT1_V 0x00000003U +#define MCPWM_GEN0_B_UT1_S 10 +/** MCPWM_GEN0_B_DTEZ : R/W; bitpos: [13:12]; default: 0; + * Action on PWM0B triggered by event TEZ when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN0_B_DTEZ 0x00000003U +#define MCPWM_GEN0_B_DTEZ_M (MCPWM_GEN0_B_DTEZ_V << MCPWM_GEN0_B_DTEZ_S) +#define MCPWM_GEN0_B_DTEZ_V 0x00000003U +#define MCPWM_GEN0_B_DTEZ_S 12 +/** MCPWM_GEN0_B_DTEP : R/W; bitpos: [15:14]; default: 0; + * Action on PWM0B triggered by event TEP when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN0_B_DTEP 0x00000003U +#define MCPWM_GEN0_B_DTEP_M (MCPWM_GEN0_B_DTEP_V << MCPWM_GEN0_B_DTEP_S) +#define MCPWM_GEN0_B_DTEP_V 0x00000003U +#define MCPWM_GEN0_B_DTEP_S 14 +/** MCPWM_GEN0_B_DTEA : R/W; bitpos: [17:16]; default: 0; + * Action on PWM0B triggered by event TEA when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN0_B_DTEA 0x00000003U +#define MCPWM_GEN0_B_DTEA_M (MCPWM_GEN0_B_DTEA_V << MCPWM_GEN0_B_DTEA_S) +#define MCPWM_GEN0_B_DTEA_V 0x00000003U +#define MCPWM_GEN0_B_DTEA_S 16 +/** MCPWM_GEN0_B_DTEB : R/W; bitpos: [19:18]; default: 0; + * Action on PWM0B triggered by event TEB when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN0_B_DTEB 0x00000003U +#define MCPWM_GEN0_B_DTEB_M (MCPWM_GEN0_B_DTEB_V << MCPWM_GEN0_B_DTEB_S) +#define MCPWM_GEN0_B_DTEB_V 0x00000003U +#define MCPWM_GEN0_B_DTEB_S 18 +/** MCPWM_GEN0_B_DT0 : R/W; bitpos: [21:20]; default: 0; + * Action on PWM0B triggered by event_t0 when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN0_B_DT0 0x00000003U +#define MCPWM_GEN0_B_DT0_M (MCPWM_GEN0_B_DT0_V << MCPWM_GEN0_B_DT0_S) +#define MCPWM_GEN0_B_DT0_V 0x00000003U +#define MCPWM_GEN0_B_DT0_S 20 +/** MCPWM_GEN0_B_DT1 : R/W; bitpos: [23:22]; default: 0; + * Action on PWM0B triggered by event_t1 when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN0_B_DT1 0x00000003U +#define MCPWM_GEN0_B_DT1_M (MCPWM_GEN0_B_DT1_V << MCPWM_GEN0_B_DT1_S) +#define MCPWM_GEN0_B_DT1_V 0x00000003U +#define MCPWM_GEN0_B_DT1_S 22 -#define MCPWM_DT0_CFG_REG(i) (REG_MCPWM_BASE(i) + 0x0058) -/* MCPWM_DT0_CLK_SEL : R/W ;bitpos:[17] ;default: 1'd0 ; */ -/*description: Dead time generator 0 clock selection. 0: PWM_clk 1: PT_clk*/ -#define MCPWM_DT0_CLK_SEL (BIT(17)) -#define MCPWM_DT0_CLK_SEL_M (BIT(17)) -#define MCPWM_DT0_CLK_SEL_V 0x1 -#define MCPWM_DT0_CLK_SEL_S 17 -/* MCPWM_DT0_B_OUTBYPASS : R/W ;bitpos:[16] ;default: 1'd1 ; */ -/*description: S0 in documentation*/ -#define MCPWM_DT0_B_OUTBYPASS (BIT(16)) -#define MCPWM_DT0_B_OUTBYPASS_M (BIT(16)) -#define MCPWM_DT0_B_OUTBYPASS_V 0x1 -#define MCPWM_DT0_B_OUTBYPASS_S 16 -/* MCPWM_DT0_A_OUTBYPASS : R/W ;bitpos:[15] ;default: 1'd1 ; */ -/*description: S1 in documentation*/ -#define MCPWM_DT0_A_OUTBYPASS (BIT(15)) -#define MCPWM_DT0_A_OUTBYPASS_M (BIT(15)) -#define MCPWM_DT0_A_OUTBYPASS_V 0x1 -#define MCPWM_DT0_A_OUTBYPASS_S 15 -/* MCPWM_DT0_FED_OUTINVERT : R/W ;bitpos:[14] ;default: 1'd0 ; */ -/*description: S3 in documentation*/ -#define MCPWM_DT0_FED_OUTINVERT (BIT(14)) -#define MCPWM_DT0_FED_OUTINVERT_M (BIT(14)) -#define MCPWM_DT0_FED_OUTINVERT_V 0x1 -#define MCPWM_DT0_FED_OUTINVERT_S 14 -/* MCPWM_DT0_RED_OUTINVERT : R/W ;bitpos:[13] ;default: 1'd0 ; */ -/*description: S2 in documentation*/ -#define MCPWM_DT0_RED_OUTINVERT (BIT(13)) -#define MCPWM_DT0_RED_OUTINVERT_M (BIT(13)) -#define MCPWM_DT0_RED_OUTINVERT_V 0x1 -#define MCPWM_DT0_RED_OUTINVERT_S 13 -/* MCPWM_DT0_FED_INSEL : R/W ;bitpos:[12] ;default: 1'd0 ; */ -/*description: S5 in documentation*/ -#define MCPWM_DT0_FED_INSEL (BIT(12)) -#define MCPWM_DT0_FED_INSEL_M (BIT(12)) -#define MCPWM_DT0_FED_INSEL_V 0x1 -#define MCPWM_DT0_FED_INSEL_S 12 -/* MCPWM_DT0_RED_INSEL : R/W ;bitpos:[11] ;default: 1'd0 ; */ -/*description: S4 in documentation*/ -#define MCPWM_DT0_RED_INSEL (BIT(11)) -#define MCPWM_DT0_RED_INSEL_M (BIT(11)) -#define MCPWM_DT0_RED_INSEL_V 0x1 -#define MCPWM_DT0_RED_INSEL_S 11 -/* MCPWM_DT0_B_OUTSWAP : R/W ;bitpos:[10] ;default: 1'd0 ; */ -/*description: S7 in documentation*/ -#define MCPWM_DT0_B_OUTSWAP (BIT(10)) -#define MCPWM_DT0_B_OUTSWAP_M (BIT(10)) -#define MCPWM_DT0_B_OUTSWAP_V 0x1 -#define MCPWM_DT0_B_OUTSWAP_S 10 -/* MCPWM_DT0_A_OUTSWAP : R/W ;bitpos:[9] ;default: 1'd0 ; */ -/*description: S6 in documentation*/ -#define MCPWM_DT0_A_OUTSWAP (BIT(9)) -#define MCPWM_DT0_A_OUTSWAP_M (BIT(9)) -#define MCPWM_DT0_A_OUTSWAP_V 0x1 -#define MCPWM_DT0_A_OUTSWAP_S 9 -/* MCPWM_DT0_DEB_MODE : R/W ;bitpos:[8] ;default: 1'd0 ; */ -/*description: S8 in documentation dual-edge B mode 0: FED/RED take effect - on different path separately 1: FED/RED take effect on B path A out is in bypass or normal operation mode*/ -#define MCPWM_DT0_DEB_MODE (BIT(8)) -#define MCPWM_DT0_DEB_MODE_M (BIT(8)) -#define MCPWM_DT0_DEB_MODE_V 0x1 -#define MCPWM_DT0_DEB_MODE_S 8 -/* MCPWM_DT0_RED_UPMETHOD : R/W ;bitpos:[7:4] ;default: 4'd0 ; */ -/*description: Update method for RED (rising edge delay) active reg. 0: immediate - bit0: TEZ bit1: TEP bit2: sync bit3: disable update*/ -#define MCPWM_DT0_RED_UPMETHOD 0x0000000F -#define MCPWM_DT0_RED_UPMETHOD_M ((MCPWM_DT0_RED_UPMETHOD_V)<<(MCPWM_DT0_RED_UPMETHOD_S)) -#define MCPWM_DT0_RED_UPMETHOD_V 0xF -#define MCPWM_DT0_RED_UPMETHOD_S 4 -/* MCPWM_DT0_FED_UPMETHOD : R/W ;bitpos:[3:0] ;default: 4'd0 ; */ -/*description: Update method for FED (falling edge delay) active reg. 0: immediate - bit0: TEZ bit1: TEP bit2: sync bit3: disable update*/ -#define MCPWM_DT0_FED_UPMETHOD 0x0000000F -#define MCPWM_DT0_FED_UPMETHOD_M ((MCPWM_DT0_FED_UPMETHOD_V)<<(MCPWM_DT0_FED_UPMETHOD_S)) -#define MCPWM_DT0_FED_UPMETHOD_V 0xF +/** MCPWM_DT0_CFG_REG register + * PWM generator 0 dead time type selection and configuration + */ +#define MCPWM_DT0_CFG_REG(i) (DR_REG_MCPWM_BASE(i) + 0x58) +/** MCPWM_DT0_FED_UPMETHOD : R/W; bitpos: [3:0]; default: 0; + * Update method for FED (rising edge delay) active register. 0: immediate, when bit0 + * is set to 1: tez, when bit1 is set to 1:tep, when bit2 is set to 1: sync, when + * bit3 is set to 1: disable the update + */ +#define MCPWM_DT0_FED_UPMETHOD 0x0000000FU +#define MCPWM_DT0_FED_UPMETHOD_M (MCPWM_DT0_FED_UPMETHOD_V << MCPWM_DT0_FED_UPMETHOD_S) +#define MCPWM_DT0_FED_UPMETHOD_V 0x0000000FU #define MCPWM_DT0_FED_UPMETHOD_S 0 +/** MCPWM_DT0_RED_UPMETHOD : R/W; bitpos: [7:4]; default: 0; + * Update method for RED (rising edge delay) active register. 0: immediate, when bit0 + * is set to 1: tez, when bit1 is set to 1:tep, when bit2 is set to 1: sync, when + * bit3 is set to 1: disable the update + */ +#define MCPWM_DT0_RED_UPMETHOD 0x0000000FU +#define MCPWM_DT0_RED_UPMETHOD_M (MCPWM_DT0_RED_UPMETHOD_V << MCPWM_DT0_RED_UPMETHOD_S) +#define MCPWM_DT0_RED_UPMETHOD_V 0x0000000FU +#define MCPWM_DT0_RED_UPMETHOD_S 4 +/** MCPWM_DT0_DEB_MODE : R/W; bitpos: [8]; default: 0; + * S8 in table, dual-edge B mode, 0: fed/red take effect on different path separately, + * 1: fed/red take effect on B path, A out is in bypass or dulpB mode + */ +#define MCPWM_DT0_DEB_MODE (BIT(8)) +#define MCPWM_DT0_DEB_MODE_M (MCPWM_DT0_DEB_MODE_V << MCPWM_DT0_DEB_MODE_S) +#define MCPWM_DT0_DEB_MODE_V 0x00000001U +#define MCPWM_DT0_DEB_MODE_S 8 +/** MCPWM_DT0_A_OUTSWAP : R/W; bitpos: [9]; default: 0; + * S6 in table + */ +#define MCPWM_DT0_A_OUTSWAP (BIT(9)) +#define MCPWM_DT0_A_OUTSWAP_M (MCPWM_DT0_A_OUTSWAP_V << MCPWM_DT0_A_OUTSWAP_S) +#define MCPWM_DT0_A_OUTSWAP_V 0x00000001U +#define MCPWM_DT0_A_OUTSWAP_S 9 +/** MCPWM_DT0_B_OUTSWAP : R/W; bitpos: [10]; default: 0; + * S7 in table + */ +#define MCPWM_DT0_B_OUTSWAP (BIT(10)) +#define MCPWM_DT0_B_OUTSWAP_M (MCPWM_DT0_B_OUTSWAP_V << MCPWM_DT0_B_OUTSWAP_S) +#define MCPWM_DT0_B_OUTSWAP_V 0x00000001U +#define MCPWM_DT0_B_OUTSWAP_S 10 +/** MCPWM_DT0_RED_INSEL : R/W; bitpos: [11]; default: 0; + * S4 in table + */ +#define MCPWM_DT0_RED_INSEL (BIT(11)) +#define MCPWM_DT0_RED_INSEL_M (MCPWM_DT0_RED_INSEL_V << MCPWM_DT0_RED_INSEL_S) +#define MCPWM_DT0_RED_INSEL_V 0x00000001U +#define MCPWM_DT0_RED_INSEL_S 11 +/** MCPWM_DT0_FED_INSEL : R/W; bitpos: [12]; default: 0; + * S5 in table + */ +#define MCPWM_DT0_FED_INSEL (BIT(12)) +#define MCPWM_DT0_FED_INSEL_M (MCPWM_DT0_FED_INSEL_V << MCPWM_DT0_FED_INSEL_S) +#define MCPWM_DT0_FED_INSEL_V 0x00000001U +#define MCPWM_DT0_FED_INSEL_S 12 +/** MCPWM_DT0_RED_OUTINVERT : R/W; bitpos: [13]; default: 0; + * S2 in table + */ +#define MCPWM_DT0_RED_OUTINVERT (BIT(13)) +#define MCPWM_DT0_RED_OUTINVERT_M (MCPWM_DT0_RED_OUTINVERT_V << MCPWM_DT0_RED_OUTINVERT_S) +#define MCPWM_DT0_RED_OUTINVERT_V 0x00000001U +#define MCPWM_DT0_RED_OUTINVERT_S 13 +/** MCPWM_DT0_FED_OUTINVERT : R/W; bitpos: [14]; default: 0; + * S3 in table + */ +#define MCPWM_DT0_FED_OUTINVERT (BIT(14)) +#define MCPWM_DT0_FED_OUTINVERT_M (MCPWM_DT0_FED_OUTINVERT_V << MCPWM_DT0_FED_OUTINVERT_S) +#define MCPWM_DT0_FED_OUTINVERT_V 0x00000001U +#define MCPWM_DT0_FED_OUTINVERT_S 14 +/** MCPWM_DT0_A_OUTBYPASS : R/W; bitpos: [15]; default: 1; + * S1 in table + */ +#define MCPWM_DT0_A_OUTBYPASS (BIT(15)) +#define MCPWM_DT0_A_OUTBYPASS_M (MCPWM_DT0_A_OUTBYPASS_V << MCPWM_DT0_A_OUTBYPASS_S) +#define MCPWM_DT0_A_OUTBYPASS_V 0x00000001U +#define MCPWM_DT0_A_OUTBYPASS_S 15 +/** MCPWM_DT0_B_OUTBYPASS : R/W; bitpos: [16]; default: 1; + * S0 in table + */ +#define MCPWM_DT0_B_OUTBYPASS (BIT(16)) +#define MCPWM_DT0_B_OUTBYPASS_M (MCPWM_DT0_B_OUTBYPASS_V << MCPWM_DT0_B_OUTBYPASS_S) +#define MCPWM_DT0_B_OUTBYPASS_V 0x00000001U +#define MCPWM_DT0_B_OUTBYPASS_S 16 +/** MCPWM_DT0_CLK_SEL : R/W; bitpos: [17]; default: 0; + * Dead time clock selection. 0: PWM_clk, 1: PT_clk + */ +#define MCPWM_DT0_CLK_SEL (BIT(17)) +#define MCPWM_DT0_CLK_SEL_M (MCPWM_DT0_CLK_SEL_V << MCPWM_DT0_CLK_SEL_S) +#define MCPWM_DT0_CLK_SEL_V 0x00000001U +#define MCPWM_DT0_CLK_SEL_S 17 -#define MCPWM_DT0_FED_CFG_REG(i) (REG_MCPWM_BASE(i) + 0x005c) -/* MCPWM_DT0_FED : R/W ;bitpos:[15:0] ;default: 16'd0 ; */ -/*description: Shadow reg for FED*/ -#define MCPWM_DT0_FED 0x0000FFFF -#define MCPWM_DT0_FED_M ((MCPWM_DT0_FED_V)<<(MCPWM_DT0_FED_S)) -#define MCPWM_DT0_FED_V 0xFFFF +/** MCPWM_DT0_FED_CFG_REG register + * PWM generator 0 shadow register for falling edge delay (FED). + */ +#define MCPWM_DT0_FED_CFG_REG(i) (DR_REG_MCPWM_BASE(i) + 0x5c) +/** MCPWM_DT0_FED : R/W; bitpos: [15:0]; default: 0; + * Shadow register for FED + */ +#define MCPWM_DT0_FED 0x0000FFFFU +#define MCPWM_DT0_FED_M (MCPWM_DT0_FED_V << MCPWM_DT0_FED_S) +#define MCPWM_DT0_FED_V 0x0000FFFFU #define MCPWM_DT0_FED_S 0 -#define MCPWM_DT0_RED_CFG_REG(i) (REG_MCPWM_BASE(i) + 0x0060) -/* MCPWM_DT0_RED : R/W ;bitpos:[15:0] ;default: 16'd0 ; */ -/*description: Shadow reg for RED*/ -#define MCPWM_DT0_RED 0x0000FFFF -#define MCPWM_DT0_RED_M ((MCPWM_DT0_RED_V)<<(MCPWM_DT0_RED_S)) -#define MCPWM_DT0_RED_V 0xFFFF +/** MCPWM_DT0_RED_CFG_REG register + * PWM generator 0 shadow register for rising edge delay (RED). + */ +#define MCPWM_DT0_RED_CFG_REG(i) (DR_REG_MCPWM_BASE(i) + 0x60) +/** MCPWM_DT0_RED : R/W; bitpos: [15:0]; default: 0; + * Shadow register for RED + */ +#define MCPWM_DT0_RED 0x0000FFFFU +#define MCPWM_DT0_RED_M (MCPWM_DT0_RED_V << MCPWM_DT0_RED_S) +#define MCPWM_DT0_RED_V 0x0000FFFFU #define MCPWM_DT0_RED_S 0 -#define MCPWM_CARRIER0_CFG_REG(i) (REG_MCPWM_BASE(i) + 0x0064) -/* MCPWM_CARRIER0_IN_INVERT : R/W ;bitpos:[13] ;default: 1'd0 ; */ -/*description: When set invert the input of PWM0A and PWM0B for this submodule*/ -#define MCPWM_CARRIER0_IN_INVERT (BIT(13)) -#define MCPWM_CARRIER0_IN_INVERT_M (BIT(13)) -#define MCPWM_CARRIER0_IN_INVERT_V 0x1 -#define MCPWM_CARRIER0_IN_INVERT_S 13 -/* MCPWM_CARRIER0_OUT_INVERT : R/W ;bitpos:[12] ;default: 1'd0 ; */ -/*description: When set invert the output of PWM0A and PWM0B for this submodule*/ -#define MCPWM_CARRIER0_OUT_INVERT (BIT(12)) -#define MCPWM_CARRIER0_OUT_INVERT_M (BIT(12)) -#define MCPWM_CARRIER0_OUT_INVERT_V 0x1 -#define MCPWM_CARRIER0_OUT_INVERT_S 12 -/* MCPWM_CARRIER0_OSHWTH : R/W ;bitpos:[11:8] ;default: 4'd0 ; */ -/*description: Width of the fist pulse in number of periods of the carrier*/ -#define MCPWM_CARRIER0_OSHWTH 0x0000000F -#define MCPWM_CARRIER0_OSHWTH_M ((MCPWM_CARRIER0_OSHWTH_V)<<(MCPWM_CARRIER0_OSHWTH_S)) -#define MCPWM_CARRIER0_OSHWTH_V 0xF -#define MCPWM_CARRIER0_OSHWTH_S 8 -/* MCPWM_CARRIER0_DUTY : R/W ;bitpos:[7:5] ;default: 3'd0 ; */ -/*description: Carrier duty selection. Duty = PWM_CARRIER0_DUTY / 8*/ -#define MCPWM_CARRIER0_DUTY 0x00000007 -#define MCPWM_CARRIER0_DUTY_M ((MCPWM_CARRIER0_DUTY_V)<<(MCPWM_CARRIER0_DUTY_S)) -#define MCPWM_CARRIER0_DUTY_V 0x7 -#define MCPWM_CARRIER0_DUTY_S 5 -/* MCPWM_CARRIER0_PRESCALE : R/W ;bitpos:[4:1] ;default: 4'd0 ; */ -/*description: PWM carrier0 clock (PC_clk) prescale value. Period of PC_clk - = period of PWM_clk * (PWM_CARRIER0_PRESCALE + 1)*/ -#define MCPWM_CARRIER0_PRESCALE 0x0000000F -#define MCPWM_CARRIER0_PRESCALE_M ((MCPWM_CARRIER0_PRESCALE_V)<<(MCPWM_CARRIER0_PRESCALE_S)) -#define MCPWM_CARRIER0_PRESCALE_V 0xF -#define MCPWM_CARRIER0_PRESCALE_S 1 -/* MCPWM_CARRIER0_EN : R/W ;bitpos:[0] ;default: 1'd0 ; */ -/*description: When set carrier0 function is enabled. When cleared carrier0 is bypassed*/ -#define MCPWM_CARRIER0_EN (BIT(0)) -#define MCPWM_CARRIER0_EN_M (BIT(0)) -#define MCPWM_CARRIER0_EN_V 0x1 +/** MCPWM_CARRIER0_CFG_REG register + * PWM generator 0 carrier enable and configuratoin + */ +#define MCPWM_CARRIER0_CFG_REG(i) (DR_REG_MCPWM_BASE(i) + 0x64) +/** MCPWM_CARRIER0_EN : R/W; bitpos: [0]; default: 0; + * When set, carrier0 function is enabled. When cleared, carrier0 is bypassed + */ +#define MCPWM_CARRIER0_EN (BIT(0)) +#define MCPWM_CARRIER0_EN_M (MCPWM_CARRIER0_EN_V << MCPWM_CARRIER0_EN_S) +#define MCPWM_CARRIER0_EN_V 0x00000001U #define MCPWM_CARRIER0_EN_S 0 +/** MCPWM_CARRIER0_PRESCALE : R/W; bitpos: [4:1]; default: 0; + * PWM carrier0 clock (PC_clk) prescale value. Period of PC_clk = period of PWM_clk * + * (PWM_CARRIER0_PRESCALE + 1) + */ +#define MCPWM_CARRIER0_PRESCALE 0x0000000FU +#define MCPWM_CARRIER0_PRESCALE_M (MCPWM_CARRIER0_PRESCALE_V << MCPWM_CARRIER0_PRESCALE_S) +#define MCPWM_CARRIER0_PRESCALE_V 0x0000000FU +#define MCPWM_CARRIER0_PRESCALE_S 1 +/** MCPWM_CARRIER0_DUTY : R/W; bitpos: [7:5]; default: 0; + * carrier duty selection. Duty = PWM_CARRIER0_DUTY / 8 + */ +#define MCPWM_CARRIER0_DUTY 0x00000007U +#define MCPWM_CARRIER0_DUTY_M (MCPWM_CARRIER0_DUTY_V << MCPWM_CARRIER0_DUTY_S) +#define MCPWM_CARRIER0_DUTY_V 0x00000007U +#define MCPWM_CARRIER0_DUTY_S 5 +/** MCPWM_CARRIER0_OSHTWTH : R/W; bitpos: [11:8]; default: 0; + * width of the first pulse in number of periods of the carrier + */ +#define MCPWM_CARRIER0_OSHTWTH 0x0000000FU +#define MCPWM_CARRIER0_OSHTWTH_M (MCPWM_CARRIER0_OSHTWTH_V << MCPWM_CARRIER0_OSHTWTH_S) +#define MCPWM_CARRIER0_OSHTWTH_V 0x0000000FU +#define MCPWM_CARRIER0_OSHTWTH_S 8 +/** MCPWM_CARRIER0_OUT_INVERT : R/W; bitpos: [12]; default: 0; + * when set, invert the output of PWM0A and PWM0B for this submodule + */ +#define MCPWM_CARRIER0_OUT_INVERT (BIT(12)) +#define MCPWM_CARRIER0_OUT_INVERT_M (MCPWM_CARRIER0_OUT_INVERT_V << MCPWM_CARRIER0_OUT_INVERT_S) +#define MCPWM_CARRIER0_OUT_INVERT_V 0x00000001U +#define MCPWM_CARRIER0_OUT_INVERT_S 12 +/** MCPWM_CARRIER0_IN_INVERT : R/W; bitpos: [13]; default: 0; + * when set, invert the input of PWM0A and PWM0B for this submodule + */ +#define MCPWM_CARRIER0_IN_INVERT (BIT(13)) +#define MCPWM_CARRIER0_IN_INVERT_M (MCPWM_CARRIER0_IN_INVERT_V << MCPWM_CARRIER0_IN_INVERT_S) +#define MCPWM_CARRIER0_IN_INVERT_V 0x00000001U +#define MCPWM_CARRIER0_IN_INVERT_S 13 -#define MCPWM_FH0_CFG0_REG(i) (REG_MCPWM_BASE(i) + 0x0068) -/* MCPWM_FH0_B_OST_U : R/W ;bitpos:[23:22] ;default: 2'd0 ; */ -/*description: One-shot mode action on PWM0B when fault event occurs and timer - is increasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ -#define MCPWM_FH0_B_OST_U 0x00000003 -#define MCPWM_FH0_B_OST_U_M ((MCPWM_FH0_B_OST_U_V)<<(MCPWM_FH0_B_OST_U_S)) -#define MCPWM_FH0_B_OST_U_V 0x3 -#define MCPWM_FH0_B_OST_U_S 22 -/* MCPWM_FH0_B_OST_D : R/W ;bitpos:[21:20] ;default: 2'd0 ; */ -/*description: One-shot mode action on PWM0B when fault event occurs and timer - is decreasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ -#define MCPWM_FH0_B_OST_D 0x00000003 -#define MCPWM_FH0_B_OST_D_M ((MCPWM_FH0_B_OST_D_V)<<(MCPWM_FH0_B_OST_D_S)) -#define MCPWM_FH0_B_OST_D_V 0x3 -#define MCPWM_FH0_B_OST_D_S 20 -/* MCPWM_FH0_B_CBC_U : R/W ;bitpos:[19:18] ;default: 2'd0 ; */ -/*description: Cycle-by-cycle mode action on PWM0B when fault event occurs and - timer is increasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ -#define MCPWM_FH0_B_CBC_U 0x00000003 -#define MCPWM_FH0_B_CBC_U_M ((MCPWM_FH0_B_CBC_U_V)<<(MCPWM_FH0_B_CBC_U_S)) -#define MCPWM_FH0_B_CBC_U_V 0x3 -#define MCPWM_FH0_B_CBC_U_S 18 -/* MCPWM_FH0_B_CBC_D : R/W ;bitpos:[17:16] ;default: 2'd0 ; */ -/*description: Cycle-by-cycle mode action on PWM0B when fault event occurs and - timer is decreasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ -#define MCPWM_FH0_B_CBC_D 0x00000003 -#define MCPWM_FH0_B_CBC_D_M ((MCPWM_FH0_B_CBC_D_V)<<(MCPWM_FH0_B_CBC_D_S)) -#define MCPWM_FH0_B_CBC_D_V 0x3 -#define MCPWM_FH0_B_CBC_D_S 16 -/* MCPWM_FH0_A_OST_U : R/W ;bitpos:[15:14] ;default: 2'd0 ; */ -/*description: One-shot mode action on PWM0A when fault event occurs and timer - is increasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ -#define MCPWM_FH0_A_OST_U 0x00000003 -#define MCPWM_FH0_A_OST_U_M ((MCPWM_FH0_A_OST_U_V)<<(MCPWM_FH0_A_OST_U_S)) -#define MCPWM_FH0_A_OST_U_V 0x3 -#define MCPWM_FH0_A_OST_U_S 14 -/* MCPWM_FH0_A_OST_D : R/W ;bitpos:[13:12] ;default: 2'd0 ; */ -/*description: One-shot mode action on PWM0A when fault event occurs and timer - is decreasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ -#define MCPWM_FH0_A_OST_D 0x00000003 -#define MCPWM_FH0_A_OST_D_M ((MCPWM_FH0_A_OST_D_V)<<(MCPWM_FH0_A_OST_D_S)) -#define MCPWM_FH0_A_OST_D_V 0x3 -#define MCPWM_FH0_A_OST_D_S 12 -/* MCPWM_FH0_A_CBC_U : R/W ;bitpos:[11:10] ;default: 2'd0 ; */ -/*description: Cycle-by-cycle mode action on PWM0A when fault event occurs and - timer is increasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ -#define MCPWM_FH0_A_CBC_U 0x00000003 -#define MCPWM_FH0_A_CBC_U_M ((MCPWM_FH0_A_CBC_U_V)<<(MCPWM_FH0_A_CBC_U_S)) -#define MCPWM_FH0_A_CBC_U_V 0x3 -#define MCPWM_FH0_A_CBC_U_S 10 -/* MCPWM_FH0_A_CBC_D : R/W ;bitpos:[9:8] ;default: 2'd0 ; */ -/*description: Cycle-by-cycle mode action on PWM0A when fault event occurs and - timer is decreasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ -#define MCPWM_FH0_A_CBC_D 0x00000003 -#define MCPWM_FH0_A_CBC_D_M ((MCPWM_FH0_A_CBC_D_V)<<(MCPWM_FH0_A_CBC_D_S)) -#define MCPWM_FH0_A_CBC_D_V 0x3 -#define MCPWM_FH0_A_CBC_D_S 8 -/* MCPWM_FH0_F0_OST : R/W ;bitpos:[7] ;default: 1'd0 ; */ -/*description: event_f0 will trigger one-shot mode action. 0: disable 1: enable*/ -#define MCPWM_FH0_F0_OST (BIT(7)) -#define MCPWM_FH0_F0_OST_M (BIT(7)) -#define MCPWM_FH0_F0_OST_V 0x1 -#define MCPWM_FH0_F0_OST_S 7 -/* MCPWM_FH0_F1_OST : R/W ;bitpos:[6] ;default: 1'd0 ; */ -/*description: event_f1 will trigger one-shot mode action. 0: disable 1: enable*/ -#define MCPWM_FH0_F1_OST (BIT(6)) -#define MCPWM_FH0_F1_OST_M (BIT(6)) -#define MCPWM_FH0_F1_OST_V 0x1 -#define MCPWM_FH0_F1_OST_S 6 -/* MCPWM_FH0_F2_OST : R/W ;bitpos:[5] ;default: 1'd0 ; */ -/*description: event_f2 will trigger one-shot mode action. 0: disable 1: enable*/ -#define MCPWM_FH0_F2_OST (BIT(5)) -#define MCPWM_FH0_F2_OST_M (BIT(5)) -#define MCPWM_FH0_F2_OST_V 0x1 -#define MCPWM_FH0_F2_OST_S 5 -/* MCPWM_FH0_SW_OST : R/W ;bitpos:[4] ;default: 1'd0 ; */ -/*description: Enable register for software force one-shot mode action. 0: disable 1: enable*/ -#define MCPWM_FH0_SW_OST (BIT(4)) -#define MCPWM_FH0_SW_OST_M (BIT(4)) -#define MCPWM_FH0_SW_OST_V 0x1 -#define MCPWM_FH0_SW_OST_S 4 -/* MCPWM_FH0_F0_CBC : R/W ;bitpos:[3] ;default: 1'd0 ; */ -/*description: event_f0 will trigger cycle-by-cycle mode action. 0: disable 1: enable*/ -#define MCPWM_FH0_F0_CBC (BIT(3)) -#define MCPWM_FH0_F0_CBC_M (BIT(3)) -#define MCPWM_FH0_F0_CBC_V 0x1 -#define MCPWM_FH0_F0_CBC_S 3 -/* MCPWM_FH0_F1_CBC : R/W ;bitpos:[2] ;default: 1'd0 ; */ -/*description: event_f1 will trigger cycle-by-cycle mode action. 0: disable 1: enable*/ -#define MCPWM_FH0_F1_CBC (BIT(2)) -#define MCPWM_FH0_F1_CBC_M (BIT(2)) -#define MCPWM_FH0_F1_CBC_V 0x1 -#define MCPWM_FH0_F1_CBC_S 2 -/* MCPWM_FH0_F2_CBC : R/W ;bitpos:[1] ;default: 1'd0 ; */ -/*description: event_f2 will trigger cycle-by-cycle mode action. 0: disable 1: enable*/ -#define MCPWM_FH0_F2_CBC (BIT(1)) -#define MCPWM_FH0_F2_CBC_M (BIT(1)) -#define MCPWM_FH0_F2_CBC_V 0x1 -#define MCPWM_FH0_F2_CBC_S 1 -/* MCPWM_FH0_SW_CBC : R/W ;bitpos:[0] ;default: 1'd0 ; */ -/*description: Enable register for software force cycle-by-cycle mode action. - 0: disable 1: enable*/ -#define MCPWM_FH0_SW_CBC (BIT(0)) -#define MCPWM_FH0_SW_CBC_M (BIT(0)) -#define MCPWM_FH0_SW_CBC_V 0x1 +/** MCPWM_FH0_CFG0_REG register + * Actions on PWM0A and PWM0B trip events + */ +#define MCPWM_FH0_CFG0_REG(i) (DR_REG_MCPWM_BASE(i) + 0x68) +/** MCPWM_FH0_SW_CBC : R/W; bitpos: [0]; default: 0; + * Enable register for software force cycle-by-cycle mode action. 0: disable, 1: enable + */ +#define MCPWM_FH0_SW_CBC (BIT(0)) +#define MCPWM_FH0_SW_CBC_M (MCPWM_FH0_SW_CBC_V << MCPWM_FH0_SW_CBC_S) +#define MCPWM_FH0_SW_CBC_V 0x00000001U #define MCPWM_FH0_SW_CBC_S 0 +/** MCPWM_FH0_F2_CBC : R/W; bitpos: [1]; default: 0; + * fault_event2 will trigger cycle-by-cycle mode action. 0: disable, 1: enable + */ +#define MCPWM_FH0_F2_CBC (BIT(1)) +#define MCPWM_FH0_F2_CBC_M (MCPWM_FH0_F2_CBC_V << MCPWM_FH0_F2_CBC_S) +#define MCPWM_FH0_F2_CBC_V 0x00000001U +#define MCPWM_FH0_F2_CBC_S 1 +/** MCPWM_FH0_F1_CBC : R/W; bitpos: [2]; default: 0; + * fault_event1 will trigger cycle-by-cycle mode action. 0: disable, 1: enable + */ +#define MCPWM_FH0_F1_CBC (BIT(2)) +#define MCPWM_FH0_F1_CBC_M (MCPWM_FH0_F1_CBC_V << MCPWM_FH0_F1_CBC_S) +#define MCPWM_FH0_F1_CBC_V 0x00000001U +#define MCPWM_FH0_F1_CBC_S 2 +/** MCPWM_FH0_F0_CBC : R/W; bitpos: [3]; default: 0; + * fault_event0 will trigger cycle-by-cycle mode action. 0: disable, 1: enable + */ +#define MCPWM_FH0_F0_CBC (BIT(3)) +#define MCPWM_FH0_F0_CBC_M (MCPWM_FH0_F0_CBC_V << MCPWM_FH0_F0_CBC_S) +#define MCPWM_FH0_F0_CBC_V 0x00000001U +#define MCPWM_FH0_F0_CBC_S 3 +/** MCPWM_FH0_SW_OST : R/W; bitpos: [4]; default: 0; + * Enable register for software force one-shot mode action. 0: disable, 1: enable + */ +#define MCPWM_FH0_SW_OST (BIT(4)) +#define MCPWM_FH0_SW_OST_M (MCPWM_FH0_SW_OST_V << MCPWM_FH0_SW_OST_S) +#define MCPWM_FH0_SW_OST_V 0x00000001U +#define MCPWM_FH0_SW_OST_S 4 +/** MCPWM_FH0_F2_OST : R/W; bitpos: [5]; default: 0; + * fault_event2 will trigger one-shot mode action. 0: disable, 1: enable + */ +#define MCPWM_FH0_F2_OST (BIT(5)) +#define MCPWM_FH0_F2_OST_M (MCPWM_FH0_F2_OST_V << MCPWM_FH0_F2_OST_S) +#define MCPWM_FH0_F2_OST_V 0x00000001U +#define MCPWM_FH0_F2_OST_S 5 +/** MCPWM_FH0_F1_OST : R/W; bitpos: [6]; default: 0; + * fault_event1 will trigger one-shot mode action. 0: disable, 1: enable + */ +#define MCPWM_FH0_F1_OST (BIT(6)) +#define MCPWM_FH0_F1_OST_M (MCPWM_FH0_F1_OST_V << MCPWM_FH0_F1_OST_S) +#define MCPWM_FH0_F1_OST_V 0x00000001U +#define MCPWM_FH0_F1_OST_S 6 +/** MCPWM_FH0_F0_OST : R/W; bitpos: [7]; default: 0; + * fault_event0 will trigger one-shot mode action. 0: disable, 1: enable + */ +#define MCPWM_FH0_F0_OST (BIT(7)) +#define MCPWM_FH0_F0_OST_M (MCPWM_FH0_F0_OST_V << MCPWM_FH0_F0_OST_S) +#define MCPWM_FH0_F0_OST_V 0x00000001U +#define MCPWM_FH0_F0_OST_S 7 +/** MCPWM_FH0_A_CBC_D : R/W; bitpos: [9:8]; default: 0; + * Cycle-by-cycle mode action on PWM0A when fault event occurs and timer is + * decreasing. 0: do nothing, 1: force low, 2: force high, 3: toggle + */ +#define MCPWM_FH0_A_CBC_D 0x00000003U +#define MCPWM_FH0_A_CBC_D_M (MCPWM_FH0_A_CBC_D_V << MCPWM_FH0_A_CBC_D_S) +#define MCPWM_FH0_A_CBC_D_V 0x00000003U +#define MCPWM_FH0_A_CBC_D_S 8 +/** MCPWM_FH0_A_CBC_U : R/W; bitpos: [11:10]; default: 0; + * Cycle-by-cycle mode action on PWM0A when fault event occurs and timer is + * increasing. 0: do nothing, 1: force low, 2: force high, 3: toggle + */ +#define MCPWM_FH0_A_CBC_U 0x00000003U +#define MCPWM_FH0_A_CBC_U_M (MCPWM_FH0_A_CBC_U_V << MCPWM_FH0_A_CBC_U_S) +#define MCPWM_FH0_A_CBC_U_V 0x00000003U +#define MCPWM_FH0_A_CBC_U_S 10 +/** MCPWM_FH0_A_OST_D : R/W; bitpos: [13:12]; default: 0; + * One-shot mode action on PWM0A when fault event occurs and timer is decreasing. 0: + * do nothing, 1: force low, 2: force high, 3: toggle + */ +#define MCPWM_FH0_A_OST_D 0x00000003U +#define MCPWM_FH0_A_OST_D_M (MCPWM_FH0_A_OST_D_V << MCPWM_FH0_A_OST_D_S) +#define MCPWM_FH0_A_OST_D_V 0x00000003U +#define MCPWM_FH0_A_OST_D_S 12 +/** MCPWM_FH0_A_OST_U : R/W; bitpos: [15:14]; default: 0; + * One-shot mode action on PWM0A when fault event occurs and timer is increasing. 0: + * do nothing, 1: force low, 2: force high, 3: toggle + */ +#define MCPWM_FH0_A_OST_U 0x00000003U +#define MCPWM_FH0_A_OST_U_M (MCPWM_FH0_A_OST_U_V << MCPWM_FH0_A_OST_U_S) +#define MCPWM_FH0_A_OST_U_V 0x00000003U +#define MCPWM_FH0_A_OST_U_S 14 +/** MCPWM_FH0_B_CBC_D : R/W; bitpos: [17:16]; default: 0; + * Cycle-by-cycle mode action on PWM0B when fault event occurs and timer is + * decreasing. 0: do nothing, 1: force low, 2: force high, 3: toggle + */ +#define MCPWM_FH0_B_CBC_D 0x00000003U +#define MCPWM_FH0_B_CBC_D_M (MCPWM_FH0_B_CBC_D_V << MCPWM_FH0_B_CBC_D_S) +#define MCPWM_FH0_B_CBC_D_V 0x00000003U +#define MCPWM_FH0_B_CBC_D_S 16 +/** MCPWM_FH0_B_CBC_U : R/W; bitpos: [19:18]; default: 0; + * Cycle-by-cycle mode action on PWM0B when fault event occurs and timer is + * increasing. 0: do nothing,1: force low, 2: force high, 3: toggle + */ +#define MCPWM_FH0_B_CBC_U 0x00000003U +#define MCPWM_FH0_B_CBC_U_M (MCPWM_FH0_B_CBC_U_V << MCPWM_FH0_B_CBC_U_S) +#define MCPWM_FH0_B_CBC_U_V 0x00000003U +#define MCPWM_FH0_B_CBC_U_S 18 +/** MCPWM_FH0_B_OST_D : R/W; bitpos: [21:20]; default: 0; + * One-shot mode action on PWM0B when fault event occurs and timer is decreasing. 0: + * do nothing, 1: force low, 2: force high, 3: toggle + */ +#define MCPWM_FH0_B_OST_D 0x00000003U +#define MCPWM_FH0_B_OST_D_M (MCPWM_FH0_B_OST_D_V << MCPWM_FH0_B_OST_D_S) +#define MCPWM_FH0_B_OST_D_V 0x00000003U +#define MCPWM_FH0_B_OST_D_S 20 +/** MCPWM_FH0_B_OST_U : R/W; bitpos: [23:22]; default: 0; + * One-shot mode action on PWM0B when fault event occurs and timer is increasing. 0: + * do nothing, 1: force low, 2: force high, 3: toggle + */ +#define MCPWM_FH0_B_OST_U 0x00000003U +#define MCPWM_FH0_B_OST_U_M (MCPWM_FH0_B_OST_U_V << MCPWM_FH0_B_OST_U_S) +#define MCPWM_FH0_B_OST_U_V 0x00000003U +#define MCPWM_FH0_B_OST_U_S 22 -#define MCPWM_FH0_CFG1_REG(i) (REG_MCPWM_BASE(i) + 0x006c) -/* MCPWM_FH0_FORCE_OST : R/W ;bitpos:[4] ;default: 1'd0 ; */ -/*description: A toggle (software negation of value of this bit) triggers a - one-shot mode action*/ -#define MCPWM_FH0_FORCE_OST (BIT(4)) -#define MCPWM_FH0_FORCE_OST_M (BIT(4)) -#define MCPWM_FH0_FORCE_OST_V 0x1 -#define MCPWM_FH0_FORCE_OST_S 4 -/* MCPWM_FH0_FORCE_CBC : R/W ;bitpos:[3] ;default: 1'd0 ; */ -/*description: A toggle triggers a cycle-by-cycle mode action*/ -#define MCPWM_FH0_FORCE_CBC (BIT(3)) -#define MCPWM_FH0_FORCE_CBC_M (BIT(3)) -#define MCPWM_FH0_FORCE_CBC_V 0x1 -#define MCPWM_FH0_FORCE_CBC_S 3 -/* MCPWM_FH0_CBCPULSE : R/W ;bitpos:[2:1] ;default: 2'd0 ; */ -/*description: The cycle-by-cycle mode action refresh moment selection. Bit0: TEZ bit1:TEP*/ -#define MCPWM_FH0_CBCPULSE 0x00000003 -#define MCPWM_FH0_CBCPULSE_M ((MCPWM_FH0_CBCPULSE_V)<<(MCPWM_FH0_CBCPULSE_S)) -#define MCPWM_FH0_CBCPULSE_V 0x3 -#define MCPWM_FH0_CBCPULSE_S 1 -/* MCPWM_FH0_CLR_OST : R/W ;bitpos:[0] ;default: 1'd0 ; */ -/*description: A toggle will clear on going one-shot mode action*/ -#define MCPWM_FH0_CLR_OST (BIT(0)) -#define MCPWM_FH0_CLR_OST_M (BIT(0)) -#define MCPWM_FH0_CLR_OST_V 0x1 +/** MCPWM_FH0_CFG1_REG register + * Software triggers for fault handler actions + */ +#define MCPWM_FH0_CFG1_REG(i) (DR_REG_MCPWM_BASE(i) + 0x6c) +/** MCPWM_FH0_CLR_OST : R/W; bitpos: [0]; default: 0; + * a rising edge will clear on going one-shot mode action + */ +#define MCPWM_FH0_CLR_OST (BIT(0)) +#define MCPWM_FH0_CLR_OST_M (MCPWM_FH0_CLR_OST_V << MCPWM_FH0_CLR_OST_S) +#define MCPWM_FH0_CLR_OST_V 0x00000001U #define MCPWM_FH0_CLR_OST_S 0 +/** MCPWM_FH0_CBCPULSE : R/W; bitpos: [2:1]; default: 0; + * cycle-by-cycle mode action refresh moment selection. When bit0 is set to 1: TEZ, + * when bit1 is set to 1:TEP, when bit0 and bit1 both set to 0: stop refresh, when + * bit0 and bit1 both set to 1: refresh at TEP/TEZ + */ +#define MCPWM_FH0_CBCPULSE 0x00000003U +#define MCPWM_FH0_CBCPULSE_M (MCPWM_FH0_CBCPULSE_V << MCPWM_FH0_CBCPULSE_S) +#define MCPWM_FH0_CBCPULSE_V 0x00000003U +#define MCPWM_FH0_CBCPULSE_S 1 +/** MCPWM_FH0_FORCE_CBC : R/W; bitpos: [3]; default: 0; + * a toggle trigger a cycle-by-cycle mode action + */ +#define MCPWM_FH0_FORCE_CBC (BIT(3)) +#define MCPWM_FH0_FORCE_CBC_M (MCPWM_FH0_FORCE_CBC_V << MCPWM_FH0_FORCE_CBC_S) +#define MCPWM_FH0_FORCE_CBC_V 0x00000001U +#define MCPWM_FH0_FORCE_CBC_S 3 +/** MCPWM_FH0_FORCE_OST : R/W; bitpos: [4]; default: 0; + * a toggle (software negate its value) triggers a one-shot mode action + */ +#define MCPWM_FH0_FORCE_OST (BIT(4)) +#define MCPWM_FH0_FORCE_OST_M (MCPWM_FH0_FORCE_OST_V << MCPWM_FH0_FORCE_OST_S) +#define MCPWM_FH0_FORCE_OST_V 0x00000001U +#define MCPWM_FH0_FORCE_OST_S 4 -#define MCPWM_FH0_STATUS_REG(i) (REG_MCPWM_BASE(i) + 0x0070) -/* MCPWM_FH0_OST_ON : RO ;bitpos:[1] ;default: 1'd0 ; */ -/*description: Set and reset by hardware. If set an one-shot mode action is on going*/ -#define MCPWM_FH0_OST_ON (BIT(1)) -#define MCPWM_FH0_OST_ON_M (BIT(1)) -#define MCPWM_FH0_OST_ON_V 0x1 -#define MCPWM_FH0_OST_ON_S 1 -/* MCPWM_FH0_CBC_ON : RO ;bitpos:[0] ;default: 1'd0 ; */ -/*description: Set and reset by hardware. If set an cycle-by-cycle mode action is on going*/ -#define MCPWM_FH0_CBC_ON (BIT(0)) -#define MCPWM_FH0_CBC_ON_M (BIT(0)) -#define MCPWM_FH0_CBC_ON_V 0x1 +/** MCPWM_FH0_STATUS_REG register + * Status of fault events. + */ +#define MCPWM_FH0_STATUS_REG(i) (DR_REG_MCPWM_BASE(i) + 0x70) +/** MCPWM_FH0_CBC_ON : RO; bitpos: [0]; default: 0; + * Set and reset by hardware. If set, a cycle-by-cycle mode action is on going + */ +#define MCPWM_FH0_CBC_ON (BIT(0)) +#define MCPWM_FH0_CBC_ON_M (MCPWM_FH0_CBC_ON_V << MCPWM_FH0_CBC_ON_S) +#define MCPWM_FH0_CBC_ON_V 0x00000001U #define MCPWM_FH0_CBC_ON_S 0 +/** MCPWM_FH0_OST_ON : RO; bitpos: [1]; default: 0; + * Set and reset by hardware. If set, an one-shot mode action is on going + */ +#define MCPWM_FH0_OST_ON (BIT(1)) +#define MCPWM_FH0_OST_ON_M (MCPWM_FH0_OST_ON_V << MCPWM_FH0_OST_ON_S) +#define MCPWM_FH0_OST_ON_V 0x00000001U +#define MCPWM_FH0_OST_ON_S 1 -#define MCPWM_GEN1_STMP_CFG_REG(i) (REG_MCPWM_BASE(i) + 0x0074) -/* MCPWM_GEN1_B_SHDW_FULL : RO ;bitpos:[9] ;default: 1'd0 ; */ -/*description: Set and reset by hardware. If set PWM generator 1 time stamp - B's shadow reg is filled and waiting to be transferred to B's active reg. If cleared B's active reg has been updated with shadow reg latest value*/ -#define MCPWM_GEN1_B_SHDW_FULL (BIT(9)) -#define MCPWM_GEN1_B_SHDW_FULL_M (BIT(9)) -#define MCPWM_GEN1_B_SHDW_FULL_V 0x1 -#define MCPWM_GEN1_B_SHDW_FULL_S 9 -/* MCPWM_GEN1_A_SHDW_FULL : RO ;bitpos:[8] ;default: 1'd0 ; */ -/*description: Set and reset by hardware. If set PWM generator 1 time stamp - A's shadow reg is filled and waiting to be transferred to A's active reg. If cleared A's active reg has been updated with shadow reg latest value*/ -#define MCPWM_GEN1_A_SHDW_FULL (BIT(8)) -#define MCPWM_GEN1_A_SHDW_FULL_M (BIT(8)) -#define MCPWM_GEN1_A_SHDW_FULL_V 0x1 -#define MCPWM_GEN1_A_SHDW_FULL_S 8 -/* MCPWM_GEN1_B_UPMETHOD : R/W ;bitpos:[7:4] ;default: 4'd0 ; */ -/*description: Update method for PWM generator 1 time stamp B's active reg. - 0: immediate bit0: TEZ bit1: TEP bit2: sync bit3: disable update*/ -#define MCPWM_GEN1_B_UPMETHOD 0x0000000F -#define MCPWM_GEN1_B_UPMETHOD_M ((MCPWM_GEN1_B_UPMETHOD_V)<<(MCPWM_GEN1_B_UPMETHOD_S)) -#define MCPWM_GEN1_B_UPMETHOD_V 0xF -#define MCPWM_GEN1_B_UPMETHOD_S 4 -/* MCPWM_GEN1_A_UPMETHOD : R/W ;bitpos:[3:0] ;default: 4'd0 ; */ -/*description: Update method for PWM generator 1 time stamp A's active reg. - 0: immediate bit0: TEZ bit1: TEP bit2: sync bit3: disable update*/ -#define MCPWM_GEN1_A_UPMETHOD 0x0000000F -#define MCPWM_GEN1_A_UPMETHOD_M ((MCPWM_GEN1_A_UPMETHOD_V)<<(MCPWM_GEN1_A_UPMETHOD_S)) -#define MCPWM_GEN1_A_UPMETHOD_V 0xF +/** MCPWM_GEN1_STMP_CFG_REG register + * Transfer status and update method for time stamp registers A and B + */ +#define MCPWM_GEN1_STMP_CFG_REG(i) (DR_REG_MCPWM_BASE(i) + 0x74) +/** MCPWM_GEN1_A_UPMETHOD : R/W; bitpos: [3:0]; default: 0; + * Update method for PWM generator 1 time stamp A's active register. When all bits are + * set to 0: immediately, when bit0 is set to 1: TEZ, when bit1 is set to 1: TEP,when + * bit2 is set to 1: sync, when bit3 is set to 1: disable the update. + */ +#define MCPWM_GEN1_A_UPMETHOD 0x0000000FU +#define MCPWM_GEN1_A_UPMETHOD_M (MCPWM_GEN1_A_UPMETHOD_V << MCPWM_GEN1_A_UPMETHOD_S) +#define MCPWM_GEN1_A_UPMETHOD_V 0x0000000FU #define MCPWM_GEN1_A_UPMETHOD_S 0 +/** MCPWM_GEN1_B_UPMETHOD : R/W; bitpos: [7:4]; default: 0; + * Update method for PWM generator 1 time stamp B's active register. When all bits are + * set to 0: immediately, when bit0 is set to 1: TEZ, when bit1 is set to 1: TEP,when + * bit2 is set to 1: sync, when bit3 is set to 1: disable the update. + */ +#define MCPWM_GEN1_B_UPMETHOD 0x0000000FU +#define MCPWM_GEN1_B_UPMETHOD_M (MCPWM_GEN1_B_UPMETHOD_V << MCPWM_GEN1_B_UPMETHOD_S) +#define MCPWM_GEN1_B_UPMETHOD_V 0x0000000FU +#define MCPWM_GEN1_B_UPMETHOD_S 4 +/** MCPWM_GEN1_A_SHDW_FULL : R/W/WTC/SC; bitpos: [8]; default: 0; + * Set and reset by hardware. If set, PWM generator 1 time stamp A's shadow reg is + * filled and waiting to be transferred to A's active reg. If cleared, A's active reg + * has been updated with shadow register latest value + */ +#define MCPWM_GEN1_A_SHDW_FULL (BIT(8)) +#define MCPWM_GEN1_A_SHDW_FULL_M (MCPWM_GEN1_A_SHDW_FULL_V << MCPWM_GEN1_A_SHDW_FULL_S) +#define MCPWM_GEN1_A_SHDW_FULL_V 0x00000001U +#define MCPWM_GEN1_A_SHDW_FULL_S 8 +/** MCPWM_GEN1_B_SHDW_FULL : R/W/WTC/SC; bitpos: [9]; default: 0; + * Set and reset by hardware. If set, PWM generator 1 time stamp B's shadow reg is + * filled and waiting to be transferred to B's active reg. If cleared, B's active reg + * has been updated with shadow register latest value + */ +#define MCPWM_GEN1_B_SHDW_FULL (BIT(9)) +#define MCPWM_GEN1_B_SHDW_FULL_M (MCPWM_GEN1_B_SHDW_FULL_V << MCPWM_GEN1_B_SHDW_FULL_S) +#define MCPWM_GEN1_B_SHDW_FULL_V 0x00000001U +#define MCPWM_GEN1_B_SHDW_FULL_S 9 -#define MCPWM_GEN1_TSTMP_A_REG(i) (REG_MCPWM_BASE(i) + 0x0078) -/* MCPWM_GEN1_A : R/W ;bitpos:[15:0] ;default: 16'd0 ; */ -/*description: PWM generator 1 time stamp A's shadow reg*/ -#define MCPWM_GEN1_A 0x0000FFFF -#define MCPWM_GEN1_A_M ((MCPWM_GEN1_A_V)<<(MCPWM_GEN1_A_S)) -#define MCPWM_GEN1_A_V 0xFFFF +/** MCPWM_GEN1_TSTMP_A_REG register + * PWM generator 1 shadow register for timer stamp A. + */ +#define MCPWM_GEN1_TSTMP_A_REG(i) (DR_REG_MCPWM_BASE(i) + 0x78) +/** MCPWM_GEN1_A : R/W; bitpos: [15:0]; default: 0; + * PWM generator 1 time stamp A's shadow register + */ +#define MCPWM_GEN1_A 0x0000FFFFU +#define MCPWM_GEN1_A_M (MCPWM_GEN1_A_V << MCPWM_GEN1_A_S) +#define MCPWM_GEN1_A_V 0x0000FFFFU #define MCPWM_GEN1_A_S 0 -#define MCPWM_GEN1_TSTMP_B_REG(i) (REG_MCPWM_BASE(i) + 0x007c) -/* MCPWM_GEN1_B : R/W ;bitpos:[15:0] ;default: 16'd0 ; */ -/*description: PWM generator 1 time stamp B's shadow reg*/ -#define MCPWM_GEN1_B 0x0000FFFF -#define MCPWM_GEN1_B_M ((MCPWM_GEN1_B_V)<<(MCPWM_GEN1_B_S)) -#define MCPWM_GEN1_B_V 0xFFFF +/** MCPWM_GEN1_TSTMP_B_REG register + * PWM generator 1 shadow register for timer stamp B. + */ +#define MCPWM_GEN1_TSTMP_B_REG(i) (DR_REG_MCPWM_BASE(i) + 0x7c) +/** MCPWM_GEN1_B : R/W; bitpos: [15:0]; default: 0; + * PWM generator 1 time stamp B's shadow register + */ +#define MCPWM_GEN1_B 0x0000FFFFU +#define MCPWM_GEN1_B_M (MCPWM_GEN1_B_V << MCPWM_GEN1_B_S) +#define MCPWM_GEN1_B_V 0x0000FFFFU #define MCPWM_GEN1_B_S 0 -#define MCPWM_GEN1_CFG0_REG(i) (REG_MCPWM_BASE(i) + 0x0080) -/* MCPWM_GEN1_T1_SEL : R/W ;bitpos:[9:7] ;default: 3'd0 ; */ -/*description: Source selection for PWM generate1 event_t1 take effect immediately - 0: fault_event0 1: fault_event1 2: fault_event2 3: sync_taken 4: none*/ -#define MCPWM_GEN1_T1_SEL 0x00000007 -#define MCPWM_GEN1_T1_SEL_M ((MCPWM_GEN1_T1_SEL_V)<<(MCPWM_GEN1_T1_SEL_S)) -#define MCPWM_GEN1_T1_SEL_V 0x7 -#define MCPWM_GEN1_T1_SEL_S 7 -/* MCPWM_GEN1_T0_SEL : R/W ;bitpos:[6:4] ;default: 3'd0 ; */ -/*description: Source selection for PWM generate1 event_t0 take effect immediately - 0: fault_event0 1: fault_event1 2: fault_event2 3: sync_taken 4: none*/ -#define MCPWM_GEN1_T0_SEL 0x00000007 -#define MCPWM_GEN1_T0_SEL_M ((MCPWM_GEN1_T0_SEL_V)<<(MCPWM_GEN1_T0_SEL_S)) -#define MCPWM_GEN1_T0_SEL_V 0x7 -#define MCPWM_GEN1_T0_SEL_S 4 -/* MCPWM_GEN1_CFG_UPMETHOD : R/W ;bitpos:[3:0] ;default: 4'd0 ; */ -/*description: Update method for PWM generate1's active reg of configuration. - 0: immediate bit0: TEZ bit1: TEP bit2: sync. bit3: disable update*/ -#define MCPWM_GEN1_CFG_UPMETHOD 0x0000000F -#define MCPWM_GEN1_CFG_UPMETHOD_M ((MCPWM_GEN1_CFG_UPMETHOD_V)<<(MCPWM_GEN1_CFG_UPMETHOD_S)) -#define MCPWM_GEN1_CFG_UPMETHOD_V 0xF +/** MCPWM_GEN1_CFG0_REG register + * PWM generator 1 event T0 and T1 handling + */ +#define MCPWM_GEN1_CFG0_REG(i) (DR_REG_MCPWM_BASE(i) + 0x80) +/** MCPWM_GEN1_CFG_UPMETHOD : R/W; bitpos: [3:0]; default: 0; + * Update method for PWM generator 1's active register of configuration. When all bits + * are set to 0: immediately, when bit0 is set to 1: TEZ, when bit1 is set to + * 1:sync;when bit3 is set to 1:disable the update. + */ +#define MCPWM_GEN1_CFG_UPMETHOD 0x0000000FU +#define MCPWM_GEN1_CFG_UPMETHOD_M (MCPWM_GEN1_CFG_UPMETHOD_V << MCPWM_GEN1_CFG_UPMETHOD_S) +#define MCPWM_GEN1_CFG_UPMETHOD_V 0x0000000FU #define MCPWM_GEN1_CFG_UPMETHOD_S 0 +/** MCPWM_GEN1_T0_SEL : R/W; bitpos: [6:4]; default: 0; + * Source selection for PWM generator 1 event_t0, take effect immediately, 0: + * fault_event0, 1: fault_event1, 2: fault_event2, 3: sync_taken, 4: none + */ +#define MCPWM_GEN1_T0_SEL 0x00000007U +#define MCPWM_GEN1_T0_SEL_M (MCPWM_GEN1_T0_SEL_V << MCPWM_GEN1_T0_SEL_S) +#define MCPWM_GEN1_T0_SEL_V 0x00000007U +#define MCPWM_GEN1_T0_SEL_S 4 +/** MCPWM_GEN1_T1_SEL : R/W; bitpos: [9:7]; default: 0; + * Source selection for PWM generator 1 event_t1, take effect immediately, 0: + * fault_event0, 1: fault_event1, 2: fault_event2, 3: sync_taken, 4: none + */ +#define MCPWM_GEN1_T1_SEL 0x00000007U +#define MCPWM_GEN1_T1_SEL_M (MCPWM_GEN1_T1_SEL_V << MCPWM_GEN1_T1_SEL_S) +#define MCPWM_GEN1_T1_SEL_V 0x00000007U +#define MCPWM_GEN1_T1_SEL_S 7 -#define MCPWM_GEN1_FORCE_REG(i) (REG_MCPWM_BASE(i) + 0x0084) -/* MCPWM_GEN1_B_NCIFORCE_MODE : R/W ;bitpos:[15:14] ;default: 2'd0 ; */ -/*description: Non-continuous immediate software force mode for PWM1B 0: disabled - 1: low 2: high 3: disabled*/ -#define MCPWM_GEN1_B_NCIFORCE_MODE 0x00000003 -#define MCPWM_GEN1_B_NCIFORCE_MODE_M ((MCPWM_GEN1_B_NCIFORCE_MODE_V)<<(MCPWM_GEN1_B_NCIFORCE_MODE_S)) -#define MCPWM_GEN1_B_NCIFORCE_MODE_V 0x3 -#define MCPWM_GEN1_B_NCIFORCE_MODE_S 14 -/* MCPWM_GEN1_B_NCIFORCE : R/W ;bitpos:[13] ;default: 1'd0 ; */ -/*description: Non-continuous immediate software force trigger for PWM1B a - toggle will trigger a force event*/ -#define MCPWM_GEN1_B_NCIFORCE (BIT(13)) -#define MCPWM_GEN1_B_NCIFORCE_M (BIT(13)) -#define MCPWM_GEN1_B_NCIFORCE_V 0x1 -#define MCPWM_GEN1_B_NCIFORCE_S 13 -/* MCPWM_GEN1_A_NCIFORCE_MODE : R/W ;bitpos:[12:11] ;default: 2'd0 ; */ -/*description: Non-continuous immediate software force mode for PWM1A 0: disabled - 1: low 2: high 3: disabled*/ -#define MCPWM_GEN1_A_NCIFORCE_MODE 0x00000003 -#define MCPWM_GEN1_A_NCIFORCE_MODE_M ((MCPWM_GEN1_A_NCIFORCE_MODE_V)<<(MCPWM_GEN1_A_NCIFORCE_MODE_S)) -#define MCPWM_GEN1_A_NCIFORCE_MODE_V 0x3 -#define MCPWM_GEN1_A_NCIFORCE_MODE_S 11 -/* MCPWM_GEN1_A_NCIFORCE : R/W ;bitpos:[10] ;default: 1'd0 ; */ -/*description: Non-continuous immediate software force trigger for PWM1A a - toggle will trigger a force event*/ -#define MCPWM_GEN1_A_NCIFORCE (BIT(10)) -#define MCPWM_GEN1_A_NCIFORCE_M (BIT(10)) -#define MCPWM_GEN1_A_NCIFORCE_V 0x1 -#define MCPWM_GEN1_A_NCIFORCE_S 10 -/* MCPWM_GEN1_B_CNTUFORCE_MODE : R/W ;bitpos:[9:8] ;default: 2'd0 ; */ -/*description: Continuous software force mode for PWM1B. 0: disabled 1: low - 2: high 3: disabled*/ -#define MCPWM_GEN1_B_CNTUFORCE_MODE 0x00000003 -#define MCPWM_GEN1_B_CNTUFORCE_MODE_M ((MCPWM_GEN1_B_CNTUFORCE_MODE_V)<<(MCPWM_GEN1_B_CNTUFORCE_MODE_S)) -#define MCPWM_GEN1_B_CNTUFORCE_MODE_V 0x3 -#define MCPWM_GEN1_B_CNTUFORCE_MODE_S 8 -/* MCPWM_GEN1_A_CNTUFORCE_MODE : R/W ;bitpos:[7:6] ;default: 2'd0 ; */ -/*description: Continuous software force mode for PWM1A. 0: disabled 1: low - 2: high 3: disabled*/ -#define MCPWM_GEN1_A_CNTUFORCE_MODE 0x00000003 -#define MCPWM_GEN1_A_CNTUFORCE_MODE_M ((MCPWM_GEN1_A_CNTUFORCE_MODE_V)<<(MCPWM_GEN1_A_CNTUFORCE_MODE_S)) -#define MCPWM_GEN1_A_CNTUFORCE_MODE_V 0x3 -#define MCPWM_GEN1_A_CNTUFORCE_MODE_S 6 -/* MCPWM_GEN1_CNTUFORCE_UPMETHOD : R/W ;bitpos:[5:0] ;default: 6'h20 ; */ -/*description: Update method for continuous software force of PWM generator1. - 0: immediate bit0: TEZ bit1: TEP bit2: TEA bit3: TEB bit4: sync bit5: disable update. (TEA/B here and below means an event generated when timer value equals A/B register)*/ -#define MCPWM_GEN1_CNTUFORCE_UPMETHOD 0x0000003F -#define MCPWM_GEN1_CNTUFORCE_UPMETHOD_M ((MCPWM_GEN1_CNTUFORCE_UPMETHOD_V)<<(MCPWM_GEN1_CNTUFORCE_UPMETHOD_S)) -#define MCPWM_GEN1_CNTUFORCE_UPMETHOD_V 0x3F +/** MCPWM_GEN1_FORCE_REG register + * Permissives to force PWM1A and PWM1B outputs by software + */ +#define MCPWM_GEN1_FORCE_REG(i) (DR_REG_MCPWM_BASE(i) + 0x84) +/** MCPWM_GEN1_CNTUFORCE_UPMETHOD : R/W; bitpos: [5:0]; default: 32; + * Updating method for continuous software force of PWM generator 1. When all bits are + * set to 0: immediately, when bit0 is set to 1: TEZ,when bit1 is set to 1: TEP, when + * bit2 is set to 1: TEA, when bit3 is set to 1: TEB, when bit4 is set to 1: sync, + * when bit5 is set to 1: disable update. (TEA/B here and below means an event + * generated when the timer's value equals to that of register A/B.) + */ +#define MCPWM_GEN1_CNTUFORCE_UPMETHOD 0x0000003FU +#define MCPWM_GEN1_CNTUFORCE_UPMETHOD_M (MCPWM_GEN1_CNTUFORCE_UPMETHOD_V << MCPWM_GEN1_CNTUFORCE_UPMETHOD_S) +#define MCPWM_GEN1_CNTUFORCE_UPMETHOD_V 0x0000003FU #define MCPWM_GEN1_CNTUFORCE_UPMETHOD_S 0 +/** MCPWM_GEN1_A_CNTUFORCE_MODE : R/W; bitpos: [7:6]; default: 0; + * Continuous software force mode for PWM1A. 0: disabled, 1: low, 2: high, 3: disabled + */ +#define MCPWM_GEN1_A_CNTUFORCE_MODE 0x00000003U +#define MCPWM_GEN1_A_CNTUFORCE_MODE_M (MCPWM_GEN1_A_CNTUFORCE_MODE_V << MCPWM_GEN1_A_CNTUFORCE_MODE_S) +#define MCPWM_GEN1_A_CNTUFORCE_MODE_V 0x00000003U +#define MCPWM_GEN1_A_CNTUFORCE_MODE_S 6 +/** MCPWM_GEN1_B_CNTUFORCE_MODE : R/W; bitpos: [9:8]; default: 0; + * Continuous software force mode for PWM1B. 0: disabled, 1: low, 2: high, 3: disabled + */ +#define MCPWM_GEN1_B_CNTUFORCE_MODE 0x00000003U +#define MCPWM_GEN1_B_CNTUFORCE_MODE_M (MCPWM_GEN1_B_CNTUFORCE_MODE_V << MCPWM_GEN1_B_CNTUFORCE_MODE_S) +#define MCPWM_GEN1_B_CNTUFORCE_MODE_V 0x00000003U +#define MCPWM_GEN1_B_CNTUFORCE_MODE_S 8 +/** MCPWM_GEN1_A_NCIFORCE : R/W; bitpos: [10]; default: 0; + * Trigger of non-continuous immediate software-force event for PWM1A, a toggle will + * trigger a force event. + */ +#define MCPWM_GEN1_A_NCIFORCE (BIT(10)) +#define MCPWM_GEN1_A_NCIFORCE_M (MCPWM_GEN1_A_NCIFORCE_V << MCPWM_GEN1_A_NCIFORCE_S) +#define MCPWM_GEN1_A_NCIFORCE_V 0x00000001U +#define MCPWM_GEN1_A_NCIFORCE_S 10 +/** MCPWM_GEN1_A_NCIFORCE_MODE : R/W; bitpos: [12:11]; default: 0; + * non-continuous immediate software force mode for PWM1A, 0: disabled, 1: low, 2: + * high, 3: disabled + */ +#define MCPWM_GEN1_A_NCIFORCE_MODE 0x00000003U +#define MCPWM_GEN1_A_NCIFORCE_MODE_M (MCPWM_GEN1_A_NCIFORCE_MODE_V << MCPWM_GEN1_A_NCIFORCE_MODE_S) +#define MCPWM_GEN1_A_NCIFORCE_MODE_V 0x00000003U +#define MCPWM_GEN1_A_NCIFORCE_MODE_S 11 +/** MCPWM_GEN1_B_NCIFORCE : R/W; bitpos: [13]; default: 0; + * Trigger of non-continuous immediate software-force event for PWM1B, a toggle will + * trigger a force event. + */ +#define MCPWM_GEN1_B_NCIFORCE (BIT(13)) +#define MCPWM_GEN1_B_NCIFORCE_M (MCPWM_GEN1_B_NCIFORCE_V << MCPWM_GEN1_B_NCIFORCE_S) +#define MCPWM_GEN1_B_NCIFORCE_V 0x00000001U +#define MCPWM_GEN1_B_NCIFORCE_S 13 +/** MCPWM_GEN1_B_NCIFORCE_MODE : R/W; bitpos: [15:14]; default: 0; + * non-continuous immediate software force mode for PWM1B, 0: disabled, 1: low, 2: + * high, 3: disabled + */ +#define MCPWM_GEN1_B_NCIFORCE_MODE 0x00000003U +#define MCPWM_GEN1_B_NCIFORCE_MODE_M (MCPWM_GEN1_B_NCIFORCE_MODE_V << MCPWM_GEN1_B_NCIFORCE_MODE_S) +#define MCPWM_GEN1_B_NCIFORCE_MODE_V 0x00000003U +#define MCPWM_GEN1_B_NCIFORCE_MODE_S 14 -#define MCPWM_GEN1_A_REG(i) (REG_MCPWM_BASE(i) + 0x0088) -/* MCPWM_GEN1_A_DT1 : R/W ;bitpos:[23:22] ;default: 2'd0 ; */ -/*description: Action on PWM1A triggered by event_t1 when timer decreasing. - 0: no change 1: low 2: high 3: toggle*/ -#define MCPWM_GEN1_A_DT1 0x00000003 -#define MCPWM_GEN1_A_DT1_M ((MCPWM_GEN1_A_DT1_V)<<(MCPWM_GEN1_A_DT1_S)) -#define MCPWM_GEN1_A_DT1_V 0x3 -#define MCPWM_GEN1_A_DT1_S 22 -/* MCPWM_GEN1_A_DT0 : R/W ;bitpos:[21:20] ;default: 2'd0 ; */ -/*description: Action on PWM1A triggered by event_t0 when timer decreasing*/ -#define MCPWM_GEN1_A_DT0 0x00000003 -#define MCPWM_GEN1_A_DT0_M ((MCPWM_GEN1_A_DT0_V)<<(MCPWM_GEN1_A_DT0_S)) -#define MCPWM_GEN1_A_DT0_V 0x3 -#define MCPWM_GEN1_A_DT0_S 20 -/* MCPWM_GEN1_A_DTEB : R/W ;bitpos:[19:18] ;default: 2'd0 ; */ -/*description: Action on PWM1A triggered by event TEB when timer decreasing*/ -#define MCPWM_GEN1_A_DTEB 0x00000003 -#define MCPWM_GEN1_A_DTEB_M ((MCPWM_GEN1_A_DTEB_V)<<(MCPWM_GEN1_A_DTEB_S)) -#define MCPWM_GEN1_A_DTEB_V 0x3 -#define MCPWM_GEN1_A_DTEB_S 18 -/* MCPWM_GEN1_A_DTEA : R/W ;bitpos:[17:16] ;default: 2'd0 ; */ -/*description: Action on PWM1A triggered by event TEA when timer decreasing*/ -#define MCPWM_GEN1_A_DTEA 0x00000003 -#define MCPWM_GEN1_A_DTEA_M ((MCPWM_GEN1_A_DTEA_V)<<(MCPWM_GEN1_A_DTEA_S)) -#define MCPWM_GEN1_A_DTEA_V 0x3 -#define MCPWM_GEN1_A_DTEA_S 16 -/* MCPWM_GEN1_A_DTEP : R/W ;bitpos:[15:14] ;default: 2'd0 ; */ -/*description: Action on PWM1A triggered by event TEP when timer decreasing*/ -#define MCPWM_GEN1_A_DTEP 0x00000003 -#define MCPWM_GEN1_A_DTEP_M ((MCPWM_GEN1_A_DTEP_V)<<(MCPWM_GEN1_A_DTEP_S)) -#define MCPWM_GEN1_A_DTEP_V 0x3 -#define MCPWM_GEN1_A_DTEP_S 14 -/* MCPWM_GEN1_A_DTEZ : R/W ;bitpos:[13:12] ;default: 2'd0 ; */ -/*description: Action on PWM1A triggered by event TEZ when timer decreasing*/ -#define MCPWM_GEN1_A_DTEZ 0x00000003 -#define MCPWM_GEN1_A_DTEZ_M ((MCPWM_GEN1_A_DTEZ_V)<<(MCPWM_GEN1_A_DTEZ_S)) -#define MCPWM_GEN1_A_DTEZ_V 0x3 -#define MCPWM_GEN1_A_DTEZ_S 12 -/* MCPWM_GEN1_A_UT1 : R/W ;bitpos:[11:10] ;default: 2'd0 ; */ -/*description: Action on PWM1A triggered by event_t1 when timer increasing*/ -#define MCPWM_GEN1_A_UT1 0x00000003 -#define MCPWM_GEN1_A_UT1_M ((MCPWM_GEN1_A_UT1_V)<<(MCPWM_GEN1_A_UT1_S)) -#define MCPWM_GEN1_A_UT1_V 0x3 -#define MCPWM_GEN1_A_UT1_S 10 -/* MCPWM_GEN1_A_UT0 : R/W ;bitpos:[9:8] ;default: 2'd0 ; */ -/*description: Action on PWM1A triggered by event_t0 when timer increasing*/ -#define MCPWM_GEN1_A_UT0 0x00000003 -#define MCPWM_GEN1_A_UT0_M ((MCPWM_GEN1_A_UT0_V)<<(MCPWM_GEN1_A_UT0_S)) -#define MCPWM_GEN1_A_UT0_V 0x3 -#define MCPWM_GEN1_A_UT0_S 8 -/* MCPWM_GEN1_A_UTEB : R/W ;bitpos:[7:6] ;default: 2'd0 ; */ -/*description: Action on PWM1A triggered by event TEB when timer increasing*/ -#define MCPWM_GEN1_A_UTEB 0x00000003 -#define MCPWM_GEN1_A_UTEB_M ((MCPWM_GEN1_A_UTEB_V)<<(MCPWM_GEN1_A_UTEB_S)) -#define MCPWM_GEN1_A_UTEB_V 0x3 -#define MCPWM_GEN1_A_UTEB_S 6 -/* MCPWM_GEN1_A_UTEA : R/W ;bitpos:[5:4] ;default: 2'd0 ; */ -/*description: Action on PWM1A triggered by event TEA when timer increasing*/ -#define MCPWM_GEN1_A_UTEA 0x00000003 -#define MCPWM_GEN1_A_UTEA_M ((MCPWM_GEN1_A_UTEA_V)<<(MCPWM_GEN1_A_UTEA_S)) -#define MCPWM_GEN1_A_UTEA_V 0x3 -#define MCPWM_GEN1_A_UTEA_S 4 -/* MCPWM_GEN1_A_UTEP : R/W ;bitpos:[3:2] ;default: 2'd0 ; */ -/*description: Action on PWM1A triggered by event TEP when timer increasing*/ -#define MCPWM_GEN1_A_UTEP 0x00000003 -#define MCPWM_GEN1_A_UTEP_M ((MCPWM_GEN1_A_UTEP_V)<<(MCPWM_GEN1_A_UTEP_S)) -#define MCPWM_GEN1_A_UTEP_V 0x3 -#define MCPWM_GEN1_A_UTEP_S 2 -/* MCPWM_GEN1_A_UTEZ : R/W ;bitpos:[1:0] ;default: 2'd0 ; */ -/*description: Action on PWM1A triggered by event TEZ when timer increasing*/ -#define MCPWM_GEN1_A_UTEZ 0x00000003 -#define MCPWM_GEN1_A_UTEZ_M ((MCPWM_GEN1_A_UTEZ_V)<<(MCPWM_GEN1_A_UTEZ_S)) -#define MCPWM_GEN1_A_UTEZ_V 0x3 +/** MCPWM_GEN1_A_REG register + * Actions triggered by events on PWM1A + */ +#define MCPWM_GEN1_A_REG(i) (DR_REG_MCPWM_BASE(i) + 0x88) +/** MCPWM_GEN1_A_UTEZ : R/W; bitpos: [1:0]; default: 0; + * Action on PWM1A triggered by event TEZ when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN1_A_UTEZ 0x00000003U +#define MCPWM_GEN1_A_UTEZ_M (MCPWM_GEN1_A_UTEZ_V << MCPWM_GEN1_A_UTEZ_S) +#define MCPWM_GEN1_A_UTEZ_V 0x00000003U #define MCPWM_GEN1_A_UTEZ_S 0 +/** MCPWM_GEN1_A_UTEP : R/W; bitpos: [3:2]; default: 0; + * Action on PWM1A triggered by event TEP when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN1_A_UTEP 0x00000003U +#define MCPWM_GEN1_A_UTEP_M (MCPWM_GEN1_A_UTEP_V << MCPWM_GEN1_A_UTEP_S) +#define MCPWM_GEN1_A_UTEP_V 0x00000003U +#define MCPWM_GEN1_A_UTEP_S 2 +/** MCPWM_GEN1_A_UTEA : R/W; bitpos: [5:4]; default: 0; + * Action on PWM1A triggered by event TEA when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN1_A_UTEA 0x00000003U +#define MCPWM_GEN1_A_UTEA_M (MCPWM_GEN1_A_UTEA_V << MCPWM_GEN1_A_UTEA_S) +#define MCPWM_GEN1_A_UTEA_V 0x00000003U +#define MCPWM_GEN1_A_UTEA_S 4 +/** MCPWM_GEN1_A_UTEB : R/W; bitpos: [7:6]; default: 0; + * Action on PWM1A triggered by event TEB when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN1_A_UTEB 0x00000003U +#define MCPWM_GEN1_A_UTEB_M (MCPWM_GEN1_A_UTEB_V << MCPWM_GEN1_A_UTEB_S) +#define MCPWM_GEN1_A_UTEB_V 0x00000003U +#define MCPWM_GEN1_A_UTEB_S 6 +/** MCPWM_GEN1_A_UT0 : R/W; bitpos: [9:8]; default: 0; + * Action on PWM1A triggered by event_t0 when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN1_A_UT0 0x00000003U +#define MCPWM_GEN1_A_UT0_M (MCPWM_GEN1_A_UT0_V << MCPWM_GEN1_A_UT0_S) +#define MCPWM_GEN1_A_UT0_V 0x00000003U +#define MCPWM_GEN1_A_UT0_S 8 +/** MCPWM_GEN1_A_UT1 : R/W; bitpos: [11:10]; default: 0; + * Action on PWM1A triggered by event_t1 when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN1_A_UT1 0x00000003U +#define MCPWM_GEN1_A_UT1_M (MCPWM_GEN1_A_UT1_V << MCPWM_GEN1_A_UT1_S) +#define MCPWM_GEN1_A_UT1_V 0x00000003U +#define MCPWM_GEN1_A_UT1_S 10 +/** MCPWM_GEN1_A_DTEZ : R/W; bitpos: [13:12]; default: 0; + * Action on PWM1A triggered by event TEZ when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN1_A_DTEZ 0x00000003U +#define MCPWM_GEN1_A_DTEZ_M (MCPWM_GEN1_A_DTEZ_V << MCPWM_GEN1_A_DTEZ_S) +#define MCPWM_GEN1_A_DTEZ_V 0x00000003U +#define MCPWM_GEN1_A_DTEZ_S 12 +/** MCPWM_GEN1_A_DTEP : R/W; bitpos: [15:14]; default: 0; + * Action on PWM1A triggered by event TEP when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN1_A_DTEP 0x00000003U +#define MCPWM_GEN1_A_DTEP_M (MCPWM_GEN1_A_DTEP_V << MCPWM_GEN1_A_DTEP_S) +#define MCPWM_GEN1_A_DTEP_V 0x00000003U +#define MCPWM_GEN1_A_DTEP_S 14 +/** MCPWM_GEN1_A_DTEA : R/W; bitpos: [17:16]; default: 0; + * Action on PWM1A triggered by event TEA when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN1_A_DTEA 0x00000003U +#define MCPWM_GEN1_A_DTEA_M (MCPWM_GEN1_A_DTEA_V << MCPWM_GEN1_A_DTEA_S) +#define MCPWM_GEN1_A_DTEA_V 0x00000003U +#define MCPWM_GEN1_A_DTEA_S 16 +/** MCPWM_GEN1_A_DTEB : R/W; bitpos: [19:18]; default: 0; + * Action on PWM1A triggered by event TEB when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN1_A_DTEB 0x00000003U +#define MCPWM_GEN1_A_DTEB_M (MCPWM_GEN1_A_DTEB_V << MCPWM_GEN1_A_DTEB_S) +#define MCPWM_GEN1_A_DTEB_V 0x00000003U +#define MCPWM_GEN1_A_DTEB_S 18 +/** MCPWM_GEN1_A_DT0 : R/W; bitpos: [21:20]; default: 0; + * Action on PWM1A triggered by event_t0 when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN1_A_DT0 0x00000003U +#define MCPWM_GEN1_A_DT0_M (MCPWM_GEN1_A_DT0_V << MCPWM_GEN1_A_DT0_S) +#define MCPWM_GEN1_A_DT0_V 0x00000003U +#define MCPWM_GEN1_A_DT0_S 20 +/** MCPWM_GEN1_A_DT1 : R/W; bitpos: [23:22]; default: 0; + * Action on PWM1A triggered by event_t1 when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN1_A_DT1 0x00000003U +#define MCPWM_GEN1_A_DT1_M (MCPWM_GEN1_A_DT1_V << MCPWM_GEN1_A_DT1_S) +#define MCPWM_GEN1_A_DT1_V 0x00000003U +#define MCPWM_GEN1_A_DT1_S 22 -#define MCPWM_GEN1_B_REG(i) (REG_MCPWM_BASE(i) + 0x008c) -/* MCPWM_GEN1_B_DT1 : R/W ;bitpos:[23:22] ;default: 2'd0 ; */ -/*description: Action on PWM1B triggered by event_t1 when timer decreasing. - 0: no change 1: low 2: high 3: toggle*/ -#define MCPWM_GEN1_B_DT1 0x00000003 -#define MCPWM_GEN1_B_DT1_M ((MCPWM_GEN1_B_DT1_V)<<(MCPWM_GEN1_B_DT1_S)) -#define MCPWM_GEN1_B_DT1_V 0x3 -#define MCPWM_GEN1_B_DT1_S 22 -/* MCPWM_GEN1_B_DT0 : R/W ;bitpos:[21:20] ;default: 2'd0 ; */ -/*description: Action on PWM1B triggered by event_t0 when timer decreasing*/ -#define MCPWM_GEN1_B_DT0 0x00000003 -#define MCPWM_GEN1_B_DT0_M ((MCPWM_GEN1_B_DT0_V)<<(MCPWM_GEN1_B_DT0_S)) -#define MCPWM_GEN1_B_DT0_V 0x3 -#define MCPWM_GEN1_B_DT0_S 20 -/* MCPWM_GEN1_B_DTEB : R/W ;bitpos:[19:18] ;default: 2'd0 ; */ -/*description: Action on PWM1B triggered by event TEB when timer decreasing*/ -#define MCPWM_GEN1_B_DTEB 0x00000003 -#define MCPWM_GEN1_B_DTEB_M ((MCPWM_GEN1_B_DTEB_V)<<(MCPWM_GEN1_B_DTEB_S)) -#define MCPWM_GEN1_B_DTEB_V 0x3 -#define MCPWM_GEN1_B_DTEB_S 18 -/* MCPWM_GEN1_B_DTEA : R/W ;bitpos:[17:16] ;default: 2'd0 ; */ -/*description: Action on PWM1B triggered by event TEA when timer decreasing*/ -#define MCPWM_GEN1_B_DTEA 0x00000003 -#define MCPWM_GEN1_B_DTEA_M ((MCPWM_GEN1_B_DTEA_V)<<(MCPWM_GEN1_B_DTEA_S)) -#define MCPWM_GEN1_B_DTEA_V 0x3 -#define MCPWM_GEN1_B_DTEA_S 16 -/* MCPWM_GEN1_B_DTEP : R/W ;bitpos:[15:14] ;default: 2'd0 ; */ -/*description: Action on PWM1B triggered by event TEP when timer decreasing*/ -#define MCPWM_GEN1_B_DTEP 0x00000003 -#define MCPWM_GEN1_B_DTEP_M ((MCPWM_GEN1_B_DTEP_V)<<(MCPWM_GEN1_B_DTEP_S)) -#define MCPWM_GEN1_B_DTEP_V 0x3 -#define MCPWM_GEN1_B_DTEP_S 14 -/* MCPWM_GEN1_B_DTEZ : R/W ;bitpos:[13:12] ;default: 2'd0 ; */ -/*description: Action on PWM1B triggered by event TEZ when timer decreasing*/ -#define MCPWM_GEN1_B_DTEZ 0x00000003 -#define MCPWM_GEN1_B_DTEZ_M ((MCPWM_GEN1_B_DTEZ_V)<<(MCPWM_GEN1_B_DTEZ_S)) -#define MCPWM_GEN1_B_DTEZ_V 0x3 -#define MCPWM_GEN1_B_DTEZ_S 12 -/* MCPWM_GEN1_B_UT1 : R/W ;bitpos:[11:10] ;default: 2'd0 ; */ -/*description: Action on PWM1B triggered by event_t1 when timer increasing*/ -#define MCPWM_GEN1_B_UT1 0x00000003 -#define MCPWM_GEN1_B_UT1_M ((MCPWM_GEN1_B_UT1_V)<<(MCPWM_GEN1_B_UT1_S)) -#define MCPWM_GEN1_B_UT1_V 0x3 -#define MCPWM_GEN1_B_UT1_S 10 -/* MCPWM_GEN1_B_UT0 : R/W ;bitpos:[9:8] ;default: 2'd0 ; */ -/*description: Action on PWM1B triggered by event_t0 when timer increasing*/ -#define MCPWM_GEN1_B_UT0 0x00000003 -#define MCPWM_GEN1_B_UT0_M ((MCPWM_GEN1_B_UT0_V)<<(MCPWM_GEN1_B_UT0_S)) -#define MCPWM_GEN1_B_UT0_V 0x3 -#define MCPWM_GEN1_B_UT0_S 8 -/* MCPWM_GEN1_B_UTEB : R/W ;bitpos:[7:6] ;default: 2'd0 ; */ -/*description: Action on PWM1B triggered by event TEB when timer increasing*/ -#define MCPWM_GEN1_B_UTEB 0x00000003 -#define MCPWM_GEN1_B_UTEB_M ((MCPWM_GEN1_B_UTEB_V)<<(MCPWM_GEN1_B_UTEB_S)) -#define MCPWM_GEN1_B_UTEB_V 0x3 -#define MCPWM_GEN1_B_UTEB_S 6 -/* MCPWM_GEN1_B_UTEA : R/W ;bitpos:[5:4] ;default: 2'd0 ; */ -/*description: Action on PWM1B triggered by event TEA when timer increasing*/ -#define MCPWM_GEN1_B_UTEA 0x00000003 -#define MCPWM_GEN1_B_UTEA_M ((MCPWM_GEN1_B_UTEA_V)<<(MCPWM_GEN1_B_UTEA_S)) -#define MCPWM_GEN1_B_UTEA_V 0x3 -#define MCPWM_GEN1_B_UTEA_S 4 -/* MCPWM_GEN1_B_UTEP : R/W ;bitpos:[3:2] ;default: 2'd0 ; */ -/*description: Action on PWM1B triggered by event TEP when timer increasing*/ -#define MCPWM_GEN1_B_UTEP 0x00000003 -#define MCPWM_GEN1_B_UTEP_M ((MCPWM_GEN1_B_UTEP_V)<<(MCPWM_GEN1_B_UTEP_S)) -#define MCPWM_GEN1_B_UTEP_V 0x3 -#define MCPWM_GEN1_B_UTEP_S 2 -/* MCPWM_GEN1_B_UTEZ : R/W ;bitpos:[1:0] ;default: 2'd0 ; */ -/*description: Action on PWM1B triggered by event TEZ when timer increasing*/ -#define MCPWM_GEN1_B_UTEZ 0x00000003 -#define MCPWM_GEN1_B_UTEZ_M ((MCPWM_GEN1_B_UTEZ_V)<<(MCPWM_GEN1_B_UTEZ_S)) -#define MCPWM_GEN1_B_UTEZ_V 0x3 +/** MCPWM_GEN1_B_REG register + * Actions triggered by events on PWM1B + */ +#define MCPWM_GEN1_B_REG(i) (DR_REG_MCPWM_BASE(i) + 0x8c) +/** MCPWM_GEN1_B_UTEZ : R/W; bitpos: [1:0]; default: 0; + * Action on PWM1B triggered by event TEZ when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN1_B_UTEZ 0x00000003U +#define MCPWM_GEN1_B_UTEZ_M (MCPWM_GEN1_B_UTEZ_V << MCPWM_GEN1_B_UTEZ_S) +#define MCPWM_GEN1_B_UTEZ_V 0x00000003U #define MCPWM_GEN1_B_UTEZ_S 0 - -#define MCPWM_DT1_CFG_REG(i) (REG_MCPWM_BASE(i) + 0x0090) -/* MCPWM_DT1_CLK_SEL : R/W ;bitpos:[17] ;default: 1'd0 ; */ -/*description: Dead time generator 1 clock selection. 0: PWM_clk 1: PT_clk*/ -#define MCPWM_DT1_CLK_SEL (BIT(17)) -#define MCPWM_DT1_CLK_SEL_M (BIT(17)) -#define MCPWM_DT1_CLK_SEL_V 0x1 -#define MCPWM_DT1_CLK_SEL_S 17 -/* MCPWM_DT1_B_OUTBYPASS : R/W ;bitpos:[16] ;default: 1'd1 ; */ -/*description: S0 in documentation*/ -#define MCPWM_DT1_B_OUTBYPASS (BIT(16)) -#define MCPWM_DT1_B_OUTBYPASS_M (BIT(16)) -#define MCPWM_DT1_B_OUTBYPASS_V 0x1 -#define MCPWM_DT1_B_OUTBYPASS_S 16 -/* MCPWM_DT1_A_OUTBYPASS : R/W ;bitpos:[15] ;default: 1'd1 ; */ -/*description: S1 in documentation*/ -#define MCPWM_DT1_A_OUTBYPASS (BIT(15)) -#define MCPWM_DT1_A_OUTBYPASS_M (BIT(15)) -#define MCPWM_DT1_A_OUTBYPASS_V 0x1 -#define MCPWM_DT1_A_OUTBYPASS_S 15 -/* MCPWM_DT1_FED_OUTINVERT : R/W ;bitpos:[14] ;default: 1'd0 ; */ -/*description: S3 in documentation*/ -#define MCPWM_DT1_FED_OUTINVERT (BIT(14)) -#define MCPWM_DT1_FED_OUTINVERT_M (BIT(14)) -#define MCPWM_DT1_FED_OUTINVERT_V 0x1 -#define MCPWM_DT1_FED_OUTINVERT_S 14 -/* MCPWM_DT1_RED_OUTINVERT : R/W ;bitpos:[13] ;default: 1'd0 ; */ -/*description: S2 in documentation*/ -#define MCPWM_DT1_RED_OUTINVERT (BIT(13)) -#define MCPWM_DT1_RED_OUTINVERT_M (BIT(13)) -#define MCPWM_DT1_RED_OUTINVERT_V 0x1 -#define MCPWM_DT1_RED_OUTINVERT_S 13 -/* MCPWM_DT1_FED_INSEL : R/W ;bitpos:[12] ;default: 1'd0 ; */ -/*description: S5 in documentation*/ -#define MCPWM_DT1_FED_INSEL (BIT(12)) -#define MCPWM_DT1_FED_INSEL_M (BIT(12)) -#define MCPWM_DT1_FED_INSEL_V 0x1 -#define MCPWM_DT1_FED_INSEL_S 12 -/* MCPWM_DT1_RED_INSEL : R/W ;bitpos:[11] ;default: 1'd0 ; */ -/*description: S4 in documentation*/ -#define MCPWM_DT1_RED_INSEL (BIT(11)) -#define MCPWM_DT1_RED_INSEL_M (BIT(11)) -#define MCPWM_DT1_RED_INSEL_V 0x1 -#define MCPWM_DT1_RED_INSEL_S 11 -/* MCPWM_DT1_B_OUTSWAP : R/W ;bitpos:[10] ;default: 1'd0 ; */ -/*description: S7 in documentation*/ -#define MCPWM_DT1_B_OUTSWAP (BIT(10)) -#define MCPWM_DT1_B_OUTSWAP_M (BIT(10)) -#define MCPWM_DT1_B_OUTSWAP_V 0x1 -#define MCPWM_DT1_B_OUTSWAP_S 10 -/* MCPWM_DT1_A_OUTSWAP : R/W ;bitpos:[9] ;default: 1'd0 ; */ -/*description: S6 in documentation*/ -#define MCPWM_DT1_A_OUTSWAP (BIT(9)) -#define MCPWM_DT1_A_OUTSWAP_M (BIT(9)) -#define MCPWM_DT1_A_OUTSWAP_V 0x1 -#define MCPWM_DT1_A_OUTSWAP_S 9 -/* MCPWM_DT1_DEB_MODE : R/W ;bitpos:[8] ;default: 1'd0 ; */ -/*description: S8 in documentation dual-edge B mode 0: FED/RED take effect - on different path separately 1: FED/RED take effect on B path A out is in bypass or normal operation mode*/ -#define MCPWM_DT1_DEB_MODE (BIT(8)) -#define MCPWM_DT1_DEB_MODE_M (BIT(8)) -#define MCPWM_DT1_DEB_MODE_V 0x1 -#define MCPWM_DT1_DEB_MODE_S 8 -/* MCPWM_DT1_RED_UPMETHOD : R/W ;bitpos:[7:4] ;default: 4'd0 ; */ -/*description: Update method for RED (rising edge delay) active reg. 0: immediate - bit0: TEZ bit1: TEP bit2: sync bit3: disable update*/ -#define MCPWM_DT1_RED_UPMETHOD 0x0000000F -#define MCPWM_DT1_RED_UPMETHOD_M ((MCPWM_DT1_RED_UPMETHOD_V)<<(MCPWM_DT1_RED_UPMETHOD_S)) -#define MCPWM_DT1_RED_UPMETHOD_V 0xF -#define MCPWM_DT1_RED_UPMETHOD_S 4 -/* MCPWM_DT1_FED_UPMETHOD : R/W ;bitpos:[3:0] ;default: 4'd0 ; */ -/*description: Update method for FED (falling edge delay) active reg. 0: immediate - bit0: TEZ bit1: TEP bit2: sync bit3: disable update*/ -#define MCPWM_DT1_FED_UPMETHOD 0x0000000F -#define MCPWM_DT1_FED_UPMETHOD_M ((MCPWM_DT1_FED_UPMETHOD_V)<<(MCPWM_DT1_FED_UPMETHOD_S)) -#define MCPWM_DT1_FED_UPMETHOD_V 0xF +/** MCPWM_GEN1_B_UTEP : R/W; bitpos: [3:2]; default: 0; + * Action on PWM1B triggered by event TEP when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN1_B_UTEP 0x00000003U +#define MCPWM_GEN1_B_UTEP_M (MCPWM_GEN1_B_UTEP_V << MCPWM_GEN1_B_UTEP_S) +#define MCPWM_GEN1_B_UTEP_V 0x00000003U +#define MCPWM_GEN1_B_UTEP_S 2 +/** MCPWM_GEN1_B_UTEA : R/W; bitpos: [5:4]; default: 0; + * Action on PWM1B triggered by event TEA when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN1_B_UTEA 0x00000003U +#define MCPWM_GEN1_B_UTEA_M (MCPWM_GEN1_B_UTEA_V << MCPWM_GEN1_B_UTEA_S) +#define MCPWM_GEN1_B_UTEA_V 0x00000003U +#define MCPWM_GEN1_B_UTEA_S 4 +/** MCPWM_GEN1_B_UTEB : R/W; bitpos: [7:6]; default: 0; + * Action on PWM1B triggered by event TEB when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN1_B_UTEB 0x00000003U +#define MCPWM_GEN1_B_UTEB_M (MCPWM_GEN1_B_UTEB_V << MCPWM_GEN1_B_UTEB_S) +#define MCPWM_GEN1_B_UTEB_V 0x00000003U +#define MCPWM_GEN1_B_UTEB_S 6 +/** MCPWM_GEN1_B_UT0 : R/W; bitpos: [9:8]; default: 0; + * Action on PWM1B triggered by event_t0 when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN1_B_UT0 0x00000003U +#define MCPWM_GEN1_B_UT0_M (MCPWM_GEN1_B_UT0_V << MCPWM_GEN1_B_UT0_S) +#define MCPWM_GEN1_B_UT0_V 0x00000003U +#define MCPWM_GEN1_B_UT0_S 8 +/** MCPWM_GEN1_B_UT1 : R/W; bitpos: [11:10]; default: 0; + * Action on PWM1B triggered by event_t1 when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN1_B_UT1 0x00000003U +#define MCPWM_GEN1_B_UT1_M (MCPWM_GEN1_B_UT1_V << MCPWM_GEN1_B_UT1_S) +#define MCPWM_GEN1_B_UT1_V 0x00000003U +#define MCPWM_GEN1_B_UT1_S 10 +/** MCPWM_GEN1_B_DTEZ : R/W; bitpos: [13:12]; default: 0; + * Action on PWM1B triggered by event TEZ when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN1_B_DTEZ 0x00000003U +#define MCPWM_GEN1_B_DTEZ_M (MCPWM_GEN1_B_DTEZ_V << MCPWM_GEN1_B_DTEZ_S) +#define MCPWM_GEN1_B_DTEZ_V 0x00000003U +#define MCPWM_GEN1_B_DTEZ_S 12 +/** MCPWM_GEN1_B_DTEP : R/W; bitpos: [15:14]; default: 0; + * Action on PWM1B triggered by event TEP when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN1_B_DTEP 0x00000003U +#define MCPWM_GEN1_B_DTEP_M (MCPWM_GEN1_B_DTEP_V << MCPWM_GEN1_B_DTEP_S) +#define MCPWM_GEN1_B_DTEP_V 0x00000003U +#define MCPWM_GEN1_B_DTEP_S 14 +/** MCPWM_GEN1_B_DTEA : R/W; bitpos: [17:16]; default: 0; + * Action on PWM1B triggered by event TEA when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN1_B_DTEA 0x00000003U +#define MCPWM_GEN1_B_DTEA_M (MCPWM_GEN1_B_DTEA_V << MCPWM_GEN1_B_DTEA_S) +#define MCPWM_GEN1_B_DTEA_V 0x00000003U +#define MCPWM_GEN1_B_DTEA_S 16 +/** MCPWM_GEN1_B_DTEB : R/W; bitpos: [19:18]; default: 0; + * Action on PWM1B triggered by event TEB when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN1_B_DTEB 0x00000003U +#define MCPWM_GEN1_B_DTEB_M (MCPWM_GEN1_B_DTEB_V << MCPWM_GEN1_B_DTEB_S) +#define MCPWM_GEN1_B_DTEB_V 0x00000003U +#define MCPWM_GEN1_B_DTEB_S 18 +/** MCPWM_GEN1_B_DT0 : R/W; bitpos: [21:20]; default: 0; + * Action on PWM1B triggered by event_t0 when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN1_B_DT0 0x00000003U +#define MCPWM_GEN1_B_DT0_M (MCPWM_GEN1_B_DT0_V << MCPWM_GEN1_B_DT0_S) +#define MCPWM_GEN1_B_DT0_V 0x00000003U +#define MCPWM_GEN1_B_DT0_S 20 +/** MCPWM_GEN1_B_DT1 : R/W; bitpos: [23:22]; default: 0; + * Action on PWM1B triggered by event_t1 when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN1_B_DT1 0x00000003U +#define MCPWM_GEN1_B_DT1_M (MCPWM_GEN1_B_DT1_V << MCPWM_GEN1_B_DT1_S) +#define MCPWM_GEN1_B_DT1_V 0x00000003U +#define MCPWM_GEN1_B_DT1_S 22 + +/** MCPWM_DT1_CFG_REG register + * PWM generator 1 dead time type selection and configuration + */ +#define MCPWM_DT1_CFG_REG(i) (DR_REG_MCPWM_BASE(i) + 0x90) +/** MCPWM_DT1_FED_UPMETHOD : R/W; bitpos: [3:0]; default: 0; + * Update method for FED (falling edge delay) active register. 0: immediate, when bit0 + * is set to 1: tez, when bit1 is set to 1:tep, when bit2 is set to 1: sync, when + * bit3 is set to 1: disable the update + */ +#define MCPWM_DT1_FED_UPMETHOD 0x0000000FU +#define MCPWM_DT1_FED_UPMETHOD_M (MCPWM_DT1_FED_UPMETHOD_V << MCPWM_DT1_FED_UPMETHOD_S) +#define MCPWM_DT1_FED_UPMETHOD_V 0x0000000FU #define MCPWM_DT1_FED_UPMETHOD_S 0 +/** MCPWM_DT1_RED_UPMETHOD : R/W; bitpos: [7:4]; default: 0; + * Update method for RED (rising edge delay) active register. 0: immediate,when bit0 + * is set to 1: tez, when bit1 is set to 1:tep, when bit2 is set to 1: sync, when + * bit3 is set to 1: disable the update + */ +#define MCPWM_DT1_RED_UPMETHOD 0x0000000FU +#define MCPWM_DT1_RED_UPMETHOD_M (MCPWM_DT1_RED_UPMETHOD_V << MCPWM_DT1_RED_UPMETHOD_S) +#define MCPWM_DT1_RED_UPMETHOD_V 0x0000000FU +#define MCPWM_DT1_RED_UPMETHOD_S 4 +/** MCPWM_DT1_DEB_MODE : R/W; bitpos: [8]; default: 0; + * S8 in table, dual-edge B mode, 0: fed/red take effect on different path separately, + * 1: fed/red take effect on B path, A out is in bypass or dulpB mode + */ +#define MCPWM_DT1_DEB_MODE (BIT(8)) +#define MCPWM_DT1_DEB_MODE_M (MCPWM_DT1_DEB_MODE_V << MCPWM_DT1_DEB_MODE_S) +#define MCPWM_DT1_DEB_MODE_V 0x00000001U +#define MCPWM_DT1_DEB_MODE_S 8 +/** MCPWM_DT1_A_OUTSWAP : R/W; bitpos: [9]; default: 0; + * S6 in table + */ +#define MCPWM_DT1_A_OUTSWAP (BIT(9)) +#define MCPWM_DT1_A_OUTSWAP_M (MCPWM_DT1_A_OUTSWAP_V << MCPWM_DT1_A_OUTSWAP_S) +#define MCPWM_DT1_A_OUTSWAP_V 0x00000001U +#define MCPWM_DT1_A_OUTSWAP_S 9 +/** MCPWM_DT1_B_OUTSWAP : R/W; bitpos: [10]; default: 0; + * S7 in table + */ +#define MCPWM_DT1_B_OUTSWAP (BIT(10)) +#define MCPWM_DT1_B_OUTSWAP_M (MCPWM_DT1_B_OUTSWAP_V << MCPWM_DT1_B_OUTSWAP_S) +#define MCPWM_DT1_B_OUTSWAP_V 0x00000001U +#define MCPWM_DT1_B_OUTSWAP_S 10 +/** MCPWM_DT1_RED_INSEL : R/W; bitpos: [11]; default: 0; + * S4 in table + */ +#define MCPWM_DT1_RED_INSEL (BIT(11)) +#define MCPWM_DT1_RED_INSEL_M (MCPWM_DT1_RED_INSEL_V << MCPWM_DT1_RED_INSEL_S) +#define MCPWM_DT1_RED_INSEL_V 0x00000001U +#define MCPWM_DT1_RED_INSEL_S 11 +/** MCPWM_DT1_FED_INSEL : R/W; bitpos: [12]; default: 0; + * S5 in table + */ +#define MCPWM_DT1_FED_INSEL (BIT(12)) +#define MCPWM_DT1_FED_INSEL_M (MCPWM_DT1_FED_INSEL_V << MCPWM_DT1_FED_INSEL_S) +#define MCPWM_DT1_FED_INSEL_V 0x00000001U +#define MCPWM_DT1_FED_INSEL_S 12 +/** MCPWM_DT1_RED_OUTINVERT : R/W; bitpos: [13]; default: 0; + * S2 in table + */ +#define MCPWM_DT1_RED_OUTINVERT (BIT(13)) +#define MCPWM_DT1_RED_OUTINVERT_M (MCPWM_DT1_RED_OUTINVERT_V << MCPWM_DT1_RED_OUTINVERT_S) +#define MCPWM_DT1_RED_OUTINVERT_V 0x00000001U +#define MCPWM_DT1_RED_OUTINVERT_S 13 +/** MCPWM_DT1_FED_OUTINVERT : R/W; bitpos: [14]; default: 0; + * S3 in table + */ +#define MCPWM_DT1_FED_OUTINVERT (BIT(14)) +#define MCPWM_DT1_FED_OUTINVERT_M (MCPWM_DT1_FED_OUTINVERT_V << MCPWM_DT1_FED_OUTINVERT_S) +#define MCPWM_DT1_FED_OUTINVERT_V 0x00000001U +#define MCPWM_DT1_FED_OUTINVERT_S 14 +/** MCPWM_DT1_A_OUTBYPASS : R/W; bitpos: [15]; default: 1; + * S1 in table + */ +#define MCPWM_DT1_A_OUTBYPASS (BIT(15)) +#define MCPWM_DT1_A_OUTBYPASS_M (MCPWM_DT1_A_OUTBYPASS_V << MCPWM_DT1_A_OUTBYPASS_S) +#define MCPWM_DT1_A_OUTBYPASS_V 0x00000001U +#define MCPWM_DT1_A_OUTBYPASS_S 15 +/** MCPWM_DT1_B_OUTBYPASS : R/W; bitpos: [16]; default: 1; + * S0 in table + */ +#define MCPWM_DT1_B_OUTBYPASS (BIT(16)) +#define MCPWM_DT1_B_OUTBYPASS_M (MCPWM_DT1_B_OUTBYPASS_V << MCPWM_DT1_B_OUTBYPASS_S) +#define MCPWM_DT1_B_OUTBYPASS_V 0x00000001U +#define MCPWM_DT1_B_OUTBYPASS_S 16 +/** MCPWM_DT1_CLK_SEL : R/W; bitpos: [17]; default: 0; + * Dead time clock selection. 0: PWM_clk, 1: PT_clk + */ +#define MCPWM_DT1_CLK_SEL (BIT(17)) +#define MCPWM_DT1_CLK_SEL_M (MCPWM_DT1_CLK_SEL_V << MCPWM_DT1_CLK_SEL_S) +#define MCPWM_DT1_CLK_SEL_V 0x00000001U +#define MCPWM_DT1_CLK_SEL_S 17 -#define MCPWM_DT1_FED_CFG_REG(i) (REG_MCPWM_BASE(i) + 0x0094) -/* MCPWM_DT1_FED : R/W ;bitpos:[15:0] ;default: 16'd0 ; */ -/*description: Shadow reg for FED*/ -#define MCPWM_DT1_FED 0x0000FFFF -#define MCPWM_DT1_FED_M ((MCPWM_DT1_FED_V)<<(MCPWM_DT1_FED_S)) -#define MCPWM_DT1_FED_V 0xFFFF +/** MCPWM_DT1_FED_CFG_REG register + * PWM generator 1 shadow register for falling edge delay (FED). + */ +#define MCPWM_DT1_FED_CFG_REG(i) (DR_REG_MCPWM_BASE(i) + 0x94) +/** MCPWM_DT1_FED : R/W; bitpos: [15:0]; default: 0; + * Shadow register for FED + */ +#define MCPWM_DT1_FED 0x0000FFFFU +#define MCPWM_DT1_FED_M (MCPWM_DT1_FED_V << MCPWM_DT1_FED_S) +#define MCPWM_DT1_FED_V 0x0000FFFFU #define MCPWM_DT1_FED_S 0 -#define MCPWM_DT1_RED_CFG_REG(i) (REG_MCPWM_BASE(i) + 0x0098) -/* MCPWM_DT1_RED : R/W ;bitpos:[15:0] ;default: 16'd0 ; */ -/*description: Shadow reg for RED*/ -#define MCPWM_DT1_RED 0x0000FFFF -#define MCPWM_DT1_RED_M ((MCPWM_DT1_RED_V)<<(MCPWM_DT1_RED_S)) -#define MCPWM_DT1_RED_V 0xFFFF +/** MCPWM_DT1_RED_CFG_REG register + * PWM generator 1 shadow register for rising edge delay (RED). + */ +#define MCPWM_DT1_RED_CFG_REG(i) (DR_REG_MCPWM_BASE(i) + 0x98) +/** MCPWM_DT1_RED : R/W; bitpos: [15:0]; default: 0; + * Shadow register for RED + */ +#define MCPWM_DT1_RED 0x0000FFFFU +#define MCPWM_DT1_RED_M (MCPWM_DT1_RED_V << MCPWM_DT1_RED_S) +#define MCPWM_DT1_RED_V 0x0000FFFFU #define MCPWM_DT1_RED_S 0 -#define MCPWM_CARRIER1_CFG_REG(i) (REG_MCPWM_BASE(i) + 0x009c) -/* MCPWM_CARRIER1_IN_INVERT : R/W ;bitpos:[13] ;default: 1'd0 ; */ -/*description: When set invert the input of PWM1A and PWM1B for this submodule*/ -#define MCPWM_CARRIER1_IN_INVERT (BIT(13)) -#define MCPWM_CARRIER1_IN_INVERT_M (BIT(13)) -#define MCPWM_CARRIER1_IN_INVERT_V 0x1 -#define MCPWM_CARRIER1_IN_INVERT_S 13 -/* MCPWM_CARRIER1_OUT_INVERT : R/W ;bitpos:[12] ;default: 1'd0 ; */ -/*description: When set invert the output of PWM1A and PWM1B for this submodule*/ -#define MCPWM_CARRIER1_OUT_INVERT (BIT(12)) -#define MCPWM_CARRIER1_OUT_INVERT_M (BIT(12)) -#define MCPWM_CARRIER1_OUT_INVERT_V 0x1 -#define MCPWM_CARRIER1_OUT_INVERT_S 12 -/* MCPWM_CARRIER1_OSHWTH : R/W ;bitpos:[11:8] ;default: 4'd0 ; */ -/*description: Width of the fist pulse in number of periods of the carrier*/ -#define MCPWM_CARRIER1_OSHWTH 0x0000000F -#define MCPWM_CARRIER1_OSHWTH_M ((MCPWM_CARRIER1_OSHWTH_V)<<(MCPWM_CARRIER1_OSHWTH_S)) -#define MCPWM_CARRIER1_OSHWTH_V 0xF -#define MCPWM_CARRIER1_OSHWTH_S 8 -/* MCPWM_CARRIER1_DUTY : R/W ;bitpos:[7:5] ;default: 3'd0 ; */ -/*description: Carrier duty selection. Duty = PWM_CARRIER1_DUTY / 8*/ -#define MCPWM_CARRIER1_DUTY 0x00000007 -#define MCPWM_CARRIER1_DUTY_M ((MCPWM_CARRIER1_DUTY_V)<<(MCPWM_CARRIER1_DUTY_S)) -#define MCPWM_CARRIER1_DUTY_V 0x7 -#define MCPWM_CARRIER1_DUTY_S 5 -/* MCPWM_CARRIER1_PRESCALE : R/W ;bitpos:[4:1] ;default: 4'd0 ; */ -/*description: PWM carrier1 clock (PC_clk) prescale value. Period of PC_clk - = period of PWM_clk * (PWM_CARRIER1_PRESCALE + 1)*/ -#define MCPWM_CARRIER1_PRESCALE 0x0000000F -#define MCPWM_CARRIER1_PRESCALE_M ((MCPWM_CARRIER1_PRESCALE_V)<<(MCPWM_CARRIER1_PRESCALE_S)) -#define MCPWM_CARRIER1_PRESCALE_V 0xF -#define MCPWM_CARRIER1_PRESCALE_S 1 -/* MCPWM_CARRIER1_EN : R/W ;bitpos:[0] ;default: 1'd0 ; */ -/*description: When set carrier1 function is enabled. When cleared carrier1 is bypassed*/ -#define MCPWM_CARRIER1_EN (BIT(0)) -#define MCPWM_CARRIER1_EN_M (BIT(0)) -#define MCPWM_CARRIER1_EN_V 0x1 +/** MCPWM_CARRIER1_CFG_REG register + * PWM generator 1 carrier enable and configuratoin + */ +#define MCPWM_CARRIER1_CFG_REG(i) (DR_REG_MCPWM_BASE(i) + 0x9c) +/** MCPWM_CARRIER1_EN : R/W; bitpos: [0]; default: 0; + * When set, carrier1 function is enabled. When cleared, carrier1 is bypassed + */ +#define MCPWM_CARRIER1_EN (BIT(0)) +#define MCPWM_CARRIER1_EN_M (MCPWM_CARRIER1_EN_V << MCPWM_CARRIER1_EN_S) +#define MCPWM_CARRIER1_EN_V 0x00000001U #define MCPWM_CARRIER1_EN_S 0 +/** MCPWM_CARRIER1_PRESCALE : R/W; bitpos: [4:1]; default: 0; + * PWM carrier1 clock (PC_clk) prescale value. Period of PC_clk = period of PWM_clk * + * (PWM_CARRIER0_PRESCALE + 1) + */ +#define MCPWM_CARRIER1_PRESCALE 0x0000000FU +#define MCPWM_CARRIER1_PRESCALE_M (MCPWM_CARRIER1_PRESCALE_V << MCPWM_CARRIER1_PRESCALE_S) +#define MCPWM_CARRIER1_PRESCALE_V 0x0000000FU +#define MCPWM_CARRIER1_PRESCALE_S 1 +/** MCPWM_CARRIER1_DUTY : R/W; bitpos: [7:5]; default: 0; + * carrier duty selection. Duty = PWM_CARRIER0_DUTY / 8 + */ +#define MCPWM_CARRIER1_DUTY 0x00000007U +#define MCPWM_CARRIER1_DUTY_M (MCPWM_CARRIER1_DUTY_V << MCPWM_CARRIER1_DUTY_S) +#define MCPWM_CARRIER1_DUTY_V 0x00000007U +#define MCPWM_CARRIER1_DUTY_S 5 +/** MCPWM_CARRIER1_OSHTWTH : R/W; bitpos: [11:8]; default: 0; + * width of the first pulse in number of periods of the carrier + */ +#define MCPWM_CARRIER1_OSHTWTH 0x0000000FU +#define MCPWM_CARRIER1_OSHTWTH_M (MCPWM_CARRIER1_OSHTWTH_V << MCPWM_CARRIER1_OSHTWTH_S) +#define MCPWM_CARRIER1_OSHTWTH_V 0x0000000FU +#define MCPWM_CARRIER1_OSHTWTH_S 8 +/** MCPWM_CARRIER1_OUT_INVERT : R/W; bitpos: [12]; default: 0; + * when set, invert the output of PWM1A and PWM1B for this submodule + */ +#define MCPWM_CARRIER1_OUT_INVERT (BIT(12)) +#define MCPWM_CARRIER1_OUT_INVERT_M (MCPWM_CARRIER1_OUT_INVERT_V << MCPWM_CARRIER1_OUT_INVERT_S) +#define MCPWM_CARRIER1_OUT_INVERT_V 0x00000001U +#define MCPWM_CARRIER1_OUT_INVERT_S 12 +/** MCPWM_CARRIER1_IN_INVERT : R/W; bitpos: [13]; default: 0; + * when set, invert the input of PWM1A and PWM1B for this submodule + */ +#define MCPWM_CARRIER1_IN_INVERT (BIT(13)) +#define MCPWM_CARRIER1_IN_INVERT_M (MCPWM_CARRIER1_IN_INVERT_V << MCPWM_CARRIER1_IN_INVERT_S) +#define MCPWM_CARRIER1_IN_INVERT_V 0x00000001U +#define MCPWM_CARRIER1_IN_INVERT_S 13 -#define MCPWM_FH1_CFG0_REG(i) (REG_MCPWM_BASE(i) + 0x00a0) -/* MCPWM_FH1_B_OST_U : R/W ;bitpos:[23:22] ;default: 2'd0 ; */ -/*description: One-shot mode action on PWM1B when fault event occurs and timer - is increasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ -#define MCPWM_FH1_B_OST_U 0x00000003 -#define MCPWM_FH1_B_OST_U_M ((MCPWM_FH1_B_OST_U_V)<<(MCPWM_FH1_B_OST_U_S)) -#define MCPWM_FH1_B_OST_U_V 0x3 -#define MCPWM_FH1_B_OST_U_S 22 -/* MCPWM_FH1_B_OST_D : R/W ;bitpos:[21:20] ;default: 2'd0 ; */ -/*description: One-shot mode action on PWM1B when fault event occurs and timer - is decreasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ -#define MCPWM_FH1_B_OST_D 0x00000003 -#define MCPWM_FH1_B_OST_D_M ((MCPWM_FH1_B_OST_D_V)<<(MCPWM_FH1_B_OST_D_S)) -#define MCPWM_FH1_B_OST_D_V 0x3 -#define MCPWM_FH1_B_OST_D_S 20 -/* MCPWM_FH1_B_CBC_U : R/W ;bitpos:[19:18] ;default: 2'd0 ; */ -/*description: Cycle-by-cycle mode action on PWM1B when fault event occurs and - timer is increasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ -#define MCPWM_FH1_B_CBC_U 0x00000003 -#define MCPWM_FH1_B_CBC_U_M ((MCPWM_FH1_B_CBC_U_V)<<(MCPWM_FH1_B_CBC_U_S)) -#define MCPWM_FH1_B_CBC_U_V 0x3 -#define MCPWM_FH1_B_CBC_U_S 18 -/* MCPWM_FH1_B_CBC_D : R/W ;bitpos:[17:16] ;default: 2'd0 ; */ -/*description: Cycle-by-cycle mode action on PWM1B when fault event occurs and - timer is decreasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ -#define MCPWM_FH1_B_CBC_D 0x00000003 -#define MCPWM_FH1_B_CBC_D_M ((MCPWM_FH1_B_CBC_D_V)<<(MCPWM_FH1_B_CBC_D_S)) -#define MCPWM_FH1_B_CBC_D_V 0x3 -#define MCPWM_FH1_B_CBC_D_S 16 -/* MCPWM_FH1_A_OST_U : R/W ;bitpos:[15:14] ;default: 2'd0 ; */ -/*description: One-shot mode action on PWM1A when fault event occurs and timer - is increasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ -#define MCPWM_FH1_A_OST_U 0x00000003 -#define MCPWM_FH1_A_OST_U_M ((MCPWM_FH1_A_OST_U_V)<<(MCPWM_FH1_A_OST_U_S)) -#define MCPWM_FH1_A_OST_U_V 0x3 -#define MCPWM_FH1_A_OST_U_S 14 -/* MCPWM_FH1_A_OST_D : R/W ;bitpos:[13:12] ;default: 2'd0 ; */ -/*description: One-shot mode action on PWM1A when fault event occurs and timer - is decreasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ -#define MCPWM_FH1_A_OST_D 0x00000003 -#define MCPWM_FH1_A_OST_D_M ((MCPWM_FH1_A_OST_D_V)<<(MCPWM_FH1_A_OST_D_S)) -#define MCPWM_FH1_A_OST_D_V 0x3 -#define MCPWM_FH1_A_OST_D_S 12 -/* MCPWM_FH1_A_CBC_U : R/W ;bitpos:[11:10] ;default: 2'd0 ; */ -/*description: Cycle-by-cycle mode action on PWM1A when fault event occurs and - timer is increasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ -#define MCPWM_FH1_A_CBC_U 0x00000003 -#define MCPWM_FH1_A_CBC_U_M ((MCPWM_FH1_A_CBC_U_V)<<(MCPWM_FH1_A_CBC_U_S)) -#define MCPWM_FH1_A_CBC_U_V 0x3 -#define MCPWM_FH1_A_CBC_U_S 10 -/* MCPWM_FH1_A_CBC_D : R/W ;bitpos:[9:8] ;default: 2'd0 ; */ -/*description: Cycle-by-cycle mode action on PWM1A when fault event occurs and - timer is decreasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ -#define MCPWM_FH1_A_CBC_D 0x00000003 -#define MCPWM_FH1_A_CBC_D_M ((MCPWM_FH1_A_CBC_D_V)<<(MCPWM_FH1_A_CBC_D_S)) -#define MCPWM_FH1_A_CBC_D_V 0x3 -#define MCPWM_FH1_A_CBC_D_S 8 -/* MCPWM_FH1_F0_OST : R/W ;bitpos:[7] ;default: 1'd0 ; */ -/*description: event_f0 will trigger one-shot mode action. 0: disable 1: enable*/ -#define MCPWM_FH1_F0_OST (BIT(7)) -#define MCPWM_FH1_F0_OST_M (BIT(7)) -#define MCPWM_FH1_F0_OST_V 0x1 -#define MCPWM_FH1_F0_OST_S 7 -/* MCPWM_FH1_F1_OST : R/W ;bitpos:[6] ;default: 1'd0 ; */ -/*description: event_f1 will trigger one-shot mode action. 0: disable 1: enable*/ -#define MCPWM_FH1_F1_OST (BIT(6)) -#define MCPWM_FH1_F1_OST_M (BIT(6)) -#define MCPWM_FH1_F1_OST_V 0x1 -#define MCPWM_FH1_F1_OST_S 6 -/* MCPWM_FH1_F2_OST : R/W ;bitpos:[5] ;default: 1'd0 ; */ -/*description: event_f2 will trigger one-shot mode action. 0: disable 1: enable*/ -#define MCPWM_FH1_F2_OST (BIT(5)) -#define MCPWM_FH1_F2_OST_M (BIT(5)) -#define MCPWM_FH1_F2_OST_V 0x1 -#define MCPWM_FH1_F2_OST_S 5 -/* MCPWM_FH1_SW_OST : R/W ;bitpos:[4] ;default: 1'd0 ; */ -/*description: Enable register for software force one-shot mode action. 0: disable 1: enable*/ -#define MCPWM_FH1_SW_OST (BIT(4)) -#define MCPWM_FH1_SW_OST_M (BIT(4)) -#define MCPWM_FH1_SW_OST_V 0x1 -#define MCPWM_FH1_SW_OST_S 4 -/* MCPWM_FH1_F0_CBC : R/W ;bitpos:[3] ;default: 1'd0 ; */ -/*description: event_f0 will trigger cycle-by-cycle mode action. 0: disable 1: enable*/ -#define MCPWM_FH1_F0_CBC (BIT(3)) -#define MCPWM_FH1_F0_CBC_M (BIT(3)) -#define MCPWM_FH1_F0_CBC_V 0x1 -#define MCPWM_FH1_F0_CBC_S 3 -/* MCPWM_FH1_F1_CBC : R/W ;bitpos:[2] ;default: 1'd0 ; */ -/*description: event_f1 will trigger cycle-by-cycle mode action. 0: disable 1: enable*/ -#define MCPWM_FH1_F1_CBC (BIT(2)) -#define MCPWM_FH1_F1_CBC_M (BIT(2)) -#define MCPWM_FH1_F1_CBC_V 0x1 -#define MCPWM_FH1_F1_CBC_S 2 -/* MCPWM_FH1_F2_CBC : R/W ;bitpos:[1] ;default: 1'd0 ; */ -/*description: event_f2 will trigger cycle-by-cycle mode action. 0: disable 1: enable*/ -#define MCPWM_FH1_F2_CBC (BIT(1)) -#define MCPWM_FH1_F2_CBC_M (BIT(1)) -#define MCPWM_FH1_F2_CBC_V 0x1 -#define MCPWM_FH1_F2_CBC_S 1 -/* MCPWM_FH1_SW_CBC : R/W ;bitpos:[0] ;default: 1'd0 ; */ -/*description: Enable register for software force cycle-by-cycle mode action. - 0: disable 1: enable*/ -#define MCPWM_FH1_SW_CBC (BIT(0)) -#define MCPWM_FH1_SW_CBC_M (BIT(0)) -#define MCPWM_FH1_SW_CBC_V 0x1 +/** MCPWM_FH1_CFG0_REG register + * Actions on PWM1A and PWM1B trip events + */ +#define MCPWM_FH1_CFG0_REG(i) (DR_REG_MCPWM_BASE(i) + 0xa0) +/** MCPWM_FH1_SW_CBC : R/W; bitpos: [0]; default: 0; + * Enable register for software force cycle-by-cycle mode action. 0: disable, 1: enable + */ +#define MCPWM_FH1_SW_CBC (BIT(0)) +#define MCPWM_FH1_SW_CBC_M (MCPWM_FH1_SW_CBC_V << MCPWM_FH1_SW_CBC_S) +#define MCPWM_FH1_SW_CBC_V 0x00000001U #define MCPWM_FH1_SW_CBC_S 0 +/** MCPWM_FH1_F2_CBC : R/W; bitpos: [1]; default: 0; + * fault_event2 will trigger cycle-by-cycle mode action. 0: disable, 1: enable + */ +#define MCPWM_FH1_F2_CBC (BIT(1)) +#define MCPWM_FH1_F2_CBC_M (MCPWM_FH1_F2_CBC_V << MCPWM_FH1_F2_CBC_S) +#define MCPWM_FH1_F2_CBC_V 0x00000001U +#define MCPWM_FH1_F2_CBC_S 1 +/** MCPWM_FH1_F1_CBC : R/W; bitpos: [2]; default: 0; + * fault_event1 will trigger cycle-by-cycle mode action. 0: disable, 1: enable + */ +#define MCPWM_FH1_F1_CBC (BIT(2)) +#define MCPWM_FH1_F1_CBC_M (MCPWM_FH1_F1_CBC_V << MCPWM_FH1_F1_CBC_S) +#define MCPWM_FH1_F1_CBC_V 0x00000001U +#define MCPWM_FH1_F1_CBC_S 2 +/** MCPWM_FH1_F0_CBC : R/W; bitpos: [3]; default: 0; + * fault_event0 will trigger cycle-by-cycle mode action. 0: disable, 1: enable + */ +#define MCPWM_FH1_F0_CBC (BIT(3)) +#define MCPWM_FH1_F0_CBC_M (MCPWM_FH1_F0_CBC_V << MCPWM_FH1_F0_CBC_S) +#define MCPWM_FH1_F0_CBC_V 0x00000001U +#define MCPWM_FH1_F0_CBC_S 3 +/** MCPWM_FH1_SW_OST : R/W; bitpos: [4]; default: 0; + * Enable register for software force one-shot mode action. 0: disable, 1: enable + */ +#define MCPWM_FH1_SW_OST (BIT(4)) +#define MCPWM_FH1_SW_OST_M (MCPWM_FH1_SW_OST_V << MCPWM_FH1_SW_OST_S) +#define MCPWM_FH1_SW_OST_V 0x00000001U +#define MCPWM_FH1_SW_OST_S 4 +/** MCPWM_FH1_F2_OST : R/W; bitpos: [5]; default: 0; + * fault_event2 will trigger one-shot mode action. 0: disable, 1: enable + */ +#define MCPWM_FH1_F2_OST (BIT(5)) +#define MCPWM_FH1_F2_OST_M (MCPWM_FH1_F2_OST_V << MCPWM_FH1_F2_OST_S) +#define MCPWM_FH1_F2_OST_V 0x00000001U +#define MCPWM_FH1_F2_OST_S 5 +/** MCPWM_FH1_F1_OST : R/W; bitpos: [6]; default: 0; + * fault_event1 will trigger one-shot mode action. 0: disable, 1: enable + */ +#define MCPWM_FH1_F1_OST (BIT(6)) +#define MCPWM_FH1_F1_OST_M (MCPWM_FH1_F1_OST_V << MCPWM_FH1_F1_OST_S) +#define MCPWM_FH1_F1_OST_V 0x00000001U +#define MCPWM_FH1_F1_OST_S 6 +/** MCPWM_FH1_F0_OST : R/W; bitpos: [7]; default: 0; + * fault_event0 will trigger one-shot mode action. 0: disable, 1: enable + */ +#define MCPWM_FH1_F0_OST (BIT(7)) +#define MCPWM_FH1_F0_OST_M (MCPWM_FH1_F0_OST_V << MCPWM_FH1_F0_OST_S) +#define MCPWM_FH1_F0_OST_V 0x00000001U +#define MCPWM_FH1_F0_OST_S 7 +/** MCPWM_FH1_A_CBC_D : R/W; bitpos: [9:8]; default: 0; + * Cycle-by-cycle mode action on PWM1A when fault event occurs and timer is + * decreasing. 0: do nothing, 1: force low, 2: force high, 3: toggle + */ +#define MCPWM_FH1_A_CBC_D 0x00000003U +#define MCPWM_FH1_A_CBC_D_M (MCPWM_FH1_A_CBC_D_V << MCPWM_FH1_A_CBC_D_S) +#define MCPWM_FH1_A_CBC_D_V 0x00000003U +#define MCPWM_FH1_A_CBC_D_S 8 +/** MCPWM_FH1_A_CBC_U : R/W; bitpos: [11:10]; default: 0; + * Cycle-by-cycle mode action on PWM1A when fault event occurs and timer is + * increasing. 0: do nothing, 1: force low, 2: force high, 3: toggle + */ +#define MCPWM_FH1_A_CBC_U 0x00000003U +#define MCPWM_FH1_A_CBC_U_M (MCPWM_FH1_A_CBC_U_V << MCPWM_FH1_A_CBC_U_S) +#define MCPWM_FH1_A_CBC_U_V 0x00000003U +#define MCPWM_FH1_A_CBC_U_S 10 +/** MCPWM_FH1_A_OST_D : R/W; bitpos: [13:12]; default: 0; + * One-shot mode action on PWM1A when fault event occurs and timer is decreasing. 0: + * do nothing,1: force low, 2: force high, 3: toggle + */ +#define MCPWM_FH1_A_OST_D 0x00000003U +#define MCPWM_FH1_A_OST_D_M (MCPWM_FH1_A_OST_D_V << MCPWM_FH1_A_OST_D_S) +#define MCPWM_FH1_A_OST_D_V 0x00000003U +#define MCPWM_FH1_A_OST_D_S 12 +/** MCPWM_FH1_A_OST_U : R/W; bitpos: [15:14]; default: 0; + * One-shot mode action on PWM1A when fault event occurs and timer is increasing. 0: + * do nothing, 1: force low, 2: force high, 3: toggle + */ +#define MCPWM_FH1_A_OST_U 0x00000003U +#define MCPWM_FH1_A_OST_U_M (MCPWM_FH1_A_OST_U_V << MCPWM_FH1_A_OST_U_S) +#define MCPWM_FH1_A_OST_U_V 0x00000003U +#define MCPWM_FH1_A_OST_U_S 14 +/** MCPWM_FH1_B_CBC_D : R/W; bitpos: [17:16]; default: 0; + * Cycle-by-cycle mode action on PWM1B when fault event occurs and timer is + * decreasing. 0: do nothing, 1: force low, 2: force high, 3: toggle + */ +#define MCPWM_FH1_B_CBC_D 0x00000003U +#define MCPWM_FH1_B_CBC_D_M (MCPWM_FH1_B_CBC_D_V << MCPWM_FH1_B_CBC_D_S) +#define MCPWM_FH1_B_CBC_D_V 0x00000003U +#define MCPWM_FH1_B_CBC_D_S 16 +/** MCPWM_FH1_B_CBC_U : R/W; bitpos: [19:18]; default: 0; + * Cycle-by-cycle mode action on PWM1B when fault event occurs and timer is + * increasing. 0: do nothing, 1: force low, 2: force high, 3: toggle + */ +#define MCPWM_FH1_B_CBC_U 0x00000003U +#define MCPWM_FH1_B_CBC_U_M (MCPWM_FH1_B_CBC_U_V << MCPWM_FH1_B_CBC_U_S) +#define MCPWM_FH1_B_CBC_U_V 0x00000003U +#define MCPWM_FH1_B_CBC_U_S 18 +/** MCPWM_FH1_B_OST_D : R/W; bitpos: [21:20]; default: 0; + * One-shot mode action on PWM1B when fault event occurs and timer is decreasing. 0: + * do nothing, 1: force low, 2: force high, 3: toggle + */ +#define MCPWM_FH1_B_OST_D 0x00000003U +#define MCPWM_FH1_B_OST_D_M (MCPWM_FH1_B_OST_D_V << MCPWM_FH1_B_OST_D_S) +#define MCPWM_FH1_B_OST_D_V 0x00000003U +#define MCPWM_FH1_B_OST_D_S 20 +/** MCPWM_FH1_B_OST_U : R/W; bitpos: [23:22]; default: 0; + * One-shot mode action on PWM1B when fault event occurs and timer is increasing. 0: + * do nothing, 1: force low, 2: force high, 3: toggle + */ +#define MCPWM_FH1_B_OST_U 0x00000003U +#define MCPWM_FH1_B_OST_U_M (MCPWM_FH1_B_OST_U_V << MCPWM_FH1_B_OST_U_S) +#define MCPWM_FH1_B_OST_U_V 0x00000003U +#define MCPWM_FH1_B_OST_U_S 22 -#define MCPWM_FH1_CFG1_REG(i) (REG_MCPWM_BASE(i) + 0x00a4) -/* MCPWM_FH1_FORCE_OST : R/W ;bitpos:[4] ;default: 1'd0 ; */ -/*description: A toggle (software negation of value of this bit) triggers a - one-shot mode action*/ -#define MCPWM_FH1_FORCE_OST (BIT(4)) -#define MCPWM_FH1_FORCE_OST_M (BIT(4)) -#define MCPWM_FH1_FORCE_OST_V 0x1 -#define MCPWM_FH1_FORCE_OST_S 4 -/* MCPWM_FH1_FORCE_CBC : R/W ;bitpos:[3] ;default: 1'd0 ; */ -/*description: A toggle triggers a cycle-by-cycle mode action*/ -#define MCPWM_FH1_FORCE_CBC (BIT(3)) -#define MCPWM_FH1_FORCE_CBC_M (BIT(3)) -#define MCPWM_FH1_FORCE_CBC_V 0x1 -#define MCPWM_FH1_FORCE_CBC_S 3 -/* MCPWM_FH1_CBCPULSE : R/W ;bitpos:[2:1] ;default: 2'd0 ; */ -/*description: The cycle-by-cycle mode action refresh moment selection. Bit0: TEZ bit1:TEP*/ -#define MCPWM_FH1_CBCPULSE 0x00000003 -#define MCPWM_FH1_CBCPULSE_M ((MCPWM_FH1_CBCPULSE_V)<<(MCPWM_FH1_CBCPULSE_S)) -#define MCPWM_FH1_CBCPULSE_V 0x3 -#define MCPWM_FH1_CBCPULSE_S 1 -/* MCPWM_FH1_CLR_OST : R/W ;bitpos:[0] ;default: 1'd0 ; */ -/*description: A toggle will clear on going one-shot mode action*/ -#define MCPWM_FH1_CLR_OST (BIT(0)) -#define MCPWM_FH1_CLR_OST_M (BIT(0)) -#define MCPWM_FH1_CLR_OST_V 0x1 +/** MCPWM_FH1_CFG1_REG register + * Software triggers for fault handler actions + */ +#define MCPWM_FH1_CFG1_REG(i) (DR_REG_MCPWM_BASE(i) + 0xa4) +/** MCPWM_FH1_CLR_OST : R/W; bitpos: [0]; default: 0; + * a rising edge will clear on going one-shot mode action + */ +#define MCPWM_FH1_CLR_OST (BIT(0)) +#define MCPWM_FH1_CLR_OST_M (MCPWM_FH1_CLR_OST_V << MCPWM_FH1_CLR_OST_S) +#define MCPWM_FH1_CLR_OST_V 0x00000001U #define MCPWM_FH1_CLR_OST_S 0 +/** MCPWM_FH1_CBCPULSE : R/W; bitpos: [2:1]; default: 0; + * cycle-by-cycle mode action refresh moment selection. When bit0 is set to 1: TEZ, + * when bit1 is set to 1:TEP + */ +#define MCPWM_FH1_CBCPULSE 0x00000003U +#define MCPWM_FH1_CBCPULSE_M (MCPWM_FH1_CBCPULSE_V << MCPWM_FH1_CBCPULSE_S) +#define MCPWM_FH1_CBCPULSE_V 0x00000003U +#define MCPWM_FH1_CBCPULSE_S 1 +/** MCPWM_FH1_FORCE_CBC : R/W; bitpos: [3]; default: 0; + * a toggle trigger a cycle-by-cycle mode action + */ +#define MCPWM_FH1_FORCE_CBC (BIT(3)) +#define MCPWM_FH1_FORCE_CBC_M (MCPWM_FH1_FORCE_CBC_V << MCPWM_FH1_FORCE_CBC_S) +#define MCPWM_FH1_FORCE_CBC_V 0x00000001U +#define MCPWM_FH1_FORCE_CBC_S 3 +/** MCPWM_FH1_FORCE_OST : R/W; bitpos: [4]; default: 0; + * a toggle (software negate its value) triggers a one-shot mode action + */ +#define MCPWM_FH1_FORCE_OST (BIT(4)) +#define MCPWM_FH1_FORCE_OST_M (MCPWM_FH1_FORCE_OST_V << MCPWM_FH1_FORCE_OST_S) +#define MCPWM_FH1_FORCE_OST_V 0x00000001U +#define MCPWM_FH1_FORCE_OST_S 4 -#define MCPWM_FH1_STATUS_REG(i) (REG_MCPWM_BASE(i) + 0x00a8) -/* MCPWM_FH1_OST_ON : RO ;bitpos:[1] ;default: 1'd0 ; */ -/*description: Set and reset by hardware. If set an one-shot mode action is on going*/ -#define MCPWM_FH1_OST_ON (BIT(1)) -#define MCPWM_FH1_OST_ON_M (BIT(1)) -#define MCPWM_FH1_OST_ON_V 0x1 -#define MCPWM_FH1_OST_ON_S 1 -/* MCPWM_FH1_CBC_ON : RO ;bitpos:[0] ;default: 1'd0 ; */ -/*description: Set and reset by hardware. If set an cycle-by-cycle mode action is on going*/ -#define MCPWM_FH1_CBC_ON (BIT(0)) -#define MCPWM_FH1_CBC_ON_M (BIT(0)) -#define MCPWM_FH1_CBC_ON_V 0x1 +/** MCPWM_FH1_STATUS_REG register + * Status of fault events. + */ +#define MCPWM_FH1_STATUS_REG(i) (DR_REG_MCPWM_BASE(i) + 0xa8) +/** MCPWM_FH1_CBC_ON : RO; bitpos: [0]; default: 0; + * Set and reset by hardware. If set, a cycle-by-cycle mode action is on going + */ +#define MCPWM_FH1_CBC_ON (BIT(0)) +#define MCPWM_FH1_CBC_ON_M (MCPWM_FH1_CBC_ON_V << MCPWM_FH1_CBC_ON_S) +#define MCPWM_FH1_CBC_ON_V 0x00000001U #define MCPWM_FH1_CBC_ON_S 0 +/** MCPWM_FH1_OST_ON : RO; bitpos: [1]; default: 0; + * Set and reset by hardware. If set, an one-shot mode action is on going + */ +#define MCPWM_FH1_OST_ON (BIT(1)) +#define MCPWM_FH1_OST_ON_M (MCPWM_FH1_OST_ON_V << MCPWM_FH1_OST_ON_S) +#define MCPWM_FH1_OST_ON_V 0x00000001U +#define MCPWM_FH1_OST_ON_S 1 -#define MCPWM_GEN2_STMP_CFG_REG(i) (REG_MCPWM_BASE(i) + 0x00ac) -/* MCPWM_GEN2_B_SHDW_FULL : RO ;bitpos:[9] ;default: 1'd0 ; */ -/*description: Set and reset by hardware. If set PWM generator 2 time stamp - B's shadow reg is filled and waiting to be transferred to B's active reg. If cleared B's active reg has been updated with shadow reg latest value*/ -#define MCPWM_GEN2_B_SHDW_FULL (BIT(9)) -#define MCPWM_GEN2_B_SHDW_FULL_M (BIT(9)) -#define MCPWM_GEN2_B_SHDW_FULL_V 0x1 -#define MCPWM_GEN2_B_SHDW_FULL_S 9 -/* MCPWM_GEN2_A_SHDW_FULL : RO ;bitpos:[8] ;default: 1'd0 ; */ -/*description: Set and reset by hardware. If set PWM generator 2 time stamp - A's shadow reg is filled and waiting to be transferred to A's active reg. If cleared A's active reg has been updated with shadow reg latest value*/ -#define MCPWM_GEN2_A_SHDW_FULL (BIT(8)) -#define MCPWM_GEN2_A_SHDW_FULL_M (BIT(8)) -#define MCPWM_GEN2_A_SHDW_FULL_V 0x1 -#define MCPWM_GEN2_A_SHDW_FULL_S 8 -/* MCPWM_GEN2_B_UPMETHOD : R/W ;bitpos:[7:4] ;default: 4'd0 ; */ -/*description: Update method for PWM generator 2 time stamp B's active reg. - 0: immediate bit0: TEZ bit1: TEP bit2: sync bit3: disable update*/ -#define MCPWM_GEN2_B_UPMETHOD 0x0000000F -#define MCPWM_GEN2_B_UPMETHOD_M ((MCPWM_GEN2_B_UPMETHOD_V)<<(MCPWM_GEN2_B_UPMETHOD_S)) -#define MCPWM_GEN2_B_UPMETHOD_V 0xF -#define MCPWM_GEN2_B_UPMETHOD_S 4 -/* MCPWM_GEN2_A_UPMETHOD : R/W ;bitpos:[3:0] ;default: 4'd0 ; */ -/*description: Update method for PWM generator 2 time stamp A's active reg. - 0: immediate bit0: TEZ bit1: TEP bit2: sync bit3: disable update*/ -#define MCPWM_GEN2_A_UPMETHOD 0x0000000F -#define MCPWM_GEN2_A_UPMETHOD_M ((MCPWM_GEN2_A_UPMETHOD_V)<<(MCPWM_GEN2_A_UPMETHOD_S)) -#define MCPWM_GEN2_A_UPMETHOD_V 0xF +/** MCPWM_GEN2_STMP_CFG_REG register + * Transfer status and update method for time stamp registers A and B + */ +#define MCPWM_GEN2_STMP_CFG_REG(i) (DR_REG_MCPWM_BASE(i) + 0xac) +/** MCPWM_GEN2_A_UPMETHOD : R/W; bitpos: [3:0]; default: 0; + * Update method for PWM generator 2 time stamp A's active register. When all bits are + * set to 0: immediately, when bit0 is set to 1: TEZ, when bit1 is set to 1: TEP,when + * bit2 is set to 1: sync, when bit3 is set to 1: disable the update. + */ +#define MCPWM_GEN2_A_UPMETHOD 0x0000000FU +#define MCPWM_GEN2_A_UPMETHOD_M (MCPWM_GEN2_A_UPMETHOD_V << MCPWM_GEN2_A_UPMETHOD_S) +#define MCPWM_GEN2_A_UPMETHOD_V 0x0000000FU #define MCPWM_GEN2_A_UPMETHOD_S 0 +/** MCPWM_GEN2_B_UPMETHOD : R/W; bitpos: [7:4]; default: 0; + * Update method for PWM generator 2 time stamp B's active register. When all bits are + * set to 0: immediately, when bit0 is set to 1: TEZ, when bit1 is set to 1: TEP,when + * bit2 is set to 1: sync, when bit3 is set to 1: disable the update. + */ +#define MCPWM_GEN2_B_UPMETHOD 0x0000000FU +#define MCPWM_GEN2_B_UPMETHOD_M (MCPWM_GEN2_B_UPMETHOD_V << MCPWM_GEN2_B_UPMETHOD_S) +#define MCPWM_GEN2_B_UPMETHOD_V 0x0000000FU +#define MCPWM_GEN2_B_UPMETHOD_S 4 +/** MCPWM_GEN2_A_SHDW_FULL : R/W/WTC/SC; bitpos: [8]; default: 0; + * Set and reset by hardware. If set, PWM generator 2 time stamp A's shadow reg is + * filled and waiting to be transferred to A's active reg. If cleared, A's active reg + * has been updated with shadow register latest value + */ +#define MCPWM_GEN2_A_SHDW_FULL (BIT(8)) +#define MCPWM_GEN2_A_SHDW_FULL_M (MCPWM_GEN2_A_SHDW_FULL_V << MCPWM_GEN2_A_SHDW_FULL_S) +#define MCPWM_GEN2_A_SHDW_FULL_V 0x00000001U +#define MCPWM_GEN2_A_SHDW_FULL_S 8 +/** MCPWM_GEN2_B_SHDW_FULL : R/W/WTC/SC; bitpos: [9]; default: 0; + * Set and reset by hardware. If set, PWM generator 2 time stamp B's shadow reg is + * filled and waiting to be transferred to B's active reg. If cleared, B's active reg + * has been updated with shadow register latest value + */ +#define MCPWM_GEN2_B_SHDW_FULL (BIT(9)) +#define MCPWM_GEN2_B_SHDW_FULL_M (MCPWM_GEN2_B_SHDW_FULL_V << MCPWM_GEN2_B_SHDW_FULL_S) +#define MCPWM_GEN2_B_SHDW_FULL_V 0x00000001U +#define MCPWM_GEN2_B_SHDW_FULL_S 9 -#define MCPWM_GEN2_TSTMP_A_REG(i) (REG_MCPWM_BASE(i) + 0x00b0) -/* MCPWM_GEN2_A : R/W ;bitpos:[15:0] ;default: 16'd0 ; */ -/*description: PWM generator 2 time stamp A's shadow reg*/ -#define MCPWM_GEN2_A 0x0000FFFF -#define MCPWM_GEN2_A_M ((MCPWM_GEN2_A_V)<<(MCPWM_GEN2_A_S)) -#define MCPWM_GEN2_A_V 0xFFFF +/** MCPWM_GEN2_TSTMP_A_REG register + * PWM generator 2 shadow register for timer stamp A. + */ +#define MCPWM_GEN2_TSTMP_A_REG(i) (DR_REG_MCPWM_BASE(i) + 0xb0) +/** MCPWM_GEN2_A : R/W; bitpos: [15:0]; default: 0; + * PWM generator 2 time stamp A's shadow register + */ +#define MCPWM_GEN2_A 0x0000FFFFU +#define MCPWM_GEN2_A_M (MCPWM_GEN2_A_V << MCPWM_GEN2_A_S) +#define MCPWM_GEN2_A_V 0x0000FFFFU #define MCPWM_GEN2_A_S 0 -#define MCPWM_GEN2_TSTMP_B_REG(i) (REG_MCPWM_BASE(i) + 0x00b4) -/* MCPWM_GEN2_B : R/W ;bitpos:[15:0] ;default: 16'd0 ; */ -/*description: PWM generator 2 time stamp B's shadow reg*/ -#define MCPWM_GEN2_B 0x0000FFFF -#define MCPWM_GEN2_B_M ((MCPWM_GEN2_B_V)<<(MCPWM_GEN2_B_S)) -#define MCPWM_GEN2_B_V 0xFFFF +/** MCPWM_GEN2_TSTMP_B_REG register + * PWM generator 2 shadow register for timer stamp A. + */ +#define MCPWM_GEN2_TSTMP_B_REG(i) (DR_REG_MCPWM_BASE(i) + 0xb4) +/** MCPWM_GEN2_B : R/W; bitpos: [15:0]; default: 0; + * PWM generator 2 time stamp B's shadow register + */ +#define MCPWM_GEN2_B 0x0000FFFFU +#define MCPWM_GEN2_B_M (MCPWM_GEN2_B_V << MCPWM_GEN2_B_S) +#define MCPWM_GEN2_B_V 0x0000FFFFU #define MCPWM_GEN2_B_S 0 -#define MCPWM_GEN2_CFG0_REG(i) (REG_MCPWM_BASE(i) + 0x00b8) -/* MCPWM_GEN2_T1_SEL : R/W ;bitpos:[9:7] ;default: 3'd0 ; */ -/*description: Source selection for PWM generate2 event_t1 take effect immediately - 0: fault_event0 1: fault_event1 2: fault_event2 3: sync_taken 4: none*/ -#define MCPWM_GEN2_T1_SEL 0x00000007 -#define MCPWM_GEN2_T1_SEL_M ((MCPWM_GEN2_T1_SEL_V)<<(MCPWM_GEN2_T1_SEL_S)) -#define MCPWM_GEN2_T1_SEL_V 0x7 -#define MCPWM_GEN2_T1_SEL_S 7 -/* MCPWM_GEN2_T0_SEL : R/W ;bitpos:[6:4] ;default: 3'd0 ; */ -/*description: Source selection for PWM generate2 event_t0 take effect immediately - 0: fault_event0 1: fault_event1 2: fault_event2 3: sync_taken 4: none*/ -#define MCPWM_GEN2_T0_SEL 0x00000007 -#define MCPWM_GEN2_T0_SEL_M ((MCPWM_GEN2_T0_SEL_V)<<(MCPWM_GEN2_T0_SEL_S)) -#define MCPWM_GEN2_T0_SEL_V 0x7 -#define MCPWM_GEN2_T0_SEL_S 4 -/* MCPWM_GEN2_CFG_UPMETHOD : R/W ;bitpos:[3:0] ;default: 4'd0 ; */ -/*description: Update method for PWM generate2's active reg of configuration. - 0: immediate bit0: TEZ bit1: TEP bit2: sync. bit3: disable update*/ -#define MCPWM_GEN2_CFG_UPMETHOD 0x0000000F -#define MCPWM_GEN2_CFG_UPMETHOD_M ((MCPWM_GEN2_CFG_UPMETHOD_V)<<(MCPWM_GEN2_CFG_UPMETHOD_S)) -#define MCPWM_GEN2_CFG_UPMETHOD_V 0xF +/** MCPWM_GEN2_CFG0_REG register + * PWM generator 2 event T0 and T1 handling + */ +#define MCPWM_GEN2_CFG0_REG(i) (DR_REG_MCPWM_BASE(i) + 0xb8) +/** MCPWM_GEN2_CFG_UPMETHOD : R/W; bitpos: [3:0]; default: 0; + * Update method for PWM generator 2's active register of configuration. 0: + * immediately, when bit0 is set to 1: TEZ, when bit1 is set to 1:sync;when bit3 is + * set to 1:disable the update. + */ +#define MCPWM_GEN2_CFG_UPMETHOD 0x0000000FU +#define MCPWM_GEN2_CFG_UPMETHOD_M (MCPWM_GEN2_CFG_UPMETHOD_V << MCPWM_GEN2_CFG_UPMETHOD_S) +#define MCPWM_GEN2_CFG_UPMETHOD_V 0x0000000FU #define MCPWM_GEN2_CFG_UPMETHOD_S 0 +/** MCPWM_GEN2_T0_SEL : R/W; bitpos: [6:4]; default: 0; + * Source selection for PWM generator 2 event_t0, take effect immediately, 0: + * fault_event0, 1: fault_event1, 2: fault_event2, 3: sync_taken, 4: none + */ +#define MCPWM_GEN2_T0_SEL 0x00000007U +#define MCPWM_GEN2_T0_SEL_M (MCPWM_GEN2_T0_SEL_V << MCPWM_GEN2_T0_SEL_S) +#define MCPWM_GEN2_T0_SEL_V 0x00000007U +#define MCPWM_GEN2_T0_SEL_S 4 +/** MCPWM_GEN2_T1_SEL : R/W; bitpos: [9:7]; default: 0; + * Source selection for PWM generator 2 event_t1, take effect immediately, 0: + * fault_event0, 1: fault_event1, 2: fault_event2, 3: sync_taken, 4: none + */ +#define MCPWM_GEN2_T1_SEL 0x00000007U +#define MCPWM_GEN2_T1_SEL_M (MCPWM_GEN2_T1_SEL_V << MCPWM_GEN2_T1_SEL_S) +#define MCPWM_GEN2_T1_SEL_V 0x00000007U +#define MCPWM_GEN2_T1_SEL_S 7 -#define MCPWM_GEN2_FORCE_REG(i) (REG_MCPWM_BASE(i) + 0x00bc) -/* MCPWM_GEN2_B_NCIFORCE_MODE : R/W ;bitpos:[15:14] ;default: 2'd0 ; */ -/*description: Non-continuous immediate software force mode for PWM2B 0: disabled - 1: low 2: high 3: disabled*/ -#define MCPWM_GEN2_B_NCIFORCE_MODE 0x00000003 -#define MCPWM_GEN2_B_NCIFORCE_MODE_M ((MCPWM_GEN2_B_NCIFORCE_MODE_V)<<(MCPWM_GEN2_B_NCIFORCE_MODE_S)) -#define MCPWM_GEN2_B_NCIFORCE_MODE_V 0x3 -#define MCPWM_GEN2_B_NCIFORCE_MODE_S 14 -/* MCPWM_GEN2_B_NCIFORCE : R/W ;bitpos:[13] ;default: 1'd0 ; */ -/*description: Non-continuous immediate software force trigger for PWM2B a - toggle will trigger a force event*/ -#define MCPWM_GEN2_B_NCIFORCE (BIT(13)) -#define MCPWM_GEN2_B_NCIFORCE_M (BIT(13)) -#define MCPWM_GEN2_B_NCIFORCE_V 0x1 -#define MCPWM_GEN2_B_NCIFORCE_S 13 -/* MCPWM_GEN2_A_NCIFORCE_MODE : R/W ;bitpos:[12:11] ;default: 2'd0 ; */ -/*description: Non-continuous immediate software force mode for PWM2A 0: disabled - 1: low 2: high 3: disabled*/ -#define MCPWM_GEN2_A_NCIFORCE_MODE 0x00000003 -#define MCPWM_GEN2_A_NCIFORCE_MODE_M ((MCPWM_GEN2_A_NCIFORCE_MODE_V)<<(MCPWM_GEN2_A_NCIFORCE_MODE_S)) -#define MCPWM_GEN2_A_NCIFORCE_MODE_V 0x3 -#define MCPWM_GEN2_A_NCIFORCE_MODE_S 11 -/* MCPWM_GEN2_A_NCIFORCE : R/W ;bitpos:[10] ;default: 1'd0 ; */ -/*description: Non-continuous immediate software force trigger for PWM2A a - toggle will trigger a force event*/ -#define MCPWM_GEN2_A_NCIFORCE (BIT(10)) -#define MCPWM_GEN2_A_NCIFORCE_M (BIT(10)) -#define MCPWM_GEN2_A_NCIFORCE_V 0x1 -#define MCPWM_GEN2_A_NCIFORCE_S 10 -/* MCPWM_GEN2_B_CNTUFORCE_MODE : R/W ;bitpos:[9:8] ;default: 2'd0 ; */ -/*description: Continuous software force mode for PWM2B. 0: disabled 1: low - 2: high 3: disabled*/ -#define MCPWM_GEN2_B_CNTUFORCE_MODE 0x00000003 -#define MCPWM_GEN2_B_CNTUFORCE_MODE_M ((MCPWM_GEN2_B_CNTUFORCE_MODE_V)<<(MCPWM_GEN2_B_CNTUFORCE_MODE_S)) -#define MCPWM_GEN2_B_CNTUFORCE_MODE_V 0x3 -#define MCPWM_GEN2_B_CNTUFORCE_MODE_S 8 -/* MCPWM_GEN2_A_CNTUFORCE_MODE : R/W ;bitpos:[7:6] ;default: 2'd0 ; */ -/*description: Continuous software force mode for PWM2A. 0: disabled 1: low - 2: high 3: disabled*/ -#define MCPWM_GEN2_A_CNTUFORCE_MODE 0x00000003 -#define MCPWM_GEN2_A_CNTUFORCE_MODE_M ((MCPWM_GEN2_A_CNTUFORCE_MODE_V)<<(MCPWM_GEN2_A_CNTUFORCE_MODE_S)) -#define MCPWM_GEN2_A_CNTUFORCE_MODE_V 0x3 -#define MCPWM_GEN2_A_CNTUFORCE_MODE_S 6 -/* MCPWM_GEN2_CNTUFORCE_UPMETHOD : R/W ;bitpos:[5:0] ;default: 6'h20 ; */ -/*description: Update method for continuous software force of PWM generator2. - 0: immediate bit0: TEZ bit1: TEP bit2: TEA bit3: TEB bit4: sync bit5: disable update. (TEA/B here and below means an event generated when timer value equals A/B register)*/ -#define MCPWM_GEN2_CNTUFORCE_UPMETHOD 0x0000003F -#define MCPWM_GEN2_CNTUFORCE_UPMETHOD_M ((MCPWM_GEN2_CNTUFORCE_UPMETHOD_V)<<(MCPWM_GEN2_CNTUFORCE_UPMETHOD_S)) -#define MCPWM_GEN2_CNTUFORCE_UPMETHOD_V 0x3F +/** MCPWM_GEN2_FORCE_REG register + * Permissives to force PWM2A and PWM2B outputs by software + */ +#define MCPWM_GEN2_FORCE_REG(i) (DR_REG_MCPWM_BASE(i) + 0xbc) +/** MCPWM_GEN2_CNTUFORCE_UPMETHOD : R/W; bitpos: [5:0]; default: 32; + * Updating method for continuous software force of PWM generator 2. When all bits are + * set to 0: immediately, when bit0 is set to 1: TEZ,when bit1 is set to 1: TEP, when + * bit2 is set to 1: TEA, when bit3 is set to 1: TEB, when bit4 is set to 1: sync, + * when bit5 is set to 1: disable update. (TEA/B here and below means an event + * generated when the timer's value equals to that of register A/B.) + */ +#define MCPWM_GEN2_CNTUFORCE_UPMETHOD 0x0000003FU +#define MCPWM_GEN2_CNTUFORCE_UPMETHOD_M (MCPWM_GEN2_CNTUFORCE_UPMETHOD_V << MCPWM_GEN2_CNTUFORCE_UPMETHOD_S) +#define MCPWM_GEN2_CNTUFORCE_UPMETHOD_V 0x0000003FU #define MCPWM_GEN2_CNTUFORCE_UPMETHOD_S 0 +/** MCPWM_GEN2_A_CNTUFORCE_MODE : R/W; bitpos: [7:6]; default: 0; + * Continuous software force mode for PWM2A. 0: disabled, 1: low, 2: high, 3: disabled + */ +#define MCPWM_GEN2_A_CNTUFORCE_MODE 0x00000003U +#define MCPWM_GEN2_A_CNTUFORCE_MODE_M (MCPWM_GEN2_A_CNTUFORCE_MODE_V << MCPWM_GEN2_A_CNTUFORCE_MODE_S) +#define MCPWM_GEN2_A_CNTUFORCE_MODE_V 0x00000003U +#define MCPWM_GEN2_A_CNTUFORCE_MODE_S 6 +/** MCPWM_GEN2_B_CNTUFORCE_MODE : R/W; bitpos: [9:8]; default: 0; + * Continuous software force mode for PWM2B. 0: disabled, 1: low, 2: high, 3: disabled + */ +#define MCPWM_GEN2_B_CNTUFORCE_MODE 0x00000003U +#define MCPWM_GEN2_B_CNTUFORCE_MODE_M (MCPWM_GEN2_B_CNTUFORCE_MODE_V << MCPWM_GEN2_B_CNTUFORCE_MODE_S) +#define MCPWM_GEN2_B_CNTUFORCE_MODE_V 0x00000003U +#define MCPWM_GEN2_B_CNTUFORCE_MODE_S 8 +/** MCPWM_GEN2_A_NCIFORCE : R/W; bitpos: [10]; default: 0; + * Trigger of non-continuous immediate software-force event for PWM2A, a toggle will + * trigger a force event. + */ +#define MCPWM_GEN2_A_NCIFORCE (BIT(10)) +#define MCPWM_GEN2_A_NCIFORCE_M (MCPWM_GEN2_A_NCIFORCE_V << MCPWM_GEN2_A_NCIFORCE_S) +#define MCPWM_GEN2_A_NCIFORCE_V 0x00000001U +#define MCPWM_GEN2_A_NCIFORCE_S 10 +/** MCPWM_GEN2_A_NCIFORCE_MODE : R/W; bitpos: [12:11]; default: 0; + * non-continuous immediate software force mode for PWM2A, 0: disabled, 1: low, 2: + * high, 3: disabled + */ +#define MCPWM_GEN2_A_NCIFORCE_MODE 0x00000003U +#define MCPWM_GEN2_A_NCIFORCE_MODE_M (MCPWM_GEN2_A_NCIFORCE_MODE_V << MCPWM_GEN2_A_NCIFORCE_MODE_S) +#define MCPWM_GEN2_A_NCIFORCE_MODE_V 0x00000003U +#define MCPWM_GEN2_A_NCIFORCE_MODE_S 11 +/** MCPWM_GEN2_B_NCIFORCE : R/W; bitpos: [13]; default: 0; + * Trigger of non-continuous immediate software-force event for PWM2B, a toggle will + * trigger a force event. + */ +#define MCPWM_GEN2_B_NCIFORCE (BIT(13)) +#define MCPWM_GEN2_B_NCIFORCE_M (MCPWM_GEN2_B_NCIFORCE_V << MCPWM_GEN2_B_NCIFORCE_S) +#define MCPWM_GEN2_B_NCIFORCE_V 0x00000001U +#define MCPWM_GEN2_B_NCIFORCE_S 13 +/** MCPWM_GEN2_B_NCIFORCE_MODE : R/W; bitpos: [15:14]; default: 0; + * non-continuous immediate software force mode for PWM2B, 0: disabled, 1: low, 2: + * high, 3: disabled + */ +#define MCPWM_GEN2_B_NCIFORCE_MODE 0x00000003U +#define MCPWM_GEN2_B_NCIFORCE_MODE_M (MCPWM_GEN2_B_NCIFORCE_MODE_V << MCPWM_GEN2_B_NCIFORCE_MODE_S) +#define MCPWM_GEN2_B_NCIFORCE_MODE_V 0x00000003U +#define MCPWM_GEN2_B_NCIFORCE_MODE_S 14 -#define MCPWM_GEN2_A_REG(i) (REG_MCPWM_BASE(i) + 0x00c0) -/* MCPWM_GEN2_A_DT1 : R/W ;bitpos:[23:22] ;default: 2'd0 ; */ -/*description: Action on PWM2A triggered by event_t1 when timer decreasing. - 0: no change 1: low 2: high 3: toggle*/ -#define MCPWM_GEN2_A_DT1 0x00000003 -#define MCPWM_GEN2_A_DT1_M ((MCPWM_GEN2_A_DT1_V)<<(MCPWM_GEN2_A_DT1_S)) -#define MCPWM_GEN2_A_DT1_V 0x3 -#define MCPWM_GEN2_A_DT1_S 22 -/* MCPWM_GEN2_A_DT0 : R/W ;bitpos:[21:20] ;default: 2'd0 ; */ -/*description: Action on PWM2A triggered by event_t0 when timer decreasing*/ -#define MCPWM_GEN2_A_DT0 0x00000003 -#define MCPWM_GEN2_A_DT0_M ((MCPWM_GEN2_A_DT0_V)<<(MCPWM_GEN2_A_DT0_S)) -#define MCPWM_GEN2_A_DT0_V 0x3 -#define MCPWM_GEN2_A_DT0_S 20 -/* MCPWM_GEN2_A_DTEB : R/W ;bitpos:[19:18] ;default: 2'd0 ; */ -/*description: Action on PWM2A triggered by event TEB when timer decreasing*/ -#define MCPWM_GEN2_A_DTEB 0x00000003 -#define MCPWM_GEN2_A_DTEB_M ((MCPWM_GEN2_A_DTEB_V)<<(MCPWM_GEN2_A_DTEB_S)) -#define MCPWM_GEN2_A_DTEB_V 0x3 -#define MCPWM_GEN2_A_DTEB_S 18 -/* MCPWM_GEN2_A_DTEA : R/W ;bitpos:[17:16] ;default: 2'd0 ; */ -/*description: Action on PWM2A triggered by event TEA when timer decreasing*/ -#define MCPWM_GEN2_A_DTEA 0x00000003 -#define MCPWM_GEN2_A_DTEA_M ((MCPWM_GEN2_A_DTEA_V)<<(MCPWM_GEN2_A_DTEA_S)) -#define MCPWM_GEN2_A_DTEA_V 0x3 -#define MCPWM_GEN2_A_DTEA_S 16 -/* MCPWM_GEN2_A_DTEP : R/W ;bitpos:[15:14] ;default: 2'd0 ; */ -/*description: Action on PWM2A triggered by event TEP when timer decreasing*/ -#define MCPWM_GEN2_A_DTEP 0x00000003 -#define MCPWM_GEN2_A_DTEP_M ((MCPWM_GEN2_A_DTEP_V)<<(MCPWM_GEN2_A_DTEP_S)) -#define MCPWM_GEN2_A_DTEP_V 0x3 -#define MCPWM_GEN2_A_DTEP_S 14 -/* MCPWM_GEN2_A_DTEZ : R/W ;bitpos:[13:12] ;default: 2'd0 ; */ -/*description: Action on PWM2A triggered by event TEZ when timer decreasing*/ -#define MCPWM_GEN2_A_DTEZ 0x00000003 -#define MCPWM_GEN2_A_DTEZ_M ((MCPWM_GEN2_A_DTEZ_V)<<(MCPWM_GEN2_A_DTEZ_S)) -#define MCPWM_GEN2_A_DTEZ_V 0x3 -#define MCPWM_GEN2_A_DTEZ_S 12 -/* MCPWM_GEN2_A_UT1 : R/W ;bitpos:[11:10] ;default: 2'd0 ; */ -/*description: Action on PWM2A triggered by event_t1 when timer increasing*/ -#define MCPWM_GEN2_A_UT1 0x00000003 -#define MCPWM_GEN2_A_UT1_M ((MCPWM_GEN2_A_UT1_V)<<(MCPWM_GEN2_A_UT1_S)) -#define MCPWM_GEN2_A_UT1_V 0x3 -#define MCPWM_GEN2_A_UT1_S 10 -/* MCPWM_GEN2_A_UT0 : R/W ;bitpos:[9:8] ;default: 2'd0 ; */ -/*description: Action on PWM2A triggered by event_t0 when timer increasing*/ -#define MCPWM_GEN2_A_UT0 0x00000003 -#define MCPWM_GEN2_A_UT0_M ((MCPWM_GEN2_A_UT0_V)<<(MCPWM_GEN2_A_UT0_S)) -#define MCPWM_GEN2_A_UT0_V 0x3 -#define MCPWM_GEN2_A_UT0_S 8 -/* MCPWM_GEN2_A_UTEB : R/W ;bitpos:[7:6] ;default: 2'd0 ; */ -/*description: Action on PWM2A triggered by event TEB when timer increasing*/ -#define MCPWM_GEN2_A_UTEB 0x00000003 -#define MCPWM_GEN2_A_UTEB_M ((MCPWM_GEN2_A_UTEB_V)<<(MCPWM_GEN2_A_UTEB_S)) -#define MCPWM_GEN2_A_UTEB_V 0x3 -#define MCPWM_GEN2_A_UTEB_S 6 -/* MCPWM_GEN2_A_UTEA : R/W ;bitpos:[5:4] ;default: 2'd0 ; */ -/*description: Action on PWM2A triggered by event TEA when timer increasing*/ -#define MCPWM_GEN2_A_UTEA 0x00000003 -#define MCPWM_GEN2_A_UTEA_M ((MCPWM_GEN2_A_UTEA_V)<<(MCPWM_GEN2_A_UTEA_S)) -#define MCPWM_GEN2_A_UTEA_V 0x3 -#define MCPWM_GEN2_A_UTEA_S 4 -/* MCPWM_GEN2_A_UTEP : R/W ;bitpos:[3:2] ;default: 2'd0 ; */ -/*description: Action on PWM2A triggered by event TEP when timer increasing*/ -#define MCPWM_GEN2_A_UTEP 0x00000003 -#define MCPWM_GEN2_A_UTEP_M ((MCPWM_GEN2_A_UTEP_V)<<(MCPWM_GEN2_A_UTEP_S)) -#define MCPWM_GEN2_A_UTEP_V 0x3 -#define MCPWM_GEN2_A_UTEP_S 2 -/* MCPWM_GEN2_A_UTEZ : R/W ;bitpos:[1:0] ;default: 2'd0 ; */ -/*description: Action on PWM2A triggered by event TEZ when timer increasing*/ -#define MCPWM_GEN2_A_UTEZ 0x00000003 -#define MCPWM_GEN2_A_UTEZ_M ((MCPWM_GEN2_A_UTEZ_V)<<(MCPWM_GEN2_A_UTEZ_S)) -#define MCPWM_GEN2_A_UTEZ_V 0x3 +/** MCPWM_GEN2_A_REG register + * Actions triggered by events on PWM2A + */ +#define MCPWM_GEN2_A_REG(i) (DR_REG_MCPWM_BASE(i) + 0xc0) +/** MCPWM_GEN2_A_UTEZ : R/W; bitpos: [1:0]; default: 0; + * Action on PWM2A triggered by event TEZ when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN2_A_UTEZ 0x00000003U +#define MCPWM_GEN2_A_UTEZ_M (MCPWM_GEN2_A_UTEZ_V << MCPWM_GEN2_A_UTEZ_S) +#define MCPWM_GEN2_A_UTEZ_V 0x00000003U #define MCPWM_GEN2_A_UTEZ_S 0 +/** MCPWM_GEN2_A_UTEP : R/W; bitpos: [3:2]; default: 0; + * Action on PWM2A triggered by event TEP when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN2_A_UTEP 0x00000003U +#define MCPWM_GEN2_A_UTEP_M (MCPWM_GEN2_A_UTEP_V << MCPWM_GEN2_A_UTEP_S) +#define MCPWM_GEN2_A_UTEP_V 0x00000003U +#define MCPWM_GEN2_A_UTEP_S 2 +/** MCPWM_GEN2_A_UTEA : R/W; bitpos: [5:4]; default: 0; + * Action on PWM2A triggered by event TEA when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN2_A_UTEA 0x00000003U +#define MCPWM_GEN2_A_UTEA_M (MCPWM_GEN2_A_UTEA_V << MCPWM_GEN2_A_UTEA_S) +#define MCPWM_GEN2_A_UTEA_V 0x00000003U +#define MCPWM_GEN2_A_UTEA_S 4 +/** MCPWM_GEN2_A_UTEB : R/W; bitpos: [7:6]; default: 0; + * Action on PWM2A triggered by event TEB when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN2_A_UTEB 0x00000003U +#define MCPWM_GEN2_A_UTEB_M (MCPWM_GEN2_A_UTEB_V << MCPWM_GEN2_A_UTEB_S) +#define MCPWM_GEN2_A_UTEB_V 0x00000003U +#define MCPWM_GEN2_A_UTEB_S 6 +/** MCPWM_GEN2_A_UT0 : R/W; bitpos: [9:8]; default: 0; + * Action on PWM2A triggered by event_t0 when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN2_A_UT0 0x00000003U +#define MCPWM_GEN2_A_UT0_M (MCPWM_GEN2_A_UT0_V << MCPWM_GEN2_A_UT0_S) +#define MCPWM_GEN2_A_UT0_V 0x00000003U +#define MCPWM_GEN2_A_UT0_S 8 +/** MCPWM_GEN2_A_UT1 : R/W; bitpos: [11:10]; default: 0; + * Action on PWM2A triggered by event_t1 when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN2_A_UT1 0x00000003U +#define MCPWM_GEN2_A_UT1_M (MCPWM_GEN2_A_UT1_V << MCPWM_GEN2_A_UT1_S) +#define MCPWM_GEN2_A_UT1_V 0x00000003U +#define MCPWM_GEN2_A_UT1_S 10 +/** MCPWM_GEN2_A_DTEZ : R/W; bitpos: [13:12]; default: 0; + * Action on PWM2A triggered by event TEZ when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN2_A_DTEZ 0x00000003U +#define MCPWM_GEN2_A_DTEZ_M (MCPWM_GEN2_A_DTEZ_V << MCPWM_GEN2_A_DTEZ_S) +#define MCPWM_GEN2_A_DTEZ_V 0x00000003U +#define MCPWM_GEN2_A_DTEZ_S 12 +/** MCPWM_GEN2_A_DTEP : R/W; bitpos: [15:14]; default: 0; + * Action on PWM2A triggered by event TEP when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN2_A_DTEP 0x00000003U +#define MCPWM_GEN2_A_DTEP_M (MCPWM_GEN2_A_DTEP_V << MCPWM_GEN2_A_DTEP_S) +#define MCPWM_GEN2_A_DTEP_V 0x00000003U +#define MCPWM_GEN2_A_DTEP_S 14 +/** MCPWM_GEN2_A_DTEA : R/W; bitpos: [17:16]; default: 0; + * Action on PWM2A triggered by event TEA when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN2_A_DTEA 0x00000003U +#define MCPWM_GEN2_A_DTEA_M (MCPWM_GEN2_A_DTEA_V << MCPWM_GEN2_A_DTEA_S) +#define MCPWM_GEN2_A_DTEA_V 0x00000003U +#define MCPWM_GEN2_A_DTEA_S 16 +/** MCPWM_GEN2_A_DTEB : R/W; bitpos: [19:18]; default: 0; + * Action on PWM2A triggered by event TEB when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN2_A_DTEB 0x00000003U +#define MCPWM_GEN2_A_DTEB_M (MCPWM_GEN2_A_DTEB_V << MCPWM_GEN2_A_DTEB_S) +#define MCPWM_GEN2_A_DTEB_V 0x00000003U +#define MCPWM_GEN2_A_DTEB_S 18 +/** MCPWM_GEN2_A_DT0 : R/W; bitpos: [21:20]; default: 0; + * Action on PWM2A triggered by event_t0 when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN2_A_DT0 0x00000003U +#define MCPWM_GEN2_A_DT0_M (MCPWM_GEN2_A_DT0_V << MCPWM_GEN2_A_DT0_S) +#define MCPWM_GEN2_A_DT0_V 0x00000003U +#define MCPWM_GEN2_A_DT0_S 20 +/** MCPWM_GEN2_A_DT1 : R/W; bitpos: [23:22]; default: 0; + * Action on PWM2A triggered by event_t1 when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN2_A_DT1 0x00000003U +#define MCPWM_GEN2_A_DT1_M (MCPWM_GEN2_A_DT1_V << MCPWM_GEN2_A_DT1_S) +#define MCPWM_GEN2_A_DT1_V 0x00000003U +#define MCPWM_GEN2_A_DT1_S 22 -#define MCPWM_GEN2_B_REG(i) (REG_MCPWM_BASE(i) + 0x00c4) -/* MCPWM_GEN2_B_DT1 : R/W ;bitpos:[23:22] ;default: 2'd0 ; */ -/*description: Action on PWM2B triggered by event_t1 when timer decreasing. - 0: no change 1: low 2: high 3: toggle*/ -#define MCPWM_GEN2_B_DT1 0x00000003 -#define MCPWM_GEN2_B_DT1_M ((MCPWM_GEN2_B_DT1_V)<<(MCPWM_GEN2_B_DT1_S)) -#define MCPWM_GEN2_B_DT1_V 0x3 -#define MCPWM_GEN2_B_DT1_S 22 -/* MCPWM_GEN2_B_DT0 : R/W ;bitpos:[21:20] ;default: 2'd0 ; */ -/*description: Action on PWM2B triggered by event_t0 when timer decreasing*/ -#define MCPWM_GEN2_B_DT0 0x00000003 -#define MCPWM_GEN2_B_DT0_M ((MCPWM_GEN2_B_DT0_V)<<(MCPWM_GEN2_B_DT0_S)) -#define MCPWM_GEN2_B_DT0_V 0x3 -#define MCPWM_GEN2_B_DT0_S 20 -/* MCPWM_GEN2_B_DTEB : R/W ;bitpos:[19:18] ;default: 2'd0 ; */ -/*description: Action on PWM2B triggered by event TEB when timer decreasing*/ -#define MCPWM_GEN2_B_DTEB 0x00000003 -#define MCPWM_GEN2_B_DTEB_M ((MCPWM_GEN2_B_DTEB_V)<<(MCPWM_GEN2_B_DTEB_S)) -#define MCPWM_GEN2_B_DTEB_V 0x3 -#define MCPWM_GEN2_B_DTEB_S 18 -/* MCPWM_GEN2_B_DTEA : R/W ;bitpos:[17:16] ;default: 2'd0 ; */ -/*description: Action on PWM2B triggered by event TEA when timer decreasing*/ -#define MCPWM_GEN2_B_DTEA 0x00000003 -#define MCPWM_GEN2_B_DTEA_M ((MCPWM_GEN2_B_DTEA_V)<<(MCPWM_GEN2_B_DTEA_S)) -#define MCPWM_GEN2_B_DTEA_V 0x3 -#define MCPWM_GEN2_B_DTEA_S 16 -/* MCPWM_GEN2_B_DTEP : R/W ;bitpos:[15:14] ;default: 2'd0 ; */ -/*description: Action on PWM2B triggered by event TEP when timer decreasing*/ -#define MCPWM_GEN2_B_DTEP 0x00000003 -#define MCPWM_GEN2_B_DTEP_M ((MCPWM_GEN2_B_DTEP_V)<<(MCPWM_GEN2_B_DTEP_S)) -#define MCPWM_GEN2_B_DTEP_V 0x3 -#define MCPWM_GEN2_B_DTEP_S 14 -/* MCPWM_GEN2_B_DTEZ : R/W ;bitpos:[13:12] ;default: 2'd0 ; */ -/*description: Action on PWM2B triggered by event TEZ when timer decreasing*/ -#define MCPWM_GEN2_B_DTEZ 0x00000003 -#define MCPWM_GEN2_B_DTEZ_M ((MCPWM_GEN2_B_DTEZ_V)<<(MCPWM_GEN2_B_DTEZ_S)) -#define MCPWM_GEN2_B_DTEZ_V 0x3 -#define MCPWM_GEN2_B_DTEZ_S 12 -/* MCPWM_GEN2_B_UT1 : R/W ;bitpos:[11:10] ;default: 2'd0 ; */ -/*description: Action on PWM2B triggered by event_t1 when timer increasing*/ -#define MCPWM_GEN2_B_UT1 0x00000003 -#define MCPWM_GEN2_B_UT1_M ((MCPWM_GEN2_B_UT1_V)<<(MCPWM_GEN2_B_UT1_S)) -#define MCPWM_GEN2_B_UT1_V 0x3 -#define MCPWM_GEN2_B_UT1_S 10 -/* MCPWM_GEN2_B_UT0 : R/W ;bitpos:[9:8] ;default: 2'd0 ; */ -/*description: Action on PWM2B triggered by event_t0 when timer increasing*/ -#define MCPWM_GEN2_B_UT0 0x00000003 -#define MCPWM_GEN2_B_UT0_M ((MCPWM_GEN2_B_UT0_V)<<(MCPWM_GEN2_B_UT0_S)) -#define MCPWM_GEN2_B_UT0_V 0x3 -#define MCPWM_GEN2_B_UT0_S 8 -/* MCPWM_GEN2_B_UTEB : R/W ;bitpos:[7:6] ;default: 2'd0 ; */ -/*description: Action on PWM2B triggered by event TEB when timer increasing*/ -#define MCPWM_GEN2_B_UTEB 0x00000003 -#define MCPWM_GEN2_B_UTEB_M ((MCPWM_GEN2_B_UTEB_V)<<(MCPWM_GEN2_B_UTEB_S)) -#define MCPWM_GEN2_B_UTEB_V 0x3 -#define MCPWM_GEN2_B_UTEB_S 6 -/* MCPWM_GEN2_B_UTEA : R/W ;bitpos:[5:4] ;default: 2'd0 ; */ -/*description: Action on PWM2B triggered by event TEA when timer increasing*/ -#define MCPWM_GEN2_B_UTEA 0x00000003 -#define MCPWM_GEN2_B_UTEA_M ((MCPWM_GEN2_B_UTEA_V)<<(MCPWM_GEN2_B_UTEA_S)) -#define MCPWM_GEN2_B_UTEA_V 0x3 -#define MCPWM_GEN2_B_UTEA_S 4 -/* MCPWM_GEN2_B_UTEP : R/W ;bitpos:[3:2] ;default: 2'd0 ; */ -/*description: Action on PWM2B triggered by event TEP when timer increasing*/ -#define MCPWM_GEN2_B_UTEP 0x00000003 -#define MCPWM_GEN2_B_UTEP_M ((MCPWM_GEN2_B_UTEP_V)<<(MCPWM_GEN2_B_UTEP_S)) -#define MCPWM_GEN2_B_UTEP_V 0x3 -#define MCPWM_GEN2_B_UTEP_S 2 -/* MCPWM_GEN2_B_UTEZ : R/W ;bitpos:[1:0] ;default: 2'd0 ; */ -/*description: Action on PWM2B triggered by event TEZ when timer increasing*/ -#define MCPWM_GEN2_B_UTEZ 0x00000003 -#define MCPWM_GEN2_B_UTEZ_M ((MCPWM_GEN2_B_UTEZ_V)<<(MCPWM_GEN2_B_UTEZ_S)) -#define MCPWM_GEN2_B_UTEZ_V 0x3 +/** MCPWM_GEN2_B_REG register + * Actions triggered by events on PWM2B + */ +#define MCPWM_GEN2_B_REG(i) (DR_REG_MCPWM_BASE(i) + 0xc4) +/** MCPWM_GEN2_B_UTEZ : R/W; bitpos: [1:0]; default: 0; + * Action on PWM2B triggered by event TEZ when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN2_B_UTEZ 0x00000003U +#define MCPWM_GEN2_B_UTEZ_M (MCPWM_GEN2_B_UTEZ_V << MCPWM_GEN2_B_UTEZ_S) +#define MCPWM_GEN2_B_UTEZ_V 0x00000003U #define MCPWM_GEN2_B_UTEZ_S 0 +/** MCPWM_GEN2_B_UTEP : R/W; bitpos: [3:2]; default: 0; + * Action on PWM2B triggered by event TEP when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN2_B_UTEP 0x00000003U +#define MCPWM_GEN2_B_UTEP_M (MCPWM_GEN2_B_UTEP_V << MCPWM_GEN2_B_UTEP_S) +#define MCPWM_GEN2_B_UTEP_V 0x00000003U +#define MCPWM_GEN2_B_UTEP_S 2 +/** MCPWM_GEN2_B_UTEA : R/W; bitpos: [5:4]; default: 0; + * Action on PWM2B triggered by event TEA when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN2_B_UTEA 0x00000003U +#define MCPWM_GEN2_B_UTEA_M (MCPWM_GEN2_B_UTEA_V << MCPWM_GEN2_B_UTEA_S) +#define MCPWM_GEN2_B_UTEA_V 0x00000003U +#define MCPWM_GEN2_B_UTEA_S 4 +/** MCPWM_GEN2_B_UTEB : R/W; bitpos: [7:6]; default: 0; + * Action on PWM2B triggered by event TEB when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN2_B_UTEB 0x00000003U +#define MCPWM_GEN2_B_UTEB_M (MCPWM_GEN2_B_UTEB_V << MCPWM_GEN2_B_UTEB_S) +#define MCPWM_GEN2_B_UTEB_V 0x00000003U +#define MCPWM_GEN2_B_UTEB_S 6 +/** MCPWM_GEN2_B_UT0 : R/W; bitpos: [9:8]; default: 0; + * Action on PWM2B triggered by event_t0 when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN2_B_UT0 0x00000003U +#define MCPWM_GEN2_B_UT0_M (MCPWM_GEN2_B_UT0_V << MCPWM_GEN2_B_UT0_S) +#define MCPWM_GEN2_B_UT0_V 0x00000003U +#define MCPWM_GEN2_B_UT0_S 8 +/** MCPWM_GEN2_B_UT1 : R/W; bitpos: [11:10]; default: 0; + * Action on PWM2B triggered by event_t1 when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN2_B_UT1 0x00000003U +#define MCPWM_GEN2_B_UT1_M (MCPWM_GEN2_B_UT1_V << MCPWM_GEN2_B_UT1_S) +#define MCPWM_GEN2_B_UT1_V 0x00000003U +#define MCPWM_GEN2_B_UT1_S 10 +/** MCPWM_GEN2_B_DTEZ : R/W; bitpos: [13:12]; default: 0; + * Action on PWM2B triggered by event TEZ when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN2_B_DTEZ 0x00000003U +#define MCPWM_GEN2_B_DTEZ_M (MCPWM_GEN2_B_DTEZ_V << MCPWM_GEN2_B_DTEZ_S) +#define MCPWM_GEN2_B_DTEZ_V 0x00000003U +#define MCPWM_GEN2_B_DTEZ_S 12 +/** MCPWM_GEN2_B_DTEP : R/W; bitpos: [15:14]; default: 0; + * Action on PWM2B triggered by event TEP when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN2_B_DTEP 0x00000003U +#define MCPWM_GEN2_B_DTEP_M (MCPWM_GEN2_B_DTEP_V << MCPWM_GEN2_B_DTEP_S) +#define MCPWM_GEN2_B_DTEP_V 0x00000003U +#define MCPWM_GEN2_B_DTEP_S 14 +/** MCPWM_GEN2_B_DTEA : R/W; bitpos: [17:16]; default: 0; + * Action on PWM2B triggered by event TEA when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN2_B_DTEA 0x00000003U +#define MCPWM_GEN2_B_DTEA_M (MCPWM_GEN2_B_DTEA_V << MCPWM_GEN2_B_DTEA_S) +#define MCPWM_GEN2_B_DTEA_V 0x00000003U +#define MCPWM_GEN2_B_DTEA_S 16 +/** MCPWM_GEN2_B_DTEB : R/W; bitpos: [19:18]; default: 0; + * Action on PWM2B triggered by event TEB when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN2_B_DTEB 0x00000003U +#define MCPWM_GEN2_B_DTEB_M (MCPWM_GEN2_B_DTEB_V << MCPWM_GEN2_B_DTEB_S) +#define MCPWM_GEN2_B_DTEB_V 0x00000003U +#define MCPWM_GEN2_B_DTEB_S 18 +/** MCPWM_GEN2_B_DT0 : R/W; bitpos: [21:20]; default: 0; + * Action on PWM2B triggered by event_t0 when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN2_B_DT0 0x00000003U +#define MCPWM_GEN2_B_DT0_M (MCPWM_GEN2_B_DT0_V << MCPWM_GEN2_B_DT0_S) +#define MCPWM_GEN2_B_DT0_V 0x00000003U +#define MCPWM_GEN2_B_DT0_S 20 +/** MCPWM_GEN2_B_DT1 : R/W; bitpos: [23:22]; default: 0; + * Action on PWM2B triggered by event_t1 when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ +#define MCPWM_GEN2_B_DT1 0x00000003U +#define MCPWM_GEN2_B_DT1_M (MCPWM_GEN2_B_DT1_V << MCPWM_GEN2_B_DT1_S) +#define MCPWM_GEN2_B_DT1_V 0x00000003U +#define MCPWM_GEN2_B_DT1_S 22 -#define MCPWM_DT2_CFG_REG(i) (REG_MCPWM_BASE(i) + 0x00c8) -/* MCPWM_DT2_CLK_SEL : R/W ;bitpos:[17] ;default: 1'd0 ; */ -/*description: Dead time generator 1 clock selection. 0: PWM_clk 1: PT_clk*/ -#define MCPWM_DT2_CLK_SEL (BIT(17)) -#define MCPWM_DT2_CLK_SEL_M (BIT(17)) -#define MCPWM_DT2_CLK_SEL_V 0x1 -#define MCPWM_DT2_CLK_SEL_S 17 -/* MCPWM_DT2_B_OUTBYPASS : R/W ;bitpos:[16] ;default: 1'd1 ; */ -/*description: S0 in documentation*/ -#define MCPWM_DT2_B_OUTBYPASS (BIT(16)) -#define MCPWM_DT2_B_OUTBYPASS_M (BIT(16)) -#define MCPWM_DT2_B_OUTBYPASS_V 0x1 -#define MCPWM_DT2_B_OUTBYPASS_S 16 -/* MCPWM_DT2_A_OUTBYPASS : R/W ;bitpos:[15] ;default: 1'd1 ; */ -/*description: S1 in documentation*/ -#define MCPWM_DT2_A_OUTBYPASS (BIT(15)) -#define MCPWM_DT2_A_OUTBYPASS_M (BIT(15)) -#define MCPWM_DT2_A_OUTBYPASS_V 0x1 -#define MCPWM_DT2_A_OUTBYPASS_S 15 -/* MCPWM_DT2_FED_OUTINVERT : R/W ;bitpos:[14] ;default: 1'd0 ; */ -/*description: S3 in documentation*/ -#define MCPWM_DT2_FED_OUTINVERT (BIT(14)) -#define MCPWM_DT2_FED_OUTINVERT_M (BIT(14)) -#define MCPWM_DT2_FED_OUTINVERT_V 0x1 -#define MCPWM_DT2_FED_OUTINVERT_S 14 -/* MCPWM_DT2_RED_OUTINVERT : R/W ;bitpos:[13] ;default: 1'd0 ; */ -/*description: S2 in documentation*/ -#define MCPWM_DT2_RED_OUTINVERT (BIT(13)) -#define MCPWM_DT2_RED_OUTINVERT_M (BIT(13)) -#define MCPWM_DT2_RED_OUTINVERT_V 0x1 -#define MCPWM_DT2_RED_OUTINVERT_S 13 -/* MCPWM_DT2_FED_INSEL : R/W ;bitpos:[12] ;default: 1'd0 ; */ -/*description: S5 in documentation*/ -#define MCPWM_DT2_FED_INSEL (BIT(12)) -#define MCPWM_DT2_FED_INSEL_M (BIT(12)) -#define MCPWM_DT2_FED_INSEL_V 0x1 -#define MCPWM_DT2_FED_INSEL_S 12 -/* MCPWM_DT2_RED_INSEL : R/W ;bitpos:[11] ;default: 1'd0 ; */ -/*description: S4 in documentation*/ -#define MCPWM_DT2_RED_INSEL (BIT(11)) -#define MCPWM_DT2_RED_INSEL_M (BIT(11)) -#define MCPWM_DT2_RED_INSEL_V 0x1 -#define MCPWM_DT2_RED_INSEL_S 11 -/* MCPWM_DT2_B_OUTSWAP : R/W ;bitpos:[10] ;default: 1'd0 ; */ -/*description: S7 in documentation*/ -#define MCPWM_DT2_B_OUTSWAP (BIT(10)) -#define MCPWM_DT2_B_OUTSWAP_M (BIT(10)) -#define MCPWM_DT2_B_OUTSWAP_V 0x1 -#define MCPWM_DT2_B_OUTSWAP_S 10 -/* MCPWM_DT2_A_OUTSWAP : R/W ;bitpos:[9] ;default: 1'd0 ; */ -/*description: S6 in documentation*/ -#define MCPWM_DT2_A_OUTSWAP (BIT(9)) -#define MCPWM_DT2_A_OUTSWAP_M (BIT(9)) -#define MCPWM_DT2_A_OUTSWAP_V 0x1 -#define MCPWM_DT2_A_OUTSWAP_S 9 -/* MCPWM_DT2_DEB_MODE : R/W ;bitpos:[8] ;default: 1'd0 ; */ -/*description: S8 in documentation dual-edge B mode 0: FED/RED take effect - on different path separately 1: FED/RED take effect on B path A out is in bypass or normal operation mode*/ -#define MCPWM_DT2_DEB_MODE (BIT(8)) -#define MCPWM_DT2_DEB_MODE_M (BIT(8)) -#define MCPWM_DT2_DEB_MODE_V 0x1 -#define MCPWM_DT2_DEB_MODE_S 8 -/* MCPWM_DT2_RED_UPMETHOD : R/W ;bitpos:[7:4] ;default: 4'd0 ; */ -/*description: Update method for RED (rising edge delay) active reg. 0: immediate - bit0: TEZ bit1: TEP bit2: sync bit3: disable update*/ -#define MCPWM_DT2_RED_UPMETHOD 0x0000000F -#define MCPWM_DT2_RED_UPMETHOD_M ((MCPWM_DT2_RED_UPMETHOD_V)<<(MCPWM_DT2_RED_UPMETHOD_S)) -#define MCPWM_DT2_RED_UPMETHOD_V 0xF -#define MCPWM_DT2_RED_UPMETHOD_S 4 -/* MCPWM_DT2_FED_UPMETHOD : R/W ;bitpos:[3:0] ;default: 4'd0 ; */ -/*description: Update method for FED (falling edge delay) active reg. 0: immediate - bit0: TEZ bit1: TEP bit2: sync bit3: disable update*/ -#define MCPWM_DT2_FED_UPMETHOD 0x0000000F -#define MCPWM_DT2_FED_UPMETHOD_M ((MCPWM_DT2_FED_UPMETHOD_V)<<(MCPWM_DT2_FED_UPMETHOD_S)) -#define MCPWM_DT2_FED_UPMETHOD_V 0xF +/** MCPWM_DT2_CFG_REG register + * PWM generator 2 dead time type selection and configuration + */ +#define MCPWM_DT2_CFG_REG(i) (DR_REG_MCPWM_BASE(i) + 0xc8) +/** MCPWM_DT2_FED_UPMETHOD : R/W; bitpos: [3:0]; default: 0; + * Update method for FED (falling edge delay) active register. 0: immediate,when bit0 + * is set to 1: tez, when bit1 is set to 1:tep, when bit2 is set to 1: sync, when + * bit3 is set to 1: disable the update + */ +#define MCPWM_DT2_FED_UPMETHOD 0x0000000FU +#define MCPWM_DT2_FED_UPMETHOD_M (MCPWM_DT2_FED_UPMETHOD_V << MCPWM_DT2_FED_UPMETHOD_S) +#define MCPWM_DT2_FED_UPMETHOD_V 0x0000000FU #define MCPWM_DT2_FED_UPMETHOD_S 0 +/** MCPWM_DT2_RED_UPMETHOD : R/W; bitpos: [7:4]; default: 0; + * Update method for RED (rising edge delay) active register. 0: immediate,when bit0 + * is set to 1: tez, when bit1 is set to 1:tep, when bit2 is set to 1: sync, when + * bit3 is set to 1: disable the update + */ +#define MCPWM_DT2_RED_UPMETHOD 0x0000000FU +#define MCPWM_DT2_RED_UPMETHOD_M (MCPWM_DT2_RED_UPMETHOD_V << MCPWM_DT2_RED_UPMETHOD_S) +#define MCPWM_DT2_RED_UPMETHOD_V 0x0000000FU +#define MCPWM_DT2_RED_UPMETHOD_S 4 +/** MCPWM_DT2_DEB_MODE : R/W; bitpos: [8]; default: 0; + * S8 in table, dual-edge B mode, 0: fed/red take effect on different path separately, + * 1: fed/red take effect on B path, A out is in bypass or dulpB mode + */ +#define MCPWM_DT2_DEB_MODE (BIT(8)) +#define MCPWM_DT2_DEB_MODE_M (MCPWM_DT2_DEB_MODE_V << MCPWM_DT2_DEB_MODE_S) +#define MCPWM_DT2_DEB_MODE_V 0x00000001U +#define MCPWM_DT2_DEB_MODE_S 8 +/** MCPWM_DT2_A_OUTSWAP : R/W; bitpos: [9]; default: 0; + * S6 in table + */ +#define MCPWM_DT2_A_OUTSWAP (BIT(9)) +#define MCPWM_DT2_A_OUTSWAP_M (MCPWM_DT2_A_OUTSWAP_V << MCPWM_DT2_A_OUTSWAP_S) +#define MCPWM_DT2_A_OUTSWAP_V 0x00000001U +#define MCPWM_DT2_A_OUTSWAP_S 9 +/** MCPWM_DT2_B_OUTSWAP : R/W; bitpos: [10]; default: 0; + * S7 in table + */ +#define MCPWM_DT2_B_OUTSWAP (BIT(10)) +#define MCPWM_DT2_B_OUTSWAP_M (MCPWM_DT2_B_OUTSWAP_V << MCPWM_DT2_B_OUTSWAP_S) +#define MCPWM_DT2_B_OUTSWAP_V 0x00000001U +#define MCPWM_DT2_B_OUTSWAP_S 10 +/** MCPWM_DT2_RED_INSEL : R/W; bitpos: [11]; default: 0; + * S4 in table + */ +#define MCPWM_DT2_RED_INSEL (BIT(11)) +#define MCPWM_DT2_RED_INSEL_M (MCPWM_DT2_RED_INSEL_V << MCPWM_DT2_RED_INSEL_S) +#define MCPWM_DT2_RED_INSEL_V 0x00000001U +#define MCPWM_DT2_RED_INSEL_S 11 +/** MCPWM_DT2_FED_INSEL : R/W; bitpos: [12]; default: 0; + * S5 in table + */ +#define MCPWM_DT2_FED_INSEL (BIT(12)) +#define MCPWM_DT2_FED_INSEL_M (MCPWM_DT2_FED_INSEL_V << MCPWM_DT2_FED_INSEL_S) +#define MCPWM_DT2_FED_INSEL_V 0x00000001U +#define MCPWM_DT2_FED_INSEL_S 12 +/** MCPWM_DT2_RED_OUTINVERT : R/W; bitpos: [13]; default: 0; + * S2 in table + */ +#define MCPWM_DT2_RED_OUTINVERT (BIT(13)) +#define MCPWM_DT2_RED_OUTINVERT_M (MCPWM_DT2_RED_OUTINVERT_V << MCPWM_DT2_RED_OUTINVERT_S) +#define MCPWM_DT2_RED_OUTINVERT_V 0x00000001U +#define MCPWM_DT2_RED_OUTINVERT_S 13 +/** MCPWM_DT2_FED_OUTINVERT : R/W; bitpos: [14]; default: 0; + * S3 in table + */ +#define MCPWM_DT2_FED_OUTINVERT (BIT(14)) +#define MCPWM_DT2_FED_OUTINVERT_M (MCPWM_DT2_FED_OUTINVERT_V << MCPWM_DT2_FED_OUTINVERT_S) +#define MCPWM_DT2_FED_OUTINVERT_V 0x00000001U +#define MCPWM_DT2_FED_OUTINVERT_S 14 +/** MCPWM_DT2_A_OUTBYPASS : R/W; bitpos: [15]; default: 1; + * S1 in table + */ +#define MCPWM_DT2_A_OUTBYPASS (BIT(15)) +#define MCPWM_DT2_A_OUTBYPASS_M (MCPWM_DT2_A_OUTBYPASS_V << MCPWM_DT2_A_OUTBYPASS_S) +#define MCPWM_DT2_A_OUTBYPASS_V 0x00000001U +#define MCPWM_DT2_A_OUTBYPASS_S 15 +/** MCPWM_DT2_B_OUTBYPASS : R/W; bitpos: [16]; default: 1; + * S0 in table + */ +#define MCPWM_DT2_B_OUTBYPASS (BIT(16)) +#define MCPWM_DT2_B_OUTBYPASS_M (MCPWM_DT2_B_OUTBYPASS_V << MCPWM_DT2_B_OUTBYPASS_S) +#define MCPWM_DT2_B_OUTBYPASS_V 0x00000001U +#define MCPWM_DT2_B_OUTBYPASS_S 16 +/** MCPWM_DT2_CLK_SEL : R/W; bitpos: [17]; default: 0; + * Dead time clock selection. 0: PWM_clk, 1: PT_clk + */ +#define MCPWM_DT2_CLK_SEL (BIT(17)) +#define MCPWM_DT2_CLK_SEL_M (MCPWM_DT2_CLK_SEL_V << MCPWM_DT2_CLK_SEL_S) +#define MCPWM_DT2_CLK_SEL_V 0x00000001U +#define MCPWM_DT2_CLK_SEL_S 17 -#define MCPWM_DT2_FED_CFG_REG(i) (REG_MCPWM_BASE(i) + 0x00cc) -/* MCPWM_DT2_FED : R/W ;bitpos:[15:0] ;default: 16'd0 ; */ -/*description: Shadow reg for FED*/ -#define MCPWM_DT2_FED 0x0000FFFF -#define MCPWM_DT2_FED_M ((MCPWM_DT2_FED_V)<<(MCPWM_DT2_FED_S)) -#define MCPWM_DT2_FED_V 0xFFFF +/** MCPWM_DT2_FED_CFG_REG register + * PWM generator 2 shadow register for falling edge delay (FED). + */ +#define MCPWM_DT2_FED_CFG_REG(i) (DR_REG_MCPWM_BASE(i) + 0xcc) +/** MCPWM_DT2_FED : R/W; bitpos: [15:0]; default: 0; + * Shadow register for FED + */ +#define MCPWM_DT2_FED 0x0000FFFFU +#define MCPWM_DT2_FED_M (MCPWM_DT2_FED_V << MCPWM_DT2_FED_S) +#define MCPWM_DT2_FED_V 0x0000FFFFU #define MCPWM_DT2_FED_S 0 -#define MCPWM_DT2_RED_CFG_REG(i) (REG_MCPWM_BASE(i) + 0x00d0) -/* MCPWM_DT2_RED : R/W ;bitpos:[15:0] ;default: 16'd0 ; */ -/*description: Shadow reg for RED*/ -#define MCPWM_DT2_RED 0x0000FFFF -#define MCPWM_DT2_RED_M ((MCPWM_DT2_RED_V)<<(MCPWM_DT2_RED_S)) -#define MCPWM_DT2_RED_V 0xFFFF +/** MCPWM_DT2_RED_CFG_REG register + * PWM generator 2 shadow register for rising edge delay (RED). + */ +#define MCPWM_DT2_RED_CFG_REG(i) (DR_REG_MCPWM_BASE(i) + 0xd0) +/** MCPWM_DT2_RED : R/W; bitpos: [15:0]; default: 0; + * Shadow register for RED + */ +#define MCPWM_DT2_RED 0x0000FFFFU +#define MCPWM_DT2_RED_M (MCPWM_DT2_RED_V << MCPWM_DT2_RED_S) +#define MCPWM_DT2_RED_V 0x0000FFFFU #define MCPWM_DT2_RED_S 0 -#define MCPWM_CARRIER2_CFG_REG(i) (REG_MCPWM_BASE(i) + 0x00d4) -/* MCPWM_CARRIER2_IN_INVERT : R/W ;bitpos:[13] ;default: 1'd0 ; */ -/*description: When set invert the input of PWM2A and PWM2B for this submodule*/ -#define MCPWM_CARRIER2_IN_INVERT (BIT(13)) -#define MCPWM_CARRIER2_IN_INVERT_M (BIT(13)) -#define MCPWM_CARRIER2_IN_INVERT_V 0x1 -#define MCPWM_CARRIER2_IN_INVERT_S 13 -/* MCPWM_CARRIER2_OUT_INVERT : R/W ;bitpos:[12] ;default: 1'd0 ; */ -/*description: When set invert the output of PWM2A and PWM2B for this submodule*/ -#define MCPWM_CARRIER2_OUT_INVERT (BIT(12)) -#define MCPWM_CARRIER2_OUT_INVERT_M (BIT(12)) -#define MCPWM_CARRIER2_OUT_INVERT_V 0x1 -#define MCPWM_CARRIER2_OUT_INVERT_S 12 -/* MCPWM_CARRIER2_OSHWTH : R/W ;bitpos:[11:8] ;default: 4'd0 ; */ -/*description: Width of the fist pulse in number of periods of the carrier*/ -#define MCPWM_CARRIER2_OSHWTH 0x0000000F -#define MCPWM_CARRIER2_OSHWTH_M ((MCPWM_CARRIER2_OSHWTH_V)<<(MCPWM_CARRIER2_OSHWTH_S)) -#define MCPWM_CARRIER2_OSHWTH_V 0xF -#define MCPWM_CARRIER2_OSHWTH_S 8 -/* MCPWM_CARRIER2_DUTY : R/W ;bitpos:[7:5] ;default: 3'd0 ; */ -/*description: Carrier duty selection. Duty = PWM_CARRIER2_DUTY / 8*/ -#define MCPWM_CARRIER2_DUTY 0x00000007 -#define MCPWM_CARRIER2_DUTY_M ((MCPWM_CARRIER2_DUTY_V)<<(MCPWM_CARRIER2_DUTY_S)) -#define MCPWM_CARRIER2_DUTY_V 0x7 -#define MCPWM_CARRIER2_DUTY_S 5 -/* MCPWM_CARRIER2_PRESCALE : R/W ;bitpos:[4:1] ;default: 4'd0 ; */ -/*description: PWM carrier2 clock (PC_clk) prescale value. Period of PC_clk - = period of PWM_clk * (PWM_CARRIER2_PRESCALE + 1)*/ -#define MCPWM_CARRIER2_PRESCALE 0x0000000F -#define MCPWM_CARRIER2_PRESCALE_M ((MCPWM_CARRIER2_PRESCALE_V)<<(MCPWM_CARRIER2_PRESCALE_S)) -#define MCPWM_CARRIER2_PRESCALE_V 0xF -#define MCPWM_CARRIER2_PRESCALE_S 1 -/* MCPWM_CARRIER2_EN : R/W ;bitpos:[0] ;default: 1'd0 ; */ -/*description: When set carrier2 function is enabled. When cleared carrier2 is bypassed*/ -#define MCPWM_CARRIER2_EN (BIT(0)) -#define MCPWM_CARRIER2_EN_M (BIT(0)) -#define MCPWM_CARRIER2_EN_V 0x1 +/** MCPWM_CARRIER2_CFG_REG register + * PWM generator 2 carrier enable and configuratoin + */ +#define MCPWM_CARRIER2_CFG_REG(i) (DR_REG_MCPWM_BASE(i) + 0xd4) +/** MCPWM_CARRIER2_EN : R/W; bitpos: [0]; default: 0; + * When set, carrier2 function is enabled. When cleared, carrier2 is bypassed + */ +#define MCPWM_CARRIER2_EN (BIT(0)) +#define MCPWM_CARRIER2_EN_M (MCPWM_CARRIER2_EN_V << MCPWM_CARRIER2_EN_S) +#define MCPWM_CARRIER2_EN_V 0x00000001U #define MCPWM_CARRIER2_EN_S 0 +/** MCPWM_CARRIER2_PRESCALE : R/W; bitpos: [4:1]; default: 0; + * PWM carrier2 clock (PC_clk) prescale value. Period of PC_clk = period of PWM_clk * + * (PWM_CARRIER0_PRESCALE + 1) + */ +#define MCPWM_CARRIER2_PRESCALE 0x0000000FU +#define MCPWM_CARRIER2_PRESCALE_M (MCPWM_CARRIER2_PRESCALE_V << MCPWM_CARRIER2_PRESCALE_S) +#define MCPWM_CARRIER2_PRESCALE_V 0x0000000FU +#define MCPWM_CARRIER2_PRESCALE_S 1 +/** MCPWM_CARRIER2_DUTY : R/W; bitpos: [7:5]; default: 0; + * carrier duty selection. Duty = PWM_CARRIER0_DUTY / 8 + */ +#define MCPWM_CARRIER2_DUTY 0x00000007U +#define MCPWM_CARRIER2_DUTY_M (MCPWM_CARRIER2_DUTY_V << MCPWM_CARRIER2_DUTY_S) +#define MCPWM_CARRIER2_DUTY_V 0x00000007U +#define MCPWM_CARRIER2_DUTY_S 5 +/** MCPWM_CARRIER2_OSHTWTH : R/W; bitpos: [11:8]; default: 0; + * width of the first pulse in number of periods of the carrier + */ +#define MCPWM_CARRIER2_OSHTWTH 0x0000000FU +#define MCPWM_CARRIER2_OSHTWTH_M (MCPWM_CARRIER2_OSHTWTH_V << MCPWM_CARRIER2_OSHTWTH_S) +#define MCPWM_CARRIER2_OSHTWTH_V 0x0000000FU +#define MCPWM_CARRIER2_OSHTWTH_S 8 +/** MCPWM_CARRIER2_OUT_INVERT : R/W; bitpos: [12]; default: 0; + * when set, invert the output of PWM2A and PWM2B for this submodule + */ +#define MCPWM_CARRIER2_OUT_INVERT (BIT(12)) +#define MCPWM_CARRIER2_OUT_INVERT_M (MCPWM_CARRIER2_OUT_INVERT_V << MCPWM_CARRIER2_OUT_INVERT_S) +#define MCPWM_CARRIER2_OUT_INVERT_V 0x00000001U +#define MCPWM_CARRIER2_OUT_INVERT_S 12 +/** MCPWM_CARRIER2_IN_INVERT : R/W; bitpos: [13]; default: 0; + * when set, invert the input of PWM2A and PWM2B for this submodule + */ +#define MCPWM_CARRIER2_IN_INVERT (BIT(13)) +#define MCPWM_CARRIER2_IN_INVERT_M (MCPWM_CARRIER2_IN_INVERT_V << MCPWM_CARRIER2_IN_INVERT_S) +#define MCPWM_CARRIER2_IN_INVERT_V 0x00000001U +#define MCPWM_CARRIER2_IN_INVERT_S 13 -#define MCPWM_FH2_CFG0_REG(i) (REG_MCPWM_BASE(i) + 0x00d8) -/* MCPWM_FH2_B_OST_U : R/W ;bitpos:[23:22] ;default: 2'd0 ; */ -/*description: One-shot mode action on PWM2B when fault event occurs and timer - is increasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ -#define MCPWM_FH2_B_OST_U 0x00000003 -#define MCPWM_FH2_B_OST_U_M ((MCPWM_FH2_B_OST_U_V)<<(MCPWM_FH2_B_OST_U_S)) -#define MCPWM_FH2_B_OST_U_V 0x3 -#define MCPWM_FH2_B_OST_U_S 22 -/* MCPWM_FH2_B_OST_D : R/W ;bitpos:[21:20] ;default: 2'd0 ; */ -/*description: One-shot mode action on PWM2B when fault event occurs and timer - is decreasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ -#define MCPWM_FH2_B_OST_D 0x00000003 -#define MCPWM_FH2_B_OST_D_M ((MCPWM_FH2_B_OST_D_V)<<(MCPWM_FH2_B_OST_D_S)) -#define MCPWM_FH2_B_OST_D_V 0x3 -#define MCPWM_FH2_B_OST_D_S 20 -/* MCPWM_FH2_B_CBC_U : R/W ;bitpos:[19:18] ;default: 2'd0 ; */ -/*description: Cycle-by-cycle mode action on PWM2B when fault event occurs and - timer is increasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ -#define MCPWM_FH2_B_CBC_U 0x00000003 -#define MCPWM_FH2_B_CBC_U_M ((MCPWM_FH2_B_CBC_U_V)<<(MCPWM_FH2_B_CBC_U_S)) -#define MCPWM_FH2_B_CBC_U_V 0x3 -#define MCPWM_FH2_B_CBC_U_S 18 -/* MCPWM_FH2_B_CBC_D : R/W ;bitpos:[17:16] ;default: 2'd0 ; */ -/*description: Cycle-by-cycle mode action on PWM2B when fault event occurs and - timer is decreasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ -#define MCPWM_FH2_B_CBC_D 0x00000003 -#define MCPWM_FH2_B_CBC_D_M ((MCPWM_FH2_B_CBC_D_V)<<(MCPWM_FH2_B_CBC_D_S)) -#define MCPWM_FH2_B_CBC_D_V 0x3 -#define MCPWM_FH2_B_CBC_D_S 16 -/* MCPWM_FH2_A_OST_U : R/W ;bitpos:[15:14] ;default: 2'd0 ; */ -/*description: One-shot mode action on PWM2A when fault event occurs and timer - is increasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ -#define MCPWM_FH2_A_OST_U 0x00000003 -#define MCPWM_FH2_A_OST_U_M ((MCPWM_FH2_A_OST_U_V)<<(MCPWM_FH2_A_OST_U_S)) -#define MCPWM_FH2_A_OST_U_V 0x3 -#define MCPWM_FH2_A_OST_U_S 14 -/* MCPWM_FH2_A_OST_D : R/W ;bitpos:[13:12] ;default: 2'd0 ; */ -/*description: One-shot mode action on PWM2A when fault event occurs and timer - is decreasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ -#define MCPWM_FH2_A_OST_D 0x00000003 -#define MCPWM_FH2_A_OST_D_M ((MCPWM_FH2_A_OST_D_V)<<(MCPWM_FH2_A_OST_D_S)) -#define MCPWM_FH2_A_OST_D_V 0x3 -#define MCPWM_FH2_A_OST_D_S 12 -/* MCPWM_FH2_A_CBC_U : R/W ;bitpos:[11:10] ;default: 2'd0 ; */ -/*description: Cycle-by-cycle mode action on PWM2A when fault event occurs and - timer is increasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ -#define MCPWM_FH2_A_CBC_U 0x00000003 -#define MCPWM_FH2_A_CBC_U_M ((MCPWM_FH2_A_CBC_U_V)<<(MCPWM_FH2_A_CBC_U_S)) -#define MCPWM_FH2_A_CBC_U_V 0x3 -#define MCPWM_FH2_A_CBC_U_S 10 -/* MCPWM_FH2_A_CBC_D : R/W ;bitpos:[9:8] ;default: 2'd0 ; */ -/*description: Cycle-by-cycle mode action on PWM2A when fault event occurs and - timer is decreasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ -#define MCPWM_FH2_A_CBC_D 0x00000003 -#define MCPWM_FH2_A_CBC_D_M ((MCPWM_FH2_A_CBC_D_V)<<(MCPWM_FH2_A_CBC_D_S)) -#define MCPWM_FH2_A_CBC_D_V 0x3 -#define MCPWM_FH2_A_CBC_D_S 8 -/* MCPWM_FH2_F0_OST : R/W ;bitpos:[7] ;default: 1'd0 ; */ -/*description: event_f0 will trigger one-shot mode action. 0: disable 1: enable*/ -#define MCPWM_FH2_F0_OST (BIT(7)) -#define MCPWM_FH2_F0_OST_M (BIT(7)) -#define MCPWM_FH2_F0_OST_V 0x1 -#define MCPWM_FH2_F0_OST_S 7 -/* MCPWM_FH2_F1_OST : R/W ;bitpos:[6] ;default: 1'd0 ; */ -/*description: event_f1 will trigger one-shot mode action. 0: disable 1: enable*/ -#define MCPWM_FH2_F1_OST (BIT(6)) -#define MCPWM_FH2_F1_OST_M (BIT(6)) -#define MCPWM_FH2_F1_OST_V 0x1 -#define MCPWM_FH2_F1_OST_S 6 -/* MCPWM_FH2_F2_OST : R/W ;bitpos:[5] ;default: 1'd0 ; */ -/*description: event_f2 will trigger one-shot mode action. 0: disable 1: enable*/ -#define MCPWM_FH2_F2_OST (BIT(5)) -#define MCPWM_FH2_F2_OST_M (BIT(5)) -#define MCPWM_FH2_F2_OST_V 0x1 -#define MCPWM_FH2_F2_OST_S 5 -/* MCPWM_FH2_SW_OST : R/W ;bitpos:[4] ;default: 1'd0 ; */ -/*description: Enable register for software force one-shot mode action. 0: disable 1: enable*/ -#define MCPWM_FH2_SW_OST (BIT(4)) -#define MCPWM_FH2_SW_OST_M (BIT(4)) -#define MCPWM_FH2_SW_OST_V 0x1 -#define MCPWM_FH2_SW_OST_S 4 -/* MCPWM_FH2_F0_CBC : R/W ;bitpos:[3] ;default: 1'd0 ; */ -/*description: event_f0 will trigger cycle-by-cycle mode action. 0: disable 1: enable*/ -#define MCPWM_FH2_F0_CBC (BIT(3)) -#define MCPWM_FH2_F0_CBC_M (BIT(3)) -#define MCPWM_FH2_F0_CBC_V 0x1 -#define MCPWM_FH2_F0_CBC_S 3 -/* MCPWM_FH2_F1_CBC : R/W ;bitpos:[2] ;default: 1'd0 ; */ -/*description: event_f1 will trigger cycle-by-cycle mode action. 0: disable 1: enable*/ -#define MCPWM_FH2_F1_CBC (BIT(2)) -#define MCPWM_FH2_F1_CBC_M (BIT(2)) -#define MCPWM_FH2_F1_CBC_V 0x1 -#define MCPWM_FH2_F1_CBC_S 2 -/* MCPWM_FH2_F2_CBC : R/W ;bitpos:[1] ;default: 1'd0 ; */ -/*description: event_f2 will trigger cycle-by-cycle mode action. 0: disable 1: enable*/ -#define MCPWM_FH2_F2_CBC (BIT(1)) -#define MCPWM_FH2_F2_CBC_M (BIT(1)) -#define MCPWM_FH2_F2_CBC_V 0x1 -#define MCPWM_FH2_F2_CBC_S 1 -/* MCPWM_FH2_SW_CBC : R/W ;bitpos:[0] ;default: 1'd0 ; */ -/*description: Enable register for software force cycle-by-cycle mode action. - 0: disable 1: enable*/ -#define MCPWM_FH2_SW_CBC (BIT(0)) -#define MCPWM_FH2_SW_CBC_M (BIT(0)) -#define MCPWM_FH2_SW_CBC_V 0x1 +/** MCPWM_FH2_CFG0_REG register + * Actions on PWM2A and PWM2B trip events + */ +#define MCPWM_FH2_CFG0_REG(i) (DR_REG_MCPWM_BASE(i) + 0xd8) +/** MCPWM_FH2_SW_CBC : R/W; bitpos: [0]; default: 0; + * Enable register for software force cycle-by-cycle mode action. 0: disable, 1: enable + */ +#define MCPWM_FH2_SW_CBC (BIT(0)) +#define MCPWM_FH2_SW_CBC_M (MCPWM_FH2_SW_CBC_V << MCPWM_FH2_SW_CBC_S) +#define MCPWM_FH2_SW_CBC_V 0x00000001U #define MCPWM_FH2_SW_CBC_S 0 +/** MCPWM_FH2_F2_CBC : R/W; bitpos: [1]; default: 0; + * fault_event2 will trigger cycle-by-cycle mode action. 0: disable, 1: enable + */ +#define MCPWM_FH2_F2_CBC (BIT(1)) +#define MCPWM_FH2_F2_CBC_M (MCPWM_FH2_F2_CBC_V << MCPWM_FH2_F2_CBC_S) +#define MCPWM_FH2_F2_CBC_V 0x00000001U +#define MCPWM_FH2_F2_CBC_S 1 +/** MCPWM_FH2_F1_CBC : R/W; bitpos: [2]; default: 0; + * fault_event1 will trigger cycle-by-cycle mode action. 0: disable, 1: enable + */ +#define MCPWM_FH2_F1_CBC (BIT(2)) +#define MCPWM_FH2_F1_CBC_M (MCPWM_FH2_F1_CBC_V << MCPWM_FH2_F1_CBC_S) +#define MCPWM_FH2_F1_CBC_V 0x00000001U +#define MCPWM_FH2_F1_CBC_S 2 +/** MCPWM_FH2_F0_CBC : R/W; bitpos: [3]; default: 0; + * fault_event0 will trigger cycle-by-cycle mode action. 0: disable, 1: enable + */ +#define MCPWM_FH2_F0_CBC (BIT(3)) +#define MCPWM_FH2_F0_CBC_M (MCPWM_FH2_F0_CBC_V << MCPWM_FH2_F0_CBC_S) +#define MCPWM_FH2_F0_CBC_V 0x00000001U +#define MCPWM_FH2_F0_CBC_S 3 +/** MCPWM_FH2_SW_OST : R/W; bitpos: [4]; default: 0; + * Enable register for software force one-shot mode action. 0: disable, 1: enable + */ +#define MCPWM_FH2_SW_OST (BIT(4)) +#define MCPWM_FH2_SW_OST_M (MCPWM_FH2_SW_OST_V << MCPWM_FH2_SW_OST_S) +#define MCPWM_FH2_SW_OST_V 0x00000001U +#define MCPWM_FH2_SW_OST_S 4 +/** MCPWM_FH2_F2_OST : R/W; bitpos: [5]; default: 0; + * fault_event2 will trigger one-shot mode action. 0: disable, 1: enable + */ +#define MCPWM_FH2_F2_OST (BIT(5)) +#define MCPWM_FH2_F2_OST_M (MCPWM_FH2_F2_OST_V << MCPWM_FH2_F2_OST_S) +#define MCPWM_FH2_F2_OST_V 0x00000001U +#define MCPWM_FH2_F2_OST_S 5 +/** MCPWM_FH2_F1_OST : R/W; bitpos: [6]; default: 0; + * fault_event1 will trigger one-shot mode action. 0: disable, 1: enable + */ +#define MCPWM_FH2_F1_OST (BIT(6)) +#define MCPWM_FH2_F1_OST_M (MCPWM_FH2_F1_OST_V << MCPWM_FH2_F1_OST_S) +#define MCPWM_FH2_F1_OST_V 0x00000001U +#define MCPWM_FH2_F1_OST_S 6 +/** MCPWM_FH2_F0_OST : R/W; bitpos: [7]; default: 0; + * fault_event0 will trigger one-shot mode action. 0: disable, 1: enable + */ +#define MCPWM_FH2_F0_OST (BIT(7)) +#define MCPWM_FH2_F0_OST_M (MCPWM_FH2_F0_OST_V << MCPWM_FH2_F0_OST_S) +#define MCPWM_FH2_F0_OST_V 0x00000001U +#define MCPWM_FH2_F0_OST_S 7 +/** MCPWM_FH2_A_CBC_D : R/W; bitpos: [9:8]; default: 0; + * Cycle-by-cycle mode action on PWM2A when fault event occurs and timer is + * decreasing. 0: do nothing, 1: force low, 2: force high, 3: toggle + */ +#define MCPWM_FH2_A_CBC_D 0x00000003U +#define MCPWM_FH2_A_CBC_D_M (MCPWM_FH2_A_CBC_D_V << MCPWM_FH2_A_CBC_D_S) +#define MCPWM_FH2_A_CBC_D_V 0x00000003U +#define MCPWM_FH2_A_CBC_D_S 8 +/** MCPWM_FH2_A_CBC_U : R/W; bitpos: [11:10]; default: 0; + * Cycle-by-cycle mode action on PWM2A when fault event occurs and timer is + * increasing. 0: do nothing, 1: force low, 2: force high, 3: toggle + */ +#define MCPWM_FH2_A_CBC_U 0x00000003U +#define MCPWM_FH2_A_CBC_U_M (MCPWM_FH2_A_CBC_U_V << MCPWM_FH2_A_CBC_U_S) +#define MCPWM_FH2_A_CBC_U_V 0x00000003U +#define MCPWM_FH2_A_CBC_U_S 10 +/** MCPWM_FH2_A_OST_D : R/W; bitpos: [13:12]; default: 0; + * One-shot mode action on PWM2A when fault event occurs and timer is decreasing. 0: + * do nothing, 1: force low, 2: force high, 3: toggle + */ +#define MCPWM_FH2_A_OST_D 0x00000003U +#define MCPWM_FH2_A_OST_D_M (MCPWM_FH2_A_OST_D_V << MCPWM_FH2_A_OST_D_S) +#define MCPWM_FH2_A_OST_D_V 0x00000003U +#define MCPWM_FH2_A_OST_D_S 12 +/** MCPWM_FH2_A_OST_U : R/W; bitpos: [15:14]; default: 0; + * One-shot mode action on PWM2A when fault event occurs and timer is increasing. 0: + * do nothing, 1: force low, 2: force high, 3: toggle + */ +#define MCPWM_FH2_A_OST_U 0x00000003U +#define MCPWM_FH2_A_OST_U_M (MCPWM_FH2_A_OST_U_V << MCPWM_FH2_A_OST_U_S) +#define MCPWM_FH2_A_OST_U_V 0x00000003U +#define MCPWM_FH2_A_OST_U_S 14 +/** MCPWM_FH2_B_CBC_D : R/W; bitpos: [17:16]; default: 0; + * Cycle-by-cycle mode action on PWM2B when fault event occurs and timer is + * decreasing. 0: do nothing, 1: force low, 2: force high, 3: toggle + */ +#define MCPWM_FH2_B_CBC_D 0x00000003U +#define MCPWM_FH2_B_CBC_D_M (MCPWM_FH2_B_CBC_D_V << MCPWM_FH2_B_CBC_D_S) +#define MCPWM_FH2_B_CBC_D_V 0x00000003U +#define MCPWM_FH2_B_CBC_D_S 16 +/** MCPWM_FH2_B_CBC_U : R/W; bitpos: [19:18]; default: 0; + * Cycle-by-cycle mode action on PWM2B when fault event occurs and timer is + * increasing. 0: do nothing, 1: force low, 2: force high, 3: toggle + */ +#define MCPWM_FH2_B_CBC_U 0x00000003U +#define MCPWM_FH2_B_CBC_U_M (MCPWM_FH2_B_CBC_U_V << MCPWM_FH2_B_CBC_U_S) +#define MCPWM_FH2_B_CBC_U_V 0x00000003U +#define MCPWM_FH2_B_CBC_U_S 18 +/** MCPWM_FH2_B_OST_D : R/W; bitpos: [21:20]; default: 0; + * One-shot mode action on PWM2B when fault event occurs and timer is decreasing. 0: + * do nothing, 1: force low, 2: force high, 3: toggle + */ +#define MCPWM_FH2_B_OST_D 0x00000003U +#define MCPWM_FH2_B_OST_D_M (MCPWM_FH2_B_OST_D_V << MCPWM_FH2_B_OST_D_S) +#define MCPWM_FH2_B_OST_D_V 0x00000003U +#define MCPWM_FH2_B_OST_D_S 20 +/** MCPWM_FH2_B_OST_U : R/W; bitpos: [23:22]; default: 0; + * One-shot mode action on PWM2B when fault event occurs and timer is increasing. 0: + * do nothing, 1: force low, 2: force high, 3: toggle + */ +#define MCPWM_FH2_B_OST_U 0x00000003U +#define MCPWM_FH2_B_OST_U_M (MCPWM_FH2_B_OST_U_V << MCPWM_FH2_B_OST_U_S) +#define MCPWM_FH2_B_OST_U_V 0x00000003U +#define MCPWM_FH2_B_OST_U_S 22 -#define MCPWM_FH2_CFG1_REG(i) (REG_MCPWM_BASE(i) + 0x00dc) -/* MCPWM_FH2_FORCE_OST : R/W ;bitpos:[4] ;default: 1'd0 ; */ -/*description: A toggle (software negation of value of this bit) triggers a - one-shot mode action*/ -#define MCPWM_FH2_FORCE_OST (BIT(4)) -#define MCPWM_FH2_FORCE_OST_M (BIT(4)) -#define MCPWM_FH2_FORCE_OST_V 0x1 -#define MCPWM_FH2_FORCE_OST_S 4 -/* MCPWM_FH2_FORCE_CBC : R/W ;bitpos:[3] ;default: 1'd0 ; */ -/*description: A toggle triggers a cycle-by-cycle mode action*/ -#define MCPWM_FH2_FORCE_CBC (BIT(3)) -#define MCPWM_FH2_FORCE_CBC_M (BIT(3)) -#define MCPWM_FH2_FORCE_CBC_V 0x1 -#define MCPWM_FH2_FORCE_CBC_S 3 -/* MCPWM_FH2_CBCPULSE : R/W ;bitpos:[2:1] ;default: 2'd0 ; */ -/*description: The cycle-by-cycle mode action refresh moment selection. Bit0: TEZ bit1:TEP*/ -#define MCPWM_FH2_CBCPULSE 0x00000003 -#define MCPWM_FH2_CBCPULSE_M ((MCPWM_FH2_CBCPULSE_V)<<(MCPWM_FH2_CBCPULSE_S)) -#define MCPWM_FH2_CBCPULSE_V 0x3 -#define MCPWM_FH2_CBCPULSE_S 1 -/* MCPWM_FH2_CLR_OST : R/W ;bitpos:[0] ;default: 1'd0 ; */ -/*description: A toggle will clear on going one-shot mode action*/ -#define MCPWM_FH2_CLR_OST (BIT(0)) -#define MCPWM_FH2_CLR_OST_M (BIT(0)) -#define MCPWM_FH2_CLR_OST_V 0x1 +/** MCPWM_FH2_CFG1_REG register + * Software triggers for fault handler actions + */ +#define MCPWM_FH2_CFG1_REG(i) (DR_REG_MCPWM_BASE(i) + 0xdc) +/** MCPWM_FH2_CLR_OST : R/W; bitpos: [0]; default: 0; + * a rising edge will clear on going one-shot mode action + */ +#define MCPWM_FH2_CLR_OST (BIT(0)) +#define MCPWM_FH2_CLR_OST_M (MCPWM_FH2_CLR_OST_V << MCPWM_FH2_CLR_OST_S) +#define MCPWM_FH2_CLR_OST_V 0x00000001U #define MCPWM_FH2_CLR_OST_S 0 +/** MCPWM_FH2_CBCPULSE : R/W; bitpos: [2:1]; default: 0; + * cycle-by-cycle mode action refresh moment selection. When bit0 is set to 1: TEZ, + * when bit1 is set to 1:TEP + */ +#define MCPWM_FH2_CBCPULSE 0x00000003U +#define MCPWM_FH2_CBCPULSE_M (MCPWM_FH2_CBCPULSE_V << MCPWM_FH2_CBCPULSE_S) +#define MCPWM_FH2_CBCPULSE_V 0x00000003U +#define MCPWM_FH2_CBCPULSE_S 1 +/** MCPWM_FH2_FORCE_CBC : R/W; bitpos: [3]; default: 0; + * a toggle trigger a cycle-by-cycle mode action + */ +#define MCPWM_FH2_FORCE_CBC (BIT(3)) +#define MCPWM_FH2_FORCE_CBC_M (MCPWM_FH2_FORCE_CBC_V << MCPWM_FH2_FORCE_CBC_S) +#define MCPWM_FH2_FORCE_CBC_V 0x00000001U +#define MCPWM_FH2_FORCE_CBC_S 3 +/** MCPWM_FH2_FORCE_OST : R/W; bitpos: [4]; default: 0; + * a toggle (software negate its value) triggers a one-shot mode action + */ +#define MCPWM_FH2_FORCE_OST (BIT(4)) +#define MCPWM_FH2_FORCE_OST_M (MCPWM_FH2_FORCE_OST_V << MCPWM_FH2_FORCE_OST_S) +#define MCPWM_FH2_FORCE_OST_V 0x00000001U +#define MCPWM_FH2_FORCE_OST_S 4 -#define MCPWM_FH2_STATUS_REG(i) (REG_MCPWM_BASE(i) + 0x00e0) -/* MCPWM_FH2_OST_ON : RO ;bitpos:[1] ;default: 1'd0 ; */ -/*description: Set and reset by hardware. If set an one-shot mode action is on going*/ -#define MCPWM_FH2_OST_ON (BIT(1)) -#define MCPWM_FH2_OST_ON_M (BIT(1)) -#define MCPWM_FH2_OST_ON_V 0x1 -#define MCPWM_FH2_OST_ON_S 1 -/* MCPWM_FH2_CBC_ON : RO ;bitpos:[0] ;default: 1'd0 ; */ -/*description: Set and reset by hardware. If set an cycle-by-cycle mode action is on going*/ -#define MCPWM_FH2_CBC_ON (BIT(0)) -#define MCPWM_FH2_CBC_ON_M (BIT(0)) -#define MCPWM_FH2_CBC_ON_V 0x1 +/** MCPWM_FH2_STATUS_REG register + * Status of fault events. + */ +#define MCPWM_FH2_STATUS_REG(i) (DR_REG_MCPWM_BASE(i) + 0xe0) +/** MCPWM_FH2_CBC_ON : RO; bitpos: [0]; default: 0; + * Set and reset by hardware. If set, a cycle-by-cycle mode action is on going + */ +#define MCPWM_FH2_CBC_ON (BIT(0)) +#define MCPWM_FH2_CBC_ON_M (MCPWM_FH2_CBC_ON_V << MCPWM_FH2_CBC_ON_S) +#define MCPWM_FH2_CBC_ON_V 0x00000001U #define MCPWM_FH2_CBC_ON_S 0 +/** MCPWM_FH2_OST_ON : RO; bitpos: [1]; default: 0; + * Set and reset by hardware. If set, an one-shot mode action is on going + */ +#define MCPWM_FH2_OST_ON (BIT(1)) +#define MCPWM_FH2_OST_ON_M (MCPWM_FH2_OST_ON_V << MCPWM_FH2_OST_ON_S) +#define MCPWM_FH2_OST_ON_V 0x00000001U +#define MCPWM_FH2_OST_ON_S 1 -#define MCPWM_FAULT_DETECT_REG(i) (REG_MCPWM_BASE(i) + 0x00e4) -/* MCPWM_EVENT_F2 : RO ;bitpos:[8] ;default: 1'd0 ; */ -/*description: Set and reset by hardware. If set event_f2 is on going*/ -#define MCPWM_EVENT_F2 (BIT(8)) -#define MCPWM_EVENT_F2_M (BIT(8)) -#define MCPWM_EVENT_F2_V 0x1 -#define MCPWM_EVENT_F2_S 8 -/* MCPWM_EVENT_F1 : RO ;bitpos:[7] ;default: 1'd0 ; */ -/*description: Set and reset by hardware. If set event_f1 is on going*/ -#define MCPWM_EVENT_F1 (BIT(7)) -#define MCPWM_EVENT_F1_M (BIT(7)) -#define MCPWM_EVENT_F1_V 0x1 -#define MCPWM_EVENT_F1_S 7 -/* MCPWM_EVENT_F0 : RO ;bitpos:[6] ;default: 1'd0 ; */ -/*description: Set and reset by hardware. If set event_f0 is on going*/ -#define MCPWM_EVENT_F0 (BIT(6)) -#define MCPWM_EVENT_F0_M (BIT(6)) -#define MCPWM_EVENT_F0_V 0x1 -#define MCPWM_EVENT_F0_S 6 -/* MCPWM_F2_POLE : R/W ;bitpos:[5] ;default: 1'd0 ; */ -/*description: Set event_f2 trigger polarity on FAULT2 source from GPIO matrix. - 0: level low 1: level high*/ -#define MCPWM_F2_POLE (BIT(5)) -#define MCPWM_F2_POLE_M (BIT(5)) -#define MCPWM_F2_POLE_V 0x1 -#define MCPWM_F2_POLE_S 5 -/* MCPWM_F1_POLE : R/W ;bitpos:[4] ;default: 1'd0 ; */ -/*description: Set event_f1 trigger polarity on FAULT2 source from GPIO matrix. - 0: level low 1: level high*/ -#define MCPWM_F1_POLE (BIT(4)) -#define MCPWM_F1_POLE_M (BIT(4)) -#define MCPWM_F1_POLE_V 0x1 -#define MCPWM_F1_POLE_S 4 -/* MCPWM_F0_POLE : R/W ;bitpos:[3] ;default: 1'd0 ; */ -/*description: Set event_f0 trigger polarity on FAULT2 source from GPIO matrix. - 0: level low 1: level high*/ -#define MCPWM_F0_POLE (BIT(3)) -#define MCPWM_F0_POLE_M (BIT(3)) -#define MCPWM_F0_POLE_V 0x1 -#define MCPWM_F0_POLE_S 3 -/* MCPWM_F2_EN : R/W ;bitpos:[2] ;default: 1'd0 ; */ -/*description: Set to enable generation of event_f2*/ -#define MCPWM_F2_EN (BIT(2)) -#define MCPWM_F2_EN_M (BIT(2)) -#define MCPWM_F2_EN_V 0x1 -#define MCPWM_F2_EN_S 2 -/* MCPWM_F1_EN : R/W ;bitpos:[1] ;default: 1'd0 ; */ -/*description: Set to enable generation of event_f1*/ -#define MCPWM_F1_EN (BIT(1)) -#define MCPWM_F1_EN_M (BIT(1)) -#define MCPWM_F1_EN_V 0x1 -#define MCPWM_F1_EN_S 1 -/* MCPWM_F0_EN : R/W ;bitpos:[0] ;default: 1'd0 ; */ -/*description: Set to enable generation of event_f0*/ -#define MCPWM_F0_EN (BIT(0)) -#define MCPWM_F0_EN_M (BIT(0)) -#define MCPWM_F0_EN_V 0x1 +/** MCPWM_FAULT_DETECT_REG register + * Fault detection configuration and status + */ +#define MCPWM_FAULT_DETECT_REG(i) (DR_REG_MCPWM_BASE(i) + 0xe4) +/** MCPWM_F0_EN : R/W; bitpos: [0]; default: 0; + * When set, fault_event0 generation is enabled + */ +#define MCPWM_F0_EN (BIT(0)) +#define MCPWM_F0_EN_M (MCPWM_F0_EN_V << MCPWM_F0_EN_S) +#define MCPWM_F0_EN_V 0x00000001U #define MCPWM_F0_EN_S 0 +/** MCPWM_F1_EN : R/W; bitpos: [1]; default: 0; + * When set, fault_event1 generation is enabled + */ +#define MCPWM_F1_EN (BIT(1)) +#define MCPWM_F1_EN_M (MCPWM_F1_EN_V << MCPWM_F1_EN_S) +#define MCPWM_F1_EN_V 0x00000001U +#define MCPWM_F1_EN_S 1 +/** MCPWM_F2_EN : R/W; bitpos: [2]; default: 0; + * When set, fault_event2 generation is enabled + */ +#define MCPWM_F2_EN (BIT(2)) +#define MCPWM_F2_EN_M (MCPWM_F2_EN_V << MCPWM_F2_EN_S) +#define MCPWM_F2_EN_V 0x00000001U +#define MCPWM_F2_EN_S 2 +/** MCPWM_F0_POLE : R/W; bitpos: [3]; default: 0; + * Set fault_event0 trigger polarity on FAULT2 source from GPIO matrix. 0: level low, + * 1: level high + */ +#define MCPWM_F0_POLE (BIT(3)) +#define MCPWM_F0_POLE_M (MCPWM_F0_POLE_V << MCPWM_F0_POLE_S) +#define MCPWM_F0_POLE_V 0x00000001U +#define MCPWM_F0_POLE_S 3 +/** MCPWM_F1_POLE : R/W; bitpos: [4]; default: 0; + * Set fault_event1 trigger polarity on FAULT2 source from GPIO matrix. 0: level low, + * 1: level high + */ +#define MCPWM_F1_POLE (BIT(4)) +#define MCPWM_F1_POLE_M (MCPWM_F1_POLE_V << MCPWM_F1_POLE_S) +#define MCPWM_F1_POLE_V 0x00000001U +#define MCPWM_F1_POLE_S 4 +/** MCPWM_F2_POLE : R/W; bitpos: [5]; default: 0; + * Set fault_event2 trigger polarity on FAULT2 source from GPIO matrix. 0: level low, + * 1: level high + */ +#define MCPWM_F2_POLE (BIT(5)) +#define MCPWM_F2_POLE_M (MCPWM_F2_POLE_V << MCPWM_F2_POLE_S) +#define MCPWM_F2_POLE_V 0x00000001U +#define MCPWM_F2_POLE_S 5 +/** MCPWM_EVENT_F0 : RO; bitpos: [6]; default: 0; + * Set and reset by hardware. If set, fault_event0 is on going + */ +#define MCPWM_EVENT_F0 (BIT(6)) +#define MCPWM_EVENT_F0_M (MCPWM_EVENT_F0_V << MCPWM_EVENT_F0_S) +#define MCPWM_EVENT_F0_V 0x00000001U +#define MCPWM_EVENT_F0_S 6 +/** MCPWM_EVENT_F1 : RO; bitpos: [7]; default: 0; + * Set and reset by hardware. If set, fault_event1 is on going + */ +#define MCPWM_EVENT_F1 (BIT(7)) +#define MCPWM_EVENT_F1_M (MCPWM_EVENT_F1_V << MCPWM_EVENT_F1_S) +#define MCPWM_EVENT_F1_V 0x00000001U +#define MCPWM_EVENT_F1_S 7 +/** MCPWM_EVENT_F2 : RO; bitpos: [8]; default: 0; + * Set and reset by hardware. If set, fault_event2 is on going + */ +#define MCPWM_EVENT_F2 (BIT(8)) +#define MCPWM_EVENT_F2_M (MCPWM_EVENT_F2_V << MCPWM_EVENT_F2_S) +#define MCPWM_EVENT_F2_V 0x00000001U +#define MCPWM_EVENT_F2_S 8 -#define MCPWM_CAP_TIMER_CFG_REG(i) (REG_MCPWM_BASE(i) + 0x00e8) -/* MCPWM_CAP_SYNC_SW : WO ;bitpos:[5] ;default: 1'd0 ; */ -/*description: Set this bit to force a capture timer sync capture timer is - loaded with value in phase register.*/ -#define MCPWM_CAP_SYNC_SW (BIT(5)) -#define MCPWM_CAP_SYNC_SW_M (BIT(5)) -#define MCPWM_CAP_SYNC_SW_V 0x1 -#define MCPWM_CAP_SYNC_SW_S 5 -/* MCPWM_CAP_SYNCI_SEL : R/W ;bitpos:[4:2] ;default: 3'd0 ; */ -/*description: Capture module sync input selection. 0: none 1: timer0 synco - 2: timer1 synco 3: timer2 synco 4: SYNC0 from GPIO matrix 5: SYNC1 from GPIO matrix 6: SYNC2 from GPIO matrix*/ -#define MCPWM_CAP_SYNCI_SEL 0x00000007 -#define MCPWM_CAP_SYNCI_SEL_M ((MCPWM_CAP_SYNCI_SEL_V)<<(MCPWM_CAP_SYNCI_SEL_S)) -#define MCPWM_CAP_SYNCI_SEL_V 0x7 -#define MCPWM_CAP_SYNCI_SEL_S 2 -/* MCPWM_CAP_SYNCI_EN : R/W ;bitpos:[1] ;default: 1'd0 ; */ -/*description: When set capture timer sync is enabled.*/ -#define MCPWM_CAP_SYNCI_EN (BIT(1)) -#define MCPWM_CAP_SYNCI_EN_M (BIT(1)) -#define MCPWM_CAP_SYNCI_EN_V 0x1 -#define MCPWM_CAP_SYNCI_EN_S 1 -/* MCPWM_CAP_TIMER_EN : R/W ;bitpos:[0] ;default: 1'd0 ; */ -/*description: When set capture timer incrementing under APB_clk is enabled.*/ -#define MCPWM_CAP_TIMER_EN (BIT(0)) -#define MCPWM_CAP_TIMER_EN_M (BIT(0)) -#define MCPWM_CAP_TIMER_EN_V 0x1 +/** MCPWM_CAP_TIMER_CFG_REG register + * Configure capture timer + */ +#define MCPWM_CAP_TIMER_CFG_REG(i) (DR_REG_MCPWM_BASE(i) + 0xe8) +/** MCPWM_CAP_TIMER_EN : R/W; bitpos: [0]; default: 0; + * When set, capture timer incrementing under APB_clk is enabled. + */ +#define MCPWM_CAP_TIMER_EN (BIT(0)) +#define MCPWM_CAP_TIMER_EN_M (MCPWM_CAP_TIMER_EN_V << MCPWM_CAP_TIMER_EN_S) +#define MCPWM_CAP_TIMER_EN_V 0x00000001U #define MCPWM_CAP_TIMER_EN_S 0 +/** MCPWM_CAP_SYNCI_EN : R/W; bitpos: [1]; default: 0; + * When set, capture timer sync is enabled. + */ +#define MCPWM_CAP_SYNCI_EN (BIT(1)) +#define MCPWM_CAP_SYNCI_EN_M (MCPWM_CAP_SYNCI_EN_V << MCPWM_CAP_SYNCI_EN_S) +#define MCPWM_CAP_SYNCI_EN_V 0x00000001U +#define MCPWM_CAP_SYNCI_EN_S 1 +/** MCPWM_CAP_SYNCI_SEL : R/W; bitpos: [4:2]; default: 0; + * capture module sync input selection. 0: none, 1: timer0 sync_out, 2: timer1 + * sync_out, 3: timer2 sync_out, 4: SYNC0 from GPIO matrix, 5: SYNC1 from GPIO matrix, + * 6: SYNC2 from GPIO matrix + */ +#define MCPWM_CAP_SYNCI_SEL 0x00000007U +#define MCPWM_CAP_SYNCI_SEL_M (MCPWM_CAP_SYNCI_SEL_V << MCPWM_CAP_SYNCI_SEL_S) +#define MCPWM_CAP_SYNCI_SEL_V 0x00000007U +#define MCPWM_CAP_SYNCI_SEL_S 2 +/** MCPWM_CAP_SYNC_SW : WT; bitpos: [5]; default: 0; + * When reg_cap_synci_en is 1, write 1 will trigger a capture timer sync, capture + * timer is loaded with value in phase register. + */ +#define MCPWM_CAP_SYNC_SW (BIT(5)) +#define MCPWM_CAP_SYNC_SW_M (MCPWM_CAP_SYNC_SW_V << MCPWM_CAP_SYNC_SW_S) +#define MCPWM_CAP_SYNC_SW_V 0x00000001U +#define MCPWM_CAP_SYNC_SW_S 5 -#define MCPWM_CAP_TIMER_PHASE_REG(i) (REG_MCPWM_BASE(i) + 0x00ec) -/* MCPWM_CAP_PHASE : R/W ;bitpos:[31:0] ;default: 32'd0 ; */ -/*description: Phase value for capture timer sync operation.*/ -#define MCPWM_CAP_PHASE 0xFFFFFFFF -#define MCPWM_CAP_PHASE_M ((MCPWM_CAP_PHASE_V)<<(MCPWM_CAP_PHASE_S)) -#define MCPWM_CAP_PHASE_V 0xFFFFFFFF -#define MCPWM_CAP_PHASE_S 0 - -#define MCPWM_CAP_CH0_CFG_REG(i) (REG_MCPWM_BASE(i) + 0x00f0) -/* MCPWM_CAP0_SW : WO ;bitpos:[12] ;default: 1'd0 ; */ -/*description: Write 1 will trigger a software forced capture on channel 0*/ -#define MCPWM_CAP0_SW (BIT(12)) -#define MCPWM_CAP0_SW_M (BIT(12)) -#define MCPWM_CAP0_SW_V 0x1 -#define MCPWM_CAP0_SW_S 12 -/* MCPWM_CAP0_IN_INVERT : R/W ;bitpos:[11] ;default: 1'd0 ; */ -/*description: When set CAP0 form GPIO matrix is inverted before prescale*/ -#define MCPWM_CAP0_IN_INVERT (BIT(11)) -#define MCPWM_CAP0_IN_INVERT_M (BIT(11)) -#define MCPWM_CAP0_IN_INVERT_V 0x1 -#define MCPWM_CAP0_IN_INVERT_S 11 -/* MCPWM_CAP0_PRESCALE : R/W ;bitpos:[10:3] ;default: 8'd0 ; */ -/*description: Value of prescale on possitive edge of CAP0. Prescale value = - PWM_CAP0_PRESCALE + 1*/ -#define MCPWM_CAP0_PRESCALE 0x000000FF -#define MCPWM_CAP0_PRESCALE_M ((MCPWM_CAP0_PRESCALE_V)<<(MCPWM_CAP0_PRESCALE_S)) -#define MCPWM_CAP0_PRESCALE_V 0xFF -#define MCPWM_CAP0_PRESCALE_S 3 -/* MCPWM_CAP0_MODE : R/W ;bitpos:[2:1] ;default: 2'd0 ; */ -/*description: Edge of capture on channel 0 after prescale. bit0: negedge cap - en bit1: posedge cap en*/ -#define MCPWM_CAP0_MODE 0x00000003 -#define MCPWM_CAP0_MODE_M ((MCPWM_CAP0_MODE_V)<<(MCPWM_CAP0_MODE_S)) -#define MCPWM_CAP0_MODE_V 0x3 -#define MCPWM_CAP0_MODE_S 1 -/* MCPWM_CAP0_EN : R/W ;bitpos:[0] ;default: 1'd0 ; */ -/*description: When set capture on channel 0 is enabled*/ -#define MCPWM_CAP0_EN (BIT(0)) -#define MCPWM_CAP0_EN_M (BIT(0)) -#define MCPWM_CAP0_EN_V 0x1 +/** MCPWM_CAP_TIMER_PHASE_REG register + * Phase for capture timer sync + */ +#define MCPWM_CAP_TIMER_PHASE_REG(i) (DR_REG_MCPWM_BASE(i) + 0xec) +/** MCPWM_CAP_TIMER_PHASE : R/W; bitpos: [31:0]; default: 0; + * Phase value for capture timer sync operation. + */ +#define MCPWM_CAP_TIMER_PHASE 0xFFFFFFFFU +#define MCPWM_CAP_TIMER_PHASE_M (MCPWM_CAP_TIMER_PHASE_V << MCPWM_CAP_TIMER_PHASE_S) +#define MCPWM_CAP_TIMER_PHASE_V 0xFFFFFFFFU +#define MCPWM_CAP_TIMER_PHASE_S 0 + +/** MCPWM_CAP_CH0_CFG_REG register + * Capture channel 0 configuration and enable + */ +#define MCPWM_CAP_CH0_CFG_REG(i) (DR_REG_MCPWM_BASE(i) + 0xf0) +/** MCPWM_CAP0_EN : R/W; bitpos: [0]; default: 0; + * When set, capture on channel 0 is enabled + */ +#define MCPWM_CAP0_EN (BIT(0)) +#define MCPWM_CAP0_EN_M (MCPWM_CAP0_EN_V << MCPWM_CAP0_EN_S) +#define MCPWM_CAP0_EN_V 0x00000001U #define MCPWM_CAP0_EN_S 0 +/** MCPWM_CAP0_MODE : R/W; bitpos: [2:1]; default: 0; + * Edge of capture on channel 0 after prescaling. When bit0 is set to 1: enable + * capture on the negative edge, When bit1 is set to 1: enable capture on the positive + * edge. + */ +#define MCPWM_CAP0_MODE 0x00000003U +#define MCPWM_CAP0_MODE_M (MCPWM_CAP0_MODE_V << MCPWM_CAP0_MODE_S) +#define MCPWM_CAP0_MODE_V 0x00000003U +#define MCPWM_CAP0_MODE_S 1 +/** MCPWM_CAP0_PRESCALE : R/W; bitpos: [10:3]; default: 0; + * Value of prescaling on possitive edge of CAP0. Prescale value = PWM_CAP0_PRESCALE + + * 1 + */ +#define MCPWM_CAP0_PRESCALE 0x000000FFU +#define MCPWM_CAP0_PRESCALE_M (MCPWM_CAP0_PRESCALE_V << MCPWM_CAP0_PRESCALE_S) +#define MCPWM_CAP0_PRESCALE_V 0x000000FFU +#define MCPWM_CAP0_PRESCALE_S 3 +/** MCPWM_CAP0_IN_INVERT : R/W; bitpos: [11]; default: 0; + * when set, CAP0 form GPIO matrix is inverted before prescale + */ +#define MCPWM_CAP0_IN_INVERT (BIT(11)) +#define MCPWM_CAP0_IN_INVERT_M (MCPWM_CAP0_IN_INVERT_V << MCPWM_CAP0_IN_INVERT_S) +#define MCPWM_CAP0_IN_INVERT_V 0x00000001U +#define MCPWM_CAP0_IN_INVERT_S 11 +/** MCPWM_CAP0_SW : WT; bitpos: [12]; default: 0; + * Write 1 will trigger a software forced capture on channel 0 + */ +#define MCPWM_CAP0_SW (BIT(12)) +#define MCPWM_CAP0_SW_M (MCPWM_CAP0_SW_V << MCPWM_CAP0_SW_S) +#define MCPWM_CAP0_SW_V 0x00000001U +#define MCPWM_CAP0_SW_S 12 -#define MCPWM_CAP_CH1_CFG_REG(i) (REG_MCPWM_BASE(i) + 0x00f4) -/* MCPWM_CAP1_SW : WO ;bitpos:[12] ;default: 1'd0 ; */ -/*description: Write 1 will trigger a software forced capture on channel 1*/ -#define MCPWM_CAP1_SW (BIT(12)) -#define MCPWM_CAP1_SW_M (BIT(12)) -#define MCPWM_CAP1_SW_V 0x1 -#define MCPWM_CAP1_SW_S 12 -/* MCPWM_CAP1_IN_INVERT : R/W ;bitpos:[11] ;default: 1'd0 ; */ -/*description: When set CAP1 form GPIO matrix is inverted before prescale*/ -#define MCPWM_CAP1_IN_INVERT (BIT(11)) -#define MCPWM_CAP1_IN_INVERT_M (BIT(11)) -#define MCPWM_CAP1_IN_INVERT_V 0x1 -#define MCPWM_CAP1_IN_INVERT_S 11 -/* MCPWM_CAP1_PRESCALE : R/W ;bitpos:[10:3] ;default: 8'd0 ; */ -/*description: Value of prescale on possitive edge of CAP1. Prescale value = - PWM_CAP1_PRESCALE + 1*/ -#define MCPWM_CAP1_PRESCALE 0x000000FF -#define MCPWM_CAP1_PRESCALE_M ((MCPWM_CAP1_PRESCALE_V)<<(MCPWM_CAP1_PRESCALE_S)) -#define MCPWM_CAP1_PRESCALE_V 0xFF -#define MCPWM_CAP1_PRESCALE_S 3 -/* MCPWM_CAP1_MODE : R/W ;bitpos:[2:1] ;default: 2'd0 ; */ -/*description: Edge of capture on channel 1 after prescale. bit0: negedge cap - en bit1: posedge cap en*/ -#define MCPWM_CAP1_MODE 0x00000003 -#define MCPWM_CAP1_MODE_M ((MCPWM_CAP1_MODE_V)<<(MCPWM_CAP1_MODE_S)) -#define MCPWM_CAP1_MODE_V 0x3 -#define MCPWM_CAP1_MODE_S 1 -/* MCPWM_CAP1_EN : R/W ;bitpos:[0] ;default: 1'd0 ; */ -/*description: When set capture on channel 1 is enabled*/ -#define MCPWM_CAP1_EN (BIT(0)) -#define MCPWM_CAP1_EN_M (BIT(0)) -#define MCPWM_CAP1_EN_V 0x1 +/** MCPWM_CAP_CH1_CFG_REG register + * Capture channel 1 configuration and enable + */ +#define MCPWM_CAP_CH1_CFG_REG(i) (DR_REG_MCPWM_BASE(i) + 0xf4) +/** MCPWM_CAP1_EN : R/W; bitpos: [0]; default: 0; + * When set, capture on channel 2 is enabled + */ +#define MCPWM_CAP1_EN (BIT(0)) +#define MCPWM_CAP1_EN_M (MCPWM_CAP1_EN_V << MCPWM_CAP1_EN_S) +#define MCPWM_CAP1_EN_V 0x00000001U #define MCPWM_CAP1_EN_S 0 +/** MCPWM_CAP1_MODE : R/W; bitpos: [2:1]; default: 0; + * Edge of capture on channel 1 after prescaling. When bit0 is set to 1: enable + * capture on the negative edge, When bit1 is set to 1: enable capture on the positive + * edge. + */ +#define MCPWM_CAP1_MODE 0x00000003U +#define MCPWM_CAP1_MODE_M (MCPWM_CAP1_MODE_V << MCPWM_CAP1_MODE_S) +#define MCPWM_CAP1_MODE_V 0x00000003U +#define MCPWM_CAP1_MODE_S 1 +/** MCPWM_CAP1_PRESCALE : R/W; bitpos: [10:3]; default: 0; + * Value of prescaling on possitive edge of CAP1. Prescale value = PWM_CAP1_PRESCALE + + * 1 + */ +#define MCPWM_CAP1_PRESCALE 0x000000FFU +#define MCPWM_CAP1_PRESCALE_M (MCPWM_CAP1_PRESCALE_V << MCPWM_CAP1_PRESCALE_S) +#define MCPWM_CAP1_PRESCALE_V 0x000000FFU +#define MCPWM_CAP1_PRESCALE_S 3 +/** MCPWM_CAP1_IN_INVERT : R/W; bitpos: [11]; default: 0; + * when set, CAP1 form GPIO matrix is inverted before prescale + */ +#define MCPWM_CAP1_IN_INVERT (BIT(11)) +#define MCPWM_CAP1_IN_INVERT_M (MCPWM_CAP1_IN_INVERT_V << MCPWM_CAP1_IN_INVERT_S) +#define MCPWM_CAP1_IN_INVERT_V 0x00000001U +#define MCPWM_CAP1_IN_INVERT_S 11 +/** MCPWM_CAP1_SW : WT; bitpos: [12]; default: 0; + * Write 1 will trigger a software forced capture on channel 1 + */ +#define MCPWM_CAP1_SW (BIT(12)) +#define MCPWM_CAP1_SW_M (MCPWM_CAP1_SW_V << MCPWM_CAP1_SW_S) +#define MCPWM_CAP1_SW_V 0x00000001U +#define MCPWM_CAP1_SW_S 12 -#define MCPWM_CAP_CH2_CFG_REG(i) (REG_MCPWM_BASE(i) + 0x00f8) -/* MCPWM_CAP2_SW : WO ;bitpos:[12] ;default: 1'd0 ; */ -/*description: Write 1 will trigger a software forced capture on channel 2*/ -#define MCPWM_CAP2_SW (BIT(12)) -#define MCPWM_CAP2_SW_M (BIT(12)) -#define MCPWM_CAP2_SW_V 0x1 -#define MCPWM_CAP2_SW_S 12 -/* MCPWM_CAP2_IN_INVERT : R/W ;bitpos:[11] ;default: 1'd0 ; */ -/*description: When set CAP2 form GPIO matrix is inverted before prescale*/ -#define MCPWM_CAP2_IN_INVERT (BIT(11)) -#define MCPWM_CAP2_IN_INVERT_M (BIT(11)) -#define MCPWM_CAP2_IN_INVERT_V 0x1 -#define MCPWM_CAP2_IN_INVERT_S 11 -/* MCPWM_CAP2_PRESCALE : R/W ;bitpos:[10:3] ;default: 8'd0 ; */ -/*description: Value of prescale on possitive edge of CAP2. Prescale value = - PWM_CAP2_PRESCALE + 1*/ -#define MCPWM_CAP2_PRESCALE 0x000000FF -#define MCPWM_CAP2_PRESCALE_M ((MCPWM_CAP2_PRESCALE_V)<<(MCPWM_CAP2_PRESCALE_S)) -#define MCPWM_CAP2_PRESCALE_V 0xFF -#define MCPWM_CAP2_PRESCALE_S 3 -/* MCPWM_CAP2_MODE : R/W ;bitpos:[2:1] ;default: 2'd0 ; */ -/*description: Edge of capture on channel 2 after prescale. bit0: negedge cap - en bit1: posedge cap en*/ -#define MCPWM_CAP2_MODE 0x00000003 -#define MCPWM_CAP2_MODE_M ((MCPWM_CAP2_MODE_V)<<(MCPWM_CAP2_MODE_S)) -#define MCPWM_CAP2_MODE_V 0x3 -#define MCPWM_CAP2_MODE_S 1 -/* MCPWM_CAP2_EN : R/W ;bitpos:[0] ;default: 1'd0 ; */ -/*description: When set capture on channel 2 is enabled*/ -#define MCPWM_CAP2_EN (BIT(0)) -#define MCPWM_CAP2_EN_M (BIT(0)) -#define MCPWM_CAP2_EN_V 0x1 +/** MCPWM_CAP_CH2_CFG_REG register + * Capture channel 2 configuration and enable + */ +#define MCPWM_CAP_CH2_CFG_REG(i) (DR_REG_MCPWM_BASE(i) + 0xf8) +/** MCPWM_CAP2_EN : R/W; bitpos: [0]; default: 0; + * When set, capture on channel 2 is enabled + */ +#define MCPWM_CAP2_EN (BIT(0)) +#define MCPWM_CAP2_EN_M (MCPWM_CAP2_EN_V << MCPWM_CAP2_EN_S) +#define MCPWM_CAP2_EN_V 0x00000001U #define MCPWM_CAP2_EN_S 0 +/** MCPWM_CAP2_MODE : R/W; bitpos: [2:1]; default: 0; + * Edge of capture on channel 2 after prescaling. When bit0 is set to 1: enable + * capture on the negative edge, When bit1 is set to 1: enable capture on the positive + * edge. + */ +#define MCPWM_CAP2_MODE 0x00000003U +#define MCPWM_CAP2_MODE_M (MCPWM_CAP2_MODE_V << MCPWM_CAP2_MODE_S) +#define MCPWM_CAP2_MODE_V 0x00000003U +#define MCPWM_CAP2_MODE_S 1 +/** MCPWM_CAP2_PRESCALE : R/W; bitpos: [10:3]; default: 0; + * Value of prescaling on possitive edge of CAP2. Prescale value = PWM_CAP2_PRESCALE + + * 1 + */ +#define MCPWM_CAP2_PRESCALE 0x000000FFU +#define MCPWM_CAP2_PRESCALE_M (MCPWM_CAP2_PRESCALE_V << MCPWM_CAP2_PRESCALE_S) +#define MCPWM_CAP2_PRESCALE_V 0x000000FFU +#define MCPWM_CAP2_PRESCALE_S 3 +/** MCPWM_CAP2_IN_INVERT : R/W; bitpos: [11]; default: 0; + * when set, CAP2 form GPIO matrix is inverted before prescale + */ +#define MCPWM_CAP2_IN_INVERT (BIT(11)) +#define MCPWM_CAP2_IN_INVERT_M (MCPWM_CAP2_IN_INVERT_V << MCPWM_CAP2_IN_INVERT_S) +#define MCPWM_CAP2_IN_INVERT_V 0x00000001U +#define MCPWM_CAP2_IN_INVERT_S 11 +/** MCPWM_CAP2_SW : WT; bitpos: [12]; default: 0; + * Write 1 will trigger a software forced capture on channel 2 + */ +#define MCPWM_CAP2_SW (BIT(12)) +#define MCPWM_CAP2_SW_M (MCPWM_CAP2_SW_V << MCPWM_CAP2_SW_S) +#define MCPWM_CAP2_SW_V 0x00000001U +#define MCPWM_CAP2_SW_S 12 -#define MCPWM_CAP_CH0_REG(i) (REG_MCPWM_BASE(i) + 0x00fc) -/* MCPWM_CAP0_VALUE : RO ;bitpos:[31:0] ;default: 32'd0 ; */ -/*description: Value of last capture on channel 0*/ -#define MCPWM_CAP0_VALUE 0xFFFFFFFF -#define MCPWM_CAP0_VALUE_M ((MCPWM_CAP0_VALUE_V)<<(MCPWM_CAP0_VALUE_S)) -#define MCPWM_CAP0_VALUE_V 0xFFFFFFFF +/** MCPWM_CAP_CH0_REG register + * ch0 capture value status register + */ +#define MCPWM_CAP_CH0_REG(i) (DR_REG_MCPWM_BASE(i) + 0xfc) +/** MCPWM_CAP0_VALUE : RO; bitpos: [31:0]; default: 0; + * Value of last capture on channel 0 + */ +#define MCPWM_CAP0_VALUE 0xFFFFFFFFU +#define MCPWM_CAP0_VALUE_M (MCPWM_CAP0_VALUE_V << MCPWM_CAP0_VALUE_S) +#define MCPWM_CAP0_VALUE_V 0xFFFFFFFFU #define MCPWM_CAP0_VALUE_S 0 -#define MCPWM_CAP_CH1_REG(i) (REG_MCPWM_BASE(i) + 0x0100) -/* MCPWM_CAP1_VALUE : RO ;bitpos:[31:0] ;default: 32'd0 ; */ -/*description: Value of last capture on channel 1*/ -#define MCPWM_CAP1_VALUE 0xFFFFFFFF -#define MCPWM_CAP1_VALUE_M ((MCPWM_CAP1_VALUE_V)<<(MCPWM_CAP1_VALUE_S)) -#define MCPWM_CAP1_VALUE_V 0xFFFFFFFF +/** MCPWM_CAP_CH1_REG register + * ch1 capture value status register + */ +#define MCPWM_CAP_CH1_REG(i) (DR_REG_MCPWM_BASE(i) + 0x100) +/** MCPWM_CAP1_VALUE : RO; bitpos: [31:0]; default: 0; + * Value of last capture on channel 1 + */ +#define MCPWM_CAP1_VALUE 0xFFFFFFFFU +#define MCPWM_CAP1_VALUE_M (MCPWM_CAP1_VALUE_V << MCPWM_CAP1_VALUE_S) +#define MCPWM_CAP1_VALUE_V 0xFFFFFFFFU #define MCPWM_CAP1_VALUE_S 0 -#define MCPWM_CAP_CH2_REG(i) (REG_MCPWM_BASE(i) + 0x0104) -/* MCPWM_CAP2_VALUE : RO ;bitpos:[31:0] ;default: 32'd0 ; */ -/*description: Value of last capture on channel 2*/ -#define MCPWM_CAP2_VALUE 0xFFFFFFFF -#define MCPWM_CAP2_VALUE_M ((MCPWM_CAP2_VALUE_V)<<(MCPWM_CAP2_VALUE_S)) -#define MCPWM_CAP2_VALUE_V 0xFFFFFFFF +/** MCPWM_CAP_CH2_REG register + * ch2 capture value status register + */ +#define MCPWM_CAP_CH2_REG(i) (DR_REG_MCPWM_BASE(i) + 0x104) +/** MCPWM_CAP2_VALUE : RO; bitpos: [31:0]; default: 0; + * Value of last capture on channel 2 + */ +#define MCPWM_CAP2_VALUE 0xFFFFFFFFU +#define MCPWM_CAP2_VALUE_M (MCPWM_CAP2_VALUE_V << MCPWM_CAP2_VALUE_S) +#define MCPWM_CAP2_VALUE_V 0xFFFFFFFFU #define MCPWM_CAP2_VALUE_S 0 -#define MCPWM_CAP_STATUS_REG(i) (REG_MCPWM_BASE(i) + 0x0108) -/* MCPWM_CAP2_EDGE : RO ;bitpos:[2] ;default: 1'd0 ; */ -/*description: Edge of last capture trigger on channel 2 0: posedge 1: negedge*/ -#define MCPWM_CAP2_EDGE (BIT(2)) -#define MCPWM_CAP2_EDGE_M (BIT(2)) -#define MCPWM_CAP2_EDGE_V 0x1 -#define MCPWM_CAP2_EDGE_S 2 -/* MCPWM_CAP1_EDGE : RO ;bitpos:[1] ;default: 1'd0 ; */ -/*description: Edge of last capture trigger on channel 1 0: posedge 1: negedge*/ -#define MCPWM_CAP1_EDGE (BIT(1)) -#define MCPWM_CAP1_EDGE_M (BIT(1)) -#define MCPWM_CAP1_EDGE_V 0x1 -#define MCPWM_CAP1_EDGE_S 1 -/* MCPWM_CAP0_EDGE : RO ;bitpos:[0] ;default: 1'd0 ; */ -/*description: Edge of last capture trigger on channel 0 0: posedge 1: negedge*/ -#define MCPWM_CAP0_EDGE (BIT(0)) -#define MCPWM_CAP0_EDGE_M (BIT(0)) -#define MCPWM_CAP0_EDGE_V 0x1 +/** MCPWM_CAP_STATUS_REG register + * Edge of last capture trigger + */ +#define MCPWM_CAP_STATUS_REG(i) (DR_REG_MCPWM_BASE(i) + 0x108) +/** MCPWM_CAP0_EDGE : RO; bitpos: [0]; default: 0; + * Edge of last capture trigger on channel 0, 0: posedge, 1: negedge + */ +#define MCPWM_CAP0_EDGE (BIT(0)) +#define MCPWM_CAP0_EDGE_M (MCPWM_CAP0_EDGE_V << MCPWM_CAP0_EDGE_S) +#define MCPWM_CAP0_EDGE_V 0x00000001U #define MCPWM_CAP0_EDGE_S 0 +/** MCPWM_CAP1_EDGE : RO; bitpos: [1]; default: 0; + * Edge of last capture trigger on channel 1, 0: posedge, 1: negedge + */ +#define MCPWM_CAP1_EDGE (BIT(1)) +#define MCPWM_CAP1_EDGE_M (MCPWM_CAP1_EDGE_V << MCPWM_CAP1_EDGE_S) +#define MCPWM_CAP1_EDGE_V 0x00000001U +#define MCPWM_CAP1_EDGE_S 1 +/** MCPWM_CAP2_EDGE : RO; bitpos: [2]; default: 0; + * Edge of last capture trigger on channel 2, 0: posedge, 1: negedge + */ +#define MCPWM_CAP2_EDGE (BIT(2)) +#define MCPWM_CAP2_EDGE_M (MCPWM_CAP2_EDGE_V << MCPWM_CAP2_EDGE_S) +#define MCPWM_CAP2_EDGE_V 0x00000001U +#define MCPWM_CAP2_EDGE_S 2 -#define MCPWM_UPDATE_CFG_REG(i) (REG_MCPWM_BASE(i) + 0x010c) -/* MCPWM_OP2_FORCE_UP : R/W ;bitpos:[7] ;default: 1'd0 ; */ -/*description: A toggle (software negation of value of this bit) will trigger - a forced update of active registers in PWM operator 2*/ -#define MCPWM_OP2_FORCE_UP (BIT(7)) -#define MCPWM_OP2_FORCE_UP_M (BIT(7)) -#define MCPWM_OP2_FORCE_UP_V 0x1 -#define MCPWM_OP2_FORCE_UP_S 7 -/* MCPWM_OP2_UP_EN : R/W ;bitpos:[6] ;default: 1'd1 ; */ -/*description: When set and PWM_GLOBAL_UP_EN is set update of active registers - in PWM operator 2 are enabled*/ -#define MCPWM_OP2_UP_EN (BIT(6)) -#define MCPWM_OP2_UP_EN_M (BIT(6)) -#define MCPWM_OP2_UP_EN_V 0x1 -#define MCPWM_OP2_UP_EN_S 6 -/* MCPWM_OP1_FORCE_UP : R/W ;bitpos:[5] ;default: 1'd0 ; */ -/*description: A toggle (software negation of value of this bit) will trigger - a forced update of active registers in PWM operator 1*/ -#define MCPWM_OP1_FORCE_UP (BIT(5)) -#define MCPWM_OP1_FORCE_UP_M (BIT(5)) -#define MCPWM_OP1_FORCE_UP_V 0x1 -#define MCPWM_OP1_FORCE_UP_S 5 -/* MCPWM_OP1_UP_EN : R/W ;bitpos:[4] ;default: 1'd1 ; */ -/*description: When set and PWM_GLOBAL_UP_EN is set update of active registers - in PWM operator 1 are enabled*/ -#define MCPWM_OP1_UP_EN (BIT(4)) -#define MCPWM_OP1_UP_EN_M (BIT(4)) -#define MCPWM_OP1_UP_EN_V 0x1 -#define MCPWM_OP1_UP_EN_S 4 -/* MCPWM_OP0_FORCE_UP : R/W ;bitpos:[3] ;default: 1'd0 ; */ -/*description: A toggle (software negation of value of this bit) will trigger - a forced update of active registers in PWM operator 0*/ -#define MCPWM_OP0_FORCE_UP (BIT(3)) -#define MCPWM_OP0_FORCE_UP_M (BIT(3)) -#define MCPWM_OP0_FORCE_UP_V 0x1 -#define MCPWM_OP0_FORCE_UP_S 3 -/* MCPWM_OP0_UP_EN : R/W ;bitpos:[2] ;default: 1'd1 ; */ -/*description: When set and PWM_GLOBAL_UP_EN is set update of active registers - in PWM operator 0 are enabled*/ -#define MCPWM_OP0_UP_EN (BIT(2)) -#define MCPWM_OP0_UP_EN_M (BIT(2)) -#define MCPWM_OP0_UP_EN_V 0x1 -#define MCPWM_OP0_UP_EN_S 2 -/* MCPWM_GLOBAL_FORCE_UP : R/W ;bitpos:[1] ;default: 1'd0 ; */ -/*description: A toggle (software negation of value of this bit) will trigger - a forced update of all active registers in MCPWM module*/ -#define MCPWM_GLOBAL_FORCE_UP (BIT(1)) -#define MCPWM_GLOBAL_FORCE_UP_M (BIT(1)) -#define MCPWM_GLOBAL_FORCE_UP_V 0x1 -#define MCPWM_GLOBAL_FORCE_UP_S 1 -/* MCPWM_GLOBAL_UP_EN : R/W ;bitpos:[0] ;default: 1'd1 ; */ -/*description: The global enable of update of all active registers in MCPWM module*/ -#define MCPWM_GLOBAL_UP_EN (BIT(0)) -#define MCPWM_GLOBAL_UP_EN_M (BIT(0)) -#define MCPWM_GLOBAL_UP_EN_V 0x1 +/** MCPWM_UPDATE_CFG_REG register + * Enable update. + */ +#define MCPWM_UPDATE_CFG_REG(i) (DR_REG_MCPWM_BASE(i) + 0x10c) +/** MCPWM_GLOBAL_UP_EN : R/W; bitpos: [0]; default: 1; + * The global enable of update of all active registers in MCPWM module + */ +#define MCPWM_GLOBAL_UP_EN (BIT(0)) +#define MCPWM_GLOBAL_UP_EN_M (MCPWM_GLOBAL_UP_EN_V << MCPWM_GLOBAL_UP_EN_S) +#define MCPWM_GLOBAL_UP_EN_V 0x00000001U #define MCPWM_GLOBAL_UP_EN_S 0 +/** MCPWM_GLOBAL_FORCE_UP : R/W; bitpos: [1]; default: 0; + * a toggle (software invert its value) will trigger a forced update of all active + * registers in MCPWM module + */ +#define MCPWM_GLOBAL_FORCE_UP (BIT(1)) +#define MCPWM_GLOBAL_FORCE_UP_M (MCPWM_GLOBAL_FORCE_UP_V << MCPWM_GLOBAL_FORCE_UP_S) +#define MCPWM_GLOBAL_FORCE_UP_V 0x00000001U +#define MCPWM_GLOBAL_FORCE_UP_S 1 +/** MCPWM_OP0_UP_EN : R/W; bitpos: [2]; default: 1; + * When set and PWM_GLOBAL_UP_EN is set, update of active registers in PWM operator 0 + * are enabled + */ +#define MCPWM_OP0_UP_EN (BIT(2)) +#define MCPWM_OP0_UP_EN_M (MCPWM_OP0_UP_EN_V << MCPWM_OP0_UP_EN_S) +#define MCPWM_OP0_UP_EN_V 0x00000001U +#define MCPWM_OP0_UP_EN_S 2 +/** MCPWM_OP0_FORCE_UP : R/W; bitpos: [3]; default: 0; + * a toggle (software invert its value) will trigger a forced update of active + * registers in PWM operator 0 + */ +#define MCPWM_OP0_FORCE_UP (BIT(3)) +#define MCPWM_OP0_FORCE_UP_M (MCPWM_OP0_FORCE_UP_V << MCPWM_OP0_FORCE_UP_S) +#define MCPWM_OP0_FORCE_UP_V 0x00000001U +#define MCPWM_OP0_FORCE_UP_S 3 +/** MCPWM_OP1_UP_EN : R/W; bitpos: [4]; default: 1; + * When set and PWM_GLOBAL_UP_EN is set, update of active registers in PWM operator 1 + * are enabled + */ +#define MCPWM_OP1_UP_EN (BIT(4)) +#define MCPWM_OP1_UP_EN_M (MCPWM_OP1_UP_EN_V << MCPWM_OP1_UP_EN_S) +#define MCPWM_OP1_UP_EN_V 0x00000001U +#define MCPWM_OP1_UP_EN_S 4 +/** MCPWM_OP1_FORCE_UP : R/W; bitpos: [5]; default: 0; + * a toggle (software invert its value) will trigger a forced update of active + * registers in PWM operator 1 + */ +#define MCPWM_OP1_FORCE_UP (BIT(5)) +#define MCPWM_OP1_FORCE_UP_M (MCPWM_OP1_FORCE_UP_V << MCPWM_OP1_FORCE_UP_S) +#define MCPWM_OP1_FORCE_UP_V 0x00000001U +#define MCPWM_OP1_FORCE_UP_S 5 +/** MCPWM_OP2_UP_EN : R/W; bitpos: [6]; default: 1; + * When set and PWM_GLOBAL_UP_EN is set, update of active registers in PWM operator 2 + * are enabled + */ +#define MCPWM_OP2_UP_EN (BIT(6)) +#define MCPWM_OP2_UP_EN_M (MCPWM_OP2_UP_EN_V << MCPWM_OP2_UP_EN_S) +#define MCPWM_OP2_UP_EN_V 0x00000001U +#define MCPWM_OP2_UP_EN_S 6 +/** MCPWM_OP2_FORCE_UP : R/W; bitpos: [7]; default: 0; + * a toggle (software invert its value) will trigger a forced update of active + * registers in PWM operator 2 + */ +#define MCPWM_OP2_FORCE_UP (BIT(7)) +#define MCPWM_OP2_FORCE_UP_M (MCPWM_OP2_FORCE_UP_V << MCPWM_OP2_FORCE_UP_S) +#define MCPWM_OP2_FORCE_UP_V 0x00000001U +#define MCPWM_OP2_FORCE_UP_S 7 -#define MCMCPWM_INT_ENA_MCPWM_REG(i) (REG_MCPWM_BASE(i) + 0x0110) -/* MCPWM_CAP2_INT_ENA : R/W ;bitpos:[29] ;default: 1'd0 ; */ -/*description: The enable bit for interrupt triggered by captureon channel 2*/ -#define MCPWM_CAP2_INT_ENA (BIT(29)) -#define MCPWM_CAP2_INT_ENA_M (BIT(29)) -#define MCPWM_CAP2_INT_ENA_V 0x1 -#define MCPWM_CAP2_INT_ENA_S 29 -/* MCPWM_CAP1_INT_ENA : R/W ;bitpos:[28] ;default: 1'd0 ; */ -/*description: The enable bit for interrupt triggered by captureon channel 1*/ -#define MCPWM_CAP1_INT_ENA (BIT(28)) -#define MCPWM_CAP1_INT_ENA_M (BIT(28)) -#define MCPWM_CAP1_INT_ENA_V 0x1 -#define MCPWM_CAP1_INT_ENA_S 28 -/* MCPWM_CAP0_INT_ENA : R/W ;bitpos:[27] ;default: 1'd0 ; */ -/*description: The enable bit for interrupt triggered by captureon channel 0*/ -#define MCPWM_CAP0_INT_ENA (BIT(27)) -#define MCPWM_CAP0_INT_ENA_M (BIT(27)) -#define MCPWM_CAP0_INT_ENA_V 0x1 -#define MCPWM_CAP0_INT_ENA_S 27 -/* MCPWM_FH2_OST_INT_ENA : R/W ;bitpos:[26] ;default: 1'd0 ; */ -/*description: The enable bit for interrupt triggered by an one-shot mode action on PWM2*/ -#define MCPWM_FH2_OST_INT_ENA (BIT(26)) -#define MCPWM_FH2_OST_INT_ENA_M (BIT(26)) -#define MCPWM_FH2_OST_INT_ENA_V 0x1 -#define MCPWM_FH2_OST_INT_ENA_S 26 -/* MCPWM_FH1_OST_INT_ENA : R/W ;bitpos:[25] ;default: 1'd0 ; */ -/*description: The enable bit for interrupt triggered by an one-shot mode action on PWM0*/ -#define MCPWM_FH1_OST_INT_ENA (BIT(25)) -#define MCPWM_FH1_OST_INT_ENA_M (BIT(25)) -#define MCPWM_FH1_OST_INT_ENA_V 0x1 -#define MCPWM_FH1_OST_INT_ENA_S 25 -/* MCPWM_FH0_OST_INT_ENA : R/W ;bitpos:[24] ;default: 1'd0 ; */ -/*description: The enable bit for interrupt triggered by an one-shot mode action on PWM0*/ -#define MCPWM_FH0_OST_INT_ENA (BIT(24)) -#define MCPWM_FH0_OST_INT_ENA_M (BIT(24)) -#define MCPWM_FH0_OST_INT_ENA_V 0x1 -#define MCPWM_FH0_OST_INT_ENA_S 24 -/* MCPWM_FH2_CBC_INT_ENA : R/W ;bitpos:[23] ;default: 1'd0 ; */ -/*description: The enable bit for interrupt triggered by an cycle-by-cycle mode action on PWM2*/ -#define MCPWM_FH2_CBC_INT_ENA (BIT(23)) -#define MCPWM_FH2_CBC_INT_ENA_M (BIT(23)) -#define MCPWM_FH2_CBC_INT_ENA_V 0x1 -#define MCPWM_FH2_CBC_INT_ENA_S 23 -/* MCPWM_FH1_CBC_INT_ENA : R/W ;bitpos:[22] ;default: 1'd0 ; */ -/*description: The enable bit for interrupt triggered by an cycle-by-cycle mode action on PWM1*/ -#define MCPWM_FH1_CBC_INT_ENA (BIT(22)) -#define MCPWM_FH1_CBC_INT_ENA_M (BIT(22)) -#define MCPWM_FH1_CBC_INT_ENA_V 0x1 -#define MCPWM_FH1_CBC_INT_ENA_S 22 -/* MCPWM_FH0_CBC_INT_ENA : R/W ;bitpos:[21] ;default: 1'd0 ; */ -/*description: The enable bit for interrupt triggered by an cycle-by-cycle mode action on PWM0*/ -#define MCPWM_FH0_CBC_INT_ENA (BIT(21)) -#define MCPWM_FH0_CBC_INT_ENA_M (BIT(21)) -#define MCPWM_FH0_CBC_INT_ENA_V 0x1 -#define MCPWM_FH0_CBC_INT_ENA_S 21 -/* MCPWM_OP2_TEB_INT_ENA : R/W ;bitpos:[20] ;default: 1'd0 ; */ -/*description: The enable bit for interrupt triggered by a PWM operator 2 TEB event*/ -#define MCPWM_OP2_TEB_INT_ENA (BIT(20)) -#define MCPWM_OP2_TEB_INT_ENA_M (BIT(20)) -#define MCPWM_OP2_TEB_INT_ENA_V 0x1 -#define MCPWM_OP2_TEB_INT_ENA_S 20 -/* MCPWM_OP1_TEB_INT_ENA : R/W ;bitpos:[19] ;default: 1'd0 ; */ -/*description: The enable bit for interrupt triggered by a PWM operator 1 TEB event*/ -#define MCPWM_OP1_TEB_INT_ENA (BIT(19)) -#define MCPWM_OP1_TEB_INT_ENA_M (BIT(19)) -#define MCPWM_OP1_TEB_INT_ENA_V 0x1 -#define MCPWM_OP1_TEB_INT_ENA_S 19 -/* MCPWM_OP0_TEB_INT_ENA : R/W ;bitpos:[18] ;default: 1'd0 ; */ -/*description: The enable bit for interrupt triggered by a PWM operator 0 TEB event*/ -#define MCPWM_OP0_TEB_INT_ENA (BIT(18)) -#define MCPWM_OP0_TEB_INT_ENA_M (BIT(18)) -#define MCPWM_OP0_TEB_INT_ENA_V 0x1 -#define MCPWM_OP0_TEB_INT_ENA_S 18 -/* MCPWM_OP2_TEA_INT_ENA : R/W ;bitpos:[17] ;default: 1'd0 ; */ -/*description: The enable bit for interrupt triggered by a PWM operator 2 TEA event*/ -#define MCPWM_OP2_TEA_INT_ENA (BIT(17)) -#define MCPWM_OP2_TEA_INT_ENA_M (BIT(17)) -#define MCPWM_OP2_TEA_INT_ENA_V 0x1 -#define MCPWM_OP2_TEA_INT_ENA_S 17 -/* MCPWM_OP1_TEA_INT_ENA : R/W ;bitpos:[16] ;default: 1'd0 ; */ -/*description: The enable bit for interrupt triggered by a PWM operator 1 TEA event*/ -#define MCPWM_OP1_TEA_INT_ENA (BIT(16)) -#define MCPWM_OP1_TEA_INT_ENA_M (BIT(16)) -#define MCPWM_OP1_TEA_INT_ENA_V 0x1 -#define MCPWM_OP1_TEA_INT_ENA_S 16 -/* MCPWM_OP0_TEA_INT_ENA : R/W ;bitpos:[15] ;default: 1'd0 ; */ -/*description: The enable bit for interrupt triggered by a PWM operator 0 TEA event*/ -#define MCPWM_OP0_TEA_INT_ENA (BIT(15)) -#define MCPWM_OP0_TEA_INT_ENA_M (BIT(15)) -#define MCPWM_OP0_TEA_INT_ENA_V 0x1 -#define MCPWM_OP0_TEA_INT_ENA_S 15 -/* MCPWM_FAULT2_CLR_INT_ENA : R/W ;bitpos:[14] ;default: 1'd0 ; */ -/*description: The enable bit for interrupt triggered when event_f2 ends*/ -#define MCPWM_FAULT2_CLR_INT_ENA (BIT(14)) -#define MCPWM_FAULT2_CLR_INT_ENA_M (BIT(14)) -#define MCPWM_FAULT2_CLR_INT_ENA_V 0x1 -#define MCPWM_FAULT2_CLR_INT_ENA_S 14 -/* MCPWM_FAULT1_CLR_INT_ENA : R/W ;bitpos:[13] ;default: 1'd0 ; */ -/*description: The enable bit for interrupt triggered when event_f1 ends*/ -#define MCPWM_FAULT1_CLR_INT_ENA (BIT(13)) -#define MCPWM_FAULT1_CLR_INT_ENA_M (BIT(13)) -#define MCPWM_FAULT1_CLR_INT_ENA_V 0x1 -#define MCPWM_FAULT1_CLR_INT_ENA_S 13 -/* MCPWM_FAULT0_CLR_INT_ENA : R/W ;bitpos:[12] ;default: 1'd0 ; */ -/*description: The enable bit for interrupt triggered when event_f0 ends*/ -#define MCPWM_FAULT0_CLR_INT_ENA (BIT(12)) -#define MCPWM_FAULT0_CLR_INT_ENA_M (BIT(12)) -#define MCPWM_FAULT0_CLR_INT_ENA_V 0x1 -#define MCPWM_FAULT0_CLR_INT_ENA_S 12 -/* MCPWM_FAULT2_INT_ENA : R/W ;bitpos:[11] ;default: 1'd0 ; */ -/*description: The enable bit for interrupt triggered when event_f2 starts*/ -#define MCPWM_FAULT2_INT_ENA (BIT(11)) -#define MCPWM_FAULT2_INT_ENA_M (BIT(11)) -#define MCPWM_FAULT2_INT_ENA_V 0x1 -#define MCPWM_FAULT2_INT_ENA_S 11 -/* MCPWM_FAULT1_INT_ENA : R/W ;bitpos:[10] ;default: 1'd0 ; */ -/*description: The enable bit for interrupt triggered when event_f1 starts*/ -#define MCPWM_FAULT1_INT_ENA (BIT(10)) -#define MCPWM_FAULT1_INT_ENA_M (BIT(10)) -#define MCPWM_FAULT1_INT_ENA_V 0x1 -#define MCPWM_FAULT1_INT_ENA_S 10 -/* MCPWM_FAULT0_INT_ENA : R/W ;bitpos:[9] ;default: 1'd0 ; */ -/*description: The enable bit for interrupt triggered when event_f0 starts*/ -#define MCPWM_FAULT0_INT_ENA (BIT(9)) -#define MCPWM_FAULT0_INT_ENA_M (BIT(9)) -#define MCPWM_FAULT0_INT_ENA_V 0x1 -#define MCPWM_FAULT0_INT_ENA_S 9 -/* MCPWM_TIMER2_TEP_INT_ENA : R/W ;bitpos:[8] ;default: 1'h0 ; */ -/*description: The enable bit for interrupt triggered by a PWM timer 2 TEP event*/ -#define MCPWM_TIMER2_TEP_INT_ENA (BIT(8)) -#define MCPWM_TIMER2_TEP_INT_ENA_M (BIT(8)) -#define MCPWM_TIMER2_TEP_INT_ENA_V 0x1 -#define MCPWM_TIMER2_TEP_INT_ENA_S 8 -/* MCPWM_TIMER1_TEP_INT_ENA : R/W ;bitpos:[7] ;default: 1'h0 ; */ -/*description: The enable bit for interrupt triggered by a PWM timer 1 TEP event*/ -#define MCPWM_TIMER1_TEP_INT_ENA (BIT(7)) -#define MCPWM_TIMER1_TEP_INT_ENA_M (BIT(7)) -#define MCPWM_TIMER1_TEP_INT_ENA_V 0x1 -#define MCPWM_TIMER1_TEP_INT_ENA_S 7 -/* MCPWM_TIMER0_TEP_INT_ENA : R/W ;bitpos:[6] ;default: 1'h0 ; */ -/*description: The enable bit for interrupt triggered by a PWM timer 0 TEP event*/ -#define MCPWM_TIMER0_TEP_INT_ENA (BIT(6)) -#define MCPWM_TIMER0_TEP_INT_ENA_M (BIT(6)) -#define MCPWM_TIMER0_TEP_INT_ENA_V 0x1 -#define MCPWM_TIMER0_TEP_INT_ENA_S 6 -/* MCPWM_TIMER2_TEZ_INT_ENA : R/W ;bitpos:[5] ;default: 1'h0 ; */ -/*description: The enable bit for interrupt triggered by a PWM timer 2 TEZ event*/ -#define MCPWM_TIMER2_TEZ_INT_ENA (BIT(5)) -#define MCPWM_TIMER2_TEZ_INT_ENA_M (BIT(5)) -#define MCPWM_TIMER2_TEZ_INT_ENA_V 0x1 -#define MCPWM_TIMER2_TEZ_INT_ENA_S 5 -/* MCPWM_TIMER1_TEZ_INT_ENA : R/W ;bitpos:[4] ;default: 1'h0 ; */ -/*description: The enable bit for interrupt triggered by a PWM timer 1 TEZ event*/ -#define MCPWM_TIMER1_TEZ_INT_ENA (BIT(4)) -#define MCPWM_TIMER1_TEZ_INT_ENA_M (BIT(4)) -#define MCPWM_TIMER1_TEZ_INT_ENA_V 0x1 -#define MCPWM_TIMER1_TEZ_INT_ENA_S 4 -/* MCPWM_TIMER0_TEZ_INT_ENA : R/W ;bitpos:[3] ;default: 1'h0 ; */ -/*description: The enable bit for interrupt triggered by a PWM timer 0 TEZ event*/ -#define MCPWM_TIMER0_TEZ_INT_ENA (BIT(3)) -#define MCPWM_TIMER0_TEZ_INT_ENA_M (BIT(3)) -#define MCPWM_TIMER0_TEZ_INT_ENA_V 0x1 -#define MCPWM_TIMER0_TEZ_INT_ENA_S 3 -/* MCPWM_TIMER2_STOP_INT_ENA : R/W ;bitpos:[2] ;default: 1'h0 ; */ -/*description: The enable bit for interrupt triggered when timer 2 stops*/ -#define MCPWM_TIMER2_STOP_INT_ENA (BIT(2)) -#define MCPWM_TIMER2_STOP_INT_ENA_M (BIT(2)) -#define MCPWM_TIMER2_STOP_INT_ENA_V 0x1 -#define MCPWM_TIMER2_STOP_INT_ENA_S 2 -/* MCPWM_TIMER1_STOP_INT_ENA : R/W ;bitpos:[1] ;default: 1'h0 ; */ -/*description: The enable bit for interrupt triggered when timer 1 stops*/ -#define MCPWM_TIMER1_STOP_INT_ENA (BIT(1)) -#define MCPWM_TIMER1_STOP_INT_ENA_M (BIT(1)) -#define MCPWM_TIMER1_STOP_INT_ENA_V 0x1 -#define MCPWM_TIMER1_STOP_INT_ENA_S 1 -/* MCPWM_TIMER0_STOP_INT_ENA : R/W ;bitpos:[0] ;default: 1'h0 ; */ -/*description: The enable bit for interrupt triggered when timer 0 stops*/ -#define MCPWM_TIMER0_STOP_INT_ENA (BIT(0)) -#define MCPWM_TIMER0_STOP_INT_ENA_M (BIT(0)) -#define MCPWM_TIMER0_STOP_INT_ENA_V 0x1 +/** MCPWM_INT_ENA_REG register + * Interrupt enable bits + */ +#define MCPWM_INT_ENA_REG(i) (DR_REG_MCPWM_BASE(i) + 0x110) +/** MCPWM_TIMER0_STOP_INT_ENA : R/W; bitpos: [0]; default: 0; + * The enable bit for the interrupt triggered when the timer 0 stops. + */ +#define MCPWM_TIMER0_STOP_INT_ENA (BIT(0)) +#define MCPWM_TIMER0_STOP_INT_ENA_M (MCPWM_TIMER0_STOP_INT_ENA_V << MCPWM_TIMER0_STOP_INT_ENA_S) +#define MCPWM_TIMER0_STOP_INT_ENA_V 0x00000001U #define MCPWM_TIMER0_STOP_INT_ENA_S 0 +/** MCPWM_TIMER1_STOP_INT_ENA : R/W; bitpos: [1]; default: 0; + * The enable bit for the interrupt triggered when the timer 1 stops. + */ +#define MCPWM_TIMER1_STOP_INT_ENA (BIT(1)) +#define MCPWM_TIMER1_STOP_INT_ENA_M (MCPWM_TIMER1_STOP_INT_ENA_V << MCPWM_TIMER1_STOP_INT_ENA_S) +#define MCPWM_TIMER1_STOP_INT_ENA_V 0x00000001U +#define MCPWM_TIMER1_STOP_INT_ENA_S 1 +/** MCPWM_TIMER2_STOP_INT_ENA : R/W; bitpos: [2]; default: 0; + * The enable bit for the interrupt triggered when the timer 2 stops. + */ +#define MCPWM_TIMER2_STOP_INT_ENA (BIT(2)) +#define MCPWM_TIMER2_STOP_INT_ENA_M (MCPWM_TIMER2_STOP_INT_ENA_V << MCPWM_TIMER2_STOP_INT_ENA_S) +#define MCPWM_TIMER2_STOP_INT_ENA_V 0x00000001U +#define MCPWM_TIMER2_STOP_INT_ENA_S 2 +/** MCPWM_TIMER0_TEZ_INT_ENA : R/W; bitpos: [3]; default: 0; + * The enable bit for the interrupt triggered by a PWM timer 0 TEZ event. + */ +#define MCPWM_TIMER0_TEZ_INT_ENA (BIT(3)) +#define MCPWM_TIMER0_TEZ_INT_ENA_M (MCPWM_TIMER0_TEZ_INT_ENA_V << MCPWM_TIMER0_TEZ_INT_ENA_S) +#define MCPWM_TIMER0_TEZ_INT_ENA_V 0x00000001U +#define MCPWM_TIMER0_TEZ_INT_ENA_S 3 +/** MCPWM_TIMER1_TEZ_INT_ENA : R/W; bitpos: [4]; default: 0; + * The enable bit for the interrupt triggered by a PWM timer 1 TEZ event. + */ +#define MCPWM_TIMER1_TEZ_INT_ENA (BIT(4)) +#define MCPWM_TIMER1_TEZ_INT_ENA_M (MCPWM_TIMER1_TEZ_INT_ENA_V << MCPWM_TIMER1_TEZ_INT_ENA_S) +#define MCPWM_TIMER1_TEZ_INT_ENA_V 0x00000001U +#define MCPWM_TIMER1_TEZ_INT_ENA_S 4 +/** MCPWM_TIMER2_TEZ_INT_ENA : R/W; bitpos: [5]; default: 0; + * The enable bit for the interrupt triggered by a PWM timer 2 TEZ event. + */ +#define MCPWM_TIMER2_TEZ_INT_ENA (BIT(5)) +#define MCPWM_TIMER2_TEZ_INT_ENA_M (MCPWM_TIMER2_TEZ_INT_ENA_V << MCPWM_TIMER2_TEZ_INT_ENA_S) +#define MCPWM_TIMER2_TEZ_INT_ENA_V 0x00000001U +#define MCPWM_TIMER2_TEZ_INT_ENA_S 5 +/** MCPWM_TIMER0_TEP_INT_ENA : R/W; bitpos: [6]; default: 0; + * The enable bit for the interrupt triggered by a PWM timer 0 TEP event. + */ +#define MCPWM_TIMER0_TEP_INT_ENA (BIT(6)) +#define MCPWM_TIMER0_TEP_INT_ENA_M (MCPWM_TIMER0_TEP_INT_ENA_V << MCPWM_TIMER0_TEP_INT_ENA_S) +#define MCPWM_TIMER0_TEP_INT_ENA_V 0x00000001U +#define MCPWM_TIMER0_TEP_INT_ENA_S 6 +/** MCPWM_TIMER1_TEP_INT_ENA : R/W; bitpos: [7]; default: 0; + * The enable bit for the interrupt triggered by a PWM timer 1 TEP event. + */ +#define MCPWM_TIMER1_TEP_INT_ENA (BIT(7)) +#define MCPWM_TIMER1_TEP_INT_ENA_M (MCPWM_TIMER1_TEP_INT_ENA_V << MCPWM_TIMER1_TEP_INT_ENA_S) +#define MCPWM_TIMER1_TEP_INT_ENA_V 0x00000001U +#define MCPWM_TIMER1_TEP_INT_ENA_S 7 +/** MCPWM_TIMER2_TEP_INT_ENA : R/W; bitpos: [8]; default: 0; + * The enable bit for the interrupt triggered by a PWM timer 2 TEP event. + */ +#define MCPWM_TIMER2_TEP_INT_ENA (BIT(8)) +#define MCPWM_TIMER2_TEP_INT_ENA_M (MCPWM_TIMER2_TEP_INT_ENA_V << MCPWM_TIMER2_TEP_INT_ENA_S) +#define MCPWM_TIMER2_TEP_INT_ENA_V 0x00000001U +#define MCPWM_TIMER2_TEP_INT_ENA_S 8 +/** MCPWM_FAULT0_INT_ENA : R/W; bitpos: [9]; default: 0; + * The enable bit for the interrupt triggered when fault_event0 starts. + */ +#define MCPWM_FAULT0_INT_ENA (BIT(9)) +#define MCPWM_FAULT0_INT_ENA_M (MCPWM_FAULT0_INT_ENA_V << MCPWM_FAULT0_INT_ENA_S) +#define MCPWM_FAULT0_INT_ENA_V 0x00000001U +#define MCPWM_FAULT0_INT_ENA_S 9 +/** MCPWM_FAULT1_INT_ENA : R/W; bitpos: [10]; default: 0; + * The enable bit for the interrupt triggered when fault_event1 starts. + */ +#define MCPWM_FAULT1_INT_ENA (BIT(10)) +#define MCPWM_FAULT1_INT_ENA_M (MCPWM_FAULT1_INT_ENA_V << MCPWM_FAULT1_INT_ENA_S) +#define MCPWM_FAULT1_INT_ENA_V 0x00000001U +#define MCPWM_FAULT1_INT_ENA_S 10 +/** MCPWM_FAULT2_INT_ENA : R/W; bitpos: [11]; default: 0; + * The enable bit for the interrupt triggered when fault_event2 starts. + */ +#define MCPWM_FAULT2_INT_ENA (BIT(11)) +#define MCPWM_FAULT2_INT_ENA_M (MCPWM_FAULT2_INT_ENA_V << MCPWM_FAULT2_INT_ENA_S) +#define MCPWM_FAULT2_INT_ENA_V 0x00000001U +#define MCPWM_FAULT2_INT_ENA_S 11 +/** MCPWM_FAULT0_CLR_INT_ENA : R/W; bitpos: [12]; default: 0; + * The enable bit for the interrupt triggered when fault_event0 ends. + */ +#define MCPWM_FAULT0_CLR_INT_ENA (BIT(12)) +#define MCPWM_FAULT0_CLR_INT_ENA_M (MCPWM_FAULT0_CLR_INT_ENA_V << MCPWM_FAULT0_CLR_INT_ENA_S) +#define MCPWM_FAULT0_CLR_INT_ENA_V 0x00000001U +#define MCPWM_FAULT0_CLR_INT_ENA_S 12 +/** MCPWM_FAULT1_CLR_INT_ENA : R/W; bitpos: [13]; default: 0; + * The enable bit for the interrupt triggered when fault_event1 ends. + */ +#define MCPWM_FAULT1_CLR_INT_ENA (BIT(13)) +#define MCPWM_FAULT1_CLR_INT_ENA_M (MCPWM_FAULT1_CLR_INT_ENA_V << MCPWM_FAULT1_CLR_INT_ENA_S) +#define MCPWM_FAULT1_CLR_INT_ENA_V 0x00000001U +#define MCPWM_FAULT1_CLR_INT_ENA_S 13 +/** MCPWM_FAULT2_CLR_INT_ENA : R/W; bitpos: [14]; default: 0; + * The enable bit for the interrupt triggered when fault_event2 ends. + */ +#define MCPWM_FAULT2_CLR_INT_ENA (BIT(14)) +#define MCPWM_FAULT2_CLR_INT_ENA_M (MCPWM_FAULT2_CLR_INT_ENA_V << MCPWM_FAULT2_CLR_INT_ENA_S) +#define MCPWM_FAULT2_CLR_INT_ENA_V 0x00000001U +#define MCPWM_FAULT2_CLR_INT_ENA_S 14 +/** MCPWM_OP0_TEA_INT_ENA : R/W; bitpos: [15]; default: 0; + * The enable bit for the interrupt triggered by a PWM operator 0 TEA event + */ +#define MCPWM_OP0_TEA_INT_ENA (BIT(15)) +#define MCPWM_OP0_TEA_INT_ENA_M (MCPWM_OP0_TEA_INT_ENA_V << MCPWM_OP0_TEA_INT_ENA_S) +#define MCPWM_OP0_TEA_INT_ENA_V 0x00000001U +#define MCPWM_OP0_TEA_INT_ENA_S 15 +/** MCPWM_OP1_TEA_INT_ENA : R/W; bitpos: [16]; default: 0; + * The enable bit for the interrupt triggered by a PWM operator 1 TEA event + */ +#define MCPWM_OP1_TEA_INT_ENA (BIT(16)) +#define MCPWM_OP1_TEA_INT_ENA_M (MCPWM_OP1_TEA_INT_ENA_V << MCPWM_OP1_TEA_INT_ENA_S) +#define MCPWM_OP1_TEA_INT_ENA_V 0x00000001U +#define MCPWM_OP1_TEA_INT_ENA_S 16 +/** MCPWM_OP2_TEA_INT_ENA : R/W; bitpos: [17]; default: 0; + * The enable bit for the interrupt triggered by a PWM operator 2 TEA event + */ +#define MCPWM_OP2_TEA_INT_ENA (BIT(17)) +#define MCPWM_OP2_TEA_INT_ENA_M (MCPWM_OP2_TEA_INT_ENA_V << MCPWM_OP2_TEA_INT_ENA_S) +#define MCPWM_OP2_TEA_INT_ENA_V 0x00000001U +#define MCPWM_OP2_TEA_INT_ENA_S 17 +/** MCPWM_OP0_TEB_INT_ENA : R/W; bitpos: [18]; default: 0; + * The enable bit for the interrupt triggered by a PWM operator 0 TEB event + */ +#define MCPWM_OP0_TEB_INT_ENA (BIT(18)) +#define MCPWM_OP0_TEB_INT_ENA_M (MCPWM_OP0_TEB_INT_ENA_V << MCPWM_OP0_TEB_INT_ENA_S) +#define MCPWM_OP0_TEB_INT_ENA_V 0x00000001U +#define MCPWM_OP0_TEB_INT_ENA_S 18 +/** MCPWM_OP1_TEB_INT_ENA : R/W; bitpos: [19]; default: 0; + * The enable bit for the interrupt triggered by a PWM operator 1 TEB event + */ +#define MCPWM_OP1_TEB_INT_ENA (BIT(19)) +#define MCPWM_OP1_TEB_INT_ENA_M (MCPWM_OP1_TEB_INT_ENA_V << MCPWM_OP1_TEB_INT_ENA_S) +#define MCPWM_OP1_TEB_INT_ENA_V 0x00000001U +#define MCPWM_OP1_TEB_INT_ENA_S 19 +/** MCPWM_OP2_TEB_INT_ENA : R/W; bitpos: [20]; default: 0; + * The enable bit for the interrupt triggered by a PWM operator 2 TEB event + */ +#define MCPWM_OP2_TEB_INT_ENA (BIT(20)) +#define MCPWM_OP2_TEB_INT_ENA_M (MCPWM_OP2_TEB_INT_ENA_V << MCPWM_OP2_TEB_INT_ENA_S) +#define MCPWM_OP2_TEB_INT_ENA_V 0x00000001U +#define MCPWM_OP2_TEB_INT_ENA_S 20 +/** MCPWM_FH0_CBC_INT_ENA : R/W; bitpos: [21]; default: 0; + * The enable bit for the interrupt triggered by a cycle-by-cycle mode action on PWM0. + */ +#define MCPWM_FH0_CBC_INT_ENA (BIT(21)) +#define MCPWM_FH0_CBC_INT_ENA_M (MCPWM_FH0_CBC_INT_ENA_V << MCPWM_FH0_CBC_INT_ENA_S) +#define MCPWM_FH0_CBC_INT_ENA_V 0x00000001U +#define MCPWM_FH0_CBC_INT_ENA_S 21 +/** MCPWM_FH1_CBC_INT_ENA : R/W; bitpos: [22]; default: 0; + * The enable bit for the interrupt triggered by a cycle-by-cycle mode action on PWM1. + */ +#define MCPWM_FH1_CBC_INT_ENA (BIT(22)) +#define MCPWM_FH1_CBC_INT_ENA_M (MCPWM_FH1_CBC_INT_ENA_V << MCPWM_FH1_CBC_INT_ENA_S) +#define MCPWM_FH1_CBC_INT_ENA_V 0x00000001U +#define MCPWM_FH1_CBC_INT_ENA_S 22 +/** MCPWM_FH2_CBC_INT_ENA : R/W; bitpos: [23]; default: 0; + * The enable bit for the interrupt triggered by a cycle-by-cycle mode action on PWM2. + */ +#define MCPWM_FH2_CBC_INT_ENA (BIT(23)) +#define MCPWM_FH2_CBC_INT_ENA_M (MCPWM_FH2_CBC_INT_ENA_V << MCPWM_FH2_CBC_INT_ENA_S) +#define MCPWM_FH2_CBC_INT_ENA_V 0x00000001U +#define MCPWM_FH2_CBC_INT_ENA_S 23 +/** MCPWM_FH0_OST_INT_ENA : R/W; bitpos: [24]; default: 0; + * The enable bit for the interrupt triggered by a one-shot mode action on PWM0. + */ +#define MCPWM_FH0_OST_INT_ENA (BIT(24)) +#define MCPWM_FH0_OST_INT_ENA_M (MCPWM_FH0_OST_INT_ENA_V << MCPWM_FH0_OST_INT_ENA_S) +#define MCPWM_FH0_OST_INT_ENA_V 0x00000001U +#define MCPWM_FH0_OST_INT_ENA_S 24 +/** MCPWM_FH1_OST_INT_ENA : R/W; bitpos: [25]; default: 0; + * The enable bit for the interrupt triggered by a one-shot mode action on PWM1. + */ +#define MCPWM_FH1_OST_INT_ENA (BIT(25)) +#define MCPWM_FH1_OST_INT_ENA_M (MCPWM_FH1_OST_INT_ENA_V << MCPWM_FH1_OST_INT_ENA_S) +#define MCPWM_FH1_OST_INT_ENA_V 0x00000001U +#define MCPWM_FH1_OST_INT_ENA_S 25 +/** MCPWM_FH2_OST_INT_ENA : R/W; bitpos: [26]; default: 0; + * The enable bit for the interrupt triggered by a one-shot mode action on PWM2. + */ +#define MCPWM_FH2_OST_INT_ENA (BIT(26)) +#define MCPWM_FH2_OST_INT_ENA_M (MCPWM_FH2_OST_INT_ENA_V << MCPWM_FH2_OST_INT_ENA_S) +#define MCPWM_FH2_OST_INT_ENA_V 0x00000001U +#define MCPWM_FH2_OST_INT_ENA_S 26 +/** MCPWM_CAP0_INT_ENA : R/W; bitpos: [27]; default: 0; + * The enable bit for the interrupt triggered by capture on channel 0. + */ +#define MCPWM_CAP0_INT_ENA (BIT(27)) +#define MCPWM_CAP0_INT_ENA_M (MCPWM_CAP0_INT_ENA_V << MCPWM_CAP0_INT_ENA_S) +#define MCPWM_CAP0_INT_ENA_V 0x00000001U +#define MCPWM_CAP0_INT_ENA_S 27 +/** MCPWM_CAP1_INT_ENA : R/W; bitpos: [28]; default: 0; + * The enable bit for the interrupt triggered by capture on channel 1. + */ +#define MCPWM_CAP1_INT_ENA (BIT(28)) +#define MCPWM_CAP1_INT_ENA_M (MCPWM_CAP1_INT_ENA_V << MCPWM_CAP1_INT_ENA_S) +#define MCPWM_CAP1_INT_ENA_V 0x00000001U +#define MCPWM_CAP1_INT_ENA_S 28 +/** MCPWM_CAP2_INT_ENA : R/W; bitpos: [29]; default: 0; + * The enable bit for the interrupt triggered by capture on channel 2. + */ +#define MCPWM_CAP2_INT_ENA (BIT(29)) +#define MCPWM_CAP2_INT_ENA_M (MCPWM_CAP2_INT_ENA_V << MCPWM_CAP2_INT_ENA_S) +#define MCPWM_CAP2_INT_ENA_V 0x00000001U +#define MCPWM_CAP2_INT_ENA_S 29 -#define MCMCPWM_INT_RAW_MCPWM_REG(i) (REG_MCPWM_BASE(i) + 0x0114) -/* MCPWM_CAP2_INT_RAW : RO ;bitpos:[29] ;default: 1'd0 ; */ -/*description: The raw status bit for interrupt triggered by captureon channel 2*/ -#define MCPWM_CAP2_INT_RAW (BIT(29)) -#define MCPWM_CAP2_INT_RAW_M (BIT(29)) -#define MCPWM_CAP2_INT_RAW_V 0x1 -#define MCPWM_CAP2_INT_RAW_S 29 -/* MCPWM_CAP1_INT_RAW : RO ;bitpos:[28] ;default: 1'd0 ; */ -/*description: The raw status bit for interrupt triggered by captureon channel 1*/ -#define MCPWM_CAP1_INT_RAW (BIT(28)) -#define MCPWM_CAP1_INT_RAW_M (BIT(28)) -#define MCPWM_CAP1_INT_RAW_V 0x1 -#define MCPWM_CAP1_INT_RAW_S 28 -/* MCPWM_CAP0_INT_RAW : RO ;bitpos:[27] ;default: 1'd0 ; */ -/*description: The raw status bit for interrupt triggered by captureon channel 0*/ -#define MCPWM_CAP0_INT_RAW (BIT(27)) -#define MCPWM_CAP0_INT_RAW_M (BIT(27)) -#define MCPWM_CAP0_INT_RAW_V 0x1 -#define MCPWM_CAP0_INT_RAW_S 27 -/* MCPWM_FH2_OST_INT_RAW : RO ;bitpos:[26] ;default: 1'd0 ; */ -/*description: The raw status bit for interrupt triggered by an one-shot mode action on PWM2*/ -#define MCPWM_FH2_OST_INT_RAW (BIT(26)) -#define MCPWM_FH2_OST_INT_RAW_M (BIT(26)) -#define MCPWM_FH2_OST_INT_RAW_V 0x1 -#define MCPWM_FH2_OST_INT_RAW_S 26 -/* MCPWM_FH1_OST_INT_RAW : RO ;bitpos:[25] ;default: 1'd0 ; */ -/*description: The raw status bit for interrupt triggered by an one-shot mode action on PWM0*/ -#define MCPWM_FH1_OST_INT_RAW (BIT(25)) -#define MCPWM_FH1_OST_INT_RAW_M (BIT(25)) -#define MCPWM_FH1_OST_INT_RAW_V 0x1 -#define MCPWM_FH1_OST_INT_RAW_S 25 -/* MCPWM_FH0_OST_INT_RAW : RO ;bitpos:[24] ;default: 1'd0 ; */ -/*description: The raw status bit for interrupt triggered by an one-shot mode action on PWM0*/ -#define MCPWM_FH0_OST_INT_RAW (BIT(24)) -#define MCPWM_FH0_OST_INT_RAW_M (BIT(24)) -#define MCPWM_FH0_OST_INT_RAW_V 0x1 -#define MCPWM_FH0_OST_INT_RAW_S 24 -/* MCPWM_FH2_CBC_INT_RAW : RO ;bitpos:[23] ;default: 1'd0 ; */ -/*description: The raw status bit for interrupt triggered by an cycle-by-cycle - mode action on PWM2*/ -#define MCPWM_FH2_CBC_INT_RAW (BIT(23)) -#define MCPWM_FH2_CBC_INT_RAW_M (BIT(23)) -#define MCPWM_FH2_CBC_INT_RAW_V 0x1 -#define MCPWM_FH2_CBC_INT_RAW_S 23 -/* MCPWM_FH1_CBC_INT_RAW : RO ;bitpos:[22] ;default: 1'd0 ; */ -/*description: The raw status bit for interrupt triggered by an cycle-by-cycle - mode action on PWM1*/ -#define MCPWM_FH1_CBC_INT_RAW (BIT(22)) -#define MCPWM_FH1_CBC_INT_RAW_M (BIT(22)) -#define MCPWM_FH1_CBC_INT_RAW_V 0x1 -#define MCPWM_FH1_CBC_INT_RAW_S 22 -/* MCPWM_FH0_CBC_INT_RAW : RO ;bitpos:[21] ;default: 1'd0 ; */ -/*description: The raw status bit for interrupt triggered by an cycle-by-cycle - mode action on PWM0*/ -#define MCPWM_FH0_CBC_INT_RAW (BIT(21)) -#define MCPWM_FH0_CBC_INT_RAW_M (BIT(21)) -#define MCPWM_FH0_CBC_INT_RAW_V 0x1 -#define MCPWM_FH0_CBC_INT_RAW_S 21 -/* MCPWM_OP2_TEB_INT_RAW : RO ;bitpos:[20] ;default: 1'd0 ; */ -/*description: The raw status bit for interrupt triggered by a PWM operator 2 TEB event*/ -#define MCPWM_OP2_TEB_INT_RAW (BIT(20)) -#define MCPWM_OP2_TEB_INT_RAW_M (BIT(20)) -#define MCPWM_OP2_TEB_INT_RAW_V 0x1 -#define MCPWM_OP2_TEB_INT_RAW_S 20 -/* MCPWM_OP1_TEB_INT_RAW : RO ;bitpos:[19] ;default: 1'd0 ; */ -/*description: The raw status bit for interrupt triggered by a PWM operator 1 TEB event*/ -#define MCPWM_OP1_TEB_INT_RAW (BIT(19)) -#define MCPWM_OP1_TEB_INT_RAW_M (BIT(19)) -#define MCPWM_OP1_TEB_INT_RAW_V 0x1 -#define MCPWM_OP1_TEB_INT_RAW_S 19 -/* MCPWM_OP0_TEB_INT_RAW : RO ;bitpos:[18] ;default: 1'd0 ; */ -/*description: The raw status bit for interrupt triggered by a PWM operator 0 TEB event*/ -#define MCPWM_OP0_TEB_INT_RAW (BIT(18)) -#define MCPWM_OP0_TEB_INT_RAW_M (BIT(18)) -#define MCPWM_OP0_TEB_INT_RAW_V 0x1 -#define MCPWM_OP0_TEB_INT_RAW_S 18 -/* MCPWM_OP2_TEA_INT_RAW : RO ;bitpos:[17] ;default: 1'd0 ; */ -/*description: The raw status bit for interrupt triggered by a PWM operator 2 TEA event*/ -#define MCPWM_OP2_TEA_INT_RAW (BIT(17)) -#define MCPWM_OP2_TEA_INT_RAW_M (BIT(17)) -#define MCPWM_OP2_TEA_INT_RAW_V 0x1 -#define MCPWM_OP2_TEA_INT_RAW_S 17 -/* MCPWM_OP1_TEA_INT_RAW : RO ;bitpos:[16] ;default: 1'd0 ; */ -/*description: The raw status bit for interrupt triggered by a PWM operator 1 TEA event*/ -#define MCPWM_OP1_TEA_INT_RAW (BIT(16)) -#define MCPWM_OP1_TEA_INT_RAW_M (BIT(16)) -#define MCPWM_OP1_TEA_INT_RAW_V 0x1 -#define MCPWM_OP1_TEA_INT_RAW_S 16 -/* MCPWM_OP0_TEA_INT_RAW : RO ;bitpos:[15] ;default: 1'd0 ; */ -/*description: The raw status bit for interrupt triggered by a PWM operator 0 TEA event*/ -#define MCPWM_OP0_TEA_INT_RAW (BIT(15)) -#define MCPWM_OP0_TEA_INT_RAW_M (BIT(15)) -#define MCPWM_OP0_TEA_INT_RAW_V 0x1 -#define MCPWM_OP0_TEA_INT_RAW_S 15 -/* MCPWM_FAULT2_CLR_INT_RAW : RO ;bitpos:[14] ;default: 1'd0 ; */ -/*description: The raw status bit for interrupt triggered when event_f2 ends*/ -#define MCPWM_FAULT2_CLR_INT_RAW (BIT(14)) -#define MCPWM_FAULT2_CLR_INT_RAW_M (BIT(14)) -#define MCPWM_FAULT2_CLR_INT_RAW_V 0x1 -#define MCPWM_FAULT2_CLR_INT_RAW_S 14 -/* MCPWM_FAULT1_CLR_INT_RAW : RO ;bitpos:[13] ;default: 1'd0 ; */ -/*description: The raw status bit for interrupt triggered when event_f1 ends*/ -#define MCPWM_FAULT1_CLR_INT_RAW (BIT(13)) -#define MCPWM_FAULT1_CLR_INT_RAW_M (BIT(13)) -#define MCPWM_FAULT1_CLR_INT_RAW_V 0x1 -#define MCPWM_FAULT1_CLR_INT_RAW_S 13 -/* MCPWM_FAULT0_CLR_INT_RAW : RO ;bitpos:[12] ;default: 1'd0 ; */ -/*description: The raw status bit for interrupt triggered when event_f0 ends*/ -#define MCPWM_FAULT0_CLR_INT_RAW (BIT(12)) -#define MCPWM_FAULT0_CLR_INT_RAW_M (BIT(12)) -#define MCPWM_FAULT0_CLR_INT_RAW_V 0x1 -#define MCPWM_FAULT0_CLR_INT_RAW_S 12 -/* MCPWM_FAULT2_INT_RAW : RO ;bitpos:[11] ;default: 1'd0 ; */ -/*description: The raw status bit for interrupt triggered when event_f2 starts*/ -#define MCPWM_FAULT2_INT_RAW (BIT(11)) -#define MCPWM_FAULT2_INT_RAW_M (BIT(11)) -#define MCPWM_FAULT2_INT_RAW_V 0x1 -#define MCPWM_FAULT2_INT_RAW_S 11 -/* MCPWM_FAULT1_INT_RAW : RO ;bitpos:[10] ;default: 1'd0 ; */ -/*description: The raw status bit for interrupt triggered when event_f1 starts*/ -#define MCPWM_FAULT1_INT_RAW (BIT(10)) -#define MCPWM_FAULT1_INT_RAW_M (BIT(10)) -#define MCPWM_FAULT1_INT_RAW_V 0x1 -#define MCPWM_FAULT1_INT_RAW_S 10 -/* MCPWM_FAULT0_INT_RAW : RO ;bitpos:[9] ;default: 1'd0 ; */ -/*description: The raw status bit for interrupt triggered when event_f0 starts*/ -#define MCPWM_FAULT0_INT_RAW (BIT(9)) -#define MCPWM_FAULT0_INT_RAW_M (BIT(9)) -#define MCPWM_FAULT0_INT_RAW_V 0x1 -#define MCPWM_FAULT0_INT_RAW_S 9 -/* MCPWM_TIMER2_TEP_INT_RAW : RO ;bitpos:[8] ;default: 1'h0 ; */ -/*description: The raw status bit for interrupt triggered by a PWM timer 2 TEP event*/ -#define MCPWM_TIMER2_TEP_INT_RAW (BIT(8)) -#define MCPWM_TIMER2_TEP_INT_RAW_M (BIT(8)) -#define MCPWM_TIMER2_TEP_INT_RAW_V 0x1 -#define MCPWM_TIMER2_TEP_INT_RAW_S 8 -/* MCPWM_TIMER1_TEP_INT_RAW : RO ;bitpos:[7] ;default: 1'h0 ; */ -/*description: The raw status bit for interrupt triggered by a PWM timer 1 TEP event*/ -#define MCPWM_TIMER1_TEP_INT_RAW (BIT(7)) -#define MCPWM_TIMER1_TEP_INT_RAW_M (BIT(7)) -#define MCPWM_TIMER1_TEP_INT_RAW_V 0x1 -#define MCPWM_TIMER1_TEP_INT_RAW_S 7 -/* MCPWM_TIMER0_TEP_INT_RAW : RO ;bitpos:[6] ;default: 1'h0 ; */ -/*description: The raw status bit for interrupt triggered by a PWM timer 0 TEP event*/ -#define MCPWM_TIMER0_TEP_INT_RAW (BIT(6)) -#define MCPWM_TIMER0_TEP_INT_RAW_M (BIT(6)) -#define MCPWM_TIMER0_TEP_INT_RAW_V 0x1 -#define MCPWM_TIMER0_TEP_INT_RAW_S 6 -/* MCPWM_TIMER2_TEZ_INT_RAW : RO ;bitpos:[5] ;default: 1'h0 ; */ -/*description: The raw status bit for interrupt triggered by a PWM timer 2 TEZ event*/ -#define MCPWM_TIMER2_TEZ_INT_RAW (BIT(5)) -#define MCPWM_TIMER2_TEZ_INT_RAW_M (BIT(5)) -#define MCPWM_TIMER2_TEZ_INT_RAW_V 0x1 -#define MCPWM_TIMER2_TEZ_INT_RAW_S 5 -/* MCPWM_TIMER1_TEZ_INT_RAW : RO ;bitpos:[4] ;default: 1'h0 ; */ -/*description: The raw status bit for interrupt triggered by a PWM timer 1 TEZ event*/ -#define MCPWM_TIMER1_TEZ_INT_RAW (BIT(4)) -#define MCPWM_TIMER1_TEZ_INT_RAW_M (BIT(4)) -#define MCPWM_TIMER1_TEZ_INT_RAW_V 0x1 -#define MCPWM_TIMER1_TEZ_INT_RAW_S 4 -/* MCPWM_TIMER0_TEZ_INT_RAW : RO ;bitpos:[3] ;default: 1'h0 ; */ -/*description: The raw status bit for interrupt triggered by a PWM timer 0 TEZ event*/ -#define MCPWM_TIMER0_TEZ_INT_RAW (BIT(3)) -#define MCPWM_TIMER0_TEZ_INT_RAW_M (BIT(3)) -#define MCPWM_TIMER0_TEZ_INT_RAW_V 0x1 -#define MCPWM_TIMER0_TEZ_INT_RAW_S 3 -/* MCPWM_TIMER2_STOP_INT_RAW : RO ;bitpos:[2] ;default: 1'h0 ; */ -/*description: The raw status bit for interrupt triggered when timer 2 stops*/ -#define MCPWM_TIMER2_STOP_INT_RAW (BIT(2)) -#define MCPWM_TIMER2_STOP_INT_RAW_M (BIT(2)) -#define MCPWM_TIMER2_STOP_INT_RAW_V 0x1 -#define MCPWM_TIMER2_STOP_INT_RAW_S 2 -/* MCPWM_TIMER1_STOP_INT_RAW : RO ;bitpos:[1] ;default: 1'h0 ; */ -/*description: The raw status bit for interrupt triggered when timer 1 stops*/ -#define MCPWM_TIMER1_STOP_INT_RAW (BIT(1)) -#define MCPWM_TIMER1_STOP_INT_RAW_M (BIT(1)) -#define MCPWM_TIMER1_STOP_INT_RAW_V 0x1 -#define MCPWM_TIMER1_STOP_INT_RAW_S 1 -/* MCPWM_TIMER0_STOP_INT_RAW : RO ;bitpos:[0] ;default: 1'h0 ; */ -/*description: The raw status bit for interrupt triggered when timer 0 stops*/ -#define MCPWM_TIMER0_STOP_INT_RAW (BIT(0)) -#define MCPWM_TIMER0_STOP_INT_RAW_M (BIT(0)) -#define MCPWM_TIMER0_STOP_INT_RAW_V 0x1 +/** MCPWM_INT_RAW_REG register + * Raw interrupt status + */ +#define MCPWM_INT_RAW_REG(i) (DR_REG_MCPWM_BASE(i) + 0x114) +/** MCPWM_TIMER0_STOP_INT_RAW : R/WTC/SS; bitpos: [0]; default: 0; + * The raw status bit for the interrupt triggered when the timer 0 stops. + */ +#define MCPWM_TIMER0_STOP_INT_RAW (BIT(0)) +#define MCPWM_TIMER0_STOP_INT_RAW_M (MCPWM_TIMER0_STOP_INT_RAW_V << MCPWM_TIMER0_STOP_INT_RAW_S) +#define MCPWM_TIMER0_STOP_INT_RAW_V 0x00000001U #define MCPWM_TIMER0_STOP_INT_RAW_S 0 +/** MCPWM_TIMER1_STOP_INT_RAW : R/WTC/SS; bitpos: [1]; default: 0; + * The raw status bit for the interrupt triggered when the timer 1 stops. + */ +#define MCPWM_TIMER1_STOP_INT_RAW (BIT(1)) +#define MCPWM_TIMER1_STOP_INT_RAW_M (MCPWM_TIMER1_STOP_INT_RAW_V << MCPWM_TIMER1_STOP_INT_RAW_S) +#define MCPWM_TIMER1_STOP_INT_RAW_V 0x00000001U +#define MCPWM_TIMER1_STOP_INT_RAW_S 1 +/** MCPWM_TIMER2_STOP_INT_RAW : R/WTC/SS; bitpos: [2]; default: 0; + * The raw status bit for the interrupt triggered when the timer 2 stops. + */ +#define MCPWM_TIMER2_STOP_INT_RAW (BIT(2)) +#define MCPWM_TIMER2_STOP_INT_RAW_M (MCPWM_TIMER2_STOP_INT_RAW_V << MCPWM_TIMER2_STOP_INT_RAW_S) +#define MCPWM_TIMER2_STOP_INT_RAW_V 0x00000001U +#define MCPWM_TIMER2_STOP_INT_RAW_S 2 +/** MCPWM_TIMER0_TEZ_INT_RAW : R/WTC/SS; bitpos: [3]; default: 0; + * The raw status bit for the interrupt triggered by a PWM timer 0 TEZ event. + */ +#define MCPWM_TIMER0_TEZ_INT_RAW (BIT(3)) +#define MCPWM_TIMER0_TEZ_INT_RAW_M (MCPWM_TIMER0_TEZ_INT_RAW_V << MCPWM_TIMER0_TEZ_INT_RAW_S) +#define MCPWM_TIMER0_TEZ_INT_RAW_V 0x00000001U +#define MCPWM_TIMER0_TEZ_INT_RAW_S 3 +/** MCPWM_TIMER1_TEZ_INT_RAW : R/WTC/SS; bitpos: [4]; default: 0; + * The raw status bit for the interrupt triggered by a PWM timer 1 TEZ event. + */ +#define MCPWM_TIMER1_TEZ_INT_RAW (BIT(4)) +#define MCPWM_TIMER1_TEZ_INT_RAW_M (MCPWM_TIMER1_TEZ_INT_RAW_V << MCPWM_TIMER1_TEZ_INT_RAW_S) +#define MCPWM_TIMER1_TEZ_INT_RAW_V 0x00000001U +#define MCPWM_TIMER1_TEZ_INT_RAW_S 4 +/** MCPWM_TIMER2_TEZ_INT_RAW : R/WTC/SS; bitpos: [5]; default: 0; + * The raw status bit for the interrupt triggered by a PWM timer 2 TEZ event. + */ +#define MCPWM_TIMER2_TEZ_INT_RAW (BIT(5)) +#define MCPWM_TIMER2_TEZ_INT_RAW_M (MCPWM_TIMER2_TEZ_INT_RAW_V << MCPWM_TIMER2_TEZ_INT_RAW_S) +#define MCPWM_TIMER2_TEZ_INT_RAW_V 0x00000001U +#define MCPWM_TIMER2_TEZ_INT_RAW_S 5 +/** MCPWM_TIMER0_TEP_INT_RAW : R/WTC/SS; bitpos: [6]; default: 0; + * The raw status bit for the interrupt triggered by a PWM timer 0 TEP event. + */ +#define MCPWM_TIMER0_TEP_INT_RAW (BIT(6)) +#define MCPWM_TIMER0_TEP_INT_RAW_M (MCPWM_TIMER0_TEP_INT_RAW_V << MCPWM_TIMER0_TEP_INT_RAW_S) +#define MCPWM_TIMER0_TEP_INT_RAW_V 0x00000001U +#define MCPWM_TIMER0_TEP_INT_RAW_S 6 +/** MCPWM_TIMER1_TEP_INT_RAW : R/WTC/SS; bitpos: [7]; default: 0; + * The raw status bit for the interrupt triggered by a PWM timer 1 TEP event. + */ +#define MCPWM_TIMER1_TEP_INT_RAW (BIT(7)) +#define MCPWM_TIMER1_TEP_INT_RAW_M (MCPWM_TIMER1_TEP_INT_RAW_V << MCPWM_TIMER1_TEP_INT_RAW_S) +#define MCPWM_TIMER1_TEP_INT_RAW_V 0x00000001U +#define MCPWM_TIMER1_TEP_INT_RAW_S 7 +/** MCPWM_TIMER2_TEP_INT_RAW : R/WTC/SS; bitpos: [8]; default: 0; + * The raw status bit for the interrupt triggered by a PWM timer 2 TEP event. + */ +#define MCPWM_TIMER2_TEP_INT_RAW (BIT(8)) +#define MCPWM_TIMER2_TEP_INT_RAW_M (MCPWM_TIMER2_TEP_INT_RAW_V << MCPWM_TIMER2_TEP_INT_RAW_S) +#define MCPWM_TIMER2_TEP_INT_RAW_V 0x00000001U +#define MCPWM_TIMER2_TEP_INT_RAW_S 8 +/** MCPWM_FAULT0_INT_RAW : R/WTC/SS; bitpos: [9]; default: 0; + * The raw status bit for the interrupt triggered when fault_event0 starts. + */ +#define MCPWM_FAULT0_INT_RAW (BIT(9)) +#define MCPWM_FAULT0_INT_RAW_M (MCPWM_FAULT0_INT_RAW_V << MCPWM_FAULT0_INT_RAW_S) +#define MCPWM_FAULT0_INT_RAW_V 0x00000001U +#define MCPWM_FAULT0_INT_RAW_S 9 +/** MCPWM_FAULT1_INT_RAW : R/WTC/SS; bitpos: [10]; default: 0; + * The raw status bit for the interrupt triggered when fault_event1 starts. + */ +#define MCPWM_FAULT1_INT_RAW (BIT(10)) +#define MCPWM_FAULT1_INT_RAW_M (MCPWM_FAULT1_INT_RAW_V << MCPWM_FAULT1_INT_RAW_S) +#define MCPWM_FAULT1_INT_RAW_V 0x00000001U +#define MCPWM_FAULT1_INT_RAW_S 10 +/** MCPWM_FAULT2_INT_RAW : R/WTC/SS; bitpos: [11]; default: 0; + * The raw status bit for the interrupt triggered when fault_event2 starts. + */ +#define MCPWM_FAULT2_INT_RAW (BIT(11)) +#define MCPWM_FAULT2_INT_RAW_M (MCPWM_FAULT2_INT_RAW_V << MCPWM_FAULT2_INT_RAW_S) +#define MCPWM_FAULT2_INT_RAW_V 0x00000001U +#define MCPWM_FAULT2_INT_RAW_S 11 +/** MCPWM_FAULT0_CLR_INT_RAW : R/WTC/SS; bitpos: [12]; default: 0; + * The raw status bit for the interrupt triggered when fault_event0 ends. + */ +#define MCPWM_FAULT0_CLR_INT_RAW (BIT(12)) +#define MCPWM_FAULT0_CLR_INT_RAW_M (MCPWM_FAULT0_CLR_INT_RAW_V << MCPWM_FAULT0_CLR_INT_RAW_S) +#define MCPWM_FAULT0_CLR_INT_RAW_V 0x00000001U +#define MCPWM_FAULT0_CLR_INT_RAW_S 12 +/** MCPWM_FAULT1_CLR_INT_RAW : R/WTC/SS; bitpos: [13]; default: 0; + * The raw status bit for the interrupt triggered when fault_event1 ends. + */ +#define MCPWM_FAULT1_CLR_INT_RAW (BIT(13)) +#define MCPWM_FAULT1_CLR_INT_RAW_M (MCPWM_FAULT1_CLR_INT_RAW_V << MCPWM_FAULT1_CLR_INT_RAW_S) +#define MCPWM_FAULT1_CLR_INT_RAW_V 0x00000001U +#define MCPWM_FAULT1_CLR_INT_RAW_S 13 +/** MCPWM_FAULT2_CLR_INT_RAW : R/WTC/SS; bitpos: [14]; default: 0; + * The raw status bit for the interrupt triggered when fault_event2 ends. + */ +#define MCPWM_FAULT2_CLR_INT_RAW (BIT(14)) +#define MCPWM_FAULT2_CLR_INT_RAW_M (MCPWM_FAULT2_CLR_INT_RAW_V << MCPWM_FAULT2_CLR_INT_RAW_S) +#define MCPWM_FAULT2_CLR_INT_RAW_V 0x00000001U +#define MCPWM_FAULT2_CLR_INT_RAW_S 14 +/** MCPWM_OP0_TEA_INT_RAW : R/WTC/SS; bitpos: [15]; default: 0; + * The raw status bit for the interrupt triggered by a PWM operator 0 TEA event + */ +#define MCPWM_OP0_TEA_INT_RAW (BIT(15)) +#define MCPWM_OP0_TEA_INT_RAW_M (MCPWM_OP0_TEA_INT_RAW_V << MCPWM_OP0_TEA_INT_RAW_S) +#define MCPWM_OP0_TEA_INT_RAW_V 0x00000001U +#define MCPWM_OP0_TEA_INT_RAW_S 15 +/** MCPWM_OP1_TEA_INT_RAW : R/WTC/SS; bitpos: [16]; default: 0; + * The raw status bit for the interrupt triggered by a PWM operator 1 TEA event + */ +#define MCPWM_OP1_TEA_INT_RAW (BIT(16)) +#define MCPWM_OP1_TEA_INT_RAW_M (MCPWM_OP1_TEA_INT_RAW_V << MCPWM_OP1_TEA_INT_RAW_S) +#define MCPWM_OP1_TEA_INT_RAW_V 0x00000001U +#define MCPWM_OP1_TEA_INT_RAW_S 16 +/** MCPWM_OP2_TEA_INT_RAW : R/WTC/SS; bitpos: [17]; default: 0; + * The raw status bit for the interrupt triggered by a PWM operator 2 TEA event + */ +#define MCPWM_OP2_TEA_INT_RAW (BIT(17)) +#define MCPWM_OP2_TEA_INT_RAW_M (MCPWM_OP2_TEA_INT_RAW_V << MCPWM_OP2_TEA_INT_RAW_S) +#define MCPWM_OP2_TEA_INT_RAW_V 0x00000001U +#define MCPWM_OP2_TEA_INT_RAW_S 17 +/** MCPWM_OP0_TEB_INT_RAW : R/WTC/SS; bitpos: [18]; default: 0; + * The raw status bit for the interrupt triggered by a PWM operator 0 TEB event + */ +#define MCPWM_OP0_TEB_INT_RAW (BIT(18)) +#define MCPWM_OP0_TEB_INT_RAW_M (MCPWM_OP0_TEB_INT_RAW_V << MCPWM_OP0_TEB_INT_RAW_S) +#define MCPWM_OP0_TEB_INT_RAW_V 0x00000001U +#define MCPWM_OP0_TEB_INT_RAW_S 18 +/** MCPWM_OP1_TEB_INT_RAW : R/WTC/SS; bitpos: [19]; default: 0; + * The raw status bit for the interrupt triggered by a PWM operator 1 TEB event + */ +#define MCPWM_OP1_TEB_INT_RAW (BIT(19)) +#define MCPWM_OP1_TEB_INT_RAW_M (MCPWM_OP1_TEB_INT_RAW_V << MCPWM_OP1_TEB_INT_RAW_S) +#define MCPWM_OP1_TEB_INT_RAW_V 0x00000001U +#define MCPWM_OP1_TEB_INT_RAW_S 19 +/** MCPWM_OP2_TEB_INT_RAW : R/WTC/SS; bitpos: [20]; default: 0; + * The raw status bit for the interrupt triggered by a PWM operator 2 TEB event + */ +#define MCPWM_OP2_TEB_INT_RAW (BIT(20)) +#define MCPWM_OP2_TEB_INT_RAW_M (MCPWM_OP2_TEB_INT_RAW_V << MCPWM_OP2_TEB_INT_RAW_S) +#define MCPWM_OP2_TEB_INT_RAW_V 0x00000001U +#define MCPWM_OP2_TEB_INT_RAW_S 20 +/** MCPWM_FH0_CBC_INT_RAW : R/WTC/SS; bitpos: [21]; default: 0; + * The raw status bit for the interrupt triggered by a cycle-by-cycle mode action on + * PWM0. + */ +#define MCPWM_FH0_CBC_INT_RAW (BIT(21)) +#define MCPWM_FH0_CBC_INT_RAW_M (MCPWM_FH0_CBC_INT_RAW_V << MCPWM_FH0_CBC_INT_RAW_S) +#define MCPWM_FH0_CBC_INT_RAW_V 0x00000001U +#define MCPWM_FH0_CBC_INT_RAW_S 21 +/** MCPWM_FH1_CBC_INT_RAW : R/WTC/SS; bitpos: [22]; default: 0; + * The raw status bit for the interrupt triggered by a cycle-by-cycle mode action on + * PWM1. + */ +#define MCPWM_FH1_CBC_INT_RAW (BIT(22)) +#define MCPWM_FH1_CBC_INT_RAW_M (MCPWM_FH1_CBC_INT_RAW_V << MCPWM_FH1_CBC_INT_RAW_S) +#define MCPWM_FH1_CBC_INT_RAW_V 0x00000001U +#define MCPWM_FH1_CBC_INT_RAW_S 22 +/** MCPWM_FH2_CBC_INT_RAW : R/WTC/SS; bitpos: [23]; default: 0; + * The raw status bit for the interrupt triggered by a cycle-by-cycle mode action on + * PWM2. + */ +#define MCPWM_FH2_CBC_INT_RAW (BIT(23)) +#define MCPWM_FH2_CBC_INT_RAW_M (MCPWM_FH2_CBC_INT_RAW_V << MCPWM_FH2_CBC_INT_RAW_S) +#define MCPWM_FH2_CBC_INT_RAW_V 0x00000001U +#define MCPWM_FH2_CBC_INT_RAW_S 23 +/** MCPWM_FH0_OST_INT_RAW : R/WTC/SS; bitpos: [24]; default: 0; + * The raw status bit for the interrupt triggered by a one-shot mode action on PWM0. + */ +#define MCPWM_FH0_OST_INT_RAW (BIT(24)) +#define MCPWM_FH0_OST_INT_RAW_M (MCPWM_FH0_OST_INT_RAW_V << MCPWM_FH0_OST_INT_RAW_S) +#define MCPWM_FH0_OST_INT_RAW_V 0x00000001U +#define MCPWM_FH0_OST_INT_RAW_S 24 +/** MCPWM_FH1_OST_INT_RAW : R/WTC/SS; bitpos: [25]; default: 0; + * The raw status bit for the interrupt triggered by a one-shot mode action on PWM1. + */ +#define MCPWM_FH1_OST_INT_RAW (BIT(25)) +#define MCPWM_FH1_OST_INT_RAW_M (MCPWM_FH1_OST_INT_RAW_V << MCPWM_FH1_OST_INT_RAW_S) +#define MCPWM_FH1_OST_INT_RAW_V 0x00000001U +#define MCPWM_FH1_OST_INT_RAW_S 25 +/** MCPWM_FH2_OST_INT_RAW : R/WTC/SS; bitpos: [26]; default: 0; + * The raw status bit for the interrupt triggered by a one-shot mode action on PWM2. + */ +#define MCPWM_FH2_OST_INT_RAW (BIT(26)) +#define MCPWM_FH2_OST_INT_RAW_M (MCPWM_FH2_OST_INT_RAW_V << MCPWM_FH2_OST_INT_RAW_S) +#define MCPWM_FH2_OST_INT_RAW_V 0x00000001U +#define MCPWM_FH2_OST_INT_RAW_S 26 +/** MCPWM_CAP0_INT_RAW : R/WTC/SS; bitpos: [27]; default: 0; + * The raw status bit for the interrupt triggered by capture on channel 0. + */ +#define MCPWM_CAP0_INT_RAW (BIT(27)) +#define MCPWM_CAP0_INT_RAW_M (MCPWM_CAP0_INT_RAW_V << MCPWM_CAP0_INT_RAW_S) +#define MCPWM_CAP0_INT_RAW_V 0x00000001U +#define MCPWM_CAP0_INT_RAW_S 27 +/** MCPWM_CAP1_INT_RAW : R/WTC/SS; bitpos: [28]; default: 0; + * The raw status bit for the interrupt triggered by capture on channel 1. + */ +#define MCPWM_CAP1_INT_RAW (BIT(28)) +#define MCPWM_CAP1_INT_RAW_M (MCPWM_CAP1_INT_RAW_V << MCPWM_CAP1_INT_RAW_S) +#define MCPWM_CAP1_INT_RAW_V 0x00000001U +#define MCPWM_CAP1_INT_RAW_S 28 +/** MCPWM_CAP2_INT_RAW : R/WTC/SS; bitpos: [29]; default: 0; + * The raw status bit for the interrupt triggered by capture on channel 2. + */ +#define MCPWM_CAP2_INT_RAW (BIT(29)) +#define MCPWM_CAP2_INT_RAW_M (MCPWM_CAP2_INT_RAW_V << MCPWM_CAP2_INT_RAW_S) +#define MCPWM_CAP2_INT_RAW_V 0x00000001U +#define MCPWM_CAP2_INT_RAW_S 29 -#define MCMCPWM_INT_ST_MCPWM_REG(i) (REG_MCPWM_BASE(i) + 0x0118) -/* MCPWM_CAP2_INT_ST : RO ;bitpos:[29] ;default: 1'd0 ; */ -/*description: The masked status bit for interrupt triggered by captureon channel 2*/ -#define MCPWM_CAP2_INT_ST (BIT(29)) -#define MCPWM_CAP2_INT_ST_M (BIT(29)) -#define MCPWM_CAP2_INT_ST_V 0x1 -#define MCPWM_CAP2_INT_ST_S 29 -/* MCPWM_CAP1_INT_ST : RO ;bitpos:[28] ;default: 1'd0 ; */ -/*description: The masked status bit for interrupt triggered by captureon channel 1*/ -#define MCPWM_CAP1_INT_ST (BIT(28)) -#define MCPWM_CAP1_INT_ST_M (BIT(28)) -#define MCPWM_CAP1_INT_ST_V 0x1 -#define MCPWM_CAP1_INT_ST_S 28 -/* MCPWM_CAP0_INT_ST : RO ;bitpos:[27] ;default: 1'd0 ; */ -/*description: The masked status bit for interrupt triggered by captureon channel 0*/ -#define MCPWM_CAP0_INT_ST (BIT(27)) -#define MCPWM_CAP0_INT_ST_M (BIT(27)) -#define MCPWM_CAP0_INT_ST_V 0x1 -#define MCPWM_CAP0_INT_ST_S 27 -/* MCPWM_FH2_OST_INT_ST : RO ;bitpos:[26] ;default: 1'd0 ; */ -/*description: The masked status bit for interrupt triggered by an one-shot mode action on PWM2*/ -#define MCPWM_FH2_OST_INT_ST (BIT(26)) -#define MCPWM_FH2_OST_INT_ST_M (BIT(26)) -#define MCPWM_FH2_OST_INT_ST_V 0x1 -#define MCPWM_FH2_OST_INT_ST_S 26 -/* MCPWM_FH1_OST_INT_ST : RO ;bitpos:[25] ;default: 1'd0 ; */ -/*description: The masked status bit for interrupt triggered by an one-shot mode action on PWM0*/ -#define MCPWM_FH1_OST_INT_ST (BIT(25)) -#define MCPWM_FH1_OST_INT_ST_M (BIT(25)) -#define MCPWM_FH1_OST_INT_ST_V 0x1 -#define MCPWM_FH1_OST_INT_ST_S 25 -/* MCPWM_FH0_OST_INT_ST : RO ;bitpos:[24] ;default: 1'd0 ; */ -/*description: The masked status bit for interrupt triggered by an one-shot mode action on PWM0*/ -#define MCPWM_FH0_OST_INT_ST (BIT(24)) -#define MCPWM_FH0_OST_INT_ST_M (BIT(24)) -#define MCPWM_FH0_OST_INT_ST_V 0x1 -#define MCPWM_FH0_OST_INT_ST_S 24 -/* MCPWM_FH2_CBC_INT_ST : RO ;bitpos:[23] ;default: 1'd0 ; */ -/*description: The masked status bit for interrupt triggered by an cycle-by-cycle - mode action on PWM2*/ -#define MCPWM_FH2_CBC_INT_ST (BIT(23)) -#define MCPWM_FH2_CBC_INT_ST_M (BIT(23)) -#define MCPWM_FH2_CBC_INT_ST_V 0x1 -#define MCPWM_FH2_CBC_INT_ST_S 23 -/* MCPWM_FH1_CBC_INT_ST : RO ;bitpos:[22] ;default: 1'd0 ; */ -/*description: The masked status bit for interrupt triggered by an cycle-by-cycle - mode action on PWM1*/ -#define MCPWM_FH1_CBC_INT_ST (BIT(22)) -#define MCPWM_FH1_CBC_INT_ST_M (BIT(22)) -#define MCPWM_FH1_CBC_INT_ST_V 0x1 -#define MCPWM_FH1_CBC_INT_ST_S 22 -/* MCPWM_FH0_CBC_INT_ST : RO ;bitpos:[21] ;default: 1'd0 ; */ -/*description: The masked status bit for interrupt triggered by an cycle-by-cycle - mode action on PWM0*/ -#define MCPWM_FH0_CBC_INT_ST (BIT(21)) -#define MCPWM_FH0_CBC_INT_ST_M (BIT(21)) -#define MCPWM_FH0_CBC_INT_ST_V 0x1 -#define MCPWM_FH0_CBC_INT_ST_S 21 -/* MCPWM_OP2_TEB_INT_ST : RO ;bitpos:[20] ;default: 1'd0 ; */ -/*description: The masked status bit for interrupt triggered by a PWM operator 2 TEB event*/ -#define MCPWM_OP2_TEB_INT_ST (BIT(20)) -#define MCPWM_OP2_TEB_INT_ST_M (BIT(20)) -#define MCPWM_OP2_TEB_INT_ST_V 0x1 -#define MCPWM_OP2_TEB_INT_ST_S 20 -/* MCPWM_OP1_TEB_INT_ST : RO ;bitpos:[19] ;default: 1'd0 ; */ -/*description: The masked status bit for interrupt triggered by a PWM operator 1 TEB event*/ -#define MCPWM_OP1_TEB_INT_ST (BIT(19)) -#define MCPWM_OP1_TEB_INT_ST_M (BIT(19)) -#define MCPWM_OP1_TEB_INT_ST_V 0x1 -#define MCPWM_OP1_TEB_INT_ST_S 19 -/* MCPWM_OP0_TEB_INT_ST : RO ;bitpos:[18] ;default: 1'd0 ; */ -/*description: The masked status bit for interrupt triggered by a PWM operator 0 TEB event*/ -#define MCPWM_OP0_TEB_INT_ST (BIT(18)) -#define MCPWM_OP0_TEB_INT_ST_M (BIT(18)) -#define MCPWM_OP0_TEB_INT_ST_V 0x1 -#define MCPWM_OP0_TEB_INT_ST_S 18 -/* MCPWM_OP2_TEA_INT_ST : RO ;bitpos:[17] ;default: 1'd0 ; */ -/*description: The masked status bit for interrupt triggered by a PWM operator 2 TEA event*/ -#define MCPWM_OP2_TEA_INT_ST (BIT(17)) -#define MCPWM_OP2_TEA_INT_ST_M (BIT(17)) -#define MCPWM_OP2_TEA_INT_ST_V 0x1 -#define MCPWM_OP2_TEA_INT_ST_S 17 -/* MCPWM_OP1_TEA_INT_ST : RO ;bitpos:[16] ;default: 1'd0 ; */ -/*description: The masked status bit for interrupt triggered by a PWM operator 1 TEA event*/ -#define MCPWM_OP1_TEA_INT_ST (BIT(16)) -#define MCPWM_OP1_TEA_INT_ST_M (BIT(16)) -#define MCPWM_OP1_TEA_INT_ST_V 0x1 -#define MCPWM_OP1_TEA_INT_ST_S 16 -/* MCPWM_OP0_TEA_INT_ST : RO ;bitpos:[15] ;default: 1'd0 ; */ -/*description: The masked status bit for interrupt triggered by a PWM operator 0 TEA event*/ -#define MCPWM_OP0_TEA_INT_ST (BIT(15)) -#define MCPWM_OP0_TEA_INT_ST_M (BIT(15)) -#define MCPWM_OP0_TEA_INT_ST_V 0x1 -#define MCPWM_OP0_TEA_INT_ST_S 15 -/* MCPWM_FAULT2_CLR_INT_ST : RO ;bitpos:[14] ;default: 1'd0 ; */ -/*description: The masked status bit for interrupt triggered when event_f2 ends*/ -#define MCPWM_FAULT2_CLR_INT_ST (BIT(14)) -#define MCPWM_FAULT2_CLR_INT_ST_M (BIT(14)) -#define MCPWM_FAULT2_CLR_INT_ST_V 0x1 -#define MCPWM_FAULT2_CLR_INT_ST_S 14 -/* MCPWM_FAULT1_CLR_INT_ST : RO ;bitpos:[13] ;default: 1'd0 ; */ -/*description: The masked status bit for interrupt triggered when event_f1 ends*/ -#define MCPWM_FAULT1_CLR_INT_ST (BIT(13)) -#define MCPWM_FAULT1_CLR_INT_ST_M (BIT(13)) -#define MCPWM_FAULT1_CLR_INT_ST_V 0x1 -#define MCPWM_FAULT1_CLR_INT_ST_S 13 -/* MCPWM_FAULT0_CLR_INT_ST : RO ;bitpos:[12] ;default: 1'd0 ; */ -/*description: The masked status bit for interrupt triggered when event_f0 ends*/ -#define MCPWM_FAULT0_CLR_INT_ST (BIT(12)) -#define MCPWM_FAULT0_CLR_INT_ST_M (BIT(12)) -#define MCPWM_FAULT0_CLR_INT_ST_V 0x1 -#define MCPWM_FAULT0_CLR_INT_ST_S 12 -/* MCPWM_FAULT2_INT_ST : RO ;bitpos:[11] ;default: 1'd0 ; */ -/*description: The masked status bit for interrupt triggered when event_f2 starts*/ -#define MCPWM_FAULT2_INT_ST (BIT(11)) -#define MCPWM_FAULT2_INT_ST_M (BIT(11)) -#define MCPWM_FAULT2_INT_ST_V 0x1 -#define MCPWM_FAULT2_INT_ST_S 11 -/* MCPWM_FAULT1_INT_ST : RO ;bitpos:[10] ;default: 1'd0 ; */ -/*description: The masked status bit for interrupt triggered when event_f1 starts*/ -#define MCPWM_FAULT1_INT_ST (BIT(10)) -#define MCPWM_FAULT1_INT_ST_M (BIT(10)) -#define MCPWM_FAULT1_INT_ST_V 0x1 -#define MCPWM_FAULT1_INT_ST_S 10 -/* MCPWM_FAULT0_INT_ST : RO ;bitpos:[9] ;default: 1'd0 ; */ -/*description: The masked status bit for interrupt triggered when event_f0 starts*/ -#define MCPWM_FAULT0_INT_ST (BIT(9)) -#define MCPWM_FAULT0_INT_ST_M (BIT(9)) -#define MCPWM_FAULT0_INT_ST_V 0x1 -#define MCPWM_FAULT0_INT_ST_S 9 -/* MCPWM_TIMER2_TEP_INT_ST : RO ;bitpos:[8] ;default: 1'h0 ; */ -/*description: The masked status bit for interrupt triggered by a PWM timer 2 TEP event*/ -#define MCPWM_TIMER2_TEP_INT_ST (BIT(8)) -#define MCPWM_TIMER2_TEP_INT_ST_M (BIT(8)) -#define MCPWM_TIMER2_TEP_INT_ST_V 0x1 -#define MCPWM_TIMER2_TEP_INT_ST_S 8 -/* MCPWM_TIMER1_TEP_INT_ST : RO ;bitpos:[7] ;default: 1'h0 ; */ -/*description: The masked status bit for interrupt triggered by a PWM timer 1 TEP event*/ -#define MCPWM_TIMER1_TEP_INT_ST (BIT(7)) -#define MCPWM_TIMER1_TEP_INT_ST_M (BIT(7)) -#define MCPWM_TIMER1_TEP_INT_ST_V 0x1 -#define MCPWM_TIMER1_TEP_INT_ST_S 7 -/* MCPWM_TIMER0_TEP_INT_ST : RO ;bitpos:[6] ;default: 1'h0 ; */ -/*description: The masked status bit for interrupt triggered by a PWM timer 0 TEP event*/ -#define MCPWM_TIMER0_TEP_INT_ST (BIT(6)) -#define MCPWM_TIMER0_TEP_INT_ST_M (BIT(6)) -#define MCPWM_TIMER0_TEP_INT_ST_V 0x1 -#define MCPWM_TIMER0_TEP_INT_ST_S 6 -/* MCPWM_TIMER2_TEZ_INT_ST : RO ;bitpos:[5] ;default: 1'h0 ; */ -/*description: The masked status bit for interrupt triggered by a PWM timer 2 TEZ event*/ -#define MCPWM_TIMER2_TEZ_INT_ST (BIT(5)) -#define MCPWM_TIMER2_TEZ_INT_ST_M (BIT(5)) -#define MCPWM_TIMER2_TEZ_INT_ST_V 0x1 -#define MCPWM_TIMER2_TEZ_INT_ST_S 5 -/* MCPWM_TIMER1_TEZ_INT_ST : RO ;bitpos:[4] ;default: 1'h0 ; */ -/*description: The masked status bit for interrupt triggered by a PWM timer 1 TEZ event*/ -#define MCPWM_TIMER1_TEZ_INT_ST (BIT(4)) -#define MCPWM_TIMER1_TEZ_INT_ST_M (BIT(4)) -#define MCPWM_TIMER1_TEZ_INT_ST_V 0x1 -#define MCPWM_TIMER1_TEZ_INT_ST_S 4 -/* MCPWM_TIMER0_TEZ_INT_ST : RO ;bitpos:[3] ;default: 1'h0 ; */ -/*description: The masked status bit for interrupt triggered by a PWM timer 0 TEZ event*/ -#define MCPWM_TIMER0_TEZ_INT_ST (BIT(3)) -#define MCPWM_TIMER0_TEZ_INT_ST_M (BIT(3)) -#define MCPWM_TIMER0_TEZ_INT_ST_V 0x1 -#define MCPWM_TIMER0_TEZ_INT_ST_S 3 -/* MCPWM_TIMER2_STOP_INT_ST : RO ;bitpos:[2] ;default: 1'h0 ; */ -/*description: The masked status bit for interrupt triggered when timer 2 stops*/ -#define MCPWM_TIMER2_STOP_INT_ST (BIT(2)) -#define MCPWM_TIMER2_STOP_INT_ST_M (BIT(2)) -#define MCPWM_TIMER2_STOP_INT_ST_V 0x1 -#define MCPWM_TIMER2_STOP_INT_ST_S 2 -/* MCPWM_TIMER1_STOP_INT_ST : RO ;bitpos:[1] ;default: 1'h0 ; */ -/*description: The masked status bit for interrupt triggered when timer 1 stops*/ -#define MCPWM_TIMER1_STOP_INT_ST (BIT(1)) -#define MCPWM_TIMER1_STOP_INT_ST_M (BIT(1)) -#define MCPWM_TIMER1_STOP_INT_ST_V 0x1 -#define MCPWM_TIMER1_STOP_INT_ST_S 1 -/* MCPWM_TIMER0_STOP_INT_ST : RO ;bitpos:[0] ;default: 1'h0 ; */ -/*description: The masked status bit for interrupt triggered when timer 0 stops*/ -#define MCPWM_TIMER0_STOP_INT_ST (BIT(0)) -#define MCPWM_TIMER0_STOP_INT_ST_M (BIT(0)) -#define MCPWM_TIMER0_STOP_INT_ST_V 0x1 +/** MCPWM_INT_ST_REG register + * Masked interrupt status + */ +#define MCPWM_INT_ST_REG(i) (DR_REG_MCPWM_BASE(i) + 0x118) +/** MCPWM_TIMER0_STOP_INT_ST : RO; bitpos: [0]; default: 0; + * The masked status bit for the interrupt triggered when the timer 0 stops. + */ +#define MCPWM_TIMER0_STOP_INT_ST (BIT(0)) +#define MCPWM_TIMER0_STOP_INT_ST_M (MCPWM_TIMER0_STOP_INT_ST_V << MCPWM_TIMER0_STOP_INT_ST_S) +#define MCPWM_TIMER0_STOP_INT_ST_V 0x00000001U #define MCPWM_TIMER0_STOP_INT_ST_S 0 +/** MCPWM_TIMER1_STOP_INT_ST : RO; bitpos: [1]; default: 0; + * The masked status bit for the interrupt triggered when the timer 1 stops. + */ +#define MCPWM_TIMER1_STOP_INT_ST (BIT(1)) +#define MCPWM_TIMER1_STOP_INT_ST_M (MCPWM_TIMER1_STOP_INT_ST_V << MCPWM_TIMER1_STOP_INT_ST_S) +#define MCPWM_TIMER1_STOP_INT_ST_V 0x00000001U +#define MCPWM_TIMER1_STOP_INT_ST_S 1 +/** MCPWM_TIMER2_STOP_INT_ST : RO; bitpos: [2]; default: 0; + * The masked status bit for the interrupt triggered when the timer 2 stops. + */ +#define MCPWM_TIMER2_STOP_INT_ST (BIT(2)) +#define MCPWM_TIMER2_STOP_INT_ST_M (MCPWM_TIMER2_STOP_INT_ST_V << MCPWM_TIMER2_STOP_INT_ST_S) +#define MCPWM_TIMER2_STOP_INT_ST_V 0x00000001U +#define MCPWM_TIMER2_STOP_INT_ST_S 2 +/** MCPWM_TIMER0_TEZ_INT_ST : RO; bitpos: [3]; default: 0; + * The masked status bit for the interrupt triggered by a PWM timer 0 TEZ event. + */ +#define MCPWM_TIMER0_TEZ_INT_ST (BIT(3)) +#define MCPWM_TIMER0_TEZ_INT_ST_M (MCPWM_TIMER0_TEZ_INT_ST_V << MCPWM_TIMER0_TEZ_INT_ST_S) +#define MCPWM_TIMER0_TEZ_INT_ST_V 0x00000001U +#define MCPWM_TIMER0_TEZ_INT_ST_S 3 +/** MCPWM_TIMER1_TEZ_INT_ST : RO; bitpos: [4]; default: 0; + * The masked status bit for the interrupt triggered by a PWM timer 1 TEZ event. + */ +#define MCPWM_TIMER1_TEZ_INT_ST (BIT(4)) +#define MCPWM_TIMER1_TEZ_INT_ST_M (MCPWM_TIMER1_TEZ_INT_ST_V << MCPWM_TIMER1_TEZ_INT_ST_S) +#define MCPWM_TIMER1_TEZ_INT_ST_V 0x00000001U +#define MCPWM_TIMER1_TEZ_INT_ST_S 4 +/** MCPWM_TIMER2_TEZ_INT_ST : RO; bitpos: [5]; default: 0; + * The masked status bit for the interrupt triggered by a PWM timer 2 TEZ event. + */ +#define MCPWM_TIMER2_TEZ_INT_ST (BIT(5)) +#define MCPWM_TIMER2_TEZ_INT_ST_M (MCPWM_TIMER2_TEZ_INT_ST_V << MCPWM_TIMER2_TEZ_INT_ST_S) +#define MCPWM_TIMER2_TEZ_INT_ST_V 0x00000001U +#define MCPWM_TIMER2_TEZ_INT_ST_S 5 +/** MCPWM_TIMER0_TEP_INT_ST : RO; bitpos: [6]; default: 0; + * The masked status bit for the interrupt triggered by a PWM timer 0 TEP event. + */ +#define MCPWM_TIMER0_TEP_INT_ST (BIT(6)) +#define MCPWM_TIMER0_TEP_INT_ST_M (MCPWM_TIMER0_TEP_INT_ST_V << MCPWM_TIMER0_TEP_INT_ST_S) +#define MCPWM_TIMER0_TEP_INT_ST_V 0x00000001U +#define MCPWM_TIMER0_TEP_INT_ST_S 6 +/** MCPWM_TIMER1_TEP_INT_ST : RO; bitpos: [7]; default: 0; + * The masked status bit for the interrupt triggered by a PWM timer 1 TEP event. + */ +#define MCPWM_TIMER1_TEP_INT_ST (BIT(7)) +#define MCPWM_TIMER1_TEP_INT_ST_M (MCPWM_TIMER1_TEP_INT_ST_V << MCPWM_TIMER1_TEP_INT_ST_S) +#define MCPWM_TIMER1_TEP_INT_ST_V 0x00000001U +#define MCPWM_TIMER1_TEP_INT_ST_S 7 +/** MCPWM_TIMER2_TEP_INT_ST : RO; bitpos: [8]; default: 0; + * The masked status bit for the interrupt triggered by a PWM timer 2 TEP event. + */ +#define MCPWM_TIMER2_TEP_INT_ST (BIT(8)) +#define MCPWM_TIMER2_TEP_INT_ST_M (MCPWM_TIMER2_TEP_INT_ST_V << MCPWM_TIMER2_TEP_INT_ST_S) +#define MCPWM_TIMER2_TEP_INT_ST_V 0x00000001U +#define MCPWM_TIMER2_TEP_INT_ST_S 8 +/** MCPWM_FAULT0_INT_ST : RO; bitpos: [9]; default: 0; + * The masked status bit for the interrupt triggered when fault_event0 starts. + */ +#define MCPWM_FAULT0_INT_ST (BIT(9)) +#define MCPWM_FAULT0_INT_ST_M (MCPWM_FAULT0_INT_ST_V << MCPWM_FAULT0_INT_ST_S) +#define MCPWM_FAULT0_INT_ST_V 0x00000001U +#define MCPWM_FAULT0_INT_ST_S 9 +/** MCPWM_FAULT1_INT_ST : RO; bitpos: [10]; default: 0; + * The masked status bit for the interrupt triggered when fault_event1 starts. + */ +#define MCPWM_FAULT1_INT_ST (BIT(10)) +#define MCPWM_FAULT1_INT_ST_M (MCPWM_FAULT1_INT_ST_V << MCPWM_FAULT1_INT_ST_S) +#define MCPWM_FAULT1_INT_ST_V 0x00000001U +#define MCPWM_FAULT1_INT_ST_S 10 +/** MCPWM_FAULT2_INT_ST : RO; bitpos: [11]; default: 0; + * The masked status bit for the interrupt triggered when fault_event2 starts. + */ +#define MCPWM_FAULT2_INT_ST (BIT(11)) +#define MCPWM_FAULT2_INT_ST_M (MCPWM_FAULT2_INT_ST_V << MCPWM_FAULT2_INT_ST_S) +#define MCPWM_FAULT2_INT_ST_V 0x00000001U +#define MCPWM_FAULT2_INT_ST_S 11 +/** MCPWM_FAULT0_CLR_INT_ST : RO; bitpos: [12]; default: 0; + * The masked status bit for the interrupt triggered when fault_event0 ends. + */ +#define MCPWM_FAULT0_CLR_INT_ST (BIT(12)) +#define MCPWM_FAULT0_CLR_INT_ST_M (MCPWM_FAULT0_CLR_INT_ST_V << MCPWM_FAULT0_CLR_INT_ST_S) +#define MCPWM_FAULT0_CLR_INT_ST_V 0x00000001U +#define MCPWM_FAULT0_CLR_INT_ST_S 12 +/** MCPWM_FAULT1_CLR_INT_ST : RO; bitpos: [13]; default: 0; + * The masked status bit for the interrupt triggered when fault_event1 ends. + */ +#define MCPWM_FAULT1_CLR_INT_ST (BIT(13)) +#define MCPWM_FAULT1_CLR_INT_ST_M (MCPWM_FAULT1_CLR_INT_ST_V << MCPWM_FAULT1_CLR_INT_ST_S) +#define MCPWM_FAULT1_CLR_INT_ST_V 0x00000001U +#define MCPWM_FAULT1_CLR_INT_ST_S 13 +/** MCPWM_FAULT2_CLR_INT_ST : RO; bitpos: [14]; default: 0; + * The masked status bit for the interrupt triggered when fault_event2 ends. + */ +#define MCPWM_FAULT2_CLR_INT_ST (BIT(14)) +#define MCPWM_FAULT2_CLR_INT_ST_M (MCPWM_FAULT2_CLR_INT_ST_V << MCPWM_FAULT2_CLR_INT_ST_S) +#define MCPWM_FAULT2_CLR_INT_ST_V 0x00000001U +#define MCPWM_FAULT2_CLR_INT_ST_S 14 +/** MCPWM_OP0_TEA_INT_ST : RO; bitpos: [15]; default: 0; + * The masked status bit for the interrupt triggered by a PWM operator 0 TEA event + */ +#define MCPWM_OP0_TEA_INT_ST (BIT(15)) +#define MCPWM_OP0_TEA_INT_ST_M (MCPWM_OP0_TEA_INT_ST_V << MCPWM_OP0_TEA_INT_ST_S) +#define MCPWM_OP0_TEA_INT_ST_V 0x00000001U +#define MCPWM_OP0_TEA_INT_ST_S 15 +/** MCPWM_OP1_TEA_INT_ST : RO; bitpos: [16]; default: 0; + * The masked status bit for the interrupt triggered by a PWM operator 1 TEA event + */ +#define MCPWM_OP1_TEA_INT_ST (BIT(16)) +#define MCPWM_OP1_TEA_INT_ST_M (MCPWM_OP1_TEA_INT_ST_V << MCPWM_OP1_TEA_INT_ST_S) +#define MCPWM_OP1_TEA_INT_ST_V 0x00000001U +#define MCPWM_OP1_TEA_INT_ST_S 16 +/** MCPWM_OP2_TEA_INT_ST : RO; bitpos: [17]; default: 0; + * The masked status bit for the interrupt triggered by a PWM operator 2 TEA event + */ +#define MCPWM_OP2_TEA_INT_ST (BIT(17)) +#define MCPWM_OP2_TEA_INT_ST_M (MCPWM_OP2_TEA_INT_ST_V << MCPWM_OP2_TEA_INT_ST_S) +#define MCPWM_OP2_TEA_INT_ST_V 0x00000001U +#define MCPWM_OP2_TEA_INT_ST_S 17 +/** MCPWM_OP0_TEB_INT_ST : RO; bitpos: [18]; default: 0; + * The masked status bit for the interrupt triggered by a PWM operator 0 TEB event + */ +#define MCPWM_OP0_TEB_INT_ST (BIT(18)) +#define MCPWM_OP0_TEB_INT_ST_M (MCPWM_OP0_TEB_INT_ST_V << MCPWM_OP0_TEB_INT_ST_S) +#define MCPWM_OP0_TEB_INT_ST_V 0x00000001U +#define MCPWM_OP0_TEB_INT_ST_S 18 +/** MCPWM_OP1_TEB_INT_ST : RO; bitpos: [19]; default: 0; + * The masked status bit for the interrupt triggered by a PWM operator 1 TEB event + */ +#define MCPWM_OP1_TEB_INT_ST (BIT(19)) +#define MCPWM_OP1_TEB_INT_ST_M (MCPWM_OP1_TEB_INT_ST_V << MCPWM_OP1_TEB_INT_ST_S) +#define MCPWM_OP1_TEB_INT_ST_V 0x00000001U +#define MCPWM_OP1_TEB_INT_ST_S 19 +/** MCPWM_OP2_TEB_INT_ST : RO; bitpos: [20]; default: 0; + * The masked status bit for the interrupt triggered by a PWM operator 2 TEB event + */ +#define MCPWM_OP2_TEB_INT_ST (BIT(20)) +#define MCPWM_OP2_TEB_INT_ST_M (MCPWM_OP2_TEB_INT_ST_V << MCPWM_OP2_TEB_INT_ST_S) +#define MCPWM_OP2_TEB_INT_ST_V 0x00000001U +#define MCPWM_OP2_TEB_INT_ST_S 20 +/** MCPWM_FH0_CBC_INT_ST : RO; bitpos: [21]; default: 0; + * The masked status bit for the interrupt triggered by a cycle-by-cycle mode action + * on PWM0. + */ +#define MCPWM_FH0_CBC_INT_ST (BIT(21)) +#define MCPWM_FH0_CBC_INT_ST_M (MCPWM_FH0_CBC_INT_ST_V << MCPWM_FH0_CBC_INT_ST_S) +#define MCPWM_FH0_CBC_INT_ST_V 0x00000001U +#define MCPWM_FH0_CBC_INT_ST_S 21 +/** MCPWM_FH1_CBC_INT_ST : RO; bitpos: [22]; default: 0; + * The masked status bit for the interrupt triggered by a cycle-by-cycle mode action + * on PWM1. + */ +#define MCPWM_FH1_CBC_INT_ST (BIT(22)) +#define MCPWM_FH1_CBC_INT_ST_M (MCPWM_FH1_CBC_INT_ST_V << MCPWM_FH1_CBC_INT_ST_S) +#define MCPWM_FH1_CBC_INT_ST_V 0x00000001U +#define MCPWM_FH1_CBC_INT_ST_S 22 +/** MCPWM_FH2_CBC_INT_ST : RO; bitpos: [23]; default: 0; + * The masked status bit for the interrupt triggered by a cycle-by-cycle mode action + * on PWM2. + */ +#define MCPWM_FH2_CBC_INT_ST (BIT(23)) +#define MCPWM_FH2_CBC_INT_ST_M (MCPWM_FH2_CBC_INT_ST_V << MCPWM_FH2_CBC_INT_ST_S) +#define MCPWM_FH2_CBC_INT_ST_V 0x00000001U +#define MCPWM_FH2_CBC_INT_ST_S 23 +/** MCPWM_FH0_OST_INT_ST : RO; bitpos: [24]; default: 0; + * The masked status bit for the interrupt triggered by a one-shot mode action on PWM0. + */ +#define MCPWM_FH0_OST_INT_ST (BIT(24)) +#define MCPWM_FH0_OST_INT_ST_M (MCPWM_FH0_OST_INT_ST_V << MCPWM_FH0_OST_INT_ST_S) +#define MCPWM_FH0_OST_INT_ST_V 0x00000001U +#define MCPWM_FH0_OST_INT_ST_S 24 +/** MCPWM_FH1_OST_INT_ST : RO; bitpos: [25]; default: 0; + * The masked status bit for the interrupt triggered by a one-shot mode action on PWM1. + */ +#define MCPWM_FH1_OST_INT_ST (BIT(25)) +#define MCPWM_FH1_OST_INT_ST_M (MCPWM_FH1_OST_INT_ST_V << MCPWM_FH1_OST_INT_ST_S) +#define MCPWM_FH1_OST_INT_ST_V 0x00000001U +#define MCPWM_FH1_OST_INT_ST_S 25 +/** MCPWM_FH2_OST_INT_ST : RO; bitpos: [26]; default: 0; + * The masked status bit for the interrupt triggered by a one-shot mode action on PWM2. + */ +#define MCPWM_FH2_OST_INT_ST (BIT(26)) +#define MCPWM_FH2_OST_INT_ST_M (MCPWM_FH2_OST_INT_ST_V << MCPWM_FH2_OST_INT_ST_S) +#define MCPWM_FH2_OST_INT_ST_V 0x00000001U +#define MCPWM_FH2_OST_INT_ST_S 26 +/** MCPWM_CAP0_INT_ST : RO; bitpos: [27]; default: 0; + * The masked status bit for the interrupt triggered by capture on channel 0. + */ +#define MCPWM_CAP0_INT_ST (BIT(27)) +#define MCPWM_CAP0_INT_ST_M (MCPWM_CAP0_INT_ST_V << MCPWM_CAP0_INT_ST_S) +#define MCPWM_CAP0_INT_ST_V 0x00000001U +#define MCPWM_CAP0_INT_ST_S 27 +/** MCPWM_CAP1_INT_ST : RO; bitpos: [28]; default: 0; + * The masked status bit for the interrupt triggered by capture on channel 1. + */ +#define MCPWM_CAP1_INT_ST (BIT(28)) +#define MCPWM_CAP1_INT_ST_M (MCPWM_CAP1_INT_ST_V << MCPWM_CAP1_INT_ST_S) +#define MCPWM_CAP1_INT_ST_V 0x00000001U +#define MCPWM_CAP1_INT_ST_S 28 +/** MCPWM_CAP2_INT_ST : RO; bitpos: [29]; default: 0; + * The masked status bit for the interrupt triggered by capture on channel 2. + */ +#define MCPWM_CAP2_INT_ST (BIT(29)) +#define MCPWM_CAP2_INT_ST_M (MCPWM_CAP2_INT_ST_V << MCPWM_CAP2_INT_ST_S) +#define MCPWM_CAP2_INT_ST_V 0x00000001U +#define MCPWM_CAP2_INT_ST_S 29 -#define MCMCPWM_INT_CLR_MCPWM_REG(i) (REG_MCPWM_BASE(i) + 0x011c) -/* MCPWM_CAP2_INT_CLR : WO ;bitpos:[29] ;default: 1'd0 ; */ -/*description: Set this bit to clear interrupt triggered by captureon channel 2*/ -#define MCPWM_CAP2_INT_CLR (BIT(29)) -#define MCPWM_CAP2_INT_CLR_M (BIT(29)) -#define MCPWM_CAP2_INT_CLR_V 0x1 -#define MCPWM_CAP2_INT_CLR_S 29 -/* MCPWM_CAP1_INT_CLR : WO ;bitpos:[28] ;default: 1'd0 ; */ -/*description: Set this bit to clear interrupt triggered by captureon channel 1*/ -#define MCPWM_CAP1_INT_CLR (BIT(28)) -#define MCPWM_CAP1_INT_CLR_M (BIT(28)) -#define MCPWM_CAP1_INT_CLR_V 0x1 -#define MCPWM_CAP1_INT_CLR_S 28 -/* MCPWM_CAP0_INT_CLR : WO ;bitpos:[27] ;default: 1'd0 ; */ -/*description: Set this bit to clear interrupt triggered by captureon channel 0*/ -#define MCPWM_CAP0_INT_CLR (BIT(27)) -#define MCPWM_CAP0_INT_CLR_M (BIT(27)) -#define MCPWM_CAP0_INT_CLR_V 0x1 -#define MCPWM_CAP0_INT_CLR_S 27 -/* MCPWM_FH2_OST_INT_CLR : WO ;bitpos:[26] ;default: 1'd0 ; */ -/*description: Set this bit to clear interrupt triggered by an one-shot mode action on PWM2*/ -#define MCPWM_FH2_OST_INT_CLR (BIT(26)) -#define MCPWM_FH2_OST_INT_CLR_M (BIT(26)) -#define MCPWM_FH2_OST_INT_CLR_V 0x1 -#define MCPWM_FH2_OST_INT_CLR_S 26 -/* MCPWM_FH1_OST_INT_CLR : WO ;bitpos:[25] ;default: 1'd0 ; */ -/*description: Set this bit to clear interrupt triggered by an one-shot mode action on PWM0*/ -#define MCPWM_FH1_OST_INT_CLR (BIT(25)) -#define MCPWM_FH1_OST_INT_CLR_M (BIT(25)) -#define MCPWM_FH1_OST_INT_CLR_V 0x1 -#define MCPWM_FH1_OST_INT_CLR_S 25 -/* MCPWM_FH0_OST_INT_CLR : WO ;bitpos:[24] ;default: 1'd0 ; */ -/*description: Set this bit to clear interrupt triggered by an one-shot mode action on PWM0*/ -#define MCPWM_FH0_OST_INT_CLR (BIT(24)) -#define MCPWM_FH0_OST_INT_CLR_M (BIT(24)) -#define MCPWM_FH0_OST_INT_CLR_V 0x1 -#define MCPWM_FH0_OST_INT_CLR_S 24 -/* MCPWM_FH2_CBC_INT_CLR : WO ;bitpos:[23] ;default: 1'd0 ; */ -/*description: Set this bit to clear interrupt triggered by an cycle-by-cycle - mode action on PWM2*/ -#define MCPWM_FH2_CBC_INT_CLR (BIT(23)) -#define MCPWM_FH2_CBC_INT_CLR_M (BIT(23)) -#define MCPWM_FH2_CBC_INT_CLR_V 0x1 -#define MCPWM_FH2_CBC_INT_CLR_S 23 -/* MCPWM_FH1_CBC_INT_CLR : WO ;bitpos:[22] ;default: 1'd0 ; */ -/*description: Set this bit to clear interrupt triggered by an cycle-by-cycle - mode action on PWM1*/ -#define MCPWM_FH1_CBC_INT_CLR (BIT(22)) -#define MCPWM_FH1_CBC_INT_CLR_M (BIT(22)) -#define MCPWM_FH1_CBC_INT_CLR_V 0x1 -#define MCPWM_FH1_CBC_INT_CLR_S 22 -/* MCPWM_FH0_CBC_INT_CLR : WO ;bitpos:[21] ;default: 1'd0 ; */ -/*description: Set this bit to clear interrupt triggered by an cycle-by-cycle - mode action on PWM0*/ -#define MCPWM_FH0_CBC_INT_CLR (BIT(21)) -#define MCPWM_FH0_CBC_INT_CLR_M (BIT(21)) -#define MCPWM_FH0_CBC_INT_CLR_V 0x1 -#define MCPWM_FH0_CBC_INT_CLR_S 21 -/* MCPWM_OP2_TEB_INT_CLR : WO ;bitpos:[20] ;default: 1'd0 ; */ -/*description: Set this bit to clear interrupt triggered by a PWM operator 2 TEB event*/ -#define MCPWM_OP2_TEB_INT_CLR (BIT(20)) -#define MCPWM_OP2_TEB_INT_CLR_M (BIT(20)) -#define MCPWM_OP2_TEB_INT_CLR_V 0x1 -#define MCPWM_OP2_TEB_INT_CLR_S 20 -/* MCPWM_OP1_TEB_INT_CLR : WO ;bitpos:[19] ;default: 1'd0 ; */ -/*description: Set this bit to clear interrupt triggered by a PWM operator 1 TEB event*/ -#define MCPWM_OP1_TEB_INT_CLR (BIT(19)) -#define MCPWM_OP1_TEB_INT_CLR_M (BIT(19)) -#define MCPWM_OP1_TEB_INT_CLR_V 0x1 -#define MCPWM_OP1_TEB_INT_CLR_S 19 -/* MCPWM_OP0_TEB_INT_CLR : WO ;bitpos:[18] ;default: 1'd0 ; */ -/*description: Set this bit to clear interrupt triggered by a PWM operator 0 TEB event*/ -#define MCPWM_OP0_TEB_INT_CLR (BIT(18)) -#define MCPWM_OP0_TEB_INT_CLR_M (BIT(18)) -#define MCPWM_OP0_TEB_INT_CLR_V 0x1 -#define MCPWM_OP0_TEB_INT_CLR_S 18 -/* MCPWM_OP2_TEA_INT_CLR : WO ;bitpos:[17] ;default: 1'd0 ; */ -/*description: Set this bit to clear interrupt triggered by a PWM operator 2 TEA event*/ -#define MCPWM_OP2_TEA_INT_CLR (BIT(17)) -#define MCPWM_OP2_TEA_INT_CLR_M (BIT(17)) -#define MCPWM_OP2_TEA_INT_CLR_V 0x1 -#define MCPWM_OP2_TEA_INT_CLR_S 17 -/* MCPWM_OP1_TEA_INT_CLR : WO ;bitpos:[16] ;default: 1'd0 ; */ -/*description: Set this bit to clear interrupt triggered by a PWM operator 1 TEA event*/ -#define MCPWM_OP1_TEA_INT_CLR (BIT(16)) -#define MCPWM_OP1_TEA_INT_CLR_M (BIT(16)) -#define MCPWM_OP1_TEA_INT_CLR_V 0x1 -#define MCPWM_OP1_TEA_INT_CLR_S 16 -/* MCPWM_OP0_TEA_INT_CLR : WO ;bitpos:[15] ;default: 1'd0 ; */ -/*description: Set this bit to clear interrupt triggered by a PWM operator 0 TEA event*/ -#define MCPWM_OP0_TEA_INT_CLR (BIT(15)) -#define MCPWM_OP0_TEA_INT_CLR_M (BIT(15)) -#define MCPWM_OP0_TEA_INT_CLR_V 0x1 -#define MCPWM_OP0_TEA_INT_CLR_S 15 -/* MCPWM_FAULT2_CLR_INT_CLR : WO ;bitpos:[14] ;default: 1'd0 ; */ -/*description: Set this bit to clear interrupt triggered when event_f2 ends*/ -#define MCPWM_FAULT2_CLR_INT_CLR (BIT(14)) -#define MCPWM_FAULT2_CLR_INT_CLR_M (BIT(14)) -#define MCPWM_FAULT2_CLR_INT_CLR_V 0x1 -#define MCPWM_FAULT2_CLR_INT_CLR_S 14 -/* MCPWM_FAULT1_CLR_INT_CLR : WO ;bitpos:[13] ;default: 1'd0 ; */ -/*description: Set this bit to clear interrupt triggered when event_f1 ends*/ -#define MCPWM_FAULT1_CLR_INT_CLR (BIT(13)) -#define MCPWM_FAULT1_CLR_INT_CLR_M (BIT(13)) -#define MCPWM_FAULT1_CLR_INT_CLR_V 0x1 -#define MCPWM_FAULT1_CLR_INT_CLR_S 13 -/* MCPWM_FAULT0_CLR_INT_CLR : WO ;bitpos:[12] ;default: 1'd0 ; */ -/*description: Set this bit to clear interrupt triggered when event_f0 ends*/ -#define MCPWM_FAULT0_CLR_INT_CLR (BIT(12)) -#define MCPWM_FAULT0_CLR_INT_CLR_M (BIT(12)) -#define MCPWM_FAULT0_CLR_INT_CLR_V 0x1 -#define MCPWM_FAULT0_CLR_INT_CLR_S 12 -/* MCPWM_FAULT2_INT_CLR : WO ;bitpos:[11] ;default: 1'd0 ; */ -/*description: Set this bit to clear interrupt triggered when event_f2 starts*/ -#define MCPWM_FAULT2_INT_CLR (BIT(11)) -#define MCPWM_FAULT2_INT_CLR_M (BIT(11)) -#define MCPWM_FAULT2_INT_CLR_V 0x1 -#define MCPWM_FAULT2_INT_CLR_S 11 -/* MCPWM_FAULT1_INT_CLR : WO ;bitpos:[10] ;default: 1'd0 ; */ -/*description: Set this bit to clear interrupt triggered when event_f1 starts*/ -#define MCPWM_FAULT1_INT_CLR (BIT(10)) -#define MCPWM_FAULT1_INT_CLR_M (BIT(10)) -#define MCPWM_FAULT1_INT_CLR_V 0x1 -#define MCPWM_FAULT1_INT_CLR_S 10 -/* MCPWM_FAULT0_INT_CLR : WO ;bitpos:[9] ;default: 1'd0 ; */ -/*description: Set this bit to clear interrupt triggered when event_f0 starts*/ -#define MCPWM_FAULT0_INT_CLR (BIT(9)) -#define MCPWM_FAULT0_INT_CLR_M (BIT(9)) -#define MCPWM_FAULT0_INT_CLR_V 0x1 -#define MCPWM_FAULT0_INT_CLR_S 9 -/* MCPWM_TIMER2_TEP_INT_CLR : WO ;bitpos:[8] ;default: 1'h0 ; */ -/*description: Set this bit to clear interrupt triggered by a PWM timer 2 TEP event*/ -#define MCPWM_TIMER2_TEP_INT_CLR (BIT(8)) -#define MCPWM_TIMER2_TEP_INT_CLR_M (BIT(8)) -#define MCPWM_TIMER2_TEP_INT_CLR_V 0x1 -#define MCPWM_TIMER2_TEP_INT_CLR_S 8 -/* MCPWM_TIMER1_TEP_INT_CLR : WO ;bitpos:[7] ;default: 1'h0 ; */ -/*description: Set this bit to clear interrupt triggered by a PWM timer 1 TEP event*/ -#define MCPWM_TIMER1_TEP_INT_CLR (BIT(7)) -#define MCPWM_TIMER1_TEP_INT_CLR_M (BIT(7)) -#define MCPWM_TIMER1_TEP_INT_CLR_V 0x1 -#define MCPWM_TIMER1_TEP_INT_CLR_S 7 -/* MCPWM_TIMER0_TEP_INT_CLR : WO ;bitpos:[6] ;default: 1'h0 ; */ -/*description: Set this bit to clear interrupt triggered by a PWM timer 0 TEP event*/ -#define MCPWM_TIMER0_TEP_INT_CLR (BIT(6)) -#define MCPWM_TIMER0_TEP_INT_CLR_M (BIT(6)) -#define MCPWM_TIMER0_TEP_INT_CLR_V 0x1 -#define MCPWM_TIMER0_TEP_INT_CLR_S 6 -/* MCPWM_TIMER2_TEZ_INT_CLR : WO ;bitpos:[5] ;default: 1'h0 ; */ -/*description: Set this bit to clear interrupt triggered by a PWM timer 2 TEZ event*/ -#define MCPWM_TIMER2_TEZ_INT_CLR (BIT(5)) -#define MCPWM_TIMER2_TEZ_INT_CLR_M (BIT(5)) -#define MCPWM_TIMER2_TEZ_INT_CLR_V 0x1 -#define MCPWM_TIMER2_TEZ_INT_CLR_S 5 -/* MCPWM_TIMER1_TEZ_INT_CLR : WO ;bitpos:[4] ;default: 1'h0 ; */ -/*description: Set this bit to clear interrupt triggered by a PWM timer 1 TEZ event*/ -#define MCPWM_TIMER1_TEZ_INT_CLR (BIT(4)) -#define MCPWM_TIMER1_TEZ_INT_CLR_M (BIT(4)) -#define MCPWM_TIMER1_TEZ_INT_CLR_V 0x1 -#define MCPWM_TIMER1_TEZ_INT_CLR_S 4 -/* MCPWM_TIMER0_TEZ_INT_CLR : WO ;bitpos:[3] ;default: 1'h0 ; */ -/*description: Set this bit to clear interrupt triggered by a PWM timer 0 TEZ event*/ -#define MCPWM_TIMER0_TEZ_INT_CLR (BIT(3)) -#define MCPWM_TIMER0_TEZ_INT_CLR_M (BIT(3)) -#define MCPWM_TIMER0_TEZ_INT_CLR_V 0x1 -#define MCPWM_TIMER0_TEZ_INT_CLR_S 3 -/* MCPWM_TIMER2_STOP_INT_CLR : WO ;bitpos:[2] ;default: 1'h0 ; */ -/*description: Set this bit to clear interrupt triggered when timer 2 stops*/ -#define MCPWM_TIMER2_STOP_INT_CLR (BIT(2)) -#define MCPWM_TIMER2_STOP_INT_CLR_M (BIT(2)) -#define MCPWM_TIMER2_STOP_INT_CLR_V 0x1 -#define MCPWM_TIMER2_STOP_INT_CLR_S 2 -/* MCPWM_TIMER1_STOP_INT_CLR : WO ;bitpos:[1] ;default: 1'h0 ; */ -/*description: Set this bit to clear interrupt triggered when timer 1 stops*/ -#define MCPWM_TIMER1_STOP_INT_CLR (BIT(1)) -#define MCPWM_TIMER1_STOP_INT_CLR_M (BIT(1)) -#define MCPWM_TIMER1_STOP_INT_CLR_V 0x1 -#define MCPWM_TIMER1_STOP_INT_CLR_S 1 -/* MCPWM_TIMER0_STOP_INT_CLR : WO ;bitpos:[0] ;default: 1'h0 ; */ -/*description: Set this bit to clear interrupt triggered when timer 0 stops*/ -#define MCPWM_TIMER0_STOP_INT_CLR (BIT(0)) -#define MCPWM_TIMER0_STOP_INT_CLR_M (BIT(0)) -#define MCPWM_TIMER0_STOP_INT_CLR_V 0x1 +/** MCPWM_INT_CLR_REG register + * Interrupt clear bits + */ +#define MCPWM_INT_CLR_REG(i) (DR_REG_MCPWM_BASE(i) + 0x11c) +/** MCPWM_TIMER0_STOP_INT_CLR : WT; bitpos: [0]; default: 0; + * Set this bit to clear the interrupt triggered when the timer 0 stops. + */ +#define MCPWM_TIMER0_STOP_INT_CLR (BIT(0)) +#define MCPWM_TIMER0_STOP_INT_CLR_M (MCPWM_TIMER0_STOP_INT_CLR_V << MCPWM_TIMER0_STOP_INT_CLR_S) +#define MCPWM_TIMER0_STOP_INT_CLR_V 0x00000001U #define MCPWM_TIMER0_STOP_INT_CLR_S 0 +/** MCPWM_TIMER1_STOP_INT_CLR : WT; bitpos: [1]; default: 0; + * Set this bit to clear the interrupt triggered when the timer 1 stops. + */ +#define MCPWM_TIMER1_STOP_INT_CLR (BIT(1)) +#define MCPWM_TIMER1_STOP_INT_CLR_M (MCPWM_TIMER1_STOP_INT_CLR_V << MCPWM_TIMER1_STOP_INT_CLR_S) +#define MCPWM_TIMER1_STOP_INT_CLR_V 0x00000001U +#define MCPWM_TIMER1_STOP_INT_CLR_S 1 +/** MCPWM_TIMER2_STOP_INT_CLR : WT; bitpos: [2]; default: 0; + * Set this bit to clear the interrupt triggered when the timer 2 stops. + */ +#define MCPWM_TIMER2_STOP_INT_CLR (BIT(2)) +#define MCPWM_TIMER2_STOP_INT_CLR_M (MCPWM_TIMER2_STOP_INT_CLR_V << MCPWM_TIMER2_STOP_INT_CLR_S) +#define MCPWM_TIMER2_STOP_INT_CLR_V 0x00000001U +#define MCPWM_TIMER2_STOP_INT_CLR_S 2 +/** MCPWM_TIMER0_TEZ_INT_CLR : WT; bitpos: [3]; default: 0; + * Set this bit to clear the interrupt triggered by a PWM timer 0 TEZ event. + */ +#define MCPWM_TIMER0_TEZ_INT_CLR (BIT(3)) +#define MCPWM_TIMER0_TEZ_INT_CLR_M (MCPWM_TIMER0_TEZ_INT_CLR_V << MCPWM_TIMER0_TEZ_INT_CLR_S) +#define MCPWM_TIMER0_TEZ_INT_CLR_V 0x00000001U +#define MCPWM_TIMER0_TEZ_INT_CLR_S 3 +/** MCPWM_TIMER1_TEZ_INT_CLR : WT; bitpos: [4]; default: 0; + * Set this bit to clear the interrupt triggered by a PWM timer 1 TEZ event. + */ +#define MCPWM_TIMER1_TEZ_INT_CLR (BIT(4)) +#define MCPWM_TIMER1_TEZ_INT_CLR_M (MCPWM_TIMER1_TEZ_INT_CLR_V << MCPWM_TIMER1_TEZ_INT_CLR_S) +#define MCPWM_TIMER1_TEZ_INT_CLR_V 0x00000001U +#define MCPWM_TIMER1_TEZ_INT_CLR_S 4 +/** MCPWM_TIMER2_TEZ_INT_CLR : WT; bitpos: [5]; default: 0; + * Set this bit to clear the interrupt triggered by a PWM timer 2 TEZ event. + */ +#define MCPWM_TIMER2_TEZ_INT_CLR (BIT(5)) +#define MCPWM_TIMER2_TEZ_INT_CLR_M (MCPWM_TIMER2_TEZ_INT_CLR_V << MCPWM_TIMER2_TEZ_INT_CLR_S) +#define MCPWM_TIMER2_TEZ_INT_CLR_V 0x00000001U +#define MCPWM_TIMER2_TEZ_INT_CLR_S 5 +/** MCPWM_TIMER0_TEP_INT_CLR : WT; bitpos: [6]; default: 0; + * Set this bit to clear the interrupt triggered by a PWM timer 0 TEP event. + */ +#define MCPWM_TIMER0_TEP_INT_CLR (BIT(6)) +#define MCPWM_TIMER0_TEP_INT_CLR_M (MCPWM_TIMER0_TEP_INT_CLR_V << MCPWM_TIMER0_TEP_INT_CLR_S) +#define MCPWM_TIMER0_TEP_INT_CLR_V 0x00000001U +#define MCPWM_TIMER0_TEP_INT_CLR_S 6 +/** MCPWM_TIMER1_TEP_INT_CLR : WT; bitpos: [7]; default: 0; + * Set this bit to clear the interrupt triggered by a PWM timer 1 TEP event. + */ +#define MCPWM_TIMER1_TEP_INT_CLR (BIT(7)) +#define MCPWM_TIMER1_TEP_INT_CLR_M (MCPWM_TIMER1_TEP_INT_CLR_V << MCPWM_TIMER1_TEP_INT_CLR_S) +#define MCPWM_TIMER1_TEP_INT_CLR_V 0x00000001U +#define MCPWM_TIMER1_TEP_INT_CLR_S 7 +/** MCPWM_TIMER2_TEP_INT_CLR : WT; bitpos: [8]; default: 0; + * Set this bit to clear the interrupt triggered by a PWM timer 2 TEP event. + */ +#define MCPWM_TIMER2_TEP_INT_CLR (BIT(8)) +#define MCPWM_TIMER2_TEP_INT_CLR_M (MCPWM_TIMER2_TEP_INT_CLR_V << MCPWM_TIMER2_TEP_INT_CLR_S) +#define MCPWM_TIMER2_TEP_INT_CLR_V 0x00000001U +#define MCPWM_TIMER2_TEP_INT_CLR_S 8 +/** MCPWM_FAULT0_INT_CLR : WT; bitpos: [9]; default: 0; + * Set this bit to clear the interrupt triggered when fault_event0 starts. + */ +#define MCPWM_FAULT0_INT_CLR (BIT(9)) +#define MCPWM_FAULT0_INT_CLR_M (MCPWM_FAULT0_INT_CLR_V << MCPWM_FAULT0_INT_CLR_S) +#define MCPWM_FAULT0_INT_CLR_V 0x00000001U +#define MCPWM_FAULT0_INT_CLR_S 9 +/** MCPWM_FAULT1_INT_CLR : WT; bitpos: [10]; default: 0; + * Set this bit to clear the interrupt triggered when fault_event1 starts. + */ +#define MCPWM_FAULT1_INT_CLR (BIT(10)) +#define MCPWM_FAULT1_INT_CLR_M (MCPWM_FAULT1_INT_CLR_V << MCPWM_FAULT1_INT_CLR_S) +#define MCPWM_FAULT1_INT_CLR_V 0x00000001U +#define MCPWM_FAULT1_INT_CLR_S 10 +/** MCPWM_FAULT2_INT_CLR : WT; bitpos: [11]; default: 0; + * Set this bit to clear the interrupt triggered when fault_event2 starts. + */ +#define MCPWM_FAULT2_INT_CLR (BIT(11)) +#define MCPWM_FAULT2_INT_CLR_M (MCPWM_FAULT2_INT_CLR_V << MCPWM_FAULT2_INT_CLR_S) +#define MCPWM_FAULT2_INT_CLR_V 0x00000001U +#define MCPWM_FAULT2_INT_CLR_S 11 +/** MCPWM_FAULT0_CLR_INT_CLR : WT; bitpos: [12]; default: 0; + * Set this bit to clear the interrupt triggered when fault_event0 ends. + */ +#define MCPWM_FAULT0_CLR_INT_CLR (BIT(12)) +#define MCPWM_FAULT0_CLR_INT_CLR_M (MCPWM_FAULT0_CLR_INT_CLR_V << MCPWM_FAULT0_CLR_INT_CLR_S) +#define MCPWM_FAULT0_CLR_INT_CLR_V 0x00000001U +#define MCPWM_FAULT0_CLR_INT_CLR_S 12 +/** MCPWM_FAULT1_CLR_INT_CLR : WT; bitpos: [13]; default: 0; + * Set this bit to clear the interrupt triggered when fault_event1 ends. + */ +#define MCPWM_FAULT1_CLR_INT_CLR (BIT(13)) +#define MCPWM_FAULT1_CLR_INT_CLR_M (MCPWM_FAULT1_CLR_INT_CLR_V << MCPWM_FAULT1_CLR_INT_CLR_S) +#define MCPWM_FAULT1_CLR_INT_CLR_V 0x00000001U +#define MCPWM_FAULT1_CLR_INT_CLR_S 13 +/** MCPWM_FAULT2_CLR_INT_CLR : WT; bitpos: [14]; default: 0; + * Set this bit to clear the interrupt triggered when fault_event2 ends. + */ +#define MCPWM_FAULT2_CLR_INT_CLR (BIT(14)) +#define MCPWM_FAULT2_CLR_INT_CLR_M (MCPWM_FAULT2_CLR_INT_CLR_V << MCPWM_FAULT2_CLR_INT_CLR_S) +#define MCPWM_FAULT2_CLR_INT_CLR_V 0x00000001U +#define MCPWM_FAULT2_CLR_INT_CLR_S 14 +/** MCPWM_OP0_TEA_INT_CLR : WT; bitpos: [15]; default: 0; + * Set this bit to clear the interrupt triggered by a PWM operator 0 TEA event + */ +#define MCPWM_OP0_TEA_INT_CLR (BIT(15)) +#define MCPWM_OP0_TEA_INT_CLR_M (MCPWM_OP0_TEA_INT_CLR_V << MCPWM_OP0_TEA_INT_CLR_S) +#define MCPWM_OP0_TEA_INT_CLR_V 0x00000001U +#define MCPWM_OP0_TEA_INT_CLR_S 15 +/** MCPWM_OP1_TEA_INT_CLR : WT; bitpos: [16]; default: 0; + * Set this bit to clear the interrupt triggered by a PWM operator 1 TEA event + */ +#define MCPWM_OP1_TEA_INT_CLR (BIT(16)) +#define MCPWM_OP1_TEA_INT_CLR_M (MCPWM_OP1_TEA_INT_CLR_V << MCPWM_OP1_TEA_INT_CLR_S) +#define MCPWM_OP1_TEA_INT_CLR_V 0x00000001U +#define MCPWM_OP1_TEA_INT_CLR_S 16 +/** MCPWM_OP2_TEA_INT_CLR : WT; bitpos: [17]; default: 0; + * Set this bit to clear the interrupt triggered by a PWM operator 2 TEA event + */ +#define MCPWM_OP2_TEA_INT_CLR (BIT(17)) +#define MCPWM_OP2_TEA_INT_CLR_M (MCPWM_OP2_TEA_INT_CLR_V << MCPWM_OP2_TEA_INT_CLR_S) +#define MCPWM_OP2_TEA_INT_CLR_V 0x00000001U +#define MCPWM_OP2_TEA_INT_CLR_S 17 +/** MCPWM_OP0_TEB_INT_CLR : WT; bitpos: [18]; default: 0; + * Set this bit to clear the interrupt triggered by a PWM operator 0 TEB event + */ +#define MCPWM_OP0_TEB_INT_CLR (BIT(18)) +#define MCPWM_OP0_TEB_INT_CLR_M (MCPWM_OP0_TEB_INT_CLR_V << MCPWM_OP0_TEB_INT_CLR_S) +#define MCPWM_OP0_TEB_INT_CLR_V 0x00000001U +#define MCPWM_OP0_TEB_INT_CLR_S 18 +/** MCPWM_OP1_TEB_INT_CLR : WT; bitpos: [19]; default: 0; + * Set this bit to clear the interrupt triggered by a PWM operator 1 TEB event + */ +#define MCPWM_OP1_TEB_INT_CLR (BIT(19)) +#define MCPWM_OP1_TEB_INT_CLR_M (MCPWM_OP1_TEB_INT_CLR_V << MCPWM_OP1_TEB_INT_CLR_S) +#define MCPWM_OP1_TEB_INT_CLR_V 0x00000001U +#define MCPWM_OP1_TEB_INT_CLR_S 19 +/** MCPWM_OP2_TEB_INT_CLR : WT; bitpos: [20]; default: 0; + * Set this bit to clear the interrupt triggered by a PWM operator 2 TEB event + */ +#define MCPWM_OP2_TEB_INT_CLR (BIT(20)) +#define MCPWM_OP2_TEB_INT_CLR_M (MCPWM_OP2_TEB_INT_CLR_V << MCPWM_OP2_TEB_INT_CLR_S) +#define MCPWM_OP2_TEB_INT_CLR_V 0x00000001U +#define MCPWM_OP2_TEB_INT_CLR_S 20 +/** MCPWM_FH0_CBC_INT_CLR : WT; bitpos: [21]; default: 0; + * Set this bit to clear the interrupt triggered by a cycle-by-cycle mode action on + * PWM0. + */ +#define MCPWM_FH0_CBC_INT_CLR (BIT(21)) +#define MCPWM_FH0_CBC_INT_CLR_M (MCPWM_FH0_CBC_INT_CLR_V << MCPWM_FH0_CBC_INT_CLR_S) +#define MCPWM_FH0_CBC_INT_CLR_V 0x00000001U +#define MCPWM_FH0_CBC_INT_CLR_S 21 +/** MCPWM_FH1_CBC_INT_CLR : WT; bitpos: [22]; default: 0; + * Set this bit to clear the interrupt triggered by a cycle-by-cycle mode action on + * PWM1. + */ +#define MCPWM_FH1_CBC_INT_CLR (BIT(22)) +#define MCPWM_FH1_CBC_INT_CLR_M (MCPWM_FH1_CBC_INT_CLR_V << MCPWM_FH1_CBC_INT_CLR_S) +#define MCPWM_FH1_CBC_INT_CLR_V 0x00000001U +#define MCPWM_FH1_CBC_INT_CLR_S 22 +/** MCPWM_FH2_CBC_INT_CLR : WT; bitpos: [23]; default: 0; + * Set this bit to clear the interrupt triggered by a cycle-by-cycle mode action on + * PWM2. + */ +#define MCPWM_FH2_CBC_INT_CLR (BIT(23)) +#define MCPWM_FH2_CBC_INT_CLR_M (MCPWM_FH2_CBC_INT_CLR_V << MCPWM_FH2_CBC_INT_CLR_S) +#define MCPWM_FH2_CBC_INT_CLR_V 0x00000001U +#define MCPWM_FH2_CBC_INT_CLR_S 23 +/** MCPWM_FH0_OST_INT_CLR : WT; bitpos: [24]; default: 0; + * Set this bit to clear the interrupt triggered by a one-shot mode action on PWM0. + */ +#define MCPWM_FH0_OST_INT_CLR (BIT(24)) +#define MCPWM_FH0_OST_INT_CLR_M (MCPWM_FH0_OST_INT_CLR_V << MCPWM_FH0_OST_INT_CLR_S) +#define MCPWM_FH0_OST_INT_CLR_V 0x00000001U +#define MCPWM_FH0_OST_INT_CLR_S 24 +/** MCPWM_FH1_OST_INT_CLR : WT; bitpos: [25]; default: 0; + * Set this bit to clear the interrupt triggered by a one-shot mode action on PWM1. + */ +#define MCPWM_FH1_OST_INT_CLR (BIT(25)) +#define MCPWM_FH1_OST_INT_CLR_M (MCPWM_FH1_OST_INT_CLR_V << MCPWM_FH1_OST_INT_CLR_S) +#define MCPWM_FH1_OST_INT_CLR_V 0x00000001U +#define MCPWM_FH1_OST_INT_CLR_S 25 +/** MCPWM_FH2_OST_INT_CLR : WT; bitpos: [26]; default: 0; + * Set this bit to clear the interrupt triggered by a one-shot mode action on PWM2. + */ +#define MCPWM_FH2_OST_INT_CLR (BIT(26)) +#define MCPWM_FH2_OST_INT_CLR_M (MCPWM_FH2_OST_INT_CLR_V << MCPWM_FH2_OST_INT_CLR_S) +#define MCPWM_FH2_OST_INT_CLR_V 0x00000001U +#define MCPWM_FH2_OST_INT_CLR_S 26 +/** MCPWM_CAP0_INT_CLR : WT; bitpos: [27]; default: 0; + * Set this bit to clear the interrupt triggered by capture on channel 0. + */ +#define MCPWM_CAP0_INT_CLR (BIT(27)) +#define MCPWM_CAP0_INT_CLR_M (MCPWM_CAP0_INT_CLR_V << MCPWM_CAP0_INT_CLR_S) +#define MCPWM_CAP0_INT_CLR_V 0x00000001U +#define MCPWM_CAP0_INT_CLR_S 27 +/** MCPWM_CAP1_INT_CLR : WT; bitpos: [28]; default: 0; + * Set this bit to clear the interrupt triggered by capture on channel 1. + */ +#define MCPWM_CAP1_INT_CLR (BIT(28)) +#define MCPWM_CAP1_INT_CLR_M (MCPWM_CAP1_INT_CLR_V << MCPWM_CAP1_INT_CLR_S) +#define MCPWM_CAP1_INT_CLR_V 0x00000001U +#define MCPWM_CAP1_INT_CLR_S 28 +/** MCPWM_CAP2_INT_CLR : WT; bitpos: [29]; default: 0; + * Set this bit to clear the interrupt triggered by capture on channel 2. + */ +#define MCPWM_CAP2_INT_CLR (BIT(29)) +#define MCPWM_CAP2_INT_CLR_M (MCPWM_CAP2_INT_CLR_V << MCPWM_CAP2_INT_CLR_S) +#define MCPWM_CAP2_INT_CLR_V 0x00000001U +#define MCPWM_CAP2_INT_CLR_S 29 -#define MCPWM_CLK_REG(i) (REG_MCPWM_BASE(i) + 0x0120) -/* MCPWM_CLK_EN : R/W ;bitpos:[0] ;default: 1'd0 ; */ -/*description: Force clock on for this reg file*/ -#define MCPWM_CLK_EN (BIT(0)) -#define MCPWM_CLK_EN_M (BIT(0)) -#define MCPWM_CLK_EN_V 0x1 +/** MCPWM_CLK_REG register + * MCPWM APB configuration register + */ +#define MCPWM_CLK_REG(i) (DR_REG_MCPWM_BASE(i) + 0x120) +/** MCPWM_CLK_EN : R/W; bitpos: [0]; default: 0; + * Force clock on for this register file + */ +#define MCPWM_CLK_EN (BIT(0)) +#define MCPWM_CLK_EN_M (MCPWM_CLK_EN_V << MCPWM_CLK_EN_S) +#define MCPWM_CLK_EN_V 0x00000001U #define MCPWM_CLK_EN_S 0 -#define MCPWM_VERSION_REG(i) (REG_MCPWM_BASE(i) + 0x0124) -/* MCPWM_DATE : R/W ;bitpos:[27:0] ;default: 28'h1509110 ; */ -/*description: Version of this reg file*/ -#define MCPWM_DATE 0x0FFFFFFF -#define MCPWM_DATE_M ((MCPWM_DATE_V)<<(MCPWM_DATE_S)) -#define MCPWM_DATE_V 0xFFFFFFF +/** MCPWM_VERSION_REG register + * Version register. + */ +#define MCPWM_VERSION_REG(i) (DR_REG_MCPWM_BASE(i) + 0x124) +/** MCPWM_DATE : R/W; bitpos: [27:0]; default: 34632240; + * Version of this register file + */ +#define MCPWM_DATE 0x0FFFFFFFU +#define MCPWM_DATE_M (MCPWM_DATE_V << MCPWM_DATE_S) +#define MCPWM_DATE_V 0x0FFFFFFFU #define MCPWM_DATE_S 0 - - - -#endif /*_SOC_MCPWM_REG_H_ */ +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32/include/soc/esp32/include/soc/mcpwm_struct.h b/tools/sdk/esp32/include/soc/esp32/include/soc/mcpwm_struct.h index 87f3f227272..4e13290fe8f 100644 --- a/tools/sdk/esp32/include/soc/esp32/include/soc/mcpwm_struct.h +++ b/tools/sdk/esp32/include/soc/esp32/include/soc/mcpwm_struct.h @@ -1,461 +1,1468 @@ -// Copyright 2015-2020 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. +/** + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include - #ifdef __cplusplus extern "C" { #endif -typedef volatile struct mcpwm_dev_s { - union { - struct { - uint32_t prescale : 8; /*Period of PWM_clk = 6.25ns * (PWM_CLK_PRESCALE + 1)*/ - uint32_t reserved8 : 24; - }; - uint32_t val; - } clk_cfg; - struct { - union { - struct { - uint32_t prescale : 8; /*period of PT0_clk = Period of PWM_clk * (PWM_TIMER0_PRESCALE + 1)*/ - uint32_t period : 16; /*period shadow reg of PWM timer0*/ - uint32_t upmethod : 2; /*Update method for active reg of PWM timer0 period 0: immediate 1: TEZ 2: sync 3: TEZ | sync. TEZ here and below means timer equal zero event*/ - uint32_t reserved26 : 6; - }; - uint32_t val; - } period; - union { - struct { - uint32_t start : 3; /*PWM timer0 start and stop control. 0: stop @ TEZ 1: stop @ TEP 2: free run 3: start and stop @ next TEZ 4: start and stop @ next TEP. TEP here and below means timer equal period event*/ - uint32_t mode : 2; /*PWM timer0 working mode 0: freeze 1: increase mod 2: decrease mod 3: up-down mod*/ - uint32_t reserved5 : 27; - }; - uint32_t val; - } mode; - union { - struct { - uint32_t in_en : 1; /*when set timer reload with phase on sync input event is enabled*/ - uint32_t sync_sw : 1; /*write the negate value will trigger a software sync*/ - uint32_t out_sel : 2; /*PWM timer0 synco selection 0: synci 1: TEZ 2: TEP else 0*/ - uint32_t timer_phase : 16; /*phase for timer reload on sync event*/ - uint32_t phase_direct : 1; /*counter direction to apply on sync event*/ - uint32_t reserved21 : 11; - }; - uint32_t val; - } sync; - union { - struct { - uint32_t value : 16; /*current PWM timer0 counter value*/ - uint32_t direction : 1; /*current PWM timer0 counter direction 0: increment 1: decrement*/ - uint32_t reserved17 : 15; - }; - uint32_t val; - } status; - } timer[3]; - - union { - struct { - uint32_t t0_in_sel : 3; /*select sync input for PWM timer0 1: PWM timer0 synco 2: PWM timer1 synco 3: PWM timer2 synco 4: SYNC0 from GPIO matrix 5: SYNC1 from GPIO matrix 6: SYNC2 from GPIO matrix else: none*/ - uint32_t t1_in_sel : 3; /*select sync input for PWM timer1 1: PWM timer0 synco 2: PWM timer1 synco 3: PWM timer2 synco 4: SYNC0 from GPIO matrix 5: SYNC1 from GPIO matrix 6: SYNC2 from GPIO matrix else: none*/ - uint32_t t2_in_sel : 3; /*select sync input for PWM timer2 1: PWM timer0 synco 2: PWM timer1 synco 3: PWM timer2 synco 4: SYNC0 from GPIO matrix 5: SYNC1 from GPIO matrix 6: SYNC2 from GPIO matrix else: none*/ - uint32_t ext_in0_inv : 1; /*invert SYNC0 from GPIO matrix*/ - uint32_t ext_in1_inv : 1; /*invert SYNC1 from GPIO matrix*/ - uint32_t ext_in2_inv : 1; /*invert SYNC2 from GPIO matrix*/ - uint32_t reserved12 : 20; - }; - uint32_t val; - } timer_synci_cfg; - union { - struct { - uint32_t operator0_sel : 2; /*Select which PWM timer's is the timing reference for PWM operator0 0: timer0 1: timer1 2: timer2*/ - uint32_t operator1_sel : 2; /*Select which PWM timer's is the timing reference for PWM operator1 0: timer0 1: timer1 2: timer2*/ - uint32_t operator2_sel : 2; /*Select which PWM timer's is the timing reference for PWM operator2 0: timer0 1: timer1 2: timer2*/ - uint32_t reserved6 : 26; - }; - uint32_t val; - } timer_sel; - - struct { - union { - struct { - uint32_t a_upmethod : 4; /*Update method for PWM compare0 A's active reg. 0: immediate bit0: TEZ bit1: TEP bit2: sync bit3: freeze*/ - uint32_t b_upmethod : 4; /*Update method for PWM compare0 B's active reg. 0: immediate bit0: TEZ bit1: TEP bit2: sync bit3: freeze*/ - uint32_t a_shdw_full : 1; /*Set and reset by hardware. If set PWM compare0 A's shadow reg is filled and waiting to be transferred to A's active reg. If cleared A's active reg has been updated with shadow reg latest value*/ - uint32_t b_shdw_full : 1; /*Set and reset by hardware. If set PWM compare0 B's shadow reg is filled and waiting to be transferred to B's active reg. If cleared B's active reg has been updated with shadow reg latest value*/ - uint32_t reserved10 : 22; - }; - uint32_t val; - } cmpr_cfg; - union { - struct { - uint32_t cmpr_val : 16; /*PWM compare0 A's shadow reg*/ - uint32_t reserved16 : 16; - }; - uint32_t val; - } cmpr_value[2]; - union { - struct { - uint32_t upmethod : 4; /*Update method for PWM generate0's active reg of configuration. 0: immediate bit0: TEZ bit1: TEP bit2: sync. bit3: freeze*/ - uint32_t t0_sel : 3; /*Source selection for PWM generate0 event_t0 take effect immediately 0: fault_event0 1: fault_event1 2: fault_event2 3: sync_taken 4: none*/ - uint32_t t1_sel : 3; /*Source selection for PWM generate0 event_t1 take effect immediately 0: fault_event0 1: fault_event1 2: fault_event2 3: sync_taken 4: none*/ - uint32_t reserved10 : 22; - }; - uint32_t val; - } gen_cfg0; - union { - struct { - uint32_t cntu_force_upmethod : 6; /*Update method for continuous software force of PWM generate0. 0: immediate bit0: TEZ bit1: TEP bit2: TEA bit3: TEB bit4: sync bit5: freeze. (TEA/B here and below means timer equals A/B event)*/ - uint32_t a_cntuforce_mode : 2; /*Continuous software force mode for PWM0A. 0: disabled 1: low 2: high 3: disabled*/ - uint32_t b_cntuforce_mode : 2; /*Continuous software force mode for PWM0B. 0: disabled 1: low 2: high 3: disabled*/ - uint32_t a_nciforce : 1; /*non-continuous immediate software force trigger for PWM0A a toggle will trigger a force event*/ - uint32_t a_nciforce_mode : 2; /*non-continuous immediate software force mode for PWM0A 0: disabled 1: low 2: high 3: disabled*/ - uint32_t b_nciforce : 1; /*non-continuous immediate software force trigger for PWM0B a toggle will trigger a force event*/ - uint32_t b_nciforce_mode : 2; /*non-continuous immediate software force mode for PWM0B 0: disabled 1: low 2: high 3: disabled*/ - uint32_t reserved16 : 16; - }; - uint32_t val; - } gen_force; - union { - struct { - uint32_t utez : 2; /*Action on PWM0A triggered by event TEZ when timer increasing*/ - uint32_t utep : 2; /*Action on PWM0A triggered by event TEP when timer increasing*/ - uint32_t utea : 2; /*Action on PWM0A triggered by event TEA when timer increasing*/ - uint32_t uteb : 2; /*Action on PWM0A triggered by event TEB when timer increasing*/ - uint32_t ut0 : 2; /*Action on PWM0A triggered by event_t0 when timer increasing*/ - uint32_t ut1 : 2; /*Action on PWM0A triggered by event_t1 when timer increasing*/ - uint32_t dtez : 2; /*Action on PWM0A triggered by event TEZ when timer decreasing*/ - uint32_t dtep : 2; /*Action on PWM0A triggered by event TEP when timer decreasing*/ - uint32_t dtea : 2; /*Action on PWM0A triggered by event TEA when timer decreasing*/ - uint32_t dteb : 2; /*Action on PWM0A triggered by event TEB when timer decreasing*/ - uint32_t dt0 : 2; /*Action on PWM0A triggered by event_t0 when timer decreasing*/ - uint32_t dt1 : 2; /*Action on PWM0A triggered by event_t1 when timer decreasing. 0: no change 1: low 2: high 3: toggle*/ - uint32_t reserved24 : 8; - }; - uint32_t val; - } generator[2]; - union { - struct { - uint32_t fed_upmethod : 4; /*Update method for FED (falling edge delay) active reg. 0: immediate bit0: tez bit1: tep bit2: sync bit3: freeze*/ - uint32_t red_upmethod : 4; /*Update method for RED (rising edge delay) active reg. 0: immediate bit0: tez bit1: tep bit2: sync bit3: freeze*/ - uint32_t deb_mode : 1; /*S8 in documentation dual-edge B mode 0: fed/red take effect on different path separately 1: fed/red take effect on B path A out is in bypass or dulpB mode*/ - uint32_t a_outswap : 1; /*S6 in documentation*/ - uint32_t b_outswap : 1; /*S7 in documentation*/ - uint32_t red_insel : 1; /*S4 in documentation*/ - uint32_t fed_insel : 1; /*S5 in documentation*/ - uint32_t red_outinvert : 1; /*S2 in documentation*/ - uint32_t fed_outinvert : 1; /*S3 in documentation*/ - uint32_t a_outbypass : 1; /*S1 in documentation*/ - uint32_t b_outbypass : 1; /*S0 in documentation*/ - uint32_t clk_sel : 1; /*Dead band0 clock selection. 0: PWM_clk 1: PT_clk*/ - uint32_t reserved18 : 14; - }; - uint32_t val; - } db_cfg; - union { - struct { - uint32_t fed : 16; /*Shadow reg for FED*/ - uint32_t reserved16 : 16; - }; - uint32_t val; - } db_fed_cfg; - union { - struct { - uint32_t red : 16; /*Shadow reg for RED*/ - uint32_t reserved16 : 16; - }; - uint32_t val; - } db_red_cfg; - union { - struct { - uint32_t en : 1; /*When set carrier0 function is enabled. When reset carrier0 is bypassed*/ - uint32_t prescale : 4; /*carrier0 clk (CP_clk) prescale value. Period of CP_clk = period of PWM_clk * (PWM_CARRIER0_PRESCALE + 1)*/ - uint32_t duty : 3; /*carrier duty selection. Duty = PWM_CARRIER0_DUTY / 8*/ - uint32_t oshtwth : 4; /*width of the fist pulse in number of periods of the carrier*/ - uint32_t out_invert : 1; /*when set invert the output of PWM0A and PWM0B for this submodule*/ - uint32_t in_invert : 1; /*when set invert the input of PWM0A and PWM0B for this submodule*/ - uint32_t reserved14 : 18; - }; - uint32_t val; - } carrier_cfg; - union { - struct { - uint32_t sw_cbc : 1; /*Cycle-by-cycle tripping software force event will trigger cycle-by-cycle trip event. 0: disable 1: enable*/ - uint32_t f2_cbc : 1; /*event_f2 will trigger cycle-by-cycle trip event. 0: disable 1: enable*/ - uint32_t f1_cbc : 1; /*event_f1 will trigger cycle-by-cycle trip event. 0: disable 1: enable*/ - uint32_t f0_cbc : 1; /*event_f0 will trigger cycle-by-cycle trip event. 0: disable 1: enable*/ - uint32_t sw_ost : 1; /*one-shot tripping software force event will trigger one-shot trip event. 0: disable 1: enable*/ - uint32_t f2_ost : 1; /*event_f2 will trigger one-shot trip event. 0: disable 1: enable*/ - uint32_t f1_ost : 1; /*event_f1 will trigger one-shot trip event. 0: disable 1: enable*/ - uint32_t f0_ost : 1; /*event_f0 will trigger one-shot trip event. 0: disable 1: enable*/ - uint32_t a_cbc_d : 2; /*Action on PWM0A when cycle-by-cycle trip event occurs and timer is decreasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ - uint32_t a_cbc_u : 2; /*Action on PWM0A when cycle-by-cycle trip event occurs and timer is increasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ - uint32_t a_ost_d : 2; /*Action on PWM0A when one-shot trip event occurs and timer is decreasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ - uint32_t a_ost_u : 2; /*Action on PWM0A when one-shot trip event occurs and timer is increasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ - uint32_t b_cbc_d : 2; /*Action on PWM0B when cycle-by-cycle trip event occurs and timer is decreasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ - uint32_t b_cbc_u : 2; /*Action on PWM0B when cycle-by-cycle trip event occurs and timer is increasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ - uint32_t b_ost_d : 2; /*Action on PWM0B when one-shot trip event occurs and timer is decreasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ - uint32_t b_ost_u : 2; /*Action on PWM0B when one-shot trip event occurs and timer is increasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/ - uint32_t reserved24 : 8; - }; - uint32_t val; - } tz_cfg0; - union { - struct { - uint32_t clr_ost : 1; /*a posedge will clear on going one-shot tripping*/ - uint32_t cbcpulse : 2; /*cycle-by-cycle tripping refresh moment selection. Bit0: TEZ bit1:TEP*/ - uint32_t force_cbc : 1; /*a toggle trigger a cycle-by-cycle tripping software force event*/ - uint32_t force_ost : 1; /*a toggle (software negate its value) trigger a one-shot tripping software force event*/ - uint32_t reserved5 : 27; - }; - uint32_t val; - } tz_cfg1; - union { - struct { - uint32_t cbc_on : 1; /*Set and reset by hardware. If set an cycle-by-cycle trip event is on going*/ - uint32_t ost_on : 1; /*Set and reset by hardware. If set an one-shot trip event is on going*/ - uint32_t reserved2 : 30; - }; - uint32_t val; - } tz_status; - } channel[3]; - - union { - struct { - uint32_t f0_en : 1; /*When set event_f0 generation is enabled*/ - uint32_t f1_en : 1; /*When set event_f1 generation is enabled*/ - uint32_t f2_en : 1; /*When set event_f2 generation is enabled*/ - uint32_t f0_pole : 1; /*Set event_f0 trigger polarity on FAULT0 source from GPIO matrix. 0: level low 1: level high*/ - uint32_t f1_pole : 1; /*Set event_f1 trigger polarity on FAULT1 source from GPIO matrix. 0: level low 1: level high*/ - uint32_t f2_pole : 1; /*Set event_f2 trigger polarity on FAULT2 source from GPIO matrix. 0: level low 1: level high*/ - uint32_t event_f0 : 1; /*Set and reset by hardware. If set event_f0 is on going*/ - uint32_t event_f1 : 1; /*Set and reset by hardware. If set event_f1 is on going*/ - uint32_t event_f2 : 1; /*Set and reset by hardware. If set event_f2 is on going*/ - uint32_t reserved9 : 23; - }; - uint32_t val; - } fault_detect; - union { - struct { - uint32_t timer_en : 1; /*When set capture timer incrementing under APB_clk is enabled.*/ - uint32_t synci_en : 1; /*When set capture timer sync is enabled.*/ - uint32_t synci_sel : 3; /*capture module sync input selection. 0: none 1: timer0 synco 2: timer1 synco 3: timer2 synco 4: SYNC0 from GPIO matrix 5: SYNC1 from GPIO matrix 6: SYNC2 from GPIO matrix*/ - uint32_t sync_sw : 1; /*Write 1 will force a capture timer sync capture timer is loaded with value in phase register.*/ - uint32_t reserved6 : 26; - }; - uint32_t val; - } cap_timer_cfg; - uint32_t cap_timer_phase; /*Phase value for capture timer sync operation.*/ - union { - struct { - uint32_t en : 1; /*When set capture on channel 0 is enabled*/ - uint32_t mode : 2; /*Edge of capture on channel 0 after prescale. bit0: negedge cap en bit1: posedge cap en*/ - uint32_t prescale : 8; /*Value of prescale on possitive edge of CAP0. Prescale value = PWM_CAP0_PRESCALE + 1*/ - uint32_t in_invert : 1; /*when set CAP0 form GPIO matrix is inverted before prescale*/ - uint32_t sw : 1; /*Write 1 will trigger a software forced capture on channel 0*/ - uint32_t reserved13 : 19; - }; - uint32_t val; - } cap_cfg_ch[3]; - uint32_t cap_val_ch[3]; /*Value of last capture on channel 0*/ - union { - struct { - uint32_t cap0_edge : 1; /*Edge of last capture trigger on channel 0 0: posedge 1: negedge*/ - uint32_t cap1_edge : 1; /*Edge of last capture trigger on channel 1 0: posedge 1: negedge*/ - uint32_t cap2_edge : 1; /*Edge of last capture trigger on channel 2 0: posedge 1: negedge*/ - uint32_t reserved3 : 29; - }; - uint32_t val; - } cap_status; - union { - struct { - uint32_t global_up_en : 1; /*The global enable of update of all active registers in MCPWM module*/ - uint32_t global_force_up : 1; /*a toggle (software invert its value) will trigger a forced update of all active registers in MCPWM module*/ - uint32_t op0_up_en : 1; /*When set and PWM_GLOBAL_UP_EN is set update of active registers in PWM operator 0 are enabled*/ - uint32_t op0_force_up : 1; /*a toggle (software invert its value) will trigger a forced update of active registers in PWM operator 0*/ - uint32_t op1_up_en : 1; /*When set and PWM_GLOBAL_UP_EN is set update of active registers in PWM operator 1 are enabled*/ - uint32_t op1_force_up : 1; /*a toggle (software invert its value) will trigger a forced update of active registers in PWM operator 1*/ - uint32_t op2_up_en : 1; /*When set and PWM_GLOBAL_UP_EN is set update of active registers in PWM operator 2 are enabled*/ - uint32_t op2_force_up : 1; /*a toggle (software invert its value) will trigger a forced update of active registers in PWM operator 2*/ - uint32_t reserved8 : 24; - }; - uint32_t val; - } update_cfg; - union { - struct { - uint32_t timer0_stop_int_ena : 1; /*Interrupt when timer 0 stops*/ - uint32_t timer1_stop_int_ena : 1; /*Interrupt when timer 1 stops*/ - uint32_t timer2_stop_int_ena : 1; /*Interrupt when timer 2 stops*/ - uint32_t timer0_tez_int_ena : 1; /*A PWM timer 0 TEZ event will trigger this interrupt*/ - uint32_t timer1_tez_int_ena : 1; /*A PWM timer 1 TEZ event will trigger this interrupt*/ - uint32_t timer2_tez_int_ena : 1; /*A PWM timer 2 TEZ event will trigger this interrupt*/ - uint32_t timer0_tep_int_ena : 1; /*A PWM timer 0 TEP event will trigger this interrupt*/ - uint32_t timer1_tep_int_ena : 1; /*A PWM timer 1 TEP event will trigger this interrupt*/ - uint32_t timer2_tep_int_ena : 1; /*A PWM timer 2 TEP event will trigger this interrupt*/ - uint32_t fault0_int_ena : 1; /*Interrupt when event_f0 starts*/ - uint32_t fault1_int_ena : 1; /*Interrupt when event_f1 starts*/ - uint32_t fault2_int_ena : 1; /*Interrupt when event_f2 starts*/ - uint32_t fault0_clr_int_ena : 1; /*Interrupt when event_f0 ends*/ - uint32_t fault1_clr_int_ena : 1; /*Interrupt when event_f1 ends*/ - uint32_t fault2_clr_int_ena : 1; /*Interrupt when event_f2 ends*/ - uint32_t cmpr0_tea_int_ena : 1; /*A PWM operator 0 TEA event will trigger this interrupt*/ - uint32_t cmpr1_tea_int_ena : 1; /*A PWM operator 1 TEA event will trigger this interrupt*/ - uint32_t cmpr2_tea_int_ena : 1; /*A PWM operator 2 TEA event will trigger this interrupt*/ - uint32_t cmpr0_teb_int_ena : 1; /*A PWM operator 0 TEB event will trigger this interrupt*/ - uint32_t cmpr1_teb_int_ena : 1; /*A PWM operator 1 TEB event will trigger this interrupt*/ - uint32_t cmpr2_teb_int_ena : 1; /*A PWM operator 2 TEB event will trigger this interrupt*/ - uint32_t tz0_cbc_int_ena : 1; /*An cycle-by-cycle trip event on PWM0 will trigger this interrupt*/ - uint32_t tz1_cbc_int_ena : 1; /*An cycle-by-cycle trip event on PWM1 will trigger this interrupt*/ - uint32_t tz2_cbc_int_ena : 1; /*An cycle-by-cycle trip event on PWM2 will trigger this interrupt*/ - uint32_t tz0_ost_int_ena : 1; /*An one-shot trip event on PWM0 will trigger this interrupt*/ - uint32_t tz1_ost_int_ena : 1; /*An one-shot trip event on PWM1 will trigger this interrupt*/ - uint32_t tz2_ost_int_ena : 1; /*An one-shot trip event on PWM2 will trigger this interrupt*/ - uint32_t cap0_int_ena : 1; /*A capture on channel 0 will trigger this interrupt*/ - uint32_t cap1_int_ena : 1; /*A capture on channel 1 will trigger this interrupt*/ - uint32_t cap2_int_ena : 1; /*A capture on channel 2 will trigger this interrupt*/ - uint32_t reserved30 : 2; - }; - uint32_t val; - } int_ena; - union { - struct { - uint32_t timer0_stop_int_raw : 1; /*Interrupt when timer 0 stops*/ - uint32_t timer1_stop_int_raw : 1; /*Interrupt when timer 1 stops*/ - uint32_t timer2_stop_int_raw : 1; /*Interrupt when timer 2 stops*/ - uint32_t timer0_tez_int_raw : 1; /*A PWM timer 0 TEZ event will trigger this interrupt*/ - uint32_t timer1_tez_int_raw : 1; /*A PWM timer 1 TEZ event will trigger this interrupt*/ - uint32_t timer2_tez_int_raw : 1; /*A PWM timer 2 TEZ event will trigger this interrupt*/ - uint32_t timer0_tep_int_raw : 1; /*A PWM timer 0 TEP event will trigger this interrupt*/ - uint32_t timer1_tep_int_raw : 1; /*A PWM timer 1 TEP event will trigger this interrupt*/ - uint32_t timer2_tep_int_raw : 1; /*A PWM timer 2 TEP event will trigger this interrupt*/ - uint32_t fault0_int_raw : 1; /*Interrupt when event_f0 starts*/ - uint32_t fault1_int_raw : 1; /*Interrupt when event_f1 starts*/ - uint32_t fault2_int_raw : 1; /*Interrupt when event_f2 starts*/ - uint32_t fault0_clr_int_raw : 1; /*Interrupt when event_f0 ends*/ - uint32_t fault1_clr_int_raw : 1; /*Interrupt when event_f1 ends*/ - uint32_t fault2_clr_int_raw : 1; /*Interrupt when event_f2 ends*/ - uint32_t cmpr0_tea_int_raw : 1; /*A PWM operator 0 TEA event will trigger this interrupt*/ - uint32_t cmpr1_tea_int_raw : 1; /*A PWM operator 1 TEA event will trigger this interrupt*/ - uint32_t cmpr2_tea_int_raw : 1; /*A PWM operator 2 TEA event will trigger this interrupt*/ - uint32_t cmpr0_teb_int_raw : 1; /*A PWM operator 0 TEB event will trigger this interrupt*/ - uint32_t cmpr1_teb_int_raw : 1; /*A PWM operator 1 TEB event will trigger this interrupt*/ - uint32_t cmpr2_teb_int_raw : 1; /*A PWM operator 2 TEB event will trigger this interrupt*/ - uint32_t tz0_cbc_int_raw : 1; /*An cycle-by-cycle trip event on PWM0 will trigger this interrupt*/ - uint32_t tz1_cbc_int_raw : 1; /*An cycle-by-cycle trip event on PWM1 will trigger this interrupt*/ - uint32_t tz2_cbc_int_raw : 1; /*An cycle-by-cycle trip event on PWM2 will trigger this interrupt*/ - uint32_t tz0_ost_int_raw : 1; /*An one-shot trip event on PWM0 will trigger this interrupt*/ - uint32_t tz1_ost_int_raw : 1; /*An one-shot trip event on PWM1 will trigger this interrupt*/ - uint32_t tz2_ost_int_raw : 1; /*An one-shot trip event on PWM2 will trigger this interrupt*/ - uint32_t cap0_int_raw : 1; /*A capture on channel 0 will trigger this interrupt*/ - uint32_t cap1_int_raw : 1; /*A capture on channel 1 will trigger this interrupt*/ - uint32_t cap2_int_raw : 1; /*A capture on channel 2 will trigger this interrupt*/ - uint32_t reserved30 : 2; - }; - uint32_t val; - } int_raw; - union { - struct { - uint32_t timer0_stop_int_st : 1; /*Interrupt when timer 0 stops*/ - uint32_t timer1_stop_int_st : 1; /*Interrupt when timer 1 stops*/ - uint32_t timer2_stop_int_st : 1; /*Interrupt when timer 2 stops*/ - uint32_t timer0_tez_int_st : 1; /*A PWM timer 0 TEZ event will trigger this interrupt*/ - uint32_t timer1_tez_int_st : 1; /*A PWM timer 1 TEZ event will trigger this interrupt*/ - uint32_t timer2_tez_int_st : 1; /*A PWM timer 2 TEZ event will trigger this interrupt*/ - uint32_t timer0_tep_int_st : 1; /*A PWM timer 0 TEP event will trigger this interrupt*/ - uint32_t timer1_tep_int_st : 1; /*A PWM timer 1 TEP event will trigger this interrupt*/ - uint32_t timer2_tep_int_st : 1; /*A PWM timer 2 TEP event will trigger this interrupt*/ - uint32_t fault0_int_st : 1; /*Interrupt when event_f0 starts*/ - uint32_t fault1_int_st : 1; /*Interrupt when event_f1 starts*/ - uint32_t fault2_int_st : 1; /*Interrupt when event_f2 starts*/ - uint32_t fault0_clr_int_st : 1; /*Interrupt when event_f0 ends*/ - uint32_t fault1_clr_int_st : 1; /*Interrupt when event_f1 ends*/ - uint32_t fault2_clr_int_st : 1; /*Interrupt when event_f2 ends*/ - uint32_t cmpr0_tea_int_st : 1; /*A PWM operator 0 TEA event will trigger this interrupt*/ - uint32_t cmpr1_tea_int_st : 1; /*A PWM operator 1 TEA event will trigger this interrupt*/ - uint32_t cmpr2_tea_int_st : 1; /*A PWM operator 2 TEA event will trigger this interrupt*/ - uint32_t cmpr0_teb_int_st : 1; /*A PWM operator 0 TEB event will trigger this interrupt*/ - uint32_t cmpr1_teb_int_st : 1; /*A PWM operator 1 TEB event will trigger this interrupt*/ - uint32_t cmpr2_teb_int_st : 1; /*A PWM operator 2 TEB event will trigger this interrupt*/ - uint32_t tz0_cbc_int_st : 1; /*An cycle-by-cycle trip event on PWM0 will trigger this interrupt*/ - uint32_t tz1_cbc_int_st : 1; /*An cycle-by-cycle trip event on PWM1 will trigger this interrupt*/ - uint32_t tz2_cbc_int_st : 1; /*An cycle-by-cycle trip event on PWM2 will trigger this interrupt*/ - uint32_t tz0_ost_int_st : 1; /*An one-shot trip event on PWM0 will trigger this interrupt*/ - uint32_t tz1_ost_int_st : 1; /*An one-shot trip event on PWM1 will trigger this interrupt*/ - uint32_t tz2_ost_int_st : 1; /*An one-shot trip event on PWM2 will trigger this interrupt*/ - uint32_t cap0_int_st : 1; /*A capture on channel 0 will trigger this interrupt*/ - uint32_t cap1_int_st : 1; /*A capture on channel 1 will trigger this interrupt*/ - uint32_t cap2_int_st : 1; /*A capture on channel 2 will trigger this interrupt*/ - uint32_t reserved30 : 2; - }; - uint32_t val; - } int_st; - union { - struct { - uint32_t timer0_stop_int_clr : 1; /*Interrupt when timer 0 stops*/ - uint32_t timer1_stop_int_clr : 1; /*Interrupt when timer 1 stops*/ - uint32_t timer2_stop_int_clr : 1; /*Interrupt when timer 2 stops*/ - uint32_t timer0_tez_int_clr : 1; /*A PWM timer 0 TEZ event will trigger this interrupt*/ - uint32_t timer1_tez_int_clr : 1; /*A PWM timer 1 TEZ event will trigger this interrupt*/ - uint32_t timer2_tez_int_clr : 1; /*A PWM timer 2 TEZ event will trigger this interrupt*/ - uint32_t timer0_tep_int_clr : 1; /*A PWM timer 0 TEP event will trigger this interrupt*/ - uint32_t timer1_tep_int_clr : 1; /*A PWM timer 1 TEP event will trigger this interrupt*/ - uint32_t timer2_tep_int_clr : 1; /*A PWM timer 2 TEP event will trigger this interrupt*/ - uint32_t fault0_int_clr : 1; /*Interrupt when event_f0 starts*/ - uint32_t fault1_int_clr : 1; /*Interrupt when event_f1 starts*/ - uint32_t fault2_int_clr : 1; /*Interrupt when event_f2 starts*/ - uint32_t fault0_clr_int_clr : 1; /*Interrupt when event_f0 ends*/ - uint32_t fault1_clr_int_clr : 1; /*Interrupt when event_f1 ends*/ - uint32_t fault2_clr_int_clr : 1; /*Interrupt when event_f2 ends*/ - uint32_t cmpr0_tea_int_clr : 1; /*A PWM operator 0 TEA event will trigger this interrupt*/ - uint32_t cmpr1_tea_int_clr : 1; /*A PWM operator 1 TEA event will trigger this interrupt*/ - uint32_t cmpr2_tea_int_clr : 1; /*A PWM operator 2 TEA event will trigger this interrupt*/ - uint32_t cmpr0_teb_int_clr : 1; /*A PWM operator 0 TEB event will trigger this interrupt*/ - uint32_t cmpr1_teb_int_clr : 1; /*A PWM operator 1 TEB event will trigger this interrupt*/ - uint32_t cmpr2_teb_int_clr : 1; /*A PWM operator 2 TEB event will trigger this interrupt*/ - uint32_t tz0_cbc_int_clr : 1; /*An cycle-by-cycle trip event on PWM0 will trigger this interrupt*/ - uint32_t tz1_cbc_int_clr : 1; /*An cycle-by-cycle trip event on PWM1 will trigger this interrupt*/ - uint32_t tz2_cbc_int_clr : 1; /*An cycle-by-cycle trip event on PWM2 will trigger this interrupt*/ - uint32_t tz0_ost_int_clr : 1; /*An one-shot trip event on PWM0 will trigger this interrupt*/ - uint32_t tz1_ost_int_clr : 1; /*An one-shot trip event on PWM1 will trigger this interrupt*/ - uint32_t tz2_ost_int_clr : 1; /*An one-shot trip event on PWM2 will trigger this interrupt*/ - uint32_t cap0_int_clr : 1; /*A capture on channel 0 will trigger this interrupt*/ - uint32_t cap1_int_clr : 1; /*A capture on channel 1 will trigger this interrupt*/ - uint32_t cap2_int_clr : 1; /*A capture on channel 2 will trigger this interrupt*/ - uint32_t reserved30 : 2; - }; - uint32_t val; - } int_clr; - union { - struct { - uint32_t clk_en : 1; /*Force clock on for this reg file*/ - uint32_t reserved1 : 31; - }; - uint32_t val; - } reg_clk; - union { - struct { - uint32_t date : 28; /*Version of this reg file*/ - uint32_t reserved28 : 4; - }; - uint32_t val; - } version; +/** Group: Prescaler configuration */ +/** Type of clk_cfg register + * PWM clock prescaler register. + */ +typedef union { + struct { + /** clk_prescale : R/W; bitpos: [7:0]; default: 0; + * Period of PWM_clk = 6.25ns * (PWM_CLK_PRESCALE + 1) + */ + uint32_t clk_prescale: 8; + uint32_t reserved_8: 24; + }; + uint32_t val; +} mcpwm_clk_cfg_reg_t; + + +/** Group: MCPWM Timer Configuration and status */ +/** Type of timer_cfg0 register + * PWM timer period and update method configuration register. + */ +typedef union { + struct { + /** timer_prescale : R/W; bitpos: [7:0]; default: 0; + * Configure the divisor of PT0_clk, takes effect when PWM timer stops and starts + * agsin. period of PT0_clk = Period of PWM_clk * (PWM_TIMER_PRESCALE + 1) + */ + uint32_t timer_prescale: 8; + /** timer_period : R/W; bitpos: [23:8]; default: 255; + * period shadow register of PWM timer + */ + uint32_t timer_period: 16; + /** timer_period_upmethod : R/W; bitpos: [25:24]; default: 0; + * Update method for active register of PWM timer period, 0: immediate, 1: TEZ, 2: + * sync, 3: TEZ or sync. TEZ here and below means timer equal zero event + */ + uint32_t timer_period_upmethod: 2; + uint32_t reserved_26: 6; + }; + uint32_t val; +} mcpwm_timer_cfg0_reg_t; + +/** Type of timer_cfg1 register + * PWM timer working mode and start/stop control configuration register. + */ +typedef union { + struct { + /** timer_start : R/W/SC; bitpos: [2:0]; default: 0; + * PWM timer start and stop control. 0: if PWM timer starts, then stops at TEZ, 1: + * if timer starts, then stops at TEP, 2: PWM timer starts and runs on, 3: timer + * starts and stops at the next TEZ, 4: timer starts and stops at the next TEP. TEP + * here and below means the event that happens when the timer equals to period + */ + uint32_t timer_start: 3; + /** timer_mod : R/W; bitpos: [4:3]; default: 0; + * PWM timer working mode, 0: freeze, 1: increase mode, 2: decrease mode, 3: up-down + * mode + */ + uint32_t timer_mod: 2; + uint32_t reserved_5: 27; + }; + uint32_t val; +} mcpwm_timer_cfg1_reg_t; + +/** Type of timer_sync register + * PWM timer sync function configuration register. + */ +typedef union { + struct { + /** timer_synci_en : R/W; bitpos: [0]; default: 0; + * When set, timer reloading with phase on sync input event is enabled. + */ + uint32_t timer_synci_en: 1; + /** timer_sync_sw : R/W; bitpos: [1]; default: 0; + * Toggling this bit will trigger a software sync. + */ + uint32_t timer_sync_sw: 1; + /** timer_synco_sel : R/W; bitpos: [3:2]; default: 0; + * PWM timer sync_out selection, 0: sync_in, 1: TEZ, 2: TEP, and sync out will always + * generate when toggling the reg_timer_sync_sw bit + */ + uint32_t timer_synco_sel: 2; + /** timer_phase : R/W; bitpos: [19:4]; default: 0; + * phase for timer reload on sync event + */ + uint32_t timer_phase: 16; + /** timer_phase_direction : R/W; bitpos: [20]; default: 0; + * Configure the PWM timer's direction at the time sync event occurs when timer mode + * is up-down mode: 0-increase,1-decrease + */ + uint32_t timer_phase_direction: 1; + uint32_t reserved_21: 11; + }; + uint32_t val; +} mcpwm_timer_sync_reg_t; + +/** Type of timer_status register + * PWM timer status register. + */ +typedef union { + struct { + /** timer_value : RO; bitpos: [15:0]; default: 0; + * current PWM timer counter value + */ + uint32_t timer_value: 16; + /** timer_direction : RO; bitpos: [16]; default: 0; + * current PWM timer counter direction, 0: increment 1: decrement + */ + uint32_t timer_direction: 1; + uint32_t reserved_17: 15; + }; + uint32_t val; +} mcpwm_timer_status_reg_t; + + +/** Group: Common configuration for MCPWM timers */ +/** Type of timer_synci_cfg register + * Synchronization input selection for three PWM timers. + */ +typedef union { + struct { + /** timer0_syncisel : R/W; bitpos: [2:0]; default: 0; + * select sync input for PWM timer0, 1: PWM timer0 sync_out, 2: PWM timer1 sync_out, + * 3: PWM timer2 sync_out, 4: SYNC0 from GPIO matrix, 5: SYNC1 from GPIO matrix, 6: + * SYNC2 from GPIO matrix, other values: no sync input selected + */ + uint32_t timer0_syncisel: 3; + /** timer1_syncisel : R/W; bitpos: [5:3]; default: 0; + * select sync input for PWM timer1, 1: PWM timer0 sync_out, 2: PWM timer1 sync_out, + * 3: PWM timer2 sync_out, 4: SYNC0 from GPIO matrix, 5: SYNC1 from GPIO matrix, 6: + * SYNC2 from GPIO matrix, other values: no sync input selected + */ + uint32_t timer1_syncisel: 3; + /** timer2_syncisel : R/W; bitpos: [8:6]; default: 0; + * select sync input for PWM timer2, 1: PWM timer0 sync_out, 2: PWM timer1 sync_out, + * 3: PWM timer2 sync_out, 4: SYNC0 from GPIO matrix, 5: SYNC1 from GPIO matrix, 6: + * SYNC2 from GPIO matrix, other values: no sync input selected + */ + uint32_t timer2_syncisel: 3; + /** external_synci0_invert : R/W; bitpos: [9]; default: 0; + * invert SYNC0 from GPIO matrix + */ + uint32_t external_synci0_invert: 1; + /** external_synci1_invert : R/W; bitpos: [10]; default: 0; + * invert SYNC1 from GPIO matrix + */ + uint32_t external_synci1_invert: 1; + /** external_synci2_invert : R/W; bitpos: [11]; default: 0; + * invert SYNC2 from GPIO matrix + */ + uint32_t external_synci2_invert: 1; + uint32_t reserved_12: 20; + }; + uint32_t val; +} mcpwm_timer_synci_cfg_reg_t; + +/** Type of operator_timersel register + * Select specific timer for PWM operators. + */ +typedef union { + struct { + /** operator0_timersel : R/W; bitpos: [1:0]; default: 0; + * Select which PWM timer is the timing reference for PWM operator0, 0: timer0, 1: + * timer1, 2: timer2 + */ + uint32_t operator0_timersel: 2; + /** operator1_timersel : R/W; bitpos: [3:2]; default: 0; + * Select which PWM timer is the timing reference for PWM operator1, 0: timer0, 1: + * timer1, 2: timer2 + */ + uint32_t operator1_timersel: 2; + /** operator2_timersel : R/W; bitpos: [5:4]; default: 0; + * Select which PWM timer is the timing reference for PWM operator2, 0: timer0, 1: + * timer1, 2: timer2 + */ + uint32_t operator2_timersel: 2; + uint32_t reserved_6: 26; + }; + uint32_t val; +} mcpwm_operator_timersel_reg_t; + + +/** Group: MCPWM Operator Configuration and Status */ +/** Type of gen_stmp_cfg register + * Transfer status and update method for time stamp registers A and B + */ +typedef union { + struct { + /** gen_a_upmethod : R/W; bitpos: [3:0]; default: 0; + * Update method for PWM generator time stamp A's active register. When all bits are + * set to 0: immediately, when bit0 is set to 1: TEZ, when bit1 is set to 1: TEP,when + * bit2 is set to 1: sync, when bit3 is set to 1: disable the update. + */ + uint32_t gen_a_upmethod: 4; + /** gen_b_upmethod : R/W; bitpos: [7:4]; default: 0; + * Update method for PWM generator time stamp B's active register. When all bits are + * set to 0: immediately, when bit0 is set to 1: TEZ, when bit1 is set to 1: TEP,when + * bit2 is set to 1: sync, when bit3 is set to 1: disable the update. + */ + uint32_t gen_b_upmethod: 4; + /** gen_a_shdw_full : R/W/WTC/SC; bitpos: [8]; default: 0; + * Set and reset by hardware. If set, PWM generator time stamp A's shadow reg is + * filled and waiting to be transferred to A's active reg. If cleared, A's active reg + * has been updated with shadow register latest value + */ + uint32_t gen_a_shdw_full: 1; + /** gen_b_shdw_full : R/W/WTC/SC; bitpos: [9]; default: 0; + * Set and reset by hardware. If set, PWM generator time stamp B's shadow reg is + * filled and waiting to be transferred to B's active reg. If cleared, B's active reg + * has been updated with shadow register latest value + */ + uint32_t gen_b_shdw_full: 1; + uint32_t reserved_10: 22; + }; + uint32_t val; +} mcpwm_gen_stmp_cfg_reg_t; + +/** Type of gen_tstmp register + * PWM generator shadow register for timer stamp + */ +typedef union { + struct { + /** gen : R/W; bitpos: [15:0]; default: 0; + * PWM generator time stamp's shadow register + */ + uint32_t gen: 16; + uint32_t reserved_16: 16; + }; + uint32_t val; +} mcpwm_gen_tstmp_reg_t; + +/** Type of gen_cfg0 register + * PWM generator event T0 and T1 handling + */ +typedef union { + struct { + /** gen_cfg_upmethod : R/W; bitpos: [3:0]; default: 0; + * Update method for PWM generator's active register of configuration. When all bits + * are set to 0: immediately, when bit0 is set to 1: TEZ, when bit1 is set to + * 1:TEP,when bit2 is set to 1:sync,when bit3 is set to 1:disable the update + */ + uint32_t gen_cfg_upmethod: 4; + /** gen_t0_sel : R/W; bitpos: [6:4]; default: 0; + * Source selection for PWM generator event_t0, take effect immediately, 0: + * fault_event0, 1: fault_event1, 2: fault_event2, 3: sync_taken, 4: none + */ + uint32_t gen_t0_sel: 3; + /** gen_t1_sel : R/W; bitpos: [9:7]; default: 0; + * Source selection for PWM generator event_t1, take effect immediately, 0: + * fault_event0, 1: fault_event1, 2: fault_event2, 3: sync_taken, 4: none + */ + uint32_t gen_t1_sel: 3; + uint32_t reserved_10: 22; + }; + uint32_t val; +} mcpwm_gen_cfg0_reg_t; + +/** Type of gen_force register + * Permissives to force PWM0A and PWM0B outputs by software + */ +typedef union { + struct { + /** gen_cntuforce_upmethod : R/W; bitpos: [5:0]; default: 32; + * Updating method for continuous software force of PWM generator0. When all bits are + * set to 0: immediately, when bit0 is set to 1: TEZ,,when bit1 is set to 1: TEP, when + * bit2 is set to 1: TEA, when bit3 is set to 1: TEB, when bit4 is set to 1: sync, + * when bit5 is set to 1: disable update. (TEA/B here and below means an event + * generated when the timer's value equals to that of register A/B.) + */ + uint32_t gen_cntuforce_upmethod: 6; + /** gen_a_cntuforce_mode : R/W; bitpos: [7:6]; default: 0; + * Continuous software force mode for PWM0A. 0: disabled, 1: low, 2: high, 3: disabled + */ + uint32_t gen_a_cntuforce_mode: 2; + /** gen_b_cntuforce_mode : R/W; bitpos: [9:8]; default: 0; + * Continuous software force mode for PWM0B. 0: disabled, 1: low, 2: high, 3: disabled + */ + uint32_t gen_b_cntuforce_mode: 2; + /** gen_a_nciforce : R/W; bitpos: [10]; default: 0; + * Trigger of non-continuous immediate software-force event for PWM0A, a toggle will + * trigger a force event. + */ + uint32_t gen_a_nciforce: 1; + /** gen_a_nciforce_mode : R/W; bitpos: [12:11]; default: 0; + * non-continuous immediate software force mode for PWM0A, 0: disabled, 1: low, 2: + * high, 3: disabled + */ + uint32_t gen_a_nciforce_mode: 2; + /** gen_b_nciforce : R/W; bitpos: [13]; default: 0; + * Trigger of non-continuous immediate software-force event for PWM0B, a toggle will + * trigger a force event. + */ + uint32_t gen_b_nciforce: 1; + /** gen_b_nciforce_mode : R/W; bitpos: [15:14]; default: 0; + * non-continuous immediate software force mode for PWM0B, 0: disabled, 1: low, 2: + * high, 3: disabled + */ + uint32_t gen_b_nciforce_mode: 2; + uint32_t reserved_16: 16; + }; + uint32_t val; +} mcpwm_gen_force_reg_t; + +/** Type of generator register + * Actions triggered by events on PWM0A + */ +typedef union { + struct { + /** gen_utez : R/W; bitpos: [1:0]; default: 0; + * Action on PWM0A triggered by event TEZ when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ + uint32_t gen_utez: 2; + /** gen_utep : R/W; bitpos: [3:2]; default: 0; + * Action on PWM0A triggered by event TEP when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ + uint32_t gen_utep: 2; + /** gen_utea : R/W; bitpos: [5:4]; default: 0; + * Action on PWM0A triggered by event TEA when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ + uint32_t gen_utea: 2; + /** gen_uteb : R/W; bitpos: [7:6]; default: 0; + * Action on PWM0A triggered by event TEB when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ + uint32_t gen_uteb: 2; + /** gen_ut0 : R/W; bitpos: [9:8]; default: 0; + * Action on PWM0A triggered by event_t0 when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ + uint32_t gen_ut0: 2; + /** gen_ut1 : R/W; bitpos: [11:10]; default: 0; + * Action on PWM0A triggered by event_t1 when timer increasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ + uint32_t gen_ut1: 2; + /** gen_dtez : R/W; bitpos: [13:12]; default: 0; + * Action on PWM0A triggered by event TEZ when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ + uint32_t gen_dtez: 2; + /** gen_dtep : R/W; bitpos: [15:14]; default: 0; + * Action on PWM0A triggered by event TEP when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ + uint32_t gen_dtep: 2; + /** gen_dtea : R/W; bitpos: [17:16]; default: 0; + * Action on PWM0A triggered by event TEA when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ + uint32_t gen_dtea: 2; + /** gen_dteb : R/W; bitpos: [19:18]; default: 0; + * Action on PWM0A triggered by event TEB when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ + uint32_t gen_dteb: 2; + /** gen_dt0 : R/W; bitpos: [21:20]; default: 0; + * Action on PWM0A triggered by event_t0 when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ + uint32_t gen_dt0: 2; + /** gen_dt1 : R/W; bitpos: [23:22]; default: 0; + * Action on PWM0A triggered by event_t1 when timer decreasing. 0: no change, 1: low, + * 2: high, 3: toggle + */ + uint32_t gen_dt1: 2; + uint32_t reserved_24: 8; + }; + uint32_t val; +} mcpwm_gen_reg_t; + +/** Type of dt_cfg register + * PWM generator dead time type selection and configuration + */ +typedef union { + struct { + /** dt_fed_upmethod : R/W; bitpos: [3:0]; default: 0; + * Update method for FED (rising edge delay) active register. 0: immediate, when bit0 + * is set to 1: tez, when bit1 is set to 1:tep, when bit2 is set to 1: sync, when + * bit3 is set to 1: disable the update + */ + uint32_t dt_fed_upmethod: 4; + /** dt_red_upmethod : R/W; bitpos: [7:4]; default: 0; + * Update method for RED (rising edge delay) active register. 0: immediate, when bit0 + * is set to 1: tez, when bit1 is set to 1:tep, when bit2 is set to 1: sync, when + * bit3 is set to 1: disable the update + */ + uint32_t dt_red_upmethod: 4; + /** dt_deb_mode : R/W; bitpos: [8]; default: 0; + * S8 in table, dual-edge B mode, 0: fed/red take effect on different path separately, + * 1: fed/red take effect on B path, A out is in bypass or dulpB mode + */ + uint32_t dt_deb_mode: 1; + /** dt_a_outswap : R/W; bitpos: [9]; default: 0; + * S6 in table + */ + uint32_t dt_a_outswap: 1; + /** dt_b_outswap : R/W; bitpos: [10]; default: 0; + * S7 in table + */ + uint32_t dt_b_outswap: 1; + /** dt_red_insel : R/W; bitpos: [11]; default: 0; + * S4 in table + */ + uint32_t dt_red_insel: 1; + /** dt_fed_insel : R/W; bitpos: [12]; default: 0; + * S5 in table + */ + uint32_t dt_fed_insel: 1; + /** dt_red_outinvert : R/W; bitpos: [13]; default: 0; + * S2 in table + */ + uint32_t dt_red_outinvert: 1; + /** dt_fed_outinvert : R/W; bitpos: [14]; default: 0; + * S3 in table + */ + uint32_t dt_fed_outinvert: 1; + /** dt_a_outbypass : R/W; bitpos: [15]; default: 1; + * S1 in table + */ + uint32_t dt_a_outbypass: 1; + /** dt_b_outbypass : R/W; bitpos: [16]; default: 1; + * S0 in table + */ + uint32_t dt_b_outbypass: 1; + /** dt_clk_sel : R/W; bitpos: [17]; default: 0; + * Dead time clock selection. 0: PWM_clk, 1: PT_clk + */ + uint32_t dt_clk_sel: 1; + uint32_t reserved_18: 14; + }; + uint32_t val; +} mcpwm_dt_cfg_reg_t; + +/** Type of dt_fed_cfg register + * PWM generator shadow register for falling edge delay (FED). + */ +typedef union { + struct { + /** dt_fed : R/W; bitpos: [15:0]; default: 0; + * Shadow register for FED + */ + uint32_t dt_fed: 16; + uint32_t reserved_16: 16; + }; + uint32_t val; +} mcpwm_dt_fed_cfg_reg_t; + +/** Type of dt_red_cfg register + * PWM generator shadow register for rising edge delay (RED). + */ +typedef union { + struct { + /** dt_red : R/W; bitpos: [15:0]; default: 0; + * Shadow register for RED + */ + uint32_t dt_red: 16; + uint32_t reserved_16: 16; + }; + uint32_t val; +} mcpwm_dt_red_cfg_reg_t; + +/** Type of carrier_cfg register + * PWM generator carrier enable and configuratoin + */ +typedef union { + struct { + /** carrier_en : R/W; bitpos: [0]; default: 0; + * When set, carrier function is enabled. When cleared, carrier is bypassed + */ + uint32_t carrier_en: 1; + /** carrier_prescale : R/W; bitpos: [4:1]; default: 0; + * PWM carrier clock (PC_clk) prescale value. Period of PC_clk = period of PWM_clk * + * (PWM_CARRIER_PRESCALE + 1) + */ + uint32_t carrier_prescale: 4; + /** carrier_duty : R/W; bitpos: [7:5]; default: 0; + * carrier duty selection. Duty = PWM_CARRIER_DUTY / 8 + */ + uint32_t carrier_duty: 3; + /** carrier_oshtwth : R/W; bitpos: [11:8]; default: 0; + * width of the first pulse in number of periods of the carrier + */ + uint32_t carrier_oshtwth: 4; + /** carrier_out_invert : R/W; bitpos: [12]; default: 0; + * when set, invert the output of PWM0A and PWM0B for this submodule + */ + uint32_t carrier_out_invert: 1; + /** carrier_in_invert : R/W; bitpos: [13]; default: 0; + * when set, invert the input of PWM0A and PWM0B for this submodule + */ + uint32_t carrier_in_invert: 1; + uint32_t reserved_14: 18; + }; + uint32_t val; +} mcpwm_carrier_cfg_reg_t; + +/** Type of fh_cfg0 register + * Actions on PWM0A and PWM0B trip events + */ +typedef union { + struct { + /** fh_sw_cbc : R/W; bitpos: [0]; default: 0; + * Enable register for software force cycle-by-cycle mode action. 0: disable, 1: enable + */ + uint32_t fh_sw_cbc: 1; + /** fh_f2_cbc : R/W; bitpos: [1]; default: 0; + * fault_event2 will trigger cycle-by-cycle mode action. 0: disable, 1: enable + */ + uint32_t fh_f2_cbc: 1; + /** fh_f1_cbc : R/W; bitpos: [2]; default: 0; + * fault_event1 will trigger cycle-by-cycle mode action. 0: disable, 1: enable + */ + uint32_t fh_f1_cbc: 1; + /** fh_f0_cbc : R/W; bitpos: [3]; default: 0; + * fault_event0 will trigger cycle-by-cycle mode action. 0: disable, 1: enable + */ + uint32_t fh_f0_cbc: 1; + /** fh_sw_ost : R/W; bitpos: [4]; default: 0; + * Enable register for software force one-shot mode action. 0: disable, 1: enable + */ + uint32_t fh_sw_ost: 1; + /** fh_f2_ost : R/W; bitpos: [5]; default: 0; + * fault_event2 will trigger one-shot mode action. 0: disable, 1: enable + */ + uint32_t fh_f2_ost: 1; + /** fh_f1_ost : R/W; bitpos: [6]; default: 0; + * fault_event1 will trigger one-shot mode action. 0: disable, 1: enable + */ + uint32_t fh_f1_ost: 1; + /** fh_f0_ost : R/W; bitpos: [7]; default: 0; + * fault_event0 will trigger one-shot mode action. 0: disable, 1: enable + */ + uint32_t fh_f0_ost: 1; + /** fh_a_cbc_d : R/W; bitpos: [9:8]; default: 0; + * Cycle-by-cycle mode action on PWM0A when fault event occurs and timer is + * decreasing. 0: do nothing, 1: force low, 2: force high, 3: toggle + */ + uint32_t fh_a_cbc_d: 2; + /** fh_a_cbc_u : R/W; bitpos: [11:10]; default: 0; + * Cycle-by-cycle mode action on PWM0A when fault event occurs and timer is + * increasing. 0: do nothing, 1: force low, 2: force high, 3: toggle + */ + uint32_t fh_a_cbc_u: 2; + /** fh_a_ost_d : R/W; bitpos: [13:12]; default: 0; + * One-shot mode action on PWM0A when fault event occurs and timer is decreasing. 0: + * do nothing, 1: force low, 2: force high, 3: toggle + */ + uint32_t fh_a_ost_d: 2; + /** fh_a_ost_u : R/W; bitpos: [15:14]; default: 0; + * One-shot mode action on PWM0A when fault event occurs and timer is increasing. 0: + * do nothing, 1: force low, 2: force high, 3: toggle + */ + uint32_t fh_a_ost_u: 2; + /** fh_b_cbc_d : R/W; bitpos: [17:16]; default: 0; + * Cycle-by-cycle mode action on PWM0B when fault event occurs and timer is + * decreasing. 0: do nothing, 1: force low, 2: force high, 3: toggle + */ + uint32_t fh_b_cbc_d: 2; + /** fh_b_cbc_u : R/W; bitpos: [19:18]; default: 0; + * Cycle-by-cycle mode action on PWM0B when fault event occurs and timer is + * increasing. 0: do nothing,1: force low, 2: force high, 3: toggle + */ + uint32_t fh_b_cbc_u: 2; + /** fh_b_ost_d : R/W; bitpos: [21:20]; default: 0; + * One-shot mode action on PWM0B when fault event occurs and timer is decreasing. 0: + * do nothing, 1: force low, 2: force high, 3: toggle + */ + uint32_t fh_b_ost_d: 2; + /** fh_b_ost_u : R/W; bitpos: [23:22]; default: 0; + * One-shot mode action on PWM0B when fault event occurs and timer is increasing. 0: + * do nothing, 1: force low, 2: force high, 3: toggle + */ + uint32_t fh_b_ost_u: 2; + uint32_t reserved_24: 8; + }; + uint32_t val; +} mcpwm_fh_cfg0_reg_t; + +/** Type of fh_cfg1 register + * Software triggers for fault handler actions + */ +typedef union { + struct { + /** fh_clr_ost : R/W; bitpos: [0]; default: 0; + * a rising edge will clear on going one-shot mode action + */ + uint32_t fh_clr_ost: 1; + /** fh_cbcpulse : R/W; bitpos: [2:1]; default: 0; + * cycle-by-cycle mode action refresh moment selection. When bit0 is set to 1: TEZ, + * when bit1 is set to 1:TEP, when bit0 and bit1 both set to 0: stop refresh, when + * bit0 and bit1 both set to 1: refresh at TEP/TEZ + */ + uint32_t fh_cbcpulse: 2; + /** fh_force_cbc : R/W; bitpos: [3]; default: 0; + * a toggle trigger a cycle-by-cycle mode action + */ + uint32_t fh_force_cbc: 1; + /** fh_force_ost : R/W; bitpos: [4]; default: 0; + * a toggle (software negate its value) triggers a one-shot mode action + */ + uint32_t fh_force_ost: 1; + uint32_t reserved_5: 27; + }; + uint32_t val; +} mcpwm_fh_cfg1_reg_t; + +/** Type of fh_status register + * Status of fault events. + */ +typedef union { + struct { + /** fh_cbc_on : RO; bitpos: [0]; default: 0; + * Set and reset by hardware. If set, a cycle-by-cycle mode action is on going + */ + uint32_t fh_cbc_on: 1; + /** fh_ost_on : RO; bitpos: [1]; default: 0; + * Set and reset by hardware. If set, an one-shot mode action is on going + */ + uint32_t fh_ost_on: 1; + uint32_t reserved_2: 30; + }; + uint32_t val; +} mcpwm_fh_status_reg_t; + +/** Group: Fault Detection Configuration and Status */ +/** Type of fault_detect register + * Fault detection configuration and status + */ +typedef union { + struct { + /** f0_en : R/W; bitpos: [0]; default: 0; + * When set, fault_event0 generation is enabled + */ + uint32_t f0_en: 1; + /** f1_en : R/W; bitpos: [1]; default: 0; + * When set, fault_event1 generation is enabled + */ + uint32_t f1_en: 1; + /** f2_en : R/W; bitpos: [2]; default: 0; + * When set, fault_event2 generation is enabled + */ + uint32_t f2_en: 1; + /** f0_pole : R/W; bitpos: [3]; default: 0; + * Set fault_event0 trigger polarity on FAULT2 source from GPIO matrix. 0: level low, + * 1: level high + */ + uint32_t f0_pole: 1; + /** f1_pole : R/W; bitpos: [4]; default: 0; + * Set fault_event1 trigger polarity on FAULT2 source from GPIO matrix. 0: level low, + * 1: level high + */ + uint32_t f1_pole: 1; + /** f2_pole : R/W; bitpos: [5]; default: 0; + * Set fault_event2 trigger polarity on FAULT2 source from GPIO matrix. 0: level low, + * 1: level high + */ + uint32_t f2_pole: 1; + /** event_f0 : RO; bitpos: [6]; default: 0; + * Set and reset by hardware. If set, fault_event0 is on going + */ + uint32_t event_f0: 1; + /** event_f1 : RO; bitpos: [7]; default: 0; + * Set and reset by hardware. If set, fault_event1 is on going + */ + uint32_t event_f1: 1; + /** event_f2 : RO; bitpos: [8]; default: 0; + * Set and reset by hardware. If set, fault_event2 is on going + */ + uint32_t event_f2: 1; + uint32_t reserved_9: 23; + }; + uint32_t val; +} mcpwm_fault_detect_reg_t; + + +/** Group: Capture Configuration and Status */ +/** Type of cap_timer_cfg register + * Configure capture timer + */ +typedef union { + struct { + /** cap_timer_en : R/W; bitpos: [0]; default: 0; + * When set, capture timer incrementing under APB_clk is enabled. + */ + uint32_t cap_timer_en: 1; + /** cap_synci_en : R/W; bitpos: [1]; default: 0; + * When set, capture timer sync is enabled. + */ + uint32_t cap_synci_en: 1; + /** cap_synci_sel : R/W; bitpos: [4:2]; default: 0; + * capture module sync input selection. 0: none, 1: timer0 sync_out, 2: timer1 + * sync_out, 3: timer2 sync_out, 4: SYNC0 from GPIO matrix, 5: SYNC1 from GPIO matrix, + * 6: SYNC2 from GPIO matrix + */ + uint32_t cap_synci_sel: 3; + /** cap_sync_sw : WT; bitpos: [5]; default: 0; + * When reg_cap_synci_en is 1, write 1 will trigger a capture timer sync, capture + * timer is loaded with value in phase register. + */ + uint32_t cap_sync_sw: 1; + uint32_t reserved_6: 26; + }; + uint32_t val; +} mcpwm_cap_timer_cfg_reg_t; + +/** Type of cap_timer_phase register + * Phase for capture timer sync + */ +typedef union { + struct { + /** cap_timer_phase : R/W; bitpos: [31:0]; default: 0; + * Phase value for capture timer sync operation. + */ + uint32_t cap_timer_phase: 32; + }; + uint32_t val; +} mcpwm_cap_timer_phase_reg_t; + +/** Type of cap_chn_cfg register + * Capture channel 0 configuration and enable + */ +typedef union { + struct { + /** capn_en : R/W; bitpos: [0]; default: 0; + * When set, capture on channel 0 is enabled + */ + uint32_t capn_en: 1; + /** capn_mode : R/W; bitpos: [2:1]; default: 0; + * Edge of capture on channel 0 after prescaling. When bit0 is set to 1: enable + * capture on the negative edge, When bit1 is set to 1: enable capture on the positive + * edge. + */ + uint32_t capn_mode: 2; + /** capn_prescale : R/W; bitpos: [10:3]; default: 0; + * Value of prescaling on possitive edge of CAPn. Prescale value = PWM_CAPn_PRESCALE + + * 1 + */ + uint32_t capn_prescale: 8; + /** capn_in_invert : R/W; bitpos: [11]; default: 0; + * when set, CAPn form GPIO matrix is inverted before prescale + */ + uint32_t capn_in_invert: 1; + /** capn_sw : WT; bitpos: [12]; default: 0; + * Write 1 will trigger a software forced capture on channel 0 + */ + uint32_t capn_sw: 1; + uint32_t reserved_13: 19; + }; + uint32_t val; +} mcpwm_cap_chn_cfg_reg_t; + +/** Type of cap_chn register + * chn capture value status register + */ +typedef union { + struct { + /** capn_value : RO; bitpos: [31:0]; default: 0; + * Value of last capture on channel n + */ + uint32_t capn_value: 32; + }; + uint32_t val; +} mcpwm_cap_chn_reg_t; + +/** Type of cap_status register + * Edge of last capture trigger + */ +typedef union { + struct { + /** cap0_edge : RO; bitpos: [0]; default: 0; + * Edge of last capture trigger on channel 0, 0: posedge, 1: negedge + */ + uint32_t cap0_edge: 1; + /** cap1_edge : RO; bitpos: [1]; default: 0; + * Edge of last capture trigger on channel 1, 0: posedge, 1: negedge + */ + uint32_t cap1_edge: 1; + /** cap2_edge : RO; bitpos: [2]; default: 0; + * Edge of last capture trigger on channel 2, 0: posedge, 1: negedge + */ + uint32_t cap2_edge: 1; + uint32_t reserved_3: 29; + }; + uint32_t val; +} mcpwm_cap_status_reg_t; + + +/** Group: Enable update of active registers */ +/** Type of update_cfg register + * Enable update. + */ +typedef union { + struct { + /** global_up_en : R/W; bitpos: [0]; default: 1; + * The global enable of update of all active registers in MCPWM module + */ + uint32_t global_up_en: 1; + /** global_force_up : R/W; bitpos: [1]; default: 0; + * a toggle (software invert its value) will trigger a forced update of all active + * registers in MCPWM module + */ + uint32_t global_force_up: 1; + /** op0_up_en : R/W; bitpos: [2]; default: 1; + * When set and PWM_GLOBAL_UP_EN is set, update of active registers in PWM operator 0 + * are enabled + */ + uint32_t op0_up_en: 1; + /** op0_force_up : R/W; bitpos: [3]; default: 0; + * a toggle (software invert its value) will trigger a forced update of active + * registers in PWM operator 0 + */ + uint32_t op0_force_up: 1; + /** op1_up_en : R/W; bitpos: [4]; default: 1; + * When set and PWM_GLOBAL_UP_EN is set, update of active registers in PWM operator 1 + * are enabled + */ + uint32_t op1_up_en: 1; + /** op1_force_up : R/W; bitpos: [5]; default: 0; + * a toggle (software invert its value) will trigger a forced update of active + * registers in PWM operator 1 + */ + uint32_t op1_force_up: 1; + /** op2_up_en : R/W; bitpos: [6]; default: 1; + * When set and PWM_GLOBAL_UP_EN is set, update of active registers in PWM operator 2 + * are enabled + */ + uint32_t op2_up_en: 1; + /** op2_force_up : R/W; bitpos: [7]; default: 0; + * a toggle (software invert its value) will trigger a forced update of active + * registers in PWM operator 2 + */ + uint32_t op2_force_up: 1; + uint32_t reserved_8: 24; + }; + uint32_t val; +} mcpwm_update_cfg_reg_t; + + +/** Group: Manage Interrupts */ +/** Type of int_ena register + * Interrupt enable bits + */ +typedef union { + struct { + /** timer0_stop_int_ena : R/W; bitpos: [0]; default: 0; + * The enable bit for the interrupt triggered when the timer 0 stops. + */ + uint32_t timer0_stop_int_ena: 1; + /** timer1_stop_int_ena : R/W; bitpos: [1]; default: 0; + * The enable bit for the interrupt triggered when the timer 1 stops. + */ + uint32_t timer1_stop_int_ena: 1; + /** timer2_stop_int_ena : R/W; bitpos: [2]; default: 0; + * The enable bit for the interrupt triggered when the timer 2 stops. + */ + uint32_t timer2_stop_int_ena: 1; + /** timer0_tez_int_ena : R/W; bitpos: [3]; default: 0; + * The enable bit for the interrupt triggered by a PWM timer 0 TEZ event. + */ + uint32_t timer0_tez_int_ena: 1; + /** timer1_tez_int_ena : R/W; bitpos: [4]; default: 0; + * The enable bit for the interrupt triggered by a PWM timer 1 TEZ event. + */ + uint32_t timer1_tez_int_ena: 1; + /** timer2_tez_int_ena : R/W; bitpos: [5]; default: 0; + * The enable bit for the interrupt triggered by a PWM timer 2 TEZ event. + */ + uint32_t timer2_tez_int_ena: 1; + /** timer0_tep_int_ena : R/W; bitpos: [6]; default: 0; + * The enable bit for the interrupt triggered by a PWM timer 0 TEP event. + */ + uint32_t timer0_tep_int_ena: 1; + /** timer1_tep_int_ena : R/W; bitpos: [7]; default: 0; + * The enable bit for the interrupt triggered by a PWM timer 1 TEP event. + */ + uint32_t timer1_tep_int_ena: 1; + /** timer2_tep_int_ena : R/W; bitpos: [8]; default: 0; + * The enable bit for the interrupt triggered by a PWM timer 2 TEP event. + */ + uint32_t timer2_tep_int_ena: 1; + /** fault0_int_ena : R/W; bitpos: [9]; default: 0; + * The enable bit for the interrupt triggered when fault_event0 starts. + */ + uint32_t fault0_int_ena: 1; + /** fault1_int_ena : R/W; bitpos: [10]; default: 0; + * The enable bit for the interrupt triggered when fault_event1 starts. + */ + uint32_t fault1_int_ena: 1; + /** fault2_int_ena : R/W; bitpos: [11]; default: 0; + * The enable bit for the interrupt triggered when fault_event2 starts. + */ + uint32_t fault2_int_ena: 1; + /** fault0_clr_int_ena : R/W; bitpos: [12]; default: 0; + * The enable bit for the interrupt triggered when fault_event0 ends. + */ + uint32_t fault0_clr_int_ena: 1; + /** fault1_clr_int_ena : R/W; bitpos: [13]; default: 0; + * The enable bit for the interrupt triggered when fault_event1 ends. + */ + uint32_t fault1_clr_int_ena: 1; + /** fault2_clr_int_ena : R/W; bitpos: [14]; default: 0; + * The enable bit for the interrupt triggered when fault_event2 ends. + */ + uint32_t fault2_clr_int_ena: 1; + /** op0_tea_int_ena : R/W; bitpos: [15]; default: 0; + * The enable bit for the interrupt triggered by a PWM operator 0 TEA event + */ + uint32_t op0_tea_int_ena: 1; + /** op1_tea_int_ena : R/W; bitpos: [16]; default: 0; + * The enable bit for the interrupt triggered by a PWM operator 1 TEA event + */ + uint32_t op1_tea_int_ena: 1; + /** op2_tea_int_ena : R/W; bitpos: [17]; default: 0; + * The enable bit for the interrupt triggered by a PWM operator 2 TEA event + */ + uint32_t op2_tea_int_ena: 1; + /** op0_teb_int_ena : R/W; bitpos: [18]; default: 0; + * The enable bit for the interrupt triggered by a PWM operator 0 TEB event + */ + uint32_t op0_teb_int_ena: 1; + /** op1_teb_int_ena : R/W; bitpos: [19]; default: 0; + * The enable bit for the interrupt triggered by a PWM operator 1 TEB event + */ + uint32_t op1_teb_int_ena: 1; + /** op2_teb_int_ena : R/W; bitpos: [20]; default: 0; + * The enable bit for the interrupt triggered by a PWM operator 2 TEB event + */ + uint32_t op2_teb_int_ena: 1; + /** fh0_cbc_int_ena : R/W; bitpos: [21]; default: 0; + * The enable bit for the interrupt triggered by a cycle-by-cycle mode action on PWM0. + */ + uint32_t fh0_cbc_int_ena: 1; + /** fh1_cbc_int_ena : R/W; bitpos: [22]; default: 0; + * The enable bit for the interrupt triggered by a cycle-by-cycle mode action on PWM1. + */ + uint32_t fh1_cbc_int_ena: 1; + /** fh2_cbc_int_ena : R/W; bitpos: [23]; default: 0; + * The enable bit for the interrupt triggered by a cycle-by-cycle mode action on PWM2. + */ + uint32_t fh2_cbc_int_ena: 1; + /** fh0_ost_int_ena : R/W; bitpos: [24]; default: 0; + * The enable bit for the interrupt triggered by a one-shot mode action on PWM0. + */ + uint32_t fh0_ost_int_ena: 1; + /** fh1_ost_int_ena : R/W; bitpos: [25]; default: 0; + * The enable bit for the interrupt triggered by a one-shot mode action on PWM1. + */ + uint32_t fh1_ost_int_ena: 1; + /** fh2_ost_int_ena : R/W; bitpos: [26]; default: 0; + * The enable bit for the interrupt triggered by a one-shot mode action on PWM2. + */ + uint32_t fh2_ost_int_ena: 1; + /** cap0_int_ena : R/W; bitpos: [27]; default: 0; + * The enable bit for the interrupt triggered by capture on channel 0. + */ + uint32_t cap0_int_ena: 1; + /** cap1_int_ena : R/W; bitpos: [28]; default: 0; + * The enable bit for the interrupt triggered by capture on channel 1. + */ + uint32_t cap1_int_ena: 1; + /** cap2_int_ena : R/W; bitpos: [29]; default: 0; + * The enable bit for the interrupt triggered by capture on channel 2. + */ + uint32_t cap2_int_ena: 1; + uint32_t reserved_30: 2; + }; + uint32_t val; +} mcpwm_int_ena_reg_t; + +/** Type of int_raw register + * Raw interrupt status + */ +typedef union { + struct { + /** timer0_stop_int_raw : R/WTC/SS; bitpos: [0]; default: 0; + * The raw status bit for the interrupt triggered when the timer 0 stops. + */ + uint32_t timer0_stop_int_raw: 1; + /** timer1_stop_int_raw : R/WTC/SS; bitpos: [1]; default: 0; + * The raw status bit for the interrupt triggered when the timer 1 stops. + */ + uint32_t timer1_stop_int_raw: 1; + /** timer2_stop_int_raw : R/WTC/SS; bitpos: [2]; default: 0; + * The raw status bit for the interrupt triggered when the timer 2 stops. + */ + uint32_t timer2_stop_int_raw: 1; + /** timer0_tez_int_raw : R/WTC/SS; bitpos: [3]; default: 0; + * The raw status bit for the interrupt triggered by a PWM timer 0 TEZ event. + */ + uint32_t timer0_tez_int_raw: 1; + /** timer1_tez_int_raw : R/WTC/SS; bitpos: [4]; default: 0; + * The raw status bit for the interrupt triggered by a PWM timer 1 TEZ event. + */ + uint32_t timer1_tez_int_raw: 1; + /** timer2_tez_int_raw : R/WTC/SS; bitpos: [5]; default: 0; + * The raw status bit for the interrupt triggered by a PWM timer 2 TEZ event. + */ + uint32_t timer2_tez_int_raw: 1; + /** timer0_tep_int_raw : R/WTC/SS; bitpos: [6]; default: 0; + * The raw status bit for the interrupt triggered by a PWM timer 0 TEP event. + */ + uint32_t timer0_tep_int_raw: 1; + /** timer1_tep_int_raw : R/WTC/SS; bitpos: [7]; default: 0; + * The raw status bit for the interrupt triggered by a PWM timer 1 TEP event. + */ + uint32_t timer1_tep_int_raw: 1; + /** timer2_tep_int_raw : R/WTC/SS; bitpos: [8]; default: 0; + * The raw status bit for the interrupt triggered by a PWM timer 2 TEP event. + */ + uint32_t timer2_tep_int_raw: 1; + /** fault0_int_raw : R/WTC/SS; bitpos: [9]; default: 0; + * The raw status bit for the interrupt triggered when fault_event0 starts. + */ + uint32_t fault0_int_raw: 1; + /** fault1_int_raw : R/WTC/SS; bitpos: [10]; default: 0; + * The raw status bit for the interrupt triggered when fault_event1 starts. + */ + uint32_t fault1_int_raw: 1; + /** fault2_int_raw : R/WTC/SS; bitpos: [11]; default: 0; + * The raw status bit for the interrupt triggered when fault_event2 starts. + */ + uint32_t fault2_int_raw: 1; + /** fault0_clr_int_raw : R/WTC/SS; bitpos: [12]; default: 0; + * The raw status bit for the interrupt triggered when fault_event0 ends. + */ + uint32_t fault0_clr_int_raw: 1; + /** fault1_clr_int_raw : R/WTC/SS; bitpos: [13]; default: 0; + * The raw status bit for the interrupt triggered when fault_event1 ends. + */ + uint32_t fault1_clr_int_raw: 1; + /** fault2_clr_int_raw : R/WTC/SS; bitpos: [14]; default: 0; + * The raw status bit for the interrupt triggered when fault_event2 ends. + */ + uint32_t fault2_clr_int_raw: 1; + /** op0_tea_int_raw : R/WTC/SS; bitpos: [15]; default: 0; + * The raw status bit for the interrupt triggered by a PWM operator 0 TEA event + */ + uint32_t op0_tea_int_raw: 1; + /** op1_tea_int_raw : R/WTC/SS; bitpos: [16]; default: 0; + * The raw status bit for the interrupt triggered by a PWM operator 1 TEA event + */ + uint32_t op1_tea_int_raw: 1; + /** op2_tea_int_raw : R/WTC/SS; bitpos: [17]; default: 0; + * The raw status bit for the interrupt triggered by a PWM operator 2 TEA event + */ + uint32_t op2_tea_int_raw: 1; + /** op0_teb_int_raw : R/WTC/SS; bitpos: [18]; default: 0; + * The raw status bit for the interrupt triggered by a PWM operator 0 TEB event + */ + uint32_t op0_teb_int_raw: 1; + /** op1_teb_int_raw : R/WTC/SS; bitpos: [19]; default: 0; + * The raw status bit for the interrupt triggered by a PWM operator 1 TEB event + */ + uint32_t op1_teb_int_raw: 1; + /** op2_teb_int_raw : R/WTC/SS; bitpos: [20]; default: 0; + * The raw status bit for the interrupt triggered by a PWM operator 2 TEB event + */ + uint32_t op2_teb_int_raw: 1; + /** fh0_cbc_int_raw : R/WTC/SS; bitpos: [21]; default: 0; + * The raw status bit for the interrupt triggered by a cycle-by-cycle mode action on + * PWM0. + */ + uint32_t fh0_cbc_int_raw: 1; + /** fh1_cbc_int_raw : R/WTC/SS; bitpos: [22]; default: 0; + * The raw status bit for the interrupt triggered by a cycle-by-cycle mode action on + * PWM1. + */ + uint32_t fh1_cbc_int_raw: 1; + /** fh2_cbc_int_raw : R/WTC/SS; bitpos: [23]; default: 0; + * The raw status bit for the interrupt triggered by a cycle-by-cycle mode action on + * PWM2. + */ + uint32_t fh2_cbc_int_raw: 1; + /** fh0_ost_int_raw : R/WTC/SS; bitpos: [24]; default: 0; + * The raw status bit for the interrupt triggered by a one-shot mode action on PWM0. + */ + uint32_t fh0_ost_int_raw: 1; + /** fh1_ost_int_raw : R/WTC/SS; bitpos: [25]; default: 0; + * The raw status bit for the interrupt triggered by a one-shot mode action on PWM1. + */ + uint32_t fh1_ost_int_raw: 1; + /** fh2_ost_int_raw : R/WTC/SS; bitpos: [26]; default: 0; + * The raw status bit for the interrupt triggered by a one-shot mode action on PWM2. + */ + uint32_t fh2_ost_int_raw: 1; + /** cap0_int_raw : R/WTC/SS; bitpos: [27]; default: 0; + * The raw status bit for the interrupt triggered by capture on channel 0. + */ + uint32_t cap0_int_raw: 1; + /** cap1_int_raw : R/WTC/SS; bitpos: [28]; default: 0; + * The raw status bit for the interrupt triggered by capture on channel 1. + */ + uint32_t cap1_int_raw: 1; + /** cap2_int_raw : R/WTC/SS; bitpos: [29]; default: 0; + * The raw status bit for the interrupt triggered by capture on channel 2. + */ + uint32_t cap2_int_raw: 1; + uint32_t reserved_30: 2; + }; + uint32_t val; +} mcpwm_int_raw_reg_t; + +/** Type of int_st register + * Masked interrupt status + */ +typedef union { + struct { + /** timer0_stop_int_st : RO; bitpos: [0]; default: 0; + * The masked status bit for the interrupt triggered when the timer 0 stops. + */ + uint32_t timer0_stop_int_st: 1; + /** timer1_stop_int_st : RO; bitpos: [1]; default: 0; + * The masked status bit for the interrupt triggered when the timer 1 stops. + */ + uint32_t timer1_stop_int_st: 1; + /** timer2_stop_int_st : RO; bitpos: [2]; default: 0; + * The masked status bit for the interrupt triggered when the timer 2 stops. + */ + uint32_t timer2_stop_int_st: 1; + /** timer0_tez_int_st : RO; bitpos: [3]; default: 0; + * The masked status bit for the interrupt triggered by a PWM timer 0 TEZ event. + */ + uint32_t timer0_tez_int_st: 1; + /** timer1_tez_int_st : RO; bitpos: [4]; default: 0; + * The masked status bit for the interrupt triggered by a PWM timer 1 TEZ event. + */ + uint32_t timer1_tez_int_st: 1; + /** timer2_tez_int_st : RO; bitpos: [5]; default: 0; + * The masked status bit for the interrupt triggered by a PWM timer 2 TEZ event. + */ + uint32_t timer2_tez_int_st: 1; + /** timer0_tep_int_st : RO; bitpos: [6]; default: 0; + * The masked status bit for the interrupt triggered by a PWM timer 0 TEP event. + */ + uint32_t timer0_tep_int_st: 1; + /** timer1_tep_int_st : RO; bitpos: [7]; default: 0; + * The masked status bit for the interrupt triggered by a PWM timer 1 TEP event. + */ + uint32_t timer1_tep_int_st: 1; + /** timer2_tep_int_st : RO; bitpos: [8]; default: 0; + * The masked status bit for the interrupt triggered by a PWM timer 2 TEP event. + */ + uint32_t timer2_tep_int_st: 1; + /** fault0_int_st : RO; bitpos: [9]; default: 0; + * The masked status bit for the interrupt triggered when fault_event0 starts. + */ + uint32_t fault0_int_st: 1; + /** fault1_int_st : RO; bitpos: [10]; default: 0; + * The masked status bit for the interrupt triggered when fault_event1 starts. + */ + uint32_t fault1_int_st: 1; + /** fault2_int_st : RO; bitpos: [11]; default: 0; + * The masked status bit for the interrupt triggered when fault_event2 starts. + */ + uint32_t fault2_int_st: 1; + /** fault0_clr_int_st : RO; bitpos: [12]; default: 0; + * The masked status bit for the interrupt triggered when fault_event0 ends. + */ + uint32_t fault0_clr_int_st: 1; + /** fault1_clr_int_st : RO; bitpos: [13]; default: 0; + * The masked status bit for the interrupt triggered when fault_event1 ends. + */ + uint32_t fault1_clr_int_st: 1; + /** fault2_clr_int_st : RO; bitpos: [14]; default: 0; + * The masked status bit for the interrupt triggered when fault_event2 ends. + */ + uint32_t fault2_clr_int_st: 1; + /** op0_tea_int_st : RO; bitpos: [15]; default: 0; + * The masked status bit for the interrupt triggered by a PWM operator 0 TEA event + */ + uint32_t op0_tea_int_st: 1; + /** op1_tea_int_st : RO; bitpos: [16]; default: 0; + * The masked status bit for the interrupt triggered by a PWM operator 1 TEA event + */ + uint32_t op1_tea_int_st: 1; + /** op2_tea_int_st : RO; bitpos: [17]; default: 0; + * The masked status bit for the interrupt triggered by a PWM operator 2 TEA event + */ + uint32_t op2_tea_int_st: 1; + /** op0_teb_int_st : RO; bitpos: [18]; default: 0; + * The masked status bit for the interrupt triggered by a PWM operator 0 TEB event + */ + uint32_t op0_teb_int_st: 1; + /** op1_teb_int_st : RO; bitpos: [19]; default: 0; + * The masked status bit for the interrupt triggered by a PWM operator 1 TEB event + */ + uint32_t op1_teb_int_st: 1; + /** op2_teb_int_st : RO; bitpos: [20]; default: 0; + * The masked status bit for the interrupt triggered by a PWM operator 2 TEB event + */ + uint32_t op2_teb_int_st: 1; + /** fh0_cbc_int_st : RO; bitpos: [21]; default: 0; + * The masked status bit for the interrupt triggered by a cycle-by-cycle mode action + * on PWM0. + */ + uint32_t fh0_cbc_int_st: 1; + /** fh1_cbc_int_st : RO; bitpos: [22]; default: 0; + * The masked status bit for the interrupt triggered by a cycle-by-cycle mode action + * on PWM1. + */ + uint32_t fh1_cbc_int_st: 1; + /** fh2_cbc_int_st : RO; bitpos: [23]; default: 0; + * The masked status bit for the interrupt triggered by a cycle-by-cycle mode action + * on PWM2. + */ + uint32_t fh2_cbc_int_st: 1; + /** fh0_ost_int_st : RO; bitpos: [24]; default: 0; + * The masked status bit for the interrupt triggered by a one-shot mode action on PWM0. + */ + uint32_t fh0_ost_int_st: 1; + /** fh1_ost_int_st : RO; bitpos: [25]; default: 0; + * The masked status bit for the interrupt triggered by a one-shot mode action on PWM1. + */ + uint32_t fh1_ost_int_st: 1; + /** fh2_ost_int_st : RO; bitpos: [26]; default: 0; + * The masked status bit for the interrupt triggered by a one-shot mode action on PWM2. + */ + uint32_t fh2_ost_int_st: 1; + /** cap0_int_st : RO; bitpos: [27]; default: 0; + * The masked status bit for the interrupt triggered by capture on channel 0. + */ + uint32_t cap0_int_st: 1; + /** cap1_int_st : RO; bitpos: [28]; default: 0; + * The masked status bit for the interrupt triggered by capture on channel 1. + */ + uint32_t cap1_int_st: 1; + /** cap2_int_st : RO; bitpos: [29]; default: 0; + * The masked status bit for the interrupt triggered by capture on channel 2. + */ + uint32_t cap2_int_st: 1; + uint32_t reserved_30: 2; + }; + uint32_t val; +} mcpwm_int_st_reg_t; + +/** Type of int_clr register + * Interrupt clear bits + */ +typedef union { + struct { + /** timer0_stop_int_clr : WT; bitpos: [0]; default: 0; + * Set this bit to clear the interrupt triggered when the timer 0 stops. + */ + uint32_t timer0_stop_int_clr: 1; + /** timer1_stop_int_clr : WT; bitpos: [1]; default: 0; + * Set this bit to clear the interrupt triggered when the timer 1 stops. + */ + uint32_t timer1_stop_int_clr: 1; + /** timer2_stop_int_clr : WT; bitpos: [2]; default: 0; + * Set this bit to clear the interrupt triggered when the timer 2 stops. + */ + uint32_t timer2_stop_int_clr: 1; + /** timer0_tez_int_clr : WT; bitpos: [3]; default: 0; + * Set this bit to clear the interrupt triggered by a PWM timer 0 TEZ event. + */ + uint32_t timer0_tez_int_clr: 1; + /** timer1_tez_int_clr : WT; bitpos: [4]; default: 0; + * Set this bit to clear the interrupt triggered by a PWM timer 1 TEZ event. + */ + uint32_t timer1_tez_int_clr: 1; + /** timer2_tez_int_clr : WT; bitpos: [5]; default: 0; + * Set this bit to clear the interrupt triggered by a PWM timer 2 TEZ event. + */ + uint32_t timer2_tez_int_clr: 1; + /** timer0_tep_int_clr : WT; bitpos: [6]; default: 0; + * Set this bit to clear the interrupt triggered by a PWM timer 0 TEP event. + */ + uint32_t timer0_tep_int_clr: 1; + /** timer1_tep_int_clr : WT; bitpos: [7]; default: 0; + * Set this bit to clear the interrupt triggered by a PWM timer 1 TEP event. + */ + uint32_t timer1_tep_int_clr: 1; + /** timer2_tep_int_clr : WT; bitpos: [8]; default: 0; + * Set this bit to clear the interrupt triggered by a PWM timer 2 TEP event. + */ + uint32_t timer2_tep_int_clr: 1; + /** fault0_int_clr : WT; bitpos: [9]; default: 0; + * Set this bit to clear the interrupt triggered when fault_event0 starts. + */ + uint32_t fault0_int_clr: 1; + /** fault1_int_clr : WT; bitpos: [10]; default: 0; + * Set this bit to clear the interrupt triggered when fault_event1 starts. + */ + uint32_t fault1_int_clr: 1; + /** fault2_int_clr : WT; bitpos: [11]; default: 0; + * Set this bit to clear the interrupt triggered when fault_event2 starts. + */ + uint32_t fault2_int_clr: 1; + /** fault0_clr_int_clr : WT; bitpos: [12]; default: 0; + * Set this bit to clear the interrupt triggered when fault_event0 ends. + */ + uint32_t fault0_clr_int_clr: 1; + /** fault1_clr_int_clr : WT; bitpos: [13]; default: 0; + * Set this bit to clear the interrupt triggered when fault_event1 ends. + */ + uint32_t fault1_clr_int_clr: 1; + /** fault2_clr_int_clr : WT; bitpos: [14]; default: 0; + * Set this bit to clear the interrupt triggered when fault_event2 ends. + */ + uint32_t fault2_clr_int_clr: 1; + /** op0_tea_int_clr : WT; bitpos: [15]; default: 0; + * Set this bit to clear the interrupt triggered by a PWM operator 0 TEA event + */ + uint32_t op0_tea_int_clr: 1; + /** op1_tea_int_clr : WT; bitpos: [16]; default: 0; + * Set this bit to clear the interrupt triggered by a PWM operator 1 TEA event + */ + uint32_t op1_tea_int_clr: 1; + /** op2_tea_int_clr : WT; bitpos: [17]; default: 0; + * Set this bit to clear the interrupt triggered by a PWM operator 2 TEA event + */ + uint32_t op2_tea_int_clr: 1; + /** op0_teb_int_clr : WT; bitpos: [18]; default: 0; + * Set this bit to clear the interrupt triggered by a PWM operator 0 TEB event + */ + uint32_t op0_teb_int_clr: 1; + /** op1_teb_int_clr : WT; bitpos: [19]; default: 0; + * Set this bit to clear the interrupt triggered by a PWM operator 1 TEB event + */ + uint32_t op1_teb_int_clr: 1; + /** op2_teb_int_clr : WT; bitpos: [20]; default: 0; + * Set this bit to clear the interrupt triggered by a PWM operator 2 TEB event + */ + uint32_t op2_teb_int_clr: 1; + /** fh0_cbc_int_clr : WT; bitpos: [21]; default: 0; + * Set this bit to clear the interrupt triggered by a cycle-by-cycle mode action on + * PWM0. + */ + uint32_t fh0_cbc_int_clr: 1; + /** fh1_cbc_int_clr : WT; bitpos: [22]; default: 0; + * Set this bit to clear the interrupt triggered by a cycle-by-cycle mode action on + * PWM1. + */ + uint32_t fh1_cbc_int_clr: 1; + /** fh2_cbc_int_clr : WT; bitpos: [23]; default: 0; + * Set this bit to clear the interrupt triggered by a cycle-by-cycle mode action on + * PWM2. + */ + uint32_t fh2_cbc_int_clr: 1; + /** fh0_ost_int_clr : WT; bitpos: [24]; default: 0; + * Set this bit to clear the interrupt triggered by a one-shot mode action on PWM0. + */ + uint32_t fh0_ost_int_clr: 1; + /** fh1_ost_int_clr : WT; bitpos: [25]; default: 0; + * Set this bit to clear the interrupt triggered by a one-shot mode action on PWM1. + */ + uint32_t fh1_ost_int_clr: 1; + /** fh2_ost_int_clr : WT; bitpos: [26]; default: 0; + * Set this bit to clear the interrupt triggered by a one-shot mode action on PWM2. + */ + uint32_t fh2_ost_int_clr: 1; + /** cap0_int_clr : WT; bitpos: [27]; default: 0; + * Set this bit to clear the interrupt triggered by capture on channel 0. + */ + uint32_t cap0_int_clr: 1; + /** cap1_int_clr : WT; bitpos: [28]; default: 0; + * Set this bit to clear the interrupt triggered by capture on channel 1. + */ + uint32_t cap1_int_clr: 1; + /** cap2_int_clr : WT; bitpos: [29]; default: 0; + * Set this bit to clear the interrupt triggered by capture on channel 2. + */ + uint32_t cap2_int_clr: 1; + uint32_t reserved_30: 2; + }; + uint32_t val; +} mcpwm_int_clr_reg_t; + + +/** Group: MCMCPWM APB configuration register */ +/** Type of clk register + * MCPWM APB configuration register + */ +typedef union { + struct { + /** clk_en : R/W; bitpos: [0]; default: 0; + * Force clock on for this register file + */ + uint32_t clk_en: 1; + uint32_t reserved_1: 31; + }; + uint32_t val; +} mcpwm_clk_reg_t; + + +/** Group: Version Register */ +/** Type of version register + * Version register. + */ +typedef union { + struct { + /** date : R/W; bitpos: [27:0]; default: 34632240; + * Version of this register file + */ + uint32_t date: 28; + uint32_t reserved_28: 4; + }; + uint32_t val; +} mcpwm_version_reg_t; + + +typedef struct { + mcpwm_timer_cfg0_reg_t timer_cfg0; + mcpwm_timer_cfg1_reg_t timer_cfg1; + mcpwm_timer_sync_reg_t timer_sync; + mcpwm_timer_status_reg_t timer_status; +} mcpwm_timer_regs_t; + +typedef struct { + mcpwm_gen_stmp_cfg_reg_t gen_stmp_cfg; + mcpwm_gen_tstmp_reg_t timestamp[2]; + mcpwm_gen_cfg0_reg_t gen_cfg0; + mcpwm_gen_force_reg_t gen_force; + mcpwm_gen_reg_t generator[2]; + mcpwm_dt_cfg_reg_t dt_cfg; + mcpwm_dt_fed_cfg_reg_t dt_fed_cfg; + mcpwm_dt_red_cfg_reg_t dt_red_cfg; + mcpwm_carrier_cfg_reg_t carrier_cfg; + mcpwm_fh_cfg0_reg_t fh_cfg0; + mcpwm_fh_cfg1_reg_t fh_cfg1; + mcpwm_fh_status_reg_t fh_status; +} mcpwm_operator_reg_t; + +typedef struct { + volatile mcpwm_clk_cfg_reg_t clk_cfg; + volatile mcpwm_timer_regs_t timer[3]; + volatile mcpwm_timer_synci_cfg_reg_t timer_synci_cfg; + volatile mcpwm_operator_timersel_reg_t operator_timersel; + volatile mcpwm_operator_reg_t operators[3]; + volatile mcpwm_fault_detect_reg_t fault_detect; + volatile mcpwm_cap_timer_cfg_reg_t cap_timer_cfg; + volatile mcpwm_cap_timer_phase_reg_t cap_timer_phase; + volatile mcpwm_cap_chn_cfg_reg_t cap_chn_cfg[3]; + volatile mcpwm_cap_chn_reg_t cap_chn[3]; + volatile mcpwm_cap_status_reg_t cap_status; + volatile mcpwm_update_cfg_reg_t update_cfg; + volatile mcpwm_int_ena_reg_t int_ena; + volatile mcpwm_int_raw_reg_t int_raw; + volatile mcpwm_int_st_reg_t int_st; + volatile mcpwm_int_clr_reg_t int_clr; + volatile mcpwm_clk_reg_t clk; + volatile mcpwm_version_reg_t version; } mcpwm_dev_t; extern mcpwm_dev_t MCPWM0; extern mcpwm_dev_t MCPWM1; +#ifndef __cplusplus +_Static_assert(sizeof(mcpwm_dev_t) == 0x128, "Invalid size of mcpwm_dev_t structure"); +#endif + #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32/include/soc/esp32/include/soc/pcnt_struct.h b/tools/sdk/esp32/include/soc/esp32/include/soc/pcnt_struct.h index caeb02ac23e..ecb79f3f4fa 100644 --- a/tools/sdk/esp32/include/soc/esp32/include/soc/pcnt_struct.h +++ b/tools/sdk/esp32/include/soc/esp32/include/soc/pcnt_struct.h @@ -21,7 +21,7 @@ extern "C" { #endif typedef volatile struct pcnt_dev_s { - struct{ + struct { union { struct { uint32_t filter_thres: 10; /*This register is used to filter pulse whose width is smaller than this value for unit0.*/ diff --git a/tools/sdk/esp32/include/soc/esp32/include/soc/rmt_struct.h b/tools/sdk/esp32/include/soc/esp32/include/soc/rmt_struct.h index 9736a28a776..fd1815a4984 100644 --- a/tools/sdk/esp32/include/soc/esp32/include/soc/rmt_struct.h +++ b/tools/sdk/esp32/include/soc/esp32/include/soc/rmt_struct.h @@ -24,7 +24,7 @@ typedef volatile struct rmt_dev_s { uint32_t data_ch[8]; /*The R/W ram address for channel0-7 by apb fifo access. Note that in some circumstances, data read from the FIFO may get lost. As RMT memory area accesses using the RMTMEM method do not have this issue and provide all the functionality that the FIFO register has, it is encouraged to use that instead.*/ - struct{ + struct { union { struct { uint32_t div_cnt: 8; /*This register is used to configure the frequency divider's factor in channel0-7.*/ @@ -250,9 +250,7 @@ typedef struct rmt_item32_s { //Allow access to RMT memory using RMTMEM.chan[0].data32[8] typedef volatile struct rmt_mem_s { struct { - union { - rmt_item32_t data32[64]; - }; + rmt_item32_t data32[64]; } chan[8]; } rmt_mem_t; extern rmt_mem_t RMTMEM; diff --git a/tools/sdk/esp32/include/soc/esp32/include/soc/sdmmc_struct.h b/tools/sdk/esp32/include/soc/esp32/include/soc/sdmmc_struct.h index 8a3bd8fcf6f..814a255249e 100644 --- a/tools/sdk/esp32/include/soc/esp32/include/soc/sdmmc_struct.h +++ b/tools/sdk/esp32/include/soc/esp32/include/soc/sdmmc_struct.h @@ -23,18 +23,22 @@ extern "C" { #endif typedef struct sdmmc_desc_s { - uint32_t reserved1: 1; - uint32_t disable_int_on_completion: 1; - uint32_t last_descriptor: 1; - uint32_t first_descriptor: 1; - uint32_t second_address_chained: 1; - uint32_t end_of_ring: 1; - uint32_t reserved2: 24; - uint32_t card_error_summary: 1; - uint32_t owned_by_idmac: 1; - uint32_t buffer1_size: 13; - uint32_t buffer2_size: 13; - uint32_t reserved3: 6; + struct { + uint32_t reserved1: 1; + uint32_t disable_int_on_completion: 1; + uint32_t last_descriptor: 1; + uint32_t first_descriptor: 1; + uint32_t second_address_chained: 1; + uint32_t end_of_ring: 1; + uint32_t reserved2: 24; + uint32_t card_error_summary: 1; + uint32_t owned_by_idmac: 1; + }; + struct { + uint32_t buffer1_size: 13; + uint32_t buffer2_size: 13; + uint32_t reserved3: 6; + }; void* buffer1_ptr; union { void* buffer2_ptr; @@ -146,8 +150,10 @@ typedef volatile struct sdmmc_dev_s { uint32_t val; } ctype; - uint32_t blksiz: 16; ///< block size, default 0x200 - uint32_t : 16; + struct { + uint32_t blksiz: 16; ///< block size, default 0x200 + uint32_t reserved: 16; + }; uint32_t bytcnt; ///< number of bytes to be transferred @@ -326,6 +332,7 @@ typedef volatile struct sdmmc_dev_s { uint32_t ces: 1; ///< card error summary uint32_t reserved2: 2; uint32_t nis: 1; ///< normal interrupt summary + uint32_t ais: 1; ///< abnormal interrupt summary uint32_t fbe_code: 3; ///< code of fatal bus error uint32_t fsm: 4; ///< DMAC FSM state uint32_t reserved3: 15; @@ -362,6 +369,7 @@ typedef volatile struct sdmmc_dev_s { uint32_t write_thr_en : 1; ///< equivalent of read_thr_en for writes uint32_t reserved1 : 13; uint32_t card_threshold : 12; ///< threshold value for reads/writes, in bytes + uint32_t reserved28: 4; }; uint32_t val; } cardthrctl; @@ -378,6 +386,7 @@ typedef volatile struct sdmmc_dev_s { uint32_t div_factor_p: 4; ///< controls clock period; it will be (div_factor_p + 1) / 160MHz uint32_t div_factor_h: 4; ///< controls length of high pulse; it will be (div_factor_h + 1) / 160MHz uint32_t div_factor_m: 4; ///< should be equal to div_factor_p + uint32_t reserved21: 11; }; uint32_t val; } clock; diff --git a/tools/sdk/esp32/include/soc/esp32/include/soc/soc.h b/tools/sdk/esp32/include/soc/esp32/include/soc/soc.h index 07b1e9c27c8..f9e3e875937 100644 --- a/tools/sdk/esp32/include/soc/esp32/include/soc/soc.h +++ b/tools/sdk/esp32/include/soc/esp32/include/soc/soc.h @@ -307,8 +307,8 @@ #define ETS_GPIO_NMI_SOURCE 23/**< interrupt of GPIO, NMI*/ #define ETS_FROM_CPU_INTR0_SOURCE 24/**< interrupt0 generated from a CPU, level*/ /* Used for FreeRTOS */ #define ETS_FROM_CPU_INTR1_SOURCE 25/**< interrupt1 generated from a CPU, level*/ /* Used for FreeRTOS */ -#define ETS_FROM_CPU_INTR2_SOURCE 26/**< interrupt2 generated from a CPU, level*/ /* Used for DPORT Access */ -#define ETS_FROM_CPU_INTR3_SOURCE 27/**< interrupt3 generated from a CPU, level*/ /* Used for DPORT Access */ +#define ETS_FROM_CPU_INTR2_SOURCE 26/**< interrupt2 generated from a CPU, level*/ /* Used for IPC_ISR */ +#define ETS_FROM_CPU_INTR3_SOURCE 27/**< interrupt3 generated from a CPU, level*/ /* Used for IPC_ISR */ #define ETS_SPI0_INTR_SOURCE 28/**< interrupt of SPI0, level, SPI0 is for Cache Access, do not use this*/ #define ETS_SPI1_INTR_SOURCE 29/**< interrupt of SPI1, level, SPI1 is for flash read/write, do not use this*/ #define ETS_SPI2_INTR_SOURCE 30/**< interrupt of SPI2, level*/ @@ -351,6 +351,60 @@ #define ETS_CACHE_IA_INTR_SOURCE 68/**< interrupt of Cache Invalied Access, LEVEL*/ #define ETS_MAX_INTR_SOURCE 69/**< total number of interrupt sources*/ +#if CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_5 +//interrupt cpu using table, Please see the core-isa.h +/************************************************************************************************************* + * Intr num Level Type PRO CPU usage APP CPU uasge + * 0 1 extern level WMAC Reserved + * 1 1 extern level BT/BLE Host HCI DMA BT/BLE Host HCI DMA + * 2 1 extern level + * 3 1 extern level + * 4 1 extern level WBB + * 5 1 extern level + * 6 1 timer FreeRTOS Tick(L1) FreeRTOS Tick(L1) + * 7 1 software BT/BLE VHCI BT/BLE VHCI + * 8 1 extern level BT/BLE BB(RX/TX) BT/BLE BB(RX/TX) + * 9 1 extern level + * 10 1 extern edge + * 11 3 profiling + * 12 1 extern level + * 13 1 extern level + * 14 7 nmi Reserved Reserved + * 15 3 timer FreeRTOS Tick(L3) FreeRTOS Tick(L3) + * 16 5 timer Reserved Reserved + * 17 1 extern level + * 18 1 extern level + * 19 2 extern level + * 20 2 extern level + * 21 2 extern level + * 22 3 extern edge + * 23 3 extern level + * 24 4 extern level + * 25 4 extern level BT/BLE Controller BT/BLE Controller + * 26 5 extern level TG1_WDT & CACHEERR + * 27 3 extern level Reserved Reserved + * 28 4 extern edge + * 29 3 software BT/BLE hli BT/BLE hli + * 30 4 extern edge Reserved Reserved + * 31 5 extern level IPC_ISR IPC_ISR + ************************************************************************************************************* + */ + +//CPU0 Interrupt number reserved, not touch this. +#define ETS_WMAC_INUM 0 +#define ETS_BT_HOST_INUM 1 +#define ETS_WBB_INUM 4 +#define ETS_TG0_T1_INUM 10 /**< use edge interrupt*/ +#define ETS_FRC1_INUM 22 +#define ETS_T1_WDT_CACHEERR_INUM 26 +#define ETS_T1_WDT_INUM ETS_T1_WDT_CACHEERR_INUM +#define ETS_MEMACCESS_ERR_INUM ETS_T1_WDT_CACHEERR_INUM +/* backwards compatibility only, use ETS_MEMACCESS_ERR_INUM instead*/ +#define ETS_CACHEERR_INUM ETS_MEMACCESS_ERR_INUM +#define ETS_IPC_ISR_INUM 31 + +#elif CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_4 + //interrupt cpu using table, Please see the core-isa.h /************************************************************************************************************* * Intr num Level Type PRO CPU usage APP CPU uasge @@ -382,7 +436,7 @@ * 25 4 extern level CACHEERR * 26 5 extern level * 27 3 extern level Reserved Reserved - * 28 4 extern edge DPORT ACCESS DPORT ACCESS + * 28 4 extern edge IPC_ISR IPC_ISR * 29 3 software Reserved Reserved * 30 4 extern edge Reserved Reserved * 31 5 extern level @@ -399,7 +453,9 @@ #define ETS_MEMACCESS_ERR_INUM 25 /* backwards compatibility only, use ETS_MEMACCESS_ERR_INUM instead*/ #define ETS_CACHEERR_INUM ETS_MEMACCESS_ERR_INUM -#define ETS_DPORT_INUM 28 +#define ETS_IPC_ISR_INUM 28 + +#endif /* CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_5 */ //CPU0 Interrupt number used in ROM, should be cancelled in SDK #define ETS_SLC_INUM 1 diff --git a/tools/sdk/esp32/include/soc/esp32/include/soc/soc_caps.h b/tools/sdk/esp32/include/soc/esp32/include/soc/soc_caps.h index 1ecedd65570..f9eef1ce18e 100644 --- a/tools/sdk/esp32/include/soc/esp32/include/soc/soc_caps.h +++ b/tools/sdk/esp32/include/soc/esp32/include/soc/soc_caps.h @@ -68,7 +68,6 @@ #define SOC_SDIO_SLAVE_SUPPORTED 1 #define SOC_TWAI_SUPPORTED 1 #define SOC_EMAC_SUPPORTED 1 -#define SOC_RISCV_COPROC_SUPPORTED 0 //TODO: correct the caller and remove this line #define SOC_CPU_CORES_NUM 2 #define SOC_ULP_SUPPORTED 1 #define SOC_RTC_SLOW_MEM_SUPPORTED 1 @@ -76,20 +75,33 @@ #define SOC_EFUSE_SECURE_BOOT_KEY_DIGESTS 1 /*-------------------------- ADC CAPS ----------------------------------------*/ -#define SOC_ADC_PERIPH_NUM (2) -#define SOC_ADC_PATT_LEN_MAX (16) -#define SOC_ADC_CHANNEL_NUM(PERIPH_NUM) ((PERIPH_NUM==0)? 8: 10) -#define SOC_ADC_MAX_CHANNEL_NUM (10) -#define SOC_ADC_MAX_BITWIDTH (12) - /** + * TO BE REMOVED in !14278 * Check if adc support digital controller (DMA) mode. * @value * - 1 : support; * - 0 : not support; */ #define SOC_ADC_SUPPORT_DMA_MODE(PERIPH_NUM) ((PERIPH_NUM==0)? 1: 0) -#define SOC_ADC_SUPPORT_RTC_CTRL 1 + +/*!< SAR ADC Module*/ +#define SOC_ADC_RTC_CTRL_SUPPORTED 1 +#define SOC_ADC_PERIPH_NUM (2) +#define SOC_ADC_CHANNEL_NUM(PERIPH_NUM) ((PERIPH_NUM==0)? 8: 10) +#define SOC_ADC_MAX_CHANNEL_NUM (10) + +/*!< Digital */ +#define SOC_ADC_DIGI_CONTROLLER_NUM (2) +#define SOC_ADC_PATT_LEN_MAX (16) //Two pattern table, each contains 16 items. Each item takes 1 byte. But only support ADC1 using DMA mode +#define SOC_ADC_DIGI_MIN_BITWIDTH (9) +#define SOC_ADC_DIGI_MAX_BITWIDTH (12) +/*!< F_sample = F_digi_con / 2 / interval. F_digi_con = 5M for now. 30 <= interva <= 4095 */ +#define SOC_ADC_SAMPLE_FREQ_THRES_HIGH 83333 +#define SOC_ADC_SAMPLE_FREQ_THRES_LOW 611 + +/*!< RTC */ +#define SOC_ADC_MAX_BITWIDTH (12) + /*-------------------------- BROWNOUT CAPS -----------------------------------*/ #if SOC_CAPS_ECO_VER >= 1 @@ -117,8 +129,8 @@ // set pullup/down/capability via RTC register. On ESP32-S2, Digital IOs have their own registers to // control pullup/down/capability, independent with RTC registers. -// 0~39 except from 20, 24, 28~31 are valid -#define SOC_GPIO_VALID_GPIO_MASK (0xFFFFFFFFFFULL & ~(0ULL | BIT20 | BIT24 | BIT28 | BIT29 | BIT30 | BIT31)) +// 0~39 except from 24, 28~31 are valid +#define SOC_GPIO_VALID_GPIO_MASK (0xFFFFFFFFFFULL & ~(0ULL | BIT24 | BIT28 | BIT29 | BIT30 | BIT31)) // GPIO >= 34 are input only #define SOC_GPIO_VALID_OUTPUT_GPIO_MASK (SOC_GPIO_VALID_GPIO_MASK & ~(0ULL | BIT34 | BIT35 | BIT36 | BIT37 | BIT38 | BIT39)) @@ -136,15 +148,23 @@ /*-------------------------- I2S CAPS ----------------------------------------*/ // ESP32 have 2 I2S #define SOC_I2S_NUM (2) +#define SOC_I2S_SUPPORTS_PDM_TX (1) +#define SOC_I2S_SUPPORTS_PDM_RX (1) +#define SOC_I2S_SUPPORTS_ADC (1) // ESP32 support ADC and DAC +#define SOC_I2S_SUPPORTS_DAC (1) -#define SOC_I2S_SUPPORTS_PDM (1) // ESP32 support PDM -#define SOC_I2S_SUPPORTS_ADC_DAC (1) // ESP32 support ADC and DAC - -#define SOC_I2S_MAX_BUFFER_SIZE (4 * 1024 * 1024) //the maximum RAM can be allocated - +#define SOC_I2S_SUPPORTS_APLL (1)// ESP32 support APLL #define SOC_I2S_APLL_MIN_FREQ (250000000) #define SOC_I2S_APLL_MAX_FREQ (500000000) #define SOC_I2S_APLL_MIN_RATE (10675) //in Hz, I2S Clock rate limited by hardware +#define SOC_I2S_TRANS_SIZE_ALIGN_WORD (1) // I2S DMA transfer size must be aligned to word +#define SOC_I2S_LCD_I80_VARIANT (1) // I2S has a special LCD mode that can generate Intel 8080 TX timing + +/*-------------------------- LCD CAPS ----------------------------------------*/ +/* Notes: On esp32, LCD intel 8080 timing is generated by I2S peripheral */ +#define SOC_LCD_I80_SUPPORTED (1) /*!< Intel 8080 LCD is supported */ +#define SOC_LCD_I80_BUSES (1) /*!< Only I2S0 has LCD mode */ +#define SOC_LCD_I80_BUS_WIDTH (24) /*!< Intel 8080 bus width */ /*-------------------------- LEDC CAPS ---------------------------------------*/ #define SOC_LEDC_SUPPORT_HS_MODE (1) @@ -158,10 +178,11 @@ #define SOC_MCPWM_OPERATORS_PER_GROUP (3) ///< The number of operators that each group has #define SOC_MCPWM_COMPARATORS_PER_OPERATOR (2) ///< The number of comparators that each operator has #define SOC_MCPWM_GENERATORS_PER_OPERATOR (2) ///< The number of generators that each operator has -#define SOC_MCPWM_FAULT_DETECTORS_PER_GROUP (3) ///< The number of fault signal detectors that each group has +#define SOC_MCPWM_TRIGGERS_PER_OPERATOR (2) ///< The number of triggers that each operator has +#define SOC_MCPWM_GPIO_FAULTS_PER_GROUP (3) ///< The number of GPIO fault signals that each group has #define SOC_MCPWM_CAPTURE_TIMERS_PER_GROUP (1) ///< The number of capture timers that each group has #define SOC_MCPWM_CAPTURE_CHANNELS_PER_TIMER (3) ///< The number of capture channels that each capture timer has -#define SOC_MCPWM_EXT_SYNCERS_PER_GROUP (3) ///< The number of external syncers that each group has +#define SOC_MCPWM_GPIO_SYNCHROS_PER_GROUP (3) ///< The number of GPIO synchros that each group has #define SOC_MCPWM_BASE_CLK_HZ (160000000ULL) ///< Base Clock frequency of 160MHz /*-------------------------- MPU CAPS ----------------------------------------*/ @@ -173,10 +194,10 @@ #define SOC_MPU_REGION_WO_SUPPORTED 0 /*-------------------------- PCNT CAPS ---------------------------------------*/ -// ESP32 have 1 PCNT peripheral -#define SOC_PCNT_PORT_NUM (1) -#define SOC_PCNT_UNIT_NUM (8) -#define SOC_PCNT_UNIT_CHANNEL_NUM (2) +#define SOC_PCNT_GROUPS (1) +#define SOC_PCNT_UNITS_PER_GROUP (8) +#define SOC_PCNT_CHANNELS_PER_UNIT (2) +#define SOC_PCNT_THRES_POINT_PER_UNIT (2) /*-------------------------- RMT CAPS ----------------------------------------*/ #define SOC_RMT_GROUPS (1) /*!< One RMT group */ @@ -292,3 +313,6 @@ */ #define SOC_SDMMC_USE_IOMUX 1 #define SOC_SDMMC_NUM_SLOTS 2 + +/*------------------------------ BLE --------------------------------------------*/ +#define SOC_BLE_DONT_UPDATE_OWN_RPA (1) diff --git a/tools/sdk/esp32/include/soc/esp32/include/soc/timer_group_struct.h b/tools/sdk/esp32/include/soc/esp32/include/soc/timer_group_struct.h index 4ea1abe75d4..ec43f6d7a36 100644 --- a/tools/sdk/esp32/include/soc/esp32/include/soc/timer_group_struct.h +++ b/tools/sdk/esp32/include/soc/esp32/include/soc/timer_group_struct.h @@ -21,7 +21,7 @@ extern "C" { #endif typedef volatile struct timg_dev_s { - struct{ + struct { union { struct { uint32_t reserved0: 10; diff --git a/tools/sdk/esp32/include/soc/esp32/include/soc/twai_struct.h b/tools/sdk/esp32/include/soc/esp32/include/soc/twai_struct.h index e9454e1cc58..e4349d33edd 100644 --- a/tools/sdk/esp32/include/soc/esp32/include/soc/twai_struct.h +++ b/tools/sdk/esp32/include/soc/esp32/include/soc/twai_struct.h @@ -35,10 +35,10 @@ typedef volatile struct twai_dev_s { uint32_t lom: 1; /* MOD.1 Listen Only Mode */ uint32_t stm: 1; /* MOD.2 Self Test Mode */ uint32_t afm: 1; /* MOD.3 Acceptance Filter Mode */ - uint32_t reserved28: 28; /* Internal Reserved. MOD.4 Sleep Mode not supported */ + uint32_t reserved4: 28; /* Internal Reserved. MOD.4 Sleep Mode not supported */ }; uint32_t val; - } mode_reg; /* Address 0 */ + } mode_reg; /* Address 0x0000 */ union { struct { uint32_t tr: 1; /* CMR.0 Transmission Request */ @@ -46,10 +46,10 @@ typedef volatile struct twai_dev_s { uint32_t rrb: 1; /* CMR.2 Release Receive Buffer */ uint32_t cdo: 1; /* CMR.3 Clear Data Overrun */ uint32_t srr: 1; /* CMR.4 Self Reception Request */ - uint32_t reserved27: 27; /* Internal Reserved */ + uint32_t reserved5: 27; /* Internal Reserved */ }; uint32_t val; - } command_reg; /* Address 1 */ + } command_reg; /* Address 0x0004 */ union { struct { uint32_t rbs: 1; /* SR.0 Receive Buffer Status */ @@ -60,23 +60,24 @@ typedef volatile struct twai_dev_s { uint32_t ts: 1; /* SR.5 Transmit Status */ uint32_t es: 1; /* SR.6 Error Status */ uint32_t bs: 1; /* SR.7 Bus Status */ - uint32_t reserved24: 24; /* Internal Reserved */ + uint32_t reserved8: 24; /* Internal Reserved */ }; uint32_t val; - } status_reg; /* Address 2 */ + } status_reg; /* Address 0x0008 */ union { struct { uint32_t ri: 1; /* IR.0 Receive Interrupt */ uint32_t ti: 1; /* IR.1 Transmit Interrupt */ uint32_t ei: 1; /* IR.2 Error Interrupt */ - uint32_t reserved2: 2; /* Internal Reserved (Data Overrun interrupt and Wake-up not supported) */ + uint32_t doi: 1; /* IR.3 Data Overrun Interrupt */ + uint32_t reserved4: 1; /* Internal Reserved (Wake-up not supported) */ uint32_t epi: 1; /* IR.5 Error Passive Interrupt */ uint32_t ali: 1; /* IR.6 Arbitration Lost Interrupt */ uint32_t bei: 1; /* IR.7 Bus Error Interrupt */ - uint32_t reserved24: 24; /* Internal Reserved */ + uint32_t reserved8: 24; /* Internal Reserved */ }; uint32_t val; - } interrupt_reg; /* Address 3 */ + } interrupt_reg; /* Address 0x000C */ union { struct { uint32_t rie: 1; /* IER.0 Receive Interrupt Enable */ @@ -87,70 +88,70 @@ typedef volatile struct twai_dev_s { uint32_t epie: 1; /* IER.5 Error Passive Interrupt Enable */ uint32_t alie: 1; /* IER.6 Arbitration Lost Interrupt Enable */ uint32_t beie: 1; /* IER.7 Bus Error Interrupt Enable */ - uint32_t reserved24: 24; /* Internal Reserved */ + uint32_t reserved8: 24; /* Internal Reserved */ }; uint32_t val; - } interrupt_enable_reg; /* Address 4 */ - uint32_t reserved_05; /* Address 5 */ + } interrupt_enable_reg; /* Address 0x0010 */ + uint32_t reserved_14; union { struct { uint32_t brp: 6; /* BTR0[5:0] Baud Rate Prescaler */ uint32_t sjw: 2; /* BTR0[7:6] Synchronization Jump Width*/ - uint32_t reserved24: 24; /* Internal Reserved */ + uint32_t reserved8: 24; /* Internal Reserved */ }; uint32_t val; - } bus_timing_0_reg; /* Address 6 */ + } bus_timing_0_reg; /* Address 0x0018 */ union { struct { uint32_t tseg1: 4; /* BTR1[3:0] Timing Segment 1 */ uint32_t tseg2: 3; /* BTR1[6:4] Timing Segment 2 */ uint32_t sam: 1; /* BTR1.7 Sampling*/ - uint32_t reserved24: 24; /* Internal Reserved */ + uint32_t reserved8: 24; /* Internal Reserved */ }; uint32_t val; - } bus_timing_1_reg; /* Address 7 */ - uint32_t reserved_08; /* Address 8 (Output control not supported) */ - uint32_t reserved_09; /* Address 9 (Test Register not supported) */ - uint32_t reserved_10; /* Address 10 */ + } bus_timing_1_reg; /* Address 0x001C */ + uint32_t reserved_20; /* Address 0x0020 (Output control not supported) */ + uint32_t reserved_24; /* Address 0x0024 (Test Register not supported) */ + uint32_t reserved_28; /* Address 0x0028 */ //Capture and Counter Registers union { struct { uint32_t alc: 5; /* ALC[4:0] Arbitration lost capture */ - uint32_t reserved27: 27; /* Internal Reserved */ + uint32_t reserved5: 27; /* Internal Reserved */ }; uint32_t val; - } arbitration_lost_captue_reg; /* Address 11 */ + } arbitration_lost_captue_reg; /* Address 0x002C */ union { struct { uint32_t seg: 5; /* ECC[4:0] Error Code Segment 0 to 5 */ uint32_t dir: 1; /* ECC.5 Error Direction (TX/RX) */ uint32_t errc: 2; /* ECC[7:6] Error Code */ - uint32_t reserved24: 24; /* Internal Reserved */ + uint32_t reserved8: 24; /* Internal Reserved */ }; uint32_t val; - } error_code_capture_reg; /* Address 12 */ + } error_code_capture_reg; /* Address 0x0030 */ union { struct { uint32_t ewl: 8; /* EWL[7:0] Error Warning Limit */ - uint32_t reserved24: 24; /* Internal Reserved */ + uint32_t reserved8: 24; /* Internal Reserved */ }; uint32_t val; - } error_warning_limit_reg; /* EWLR[7:0] Error Warning Limit: Address 13 */ + } error_warning_limit_reg; /* Address 0x0034 */ union { struct { uint32_t rxerr: 8; /* RXERR[7:0] Receive Error Counter */ - uint32_t reserved24: 24; /* Internal Reserved */ + uint32_t reserved8: 24; /* Internal Reserved */ }; uint32_t val; - } rx_error_counter_reg; /* Address 12 */ + } rx_error_counter_reg; /* Address 0x0038 */ union { struct { uint32_t txerr: 8; /* TXERR[7:0] Receive Error Counter */ - uint32_t reserved24: 24; /* Internal Reserved */ + uint32_t reserved8: 24; /* Internal Reserved */ }; uint32_t val; - } tx_error_counter_reg; /* Address 15 */ + } tx_error_counter_reg; /* Address 0x003C */ //Shared Registers (TX Buff/RX Buff/Acc Filter) union { @@ -158,47 +159,51 @@ typedef volatile struct twai_dev_s { union { struct { uint32_t byte: 8; /* ACRx[7:0] Acceptance Code */ - uint32_t reserved24: 24; /* Internal Reserved */ + uint32_t reserved8: 24; /* Internal Reserved */ }; uint32_t val; } acr[4]; union { struct { uint32_t byte: 8; /* AMRx[7:0] Acceptance Mask */ - uint32_t reserved24: 24; /* Internal Reserved */ + uint32_t reserved8: 24; /* Internal Reserved */ }; uint32_t val; } amr[4]; - uint32_t reserved32[5]; + uint32_t reserved_60; + uint32_t reserved_64; + uint32_t reserved_68; + uint32_t reserved_6c; + uint32_t reserved_70; } acceptance_filter; union { struct { - uint32_t byte: 8; - uint32_t reserved24: 24; + uint32_t byte: 8; /* TX/RX Byte X [7:0] */ + uint32_t reserved24: 24; /* Internal Reserved */ }; uint32_t val; } tx_rx_buffer[13]; - }; /* Address 16-28 TX/RX Buffer and Acc Filter*/; + }; /* Address 0x0040 - 0x0070 */ //Misc Registers union { struct { uint32_t rmc: 7; /* RMC[6:0] RX Message Counter */ - uint32_t reserved25: 25; /* Internal Reserved */ + uint32_t reserved7: 25; /* Internal Reserved */ }; uint32_t val; - } rx_message_counter_reg; /* Address 29 */ - uint32_t reserved_30; /* Address 30 (RX Buffer Start Address not supported) */ + } rx_message_counter_reg; /* Address 0x0074 */ + uint32_t reserved_78; /* Address 0x0078 (RX Buffer Start Address not supported) */ union { struct { uint32_t cd: 3; /* CDR[2:0] CLKOUT frequency selector based of fOSC */ uint32_t co: 1; /* CDR.3 CLKOUT enable/disable */ - uint32_t reserved3: 3; /* Internal Reserved. RXINTEN and CBP not supported */ + uint32_t reserved4: 3; /* Internal Reserved. RXINTEN and CBP not supported */ uint32_t cm: 1; /* CDR.7 Register Layout. Basic:0 Extended:1 */ - uint32_t reserved24: 24; /* Internal Reserved */ + uint32_t reserved6: 24; /* Internal Reserved */ }; uint32_t val; - } clock_divider_reg; /* Address 31 */ + } clock_divider_reg; /* Address 0x007C */ } twai_dev_t; _Static_assert(sizeof(twai_dev_t) == 128, "TWAI registers should be 32 * 4 bytes"); diff --git a/tools/sdk/esp32/include/soc/esp32/include/soc/uart_pins.h b/tools/sdk/esp32/include/soc/esp32/include/soc/uart_pins.h new file mode 100644 index 00000000000..c84d3997682 --- /dev/null +++ b/tools/sdk/esp32/include/soc/esp32/include/soc/uart_pins.h @@ -0,0 +1,53 @@ +// Copyright 2015-2021 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/io_mux_reg.h" + +/* Specify the number of pins for UART */ +#define SOC_UART_PINS_COUNT (4) + +/* Specify the GPIO pin number for each UART signal in the IOMUX */ +#define U0TXD_GPIO_NUM (1) +#define U0RXD_GPIO_NUM (3) +#define U0CTS_GPIO_NUM (19) +#define U0RTS_GPIO_NUM (22) + +#define U1TXD_GPIO_NUM (10) +#define U1RXD_GPIO_NUM (9) +#define U1CTS_GPIO_NUM (6) +#define U1RTS_GPIO_NUM (11) + +#define U2TXD_GPIO_NUM (17) +#define U2RXD_GPIO_NUM (16) +#define U2CTS_GPIO_NUM (8) +#define U2RTS_GPIO_NUM (7) + +/* The following defines are necessary for reconfiguring the UART + * to use IOMUX, at runtime. */ +#define U0TXD_MUX_FUNC (FUNC_U0TXD_U0TXD) +#define U0RXD_MUX_FUNC (FUNC_U0RXD_U0RXD) +#define U0RTS_MUX_FUNC (FUNC_GPIO22_U0RTS) +#define U0CTS_MUX_FUNC (FUNC_GPIO19_U0CTS) + +#define U1TXD_MUX_FUNC (FUNC_SD_DATA3_U1TXD) +#define U1RXD_MUX_FUNC (FUNC_SD_DATA2_U1RXD) +#define U1RTS_MUX_FUNC (FUNC_SD_CMD_U1RTS) +#define U1CTS_MUX_FUNC (FUNC_SD_CLK_U1CTS) + +#define U2TXD_MUX_FUNC (FUNC_GPIO17_U2TXD) +#define U2RXD_MUX_FUNC (FUNC_GPIO16_U2RXD) +#define U2RTS_MUX_FUNC (FUNC_SD_DATA0_U2RTS) +#define U2CTS_MUX_FUNC (FUNC_SD_DATA1_U2CTS) diff --git a/tools/sdk/esp32/include/soc/esp32/include/soc/uart_struct.h b/tools/sdk/esp32/include/soc/esp32/include/soc/uart_struct.h index 7dc9b5144ca..9feb0cb353f 100644 --- a/tools/sdk/esp32/include/soc/esp32/include/soc/uart_struct.h +++ b/tools/sdk/esp32/include/soc/esp32/include/soc/uart_struct.h @@ -23,8 +23,8 @@ extern "C" { typedef volatile struct uart_dev_s { union { struct { - uint8_t rw_byte; /*This register stores one byte data read by rx fifo.*/ - uint8_t reserved[3]; + uint32_t rw_byte: 8; /*This register stores one byte data read by rx fifo.*/ + uint32_t reserved: 24; }; uint32_t val; } fifo; diff --git a/tools/sdk/esp32/include/soc/esp32/include/soc/uhci_struct.h b/tools/sdk/esp32/include/soc/esp32/include/soc/uhci_struct.h index 3f42536c31d..764268b35a1 100644 --- a/tools/sdk/esp32/include/soc/esp32/include/soc/uhci_struct.h +++ b/tools/sdk/esp32/include/soc/esp32/include/soc/uhci_struct.h @@ -277,7 +277,7 @@ typedef volatile struct uhci_dev_s { }; uint32_t val; } quick_sent; - struct{ + struct { uint32_t w_data[2]; /*This register stores the content of short packet's dword*/ } q_data[7]; union { diff --git a/tools/sdk/esp32/include/soc/include/soc/adc_periph.h b/tools/sdk/esp32/include/soc/include/soc/adc_periph.h index 796ea18e906..437d8ad6e6a 100644 --- a/tools/sdk/esp32/include/soc/include/soc/adc_periph.h +++ b/tools/sdk/esp32/include/soc/include/soc/adc_periph.h @@ -18,7 +18,7 @@ #include "soc/soc_caps.h" #include "soc/syscon_struct.h" -#if SOC_ADC_SUPPORT_RTC_CTRL +#if SOC_ADC_RTC_CTRL_SUPPORTED #include "soc/sens_reg.h" #include "soc/sens_struct.h" #endif diff --git a/tools/sdk/esp32/include/soc/include/soc/i2s_periph.h b/tools/sdk/esp32/include/soc/include/soc/i2s_periph.h index a2b9c542744..167c84700fd 100644 --- a/tools/sdk/esp32/include/soc/include/soc/i2s_periph.h +++ b/tools/sdk/esp32/include/soc/include/soc/i2s_periph.h @@ -1,4 +1,4 @@ -// Copyright 2019 Espressif Systems (Shanghai) PTE LTD +// Copyright 2020 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. @@ -27,16 +27,21 @@ extern "C" { Stores a bunch of per-I2S-peripheral data. */ typedef struct { - const uint8_t o_bck_in_sig; - const uint8_t o_ws_in_sig; - const uint8_t o_bck_out_sig; - const uint8_t o_ws_out_sig; - const uint8_t o_data_out_sig; - const uint8_t i_bck_in_sig; - const uint8_t i_ws_in_sig; - const uint8_t i_bck_out_sig; - const uint8_t i_ws_out_sig; - const uint8_t i_data_in_sig; + const uint8_t mck_out_sig; + + const uint8_t m_tx_bck_sig; + const uint8_t m_rx_bck_sig; + const uint8_t m_tx_ws_sig; + const uint8_t m_rx_ws_sig; + + const uint8_t s_tx_bck_sig; + const uint8_t s_rx_bck_sig; + const uint8_t s_tx_ws_sig; + const uint8_t s_rx_ws_sig; + + const uint8_t data_out_sig; + const uint8_t data_in_sig; + const uint8_t irq; const periph_module_t module; } i2s_signal_conn_t; diff --git a/tools/sdk/esp32/include/soc/include/soc/lcd_periph.h b/tools/sdk/esp32/include/soc/include/soc/lcd_periph.h index 6b1071b316c..d7d3ebc68bf 100644 --- a/tools/sdk/esp32/include/soc/include/soc/lcd_periph.h +++ b/tools/sdk/esp32/include/soc/include/soc/lcd_periph.h @@ -21,6 +21,7 @@ extern "C" { #endif +#if SOC_LCDCAM_SUPPORTED typedef struct { struct { const periph_module_t module; @@ -41,6 +42,19 @@ typedef struct { } panels[SOC_LCD_RGB_PANELS]; } lcd_signal_conn_t; +#endif // SOC_LCDCAM_SUPPORTED + +#if SOC_I2S_LCD_I80_VARIANT +typedef struct { + struct { + const periph_module_t module; + const int irq_id; + const int data_sigs[SOC_LCD_I80_BUS_WIDTH]; + const int wr_sig; + } buses[SOC_LCD_I80_BUSES]; +} lcd_signal_conn_t; +#endif // SOC_I2S_LCD_I80_VARIANT + extern const lcd_signal_conn_t lcd_periph_signals; #ifdef __cplusplus diff --git a/tools/sdk/esp32/include/soc/include/soc/mcpwm_periph.h b/tools/sdk/esp32/include/soc/include/soc/mcpwm_periph.h index ae5809c91ef..d807600c4a7 100644 --- a/tools/sdk/esp32/include/soc/include/soc/mcpwm_periph.h +++ b/tools/sdk/esp32/include/soc/include/soc/mcpwm_periph.h @@ -34,13 +34,13 @@ typedef struct { } operators[SOC_MCPWM_OPERATORS_PER_GROUP]; struct { const uint32_t fault_sig; - } detectors[SOC_MCPWM_FAULT_DETECTORS_PER_GROUP]; + } gpio_faults[SOC_MCPWM_GPIO_FAULTS_PER_GROUP]; struct { const uint32_t cap_sig; } captures[SOC_MCPWM_CAPTURE_CHANNELS_PER_TIMER]; struct { const uint32_t sync_sig; - } ext_syncers[SOC_MCPWM_EXT_SYNCERS_PER_GROUP]; + } gpio_synchros[SOC_MCPWM_GPIO_SYNCHROS_PER_GROUP]; } groups[SOC_MCPWM_GROUPS]; } mcpwm_signal_conn_t; diff --git a/tools/sdk/esp32/include/soc/include/soc/pcnt_periph.h b/tools/sdk/esp32/include/soc/include/soc/pcnt_periph.h index fa0f58221d5..966950c8461 100644 --- a/tools/sdk/esp32/include/soc/include/soc/pcnt_periph.h +++ b/tools/sdk/esp32/include/soc/include/soc/pcnt_periph.h @@ -1,4 +1,4 @@ -// Copyright 2019 Espressif Systems (Shanghai) PTE LTD +// Copyright 2019-2020 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. @@ -27,12 +27,14 @@ extern "C" { typedef struct { struct { struct { - const uint32_t pulse_sig; - const uint32_t control_sig; - } channels[SOC_PCNT_UNIT_CHANNEL_NUM]; - } units[SOC_PCNT_UNIT_NUM]; - const uint32_t irq; - const periph_module_t module; + struct { + const uint32_t pulse_sig; + const uint32_t control_sig; + } channels[SOC_PCNT_CHANNELS_PER_UNIT]; + } units[SOC_PCNT_UNITS_PER_GROUP]; + const uint32_t irq; + const periph_module_t module; + } groups[SOC_PCNT_GROUPS]; } pcnt_signal_conn_t; extern const pcnt_signal_conn_t pcnt_periph_signals; diff --git a/tools/sdk/esp32/include/soc/include/soc/rtc_io_periph.h b/tools/sdk/esp32/include/soc/include/soc/rtc_io_periph.h index e9309771c63..618b64cd8f7 100644 --- a/tools/sdk/esp32/include/soc/include/soc/rtc_io_periph.h +++ b/tools/sdk/esp32/include/soc/include/soc/rtc_io_periph.h @@ -27,7 +27,7 @@ #include "soc/rtc_cntl_reg.h" #include "soc/rtc_cntl_struct.h" -#if SOC_ADC_SUPPORT_RTC_CTRL +#if SOC_ADC_RTC_CTRL_SUPPORTED #include "soc/sens_struct.h" #endif diff --git a/tools/sdk/esp32/include/soc/include/soc/sdio_slave_periph.h b/tools/sdk/esp32/include/soc/include/soc/sdio_slave_periph.h index d39f72f5269..0f748ae12e5 100644 --- a/tools/sdk/esp32/include/soc/include/soc/sdio_slave_periph.h +++ b/tools/sdk/esp32/include/soc/include/soc/sdio_slave_periph.h @@ -15,9 +15,12 @@ #pragma once #include //include soc related (generated) definitions +#include "soc/soc_caps.h" #include "soc/soc_pins.h" +#ifdef SOC_SDIO_SLAVE_SUPPORTED #include "soc/slc_reg.h" #include "soc/slc_struct.h" +#endif #include "soc/host_reg.h" #include "soc/host_struct.h" #include "soc/hinf_reg.h" diff --git a/tools/sdk/esp32/include/soc/include/soc/spi_periph.h b/tools/sdk/esp32/include/soc/include/soc/spi_periph.h index 4ddb8b3f1ef..7aa38650356 100644 --- a/tools/sdk/esp32/include/soc/include/soc/spi_periph.h +++ b/tools/sdk/esp32/include/soc/include/soc/spi_periph.h @@ -30,8 +30,7 @@ #endif #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif #if CONFIG_IDF_TARGET_ESP32S2 @@ -41,8 +40,6 @@ extern "C" #define SPI_FWRITE_QIO 0 #endif - - /* Stores a bunch of per-spi-peripheral data. */ @@ -53,10 +50,22 @@ typedef struct { const uint8_t spiq_out; const uint8_t spiwp_out; const uint8_t spihd_out; +#if SOC_SPI_SUPPORT_OCT + const uint8_t spid4_out; + const uint8_t spid5_out; + const uint8_t spid6_out; + const uint8_t spid7_out; +#endif // SOC_SPI_SUPPORT_OCT const uint8_t spid_in; //GPIO mux input signals const uint8_t spiq_in; const uint8_t spiwp_in; const uint8_t spihd_in; +#if SOC_SPI_SUPPORT_OCT + const uint8_t spid4_in; + const uint8_t spid5_in; + const uint8_t spid6_in; + const uint8_t spid7_in; +#endif // SOC_SPI_SUPPORT_OCT const uint8_t spics_out[3]; // /CS GPIO output mux signals const uint8_t spics_in; const uint8_t spidqs_out; diff --git a/tools/sdk/esp32/include/soc/include/soc/uart_periph.h b/tools/sdk/esp32/include/soc/include/soc/uart_periph.h index f7e47099328..320b947c3b8 100644 --- a/tools/sdk/esp32/include/soc/include/soc/uart_periph.h +++ b/tools/sdk/esp32/include/soc/include/soc/uart_periph.h @@ -18,16 +18,40 @@ #include "soc/uart_struct.h" #include "soc/periph_defs.h" #include "soc/gpio_sig_map.h" +#include "soc/io_mux_reg.h" +#include "soc/uart_pins.h" #ifdef __cplusplus extern "C" { #endif +#define SOC_UART_TX_PIN_IDX (0) +#define SOC_UART_RX_PIN_IDX (1) +#define SOC_UART_RTS_PIN_IDX (2) +#define SOC_UART_CTS_PIN_IDX (3) + +/** + * @brief Macro that can be used to retrieve the signal of a certain pin for a + * certain UART. + */ +#define UART_PERIPH_SIGNAL(IDX, PIN) (uart_periph_signal[(IDX)].pins[(PIN)].signal) + +typedef struct { + /* Default GPIO number for this UART pin in the IOMUX. + * This value can be -1 if there is no default GPIO for a pin. + * For example, ESP32-C3 doesn't have any default GPIO for + * U0CTS and U0RTS. */ + int32_t default_gpio : 15; + /* Func which should be assigned to the GPIO to be used as UART */ + int32_t iomux_func : 4; + /* Marks if the current UART pin is input (or not) */ + uint32_t input : 1; + /* Signal in the GPIO signal map. */ + uint32_t signal : 12; +} uart_periph_sig_t; + typedef struct { - const uint8_t tx_sig; - const uint8_t rx_sig; - const uint8_t rts_sig; - const uint8_t cts_sig; + const uart_periph_sig_t pins[SOC_UART_PINS_COUNT]; const uint8_t irq; const periph_module_t module; } uart_signal_conn_t; diff --git a/tools/sdk/esp32/include/soc/include/soc/usb_phy_periph.h b/tools/sdk/esp32/include/soc/include/soc/usb_phy_periph.h new file mode 100644 index 00000000000..802d1720cec --- /dev/null +++ b/tools/sdk/esp32/include/soc/include/soc/usb_phy_periph.h @@ -0,0 +1,35 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once +#include +#include "soc/soc_caps.h" +#include "soc/periph_defs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + Stores a bunch of USB-peripheral data. +*/ +typedef struct { + const uint8_t extphy_vp_in; + const uint8_t extphy_vm_in; + const uint8_t extphy_rcv_in; + const uint8_t extphy_oen_out; + const uint8_t extphy_vpo_out; + const uint8_t extphy_vmo_out; + const uint8_t extphy_suspend_in; + const uint8_t extphy_speed_in; + const periph_module_t module; +} usb_phy_signal_conn_t; + +extern const usb_phy_signal_conn_t usb_phy_periph_signal; + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32/include/spi_flash/include/esp_partition.h b/tools/sdk/esp32/include/spi_flash/include/esp_partition.h index e59babb451b..36baea29860 100644 --- a/tools/sdk/esp32/include/spi_flash/include/esp_partition.h +++ b/tools/sdk/esp32/include/spi_flash/include/esp_partition.h @@ -87,6 +87,7 @@ typedef enum { ESP_PARTITION_SUBTYPE_DATA_COREDUMP = 0x03, //!< COREDUMP partition ESP_PARTITION_SUBTYPE_DATA_NVS_KEYS = 0x04, //!< Partition for NVS keys ESP_PARTITION_SUBTYPE_DATA_EFUSE_EM = 0x05, //!< Partition for emulate eFuse bits + ESP_PARTITION_SUBTYPE_DATA_UNDEFINED = 0x06, //!< Undefined (or unspecified) data partition ESP_PARTITION_SUBTYPE_DATA_ESPHTTPD = 0x80, //!< ESPHTTPD partition ESP_PARTITION_SUBTYPE_DATA_FAT = 0x81, //!< FAT partition diff --git a/tools/sdk/esp32/include/spi_flash/include/spi_flash/spi_flash_defs.h b/tools/sdk/esp32/include/spi_flash/include/spi_flash/spi_flash_defs.h index cf26fda1486..1ff0bfdea5c 100644 --- a/tools/sdk/esp32/include/spi_flash/include/spi_flash/spi_flash_defs.h +++ b/tools/sdk/esp32/include/spi_flash/include/spi_flash/spi_flash_defs.h @@ -68,3 +68,7 @@ #define SPI_FLASH_FASTRD_DUMMY_BITLEN 8 #define SPI_FLASH_SLOWRD_ADDR_BITLEN 24 #define SPI_FLASH_SLOWRD_DUMMY_BITLEN 0 +#define SPI_FLASH_OPISTR_ADDR_BITLEN 32 +#define SPI_FLASH_OPISTR_DUMMY_BITLEN 20 +#define SPI_FLASH_OPIDTR_ADDR_BITLEN 32 +#define SPI_FLASH_OPIDTR_DUMMY_BITLEN 40 diff --git a/tools/sdk/esp32/include/spi_flash/include/spi_flash_chip_driver.h b/tools/sdk/esp32/include/spi_flash/include/spi_flash_chip_driver.h index 9a143d84d2e..d2ef25bf6de 100644 --- a/tools/sdk/esp32/include/spi_flash/include/spi_flash_chip_driver.h +++ b/tools/sdk/esp32/include/spi_flash/include/spi_flash_chip_driver.h @@ -206,6 +206,11 @@ struct spi_flash_chip_t { * Get the capabilities of the flash chip. See SPI_FLASH_CHIP_CAP_* macros as reference. */ spi_flash_caps_t (*get_chip_caps)(esp_flash_t *chip); + + /** + * Configure the host registers to use the specified read mode set in the ``chip->read_mode``. + */ + esp_err_t (*config_host_io_mode)(esp_flash_t *chip, uint32_t flags); }; /* Pointer to an array of pointers to all known drivers for flash chips. This array is used diff --git a/tools/sdk/esp32/include/spi_flash/include/spi_flash_chip_generic.h b/tools/sdk/esp32/include/spi_flash/include/spi_flash_chip_generic.h index 9e99f73e44b..019a6966a40 100644 --- a/tools/sdk/esp32/include/spi_flash/include/spi_flash_chip_generic.h +++ b/tools/sdk/esp32/include/spi_flash/include/spi_flash_chip_generic.h @@ -370,14 +370,15 @@ esp_err_t spi_flash_common_set_io_mode(esp_flash_t *chip, esp_flash_wrsr_func_t * transactions. Also prepare the command to be sent in read functions. * * @param chip Pointer to SPI flash chip to use. If NULL, esp_flash_default_chip is substituted. - * @param addr_32bit Whether 32 bit commands will be used (Currently only W25Q256 and GD25Q256 are supported) + * @param flags Special rules to configure io mode, (i.e. Whether 32 bit commands will be used (Currently only W25Q256 and GD25Q256 are supported)) * * @return * - ESP_OK if success * - ESP_ERR_FLASH_NOT_INITIALISED if chip not initialized properly * - or other error passed from the ``configure_host_mode`` function of host driver */ -esp_err_t spi_flash_chip_generic_config_host_io_mode(esp_flash_t *chip, bool addr_32bit); +esp_err_t spi_flash_chip_generic_config_host_io_mode(esp_flash_t *chip, uint32_t flags); +#define SPI_FLASH_CONFIG_IO_MODE_32B_ADDR BIT(0) /** * @brief Handle explicit yield requests @@ -396,5 +397,15 @@ esp_err_t spi_flash_chip_generic_yield(esp_flash_t* chip, uint32_t wip); */ esp_err_t spi_flash_chip_generic_suspend_cmd_conf(esp_flash_t *chip); +/** + * + * @brief Read the chip unique ID unsupported function. + * + * @param chip Pointer to SPI flash chip to use. + * @param flash_unique_id Pointer to store output unique id (Although this function is an unsupported function, but the parameter should be kept for the consistence of the function pointer). + * @return Always ESP_ERR_NOT_SUPPORTED. + */ +esp_err_t spi_flash_chip_generic_read_unique_id_none(esp_flash_t *chip, uint64_t* flash_unique_id); + /// Default timeout configuration used by most chips -const flash_chip_op_timeout_t spi_flash_chip_generic_timeout; +extern const flash_chip_op_timeout_t spi_flash_chip_generic_timeout; diff --git a/tools/sdk/esp32/include/spi_flash/include/spi_flash_chip_mxic.h b/tools/sdk/esp32/include/spi_flash/include/spi_flash_chip_mxic.h index f998c1564e5..201ad496e2a 100644 --- a/tools/sdk/esp32/include/spi_flash/include/spi_flash_chip_mxic.h +++ b/tools/sdk/esp32/include/spi_flash/include/spi_flash_chip_mxic.h @@ -25,3 +25,10 @@ * is not found. */ extern const spi_flash_chip_t esp_flash_chip_mxic; + +/** + * MXIC OPI flash chip_drv, uses all the above functions for its operations. In + * default autodetection, this is used as a catchall if a more specific chip_drv + * is not found. + */ +extern const spi_flash_chip_t esp_flash_chip_mxic_opi; diff --git a/tools/sdk/esp32/include/spi_flash/include/spi_flash_private.h b/tools/sdk/esp32/include/spi_flash/include/spi_flash_private.h index f792faef657..9d822fb9475 100644 --- a/tools/sdk/esp32/include/spi_flash/include/spi_flash_private.h +++ b/tools/sdk/esp32/include/spi_flash/include/spi_flash_private.h @@ -26,6 +26,8 @@ #elif CONFIG_IDF_TARGET_ESP32S3 #include "esp32s3/rom/spi_flash.h" #endif +#include "esp_flash.h" +#include "hal/spi_flash_hal.h" #ifdef __cplusplus extern "C" { @@ -38,13 +40,15 @@ esp_err_t esp_opiflash_init(void); /** * @brief Make MSPI work under 20Mhz + * @param control_spi1 Select whether to control SPI1. For tuning, we need to use SPI1. After tuning (during startup stage), let the flash driver to control SPI1 */ -void spi_timing_enter_mspi_low_speed_mode(void); +void spi_timing_enter_mspi_low_speed_mode(bool control_spi1); /** * @brief Make MSPI work under the frequency as users set + * @param control_spi1 Select whether to control SPI1. For tuning, we need to use SPI1. After tuning (during startup stage), let the flash driver to control SPI1 */ -void spi_timing_enter_mspi_high_speed_mode(void); +void spi_timing_enter_mspi_high_speed_mode(bool control_spi1); /** * @brief Tune MSPI flash timing to make it work under high frequency @@ -56,12 +60,34 @@ void spi_timing_flash_tuning(void); */ void spi_timing_psram_tuning(void); +/** + * @brief To initislize the MSPI pins + */ +void esp_mspi_pin_init(void); + /** * @brief Set SPI1 registers to make ROM functions work * @note This function is used for setting SPI1 registers to the state that ROM SPI functions work */ void spi_flash_set_rom_required_regs(void); +/** + * @brief Initialize main flash + * @param chip Pointer to main SPI flash(SPI1 CS0) chip to use.. + */ +esp_err_t esp_flash_init_main(esp_flash_t *chip); + +/** + * @brief Should be only used by SPI1 Flash driver to know the necessary timing registers + * @param out_timing_config Pointer to timing_tuning parameters. + */ +void spi_timing_get_flash_timing_param(spi_flash_hal_timing_config_t *out_timing_config); + +/** + * @brief Judge if the flash in tuned + */ +bool spi_timine_config_flash_is_tuned(void); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32/include/wpa_supplicant/include/esp_supplicant/esp_dpp.h b/tools/sdk/esp32/include/wpa_supplicant/esp_supplicant/include/esp_dpp.h similarity index 100% rename from tools/sdk/esp32/include/wpa_supplicant/include/esp_supplicant/esp_dpp.h rename to tools/sdk/esp32/include/wpa_supplicant/esp_supplicant/include/esp_dpp.h diff --git a/tools/sdk/esp32/include/wpa_supplicant/include/esp_supplicant/esp_rrm.h b/tools/sdk/esp32/include/wpa_supplicant/esp_supplicant/include/esp_rrm.h similarity index 100% rename from tools/sdk/esp32/include/wpa_supplicant/include/esp_supplicant/esp_rrm.h rename to tools/sdk/esp32/include/wpa_supplicant/esp_supplicant/include/esp_rrm.h diff --git a/tools/sdk/esp32/include/wpa_supplicant/include/esp_supplicant/esp_wnm.h b/tools/sdk/esp32/include/wpa_supplicant/esp_supplicant/include/esp_wnm.h similarity index 100% rename from tools/sdk/esp32/include/wpa_supplicant/include/esp_supplicant/esp_wnm.h rename to tools/sdk/esp32/include/wpa_supplicant/esp_supplicant/include/esp_wnm.h diff --git a/tools/sdk/esp32/include/wpa_supplicant/include/esp_supplicant/esp_wpa.h b/tools/sdk/esp32/include/wpa_supplicant/esp_supplicant/include/esp_wpa.h similarity index 100% rename from tools/sdk/esp32/include/wpa_supplicant/include/esp_supplicant/esp_wpa.h rename to tools/sdk/esp32/include/wpa_supplicant/esp_supplicant/include/esp_wpa.h diff --git a/tools/sdk/esp32/include/wpa_supplicant/include/esp_supplicant/esp_wpa2.h b/tools/sdk/esp32/include/wpa_supplicant/esp_supplicant/include/esp_wpa2.h similarity index 100% rename from tools/sdk/esp32/include/wpa_supplicant/include/esp_supplicant/esp_wpa2.h rename to tools/sdk/esp32/include/wpa_supplicant/esp_supplicant/include/esp_wpa2.h diff --git a/tools/sdk/esp32/include/wpa_supplicant/include/esp_supplicant/esp_wps.h b/tools/sdk/esp32/include/wpa_supplicant/esp_supplicant/include/esp_wps.h similarity index 100% rename from tools/sdk/esp32/include/wpa_supplicant/include/esp_supplicant/esp_wps.h rename to tools/sdk/esp32/include/wpa_supplicant/esp_supplicant/include/esp_wps.h diff --git a/tools/sdk/esp32/ld/esp32.rom.api.ld b/tools/sdk/esp32/ld/esp32.rom.api.ld index be023b85d3f..afd3cc04eb5 100644 --- a/tools/sdk/esp32/ld/esp32.rom.api.ld +++ b/tools/sdk/esp32/ld/esp32.rom.api.ld @@ -2,6 +2,11 @@ * ROM APIs */ +/* user may provide newer version of tjpgd */ +/* so here directly assign the symbols with the ROM API address to make sure one from rom is correctly linked */ +PROVIDE ( esp_rom_tjpgd_decomp = 0x400613e8 ); +PROVIDE ( esp_rom_tjpgd_prepare = 0x40060fa8 ); + PROVIDE ( esp_rom_crc32_le = crc32_le ); PROVIDE ( esp_rom_crc16_le = crc16_le ); PROVIDE ( esp_rom_crc8_le = crc8_le ); diff --git a/tools/sdk/esp32/ld/libbtdm_app.a b/tools/sdk/esp32/ld/libbtdm_app.a index 723e31ac3c5..9fec092fc92 100644 Binary files a/tools/sdk/esp32/ld/libbtdm_app.a and b/tools/sdk/esp32/ld/libbtdm_app.a differ diff --git a/tools/sdk/esp32/ld/libcat_face_detect.a b/tools/sdk/esp32/ld/libcat_face_detect.a new file mode 100644 index 00000000000..18bff9da4e2 Binary files /dev/null and b/tools/sdk/esp32/ld/libcat_face_detect.a differ diff --git a/tools/sdk/esp32/ld/libdetection.a b/tools/sdk/esp32/ld/libdetection.a deleted file mode 100644 index 8d5081bdfd9..00000000000 Binary files a/tools/sdk/esp32/ld/libdetection.a and /dev/null differ diff --git a/tools/sdk/esp32/ld/libdetection_cat_face.a b/tools/sdk/esp32/ld/libdetection_cat_face.a deleted file mode 100644 index e1d42e756b8..00000000000 Binary files a/tools/sdk/esp32/ld/libdetection_cat_face.a and /dev/null differ diff --git a/tools/sdk/esp32/ld/libdl.a b/tools/sdk/esp32/ld/libdl.a index 0160b0edc3c..8840177a68b 100644 Binary files a/tools/sdk/esp32/ld/libdl.a and b/tools/sdk/esp32/ld/libdl.a differ diff --git a/tools/sdk/esp32/ld/libfd.a b/tools/sdk/esp32/ld/libfd.a deleted file mode 100644 index 9f58faef4a2..00000000000 Binary files a/tools/sdk/esp32/ld/libfd.a and /dev/null differ diff --git a/tools/sdk/esp32/ld/libfr.a b/tools/sdk/esp32/ld/libfr.a deleted file mode 100644 index c824bcd9a3e..00000000000 Binary files a/tools/sdk/esp32/ld/libfr.a and /dev/null differ diff --git a/tools/sdk/esp32/ld/libhuman_face_detect.a b/tools/sdk/esp32/ld/libhuman_face_detect.a new file mode 100644 index 00000000000..8a6930968aa Binary files /dev/null and b/tools/sdk/esp32/ld/libhuman_face_detect.a differ diff --git a/tools/sdk/esp32/ld/libpe.a b/tools/sdk/esp32/ld/libpe.a deleted file mode 100644 index b859f2429eb..00000000000 Binary files a/tools/sdk/esp32/ld/libpe.a and /dev/null differ diff --git a/tools/sdk/esp32/ld/memory.ld b/tools/sdk/esp32/ld/memory.ld index cd8d0a9a340..f7759ace4e5 100644 --- a/tools/sdk/esp32/ld/memory.ld +++ b/tools/sdk/esp32/ld/memory.ld @@ -25,6 +25,17 @@ */ /* List of deprecated options */ +/* + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* CPU instruction prefetch padding size for flash mmap scenario */ +_esp_flash_mmap_prefetch_pad_size = 16; +/* CPU instruction prefetch padding size for memory protection scenario */ +_esp_memprot_prefetch_pad_size = 0; +/* Memory alignment size for PMS */ +_esp_memprot_align_size = 0; /* If BT is not built at all */ MEMORY { @@ -68,7 +79,7 @@ MEMORY */ rtc_slow_seg(RW) : org = 0x50000000 + 512, len = 0x2000 - 512 - /* external memory ,including data and text */ + /* external memory */ extern_ram_seg(RWX) : org = 0x3F800000, len = 0x400000 } diff --git a/tools/sdk/esp32/ld/sections.ld b/tools/sdk/esp32/ld/sections.ld index c769c5cd9c8..85a3a35947d 100644 --- a/tools/sdk/esp32/ld/sections.ld +++ b/tools/sdk/esp32/ld/sections.ld @@ -322,7 +322,7 @@ SECTIONS *libesp_system.a:esp_system.*(.literal.esp_system_abort .text.esp_system_abort) *libesp_system.a:ubsan.*(.literal .literal.* .text .text.*) *libfreertos.a:(EXCLUDE_FILE(*libfreertos.a:port.* *libfreertos.a:port_common.*) .literal EXCLUDE_FILE(*libfreertos.a:port.* *libfreertos.a:port_common.*) .literal.* EXCLUDE_FILE(*libfreertos.a:port.* *libfreertos.a:port_common.*) .text EXCLUDE_FILE(*libfreertos.a:port.* *libfreertos.a:port_common.*) .text.*) - *libfreertos.a:port.*(.literal.pxPortInitialiseStack .literal.unlikely.vPortEndScheduler .literal.vApplicationStackOverflowHook .literal.vPortAssertIfInISR .literal.vPortEnterCritical .literal.vPortExitCritical .literal.vPortReleaseTaskMPUSettings .literal.vPortSetStackWatchpoint .literal.vPortYieldOtherCore .literal.xPortInIsrContext .literal.xPortStartScheduler .literal.xPortSysTickHandler .text .text.pxPortInitialiseStack .text.unlikely.vPortEndScheduler .text.vApplicationStackOverflowHook .text.vPortAssertIfInISR .text.vPortEnterCritical .text.vPortExitCritical .text.vPortReleaseTaskMPUSettings .text.vPortSetStackWatchpoint .text.vPortStoreTaskMPUSettings .text.vPortYieldOtherCore .text.xPortGetTickRateHz .text.xPortInIsrContext .text.xPortStartScheduler .text.xPortSysTickHandler) + *libfreertos.a:port.*(.literal.pxPortInitialiseStack .literal.unlikely.vPortEndScheduler .literal.vApplicationStackOverflowHook .literal.vPortAssertIfInISR .literal.vPortEnterCritical .literal.vPortExitCritical .literal.vPortReleaseTaskMPUSettings .literal.vPortSetStackWatchpoint .literal.vPortYieldOtherCore .literal.xPortInIsrContext .literal.xPortStartScheduler .text .text.pxPortInitialiseStack .text.unlikely.vPortEndScheduler .text.vApplicationStackOverflowHook .text.vPortAssertIfInISR .text.vPortEnterCritical .text.vPortExitCritical .text.vPortReleaseTaskMPUSettings .text.vPortSetStackWatchpoint .text.vPortStoreTaskMPUSettings .text.vPortYieldOtherCore .text.xPortGetTickRateHz .text.xPortInIsrContext .text.xPortStartScheduler) *libfreertos.a:port_common.*(.literal.esp_startup_start_app_common .text .text.esp_startup_start_app_common) *libgcc.a:lib2funcs.*(.literal .literal.* .text .text.*) *libgcov.a:(.literal .literal.* .text .text.*) @@ -345,6 +345,7 @@ SECTIONS *liblog.a:log_freertos.*(.literal.esp_log_impl_unlock .text.esp_log_impl_unlock) *liblog.a:log_freertos.*(.literal.esp_log_timestamp .text.esp_log_timestamp) *libnewlib.a:abort.*(.literal .literal.* .text .text.*) + *libnewlib.a:assert.*(.literal .literal.* .text .text.*) *libnewlib.a:heap.*(.literal .literal.* .text .text.*) *libnewlib.a:stdatomic.*(.literal .literal.* .text .text.*) *librtc.a:(.literal .literal.* .text .text.*) @@ -536,6 +537,7 @@ SECTIONS *libheap.a:multi_heap.*(.rodata .rodata.*) *libheap.a:multi_heap_poisoning.*(.rodata .rodata.*) *libnewlib.a:abort.*(.rodata .rodata.*) + *libnewlib.a:assert.*(.rodata .rodata.*) *libnewlib.a:heap.*(.rodata .rodata.*) *libnewlib.a:stdatomic.*(.rodata .rodata.*) _nimble_data_start = ABSOLUTE(.); @@ -556,6 +558,18 @@ SECTIONS . = ALIGN(4); } > dram0_0_seg + /** + * This section holds data that won't be initialised when startup. + * This section locates in External RAM region. + */ + .ext_ram_noinit (NOLOAD) : + { + _ext_ram_noinit_start = ABSOLUTE(.); + *(.ext_ram_noinit*) + . = ALIGN(4); + _ext_ram_noinit_end = ABSOLUTE(.); + } > extern_ram_seg + /*This section holds data that should not be initialized at power up. The section located in Internal SRAM memory region. The macro _NOINIT can be used as attribute to place data into this section. @@ -587,8 +601,8 @@ SECTIONS _bss_start = ABSOLUTE(.); *(.bss .bss.*) - *(.dynbss .dynsbss .gnu.linkonce.b .gnu.linkonce.b.* .gnu.linkonce.sb .gnu.linkonce.sb.* .gnu.linkonce.sb2 .gnu.linkonce.sb2.* .sbss .sbss.* .sbss2 .sbss2.* .scommon .share.mem) *(.ext_ram.bss .ext_ram.bss.*) + *(.dynbss .dynsbss .gnu.linkonce.b .gnu.linkonce.b.* .gnu.linkonce.sb .gnu.linkonce.sb.* .gnu.linkonce.sb2 .gnu.linkonce.sb2.* .sbss .sbss.* .sbss2 .sbss2.* .scommon .share.mem) *(COMMON) _bt_bss_start = ABSOLUTE(.); *libbt.a:(.bss .bss.* COMMON) @@ -627,7 +641,7 @@ SECTIONS { _flash_rodata_start = ABSOLUTE(.); - *(EXCLUDE_FILE(*libgcov.a *libphy.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libc.a:creat.* *libc.a:isatty.* *libc.a:lib_a-abs.* *libc.a:lib_a-asctime.* *libc.a:lib_a-asctime_r.* *libc.a:lib_a-atoi.* *libc.a:lib_a-atol.* *libc.a:lib_a-bzero.* *libc.a:lib_a-close.* *libc.a:lib_a-creat.* *libc.a:lib_a-ctime.* *libc.a:lib_a-ctime_r.* *libc.a:lib_a-ctype_.* *libc.a:lib_a-div.* *libc.a:lib_a-environ.* *libc.a:lib_a-envlock.* *libc.a:lib_a-fclose.* *libc.a:lib_a-fflush.* *libc.a:lib_a-findfp.* *libc.a:lib_a-fputwc.* *libc.a:lib_a-fvwrite.* *libc.a:lib_a-fwalk.* *libc.a:lib_a-getenv_r.* *libc.a:lib_a-gettzinfo.* *libc.a:lib_a-gmtime.* *libc.a:lib_a-gmtime_r.* *libc.a:lib_a-impure.* *libc.a:lib_a-isalnum.* *libc.a:lib_a-isalpha.* *libc.a:lib_a-isascii.* *libc.a:lib_a-isblank.* *libc.a:lib_a-iscntrl.* *libc.a:lib_a-isdigit.* *libc.a:lib_a-isgraph.* *libc.a:lib_a-islower.* *libc.a:lib_a-isprint.* *libc.a:lib_a-ispunct.* *libc.a:lib_a-isspace.* *libc.a:lib_a-isupper.* *libc.a:lib_a-itoa.* *libc.a:lib_a-labs.* *libc.a:lib_a-lcltime.* *libc.a:lib_a-lcltime_r.* *libc.a:lib_a-ldiv.* *libc.a:lib_a-longjmp.* *libc.a:lib_a-makebuf.* *libc.a:lib_a-memccpy.* *libc.a:lib_a-memchr.* *libc.a:lib_a-memcmp.* *libc.a:lib_a-memcpy.* *libc.a:lib_a-memmove.* *libc.a:lib_a-memrchr.* *libc.a:lib_a-memset.* *libc.a:lib_a-mktime.* *libc.a:lib_a-month_lengths.* *libc.a:lib_a-open.* *libc.a:lib_a-quorem.* *libc.a:lib_a-raise.* *libc.a:lib_a-rand.* *libc.a:lib_a-rand_r.* *libc.a:lib_a-read.* *libc.a:lib_a-refill.* *libc.a:lib_a-rshift.* *libc.a:lib_a-s_fpclassify.* *libc.a:lib_a-sbrk.* *libc.a:lib_a-sccl.* *libc.a:lib_a-setjmp.* *libc.a:lib_a-sf_nan.* *libc.a:lib_a-srand.* *libc.a:lib_a-stdio.* *libc.a:lib_a-strcasecmp.* *libc.a:lib_a-strcasestr.* *libc.a:lib_a-strcat.* *libc.a:lib_a-strchr.* *libc.a:lib_a-strcmp.* *libc.a:lib_a-strcoll.* *libc.a:lib_a-strcpy.* *libc.a:lib_a-strcspn.* *libc.a:lib_a-strdup.* *libc.a:lib_a-strdup_r.* *libc.a:lib_a-strftime.* *libc.a:lib_a-strlcat.* *libc.a:lib_a-strlcpy.* *libc.a:lib_a-strlen.* *libc.a:lib_a-strlwr.* *libc.a:lib_a-strncasecmp.* *libc.a:lib_a-strncat.* *libc.a:lib_a-strncmp.* *libc.a:lib_a-strncpy.* *libc.a:lib_a-strndup.* *libc.a:lib_a-strndup_r.* *libc.a:lib_a-strnlen.* *libc.a:lib_a-strptime.* *libc.a:lib_a-strrchr.* *libc.a:lib_a-strsep.* *libc.a:lib_a-strspn.* *libc.a:lib_a-strstr.* *libc.a:lib_a-strtok_r.* *libc.a:lib_a-strtol.* *libc.a:lib_a-strtoul.* *libc.a:lib_a-strupr.* *libc.a:lib_a-sysclose.* *libc.a:lib_a-sysopen.* *libc.a:lib_a-sysread.* *libc.a:lib_a-syssbrk.* *libc.a:lib_a-system.* *libc.a:lib_a-systimes.* *libc.a:lib_a-syswrite.* *libc.a:lib_a-time.* *libc.a:lib_a-timelocal.* *libc.a:lib_a-toascii.* *libc.a:lib_a-tolower.* *libc.a:lib_a-toupper.* *libc.a:lib_a-tzcalc_limits.* *libc.a:lib_a-tzlock.* *libc.a:lib_a-tzset.* *libc.a:lib_a-tzset_r.* *libc.a:lib_a-tzvars.* *libc.a:lib_a-ungetc.* *libc.a:lib_a-utoa.* *libc.a:lib_a-wbuf.* *libc.a:lib_a-wcrtomb.* *libc.a:lib_a-wctomb_r.* *libc.a:lib_a-wsetup.* *libc.a:lock.* *libesp_hw_support.a:rtc_clk.* *libesp_system.a:esp_err.* *libesp_system.a:ubsan.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libheap.a:multi_heap_poisoning.* *libnewlib.a:abort.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .rodata EXCLUDE_FILE(*libgcov.a *libphy.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libc.a:creat.* *libc.a:isatty.* *libc.a:lib_a-abs.* *libc.a:lib_a-asctime.* *libc.a:lib_a-asctime_r.* *libc.a:lib_a-atoi.* *libc.a:lib_a-atol.* *libc.a:lib_a-bzero.* *libc.a:lib_a-close.* *libc.a:lib_a-creat.* *libc.a:lib_a-ctime.* *libc.a:lib_a-ctime_r.* *libc.a:lib_a-ctype_.* *libc.a:lib_a-div.* *libc.a:lib_a-environ.* *libc.a:lib_a-envlock.* *libc.a:lib_a-fclose.* *libc.a:lib_a-fflush.* *libc.a:lib_a-findfp.* *libc.a:lib_a-fputwc.* *libc.a:lib_a-fvwrite.* *libc.a:lib_a-fwalk.* *libc.a:lib_a-getenv_r.* *libc.a:lib_a-gettzinfo.* *libc.a:lib_a-gmtime.* *libc.a:lib_a-gmtime_r.* *libc.a:lib_a-impure.* *libc.a:lib_a-isalnum.* *libc.a:lib_a-isalpha.* *libc.a:lib_a-isascii.* *libc.a:lib_a-isblank.* *libc.a:lib_a-iscntrl.* *libc.a:lib_a-isdigit.* *libc.a:lib_a-isgraph.* *libc.a:lib_a-islower.* *libc.a:lib_a-isprint.* *libc.a:lib_a-ispunct.* *libc.a:lib_a-isspace.* *libc.a:lib_a-isupper.* *libc.a:lib_a-itoa.* *libc.a:lib_a-labs.* *libc.a:lib_a-lcltime.* *libc.a:lib_a-lcltime_r.* *libc.a:lib_a-ldiv.* *libc.a:lib_a-longjmp.* *libc.a:lib_a-makebuf.* *libc.a:lib_a-memccpy.* *libc.a:lib_a-memchr.* *libc.a:lib_a-memcmp.* *libc.a:lib_a-memcpy.* *libc.a:lib_a-memmove.* *libc.a:lib_a-memrchr.* *libc.a:lib_a-memset.* *libc.a:lib_a-mktime.* *libc.a:lib_a-month_lengths.* *libc.a:lib_a-open.* *libc.a:lib_a-quorem.* *libc.a:lib_a-raise.* *libc.a:lib_a-rand.* *libc.a:lib_a-rand_r.* *libc.a:lib_a-read.* *libc.a:lib_a-refill.* *libc.a:lib_a-rshift.* *libc.a:lib_a-s_fpclassify.* *libc.a:lib_a-sbrk.* *libc.a:lib_a-sccl.* *libc.a:lib_a-setjmp.* *libc.a:lib_a-sf_nan.* *libc.a:lib_a-srand.* *libc.a:lib_a-stdio.* *libc.a:lib_a-strcasecmp.* *libc.a:lib_a-strcasestr.* *libc.a:lib_a-strcat.* *libc.a:lib_a-strchr.* *libc.a:lib_a-strcmp.* *libc.a:lib_a-strcoll.* *libc.a:lib_a-strcpy.* *libc.a:lib_a-strcspn.* *libc.a:lib_a-strdup.* *libc.a:lib_a-strdup_r.* *libc.a:lib_a-strftime.* *libc.a:lib_a-strlcat.* *libc.a:lib_a-strlcpy.* *libc.a:lib_a-strlen.* *libc.a:lib_a-strlwr.* *libc.a:lib_a-strncasecmp.* *libc.a:lib_a-strncat.* *libc.a:lib_a-strncmp.* *libc.a:lib_a-strncpy.* *libc.a:lib_a-strndup.* *libc.a:lib_a-strndup_r.* *libc.a:lib_a-strnlen.* *libc.a:lib_a-strptime.* *libc.a:lib_a-strrchr.* *libc.a:lib_a-strsep.* *libc.a:lib_a-strspn.* *libc.a:lib_a-strstr.* *libc.a:lib_a-strtok_r.* *libc.a:lib_a-strtol.* *libc.a:lib_a-strtoul.* *libc.a:lib_a-strupr.* *libc.a:lib_a-sysclose.* *libc.a:lib_a-sysopen.* *libc.a:lib_a-sysread.* *libc.a:lib_a-syssbrk.* *libc.a:lib_a-system.* *libc.a:lib_a-systimes.* *libc.a:lib_a-syswrite.* *libc.a:lib_a-time.* *libc.a:lib_a-timelocal.* *libc.a:lib_a-toascii.* *libc.a:lib_a-tolower.* *libc.a:lib_a-toupper.* *libc.a:lib_a-tzcalc_limits.* *libc.a:lib_a-tzlock.* *libc.a:lib_a-tzset.* *libc.a:lib_a-tzset_r.* *libc.a:lib_a-tzvars.* *libc.a:lib_a-ungetc.* *libc.a:lib_a-utoa.* *libc.a:lib_a-wbuf.* *libc.a:lib_a-wcrtomb.* *libc.a:lib_a-wctomb_r.* *libc.a:lib_a-wsetup.* *libc.a:lock.* *libesp_hw_support.a:rtc_clk.* *libesp_system.a:esp_err.* *libesp_system.a:ubsan.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libheap.a:multi_heap_poisoning.* *libnewlib.a:abort.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .rodata.*) + *(EXCLUDE_FILE(*libgcov.a *libphy.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libc.a:creat.* *libc.a:isatty.* *libc.a:lib_a-abs.* *libc.a:lib_a-asctime.* *libc.a:lib_a-asctime_r.* *libc.a:lib_a-atoi.* *libc.a:lib_a-atol.* *libc.a:lib_a-bzero.* *libc.a:lib_a-close.* *libc.a:lib_a-creat.* *libc.a:lib_a-ctime.* *libc.a:lib_a-ctime_r.* *libc.a:lib_a-ctype_.* *libc.a:lib_a-div.* *libc.a:lib_a-environ.* *libc.a:lib_a-envlock.* *libc.a:lib_a-fclose.* *libc.a:lib_a-fflush.* *libc.a:lib_a-findfp.* *libc.a:lib_a-fputwc.* *libc.a:lib_a-fvwrite.* *libc.a:lib_a-fwalk.* *libc.a:lib_a-getenv_r.* *libc.a:lib_a-gettzinfo.* *libc.a:lib_a-gmtime.* *libc.a:lib_a-gmtime_r.* *libc.a:lib_a-impure.* *libc.a:lib_a-isalnum.* *libc.a:lib_a-isalpha.* *libc.a:lib_a-isascii.* *libc.a:lib_a-isblank.* *libc.a:lib_a-iscntrl.* *libc.a:lib_a-isdigit.* *libc.a:lib_a-isgraph.* *libc.a:lib_a-islower.* *libc.a:lib_a-isprint.* *libc.a:lib_a-ispunct.* *libc.a:lib_a-isspace.* *libc.a:lib_a-isupper.* *libc.a:lib_a-itoa.* *libc.a:lib_a-labs.* *libc.a:lib_a-lcltime.* *libc.a:lib_a-lcltime_r.* *libc.a:lib_a-ldiv.* *libc.a:lib_a-longjmp.* *libc.a:lib_a-makebuf.* *libc.a:lib_a-memccpy.* *libc.a:lib_a-memchr.* *libc.a:lib_a-memcmp.* *libc.a:lib_a-memcpy.* *libc.a:lib_a-memmove.* *libc.a:lib_a-memrchr.* *libc.a:lib_a-memset.* *libc.a:lib_a-mktime.* *libc.a:lib_a-month_lengths.* *libc.a:lib_a-open.* *libc.a:lib_a-quorem.* *libc.a:lib_a-raise.* *libc.a:lib_a-rand.* *libc.a:lib_a-rand_r.* *libc.a:lib_a-read.* *libc.a:lib_a-refill.* *libc.a:lib_a-rshift.* *libc.a:lib_a-s_fpclassify.* *libc.a:lib_a-sbrk.* *libc.a:lib_a-sccl.* *libc.a:lib_a-setjmp.* *libc.a:lib_a-sf_nan.* *libc.a:lib_a-srand.* *libc.a:lib_a-stdio.* *libc.a:lib_a-strcasecmp.* *libc.a:lib_a-strcasestr.* *libc.a:lib_a-strcat.* *libc.a:lib_a-strchr.* *libc.a:lib_a-strcmp.* *libc.a:lib_a-strcoll.* *libc.a:lib_a-strcpy.* *libc.a:lib_a-strcspn.* *libc.a:lib_a-strdup.* *libc.a:lib_a-strdup_r.* *libc.a:lib_a-strftime.* *libc.a:lib_a-strlcat.* *libc.a:lib_a-strlcpy.* *libc.a:lib_a-strlen.* *libc.a:lib_a-strlwr.* *libc.a:lib_a-strncasecmp.* *libc.a:lib_a-strncat.* *libc.a:lib_a-strncmp.* *libc.a:lib_a-strncpy.* *libc.a:lib_a-strndup.* *libc.a:lib_a-strndup_r.* *libc.a:lib_a-strnlen.* *libc.a:lib_a-strptime.* *libc.a:lib_a-strrchr.* *libc.a:lib_a-strsep.* *libc.a:lib_a-strspn.* *libc.a:lib_a-strstr.* *libc.a:lib_a-strtok_r.* *libc.a:lib_a-strtol.* *libc.a:lib_a-strtoul.* *libc.a:lib_a-strupr.* *libc.a:lib_a-sysclose.* *libc.a:lib_a-sysopen.* *libc.a:lib_a-sysread.* *libc.a:lib_a-syssbrk.* *libc.a:lib_a-system.* *libc.a:lib_a-systimes.* *libc.a:lib_a-syswrite.* *libc.a:lib_a-time.* *libc.a:lib_a-timelocal.* *libc.a:lib_a-toascii.* *libc.a:lib_a-tolower.* *libc.a:lib_a-toupper.* *libc.a:lib_a-tzcalc_limits.* *libc.a:lib_a-tzlock.* *libc.a:lib_a-tzset.* *libc.a:lib_a-tzset_r.* *libc.a:lib_a-tzvars.* *libc.a:lib_a-ungetc.* *libc.a:lib_a-utoa.* *libc.a:lib_a-wbuf.* *libc.a:lib_a-wcrtomb.* *libc.a:lib_a-wctomb_r.* *libc.a:lib_a-wsetup.* *libc.a:lock.* *libesp_hw_support.a:rtc_clk.* *libesp_system.a:esp_err.* *libesp_system.a:ubsan.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libheap.a:multi_heap_poisoning.* *libnewlib.a:abort.* *libnewlib.a:assert.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .rodata EXCLUDE_FILE(*libgcov.a *libphy.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libc.a:creat.* *libc.a:isatty.* *libc.a:lib_a-abs.* *libc.a:lib_a-asctime.* *libc.a:lib_a-asctime_r.* *libc.a:lib_a-atoi.* *libc.a:lib_a-atol.* *libc.a:lib_a-bzero.* *libc.a:lib_a-close.* *libc.a:lib_a-creat.* *libc.a:lib_a-ctime.* *libc.a:lib_a-ctime_r.* *libc.a:lib_a-ctype_.* *libc.a:lib_a-div.* *libc.a:lib_a-environ.* *libc.a:lib_a-envlock.* *libc.a:lib_a-fclose.* *libc.a:lib_a-fflush.* *libc.a:lib_a-findfp.* *libc.a:lib_a-fputwc.* *libc.a:lib_a-fvwrite.* *libc.a:lib_a-fwalk.* *libc.a:lib_a-getenv_r.* *libc.a:lib_a-gettzinfo.* *libc.a:lib_a-gmtime.* *libc.a:lib_a-gmtime_r.* *libc.a:lib_a-impure.* *libc.a:lib_a-isalnum.* *libc.a:lib_a-isalpha.* *libc.a:lib_a-isascii.* *libc.a:lib_a-isblank.* *libc.a:lib_a-iscntrl.* *libc.a:lib_a-isdigit.* *libc.a:lib_a-isgraph.* *libc.a:lib_a-islower.* *libc.a:lib_a-isprint.* *libc.a:lib_a-ispunct.* *libc.a:lib_a-isspace.* *libc.a:lib_a-isupper.* *libc.a:lib_a-itoa.* *libc.a:lib_a-labs.* *libc.a:lib_a-lcltime.* *libc.a:lib_a-lcltime_r.* *libc.a:lib_a-ldiv.* *libc.a:lib_a-longjmp.* *libc.a:lib_a-makebuf.* *libc.a:lib_a-memccpy.* *libc.a:lib_a-memchr.* *libc.a:lib_a-memcmp.* *libc.a:lib_a-memcpy.* *libc.a:lib_a-memmove.* *libc.a:lib_a-memrchr.* *libc.a:lib_a-memset.* *libc.a:lib_a-mktime.* *libc.a:lib_a-month_lengths.* *libc.a:lib_a-open.* *libc.a:lib_a-quorem.* *libc.a:lib_a-raise.* *libc.a:lib_a-rand.* *libc.a:lib_a-rand_r.* *libc.a:lib_a-read.* *libc.a:lib_a-refill.* *libc.a:lib_a-rshift.* *libc.a:lib_a-s_fpclassify.* *libc.a:lib_a-sbrk.* *libc.a:lib_a-sccl.* *libc.a:lib_a-setjmp.* *libc.a:lib_a-sf_nan.* *libc.a:lib_a-srand.* *libc.a:lib_a-stdio.* *libc.a:lib_a-strcasecmp.* *libc.a:lib_a-strcasestr.* *libc.a:lib_a-strcat.* *libc.a:lib_a-strchr.* *libc.a:lib_a-strcmp.* *libc.a:lib_a-strcoll.* *libc.a:lib_a-strcpy.* *libc.a:lib_a-strcspn.* *libc.a:lib_a-strdup.* *libc.a:lib_a-strdup_r.* *libc.a:lib_a-strftime.* *libc.a:lib_a-strlcat.* *libc.a:lib_a-strlcpy.* *libc.a:lib_a-strlen.* *libc.a:lib_a-strlwr.* *libc.a:lib_a-strncasecmp.* *libc.a:lib_a-strncat.* *libc.a:lib_a-strncmp.* *libc.a:lib_a-strncpy.* *libc.a:lib_a-strndup.* *libc.a:lib_a-strndup_r.* *libc.a:lib_a-strnlen.* *libc.a:lib_a-strptime.* *libc.a:lib_a-strrchr.* *libc.a:lib_a-strsep.* *libc.a:lib_a-strspn.* *libc.a:lib_a-strstr.* *libc.a:lib_a-strtok_r.* *libc.a:lib_a-strtol.* *libc.a:lib_a-strtoul.* *libc.a:lib_a-strupr.* *libc.a:lib_a-sysclose.* *libc.a:lib_a-sysopen.* *libc.a:lib_a-sysread.* *libc.a:lib_a-syssbrk.* *libc.a:lib_a-system.* *libc.a:lib_a-systimes.* *libc.a:lib_a-syswrite.* *libc.a:lib_a-time.* *libc.a:lib_a-timelocal.* *libc.a:lib_a-toascii.* *libc.a:lib_a-tolower.* *libc.a:lib_a-toupper.* *libc.a:lib_a-tzcalc_limits.* *libc.a:lib_a-tzlock.* *libc.a:lib_a-tzset.* *libc.a:lib_a-tzset_r.* *libc.a:lib_a-tzvars.* *libc.a:lib_a-ungetc.* *libc.a:lib_a-utoa.* *libc.a:lib_a-wbuf.* *libc.a:lib_a-wcrtomb.* *libc.a:lib_a-wctomb_r.* *libc.a:lib_a-wsetup.* *libc.a:lock.* *libesp_hw_support.a:rtc_clk.* *libesp_system.a:esp_err.* *libesp_system.a:ubsan.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libheap.a:multi_heap_poisoning.* *libnewlib.a:abort.* *libnewlib.a:assert.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .rodata.*) *(.rodata_wlog_error .rodata_wlog_error.*) @@ -701,7 +715,7 @@ SECTIONS _stext = .; _text_start = ABSOLUTE(.); - *(EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libxt_hal.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libc.a:creat.* *libc.a:isatty.* *libc.a:lib_a-abs.* *libc.a:lib_a-asctime.* *libc.a:lib_a-asctime_r.* *libc.a:lib_a-atoi.* *libc.a:lib_a-atol.* *libc.a:lib_a-bzero.* *libc.a:lib_a-close.* *libc.a:lib_a-creat.* *libc.a:lib_a-ctime.* *libc.a:lib_a-ctime_r.* *libc.a:lib_a-ctype_.* *libc.a:lib_a-div.* *libc.a:lib_a-environ.* *libc.a:lib_a-envlock.* *libc.a:lib_a-fclose.* *libc.a:lib_a-fflush.* *libc.a:lib_a-findfp.* *libc.a:lib_a-fputwc.* *libc.a:lib_a-fvwrite.* *libc.a:lib_a-fwalk.* *libc.a:lib_a-getenv_r.* *libc.a:lib_a-gettzinfo.* *libc.a:lib_a-gmtime.* *libc.a:lib_a-gmtime_r.* *libc.a:lib_a-impure.* *libc.a:lib_a-isalnum.* *libc.a:lib_a-isalpha.* *libc.a:lib_a-isascii.* *libc.a:lib_a-isblank.* *libc.a:lib_a-iscntrl.* *libc.a:lib_a-isdigit.* *libc.a:lib_a-isgraph.* *libc.a:lib_a-islower.* *libc.a:lib_a-isprint.* *libc.a:lib_a-ispunct.* *libc.a:lib_a-isspace.* *libc.a:lib_a-isupper.* *libc.a:lib_a-itoa.* *libc.a:lib_a-labs.* *libc.a:lib_a-lcltime.* *libc.a:lib_a-lcltime_r.* *libc.a:lib_a-ldiv.* *libc.a:lib_a-longjmp.* *libc.a:lib_a-makebuf.* *libc.a:lib_a-memccpy.* *libc.a:lib_a-memchr.* *libc.a:lib_a-memcmp.* *libc.a:lib_a-memcpy.* *libc.a:lib_a-memmove.* *libc.a:lib_a-memrchr.* *libc.a:lib_a-memset.* *libc.a:lib_a-mktime.* *libc.a:lib_a-month_lengths.* *libc.a:lib_a-open.* *libc.a:lib_a-quorem.* *libc.a:lib_a-raise.* *libc.a:lib_a-rand.* *libc.a:lib_a-rand_r.* *libc.a:lib_a-read.* *libc.a:lib_a-refill.* *libc.a:lib_a-rshift.* *libc.a:lib_a-s_fpclassify.* *libc.a:lib_a-sbrk.* *libc.a:lib_a-sccl.* *libc.a:lib_a-setjmp.* *libc.a:lib_a-sf_nan.* *libc.a:lib_a-srand.* *libc.a:lib_a-stdio.* *libc.a:lib_a-strcasecmp.* *libc.a:lib_a-strcasestr.* *libc.a:lib_a-strcat.* *libc.a:lib_a-strchr.* *libc.a:lib_a-strcmp.* *libc.a:lib_a-strcoll.* *libc.a:lib_a-strcpy.* *libc.a:lib_a-strcspn.* *libc.a:lib_a-strdup.* *libc.a:lib_a-strdup_r.* *libc.a:lib_a-strftime.* *libc.a:lib_a-strlcat.* *libc.a:lib_a-strlcpy.* *libc.a:lib_a-strlen.* *libc.a:lib_a-strlwr.* *libc.a:lib_a-strncasecmp.* *libc.a:lib_a-strncat.* *libc.a:lib_a-strncmp.* *libc.a:lib_a-strncpy.* *libc.a:lib_a-strndup.* *libc.a:lib_a-strndup_r.* *libc.a:lib_a-strnlen.* *libc.a:lib_a-strptime.* *libc.a:lib_a-strrchr.* *libc.a:lib_a-strsep.* *libc.a:lib_a-strspn.* *libc.a:lib_a-strstr.* *libc.a:lib_a-strtok_r.* *libc.a:lib_a-strtol.* *libc.a:lib_a-strtoul.* *libc.a:lib_a-strupr.* *libc.a:lib_a-sysclose.* *libc.a:lib_a-sysopen.* *libc.a:lib_a-sysread.* *libc.a:lib_a-syssbrk.* *libc.a:lib_a-system.* *libc.a:lib_a-systimes.* *libc.a:lib_a-syswrite.* *libc.a:lib_a-time.* *libc.a:lib_a-timelocal.* *libc.a:lib_a-toascii.* *libc.a:lib_a-tolower.* *libc.a:lib_a-toupper.* *libc.a:lib_a-tzcalc_limits.* *libc.a:lib_a-tzlock.* *libc.a:lib_a-tzset.* *libc.a:lib_a-tzset_r.* *libc.a:lib_a-tzvars.* *libc.a:lib_a-ungetc.* *libc.a:lib_a-utoa.* *libc.a:lib_a-wbuf.* *libc.a:lib_a-wcrtomb.* *libc.a:lib_a-wctomb_r.* *libc.a:lib_a-wsetup.* *libc.a:lock.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_hw_support.a:rtc_wdt.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:lib2funcs.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libheap.a:multi_heap_poisoning.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.* *libxtensa.a:eri.* *libxtensa.a:xtensa_intr_asm.*) .literal EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libxt_hal.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libc.a:creat.* *libc.a:isatty.* *libc.a:lib_a-abs.* *libc.a:lib_a-asctime.* *libc.a:lib_a-asctime_r.* *libc.a:lib_a-atoi.* *libc.a:lib_a-atol.* *libc.a:lib_a-bzero.* *libc.a:lib_a-close.* *libc.a:lib_a-creat.* *libc.a:lib_a-ctime.* *libc.a:lib_a-ctime_r.* *libc.a:lib_a-ctype_.* *libc.a:lib_a-div.* *libc.a:lib_a-environ.* *libc.a:lib_a-envlock.* *libc.a:lib_a-fclose.* *libc.a:lib_a-fflush.* *libc.a:lib_a-findfp.* *libc.a:lib_a-fputwc.* *libc.a:lib_a-fvwrite.* *libc.a:lib_a-fwalk.* *libc.a:lib_a-getenv_r.* *libc.a:lib_a-gettzinfo.* *libc.a:lib_a-gmtime.* *libc.a:lib_a-gmtime_r.* *libc.a:lib_a-impure.* *libc.a:lib_a-isalnum.* *libc.a:lib_a-isalpha.* *libc.a:lib_a-isascii.* *libc.a:lib_a-isblank.* *libc.a:lib_a-iscntrl.* *libc.a:lib_a-isdigit.* *libc.a:lib_a-isgraph.* *libc.a:lib_a-islower.* *libc.a:lib_a-isprint.* *libc.a:lib_a-ispunct.* *libc.a:lib_a-isspace.* *libc.a:lib_a-isupper.* *libc.a:lib_a-itoa.* *libc.a:lib_a-labs.* *libc.a:lib_a-lcltime.* *libc.a:lib_a-lcltime_r.* *libc.a:lib_a-ldiv.* *libc.a:lib_a-longjmp.* *libc.a:lib_a-makebuf.* *libc.a:lib_a-memccpy.* *libc.a:lib_a-memchr.* *libc.a:lib_a-memcmp.* *libc.a:lib_a-memcpy.* *libc.a:lib_a-memmove.* *libc.a:lib_a-memrchr.* *libc.a:lib_a-memset.* *libc.a:lib_a-mktime.* *libc.a:lib_a-month_lengths.* *libc.a:lib_a-open.* *libc.a:lib_a-quorem.* *libc.a:lib_a-raise.* *libc.a:lib_a-rand.* *libc.a:lib_a-rand_r.* *libc.a:lib_a-read.* *libc.a:lib_a-refill.* *libc.a:lib_a-rshift.* *libc.a:lib_a-s_fpclassify.* *libc.a:lib_a-sbrk.* *libc.a:lib_a-sccl.* *libc.a:lib_a-setjmp.* *libc.a:lib_a-sf_nan.* *libc.a:lib_a-srand.* *libc.a:lib_a-stdio.* *libc.a:lib_a-strcasecmp.* *libc.a:lib_a-strcasestr.* *libc.a:lib_a-strcat.* *libc.a:lib_a-strchr.* *libc.a:lib_a-strcmp.* *libc.a:lib_a-strcoll.* *libc.a:lib_a-strcpy.* *libc.a:lib_a-strcspn.* *libc.a:lib_a-strdup.* *libc.a:lib_a-strdup_r.* *libc.a:lib_a-strftime.* *libc.a:lib_a-strlcat.* *libc.a:lib_a-strlcpy.* *libc.a:lib_a-strlen.* *libc.a:lib_a-strlwr.* *libc.a:lib_a-strncasecmp.* *libc.a:lib_a-strncat.* *libc.a:lib_a-strncmp.* *libc.a:lib_a-strncpy.* *libc.a:lib_a-strndup.* *libc.a:lib_a-strndup_r.* *libc.a:lib_a-strnlen.* *libc.a:lib_a-strptime.* *libc.a:lib_a-strrchr.* *libc.a:lib_a-strsep.* *libc.a:lib_a-strspn.* *libc.a:lib_a-strstr.* *libc.a:lib_a-strtok_r.* *libc.a:lib_a-strtol.* *libc.a:lib_a-strtoul.* *libc.a:lib_a-strupr.* *libc.a:lib_a-sysclose.* *libc.a:lib_a-sysopen.* *libc.a:lib_a-sysread.* *libc.a:lib_a-syssbrk.* *libc.a:lib_a-system.* *libc.a:lib_a-systimes.* *libc.a:lib_a-syswrite.* *libc.a:lib_a-time.* *libc.a:lib_a-timelocal.* *libc.a:lib_a-toascii.* *libc.a:lib_a-tolower.* *libc.a:lib_a-toupper.* *libc.a:lib_a-tzcalc_limits.* *libc.a:lib_a-tzlock.* *libc.a:lib_a-tzset.* *libc.a:lib_a-tzset_r.* *libc.a:lib_a-tzvars.* *libc.a:lib_a-ungetc.* *libc.a:lib_a-utoa.* *libc.a:lib_a-wbuf.* *libc.a:lib_a-wcrtomb.* *libc.a:lib_a-wctomb_r.* *libc.a:lib_a-wsetup.* *libc.a:lock.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_hw_support.a:rtc_wdt.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:lib2funcs.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libheap.a:multi_heap_poisoning.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.* *libxtensa.a:eri.* *libxtensa.a:xtensa_intr_asm.*) .literal.* EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libxt_hal.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libc.a:creat.* *libc.a:isatty.* *libc.a:lib_a-abs.* *libc.a:lib_a-asctime.* *libc.a:lib_a-asctime_r.* *libc.a:lib_a-atoi.* *libc.a:lib_a-atol.* *libc.a:lib_a-bzero.* *libc.a:lib_a-close.* *libc.a:lib_a-creat.* *libc.a:lib_a-ctime.* *libc.a:lib_a-ctime_r.* *libc.a:lib_a-ctype_.* *libc.a:lib_a-div.* *libc.a:lib_a-environ.* *libc.a:lib_a-envlock.* *libc.a:lib_a-fclose.* *libc.a:lib_a-fflush.* *libc.a:lib_a-findfp.* *libc.a:lib_a-fputwc.* *libc.a:lib_a-fvwrite.* *libc.a:lib_a-fwalk.* *libc.a:lib_a-getenv_r.* *libc.a:lib_a-gettzinfo.* *libc.a:lib_a-gmtime.* *libc.a:lib_a-gmtime_r.* *libc.a:lib_a-impure.* *libc.a:lib_a-isalnum.* *libc.a:lib_a-isalpha.* *libc.a:lib_a-isascii.* *libc.a:lib_a-isblank.* *libc.a:lib_a-iscntrl.* *libc.a:lib_a-isdigit.* *libc.a:lib_a-isgraph.* *libc.a:lib_a-islower.* *libc.a:lib_a-isprint.* *libc.a:lib_a-ispunct.* *libc.a:lib_a-isspace.* *libc.a:lib_a-isupper.* *libc.a:lib_a-itoa.* *libc.a:lib_a-labs.* *libc.a:lib_a-lcltime.* *libc.a:lib_a-lcltime_r.* *libc.a:lib_a-ldiv.* *libc.a:lib_a-longjmp.* *libc.a:lib_a-makebuf.* *libc.a:lib_a-memccpy.* *libc.a:lib_a-memchr.* *libc.a:lib_a-memcmp.* *libc.a:lib_a-memcpy.* *libc.a:lib_a-memmove.* *libc.a:lib_a-memrchr.* *libc.a:lib_a-memset.* *libc.a:lib_a-mktime.* *libc.a:lib_a-month_lengths.* *libc.a:lib_a-open.* *libc.a:lib_a-quorem.* *libc.a:lib_a-raise.* *libc.a:lib_a-rand.* *libc.a:lib_a-rand_r.* *libc.a:lib_a-read.* *libc.a:lib_a-refill.* *libc.a:lib_a-rshift.* *libc.a:lib_a-s_fpclassify.* *libc.a:lib_a-sbrk.* *libc.a:lib_a-sccl.* *libc.a:lib_a-setjmp.* *libc.a:lib_a-sf_nan.* *libc.a:lib_a-srand.* *libc.a:lib_a-stdio.* *libc.a:lib_a-strcasecmp.* *libc.a:lib_a-strcasestr.* *libc.a:lib_a-strcat.* *libc.a:lib_a-strchr.* *libc.a:lib_a-strcmp.* *libc.a:lib_a-strcoll.* *libc.a:lib_a-strcpy.* *libc.a:lib_a-strcspn.* *libc.a:lib_a-strdup.* *libc.a:lib_a-strdup_r.* *libc.a:lib_a-strftime.* *libc.a:lib_a-strlcat.* *libc.a:lib_a-strlcpy.* *libc.a:lib_a-strlen.* *libc.a:lib_a-strlwr.* *libc.a:lib_a-strncasecmp.* *libc.a:lib_a-strncat.* *libc.a:lib_a-strncmp.* *libc.a:lib_a-strncpy.* *libc.a:lib_a-strndup.* *libc.a:lib_a-strndup_r.* *libc.a:lib_a-strnlen.* *libc.a:lib_a-strptime.* *libc.a:lib_a-strrchr.* *libc.a:lib_a-strsep.* *libc.a:lib_a-strspn.* *libc.a:lib_a-strstr.* *libc.a:lib_a-strtok_r.* *libc.a:lib_a-strtol.* *libc.a:lib_a-strtoul.* *libc.a:lib_a-strupr.* *libc.a:lib_a-sysclose.* *libc.a:lib_a-sysopen.* *libc.a:lib_a-sysread.* *libc.a:lib_a-syssbrk.* *libc.a:lib_a-system.* *libc.a:lib_a-systimes.* *libc.a:lib_a-syswrite.* *libc.a:lib_a-time.* *libc.a:lib_a-timelocal.* *libc.a:lib_a-toascii.* *libc.a:lib_a-tolower.* *libc.a:lib_a-toupper.* *libc.a:lib_a-tzcalc_limits.* *libc.a:lib_a-tzlock.* *libc.a:lib_a-tzset.* *libc.a:lib_a-tzset_r.* *libc.a:lib_a-tzvars.* *libc.a:lib_a-ungetc.* *libc.a:lib_a-utoa.* *libc.a:lib_a-wbuf.* *libc.a:lib_a-wcrtomb.* *libc.a:lib_a-wctomb_r.* *libc.a:lib_a-wsetup.* *libc.a:lock.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_hw_support.a:rtc_wdt.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:lib2funcs.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libheap.a:multi_heap_poisoning.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.* *libxtensa.a:eri.* *libxtensa.a:xtensa_intr_asm.*) .text EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libxt_hal.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libc.a:creat.* *libc.a:isatty.* *libc.a:lib_a-abs.* *libc.a:lib_a-asctime.* *libc.a:lib_a-asctime_r.* *libc.a:lib_a-atoi.* *libc.a:lib_a-atol.* *libc.a:lib_a-bzero.* *libc.a:lib_a-close.* *libc.a:lib_a-creat.* *libc.a:lib_a-ctime.* *libc.a:lib_a-ctime_r.* *libc.a:lib_a-ctype_.* *libc.a:lib_a-div.* *libc.a:lib_a-environ.* *libc.a:lib_a-envlock.* *libc.a:lib_a-fclose.* *libc.a:lib_a-fflush.* *libc.a:lib_a-findfp.* *libc.a:lib_a-fputwc.* *libc.a:lib_a-fvwrite.* *libc.a:lib_a-fwalk.* *libc.a:lib_a-getenv_r.* *libc.a:lib_a-gettzinfo.* *libc.a:lib_a-gmtime.* *libc.a:lib_a-gmtime_r.* *libc.a:lib_a-impure.* *libc.a:lib_a-isalnum.* *libc.a:lib_a-isalpha.* *libc.a:lib_a-isascii.* *libc.a:lib_a-isblank.* *libc.a:lib_a-iscntrl.* *libc.a:lib_a-isdigit.* *libc.a:lib_a-isgraph.* *libc.a:lib_a-islower.* *libc.a:lib_a-isprint.* *libc.a:lib_a-ispunct.* *libc.a:lib_a-isspace.* *libc.a:lib_a-isupper.* *libc.a:lib_a-itoa.* *libc.a:lib_a-labs.* *libc.a:lib_a-lcltime.* *libc.a:lib_a-lcltime_r.* *libc.a:lib_a-ldiv.* *libc.a:lib_a-longjmp.* *libc.a:lib_a-makebuf.* *libc.a:lib_a-memccpy.* *libc.a:lib_a-memchr.* *libc.a:lib_a-memcmp.* *libc.a:lib_a-memcpy.* *libc.a:lib_a-memmove.* *libc.a:lib_a-memrchr.* *libc.a:lib_a-memset.* *libc.a:lib_a-mktime.* *libc.a:lib_a-month_lengths.* *libc.a:lib_a-open.* *libc.a:lib_a-quorem.* *libc.a:lib_a-raise.* *libc.a:lib_a-rand.* *libc.a:lib_a-rand_r.* *libc.a:lib_a-read.* *libc.a:lib_a-refill.* *libc.a:lib_a-rshift.* *libc.a:lib_a-s_fpclassify.* *libc.a:lib_a-sbrk.* *libc.a:lib_a-sccl.* *libc.a:lib_a-setjmp.* *libc.a:lib_a-sf_nan.* *libc.a:lib_a-srand.* *libc.a:lib_a-stdio.* *libc.a:lib_a-strcasecmp.* *libc.a:lib_a-strcasestr.* *libc.a:lib_a-strcat.* *libc.a:lib_a-strchr.* *libc.a:lib_a-strcmp.* *libc.a:lib_a-strcoll.* *libc.a:lib_a-strcpy.* *libc.a:lib_a-strcspn.* *libc.a:lib_a-strdup.* *libc.a:lib_a-strdup_r.* *libc.a:lib_a-strftime.* *libc.a:lib_a-strlcat.* *libc.a:lib_a-strlcpy.* *libc.a:lib_a-strlen.* *libc.a:lib_a-strlwr.* *libc.a:lib_a-strncasecmp.* *libc.a:lib_a-strncat.* *libc.a:lib_a-strncmp.* *libc.a:lib_a-strncpy.* *libc.a:lib_a-strndup.* *libc.a:lib_a-strndup_r.* *libc.a:lib_a-strnlen.* *libc.a:lib_a-strptime.* *libc.a:lib_a-strrchr.* *libc.a:lib_a-strsep.* *libc.a:lib_a-strspn.* *libc.a:lib_a-strstr.* *libc.a:lib_a-strtok_r.* *libc.a:lib_a-strtol.* *libc.a:lib_a-strtoul.* *libc.a:lib_a-strupr.* *libc.a:lib_a-sysclose.* *libc.a:lib_a-sysopen.* *libc.a:lib_a-sysread.* *libc.a:lib_a-syssbrk.* *libc.a:lib_a-system.* *libc.a:lib_a-systimes.* *libc.a:lib_a-syswrite.* *libc.a:lib_a-time.* *libc.a:lib_a-timelocal.* *libc.a:lib_a-toascii.* *libc.a:lib_a-tolower.* *libc.a:lib_a-toupper.* *libc.a:lib_a-tzcalc_limits.* *libc.a:lib_a-tzlock.* *libc.a:lib_a-tzset.* *libc.a:lib_a-tzset_r.* *libc.a:lib_a-tzvars.* *libc.a:lib_a-ungetc.* *libc.a:lib_a-utoa.* *libc.a:lib_a-wbuf.* *libc.a:lib_a-wcrtomb.* *libc.a:lib_a-wctomb_r.* *libc.a:lib_a-wsetup.* *libc.a:lock.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_hw_support.a:rtc_wdt.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:lib2funcs.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libheap.a:multi_heap_poisoning.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.* *libxtensa.a:eri.* *libxtensa.a:xtensa_intr_asm.*) .text.*) + *(EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libxt_hal.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libc.a:creat.* *libc.a:isatty.* *libc.a:lib_a-abs.* *libc.a:lib_a-asctime.* *libc.a:lib_a-asctime_r.* *libc.a:lib_a-atoi.* *libc.a:lib_a-atol.* *libc.a:lib_a-bzero.* *libc.a:lib_a-close.* *libc.a:lib_a-creat.* *libc.a:lib_a-ctime.* *libc.a:lib_a-ctime_r.* *libc.a:lib_a-ctype_.* *libc.a:lib_a-div.* *libc.a:lib_a-environ.* *libc.a:lib_a-envlock.* *libc.a:lib_a-fclose.* *libc.a:lib_a-fflush.* *libc.a:lib_a-findfp.* *libc.a:lib_a-fputwc.* *libc.a:lib_a-fvwrite.* *libc.a:lib_a-fwalk.* *libc.a:lib_a-getenv_r.* *libc.a:lib_a-gettzinfo.* *libc.a:lib_a-gmtime.* *libc.a:lib_a-gmtime_r.* *libc.a:lib_a-impure.* *libc.a:lib_a-isalnum.* *libc.a:lib_a-isalpha.* *libc.a:lib_a-isascii.* *libc.a:lib_a-isblank.* *libc.a:lib_a-iscntrl.* *libc.a:lib_a-isdigit.* *libc.a:lib_a-isgraph.* *libc.a:lib_a-islower.* *libc.a:lib_a-isprint.* *libc.a:lib_a-ispunct.* *libc.a:lib_a-isspace.* *libc.a:lib_a-isupper.* *libc.a:lib_a-itoa.* *libc.a:lib_a-labs.* *libc.a:lib_a-lcltime.* *libc.a:lib_a-lcltime_r.* *libc.a:lib_a-ldiv.* *libc.a:lib_a-longjmp.* *libc.a:lib_a-makebuf.* *libc.a:lib_a-memccpy.* *libc.a:lib_a-memchr.* *libc.a:lib_a-memcmp.* *libc.a:lib_a-memcpy.* *libc.a:lib_a-memmove.* *libc.a:lib_a-memrchr.* *libc.a:lib_a-memset.* *libc.a:lib_a-mktime.* *libc.a:lib_a-month_lengths.* *libc.a:lib_a-open.* *libc.a:lib_a-quorem.* *libc.a:lib_a-raise.* *libc.a:lib_a-rand.* *libc.a:lib_a-rand_r.* *libc.a:lib_a-read.* *libc.a:lib_a-refill.* *libc.a:lib_a-rshift.* *libc.a:lib_a-s_fpclassify.* *libc.a:lib_a-sbrk.* *libc.a:lib_a-sccl.* *libc.a:lib_a-setjmp.* *libc.a:lib_a-sf_nan.* *libc.a:lib_a-srand.* *libc.a:lib_a-stdio.* *libc.a:lib_a-strcasecmp.* *libc.a:lib_a-strcasestr.* *libc.a:lib_a-strcat.* *libc.a:lib_a-strchr.* *libc.a:lib_a-strcmp.* *libc.a:lib_a-strcoll.* *libc.a:lib_a-strcpy.* *libc.a:lib_a-strcspn.* *libc.a:lib_a-strdup.* *libc.a:lib_a-strdup_r.* *libc.a:lib_a-strftime.* *libc.a:lib_a-strlcat.* *libc.a:lib_a-strlcpy.* *libc.a:lib_a-strlen.* *libc.a:lib_a-strlwr.* *libc.a:lib_a-strncasecmp.* *libc.a:lib_a-strncat.* *libc.a:lib_a-strncmp.* *libc.a:lib_a-strncpy.* *libc.a:lib_a-strndup.* *libc.a:lib_a-strndup_r.* *libc.a:lib_a-strnlen.* *libc.a:lib_a-strptime.* *libc.a:lib_a-strrchr.* *libc.a:lib_a-strsep.* *libc.a:lib_a-strspn.* *libc.a:lib_a-strstr.* *libc.a:lib_a-strtok_r.* *libc.a:lib_a-strtol.* *libc.a:lib_a-strtoul.* *libc.a:lib_a-strupr.* *libc.a:lib_a-sysclose.* *libc.a:lib_a-sysopen.* *libc.a:lib_a-sysread.* *libc.a:lib_a-syssbrk.* *libc.a:lib_a-system.* *libc.a:lib_a-systimes.* *libc.a:lib_a-syswrite.* *libc.a:lib_a-time.* *libc.a:lib_a-timelocal.* *libc.a:lib_a-toascii.* *libc.a:lib_a-tolower.* *libc.a:lib_a-toupper.* *libc.a:lib_a-tzcalc_limits.* *libc.a:lib_a-tzlock.* *libc.a:lib_a-tzset.* *libc.a:lib_a-tzset_r.* *libc.a:lib_a-tzvars.* *libc.a:lib_a-ungetc.* *libc.a:lib_a-utoa.* *libc.a:lib_a-wbuf.* *libc.a:lib_a-wcrtomb.* *libc.a:lib_a-wctomb_r.* *libc.a:lib_a-wsetup.* *libc.a:lock.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_hw_support.a:rtc_wdt.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:lib2funcs.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libheap.a:multi_heap_poisoning.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:assert.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.* *libxtensa.a:eri.* *libxtensa.a:xtensa_intr_asm.*) .literal EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libxt_hal.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libc.a:creat.* *libc.a:isatty.* *libc.a:lib_a-abs.* *libc.a:lib_a-asctime.* *libc.a:lib_a-asctime_r.* *libc.a:lib_a-atoi.* *libc.a:lib_a-atol.* *libc.a:lib_a-bzero.* *libc.a:lib_a-close.* *libc.a:lib_a-creat.* *libc.a:lib_a-ctime.* *libc.a:lib_a-ctime_r.* *libc.a:lib_a-ctype_.* *libc.a:lib_a-div.* *libc.a:lib_a-environ.* *libc.a:lib_a-envlock.* *libc.a:lib_a-fclose.* *libc.a:lib_a-fflush.* *libc.a:lib_a-findfp.* *libc.a:lib_a-fputwc.* *libc.a:lib_a-fvwrite.* *libc.a:lib_a-fwalk.* *libc.a:lib_a-getenv_r.* *libc.a:lib_a-gettzinfo.* *libc.a:lib_a-gmtime.* *libc.a:lib_a-gmtime_r.* *libc.a:lib_a-impure.* *libc.a:lib_a-isalnum.* *libc.a:lib_a-isalpha.* *libc.a:lib_a-isascii.* *libc.a:lib_a-isblank.* *libc.a:lib_a-iscntrl.* *libc.a:lib_a-isdigit.* *libc.a:lib_a-isgraph.* *libc.a:lib_a-islower.* *libc.a:lib_a-isprint.* *libc.a:lib_a-ispunct.* *libc.a:lib_a-isspace.* *libc.a:lib_a-isupper.* *libc.a:lib_a-itoa.* *libc.a:lib_a-labs.* *libc.a:lib_a-lcltime.* *libc.a:lib_a-lcltime_r.* *libc.a:lib_a-ldiv.* *libc.a:lib_a-longjmp.* *libc.a:lib_a-makebuf.* *libc.a:lib_a-memccpy.* *libc.a:lib_a-memchr.* *libc.a:lib_a-memcmp.* *libc.a:lib_a-memcpy.* *libc.a:lib_a-memmove.* *libc.a:lib_a-memrchr.* *libc.a:lib_a-memset.* *libc.a:lib_a-mktime.* *libc.a:lib_a-month_lengths.* *libc.a:lib_a-open.* *libc.a:lib_a-quorem.* *libc.a:lib_a-raise.* *libc.a:lib_a-rand.* *libc.a:lib_a-rand_r.* *libc.a:lib_a-read.* *libc.a:lib_a-refill.* *libc.a:lib_a-rshift.* *libc.a:lib_a-s_fpclassify.* *libc.a:lib_a-sbrk.* *libc.a:lib_a-sccl.* *libc.a:lib_a-setjmp.* *libc.a:lib_a-sf_nan.* *libc.a:lib_a-srand.* *libc.a:lib_a-stdio.* *libc.a:lib_a-strcasecmp.* *libc.a:lib_a-strcasestr.* *libc.a:lib_a-strcat.* *libc.a:lib_a-strchr.* *libc.a:lib_a-strcmp.* *libc.a:lib_a-strcoll.* *libc.a:lib_a-strcpy.* *libc.a:lib_a-strcspn.* *libc.a:lib_a-strdup.* *libc.a:lib_a-strdup_r.* *libc.a:lib_a-strftime.* *libc.a:lib_a-strlcat.* *libc.a:lib_a-strlcpy.* *libc.a:lib_a-strlen.* *libc.a:lib_a-strlwr.* *libc.a:lib_a-strncasecmp.* *libc.a:lib_a-strncat.* *libc.a:lib_a-strncmp.* *libc.a:lib_a-strncpy.* *libc.a:lib_a-strndup.* *libc.a:lib_a-strndup_r.* *libc.a:lib_a-strnlen.* *libc.a:lib_a-strptime.* *libc.a:lib_a-strrchr.* *libc.a:lib_a-strsep.* *libc.a:lib_a-strspn.* *libc.a:lib_a-strstr.* *libc.a:lib_a-strtok_r.* *libc.a:lib_a-strtol.* *libc.a:lib_a-strtoul.* *libc.a:lib_a-strupr.* *libc.a:lib_a-sysclose.* *libc.a:lib_a-sysopen.* *libc.a:lib_a-sysread.* *libc.a:lib_a-syssbrk.* *libc.a:lib_a-system.* *libc.a:lib_a-systimes.* *libc.a:lib_a-syswrite.* *libc.a:lib_a-time.* *libc.a:lib_a-timelocal.* *libc.a:lib_a-toascii.* *libc.a:lib_a-tolower.* *libc.a:lib_a-toupper.* *libc.a:lib_a-tzcalc_limits.* *libc.a:lib_a-tzlock.* *libc.a:lib_a-tzset.* *libc.a:lib_a-tzset_r.* *libc.a:lib_a-tzvars.* *libc.a:lib_a-ungetc.* *libc.a:lib_a-utoa.* *libc.a:lib_a-wbuf.* *libc.a:lib_a-wcrtomb.* *libc.a:lib_a-wctomb_r.* *libc.a:lib_a-wsetup.* *libc.a:lock.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_hw_support.a:rtc_wdt.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:lib2funcs.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libheap.a:multi_heap_poisoning.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:assert.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.* *libxtensa.a:eri.* *libxtensa.a:xtensa_intr_asm.*) .literal.* EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libxt_hal.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libc.a:creat.* *libc.a:isatty.* *libc.a:lib_a-abs.* *libc.a:lib_a-asctime.* *libc.a:lib_a-asctime_r.* *libc.a:lib_a-atoi.* *libc.a:lib_a-atol.* *libc.a:lib_a-bzero.* *libc.a:lib_a-close.* *libc.a:lib_a-creat.* *libc.a:lib_a-ctime.* *libc.a:lib_a-ctime_r.* *libc.a:lib_a-ctype_.* *libc.a:lib_a-div.* *libc.a:lib_a-environ.* *libc.a:lib_a-envlock.* *libc.a:lib_a-fclose.* *libc.a:lib_a-fflush.* *libc.a:lib_a-findfp.* *libc.a:lib_a-fputwc.* *libc.a:lib_a-fvwrite.* *libc.a:lib_a-fwalk.* *libc.a:lib_a-getenv_r.* *libc.a:lib_a-gettzinfo.* *libc.a:lib_a-gmtime.* *libc.a:lib_a-gmtime_r.* *libc.a:lib_a-impure.* *libc.a:lib_a-isalnum.* *libc.a:lib_a-isalpha.* *libc.a:lib_a-isascii.* *libc.a:lib_a-isblank.* *libc.a:lib_a-iscntrl.* *libc.a:lib_a-isdigit.* *libc.a:lib_a-isgraph.* *libc.a:lib_a-islower.* *libc.a:lib_a-isprint.* *libc.a:lib_a-ispunct.* *libc.a:lib_a-isspace.* *libc.a:lib_a-isupper.* *libc.a:lib_a-itoa.* *libc.a:lib_a-labs.* *libc.a:lib_a-lcltime.* *libc.a:lib_a-lcltime_r.* *libc.a:lib_a-ldiv.* *libc.a:lib_a-longjmp.* *libc.a:lib_a-makebuf.* *libc.a:lib_a-memccpy.* *libc.a:lib_a-memchr.* *libc.a:lib_a-memcmp.* *libc.a:lib_a-memcpy.* *libc.a:lib_a-memmove.* *libc.a:lib_a-memrchr.* *libc.a:lib_a-memset.* *libc.a:lib_a-mktime.* *libc.a:lib_a-month_lengths.* *libc.a:lib_a-open.* *libc.a:lib_a-quorem.* *libc.a:lib_a-raise.* *libc.a:lib_a-rand.* *libc.a:lib_a-rand_r.* *libc.a:lib_a-read.* *libc.a:lib_a-refill.* *libc.a:lib_a-rshift.* *libc.a:lib_a-s_fpclassify.* *libc.a:lib_a-sbrk.* *libc.a:lib_a-sccl.* *libc.a:lib_a-setjmp.* *libc.a:lib_a-sf_nan.* *libc.a:lib_a-srand.* *libc.a:lib_a-stdio.* *libc.a:lib_a-strcasecmp.* *libc.a:lib_a-strcasestr.* *libc.a:lib_a-strcat.* *libc.a:lib_a-strchr.* *libc.a:lib_a-strcmp.* *libc.a:lib_a-strcoll.* *libc.a:lib_a-strcpy.* *libc.a:lib_a-strcspn.* *libc.a:lib_a-strdup.* *libc.a:lib_a-strdup_r.* *libc.a:lib_a-strftime.* *libc.a:lib_a-strlcat.* *libc.a:lib_a-strlcpy.* *libc.a:lib_a-strlen.* *libc.a:lib_a-strlwr.* *libc.a:lib_a-strncasecmp.* *libc.a:lib_a-strncat.* *libc.a:lib_a-strncmp.* *libc.a:lib_a-strncpy.* *libc.a:lib_a-strndup.* *libc.a:lib_a-strndup_r.* *libc.a:lib_a-strnlen.* *libc.a:lib_a-strptime.* *libc.a:lib_a-strrchr.* *libc.a:lib_a-strsep.* *libc.a:lib_a-strspn.* *libc.a:lib_a-strstr.* *libc.a:lib_a-strtok_r.* *libc.a:lib_a-strtol.* *libc.a:lib_a-strtoul.* *libc.a:lib_a-strupr.* *libc.a:lib_a-sysclose.* *libc.a:lib_a-sysopen.* *libc.a:lib_a-sysread.* *libc.a:lib_a-syssbrk.* *libc.a:lib_a-system.* *libc.a:lib_a-systimes.* *libc.a:lib_a-syswrite.* *libc.a:lib_a-time.* *libc.a:lib_a-timelocal.* *libc.a:lib_a-toascii.* *libc.a:lib_a-tolower.* *libc.a:lib_a-toupper.* *libc.a:lib_a-tzcalc_limits.* *libc.a:lib_a-tzlock.* *libc.a:lib_a-tzset.* *libc.a:lib_a-tzset_r.* *libc.a:lib_a-tzvars.* *libc.a:lib_a-ungetc.* *libc.a:lib_a-utoa.* *libc.a:lib_a-wbuf.* *libc.a:lib_a-wcrtomb.* *libc.a:lib_a-wctomb_r.* *libc.a:lib_a-wsetup.* *libc.a:lock.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_hw_support.a:rtc_wdt.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:lib2funcs.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libheap.a:multi_heap_poisoning.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:assert.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.* *libxtensa.a:eri.* *libxtensa.a:xtensa_intr_asm.*) .text EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libxt_hal.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libc.a:creat.* *libc.a:isatty.* *libc.a:lib_a-abs.* *libc.a:lib_a-asctime.* *libc.a:lib_a-asctime_r.* *libc.a:lib_a-atoi.* *libc.a:lib_a-atol.* *libc.a:lib_a-bzero.* *libc.a:lib_a-close.* *libc.a:lib_a-creat.* *libc.a:lib_a-ctime.* *libc.a:lib_a-ctime_r.* *libc.a:lib_a-ctype_.* *libc.a:lib_a-div.* *libc.a:lib_a-environ.* *libc.a:lib_a-envlock.* *libc.a:lib_a-fclose.* *libc.a:lib_a-fflush.* *libc.a:lib_a-findfp.* *libc.a:lib_a-fputwc.* *libc.a:lib_a-fvwrite.* *libc.a:lib_a-fwalk.* *libc.a:lib_a-getenv_r.* *libc.a:lib_a-gettzinfo.* *libc.a:lib_a-gmtime.* *libc.a:lib_a-gmtime_r.* *libc.a:lib_a-impure.* *libc.a:lib_a-isalnum.* *libc.a:lib_a-isalpha.* *libc.a:lib_a-isascii.* *libc.a:lib_a-isblank.* *libc.a:lib_a-iscntrl.* *libc.a:lib_a-isdigit.* *libc.a:lib_a-isgraph.* *libc.a:lib_a-islower.* *libc.a:lib_a-isprint.* *libc.a:lib_a-ispunct.* *libc.a:lib_a-isspace.* *libc.a:lib_a-isupper.* *libc.a:lib_a-itoa.* *libc.a:lib_a-labs.* *libc.a:lib_a-lcltime.* *libc.a:lib_a-lcltime_r.* *libc.a:lib_a-ldiv.* *libc.a:lib_a-longjmp.* *libc.a:lib_a-makebuf.* *libc.a:lib_a-memccpy.* *libc.a:lib_a-memchr.* *libc.a:lib_a-memcmp.* *libc.a:lib_a-memcpy.* *libc.a:lib_a-memmove.* *libc.a:lib_a-memrchr.* *libc.a:lib_a-memset.* *libc.a:lib_a-mktime.* *libc.a:lib_a-month_lengths.* *libc.a:lib_a-open.* *libc.a:lib_a-quorem.* *libc.a:lib_a-raise.* *libc.a:lib_a-rand.* *libc.a:lib_a-rand_r.* *libc.a:lib_a-read.* *libc.a:lib_a-refill.* *libc.a:lib_a-rshift.* *libc.a:lib_a-s_fpclassify.* *libc.a:lib_a-sbrk.* *libc.a:lib_a-sccl.* *libc.a:lib_a-setjmp.* *libc.a:lib_a-sf_nan.* *libc.a:lib_a-srand.* *libc.a:lib_a-stdio.* *libc.a:lib_a-strcasecmp.* *libc.a:lib_a-strcasestr.* *libc.a:lib_a-strcat.* *libc.a:lib_a-strchr.* *libc.a:lib_a-strcmp.* *libc.a:lib_a-strcoll.* *libc.a:lib_a-strcpy.* *libc.a:lib_a-strcspn.* *libc.a:lib_a-strdup.* *libc.a:lib_a-strdup_r.* *libc.a:lib_a-strftime.* *libc.a:lib_a-strlcat.* *libc.a:lib_a-strlcpy.* *libc.a:lib_a-strlen.* *libc.a:lib_a-strlwr.* *libc.a:lib_a-strncasecmp.* *libc.a:lib_a-strncat.* *libc.a:lib_a-strncmp.* *libc.a:lib_a-strncpy.* *libc.a:lib_a-strndup.* *libc.a:lib_a-strndup_r.* *libc.a:lib_a-strnlen.* *libc.a:lib_a-strptime.* *libc.a:lib_a-strrchr.* *libc.a:lib_a-strsep.* *libc.a:lib_a-strspn.* *libc.a:lib_a-strstr.* *libc.a:lib_a-strtok_r.* *libc.a:lib_a-strtol.* *libc.a:lib_a-strtoul.* *libc.a:lib_a-strupr.* *libc.a:lib_a-sysclose.* *libc.a:lib_a-sysopen.* *libc.a:lib_a-sysread.* *libc.a:lib_a-syssbrk.* *libc.a:lib_a-system.* *libc.a:lib_a-systimes.* *libc.a:lib_a-syswrite.* *libc.a:lib_a-time.* *libc.a:lib_a-timelocal.* *libc.a:lib_a-toascii.* *libc.a:lib_a-tolower.* *libc.a:lib_a-toupper.* *libc.a:lib_a-tzcalc_limits.* *libc.a:lib_a-tzlock.* *libc.a:lib_a-tzset.* *libc.a:lib_a-tzset_r.* *libc.a:lib_a-tzvars.* *libc.a:lib_a-ungetc.* *libc.a:lib_a-utoa.* *libc.a:lib_a-wbuf.* *libc.a:lib_a-wcrtomb.* *libc.a:lib_a-wctomb_r.* *libc.a:lib_a-wsetup.* *libc.a:lock.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_hw_support.a:rtc_wdt.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:lib2funcs.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libheap.a:multi_heap_poisoning.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:assert.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.* *libxtensa.a:eri.* *libxtensa.a:xtensa_intr_asm.*) .text.*) *(.wifi0iram .wifi0iram.*) *(.wifiorslpiram .wifiorslpiram.*) *(.wifirxiram .wifirxiram.*) @@ -728,7 +742,7 @@ SECTIONS * safe access to up to 16 bytes after the last real instruction, add * dummy bytes to ensure this */ - . += 16; + . += _esp_flash_mmap_prefetch_pad_size; _text_end = ABSOLUTE(.); _etext = .; diff --git a/tools/sdk/esp32/lib/libapp_trace.a b/tools/sdk/esp32/lib/libapp_trace.a index ae7a037294c..457355a9cff 100644 Binary files a/tools/sdk/esp32/lib/libapp_trace.a and b/tools/sdk/esp32/lib/libapp_trace.a differ diff --git a/tools/sdk/esp32/lib/libapp_update.a b/tools/sdk/esp32/lib/libapp_update.a index 76308dc725a..551bfb86cf9 100644 Binary files a/tools/sdk/esp32/lib/libapp_update.a and b/tools/sdk/esp32/lib/libapp_update.a differ diff --git a/tools/sdk/esp32/lib/libasio.a b/tools/sdk/esp32/lib/libasio.a index 931755d4169..69e072d1737 100644 Binary files a/tools/sdk/esp32/lib/libasio.a and b/tools/sdk/esp32/lib/libasio.a differ diff --git a/tools/sdk/esp32/lib/libbootloader_support.a b/tools/sdk/esp32/lib/libbootloader_support.a index b0bafec2fad..db0df17b7a6 100644 Binary files a/tools/sdk/esp32/lib/libbootloader_support.a and b/tools/sdk/esp32/lib/libbootloader_support.a differ diff --git a/tools/sdk/esp32/lib/libbt.a b/tools/sdk/esp32/lib/libbt.a index 6070e9ead5e..cf6f28abaf3 100644 Binary files a/tools/sdk/esp32/lib/libbt.a and b/tools/sdk/esp32/lib/libbt.a differ diff --git a/tools/sdk/esp32/lib/libbutton.a b/tools/sdk/esp32/lib/libbutton.a index a8f591783e4..ee6935a6eaf 100644 Binary files a/tools/sdk/esp32/lib/libbutton.a and b/tools/sdk/esp32/lib/libbutton.a differ diff --git a/tools/sdk/esp32/lib/libcbor.a b/tools/sdk/esp32/lib/libcbor.a index 1c400175953..2a9cb841698 100644 Binary files a/tools/sdk/esp32/lib/libcbor.a and b/tools/sdk/esp32/lib/libcbor.a differ diff --git a/tools/sdk/esp32/lib/libcoap.a b/tools/sdk/esp32/lib/libcoap.a index 0fea85aea3e..475f344c21a 100644 Binary files a/tools/sdk/esp32/lib/libcoap.a and b/tools/sdk/esp32/lib/libcoap.a differ diff --git a/tools/sdk/esp32/lib/libcoexist.a b/tools/sdk/esp32/lib/libcoexist.a index ded319fa12d..6a07d9fab49 100644 Binary files a/tools/sdk/esp32/lib/libcoexist.a and b/tools/sdk/esp32/lib/libcoexist.a differ diff --git a/tools/sdk/esp32/lib/libconsole.a b/tools/sdk/esp32/lib/libconsole.a index 63844404197..f711007592c 100644 Binary files a/tools/sdk/esp32/lib/libconsole.a and b/tools/sdk/esp32/lib/libconsole.a differ diff --git a/tools/sdk/esp32/lib/libcore.a b/tools/sdk/esp32/lib/libcore.a index f4d37b8b33d..5dfca587210 100644 Binary files a/tools/sdk/esp32/lib/libcore.a and b/tools/sdk/esp32/lib/libcore.a differ diff --git a/tools/sdk/esp32/lib/libcxx.a b/tools/sdk/esp32/lib/libcxx.a index 8082c898563..ef0e12ce41d 100644 Binary files a/tools/sdk/esp32/lib/libcxx.a and b/tools/sdk/esp32/lib/libcxx.a differ diff --git a/tools/sdk/esp32/lib/libdriver.a b/tools/sdk/esp32/lib/libdriver.a index 4eb6968d756..f238bbb787e 100644 Binary files a/tools/sdk/esp32/lib/libdriver.a and b/tools/sdk/esp32/lib/libdriver.a differ diff --git a/tools/sdk/esp32/lib/libefuse.a b/tools/sdk/esp32/lib/libefuse.a index ed5424d2307..3f941fd6035 100644 Binary files a/tools/sdk/esp32/lib/libefuse.a and b/tools/sdk/esp32/lib/libefuse.a differ diff --git a/tools/sdk/esp32/lib/libesp-dsp.a b/tools/sdk/esp32/lib/libesp-dsp.a index 755966b3799..49b548eaf7a 100644 Binary files a/tools/sdk/esp32/lib/libesp-dsp.a and b/tools/sdk/esp32/lib/libesp-dsp.a differ diff --git a/tools/sdk/esp32/lib/libesp-face.a b/tools/sdk/esp32/lib/libesp-face.a deleted file mode 100644 index d0190b7e6c5..00000000000 Binary files a/tools/sdk/esp32/lib/libesp-face.a and /dev/null differ diff --git a/tools/sdk/esp32/lib/libesp-tls.a b/tools/sdk/esp32/lib/libesp-tls.a index 31107e8cccc..b68a26e8905 100644 Binary files a/tools/sdk/esp32/lib/libesp-tls.a and b/tools/sdk/esp32/lib/libesp-tls.a differ diff --git a/tools/sdk/esp32/lib/libesp32-camera.a b/tools/sdk/esp32/lib/libesp32-camera.a index 15b3e06df25..0514d6ce494 100644 Binary files a/tools/sdk/esp32/lib/libesp32-camera.a and b/tools/sdk/esp32/lib/libesp32-camera.a differ diff --git a/tools/sdk/esp32/lib/libesp_adc_cal.a b/tools/sdk/esp32/lib/libesp_adc_cal.a index f8b9308d2f7..0440a8e137a 100644 Binary files a/tools/sdk/esp32/lib/libesp_adc_cal.a and b/tools/sdk/esp32/lib/libesp_adc_cal.a differ diff --git a/tools/sdk/esp32/lib/libesp_common.a b/tools/sdk/esp32/lib/libesp_common.a index fabb2371dcb..55ad6397248 100644 Binary files a/tools/sdk/esp32/lib/libesp_common.a and b/tools/sdk/esp32/lib/libesp_common.a differ diff --git a/tools/sdk/esp32/lib/libesp_eth.a b/tools/sdk/esp32/lib/libesp_eth.a index eb638b4417f..b1929f1e507 100644 Binary files a/tools/sdk/esp32/lib/libesp_eth.a and b/tools/sdk/esp32/lib/libesp_eth.a differ diff --git a/tools/sdk/esp32/lib/libesp_event.a b/tools/sdk/esp32/lib/libesp_event.a index a2884afb5a8..553ea1c7aee 100644 Binary files a/tools/sdk/esp32/lib/libesp_event.a and b/tools/sdk/esp32/lib/libesp_event.a differ diff --git a/tools/sdk/esp32/lib/libesp_gdbstub.a b/tools/sdk/esp32/lib/libesp_gdbstub.a index 7be2059d8a7..4532df2f78a 100644 Binary files a/tools/sdk/esp32/lib/libesp_gdbstub.a and b/tools/sdk/esp32/lib/libesp_gdbstub.a differ diff --git a/tools/sdk/esp32/lib/libesp_hid.a b/tools/sdk/esp32/lib/libesp_hid.a index e133f66da49..81355c91e67 100644 Binary files a/tools/sdk/esp32/lib/libesp_hid.a and b/tools/sdk/esp32/lib/libesp_hid.a differ diff --git a/tools/sdk/esp32/lib/libesp_http_client.a b/tools/sdk/esp32/lib/libesp_http_client.a index 7f53744d5d2..9d084d94942 100644 Binary files a/tools/sdk/esp32/lib/libesp_http_client.a and b/tools/sdk/esp32/lib/libesp_http_client.a differ diff --git a/tools/sdk/esp32/lib/libesp_http_server.a b/tools/sdk/esp32/lib/libesp_http_server.a index ab9bb6dc8ec..f20074b7e94 100644 Binary files a/tools/sdk/esp32/lib/libesp_http_server.a and b/tools/sdk/esp32/lib/libesp_http_server.a differ diff --git a/tools/sdk/esp32/lib/libesp_https_ota.a b/tools/sdk/esp32/lib/libesp_https_ota.a index 510e8ee36f4..c8f743f733a 100644 Binary files a/tools/sdk/esp32/lib/libesp_https_ota.a and b/tools/sdk/esp32/lib/libesp_https_ota.a differ diff --git a/tools/sdk/esp32/lib/libesp_hw_support.a b/tools/sdk/esp32/lib/libesp_hw_support.a index b00299c3661..8b318d6bfdb 100644 Binary files a/tools/sdk/esp32/lib/libesp_hw_support.a and b/tools/sdk/esp32/lib/libesp_hw_support.a differ diff --git a/tools/sdk/esp32/lib/libesp_ipc.a b/tools/sdk/esp32/lib/libesp_ipc.a index 5b82b32f8fb..8958f861427 100644 Binary files a/tools/sdk/esp32/lib/libesp_ipc.a and b/tools/sdk/esp32/lib/libesp_ipc.a differ diff --git a/tools/sdk/esp32/lib/libesp_lcd.a b/tools/sdk/esp32/lib/libesp_lcd.a index db4b19ad25a..1801d9b8755 100644 Binary files a/tools/sdk/esp32/lib/libesp_lcd.a and b/tools/sdk/esp32/lib/libesp_lcd.a differ diff --git a/tools/sdk/esp32/lib/libesp_littlefs.a b/tools/sdk/esp32/lib/libesp_littlefs.a index 1813366368b..38290da68ae 100644 Binary files a/tools/sdk/esp32/lib/libesp_littlefs.a and b/tools/sdk/esp32/lib/libesp_littlefs.a differ diff --git a/tools/sdk/esp32/lib/libesp_local_ctrl.a b/tools/sdk/esp32/lib/libesp_local_ctrl.a index e38d78b67d6..e1f10c0dffe 100644 Binary files a/tools/sdk/esp32/lib/libesp_local_ctrl.a and b/tools/sdk/esp32/lib/libesp_local_ctrl.a differ diff --git a/tools/sdk/esp32/lib/libesp_netif.a b/tools/sdk/esp32/lib/libesp_netif.a index 871b9fa0cd5..d606140499b 100644 Binary files a/tools/sdk/esp32/lib/libesp_netif.a and b/tools/sdk/esp32/lib/libesp_netif.a differ diff --git a/tools/sdk/esp32/lib/libesp_phy.a b/tools/sdk/esp32/lib/libesp_phy.a index 096f9d7a45c..3abd25f53b2 100644 Binary files a/tools/sdk/esp32/lib/libesp_phy.a and b/tools/sdk/esp32/lib/libesp_phy.a differ diff --git a/tools/sdk/esp32/lib/libesp_pm.a b/tools/sdk/esp32/lib/libesp_pm.a index 0c4e51e5989..39cb0ce9527 100644 Binary files a/tools/sdk/esp32/lib/libesp_pm.a and b/tools/sdk/esp32/lib/libesp_pm.a differ diff --git a/tools/sdk/esp32/lib/libesp_rainmaker.a b/tools/sdk/esp32/lib/libesp_rainmaker.a index 372517c2481..eb552bda46d 100644 Binary files a/tools/sdk/esp32/lib/libesp_rainmaker.a and b/tools/sdk/esp32/lib/libesp_rainmaker.a differ diff --git a/tools/sdk/esp32/lib/libesp_ringbuf.a b/tools/sdk/esp32/lib/libesp_ringbuf.a index d287666a1d1..e3fe56d6590 100644 Binary files a/tools/sdk/esp32/lib/libesp_ringbuf.a and b/tools/sdk/esp32/lib/libesp_ringbuf.a differ diff --git a/tools/sdk/esp32/lib/libesp_rom.a b/tools/sdk/esp32/lib/libesp_rom.a index c25ad02c9e8..a6d86d724ed 100644 Binary files a/tools/sdk/esp32/lib/libesp_rom.a and b/tools/sdk/esp32/lib/libesp_rom.a differ diff --git a/tools/sdk/esp32/lib/libesp_schedule.a b/tools/sdk/esp32/lib/libesp_schedule.a index a7f0585dfbd..13d28e57465 100644 Binary files a/tools/sdk/esp32/lib/libesp_schedule.a and b/tools/sdk/esp32/lib/libesp_schedule.a differ diff --git a/tools/sdk/esp32/lib/libesp_serial_slave_link.a b/tools/sdk/esp32/lib/libesp_serial_slave_link.a index 2faf1f9832c..0f49c488742 100644 Binary files a/tools/sdk/esp32/lib/libesp_serial_slave_link.a and b/tools/sdk/esp32/lib/libesp_serial_slave_link.a differ diff --git a/tools/sdk/esp32/lib/libesp_system.a b/tools/sdk/esp32/lib/libesp_system.a index eafe70d616c..f50673a65c4 100644 Binary files a/tools/sdk/esp32/lib/libesp_system.a and b/tools/sdk/esp32/lib/libesp_system.a differ diff --git a/tools/sdk/esp32/lib/libesp_timer.a b/tools/sdk/esp32/lib/libesp_timer.a index 6f3397b2283..6dd4d143f6e 100644 Binary files a/tools/sdk/esp32/lib/libesp_timer.a and b/tools/sdk/esp32/lib/libesp_timer.a differ diff --git a/tools/sdk/esp32/lib/libesp_websocket_client.a b/tools/sdk/esp32/lib/libesp_websocket_client.a index bdf84cd373d..4ea65a16e18 100644 Binary files a/tools/sdk/esp32/lib/libesp_websocket_client.a and b/tools/sdk/esp32/lib/libesp_websocket_client.a differ diff --git a/tools/sdk/esp32/lib/libesp_wifi.a b/tools/sdk/esp32/lib/libesp_wifi.a index afae8ae4882..6d7bcc29315 100644 Binary files a/tools/sdk/esp32/lib/libesp_wifi.a and b/tools/sdk/esp32/lib/libesp_wifi.a differ diff --git a/tools/sdk/esp32/lib/libespcoredump.a b/tools/sdk/esp32/lib/libespcoredump.a index 680514c1235..25cd8820b99 100644 Binary files a/tools/sdk/esp32/lib/libespcoredump.a and b/tools/sdk/esp32/lib/libespcoredump.a differ diff --git a/tools/sdk/esp32/lib/libespnow.a b/tools/sdk/esp32/lib/libespnow.a index a9de3a21de8..9b53365726b 100644 Binary files a/tools/sdk/esp32/lib/libespnow.a and b/tools/sdk/esp32/lib/libespnow.a differ diff --git a/tools/sdk/esp32/lib/libexpat.a b/tools/sdk/esp32/lib/libexpat.a index 9549a1538eb..6935208e49f 100644 Binary files a/tools/sdk/esp32/lib/libexpat.a and b/tools/sdk/esp32/lib/libexpat.a differ diff --git a/tools/sdk/esp32/lib/libfatfs.a b/tools/sdk/esp32/lib/libfatfs.a index 76d671bda7c..4ee8d7990ed 100644 Binary files a/tools/sdk/esp32/lib/libfatfs.a and b/tools/sdk/esp32/lib/libfatfs.a differ diff --git a/tools/sdk/esp32/lib/libfreemodbus.a b/tools/sdk/esp32/lib/libfreemodbus.a index da875643e53..66297b41164 100644 Binary files a/tools/sdk/esp32/lib/libfreemodbus.a and b/tools/sdk/esp32/lib/libfreemodbus.a differ diff --git a/tools/sdk/esp32/lib/libfreertos.a b/tools/sdk/esp32/lib/libfreertos.a index 4b7bd969236..310a0260efa 100644 Binary files a/tools/sdk/esp32/lib/libfreertos.a and b/tools/sdk/esp32/lib/libfreertos.a differ diff --git a/tools/sdk/esp32/lib/libhal.a b/tools/sdk/esp32/lib/libhal.a index 700c869e46e..1ec5baa88e8 100644 Binary files a/tools/sdk/esp32/lib/libhal.a and b/tools/sdk/esp32/lib/libhal.a differ diff --git a/tools/sdk/esp32/lib/libheap.a b/tools/sdk/esp32/lib/libheap.a index 4c0fe489007..9c1f8d53e6e 100644 Binary files a/tools/sdk/esp32/lib/libheap.a and b/tools/sdk/esp32/lib/libheap.a differ diff --git a/tools/sdk/esp32/lib/libjson.a b/tools/sdk/esp32/lib/libjson.a index a1426ffe025..cf7d8626fc9 100644 Binary files a/tools/sdk/esp32/lib/libjson.a and b/tools/sdk/esp32/lib/libjson.a differ diff --git a/tools/sdk/esp32/lib/liblibsodium.a b/tools/sdk/esp32/lib/liblibsodium.a index afe3ddc8475..938b26806f4 100644 Binary files a/tools/sdk/esp32/lib/liblibsodium.a and b/tools/sdk/esp32/lib/liblibsodium.a differ diff --git a/tools/sdk/esp32/lib/liblog.a b/tools/sdk/esp32/lib/liblog.a index 02dc4609677..32d9e92b187 100644 Binary files a/tools/sdk/esp32/lib/liblog.a and b/tools/sdk/esp32/lib/liblog.a differ diff --git a/tools/sdk/esp32/lib/liblwip.a b/tools/sdk/esp32/lib/liblwip.a index c07958af921..ad6dcde9e98 100644 Binary files a/tools/sdk/esp32/lib/liblwip.a and b/tools/sdk/esp32/lib/liblwip.a differ diff --git a/tools/sdk/esp32/lib/libmbedcrypto.a b/tools/sdk/esp32/lib/libmbedcrypto.a index f609aa225a1..b63bf72ce9b 100644 Binary files a/tools/sdk/esp32/lib/libmbedcrypto.a and b/tools/sdk/esp32/lib/libmbedcrypto.a differ diff --git a/tools/sdk/esp32/lib/libmbedtls.a b/tools/sdk/esp32/lib/libmbedtls.a index 434d753318f..116564a2f60 100644 Binary files a/tools/sdk/esp32/lib/libmbedtls.a and b/tools/sdk/esp32/lib/libmbedtls.a differ diff --git a/tools/sdk/esp32/lib/libmbedx509.a b/tools/sdk/esp32/lib/libmbedx509.a index fef896b479a..0c60ab90cab 100644 Binary files a/tools/sdk/esp32/lib/libmbedx509.a and b/tools/sdk/esp32/lib/libmbedx509.a differ diff --git a/tools/sdk/esp32/lib/libmdns.a b/tools/sdk/esp32/lib/libmdns.a index 858aed4dbd2..a07fbbd45ea 100644 Binary files a/tools/sdk/esp32/lib/libmdns.a and b/tools/sdk/esp32/lib/libmdns.a differ diff --git a/tools/sdk/esp32/lib/libmesh.a b/tools/sdk/esp32/lib/libmesh.a index e0b5750419a..9a32bef01fd 100644 Binary files a/tools/sdk/esp32/lib/libmesh.a and b/tools/sdk/esp32/lib/libmesh.a differ diff --git a/tools/sdk/esp32/lib/libmqtt.a b/tools/sdk/esp32/lib/libmqtt.a index c1770a7ee08..127053e6c78 100644 Binary files a/tools/sdk/esp32/lib/libmqtt.a and b/tools/sdk/esp32/lib/libmqtt.a differ diff --git a/tools/sdk/esp32/lib/libnet80211.a b/tools/sdk/esp32/lib/libnet80211.a index ab910a6ccb8..75b75922b13 100644 Binary files a/tools/sdk/esp32/lib/libnet80211.a and b/tools/sdk/esp32/lib/libnet80211.a differ diff --git a/tools/sdk/esp32/lib/libnewlib.a b/tools/sdk/esp32/lib/libnewlib.a index 7853e895853..0f96d134212 100644 Binary files a/tools/sdk/esp32/lib/libnewlib.a and b/tools/sdk/esp32/lib/libnewlib.a differ diff --git a/tools/sdk/esp32/lib/libnghttp.a b/tools/sdk/esp32/lib/libnghttp.a index 32713088d28..b8d76a83672 100644 Binary files a/tools/sdk/esp32/lib/libnghttp.a and b/tools/sdk/esp32/lib/libnghttp.a differ diff --git a/tools/sdk/esp32/lib/libnvs_flash.a b/tools/sdk/esp32/lib/libnvs_flash.a index 23331560235..7ef82432abc 100644 Binary files a/tools/sdk/esp32/lib/libnvs_flash.a and b/tools/sdk/esp32/lib/libnvs_flash.a differ diff --git a/tools/sdk/esp32/lib/libopenssl.a b/tools/sdk/esp32/lib/libopenssl.a index 999d5528abf..1a87c1f7d05 100644 Binary files a/tools/sdk/esp32/lib/libopenssl.a and b/tools/sdk/esp32/lib/libopenssl.a differ diff --git a/tools/sdk/esp32/lib/libperfmon.a b/tools/sdk/esp32/lib/libperfmon.a index 439ba773361..45281b34c8f 100644 Binary files a/tools/sdk/esp32/lib/libperfmon.a and b/tools/sdk/esp32/lib/libperfmon.a differ diff --git a/tools/sdk/esp32/lib/libpp.a b/tools/sdk/esp32/lib/libpp.a index a17de2b4b78..3ec218aa6f1 100644 Binary files a/tools/sdk/esp32/lib/libpp.a and b/tools/sdk/esp32/lib/libpp.a differ diff --git a/tools/sdk/esp32/lib/libprotobuf-c.a b/tools/sdk/esp32/lib/libprotobuf-c.a index ecbe440ef2c..174b3237ced 100644 Binary files a/tools/sdk/esp32/lib/libprotobuf-c.a and b/tools/sdk/esp32/lib/libprotobuf-c.a differ diff --git a/tools/sdk/esp32/lib/libprotocomm.a b/tools/sdk/esp32/lib/libprotocomm.a index 4d15e2f7334..701acf9e584 100644 Binary files a/tools/sdk/esp32/lib/libprotocomm.a and b/tools/sdk/esp32/lib/libprotocomm.a differ diff --git a/tools/sdk/esp32/lib/libpthread.a b/tools/sdk/esp32/lib/libpthread.a index 0dee2cb7de3..1329ba601b3 100644 Binary files a/tools/sdk/esp32/lib/libpthread.a and b/tools/sdk/esp32/lib/libpthread.a differ diff --git a/tools/sdk/esp32/lib/libqrcode.a b/tools/sdk/esp32/lib/libqrcode.a index b4c229291af..c834f6d204b 100644 Binary files a/tools/sdk/esp32/lib/libqrcode.a and b/tools/sdk/esp32/lib/libqrcode.a differ diff --git a/tools/sdk/esp32/lib/libsdmmc.a b/tools/sdk/esp32/lib/libsdmmc.a index 79be79761dc..30b5bbaa4e5 100644 Binary files a/tools/sdk/esp32/lib/libsdmmc.a and b/tools/sdk/esp32/lib/libsdmmc.a differ diff --git a/tools/sdk/esp32/lib/libsmartconfig.a b/tools/sdk/esp32/lib/libsmartconfig.a index bc816377da3..2ae36360fa1 100644 Binary files a/tools/sdk/esp32/lib/libsmartconfig.a and b/tools/sdk/esp32/lib/libsmartconfig.a differ diff --git a/tools/sdk/esp32/lib/libsoc.a b/tools/sdk/esp32/lib/libsoc.a index a150152473c..5b5287c04be 100644 Binary files a/tools/sdk/esp32/lib/libsoc.a and b/tools/sdk/esp32/lib/libsoc.a differ diff --git a/tools/sdk/esp32/lib/libspi_flash.a b/tools/sdk/esp32/lib/libspi_flash.a index 7f87115de03..f9a11137071 100644 Binary files a/tools/sdk/esp32/lib/libspi_flash.a and b/tools/sdk/esp32/lib/libspi_flash.a differ diff --git a/tools/sdk/esp32/lib/libspiffs.a b/tools/sdk/esp32/lib/libspiffs.a index 305a7e18350..56eea5993cf 100644 Binary files a/tools/sdk/esp32/lib/libspiffs.a and b/tools/sdk/esp32/lib/libspiffs.a differ diff --git a/tools/sdk/esp32/lib/libtcp_transport.a b/tools/sdk/esp32/lib/libtcp_transport.a index 924c1590aca..83f2ad57d38 100644 Binary files a/tools/sdk/esp32/lib/libtcp_transport.a and b/tools/sdk/esp32/lib/libtcp_transport.a differ diff --git a/tools/sdk/esp32/lib/libtcpip_adapter.a b/tools/sdk/esp32/lib/libtcpip_adapter.a index f6bd2070208..20f3e0cb843 100644 Binary files a/tools/sdk/esp32/lib/libtcpip_adapter.a and b/tools/sdk/esp32/lib/libtcpip_adapter.a differ diff --git a/tools/sdk/esp32/lib/libulp.a b/tools/sdk/esp32/lib/libulp.a index fd69ead0297..c3e3bdf0419 100644 Binary files a/tools/sdk/esp32/lib/libulp.a and b/tools/sdk/esp32/lib/libulp.a differ diff --git a/tools/sdk/esp32/lib/libunity.a b/tools/sdk/esp32/lib/libunity.a index fb9451c0bfd..e977f3a578b 100644 Binary files a/tools/sdk/esp32/lib/libunity.a and b/tools/sdk/esp32/lib/libunity.a differ diff --git a/tools/sdk/esp32/lib/libvfs.a b/tools/sdk/esp32/lib/libvfs.a index e9a64993673..51230fadaf3 100644 Binary files a/tools/sdk/esp32/lib/libvfs.a and b/tools/sdk/esp32/lib/libvfs.a differ diff --git a/tools/sdk/esp32/lib/libwapi.a b/tools/sdk/esp32/lib/libwapi.a index 3a5905bb479..4d0200ad4b0 100644 Binary files a/tools/sdk/esp32/lib/libwapi.a and b/tools/sdk/esp32/lib/libwapi.a differ diff --git a/tools/sdk/esp32/lib/libwear_levelling.a b/tools/sdk/esp32/lib/libwear_levelling.a index c9095ff0c79..e6793f3b3c9 100644 Binary files a/tools/sdk/esp32/lib/libwear_levelling.a and b/tools/sdk/esp32/lib/libwear_levelling.a differ diff --git a/tools/sdk/esp32/lib/libwifi_provisioning.a b/tools/sdk/esp32/lib/libwifi_provisioning.a index 416eb86b25a..b0764129217 100644 Binary files a/tools/sdk/esp32/lib/libwifi_provisioning.a and b/tools/sdk/esp32/lib/libwifi_provisioning.a differ diff --git a/tools/sdk/esp32/lib/libwpa_supplicant.a b/tools/sdk/esp32/lib/libwpa_supplicant.a index 6fec046e1c9..011380db2c8 100644 Binary files a/tools/sdk/esp32/lib/libwpa_supplicant.a and b/tools/sdk/esp32/lib/libwpa_supplicant.a differ diff --git a/tools/sdk/esp32/lib/libws2812_led.a b/tools/sdk/esp32/lib/libws2812_led.a index 8f5a2f5b74c..17c368b009a 100644 Binary files a/tools/sdk/esp32/lib/libws2812_led.a and b/tools/sdk/esp32/lib/libws2812_led.a differ diff --git a/tools/sdk/esp32/lib/libxtensa.a b/tools/sdk/esp32/lib/libxtensa.a index 768abffe796..37ff7464dc0 100644 Binary files a/tools/sdk/esp32/lib/libxtensa.a and b/tools/sdk/esp32/lib/libxtensa.a differ diff --git a/tools/sdk/esp32/sdkconfig b/tools/sdk/esp32/sdkconfig index f6b53e2d216..79ed5b40ca2 100644 --- a/tools/sdk/esp32/sdkconfig +++ b/tools/sdk/esp32/sdkconfig @@ -63,6 +63,7 @@ CONFIG_BOOTLOADER_WDT_TIME_MS=9000 # CONFIG_BOOTLOADER_SKIP_VALIDATE_ALWAYS is not set CONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0 # CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC is not set +CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT=y # end of Bootloader config # @@ -83,6 +84,7 @@ CONFIG_ESPTOOLPY_BAUD_OTHER_VAL=115200 CONFIG_ESPTOOLPY_FLASHMODE_DIO=y # CONFIG_ESPTOOLPY_FLASHMODE_DOUT is not set CONFIG_ESPTOOLPY_FLASHMODE="dio" +# CONFIG_ESPTOOLPY_FLASHFREQ_120M is not set # CONFIG_ESPTOOLPY_FLASHFREQ_80M is not set CONFIG_ESPTOOLPY_FLASHFREQ_40M=y # CONFIG_ESPTOOLPY_FLASHFREQ_26M is not set @@ -263,10 +265,9 @@ CONFIG_APPTRACE_LOCK_ENABLE=y # Bluetooth # CONFIG_BT_ENABLED=y -CONFIG_BT_CTRL_ESP32=y # -# Bluetooth controller(ESP32 Dual Mode Bluetooth) +# Bluetooth controller # # CONFIG_BTDM_CTRL_MODE_BLE_ONLY is not set # CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY is not set @@ -318,37 +319,9 @@ CONFIG_BTDM_CTRL_FULL_SCAN_SUPPORTED=y CONFIG_BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP=y CONFIG_BTDM_BLE_ADV_REPORT_FLOW_CTRL_NUM=100 CONFIG_BTDM_BLE_ADV_REPORT_DISCARD_THRSHOLD=20 -# end of Bluetooth controller(ESP32 Dual Mode Bluetooth) - -CONFIG_BT_CTRL_MODE_EFF=1 -CONFIG_BT_CTRL_BLE_MAX_ACT=10 -CONFIG_BT_CTRL_BLE_MAX_ACT_EFF=10 -CONFIG_BT_CTRL_BLE_STATIC_ACL_TX_BUF_NB=0 -CONFIG_BT_CTRL_PINNED_TO_CORE=0 -CONFIG_BT_CTRL_HCI_TL=1 -CONFIG_BT_CTRL_ADV_DUP_FILT_MAX=30 -CONFIG_BT_CTRL_HW_CCA_EFF=0 -CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_EFF=0 -CONFIG_BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP=y -CONFIG_BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_NUM=100 -CONFIG_BT_CTRL_BLE_ADV_REPORT_DISCARD_THRSHOLD=20 -CONFIG_BT_CTRL_BLE_SCAN_DUPL=y -CONFIG_BT_CTRL_SCAN_DUPL_TYPE=0 -CONFIG_BT_CTRL_SCAN_DUPL_CACHE_SIZE=100 - -# -# MODEM SLEEP Options -# -# end of MODEM SLEEP Options - -CONFIG_BT_CTRL_SLEEP_MODE_EFF=0 -CONFIG_BT_CTRL_SLEEP_CLOCK_EFF=0 -CONFIG_BT_CTRL_HCI_TL_EFF=1 - -# -# MODEM SLEEP Options -# -# end of MODEM SLEEP Options +CONFIG_BTDM_RESERVE_DRAM=0xdb5c +CONFIG_BTDM_CTRL_HLI=y +# end of Bluetooth controller CONFIG_BT_BLUEDROID_ENABLED=y # CONFIG_BT_NIMBLE_ENABLED is not set @@ -371,7 +344,7 @@ CONFIG_BT_HFP_CLIENT_ENABLE=y # CONFIG_BT_HFP_AG_ENABLE is not set CONFIG_BT_HFP_AUDIO_DATA_PATH_PCM=y # CONFIG_BT_HFP_AUDIO_DATA_PATH_HCI is not set -# CONFIG_BT_HID_HOST_ENABLED is not set +# CONFIG_BT_HID_ENABLED is not set CONFIG_BT_SSP_ENABLED=y CONFIG_BT_BLE_ENABLED=y CONFIG_BT_GATTS_ENABLE=y @@ -396,10 +369,7 @@ CONFIG_BT_SMP_ENABLE=y # CONFIG_BT_BLE_ACT_SCAN_REP_ADV_SCAN is not set CONFIG_BT_BLE_ESTAB_LINK_CONN_TOUT=30 # CONFIG_BT_BLE_RPA_SUPPORTED is not set -CONFIG_BT_RESERVE_DRAM=0xdb5c # end of Bluedroid Options - -CONFIG_BT_NIMBLE_USE_ESP_TIMER=y # end of Bluetooth # CONFIG_BLE_MESH is not set @@ -424,6 +394,12 @@ CONFIG_COAP_LOG_DEFAULT_LEVEL=0 CONFIG_ADC_DISABLE_DAC=y # end of ADC configuration +# +# MCPWM configuration +# +# CONFIG_MCPWM_ISR_IN_IRAM is not set +# end of MCPWM configuration + # # SPI configuration # @@ -479,6 +455,7 @@ CONFIG_EFUSE_MAX_BLK_LEN=192 CONFIG_ESP_TLS_USING_MBEDTLS=y # CONFIG_ESP_TLS_USE_SECURE_ELEMENT is not set # CONFIG_ESP_TLS_SERVER is not set +# CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS is not set # CONFIG_ESP_TLS_PSK_VERIFICATION is not set # CONFIG_ESP_TLS_INSECURE is not set # end of ESP-TLS @@ -517,6 +494,7 @@ CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=16384 # CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP is not set CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=32768 # CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set +# CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY is not set CONFIG_SPIRAM_CACHE_WORKAROUND=y # @@ -705,12 +683,29 @@ CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES=4 # # Sleep Config # +CONFIG_ESP_SLEEP_RTC_BUS_ISO_WORKAROUND=y +# CONFIG_ESP_SLEEP_PSRAM_LEAKAGE_WORKAROUND is not set +# CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND is not set # end of Sleep Config # end of Hardware Settings +# +# IPC (Inter-Processor Call) +# +CONFIG_ESP_IPC_TASK_STACK_SIZE=1024 +CONFIG_ESP_IPC_USES_CALLERS_PRIORITY=y +CONFIG_ESP_IPC_ISR_ENABLE=y +# end of IPC (Inter-Processor Call) + # # LCD and Touch Panel # + +# +# LCD Peripheral Configuration +# +CONFIG_LCD_PANEL_IO_FORMAT_BUF_SIZE=32 +# end of LCD Peripheral Configuration # end of LCD and Touch Panel # @@ -775,9 +770,8 @@ CONFIG_ESP_TASK_WDT_PANIC=y CONFIG_ESP_TASK_WDT_TIMEOUT_S=5 CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=y # CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1 is not set -CONFIG_ESP_IPC_TASK_STACK_SIZE=1024 -CONFIG_ESP_IPC_USES_CALLERS_PRIORITY=y # CONFIG_ESP_PANIC_HANDLER_IRAM is not set +CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_5=y # end of ESP System Settings # @@ -899,6 +893,8 @@ CONFIG_FMB_EVENT_QUEUE_TIMEOUT=20 CONFIG_FMB_TIMER_PORT_ENABLED=y CONFIG_FMB_TIMER_GROUP=0 CONFIG_FMB_TIMER_INDEX=0 +CONFIG_FMB_MASTER_TIMER_GROUP=0 +CONFIG_FMB_MASTER_TIMER_INDEX=0 # CONFIG_FMB_TIMER_ISR_IN_IRAM is not set # end of Modbus configuration @@ -907,8 +903,10 @@ CONFIG_FMB_TIMER_INDEX=0 # # CONFIG_FREERTOS_UNICORE is not set CONFIG_FREERTOS_NO_AFFINITY=0x7FFFFFFF +CONFIG_FREERTOS_TICK_SUPPORT_CORETIMER=y CONFIG_FREERTOS_CORETIMER_0=y # CONFIG_FREERTOS_CORETIMER_1 is not set +CONFIG_FREERTOS_SYSTICK_USES_CCOUNT=y CONFIG_FREERTOS_HZ=1000 # CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION is not set # CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE is not set @@ -937,6 +935,8 @@ CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=y # CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH is not set CONFIG_FREERTOS_DEBUG_OCDAWARE=y # CONFIG_FREERTOS_FPU_IN_ISR is not set +CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT=y +# CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH is not set # end of FreeRTOS # @@ -1001,6 +1001,7 @@ CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y # CONFIG_LWIP_LOCAL_HOSTNAME="espressif" # CONFIG_LWIP_NETIF_API is not set +# CONFIG_LWIP_TCPIP_CORE_LOCKING is not set CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y # CONFIG_LWIP_L2_TO_L3_COPY is not set # CONFIG_LWIP_IRAM_OPTIMIZATION is not set @@ -1039,7 +1040,6 @@ CONFIG_LWIP_IPV6=y # CONFIG_LWIP_IPV6_AUTOCONFIG is not set CONFIG_LWIP_IPV6_NUM_ADDRESSES=3 # CONFIG_LWIP_IPV6_FORWARD is not set -CONFIG_LWIP_IPV6_RDNSS_MAX_DNS_SERVERS=0 # CONFIG_LWIP_NETIF_STATUS_CALLBACK is not set CONFIG_LWIP_NETIF_LOOPBACK=y CONFIG_LWIP_LOOPBACK_MAX_PBUFS=8 @@ -1117,7 +1117,8 @@ CONFIG_LWIP_MAX_RAW_PCBS=16 # # SNTP # -CONFIG_LWIP_DHCP_MAX_NTP_SERVERS=1 +CONFIG_LWIP_SNTP_MAX_SERVERS=1 +# CONFIG_LWIP_DHCP_GET_NTP_SRV is not set CONFIG_LWIP_SNTP_UPDATE_DELAY=3600000 # end of SNTP @@ -1207,6 +1208,7 @@ CONFIG_MBEDTLS_SSL_RENEGOTIATION=y CONFIG_MBEDTLS_SSL_PROTO_TLS1=y CONFIG_MBEDTLS_SSL_PROTO_TLS1_1=y CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y +# CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1 is not set CONFIG_MBEDTLS_SSL_PROTO_DTLS=y CONFIG_MBEDTLS_SSL_ALPN=y CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS=y @@ -1279,6 +1281,7 @@ CONFIG_MDNS_TASK_AFFINITY=0x0 CONFIG_MDNS_SERVICE_ADD_TIMEOUT_MS=2000 # CONFIG_MDNS_STRICT_MODE is not set CONFIG_MDNS_TIMER_PERIOD_MS=100 +# CONFIG_MDNS_NETWORKING_SOCKET is not set # end of mDNS # @@ -1421,11 +1424,6 @@ CONFIG_WS_BUFFER_SIZE=1024 # end of Websocket # end of TCP Transport -# -# TinyUSB -# -# end of TinyUSB - # # Unity unit testing library # @@ -1504,37 +1502,6 @@ CONFIG_DSP_MAX_FFT_SIZE_4096=y CONFIG_DSP_MAX_FFT_SIZE=4096 # end of DSP Library -# CONFIG_C_IMPL is not set -CONFIG_XTENSA_IMPL=y - -# -# ESP-FACE Configuration -# -CONFIG_MTMN_LITE_QUANT=y -# CONFIG_MTMN_LITE_FLOAT is not set -# CONFIG_MTMN_HEAVY_QUANT is not set -# CONFIG_FRMN is not set -CONFIG_MFN56_1X=y -# CONFIG_MFN56_2X is not set -# CONFIG_MFN56_3X is not set -# CONFIG_MFN56_4X is not set - -# -# Object Detection -# -# CONFIG_DETECT_WITH_LANDMARK is not set -# end of Object Detection - -# -# Pose Estimation -# -CONFIG_HD_NANO1=y -# CONFIG_HD_LITE1 is not set -CONFIG_HP_NANO1=y -# CONFIG_HP_LITE1 is not set -# end of Pose Estimation -# end of ESP-FACE Configuration - # # Camera configuration # @@ -1704,6 +1671,7 @@ CONFIG_POST_EVENTS_FROM_IRAM_ISR=y # CONFIG_TWO_UNIVERSAL_MAC_ADDRESS is not set CONFIG_FOUR_UNIVERSAL_MAC_ADDRESS=y CONFIG_NUMBER_OF_UNIVERSAL_MAC_ADDRESS=4 +CONFIG_IPC_TASK_STACK_SIZE=1024 CONFIG_REDUCE_PHY_TX_POWER=y # CONFIG_ESP32S2_PANIC_PRINT_HALT is not set CONFIG_ESP32S2_PANIC_PRINT_REBOOT=y @@ -1726,7 +1694,6 @@ CONFIG_TASK_WDT_PANIC=y CONFIG_TASK_WDT_TIMEOUT_S=5 CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0=y # CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1 is not set -CONFIG_IPC_TASK_STACK_SIZE=1024 CONFIG_TIMER_TASK_STACK_SIZE=4096 CONFIG_SW_COEXIST_ENABLE=y # CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH is not set diff --git a/tools/sdk/esp32c3/bin/bootloader_dio_40m.bin b/tools/sdk/esp32c3/bin/bootloader_dio_40m.bin index 0d314c54e7f..78c947604fd 100644 Binary files a/tools/sdk/esp32c3/bin/bootloader_dio_40m.bin and b/tools/sdk/esp32c3/bin/bootloader_dio_40m.bin differ diff --git a/tools/sdk/esp32c3/bin/bootloader_dio_80m.bin b/tools/sdk/esp32c3/bin/bootloader_dio_80m.bin index 869cbb1a5dd..5fdaf4eed6a 100644 Binary files a/tools/sdk/esp32c3/bin/bootloader_dio_80m.bin and b/tools/sdk/esp32c3/bin/bootloader_dio_80m.bin differ diff --git a/tools/sdk/esp32c3/bin/bootloader_dout_40m.bin b/tools/sdk/esp32c3/bin/bootloader_dout_40m.bin index afc66b4b308..e369d99e862 100644 Binary files a/tools/sdk/esp32c3/bin/bootloader_dout_40m.bin and b/tools/sdk/esp32c3/bin/bootloader_dout_40m.bin differ diff --git a/tools/sdk/esp32c3/bin/bootloader_dout_80m.bin b/tools/sdk/esp32c3/bin/bootloader_dout_80m.bin index da7da2cdf08..2b9800fc7e7 100644 Binary files a/tools/sdk/esp32c3/bin/bootloader_dout_80m.bin and b/tools/sdk/esp32c3/bin/bootloader_dout_80m.bin differ diff --git a/tools/sdk/esp32c3/bin/bootloader_qio_40m.bin b/tools/sdk/esp32c3/bin/bootloader_qio_40m.bin index c9e3e7e0380..22880d8cf71 100644 Binary files a/tools/sdk/esp32c3/bin/bootloader_qio_40m.bin and b/tools/sdk/esp32c3/bin/bootloader_qio_40m.bin differ diff --git a/tools/sdk/esp32c3/bin/bootloader_qio_80m.bin b/tools/sdk/esp32c3/bin/bootloader_qio_80m.bin index 28102fdd73c..d630c8774ee 100644 Binary files a/tools/sdk/esp32c3/bin/bootloader_qio_80m.bin and b/tools/sdk/esp32c3/bin/bootloader_qio_80m.bin differ diff --git a/tools/sdk/esp32c3/bin/bootloader_qout_40m.bin b/tools/sdk/esp32c3/bin/bootloader_qout_40m.bin index e2cdf7c9429..9566026d6b4 100644 Binary files a/tools/sdk/esp32c3/bin/bootloader_qout_40m.bin and b/tools/sdk/esp32c3/bin/bootloader_qout_40m.bin differ diff --git a/tools/sdk/esp32c3/bin/bootloader_qout_80m.bin b/tools/sdk/esp32c3/bin/bootloader_qout_80m.bin index 9c6a9cd83ef..d8a35e03d63 100644 Binary files a/tools/sdk/esp32c3/bin/bootloader_qout_80m.bin and b/tools/sdk/esp32c3/bin/bootloader_qout_80m.bin differ diff --git a/tools/sdk/esp32c3/include/app_update/include/esp_ota_ops.h b/tools/sdk/esp32c3/include/app_update/include/esp_ota_ops.h index 6278ab7905c..ba07c013d90 100644 --- a/tools/sdk/esp32c3/include/app_update/include/esp_ota_ops.h +++ b/tools/sdk/esp32c3/include/app_update/include/esp_ota_ops.h @@ -244,6 +244,14 @@ const esp_partition_t* esp_ota_get_next_update_partition(const esp_partition_t * */ esp_err_t esp_ota_get_partition_description(const esp_partition_t *partition, esp_app_desc_t *app_desc); +/** + * @brief Returns number of ota partitions provided in partition table. + * + * @return + * - Number of OTA partitions + */ +uint8_t esp_ota_get_app_partition_count(void); + /** * @brief This function is called to indicate that the running app is working well. * diff --git a/tools/sdk/esp32c3/include/bootloader_support/include/bootloader_common.h b/tools/sdk/esp32c3/include/bootloader_support/include/bootloader_common.h index 2ff0e595a27..2f4e9062200 100644 --- a/tools/sdk/esp32c3/include/bootloader_support/include/bootloader_common.h +++ b/tools/sdk/esp32c3/include/bootloader_support/include/bootloader_common.h @@ -119,6 +119,15 @@ bool bootloader_common_label_search(const char *list, char *label); */ void bootloader_configure_spi_pins(int drv); +/** + * @brief Get flash CS IO + * + * Can be determined by eFuse values, or the default value + * + * @return Flash CS IO + */ +uint8_t bootloader_flash_get_cs_io(void); + /** * @brief Calculates a sha-256 for a given partition or returns a appended digest. * diff --git a/tools/sdk/esp32c3/include/bootloader_support/include/bootloader_flash.h b/tools/sdk/esp32c3/include/bootloader_support/include/bootloader_flash.h index 73aa48923d0..49e457f372e 100644 --- a/tools/sdk/esp32c3/include/bootloader_support/include/bootloader_flash.h +++ b/tools/sdk/esp32c3/include/bootloader_support/include/bootloader_flash.h @@ -10,6 +10,18 @@ #include "sdkconfig.h" #include "soc/soc_caps.h" +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Read flash ID by sending RDID command (0x9F) + * @return flash raw ID + * mfg_id = (ID >> 16) & 0xFF; + flash_id = ID & 0xffff; + */ +uint32_t bootloader_read_flash_id(void); + #if SOC_CACHE_SUPPORT_WRAP /** * @brief Set the burst mode setting command for specified wrap mode. @@ -19,3 +31,22 @@ */ esp_err_t bootloader_flash_wrap_set(spi_flash_wrap_mode_t mode); #endif + +/** + * @brief Unlock Flash write protect. + * Please do not call this function in SDK. + * + * @note This can be overridden because it's attribute weak. + */ +esp_err_t bootloader_flash_unlock(void); + +/** + * @brief Startup flow recommended by XMC. Call at startup before any erase/write operation. + * + * @return ESP_OK When startup successfully, otherwise ESP_FAIL (indiciating you should reboot before erase/write). + */ +esp_err_t bootloader_flash_xmc_startup(void); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32c3/include/bt/common/osi/include/osi/alarm.h b/tools/sdk/esp32c3/include/bt/common/osi/include/osi/alarm.h index a1d3fa8961b..fe8344cdb9f 100644 --- a/tools/sdk/esp32c3/include/bt/common/osi/include/osi/alarm.h +++ b/tools/sdk/esp32c3/include/bt/common/osi/include/osi/alarm.h @@ -77,4 +77,8 @@ period_ms_t osi_alarm_get_remaining_ms(const osi_alarm_t *alarm); uint32_t osi_time_get_os_boottime_ms(void); +// This function returns whether the given |alarm| is active or not. +// Return true if active, false otherwise. +bool osi_alarm_is_active(osi_alarm_t *alarm); + #endif /*_ALARM_H_*/ diff --git a/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h b/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h index ce309935853..dd48ab982dd 100644 --- a/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h +++ b/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h @@ -467,7 +467,7 @@ typedef struct { uint16_t rx_len; /*!< pkt rx data length value */ uint16_t tx_len; /*!< pkt tx data length value */ -}esp_ble_pkt_data_length_params_t; +} esp_ble_pkt_data_length_params_t; /** * @brief BLE encryption keys @@ -648,7 +648,7 @@ typedef enum { typedef enum{ ESP_BLE_WHITELIST_REMOVE = 0X00, /*!< remove mac from whitelist */ ESP_BLE_WHITELIST_ADD = 0X01, /*!< add address to whitelist */ -}esp_ble_wl_opration_t; +} esp_ble_wl_opration_t; #if (BLE_42_FEATURE_SUPPORT == TRUE) typedef enum { ESP_BLE_DUPLICATE_EXCEPTIONAL_LIST_ADD = 0, /*!< Add device info into duplicate scan exceptional list */ @@ -998,7 +998,7 @@ typedef union { uint16_t conn_int; /*!< Current connection interval */ uint16_t timeout; /*!< Supervision timeout for the LE Link. Range: 0x000A to 0x0C80. Mandatory Range: 0x000A to 0x0C80 Time = N * 10 msec */ - }update_conn_params; /*!< Event parameter of ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT */ + } update_conn_params; /*!< Event parameter of ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT */ /** * @brief ESP_GAP_BLE_SET_PKT_LENGTH_COMPLETE_EVT */ @@ -1018,13 +1018,13 @@ typedef union { struct ble_remove_bond_dev_cmpl_evt_param { esp_bt_status_t status; /*!< Indicate the remove bond device operation success status */ esp_bd_addr_t bd_addr; /*!< The device address which has been remove from the bond list */ - }remove_bond_dev_cmpl; /*!< Event parameter of ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT */ + } remove_bond_dev_cmpl; /*!< Event parameter of ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT */ /** * @brief ESP_GAP_BLE_CLEAR_BOND_DEV_COMPLETE_EVT */ struct ble_clear_bond_dev_cmpl_evt_param { esp_bt_status_t status; /*!< Indicate the clear bond device operation success status */ - }clear_bond_dev_cmpl; /*!< Event parameter of ESP_GAP_BLE_CLEAR_BOND_DEV_COMPLETE_EVT */ + } clear_bond_dev_cmpl; /*!< Event parameter of ESP_GAP_BLE_CLEAR_BOND_DEV_COMPLETE_EVT */ /** * @brief ESP_GAP_BLE_GET_BOND_DEV_COMPLETE_EVT */ @@ -1032,7 +1032,7 @@ typedef union { esp_bt_status_t status; /*!< Indicate the get bond device operation success status */ uint8_t dev_num; /*!< Indicate the get number device in the bond list */ esp_ble_bond_dev_t *bond_dev; /*!< the pointer to the bond device Structure */ - }get_bond_dev_cmpl; /*!< Event parameter of ESP_GAP_BLE_GET_BOND_DEV_COMPLETE_EVT */ + } get_bond_dev_cmpl; /*!< Event parameter of ESP_GAP_BLE_GET_BOND_DEV_COMPLETE_EVT */ /** * @brief ESP_GAP_BLE_READ_RSSI_COMPLETE_EVT */ diff --git a/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_gattc_api.h b/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_gattc_api.h index 077cca38507..40719096345 100644 --- a/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_gattc_api.h +++ b/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_gattc_api.h @@ -380,7 +380,7 @@ esp_err_t esp_ble_gattc_search_service(esp_gatt_if_t gattc_if, uint16_t conn_id, /** * @brief Find all the service with the given service uuid in the gattc cache, if the svc_uuid is NULL, find all the service. * Note: It just get service from local cache, won't get from remote devices. If want to get it from remote device, need - * to used the esp_ble_gattc_search_service. + * to used the esp_ble_gattc_cache_refresh, then call esp_ble_gattc_get_service again. * * @param[in] gattc_if: Gatt client access interface. * @param[in] conn_id: connection ID which identify the server. diff --git a/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_hidd_api.h b/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_hidd_api.h new file mode 100644 index 00000000000..de90ff8efc6 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_hidd_api.h @@ -0,0 +1,379 @@ +// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD +// Copyright 2019 Blake Felt +// +// 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_HIDD_API_H__ +#define __ESP_HIDD_API_H__ + +#include "esp_bt_defs.h" +#include "esp_err.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* sub_class of hid device */ +#define ESP_HID_CLASS_UNKNOWN (0x00<<2) +#define ESP_HID_CLASS_JOS (0x01<<2) /* joy stick */ +#define ESP_HID_CLASS_GPD (0x02<<2) /* game pad */ +#define ESP_HID_CLASS_RMC (0x03<<2) /* remote control */ +#define ESP_HID_CLASS_SED (0x04<<2) /* sensing device */ +#define ESP_HID_CLASS_DGT (0x05<<2) /* Digitizer tablet */ +#define ESP_HID_CLASS_CDR (0x06<<2) /* card reader */ +#define ESP_HID_CLASS_KBD (0x10<<2) /* keyboard */ +#define ESP_HID_CLASS_MIC (0x20<<2) /* pointing device */ +#define ESP_HID_CLASS_COM (0x30<<2) /* Combo keyboard/pointing */ + +/** + * @brief HIDD handshake error + */ +typedef enum { + ESP_HID_PAR_HANDSHAKE_RSP_SUCCESS = 0, + ESP_HID_PAR_HANDSHAKE_RSP_NOT_READY = 1, + ESP_HID_PAR_HANDSHAKE_RSP_ERR_INVALID_REP_ID = 2, + ESP_HID_PAR_HANDSHAKE_RSP_ERR_UNSUPPORTED_REQ = 3, + ESP_HID_PAR_HANDSHAKE_RSP_ERR_INVALID_PARAM = 4, + ESP_HID_PAR_HANDSHAKE_RSP_ERR_UNKNOWN = 14, + ESP_HID_PAR_HANDSHAKE_RSP_ERR_FATAL = 15 +} esp_hidd_handshake_error_t; + +/** + * @brief HIDD report types + */ +typedef enum { + ESP_HIDD_REPORT_TYPE_OTHER = 0, + ESP_HIDD_REPORT_TYPE_INPUT, + ESP_HIDD_REPORT_TYPE_OUTPUT, + ESP_HIDD_REPORT_TYPE_FEATURE, + // special value for reports to be sent on INTR(INPUT is assumed) + ESP_HIDD_REPORT_TYPE_INTRDATA +} esp_hidd_report_type_t; + +/** + * @brief HIDD connection state + */ +typedef enum { + ESP_HIDD_CONN_STATE_CONNECTED, + ESP_HIDD_CONN_STATE_CONNECTING, + ESP_HIDD_CONN_STATE_DISCONNECTED, + ESP_HIDD_CONN_STATE_DISCONNECTING, + ESP_HIDD_CONN_STATE_UNKNOWN +} esp_hidd_connection_state_t; + +/** + * @brief HID device protocol modes + */ +typedef enum { + ESP_HIDD_REPORT_MODE = 0x00, + ESP_HIDD_BOOT_MODE = 0x01, + ESP_HIDD_UNSUPPORTED_MODE = 0xff +} esp_hidd_protocol_mode_t; + + +/** + * @brief HIDD characteristics for SDP report + */ +typedef struct { + const char *name; + const char *description; + const char *provider; + uint8_t subclass; + uint8_t *desc_list; + int desc_list_len; +} esp_hidd_app_param_t; + +/** + * @brief HIDD Quality of Service parameters + */ +typedef struct { + uint8_t service_type; + uint32_t token_rate; + uint32_t token_bucket_size; + uint32_t peak_bandwidth; + uint32_t access_latency; + uint32_t delay_variation; +} esp_hidd_qos_param_t; + +/** + * @brief HID device callback function events + */ +typedef enum { + ESP_HIDD_INIT_EVT = 0, /*!< When HID device is inited, the event comes */ + ESP_HIDD_DEINIT_EVT, /*!< When HID device is deinited, the event comes */ + ESP_HIDD_REGISTER_APP_EVT, /*!< When HID device application registered, the event comes */ + ESP_HIDD_UNREGISTER_APP_EVT, /*!< When HID device application unregistered, the event comes */ + ESP_HIDD_OPEN_EVT, /*!< When HID device connection to host opened, the event comes */ + ESP_HIDD_CLOSE_EVT, /*!< When HID device connection to host closed, the event comes */ + ESP_HIDD_SEND_REPORT_EVT, /*!< When HID device send report to lower layer, the event comes */ + ESP_HIDD_REPORT_ERR_EVT, /*!< When HID device report handshanke error to lower layer, the event comes */ + ESP_HIDD_GET_REPORT_EVT, /*!< When HID device receives GET_REPORT request from host, the event comes */ + ESP_HIDD_SET_REPORT_EVT, /*!< When HID device receives SET_REPORT request from host, the event comes */ + ESP_HIDD_SET_PROTOCOL_EVT, /*!< When HID device receives SET_PROTOCOL request from host, the event comes */ + ESP_HIDD_INTR_DATA_EVT, /*!< When HID device receives DATA from host on intr, the event comes */ + ESP_HIDD_VC_UNPLUG_EVT, /*!< When HID device initiates Virtual Cable Unplug, the event comes */ + ESP_HIDD_API_ERR_EVT /*!< When HID device has API error, the event comes */ +} esp_hidd_cb_event_t; + +typedef enum { + ESP_HIDD_SUCCESS, + ESP_HIDD_ERROR, /*!< general ESP HD error */ + ESP_HIDD_NO_RES, /*!< out of system resources */ + ESP_HIDD_BUSY, /*!< Temporarily can not handle this request. */ + ESP_HIDD_NO_DATA, /*!< No data. */ + ESP_HIDD_NEED_INIT, /*!< HIDD module shall init first */ + ESP_HIDD_NEED_DEINIT, /*!< HIDD module shall deinit first */ + ESP_HIDD_NEED_REG, /*!< HIDD module shall register first */ + ESP_HIDD_NEED_DEREG, /*!< HIDD module shall deregister first */ + ESP_HIDD_NO_CONNECTION, /*!< connection may have been closed */ +} esp_hidd_status_t; + +/** + * @brief HID device callback parameters union + */ +typedef union { + /** + * @brief ESP_HIDD_INIT_EVT + */ + struct hidd_init_evt_param { + esp_hidd_status_t status; /*!< operation status */ + } init; /*!< HIDD callback param of ESP_HIDD_INIT_EVT */ + + /** + * @brief ESP_HIDD_DEINIT_EVT + */ + struct hidd_deinit_evt_param { + esp_hidd_status_t status; /*!< operation status */ + } deinit; /*!< HIDD callback param of ESP_HIDD_DEINIT_EVT */ + + /** + * @brief ESP_HIDD_REGISTER_APP_EVT + */ + struct hidd_register_app_evt_param { + esp_hidd_status_t status; /*!< operation status */ + bool in_use; /*!< indicate whether use virtual cable plug host address */ + esp_bd_addr_t bd_addr; /*!< host address */ + } register_app; /*!< HIDD callback param of ESP_HIDD_REGISTER_APP_EVT */ + + /** + * @brief ESP_HIDD_UNREGISTER_APP_EVT + */ + struct hidd_unregister_app_evt_param { + esp_hidd_status_t status; /*!< operation status */ + } unregister_app; /*!< HIDD callback param of ESP_HIDD_UNREGISTER_APP_EVT */ + + /** + * @brief ESP_HIDD_OPEN_EVT + */ + struct hidd_open_evt_param { + esp_hidd_status_t status; /*!< operation status */ + esp_hidd_connection_state_t conn_status; /*!< connection status */ + esp_bd_addr_t bd_addr; /*!< host address */ + } open; /*!< HIDD callback param of ESP_HIDD_OPEN_EVT */ + + /** + * @brief ESP_HIDD_CLOSE_EVT + */ + struct hidd_close_evt_param { + esp_hidd_status_t status; /*!< operation status */ + esp_hidd_connection_state_t conn_status; /*!< connection status */ + } close; /*!< HIDD callback param of ESP_HIDD_CLOSE_EVT */ + + /** + * @brief ESP_HIDD_SEND_REPORT_EVT + */ + struct hidd_send_report_evt_param { + esp_hidd_status_t status; /*!< operation status */ + uint8_t reason; /*!< lower layer failed reason(ref hiddefs.h) */ + esp_hidd_report_type_t report_type; /*!< report type */ + uint8_t report_id; /*!< report id */ + } send_report; /*!< HIDD callback param of ESP_HIDD_SEND_REPORT_EVT */ + + /** + * @brief ESP_HIDD_REPORT_ERR_EVT + */ + struct hidd_report_err_evt_param { + esp_hidd_status_t status; /*!< operation status */ + uint8_t reason; /*!< lower layer failed reason(ref hiddefs.h) */ + } report_err; /*!< HIDD callback param of ESP_HIDD_REPORT_ERR_EVT */ + + /** + * @brief ESP_HIDD_GET_REPORT_EVT + */ + struct hidd_get_report_evt_param { + esp_hidd_report_type_t report_type; /*!< report type */ + uint8_t report_id; /*!< report id */ + uint16_t buffer_size; /*!< buffer size */ + } get_report; /*!< HIDD callback param of ESP_HIDD_GET_REPORT_EVT */ + + /** + * @brief ESP_HIDD_SET_REPORT_EVT + */ + struct hidd_set_report_evt_param { + esp_hidd_report_type_t report_type; /*!< report type */ + uint8_t report_id; /*!< report id */ + uint16_t len; /*!< set_report data length */ + uint8_t *data; /*!< set_report data pointer */ + } set_report; /*!< HIDD callback param of ESP_HIDD_SET_REPORT_EVT */ + + /** + * @brief ESP_HIDD_SET_PROTOCOL_EVT + */ + struct hidd_set_protocol_evt_param { + esp_hidd_protocol_mode_t protocol_mode; /*!< protocol mode */ + } set_protocol; /*!< HIDD callback param of ESP_HIDD_SET_PROTOCOL_EVT */ + + /** + * @brief ESP_HIDD_INTR_DATA_EVT + */ + struct hidd_intr_data_evt_param { + uint8_t report_id; /*!< interrupt channel report id */ + uint16_t len; /*!< interrupt channel report data length */ + uint8_t *data; /*!< interrupt channel report data pointer */ + } intr_data; /*!< HIDD callback param of ESP_HIDD_INTR_DATA_EVT */ + + /** + * @brief ESP_HIDD_VC_UNPLUG_EVT + */ + struct hidd_vc_unplug_param { + esp_hidd_status_t status; /*!< operation status */ + esp_hidd_connection_state_t conn_status; /*!< connection status */ + } vc_unplug; /*!< HIDD callback param of ESP_HIDD_VC_UNPLUG_EVT */ +} esp_hidd_cb_param_t; + +/** + * @brief HID device callback function type. + * @param event: Event type + * @param param: Point to callback parameter, currently is union type + */ +typedef void (esp_hd_cb_t)(esp_hidd_cb_event_t event, esp_hidd_cb_param_t *param); + +/** + * @brief This function is called to init callbacks with HID device module. + * + * @param[in] callback: pointer to the init callback function. + * + * @return + * - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_device_register_callback(esp_hd_cb_t callback); + +/** + * @brief This function initializes HIDD. This function should be called after esp_bluedroid_enable and + * esp_blueroid_init success, and should be called after esp_bt_hid_device_register_callback. + * When the operation is complete the callback function will be called with ESP_HIDD_INIT_EVT. + * + * @return + * - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_device_init(void); + +/** + * @brief This function de-initializes HIDD interface. This function should be called after esp_bluedroid_enable() and + * esp_blueroid_init() success, and should be called after esp_bt_hid_device_init(). When the operation is complete the callback + * function will be called with ESP_HIDD_DEINIT_EVT. + * + * @return - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_device_deinit(void); + +/** + * @brief Registers HIDD parameters with SDP and sets l2cap Quality of Service. This function should be called after + * esp_bluedroid_enable and esp_blueroid_init success, and must be done after esp_bt_hid_device_init. When the operation is complete the callback + * function will be called with ESP_HIDD_REGISTER_APP_EVT. + * + * @param[in] app_param: HIDD parameters + * @param[in] in_qos: incoming QoS parameters + * @param[in] out_qos: outgoing QoS parameters + * + * @return - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_device_register_app(esp_hidd_app_param_t *app_param, esp_hidd_qos_param_t *in_qos, + esp_hidd_qos_param_t *out_qos); + +/** + * @brief Removes HIDD parameters from SDP and resets l2cap Quality of Service. This function should be called after esp_bluedroid_enable and + * esp_blueroid_init success, and should be called after esp_bt_hid_device_init. When the operation is complete the callback + * function will be called with ESP_HIDD_UNREGISTER_APP_EVT. + * + * @return - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_device_unregister_app(void); + +/** + * @brief This function connects HIDD interface to connected bluetooth device, if not done already. When the operation is complete the callback + * function will be called with ESP_HIDD_OPEN_EVT. + * + * @param[in] bd_addr: Remote host bluetooth device address. + * + * @return + * - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_device_connect(esp_bd_addr_t bd_addr); + +/** + * @brief This function disconnects HIDD interface. When the operation is complete the callback + * function will be called with ESP_HIDD_CLOSE_EVT. + * + * @return + * - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_device_disconnect(void); + +/** + * @brief Send HIDD report. When the operation is complete the callback + * function will be called with ESP_HIDD_SEND_REPORT_EVT. + * + * @param[in] type: type of report + * @param[in] id: report id as defined by descriptor + * @param[in] len: length of report + * @param[in] data: report data + * + * @return + * - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_device_send_report(esp_hidd_report_type_t type, uint8_t id, uint16_t len, uint8_t *data); + +/** + * @brief Sends HIDD handshake with error info for invalid set_report. When the operation is complete the callback + * function will be called with ESP_HIDD_REPORT_ERR_EVT. + * + * @param[in] error: type of error + * + * @return - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_device_report_error(esp_hidd_handshake_error_t error); + +/** + * @brief Unplug virtual cable of HIDD. When the operation is complete the callback + * function will be called with ESP_HIDD_VC_UNPLUG_EVT. + * + * @return - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_device_virtual_cable_unplug(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_hidh_api.h b/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_hidh_api.h new file mode 100644 index 00000000000..07abdece2d0 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_hidh_api.h @@ -0,0 +1,465 @@ +// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD +// Copyright 2019 Blake Felt +// +// 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_HIDH_API_H__ +#define __ESP_HIDH_API_H__ + +#include "esp_bt_defs.h" +#include "esp_err.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define BTHH_MAX_DSC_LEN 884 + +/** + * @brief HID host connection state + */ +typedef enum { + ESP_HIDH_CONN_STATE_CONNECTED = 0, /*!< connected state */ + ESP_HIDH_CONN_STATE_CONNECTING, /*!< connecting state */ + ESP_HIDH_CONN_STATE_DISCONNECTED, /*!< disconnected state */ + ESP_HIDH_CONN_STATE_DISCONNECTING, /*!< disconnecting state */ + ESP_HIDH_CONN_STATE_UNKNOWN /*!< unknown state(initial state) */ +} esp_hidh_connection_state_t; + +typedef enum { + ESP_HIDH_OK, + ESP_HIDH_HS_HID_NOT_READY, /*!< handshake error : device not ready */ + ESP_HIDH_HS_INVALID_RPT_ID, /*!< handshake error : invalid report ID */ + ESP_HIDH_HS_TRANS_NOT_SPT, /*!< handshake error : transaction not spt */ + ESP_HIDH_HS_INVALID_PARAM, /*!< handshake error : invalid paremter */ + ESP_HIDH_HS_ERROR, /*!< handshake error : unspecified HS error */ + ESP_HIDH_ERR, /*!< general ESP HH error */ + ESP_HIDH_ERR_SDP, /*!< SDP error */ + ESP_HIDH_ERR_PROTO, /*!< SET_Protocol error, + only used in ESP_HIDH_OPEN_EVT callback */ + + ESP_HIDH_ERR_DB_FULL, /*!< device database full error, used in + ESP_HIDH_OPEN_EVT/ESP_HIDH_ADD_DEV_EVT */ + ESP_HIDH_ERR_TOD_UNSPT, /*!< type of device not supported */ + ESP_HIDH_ERR_NO_RES, /*!< out of system resources */ + ESP_HIDH_ERR_AUTH_FAILED, /*!< authentication fail */ + ESP_HIDH_ERR_HDL, /*!< connection handle error */ + ESP_HIDH_ERR_SEC, /*!< encryption error */ + // self_defined + ESP_HIDH_BUSY, /*!< Temporarily can not handle this request. */ + ESP_HIDH_NO_DATA, /*!< No data. */ + ESP_HIDH_NEED_INIT, /*!< HIDH module shall init first */ + ESP_HIDH_NEED_DEINIT, /*!< HIDH module shall deinit first */ + ESP_HIDH_NO_CONNECTION, /*!< connection may have been closed */ +} esp_hidh_status_t; + +/** + * @brief HID host protocol modes + */ +typedef enum { + ESP_HIDH_BOOT_MODE = 0x00, /*!< boot protocol mode */ + ESP_HIDH_REPORT_MODE = 0x01, /*!< report protocol mode */ + ESP_HIDH_UNSUPPORTED_MODE = 0xff /*!< unsupported protocol mode */ +} esp_hidh_protocol_mode_t; + +/** + * @brief HID host report types + */ +typedef enum { + ESP_HIDH_REPORT_TYPE_OTHER = 0, /*!< unsupported report type */ + ESP_HIDH_REPORT_TYPE_INPUT, /*!< input report type */ + ESP_HIDH_REPORT_TYPE_OUTPUT, /*!< output report type */ + ESP_HIDH_REPORT_TYPE_FEATURE, /*!< feature report type */ +} esp_hidh_report_type_t; + +/** + * @brief HID host callback function events + */ +typedef enum { + ESP_HIDH_INIT_EVT = 0, /*!< When HID host is inited, the event comes */ + ESP_HIDH_DEINIT_EVT, /*!< When HID host is deinited, the event comes */ + ESP_HIDH_OPEN_EVT, /*!< When HID host connection opened, the event comes */ + ESP_HIDH_CLOSE_EVT, /*!< When HID host connection closed, the event comes */ + ESP_HIDH_GET_RPT_EVT, /*!< When Get_Report command is called, the event comes */ + ESP_HIDH_SET_RPT_EVT, /*!< When Set_Report command is called, the event comes */ + ESP_HIDH_GET_PROTO_EVT, /*!< When Get_Protocol command is called, the event comes */ + ESP_HIDH_SET_PROTO_EVT, /*!< When Set_Protocol command is called, the event comes */ + ESP_HIDH_GET_IDLE_EVT, /*!< When Get_Idle command is called, the event comes */ + ESP_HIDH_SET_IDLE_EVT, /*!< When Set_Idle command is called, the event comes */ + ESP_HIDH_GET_DSCP_EVT, /*!< When HIDH is inited, the event comes */ + ESP_HIDH_ADD_DEV_EVT, /*!< When a device is added, the event comes */ + ESP_HIDH_RMV_DEV_EVT, /*!< When a device is removed, the event comes */ + ESP_HIDH_VC_UNPLUG_EVT, /*!< When virtually unplugged, the event comes */ + ESP_HIDH_DATA_EVT, /*!< When send data on interrupt channel, the event comes */ + ESP_HIDH_DATA_IND_EVT, /*!< When receive data on interrupt channel, the event comes */ + ESP_HIDH_SET_INFO_EVT /*!< When set the HID device descriptor, the event comes */ +} esp_hidh_cb_event_t; + +typedef struct { + int attr_mask; + uint8_t sub_class; + uint8_t app_id; + int vendor_id; + int product_id; + int version; + uint8_t ctry_code; + int dl_len; + uint8_t dsc_list[BTHH_MAX_DSC_LEN]; +} esp_hidh_hid_info_t; + +/** + * @brief HID host callback parameters union + */ +typedef union { + /** + * @brief ESP_HIDH_INIT_EVT + */ + struct hidh_init_evt_param { + esp_hidh_status_t status; /*!< status */ + } init; /*!< HIDH callback param of ESP_HIDH_INIT_EVT */ + + /** + * @brief ESP_HIDH_DEINIT_EVT + */ + struct hidh_uninit_evt_param { + esp_hidh_status_t status; /*!< status */ + } deinit; /*!< HIDH callback param of ESP_HIDH_DEINIT_EVT */ + + /** + * @brief ESP_HIDH_OPEN_EVT + */ + struct hidh_open_evt_param { + esp_hidh_status_t status; /*!< operation status */ + esp_hidh_connection_state_t conn_status; /*!< connection status */ + bool is_orig; /*!< indicate if host intiate the connection */ + uint8_t handle; /*!< device handle */ + esp_bd_addr_t bd_addr; /*!< device address */ + } open; /*!< HIDH callback param of ESP_HIDH_OPEN_EVT */ + + /** + * @brief ESP_HIDH_CLOSE_EVT + */ + struct hidh_close_evt_param { + esp_hidh_status_t status; /*!< operation status */ + uint8_t reason; /*!< lower layer failed reason(ref hiddefs.h) */ + esp_hidh_connection_state_t conn_status; /*!< connection status */ + uint8_t handle; /*!< device handle */ + } close; /*!< HIDH callback param of ESP_HIDH_CLOSE_EVT */ + + /** + * @brief ESP_HIDH_VC_UNPLUG_EVT + */ + struct hidh_unplug_evt_param { + esp_hidh_status_t status; /*!< operation status */ + esp_hidh_connection_state_t conn_status; /*!< connection status */ + uint8_t handle; /*!< device handle */ + } unplug; /*!< HIDH callback param of ESP_HIDH_VC_UNPLUG_EVT */ + + /** + * @brief ESP_HIDH_GET_PROTO_EVT + */ + struct hidh_get_proto_evt_param { + esp_hidh_status_t status; /*!< operation status */ + uint8_t handle; /*!< device handle */ + esp_hidh_protocol_mode_t proto_mode; /*!< protocol mode */ + } get_proto; /*!< HIDH callback param of ESP_HIDH_GET_PROTO_EVT */ + + /** + * @brief ESP_HIDH_SET_PROTO_EVT + */ + struct hidh_set_proto_evt_param { + esp_hidh_status_t status; /*!< operation status */ + uint8_t handle; /*!< device handle */ + } set_proto; /*!< HIDH callback param of ESP_HIDH_SET_PROTO_EVT */ + + /** + * @brief ESP_HIDH_GET_RPT_EVT + */ + struct hidh_get_rpt_evt_param { + esp_hidh_status_t status; /*!< operation status */ + uint8_t handle; /*!< device handle */ + uint16_t len; /*!< data length */ + uint8_t *data; /*!< data pointer */ + } get_rpt; /*!< HIDH callback param of ESP_HIDH_GET_RPT_EVT */ + + /** + * @brief ESP_HIDH_SET_RPT_EVT + */ + struct hidh_set_rpt_evt_param { + esp_hidh_status_t status; /*!< operation status */ + uint8_t handle; /*!< device handle */ + } set_rpt; /*!< HIDH callback param of ESP_HIDH_SET_RPT_EVT */ + + /** + * @brief ESP_HIDH_DATA_EVT + */ + struct hidh_send_data_evt_param { + esp_hidh_status_t status; /*!< operation status */ + uint8_t handle; /*!< device handle */ + uint8_t reason; /*!< lower layer failed reason(ref hiddefs.h) */ + } send_data; /*!< HIDH callback param of ESP_HIDH_DATA_EVT */ + + /** + * @brief ESP_HIDH_GET_IDLE_EVT + */ + struct hidh_get_idle_evt_param { + esp_hidh_status_t status; /*!< operation status */ + uint8_t handle; /*!< device handle */ + uint8_t idle_rate; /*!< idle rate */ + } get_idle; /*!< HIDH callback param of ESP_HIDH_GET_IDLE_EVT */ + + /** + * @brief ESP_HIDH_SET_IDLE_EVT + */ + struct hidh_set_idle_evt_param { + esp_hidh_status_t status; /*!< operation status */ + uint8_t handle; /*!< device handle */ + } set_idle; /*!< HIDH callback param of ESP_HIDH_SET_IDLE_EVT */ + + /** + * @brief ESP_HIDH_DATA_IND_EVT + */ + struct hidh_data_ind_evt_param { + esp_hidh_status_t status; /*!< operation status */ + uint8_t handle; /*!< device handle */ + esp_hidh_protocol_mode_t proto_mode; /*!< protocol mode */ + uint16_t len; /*!< data length */ + uint8_t *data; /*!< data pointer */ + } data_ind; /*!< HIDH callback param of ESP_HIDH_DATA_IND_EVT */ + + /** + * @brief ESP_HIDH_ADD_DEV_EVT + */ + struct hidh_add_dev_evt_param { + esp_hidh_status_t status; /*!< operation status */ + uint8_t handle; /*!< device handle */ + esp_bd_addr_t bd_addr; /*!< device address */ + } add_dev; /*!< HIDH callback param of ESP_HIDH_ADD_DEV_EVT */ + + /** + * @brief ESP_HIDH_RMV_DEV_EVT + */ + struct hidh_rmv_dev_evt_param { + esp_hidh_status_t status; /*!< operation status */ + uint8_t handle; /*!< device handle */ + esp_bd_addr_t bd_addr; /*!< device address */ + } rmv_dev; /*!< HIDH callback param of ESP_HIDH_RMV_DEV_EVT */ + + /** + * @brief ESP_HIDH_GET_DSCP_EVT + */ + struct hidh_get_dscp_evt_param { + esp_hidh_status_t status; /*!< operation status */ + uint8_t handle; /*!< device handle */ + bool added; /*!< Indicate if added */ + uint16_t vendor_id; /*!< Vendor ID */ + uint16_t product_id; /*!< Product ID */ + uint16_t version; /*!< Version */ + uint16_t ssr_max_latency; /*!< SSR max latency */ + uint16_t ssr_min_tout; /*!< SSR min timeout */ + uint8_t ctry_code; /*!< Country Code */ + uint16_t dl_len; /*!< Device descriptor length */ + uint8_t *dsc_list; /*!< Device descriptor pointer */ + } dscp; /*!< HIDH callback param of ESP_HIDH_GET_DSCP_EVT */ + + /** + * @brief ESP_HIDH_SET_INFO_EVT + */ + struct hidh_set_info_evt_param { + esp_hidh_status_t status; /*!< operation status */ + uint8_t handle; /*!< device handle */ + esp_bd_addr_t bd_addr; /*!< device address */ + } set_info; /*!< HIDH callback param of ESP_HIDH_SET_INFO_EVT */ +} esp_hidh_cb_param_t; + +/** + * @brief HID host callback function type + * @param event: Event type + * @param param: Point to callback parameter, currently is union type + */ +typedef void (esp_hh_cb_t)(esp_hidh_cb_event_t event, esp_hidh_cb_param_t *param); + +/** + * @brief This function is called to init callbacks with HID host module. + * + * @param[in] callback: pointer to the init callback function. + * + * @return + * - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_host_register_callback(esp_hh_cb_t callback); + +/** + * @brief This function initializes HID host. This function should be called after esp_bluedroid_enable() and + * esp_blueroid_init() success, and should be called after esp_bt_hid_host_register_callback(). + * When the operation is complete the callback function will be called with ESP_HIDH_INIT_EVT. + * + * @return + * - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_host_init(void); + +/** + * @brief Closes the interface. This function should be called after esp_bluedroid_enable() and + * esp_blueroid_init() success, and should be called after esp_bt_hid_host_init(). + * When the operation is complete the callback function will be called with ESP_HIDH_DEINIT_EVT. + * + * @return - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_host_deinit(void); + +/** + * @brief Connect to hid device. When the operation is complete the callback + * function will be called with ESP_HIDH_OPEN_EVT. + * + * @param[in] bd_addr: Remote device bluetooth device address. + * + * @return - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_host_connect(esp_bd_addr_t bd_addr); + +/** + * @brief Disconnect from hid device. When the operation is complete the callback + * function will be called with ESP_HIDH_CLOSE_EVT. + * + * @param[in] bd_addr: Remote device bluetooth device address. + * + * @return - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_host_disconnect(esp_bd_addr_t bd_addr); + +/** + * @brief Virtual UnPlug (VUP) the specified HID device. When the operation is complete the callback + * function will be called with ESP_HIDH_VC_UNPLUG_EVT. + * + * @param[in] bd_addr: Remote device bluetooth device address. + * + * @return - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_host_virtual_cable_unplug(esp_bd_addr_t bd_addr); + +/** + * @brief Set the HID device descriptor for the specified HID device. When the operation is complete the callback + * function will be called with ESP_HIDH_SET_INFO_EVT. + * + * @param[in] bd_addr: Remote device bluetooth device address. + * @param[in] hid_info: HID device descriptor structure. + * + * @return - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_host_set_info(esp_bd_addr_t bd_addr, esp_hidh_hid_info_t *hid_info); + +/** + * @brief Get the HID proto mode. When the operation is complete the callback + * function will be called with ESP_HIDH_GET_PROTO_EVT. + * + * @param[in] bd_addr: Remote device bluetooth device address. + * + * @return + * - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_host_get_protocol(esp_bd_addr_t bd_addr); + +/** + * @brief Set the HID proto mode. When the operation is complete the callback + * function will be called with ESP_HIDH_SET_PROTO_EVT. + * + * @param[in] bd_addr: Remote device bluetooth device address. + * @param[in] protocol_mode: Protocol mode type. + * + * @return + * - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_host_set_protocol(esp_bd_addr_t bd_addr, esp_hidh_protocol_mode_t protocol_mode); + +/** + * @brief Get the HID Idle Time. When the operation is complete the callback + * function will be called with ESP_HIDH_GET_IDLE_EVT. + * + * @param[in] bd_addr: Remote device bluetooth device address. + * + * @return + * - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_host_get_idle(esp_bd_addr_t bd_addr); + +/** + * @brief Set the HID Idle Time. When the operation is complete the callback + * function will be called with ESP_HIDH_SET_IDLE_EVT. + * + * @param[in] bd_addr: Remote device bluetooth device address. + * @param[in] idle_time: Idle time rate + * + * @return - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_host_set_idle(esp_bd_addr_t bd_addr, uint16_t idle_time); + +/** + * @brief Send a GET_REPORT to HID device. When the operation is complete the callback + * function will be called with ESP_HIDH_GET_RPT_EVT. + * + * @param[in] bd_addr: Remote device bluetooth device address. + * @param[in] report_type: Report type + * @param[in] report_id: Report id + * @param[in] buffer_size: Buffer size + * + * @return - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_host_get_report(esp_bd_addr_t bd_addr, esp_hidh_report_type_t report_type, uint8_t report_id, + int buffer_size); + +/** + * @brief Send a SET_REPORT to HID device. When the operation is complete the callback + * function will be called with ESP_HIDH_SET_RPT_EVT. + * + * @param[in] bd_addr: Remote device bluetooth device address. + * @param[in] report_type: Report type + * @param[in] report: Report data pointer + * @param[in] len: Report data length + * + * @return - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_host_set_report(esp_bd_addr_t bd_addr, esp_hidh_report_type_t report_type, uint8_t *report, + size_t len); + +/** + * @brief Send data to HID device. When the operation is complete the callback + * function will be called with ESP_HIDH_DATA_EVT. + * + * @param[in] bd_addr: Remote device bluetooth device address. + * @param[in] data: Data pointer + * @param[in] len: Data length + * + * @return - ESP_OK: success + * - other: failed + */ +esp_err_t esp_bt_hid_host_send_data(esp_bd_addr_t bd_addr, uint8_t *data, size_t len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/tools/sdk/esp32c3/include/bt/include/esp32c3/include/esp_bt.h b/tools/sdk/esp32c3/include/bt/include/esp32c3/include/esp_bt.h index 78f6691740e..8860d75ff68 100644 --- a/tools/sdk/esp32c3/include/bt/include/esp32c3/include/esp_bt.h +++ b/tools/sdk/esp32c3/include/bt/include/esp32c3/include/esp_bt.h @@ -527,12 +527,6 @@ void esp_bt_controller_wakeup_request(void); */ int esp_bt_h4tl_eif_io_event_notify(int event); -/** - * @brief Get BT MAC address. - * @return Array pointer of length 6 storing MAC address value. - */ -uint8_t* esp_bt_get_mac(void); - #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/async.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/async.h deleted file mode 100644 index e399929677d..00000000000 --- a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/async.h +++ /dev/null @@ -1,148 +0,0 @@ -/* - * async.h -- state management for asynchronous messages - * - * Copyright (C) 2010-2011 Olaf Bergmann - * - * This file is part of the CoAP library libcoap. Please see README for terms - * of use. - */ - -/** - * @file async.h - * @brief State management for asynchronous messages - */ - -#ifndef COAP_ASYNC_H_ -#define COAP_ASYNC_H_ - -#include "net.h" - -#ifndef WITHOUT_ASYNC - -/** - * @defgroup coap_async Asynchronous Messaging - * @{ - * Structure for managing asynchronous state of CoAP resources. A - * coap_resource_t object holds a list of coap_async_state_t objects that can be - * used to generate a separate response in case a result of an operation cannot - * be delivered in time, or the resource has been explicitly subscribed to with - * the option @c observe. - */ -typedef struct coap_async_state_t { - unsigned char flags; /**< holds the flags to control behaviour */ - - /** - * Holds the internal time when the object was registered with a - * resource. This field will be updated whenever - * coap_register_async() is called for a specific resource. - */ - coap_tick_t created; - - /** - * This field can be used to register opaque application data with the - * asynchronous state object. - */ - void *appdata; - coap_session_t *session; /**< transaction session */ - coap_tid_t id; /**< transaction id */ - struct coap_async_state_t *next; /**< internally used for linking */ - size_t tokenlen; /**< length of the token */ - uint8_t token[8]; /**< the token to use in a response */ -} coap_async_state_t; - -/* Definitions for Async Status Flags These flags can be used to control the - * behaviour of asynchronous response generation. - */ -#define COAP_ASYNC_CONFIRM 0x01 /**< send confirmable response */ -#define COAP_ASYNC_SEPARATE 0x02 /**< send separate response */ -#define COAP_ASYNC_OBSERVED 0x04 /**< the resource is being observed */ - -/** release application data on destruction */ -#define COAP_ASYNC_RELEASE_DATA 0x08 - -/** - * Allocates a new coap_async_state_t object and fills its fields according to - * the given @p request. The @p flags are used to control generation of empty - * ACK responses to stop retransmissions and to release registered @p data when - * the resource is deleted by coap_free_async(). This function returns a pointer - * to the registered coap_async_t object or @c NULL on error. Note that this - * function will return @c NULL in case that an object with the same identifier - * is already registered. - * - * @param context The context to use. - * @param session The session that is used for asynchronous transmissions. - * @param request The request that is handled asynchronously. - * @param flags Flags to control state management. - * @param data Opaque application data to register. Note that the - * storage occupied by @p data is released on destruction - * only if flag COAP_ASYNC_RELEASE_DATA is set. - * - * @return A pointer to the registered coap_async_state_t object or @c - * NULL in case of an error. - */ -coap_async_state_t * -coap_register_async(coap_context_t *context, - coap_session_t *session, - coap_pdu_t *request, - unsigned char flags, - void *data); - -/** - * Removes the state object identified by @p id from @p context. The removed - * object is returned in @p s, if found. Otherwise, @p s is undefined. This - * function returns @c 1 if the object was removed, @c 0 otherwise. Note that - * the storage allocated for the stored object is not released by this - * functions. You will have to call coap_free_async() to do so. - * - * @param context The context where the async object is registered. - * @param session The session that is used for asynchronous transmissions. - * @param id The identifier of the asynchronous transaction. - * @param s Will be set to the object identified by @p id after removal. - * - * @return @c 1 if object was removed and @p s updated, or @c 0 if no - * object was found with the given id. @p s is valid only if the - * return value is @c 1. - */ -int coap_remove_async(coap_context_t *context, - coap_session_t *session, - coap_tid_t id, - coap_async_state_t **s); - -/** - * Releases the memory that was allocated by coap_async_state_init() for the - * object @p s. The registered application data will be released automatically - * if COAP_ASYNC_RELEASE_DATA is set. - * - * @param state The object to delete. - */ -void -coap_free_async(coap_async_state_t *state); - -/** - * Retrieves the object identified by @p id from the list of asynchronous - * transactions that are registered with @p context. This function returns a - * pointer to that object or @c NULL if not found. - * - * @param context The context where the asynchronous objects are registered - * with. - * @param session The session that is used for asynchronous transmissions. - * @param id The id of the object to retrieve. - * - * @return A pointer to the object identified by @p id or @c NULL if - * not found. - */ -coap_async_state_t *coap_find_async(coap_context_t *context, coap_session_t *session, coap_tid_t id); - -/** - * Updates the time stamp of @p s. - * - * @param s The state object to update. - */ -COAP_STATIC_INLINE void -coap_touch_async(coap_async_state_t *s) { coap_ticks(&s->created); } - -/** @} */ - -#endif /* WITHOUT_ASYNC */ - -#endif /* COAP_ASYNC_H_ */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/bits.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/bits.h deleted file mode 100644 index 3b1871487c9..00000000000 --- a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/bits.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * bits.h -- bit vector manipulation - * - * Copyright (C) 2010-2011 Olaf Bergmann - * - * This file is part of the CoAP library libcoap. Please see README for terms - * of use. - */ - -/** - * @file bits.h - * @brief Bit vector manipulation - */ - -#ifndef COAP_BITS_H_ -#define COAP_BITS_H_ - -#include - -/** - * Sets the bit @p bit in bit-vector @p vec. This function returns @c 1 if bit - * was set or @c -1 on error (i.e. when the given bit does not fit in the - * vector). - * - * @param vec The bit-vector to change. - * @param size The size of @p vec in bytes. - * @param bit The bit to set in @p vec. - * - * @return @c -1 if @p bit does not fit into @p vec, @c 1 otherwise. - */ -COAP_STATIC_INLINE int -bits_setb(uint8_t *vec, size_t size, uint8_t bit) { - if (size <= ((size_t)bit >> 3)) - return -1; - - *(vec + (bit >> 3)) |= (uint8_t)(1 << (bit & 0x07)); - return 1; -} - -/** - * Clears the bit @p bit from bit-vector @p vec. This function returns @c 1 if - * bit was cleared or @c -1 on error (i.e. when the given bit does not fit in - * the vector). - * - * @param vec The bit-vector to change. - * @param size The size of @p vec in bytes. - * @param bit The bit to clear from @p vec. - * - * @return @c -1 if @p bit does not fit into @p vec, @c 1 otherwise. - */ -COAP_STATIC_INLINE int -bits_clrb(uint8_t *vec, size_t size, uint8_t bit) { - if (size <= ((size_t)bit >> 3)) - return -1; - - *(vec + (bit >> 3)) &= (uint8_t)(~(1 << (bit & 0x07))); - return 1; -} - -/** - * Gets the status of bit @p bit from bit-vector @p vec. This function returns - * @c 1 if the bit is set, @c 0 otherwise (even in case of an error). - * - * @param vec The bit-vector to read from. - * @param size The size of @p vec in bytes. - * @param bit The bit to get from @p vec. - * - * @return @c 1 if the bit is set, @c 0 otherwise. - */ -COAP_STATIC_INLINE int -bits_getb(const uint8_t *vec, size_t size, uint8_t bit) { - if (size <= ((size_t)bit >> 3)) - return -1; - - return (*(vec + (bit >> 3)) & (1 << (bit & 0x07))) != 0; -} - -#endif /* COAP_BITS_H_ */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/block.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/block.h deleted file mode 100644 index 848897639c9..00000000000 --- a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/block.h +++ /dev/null @@ -1,173 +0,0 @@ -/* - * block.h -- block transfer - * - * Copyright (C) 2010-2012,2014-2015 Olaf Bergmann - * - * This file is part of the CoAP library libcoap. Please see README for terms - * of use. - */ - -#ifndef COAP_BLOCK_H_ -#define COAP_BLOCK_H_ - -#include "encode.h" -#include "option.h" -#include "pdu.h" - -struct coap_resource_t; -struct coap_session_t; - -/** - * @defgroup block Block Transfer - * API functions for handling PDUs using CoAP BLOCK options - * @{ - */ - -#ifndef COAP_MAX_BLOCK_SZX -/** - * The largest value for the SZX component in a Block option. - */ -#define COAP_MAX_BLOCK_SZX 6 -#endif /* COAP_MAX_BLOCK_SZX */ - -/** - * Structure of Block options. - */ -typedef struct { - unsigned int num; /**< block number */ - unsigned int m:1; /**< 1 if more blocks follow, 0 otherwise */ - unsigned int szx:3; /**< block size */ -} coap_block_t; - -/** - * Returns the value of the least significant byte of a Block option @p opt. - * For zero-length options (i.e. num == m == szx == 0), COAP_OPT_BLOCK_LAST - * returns @c NULL. - */ -#define COAP_OPT_BLOCK_LAST(opt) \ - (coap_opt_length(opt) ? (coap_opt_value(opt) + (coap_opt_length(opt)-1)) : 0) - -/** Returns the value of the More-bit of a Block option @p opt. */ -#define COAP_OPT_BLOCK_MORE(opt) \ - (coap_opt_length(opt) ? (*COAP_OPT_BLOCK_LAST(opt) & 0x08) : 0) - -/** Returns the value of the SZX-field of a Block option @p opt. */ -#define COAP_OPT_BLOCK_SZX(opt) \ - (coap_opt_length(opt) ? (*COAP_OPT_BLOCK_LAST(opt) & 0x07) : 0) - -/** - * Returns the value of field @c num in the given block option @p block_opt. - */ -unsigned int coap_opt_block_num(const coap_opt_t *block_opt); - -/** - * Checks if more than @p num blocks are required to deliver @p data_len - * bytes of data for a block size of 1 << (@p szx + 4). - */ -COAP_STATIC_INLINE int -coap_more_blocks(size_t data_len, unsigned int num, uint16_t szx) { - return ((num+1) << (szx + 4)) < data_len; -} - -#if 0 -/** Sets the More-bit in @p block_opt */ -COAP_STATIC_INLINE void -coap_opt_block_set_m(coap_opt_t *block_opt, int m) { - if (m) - *(coap_opt_value(block_opt) + (coap_opt_length(block_opt) - 1)) |= 0x08; - else - *(coap_opt_value(block_opt) + (coap_opt_length(block_opt) - 1)) &= ~0x08; -} -#endif - -/** - * Initializes @p block from @p pdu. @p type must be either COAP_OPTION_BLOCK1 - * or COAP_OPTION_BLOCK2. When option @p type was found in @p pdu, @p block is - * initialized with values from this option and the function returns the value - * @c 1. Otherwise, @c 0 is returned. - * - * @param pdu The pdu to search for option @p type. - * @param type The option to search for (must be COAP_OPTION_BLOCK1 or - * COAP_OPTION_BLOCK2). - * @param block The block structure to initilize. - * - * @return @c 1 on success, @c 0 otherwise. - */ -int coap_get_block(coap_pdu_t *pdu, uint16_t type, coap_block_t *block); - -/** - * Writes a block option of type @p type to message @p pdu. If the requested - * block size is too large to fit in @p pdu, it is reduced accordingly. An - * exception is made for the final block when less space is required. The actual - * length of the resource is specified in @p data_length. - * - * This function may change *block to reflect the values written to @p pdu. As - * the function takes into consideration the remaining space @p pdu, no more - * options should be added after coap_write_block_opt() has returned. - * - * @param block The block structure to use. On return, this object is - * updated according to the values that have been written to - * @p pdu. - * @param type COAP_OPTION_BLOCK1 or COAP_OPTION_BLOCK2. - * @param pdu The message where the block option should be written. - * @param data_length The length of the actual data that will be added the @p - * pdu by calling coap_add_block(). - * - * @return @c 1 on success, or a negative value on error. - */ -int coap_write_block_opt(coap_block_t *block, - uint16_t type, - coap_pdu_t *pdu, - size_t data_length); - -/** - * Adds the @p block_num block of size 1 << (@p block_szx + 4) from source @p - * data to @p pdu. - * - * @param pdu The message to add the block. - * @param len The length of @p data. - * @param data The source data to fill the block with. - * @param block_num The actual block number. - * @param block_szx Encoded size of block @p block_number. - * - * @return @c 1 on success, @c 0 otherwise. - */ -int coap_add_block(coap_pdu_t *pdu, - unsigned int len, - const uint8_t *data, - unsigned int block_num, - unsigned char block_szx); - -/** - * Adds the appropriate part of @p data to the @p response pdu. If blocks are - * required, then the appropriate block will be added to the PDU and sent. - * Adds a ETAG option that is the hash of the entire data if the data is to be - * split into blocks - * Used by a GET request handler. - * - * @param resource The resource the data is associated with. - * @param session The coap session. - * @param request The requesting pdu. - * @param response The response pdu. - * @param token The token taken from the (original) requesting pdu. - * @param media_type The format of the data. - * @param maxage The maxmimum life of the data. If @c -1, then there - * is no maxage. - * @param length The total length of the data. - * @param data The entire data block to transmit. - * - */ -void -coap_add_data_blocked_response(struct coap_resource_t *resource, - struct coap_session_t *session, - coap_pdu_t *request, - coap_pdu_t *response, - const coap_binary_t *token, - uint16_t media_type, - int maxage, - size_t length, - const uint8_t* data); - -/**@}*/ - -#endif /* COAP_BLOCK_H_ */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/coap_dtls.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/coap_dtls.h deleted file mode 100644 index f0554f3dfea..00000000000 --- a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/coap_dtls.h +++ /dev/null @@ -1,611 +0,0 @@ -/* - * coap_dtls.h -- (Datagram) Transport Layer Support for libcoap - * - * Copyright (C) 2016 Olaf Bergmann - * Copyright (C) 2017 Jean-Claude Michelou - * - * This file is part of the CoAP library libcoap. Please see README for terms - * of use. - */ - -#ifndef COAP_DTLS_H_ -#define COAP_DTLS_H_ - -#include "coap_time.h" - -struct coap_context_t; -struct coap_session_t; -struct coap_dtls_pki_t; - -/** - * @defgroup dtls DTLS Support - * API functions for interfacing with DTLS libraries. - * @{ - */ - -/** - * Check whether DTLS is available. - * - * @return @c 1 if support for DTLS is enabled, or @c 0 otherwise. - */ -int coap_dtls_is_supported(void); - -/** - * Check whether TLS is available. - * - * @return @c 1 if support for TLS is enabled, or @c 0 otherwise. - */ -int coap_tls_is_supported(void); - -#define COAP_TLS_LIBRARY_NOTLS 0 /**< No DTLS library */ -#define COAP_TLS_LIBRARY_TINYDTLS 1 /**< Using TinyDTLS library */ -#define COAP_TLS_LIBRARY_OPENSSL 2 /**< Using OpenSSL library */ -#define COAP_TLS_LIBRARY_GNUTLS 3 /**< Using GnuTLS library */ - -/** - * The structure used for returning the underlying (D)TLS library - * information. - */ -typedef struct coap_tls_version_t { - uint64_t version; /**< (D)TLS runtime Library Version */ - int type; /**< Library type. One of COAP_TLS_LIBRARY_* */ - uint64_t built_version; /**< (D)TLS Built against Library Version */ -} coap_tls_version_t; - -/** - * Determine the type and version of the underlying (D)TLS library. - * - * @return The version and type of library libcoap was compiled against. - */ -coap_tls_version_t *coap_get_tls_library_version(void); - -/** - * Additional Security setup handler that can be set up by - * coap_context_set_pki(). - * Invoked when libcoap has done the validation checks at the TLS level, - * but the application needs to do some additional checks/changes/updates. - * - * @param tls_session The security session definition - e.g. SSL * for OpenSSL. - * NULL if server call-back. - * This will be dependent on the underlying TLS library - - * see coap_get_tls_library_version() - * @param setup_data A structure containing setup data originally passed into - * coap_context_set_pki() or coap_new_client_session_pki(). - * - * @return @c 1 if successful, else @c 0. - */ -typedef int (*coap_dtls_security_setup_t)(void* tls_session, - struct coap_dtls_pki_t *setup_data); - -/** - * CN Validation call-back that can be set up by coap_context_set_pki(). - * Invoked when libcoap has done the validation checks at the TLS level, - * but the application needs to check that the CN is allowed. - * CN is the SubjectAltName in the cert, if not present, then the leftmost - * Common Name (CN) component of the subject name. - * - * @param cn The determined CN from the certificate - * @param asn1_public_cert The ASN.1 DER encoded X.509 certificate - * @param asn1_length The ASN.1 length - * @param coap_session The CoAP session associated with the certificate update - * @param depth Depth in cert chain. If 0, then client cert, else a CA - * @param validated TLS layer can find no issues if 1 - * @param arg The same as was passed into coap_context_set_pki() - * in setup_data->cn_call_back_arg - * - * @return @c 1 if accepted, else @c 0 if to be rejected. - */ -typedef int (*coap_dtls_cn_callback_t)(const char *cn, - const uint8_t *asn1_public_cert, - size_t asn1_length, - struct coap_session_t *coap_session, - unsigned depth, - int validated, - void *arg); - -/** - * The enum used for determining the provided PKI ASN.1 (DER) Private Key - * formats. - */ -typedef enum coap_asn1_privatekey_type_t { - COAP_ASN1_PKEY_NONE, /**< NONE */ - COAP_ASN1_PKEY_RSA, /**< RSA type */ - COAP_ASN1_PKEY_RSA2, /**< RSA2 type */ - COAP_ASN1_PKEY_DSA, /**< DSA type */ - COAP_ASN1_PKEY_DSA1, /**< DSA1 type */ - COAP_ASN1_PKEY_DSA2, /**< DSA2 type */ - COAP_ASN1_PKEY_DSA3, /**< DSA3 type */ - COAP_ASN1_PKEY_DSA4, /**< DSA4 type */ - COAP_ASN1_PKEY_DH, /**< DH type */ - COAP_ASN1_PKEY_DHX, /**< DHX type */ - COAP_ASN1_PKEY_EC, /**< EC type */ - COAP_ASN1_PKEY_HMAC, /**< HMAC type */ - COAP_ASN1_PKEY_CMAC, /**< CMAC type */ - COAP_ASN1_PKEY_TLS1_PRF, /**< TLS1_PRF type */ - COAP_ASN1_PKEY_HKDF /**< HKDF type */ -} coap_asn1_privatekey_type_t; - -/** - * The enum used for determining the PKI key formats. - */ -typedef enum coap_pki_key_t { - COAP_PKI_KEY_PEM = 0, /**< The PKI key type is PEM */ - COAP_PKI_KEY_ASN1, /**< The PKI key type is ASN.1 (DER) */ -} coap_pki_key_t; - -/** - * The structure that holds the PKI PEM definitions. - */ -typedef struct coap_pki_key_pem_t { - const char *ca_file; /**< File location of Common CA in PEM format */ - const char *public_cert; /**< File location of Public Cert in PEM format */ - const char *private_key; /**< File location of Private Key in PEM format */ -} coap_pki_key_pem_t; - -/** - * The structure that holds the PKI ASN.1 (DER) definitions. - */ -typedef struct coap_pki_key_asn1_t { - const uint8_t *ca_cert; /**< ASN1 (DER) Common CA Cert */ - const uint8_t *public_cert; /**< ASN1 (DER) Public Cert */ - const uint8_t *private_key; /**< ASN1 (DER) Private Key */ - size_t ca_cert_len; /**< ASN1 CA Cert length */ - size_t public_cert_len; /**< ASN1 Public Cert length */ - size_t private_key_len; /**< ASN1 Private Key length */ - coap_asn1_privatekey_type_t private_key_type; /**< Private Key Type */ -} coap_pki_key_asn1_t; - -/** - * The structure that holds the PKI key information. - */ -typedef struct coap_dtls_key_t { - coap_pki_key_t key_type; /**< key format type */ - union { - coap_pki_key_pem_t pem; /**< for PEM keys */ - coap_pki_key_asn1_t asn1; /**< for ASN.1 (DER) keys */ - } key; -} coap_dtls_key_t; - -/** - * Server Name Indication (SNI) Validation call-back that can be set up by - * coap_context_set_pki(). - * Invoked if the SNI is not previously seen and prior to sending a certificate - * set back to the client so that the appropriate certificate set can be used - * based on the requesting SNI. - * - * @param sni The requested SNI - * @param arg The same as was passed into coap_context_set_pki() - * in setup_data->sni_call_back_arg - * - * @return New set of certificates to use, or @c NULL if SNI is to be rejected. - */ -typedef coap_dtls_key_t *(*coap_dtls_sni_callback_t)(const char *sni, - void* arg); - - -#define COAP_DTLS_PKI_SETUP_VERSION 1 /**< Latest PKI setup version */ - -/** - * The structure used for defining the PKI setup data to be used. - */ -typedef struct coap_dtls_pki_t { - uint8_t version; /** Set to 1 to support this version of the struct */ - - /* Options to enable different TLS functionality in libcoap */ - uint8_t verify_peer_cert; /**< 1 if peer cert is to be verified */ - uint8_t require_peer_cert; /**< 1 if peer cert is required */ - uint8_t allow_self_signed; /**< 1 if self signed certs are allowed */ - uint8_t allow_expired_certs; /**< 1 if expired certs are allowed */ - uint8_t cert_chain_validation; /**< 1 if to check cert_chain_verify_depth */ - uint8_t cert_chain_verify_depth; /**< recommended depth is 3 */ - uint8_t check_cert_revocation; /**< 1 if revocation checks wanted */ - uint8_t allow_no_crl; /**< 1 ignore if CRL not there */ - uint8_t allow_expired_crl; /**< 1 if expired crl is allowed */ - uint8_t reserved[6]; /**< Reserved - must be set to 0 for - future compatibility */ - /* Size of 6 chosen to align to next - * parameter, so if newly defined option - * it can use one of the reserverd slot so - * no need to change - * COAP_DTLS_PKI_SETUP_VERSION and just - * decrement the reserved[] count. - */ - - /** CN check call-back function. - * If not NULL, is called when the TLS connection has passed the configured - * TLS options above for the application to verify if the CN is valid. - */ - coap_dtls_cn_callback_t validate_cn_call_back; - void *cn_call_back_arg; /**< Passed in to the CN call-back function */ - - /** SNI check call-back function. - * If not @p NULL, called if the SNI is not previously seen and prior to - * sending a certificate set back to the client so that the appropriate - * certificate set can be used based on the requesting SNI. - */ - coap_dtls_sni_callback_t validate_sni_call_back; - void *sni_call_back_arg; /**< Passed in to the sni call-back function */ - - /** Additional Security call-back handler that is invoked when libcoap has - * done the standerd, defined validation checks at the TLS level, - * If not @p NULL, called from within the TLS Client Hello connection - * setup. - */ - coap_dtls_security_setup_t additional_tls_setup_call_back; - - char* client_sni; /**< If not NULL, SNI to use in client TLS setup. - Owned by the client app and must remain valid - during the call to coap_new_client_session_pki() */ - - coap_dtls_key_t pki_key; /**< PKI key definition */ -} coap_dtls_pki_t; - -/** @} */ - -/** - * @defgroup dtls_internal DTLS Support (Internal) - * Internal API functions for interfacing with DTLS libraries. - * @{ - */ - -/** - * Creates a new DTLS context for the given @p coap_context. This function - * returns a pointer to a new DTLS context object or @c NULL on error. - * - * Internal function. - * - * @param coap_context The CoAP context where the DTLS object shall be used. - * - * @return A DTLS context object or @c NULL on error. - */ -void * -coap_dtls_new_context(struct coap_context_t *coap_context); - -typedef enum coap_dtls_role_t { - COAP_DTLS_ROLE_CLIENT, /**< Internal function invoked for client */ - COAP_DTLS_ROLE_SERVER /**< Internal function invoked for server */ -} coap_dtls_role_t; - -/** - * Set the DTLS context's default PSK information. - * This does the PSK specifics following coap_dtls_new_context(). - * If @p COAP_DTLS_ROLE_SERVER, then identity hint will also get set. - * If @p COAP_DTLS_ROLE_SERVER, then the information will get put into the - * TLS library's context (from which sessions are derived). - * If @p COAP_DTLS_ROLE_CLIENT, then the information will get put into the - * TLS library's session. - * - * Internal function. - * - * @param coap_context The CoAP context. - * @param identity_hint The default PSK server identity hint sent to a client. - * Required parameter. If @p NULL, will be set to "". - * Empty string is a valid hint. - * This parameter is ignored if COAP_DTLS_ROLE_CLIENT - * @param role One of @p COAP_DTLS_ROLE_CLIENT or @p COAP_DTLS_ROLE_SERVER - * - * @return @c 1 if successful, else @c 0. - */ - -int -coap_dtls_context_set_psk(struct coap_context_t *coap_context, - const char *identity_hint, - coap_dtls_role_t role); - -/** - * Set the DTLS context's default server PKI information. - * This does the PKI specifics following coap_dtls_new_context(). - * If @p COAP_DTLS_ROLE_SERVER, then the information will get put into the - * TLS library's context (from which sessions are derived). - * If @p COAP_DTLS_ROLE_CLIENT, then the information will get put into the - * TLS library's session. - * - * Internal function. - * - * @param coap_context The CoAP context. - * @param setup_data Setup information defining how PKI is to be setup. - * Required parameter. If @p NULL, PKI will not be - * set up. - * @param role One of @p COAP_DTLS_ROLE_CLIENT or @p COAP_DTLS_ROLE_SERVER - * - * @return @c 1 if successful, else @c 0. - */ - -int -coap_dtls_context_set_pki(struct coap_context_t *coap_context, - coap_dtls_pki_t *setup_data, - coap_dtls_role_t role); - -/** - * Set the dtls context's default Root CA information for a client or server. - * - * Internal function. - * - * @param coap_context The current coap_context_t object. - * @param ca_file If not @p NULL, is the full path name of a PEM encoded - * file containing all the Root CAs to be used. - * @param ca_dir If not @p NULL, points to a directory containing PEM - * encoded files containing all the Root CAs to be used. - * - * @return @c 1 if successful, else @c 0. - */ - -int -coap_dtls_context_set_pki_root_cas(struct coap_context_t *coap_context, - const char *ca_file, - const char *ca_dir); - -/** - * Check whether one of the coap_dtls_context_set_{psk|pki}() functions have - * been called. - * - * Internal function. - * - * @param coap_context The current coap_context_t object. - * - * @return @c 1 if coap_dtls_context_set_{psk|pki}() called, else @c 0. - */ - -int coap_dtls_context_check_keys_enabled(struct coap_context_t *coap_context); - -/** - * Releases the storage allocated for @p dtls_context. - * - * Internal function. - * - * @param dtls_context The DTLS context as returned by coap_dtls_new_context(). - */ -void coap_dtls_free_context(void *dtls_context); - -/** - * Create a new client-side session. This should send a HELLO to the server. - * - * Internal function. - * - * @param coap_session The CoAP session. - * - * @return Opaque handle to underlying TLS library object containing security - * parameters for the session. -*/ -void *coap_dtls_new_client_session(struct coap_session_t *coap_session); - -/** - * Create a new DTLS server-side session. - * Called after coap_dtls_hello() has returned @c 1, signalling that a validated - * HELLO was received from a client. - * This should send a HELLO to the server. - * - * Internal function. - * - * @param coap_session The CoAP session. - * - * @return Opaque handle to underlying TLS library object containing security - * parameters for the DTLS session. - */ -void *coap_dtls_new_server_session(struct coap_session_t *coap_session); - -/** - * Terminates the DTLS session (may send an ALERT if necessary) then frees the - * underlying TLS library object containing security parameters for the session. - * - * Internal function. - * - * @param coap_session The CoAP session. - */ -void coap_dtls_free_session(struct coap_session_t *coap_session); - -/** - * Notify of a change in the CoAP session's MTU, for example after - * a PMTU update. - * - * Internal function. - * - * @param coap_session The CoAP session. - */ -void coap_dtls_session_update_mtu(struct coap_session_t *coap_session); - -/** - * Send data to a DTLS peer. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param data pointer to data. - * @param data_len Number of bytes to send. - * - * @return @c 0 if this would be blocking, @c -1 if there is an error or the - * number of cleartext bytes sent. - */ -int coap_dtls_send(struct coap_session_t *coap_session, - const uint8_t *data, - size_t data_len); - -/** - * Check if timeout is handled per CoAP session or per CoAP context. - * - * Internal function. - * - * @return @c 1 of timeout and retransmit is per context, @c 0 if it is - * per session. - */ -int coap_dtls_is_context_timeout(void); - -/** - * Do all pending retransmits and get next timeout - * - * Internal function. - * - * @param dtls_context The DTLS context. - * - * @return @c 0 if no event is pending or date of the next retransmit. - */ -coap_tick_t coap_dtls_get_context_timeout(void *dtls_context); - -/** - * Get next timeout for this session. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param now The current time in ticks. - * - * @return @c 0 If no event is pending or ticks time of the next retransmit. - */ -coap_tick_t coap_dtls_get_timeout(struct coap_session_t *coap_session, - coap_tick_t now); - -/** - * Handle a DTLS timeout expiration. - * - * Internal function. - * - * @param coap_session The CoAP session. - */ -void coap_dtls_handle_timeout(struct coap_session_t *coap_session); - -/** - * Handling incoming data from a DTLS peer. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param data Encrypted datagram. - * @param data_len Encrypted datagram size. - * - * @return Result of coap_handle_dgram on the decrypted CoAP PDU - * or @c -1 for error. - */ -int coap_dtls_receive(struct coap_session_t *coap_session, - const uint8_t *data, - size_t data_len); - -/** - * Handling client HELLO messages from a new candiate peer. - * Note that session->tls is empty. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param data Encrypted datagram. - * @param data_len Encrypted datagram size. - * - * @return @c 0 if a cookie verification message has been sent, @c 1 if the - * HELLO contains a valid cookie and a server session should be created, - * @c -1 if the message is invalid. - */ -int coap_dtls_hello(struct coap_session_t *coap_session, - const uint8_t *data, - size_t data_len); - -/** - * Get DTLS overhead over cleartext PDUs. - * - * Internal function. - * - * @param coap_session The CoAP session. - * - * @return Maximum number of bytes added by DTLS layer. - */ -unsigned int coap_dtls_get_overhead(struct coap_session_t *coap_session); - -/** - * Create a new TLS client-side session. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param connected Updated with whether the connection is connected yet or not. - * @c 0 is not connected, @c 1 is connected. - * - * @return Opaque handle to underlying TLS library object containing security - * parameters for the session. -*/ -void *coap_tls_new_client_session(struct coap_session_t *coap_session, int *connected); - -/** - * Create a TLS new server-side session. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param connected Updated with whether the connection is connected yet or not. - * @c 0 is not connected, @c 1 is connected. - * - * @return Opaque handle to underlying TLS library object containing security - * parameters for the session. - */ -void *coap_tls_new_server_session(struct coap_session_t *coap_session, int *connected); - -/** - * Terminates the TLS session (may send an ALERT if necessary) then frees the - * underlying TLS library object containing security parameters for the session. - * - * Internal function. - * - * @param coap_session The CoAP session. - */ -void coap_tls_free_session( struct coap_session_t *coap_session ); - -/** - * Send data to a TLS peer, with implicit flush. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param data Pointer to data. - * @param data_len Number of bytes to send. - * - * @return @c 0 if this should be retried, @c -1 if there is an error - * or the number of cleartext bytes sent. - */ -ssize_t coap_tls_write(struct coap_session_t *coap_session, - const uint8_t *data, - size_t data_len - ); - -/** - * Read some data from a TLS peer. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param data Pointer to data. - * @param data_len Maximum number of bytes to read. - * - * @return @c 0 if this should be retried, @c -1 if there is an error - * or the number of cleartext bytes read. - */ -ssize_t coap_tls_read(struct coap_session_t *coap_session, - uint8_t *data, - size_t data_len - ); - -/** - * Initialize the underlying (D)TLS Library layer. - * - * Internal function. - * - */ -void coap_dtls_startup(void); - -/** @} */ - -/** - * @ingroup logging - * Sets the (D)TLS logging level to the specified @p level. - * Note: coap_log_level() will influence output if at a specified level. - * - * @param level The logging level to use - LOG_* - */ -void coap_dtls_set_log_level(int level); - -/** - * @ingroup logging - * Get the current (D)TLS logging. - * - * @return The current log level (one of LOG_*). - */ -int coap_dtls_get_log_level(void); - - -#endif /* COAP_DTLS_H */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/coap_session.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/coap_session.h deleted file mode 100644 index 1dc0103e3e7..00000000000 --- a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/coap_session.h +++ /dev/null @@ -1,492 +0,0 @@ -/* coap_session.h -- Session management for libcoap -* -* Copyright (C) 2017 Jean-Claue Michelou -* -* This file is part of the CoAP library libcoap. Please see -* README for terms of use. -*/ - -#ifndef COAP_SESSION_H_ -#define COAP_SESSION_H_ - - -#include "coap_io.h" -#include "coap_time.h" -#include "pdu.h" - -struct coap_endpoint_t; -struct coap_context_t; -struct coap_queue_t; - -/** -* Abstraction of a fixed point number that can be used where necessary instead -* of a float. 1,000 fractional bits equals one integer -*/ -typedef struct coap_fixed_point_t { - uint16_t integer_part; /**< Integer part of fixed point variable */ - uint16_t fractional_part; /**< Fractional part of fixed point variable - 1/1000 (3 points) precision */ -} coap_fixed_point_t; - -#define COAP_DEFAULT_SESSION_TIMEOUT 300 -#define COAP_PARTIAL_SESSION_TIMEOUT_TICKS (30 * COAP_TICKS_PER_SECOND) -#define COAP_DEFAULT_MAX_HANDSHAKE_SESSIONS 100 - -#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS) -#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS) - -typedef uint8_t coap_session_type_t; -/** - * coap_session_type_t values - */ -#define COAP_SESSION_TYPE_CLIENT 1 /**< client-side */ -#define COAP_SESSION_TYPE_SERVER 2 /**< server-side */ -#define COAP_SESSION_TYPE_HELLO 3 /**< server-side ephemeral session for responding to a client hello */ - -typedef uint8_t coap_session_state_t; -/** - * coap_session_state_t values - */ -#define COAP_SESSION_STATE_NONE 0 -#define COAP_SESSION_STATE_CONNECTING 1 -#define COAP_SESSION_STATE_HANDSHAKE 2 -#define COAP_SESSION_STATE_CSM 3 -#define COAP_SESSION_STATE_ESTABLISHED 4 - -typedef struct coap_session_t { - struct coap_session_t *next; - coap_proto_t proto; /**< protocol used */ - coap_session_type_t type; /**< client or server side socket */ - coap_session_state_t state; /**< current state of relationaship with peer */ - unsigned ref; /**< reference count from queues */ - unsigned tls_overhead; /**< overhead of TLS layer */ - unsigned mtu; /**< path or CSM mtu */ - coap_address_t local_if; /**< optional local interface address */ - coap_address_t remote_addr; /**< remote address and port */ - coap_address_t local_addr; /**< local address and port */ - int ifindex; /**< interface index */ - coap_socket_t sock; /**< socket object for the session, if any */ - struct coap_endpoint_t *endpoint; /**< session's endpoint */ - struct coap_context_t *context; /**< session's context */ - void *tls; /**< security parameters */ - uint16_t tx_mid; /**< the last message id that was used in this session */ - uint8_t con_active; /**< Active CON request sent */ - struct coap_queue_t *delayqueue; /**< list of delayed messages waiting to be sent */ - size_t partial_write; /**< if > 0 indicates number of bytes already written from the pdu at the head of sendqueue */ - uint8_t read_header[8]; /**< storage space for header of incoming message header */ - size_t partial_read; /**< if > 0 indicates number of bytes already read for an incoming message */ - coap_pdu_t *partial_pdu; /**< incomplete incoming pdu */ - coap_tick_t last_rx_tx; - coap_tick_t last_tx_rst; - coap_tick_t last_ping; - coap_tick_t last_pong; - coap_tick_t csm_tx; - uint8_t *psk_identity; - size_t psk_identity_len; - uint8_t *psk_key; - size_t psk_key_len; - void *app; /**< application-specific data */ - unsigned int max_retransmit; /**< maximum re-transmit count (default 4) */ - coap_fixed_point_t ack_timeout; /**< timeout waiting for ack (default 2 secs) */ - coap_fixed_point_t ack_random_factor; /**< ack random factor backoff (default 1.5) */ - unsigned int dtls_timeout_count; /**< dtls setup retry counter */ - int dtls_event; /**< Tracking any (D)TLS events on this sesison */ -} coap_session_t; - -/** -* Increment reference counter on a session. -* -* @param session The CoAP session. -* @return same as session -*/ -coap_session_t *coap_session_reference(coap_session_t *session); - -/** -* Decrement reference counter on a session. -* Note that the session may be deleted as a result and should not be used -* after this call. -* -* @param session The CoAP session. -*/ -void coap_session_release(coap_session_t *session); - -/** -* Stores @p data with the given session. This function overwrites any value -* that has previously been stored with @p session. -*/ -void coap_session_set_app_data(coap_session_t *session, void *data); - -/** -* Returns any application-specific data that has been stored with @p -* session using the function coap_session_set_app_data(). This function will -* return @c NULL if no data has been stored. -*/ -void *coap_session_get_app_data(const coap_session_t *session); - -/** -* Notify session that it has failed. -* -* @param session The CoAP session. -* @param reason The reason why the session was disconnected. -*/ -void coap_session_disconnected(coap_session_t *session, coap_nack_reason_t reason); - -/** -* Notify session transport has just connected and CSM exchange can now start. -* -* @param session The CoAP session. -*/ -void coap_session_send_csm(coap_session_t *session); - -/** -* Notify session that it has just connected or reconnected. -* -* @param session The CoAP session. -*/ -void coap_session_connected(coap_session_t *session); - -/** -* Set the session MTU. This is the maximum message size that can be sent, -* excluding IP and UDP overhead. -* -* @param session The CoAP session. -* @param mtu maximum message size -*/ -void coap_session_set_mtu(coap_session_t *session, unsigned mtu); - -/** - * Get maximum acceptable PDU size - * - * @param session The CoAP session. - * @return maximum PDU size, not including header (but including token). - */ -size_t coap_session_max_pdu_size(const coap_session_t *session); - -/** -* Creates a new client session to the designated server. -* @param ctx The CoAP context. -* @param local_if Address of local interface. It is recommended to use NULL to let the operating system choose a suitable local interface. If an address is specified, the port number should be zero, which means that a free port is automatically selected. -* @param server The server's address. If the port number is zero, the default port for the protocol will be used. -* @param proto Protocol. -* -* @return A new CoAP session or NULL if failed. Call coap_session_release to free. -*/ -coap_session_t *coap_new_client_session( - struct coap_context_t *ctx, - const coap_address_t *local_if, - const coap_address_t *server, - coap_proto_t proto -); - -/** -* Creates a new client session to the designated server with PSK credentials -* @param ctx The CoAP context. -* @param local_if Address of local interface. It is recommended to use NULL to let the operating system choose a suitable local interface. If an address is specified, the port number should be zero, which means that a free port is automatically selected. -* @param server The server's address. If the port number is zero, the default port for the protocol will be used. -* @param proto Protocol. -* @param identity PSK client identity -* @param key PSK shared key -* @param key_len PSK shared key length -* -* @return A new CoAP session or NULL if failed. Call coap_session_release to free. -*/ -coap_session_t *coap_new_client_session_psk( - struct coap_context_t *ctx, - const coap_address_t *local_if, - const coap_address_t *server, - coap_proto_t proto, - const char *identity, - const uint8_t *key, - unsigned key_len -); - -struct coap_dtls_pki_t; - -/** -* Creates a new client session to the designated server with PKI credentials -* @param ctx The CoAP context. -* @param local_if Address of local interface. It is recommended to use NULL to -* let the operating system choose a suitable local interface. -* If an address is specified, the port number should be zero, -* which means that a free port is automatically selected. -* @param server The server's address. If the port number is zero, the default -* port for the protocol will be used. -* @param proto CoAP Protocol. -* @param setup_data PKI parameters. -* -* @return A new CoAP session or NULL if failed. Call coap_session_release() -* to free. -*/ -coap_session_t *coap_new_client_session_pki( - struct coap_context_t *ctx, - const coap_address_t *local_if, - const coap_address_t *server, - coap_proto_t proto, - struct coap_dtls_pki_t *setup_data -); - -/** -* Creates a new server session for the specified endpoint. -* @param ctx The CoAP context. -* @param ep An endpoint where an incoming connection request is pending. -* -* @return A new CoAP session or NULL if failed. Call coap_session_release to free. -*/ -coap_session_t *coap_new_server_session( - struct coap_context_t *ctx, - struct coap_endpoint_t *ep -); - -/** -* Function interface for datagram data transmission. This function returns -* the number of bytes that have been transmitted, or a value less than zero -* on error. -* -* @param session Session to send data on. -* @param data The data to send. -* @param datalen The actual length of @p data. -* -* @return The number of bytes written on success, or a value -* less than zero on error. -*/ -ssize_t coap_session_send(coap_session_t *session, - const uint8_t *data, size_t datalen); - -/** -* Function interface for stream data transmission. This function returns -* the number of bytes that have been transmitted, or a value less than zero -* on error. The number of bytes written may be less than datalen because of -* congestion control. -* -* @param session Session to send data on. -* @param data The data to send. -* @param datalen The actual length of @p data. -* -* @return The number of bytes written on success, or a value -* less than zero on error. -*/ -ssize_t coap_session_write(coap_session_t *session, - const uint8_t *data, size_t datalen); - -/** -* Send a pdu according to the session's protocol. This function returns -* the number of bytes that have been transmitted, or a value less than zero -* on error. -* -* @param session Session to send pdu on. -* @param pdu The pdu to send. -* -* @return The number of bytes written on success, or a value -* less than zero on error. -*/ -ssize_t coap_session_send_pdu(coap_session_t *session, coap_pdu_t *pdu); - - -/** - * @ingroup logging - * Get session description. - * - * @param session The CoAP session. - * @return description string. - */ -const char *coap_session_str(const coap_session_t *session); - -ssize_t -coap_session_delay_pdu(coap_session_t *session, coap_pdu_t *pdu, - struct coap_queue_t *node); -/** -* Abstraction of virtual endpoint that can be attached to coap_context_t. The -* tuple (handle, addr) must uniquely identify this endpoint. -*/ -typedef struct coap_endpoint_t { - struct coap_endpoint_t *next; - struct coap_context_t *context; /**< endpoint's context */ - coap_proto_t proto; /**< protocol used on this interface */ - uint16_t default_mtu; /**< default mtu for this interface */ - coap_socket_t sock; /**< socket object for the interface, if any */ - coap_address_t bind_addr; /**< local interface address */ - coap_session_t *sessions; /**< list of active sessions */ -} coap_endpoint_t; - -/** -* Create a new endpoint for communicating with peers. -* -* @param context The coap context that will own the new endpoint -* @param listen_addr Address the endpoint will listen for incoming requests on or originate outgoing requests from. Use NULL to specify that no incoming request will be accepted and use a random endpoint. -* @param proto Protocol used on this endpoint -*/ - -coap_endpoint_t *coap_new_endpoint(struct coap_context_t *context, const coap_address_t *listen_addr, coap_proto_t proto); - -/** -* Set the endpoint's default MTU. This is the maximum message size that can be -* sent, excluding IP and UDP overhead. -* -* @param endpoint The CoAP endpoint. -* @param mtu maximum message size -*/ -void coap_endpoint_set_default_mtu(coap_endpoint_t *endpoint, unsigned mtu); - -void coap_free_endpoint(coap_endpoint_t *ep); - - -/** - * @ingroup logging -* Get endpoint description. -* -* @param endpoint The CoAP endpoint. -* @return description string. -*/ -const char *coap_endpoint_str(const coap_endpoint_t *endpoint); - -/** -* Lookup the server session for the packet received on an endpoint, or create -* a new one. -* -* @param endpoint Active endpoint the packet was received on. -* @param packet Received packet. -* @param now The current time in ticks. -* @return The CoAP session or @c NULL if error. -*/ -coap_session_t *coap_endpoint_get_session(coap_endpoint_t *endpoint, - const struct coap_packet_t *packet, coap_tick_t now); - -/** - * Create a new DTLS session for the @p session. - * Note: the @p session is released if no DTLS server session can be created. - * - * @ingroup dtls_internal - * - * @param session Session to add DTLS session to - * @param now The current time in ticks. - * - * @return CoAP session or @c NULL if error. - */ -coap_session_t *coap_session_new_dtls_session(coap_session_t *session, - coap_tick_t now); - -coap_session_t *coap_session_get_by_peer(struct coap_context_t *ctx, - const struct coap_address_t *remote_addr, int ifindex); - -void coap_session_free(coap_session_t *session); -void coap_session_mfree(coap_session_t *session); - - /** - * @defgroup cc Rate Control - * The transmission parameters for CoAP rate control ("Congestion - * Control" in stream-oriented protocols) are defined in - * https://tools.ietf.org/html/rfc7252#section-4.8 - * @{ - */ - - /** - * Number of seconds when to expect an ACK or a response to an - * outstanding CON message. - * RFC 7252, Section 4.8 Default value of ACK_TIMEOUT is 2 - */ -#define COAP_DEFAULT_ACK_TIMEOUT ((coap_fixed_point_t){2,0}) - - /** - * A factor that is used to randomize the wait time before a message - * is retransmitted to prevent synchronization effects. - * RFC 7252, Section 4.8 Default value of ACK_RANDOM_FACTOR is 1.5 - */ -#define COAP_DEFAULT_ACK_RANDOM_FACTOR ((coap_fixed_point_t){1,500}) - - /** - * Number of message retransmissions before message sending is stopped - * RFC 7252, Section 4.8 Default value of MAX_RETRANSMIT is 4 - */ -#define COAP_DEFAULT_MAX_RETRANSMIT 4 - - /** - * The number of simultaneous outstanding interactions that a client - * maintains to a given server. - * RFC 7252, Section 4.8 Default value of NSTART is 1 - */ -#define COAP_DEFAULT_NSTART 1 - - /** @} */ - -/** -* Set the CoAP maximum retransmit count before failure -* -* Number of message retransmissions before message sending is stopped -* -* @param session The CoAP session. -* @param value The value to set to. The default is 4 and should not normally -* get changed. -*/ -void coap_session_set_max_retransmit(coap_session_t *session, - unsigned int value); - -/** -* Set the CoAP initial ack response timeout before the next re-transmit -* -* Number of seconds when to expect an ACK or a response to an -* outstanding CON message. -* -* @param session The CoAP session. -* @param value The value to set to. The default is 2 and should not normally -* get changed. -*/ -void coap_session_set_ack_timeout(coap_session_t *session, - coap_fixed_point_t value); - -/** -* Set the CoAP ack randomize factor -* -* A factor that is used to randomize the wait time before a message -* is retransmitted to prevent synchronization effects. -* -* @param session The CoAP session. -* @param value The value to set to. The default is 1.5 and should not normally -* get changed. -*/ -void coap_session_set_ack_random_factor(coap_session_t *session, - coap_fixed_point_t value); - -/** -* Get the CoAP maximum retransmit before failure -* -* Number of message retransmissions before message sending is stopped -* -* @param session The CoAP session. -* -* @return Current maximum retransmit value -*/ -unsigned int coap_session_get_max_transmit(coap_session_t *session); - -/** -* Get the CoAP initial ack response timeout before the next re-transmit -* -* Number of seconds when to expect an ACK or a response to an -* outstanding CON message. -* -* @param session The CoAP session. -* -* @return Current ack response timeout value -*/ -coap_fixed_point_t coap_session_get_ack_timeout(coap_session_t *session); - -/** -* Get the CoAP ack randomize factor -* -* A factor that is used to randomize the wait time before a message -* is retransmitted to prevent synchronization effects. -* -* @param session The CoAP session. -* -* @return Current ack randomize value -*/ -coap_fixed_point_t coap_session_get_ack_random_factor(coap_session_t *session); - -/** - * Send a ping message for the session. - * @param session The CoAP session. - * - * @return COAP_INVALID_TID if there is an error - */ -coap_tid_t coap_session_send_ping(coap_session_t *session); - -#endif /* COAP_SESSION_H */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/net.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/net.h deleted file mode 100644 index 7fccf3326c7..00000000000 --- a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/net.h +++ /dev/null @@ -1,746 +0,0 @@ -/* - * net.h -- CoAP network interface - * - * Copyright (C) 2010-2015 Olaf Bergmann - * - * This file is part of the CoAP library libcoap. Please see README for terms - * of use. - */ - -#ifndef COAP_NET_H_ -#define COAP_NET_H_ - -#include -#include -#include -#ifndef _WIN32 -#include -#endif -#include - -#ifdef WITH_LWIP -#include -#endif - -#include "coap_io.h" -#include "coap_dtls.h" -#include "coap_event.h" -#include "coap_time.h" -#include "option.h" -#include "pdu.h" -#include "prng.h" -#include "coap_session.h" - -struct coap_queue_t; - -/** - * Queue entry - */ -typedef struct coap_queue_t { - struct coap_queue_t *next; - coap_tick_t t; /**< when to send PDU for the next time */ - unsigned char retransmit_cnt; /**< retransmission counter, will be removed - * when zero */ - unsigned int timeout; /**< the randomized timeout value */ - coap_session_t *session; /**< the CoAP session */ - coap_tid_t id; /**< CoAP transaction id */ - coap_pdu_t *pdu; /**< the CoAP PDU to send */ -} coap_queue_t; - -/** - * Adds @p node to given @p queue, ordered by variable t in @p node. - * - * @param queue Queue to add to. - * @param node Node entry to add to Queue. - * - * @return @c 1 added to queue, @c 0 failure. - */ -int coap_insert_node(coap_queue_t **queue, coap_queue_t *node); - -/** - * Destroys specified @p node. - * - * @param node Node entry to remove. - * - * @return @c 1 node deleted from queue, @c 0 failure. - */ -int coap_delete_node(coap_queue_t *node); - -/** - * Removes all items from given @p queue and frees the allocated storage. - * - * @param queue The queue to delete. - */ -void coap_delete_all(coap_queue_t *queue); - -/** - * Creates a new node suitable for adding to the CoAP sendqueue. - * - * @return New node entry, or @c NULL if failure. - */ -coap_queue_t *coap_new_node(void); - -struct coap_resource_t; -struct coap_context_t; -#ifndef WITHOUT_ASYNC -struct coap_async_state_t; -#endif - -/** - * Response handler that is used as call-back in coap_context_t. - * - * @param context CoAP session. - * @param session CoAP session. - * @param sent The PDU that was transmitted. - * @param received The PDU that was received. - * @param id CoAP transaction ID. - */ -typedef void (*coap_response_handler_t)(struct coap_context_t *context, - coap_session_t *session, - coap_pdu_t *sent, - coap_pdu_t *received, - const coap_tid_t id); - -/** - * Negative Acknowedge handler that is used as call-back in coap_context_t. - * - * @param context CoAP session. - * @param session CoAP session. - * @param sent The PDU that was transmitted. - * @param reason The reason for the NACK. - * @param id CoAP transaction ID. - */ -typedef void (*coap_nack_handler_t)(struct coap_context_t *context, - coap_session_t *session, - coap_pdu_t *sent, - coap_nack_reason_t reason, - const coap_tid_t id); - -/** - * Recieved Ping handler that is used as call-back in coap_context_t. - * - * @param context CoAP session. - * @param session CoAP session. - * @param received The PDU that was received. - * @param id CoAP transaction ID. - */ -typedef void (*coap_ping_handler_t)(struct coap_context_t *context, - coap_session_t *session, - coap_pdu_t *received, - const coap_tid_t id); - -/** - * Recieved Pong handler that is used as call-back in coap_context_t. - * - * @param context CoAP session. - * @param session CoAP session. - * @param received The PDU that was received. - * @param id CoAP transaction ID. - */ -typedef void (*coap_pong_handler_t)(struct coap_context_t *context, - coap_session_t *session, - coap_pdu_t *received, - const coap_tid_t id); - -/** - * The CoAP stack's global state is stored in a coap_context_t object. - */ -typedef struct coap_context_t { - coap_opt_filter_t known_options; - struct coap_resource_t *resources; /**< hash table or list of known - resources */ - struct coap_resource_t *unknown_resource; /**< can be used for handling - unknown resources */ - -#ifndef WITHOUT_ASYNC - /** - * list of asynchronous transactions */ - struct coap_async_state_t *async_state; -#endif /* WITHOUT_ASYNC */ - - /** - * The time stamp in the first element of the sendqeue is relative - * to sendqueue_basetime. */ - coap_tick_t sendqueue_basetime; - coap_queue_t *sendqueue; - coap_endpoint_t *endpoint; /**< the endpoints used for listening */ - coap_session_t *sessions; /**< client sessions */ - -#ifdef WITH_CONTIKI - struct uip_udp_conn *conn; /**< uIP connection object */ - struct etimer retransmit_timer; /**< fires when the next packet must be sent */ - struct etimer notify_timer; /**< used to check resources periodically */ -#endif /* WITH_CONTIKI */ - -#ifdef WITH_LWIP - uint8_t timer_configured; /**< Set to 1 when a retransmission is - * scheduled using lwIP timers for this - * context, otherwise 0. */ -#endif /* WITH_LWIP */ - - coap_response_handler_t response_handler; - coap_nack_handler_t nack_handler; - coap_ping_handler_t ping_handler; - coap_pong_handler_t pong_handler; - - /** - * Callback function that is used to signal events to the - * application. This field is set by coap_set_event_handler(). - */ - coap_event_handler_t handle_event; - - ssize_t (*network_send)(coap_socket_t *sock, const coap_session_t *session, const uint8_t *data, size_t datalen); - - ssize_t (*network_read)(coap_socket_t *sock, struct coap_packet_t *packet); - - size_t(*get_client_psk)(const coap_session_t *session, const uint8_t *hint, size_t hint_len, uint8_t *identity, size_t *identity_len, size_t max_identity_len, uint8_t *psk, size_t max_psk_len); - size_t(*get_server_psk)(const coap_session_t *session, const uint8_t *identity, size_t identity_len, uint8_t *psk, size_t max_psk_len); - size_t(*get_server_hint)(const coap_session_t *session, uint8_t *hint, size_t max_hint_len); - - void *dtls_context; - uint8_t *psk_hint; - size_t psk_hint_len; - uint8_t *psk_key; - size_t psk_key_len; - - unsigned int session_timeout; /**< Number of seconds of inactivity after which an unused session will be closed. 0 means use default. */ - unsigned int max_idle_sessions; /**< Maximum number of simultaneous unused sessions per endpoint. 0 means no maximum. */ - unsigned int max_handshake_sessions; /**< Maximum number of simultaneous negotating sessions per endpoint. 0 means use default. */ - unsigned int ping_timeout; /**< Minimum inactivity time before sending a ping message. 0 means disabled. */ - unsigned int csm_timeout; /**< Timeout for waiting for a CSM from the remote side. 0 means disabled. */ - - void *app; /**< application-specific data */ -} coap_context_t; - -/** - * Registers a new message handler that is called whenever a response was - * received that matches an ongoing transaction. - * - * @param context The context to register the handler for. - * @param handler The response handler to register. - */ -COAP_STATIC_INLINE void -coap_register_response_handler(coap_context_t *context, - coap_response_handler_t handler) { - context->response_handler = handler; -} - -/** - * Registers a new message handler that is called whenever a confirmable - * message (request or response) is dropped after all retries have been - * exhausted, or a rst message was received, or a network or TLS level - * event was received that indicates delivering the message is not possible. - * - * @param context The context to register the handler for. - * @param handler The nack handler to register. - */ -COAP_STATIC_INLINE void -coap_register_nack_handler(coap_context_t *context, - coap_nack_handler_t handler) { - context->nack_handler = handler; -} - -/** - * Registers a new message handler that is called whenever a CoAP Ping - * message is received. - * - * @param context The context to register the handler for. - * @param handler The ping handler to register. - */ -COAP_STATIC_INLINE void -coap_register_ping_handler(coap_context_t *context, - coap_ping_handler_t handler) { - context->ping_handler = handler; -} - -/** - * Registers a new message handler that is called whenever a CoAP Pong - * message is received. - * - * @param context The context to register the handler for. - * @param handler The pong handler to register. - */ -COAP_STATIC_INLINE void -coap_register_pong_handler(coap_context_t *context, - coap_pong_handler_t handler) { - context->pong_handler = handler; -} - -/** - * Registers the option type @p type with the given context object @p ctx. - * - * @param ctx The context to use. - * @param type The option type to register. - */ -COAP_STATIC_INLINE void -coap_register_option(coap_context_t *ctx, uint16_t type) { - coap_option_setb(ctx->known_options, type); -} - -/** - * Set sendqueue_basetime in the given context object @p ctx to @p now. This - * function returns the number of elements in the queue head that have timed - * out. - */ -unsigned int coap_adjust_basetime(coap_context_t *ctx, coap_tick_t now); - -/** - * Returns the next pdu to send without removing from sendqeue. - */ -coap_queue_t *coap_peek_next( coap_context_t *context ); - -/** - * Returns the next pdu to send and removes it from the sendqeue. - */ -coap_queue_t *coap_pop_next( coap_context_t *context ); - -/** - * Creates a new coap_context_t object that will hold the CoAP stack status. - */ -coap_context_t *coap_new_context(const coap_address_t *listen_addr); - -/** - * Set the context's default PSK hint and/or key for a server. - * - * @param context The current coap_context_t object. - * @param hint The default PSK server hint sent to a client. If @p NULL, PSK - * authentication is disabled. Empty string is a valid hint. - * @param key The default PSK key. If @p NULL, PSK authentication will fail. - * @param key_len The default PSK key's length. If @p 0, PSK authentication will - * fail. - * - * @return @c 1 if successful, else @c 0. - */ -int coap_context_set_psk( coap_context_t *context, const char *hint, - const uint8_t *key, size_t key_len ); - -/** - * Set the context's default PKI information for a server. - * - * @param context The current coap_context_t object. - * @param setup_data If @p NULL, PKI authentication will fail. Certificate - * information required. - * - * @return @c 1 if successful, else @c 0. - */ -int -coap_context_set_pki(coap_context_t *context, - coap_dtls_pki_t *setup_data); - -/** - * Set the context's default Root CA information for a client or server. - * - * @param context The current coap_context_t object. - * @param ca_file If not @p NULL, is the full path name of a PEM encoded - * file containing all the Root CAs to be used. - * @param ca_dir If not @p NULL, points to a directory containing PEM - * encoded files containing all the Root CAs to be used. - * - * @return @c 1 if successful, else @c 0. - */ -int -coap_context_set_pki_root_cas(coap_context_t *context, - const char *ca_file, - const char *ca_dir); - -/** - * Set the context keepalive timer for sessions. - * A keepalive message will be sent after if a session has been inactive, - * i.e. no packet sent or received, for the given number of seconds. - * For reliable protocols, a PING message will be sent. If a PONG has not - * been received before the next PING is due to be sent, the session will - * considered as disconnected. - * - * @param context The coap_context_t object. - * @param seconds Number of seconds for the inactivity timer, or zero - * to disable CoAP-level keepalive messages. - * - * @return 1 if successful, else 0 - */ -void coap_context_set_keepalive(coap_context_t *context, unsigned int seconds); - -/** - * Returns a new message id and updates @p session->tx_mid accordingly. The - * message id is returned in network byte order to make it easier to read in - * tracing tools. - * - * @param session The current coap_session_t object. - * - * @return Incremented message id in network byte order. - */ -COAP_STATIC_INLINE uint16_t -coap_new_message_id(coap_session_t *session) { - return ++session->tx_mid; -} - -/** - * CoAP stack context must be released with coap_free_context(). This function - * clears all entries from the receive queue and send queue and deletes the - * resources that have been registered with @p context, and frees the attached - * endpoints. - * - * @param context The current coap_context_t object to free off. - */ -void coap_free_context(coap_context_t *context); - -/** - * Stores @p data with the given CoAP context. This function - * overwrites any value that has previously been stored with @p - * context. - * - * @param context The CoAP context. - * @param data The data to store with wih the context. Note that this data - * must be valid during the lifetime of @p context. - */ -void coap_set_app_data(coap_context_t *context, void *data); - -/** - * Returns any application-specific data that has been stored with @p - * context using the function coap_set_app_data(). This function will - * return @c NULL if no data has been stored. - * - * @param context The CoAP context. - * - * @return The data previously stored or @c NULL if not data stored. - */ -void *coap_get_app_data(const coap_context_t *context); - -/** - * Creates a new ACK PDU with specified error @p code. The options specified by - * the filter expression @p opts will be copied from the original request - * contained in @p request. Unless @c SHORT_ERROR_RESPONSE was defined at build - * time, the textual reason phrase for @p code will be added as payload, with - * Content-Type @c 0. - * This function returns a pointer to the new response message, or @c NULL on - * error. The storage allocated for the new message must be relased with - * coap_free(). - * - * @param request Specification of the received (confirmable) request. - * @param code The error code to set. - * @param opts An option filter that specifies which options to copy from - * the original request in @p node. - * - * @return A pointer to the new message or @c NULL on error. - */ -coap_pdu_t *coap_new_error_response(coap_pdu_t *request, - unsigned char code, - coap_opt_filter_t opts); - -/** - * Sends an error response with code @p code for request @p request to @p dst. - * @p opts will be passed to coap_new_error_response() to copy marked options - * from the request. This function returns the transaction id if the message was - * sent, or @c COAP_INVALID_TID otherwise. - * - * @param session The CoAP session. - * @param request The original request to respond to. - * @param code The response code. - * @param opts A filter that specifies the options to copy from the - * @p request. - * - * @return The transaction id if the message was sent, or @c - * COAP_INVALID_TID otherwise. - */ -coap_tid_t coap_send_error(coap_session_t *session, - coap_pdu_t *request, - unsigned char code, - coap_opt_filter_t opts); - -/** - * Helper funktion to create and send a message with @p type (usually ACK or - * RST). This function returns @c COAP_INVALID_TID when the message was not - * sent, a valid transaction id otherwise. - * - * @param session The CoAP session. - * @param request The request that should be responded to. - * @param type Which type to set. - * @return transaction id on success or @c COAP_INVALID_TID - * otherwise. - */ -coap_tid_t -coap_send_message_type(coap_session_t *session, coap_pdu_t *request, unsigned char type); - -/** - * Sends an ACK message with code @c 0 for the specified @p request to @p dst. - * This function returns the corresponding transaction id if the message was - * sent or @c COAP_INVALID_TID on error. - * - * @param session The CoAP session. - * @param request The request to be acknowledged. - * - * @return The transaction id if ACK was sent or @c - * COAP_INVALID_TID on error. - */ -coap_tid_t coap_send_ack(coap_session_t *session, coap_pdu_t *request); - -/** - * Sends an RST message with code @c 0 for the specified @p request to @p dst. - * This function returns the corresponding transaction id if the message was - * sent or @c COAP_INVALID_TID on error. - * - * @param session The CoAP session. - * @param request The request to be reset. - * - * @return The transaction id if RST was sent or @c - * COAP_INVALID_TID on error. - */ -COAP_STATIC_INLINE coap_tid_t -coap_send_rst(coap_session_t *session, coap_pdu_t *request) { - return coap_send_message_type(session, request, COAP_MESSAGE_RST); -} - -/** -* Sends a CoAP message to given peer. The memory that is -* allocated by pdu will be released by coap_send(). -* The caller must not use the pdu after calling coap_send(). -* -* @param session The CoAP session. -* @param pdu The CoAP PDU to send. -* -* @return The message id of the sent message or @c -* COAP_INVALID_TID on error. -*/ -coap_tid_t coap_send( coap_session_t *session, coap_pdu_t *pdu ); - -/** - * Handles retransmissions of confirmable messages - * - * @param context The CoAP context. - * @param node The node to retransmit. - * - * @return The message id of the sent message or @c - * COAP_INVALID_TID on error. - */ -coap_tid_t coap_retransmit(coap_context_t *context, coap_queue_t *node); - -/** -* For applications with their own message loop, send all pending retransmits and -* return the list of sockets with events to wait for and the next timeout -* The application should call coap_read, then coap_write again when any condition below is true: -* - data is available on any of the sockets with the COAP_SOCKET_WANT_READ -* - an incoming connection is pending in the listen queue and the COAP_SOCKET_WANT_ACCEPT flag is set -* - at least some data can be written without blocking on any of the sockets with the COAP_SOCKET_WANT_WRITE flag set -* - a connection event occured (success or failure) and the COAP_SOCKET_WANT_CONNECT flag is set -* - the timeout has expired -* Before calling coap_read or coap_write again, the application should position COAP_SOCKET_CAN_READ and COAP_SOCKET_CAN_WRITE flags as applicable. -* -* @param ctx The CoAP context -* @param sockets array of socket descriptors, filled on output -* @param max_sockets size of socket array. -* @param num_sockets pointer to the number of valid entries in the socket arrays on output -* @param now Current time. -* -* @return timeout as maxmimum number of milliseconds that the application should wait for network events or 0 if the application should wait forever. -*/ - -unsigned int -coap_write(coap_context_t *ctx, - coap_socket_t *sockets[], - unsigned int max_sockets, - unsigned int *num_sockets, - coap_tick_t now -); - -/** - * For applications with their own message loop, reads all data from the network. - * - * @param ctx The CoAP context - * @param now Current time - */ -void coap_read(coap_context_t *ctx, coap_tick_t now); - -/** - * The main message processing loop. - * - * @param ctx The CoAP context - * @param timeout_ms Minimum number of milliseconds to wait for new messages before returning. If zero the call will block until at least one packet is sent or received. - * - * @return number of milliseconds spent or @c -1 if there was an error - */ - -int coap_run_once( coap_context_t *ctx, unsigned int timeout_ms ); - -/** - * Parses and interprets a CoAP datagram with context @p ctx. This function - * returns @c 0 if the datagram was handled, or a value less than zero on - * error. - * - * @param ctx The current CoAP context. - * @param session The current CoAP session. - * @param data The received packet'd data. - * @param data_len The received packet'd data length. - * - * @return @c 0 if message was handled successfully, or less than zero on - * error. - */ -int coap_handle_dgram(coap_context_t *ctx, coap_session_t *session, uint8_t *data, size_t data_len); - -/** - * Invokes the event handler of @p context for the given @p event and - * @p data. - * - * @param context The CoAP context whose event handler is to be called. - * @param event The event to deliver. - * @param session The session related to @p event. - * @return The result from the associated event handler or 0 if none was - * registered. - */ -int coap_handle_event(coap_context_t *context, - coap_event_t event, - coap_session_t *session); -/** - * This function removes the element with given @p id from the list given list. - * If @p id was found, @p node is updated to point to the removed element. Note - * that the storage allocated by @p node is @b not released. The caller must do - * this manually using coap_delete_node(). This function returns @c 1 if the - * element with id @p id was found, @c 0 otherwise. For a return value of @c 0, - * the contents of @p node is undefined. - * - * @param queue The queue to search for @p id. - * @param session The session to look for. - * @param id The transaction id to look for. - * @param node If found, @p node is updated to point to the removed node. You - * must release the storage pointed to by @p node manually. - * - * @return @c 1 if @p id was found, @c 0 otherwise. - */ -int coap_remove_from_queue(coap_queue_t **queue, - coap_session_t *session, - coap_tid_t id, - coap_queue_t **node); - -coap_tid_t -coap_wait_ack( coap_context_t *context, coap_session_t *session, - coap_queue_t *node); - -/** - * Retrieves transaction from the queue. - * - * @param queue The transaction queue to be searched. - * @param session The session to find. - * @param id The transaction id to find. - * - * @return A pointer to the transaction object or @c NULL if not found. - */ -coap_queue_t *coap_find_transaction(coap_queue_t *queue, coap_session_t *session, coap_tid_t id); - -/** - * Cancels all outstanding messages for session @p session that have the specified - * token. - * - * @param context The context in use. - * @param session Session of the messages to remove. - * @param token Message token. - * @param token_length Actual length of @p token. - */ -void coap_cancel_all_messages(coap_context_t *context, - coap_session_t *session, - const uint8_t *token, - size_t token_length); - -/** -* Cancels all outstanding messages for session @p session. -* -* @param context The context in use. -* @param session Session of the messages to remove. -* @param reason The reasion for the session cancellation -*/ -void -coap_cancel_session_messages(coap_context_t *context, - coap_session_t *session, - coap_nack_reason_t reason); - -/** - * Dispatches the PDUs from the receive queue in given context. - */ -void coap_dispatch(coap_context_t *context, coap_session_t *session, - coap_pdu_t *pdu); - -/** - * Returns 1 if there are no messages to send or to dispatch in the context's - * queues. */ -int coap_can_exit(coap_context_t *context); - -/** - * Returns the current value of an internal tick counter. The counter counts \c - * COAP_TICKS_PER_SECOND ticks every second. - */ -void coap_ticks(coap_tick_t *); - -/** - * Verifies that @p pdu contains no unknown critical options. Options must be - * registered at @p ctx, using the function coap_register_option(). A basic set - * of options is registered automatically by coap_new_context(). This function - * returns @c 1 if @p pdu is ok, @c 0 otherwise. The given filter object @p - * unknown will be updated with the unknown options. As only @c COAP_MAX_OPT - * options can be signalled this way, remaining options must be examined - * manually. - * - * @code - coap_opt_filter_t f = COAP_OPT_NONE; - coap_opt_iterator_t opt_iter; - - if (coap_option_check_critical(ctx, pdu, f) == 0) { - coap_option_iterator_init(pdu, &opt_iter, f); - - while (coap_option_next(&opt_iter)) { - if (opt_iter.type & 0x01) { - ... handle unknown critical option in opt_iter ... - } - } - } - @endcode - * - * @param ctx The context where all known options are registered. - * @param pdu The PDU to check. - * @param unknown The output filter that will be updated to indicate the - * unknown critical options found in @p pdu. - * - * @return @c 1 if everything was ok, @c 0 otherwise. - */ -int coap_option_check_critical(coap_context_t *ctx, - coap_pdu_t *pdu, - coap_opt_filter_t unknown); - -/** - * Creates a new response for given @p request with the contents of @c - * .well-known/core. The result is NULL on error or a newly allocated PDU that - * must be either sent with coap_sent() or released by coap_delete_pdu(). - * - * @param context The current coap context to use. - * @param session The CoAP session. - * @param request The request for @c .well-known/core . - * - * @return A new 2.05 response for @c .well-known/core or NULL on error. - */ -coap_pdu_t *coap_wellknown_response(coap_context_t *context, - coap_session_t *session, - coap_pdu_t *request); - -/** - * Calculates the initial timeout based on the session CoAP transmission - * parameters 'ack_timeout', 'ack_random_factor', and COAP_TICKS_PER_SECOND. - * The calculation requires 'ack_timeout' and 'ack_random_factor' to be in - * Qx.FRAC_BITS fixed point notation, whereas the passed parameter @p r - * is interpreted as the fractional part of a Q0.MAX_BITS random value. - * - * @param session session timeout is associated with - * @param r random value as fractional part of a Q0.MAX_BITS fixed point - * value - * @return COAP_TICKS_PER_SECOND * 'ack_timeout' * - * (1 + ('ack_random_factor' - 1) * r) - */ -unsigned int coap_calc_timeout(coap_session_t *session, unsigned char r); - -/** - * Function interface for joining a multicast group for listening - * - * @param ctx The current context - * @param groupname The name of the group that is to be joined for listening - * - * @return 0 on success, -1 on error - */ -int -coap_join_mcast_group(coap_context_t *ctx, const char *groupname); - -#endif /* COAP_NET_H_ */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/pdu.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/pdu.h deleted file mode 100644 index 206e2643543..00000000000 --- a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/pdu.h +++ /dev/null @@ -1,543 +0,0 @@ -/* - * pdu.h -- CoAP message structure - * - * Copyright (C) 2010-2014 Olaf Bergmann - * - * This file is part of the CoAP library libcoap. Please see README for terms - * of use. - */ - -/** - * @file pdu.h - * @brief Pre-defined constants that reflect defaults for CoAP - */ - -#ifndef COAP_PDU_H_ -#define COAP_PDU_H_ - -#include "uri.h" - -struct coap_session_t; - -#ifdef WITH_LWIP -#include -#endif - -#include - -#define COAP_DEFAULT_PORT 5683 /* CoAP default UDP/TCP port */ -#define COAPS_DEFAULT_PORT 5684 /* CoAP default UDP/TCP port for secure transmission */ -#define COAP_DEFAULT_MAX_AGE 60 /* default maximum object lifetime in seconds */ -#ifndef COAP_DEFAULT_MTU -#define COAP_DEFAULT_MTU 1152 -#endif /* COAP_DEFAULT_MTU */ - -/* TCP Message format constants, do not modify */ -#define COAP_MESSAGE_SIZE_OFFSET_TCP8 13 -#define COAP_MESSAGE_SIZE_OFFSET_TCP16 269 /* 13 + 256 */ -#define COAP_MESSAGE_SIZE_OFFSET_TCP32 65805 /* 269 + 65536 */ - -/* Derived message size limits */ -#define COAP_MAX_MESSAGE_SIZE_TCP0 (COAP_MESSAGE_SIZE_OFFSET_TCP8-1) /* 12 */ -#define COAP_MAX_MESSAGE_SIZE_TCP8 (COAP_MESSAGE_SIZE_OFFSET_TCP16-1) /* 268 */ -#define COAP_MAX_MESSAGE_SIZE_TCP16 (COAP_MESSAGE_SIZE_OFFSET_TCP32-1) /* 65804 */ -#define COAP_MAX_MESSAGE_SIZE_TCP32 (COAP_MESSAGE_SIZE_OFFSET_TCP32+0xFFFFFFFF) - -#ifndef COAP_DEFAULT_MAX_PDU_RX_SIZE -#if defined(WITH_CONTIKI) || defined(WITH_LWIP) -#define COAP_DEFAULT_MAX_PDU_RX_SIZE (COAP_MAX_MESSAGE_SIZE_TCP16+4) -#else -/* 8 MiB max-message-size plus some space for options */ -#define COAP_DEFAULT_MAX_PDU_RX_SIZE (8*1024*1024+256) -#endif -#endif /* COAP_DEFAULT_MAX_PDU_RX_SIZE */ - -#ifndef COAP_DEBUG_BUF_SIZE -#if defined(WITH_CONTIKI) || defined(WITH_LWIP) -#define COAP_DEBUG_BUF_SIZE 128 -#else /* defined(WITH_CONTIKI) || defined(WITH_LWIP) */ -/* 1024 derived from RFC7252 4.6. Message Size max payload */ -#define COAP_DEBUG_BUF_SIZE (8 + 1024 * 2) -#endif /* defined(WITH_CONTIKI) || defined(WITH_LWIP) */ -#endif /* COAP_DEBUG_BUF_SIZE */ - -#define COAP_DEFAULT_VERSION 1 /* version of CoAP supported */ -#define COAP_DEFAULT_SCHEME "coap" /* the default scheme for CoAP URIs */ - -/** well-known resources URI */ -#define COAP_DEFAULT_URI_WELLKNOWN ".well-known/core" - -/* CoAP message types */ - -#define COAP_MESSAGE_CON 0 /* confirmable message (requires ACK/RST) */ -#define COAP_MESSAGE_NON 1 /* non-confirmable message (one-shot message) */ -#define COAP_MESSAGE_ACK 2 /* used to acknowledge confirmable messages */ -#define COAP_MESSAGE_RST 3 /* indicates error in received messages */ - -/* CoAP request methods */ - -#define COAP_REQUEST_GET 1 -#define COAP_REQUEST_POST 2 -#define COAP_REQUEST_PUT 3 -#define COAP_REQUEST_DELETE 4 -#define COAP_REQUEST_FETCH 5 /* RFC 8132 */ -#define COAP_REQUEST_PATCH 6 /* RFC 8132 */ -#define COAP_REQUEST_IPATCH 7 /* RFC 8132 */ - -/* - * CoAP option types (be sure to update coap_option_check_critical() when - * adding options - */ - -#define COAP_OPTION_IF_MATCH 1 /* C, opaque, 0-8 B, (none) */ -#define COAP_OPTION_URI_HOST 3 /* C, String, 1-255 B, destination address */ -#define COAP_OPTION_ETAG 4 /* E, opaque, 1-8 B, (none) */ -#define COAP_OPTION_IF_NONE_MATCH 5 /* empty, 0 B, (none) */ -#define COAP_OPTION_URI_PORT 7 /* C, uint, 0-2 B, destination port */ -#define COAP_OPTION_LOCATION_PATH 8 /* E, String, 0-255 B, - */ -#define COAP_OPTION_URI_PATH 11 /* C, String, 0-255 B, (none) */ -#define COAP_OPTION_CONTENT_FORMAT 12 /* E, uint, 0-2 B, (none) */ -#define COAP_OPTION_CONTENT_TYPE COAP_OPTION_CONTENT_FORMAT -#define COAP_OPTION_MAXAGE 14 /* E, uint, 0--4 B, 60 Seconds */ -#define COAP_OPTION_URI_QUERY 15 /* C, String, 1-255 B, (none) */ -#define COAP_OPTION_ACCEPT 17 /* C, uint, 0-2 B, (none) */ -#define COAP_OPTION_LOCATION_QUERY 20 /* E, String, 0-255 B, (none) */ -#define COAP_OPTION_SIZE2 28 /* E, uint, 0-4 B, (none) */ -#define COAP_OPTION_PROXY_URI 35 /* C, String, 1-1034 B, (none) */ -#define COAP_OPTION_PROXY_SCHEME 39 /* C, String, 1-255 B, (none) */ -#define COAP_OPTION_SIZE1 60 /* E, uint, 0-4 B, (none) */ - -/* option types from RFC 7641 */ - -#define COAP_OPTION_OBSERVE 6 /* E, empty/uint, 0 B/0-3 B, (none) */ -#define COAP_OPTION_SUBSCRIPTION COAP_OPTION_OBSERVE - -/* selected option types from RFC 7959 */ - -#define COAP_OPTION_BLOCK2 23 /* C, uint, 0--3 B, (none) */ -#define COAP_OPTION_BLOCK1 27 /* C, uint, 0--3 B, (none) */ - -/* selected option types from RFC 7967 */ - -#define COAP_OPTION_NORESPONSE 258 /* N, uint, 0--1 B, 0 */ - -#define COAP_MAX_OPT 65535 /**< the highest option number we know */ - -/* CoAP result codes (HTTP-Code / 100 * 40 + HTTP-Code % 100) */ - -/* As of draft-ietf-core-coap-04, response codes are encoded to base - * 32, i.e. the three upper bits determine the response class while - * the remaining five fine-grained information specific to that class. - */ -#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100) - -/* Determines the class of response code C */ -#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF) - -#ifndef SHORT_ERROR_RESPONSE -/** - * Returns a human-readable response phrase for the specified CoAP response @p - * code. This function returns @c NULL if not found. - * - * @param code The response code for which the literal phrase should be - * retrieved. - * - * @return A zero-terminated string describing the error, or @c NULL if not - * found. - */ -const char *coap_response_phrase(unsigned char code); - -#define COAP_ERROR_PHRASE_LENGTH 32 /**< maximum length of error phrase */ - -#else -#define coap_response_phrase(x) ((char *)NULL) - -#define COAP_ERROR_PHRASE_LENGTH 0 /**< maximum length of error phrase */ -#endif /* SHORT_ERROR_RESPONSE */ - -/* The following definitions exist for backwards compatibility */ -#if 0 /* this does not exist any more */ -#define COAP_RESPONSE_100 40 /* 100 Continue */ -#endif -#define COAP_RESPONSE_200 COAP_RESPONSE_CODE(200) /* 2.00 OK */ -#define COAP_RESPONSE_201 COAP_RESPONSE_CODE(201) /* 2.01 Created */ -#define COAP_RESPONSE_304 COAP_RESPONSE_CODE(203) /* 2.03 Valid */ -#define COAP_RESPONSE_400 COAP_RESPONSE_CODE(400) /* 4.00 Bad Request */ -#define COAP_RESPONSE_404 COAP_RESPONSE_CODE(404) /* 4.04 Not Found */ -#define COAP_RESPONSE_405 COAP_RESPONSE_CODE(405) /* 4.05 Method Not Allowed */ -#define COAP_RESPONSE_415 COAP_RESPONSE_CODE(415) /* 4.15 Unsupported Media Type */ -#define COAP_RESPONSE_500 COAP_RESPONSE_CODE(500) /* 5.00 Internal Server Error */ -#define COAP_RESPONSE_501 COAP_RESPONSE_CODE(501) /* 5.01 Not Implemented */ -#define COAP_RESPONSE_503 COAP_RESPONSE_CODE(503) /* 5.03 Service Unavailable */ -#define COAP_RESPONSE_504 COAP_RESPONSE_CODE(504) /* 5.04 Gateway Timeout */ -#if 0 /* these response codes do not have a valid code any more */ -# define COAP_RESPONSE_X_240 240 /* Token Option required by server */ -# define COAP_RESPONSE_X_241 241 /* Uri-Authority Option required by server */ -#endif -#define COAP_RESPONSE_X_242 COAP_RESPONSE_CODE(402) /* Critical Option not supported */ - -#define COAP_SIGNALING_CODE(N) (((N)/100 << 5) | (N)%100) -#define COAP_SIGNALING_CSM COAP_SIGNALING_CODE(701) -#define COAP_SIGNALING_PING COAP_SIGNALING_CODE(702) -#define COAP_SIGNALING_PONG COAP_SIGNALING_CODE(703) -#define COAP_SIGNALING_RELEASE COAP_SIGNALING_CODE(704) -#define COAP_SIGNALING_ABORT COAP_SIGNALING_CODE(705) - -/* Applies to COAP_SIGNALING_CSM */ -#define COAP_SIGNALING_OPTION_MAX_MESSAGE_SIZE 2 -#define COAP_SIGNALING_OPTION_BLOCK_WISE_TRANSFER 4 -/* Applies to COAP_SIGNALING_PING / COAP_SIGNALING_PONG */ -#define COAP_SIGNALING_OPTION_CUSTODY 2 -/* Applies to COAP_SIGNALING_RELEASE */ -#define COAP_SIGNALING_OPTION_ALTERNATIVE_ADDRESS 2 -#define COAP_SIGNALING_OPTION_HOLD_OFF 4 -/* Applies to COAP_SIGNALING_ABORT */ -#define COAP_SIGNALING_OPTION_BAD_CSM_OPTION 2 - -/* CoAP media type encoding */ - -#define COAP_MEDIATYPE_TEXT_PLAIN 0 /* text/plain (UTF-8) */ -#define COAP_MEDIATYPE_APPLICATION_LINK_FORMAT 40 /* application/link-format */ -#define COAP_MEDIATYPE_APPLICATION_XML 41 /* application/xml */ -#define COAP_MEDIATYPE_APPLICATION_OCTET_STREAM 42 /* application/octet-stream */ -#define COAP_MEDIATYPE_APPLICATION_RDF_XML 43 /* application/rdf+xml */ -#define COAP_MEDIATYPE_APPLICATION_EXI 47 /* application/exi */ -#define COAP_MEDIATYPE_APPLICATION_JSON 50 /* application/json */ -#define COAP_MEDIATYPE_APPLICATION_CBOR 60 /* application/cbor */ - -/* Content formats from RFC 8152 */ -#define COAP_MEDIATYPE_APPLICATION_COSE_SIGN 98 /* application/cose; cose-type="cose-sign" */ -#define COAP_MEDIATYPE_APPLICATION_COSE_SIGN1 18 /* application/cose; cose-type="cose-sign1" */ -#define COAP_MEDIATYPE_APPLICATION_COSE_ENCRYPT 96 /* application/cose; cose-type="cose-encrypt" */ -#define COAP_MEDIATYPE_APPLICATION_COSE_ENCRYPT0 16 /* application/cose; cose-type="cose-encrypt0" */ -#define COAP_MEDIATYPE_APPLICATION_COSE_MAC 97 /* application/cose; cose-type="cose-mac" */ -#define COAP_MEDIATYPE_APPLICATION_COSE_MAC0 17 /* application/cose; cose-type="cose-mac0" */ - -#define COAP_MEDIATYPE_APPLICATION_COSE_KEY 101 /* application/cose-key */ -#define COAP_MEDIATYPE_APPLICATION_COSE_KEY_SET 102 /* application/cose-key-set */ - -/* Content formats from RFC 8428 */ -#define COAP_MEDIATYPE_APPLICATION_SENML_JSON 110 /* application/senml+json */ -#define COAP_MEDIATYPE_APPLICATION_SENSML_JSON 111 /* application/sensml+json */ -#define COAP_MEDIATYPE_APPLICATION_SENML_CBOR 112 /* application/senml+cbor */ -#define COAP_MEDIATYPE_APPLICATION_SENSML_CBOR 113 /* application/sensml+cbor */ -#define COAP_MEDIATYPE_APPLICATION_SENML_EXI 114 /* application/senml-exi */ -#define COAP_MEDIATYPE_APPLICATION_SENSML_EXI 115 /* application/sensml-exi */ -#define COAP_MEDIATYPE_APPLICATION_SENML_XML 310 /* application/senml+xml */ -#define COAP_MEDIATYPE_APPLICATION_SENSML_XML 311 /* application/sensml+xml */ - -/* Note that identifiers for registered media types are in the range 0-65535. We - * use an unallocated type here and hope for the best. */ -#define COAP_MEDIATYPE_ANY 0xff /* any media type */ - -/** - * coap_tid_t is used to store CoAP transaction id, i.e. a hash value - * built from the remote transport address and the message id of a - * CoAP PDU. Valid transaction ids are greater or equal zero. - */ -typedef int coap_tid_t; - -/** Indicates an invalid transaction id. */ -#define COAP_INVALID_TID -1 - -/** - * Indicates that a response is suppressed. This will occur for error - * responses if the request was received via IP multicast. - */ -#define COAP_DROPPED_RESPONSE -2 - -#define COAP_PDU_DELAYED -3 - -#define COAP_OPT_LONG 0x0F /* OC == 0b1111 indicates that the option list - * in a CoAP message is limited by 0b11110000 - * marker */ - -#define COAP_OPT_END 0xF0 /* end marker */ - -#define COAP_PAYLOAD_START 0xFF /* payload marker */ - -/** - * @deprecated Use coap_optlist_t instead. - * - * Structures for more convenient handling of options. (To be used with ordered - * coap_list_t.) The option's data will be added to the end of the coap_option - * structure (see macro COAP_OPTION_DATA). - */ -COAP_DEPRECATED typedef struct { - uint16_t key; /* the option key (no delta coding) */ - unsigned int length; -} coap_option; - -#define COAP_OPTION_KEY(option) (option).key -#define COAP_OPTION_LENGTH(option) (option).length -#define COAP_OPTION_DATA(option) ((unsigned char *)&(option) + sizeof(coap_option)) - -/** - * structure for CoAP PDUs - * token, if any, follows the fixed size header, then options until - * payload marker (0xff), then the payload if stored inline. - * Memory layout is: - * <---header--->|<---token---><---options--->0xff<---payload---> - * header is addressed with a negative offset to token, its maximum size is - * max_hdr_size. - * options starts at token + token_length - * payload starts at data, its length is used_size - (data - token) - */ - -typedef struct coap_pdu_t { - uint8_t type; /**< message type */ - uint8_t code; /**< request method (value 1--10) or response code (value 40-255) */ - uint8_t max_hdr_size; /**< space reserved for protocol-specific header */ - uint8_t hdr_size; /**< actaul size used for protocol-specific header */ - uint8_t token_length; /**< length of Token */ - uint16_t tid; /**< transaction id, if any, in regular host byte order */ - uint16_t max_delta; /**< highest option number */ - size_t alloc_size; /**< allocated storage for token, options and payload */ - size_t used_size; /**< used bytes of storage for token, options and payload */ - size_t max_size; /**< maximum size for token, options and payload, or zero for variable size pdu */ - uint8_t *token; /**< first byte of token, if any, or options */ - uint8_t *data; /**< first byte of payload, if any */ -#ifdef WITH_LWIP - struct pbuf *pbuf; /**< lwIP PBUF. The package data will always reside - * inside the pbuf's payload, but this pointer - * has to be kept because no exact offset can be - * given. This field must not be accessed from - * outside, because the pbuf's reference count - * is checked to be 1 when the pbuf is assigned - * to the pdu, and the pbuf stays exclusive to - * this pdu. */ -#endif -} coap_pdu_t; - -#define COAP_PDU_IS_EMPTY(pdu) ((pdu)->code == 0) -#define COAP_PDU_IS_REQUEST(pdu) (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32) -#define COAP_PDU_IS_RESPONSE(pdu) ((pdu)->code >= 64 && (pdu)->code < 224) -#define COAP_PDU_IS_SIGNALING(pdu) ((pdu)->code >= 224) - -#define COAP_PDU_MAX_UDP_HEADER_SIZE 4 -#define COAP_PDU_MAX_TCP_HEADER_SIZE 6 - -#ifdef WITH_LWIP -/** - * Creates a CoAP PDU from an lwIP @p pbuf, whose reference is passed on to this - * function. - * - * The pbuf is checked for being contiguous, and for having only one reference. - * The reference is stored in the PDU and will be freed when the PDU is freed. - * - * (For now, these are fatal errors; in future, a new pbuf might be allocated, - * the data copied and the passed pbuf freed). - * - * This behaves like coap_pdu_init(0, 0, 0, pbuf->tot_len), and afterwards - * copying the contents of the pbuf to the pdu. - * - * @return A pointer to the new PDU object or @c NULL on error. - */ -coap_pdu_t * coap_pdu_from_pbuf(struct pbuf *pbuf); -#endif - -typedef uint8_t coap_proto_t; -/** -* coap_proto_t values -*/ -#define COAP_PROTO_NONE 0 -#define COAP_PROTO_UDP 1 -#define COAP_PROTO_DTLS 2 -#define COAP_PROTO_TCP 3 -#define COAP_PROTO_TLS 4 - -/** - * Creates a new CoAP PDU with at least enough storage space for the given - * @p size maximum message size. The function returns a pointer to the - * node coap_pdu_t object on success, or @c NULL on error. The storage allocated - * for the result must be released with coap_delete_pdu() if coap_send() is not - * called. - * - * @param type The type of the PDU (one of COAP_MESSAGE_CON, COAP_MESSAGE_NON, - * COAP_MESSAGE_ACK, COAP_MESSAGE_RST). - * @param code The message code. - * @param tid The transcation id to set or 0 if unknown / not applicable. - * @param size The maximum allowed number of byte for the message. - * @return A pointer to the new PDU object or @c NULL on error. - */ -coap_pdu_t * -coap_pdu_init(uint8_t type, uint8_t code, uint16_t tid, size_t size); - -/** - * Dynamically grows the size of @p pdu to @p new_size. The new size - * must not exceed the PDU's configure maximum size. On success, this - * function returns 1, otherwise 0. - * - * @param pdu The PDU to resize. - * @param new_size The new size in bytes. - * @return 1 if the operation succeeded, 0 otherwise. - */ -int coap_pdu_resize(coap_pdu_t *pdu, size_t new_size); - -/** - * Clears any contents from @p pdu and resets @c used_size, - * and @c data pointers. @c max_size is set to @p size, any - * other field is set to @c 0. Note that @p pdu must be a valid - * pointer to a coap_pdu_t object created e.g. by coap_pdu_init(). - */ -void coap_pdu_clear(coap_pdu_t *pdu, size_t size); - -/** - * Creates a new CoAP PDU. - */ -coap_pdu_t *coap_new_pdu(const struct coap_session_t *session); - -/** - * Dispose of an CoAP PDU and frees associated storage. - * Not that in general you should not call this function directly. - * When a PDU is sent with coap_send(), coap_delete_pdu() will be - * called automatically for you. - */ - -void coap_delete_pdu(coap_pdu_t *); - -/** -* Interprets @p data to determine the number of bytes in the header. -* This function returns @c 0 on error or a number greater than zero on success. -* -* @param proto Session's protocol -* @param data The first byte of raw data to parse as CoAP PDU. -* -* @return A value greater than zero on success or @c 0 on error. -*/ -size_t coap_pdu_parse_header_size(coap_proto_t proto, - const uint8_t *data); - -/** - * Parses @p data to extract the message size. - * @p length must be at least coap_pdu_parse_header_size(proto, data). - * This function returns @c 0 on error or a number greater than zero on success. - * - * @param proto Session's protocol - * @param data The raw data to parse as CoAP PDU. - * @param length The actual size of @p data. - * - * @return A value greater than zero on success or @c 0 on error. - */ -size_t coap_pdu_parse_size(coap_proto_t proto, - const uint8_t *data, - size_t length); - -/** - * Decode the protocol specific header for the specified PDU. - * @param pdu A newly received PDU. - * @param proto The target wire protocol. - * @return 1 for success or 0 on error. - */ - -int coap_pdu_parse_header(coap_pdu_t *pdu, coap_proto_t proto); - -/** - * Verify consistency in the given CoAP PDU structure and locate the data. - * This function returns @c 0 on error or a number greater than zero on - * success. - * This function only parses the token and options, up to the payload start - * marker. - * - * @param pdu The PDU structure to. - * - * @return 1 on success or @c 0 on error. - */ -int coap_pdu_parse_opt(coap_pdu_t *pdu); - -/** -* Parses @p data into the CoAP PDU structure given in @p result. -* The target pdu must be large enough to -* This function returns @c 0 on error or a number greater than zero on success. -* -* @param proto Session's protocol -* @param data The raw data to parse as CoAP PDU. -* @param length The actual size of @p data. -* @param pdu The PDU structure to fill. Note that the structure must -* provide space to hold at least the token and options -* part of the message. -* -* @return 1 on success or @c 0 on error. -*/ -int coap_pdu_parse(coap_proto_t proto, - const uint8_t *data, - size_t length, - coap_pdu_t *pdu); -/** - * Adds token of length @p len to @p pdu. - * Adding the token destroys any following contents of the pdu. Hence options - * and data must be added after coap_add_token() has been called. In @p pdu, - * length is set to @p len + @c 4, and max_delta is set to @c 0. This function - * returns @c 0 on error or a value greater than zero on success. - * - * @param pdu The PDU where the token is to be added. - * @param len The length of the new token. - * @param data The token to add. - * - * @return A value greater than zero on success, or @c 0 on error. - */ -int coap_add_token(coap_pdu_t *pdu, - size_t len, - const uint8_t *data); - -/** - * Adds option of given type to pdu that is passed as first - * parameter. - * coap_add_option() destroys the PDU's data, so coap_add_data() must be called - * after all options have been added. As coap_add_token() destroys the options - * following the token, the token must be added before coap_add_option() is - * called. This function returns the number of bytes written or @c 0 on error. - */ -size_t coap_add_option(coap_pdu_t *pdu, - uint16_t type, - size_t len, - const uint8_t *data); - -/** - * Adds option of given type to pdu that is passed as first parameter, but does - * not write a value. It works like coap_add_option with respect to calling - * sequence (i.e. after token and before data). This function returns a memory - * address to which the option data has to be written before the PDU can be - * sent, or @c NULL on error. - */ -uint8_t *coap_add_option_later(coap_pdu_t *pdu, - uint16_t type, - size_t len); - -/** - * Adds given data to the pdu that is passed as first parameter. Note that the - * PDU's data is destroyed by coap_add_option(). coap_add_data() must be called - * only once per PDU, otherwise the result is undefined. - */ -int coap_add_data(coap_pdu_t *pdu, - size_t len, - const uint8_t *data); - -/** - * Adds given data to the pdu that is passed as first parameter but does not - * copyt it. Note that the PDU's data is destroyed by coap_add_option(). - * coap_add_data() must be have been called once for this PDU, otherwise the - * result is undefined. - * The actual data must be copied at the returned location. - */ -uint8_t *coap_add_data_after(coap_pdu_t *pdu, size_t len); - -/** - * Retrieves the length and data pointer of specified PDU. Returns 0 on error or - * 1 if *len and *data have correct values. Note that these values are destroyed - * with the pdu. - */ -int coap_get_data(const coap_pdu_t *pdu, - size_t *len, - uint8_t **data); - -/** - * Compose the protocol specific header for the specified PDU. - * @param pdu A newly composed PDU. - * @param proto The target wire protocol. - * @return Number of header bytes prepended before pdu->token or 0 on error. - */ - -size_t coap_pdu_encode_header(coap_pdu_t *pdu, coap_proto_t proto); - -#endif /* COAP_PDU_H_ */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/prng.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/prng.h deleted file mode 100644 index c9510bf5602..00000000000 --- a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/prng.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * prng.h -- Pseudo Random Numbers - * - * Copyright (C) 2010-2011 Olaf Bergmann - * - * This file is part of the CoAP library libcoap. Please see README for terms - * of use. - */ - -/** - * @file prng.h - * @brief Pseudo Random Numbers - */ - -#ifndef COAP_PRNG_H_ -#define COAP_PRNG_H_ - -/** - * @defgroup prng Pseudo Random Numbers - * API functions for gerating pseudo random numbers - * @{ - */ - -#if defined(WITH_CONTIKI) -#include - -/** - * Fills \p buf with \p len random bytes. This is the default implementation for - * prng(). You might want to change prng() to use a better PRNG on your specific - * platform. - */ -COAP_STATIC_INLINE int -contiki_prng_impl(unsigned char *buf, size_t len) { - uint16_t v = random_rand(); - while (len > sizeof(v)) { - memcpy(buf, &v, sizeof(v)); - len -= sizeof(v); - buf += sizeof(v); - v = random_rand(); - } - - memcpy(buf, &v, len); - return 1; -} - -#define prng(Buf,Length) contiki_prng_impl((Buf), (Length)) -#define prng_init(Value) random_init((uint16_t)(Value)) -#elif defined(WITH_LWIP) && defined(LWIP_RAND) -COAP_STATIC_INLINE int -lwip_prng_impl(unsigned char *buf, size_t len) { - u32_t v = LWIP_RAND(); - while (len > sizeof(v)) { - memcpy(buf, &v, sizeof(v)); - len -= sizeof(v); - buf += sizeof(v); - v = LWIP_RAND(); - } - - memcpy(buf, &v, len); - return 1; -} - -#define prng(Buf,Length) lwip_prng_impl((Buf), (Length)) -#define prng_init(Value) -#elif defined(_WIN32) -#define prng_init(Value) -errno_t __cdecl rand_s( _Out_ unsigned int* _RandomValue ); - /** - * Fills \p buf with \p len random bytes. This is the default implementation for - * prng(). You might want to change prng() to use a better PRNG on your specific - * platform. - */ -COAP_STATIC_INLINE int -coap_prng_impl( unsigned char *buf, size_t len ) { - while ( len != 0 ) { - uint32_t r = 0; - size_t i; - if ( rand_s( &r ) != 0 ) - return 0; - for ( i = 0; i < len && i < 4; i++ ) { - *buf++ = (uint8_t)r; - r >>= 8; - } - len -= i; - } - return 1; -} - -#else -#include - - /** - * Fills \p buf with \p len random bytes. This is the default implementation for - * prng(). You might want to change prng() to use a better PRNG on your specific - * platform. - */ -COAP_STATIC_INLINE int -coap_prng_impl( unsigned char *buf, size_t len ) { - while ( len-- ) - *buf++ = rand() & 0xFF; - return 1; -} -#endif - - -#ifndef prng -/** - * Fills \p Buf with \p Length bytes of random data. - * - * @hideinitializer - */ -#define prng(Buf,Length) coap_prng_impl((Buf), (Length)) -#endif - -#ifndef prng_init -/** - * Called to set the PRNG seed. You may want to re-define this to allow for a - * better PRNG. - * - * @hideinitializer - */ -#define prng_init(Value) srand((unsigned long)(Value)) -#endif - -/** @} */ - -#endif /* COAP_PRNG_H_ */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/str.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/str.h deleted file mode 100644 index 6c1488c982d..00000000000 --- a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/str.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - * str.h -- strings to be used in the CoAP library - * - * Copyright (C) 2010-2011 Olaf Bergmann - * - * This file is part of the CoAP library libcoap. Please see README for terms - * of use. - */ - -#ifndef COAP_STR_H_ -#define COAP_STR_H_ - -#include - - -/** - * @defgroup string String handling support - * API functions for handling strings - * @{ - */ - -/** - * Coap string data definition - */ -typedef struct coap_string_t { - size_t length; /**< length of string */ - uint8_t *s; /**< string data */ -} coap_string_t; - -/** - * Coap string data definition with const data - */ -typedef struct coap_str_const_t { - size_t length; /**< length of string */ - const uint8_t *s; /**< string data */ -} coap_str_const_t; - -#define COAP_SET_STR(st,l,v) { (st)->length = (l), (st)->s = (v); } - -/** - * Coap binary data definition - */ -typedef struct coap_binary_t { - size_t length; /**< length of binary data */ - uint8_t *s; /**< binary data */ -} coap_binary_t; - -/** - * Returns a new string object with at least size+1 bytes storage allocated. - * The string must be released using coap_delete_string(). - * - * @param size The size to allocate for the binary string data. - * - * @return A pointer to the new object or @c NULL on error. - */ -coap_string_t *coap_new_string(size_t size); - -/** - * Deletes the given string and releases any memory allocated. - * - * @param string The string to free off. - */ -void coap_delete_string(coap_string_t *string); - -/** - * Returns a new const string object with at least size+1 bytes storage - * allocated, and the provided data copied into the string object. - * The string must be released using coap_delete_str_const(). - * - * @param data The data to put in the new string object. - * @param size The size to allocate for the binary string data. - * - * @return A pointer to the new object or @c NULL on error. - */ -coap_str_const_t *coap_new_str_const(const uint8_t *data, size_t size); - -/** - * Deletes the given const string and releases any memory allocated. - * - * @param string The string to free off. - */ -void coap_delete_str_const(coap_str_const_t *string); - -/** - * Take the specified byte array (text) and create a coap_str_const_t * - * - * WARNING: The byte array must be in the local scope and not a - * parameter in the function call as sizeof() will return the size of the - * pointer, not the size of the byte array, leading to unxepected results. - * - * @param string The const byte array to convert to a coap_str_const_t * - */ -#ifdef __cplusplus -namespace libcoap { - struct CoAPStrConst : coap_str_const_t { - operator coap_str_const_t *() { return this; } - }; -} -#define coap_make_str_const(CStr) \ - libcoap::CoAPStrConst{sizeof(CStr)-1, reinterpret_cast(CStr)} -#else /* __cplusplus */ -#define coap_make_str_const(string) \ - (&(coap_str_const_t){sizeof(string)-1,(const uint8_t *)(string)}) -#endif /* __cplusplus */ - -/** - * Compares the two strings for equality - * - * @param string1 The first string. - * @param string2 The second string. - * - * @return @c 1 if the strings are equal - * @c 0 otherwise. - */ -#define coap_string_equal(string1,string2) \ - ((string1)->length == (string2)->length && ((string1)->length == 0 || \ - memcmp((string1)->s, (string2)->s, (string1)->length) == 0)) - -/** @} */ - -#endif /* COAP_STR_H_ */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/subscribe.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/subscribe.h deleted file mode 100644 index ed635a6182a..00000000000 --- a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/subscribe.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * subscribe.h -- subscription handling for CoAP - * see RFC7641 - * - * Copyright (C) 2010-2012,2014-2015 Olaf Bergmann - * - * This file is part of the CoAP library libcoap. Please see README for terms - * of use. - */ - - -#ifndef COAP_SUBSCRIBE_H_ -#define COAP_SUBSCRIBE_H_ - -#include "address.h" -#include "coap_io.h" -#include "block.h" - -/** - * @defgroup observe Resource observation - * API functions for interfacing with the observe handling (RFC7641) - * @{ - */ - -/** - * The value COAP_OBSERVE_ESTABLISH in a GET request indicates a new observe - * relationship for (sender address, token) is requested. - */ -#define COAP_OBSERVE_ESTABLISH 0 - -/** - * The value COAP_OBSERVE_CANCEL in a GET request indicates that the observe - * relationship for (sender address, token) must be cancelled. - */ -#define COAP_OBSERVE_CANCEL 1 - -#ifndef COAP_OBS_MAX_NON -/** - * Number of notifications that may be sent non-confirmable before a confirmable - * message is sent to detect if observers are alive. The maximum allowed value - * here is @c 15. - */ -#define COAP_OBS_MAX_NON 5 -#endif /* COAP_OBS_MAX_NON */ - -#ifndef COAP_OBS_MAX_FAIL -/** - * Number of confirmable notifications that may fail (i.e. time out without - * being ACKed) before an observer is removed. The maximum value for - * COAP_OBS_MAX_FAIL is @c 3. - */ -#define COAP_OBS_MAX_FAIL 3 -#endif /* COAP_OBS_MAX_FAIL */ - -/** Subscriber information */ -typedef struct coap_subscription_t { - struct coap_subscription_t *next; /**< next element in linked list */ - coap_session_t *session; /**< subscriber session */ - - unsigned int non_cnt:4; /**< up to 15 non-confirmable notifies allowed */ - unsigned int fail_cnt:2; /**< up to 3 confirmable notifies can fail */ - unsigned int dirty:1; /**< set if the notification temporarily could not be - * sent (in that case, the resource's partially - * dirty flag is set too) */ - unsigned int has_block2:1; /**< GET request had Block2 definition */ - uint16_t tid; /**< transaction id, if any, in regular host byte order */ - coap_block_t block2; /**< GET request Block2 definition */ - size_t token_length; /**< actual length of token */ - unsigned char token[8]; /**< token used for subscription */ - coap_string_t *query; /**< query string used for subscription, if any */ -} coap_subscription_t; - -void coap_subscription_init(coap_subscription_t *); - -/** @} */ - -#endif /* COAP_SUBSCRIBE_H_ */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/address.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/address.h similarity index 81% rename from tools/sdk/esp32s2/include/coap/libcoap/include/coap2/address.h rename to tools/sdk/esp32c3/include/coap/libcoap/include/coap3/address.h index a51236d5a60..8b8d9a24fae 100644 --- a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/address.h +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/address.h @@ -3,6 +3,8 @@ * * Copyright (C) 2010-2011,2015-2016 Olaf Bergmann * + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ @@ -30,6 +32,22 @@ typedef struct coap_address_t { ip_addr_t addr; } coap_address_t; +/** + * Returns the port from @p addr in host byte order. + */ +COAP_STATIC_INLINE uint16_t +coap_address_get_port(const coap_address_t *addr) { + return ntohs(addr->port); +} + +/** + * Sets the port field of @p addr to @p port (in host byte order). + */ +COAP_STATIC_INLINE void +coap_address_set_port(coap_address_t *addr, uint16_t port) { + addr->port = htons(port); +} + #define _coap_address_equals_impl(A, B) \ ((A)->port == (B)->port \ && (!!ip_addr_cmp(&(A)->addr,&(B)->addr))) @@ -47,6 +65,22 @@ typedef struct coap_address_t { uint16_t port; } coap_address_t; +/** + * Returns the port from @p addr in host byte order. + */ +COAP_STATIC_INLINE uint16_t +coap_address_get_port(const coap_address_t *addr) { + return uip_ntohs(addr->port); +} + +/** + * Sets the port field of @p addr to @p port (in host byte order). + */ +COAP_STATIC_INLINE void +coap_address_set_port(coap_address_t *addr, uint16_t port) { + addr->port = uip_htons(port); +} + #define _coap_address_equals_impl(A,B) \ ((A)->port == (B)->port \ && uip_ipaddr_cmp(&((A)->addr),&((B)->addr))) @@ -68,6 +102,16 @@ typedef struct coap_address_t { } addr; } coap_address_t; +/** + * Returns the port from @p addr in host byte order. + */ +uint16_t coap_address_get_port(const coap_address_t *addr); + +/** + * Set the port field of @p addr to @p port (in host byte order). + */ +void coap_address_set_port(coap_address_t *addr, uint16_t port); + /** * Compares given address objects @p a and @p b. This function returns @c 1 if * addresses are equal, @c 0 otherwise. The parameters @p a and @p b must not be @@ -100,15 +144,7 @@ _coap_address_isany_impl(const coap_address_t *a) { * * @param addr The coap_address_t object to initialize. */ -COAP_STATIC_INLINE void -coap_address_init(coap_address_t *addr) { - assert(addr); - memset(addr, 0, sizeof(coap_address_t)); -#if !defined(WITH_LWIP) && !defined(WITH_CONTIKI) - /* lwip and Contiki have constant address sizes and doesn't need the .size part */ - addr->size = sizeof(addr->addr); -#endif -} +void coap_address_init(coap_address_t *addr); /* Convenience function to copy IPv6 addresses without garbage. */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/async.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/async.h new file mode 100644 index 00000000000..a61e0c09828 --- /dev/null +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/async.h @@ -0,0 +1,116 @@ +/* + * async.h -- state management for asynchronous messages + * + * Copyright (C) 2010-2011 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file async.h + * @brief State management for asynchronous messages + */ + +#ifndef COAP_ASYNC_H_ +#define COAP_ASYNC_H_ + +#include "net.h" + +/** + * @defgroup coap_async Asynchronous Messaging + * @{ + * API functions for Async "separate" messages. + * A coap_context_t object holds a list of coap_async_t objects that can + * be used to generate a separate response in the case a result of a request + * cannot be delivered immediately. + */ + +/** + * Returns @c 1 if libcoap was built with separate messages enabled, + * @c 0 otherwise. + */ +int coap_async_is_supported(void); + +/** + * Allocates a new coap_async_t object and fills its fields according to + * the given @p request. This function returns a pointer to the registered + * coap_async_t object or @c NULL on error. Note that this function will + * return @c NULL in case that an object with the same identifier is already + * registered. + * + * When the delay expires, a copy of the @p request will get sent to the + * appropriate request handler. + * + * @param session The session that is used for asynchronous transmissions. + * @param request The request that is handled asynchronously. + * @param delay The amount of time to delay before sending response, 0 means + * wait forever. + * + * @return A pointer to the registered coap_async_t object or @c + * NULL in case of an error. + */ +coap_async_t * +coap_register_async(coap_session_t *session, + const coap_pdu_t *request, + coap_tick_t delay); + +/** + * Update the delay timeout, so changing when the registered @p async triggers. + * + * When the new delay expires, a copy of the original request will get sent to + * the appropriate request handler. + * + * @param async The object to update. + * @param delay The amount of time to delay before sending response, 0 means + * wait forever. + */ +void +coap_async_set_delay(coap_async_t *async, coap_tick_t delay); + +/** + * Releases the memory that was allocated by coap_register_async() for the + * object @p async. + * + * @param session The session to use. + * @param async The object to delete. + */ +void +coap_free_async(coap_session_t *session, coap_async_t *async); + +/** + * Retrieves the object identified by @p token from the list of asynchronous + * transactions that are registered with @p context. This function returns a + * pointer to that object or @c NULL if not found. + * + * @param session The session that is used for asynchronous transmissions. + * @param token The PDU's token of the object to retrieve. + * + * @return A pointer to the object identified by @p token or @c NULL if + * not found. + */ +coap_async_t *coap_find_async(coap_session_t *session, coap_bin_const_t token); + +/** + * Set the application data pointer held in @p async. This overwrites any + * existing data pointer. + * + * @param async The async state object. + * @param app_data The pointer to the data. + */ +void coap_async_set_app_data(coap_async_t *async, void *app_data); + +/** + * Gets the application data pointer held in @p async. + * + * @param async The async state object. + * + * @return The applicaton data pointer. + */ +void *coap_async_get_app_data(const coap_async_t *async); + +/** @} */ + +#endif /* COAP_ASYNC_H_ */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/block.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/block.h new file mode 100644 index 00000000000..a2aac00fdc6 --- /dev/null +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/block.h @@ -0,0 +1,348 @@ +/* + * block.h -- block transfer + * + * Copyright (C) 2010-2012,2014-2015 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +#ifndef COAP_BLOCK_H_ +#define COAP_BLOCK_H_ + +#include "encode.h" +#include "option.h" +#include "pdu.h" + +/** + * @defgroup block Block Transfer + * API functions for handling PDUs using CoAP BLOCK options + * @{ + */ + +#ifndef COAP_MAX_BLOCK_SZX +/** + * The largest value for the SZX component in a Block option. + */ +#define COAP_MAX_BLOCK_SZX 6 +#endif /* COAP_MAX_BLOCK_SZX */ + +/** + * Structure of Block options. + */ +typedef struct { + unsigned int num; /**< block number */ + unsigned int m:1; /**< 1 if more blocks follow, 0 otherwise */ + unsigned int szx:3; /**< block size */ +} coap_block_t; + +#define COAP_BLOCK_USE_LIBCOAP 0x01 /* Use libcoap to do block requests */ +#define COAP_BLOCK_SINGLE_BODY 0x02 /* Deliver the data as a single body */ + +/** + * Returns the value of the least significant byte of a Block option @p opt. + * For zero-length options (i.e. num == m == szx == 0), COAP_OPT_BLOCK_LAST + * returns @c NULL. + */ +#define COAP_OPT_BLOCK_LAST(opt) \ + (coap_opt_length(opt) ? (coap_opt_value(opt) + (coap_opt_length(opt)-1)) : 0) + +/** Returns the value of the More-bit of a Block option @p opt. */ +#define COAP_OPT_BLOCK_MORE(opt) \ + (coap_opt_length(opt) ? (*COAP_OPT_BLOCK_LAST(opt) & 0x08) : 0) + +/** Returns the value of the SZX-field of a Block option @p opt. */ +#define COAP_OPT_BLOCK_SZX(opt) \ + (coap_opt_length(opt) ? (*COAP_OPT_BLOCK_LAST(opt) & 0x07) : 0) + +/** + * Returns the value of field @c num in the given block option @p block_opt. + */ +unsigned int coap_opt_block_num(const coap_opt_t *block_opt); + +/** + * Checks if more than @p num blocks are required to deliver @p data_len + * bytes of data for a block size of 1 << (@p szx + 4). + */ +COAP_STATIC_INLINE int +coap_more_blocks(size_t data_len, unsigned int num, uint16_t szx) { + return ((num+1) << (szx + 4)) < data_len; +} + +#if 0 +/** Sets the More-bit in @p block_opt */ +COAP_STATIC_INLINE void +coap_opt_block_set_m(coap_opt_t *block_opt, int m) { + if (m) + *(coap_opt_value(block_opt) + (coap_opt_length(block_opt) - 1)) |= 0x08; + else + *(coap_opt_value(block_opt) + (coap_opt_length(block_opt) - 1)) &= ~0x08; +} +#endif + +/** + * Initializes @p block from @p pdu. @p number must be either COAP_OPTION_BLOCK1 + * or COAP_OPTION_BLOCK2. When option @p number was found in @p pdu, @p block is + * initialized with values from this option and the function returns the value + * @c 1. Otherwise, @c 0 is returned. + * + * @param pdu The pdu to search for option @p number. + * @param number The option number to search for (must be COAP_OPTION_BLOCK1 or + * COAP_OPTION_BLOCK2). + * @param block The block structure to initilize. + * + * @return @c 1 on success, @c 0 otherwise. + */ +int coap_get_block(const coap_pdu_t *pdu, coap_option_num_t number, + coap_block_t *block); + +/** + * Writes a block option of type @p number to message @p pdu. If the requested + * block size is too large to fit in @p pdu, it is reduced accordingly. An + * exception is made for the final block when less space is required. The actual + * length of the resource is specified in @p data_length. + * + * This function may change *block to reflect the values written to @p pdu. As + * the function takes into consideration the remaining space @p pdu, no more + * options should be added after coap_write_block_opt() has returned. + * + * @param block The block structure to use. On return, this object is + * updated according to the values that have been written to + * @p pdu. + * @param number COAP_OPTION_BLOCK1 or COAP_OPTION_BLOCK2. + * @param pdu The message where the block option should be written. + * @param data_length The length of the actual data that will be added the @p + * pdu by calling coap_add_block(). + * + * @return @c 1 on success, or a negative value on error. + */ +int coap_write_block_opt(coap_block_t *block, + coap_option_num_t number, + coap_pdu_t *pdu, + size_t data_length); + +/** + * Adds the @p block_num block of size 1 << (@p block_szx + 4) from source @p + * data to @p pdu. + * + * @param pdu The message to add the block. + * @param len The length of @p data. + * @param data The source data to fill the block with. + * @param block_num The actual block number. + * @param block_szx Encoded size of block @p block_number. + * + * @return @c 1 on success, @c 0 otherwise. + */ +int coap_add_block(coap_pdu_t *pdu, + size_t len, + const uint8_t *data, + unsigned int block_num, + unsigned char block_szx); + +/** + * Re-assemble payloads into a body + * + * @param body_data The pointer to the data for the body holding the + * representation so far or NULL if the first time. + * @param length The length of @p data. + * @param data The payload data to update the body with. + * @param offset The offset of the @p data into the body. + * @param total The estimated total size of the body. + * + * @return The current representation of the body or @c NULL if error. + * If NULL, @p body_data will have been de-allocated. + */ +coap_binary_t * +coap_block_build_body(coap_binary_t *body_data, size_t length, + const uint8_t *data, size_t offset, size_t total); + +/** + * Adds the appropriate part of @p data to the @p response pdu. If blocks are + * required, then the appropriate block will be added to the PDU and sent. + * Adds a ETAG option that is the hash of the entire data if the data is to be + * split into blocks + * Used by a request handler. + * + * Note: The application will get called for every packet of a large body to + * process. Consider using coap_add_data_response_large() instead. + * + * @param request The requesting pdu. + * @param response The response pdu. + * @param media_type The format of the data. + * @param maxage The maxmimum life of the data. If @c -1, then there + * is no maxage. + * @param length The total length of the data. + * @param data The entire data block to transmit. + * + */ +void +coap_add_data_blocked_response(const coap_pdu_t *request, + coap_pdu_t *response, + uint16_t media_type, + int maxage, + size_t length, + const uint8_t* data); + +/** + * Callback handler for de-allocating the data based on @p app_ptr provided to + * coap_add_data_large_*() functions following transmission of the supplied + * data. + * + * @param session The session that this data is associated with + * @param app_ptr The application provided pointer provided to the + * coap_add_data_large_* functions. + */ +typedef void (*coap_release_large_data_t)(coap_session_t *session, + void *app_ptr); + +/** + * Associates given data with the @p pdu that is passed as second parameter. + * + * If all the data can be transmitted in a single PDU, this is functionally + * the same as coap_add_data() except @p release_func (if not NULL) will get + * invoked after data transmission. + * + * Used for a client request. + * + * If the data spans multiple PDUs, then the data will get transmitted using + * BLOCK1 option with the addition of the SIZE1 option. + * The underlying library will handle the transmission of the individual blocks. + * Once the body of data has been transmitted (or a failure occurred), then + * @p release_func (if not NULL) will get called so the application can + * de-allocate the @p data based on @p app_data. It is the responsibility of + * the application not to change the contents of @p data until the data + * transfer has completed. + * + * There is no need for the application to include the BLOCK1 option in the + * @p pdu. + * + * coap_add_data_large_request() (or the alternative coap_add_data_large_*() + * functions) must be called only once per PDU and must be the last PDU update + * before the PDU is transmitted. The (potentially) initial data will get + * transmitted when coap_send() is invoked. + * + * Note: COAP_BLOCK_USE_LIBCOAP must be set by coap_context_set_block_mode() + * for libcoap to work correctly when using this function. + * + * @param session The session to associate the data with. + * @param pdu The PDU to associate the data with. + * @param length The length of data to transmit. + * @param data The data to transmit. + * @param release_func The function to call to de-allocate @p data or @c NULL + * if the function is not required. + * @param app_ptr A Pointer that the application can provide for when + * release_func() is called. + * + * @return @c 1 if addition is successful, else @c 0. + */ +int coap_add_data_large_request(coap_session_t *session, + coap_pdu_t *pdu, + size_t length, + const uint8_t *data, + coap_release_large_data_t release_func, + void *app_ptr); + +/** + * Associates given data with the @p response pdu that is passed as fourth + * parameter. + * + * If all the data can be transmitted in a single PDU, this is functionally + * the same as coap_add_data() except @p release_func (if not NULL) will get + * invoked after data transmission. The MEDIA_TYPE, MAXAGE and ETAG options may + * be added in as appropriate. + * + * Used by a server request handler to create the response. + * + * If the data spans multiple PDUs, then the data will get transmitted using + * BLOCK2 (response) option with the addition of the SIZE2 and ETAG + * options. The underlying library will handle the transmission of the + * individual blocks. Once the body of data has been transmitted (or a + * failure occurred), then @p release_func (if not NULL) will get called so the + * application can de-allocate the @p data based on @p app_data. It is the + * responsibility of the application not to change the contents of @p data + * until the data transfer has completed. + * + * There is no need for the application to include the BLOCK2 option in the + * @p pdu. + * + * coap_add_data_large_response() (or the alternative coap_add_data_large*() + * functions) must be called only once per PDU and must be the last PDU update + * before returning from the request handler function. + * + * Note: COAP_BLOCK_USE_LIBCOAP must be set by coap_context_set_block_mode() + * for libcoap to work correctly when using this function. + * + * @param resource The resource the data is associated with. + * @param session The coap session. + * @param request The requesting pdu. + * @param response The response pdu. + * @param query The query taken from the (original) requesting pdu. + * @param media_type The format of the data. + * @param maxage The maxmimum life of the data. If @c -1, then there + * is no maxage. + * @param etag ETag to use if not 0. + * @param length The total length of the data. + * @param data The entire data block to transmit. + * @param release_func The function to call to de-allocate @p data or NULL if + * the function is not required. + * @param app_ptr A Pointer that the application can provide for when + * release_func() is called. + * + * @return @c 1 if addition is successful, else @c 0. + */ +int +coap_add_data_large_response(coap_resource_t *resource, + coap_session_t *session, + const coap_pdu_t *request, + coap_pdu_t *response, + const coap_string_t *query, + uint16_t media_type, + int maxage, + uint64_t etag, + size_t length, + const uint8_t *data, + coap_release_large_data_t release_func, + void *app_ptr); + +/** + * Set the context level CoAP block handling bits for handling RFC7959. + * These bits flow down to a session when a session is created and if the peer + * does not support something, an appropriate bit may get disabled in the + * session block_mode. + * The session block_mode then flows down into coap_crcv_t or coap_srcv_t where + * again an appropriate bit may get disabled. + * + * Note: This function must be called before the session is set up. + * + * Note: COAP_BLOCK_USE_LIBCOAP must be set if libcoap is to do all the + * block tracking and requesting, otherwise the application will have to do + * all of this work (the default if coap_context_set_block_mode() is not + * called). + * + * @param context The coap_context_t object. + * @param block_mode Zero or more COAP_BLOCK_ or'd options + */ +void coap_context_set_block_mode(coap_context_t *context, + uint8_t block_mode); + +/** + * Cancel an observe that is being tracked by the client large receive logic. + * (coap_context_set_block_mode() has to be called) + * This will trigger the sending of an observe cancel pdu to the server. + * + * @param session The session that is being used for the observe. + * @param token The original token used to initiate the observation. + * @param message_type The COAP_MESSAGE_ type (NON or CON) to send the observe + * cancel pdu as. + * + * @return @c 1 if observe cancel transmission initiation is successful, + * else @c 0. + */ +int coap_cancel_observe(coap_session_t *session, coap_binary_t *token, + coap_pdu_type_t message_type); + +/**@}*/ + +#endif /* COAP_BLOCK_H_ */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_asn1_internal.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_asn1_internal.h new file mode 100644 index 00000000000..5bb4e2a8dbe --- /dev/null +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_asn1_internal.h @@ -0,0 +1,89 @@ +/* + * coap_asn1_internal.h -- ASN.1 functions for libcoap + * + * Copyright (C) 2020 Jon Shallow + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_asn1_internal.h + * @brief COAP ASN.1 internal information + */ + +#ifndef COAP_ASN1_INTERNAL_H_ +#define COAP_ASN1_INTERNAL_H_ + + +/** + * @defgroup asn1 ASN.1 Support (Internal) + * CoAP ASN.1 Structures, Enums and Functions that are not exposed to + * applications + * @{ + */ + +typedef enum { + COAP_ASN1_NONE = 0, + COAP_ASN1_INTEGER = 2, + COAP_ASN1_BITSTRING = 3, + COAP_ASN1_OCTETSTRING = 4, + COAP_ASN1_IDENTIFIER = 6, +} coap_asn1_tag_t; + +/** + * Callback to validate the asn1 tag and data. + * + * Internal function. + * + * @param data The start of the tag and data + * @param size The size of the tag and data + * + * @return @c 1 if pass, else @c 0 if fail + */ +typedef int (*asn1_validate)(const uint8_t *data, size_t size); + +/** + * Get the asn1 length from the current @p ptr. + * + * Internal function. + * + * @param ptr The current asn.1 object length pointer + * + * @return The length of the asn.1 object. @p ptr is updated to be after the length. + */ +size_t asn1_len(const uint8_t **ptr); + +/** + * Get the asn1 tag from the current @p ptr. + * + * Internal function. + * + * @param ptr The current asn.1 object tag pointer + * @param constructed 1 if current tag is constructed + * @param class The current class of the tag + * + * @return The tag value.@p ptr is updated to be after the tag. + */ +coap_asn1_tag_t asn1_tag_c(const uint8_t **ptr, int *constructed, int *class); + +/** + * Get the asn1 tag and data from the current @p ptr. + * + * Internal function. + * + * @param ltag The tag to look for + * @param ptr The current asn.1 object pointer + * @param tlen The remaining size oof the asn.1 data + * @param validate Call validate to verify tag data or @c NULL + * + * @return The asn.1 tag and data or @c NULL if not found + */ +coap_binary_t *get_asn1_tag(coap_asn1_tag_t ltag, const uint8_t *ptr, + size_t tlen, asn1_validate validate); + +/** @} */ + +#endif /* COAP_ASN1_INTERNAL_H_ */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_async_internal.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_async_internal.h new file mode 100644 index 00000000000..a23b1c8e697 --- /dev/null +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_async_internal.h @@ -0,0 +1,67 @@ +/* + * coap_async_internal.h -- state management for asynchronous messages + * + * Copyright (C) 2010-2021 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_async_internal.h + * @brief CoAP async internal information + */ + +#ifndef COAP_ASYNC_INTERNAL_H_ +#define COAP_ASYNC_INTERNAL_H_ + +#include "coap3/net.h" + +#ifndef WITHOUT_ASYNC + +/** + * @defgroup coap_async_internal Asynchronous Messaging (Internal) + * @{ + * CoAP Async Structures, Enums and Functions that are not exposed to + * applications. + * A coap_context_t object holds a list of coap_async_t objects that can be + * used to generate a separate response in the case a result of a request cannot + * be delivered immediately. + */ +struct coap_async_t { + struct coap_async_t *next; /**< internally used for linking */ + coap_tick_t delay; /**< When to delay to before triggering the response + 0 indicates never trigger */ + coap_session_t *session; /**< transaction session */ + coap_pdu_t *pdu; /**< copy of request pdu */ + void* appdata; /** User definable data pointer */ +}; + +/** + * Checks if there are any pending Async requests - if so, send them off. + * Otherewise return the time remaining for the next Async to be triggered + * or 0 if nothing to do. + * + * @param context The current context. + * @param now The current time in ticks. + * + * @return The tick time before the next Async needs to go, else 0 if + * nothing to do. + */ +coap_tick_t coap_check_async(coap_context_t *context, coap_tick_t now); + +/** + * Removes and frees off all of the async entries for the given context. + * + * @param context The context to remove all async entries from. + */ +void +coap_delete_all_async(coap_context_t *context); + +/** @} */ + +#endif /* WITHOUT_ASYNC */ + +#endif /* COAP_ASYNC_INTERNAL_H_ */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_block_internal.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_block_internal.h new file mode 100644 index 00000000000..9abe81557fa --- /dev/null +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_block_internal.h @@ -0,0 +1,239 @@ +/* + * coap_block_internal.h -- Structures, Enums & Functions that are not + * exposed to application programming + * + * Copyright (C) 2010-2021 Olaf Bergmann + * Copyright (C) 2021 Jon Shallow + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_block_internal.h + * @brief COAP block internal information + */ + +#ifndef COAP_BLOCK_INTERNAL_H_ +#define COAP_BLOCK_INTERNAL_H_ + +#include "coap_pdu_internal.h" +#include "resource.h" + +/** + * @defgroup block_internal Block (Internal) + * Structures, Enums and Functions that are not exposed to applications + * @{ + */ + +typedef enum { + COAP_RECURSE_OK, + COAP_RECURSE_NO +} coap_recurse_t; + +struct coap_lg_range { + uint32_t begin; + uint32_t end; +}; + +#define COAP_RBLOCK_CNT 4 +/** + * Structure to keep track of received blocks + */ +typedef struct coap_rblock_t { + uint32_t used; + uint32_t retry; + struct coap_lg_range range[COAP_RBLOCK_CNT]; + coap_tick_t last_seen; +} coap_rblock_t; + +/** + * Structure to keep track of block1 specific information + * (Requests) + */ +typedef struct coap_l_block1_t { + coap_binary_t *app_token; /**< original PDU token */ + uint8_t token[8]; /**< last used token */ + size_t token_length; /**< length of token */ + uint32_t count; /**< the number of packets sent for payload */ +} coap_l_block1_t; + +/** + * Structure to keep track of block2 specific information + * (Responses) + */ +typedef struct coap_l_block2_t { + coap_resource_t *resource; /**< associated resource */ + coap_string_t *query; /**< Associated query for the resource */ + uint64_t etag; /**< ETag value */ + coap_time_t maxage_expire; /**< When this entry expires */ +} coap_l_block2_t; + +/** + * Structure to hold large body (many blocks) transmission information + */ +struct coap_lg_xmit_t { + struct coap_lg_xmit_t *next; + uint8_t blk_size; /**< large block transmission size */ + uint16_t option; /**< large block transmisson CoAP option */ + int last_block; /**< last acknowledged block number */ + const uint8_t *data; /**< large data ptr */ + size_t length; /**< large data length */ + size_t offset; /**< large data next offset to transmit */ + union { + coap_l_block1_t b1; + coap_l_block2_t b2; + } b; + coap_pdu_t pdu; /**< skeletal PDU */ + coap_tick_t last_payload; /**< Last time MAX_PAYLOAD was sent or 0 */ + coap_tick_t last_used; /**< Last time all data sent or 0 */ + coap_release_large_data_t release_func; /**< large data de-alloc function */ + void *app_ptr; /**< applicaton provided ptr for de-alloc function */ +}; + +/** + * Structure to hold large body (many blocks) client receive information + */ +struct coap_lg_crcv_t { + struct coap_lg_crcv_t *next; + uint8_t observe[3]; /**< Observe data (if set) (only 24 bits) */ + uint8_t observe_length;/**< Length of observe data */ + uint8_t observe_set; /**< Set if this is an observe receive PDU */ + uint8_t etag_set; /**< Set if ETag is in receive PDU */ + uint8_t etag_length; /**< ETag length */ + uint8_t etag[8]; /**< ETag for block checking */ + uint16_t content_format; /**< Content format for the set of blocks */ + uint8_t last_type; /**< Last request type (CON/NON) */ + uint8_t initial; /**< If set, has not been used yet */ + uint8_t szx; /**< size of individual blocks */ + size_t total_len; /**< Length as indicated by SIZE2 option */ + coap_binary_t *body_data; /**< Used for re-assembling entire body */ + coap_binary_t *app_token; /**< app requesting PDU token */ + uint8_t base_token[8]; /**< established base PDU token */ + size_t base_token_length; /**< length of token */ + uint8_t token[8]; /**< last used token */ + size_t token_length; /**< length of token */ + coap_pdu_t pdu; /**< skeletal PDU */ + coap_rblock_t rec_blocks; /** < list of received blocks */ + coap_tick_t last_used; /**< Last time all data sent or 0 */ + uint16_t block_option; /**< Block option in use */ +}; + +/** + * Structure to hold large body (many blocks) server receive information + */ +struct coap_lg_srcv_t { + struct coap_lg_srcv_t *next; + uint8_t observe[3]; /**< Observe data (if set) (only 24 bits) */ + uint8_t observe_length;/**< Length of observe data */ + uint8_t observe_set; /**< Set if this is an observe receive PDU */ + uint8_t rtag_set; /**< Set if RTag is in receive PDU */ + uint8_t rtag_length; /**< RTag length */ + uint8_t rtag[8]; /**< RTag for block checking */ + uint16_t content_format; /**< Content format for the set of blocks */ + uint8_t last_type; /**< Last request type (CON/NON) */ + uint8_t szx; /**< size of individual blocks */ + size_t total_len; /**< Length as indicated by SIZE1 option */ + coap_binary_t *body_data; /**< Used for re-assembling entire body */ + size_t amount_so_far; /**< Amount of data seen so far */ + coap_resource_t *resource; /**< associated resource */ + coap_str_const_t *uri_path; /** set to uri_path if unknown resource */ + coap_rblock_t rec_blocks; /** < list of received blocks */ + uint8_t last_token[8]; /**< last used token */ + size_t last_token_length; /**< length of token */ + coap_mid_t last_mid; /**< Last received mid for this set of packets */ + coap_tick_t last_used; /**< Last time data sent or 0 */ + uint16_t block_option; /**< Block option in use */ +}; + +coap_lg_crcv_t * coap_block_new_lg_crcv(coap_session_t *session, + coap_pdu_t *pdu); + +void coap_block_delete_lg_crcv(coap_session_t *session, + coap_lg_crcv_t *lg_crcv); + +coap_tick_t coap_block_check_lg_crcv_timeouts(coap_session_t *session, + coap_tick_t now); + +void coap_block_delete_lg_srcv(coap_session_t *session, + coap_lg_srcv_t *lg_srcv); + +coap_tick_t coap_block_check_lg_srcv_timeouts(coap_session_t *session, + coap_tick_t now); + +int coap_handle_request_send_block(coap_session_t *session, + coap_pdu_t *pdu, + coap_pdu_t *response, + coap_resource_t *resource, + coap_string_t *query); + +int coap_handle_request_put_block(coap_context_t *context, + coap_session_t *session, + coap_pdu_t *pdu, + coap_pdu_t *response, + coap_resource_t *resource, + coap_string_t *uri_path, + coap_opt_t *observe, + coap_string_t *query, + coap_method_handler_t h, + int *added_block); + +int coap_handle_response_send_block(coap_session_t *session, coap_pdu_t *rcvd); + +int coap_handle_response_get_block(coap_context_t *context, + coap_session_t *session, + coap_pdu_t *sent, + coap_pdu_t *rcvd, + coap_recurse_t recursive); + +void coap_block_delete_lg_xmit(coap_session_t *session, + coap_lg_xmit_t *lg_xmit); + +/** + * The function that does all the work for the coap_add_data_large*() + * functions. + * + * @param session The session to associate the data with. + * @param pdu The PDU to associate the data with. + * @param resource The resource to associate the data with (BLOCK2). + * @param query The query to associate the data with (BLOCK2). + * @param maxage The maxmimum life of the data. If @c -1, then there + * is no maxage (BLOCK2). + * @param etag ETag to use if not 0 (BLOCK2). + * @param length The length of data to transmit. + * @param data The data to transmit. + * @param release_func The function to call to de-allocate @p data or NULL if + * the function is not required. + * @param app_ptr A Pointer that the application can provide for when + * release_func() is called. + * + * @return @c 1 if transmission initiation is successful, else @c 0. + */ +int coap_add_data_large_internal(coap_session_t *session, + coap_pdu_t *pdu, + coap_resource_t *resource, + const coap_string_t *query, + int maxage, + uint64_t etag, + size_t length, + const uint8_t *data, + coap_release_large_data_t release_func, + void *app_ptr); + +/** + * The function checks that the code in a newly formed lg_xmit created by + * coap_add_data_large_response() is updated. + * + * @param session The session + * @param response The response PDU to to check + * @param resource The requested resource + * @param query The requested query + */ +void coap_check_code_lg_xmit(coap_session_t *session, coap_pdu_t *response, + coap_resource_t *resource, coap_string_t *query); + +/** @} */ + +#endif /* COAP_BLOCK_INTERNAL_H_ */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_cache.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_cache.h new file mode 100644 index 00000000000..a8d2fd7a84e --- /dev/null +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_cache.h @@ -0,0 +1,232 @@ +/* coap_cache.h -- Caching of CoAP requests +* +* Copyright (C) 2020 Olaf Bergmann +* + * SPDX-License-Identifier: BSD-2-Clause + * +* This file is part of the CoAP library libcoap. Please see +* README for terms of use. +*/ + +/** + * @file coap_cache.h + * @brief Provides a simple cache request storage for CoAP requests + */ + +#ifndef COAP_CACHE_H_ +#define COAP_CACHE_H_ + +#include "coap_forward_decls.h" + +/** + * @defgroup cache Cache Support + * API functions for CoAP Caching + * @{ + */ + +/** + * Callback to free off the app data when the cache-entry is + * being deleted / freed off. + * + * @param data The app data to be freed off. + */ +typedef void (*coap_cache_app_data_free_callback_t)(void *data); + +typedef enum coap_cache_session_based_t { + COAP_CACHE_NOT_SESSION_BASED, + COAP_CACHE_IS_SESSION_BASED +} coap_cache_session_based_t; + +typedef enum coap_cache_record_pdu_t { + COAP_CACHE_NOT_RECORD_PDU, + COAP_CACHE_RECORD_PDU +} coap_cache_record_pdu_t; + +/** + * Calculates a cache-key for the given CoAP PDU. See + * https://tools.ietf.org/html/rfc7252#section-5.6 + * for an explanation of CoAP cache keys. + * + * Specific CoAP options can be removed from the cache-key. Examples of + * this are the BLOCK1 and BLOCK2 options - which make no real sense including + * them in a client or server environment, but should be included in a proxy + * caching environment where things are cached on a per block basis. + * This is done globally by calling the coap_cache_ignore_options() + * function. + * + * NOTE: The returned cache-key needs to be freed off by the caller by + * calling coap_cache_delete_key(). + * + * @param session The session to add into cache-key if @p session_based + * is set. + * @param pdu The CoAP PDU for which a cache-key is to be + * calculated. + * @param session_based COAP_CACHE_IS_SESSION_BASED if session based + * cache-key, else COAP_CACHE_NOT_SESSION_BASED. + * + * @return The returned cache-key or @c NULL if failure. + */ +coap_cache_key_t *coap_cache_derive_key(const coap_session_t *session, + const coap_pdu_t *pdu, + coap_cache_session_based_t session_based); + +/** + * Calculates a cache-key for the given CoAP PDU. See + * https://tools.ietf.org/html/rfc7252#section-5.6 + * for an explanation of CoAP cache keys. + * + * Specific CoAP options can be removed from the cache-key. Examples of + * this are the BLOCK1 and BLOCK2 options - which make no real sense including + * them in a client or server environment, but should be included in a proxy + * caching environment where things are cached on a per block basis. + * This is done individually by specifying @p cache_ignore_count and + * @p cache_ignore_options . + * + * NOTE: The returned cache-key needs to be freed off by the caller by + * calling coap_cache_delete_key(). + * + * @param session The session to add into cache-key if @p session_based + * is set. + * @param pdu The CoAP PDU for which a cache-key is to be + * calculated. + * @param session_based COAP_CACHE_IS_SESSION_BASED if session based + * cache-key, else COAP_CACHE_NOT_SESSION_BASED. + * @param ignore_options The array of options to ignore. + * @param ignore_count The number of options to ignore. + * + * @return The returned cache-key or @c NULL if failure. + */ +coap_cache_key_t *coap_cache_derive_key_w_ignore(const coap_session_t *session, + const coap_pdu_t *pdu, + coap_cache_session_based_t session_based, + const uint16_t *ignore_options, + size_t ignore_count); + +/** + * Delete the cache-key. + * + * @param cache_key The cache-key to delete. + */ +void coap_delete_cache_key(coap_cache_key_t *cache_key); + +/** + * Define the CoAP options that are not to be included when calculating + * the cache-key. Options that are defined as Non-Cache and the Observe + * option are always ignored. + * + * @param context The context to save the ignored options information in. + * @param options The array of options to ignore. + * @param count The number of options to ignore. Use 0 to reset the + * options matching. + * + * @return @return @c 1 if successful, else @c 0. + */ +int coap_cache_ignore_options(coap_context_t *context, + const uint16_t *options, size_t count); + +/** + * Create a new cache-entry hash keyed by cache-key derived from the PDU. + * + * If @p session_based is set, then this cache-entry will get deleted when + * the session is freed off. + * If @p record_pdu is set, then the copied PDU will get freed off when + * this cache-entry is deleted. + * + * The cache-entry is maintained on a context hash list. + * + * @param session The session to use to derive the context from. + * @param pdu The pdu to use to generate the cache-key. + * @param record_pdu COAP_CACHE_RECORD_PDU if to take a copy of the PDU for + * later use, else COAP_CACHE_NOT_RECORD_PDU. + * @param session_based COAP_CACHE_IS_SESSION_BASED if to associate this + * cache-entry with the the session (which is embedded + * in the cache-entry), else COAP_CACHE_NOT_SESSION_BASED. + * @param idle_time Idle time in seconds before cache-entry is expired. + * If set to 0, it does not expire (but will get + * deleted if the session is deleted and it is session_based). + * + * @return The returned cache-key or @c NULL if failure. + */ +coap_cache_entry_t *coap_new_cache_entry(coap_session_t *session, + const coap_pdu_t *pdu, + coap_cache_record_pdu_t record_pdu, + coap_cache_session_based_t session_based, + unsigned int idle_time); + +/** + * Remove a cache-entry from the hash list and free off all the appropriate + * contents apart from app_data. + * + * @param context The context to use. + * @param cache_entry The cache-entry to remove. + */ +void coap_delete_cache_entry(coap_context_t *context, + coap_cache_entry_t *cache_entry); + +/** + * Searches for a cache-entry identified by @p cache_key. This + * function returns the corresponding cache-entry or @c NULL + * if not found. + * + * @param context The context to use. + * @param cache_key The cache-key to get the hashed coap-entry. + * + * @return The cache-entry for @p cache_key or @c NULL if not found. + */ +coap_cache_entry_t *coap_cache_get_by_key(coap_context_t *context, + const coap_cache_key_t *cache_key); + +/** + * Searches for a cache-entry corresponding to @p pdu. This + * function returns the corresponding cache-entry or @c NULL if not + * found. + * + * @param session The session to use. + * @param pdu The CoAP request to search for. + * @param session_based COAP_CACHE_IS_SESSION_BASED if session based + * cache-key to be used, else COAP_CACHE_NOT_SESSION_BASED. + * + * @return The cache-entry for @p request or @c NULL if not found. + */ +coap_cache_entry_t *coap_cache_get_by_pdu(coap_session_t *session, + const coap_pdu_t *pdu, + coap_cache_session_based_t session_based); + +/** + * Returns the PDU information stored in the @p coap_cache entry. + * + * @param cache_entry The CoAP cache entry. + * + * @return The PDU information stored in the cache_entry or NULL + * if the PDU was not initially copied. + */ +const coap_pdu_t *coap_cache_get_pdu(const coap_cache_entry_t *cache_entry); + +/** + * Stores @p data with the given cache entry. This function + * overwrites any value that has previously been stored with @p + * cache_entry. + * + * @param cache_entry The CoAP cache entry. + * @param data The data pointer to store with wih the cache entry. Note that + * this data must be valid during the lifetime of @p cache_entry. + * @param callback The callback to call to free off this data when the + * cache-entry is deleted, or @c NULL if not required. + */ +void coap_cache_set_app_data(coap_cache_entry_t *cache_entry, void *data, + coap_cache_app_data_free_callback_t callback); + +/** + * Returns any application-specific data that has been stored with @p + * cache_entry using the function coap_cache_set_app_data(). This function will + * return @c NULL if no data has been stored. + * + * @param cache_entry The CoAP cache entry. + * + * @return The data pointer previously stored or @c NULL if no data stored. + */ +void *coap_cache_get_app_data(const coap_cache_entry_t *cache_entry); + +/** @} */ + +#endif /* COAP_CACHE_H */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_cache_internal.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_cache_internal.h new file mode 100644 index 00000000000..29c0756875c --- /dev/null +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_cache_internal.h @@ -0,0 +1,111 @@ +/* + * coap_cache_internal.h -- Cache functions for libcoap + * + * Copyright (C) 2019--2020 Olaf Bergmann and others + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_cache_internal.h + * @brief COAP cache internal information + */ + +#ifndef COAP_CACHE_INTERNAL_H_ +#define COAP_CACHE_INTERNAL_H_ + +#include "coap_io.h" + +/** + * @defgroup cache_internal Cache Support (Internal) + * CoAP Cache Structures, Enums and Functions that are not exposed to + * applications + * @{ + */ + +/* Holds a digest in binary typically sha256 except for notls */ +typedef struct coap_digest_t { + uint8_t key[32]; +} coap_digest_t; + +struct coap_cache_key_t { + uint8_t key[32]; +}; + +struct coap_cache_entry_t { + UT_hash_handle hh; + coap_cache_key_t *cache_key; + coap_session_t *session; + coap_pdu_t *pdu; + void* app_data; + coap_tick_t expire_ticks; + unsigned int idle_timeout; + coap_cache_app_data_free_callback_t callback; +}; + +/** + * Expire coap_cache_entry_t entries + * + * Internal function. + * + * @param context The context holding the coap-entries to exire + */ +void coap_expire_cache_entries(coap_context_t *context); + +typedef void coap_digest_ctx_t; + +/** + * Initialize a coap_digest + * + * Internal function. + * + * @return The digest context or @c NULL if failure. + */ +coap_digest_ctx_t *coap_digest_setup(void); + +/** + * Free off coap_digest_ctx_t. Always done by + * coap_digest_final() + * + * Internal function. + * + * @param digest_ctx The coap_digest context. + */ +void coap_digest_free(coap_digest_ctx_t *digest_ctx); + +/** + * Update the coap_digest information with the next chunk of data + * + * Internal function. + * + * @param digest_ctx The coap_digest context. + * @param data Pointer to data. + * @param data_len Number of bytes. + * + * @return @c 1 success, @c 0 failure. + */ +int coap_digest_update(coap_digest_ctx_t *digest_ctx, + const uint8_t *data, + size_t data_len + ); + +/** + * Finalize the coap_digest information into the provided + * @p digest_buffer. + * + * Internal function. + * + * @param digest_ctx The coap_digest context. + * @param digest_buffer Pointer to digest buffer to update + * + * @return @c 1 success, @c 0 failure. + */ +int coap_digest_final(coap_digest_ctx_t *digest_ctx, + coap_digest_t *digest_buffer); + +/** @} */ + +#endif /* COAP_CACHE_INTERNAL_H_ */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/coap_debug.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_debug.h similarity index 78% rename from tools/sdk/esp32c3/include/coap/libcoap/include/coap2/coap_debug.h rename to tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_debug.h index e4631b71f2b..f8f70f64495 100644 --- a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/coap_debug.h +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_debug.h @@ -3,6 +3,8 @@ * * Copyright (C) 2010-2011,2014 Olaf Bergmann * + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ @@ -36,8 +38,16 @@ * Logging type. One of LOG_* from @b syslog. */ typedef short coap_log_t; -#else -/** Pre-defined log levels akin to what is used in \b syslog. */ +/* + LOG_DEBUG+2 gives ciphers in GnuTLS + Use COAP_LOG_CIPHERS to output Cipher Info in OpenSSL etc. + */ +#define COAP_LOG_CIPHERS (LOG_DEBUG+2) +#else /* !HAVE_SYSLOG_H */ +/** Pre-defined log levels akin to what is used in \b syslog + with LOG_CIPHERS added. */ + +#if !defined(RIOT_VERSION) typedef enum { LOG_EMERG=0, /**< Emergency */ LOG_ALERT, /**< Alert */ @@ -46,9 +56,29 @@ typedef enum { LOG_WARNING, /**< Warning */ LOG_NOTICE, /**< Notice */ LOG_INFO, /**< Information */ - LOG_DEBUG /**< Debug */ + LOG_DEBUG, /**< Debug */ + COAP_LOG_CIPHERS=LOG_DEBUG+2 /**< CipherInfo */ } coap_log_t; -#endif +#else /* RIOT_VERSION */ +/* RIOT defines a subset of the syslog levels in log.h with different + * numeric values. The remaining levels are defined here. Note that + * output granularity differs from what would be expected when + * adhering to the syslog levels. + */ +#include +typedef short coap_log_t; +#define LOG_EMERG (0) +#define LOG_ALERT (1) +#define LOG_CRIT (2) +#define LOG_ERR (3) +/* LOG_WARNING (4) */ +#define LOG_NOTICE (5) +/* LOG_INFO (6) */ +/* LOG_DEBUG (7) */ +#define COAP_LOG_CIPHERS (9) +#endif /* RIOT_VERSION */ + +#endif /* !HAVE_SYSLOG_H */ /** * Get the current logging level. @@ -65,7 +95,7 @@ coap_log_t coap_get_log_level(void); void coap_set_log_level(coap_log_t level); /** - * Logging call-back handler definition. + * Logging callback handler definition. * * @param level One of the LOG_* values. * @param message Zero-terminated string message to log. @@ -163,7 +193,15 @@ void coap_show_tls_version(coap_log_t level); */ char *coap_string_tls_version(char *buffer, size_t bufsize); -struct coap_address_t; +/** + * Build a string containing the current (D)TLS library support + * + * @param buffer The buffer to put the string into. + * @param bufsize The size of the buffer to put the string into. + * + * @return A pointer to the provided buffer. + */ +char *coap_string_tls_support(char *buffer, size_t bufsize); /** * Print the address into the defined buffer. @@ -176,7 +214,7 @@ struct coap_address_t; * * @return The amount written into the buffer. */ -size_t coap_print_addr(const struct coap_address_t *address, +size_t coap_print_addr(const coap_address_t *address, unsigned char *buffer, size_t size); /** @} */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_dtls.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_dtls.h new file mode 100644 index 00000000000..cbd369dfce6 --- /dev/null +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_dtls.h @@ -0,0 +1,479 @@ +/* + * coap_dtls.h -- (Datagram) Transport Layer Support for libcoap + * + * Copyright (C) 2016 Olaf Bergmann + * Copyright (C) 2017 Jean-Claude Michelou + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +#ifndef COAP_DTLS_H_ +#define COAP_DTLS_H_ + +#include "coap_time.h" +#include "str.h" + +/** + * @defgroup dtls DTLS Support + * API functions for interfacing with DTLS libraries. + * @{ + */ + +typedef struct coap_dtls_pki_t coap_dtls_pki_t; + +#ifndef COAP_DTLS_HINT_LENGTH +#define COAP_DTLS_HINT_LENGTH 128 +#endif + +typedef enum coap_dtls_role_t { + COAP_DTLS_ROLE_CLIENT, /**< Internal function invoked for client */ + COAP_DTLS_ROLE_SERVER /**< Internal function invoked for server */ +} coap_dtls_role_t; + +#define COAP_DTLS_RPK_CERT_CN "RPK" + +/** + * Check whether DTLS is available. + * + * @return @c 1 if support for DTLS is enabled, or @c 0 otherwise. + */ +int coap_dtls_is_supported(void); + +/** + * Check whether TLS is available. + * + * @return @c 1 if support for TLS is enabled, or @c 0 otherwise. + */ +int coap_tls_is_supported(void); + +typedef enum coap_tls_library_t { + COAP_TLS_LIBRARY_NOTLS = 0, /**< No DTLS library */ + COAP_TLS_LIBRARY_TINYDTLS, /**< Using TinyDTLS library */ + COAP_TLS_LIBRARY_OPENSSL, /**< Using OpenSSL library */ + COAP_TLS_LIBRARY_GNUTLS, /**< Using GnuTLS library */ + COAP_TLS_LIBRARY_MBEDTLS, /**< Using Mbed TLS library */ +} coap_tls_library_t; + +/** + * The structure used for returning the underlying (D)TLS library + * information. + */ +typedef struct coap_tls_version_t { + uint64_t version; /**< (D)TLS runtime Library Version */ + coap_tls_library_t type; /**< Library type. One of COAP_TLS_LIBRARY_* */ + uint64_t built_version; /**< (D)TLS Built against Library Version */ +} coap_tls_version_t; + +/** + * Determine the type and version of the underlying (D)TLS library. + * + * @return The version and type of library libcoap was compiled against. + */ +coap_tls_version_t *coap_get_tls_library_version(void); + +/** + * Additional Security setup handler that can be set up by + * coap_context_set_pki(). + * Invoked when libcoap has done the validation checks at the TLS level, + * but the application needs to do some additional checks/changes/updates. + * + * @param tls_session The security session definition - e.g. SSL * for OpenSSL. + * NULL if server callback. + * This will be dependent on the underlying TLS library - + * see coap_get_tls_library_version() + * @param setup_data A structure containing setup data originally passed into + * coap_context_set_pki() or coap_new_client_session_pki(). + * + * @return @c 1 if successful, else @c 0. + */ +typedef int (*coap_dtls_security_setup_t)(void* tls_session, + coap_dtls_pki_t *setup_data); + +/** + * CN Validation callback that can be set up by coap_context_set_pki(). + * Invoked when libcoap has done the validation checks at the TLS level, + * but the application needs to check that the CN is allowed. + * CN is the SubjectAltName in the cert, if not present, then the leftmost + * Common Name (CN) component of the subject name. + * NOTE: If using RPK, then the Public Key does not contain a CN, but the + * content of COAP_DTLS_RPK_CERT_CN is presented for the @p cn parameter. + * + * @param cn The determined CN from the certificate + * @param asn1_public_cert The ASN.1 DER encoded X.509 certificate + * @param asn1_length The ASN.1 length + * @param coap_session The CoAP session associated with the certificate update + * @param depth Depth in cert chain. If 0, then client cert, else a CA + * @param validated TLS layer can find no issues if 1 + * @param arg The same as was passed into coap_context_set_pki() + * in setup_data->cn_call_back_arg + * + * @return @c 1 if accepted, else @c 0 if to be rejected. + */ +typedef int (*coap_dtls_cn_callback_t)(const char *cn, + const uint8_t *asn1_public_cert, + size_t asn1_length, + coap_session_t *coap_session, + unsigned int depth, + int validated, + void *arg); + +/** + * The enum used for determining the provided PKI ASN.1 (DER) Private Key + * formats. + */ +typedef enum coap_asn1_privatekey_type_t { + COAP_ASN1_PKEY_NONE, /**< NONE */ + COAP_ASN1_PKEY_RSA, /**< RSA type */ + COAP_ASN1_PKEY_RSA2, /**< RSA2 type */ + COAP_ASN1_PKEY_DSA, /**< DSA type */ + COAP_ASN1_PKEY_DSA1, /**< DSA1 type */ + COAP_ASN1_PKEY_DSA2, /**< DSA2 type */ + COAP_ASN1_PKEY_DSA3, /**< DSA3 type */ + COAP_ASN1_PKEY_DSA4, /**< DSA4 type */ + COAP_ASN1_PKEY_DH, /**< DH type */ + COAP_ASN1_PKEY_DHX, /**< DHX type */ + COAP_ASN1_PKEY_EC, /**< EC type */ + COAP_ASN1_PKEY_HMAC, /**< HMAC type */ + COAP_ASN1_PKEY_CMAC, /**< CMAC type */ + COAP_ASN1_PKEY_TLS1_PRF, /**< TLS1_PRF type */ + COAP_ASN1_PKEY_HKDF /**< HKDF type */ +} coap_asn1_privatekey_type_t; + +/** + * The enum used for determining the PKI key formats. + */ +typedef enum coap_pki_key_t { + COAP_PKI_KEY_PEM = 0, /**< The PKI key type is PEM file */ + COAP_PKI_KEY_ASN1, /**< The PKI key type is ASN.1 (DER) buffer */ + COAP_PKI_KEY_PEM_BUF, /**< The PKI key type is PEM buffer */ + COAP_PKI_KEY_PKCS11, /**< The PKI key type is PKCS11 (DER) */ +} coap_pki_key_t; + +/** + * The structure that holds the PKI PEM definitions. + */ +typedef struct coap_pki_key_pem_t { + const char *ca_file; /**< File location of Common CA in PEM format */ + const char *public_cert; /**< File location of Public Cert */ + const char *private_key; /**< File location of Private Key in PEM format */ +} coap_pki_key_pem_t; + +/** + * The structure that holds the PKI PEM buffer definitions. + * The certificates and private key data must be in PEM format. + * + * Note: The Certs and Key should be NULL terminated strings for + * performance reasons (to save a potential buffer copy) and the length include + * this NULL terminator. It is not a requirement to have the NULL terminator + * though and the length must then reflect the actual data size. + */ +typedef struct coap_pki_key_pem_buf_t { + const uint8_t *ca_cert; /**< PEM buffer Common CA Cert */ + const uint8_t *public_cert; /**< PEM buffer Public Cert, or Public Key if RPK */ + const uint8_t *private_key; /**< PEM buffer Private Key + If RPK and 'EC PRIVATE KEY' this can be used + for both the public_cert and private_key */ + size_t ca_cert_len; /**< PEM buffer CA Cert length */ + size_t public_cert_len; /**< PEM buffer Public Cert length */ + size_t private_key_len; /**< PEM buffer Private Key length */ +} coap_pki_key_pem_buf_t; + +/** + * The structure that holds the PKI ASN.1 (DER) definitions. + */ +typedef struct coap_pki_key_asn1_t { + const uint8_t *ca_cert; /**< ASN1 (DER) Common CA Cert */ + const uint8_t *public_cert; /**< ASN1 (DER) Public Cert, or Public Key if RPK */ + const uint8_t *private_key; /**< ASN1 (DER) Private Key */ + size_t ca_cert_len; /**< ASN1 CA Cert length */ + size_t public_cert_len; /**< ASN1 Public Cert length */ + size_t private_key_len; /**< ASN1 Private Key length */ + coap_asn1_privatekey_type_t private_key_type; /**< Private Key Type */ +} coap_pki_key_asn1_t; + +/** + * The structure that holds the PKI PKCS11 definitions. + */ +typedef struct coap_pki_key_pkcs11_t { + const char *ca; /**< pkcs11: URI for Common CA Certificate */ + const char *public_cert; /**< pkcs11: URI for Public Cert */ + const char *private_key; /**< pkcs11: URI for Private Key */ + const char *user_pin; /**< User pin to access PKCS11. If NULL, then + pin-value= parameter must be set in + pkcs11: URI as a query. */ +} coap_pki_key_pkcs11_t; + +/** + * The structure that holds the PKI key information. + */ +typedef struct coap_dtls_key_t { + coap_pki_key_t key_type; /**< key format type */ + union { + coap_pki_key_pem_t pem; /**< for PEM file keys */ + coap_pki_key_pem_buf_t pem_buf; /**< for PEM memory keys */ + coap_pki_key_asn1_t asn1; /**< for ASN.1 (DER) memory keys */ + coap_pki_key_pkcs11_t pkcs11; /**< for PKCS11 keys */ + } key; +} coap_dtls_key_t; + +/** + * Server Name Indication (SNI) Validation callback that can be set up by + * coap_context_set_pki(). + * Invoked if the SNI is not previously seen and prior to sending a certificate + * set back to the client so that the appropriate certificate set can be used + * based on the requesting SNI. + * + * @param sni The requested SNI + * @param arg The same as was passed into coap_context_set_pki() + * in setup_data->sni_call_back_arg + * + * @return New set of certificates to use, or @c NULL if SNI is to be rejected. + */ +typedef coap_dtls_key_t *(*coap_dtls_pki_sni_callback_t)(const char *sni, + void* arg); + + +#define COAP_DTLS_PKI_SETUP_VERSION 1 /**< Latest PKI setup version */ + +/** + * The structure used for defining the PKI setup data to be used. + */ +struct coap_dtls_pki_t { + uint8_t version; /** Set to COAP_DTLS_PKI_SETUP_VERSION + to support this version of the struct */ + + /* Options to enable different TLS functionality in libcoap */ + uint8_t verify_peer_cert; /**< 1 if peer cert is to be verified */ + uint8_t check_common_ca; /**< 1 if peer cert is to be signed by + * the same CA as the local cert */ + uint8_t allow_self_signed; /**< 1 if self-signed certs are allowed. + * Ignored if check_common_ca set */ + uint8_t allow_expired_certs; /**< 1 if expired certs are allowed */ + uint8_t cert_chain_validation; /**< 1 if to check cert_chain_verify_depth */ + uint8_t cert_chain_verify_depth; /**< recommended depth is 3 */ + uint8_t check_cert_revocation; /**< 1 if revocation checks wanted */ + uint8_t allow_no_crl; /**< 1 ignore if CRL not there */ + uint8_t allow_expired_crl; /**< 1 if expired crl is allowed */ + uint8_t allow_bad_md_hash; /**< 1 if unsupported MD hashes are allowed */ + uint8_t allow_short_rsa_length; /**< 1 if small RSA keysizes are allowed */ + uint8_t is_rpk_not_cert; /**< 1 is RPK instead of Public Certificate. + * If set, PKI key format type cannot be + * COAP_PKI_KEY_PEM */ + uint8_t reserved[3]; /**< Reserved - must be set to 0 for + future compatibility */ + /* Size of 3 chosen to align to next + * parameter, so if newly defined option + * it can use one of the reserverd slot so + * no need to change + * COAP_DTLS_PKI_SETUP_VERSION and just + * decrement the reserved[] count. + */ + + /** CN check callback function. + * If not NULL, is called when the TLS connection has passed the configured + * TLS options above for the application to verify if the CN is valid. + */ + coap_dtls_cn_callback_t validate_cn_call_back; + void *cn_call_back_arg; /**< Passed in to the CN callback function */ + + /** SNI check callback function. + * If not @p NULL, called if the SNI is not previously seen and prior to + * sending a certificate set back to the client so that the appropriate + * certificate set can be used based on the requesting SNI. + */ + coap_dtls_pki_sni_callback_t validate_sni_call_back; + void *sni_call_back_arg; /**< Passed in to the sni callback function */ + + /** Additional Security callback handler that is invoked when libcoap has + * done the standard, defined validation checks at the TLS level, + * If not @p NULL, called from within the TLS Client Hello connection + * setup. + */ + coap_dtls_security_setup_t additional_tls_setup_call_back; + + char* client_sni; /**< If not NULL, SNI to use in client TLS setup. + Owned by the client app and must remain valid + during the call to coap_new_client_session_pki() */ + + coap_dtls_key_t pki_key; /**< PKI key definition */ +}; + +/** + * The structure that holds the Client PSK information. + */ +typedef struct coap_dtls_cpsk_info_t { + coap_bin_const_t identity; + coap_bin_const_t key; +} coap_dtls_cpsk_info_t; + +/** + * Identity Hint Validation callback that can be set up by + * coap_new_client_session_psk2(). + * Invoked when libcoap has done the validation checks at the TLS level, + * but the application needs to check that the Identity Hint is allowed, + * and thus needs to use the appropriate PSK information for the Identity + * Hint for the (D)TLS session. + * Note: Identity Hint is not supported in (D)TLS1.3. + * + * @param hint The server provided Identity Hint + * @param coap_session The CoAP session associated with the Identity Hint + * @param arg The same as was passed into coap_new_client_session_psk2() + * in setup_data->ih_call_back_arg + * + * @return New coap_dtls_cpsk_info_t object or @c NULL on error. + */ +typedef const coap_dtls_cpsk_info_t *(*coap_dtls_ih_callback_t)( + coap_str_const_t *hint, + coap_session_t *coap_session, + void *arg); + +#define COAP_DTLS_CPSK_SETUP_VERSION 1 /**< Latest CPSK setup version */ + +/** + * The structure used for defining the Client PSK setup data to be used. + */ +typedef struct coap_dtls_cpsk_t { + uint8_t version; /** Set to COAP_DTLS_CPSK_SETUP_VERSION + to support this version of the struct */ + + /* Options to enable different TLS functionality in libcoap */ + uint8_t reserved[7]; /**< Reserved - must be set to 0 for + future compatibility */ + /* Size of 7 chosen to align to next + * parameter, so if newly defined option + * it can use one of the reserverd slot so + * no need to change + * COAP_DTLS_CPSK_SETUP_VERSION and just + * decrement the reserved[] count. + */ + + /** Identity Hint check callback function. + * If not NULL, is called when the Identity Hint (TLS1.2 or earlier) is + * provided by the server. + * The appropriate Identity and Pre-shared Key to use can then be returned. + */ + coap_dtls_ih_callback_t validate_ih_call_back; + void *ih_call_back_arg; /**< Passed in to the Identity Hint callback + function */ + + char* client_sni; /**< If not NULL, SNI to use in client TLS setup. + Owned by the client app and must remain valid + during the call to coap_new_client_session_psk2() + Note: Not supported by TinyDTLS. */ + + coap_dtls_cpsk_info_t psk_info; /**< Client PSK definition */ +} coap_dtls_cpsk_t; + +/** + * The structure that holds the Server Pre-Shared Key and Identity + * Hint information. + */ +typedef struct coap_dtls_spsk_info_t { + coap_bin_const_t hint; + coap_bin_const_t key; +} coap_dtls_spsk_info_t; + + +/** + * Identity Validation callback that can be set up by + * coap_context_set_psk2(). + * Invoked when libcoap has done the validation checks at the TLS level, + * but the application needs to check that the Identity is allowed, + * and needs to use the appropriate Pre-Shared Key for the (D)TLS session. + * + * @param identity The client provided Identity + * @param coap_session The CoAP session associated with the Identity Hint + * @param arg The value as passed into coap_context_set_psk2() + * in setup_data->id_call_back_arg + * + * @return New coap_bin_const_t object containing the Pre-Shared Key or + @c NULL on error. + * Note: This information will be duplicated into an internal + * structure. + */ +typedef const coap_bin_const_t *(*coap_dtls_id_callback_t)( + coap_bin_const_t *identity, + coap_session_t *coap_session, + void *arg); +/** + * PSK SNI callback that can be set up by coap_context_set_psk2(). + * Invoked when libcoap has done the validation checks at the TLS level + * and the application needs to:- + * a) check that the SNI is allowed + * b) provide the appropriate PSK information for the (D)TLS session. + * + * @param sni The client provided SNI + * @param coap_session The CoAP session associated with the SNI + * @param arg The same as was passed into coap_context_set_psk2() + * in setup_data->sni_call_back_arg + * + * @return New coap_dtls_spsk_info_t object or @c NULL on error. + */ +typedef const coap_dtls_spsk_info_t *(*coap_dtls_psk_sni_callback_t)( + const char *sni, + coap_session_t *coap_session, + void *arg); + +#define COAP_DTLS_SPSK_SETUP_VERSION 1 /**< Latest SPSK setup version */ + +/** + * The structure used for defining the Server PSK setup data to be used. + */ +typedef struct coap_dtls_spsk_t { + uint8_t version; /** Set to COAP_DTLS_SPSK_SETUP_VERSION + to support this version of the struct */ + + /* Options to enable different TLS functionality in libcoap */ + uint8_t reserved[7]; /**< Reserved - must be set to 0 for + future compatibility */ + /* Size of 7 chosen to align to next + * parameter, so if newly defined option + * it can use one of the reserverd slot so + * no need to change + * COAP_DTLS_SPSK_SETUP_VERSION and just + * decrement the reserved[] count. + */ + + /** Identity check callback function. + * If not @p NULL, is called when the Identity is provided by the client. + * The appropriate Pre-Shared Key to use can then be returned. + */ + coap_dtls_id_callback_t validate_id_call_back; + void *id_call_back_arg; /**< Passed in to the Identity callback function */ + + /** SNI check callback function. + * If not @p NULL, called if the SNI is not previously seen and prior to + * sending PSK information back to the client so that the appropriate + * PSK information can be used based on the requesting SNI. + */ + coap_dtls_psk_sni_callback_t validate_sni_call_back; + void *sni_call_back_arg; /**< Passed in to the SNI callback function */ + + coap_dtls_spsk_info_t psk_info; /**< Server PSK definition */ +} coap_dtls_spsk_t; + + +/** @} */ + +/** + * @ingroup logging + * Sets the (D)TLS logging level to the specified @p level. + * Note: coap_log_level() will influence output if at a specified level. + * + * @param level The logging level to use - LOG_* + */ +void coap_dtls_set_log_level(int level); + +/** + * @ingroup logging + * Get the current (D)TLS logging. + * + * @return The current log level (one of LOG_*). + */ +int coap_dtls_get_log_level(void); + + +#endif /* COAP_DTLS_H */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_dtls_internal.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_dtls_internal.h new file mode 100644 index 00000000000..8ea09a4eb3e --- /dev/null +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_dtls_internal.h @@ -0,0 +1,345 @@ +/* + * coap_dtls_internal.h -- (Datagram) Transport Layer Support for libcoap + * + * Copyright (C) 2016 Olaf Bergmann + * Copyright (C) 2017 Jean-Claude Michelou + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +#ifndef COAP_DTLS_INTERNAL_H_ +#define COAP_DTLS_INTERNAL_H_ + +/** + * @defgroup dtls_internal DTLS Support (Internal) + * CoAP DTLS Structures, Enums and Functions that are not exposed to + * applications + * @{ + */ + +/* https://tools.ietf.org/html/rfc6347#section-4.2.4.1 */ +#ifndef COAP_DTLS_RETRANSMIT_MS +#define COAP_DTLS_RETRANSMIT_MS 1000 +#endif +#ifndef COAP_DTLS_RETRANSMIT_TOTAL_MS +#define COAP_DTLS_RETRANSMIT_TOTAL_MS 60000 +#endif + +#define COAP_DTLS_RETRANSMIT_COAP_TICKS (COAP_DTLS_RETRANSMIT_MS * COAP_TICKS_PER_SECOND / 1000) + +/** + * Creates a new DTLS context for the given @p coap_context. This function + * returns a pointer to a new DTLS context object or @c NULL on error. + * + * @param coap_context The CoAP context where the DTLS object shall be used. + * + * @return A DTLS context object or @c NULL on error. + */ +void * +coap_dtls_new_context(coap_context_t *coap_context); + +/** + * Set the DTLS context's default server PSK information. + * This does the PSK specifics following coap_dtls_new_context(). + * + * @param coap_context The CoAP context. + * @param setup_data A structure containing setup data originally passed into + * coap_context_set_psk2(). + * + * @return @c 1 if successful, else @c 0. + */ + +int +coap_dtls_context_set_spsk(coap_context_t *coap_context, + coap_dtls_spsk_t *setup_data); + +/** + * Set the DTLS context's default client PSK information. + * This does the PSK specifics following coap_dtls_new_context(). + * + * @param coap_context The CoAP context. + * @param setup_data A structure containing setup data originally passed into + * coap_new_client_session_psk2(). + * + * @return @c 1 if successful, else @c 0. + */ + +int +coap_dtls_context_set_cpsk(coap_context_t *coap_context, + coap_dtls_cpsk_t *setup_data); + +/** + * Set the DTLS context's default server PKI information. + * This does the PKI specifics following coap_dtls_new_context(). + * If @p COAP_DTLS_ROLE_SERVER, then the information will get put into the + * TLS library's context (from which sessions are derived). + * If @p COAP_DTLS_ROLE_CLIENT, then the information will get put into the + * TLS library's session. + * + * @param coap_context The CoAP context. + * @param setup_data Setup information defining how PKI is to be setup. + * Required parameter. If @p NULL, PKI will not be + * set up. + * @param role One of @p COAP_DTLS_ROLE_CLIENT or @p COAP_DTLS_ROLE_SERVER + * + * @return @c 1 if successful, else @c 0. + */ + +int +coap_dtls_context_set_pki(coap_context_t *coap_context, + const coap_dtls_pki_t *setup_data, + const coap_dtls_role_t role); + +/** + * Set the dtls context's default Root CA information for a client or server. + * + * @param coap_context The current coap_context_t object. + * @param ca_file If not @p NULL, is the full path name of a PEM encoded + * file containing all the Root CAs to be used. + * @param ca_dir If not @p NULL, points to a directory containing PEM + * encoded files containing all the Root CAs to be used. + * + * @return @c 1 if successful, else @c 0. + */ + +int +coap_dtls_context_set_pki_root_cas(coap_context_t *coap_context, + const char *ca_file, + const char *ca_dir); + +/** + * Check whether one of the coap_dtls_context_set_{psk|pki}() functions have + * been called. + * + * @param coap_context The current coap_context_t object. + * + * @return @c 1 if coap_dtls_context_set_{psk|pki}() called, else @c 0. + */ + +int coap_dtls_context_check_keys_enabled(coap_context_t *coap_context); + +/** + * Releases the storage allocated for @p dtls_context. + * + * @param dtls_context The DTLS context as returned by coap_dtls_new_context(). + */ +void coap_dtls_free_context(void *dtls_context); + +/** + * Create a new client-side session. This should send a HELLO to the server. + * + * @param coap_session The CoAP session. + * + * @return Opaque handle to underlying TLS library object containing security + * parameters for the session. +*/ +void *coap_dtls_new_client_session(coap_session_t *coap_session); + +/** + * Create a new DTLS server-side session. + * Called after coap_dtls_hello() has returned @c 1, signalling that a validated + * HELLO was received from a client. + * This should send a HELLO to the server. + * + * @param coap_session The CoAP session. + * + * @return Opaque handle to underlying TLS library object containing security + * parameters for the DTLS session. + */ +void *coap_dtls_new_server_session(coap_session_t *coap_session); + +/** + * Terminates the DTLS session (may send an ALERT if necessary) then frees the + * underlying TLS library object containing security parameters for the session. + * + * @param coap_session The CoAP session. + */ +void coap_dtls_free_session(coap_session_t *coap_session); + +/** + * Notify of a change in the CoAP session's MTU, for example after + * a PMTU update. + * + * @param coap_session The CoAP session. + */ +void coap_dtls_session_update_mtu(coap_session_t *coap_session); + +/** + * Send data to a DTLS peer. + * + * @param coap_session The CoAP session. + * @param data pointer to data. + * @param data_len Number of bytes to send. + * + * @return @c 0 if this would be blocking, @c -1 if there is an error or the + * number of cleartext bytes sent. + */ +int coap_dtls_send(coap_session_t *coap_session, + const uint8_t *data, + size_t data_len); + +/** + * Check if timeout is handled per CoAP session or per CoAP context. + * + * @return @c 1 of timeout and retransmit is per context, @c 0 if it is + * per session. + */ +int coap_dtls_is_context_timeout(void); + +/** + * Do all pending retransmits and get next timeout + * + * @param dtls_context The DTLS context. + * + * @return @c 0 if no event is pending or date of the next retransmit. + */ +coap_tick_t coap_dtls_get_context_timeout(void *dtls_context); + +/** + * Get next timeout for this session. + * + * @param coap_session The CoAP session. + * @param now The current time in ticks. + * + * @return @c 0 If no event is pending or ticks time of the next retransmit. + */ +coap_tick_t coap_dtls_get_timeout(coap_session_t *coap_session, + coap_tick_t now); + +/** + * Handle a DTLS timeout expiration. + * + * @param coap_session The CoAP session. + */ +void coap_dtls_handle_timeout(coap_session_t *coap_session); + +/** + * Handling incoming data from a DTLS peer. + * + * @param coap_session The CoAP session. + * @param data Encrypted datagram. + * @param data_len Encrypted datagram size. + * + * @return Result of coap_handle_dgram on the decrypted CoAP PDU + * or @c -1 for error. + */ +int coap_dtls_receive(coap_session_t *coap_session, + const uint8_t *data, + size_t data_len); + +/** + * Handling client HELLO messages from a new candiate peer. + * Note that session->tls is empty. + * + * @param coap_session The CoAP session. + * @param data Encrypted datagram. + * @param data_len Encrypted datagram size. + * + * @return @c 0 if a cookie verification message has been sent, @c 1 if the + * HELLO contains a valid cookie and a server session should be created, + * @c -1 if the message is invalid. + */ +int coap_dtls_hello(coap_session_t *coap_session, + const uint8_t *data, + size_t data_len); + +/** + * Get DTLS overhead over cleartext PDUs. + * + * @param coap_session The CoAP session. + * + * @return Maximum number of bytes added by DTLS layer. + */ +unsigned int coap_dtls_get_overhead(coap_session_t *coap_session); + +/** + * Create a new TLS client-side session. + * + * @param coap_session The CoAP session. + * @param connected Updated with whether the connection is connected yet or not. + * @c 0 is not connected, @c 1 is connected. + * + * @return Opaque handle to underlying TLS library object containing security + * parameters for the session. +*/ +void *coap_tls_new_client_session(coap_session_t *coap_session, int *connected); + +/** + * Create a TLS new server-side session. + * + * @param coap_session The CoAP session. + * @param connected Updated with whether the connection is connected yet or not. + * @c 0 is not connected, @c 1 is connected. + * + * @return Opaque handle to underlying TLS library object containing security + * parameters for the session. + */ +void *coap_tls_new_server_session(coap_session_t *coap_session, int *connected); + +/** + * Terminates the TLS session (may send an ALERT if necessary) then frees the + * underlying TLS library object containing security parameters for the session. + * + * @param coap_session The CoAP session. + */ +void coap_tls_free_session( coap_session_t *coap_session ); + +/** + * Send data to a TLS peer, with implicit flush. + * + * @param coap_session The CoAP session. + * @param data Pointer to data. + * @param data_len Number of bytes to send. + * + * @return @c 0 if this should be retried, @c -1 if there is an error + * or the number of cleartext bytes sent. + */ +ssize_t coap_tls_write(coap_session_t *coap_session, + const uint8_t *data, + size_t data_len + ); + +/** + * Read some data from a TLS peer. + * + * @param coap_session The CoAP session. + * @param data Pointer to data. + * @param data_len Maximum number of bytes to read. + * + * @return @c 0 if this should be retried, @c -1 if there is an error + * or the number of cleartext bytes read. + */ +ssize_t coap_tls_read(coap_session_t *coap_session, + uint8_t *data, + size_t data_len + ); + +/** + * Initialize the underlying (D)TLS Library layer. + * + */ +void coap_dtls_startup(void); + +/** + * Close down the underlying (D)TLS Library layer. + * + */ +void coap_dtls_shutdown(void); + +/** + * Get the actual (D)TLS object for the session. + * + * @param session The session. + * @param tls_lib Updated with the library type. + * + * @return The TLS information. + */ +void *coap_dtls_get_tls(const coap_session_t *session, + coap_tls_library_t *tls_lib); + +/** @} */ + +#endif /* COAP_DTLS_INTERNAL_H */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap2/coap_event.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_event.h similarity index 79% rename from tools/sdk/esp32/include/coap/libcoap/include/coap2/coap_event.h rename to tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_event.h index 81a3b0511fd..89b2a63967c 100644 --- a/tools/sdk/esp32/include/coap/libcoap/include/coap2/coap_event.h +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_event.h @@ -3,6 +3,8 @@ * * Copyright (C) 2016 Olaf Bergmann * + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ @@ -12,9 +14,6 @@ #include "libcoap.h" -struct coap_context_t; -struct coap_session_t; - /** * @defgroup events Event API * API functions for event delivery from lower-layer library functions. @@ -49,17 +48,20 @@ struct coap_session_t; #define COAP_EVENT_SESSION_CLOSED 0x2002 #define COAP_EVENT_SESSION_FAILED 0x2003 +/** + * BLOCK2 receive errors + */ +#define COAP_EVENT_PARTIAL_BLOCK 0x3001 + /** * Type for event handler functions that can be registered with a CoAP * context using the unction coap_set_event_handler(). When called by - * the library, the first argument will be the coap_context_t object - * where the handler function has been registered. The second argument - * is the event type that may be complemented by event-specific data - * passed as the third argument. + * the library, the first argument will be the current coap_session_t object + * which is associated with the original CoAP context. The second parameter + * is the event type. */ -typedef int (*coap_event_handler_t)(struct coap_context_t *, - coap_event_t event, - struct coap_session_t *session); +typedef int (*coap_event_handler_t)(coap_session_t *session, + const coap_event_t event); /** * Registers the function @p hnd as callback for events from the given @@ -70,9 +72,11 @@ typedef int (*coap_event_handler_t)(struct coap_context_t *, * @param hnd The event handler to be registered. @c NULL if to be * de-registered. */ -void coap_register_event_handler(struct coap_context_t *context, +void coap_register_event_handler(coap_context_t *context, coap_event_handler_t hnd); +/** @} */ + /** * Registers the function @p hnd as callback for events from the given * CoAP context @p context. Any event handler that has previously been @@ -84,7 +88,7 @@ void coap_register_event_handler(struct coap_context_t *context, * @param hnd The event handler to be registered. */ COAP_DEPRECATED -void coap_set_event_handler(struct coap_context_t *context, +void coap_set_event_handler(coap_context_t *context, coap_event_handler_t hnd); /** @@ -95,8 +99,6 @@ void coap_set_event_handler(struct coap_context_t *context, * @param context The CoAP context whose event handler is to be removed. */ COAP_DEPRECATED -void coap_clear_event_handler(struct coap_context_t *context); - -/** @} */ +void coap_clear_event_handler(coap_context_t *context); #endif /* COAP_EVENT_H */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_forward_decls.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_forward_decls.h new file mode 100644 index 00000000000..3bedbf7899a --- /dev/null +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_forward_decls.h @@ -0,0 +1,107 @@ +/* + * coap_forward_decls.h -- Forward declarations of structures that are + * opaque to application programming that use libcoap. + * + * Copyright (C) 2019-2021 Jon Shallow + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_forward_decls.h + * @brief COAP forward definitions + */ + +#ifndef COAP_FORWARD_DECLS_H_ +#define COAP_FORWARD_DECLS_H_ + +/* + * Define the forward declations for the structures (even non-opaque) + * so that applications (using coap.h) as well as libcoap builds + * can reference them (and makes .h file dependencies a lot simpler). + */ +struct coap_address_t; +struct coap_bin_const_t; +struct coap_dtls_pki_t; +struct coap_str_const_t; +struct coap_string_t; + +/* + * typedef all the opaque structures that are defined in coap_*_internal.h + */ + +/* ************* coap_async_internal.h ***************** */ + +/** + * Async Entry information. + */ +typedef struct coap_async_t coap_async_t; + +/* ************* coap_block_internal.h ***************** */ + +/* + * Block handling information. + */ +typedef struct coap_lg_xmit_t coap_lg_xmit_t; +typedef struct coap_lg_crcv_t coap_lg_crcv_t; +typedef struct coap_lg_srcv_t coap_lg_srcv_t; + +/* ************* coap_cache_internal.h ***************** */ + +/* + * Cache Entry information. + */ +typedef struct coap_cache_entry_t coap_cache_entry_t; +typedef struct coap_cache_key_t coap_cache_key_t; + +/* ************* coap_io_internal.h ***************** */ + +/** + * coap_socket_t and coap_packet_t information. + */ +typedef struct coap_packet_t coap_packet_t; +typedef struct coap_socket_t coap_socket_t; + +/* ************* coap_net_internal.h ***************** */ + +/* + * Net information. + */ +typedef struct coap_context_t coap_context_t; +typedef struct coap_queue_t coap_queue_t; + +/* ************* coap_pdu_internal.h ***************** */ + +/** + * PDU information. + */ +typedef struct coap_pdu_t coap_pdu_t; + +/* ************* coap_resource_internal.h ***************** */ + +/* + * Resource information. + */ +typedef struct coap_attr_t coap_attr_t; +typedef struct coap_resource_t coap_resource_t; + +/* ************* coap_session_internal.h ***************** */ + +/* + * Session information. + */ +typedef struct coap_addr_hash_t coap_addr_hash_t; +typedef struct coap_endpoint_t coap_endpoint_t; +typedef struct coap_session_t coap_session_t; + +/* ************* coap_subscribe_internal.h ***************** */ + +/* + * Observe subscriber information. + */ +typedef struct coap_subscription_t coap_subscription_t; + +#endif /* COAP_FORWARD_DECLS_H_ */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap2/coap_hashkey.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_hashkey.h similarity index 93% rename from tools/sdk/esp32/include/coap/libcoap/include/coap2/coap_hashkey.h rename to tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_hashkey.h index 252f34822d4..11a797bde7a 100644 --- a/tools/sdk/esp32/include/coap/libcoap/include/coap2/coap_hashkey.h +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_hashkey.h @@ -3,6 +3,8 @@ * * Copyright (C) 2010-2011 Olaf Bergmann * + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ @@ -31,7 +33,7 @@ typedef unsigned char coap_key_t[4]; * @param len The length of @p s. * @param h The result buffer to store the calculated hash key. */ -void coap_hash_impl(const unsigned char *s, unsigned int len, coap_key_t h); +void coap_hash_impl(const unsigned char *s, size_t len, coap_key_t h); #define coap_hash(String,Length,Result) \ coap_hash_impl((String),(Length),(Result)) diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_internal.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_internal.h new file mode 100644 index 00000000000..5eee5c12867 --- /dev/null +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_internal.h @@ -0,0 +1,65 @@ +/* + * coap_internal.h -- Structures, Enums & Functions that are not exposed to + * application programming + * + * Copyright (C) 2019-2021 Jon Shallow + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/* + * All libcoap library files should include this file which then pulls in all + * of the other appropriate header files. + * + * Note: This file should never be included in application code (with the + * possible exception of internal test suites). + */ + +/** + * @file coap_internal.h + * @brief Pulls together all the internal only header files + */ + +#ifndef COAP_INTERNAL_H_ +#define COAP_INTERNAL_H_ + +#include "coap_config.h" + +/* + * Correctly set up assert() based on NDEBUG for libcoap + */ +#if defined(HAVE_ASSERT_H) && !defined(assert) +# include +#endif + +#include "coap3/coap.h" + +/* + * Include all the header files that are for internal use only. + */ + +/* Not defined in coap.h - internal usage .h files */ +#include "utlist.h" +#include "uthash.h" +#include "coap_hashkey.h" +#include "coap_mutex.h" + +/* Specifically defined internal .h files */ +#include "coap_asn1_internal.h" +#include "coap_async_internal.h" +#include "coap_block_internal.h" +#include "coap_cache_internal.h" +#include "coap_dtls_internal.h" +#include "coap_io_internal.h" +#include "coap_net_internal.h" +#include "coap_pdu_internal.h" +#include "coap_session_internal.h" +#include "coap_resource_internal.h" +#include "coap_session_internal.h" +#include "coap_subscribe_internal.h" +#include "coap_tcp_internal.h" + +#endif /* COAP_INTERNAL_H_ */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_io.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_io.h new file mode 100644 index 00000000000..b27921f8be1 --- /dev/null +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_io.h @@ -0,0 +1,72 @@ +/* + * coap_io.h -- Default network I/O functions for libcoap + * + * Copyright (C) 2012-2013 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +#ifndef COAP_IO_H_ +#define COAP_IO_H_ + +#include + +#include "address.h" + +#ifdef RIOT_VERSION +#include "net/gnrc.h" +#endif /* RIOT_VERSION */ + +#ifndef COAP_RXBUFFER_SIZE +#define COAP_RXBUFFER_SIZE 1472 +#endif /* COAP_RXBUFFER_SIZE */ + +/* + * It may may make sense to define this larger on busy systems + * (lots of sessions, large number of which are active), by using + * -DCOAP_MAX_EPOLL_EVENTS=nn at compile time. + */ +#ifndef COAP_MAX_EPOLL_EVENTS +#define COAP_MAX_EPOLL_EVENTS 10 +#endif /* COAP_MAX_EPOLL_EVENTS */ + +#ifdef _WIN32 +typedef SOCKET coap_fd_t; +#define coap_closesocket closesocket +#define COAP_SOCKET_ERROR SOCKET_ERROR +#define COAP_INVALID_SOCKET INVALID_SOCKET +#else +typedef int coap_fd_t; +#define coap_closesocket close +#define COAP_SOCKET_ERROR (-1) +#define COAP_INVALID_SOCKET (-1) +#endif + +typedef uint16_t coap_socket_flags_t; + +typedef struct coap_addr_tuple_t { + coap_address_t remote; /**< remote address and port */ + coap_address_t local; /**< local address and port */ +} coap_addr_tuple_t; + +const char *coap_socket_strerror( void ); + +/** + * Check whether TCP is available. + * + * @return @c 1 if support for TCP is enabled, or @c 0 otherwise. + */ +int coap_tcp_is_supported(void); + +typedef enum { + COAP_NACK_TOO_MANY_RETRIES, + COAP_NACK_NOT_DELIVERABLE, + COAP_NACK_RST, + COAP_NACK_TLS_FAILED, + COAP_NACK_ICMP_ISSUE +} coap_nack_reason_t; + +#endif /* COAP_IO_H_ */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/coap_io.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_io_internal.h similarity index 62% rename from tools/sdk/esp32c3/include/coap/libcoap/include/coap2/coap_io.h rename to tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_io_internal.h index 1854501be89..241ef7f9955 100644 --- a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/coap_io.h +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_io_internal.h @@ -3,41 +3,24 @@ * * Copyright (C) 2012-2013 Olaf Bergmann * + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ -#ifndef COAP_IO_H_ -#define COAP_IO_H_ +#ifndef COAP_IO_INTERNAL_H_ +#define COAP_IO_INTERNAL_H_ -#include #include #include "address.h" -#ifndef COAP_RXBUFFER_SIZE -#define COAP_RXBUFFER_SIZE 1472 -#endif /* COAP_RXBUFFER_SIZE */ - -#ifdef _WIN32 -typedef SOCKET coap_fd_t; -#define coap_closesocket closesocket -#define COAP_SOCKET_ERROR SOCKET_ERROR -#define COAP_INVALID_SOCKET INVALID_SOCKET -#else -typedef int coap_fd_t; -#define coap_closesocket close -#define COAP_SOCKET_ERROR (-1) -#define COAP_INVALID_SOCKET (-1) -#endif - -struct coap_packet_t; -struct coap_session_t; -struct coap_pdu_t; +#ifdef RIOT_VERSION +#include "net/gnrc.h" +#endif /* RIOT_VERSION */ -typedef uint16_t coap_socket_flags_t; - -typedef struct coap_socket_t { +struct coap_socket_t { #if defined(WITH_LWIP) struct udp_pcb *pcb; #elif defined(WITH_CONTIKI) @@ -45,8 +28,14 @@ typedef struct coap_socket_t { #else coap_fd_t fd; #endif /* WITH_LWIP */ +#if defined(RIOT_VERSION) + gnrc_pktsnip_t *pkt; /* pointer to received packet for processing */ +#endif /* RIOT_VERSION */ coap_socket_flags_t flags; -} coap_socket_t; + coap_session_t *session; /* Used by the epoll logic for an active session. */ + coap_endpoint_t *endpoint; /* Used by the epoll logic for a listening + endpoint. */ +}; /** * coap_socket_flags_t values @@ -65,8 +54,10 @@ typedef struct coap_socket_t { #define COAP_SOCKET_CAN_CONNECT 0x0800 /**< non blocking client socket can now connect without blocking */ #define COAP_SOCKET_MULTICAST 0x1000 /**< socket is used for multicast communication */ -struct coap_endpoint_t *coap_malloc_endpoint( void ); -void coap_mfree_endpoint( struct coap_endpoint_t *ep ); +coap_endpoint_t *coap_malloc_endpoint( void ); +void coap_mfree_endpoint( coap_endpoint_t *ep ); + +const char *coap_socket_format_errno(int error); int coap_socket_connect_udp(coap_socket_t *sock, @@ -81,34 +72,10 @@ coap_socket_bind_udp(coap_socket_t *sock, const coap_address_t *listen_addr, coap_address_t *bound_addr ); -int -coap_socket_connect_tcp1(coap_socket_t *sock, - const coap_address_t *local_if, - const coap_address_t *server, - int default_port, - coap_address_t *local_addr, - coap_address_t *remote_addr); - -int -coap_socket_connect_tcp2(coap_socket_t *sock, - coap_address_t *local_addr, - coap_address_t *remote_addr); - -int -coap_socket_bind_tcp(coap_socket_t *sock, - const coap_address_t *listen_addr, - coap_address_t *bound_addr); - -int -coap_socket_accept_tcp(coap_socket_t *server, - coap_socket_t *new_client, - coap_address_t *local_addr, - coap_address_t *remote_addr); - void coap_socket_close(coap_socket_t *sock); ssize_t -coap_socket_send( coap_socket_t *sock, struct coap_session_t *session, +coap_socket_send( coap_socket_t *sock, coap_session_t *session, const uint8_t *data, size_t data_len ); ssize_t @@ -117,14 +84,15 @@ coap_socket_write(coap_socket_t *sock, const uint8_t *data, size_t data_len); ssize_t coap_socket_read(coap_socket_t *sock, uint8_t *data, size_t data_len); +void +coap_epoll_ctl_mod(coap_socket_t *sock, uint32_t events, const char *func); + #ifdef WITH_LWIP ssize_t -coap_socket_send_pdu( coap_socket_t *sock, struct coap_session_t *session, - struct coap_pdu_t *pdu ); +coap_socket_send_pdu( coap_socket_t *sock, coap_session_t *session, + coap_pdu_t *pdu ); #endif -const char *coap_socket_strerror( void ); - /** * Function interface for data transmission. This function returns the number of * bytes that have been transmitted, or a value less than zero on error. @@ -137,7 +105,7 @@ const char *coap_socket_strerror( void ); * @return The number of bytes written on success, or a value * less than zero on error. */ -ssize_t coap_network_send( coap_socket_t *sock, const struct coap_session_t *session, const uint8_t *data, size_t datalen ); +ssize_t coap_network_send( coap_socket_t *sock, const coap_session_t *session, const uint8_t *data, size_t datalen ); /** * Function interface for reading data. This function returns the number of @@ -150,7 +118,7 @@ ssize_t coap_network_send( coap_socket_t *sock, const struct coap_session_t *ses * @return The number of bytes received on success, or a value less than * zero on error. */ -ssize_t coap_network_read( coap_socket_t *sock, struct coap_packet_t *packet ); +ssize_t coap_network_read( coap_socket_t *sock, coap_packet_t *packet ); #ifndef coap_mcast_interface # define coap_mcast_interface(Local) 0 @@ -160,7 +128,7 @@ ssize_t coap_network_read( coap_socket_t *sock, struct coap_packet_t *packet ); * Given a packet, set msg and msg_len to an address and length of the packet's * data in memory. * */ -void coap_packet_get_memmapped(struct coap_packet_t *packet, +void coap_packet_get_memmapped(coap_packet_t *packet, unsigned char **address, size_t *length); @@ -169,7 +137,7 @@ void coap_packet_get_memmapped(struct coap_packet_t *packet, * Get the pbuf of a packet. The caller takes over responsibility for freeing * the pbuf. */ -struct pbuf *coap_packet_extract_pbuf(struct coap_packet_t *packet); +struct pbuf *coap_packet_extract_pbuf(coap_packet_t *packet); #endif #if defined(WITH_LWIP) @@ -183,28 +151,18 @@ struct pbuf *coap_packet_extract_pbuf(struct coap_packet_t *packet); */ struct coap_packet_t { struct pbuf *pbuf; - const struct coap_endpoint_t *local_interface; - coap_address_t src; /**< the packet's source address */ - coap_address_t dst; /**< the packet's destination address */ + const coap_endpoint_t *local_interface; + coap_addr_tuple_t addr_info; /**< local and remote addresses */ int ifindex; /**< the interface index */ // uint16_t srcport; }; #else struct coap_packet_t { - coap_address_t src; /**< the packet's source address */ - coap_address_t dst; /**< the packet's destination address */ + coap_addr_tuple_t addr_info; /**< local and remote addresses */ int ifindex; /**< the interface index */ size_t length; /**< length of payload */ unsigned char payload[COAP_RXBUFFER_SIZE]; /**< payload */ }; #endif -typedef struct coap_packet_t coap_packet_t; - -typedef enum { - COAP_NACK_TOO_MANY_RETRIES, - COAP_NACK_NOT_DELIVERABLE, - COAP_NACK_RST, - COAP_NACK_TLS_FAILED -} coap_nack_reason_t; -#endif /* COAP_IO_H_ */ +#endif /* COAP_IO_INTERNAL_H_ */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/coap_mutex.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_mutex.h similarity index 63% rename from tools/sdk/esp32s2/include/coap/libcoap/include/coap2/coap_mutex.h rename to tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_mutex.h index 99d7d335e47..44084fecb1c 100644 --- a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/coap_mutex.h +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_mutex.h @@ -2,6 +2,9 @@ * coap_mutex.h -- mutex utilities * * Copyright (C) 2019 Jon Shallow + * 2019 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause * * This file is part of the CoAP library libcoap. Please see README for terms * of use. @@ -15,8 +18,24 @@ #ifndef COAP_MUTEX_H_ #define COAP_MUTEX_H_ -#if defined(RIOT_VERSION) +/* + * Mutexes are currently only used if there is a constrained stack, + * and large static variables (instead of the large variable being on + * the stack) need to be protected. + */ +#if COAP_CONSTRAINED_STACK + +#if defined(HAVE_PTHREAD_H) && defined(HAVE_PTHREAD_MUTEX_LOCK) +#include + +typedef pthread_mutex_t coap_mutex_t; +#define COAP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER +#define coap_mutex_lock(a) pthread_mutex_lock(a) +#define coap_mutex_trylock(a) pthread_mutex_trylock(a) +#define coap_mutex_unlock(a) pthread_mutex_unlock(a) +#elif defined(RIOT_VERSION) +/* use RIOT's mutex API */ #include typedef mutex_t coap_mutex_t; @@ -25,26 +44,16 @@ typedef mutex_t coap_mutex_t; #define coap_mutex_trylock(a) mutex_trylock(a) #define coap_mutex_unlock(a) mutex_unlock(a) -#elif defined(WITH_CONTIKI) - -/* CONTIKI does not support mutex */ - +#else +/* define stub mutex functions */ typedef int coap_mutex_t; #define COAP_MUTEX_INITIALIZER 0 #define coap_mutex_lock(a) *(a) = 1 #define coap_mutex_trylock(a) *(a) = 1 #define coap_mutex_unlock(a) *(a) = 0 -#else /* ! RIOT_VERSION && ! WITH_CONTIKI */ - -#include - -typedef pthread_mutex_t coap_mutex_t; -#define COAP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER -#define coap_mutex_lock(a) pthread_mutex_lock(a) -#define coap_mutex_trylock(a) pthread_mutex_trylock(a) -#define coap_mutex_unlock(a) pthread_mutex_unlock(a) +#endif /* !RIOT_VERSION && !HAVE_PTHREAD_H && !HAVE_PTHREAD_MUTEX_LOCK */ -#endif /* ! RIOT_VERSION && ! WITH_CONTIKI */ +#endif /* COAP_CONSTRAINED_STACK */ #endif /* COAP_MUTEX_H_ */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_net_internal.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_net_internal.h new file mode 100644 index 00000000000..bf243f3d022 --- /dev/null +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_net_internal.h @@ -0,0 +1,366 @@ +/* + * coap_context_internal.h -- Structures, Enums & Functions that are not + * exposed to application programming + * + * Copyright (C) 2010-2021 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_net_internal.h + * @brief COAP net internal information + */ + +#ifndef COAP_NET_INTERNAL_H_ +#define COAP_NET_INTERNAL_H_ + +/** + * @defgroup context_internal Context Handling (Internal) + * CoAP Context Structures, Enums and Functions that are not exposed to + * applications + * @{ + */ + +/** + * Queue entry + */ +struct coap_queue_t { + struct coap_queue_t *next; + coap_tick_t t; /**< when to send PDU for the next time */ + unsigned char retransmit_cnt; /**< retransmission counter, will be removed + * when zero */ + unsigned int timeout; /**< the randomized timeout value */ + coap_session_t *session; /**< the CoAP session */ + coap_mid_t id; /**< CoAP message id */ + coap_pdu_t *pdu; /**< the CoAP PDU to send */ +}; + +/** + * The CoAP stack's global state is stored in a coap_context_t object. + */ +struct coap_context_t { + coap_opt_filter_t known_options; + coap_resource_t *resources; /**< hash table or list of known + resources */ + coap_resource_t *unknown_resource; /**< can be used for handling + unknown resources */ + coap_resource_t *proxy_uri_resource; /**< can be used for handling + proxy URI resources */ + coap_resource_release_userdata_handler_t release_userdata; + /**< function to release user_data + when resource is deleted */ + +#ifndef WITHOUT_ASYNC + /** + * list of asynchronous message ids */ + coap_async_t *async_state; +#endif /* WITHOUT_ASYNC */ + + /** + * The time stamp in the first element of the sendqeue is relative + * to sendqueue_basetime. */ + coap_tick_t sendqueue_basetime; + coap_queue_t *sendqueue; + coap_endpoint_t *endpoint; /**< the endpoints used for listening */ + coap_session_t *sessions; /**< client sessions */ + +#ifdef WITH_CONTIKI + struct uip_udp_conn *conn; /**< uIP connection object */ + struct etimer retransmit_timer; /**< fires when the next packet must be + sent */ + struct etimer notify_timer; /**< used to check resources periodically */ +#endif /* WITH_CONTIKI */ + +#ifdef WITH_LWIP + uint8_t timer_configured; /**< Set to 1 when a retransmission is + * scheduled using lwIP timers for this + * context, otherwise 0. */ +#endif /* WITH_LWIP */ + + coap_response_handler_t response_handler; + coap_nack_handler_t nack_handler; + coap_ping_handler_t ping_handler; + coap_pong_handler_t pong_handler; + + /** + * Callback function that is used to signal events to the + * application. This field is set by coap_set_event_handler(). + */ + coap_event_handler_t handle_event; + + ssize_t (*network_send)(coap_socket_t *sock, const coap_session_t *session, + const uint8_t *data, size_t datalen); + + ssize_t (*network_read)(coap_socket_t *sock, coap_packet_t *packet); + + size_t(*get_client_psk)(const coap_session_t *session, const uint8_t *hint, + size_t hint_len, uint8_t *identity, + size_t *identity_len, size_t max_identity_len, + uint8_t *psk, size_t max_psk_len); + size_t(*get_server_psk)(const coap_session_t *session, + const uint8_t *identity, size_t identity_len, + uint8_t *psk, size_t max_psk_len); + size_t(*get_server_hint)(const coap_session_t *session, uint8_t *hint, + size_t max_hint_len); + + void *dtls_context; + + coap_dtls_spsk_t spsk_setup_data; /**< Contains the initial PSK server setup + data */ + + unsigned int session_timeout; /**< Number of seconds of inactivity after + which an unused session will be closed. + 0 means use default. */ + unsigned int max_idle_sessions; /**< Maximum number of simultaneous unused + sessions per endpoint. 0 means no + maximum. */ + unsigned int max_handshake_sessions; /**< Maximum number of simultaneous + negotating sessions per endpoint. 0 + means use default. */ + unsigned int ping_timeout; /**< Minimum inactivity time before + sending a ping message. 0 means + disabled. */ + unsigned int csm_timeout; /**< Timeout for waiting for a CSM from + the remote side. 0 means disabled. */ + uint8_t observe_pending; /**< Observe response pending */ + uint8_t block_mode; /**< Zero or more COAP_BLOCK_ or'd options */ + uint64_t etag; /**< Next ETag to use */ + + coap_cache_entry_t *cache; /**< CoAP cache-entry cache */ + uint16_t *cache_ignore_options; /**< CoAP options to ignore when creating a + cache-key */ + size_t cache_ignore_count; /**< The number of CoAP options to ignore + when creating a cache-key */ + void *app; /**< application-specific data */ +#ifdef COAP_EPOLL_SUPPORT + int epfd; /**< External FD for epoll */ + int eptimerfd; /**< Internal FD for timeout */ + coap_tick_t next_timeout; /**< When the next timeout is to occur */ +#endif /* COAP_EPOLL_SUPPORT */ +}; + +/** + * Adds @p node to given @p queue, ordered by variable t in @p node. + * + * @param queue Queue to add to. + * @param node Node entry to add to Queue. + * + * @return @c 1 added to queue, @c 0 failure. + */ +int coap_insert_node(coap_queue_t **queue, coap_queue_t *node); + +/** + * Destroys specified @p node. + * + * @param node Node entry to remove. + * + * @return @c 1 node deleted from queue, @c 0 failure. + */ +int coap_delete_node(coap_queue_t *node); + +/** + * Removes all items from given @p queue and frees the allocated storage. + * + * Internal function. + * + * @param queue The queue to delete. + */ +void coap_delete_all(coap_queue_t *queue); + +/** + * Creates a new node suitable for adding to the CoAP sendqueue. + * + * @return New node entry, or @c NULL if failure. + */ +coap_queue_t *coap_new_node(void); + +/** + * Set sendqueue_basetime in the given context object @p ctx to @p now. This + * function returns the number of elements in the queue head that have timed + * out. + */ +unsigned int coap_adjust_basetime(coap_context_t *ctx, coap_tick_t now); + +/** + * Returns the next pdu to send without removing from sendqeue. + */ +coap_queue_t *coap_peek_next( coap_context_t *context ); + +/** + * Returns the next pdu to send and removes it from the sendqeue. + */ +coap_queue_t *coap_pop_next( coap_context_t *context ); + +/** + * Handles retransmissions of confirmable messages + * + * @param context The CoAP context. + * @param node The node to retransmit. + * + * @return The message id of the sent message or @c + * COAP_INVALID_MID on error. + */ +coap_mid_t coap_retransmit(coap_context_t *context, coap_queue_t *node); + +/** + * Parses and interprets a CoAP datagram with context @p ctx. This function + * returns @c 0 if the datagram was handled, or a value less than zero on + * error. + * + * @param ctx The current CoAP context. + * @param session The current CoAP session. + * @param data The received packet'd data. + * @param data_len The received packet'd data length. + * + * @return @c 0 if message was handled successfully, or less than zero on + * error. + */ +int coap_handle_dgram(coap_context_t *ctx, coap_session_t *session, uint8_t *data, size_t data_len); + +/** + * This function removes the element with given @p id from the list given list. + * If @p id was found, @p node is updated to point to the removed element. Note + * that the storage allocated by @p node is @b not released. The caller must do + * this manually using coap_delete_node(). This function returns @c 1 if the + * element with id @p id was found, @c 0 otherwise. For a return value of @c 0, + * the contents of @p node is undefined. + * + * @param queue The queue to search for @p id. + * @param session The session to look for. + * @param id The message id to look for. + * @param node If found, @p node is updated to point to the removed node. You + * must release the storage pointed to by @p node manually. + * + * @return @c 1 if @p id was found, @c 0 otherwise. + */ +int coap_remove_from_queue(coap_queue_t **queue, + coap_session_t *session, + coap_mid_t id, + coap_queue_t **node); + +coap_mid_t +coap_wait_ack( coap_context_t *context, coap_session_t *session, + coap_queue_t *node); + +/** + * Cancels all outstanding messages for session @p session that have the specified + * token. + * + * @param context The context in use. + * @param session Session of the messages to remove. + * @param token Message token. + * @param token_length Actual length of @p token. + */ +void coap_cancel_all_messages(coap_context_t *context, + coap_session_t *session, + const uint8_t *token, + size_t token_length); + +/** +* Cancels all outstanding messages for session @p session. +* +* @param context The context in use. +* @param session Session of the messages to remove. +* @param reason The reasion for the session cancellation +*/ +void +coap_cancel_session_messages(coap_context_t *context, + coap_session_t *session, + coap_nack_reason_t reason); + +/** + * Dispatches the PDUs from the receive queue in given context. + */ +void coap_dispatch(coap_context_t *context, coap_session_t *session, + coap_pdu_t *pdu); + +/** + * Verifies that @p pdu contains no unknown critical options. Options must be + * registered at @p ctx, using the function coap_register_option(). A basic set + * of options is registered automatically by coap_new_context(). This function + * returns @c 1 if @p pdu is ok, @c 0 otherwise. The given filter object @p + * unknown will be updated with the unknown options. As only @c COAP_MAX_OPT + * options can be signalled this way, remaining options must be examined + * manually. + * + * @code + coap_opt_filter_t f = COAP_OPT_NONE; + coap_opt_iterator_t opt_iter; + + if (coap_option_check_critical(ctx, pdu, f) == 0) { + coap_option_iterator_init(pdu, &opt_iter, f); + + while (coap_option_next(&opt_iter)) { + if (opt_iter.type & 0x01) { + ... handle unknown critical option in opt_iter ... + } + } + } + @endcode + * + * @param ctx The context where all known options are registered. + * @param pdu The PDU to check. + * @param unknown The output filter that will be updated to indicate the + * unknown critical options found in @p pdu. + * + * @return @c 1 if everything was ok, @c 0 otherwise. + */ +int coap_option_check_critical(coap_context_t *ctx, + coap_pdu_t *pdu, + coap_opt_filter_t *unknown); + +/** + * Creates a new response for given @p request with the contents of @c + * .well-known/core. The result is NULL on error or a newly allocated PDU that + * must be either sent with coap_sent() or released by coap_delete_pdu(). + * + * @param context The current coap context to use. + * @param session The CoAP session. + * @param request The request for @c .well-known/core . + * + * @return A new 2.05 response for @c .well-known/core or NULL on error. + */ +coap_pdu_t *coap_wellknown_response(coap_context_t *context, + coap_session_t *session, + coap_pdu_t *request); + +/** + * Calculates the initial timeout based on the session CoAP transmission + * parameters 'ack_timeout', 'ack_random_factor', and COAP_TICKS_PER_SECOND. + * The calculation requires 'ack_timeout' and 'ack_random_factor' to be in + * Qx.FRAC_BITS fixed point notation, whereas the passed parameter @p r + * is interpreted as the fractional part of a Q0.MAX_BITS random value. + * + * @param session session timeout is associated with + * @param r random value as fractional part of a Q0.MAX_BITS fixed point + * value + * @return COAP_TICKS_PER_SECOND * 'ack_timeout' * + * (1 + ('ack_random_factor' - 1) * r) + */ +unsigned int coap_calc_timeout(coap_session_t *session, unsigned char r); + +/** + * Sends a CoAP message to given peer. The memory that is + * allocated for the pdu will be released by coap_send_internal(). + * The caller must not use the pdu after calling coap_send_internal(). + * + * If the response body is split into multiple payloads using blocks, libcoap + * will handle asking for the subsequent blocks and any necessary recovery + * needed. + * + * @param session The CoAP session. + * @param pdu The CoAP PDU to send. + * + * @return The message id of the sent message or @c + * COAP_INVALID_MID on error. + */ +coap_mid_t coap_send_internal(coap_session_t *session, coap_pdu_t *pdu); + +/** @} */ + +#endif /* COAP_NET_INTERNAL_H_ */ + diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_pdu_internal.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_pdu_internal.h new file mode 100644 index 00000000000..0d8446c0d4c --- /dev/null +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_pdu_internal.h @@ -0,0 +1,300 @@ +/* + * coap_pdu_internal.h -- CoAP PDU structure + * + * Copyright (C) 2010-2021 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_pdu_internal.h + * @brief CoAP PDU internal information + */ + +#ifndef COAP_COAP_PDU_INTERNAL_H_ +#define COAP_COAP_PDU_INTERNAL_H_ + +#ifdef WITH_LWIP +#include +#endif + +#include + +/** + * @defgroup pdu_internal PDU (Internal) + * CoAP PDU Structures, Enums and Functions that are not exposed to + * applications + * @{ + */ + +#define COAP_DEFAULT_VERSION 1 /* version of CoAP supported */ + +/* TCP Message format constants, do not modify */ +#define COAP_MESSAGE_SIZE_OFFSET_TCP8 13 +#define COAP_MESSAGE_SIZE_OFFSET_TCP16 269 /* 13 + 256 */ +#define COAP_MESSAGE_SIZE_OFFSET_TCP32 65805 /* 269 + 65536 */ + +/* Derived message size limits */ +#define COAP_MAX_MESSAGE_SIZE_TCP0 (COAP_MESSAGE_SIZE_OFFSET_TCP8-1) /* 12 */ +#define COAP_MAX_MESSAGE_SIZE_TCP8 (COAP_MESSAGE_SIZE_OFFSET_TCP16-1) /* 268 */ +#define COAP_MAX_MESSAGE_SIZE_TCP16 (COAP_MESSAGE_SIZE_OFFSET_TCP32-1) /* 65804 */ +#define COAP_MAX_MESSAGE_SIZE_TCP32 (COAP_MESSAGE_SIZE_OFFSET_TCP32+0xFFFFFFFF) + +#ifndef COAP_DEBUG_BUF_SIZE +#if defined(WITH_CONTIKI) || defined(WITH_LWIP) +#define COAP_DEBUG_BUF_SIZE 128 +#else /* defined(WITH_CONTIKI) || defined(WITH_LWIP) */ +/* 1024 derived from RFC7252 4.6. Message Size max payload */ +#define COAP_DEBUG_BUF_SIZE (8 + 1024 * 2) +#endif /* defined(WITH_CONTIKI) || defined(WITH_LWIP) */ +#endif /* COAP_DEBUG_BUF_SIZE */ + +#ifndef COAP_DEFAULT_MAX_PDU_RX_SIZE +#if defined(WITH_CONTIKI) || defined(WITH_LWIP) +#define COAP_DEFAULT_MAX_PDU_RX_SIZE (COAP_MAX_MESSAGE_SIZE_TCP16+4UL) +#else +/* 8 MiB max-message-size plus some space for options */ +#define COAP_DEFAULT_MAX_PDU_RX_SIZE (8UL*1024*1024+256) +#endif +#endif /* COAP_DEFAULT_MAX_PDU_RX_SIZE */ + +/** + * Indicates that a response is suppressed. This will occur for error + * responses if the request was received via IP multicast. + */ +#define COAP_DROPPED_RESPONSE -2 + +#define COAP_PDU_DELAYED -3 + +#define COAP_PAYLOAD_START 0xFF /* payload marker */ + +#define COAP_PDU_IS_EMPTY(pdu) ((pdu)->code == 0) +#define COAP_PDU_IS_REQUEST(pdu) (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32) +#define COAP_PDU_IS_RESPONSE(pdu) ((pdu)->code >= 64 && (pdu)->code < 224) +#define COAP_PDU_IS_SIGNALING(pdu) ((pdu)->code >= 224) + +#define COAP_PDU_MAX_UDP_HEADER_SIZE 4 +#define COAP_PDU_MAX_TCP_HEADER_SIZE 6 + +/** + * structure for CoAP PDUs + * token, if any, follows the fixed size header, then options until + * payload marker (0xff), then the payload if stored inline. + * Memory layout is: + * <---header--->|<---token---><---options--->0xff<---payload---> + * header is addressed with a negative offset to token, its maximum size is + * max_hdr_size. + * options starts at token + token_length + * payload starts at data, its length is used_size - (data - token) + */ + +struct coap_pdu_t { + coap_pdu_type_t type; /**< message type */ + coap_pdu_code_t code; /**< request method (value 1--31) or response code + (value 64-255) */ + coap_mid_t mid; /**< message id, if any, in regular host byte + order */ + uint8_t max_hdr_size; /**< space reserved for protocol-specific header */ + uint8_t hdr_size; /**< actual size used for protocol-specific + header */ + uint8_t token_length; /**< length of Token */ + uint16_t max_opt; /**< highest option number in PDU */ + size_t alloc_size; /**< allocated storage for token, options and + payload */ + size_t used_size; /**< used bytes of storage for token, options and + payload */ + size_t max_size; /**< maximum size for token, options and payload, + or zero for variable size pdu */ + uint8_t *token; /**< first byte of token, if any, or options */ + uint8_t *data; /**< first byte of payload, if any */ +#ifdef WITH_LWIP + struct pbuf *pbuf; /**< lwIP PBUF. The package data will always reside + * inside the pbuf's payload, but this pointer + * has to be kept because no exact offset can be + * given. This field must not be accessed from + * outside, because the pbuf's reference count + * is checked to be 1 when the pbuf is assigned + * to the pdu, and the pbuf stays exclusive to + * this pdu. */ +#endif + const uint8_t *body_data; /**< Holds ptr to re-assembled data or NULL */ + size_t body_length; /**< Holds body data length */ + size_t body_offset; /**< Holds body data offset */ + size_t body_total; /**< Holds body data total size */ + coap_lg_xmit_t *lg_xmit; /**< Holds ptr to lg_xmit if sending a set of + blocks */ +}; + +/** + * Dynamically grows the size of @p pdu to @p new_size. The new size + * must not exceed the PDU's configure maximum size. On success, this + * function returns 1, otherwise 0. + * + * @param pdu The PDU to resize. + * @param new_size The new size in bytes. + * @return 1 if the operation succeeded, 0 otherwise. + */ +int coap_pdu_resize(coap_pdu_t *pdu, size_t new_size); + +/** + * Dynamically grows the size of @p pdu to @p new_size if needed. The new size + * must not exceed the PDU's configured maximum size. On success, this + * function returns 1, otherwise 0. + * + * @param pdu The PDU to resize. + * @param new_size The new size in bytes. + * @return 1 if the operation succeeded, 0 otherwise. + */ +int coap_pdu_check_resize(coap_pdu_t *pdu, size_t new_size); + +/** +* Interprets @p data to determine the number of bytes in the header. +* This function returns @c 0 on error or a number greater than zero on success. +* +* @param proto Session's protocol +* @param data The first byte of raw data to parse as CoAP PDU. +* +* @return A value greater than zero on success or @c 0 on error. +*/ +size_t coap_pdu_parse_header_size(coap_proto_t proto, + const uint8_t *data); + +/** + * Parses @p data to extract the message size. + * @p length must be at least coap_pdu_parse_header_size(proto, data). + * This function returns @c 0 on error or a number greater than zero on success. + * + * @param proto Session's protocol + * @param data The raw data to parse as CoAP PDU. + * @param length The actual size of @p data. + * + * @return A value greater than zero on success or @c 0 on error. + */ +size_t coap_pdu_parse_size(coap_proto_t proto, + const uint8_t *data, + size_t length); + +/** + * Decode the protocol specific header for the specified PDU. + * @param pdu A newly received PDU. + * @param proto The target wire protocol. + * @return 1 for success or 0 on error. + */ + +int coap_pdu_parse_header(coap_pdu_t *pdu, coap_proto_t proto); + +/** + * Verify consistency in the given CoAP PDU structure and locate the data. + * This function returns @c 0 on error or a number greater than zero on + * success. + * This function only parses the token and options, up to the payload start + * marker. + * + * @param pdu The PDU structure to check. + * + * @return 1 on success or @c 0 on error. + */ +int coap_pdu_parse_opt(coap_pdu_t *pdu); + +/** +* Parses @p data into the CoAP PDU structure given in @p result. +* The target pdu must be large enough to +* This function returns @c 0 on error or a number greater than zero on success. +* +* @param proto Session's protocol +* @param data The raw data to parse as CoAP PDU. +* @param length The actual size of @p data. +* @param pdu The PDU structure to fill. Note that the structure must +* provide space to hold at least the token and options +* part of the message. +* +* @return 1 on success or @c 0 on error. +*/ +int coap_pdu_parse(coap_proto_t proto, + const uint8_t *data, + size_t length, + coap_pdu_t *pdu); + +/** + * Clears any contents from @p pdu and resets @c used_size, + * and @c data pointers. @c max_size is set to @p size, any + * other field is set to @c 0. Note that @p pdu must be a valid + * pointer to a coap_pdu_t object created e.g. by coap_pdu_init(). + * + * @param pdu The PDU to clear. + * @param size The maximum size of the PDU. + */ +void coap_pdu_clear(coap_pdu_t *pdu, size_t size); + +/** + * Removes (first) option of given number from the @p pdu. + * + * @param pdu The PDU to remove the option from. + * @param number The number of the CoAP option to remove (first only removed). + * + * @return @c 1 if success else @c 0 if error. + */ +int coap_remove_option(coap_pdu_t *pdu, coap_option_num_t number); + +/** + * Inserts option of given number in the @p pdu with the appropriate data. + * The option will be inserted in the appropriate place in the options in + * the pdu. + * + * @param pdu The PDU where the option is to be inserted. + * @param number The number of the new option. + * @param len The length of the new option. + * @param data The data of the new option. + * + * @return The overall length of the option or @c 0 on failure. + */ +size_t coap_insert_option(coap_pdu_t *pdu, coap_option_num_t number, + size_t len, const uint8_t *data); + +/** + * Updates existing first option of given number in the @p pdu with the new + * data. + * + * @param pdu The PDU where the option is to be updated. + * @param number The number of the option to update (first only updated). + * @param len The length of the updated option. + * @param data The data of the updated option. + * + * @return The overall length of the updated option or @c 0 on failure. + */ +size_t coap_update_option(coap_pdu_t *pdu, + coap_option_num_t number, + size_t len, + const uint8_t *data); + +/** + * Compose the protocol specific header for the specified PDU. + * + * @param pdu A newly composed PDU. + * @param proto The target wire protocol. + * + * @return Number of header bytes prepended before pdu->token or 0 on error. + */ + +size_t coap_pdu_encode_header(coap_pdu_t *pdu, coap_proto_t proto); + + /** + * Updates token in @p pdu with length @p len and @p data. + * This function returns @c 0 on error or a value greater than zero on success. + * + * @param pdu The PDU where the token is to be updated. + * @param len The length of the new token. + * @param data The token to add. + * + * @return A value greater than zero on success, or @c 0 on error. + */ +int coap_update_token(coap_pdu_t *pdu, + size_t len, + const uint8_t *data); + +/** @} */ + +#endif /* COAP_COAP_PDU_INTERNAL_H_ */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_prng.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_prng.h new file mode 100644 index 00000000000..6d297afaec3 --- /dev/null +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_prng.h @@ -0,0 +1,113 @@ +/* + * coap_prng.h -- Pseudo Random Numbers + * + * Copyright (C) 2010-2020 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_prng.h + * @brief Pseudo Random Numbers + */ + +#ifndef COAP_PRNG_H_ +#define COAP_PRNG_H_ + +/** + * @defgroup coap_prng Pseudo Random Numbers + * API functions for gerating pseudo random numbers + * @{ + */ + +#if defined(WITH_CONTIKI) +#include + +/** + * Fills \p buf with \p len random bytes. This is the default implementation for + * coap_prng(). You might want to change contiki_prng_impl() to use a better + * PRNG on your specific platform. + */ +COAP_STATIC_INLINE int +contiki_prng_impl(unsigned char *buf, size_t len) { + uint16_t v = random_rand(); + while (len > sizeof(v)) { + memcpy(buf, &v, sizeof(v)); + len -= sizeof(v); + buf += sizeof(v); + v = random_rand(); + } + + memcpy(buf, &v, len); + return 1; +} + +#define coap_prng(Buf,Length) contiki_prng_impl((Buf), (Length)) +#define coap_prng_init(Value) random_init((uint16_t)(Value)) + +#elif defined(WITH_LWIP) && defined(LWIP_RAND) + +COAP_STATIC_INLINE int +lwip_prng_impl(unsigned char *buf, size_t len) { + u32_t v = LWIP_RAND(); + while (len > sizeof(v)) { + memcpy(buf, &v, sizeof(v)); + len -= sizeof(v); + buf += sizeof(v); + v = LWIP_RAND(); + } + + memcpy(buf, &v, len); + return 1; +} + +#define coap_prng(Buf,Length) lwip_prng_impl((Buf), (Length)) +#define coap_prng_init(Value) (void)Value + +#else + +/** + * Data type for random number generator function. The function must + * fill @p len bytes of random data into the buffer starting at @p + * out. On success, the function should return 1, zero otherwise. + */ +typedef int (*coap_rand_func_t)(void *out, size_t len); + +/** + * Replaces the current random number generation function with the + * default function @p rng. + * + * @param rng The random number generation function to use. + */ +void coap_set_prng(coap_rand_func_t rng); + +/** + * Seeds the default random number generation function with the given + * @p seed. The default random number generation function will use + * getrandom() if available, ignoring the seed. + * + * @param seed The seed for the pseudo random number generator. + */ +void coap_prng_init(unsigned int seed); + +/** + * Fills @p buf with @p len random bytes using the default pseudo + * random number generator. The default PRNG can be changed with + * coap_set_prng(). This function returns 1 when @p len random bytes + * have been written to @p buf, zero otherwise. + * + * @param buf The buffer to fill with random bytes. + * @param len The number of random bytes to write into @p buf. + * + * @return 1 on success, 0 otherwise. + */ +int coap_prng(void *buf, size_t len); + +#endif /* POSIX */ + +/** @} */ + +#endif /* COAP_PRNG_H_ */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_resource_internal.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_resource_internal.h new file mode 100644 index 00000000000..cbcc36a664c --- /dev/null +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_resource_internal.h @@ -0,0 +1,141 @@ +/* + * coap_resource_internal.h -- generic resource handling + * + * Copyright (C) 2010,2011,2014-2021 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_resource_internal.h + * @brief Generic resource internal handling + */ + +#ifndef COAP_RESOURCE_INTERNAL_H_ +#define COAP_RESOURCE_INTERNAL_H_ + +#include "uthash.h" + +/** + * @defgroup coap_resource_internal Resources (Internal) + * Structures, Enums and Functions that are not exposed to applications + * @{ + */ + +/** +* Abstraction of attribute associated with a resource. +*/ +struct coap_attr_t { + struct coap_attr_t *next; /**< Pointer to next in chain or NULL */ + coap_str_const_t *name; /**< Name of the attribute */ + coap_str_const_t *value; /**< Value of the attribute (can be NULL) */ + int flags; +}; + +/** +* Abstraction of resource that can be attached to coap_context_t. +* The key is uri_path. +*/ +struct coap_resource_t { + unsigned int dirty:1; /**< set to 1 if resource has changed */ + unsigned int partiallydirty:1; /**< set to 1 if some subscribers have not yet + * been notified of the last change */ + unsigned int observable:1; /**< can be observed */ + unsigned int cacheable:1; /**< can be cached */ + unsigned int is_unknown:1; /**< resource created for unknown handler */ + unsigned int is_proxy_uri:1; /**< resource created for proxy URI handler */ + + /** + * Used to store handlers for the seven coap methods @c GET, @c POST, @c PUT, + * @c DELETE, @c FETCH, @c PATCH and @c IPATCH. + * coap_dispatch() will pass incoming requests to handle_request() and then + * to the handler that corresponds to its request method or generate a 4.05 + * response if no handler is available. + */ + coap_method_handler_t handler[7]; + + UT_hash_handle hh; + + coap_attr_t *link_attr; /**< attributes to be included with the link format */ + coap_subscription_t *subscribers; /**< list of observers for this resource */ + + /** + * Request URI Path for this resource. This field will point into static + * or allocated memory which must remain there for the duration of the + * resource. + */ + coap_str_const_t *uri_path; /**< the key used for hash lookup for this + resource */ + int flags; /**< zero or more COAP_RESOURCE_FLAGS_* or'd together */ + + /** + * The next value for the Observe option. This field must be increased each + * time the resource changes. Only the lower 24 bits are sent. + */ + unsigned int observe; + + /** + * Pointer back to the context that 'owns' this resource. + */ + coap_context_t *context; + + /** + * Count of valid names this host is known by (proxy support) + */ + size_t proxy_name_count; + + /** + * Array valid names this host is known by (proxy support) + */ + coap_str_const_t ** proxy_name_list; + + /** + * This pointer is under user control. It can be used to store context for + * the coap handler. + */ + void *user_data; + +}; + +/** + * Deletes all resources from given @p context and frees their storage. + * + * @param context The CoAP context with the resources to be deleted. + */ +void coap_delete_all_resources(coap_context_t *context); + +#define RESOURCES_ADD(r, obj) \ + HASH_ADD(hh, (r), uri_path->s[0], (obj)->uri_path->length, (obj)) + +#define RESOURCES_DELETE(r, obj) \ + HASH_DELETE(hh, (r), (obj)) + +#define RESOURCES_ITER(r,tmp) \ + coap_resource_t *tmp, *rtmp; \ + HASH_ITER(hh, (r), tmp, rtmp) + +#define RESOURCES_FIND(r, k, res) { \ + HASH_FIND(hh, (r), (k)->s, (k)->length, (res)); \ + } + +/** + * Deletes an attribute. + * Note: This is for internal use only, as it is not deleted from its chain. + * + * @param attr Pointer to a previously created attribute. + * + */ +void coap_delete_attr(coap_attr_t *attr); + +coap_print_status_t coap_print_wellknown(coap_context_t *, + unsigned char *, + size_t *, size_t, + coap_opt_t *); + + +/** @} */ + +#endif /* COAP_RESOURCE_INTERNAL_H_ */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_riot.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_riot.h new file mode 100644 index 00000000000..fc4bfa2e655 --- /dev/null +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_riot.h @@ -0,0 +1,34 @@ +/* coap_riot.h -- RIOT-specific definitions for libcoap + * + * Copyright (C) 2019 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see + * README for terms of use. + */ + +#ifndef COAP_RIOT_H_ +#define COAP_RIOT_H_ + +#ifndef LIBCOAP_MSG_QUEUE_SIZE +/** + * Size of the queue for passing messages between the network + * interface and the coap stack. */ +#define LIBCOAP_MSG_QUEUE_SIZE (32U) +#endif /* LIBCOAP_MSG_QUEUE_SIZE */ + +#ifndef LIBCOAP_MAX_SOCKETS +/** + * Maximum number of sockets that are simultaneously considered for + * reading or writing. */ +#define LIBCOAP_MAX_SOCKETS (16U) +#endif /* LIBCOAP_MAX_SOCKETS */ + +/** + * This function must be called in the RIOT CoAP thread for + * RIOT-specific initialization. + */ +void coap_riot_startup(void); + +#endif /* COAP_RIOT_H_ */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_session.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_session.h new file mode 100644 index 00000000000..6c49b78e97d --- /dev/null +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_session.h @@ -0,0 +1,591 @@ +/* coap_session.h -- Session management for libcoap +* +* Copyright (C) 2017 Jean-Claue Michelou +* + * SPDX-License-Identifier: BSD-2-Clause + * +* This file is part of the CoAP library libcoap. Please see +* README for terms of use. +*/ + +/** + * @file coap_session.h + * @brief Defines the application visible session information + */ + +#ifndef COAP_SESSION_H_ +#define COAP_SESSION_H_ + +/** + * @defgroup session Sessions + * API functions for CoAP Sessions + * @{ + */ + +/** +* Abstraction of a fixed point number that can be used where necessary instead +* of a float. 1,000 fractional bits equals one integer +*/ +typedef struct coap_fixed_point_t { + uint16_t integer_part; /**< Integer part of fixed point variable */ + uint16_t fractional_part; /**< Fractional part of fixed point variable + 1/1000 (3 points) precision */ +} coap_fixed_point_t; + +#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS) +#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS) + +/** + * coap_session_type_t values + */ +typedef enum coap_session_type_t { + COAP_SESSION_TYPE_NONE = 0, /**< Not defined */ + COAP_SESSION_TYPE_CLIENT, /**< client-side */ + COAP_SESSION_TYPE_SERVER, /**< server-side */ + COAP_SESSION_TYPE_HELLO, /**< server-side ephemeral session for + responding to a client hello */ +} coap_session_type_t; + +/** + * coap_session_state_t values + */ +typedef enum coap_session_state_t { + COAP_SESSION_STATE_NONE = 0, + COAP_SESSION_STATE_CONNECTING, + COAP_SESSION_STATE_HANDSHAKE, + COAP_SESSION_STATE_CSM, + COAP_SESSION_STATE_ESTABLISHED, +} coap_session_state_t; + +/** + * Increment reference counter on a session. + * + * @param session The CoAP session. + * @return same as session + */ +coap_session_t *coap_session_reference(coap_session_t *session); + +/** + * Decrement reference counter on a session. + * Note that the session may be deleted as a result and should not be used + * after this call. + * + * @param session The CoAP session. + */ +void coap_session_release(coap_session_t *session); + +/** + * Notify session that it has failed. This cleans up any outstanding / queued + * transmissions, observations etc.. + * + * @param session The CoAP session. + * @param reason The reason why the session was disconnected. + */ +void coap_session_disconnected(coap_session_t *session, + coap_nack_reason_t reason); + +/** + * Stores @p data with the given session. This function overwrites any value + * that has previously been stored with @p session. + * + * @param session The CoAP session. + * @param data The pointer to the data to store. + */ +void coap_session_set_app_data(coap_session_t *session, void *data); + +/** + * Returns any application-specific data that has been stored with @p + * session using the function coap_session_set_app_data(). This function will + * return @c NULL if no data has been stored. + * + * @param session The CoAP session. + * + * @return Pointer to the stored data or @c NULL. + */ +void *coap_session_get_app_data(const coap_session_t *session); + +/** + * Get the remote IP address from the session. + * + * @param session The CoAP session. + * + * @return The session's remote address or @c NULL on failure. + */ +const coap_address_t *coap_session_get_addr_remote( + const coap_session_t *session); + +/** + * Get the local IP address from the session. + * + * @param session The CoAP session. + * + * @return The session's local address or @c NULL on failure. + */ +const coap_address_t *coap_session_get_addr_local( + const coap_session_t *session); + +/** + * Get the session protocol type + * + * @param session The CoAP session. + * + * @return The session's protocol type + */ +coap_proto_t coap_session_get_proto(const coap_session_t *session); + +/** + * Get the session type + * + * @param session The CoAP session. + * + * @return The session's type + */ +coap_session_type_t coap_session_get_type(const coap_session_t *session); + +/** + * Get the session state + * + * @param session The CoAP session. + * + * @return The session's state + */ +coap_session_state_t coap_session_get_state(const coap_session_t *session); + +/** + * Get the session if index + * + * @param session The CoAP session. + * + * @return The session's if index, or @c -1 on error. + */ +int coap_session_get_ifindex(const coap_session_t *session); + +/** + * Get the session TLS security ptr (TLS type dependent) + * + * OpenSSL: SSL* + * GnuTLS: gnutls_session_t (implicit *) + * Mbed TLS: mbedtls_ssl_context* + * TinyDTLS: struct dtls_context* + * + * @param session The CoAP session. + * @param tls_lib Updated with the library type. + * + * @return The session TLS ptr or @c NULL if not set up + */ +void *coap_session_get_tls(const coap_session_t *session, + coap_tls_library_t *tls_lib); + +/** + * Get the session context + * + * @param session The CoAP session. + * + * @return The session's context + */ +coap_context_t *coap_session_get_context(const coap_session_t *session); + +/** + * Set the session type to client. Typically used in a call-home server. + * The session needs to be of type COAP_SESSION_TYPE_SERVER. + * Note: If this function is successful, the session reference count is + * incremented and a subsequent coap_session_release() taking the + * reference count to 0 will cause the session to be freed off. + * + * @param session The CoAP session. + * + * @return @c 1 if updated, @c 0 on failure. + */ +int coap_session_set_type_client(coap_session_t *session); + +/** + * Set the session MTU. This is the maximum message size that can be sent, + * excluding IP and UDP overhead. + * + * @param session The CoAP session. + * @param mtu maximum message size + */ +void coap_session_set_mtu(coap_session_t *session, unsigned mtu); + +/** + * Get maximum acceptable PDU size + * + * @param session The CoAP session. + * @return maximum PDU size, not including header (but including token). + */ +size_t coap_session_max_pdu_size(const coap_session_t *session); + +/** +* Creates a new client session to the designated server. +* @param ctx The CoAP context. +* @param local_if Address of local interface. It is recommended to use NULL to let the operating system choose a suitable local interface. If an address is specified, the port number should be zero, which means that a free port is automatically selected. +* @param server The server's address. If the port number is zero, the default port for the protocol will be used. +* @param proto Protocol. +* +* @return A new CoAP session or NULL if failed. Call coap_session_release to free. +*/ +coap_session_t *coap_new_client_session( + coap_context_t *ctx, + const coap_address_t *local_if, + const coap_address_t *server, + coap_proto_t proto +); + +/** +* Creates a new client session to the designated server with PSK credentials +* @param ctx The CoAP context. +* @param local_if Address of local interface. It is recommended to use NULL to let the operating system choose a suitable local interface. If an address is specified, the port number should be zero, which means that a free port is automatically selected. +* @param server The server's address. If the port number is zero, the default port for the protocol will be used. +* @param proto Protocol. +* @param identity PSK client identity +* @param key PSK shared key +* @param key_len PSK shared key length +* +* @return A new CoAP session or NULL if failed. Call coap_session_release to free. +*/ +coap_session_t *coap_new_client_session_psk( + coap_context_t *ctx, + const coap_address_t *local_if, + const coap_address_t *server, + coap_proto_t proto, + const char *identity, + const uint8_t *key, + unsigned key_len +); + +/** +* Creates a new client session to the designated server with PSK credentials +* @param ctx The CoAP context. +* @param local_if Address of local interface. It is recommended to use NULL to +* let the operating system choose a suitable local interface. +* If an address is specified, the port number should be zero, +* which means that a free port is automatically selected. +* @param server The server's address. If the port number is zero, the default +* port for the protocol will be used. +* @param proto CoAP Protocol. +* @param setup_data PSK parameters. +* +* @return A new CoAP session or NULL if failed. Call coap_session_release() +* to free. +*/ +coap_session_t *coap_new_client_session_psk2( + coap_context_t *ctx, + const coap_address_t *local_if, + const coap_address_t *server, + coap_proto_t proto, + coap_dtls_cpsk_t *setup_data +); + +/** + * Get the server session's current Identity Hint (PSK). + * + * @param session The current coap_session_t object. + * + * @return @c hint if successful, else @c NULL. + */ +const coap_bin_const_t * coap_session_get_psk_hint( + const coap_session_t *session); + +/** + * Get the session's current pre-shared key (PSK). + * + * @param session The current coap_session_t object. + * + * @return @c psk_key if successful, else @c NULL. + */ +const coap_bin_const_t * coap_session_get_psk_key( + const coap_session_t *session); + +/** +* Creates a new client session to the designated server with PKI credentials +* @param ctx The CoAP context. +* @param local_if Address of local interface. It is recommended to use NULL to +* let the operating system choose a suitable local interface. +* If an address is specified, the port number should be zero, +* which means that a free port is automatically selected. +* @param server The server's address. If the port number is zero, the default +* port for the protocol will be used. +* @param proto CoAP Protocol. +* @param setup_data PKI parameters. +* +* @return A new CoAP session or NULL if failed. Call coap_session_release() +* to free. +*/ +coap_session_t *coap_new_client_session_pki( + coap_context_t *ctx, + const coap_address_t *local_if, + const coap_address_t *server, + coap_proto_t proto, + coap_dtls_pki_t *setup_data +); + +/** + * Initializes the token value to use as a starting point. + * + * @param session The current coap_session_t object. + * @param length The length of the token (0 - 8 bytes). + * @param token The token data. + * + */ +void coap_session_init_token(coap_session_t *session, size_t length, + const uint8_t *token); + +/** + * Creates a new token for use. + * + * @param session The current coap_session_t object. + * @param length Updated with the length of the new token. + * @param token Updated with the new token data (must be 8 bytes long). + * + */ +void coap_session_new_token(coap_session_t *session, size_t *length, + uint8_t *token); + +/** + * @ingroup logging + * Get session description. + * + * @param session The CoAP session. + * @return description string. + */ +const char *coap_session_str(const coap_session_t *session); + +/** +* Create a new endpoint for communicating with peers. +* +* @param context The coap context that will own the new endpoint +* @param listen_addr Address the endpoint will listen for incoming requests on or originate outgoing requests from. Use NULL to specify that no incoming request will be accepted and use a random endpoint. +* @param proto Protocol used on this endpoint +*/ + +coap_endpoint_t *coap_new_endpoint(coap_context_t *context, const coap_address_t *listen_addr, coap_proto_t proto); + +/** +* Set the endpoint's default MTU. This is the maximum message size that can be +* sent, excluding IP and UDP overhead. +* +* @param endpoint The CoAP endpoint. +* @param mtu maximum message size +*/ +void coap_endpoint_set_default_mtu(coap_endpoint_t *endpoint, unsigned mtu); + +void coap_free_endpoint(coap_endpoint_t *ep); + +/** @} */ + +/** + * @ingroup logging +* Get endpoint description. +* +* @param endpoint The CoAP endpoint. +* @return description string. +*/ +const char *coap_endpoint_str(const coap_endpoint_t *endpoint); + +coap_session_t *coap_session_get_by_peer(const coap_context_t *ctx, + const coap_address_t *remote_addr, int ifindex); + + /** + * @defgroup cc Rate Control + * The transmission parameters for CoAP rate control ("Congestion + * Control" in stream-oriented protocols) are defined in + * https://tools.ietf.org/html/rfc7252#section-4.8 + * @{ + */ + + /** + * Number of seconds when to expect an ACK or a response to an + * outstanding CON message. + * RFC 7252, Section 4.8 Default value of ACK_TIMEOUT is 2 + * + * Configurable using coap_session_set_ack_timeout() + */ +#define COAP_DEFAULT_ACK_TIMEOUT ((coap_fixed_point_t){2,0}) + + /** + * A factor that is used to randomize the wait time before a message + * is retransmitted to prevent synchronization effects. + * RFC 7252, Section 4.8 Default value of ACK_RANDOM_FACTOR is 1.5 + * + * Configurable using coap_session_set_ack_random_factor() + */ +#define COAP_DEFAULT_ACK_RANDOM_FACTOR ((coap_fixed_point_t){1,500}) + + /** + * Number of message retransmissions before message sending is stopped + * RFC 7252, Section 4.8 Default value of MAX_RETRANSMIT is 4 + * + * Configurable using coap_session_set_max_retransmit() + */ +#define COAP_DEFAULT_MAX_RETRANSMIT 4 + + /** + * The number of simultaneous outstanding interactions that a client + * maintains to a given server. + * RFC 7252, Section 4.8 Default value of NSTART is 1 + */ +#define COAP_DEFAULT_NSTART 1 + + /** + * The maximum number of seconds before sending back a response to a + * multicast request. + * RFC 7252, Section 4.8 DEFAULT_LEISURE is 5. + */ +#ifndef COAP_DEFAULT_LEISURE +#define COAP_DEFAULT_LEISURE (5U) +#endif /* COAP_DEFAULT_LEISURE */ + + /** + * The MAX_TRANSMIT_SPAN definition for the session (s). + * + * RFC 7252, Section 4.8.2 Calculation of MAX_TRAMSMIT_SPAN + * ACK_TIMEOUT * ((2 ** (MAX_RETRANSMIT)) - 1) * ACK_RANDOM_FACTOR + */ +#define COAP_MAX_TRANSMIT_SPAN(s) \ + ((s->ack_timeout.integer_part * 1000 + s->ack_timeout.fractional_part) * \ + ((1 << (s->max_retransmit)) -1) * \ + (s->ack_random_factor.integer_part * 1000 + \ + s->ack_random_factor.fractional_part) \ + / 1000000) + + /** + * The MAX_TRANSMIT_WAIT definition for the session (s). + * + * RFC 7252, Section 4.8.2 Calculation of MAX_TRAMSMIT_WAIT + * ACK_TIMEOUT * ((2 ** (MAX_RETRANSMIT + 1)) - 1) * ACK_RANDOM_FACTOR + */ +#define COAP_MAX_TRANSMIT_WAIT(s) \ + ((s->ack_timeout.integer_part * 1000 + s->ack_timeout.fractional_part) * \ + ((1 << (s->max_retransmit + 1)) -1) * \ + (s->ack_random_factor.integer_part * 1000 + \ + s->ack_random_factor.fractional_part) \ + / 1000000) + + /** + * The MAX_LATENCY definition. + * RFC 7252, Section 4.8.2 MAX_LATENCY is 100. + */ +#define COAP_MAX_LATENCY 100 + + /** + * The PROCESSING_DELAY definition for the session (s). + * + * RFC 7252, Section 4.8.2 Calculation of PROCESSING_DELAY + * PROCESSING_DELAY set to ACK_TIMEOUT + */ +#define COAP_PROCESSING_DELAY(s) \ + ((s->ack_timeout.integer_part * 1000 + s->ack_timeout.fractional_part + 500) \ + / 1000) + + /** + * The MAX_RTT definition for the session (s). + * + * RFC 7252, Section 4.8.2 Calculation of MAX_RTT + * (2 * MAX_LATENCY) + PROCESSING_DELAY + */ +#define COAP_MAX_RTT(s) \ + ((2 * COAP_MAX_LATENCY) + COAP_PROCESSING_DELAY(s)) + + /** + * The EXCHANGE_LIFETIME definition for the session (s). + * + * RFC 7252, Section 4.8.2 Calculation of EXCHANGE_LIFETIME + * MAX_TRANSMIT_SPAN + (2 * MAX_LATENCY) + PROCESSING_DELAY + */ +#define COAP_EXCHANGE_LIFETIME(s) \ + (COAP_MAX_TRANSMIT_SPAN(s) + (2 * COAP_MAX_LATENCY) + COAP_PROCESSING_DELAY(s)) + + /** + * The NON_LIFETIME definition for the session (s). + * + * RFC 7252, Section 4.8.2 Calculation of NON_LIFETIME + * MAX_TRANSMIT_SPAN + MAX_LATENCY + */ +#define COAP_NON_LIFETIME(s) \ + (COAP_MAX_TRANSMIT_SPAN(s) + COAP_MAX_LATENCY) + + /** @} */ + +/** +* Set the CoAP maximum retransmit count before failure +* +* Number of message retransmissions before message sending is stopped +* +* @param session The CoAP session. +* @param value The value to set to. The default is 4 and should not normally +* get changed. +*/ +void coap_session_set_max_retransmit(coap_session_t *session, + unsigned int value); + +/** +* Set the CoAP initial ack response timeout before the next re-transmit +* +* Number of seconds when to expect an ACK or a response to an +* outstanding CON message. +* +* @param session The CoAP session. +* @param value The value to set to. The default is 2 and should not normally +* get changed. +*/ +void coap_session_set_ack_timeout(coap_session_t *session, + coap_fixed_point_t value); + +/** +* Set the CoAP ack randomize factor +* +* A factor that is used to randomize the wait time before a message +* is retransmitted to prevent synchronization effects. +* +* @param session The CoAP session. +* @param value The value to set to. The default is 1.5 and should not normally +* get changed. +*/ +void coap_session_set_ack_random_factor(coap_session_t *session, + coap_fixed_point_t value); + +/** +* Get the CoAP maximum retransmit before failure +* +* Number of message retransmissions before message sending is stopped +* +* @param session The CoAP session. +* +* @return Current maximum retransmit value +*/ +unsigned int coap_session_get_max_retransmit(const coap_session_t *session); + +/** +* Get the CoAP initial ack response timeout before the next re-transmit +* +* Number of seconds when to expect an ACK or a response to an +* outstanding CON message. +* +* @param session The CoAP session. +* +* @return Current ack response timeout value +*/ +coap_fixed_point_t coap_session_get_ack_timeout(const coap_session_t *session); + +/** +* Get the CoAP ack randomize factor +* +* A factor that is used to randomize the wait time before a message +* is retransmitted to prevent synchronization effects. +* +* @param session The CoAP session. +* +* @return Current ack randomize value +*/ +coap_fixed_point_t coap_session_get_ack_random_factor( + const coap_session_t *session); + +/** + * Send a ping message for the session. + * @param session The CoAP session. + * + * @return COAP_INVALID_MID if there is an error + */ +coap_mid_t coap_session_send_ping(coap_session_t *session); + +#endif /* COAP_SESSION_H */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_session_internal.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_session_internal.h new file mode 100644 index 00000000000..1fd2de9ecf1 --- /dev/null +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_session_internal.h @@ -0,0 +1,295 @@ +/* + * coap_session_internal.h -- Structures, Enums & Functions that are not + * exposed to application programming + * + * Copyright (C) 2010-2019 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_session_internal.h + * @brief COAP session internal information + */ + +#ifndef COAP_SESSION_INTERNAL_H_ +#define COAP_SESSION_INTERNAL_H_ + +#include "coap_io_internal.h" + +#define COAP_DEFAULT_SESSION_TIMEOUT 300 +#define COAP_PARTIAL_SESSION_TIMEOUT_TICKS (30 * COAP_TICKS_PER_SECOND) +#define COAP_DEFAULT_MAX_HANDSHAKE_SESSIONS 100 + +/** + * @defgroup session_internal Sessions (Internal) + * CoAP Session Structures, Enums and Functions that are not exposed to + * applications + * @{ + */ + +/** + * Only used for servers for hashing incoming packets. Cannot have local IP + * address as this may be an initial multicast and subsequent unicast address + */ +struct coap_addr_hash_t { + coap_address_t remote; /**< remote address and port */ + uint16_t lport; /**< local port */ + coap_proto_t proto; /**< CoAP protocol */ +}; + +/** + * Abstraction of virtual session that can be attached to coap_context_t + * (client) or coap_endpoint_t (server). + */ +struct coap_session_t { + coap_proto_t proto; /**< protocol used */ + coap_session_type_t type; /**< client or server side socket */ + coap_session_state_t state; /**< current state of relationaship with + peer */ + unsigned ref; /**< reference count from queues */ + size_t tls_overhead; /**< overhead of TLS layer */ + size_t mtu; /**< path or CSM mtu */ + coap_addr_hash_t addr_hash; /**< Address hash for server incoming packets */ + UT_hash_handle hh; + coap_addr_tuple_t addr_info; /**< key: remote/local address info */ + int ifindex; /**< interface index */ + coap_socket_t sock; /**< socket object for the session, if + any */ + coap_endpoint_t *endpoint; /**< session's endpoint */ + coap_context_t *context; /**< session's context */ + void *tls; /**< security parameters */ + uint16_t tx_mid; /**< the last message id that was used in + this session */ + uint8_t con_active; /**< Active CON request sent */ + uint8_t csm_block_supported; /**< CSM TCP blocks supported */ + coap_mid_t last_ping_mid; /**< the last keepalive message id that was + used in this session */ + coap_queue_t *delayqueue; /**< list of delayed messages waiting to + be sent */ + coap_lg_xmit_t *lg_xmit; /**< list of large transmissions */ + coap_lg_crcv_t *lg_crcv; /**< Client list of expected large receives */ + coap_lg_srcv_t *lg_srcv; /**< Server list of expected large receives */ + size_t partial_write; /**< if > 0 indicates number of bytes + already written from the pdu at the + head of sendqueue */ + uint8_t read_header[8]; /**< storage space for header of incoming + message header */ + size_t partial_read; /**< if > 0 indicates number of bytes + already read for an incoming message */ + coap_pdu_t *partial_pdu; /**< incomplete incoming pdu */ + coap_tick_t last_rx_tx; + coap_tick_t last_tx_rst; + coap_tick_t last_ping; + coap_tick_t last_pong; + coap_tick_t csm_tx; + coap_dtls_cpsk_t cpsk_setup_data; /**< client provided PSK initial setup + data */ + coap_bin_const_t *psk_identity; /**< If client, this field contains the + current identity for server; When this + field is NULL, the current identity is + contained in cpsk_setup_data + + If server, this field contains the client + provided identity. + + Value maintained internally */ + coap_bin_const_t *psk_key; /**< If client, this field contains the + current pre-shared key for server; + When this field is NULL, the current + key is contained in cpsk_setup_data + + If server, this field contains the + client's current key. + + Value maintained internally */ + coap_bin_const_t *psk_hint; /**< If client, this field contains the + server provided identity hint. + + If server, this field contains the + current hint for the client; When this + field is NULL, the current hint is + contained in context->spsk_setup_data + + Value maintained internally */ + void *app; /**< application-specific data */ + unsigned int max_retransmit; /**< maximum re-transmit count (default + 4) */ + coap_fixed_point_t ack_timeout; /**< timeout waiting for ack (default 2 + secs) */ + coap_fixed_point_t ack_random_factor; /**< ack random factor backoff (default + 1.5) */ + unsigned int dtls_timeout_count; /**< dtls setup retry counter */ + int dtls_event; /**< Tracking any (D)TLS events on this + sesison */ + uint8_t block_mode; /**< Zero or more COAP_BLOCK_ or'd options */ + uint64_t tx_token; /**< Next token number to use */ +}; + +/** + * Abstraction of virtual endpoint that can be attached to coap_context_t. The + * keys (port, bind_addr) must uniquely identify this endpoint. + */ +struct coap_endpoint_t { + struct coap_endpoint_t *next; + coap_context_t *context; /**< endpoint's context */ + coap_proto_t proto; /**< protocol used on this interface */ + uint16_t default_mtu; /**< default mtu for this interface */ + coap_socket_t sock; /**< socket object for the interface, if + any */ + coap_address_t bind_addr; /**< local interface address */ + coap_session_t *sessions; /**< hash table or list of active sessions */ +}; + +/** + * Notify session transport has just connected and CSM exchange can now start. + * + * @param session The CoAP session. + */ +void coap_session_send_csm(coap_session_t *session); + +/** + * Notify session that it has just connected or reconnected. + * + * @param session The CoAP session. + */ +void coap_session_connected(coap_session_t *session); + +/** + * Refresh the session's current Identity Hint (PSK). + * Note: A copy of @p psk_hint is maintained in the session by libcoap. + * + * @param session The current coap_session_t object. + * @param psk_hint If NULL, the Identity Hint will revert to the + * initial Identity Hint used at session setup. + * + * @return @c 1 if successful, else @c 0. + */ +int coap_session_refresh_psk_hint(coap_session_t *session, + const coap_bin_const_t *psk_hint); + +/** + * Refresh the session's current pre-shared key (PSK). + * Note: A copy of @p psk_key is maintained in the session by libcoap. + * + * @param session The current coap_session_t object. + * @param psk_key If NULL, the pre-shared key will revert to the + * initial pre-shared key used as session setup. + * + * @return @c 1 if successful, else @c 0. + */ +int coap_session_refresh_psk_key(coap_session_t *session, + const coap_bin_const_t *psk_key); + +/** + * Creates a new server session for the specified endpoint. + * @param ctx The CoAP context. + * @param ep An endpoint where an incoming connection request is pending. + * + * @return A new CoAP session or NULL if failed. Call coap_session_release to + * add to unused queue. + */ +coap_session_t *coap_new_server_session( + coap_context_t *ctx, + coap_endpoint_t *ep +); + +/** + * Function interface for datagram data transmission. This function returns + * the number of bytes that have been transmitted, or a value less than zero + * on error. + * + * @param session Session to send data on. + * @param data The data to send. + * @param datalen The actual length of @p data. + * + * @return The number of bytes written on success, or a value + * less than zero on error. + */ +ssize_t coap_session_send(coap_session_t *session, + const uint8_t *data, size_t datalen); + +/** + * Function interface for stream data transmission. This function returns + * the number of bytes that have been transmitted, or a value less than zero + * on error. The number of bytes written may be less than datalen because of + * congestion control. + * + * @param session Session to send data on. + * @param data The data to send. + * @param datalen The actual length of @p data. + * + * @return The number of bytes written on success, or a value + * less than zero on error. + */ +ssize_t coap_session_write(coap_session_t *session, + const uint8_t *data, size_t datalen); + +/** + * Send a pdu according to the session's protocol. This function returns + * the number of bytes that have been transmitted, or a value less than zero + * on error. + * + * @param session Session to send pdu on. + * @param pdu The pdu to send. + * + * @return The number of bytes written on success, or a value + * less than zero on error. + */ +ssize_t coap_session_send_pdu(coap_session_t *session, coap_pdu_t *pdu); + +ssize_t +coap_session_delay_pdu(coap_session_t *session, coap_pdu_t *pdu, + coap_queue_t *node); + +/** + * Lookup the server session for the packet received on an endpoint, or create + * a new one. + * + * @param endpoint Active endpoint the packet was received on. + * @param packet Received packet. + * @param now The current time in ticks. + * @return The CoAP session or @c NULL if error. + */ +coap_session_t *coap_endpoint_get_session(coap_endpoint_t *endpoint, + const coap_packet_t *packet, coap_tick_t now); + +/** + * Create a new DTLS session for the @p session. + * Note: the @p session is released if no DTLS server session can be created. + * + * @ingroup dtls_internal + * + * @param session Session to add DTLS session to + * @param now The current time in ticks. + * + * @return CoAP session or @c NULL if error. + */ +coap_session_t *coap_session_new_dtls_session(coap_session_t *session, + coap_tick_t now); + +void coap_session_free(coap_session_t *session); +void coap_session_mfree(coap_session_t *session); + +/** @} */ + +#define SESSIONS_ADD(e, obj) \ + HASH_ADD(hh, (e), addr_hash, sizeof((obj)->addr_hash), (obj)) + +#define SESSIONS_DELETE(e, obj) \ + HASH_DELETE(hh, (e), (obj)) + +#define SESSIONS_ITER(e, el, rtmp) \ + HASH_ITER(hh, (e), el, rtmp) + +#define SESSIONS_ITER_SAFE(e, el, rtmp) \ +for ((el) = (e); (el) && ((rtmp) = (el)->hh.next, 1); (el) = (rtmp)) + +#define SESSIONS_FIND(e, k, res) { \ + HASH_FIND(hh, (e), &(k), sizeof(k), (res)); \ + } + +#endif /* COAP_SESSION_INTERNAL_H_ */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_subscribe_internal.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_subscribe_internal.h new file mode 100644 index 00000000000..b7702362bee --- /dev/null +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_subscribe_internal.h @@ -0,0 +1,151 @@ +/* + * coap_subscribe_internal.h -- Structures, Enums & Functions that are not + * exposed to application programming + * + * Copyright (C) 2010-2021 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_subscribe_internal.h + * @brief COAP subscribe internal information + */ + +#ifndef COAP_SUBSCRIBE_INTERNAL_H_ +#define COAP_SUBSCRIBE_INTERNAL_H_ + +/** + * @defgroup subscribe_internal Observe Subscription (Internal) + * CoAP Observe Subscription Structures, Enums and Functions that are not + * exposed to applications + * @{ + */ + +#ifndef COAP_OBS_MAX_NON +/** + * Number of notifications that may be sent non-confirmable before a confirmable + * message is sent to detect if observers are alive. The maximum allowed value + * here is @c 15. + */ +#define COAP_OBS_MAX_NON 5 +#endif /* COAP_OBS_MAX_NON */ + +#ifndef COAP_OBS_MAX_FAIL +/** + * Number of confirmable notifications that may fail (i.e. time out without + * being ACKed) before an observer is removed. The maximum value for + * COAP_OBS_MAX_FAIL is @c 3. + */ +#define COAP_OBS_MAX_FAIL 3 +#endif /* COAP_OBS_MAX_FAIL */ + +/** Subscriber information */ +struct coap_subscription_t { + struct coap_subscription_t *next; /**< next element in linked list */ + struct coap_session_t *session; /**< subscriber session */ + + unsigned int non_cnt:4; /**< up to 15 non-confirmable notifies allowed */ + unsigned int fail_cnt:2; /**< up to 3 confirmable notifies can fail */ + unsigned int dirty:1; /**< set if the notification temporarily could not be + * sent (in that case, the resource's partially + * dirty flag is set too) */ + coap_cache_key_t *cache_key; /** cache_key to identify requester */ + coap_pdu_t *pdu; /**< PDU to use for additional requests */ +}; + +void coap_subscription_init(coap_subscription_t *); + +/** + * Handles a failed observe notify. + * + * @param context The context holding the resource. + * @param session The session that the observe notify failed on. + * @param token The token used when the observe notify failed. + */ +void +coap_handle_failed_notify(coap_context_t *context, + coap_session_t *session, + const coap_binary_t *token); + +/** + * Checks all known resources to see if they are dirty and then notifies + * subscribed observers. + * + * @param context The context to check for dirty resources. + */ +void coap_check_notify(coap_context_t *context); + +/** + * Adds the specified peer as observer for @p resource. The subscription is + * identified by the given @p token. This function returns the registered + * subscription information if the @p observer has been added, or @c NULL on + * error. + * + * @param resource The observed resource. + * @param session The observer's session + * @param token The token that identifies this subscription. + * @param pdu The requesting pdu. + * + * @return A pointer to the added/updated subscription + * information or @c NULL on error. + */ +coap_subscription_t *coap_add_observer(coap_resource_t *resource, + coap_session_t *session, + const coap_binary_t *token, + const coap_pdu_t *pdu); + +/** + * Returns a subscription object for given @p peer. + * + * @param resource The observed resource. + * @param session The observer's session + * @param token The token that identifies this subscription or @c NULL for + * any token. + * @return A valid subscription if exists or @c NULL otherwise. + */ +coap_subscription_t *coap_find_observer(coap_resource_t *resource, + coap_session_t *session, + const coap_binary_t *token); + +/** + * Flags that data is ready to be sent to observers. + * + * @param context The CoAP context to use. + * @param session The observer's session + * @param token The corresponding token that has been used for the + * subscription. + */ +void coap_touch_observer(coap_context_t *context, + coap_session_t *session, + const coap_binary_t *token); + +/** + * Removes any subscription for @p observer from @p resource and releases the + * allocated storage. The result is @c 1 if an observation relationship with @p + * observer and @p token existed, @c 0 otherwise. + * + * @param resource The observed resource. + * @param session The observer's session. + * @param token The token that identifies this subscription or @c NULL for + * any token. + * @return @c 1 if the observer has been deleted, @c 0 otherwise. + */ +int coap_delete_observer(coap_resource_t *resource, + coap_session_t *session, + const coap_binary_t *token); + +/** + * Removes any subscription for @p session and releases the allocated storage. + * + * @param context The CoAP context to use. + * @param session The observer's session. + */ +void coap_delete_observers(coap_context_t *context, coap_session_t *session); + +/** @} */ + +#endif /* COAP_SUBSCRIBE_INTERNAL_H_ */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_tcp_internal.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_tcp_internal.h new file mode 100644 index 00000000000..4fd31b38d01 --- /dev/null +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_tcp_internal.h @@ -0,0 +1,111 @@ +/* + * coap_tcp_internal.h -- TCP functions for libcoap + * + * Copyright (C) 2019--2020 Olaf Bergmann and others + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_tcp_internal.h + * @brief COAP tcp internal information + */ + +#ifndef COAP_TCP_INTERNAL_H_ +#define COAP_TCP_INTERNAL_H_ + +#include "coap_io.h" + +/** + * @defgroup tcp TCP Support (Internal) + * CoAP TCP Structures, Enums and Functions that are not exposed to + * applications + * @{ + */ + +#if !COAP_DISABLE_TCP + +/** + * Create a new TCP socket and initiate the connection + * + * Internal function. + * + * @param sock Where socket information is to be filled in + * @param local_if The local address to use or NULL + * @param server The address to connect to + * @param default_port The port to use if not set in @p server + * @param local_addr Filled in after connection initiation with + * the local address + * @param remote_addr Filled in after connection initiation with + * the remote address + * + * @return @c 1 if succesful, @c 0 if failure of some sort +*/ +int +coap_socket_connect_tcp1(coap_socket_t *sock, + const coap_address_t *local_if, + const coap_address_t *server, + int default_port, + coap_address_t *local_addr, + coap_address_t *remote_addr); + +/** + * Complete the TCP Connection + * + * Internal function. + * + * @param sock The socket information to use + * @param local_addr Filled in with the final local address + * @param remote_addr Filled in with the final remote address + * + * @return @c 1 if succesful, @c 0 if failure of some sort +*/ +int +coap_socket_connect_tcp2(coap_socket_t *sock, + coap_address_t *local_addr, + coap_address_t *remote_addr); + +/** + * Create a new TCP socket and then listen for new incoming TCP sessions + * + * Internal function. + * + * @param sock Where socket information is to be filled in + * @param listen_addr The address to be listening for new incoming sessions + * @param bound_addr Filled in with the address that the TCP layer + * is listening on for new incoming TCP sessions + * + * @return @c 1 if succesful, @c 0 if failure of some sort +*/ +int +coap_socket_bind_tcp(coap_socket_t *sock, + const coap_address_t *listen_addr, + coap_address_t *bound_addr); + +/** + * Accept a new incoming TCP session + * + * Internal function. + * + * @param server The socket information to use to accept the TCP connection + * @param new_client Filled in socket information with the new incoming + * session information + * @param local_addr Filled in with the local address + * @param remote_addr Filled in with the remote address + * + * @return @c 1 if succesful, @c 0 if failure of some sort +*/ +int +coap_socket_accept_tcp(coap_socket_t *server, + coap_socket_t *new_client, + coap_address_t *local_addr, + coap_address_t *remote_addr); + +#endif /* !COAP_DISABLE_TCP */ + +/** @} */ + +#endif /* COAP_TCP_INTERNAL_H_ */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/coap_time.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_time.h similarity index 80% rename from tools/sdk/esp32c3/include/coap/libcoap/include/coap2/coap_time.h rename to tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_time.h index e4a8e7c7c73..baa8650eaff 100644 --- a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/coap_time.h +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/coap_time.h @@ -3,6 +3,8 @@ * * Copyright (C) 2010-2019 Olaf Bergmann * + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ @@ -47,6 +49,10 @@ COAP_STATIC_INLINE coap_time_t coap_ticks_to_rt(coap_tick_t t) { return t / COAP_TICKS_PER_SECOND; } +COAP_STATIC_INLINE uint64_t coap_ticks_to_rt_us(coap_tick_t t) { + return (uint64_t)t * 1000000 / COAP_TICKS_PER_SECOND; +} + #elif defined(WITH_CONTIKI) #include "clock.h" @@ -75,7 +81,38 @@ COAP_STATIC_INLINE coap_time_t coap_ticks_to_rt(coap_tick_t t) { return t / COAP_TICKS_PER_SECOND; } -#else +COAP_STATIC_INLINE uint64_t coap_ticks_to_rt_us(coap_tick_t t) { + return (uint64_t)t * 1000000 / COAP_TICKS_PER_SECOND; +} + +#elif defined(RIOT_VERSION) +#include + +#define COAP_TICKS_PER_SECOND (XTIMER_HZ) + +typedef uint64_t coap_tick_t; +typedef int64_t coap_tick_diff_t; +typedef uint32_t coap_time_t; + +static inline void coap_clock_init(void) {} + +static inline void coap_ticks(coap_tick_t *t) { + *t = xtimer_now_usec64(); +} + +static inline coap_time_t coap_ticks_to_rt(coap_tick_t t) { + return t / 1000000UL; +} + +static inline uint64_t coap_ticks_to_rt_us(coap_tick_t t) { + return t; +} + +static inline coap_tick_t coap_ticks_from_rt_us(uint64_t t) { + return t / 1000000UL; +} +#else /* !WITH_LWIP && !WITH_CONTIKI && !RIOT_VERSION */ + #include /** diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/encode.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/encode.h similarity index 61% rename from tools/sdk/esp32c3/include/coap/libcoap/include/coap2/encode.h rename to tools/sdk/esp32c3/include/coap/libcoap/include/coap3/encode.h index b6d1524443c..a79146fc862 100644 --- a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/encode.h +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/encode.h @@ -3,6 +3,8 @@ * * Copyright (C) 2010-2012 Olaf Bergmann * + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ @@ -18,15 +20,6 @@ #include -#define Nn 8 /* duplicate definition of N if built on sky motes */ -#define ENCODE_HEADER_SIZE 4 -#define HIBIT (1 << (Nn - 1)) -#define EMASK ((1 << ENCODE_HEADER_SIZE) - 1) -#define MMASK ((1 << Nn) - 1 - EMASK) -#define MAX_VALUE ( (1 << Nn) - (1 << ENCODE_HEADER_SIZE) ) * (1 << ((1 << ENCODE_HEADER_SIZE) - 1)) - -#define COAP_PSEUDOFP_DECODE_8_4(r) (r < HIBIT ? r : (r & MMASK) << (r & EMASK)) - #ifndef HAVE_FLS /* include this only if fls() is not available */ extern int coap_fls(unsigned int i); @@ -41,28 +34,41 @@ extern int coap_flsll(long long i); #define coap_flsll(i) flsll(i) #endif -/* ls and s must be integer variables */ -#define COAP_PSEUDOFP_ENCODE_8_4_DOWN(v,ls) (v < HIBIT ? v : (ls = coap_fls(v) - Nn, (v >> ls) & MMASK) + ls) -#define COAP_PSEUDOFP_ENCODE_8_4_UP(v,ls,s) (v < HIBIT ? v : (ls = coap_fls(v) - Nn, (s = (((v + ((1<> ls) & MMASK)), s == 0 ? HIBIT + ls + 1 : s + ls)) +/** + * @defgroup encode Encode / Decode API + * API functions for endoding/decoding CoAP options. + * @{ + */ + +/** + * Decodes multiple-length byte sequences. @p buf points to an input byte + * sequence of length @p length. Returns the up to 4 byte decoded value. + * + * @param buf The input byte sequence to decode from + * @param length The length of the input byte sequence + * + * @return The decoded value + */ +unsigned int coap_decode_var_bytes(const uint8_t *buf, size_t length); /** * Decodes multiple-length byte sequences. @p buf points to an input byte - * sequence of length @p length. Returns the decoded value. + * sequence of length @p length. Returns the up to 8 byte decoded value. * * @param buf The input byte sequence to decode from * @param length The length of the input byte sequence * * @return The decoded value */ -unsigned int coap_decode_var_bytes(const uint8_t *buf, unsigned int length); +uint64_t coap_decode_var_bytes8(const uint8_t *buf, size_t length); /** * Encodes multiple-length byte sequences. @p buf points to an output buffer of - * sufficient length to store the encoded bytes. @p value is the value to - * encode. + * sufficient length to store the encoded bytes. @p value is the 4 byte value + * to encode. * Returns the number of bytes used to encode @p value or 0 on error. * - * @param buf The output buffer to decode into + * @param buf The output buffer to encode into * @param length The output buffer size to encode into (must be sufficient) * @param value The value to encode into the buffer * @@ -72,6 +78,24 @@ unsigned int coap_encode_var_safe(uint8_t *buf, size_t length, unsigned int value); +/** + * Encodes multiple-length byte sequences. @p buf points to an output buffer of + * sufficient length to store the encoded bytes. @p value is the 8 byte value + * to encode. + * Returns the number of bytes used to encode @p value or 0 on error. + * + * @param buf The output buffer to encode into + * @param length The output buffer size to encode into (must be sufficient) + * @param value The value to encode into the buffer + * + * @return The number of bytes used to encode @p value or @c 0 on error. + */ +unsigned int coap_encode_var_safe8(uint8_t *buf, + size_t length, + uint64_t value); + +/** @} */ + /** * @deprecated Use coap_encode_var_safe() instead. * Provided for backward compatibility. As @p value has a diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/libcoap.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/libcoap.h similarity index 86% rename from tools/sdk/esp32c3/include/coap/libcoap/include/coap2/libcoap.h rename to tools/sdk/esp32c3/include/coap/libcoap/include/coap3/libcoap.h index 77ba5db23e2..60ca3b64b90 100644 --- a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/libcoap.h +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/libcoap.h @@ -3,6 +3,8 @@ * * Copyright (C) 2015 Carsten Schoenert * + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ @@ -46,6 +48,13 @@ typedef USHORT in_port_t; # define COAP_DEPRECATED __attribute__ ((deprecated)) # endif #endif +#ifndef COAP_UNUSED +# ifdef __GNUC__ +# define COAP_UNUSED __attribute__((unused)) +# else /* __GNUC__ */ +# define COAP_UNUSED +# endif /* __GNUC__ */ +#endif /* COAP_UNUSED */ void coap_startup(void); diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/lwippools.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/lwippools.h similarity index 66% rename from tools/sdk/esp32c3/include/coap/libcoap/include/coap2/lwippools.h rename to tools/sdk/esp32c3/include/coap/libcoap/include/coap3/lwippools.h index cb90d8099db..445bce4a94a 100644 --- a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/lwippools.h +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/lwippools.h @@ -1,4 +1,6 @@ /* + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ @@ -9,10 +11,10 @@ * include this or include something more generic which includes this), and * MEMP_USE_CUSTOM_POOLS has to be set in lwipopts.h. */ -#include "coap_config.h" -#include -#include -#include +#include "coap_internal.h" +#include "net.h" +#include "resource.h" +#include "subscribe.h" #ifndef MEMP_NUM_COAPCONTEXT #define MEMP_NUM_COAPCONTEXT 1 @@ -67,6 +69,34 @@ #define MEMP_LEN_COAPSTRING 32 #endif +#ifndef MEMP_NUM_COAPCACHE_KEYS +#define MEMP_NUM_COAPCACHE_KEYS (2U) +#endif /* MEMP_NUM_COAPCACHE_KEYS */ + +#ifndef MEMP_NUM_COAPCACHE_ENTRIES +#define MEMP_NUM_COAPCACHE_ENTRIES (2U) +#endif /* MEMP_NUM_COAPCACHE_ENTRIES */ + +#ifndef MEMP_NUM_COAPPDUBUF +#define MEMP_NUM_COAPPDUBUF 2 +#endif + +#ifndef MEMP_LEN_COAPPDUBUF +#define MEMP_LEN_COAPPDUBUF 32 +#endif + +#ifndef MEMP_NUM_COAPLGXMIT +#define MEMP_NUM_COAPLGXMIT 2 +#endif + +#ifndef MEMP_NUM_COAPLGCRCV +#define MEMP_NUM_COAPLGCRCV 2 +#endif + +#ifndef MEMP_NUM_COAPLGSRCV +#define MEMP_NUM_COAPLGSRCV 2 +#endif + LWIP_MEMPOOL(COAP_CONTEXT, MEMP_NUM_COAPCONTEXT, sizeof(coap_context_t), "COAP_CONTEXT") LWIP_MEMPOOL(COAP_ENDPOINT, MEMP_NUM_COAPENDPOINT, sizeof(coap_endpoint_t), "COAP_ENDPOINT") LWIP_MEMPOOL(COAP_PACKET, MEMP_NUM_COAPPACKET, sizeof(coap_packet_t), "COAP_PACKET") @@ -78,4 +108,10 @@ LWIP_MEMPOOL(COAP_RESOURCE, MEMP_NUM_COAPRESOURCE, sizeof(coap_resource_t), "COA LWIP_MEMPOOL(COAP_RESOURCEATTR, MEMP_NUM_COAPRESOURCEATTR, sizeof(coap_attr_t), "COAP_RESOURCEATTR") LWIP_MEMPOOL(COAP_OPTLIST, MEMP_NUM_COAPOPTLIST, sizeof(coap_optlist_t)+MEMP_LEN_COAPOPTLIST, "COAP_OPTLIST") LWIP_MEMPOOL(COAP_STRING, MEMP_NUM_COAPSTRING, sizeof(coap_string_t)+MEMP_LEN_COAPSTRING, "COAP_STRING") +LWIP_MEMPOOL(COAP_CACHE_KEY, MEMP_NUM_COAPCACHE_KEYS, sizeof(coap_cache_key_t), "COAP_CACHE_KEY") +LWIP_MEMPOOL(COAP_CACHE_ENTRY, MEMP_NUM_COAPCACHE_ENTRIES, sizeof(coap_cache_entry_t), "COAP_CACHE_ENTRY") +LWIP_MEMPOOL(COAP_PDU_BUF, MEMP_NUM_COAPPDUBUF, MEMP_LEN_COAPPDUBUF, "COAP_PDU_BUF") +LWIP_MEMPOOL(COAP_LG_XMIT, MEMP_NUM_COAPLGXMIT, sizeof(coap_lg_xmit_t), "COAP_LG_XMIT") +LWIP_MEMPOOL(COAP_LG_CRCV, MEMP_NUM_COAPLGCRCV, sizeof(coap_lg_crcv_t), "COAP_LG_CRCV") +LWIP_MEMPOOL(COAP_LG_SRCV, MEMP_NUM_COAPLGSRCV, sizeof(coap_lg_srcv_t), "COAP_LG_SRCV") diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/mem.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/mem.h similarity index 81% rename from tools/sdk/esp32c3/include/coap/libcoap/include/coap2/mem.h rename to tools/sdk/esp32c3/include/coap/libcoap/include/coap3/mem.h index ea3c619fd30..c42008963da 100644 --- a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/mem.h +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/mem.h @@ -3,6 +3,8 @@ * * Copyright (C) 2010-2011,2014-2015 Olaf Bergmann * + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ @@ -43,6 +45,11 @@ typedef enum { #endif COAP_SESSION, COAP_OPTLIST, + COAP_CACHE_KEY, + COAP_CACHE_ENTRY, + COAP_LG_XMIT, + COAP_LG_CRCV, + COAP_LG_SRCV, } coap_memory_tag_t; #ifndef WITH_LWIP @@ -59,6 +66,22 @@ typedef enum { */ void *coap_malloc_type(coap_memory_tag_t type, size_t size); +/** + * Reallocates a chunk @p p of bytes created by coap_malloc_type() or + * coap_realloc_type() and returns a pointer to the newly allocated memory of + * @p size. + * Only COAP_STRING type is supported. + * + * Note: If there is an error, @p p will separately need to be released by + * coap_free_type(). + * + * @param type The type of object to be stored. + * @param p A pointer to memory that was allocated by coap_malloc_type(). + * @param size The number of bytes requested. + * @return A pointer to the allocated storage or @c NULL on error. + */ +void *coap_realloc_type(coap_memory_tag_t type, void *p, size_t size); + /** * Releases the memory that was allocated by coap_malloc_type(). The type tag @p * type must be the same that was used for allocating the object pointed to by diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/net.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/net.h new file mode 100644 index 00000000000..577a0b5d5a5 --- /dev/null +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/net.h @@ -0,0 +1,779 @@ +/* + * net.h -- CoAP network interface + * + * Copyright (C) 2010-2021 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +#ifndef COAP_NET_H_ +#define COAP_NET_H_ + +#include +#include +#ifndef _WIN32 +#include +#endif +#include + +#ifdef WITH_LWIP +#include +#endif + +#include "coap_io.h" +#include "coap_dtls.h" +#include "coap_event.h" +#include "pdu.h" +#include "coap_session.h" + +/** + * @defgroup context Context Handling + * API functions for handling PDUs using CoAP Contexts + * @{ + */ + +typedef enum coap_response_t { + COAP_RESPONSE_FAIL, /**< Response not liked - send CoAP RST packet */ + COAP_RESPONSE_OK /**< Response is fine */ +} coap_response_t; + +/** + * Response handler that is used as callback in coap_context_t. + * + * @param session CoAP session. + * @param sent The PDU that was transmitted. + * @param received The PDU that was received. + * @param mid CoAP transaction ID. + + * @return @c COAP_RESPONSE_OK if successful, else @c COAP_RESPONSE_FAIL which + * triggers sending a RST packet. + */ +typedef coap_response_t (*coap_response_handler_t)(coap_session_t *session, + const coap_pdu_t *sent, + const coap_pdu_t *received, + const coap_mid_t mid); + +/** + * Negative Acknowedge handler that is used as callback in coap_context_t. + * + * @param session CoAP session. + * @param sent The PDU that was transmitted. + * @param reason The reason for the NACK. + * @param mid CoAP message ID. + */ +typedef void (*coap_nack_handler_t)(coap_session_t *session, + const coap_pdu_t *sent, + const coap_nack_reason_t reason, + const coap_mid_t mid); + +/** + * Received Ping handler that is used as callback in coap_context_t. + * + * @param session CoAP session. + * @param received The PDU that was received. + * @param mid CoAP message ID. + */ +typedef void (*coap_ping_handler_t)(coap_session_t *session, + const coap_pdu_t *received, + const coap_mid_t mid); + +/** + * Received Pong handler that is used as callback in coap_context_t. + * + * @param session CoAP session. + * @param received The PDU that was received. + * @param mid CoAP message ID. + */ +typedef void (*coap_pong_handler_t)(coap_session_t *session, + const coap_pdu_t *received, + const coap_mid_t mid); + +/** + * Registers a new message handler that is called whenever a response is + * received. + * + * @param context The context to register the handler for. + * @param handler The response handler to register. + */ +void +coap_register_response_handler(coap_context_t *context, + coap_response_handler_t handler); + +/** + * Registers a new message handler that is called whenever a confirmable + * message (request or response) is dropped after all retries have been + * exhausted, or a rst message was received, or a network or TLS level + * event was received that indicates delivering the message is not possible. + * + * @param context The context to register the handler for. + * @param handler The nack handler to register. + */ +void +coap_register_nack_handler(coap_context_t *context, + coap_nack_handler_t handler); + +/** + * Registers a new message handler that is called whenever a CoAP Ping + * message is received. + * + * @param context The context to register the handler for. + * @param handler The ping handler to register. + */ +void +coap_register_ping_handler(coap_context_t *context, + coap_ping_handler_t handler); + +/** + * Registers a new message handler that is called whenever a CoAP Pong + * message is received. + * + * @param context The context to register the handler for. + * @param handler The pong handler to register. + */ +void +coap_register_pong_handler(coap_context_t *context, + coap_pong_handler_t handler); + +/** + * Registers the option type @p type with the given context object @p ctx. + * + * @param ctx The context to use. + * @param type The option type to register. + */ +void +coap_register_option(coap_context_t *ctx, uint16_t type); + +/** + * Creates a new coap_context_t object that will hold the CoAP stack status. + */ +coap_context_t *coap_new_context(const coap_address_t *listen_addr); + +/** + * Set the context's default PSK hint and/or key for a server. + * + * @param context The current coap_context_t object. + * @param hint The default PSK server hint sent to a client. If NULL, PSK + * authentication is disabled. Empty string is a valid hint. + * @param key The default PSK key. If NULL, PSK authentication will fail. + * @param key_len The default PSK key's length. If @p 0, PSK authentication will + * fail. + * + * @return @c 1 if successful, else @c 0. + */ +int coap_context_set_psk( coap_context_t *context, const char *hint, + const uint8_t *key, size_t key_len ); + +/** + * Set the context's default PSK hint and/or key for a server. + * + * @param context The current coap_context_t object. + * @param setup_data If NULL, PSK authentication will fail. PSK + * information required. + * + * @return @c 1 if successful, else @c 0. + */ +int coap_context_set_psk2(coap_context_t *context, + coap_dtls_spsk_t *setup_data); + +/** + * Set the context's default PKI information for a server. + * + * @param context The current coap_context_t object. + * @param setup_data If NULL, PKI authentication will fail. Certificate + * information required. + * + * @return @c 1 if successful, else @c 0. + */ +int +coap_context_set_pki(coap_context_t *context, + const coap_dtls_pki_t *setup_data); + +/** + * Set the context's default Root CA information for a client or server. + * + * @param context The current coap_context_t object. + * @param ca_file If not NULL, is the full path name of a PEM encoded + * file containing all the Root CAs to be used. + * @param ca_dir If not NULL, points to a directory containing PEM + * encoded files containing all the Root CAs to be used. + * + * @return @c 1 if successful, else @c 0. + */ +int +coap_context_set_pki_root_cas(coap_context_t *context, + const char *ca_file, + const char *ca_dir); + +/** + * Set the context keepalive timer for sessions. + * A keepalive message will be sent after if a session has been inactive, + * i.e. no packet sent or received, for the given number of seconds. + * For unreliable protocols, a CoAP Empty message will be sent. If a + * CoAP RST is not received, the CoAP Empty messages will get resent based + * on the Confirmable retry parameters until there is a failure timeout, + * at which point the session will be considered as disconnected. + * For reliable protocols, a CoAP PING message will be sent. If a CoAP PONG + * has not been received before the next PING is due to be sent, the session + * will be considered as disconnected. + * + * @param context The coap_context_t object. + * @param seconds Number of seconds for the inactivity timer, or zero + * to disable CoAP-level keepalive messages. + */ +void coap_context_set_keepalive(coap_context_t *context, unsigned int seconds); + +/** + * Get the libcoap internal file descriptor for using in an application's + * select() or returned as an event in an application's epoll_wait() call. + * + * @param context The coap_context_t object. + * + * @return The libcoap file descriptor or @c -1 if epoll is not available. + */ +int coap_context_get_coap_fd(const coap_context_t *context); + +/** + * Set the maximum idle sessions count. The number of server sessions that + * are currently not in use. If this number is exceeded, the least recently + * used server session is completely removed. + * 0 (the default) means that the number is not monitored. + * + * @param context The coap_context_t object. + * @param max_idle_sessions The maximum idle session count. + */ +void +coap_context_set_max_idle_sessions(coap_context_t *context, + unsigned int max_idle_sessions); + +/** + * Get the maximum idle sessions count. + * + * @param context The coap_context_t object. + * + * @return The count of max idle sessions. + */ +unsigned int +coap_context_get_max_idle_sessions(const coap_context_t *context); + +/** + * Set the session timeout value. The number of seconds of inactivity after + * which an unused server session will be closed. + * 0 means use default (300 secs). + * + * @param context The coap_context_t object. + * @param session_timeout The session timeout value. + */ +void +coap_context_set_session_timeout(coap_context_t *context, + unsigned int session_timeout); + +/** + * Get the session timeout value + * + * @param context The coap_context_t object. + * + * @return The session timeout value. + */ +unsigned int +coap_context_get_session_timeout(const coap_context_t *context); + +/** + * Set the CSM timeout value. The number of seconds to wait for a (TCP) CSM + * negotiation response from the peer. + * 0 (the default) means use wait forever. + * + * @param context The coap_context_t object. + * @param csm_tmeout The CSM timeout value. + */ +void +coap_context_set_csm_timeout(coap_context_t *context, + unsigned int csm_tmeout); + +/** + * Get the CSM timeout value + * + * @param context The coap_context_t object. + * + * @return The CSM timeout value. + */ +unsigned int +coap_context_get_csm_timeout(const coap_context_t *context); + +/** + * Set the maximum number of sessions in (D)TLS handshake value. If this number + * is exceeded, the least recently used server session in handshake is + * completely removed. + * 0 (the default) means that the number is not monitored. + * + * @param context The coap_context_t object. + * @param max_handshake_sessions The maximum number of sessions in handshake. + */ +void +coap_context_set_max_handshake_sessions(coap_context_t *context, + unsigned int max_handshake_sessions); + +/** + * Get the session timeout value + * + * @param context The coap_context_t object. + * + * @return The maximim number of sessions in (D)TLS handshake value. + */ +unsigned int +coap_context_get_max_handshake_sessions(const coap_context_t *context); + +/** + * Returns a new message id and updates @p session->tx_mid accordingly. The + * message id is returned in network byte order to make it easier to read in + * tracing tools. + * + * @param session The current coap_session_t object. + * + * @return Incremented message id in network byte order. + */ +uint16_t coap_new_message_id(coap_session_t *session); + +/** + * CoAP stack context must be released with coap_free_context(). This function + * clears all entries from the receive queue and send queue and deletes the + * resources that have been registered with @p context, and frees the attached + * endpoints. + * + * @param context The current coap_context_t object to free off. + */ +void coap_free_context(coap_context_t *context); + +/** + * Stores @p data with the given CoAP context. This function + * overwrites any value that has previously been stored with @p + * context. + * + * @param context The CoAP context. + * @param data The data to store with wih the context. Note that this data + * must be valid during the lifetime of @p context. + */ +void coap_set_app_data(coap_context_t *context, void *data); + +/** + * Returns any application-specific data that has been stored with @p + * context using the function coap_set_app_data(). This function will + * return @c NULL if no data has been stored. + * + * @param context The CoAP context. + * + * @return The data previously stored or @c NULL if not data stored. + */ +void *coap_get_app_data(const coap_context_t *context); + +/** + * Creates a new ACK PDU with specified error @p code. The options specified by + * the filter expression @p opts will be copied from the original request + * contained in @p request. Unless @c SHORT_ERROR_RESPONSE was defined at build + * time, the textual reason phrase for @p code will be added as payload, with + * Content-Type @c 0. + * This function returns a pointer to the new response message, or @c NULL on + * error. The storage allocated for the new message must be released with + * coap_free(). + * + * @param request Specification of the received (confirmable) request. + * @param code The error code to set. + * @param opts An option filter that specifies which options to copy from + * the original request in @p node. + * + * @return A pointer to the new message or @c NULL on error. + */ +coap_pdu_t *coap_new_error_response(const coap_pdu_t *request, + coap_pdu_code_t code, + coap_opt_filter_t *opts); + +/** + * Sends an error response with code @p code for request @p request to @p dst. + * @p opts will be passed to coap_new_error_response() to copy marked options + * from the request. This function returns the message id if the message was + * sent, or @c COAP_INVALID_MID otherwise. + * + * @param session The CoAP session. + * @param request The original request to respond to. + * @param code The response code. + * @param opts A filter that specifies the options to copy from the + * @p request. + * + * @return The message id if the message was sent, or @c + * COAP_INVALID_MID otherwise. + */ +coap_mid_t coap_send_error(coap_session_t *session, + const coap_pdu_t *request, + coap_pdu_code_t code, + coap_opt_filter_t *opts); + +/** + * Helper function to create and send a message with @p type (usually ACK or + * RST). This function returns @c COAP_INVALID_MID when the message was not + * sent, a valid transaction id otherwise. + * + * @param session The CoAP session. + * @param request The request that should be responded to. + * @param type Which type to set. + * @return message id on success or @c COAP_INVALID_MID + * otherwise. + */ +coap_mid_t +coap_send_message_type(coap_session_t *session, const coap_pdu_t *request, + coap_pdu_type_t type); + +/** + * Sends an ACK message with code @c 0 for the specified @p request to @p dst. + * This function returns the corresponding message id if the message was + * sent or @c COAP_INVALID_MID on error. + * + * @param session The CoAP session. + * @param request The request to be acknowledged. + * + * @return The message id if ACK was sent or @c + * COAP_INVALID_MID on error. + */ +coap_mid_t coap_send_ack(coap_session_t *session, const coap_pdu_t *request); + +/** + * Sends an RST message with code @c 0 for the specified @p request to @p dst. + * This function returns the corresponding message id if the message was + * sent or @c COAP_INVALID_MID on error. + * + * @param session The CoAP session. + * @param request The request to be reset. + * + * @return The message id if RST was sent or @c + * COAP_INVALID_MID on error. + */ +COAP_STATIC_INLINE coap_mid_t +coap_send_rst(coap_session_t *session, const coap_pdu_t *request) { + return coap_send_message_type(session, request, COAP_MESSAGE_RST); +} + +/** +* Sends a CoAP message to given peer. The memory that is +* allocated for the pdu will be released by coap_send(). +* The caller must not use the pdu after calling coap_send(). +* +* @param session The CoAP session. +* @param pdu The CoAP PDU to send. +* +* @return The message id of the sent message or @c +* COAP_INVALID_MID on error. +*/ +coap_mid_t coap_send( coap_session_t *session, coap_pdu_t *pdu ); + +#define coap_send_large(session, pdu) coap_send(session, pdu) + +/** + * Invokes the event handler of @p context for the given @p event and + * @p data. + * + * @param context The CoAP context whose event handler is to be called. + * @param event The event to deliver. + * @param session The session related to @p event. + * @return The result from the associated event handler or 0 if none was + * registered. + */ +int coap_handle_event(coap_context_t *context, + coap_event_t event, + coap_session_t *session); +/** + * Returns 1 if there are no messages to send or to dispatch in the context's + * queues. */ +int coap_can_exit(coap_context_t *context); + +/** + * Returns the current value of an internal tick counter. The counter counts \c + * COAP_TICKS_PER_SECOND ticks every second. + */ +void coap_ticks(coap_tick_t *); + +/** + * Function interface for joining a multicast group for listening for the + * currently defined endpoints that are UDP. + * + * @param ctx The current context. + * @param groupname The name of the group that is to be joined for listening. + * @param ifname Network interface to join the group on, or NULL if first + * appropriate interface is to be chosen by the O/S. + * + * @return 0 on success, -1 on error + */ +int +coap_join_mcast_group_intf(coap_context_t *ctx, const char *groupname, + const char *ifname); + +#define coap_join_mcast_group(ctx, groupname) \ + (coap_join_mcast_group_intf(ctx, groupname, NULL)) + +/** + * Function interface for defining the hop count (ttl) for sending + * multicast traffic + * + * @param session The current contexsion. + * @param hops The number of hops (ttl) to use before the multicast + * packet expires. + * + * @return 1 on success, 0 on error + */ +int +coap_mcast_set_hops(coap_session_t *session, size_t hops); + +/**@}*/ + +/** + * @defgroup app_io Application I/O Handling + * API functions for Application Input / Output + * @{ + */ + +#define COAP_IO_WAIT 0 +#define COAP_IO_NO_WAIT ((uint32_t)-1) + +/** + * The main I/O processing function. All pending network I/O is completed, + * and then optionally waits for the next input packet. + * + * This internally calls coap_io_prepare_io(), then select() for the appropriate + * sockets, updates COAP_SOCKET_CAN_xxx where appropriate and then calls + * coap_io_do_io() before returning with the time spent in the function. + * + * Alternatively, if libcoap is compiled with epoll support, this internally + * calls coap_io_prepare_epoll(), then epoll_wait() for waiting for any file + * descriptors that have (internally) been set up with epoll_ctl() and + * finally coap_io_do_epoll() before returning with the time spent in the + * function. + * + * @param ctx The CoAP context + * @param timeout_ms Minimum number of milliseconds to wait for new packets + * before returning after doing any processing. + * If COAP_IO_WAIT, the call will block until the next + * internal action (e.g. packet retransmit) if any, or block + * until the next packet is received whichever is the sooner + * and do the necessary processing. + * If COAP_IO_NO_WAIT, the function will return immediately + * after processing without waiting for any new input + * packets to arrive. + * + * @return Number of milliseconds spent in function or @c -1 if there was + * an error + */ +int coap_io_process(coap_context_t *ctx, uint32_t timeout_ms); + +#ifndef RIOT_VERSION +/** + * The main message processing loop with additional fds for internal select. + * + * @param ctx The CoAP context + * @param timeout_ms Minimum number of milliseconds to wait for new packets + * before returning after doing any processing. + * If COAP_IO_WAIT, the call will block until the next + * internal action (e.g. packet retransmit) if any, or block + * until the next packet is received whichever is the sooner + * and do the necessary processing. + * If COAP_IO_NO_WAIT, the function will return immediately + * after processing without waiting for any new input + * packets to arrive. + * @param nfds The maximum FD set in readfds, writefds or exceptfds + * plus one, + * @param readfds Read FDs to additionally check for in internal select() + * or NULL if not required. + * @param writefds Write FDs to additionally check for in internal select() + * or NULL if not required. + * @param exceptfds Except FDs to additionally check for in internal select() + * or NULL if not required. + * + * + * @return Number of milliseconds spent in coap_io_process_with_fds, or @c -1 + * if there was an error. If defined, readfds, writefds, exceptfds + * are updated as returned by the internal select() call. + */ +int coap_io_process_with_fds(coap_context_t *ctx, uint32_t timeout_ms, + int nfds, fd_set *readfds, fd_set *writefds, + fd_set *exceptfds); +#endif /* !RIOT_VERSION */ + +/**@}*/ + +/** + * @defgroup app_io_internal Application I/O Handling (Internal) + * Internal API functions for Application Input / Output + * @{ + */ + +/** +* Iterates through all the coap_socket_t structures embedded in endpoints or +* sessions associated with the @p ctx to determine which are wanting any +* read, write, accept or connect I/O (COAP_SOCKET_WANT_xxx is set). If set, +* the coap_socket_t is added to the @p sockets. +* +* Any now timed out delayed packet is transmitted, along with any packets +* associated with requested observable response. +* +* In addition, it returns when the next expected I/O is expected to take place +* (e.g. a packet retransmit). +* +* Prior to calling coap_io_do_io(), the @p sockets must be tested to see +* if any of the COAP_SOCKET_WANT_xxx have the appropriate information and if +* so, COAP_SOCKET_CAN_xxx is set. This typically will be done after using a +* select() call. +* +* Note: If epoll support is compiled into libcoap, coap_io_prepare_epoll() must +* be used instead of coap_io_prepare_io(). +* +* Internal function. +* +* @param ctx The CoAP context +* @param sockets Array of socket descriptors, filled on output +* @param max_sockets Size of socket array. +* @param num_sockets Pointer to the number of valid entries in the socket +* arrays on output. +* @param now Current time. +* +* @return timeout Maxmimum number of milliseconds that can be used by a +* select() to wait for network events or 0 if wait should be +* forever. +*/ +unsigned int +coap_io_prepare_io(coap_context_t *ctx, + coap_socket_t *sockets[], + unsigned int max_sockets, + unsigned int *num_sockets, + coap_tick_t now +); + +/** + * Processes any outstanding read, write, accept or connect I/O as indicated + * in the coap_socket_t structures (COAP_SOCKET_CAN_xxx set) embedded in + * endpoints or sessions associated with @p ctx. + * + * Note: If epoll support is compiled into libcoap, coap_io_do_epoll() must + * be used instead of coap_io_do_io(). + * + * Internal function. + * + * @param ctx The CoAP context + * @param now Current time + */ +void coap_io_do_io(coap_context_t *ctx, coap_tick_t now); + +/** + * Any now timed out delayed packet is transmitted, along with any packets + * associated with requested observable response. + * + * In addition, it returns when the next expected I/O is expected to take place + * (e.g. a packet retransmit). + * + * Note: If epoll support is compiled into libcoap, coap_io_prepare_epoll() must + * be used instead of coap_io_prepare_io(). + * + * Internal function. + * + * @param ctx The CoAP context + * @param now Current time. + * + * @return timeout Maxmimum number of milliseconds that can be used by a + * epoll_wait() to wait for network events or 0 if wait should be + * forever. + */ +unsigned int +coap_io_prepare_epoll(coap_context_t *ctx, coap_tick_t now); + +struct epoll_event; + +/** + * Process all the epoll events + * + * Note: If epoll support is compiled into libcoap, coap_io_do_epoll() must + * be used instead of coap_io_do_io(). + * + * Internal function + * + * @param ctx The current CoAP context. + * @param events The list of events returned from an epoll_wait() call. + * @param nevents The number of events. + * + */ +void coap_io_do_epoll(coap_context_t *ctx, struct epoll_event* events, + size_t nevents); + +/**@}*/ + +/** + * @deprecated Use coap_io_process() instead. + * + * This function just calls coap_io_process(). + * + * @param ctx The CoAP context + * @param timeout_ms Minimum number of milliseconds to wait for new packets + * before returning after doing any processing. + * If COAP_IO_WAIT, the call will block until the next + * internal action (e.g. packet retransmit) if any, or block + * until the next packet is received whichever is the sooner + * and do the necessary processing. + * If COAP_IO_NO_WAIT, the function will return immediately + * after processing without waiting for any new input + * packets to arrive. + * + * @return Number of milliseconds spent in function or @c -1 if there was + * an error + */ +COAP_STATIC_INLINE COAP_DEPRECATED int +coap_run_once(coap_context_t *ctx, uint32_t timeout_ms) +{ + return coap_io_process(ctx, timeout_ms); +} + +/** +* @deprecated Use coap_io_prepare_io() instead. +* +* This function just calls coap_io_prepare_io(). +* +* Internal function. +* +* @param ctx The CoAP context +* @param sockets Array of socket descriptors, filled on output +* @param max_sockets Size of socket array. +* @param num_sockets Pointer to the number of valid entries in the socket +* arrays on output. +* @param now Current time. +* +* @return timeout Maxmimum number of milliseconds that can be used by a +* select() to wait for network events or 0 if wait should be +* forever. +*/ +COAP_STATIC_INLINE COAP_DEPRECATED unsigned int +coap_write(coap_context_t *ctx, + coap_socket_t *sockets[], + unsigned int max_sockets, + unsigned int *num_sockets, + coap_tick_t now +) { + return coap_io_prepare_io(ctx, sockets, max_sockets, num_sockets, now); +} + +/** + * @deprecated Use coap_io_do_io() instead. + * + * This function just calls coap_io_do_io(). + * + * Internal function. + * + * @param ctx The CoAP context + * @param now Current time + */ +COAP_STATIC_INLINE COAP_DEPRECATED void +coap_read(coap_context_t *ctx, coap_tick_t now +) { + coap_io_do_io(ctx, now); +} + +/* Old definitions which may be hanging around in old code - be helpful! */ +#define COAP_RUN_NONBLOCK COAP_RUN_NONBLOCK_deprecated_use_COAP_IO_NO_WAIT +#define COAP_RUN_BLOCK COAP_RUN_BLOCK_deprecated_use_COAP_IO_WAIT + +#endif /* COAP_NET_H_ */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/option.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/option.h similarity index 77% rename from tools/sdk/esp32s2/include/coap/libcoap/include/coap2/option.h rename to tools/sdk/esp32c3/include/coap/libcoap/include/coap3/option.h index 3af9e71e706..c01e8f6688b 100644 --- a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/option.h +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/option.h @@ -3,6 +3,8 @@ * * Copyright (C) 2010-2013 Olaf Bergmann * + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ @@ -15,8 +17,7 @@ #ifndef COAP_OPTION_H_ #define COAP_OPTION_H_ -#include "bits.h" -#include "pdu.h" +typedef uint16_t coap_option_num_t; /** * Use byte-oriented access methods here because sliding a complex struct @@ -89,134 +90,66 @@ size_t coap_opt_size(const coap_opt_t *opt); #error COAP_OPT_FILTER_SHORT + COAP_OPT_FILTER_LONG must be less or equal 16 #endif /* (COAP_OPT_FILTER_SHORT + COAP_OPT_FILTER_LONG > 16) */ -/** The number of elements in coap_opt_filter_t. */ -#define COAP_OPT_FILTER_SIZE \ - (((COAP_OPT_FILTER_SHORT + 1) >> 1) + COAP_OPT_FILTER_LONG) +1 - -/** - * Fixed-size vector we use for option filtering. It is large enough - * to hold COAP_OPT_FILTER_SHORT entries with an option number between - * 0 and 255, and COAP_OPT_FILTER_LONG entries with an option number - * between 256 and 65535. Its internal structure is - * - * @code -struct { +/* + * mask contains a bit vector that indicates which fields in the long_opts[] + * and subsequent short_opts[] are used. The first COAP_OPT_FILTER_LONG bits + * correspond to the long option types that are stored in long_opts[] + * elements. The next COAP_OPT_FILTER_SHORT bits correspond to the short + * option types that are stored in short_opts[]. + */ +typedef struct coap_opt_filter_t { uint16_t mask; uint16_t long_opts[COAP_OPT_FILTER_LONG]; uint8_t short_opts[COAP_OPT_FILTER_SHORT]; -} - * @endcode - * - * The first element contains a bit vector that indicates which fields - * in the remaining array are used. The first COAP_OPT_FILTER_LONG - * bits correspond to the long option types that are stored in the - * elements from index 1 to COAP_OPT_FILTER_LONG. The next - * COAP_OPT_FILTER_SHORT bits correspond to the short option types - * that are stored in the elements from index COAP_OPT_FILTER_LONG + 1 - * to COAP_OPT_FILTER_LONG + COAP_OPT_FILTER_SHORT. The latter - * elements are treated as bytes. - */ -typedef uint16_t coap_opt_filter_t[COAP_OPT_FILTER_SIZE]; +} coap_opt_filter_t; /** Pre-defined filter that includes all options. */ #define COAP_OPT_ALL NULL /** - * Clears filter @p f. + * Clears filter @p filter. * - * @param f The filter to clear. + * @param filter The filter to clear. */ -COAP_STATIC_INLINE void -coap_option_filter_clear(coap_opt_filter_t f) { - memset(f, 0, sizeof(coap_opt_filter_t)); -} +void +coap_option_filter_clear(coap_opt_filter_t *filter); /** - * Sets the corresponding entry for @p type in @p filter. This + * Sets the corresponding entry for @p number in @p filter. This * function returns @c 1 if bit was set or @c 0 on error (i.e. when - * the given type does not fit in the filter). + * the given number does not fit in the filter). * * @param filter The filter object to change. - * @param type The type for which the bit should be set. + * @param number The option number for which the bit should be set. * * @return @c 1 if bit was set, @c 0 otherwise. */ -int coap_option_filter_set(coap_opt_filter_t filter, uint16_t type); +int coap_option_filter_set(coap_opt_filter_t *filter, coap_option_num_t number); /** - * Clears the corresponding entry for @p type in @p filter. This + * Clears the corresponding entry for @p number in @p filter. This * function returns @c 1 if bit was set or @c 0 on error (i.e. when - * the given type does not fit in the filter). + * the given number does not fit in the filter). * * @param filter The filter object to change. - * @param type The type that should be cleared from the filter. + * @param number The option number that should be cleared from the filter. * * @return @c 1 if bit was set, @c 0 otherwise. */ -int coap_option_filter_unset(coap_opt_filter_t filter, uint16_t type); +int coap_option_filter_unset(coap_opt_filter_t *filter, + coap_option_num_t number); /** - * Checks if @p type is contained in @p filter. This function returns + * Checks if @p number is contained in @p filter. This function returns * @c 1 if found, @c 0 if not, or @c -1 on error (i.e. when the given - * type does not fit in the filter). + * number does not fit in the filter). * * @param filter The filter object to search. - * @param type The type to search for. + * @param number The option number to search for. * - * @return @c 1 if @p type was found, @c 0 otherwise, or @c -1 on error. + * @return @c 1 if @p number was found, @c 0 otherwise, or @c -1 on error. */ -int coap_option_filter_get(coap_opt_filter_t filter, uint16_t type); - -/** - * Sets the corresponding bit for @p type in @p filter. This function returns @c - * 1 if bit was set or @c -1 on error (i.e. when the given type does not fit in - * the filter). - * - * @deprecated Use coap_option_filter_set() instead. - * - * @param filter The filter object to change. - * @param type The type for which the bit should be set. - * - * @return @c 1 if bit was set, @c -1 otherwise. - */ -COAP_STATIC_INLINE int -coap_option_setb(coap_opt_filter_t filter, uint16_t type) { - return coap_option_filter_set(filter, type) ? 1 : -1; -} - -/** - * Clears the corresponding bit for @p type in @p filter. This function returns - * @c 1 if bit was cleared or @c -1 on error (i.e. when the given type does not - * fit in the filter). - * - * @deprecated Use coap_option_filter_unset() instead. - * - * @param filter The filter object to change. - * @param type The type for which the bit should be cleared. - * - * @return @c 1 if bit was set, @c -1 otherwise. - */ -COAP_STATIC_INLINE int -coap_option_clrb(coap_opt_filter_t filter, uint16_t type) { - return coap_option_filter_unset(filter, type) ? 1 : -1; -} - -/** - * Gets the corresponding bit for @p type in @p filter. This function returns @c - * 1 if the bit is set @c 0 if not, or @c -1 on error (i.e. when the given type - * does not fit in the filter). - * - * @deprecated Use coap_option_filter_get() instead. - * - * @param filter The filter object to read bit from. - * @param type The type for which the bit should be read. - * - * @return @c 1 if bit was set, @c 0 if not, @c -1 on error. - */ -COAP_STATIC_INLINE int -coap_option_getb(coap_opt_filter_t filter, uint16_t type) { - return coap_option_filter_get(filter, type); -} +int coap_option_filter_get(coap_opt_filter_t *filter, coap_option_num_t number); /** * Iterator to run through PDU options. This object must be @@ -236,7 +169,7 @@ coap_option_getb(coap_opt_filter_t filter, uint16_t type) { */ typedef struct { size_t length; /**< remaining length of PDU */ - uint16_t type; /**< decoded option type */ + coap_option_num_t number; /**< decoded option number */ unsigned int bad:1; /**< iterator object is ok if not set */ unsigned int filtered:1; /**< denotes whether or not filter is used */ coap_opt_t *next_option; /**< pointer to the unparsed next option */ @@ -251,8 +184,8 @@ typedef struct { * * @param pdu The PDU the options of which should be walked through. * @param oi An iterator object that will be initilized. - * @param filter An optional option type filter. - * With @p type != @c COAP_OPT_ALL, coap_option_next() + * @param filter An optional option number filter. + * With @p number != @c COAP_OPT_ALL, coap_option_next() * will return only options matching this bitmask. * Fence-post options @c 14, @c 28, @c 42, ... are always * skipped. @@ -261,18 +194,18 @@ typedef struct { */ coap_opt_iterator_t *coap_option_iterator_init(const coap_pdu_t *pdu, coap_opt_iterator_t *oi, - const coap_opt_filter_t filter); + const coap_opt_filter_t *filter); /** * Updates the iterator @p oi to point to the next option. This function returns * a pointer to that option or @c NULL if no more options exist. The contents of * @p oi will be updated. In particular, @c oi->n specifies the current option's - * ordinal number (counted from @c 1), @c oi->type is the option's type code, - * and @c oi->option points to the beginning of the current option itself. When - * advanced past the last option, @c oi->option will be @c NULL. + * ordinal number (counted from @c 1), @c oi->number is the option's number + * value, and @c oi->option points to the beginning of the current option + * itself. When * advanced past the last option, @c oi->option will be @c NULL. * * Note that options are skipped whose corresponding bits in the filter - * specified with coap_option_iterator_init() are @c 0. Options with type codes + * specified with coap_option_iterator_init() are @c 0. Options with numbers * that do not fit in this filter hence will always be returned. * * @param oi The option iterator to update. @@ -282,20 +215,20 @@ coap_opt_iterator_t *coap_option_iterator_init(const coap_pdu_t *pdu, coap_opt_t *coap_option_next(coap_opt_iterator_t *oi); /** - * Retrieves the first option of type @p type from @p pdu. @p oi must point to a - * coap_opt_iterator_t object that will be initialized by this function to - * filter only options with code @p type. This function returns the first option - * with this type, or @c NULL if not found. + * Retrieves the first option of number @p number from @p pdu. @p oi must + * point to a coap_opt_iterator_t object that will be initialized by this + * function to filter only options with number @p number. This function returns + * the first option with this number, or @c NULL if not found. * * @param pdu The PDU to parse for options. - * @param type The option type code to search for. + * @param number The option number to search for. * @param oi An iterator object to use. * - * @return A pointer to the first option of type @p type, or @c NULL if + * @return A pointer to the first option of number @p number, or @c NULL if * not found. */ -coap_opt_t *coap_check_option(coap_pdu_t *pdu, - uint16_t type, +coap_opt_t *coap_check_option(const coap_pdu_t *pdu, + coap_option_num_t number, coap_opt_iterator_t *oi); /** @@ -349,18 +282,6 @@ size_t coap_opt_encode(coap_opt_t *opt, const uint8_t *val, size_t length); -/** - * Decodes the delta value of the next option. This function returns the number - * of bytes read or @c 0 on error. The caller of this function must ensure that - * it does not read over the boundaries of @p opt (e.g. by calling - * coap_opt_check_delta(). - * - * @param opt The option to examine. - * - * @return The number of bytes read or @c 0 on error. - */ -uint16_t coap_opt_delta(const coap_opt_t *opt); - /** * Returns the length of the given option. @p opt must point to an option jump * or the beginning of the option. This function returns @c 0 when @p opt is not @@ -374,7 +295,7 @@ uint16_t coap_opt_delta(const coap_opt_t *opt); * * @return The option's length or @c 0 when undefined. */ -uint16_t coap_opt_length(const coap_opt_t *opt); +uint32_t coap_opt_length(const coap_opt_t *opt); /** * Returns a pointer to the value of the given option. @p opt must point to an @@ -387,8 +308,6 @@ uint16_t coap_opt_length(const coap_opt_t *opt); */ const uint8_t *coap_opt_value(const coap_opt_t *opt); -/** @} */ - /** * Representation of chained list of CoAP options to install. * @@ -415,6 +334,12 @@ typedef struct coap_optlist_t { /** * Create a new optlist entry. * + * Note: Where possible, the option data needs to be stripped of leading zeros + * (big endian) to reduce the amount of data needed in the PDU, as well as in + * some cases the maximum data size of an opton can be exceeded if not stripped + * and hence be illegal. This is done by using coap_encode_var_safe() or + * coap_encode_var_safe8(). + * * @param number The option number (COAP_OPTION_*) * @param length The option length * @param data The option value data @@ -458,4 +383,57 @@ int coap_insert_optlist(coap_optlist_t **optlist_chain, */ void coap_delete_optlist(coap_optlist_t *optlist_chain); +/** @} */ + +/** + * Sets the corresponding bit for @p type in @p filter. This function returns @c + * 1 if bit was set or @c -1 on error (i.e. when the given type does not fit in + * the filter). + * + * @deprecated Use coap_option_filter_set() instead. + * + * @param filter The filter object to change. + * @param type The type for which the bit should be set. + * + * @return @c 1 if bit was set, @c -1 otherwise. + */ +COAP_STATIC_INLINE COAP_DEPRECATED int +coap_option_setb(coap_opt_filter_t *filter, uint16_t type) { + return coap_option_filter_set(filter, type) ? 1 : -1; +} + +/** + * Clears the corresponding bit for @p type in @p filter. This function returns + * @c 1 if bit was cleared or @c -1 on error (i.e. when the given type does not + * fit in the filter). + * + * @deprecated Use coap_option_filter_unset() instead. + * + * @param filter The filter object to change. + * @param type The type for which the bit should be cleared. + * + * @return @c 1 if bit was set, @c -1 otherwise. + */ +COAP_STATIC_INLINE COAP_DEPRECATED int +coap_option_clrb(coap_opt_filter_t *filter, uint16_t type) { + return coap_option_filter_unset(filter, type) ? 1 : -1; +} + +/** + * Gets the corresponding bit for @p type in @p filter. This function returns @c + * 1 if the bit is set @c 0 if not, or @c -1 on error (i.e. when the given type + * does not fit in the filter). + * + * @deprecated Use coap_option_filter_get() instead. + * + * @param filter The filter object to read bit from. + * @param type The type for which the bit should be read. + * + * @return @c 1 if bit was set, @c 0 if not, @c -1 on error. + */ +COAP_STATIC_INLINE COAP_DEPRECATED int +coap_option_getb(coap_opt_filter_t *filter, uint16_t type) { + return coap_option_filter_get(filter, type); +} + #endif /* COAP_OPTION_H_ */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/pdu.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/pdu.h new file mode 100644 index 00000000000..a22869b69ed --- /dev/null +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/pdu.h @@ -0,0 +1,572 @@ +/* + * pdu.h -- CoAP message structure + * + * Copyright (C) 2010-2014 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file pdu.h + * @brief Pre-defined constants that reflect defaults for CoAP + */ + +#ifndef COAP_PDU_H_ +#define COAP_PDU_H_ + +#include "uri.h" +#include "option.h" + +#ifdef WITH_LWIP +#include +#endif + +#include + +/** + * @defgroup pdu PDU + * API functions for PDUs + * @{ + */ + +#define COAP_DEFAULT_PORT 5683 /* CoAP default UDP/TCP port */ +#define COAPS_DEFAULT_PORT 5684 /* CoAP default UDP/TCP port for secure transmission */ +#define COAP_DEFAULT_MAX_AGE 60 /* default maximum object lifetime in seconds */ +#ifndef COAP_DEFAULT_MTU +#define COAP_DEFAULT_MTU 1152 +#endif /* COAP_DEFAULT_MTU */ + +#ifndef COAP_DEFAULT_HOP_LIMIT +#define COAP_DEFAULT_HOP_LIMIT 16 +#endif /* COAP_DEFAULT_HOP_LIMIT */ + +#define COAP_DEFAULT_SCHEME "coap" /* the default scheme for CoAP URIs */ + +/** well-known resources URI */ +#define COAP_DEFAULT_URI_WELLKNOWN ".well-known/core" + +/* CoAP message types */ + +/** + * CoAP PDU message type definitions + */ +typedef enum coap_pdu_type_t { + COAP_MESSAGE_CON, /* 0 confirmable message (requires ACK/RST) */ + COAP_MESSAGE_NON, /* 1 non-confirmable message (one-shot message) */ + COAP_MESSAGE_ACK, /* 2 used to acknowledge confirmable messages */ + COAP_MESSAGE_RST /* 3 indicates error in received messages */ +} coap_pdu_type_t; + +/** + * CoAP PDU Request methods + */ +typedef enum coap_request_t { + COAP_REQUEST_GET = 1, + COAP_REQUEST_POST, /* 2 */ + COAP_REQUEST_PUT, /* 3 */ + COAP_REQUEST_DELETE, /* 4 */ + COAP_REQUEST_FETCH, /* 5 RFC 8132 */ + COAP_REQUEST_PATCH, /* 6 RFC 8132 */ + COAP_REQUEST_IPATCH, /* 7 RFC 8132 */ +} coap_request_t; + +/* + * CoAP option numbers (be sure to update coap_option_check_critical() and + * coap_add_option() when adding options + */ + +/* + * The C, U, and N flags indicate the properties + * Critical, Unsafe, and NoCacheKey, respectively. + * If U is set, then N has no meaning as per + * https://tools.ietf.org/html/rfc7252#section-5.10 + * and is set to a -. + * + * Separately, R is for the options that can be repeated + * + * The least significant byte of the option is set as followed + * as per https://tools.ietf.org/html/rfc7252#section-5.4.6 + * + * 0 1 2 3 4 5 6 7 + * --+---+---+---+---+---+---+---+ + * | NoCacheKey| U | C | + * --+---+---+---+---+---+---+---+ + * + * https://tools.ietf.org/html/rfc8613#section-4 goes on to define E, I and U + * properties Encrypted and Integrity Protected, Integrity Protected Only, and + * Unprotected respectively. Integrity Protected Only is not currently used. + * + * An Option is tagged with CUNREIU with any of the letters replaced with _ if + * not set, or - for N if U is set (see above) for aiding understanding of the + * Option. + */ + +#define COAP_OPTION_IF_MATCH 1 /* C__RE__, opaque, 0-8 B, RFC7252 */ +#define COAP_OPTION_URI_HOST 3 /* CU-___U, String, 1-255 B, RFC7252 */ +#define COAP_OPTION_ETAG 4 /* ___RE__, opaque, 1-8 B, RFC7252 */ +#define COAP_OPTION_IF_NONE_MATCH 5 /* C___E__, empty, 0 B, RFC7252 */ +#define COAP_OPTION_OBSERVE 6 /* _U-_E_U, empty/uint,0/0-3 B, RFC7641 */ +#define COAP_OPTION_URI_PORT 7 /* CU-___U, uint, 0-2 B, RFC7252 */ +#define COAP_OPTION_LOCATION_PATH 8 /* ___RE__, String, 0-255 B, RFC7252 */ +#define COAP_OPTION_OSCORE 9 /* C_____U, *, 0-255 B, RFC8613 */ +#define COAP_OPTION_URI_PATH 11 /* CU-RE__, String, 0-255 B, RFC7252 */ +#define COAP_OPTION_CONTENT_FORMAT 12 /* ____E__, uint, 0-2 B, RFC7252 */ +#define COAP_OPTION_CONTENT_TYPE COAP_OPTION_CONTENT_FORMAT +/* COAP_OPTION_MAXAGE default 60 seconds if not set */ +#define COAP_OPTION_MAXAGE 14 /* _U-_E_U, uint, 0-4 B, RFC7252 */ +#define COAP_OPTION_URI_QUERY 15 /* CU-RE__, String, 1-255 B, RFC7252 */ +#define COAP_OPTION_HOP_LIMIT 16 /* ______U, uint, 1 B, RFC8768 */ +#define COAP_OPTION_ACCEPT 17 /* C___E__, uint, 0-2 B, RFC7252 */ +#define COAP_OPTION_LOCATION_QUERY 20 /* ___RE__, String, 0-255 B, RFC7252 */ +#define COAP_OPTION_BLOCK2 23 /* CU-_E_U, uint, 0-3 B, RFC7959 */ +#define COAP_OPTION_BLOCK1 27 /* CU-_E_U, uint, 0-3 B, RFC7959 */ +#define COAP_OPTION_SIZE2 28 /* __N_E_U, uint, 0-4 B, RFC7959 */ +#define COAP_OPTION_PROXY_URI 35 /* CU-___U, String, 1-1034 B, RFC7252 */ +#define COAP_OPTION_PROXY_SCHEME 39 /* CU-___U, String, 1-255 B, RFC7252 */ +#define COAP_OPTION_SIZE1 60 /* __N_E_U, uint, 0-4 B, RFC7252 */ +#define COAP_OPTION_NORESPONSE 258 /* _U-_E_U, uint, 0-1 B, RFC7967 */ + +#define COAP_MAX_OPT 65535 /**< the highest option number we know */ + +/* CoAP result codes (HTTP-Code / 100 * 40 + HTTP-Code % 100) */ + +/* As of draft-ietf-core-coap-04, response codes are encoded to base + * 32, i.e. the three upper bits determine the response class while + * the remaining five fine-grained information specific to that class. + */ +#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100) + +/* Determines the class of response code C */ +#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF) + +#ifndef SHORT_ERROR_RESPONSE +/** + * Returns a human-readable response phrase for the specified CoAP response @p + * code. This function returns @c NULL if not found. + * + * @param code The response code for which the literal phrase should be + * retrieved. + * + * @return A zero-terminated string describing the error, or @c NULL if not + * found. + */ +const char *coap_response_phrase(unsigned char code); + +#define COAP_ERROR_PHRASE_LENGTH 32 /**< maximum length of error phrase */ + +#else +#define coap_response_phrase(x) ((char *)NULL) + +#define COAP_ERROR_PHRASE_LENGTH 0 /**< maximum length of error phrase */ +#endif /* SHORT_ERROR_RESPONSE */ + +#define COAP_SIGNALING_CODE(N) (((N)/100 << 5) | (N)%100) + +typedef enum coap_pdu_signaling_proto_t { + COAP_SIGNALING_CSM = COAP_SIGNALING_CODE(701), + COAP_SIGNALING_PING = COAP_SIGNALING_CODE(702), + COAP_SIGNALING_PONG = COAP_SIGNALING_CODE(703), + COAP_SIGNALING_RELEASE = COAP_SIGNALING_CODE(704), + COAP_SIGNALING_ABORT = COAP_SIGNALING_CODE(705), +} coap_pdu_signaling_proto_t; + +/* Applies to COAP_SIGNALING_CSM */ +#define COAP_SIGNALING_OPTION_MAX_MESSAGE_SIZE 2 +#define COAP_SIGNALING_OPTION_BLOCK_WISE_TRANSFER 4 +/* Applies to COAP_SIGNALING_PING / COAP_SIGNALING_PONG */ +#define COAP_SIGNALING_OPTION_CUSTODY 2 +/* Applies to COAP_SIGNALING_RELEASE */ +#define COAP_SIGNALING_OPTION_ALTERNATIVE_ADDRESS 2 +#define COAP_SIGNALING_OPTION_HOLD_OFF 4 +/* Applies to COAP_SIGNALING_ABORT */ +#define COAP_SIGNALING_OPTION_BAD_CSM_OPTION 2 + +/* CoAP media type encoding */ + +#define COAP_MEDIATYPE_TEXT_PLAIN 0 /* text/plain (UTF-8) */ +#define COAP_MEDIATYPE_APPLICATION_LINK_FORMAT 40 /* application/link-format */ +#define COAP_MEDIATYPE_APPLICATION_XML 41 /* application/xml */ +#define COAP_MEDIATYPE_APPLICATION_OCTET_STREAM 42 /* application/octet-stream */ +#define COAP_MEDIATYPE_APPLICATION_RDF_XML 43 /* application/rdf+xml */ +#define COAP_MEDIATYPE_APPLICATION_EXI 47 /* application/exi */ +#define COAP_MEDIATYPE_APPLICATION_JSON 50 /* application/json */ +#define COAP_MEDIATYPE_APPLICATION_CBOR 60 /* application/cbor */ +#define COAP_MEDIATYPE_APPLICATION_CWT 61 /* application/cwt, RFC 8392 */ + +/* Content formats from RFC 8152 */ +#define COAP_MEDIATYPE_APPLICATION_COSE_SIGN 98 /* application/cose; cose-type="cose-sign" */ +#define COAP_MEDIATYPE_APPLICATION_COSE_SIGN1 18 /* application/cose; cose-type="cose-sign1" */ +#define COAP_MEDIATYPE_APPLICATION_COSE_ENCRYPT 96 /* application/cose; cose-type="cose-encrypt" */ +#define COAP_MEDIATYPE_APPLICATION_COSE_ENCRYPT0 16 /* application/cose; cose-type="cose-encrypt0" */ +#define COAP_MEDIATYPE_APPLICATION_COSE_MAC 97 /* application/cose; cose-type="cose-mac" */ +#define COAP_MEDIATYPE_APPLICATION_COSE_MAC0 17 /* application/cose; cose-type="cose-mac0" */ + +#define COAP_MEDIATYPE_APPLICATION_COSE_KEY 101 /* application/cose-key */ +#define COAP_MEDIATYPE_APPLICATION_COSE_KEY_SET 102 /* application/cose-key-set */ + +/* Content formats from RFC 8428 */ +#define COAP_MEDIATYPE_APPLICATION_SENML_JSON 110 /* application/senml+json */ +#define COAP_MEDIATYPE_APPLICATION_SENSML_JSON 111 /* application/sensml+json */ +#define COAP_MEDIATYPE_APPLICATION_SENML_CBOR 112 /* application/senml+cbor */ +#define COAP_MEDIATYPE_APPLICATION_SENSML_CBOR 113 /* application/sensml+cbor */ +#define COAP_MEDIATYPE_APPLICATION_SENML_EXI 114 /* application/senml-exi */ +#define COAP_MEDIATYPE_APPLICATION_SENSML_EXI 115 /* application/sensml-exi */ +#define COAP_MEDIATYPE_APPLICATION_SENML_XML 310 /* application/senml+xml */ +#define COAP_MEDIATYPE_APPLICATION_SENSML_XML 311 /* application/sensml+xml */ + +/* Content formats from RFC 8782 */ +#define COAP_MEDIATYPE_APPLICATION_DOTS_CBOR 271 /* application/dots+cbor */ + +/* Note that identifiers for registered media types are in the range 0-65535. We + * use an unallocated type here and hope for the best. */ +#define COAP_MEDIATYPE_ANY 0xff /* any media type */ + +/** + * coap_mid_t is used to store the CoAP Message ID of a CoAP PDU. + * Valid message ids are 0 to 2^16. Negative values are error codes. + */ +typedef int coap_mid_t; + +/** Indicates an invalid message id. */ +#define COAP_INVALID_MID -1 + +/** + * Indicates an invalid message id. + * @deprecated Use COAP_INVALID_MID instead. + */ +#define COAP_INVALID_TID COAP_INVALID_MID + +/** + * @deprecated Use coap_optlist_t instead. + * + * Structures for more convenient handling of options. (To be used with ordered + * coap_list_t.) The option's data will be added to the end of the coap_option + * structure (see macro COAP_OPTION_DATA). + */ +COAP_DEPRECATED typedef struct { + uint16_t key; /* the option key (no delta coding) */ + unsigned int length; +} coap_option; + +#define COAP_OPTION_KEY(option) (option).key +#define COAP_OPTION_LENGTH(option) (option).length +#define COAP_OPTION_DATA(option) ((unsigned char *)&(option) + sizeof(coap_option)) + +#ifdef WITH_LWIP +/** + * Creates a CoAP PDU from an lwIP @p pbuf, whose reference is passed on to this + * function. + * + * The pbuf is checked for being contiguous, and for having only one reference. + * The reference is stored in the PDU and will be freed when the PDU is freed. + * + * (For now, these are fatal errors; in future, a new pbuf might be allocated, + * the data copied and the passed pbuf freed). + * + * This behaves like coap_pdu_init(0, 0, 0, pbuf->tot_len), and afterwards + * copying the contents of the pbuf to the pdu. + * + * @return A pointer to the new PDU object or @c NULL on error. + */ +coap_pdu_t * coap_pdu_from_pbuf(struct pbuf *pbuf); +#endif + +/** +* CoAP protocol types +*/ +typedef enum coap_proto_t { + COAP_PROTO_NONE = 0, + COAP_PROTO_UDP, + COAP_PROTO_DTLS, + COAP_PROTO_TCP, + COAP_PROTO_TLS, +} coap_proto_t; + +/** + * Set of codes available for a PDU. + */ +typedef enum coap_pdu_code_t { + COAP_EMPTY_CODE = 0, + + COAP_REQUEST_CODE_GET = COAP_REQUEST_GET, + COAP_REQUEST_CODE_POST = COAP_REQUEST_POST, + COAP_REQUEST_CODE_PUT = COAP_REQUEST_PUT, + COAP_REQUEST_CODE_DELETE = COAP_REQUEST_DELETE, + COAP_REQUEST_CODE_FETCH = COAP_REQUEST_FETCH, + COAP_REQUEST_CODE_PATCH = COAP_REQUEST_PATCH, + COAP_REQUEST_CODE_IPATCH = COAP_REQUEST_IPATCH, + + COAP_RESPONSE_CODE_OK = COAP_RESPONSE_CODE(200), + COAP_RESPONSE_CODE_CREATED = COAP_RESPONSE_CODE(201), + COAP_RESPONSE_CODE_DELETED = COAP_RESPONSE_CODE(202), + COAP_RESPONSE_CODE_VALID = COAP_RESPONSE_CODE(203), + COAP_RESPONSE_CODE_CHANGED = COAP_RESPONSE_CODE(204), + COAP_RESPONSE_CODE_CONTENT = COAP_RESPONSE_CODE(205), + COAP_RESPONSE_CODE_CONTINUE = COAP_RESPONSE_CODE(231), + COAP_RESPONSE_CODE_BAD_REQUEST = COAP_RESPONSE_CODE(400), + COAP_RESPONSE_CODE_UNAUTHORIZED = COAP_RESPONSE_CODE(401), + COAP_RESPONSE_CODE_BAD_OPTION = COAP_RESPONSE_CODE(402), + COAP_RESPONSE_CODE_FORBIDDEN = COAP_RESPONSE_CODE(403), + COAP_RESPONSE_CODE_NOT_FOUND = COAP_RESPONSE_CODE(404), + COAP_RESPONSE_CODE_NOT_ALLOWED = COAP_RESPONSE_CODE(405), + COAP_RESPONSE_CODE_NOT_ACCEPTABLE = COAP_RESPONSE_CODE(406), + COAP_RESPONSE_CODE_INCOMPLETE = COAP_RESPONSE_CODE(408), + COAP_RESPONSE_CODE_CONFLICT = COAP_RESPONSE_CODE(409), + COAP_RESPONSE_CODE_PRECONDITION_FAILED = COAP_RESPONSE_CODE(412), + COAP_RESPONSE_CODE_REQUEST_TOO_LARGE = COAP_RESPONSE_CODE(413), + COAP_RESPONSE_CODE_UNSUPPORTED_CONTENT_FORMAT = COAP_RESPONSE_CODE(415), + COAP_RESPONSE_CODE_UNPROCESSABLE = COAP_RESPONSE_CODE(422), + COAP_RESPONSE_CODE_TOO_MANY_REQUESTS = COAP_RESPONSE_CODE(429), + COAP_RESPONSE_CODE_INTERNAL_ERROR = COAP_RESPONSE_CODE(500), + COAP_RESPONSE_CODE_NOT_IMPLEMENTED = COAP_RESPONSE_CODE(501), + COAP_RESPONSE_CODE_BAD_GATEWAY = COAP_RESPONSE_CODE(502), + COAP_RESPONSE_CODE_SERVICE_UNAVAILABLE = COAP_RESPONSE_CODE(503), + COAP_RESPONSE_CODE_GATEWAY_TIMEOUT = COAP_RESPONSE_CODE(504), + COAP_RESPONSE_CODE_PROXYING_NOT_SUPPORTED = COAP_RESPONSE_CODE(505), + COAP_RESPONSE_CODE_HOP_LIMIT_REACHED = COAP_RESPONSE_CODE(508), + + COAP_SIGNALING_CODE_CSM = COAP_SIGNALING_CSM, + COAP_SIGNALING_CODE_PING = COAP_SIGNALING_PING, + COAP_SIGNALING_CODE_PONG = COAP_SIGNALING_PONG, + COAP_SIGNALING_CODE_RELEASE = COAP_SIGNALING_RELEASE, + COAP_SIGNALING_CODE_ABORT = COAP_SIGNALING_ABORT +} coap_pdu_code_t; + +/** + * Creates a new CoAP PDU with at least enough storage space for the given + * @p size maximum message size. The function returns a pointer to the + * node coap_pdu_t object on success, or @c NULL on error. The storage allocated + * for the result must be released with coap_delete_pdu() if coap_send() + * is not called. + * + * @param type The type of the PDU (one of COAP_MESSAGE_CON, COAP_MESSAGE_NON, + * COAP_MESSAGE_ACK, COAP_MESSAGE_RST). + * @param code The message code of the PDU. + * @param mid The message id to set or 0 if unknown / not applicable. + * @param size The maximum allowed number of byte for the message. + * @return A pointer to the new PDU object or @c NULL on error. + */ +coap_pdu_t *coap_pdu_init(coap_pdu_type_t type, coap_pdu_code_t code, + coap_mid_t mid, size_t size); + +/** + * Creates a new CoAP PDU. + * + * @param type The type of the PDU (one of COAP_MESSAGE_CON, COAP_MESSAGE_NON, + * COAP_MESSAGE_ACK, COAP_MESSAGE_RST). + * @param code The message code of the PDU. + * @param session The session that will be using this PDU + * + * @return The skeletal PDU or @c NULL if failure. + */ +coap_pdu_t *coap_new_pdu(coap_pdu_type_t type, coap_pdu_code_t code, + coap_session_t *session); + +/** + * Dispose of an CoAP PDU and frees associated storage. + * Not that in general you should not call this function directly. + * When a PDU is sent with coap_send(), coap_delete_pdu() will be called + * automatically for you. + * + * @param pdu The PDU for free off. + */ +void coap_delete_pdu(coap_pdu_t *pdu); + +/** + * Duplicate an existing PDU. Specific options can be ignored and not copied + * across. The PDU data payload is not copied across. + * + * @param old_pdu The PDU to duplicate + * @param session The session that will be using this PDU. + * @param token_length The length of the token to use in this duplicated PDU. + * @param token The token to use in this duplicated PDU. + * @param drop_options A list of options not to copy into the duplicated PDU. + * If @c NULL, then all options are copied across. + * + * @return The duplicated PDU or @c NULL if failure. + */ +coap_pdu_t * +coap_pdu_duplicate(const coap_pdu_t *old_pdu, + coap_session_t *session, + size_t token_length, + const uint8_t *token, + coap_opt_filter_t *drop_options); + +/** + * Adds token of length @p len to @p pdu. + * Adding the token destroys any following contents of the pdu. Hence options + * and data must be added after coap_add_token() has been called. In @p pdu, + * length is set to @p len + @c 4, and max_delta is set to @c 0. This function + * returns @c 0 on error or a value greater than zero on success. + * + * @param pdu The PDU where the token is to be added. + * @param len The length of the new token. + * @param data The token to add. + * + * @return A value greater than zero on success, or @c 0 on error. + */ +int coap_add_token(coap_pdu_t *pdu, + size_t len, + const uint8_t *data); + +/** + * Adds option of given number to pdu that is passed as first + * parameter. + * coap_add_option() destroys the PDU's data, so coap_add_data() must be called + * after all options have been added. As coap_add_token() destroys the options + * following the token, the token must be added before coap_add_option() is + * called. This function returns the number of bytes written or @c 0 on error. + * + * Note: Where possible, the option data needs to be stripped of leading zeros + * (big endian) to reduce the amount of data needed in the PDU, as well as in + * some cases the maximum data size of an opton can be exceeded if not stripped + * and hence be illegal. This is done by using coap_encode_var_safe() or + * coap_encode_var_safe8(). + * + * @param pdu The PDU where the option is to be added. + * @param number The number of the new option. + * @param len The length of the new option. + * @param data The data of the new option. + * + * @return The overall length of the option or @c 0 on failure. + */ +size_t coap_add_option(coap_pdu_t *pdu, + coap_option_num_t number, + size_t len, + const uint8_t *data); + +/** + * Adds given data to the pdu that is passed as first parameter. Note that the + * PDU's data is destroyed by coap_add_option(). coap_add_data() must be called + * only once per PDU, otherwise the result is undefined. + * + * @param pdu The PDU where the data is to be added. + * @param len The length of the data. + * @param data The data to add. + * + * @return @c 1 if success, else @c 0 if failure. + */ +int coap_add_data(coap_pdu_t *pdu, + size_t len, + const uint8_t *data); + +/** + * Adds given data to the pdu that is passed as first parameter but does not + * copy it. Note that the PDU's data is destroyed by coap_add_option(). + * coap_add_data() must be have been called once for this PDU, otherwise the + * result is undefined. + * The actual data must be copied at the returned location. + * + * @param pdu The PDU where the data is to be added. + * @param len The length of the data. + * + * @return Where to copy the data of len to, or @c NULL is error. + */ +uint8_t *coap_add_data_after(coap_pdu_t *pdu, size_t len); + +/** + * Retrieves the length and data pointer of specified PDU. Returns 0 on error or + * 1 if *len and *data have correct values. Note that these values are destroyed + * with the pdu. + * + * @param pdu The specified PDU. + * @param len Returns the length of the current data + * @param data Returns the ptr to the current data + * + * @return @c 1 if len and data are correctly filled in, else + * @c 0 if there is no data. + */ +int coap_get_data(const coap_pdu_t *pdu, + size_t *len, + const uint8_t **data); + +/** + * Retrieves the data from a PDU, with support for large bodies of data that + * spans multiple PDUs. + * + * Note: The data pointed to on return is destroyed when the PDU is destroyed. + * + * @param pdu The specified PDU. + * @param len Returns the length of the current data + * @param data Returns the ptr to the current data + * @param offset Returns the offset of the current data from the start of the + * body comprising of many blocks (RFC7959) + * @param total Returns the total size of the body. + * If offset + length < total, then there is more data to follow. + * + * @return @c 1 if len, data, offset and total are correctly filled in, else + * @c 0 if there is no data. + */ +int coap_get_data_large(const coap_pdu_t *pdu, + size_t *len, + const uint8_t **data, + size_t *offset, + size_t *total); + +/** + * Gets the PDU code associated with @p pdu. + * + * @param pdu The PDU object. + * + * @return The PDU code. + */ +coap_pdu_code_t coap_pdu_get_code(const coap_pdu_t *pdu); + +/** + * Sets the PDU code in the @p pdu. + * + * @param pdu The PDU object. + * @param code The code to set in the PDU. + */ +void coap_pdu_set_code(coap_pdu_t *pdu, coap_pdu_code_t code); + +/** + * Gets the PDU type associated with @p pdu. + * + * @param pdu The PDU object. + * + * @return The PDU type. + */ +coap_pdu_type_t coap_pdu_get_type(const coap_pdu_t *pdu); + +/** + * Sets the PDU type in the @p pdu. + * + * @param pdu The PDU object. + * @param type The type to set for the PDU. + */ +void coap_pdu_set_type(coap_pdu_t *pdu, coap_pdu_type_t type); + +/** + * Gets the token associated with @p pdu. + * + * @param pdu The PDU object. + * + * @return The token information. + */ +coap_bin_const_t coap_pdu_get_token(const coap_pdu_t *pdu); + +/** + * Gets the message id associated with @p pdu. + * + * @param pdu The PDU object. + * + * @return The message id. + */ +coap_mid_t coap_pdu_get_mid(const coap_pdu_t *pdu); + +/** + * Sets the message id in the @p pdu. + * + * @param pdu The PDU object. + * @param mid The message id value to set in the PDU. + * + */ +void coap_pdu_set_mid(coap_pdu_t *pdu, coap_mid_t mid); + +/** @} */ + +#endif /* COAP_PDU_H_ */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap2/resource.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/resource.h similarity index 55% rename from tools/sdk/esp32/include/coap/libcoap/include/coap2/resource.h rename to tools/sdk/esp32c3/include/coap/libcoap/include/coap3/resource.h index 58018720e4e..2cd9aea48fa 100644 --- a/tools/sdk/esp32/include/coap/libcoap/include/coap2/resource.h +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/resource.h @@ -1,7 +1,9 @@ /* * resource.h -- generic resource handling * - * Copyright (C) 2010,2011,2014,2015 Olaf Bergmann + * Copyright (C) 2010,2011,2014-2021 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause * * This file is part of the CoAP library libcoap. Please see README for terms * of use. @@ -15,100 +17,62 @@ #ifndef COAP_RESOURCE_H_ #define COAP_RESOURCE_H_ -# include - #ifndef COAP_RESOURCE_CHECK_TIME /** The interval in seconds to check if resources have changed. */ #define COAP_RESOURCE_CHECK_TIME 2 #endif /* COAP_RESOURCE_CHECK_TIME */ -#include "uthash.h" #include "async.h" +#include "block.h" #include "str.h" #include "pdu.h" #include "net.h" #include "subscribe.h" /** - * Definition of message handler function (@sa coap_resource_t). + * @defgroup coap_resource Resource Configuraton + * API functions for setting up resources + * @{ + */ + +/** + * Definition of message handler function */ typedef void (*coap_method_handler_t) - (coap_context_t *, - struct coap_resource_t *, + (coap_resource_t *, coap_session_t *, - coap_pdu_t *, - coap_binary_t * /* token */, - coap_string_t * /* query string */, + const coap_pdu_t * /* request */, + const coap_string_t * /* query string */, coap_pdu_t * /* response */); #define COAP_ATTR_FLAGS_RELEASE_NAME 0x1 #define COAP_ATTR_FLAGS_RELEASE_VALUE 0x2 -typedef struct coap_attr_t { - struct coap_attr_t *next; - coap_str_const_t *name; - coap_str_const_t *value; - int flags; -} coap_attr_t; - /** The URI passed to coap_resource_init() is free'd by coap_delete_resource(). */ #define COAP_RESOURCE_FLAGS_RELEASE_URI 0x1 /** * Notifications will be sent non-confirmable by default. RFC 7641 Section 4.5 * https://tools.ietf.org/html/rfc7641#section-4.5 + * Libcoap will always send every fifth packet as confirmable. */ #define COAP_RESOURCE_FLAGS_NOTIFY_NON 0x0 /** - * Notifications will be sent confirmable by default. RFC 7641 Section 4.5 + * Notifications will be sent confirmable. RFC 7641 Section 4.5 * https://tools.ietf.org/html/rfc7641#section-4.5 */ #define COAP_RESOURCE_FLAGS_NOTIFY_CON 0x2 -typedef struct coap_resource_t { - unsigned int dirty:1; /**< set to 1 if resource has changed */ - unsigned int partiallydirty:1; /**< set to 1 if some subscribers have not yet - * been notified of the last change */ - unsigned int observable:1; /**< can be observed */ - unsigned int cacheable:1; /**< can be cached */ - unsigned int is_unknown:1; /**< resource created for unknown handler */ - - /** - * Used to store handlers for the seven coap methods @c GET, @c POST, @c PUT, - * @c DELETE, @c FETCH, @c PATCH and @c IPATCH. - * coap_dispatch() will pass incoming requests to the handler - * that corresponds to its request method or generate a 4.05 response if no - * handler is available. - */ - coap_method_handler_t handler[7]; - - UT_hash_handle hh; - - coap_attr_t *link_attr; /**< attributes to be included with the link format */ - coap_subscription_t *subscribers; /**< list of observers for this resource */ - - /** - * Request URI Path for this resource. This field will point into static - * or allocated memory which must remain there for the duration of the - * resource. - */ - coap_str_const_t *uri_path; /**< the key used for hash lookup for this resource */ - int flags; - - /** - * The next value for the Observe option. This field must be increased each - * time the resource changes. Only the lower 24 bits are sent. - */ - unsigned int observe; - - /** - * This pointer is under user control. It can be used to store context for - * the coap handler. - */ - void *user_data; - -} coap_resource_t; +/** + * Notifications will always be sent non-confirmable. This is in + * violation of RFC 7641 Section 4.5 + * https://tools.ietf.org/html/rfc7641#section-4.5 + * but required by the DOTS signal channel protocol which needs to operate in + * lossy DDoS attack environments. + * https://tools.ietf.org/html/rfc8782#section-4.4.2.1 + */ +#define COAP_RESOURCE_FLAGS_NOTIFY_NON_ALWAYS 0x4 /** * Creates a new resource object and initializes the link field to the string @@ -173,6 +137,45 @@ coap_resource_t *coap_resource_init(coap_str_const_t *uri_path, */ coap_resource_t *coap_resource_unknown_init(coap_method_handler_t put_handler); +/** + * Creates a new resource object for handling proxy URIs. + * This function returns the new coap_resource_t object. + * + * Note: There can only be one proxy resource handler per context - attaching + * a new one overrides the previous definition. + * + * @param handler The PUT/POST/GET etc. handler that handles all request types. + * @param host_name_count The number of provided host_name_list entries. A + * minimum of 1 must be provided. + * @param host_name_list Array of depth host_name_count names that this proxy + * is known by. + * + * @return A pointer to the new object or @c NULL on error. + */ +coap_resource_t *coap_resource_proxy_uri_init(coap_method_handler_t handler, + size_t host_name_count, const char *host_name_list[]); + +/** + * Returns the resource identified by the unique string @p uri_path. If no + * resource was found, this function returns @c NULL. + * + * @param context The context to look for this resource. + * @param uri_path The unique string uri of the resource. + * + * @return A pointer to the resource or @c NULL if not found. + */ +coap_resource_t *coap_get_resource_from_uri_path(coap_context_t *context, + coap_str_const_t *uri_path); + +/** + * Get the uri_path from a @p resource. + * + * @param resource The CoAP resource to check. + * + * @return The uri_path if it exists or @c NULL otherwise. + */ +coap_str_const_t* coap_resource_get_uri_path(coap_resource_t *resource); + /** * Sets the notification message type of resource @p resource to given * @p mode @@ -181,38 +184,43 @@ coap_resource_t *coap_resource_unknown_init(coap_method_handler_t put_handler); * @param mode Must be one of @c COAP_RESOURCE_FLAGS_NOTIFY_NON * or @c COAP_RESOURCE_FLAGS_NOTIFY_CON. */ -COAP_STATIC_INLINE void -coap_resource_set_mode(coap_resource_t *resource, int mode) { - resource->flags = (resource->flags & - ~(COAP_RESOURCE_FLAGS_NOTIFY_CON|COAP_RESOURCE_FLAGS_NOTIFY_NON)) | - (mode & (COAP_RESOURCE_FLAGS_NOTIFY_CON|COAP_RESOURCE_FLAGS_NOTIFY_NON)); -} +void coap_resource_set_mode(coap_resource_t *resource, int mode); /** * Sets the user_data. The user_data is exclusively used by the library-user - * and can be used as context in the handler functions. + * and can be used as user defined context in the handler functions. * - * @param r Resource to attach the data to - * @param data Data to attach to the user_data field. This pointer is only used for - * storage, the data remains under user control + * @param resource Resource to attach the data to + * @param data Data to attach to the user_data field. This pointer is + * only used for storage, the data remains under user control */ -COAP_STATIC_INLINE void -coap_resource_set_userdata(coap_resource_t *r, void *data) { - r->user_data = data; -} +void coap_resource_set_userdata(coap_resource_t *resource, void *data); /** * Gets the user_data. The user_data is exclusively used by the library-user * and can be used as context in the handler functions. * - * @param r Resource to retrieve the user_darta from + * @param resource Resource to retrieve the user_data from * * @return The user_data pointer */ -COAP_STATIC_INLINE void * -coap_resource_get_userdata(coap_resource_t *r) { - return r->user_data; -} +void *coap_resource_get_userdata(coap_resource_t *resource); + +/** + * Definition of release resource user_data callback function + */ +typedef void (*coap_resource_release_userdata_handler_t)(void *user_data); + +/** + * Defines the context wide callback to use to when the resource is deleted + * to release the data held in the resource's user_data. + * + * @param context The context to associate the release callback with + * @param callback The callback to invoke when the resource is deleted or NULL + * + */ +void coap_resource_release_userdata_handler(coap_context_t *context, + coap_resource_release_userdata_handler_t callback); /** * Registers the given @p resource for @p context. The resource must have been @@ -237,11 +245,16 @@ void coap_add_resource(coap_context_t *context, coap_resource_t *resource); int coap_delete_resource(coap_context_t *context, coap_resource_t *resource); /** - * Deletes all resources from given @p context and frees their storage. + * Registers the specified @p handler as message handler for the request type @p + * method * - * @param context The CoAP context with the resources to be deleted. + * @param resource The resource for which the handler shall be registered. + * @param method The CoAP request method to handle. + * @param handler The handler to register with @p resource. */ -void coap_delete_all_resources(coap_context_t *context); +void coap_register_handler(coap_resource_t *resource, + coap_request_t method, + coap_method_handler_t handler); /** * Registers a new attribute with the given @p resource. As the @@ -291,13 +304,13 @@ coap_attr_t *coap_find_attr(coap_resource_t *resource, coap_str_const_t *name); /** - * Deletes an attribute. - * Note: This is for internal use only, as it is not deleted from its chain. + * Returns @p attribute's value. * - * @param attr Pointer to a previously created attribute. + * @param attribute Pointer to attribute. * + * @return Attribute's value or @c NULL. */ -void coap_delete_attr(coap_attr_t *attr); +coap_str_const_t *coap_attr_get_value(coap_attr_t *attribute); /** * Status word to encode the result of conditional print or copy operations such @@ -341,17 +354,7 @@ coap_print_status_t coap_print_link(const coap_resource_t *resource, size_t *len, size_t *offset); -/** - * Registers the specified @p handler as message handler for the request type @p - * method - * - * @param resource The resource for which the handler shall be registered. - * @param method The CoAP request method to handle. - * @param handler The handler to register with @p resource. - */ -void coap_register_handler(coap_resource_t *resource, - unsigned char method, - coap_method_handler_t handler); +/** @} */ /** * Returns the resource identified by the unique string @p uri_path. If no @@ -365,155 +368,6 @@ void coap_register_handler(coap_resource_t *resource, coap_resource_t *coap_get_resource_from_uri_path(coap_context_t *context, coap_str_const_t *uri_path); -/** - * @addtogroup observe - */ - -/** - * Adds the specified peer as observer for @p resource. The subscription is - * identified by the given @p token. This function returns the registered - * subscription information if the @p observer has been added, or @c NULL on - * error. - * - * @param resource The observed resource. - * @param session The observer's session - * @param token The token that identifies this subscription. - * @param query The query string, if any. subscription will - take ownership of the string. - * @param has_block2 If Option Block2 defined. - * @param block2 Contents of Block2 if Block 2 defined. - * @return A pointer to the added/updated subscription - * information or @c NULL on error. - */ -coap_subscription_t *coap_add_observer(coap_resource_t *resource, - coap_session_t *session, - const coap_binary_t *token, - coap_string_t *query, - int has_block2, - coap_block_t block2); - -/** - * Returns a subscription object for given @p peer. - * - * @param resource The observed resource. - * @param session The observer's session - * @param token The token that identifies this subscription or @c NULL for - * any token. - * @return A valid subscription if exists or @c NULL otherwise. - */ -coap_subscription_t *coap_find_observer(coap_resource_t *resource, - coap_session_t *session, - const coap_binary_t *token); - -/** - * Marks an observer as alive. - * - * @param context The CoAP context to use. - * @param session The observer's session - * @param token The corresponding token that has been used for the - * subscription. - */ -void coap_touch_observer(coap_context_t *context, - coap_session_t *session, - const coap_binary_t *token); - -/** - * Removes any subscription for @p observer from @p resource and releases the - * allocated storage. The result is @c 1 if an observation relationship with @p - * observer and @p token existed, @c 0 otherwise. - * - * @param resource The observed resource. - * @param session The observer's session. - * @param token The token that identifies this subscription or @c NULL for - * any token. - * @return @c 1 if the observer has been deleted, @c 0 otherwise. - */ -int coap_delete_observer(coap_resource_t *resource, - coap_session_t *session, - const coap_binary_t *token); - -/** - * Removes any subscription for @p session and releases the allocated storage. - * - * @param context The CoAP context to use. - * @param session The observer's session. - */ -void coap_delete_observers(coap_context_t *context, coap_session_t *session); - -/** - * Checks for all known resources, if they are dirty and notifies subscribed - * observers. - */ -void coap_check_notify(coap_context_t *context); - -#define RESOURCES_ADD(r, obj) \ - HASH_ADD(hh, (r), uri_path->s[0], (obj)->uri_path->length, (obj)) - -#define RESOURCES_DELETE(r, obj) \ - HASH_DELETE(hh, (r), (obj)) - -#define RESOURCES_ITER(r,tmp) \ - coap_resource_t *tmp, *rtmp; \ - HASH_ITER(hh, (r), tmp, rtmp) - -#define RESOURCES_FIND(r, k, res) { \ - HASH_FIND(hh, (r), (k)->s, (k)->length, (res)); \ - } - -/** @} */ - -coap_print_status_t coap_print_wellknown(coap_context_t *, - unsigned char *, - size_t *, size_t, - coap_opt_t *); - -void -coap_handle_failed_notify(coap_context_t *, - coap_session_t *, - const coap_binary_t *); - -/** - * Set whether a @p resource is observable. If the resource is observable - * and the client has set the COAP_OPTION_OBSERVE in a request packet, then - * whenever the state of the resource changes (a call to - * coap_resource_trigger_observe()), an Observer response will get sent. - * - * @param resource The CoAP resource to use. - * @param mode @c 1 if Observable is to be set, @c 0 otherwise. - * - */ -COAP_STATIC_INLINE void -coap_resource_set_get_observable(coap_resource_t *resource, int mode) { - resource->observable = mode ? 1 : 0; -} - -/** - * Initiate the sending of an Observe packet for all observers of @p resource, - * optionally matching @p query if not NULL - * - * @param resource The CoAP resource to use. - * @param query The Query to match against or NULL - * - * @return @c 1 if the Observe has been triggered, @c 0 otherwise. - */ -int -coap_resource_notify_observers(coap_resource_t *resource, - const coap_string_t *query); - -/** - * Get the UriPath from a @p resource. - * - * @param resource The CoAP resource to check. - * - * @return The UriPath if it exists or @c NULL otherwise. - */ -COAP_STATIC_INLINE coap_str_const_t* -coap_resource_get_uri_path(coap_resource_t *resource) { - if (resource) - return resource->uri_path; - return NULL; -} - /** * @deprecated use coap_resource_notify_observers() instead. */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/str.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/str.h new file mode 100644 index 00000000000..dbf53d0c475 --- /dev/null +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/str.h @@ -0,0 +1,204 @@ +/* + * str.h -- strings to be used in the CoAP library + * + * Copyright (C) 2010-2011 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +#ifndef COAP_STR_H_ +#define COAP_STR_H_ + +#include + + +/** + * @defgroup string String handling support + * API functions for handling strings and binary data + * @{ + */ + +/* + * Note: string and binary use equivalent objects. + * string is likely to contain readable textual information, binary will not. + */ + +/** + * CoAP string data definition + */ +typedef struct coap_string_t { + size_t length; /**< length of string */ + uint8_t *s; /**< string data */ +} coap_string_t; + +/** + * CoAP string data definition with const data + */ +typedef struct coap_str_const_t { + size_t length; /**< length of string */ + const uint8_t *s; /**< read-only string data */ +} coap_str_const_t; + +#define COAP_SET_STR(st,l,v) { (st)->length = (l), (st)->s = (v); } + +/** + * CoAP binary data definition + */ +typedef struct coap_binary_t { + size_t length; /**< length of binary data */ + uint8_t *s; /**< binary data */ +} coap_binary_t; + +/** + * CoAP binary data definition with const data + */ +typedef struct coap_bin_const_t { + size_t length; /**< length of binary data */ + const uint8_t *s; /**< read-only binary data */ +} coap_bin_const_t; + +/** + * Returns a new string object with at least size+1 bytes storage allocated. + * It is the responsibility of the caller to fill in all the appropriate + * information. + * The string must be released using coap_delete_string(). + * + * @param size The size to allocate for the string data. + * + * @return A pointer to the new object or @c NULL on error. + */ +coap_string_t *coap_new_string(size_t size); + +/** + * Deletes the given string and releases any memory allocated. + * + * @param string The string to free off. + */ +void coap_delete_string(coap_string_t *string); + +/** + * Returns a new const string object with at least size+1 bytes storage + * allocated, and the provided data copied into the string object. + * The string must be released using coap_delete_str_const(). + * + * @param data The data to put in the new string object. + * @param size The size to allocate for the binary string data. + * + * @return A pointer to the new object or @c NULL on error. + */ +coap_str_const_t *coap_new_str_const(const uint8_t *data, size_t size); + +/** + * Deletes the given const string and releases any memory allocated. + * + * @param string The string to free off. + */ +void coap_delete_str_const(coap_str_const_t *string); + +/** + * Returns a new binary object with at least size bytes storage allocated. + * It is the responsibility of the caller to fill in all the appropriate + * information. + * The coap_binary_t object must be released using coap_delete_binary(). + * + * @param size The size to allocate for the binary data. + * + * @return A pointer to the new object or @c NULL on error. + */ +coap_binary_t *coap_new_binary(size_t size); + +/** + * Deletes the given coap_binary_t object and releases any memory allocated. + * + * @param binary The coap_binary_t object to free off. + */ +void coap_delete_binary(coap_binary_t *binary); + +/** + * Resizes the given coap_binary_t object. + * It is the responsibility of the caller to fill in all the appropriate + * additional information. + * + * Note: If there is an error, @p binary will separately need to be released by + * coap_delete_binary(). + * + * @param binary The coap_binary_t object to resize. + * @param new_size The new size to allocate for the binary data. + * + * @return A pointer to the new object or @c NULL on error. + */ +coap_binary_t *coap_resize_binary(coap_binary_t *binary, size_t new_size); + +/** + * Take the specified byte array (text) and create a coap_bin_const_t * + * Returns a new const binary object with at least size bytes storage + * allocated, and the provided data copied into the binary object. + * The binary data must be released using coap_delete_bin_const(). + * + * @param data The data to put in the new string object. + * @param size The size to allocate for the binary data. + * + * @return A pointer to the new object or @c NULL on error. + */ +coap_bin_const_t *coap_new_bin_const(const uint8_t *data, size_t size); + +/** + * Deletes the given const binary data and releases any memory allocated. + * + * @param binary The binary data to free off. + */ +void coap_delete_bin_const(coap_bin_const_t *binary); + +#ifndef COAP_MAX_STR_CONST_FUNC +#define COAP_MAX_STR_CONST_FUNC 2 +#endif /* COAP_MAX_STR_CONST_FUNC */ + +/** + * Take the specified byte array (text) and create a coap_str_const_t * + * + * Note: the array is 2 deep as there are up to two callings of + * coap_make_str_const in a function call. e.g. coap_add_attr(). + * Caution: If there are local variable assignments, these will cycle around + * the var[COAP_MAX_STR_CONST_FUNC] set. No current examples do this. + * + * @param string The const string to convert to a coap_str_const_t * + * + * @return A pointer to one of two static variables containing the + * coap_str_const_t * result + */ +coap_str_const_t *coap_make_str_const(const char *string); + +/** + * Compares the two strings for equality + * + * @param string1 The first string. + * @param string2 The second string. + * + * @return @c 1 if the strings are equal + * @c 0 otherwise. + */ +#define coap_string_equal(string1,string2) \ + ((string1)->length == (string2)->length && ((string1)->length == 0 || \ + ((string1)->s && (string2)->s && \ + memcmp((string1)->s, (string2)->s, (string1)->length) == 0))) + +/** + * Compares the two binary data for equality + * + * @param binary1 The first binary data. + * @param binary2 The second binary data. + * + * @return @c 1 if the binary data is equal + * @c 0 otherwise. + */ +#define coap_binary_equal(binary1,binary2) \ + ((binary1)->length == (binary2)->length && ((binary1)->length == 0 || \ + ((binary1)->s && (binary2)->s && \ + memcmp((binary1)->s, (binary2)->s, (binary1)->length) == 0))) + +/** @} */ + +#endif /* COAP_STR_H_ */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/subscribe.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/subscribe.h new file mode 100644 index 00000000000..c3aabc2db04 --- /dev/null +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/subscribe.h @@ -0,0 +1,68 @@ +/* + * subscribe.h -- subscription handling for CoAP + * see RFC7641 + * + * Copyright (C) 2010-2012,2014-2021 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file subscribe.h + * @brief Defines the application visible subscribe information + */ + +#ifndef COAP_SUBSCRIBE_H_ +#define COAP_SUBSCRIBE_H_ + +/** + * @defgroup observe Resource Observation + * API functions for interfacing with the observe handling (RFC7641) + * @{ + */ + +/** + * The value COAP_OBSERVE_ESTABLISH in a GET/FETCH request option + * COAP_OPTION_OBSERVE indicates a new observe relationship for (sender + * address, token) is requested. + */ +#define COAP_OBSERVE_ESTABLISH 0 + +/** + * The value COAP_OBSERVE_CANCEL in a GET/FETCH request option + * COAP_OPTION_OBSERVE indicates that the observe relationship for (sender + * address, token) must be cancelled. + */ +#define COAP_OBSERVE_CANCEL 1 + +/** + * Set whether a @p resource is observable. If the resource is observable + * and the client has set the COAP_OPTION_OBSERVE in a request packet, then + * whenever the state of the resource changes (a call to + * coap_resource_trigger_observe()), an Observer response will get sent. + * + * @param resource The CoAP resource to use. + * @param mode @c 1 if Observable is to be set, @c 0 otherwise. + * + */ +void coap_resource_set_get_observable(coap_resource_t *resource, int mode); + +/** + * Initiate the sending of an Observe packet for all observers of @p resource, + * optionally matching @p query if not NULL + * + * @param resource The CoAP resource to use. + * @param query The Query to match against or NULL + * + * @return @c 1 if the Observe has been triggered, @c 0 otherwise. + */ +int +coap_resource_notify_observers(coap_resource_t *resource, + const coap_string_t *query); + +/** @} */ + +#endif /* COAP_SUBSCRIBE_H_ */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap2/uri.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/uri.h similarity index 67% rename from tools/sdk/esp32/include/coap/libcoap/include/coap2/uri.h rename to tools/sdk/esp32c3/include/coap/libcoap/include/coap3/uri.h index 4d1670115eb..8084483b500 100644 --- a/tools/sdk/esp32/include/coap/libcoap/include/coap2/uri.h +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/uri.h @@ -1,7 +1,9 @@ /* * uri.h -- helper functions for URI treatment * - * Copyright (C) 2010-2011,2016 Olaf Bergmann + * Copyright (C) 2010-2020 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause * * This file is part of the CoAP library libcoap. Please see README for terms * of use. @@ -13,25 +15,27 @@ #include #include "str.h" -struct coap_pdu_t; /** * The scheme specifiers. Secure schemes have an odd numeric value, * others are even. */ -enum coap_uri_scheme_t { - COAP_URI_SCHEME_COAP=0, - COAP_URI_SCHEME_COAPS=1, - COAP_URI_SCHEME_COAP_TCP=2, - COAP_URI_SCHEME_COAPS_TCP=3 -}; +typedef enum coap_uri_scheme_t { + COAP_URI_SCHEME_COAP = 0, + COAP_URI_SCHEME_COAPS, /* 1 */ + COAP_URI_SCHEME_COAP_TCP, /* 2 */ + COAP_URI_SCHEME_COAPS_TCP, /* 3 */ + COAP_URI_SCHEME_HTTP, /* 4 Proxy-Uri only */ + COAP_URI_SCHEME_HTTPS /* 5 Proxy-Uri only */ +} coap_uri_scheme_t; /** This mask can be used to check if a parsed URI scheme is secure. */ #define COAP_URI_SCHEME_SECURE_MASK 0x01 /** * Representation of parsed URI. Components may be filled from a string with - * coap_split_uri() and can be used as input for option-creation functions. + * coap_split_uri() or coap_split_proxy_uri() and can be used as input for + * option-creation functions. */ typedef struct { coap_str_const_t host; /**< host part of the URI */ @@ -79,17 +83,36 @@ coap_uri_t *coap_clone_uri(const coap_uri_t *uri); * Parses a given string into URI components. The identified syntactic * components are stored in the result parameter @p uri. Optional URI * components that are not specified will be set to { 0, 0 }, except for the - * port which is set to @c COAP_DEFAULT_PORT. This function returns @p 0 if - * parsing succeeded, a value less than zero otherwise. + * port which is set to the default port for the protocol. This function + * returns @p 0 if parsing succeeded, a value less than zero otherwise. * * @param str_var The string to split up. * @param len The actual length of @p str_var * @param uri The coap_uri_t object to store the result. + * * @return @c 0 on success, or < 0 on error. * */ int coap_split_uri(const uint8_t *str_var, size_t len, coap_uri_t *uri); +/** + * Parses a given string into URI components. The identified syntactic + * components are stored in the result parameter @p uri. Optional URI + * components that are not specified will be set to { 0, 0 }, except for the + * port which is set to default port for the protocol. This function returns + * @p 0 if parsing succeeded, a value less than zero otherwise. + * Note: This function enforces that the given string is in Proxy-Uri format + * as well as supports different schema such as http. + * + * @param str_var The string to split up. + * @param len The actual length of @p str_var + * @param uri The coap_uri_t object to store the result. + * + * @return @c 0 on success, or < 0 on error. + * + */ +int coap_split_proxy_uri(const uint8_t *str_var, size_t len, coap_uri_t *uri); + /** * Splits the given URI path into segments. Each segment is preceded * by an option pseudo-header with delta-value 0 and the actual length @@ -131,16 +154,22 @@ int coap_split_query(const uint8_t *s, /** * Extract query string from request PDU according to escape rules in 6.5.8. * @param request Request PDU. - * @return Reconstructed and escaped query string part. + * @return Reconstructed and escaped query string part or @c NULL if + * no query was contained in @p request. The coap_string_t + * object returned by this function must be released with + * coap_delete_string. */ -coap_string_t *coap_get_query(const struct coap_pdu_t *request); +coap_string_t *coap_get_query(const coap_pdu_t *request); /** * Extract uri_path string from request PDU * @param request Request PDU. - * @return Reconstructed and escaped uri path string part. + * @return Reconstructed and escaped uri path string part or @c NULL + * if no URI-Path was contained in @p request. The + * coap_string_t object returned by this function must be + * released with coap_delete_string. */ -coap_string_t *coap_get_uri_path(const struct coap_pdu_t *request); +coap_string_t *coap_get_uri_path(const coap_pdu_t *request); /** @} */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/uthash.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/uthash.h similarity index 81% rename from tools/sdk/esp32s2/include/coap/libcoap/include/coap2/uthash.h rename to tools/sdk/esp32c3/include/coap/libcoap/include/coap3/uthash.h index 156eb8210c1..9a396b6179f 100644 --- a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/uthash.h +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/uthash.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2017, Troy D. Hanson http://troydhanson.github.com/uthash/ +Copyright (c) 2003-2021, Troy D. Hanson http://troydhanson.github.io/uthash/ All rights reserved. Redistribution and use in source and binary forms, with or without @@ -24,12 +24,22 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef UTHASH_H #define UTHASH_H -#define UTHASH_VERSION 2.0.2 +#define UTHASH_VERSION 2.3.0 #include /* memcmp, memset, strlen */ #include /* ptrdiff_t */ #include /* exit */ +#if defined(HASH_DEFINE_OWN_STDINT) && HASH_DEFINE_OWN_STDINT +/* This codepath is provided for backward compatibility, but I plan to remove it. */ +#warning "HASH_DEFINE_OWN_STDINT is deprecated; please use HASH_NO_STDINT instead" +typedef unsigned int uint32_t; +typedef unsigned char uint8_t; +#elif defined(HASH_NO_STDINT) && HASH_NO_STDINT +#else +#include /* uint8_t, uint32_t */ +#endif + /* These macros use decltype or the earlier __typeof GNU extension. As decltype is only available in newer compilers (VS2010 or gcc 4.3+ when compiling c++ source) this code uses whatever method is needed @@ -62,26 +72,6 @@ do { } while (0) #endif -/* a number of the hash function use uint32_t which isn't defined on Pre VS2010 */ -#if defined(_WIN32) -#if defined(_MSC_VER) && _MSC_VER >= 1600 -#include -#elif defined(__WATCOMC__) || defined(__MINGW32__) || defined(__CYGWIN__) -#include -#else -typedef unsigned int uint32_t; -typedef unsigned char uint8_t; -#endif -#elif defined(__GNUC__) && !defined(__VXWORKS__) -#include -#else -typedef unsigned int uint32_t; -typedef unsigned char uint8_t; -#endif - -#ifndef uthash_fatal -#define uthash_fatal(msg) exit(-1) /* fatal error (out of memory,etc) */ -#endif #ifndef uthash_malloc #define uthash_malloc(sz) malloc(sz) /* malloc fcn */ #endif @@ -91,13 +81,18 @@ typedef unsigned char uint8_t; #ifndef uthash_bzero #define uthash_bzero(a,n) memset(a,'\0',n) #endif -#ifndef uthash_memcmp -#define uthash_memcmp(a,b,n) memcmp(a,b,n) -#endif #ifndef uthash_strlen #define uthash_strlen(s) strlen(s) #endif +#ifndef HASH_FUNCTION +#define HASH_FUNCTION(keyptr,keylen,hashv) HASH_JEN(keyptr, keylen, hashv) +#endif + +#ifndef HASH_KEYCMP +#define HASH_KEYCMP(a,b,n) memcmp(a,b,n) +#endif + #ifndef uthash_noexpand_fyi #define uthash_noexpand_fyi(tbl) /* can be defined to log noexpand */ #endif @@ -105,6 +100,32 @@ typedef unsigned char uint8_t; #define uthash_expand_fyi(tbl) /* can be defined to log expands */ #endif +#ifndef HASH_NONFATAL_OOM +#define HASH_NONFATAL_OOM 0 +#endif + +#if HASH_NONFATAL_OOM +/* malloc failures can be recovered from */ + +#ifndef uthash_nonfatal_oom +#define uthash_nonfatal_oom(obj) do {} while (0) /* non-fatal OOM error */ +#endif + +#define HASH_RECORD_OOM(oomed) do { (oomed) = 1; } while (0) +#define IF_HASH_NONFATAL_OOM(x) x + +#else +/* malloc failures result in lost memory, hash tables are unusable */ + +#ifndef uthash_fatal +#define uthash_fatal(msg) exit(-1) /* fatal OOM error */ +#endif + +#define HASH_RECORD_OOM(oomed) uthash_fatal("out of memory") +#define IF_HASH_NONFATAL_OOM(x) + +#endif + /* initial number of buckets */ #define HASH_INITIAL_NUM_BUCKETS 32U /* initial number of buckets */ #define HASH_INITIAL_NUM_BUCKETS_LOG2 5U /* lg2 of initial number of buckets */ @@ -113,11 +134,21 @@ typedef unsigned char uint8_t; /* calculate the element whose hash handle address is hhp */ #define ELMT_FROM_HH(tbl,hhp) ((void*)(((char*)(hhp)) - ((tbl)->hho))) /* calculate the hash handle from element address elp */ -#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle *)(((char*)(elp)) + ((tbl)->hho))) +#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle*)(void*)(((char*)(elp)) + ((tbl)->hho))) + +#define HASH_ROLLBACK_BKT(hh, head, itemptrhh) \ +do { \ + struct UT_hash_handle *_hd_hh_item = (itemptrhh); \ + unsigned _hd_bkt; \ + HASH_TO_BKT(_hd_hh_item->hashv, (head)->hh.tbl->num_buckets, _hd_bkt); \ + (head)->hh.tbl->buckets[_hd_bkt].count++; \ + _hd_hh_item->hh_next = NULL; \ + _hd_hh_item->hh_prev = NULL; \ +} while (0) #define HASH_VALUE(keyptr,keylen,hashv) \ do { \ - HASH_FCN(keyptr, keylen, hashv); \ + HASH_FUNCTION(keyptr, keylen, hashv); \ } while (0) #define HASH_FIND_BYHASHVALUE(hh,head,keyptr,keylen,hashval,out) \ @@ -134,23 +165,27 @@ do { #define HASH_FIND(hh,head,keyptr,keylen,out) \ do { \ - unsigned _hf_hashv; \ - HASH_VALUE(keyptr, keylen, _hf_hashv); \ - HASH_FIND_BYHASHVALUE(hh, head, keyptr, keylen, _hf_hashv, out); \ + (out) = NULL; \ + if (head) { \ + unsigned _hf_hashv; \ + HASH_VALUE(keyptr, keylen, _hf_hashv); \ + HASH_FIND_BYHASHVALUE(hh, head, keyptr, keylen, _hf_hashv, out); \ + } \ } while (0) #ifdef HASH_BLOOM #define HASH_BLOOM_BITLEN (1UL << HASH_BLOOM) #define HASH_BLOOM_BYTELEN (HASH_BLOOM_BITLEN/8UL) + (((HASH_BLOOM_BITLEN%8UL)!=0UL) ? 1UL : 0UL) -#define HASH_BLOOM_MAKE(tbl) \ +#define HASH_BLOOM_MAKE(tbl,oomed) \ do { \ (tbl)->bloom_nbits = HASH_BLOOM; \ (tbl)->bloom_bv = (uint8_t*)uthash_malloc(HASH_BLOOM_BYTELEN); \ if (!(tbl)->bloom_bv) { \ - uthash_fatal("out of memory"); \ + HASH_RECORD_OOM(oomed); \ + } else { \ + uthash_bzero((tbl)->bloom_bv, HASH_BLOOM_BYTELEN); \ + (tbl)->bloom_sig = HASH_BLOOM_SIGNATURE; \ } \ - uthash_bzero((tbl)->bloom_bv, HASH_BLOOM_BYTELEN); \ - (tbl)->bloom_sig = HASH_BLOOM_SIGNATURE; \ } while (0) #define HASH_BLOOM_FREE(tbl) \ @@ -162,39 +197,49 @@ do { #define HASH_BLOOM_BITTEST(bv,idx) (bv[(idx)/8U] & (1U << ((idx)%8U))) #define HASH_BLOOM_ADD(tbl,hashv) \ - HASH_BLOOM_BITSET((tbl)->bloom_bv, (hashv & (uint32_t)((1UL << (tbl)->bloom_nbits) - 1U))) + HASH_BLOOM_BITSET((tbl)->bloom_bv, ((hashv) & (uint32_t)((1UL << (tbl)->bloom_nbits) - 1U))) #define HASH_BLOOM_TEST(tbl,hashv) \ - HASH_BLOOM_BITTEST((tbl)->bloom_bv, (hashv & (uint32_t)((1UL << (tbl)->bloom_nbits) - 1U))) + HASH_BLOOM_BITTEST((tbl)->bloom_bv, ((hashv) & (uint32_t)((1UL << (tbl)->bloom_nbits) - 1U))) #else -#define HASH_BLOOM_MAKE(tbl) +#define HASH_BLOOM_MAKE(tbl,oomed) #define HASH_BLOOM_FREE(tbl) #define HASH_BLOOM_ADD(tbl,hashv) #define HASH_BLOOM_TEST(tbl,hashv) (1) #define HASH_BLOOM_BYTELEN 0U #endif -#define HASH_MAKE_TABLE(hh,head) \ +#define HASH_MAKE_TABLE(hh,head,oomed) \ do { \ (head)->hh.tbl = (UT_hash_table*)uthash_malloc(sizeof(UT_hash_table)); \ if (!(head)->hh.tbl) { \ - uthash_fatal("out of memory"); \ - } \ - uthash_bzero((head)->hh.tbl, sizeof(UT_hash_table)); \ - (head)->hh.tbl->tail = &((head)->hh); \ - (head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \ - (head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \ - (head)->hh.tbl->hho = (char*)(&(head)->hh) - (char*)(head); \ - (head)->hh.tbl->buckets = (UT_hash_bucket*)uthash_malloc( \ - HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \ - if (!(head)->hh.tbl->buckets) { \ - uthash_fatal("out of memory"); \ + HASH_RECORD_OOM(oomed); \ + } else { \ + uthash_bzero((head)->hh.tbl, sizeof(UT_hash_table)); \ + (head)->hh.tbl->tail = &((head)->hh); \ + (head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \ + (head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \ + (head)->hh.tbl->hho = (char*)(&(head)->hh) - (char*)(head); \ + (head)->hh.tbl->buckets = (UT_hash_bucket*)uthash_malloc( \ + HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \ + (head)->hh.tbl->signature = HASH_SIGNATURE; \ + if (!(head)->hh.tbl->buckets) { \ + HASH_RECORD_OOM(oomed); \ + uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \ + } else { \ + uthash_bzero((head)->hh.tbl->buckets, \ + HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \ + HASH_BLOOM_MAKE((head)->hh.tbl, oomed); \ + IF_HASH_NONFATAL_OOM( \ + if (oomed) { \ + uthash_free((head)->hh.tbl->buckets, \ + HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket)); \ + uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \ + } \ + ) \ + } \ } \ - uthash_bzero((head)->hh.tbl->buckets, \ - HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \ - HASH_BLOOM_MAKE((head)->hh.tbl); \ - (head)->hh.tbl->signature = HASH_SIGNATURE; \ } while (0) #define HASH_REPLACE_BYHASHVALUE_INORDER(hh,head,fieldname,keylen_in,hashval,add,replaced,cmpfcn) \ @@ -264,17 +309,58 @@ do { } while (0) #endif -#define HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh,head,keyptr,keylen_in,hashval,add,cmpfcn) \ +#if HASH_NONFATAL_OOM + +#define HASH_ADD_TO_TABLE(hh,head,keyptr,keylen_in,hashval,add,oomed) \ +do { \ + if (!(oomed)) { \ + unsigned _ha_bkt; \ + (head)->hh.tbl->num_items++; \ + HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt); \ + HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], hh, &(add)->hh, oomed); \ + if (oomed) { \ + HASH_ROLLBACK_BKT(hh, head, &(add)->hh); \ + HASH_DELETE_HH(hh, head, &(add)->hh); \ + (add)->hh.tbl = NULL; \ + uthash_nonfatal_oom(add); \ + } else { \ + HASH_BLOOM_ADD((head)->hh.tbl, hashval); \ + HASH_EMIT_KEY(hh, head, keyptr, keylen_in); \ + } \ + } else { \ + (add)->hh.tbl = NULL; \ + uthash_nonfatal_oom(add); \ + } \ +} while (0) + +#else + +#define HASH_ADD_TO_TABLE(hh,head,keyptr,keylen_in,hashval,add,oomed) \ do { \ unsigned _ha_bkt; \ + (head)->hh.tbl->num_items++; \ + HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt); \ + HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], hh, &(add)->hh, oomed); \ + HASH_BLOOM_ADD((head)->hh.tbl, hashval); \ + HASH_EMIT_KEY(hh, head, keyptr, keylen_in); \ +} while (0) + +#endif + + +#define HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh,head,keyptr,keylen_in,hashval,add,cmpfcn) \ +do { \ + IF_HASH_NONFATAL_OOM( int _ha_oomed = 0; ) \ (add)->hh.hashv = (hashval); \ (add)->hh.key = (char*) (keyptr); \ (add)->hh.keylen = (unsigned) (keylen_in); \ if (!(head)) { \ (add)->hh.next = NULL; \ (add)->hh.prev = NULL; \ - (head) = (add); \ - HASH_MAKE_TABLE(hh, head); \ + HASH_MAKE_TABLE(hh, add, _ha_oomed); \ + IF_HASH_NONFATAL_OOM( if (!_ha_oomed) { ) \ + (head) = (add); \ + IF_HASH_NONFATAL_OOM( } ) \ } else { \ void *_hs_iter = (head); \ (add)->hh.tbl = (head)->hh.tbl; \ @@ -291,11 +377,7 @@ do { HASH_APPEND_LIST(hh, head, add); \ } \ } \ - (head)->hh.tbl->num_items++; \ - HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt); \ - HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], &(add)->hh); \ - HASH_BLOOM_ADD((head)->hh.tbl, hashval); \ - HASH_EMIT_KEY(hh, head, keyptr, keylen_in); \ + HASH_ADD_TO_TABLE(hh, head, keyptr, keylen_in, hashval, add, _ha_oomed); \ HASH_FSCK(hh, head, "HASH_ADD_KEYPTR_BYHASHVALUE_INORDER"); \ } while (0) @@ -314,24 +396,22 @@ do { #define HASH_ADD_KEYPTR_BYHASHVALUE(hh,head,keyptr,keylen_in,hashval,add) \ do { \ - unsigned _ha_bkt; \ + IF_HASH_NONFATAL_OOM( int _ha_oomed = 0; ) \ (add)->hh.hashv = (hashval); \ - (add)->hh.key = (const void *) (keyptr); \ + (add)->hh.key = (const void*) (keyptr); \ (add)->hh.keylen = (unsigned) (keylen_in); \ if (!(head)) { \ (add)->hh.next = NULL; \ (add)->hh.prev = NULL; \ - (head) = (add); \ - HASH_MAKE_TABLE(hh, head); \ + HASH_MAKE_TABLE(hh, add, _ha_oomed); \ + IF_HASH_NONFATAL_OOM( if (!_ha_oomed) { ) \ + (head) = (add); \ + IF_HASH_NONFATAL_OOM( } ) \ } else { \ (add)->hh.tbl = (head)->hh.tbl; \ HASH_APPEND_LIST(hh, head, add); \ } \ - (head)->hh.tbl->num_items++; \ - HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt); \ - HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], &(add)->hh); \ - HASH_BLOOM_ADD((head)->hh.tbl, hashval); \ - HASH_EMIT_KEY(hh, head, keyptr, keylen_in); \ + HASH_ADD_TO_TABLE(hh, head, keyptr, keylen_in, hashval, add, _ha_oomed); \ HASH_FSCK(hh, head, "HASH_ADD_KEYPTR_BYHASHVALUE"); \ } while (0) @@ -394,17 +474,25 @@ do { HASH_DEL_IN_BKT((head)->hh.tbl->buckets[_hd_bkt], _hd_hh_del); \ (head)->hh.tbl->num_items--; \ } \ - HASH_FSCK(hh, head, "HASH_DELETE"); \ + HASH_FSCK(hh, head, "HASH_DELETE_HH"); \ } while (0) - /* convenience forms of HASH_FIND/HASH_ADD/HASH_DEL */ #define HASH_FIND_STR(head,findstr,out) \ - HASH_FIND(hh,head,findstr,(unsigned)uthash_strlen(findstr),out) +do { \ + unsigned _uthash_hfstr_keylen = (unsigned)uthash_strlen(findstr); \ + HASH_FIND(hh, head, findstr, _uthash_hfstr_keylen, out); \ +} while (0) #define HASH_ADD_STR(head,strfield,add) \ - HASH_ADD(hh,head,strfield[0],(unsigned)uthash_strlen(add->strfield),add) +do { \ + unsigned _uthash_hastr_keylen = (unsigned)uthash_strlen((add)->strfield); \ + HASH_ADD(hh, head, strfield[0], _uthash_hastr_keylen, add); \ +} while (0) #define HASH_REPLACE_STR(head,strfield,add,replaced) \ - HASH_REPLACE(hh,head,strfield[0],(unsigned)uthash_strlen(add->strfield),add,replaced) +do { \ + unsigned _uthash_hrstr_keylen = (unsigned)uthash_strlen((add)->strfield); \ + HASH_REPLACE(hh, head, strfield[0], _uthash_hrstr_keylen, add, replaced); \ +} while (0) #define HASH_FIND_INT(head,findint,out) \ HASH_FIND(hh,head,findint,sizeof(int),out) #define HASH_ADD_INT(head,intfield,add) \ @@ -424,7 +512,8 @@ do { * This is for uthash developer only; it compiles away if HASH_DEBUG isn't defined. */ #ifdef HASH_DEBUG -#define HASH_OOPS(...) do { fprintf(stderr,__VA_ARGS__); exit(-1); } while (0) +#include /* fprintf, stderr */ +#define HASH_OOPS(...) do { fprintf(stderr, __VA_ARGS__); exit(-1); } while (0) #define HASH_FSCK(hh,head,where) \ do { \ struct UT_hash_handle *_thh; \ @@ -491,13 +580,6 @@ do { #define HASH_EMIT_KEY(hh,head,keyptr,fieldlen) #endif -/* default to Jenkin's hash unless overridden e.g. DHASH_FUNCTION=HASH_SAX */ -#ifdef HASH_FUNCTION -#define HASH_FCN HASH_FUNCTION -#else -#define HASH_FCN HASH_JEN -#endif - /* The Bernstein hash function, used in Perl prior to v5.6. Note (x<<5+x)=x*33. */ #define HASH_BER(key,keylen,hashv) \ do { \ @@ -596,8 +678,8 @@ do { case 4: _hj_i += ( (unsigned)_hj_key[3] << 24 ); /* FALLTHROUGH */ \ case 3: _hj_i += ( (unsigned)_hj_key[2] << 16 ); /* FALLTHROUGH */ \ case 2: _hj_i += ( (unsigned)_hj_key[1] << 8 ); /* FALLTHROUGH */ \ - case 1: _hj_i += _hj_key[0]; \ - default: ; /* does not happen */ \ + case 1: _hj_i += _hj_key[0]; /* FALLTHROUGH */ \ + default: ; \ } \ HASH_JEN_MIX(_hj_i, _hj_j, hashv); \ } while (0) @@ -645,6 +727,8 @@ do { case 1: hashv += *_sfh_key; \ hashv ^= hashv << 10; \ hashv += hashv >> 1; \ + break; \ + default: ; \ } \ \ /* Force "avalanching" of final 127 bits */ \ @@ -656,87 +740,6 @@ do { hashv += hashv >> 6; \ } while (0) -#ifdef HASH_USING_NO_STRICT_ALIASING -/* The MurmurHash exploits some CPU's (x86,x86_64) tolerance for unaligned reads. - * For other types of CPU's (e.g. Sparc) an unaligned read causes a bus error. - * MurmurHash uses the faster approach only on CPU's where we know it's safe. - * - * Note the preprocessor built-in defines can be emitted using: - * - * gcc -m64 -dM -E - < /dev/null (on gcc) - * cc -## a.c (where a.c is a simple test file) (Sun Studio) - */ -#if (defined(__i386__) || defined(__x86_64__) || defined(_M_IX86)) -#define MUR_GETBLOCK(p,i) p[i] -#else /* non intel */ -#define MUR_PLUS0_ALIGNED(p) (((unsigned long)p & 3UL) == 0UL) -#define MUR_PLUS1_ALIGNED(p) (((unsigned long)p & 3UL) == 1UL) -#define MUR_PLUS2_ALIGNED(p) (((unsigned long)p & 3UL) == 2UL) -#define MUR_PLUS3_ALIGNED(p) (((unsigned long)p & 3UL) == 3UL) -#define WP(p) ((uint32_t*)((unsigned long)(p) & ~3UL)) -#if (defined(__BIG_ENDIAN__) || defined(SPARC) || defined(__ppc__) || defined(__ppc64__)) -#define MUR_THREE_ONE(p) ((((*WP(p))&0x00ffffff) << 8) | (((*(WP(p)+1))&0xff000000) >> 24)) -#define MUR_TWO_TWO(p) ((((*WP(p))&0x0000ffff) <<16) | (((*(WP(p)+1))&0xffff0000) >> 16)) -#define MUR_ONE_THREE(p) ((((*WP(p))&0x000000ff) <<24) | (((*(WP(p)+1))&0xffffff00) >> 8)) -#else /* assume little endian non-intel */ -#define MUR_THREE_ONE(p) ((((*WP(p))&0xffffff00) >> 8) | (((*(WP(p)+1))&0x000000ff) << 24)) -#define MUR_TWO_TWO(p) ((((*WP(p))&0xffff0000) >>16) | (((*(WP(p)+1))&0x0000ffff) << 16)) -#define MUR_ONE_THREE(p) ((((*WP(p))&0xff000000) >>24) | (((*(WP(p)+1))&0x00ffffff) << 8)) -#endif -#define MUR_GETBLOCK(p,i) (MUR_PLUS0_ALIGNED(p) ? ((p)[i]) : \ - (MUR_PLUS1_ALIGNED(p) ? MUR_THREE_ONE(p) : \ - (MUR_PLUS2_ALIGNED(p) ? MUR_TWO_TWO(p) : \ - MUR_ONE_THREE(p)))) -#endif -#define MUR_ROTL32(x,r) (((x) << (r)) | ((x) >> (32 - (r)))) -#define MUR_FMIX(_h) \ -do { \ - _h ^= _h >> 16; \ - _h *= 0x85ebca6bu; \ - _h ^= _h >> 13; \ - _h *= 0xc2b2ae35u; \ - _h ^= _h >> 16; \ -} while (0) - -#define HASH_MUR(key,keylen,hashv) \ -do { \ - const uint8_t *_mur_data = (const uint8_t*)(key); \ - const int _mur_nblocks = (int)(keylen) / 4; \ - uint32_t _mur_h1 = 0xf88D5353u; \ - uint32_t _mur_c1 = 0xcc9e2d51u; \ - uint32_t _mur_c2 = 0x1b873593u; \ - uint32_t _mur_k1 = 0; \ - const uint8_t *_mur_tail; \ - const uint32_t *_mur_blocks = (const uint32_t*)(_mur_data+(_mur_nblocks*4)); \ - int _mur_i; \ - for (_mur_i = -_mur_nblocks; _mur_i != 0; _mur_i++) { \ - _mur_k1 = MUR_GETBLOCK(_mur_blocks,_mur_i); \ - _mur_k1 *= _mur_c1; \ - _mur_k1 = MUR_ROTL32(_mur_k1,15); \ - _mur_k1 *= _mur_c2; \ - \ - _mur_h1 ^= _mur_k1; \ - _mur_h1 = MUR_ROTL32(_mur_h1,13); \ - _mur_h1 = (_mur_h1*5U) + 0xe6546b64u; \ - } \ - _mur_tail = (const uint8_t*)(_mur_data + (_mur_nblocks*4)); \ - _mur_k1=0; \ - switch ((keylen) & 3U) { \ - case 0: break; \ - case 3: _mur_k1 ^= (uint32_t)_mur_tail[2] << 16; /* FALLTHROUGH */ \ - case 2: _mur_k1 ^= (uint32_t)_mur_tail[1] << 8; /* FALLTHROUGH */ \ - case 1: _mur_k1 ^= (uint32_t)_mur_tail[0]; \ - _mur_k1 *= _mur_c1; \ - _mur_k1 = MUR_ROTL32(_mur_k1,15); \ - _mur_k1 *= _mur_c2; \ - _mur_h1 ^= _mur_k1; \ - } \ - _mur_h1 ^= (uint32_t)(keylen); \ - MUR_FMIX(_mur_h1); \ - hashv = _mur_h1; \ -} while (0) -#endif /* HASH_USING_NO_STRICT_ALIASING */ - /* iterate over items in a known bucket to find desired item */ #define HASH_FIND_IN_BKT(tbl,hh,head,keyptr,keylen_in,hashval,out) \ do { \ @@ -747,7 +750,7 @@ do { } \ while ((out) != NULL) { \ if ((out)->hh.hashv == (hashval) && (out)->hh.keylen == (keylen_in)) { \ - if (uthash_memcmp((out)->hh.key, keyptr, keylen_in) == 0) { \ + if (HASH_KEYCMP((out)->hh.key, keyptr, keylen_in) == 0) { \ break; \ } \ } \ @@ -760,7 +763,7 @@ do { } while (0) /* add an item to a bucket */ -#define HASH_ADD_TO_BKT(head,addhh) \ +#define HASH_ADD_TO_BKT(head,hh,addhh,oomed) \ do { \ UT_hash_bucket *_ha_head = &(head); \ _ha_head->count++; \ @@ -772,7 +775,12 @@ do { _ha_head->hh_head = (addhh); \ if ((_ha_head->count >= ((_ha_head->expand_mult + 1U) * HASH_BKT_CAPACITY_THRESH)) \ && !(addhh)->tbl->noexpand) { \ - HASH_EXPAND_BUCKETS((addhh)->tbl); \ + HASH_EXPAND_BUCKETS(addhh,(addhh)->tbl, oomed); \ + IF_HASH_NONFATAL_OOM( \ + if (oomed) { \ + HASH_DEL_IN_BKT(head,addhh); \ + } \ + ) \ } \ } while (0) @@ -821,53 +829,56 @@ do { * ceil(n/b) = (n>>lb) + ( (n & (b-1)) ? 1:0) * */ -#define HASH_EXPAND_BUCKETS(tbl) \ +#define HASH_EXPAND_BUCKETS(hh,tbl,oomed) \ do { \ unsigned _he_bkt; \ unsigned _he_bkt_i; \ struct UT_hash_handle *_he_thh, *_he_hh_nxt; \ UT_hash_bucket *_he_new_buckets, *_he_newbkt; \ _he_new_buckets = (UT_hash_bucket*)uthash_malloc( \ - 2UL * (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \ + sizeof(struct UT_hash_bucket) * (tbl)->num_buckets * 2U); \ if (!_he_new_buckets) { \ - uthash_fatal("out of memory"); \ - } \ - uthash_bzero(_he_new_buckets, \ - 2UL * (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \ - (tbl)->ideal_chain_maxlen = \ - ((tbl)->num_items >> ((tbl)->log2_num_buckets+1U)) + \ - ((((tbl)->num_items & (((tbl)->num_buckets*2U)-1U)) != 0U) ? 1U : 0U); \ - (tbl)->nonideal_items = 0; \ - for (_he_bkt_i = 0; _he_bkt_i < (tbl)->num_buckets; _he_bkt_i++) { \ - _he_thh = (tbl)->buckets[ _he_bkt_i ].hh_head; \ - while (_he_thh != NULL) { \ - _he_hh_nxt = _he_thh->hh_next; \ - HASH_TO_BKT(_he_thh->hashv, (tbl)->num_buckets * 2U, _he_bkt); \ - _he_newbkt = &(_he_new_buckets[_he_bkt]); \ - if (++(_he_newbkt->count) > (tbl)->ideal_chain_maxlen) { \ - (tbl)->nonideal_items++; \ - _he_newbkt->expand_mult = _he_newbkt->count / (tbl)->ideal_chain_maxlen; \ - } \ - _he_thh->hh_prev = NULL; \ - _he_thh->hh_next = _he_newbkt->hh_head; \ - if (_he_newbkt->hh_head != NULL) { \ - _he_newbkt->hh_head->hh_prev = _he_thh; \ + HASH_RECORD_OOM(oomed); \ + } else { \ + uthash_bzero(_he_new_buckets, \ + sizeof(struct UT_hash_bucket) * (tbl)->num_buckets * 2U); \ + (tbl)->ideal_chain_maxlen = \ + ((tbl)->num_items >> ((tbl)->log2_num_buckets+1U)) + \ + ((((tbl)->num_items & (((tbl)->num_buckets*2U)-1U)) != 0U) ? 1U : 0U); \ + (tbl)->nonideal_items = 0; \ + for (_he_bkt_i = 0; _he_bkt_i < (tbl)->num_buckets; _he_bkt_i++) { \ + _he_thh = (tbl)->buckets[ _he_bkt_i ].hh_head; \ + while (_he_thh != NULL) { \ + _he_hh_nxt = _he_thh->hh_next; \ + HASH_TO_BKT(_he_thh->hashv, (tbl)->num_buckets * 2U, _he_bkt); \ + _he_newbkt = &(_he_new_buckets[_he_bkt]); \ + if (++(_he_newbkt->count) > (tbl)->ideal_chain_maxlen) { \ + (tbl)->nonideal_items++; \ + if (_he_newbkt->count > _he_newbkt->expand_mult * (tbl)->ideal_chain_maxlen) { \ + _he_newbkt->expand_mult++; \ + } \ + } \ + _he_thh->hh_prev = NULL; \ + _he_thh->hh_next = _he_newbkt->hh_head; \ + if (_he_newbkt->hh_head != NULL) { \ + _he_newbkt->hh_head->hh_prev = _he_thh; \ + } \ + _he_newbkt->hh_head = _he_thh; \ + _he_thh = _he_hh_nxt; \ } \ - _he_newbkt->hh_head = _he_thh; \ - _he_thh = _he_hh_nxt; \ } \ + uthash_free((tbl)->buckets, (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \ + (tbl)->num_buckets *= 2U; \ + (tbl)->log2_num_buckets++; \ + (tbl)->buckets = _he_new_buckets; \ + (tbl)->ineff_expands = ((tbl)->nonideal_items > ((tbl)->num_items >> 1)) ? \ + ((tbl)->ineff_expands+1U) : 0U; \ + if ((tbl)->ineff_expands > 1U) { \ + (tbl)->noexpand = 1; \ + uthash_noexpand_fyi(tbl); \ + } \ + uthash_expand_fyi(tbl); \ } \ - uthash_free((tbl)->buckets, (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \ - (tbl)->num_buckets *= 2U; \ - (tbl)->log2_num_buckets++; \ - (tbl)->buckets = _he_new_buckets; \ - (tbl)->ineff_expands = ((tbl)->nonideal_items > ((tbl)->num_items >> 1)) ? \ - ((tbl)->ineff_expands+1U) : 0U; \ - if ((tbl)->ineff_expands > 1U) { \ - (tbl)->noexpand = 1; \ - uthash_noexpand_fyi(tbl); \ - } \ - uthash_expand_fyi(tbl); \ } while (0) @@ -977,7 +988,8 @@ do { _src_hh = _src_hh->hh_next) { \ _elt = ELMT_FROM_HH((src)->hh_src.tbl, _src_hh); \ if (cond(_elt)) { \ - _dst_hh = (UT_hash_handle*)(((char*)_elt) + _dst_hho); \ + IF_HASH_NONFATAL_OOM( int _hs_oomed = 0; ) \ + _dst_hh = (UT_hash_handle*)(void*)(((char*)_elt) + _dst_hho); \ _dst_hh->key = _src_hh->key; \ _dst_hh->keylen = _src_hh->keylen; \ _dst_hh->hashv = _src_hh->hashv; \ @@ -988,14 +1000,30 @@ do { } \ if ((dst) == NULL) { \ DECLTYPE_ASSIGN(dst, _elt); \ - HASH_MAKE_TABLE(hh_dst, dst); \ + HASH_MAKE_TABLE(hh_dst, dst, _hs_oomed); \ + IF_HASH_NONFATAL_OOM( \ + if (_hs_oomed) { \ + uthash_nonfatal_oom(_elt); \ + (dst) = NULL; \ + continue; \ + } \ + ) \ } else { \ _dst_hh->tbl = (dst)->hh_dst.tbl; \ } \ HASH_TO_BKT(_dst_hh->hashv, _dst_hh->tbl->num_buckets, _dst_bkt); \ - HASH_ADD_TO_BKT(_dst_hh->tbl->buckets[_dst_bkt], _dst_hh); \ - HASH_BLOOM_ADD(_dst_hh->tbl, _dst_hh->hashv); \ + HASH_ADD_TO_BKT(_dst_hh->tbl->buckets[_dst_bkt], hh_dst, _dst_hh, _hs_oomed); \ (dst)->hh_dst.tbl->num_items++; \ + IF_HASH_NONFATAL_OOM( \ + if (_hs_oomed) { \ + HASH_ROLLBACK_BKT(hh_dst, dst, _dst_hh); \ + HASH_DELETE_HH(hh_dst, dst, _dst_hh); \ + _dst_hh->tbl = NULL; \ + uthash_nonfatal_oom(_elt); \ + continue; \ + } \ + ) \ + HASH_BLOOM_ADD(_dst_hh->tbl, _dst_hh->hashv); \ _last_elt = _elt; \ _last_elt_hh = _dst_hh; \ } \ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap2/utlist.h b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/utlist.h similarity index 98% rename from tools/sdk/esp32/include/coap/libcoap/include/coap2/utlist.h rename to tools/sdk/esp32c3/include/coap/libcoap/include/coap3/utlist.h index 2f4c08406f4..1979448a7b9 100644 --- a/tools/sdk/esp32/include/coap/libcoap/include/coap2/utlist.h +++ b/tools/sdk/esp32c3/include/coap/libcoap/include/coap3/utlist.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2007-2017, Troy D. Hanson http://troydhanson.github.com/uthash/ +Copyright (c) 2007-2021, Troy D. Hanson http://troydhanson.github.io/uthash/ All rights reserved. Redistribution and use in source and binary forms, with or without @@ -24,7 +24,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef UTLIST_H #define UTLIST_H -#define UTLIST_VERSION 2.0.2 +#define UTLIST_VERSION 2.3.0 #include @@ -358,8 +358,8 @@ do { do { \ LDECLTYPE(head) _tmp; \ if (head) { \ - LL_LOWER_BOUND(head, _tmp, add, cmp); \ - LL_APPEND_ELEM(head, _tmp, add); \ + LL_LOWER_BOUND2(head, _tmp, add, cmp, next); \ + LL_APPEND_ELEM2(head, _tmp, add, next); \ } else { \ (head) = (add); \ (head)->next = NULL; \ @@ -651,14 +651,14 @@ do { } while (0) #define DL_INSERT_INORDER(head,add,cmp) \ - DL_INSERT_INORDER2(head,add,cmp,next) + DL_INSERT_INORDER2(head,add,cmp,prev,next) -#define DL_INSERT_INORDER2(head,add,cmp,next) \ +#define DL_INSERT_INORDER2(head,add,cmp,prev,next) \ do { \ LDECLTYPE(head) _tmp; \ if (head) { \ - DL_LOWER_BOUND(head, _tmp, add, cmp); \ - DL_APPEND_ELEM(head, _tmp, add); \ + DL_LOWER_BOUND2(head, _tmp, add, cmp, next); \ + DL_APPEND_ELEM2(head, _tmp, add, prev, next); \ } else { \ (head) = (add); \ (head)->prev = (head); \ @@ -825,7 +825,7 @@ do { /* Here are VS2008 / NO_DECLTYPE replacements for a few functions */ #undef DL_INSERT_INORDER2 -#define DL_INSERT_INORDER2(head,add,cmp,next) \ +#define DL_INSERT_INORDER2(head,add,cmp,prev,next) \ do { \ if ((head) == NULL) { \ (add)->prev = (add); \ @@ -838,7 +838,7 @@ do { (head) = (add); \ } else { \ char *_tmp = (char*)(head); \ - while ((char*)(head)->next != _tmp && (cmp((head)->next, add)) < 0) { \ + while ((head)->next && (cmp((head)->next, add)) < 0) { \ (head) = (head)->next; \ } \ (add)->prev = (head); \ @@ -892,14 +892,14 @@ do { } while (0) #define CDL_INSERT_INORDER(head,add,cmp) \ - CDL_INSERT_INORDER2(head,add,cmp,next) + CDL_INSERT_INORDER2(head,add,cmp,prev,next) -#define CDL_INSERT_INORDER2(head,add,cmp,next) \ +#define CDL_INSERT_INORDER2(head,add,cmp,prev,next) \ do { \ LDECLTYPE(head) _tmp; \ if (head) { \ - CDL_LOWER_BOUND(head, _tmp, add, cmp); \ - CDL_APPEND_ELEM(head, _tmp, add); \ + CDL_LOWER_BOUND2(head, _tmp, add, cmp, next); \ + CDL_APPEND_ELEM2(head, _tmp, add, prev, next); \ } else { \ (head) = (add); \ (head)->next = (head); \ @@ -1044,7 +1044,7 @@ do { /* Here are VS2008 / NO_DECLTYPE replacements for a few functions */ #undef CDL_INSERT_INORDER2 -#define CDL_INSERT_INORDER2(head,add,cmp,next) \ +#define CDL_INSERT_INORDER2(head,add,cmp,prev,next) \ do { \ if ((head) == NULL) { \ (add)->prev = (add); \ diff --git a/tools/sdk/esp32c3/include/coap/port/include/coap/coap_dtls.h b/tools/sdk/esp32c3/include/coap/port/include/coap/coap_dtls.h deleted file mode 100644 index 2dd0e88d2e5..00000000000 --- a/tools/sdk/esp32c3/include/coap/port/include/coap/coap_dtls.h +++ /dev/null @@ -1,631 +0,0 @@ -/* - * coap_dtls.h -- (Datagram) Transport Layer Support for libcoap - * - * Copyright (C) 2016 Olaf Bergmann - * Copyright (C) 2017 Jean-Claude Michelou - * - * This file is part of the CoAP library libcoap. Please see README for terms - * of use. - */ - -#ifndef COAP_DTLS_H_ -#define COAP_DTLS_H_ - -#include "coap_time.h" -#include "str.h" - -struct coap_context_t; -struct coap_session_t; -struct coap_dtls_pki_t; - -/** - * @defgroup dtls DTLS Support - * API functions for interfacing with DTLS libraries. - * @{ - */ - -/** - * Check whether DTLS is available. - * - * @return @c 1 if support for DTLS is enabled, or @c 0 otherwise. - */ -int coap_dtls_is_supported(void); - -/** - * Check whether TLS is available. - * - * @return @c 1 if support for TLS is enabled, or @c 0 otherwise. - */ -int coap_tls_is_supported(void); - -typedef enum coap_tls_library_t { - COAP_TLS_LIBRARY_NOTLS = 0, /**< No DTLS library */ - COAP_TLS_LIBRARY_TINYDTLS, /**< Using TinyDTLS library */ - COAP_TLS_LIBRARY_OPENSSL, /**< Using OpenSSL library */ - COAP_TLS_LIBRARY_GNUTLS, /**< Using GnuTLS library */ - COAP_TLS_LIBRARY_MBEDTLS, /**< Using MbedTLS library */ -} coap_tls_library_t; - -/** - * The structure used for returning the underlying (D)TLS library - * information. - */ -typedef struct coap_tls_version_t { - uint64_t version; /**< (D)TLS runtime Library Version */ - coap_tls_library_t type; /**< Library type. One of COAP_TLS_LIBRARY_* */ - uint64_t built_version; /**< (D)TLS Built against Library Version */ -} coap_tls_version_t; - -/** - * Determine the type and version of the underlying (D)TLS library. - * - * @return The version and type of library libcoap was compiled against. - */ -coap_tls_version_t *coap_get_tls_library_version(void); - -/** - * Additional Security setup handler that can be set up by - * coap_context_set_pki(). - * Invoked when libcoap has done the validation checks at the TLS level, - * but the application needs to do some additional checks/changes/updates. - * - * @param tls_session The security session definition - e.g. SSL * for OpenSSL. - * NULL if server call-back. - * This will be dependent on the underlying TLS library - - * see coap_get_tls_library_version() - * @param setup_data A structure containing setup data originally passed into - * coap_context_set_pki() or coap_new_client_session_pki(). - * - * @return @c 1 if successful, else @c 0. - */ -typedef int (*coap_dtls_security_setup_t)(void* tls_session, - struct coap_dtls_pki_t *setup_data); - -/** - * CN Validation call-back that can be set up by coap_context_set_pki(). - * Invoked when libcoap has done the validation checks at the TLS level, - * but the application needs to check that the CN is allowed. - * CN is the SubjectAltName in the cert, if not present, then the leftmost - * Common Name (CN) component of the subject name. - * - * @param cn The determined CN from the certificate - * @param asn1_public_cert The ASN.1 DER encoded X.509 certificate - * @param asn1_length The ASN.1 length - * @param coap_session The CoAP session associated with the certificate update - * @param depth Depth in cert chain. If 0, then client cert, else a CA - * @param validated TLS layer can find no issues if 1 - * @param arg The same as was passed into coap_context_set_pki() - * in setup_data->cn_call_back_arg - * - * @return @c 1 if accepted, else @c 0 if to be rejected. - */ -typedef int (*coap_dtls_cn_callback_t)(const char *cn, - const uint8_t *asn1_public_cert, - size_t asn1_length, - struct coap_session_t *coap_session, - unsigned depth, - int validated, - void *arg); - -/** - * The enum used for determining the provided PKI ASN.1 (DER) Private Key - * formats. - */ -typedef enum coap_asn1_privatekey_type_t { - COAP_ASN1_PKEY_NONE, /**< NONE */ - COAP_ASN1_PKEY_RSA, /**< RSA type */ - COAP_ASN1_PKEY_RSA2, /**< RSA2 type */ - COAP_ASN1_PKEY_DSA, /**< DSA type */ - COAP_ASN1_PKEY_DSA1, /**< DSA1 type */ - COAP_ASN1_PKEY_DSA2, /**< DSA2 type */ - COAP_ASN1_PKEY_DSA3, /**< DSA3 type */ - COAP_ASN1_PKEY_DSA4, /**< DSA4 type */ - COAP_ASN1_PKEY_DH, /**< DH type */ - COAP_ASN1_PKEY_DHX, /**< DHX type */ - COAP_ASN1_PKEY_EC, /**< EC type */ - COAP_ASN1_PKEY_HMAC, /**< HMAC type */ - COAP_ASN1_PKEY_CMAC, /**< CMAC type */ - COAP_ASN1_PKEY_TLS1_PRF, /**< TLS1_PRF type */ - COAP_ASN1_PKEY_HKDF /**< HKDF type */ -} coap_asn1_privatekey_type_t; - -/** - * The enum used for determining the PKI key formats. - */ -typedef enum coap_pki_key_t { - COAP_PKI_KEY_PEM = 0, /**< The PKI key type is PEM file */ - COAP_PKI_KEY_ASN1, /**< The PKI key type is ASN.1 (DER) */ - COAP_PKI_KEY_PEM_BUF, /**< The PKI key type is PEM buffer */ -} coap_pki_key_t; - -/** - * The structure that holds the PKI PEM definitions. - */ -typedef struct coap_pki_key_pem_t { - const char *ca_file; /**< File location of Common CA in PEM format */ - const char *public_cert; /**< File location of Public Cert in PEM format */ - const char *private_key; /**< File location of Private Key in PEM format */ -} coap_pki_key_pem_t; - -/** - * The structure that holds the PKI PEM buffer definitions. - */ -typedef struct coap_pki_key_pem_buf_t { - const uint8_t *ca_cert; /**< PEM buffer Common CA Cert */ - const uint8_t *public_cert; /**< PEM buffer Public Cert */ - const uint8_t *private_key; /**< PEM buffer Private Key */ - size_t ca_cert_len; /**< PEM buffer CA Cert length */ - size_t public_cert_len; /**< PEM buffer Public Cert length */ - size_t private_key_len; /**< PEM buffer Private Key length */ -} coap_pki_key_pem_buf_t; - -/** - * The structure that holds the PKI ASN.1 (DER) definitions. - */ -typedef struct coap_pki_key_asn1_t { - const uint8_t *ca_cert; /**< ASN1 (DER) Common CA Cert */ - const uint8_t *public_cert; /**< ASN1 (DER) Public Cert */ - const uint8_t *private_key; /**< ASN1 (DER) Private Key */ - size_t ca_cert_len; /**< ASN1 CA Cert length */ - size_t public_cert_len; /**< ASN1 Public Cert length */ - size_t private_key_len; /**< ASN1 Private Key length */ - coap_asn1_privatekey_type_t private_key_type; /**< Private Key Type */ -} coap_pki_key_asn1_t; - -/** - * The structure that holds the PKI key information. - */ -typedef struct coap_dtls_key_t { - coap_pki_key_t key_type; /**< key format type */ - union { - coap_pki_key_pem_t pem; /**< for PEM file keys */ - coap_pki_key_pem_buf_t pem_buf; /**< for PEM memory keys */ - coap_pki_key_asn1_t asn1; /**< for ASN.1 (DER) file keys */ - } key; -} coap_dtls_key_t; - -/** - * Server Name Indication (SNI) Validation call-back that can be set up by - * coap_context_set_pki(). - * Invoked if the SNI is not previously seen and prior to sending a certificate - * set back to the client so that the appropriate certificate set can be used - * based on the requesting SNI. - * - * @param sni The requested SNI - * @param arg The same as was passed into coap_context_set_pki() - * in setup_data->sni_call_back_arg - * - * @return New set of certificates to use, or @c NULL if SNI is to be rejected. - */ -typedef coap_dtls_key_t *(*coap_dtls_sni_callback_t)(const char *sni, - void* arg); - - -#define COAP_DTLS_PKI_SETUP_VERSION 1 /**< Latest PKI setup version */ - -/** - * The structure used for defining the PKI setup data to be used. - */ -typedef struct coap_dtls_pki_t { - uint8_t version; /** Set to 1 to support this version of the struct */ - - /* Options to enable different TLS functionality in libcoap */ - uint8_t verify_peer_cert; /**< 1 if peer cert is to be verified */ - uint8_t require_peer_cert; /**< 1 if peer cert is required */ - uint8_t allow_self_signed; /**< 1 if self signed certs are allowed */ - uint8_t allow_expired_certs; /**< 1 if expired certs are allowed */ - uint8_t cert_chain_validation; /**< 1 if to check cert_chain_verify_depth */ - uint8_t cert_chain_verify_depth; /**< recommended depth is 3 */ - uint8_t check_cert_revocation; /**< 1 if revocation checks wanted */ - uint8_t allow_no_crl; /**< 1 ignore if CRL not there */ - uint8_t allow_expired_crl; /**< 1 if expired crl is allowed */ - uint8_t allow_bad_md_hash; /**< 1 if expired certs are allowed */ - uint8_t allow_short_rsa_length; /**< 1 if expired certs are allowed */ - uint8_t reserved[4]; /**< Reserved - must be set to 0 for - future compatibility */ - /* Size of 4 chosen to align to next - * parameter, so if newly defined option - * it can use one of the reserverd slot so - * no need to change - * COAP_DTLS_PKI_SETUP_VERSION and just - * decrement the reserved[] count. - */ - - /** CN check call-back function. - * If not NULL, is called when the TLS connection has passed the configured - * TLS options above for the application to verify if the CN is valid. - */ - coap_dtls_cn_callback_t validate_cn_call_back; - void *cn_call_back_arg; /**< Passed in to the CN call-back function */ - - /** SNI check call-back function. - * If not @p NULL, called if the SNI is not previously seen and prior to - * sending a certificate set back to the client so that the appropriate - * certificate set can be used based on the requesting SNI. - */ - coap_dtls_sni_callback_t validate_sni_call_back; - void *sni_call_back_arg; /**< Passed in to the sni call-back function */ - - /** Additional Security call-back handler that is invoked when libcoap has - * done the standerd, defined validation checks at the TLS level, - * If not @p NULL, called from within the TLS Client Hello connection - * setup. - */ - coap_dtls_security_setup_t additional_tls_setup_call_back; - - char* client_sni; /**< If not NULL, SNI to use in client TLS setup. - Owned by the client app and must remain valid - during the call to coap_new_client_session_pki() */ - - coap_dtls_key_t pki_key; /**< PKI key definition */ -} coap_dtls_pki_t; - -/** @} */ - -/** - * @defgroup dtls_internal DTLS Support (Internal) - * Internal API functions for interfacing with DTLS libraries. - * @{ - */ - -/** - * Creates a new DTLS context for the given @p coap_context. This function - * returns a pointer to a new DTLS context object or @c NULL on error. - * - * Internal function. - * - * @param coap_context The CoAP context where the DTLS object shall be used. - * - * @return A DTLS context object or @c NULL on error. - */ -void * -coap_dtls_new_context(struct coap_context_t *coap_context); - -typedef enum coap_dtls_role_t { - COAP_DTLS_ROLE_CLIENT, /**< Internal function invoked for client */ - COAP_DTLS_ROLE_SERVER /**< Internal function invoked for server */ -} coap_dtls_role_t; - -/** - * Set the DTLS context's default PSK information. - * This does the PSK specifics following coap_dtls_new_context(). - * If @p COAP_DTLS_ROLE_SERVER, then identity hint will also get set. - * If @p COAP_DTLS_ROLE_SERVER, then the information will get put into the - * TLS library's context (from which sessions are derived). - * If @p COAP_DTLS_ROLE_CLIENT, then the information will get put into the - * TLS library's session. - * - * Internal function. - * - * @param coap_context The CoAP context. - * @param identity_hint The default PSK server identity hint sent to a client. - * Required parameter. If @p NULL, will be set to "". - * Empty string is a valid hint. - * This parameter is ignored if COAP_DTLS_ROLE_CLIENT - * @param role One of @p COAP_DTLS_ROLE_CLIENT or @p COAP_DTLS_ROLE_SERVER - * - * @return @c 1 if successful, else @c 0. - */ - -int -coap_dtls_context_set_psk(struct coap_context_t *coap_context, - const char *identity_hint, - coap_dtls_role_t role); - -/** - * Set the DTLS context's default server PKI information. - * This does the PKI specifics following coap_dtls_new_context(). - * If @p COAP_DTLS_ROLE_SERVER, then the information will get put into the - * TLS library's context (from which sessions are derived). - * If @p COAP_DTLS_ROLE_CLIENT, then the information will get put into the - * TLS library's session. - * - * Internal function. - * - * @param coap_context The CoAP context. - * @param setup_data Setup information defining how PKI is to be setup. - * Required parameter. If @p NULL, PKI will not be - * set up. - * @param role One of @p COAP_DTLS_ROLE_CLIENT or @p COAP_DTLS_ROLE_SERVER - * - * @return @c 1 if successful, else @c 0. - */ - -int -coap_dtls_context_set_pki(struct coap_context_t *coap_context, - coap_dtls_pki_t *setup_data, - coap_dtls_role_t role); - -/** - * Set the dtls context's default Root CA information for a client or server. - * - * Internal function. - * - * @param coap_context The current coap_context_t object. - * @param ca_file If not @p NULL, is the full path name of a PEM encoded - * file containing all the Root CAs to be used. - * @param ca_dir If not @p NULL, points to a directory containing PEM - * encoded files containing all the Root CAs to be used. - * - * @return @c 1 if successful, else @c 0. - */ - -int -coap_dtls_context_set_pki_root_cas(struct coap_context_t *coap_context, - const char *ca_file, - const char *ca_dir); - -/** - * Check whether one of the coap_dtls_context_set_{psk|pki}() functions have - * been called. - * - * Internal function. - * - * @param coap_context The current coap_context_t object. - * - * @return @c 1 if coap_dtls_context_set_{psk|pki}() called, else @c 0. - */ - -int coap_dtls_context_check_keys_enabled(struct coap_context_t *coap_context); - -/** - * Releases the storage allocated for @p dtls_context. - * - * Internal function. - * - * @param dtls_context The DTLS context as returned by coap_dtls_new_context(). - */ -void coap_dtls_free_context(void *dtls_context); - -/** - * Create a new client-side session. This should send a HELLO to the server. - * - * Internal function. - * - * @param coap_session The CoAP session. - * - * @return Opaque handle to underlying TLS library object containing security - * parameters for the session. -*/ -void *coap_dtls_new_client_session(struct coap_session_t *coap_session); - -/** - * Create a new DTLS server-side session. - * Called after coap_dtls_hello() has returned @c 1, signalling that a validated - * HELLO was received from a client. - * This should send a HELLO to the server. - * - * Internal function. - * - * @param coap_session The CoAP session. - * - * @return Opaque handle to underlying TLS library object containing security - * parameters for the DTLS session. - */ -void *coap_dtls_new_server_session(struct coap_session_t *coap_session); - -/** - * Terminates the DTLS session (may send an ALERT if necessary) then frees the - * underlying TLS library object containing security parameters for the session. - * - * Internal function. - * - * @param coap_session The CoAP session. - */ -void coap_dtls_free_session(struct coap_session_t *coap_session); - -/** - * Notify of a change in the CoAP session's MTU, for example after - * a PMTU update. - * - * Internal function. - * - * @param coap_session The CoAP session. - */ -void coap_dtls_session_update_mtu(struct coap_session_t *coap_session); - -/** - * Send data to a DTLS peer. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param data pointer to data. - * @param data_len Number of bytes to send. - * - * @return @c 0 if this would be blocking, @c -1 if there is an error or the - * number of cleartext bytes sent. - */ -int coap_dtls_send(struct coap_session_t *coap_session, - const uint8_t *data, - size_t data_len); - -/** - * Check if timeout is handled per CoAP session or per CoAP context. - * - * Internal function. - * - * @return @c 1 of timeout and retransmit is per context, @c 0 if it is - * per session. - */ -int coap_dtls_is_context_timeout(void); - -/** - * Do all pending retransmits and get next timeout - * - * Internal function. - * - * @param dtls_context The DTLS context. - * - * @return @c 0 if no event is pending or date of the next retransmit. - */ -coap_tick_t coap_dtls_get_context_timeout(void *dtls_context); - -/** - * Get next timeout for this session. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param now The current time in ticks. - * - * @return @c 0 If no event is pending or ticks time of the next retransmit. - */ -coap_tick_t coap_dtls_get_timeout(struct coap_session_t *coap_session, - coap_tick_t now); - -/** - * Handle a DTLS timeout expiration. - * - * Internal function. - * - * @param coap_session The CoAP session. - */ -void coap_dtls_handle_timeout(struct coap_session_t *coap_session); - -/** - * Handling incoming data from a DTLS peer. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param data Encrypted datagram. - * @param data_len Encrypted datagram size. - * - * @return Result of coap_handle_dgram on the decrypted CoAP PDU - * or @c -1 for error. - */ -int coap_dtls_receive(struct coap_session_t *coap_session, - const uint8_t *data, - size_t data_len); - -/** - * Handling client HELLO messages from a new candiate peer. - * Note that session->tls is empty. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param data Encrypted datagram. - * @param data_len Encrypted datagram size. - * - * @return @c 0 if a cookie verification message has been sent, @c 1 if the - * HELLO contains a valid cookie and a server session should be created, - * @c -1 if the message is invalid. - */ -int coap_dtls_hello(struct coap_session_t *coap_session, - const uint8_t *data, - size_t data_len); - -/** - * Get DTLS overhead over cleartext PDUs. - * - * Internal function. - * - * @param coap_session The CoAP session. - * - * @return Maximum number of bytes added by DTLS layer. - */ -unsigned int coap_dtls_get_overhead(struct coap_session_t *coap_session); - -/** - * Create a new TLS client-side session. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param connected Updated with whether the connection is connected yet or not. - * @c 0 is not connected, @c 1 is connected. - * - * @return Opaque handle to underlying TLS library object containing security - * parameters for the session. -*/ -void *coap_tls_new_client_session(struct coap_session_t *coap_session, int *connected); - -/** - * Create a TLS new server-side session. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param connected Updated with whether the connection is connected yet or not. - * @c 0 is not connected, @c 1 is connected. - * - * @return Opaque handle to underlying TLS library object containing security - * parameters for the session. - */ -void *coap_tls_new_server_session(struct coap_session_t *coap_session, int *connected); - -/** - * Terminates the TLS session (may send an ALERT if necessary) then frees the - * underlying TLS library object containing security parameters for the session. - * - * Internal function. - * - * @param coap_session The CoAP session. - */ -void coap_tls_free_session( struct coap_session_t *coap_session ); - -/** - * Send data to a TLS peer, with implicit flush. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param data Pointer to data. - * @param data_len Number of bytes to send. - * - * @return @c 0 if this should be retried, @c -1 if there is an error - * or the number of cleartext bytes sent. - */ -ssize_t coap_tls_write(struct coap_session_t *coap_session, - const uint8_t *data, - size_t data_len - ); - -/** - * Read some data from a TLS peer. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param data Pointer to data. - * @param data_len Maximum number of bytes to read. - * - * @return @c 0 if this should be retried, @c -1 if there is an error - * or the number of cleartext bytes read. - */ -ssize_t coap_tls_read(struct coap_session_t *coap_session, - uint8_t *data, - size_t data_len - ); - -/** - * Initialize the underlying (D)TLS Library layer. - * - * Internal function. - * - */ -void coap_dtls_startup(void); - -/** @} */ - -/** - * @ingroup logging - * Sets the (D)TLS logging level to the specified @p level. - * Note: coap_log_level() will influence output if at a specified level. - * - * @param level The logging level to use - LOG_* - */ -void coap_dtls_set_log_level(int level); - -/** - * @ingroup logging - * Get the current (D)TLS logging. - * - * @return The current log level (one of LOG_*). - */ -int coap_dtls_get_log_level(void); - - -#endif /* COAP_DTLS_H */ diff --git a/tools/sdk/esp32/include/coap/port/include/coap/coap.h b/tools/sdk/esp32c3/include/coap/port/include/coap3/coap.h similarity index 53% rename from tools/sdk/esp32/include/coap/port/include/coap/coap.h rename to tools/sdk/esp32c3/include/coap/port/include/coap3/coap.h index f048ca85714..c69d2734b3a 100644 --- a/tools/sdk/esp32/include/coap/port/include/coap/coap.h +++ b/tools/sdk/esp32c3/include/coap/port/include/coap3/coap.h @@ -21,27 +21,28 @@ extern "C" { #endif -#include "libcoap.h" +#include "coap3/libcoap.h" -#include "address.h" -#include "async.h" -#include "bits.h" -#include "block.h" -#include "coap_dtls.h" -#include "coap_event.h" -#include "coap_io.h" -#include "coap_time.h" -#include "coap_debug.h" -#include "encode.h" -#include "mem.h" -#include "net.h" -#include "option.h" -#include "pdu.h" -#include "prng.h" -#include "resource.h" -#include "str.h" -#include "subscribe.h" -#include "uri.h" +#include "coap3/coap_forward_decls.h" +#include "coap3/address.h" +#include "coap3/async.h" +#include "coap3/block.h" +#include "coap3/coap_cache.h" +#include "coap3/coap_dtls.h" +#include "coap3/coap_event.h" +#include "coap3/coap_io.h" +#include "coap3/coap_time.h" +#include "coap3/coap_debug.h" +#include "coap3/encode.h" +#include "coap3/mem.h" +#include "coap3/net.h" +#include "coap3/option.h" +#include "coap3/pdu.h" +#include "coap3/coap_prng.h" +#include "coap3/resource.h" +#include "coap3/str.h" +#include "coap3/subscribe.h" +#include "coap3/uri.h" #ifdef __cplusplus } diff --git a/tools/sdk/esp32c3/include/coap/port/include/coap_config_posix.h b/tools/sdk/esp32c3/include/coap/port/include/coap_config_posix.h index 3f6b7c605fc..b24335ad156 100644 --- a/tools/sdk/esp32c3/include/coap/port/include/coap_config_posix.h +++ b/tools/sdk/esp32c3/include/coap/port/include/coap_config_posix.h @@ -30,6 +30,7 @@ #define HAVE_NETDB_H #define HAVE_NETINET_IN_H #define HAVE_STRUCT_CMSGHDR +#define COAP_DISABLE_TCP 0 #define ipi_spec_dst ipi_addr struct in6_pktinfo { @@ -53,8 +54,6 @@ struct in6_pktinfo { #define COAP_CONSTRAINED_STACK 1 #define ESPIDF_VERSION -#define _POSIX_TIMERS 1 - #define gai_strerror(x) "gai_strerror() not supported" #endif /* WITH_POSIX */ diff --git a/tools/sdk/esp32c3/include/config/sdkconfig.h b/tools/sdk/esp32c3/include/config/sdkconfig.h index 970aa8d101c..f1f31fdfd3b 100644 --- a/tools/sdk/esp32c3/include/config/sdkconfig.h +++ b/tools/sdk/esp32c3/include/config/sdkconfig.h @@ -23,6 +23,7 @@ #define CONFIG_BOOTLOADER_WDT_ENABLE 1 #define CONFIG_BOOTLOADER_WDT_TIME_MS 9000 #define CONFIG_BOOTLOADER_RESERVE_RTC_SIZE 0x0 +#define CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT 1 #define CONFIG_SECURE_BOOT_SUPPORTS_RSA 1 #define CONFIG_SECURE_TARGET_HAS_SECURE_ROM_DL_MODE 1 #define CONFIG_BOOT_ROM_LOG_ALWAYS_ON 1 @@ -68,16 +69,7 @@ #define CONFIG_APPTRACE_DEST_NONE 1 #define CONFIG_APPTRACE_LOCK_ENABLE 1 #define CONFIG_BT_ENABLED 1 -#define CONFIG_BT_CTRL_ESP32C3 1 #define CONFIG_BT_SOC_SUPPORT_5_0 1 -#define CONFIG_BTDM_CTRL_BR_EDR_SCO_DATA_PATH_EFF 0 -#define CONFIG_BTDM_CTRL_PCM_ROLE_EFF 0 -#define CONFIG_BTDM_CTRL_PCM_POLAR_EFF 0 -#define CONFIG_BTDM_CTRL_BLE_MAX_CONN_EFF 0 -#define CONFIG_BTDM_CTRL_BR_EDR_MAX_ACL_CONN_EFF 0 -#define CONFIG_BTDM_CTRL_BR_EDR_MAX_SYNC_CONN_EFF 0 -#define CONFIG_BTDM_CTRL_PINNED_TO_CORE 0 -#define CONFIG_BTDM_BLE_SLEEP_CLOCK_ACCURACY_INDEX_EFF 1 #define CONFIG_BT_CTRL_MODE_EFF 1 #define CONFIG_BT_CTRL_BLE_MAX_ACT 10 #define CONFIG_BT_CTRL_BLE_MAX_ACT_EFF 10 @@ -169,9 +161,6 @@ #define CONFIG_BT_BLE_RPA_SUPPORTED 1 #define CONFIG_BT_BLE_50_FEATURES_SUPPORTED 1 #define CONFIG_BT_BLE_42_FEATURES_SUPPORTED 1 -#define CONFIG_BT_RESERVE_DRAM 0xdb5c -#define CONFIG_BT_NIMBLE_ENABLE_CONN_REATTEMPT 1 -#define CONFIG_BT_NIMBLE_USE_ESP_TIMER 1 #define CONFIG_COAP_MBEDTLS_PSK 1 #define CONFIG_COAP_LOG_DEFAULT_LEVEL 0 #define CONFIG_ADC_DISABLE_DAC 1 @@ -213,6 +202,8 @@ #define CONFIG_ESP32C3_UNIVERSAL_MAC_ADDRESSES_FOUR 1 #define CONFIG_ESP32C3_UNIVERSAL_MAC_ADDRESSES 4 #define CONFIG_ESP_SLEEP_POWER_DOWN_FLASH 1 +#define CONFIG_ESP_IPC_TASK_STACK_SIZE 1024 +#define CONFIG_LCD_PANEL_IO_FORMAT_BUF_SIZE 32 #define CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL 120 #define CONFIG_ESP_NETIF_TCPIP_LWIP 1 #define CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER 1 @@ -224,8 +215,11 @@ #define CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE 1 #define CONFIG_ESP_SYSTEM_RTC_FAST_MEM_AS_HEAP_DEPCHECK 1 #define CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP 1 +#define CONFIG_ESP_SYSTEM_MEMPROT_DEPCHECK 1 #define CONFIG_ESP_SYSTEM_MEMPROT_FEATURE 1 #define CONFIG_ESP_SYSTEM_MEMPROT_FEATURE_LOCK 1 +#define CONFIG_ESP_SYSTEM_MEMPROT_CPU_PREFETCH_PAD_SIZE 16 +#define CONFIG_ESP_SYSTEM_MEMPROT_MEM_ALIGN_SIZE 512 #define CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE 32 #define CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE 2304 #define CONFIG_ESP_MAIN_TASK_STACK_SIZE 3584 @@ -241,7 +235,7 @@ #define CONFIG_ESP_TASK_WDT 1 #define CONFIG_ESP_TASK_WDT_TIMEOUT_S 5 #define CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0 1 -#define CONFIG_ESP_IPC_TASK_STACK_SIZE 1024 +#define CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_4 1 #define CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER 1 #define CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER 1 #define CONFIG_ESP_TIMER_TASK_STACK_SIZE 3584 @@ -298,9 +292,13 @@ #define CONFIG_FMB_TIMER_PORT_ENABLED 1 #define CONFIG_FMB_TIMER_GROUP 0 #define CONFIG_FMB_TIMER_INDEX 0 +#define CONFIG_FMB_MASTER_TIMER_GROUP 0 +#define CONFIG_FMB_MASTER_TIMER_INDEX 0 #define CONFIG_FREERTOS_UNICORE 1 #define CONFIG_FREERTOS_NO_AFFINITY 0x7FFFFFFF -#define CONFIG_FREERTOS_CORETIMER_0 1 +#define CONFIG_FREERTOS_TICK_SUPPORT_SYSTIMER 1 +#define CONFIG_FREERTOS_CORETIMER_SYSTIMER_LVL1 1 +#define CONFIG_FREERTOS_SYSTICK_USES_SYSTIMER 1 #define CONFIG_FREERTOS_OPTIMIZED_SCHEDULER 1 #define CONFIG_FREERTOS_HZ 1000 #define CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION 1 @@ -319,6 +317,7 @@ #define CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER 1 #define CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER 1 #define CONFIG_FREERTOS_DEBUG_OCDAWARE 1 +#define CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT 1 #define CONFIG_HAL_ASSERTION_EQUALS_SYSTEM 1 #define CONFIG_HAL_DEFAULT_ASSERTION_LEVEL 2 #define CONFIG_HEAP_POISONING_DISABLED 1 @@ -346,7 +345,6 @@ #define CONFIG_LWIP_DHCPS_MAX_STATION_NUM 8 #define CONFIG_LWIP_IPV6 1 #define CONFIG_LWIP_IPV6_NUM_ADDRESSES 3 -#define CONFIG_LWIP_IPV6_RDNSS_MAX_DNS_SERVERS 0 #define CONFIG_LWIP_NETIF_LOOPBACK 1 #define CONFIG_LWIP_LOOPBACK_MAX_PBUFS 8 #define CONFIG_LWIP_MAX_ACTIVE_TCP 16 @@ -373,7 +371,7 @@ #define CONFIG_LWIP_IPV6_ND6_NUM_NEIGHBORS 5 #define CONFIG_LWIP_ICMP 1 #define CONFIG_LWIP_MAX_RAW_PCBS 16 -#define CONFIG_LWIP_DHCP_MAX_NTP_SERVERS 1 +#define CONFIG_LWIP_SNTP_MAX_SERVERS 1 #define CONFIG_LWIP_SNTP_UPDATE_DELAY 3600000 #define CONFIG_LWIP_ESP_LWIP_ASSERT 1 #define CONFIG_LWIP_HOOK_TCP_ISN_DEFAULT 1 @@ -624,5 +622,5 @@ #define CONFIG_TIMER_TASK_STACK_SIZE CONFIG_ESP_TIMER_TASK_STACK_SIZE #define CONFIG_TOOLPREFIX CONFIG_SDK_TOOLPREFIX #define CONFIG_UDP_RECVMBOX_SIZE CONFIG_LWIP_UDP_RECVMBOX_SIZE -#define CONFIG_ARDUINO_IDF_COMMIT "c69f0ec32" +#define CONFIG_ARDUINO_IDF_COMMIT "3e370c4296" #define CONFIG_ARDUINO_IDF_BRANCH "master" diff --git a/tools/sdk/esp32c3/include/driver/include/driver/i2s.h b/tools/sdk/esp32c3/include/driver/include/driver/i2s.h index 4ee73b594d7..aa649ed479c 100644 --- a/tools/sdk/esp32c3/include/driver/include/driver/i2s.h +++ b/tools/sdk/esp32c3/include/driver/include/driver/i2s.h @@ -13,12 +13,11 @@ #include "soc/i2s_periph.h" #include "soc/rtc_periph.h" #include "soc/soc_caps.h" -#include "hal/i2s_hal.h" #include "hal/i2s_types.h" #include "driver/periph_ctrl.h" #include "esp_intr_alloc.h" -#if SOC_I2S_SUPPORTS_ADC_DAC +#if SOC_I2S_SUPPORTS_ADC #include "driver/adc.h" #endif @@ -28,7 +27,119 @@ extern "C" { #define I2S_PIN_NO_CHANGE (-1) /*!< Use in i2s_pin_config_t for pins which should not be changed */ -typedef intr_handle_t i2s_isr_handle_t; +/** + * @brief I2S port number, the max port number is (I2S_NUM_MAX -1). + */ +typedef enum { + I2S_NUM_0 = 0, /*!< I2S port 0 */ +#if SOC_I2S_NUM > 1 + I2S_NUM_1 = 1, /*!< I2S port 1 */ +#endif + I2S_NUM_MAX, /*!< I2S port max */ +} i2s_port_t; + +#if SOC_I2S_SUPPORTS_PCM +/** + * @brief I2S PCM configuration + * + */ +typedef struct { + i2s_pcm_compress_t pcm_type; /*!< I2S PCM a/u-law decompress or compress type */ +} i2s_pcm_cfg_t; +#endif + +#if SOC_I2S_SUPPORTS_PDM_TX +/** + * @brief Default I2S PDM Up-Sampling Rate configuration + */ +#define I2S_PDM_DEFAULT_UPSAMPLE_CONFIG(rate) { \ + .sample_rate = rate, \ + .fp = 960, \ + .fs = (rate) / 100, \ + } + +/** + * @brief I2S PDM up-sample rate configuration + * @note TX PDM can only be set to the following two upsampling rate configurations: + * 1: fp = 960, fs = sample_rate / 100, in this case, Fpdm = 128*48000 + * 2: fp = 960, fs = 480, in this case, Fpdm = 128*Fpcm = 128*sample_rate + * If the pdm receiver do not care the pdm serial clock, it's recommended set Fpdm = 128*48000. + * Otherwise, the second configuration should be applied. + */ +typedef struct { + int sample_rate; /*!< I2S PDM sample rate */ + int fp; /*!< I2S PDM TX upsampling paramater. Normally it should be set to 960 */ + int fs; /*!< I2S PDM TX upsampling paramater. When it is set to 480, the pdm clock frequency Fpdm = 128 * sample_rate, when it is set to sample_rate / 100, Fpdm will be fixed to 128*48000 */ +} i2s_pdm_tx_upsample_cfg_t; +#endif + +/** + * @brief I2S pin number for i2s_set_pin + * + */ +typedef struct { + int mck_io_num; /*!< MCK in out pin*/ + int bck_io_num; /*!< BCK in out pin*/ + int ws_io_num; /*!< WS in out pin*/ + int data_out_num; /*!< DATA out pin*/ + int data_in_num; /*!< DATA in pin*/ +} i2s_pin_config_t; + +/** + * @brief I2S driver configuration parameters + * + */ +typedef struct { + + i2s_mode_t mode; /*!< I2S work mode */ + uint32_t sample_rate; /*!< I2S sample rate */ + i2s_bits_per_sample_t bits_per_sample; /*!< I2S sample bits in one channel */ + i2s_channel_fmt_t channel_format; /*!< I2S channel format.*/ + i2s_comm_format_t communication_format; /*!< I2S communication format */ + int 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 */ + int dma_buf_count; /*!< I2S DMA Buffer Count */ + int dma_buf_len; /*!< I2S DMA Buffer Length */ + bool use_apll; /*!< I2S using APLL as main I2S clock, enable it to get accurate clock */ + bool tx_desc_auto_clear; /*!< I2S auto clear tx descriptor if there is underflow condition (helps in avoiding noise in case of data unavailability) */ + int fixed_mclk; /*!< I2S using fixed MCLK output. If use_apll = true and fixed_mclk > 0, then the clock output for i2s is fixed and equal to the fixed_mclk value. If fixed_mclk set, mclk_multiple won't take effect */ + i2s_mclk_multiple_t mclk_multiple; /*!< The multiple of I2S master clock(MCLK) to sample rate */ + i2s_bits_per_chan_t bits_per_chan; /*!< I2S total bits in one channel, only take effect when larger than 'bits_per_sample', default '0' means equal to 'bits_per_sample' */ + +#if SOC_I2S_SUPPORTS_TDM + i2s_channel_t chan_mask; /*!< I2S active channel bit mask, set value in `i2s_channel_t` to enable specific channel, the bit map of active channel can not exceed (0x1< 4 + PCNT_UNIT_4, /*!< PCNT unit 4 */ + PCNT_UNIT_5, /*!< PCNT unit 5 */ + PCNT_UNIT_6, /*!< PCNT unit 6 */ + PCNT_UNIT_7, /*!< PCNT unit 7 */ +#endif + PCNT_UNIT_MAX, +} pcnt_unit_t; + +/** + * @brief Selection of channels available for a single PCNT unit + */ +typedef enum { + PCNT_CHANNEL_0, /*!< PCNT channel 0 */ + PCNT_CHANNEL_1, /*!< PCNT channel 1 */ + PCNT_CHANNEL_MAX, +} pcnt_channel_t; + +/** + * @brief Selection of counter's events the may trigger an interrupt + */ +typedef enum { + PCNT_EVT_THRES_1 = 1 << 2, /*!< PCNT watch point event: threshold1 value event */ + PCNT_EVT_THRES_0 = 1 << 3, /*!< PCNT watch point event: threshold0 value event */ + PCNT_EVT_L_LIM = 1 << 4, /*!< PCNT watch point event: Minimum counter value */ + PCNT_EVT_H_LIM = 1 << 5, /*!< PCNT watch point event: Maximum counter value */ + PCNT_EVT_ZERO = 1 << 6, /*!< PCNT watch point event: counter value zero event */ + PCNT_EVT_MAX +} pcnt_evt_type_t; + +/** + * @brief Selection of available modes that determine the counter's action depending on the state of the control signal's input GPIO + * @note Configuration covers two actions, one for high, and one for low level on the control input + */ +typedef pcnt_channel_level_action_t pcnt_ctrl_mode_t; +#define PCNT_MODE_KEEP PCNT_CHANNEL_LEVEL_ACTION_KEEP /*!< Control mode: won't change counter mode*/ +#define PCNT_MODE_REVERSE PCNT_CHANNEL_LEVEL_ACTION_INVERSE /*!< Control mode: invert counter mode(increase -> decrease, decrease -> increase) */ +#define PCNT_MODE_DISABLE PCNT_CHANNEL_LEVEL_ACTION_HOLD /*!< Control mode: Inhibit counter(counter value will not change in this condition) */ +#define PCNT_MODE_MAX 3 + +/** + * @brief Selection of available modes that determine the counter's action on the edge of the pulse signal's input GPIO + * @note Configuration covers two actions, one for positive, and one for negative edge on the pulse input + */ +typedef pcnt_channel_edge_action_t pcnt_count_mode_t; +#define PCNT_COUNT_DIS PCNT_CHANNEL_EDGE_ACTION_HOLD /*!< Counter mode: Inhibit counter(counter value will not change in this condition) */ +#define PCNT_COUNT_INC PCNT_CHANNEL_EDGE_ACTION_INCREASE /*!< Counter mode: Increase counter value */ +#define PCNT_COUNT_DEC PCNT_CHANNEL_EDGE_ACTION_DECREASE /*!< Counter mode: Decrease counter value */ +#define PCNT_COUNT_MAX 3 + +/** + * @brief Pulse Counter configuration for a single channel + */ +typedef struct { + int pulse_gpio_num; /*!< Pulse input GPIO number, if you want to use GPIO16, enter pulse_gpio_num = 16, a negative value will be ignored */ + int ctrl_gpio_num; /*!< Control signal input GPIO number, a negative value will be ignored */ + pcnt_ctrl_mode_t lctrl_mode; /*!< PCNT low control mode */ + pcnt_ctrl_mode_t hctrl_mode; /*!< PCNT high control mode */ + pcnt_count_mode_t pos_mode; /*!< PCNT positive edge count mode */ + pcnt_count_mode_t neg_mode; /*!< PCNT negative edge count mode */ + int16_t counter_h_lim; /*!< Maximum counter value */ + int16_t counter_l_lim; /*!< Minimum counter value */ + pcnt_unit_t unit; /*!< PCNT unit number */ + pcnt_channel_t channel; /*!< the PCNT channel */ +} pcnt_config_t; + /** * @brief Configure Pulse Counter unit * @note @@ -173,7 +257,6 @@ esp_err_t pcnt_get_event_value(pcnt_unit_t unit, pcnt_evt_type_t evt_type, int16 * @param unit PCNT unit number * @param status Pointer to accept event status word * @return - * * - ESP_OK Success * - ESP_ERR_INVALID_STATE pcnt driver has not been initialized * - ESP_ERR_INVALID_ARG Parameter error @@ -363,42 +446,6 @@ void pcnt_isr_service_uninstall(void); */ esp_err_t pcnt_isr_handler_remove(pcnt_unit_t unit); -/** - * @addtogroup pcnt-examples - * - * @{ - * - * EXAMPLE OF PCNT CONFIGURATION - * ============================== - * @code{c} - * //1. Config PCNT unit - * pcnt_config_t pcnt_config = { - * .pulse_gpio_num = 4, //set gpio4 as pulse input gpio - * .ctrl_gpio_num = 5, //set gpio5 as control gpio - * .channel = PCNT_CHANNEL_0, //use unit 0 channel 0 - * .lctrl_mode = PCNT_MODE_REVERSE, //when control signal is low, reverse the primary counter mode(inc->dec/dec->inc) - * .hctrl_mode = PCNT_MODE_KEEP, //when control signal is high, keep the primary counter mode - * .pos_mode = PCNT_COUNT_INC, //increment the counter - * .neg_mode = PCNT_COUNT_DIS, //keep the counter value - * .counter_h_lim = 10, - * .counter_l_lim = -10, - * }; - * pcnt_unit_config(&pcnt_config); //init unit - * @endcode - * - * EXAMPLE OF PCNT EVENT SETTING - * ============================== - * @code{c} - * //2. Configure PCNT watchpoint event. - * pcnt_set_event_value(PCNT_UNIT_0, PCNT_EVT_THRES_1, 5); //set thres1 value - * pcnt_event_enable(PCNT_UNIT_0, PCNT_EVT_THRES_1); //enable thres1 event - * @endcode - * - * For more examples please refer to PCNT example code in IDF_PATH/examples - * - * @} - */ - #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32c3/include/driver/include/driver/spi_common.h b/tools/sdk/esp32c3/include/driver/include/driver/spi_common.h index f6b12255a53..830b8efd8c2 100644 --- a/tools/sdk/esp32c3/include/driver/include/driver/spi_common.h +++ b/tools/sdk/esp32c3/include/driver/include/driver/spi_common.h @@ -63,7 +63,8 @@ extern "C" #define SPICOMMON_BUSFLAG_DUAL (1<<6) ///< Check MOSI and MISO pins can output. Or indicates bus able to work under DIO mode. #define SPICOMMON_BUSFLAG_WPHD (1<<7) ///< Check existing of WP and HD pins. Or indicates WP & HD pins initialized. #define SPICOMMON_BUSFLAG_QUAD (SPICOMMON_BUSFLAG_DUAL|SPICOMMON_BUSFLAG_WPHD) ///< Check existing of MOSI/MISO/WP/HD pins as output. Or indicates bus able to work under QIO mode. - +#define SPICOMMON_BUSFLAG_IO4_IO7 (1<<8) ///< Check existing of IO4~IO7 pins. Or indicates IO4~IO7 pins initialized. +#define SPICOMMON_BUSFLAG_OCTAL (SPICOMMON_BUSFLAG_QUAD|SPICOMMON_BUSFLAG_IO4_IO7) ///< Check existing of MOSI/MISO/WP/HD/SPIIO4/SPIIO5/SPIIO6/SPIIO7 pins as output. Or indicates bus able to work under octal mode. #define SPICOMMON_BUSFLAG_NATIVE_PINS SPICOMMON_BUSFLAG_IOMUX_PINS /** @@ -95,18 +96,34 @@ typedef spi_common_dma_t spi_dma_chan_t; * @note Be advised that the slave driver does not use the quadwp/quadhd lines and fields in spi_bus_config_t refering to these lines will be ignored and can thus safely be left uninitialized. */ typedef struct { - int mosi_io_num; ///< GPIO pin for Master Out Slave In (=spi_d) signal, or -1 if not used. - int miso_io_num; ///< GPIO pin for Master In Slave Out (=spi_q) signal, or -1 if not used. - int sclk_io_num; ///< GPIO pin for Spi CLocK signal, or -1 if not used. - int quadwp_io_num; ///< GPIO pin for WP (Write Protect) signal which is used as D2 in 4-bit communication modes, or -1 if not used. - int quadhd_io_num; ///< GPIO pin for HD (HolD) signal which is used as D3 in 4-bit communication modes, or -1 if not used. - int max_transfer_sz; ///< Maximum transfer size, in bytes. Defaults to 4092 if 0 when DMA enabled, or to `SOC_SPI_MAXIMUM_BUFFER_SIZE` if DMA is disabled. - uint32_t flags; ///< Abilities of bus to be checked by the driver. Or-ed value of ``SPICOMMON_BUSFLAG_*`` flags. - int intr_flags; /**< Interrupt flag for the bus to set the priority, and IRAM attribute, see - * ``esp_intr_alloc.h``. Note that the EDGE, INTRDISABLED attribute are ignored - * by the driver. Note that if ESP_INTR_FLAG_IRAM is set, ALL the callbacks of - * the driver, and their callee functions, should be put in the IRAM. - */ + union { + int mosi_io_num; ///< GPIO pin for Master Out Slave In (=spi_d) signal, or -1 if not used. + int data0_io_num; ///< GPIO pin for spi data0 signal in quad/octal mode, or -1 if not used. + }; + union { + int miso_io_num; ///< GPIO pin for Master In Slave Out (=spi_q) signal, or -1 if not used. + int data1_io_num; ///< GPIO pin for spi data1 signal in quad/octal mode, or -1 if not used. + }; + int sclk_io_num; ///< GPIO pin for SPI Clock signal, or -1 if not used. + union { + int quadwp_io_num; ///< GPIO pin for WP (Write Protect) signal, or -1 if not used. + int data2_io_num; ///< GPIO pin for spi data2 signal in quad/octal mode, or -1 if not used. + }; + union { + int quadhd_io_num; ///< GPIO pin for HD (Hold) signal, or -1 if not used. + int data3_io_num; ///< GPIO pin for spi data3 signal in quad/octal mode, or -1 if not used. + }; + int data4_io_num; ///< GPIO pin for spi data4 signal in octal mode, or -1 if not used. + int data5_io_num; ///< GPIO pin for spi data5 signal in octal mode, or -1 if not used. + int data6_io_num; ///< GPIO pin for spi data6 signal in octal mode, or -1 if not used. + int data7_io_num; ///< GPIO pin for spi data7 signal in octal mode, or -1 if not used. + int max_transfer_sz; ///< Maximum transfer size, in bytes. Defaults to 4092 if 0 when DMA enabled, or to `SOC_SPI_MAXIMUM_BUFFER_SIZE` if DMA is disabled. + uint32_t flags; ///< Abilities of bus to be checked by the driver. Or-ed value of ``SPICOMMON_BUSFLAG_*`` flags. + int intr_flags; /**< Interrupt flag for the bus to set the priority, and IRAM attribute, see + * ``esp_intr_alloc.h``. Note that the EDGE, INTRDISABLED attribute are ignored + * by the driver. Note that if ESP_INTR_FLAG_IRAM is set, ALL the callbacks of + * the driver, and their callee functions, should be put in the IRAM. + */ } spi_bus_config_t; diff --git a/tools/sdk/esp32c3/include/driver/include/driver/spi_common_internal.h b/tools/sdk/esp32c3/include/driver/include/driver/spi_common_internal.h index 31baaa75d70..90826c0a8e9 100644 --- a/tools/sdk/esp32c3/include/driver/include/driver/spi_common_internal.h +++ b/tools/sdk/esp32c3/include/driver/include/driver/spi_common_internal.h @@ -155,6 +155,8 @@ esp_err_t spicommon_slave_free_dma(spi_host_device_t host_id); * - ``SPICOMMON_BUSFLAG_DUAL``: Make sure both MISO and MOSI are output capable so that DIO mode is capable. * - ``SPICOMMON_BUSFLAG_WPHD`` Make sure WP and HD are set to valid output GPIOs. * - ``SPICOMMON_BUSFLAG_QUAD``: Combination of ``SPICOMMON_BUSFLAG_DUAL`` and ``SPICOMMON_BUSFLAG_WPHD``. + * - ``SPICOMMON_BUSFLAG_IO4_IO7``: Make sure spi data4 ~ spi data7 are set to valid output GPIOs. + * - ``SPICOMMON_BUSFLAG_OCTAL``: Combination of ``SPICOMMON_BUSFLAG_QUAL`` and ``SPICOMMON_BUSFLAG_IO4_IO7``. * @param[out] flags_o A SPICOMMON_BUSFLAG_* flag combination of bus abilities will be written to this address. * Leave to NULL if not needed. * - ``SPICOMMON_BUSFLAG_IOMUX_PINS``: The bus is connected to iomux pins. @@ -163,6 +165,8 @@ esp_err_t spicommon_slave_free_dma(spi_host_device_t host_id); * - ``SPICOMMON_BUSFLAG_DUAL``: The bus is capable with DIO mode. * - ``SPICOMMON_BUSFLAG_WPHD`` The bus has WP and HD connected. * - ``SPICOMMON_BUSFLAG_QUAD``: Combination of ``SPICOMMON_BUSFLAG_DUAL`` and ``SPICOMMON_BUSFLAG_WPHD``. + * - ``SPICOMMON_BUSFLAG_IO4_IO7``: The bus has spi data4 ~ spi data7 connected. + * - ``SPICOMMON_BUSFLAG_OCTAL``: Combination of ``SPICOMMON_BUSFLAG_QUAL`` and ``SPICOMMON_BUSFLAG_IO4_IO7``. * @return * - ESP_ERR_INVALID_ARG if parameter is invalid * - ESP_OK on success diff --git a/tools/sdk/esp32c3/include/driver/include/driver/spi_master.h b/tools/sdk/esp32c3/include/driver/include/driver/spi_master.h index 8582a332766..d6a202f848a 100644 --- a/tools/sdk/esp32c3/include/driver/include/driver/spi_master.h +++ b/tools/sdk/esp32c3/include/driver/include/driver/spi_master.h @@ -104,8 +104,11 @@ typedef struct { #define SPI_TRANS_VARIABLE_CMD (1<<5) ///< Use the ``command_bits`` in ``spi_transaction_ext_t`` rather than default value in ``spi_device_interface_config_t``. #define SPI_TRANS_VARIABLE_ADDR (1<<6) ///< Use the ``address_bits`` in ``spi_transaction_ext_t`` rather than default value in ``spi_device_interface_config_t``. #define SPI_TRANS_VARIABLE_DUMMY (1<<7) ///< Use the ``dummy_bits`` in ``spi_transaction_ext_t`` rather than default value in ``spi_device_interface_config_t``. -#define SPI_TRANS_SET_CD (1<<7) ///< Set the CD pin #define SPI_TRANS_CS_KEEP_ACTIVE (1<<8) ///< Keep CS active after data transfer +#define SPI_TRANS_MULTILINE_CMD (1<<9) ///< The data lines used at command phase is the same as data phase (otherwise, only one data line is used at command phase) +#define SPI_TRANS_MODE_OCT (1<<10) ///< Transmit/receive data in 8-bit mode +#define SPI_TRANS_MULTILINE_ADDR SPI_TRANS_MODE_DIOQIO_ADDR ///< The data lines used at address phase is the same as data phase (otherwise, only one data line is used at address phase) + /** * This structure describes one SPI transaction. The descriptor should not be modified until the transaction finishes. */ @@ -148,7 +151,7 @@ typedef struct { } spi_transaction_ext_t ; -typedef struct spi_device_t* spi_device_handle_t; ///< Handle for a device on a SPI bus +typedef struct spi_device_t *spi_device_handle_t; ///< Handle for a device on a SPI bus /** * @brief Allocate a device on a SPI bus * @@ -341,7 +344,7 @@ void spi_device_release_bus(spi_device_handle_t dev); * * @return Actual working frequency that most fit. */ -int spi_cal_clock(int fapb, int hz, int duty_cycle, uint32_t* reg_o) __attribute__((deprecated)); +int spi_cal_clock(int fapb, int hz, int duty_cycle, uint32_t *reg_o) __attribute__((deprecated)); /** * @brief Calculate the working frequency that is most close to desired frequency. @@ -368,7 +371,7 @@ int spi_get_actual_clock(int fapb, int hz, int duty_cycle); * * @note If **dummy_o* is not zero, it means dummy bits should be applied in half duplex mode, and full duplex mode may not work. */ -void spi_get_timing(bool gpio_is_used, int input_delay_ns, int eff_clk, int* dummy_o, int* cycles_remain_o); +void spi_get_timing(bool gpio_is_used, int input_delay_ns, int eff_clk, int *dummy_o, int *cycles_remain_o); /** * @brief Get the frequency limit of current configurations. diff --git a/tools/sdk/esp32c3/include/driver/include/driver/timer.h b/tools/sdk/esp32c3/include/driver/include/driver/timer.h index 204fc9db27d..a3ab39267cd 100644 --- a/tools/sdk/esp32c3/include/driver/include/driver/timer.h +++ b/tools/sdk/esp32c3/include/driver/include/driver/timer.h @@ -130,8 +130,9 @@ esp_err_t timer_set_counter_mode(timer_group_t group_num, timer_idx_t timer_num, esp_err_t timer_set_auto_reload(timer_group_t group_num, timer_idx_t timer_num, timer_autoreload_t reload); /** - * @brief Set hardware timer source clock divider. Timer groups clock are divider from APB clock. - * + * @brief Set hardware divider of the source clock to the timer group. + * By default, the source clock is APB clock running at 80 MHz. + * For more information, please check Chapter Reset and Clock in Chip Technical Reference Manual. * @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1 * @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1] * @param divider Timer clock divider value. The divider's range is from from 2 to 65536. diff --git a/tools/sdk/esp32c3/include/driver/include/driver/twai.h b/tools/sdk/esp32c3/include/driver/include/driver/twai.h index ce616fe1251..70f88a4da10 100644 --- a/tools/sdk/esp32c3/include/driver/include/driver/twai.h +++ b/tools/sdk/esp32c3/include/driver/include/driver/twai.h @@ -47,23 +47,24 @@ extern "C" { */ #define TWAI_ALERT_TX_IDLE 0x00000001 /**< Alert(1): No more messages to transmit */ #define TWAI_ALERT_TX_SUCCESS 0x00000002 /**< Alert(2): The previous transmission was successful */ -#define TWAI_ALERT_BELOW_ERR_WARN 0x00000004 /**< Alert(4): Both error counters have dropped below error warning limit */ -#define TWAI_ALERT_ERR_ACTIVE 0x00000008 /**< Alert(8): TWAI controller has become error active */ -#define TWAI_ALERT_RECOVERY_IN_PROGRESS 0x00000010 /**< Alert(16): TWAI controller is undergoing bus recovery */ -#define TWAI_ALERT_BUS_RECOVERED 0x00000020 /**< Alert(32): TWAI controller has successfully completed bus recovery */ -#define TWAI_ALERT_ARB_LOST 0x00000040 /**< Alert(64): The previous transmission lost arbitration */ -#define TWAI_ALERT_ABOVE_ERR_WARN 0x00000080 /**< Alert(128): One of the error counters have exceeded the error warning limit */ -#define TWAI_ALERT_BUS_ERROR 0x00000100 /**< Alert(256): A (Bit, Stuff, CRC, Form, ACK) error has occurred on the bus */ -#define TWAI_ALERT_TX_FAILED 0x00000200 /**< Alert(512): The previous transmission has failed (for single shot transmission) */ -#define TWAI_ALERT_RX_QUEUE_FULL 0x00000400 /**< Alert(1024): The RX queue is full causing a frame to be lost */ -#define TWAI_ALERT_ERR_PASS 0x00000800 /**< Alert(2048): TWAI controller has become error passive */ -#define TWAI_ALERT_BUS_OFF 0x00001000 /**< Alert(4096): Bus-off condition occurred. TWAI controller can no longer influence bus */ -#define TWAI_ALERT_RX_FIFO_OVERRUN 0x00002000 /**< Alert(8192): An RX FIFO overrun has occurred */ -#define TWAI_ALERT_TX_RETRIED 0x00004000 /**< Alert(16384): An message transmission was cancelled and retried due to an errata workaround */ -#define TWAI_ALERT_PERIPH_RESET 0x00008000 /**< Alert(32768): The TWAI controller was reset */ -#define TWAI_ALERT_ALL 0x0000FFFF /**< Bit mask to enable all alerts during configuration */ +#define TWAI_ALERT_RX_DATA 0x00000004 /**< Alert(4): A frame has been received and added to the RX queue */ +#define TWAI_ALERT_BELOW_ERR_WARN 0x00000008 /**< Alert(8): Both error counters have dropped below error warning limit */ +#define TWAI_ALERT_ERR_ACTIVE 0x00000010 /**< Alert(16): TWAI controller has become error active */ +#define TWAI_ALERT_RECOVERY_IN_PROGRESS 0x00000020 /**< Alert(32): TWAI controller is undergoing bus recovery */ +#define TWAI_ALERT_BUS_RECOVERED 0x00000040 /**< Alert(64): TWAI controller has successfully completed bus recovery */ +#define TWAI_ALERT_ARB_LOST 0x00000080 /**< Alert(128): The previous transmission lost arbitration */ +#define TWAI_ALERT_ABOVE_ERR_WARN 0x00000100 /**< Alert(256): One of the error counters have exceeded the error warning limit */ +#define TWAI_ALERT_BUS_ERROR 0x00000200 /**< Alert(512): A (Bit, Stuff, CRC, Form, ACK) error has occurred on the bus */ +#define TWAI_ALERT_TX_FAILED 0x00000400 /**< Alert(1024): The previous transmission has failed (for single shot transmission) */ +#define TWAI_ALERT_RX_QUEUE_FULL 0x00000800 /**< Alert(2048): The RX queue is full causing a frame to be lost */ +#define TWAI_ALERT_ERR_PASS 0x00001000 /**< Alert(4096): TWAI controller has become error passive */ +#define TWAI_ALERT_BUS_OFF 0x00002000 /**< Alert(8192): Bus-off condition occurred. TWAI controller can no longer influence bus */ +#define TWAI_ALERT_RX_FIFO_OVERRUN 0x00004000 /**< Alert(16384): An RX FIFO overrun has occurred */ +#define TWAI_ALERT_TX_RETRIED 0x00008000 /**< Alert(32768): An message transmission was cancelled and retried due to an errata workaround */ +#define TWAI_ALERT_PERIPH_RESET 0x00010000 /**< Alert(65536): The TWAI controller was reset */ +#define TWAI_ALERT_ALL 0x0001FFFF /**< Bit mask to enable all alerts during configuration */ #define TWAI_ALERT_NONE 0x00000000 /**< Bit mask to disable all alerts during configuration */ -#define TWAI_ALERT_AND_LOG 0x00010000 /**< Bit mask to enable alerts to also be logged when they occur. Note that logging from the ISR is disabled if CONFIG_TWAI_ISR_IN_IRAM is enabled (see docs). */ +#define TWAI_ALERT_AND_LOG 0x00020000 /**< Bit mask to enable alerts to also be logged when they occur. Note that logging from the ISR is disabled if CONFIG_TWAI_ISR_IN_IRAM is enabled (see docs). */ /** @endcond */ diff --git a/tools/sdk/esp32c3/include/driver/include/driver/uart.h b/tools/sdk/esp32c3/include/driver/include/driver/uart.h index 311f21a8334..76aa424fa27 100644 --- a/tools/sdk/esp32c3/include/driver/include/driver/uart.h +++ b/tools/sdk/esp32c3/include/driver/include/driver/uart.h @@ -28,7 +28,10 @@ extern "C" { #endif #define UART_NUM_MAX (SOC_UART_NUM) /*!< UART port max */ -#define UART_PIN_NO_CHANGE (-1) /*!< Constant for uart_set_pin function which indicates that UART pin should not be changed */ +/* @brief When calling `uart_set_pin`, instead of GPIO number, `UART_PIN_NO_CHANGE` + * can be provided to keep the currently allocated pin. + */ +#define UART_PIN_NO_CHANGE (-1) #define UART_FIFO_LEN SOC_UART_FIFO_LEN ///< Length of the UART HW FIFO #define UART_BITRATE_MAX SOC_UART_BITRATE_MAX ///< Maximum configurable bitrate @@ -380,14 +383,23 @@ esp_err_t uart_isr_register(uart_port_t uart_num, void (*fn)(void*), void * arg, esp_err_t uart_isr_free(uart_port_t uart_num); /** - * @brief Set UART pin number + * @brief Assign signals of a UART peripheral to GPIO pins + * + * @note If the GPIO number configured for a UART signal matches one of the + * IOMUX signals for that GPIO, the signal will be connected directly + * via the IOMUX. Otherwise the GPIO and signal will be connected via + * the GPIO Matrix. For example, if on an ESP32 the call + * `uart_set_pin(0, 1, 3, -1, -1)` is performed, as GPIO1 is UART0's + * default TX pin and GPIO3 is UART0's default RX pin, both will be + * connected to respectively U0TXD and U0RXD through the IOMUX, totally + * bypassing the GPIO matrix. + * The check is performed on a per-pin basis. Thus, it is possible to have + * RX pin binded to a GPIO through the GPIO matrix, whereas TX is binded + * to its GPIO through the IOMUX. * * @note Internal signal can be output to multiple GPIO pads. * Only one GPIO pad can connect with input signal. * - * @note Instead of GPIO number a macro 'UART_PIN_NO_CHANGE' may be provided - to keep the currently allocated pin. - * * @param uart_num UART port number, the max port number is (UART_NUM_MAX -1). * @param tx_io_num UART TX pin GPIO number. * @param rx_io_num UART RX pin GPIO number. diff --git a/tools/sdk/esp32c3/include/driver/include/esp_private/i2s_platform.h b/tools/sdk/esp32c3/include/driver/include/esp_private/i2s_platform.h new file mode 100644 index 00000000000..ff1ebdf17a6 --- /dev/null +++ b/tools/sdk/esp32c3/include/driver/include/esp_private/i2s_platform.h @@ -0,0 +1,48 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +// DO NOT USE THESE APIS IN YOUR APPLICATIONS +// The following APIs are for internal use, public to other IDF components, but not for users' applications. + +#pragma once + +#include "esp_err.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Register an I2S or I2S variant driver object to platform + * + * @note This private API is used to avoid applications from using the same I2S instance for different purpose. + * @note This function will help enable the peripheral APB clock as well. + * + * @param driver_obj Driver object + * @param port_id I2S port number + * @return + * - ESP_OK: The specific I2S port is free and register the new device object successfully + * - ESP_ERR_INVALID_ARG: Invalid argument, e.g. wrong port_id + * - ESP_ERR_NOT_FOUND: Specific I2S port is not available + */ +esp_err_t i2s_priv_register_object(void *driver_obj, int port_id); + +/** + * @brief Deregister I2S or I2S variant driver object from platform + * + * @note This function will help disable the peripheral APB clock as well. + * + * @param port_id I2S port number + * @return + * - ESP_OK: Deregister I2S port successfully (i.e. that I2S port can used used by other users after this function returns) + * - ESP_ERR_INVALID_ARG: Invalid argument, e.g. wrong port_id + * - ESP_ERR_INVALID_STATE: Specific I2S port is free already + */ +esp_err_t i2s_priv_deregister_object(int port_id); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32c3/include/efuse/esp32c3/include/esp_efuse_table.h b/tools/sdk/esp32c3/include/efuse/esp32c3/include/esp_efuse_table.h index 96fba509131..839116af264 100644 --- a/tools/sdk/esp32c3/include/efuse/esp32c3/include/esp_efuse_table.h +++ b/tools/sdk/esp32c3/include/efuse/esp32c3/include/esp_efuse_table.h @@ -9,7 +9,7 @@ extern "C" { #endif -// md5_digest_table 7a50fdd084e3b80b143c5bd2a36f9c26 +// md5_digest_table ef33779021404fbaddc878eefebaddc1 // This file was generated from the file esp_efuse_table.csv. DO NOT CHANGE THIS FILE MANUALLY. // If you want to change some fields, you need to change esp_efuse_table.csv file // then run `efuse_common_table` or `efuse_custom_table` command it will generate this file. @@ -51,7 +51,6 @@ extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_KEY3[]; extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_KEY4[]; extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_KEY5[]; extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_SYS_DATA_PART2[]; -extern const esp_efuse_desc_t* ESP_EFUSE_DIS_RTC_RAM_BOOT[]; extern const esp_efuse_desc_t* ESP_EFUSE_DIS_ICACHE[]; extern const esp_efuse_desc_t* ESP_EFUSE_DIS_USB_JTAG[]; extern const esp_efuse_desc_t* ESP_EFUSE_DIS_DOWNLOAD_ICACHE[]; @@ -125,6 +124,7 @@ extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_CAL_VOL_ATTEN1[]; extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_CAL_VOL_ATTEN2[]; extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_CAL_VOL_ATTEN3[]; extern const esp_efuse_desc_t* ESP_EFUSE_USER_DATA[]; +extern const esp_efuse_desc_t* ESP_EFUSE_USER_DATA_MAC_CUSTOM[]; extern const esp_efuse_desc_t* ESP_EFUSE_KEY0[]; extern const esp_efuse_desc_t* ESP_EFUSE_KEY1[]; extern const esp_efuse_desc_t* ESP_EFUSE_KEY2[]; diff --git a/tools/sdk/esp32c3/include/esp-tls/esp_tls.h b/tools/sdk/esp32c3/include/esp-tls/esp_tls.h index 9330f9dd699..588f70d83f9 100644 --- a/tools/sdk/esp32c3/include/esp-tls/esp_tls.h +++ b/tools/sdk/esp32c3/include/esp-tls/esp_tls.h @@ -20,6 +20,9 @@ #include "mbedtls/ctr_drbg.h" #include "mbedtls/error.h" #include "mbedtls/certs.h" +#ifdef CONFIG_ESP_TLS_SERVER_SESSION_TICKETS +#include "mbedtls/ssl_ticket.h" +#endif #elif CONFIG_ESP_TLS_USING_WOLFSSL #include "wolfssl/wolfcrypt/settings.h" #include "wolfssl/ssl.h" @@ -54,6 +57,15 @@ typedef struct psk_key_hint { const char* hint; /*!< hint in PSK authentication mode in string format */ } psk_hint_key_t; +/** + * @brief esp-tls client session ticket ctx + */ +#ifdef CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS +typedef struct esp_tls_client_session { + mbedtls_ssl_session saved_session; +} esp_tls_client_session_t; +#endif /* CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS */ + /** * @brief Keep alive parameters structure */ @@ -168,9 +180,27 @@ typedef struct esp_tls_cfg { directly with esp_tls_plain_tcp_connect() API */ struct ifreq *if_name; /*!< The name of interface for data to go through. Use the default interface without setting */ + +#ifdef CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS + esp_tls_client_session_t *client_session; /*! Pointer for the client session ticket context. */ +#endif /* CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS */ } esp_tls_cfg_t; #ifdef CONFIG_ESP_TLS_SERVER +#if defined(CONFIG_ESP_TLS_SERVER_SESSION_TICKETS) +/** + * @brief Data structures necessary to support TLS session tickets according to RFC5077 + */ +typedef struct esp_tls_server_session_ticket_ctx { + mbedtls_entropy_context entropy; /*!< mbedTLS entropy context structure */ + + mbedtls_ctr_drbg_context ctr_drbg; /*!< mbedTLS ctr drbg context structure. + CTR_DRBG is deterministic random + bit generation based on AES-256 */ + mbedtls_ssl_ticket_context ticket_ctx; /*!< Session ticket generation context */ +} esp_tls_server_session_ticket_ctx_t; +#endif + typedef struct esp_tls_cfg_server { const char **alpn_protos; /*!< Application protocols required for HTTP2. If HTTP2/ALPN support is required, a list @@ -222,7 +252,39 @@ typedef struct esp_tls_cfg_server { unsigned int serverkey_password_len; /*!< String length of the password pointed to by serverkey_password */ +#if defined(CONFIG_ESP_TLS_SERVER_SESSION_TICKETS) + esp_tls_server_session_ticket_ctx_t * ticket_ctx; /*!< Session ticket generation context. + You have to call esp_tls_cfg_server_session_tickets_init + to use it. + Call esp_tls_cfg_server_session_tickets_free + to free the data associated with this context. */ +#endif } esp_tls_cfg_server_t; + +/** + * @brief Initialize the server side TLS session ticket context + * + * This function initializes the server side tls session ticket context + * which holds all necessary data structures to enable tls session tickets + * according to RFC5077. + * Use esp_tls_cfg_server_session_tickets_free to free the data. + * + * @param[in] cfg server configuration as esp_tls_cfg_server_t + * @return + * ESP_OK if setup succeeded + * ESP_ERR_INVALID_ARG if context is already initialized + * ESP_ERR_NO_MEM if memory allocation failed + * ESP_ERR_NOT_SUPPORTED if session tickets are not available due to build configuration + * ESP_FAIL if setup failed + */ +esp_err_t esp_tls_cfg_server_session_tickets_init(esp_tls_cfg_server_t *cfg); + +/** + * @brief Free the server side TLS session ticket context + * + * @param cfg server configuration as esp_tls_cfg_server_t + */ +void esp_tls_cfg_server_session_tickets_free(esp_tls_cfg_server_t *cfg); #endif /* ! CONFIG_ESP_TLS_SERVER */ /** @@ -404,6 +466,10 @@ int esp_tls_conn_http_new_async(const char *url, const esp_tls_cfg_t *cfg, esp_t * of bytes actually written to the TLS/SSL connection. * - <0 if write operation was not successful, because either an * error occured or an action must be taken by the calling process. + * - ESP_TLS_ERR_SSL_WANT_READ/ + * ESP_TLS_ERR_SSL_WANT_WRITE. + * if the handshake is incomplete and waiting for data to be available for reading. + * In this case this functions needs to be called again when the underlying transport is ready for operation. */ static inline ssize_t esp_tls_conn_write(esp_tls_t *tls, const void *data, size_t datalen) { @@ -609,6 +675,20 @@ void esp_tls_server_session_delete(esp_tls_t *tls); */ esp_err_t esp_tls_plain_tcp_connect(const char *host, int hostlen, int port, const esp_tls_cfg_t *cfg, esp_tls_error_handle_t error_handle, int *sockfd); +#ifdef CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS +/** + * @brief Obtain the client session ticket + * + * This function should be called when the TLS connection is already established. + * This can be passed again in the esp_tls_cfg_t structure, to appropriate tls session create (e.g. esp_tls_conn_http_new) API for session resumption. + * + * @param[in] esp_tls context as esp_tls_t + * @return + * Pointer to the saved client session. + * NULL on Failure + */ +esp_tls_client_session_t *esp_tls_get_client_session(esp_tls_t *tls); +#endif /* CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS */ #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32c3/include/esp-tls/esp_tls_errors.h b/tools/sdk/esp32c3/include/esp-tls/esp_tls_errors.h index 5dfe74791c5..ad104895aaf 100644 --- a/tools/sdk/esp32c3/include/esp-tls/esp_tls_errors.h +++ b/tools/sdk/esp32c3/include/esp-tls/esp_tls_errors.h @@ -14,35 +14,42 @@ extern "C" { #endif #define ESP_ERR_ESP_TLS_BASE 0x8000 /*!< Starting number of ESP-TLS error codes */ + +/* generic esp-tls error codes */ #define ESP_ERR_ESP_TLS_CANNOT_RESOLVE_HOSTNAME (ESP_ERR_ESP_TLS_BASE + 0x01) /*!< Error if hostname couldn't be resolved upon tls connection */ #define ESP_ERR_ESP_TLS_CANNOT_CREATE_SOCKET (ESP_ERR_ESP_TLS_BASE + 0x02) /*!< Failed to create socket */ #define ESP_ERR_ESP_TLS_UNSUPPORTED_PROTOCOL_FAMILY (ESP_ERR_ESP_TLS_BASE + 0x03) /*!< Unsupported protocol family */ #define ESP_ERR_ESP_TLS_FAILED_CONNECT_TO_HOST (ESP_ERR_ESP_TLS_BASE + 0x04) /*!< Failed to connect to host */ #define ESP_ERR_ESP_TLS_SOCKET_SETOPT_FAILED (ESP_ERR_ESP_TLS_BASE + 0x05) /*!< failed to set/get socket option */ -#define ESP_ERR_MBEDTLS_CERT_PARTLY_OK (ESP_ERR_ESP_TLS_BASE + 0x06) /*!< mbedtls parse certificates was partly successful */ -#define ESP_ERR_MBEDTLS_CTR_DRBG_SEED_FAILED (ESP_ERR_ESP_TLS_BASE + 0x07) /*!< mbedtls api returned error */ -#define ESP_ERR_MBEDTLS_SSL_SET_HOSTNAME_FAILED (ESP_ERR_ESP_TLS_BASE + 0x08) /*!< mbedtls api returned error */ -#define ESP_ERR_MBEDTLS_SSL_CONFIG_DEFAULTS_FAILED (ESP_ERR_ESP_TLS_BASE + 0x09) /*!< mbedtls api returned error */ -#define ESP_ERR_MBEDTLS_SSL_CONF_ALPN_PROTOCOLS_FAILED (ESP_ERR_ESP_TLS_BASE + 0x0A) /*!< mbedtls api returned error */ -#define ESP_ERR_MBEDTLS_X509_CRT_PARSE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x0B) /*!< mbedtls api returned error */ -#define ESP_ERR_MBEDTLS_SSL_CONF_OWN_CERT_FAILED (ESP_ERR_ESP_TLS_BASE + 0x0C) /*!< mbedtls api returned error */ -#define ESP_ERR_MBEDTLS_SSL_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x0D) /*!< mbedtls api returned error */ -#define ESP_ERR_MBEDTLS_SSL_WRITE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x0E) /*!< mbedtls api returned error */ -#define ESP_ERR_MBEDTLS_PK_PARSE_KEY_FAILED (ESP_ERR_ESP_TLS_BASE + 0x0F) /*!< mbedtls api returned failed */ -#define ESP_ERR_MBEDTLS_SSL_HANDSHAKE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x10) /*!< mbedtls api returned failed */ -#define ESP_ERR_MBEDTLS_SSL_CONF_PSK_FAILED (ESP_ERR_ESP_TLS_BASE + 0x11) /*!< mbedtls api returned failed */ -#define ESP_ERR_ESP_TLS_CONNECTION_TIMEOUT (ESP_ERR_ESP_TLS_BASE + 0x12) /*!< new connection in esp_tls_low_level_conn connection timeouted */ -#define ESP_ERR_WOLFSSL_SSL_SET_HOSTNAME_FAILED (ESP_ERR_ESP_TLS_BASE + 0x13) /*!< wolfSSL api returned error */ -#define ESP_ERR_WOLFSSL_SSL_CONF_ALPN_PROTOCOLS_FAILED (ESP_ERR_ESP_TLS_BASE + 0x14) /*!< wolfSSL api returned error */ -#define ESP_ERR_WOLFSSL_CERT_VERIFY_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x15) /*!< wolfSSL api returned error */ -#define ESP_ERR_WOLFSSL_KEY_VERIFY_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x16) /*!< wolfSSL api returned error */ -#define ESP_ERR_WOLFSSL_SSL_HANDSHAKE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x17) /*!< wolfSSL api returned failed */ -#define ESP_ERR_WOLFSSL_CTX_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x18) /*!< wolfSSL api returned failed */ -#define ESP_ERR_WOLFSSL_SSL_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x19) /*!< wolfSSL api returned failed */ -#define ESP_ERR_WOLFSSL_SSL_WRITE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x1A) /*!< wolfSSL api returned failed */ +#define ESP_ERR_ESP_TLS_CONNECTION_TIMEOUT (ESP_ERR_ESP_TLS_BASE + 0x06) /*!< new connection in esp_tls_low_level_conn connection timeouted */ +#define ESP_ERR_ESP_TLS_SE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x07) /*< esp-tls use Secure Element returned failed */ +#define ESP_ERR_ESP_TLS_TCP_CLOSED_FIN (ESP_ERR_ESP_TLS_BASE + 0x08) /*< esp-tls's TPC transport connection has benn closed (in a clean way) */ + +/* mbedtls specific error codes */ +#define ESP_ERR_MBEDTLS_CERT_PARTLY_OK (ESP_ERR_ESP_TLS_BASE + 0x10) /*!< mbedtls parse certificates was partly successful */ +#define ESP_ERR_MBEDTLS_CTR_DRBG_SEED_FAILED (ESP_ERR_ESP_TLS_BASE + 0x11) /*!< mbedtls api returned error */ +#define ESP_ERR_MBEDTLS_SSL_SET_HOSTNAME_FAILED (ESP_ERR_ESP_TLS_BASE + 0x12) /*!< mbedtls api returned error */ +#define ESP_ERR_MBEDTLS_SSL_CONFIG_DEFAULTS_FAILED (ESP_ERR_ESP_TLS_BASE + 0x13) /*!< mbedtls api returned error */ +#define ESP_ERR_MBEDTLS_SSL_CONF_ALPN_PROTOCOLS_FAILED (ESP_ERR_ESP_TLS_BASE + 0x14) /*!< mbedtls api returned error */ +#define ESP_ERR_MBEDTLS_X509_CRT_PARSE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x15) /*!< mbedtls api returned error */ +#define ESP_ERR_MBEDTLS_SSL_CONF_OWN_CERT_FAILED (ESP_ERR_ESP_TLS_BASE + 0x16) /*!< mbedtls api returned error */ +#define ESP_ERR_MBEDTLS_SSL_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x17) /*!< mbedtls api returned error */ +#define ESP_ERR_MBEDTLS_SSL_WRITE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x18) /*!< mbedtls api returned error */ +#define ESP_ERR_MBEDTLS_PK_PARSE_KEY_FAILED (ESP_ERR_ESP_TLS_BASE + 0x19) /*!< mbedtls api returned failed */ +#define ESP_ERR_MBEDTLS_SSL_HANDSHAKE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x1A) /*!< mbedtls api returned failed */ +#define ESP_ERR_MBEDTLS_SSL_CONF_PSK_FAILED (ESP_ERR_ESP_TLS_BASE + 0x1B) /*!< mbedtls api returned failed */ +#define ESP_ERR_MBEDTLS_SSL_TICKET_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x1C) /*!< mbedtls api returned failed */ + +/* wolfssl specific error codes */ +#define ESP_ERR_WOLFSSL_SSL_SET_HOSTNAME_FAILED (ESP_ERR_ESP_TLS_BASE + 0x31) /*!< wolfSSL api returned error */ +#define ESP_ERR_WOLFSSL_SSL_CONF_ALPN_PROTOCOLS_FAILED (ESP_ERR_ESP_TLS_BASE + 0x32) /*!< wolfSSL api returned error */ +#define ESP_ERR_WOLFSSL_CERT_VERIFY_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x33) /*!< wolfSSL api returned error */ +#define ESP_ERR_WOLFSSL_KEY_VERIFY_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x34) /*!< wolfSSL api returned error */ +#define ESP_ERR_WOLFSSL_SSL_HANDSHAKE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x35) /*!< wolfSSL api returned failed */ +#define ESP_ERR_WOLFSSL_CTX_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x36) /*!< wolfSSL api returned failed */ +#define ESP_ERR_WOLFSSL_SSL_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x37) /*!< wolfSSL api returned failed */ +#define ESP_ERR_WOLFSSL_SSL_WRITE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x38) /*!< wolfSSL api returned failed */ -#define ESP_ERR_ESP_TLS_SE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x1B) /*< esp-tls use Secure Element returned failed */ -#define ESP_ERR_ESP_TLS_TCP_CLOSED_FIN (ESP_ERR_ESP_TLS_BASE + 0x1C) /*< esp-tls's TPC transport connection has benn closed (in a clean way) */ /** * Definition of errors reported from IO API (potentially non-blocking) in case of error: diff --git a/tools/sdk/esp32c3/include/esp-tls/private_include/esp_tls_mbedtls.h b/tools/sdk/esp32c3/include/esp-tls/private_include/esp_tls_mbedtls.h index 78694fc858e..c1c5d4f3288 100644 --- a/tools/sdk/esp32c3/include/esp-tls/private_include/esp_tls_mbedtls.h +++ b/tools/sdk/esp32c3/include/esp-tls/private_include/esp_tls_mbedtls.h @@ -76,6 +76,22 @@ int esp_mbedtls_server_session_create(esp_tls_cfg_server_t *cfg, int sockfd, esp * /note :- The function can only be used with mbedtls ssl library */ void esp_mbedtls_server_session_delete(esp_tls_t *tls); + +#ifdef CONFIG_ESP_TLS_SERVER_SESSION_TICKETS +/** + * Internal function to setup server side session ticket context + * + * /note :- The function can only be used with mbedtls ssl library + */ +esp_err_t esp_mbedtls_server_session_ticket_ctx_init(esp_tls_server_session_ticket_ctx_t *cfg); + +/** + * Internal function to free server side session ticket context + * + * /note :- The function can only be used with mbedtls ssl library + */ +void esp_mbedtls_server_session_ticket_ctx_free(esp_tls_server_session_ticket_ctx_t *cfg); +#endif #endif /** @@ -83,6 +99,13 @@ void esp_mbedtls_server_session_delete(esp_tls_t *tls); */ esp_err_t set_client_config(const char *hostname, size_t hostlen, esp_tls_cfg_t *cfg, esp_tls_t *tls); +#ifdef CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS +/** + * Internal Callback for mbedtls_get_client_session + */ +esp_tls_client_session_t *esp_mbedtls_get_client_session(esp_tls_t *tls); +#endif + /** * Internal Callback for mbedtls_init_global_ca_store */ diff --git a/tools/sdk/esp32c3/include/esp_adc_cal/include/esp_adc_cal.h b/tools/sdk/esp32c3/include/esp_adc_cal/include/esp_adc_cal.h index 9adf28078de..171b2ed8501 100644 --- a/tools/sdk/esp32c3/include/esp_adc_cal/include/esp_adc_cal.h +++ b/tools/sdk/esp32c3/include/esp_adc_cal/include/esp_adc_cal.h @@ -30,6 +30,7 @@ typedef enum { ESP_ADC_CAL_VAL_EFUSE_VREF = 0, /**< Characterization based on reference voltage stored in eFuse*/ ESP_ADC_CAL_VAL_EFUSE_TP = 1, /**< Characterization based on Two Point values stored in eFuse*/ ESP_ADC_CAL_VAL_DEFAULT_VREF = 2, /**< Characterization based on default reference voltage*/ + ESP_ADC_CAL_VAL_EFUSE_TP_FIT = 3, /**< Characterization based on Two Point values and fitting curve coefficients stored in eFuse */ ESP_ADC_CAL_VAL_MAX, ESP_ADC_CAL_VAL_NOT_SUPPORTED = ESP_ADC_CAL_VAL_MAX, } esp_adc_cal_value_t; @@ -48,6 +49,7 @@ typedef struct { uint32_t vref; /**< Vref used by lookup table*/ const uint32_t *low_curve; /**< Pointer to low Vref curve of lookup table (NULL if unused)*/ const uint32_t *high_curve; /**< Pointer to high Vref curve of lookup table (NULL if unused)*/ + uint8_t version; /**< ADC Calibration */ } esp_adc_cal_characteristics_t; /** @@ -129,8 +131,8 @@ uint32_t esp_adc_cal_raw_to_voltage(uint32_t adc_reading, const esp_adc_cal_char * * @return * - ESP_OK: ADC read and converted to mV - * - ESP_ERR_TIMEOUT: Error, timed out attempting to read ADC * - ESP_ERR_INVALID_ARG: Error due to invalid arguments + * - ESP_ERR_INVALID_STATE: Reading result is invalid. Try to read again. */ esp_err_t esp_adc_cal_get_voltage(adc_channel_t channel, const esp_adc_cal_characteristics_t *chars, uint32_t *voltage); diff --git a/tools/sdk/esp32c3/include/esp_common/include/esp_attr.h b/tools/sdk/esp32c3/include/esp_common/include/esp_attr.h index 21e52bd67bc..7b73af76634 100644 --- a/tools/sdk/esp32c3/include/esp_common/include/esp_attr.h +++ b/tools/sdk/esp32c3/include/esp_common/include/esp_attr.h @@ -89,6 +89,14 @@ extern "C" { // Forces data into noinit section to avoid initialization after restart. #define __NOINIT_ATTR _SECTION_ATTR_IMPL(".noinit", __COUNTER__) +#if CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY +// Forces data into external memory noinit section to avoid initialization after restart. +#define EXT_RAM_NOINIT_ATTR _SECTION_ATTR_IMPL(".ext_ram_noinit", __COUNTER__) +#else +// Place in internal noinit section +#define EXT_RAM_NOINIT_ATTR __NOINIT_ATTR +#endif + // Forces data into RTC slow memory of .noinit section. // Any variable marked with this attribute will keep its value // after restart or during a deep sleep / wake cycle. @@ -155,4 +163,3 @@ FORCE_INLINE_ATTR TYPE& operator<<=(TYPE& a, int b) { a <<= b; return a; } } #endif #endif /* __ESP_ATTR_H__ */ - diff --git a/tools/sdk/esp32c3/include/esp_eth/include/esp_eth.h b/tools/sdk/esp32c3/include/esp_eth/include/esp_eth.h index d204b50898a..6aea512a692 100644 --- a/tools/sdk/esp32c3/include/esp_eth/include/esp_eth.h +++ b/tools/sdk/esp32c3/include/esp_eth/include/esp_eth.h @@ -265,12 +265,24 @@ esp_err_t esp_eth_receive(esp_eth_handle_t hdl, uint8_t *buf, uint32_t *length) * * @param[in] hdl: handle of Ethernet driver * @param[in] cmd: IO control command -* @param[in] data: specificed data for command +* @param[in, out] data: address of data for `set` command or address where to store the data when used with `get` command * * @return * - ESP_OK: process io command successfully * - ESP_ERR_INVALID_ARG: process io command failed because of some invalid argument * - ESP_FAIL: process io command failed because some other error occurred +* +* The following IO control commands are supported: +* @li @c ETH_CMD_S_MAC_ADDR sets Ethernet interface MAC address. @c data argument is pointer to MAC address buffer with expected size of 6 bytes. +* @li @c ETH_CMD_G_MAC_ADDR gets Ethernet interface MAC address. @c data argument is pointer to a buffer to which MAC address is to be copied. The buffer size must be at least 6 bytes. +* @li @c ETH_CMD_S_PHY_ADDR sets PHY address in range of <0-31>. @c data argument is pointer to memory of uint32_t datatype from where the configuration option is read. +* @li @c ETH_CMD_G_PHY_ADDR gets PHY address. @c data argument is pointer to memory of uint32_t datatype to which the PHY address is to be stored. +* @li @c ETH_CMD_G_SPEED gets current Ethernet link speed. @c data argument is pointer to memory of eth_speed_t datatype to which the speed is to be stored. +* @li @c ETH_CMD_S_PROMISCUOUS sets/resets Ethernet interface promiscuous mode. @c data argument is pointer to memory of bool datatype from which the configuration option is read. +* @li @c ETH_CMD_S_FLOW_CTRL sets/resets Ethernet interface flow control. @c data argument is pointer to memory of bool datatype from which the configuration option is read. +* @li @c ETH_CMD_G_DUPLEX_MODE gets current Ethernet link duplex mode. @c data argument is pointer to memory of eth_duplex_t datatype to which the duplex mode is to be stored. +* @li @c ETH_CMD_S_PHY_LOOPBACK sets/resets PHY to/from loopback mode. @c data argument is pointer to memory of bool datatype from which the configuration option is read. +* */ esp_err_t esp_eth_ioctl(esp_eth_handle_t hdl, esp_eth_io_cmd_t cmd, void *data); diff --git a/tools/sdk/esp32c3/include/esp_eth/include/esp_eth_com.h b/tools/sdk/esp32c3/include/esp_eth/include/esp_eth_com.h index 46409ed710a..7ce0538fbe8 100644 --- a/tools/sdk/esp32c3/include/esp_eth/include/esp_eth_com.h +++ b/tools/sdk/esp32c3/include/esp_eth/include/esp_eth_com.h @@ -89,6 +89,7 @@ typedef enum { ETH_CMD_S_PROMISCUOUS, /*!< Set promiscuous mode */ ETH_CMD_S_FLOW_CTRL, /*!< Set flow control */ ETH_CMD_G_DUPLEX_MODE, /*!< Get Duplex mode */ + ETH_CMD_S_PHY_LOOPBACK,/*!< Set PHY loopback */ } esp_eth_io_cmd_t; /** diff --git a/tools/sdk/esp32c3/include/esp_eth/include/esp_eth_mac.h b/tools/sdk/esp32c3/include/esp_eth/include/esp_eth_mac.h index f1e790c756d..db462728a18 100644 --- a/tools/sdk/esp32c3/include/esp_eth/include/esp_eth_mac.h +++ b/tools/sdk/esp32c3/include/esp_eth/include/esp_eth_mac.h @@ -391,7 +391,7 @@ typedef struct { #define ETH_MAC_DEFAULT_CONFIG() \ { \ .sw_reset_timeout_ms = 100, \ - .rx_task_stack_size = 4096, \ + .rx_task_stack_size = 2048, \ .rx_task_prio = 15, \ .smi_mdc_gpio_num = 23, \ .smi_mdio_gpio_num = 18, \ diff --git a/tools/sdk/esp32c3/include/esp_eth/include/esp_eth_netif_glue.h b/tools/sdk/esp32c3/include/esp_eth/include/esp_eth_netif_glue.h index 5e88b5ba5e1..d577fc00b7b 100644 --- a/tools/sdk/esp32c3/include/esp_eth/include/esp_eth_netif_glue.h +++ b/tools/sdk/esp32c3/include/esp_eth/include/esp_eth_netif_glue.h @@ -19,6 +19,12 @@ extern "C" { #endif +/** + * @brief Handle of netif glue - an intermediate layer between netif and Ethernet driver + * + */ +typedef struct esp_eth_netif_glue_t* esp_eth_netif_glue_handle_t; + /** * @brief Create a netif glue for Ethernet driver * @note netif glue is used to attach io driver to TCP/IP netif @@ -26,20 +32,23 @@ extern "C" { * @param eth_hdl Ethernet driver handle * @return glue object, which inherits esp_netif_driver_base_t */ -void *esp_eth_new_netif_glue(esp_eth_handle_t eth_hdl); +esp_eth_netif_glue_handle_t esp_eth_new_netif_glue(esp_eth_handle_t eth_hdl); /** * @brief Delete netif glue of Ethernet driver * - * @param glue netif glue + * @param eth_netif_glue netif glue * @return -ESP_OK: delete netif glue successfully */ -esp_err_t esp_eth_del_netif_glue(void *glue); +esp_err_t esp_eth_del_netif_glue(esp_eth_netif_glue_handle_t eth_netif_glue); /** * @brief Register default IP layer handlers for Ethernet * * @note: Ethernet handle might not yet properly initialized when setting up these default handlers + * @warning: This function is deprecated and is kept here only for compatibility reasons. Registration + * of default IP layer handlers for Ethernet is now handled automatically. Do not call this + * function if you want to use multiple Ethernet instances at a time. * * @param[in] esp_netif esp network interface handle created for Ethernet driver * @return @@ -47,12 +56,15 @@ esp_err_t esp_eth_del_netif_glue(void *glue); * - ESP_OK: set default IP layer handlers successfully * - others: other failure occurred during register esp_event handler */ - -esp_err_t esp_eth_set_default_handlers(void *esp_netif); +esp_err_t esp_eth_set_default_handlers(void *esp_netif) __attribute__ ((deprecated)); /** * @brief Unregister default IP layer handlers for Ethernet * + * @warning: This function is deprecated and is kept here only for compatibility reasons. Unregistration + * of default IP layer handlers for Ethernet is now handled automatically if not registered + * by calling esp_eth_set_default_handlers. + * * @param[in] esp_netif esp network interface handle created for Ethernet driver * @return * - ESP_ERR_INVALID_ARG: invalid parameter (esp_netif is NULL) diff --git a/tools/sdk/esp32c3/include/esp_eth/include/esp_eth_phy.h b/tools/sdk/esp32c3/include/esp_eth/include/esp_eth_phy.h index c9d32b367c0..f85b7d43043 100644 --- a/tools/sdk/esp32c3/include/esp_eth/include/esp_eth_phy.h +++ b/tools/sdk/esp32c3/include/esp_eth/include/esp_eth_phy.h @@ -1,4 +1,4 @@ -// Copyright 2019 Espressif Systems (Shanghai) PTE LTD +// Copyright 2019-2021 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. @@ -173,6 +173,19 @@ struct esp_eth_phy_s { */ esp_err_t (*advertise_pause_ability)(esp_eth_phy_t *phy, uint32_t ability); + /** + * @brief + * + * @param[in] phy: Ethernet PHY instance + * @param[in] enable: enables or disables PHY loopback + * + * @return + * - ESP_OK: configures PHY instance loopback function successfully + * - ESP_FAIL: PHY instance loopback configuration failed because some error occurred + * + */ + esp_err_t (*loopback)(esp_eth_phy_t *phy, bool enable); + /** * @brief Free memory of Ethernet PHY instance * @@ -231,16 +244,32 @@ esp_eth_phy_t *esp_eth_phy_new_ip101(const eth_phy_config_t *config); */ esp_eth_phy_t *esp_eth_phy_new_rtl8201(const eth_phy_config_t *config); +/** +* @brief Create a PHY instance of LAN87xx +* +* @param[in] config: configuration of PHY +* +* @return +* - instance: create PHY instance successfully +* - NULL: create PHY instance failed because some error occurred +*/ +esp_eth_phy_t *esp_eth_phy_new_lan87xx(const eth_phy_config_t *config); + /** * @brief Create a PHY instance of LAN8720 * +* @note For ESP-IDF backwards compatibility reasons. In all other cases, use esp_eth_phy_new_lan87xx instead. +* * @param[in] config: configuration of PHY * * @return * - instance: create PHY instance successfully * - NULL: create PHY instance failed because some error occurred */ -esp_eth_phy_t *esp_eth_phy_new_lan8720(const eth_phy_config_t *config); +static inline esp_eth_phy_t *esp_eth_phy_new_lan8720(const eth_phy_config_t *config) +{ + return esp_eth_phy_new_lan87xx(config); +} /** * @brief Create a PHY instance of DP83848 diff --git a/tools/sdk/esp32c3/include/esp_event/include/esp_event.h b/tools/sdk/esp32c3/include/esp_event/include/esp_event.h index 2d39422db57..2c069b0c684 100644 --- a/tools/sdk/esp32c3/include/esp_event/include/esp_event.h +++ b/tools/sdk/esp32c3/include/esp_event/include/esp_event.h @@ -23,7 +23,10 @@ #include "freertos/semphr.h" #include "esp_event_base.h" +// Legacy event loop not implemented on Linux target +#if !CONFIG_IDF_TARGET_LINUX #include "esp_event_legacy.h" +#endif #ifdef __cplusplus extern "C" { diff --git a/tools/sdk/esp32c3/include/esp_hid/include/esp_hid_common.h b/tools/sdk/esp32c3/include/esp_hid/include/esp_hid_common.h index 9fd7a2c6375..d7582cbc841 100644 --- a/tools/sdk/esp32c3/include/esp_hid/include/esp_hid_common.h +++ b/tools/sdk/esp32c3/include/esp_hid/include/esp_hid_common.h @@ -126,6 +126,21 @@ typedef enum { ESP_HID_COD_MIN_MAX } esp_hid_cod_min_t; +/* HID transaction Types */ +typedef enum { + ESP_HID_TRANS_HANDSHAKE = 0, + ESP_HID_TRANS_CONTROL = 1, + ESP_HID_TRANS_GET_REPORT = 4, + ESP_HID_TRANS_SET_REPORT = 5, + ESP_HID_TRANS_GET_PROTOCOL = 6, + ESP_HID_TRANS_SET_PROTOCOL = 7, + ESP_HID_TRANS_GET_IDLE = 8, + ESP_HID_TRANS_SET_IDLE = 9, + ESP_HID_TRANS_DATA = 10, + ESP_HID_TRANS_DATAC = 11, + ESP_HID_TRANS_MAX +} esp_hid_trans_type_t; + /** * @brief HID report item structure */ diff --git a/tools/sdk/esp32c3/include/esp_hid/include/esp_hidd.h b/tools/sdk/esp32c3/include/esp_hid/include/esp_hidd.h index ef596c6b2ba..3e1bfc2c06f 100644 --- a/tools/sdk/esp32c3/include/esp_hid/include/esp_hidd.h +++ b/tools/sdk/esp32c3/include/esp_hid/include/esp_hidd.h @@ -53,11 +53,28 @@ typedef struct esp_hidd_dev_s esp_hidd_dev_t; * @brief HIDD callback parameters union */ typedef union { + /** + * @brief ESP_HIDD_START_EVENT + * @note Used only for Classic Bluetooth. + */ + struct { + esp_err_t status; /*!< HID device operation status */ + } start; /*!< HID callback param of ESP_HIDD_START_EVENT */ + + /** + * @brief ESP_HIDD_STOP_EVENT + * @note Used only for Classic Bluetooth. + */ + struct { + esp_err_t status; /*!< HID device operation status */ + } stop; /*!< HID callback param of ESP_HIDD_STOP_EVENT */ + /** * @brief ESP_HIDD_CONNECT_EVENT */ struct { esp_hidd_dev_t *dev; /*!< HID device structure */ + esp_err_t status; /*!< HID device operation status, used only for Classic Bluetooth */ } connect; /*!< HID callback param of ESP_HIDD_CONNECT_EVENT */ /** @@ -66,6 +83,7 @@ typedef union { struct { esp_hidd_dev_t *dev; /*!< HID device structure */ int reason; /*!< Indicate the reason of disconnection */ + esp_err_t status; /*!< HID device operation status, used only for Classic Bluetooth */ } disconnect; /*!< HID callback param of ESP_HIDD_DISCONNECT_EVENT */ /** @@ -90,6 +108,8 @@ typedef union { uint16_t length; /*!< data length */ uint8_t *data; /*!< The pointer to the data */ uint8_t map_index; /*!< HID config report map index */ + uint8_t trans_type; /*!< HID device feature transaction type, used only for Classic Bluetooth */ + uint8_t report_type; /*!< HID device feature report type, used only for Classic Bluetooth */ } feature; /*!< HID callback param of ESP_HIDD_FEATURE_EVENT */ /** diff --git a/tools/sdk/esp32c3/include/esp_hid/include/esp_hidh.h b/tools/sdk/esp32c3/include/esp_hid/include/esp_hidh.h index d3d10021034..d49f76e6807 100644 --- a/tools/sdk/esp32c3/include/esp_hid/include/esp_hidh.h +++ b/tools/sdk/esp32c3/include/esp_hid/include/esp_hidh.h @@ -42,6 +42,8 @@ typedef enum { ESP_HIDH_INPUT_EVENT, /*!< Received HID device INPUT report */ ESP_HIDH_FEATURE_EVENT, /*!< Received HID device FEATURE report */ ESP_HIDH_CLOSE_EVENT, /*!< HID device closed */ + ESP_HIDH_START_EVENT, /*!< HID host stack started, used only for Classic Bluetooth */ + ESP_HIDH_STOP_EVENT, /*!< HID host stack stopped, used only for Classic Bluetooth */ ESP_HIDH_MAX_EVENT, /*!< HID events end marker */ } esp_hidh_event_t; @@ -49,11 +51,28 @@ typedef enum { * @brief HIDH callback parameters union */ typedef union { + /** + * @brief ESP_HIDH_START_EVENT + * @note Used only for Classic Bluetooth. + */ + struct { + esp_err_t status; /*!< HID host operation status */ + } start; /*!< HID callback param of ESP_HIDH_START_EVENT */ + + /** + * @brief ESP_HIDH_STOP_EVENT + * @note Used only for Classic Bluetooth. + */ + struct { + esp_err_t status; /*!< HID host operation status */ + } stop; /*!< HID callback param of ESP_HIDH_STOP_EVENT */ + /** * @brief ESP_HIDH_OPEN_EVENT */ struct { esp_hidh_dev_t *dev; /*!< HID Remote bluetooth device */ + esp_err_t status; /*!< HID host operation status, used only for Classic Bluetooth */ } open; /*!< HID callback param of ESP_HIDH_OPEN_EVENT */ /** @@ -62,6 +81,7 @@ typedef union { struct { esp_hidh_dev_t *dev; /*!< HID Remote bluetooth device. */ int reason; /*!< Reason why the connection was closed. BLE Only */ + esp_err_t status; /*!< HID host operation status, used only for Classic Bluetooth */ } close; /*!< HID callback param of ESP_HIDH_CLOSE_EVENT */ /** @@ -70,6 +90,7 @@ typedef union { struct { esp_hidh_dev_t *dev; /*!< HID Remote bluetooth device */ uint8_t level; /*!< Battery Level (0-100%) */ + esp_err_t status; /*!< HID host operation status */ } battery; /*!< HID callback param of ESP_HIDH_BATTERY_EVENT */ /** @@ -80,7 +101,7 @@ typedef union { esp_hid_usage_t usage; /*!< HID report usage */ uint16_t report_id; /*!< HID report index */ uint16_t length; /*!< HID data length */ - uint8_t *data; /*!< The pointer to the HID data */ + uint8_t *data; /*!< The pointer to the HID data */ uint8_t map_index; /*!< HID report map index */ } input; /*!< HID callback param of ESP_HIDH_INPUT_EVENT */ @@ -92,8 +113,10 @@ typedef union { esp_hid_usage_t usage; /*!< HID report usage */ uint16_t report_id; /*!< HID report index */ uint16_t length; /*!< HID data length */ - uint8_t *data; /*!< The pointer to the HID data */ + uint8_t *data; /*!< The pointer to the HID data */ uint8_t map_index; /*!< HID report map index */ + esp_err_t status; /*!< HID host operation status, used only for Classic Bluetooth */ + esp_hid_trans_type_t trans_type; /*!< HID host feature transaction type, used only for Classic Bluetooth */ } feature; /*!< HID callback param of ESP_HIDH_FEATURE_EVENT */ } esp_hidh_event_data_t; @@ -101,6 +124,7 @@ typedef union { typedef struct { esp_event_handler_t callback; uint16_t event_stack_size; + void *callback_arg; } esp_hidh_config_t; /** @@ -136,6 +160,14 @@ esp_err_t esp_hidh_dev_close(esp_hidh_dev_t *dev); */ esp_err_t esp_hidh_dev_free(esp_hidh_dev_t *dev); +/** + * @brief Check if the device still exists. + * @param dev : pointer to the device + * + * @return: true if exists + */ +bool esp_hidh_dev_exists(esp_hidh_dev_t *dev); + /** * @brief Send an OUTPUT report to the device * @param dev : pointer to the device @@ -173,6 +205,79 @@ esp_err_t esp_hidh_dev_feature_set(esp_hidh_dev_t *dev, size_t map_index, size_t */ esp_err_t esp_hidh_dev_feature_get(esp_hidh_dev_t *dev, size_t map_index, size_t report_id, size_t max_len, uint8_t *data, size_t *length); +/** + * @brief Set_Report command. + * @note For now, this function used only for Classic Bluetooth. + * + * @param dev : pointer to the device + * @param map_index : index of the device report map + * @param report_id : id of the HID FEATURE report + * @param report_type : report type, defines in `esp_hid_common.h` + * @param data : pointer to the data to send + * @param length : length of the data to send + * + * @return: ESP_OK on success + */ +esp_err_t esp_hidh_dev_set_report(esp_hidh_dev_t *dev, size_t map_index, size_t report_id, int report_type, + uint8_t *data, size_t length); + +/** + * @brief Get_Report command. + * @note For now, this function used only for Classic Bluetooth. + * + * @param dev : pointer to the device + * @param map_index : index of the device report map + * @param report_id : id of the HID FEATURE report + * @param report_type : report type, defines in `esp_hid_common.h` + * @param max_len : size of the buffer that will hold the data + * + * @return: ESP_OK on success + */ +esp_err_t esp_hidh_dev_get_report(esp_hidh_dev_t *dev, size_t map_index, size_t report_id, int report_type, + size_t max_len); + +/** + * @brief Get_Idle Command. + * @note For now, this function used only for Classic Bluetooth. + * + * @param dev : pointer to the device + * + * @return: ESP_OK on success + */ +esp_err_t esp_hidh_dev_get_idle(esp_hidh_dev_t *dev); + +/** + * @brief Set_Idle Command. + * @note For now, this function used only for Classic Bluetooth. + * + * @param dev : pointer to the device + * @param idle_time : idle_time + * + * @return: ESP_OK on success + */ +esp_err_t esp_hidh_dev_set_idle(esp_hidh_dev_t *dev, uint8_t idle_time); + +/** + * @brief Get_Protocol Command. + * @note For now, this function used only for Classic Bluetooth. + * + * @param dev : pointer to the device + * + * @return: ESP_OK on success + */ +esp_err_t esp_hidh_dev_get_protocol(esp_hidh_dev_t *dev); + +/** + * @brief Set_Protocol Command. + * @note For now, this function used only for Classic Bluetooth. + * + * @param dev : pointer to the device + * @param protocol_mode : protocol_mode + * + * @return: ESP_OK on success + */ +esp_err_t esp_hidh_dev_set_protocol(esp_hidh_dev_t *dev, uint8_t protocol_mode); + /** * @brief Dump the properties of HID Device to UART * @param dev : pointer to the HID Device diff --git a/tools/sdk/esp32c3/include/esp_http_client/include/esp_http_client.h b/tools/sdk/esp32c3/include/esp_http_client/include/esp_http_client.h index ab7e3c2e328..820c4168f66 100644 --- a/tools/sdk/esp32c3/include/esp_http_client/include/esp_http_client.h +++ b/tools/sdk/esp32c3/include/esp_http_client/include/esp_http_client.h @@ -113,6 +113,8 @@ typedef struct { size_t client_cert_len; /*!< Length of the buffer pointed to by client_cert_pem. May be 0 for null-terminated pem */ const char *client_key_pem; /*!< SSL client key, PEM format as string, if the server requires to verify client */ size_t client_key_len; /*!< Length of the buffer pointed to by client_key_pem. May be 0 for null-terminated pem */ + const char *client_key_password; /*!< Client key decryption password string */ + size_t client_key_password_len; /*!< String length of the password pointed to by client_key_password */ const char *user_agent; /*!< The User Agent string to send with HTTP requests */ esp_http_client_method_t method; /*!< HTTP Method */ int timeout_ms; /*!< Network timeout in milliseconds */ diff --git a/tools/sdk/esp32c3/include/esp_http_server/include/esp_http_server.h b/tools/sdk/esp32c3/include/esp_http_server/include/esp_http_server.h index d14a943c108..1c8b78583ff 100644 --- a/tools/sdk/esp32c3/include/esp_http_server/include/esp_http_server.h +++ b/tools/sdk/esp32c3/include/esp_http_server/include/esp_http_server.h @@ -941,6 +941,24 @@ esp_err_t httpd_req_get_url_query_str(httpd_req_t *r, char *buf, size_t buf_len) */ esp_err_t httpd_query_key_value(const char *qry, const char *key, char *val, size_t val_size); +/** + * @brief Get the value string of a cookie value from the "Cookie" request headers by cookie name. + * + * @param[in] req Pointer to the HTTP request + * @param[in] cookie_name The cookie name to be searched in the request + * @param[out] val Pointer to the buffer into which the value of cookie will be copied if the cookie is found + * @param[inout] val_size Pointer to size of the user buffer "val". This variable will contain cookie length if + * ESP_OK is returned and required buffer length incase ESP_ERR_HTTPD_RESULT_TRUNC is returned. + * + * @return + * - ESP_OK : Key is found in the cookie string and copied to buffer + * - ESP_ERR_NOT_FOUND : Key not found + * - ESP_ERR_INVALID_ARG : Null arguments + * - ESP_ERR_HTTPD_RESULT_TRUNC : Value string truncated + * - ESP_ERR_NO_MEM : Memory allocation failure + */ +esp_err_t httpd_req_get_cookie_val(httpd_req_t *req, const char *cookie_name, char *val, size_t *val_size); + /** * @brief Test if a URI matches the given wildcard template. * @@ -1585,6 +1603,11 @@ typedef struct httpd_ws_frame { size_t len; /*!< Length of the WebSocket data */ } httpd_ws_frame_t; +/** + * @brief Transfer complete callback + */ +typedef void (*transfer_complete_cb)(esp_err_t err, int socket, void *arg); + /** * @brief Receive and parse a WebSocket frame * @@ -1645,6 +1668,35 @@ esp_err_t httpd_ws_send_frame_async(httpd_handle_t hd, int fd, httpd_ws_frame_t */ httpd_ws_client_info_t httpd_ws_get_fd_info(httpd_handle_t hd, int fd); +/** + * @brief Sends data to to specified websocket synchronously + * + * @param[in] handle Server instance data + * @param[in] socket Socket descriptor + * @param[in] frame Websocket frame + * @return + * - ESP_OK : On successful + * - ESP_FAIL : When socket errors occurs + * - ESP_ERR_NO_MEM : Unable to allocate memory + */ +esp_err_t httpd_ws_send_data(httpd_handle_t handle, int socket, httpd_ws_frame_t *frame); + +/** + * @brief Sends data to to specified websocket asynchronously + * + * @param[in] handle Server instance data + * @param[in] socket Socket descriptor + * @param[in] frame Websocket frame + * @param[in] callback Callback invoked after sending data + * @param[in] arg User data passed to provided callback + * @return + * - ESP_OK : On successful + * - ESP_FAIL : When socket errors occurs + * - ESP_ERR_NO_MEM : Unable to allocate memory + */ +esp_err_t httpd_ws_send_data_async(httpd_handle_t handle, int socket, httpd_ws_frame_t *frame, + transfer_complete_cb callback, void *arg); + #endif /* CONFIG_HTTPD_WS_SUPPORT */ /** End of WebSocket related stuff * @} diff --git a/tools/sdk/esp32c3/include/esp_https_server/include/esp_https_server.h b/tools/sdk/esp32c3/include/esp_https_server/include/esp_https_server.h index 52f9dc2132a..00565a963ad 100644 --- a/tools/sdk/esp32c3/include/esp_https_server/include/esp_https_server.h +++ b/tools/sdk/esp32c3/include/esp_https_server/include/esp_https_server.h @@ -63,6 +63,9 @@ struct httpd_ssl_config { /** Port used when transport mode is insecure (default 80) */ uint16_t port_insecure; + + /** Enable tls session tickets */ + bool session_tickets; }; typedef struct httpd_ssl_config httpd_ssl_config_t; @@ -109,6 +112,7 @@ typedef struct httpd_ssl_config httpd_ssl_config_t; .transport_mode = HTTPD_SSL_TRANSPORT_SECURE, \ .port_secure = 443, \ .port_insecure = 80, \ + .session_tickets = false, \ } /** diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/esp_async_memcpy.h b/tools/sdk/esp32c3/include/esp_hw_support/include/esp_async_memcpy.h index e95f9638e76..c45c61b2d15 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/esp_async_memcpy.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/esp_async_memcpy.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/esp_chip_info.h b/tools/sdk/esp32c3/include/esp_hw_support/include/esp_chip_info.h index d04dcaf4245..69d23c08d36 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/esp_chip_info.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/esp_chip_info.h @@ -1,16 +1,8 @@ -// Copyright 2021 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. +/* + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once @@ -30,7 +22,7 @@ extern "C" { typedef enum { CHIP_ESP32 = 1, //!< ESP32 CHIP_ESP32S2 = 2, //!< ESP32-S2 - CHIP_ESP32S3 = 4, //!< ESP32-S3 + CHIP_ESP32S3 = 9, //!< ESP32-S3 CHIP_ESP32C3 = 5, //!< ESP32-C3 CHIP_ESP32H2 = 6, //!< ESP32-H2 } esp_chip_model_t; diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/esp_cpu.h b/tools/sdk/esp32c3/include/esp_hw_support/include/esp_cpu.h index e1536e979b8..2a810aba440 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/esp_cpu.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/esp_cpu.h @@ -1,16 +1,8 @@ -// Copyright 2010-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. +/* + * SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_CPU_H #define _ESP_CPU_H diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/esp_crc.h b/tools/sdk/esp32c3/include/esp_hw_support/include/esp_crc.h index 6294a7b6218..f12dcf767dd 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/esp_crc.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/esp_crc.h @@ -1,16 +1,8 @@ -// Copyright 2015-2019 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #ifdef __cplusplus diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/esp_fault.h b/tools/sdk/esp32c3/include/esp_hw_support/include/esp_fault.h index fe9de334259..910ba59d06c 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/esp_fault.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/esp_fault.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include "sdkconfig.h" #include "soc/rtc_cntl_reg.h" #include "esp_rom_sys.h" diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/esp_interface.h b/tools/sdk/esp32c3/include/esp_hw_support/include/esp_interface.h index 950c05bb22c..fdb4c0056ce 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/esp_interface.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/esp_interface.h @@ -1,16 +1,8 @@ -// 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef __ESP_INTERFACE_H__ diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/esp_intr.h b/tools/sdk/esp32c3/include/esp_hw_support/include/esp_intr.h index c29dc9bfd1a..0818ed3feab 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/esp_intr.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/esp_intr.h @@ -1,16 +1,8 @@ -// Copyright 2010-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. +/* + * SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #warning esp_intr.h is deprecated, please include esp_intr_alloc.h instead diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/esp_intr_alloc.h b/tools/sdk/esp32c3/include/esp_hw_support/include/esp_intr_alloc.h index 33f70b95970..a26fde9394f 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/esp_intr_alloc.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/esp_intr_alloc.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/esp_mac.h b/tools/sdk/esp32c3/include/esp_hw_support/include/esp_mac.h index 75e01ebbd16..f0efddfc2f7 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/esp_mac.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/esp_mac.h @@ -1,16 +1,8 @@ -// Copyright 2021 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. +/* + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once @@ -79,6 +71,7 @@ esp_err_t esp_base_mac_addr_set(const uint8_t *mac); * 8 bytes for EUI-64(used for IEEE 802.15.4) * * @return ESP_OK on success + * ESP_ERR_INVALID_ARG mac is NULL * ESP_ERR_INVALID_MAC base MAC address has not been set */ esp_err_t esp_base_mac_addr_get(uint8_t *mac); @@ -100,8 +93,10 @@ esp_err_t esp_base_mac_addr_get(uint8_t *mac); * 8 bytes for EUI-64(used for IEEE 802.15.4) * * @return ESP_OK on success - * ESP_ERR_INVALID_VERSION An invalid MAC version field was read from BLK3 of EFUSE - * ESP_ERR_INVALID_CRC An invalid MAC CRC was read from BLK3 of EFUSE + * ESP_ERR_INVALID_ARG mac is NULL + * ESP_ERR_INVALID_MAC CUSTOM_MAC address has not been set, all zeros (for esp32-xx) + * ESP_ERR_INVALID_VERSION An invalid MAC version field was read from BLK3 of EFUSE (for esp32) + * ESP_ERR_INVALID_CRC An invalid MAC CRC was read from BLK3 of EFUSE (for esp32) */ esp_err_t esp_efuse_mac_get_custom(uint8_t *mac); @@ -113,6 +108,7 @@ esp_err_t esp_efuse_mac_get_custom(uint8_t *mac); * 8 bytes for EUI-64(used for IEEE 802.15.4) * * @return ESP_OK on success + * ESP_ERR_INVALID_ARG mac is NULL */ esp_err_t esp_efuse_mac_get_default(uint8_t *mac); diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/esp_private/esp_clk.h b/tools/sdk/esp32c3/include/esp_hw_support/include/esp_private/esp_clk.h index 14326898bd7..5a4666fdddf 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/esp_private/esp_clk.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/esp_private/esp_clk.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/esp_private/sleep_gpio.h b/tools/sdk/esp32c3/include/esp_hw_support/include/esp_private/sleep_gpio.h new file mode 100644 index 00000000000..abab21871a4 --- /dev/null +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/esp_private/sleep_gpio.h @@ -0,0 +1,46 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once +#include +#include "sdkconfig.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file sleep_gpio.h + * + * This file contains declarations of GPIO related functions in light sleep mode. + */ + +#if SOC_GPIO_SUPPORT_SLP_SWITCH && CONFIG_GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL + +/** + * @brief Save GPIO pull-up and pull-down configuration information in the wake-up state + * + * In light sleep mode, the pull-up and pull-down resistors of GPIO will cause + * leakage current when the system sleeps. In order to reduce the power + * consumption of system sleep, it needs to save the configuration information + * of all GPIO pull-up and pull-down resistors and disable the pull-up and + * pull-down resistors of GPIO before the system enters sleep. + */ +void gpio_sleep_mode_config_apply(void); + +/** + * @brief Restore GPIO pull-up and pull-down configuration information in the wake-up state + * + * In light sleep mode, after the system wakes up, it needs to restore all GPIO + * pull-up and pull-down configurations before the last sleep. + */ +void gpio_sleep_mode_config_unapply(void); + +#endif // SOC_GPIO_SUPPORT_SLP_SWITCH && CONFIG_GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/esp_private/sleep_mac_bb.h b/tools/sdk/esp32c3/include/esp_hw_support/include/esp_private/sleep_mac_bb.h new file mode 100644 index 00000000000..6b4019639d8 --- /dev/null +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/esp_private/sleep_mac_bb.h @@ -0,0 +1,43 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once +#include +#include "sdkconfig.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file sleep_mac_bb.h + * + * This file contains declarations of MAC and baseband power consumption related functions in light sleep mode. + */ + +#if CONFIG_MAC_BB_PD + +/** + * @brief A callback function completes MAC and baseband power down operation + * + * In light sleep mode, execute Wi-Fi and Bluetooth module MAC and baseband + * power down and backup register configuration information operations. + */ +void mac_bb_power_down_cb_execute(void); + +/** + * @brief A callback function completes MAC and baseband power up operation + * + * In light sleep mode, execute Wi-Fi and Bluetooth module MAC and baseband + * power up and restore register configuration information operations. + */ +void mac_bb_power_up_cb_execute(void); + +#endif // CONFIG_MAC_BB_PD + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/esp_private/sleep_retention.h b/tools/sdk/esp32c3/include/esp_hw_support/include/esp_private/sleep_retention.h new file mode 100644 index 00000000000..001e559c0c7 --- /dev/null +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/esp_private/sleep_retention.h @@ -0,0 +1,55 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once +#include +#include "sdkconfig.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file sleep_retention.h + * + * This file contains declarations of memory retention related functions in light sleeo mode. + */ + +#if SOC_PM_SUPPORT_CPU_PD + +/** + * @brief Whether to allow the cpu power domain to be powered off. + * + * In light sleep mode, only when the system can provide enough memory + * for cpu retention, the cpu power domain can be powered off. + */ +bool cpu_domain_pd_allowed(void); + +#endif + +#if SOC_PM_SUPPORT_CPU_PD || SOC_PM_SUPPORT_TAGMEM_PD + +/** + * @brief Enable memory retention of some modules. + * + * In light sleep mode, before the system goes to sleep, enable the memory + * retention of modules such as CPU and I/D-cache tag memory. + */ +void sleep_enable_memory_retention(void); + +/** + * @brief Disable memory retention of some modules. + * + * In light sleep mode, after the system exits sleep, disable the memory + * retention of moudles such as CPU and I/D-cache tag memory. + */ +void sleep_disable_memory_retention(void); + +#endif // SOC_PM_SUPPORT_CPU_PD || SOC_PM_SUPPORT_TAGMEM_PD + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/esp_random.h b/tools/sdk/esp32c3/include/esp_hw_support/include/esp_random.h index cf4f408b513..a6b8a884b69 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/esp_random.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/esp_random.h @@ -1,16 +1,8 @@ -// Copyright 2021 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. +/* + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/esp_sleep.h b/tools/sdk/esp32c3/include/esp_hw_support/include/esp_sleep.h index 000d020aebb..cfdfbc04186 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/esp_sleep.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/esp_sleep.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once @@ -49,7 +41,9 @@ typedef enum { ESP_PD_DOMAIN_RTC_SLOW_MEM, //!< RTC slow memory ESP_PD_DOMAIN_RTC_FAST_MEM, //!< RTC fast memory ESP_PD_DOMAIN_XTAL, //!< XTAL oscillator +#if SOC_PM_SUPPORT_CPU_PD ESP_PD_DOMAIN_CPU, //!< CPU core +#endif ESP_PD_DOMAIN_VDDSDIO, //!< VDD_SDIO ESP_PD_DOMAIN_MAX //!< Number of domains } esp_sleep_pd_domain_t; @@ -380,6 +374,8 @@ esp_err_t esp_light_sleep_start(void); * * This function does not return. * + * @note The device will wake up immediately if the deep-sleep time is set to 0 + * * @param time_in_us deep-sleep time, unit: microsecond */ void esp_deep_sleep(uint64_t time_in_us) __attribute__((noreturn)); diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/clk_ctrl_os.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/clk_ctrl_os.h index f4d769b8014..b5eff46930c 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/clk_ctrl_os.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/clk_ctrl_os.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include "soc/rtc.h" diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/compare_set.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/compare_set.h index ddbaeb7e3d6..b5a35fa701a 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/compare_set.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/compare_set.h @@ -1,16 +1,8 @@ -// Copyright 2015-2019 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/cpu.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/cpu.h index 0e4d1688ca3..526171bc1ce 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/cpu.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/cpu.h @@ -1,16 +1,8 @@ -// Copyright 2010-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. +/* + * SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _SOC_CPU_H #define _SOC_CPU_H diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32/clk.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32/clk.h index 31902ebad01..a9ed3028527 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32/clk.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32/clk.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include "esp_private/esp_clk.h" diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32/dport_access.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32/dport_access.h index 4f473940ad4..8e04674951a 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32/dport_access.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32/dport_access.h @@ -3,30 +3,28 @@ * * SPDX-License-Identifier: Apache-2.0 */ -#include - -#include -#ifndef _ESP_DPORT_ACCESS_H_ -#define _ESP_DPORT_ACCESS_H_ +#pragma once +#include +#include #include "xtensa/xtruntime.h" #ifdef __cplusplus extern "C" { #endif -void esp_dport_access_stall_other_cpu_start(void); -void esp_dport_access_stall_other_cpu_end(void); -void esp_dport_access_int_init(void); -void esp_dport_access_int_pause(void); -void esp_dport_access_int_resume(void); +void esp_dport_access_stall_other_cpu_start(void) __attribute__ ((deprecated)); +void esp_dport_access_stall_other_cpu_end(void) __attribute__ ((deprecated)); +void esp_dport_access_int_init(void) __attribute__ ((deprecated)); +void esp_dport_access_int_pause(void) __attribute__ ((deprecated)); +void esp_dport_access_int_resume(void) __attribute__ ((deprecated)); void esp_dport_access_read_buffer(uint32_t *buff_out, uint32_t address, uint32_t num_words); uint32_t esp_dport_access_reg_read(uint32_t reg); uint32_t esp_dport_access_sequence_reg_read(uint32_t reg); //This routine does not stop the dport routines in any way that is recoverable. Please //only call in case of panic(). -void esp_dport_access_int_abort(void); +void esp_dport_access_int_abort(void) __attribute__ ((deprecated)); #if defined(BOOTLOADER_BUILD) || !defined(CONFIG_ESP32_DPORT_WORKAROUND) || !defined(ESP_PLATFORM) #define DPORT_STALL_OTHER_CPU_START() @@ -34,8 +32,9 @@ void esp_dport_access_int_abort(void); #define DPORT_INTERRUPT_DISABLE() #define DPORT_INTERRUPT_RESTORE() #else -#define DPORT_STALL_OTHER_CPU_START() esp_dport_access_stall_other_cpu_start() -#define DPORT_STALL_OTHER_CPU_END() esp_dport_access_stall_other_cpu_end() +#include "esp_ipc_isr.h" +#define DPORT_STALL_OTHER_CPU_START() esp_ipc_isr_stall_other_cpu() +#define DPORT_STALL_OTHER_CPU_END() esp_ipc_isr_release_other_cpu() #define DPORT_INTERRUPT_DISABLE() unsigned int intLvl = XTOS_SET_INTLEVEL(CONFIG_ESP32_DPORT_DIS_INTERRUPT_LVL) #define DPORT_INTERRUPT_RESTORE() XTOS_RESTORE_JUST_INTLEVEL(intLvl) #endif @@ -43,5 +42,3 @@ void esp_dport_access_int_abort(void); #ifdef __cplusplus } #endif - -#endif /* _ESP_DPORT_ACCESS_H_ */ diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32/spiram.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32/spiram.h index e58712d1fa6..a6086f3d311 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32/spiram.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32/spiram.h @@ -85,6 +85,15 @@ size_t esp_spiram_get_size(void); */ void esp_spiram_writeback_cache(void); +/** + * @brief get psram CS IO + * + * This interface should be called after PSRAM is enabled, otherwise it will + * return an invalid value -1/0xff. + * + * @return psram CS IO or -1/0xff if psram not enabled + */ +uint8_t esp_spiram_get_cs_io(void); /** diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32c3/clk.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32c3/clk.h index 31902ebad01..a9ed3028527 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32c3/clk.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32c3/clk.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include "esp_private/esp_clk.h" diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32c3/dport_access.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32c3/dport_access.h index f3f7007a9cb..e5aedd2e1b1 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32c3/dport_access.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32c3/dport_access.h @@ -1,16 +1,8 @@ -// Copyright 2010-2020 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. +/* + * SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_DPORT_ACCESS_H_ #define _ESP_DPORT_ACCESS_H_ diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32c3/esp_crypto_lock.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32c3/esp_crypto_lock.h index 3149d34692b..67a08741b51 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32c3/esp_crypto_lock.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32c3/esp_crypto_lock.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32c3/esp_ds.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32c3/esp_ds.h index 911e44c8379..9d59aa71c6f 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32c3/esp_ds.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32c3/esp_ds.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32c3/esp_hmac.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32c3/esp_hmac.h index 391ba12fe15..26e2bc71a05 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32c3/esp_hmac.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32c3/esp_hmac.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_HMAC_H_ #define _ESP_HMAC_H_ @@ -60,6 +52,35 @@ esp_err_t esp_hmac_calculate(hmac_key_id_t key_id, size_t message_len, uint8_t *hmac); +/** + * @brief Use HMAC peripheral in Downstream mode to re-enable the JTAG, if it is not permanently disabled by HW. + * In downstream mode, HMAC calculations performed by peripheral are used internally and not provided back to user. + * + * @param key_id Determines which of the 6 key blocks in the efuses should be used for the HMAC calculation. + * The corresponding purpose field of the key block in the efuse must be set to HMAC downstream purpose. + * + * @param token Pre calculated HMAC value of the 32-byte 0x00 using SHA-256 and the known private HMAC key. The key is already + * programmed to a eFuse key block. The key block number is provided as the first parameter to this function. + * + * @return + * * ESP_OK, if the calculation was successful, + * if the calculated HMAC value matches with provided token, + * JTAG will be re-enable otherwise JTAG will remain disabled. + * Return value does not indicate the JTAG status. + * * ESP_FAIL, if the hmac calculation failed or JTAG is permanently disabled by EFUSE_HARD_DIS_JTAG eFuse parameter. + * * ESP_ERR_INVALID_ARG, invalid input arguments + */ +esp_err_t esp_hmac_jtag_enable(hmac_key_id_t key_id, const uint8_t *token); + +/** + * @brief Disable the JTAG which might be enabled using the HMAC downstream mode. This function just clears the result generated + * by calling esp_hmac_jtag_enable() API. + * + * @return + * * ESP_OK return ESP_OK after writing the HMAC_SET_INVALIDATE_JTAG_REG with value 1. + */ +esp_err_t esp_hmac_jtag_disable(void); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32c3/memprot.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32c3/memprot.h index 0d7e6ca40df..818cd677dc8 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32c3/memprot.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32c3/memprot.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /* INTERNAL API diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32c3/rtc.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32c3/rtc.h index b090ae5cfbe..4d46831ded3 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32c3/rtc.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32c3/rtc.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32h2/clk.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32h2/clk.h index 31902ebad01..a9ed3028527 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32h2/clk.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32h2/clk.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include "esp_private/esp_clk.h" diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32h2/dport_access.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32h2/dport_access.h index f3f7007a9cb..e5aedd2e1b1 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32h2/dport_access.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32h2/dport_access.h @@ -1,16 +1,8 @@ -// Copyright 2010-2020 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. +/* + * SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_DPORT_ACCESS_H_ #define _ESP_DPORT_ACCESS_H_ diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32h2/esp_crypto_lock.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32h2/esp_crypto_lock.h index 3149d34692b..67a08741b51 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32h2/esp_crypto_lock.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32h2/esp_crypto_lock.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32h2/esp_ds.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32h2/esp_ds.h index 79e963fc6bd..6bad7075587 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32h2/esp_ds.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32h2/esp_ds.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32h2/esp_hmac.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32h2/esp_hmac.h index 391ba12fe15..26e2bc71a05 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32h2/esp_hmac.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32h2/esp_hmac.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_HMAC_H_ #define _ESP_HMAC_H_ @@ -60,6 +52,35 @@ esp_err_t esp_hmac_calculate(hmac_key_id_t key_id, size_t message_len, uint8_t *hmac); +/** + * @brief Use HMAC peripheral in Downstream mode to re-enable the JTAG, if it is not permanently disabled by HW. + * In downstream mode, HMAC calculations performed by peripheral are used internally and not provided back to user. + * + * @param key_id Determines which of the 6 key blocks in the efuses should be used for the HMAC calculation. + * The corresponding purpose field of the key block in the efuse must be set to HMAC downstream purpose. + * + * @param token Pre calculated HMAC value of the 32-byte 0x00 using SHA-256 and the known private HMAC key. The key is already + * programmed to a eFuse key block. The key block number is provided as the first parameter to this function. + * + * @return + * * ESP_OK, if the calculation was successful, + * if the calculated HMAC value matches with provided token, + * JTAG will be re-enable otherwise JTAG will remain disabled. + * Return value does not indicate the JTAG status. + * * ESP_FAIL, if the hmac calculation failed or JTAG is permanently disabled by EFUSE_HARD_DIS_JTAG eFuse parameter. + * * ESP_ERR_INVALID_ARG, invalid input arguments + */ +esp_err_t esp_hmac_jtag_enable(hmac_key_id_t key_id, const uint8_t *token); + +/** + * @brief Disable the JTAG which might be enabled using the HMAC downstream mode. This function just clears the result generated + * by calling esp_hmac_jtag_enable() API. + * + * @return + * * ESP_OK return ESP_OK after writing the HMAC_SET_INVALIDATE_JTAG_REG with value 1. + */ +esp_err_t esp_hmac_jtag_disable(void); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32h2/memprot.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32h2/memprot.h index 2567b604b00..75228580ffd 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32h2/memprot.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32h2/memprot.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /* INTERNAL API diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32h2/rtc.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32h2/rtc.h index cca748df919..75460416c7d 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32h2/rtc.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32h2/rtc.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/clk.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/clk.h index 31902ebad01..a9ed3028527 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/clk.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/clk.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include "esp_private/esp_clk.h" diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/dport_access.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/dport_access.h index 6ba6fd65556..e5aedd2e1b1 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/dport_access.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/dport_access.h @@ -1,16 +1,8 @@ -// Copyright 2010-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. +/* + * SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_DPORT_ACCESS_H_ #define _ESP_DPORT_ACCESS_H_ diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/esp_crypto_lock.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/esp_crypto_lock.h index e1df0399f30..2c337c93714 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/esp_crypto_lock.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/esp_crypto_lock.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/esp_ds.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/esp_ds.h index 12906377ee5..2ef0bd00fbe 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/esp_ds.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/esp_ds.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/esp_hmac.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/esp_hmac.h index 5fa836c47d8..409217c06bc 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/esp_hmac.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/esp_hmac.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_HMAC_H_ #define _ESP_HMAC_H_ diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/memprot.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/memprot.h index c63fb395e6d..0ebd6474578 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/memprot.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/memprot.h @@ -1,17 +1,8 @@ -// Copyright 2020 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. - +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /* INTERNAL API * generic interface to MMU memory protection features @@ -21,6 +12,7 @@ #include #include #include "esp_attr.h" +#include "esp_err.h" #ifdef __cplusplus extern "C" { @@ -51,6 +43,8 @@ extern "C" { #define MEMPROT_UNLOCK false #define DEF_SPLIT_LINE NULL +#define MEMPROT_INVALID_ADDRESS -1 + //memory range types typedef enum { MEMPROT_NONE = 0x00000000, @@ -77,23 +71,27 @@ typedef enum { uint32_t *IRAM_ATTR esp_memprot_get_split_addr(mem_type_prot_t mem_type); /** - * @brief Initializes illegal memory access control (MMU) for required memory section. + * @brief Initializes illegal memory access control for required memory section. * * All memory access interrupts share ETS_MEMACCESS_ERR_INUM input channel, it is caller's * responsibility to properly detect actual intr. source as well as possible prioritization in case * of multiple source reported during one intr.handling routine run * - * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @param mem_type Memory protection area type (see mem_type_prot_t enum)\ + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_intr_init(mem_type_prot_t mem_type); +esp_err_t esp_memprot_intr_init(mem_type_prot_t mem_type); /** * @brief Enable/disable the memory protection interrupt * * @param mem_type Memory protection area type (see mem_type_prot_t enum) * @param enable enable/disable + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_intr_ena(mem_type_prot_t mem_type, bool enable); +esp_err_t esp_memprot_intr_ena(mem_type_prot_t mem_type, bool enable); /** * @brief Sets a request for clearing interrupt-on flag for specified memory region (register write) @@ -102,8 +100,10 @@ void esp_memprot_intr_ena(mem_type_prot_t mem_type, bool enable); * Should be used only after the real interrupt appears, typically as the last step in interrupt handler's routine. * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_clear_intr(mem_type_prot_t mem_type); +esp_err_t esp_memprot_clear_intr(mem_type_prot_t mem_type); /** * @brief Detects which memory protection interrupt is active @@ -122,10 +122,11 @@ mem_type_prot_t IRAM_ATTR esp_memprot_get_active_intr_memtype(void); * @brief Gets interrupt status register contents for specified memory region * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @param fault_reg_val Contents of status register * - * @return Contents of status register + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -uint32_t esp_memprot_get_fault_reg(mem_type_prot_t mem_type); +esp_err_t esp_memprot_get_fault_reg(mem_type_prot_t mem_type, uint32_t *fault_reg_val); /** * @brief Get details of given interrupt status @@ -138,8 +139,9 @@ uint32_t esp_memprot_get_fault_reg(mem_type_prot_t mem_type); * @param op_subtype Additional info for op_type [out] * IRAM0: 0 - instruction segment access, 1 - data segment access * DRAM0: 0 - non-atomic operation, 1 - atomic operation + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void IRAM_ATTR esp_memprot_get_fault_status(mem_type_prot_t mem_type, uint32_t **faulting_address, uint32_t *op_type, uint32_t *op_subtype); +esp_err_t IRAM_ATTR esp_memprot_get_fault_status(mem_type_prot_t mem_type, uint32_t **faulting_address, uint32_t *op_type, uint32_t *op_subtype); /** * @brief Gets string representation of required memory region identifier @@ -163,26 +165,30 @@ bool esp_memprot_is_locked_any(void); * Locks can be unlocked only by digital system reset * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_set_lock(mem_type_prot_t mem_type); +esp_err_t esp_memprot_set_lock(mem_type_prot_t mem_type); /** * @brief Gets lock status for required memory region * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @param locked Settings locked: true/false (locked/unlocked) * - * @return true/false (locked/unlocked) + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -bool esp_memprot_get_lock(mem_type_prot_t mem_type); +esp_err_t esp_memprot_get_lock(mem_type_prot_t mem_type, bool *locked); /** * @brief Gets permission control configuration register contents for required memory region * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @param conf_reg_val Permission control register contents * - * @return Permission control register contents + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -uint32_t esp_memprot_get_conf_reg(mem_type_prot_t mem_type); +esp_err_t esp_memprot_get_conf_reg(mem_type_prot_t mem_type, uint32_t *conf_reg_val); /** * @brief Gets interrupt permission settings for unified management block @@ -190,21 +196,23 @@ uint32_t esp_memprot_get_conf_reg(mem_type_prot_t mem_type); * Gets interrupt permission settings register contents for required memory region, returns settings for unified management blocks * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @param perm_reg Permission settings register contents * - * @return Permission settings register contents + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -uint32_t esp_memprot_get_perm_uni_reg(mem_type_prot_t mem_type); +esp_err_t esp_memprot_get_perm_uni_reg(mem_type_prot_t mem_type, uint32_t *perm_reg); /** * @brief Gets interrupt permission settings for split management block * - * Gets interrupt permission settings register contents for required memory region, returns settings for split management blocks + * Gets interrupt permission settings register contents for required memory region (unified management blocks) * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @return split_reg Unified management settings register contents * - * @return Permission settings register contents + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -uint32_t esp_memprot_get_perm_split_reg(mem_type_prot_t mem_type); +esp_err_t esp_memprot_get_perm_split_reg(mem_type_prot_t mem_type, uint32_t *split_reg); /** * @brief Detects whether any of the memory protection interrupts is enabled @@ -217,28 +225,30 @@ bool esp_memprot_is_intr_ena_any(void); * @brief Gets interrupt-enabled flag for given memory region * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @param enable_bit Interrupt-enabled flag * - * @return Interrupt-enabled value + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -uint32_t esp_memprot_get_intr_ena_bit(mem_type_prot_t mem_type); +esp_err_t esp_memprot_get_intr_ena_bit(mem_type_prot_t mem_type, uint32_t *enable_bit); /** * @brief Gets interrupt-active flag for given memory region * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @param intr_on_bit Interrupt-active flag * - * @return Interrupt-active value - */ -uint32_t esp_memprot_get_intr_on_bit(mem_type_prot_t mem_type); + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ +esp_err_t esp_memprot_get_intr_on_bit(mem_type_prot_t mem_type, uint32_t *intr_on_bit); /** * @brief Gets interrupt-clear request flag for given memory region * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @param clear_bit Interrupt-clear request flag * - * @return Interrupt-clear request value + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -uint32_t esp_memprot_get_intr_clr_bit(mem_type_prot_t mem_type); +esp_err_t esp_memprot_get_intr_clr_bit(mem_type_prot_t mem_type, uint32_t *clear_bit); /** * @brief Gets read permission value for specified block and memory region @@ -248,10 +258,11 @@ uint32_t esp_memprot_get_intr_clr_bit(mem_type_prot_t mem_type); * * @param mem_type Memory protection area type (see mem_type_prot_t enum) * @param block Memory block identifier (0-3) + * @param read_bit Read permission value for required block * - * @return Read permission value for required block + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -uint32_t esp_memprot_get_uni_block_read_bit(mem_type_prot_t mem_type, uint32_t block); +esp_err_t esp_memprot_get_uni_block_read_bit(mem_type_prot_t mem_type, uint32_t block, uint32_t *read_bit); /** * @brief Gets write permission value for specified block and memory region @@ -261,10 +272,11 @@ uint32_t esp_memprot_get_uni_block_read_bit(mem_type_prot_t mem_type, uint32_t b * * @param mem_type Memory protection area type (see mem_type_prot_t enum) * @param block Memory block identifier (0-3) + * @param write_bit Write permission value for required block * - * @return Write permission value for required block + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -uint32_t esp_memprot_get_uni_block_write_bit(mem_type_prot_t mem_type, uint32_t block); +esp_err_t esp_memprot_get_uni_block_write_bit(mem_type_prot_t mem_type, uint32_t block, uint32_t *write_bit); /** * @brief Gets execute permission value for specified block and memory region @@ -274,10 +286,11 @@ uint32_t esp_memprot_get_uni_block_write_bit(mem_type_prot_t mem_type, uint32_t * * @param mem_type Memory protection area type (see mem_type_prot_t enum) * @param block Memory block identifier (0-3) + * @param exec_bit Execute permission value for required block * - * @return Execute permission value for required block + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -uint32_t esp_memprot_get_uni_block_exec_bit(mem_type_prot_t mem_type, uint32_t block); +esp_err_t esp_memprot_get_uni_block_exec_bit(mem_type_prot_t mem_type, uint32_t block, uint32_t *exec_bit); /** * @brief Sets permissions for specified block in DRAM region @@ -289,8 +302,10 @@ uint32_t esp_memprot_get_uni_block_exec_bit(mem_type_prot_t mem_type, uint32_t b * @param block Memory block identifier (0-3) * @param write_perm Write permission flag * @param read_perm Read permission flag + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_set_uni_block_perm_dram(mem_type_prot_t mem_type, uint32_t block, bool write_perm, bool read_perm); +esp_err_t esp_memprot_set_uni_block_perm_dram(mem_type_prot_t mem_type, uint32_t block, bool write_perm, bool read_perm); /** * @brief Sets permissions for high and low memory segment in DRAM region @@ -305,8 +320,10 @@ void esp_memprot_set_uni_block_perm_dram(mem_type_prot_t mem_type, uint32_t bloc * @param lr Low segment Read permission flag * @param hw High segment Write permission flag * @param hr High segment Read permission flag + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_set_prot_dram(mem_type_prot_t mem_type, uint32_t *split_addr, bool lw, bool lr, bool hw, bool hr); +esp_err_t esp_memprot_set_prot_dram(mem_type_prot_t mem_type, uint32_t *split_addr, bool lw, bool lr, bool hw, bool hr); /** * @brief Sets permissions for specified block in IRAM region @@ -314,12 +331,17 @@ void esp_memprot_set_prot_dram(mem_type_prot_t mem_type, uint32_t *split_addr, b * Sets Read, Write and Execute permission for specified unified-management block (0-3) in given memory region. * Applicable only to IRAM memory types * - * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @param mem_type Memory protection area type (MEMPROT_IRAM0_SRAM) * @param block Memory block identifier (0-3) * @param write_perm Write permission flag + * @param read_perm Read permission flag * @param exec_perm Execute permission flag + * + * @return ESP_OK on success + * ESP_ERR_NOT_SUPPORTED on invalid mem_type + * ESP_ERR_INVALID_ARG on incorrect block number */ -void esp_memprot_set_uni_block_perm_iram(mem_type_prot_t mem_type, uint32_t block, bool write_perm, bool read_perm, bool exec_perm); +esp_err_t esp_memprot_set_uni_block_perm_iram(mem_type_prot_t mem_type, uint32_t block, bool write_perm, bool read_perm, bool exec_perm); /** * @brief Sets permissions for high and low memory segment in IRAM region @@ -336,8 +358,10 @@ void esp_memprot_set_uni_block_perm_iram(mem_type_prot_t mem_type, uint32_t bloc * @param hw High segment Write permission flag * @param hr High segment Read permission flag * @param hx High segment Execute permission flag + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_set_prot_iram(mem_type_prot_t mem_type, uint32_t *split_addr, bool lw, bool lr, bool lx, bool hw, bool hr, bool hx); +esp_err_t esp_memprot_set_prot_iram(mem_type_prot_t mem_type, uint32_t *split_addr, bool lw, bool lr, bool lx, bool hw, bool hr, bool hx); /** * @brief Activates memory protection for all supported memory region types @@ -347,8 +371,10 @@ void esp_memprot_set_prot_iram(mem_type_prot_t mem_type, uint32_t *split_addr, b * @param invoke_panic_handler map mem.prot interrupt to ETS_MEMACCESS_ERR_INUM and thus invokes panic handler when fired ('true' not suitable for testing) * @param lock_feature sets LOCK bit, see esp_memprot_set_lock() ('true' not suitable for testing) * @param mem_type_mask holds a set of required memory protection types (bitmask built of mem_type_prot_t). NULL means default (MEMPROT_ALL in this version) + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_set_prot(bool invoke_panic_handler, bool lock_feature, uint32_t *mem_type_mask); +esp_err_t esp_memprot_set_prot(bool invoke_panic_handler, bool lock_feature, uint32_t *mem_type_mask); /** * @brief Get permission settings bits for IRAM0 split mgmt. Only IRAM0 memory types allowed @@ -360,8 +386,10 @@ void esp_memprot_set_prot(bool invoke_panic_handler, bool lock_feature, uint32_t * @param hw High segment Write permission flag * @param hr High segment Read permission flag * @param hx High segment Execute permission flag + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_get_perm_split_bits_iram(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *lx, bool *hw, bool *hr, bool *hx); +esp_err_t esp_memprot_get_perm_split_bits_iram(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *lx, bool *hw, bool *hr, bool *hx); /** * @brief Get permission settings bits for DRAM0 split mgmt. Only DRAM0 memory types allowed @@ -371,8 +399,10 @@ void esp_memprot_get_perm_split_bits_iram(mem_type_prot_t mem_type, bool *lw, bo * @param lr Low segment Read permission flag * @param hw High segment Write permission flag * @param hr High segment Read permission flag + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_get_perm_split_bits_dram(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *hw, bool *hr); +esp_err_t esp_memprot_get_perm_split_bits_dram(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *hw, bool *hr); /** * @brief Sets permissions for high and low memory segment in PERIBUS1 region @@ -386,8 +416,10 @@ void esp_memprot_get_perm_split_bits_dram(mem_type_prot_t mem_type, bool *lw, bo * @param lr Low segment Read permission flag * @param hw High segment Write permission flag * @param hr High segment Read permission flag + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_set_prot_peri1(mem_type_prot_t mem_type, uint32_t *split_addr, bool lw, bool lr, bool hw, bool hr); +esp_err_t esp_memprot_set_prot_peri1(mem_type_prot_t mem_type, uint32_t *split_addr, bool lw, bool lr, bool hw, bool hr); /** * @brief Get permission settings bits for PERIBUS1 split mgmt. Only PERIBUS1 memory types allowed @@ -397,8 +429,10 @@ void esp_memprot_set_prot_peri1(mem_type_prot_t mem_type, uint32_t *split_addr, * @param lr Low segment Read permission flag * @param hw High segment Write permission flag * @param hr High segment Read permission flag + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_get_perm_split_bits_peri1(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *hw, bool *hr); +esp_err_t esp_memprot_get_perm_split_bits_peri1(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *hw, bool *hr); /** * @brief Get permission settings bits for PERIBUS2 split mgmt. Only PERIBUS2 memory types allowed @@ -410,25 +444,32 @@ void esp_memprot_get_perm_split_bits_peri1(mem_type_prot_t mem_type, bool *lw, b * @param hw High segment Write permission flag * @param hr High segment Read permission flag * @param hx High segment Execute permission flag + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_get_perm_split_bits_peri2(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *lx, bool *hw, bool *hr, bool *hx); +esp_err_t esp_memprot_get_perm_split_bits_peri2(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *lx, bool *hw, bool *hr, bool *hx); /** - * @brief Sets permissions for high and low memory segment in PERIBUS2 region + * @brief Configures the memory protection for high and low segment in PERIBUS2 region * * Sets Read Write permission for both low and high memory segments given by splitting address. * Applicable only to PERIBUS2 memory types * - * @param mem_type Memory protection area type (see mem_type_prot_t enum) - * @param split_addr Address to split the memory region to lower and higher segment + * @param mem_type Memory protection area type (MEMPROT_PERI2_RTCSLOW_0, MEMPROT_PERI2_RTCSLOW_1) + * @param split_addr Address to split the memory region to lower and higher segment (32bit aligned) * @param lw Low segment Write permission flag * @param lr Low segment Read permission flag * @param lx Low segment Execute permission flag * @param hw High segment Write permission flag * @param hr High segment Read permission flag * @param hx High segment Execute permission flag + * + * @return ESP_OK on success + * ESP_ERR_NOT_SUPPORTED on invalid mem_type + * ESP_ERR_INVALID_STATE on splitting address out of PERIBUS2 range + * ESP_ERR_INVALID_SIZE on splitting address not 32-bit aligned */ -void esp_memprot_set_prot_peri2(mem_type_prot_t mem_type, uint32_t *split_addr, bool lw, bool lr, bool lx, bool hw, bool hr, bool hx); +esp_err_t esp_memprot_set_prot_peri2(mem_type_prot_t mem_type, uint32_t *split_addr, bool lw, bool lr, bool lx, bool hw, bool hr, bool hx); /** * @brief Get permissions for specified memory type. Irrelevant bits are ignored @@ -440,8 +481,12 @@ void esp_memprot_set_prot_peri2(mem_type_prot_t mem_type, uint32_t *split_addr, * @param hw High segment Write permission flag * @param hr High segment Read permission flag * @param hx High segment Execute permission flag + * + * @return ESP_OK on success + * ESP_ERR_INVALID_ARG on NULL lw/lr/lx/hw/hr/hx args + * ESP_ERR_NOT_SUPPORTED on invalid mem_type */ -void esp_memprot_get_permissions(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *lx, bool *hw, bool *hr, bool *hx); +esp_err_t esp_memprot_get_permissions(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *lx, bool *hw, bool *hr, bool *hx); /** * @brief Get Read permission settings for low and high regions of given memory type @@ -449,8 +494,12 @@ void esp_memprot_get_permissions(mem_type_prot_t mem_type, bool *lw, bool *lr, b * @param mem_type Memory protection area type (see mem_type_prot_t enum) * @param lr Low segment Read permission flag * @param hr High segment Read permission flag + * + * @return ESP_OK on success + * ESP_ERR_INVALID_ARG on NULL lr/hr args + * ESP_ERR_NOT_SUPPORTED on invalid mem_type */ -void esp_memprot_get_perm_read(mem_type_prot_t mem_type, bool *lr, bool *hr); +esp_err_t esp_memprot_get_perm_read(mem_type_prot_t mem_type, bool *lr, bool *hr); /** * @brief Get Write permission settings for low and high regions of given memory type @@ -458,23 +507,33 @@ void esp_memprot_get_perm_read(mem_type_prot_t mem_type, bool *lr, bool *hr); * @param mem_type Memory protection area type (see mem_type_prot_t enum) * @param lr Low segment Write permission flag * @param hr High segment Write permission flag + * + * @return ESP_OK on success + * ESP_ERR_INVALID_ARG on NULL lw/hw args + * ESP_ERR_NOT_SUPPORTED on invalid mem_type */ -void esp_memprot_get_perm_write(mem_type_prot_t mem_type, bool *lw, bool *hw); +esp_err_t esp_memprot_get_perm_write(mem_type_prot_t mem_type, bool *lw, bool *hw); /** * @brief Get Execute permission settings for low and high regions of given memory type * Applicable only to IBUS-compatible memory types * - * @param mem_type Memory protection area type (see mem_type_prot_t enum) - * @param lr Low segment Exec permission flag - * @param hr High segment Exec permission flag + * @param mem_type Memory protection area type (MEMPROT_IRAM0_SRAM, MEMPROT_IRAM0_RTCFAST, MEMPROT_PERI2_RTCSLOW_0, MEMPROT_PERI2_RTCSLOW_1) + * @param lx Low segment Exec permission flag + * @param hx High segment Exec permission flag + * + * @return ESP_OK on success + * ESP_ERR_INVALID_ARG on NULL lx/hx args + * ESP_ERR_NOT_SUPPORTED on invalid mem_type */ -void esp_memprot_get_perm_exec(mem_type_prot_t mem_type, bool *lx, bool *hx); +esp_err_t esp_memprot_get_perm_exec(mem_type_prot_t mem_type, bool *lx, bool *hx); /** * @brief Returns the lowest address in required memory region * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * + * @return Required address or MEMPROT_INVALID_ADDRESS for invalid mem_type */ uint32_t esp_memprot_get_low_limit(mem_type_prot_t mem_type); @@ -482,6 +541,8 @@ uint32_t esp_memprot_get_low_limit(mem_type_prot_t mem_type); * @brief Returns the highest address in required memory region * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * + * @return Required address or MEMPROT_INVALID_ADDRESS for invalid mem_type */ uint32_t esp_memprot_get_high_limit(mem_type_prot_t mem_type); @@ -491,8 +552,11 @@ uint32_t esp_memprot_get_high_limit(mem_type_prot_t mem_type); * @param mem_type Memory protection area type (see mem_type_prot_t enum) * @param lr Low segment Read permission flag * @param hr High segment Read permission flag + * + * @return ESP_OK on success + * ESP_ERR_NOT_SUPPORTED on invalid mem_type */ -void esp_memprot_set_read_perm(mem_type_prot_t mem_type, bool lr, bool hr); +esp_err_t esp_memprot_set_read_perm(mem_type_prot_t mem_type, bool lr, bool hr); /** * @brief Sets WRITE permission bit for required memory region @@ -500,17 +564,23 @@ void esp_memprot_set_read_perm(mem_type_prot_t mem_type, bool lr, bool hr); * @param mem_type Memory protection area type (see mem_type_prot_t enum) * @param lr Low segment Write permission flag * @param hr High segment Write permission flag + * + * @return ESP_OK on success + * ESP_ERR_NOT_SUPPORTED on invalid mem_type */ -void esp_memprot_set_write_perm(mem_type_prot_t mem_type, bool lw, bool hw); +esp_err_t esp_memprot_set_write_perm(mem_type_prot_t mem_type, bool lw, bool hw); /** * @brief Sets EXECUTE permission bit for required memory region * - * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @param mem_type Memory protection area type (MEMPROT_IRAM0_SRAM, MEMPROT_IRAM0_RTCFAST, MEMPROT_PERI2_RTCSLOW_0, MEMPROT_PERI2_RTCSLOW_1) * @param lr Low segment Exec permission flag * @param hr High segment Exec permission flag + * + * @return ESP_OK on success + * ESP_ERR_NOT_SUPPORTED on invalid mem_type */ -void esp_memprot_set_exec_perm(mem_type_prot_t mem_type, bool lx, bool hx); +esp_err_t esp_memprot_set_exec_perm(mem_type_prot_t mem_type, bool lx, bool hx); #ifdef __cplusplus diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/rtc.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/rtc.h index 296292e21db..3ab96b37872 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/rtc.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/rtc.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/spiram.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/spiram.h index cc2b4c85497..70d07e61a85 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/spiram.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s2/spiram.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef __ESP_SPIRAM_H @@ -78,6 +70,15 @@ size_t esp_spiram_get_size(void); */ void esp_spiram_writeback_cache(void); +/** + * @brief get psram CS IO + * + * This interface should be called after PSRAM is enabled, otherwise it will + * return an invalid value -1/0xff. + * + * @return psram CS IO or -1/0xff if psram not enabled + */ +uint8_t esp_spiram_get_cs_io(void); /** @@ -91,6 +92,15 @@ void esp_spiram_writeback_cache(void); */ esp_err_t esp_spiram_reserve_dma_pool(size_t size); +/** + * @brief If SPI RAM(PSRAM) has been initialized + * + * @return + * - true SPI RAM has been initialized successfully + * - false SPI RAM hasn't been initialized or initialized failed + */ +bool esp_spiram_is_initialized(void); + #if CONFIG_SPIRAM_FETCH_INSTRUCTIONS extern int _instruction_reserved_start, _instruction_reserved_end; diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s3/clk.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s3/clk.h index 31902ebad01..a9ed3028527 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s3/clk.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s3/clk.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include "esp_private/esp_clk.h" diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s3/dport_access.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s3/dport_access.h index f3f7007a9cb..e5aedd2e1b1 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s3/dport_access.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s3/dport_access.h @@ -1,16 +1,8 @@ -// Copyright 2010-2020 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. +/* + * SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_DPORT_ACCESS_H_ #define _ESP_DPORT_ACCESS_H_ diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s3/esp_crypto_lock.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s3/esp_crypto_lock.h index 781ac077803..074754a86b2 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s3/esp_crypto_lock.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s3/esp_crypto_lock.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once @@ -26,6 +18,34 @@ extern "C" { * Other unrelated components must not use it. */ +/** + * @brief Acquire lock for Digital Signature(DS) cryptography peripheral + * + * Internally also takes the HMAC lock, as the DS depends on the HMAC peripheral + */ +void esp_crypto_ds_lock_acquire(void); + +/** + * @brief Release lock for Digital Signature(DS) cryptography peripheral + * + * Internally also releases the HMAC lock, as the DS depends on the HMAC peripheral + */ +void esp_crypto_ds_lock_release(void); + +/** + * @brief Acquire lock for HMAC cryptography peripheral + * + * Internally also takes the SHA & AES lock, as the HMAC depends on the SHA peripheral + */ +void esp_crypto_hmac_lock_acquire(void); + +/** + * @brief Release lock for HMAC cryptography peripheral + * + * Internally also releases the SHA & AES lock, as the HMAC depends on the SHA peripheral + */ +void esp_crypto_hmac_lock_release(void); + /** * @brief Acquire lock for the SHA and AES cryptography peripheral. * diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s3/esp_ds.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s3/esp_ds.h new file mode 100644 index 00000000000..46a1d22a543 --- /dev/null +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s3/esp_ds.h @@ -0,0 +1,192 @@ +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once +#include + +#include "esp_hmac.h" +#include "esp_err.h" +#include "soc/soc_caps.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ESP32S3_ERR_HW_CRYPTO_DS_HMAC_FAIL ESP_ERR_HW_CRYPTO_BASE + 0x1 /*!< HMAC peripheral problem */ +#define ESP32S3_ERR_HW_CRYPTO_DS_INVALID_KEY ESP_ERR_HW_CRYPTO_BASE + 0x2 /*!< given HMAC key isn't correct, + HMAC peripheral problem */ +#define ESP32S3_ERR_HW_CRYPTO_DS_INVALID_DIGEST ESP_ERR_HW_CRYPTO_BASE + 0x4 /*!< message digest check failed, + result is invalid */ +#define ESP32S3_ERR_HW_CRYPTO_DS_INVALID_PADDING ESP_ERR_HW_CRYPTO_BASE + 0x5 /*!< padding check failed, but result + is produced anyway and can be read*/ + +#define ESP_DS_IV_LEN 16 + +/* Length of parameter 'C' stored in flash */ +#define ESP_DS_C_LEN (12672 / 8) + +typedef struct esp_ds_context esp_ds_context_t; + +typedef enum { + ESP_DS_RSA_1024 = (1024 / 32) - 1, + ESP_DS_RSA_2048 = (2048 / 32) - 1, + ESP_DS_RSA_3072 = (3072 / 32) - 1, + ESP_DS_RSA_4096 = (4096 / 32) - 1 +} esp_digital_signature_length_t; + +/** + * Encrypted private key data. Recommended to store in flash in this format. + * + * @note This struct has to match to one from the ROM code! This documentation is mostly taken from there. + */ +typedef struct esp_digital_signature_data { + /** + * RSA LENGTH register parameters + * (number of words in RSA key & operands, minus one). + * + * Max value 127 (for RSA 4096). + * + * This value must match the length field encrypted and stored in 'c', + * or invalid results will be returned. (The DS peripheral will + * always use the value in 'c', not this value, so an attacker can't + * alter the DS peripheral results this way, it will just truncate or + * extend the message and the resulting signature in software.) + * + * @note In IDF, the enum type length is the same as of type unsigned, so they can be used interchangably. + * See the ROM code for the original declaration of struct \c ets_ds_data_t. + */ + esp_digital_signature_length_t rsa_length; + + /** + * IV value used to encrypt 'c' + */ + uint8_t iv[ESP_DS_IV_LEN]; + + /** + * Encrypted Digital Signature parameters. Result of AES-CBC encryption + * of plaintext values. Includes an encrypted message digest. + */ + uint8_t c[ESP_DS_C_LEN]; +} esp_ds_data_t; + +/** Plaintext parameters used by Digital Signature. + * + * Not used for signing with DS peripheral, but can be encrypted + * in-device by calling esp_ds_encrypt_params() + * + * @note This documentation is mostly taken from the ROM code. + */ +typedef struct { + uint32_t Y[SOC_RSA_MAX_BIT_LEN / 32]; //!< RSA exponent + uint32_t M[SOC_RSA_MAX_BIT_LEN / 32]; //!< RSA modulus + uint32_t Rb[SOC_RSA_MAX_BIT_LEN / 32]; //!< RSA r inverse operand + uint32_t M_prime; //!< RSA M prime operand + esp_digital_signature_length_t length; //!< RSA length +} esp_ds_p_data_t; + +/** + * Sign the message. + * + * This function is a wrapper around \c esp_ds_finish_sign() and \c esp_ds_start_sign(), so do not use them + * in parallel. + * It blocks until the signing is finished and then returns the signature. + * + * @note This function locks the HMAC, SHA, AES and RSA components during its entire execution time. + * + * @param message the message to be signed; its length is determined by data->rsa_length + * @param data the encrypted signing key data (AES encrypted RSA key + IV) + * @param key_id the HMAC key ID determining the HMAC key of the HMAC which will be used to decrypt the + * signing key data + * @param signature the destination of the signature, should be (data->rsa_length + 1)*4 bytes long + * + * @return + * - ESP_OK if successful, the signature was written to the parameter \c signature. + * - ESP_ERR_INVALID_ARG if one of the parameters is NULL or data->rsa_length is too long or 0 + * - ESP_ERR_HW_CRYPTO_DS_HMAC_FAIL if there was an HMAC failure during retrieval of the decryption key + * - ESP_ERR_NO_MEM if there hasn't been enough memory to allocate the context object + * - ESP_ERR_HW_CRYPTO_DS_INVALID_KEY if there's a problem with passing the HMAC key to the DS component + * - ESP_ERR_HW_CRYPTO_DS_INVALID_DIGEST if the message digest didn't match; the signature is invalid. + * - ESP_ERR_HW_CRYPTO_DS_INVALID_PADDING if the message padding is incorrect, the signature can be read though + * since the message digest matches. + */ +esp_err_t esp_ds_sign(const void *message, + const esp_ds_data_t *data, + hmac_key_id_t key_id, + void *signature); + +/** + * Start the signing process. + * + * This function yields a context object which needs to be passed to \c esp_ds_finish_sign() to finish the signing + * process. + * + * @note This function locks the HMAC, SHA, AES and RSA components, so the user has to ensure to call + * \c esp_ds_finish_sign() in a timely manner. + * + * @param message the message to be signed; its length is determined by data->rsa_length + * @param data the encrypted signing key data (AES encrypted RSA key + IV) + * @param key_id the HMAC key ID determining the HMAC key of the HMAC which will be used to decrypt the + * signing key data + * @param esp_ds_ctx the context object which is needed for finishing the signing process later + * + * @return + * - ESP_OK if successful, the ds operation was started now and has to be finished with \c esp_ds_finish_sign() + * - ESP_ERR_INVALID_ARG if one of the parameters is NULL or data->rsa_length is too long or 0 + * - ESP_ERR_HW_CRYPTO_DS_HMAC_FAIL if there was an HMAC failure during retrieval of the decryption key + * - ESP_ERR_NO_MEM if there hasn't been enough memory to allocate the context object + * - ESP_ERR_HW_CRYPTO_DS_INVALID_KEY if there's a problem with passing the HMAC key to the DS component + */ +esp_err_t esp_ds_start_sign(const void *message, + const esp_ds_data_t *data, + hmac_key_id_t key_id, + esp_ds_context_t **esp_ds_ctx); + +/** + * Return true if the DS peripheral is busy, otherwise false. + * + * @note Only valid if \c esp_ds_start_sign() was called before. + */ +bool esp_ds_is_busy(void); + +/** + * Finish the signing process. + * + * @param signature the destination of the signature, should be (data->rsa_length + 1)*4 bytes long + * @param esp_ds_ctx the context object retreived by \c esp_ds_start_sign() + * + * @return + * - ESP_OK if successful, the ds operation has been finished and the result is written to signature. + * - ESP_ERR_INVALID_ARG if one of the parameters is NULL + * - ESP_ERR_HW_CRYPTO_DS_INVALID_DIGEST if the message digest didn't match; the signature is invalid. + * - ESP_ERR_HW_CRYPTO_DS_INVALID_PADDING if the message padding is incorrect, the signature can be read though + * since the message digest matches. + */ +esp_err_t esp_ds_finish_sign(void *signature, esp_ds_context_t *esp_ds_ctx); + +/** + * Encrypt the private key parameters. + * + * @param data Output buffer to store encrypted data, suitable for later use generating signatures. + * The allocated memory must be in internal memory and word aligned since it's filled by DMA. Both is asserted + * at run time. + * @param iv Pointer to 16 byte IV buffer, will be copied into 'data'. Should be randomly generated bytes each time. + * @param p_data Pointer to input plaintext key data. The expectation is this data will be deleted after this process + * is done and 'data' is stored. + * @param key Pointer to 32 bytes of key data. Type determined by key_type parameter. The expectation is the + * corresponding HMAC key will be stored to efuse and then permanently erased. + * + * @return + * - ESP_OK if successful, the ds operation has been finished and the result is written to signature. + * - ESP_ERR_INVALID_ARG if one of the parameters is NULL or p_data->rsa_length is too long + */ +esp_err_t esp_ds_encrypt_params(esp_ds_data_t *data, + const void *iv, + const esp_ds_p_data_t *p_data, + const void *key); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s3/esp_hmac.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s3/esp_hmac.h new file mode 100644 index 00000000000..101dce556b6 --- /dev/null +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s3/esp_hmac.h @@ -0,0 +1,84 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "esp_err.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The possible efuse keys for the HMAC peripheral + */ +typedef enum { + HMAC_KEY0 = 0, + HMAC_KEY1, + HMAC_KEY2, + HMAC_KEY3, + HMAC_KEY4, + HMAC_KEY5, + HMAC_KEY_MAX +} hmac_key_id_t; + +/** + * @brief + * Calculate the HMAC of a given message. + * + * Calculate the HMAC \c hmac of a given message \c message with length \c message_len. + * SHA256 is used for the calculation (fixed on ESP32S3). + * + * @note Uses the HMAC peripheral in "upstream" mode. + * + * @param key_id Determines which of the 6 key blocks in the efuses should be used for the HMAC calcuation. + * The corresponding purpose field of the key block in the efuse must be set to the HMAC upstream purpose value. + * @param message the message for which to calculate the HMAC + * @param message_len message length + * @param [out] hmac the hmac result; the buffer behind the provided pointer must be 32 bytes long + * + * @return + * * ESP_OK, if the calculation was successful, + * * ESP_ERR_INVALID_ARG if message or hmac is a nullptr or if key_id out of range + * * ESP_FAIL, if the hmac calculation failed + */ +esp_err_t esp_hmac_calculate(hmac_key_id_t key_id, + const void *message, + size_t message_len, + uint8_t *hmac); + +/** + * @brief Use HMAC peripheral in Downstream mode to re-enable the JTAG, if it is not permanently disabled by HW. + * In downstream mode, HMAC calculations performed by peripheral are used internally and not provided back to user. + * + * @param key_id Determines which of the 6 key blocks in the efuses should be used for the HMAC calculation. + * The corresponding purpose field of the key block in the efuse must be set to HMAC downstream purpose. + * + * @param token Pre calculated HMAC value of the 32-byte 0x00 using SHA-256 and the known private HMAC key. The key is already + * programmed to a eFuse key block. The key block number is provided as the first parameter to this function. + * + * @return + * * ESP_OK, if the calculation was successful, + * if the calculated HMAC value matches with provided token, + * JTAG will be re-enable otherwise JTAG will remain disabled. + * Return value does not indicate the JTAG status. + * * ESP_FAIL, if the hmac calculation failed or JTAG is permanently disabled by EFUSE_HARD_DIS_JTAG eFuse parameter. + * * ESP_ERR_INVALID_ARG, invalid input arguments + */ +esp_err_t esp_hmac_jtag_enable(hmac_key_id_t key_id, const uint8_t *token); + +/** + * @brief Disable the JTAG which might be enabled using the HMAC downstream mode. This function just clears the result generated + * by calling esp_hmac_jtag_enable() API. + * + * @return + * * ESP_OK return ESP_OK after writing the HMAC_SET_INVALIDATE_JTAG_REG with value 1. + */ +esp_err_t esp_hmac_jtag_disable(void); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s3/memprot.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s3/memprot.h index 7e47a8cfa33..948e0676680 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s3/memprot.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s3/memprot.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /* INTERNAL API diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s3/rtc.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s3/rtc.h index 296292e21db..3ab96b37872 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s3/rtc.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s3/rtc.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s3/spiram.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s3/spiram.h index 105a60543e0..067c3d27bf8 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s3/spiram.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/esp32s3/spiram.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef __ESP_SPIRAM_H @@ -78,7 +70,24 @@ size_t esp_spiram_get_size(void); */ void esp_spiram_writeback_cache(void); +/** + * @brief If SPI RAM(PSRAM) has been initialized + * + * @return + * - true SPI RAM has been initialized successfully + * - false SPI RAM hasn't been initialized or initialized failed + */ +bool esp_spiram_is_initialized(void); +/** + * @brief get psram CS IO + * + * This interface should be called after PSRAM is enabled, otherwise it will + * return an invalid value -1/0xff. + * + * @return psram CS IO or -1/0xff if psram not enabled + */ +uint8_t esp_spiram_get_cs_io(void); /** * @brief Reserve a pool of internal memory for specific DMA/internal allocations @@ -91,6 +100,15 @@ void esp_spiram_writeback_cache(void); */ esp_err_t esp_spiram_reserve_dma_pool(size_t size); +/** + * @brief If SPI RAM(PSRAM) has been initialized + * + * @return + * - true SPI RAM has been initialized successfully + * - false SPI RAM hasn't been initialized or initialized failed + */ +bool esp_spiram_is_initialized(void); + #if CONFIG_SPIRAM_FETCH_INSTRUCTIONS extern int _instruction_reserved_start, _instruction_reserved_end; diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/rtc_wdt.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/rtc_wdt.h index 7d13e6a4f75..97d1d8425bd 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/rtc_wdt.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/rtc_wdt.h @@ -1,16 +1,8 @@ -// Copyright 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. +/* + * SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /* Recommendation of using API RTC_WDT. 1) Setting and enabling rtc_wdt: diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/spinlock.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/spinlock.h index 66baa93066b..97cc9e514ab 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/spinlock.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/spinlock.h @@ -1,16 +1,8 @@ -// Copyright 2015-2019 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc_log.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc_log.h index ea2ecce8f80..64268433fb9 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc_log.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc_log.h @@ -1,16 +1,8 @@ -// Copyright 2016-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2016-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include "esp_rom_sys.h" diff --git a/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/i2c_brownout.h b/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/i2c_brownout.h index 5fac2c91b39..1d2ab344112 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/i2c_brownout.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/i2c_brownout.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/i2c_rtc_clk.h b/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/i2c_rtc_clk.h index 0bbe0ee1a1e..dbb7d73dc42 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/i2c_rtc_clk.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/i2c_rtc_clk.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/private_include/regi2c_bbpll.h b/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/private_include/regi2c_bbpll.h index 842f7029346..8235741d58f 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/private_include/regi2c_bbpll.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/private_include/regi2c_bbpll.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/private_include/regi2c_bias.h b/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/private_include/regi2c_bias.h index f459a344ba2..e359ef0a699 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/private_include/regi2c_bias.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/private_include/regi2c_bias.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/private_include/regi2c_brownout.h b/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/private_include/regi2c_brownout.h index d81751347c0..1aa54a20177 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/private_include/regi2c_brownout.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/private_include/regi2c_brownout.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/private_include/regi2c_dig_reg.h b/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/private_include/regi2c_dig_reg.h index 2510f43ae57..9d2032b60ef 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/private_include/regi2c_dig_reg.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/private_include/regi2c_dig_reg.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/private_include/regi2c_lp_bias.h b/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/private_include/regi2c_lp_bias.h index 0dae77107c6..c50c1a941a3 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/private_include/regi2c_lp_bias.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/private_include/regi2c_lp_bias.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/private_include/regi2c_saradc.h b/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/private_include/regi2c_saradc.h index e9def9583d1..1c35fd61ef7 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/private_include/regi2c_saradc.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/private_include/regi2c_saradc.h @@ -1,16 +1,8 @@ -// Copyright 2019-2020 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. +/* + * SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/regi2c_ctrl.h b/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/regi2c_ctrl.h index 95f2626656e..27e969eda84 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/regi2c_ctrl.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/regi2c_ctrl.h @@ -1,30 +1,8 @@ -// Copyright 2020 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. - -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/rtc_clk_common.h b/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/rtc_clk_common.h index c3e8a86e093..07f8c1243c3 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/rtc_clk_common.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/port/esp32c3/rtc_clk_common.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32c3/include/esp_ipc/include/esp_ipc.h b/tools/sdk/esp32c3/include/esp_ipc/include/esp_ipc.h index 477b3d0af4e..5e02c460bce 100644 --- a/tools/sdk/esp32c3/include/esp_ipc/include/esp_ipc.h +++ b/tools/sdk/esp32c3/include/esp_ipc/include/esp_ipc.h @@ -20,6 +20,9 @@ #ifdef __cplusplus extern "C" { #endif + +#if !defined(CONFIG_FREERTOS_UNICORE) || defined(CONFIG_APPTRACE_GCOV_ENABLE) + /** @cond */ typedef void (*esp_ipc_func_t)(void* arg); /** @endcond */ @@ -85,6 +88,7 @@ esp_err_t esp_ipc_call(uint32_t cpu_id, esp_ipc_func_t func, void* arg); */ esp_err_t esp_ipc_call_blocking(uint32_t cpu_id, esp_ipc_func_t func, void* arg); +#endif // not CONFIG_FREERTOS_UNICORE or CONFIG_APPTRACE_GCOV_ENABLE #ifdef __cplusplus } diff --git a/tools/sdk/esp32c3/include/esp_ipc/include/esp_ipc_isr.h b/tools/sdk/esp32c3/include/esp_ipc/include/esp_ipc_isr.h new file mode 100644 index 00000000000..7b6e060f1d5 --- /dev/null +++ b/tools/sdk/esp32c3/include/esp_ipc/include/esp_ipc_isr.h @@ -0,0 +1,117 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "sdkconfig.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef CONFIG_ESP_IPC_ISR_ENABLE + +/** @cond */ +typedef void (*esp_ipc_isr_func_t)(void* arg); +/** @endcond */ + +/** + * @brief Initialize inter-processor call module which based on #4 high-interrupt. + * + * This function is called on CPU start and should not be called from the application. + * + * This function starts two tasks, one on each CPU. These tasks register + * #4 High-interrupt and after that, the tasks are deleted. + * The next API functions work with this functionality: + * esp_ipc_isr_asm_call + * esp_ipc_isr_asm_call_blocking + * They allow to run an asm function on other CPU. + */ +void esp_ipc_isr_init(void); + +/** + * @brief Execute an asm function on the other CPU (uses the #4 high-priority interrupt) + * + * @note In single-core mode, it is not available. + * This function calls the #4 high-priority interrupt on the other CPU. + * The given function is called in the context of the interrupt by CALLX0 command and + * operates with registers a2, a3, a4. + * + * @param[in] func Pointer to a function of type void func(void* arg) to be executed + * @param[in] arg Arbitrary argument of type void* to be passed into the function + */ +void esp_ipc_isr_asm_call(esp_ipc_isr_func_t func, void* arg); + +/** + * @brief Execute an asm function on the other CPU and blocks until it completes (uses the #4 high-priority interrupt) + * + * @note In single-core mode, it is not available. + * This function calls the #4 high-priority interrupt on the other CPU. + * The given function is called in the context of the interrupt by CALLX0 command. + * + * @param[in] func Pointer to a function of type void func(void* arg) to be executed + * @param[in] arg Arbitrary argument of type void* to be passed into the function + */ +void esp_ipc_isr_asm_call_blocking(esp_ipc_isr_func_t func, void* arg); + +/** + * @brief Stall the other CPU and the current CPU disables interrupts with level 3 and lower. + * + * @note In single-core mode, it is not available. + * This function calls the #4 high-priority interrupt on the other CPU. + * The esp_ipc_isr_finish_cmd() function is called on the other CPU in the context of the #4 high-priority interrupt. + * The esp_ipc_isr_finish_cmd is called by CALLX0 command. + * It is waiting for the end command. The command will be sent by esp_ipc_isr_release_other_cpu(). + * This function is used for DPORT workaround. + * + * This function blocks other CPU until the release call esp_ipc_isr_release_other_cpu(). + * + * This fucntion is used for the DPORT workaround: stall other cpu that this cpu is pending to access dport register start. + */ +void esp_ipc_isr_stall_other_cpu(void); + +/** + * @brief Release the other CPU + * + * @note In single-core mode, it is not available. + * This function will send the end command to release the stall other CPU. + * This function is used for DPORT workaround: stall other cpu that this cpu is pending to access dport register end. + * + */ +void esp_ipc_isr_release_other_cpu(void); + +/** + * @brief Pause stall the other CPU + */ +void esp_ipc_isr_stall_pause(void); + +/** + * @brief Abort stall the other CPU + * + * This routine does not stop the stall routines in any way that is recoverable. + * Please only call in case of panic(). + * Used in panic code: the enter_critical stuff may be messed up so we just stop everything without checking the mux. + */ +void esp_ipc_isr_stall_abort(void); + +/** + * @brief Resume stall the other CPU + */ +void esp_ipc_isr_stall_resume(void); + +#else // not CONFIG_ESP_IPC_ISR_ENABLE + +#define esp_ipc_isr_stall_other_cpu() +#define esp_ipc_isr_release_other_cpu() +#define esp_ipc_isr_stall_pause() +#define esp_ipc_isr_stall_abort() +#define esp_ipc_isr_stall_resume() + +#endif // CONFIG_ESP_IPC_ISR_ENABLE + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32c3/include/esp_lcd/include/esp_lcd_panel_io.h b/tools/sdk/esp32c3/include/esp_lcd/include/esp_lcd_panel_io.h index c362180f53e..eebcabf42b4 100644 --- a/tools/sdk/esp32c3/include/esp_lcd/include/esp_lcd_panel_io.h +++ b/tools/sdk/esp32c3/include/esp_lcd/include/esp_lcd_panel_io.h @@ -9,6 +9,7 @@ #include "esp_err.h" #include "esp_lcd_types.h" #include "soc/soc_caps.h" +#include "hal/lcd_types.h" #ifdef __cplusplus extern "C" { @@ -28,14 +29,13 @@ typedef struct esp_lcd_i80_bus_t *esp_lcd_i80_bus_handle_t; /*!< Type of LCD i * * @param[in] io LCD panel IO handle, which is created by other factory API like `esp_lcd_new_panel_io_spi()` * @param[in] lcd_cmd The specific LCD command - * @param[in] lcd_cmd_bits Length of LCD command, in bits (e.g. 8 bits or 16 bits) * @param[in] param Buffer that holds the command specific parameters, set to NULL if no parameter is needed for the command * @param[in] param_size Size of `param` in memory, in bytes, set to zero if no parameter is needed for the command * @return * - ESP_ERR_INVALID_ARG if parameter is invalid * - ESP_OK on success */ -esp_err_t esp_lcd_panel_io_tx_param(esp_lcd_panel_io_handle_t io, int lcd_cmd, int lcd_cmd_bits, const void *param, size_t param_size); +esp_err_t esp_lcd_panel_io_tx_param(esp_lcd_panel_io_handle_t io, int lcd_cmd, const void *param, size_t param_size); /** * @brief Transmit LCD RGB data @@ -47,14 +47,13 @@ esp_err_t esp_lcd_panel_io_tx_param(esp_lcd_panel_io_handle_t io, int lcd_cmd, i * * @param[in] io LCD panel IO handle, which is created by factory API like `esp_lcd_new_panel_io_spi()` * @param[in] lcd_cmd The specific LCD command - * @param[in] lcd_cmd_bits Length of LCD command, in bits (e.g. 8 bits or 16 bits) * @param[in] color Buffer that holds the RGB color data * @param[in] color_size Size of `color` in memory, in bytes * @return * - ESP_ERR_INVALID_ARG if parameter is invalid * - ESP_OK on success */ -esp_err_t esp_lcd_panel_io_tx_color(esp_lcd_panel_io_handle_t io, int lcd_cmd, int lcd_cmd_bits, const void *color, size_t color_size); +esp_err_t esp_lcd_panel_io_tx_color(esp_lcd_panel_io_handle_t io, int lcd_cmd, const void *color, size_t color_size); /** * @brief Destory LCD panel IO handle (deinitialize panel and free all corresponding resource) @@ -76,10 +75,13 @@ typedef struct { unsigned int pclk_hz; /*!< Frequency of pixel clock */ size_t trans_queue_depth; /*!< Size of internal transaction queue */ bool (*on_color_trans_done)(esp_lcd_panel_io_handle_t panel_io, void *user_data, void *event_data); /*!< Callback, invoked when color data transfer has finished */ - void *user_data; /*!< User private data, passed directly to on_trans_frame_done's user_data */ + void *user_data; /*!< User private data, passed directly to on_trans_frame_done's user_data */ + int lcd_cmd_bits; /*!< Bit-width of LCD command */ + int lcd_param_bits; /*!< Bit-width of LCD parameter */ struct { unsigned int dc_as_cmd_phase: 1; /*!< D/C line value is encoded into SPI transaction command phase */ unsigned int dc_low_on_data: 1; /*!< If this flag is enabled, DC line = 0 means transfer data, DC line = 1 means transfer command; vice versa */ + unsigned int octal_mode: 1; /*!< transmit with octal mode (8 data lines), this mode is used to simulate Intel 8080 timing */ } flags; } esp_lcd_panel_io_spi_config_t; @@ -102,6 +104,8 @@ typedef struct { void *user_data; /*!< User private data, passed directly to on_trans_frame_done's user_data */ size_t control_phase_bytes; /*!< I2C LCD panel will encode control information (e.g. D/C seclection) into control phase, in several bytes */ unsigned int dc_bit_offset; /*!< Offset of the D/C selection bit in control phase */ + int lcd_cmd_bits; /*!< Bit-width of LCD command */ + int lcd_param_bits; /*!< Bit-width of LCD parameter */ struct { unsigned int dc_low_on_data: 1; /*!< If this flag is enabled, DC line = 0 means transfer data, DC line = 1 means transfer command; vice versa */ } flags; @@ -127,8 +131,9 @@ esp_err_t esp_lcd_new_panel_io_i2c(esp_lcd_i2c_bus_handle_t bus, const esp_lcd_p typedef struct { int dc_gpio_num; /*!< GPIO used for D/C line */ int wr_gpio_num; /*!< GPIO used for WR line */ + lcd_clock_source_t clk_src; /*!< Clock source for the I80 LCD peripheral */ int data_gpio_nums[SOC_LCD_I80_BUS_WIDTH]; /*!< GPIOs used for data lines */ - size_t data_width; /*!< Number of data lines, 8 or 16 */ + size_t bus_width; /*!< Number of data lines, 8 or 16 */ size_t max_transfer_bytes; /*!< Maximum transfer size, this determines the length of internal DMA link */ } esp_lcd_i80_bus_config_t; @@ -160,11 +165,13 @@ esp_err_t esp_lcd_del_i80_bus(esp_lcd_i80_bus_handle_t bus); * @brief Panel IO configuration structure, for intel 8080 interface */ typedef struct { - int cs_gpio_num; /*!< GPIO used for CS line */ + int cs_gpio_num; /*!< GPIO used for CS line, set to -1 will declaim exclusively use of I80 bus */ unsigned int pclk_hz; /*!< Frequency of pixel clock */ size_t trans_queue_depth; /*!< Transaction queue size, larger queue, higher throughput */ bool (*on_color_trans_done)(esp_lcd_panel_io_handle_t panel_io, void *user_data, void *event_data); /*!< Callback, invoked when color data was tranferred done */ - void *user_data; /*!< User private data, passed directly to on_trans_done's user_data */ + void *user_data; /*!< User private data, passed directly to on_trans_done's user_data */ + int lcd_cmd_bits; /*!< Bit-width of LCD command */ + int lcd_param_bits; /*!< Bit-width of LCD parameter */ struct { unsigned int dc_idle_level: 1; /*!< Level of DC line in IDLE phase */ unsigned int dc_cmd_level: 1; /*!< Level of DC line in CMD phase */ @@ -172,7 +179,7 @@ typedef struct { unsigned int dc_data_level: 1; /*!< Level of DC line in DATA phase */ } dc_levels; /*!< Each i80 device might have its own D/C control logic */ struct { - unsigned int invert_cs: 1; /*!< Whether to invert the CS line */ + unsigned int cs_active_high: 1; /*!< If set, a high level of CS line will select the device, otherwise, CS line is low level active */ unsigned int reverse_color_bits: 1; /*!< Reverse the data bits, D[N:0] -> D[0:N] */ unsigned int swap_color_bytes: 1; /*!< Swap adjacent two color bytes */ unsigned int pclk_active_neg: 1; /*!< The display will write data lines when there's a falling edge on WR signal (a.k.a the PCLK) */ diff --git a/tools/sdk/esp32c3/include/esp_lcd/include/esp_lcd_panel_rgb.h b/tools/sdk/esp32c3/include/esp_lcd/include/esp_lcd_panel_rgb.h index 0847e84bd21..2ddd2b6b9a6 100644 --- a/tools/sdk/esp32c3/include/esp_lcd/include/esp_lcd_panel_rgb.h +++ b/tools/sdk/esp32c3/include/esp_lcd/include/esp_lcd_panel_rgb.h @@ -9,6 +9,7 @@ #include "esp_err.h" #include "esp_lcd_types.h" #include "soc/soc_caps.h" +#include "hal/lcd_types.h" #ifdef __cplusplus extern "C" { @@ -41,6 +42,7 @@ typedef struct { * @brief LCD RGB panel configuration structure */ typedef struct { + lcd_clock_source_t clk_src; /*!< Clock source for the RGB LCD peripheral */ esp_lcd_rgb_timing_t timings; /*!< RGB timing parameters */ size_t data_width; /*!< Number of data lines */ int hsync_gpio_num; /*!< GPIO used for HSYNC signal */ @@ -54,6 +56,7 @@ typedef struct { struct { unsigned int disp_active_low: 1; /*!< If this flag is enabled, a low level of display control signal can turn the screen on; vice versa */ unsigned int relax_on_idle: 1; /*!< If this flag is enabled, the host won't refresh the LCD if nothing changed in host's frame buffer (this is usefull for LCD with built-in GRAM) */ + unsigned int fb_in_psram: 1; /*!< If this flag is enabled, the frame buffer will be allocated from PSRAM preferentially */ } flags; } esp_lcd_rgb_panel_config_t; diff --git a/tools/sdk/esp32c3/include/esp_lcd/include/esp_lcd_panel_vendor.h b/tools/sdk/esp32c3/include/esp_lcd/include/esp_lcd_panel_vendor.h index ac98cc3913d..dde8be68d3b 100644 --- a/tools/sdk/esp32c3/include/esp_lcd/include/esp_lcd_panel_vendor.h +++ b/tools/sdk/esp32c3/include/esp_lcd/include/esp_lcd_panel_vendor.h @@ -39,6 +39,19 @@ typedef struct { */ esp_err_t esp_lcd_new_panel_st7789(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config, esp_lcd_panel_handle_t *ret_panel); +/** + * @brief Create LCD panel for model NT35510 + * + * @param[in] io LCD panel IO handle + * @param[in] panel_dev_config general panel device configuration + * @param[out] ret_panel Returned LCD panel handle + * @return + * - ESP_ERR_INVALID_ARG if parameter is invalid + * - ESP_ERR_NO_MEM if out of memory + * - ESP_OK on success + */ +esp_err_t esp_lcd_new_panel_nt35510(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config, esp_lcd_panel_handle_t *ret_panel); + /** * @brief Create LCD panel for model SSD1306 * diff --git a/tools/sdk/esp32c3/include/esp_lcd/interface/esp_lcd_panel_io_interface.h b/tools/sdk/esp32c3/include/esp_lcd/interface/esp_lcd_panel_io_interface.h index b6b85564cd5..2faa6fab268 100644 --- a/tools/sdk/esp32c3/include/esp_lcd/interface/esp_lcd_panel_io_interface.h +++ b/tools/sdk/esp32c3/include/esp_lcd/interface/esp_lcd_panel_io_interface.h @@ -25,14 +25,13 @@ struct esp_lcd_panel_io_t { * * @param[in] io LCD panel IO handle, which is created by other factory API like `esp_lcd_new_panel_io_spi()` * @param[in] lcd_cmd The specific LCD command - * @param[in] lcd_cmd_bits Length of LCD command, in bits (e.g. 8 bits or 16 bits) * @param[in] param Buffer that holds the command specific parameters, set to NULL if no parameter is needed for the command * @param[in] param_size Size of `param` in memory, in bytes, set to zero if no parameter is needed for the command * @return * - ESP_ERR_INVALID_ARG if parameter is invalid * - ESP_OK on success */ - esp_err_t (*tx_param)(esp_lcd_panel_io_t *io, int lcd_cmd, int lcd_cmd_bits, const void *param, size_t param_size); + esp_err_t (*tx_param)(esp_lcd_panel_io_t *io, int lcd_cmd, const void *param, size_t param_size); /** * @brief Transmit LCD RGB data @@ -41,14 +40,13 @@ struct esp_lcd_panel_io_t { * * @param[in] io LCD panel IO handle, which is created by other factory API like `esp_lcd_new_panel_io_spi()` * @param[in] lcd_cmd The specific LCD command - * @param[in] lcd_cmd_bits Length of LCD command, in bits (e.g. 8 bits or 16 bits) * @param[in] color Buffer that holds the RGB color data * @param[in] color_size Size of `color` in memory, in bytes * @return * - ESP_ERR_INVALID_ARG if parameter is invalid * - ESP_OK on success */ - esp_err_t (*tx_color)(esp_lcd_panel_io_t *io, int lcd_cmd, int lcd_cmd_bits, const void *color, size_t color_size); + esp_err_t (*tx_color)(esp_lcd_panel_io_t *io, int lcd_cmd, const void *color, size_t color_size); /** * @brief Destory LCD panel IO handle (deinitialize all and free resource) diff --git a/tools/sdk/esp32c3/include/esp_littlefs/src/littlefs/lfs.h b/tools/sdk/esp32c3/include/esp_littlefs/src/littlefs/lfs.h index 35bbbabfa7b..ad491627fe1 100644 --- a/tools/sdk/esp32c3/include/esp_littlefs/src/littlefs/lfs.h +++ b/tools/sdk/esp32c3/include/esp_littlefs/src/littlefs/lfs.h @@ -9,6 +9,7 @@ #include #include +#include "lfs_util.h" #ifdef __cplusplus extern "C" @@ -21,7 +22,7 @@ extern "C" // Software library version // Major (top-nibble), incremented on backwards incompatible changes // Minor (bottom-nibble), incremented on feature additions -#define LFS_VERSION 0x00020002 +#define LFS_VERSION 0x00020004 #define LFS_VERSION_MAJOR (0xffff & (LFS_VERSION >> 16)) #define LFS_VERSION_MINOR (0xffff & (LFS_VERSION >> 0)) @@ -123,20 +124,25 @@ enum lfs_type { enum lfs_open_flags { // open flags LFS_O_RDONLY = 1, // Open a file as read only +#ifndef LFS_READONLY LFS_O_WRONLY = 2, // Open a file as write only LFS_O_RDWR = 3, // Open a file as read and write LFS_O_CREAT = 0x0100, // Create a file if it does not exist LFS_O_EXCL = 0x0200, // Fail if a file already exists LFS_O_TRUNC = 0x0400, // Truncate the existing file to zero size LFS_O_APPEND = 0x0800, // Move to end of file on every write +#endif // internally used flags +#ifndef LFS_READONLY LFS_F_DIRTY = 0x010000, // File does not match storage LFS_F_WRITING = 0x020000, // File has been written since last flush +#endif LFS_F_READING = 0x040000, // File has been read since last flush - LFS_F_ERRED = 0x080000, // An error occured during write +#ifndef LFS_READONLY + LFS_F_ERRED = 0x080000, // An error occurred during write +#endif LFS_F_INLINE = 0x100000, // Currently inlined in directory entry - LFS_F_OPENED = 0x200000, // File has been opened }; // File seek flags @@ -174,6 +180,16 @@ struct lfs_config { // are propogated to the user. int (*sync)(const struct lfs_config *c); +#ifdef LFS_THREADSAFE + // Lock the underlying block device. Negative error codes + // are propogated to the user. + int (*lock)(const struct lfs_config *c); + + // Unlock the underlying block device. Negative error codes + // are propogated to the user. + int (*unlock)(const struct lfs_config *c); +#endif + // Minimum size of a block read. All read operations will be a // multiple of this value. lfs_size_t read_size; @@ -191,7 +207,7 @@ struct lfs_config { // Number of erasable blocks on the device. lfs_size_t block_count; - // Number of erase cycles before littlefs evicts metadata logs and moves + // Number of erase cycles before littlefs evicts metadata logs and moves // the metadata to another block. Suggested values are in the // range 100-1000, with large values having better performance at the cost // of less consistent wear distribution. @@ -240,6 +256,12 @@ struct lfs_config { // larger attributes size but must be <= LFS_ATTR_MAX. Defaults to // LFS_ATTR_MAX when zero. lfs_size_t attr_max; + + // Optional upper limit on total space given to metadata pairs in bytes. On + // devices with large blocks (e.g. 128kB) setting this to a low size (2-8kB) + // can help bound the metadata compaction time. Must be <= block_size. + // Defaults to block_size when zero. + lfs_size_t metadata_max; }; // File info structure @@ -399,6 +421,7 @@ typedef struct lfs { /// Filesystem functions /// +#ifndef LFS_READONLY // Format a block device with the littlefs // // Requires a littlefs object and config struct. This clobbers the littlefs @@ -407,6 +430,7 @@ typedef struct lfs { // // Returns a negative error code on failure. int lfs_format(lfs_t *lfs, const struct lfs_config *config); +#endif // Mounts a littlefs // @@ -426,12 +450,15 @@ int lfs_unmount(lfs_t *lfs); /// General operations /// +#ifndef LFS_READONLY // Removes a file or directory // // If removing a directory, the directory must be empty. // Returns a negative error code on failure. int lfs_remove(lfs_t *lfs, const char *path); +#endif +#ifndef LFS_READONLY // Rename or move a file or directory // // If the destination exists, it must match the source in type. @@ -439,6 +466,7 @@ int lfs_remove(lfs_t *lfs, const char *path); // // Returns a negative error code on failure. int lfs_rename(lfs_t *lfs, const char *oldpath, const char *newpath); +#endif // Find info about a file or directory // @@ -461,6 +489,7 @@ int lfs_stat(lfs_t *lfs, const char *path, struct lfs_info *info); lfs_ssize_t lfs_getattr(lfs_t *lfs, const char *path, uint8_t type, void *buffer, lfs_size_t size); +#ifndef LFS_READONLY // Set custom attributes // // Custom attributes are uniquely identified by an 8-bit type and limited @@ -470,13 +499,16 @@ lfs_ssize_t lfs_getattr(lfs_t *lfs, const char *path, // Returns a negative error code on failure. int lfs_setattr(lfs_t *lfs, const char *path, uint8_t type, const void *buffer, lfs_size_t size); +#endif +#ifndef LFS_READONLY // Removes a custom attribute // // If an attribute is not found, nothing happens. // // Returns a negative error code on failure. int lfs_removeattr(lfs_t *lfs, const char *path, uint8_t type); +#endif /// File operations /// @@ -525,6 +557,7 @@ int lfs_file_sync(lfs_t *lfs, lfs_file_t *file); lfs_ssize_t lfs_file_read(lfs_t *lfs, lfs_file_t *file, void *buffer, lfs_size_t size); +#ifndef LFS_READONLY // Write data to file // // Takes a buffer and size indicating the data to write. The file will not @@ -533,6 +566,7 @@ lfs_ssize_t lfs_file_read(lfs_t *lfs, lfs_file_t *file, // Returns the number of bytes written, or a negative error code on failure. lfs_ssize_t lfs_file_write(lfs_t *lfs, lfs_file_t *file, const void *buffer, lfs_size_t size); +#endif // Change the position of the file // @@ -541,10 +575,12 @@ lfs_ssize_t lfs_file_write(lfs_t *lfs, lfs_file_t *file, lfs_soff_t lfs_file_seek(lfs_t *lfs, lfs_file_t *file, lfs_soff_t off, int whence); +#ifndef LFS_READONLY // Truncates the size of the file to the specified size // // Returns a negative error code on failure. int lfs_file_truncate(lfs_t *lfs, lfs_file_t *file, lfs_off_t size); +#endif // Return the position of the file // @@ -567,10 +603,12 @@ lfs_soff_t lfs_file_size(lfs_t *lfs, lfs_file_t *file); /// Directory operations /// +#ifndef LFS_READONLY // Create a directory // // Returns a negative error code on failure. int lfs_mkdir(lfs_t *lfs, const char *path); +#endif // Open a directory // @@ -632,6 +670,7 @@ lfs_ssize_t lfs_fs_size(lfs_t *lfs); // Returns a negative error code on failure. int lfs_fs_traverse(lfs_t *lfs, int (*cb)(void*, lfs_block_t), void *data); +#ifndef LFS_READONLY #ifdef LFS_MIGRATE // Attempts to migrate a previous version of littlefs // @@ -646,6 +685,7 @@ int lfs_fs_traverse(lfs_t *lfs, int (*cb)(void*, lfs_block_t), void *data); // Returns a negative error code on failure. int lfs_migrate(lfs_t *lfs, const struct lfs_config *cfg); #endif +#endif #ifdef __cplusplus diff --git a/tools/sdk/esp32c3/include/esp_littlefs/src/littlefs/lfs_util.h b/tools/sdk/esp32c3/include/esp_littlefs/src/littlefs/lfs_util.h index dbb4c5ba866..fc1b0c2ae86 100644 --- a/tools/sdk/esp32c3/include/esp_littlefs/src/littlefs/lfs_util.h +++ b/tools/sdk/esp32c3/include/esp_littlefs/src/littlefs/lfs_util.h @@ -49,6 +49,7 @@ extern "C" // code footprint // Logging functions +#ifndef LFS_TRACE #ifdef LFS_YES_TRACE #define LFS_TRACE_(fmt, ...) \ printf("%s:%d:trace: " fmt "%s\n", __FILE__, __LINE__, __VA_ARGS__) @@ -56,7 +57,9 @@ extern "C" #else #define LFS_TRACE(...) #endif +#endif +#ifndef LFS_DEBUG #ifndef LFS_NO_DEBUG #define LFS_DEBUG_(fmt, ...) \ printf("%s:%d:debug: " fmt "%s\n", __FILE__, __LINE__, __VA_ARGS__) @@ -64,7 +67,9 @@ extern "C" #else #define LFS_DEBUG(...) #endif +#endif +#ifndef LFS_WARN #ifndef LFS_NO_WARN #define LFS_WARN_(fmt, ...) \ printf("%s:%d:warn: " fmt "%s\n", __FILE__, __LINE__, __VA_ARGS__) @@ -72,7 +77,9 @@ extern "C" #else #define LFS_WARN(...) #endif +#endif +#ifndef LFS_ERROR #ifndef LFS_NO_ERROR #define LFS_ERROR_(fmt, ...) \ printf("%s:%d:error: " fmt "%s\n", __FILE__, __LINE__, __VA_ARGS__) @@ -80,13 +87,16 @@ extern "C" #else #define LFS_ERROR(...) #endif +#endif // Runtime assertions +#ifndef LFS_ASSERT #ifndef LFS_NO_ASSERT #define LFS_ASSERT(test) assert(test) #else #define LFS_ASSERT(test) #endif +#endif // Builtin functions, these may be replaced by more efficient diff --git a/tools/sdk/esp32c3/include/esp_local_ctrl/include/esp_local_ctrl.h b/tools/sdk/esp32c3/include/esp_local_ctrl/include/esp_local_ctrl.h index 9f4f89daa31..8322412eb3a 100644 --- a/tools/sdk/esp32c3/include/esp_local_ctrl/include/esp_local_ctrl.h +++ b/tools/sdk/esp32c3/include/esp_local_ctrl/include/esp_local_ctrl.h @@ -228,6 +228,37 @@ typedef union { esp_local_ctrl_transport_config_httpd_t *httpd; } esp_local_ctrl_transport_config_t; +/** + * @brief Security types for esp_local_control + */ +typedef enum esp_local_ctrl_proto_sec { + PROTOCOM_SEC0 = 0, + PROTOCOM_SEC1, + PROTOCOM_SEC_CUSTOM, +} esp_local_ctrl_proto_sec_t; + +/** + * Protocom security configs + */ +typedef struct esp_local_ctrl_proto_sec_cfg { + /** + * This sets protocom security version, sec0/sec1 or custom + * If custom, user must provide handle via `proto_sec_custom_handle` below + */ + esp_local_ctrl_proto_sec_t version; + + /** + * Custom security handle if security is set custom via `proto_sec` above + * This handle must follow `protocomm_security_t` signature + */ + void *custom_handle; + + /** + * Proof of possession to be used for local control. Could be NULL. + */ + void *pop; +} esp_local_ctrl_proto_sec_cfg_t; + /** * @brief Configuration structure to pass to `esp_local_ctrl_start()` */ @@ -242,6 +273,11 @@ typedef struct esp_local_ctrl_config { */ esp_local_ctrl_transport_config_t transport_config; + /** + * Security version and POP + */ + esp_local_ctrl_proto_sec_cfg_t proto_sec; + /** * Register handlers for responding to get/set requests on properties */ diff --git a/tools/sdk/esp32c3/include/esp_netif/include/esp_netif_ppp.h b/tools/sdk/esp32c3/include/esp_netif/include/esp_netif_ppp.h index 413910c4331..159388e80ea 100644 --- a/tools/sdk/esp32c3/include/esp_netif/include/esp_netif_ppp.h +++ b/tools/sdk/esp32c3/include/esp_netif/include/esp_netif_ppp.h @@ -38,6 +38,11 @@ typedef struct esp_netif_ppp_config { */ #define NETIF_PP_PHASE_OFFSET (0x100) +/** @brief event id offset for internal errors + * + */ +#define NETIF_PPP_INTERNAL_ERR_OFFSET (0x200) + /** @brief event ids for different PPP related events * */ @@ -68,6 +73,7 @@ typedef enum { NETIF_PPP_PHASE_RUNNING = NETIF_PP_PHASE_OFFSET + 10, NETIF_PPP_PHASE_TERMINATE = NETIF_PP_PHASE_OFFSET + 11, NETIF_PPP_PHASE_DISCONNECT = NETIF_PP_PHASE_OFFSET + 12, + NETIF_PPP_CONNECT_FAILED = NETIF_PPP_INTERNAL_ERR_OFFSET + 0, } esp_netif_ppp_status_event_t; /** @brief definitions of different authorisation types @@ -89,7 +95,8 @@ typedef enum { * @param[in] user User name * @param[in] passwd Password * - * @return ESP_OK on success, ESP_ERR_ESP_NETIF_INVALID_PARAMS if netif null or not PPP + * @return ESP_OK on success, + * ESP_ERR_ESP_NETIF_INVALID_PARAMS if the supplied netif is not of PPP type, or netif is null */ esp_err_t esp_netif_ppp_set_auth(esp_netif_t *netif, esp_netif_auth_type_t authtype, const char *user, const char *passwd); @@ -98,10 +105,20 @@ esp_err_t esp_netif_ppp_set_auth(esp_netif_t *netif, esp_netif_auth_type_t autht * @param[in] esp_netif Handle to esp-netif instance * @param[in] config Pointer to PPP netif configuration structure * - * @return ESP_OK on success, ESP_ERR_ESP_NETIF_INVALID_PARAMS if netif null or not PPP + * @return ESP_OK on success, + * ESP_ERR_ESP_NETIF_INVALID_PARAMS if the supplied netif is not of PPP type, or netif is null */ esp_err_t esp_netif_ppp_set_params(esp_netif_t *netif, const esp_netif_ppp_config_t *config); +/** @brief Gets parameters configured in the supplied esp-netif. + * + * @param[in] esp_netif Handle to esp-netif instance + * @param[out] config Pointer to PPP netif configuration structure + * + * @return ESP_OK on success, + * ESP_ERR_ESP_NETIF_INVALID_PARAMS if the supplied netif is not of PPP type, or netif is null + */ +esp_err_t esp_netif_ppp_get_params(esp_netif_t *netif, esp_netif_ppp_config_t *config); #ifdef __cplusplus } diff --git a/tools/sdk/esp32c3/include/esp_phy/include/phy.h b/tools/sdk/esp32c3/include/esp_phy/include/phy.h index c0eadbf2ba4..51b972bb6ca 100644 --- a/tools/sdk/esp32c3/include/esp_phy/include/phy.h +++ b/tools/sdk/esp32c3/include/esp_phy/include/phy.h @@ -69,7 +69,7 @@ void phy_wakeup_init(void); */ void phy_close_rf(void); -#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2 +#if !CONFIG_IDF_TARGET_ESP32 /** * @brief Disable PHY temperature sensor. */ diff --git a/tools/sdk/esp32c3/include/esp_rom/esp32c3/esp_rom_caps.h b/tools/sdk/esp32c3/include/esp_rom/esp32c3/esp_rom_caps.h index de9eda41fb3..7a210f1a536 100644 --- a/tools/sdk/esp32c3/include/esp_rom/esp32c3/esp_rom_caps.h +++ b/tools/sdk/esp32c3/include/esp_rom/esp32c3/esp_rom_caps.h @@ -20,3 +20,4 @@ #define ESP_ROM_UART_CLK_IS_XTAL (1) // UART clock source is selected to XTAL in ROM #define ESP_ROM_USB_SERIAL_DEVICE_NUM (3) // UART uses USB_SERIAL_JTAG port in ROM. #define ESP_ROM_HAS_RETARGETABLE_LOCKING (1) // ROM was built with retargetable locking +#define ESP_ROM_HAS_ERASE_0_REGION_BUG (1) // ROM has esp_flash_erase_region(size=0) bug diff --git a/tools/sdk/esp32c3/include/esp_rom/include/esp32/rom/spi_flash.h b/tools/sdk/esp32c3/include/esp_rom/include/esp32/rom/spi_flash.h index 6d162343f34..500ba300cbb 100644 --- a/tools/sdk/esp32c3/include/esp_rom/include/esp32/rom/spi_flash.h +++ b/tools/sdk/esp32c3/include/esp_rom/include/esp32/rom/spi_flash.h @@ -260,7 +260,7 @@ esp_rom_spiflash_result_t esp_rom_spiflash_read_status(esp_rom_spiflash_chip_t * esp_rom_spiflash_result_t esp_rom_spiflash_read_statushigh(esp_rom_spiflash_chip_t *spi, uint32_t *status); /** - * @brief Write status to Falsh status register. + * @brief Write status to Flash status register. * Please do not call this function in SDK. * * @param esp_rom_spiflash_chip_t *spi : The information for Flash, which is exported from ld file. diff --git a/tools/sdk/esp32c3/include/esp_rom/include/esp32c3/rom/newlib.h b/tools/sdk/esp32c3/include/esp_rom/include/esp32c3/rom/newlib.h deleted file mode 100644 index a852bdb7f5b..00000000000 --- a/tools/sdk/esp32c3/include/esp_rom/include/esp32c3/rom/newlib.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2020 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 -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Global variables used by newlib in ROM - - Note that any of these symbols which are used by both ROM & IDF will have duplicate copies - in each "side" of the memory. However they're all pointers, and the pointers will be to the same - thing, so it's not a big memory waste and functionality is the same. - - Some variables which look like they should be here, but aren't: - - - __sf_fake_stdin, __sf_fake_stdout, __sf_fake_stderr - These are defined in ROM because ROM includes findfp.c, - but only used if _REENT_INIT or _REENT_INIT_PTR are ever called and ROM doesn't use these macros anywhere unless - printf() or similar is called without initializing reent first. ESP-IDF sets up its own minimal reent structures. - - - __lock___sinit_recursive_mutex, etc. - these are combined into common_recursive_mutex & common_mutex to save space -*/ -typedef struct { - _LOCK_T common_recursive_mutex; - _LOCK_T common_mutex; - struct _reent *global_reent; -} esp_rom_newlib_global_data_t; - -/* Called from IDF newlib component setup - to initialize common data shared between ROM and IDF -*/ -void esp_rom_newlib_init_global_data(const esp_rom_newlib_global_data_t *data); - -#ifdef __cplusplus -} -#endif diff --git a/tools/sdk/esp32c3/include/esp_rom/include/esp32c3/rom/rtc.h b/tools/sdk/esp32c3/include/esp_rom/include/esp32c3/rom/rtc.h index 76ece7e8194..2a7f6cb6140 100644 --- a/tools/sdk/esp32c3/include/esp_rom/include/esp32c3/rom/rtc.h +++ b/tools/sdk/esp32c3/include/esp_rom/include/esp32c3/rom/rtc.h @@ -85,8 +85,7 @@ typedef enum { NO_MEAN = 0, POWERON_RESET = 1, /**<1, Vbat power on reset*/ RTC_SW_SYS_RESET = 3, /**<3, Software reset digital core*/ - DEEPSLEEP_RESET = 5, /**<3, Deep Sleep reset digital core*/ - SDIO_RESET = 6, /**<6, Reset by SLC module, reset digital core*/ + DEEPSLEEP_RESET = 5, /**<5, Deep Sleep reset digital core*/ TG0WDT_SYS_RESET = 7, /**<7, Timer Group0 Watch dog reset digital core*/ TG1WDT_SYS_RESET = 8, /**<8, Timer Group1 Watch dog reset digital core*/ RTCWDT_SYS_RESET = 9, /**<9, RTC Watch dog Reset digital core*/ @@ -96,8 +95,13 @@ typedef enum { RTCWDT_CPU_RESET = 13, /**<13, RTC Watch dog Reset CPU*/ RTCWDT_BROWN_OUT_RESET = 15, /**<15, Reset when the vdd voltage is not stable*/ RTCWDT_RTC_RESET = 16, /**<16, RTC Watch dog reset digital core and rtc module*/ - TG1WDT_CPU_RESET = 17, /**<11, Time Group1 reset CPU*/ - SUPER_WDT_RESET = 18, /**<11, super watchdog reset digital core and rtc module*/ + TG1WDT_CPU_RESET = 17, /**<17, Time Group1 reset CPU*/ + SUPER_WDT_RESET = 18, /**<18, super watchdog reset digital core and rtc module*/ + GLITCH_RTC_RESET = 19, /**<19, glitch reset digital core and rtc module*/ + EFUSE_RESET = 20, /**<20, efuse reset digital core*/ + USB_UART_CHIP_RESET = 21, /**<21, usb uart reset digital core */ + USB_JTAG_CHIP_RESET = 22, /**<22, usb jtag reset digital core */ + POWER_GLITCH_RESET = 23, /**<23, power glitch reset digital core and rtc module*/ } RESET_REASON; // Check if the reset reason defined in ROM is compatible with soc/reset_reasons.h @@ -112,7 +116,13 @@ _Static_assert((soc_reset_reason_t)RTC_SW_CPU_RESET == RESET_REASON_CPU0_SW, "RT _Static_assert((soc_reset_reason_t)RTCWDT_CPU_RESET == RESET_REASON_CPU0_RTC_WDT, "RTCWDT_CPU_RESET != RESET_REASON_CPU0_RTC_WDT"); _Static_assert((soc_reset_reason_t)RTCWDT_BROWN_OUT_RESET == RESET_REASON_SYS_BROWN_OUT, "RTCWDT_BROWN_OUT_RESET != RESET_REASON_SYS_BROWN_OUT"); _Static_assert((soc_reset_reason_t)RTCWDT_RTC_RESET == RESET_REASON_SYS_RTC_WDT, "RTCWDT_RTC_RESET != RESET_REASON_SYS_RTC_WDT"); +_Static_assert((soc_reset_reason_t)TG1WDT_CPU_RESET == RESET_REASON_CPU0_MWDT1, "TG1WDT_CPU_RESET != RESET_REASON_CPU0_MWDT1"); _Static_assert((soc_reset_reason_t)SUPER_WDT_RESET == RESET_REASON_SYS_SUPER_WDT, "SUPER_WDT_RESET != RESET_REASON_SYS_SUPER_WDT"); +_Static_assert((soc_reset_reason_t)GLITCH_RTC_RESET == RESET_REASON_SYS_CLK_GLITCH, "GLITCH_RTC_RESET != RESET_REASON_SYS_CLK_GLITCH"); +_Static_assert((soc_reset_reason_t)EFUSE_RESET == RESET_REASON_CORE_EFUSE_CRC, "EFUSE_RESET != RESET_REASON_CORE_EFUSE_CRC"); +_Static_assert((soc_reset_reason_t)USB_UART_CHIP_RESET == RESET_REASON_CORE_USB_UART, "USB_UART_CHIP_RESET != RESET_REASON_CORE_USB_UART"); +_Static_assert((soc_reset_reason_t)USB_JTAG_CHIP_RESET == RESET_REASON_CORE_USB_JTAG, "USB_JTAG_CHIP_RESET != RESET_REASON_CORE_USB_JTAG"); +_Static_assert((soc_reset_reason_t)POWER_GLITCH_RESET == RESET_REASON_CORE_PWR_GLITCH, "POWER_GLITCH_RESET != RESET_REASON_CORE_PWR_GLITCH"); typedef enum { NO_SLEEP = 0, diff --git a/tools/sdk/esp32c3/include/esp_rom/include/esp32h2/rom/newlib.h b/tools/sdk/esp32c3/include/esp_rom/include/esp32h2/rom/newlib.h deleted file mode 100644 index a852bdb7f5b..00000000000 --- a/tools/sdk/esp32c3/include/esp_rom/include/esp32h2/rom/newlib.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2020 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 -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Global variables used by newlib in ROM - - Note that any of these symbols which are used by both ROM & IDF will have duplicate copies - in each "side" of the memory. However they're all pointers, and the pointers will be to the same - thing, so it's not a big memory waste and functionality is the same. - - Some variables which look like they should be here, but aren't: - - - __sf_fake_stdin, __sf_fake_stdout, __sf_fake_stderr - These are defined in ROM because ROM includes findfp.c, - but only used if _REENT_INIT or _REENT_INIT_PTR are ever called and ROM doesn't use these macros anywhere unless - printf() or similar is called without initializing reent first. ESP-IDF sets up its own minimal reent structures. - - - __lock___sinit_recursive_mutex, etc. - these are combined into common_recursive_mutex & common_mutex to save space -*/ -typedef struct { - _LOCK_T common_recursive_mutex; - _LOCK_T common_mutex; - struct _reent *global_reent; -} esp_rom_newlib_global_data_t; - -/* Called from IDF newlib component setup - to initialize common data shared between ROM and IDF -*/ -void esp_rom_newlib_init_global_data(const esp_rom_newlib_global_data_t *data); - -#ifdef __cplusplus -} -#endif diff --git a/tools/sdk/esp32c3/include/esp_rom/include/esp32h2/rom/rtc.h b/tools/sdk/esp32c3/include/esp_rom/include/esp32h2/rom/rtc.h index 76ece7e8194..ad4f45c2ca7 100644 --- a/tools/sdk/esp32c3/include/esp_rom/include/esp32h2/rom/rtc.h +++ b/tools/sdk/esp32c3/include/esp_rom/include/esp32h2/rom/rtc.h @@ -85,8 +85,7 @@ typedef enum { NO_MEAN = 0, POWERON_RESET = 1, /**<1, Vbat power on reset*/ RTC_SW_SYS_RESET = 3, /**<3, Software reset digital core*/ - DEEPSLEEP_RESET = 5, /**<3, Deep Sleep reset digital core*/ - SDIO_RESET = 6, /**<6, Reset by SLC module, reset digital core*/ + DEEPSLEEP_RESET = 5, /**<5, Deep Sleep reset digital core*/ TG0WDT_SYS_RESET = 7, /**<7, Timer Group0 Watch dog reset digital core*/ TG1WDT_SYS_RESET = 8, /**<8, Timer Group1 Watch dog reset digital core*/ RTCWDT_SYS_RESET = 9, /**<9, RTC Watch dog Reset digital core*/ @@ -96,8 +95,14 @@ typedef enum { RTCWDT_CPU_RESET = 13, /**<13, RTC Watch dog Reset CPU*/ RTCWDT_BROWN_OUT_RESET = 15, /**<15, Reset when the vdd voltage is not stable*/ RTCWDT_RTC_RESET = 16, /**<16, RTC Watch dog reset digital core and rtc module*/ - TG1WDT_CPU_RESET = 17, /**<11, Time Group1 reset CPU*/ - SUPER_WDT_RESET = 18, /**<11, super watchdog reset digital core and rtc module*/ + TG1WDT_CPU_RESET = 17, /**<17, Time Group1 reset CPU*/ + SUPER_WDT_RESET = 18, /**<18, super watchdog reset digital core and rtc module*/ + GLITCH_RTC_RESET = 19, /**<19, glitch reset digital core and rtc module*/ + EFUSE_RESET = 20, /**<20, efuse reset digital core*/ + USB_UART_CHIP_RESET = 21, /**<21, usb uart reset digital core */ + USB_JTAG_CHIP_RESET = 22, /**<22, usb jtag reset digital core */ + POWER_GLITCH_RESET = 23, /**<23, power glitch reset digital core and rtc module*/ + JTAG_RESET = 24, /**<24, jtag reset CPU*/ } RESET_REASON; // Check if the reset reason defined in ROM is compatible with soc/reset_reasons.h @@ -112,7 +117,14 @@ _Static_assert((soc_reset_reason_t)RTC_SW_CPU_RESET == RESET_REASON_CPU0_SW, "RT _Static_assert((soc_reset_reason_t)RTCWDT_CPU_RESET == RESET_REASON_CPU0_RTC_WDT, "RTCWDT_CPU_RESET != RESET_REASON_CPU0_RTC_WDT"); _Static_assert((soc_reset_reason_t)RTCWDT_BROWN_OUT_RESET == RESET_REASON_SYS_BROWN_OUT, "RTCWDT_BROWN_OUT_RESET != RESET_REASON_SYS_BROWN_OUT"); _Static_assert((soc_reset_reason_t)RTCWDT_RTC_RESET == RESET_REASON_SYS_RTC_WDT, "RTCWDT_RTC_RESET != RESET_REASON_SYS_RTC_WDT"); +_Static_assert((soc_reset_reason_t)TG1WDT_CPU_RESET == RESET_REASON_CPU0_MWDT1, "TG1WDT_CPU_RESET != RESET_REASON_CPU0_MWDT1"); _Static_assert((soc_reset_reason_t)SUPER_WDT_RESET == RESET_REASON_SYS_SUPER_WDT, "SUPER_WDT_RESET != RESET_REASON_SYS_SUPER_WDT"); +_Static_assert((soc_reset_reason_t)GLITCH_RTC_RESET == RESET_REASON_SYS_CLK_GLITCH, "GLITCH_RTC_RESET != RESET_REASON_SYS_CLK_GLITCH"); +_Static_assert((soc_reset_reason_t)EFUSE_RESET == RESET_REASON_CORE_EFUSE_CRC, "EFUSE_RESET != RESET_REASON_CORE_EFUSE_CRC"); +_Static_assert((soc_reset_reason_t)USB_UART_CHIP_RESET == RESET_REASON_CORE_USB_UART, "USB_UART_CHIP_RESET != RESET_REASON_CORE_USB_UART"); +_Static_assert((soc_reset_reason_t)USB_JTAG_CHIP_RESET == RESET_REASON_CORE_USB_JTAG, "USB_JTAG_CHIP_RESET != RESET_REASON_CORE_USB_JTAG"); +_Static_assert((soc_reset_reason_t)POWER_GLITCH_RESET == RESET_REASON_CORE_PWR_GLITCH, "POWER_GLITCH_RESET != RESET_REASON_CORE_PWR_GLITCH"); +_Static_assert((soc_reset_reason_t)JTAG_RESET == RESET_REASON_CPU_JTAG, "JTAG_RESET != RESET_REASON_CPU_JTAG"); typedef enum { NO_SLEEP = 0, diff --git a/tools/sdk/esp32c3/include/esp_rom/include/esp32s2/rom/opi_flash.h b/tools/sdk/esp32c3/include/esp_rom/include/esp32s2/rom/opi_flash.h index c985810b678..bb209f67f05 100644 --- a/tools/sdk/esp32c3/include/esp_rom/include/esp32s2/rom/opi_flash.h +++ b/tools/sdk/esp32c3/include/esp_rom/include/esp32s2/rom/opi_flash.h @@ -40,7 +40,6 @@ typedef struct { #define ESP_ROM_SPIFLASH_BP2 BIT4 #define ESP_ROM_SPIFLASH_WR_PROTECT (ESP_ROM_SPIFLASH_BP0|ESP_ROM_SPIFLASH_BP1|ESP_ROM_SPIFLASH_BP2) #define ESP_ROM_SPIFLASH_QE BIT9 -#define ESP_ROM_SPIFLASH_BP_MASK_ISSI (BIT7 | BIT5 | BIT4 | BIT3 | BIT2) #define FLASH_OP_MODE_RDCMD_DOUT 0x3B #define ESP_ROM_FLASH_SECTOR_SIZE 0x1000 diff --git a/tools/sdk/esp32c3/include/esp_rom/include/esp32s2/rom/spi_flash.h b/tools/sdk/esp32c3/include/esp_rom/include/esp32s2/rom/spi_flash.h index c93b4e27c18..beb2fcdf309 100644 --- a/tools/sdk/esp32c3/include/esp_rom/include/esp32s2/rom/spi_flash.h +++ b/tools/sdk/esp32c3/include/esp_rom/include/esp32s2/rom/spi_flash.h @@ -119,7 +119,6 @@ extern "C" { #define ESP_ROM_SPIFLASH_BP2 BIT4 #define ESP_ROM_SPIFLASH_WR_PROTECT (ESP_ROM_SPIFLASH_BP0|ESP_ROM_SPIFLASH_BP1|ESP_ROM_SPIFLASH_BP2) #define ESP_ROM_SPIFLASH_QE BIT9 -#define ESP_ROM_SPIFLASH_BP_MASK_ISSI (BIT7 | BIT5 | BIT4 | BIT3 | BIT2) #define FLASH_ID_GD25LQ32C 0xC86016 diff --git a/tools/sdk/esp32c3/include/esp_rom/include/esp32s2/rom/usb/cpio.h b/tools/sdk/esp32c3/include/esp_rom/include/esp32s2/rom/usb/cpio.h index 5603b3f541a..886b5080fb4 100644 --- a/tools/sdk/esp32c3/include/esp_rom/include/esp32s2/rom/usb/cpio.h +++ b/tools/sdk/esp32c3/include/esp_rom/include/esp32s2/rom/usb/cpio.h @@ -79,7 +79,7 @@ typedef enum { * The initial time with reason=CPIO_RSN_FILE_INITIAL, when more data is available with * CPIO_RSN_FILE_MORE and finally with CPIO_RSN_FILE_END. For these calls, fileinfo * will again contain file information. buff will be the information contained in the - * file at offset buff_offset, and the lenght of this buffer will be in buff_len. + * file at offset buff_offset, and the length of this buffer will be in buff_len. * * The library guarantees to feed all file data to the callback consequitively, so * within the same file, the buff_offset from a call will always be (buff_offset+buff_len) diff --git a/tools/sdk/esp32c3/include/esp_rom/include/esp32s3/rom/apb_backup_dma.h b/tools/sdk/esp32c3/include/esp_rom/include/esp32s3/rom/apb_backup_dma.h new file mode 100644 index 00000000000..324135cb836 --- /dev/null +++ b/tools/sdk/esp32c3/include/esp_rom/include/esp32s3/rom/apb_backup_dma.h @@ -0,0 +1,17 @@ +/* + * SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +void ets_apb_backup_init_lock_func(void(* _apb_backup_lock)(void), void(* _apb_backup_unlock)(void)); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32c3/include/esp_rom/include/esp32s3/rom/cache.h b/tools/sdk/esp32c3/include/esp_rom/include/esp32s3/rom/cache.h index 0ec6308f7cd..27780446fe0 100644 --- a/tools/sdk/esp32c3/include/esp_rom/include/esp32s3/rom/cache.h +++ b/tools/sdk/esp32c3/include/esp_rom/include/esp32s3/rom/cache.h @@ -103,6 +103,11 @@ typedef enum { CACHE_AUTOLOAD_NEGATIVE = 1, /*!< cache autoload step is negative */ } cache_autoload_order_t; +typedef enum { + CACHE_AUTOLOAD_REGION0 = 0, /*!< cache autoload region0 */ + CACHE_AUTOLOAD_REGION1 = 1, /*!< cache autoload region1 */ +} cache_autoload_region_t; + #define CACHE_AUTOLOAD_STEP(i) ((i) - 1) typedef enum { @@ -144,14 +149,17 @@ struct dcache_tag_item { }; struct autoload_config { + uint8_t ena; /*!< autoload enable */ uint8_t order; /*!< autoload step is positive or negative */ uint8_t trigger; /*!< autoload trigger */ - uint8_t ena0; /*!< autoload region0 enable */ - uint8_t ena1; /*!< autoload region1 enable */ - uint32_t addr0; /*!< autoload region0 start address */ - uint32_t size0; /*!< autoload region0 size */ - uint32_t addr1; /*!< autoload region1 start address */ - uint32_t size1; /*!< autoload region1 size */ + uint8_t size; /*!< autoload size */ +}; + +struct autoload_region_config { + uint8_t region; /*!< autoload region*/ + uint8_t ena; /*!< autoload region enable */ + uint32_t addr; /*!< autoload region start address */ + uint32_t size; /*!< autoload region size */ }; struct tag_group_info { @@ -160,6 +168,7 @@ struct tag_group_info { uint32_t vaddr_offset; /*!< virtual address offset of the cache ways */ uint32_t tag_addr[MAX_CACHE_WAYS]; /*!< tag memory address, only [0~mode.ways-1] is valid to use */ uint32_t cache_memory_offset[MAX_CACHE_WAYS]; /*!< cache memory address, only [0~mode.ways-1] is valid to use */ + uint8_t use_legacy; /*!< 1 for using legacy tag api, 0 for using 2rd tag api */ }; struct lock_config { @@ -168,6 +177,39 @@ struct lock_config { uint16_t group; /*!< manual lock group, 0 or 1*/ }; +struct cache_internal_stub_table { + uint32_t (* icache_line_size)(void); + uint32_t (* dcache_line_size)(void); + uint32_t (* icache_addr)(uint32_t addr); + uint32_t (* dcache_addr)(uint32_t addr); + void (* invalidate_icache_items)(uint32_t addr, uint32_t items); + void (* invalidate_dcache_items)(uint32_t addr, uint32_t items); + void (* clean_items)(uint32_t addr, uint32_t items); + void (* writeback_items)(uint32_t addr, uint32_t items); + void (* lock_icache_items)(uint32_t addr, uint32_t items); + void (* lock_dcache_items)(uint32_t addr, uint32_t items); + void (* unlock_icache_items)(uint32_t addr, uint32_t items); + void (* unlock_dcache_items)(uint32_t addr, uint32_t items); + void (* occupy_items)(uint32_t addr, uint32_t items); + uint32_t (* suspend_icache_autoload)(void); + void (* resume_icache_autoload)(uint32_t autoload); + uint32_t (* suspend_dcache_autoload)(void); + void (* resume_dcache_autoload)(uint32_t autoload); + void (* freeze_icache_enable)(cache_freeze_mode_t mode); + void (* freeze_icache_disable)(void); + void (* freeze_dcache_enable)(cache_freeze_mode_t mode); + void (* freeze_dcache_disable)(void); + int (* op_addr)(uint32_t op_icache, uint32_t start_addr, uint32_t size, uint32_t cache_line_size, uint32_t max_sync_num, void(* cache_Iop)(uint32_t, uint32_t), void(* cache_Dop)(uint32_t, uint32_t)); +}; + +typedef void (* cache_op_start)(void); +typedef void (* cache_op_end)(void); + +typedef struct { + cache_op_start start; + cache_op_end end; +} cache_op_cb_t; + #define ESP_ROM_ERR_INVALID_ARG 1 #define MMU_SET_ADDR_ALIGNED_ERROR 2 #define MMU_SET_PASE_SIZE_ERROR 3 @@ -190,7 +232,7 @@ void Cache_MMU_Init(void); * @brief Set ICache mmu mapping. * Please do not call this function in your SDK application. * - * @param uint32_t ext_ram : DPORT_MMU_ACCESS_FLASH for flash, DPORT_MMU_ACCESS_SPIRAM for spiram, DPORT_MMU_INVALID for invalid. + * @param uint32_t ext_ram : MMU_ACCESS_FLASH for flash, MMU_ACCESS_SPIRAM for spiram, MMU_INVALID for invalid. * * @param uint32_t vaddr : virtual address in CPU address space. * Can be Iram0,Iram1,Irom0,Drom0 and AHB buses address. @@ -217,7 +259,7 @@ int Cache_Ibus_MMU_Set(uint32_t ext_ram, uint32_t vaddr, uint32_t paddr, uint32 * @brief Set DCache mmu mapping. * Please do not call this function in your SDK application. * - * @param uint32_t ext_ram : DPORT_MMU_ACCESS_FLASH for flash, DPORT_MMU_ACCESS_SPIRAM for spiram, DPORT_MMU_INVALID for invalid. + * @param uint32_t ext_ram : MMU_ACCESS_FLASH for flash, MMU_ACCESS_SPIRAM for spiram, MMU_INVALID for invalid. * * @param uint32_t vaddr : virtual address in CPU address space. * Can be DRam0, DRam1, DRom0, DPort and AHB buses address. @@ -272,9 +314,9 @@ uint32_t Cache_Flash_To_SPIRAM_Copy(uint32_t bus, uint32_t bus_start_addr, uint3 * @brief allocate memory to used by ICache. * Please do not call this function in your SDK application. * - * @param cache_array_t icache_low : the data array bank used by icache low part, can be CACHE_MEMORY_INVALID, CACHE_MEMORY_IBANK0, CACHE_MEMORY_IBANK1 + * @param cache_array_t icache_low : the data array bank used by icache low part. Due to timing constraint, can only be CACHE_MEMORY_INVALID, CACHE_MEMORY_IBANK0 * - * @param cache_array_t icache_high : the data array bank used by icache high part, can be CACHE_MEMORY_INVALID, CACHE_MEMORY_IBANK0, CACHE_MEMORY_IBANK1 only if icache_low and icache_high is not CACHE_MEMORY_INVALID + * @param cache_array_t icache_high : the data array bank used by icache high part. Due to timing constraint, can only be CACHE_MEMORY_INVALID, or CACHE_MEMORY_IBANK1 only if icache_low and icache_high is CACHE_MEMORY_IBANK0 * * return none */ @@ -284,9 +326,9 @@ void Cache_Occupy_ICache_MEMORY(cache_array_t icache_low, cache_array_t icache_h * @brief allocate memory to used by DCache. * Please do not call this function in your SDK application. * - * @param cache_array_t dcache_low : the data array bank used by dcache low part, can be CACHE_MEMORY_INVALID, CACHE_MEMORY_DBANK0, CACHE_MEMORY_DBANK1 + * @param cache_array_t dcache_low : the data array bank used by dcache low part. Due to timing constraint, can only be CACHE_MEMORY_INVALID, CACHE_MEMORY_DBANK1 * - * @param cache_array_t dcache1_high : the data array bank used by dcache high part, can be CACHE_MEMORY_INVALID, CACHE_MEMORY_DBANK0, CACHE_MEMORY_DBANK1 only if dcache_low0 and dcache_low1 is not CACHE_MEMORY_INVALID + * @param cache_array_t dcache1_high : the data array bank used by dcache high part. Due to timing constraint, can only be CACHE_MEMORY_INVALID, or CACHE_MEMORY_DBANK0 only if dcache_low0 and dcache_low1 is CACHE_MEMORY_DBANK1 * * return none */ @@ -310,7 +352,7 @@ void Cache_Get_Mode(struct cache_mode *mode); * * @param cache_ways_t ways : the associate ways of cache, can be CACHE_4WAYS_ASSOC and CACHE_8WAYS_ASSOC * - * @param cache_line_size_t cache_line_size : the cache line size, can be CACHE_LINE_SIZE_16B, CACHE_LINE_SIZE_32B and CACHE_LINE_SIZE_64B + * @param cache_line_size_t cache_line_size : the cache line size, can be CACHE_LINE_SIZE_16B and CACHE_LINE_SIZE_32B * * return none */ @@ -320,9 +362,9 @@ void Cache_Set_ICache_Mode(cache_size_t cache_size, cache_ways_t ways, cache_lin * @brief set DCache modes: cache size, associate ways and cache line size. * Please do not call this function in your SDK application. * - * @param cache_size_t cache_size : the cache size, can be CACHE_SIZE_8KB and CACHE_SIZE_16KB + * @param cache_size_t cache_size : the cache size, can be CACHE_SIZE_HALF and CACHE_SIZE_FULL * - * @param cache_ways_t ways : the associate ways of cache, can be CACHE_4WAYS_ASSOC and CACHE_8WAYS_ASSOC + * @param cache_ways_t ways : the associate ways of cache, can be CACHE_4WAYS_ASSOC and CACHE_8WAYS_ASSOC, only CACHE_4WAYS_ASSOC works * * @param cache_line_size_t cache_line_size : the cache line size, can be CACHE_LINE_SIZE_16B, CACHE_LINE_SIZE_32B and CACHE_LINE_SIZE_64B * @@ -351,7 +393,7 @@ uint32_t Cache_Address_Through_ICache(uint32_t addr); uint32_t Cache_Address_Through_DCache(uint32_t addr); /** - * @brief Init mmu owner register to make i/d cache use half mmu entries. + * @brief Init Cache for ROM boot, including resetting the Dcache, initializing Owner, MMU, setting DCache mode, Enabling DCache, unmasking bus. * * @param None * @@ -636,6 +678,16 @@ void Cache_End_DCache_Preload(uint32_t autoload); */ void Cache_Config_ICache_Autoload(const struct autoload_config *config); +/** + * @brief Config region autoload parameters of ICache. + * Please do not call this function in your SDK application. + * + * @param struct autoload_region_config * config : region autoload parameters. + * + * @return ESP_ROM_ERR_INVALID_ARG : invalid param, 0 : success + */ +int Cache_Config_ICache_Region_Autoload(const struct autoload_region_config *config); + /** * @brief Enable auto preload for ICache. * Please do not call this function in your SDK application. @@ -666,6 +718,16 @@ void Cache_Disable_ICache_Autoload(void); */ void Cache_Config_DCache_Autoload(const struct autoload_config *config); +/** + * @brief Config region autoload parameters of DCache. + * Please do not call this function in your SDK application. + * + * @param struct autoload_region_config * config : region autoload parameters. + * + * @return ESP_ROM_ERR_INVALID_ARG : invalid param, 0 : success + */ +int Cache_Config_DCache_Region_Autoload(const struct autoload_region_config *config); + /** * @brief Enable auto preload for DCache. * Please do not call this function in your SDK application. @@ -1008,7 +1070,24 @@ void Cache_Freeze_DCache_Disable(void); * * @return None */ -void Cache_Travel_Tag_Memory(struct cache_mode *mode, uint32_t filter_addr, void (* process)(struct tag_group_info *)); +void Cache_Travel_Tag_Memory(struct cache_mode * mode, uint32_t filter_addr, void (* process)(struct tag_group_info *)); + +/** + * @brief Travel tag memory to run a call back function, using 2nd tag registers. + * ICache and DCache are suspend when doing this. + * The callback will get the parameter tag_group_info, which will include a group of tag memory addresses and cache memory addresses. + * Please do not call this function in your SDK application. + * + * @param struct cache_mode * mode : the cache to check and the cache mode. + * + * @param uint32_t filter_addr : only the cache lines which may include the filter_address will be returned to the call back function. + * 0 for do not filter, all cache lines will be returned. + * + * @param void (* process)(struct tag_group_info *) : call back function, which may be called many times, a group(the addresses in the group are in the same position in the cache ways) a time. + * + * @return None + */ +void Cache_Travel_Tag_Memory2(struct cache_mode * mode, uint32_t filter_addr, void (* process)(struct tag_group_info *)); /** * @brief Get the virtual address from cache mode, cache tag and the virtual address offset of cache ways. @@ -1092,6 +1171,8 @@ int flash2spiram_rodata_offset(void); uint32_t flash_instr_rodata_start_page(uint32_t bus); uint32_t flash_instr_rodata_end_page(uint32_t bus); +extern struct cache_internal_stub_table* rom_cache_internal_table_ptr; +extern cache_op_cb_t rom_cache_op_cb; #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32c3/include/esp_rom/include/esp32s3/rom/rsa_pss.h b/tools/sdk/esp32c3/include/esp_rom/include/esp32s3/rom/rsa_pss.h index b9ced67a1a2..71ae5892263 100644 --- a/tools/sdk/esp32c3/include/esp_rom/include/esp32s3/rom/rsa_pss.h +++ b/tools/sdk/esp32c3/include/esp_rom/include/esp32s3/rom/rsa_pss.h @@ -32,7 +32,7 @@ typedef struct { uint32_t mdash; } ets_rsa_pubkey_t; -bool ets_rsa_pss_verify(const ets_rsa_pubkey_t *key, const uint8_t *sig, const uint8_t *digest); +bool ets_rsa_pss_verify(const ets_rsa_pubkey_t *key, const uint8_t *sig, const uint8_t *digest, uint8_t *verified_digest); void ets_mgf1_sha256(const uint8_t *mgfSeed, size_t seedLen, size_t maskLen, uint8_t *mask); diff --git a/tools/sdk/esp32c3/include/esp_rom/include/esp32s3/rom/rtc.h b/tools/sdk/esp32c3/include/esp_rom/include/esp32s3/rom/rtc.h index 09d2376ef38..d928c4dee44 100644 --- a/tools/sdk/esp32c3/include/esp_rom/include/esp32s3/rom/rtc.h +++ b/tools/sdk/esp32c3/include/esp_rom/include/esp32s3/rom/rtc.h @@ -92,6 +92,9 @@ typedef enum { SUPER_WDT_RESET = 18, /**<18, super watchdog reset digital core and rtc module*/ GLITCH_RTC_RESET = 19, /**<19, glitch reset digital core and rtc module*/ EFUSE_RESET = 20, /**<20, efuse reset digital core*/ + USB_UART_CHIP_RESET = 21, /**<21, usb uart reset digital core */ + USB_JTAG_CHIP_RESET = 22, /**<22, usb jtag reset digital core */ + POWER_GLITCH_RESET = 23, /**<23, power glitch reset digital core and rtc module*/ } RESET_REASON; // Check if the reset reason defined in ROM is compatible with soc/reset_reasons.h @@ -106,9 +109,13 @@ _Static_assert((soc_reset_reason_t)RTC_SW_CPU_RESET == RESET_REASON_CPU0_SW, "RT _Static_assert((soc_reset_reason_t)RTCWDT_CPU_RESET == RESET_REASON_CPU0_RTC_WDT, "RTCWDT_CPU_RESET != RESET_REASON_CPU0_RTC_WDT"); _Static_assert((soc_reset_reason_t)RTCWDT_BROWN_OUT_RESET == RESET_REASON_SYS_BROWN_OUT, "RTCWDT_BROWN_OUT_RESET != RESET_REASON_SYS_BROWN_OUT"); _Static_assert((soc_reset_reason_t)RTCWDT_RTC_RESET == RESET_REASON_SYS_RTC_WDT, "RTCWDT_RTC_RESET != RESET_REASON_SYS_RTC_WDT"); +_Static_assert((soc_reset_reason_t)TG1WDT_CPU_RESET == RESET_REASON_CPU0_MWDT1, "TG1WDT_CPU_RESET != RESET_REASON_CPU0_MWDT1"); _Static_assert((soc_reset_reason_t)SUPER_WDT_RESET == RESET_REASON_SYS_SUPER_WDT, "SUPER_WDT_RESET != RESET_REASON_SYS_SUPER_WDT"); _Static_assert((soc_reset_reason_t)GLITCH_RTC_RESET == RESET_REASON_SYS_CLK_GLITCH, "GLITCH_RTC_RESET != RESET_REASON_SYS_CLK_GLITCH"); _Static_assert((soc_reset_reason_t)EFUSE_RESET == RESET_REASON_CORE_EFUSE_CRC, "EFUSE_RESET != RESET_REASON_CORE_EFUSE_CRC"); +_Static_assert((soc_reset_reason_t)USB_UART_CHIP_RESET == RESET_REASON_CORE_USB_UART, "USB_UART_CHIP_RESET != RESET_REASON_CORE_USB_UART"); +_Static_assert((soc_reset_reason_t)USB_JTAG_CHIP_RESET == RESET_REASON_CORE_USB_JTAG, "USB_JTAG_CHIP_RESET != RESET_REASON_CORE_USB_JTAG"); +_Static_assert((soc_reset_reason_t)POWER_GLITCH_RESET == RESET_REASON_CORE_PWR_GLITCH, "POWER_GLITCH_RESET != RESET_REASON_CORE_PWR_GLITCH"); typedef enum { NO_SLEEP = 0, diff --git a/tools/sdk/esp32c3/include/esp_rom/include/esp32s3/rom/spi_flash.h b/tools/sdk/esp32c3/include/esp_rom/include/esp32s3/rom/spi_flash.h index 8c5170b5a8e..293306c9b97 100644 --- a/tools/sdk/esp32c3/include/esp_rom/include/esp32s3/rom/spi_flash.h +++ b/tools/sdk/esp32c3/include/esp_rom/include/esp32s3/rom/spi_flash.h @@ -111,7 +111,6 @@ extern "C" { #define ESP_ROM_SPIFLASH_BP2 BIT4 #define ESP_ROM_SPIFLASH_WR_PROTECT (ESP_ROM_SPIFLASH_BP0|ESP_ROM_SPIFLASH_BP1|ESP_ROM_SPIFLASH_BP2) #define ESP_ROM_SPIFLASH_QE BIT9 -#define ESP_ROM_SPIFLASH_BP_MASK_ISSI (BIT7 | BIT5 | BIT4 | BIT3 | BIT2) #define FLASH_ID_GD25LQ32C 0xC86016 diff --git a/tools/sdk/esp32c3/include/esp_rom/include/esp32s3/rom/usb/cpio.h b/tools/sdk/esp32c3/include/esp_rom/include/esp32s3/rom/usb/cpio.h index 5603b3f541a..886b5080fb4 100644 --- a/tools/sdk/esp32c3/include/esp_rom/include/esp32s3/rom/usb/cpio.h +++ b/tools/sdk/esp32c3/include/esp_rom/include/esp32s3/rom/usb/cpio.h @@ -79,7 +79,7 @@ typedef enum { * The initial time with reason=CPIO_RSN_FILE_INITIAL, when more data is available with * CPIO_RSN_FILE_MORE and finally with CPIO_RSN_FILE_END. For these calls, fileinfo * will again contain file information. buff will be the information contained in the - * file at offset buff_offset, and the lenght of this buffer will be in buff_len. + * file at offset buff_offset, and the length of this buffer will be in buff_len. * * The library guarantees to feed all file data to the callback consequitively, so * within the same file, the buff_offset from a call will always be (buff_offset+buff_len) diff --git a/tools/sdk/esp32c3/include/esp_rom/include/esp_rom_sys.h b/tools/sdk/esp32c3/include/esp_rom/include/esp_rom_sys.h index 9bf73adea5c..946cb7af791 100644 --- a/tools/sdk/esp32c3/include/esp_rom/include/esp_rom_sys.h +++ b/tools/sdk/esp32c3/include/esp_rom/include/esp_rom_sys.h @@ -13,7 +13,7 @@ // limitations under the License. #pragma once - +#include "sdkconfig.h" #include #include "soc/reset_reasons.h" diff --git a/tools/sdk/esp32c3/include/esp_rom/include/esp_rom_tjpgd.h b/tools/sdk/esp32c3/include/esp_rom/include/esp_rom_tjpgd.h new file mode 100644 index 00000000000..318519ba749 --- /dev/null +++ b/tools/sdk/esp32c3/include/esp_rom/include/esp_rom_tjpgd.h @@ -0,0 +1,152 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/*-----------------------------------------------------------------------------/ +/ TJpgDec - Tiny JPEG Decompressor R0.01b (C)ChaN, 2012 +/-----------------------------------------------------------------------------/ +/ The TJpgDec is a generic JPEG decompressor module for tiny embedded systems. +/ This is a free software that opened for education, research and commercial +/ developments under license policy of following terms. +/ +/ Copyright (C) 2012, ChaN, all right reserved. +/ +/ * The TJpgDec module is a free software and there is NO WARRANTY. +/ * No restriction on use. You can use, modify and redistribute it for +/ personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY. +/ * Redistributions of source code must retain the above copyright notice. +/ +/-----------------------------------------------------------------------------*/ + +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Error code */ +typedef enum { + JDR_OK = 0, /* 0: Succeeded */ + JDR_INTR, /* 1: Interrupted by output function */ + JDR_INP, /* 2: Device error or wrong termination of input stream */ + JDR_MEM1, /* 3: Insufficient memory pool for the image */ + JDR_MEM2, /* 4: Insufficient stream input buffer */ + JDR_PAR, /* 5: Parameter error */ + JDR_FMT1, /* 6: Data format error (may be damaged data) */ + JDR_FMT2, /* 7: Right format but not supported */ + JDR_FMT3 /* 8: Not supported JPEG standard */ +} esp_rom_tjpgd_result_t; + +/* Rectangular structure */ +typedef struct { + uint16_t left; /* Left end */ + uint16_t right; /* Right end */ + uint16_t top; /* Top end */ + uint16_t bottom;/* Bottom end */ +} esp_rom_tjpgd_rect_t; + +typedef struct JDEC_s esp_rom_tjpgd_dec_t; + +/** + * @brief Type of user defined input function to read data from input stream + * @param dec Specifies the decompression object of the decompression session + * @param buffer Specifies the pointer to the read buffer to store the read data. A NULL specifies to remove the data from input stream + * @param ndata Specifies number of bytes to read/remove from the input stream + * + * @return number of bytes read/removed. When a zero is returned, the esp_rom_tjpgd_prepare and esp_rom_tjpgd_decomp function aborts with JDR_INP + */ +typedef uint32_t (*esp_rom_tjpgd_input_function_t)(esp_rom_tjpgd_dec_t *dec, uint8_t *buffer, uint32_t ndata); + +/** + * @brief User defined output function to write decompressed pixels to the output device + * + * This function is the data output interface of the TJpgDec module. + * The corresponding decompression session can be identified by the pointer to the device identifier jdec->device passed to the 5th argument of jd_prepare function. + * The bitmap is sent to the frame buffer or display device in this function. + * The first pixel in the bitmap is the left-top of the rectangular, the second one is next right and last pixel is the bottom-right of the rectangular. + * The size of rectangular varies from 1x1 to 16x16 depends on clipping, scaling and sampling factor of the image. + * If the rectangular is out of the frame buffer, it should be clipped in this function. + * + * The pixel format is currently configured to RGB888 + * + * @param dec Specifies the decompression object of the decompression session + * @param bitmap Specifies the RGB bitmap to be output + * @param rect Specifies rectangular region in the image to output the RGB bitmap + * + * @return Normally returns 1. It lets TJpgDec to continue the decompressing process. + * When a 0 is returned, the esp_rom_tjpgd_decomp function aborts with JDR_INTR. + * This is useful to interrupt the decompression process + */ +typedef uint32_t (*esp_rom_tjpgd_output_function_t)(esp_rom_tjpgd_dec_t *dec, void *bitmap, esp_rom_tjpgd_rect_t *rect); + +struct JDEC_s { + uint32_t dctr; /* Number of bytes available in the input buffer */ + uint8_t *dptr; /* Current data read ptr */ + uint8_t *inbuf; /* Bit stream input buffer */ + uint8_t dmsk; /* Current bit in the current read byte */ + uint8_t scale; /* Output scaling ratio */ + uint8_t msx, msy; /* MCU size in unit of block (width, height) */ + uint8_t qtid[3]; /* Quantization table ID of each component */ + int16_t dcv[3]; /* Previous DC element of each component */ + uint16_t nrst; /* Restart inverval */ + uint32_t width, height; /* Size of the input image (pixel) */ + uint8_t *huffbits[2][2]; /* Huffman bit distribution tables [id][dcac] */ + uint16_t *huffcode[2][2]; /* Huffman code word tables [id][dcac] */ + uint8_t *huffdata[2][2]; /* Huffman decoded data tables [id][dcac] */ + int32_t *qttbl[4]; /* Dequaitizer tables [id] */ + void *workbuf; /* Working buffer for IDCT and RGB output */ + uint8_t *mcubuf; /* Working buffer for the MCU */ + void *pool; /* Pointer to available memory pool */ + uint32_t sz_pool; /* Size of momory pool (bytes available) */ + esp_rom_tjpgd_input_function_t infunc; /* Pointer to jpeg stream input function */ + void *device; /* Pointer to I/O device identifiler for the session */ +}; + +/* TJpgDec API functions */ + +/** + * @brief Analyzes the JPEG data and create a decompression object for subsequent decompression process. + * @param dec Specifies the decompression object to be initialized. The decompression object is used for subsequent decompression process. + * @param infunc Specifies the user defined data input function. + * @param work Specifies pointer to the work area for this session. It should be aligned to word boundary or it can result an exception. + * @param sz_work Specifies size of the work area in unit of byte. + * TJpgDec requires upto 3092 bytes of work area depends on the built-in parameter tables of the JPEG image. + * Thus 3092 bytes of work area is sufficient for most case. + * @param dev Specifies pointer to the user defined device identifier for this session. + * It is stored to the member device in the decompression object. It can be referred by I/O functions to identify the current session. + * When I/O device is fixed in the project or this feature is not needed, set NULL and do not care about this. + * + * @return + * - JDR_OK Function succeeded and decompression object is valid. + * - JDR_INP An error occurred in input function due to hard error or wrong stream termination. + * - JDR_MEM1 Insufficient work area for this JPEG image. + * - JDR_MEM2 Insufficient input buffer for this JPEG image. JD_SZBUF may be too small. + * - JDR_PAR Parameter error. Given pointer to the work area is NULL. + * - JDR_FMT1 Data format error. The JPEG data can be collapsed. + * - JDR_FMT2 Right format but not supported. May be a grayscale image. + * - JDR_FMT3 Not supported JPEG standard. May be a progressive JPEG image. + */ +esp_rom_tjpgd_result_t esp_rom_tjpgd_prepare(esp_rom_tjpgd_dec_t *dec, esp_rom_tjpgd_input_function_t infunc, void *work, uint32_t sz_work, void *dev); + +/** + * @brief Decompress the JPEG image and output it as RGB data. + * @param dec Specifies the valid decompressor object. + * @param outfunc Specifies the user defined data output function. The esp_rom_tjpgd_decomp function calls this function to output the decompressed JPEG image in RGB form. + * @param scale Specifies scaling factor N for output. The output image is descaled to 1 / 2 ^ N (N = 0 to 3). + * + * @return + * - JDR_OK Function succeeded. + * - JDR_INTR The decompression process is interrupted by output function. + * - JDR_INP An error occured in input function due to hard error or wrong stream termination. + * - JDR_PAR Parameter error. Given scale factor is invalid. + * - JDR_FMT1 Data format error. The JPEG data can be collapted. + */ +esp_rom_tjpgd_result_t esp_rom_tjpgd_decomp(esp_rom_tjpgd_dec_t *dec, esp_rom_tjpgd_output_function_t outfunc, uint8_t scale); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32c3/include/esp_rom/include/linux/soc/reset_reasons.h b/tools/sdk/esp32c3/include/esp_rom/include/linux/soc/reset_reasons.h new file mode 100644 index 00000000000..7cc86ffddfb --- /dev/null +++ b/tools/sdk/esp32c3/include/esp_rom/include/linux/soc/reset_reasons.h @@ -0,0 +1,31 @@ +// Copyright 2021 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 + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Dummy to satisfy the requirement for this type on Linux targets. + * Look at other reset_reasons.h files in IDF. + */ +typedef enum { + RESET_REASON_CHIP_POWER_ON = 0x01, // Power on reset +} soc_reset_reason_t; + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32c3/include/esp_serial_slave_link/include/esp_serial_slave_link/essl.h b/tools/sdk/esp32c3/include/esp_serial_slave_link/include/esp_serial_slave_link/essl.h index 505edcdc2f6..f03274a4013 100644 --- a/tools/sdk/esp32c3/include/esp_serial_slave_link/include/esp_serial_slave_link/essl.h +++ b/tools/sdk/esp32c3/include/esp_serial_slave_link/include/esp_serial_slave_link/essl.h @@ -29,42 +29,48 @@ typedef struct essl_dev_t* essl_handle_t; * * @param handle Handle of an ESSL device. * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. - * @return ESP_OK if success, or other value returned from lower layer `init`. + * @return + * - ESP_OK: If success + * - ESP_ERR_NOT_SUPPORTED: Current device does not support this function. + * - Other value returned from lower layer `init`. */ esp_err_t essl_init(essl_handle_t handle, uint32_t wait_ms); -/** Wait for interrupt of an ESP slave device. +/** Wait for interrupt of an ESSL slave device. * * @param handle Handle of an ESSL device. * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. * * @return - * - ESP_OK if success + * - ESP_OK: If success + * - ESP_ERR_NOT_SUPPORTED: Current device does not support this function. * - One of the error codes from SDMMC host controller */ esp_err_t essl_wait_for_ready(essl_handle_t handle, uint32_t wait_ms); /** Get buffer num for the host to send data to the slave. The buffers are size of ``buffer_size``. * - * @param handle Handle of an ESSL device. - * @param out_tx_num Output of buffer num that host can send data to an ESP slave. + * @param handle Handle of a ESSL device. + * @param out_tx_num Output of buffer num that host can send data to ESSL slave. * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. * * @return - * - ESP_OK Success - * - One of the error codes from SDMMC host controller + * - ESP_OK: Success + * - ESP_ERR_NOT_SUPPORTED: This API is not supported in this mode + * - One of the error codes from SDMMC/SPI host controller */ esp_err_t essl_get_tx_buffer_num(essl_handle_t handle, uint32_t *out_tx_num, uint32_t wait_ms); -/** Get amount of data the ESP slave preparing to send to host. +/** Get the size, in bytes, of the data that the ESSL slave is ready to send * * @param handle Handle of an ESSL device. - * @param out_rx_size Output of data size to read from slave. + * @param out_rx_size Output of data size to read from slave, in bytes * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. * * @return - * - ESP_OK Success - * - One of the error codes from SDMMC host controller + * - ESP_OK: Success + * - ESP_ERR_NOT_SUPPORTED: This API is not supported in this mode + * - One of the error codes from SDMMC/SPI host controller */ esp_err_t essl_get_rx_data_size(essl_handle_t handle, uint32_t *out_rx_size, uint32_t wait_ms); @@ -72,10 +78,15 @@ esp_err_t essl_get_rx_data_size(essl_handle_t handle, uint32_t *out_rx_size, uin /** Reset the counters of this component. Usually you don't need to do this unless you know the slave is reset. * * @param handle Handle of an ESSL device. + * + * @return + * - ESP_OK: Success + * - ESP_ERR_NOT_SUPPORTED: This API is not supported in this mode + * - ESP_ERR_INVALID_ARG: Invalid argument, handle is not init. */ esp_err_t essl_reset_cnt(essl_handle_t handle); -/** Send a packet to the ESP slave. The slave receive the packet into buffers whose size is ``buffer_size`` (configured during initialization). +/** Send a packet to the ESSL Slave. The Slave receives the packet into buffers whose size is ``buffer_size`` (configured during initialization). * * @param handle Handle of an ESSL device. * @param start Start address of the packet to send @@ -84,12 +95,15 @@ esp_err_t essl_reset_cnt(essl_handle_t handle); * * @return * - ESP_OK Success - * - ESP_ERR_TIMEOUT No buffer to use, or error ftrom SDMMC host controller - * - One of the error codes from SDMMC host controller + * - ESP_ERR_INVALID_ARG: Invalid argument, handle is not init or other argument is not valid. + * - ESP_ERR_TIMEOUT: No buffer to use, or error ftrom SDMMC host controller. + * - ESP_ERR_NOT_FOUND: Slave is not ready for receiving. + * - ESP_ERR_NOT_SUPPORTED: This API is not supported in this mode + * - One of the error codes from SDMMC/SPI host controller. */ esp_err_t essl_send_packet(essl_handle_t handle, const void *start, size_t length, uint32_t wait_ms); -/** Get a packet from an ESP slave. +/** Get a packet from ESSL slave. * * @param handle Handle of an ESSL device. * @param[out] out_data Data output address @@ -98,16 +112,19 @@ esp_err_t essl_send_packet(essl_handle_t handle, const void *start, size_t lengt * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. * * @return - * - ESP_OK Success, all the data are read from the slave. - * - ESP_ERR_NOT_FINISHED Read success, while there're data remaining. - * - One of the error codes from SDMMC host controller + * - ESP_OK Success: All the data has been read from the slave. + * - ESP_ERR_INVALID_ARG: Invalid argument, The handle is not initialized or the other arguments are invalid. + * - ESP_ERR_NOT_FINISHED: Read was successful, but there is still data remaining. + * - ESP_ERR_NOT_FOUND: Slave is not ready to send data. + * - ESP_ERR_NOT_SUPPORTED: This API is not supported in this mode + * - One of the error codes from SDMMC/SPI host controller. */ esp_err_t essl_get_packet(essl_handle_t handle, void *out_data, size_t size, size_t *out_length, uint32_t wait_ms); -/** Write general purpose R/W registers (8-bit) of an ESP slave. +/** Write general purpose R/W registers (8-bit) of ESSL slave. * * @param handle Handle of an ESSL device. - * @param addr Address of register to write. Valid address: 0-59. + * @param addr Address of register to write. For SDIO, valid address: 0-59. For SPI, see ``essl_spi.h`` * @param value Value to write to the register. * @param value_o Output of the returned written value. * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. @@ -116,22 +133,20 @@ esp_err_t essl_get_packet(essl_handle_t handle, void *out_data, size_t size, siz * * @return * - ESP_OK Success - * - ESP_ERR_INVALID_ARG Address not valid. - * - One of the error codes from SDMMC host controller + * - One of the error codes from SDMMC/SPI host controller */ esp_err_t essl_write_reg(essl_handle_t handle, uint8_t addr, uint8_t value, uint8_t *value_o, uint32_t wait_ms); -/** Read general purpose R/W registers (8-bit) of an ESP slave. +/** Read general purpose R/W registers (8-bit) of ESSL slave. * - * @param handle Handle of an ESSL device. - * @param add Address of register to read. Valid address: 0-27, 32-63 (28-31 reserved, return interrupt bits on read). + * @param handle Handle of a ``essl`` device. + * @param add Address of register to read. For SDIO, Valid address: 0-27, 32-63 (28-31 reserved, return interrupt bits on read). For SPI, see ``essl_spi.h`` * @param value_o Output value read from the register. * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. * * @return * - ESP_OK Success - * - ESP_ERR_INVALID_ARG Address not valid. - * - One of the error codes from SDMMC host controller + * - One of the error codes from SDMMC/SPI host controller */ esp_err_t essl_read_reg(essl_handle_t handle, uint8_t add, uint8_t *value_o, uint32_t wait_ms); @@ -141,25 +156,26 @@ esp_err_t essl_read_reg(essl_handle_t handle, uint8_t add, uint8_t *value_o, uin * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. * * @return - * - ESP_ERR_NOT_SUPPORTED Currently our driver doesnot support SDIO with SPI interface. - * - ESP_OK If interrupt triggered. - * - ESP_ERR_TIMEOUT No interrupts before timeout. + * - ESP_OK: If interrupt is triggered. + * - ESP_ERR_NOT_SUPPORTED: Current device does not support this function. + * - ESP_ERR_TIMEOUT: No interrupts before timeout. */ esp_err_t essl_wait_int(essl_handle_t handle, uint32_t wait_ms); -/** Clear interrupt bits of an ESP slave. All the bits set in the mask will be cleared, while other bits will stay the same. +/** Clear interrupt bits of ESSL slave. All the bits set in the mask will be cleared, while other bits will stay the same. * * @param handle Handle of an ESSL device. * @param intr_mask Mask of interrupt bits to clear. * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. * * @return - * - ESP_OK Success - * - One of the error codes from SDMMC host controller + * - ESP_OK: Success + * - ESP_ERR_NOT_SUPPORTED: Current device does not support this function. + * - One of the error codes from SDMMC host controller */ esp_err_t essl_clear_intr(essl_handle_t handle, uint32_t intr_mask, uint32_t wait_ms); -/** Get interrupt bits of an ESP slave. +/** Get interrupt bits of ESSL slave. * * @param handle Handle of an ESSL device. * @param intr_raw Output of the raw interrupt bits. Set to NULL if only masked bits are read. @@ -167,25 +183,27 @@ esp_err_t essl_clear_intr(essl_handle_t handle, uint32_t intr_mask, uint32_t wai * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. * * @return - * - ESP_OK Success - * - ESP_INVALID_ARG if both ``intr_raw`` and ``intr_st`` are NULL. - * - One of the error codes from SDMMC host controller + * - ESP_OK: Success + * - ESP_INVALID_ARG: If both ``intr_raw`` and ``intr_st`` are NULL. + * - ESP_ERR_NOT_SUPPORTED: Current device does not support this function. + * - One of the error codes from SDMMC host controller */ esp_err_t essl_get_intr(essl_handle_t handle, uint32_t *intr_raw, uint32_t *intr_st, uint32_t wait_ms); -/** Set interrupt enable bits of an ESP slave. The slave only sends interrupt on the line when there is a bit both the raw status and the enable are set. +/** Set interrupt enable bits of ESSL slave. The slave only sends interrupt on the line when there is a bit both the raw status and the enable are set. * * @param handle Handle of an ESSL device. * @param ena_mask Mask of the interrupt bits to enable. * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. * * @return - * - ESP_OK Success - * - One of the error codes from SDMMC host controller + * - ESP_OK: Success + * - ESP_ERR_NOT_SUPPORTED: Current device does not support this function. + * - One of the error codes from SDMMC host controller */ esp_err_t essl_set_intr_ena(essl_handle_t handle, uint32_t ena_mask, uint32_t wait_ms); -/** Get interrupt enable bits of an ESP slave. +/** Get interrupt enable bits of ESSL slave. * * @param handle Handle of an ESSL device. * @param ena_mask_o Output of interrupt bit enable mask. @@ -204,7 +222,8 @@ esp_err_t essl_get_intr_ena(essl_handle_t handle, uint32_t *ena_mask_o, uint32_t * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. * * @return - * - ESP_OK Success - * - One of the error codes from SDMMC host controller + * - ESP_OK: Success + * - ESP_ERR_NOT_SUPPORTED: Current device does not support this function. + * - One of the error codes from SDMMC host controller */ esp_err_t essl_send_slave_intr(essl_handle_t handle, uint32_t intr_mask, uint32_t wait_ms); diff --git a/tools/sdk/esp32c3/include/esp_serial_slave_link/include/esp_serial_slave_link/essl_spi.h b/tools/sdk/esp32c3/include/esp_serial_slave_link/include/esp_serial_slave_link/essl_spi.h index a6c3c40c04f..22721d17ece 100644 --- a/tools/sdk/esp32c3/include/esp_serial_slave_link/include/esp_serial_slave_link/essl_spi.h +++ b/tools/sdk/esp32c3/include/esp_serial_slave_link/include/esp_serial_slave_link/essl_spi.h @@ -23,22 +23,141 @@ extern "C" { #endif +/// Configuration of ESSL SPI device +typedef struct { + spi_device_handle_t *spi; ///< Pointer to SPI device handle. + uint32_t tx_buf_size; ///< The pre-negotiated Master TX buffer size used by both the host and the slave. + uint8_t tx_sync_reg; ///< The pre-negotiated register ID for Master-TX-SLAVE-RX synchronization. 1 word (4 Bytes) will be reserved for the synchronization. + uint8_t rx_sync_reg; ///< The pre-negotiated register ID for Master-RX-Slave-TX synchronization. 1 word (4 Bytes) will be reserved for the synchronization. +} essl_spi_config_t; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// APIs for DMA Append Mode +// This mode has a better performance for continuous Half Duplex SPI transactions. +// +// * You can use the ``essl_spi_init_dev`` and ``essl_spi_deinit_dev`` together with APIs in ``essl.h`` to communicate +// with ESP SPI Slaves in Half Duplex DMA Append Mode. See example for SPI SLAVE HALFDUPLEX APPEND MODE. +// * You can also use the following APIs to create your own logic. +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Initialize the ESSL SPI device function list and get its handle + * + * @param[out] out_handle Output of the handle + * @param init_config Configuration for the ESSL SPI device + * @return + * - ESP_OK: On success + * - ESP_ERR_NO_MEM: Memory exhausted + * - ESP_ERR_INVALID_STATE: SPI driver is not initialized + * - ESP_ERR_INVALID_ARG: Wrong register ID + */ +esp_err_t essl_spi_init_dev(essl_handle_t *out_handle, const essl_spi_config_t *init_config); + +/** + * @brief Deinitialize the ESSL SPI device and free the memory used by the device + * + * @param handle Handle of the ESSL SPI device + * @return + * - ESP_OK: On success + * - ESP_ERR_INVALID_STATE: ESSL SPI is not in use + */ +esp_err_t essl_spi_deinit_dev(essl_handle_t handle); + +/** + * @brief Read from the shared registers + * + * @note The registers for Master/Slave synchronization are reserved. Do not use them. (see `rx_sync_reg` in `essl_spi_config_t`) + * + * @param arg Context of the component. (Member ``arg`` from ``essl_handle_t``) + * @param addr Address of the shared registers. (Valid: 0 ~ SOC_SPI_MAXIMUM_BUFFER_SIZE, registers for M/S sync are reserved, see note1). + * @param[out] out_value Read buffer for the shared registers. + * @param wait_ms Time to wait before timeout (reserved for future use, user should set this to 0). + * @return + * - ESP_OK: success + * - ESP_ERR_INVALID_STATE: ESSL SPI has not been initialized. + * - ESP_ERR_INVALID_ARG: The address argument is not valid. See note 1. + * - or other return value from :cpp:func:`spi_device_transmit`. + */ +esp_err_t essl_spi_read_reg(void *arg, uint8_t addr, uint8_t *out_value, uint32_t wait_ms); + +/** + * @brief Get a packet from Slave + * + * @param arg Context of the component. (Member ``arg`` from ``essl_handle_t``) + * @param[out] out_data Output data address + * @param size The size of the output data. + * @param wait_ms Time to wait before timeout (reserved for future use, user should set this to 0). + * @return + * - ESP_OK: On Success + * - ESP_ERR_INVALID_STATE: ESSL SPI has not been initialized. + * - ESP_ERR_INVALID_ARG: The output data address is neither DMA capable nor 4 byte-aligned + * - ESP_ERR_INVALID_SIZE: Master requires ``size`` bytes of data but Slave did not load enough bytes. + */ +esp_err_t essl_spi_get_packet(void *arg, void *out_data, size_t size, uint32_t wait_ms); + +/** + * @brief Write to the shared registers + * + * @note The registers for Master/Slave synchronization are reserved. Do not use them. (see `tx_sync_reg` in `essl_spi_config_t`) + * @note Feature of checking the actual written value (``out_value``) is not supported. + * + * @param arg Context of the component. (Member ``arg`` from ``essl_handle_t``) + * @param addr Address of the shared registers. (Valid: 0 ~ SOC_SPI_MAXIMUM_BUFFER_SIZE, registers for M/S sync are reserved, see note1) + * @param value Buffer for data to send, should be align to 4. + * @param[out] out_value Not supported, should be set to NULL. + * @param wait_ms Time to wait before timeout (reserved for future use, user should set this to 0). + * @return + * - ESP_OK: success + * - ESP_ERR_INVALID_STATE: ESSL SPI has not been initialized. + * - ESP_ERR_INVALID_ARG: The address argument is not valid. See note 1. + * - ESP_ERR_NOT_SUPPORTED: Should set ``out_value`` to NULL. See note 2. + * - or other return value from :cpp:func:`spi_device_transmit`. + * + */ +esp_err_t essl_spi_write_reg(void *arg, uint8_t addr, uint8_t value, uint8_t *out_value, uint32_t wait_ms); + +/** + * @brief Send a packet to Slave + * + * @param arg Context of the component. (Member ``arg`` from ``essl_handle_t``) + * @param data Address of the data to send + * @param size Size of the data to send. + * @param wait_ms Time to wait before timeout (reserved for future use, user should set this to 0). + * @return + * - ESP_OK: On success + * - ESP_ERR_INVALID_STATE: ESSL SPI has not been initialized. + * - ESP_ERR_INVALID_ARG: The data address is not DMA capable + * - ESP_ERR_INVALID_SIZE: Master will send ``size`` bytes of data but Slave did not load enough RX buffer + */ +esp_err_t essl_spi_send_packet(void *arg, const void *data, size_t size, uint32_t wait_ms); + +/** + * @brief Reset the counter in Master context + * + * @note Shall only be called if the slave has reset its counter. Else, Slave and Master would be desynchronized + * + * @param arg Context of the component. (Member ``arg`` from ``essl_handle_t``) + */ +void essl_spi_reset_cnt(void *arg); + //////////////////////////////////////////////////////////////////////////////// // Basic commands to communicate with the SPI Slave HD on ESP32-S2 //////////////////////////////////////////////////////////////////////////////// - /** * @brief Read the shared buffer from the slave in ISR way * + * @note The slave's HW doesn't guarantee the data in one SPI transaction is consistent. It sends data in unit of byte. + * In other words, if the slave SW attempts to update the shared register when a rdbuf SPI transaction is in-flight, + * the data got by the master will be the combination of bytes of different writes of slave SW. + * * @note ``out_data`` should be prepared in words and in the DRAM. The buffer may be written in words * by the DMA. When a byte is written, the remaining bytes in the same word will also be * overwritten, even the ``len`` is shorter than a word. * - * @param spi SPI device handle representing the slave - * @param out_data Buffer for read data, strongly suggested to be in the DRAM and align to 4 - * @param addr Address of the slave shared buffer - * @param len Length to read - * @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send. + * @param spi SPI device handle representing the slave + * @param[out] out_data Buffer for read data, strongly suggested to be in the DRAM and aligned to 4 + * @param addr Address of the slave shared buffer + * @param len Length to read + * @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send. * @return * - ESP_OK: on success * - or other return value from :cpp:func:`spi_device_transmit`. @@ -52,11 +171,11 @@ esp_err_t essl_spi_rdbuf(spi_device_handle_t spi, uint8_t *out_data, int addr, i * by the DMA. When a byte is written, the remaining bytes in the same word will also be * overwritten, even the ``len`` is shorter than a word. * - * @param spi SPI device handle representing the slave - * @param out_data Buffer for read data, strongly suggested to be in the DRAM and align to 4 - * @param addr Address of the slave shared buffer - * @param len Length to read - * @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send. + * @param spi SPI device handle representing the slave + * @param[out] out_data Buffer for read data, strongly suggested to be in the DRAM and aligned to 4 + * @param addr Address of the slave shared buffer + * @param len Length to read + * @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send. * @return * - ESP_OK: on success * - or other return value from :cpp:func:`spi_device_transmit`. @@ -71,7 +190,7 @@ esp_err_t essl_spi_rdbuf_polling(spi_device_handle_t spi, uint8_t *out_data, int * overwritten, even the ``len`` is shorter than a word. * * @param spi SPI device handle representing the slave - * @param data Buffer for data to send, strongly suggested to be in the DRAM and align to 4 + * @param data Buffer for data to send, strongly suggested to be in the DRAM * @param addr Address of the slave shared buffer, * @param len Length to write * @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send. @@ -89,7 +208,7 @@ esp_err_t essl_spi_wrbuf(spi_device_handle_t spi, const uint8_t *data, int addr, * overwritten, even the ``len`` is shorter than a word. * * @param spi SPI device handle representing the slave - * @param data Buffer for data to send, strongly suggested to be in the DRAM and align to 4 + * @param data Buffer for data to send, strongly suggested to be in the DRAM * @param addr Address of the slave shared buffer, * @param len Length to write * @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send. @@ -105,10 +224,10 @@ esp_err_t essl_spi_wrbuf_polling(spi_device_handle_t spi, const uint8_t *data, i * @note This function combines several :cpp:func:`essl_spi_rddma_seg` and one * :cpp:func:`essl_spi_rddma_done` at the end. Used when the slave is working in segment mode. * - * @param spi SPI device handle representing the slave - * @param out_data Buffer to hold the received data, strongly suggested to be in the DRAM and align to 4 - * @param len Total length of data to receive. - * @param seg_len Length of each segment, which is not larger than the maximum transaction length + * @param spi SPI device handle representing the slave + * @param[out] out_data Buffer to hold the received data, strongly suggested to be in the DRAM and aligned to 4 + * @param len Total length of data to receive. + * @param seg_len Length of each segment, which is not larger than the maximum transaction length * allowed for the spi device. Suggested to be multiples of 4. When set < 0, means send * all data in one segment (the ``rddma_done`` will still be sent.) * @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send. @@ -123,10 +242,10 @@ esp_err_t essl_spi_rddma(spi_device_handle_t spi, uint8_t *out_data, int len, in * * @note To read long buffer, call :cpp:func:`essl_spi_rddma` instead. * - * @param spi SPI device handle representing the slave - * @param out_data Buffer to hold the received data, strongly suggested to be in the DRAM and align to 4 - * @param seg_len Length of this segment - * @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send. + * @param spi SPI device handle representing the slave + * @param[out] out_data Buffer to hold the received data. strongly suggested to be in the DRAM and aligned to 4 + * @param seg_len Length of this segment + * @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send. * @return * - ESP_OK: success * - or other return value from :cpp:func:`spi_device_transmit`. @@ -155,7 +274,7 @@ esp_err_t essl_spi_rddma_done(spi_device_handle_t spi, uint32_t flags); * :cpp:func:`essl_spi_wrdma_done` at the end. Used when the slave is working in segment mode. * * @param spi SPI device handle representing the slave - * @param data Buffer for data to send, strongly suggested to be in the DRAM and align to 4 + * @param data Buffer for data to send, strongly suggested to be in the DRAM * @param len Total length of data to send. * @param seg_len Length of each segment, which is not larger than the maximum transaction length * allowed for the spi device. Suggested to be multiples of 4. When set < 0, means send @@ -173,7 +292,7 @@ esp_err_t essl_spi_wrdma(spi_device_handle_t spi, const uint8_t *data, int len, * @note To send long buffer, call :cpp:func:`essl_spi_wrdma` instead. * * @param spi SPI device handle representing the slave - * @param data Buffer for data to send, strongly suggested to be in the DRAM and align to 4 + * @param data Buffer for data to send, strongly suggested to be in the DRAM * @param seg_len Length of this segment * @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send. * @return diff --git a/tools/sdk/esp32c3/include/esp_system/include/esp_private/dbg_stubs.h b/tools/sdk/esp32c3/include/esp_system/include/esp_private/dbg_stubs.h index f3f5fba3b7b..ead23447bc7 100644 --- a/tools/sdk/esp32c3/include/esp_system/include/esp_private/dbg_stubs.h +++ b/tools/sdk/esp32c3/include/esp_system/include/esp_private/dbg_stubs.h @@ -24,13 +24,19 @@ extern "C" { * Debug stubs entries IDs */ typedef enum { - ESP_DBG_STUB_CONTROL_DATA, ///< stubs descriptor entry + ESP_DBG_STUB_MAGIC_NUM, + ESP_DBG_STUB_TABLE_SIZE, + ESP_DBG_STUB_CONTROL_DATA, ///< stubs descriptor entry ESP_DBG_STUB_ENTRY_FIRST, - ESP_DBG_STUB_ENTRY_GCOV ///< GCOV entry - = ESP_DBG_STUB_ENTRY_FIRST, + ESP_DBG_STUB_ENTRY_GCOV ///< GCOV entry + = ESP_DBG_STUB_ENTRY_FIRST, + ESP_DBG_STUB_ENTRY_CAPABILITIES, ESP_DBG_STUB_ENTRY_MAX } esp_dbg_stub_id_t; +#define ESP_DBG_STUB_MAGIC_NUM_VAL 0xFEEDBEEF +#define ESP_DBG_STUB_CAP_GCOV_TASK (1 << 0) + /** * @brief Initializes debug stubs. * @@ -45,12 +51,24 @@ void esp_dbg_stubs_init(void); * * @param id Stub ID. * @param entry Stub entry. Usually it is stub entry function address, - * but can be any value meaningfull for OpenOCD command/code. - * + * but can be any value meaningfull for OpenOCD command/code + * such as capabilities * @return ESP_OK on success, otherwise see esp_err_t */ esp_err_t esp_dbg_stub_entry_set(esp_dbg_stub_id_t id, uint32_t entry); +/** + * @brief Retrives the corresponding stub entry + * + * @param id Stub ID. + * @param entry Stub entry. Usually it is stub entry function address, + * but can be any value meaningfull for OpenOCD command/code + * such as capabilities + * + * @return ESP_OK on success, otherwise see esp_err_t + */ +esp_err_t esp_dbg_stub_entry_get(esp_dbg_stub_id_t id, uint32_t *entry); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32c3/include/esp_system/include/esp_task.h b/tools/sdk/esp32c3/include/esp_system/include/esp_task.h index 37d78bca6e8..adca9cde6bc 100644 --- a/tools/sdk/esp32c3/include/esp_system/include/esp_task.h +++ b/tools/sdk/esp32c3/include/esp_system/include/esp_task.h @@ -52,7 +52,11 @@ #define ESP_TASK_TIMER_PRIO (ESP_TASK_PRIO_MAX - 3) #define ESP_TASK_TIMER_STACK (CONFIG_ESP_TIMER_TASK_STACK_SIZE + TASK_EXTRA_STACK_SIZE) #define ESP_TASKD_EVENT_PRIO (ESP_TASK_PRIO_MAX - 5) +#if CONFIG_LWIP_TCPIP_CORE_LOCKING +#define ESP_TASKD_EVENT_STACK (CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE + TASK_EXTRA_STACK_SIZE + 2048) +#else #define ESP_TASKD_EVENT_STACK (CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE + TASK_EXTRA_STACK_SIZE) +#endif /* CONFIG_LWIP_TCPIP_CORE_LOCKING */ #define ESP_TASK_TCPIP_PRIO (ESP_TASK_PRIO_MAX - 7) #define ESP_TASK_TCPIP_STACK (CONFIG_LWIP_TCPIP_TASK_STACK_SIZE + TASK_EXTRA_STACK_SIZE) #define ESP_TASK_MAIN_PRIO (ESP_TASK_PRIO_MIN + 1) diff --git a/tools/sdk/esp32c3/include/esp_system/include/esp_xt_wdt.h b/tools/sdk/esp32c3/include/esp_system/include/esp_xt_wdt.h new file mode 100644 index 00000000000..3b39d8056dc --- /dev/null +++ b/tools/sdk/esp32c3/include/esp_system/include/esp_xt_wdt.h @@ -0,0 +1,63 @@ +/* + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include + +#include "esp_err.h" +#include "esp_intr_alloc.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief esp_xt_wdt configuration struct + * + */ +typedef struct { + uint8_t timeout; /*!< Watchdog timeout */ + bool auto_backup_clk_enable; /*!< Enable automatic switch to backup clock at timeout */ +} esp_xt_wdt_config_t; + +/* Callback function for WDT interrupt*/ +typedef void (*esp_xt_callback_t)(void *arg); + +/** + * @brief Initializes the xtal32k watchdog timer + * + * @param cfg Pointer to configuration struct + * @return esp_err_t + * - ESP_OK: XTWDT was successfully enabled + * - ESP_ERR_NO_MEM: Failed to allocate ISR + */ +esp_err_t esp_xt_wdt_init(const esp_xt_wdt_config_t *cfg); + +/** + * @brief Register a callback function that will be called when the watchdog + * times out. + * + * @note This function will be called from an interrupt context where the cache might be disabled. + * Thus the function should be placed in IRAM and must not perform any blocking operations. + * + * Only one callback function can be registered, any call to esp_xt_wdt_register_callback + * will override the previous callback function. + * + * @param func The callback function to register + * @param arg Pointer to argument that will be passed to the callback function + */ +void esp_xt_wdt_register_callback(esp_xt_callback_t func, void *arg); + +/** + * @brief Restores the xtal32k clock and re-enables the WDT + * + */ +void esp_xt_wdt_restore_clk(void); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32c3/include/esp_wifi/include/esp_mesh.h b/tools/sdk/esp32c3/include/esp_wifi/include/esp_mesh.h index ab8f8a4c86f..f146b5e730e 100644 --- a/tools/sdk/esp32c3/include/esp_wifi/include/esp_mesh.h +++ b/tools/sdk/esp32c3/include/esp_wifi/include/esp_mesh.h @@ -505,8 +505,13 @@ typedef struct { * @brief Mesh softAP configuration */ typedef struct { - uint8_t password[64]; /**< mesh softAP password */ - uint8_t max_connection; /**< max number of stations allowed to connect in, max 10 */ + uint8_t password[64]; /**< mesh softAP password */ + /** + * max number of stations allowed to connect in, default 6, max 10 + * = max_connection + nonmesh_max_connection + */ + uint8_t max_connection; /**< max mesh connections */ + uint8_t nonmesh_max_connection; /**< max non-mesh connections */ } mesh_ap_cfg_t; /** @@ -947,7 +952,8 @@ esp_err_t esp_mesh_set_ap_authmode(wifi_auth_mode_t authmode); wifi_auth_mode_t esp_mesh_get_ap_authmode(void); /** - * @brief Set mesh softAP max connection value + * @brief Set mesh max connection value + * - Set mesh softAP max connection = mesh max connection + non-mesh max connection * * @attention This API shall be called before mesh is started. * @@ -960,12 +966,19 @@ wifi_auth_mode_t esp_mesh_get_ap_authmode(void); esp_err_t esp_mesh_set_ap_connections(int connections); /** - * @brief Get mesh softAP max connection configuration + * @brief Get mesh max connection configuration * - * @return the number of max connections + * @return the number of mesh max connections */ int esp_mesh_get_ap_connections(void); +/** + * @brief Get non-mesh max connection configuration + * + * @return the number of non-mesh max connections + */ +int esp_mesh_get_non_mesh_connections(void); + /** * @brief Get current layer value over the mesh network * diff --git a/tools/sdk/esp32c3/include/esp_wifi/include/esp_wifi.h b/tools/sdk/esp32c3/include/esp_wifi/include/esp_wifi.h index dfd43bff440..51e03234841 100644 --- a/tools/sdk/esp32c3/include/esp_wifi/include/esp_wifi.h +++ b/tools/sdk/esp32c3/include/esp_wifi/include/esp_wifi.h @@ -1224,7 +1224,7 @@ esp_err_t esp_wifi_config_11b_rate(wifi_interface_t ifx, bool disable); * @attention 1. This API should be called after esp_wifi_init() and before esp_wifi_start(). * * @param ifx Interface to be configured. - * @param rate Only support 1M, 6M and MCS0_LGI + * @param rate Phy rate to be configured. * * @return * - ESP_OK: succeed @@ -1289,6 +1289,20 @@ esp_err_t esp_wifi_set_country_code(const char *country, bool ieee80211d_enabled */ esp_err_t esp_wifi_get_country_code(char *country); +/** + * @brief Config 80211 tx rate of specified interface + * + * @attention 1. This API should be called after esp_wifi_init() and before esp_wifi_start(). + * + * @param ifx Interface to be configured. + * @param rate Phy rate to be configured. + * + * @return + * - ESP_OK: succeed + * - others: failed + */ +esp_err_t esp_wifi_config_80211_tx_rate(wifi_interface_t ifx, wifi_phy_rate_t rate); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32c3/include/esp_wifi/include/esp_wifi_default.h b/tools/sdk/esp32c3/include/esp_wifi/include/esp_wifi_default.h index 958977bf25e..908ea2c113c 100644 --- a/tools/sdk/esp32c3/include/esp_wifi/include/esp_wifi_default.h +++ b/tools/sdk/esp32c3/include/esp_wifi/include/esp_wifi_default.h @@ -50,7 +50,7 @@ esp_err_t esp_netif_attach_wifi_ap(esp_netif_t *esp_netif); esp_err_t esp_wifi_set_default_wifi_sta_handlers(void); /** - * @brief Sets default wifi event handlers for STA interface + * @brief Sets default wifi event handlers for AP interface * * @return * - ESP_OK on success, error returned from esp_event_handler_register if failed diff --git a/tools/sdk/esp32c3/include/esp_wifi/include/esp_wifi_types.h b/tools/sdk/esp32c3/include/esp_wifi/include/esp_wifi_types.h index 03b8ae6a75e..503e8d7bb05 100644 --- a/tools/sdk/esp32c3/include/esp_wifi/include/esp_wifi_types.h +++ b/tools/sdk/esp32c3/include/esp_wifi/include/esp_wifi_types.h @@ -272,7 +272,8 @@ typedef struct { uint32_t phy_11g:1; /**< bit: 1 flag to identify if 11g mode is enabled or not */ uint32_t phy_11n:1; /**< bit: 2 flag to identify if 11n mode is enabled or not */ uint32_t phy_lr:1; /**< bit: 3 flag to identify if low rate is enabled or not */ - uint32_t reserved:28; /**< bit: 4..31 reserved */ + uint32_t is_mesh_child:1;/**< bit: 4 flag to identify mesh child */ + uint32_t reserved:27; /**< bit: 5..31 reserved */ } wifi_sta_info_t; #define ESP_WIFI_MAX_CONN_NUM (10) /**< max number of stations which can connect to ESP32 soft-AP */ @@ -669,12 +670,14 @@ typedef struct { typedef struct { uint8_t mac[6]; /**< MAC address of the station connected to ESP32 soft-AP */ uint8_t aid; /**< the aid that ESP32 soft-AP gives to the station connected to */ + bool is_mesh_child; /**< flag to identify mesh child */ } wifi_event_ap_staconnected_t; /** Argument structure for WIFI_EVENT_AP_STADISCONNECTED event */ typedef struct { uint8_t mac[6]; /**< MAC address of the station disconnects to ESP32 soft-AP */ uint8_t aid; /**< the aid that ESP32 soft-AP gave to the station disconnects to */ + bool is_mesh_child; /**< flag to identify mesh child */ } wifi_event_ap_stadisconnected_t; /** Argument structure for WIFI_EVENT_AP_PROBEREQRECVED event */ diff --git a/tools/sdk/esp32c3/include/freemodbus/common/include/esp_modbus_master.h b/tools/sdk/esp32c3/include/freemodbus/common/include/esp_modbus_master.h index 621348e1933..5d7539b08d9 100644 --- a/tools/sdk/esp32c3/include/freemodbus/common/include/esp_modbus_master.h +++ b/tools/sdk/esp32c3/include/freemodbus/common/include/esp_modbus_master.h @@ -232,7 +232,7 @@ esp_err_t mbc_master_get_cid_info(uint16_t cid, const mb_parameter_descriptor_t* * @return * - esp_err_t ESP_OK - request was successful and value buffer contains * representation of actual parameter data from slave - * - esp_err_t ESP_ERR_INVALID_ARG - invalid argument of function + * - esp_err_t ESP_ERR_INVALID_ARG - invalid argument of function or parameter descriptor * - esp_err_t ESP_ERR_INVALID_RESPONSE - an invalid response from slave * - esp_err_t ESP_ERR_INVALID_STATE - invalid state during data processing or allocation failure * - esp_err_t ESP_ERR_TIMEOUT - operation timed out and no response from slave @@ -253,7 +253,7 @@ esp_err_t mbc_master_get_parameter(uint16_t cid, char* name, uint8_t* value, uin * * @return * - esp_err_t ESP_OK - request was successful and value was saved in the slave device registers - * - esp_err_t ESP_ERR_INVALID_ARG - invalid argument of function + * - esp_err_t ESP_ERR_INVALID_ARG - invalid argument of function or parameter descriptor * - esp_err_t ESP_ERR_INVALID_RESPONSE - an invalid response from slave during processing of parameter * - esp_err_t ESP_ERR_INVALID_STATE - invalid state during data processing or allocation failure * - esp_err_t ESP_ERR_TIMEOUT - operation timed out and no response from slave diff --git a/tools/sdk/esp32/include/freertos/include/freertos/FreeRTOSConfig.h b/tools/sdk/esp32c3/include/freertos/include/esp_additions/freertos/FreeRTOSConfig.h similarity index 95% rename from tools/sdk/esp32/include/freertos/include/freertos/FreeRTOSConfig.h rename to tools/sdk/esp32c3/include/freertos/include/esp_additions/freertos/FreeRTOSConfig.h index c64cb980d85..a01a56e9fd4 100644 --- a/tools/sdk/esp32/include/freertos/include/freertos/FreeRTOSConfig.h +++ b/tools/sdk/esp32c3/include/freertos/include/esp_additions/freertos/FreeRTOSConfig.h @@ -71,10 +71,16 @@ #define FREERTOS_CONFIG_H #include "sdkconfig.h" -// The arch-specific FreeRTOSConfig.h in port//include. -#include_next "freertos/FreeRTOSConfig.h" -#if !(defined(FREERTOS_CONFIG_XTENSA_H) || defined(FREERTOS_CONFIG_RISCV_H)) +/* for likely and unlikely */ +#include "esp_compiler.h" + +// The arch-specific FreeRTOSConfig_arch.h in port//include. +#include "freertos/FreeRTOSConfig_arch.h" + +#if !(defined(FREERTOS_CONFIG_XTENSA_H) \ + || defined(FREERTOS_CONFIG_RISCV_H) \ + || defined(FREERTOS_CONFIG_LINUX_H)) #error "Needs architecture-speific FreeRTOSConfig.h!" #endif @@ -244,7 +250,9 @@ kept at 1. */ #define configKERNEL_INTERRUPT_PRIORITY 1 +#if !CONFIG_IDF_TARGET_LINUX #define configUSE_NEWLIB_REENTRANT 1 +#endif #define configSUPPORT_DYNAMIC_ALLOCATION 1 #define configSUPPORT_STATIC_ALLOCATION 1 @@ -273,11 +281,11 @@ extern void vPortCleanUpTCB ( void *pxTCB ); #endif //configUSE_TICKLESS_IDLE -#if CONFIG_ESP_COREDUMP_ENABLE +#if CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT #define configENABLE_TASK_SNAPSHOT 1 #endif #ifndef configENABLE_TASK_SNAPSHOT -#define configENABLE_TASK_SNAPSHOT 1 +#define configENABLE_TASK_SNAPSHOT 0 #endif #if CONFIG_SYSVIEW_ENABLE @@ -293,4 +301,9 @@ extern void vPortCleanUpTCB ( void *pxTCB ); #define configCHECK_MUTEX_GIVEN_BY_OWNER 0 #endif + +#define configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H 1 + +#define configTASK_NOTIFICATION_ARRAY_ENTRIES 1 + #endif /* FREERTOS_CONFIG_H */ diff --git a/tools/sdk/esp32c3/include/freertos/include/esp_additions/freertos/task_snapshot.h b/tools/sdk/esp32c3/include/freertos/include/esp_additions/freertos/task_snapshot.h new file mode 100644 index 00000000000..1ad04cce694 --- /dev/null +++ b/tools/sdk/esp32c3/include/freertos/include/esp_additions/freertos/task_snapshot.h @@ -0,0 +1,90 @@ +// Copyright 2015-2021 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 "freertos/FreeRTOS.h" +#include "freertos/task.h" + +#if ( configENABLE_TASK_SNAPSHOT == 1 ) + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Check `freertos_tasks_c_additions.h` file for more info + * about these functions declaration. + */ +UBaseType_t pxTCBGetSize ( void ); +ListItem_t* pxTCBGetStateListItem ( void *pxTCB ); +StackType_t* pxTCBGetStartOfStack ( void *pxTCB ); +StackType_t* pxTCBGetTopOfStack ( void *pxTCB ); +StackType_t* pxTCBGetEndOfStack ( void *pxTCB ); +List_t* pxListGetReadyTask ( UBaseType_t idx ); +List_t* pxListGetReadyPendingTask ( UBaseType_t idx ); +List_t* pxGetDelayedTaskList ( void ); +List_t* pxGetOverflowDelayedTaskList ( void ); +List_t* pxGetTasksWaitingTermination ( void ); +List_t* pxGetSuspendedTaskList ( void ); + +/** + * 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*/ +} TaskSnapshot_t; + + +/* + * This function fills array with TaskSnapshot_t structures for every task in the system. + * Used by panic handling code to get snapshots of all tasks in the system. + * Only available when configENABLE_TASK_SNAPSHOT is set to 1. + * @param pxTaskSnapshotArray Pointer to array of TaskSnapshot_t structures to store tasks snapshot data. + * @param uxArraySize Size of tasks snapshots array. + * @param pxTcbSz Pointer to store size of TCB. + * @return Number of elements stored in array. + */ +UBaseType_t uxTaskGetSnapshotAll( TaskSnapshot_t * const pxTaskSnapshotArray, const UBaseType_t uxArraySize, UBaseType_t * const pxTcbSz ); + +/* + * This function iterates over all tasks in the system. + * Used by panic handling code to iterate over tasks in the system. + * Only available when configENABLE_TASK_SNAPSHOT is set to 1. + * @note This function should not be used while FreeRTOS is running (as it doesn't acquire any locks). + * @param pxTask task handle. + * @return Handle for the next task. If pxTask is NULL, returns hadnle for the first task. + */ +TaskHandle_t pxTaskGetNext( TaskHandle_t pxTask ); + +/* + * This function fills TaskSnapshot_t structure for specified task. + * Used by panic handling code to get snapshot of a task. + * Only available when configENABLE_TASK_SNAPSHOT is set to 1. + * @note This function should not be used while FreeRTOS is running (as it doesn't acquire any locks). + * @param pxTask task handle. + * @param pxTaskSnapshot address of TaskSnapshot_t structure to fill. + */ +void vTaskGetSnapshot( TaskHandle_t pxTask, TaskSnapshot_t *pxTaskSnapshot ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/tools/sdk/esp32c3/include/freertos/include/esp_additions/freertos_tasks_c_additions.h b/tools/sdk/esp32c3/include/freertos/include/esp_additions/freertos_tasks_c_additions.h new file mode 100644 index 00000000000..464c0b3ffb9 --- /dev/null +++ b/tools/sdk/esp32c3/include/freertos/include/esp_additions/freertos_tasks_c_additions.h @@ -0,0 +1,80 @@ +// Copyright 2015-2021 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 + +/** + * This file will be included in `tasks.c` file, thus, it must NOT be included + * by any (other) file. + * The functions below only consist in getters for the static variables in + * `tasks.c` file. + * The only source files that should call these functions are the ones in + * `/additions` directory. + */ + +#if ( configENABLE_TASK_SNAPSHOT == 1 ) + + UBaseType_t pxTCBGetSize ( void ) + { + return sizeof(TCB_t); + } + + ListItem_t* pxTCBGetStateListItem ( void *pxTCB ) + { + return &(((TCB_t*)pxTCB)->xStateListItem); + } + + StackType_t* pxTCBGetStartOfStack ( void *pxTCB ) + { + return (StackType_t*) ((TCB_t*)pxTCB)->pxStack; + } + + StackType_t* pxTCBGetTopOfStack ( void *pxTCB ) + { + return (StackType_t*) ((TCB_t*)pxTCB)->pxTopOfStack; + } + + StackType_t* pxTCBGetEndOfStack ( void *pxTCB ) + { + return (StackType_t*) ((TCB_t*)pxTCB)->pxEndOfStack; + } + + + List_t* pxListGetReadyTask ( UBaseType_t idx ) + { + return &( pxReadyTasksLists[idx] ); + } + + List_t* pxListGetReadyPendingTask ( UBaseType_t idx ) + { + return &( xPendingReadyList[idx] ); + } + + List_t* pxGetDelayedTaskList ( void ) { + return pxDelayedTaskList; + } + + List_t* pxGetOverflowDelayedTaskList ( void ) { + return pxOverflowDelayedTaskList; + } + + List_t* pxGetTasksWaitingTermination ( void ) { + return &xTasksWaitingTermination; + } + + List_t* pxGetSuspendedTaskList ( void ) { + return &xSuspendedTaskList; + } + +#endif diff --git a/tools/sdk/esp32c3/include/freertos/include/freertos/FreeRTOS.h b/tools/sdk/esp32c3/include/freertos/include/freertos/FreeRTOS.h index 2c9c5b13d00..eb0ee6be357 100644 --- a/tools/sdk/esp32c3/include/freertos/include/freertos/FreeRTOS.h +++ b/tools/sdk/esp32c3/include/freertos/include/freertos/FreeRTOS.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ #ifndef INC_FREERTOS_H @@ -46,16 +45,16 @@ * contains the typedefs required to build FreeRTOS. Read the instructions * in FreeRTOS/source/stdint.readme for more information. */ -#include /* READ COMMENT ABOVE. */ +#include /* READ COMMENT ABOVE. */ +/* *INDENT-OFF* */ #ifdef __cplusplus -extern "C" { + extern "C" { #endif -/* for likely and unlikely */ -#include "esp_compiler.h" +/* *INDENT-ON* */ /* Application specific configuration options. */ -#include "freertos/FreeRTOSConfig.h" +#include "FreeRTOSConfig.h" /* Basic FreeRTOS definitions. */ #include "projdefs.h" @@ -65,13 +64,14 @@ extern "C" { /* Must be defaulted before configUSE_NEWLIB_REENTRANT is used below. */ #ifndef configUSE_NEWLIB_REENTRANT - #define configUSE_NEWLIB_REENTRANT 0 + #define configUSE_NEWLIB_REENTRANT 0 #endif /* Required if struct _reent is used. */ #if ( configUSE_NEWLIB_REENTRANT == 1 ) - #include + #include #endif + /* * Check all the required application specific macros have been defined. * These macros are application specific and (as downloaded) are defined @@ -79,503 +79,545 @@ extern "C" { */ #ifndef configMINIMAL_STACK_SIZE - #error Missing definition: configMINIMAL_STACK_SIZE must be defined in FreeRTOSConfig.h. configMINIMAL_STACK_SIZE defines the size (in words) of the stack allocated to the idle task. Refer to the demo project provided for your port for a suitable value. + #error Missing definition: configMINIMAL_STACK_SIZE must be defined in FreeRTOSConfig.h. configMINIMAL_STACK_SIZE defines the size (in words) of the stack allocated to the idle task. Refer to the demo project provided for your port for a suitable value. #endif #ifndef configMAX_PRIORITIES - #error Missing definition: configMAX_PRIORITIES must be defined in FreeRTOSConfig.h. See the Configuration section of the FreeRTOS API documentation for details. + #error Missing definition: configMAX_PRIORITIES must be defined in FreeRTOSConfig.h. See the Configuration section of the FreeRTOS API documentation for details. #endif #if configMAX_PRIORITIES < 1 - #error configMAX_PRIORITIES must be defined to be greater than or equal to 1. + #error configMAX_PRIORITIES must be defined to be greater than or equal to 1. #endif #ifndef configUSE_PREEMPTION - #error Missing definition: configUSE_PREEMPTION must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. + #error Missing definition: configUSE_PREEMPTION must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. #endif #ifndef configUSE_IDLE_HOOK - #error Missing definition: configUSE_IDLE_HOOK must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. + #error Missing definition: configUSE_IDLE_HOOK must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. #endif #ifndef configUSE_TICK_HOOK - #error Missing definition: configUSE_TICK_HOOK must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. + #error Missing definition: configUSE_TICK_HOOK must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. #endif #ifndef configUSE_16_BIT_TICKS - #error Missing definition: configUSE_16_BIT_TICKS must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. + #error Missing definition: configUSE_16_BIT_TICKS must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. #endif #ifndef configUSE_CO_ROUTINES - #define configUSE_CO_ROUTINES 0 + #define configUSE_CO_ROUTINES 0 #endif #ifndef INCLUDE_vTaskPrioritySet - #define INCLUDE_vTaskPrioritySet 0 + #define INCLUDE_vTaskPrioritySet 0 #endif #ifndef INCLUDE_uxTaskPriorityGet - #define INCLUDE_uxTaskPriorityGet 0 + #define INCLUDE_uxTaskPriorityGet 0 #endif #ifndef INCLUDE_vTaskDelete - #define INCLUDE_vTaskDelete 0 + #define INCLUDE_vTaskDelete 0 #endif #ifndef INCLUDE_vTaskSuspend - #define INCLUDE_vTaskSuspend 0 + #define INCLUDE_vTaskSuspend 0 +#endif + +#ifdef INCLUDE_xTaskDelayUntil + #ifdef INCLUDE_vTaskDelayUntil + /* INCLUDE_vTaskDelayUntil was replaced by INCLUDE_xTaskDelayUntil. Backward + * compatibility is maintained if only one or the other is defined, but + * there is a conflict if both are defined. */ + #error INCLUDE_vTaskDelayUntil and INCLUDE_xTaskDelayUntil are both defined. INCLUDE_vTaskDelayUntil is no longer required and should be removed + #endif #endif -#ifndef INCLUDE_vTaskDelayUntil - #define INCLUDE_vTaskDelayUntil 0 +#ifndef INCLUDE_xTaskDelayUntil + #ifdef INCLUDE_vTaskDelayUntil + /* If INCLUDE_vTaskDelayUntil is set but INCLUDE_xTaskDelayUntil is not then + * the project's FreeRTOSConfig.h probably pre-dates the introduction of + * xTaskDelayUntil and setting INCLUDE_xTaskDelayUntil to whatever + * INCLUDE_vTaskDelayUntil is set to will ensure backward compatibility. + */ + #define INCLUDE_xTaskDelayUntil INCLUDE_vTaskDelayUntil + #endif +#endif + +#ifndef INCLUDE_xTaskDelayUntil + #define INCLUDE_xTaskDelayUntil 0 #endif #ifndef INCLUDE_vTaskDelay - #define INCLUDE_vTaskDelay 0 + #define INCLUDE_vTaskDelay 0 #endif #ifndef INCLUDE_xTaskGetIdleTaskHandle - #define INCLUDE_xTaskGetIdleTaskHandle 0 + #define INCLUDE_xTaskGetIdleTaskHandle 0 #endif #ifndef INCLUDE_xTaskAbortDelay - #define INCLUDE_xTaskAbortDelay 0 + #define INCLUDE_xTaskAbortDelay 0 #endif #ifndef INCLUDE_xQueueGetMutexHolder - #define INCLUDE_xQueueGetMutexHolder 0 + #define INCLUDE_xQueueGetMutexHolder 0 #endif #ifndef INCLUDE_xSemaphoreGetMutexHolder - #define INCLUDE_xSemaphoreGetMutexHolder INCLUDE_xQueueGetMutexHolder + #define INCLUDE_xSemaphoreGetMutexHolder INCLUDE_xQueueGetMutexHolder #endif #ifndef INCLUDE_xTaskGetHandle - #define INCLUDE_xTaskGetHandle 0 + #define INCLUDE_xTaskGetHandle 0 #endif #ifndef INCLUDE_uxTaskGetStackHighWaterMark - #define INCLUDE_uxTaskGetStackHighWaterMark 0 + #define INCLUDE_uxTaskGetStackHighWaterMark 0 #endif #ifndef INCLUDE_uxTaskGetStackHighWaterMark2 - #define INCLUDE_uxTaskGetStackHighWaterMark2 0 + #define INCLUDE_uxTaskGetStackHighWaterMark2 0 #endif #ifndef INCLUDE_eTaskGetState - #define INCLUDE_eTaskGetState 0 + #define INCLUDE_eTaskGetState 0 #endif #ifndef INCLUDE_xTaskResumeFromISR - #define INCLUDE_xTaskResumeFromISR 1 + #define INCLUDE_xTaskResumeFromISR 1 #endif #ifndef INCLUDE_xTimerPendFunctionCall - #define INCLUDE_xTimerPendFunctionCall 0 + #define INCLUDE_xTimerPendFunctionCall 0 #endif #ifndef INCLUDE_xTaskGetSchedulerState - #define INCLUDE_xTaskGetSchedulerState 0 + #define INCLUDE_xTaskGetSchedulerState 0 #endif #ifndef INCLUDE_xTaskGetCurrentTaskHandle - #define INCLUDE_xTaskGetCurrentTaskHandle 0 + #define INCLUDE_xTaskGetCurrentTaskHandle 0 #endif #if configUSE_CO_ROUTINES != 0 - #ifndef configMAX_CO_ROUTINE_PRIORITIES - #error configMAX_CO_ROUTINE_PRIORITIES must be greater than or equal to 1. - #endif + #ifndef configMAX_CO_ROUTINE_PRIORITIES + #error configMAX_CO_ROUTINE_PRIORITIES must be greater than or equal to 1. + #endif #endif #ifndef configUSE_DAEMON_TASK_STARTUP_HOOK - #define configUSE_DAEMON_TASK_STARTUP_HOOK 0 + #define configUSE_DAEMON_TASK_STARTUP_HOOK 0 #endif #ifndef configUSE_APPLICATION_TASK_TAG - #define configUSE_APPLICATION_TASK_TAG 0 + #define configUSE_APPLICATION_TASK_TAG 0 #endif #ifndef configNUM_THREAD_LOCAL_STORAGE_POINTERS - #define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0 + #define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0 #endif #ifndef configUSE_RECURSIVE_MUTEXES - #define configUSE_RECURSIVE_MUTEXES 0 + #define configUSE_RECURSIVE_MUTEXES 0 #endif #ifndef configUSE_MUTEXES - #define configUSE_MUTEXES 0 + #define configUSE_MUTEXES 0 #endif #ifndef configUSE_TIMERS - #define configUSE_TIMERS 0 + #define configUSE_TIMERS 0 #endif #ifndef configUSE_COUNTING_SEMAPHORES - #define configUSE_COUNTING_SEMAPHORES 0 + #define configUSE_COUNTING_SEMAPHORES 0 #endif #ifndef configUSE_ALTERNATIVE_API - #define configUSE_ALTERNATIVE_API 0 + #define configUSE_ALTERNATIVE_API 0 #endif #ifndef portCRITICAL_NESTING_IN_TCB - #define portCRITICAL_NESTING_IN_TCB 0 + #define portCRITICAL_NESTING_IN_TCB 0 #endif #ifndef configMAX_TASK_NAME_LEN - #define configMAX_TASK_NAME_LEN 16 + #define configMAX_TASK_NAME_LEN 16 #endif #ifndef configIDLE_SHOULD_YIELD - #define configIDLE_SHOULD_YIELD 1 + #define configIDLE_SHOULD_YIELD 1 #endif #if configMAX_TASK_NAME_LEN < 1 - #error configMAX_TASK_NAME_LEN must be set to a minimum of 1 in FreeRTOSConfig.h + #error configMAX_TASK_NAME_LEN must be set to a minimum of 1 in FreeRTOSConfig.h #endif #ifndef configASSERT - #define configASSERT( x ) - #define configASSERT_DEFINED 0 + #define configASSERT( x ) + #define configASSERT_DEFINED 0 #else - #define configASSERT_DEFINED 1 + #define configASSERT_DEFINED 1 #endif -/* configPRECONDITION should be resolve to configASSERT. - The CBMC proofs need a way to track assumptions and assertions. - A configPRECONDITION statement should express an implicit invariant or assumption made. - A configASSERT statement should express an invariant that must hold explicit before calling - the code. */ +/* configPRECONDITION should be defined as configASSERT. + * The CBMC proofs need a way to track assumptions and assertions. + * A configPRECONDITION statement should express an implicit invariant or + * assumption made. A configASSERT statement should express an invariant that must + * hold explicit before calling the code. */ #ifndef configPRECONDITION - #define configPRECONDITION( X ) configASSERT(X) - #define configPRECONDITION_DEFINED 0 + #define configPRECONDITION( X ) configASSERT( X ) + #define configPRECONDITION_DEFINED 0 #else - #define configPRECONDITION_DEFINED 1 + #define configPRECONDITION_DEFINED 1 #endif #ifndef portMEMORY_BARRIER - #define portMEMORY_BARRIER() + #define portMEMORY_BARRIER() +#endif + +#ifndef portSOFTWARE_BARRIER + #define portSOFTWARE_BARRIER() #endif /* The timers module relies on xTaskGetSchedulerState(). */ #if configUSE_TIMERS == 1 - #ifndef configTIMER_TASK_PRIORITY - #error If configUSE_TIMERS is set to 1 then configTIMER_TASK_PRIORITY must also be defined. - #endif /* configTIMER_TASK_PRIORITY */ + #ifndef configTIMER_TASK_PRIORITY + #error If configUSE_TIMERS is set to 1 then configTIMER_TASK_PRIORITY must also be defined. + #endif /* configTIMER_TASK_PRIORITY */ - #ifndef configTIMER_QUEUE_LENGTH - #error If configUSE_TIMERS is set to 1 then configTIMER_QUEUE_LENGTH must also be defined. - #endif /* configTIMER_QUEUE_LENGTH */ + #ifndef configTIMER_QUEUE_LENGTH + #error If configUSE_TIMERS is set to 1 then configTIMER_QUEUE_LENGTH must also be defined. + #endif /* configTIMER_QUEUE_LENGTH */ - #ifndef configTIMER_TASK_STACK_DEPTH - #error If configUSE_TIMERS is set to 1 then configTIMER_TASK_STACK_DEPTH must also be defined. - #endif /* configTIMER_TASK_STACK_DEPTH */ + #ifndef configTIMER_TASK_STACK_DEPTH + #error If configUSE_TIMERS is set to 1 then configTIMER_TASK_STACK_DEPTH must also be defined. + #endif /* configTIMER_TASK_STACK_DEPTH */ #endif /* configUSE_TIMERS */ #ifndef portSET_INTERRUPT_MASK_FROM_ISR - #define portSET_INTERRUPT_MASK_FROM_ISR() 0 + #define portSET_INTERRUPT_MASK_FROM_ISR() 0 #endif #ifndef portCLEAR_INTERRUPT_MASK_FROM_ISR - #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusValue ) ( void ) uxSavedStatusValue + #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusValue ) ( void ) uxSavedStatusValue #endif #ifndef portCLEAN_UP_TCB - #define portCLEAN_UP_TCB( pxTCB ) ( void ) pxTCB + #define portCLEAN_UP_TCB( pxTCB ) ( void ) pxTCB #endif #ifndef portPRE_TASK_DELETE_HOOK - #define portPRE_TASK_DELETE_HOOK( pvTaskToDelete, pxYieldPending ) + #define portPRE_TASK_DELETE_HOOK( pvTaskToDelete, pxYieldPending ) #endif #ifndef portSETUP_TCB - #define portSETUP_TCB( pxTCB ) ( void ) pxTCB + #define portSETUP_TCB( pxTCB ) ( void ) pxTCB #endif #ifndef configQUEUE_REGISTRY_SIZE - #define configQUEUE_REGISTRY_SIZE 0U + #define configQUEUE_REGISTRY_SIZE 0U #endif #if ( configQUEUE_REGISTRY_SIZE < 1 ) - #define vQueueAddToRegistry( xQueue, pcName ) - #define vQueueUnregisterQueue( xQueue ) - #define pcQueueGetName( xQueue ) + #define vQueueAddToRegistry( xQueue, pcName ) + #define vQueueUnregisterQueue( xQueue ) + #define pcQueueGetName( xQueue ) #endif #ifndef portPOINTER_SIZE_TYPE - #define portPOINTER_SIZE_TYPE uint32_t + #define portPOINTER_SIZE_TYPE uint32_t #endif /* Remove any unused trace macros. */ #ifndef traceSTART - /* Used to perform any necessary initialisation - for example, open a file - into which trace is to be written. */ - #define traceSTART() + +/* Used to perform any necessary initialisation - for example, open a file + * into which trace is to be written. */ + #define traceSTART() #endif #ifndef traceEND - /* Use to close a trace, for example close a file into which trace has been - written. */ - #define traceEND() + +/* Use to close a trace, for example close a file into which trace has been + * written. */ + #define traceEND() #endif #ifndef traceTASK_SWITCHED_IN - /* Called after a task has been selected to run. pxCurrentTCB holds a pointer - to the task control block of the selected task. */ - #define traceTASK_SWITCHED_IN() + +/* Called after a task has been selected to run. pxCurrentTCB holds a pointer + * to the task control block of the selected task. */ + #define traceTASK_SWITCHED_IN() #endif #ifndef traceINCREASE_TICK_COUNT - /* Called before stepping the tick count after waking from tickless idle - sleep. */ - #define traceINCREASE_TICK_COUNT( x ) + +/* Called before stepping the tick count after waking from tickless idle + * sleep. */ + #define traceINCREASE_TICK_COUNT( x ) #endif #ifndef traceLOW_POWER_IDLE_BEGIN - /* Called immediately before entering tickless idle. */ - #define traceLOW_POWER_IDLE_BEGIN() + /* Called immediately before entering tickless idle. */ + #define traceLOW_POWER_IDLE_BEGIN() #endif -#ifndef traceLOW_POWER_IDLE_END - /* Called when returning to the Idle task after a tickless idle. */ - #define traceLOW_POWER_IDLE_END() +#ifndef traceLOW_POWER_IDLE_END + /* Called when returning to the Idle task after a tickless idle. */ + #define traceLOW_POWER_IDLE_END() #endif #ifndef traceTASK_SWITCHED_OUT - /* Called before a task has been selected to run. pxCurrentTCB holds a pointer - to the task control block of the task being switched out. */ - #define traceTASK_SWITCHED_OUT() + +/* Called before a task has been selected to run. pxCurrentTCB holds a pointer + * to the task control block of the task being switched out. */ + #define traceTASK_SWITCHED_OUT() #endif #ifndef traceTASK_PRIORITY_INHERIT - /* Called when a task attempts to take a mutex that is already held by a - lower priority task. pxTCBOfMutexHolder is a pointer to the TCB of the task - that holds the mutex. uxInheritedPriority is the priority the mutex holder - will inherit (the priority of the task that is attempting to obtain the - muted. */ - #define traceTASK_PRIORITY_INHERIT( pxTCBOfMutexHolder, uxInheritedPriority ) + +/* Called when a task attempts to take a mutex that is already held by a + * lower priority task. pxTCBOfMutexHolder is a pointer to the TCB of the task + * that holds the mutex. uxInheritedPriority is the priority the mutex holder + * will inherit (the priority of the task that is attempting to obtain the + * muted. */ + #define traceTASK_PRIORITY_INHERIT( pxTCBOfMutexHolder, uxInheritedPriority ) #endif #ifndef traceTASK_PRIORITY_DISINHERIT - /* Called when a task releases a mutex, the holding of which had resulted in - the task inheriting the priority of a higher priority task. - pxTCBOfMutexHolder is a pointer to the TCB of the task that is releasing the - mutex. uxOriginalPriority is the task's configured (base) priority. */ - #define traceTASK_PRIORITY_DISINHERIT( pxTCBOfMutexHolder, uxOriginalPriority ) + +/* Called when a task releases a mutex, the holding of which had resulted in + * the task inheriting the priority of a higher priority task. + * pxTCBOfMutexHolder is a pointer to the TCB of the task that is releasing the + * mutex. uxOriginalPriority is the task's configured (base) priority. */ + #define traceTASK_PRIORITY_DISINHERIT( pxTCBOfMutexHolder, uxOriginalPriority ) #endif #ifndef traceBLOCKING_ON_QUEUE_RECEIVE - /* Task is about to block because it cannot read from a - queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore - upon which the read was attempted. pxCurrentTCB points to the TCB of the - task that attempted the read. */ - #define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ) + +/* Task is about to block because it cannot read from a + * queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore + * upon which the read was attempted. pxCurrentTCB points to the TCB of the + * task that attempted the read. */ + #define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ) #endif #ifndef traceBLOCKING_ON_QUEUE_PEEK - /* Task is about to block because it cannot read from a - queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore - upon which the read was attempted. pxCurrentTCB points to the TCB of the - task that attempted the read. */ - #define traceBLOCKING_ON_QUEUE_PEEK( pxQueue ) + +/* Task is about to block because it cannot read from a + * queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore + * upon which the read was attempted. pxCurrentTCB points to the TCB of the + * task that attempted the read. */ + #define traceBLOCKING_ON_QUEUE_PEEK( pxQueue ) #endif #ifndef traceBLOCKING_ON_QUEUE_SEND - /* Task is about to block because it cannot write to a - queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore - upon which the write was attempted. pxCurrentTCB points to the TCB of the - task that attempted the write. */ - #define traceBLOCKING_ON_QUEUE_SEND( pxQueue ) + +/* Task is about to block because it cannot write to a + * queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore + * upon which the write was attempted. pxCurrentTCB points to the TCB of the + * task that attempted the write. */ + #define traceBLOCKING_ON_QUEUE_SEND( pxQueue ) #endif #ifndef configCHECK_FOR_STACK_OVERFLOW - #define configCHECK_FOR_STACK_OVERFLOW 0 + #define configCHECK_FOR_STACK_OVERFLOW 0 #endif #ifndef configRECORD_STACK_HIGH_ADDRESS - #define configRECORD_STACK_HIGH_ADDRESS 0 + #define configRECORD_STACK_HIGH_ADDRESS 0 #endif #ifndef configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H - #define configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H 0 + #define configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H 0 #endif /* The following event macros are embedded in the kernel API calls. */ #ifndef traceMOVED_TASK_TO_READY_STATE - #define traceMOVED_TASK_TO_READY_STATE( pxTCB ) + #define traceMOVED_TASK_TO_READY_STATE( pxTCB ) #endif #ifndef tracePOST_MOVED_TASK_TO_READY_STATE - #define tracePOST_MOVED_TASK_TO_READY_STATE( pxTCB ) + #define tracePOST_MOVED_TASK_TO_READY_STATE( pxTCB ) #endif #ifndef traceQUEUE_CREATE - #define traceQUEUE_CREATE( pxNewQueue ) + #define traceQUEUE_CREATE( pxNewQueue ) #endif #ifndef traceQUEUE_CREATE_FAILED - #define traceQUEUE_CREATE_FAILED( ucQueueType ) + #define traceQUEUE_CREATE_FAILED( ucQueueType ) #endif #ifndef traceCREATE_MUTEX - #define traceCREATE_MUTEX( pxNewQueue ) + #define traceCREATE_MUTEX( pxNewQueue ) #endif #ifndef traceCREATE_MUTEX_FAILED - #define traceCREATE_MUTEX_FAILED() + #define traceCREATE_MUTEX_FAILED() #endif #ifndef traceGIVE_MUTEX_RECURSIVE - #define traceGIVE_MUTEX_RECURSIVE( pxMutex ) + #define traceGIVE_MUTEX_RECURSIVE( pxMutex ) #endif #ifndef traceGIVE_MUTEX_RECURSIVE_FAILED - #define traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex ) + #define traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex ) #endif #ifndef traceTAKE_MUTEX_RECURSIVE - #define traceTAKE_MUTEX_RECURSIVE( pxMutex ) + #define traceTAKE_MUTEX_RECURSIVE( pxMutex ) #endif #ifndef traceTAKE_MUTEX_RECURSIVE_FAILED - #define traceTAKE_MUTEX_RECURSIVE_FAILED( pxMutex ) + #define traceTAKE_MUTEX_RECURSIVE_FAILED( pxMutex ) #endif #ifndef traceCREATE_COUNTING_SEMAPHORE - #define traceCREATE_COUNTING_SEMAPHORE() + #define traceCREATE_COUNTING_SEMAPHORE() #endif #ifndef traceCREATE_COUNTING_SEMAPHORE_FAILED - #define traceCREATE_COUNTING_SEMAPHORE_FAILED() + #define traceCREATE_COUNTING_SEMAPHORE_FAILED() #endif +#ifndef traceQUEUE_SET_SEND + #define traceQUEUE_SET_SEND traceQUEUE_SEND +#endif + +#ifdef ESP_PLATFORM #ifndef traceQUEUE_SEMAPHORE_RECEIVE - #define traceQUEUE_SEMAPHORE_RECEIVE( pxQueue ) + #define traceQUEUE_SEMAPHORE_RECEIVE( pxQueue ) #endif +#endif // ESP_PLATFORM #ifndef traceQUEUE_SEND - #define traceQUEUE_SEND( pxQueue ) + #define traceQUEUE_SEND( pxQueue ) #endif #ifndef traceQUEUE_SEND_FAILED - #define traceQUEUE_SEND_FAILED( pxQueue ) + #define traceQUEUE_SEND_FAILED( pxQueue ) #endif #ifndef traceQUEUE_RECEIVE - #define traceQUEUE_RECEIVE( pxQueue ) + #define traceQUEUE_RECEIVE( pxQueue ) #endif #ifndef traceQUEUE_PEEK - #define traceQUEUE_PEEK( pxQueue ) + #define traceQUEUE_PEEK( pxQueue ) #endif #ifndef traceQUEUE_PEEK_FAILED - #define traceQUEUE_PEEK_FAILED( pxQueue ) + #define traceQUEUE_PEEK_FAILED( pxQueue ) #endif #ifndef traceQUEUE_PEEK_FROM_ISR - #define traceQUEUE_PEEK_FROM_ISR( pxQueue ) + #define traceQUEUE_PEEK_FROM_ISR( pxQueue ) #endif #ifndef traceQUEUE_RECEIVE_FAILED - #define traceQUEUE_RECEIVE_FAILED( pxQueue ) + #define traceQUEUE_RECEIVE_FAILED( pxQueue ) #endif #ifndef traceQUEUE_SEND_FROM_ISR - #define traceQUEUE_SEND_FROM_ISR( pxQueue ) + #define traceQUEUE_SEND_FROM_ISR( pxQueue ) #endif #ifndef traceQUEUE_SEND_FROM_ISR_FAILED - #define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ) + #define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ) #endif #ifndef traceQUEUE_RECEIVE_FROM_ISR - #define traceQUEUE_RECEIVE_FROM_ISR( pxQueue ) + #define traceQUEUE_RECEIVE_FROM_ISR( pxQueue ) #endif #ifndef traceQUEUE_RECEIVE_FROM_ISR_FAILED - #define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue ) + #define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue ) #endif #ifndef traceQUEUE_PEEK_FROM_ISR_FAILED - #define traceQUEUE_PEEK_FROM_ISR_FAILED( pxQueue ) + #define traceQUEUE_PEEK_FROM_ISR_FAILED( pxQueue ) #endif #ifndef traceQUEUE_DELETE - #define traceQUEUE_DELETE( pxQueue ) + #define traceQUEUE_DELETE( pxQueue ) #endif +#ifdef ESP_PLATFORM #ifndef traceQUEUE_GIVE_FROM_ISR - #define traceQUEUE_GIVE_FROM_ISR( pxQueue ) + #define traceQUEUE_GIVE_FROM_ISR( pxQueue ) #endif #ifndef traceQUEUE_GIVE_FROM_ISR_FAILED - #define traceQUEUE_GIVE_FROM_ISR_FAILED( pxQueue ) + #define traceQUEUE_GIVE_FROM_ISR_FAILED( pxQueue ) #endif +#endif // ESP_PLATFORM #ifndef traceTASK_CREATE - #define traceTASK_CREATE( pxNewTCB ) + #define traceTASK_CREATE( pxNewTCB ) #endif #ifndef traceTASK_CREATE_FAILED - #define traceTASK_CREATE_FAILED() + #define traceTASK_CREATE_FAILED() #endif #ifndef traceTASK_DELETE - #define traceTASK_DELETE( pxTaskToDelete ) + #define traceTASK_DELETE( pxTaskToDelete ) #endif #ifndef traceTASK_DELAY_UNTIL - #define traceTASK_DELAY_UNTIL( x ) + #define traceTASK_DELAY_UNTIL( x ) #endif #ifndef traceTASK_DELAY - #define traceTASK_DELAY() + #define traceTASK_DELAY() #endif #ifndef traceTASK_PRIORITY_SET - #define traceTASK_PRIORITY_SET( pxTask, uxNewPriority ) + #define traceTASK_PRIORITY_SET( pxTask, uxNewPriority ) #endif #ifndef traceTASK_SUSPEND - #define traceTASK_SUSPEND( pxTaskToSuspend ) + #define traceTASK_SUSPEND( pxTaskToSuspend ) #endif #ifndef traceTASK_RESUME - #define traceTASK_RESUME( pxTaskToResume ) + #define traceTASK_RESUME( pxTaskToResume ) #endif #ifndef traceTASK_RESUME_FROM_ISR - #define traceTASK_RESUME_FROM_ISR( pxTaskToResume ) + #define traceTASK_RESUME_FROM_ISR( pxTaskToResume ) #endif #ifndef traceTASK_INCREMENT_TICK - #define traceTASK_INCREMENT_TICK( xTickCount ) + #define traceTASK_INCREMENT_TICK( xTickCount ) #endif #ifndef traceTIMER_CREATE - #define traceTIMER_CREATE( pxNewTimer ) + #define traceTIMER_CREATE( pxNewTimer ) #endif #ifndef traceTIMER_CREATE_FAILED - #define traceTIMER_CREATE_FAILED() + #define traceTIMER_CREATE_FAILED() #endif #ifndef traceTIMER_COMMAND_SEND - #define traceTIMER_COMMAND_SEND( xTimer, xMessageID, xMessageValueValue, xReturn ) + #define traceTIMER_COMMAND_SEND( xTimer, xMessageID, xMessageValueValue, xReturn ) #endif #ifndef traceTIMER_EXPIRED - #define traceTIMER_EXPIRED( pxTimer ) + #define traceTIMER_EXPIRED( pxTimer ) #endif #ifndef traceTIMER_COMMAND_RECEIVED - #define traceTIMER_COMMAND_RECEIVED( pxTimer, xMessageID, xMessageValue ) + #define traceTIMER_COMMAND_RECEIVED( pxTimer, xMessageID, xMessageValue ) #endif #ifndef traceMALLOC @@ -587,445 +629,470 @@ extern "C" { #endif #ifndef traceEVENT_GROUP_CREATE - #define traceEVENT_GROUP_CREATE( xEventGroup ) + #define traceEVENT_GROUP_CREATE( xEventGroup ) #endif #ifndef traceEVENT_GROUP_CREATE_FAILED - #define traceEVENT_GROUP_CREATE_FAILED() + #define traceEVENT_GROUP_CREATE_FAILED() #endif #ifndef traceEVENT_GROUP_SYNC_BLOCK - #define traceEVENT_GROUP_SYNC_BLOCK( xEventGroup, uxBitsToSet, uxBitsToWaitFor ) + #define traceEVENT_GROUP_SYNC_BLOCK( xEventGroup, uxBitsToSet, uxBitsToWaitFor ) #endif #ifndef traceEVENT_GROUP_SYNC_END - #define traceEVENT_GROUP_SYNC_END( xEventGroup, uxBitsToSet, uxBitsToWaitFor, xTimeoutOccurred ) ( void ) xTimeoutOccurred + #define traceEVENT_GROUP_SYNC_END( xEventGroup, uxBitsToSet, uxBitsToWaitFor, xTimeoutOccurred ) ( void ) xTimeoutOccurred #endif #ifndef traceEVENT_GROUP_WAIT_BITS_BLOCK - #define traceEVENT_GROUP_WAIT_BITS_BLOCK( xEventGroup, uxBitsToWaitFor ) + #define traceEVENT_GROUP_WAIT_BITS_BLOCK( xEventGroup, uxBitsToWaitFor ) #endif #ifndef traceEVENT_GROUP_WAIT_BITS_END - #define traceEVENT_GROUP_WAIT_BITS_END( xEventGroup, uxBitsToWaitFor, xTimeoutOccurred ) ( void ) xTimeoutOccurred + #define traceEVENT_GROUP_WAIT_BITS_END( xEventGroup, uxBitsToWaitFor, xTimeoutOccurred ) ( void ) xTimeoutOccurred #endif #ifndef traceEVENT_GROUP_CLEAR_BITS - #define traceEVENT_GROUP_CLEAR_BITS( xEventGroup, uxBitsToClear ) + #define traceEVENT_GROUP_CLEAR_BITS( xEventGroup, uxBitsToClear ) #endif #ifndef traceEVENT_GROUP_CLEAR_BITS_FROM_ISR - #define traceEVENT_GROUP_CLEAR_BITS_FROM_ISR( xEventGroup, uxBitsToClear ) + #define traceEVENT_GROUP_CLEAR_BITS_FROM_ISR( xEventGroup, uxBitsToClear ) #endif #ifndef traceEVENT_GROUP_SET_BITS - #define traceEVENT_GROUP_SET_BITS( xEventGroup, uxBitsToSet ) + #define traceEVENT_GROUP_SET_BITS( xEventGroup, uxBitsToSet ) #endif #ifndef traceEVENT_GROUP_SET_BITS_FROM_ISR - #define traceEVENT_GROUP_SET_BITS_FROM_ISR( xEventGroup, uxBitsToSet ) + #define traceEVENT_GROUP_SET_BITS_FROM_ISR( xEventGroup, uxBitsToSet ) #endif #ifndef traceEVENT_GROUP_DELETE - #define traceEVENT_GROUP_DELETE( xEventGroup ) + #define traceEVENT_GROUP_DELETE( xEventGroup ) #endif #ifndef tracePEND_FUNC_CALL - #define tracePEND_FUNC_CALL(xFunctionToPend, pvParameter1, ulParameter2, ret) + #define tracePEND_FUNC_CALL( xFunctionToPend, pvParameter1, ulParameter2, ret ) #endif #ifndef tracePEND_FUNC_CALL_FROM_ISR - #define tracePEND_FUNC_CALL_FROM_ISR(xFunctionToPend, pvParameter1, ulParameter2, ret) + #define tracePEND_FUNC_CALL_FROM_ISR( xFunctionToPend, pvParameter1, ulParameter2, ret ) #endif #ifndef traceQUEUE_REGISTRY_ADD - #define traceQUEUE_REGISTRY_ADD(xQueue, pcQueueName) + #define traceQUEUE_REGISTRY_ADD( xQueue, pcQueueName ) #endif #ifndef traceTASK_NOTIFY_TAKE_BLOCK - #define traceTASK_NOTIFY_TAKE_BLOCK() + #define traceTASK_NOTIFY_TAKE_BLOCK( uxIndexToWait ) #endif #ifndef traceTASK_NOTIFY_TAKE - #define traceTASK_NOTIFY_TAKE() + #define traceTASK_NOTIFY_TAKE( uxIndexToWait ) #endif #ifndef traceTASK_NOTIFY_WAIT_BLOCK - #define traceTASK_NOTIFY_WAIT_BLOCK() + #define traceTASK_NOTIFY_WAIT_BLOCK( uxIndexToWait ) #endif #ifndef traceTASK_NOTIFY_WAIT - #define traceTASK_NOTIFY_WAIT() + #define traceTASK_NOTIFY_WAIT( uxIndexToWait ) #endif #ifndef traceTASK_NOTIFY - #define traceTASK_NOTIFY() + #define traceTASK_NOTIFY( uxIndexToNotify ) #endif #ifndef traceTASK_NOTIFY_FROM_ISR - #define traceTASK_NOTIFY_FROM_ISR() + #define traceTASK_NOTIFY_FROM_ISR( uxIndexToNotify ) #endif #ifndef traceTASK_NOTIFY_GIVE_FROM_ISR - #define traceTASK_NOTIFY_GIVE_FROM_ISR() + #define traceTASK_NOTIFY_GIVE_FROM_ISR( uxIndexToNotify ) #endif #ifndef traceSTREAM_BUFFER_CREATE_FAILED - #define traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer ) + #define traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer ) #endif #ifndef traceSTREAM_BUFFER_CREATE_STATIC_FAILED - #define traceSTREAM_BUFFER_CREATE_STATIC_FAILED( xReturn, xIsMessageBuffer ) + #define traceSTREAM_BUFFER_CREATE_STATIC_FAILED( xReturn, xIsMessageBuffer ) #endif #ifndef traceSTREAM_BUFFER_CREATE - #define traceSTREAM_BUFFER_CREATE( pxStreamBuffer, xIsMessageBuffer ) + #define traceSTREAM_BUFFER_CREATE( pxStreamBuffer, xIsMessageBuffer ) #endif #ifndef traceSTREAM_BUFFER_DELETE - #define traceSTREAM_BUFFER_DELETE( xStreamBuffer ) + #define traceSTREAM_BUFFER_DELETE( xStreamBuffer ) #endif #ifndef traceSTREAM_BUFFER_RESET - #define traceSTREAM_BUFFER_RESET( xStreamBuffer ) + #define traceSTREAM_BUFFER_RESET( xStreamBuffer ) #endif #ifndef traceBLOCKING_ON_STREAM_BUFFER_SEND - #define traceBLOCKING_ON_STREAM_BUFFER_SEND( xStreamBuffer ) + #define traceBLOCKING_ON_STREAM_BUFFER_SEND( xStreamBuffer ) #endif #ifndef traceSTREAM_BUFFER_SEND - #define traceSTREAM_BUFFER_SEND( xStreamBuffer, xBytesSent ) + #define traceSTREAM_BUFFER_SEND( xStreamBuffer, xBytesSent ) #endif #ifndef traceSTREAM_BUFFER_SEND_FAILED - #define traceSTREAM_BUFFER_SEND_FAILED( xStreamBuffer ) + #define traceSTREAM_BUFFER_SEND_FAILED( xStreamBuffer ) #endif #ifndef traceSTREAM_BUFFER_SEND_FROM_ISR - #define traceSTREAM_BUFFER_SEND_FROM_ISR( xStreamBuffer, xBytesSent ) + #define traceSTREAM_BUFFER_SEND_FROM_ISR( xStreamBuffer, xBytesSent ) #endif #ifndef traceBLOCKING_ON_STREAM_BUFFER_RECEIVE - #define traceBLOCKING_ON_STREAM_BUFFER_RECEIVE( xStreamBuffer ) + #define traceBLOCKING_ON_STREAM_BUFFER_RECEIVE( xStreamBuffer ) #endif #ifndef traceSTREAM_BUFFER_RECEIVE - #define traceSTREAM_BUFFER_RECEIVE( xStreamBuffer, xReceivedLength ) + #define traceSTREAM_BUFFER_RECEIVE( xStreamBuffer, xReceivedLength ) #endif #ifndef traceSTREAM_BUFFER_RECEIVE_FAILED - #define traceSTREAM_BUFFER_RECEIVE_FAILED( xStreamBuffer ) + #define traceSTREAM_BUFFER_RECEIVE_FAILED( xStreamBuffer ) #endif #ifndef traceSTREAM_BUFFER_RECEIVE_FROM_ISR - #define traceSTREAM_BUFFER_RECEIVE_FROM_ISR( xStreamBuffer, xReceivedLength ) + #define traceSTREAM_BUFFER_RECEIVE_FROM_ISR( xStreamBuffer, xReceivedLength ) #endif +#ifdef ESP_PLATFORM #ifndef traceISR_EXIT_TO_SCHEDULER - #define traceISR_EXIT_TO_SCHEDULER() + #define traceISR_EXIT_TO_SCHEDULER() #endif #ifndef traceISR_EXIT - #define traceISR_EXIT() + #define traceISR_EXIT() #endif #ifndef traceISR_ENTER - #define traceISR_ENTER(_n_) + #define traceISR_ENTER(_n_) #endif +#endif // ESP_PLATFORM #ifndef configGENERATE_RUN_TIME_STATS - #define configGENERATE_RUN_TIME_STATS 0 + #define configGENERATE_RUN_TIME_STATS 0 #endif #if ( configGENERATE_RUN_TIME_STATS == 1 ) - #ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS - #error If configGENERATE_RUN_TIME_STATS is defined then portCONFIGURE_TIMER_FOR_RUN_TIME_STATS must also be defined. portCONFIGURE_TIMER_FOR_RUN_TIME_STATS should call a port layer function to setup a peripheral timer/counter that can then be used as the run time counter time base. - #endif /* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS */ + #ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS + #error If configGENERATE_RUN_TIME_STATS is defined then portCONFIGURE_TIMER_FOR_RUN_TIME_STATS must also be defined. portCONFIGURE_TIMER_FOR_RUN_TIME_STATS should call a port layer function to setup a peripheral timer/counter that can then be used as the run time counter time base. + #endif /* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS */ - #ifndef portGET_RUN_TIME_COUNTER_VALUE - #ifndef portALT_GET_RUN_TIME_COUNTER_VALUE - #error If configGENERATE_RUN_TIME_STATS is defined then either portGET_RUN_TIME_COUNTER_VALUE or portALT_GET_RUN_TIME_COUNTER_VALUE must also be defined. See the examples provided and the FreeRTOS web site for more information. - #endif /* portALT_GET_RUN_TIME_COUNTER_VALUE */ - #endif /* portGET_RUN_TIME_COUNTER_VALUE */ + #ifndef portGET_RUN_TIME_COUNTER_VALUE + #ifndef portALT_GET_RUN_TIME_COUNTER_VALUE + #error If configGENERATE_RUN_TIME_STATS is defined then either portGET_RUN_TIME_COUNTER_VALUE or portALT_GET_RUN_TIME_COUNTER_VALUE must also be defined. See the examples provided and the FreeRTOS web site for more information. + #endif /* portALT_GET_RUN_TIME_COUNTER_VALUE */ + #endif /* portGET_RUN_TIME_COUNTER_VALUE */ #endif /* configGENERATE_RUN_TIME_STATS */ #ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS - #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() + #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() #endif #ifndef configUSE_MALLOC_FAILED_HOOK - #define configUSE_MALLOC_FAILED_HOOK 0 + #define configUSE_MALLOC_FAILED_HOOK 0 #endif #ifndef portPRIVILEGE_BIT - #define portPRIVILEGE_BIT ( ( UBaseType_t ) 0x00 ) + #define portPRIVILEGE_BIT ( ( UBaseType_t ) 0x00 ) #endif #ifndef portYIELD_WITHIN_API - #define portYIELD_WITHIN_API portYIELD + #define portYIELD_WITHIN_API portYIELD #endif #ifndef portSUPPRESS_TICKS_AND_SLEEP - #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) + #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) #endif #ifndef configEXPECTED_IDLE_TIME_BEFORE_SLEEP - #define configEXPECTED_IDLE_TIME_BEFORE_SLEEP 2 + #define configEXPECTED_IDLE_TIME_BEFORE_SLEEP 2 #endif #if configEXPECTED_IDLE_TIME_BEFORE_SLEEP < 2 - #error configEXPECTED_IDLE_TIME_BEFORE_SLEEP must not be less than 2 + #error configEXPECTED_IDLE_TIME_BEFORE_SLEEP must not be less than 2 #endif #ifndef configUSE_TICKLESS_IDLE - #define configUSE_TICKLESS_IDLE 0 + #define configUSE_TICKLESS_IDLE 0 #endif #ifndef configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING - #define configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING( x ) + #define configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING( x ) #endif #ifndef configPRE_SLEEP_PROCESSING - #define configPRE_SLEEP_PROCESSING( x ) + #define configPRE_SLEEP_PROCESSING( x ) #endif #ifndef configPOST_SLEEP_PROCESSING - #define configPOST_SLEEP_PROCESSING( x ) + #define configPOST_SLEEP_PROCESSING( x ) #endif #ifndef configUSE_QUEUE_SETS - #define configUSE_QUEUE_SETS 0 + #define configUSE_QUEUE_SETS 0 #endif #ifndef portTASK_USES_FLOATING_POINT - #define portTASK_USES_FLOATING_POINT() + #define portTASK_USES_FLOATING_POINT() #endif #ifndef portALLOCATE_SECURE_CONTEXT - #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) #endif #ifndef portDONT_DISCARD - #define portDONT_DISCARD + #define portDONT_DISCARD #endif #ifndef configUSE_TIME_SLICING - #define configUSE_TIME_SLICING 1 + #define configUSE_TIME_SLICING 1 #endif #ifndef configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS - #define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS 0 + #define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS 0 #endif #ifndef configUSE_STATS_FORMATTING_FUNCTIONS - #define configUSE_STATS_FORMATTING_FUNCTIONS 0 + #define configUSE_STATS_FORMATTING_FUNCTIONS 0 #endif #ifndef portASSERT_IF_INTERRUPT_PRIORITY_INVALID - #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() + #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() #endif #ifndef configUSE_TRACE_FACILITY - #define configUSE_TRACE_FACILITY 0 + #define configUSE_TRACE_FACILITY 0 #endif #ifndef mtCOVERAGE_TEST_MARKER - #define mtCOVERAGE_TEST_MARKER() + #define mtCOVERAGE_TEST_MARKER() #endif #ifndef mtCOVERAGE_TEST_DELAY - #define mtCOVERAGE_TEST_DELAY() + #define mtCOVERAGE_TEST_DELAY() #endif #ifndef portASSERT_IF_IN_ISR - #define portASSERT_IF_IN_ISR() + #define portASSERT_IF_IN_ISR() #endif #ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION - #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 + #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 #endif #ifndef configAPPLICATION_ALLOCATED_HEAP - #define configAPPLICATION_ALLOCATED_HEAP 0 + #define configAPPLICATION_ALLOCATED_HEAP 0 #endif #ifndef configUSE_TASK_NOTIFICATIONS - #define configUSE_TASK_NOTIFICATIONS 1 + #define configUSE_TASK_NOTIFICATIONS 1 +#endif + +#ifndef configTASK_NOTIFICATION_ARRAY_ENTRIES + #define configTASK_NOTIFICATION_ARRAY_ENTRIES 1 +#endif + +#if configTASK_NOTIFICATION_ARRAY_ENTRIES < 1 + #error configTASK_NOTIFICATION_ARRAY_ENTRIES must be at least 1 #endif #ifndef configUSE_POSIX_ERRNO - #define configUSE_POSIX_ERRNO 0 + #define configUSE_POSIX_ERRNO 0 #endif #ifndef portTICK_TYPE_IS_ATOMIC - #define portTICK_TYPE_IS_ATOMIC 0 + #define portTICK_TYPE_IS_ATOMIC 0 #endif #ifndef configSUPPORT_STATIC_ALLOCATION - /* Defaults to 0 for backward compatibility. */ - #define configSUPPORT_STATIC_ALLOCATION 0 + /* Defaults to 0 for backward compatibility. */ + #define configSUPPORT_STATIC_ALLOCATION 0 #endif #ifndef configSUPPORT_DYNAMIC_ALLOCATION - /* Defaults to 1 for backward compatibility. */ - #define configSUPPORT_DYNAMIC_ALLOCATION 1 + /* Defaults to 1 for backward compatibility. */ + #define configSUPPORT_DYNAMIC_ALLOCATION 1 +#endif + +#ifndef configSTACK_ALLOCATION_FROM_SEPARATE_HEAP + /* Defaults to 0 for backward compatibility. */ + #define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0 #endif #ifndef configSTACK_DEPTH_TYPE - /* Defaults to uint16_t for backward compatibility, but can be overridden - in FreeRTOSConfig.h if uint16_t is too restrictive. */ - #define configSTACK_DEPTH_TYPE uint16_t + +/* Defaults to uint16_t for backward compatibility, but can be overridden + * in FreeRTOSConfig.h if uint16_t is too restrictive. */ + #define configSTACK_DEPTH_TYPE uint16_t #endif #ifndef configMESSAGE_BUFFER_LENGTH_TYPE - /* Defaults to size_t for backward compatibility, but can be overridden - in FreeRTOSConfig.h if lengths will always be less than the number of bytes - in a size_t. */ - #define configMESSAGE_BUFFER_LENGTH_TYPE size_t + +/* Defaults to size_t for backward compatibility, but can be overridden + * in FreeRTOSConfig.h if lengths will always be less than the number of bytes + * in a size_t. */ + #define configMESSAGE_BUFFER_LENGTH_TYPE size_t #endif /* Sanity check the configuration. */ -#if( configUSE_TICKLESS_IDLE != 0 ) - #if( INCLUDE_vTaskSuspend != 1 ) - #error INCLUDE_vTaskSuspend must be set to 1 if configUSE_TICKLESS_IDLE is not set to 0 - #endif /* INCLUDE_vTaskSuspend */ +#if ( configUSE_TICKLESS_IDLE != 0 ) + #if ( INCLUDE_vTaskSuspend != 1 ) + #error INCLUDE_vTaskSuspend must be set to 1 if configUSE_TICKLESS_IDLE is not set to 0 + #endif /* INCLUDE_vTaskSuspend */ #endif /* configUSE_TICKLESS_IDLE */ -#if( ( configSUPPORT_STATIC_ALLOCATION == 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 0 ) ) - #error configSUPPORT_STATIC_ALLOCATION and configSUPPORT_DYNAMIC_ALLOCATION cannot both be 0, but can both be 1. +#if ( ( configSUPPORT_STATIC_ALLOCATION == 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 0 ) ) + #error configSUPPORT_STATIC_ALLOCATION and configSUPPORT_DYNAMIC_ALLOCATION cannot both be 0, but can both be 1. #endif -#if( ( configUSE_RECURSIVE_MUTEXES == 1 ) && ( configUSE_MUTEXES != 1 ) ) - #error configUSE_MUTEXES must be set to 1 to use recursive mutexes +#if ( ( configUSE_RECURSIVE_MUTEXES == 1 ) && ( configUSE_MUTEXES != 1 ) ) + #error configUSE_MUTEXES must be set to 1 to use recursive mutexes #endif #ifndef configINITIAL_TICK_COUNT - #define configINITIAL_TICK_COUNT 0 + #define configINITIAL_TICK_COUNT 0 #endif -#if( portTICK_TYPE_IS_ATOMIC == 0 ) - /* Either variables of tick type cannot be read atomically, or - portTICK_TYPE_IS_ATOMIC was not set - map the critical sections used when - the tick count is returned to the standard critical section macros. */ - #define portTICK_TYPE_ENTER_CRITICAL(mux) portENTER_CRITICAL(mux) - #define portTICK_TYPE_EXIT_CRITICAL(mux) portEXIT_CRITICAL(mux) - #define portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR() portSET_INTERRUPT_MASK_FROM_ISR() - #define portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( x ) portCLEAR_INTERRUPT_MASK_FROM_ISR( ( x ) ) +#if ( portTICK_TYPE_IS_ATOMIC == 0 ) + +/* Either variables of tick type cannot be read atomically, or + * portTICK_TYPE_IS_ATOMIC was not set - map the critical sections used when + * the tick count is returned to the standard critical section macros. */ + #define portTICK_TYPE_ENTER_CRITICAL(mux) portENTER_CRITICAL(mux) + #define portTICK_TYPE_EXIT_CRITICAL(mux) portEXIT_CRITICAL(mux) + #define portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR() portSET_INTERRUPT_MASK_FROM_ISR() + #define portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( x ) portCLEAR_INTERRUPT_MASK_FROM_ISR( ( x ) ) #else - /* The tick type can be read atomically, so critical sections used when the - tick count is returned can be defined away. */ - #define portTICK_TYPE_ENTER_CRITICAL() - #define portTICK_TYPE_EXIT_CRITICAL() - #define portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR() 0 - #define portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( x ) ( void ) x -#endif + +/* The tick type can be read atomically, so critical sections used when the + * tick count is returned can be defined away. */ + #define portTICK_TYPE_ENTER_CRITICAL() + #define portTICK_TYPE_EXIT_CRITICAL() + #define portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR() 0 + #define portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( x ) ( void ) x +#endif /* if ( portTICK_TYPE_IS_ATOMIC == 0 ) */ /* Definitions to allow backward compatibility with FreeRTOS versions prior to -V8 if desired. */ + * V8 if desired. */ #ifndef configENABLE_BACKWARD_COMPATIBILITY - #define configENABLE_BACKWARD_COMPATIBILITY 1 + #define configENABLE_BACKWARD_COMPATIBILITY 1 #endif #ifndef configPRINTF - /* configPRINTF() was not defined, so define it away to nothing. To use - configPRINTF() then define it as follows (where MyPrintFunction() is - provided by the application writer): - void MyPrintFunction(const char *pcFormat, ... ); - #define configPRINTF( X ) MyPrintFunction X - - Then call like a standard printf() function, but placing brackets around - all parameters so they are passed as a single parameter. For example: - configPRINTF( ("Value = %d", MyVariable) ); */ - #define configPRINTF( X ) +/* configPRINTF() was not defined, so define it away to nothing. To use + * configPRINTF() then define it as follows (where MyPrintFunction() is + * provided by the application writer): + * + * void MyPrintFunction(const char *pcFormat, ... ); + #define configPRINTF( X ) MyPrintFunction X + * + * Then call like a standard printf() function, but placing brackets around + * all parameters so they are passed as a single parameter. For example: + * configPRINTF( ("Value = %d", MyVariable) ); */ + #define configPRINTF( X ) #endif #ifndef configMAX - /* The application writer has not provided their own MAX macro, so define - the following generic implementation. */ - #define configMAX( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) ) + +/* The application writer has not provided their own MAX macro, so define + * the following generic implementation. */ + #define configMAX( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) ) #endif #ifndef configMIN - /* The application writer has not provided their own MAX macro, so define - the following generic implementation. */ - #define configMIN( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) ) + +/* The application writer has not provided their own MIN macro, so define + * the following generic implementation. */ + #define configMIN( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) ) #endif #if configENABLE_BACKWARD_COMPATIBILITY == 1 - #define eTaskStateGet eTaskGetState - #define portTickType TickType_t - #define xTaskHandle TaskHandle_t - #define xQueueHandle QueueHandle_t - #define xSemaphoreHandle SemaphoreHandle_t - #define xQueueSetHandle QueueSetHandle_t - #define xQueueSetMemberHandle QueueSetMemberHandle_t - #define xTimeOutType TimeOut_t - #define xMemoryRegion MemoryRegion_t - #define xTaskParameters TaskParameters_t - #define xTaskStatusType TaskStatus_t - #define xTimerHandle TimerHandle_t - #define xCoRoutineHandle CoRoutineHandle_t - #define pdTASK_HOOK_CODE TaskHookFunction_t - #define portTICK_RATE_MS portTICK_PERIOD_MS - #define pcTaskGetTaskName pcTaskGetName - #define pcTimerGetTimerName pcTimerGetName - #define pcQueueGetQueueName pcQueueGetName - #define vTaskGetTaskInfo vTaskGetInfo - - /* Backward compatibility within the scheduler code only - these definitions - are not really required but are included for completeness. */ - #define tmrTIMER_CALLBACK TimerCallbackFunction_t - #define pdTASK_CODE TaskFunction_t - #define xListItem ListItem_t - #define xList List_t - - /* For libraries that break the list data hiding, and access list structure - members directly (which is not supposed to be done). */ - #define pxContainer pvContainer + #define eTaskStateGet eTaskGetState + #define portTickType TickType_t + #define xTaskHandle TaskHandle_t + #define xQueueHandle QueueHandle_t + #define xSemaphoreHandle SemaphoreHandle_t + #define xQueueSetHandle QueueSetHandle_t + #define xQueueSetMemberHandle QueueSetMemberHandle_t + #define xTimeOutType TimeOut_t + #define xMemoryRegion MemoryRegion_t + #define xTaskParameters TaskParameters_t + #define xTaskStatusType TaskStatus_t + #define xTimerHandle TimerHandle_t + #define xCoRoutineHandle CoRoutineHandle_t + #define pdTASK_HOOK_CODE TaskHookFunction_t + #define portTICK_RATE_MS portTICK_PERIOD_MS + #define pcTaskGetTaskName pcTaskGetName + #define pcTimerGetTimerName pcTimerGetName + #define pcQueueGetQueueName pcQueueGetName + #define vTaskGetTaskInfo vTaskGetInfo + #define xTaskGetIdleRunTimeCounter ulTaskGetIdleRunTimeCounter + +/* Backward compatibility within the scheduler code only - these definitions + * are not really required but are included for completeness. */ + #define tmrTIMER_CALLBACK TimerCallbackFunction_t + #define pdTASK_CODE TaskFunction_t + #define xListItem ListItem_t + #define xList List_t + +/* For libraries that break the list data hiding, and access list structure + * members directly (which is not supposed to be done). */ + #define pxContainer pvContainer #endif /* configENABLE_BACKWARD_COMPATIBILITY */ +#ifdef ESP_PLATFORM #ifndef configESP32_PER_TASK_DATA - #define configESP32_PER_TASK_DATA 1 + #define configESP32_PER_TASK_DATA 1 #endif +#endif // ESP_PLATFORM -#if( configUSE_ALTERNATIVE_API != 0 ) - #error The alternative API was deprecated some time ago, and was removed in FreeRTOS V9.0 0 +#if ( configUSE_ALTERNATIVE_API != 0 ) + #error The alternative API was deprecated some time ago, and was removed in FreeRTOS V9.0 0 #endif /* Set configUSE_TASK_FPU_SUPPORT to 0 to omit floating point support even -if floating point hardware is otherwise supported by the FreeRTOS port in use. -This constant is not supported by all FreeRTOS ports that include floating -point support. */ + * if floating point hardware is otherwise supported by the FreeRTOS port in use. + * This constant is not supported by all FreeRTOS ports that include floating + * point support. */ #ifndef configUSE_TASK_FPU_SUPPORT - #define configUSE_TASK_FPU_SUPPORT 1 + #define configUSE_TASK_FPU_SUPPORT 1 #endif /* Set configENABLE_MPU to 1 to enable MPU support and 0 to disable it. This is -currently used in ARMv8M ports. */ + * currently used in ARMv8M ports. */ #ifndef configENABLE_MPU - #define configENABLE_MPU 0 + #define configENABLE_MPU 0 #endif /* Set configENABLE_FPU to 1 to enable FPU support and 0 to disable it. This is -currently used in ARMv8M ports. */ + * currently used in ARMv8M ports. */ #ifndef configENABLE_FPU - #define configENABLE_FPU 1 + #define configENABLE_FPU 1 #endif /* Set configENABLE_TRUSTZONE to 1 enable TrustZone support and 0 to disable it. -This is currently used in ARMv8M ports. */ + * This is currently used in ARMv8M ports. */ #ifndef configENABLE_TRUSTZONE - #define configENABLE_TRUSTZONE 1 + #define configENABLE_TRUSTZONE 1 #endif /* Set configRUN_FREERTOS_SECURE_ONLY to 1 to run the FreeRTOS ARMv8M port on -the Secure Side only. */ + * the Secure Side only. */ #ifndef configRUN_FREERTOS_SECURE_ONLY - #define configRUN_FREERTOS_SECURE_ONLY 0 + #define configRUN_FREERTOS_SECURE_ONLY 0 #endif /* Sometimes the FreeRTOSConfig.h settings only allow a task to be created using @@ -1070,55 +1137,56 @@ the Secure Side only. */ * | | | | xTaskCreateRestrictedStatic | | | | * +-----+---------+--------+-----------------------------+-----------------------------------+------------------+-----------+ */ -#define tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE ( ( ( portUSING_MPU_WRAPPERS == 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) || \ - ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) ) +#define tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE \ + ( ( ( portUSING_MPU_WRAPPERS == 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) || \ + ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) ) /* * In line with software engineering best practice, FreeRTOS implements a strict * data hiding policy, so the real structures used by FreeRTOS to maintain the * state of tasks, queues, semaphores, etc. are not accessible to the application * code. However, if the application writer wants to statically allocate such - * an object then the size of the object needs to be know. Dummy structures + * an object then the size of the object needs to be known. Dummy structures * that are guaranteed to have the same size and alignment requirements of the * real objects are used for this purpose. The dummy list and list item * structures below are used for inclusion in such a dummy structure. */ struct xSTATIC_LIST_ITEM { - #if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) - TickType_t xDummy1; - #endif - TickType_t xDummy2; - void *pvDummy3[ 4 ]; - #if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) - TickType_t xDummy4; - #endif + #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) + TickType_t xDummy1; + #endif + TickType_t xDummy2; + void * pvDummy3[ 4 ]; + #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) + TickType_t xDummy4; + #endif }; typedef struct xSTATIC_LIST_ITEM StaticListItem_t; /* See the comments above the struct xSTATIC_LIST_ITEM definition. */ struct xSTATIC_MINI_LIST_ITEM { - #if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) - TickType_t xDummy1; - #endif - TickType_t xDummy2; - void *pvDummy3[ 2 ]; + #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) + TickType_t xDummy1; + #endif + TickType_t xDummy2; + void * pvDummy3[ 2 ]; }; typedef struct xSTATIC_MINI_LIST_ITEM StaticMiniListItem_t; /* See the comments above the struct xSTATIC_LIST_ITEM definition. */ typedef struct xSTATIC_LIST { - #if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) - TickType_t xDummy1; - #endif - UBaseType_t uxDummy2; - void *pvDummy3; - StaticMiniListItem_t xDummy4; - #if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) - TickType_t xDummy5; - #endif + #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) + TickType_t xDummy1; + #endif + UBaseType_t uxDummy2; + void * pvDummy3; + StaticMiniListItem_t xDummy4; + #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) + TickType_t xDummy5; + #endif } StaticList_t; /* @@ -1127,7 +1195,7 @@ typedef struct xSTATIC_LIST * strict data hiding policy. This means the Task 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 task then - * the size of the task object needs to be know. The StaticTask_t structure + * the size of the task object needs to be known. The StaticTask_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 @@ -1136,56 +1204,56 @@ typedef struct xSTATIC_LIST */ typedef struct xSTATIC_TCB { - void *pxDummy1; - #if ( portUSING_MPU_WRAPPERS == 1 ) - xMPU_SETTINGS xDummy2; - #endif - StaticListItem_t xDummy3[ 2 ]; - UBaseType_t uxDummy5; - void *pxDummy6; - uint8_t ucDummy7[ configMAX_TASK_NAME_LEN ]; - BaseType_t xDummyCore; - #if ( ( portSTACK_GROWTH > 0 ) || ( configRECORD_STACK_HIGH_ADDRESS == 1 ) ) - void *pxDummy8; - #endif - #if ( portCRITICAL_NESTING_IN_TCB == 1 ) - UBaseType_t uxDummy9; - #endif - #if ( configUSE_TRACE_FACILITY == 1 ) - UBaseType_t uxDummy10[ 2 ]; - #endif - #if ( configUSE_MUTEXES == 1 ) - UBaseType_t uxDummy12[ 2 ]; - #endif - #if ( configUSE_APPLICATION_TASK_TAG == 1 ) - void *pxDummy14; - #endif - #if( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) - void *pvDummy15[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ]; - #if ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS ) - void *pvDummyLocalStorageCallBack[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ]; - #endif - #endif - #if ( configGENERATE_RUN_TIME_STATS == 1 ) - uint32_t ulDummy16; - #endif - #if ( configUSE_NEWLIB_REENTRANT == 1 ) - struct _reent xDummy17; - #endif - #if ( configUSE_TASK_NOTIFICATIONS == 1 ) - uint32_t ulDummy18; - uint8_t ucDummy19; - #endif - #if ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) - uint8_t uxDummy20; - #endif - - #if( INCLUDE_xTaskAbortDelay == 1 ) - uint8_t ucDummy21; - #endif - #if ( configUSE_POSIX_ERRNO == 1 ) - int iDummy22; - #endif + void * pxDummy1; + #if ( portUSING_MPU_WRAPPERS == 1 ) + xMPU_SETTINGS xDummy2; + #endif + StaticListItem_t xDummy3[ 2 ]; + UBaseType_t uxDummy5; + void * pxDummy6; + uint8_t ucDummy7[ configMAX_TASK_NAME_LEN ]; + BaseType_t xDummyCore; + #if ( ( portSTACK_GROWTH > 0 ) || ( configRECORD_STACK_HIGH_ADDRESS == 1 ) ) + void * pxDummy8; + #endif + #if ( portCRITICAL_NESTING_IN_TCB == 1 ) + UBaseType_t uxDummy9; + #endif + #if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxDummy10[ 2 ]; + #endif + #if ( configUSE_MUTEXES == 1 ) + UBaseType_t uxDummy12[ 2 ]; + #endif + #if ( configUSE_APPLICATION_TASK_TAG == 1 ) + void * pxDummy14; + #endif + #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) + void * pvDummy15[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ]; + #if ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS ) + void *pvDummyLocalStorageCallBack[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ]; + #endif + #endif + #if ( configGENERATE_RUN_TIME_STATS == 1 ) + uint32_t ulDummy16; + #endif + #if ( configUSE_NEWLIB_REENTRANT == 1 ) + struct _reent xDummy17; + #endif + #if ( configUSE_TASK_NOTIFICATIONS == 1 ) + uint32_t ulDummy18[ configTASK_NOTIFICATION_ARRAY_ENTRIES ]; + uint8_t ucDummy19[ configTASK_NOTIFICATION_ARRAY_ENTRIES ]; + #endif + #if ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) + uint8_t uxDummy20; + #endif + + #if ( INCLUDE_xTaskAbortDelay == 1 ) + uint8_t ucDummy21; + #endif + #if ( configUSE_POSIX_ERRNO == 1 ) + int iDummy22; + #endif } StaticTask_t; /* @@ -1194,7 +1262,7 @@ typedef struct xSTATIC_TCB * strict data hiding policy. This means the Queue 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 queue - * then the size of the queue object needs to be know. The StaticQueue_t + * then the size of the queue object needs to be known. The StaticQueue_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 @@ -1204,33 +1272,31 @@ typedef struct xSTATIC_TCB */ typedef struct xSTATIC_QUEUE { - void *pvDummy1[ 3 ]; - - union - { - void *pvDummy2; - UBaseType_t uxDummy2; - } u; - - StaticList_t xDummy3[ 2 ]; - UBaseType_t uxDummy4[ 3 ]; - uint8_t ucDummy5[ 2 ]; - - #if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) - uint8_t ucDummy6; - #endif - - #if ( configUSE_QUEUE_SETS == 1 ) - void *pvDummy7; - #endif - - #if ( configUSE_TRACE_FACILITY == 1 ) - UBaseType_t uxDummy8; - uint8_t ucDummy9; - #endif - - portMUX_TYPE xDummy10; - + void * pvDummy1[ 3 ]; + + union + { + void * pvDummy2; + UBaseType_t uxDummy2; + } u; + + StaticList_t xDummy3[ 2 ]; + UBaseType_t uxDummy4[ 3 ]; + uint8_t ucDummy5[ 2 ]; + + #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) + uint8_t ucDummy6; + #endif + + #if ( configUSE_QUEUE_SETS == 1 ) + void * pvDummy7; + #endif + + #if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxDummy8; + uint8_t ucDummy9; + #endif + portMUX_TYPE xDummy10; } StaticQueue_t; typedef StaticQueue_t StaticSemaphore_t; @@ -1250,19 +1316,17 @@ typedef StaticQueue_t StaticSemaphore_t; */ typedef struct xSTATIC_EVENT_GROUP { - TickType_t xDummy1; - StaticList_t xDummy2; + 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 xDummy5; + #if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxDummy3; + #endif + #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) + uint8_t ucDummy4; + #endif + portMUX_TYPE xDummy5; } StaticEventGroup_t; /* @@ -1271,7 +1335,7 @@ typedef struct xSTATIC_EVENT_GROUP * 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. + * create a software timer then the size of the queue object needs to be known. * 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 @@ -1281,49 +1345,49 @@ typedef struct xSTATIC_EVENT_GROUP */ typedef struct xSTATIC_TIMER { - void *pvDummy1; - StaticListItem_t xDummy2; - TickType_t xDummy3; - void *pvDummy5; - TaskFunction_t pvDummy6; - #if( configUSE_TRACE_FACILITY == 1 ) - UBaseType_t uxDummy7; - #endif - uint8_t ucDummy8; + void * pvDummy1; + StaticListItem_t xDummy2; + TickType_t xDummy3; + void * pvDummy5; + TaskFunction_t pvDummy6; + #if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxDummy7; + #endif + uint8_t ucDummy8; } StaticTimer_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 stream buffer 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 stream buffer then the size of the stream buffer object needs to be -* know. The StaticStreamBuffer_t structure below is provided for this purpose. -* Its size 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. -*/ + * 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 stream buffer 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 stream buffer then the size of the stream buffer object needs to be + * known. The StaticStreamBuffer_t structure below is provided for this + * purpose. Its size 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_STREAM_BUFFER { - size_t uxDummy1[ 4 ]; - void * pvDummy2[ 3 ]; - uint8_t ucDummy3; - #if ( configUSE_TRACE_FACILITY == 1 ) - UBaseType_t uxDummy4; - #endif - - portMUX_TYPE xDummy5; - + size_t uxDummy1[ 4 ]; + void * pvDummy2[ 3 ]; + uint8_t ucDummy3; + #if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxDummy4; + #endif + portMUX_TYPE xDummy5; } StaticStreamBuffer_t; /* Message buffers are built on stream buffers. */ typedef StaticStreamBuffer_t StaticMessageBuffer_t; +/* *INDENT-OFF* */ #ifdef __cplusplus -} + } #endif +/* *INDENT-ON* */ #endif /* INC_FREERTOS_H */ diff --git a/tools/sdk/esp32c3/include/freertos/include/freertos/StackMacros.h b/tools/sdk/esp32c3/include/freertos/include/freertos/StackMacros.h new file mode 100644 index 00000000000..8d09f10cd1d --- /dev/null +++ b/tools/sdk/esp32c3/include/freertos/include/freertos/StackMacros.h @@ -0,0 +1,32 @@ +/* + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * 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. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + + +#ifndef _MSC_VER /* Visual Studio doesn't support #warning. */ + #warning The name of this file has changed to stack_macros.h. Please update your code accordingly. This source file (which has the original name) will be removed in future released. +#endif + +#include "stack_macros.h" diff --git a/tools/sdk/esp32c3/include/freertos/include/freertos/atomic.h b/tools/sdk/esp32c3/include/freertos/include/freertos/atomic.h index df52a0f01fd..a47b96723cc 100644 --- a/tools/sdk/esp32c3/include/freertos/include/freertos/atomic.h +++ b/tools/sdk/esp32c3/include/freertos/include/freertos/atomic.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,19 +19,18 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ /** * @file atomic.h * @brief FreeRTOS atomic operation support. * - * This file implements atomic by disabling interrupts globally. - * Implementation with architecture specific atomic instructions - * are to be provided under each compiler directory. + * This file implements atomic functions by disabling interrupts globally. + * Implementations with architecture specific atomic instructions can be + * provided under each compiler directory. */ #ifndef ATOMIC_H @@ -44,45 +43,50 @@ /* Standard includes. */ #include +/* *INDENT-OFF* */ #ifdef __cplusplus -extern "C" { + extern "C" { #endif +/* *INDENT-ON* */ -/* Port specific definitions -- entering/exiting critical section. +/* + * Port specific definitions -- entering/exiting critical section. * Refer template -- ./lib/FreeRTOS/portable/Compiler/Arch/portmacro.h * * Every call to ATOMIC_EXIT_CRITICAL() must be closely paired with * ATOMIC_ENTER_CRITICAL(). - * */ + * + */ #if defined( portSET_INTERRUPT_MASK_FROM_ISR ) - /* Nested interrupt scheme is supported in this port. */ - #define ATOMIC_ENTER_CRITICAL() \ - UBaseType_t uxCriticalSectionType = portSET_INTERRUPT_MASK_FROM_ISR() +/* Nested interrupt scheme is supported in this port. */ + #define ATOMIC_ENTER_CRITICAL() \ + UBaseType_t uxCriticalSectionType = portSET_INTERRUPT_MASK_FROM_ISR() - #define ATOMIC_EXIT_CRITICAL() \ - portCLEAR_INTERRUPT_MASK_FROM_ISR( uxCriticalSectionType ) + #define ATOMIC_EXIT_CRITICAL() \ + portCLEAR_INTERRUPT_MASK_FROM_ISR( uxCriticalSectionType ) #else - /* Nested interrupt scheme is NOT supported in this port. */ - #define ATOMIC_ENTER_CRITICAL() portENTER_CRITICAL() - #define ATOMIC_EXIT_CRITICAL() portEXIT_CRITICAL() +/* Nested interrupt scheme is NOT supported in this port. */ + #define ATOMIC_ENTER_CRITICAL() portENTER_CRITICAL() + #define ATOMIC_EXIT_CRITICAL() portEXIT_CRITICAL() #endif /* portSET_INTERRUPT_MASK_FROM_ISR() */ -/* Port specific definition -- "always inline". - * Inline is compiler specific, and may not always get inlined depending on your optimization level. - * Also, inline is considerred as performance optimization for atomic. - * Thus, if portFORCE_INLINE is not provided by portmacro.h, instead of resulting error, - * simply define it. +/* + * Port specific definition -- "always inline". + * Inline is compiler specific, and may not always get inlined depending on your + * optimization level. Also, inline is considered as performance optimization + * for atomic. Thus, if portFORCE_INLINE is not provided by portmacro.h, + * instead of resulting error, simply define it away. */ #ifndef portFORCE_INLINE #define portFORCE_INLINE #endif -#define ATOMIC_COMPARE_AND_SWAP_SUCCESS 0x1U /**< Compare and swap succeeded, swapped. */ -#define ATOMIC_COMPARE_AND_SWAP_FAILURE 0x0U /**< Compare and swap failed, did not swap. */ +#define ATOMIC_COMPARE_AND_SWAP_SUCCESS 0x1U /**< Compare and swap succeeded, swapped. */ +#define ATOMIC_COMPARE_AND_SWAP_FAILURE 0x0U /**< Compare and swap failed, did not swap. */ /*----------------------------- Swap && CAS ------------------------------*/ @@ -91,66 +95,67 @@ extern "C" { * * @brief Performs an atomic compare-and-swap operation on the specified values. * - * @param[in, out] pDestination Pointer to memory location from where value is + * @param[in, out] pulDestination Pointer to memory location from where value is * to be loaded and checked. * @param[in] ulExchange If condition meets, write this value to memory. * @param[in] ulComparand Swap condition. * * @return Unsigned integer of value 1 or 0. 1 for swapped, 0 for not swapped. * - * @note This function only swaps *pDestination with ulExchange, if previous - * *pDestination value equals ulComparand. + * @note This function only swaps *pulDestination with ulExchange, if previous + * *pulDestination value equals ulComparand. */ -static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32( - uint32_t volatile * pDestination, - uint32_t ulExchange, - uint32_t ulComparand ) +static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32( uint32_t volatile * pulDestination, + uint32_t ulExchange, + uint32_t ulComparand ) { - - uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE; + uint32_t ulReturnValue; ATOMIC_ENTER_CRITICAL(); - - if ( *pDestination == ulComparand ) { - *pDestination = ulExchange; - ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS; + if( *pulDestination == ulComparand ) + { + *pulDestination = ulExchange; + ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS; + } + else + { + ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE; + } } - ATOMIC_EXIT_CRITICAL(); return ulReturnValue; - } +/*-----------------------------------------------------------*/ /** * Atomic swap (pointers) * - * @brief Atomically sets the address pointed to by *ppDestination to the value - * of *pExchange. + * @brief Atomically sets the address pointed to by *ppvDestination to the value + * of *pvExchange. * - * @param[in, out] ppDestination Pointer to memory location from where a pointer - * value is to be loaded and written back to. - * @param[in] pExchange Pointer value to be written to *ppDestination. + * @param[in, out] ppvDestination Pointer to memory location from where a pointer + * value is to be loaded and written back to. + * @param[in] pvExchange Pointer value to be written to *ppvDestination. * - * @return The initial value of *ppDestination. + * @return The initial value of *ppvDestination. */ -static portFORCE_INLINE void * Atomic_SwapPointers_p32( - void * volatile * ppDestination, - void * pExchange ) +static portFORCE_INLINE void * Atomic_SwapPointers_p32( void * volatile * ppvDestination, + void * pvExchange ) { void * pReturnValue; ATOMIC_ENTER_CRITICAL(); - - pReturnValue = *ppDestination; - - *ppDestination = pExchange; - + { + pReturnValue = *ppvDestination; + *ppvDestination = pvExchange; + } ATOMIC_EXIT_CRITICAL(); return pReturnValue; } +/*-----------------------------------------------------------*/ /** * Atomic compare-and-swap (pointers) @@ -158,30 +163,30 @@ static portFORCE_INLINE void * Atomic_SwapPointers_p32( * @brief Performs an atomic compare-and-swap operation on the specified pointer * values. * - * @param[in, out] ppDestination Pointer to memory location from where a pointer - * value is to be loaded and checked. - * @param[in] pExchange If condition meets, write this value to memory. - * @param[in] pComparand Swap condition. + * @param[in, out] ppvDestination Pointer to memory location from where a pointer + * value is to be loaded and checked. + * @param[in] pvExchange If condition meets, write this value to memory. + * @param[in] pvComparand Swap condition. * * @return Unsigned integer of value 1 or 0. 1 for swapped, 0 for not swapped. * - * @note This function only swaps *ppDestination with pExchange, if previous - * *ppDestination value equals pComparand. + * @note This function only swaps *ppvDestination with pvExchange, if previous + * *ppvDestination value equals pvComparand. */ -static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32( - void * volatile * ppDestination, - void * pExchange, void * pComparand ) +static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32( void * volatile * ppvDestination, + void * pvExchange, + void * pvComparand ) { uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE; ATOMIC_ENTER_CRITICAL(); - - if ( *ppDestination == pComparand ) { - *ppDestination = pExchange; - ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS; + if( *ppvDestination == pvComparand ) + { + *ppvDestination = pvExchange; + ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS; + } } - ATOMIC_EXIT_CRITICAL(); return ulReturnValue; @@ -195,28 +200,27 @@ static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32( * * @brief Atomically adds count to the value of the specified pointer points to. * - * @param[in,out] pAddend Pointer to memory location from where value is to be + * @param[in,out] pulAddend Pointer to memory location from where value is to be * loaded and written back to. - * @param[in] ulCount Value to be added to *pAddend. + * @param[in] ulCount Value to be added to *pulAddend. * - * @return previous *pAddend value. + * @return previous *pulAddend value. */ -static portFORCE_INLINE uint32_t Atomic_Add_u32( - uint32_t volatile * pAddend, - uint32_t ulCount ) +static portFORCE_INLINE uint32_t Atomic_Add_u32( uint32_t volatile * pulAddend, + uint32_t ulCount ) { uint32_t ulCurrent; ATOMIC_ENTER_CRITICAL(); - - ulCurrent = *pAddend; - - *pAddend += ulCount; - + { + ulCurrent = *pulAddend; + *pulAddend += ulCount; + } ATOMIC_EXIT_CRITICAL(); return ulCurrent; } +/*-----------------------------------------------------------*/ /** * Atomic subtract @@ -224,74 +228,72 @@ static portFORCE_INLINE uint32_t Atomic_Add_u32( * @brief Atomically subtracts count from the value of the specified pointer * pointers to. * - * @param[in,out] pAddend Pointer to memory location from where value is to be + * @param[in,out] pulAddend Pointer to memory location from where value is to be * loaded and written back to. - * @param[in] ulCount Value to be subtract from *pAddend. + * @param[in] ulCount Value to be subtract from *pulAddend. * - * @return previous *pAddend value. + * @return previous *pulAddend value. */ -static portFORCE_INLINE uint32_t Atomic_Subtract_u32( - uint32_t volatile * pAddend, - uint32_t ulCount ) +static portFORCE_INLINE uint32_t Atomic_Subtract_u32( uint32_t volatile * pulAddend, + uint32_t ulCount ) { uint32_t ulCurrent; ATOMIC_ENTER_CRITICAL(); - - ulCurrent = *pAddend; - - *pAddend -= ulCount; - + { + ulCurrent = *pulAddend; + *pulAddend -= ulCount; + } ATOMIC_EXIT_CRITICAL(); return ulCurrent; } +/*-----------------------------------------------------------*/ /** * Atomic increment * * @brief Atomically increments the value of the specified pointer points to. * - * @param[in,out] pAddend Pointer to memory location from where value is to be + * @param[in,out] pulAddend Pointer to memory location from where value is to be * loaded and written back to. * - * @return *pAddend value before increment. + * @return *pulAddend value before increment. */ -static portFORCE_INLINE uint32_t Atomic_Increment_u32( uint32_t volatile * pAddend ) +static portFORCE_INLINE uint32_t Atomic_Increment_u32( uint32_t volatile * pulAddend ) { uint32_t ulCurrent; ATOMIC_ENTER_CRITICAL(); - - ulCurrent = *pAddend; - - *pAddend += 1; - + { + ulCurrent = *pulAddend; + *pulAddend += 1; + } ATOMIC_EXIT_CRITICAL(); return ulCurrent; } +/*-----------------------------------------------------------*/ /** * Atomic decrement * * @brief Atomically decrements the value of the specified pointer points to * - * @param[in,out] pAddend Pointer to memory location from where value is to be + * @param[in,out] pulAddend Pointer to memory location from where value is to be * loaded and written back to. * - * @return *pAddend value before decrement. + * @return *pulAddend value before decrement. */ -static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pAddend ) +static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pulAddend ) { uint32_t ulCurrent; ATOMIC_ENTER_CRITICAL(); - - ulCurrent = *pAddend; - - *pAddend -= 1; - + { + ulCurrent = *pulAddend; + *pulAddend -= 1; + } ATOMIC_EXIT_CRITICAL(); return ulCurrent; @@ -304,115 +306,112 @@ static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pAdde * * @brief Performs an atomic OR operation on the specified values. * - * @param [in, out] pDestination Pointer to memory location from where value is + * @param [in, out] pulDestination Pointer to memory location from where value is * to be loaded and written back to. - * @param [in] ulValue Value to be ORed with *pDestination. + * @param [in] ulValue Value to be ORed with *pulDestination. * - * @return The original value of *pDestination. + * @return The original value of *pulDestination. */ -static portFORCE_INLINE uint32_t Atomic_OR_u32( - uint32_t volatile * pDestination, - uint32_t ulValue ) +static portFORCE_INLINE uint32_t Atomic_OR_u32( uint32_t volatile * pulDestination, + uint32_t ulValue ) { uint32_t ulCurrent; ATOMIC_ENTER_CRITICAL(); - - ulCurrent = *pDestination; - - *pDestination |= ulValue; - + { + ulCurrent = *pulDestination; + *pulDestination |= ulValue; + } ATOMIC_EXIT_CRITICAL(); return ulCurrent; } +/*-----------------------------------------------------------*/ /** * Atomic AND * * @brief Performs an atomic AND operation on the specified values. * - * @param [in, out] pDestination Pointer to memory location from where value is + * @param [in, out] pulDestination Pointer to memory location from where value is * to be loaded and written back to. - * @param [in] ulValue Value to be ANDed with *pDestination. + * @param [in] ulValue Value to be ANDed with *pulDestination. * - * @return The original value of *pDestination. + * @return The original value of *pulDestination. */ -static portFORCE_INLINE uint32_t Atomic_AND_u32( - uint32_t volatile * pDestination, - uint32_t ulValue ) +static portFORCE_INLINE uint32_t Atomic_AND_u32( uint32_t volatile * pulDestination, + uint32_t ulValue ) { uint32_t ulCurrent; ATOMIC_ENTER_CRITICAL(); - - ulCurrent = *pDestination; - - *pDestination &= ulValue; - + { + ulCurrent = *pulDestination; + *pulDestination &= ulValue; + } ATOMIC_EXIT_CRITICAL(); return ulCurrent; } +/*-----------------------------------------------------------*/ /** * Atomic NAND * * @brief Performs an atomic NAND operation on the specified values. * - * @param [in, out] pDestination Pointer to memory location from where value is + * @param [in, out] pulDestination Pointer to memory location from where value is * to be loaded and written back to. - * @param [in] ulValue Value to be NANDed with *pDestination. + * @param [in] ulValue Value to be NANDed with *pulDestination. * - * @return The original value of *pDestination. + * @return The original value of *pulDestination. */ -static portFORCE_INLINE uint32_t Atomic_NAND_u32( - uint32_t volatile * pDestination, - uint32_t ulValue ) +static portFORCE_INLINE uint32_t Atomic_NAND_u32( uint32_t volatile * pulDestination, + uint32_t ulValue ) { uint32_t ulCurrent; ATOMIC_ENTER_CRITICAL(); - - ulCurrent = *pDestination; - - *pDestination = ~(ulCurrent & ulValue); - + { + ulCurrent = *pulDestination; + *pulDestination = ~( ulCurrent & ulValue ); + } ATOMIC_EXIT_CRITICAL(); return ulCurrent; } +/*-----------------------------------------------------------*/ /** * Atomic XOR * * @brief Performs an atomic XOR operation on the specified values. * - * @param [in, out] pDestination Pointer to memory location from where value is + * @param [in, out] pulDestination Pointer to memory location from where value is * to be loaded and written back to. - * @param [in] ulValue Value to be XORed with *pDestination. + * @param [in] ulValue Value to be XORed with *pulDestination. * - * @return The original value of *pDestination. + * @return The original value of *pulDestination. */ -static portFORCE_INLINE uint32_t Atomic_XOR_u32( - uint32_t volatile * pDestination, - uint32_t ulValue ) +static portFORCE_INLINE uint32_t Atomic_XOR_u32( uint32_t volatile * pulDestination, + uint32_t ulValue ) { uint32_t ulCurrent; ATOMIC_ENTER_CRITICAL(); - - ulCurrent = *pDestination; - - *pDestination ^= ulValue; - + { + ulCurrent = *pulDestination; + *pulDestination ^= ulValue; + } ATOMIC_EXIT_CRITICAL(); return ulCurrent; } +/* *INDENT-OFF* */ #ifdef __cplusplus -} + } #endif +/* *INDENT-ON* */ #endif /* ATOMIC_H */ diff --git a/tools/sdk/esp32c3/include/freertos/include/freertos/croutine.h b/tools/sdk/esp32c3/include/freertos/include/freertos/croutine.h index 8b3b41b9051..99322d219f2 100644 --- a/tools/sdk/esp32c3/include/freertos/include/freertos/croutine.h +++ b/tools/sdk/esp32c3/include/freertos/include/freertos/croutine.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,51 +19,56 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ #ifndef CO_ROUTINE_H #define CO_ROUTINE_H #ifndef INC_FREERTOS_H - #error "include FreeRTOS.h must appear in source files before include croutine.h" + #error "include FreeRTOS.h must appear in source files before include croutine.h" #endif #include "list.h" +/* *INDENT-OFF* */ #ifdef __cplusplus -extern "C" { + extern "C" { #endif +/* *INDENT-ON* */ /* Used to hide the implementation of the co-routine control block. The -control block structure however has to be included in the header due to -the macro implementation of the co-routine functionality. */ + * control block structure however has to be included in the header due to + * the macro implementation of the co-routine functionality. */ typedef void * CoRoutineHandle_t; /* Defines the prototype to which co-routine functions must conform. */ -typedef void (*crCOROUTINE_CODE)( CoRoutineHandle_t, UBaseType_t ); +typedef void (* crCOROUTINE_CODE)( CoRoutineHandle_t, + UBaseType_t ); typedef struct corCoRoutineControlBlock { - crCOROUTINE_CODE pxCoRoutineFunction; - ListItem_t xGenericListItem; /*< List item used to place the CRCB in ready and blocked queues. */ - ListItem_t xEventListItem; /*< List item used to place the CRCB in event lists. */ - UBaseType_t uxPriority; /*< The priority of the co-routine in relation to other co-routines. */ - UBaseType_t uxIndex; /*< Used to distinguish between co-routines when multiple co-routines use the same co-routine function. */ - uint16_t uxState; /*< Used internally by the co-routine implementation. */ -} CRCB_t; /* Co-routine control block. Note must be identical in size down to uxPriority with TCB_t. */ + crCOROUTINE_CODE pxCoRoutineFunction; + ListItem_t xGenericListItem; /*< List item used to place the CRCB in ready and blocked queues. */ + ListItem_t xEventListItem; /*< List item used to place the CRCB in event lists. */ + UBaseType_t uxPriority; /*< The priority of the co-routine in relation to other co-routines. */ + UBaseType_t uxIndex; /*< Used to distinguish between co-routines when multiple co-routines use the same co-routine function. */ + uint16_t uxState; /*< Used internally by the co-routine implementation. */ +} CRCB_t; /* Co-routine control block. Note must be identical in size down to uxPriority with TCB_t. */ /** + * @cond * croutine. h - *
- BaseType_t xCoRoutineCreate(
-                                 crCOROUTINE_CODE pxCoRoutineCode,
-                                 UBaseType_t uxPriority,
-                                 UBaseType_t uxIndex
-                               );
+ * @code{c} + * BaseType_t xCoRoutineCreate( + * crCOROUTINE_CODE pxCoRoutineCode, + * UBaseType_t uxPriority, + * UBaseType_t uxIndex + * ); + * @endcode + * @endcond * * Create a new co-routine and add it to the list of co-routines that are * ready to run. @@ -83,59 +88,65 @@ typedef struct corCoRoutineControlBlock * list, otherwise an error code defined with ProjDefs.h. * * Example usage: -
- // Co-routine to be created.
- void vFlashCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- // This may not be necessary for const variables.
- static const char cLedToFlash[ 2 ] = { 5, 6 };
- static const TickType_t uxFlashRates[ 2 ] = { 200, 400 };
-
-     // Must start every co-routine with a call to crSTART();
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-         // This co-routine just delays for a fixed period, then toggles
-         // an LED.  Two co-routines are created using this function, so
-         // the uxIndex parameter is used to tell the co-routine which
-         // LED to flash and how int32_t to delay.  This assumes xQueue has
-         // already been created.
-         vParTestToggleLED( cLedToFlash[ uxIndex ] );
-         crDELAY( xHandle, uxFlashRates[ uxIndex ] );
-     }
-
-     // Must end every co-routine with a call to crEND();
-     crEND();
- }
-
- // Function that creates two co-routines.
- void vOtherFunction( void )
- {
- uint8_t ucParameterToPass;
- TaskHandle_t xHandle;
-
-     // Create two co-routines at priority 0.  The first is given index 0
-     // so (from the code above) toggles LED 5 every 200 ticks.  The second
-     // is given index 1 so toggles LED 6 every 400 ticks.
-     for( uxIndex = 0; uxIndex < 2; uxIndex++ )
-     {
-         xCoRoutineCreate( vFlashCoRoutine, 0, uxIndex );
-     }
- }
-   
+ * @code{c} + * // Co-routine to be created. + * void vFlashCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) + * { + * // Variables in co-routines must be declared static if they must maintain value across a blocking call. + * // This may not be necessary for const variables. + * static const char cLedToFlash[ 2 ] = { 5, 6 }; + * static const TickType_t uxFlashRates[ 2 ] = { 200, 400 }; + * + * // Must start every co-routine with a call to crSTART(); + * crSTART( xHandle ); + * + * for( ;; ) + * { + * // This co-routine just delays for a fixed period, then toggles + * // an LED. Two co-routines are created using this function, so + * // the uxIndex parameter is used to tell the co-routine which + * // LED to flash and how int32_t to delay. This assumes xQueue has + * // already been created. + * vParTestToggleLED( cLedToFlash[ uxIndex ] ); + * crDELAY( xHandle, uxFlashRates[ uxIndex ] ); + * } + * + * // Must end every co-routine with a call to crEND(); + * crEND(); + * } + * + * // Function that creates two co-routines. + * void vOtherFunction( void ) + * { + * uint8_t ucParameterToPass; + * TaskHandle_t xHandle; + * + * // Create two co-routines at priority 0. The first is given index 0 + * // so (from the code above) toggles LED 5 every 200 ticks. The second + * // is given index 1 so toggles LED 6 every 400 ticks. + * for( uxIndex = 0; uxIndex < 2; uxIndex++ ) + * { + * xCoRoutineCreate( vFlashCoRoutine, 0, uxIndex ); + * } + * } + * @endcode + * @cond * \defgroup xCoRoutineCreate xCoRoutineCreate + * @endcond * \ingroup Tasks */ -BaseType_t xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, UBaseType_t uxPriority, UBaseType_t uxIndex ); +BaseType_t xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, + UBaseType_t uxPriority, + UBaseType_t uxIndex ); /** + * @cond * croutine. h - *
- void vCoRoutineSchedule( void );
- * + * @code{c} + * void vCoRoutineSchedule( void ); + * @endcode + * @endcond * Run a co-routine. * * vCoRoutineSchedule() executes the highest priority co-routine that is able @@ -148,103 +159,127 @@ BaseType_t xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, UBaseType_t uxPri * hook). * * Example usage: -
- // This idle task hook will schedule a co-routine each time it is called.
- // The rest of the idle task will execute between co-routine calls.
- void vApplicationIdleHook( void )
- {
-	vCoRoutineSchedule();
- }
-
- // Alternatively, if you do not require any other part of the idle task to
- // execute, the idle task hook can call vCoRoutineScheduler() within an
- // infinite loop.
- void vApplicationIdleHook( void )
- {
-    for( ;; )
-    {
-        vCoRoutineSchedule();
-    }
- }
- 
+ * @code{c} + * // This idle task hook will schedule a co-routine each time it is called. + * // The rest of the idle task will execute between co-routine calls. + * void vApplicationIdleHook( void ) + * { + * vCoRoutineSchedule(); + * } + * + * // Alternatively, if you do not require any other part of the idle task to + * // execute, the idle task hook can call vCoRoutineScheduler() within an + * // infinite loop. + * void vApplicationIdleHook( void ) + * { + * for( ;; ) + * { + * vCoRoutineSchedule(); + * } + * } + * @endcode + * @endcode + * @cond * \defgroup vCoRoutineSchedule vCoRoutineSchedule + * @endcond * \ingroup Tasks */ void vCoRoutineSchedule( void ); /** + * @cond * croutine. h - *
- crSTART( CoRoutineHandle_t xHandle );
+ * @code{c} + * crSTART( CoRoutineHandle_t xHandle ); + * @endcode + * @endcond * * This macro MUST always be called at the start of a co-routine function. * * Example usage: -
- // Co-routine to be created.
- void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- static int32_t ulAVariable;
-
-     // Must start every co-routine with a call to crSTART();
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-          // Co-routine functionality goes here.
-     }
-
-     // Must end every co-routine with a call to crEND();
-     crEND();
- }
+ * @code{c} + * // Co-routine to be created. + * void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) + * { + * // Variables in co-routines must be declared static if they must maintain value across a blocking call. + * static int32_t ulAVariable; + * + * // Must start every co-routine with a call to crSTART(); + * crSTART( xHandle ); + * + * for( ;; ) + * { + * // Co-routine functionality goes here. + * } + * + * // Must end every co-routine with a call to crEND(); + * crEND(); + * } + * @endcode + * @cond * \defgroup crSTART crSTART + * @endcond * \ingroup Tasks */ -#define crSTART( pxCRCB ) switch( ( ( CRCB_t * )( pxCRCB ) )->uxState ) { case 0: +#define crSTART( pxCRCB ) \ + switch( ( ( CRCB_t * ) ( pxCRCB ) )->uxState ) { \ + case 0: /** + * @cond * croutine. h - *
- crEND();
+ * @code{c} + * crEND(); + * @endcode + * @endcond * * This macro MUST always be called at the end of a co-routine function. * * Example usage: -
- // Co-routine to be created.
- void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- static int32_t ulAVariable;
-
-     // Must start every co-routine with a call to crSTART();
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-          // Co-routine functionality goes here.
-     }
-
-     // Must end every co-routine with a call to crEND();
-     crEND();
- }
+ * @code{c} + * // Co-routine to be created. + * void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) + * { + * // Variables in co-routines must be declared static if they must maintain value across a blocking call. + * static int32_t ulAVariable; + * + * // Must start every co-routine with a call to crSTART(); + * crSTART( xHandle ); + * + * for( ;; ) + * { + * // Co-routine functionality goes here. + * } + * + * // Must end every co-routine with a call to crEND(); + * crEND(); + * } + * @endcode + * @cond * \defgroup crSTART crSTART + * @endcond * \ingroup Tasks */ -#define crEND() } +#define crEND() } /* * These macros are intended for internal use by the co-routine implementation * only. The macros should not be used directly by application writers. */ -#define crSET_STATE0( xHandle ) ( ( CRCB_t * )( xHandle ) )->uxState = (__LINE__ * 2); return; case (__LINE__ * 2): -#define crSET_STATE1( xHandle ) ( ( CRCB_t * )( xHandle ) )->uxState = ((__LINE__ * 2)+1); return; case ((__LINE__ * 2)+1): +#define crSET_STATE0( xHandle ) \ + ( ( CRCB_t * ) ( xHandle ) )->uxState = ( __LINE__ * 2 ); return; \ + case ( __LINE__ * 2 ): +#define crSET_STATE1( xHandle ) \ + ( ( CRCB_t * ) ( xHandle ) )->uxState = ( ( __LINE__ * 2 ) + 1 ); return; \ + case ( ( __LINE__ * 2 ) + 1 ): /** + * @cond * croutine. h - *
- crDELAY( CoRoutineHandle_t xHandle, TickType_t xTicksToDelay );
+ * @code{c} + * crDELAY( CoRoutineHandle_t xHandle, TickType_t xTicksToDelay ); + * @endcode + * @endcond * * Delay a co-routine for a fixed period of time. * @@ -261,48 +296,54 @@ void vCoRoutineSchedule( void ); * can be used to convert ticks to milliseconds. * * Example usage: -
- // Co-routine to be created.
- void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- // This may not be necessary for const variables.
- // We are to delay for 200ms.
- static const xTickType xDelayTime = 200 / portTICK_PERIOD_MS;
-
-     // Must start every co-routine with a call to crSTART();
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-        // Delay for 200ms.
-        crDELAY( xHandle, xDelayTime );
-
-        // Do something here.
-     }
-
-     // Must end every co-routine with a call to crEND();
-     crEND();
- }
+ * @code{c} + * // Co-routine to be created. + * void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) + * { + * // Variables in co-routines must be declared static if they must maintain value across a blocking call. + * // This may not be necessary for const variables. + * // We are to delay for 200ms. + * static const xTickType xDelayTime = 200 / portTICK_PERIOD_MS; + * + * // Must start every co-routine with a call to crSTART(); + * crSTART( xHandle ); + * + * for( ;; ) + * { + * // Delay for 200ms. + * crDELAY( xHandle, xDelayTime ); + * + * // Do something here. + * } + * + * // Must end every co-routine with a call to crEND(); + * crEND(); + * } + * @endcode + * @cond * \defgroup crDELAY crDELAY + * @endcond * \ingroup Tasks */ -#define crDELAY( xHandle, xTicksToDelay ) \ - if( ( xTicksToDelay ) > 0 ) \ - { \ - vCoRoutineAddToDelayedList( ( xTicksToDelay ), NULL ); \ - } \ - crSET_STATE0( ( xHandle ) ); +#define crDELAY( xHandle, xTicksToDelay ) \ + if( ( xTicksToDelay ) > 0 ) \ + { \ + vCoRoutineAddToDelayedList( ( xTicksToDelay ), NULL ); \ + } \ + crSET_STATE0( ( xHandle ) ); /** - *
- crQUEUE_SEND(
-                  CoRoutineHandle_t xHandle,
-                  QueueHandle_t pxQueue,
-                  void *pvItemToQueue,
-                  TickType_t xTicksToWait,
-                  BaseType_t *pxResult
-             )
+ * @cond + * @code{c} + * crQUEUE_SEND( + * CoRoutineHandle_t xHandle, + * QueueHandle_t pxQueue, + * void *pvItemToQueue, + * TickType_t xTicksToWait, + * BaseType_t *pxResult + * ) + * @endcode + * @endcond * * The macro's crQUEUE_SEND() and crQUEUE_RECEIVE() are the co-routine * equivalent to the xQueueSend() and xQueueReceive() functions used by tasks. @@ -342,66 +383,72 @@ void vCoRoutineSchedule( void ); * error defined within ProjDefs.h. * * Example usage: -
- // Co-routine function that blocks for a fixed period then posts a number onto
- // a queue.
- static void prvCoRoutineFlashTask( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- static BaseType_t xNumberToPost = 0;
- static BaseType_t xResult;
-
-    // Co-routines must begin with a call to crSTART().
-    crSTART( xHandle );
-
-    for( ;; )
-    {
-        // This assumes the queue has already been created.
-        crQUEUE_SEND( xHandle, xCoRoutineQueue, &xNumberToPost, NO_DELAY, &xResult );
-
-        if( xResult != pdPASS )
-        {
-            // The message was not posted!
-        }
-
-        // Increment the number to be posted onto the queue.
-        xNumberToPost++;
-
-        // Delay for 100 ticks.
-        crDELAY( xHandle, 100 );
-    }
-
-    // Co-routines must end with a call to crEND().
-    crEND();
- }
+ * @code{c} + * // Co-routine function that blocks for a fixed period then posts a number onto + * // a queue. + * static void prvCoRoutineFlashTask( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) + * { + * // Variables in co-routines must be declared static if they must maintain value across a blocking call. + * static BaseType_t xNumberToPost = 0; + * static BaseType_t xResult; + * + * // Co-routines must begin with a call to crSTART(). + * crSTART( xHandle ); + * + * for( ;; ) + * { + * // This assumes the queue has already been created. + * crQUEUE_SEND( xHandle, xCoRoutineQueue, &xNumberToPost, NO_DELAY, &xResult ); + * + * if( xResult != pdPASS ) + * { + * // The message was not posted! + * } + * + * // Increment the number to be posted onto the queue. + * xNumberToPost++; + * + * // Delay for 100 ticks. + * crDELAY( xHandle, 100 ); + * } + * + * // Co-routines must end with a call to crEND(). + * crEND(); + * } + * @endcode + * @cond * \defgroup crQUEUE_SEND crQUEUE_SEND + * @endcond * \ingroup Tasks */ -#define crQUEUE_SEND( xHandle, pxQueue, pvItemToQueue, xTicksToWait, pxResult ) \ -{ \ - *( pxResult ) = xQueueCRSend( ( pxQueue) , ( pvItemToQueue) , ( xTicksToWait ) ); \ - if( *( pxResult ) == errQUEUE_BLOCKED ) \ - { \ - crSET_STATE0( ( xHandle ) ); \ - *pxResult = xQueueCRSend( ( pxQueue ), ( pvItemToQueue ), 0 ); \ - } \ - if( *pxResult == errQUEUE_YIELD ) \ - { \ - crSET_STATE1( ( xHandle ) ); \ - *pxResult = pdPASS; \ - } \ -} +#define crQUEUE_SEND( xHandle, pxQueue, pvItemToQueue, xTicksToWait, pxResult ) \ + { \ + *( pxResult ) = xQueueCRSend( ( pxQueue ), ( pvItemToQueue ), ( xTicksToWait ) ); \ + if( *( pxResult ) == errQUEUE_BLOCKED ) \ + { \ + crSET_STATE0( ( xHandle ) ); \ + *pxResult = xQueueCRSend( ( pxQueue ), ( pvItemToQueue ), 0 ); \ + } \ + if( *pxResult == errQUEUE_YIELD ) \ + { \ + crSET_STATE1( ( xHandle ) ); \ + *pxResult = pdPASS; \ + } \ + } /** + * @cond * croutine. h - *
-  crQUEUE_RECEIVE(
-                     CoRoutineHandle_t xHandle,
-                     QueueHandle_t pxQueue,
-                     void *pvBuffer,
-                     TickType_t xTicksToWait,
-                     BaseType_t *pxResult
-                 )
+ * @code{c} + * crQUEUE_RECEIVE( + * CoRoutineHandle_t xHandle, + * QueueHandle_t pxQueue, + * void *pvBuffer, + * TickType_t xTicksToWait, + * BaseType_t *pxResult + * ) + * @endcode + * @endcond * * The macro's crQUEUE_SEND() and crQUEUE_RECEIVE() are the co-routine * equivalent to the xQueueSend() and xQueueReceive() functions used by tasks. @@ -440,58 +487,64 @@ void vCoRoutineSchedule( void ); * an error code as defined within ProjDefs.h. * * Example usage: -
- // A co-routine receives the number of an LED to flash from a queue.  It
- // blocks on the queue until the number is received.
- static void prvCoRoutineFlashWorkTask( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- static BaseType_t xResult;
- static UBaseType_t uxLEDToFlash;
-
-    // All co-routines must start with a call to crSTART().
-    crSTART( xHandle );
-
-    for( ;; )
-    {
-        // Wait for data to become available on the queue.
-        crQUEUE_RECEIVE( xHandle, xCoRoutineQueue, &uxLEDToFlash, portMAX_DELAY, &xResult );
-
-        if( xResult == pdPASS )
-        {
-            // We received the LED to flash - flash it!
-            vParTestToggleLED( uxLEDToFlash );
-        }
-    }
-
-    crEND();
- }
+ * @code{c} + * // A co-routine receives the number of an LED to flash from a queue. It + * // blocks on the queue until the number is received. + * static void prvCoRoutineFlashWorkTask( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) + * { + * // Variables in co-routines must be declared static if they must maintain value across a blocking call. + * static BaseType_t xResult; + * static UBaseType_t uxLEDToFlash; + * + * // All co-routines must start with a call to crSTART(). + * crSTART( xHandle ); + * + * for( ;; ) + * { + * // Wait for data to become available on the queue. + * crQUEUE_RECEIVE( xHandle, xCoRoutineQueue, &uxLEDToFlash, portMAX_DELAY, &xResult ); + * + * if( xResult == pdPASS ) + * { + * // We received the LED to flash - flash it! + * vParTestToggleLED( uxLEDToFlash ); + * } + * } + * + * crEND(); + * } + * @endcode + * @cond * \defgroup crQUEUE_RECEIVE crQUEUE_RECEIVE + * @endcond * \ingroup Tasks */ -#define crQUEUE_RECEIVE( xHandle, pxQueue, pvBuffer, xTicksToWait, pxResult ) \ -{ \ - *( pxResult ) = xQueueCRReceive( ( pxQueue) , ( pvBuffer ), ( xTicksToWait ) ); \ - if( *( pxResult ) == errQUEUE_BLOCKED ) \ - { \ - crSET_STATE0( ( xHandle ) ); \ - *( pxResult ) = xQueueCRReceive( ( pxQueue) , ( pvBuffer ), 0 ); \ - } \ - if( *( pxResult ) == errQUEUE_YIELD ) \ - { \ - crSET_STATE1( ( xHandle ) ); \ - *( pxResult ) = pdPASS; \ - } \ -} +#define crQUEUE_RECEIVE( xHandle, pxQueue, pvBuffer, xTicksToWait, pxResult ) \ + { \ + *( pxResult ) = xQueueCRReceive( ( pxQueue ), ( pvBuffer ), ( xTicksToWait ) ); \ + if( *( pxResult ) == errQUEUE_BLOCKED ) \ + { \ + crSET_STATE0( ( xHandle ) ); \ + *( pxResult ) = xQueueCRReceive( ( pxQueue ), ( pvBuffer ), 0 ); \ + } \ + if( *( pxResult ) == errQUEUE_YIELD ) \ + { \ + crSET_STATE1( ( xHandle ) ); \ + *( pxResult ) = pdPASS; \ + } \ + } /** + * @cond * croutine. h - *
-  crQUEUE_SEND_FROM_ISR(
-                            QueueHandle_t pxQueue,
-                            void *pvItemToQueue,
-                            BaseType_t xCoRoutinePreviouslyWoken
-                       )
+ * @code{c} + * crQUEUE_SEND_FROM_ISR( + * QueueHandle_t pxQueue, + * void *pvItemToQueue, + * BaseType_t xCoRoutinePreviouslyWoken + * ) + * @endcode + * @endcond * * The macro's crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() are the * co-routine equivalent to the xQueueSendFromISR() and xQueueReceiveFromISR() @@ -526,69 +579,76 @@ void vCoRoutineSchedule( void ); * the ISR. * * Example usage: -
- // A co-routine that blocks on a queue waiting for characters to be received.
- static void vReceivingCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- char cRxedChar;
- BaseType_t xResult;
-
-     // All co-routines must start with a call to crSTART().
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-         // Wait for data to become available on the queue.  This assumes the
-         // queue xCommsRxQueue has already been created!
-         crQUEUE_RECEIVE( xHandle, xCommsRxQueue, &uxLEDToFlash, portMAX_DELAY, &xResult );
-
-         // Was a character received?
-         if( xResult == pdPASS )
-         {
-             // Process the character here.
-         }
-     }
-
-     // All co-routines must end with a call to crEND().
-     crEND();
- }
-
- // An ISR that uses a queue to send characters received on a serial port to
- // a co-routine.
- void vUART_ISR( void )
- {
- char cRxedChar;
- BaseType_t xCRWokenByPost = pdFALSE;
-
-     // We loop around reading characters until there are none left in the UART.
-     while( UART_RX_REG_NOT_EMPTY() )
-     {
-         // Obtain the character from the UART.
-         cRxedChar = UART_RX_REG;
-
-         // Post the character onto a queue.  xCRWokenByPost will be pdFALSE
-         // the first time around the loop.  If the post causes a co-routine
-         // to be woken (unblocked) then xCRWokenByPost will be set to pdTRUE.
-         // In this manner we can ensure that if more than one co-routine is
-         // blocked on the queue only one is woken by this ISR no matter how
-         // many characters are posted to the queue.
-         xCRWokenByPost = crQUEUE_SEND_FROM_ISR( xCommsRxQueue, &cRxedChar, xCRWokenByPost );
-     }
- }
+ * @code{c} + * // A co-routine that blocks on a queue waiting for characters to be received. + * static void vReceivingCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) + * { + * char cRxedChar; + * BaseType_t xResult; + * + * // All co-routines must start with a call to crSTART(). + * crSTART( xHandle ); + * + * for( ;; ) + * { + * // Wait for data to become available on the queue. This assumes the + * // queue xCommsRxQueue has already been created! + * crQUEUE_RECEIVE( xHandle, xCommsRxQueue, &uxLEDToFlash, portMAX_DELAY, &xResult ); + * + * // Was a character received? + * if( xResult == pdPASS ) + * { + * // Process the character here. + * } + * } + * + * // All co-routines must end with a call to crEND(). + * crEND(); + * } + * + * // An ISR that uses a queue to send characters received on a serial port to + * // a co-routine. + * void vUART_ISR( void ) + * { + * char cRxedChar; + * BaseType_t xCRWokenByPost = pdFALSE; + * + * // We loop around reading characters until there are none left in the UART. + * while( UART_RX_REG_NOT_EMPTY() ) + * { + * // Obtain the character from the UART. + * cRxedChar = UART_RX_REG; + * + * // Post the character onto a queue. xCRWokenByPost will be pdFALSE + * // the first time around the loop. If the post causes a co-routine + * // to be woken (unblocked) then xCRWokenByPost will be set to pdTRUE. + * // In this manner we can ensure that if more than one co-routine is + * // blocked on the queue only one is woken by this ISR no matter how + * // many characters are posted to the queue. + * xCRWokenByPost = crQUEUE_SEND_FROM_ISR( xCommsRxQueue, &cRxedChar, xCRWokenByPost ); + * } + * } + * @endcode + * @cond * \defgroup crQUEUE_SEND_FROM_ISR crQUEUE_SEND_FROM_ISR + * @endcond * \ingroup Tasks */ -#define crQUEUE_SEND_FROM_ISR( pxQueue, pvItemToQueue, xCoRoutinePreviouslyWoken ) xQueueCRSendFromISR( ( pxQueue ), ( pvItemToQueue ), ( xCoRoutinePreviouslyWoken ) ) +#define crQUEUE_SEND_FROM_ISR( pxQueue, pvItemToQueue, xCoRoutinePreviouslyWoken ) \ + xQueueCRSendFromISR( ( pxQueue ), ( pvItemToQueue ), ( xCoRoutinePreviouslyWoken ) ) /** + * @cond * croutine. h - *
-  crQUEUE_SEND_FROM_ISR(
-                            QueueHandle_t pxQueue,
-                            void *pvBuffer,
-                            BaseType_t * pxCoRoutineWoken
-                       )
+ * @code{c} + * crQUEUE_SEND_FROM_ISR( + * QueueHandle_t pxQueue, + * void *pvBuffer, + * BaseType_t * pxCoRoutineWoken + * ) + * @endcode + * @endcond * * The macro's crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() are the * co-routine equivalent to the xQueueSendFromISR() and xQueueReceiveFromISR() @@ -623,75 +683,79 @@ void vCoRoutineSchedule( void ); * pdFALSE. * * Example usage: -
- // A co-routine that posts a character to a queue then blocks for a fixed
- // period.  The character is incremented each time.
- static void vSendingCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // cChar holds its value while this co-routine is blocked and must therefore
- // be declared static.
- static char cCharToTx = 'a';
- BaseType_t xResult;
-
-     // All co-routines must start with a call to crSTART().
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-         // Send the next character to the queue.
-         crQUEUE_SEND( xHandle, xCoRoutineQueue, &cCharToTx, NO_DELAY, &xResult );
-
-         if( xResult == pdPASS )
-         {
-             // The character was successfully posted to the queue.
-         }
-		 else
-		 {
-			// Could not post the character to the queue.
-		 }
-
-         // Enable the UART Tx interrupt to cause an interrupt in this
-		 // hypothetical UART.  The interrupt will obtain the character
-		 // from the queue and send it.
-		 ENABLE_RX_INTERRUPT();
-
-		 // Increment to the next character then block for a fixed period.
-		 // cCharToTx will maintain its value across the delay as it is
-		 // declared static.
-		 cCharToTx++;
-		 if( cCharToTx > 'x' )
-		 {
-			cCharToTx = 'a';
-		 }
-		 crDELAY( 100 );
-     }
-
-     // All co-routines must end with a call to crEND().
-     crEND();
- }
-
- // An ISR that uses a queue to receive characters to send on a UART.
- void vUART_ISR( void )
- {
- char cCharToTx;
- BaseType_t xCRWokenByPost = pdFALSE;
-
-     while( UART_TX_REG_EMPTY() )
-     {
-         // Are there any characters in the queue waiting to be sent?
-		 // xCRWokenByPost will automatically be set to pdTRUE if a co-routine
-		 // is woken by the post - ensuring that only a single co-routine is
-		 // woken no matter how many times we go around this loop.
-         if( crQUEUE_RECEIVE_FROM_ISR( pxQueue, &cCharToTx, &xCRWokenByPost ) )
-		 {
-			 SEND_CHARACTER( cCharToTx );
-		 }
-     }
- }
+ * @code{c} + * // A co-routine that posts a character to a queue then blocks for a fixed + * // period. The character is incremented each time. + * static void vSendingCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) + * { + * // cChar holds its value while this co-routine is blocked and must therefore + * // be declared static. + * static char cCharToTx = 'a'; + * BaseType_t xResult; + * + * // All co-routines must start with a call to crSTART(). + * crSTART( xHandle ); + * + * for( ;; ) + * { + * // Send the next character to the queue. + * crQUEUE_SEND( xHandle, xCoRoutineQueue, &cCharToTx, NO_DELAY, &xResult ); + * + * if( xResult == pdPASS ) + * { + * // The character was successfully posted to the queue. + * } + * else + * { + * // Could not post the character to the queue. + * } + * + * // Enable the UART Tx interrupt to cause an interrupt in this + * // hypothetical UART. The interrupt will obtain the character + * // from the queue and send it. + * ENABLE_RX_INTERRUPT(); + * + * // Increment to the next character then block for a fixed period. + * // cCharToTx will maintain its value across the delay as it is + * // declared static. + * cCharToTx++; + * if( cCharToTx > 'x' ) + * { + * cCharToTx = 'a'; + * } + * crDELAY( 100 ); + * } + * + * // All co-routines must end with a call to crEND(). + * crEND(); + * } + * + * // An ISR that uses a queue to receive characters to send on a UART. + * void vUART_ISR( void ) + * { + * char cCharToTx; + * BaseType_t xCRWokenByPost = pdFALSE; + * + * while( UART_TX_REG_EMPTY() ) + * { + * // Are there any characters in the queue waiting to be sent? + * // xCRWokenByPost will automatically be set to pdTRUE if a co-routine + * // is woken by the post - ensuring that only a single co-routine is + * // woken no matter how many times we go around this loop. + * if( crQUEUE_RECEIVE_FROM_ISR( pxQueue, &cCharToTx, &xCRWokenByPost ) ) + * { + * SEND_CHARACTER( cCharToTx ); + * } + * } + * } + * @endcode + * @cond * \defgroup crQUEUE_RECEIVE_FROM_ISR crQUEUE_RECEIVE_FROM_ISR + * @endcond * \ingroup Tasks */ -#define crQUEUE_RECEIVE_FROM_ISR( pxQueue, pvBuffer, pxCoRoutineWoken ) xQueueCRReceiveFromISR( ( pxQueue ), ( pvBuffer ), ( pxCoRoutineWoken ) ) +#define crQUEUE_RECEIVE_FROM_ISR( pxQueue, pvBuffer, pxCoRoutineWoken ) \ + xQueueCRReceiveFromISR( ( pxQueue ), ( pvBuffer ), ( pxCoRoutineWoken ) ) /* * This function is intended for internal use by the co-routine macros only. @@ -702,7 +766,8 @@ void vCoRoutineSchedule( void ); * Removes the current co-routine from its ready list and places it in the * appropriate delayed list. */ -void vCoRoutineAddToDelayedList( TickType_t xTicksToDelay, List_t *pxEventList ); +void vCoRoutineAddToDelayedList( TickType_t xTicksToDelay, + List_t * pxEventList ); /* * This function is intended for internal use by the queue implementation only. @@ -711,10 +776,12 @@ void vCoRoutineAddToDelayedList( TickType_t xTicksToDelay, List_t *pxEventList ) * Removes the highest priority co-routine from the event list and places it in * the pending ready list. */ -BaseType_t xCoRoutineRemoveFromEventList( const List_t *pxEventList ); +BaseType_t xCoRoutineRemoveFromEventList( const List_t * pxEventList ); +/* *INDENT-OFF* */ #ifdef __cplusplus -} + } #endif +/* *INDENT-ON* */ #endif /* CO_ROUTINE_H */ diff --git a/tools/sdk/esp32c3/include/freertos/include/freertos/deprecated_definitions.h b/tools/sdk/esp32c3/include/freertos/include/freertos/deprecated_definitions.h index 70fc403bd28..d3b942666d0 100644 --- a/tools/sdk/esp32c3/include/freertos/include/freertos/deprecated_definitions.h +++ b/tools/sdk/esp32c3/include/freertos/include/freertos/deprecated_definitions.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ #ifndef DEPRECATED_DEFINITIONS_H @@ -30,158 +29,158 @@ /* Each FreeRTOS port has a unique portmacro.h header file. Originally a -pre-processor definition was used to ensure the pre-processor found the correct -portmacro.h file for the port being used. That scheme was deprecated in favour -of setting the compiler's include path such that it found the correct -portmacro.h file - removing the need for the constant and allowing the -portmacro.h file to be located anywhere in relation to the port being used. The -definitions below remain in the code for backward compatibility only. New -projects should not use them. */ + * pre-processor definition was used to ensure the pre-processor found the correct + * portmacro.h file for the port being used. That scheme was deprecated in favour + * of setting the compiler's include path such that it found the correct + * portmacro.h file - removing the need for the constant and allowing the + * portmacro.h file to be located anywhere in relation to the port being used. The + * definitions below remain in the code for backward compatibility only. New + * projects should not use them. */ #ifdef OPEN_WATCOM_INDUSTRIAL_PC_PORT - #include "..\..\Source\portable\owatcom\16bitdos\pc\portmacro.h" - typedef void ( __interrupt __far *pxISR )(); + #include "..\..\Source\portable\owatcom\16bitdos\pc\portmacro.h" + typedef void ( __interrupt __far * pxISR )(); #endif #ifdef OPEN_WATCOM_FLASH_LITE_186_PORT - #include "..\..\Source\portable\owatcom\16bitdos\flsh186\portmacro.h" - typedef void ( __interrupt __far *pxISR )(); + #include "..\..\Source\portable\owatcom\16bitdos\flsh186\portmacro.h" + typedef void ( __interrupt __far * pxISR )(); #endif #ifdef GCC_MEGA_AVR - #include "../portable/GCC/ATMega323/portmacro.h" + #include "../portable/GCC/ATMega323/portmacro.h" #endif #ifdef IAR_MEGA_AVR - #include "../portable/IAR/ATMega323/portmacro.h" + #include "../portable/IAR/ATMega323/portmacro.h" #endif #ifdef MPLAB_PIC24_PORT - #include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h" + #include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h" #endif #ifdef MPLAB_DSPIC_PORT - #include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h" + #include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h" #endif #ifdef MPLAB_PIC18F_PORT - #include "../../Source/portable/MPLAB/PIC18F/portmacro.h" + #include "../../Source/portable/MPLAB/PIC18F/portmacro.h" #endif #ifdef MPLAB_PIC32MX_PORT - #include "../../Source/portable/MPLAB/PIC32MX/portmacro.h" + #include "../../Source/portable/MPLAB/PIC32MX/portmacro.h" #endif #ifdef _FEDPICC - #include "libFreeRTOS/Include/portmacro.h" + #include "libFreeRTOS/Include/portmacro.h" #endif #ifdef SDCC_CYGNAL - #include "../../Source/portable/SDCC/Cygnal/portmacro.h" + #include "../../Source/portable/SDCC/Cygnal/portmacro.h" #endif #ifdef GCC_ARM7 - #include "../../Source/portable/GCC/ARM7_LPC2000/portmacro.h" + #include "../../Source/portable/GCC/ARM7_LPC2000/portmacro.h" #endif #ifdef GCC_ARM7_ECLIPSE - #include "portmacro.h" + #include "portmacro.h" #endif #ifdef ROWLEY_LPC23xx - #include "../../Source/portable/GCC/ARM7_LPC23xx/portmacro.h" + #include "../../Source/portable/GCC/ARM7_LPC23xx/portmacro.h" #endif #ifdef IAR_MSP430 - #include "..\..\Source\portable\IAR\MSP430\portmacro.h" + #include "..\..\Source\portable\IAR\MSP430\portmacro.h" #endif #ifdef GCC_MSP430 - #include "../../Source/portable/GCC/MSP430F449/portmacro.h" + #include "../../Source/portable/GCC/MSP430F449/portmacro.h" #endif #ifdef ROWLEY_MSP430 - #include "../../Source/portable/Rowley/MSP430F449/portmacro.h" + #include "../../Source/portable/Rowley/MSP430F449/portmacro.h" #endif #ifdef ARM7_LPC21xx_KEIL_RVDS - #include "..\..\Source\portable\RVDS\ARM7_LPC21xx\portmacro.h" + #include "..\..\Source\portable\RVDS\ARM7_LPC21xx\portmacro.h" #endif #ifdef SAM7_GCC - #include "../../Source/portable/GCC/ARM7_AT91SAM7S/portmacro.h" + #include "../../Source/portable/GCC/ARM7_AT91SAM7S/portmacro.h" #endif #ifdef SAM7_IAR - #include "..\..\Source\portable\IAR\AtmelSAM7S64\portmacro.h" + #include "..\..\Source\portable\IAR\AtmelSAM7S64\portmacro.h" #endif #ifdef SAM9XE_IAR - #include "..\..\Source\portable\IAR\AtmelSAM9XE\portmacro.h" + #include "..\..\Source\portable\IAR\AtmelSAM9XE\portmacro.h" #endif #ifdef LPC2000_IAR - #include "..\..\Source\portable\IAR\LPC2000\portmacro.h" + #include "..\..\Source\portable\IAR\LPC2000\portmacro.h" #endif #ifdef STR71X_IAR - #include "..\..\Source\portable\IAR\STR71x\portmacro.h" + #include "..\..\Source\portable\IAR\STR71x\portmacro.h" #endif #ifdef STR75X_IAR - #include "..\..\Source\portable\IAR\STR75x\portmacro.h" + #include "..\..\Source\portable\IAR\STR75x\portmacro.h" #endif #ifdef STR75X_GCC - #include "..\..\Source\portable\GCC\STR75x\portmacro.h" + #include "..\..\Source\portable\GCC\STR75x\portmacro.h" #endif #ifdef STR91X_IAR - #include "..\..\Source\portable\IAR\STR91x\portmacro.h" + #include "..\..\Source\portable\IAR\STR91x\portmacro.h" #endif #ifdef GCC_H8S - #include "../../Source/portable/GCC/H8S2329/portmacro.h" + #include "../../Source/portable/GCC/H8S2329/portmacro.h" #endif #ifdef GCC_AT91FR40008 - #include "../../Source/portable/GCC/ARM7_AT91FR40008/portmacro.h" + #include "../../Source/portable/GCC/ARM7_AT91FR40008/portmacro.h" #endif #ifdef RVDS_ARMCM3_LM3S102 - #include "../../Source/portable/RVDS/ARM_CM3/portmacro.h" + #include "../../Source/portable/RVDS/ARM_CM3/portmacro.h" #endif #ifdef GCC_ARMCM3_LM3S102 - #include "../../Source/portable/GCC/ARM_CM3/portmacro.h" + #include "../../Source/portable/GCC/ARM_CM3/portmacro.h" #endif #ifdef GCC_ARMCM3 - #include "../../Source/portable/GCC/ARM_CM3/portmacro.h" + #include "../../Source/portable/GCC/ARM_CM3/portmacro.h" #endif #ifdef IAR_ARM_CM3 - #include "../../Source/portable/IAR/ARM_CM3/portmacro.h" + #include "../../Source/portable/IAR/ARM_CM3/portmacro.h" #endif #ifdef IAR_ARMCM3_LM - #include "../../Source/portable/IAR/ARM_CM3/portmacro.h" + #include "../../Source/portable/IAR/ARM_CM3/portmacro.h" #endif #ifdef HCS12_CODE_WARRIOR - #include "../../Source/portable/CodeWarrior/HCS12/portmacro.h" + #include "../../Source/portable/CodeWarrior/HCS12/portmacro.h" #endif #ifdef MICROBLAZE_GCC - #include "../../Source/portable/GCC/MicroBlaze/portmacro.h" + #include "../../Source/portable/GCC/MicroBlaze/portmacro.h" #endif #ifdef TERN_EE - #include "..\..\Source\portable\Paradigm\Tern_EE\small\portmacro.h" + #include "..\..\Source\portable\Paradigm\Tern_EE\small\portmacro.h" #endif #ifdef GCC_HCS12 - #include "../../Source/portable/GCC/HCS12/portmacro.h" + #include "../../Source/portable/GCC/HCS12/portmacro.h" #endif #ifdef GCC_MCF5235 @@ -189,90 +188,92 @@ projects should not use them. */ #endif #ifdef COLDFIRE_V2_GCC - #include "../../../Source/portable/GCC/ColdFire_V2/portmacro.h" + #include "../../../Source/portable/GCC/ColdFire_V2/portmacro.h" #endif #ifdef COLDFIRE_V2_CODEWARRIOR - #include "../../Source/portable/CodeWarrior/ColdFire_V2/portmacro.h" + #include "../../Source/portable/CodeWarrior/ColdFire_V2/portmacro.h" #endif #ifdef GCC_PPC405 - #include "../../Source/portable/GCC/PPC405_Xilinx/portmacro.h" + #include "../../Source/portable/GCC/PPC405_Xilinx/portmacro.h" #endif #ifdef GCC_PPC440 - #include "../../Source/portable/GCC/PPC440_Xilinx/portmacro.h" + #include "../../Source/portable/GCC/PPC440_Xilinx/portmacro.h" #endif #ifdef _16FX_SOFTUNE - #include "..\..\Source\portable\Softune\MB96340\portmacro.h" + #include "..\..\Source\portable\Softune\MB96340\portmacro.h" #endif #ifdef BCC_INDUSTRIAL_PC_PORT - /* A short file name has to be used in place of the normal - FreeRTOSConfig.h when using the Borland compiler. */ - #include "frconfig.h" - #include "..\portable\BCC\16BitDOS\PC\prtmacro.h" - typedef void ( __interrupt __far *pxISR )(); + +/* A short file name has to be used in place of the normal + * FreeRTOSConfig.h when using the Borland compiler. */ + #include "frconfig.h" + #include "..\portable\BCC\16BitDOS\PC\prtmacro.h" + typedef void ( __interrupt __far * pxISR )(); #endif #ifdef BCC_FLASH_LITE_186_PORT - /* A short file name has to be used in place of the normal - FreeRTOSConfig.h when using the Borland compiler. */ - #include "frconfig.h" - #include "..\portable\BCC\16BitDOS\flsh186\prtmacro.h" - typedef void ( __interrupt __far *pxISR )(); + +/* A short file name has to be used in place of the normal + * FreeRTOSConfig.h when using the Borland compiler. */ + #include "frconfig.h" + #include "..\portable\BCC\16BitDOS\flsh186\prtmacro.h" + typedef void ( __interrupt __far * pxISR )(); #endif #ifdef __GNUC__ - #ifdef __AVR32_AVR32A__ - #include "portmacro.h" - #endif + #ifdef __AVR32_AVR32A__ + #include "portmacro.h" + #endif #endif #ifdef __ICCAVR32__ - #ifdef __CORE__ - #if __CORE__ == __AVR32A__ - #include "portmacro.h" - #endif - #endif + #ifdef __CORE__ + #if __CORE__ == __AVR32A__ + #include "portmacro.h" + #endif + #endif #endif #ifdef __91467D - #include "portmacro.h" + #include "portmacro.h" #endif #ifdef __96340 - #include "portmacro.h" + #include "portmacro.h" #endif #ifdef __IAR_V850ES_Fx3__ - #include "../../Source/portable/IAR/V850ES/portmacro.h" + #include "../../Source/portable/IAR/V850ES/portmacro.h" #endif #ifdef __IAR_V850ES_Jx3__ - #include "../../Source/portable/IAR/V850ES/portmacro.h" + #include "../../Source/portable/IAR/V850ES/portmacro.h" #endif #ifdef __IAR_V850ES_Jx3_L__ - #include "../../Source/portable/IAR/V850ES/portmacro.h" + #include "../../Source/portable/IAR/V850ES/portmacro.h" #endif #ifdef __IAR_V850ES_Jx2__ - #include "../../Source/portable/IAR/V850ES/portmacro.h" + #include "../../Source/portable/IAR/V850ES/portmacro.h" #endif #ifdef __IAR_V850ES_Hx2__ - #include "../../Source/portable/IAR/V850ES/portmacro.h" + #include "../../Source/portable/IAR/V850ES/portmacro.h" #endif #ifdef __IAR_78K0R_Kx3__ - #include "../../Source/portable/IAR/78K0R/portmacro.h" + #include "../../Source/portable/IAR/78K0R/portmacro.h" #endif #ifdef __IAR_78K0R_Kx3L__ - #include "../../Source/portable/IAR/78K0R/portmacro.h" + #include "../../Source/portable/IAR/78K0R/portmacro.h" #endif #endif /* DEPRECATED_DEFINITIONS_H */ diff --git a/tools/sdk/esp32c3/include/freertos/include/freertos/event_groups.h b/tools/sdk/esp32c3/include/freertos/include/freertos/event_groups.h index 5773e8d9071..84505ddaaa0 100644 --- a/tools/sdk/esp32c3/include/freertos/include/freertos/event_groups.h +++ b/tools/sdk/esp32c3/include/freertos/include/freertos/event_groups.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,25 +19,26 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ #ifndef EVENT_GROUPS_H #define EVENT_GROUPS_H #ifndef INC_FREERTOS_H - #error "include FreeRTOS.h" must appear in source files before "include event_groups.h" + #error "include FreeRTOS.h" must appear in source files before "include event_groups.h" #endif /* FreeRTOS includes. */ #include "timers.h" +/* *INDENT-OFF* */ #ifdef __cplusplus -extern "C" { + extern "C" { #endif +/* *INDENT-ON* */ /** * An event group is a collection of bits to which an application can assign a @@ -63,6 +64,9 @@ extern "C" { * used to create a synchronisation point between multiple tasks (a * 'rendezvous'). * + * @cond + * \defgroup EventGroup EventGroup + * @endcond */ @@ -74,34 +78,45 @@ extern "C" { * xEventGroupCreate() returns an EventGroupHandle_t variable that can then * be used as a parameter to other event group functions. * + * @cond * \defgroup EventGroupHandle_t EventGroupHandle_t + * @endcond * \ingroup EventGroup */ struct EventGroupDef_t; -//typedef struct EventGroupDef_t * EventGroupHandle_t; +#ifdef ESP_PLATFORM // IDF-3770 typedef void * EventGroupHandle_t; - +#else +typedef struct EventGroupDef_t * EventGroupHandle_t; +#endif // ESP_PLATFORM /* * The type that holds event bits always matches TickType_t - therefore the * number of bits it holds is set by configUSE_16_BIT_TICKS (16 bits if set to 1, * 32 bits if set to 0. * + * @cond * \defgroup EventBits_t EventBits_t + * @endcond * \ingroup EventGroup */ -typedef TickType_t EventBits_t; +typedef TickType_t EventBits_t; /** - * + * @cond + * event_groups.h + * @code{c} + * EventGroupHandle_t xEventGroupCreate( void ); + * @endcode + * @endcond * * 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 + * 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 + * (see https://www.FreeRTOS.org/a00111.html). If an event group is created + * using xEventGroupCreateStatic() 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. @@ -116,42 +131,52 @@ typedef TickType_t EventBits_t; * * @return If the event group was created then a handle to the event group is * returned. If there was insufficient FreeRTOS heap available to create the - * event group then NULL is returned. See http://www.freertos.org/a00111.html + * event group then NULL is returned. See https://www.FreeRTOS.org/a00111.html * * Example usage: * @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. - * } + * // 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 + * @cond + * \defgroup xEventGroupCreate xEventGroupCreate + * @endcond * \ingroup EventGroup */ -#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - EventGroupHandle_t xEventGroupCreate( void ) PRIVILEGED_FUNCTION; +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + EventGroupHandle_t xEventGroupCreate( void ) PRIVILEGED_FUNCTION; #endif /** + * @cond + * event_groups.h + * @code{c} + * EventGroupHandle_t xEventGroupCreateStatic( EventGroupHandle_t * pxEventGroupBuffer ); + * @endcode + * @endcond + * * 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 + * 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 + * (see https://www.FreeRTOS.org/a00111.html). If an event group is created + * using xEventGroupCreateStatic() 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. @@ -173,25 +198,36 @@ typedef TickType_t EventBits_t; * * 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 ); + * // 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; +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + EventGroupHandle_t xEventGroupCreateStatic( StaticEventGroup_t * pxEventGroupBuffer ) PRIVILEGED_FUNCTION; #endif /** + * @cond + * event_groups.h + * @code{c} + * EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup, + * const EventBits_t uxBitsToWaitFor, + * const BaseType_t xClearOnExit, + * const BaseType_t xWaitForAllBits, + * const TickType_t xTicksToWait ); + * @endcode + * @endcond + * * [Potentially] block to wait for one or more bits to be set within a * previously created event group. * @@ -235,47 +271,60 @@ typedef TickType_t EventBits_t; * * Example usage: * @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} + * #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 + * @cond + * \defgroup xEventGroupWaitBits xEventGroupWaitBits + * @endcond * \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; +EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup, + const EventBits_t uxBitsToWaitFor, + const BaseType_t xClearOnExit, + const BaseType_t xWaitForAllBits, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; /** + * @cond + * event_groups.h + * @code{c} + * EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear ); + * @endcode + * @endcond * * Clear bits within an event group. This function cannot be called from an * interrupt. @@ -290,44 +339,54 @@ EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup, const EventBits * * Example usage: * @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. - * } - * } + * #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 + * @cond + * \defgroup xEventGroupClearBits xEventGroupClearBits + * @endcond * \ingroup EventGroup */ -EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear ) PRIVILEGED_FUNCTION; +EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, + const EventBits_t uxBitsToClear ) PRIVILEGED_FUNCTION; /** + * @cond + * event_groups.h + * @code{c} + * BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ); + * @endcode + * @endcond * * A version of xEventGroupClearBits() that can be called from an interrupt. * @@ -353,35 +412,46 @@ EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBit * * Example usage: * @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. - * } - * } + * #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 + * @cond + * \defgroup xEventGroupClearBitsFromISR xEventGroupClearBitsFromISR + * @endcond * \ingroup EventGroup */ -#if( configUSE_TRACE_FACILITY == 1 ) - BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear ) PRIVILEGED_FUNCTION; +#if ( configUSE_TRACE_FACILITY == 1 ) + BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup, + const EventBits_t uxBitsToClear ) PRIVILEGED_FUNCTION; #else - #define xEventGroupClearBitsFromISR( xEventGroup, uxBitsToClear ) xTimerPendFunctionCallFromISR( vEventGroupClearBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToClear, NULL ) + #define xEventGroupClearBitsFromISR( xEventGroup, uxBitsToClear ) \ + xTimerPendFunctionCallFromISR( vEventGroupClearBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToClear, NULL ) #endif /** + * @cond + * event_groups.h + * @code{c} + * EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ); + * @endcode + * @endcond * * Set bits within an event group. * This function cannot be called from an interrupt. xEventGroupSetBitsFromISR() @@ -408,49 +478,59 @@ EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBit * * Example usage: * @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} + * #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 + * @cond + * \defgroup xEventGroupSetBits xEventGroupSetBits + * @endcond * \ingroup EventGroup */ -EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ) PRIVILEGED_FUNCTION; +EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, + const EventBits_t uxBitsToSet ) PRIVILEGED_FUNCTION; /** + * @cond + * event_groups.h + * @code{c} + * BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * @endcond * * A version of xEventGroupSetBits() that can be called from an interrupt. * @@ -484,46 +564,61 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_ * * Example usage: * @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 ); - * } - * } + * #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 + * @cond + * \defgroup xEventGroupSetBitsFromISR xEventGroupSetBitsFromISR + * @endcond * \ingroup EventGroup */ -#if( configUSE_TRACE_FACILITY == 1 ) - BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; +#if ( configUSE_TRACE_FACILITY == 1 ) + BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, + const EventBits_t uxBitsToSet, + BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; #else - #define xEventGroupSetBitsFromISR( xEventGroup, uxBitsToSet, pxHigherPriorityTaskWoken ) xTimerPendFunctionCallFromISR( vEventGroupSetBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToSet, pxHigherPriorityTaskWoken ) + #define xEventGroupSetBitsFromISR( xEventGroup, uxBitsToSet, pxHigherPriorityTaskWoken ) \ + xTimerPendFunctionCallFromISR( vEventGroupSetBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToSet, pxHigherPriorityTaskWoken ) #endif /** + * @cond + * event_groups.h + * @code{c} + * EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, + * const EventBits_t uxBitsToSet, + * const EventBits_t uxBitsToWaitFor, + * TickType_t xTicksToWait ); + * @endcode + * @endcond * * 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 @@ -563,86 +658,98 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_ * * Example usage: * @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. - * } - * } + * // 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. - * } + * } + * + * 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 synchronisation 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 synchronisation was made by all + * // three tasks, so there is no need to test the return value. * } + * } * * @endcode + * @cond + * \defgroup xEventGroupSync xEventGroupSync + * @endcond * \ingroup EventGroup */ -EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, + const EventBits_t uxBitsToSet, + const EventBits_t uxBitsToWaitFor, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; /** + * @cond + * event_groups.h + * @code{c} + * EventBits_t xEventGroupGetBits( EventGroupHandle_t xEventGroup ); + * @endcode + * @endcond * * Returns the current value of the bits in an event group. This function * cannot be used from an interrupt. @@ -651,11 +758,20 @@ EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t u * * @return The event group bits at the time xEventGroupGetBits() was called. * + * @cond + * \defgroup xEventGroupGetBits xEventGroupGetBits + * @endcond * \ingroup EventGroup */ -#define xEventGroupGetBits( xEventGroup ) xEventGroupClearBits( xEventGroup, 0 ) +#define xEventGroupGetBits( xEventGroup ) xEventGroupClearBits( xEventGroup, 0 ) /** + * @cond + * event_groups.h + * @code{c} + * EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup ); + * @endcode + * @endcond * * A version of xEventGroupGetBits() that can be called from an ISR. * @@ -663,11 +779,21 @@ EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t u * * @return The event group bits at the time xEventGroupGetBitsFromISR() was called. * + * @cond + * \defgroup xEventGroupGetBitsFromISR xEventGroupGetBitsFromISR + * @endcond * \ingroup EventGroup */ EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION; /** + * @cond + * event_groups.h + * @code{c} + * void xEventGroupDelete( EventGroupHandle_t xEventGroup ); + * @endcode + * @endcond + * * Delete an event group that was previously created by a call to * xEventGroupCreate(). Tasks that are blocked on the event group will be * unblocked and obtain 0 as the event group's value. @@ -679,19 +805,24 @@ void vEventGroupDelete( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION; /** @cond */ /* For internal use only. */ -void vEventGroupSetBitsCallback( void *pvEventGroup, const uint32_t ulBitsToSet ) PRIVILEGED_FUNCTION; -void vEventGroupClearBitsCallback( void *pvEventGroup, const uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION; +void vEventGroupSetBitsCallback( void * pvEventGroup, + const uint32_t ulBitsToSet ) PRIVILEGED_FUNCTION; +void vEventGroupClearBitsCallback( void * pvEventGroup, + const uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION; -#if (configUSE_TRACE_FACILITY == 1) - UBaseType_t uxEventGroupGetNumber( void* xEventGroup ) PRIVILEGED_FUNCTION; - void vEventGroupSetNumber( void* xEventGroup, UBaseType_t uxEventGroupNumber ) PRIVILEGED_FUNCTION; +#if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxEventGroupGetNumber( void * xEventGroup ) PRIVILEGED_FUNCTION; + void vEventGroupSetNumber( void * xEventGroup, + UBaseType_t uxEventGroupNumber ) PRIVILEGED_FUNCTION; #endif /** @endcond */ +/* *INDENT-OFF* */ #ifdef __cplusplus -} + } #endif +/* *INDENT-ON* */ #endif /* EVENT_GROUPS_H */ diff --git a/tools/sdk/esp32c3/include/freertos/include/freertos/list.h b/tools/sdk/esp32c3/include/freertos/include/freertos/list.h index d06481e29bf..f76328f8e03 100644 --- a/tools/sdk/esp32c3/include/freertos/include/freertos/list.h +++ b/tools/sdk/esp32c3/include/freertos/include/freertos/list.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ /* @@ -54,7 +53,7 @@ */ #ifndef INC_FREERTOS_H - #error FreeRTOS.h must be included before list.h + #error "FreeRTOS.h must be included before list.h" #endif #ifndef LIST_H @@ -89,47 +88,49 @@ * "#define configLIST_VOLATILE volatile" */ #ifndef configLIST_VOLATILE - #define configLIST_VOLATILE + #define configLIST_VOLATILE #endif /* configSUPPORT_CROSS_MODULE_OPTIMISATION */ +/* *INDENT-OFF* */ #ifdef __cplusplus -extern "C" { + extern "C" { #endif +/* *INDENT-ON* */ /* Macros that can be used to place known values within the list structures, -then check that the known values do not get corrupted during the execution of -the application. These may catch the list data structures being overwritten in -memory. They will not catch data errors caused by incorrect configuration or -use of FreeRTOS.*/ -#if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 0 ) - /* Define the macros to do nothing. */ - #define listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE - #define listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE - #define listFIRST_LIST_INTEGRITY_CHECK_VALUE - #define listSECOND_LIST_INTEGRITY_CHECK_VALUE - #define listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) - #define listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) - #define listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList ) - #define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList ) - #define listTEST_LIST_ITEM_INTEGRITY( pxItem ) - #define listTEST_LIST_INTEGRITY( pxList ) -#else - /* Define macros that add new members into the list structures. */ - #define listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE TickType_t xListItemIntegrityValue1; - #define listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE TickType_t xListItemIntegrityValue2; - #define listFIRST_LIST_INTEGRITY_CHECK_VALUE TickType_t xListIntegrityValue1; - #define listSECOND_LIST_INTEGRITY_CHECK_VALUE TickType_t xListIntegrityValue2; - - /* Define macros that set the new structure members to known values. */ - #define listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) ( pxItem )->xListItemIntegrityValue1 = pdINTEGRITY_CHECK_VALUE - #define listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) ( pxItem )->xListItemIntegrityValue2 = pdINTEGRITY_CHECK_VALUE - #define listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList ) ( pxList )->xListIntegrityValue1 = pdINTEGRITY_CHECK_VALUE - #define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList ) ( pxList )->xListIntegrityValue2 = pdINTEGRITY_CHECK_VALUE - - /* Define macros that will assert if one of the structure members does not - contain its expected value. */ - #define listTEST_LIST_ITEM_INTEGRITY( pxItem ) configASSERT( ( ( pxItem )->xListItemIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxItem )->xListItemIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) ) - #define listTEST_LIST_INTEGRITY( pxList ) configASSERT( ( ( pxList )->xListIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxList )->xListIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) ) + * then check that the known values do not get corrupted during the execution of + * the application. These may catch the list data structures being overwritten in + * memory. They will not catch data errors caused by incorrect configuration or + * use of FreeRTOS.*/ +#if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 0 ) + /* Define the macros to do nothing. */ + #define listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE + #define listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE + #define listFIRST_LIST_INTEGRITY_CHECK_VALUE + #define listSECOND_LIST_INTEGRITY_CHECK_VALUE + #define listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) + #define listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) + #define listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList ) + #define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList ) + #define listTEST_LIST_ITEM_INTEGRITY( pxItem ) + #define listTEST_LIST_INTEGRITY( pxList ) +#else /* if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 0 ) */ + /* Define macros that add new members into the list structures. */ + #define listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE TickType_t xListItemIntegrityValue1; + #define listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE TickType_t xListItemIntegrityValue2; + #define listFIRST_LIST_INTEGRITY_CHECK_VALUE TickType_t xListIntegrityValue1; + #define listSECOND_LIST_INTEGRITY_CHECK_VALUE TickType_t xListIntegrityValue2; + +/* Define macros that set the new structure members to known values. */ + #define listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) ( pxItem )->xListItemIntegrityValue1 = pdINTEGRITY_CHECK_VALUE + #define listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) ( pxItem )->xListItemIntegrityValue2 = pdINTEGRITY_CHECK_VALUE + #define listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList ) ( pxList )->xListIntegrityValue1 = pdINTEGRITY_CHECK_VALUE + #define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList ) ( pxList )->xListIntegrityValue2 = pdINTEGRITY_CHECK_VALUE + +/* Define macros that will assert if one of the structure members does not + * contain its expected value. */ + #define listTEST_LIST_ITEM_INTEGRITY( pxItem ) configASSERT( ( ( pxItem )->xListItemIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxItem )->xListItemIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) ) + #define listTEST_LIST_INTEGRITY( pxList ) configASSERT( ( ( pxList )->xListIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxList )->xListIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) ) #endif /* configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES */ @@ -139,22 +140,22 @@ use of FreeRTOS.*/ struct xLIST; struct xLIST_ITEM { - listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ - configLIST_VOLATILE TickType_t xItemValue; /*< The value being listed. In most cases this is used to sort the list in descending order. */ - struct xLIST_ITEM * configLIST_VOLATILE pxNext; /*< Pointer to the next ListItem_t in the list. */ - struct xLIST_ITEM * configLIST_VOLATILE pxPrevious; /*< Pointer to the previous ListItem_t in the list. */ - void * pvOwner; /*< Pointer to the object (normally a TCB) that contains the list item. There is therefore a two way link between the object containing the list item and the list item itself. */ - struct xLIST * configLIST_VOLATILE pxContainer; /*< Pointer to the list in which this list item is placed (if any). */ - listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ + listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ + configLIST_VOLATILE TickType_t xItemValue; /*< The value being listed. In most cases this is used to sort the list in descending order. */ + struct xLIST_ITEM * configLIST_VOLATILE pxNext; /*< Pointer to the next ListItem_t in the list. */ + struct xLIST_ITEM * configLIST_VOLATILE pxPrevious; /*< Pointer to the previous ListItem_t in the list. */ + void * pvOwner; /*< Pointer to the object (normally a TCB) that contains the list item. There is therefore a two way link between the object containing the list item and the list item itself. */ + struct xLIST * configLIST_VOLATILE pxContainer; /*< Pointer to the list in which this list item is placed (if any). */ + listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ }; -typedef struct xLIST_ITEM ListItem_t; /* For some reason lint wants this as two separate definitions. */ +typedef struct xLIST_ITEM ListItem_t; /* For some reason lint wants this as two separate definitions. */ struct xMINI_LIST_ITEM { - listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ - configLIST_VOLATILE TickType_t xItemValue; - struct xLIST_ITEM * configLIST_VOLATILE pxNext; - struct xLIST_ITEM * configLIST_VOLATILE pxPrevious; + listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ + configLIST_VOLATILE TickType_t xItemValue; + struct xLIST_ITEM * configLIST_VOLATILE pxNext; + struct xLIST_ITEM * configLIST_VOLATILE pxPrevious; }; typedef struct xMINI_LIST_ITEM MiniListItem_t; @@ -163,11 +164,11 @@ typedef struct xMINI_LIST_ITEM MiniListItem_t; */ typedef struct xLIST { - listFIRST_LIST_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ - volatile UBaseType_t uxNumberOfItems; - ListItem_t * configLIST_VOLATILE pxIndex; /*< Used to walk through the list. Points to the last item returned by a call to listGET_OWNER_OF_NEXT_ENTRY (). */ - MiniListItem_t xListEnd; /*< List item that contains the maximum possible item value meaning it is always at the end of the list and is therefore used as a marker. */ - listSECOND_LIST_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ + listFIRST_LIST_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ + volatile UBaseType_t uxNumberOfItems; + ListItem_t * configLIST_VOLATILE pxIndex; /*< Used to walk through the list. Points to the last item returned by a call to listGET_OWNER_OF_NEXT_ENTRY (). */ + MiniListItem_t xListEnd; /*< List item that contains the maximum possible item value meaning it is always at the end of the list and is therefore used as a marker. */ + listSECOND_LIST_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ } List_t; /* @@ -177,7 +178,7 @@ typedef struct xLIST * \page listSET_LIST_ITEM_OWNER listSET_LIST_ITEM_OWNER * \ingroup LinkedList */ -#define listSET_LIST_ITEM_OWNER( pxListItem, pxOwner ) ( ( pxListItem )->pvOwner = ( void * ) ( pxOwner ) ) +#define listSET_LIST_ITEM_OWNER( pxListItem, pxOwner ) ( ( pxListItem )->pvOwner = ( void * ) ( pxOwner ) ) /* * Access macro to get the owner of a list item. The owner of a list item @@ -186,7 +187,7 @@ typedef struct xLIST * \page listGET_LIST_ITEM_OWNER listSET_LIST_ITEM_OWNER * \ingroup LinkedList */ -#define listGET_LIST_ITEM_OWNER( pxListItem ) ( ( pxListItem )->pvOwner ) +#define listGET_LIST_ITEM_OWNER( pxListItem ) ( ( pxListItem )->pvOwner ) /* * Access macro to set the value of the list item. In most cases the value is @@ -195,7 +196,7 @@ typedef struct xLIST * \page listSET_LIST_ITEM_VALUE listSET_LIST_ITEM_VALUE * \ingroup LinkedList */ -#define listSET_LIST_ITEM_VALUE( pxListItem, xValue ) ( ( pxListItem )->xItemValue = ( xValue ) ) +#define listSET_LIST_ITEM_VALUE( pxListItem, xValue ) ( ( pxListItem )->xItemValue = ( xValue ) ) /* * Access macro to retrieve the value of the list item. The value can @@ -205,7 +206,7 @@ typedef struct xLIST * \page listGET_LIST_ITEM_VALUE listGET_LIST_ITEM_VALUE * \ingroup LinkedList */ -#define listGET_LIST_ITEM_VALUE( pxListItem ) ( ( pxListItem )->xItemValue ) +#define listGET_LIST_ITEM_VALUE( pxListItem ) ( ( pxListItem )->xItemValue ) /* * Access macro to retrieve the value of the list item at the head of a given @@ -214,7 +215,7 @@ typedef struct xLIST * \page listGET_LIST_ITEM_VALUE listGET_LIST_ITEM_VALUE * \ingroup LinkedList */ -#define listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxList ) ( ( ( pxList )->xListEnd ).pxNext->xItemValue ) +#define listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxList ) ( ( ( pxList )->xListEnd ).pxNext->xItemValue ) /* * Return the list item at the head of the list. @@ -222,7 +223,7 @@ typedef struct xLIST * \page listGET_HEAD_ENTRY listGET_HEAD_ENTRY * \ingroup LinkedList */ -#define listGET_HEAD_ENTRY( pxList ) ( ( ( pxList )->xListEnd ).pxNext ) +#define listGET_HEAD_ENTRY( pxList ) ( ( ( pxList )->xListEnd ).pxNext ) /* * Return the next list item. @@ -230,7 +231,7 @@ typedef struct xLIST * \page listGET_NEXT listGET_NEXT * \ingroup LinkedList */ -#define listGET_NEXT( pxListItem ) ( ( pxListItem )->pxNext ) +#define listGET_NEXT( pxListItem ) ( ( pxListItem )->pxNext ) /* * Return the list item that marks the end of the list @@ -238,7 +239,7 @@ typedef struct xLIST * \page listGET_END_MARKER listGET_END_MARKER * \ingroup LinkedList */ -#define listGET_END_MARKER( pxList ) ( ( ListItem_t const * ) ( &( ( pxList )->xListEnd ) ) ) +#define listGET_END_MARKER( pxList ) ( ( ListItem_t const * ) ( &( ( pxList )->xListEnd ) ) ) /* * Access macro to determine if a list contains any items. The macro will @@ -247,12 +248,12 @@ typedef struct xLIST * \page listLIST_IS_EMPTY listLIST_IS_EMPTY * \ingroup LinkedList */ -#define listLIST_IS_EMPTY( pxList ) ( ( ( pxList )->uxNumberOfItems == ( UBaseType_t ) 0 ) ? pdTRUE : pdFALSE ) +#define listLIST_IS_EMPTY( pxList ) ( ( ( pxList )->uxNumberOfItems == ( UBaseType_t ) 0 ) ? pdTRUE : pdFALSE ) /* * Access macro to return the number of items in the list. */ -#define listCURRENT_LIST_LENGTH( pxList ) ( ( pxList )->uxNumberOfItems ) +#define listCURRENT_LIST_LENGTH( pxList ) ( ( pxList )->uxNumberOfItems ) /* * Access function to obtain the owner of the next entry in a list. @@ -274,18 +275,18 @@ typedef struct xLIST * \page listGET_OWNER_OF_NEXT_ENTRY listGET_OWNER_OF_NEXT_ENTRY * \ingroup LinkedList */ -#define listGET_OWNER_OF_NEXT_ENTRY( pxTCB, pxList ) \ -{ \ -List_t * const pxConstList = ( pxList ); \ - /* Increment the index to the next item and return the item, ensuring */ \ - /* we don't return the marker used at the end of the list. */ \ - ( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \ - if( ( void * ) ( pxConstList )->pxIndex == ( void * ) &( ( pxConstList )->xListEnd ) ) \ - { \ - ( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \ - } \ - ( pxTCB ) = ( pxConstList )->pxIndex->pvOwner; \ -} +#define listGET_OWNER_OF_NEXT_ENTRY( pxTCB, pxList ) \ + { \ + List_t * const pxConstList = ( pxList ); \ + /* Increment the index to the next item and return the item, ensuring */ \ + /* we don't return the marker used at the end of the list. */ \ + ( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \ + if( ( void * ) ( pxConstList )->pxIndex == ( void * ) &( ( pxConstList )->xListEnd ) ) \ + { \ + ( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \ + } \ + ( pxTCB ) = ( pxConstList )->pxIndex->pvOwner; \ + } /* @@ -304,7 +305,7 @@ List_t * const pxConstList = ( pxList ); \ * \page listGET_OWNER_OF_HEAD_ENTRY listGET_OWNER_OF_HEAD_ENTRY * \ingroup LinkedList */ -#define listGET_OWNER_OF_HEAD_ENTRY( pxList ) ( (&( ( pxList )->xListEnd ))->pxNext->pvOwner ) +#define listGET_OWNER_OF_HEAD_ENTRY( pxList ) ( ( &( ( pxList )->xListEnd ) )->pxNext->pvOwner ) /* * Check to see if a list item is within a list. The list item maintains a @@ -315,7 +316,7 @@ List_t * const pxConstList = ( pxList ); \ * @param pxListItem The list item we want to know if is in the list. * @return pdTRUE if the list item is in the list, otherwise pdFALSE. */ -#define listIS_CONTAINED_WITHIN( pxList, pxListItem ) ( ( ( pxListItem )->pxContainer == ( pxList ) ) ? ( pdTRUE ) : ( pdFALSE ) ) +#define listIS_CONTAINED_WITHIN( pxList, pxListItem ) ( ( ( pxListItem )->pxContainer == ( pxList ) ) ? ( pdTRUE ) : ( pdFALSE ) ) /* * Return the list a list item is contained within (referenced from). @@ -323,14 +324,14 @@ List_t * const pxConstList = ( pxList ); \ * @param pxListItem The list item being queried. * @return A pointer to the List_t object that references the pxListItem */ -#define listLIST_ITEM_CONTAINER( pxListItem ) ( ( pxListItem )->pxContainer ) +#define listLIST_ITEM_CONTAINER( pxListItem ) ( ( pxListItem )->pxContainer ) /* * This provides a crude means of knowing if a list has been initialised, as * pxList->xListEnd.xItemValue is set to portMAX_DELAY by the vListInitialise() * function. */ -#define listLIST_IS_INITIALISED( pxList ) ( ( pxList )->xListEnd.xItemValue == portMAX_DELAY ) +#define listLIST_IS_INITIALISED( pxList ) ( ( pxList )->xListEnd.xItemValue == portMAX_DELAY ) /* * Must be called before a list is used! This initialises all the members @@ -366,7 +367,8 @@ void vListInitialiseItem( ListItem_t * const pxItem ) PRIVILEGED_FUNCTION; * \page vListInsert vListInsert * \ingroup LinkedList */ -void vListInsert( List_t * const pxList, ListItem_t * const pxNewListItem ) PRIVILEGED_FUNCTION; +void vListInsert( List_t * const pxList, + ListItem_t * const pxNewListItem ) PRIVILEGED_FUNCTION; /* * Insert a list item into a list. The item will be inserted in a position @@ -387,7 +389,8 @@ void vListInsert( List_t * const pxList, ListItem_t * const pxNewListItem ) PRIV * \page vListInsertEnd vListInsertEnd * \ingroup LinkedList */ -void vListInsertEnd( List_t * const pxList, ListItem_t * const pxNewListItem ) PRIVILEGED_FUNCTION; +void vListInsertEnd( List_t * const pxList, + ListItem_t * const pxNewListItem ) PRIVILEGED_FUNCTION; /* * Remove an item from a list. The list item has a pointer to the list that @@ -404,8 +407,10 @@ void vListInsertEnd( List_t * const pxList, ListItem_t * const pxNewListItem ) P */ UBaseType_t uxListRemove( ListItem_t * const pxItemToRemove ) PRIVILEGED_FUNCTION; +/* *INDENT-OFF* */ #ifdef __cplusplus -} + } #endif +/* *INDENT-ON* */ -#endif +#endif /* ifndef LIST_H */ diff --git a/tools/sdk/esp32c3/include/freertos/include/freertos/message_buffer.h b/tools/sdk/esp32c3/include/freertos/include/freertos/message_buffer.h index a49324da437..e57c589fbac 100644 --- a/tools/sdk/esp32c3/include/freertos/include/freertos/message_buffer.h +++ b/tools/sdk/esp32c3/include/freertos/include/freertos/message_buffer.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ @@ -63,15 +62,17 @@ #define FREERTOS_MESSAGE_BUFFER_H #ifndef INC_FREERTOS_H - #error "include FreeRTOS.h must appear in source files before include message_buffer.h" + #error "include FreeRTOS.h must appear in source files before include message_buffer.h" #endif /* Message buffers are built onto of stream buffers. */ #include "stream_buffer.h" +/* *INDENT-OFF* */ #if defined( __cplusplus ) -extern "C" { + extern "C" { #endif +/* *INDENT-ON* */ /** * Type by which message buffers are referenced. For example, a call to @@ -84,6 +85,14 @@ typedef void * MessageBufferHandle_t; /*-----------------------------------------------------------*/ /** + * @cond + * message_buffer.h + * + * @code{c} + * MessageBufferHandle_t xMessageBufferCreate( size_t xBufferSizeBytes ); + * @endcode + * @endcond + * * Creates a new message buffer using dynamically allocated memory. See * xMessageBufferCreateStatic() for a version that uses statically allocated * memory (memory that is allocated at compile time). @@ -113,28 +122,41 @@ typedef void * MessageBufferHandle_t; * MessageBufferHandle_t xMessageBuffer; * const size_t xMessageBufferSizeBytes = 100; * - * // Create a message buffer that can hold 100 bytes. The memory used to hold - * // both the message buffer structure and the messages themselves is allocated - * // dynamically. Each message added to the buffer consumes an additional 4 - * // bytes which are used to hold the lengh of the message. - * xMessageBuffer = xMessageBufferCreate( xMessageBufferSizeBytes ); - * - * if( xMessageBuffer == NULL ) - * { - * // There was not enough heap memory space available to create the - * // message buffer. - * } - * else - * { - * // The message buffer was created successfully and can now be used. - * } + * // Create a message buffer that can hold 100 bytes. The memory used to hold + * // both the message buffer structure and the messages themselves is allocated + * // dynamically. Each message added to the buffer consumes an additional 4 + * // bytes which are used to hold the lengh of the message. + * xMessageBuffer = xMessageBufferCreate( xMessageBufferSizeBytes ); + * + * if( xMessageBuffer == NULL ) + * { + * // There was not enough heap memory space available to create the + * // message buffer. + * } + * else + * { + * // The message buffer was created successfully and can now be used. + * } * * @endcode + * @cond + * \defgroup xMessageBufferCreate xMessageBufferCreate + * @endcond * \ingroup MessageBufferManagement */ -#define xMessageBufferCreate( xBufferSizeBytes ) ( MessageBufferHandle_t ) xStreamBufferGenericCreate( xBufferSizeBytes, ( size_t ) 0, pdTRUE ) +#define xMessageBufferCreate( xBufferSizeBytes ) \ + ( MessageBufferHandle_t ) xStreamBufferGenericCreate( xBufferSizeBytes, ( size_t ) 0, pdTRUE ) /** + * @cond + * message_buffer.h + * + * @code{c} + * MessageBufferHandle_t xMessageBufferCreateStatic( size_t xBufferSizeBytes, + * uint8_t *pucMessageBufferStorageArea, + * StaticMessageBuffer_t *pxStaticMessageBuffer ); + * @endcode + * @endcond * Creates a new message buffer using statically allocated memory. See * xMessageBufferCreate() for a version that uses dynamically allocated memory. * @@ -176,23 +198,38 @@ typedef void * MessageBufferHandle_t; * { * MessageBufferHandle_t xMessageBuffer; * - * xMessageBuffer = xMessageBufferCreateStatic( sizeof( ucBufferStorage ), - * ucBufferStorage, - * &xMessageBufferStruct ); + * xMessageBuffer = xMessageBufferCreateStatic( sizeof( ucBufferStorage ), + * ucBufferStorage, + * &xMessageBufferStruct ); * - * // As neither the pucMessageBufferStorageArea or pxStaticMessageBuffer - * // parameters were NULL, xMessageBuffer will not be NULL, and can be used to - * // reference the created message buffer in other message buffer API calls. + * // As neither the pucMessageBufferStorageArea or pxStaticMessageBuffer + * // parameters were NULL, xMessageBuffer will not be NULL, and can be used to + * // reference the created message buffer in other message buffer API calls. * - * // Other code that uses the message buffer can go here. + * // Other code that uses the message buffer can go here. * } * * @endcode + * @cond + * \defgroup xMessageBufferCreateStatic xMessageBufferCreateStatic + * @endcond * \ingroup MessageBufferManagement */ -#define xMessageBufferCreateStatic( xBufferSizeBytes, pucMessageBufferStorageArea, pxStaticMessageBuffer ) ( MessageBufferHandle_t ) xStreamBufferGenericCreateStatic( xBufferSizeBytes, 0, pdTRUE, pucMessageBufferStorageArea, pxStaticMessageBuffer ) +#define xMessageBufferCreateStatic( xBufferSizeBytes, pucMessageBufferStorageArea, pxStaticMessageBuffer ) \ + ( MessageBufferHandle_t ) xStreamBufferGenericCreateStatic( xBufferSizeBytes, 0, pdTRUE, pucMessageBufferStorageArea, pxStaticMessageBuffer ) /** + * @cond + * message_buffer.h + * + * @code{c} + * size_t xMessageBufferSend( MessageBufferHandle_t xMessageBuffer, + * const void *pvTxData, + * size_t xDataLengthBytes, + * TickType_t xTicksToWait ); + * @endcode + * @endcond + * * Sends a discrete message to the message buffer. The message can be any * length that fits within the buffer's free space, and is copied into the * buffer. @@ -256,32 +293,47 @@ typedef void * MessageBufferHandle_t; * char *pcStringToSend = "String to send"; * const TickType_t x100ms = pdMS_TO_TICKS( 100 ); * - * // Send an array to the message buffer, blocking for a maximum of 100ms to - * // wait for enough space to be available in the message buffer. - * xBytesSent = xMessageBufferSend( xMessageBuffer, ( void * ) ucArrayToSend, sizeof( ucArrayToSend ), x100ms ); - * - * if( xBytesSent != sizeof( ucArrayToSend ) ) - * { - * // The call to xMessageBufferSend() times out before there was enough - * // space in the buffer for the data to be written. - * } - * - * // Send the string to the message buffer. Return immediately if there is - * // not enough space in the buffer. - * xBytesSent = xMessageBufferSend( xMessageBuffer, ( void * ) pcStringToSend, strlen( pcStringToSend ), 0 ); - * - * if( xBytesSent != strlen( pcStringToSend ) ) - * { - * // The string could not be added to the message buffer because there was - * // not enough free space in the buffer. - * } + * // Send an array to the message buffer, blocking for a maximum of 100ms to + * // wait for enough space to be available in the message buffer. + * xBytesSent = xMessageBufferSend( xMessageBuffer, ( void * ) ucArrayToSend, sizeof( ucArrayToSend ), x100ms ); + * + * if( xBytesSent != sizeof( ucArrayToSend ) ) + * { + * // The call to xMessageBufferSend() times out before there was enough + * // space in the buffer for the data to be written. + * } + * + * // Send the string to the message buffer. Return immediately if there is + * // not enough space in the buffer. + * xBytesSent = xMessageBufferSend( xMessageBuffer, ( void * ) pcStringToSend, strlen( pcStringToSend ), 0 ); + * + * if( xBytesSent != strlen( pcStringToSend ) ) + * { + * // The string could not be added to the message buffer because there was + * // not enough free space in the buffer. + * } * } * @endcode + * @cond + * \defgroup xMessageBufferSend xMessageBufferSend + * @endcond * \ingroup MessageBufferManagement */ -#define xMessageBufferSend( xMessageBuffer, pvTxData, xDataLengthBytes, xTicksToWait ) xStreamBufferSend( ( StreamBufferHandle_t ) xMessageBuffer, pvTxData, xDataLengthBytes, xTicksToWait ) +#define xMessageBufferSend( xMessageBuffer, pvTxData, xDataLengthBytes, xTicksToWait ) \ + xStreamBufferSend( ( StreamBufferHandle_t ) xMessageBuffer, pvTxData, xDataLengthBytes, xTicksToWait ) /** + * @cond + * message_buffer.h + * + * @code{c} + * size_t xMessageBufferSendFromISR( MessageBufferHandle_t xMessageBuffer, + * const void *pvTxData, + * size_t xDataLengthBytes, + * BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * @endcond + * * Interrupt safe version of the API function that sends a discrete message to * the message buffer. The message can be any length that fits within the * buffer's free space, and is copied into the buffer. @@ -348,34 +400,49 @@ typedef void * MessageBufferHandle_t; * char *pcStringToSend = "String to send"; * BaseType_t xHigherPriorityTaskWoken = pdFALSE; // Initialised to pdFALSE. * - * // Attempt to send the string to the message buffer. - * xBytesSent = xMessageBufferSendFromISR( xMessageBuffer, - * ( void * ) pcStringToSend, - * strlen( pcStringToSend ), - * &xHigherPriorityTaskWoken ); - * - * if( xBytesSent != strlen( pcStringToSend ) ) - * { - * // The string could not be added to the message buffer because there was - * // not enough free space in the buffer. - * } - * - * // If xHigherPriorityTaskWoken was set to pdTRUE inside - * // xMessageBufferSendFromISR() then a task that has a priority above the - * // priority of the currently executing task was unblocked and a context - * // switch should be performed to ensure the ISR returns to the unblocked - * // task. In most FreeRTOS ports this is done by simply passing - * // xHigherPriorityTaskWoken into portYIELD_FROM_ISR(), which will test the - * // variables value, and perform the context switch if necessary. Check the - * // documentation for the port in use for port specific instructions. - * portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); + * // Attempt to send the string to the message buffer. + * xBytesSent = xMessageBufferSendFromISR( xMessageBuffer, + * ( void * ) pcStringToSend, + * strlen( pcStringToSend ), + * &xHigherPriorityTaskWoken ); + * + * if( xBytesSent != strlen( pcStringToSend ) ) + * { + * // The string could not be added to the message buffer because there was + * // not enough free space in the buffer. + * } + * + * // If xHigherPriorityTaskWoken was set to pdTRUE inside + * // xMessageBufferSendFromISR() then a task that has a priority above the + * // priority of the currently executing task was unblocked and a context + * // switch should be performed to ensure the ISR returns to the unblocked + * // task. In most FreeRTOS ports this is done by simply passing + * // xHigherPriorityTaskWoken into portYIELD_FROM_ISR(), which will test the + * // variables value, and perform the context switch if necessary. Check the + * // documentation for the port in use for port specific instructions. + * portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); * } * @endcode + * @cond + * \defgroup xMessageBufferSendFromISR xMessageBufferSendFromISR + * @endcond * \ingroup MessageBufferManagement */ -#define xMessageBufferSendFromISR( xMessageBuffer, pvTxData, xDataLengthBytes, pxHigherPriorityTaskWoken ) xStreamBufferSendFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pvTxData, xDataLengthBytes, pxHigherPriorityTaskWoken ) +#define xMessageBufferSendFromISR( xMessageBuffer, pvTxData, xDataLengthBytes, pxHigherPriorityTaskWoken ) \ + xStreamBufferSendFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pvTxData, xDataLengthBytes, pxHigherPriorityTaskWoken ) /** + * @cond + * message_buffer.h + * + * @code{c} + * size_t xMessageBufferReceive( MessageBufferHandle_t xMessageBuffer, + * void *pvRxData, + * size_t xBufferLengthBytes, + * TickType_t xTicksToWait ); + * @endcode + * @endcond + * * Receives a discrete message from a message buffer. Messages can be of * variable length and are copied out of the buffer. * @@ -434,27 +501,42 @@ typedef void * MessageBufferHandle_t; * size_t xReceivedBytes; * const TickType_t xBlockTime = pdMS_TO_TICKS( 20 ); * - * // Receive the next message from the message buffer. Wait in the Blocked - * // state (so not using any CPU processing time) for a maximum of 100ms for - * // a message to become available. - * xReceivedBytes = xMessageBufferReceive( xMessageBuffer, - * ( void * ) ucRxData, - * sizeof( ucRxData ), - * xBlockTime ); - * - * if( xReceivedBytes > 0 ) - * { - * // A ucRxData contains a message that is xReceivedBytes long. Process - * // the message here.... - * } + * // Receive the next message from the message buffer. Wait in the Blocked + * // state (so not using any CPU processing time) for a maximum of 100ms for + * // a message to become available. + * xReceivedBytes = xMessageBufferReceive( xMessageBuffer, + * ( void * ) ucRxData, + * sizeof( ucRxData ), + * xBlockTime ); + * + * if( xReceivedBytes > 0 ) + * { + * // A ucRxData contains a message that is xReceivedBytes long. Process + * // the message here.... + * } * } * @endcode + * @cond + * \defgroup xMessageBufferReceive xMessageBufferReceive + * @endcond * \ingroup MessageBufferManagement */ -#define xMessageBufferReceive( xMessageBuffer, pvRxData, xBufferLengthBytes, xTicksToWait ) xStreamBufferReceive( ( StreamBufferHandle_t ) xMessageBuffer, pvRxData, xBufferLengthBytes, xTicksToWait ) +#define xMessageBufferReceive( xMessageBuffer, pvRxData, xBufferLengthBytes, xTicksToWait ) \ + xStreamBufferReceive( ( StreamBufferHandle_t ) xMessageBuffer, pvRxData, xBufferLengthBytes, xTicksToWait ) /** + * @cond + * message_buffer.h + * + * @code{c} + * size_t xMessageBufferReceiveFromISR( MessageBufferHandle_t xMessageBuffer, + * void *pvRxData, + * size_t xBufferLengthBytes, + * BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * @endcond + * * An interrupt safe version of the API function that receives a discrete * message from a message buffer. Messages can be of variable length and are * copied out of the buffer. @@ -517,34 +599,46 @@ typedef void * MessageBufferHandle_t; * size_t xReceivedBytes; * BaseType_t xHigherPriorityTaskWoken = pdFALSE; // Initialised to pdFALSE. * - * // Receive the next message from the message buffer. - * xReceivedBytes = xMessageBufferReceiveFromISR( xMessageBuffer, - * ( void * ) ucRxData, - * sizeof( ucRxData ), - * &xHigherPriorityTaskWoken ); - * - * if( xReceivedBytes > 0 ) - * { - * // A ucRxData contains a message that is xReceivedBytes long. Process - * // the message here.... - * } - * - * // If xHigherPriorityTaskWoken was set to pdTRUE inside - * // xMessageBufferReceiveFromISR() then a task that has a priority above the - * // priority of the currently executing task was unblocked and a context - * // switch should be performed to ensure the ISR returns to the unblocked - * // task. In most FreeRTOS ports this is done by simply passing - * // xHigherPriorityTaskWoken into portYIELD_FROM_ISR(), which will test the - * // variables value, and perform the context switch if necessary. Check the - * // documentation for the port in use for port specific instructions. - * portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); + * // Receive the next message from the message buffer. + * xReceivedBytes = xMessageBufferReceiveFromISR( xMessageBuffer, + * ( void * ) ucRxData, + * sizeof( ucRxData ), + * &xHigherPriorityTaskWoken ); + * + * if( xReceivedBytes > 0 ) + * { + * // A ucRxData contains a message that is xReceivedBytes long. Process + * // the message here.... + * } + * + * // If xHigherPriorityTaskWoken was set to pdTRUE inside + * // xMessageBufferReceiveFromISR() then a task that has a priority above the + * // priority of the currently executing task was unblocked and a context + * // switch should be performed to ensure the ISR returns to the unblocked + * // task. In most FreeRTOS ports this is done by simply passing + * // xHigherPriorityTaskWoken into portYIELD_FROM_ISR(), which will test the + * // variables value, and perform the context switch if necessary. Check the + * // documentation for the port in use for port specific instructions. + * portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); * } * @endcode + * @cond + * \defgroup xMessageBufferReceiveFromISR xMessageBufferReceiveFromISR + * @endcond * \ingroup MessageBufferManagement */ -#define xMessageBufferReceiveFromISR( xMessageBuffer, pvRxData, xBufferLengthBytes, pxHigherPriorityTaskWoken ) xStreamBufferReceiveFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pvRxData, xBufferLengthBytes, pxHigherPriorityTaskWoken ) +#define xMessageBufferReceiveFromISR( xMessageBuffer, pvRxData, xBufferLengthBytes, pxHigherPriorityTaskWoken ) \ + xStreamBufferReceiveFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pvRxData, xBufferLengthBytes, pxHigherPriorityTaskWoken ) /** + * @cond + * message_buffer.h + * + * @code{c} + * void vMessageBufferDelete( MessageBufferHandle_t xMessageBuffer ); + * @endcode + * @endcond + * * Deletes a message buffer that was previously created using a call to * xMessageBufferCreate() or xMessageBufferCreateStatic(). If the message * buffer was created using dynamic memory (that is, by xMessageBufferCreate()), @@ -556,9 +650,17 @@ typedef void * MessageBufferHandle_t; * @param xMessageBuffer The handle of the message buffer to be deleted. * */ -#define vMessageBufferDelete( xMessageBuffer ) vStreamBufferDelete( ( StreamBufferHandle_t ) xMessageBuffer ) +#define vMessageBufferDelete( xMessageBuffer ) \ + vStreamBufferDelete( ( StreamBufferHandle_t ) xMessageBuffer ) /** + * @cond + * message_buffer.h + * @code{c} + * BaseType_t xMessageBufferIsFull( MessageBufferHandle_t xMessageBuffer ) ); + * @endcode + * @endcond + * * Tests to see if a message buffer is full. A message buffer is full if it * cannot accept any more messages, of any size, until space is made available * by a message being removed from the message buffer. @@ -568,9 +670,17 @@ typedef void * MessageBufferHandle_t; * @return If the message buffer referenced by xMessageBuffer is full then * pdTRUE is returned. Otherwise pdFALSE is returned. */ -#define xMessageBufferIsFull( xMessageBuffer ) xStreamBufferIsFull( ( StreamBufferHandle_t ) xMessageBuffer ) +#define xMessageBufferIsFull( xMessageBuffer ) \ + xStreamBufferIsFull( ( StreamBufferHandle_t ) xMessageBuffer ) /** + * @cond + * message_buffer.h + * @code{c} + * BaseType_t xMessageBufferIsEmpty( MessageBufferHandle_t xMessageBuffer ) ); + * @endcode + * @endcond + * * Tests to see if a message buffer is empty (does not contain any messages). * * @param xMessageBuffer The handle of the message buffer being queried. @@ -579,9 +689,17 @@ typedef void * MessageBufferHandle_t; * pdTRUE is returned. Otherwise pdFALSE is returned. * */ -#define xMessageBufferIsEmpty( xMessageBuffer ) xStreamBufferIsEmpty( ( StreamBufferHandle_t ) xMessageBuffer ) +#define xMessageBufferIsEmpty( xMessageBuffer ) \ + xStreamBufferIsEmpty( ( StreamBufferHandle_t ) xMessageBuffer ) /** + * @cond + * message_buffer.h + * @code{c} + * BaseType_t xMessageBufferReset( MessageBufferHandle_t xMessageBuffer ); + * @endcode + * @endcond + * * Resets a message buffer to its initial empty state, discarding any message it * contained. * @@ -594,12 +712,23 @@ typedef void * MessageBufferHandle_t; * the message queue to wait for space to become available, or to wait for a * a message to be available, then pdFAIL is returned. * + * @cond + * \defgroup xMessageBufferReset xMessageBufferReset + * @endcond * \ingroup MessageBufferManagement */ -#define xMessageBufferReset( xMessageBuffer ) xStreamBufferReset( ( StreamBufferHandle_t ) xMessageBuffer ) +#define xMessageBufferReset( xMessageBuffer ) \ + xStreamBufferReset( ( StreamBufferHandle_t ) xMessageBuffer ) /** + * @cond + * message_buffer.h + * @code{c} + * size_t xMessageBufferSpaceAvailable( MessageBufferHandle_t xMessageBuffer ) ); + * @endcode + * @endcond + * * Returns the number of bytes of free space in the message buffer. * * @param xMessageBuffer The handle of the message buffer being queried. @@ -611,12 +740,24 @@ typedef void * MessageBufferHandle_t; * architecture, so if xMessageBufferSpacesAvailable() returns 10, then the size * of the largest message that can be written to the message buffer is 6 bytes. * + * @cond + * \defgroup xMessageBufferSpaceAvailable xMessageBufferSpaceAvailable + * @endcond * \ingroup MessageBufferManagement */ -#define xMessageBufferSpaceAvailable( xMessageBuffer ) xStreamBufferSpacesAvailable( ( StreamBufferHandle_t ) xMessageBuffer ) -#define xMessageBufferSpacesAvailable( xMessageBuffer ) xStreamBufferSpacesAvailable( ( StreamBufferHandle_t ) xMessageBuffer ) /* Corrects typo in original macro name. */ +#define xMessageBufferSpaceAvailable( xMessageBuffer ) \ + xStreamBufferSpacesAvailable( ( StreamBufferHandle_t ) xMessageBuffer ) +#define xMessageBufferSpacesAvailable( xMessageBuffer ) \ + xStreamBufferSpacesAvailable( ( StreamBufferHandle_t ) xMessageBuffer ) /* Corrects typo in original macro name. */ /** + * @cond + * message_buffer.h + * @code{c} + * size_t xMessageBufferNextLengthBytes( MessageBufferHandle_t xMessageBuffer ) ); + * @endcode + * @endcond + * * Returns the length (in bytes) of the next message in a message buffer. * Useful if xMessageBufferReceive() returned 0 because the size of the buffer * passed into xMessageBufferReceive() was too small to hold the next message. @@ -626,11 +767,23 @@ typedef void * MessageBufferHandle_t; * @return The length (in bytes) of the next message in the message buffer, or 0 * if the message buffer is empty. * + * @cond + * \defgroup xMessageBufferNextLengthBytes xMessageBufferNextLengthBytes + * @endcond * \ingroup MessageBufferManagement */ -#define xMessageBufferNextLengthBytes( xMessageBuffer ) xStreamBufferNextMessageLengthBytes( ( StreamBufferHandle_t ) xMessageBuffer ) PRIVILEGED_FUNCTION; +#define xMessageBufferNextLengthBytes( xMessageBuffer ) \ + xStreamBufferNextMessageLengthBytes( ( StreamBufferHandle_t ) xMessageBuffer ) PRIVILEGED_FUNCTION; /** + * @cond + * message_buffer.h + * + * @code{c} + * BaseType_t xMessageBufferSendCompletedFromISR( MessageBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * @endcond + * * For advanced users only. * * The sbSEND_COMPLETED() macro is called from within the FreeRTOS APIs when @@ -658,11 +811,23 @@ typedef void * MessageBufferHandle_t; * @return If a task was removed from the Blocked state then pdTRUE is returned. * Otherwise pdFALSE is returned. * + * @cond + * \defgroup xMessageBufferSendCompletedFromISR xMessageBufferSendCompletedFromISR + * @endcond * \ingroup StreamBufferManagement */ -#define xMessageBufferSendCompletedFromISR( xMessageBuffer, pxHigherPriorityTaskWoken ) xStreamBufferSendCompletedFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pxHigherPriorityTaskWoken ) +#define xMessageBufferSendCompletedFromISR( xMessageBuffer, pxHigherPriorityTaskWoken ) \ + xStreamBufferSendCompletedFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pxHigherPriorityTaskWoken ) /** + * @cond + * message_buffer.h + * + * @code{c} + * BaseType_t xMessageBufferReceiveCompletedFromISR( MessageBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * @endcond + * * For advanced users only. * * The sbRECEIVE_COMPLETED() macro is called from within the FreeRTOS APIs when @@ -691,12 +856,18 @@ typedef void * MessageBufferHandle_t; * @return If a task was removed from the Blocked state then pdTRUE is returned. * Otherwise pdFALSE is returned. * + * @cond + * \defgroup xMessageBufferReceiveCompletedFromISR xMessageBufferReceiveCompletedFromISR + * @endcond * \ingroup StreamBufferManagement */ -#define xMessageBufferReceiveCompletedFromISR( xMessageBuffer, pxHigherPriorityTaskWoken ) xStreamBufferReceiveCompletedFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pxHigherPriorityTaskWoken ) +#define xMessageBufferReceiveCompletedFromISR( xMessageBuffer, pxHigherPriorityTaskWoken ) \ + xStreamBufferReceiveCompletedFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pxHigherPriorityTaskWoken ) +/* *INDENT-OFF* */ #if defined( __cplusplus ) -} /* extern "C" */ + } /* extern "C" */ #endif +/* *INDENT-ON* */ -#endif /* !defined( FREERTOS_MESSAGE_BUFFER_H ) */ +#endif /* !defined( FREERTOS_MESSAGE_BUFFER_H ) */ diff --git a/tools/sdk/esp32c3/include/freertos/include/freertos/mpu_prototypes.h b/tools/sdk/esp32c3/include/freertos/include/freertos/mpu_prototypes.h new file mode 100644 index 00000000000..ceb74f3e5bc --- /dev/null +++ b/tools/sdk/esp32c3/include/freertos/include/freertos/mpu_prototypes.h @@ -0,0 +1,257 @@ +/* + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * 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. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +/* + * When the MPU is used the standard (non MPU) API functions are mapped to + * equivalents that start "MPU_", the prototypes for which are defined in this + * header files. This will cause the application code to call the MPU_ version + * which wraps the non-MPU version with privilege promoting then demoting code, + * so the kernel code always runs will full privileges. + */ + + +#ifndef MPU_PROTOTYPES_H +#define MPU_PROTOTYPES_H + +/* MPU versions of tasks.h API functions. */ +BaseType_t MPU_xTaskCreate( TaskFunction_t pxTaskCode, + const char * const pcName, + const uint16_t usStackDepth, + void * const pvParameters, + UBaseType_t uxPriority, + TaskHandle_t * const pxCreatedTask ) FREERTOS_SYSTEM_CALL; +TaskHandle_t MPU_xTaskCreateStatic( 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 ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskDelete( TaskHandle_t xTaskToDelete ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskDelay( const TickType_t xTicksToDelay ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskDelayUntil( TickType_t * const pxPreviousWakeTime, + const TickType_t xTimeIncrement ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskAbortDelay( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxTaskPriorityGet( const TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +eTaskState MPU_eTaskGetState( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskGetInfo( TaskHandle_t xTask, + TaskStatus_t * pxTaskStatus, + BaseType_t xGetFreeStackSpace, + eTaskState eState ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskPrioritySet( TaskHandle_t xTask, + UBaseType_t uxNewPriority ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskSuspend( TaskHandle_t xTaskToSuspend ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskResume( TaskHandle_t xTaskToResume ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskStartScheduler( void ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskSuspendAll( void ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskResumeAll( void ) FREERTOS_SYSTEM_CALL; +TickType_t MPU_xTaskGetTickCount( void ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxTaskGetNumberOfTasks( void ) FREERTOS_SYSTEM_CALL; +char * MPU_pcTaskGetName( TaskHandle_t xTaskToQuery ) FREERTOS_SYSTEM_CALL; +TaskHandle_t MPU_xTaskGetHandle( const char * pcNameToQuery ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +configSTACK_DEPTH_TYPE MPU_uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskSetApplicationTaskTag( TaskHandle_t xTask, + TaskHookFunction_t pxHookFunction ) FREERTOS_SYSTEM_CALL; +TaskHookFunction_t MPU_xTaskGetApplicationTaskTag( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, + BaseType_t xIndex, + void * pvValue ) FREERTOS_SYSTEM_CALL; +void * MPU_pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, + BaseType_t xIndex ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask, + void * pvParameter ) FREERTOS_SYSTEM_CALL; +TaskHandle_t MPU_xTaskGetIdleTaskHandle( void ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, + const UBaseType_t uxArraySize, + uint32_t * const pulTotalRunTime ) FREERTOS_SYSTEM_CALL; +uint32_t MPU_ulTaskGetIdleRunTimeCounter( void ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskList( char * pcWriteBuffer ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskGetRunTimeStats( char * pcWriteBuffer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskGenericNotify( TaskHandle_t xTaskToNotify, + UBaseType_t uxIndexToNotify, + uint32_t ulValue, + eNotifyAction eAction, + uint32_t * pulPreviousNotificationValue ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskGenericNotifyWait( UBaseType_t uxIndexToWaitOn, + uint32_t ulBitsToClearOnEntry, + uint32_t ulBitsToClearOnExit, + uint32_t * pulNotificationValue, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +uint32_t MPU_ulTaskGenericNotifyTake( UBaseType_t uxIndexToWaitOn, + BaseType_t xClearCountOnExit, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskGenericNotifyStateClear( TaskHandle_t xTask, + UBaseType_t uxIndexToClear ) FREERTOS_SYSTEM_CALL; +uint32_t MPU_ulTaskGenericNotifyValueClear( TaskHandle_t xTask, + UBaseType_t uxIndexToClear, + uint32_t ulBitsToClear ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskIncrementTick( void ) FREERTOS_SYSTEM_CALL; +TaskHandle_t MPU_xTaskGetCurrentTaskHandle( void ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, + TickType_t * const pxTicksToWait ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskMissedYield( void ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskGetSchedulerState( void ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) FREERTOS_SYSTEM_CALL; + +/* MPU versions of queue.h API functions. */ +BaseType_t MPU_xQueueGenericSend( QueueHandle_t xQueue, + const void * const pvItemToQueue, + TickType_t xTicksToWait, + const BaseType_t xCopyPosition ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueReceive( QueueHandle_t xQueue, + void * const pvBuffer, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueuePeek( QueueHandle_t xQueue, + void * const pvBuffer, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueSemaphoreTake( QueueHandle_t xQueue, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxQueueMessagesWaiting( const QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxQueueSpacesAvailable( const QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; +void MPU_vQueueDelete( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; +QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType ) FREERTOS_SYSTEM_CALL; +QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType, + StaticQueue_t * pxStaticQueue ) FREERTOS_SYSTEM_CALL; +QueueHandle_t MPU_xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, + const UBaseType_t uxInitialCount ) FREERTOS_SYSTEM_CALL; +QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, + const UBaseType_t uxInitialCount, + StaticQueue_t * pxStaticQueue ) FREERTOS_SYSTEM_CALL; +TaskHandle_t MPU_xQueueGetMutexHolder( QueueHandle_t xSemaphore ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueTakeMutexRecursive( QueueHandle_t xMutex, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueGiveMutexRecursive( QueueHandle_t pxMutex ) FREERTOS_SYSTEM_CALL; +void MPU_vQueueAddToRegistry( QueueHandle_t xQueue, + const char * pcName ) FREERTOS_SYSTEM_CALL; +void MPU_vQueueUnregisterQueue( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; +const char * MPU_pcQueueGetName( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; +QueueHandle_t MPU_xQueueGenericCreate( const UBaseType_t uxQueueLength, + const UBaseType_t uxItemSize, + const uint8_t ucQueueType ) FREERTOS_SYSTEM_CALL; +QueueHandle_t MPU_xQueueGenericCreateStatic( const UBaseType_t uxQueueLength, + const UBaseType_t uxItemSize, + uint8_t * pucQueueStorage, + StaticQueue_t * pxStaticQueue, + const uint8_t ucQueueType ) FREERTOS_SYSTEM_CALL; +QueueSetHandle_t MPU_xQueueCreateSet( const UBaseType_t uxEventQueueLength ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, + QueueSetHandle_t xQueueSet ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, + QueueSetHandle_t xQueueSet ) FREERTOS_SYSTEM_CALL; +QueueSetMemberHandle_t MPU_xQueueSelectFromSet( QueueSetHandle_t xQueueSet, + const TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueGenericReset( QueueHandle_t xQueue, + BaseType_t xNewQueue ) FREERTOS_SYSTEM_CALL; +void MPU_vQueueSetQueueNumber( QueueHandle_t xQueue, + UBaseType_t uxQueueNumber ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxQueueGetQueueNumber( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; +uint8_t MPU_ucQueueGetQueueType( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; + +/* MPU versions of timers.h API functions. */ +TimerHandle_t MPU_xTimerCreate( const char * const pcTimerName, + const TickType_t xTimerPeriodInTicks, + const UBaseType_t uxAutoReload, + void * const pvTimerID, + TimerCallbackFunction_t pxCallbackFunction ) FREERTOS_SYSTEM_CALL; +TimerHandle_t MPU_xTimerCreateStatic( const char * const pcTimerName, + const TickType_t xTimerPeriodInTicks, + const UBaseType_t uxAutoReload, + void * const pvTimerID, + TimerCallbackFunction_t pxCallbackFunction, + StaticTimer_t * pxTimerBuffer ) FREERTOS_SYSTEM_CALL; +void * MPU_pvTimerGetTimerID( const TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL; +void MPU_vTimerSetTimerID( TimerHandle_t xTimer, + void * pvNewID ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTimerIsTimerActive( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL; +TaskHandle_t MPU_xTimerGetTimerDaemonTaskHandle( void ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, + void * pvParameter1, + uint32_t ulParameter2, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +const char * MPU_pcTimerGetName( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL; +void MPU_vTimerSetReloadMode( TimerHandle_t xTimer, + const UBaseType_t uxAutoReload ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxTimerGetReloadMode( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL; +TickType_t MPU_xTimerGetPeriod( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL; +TickType_t MPU_xTimerGetExpiryTime( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTimerCreateTimerTask( void ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTimerGenericCommand( TimerHandle_t xTimer, + const BaseType_t xCommandID, + const TickType_t xOptionalValue, + BaseType_t * const pxHigherPriorityTaskWoken, + const TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; + +/* MPU versions of event_group.h API functions. */ +EventGroupHandle_t MPU_xEventGroupCreate( void ) FREERTOS_SYSTEM_CALL; +EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t * pxEventGroupBuffer ) FREERTOS_SYSTEM_CALL; +EventBits_t MPU_xEventGroupWaitBits( EventGroupHandle_t xEventGroup, + const EventBits_t uxBitsToWaitFor, + const BaseType_t xClearOnExit, + const BaseType_t xWaitForAllBits, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +EventBits_t MPU_xEventGroupClearBits( EventGroupHandle_t xEventGroup, + const EventBits_t uxBitsToClear ) FREERTOS_SYSTEM_CALL; +EventBits_t MPU_xEventGroupSetBits( EventGroupHandle_t xEventGroup, + const EventBits_t uxBitsToSet ) FREERTOS_SYSTEM_CALL; +EventBits_t MPU_xEventGroupSync( EventGroupHandle_t xEventGroup, + const EventBits_t uxBitsToSet, + const EventBits_t uxBitsToWaitFor, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +void MPU_vEventGroupDelete( EventGroupHandle_t xEventGroup ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxEventGroupGetNumber( void * xEventGroup ) FREERTOS_SYSTEM_CALL; + +/* MPU versions of message/stream_buffer.h API functions. */ +size_t MPU_xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, + const void * pvTxData, + size_t xDataLengthBytes, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +size_t MPU_xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer, + void * pvRxData, + size_t xBufferLengthBytes, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +size_t MPU_xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +void MPU_vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +size_t MPU_xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +size_t MPU_xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, + size_t xTriggerLevel ) FREERTOS_SYSTEM_CALL; +StreamBufferHandle_t MPU_xStreamBufferGenericCreate( size_t xBufferSizeBytes, + size_t xTriggerLevelBytes, + BaseType_t xIsMessageBuffer ) FREERTOS_SYSTEM_CALL; +StreamBufferHandle_t MPU_xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes, + size_t xTriggerLevelBytes, + BaseType_t xIsMessageBuffer, + uint8_t * const pucStreamBufferStorageArea, + StaticStreamBuffer_t * const pxStaticStreamBuffer ) FREERTOS_SYSTEM_CALL; + + + +#endif /* MPU_PROTOTYPES_H */ diff --git a/tools/sdk/esp32c3/include/freertos/include/freertos/mpu_wrappers.h b/tools/sdk/esp32c3/include/freertos/include/freertos/mpu_wrappers.h index 7cbad5da080..c02dcd0c41e 100644 --- a/tools/sdk/esp32c3/include/freertos/include/freertos/mpu_wrappers.h +++ b/tools/sdk/esp32c3/include/freertos/include/freertos/mpu_wrappers.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,166 +19,165 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ #ifndef MPU_WRAPPERS_H #define MPU_WRAPPERS_H /* This file redefines API functions to be called through a wrapper macro, but -only for ports that are using the MPU. */ + * only for ports that are using the MPU. */ #if portUSING_MPU_WRAPPERS - /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE will be defined when this file is - included from queue.c or task.c to prevent it from having an effect within - those files. */ - #ifndef MPU_WRAPPERS_INCLUDED_FROM_API_FILE - - /* - * Map standard (non MPU) API functions to equivalents that start - * "MPU_". This will cause the application code to call the MPU_ - * version, which wraps the non-MPU version with privilege promoting - * then demoting code, so the kernel code always runs will full - * privileges. - */ - - /* Map standard tasks.h API functions to the MPU equivalents. */ - #define xTaskCreate MPU_xTaskCreate - #define xTaskCreateStatic MPU_xTaskCreateStatic - #define xTaskCreateRestricted MPU_xTaskCreateRestricted - #define vTaskAllocateMPURegions MPU_vTaskAllocateMPURegions - #define vTaskDelete MPU_vTaskDelete - #define vTaskDelay MPU_vTaskDelay - #define vTaskDelayUntil MPU_vTaskDelayUntil - #define xTaskAbortDelay MPU_xTaskAbortDelay - #define uxTaskPriorityGet MPU_uxTaskPriorityGet - #define eTaskGetState MPU_eTaskGetState - #define vTaskGetInfo MPU_vTaskGetInfo - #define vTaskPrioritySet MPU_vTaskPrioritySet - #define vTaskSuspend MPU_vTaskSuspend - #define vTaskResume MPU_vTaskResume - #define vTaskSuspendAll MPU_vTaskSuspendAll - #define xTaskResumeAll MPU_xTaskResumeAll - #define xTaskGetTickCount MPU_xTaskGetTickCount - #define uxTaskGetNumberOfTasks MPU_uxTaskGetNumberOfTasks - #define pcTaskGetName MPU_pcTaskGetName - #define xTaskGetHandle MPU_xTaskGetHandle - #define uxTaskGetStackHighWaterMark MPU_uxTaskGetStackHighWaterMark - #define uxTaskGetStackHighWaterMark2 MPU_uxTaskGetStackHighWaterMark2 - #define vTaskSetApplicationTaskTag MPU_vTaskSetApplicationTaskTag - #define xTaskGetApplicationTaskTag MPU_xTaskGetApplicationTaskTag - // #define vTaskSetThreadLocalStoragePointer MPU_vTaskSetThreadLocalStoragePointer - // #define pvTaskGetThreadLocalStoragePointer MPU_pvTaskGetThreadLocalStoragePointer - #define xTaskCallApplicationTaskHook MPU_xTaskCallApplicationTaskHook - #define xTaskGetIdleTaskHandle MPU_xTaskGetIdleTaskHandle - #define uxTaskGetSystemState MPU_uxTaskGetSystemState - #define vTaskList MPU_vTaskList - #define vTaskGetRunTimeStats MPU_vTaskGetRunTimeStats - #define ulTaskGetIdleRunTimeCounter MPU_ulTaskGetIdleRunTimeCounter - #define xTaskGenericNotify MPU_xTaskGenericNotify - #define xTaskNotifyWait MPU_xTaskNotifyWait - #define ulTaskNotifyTake MPU_ulTaskNotifyTake - #define xTaskNotifyStateClear MPU_xTaskNotifyStateClear - #define xTaskCatchUpTicks MPU_xTaskCatchUpTicks - - #define xTaskGetCurrentTaskHandle MPU_xTaskGetCurrentTaskHandle - #define vTaskSetTimeOutState MPU_vTaskSetTimeOutState - #define xTaskCheckForTimeOut MPU_xTaskCheckForTimeOut - #define xTaskGetSchedulerState MPU_xTaskGetSchedulerState - - /* Map standard queue.h API functions to the MPU equivalents. */ - #define xQueueGenericSend MPU_xQueueGenericSend - #define xQueueReceive MPU_xQueueReceive - #define xQueuePeek MPU_xQueuePeek - #define xQueueSemaphoreTake MPU_xQueueSemaphoreTake - #define uxQueueMessagesWaiting MPU_uxQueueMessagesWaiting - #define uxQueueSpacesAvailable MPU_uxQueueSpacesAvailable - #define vQueueDelete MPU_vQueueDelete - #define xQueueCreateMutex MPU_xQueueCreateMutex - #define xQueueCreateMutexStatic MPU_xQueueCreateMutexStatic - #define xQueueCreateCountingSemaphore MPU_xQueueCreateCountingSemaphore - #define xQueueCreateCountingSemaphoreStatic MPU_xQueueCreateCountingSemaphoreStatic - #define xQueueGetMutexHolder MPU_xQueueGetMutexHolder - #define xQueueTakeMutexRecursive MPU_xQueueTakeMutexRecursive - #define xQueueGiveMutexRecursive MPU_xQueueGiveMutexRecursive - #define xQueueGenericCreate MPU_xQueueGenericCreate - #define xQueueGenericCreateStatic MPU_xQueueGenericCreateStatic - #define xQueueCreateSet MPU_xQueueCreateSet - #define xQueueAddToSet MPU_xQueueAddToSet - #define xQueueRemoveFromSet MPU_xQueueRemoveFromSet - #define xQueueSelectFromSet MPU_xQueueSelectFromSet - #define xQueueGenericReset MPU_xQueueGenericReset - - #if( configQUEUE_REGISTRY_SIZE > 0 ) - #define vQueueAddToRegistry MPU_vQueueAddToRegistry - #define vQueueUnregisterQueue MPU_vQueueUnregisterQueue - #define pcQueueGetName MPU_pcQueueGetName - #endif - - /* Map standard timer.h API functions to the MPU equivalents. */ - #define xTimerCreate MPU_xTimerCreate - #define xTimerCreateStatic MPU_xTimerCreateStatic - #define pvTimerGetTimerID MPU_pvTimerGetTimerID - #define vTimerSetTimerID MPU_vTimerSetTimerID - #define xTimerIsTimerActive MPU_xTimerIsTimerActive - #define xTimerGetTimerDaemonTaskHandle MPU_xTimerGetTimerDaemonTaskHandle - #define xTimerPendFunctionCall MPU_xTimerPendFunctionCall - #define pcTimerGetName MPU_pcTimerGetName - #define vTimerSetReloadMode MPU_vTimerSetReloadMode - #define xTimerGetPeriod MPU_xTimerGetPeriod - #define xTimerGetExpiryTime MPU_xTimerGetExpiryTime - #define xTimerGenericCommand MPU_xTimerGenericCommand - - /* Map standard event_group.h API functions to the MPU equivalents. */ - #define xEventGroupCreate MPU_xEventGroupCreate - #define xEventGroupCreateStatic MPU_xEventGroupCreateStatic - #define xEventGroupWaitBits MPU_xEventGroupWaitBits - #define xEventGroupClearBits MPU_xEventGroupClearBits - #define xEventGroupSetBits MPU_xEventGroupSetBits - #define xEventGroupSync MPU_xEventGroupSync - #define vEventGroupDelete MPU_vEventGroupDelete - - /* Map standard message/stream_buffer.h API functions to the MPU - equivalents. */ - #define xStreamBufferSend MPU_xStreamBufferSend - #define xStreamBufferReceive MPU_xStreamBufferReceive - #define xStreamBufferNextMessageLengthBytes MPU_xStreamBufferNextMessageLengthBytes - #define vStreamBufferDelete MPU_vStreamBufferDelete - #define xStreamBufferIsFull MPU_xStreamBufferIsFull - #define xStreamBufferIsEmpty MPU_xStreamBufferIsEmpty - #define xStreamBufferReset MPU_xStreamBufferReset - #define xStreamBufferSpacesAvailable MPU_xStreamBufferSpacesAvailable - #define xStreamBufferBytesAvailable MPU_xStreamBufferBytesAvailable - #define xStreamBufferSetTriggerLevel MPU_xStreamBufferSetTriggerLevel - #define xStreamBufferGenericCreate MPU_xStreamBufferGenericCreate - #define xStreamBufferGenericCreateStatic MPU_xStreamBufferGenericCreateStatic - - - /* Remove the privileged function macro, but keep the PRIVILEGED_DATA - macro so applications can place data in privileged access sections - (useful when using statically allocated objects). */ - #define PRIVILEGED_FUNCTION - #define PRIVILEGED_DATA __attribute__((section("privileged_data"))) - #define FREERTOS_SYSTEM_CALL - - #else /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */ - - /* Ensure API functions go in the privileged execution section. */ - #define PRIVILEGED_FUNCTION __attribute__((section("privileged_functions"))) - #define PRIVILEGED_DATA __attribute__((section("privileged_data"))) - #define FREERTOS_SYSTEM_CALL __attribute__((section( "freertos_system_calls"))) - - #endif /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */ +/* MPU_WRAPPERS_INCLUDED_FROM_API_FILE will be defined when this file is + * included from queue.c or task.c to prevent it from having an effect within + * those files. */ + #ifndef MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/* + * Map standard (non MPU) API functions to equivalents that start + * "MPU_". This will cause the application code to call the MPU_ + * version, which wraps the non-MPU version with privilege promoting + * then demoting code, so the kernel code always runs will full + * privileges. + */ + +/* Map standard tasks.h API functions to the MPU equivalents. */ + #define xTaskCreate MPU_xTaskCreate + #define xTaskCreateStatic MPU_xTaskCreateStatic + #define xTaskCreateRestricted MPU_xTaskCreateRestricted + #define vTaskAllocateMPURegions MPU_vTaskAllocateMPURegions + #define vTaskDelete MPU_vTaskDelete + #define vTaskDelay MPU_vTaskDelay + #define vTaskDelayUntil MPU_vTaskDelayUntil + #define xTaskAbortDelay MPU_xTaskAbortDelay + #define uxTaskPriorityGet MPU_uxTaskPriorityGet + #define eTaskGetState MPU_eTaskGetState + #define vTaskGetInfo MPU_vTaskGetInfo + #define vTaskPrioritySet MPU_vTaskPrioritySet + #define vTaskSuspend MPU_vTaskSuspend + #define vTaskResume MPU_vTaskResume + #define vTaskSuspendAll MPU_vTaskSuspendAll + #define xTaskResumeAll MPU_xTaskResumeAll + #define xTaskGetTickCount MPU_xTaskGetTickCount + #define uxTaskGetNumberOfTasks MPU_uxTaskGetNumberOfTasks + #define pcTaskGetName MPU_pcTaskGetName + #define xTaskGetHandle MPU_xTaskGetHandle + #define uxTaskGetStackHighWaterMark MPU_uxTaskGetStackHighWaterMark + #define uxTaskGetStackHighWaterMark2 MPU_uxTaskGetStackHighWaterMark2 + #define vTaskSetApplicationTaskTag MPU_vTaskSetApplicationTaskTag + #define xTaskGetApplicationTaskTag MPU_xTaskGetApplicationTaskTag + // #define vTaskSetThreadLocalStoragePointer MPU_vTaskSetThreadLocalStoragePointer + // #define pvTaskGetThreadLocalStoragePointer MPU_pvTaskGetThreadLocalStoragePointer + #define xTaskCallApplicationTaskHook MPU_xTaskCallApplicationTaskHook + #define xTaskGetIdleTaskHandle MPU_xTaskGetIdleTaskHandle + #define uxTaskGetSystemState MPU_uxTaskGetSystemState + #define vTaskList MPU_vTaskList + #define vTaskGetRunTimeStats MPU_vTaskGetRunTimeStats + #define ulTaskGetIdleRunTimeCounter MPU_ulTaskGetIdleRunTimeCounter + #define xTaskGenericNotify MPU_xTaskGenericNotify + #define xTaskNotifyWait MPU_xTaskNotifyWait + #define ulTaskNotifyTake MPU_ulTaskNotifyTake + #define xTaskNotifyStateClear MPU_xTaskNotifyStateClear + #define xTaskCatchUpTicks MPU_xTaskCatchUpTicks + + #define xTaskGetCurrentTaskHandle MPU_xTaskGetCurrentTaskHandle + #define vTaskSetTimeOutState MPU_vTaskSetTimeOutState + #define xTaskCheckForTimeOut MPU_xTaskCheckForTimeOut + #define xTaskGetSchedulerState MPU_xTaskGetSchedulerState + + /* Map standard queue.h API functions to the MPU equivalents. */ + #define xQueueGenericSend MPU_xQueueGenericSend + #define xQueueReceive MPU_xQueueReceive + #define xQueuePeek MPU_xQueuePeek + #define xQueueSemaphoreTake MPU_xQueueSemaphoreTake + #define uxQueueMessagesWaiting MPU_uxQueueMessagesWaiting + #define uxQueueSpacesAvailable MPU_uxQueueSpacesAvailable + #define vQueueDelete MPU_vQueueDelete + #define xQueueCreateMutex MPU_xQueueCreateMutex + #define xQueueCreateMutexStatic MPU_xQueueCreateMutexStatic + #define xQueueCreateCountingSemaphore MPU_xQueueCreateCountingSemaphore + #define xQueueCreateCountingSemaphoreStatic MPU_xQueueCreateCountingSemaphoreStatic + #define xQueueGetMutexHolder MPU_xQueueGetMutexHolder + #define xQueueTakeMutexRecursive MPU_xQueueTakeMutexRecursive + #define xQueueGiveMutexRecursive MPU_xQueueGiveMutexRecursive + #define xQueueGenericCreate MPU_xQueueGenericCreate + #define xQueueGenericCreateStatic MPU_xQueueGenericCreateStatic + #define xQueueCreateSet MPU_xQueueCreateSet + #define xQueueAddToSet MPU_xQueueAddToSet + #define xQueueRemoveFromSet MPU_xQueueRemoveFromSet + #define xQueueSelectFromSet MPU_xQueueSelectFromSet + #define xQueueGenericReset MPU_xQueueGenericReset + + #if ( configQUEUE_REGISTRY_SIZE > 0 ) + #define vQueueAddToRegistry MPU_vQueueAddToRegistry + #define vQueueUnregisterQueue MPU_vQueueUnregisterQueue + #define pcQueueGetName MPU_pcQueueGetName + #endif + +/* Map standard timer.h API functions to the MPU equivalents. */ + #define xTimerCreate MPU_xTimerCreate + #define xTimerCreateStatic MPU_xTimerCreateStatic + #define pvTimerGetTimerID MPU_pvTimerGetTimerID + #define vTimerSetTimerID MPU_vTimerSetTimerID + #define xTimerIsTimerActive MPU_xTimerIsTimerActive + #define xTimerGetTimerDaemonTaskHandle MPU_xTimerGetTimerDaemonTaskHandle + #define xTimerPendFunctionCall MPU_xTimerPendFunctionCall + #define pcTimerGetName MPU_pcTimerGetName + #define vTimerSetReloadMode MPU_vTimerSetReloadMode + #define xTimerGetPeriod MPU_xTimerGetPeriod + #define xTimerGetExpiryTime MPU_xTimerGetExpiryTime + #define xTimerGenericCommand MPU_xTimerGenericCommand + +/* Map standard event_group.h API functions to the MPU equivalents. */ + #define xEventGroupCreate MPU_xEventGroupCreate + #define xEventGroupCreateStatic MPU_xEventGroupCreateStatic + #define xEventGroupWaitBits MPU_xEventGroupWaitBits + #define xEventGroupClearBits MPU_xEventGroupClearBits + #define xEventGroupSetBits MPU_xEventGroupSetBits + #define xEventGroupSync MPU_xEventGroupSync + #define vEventGroupDelete MPU_vEventGroupDelete + +/* Map standard message/stream_buffer.h API functions to the MPU + * equivalents. */ + #define xStreamBufferSend MPU_xStreamBufferSend + #define xStreamBufferReceive MPU_xStreamBufferReceive + #define xStreamBufferNextMessageLengthBytes MPU_xStreamBufferNextMessageLengthBytes + #define vStreamBufferDelete MPU_vStreamBufferDelete + #define xStreamBufferIsFull MPU_xStreamBufferIsFull + #define xStreamBufferIsEmpty MPU_xStreamBufferIsEmpty + #define xStreamBufferReset MPU_xStreamBufferReset + #define xStreamBufferSpacesAvailable MPU_xStreamBufferSpacesAvailable + #define xStreamBufferBytesAvailable MPU_xStreamBufferBytesAvailable + #define xStreamBufferSetTriggerLevel MPU_xStreamBufferSetTriggerLevel + #define xStreamBufferGenericCreate MPU_xStreamBufferGenericCreate + #define xStreamBufferGenericCreateStatic MPU_xStreamBufferGenericCreateStatic + + +/* Remove the privileged function macro, but keep the PRIVILEGED_DATA + * macro so applications can place data in privileged access sections + * (useful when using statically allocated objects). */ + #define PRIVILEGED_FUNCTION + #define PRIVILEGED_DATA __attribute__( ( section( "privileged_data" ) ) ) + #define FREERTOS_SYSTEM_CALL + + #else /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */ + +/* Ensure API functions go in the privileged execution section. */ + #define PRIVILEGED_FUNCTION __attribute__( ( section( "privileged_functions" ) ) ) + #define PRIVILEGED_DATA __attribute__( ( section( "privileged_data" ) ) ) + #define FREERTOS_SYSTEM_CALL __attribute__( ( section( "freertos_system_calls" ) ) ) + + #endif /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */ #else /* portUSING_MPU_WRAPPERS */ - #define PRIVILEGED_FUNCTION - #define PRIVILEGED_DATA - #define FREERTOS_SYSTEM_CALL - #define portUSING_MPU_WRAPPERS 0 + #define PRIVILEGED_FUNCTION + #define PRIVILEGED_DATA + #define FREERTOS_SYSTEM_CALL + #define portUSING_MPU_WRAPPERS 0 #endif /* portUSING_MPU_WRAPPERS */ diff --git a/tools/sdk/esp32c3/include/freertos/include/freertos/portable.h b/tools/sdk/esp32c3/include/freertos/include/freertos/portable.h index 0c39bb9f6d8..acc337cb968 100644 --- a/tools/sdk/esp32c3/include/freertos/include/freertos/portable.h +++ b/tools/sdk/esp32c3/include/freertos/include/freertos/portable.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ /*----------------------------------------------------------- @@ -33,68 +32,70 @@ #define PORTABLE_H /* Each FreeRTOS port has a unique portmacro.h header file. Originally a -pre-processor definition was used to ensure the pre-processor found the correct -portmacro.h file for the port being used. That scheme was deprecated in favour -of setting the compiler's include path such that it found the correct -portmacro.h file - removing the need for the constant and allowing the -portmacro.h file to be located anywhere in relation to the port being used. -Purely for reasons of backward compatibility the old method is still valid, but -to make it clear that new projects should not use it, support for the port -specific constants has been moved into the deprecated_definitions.h header -file. */ + * pre-processor definition was used to ensure the pre-processor found the correct + * portmacro.h file for the port being used. That scheme was deprecated in favour + * of setting the compiler's include path such that it found the correct + * portmacro.h file - removing the need for the constant and allowing the + * portmacro.h file to be located anywhere in relation to the port being used. + * Purely for reasons of backward compatibility the old method is still valid, but + * to make it clear that new projects should not use it, support for the port + * specific constants has been moved into the deprecated_definitions.h header + * file. */ #include "deprecated_definitions.h" /* If portENTER_CRITICAL is not defined then including deprecated_definitions.h -did not result in a portmacro.h header file being included - and it should be -included here. In this case the path to the correct portmacro.h header file -must be set in the compiler's include path. */ + * did not result in a portmacro.h header file being included - and it should be + * included here. In this case the path to the correct portmacro.h header file + * must be set in the compiler's include path. */ #ifndef portENTER_CRITICAL - #include "freertos/portmacro.h" + #include "freertos/portmacro.h" #endif #if portBYTE_ALIGNMENT == 32 - #define portBYTE_ALIGNMENT_MASK ( 0x001f ) + #define portBYTE_ALIGNMENT_MASK ( 0x001f ) #endif #if portBYTE_ALIGNMENT == 16 - #define portBYTE_ALIGNMENT_MASK ( 0x000f ) + #define portBYTE_ALIGNMENT_MASK ( 0x000f ) #endif #if portBYTE_ALIGNMENT == 8 - #define portBYTE_ALIGNMENT_MASK ( 0x0007 ) + #define portBYTE_ALIGNMENT_MASK ( 0x0007 ) #endif #if portBYTE_ALIGNMENT == 4 - #define portBYTE_ALIGNMENT_MASK ( 0x0003 ) + #define portBYTE_ALIGNMENT_MASK ( 0x0003 ) #endif #if portBYTE_ALIGNMENT == 2 - #define portBYTE_ALIGNMENT_MASK ( 0x0001 ) + #define portBYTE_ALIGNMENT_MASK ( 0x0001 ) #endif #if portBYTE_ALIGNMENT == 1 - #define portBYTE_ALIGNMENT_MASK ( 0x0000 ) + #define portBYTE_ALIGNMENT_MASK ( 0x0000 ) #endif #ifndef portBYTE_ALIGNMENT_MASK - #error "Invalid portBYTE_ALIGNMENT definition" + #error "Invalid portBYTE_ALIGNMENT definition" #endif #ifndef portNUM_CONFIGURABLE_REGIONS - #define portNUM_CONFIGURABLE_REGIONS 1 + #define portNUM_CONFIGURABLE_REGIONS 1 #endif #ifndef portHAS_STACK_OVERFLOW_CHECKING - #define portHAS_STACK_OVERFLOW_CHECKING 0 + #define portHAS_STACK_OVERFLOW_CHECKING 0 #endif #ifndef portARCH_NAME - #define portARCH_NAME NULL + #define portARCH_NAME NULL #endif +/* *INDENT-OFF* */ #ifdef __cplusplus -extern "C" { + extern "C" { #endif +/* *INDENT-ON* */ #include "mpu_wrappers.h" @@ -104,40 +105,52 @@ extern "C" { * the order that the port expects to find them. * */ -#if( portUSING_MPU_WRAPPERS == 1 ) - #if( portHAS_STACK_OVERFLOW_CHECKING == 1 ) - StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; - #else - StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; - #endif -#else - #if( portHAS_STACK_OVERFLOW_CHECKING == 1 ) - StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters ) PRIVILEGED_FUNCTION; - #else - StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) PRIVILEGED_FUNCTION; - #endif +#if ( portUSING_MPU_WRAPPERS == 1 ) + #if ( portHAS_STACK_OVERFLOW_CHECKING == 1 ) + StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, + StackType_t * pxEndOfStack, + TaskFunction_t pxCode, + void * pvParameters, + BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; + #else + StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, + TaskFunction_t pxCode, + void * pvParameters, + BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; + #endif +#else /* if ( portUSING_MPU_WRAPPERS == 1 ) */ + #if ( portHAS_STACK_OVERFLOW_CHECKING == 1 ) + StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, + StackType_t * pxEndOfStack, + TaskFunction_t pxCode, + void * pvParameters ) PRIVILEGED_FUNCTION; + #else + StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, + TaskFunction_t pxCode, + void * pvParameters ) PRIVILEGED_FUNCTION; + #endif #endif #ifdef configUSE_FREERTOS_PROVIDED_HEAP /* Used by heap_5.c to define the start address and size of each memory region -that together comprise the total FreeRTOS heap space. */ + * that together comprise the total FreeRTOS heap space. */ typedef struct HeapRegion { - uint8_t *pucStartAddress; - size_t xSizeInBytes; + uint8_t * pucStartAddress; + size_t xSizeInBytes; } HeapRegion_t; /* Used to pass information about the heap out of vPortGetHeapStats(). */ typedef struct xHeapStats { - size_t xAvailableHeapSpaceInBytes; /* The total heap size currently available - this is the sum of all the free blocks, not the largest block that can be allocated. */ - size_t xSizeOfLargestFreeBlockInBytes; /* The maximum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */ - size_t xSizeOfSmallestFreeBlockInBytes; /* The minimum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */ - size_t xNumberOfFreeBlocks; /* The number of free memory blocks within the heap at the time vPortGetHeapStats() is called. */ - size_t xMinimumEverFreeBytesRemaining; /* The minimum amount of total free memory (sum of all free blocks) there has been in the heap since the system booted. */ - size_t xNumberOfSuccessfulAllocations; /* The number of calls to pvPortMalloc() that have returned a valid memory block. */ - size_t xNumberOfSuccessfulFrees; /* The number of calls to vPortFree() that has successfully freed a block of memory. */ + size_t xAvailableHeapSpaceInBytes; /* The total heap size currently available - this is the sum of all the free blocks, not the largest block that can be allocated. */ + size_t xSizeOfLargestFreeBlockInBytes; /* The maximum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */ + size_t xSizeOfSmallestFreeBlockInBytes; /* The minimum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */ + size_t xNumberOfFreeBlocks; /* The number of free memory blocks within the heap at the time vPortGetHeapStats() is called. */ + size_t xMinimumEverFreeBytesRemaining; /* The minimum amount of total free memory (sum of all free blocks) there has been in the heap since the system booted. */ + size_t xNumberOfSuccessfulAllocations; /* The number of calls to pvPortMalloc() that have returned a valid memory block. */ + size_t xNumberOfSuccessfulFrees; /* The number of calls to vPortFree() that has successfully freed a block of memory. */ } HeapStats_t; /* @@ -157,16 +170,24 @@ void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) PRIVILEG * Returns a HeapStats_t structure filled with information about the current * heap state. */ -void vPortGetHeapStats( HeapStats_t *pxHeapStats ); +void vPortGetHeapStats( HeapStats_t * pxHeapStats ); + /* * Map to the memory management routines required for the port. */ -void *pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION; -void vPortFree( void *pv ) PRIVILEGED_FUNCTION; +void * pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION; +void vPortFree( void * pv ) PRIVILEGED_FUNCTION; void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION; size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION; size_t xPortGetMinimumEverFreeHeapSize( void ) PRIVILEGED_FUNCTION; +#if( configSTACK_ALLOCATION_FROM_SEPARATE_HEAP == 1 ) + void *pvPortMallocStack( size_t xSize ) PRIVILEGED_FUNCTION; + void vPortFreeStack( void *pv ) PRIVILEGED_FUNCTION; +#else + #define pvPortMallocStack pvPortMalloc + #define vPortFreeStack vPortFree +#endif #else // configUSE_FREERTOS_PROVIDED_HEAP /* @@ -196,8 +217,25 @@ BaseType_t xPortStartScheduler( void ) PRIVILEGED_FUNCTION; */ void vPortEndScheduler( void ) PRIVILEGED_FUNCTION; +/* + * The structures and methods of manipulating the MPU are contained within the + * port layer. + * + * Fills the xMPUSettings structure with the memory region information + * contained in xRegions. + */ +#if ( portUSING_MPU_WRAPPERS == 1 ) + struct xMEMORY_REGION; + void vPortStoreTaskMPUSettings( xMPU_SETTINGS * xMPUSettings, + const struct xMEMORY_REGION * const xRegions, + StackType_t * pxBottomOfStack, + uint32_t ulStackDepth ) PRIVILEGED_FUNCTION; +#endif + +/* *INDENT-OFF* */ #ifdef __cplusplus -} + } #endif +/* *INDENT-ON* */ #endif /* PORTABLE_H */ diff --git a/tools/sdk/esp32c3/include/freertos/include/freertos/projdefs.h b/tools/sdk/esp32c3/include/freertos/include/freertos/projdefs.h index ce647fb6fb1..ec8022ca0b0 100644 --- a/tools/sdk/esp32c3/include/freertos/include/freertos/projdefs.h +++ b/tools/sdk/esp32c3/include/freertos/include/freertos/projdefs.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ #ifndef PROJDEFS_H @@ -32,95 +31,95 @@ * Defines the prototype to which task functions must conform. Defined in this * file to ensure the type is known before portable.h is included. */ -typedef void (*TaskFunction_t)( void * ); +typedef void (* TaskFunction_t)( void * ); /* Converts a time in milliseconds to a time in ticks. This macro can be -overridden by a macro of the same name defined in FreeRTOSConfig.h in case the -definition here is not suitable for your application. */ + * overridden by a macro of the same name defined in FreeRTOSConfig.h in case the + * definition here is not suitable for your application. */ #ifndef pdMS_TO_TICKS - #define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000 ) ) + #define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000U ) ) #endif - +#ifdef ESP_PLATFORM #ifndef pdTICKS_TO_MS - #define pdTICKS_TO_MS( xTicks ) ( ( uint32_t ) ( xTicks ) * 1000 / configTICK_RATE_HZ ) + #define pdTICKS_TO_MS( xTicks ) ( ( uint32_t ) ( xTicks ) * 1000 / configTICK_RATE_HZ ) #endif +#endif // ESP_PLATFORM +#define pdFALSE ( ( BaseType_t ) 0 ) +#define pdTRUE ( ( BaseType_t ) 1 ) -#define pdFALSE ( ( BaseType_t ) 0 ) -#define pdTRUE ( ( BaseType_t ) 1 ) - -#define pdPASS ( pdTRUE ) -#define pdFAIL ( pdFALSE ) -#define errQUEUE_EMPTY ( ( BaseType_t ) 0 ) -#define errQUEUE_FULL ( ( BaseType_t ) 0 ) +#define pdPASS ( pdTRUE ) +#define pdFAIL ( pdFALSE ) +#define errQUEUE_EMPTY ( ( BaseType_t ) 0 ) +#define errQUEUE_FULL ( ( BaseType_t ) 0 ) /* FreeRTOS error definitions. */ -#define errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY ( -1 ) -#define errQUEUE_BLOCKED ( -4 ) -#define errQUEUE_YIELD ( -5 ) +#define errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY ( -1 ) +#define errQUEUE_BLOCKED ( -4 ) +#define errQUEUE_YIELD ( -5 ) /* Macros used for basic data corruption checks. */ #ifndef configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES - #define configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 0 + #define configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 0 #endif -#if( configUSE_16_BIT_TICKS == 1 ) - #define pdINTEGRITY_CHECK_VALUE 0x5a5a +#if ( configUSE_16_BIT_TICKS == 1 ) + #define pdINTEGRITY_CHECK_VALUE 0x5a5a #else - #define pdINTEGRITY_CHECK_VALUE 0x5a5a5a5aUL + #define pdINTEGRITY_CHECK_VALUE 0x5a5a5a5aUL #endif /* The following errno values are used by FreeRTOS+ components, not FreeRTOS -itself. */ -#define pdFREERTOS_ERRNO_NONE 0 /* No errors */ -#define pdFREERTOS_ERRNO_ENOENT 2 /* No such file or directory */ -#define pdFREERTOS_ERRNO_EINTR 4 /* Interrupted system call */ -#define pdFREERTOS_ERRNO_EIO 5 /* I/O error */ -#define pdFREERTOS_ERRNO_ENXIO 6 /* No such device or address */ -#define pdFREERTOS_ERRNO_EBADF 9 /* Bad file number */ -#define pdFREERTOS_ERRNO_EAGAIN 11 /* No more processes */ -#define pdFREERTOS_ERRNO_EWOULDBLOCK 11 /* Operation would block */ -#define pdFREERTOS_ERRNO_ENOMEM 12 /* Not enough memory */ -#define pdFREERTOS_ERRNO_EACCES 13 /* Permission denied */ -#define pdFREERTOS_ERRNO_EFAULT 14 /* Bad address */ -#define pdFREERTOS_ERRNO_EBUSY 16 /* Mount device busy */ -#define pdFREERTOS_ERRNO_EEXIST 17 /* File exists */ -#define pdFREERTOS_ERRNO_EXDEV 18 /* Cross-device link */ -#define pdFREERTOS_ERRNO_ENODEV 19 /* No such device */ -#define pdFREERTOS_ERRNO_ENOTDIR 20 /* Not a directory */ -#define pdFREERTOS_ERRNO_EISDIR 21 /* Is a directory */ -#define pdFREERTOS_ERRNO_EINVAL 22 /* Invalid argument */ -#define pdFREERTOS_ERRNO_ENOSPC 28 /* No space left on device */ -#define pdFREERTOS_ERRNO_ESPIPE 29 /* Illegal seek */ -#define pdFREERTOS_ERRNO_EROFS 30 /* Read only file system */ -#define pdFREERTOS_ERRNO_EUNATCH 42 /* Protocol driver not attached */ -#define pdFREERTOS_ERRNO_EBADE 50 /* Invalid exchange */ -#define pdFREERTOS_ERRNO_EFTYPE 79 /* Inappropriate file type or format */ -#define pdFREERTOS_ERRNO_ENMFILE 89 /* No more files */ -#define pdFREERTOS_ERRNO_ENOTEMPTY 90 /* Directory not empty */ -#define pdFREERTOS_ERRNO_ENAMETOOLONG 91 /* File or path name too long */ -#define pdFREERTOS_ERRNO_EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ -#define pdFREERTOS_ERRNO_ENOBUFS 105 /* No buffer space available */ -#define pdFREERTOS_ERRNO_ENOPROTOOPT 109 /* Protocol not available */ -#define pdFREERTOS_ERRNO_EADDRINUSE 112 /* Address already in use */ -#define pdFREERTOS_ERRNO_ETIMEDOUT 116 /* Connection timed out */ -#define pdFREERTOS_ERRNO_EINPROGRESS 119 /* Connection already in progress */ -#define pdFREERTOS_ERRNO_EALREADY 120 /* Socket already connected */ -#define pdFREERTOS_ERRNO_EADDRNOTAVAIL 125 /* Address not available */ -#define pdFREERTOS_ERRNO_EISCONN 127 /* Socket is already connected */ -#define pdFREERTOS_ERRNO_ENOTCONN 128 /* Socket is not connected */ -#define pdFREERTOS_ERRNO_ENOMEDIUM 135 /* No medium inserted */ -#define pdFREERTOS_ERRNO_EILSEQ 138 /* An invalid UTF-16 sequence was encountered. */ -#define pdFREERTOS_ERRNO_ECANCELED 140 /* Operation canceled. */ + * itself. */ +#define pdFREERTOS_ERRNO_NONE 0 /* No errors */ +#define pdFREERTOS_ERRNO_ENOENT 2 /* No such file or directory */ +#define pdFREERTOS_ERRNO_EINTR 4 /* Interrupted system call */ +#define pdFREERTOS_ERRNO_EIO 5 /* I/O error */ +#define pdFREERTOS_ERRNO_ENXIO 6 /* No such device or address */ +#define pdFREERTOS_ERRNO_EBADF 9 /* Bad file number */ +#define pdFREERTOS_ERRNO_EAGAIN 11 /* No more processes */ +#define pdFREERTOS_ERRNO_EWOULDBLOCK 11 /* Operation would block */ +#define pdFREERTOS_ERRNO_ENOMEM 12 /* Not enough memory */ +#define pdFREERTOS_ERRNO_EACCES 13 /* Permission denied */ +#define pdFREERTOS_ERRNO_EFAULT 14 /* Bad address */ +#define pdFREERTOS_ERRNO_EBUSY 16 /* Mount device busy */ +#define pdFREERTOS_ERRNO_EEXIST 17 /* File exists */ +#define pdFREERTOS_ERRNO_EXDEV 18 /* Cross-device link */ +#define pdFREERTOS_ERRNO_ENODEV 19 /* No such device */ +#define pdFREERTOS_ERRNO_ENOTDIR 20 /* Not a directory */ +#define pdFREERTOS_ERRNO_EISDIR 21 /* Is a directory */ +#define pdFREERTOS_ERRNO_EINVAL 22 /* Invalid argument */ +#define pdFREERTOS_ERRNO_ENOSPC 28 /* No space left on device */ +#define pdFREERTOS_ERRNO_ESPIPE 29 /* Illegal seek */ +#define pdFREERTOS_ERRNO_EROFS 30 /* Read only file system */ +#define pdFREERTOS_ERRNO_EUNATCH 42 /* Protocol driver not attached */ +#define pdFREERTOS_ERRNO_EBADE 50 /* Invalid exchange */ +#define pdFREERTOS_ERRNO_EFTYPE 79 /* Inappropriate file type or format */ +#define pdFREERTOS_ERRNO_ENMFILE 89 /* No more files */ +#define pdFREERTOS_ERRNO_ENOTEMPTY 90 /* Directory not empty */ +#define pdFREERTOS_ERRNO_ENAMETOOLONG 91 /* File or path name too long */ +#define pdFREERTOS_ERRNO_EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ +#define pdFREERTOS_ERRNO_ENOBUFS 105 /* No buffer space available */ +#define pdFREERTOS_ERRNO_ENOPROTOOPT 109 /* Protocol not available */ +#define pdFREERTOS_ERRNO_EADDRINUSE 112 /* Address already in use */ +#define pdFREERTOS_ERRNO_ETIMEDOUT 116 /* Connection timed out */ +#define pdFREERTOS_ERRNO_EINPROGRESS 119 /* Connection already in progress */ +#define pdFREERTOS_ERRNO_EALREADY 120 /* Socket already connected */ +#define pdFREERTOS_ERRNO_EADDRNOTAVAIL 125 /* Address not available */ +#define pdFREERTOS_ERRNO_EISCONN 127 /* Socket is already connected */ +#define pdFREERTOS_ERRNO_ENOTCONN 128 /* Socket is not connected */ +#define pdFREERTOS_ERRNO_ENOMEDIUM 135 /* No medium inserted */ +#define pdFREERTOS_ERRNO_EILSEQ 138 /* An invalid UTF-16 sequence was encountered. */ +#define pdFREERTOS_ERRNO_ECANCELED 140 /* Operation canceled. */ /* The following endian values are used by FreeRTOS+ components, not FreeRTOS -itself. */ -#define pdFREERTOS_LITTLE_ENDIAN 0 -#define pdFREERTOS_BIG_ENDIAN 1 + * itself. */ +#define pdFREERTOS_LITTLE_ENDIAN 0 +#define pdFREERTOS_BIG_ENDIAN 1 /* Re-defining endian values for generic naming. */ -#define pdLITTLE_ENDIAN pdFREERTOS_LITTLE_ENDIAN -#define pdBIG_ENDIAN pdFREERTOS_BIG_ENDIAN +#define pdLITTLE_ENDIAN pdFREERTOS_LITTLE_ENDIAN +#define pdBIG_ENDIAN pdFREERTOS_BIG_ENDIAN #endif /* PROJDEFS_H */ diff --git a/tools/sdk/esp32c3/include/freertos/include/freertos/queue.h b/tools/sdk/esp32c3/include/freertos/include/freertos/queue.h index 8c35465316e..81cccc05df3 100644 --- a/tools/sdk/esp32c3/include/freertos/include/freertos/queue.h +++ b/tools/sdk/esp32c3/include/freertos/include/freertos/queue.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ @@ -30,12 +29,14 @@ #define QUEUE_H #ifndef INC_FREERTOS_H - #error "include FreeRTOS.h" must appear in source files before "include queue.h" + #error "include FreeRTOS.h" must appear in source files before "include queue.h" #endif +/* *INDENT-OFF* */ #ifdef __cplusplus -extern "C" { + extern "C" { #endif +/* *INDENT-ON* */ #include "task.h" @@ -45,42 +46,64 @@ extern "C" { * xQueueSend(), xQueueReceive(), etc. */ struct QueueDefinition; /* Using old naming convention so as not to break kernel aware debuggers. */ -typedef struct QueueDefinition * QueueHandle_t; +typedef struct QueueDefinition * QueueHandle_t; /** * Type by which queue sets are referenced. For example, a call to * xQueueCreateSet() returns an xQueueSet variable that can then be used as a * parameter to xQueueSelectFromSet(), xQueueAddToSet(), etc. */ -typedef struct QueueDefinition * QueueSetHandle_t; +typedef struct QueueDefinition * QueueSetHandle_t; /** * Queue sets can contain both queues and semaphores, so the * QueueSetMemberHandle_t is defined as a type to be used where a parameter or * return value can be either an QueueHandle_t or an SemaphoreHandle_t. */ -typedef struct QueueDefinition * QueueSetMemberHandle_t; +typedef struct QueueDefinition * QueueSetMemberHandle_t; /** @cond */ /* For internal use only. */ -#define queueSEND_TO_BACK ( ( BaseType_t ) 0 ) -#define queueSEND_TO_FRONT ( ( BaseType_t ) 1 ) -#define queueOVERWRITE ( ( BaseType_t ) 2 ) +#define queueSEND_TO_BACK ( ( BaseType_t ) 0 ) +#define queueSEND_TO_FRONT ( ( BaseType_t ) 1 ) +#define queueOVERWRITE ( ( BaseType_t ) 2 ) /* For internal use only. These definitions *must* match those in queue.c. */ -#define queueQUEUE_TYPE_BASE ( ( uint8_t ) 0U ) -#define queueQUEUE_TYPE_SET ( ( uint8_t ) 0U ) -#define queueQUEUE_TYPE_MUTEX ( ( uint8_t ) 1U ) -#define queueQUEUE_TYPE_COUNTING_SEMAPHORE ( ( uint8_t ) 2U ) -#define queueQUEUE_TYPE_BINARY_SEMAPHORE ( ( uint8_t ) 3U ) -#define queueQUEUE_TYPE_RECURSIVE_MUTEX ( ( uint8_t ) 4U ) +#define queueQUEUE_TYPE_BASE ( ( uint8_t ) 0U ) +#define queueQUEUE_TYPE_SET ( ( uint8_t ) 0U ) +#define queueQUEUE_TYPE_MUTEX ( ( uint8_t ) 1U ) +#define queueQUEUE_TYPE_COUNTING_SEMAPHORE ( ( uint8_t ) 2U ) +#define queueQUEUE_TYPE_BINARY_SEMAPHORE ( ( uint8_t ) 3U ) +#define queueQUEUE_TYPE_RECURSIVE_MUTEX ( ( uint8_t ) 4U ) /** @endcond */ /** - * Creates a new queue instance. This allocates the storage required by the - * new queue and returns a handle for the queue. + * @cond + * queue. h + * @code{c} + * QueueHandle_t xQueueCreate( + * UBaseType_t uxQueueLength, + * UBaseType_t uxItemSize + * ); + * @endcode + * @endcond + * + * Creates a new queue instance, and returns a handle by which the new queue + * can be referenced. + * + * Internally, within the FreeRTOS implementation, queues use two blocks of + * memory. The first block is used to hold the queue's data structures. The + * second block is used to hold items placed into the queue. If a queue is + * created using xQueueCreate() then both blocks of memory are automatically + * dynamically allocated inside the xQueueCreate() function. (see + * https://www.FreeRTOS.org/a00111.html). If a queue is created using + * xQueueCreateStatic() then the application writer must provide the memory that + * will get used by the queue. xQueueCreateStatic() therefore allows a queue to + * be created without using any dynamic memory allocation. + * + * https://www.FreeRTOS.org/Embedded-RTOS-Queues.html * * @param uxQueueLength The maximum number of items that the queue can contain. * @@ -95,15 +118,15 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * * Example usage: * @code{c} - * struct AMessage - * { + * struct AMessage + * { * char ucMessageID; * char ucData[ 20 ]; - * }; + * }; * - * void vATask( void *pvParameters ) - * { - * QueueHandle_t xQueue1, xQueue2; + * void vATask( void *pvParameters ) + * { + * QueueHandle_t xQueue1, xQueue2; * * // Create a queue capable of containing 10 uint32_t values. * xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) ); @@ -121,15 +144,29 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * } * * // ... Rest of task code. - * } + * } * @endcode + * @cond + * \defgroup xQueueCreate xQueueCreate + * @endcond * \ingroup QueueManagement */ -#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - #define xQueueCreate( uxQueueLength, uxItemSize ) xQueueGenericCreate( ( uxQueueLength ), ( uxItemSize ), ( queueQUEUE_TYPE_BASE ) ) +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + #define xQueueCreate( uxQueueLength, uxItemSize ) xQueueGenericCreate( ( uxQueueLength ), ( uxItemSize ), ( queueQUEUE_TYPE_BASE ) ) #endif /** + * @cond + * queue. h + * @code{c} + * QueueHandle_t xQueueCreateStatic( + * UBaseType_t uxQueueLength, + * UBaseType_t uxItemSize, + * uint8_t *pucQueueStorageBuffer, + * StaticQueue_t *pxQueueBuffer + * ); + * @endcode + * @endcond * Creates a new queue instance, and returns a handle by which the new queue * can be referenced. * @@ -138,12 +175,12 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * second block is used to hold items placed into the queue. If a queue is * created using xQueueCreate() then both blocks of memory are automatically * dynamically allocated inside the xQueueCreate() function. (see - * http://www.freertos.org/a00111.html). If a queue is created using + * https://www.FreeRTOS.org/a00111.html). If a queue is created using * xQueueCreateStatic() then the application writer must provide the memory that * will get used by the queue. xQueueCreateStatic() therefore allows a queue to * be created without using any dynamic memory allocation. * - * http://www.FreeRTOS.org/Embedded-RTOS-Queues.html + * https://www.FreeRTOS.org/Embedded-RTOS-Queues.html * * @param uxQueueLength The maximum number of items that the queue can contain. * @@ -184,7 +221,7 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * * void vATask( void *pvParameters ) * { - * QueueHandle_t xQueue1; + * 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. @@ -198,13 +235,27 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * // ... Rest of task code. * } * @endcode + * @cond + * \defgroup xQueueCreateStatic xQueueCreateStatic + * @endcond * \ingroup QueueManagement */ -#if( configSUPPORT_STATIC_ALLOCATION == 1 ) - #define xQueueCreateStatic( uxQueueLength, uxItemSize, pucQueueStorage, pxQueueBuffer ) xQueueGenericCreateStatic( ( uxQueueLength ), ( uxItemSize ), ( pucQueueStorage ), ( pxQueueBuffer ), ( queueQUEUE_TYPE_BASE ) ) +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + #define xQueueCreateStatic( uxQueueLength, uxItemSize, pucQueueStorage, pxQueueBuffer ) xQueueGenericCreateStatic( ( uxQueueLength ), ( uxItemSize ), ( pucQueueStorage ), ( pxQueueBuffer ), ( queueQUEUE_TYPE_BASE ) ) #endif /* configSUPPORT_STATIC_ALLOCATION */ /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueSendToToFront( + * QueueHandle_t xQueue, + * const void *pvItemToQueue, + * TickType_t xTicksToWait + * ); + * @endcode + * @endcond + * * Post an item to the front of a queue. The item is queued by copy, not by * reference. This function must not be called from an interrupt service * routine. See xQueueSendFromISR () for an alternative which may be used @@ -227,18 +278,18 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * * Example usage: * @code{c} - * struct AMessage - * { + * struct AMessage + * { * char ucMessageID; * char ucData[ 20 ]; - * } xMessage; + * } xMessage; * - * uint32_t ulVar = 10UL; + * uint32_t ulVar = 10UL; * - * void vATask( void *pvParameters ) - * { - * QueueHandle_t xQueue1, xQueue2; - * struct AMessage *pxMessage; + * 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 ) ); @@ -268,13 +319,28 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * } * * // ... Rest of task code. - * } + * } * @endcode + * @cond + * \defgroup xQueueSend xQueueSend + * @endcond * \ingroup QueueManagement */ -#define xQueueSendToFront( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_FRONT ) +#define xQueueSendToFront( xQueue, pvItemToQueue, xTicksToWait ) \ + xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_FRONT ) /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueSendToBack( + * QueueHandle_t xQueue, + * const void *pvItemToQueue, + * TickType_t xTicksToWait + * ); + * @endcode + * @endcond + * * This is a macro that calls xQueueGenericSend(). * * Post an item to the back of a queue. The item is queued by copy, not by @@ -299,18 +365,18 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * * Example usage: * @code{c} - * struct AMessage - * { + * struct AMessage + * { * char ucMessageID; * char ucData[ 20 ]; - * } xMessage; + * } xMessage; * - * uint32_t ulVar = 10UL; + * uint32_t ulVar = 10UL; * - * void vATask( void *pvParameters ) - * { - * QueueHandle_t xQueue1, xQueue2; - * struct AMessage *pxMessage; + * 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 ) ); @@ -340,13 +406,28 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * } * * // ... Rest of task code. - * } + * } * @endcode + * @cond + * \defgroup xQueueSend xQueueSend + * @endcond * \ingroup QueueManagement */ -#define xQueueSendToBack( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK ) +#define xQueueSendToBack( xQueue, pvItemToQueue, xTicksToWait ) \ + xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK ) /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueSend( + * QueueHandle_t xQueue, + * const void * pvItemToQueue, + * TickType_t xTicksToWait + * ); + * @endcode + * @endcond + * * 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 @@ -373,18 +454,18 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * * Example usage: * @code{c} - * struct AMessage - * { + * struct AMessage + * { * char ucMessageID; * char ucData[ 20 ]; - * } xMessage; + * } xMessage; * - * uint32_t ulVar = 10UL; + * uint32_t ulVar = 10UL; * - * void vATask( void *pvParameters ) - * { - * QueueHandle_t xQueue1, xQueue2; - * struct AMessage *pxMessage; + * 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 ) ); @@ -414,13 +495,27 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * } * * // ... Rest of task code. - * } + * } * @endcode + * @cond + * \defgroup xQueueSend xQueueSend + * @endcond * \ingroup QueueManagement */ -#define xQueueSend( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK ) +#define xQueueSend( xQueue, pvItemToQueue, xTicksToWait ) \ + xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK ) /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueOverwrite( + * QueueHandle_t xQueue, + * const void * pvItemToQueue + * ); + * @endcode + * @endcond + * * Only for use with queues that have a length of one - so the queue is either * empty or full. * @@ -445,10 +540,10 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * Example usage: * @code{c} * - * void vFunction( void *pvParameters ) - * { - * QueueHandle_t xQueue; - * uint32_t ulVarToSend, ulValReceived; + * 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 @@ -490,12 +585,28 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * // ... * } * @endcode + * @cond + * \defgroup xQueueOverwrite xQueueOverwrite + * @endcond * \ingroup QueueManagement */ -#define xQueueOverwrite( xQueue, pvItemToQueue ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), 0, queueOVERWRITE ) +#define xQueueOverwrite( xQueue, pvItemToQueue ) \ + xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), 0, queueOVERWRITE ) /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueGenericSend( + * QueueHandle_t xQueue, + * const void * pvItemToQueue, + * TickType_t xTicksToWait + * BaseType_t xCopyPosition + * ); + * @endcode + * @endcond + * * It is preferred that the macros xQueueSend(), xQueueSendToFront() and * xQueueSendToBack() are used in place of calling this function directly. * @@ -524,18 +635,18 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * * Example usage: * @code{c} - * struct AMessage - * { + * struct AMessage + * { * char ucMessageID; * char ucData[ 20 ]; - * } xMessage; + * } xMessage; * - * uint32_t ulVar = 10UL; + * uint32_t ulVar = 10UL; * - * void vATask( void *pvParameters ) - * { - * QueueHandle_t xQueue1, xQueue2; - * struct AMessage *pxMessage; + * 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 ) ); @@ -565,13 +676,30 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * } * * // ... Rest of task code. - * } + * } * @endcode + * @cond + * \defgroup xQueueSend xQueueSend + * @endcond * \ingroup QueueManagement */ -BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, const BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION; +BaseType_t xQueueGenericSend( QueueHandle_t xQueue, + const void * const pvItemToQueue, + TickType_t xTicksToWait, + const BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION; /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueuePeek( + * QueueHandle_t xQueue, + * void * const pvBuffer, + * TickType_t xTicksToWait + * ); + * @endcode + * @endcond + * * Receive an item from a queue without removing the item from the queue. * The item is received by copy so a buffer of adequate size must be * provided. The number of bytes copied into the buffer was defined when @@ -592,7 +720,7 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQ * * @param xTicksToWait The maximum amount of time the task should block * waiting for an item to receive should the queue be empty at the time - * of the call. The time is defined in tick periods so the constant + * of the call. The time is defined in tick periods so the constant * portTICK_PERIOD_MS should be used to convert to real time if this is required. * xQueuePeek() will return immediately if xTicksToWait is 0 and the queue * is empty. @@ -602,18 +730,18 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQ * * Example usage: * @code{c} - * struct AMessage - * { + * struct AMessage + * { * char ucMessageID; * char ucData[ 20 ]; - * } xMessage; + * } xMessage; * - * QueueHandle_t xQueue; + * QueueHandle_t xQueue; * - * // Task to create a queue and post a value. - * void vATask( void *pvParameters ) - * { - * struct AMessage *pxMessage; + * // 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. @@ -631,12 +759,12 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQ * 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; + * // Task to peek the data from the queue. + * void vADifferentTask( void *pvParameters ) + * { + * struct AMessage *pxRxedMessage; * * if( xQueue != 0 ) * { @@ -650,13 +778,28 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQ * } * * // ... Rest of task code. - * } + * } * @endcode + * @cond + * \defgroup xQueuePeek xQueuePeek + * @endcond * \ingroup QueueManagement */ -BaseType_t xQueuePeek( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +BaseType_t xQueuePeek( QueueHandle_t xQueue, + void * const pvBuffer, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueuePeekFromISR( + * QueueHandle_t xQueue, + * void *pvBuffer, + * ); + * @endcode + * @endcond + * * A version of xQueuePeek() that can be called from an interrupt service * routine (ISR). * @@ -677,11 +820,26 @@ BaseType_t xQueuePeek( QueueHandle_t xQueue, void * const pvBuffer, TickType_t x * @return pdTRUE if an item was successfully received from the queue, * otherwise pdFALSE. * + * @cond + * \defgroup xQueuePeekFromISR xQueuePeekFromISR + * @endcond * \ingroup QueueManagement */ -BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, void * const pvBuffer ) PRIVILEGED_FUNCTION; +BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, + void * const pvBuffer ) PRIVILEGED_FUNCTION; /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueReceive( + * QueueHandle_t xQueue, + * void *pvBuffer, + * TickType_t xTicksToWait + * ); + * @endcode + * @endcond + * * Receive an item from a queue. The item is received by copy so a buffer of * adequate size must be provided. The number of bytes copied into the buffer * was defined when the queue was created. @@ -699,7 +857,7 @@ BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, void * const pvBuffer ) PRIV * * @param xTicksToWait The maximum amount of time the task should block * waiting for an item to receive should the queue be empty at the time - * of the call. xQueueReceive() will return immediately if xTicksToWait + * of the call. xQueueReceive() will return immediately if xTicksToWait * is zero and the queue is empty. The time is defined in tick periods so the * constant portTICK_PERIOD_MS should be used to convert to real time if this is * required. @@ -709,72 +867,94 @@ BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, void * const pvBuffer ) PRIV * * Example usage: * @code{c} - * struct AMessage - * { - * char ucMessageID; - * char ucData[ 20 ]; - * } xMessage; + * struct AMessage + * { + * char ucMessageID; + * char ucData[ 20 ]; + * } xMessage; + * + * QueueHandle_t xQueue; * - * QueueHandle_t xQueue; + * // Task to create a queue and post a value. + * void vATask( void *pvParameters ) + * { + * struct AMessage *pxMessage; * - * // Task to create a queue and post a value. - * void vATask( void *pvParameters ) + * // 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 ) * { - * struct AMessage *pxMessage; + * // Failed to create the queue. + * } * - * // 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 ); * - * // 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. + * } * - * // ... Rest of task code. - * } + * // Task to receive from the queue. + * void vADifferentTask( void *pvParameters ) + * { + * struct AMessage *pxRxedMessage; * - * // Task to receive from the queue. - * void vADifferentTask( void *pvParameters ) + * if( xQueue != 0 ) * { - * 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. + * // 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 + * @cond + * \defgroup xQueueReceive xQueueReceive + * @endcond * \ingroup QueueManagement */ -BaseType_t xQueueReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +BaseType_t xQueueReceive( QueueHandle_t xQueue, + void * const pvBuffer, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; /** + * @cond + * queue. h + * @code{c} + * UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue ); + * @endcode + * @endcond + * * 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. * + * @cond + * \defgroup uxQueueMessagesWaiting uxQueueMessagesWaiting + * @endcond * \ingroup QueueManagement */ UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; /** + * @cond + * queue. h + * @code{c} + * UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue ); + * @endcode + * @endcond + * * 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. @@ -783,21 +963,45 @@ UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue ) PRIVILEGED_FUNC * * @return The number of spaces available in the queue. * + * @cond + * \defgroup uxQueueMessagesWaiting uxQueueMessagesWaiting + * @endcond * \ingroup QueueManagement */ UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; /** + * @cond + * queue. h + * @code{c} + * void vQueueDelete( QueueHandle_t xQueue ); + * @endcode + * @endcond + * * 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. * + * @cond + * \defgroup vQueueDelete vQueueDelete + * @endcond * \ingroup QueueManagement */ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueSendToFrontFromISR( + * QueueHandle_t xQueue, + * const void *pvItemToQueue, + * BaseType_t *pxHigherPriorityTaskWoken + * ); + * @endcode + * @endcond + * * This is a macro that calls xQueueGenericSendFromISR(). * * Post an item to the front of a queue. It is safe to use this macro from @@ -826,38 +1030,54 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; * Example usage for buffered IO (where the ISR can obtain more than one value * per call): * @code{c} - * void vBufferISR( void ) - * { - * char cIn; - * BaseType_t xHigherPrioritTaskWoken; + * void vBufferISR( void ) + * { + * char cIn; + * BaseType_t xHigherPrioritTaskWoken; * - * // We have not woken a task at the start of the ISR. - * xHigherPriorityTaskWoken = pdFALSE; + * // 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 ); + * // 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 ); + * // Post the byte. + * xQueueSendToFrontFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken ); * - * } while( portINPUT_BYTE( BUFFER_COUNT ) ); + * } while( portINPUT_BYTE( BUFFER_COUNT ) ); * - * // Now the buffer is empty we can switch context if necessary. - * if( xHigherPriorityTaskWoken ) - * { - * portYIELD_FROM_ISR (); - * } + * // Now the buffer is empty we can switch context if necessary. + * if( xHigherPriorityTaskWoken ) + * { + * portYIELD_FROM_ISR (); * } + * } * @endcode + * + * @cond + * \defgroup xQueueSendFromISR xQueueSendFromISR + * @endcond * \ingroup QueueManagement */ -#define xQueueSendToFrontFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_FRONT ) +#define xQueueSendToFrontFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) \ + xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_FRONT ) /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueSendToBackFromISR( + * QueueHandle_t xQueue, + * const void *pvItemToQueue, + * BaseType_t *pxHigherPriorityTaskWoken + * ); + * @endcode + * @endcond + * * This is a macro that calls xQueueGenericSendFromISR(). * * Post an item to the back of a queue. It is safe to use this macro from @@ -886,37 +1106,53 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; * Example usage for buffered IO (where the ISR can obtain more than one value * per call): * @code{c} - * void vBufferISR( void ) - * { - * char cIn; - * BaseType_t xHigherPriorityTaskWoken; + * void vBufferISR( void ) + * { + * char cIn; + * BaseType_t xHigherPriorityTaskWoken; * - * // We have not woken a task at the start of the ISR. - * xHigherPriorityTaskWoken = pdFALSE; + * // 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 ); + * // 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 ); + * // Post the byte. + * xQueueSendToBackFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken ); * - * } while( portINPUT_BYTE( BUFFER_COUNT ) ); + * } while( portINPUT_BYTE( BUFFER_COUNT ) ); * - * // Now the buffer is empty we can switch context if necessary. - * if( xHigherPriorityTaskWoken ) - * { - * portYIELD_FROM_ISR (); - * } + * // Now the buffer is empty we can switch context if necessary. + * if( xHigherPriorityTaskWoken ) + * { + * portYIELD_FROM_ISR (); * } + * } * @endcode + * + * @cond + * \defgroup xQueueSendFromISR xQueueSendFromISR + * @endcond * \ingroup QueueManagement */ -#define xQueueSendToBackFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK ) +#define xQueueSendToBackFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) \ + xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK ) /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueOverwriteFromISR( + * QueueHandle_t xQueue, + * const void * pvItemToQueue, + * BaseType_t *pxHigherPriorityTaskWoken + * ); + * @endcode + * @endcond + * * A version of xQueueOverwrite() that can be used in an interrupt service * routine (ISR). * @@ -947,15 +1183,16 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; * * Example usage: * @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 ) ); + * 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 ) @@ -964,35 +1201,50 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; * BaseType_t xHigherPriorityTaskWoken = pdFALSE; * uint32_t ulVarToSend, ulValReceived; * - * // Write the value 10 to the queue using xQueueOverwriteFromISR(). - * ulVarToSend = 10; - * xQueueOverwriteFromISR( xQueue, &ulVarToSend, &xHigherPriorityTaskWoken ); + * // 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 ); + * // 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. + * // 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. - * } + * 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 + * @cond + * \defgroup xQueueOverwriteFromISR xQueueOverwriteFromISR + * @endcond * \ingroup QueueManagement */ -#define xQueueOverwriteFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueOVERWRITE ) +#define xQueueOverwriteFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) \ + xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueOVERWRITE ) /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueSendFromISR( + * QueueHandle_t xQueue, + * const void *pvItemToQueue, + * BaseType_t *pxHigherPriorityTaskWoken + * ); + * @endcode + * @endcond + * * 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() @@ -1024,40 +1276,57 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; * Example usage for buffered IO (where the ISR can obtain more than one value * per call): * @code{c} - * void vBufferISR( void ) - * { - * char cIn; - * BaseType_t xHigherPriorityTaskWoken; + * void vBufferISR( void ) + * { + * char cIn; + * BaseType_t xHigherPriorityTaskWoken; * - * // We have not woken a task at the start of the ISR. - * xHigherPriorityTaskWoken = pdFALSE; + * // 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 ); + * // 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 ); + * // Post the byte. + * xQueueSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken ); * - * } while( portINPUT_BYTE( BUFFER_COUNT ) ); + * } 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 (); - * } + * // Now the buffer is empty we can switch context if necessary. + * if( xHigherPriorityTaskWoken ) + * { + * // Actual macro used here is port specific. + * portYIELD_FROM_ISR (); * } + * } * @endcode * + * @cond + * \defgroup xQueueSendFromISR xQueueSendFromISR + * @endcond * \ingroup QueueManagement */ -#define xQueueSendFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK ) +#define xQueueSendFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) \ + xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK ) +/** @cond */ /**@{*/ /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueGenericSendFromISR( + * QueueHandle_t xQueue, + * const void *pvItemToQueue, + * BaseType_t *pxHigherPriorityTaskWoken, + * BaseType_t xCopyPosition + * ); + * @endcode + * @endcond + * * It is preferred that the macros xQueueSendFromISR(), * xQueueSendToFrontFromISR() and xQueueSendToBackFromISR() be used in place * of calling this function directly. xQueueGiveFromISR() is an @@ -1093,40 +1362,57 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; * Example usage for buffered IO (where the ISR can obtain more than one value * per call): * @code{c} - * void vBufferISR( void ) - * { - * char cIn; - * BaseType_t xHigherPriorityTaskWokenByPost; + * void vBufferISR( void ) + * { + * char cIn; + * BaseType_t xHigherPriorityTaskWokenByPost; * - * // We have not woken a task at the start of the ISR. - * xHigherPriorityTaskWokenByPost = pdFALSE; + * // 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 ); + * // 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 ); + * // Post each byte. + * xQueueGenericSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWokenByPost, queueSEND_TO_BACK ); * - * } while( portINPUT_BYTE( BUFFER_COUNT ) ); + * } 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(); - * } + * // 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; +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; /**@}*/ +/** @endcond */ /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueReceiveFromISR( + * QueueHandle_t xQueue, + * void *pvBuffer, + * BaseType_t *pxTaskWoken + * ); + * @endcode + * @endcond + * * Receive an item from a queue. It is safe to use this function from within an * interrupt service routine. * @@ -1146,63 +1432,69 @@ BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue, BaseType_t * const pxHigherP * * Example usage: * @code{c} - * QueueHandle_t xQueue; * - * // Function to create a queue and post some values. - * void vAFunction( void *pvParameters ) + * 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) ) * { - * 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 ); + * // 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. * } * - * // ISR that outputs all the characters received on the queue. - * void vISR_Routine( void ) + * if( cTaskWokenByPost != ( char ) pdFALSE; * { - * 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 (); - * } + * taskYIELD (); * } + * } * @endcode + * @cond + * \defgroup xQueueReceiveFromISR xQueueReceiveFromISR + * @endcond * \ingroup QueueManagement */ -BaseType_t xQueueReceiveFromISR( QueueHandle_t xQueue, void * const pvBuffer, BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; +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 @@ -1213,7 +1505,7 @@ BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUN UBaseType_t uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; /** @cond */ -/** +/* * The functions defined above are for passing data to and from tasks. The * functions below are the equivalents for passing data to and from * co-routines. @@ -1222,10 +1514,18 @@ UBaseType_t uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue ) PRIVILEG * should not be called directly from application code. Instead use the macro * wrappers defined within croutine.h. */ -BaseType_t xQueueCRSendFromISR( QueueHandle_t xQueue, const void *pvItemToQueue, BaseType_t xCoRoutinePreviouslyWoken ); -BaseType_t xQueueCRReceiveFromISR( QueueHandle_t xQueue, void *pvBuffer, BaseType_t *pxTaskWoken ); -BaseType_t xQueueCRSend( QueueHandle_t xQueue, const void *pvItemToQueue, TickType_t xTicksToWait ); -BaseType_t xQueueCRReceive( QueueHandle_t xQueue, void *pvBuffer, TickType_t xTicksToWait ); +BaseType_t xQueueCRSendFromISR( QueueHandle_t xQueue, + const void * pvItemToQueue, + BaseType_t xCoRoutinePreviouslyWoken ); +BaseType_t xQueueCRReceiveFromISR( QueueHandle_t xQueue, + void * pvBuffer, + BaseType_t * pxTaskWoken ); +BaseType_t xQueueCRSend( QueueHandle_t xQueue, + const void * pvItemToQueue, + TickType_t xTicksToWait ); +BaseType_t xQueueCRReceive( QueueHandle_t xQueue, + void * pvBuffer, + TickType_t xTicksToWait ); /** * For internal use only. Use xSemaphoreCreateMutex(), @@ -1233,10 +1533,15 @@ BaseType_t xQueueCRReceive( QueueHandle_t xQueue, void *pvBuffer, TickType_t xTi * these functions directly. */ QueueHandle_t xQueueCreateMutex( const uint8_t ucQueueType ) PRIVILEGED_FUNCTION; -QueueHandle_t xQueueCreateMutexStatic( const uint8_t ucQueueType, StaticQueue_t *pxStaticQueue ) PRIVILEGED_FUNCTION; -QueueHandle_t xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount ) PRIVILEGED_FUNCTION; -QueueHandle_t xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount, StaticQueue_t *pxStaticQueue ) PRIVILEGED_FUNCTION; -BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +QueueHandle_t xQueueCreateMutexStatic( const uint8_t ucQueueType, + StaticQueue_t * pxStaticQueue ) PRIVILEGED_FUNCTION; +QueueHandle_t xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, + const UBaseType_t uxInitialCount ) PRIVILEGED_FUNCTION; +QueueHandle_t xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, + const UBaseType_t uxInitialCount, + StaticQueue_t * pxStaticQueue ) PRIVILEGED_FUNCTION; +BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; TaskHandle_t xQueueGetMutexHolder( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION; TaskHandle_t xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION; @@ -1244,7 +1549,8 @@ TaskHandle_t xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore ) PRIVILEGED_ * For internal use only. Use xSemaphoreTakeMutexRecursive() or * xSemaphoreGiveMutexRecursive() instead of calling these functions directly. */ -BaseType_t xQueueTakeMutexRecursive( QueueHandle_t xMutex, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +BaseType_t xQueueTakeMutexRecursive( QueueHandle_t xMutex, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION; /** @endcond */ @@ -1253,7 +1559,7 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION; * Reset a queue back to its original empty state. The return value is now * obsolete and is always set to pdPASS. */ -#define xQueueReset( xQueue ) xQueueGenericReset( xQueue, pdFALSE ) +#define xQueueReset( xQueue ) xQueueGenericReset( xQueue, pdFALSE ) /** * The registry is provided as a means for kernel aware debuggers to @@ -1277,8 +1583,9 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION; * stores a pointer to the string - so the string must be persistent (global or * preferably in ROM/Flash), not on the stack. */ -#if( configQUEUE_REGISTRY_SIZE > 0 ) - void vQueueAddToRegistry( QueueHandle_t xQueue, const char *pcQueueName ) PRIVILEGED_FUNCTION; /**lint !e971 Unqualified char types are allowed for strings and single characters only. */ +#if ( configQUEUE_REGISTRY_SIZE > 0 ) + void vQueueAddToRegistry( QueueHandle_t xQueue, + const char * pcQueueName ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ #endif /** @@ -1291,8 +1598,8 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION; * * @param xQueue The handle of the queue being removed from the registry. */ -#if( configQUEUE_REGISTRY_SIZE > 0 ) - void vQueueUnregisterQueue( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; +#if ( configQUEUE_REGISTRY_SIZE > 0 ) + void vQueueUnregisterQueue( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; #endif /** @@ -1306,26 +1613,32 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION; * queue is returned. If the queue is not in the registry then NULL is * 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. */ +#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. */ #endif /** - * Generic version of the function used to creaet a queue using dynamic memory + * Generic version of the function used to create 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. */ -#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - QueueHandle_t xQueueGenericCreate( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, const uint8_t ucQueueType ) PRIVILEGED_FUNCTION; +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + 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 + * Generic version of the function used to create 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. */ -#if( configSUPPORT_STATIC_ALLOCATION == 1 ) - QueueHandle_t xQueueGenericCreateStatic( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, uint8_t *pucQueueStorage, StaticQueue_t *pxStaticQueue, const uint8_t ucQueueType ) PRIVILEGED_FUNCTION; +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + QueueHandle_t xQueueGenericCreateStatic( const UBaseType_t uxQueueLength, + const UBaseType_t uxItemSize, + uint8_t * pucQueueStorage, + StaticQueue_t * pxStaticQueue, + const uint8_t ucQueueType ) PRIVILEGED_FUNCTION; #endif /** @@ -1342,7 +1655,7 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION; * or semaphores contained in the set is in a state where a queue read or * semaphore take operation would be successful. * - * Note 1: See the documentation on http://wwwFreeRTOS.org/RTOS-queue-sets.html + * Note 1: See the documentation on https://www.FreeRTOS.org/RTOS-queue-sets.html * for reasons why queue sets are very rarely needed in practice as there are * simpler methods of blocking on multiple objects. * @@ -1400,7 +1713,8 @@ QueueSetHandle_t xQueueCreateSet( const UBaseType_t uxEventQueueLength ) PRIVILE * queue set because it is already a member of a different queue set then pdFAIL * is returned. */ -BaseType_t xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION; +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 @@ -1419,7 +1733,8 @@ BaseType_t xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHan * then pdPASS is returned. If the queue was not in the queue set, or the * queue (or semaphore) was not empty, then pdFAIL is returned. */ -BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION; +BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, + QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION; /** * xQueueSelectFromSet() selects from the members of a queue set a queue or @@ -1431,7 +1746,7 @@ BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueS * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this * function. * - * Note 1: See the documentation on http://wwwFreeRTOS.org/RTOS-queue-sets.html + * Note 1: See the documentation on https://www.FreeRTOS.org/RTOS-queue-sets.html * for reasons why queue sets are very rarely needed in practice as there are * simpler methods of blocking on multiple objects. * @@ -1455,7 +1770,8 @@ BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueS * in the queue set that is available, or NULL if no such queue or semaphore * exists before before the specified block time expires. */ -QueueSetMemberHandle_t xQueueSelectFromSet( QueueSetHandle_t xQueueSet, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +QueueSetMemberHandle_t xQueueSelectFromSet( QueueSetHandle_t xQueueSet, + const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; /** * A version of xQueueSelectFromSet() that can be used from an ISR. @@ -1465,16 +1781,22 @@ QueueSetMemberHandle_t xQueueSelectFromSetFromISR( QueueSetHandle_t xQueueSet ) /** @cond */ /* Not public API functions. */ -void vQueueWaitForMessageRestricted( QueueHandle_t xQueue, TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION; -BaseType_t xQueueGenericReset( QueueHandle_t xQueue, BaseType_t xNewQueue ) PRIVILEGED_FUNCTION; -void vQueueSetQueueNumber( QueueHandle_t xQueue, UBaseType_t uxQueueNumber ) PRIVILEGED_FUNCTION; +void vQueueWaitForMessageRestricted( QueueHandle_t xQueue, + TickType_t xTicksToWait, + const BaseType_t xWaitIndefinitely ) 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 */ +/* *INDENT-OFF* */ #ifdef __cplusplus -} + } #endif +/* *INDENT-ON* */ #endif /* QUEUE_H */ diff --git a/tools/sdk/esp32c3/include/freertos/include/freertos/semphr.h b/tools/sdk/esp32c3/include/freertos/include/freertos/semphr.h index 971d74d496c..7e99c0b396c 100644 --- a/tools/sdk/esp32c3/include/freertos/include/freertos/semphr.h +++ b/tools/sdk/esp32c3/include/freertos/include/freertos/semphr.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,35 +19,36 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ #ifndef SEMAPHORE_H #define SEMAPHORE_H #ifndef INC_FREERTOS_H - #error "include FreeRTOS.h" must appear in source files before "include semphr.h" + #error "include FreeRTOS.h" must appear in source files before "include semphr.h" #endif #include "queue.h" typedef QueueHandle_t SemaphoreHandle_t; -#define semBINARY_SEMAPHORE_QUEUE_LENGTH ( ( uint8_t ) 1U ) -#define semSEMAPHORE_QUEUE_ITEM_LENGTH ( ( uint8_t ) 0U ) -#define semGIVE_BLOCK_TIME ( ( TickType_t ) 0U ) +#define semBINARY_SEMAPHORE_QUEUE_LENGTH ( ( uint8_t ) 1U ) +#define semSEMAPHORE_QUEUE_ITEM_LENGTH ( ( uint8_t ) 0U ) +#define semGIVE_BLOCK_TIME ( ( TickType_t ) 0U ) /** @cond */ /** * semphr. h - *
vSemaphoreCreateBinary( SemaphoreHandle_t xSemaphore )
+ * @code{c} + * vSemaphoreCreateBinary( SemaphoreHandle_t xSemaphore ); + * @endcode * * In many usage scenarios it is faster and more memory efficient to use a * direct to task notification in place of a binary semaphore! - * http://www.freertos.org/RTOS-task-notifications.html + * https://www.FreeRTOS.org/RTOS-task-notifications.html * * This old vSemaphoreCreateBinary() macro is now deprecated in favour of the * xSemaphoreCreateBinary() function. Note that binary semaphores created using @@ -72,48 +73,58 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @code{c} - * SemaphoreHandle_t xSemaphore = NULL; + * 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 ); + * 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. - * } + * if( xSemaphore != NULL ) + * { + * // The semaphore was created successfully. + * // The semaphore can now be used. * } + * } * @endcode + * @cond + * \defgroup vSemaphoreCreateBinary vSemaphoreCreateBinary + * @endcond * \ingroup Semaphores */ -#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - #define vSemaphoreCreateBinary( xSemaphore ) \ - { \ - ( xSemaphore ) = xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE ); \ - if( ( xSemaphore ) != NULL ) \ - { \ - ( void ) xSemaphoreGive( ( xSemaphore ) ); \ - } \ - } +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + #define vSemaphoreCreateBinary( xSemaphore ) \ + { \ + ( xSemaphore ) = xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE ); \ + if( ( xSemaphore ) != NULL ) \ + { \ + ( void ) xSemaphoreGive( ( xSemaphore ) ); \ + } \ + } #endif /** @endcond */ /** + * @cond + * semphr. h + * @code{c} + * SemaphoreHandle_t xSemaphoreCreateBinary( void ); + * @endcode + * @endcond + * * Creates a new binary semaphore instance, and returns a handle by which the * new semaphore can be referenced. * * In many usage scenarios it is faster and more memory efficient to use a * direct to task notification in place of a binary semaphore! - * http://www.freertos.org/RTOS-task-notifications.html + * https://www.FreeRTOS.org/RTOS-task-notifications.html * * Internally, within the FreeRTOS implementation, binary semaphores use a block * of memory, in which the semaphore structure is stored. If a binary semaphore * is created using xSemaphoreCreateBinary() then the required memory is * automatically dynamically allocated inside the xSemaphoreCreateBinary() - * function. (see http://www.freertos.org/a00111.html). If a binary semaphore + * function. (see https://www.FreeRTOS.org/a00111.html). If a binary semaphore * is created using xSemaphoreCreateBinaryStatic() then the application writer * must provide the memory. xSemaphoreCreateBinaryStatic() therefore allows a * binary semaphore to be created without using any dynamic memory allocation. @@ -137,40 +148,50 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @code{c} - * SemaphoreHandle_t xSemaphore = NULL; + * 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(); + * 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. - * } + * if( xSemaphore != NULL ) + * { + * // The semaphore was created successfully. + * // The semaphore can now be used. * } + * } * @endcode + * @cond + * \defgroup xSemaphoreCreateBinary xSemaphoreCreateBinary + * @endcond * \ingroup Semaphores */ -#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - #define xSemaphoreCreateBinary() xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE ) +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + #define xSemaphoreCreateBinary() xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE ) #endif /** + * @cond + * semphr. h + * @code{c} + * SemaphoreHandle_t xSemaphoreCreateBinaryStatic( StaticSemaphore_t *pxSemaphoreBuffer ); + * @endcode + * @endcond + * * Creates a new binary semaphore instance, and returns a handle by which the * new semaphore can be referenced. * * NOTE: In many usage scenarios it is faster and more memory efficient to use a * direct to task notification in place of a binary semaphore! - * http://www.freertos.org/RTOS-task-notifications.html + * https://www.FreeRTOS.org/RTOS-task-notifications.html * * Internally, within the FreeRTOS implementation, binary semaphores use a block * of memory, in which the semaphore structure is stored. If a binary semaphore * is created using xSemaphoreCreateBinary() then the required memory is * automatically dynamically allocated inside the xSemaphoreCreateBinary() - * function. (see http://www.freertos.org/a00111.html). If a binary semaphore + * function. (see https://www.FreeRTOS.org/a00111.html). If a binary semaphore * is created using xSemaphoreCreateBinaryStatic() then the application writer * must provide the memory. xSemaphoreCreateBinaryStatic() therefore allows a * binary semaphore to be created without using any dynamic memory allocation. @@ -191,38 +212,51 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @code{c} - * SemaphoreHandle_t xSemaphore = NULL; - * StaticSemaphore_t xSemaphoreBuffer; - * - * void vATask( void * pvParameters ) - * { - * // Semaphore cannot be used before a call to xSemaphoreCreateBinary() or - * // xSemaphoreCreateBinaryStatic(). - * // 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 = xSemaphoreCreateBinaryStatic( &xSemaphoreBuffer ); - * - * // Rest of task code goes here. - * } + * SemaphoreHandle_t xSemaphore = NULL; + * StaticSemaphore_t xSemaphoreBuffer; + * + * void vATask( void * pvParameters ) + * { + * // Semaphore cannot be used before a call to xSemaphoreCreateBinary() or + * // xSemaphoreCreateBinaryStatic(). + * // 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 = xSemaphoreCreateBinaryStatic( &xSemaphoreBuffer ); + * + * // Rest of task code goes here. + * } * @endcode + * @cond + * \defgroup xSemaphoreCreateBinaryStatic xSemaphoreCreateBinaryStatic + * @endcond * \ingroup Semaphores */ -#if( configSUPPORT_STATIC_ALLOCATION == 1 ) - #define xSemaphoreCreateBinaryStatic( pxStaticSemaphore ) xQueueGenericCreateStatic( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, NULL, pxStaticSemaphore, queueQUEUE_TYPE_BINARY_SEMAPHORE ) +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + #define xSemaphoreCreateBinaryStatic( pxStaticSemaphore ) xQueueGenericCreateStatic( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, NULL, pxStaticSemaphore, queueQUEUE_TYPE_BINARY_SEMAPHORE ) #endif /* configSUPPORT_STATIC_ALLOCATION */ /** + * @cond + * semphr. h + * @code{c} + * xSemaphoreTake( + * SemaphoreHandle_t xSemaphore, + * TickType_t xBlockTime + * ); + * @endcode + * @endcond + * * Macro to obtain a semaphore. The semaphore must have previously been * created with a call to xSemaphoreCreateBinary(), xSemaphoreCreateMutex() or * xSemaphoreCreateCounting(). * - * @param xSemaphore A handle to the semaphore being taken - obtained when + * param xSemaphore A handle to the semaphore being taken - obtained when * the semaphore was created. * - * @param xBlockTime The time in ticks to wait for the semaphore to become + * param xBlockTime The time in ticks to wait for the semaphore to become * available. The macro portTICK_PERIOD_MS can be used to convert this to a * real time. A block time of zero can be used to poll the semaphore. A block * time of portMAX_DELAY can be used to block indefinitely (provided @@ -233,48 +267,61 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @code{c} - * SemaphoreHandle_t xSemaphore = NULL; + * 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 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. + * // 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. - * } - * } + * 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 + * @cond + * \defgroup xSemaphoreTake xSemaphoreTake + * @endcond * \ingroup Semaphores */ -#define xSemaphoreTake( xSemaphore, xBlockTime ) xQueueSemaphoreTake( ( xSemaphore ), ( xBlockTime ) ) +#define xSemaphoreTake( xSemaphore, xBlockTime ) xQueueSemaphoreTake( ( xSemaphore ), ( xBlockTime ) ) /** + * @cond + * semphr. h + * @code{c} + * xSemaphoreTakeRecursive( + * SemaphoreHandle_t xMutex, + * TickType_t xBlockTime + * ); + * @endcode + * @endcond + * * Macro to recursively obtain, or 'take', a mutex type semaphore. * The mutex must have previously been created using a call to * xSemaphoreCreateRecursiveMutex(); @@ -305,76 +352,63 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @code{c} - * SemaphoreHandle_t xMutex = NULL; + * 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 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. + * // 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. - * } - * } + * 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 + * @cond + * \defgroup xSemaphoreTakeRecursive xSemaphoreTakeRecursive + * @endcond * \ingroup Semaphores */ -#define xSemaphoreTakeRecursive( xMutex, xBlockTime ) xQueueTakeMutexRecursive( ( xMutex ), ( xBlockTime ) ) - -/** @cond */ -/* - * xSemaphoreAltTake() is an alternative version of xSemaphoreTake(). - * - * The source code that implements the alternative (Alt) API is much - * simpler because it executes everything from within a critical section. - * This is the approach taken by many other RTOSes, but FreeRTOS.org has the - * preferred fully featured API too. The fully featured API has more - * complex code that takes longer to execute, but makes much less use of - * critical sections. Therefore the alternative API sacrifices interrupt - * responsiveness to gain execution speed, whereas the fully featured API - * sacrifices execution speed to ensure better interrupt responsiveness. - */ -#define xSemaphoreAltTake( xSemaphore, xBlockTime ) xQueueAltGenericReceive( ( QueueHandle_t ) ( xSemaphore ), NULL, ( xBlockTime ), pdFALSE ) -/** @endcond */ +#define xSemaphoreTakeRecursive( xMutex, xBlockTime ) xQueueTakeMutexRecursive( ( xMutex ), ( xBlockTime ) ) /** * Macro to release a semaphore. The semaphore must have previously been @@ -397,47 +431,54 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @code{c} - * SemaphoreHandle_t xSemaphore = NULL; + * SemaphoreHandle_t xSemaphore = NULL; * - * void vATask( void * pvParameters ) - * { - * // Create the semaphore to guard a shared resource. - * vSemaphoreCreateBinary( xSemaphore ); + * 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. - * } - * } - * } + * 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 + * @cond + * \defgroup xSemaphoreGive xSemaphoreGive + * @endcond * \ingroup Semaphores */ -#define xSemaphoreGive( xSemaphore ) xQueueGenericSend( ( QueueHandle_t ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK ) +#define xSemaphoreGive( xSemaphore ) xQueueGenericSend( ( QueueHandle_t ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK ) /** + * @cond * semphr. h - *
xSemaphoreGiveRecursive( SemaphoreHandle_t xMutex )
+ * @code{c} + * xSemaphoreGiveRecursive( SemaphoreHandle_t xMutex ); + * @endcode + * @endcond * * Macro to recursively release, or 'give', a mutex type semaphore. * The mutex must have previously been created using a call to @@ -462,78 +503,64 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @code{c} - * SemaphoreHandle_t xMutex = NULL; + * 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 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. + * // 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. - * } - * } + * 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 + * @cond + * \defgroup xSemaphoreGiveRecursive xSemaphoreGiveRecursive + * @endcond * \ingroup Semaphores */ -#define xSemaphoreGiveRecursive( xMutex ) xQueueGiveMutexRecursive( ( xMutex ) ) - -/** @cond */ -/* - * xSemaphoreAltGive() is an alternative version of xSemaphoreGive(). - * - * The source code that implements the alternative (Alt) API is much - * simpler because it executes everything from within a critical section. - * This is the approach taken by many other RTOSes, but FreeRTOS.org has the - * preferred fully featured API too. The fully featured API has more - * complex code that takes longer to execute, but makes much less use of - * critical sections. Therefore the alternative API sacrifices interrupt - * responsiveness to gain execution speed, whereas the fully featured API - * sacrifices execution speed to ensure better interrupt responsiveness. - */ -#define xSemaphoreAltGive( xSemaphore ) xQueueAltGenericSend( ( QueueHandle_t ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK ) - -/** @endcond */ +#define xSemaphoreGiveRecursive( xMutex ) xQueueGiveMutexRecursive( ( xMutex ) ) /** * Macro to release a semaphore. The semaphore must have previously been @@ -557,68 +584,81 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @code{c} - * \#define LONG_TIME 0xffff - * \#define TICKS_TO_WAIT 10 - * SemaphoreHandle_t xSemaphore = NULL; - * - * // Repetitive task. - * void vATask( void * pvParameters ) + * #define LONG_TIME 0xffff + * #define TICKS_TO_WAIT 10 + * SemaphoreHandle_t xSemaphore = NULL; + * + * // Repetitive task. + * void vATask( void * pvParameters ) + * { + * for( ;; ) * { - * for( ;; ) - * { - * // We want this task to run every 10 ticks of a timer. The semaphore - * // was created before this task was started. + * // 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. + * // 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. - * } - * } + * // 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; + * // Timer ISR + * void vTimerISR( void * pvParameters ) + * { + * static uint8_t ucLocalTickCount = 0; + * static BaseType_t xHigherPriorityTaskWoken; * - * // A timer tick has occurred. + * // A timer tick has occurred. * - * // ... Do other time functions. + * // ... 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 ); + * // 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; - * } + * // 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. - * } + * 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 + * @cond + * \defgroup xSemaphoreGiveFromISR xSemaphoreGiveFromISR + * @endcond * \ingroup Semaphores */ -#define xSemaphoreGiveFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueGiveFromISR( ( QueueHandle_t ) ( xSemaphore ), ( pxHigherPriorityTaskWoken ) ) +#define xSemaphoreGiveFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueGiveFromISR( ( QueueHandle_t ) ( xSemaphore ), ( pxHigherPriorityTaskWoken ) ) /** + * @cond + * semphr. h + * @code{c} + * xSemaphoreTakeFromISR( + * SemaphoreHandle_t xSemaphore, + * BaseType_t *pxHigherPriorityTaskWoken + * ); + * @endcode + * @endcond + * * Macro to take a semaphore from an ISR. The semaphore must have * previously been created with a call to xSemaphoreCreateBinary() or * xSemaphoreCreateCounting(). @@ -643,17 +683,24 @@ typedef QueueHandle_t SemaphoreHandle_t; * @return pdTRUE if the semaphore was successfully taken, otherwise * pdFALSE */ -#define xSemaphoreTakeFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueReceiveFromISR( ( QueueHandle_t ) ( xSemaphore ), NULL, ( pxHigherPriorityTaskWoken ) ) +#define xSemaphoreTakeFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueReceiveFromISR( ( QueueHandle_t ) ( xSemaphore ), NULL, ( pxHigherPriorityTaskWoken ) ) /** - * Macro that implements a mutex semaphore by using the existing queue - * mechanism. + * @cond + * semphr. h + * @code{c} + * SemaphoreHandle_t xSemaphoreCreateMutex( void ); + * @endcode + * @endcond + * + * Creates a new mutex type semaphore instance, and returns a handle by which + * the new mutex can be referenced. * * Internally, within the FreeRTOS implementation, mutex semaphores use a block * of memory, in which the mutex structure is stored. If a mutex is created * using xSemaphoreCreateMutex() then the required memory is automatically * dynamically allocated inside the xSemaphoreCreateMutex() function. (see - * http://www.freertos.org/a00111.html). If a mutex is created using + * https://www.FreeRTOS.org/a00111.html). If a mutex is created using * xSemaphoreCreateMutexStatic() then the application writer must provided the * memory. xSemaphoreCreateMutexStatic() therefore allows a mutex to be created * without using any dynamic memory allocation. @@ -679,28 +726,38 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @code{c} - * SemaphoreHandle_t xSemaphore; + * 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(); + * 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. - * } + * if( xSemaphore != NULL ) + * { + * // The semaphore was created successfully. + * // The semaphore can now be used. * } + * } * @endcode + * @cond + * \defgroup xSemaphoreCreateMutex xSemaphoreCreateMutex + * @endcond * \ingroup Semaphores */ -#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - #define xSemaphoreCreateMutex() xQueueCreateMutex( queueQUEUE_TYPE_MUTEX ) +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + #define xSemaphoreCreateMutex() xQueueCreateMutex( queueQUEUE_TYPE_MUTEX ) #endif /** + * @cond + * semphr. h + * @code{c} + * SemaphoreHandle_t xSemaphoreCreateMutexStatic( StaticSemaphore_t *pxMutexBuffer ); + * @endcode + * @endcond + * * Creates a new mutex type semaphore instance, and returns a handle by which * the new mutex can be referenced. * @@ -708,7 +765,7 @@ typedef QueueHandle_t SemaphoreHandle_t; * of memory, in which the mutex structure is stored. If a mutex is created * using xSemaphoreCreateMutex() then the required memory is automatically * dynamically allocated inside the xSemaphoreCreateMutex() function. (see - * http://www.freertos.org/a00111.html). If a mutex is created using + * https://www.FreeRTOS.org/a00111.html). If a mutex is created using * xSemaphoreCreateMutexStatic() then the application writer must provided the * memory. xSemaphoreCreateMutexStatic() therefore allows a mutex to be created * without using any dynamic memory allocation. @@ -736,25 +793,28 @@ typedef QueueHandle_t SemaphoreHandle_t; * mutex is returned. If pxMutexBuffer was NULL then NULL is returned. * * Example usage: - * @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. - * } + * @code{c} + * 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 + * @cond + * \defgroup xSemaphoreCreateMutexStatic xSemaphoreCreateMutexStatic + * @endcond * \ingroup Semaphores */ - #if( configSUPPORT_STATIC_ALLOCATION == 1 ) - #define xSemaphoreCreateMutexStatic( pxMutexBuffer ) xQueueCreateMutexStatic( queueQUEUE_TYPE_MUTEX, ( pxMutexBuffer ) ) +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + #define xSemaphoreCreateMutexStatic( pxMutexBuffer ) xQueueCreateMutexStatic( queueQUEUE_TYPE_MUTEX, ( pxMutexBuffer ) ) #endif /* configSUPPORT_STATIC_ALLOCATION */ @@ -796,7 +856,7 @@ typedef QueueHandle_t SemaphoreHandle_t; * service routines. * * @return xSemaphore Handle to the created mutex semaphore. Should be of type - * SemaphoreHandle_t. + * SemaphoreHandle_t. * * Example usage: * @code{c} @@ -818,7 +878,7 @@ typedef QueueHandle_t SemaphoreHandle_t; * \ingroup Semaphores */ #if( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_RECURSIVE_MUTEXES == 1 ) ) - #define xSemaphoreCreateRecursiveMutex() xQueueCreateMutex( queueQUEUE_TYPE_RECURSIVE_MUTEX ) + #define xSemaphoreCreateRecursiveMutex() xQueueCreateMutex( queueQUEUE_TYPE_RECURSIVE_MUTEX ) #endif /** @@ -830,7 +890,7 @@ typedef QueueHandle_t SemaphoreHandle_t; * created using xSemaphoreCreateRecursiveMutex() then the required memory is * automatically dynamically allocated inside the * xSemaphoreCreateRecursiveMutex() function. (see - * http://www.freertos.org/a00111.html). If a recursive mutex is created using + * https://www.FreeRTOS.org/a00111.html). If a recursive mutex is created using * xSemaphoreCreateRecursiveMutexStatic() then the application writer must * provide the memory that will get used by the mutex. * xSemaphoreCreateRecursiveMutexStatic() therefore allows a recursive mutex to @@ -867,7 +927,7 @@ typedef QueueHandle_t SemaphoreHandle_t; * returned. * * Example usage: - * @code + * @code{c} * SemaphoreHandle_t xSemaphore; * StaticSemaphore_t xMutexBuffer; * @@ -886,24 +946,31 @@ typedef QueueHandle_t SemaphoreHandle_t; * @endcode * \ingroup Semaphores */ -#if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_RECURSIVE_MUTEXES == 1 ) ) - #define xSemaphoreCreateRecursiveMutexStatic( pxStaticSemaphore ) xQueueCreateMutexStatic( queueQUEUE_TYPE_RECURSIVE_MUTEX, pxStaticSemaphore ) +#if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_RECURSIVE_MUTEXES == 1 ) ) + #define xSemaphoreCreateRecursiveMutexStatic( pxStaticSemaphore ) xQueueCreateMutexStatic( queueQUEUE_TYPE_RECURSIVE_MUTEX, pxStaticSemaphore ) #endif /* configSUPPORT_STATIC_ALLOCATION */ /** + * @cond + * semphr. h + * @code{c} + * SemaphoreHandle_t xSemaphoreCreateCounting( UBaseType_t uxMaxCount, UBaseType_t uxInitialCount ); + * @endcode + * @endcond + * * Creates a new counting semaphore instance, and returns a handle by which the * new counting semaphore can be referenced. * * In many usage scenarios it is faster and more memory efficient to use a * direct to task notification in place of a counting semaphore! - * http://www.freertos.org/RTOS-task-notifications.html + * https://www.FreeRTOS.org/RTOS-task-notifications.html * * Internally, within the FreeRTOS implementation, counting semaphores use a * block of memory, in which the counting semaphore structure is stored. If a * counting semaphore is created using xSemaphoreCreateCounting() then the * required memory is automatically dynamically allocated inside the * xSemaphoreCreateCounting() function. (see - * http://www.freertos.org/a00111.html). If a counting semaphore is created + * https://www.FreeRTOS.org/a00111.html). If a counting semaphore is created * using xSemaphoreCreateCountingStatic() then the application writer can * instead optionally provide the memory that will get used by the counting * semaphore. xSemaphoreCreateCountingStatic() therefore allows a counting @@ -942,44 +1009,54 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @code{c} - * SemaphoreHandle_t xSemaphore; + * SemaphoreHandle_t xSemaphore; * - * void vATask( void * pvParameters ) - * { - * SemaphoreHandle_t xSemaphore = NULL; + * 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 ); + * // 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. - * } + * if( xSemaphore != NULL ) + * { + * // The semaphore was created successfully. + * // The semaphore can now be used. * } + * } * @endcode + * @cond + * \defgroup xSemaphoreCreateCounting xSemaphoreCreateCounting + * @endcond * \ingroup Semaphores */ -#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - #define xSemaphoreCreateCounting( uxMaxCount, uxInitialCount ) xQueueCreateCountingSemaphore( ( uxMaxCount ), ( uxInitialCount ) ) +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + #define xSemaphoreCreateCounting( uxMaxCount, uxInitialCount ) xQueueCreateCountingSemaphore( ( uxMaxCount ), ( uxInitialCount ) ) #endif /** + * @cond + * semphr. h + * @code{c} + * SemaphoreHandle_t xSemaphoreCreateCountingStatic( UBaseType_t uxMaxCount, UBaseType_t uxInitialCount, StaticSemaphore_t *pxSemaphoreBuffer ); + * @endcode + * @endcond + * * Creates a new counting semaphore instance, and returns a handle by which the * new counting semaphore can be referenced. * * In many usage scenarios it is faster and more memory efficient to use a * direct to task notification in place of a counting semaphore! - * http://www.freertos.org/RTOS-task-notifications.html + * https://www.FreeRTOS.org/RTOS-task-notifications.html * * Internally, within the FreeRTOS implementation, counting semaphores use a * block of memory, in which the counting semaphore structure is stored. If a * counting semaphore is created using xSemaphoreCreateCounting() then the * required memory is automatically dynamically allocated inside the * xSemaphoreCreateCounting() function. (see - * http://www.freertos.org/a00111.html). If a counting semaphore is created + * https://www.FreeRTOS.org/a00111.html). If a counting semaphore is created * using xSemaphoreCreateCountingStatic() then the application writer must * provide the memory. xSemaphoreCreateCountingStatic() therefore allows a * counting semaphore to be created without using any dynamic memory allocation. @@ -1022,42 +1099,62 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @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. - * } + * 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 + * @cond + * \defgroup xSemaphoreCreateCountingStatic xSemaphoreCreateCountingStatic + * @endcond * \ingroup Semaphores */ -#if( configSUPPORT_STATIC_ALLOCATION == 1 ) - #define xSemaphoreCreateCountingStatic( uxMaxCount, uxInitialCount, pxSemaphoreBuffer ) xQueueCreateCountingSemaphoreStatic( ( uxMaxCount ), ( uxInitialCount ), ( pxSemaphoreBuffer ) ) +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + #define xSemaphoreCreateCountingStatic( uxMaxCount, uxInitialCount, pxSemaphoreBuffer ) xQueueCreateCountingSemaphoreStatic( ( uxMaxCount ), ( uxInitialCount ), ( pxSemaphoreBuffer ) ) #endif /* configSUPPORT_STATIC_ALLOCATION */ /** + * @cond + * semphr. h + * @code{c} + * void vSemaphoreDelete( SemaphoreHandle_t xSemaphore ); + * @endcode + * @endcond + * * 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. * + * @cond + * \defgroup vSemaphoreDelete vSemaphoreDelete + * @endcond * \ingroup Semaphores */ -#define vSemaphoreDelete( xSemaphore ) vQueueDelete( ( QueueHandle_t ) ( xSemaphore ) ) +#define vSemaphoreDelete( xSemaphore ) vQueueDelete( ( QueueHandle_t ) ( xSemaphore ) ) /** + * @cond + * semphr.h + * @code{c} + * TaskHandle_t xSemaphoreGetMutexHolder( SemaphoreHandle_t xMutex ); + * @endcode + * @endcond + * * 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. @@ -1067,20 +1164,30 @@ typedef QueueHandle_t SemaphoreHandle_t; * the holder may change between the function exiting and the returned value * being tested. */ -#define xSemaphoreGetMutexHolder( xSemaphore ) xQueueGetMutexHolder( ( xSemaphore ) ) +#define xSemaphoreGetMutexHolder( xSemaphore ) xQueueGetMutexHolder( ( xSemaphore ) ) /** + * @cond + * semphr.h + * @code{c} + * TaskHandle_t xSemaphoreGetMutexHolderFromISR( SemaphoreHandle_t xMutex ); + * @endcode + * @endcond * * 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. * */ -#define xSemaphoreGetMutexHolderFromISR( xSemaphore ) xQueueGetMutexHolderFromISR( ( xSemaphore ) ) +#define xSemaphoreGetMutexHolderFromISR( xSemaphore ) xQueueGetMutexHolderFromISR( ( xSemaphore ) ) /** + * @cond * semphr.h - *
UBaseType_t uxSemaphoreGetCount( SemaphoreHandle_t xSemaphore );
+ * @code{c} + * UBaseType_t uxSemaphoreGetCount( SemaphoreHandle_t xSemaphore ); + * @endcode + * @endcond * * If the semaphore is a counting semaphore then uxSemaphoreGetCount() returns * its current count value. If the semaphore is a binary semaphore then @@ -1088,6 +1195,6 @@ typedef QueueHandle_t SemaphoreHandle_t; * semaphore is not available. * */ -#define uxSemaphoreGetCount( xSemaphore ) uxQueueMessagesWaiting( ( QueueHandle_t ) ( xSemaphore ) ) +#define uxSemaphoreGetCount( xSemaphore ) uxQueueMessagesWaiting( ( QueueHandle_t ) ( xSemaphore ) ) #endif /* SEMAPHORE_H */ diff --git a/tools/sdk/esp32c3/include/freertos/include/freertos/stack_macros.h b/tools/sdk/esp32c3/include/freertos/include/freertos/stack_macros.h index b8eca4246f9..249c4ef840d 100644 --- a/tools/sdk/esp32c3/include/freertos/include/freertos/stack_macros.h +++ b/tools/sdk/esp32c3/include/freertos/include/freertos/stack_macros.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ #ifndef STACK_MACROS_H @@ -46,94 +45,94 @@ #if( configCHECK_FOR_STACK_OVERFLOW == 0 ) - /* FreeRTOSConfig.h is not set to check for stack overflows. */ - #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() - #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() + /* FreeRTOSConfig.h is not set to check for stack overflows. */ + #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() + #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() #endif /* configCHECK_FOR_STACK_OVERFLOW == 0 */ /*-----------------------------------------------------------*/ #if( configCHECK_FOR_STACK_OVERFLOW == 1 ) - /* FreeRTOSConfig.h is only set to use the first method of - overflow checking. */ - #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() + /* FreeRTOSConfig.h is only set to use the first method of + overflow checking. */ + #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() #endif /*-----------------------------------------------------------*/ #if( ( configCHECK_FOR_STACK_OVERFLOW > 0 ) && ( portSTACK_GROWTH < 0 ) ) - /* Only the current stack state is to be checked. */ - #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() \ - { \ - /* Is the currently saved stack pointer within the stack limit? */ \ - if( pxCurrentTCB[ xPortGetCoreID() ]->pxTopOfStack <= pxCurrentTCB[ xPortGetCoreID() ]->pxStack ) \ - { \ - vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB[ xPortGetCoreID() ], pxCurrentTCB[ xPortGetCoreID() ]->pcTaskName ); \ - } \ - } +/* Only the current stack state is to be checked. */ + #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() \ + { \ + /* Is the currently saved stack pointer within the stack limit? */ \ + if( pxCurrentTCB[ xPortGetCoreID() ]->pxTopOfStack <= pxCurrentTCB[ xPortGetCoreID() ]->pxStack ) \ + { \ + vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB[ xPortGetCoreID() ], pxCurrentTCB[ xPortGetCoreID() ]->pcTaskName ); \ + } \ + } #endif /* configCHECK_FOR_STACK_OVERFLOW > 0 */ /*-----------------------------------------------------------*/ #if( ( configCHECK_FOR_STACK_OVERFLOW > 0 ) && ( portSTACK_GROWTH > 0 ) ) - /* Only the current stack state is to be checked. */ - #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() \ - { \ - \ - /* Is the currently saved stack pointer within the stack limit? */ \ - if( pxCurrentTCB[ xPortGetCoreID() ]->pxTopOfStack >= pxCurrentTCB[ xPortGetCoreID() ]->pxEndOfStack ) \ - { \ - vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB[ xPortGetCoreID() ], pxCurrentTCB[ xPortGetCoreID() ]->pcTaskName ); \ - } \ - } +/* Only the current stack state is to be checked. */ + #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() \ + { \ + \ + /* Is the currently saved stack pointer within the stack limit? */ \ + if( pxCurrentTCB[ xPortGetCoreID() ]->pxTopOfStack >= pxCurrentTCB[ xPortGetCoreID() ]->pxEndOfStack ) \ + { \ + vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB[ xPortGetCoreID() ], pxCurrentTCB[ xPortGetCoreID() ]->pcTaskName ); \ + } \ + } #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ /*-----------------------------------------------------------*/ -#if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) ) - - #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() \ - { \ - static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ - \ - \ - /* Has the extremity of the task stack ever been written over? */ \ - if( memcmp( ( void * ) pxCurrentTCB[ xPortGetCoreID() ]->pxStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ - { \ - vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB[ xPortGetCoreID() ], pxCurrentTCB[ xPortGetCoreID() ]->pcTaskName ); \ - } \ - } +#if ( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) ) + + #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() \ + { \ + static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ + \ + \ + /* Has the extremity of the task stack ever been written over? */ \ + if( memcmp( ( void * ) pxCurrentTCB[ xPortGetCoreID() ]->pxStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ + { \ + vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB[ xPortGetCoreID() ], pxCurrentTCB[ xPortGetCoreID() ]->pcTaskName ); \ + } \ + } #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ /*-----------------------------------------------------------*/ -#if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) ) - - #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() \ - { \ - int8_t *pcEndOfStack = ( int8_t * ) pxCurrentTCB[ xPortGetCoreID() ]->pxEndOfStack; \ - static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ - \ - \ - pcEndOfStack -= sizeof( ucExpectedStackBytes ); \ - \ - /* Has the extremity of the task stack ever been written over? */ \ - if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ - { \ - vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB[ xPortGetCoreID() ], pxCurrentTCB[ xPortGetCoreID() ]->pcTaskName ); \ - } \ - } +#if ( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) ) + + #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() \ + { \ + int8_t *pcEndOfStack = ( int8_t * ) pxCurrentTCB[ xPortGetCoreID() ]->pxEndOfStack; \ + static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ + \ + \ + pcEndOfStack -= sizeof( ucExpectedStackBytes ); \ + \ + /* Has the extremity of the task stack ever been written over? */ \ + if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ + { \ + vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB[ xPortGetCoreID() ], pxCurrentTCB[ xPortGetCoreID() ]->pcTaskName ); \ + } \ + } #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ diff --git a/tools/sdk/esp32c3/include/freertos/include/freertos/stream_buffer.h b/tools/sdk/esp32c3/include/freertos/include/freertos/stream_buffer.h index 1a3d8f5190c..9e58cff120c 100644 --- a/tools/sdk/esp32c3/include/freertos/include/freertos/stream_buffer.h +++ b/tools/sdk/esp32c3/include/freertos/include/freertos/stream_buffer.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ /* @@ -43,7 +42,7 @@ * (such as xStreamBufferSend()) inside a critical section and set the send * block time to 0. Likewise, if there are to be multiple different readers * then the application writer must place each call to a reading API function - * (such as xStreamBufferRead()) inside a critical section section and set the + * (such as xStreamBufferReceive()) inside a critical section section and set the * receive block time to 0. * */ @@ -52,12 +51,14 @@ #define STREAM_BUFFER_H #ifndef INC_FREERTOS_H - #error "include FreeRTOS.h must appear in source files before include stream_buffer.h" + #error "include FreeRTOS.h must appear in source files before include stream_buffer.h" #endif +/* *INDENT-OFF* */ #if defined( __cplusplus ) -extern "C" { + extern "C" { #endif +/* *INDENT-ON* */ /** * Type by which stream buffers are referenced. For example, a call to @@ -68,7 +69,16 @@ extern "C" { struct StreamBufferDef_t; typedef struct StreamBufferDef_t * StreamBufferHandle_t; + /** + * @cond + * message_buffer.h + * + * @code{c} + * StreamBufferHandle_t xStreamBufferCreate( size_t xBufferSizeBytes, size_t xTriggerLevelBytes ); + * @endcode + * @endcond + * * Creates a new stream buffer using dynamically allocated memory. See * xStreamBufferCreateStatic() for a version that uses statically allocated * memory (memory that is allocated at compile time). @@ -103,32 +113,46 @@ typedef struct StreamBufferDef_t * StreamBufferHandle_t; * Example use: * @code{c} * - * void vAFunction( void ) - * { - * StreamBufferHandle_t xStreamBuffer; - * const size_t xStreamBufferSizeBytes = 100, xTriggerLevel = 10; - * - * // Create a stream buffer that can hold 100 bytes. The memory used to hold - * // both the stream buffer structure and the data in the stream buffer is - * // allocated dynamically. - * xStreamBuffer = xStreamBufferCreate( xStreamBufferSizeBytes, xTriggerLevel ); - * - * if( xStreamBuffer == NULL ) - * { - * // There was not enough heap memory space available to create the - * // stream buffer. - * } - * else - * { - * // The stream buffer was created successfully and can now be used. - * } - * } + * void vAFunction( void ) + * { + * StreamBufferHandle_t xStreamBuffer; + * const size_t xStreamBufferSizeBytes = 100, xTriggerLevel = 10; + * + * // Create a stream buffer that can hold 100 bytes. The memory used to hold + * // both the stream buffer structure and the data in the stream buffer is + * // allocated dynamically. + * xStreamBuffer = xStreamBufferCreate( xStreamBufferSizeBytes, xTriggerLevel ); + * + * if( xStreamBuffer == NULL ) + * { + * // There was not enough heap memory space available to create the + * // stream buffer. + * } + * else + * { + * // The stream buffer was created successfully and can now be used. + * } + * } * @endcode + * @cond + * \defgroup xStreamBufferCreate xStreamBufferCreate + * @endcond * \ingroup StreamBufferManagement */ -#define xStreamBufferCreate( xBufferSizeBytes, xTriggerLevelBytes ) xStreamBufferGenericCreate( xBufferSizeBytes, xTriggerLevelBytes, pdFALSE ) +#define xStreamBufferCreate( xBufferSizeBytes, xTriggerLevelBytes ) xStreamBufferGenericCreate( xBufferSizeBytes, xTriggerLevelBytes, pdFALSE ) /** + * @cond + * stream_buffer.h + * + * @code{c} + * StreamBufferHandle_t xStreamBufferCreateStatic( size_t xBufferSizeBytes, + * size_t xTriggerLevelBytes, + * uint8_t *pucStreamBufferStorageArea, + * StaticStreamBuffer_t *pxStaticStreamBuffer ); + * @endcode + * @endcond + * * Creates a new stream buffer using statically allocated memory. See * xStreamBufferCreate() for a version that uses dynamically allocated memory. * @@ -167,40 +191,55 @@ typedef struct StreamBufferDef_t * StreamBufferHandle_t; * Example use: * @code{c} * - * // Used to dimension the array used to hold the streams. The available space - * // will actually be one less than this, so 999. - * #define STORAGE_SIZE_BYTES 1000 + * // Used to dimension the array used to hold the streams. The available space + * // will actually be one less than this, so 999. + * #define STORAGE_SIZE_BYTES 1000 * - * // Defines the memory that will actually hold the streams within the stream - * // buffer. - * static uint8_t ucStorageBuffer[ STORAGE_SIZE_BYTES ]; + * // Defines the memory that will actually hold the streams within the stream + * // buffer. + * static uint8_t ucStorageBuffer[ STORAGE_SIZE_BYTES ]; * - * // The variable used to hold the stream buffer structure. - * StaticStreamBuffer_t xStreamBufferStruct; + * // The variable used to hold the stream buffer structure. + * StaticStreamBuffer_t xStreamBufferStruct; * - * void MyFunction( void ) - * { - * StreamBufferHandle_t xStreamBuffer; - * const size_t xTriggerLevel = 1; + * void MyFunction( void ) + * { + * StreamBufferHandle_t xStreamBuffer; + * const size_t xTriggerLevel = 1; * - * xStreamBuffer = xStreamBufferCreateStatic( sizeof( ucBufferStorage ), - * xTriggerLevel, - * ucBufferStorage, - * &xStreamBufferStruct ); + * xStreamBuffer = xStreamBufferCreateStatic( sizeof( ucBufferStorage ), + * xTriggerLevel, + * ucBufferStorage, + * &xStreamBufferStruct ); * - * // As neither the pucStreamBufferStorageArea or pxStaticStreamBuffer - * // parameters were NULL, xStreamBuffer will not be NULL, and can be used to - * // reference the created stream buffer in other stream buffer API calls. + * // As neither the pucStreamBufferStorageArea or pxStaticStreamBuffer + * // parameters were NULL, xStreamBuffer will not be NULL, and can be used to + * // reference the created stream buffer in other stream buffer API calls. * - * // Other code that uses the stream buffer can go here. - * } + * // Other code that uses the stream buffer can go here. + * } * * @endcode + * @cond + * \defgroup xStreamBufferCreateStatic xStreamBufferCreateStatic + * @endcond * \ingroup StreamBufferManagement */ -#define xStreamBufferCreateStatic( xBufferSizeBytes, xTriggerLevelBytes, pucStreamBufferStorageArea, pxStaticStreamBuffer ) xStreamBufferGenericCreateStatic( xBufferSizeBytes, xTriggerLevelBytes, pdFALSE, pucStreamBufferStorageArea, pxStaticStreamBuffer ) +#define xStreamBufferCreateStatic( xBufferSizeBytes, xTriggerLevelBytes, pucStreamBufferStorageArea, pxStaticStreamBuffer ) \ + xStreamBufferGenericCreateStatic( xBufferSizeBytes, xTriggerLevelBytes, pdFALSE, pucStreamBufferStorageArea, pxStaticStreamBuffer ) /** + * @cond + * stream_buffer.h + * + * @code{c} + * size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, + * const void *pvTxData, + * size_t xDataLengthBytes, + * TickType_t xTicksToWait ); + * @endcode + * @endcond + * * Sends bytes to a stream buffer. The bytes are copied into the stream buffer. * * ***NOTE***: Uniquely among FreeRTOS objects, the stream buffer @@ -215,7 +254,7 @@ typedef struct StreamBufferDef_t * StreamBufferHandle_t; * (such as xStreamBufferSend()) inside a critical section and set the send * block time to 0. Likewise, if there are to be multiple different readers * then the application writer must place each call to a reading API function - * (such as xStreamBufferRead()) inside a critical section and set the receive + * (such as xStreamBufferReceive()) inside a critical section and set the receive * block time to 0. * * Use xStreamBufferSend() to write to a stream buffer from a task. Use @@ -250,44 +289,58 @@ typedef struct StreamBufferDef_t * StreamBufferHandle_t; * * Example use: * @code{c} - * void vAFunction( StreamBufferHandle_t xStreamBuffer ) - * { - * size_t xBytesSent; - * uint8_t ucArrayToSend[] = { 0, 1, 2, 3 }; - * char *pcStringToSend = "String to send"; - * const TickType_t x100ms = pdMS_TO_TICKS( 100 ); - * - * // Send an array to the stream buffer, blocking for a maximum of 100ms to - * // wait for enough space to be available in the stream buffer. - * xBytesSent = xStreamBufferSend( xStreamBuffer, ( void * ) ucArrayToSend, sizeof( ucArrayToSend ), x100ms ); - * - * if( xBytesSent != sizeof( ucArrayToSend ) ) - * { - * // The call to xStreamBufferSend() times out before there was enough - * // space in the buffer for the data to be written, but it did - * // successfully write xBytesSent bytes. - * } - * - * // Send the string to the stream buffer. Return immediately if there is not - * // enough space in the buffer. - * xBytesSent = xStreamBufferSend( xStreamBuffer, ( void * ) pcStringToSend, strlen( pcStringToSend ), 0 ); - * - * if( xBytesSent != strlen( pcStringToSend ) ) - * { - * // The entire string could not be added to the stream buffer because - * // there was not enough free space in the buffer, but xBytesSent bytes - * // were sent. Could try again to send the remaining bytes. - * } - * } + * void vAFunction( StreamBufferHandle_t xStreamBuffer ) + * { + * size_t xBytesSent; + * uint8_t ucArrayToSend[] = { 0, 1, 2, 3 }; + * char *pcStringToSend = "String to send"; + * const TickType_t x100ms = pdMS_TO_TICKS( 100 ); + * + * // Send an array to the stream buffer, blocking for a maximum of 100ms to + * // wait for enough space to be available in the stream buffer. + * xBytesSent = xStreamBufferSend( xStreamBuffer, ( void * ) ucArrayToSend, sizeof( ucArrayToSend ), x100ms ); + * + * if( xBytesSent != sizeof( ucArrayToSend ) ) + * { + * // The call to xStreamBufferSend() times out before there was enough + * // space in the buffer for the data to be written, but it did + * // successfully write xBytesSent bytes. + * } + * + * // Send the string to the stream buffer. Return immediately if there is not + * // enough space in the buffer. + * xBytesSent = xStreamBufferSend( xStreamBuffer, ( void * ) pcStringToSend, strlen( pcStringToSend ), 0 ); + * + * if( xBytesSent != strlen( pcStringToSend ) ) + * { + * // The entire string could not be added to the stream buffer because + * // there was not enough free space in the buffer, but xBytesSent bytes + * // were sent. Could try again to send the remaining bytes. + * } + * } * @endcode + * @cond + * \defgroup xStreamBufferSend xStreamBufferSend + * @endcond * \ingroup StreamBufferManagement */ size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, - const void *pvTxData, - size_t xDataLengthBytes, - TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; + const void * pvTxData, + size_t xDataLengthBytes, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer, + * const void *pvTxData, + * size_t xDataLengthBytes, + * BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * @endcond + * * Interrupt safe version of the API function that sends a stream of bytes to * the stream buffer. * @@ -303,7 +356,7 @@ size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, * (such as xStreamBufferSend()) inside a critical section and set the send * block time to 0. Likewise, if there are to be multiple different readers * then the application writer must place each call to a reading API function - * (such as xStreamBufferRead()) inside a critical section and set the receive + * (such as xStreamBufferReceive()) inside a critical section and set the receive * block time to 0. * * Use xStreamBufferSend() to write to a stream buffer from a task. Use @@ -339,46 +392,60 @@ size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, * * Example use: * @code{c} - * //A stream buffer that has already been created. - * StreamBufferHandle_t xStreamBuffer; - * - * void vAnInterruptServiceRoutine( void ) - * { - * size_t xBytesSent; - * char *pcStringToSend = "String to send"; - * BaseType_t xHigherPriorityTaskWoken = pdFALSE; // Initialised to pdFALSE. - * - * // Attempt to send the string to the stream buffer. - * xBytesSent = xStreamBufferSendFromISR( xStreamBuffer, - * ( void * ) pcStringToSend, - * strlen( pcStringToSend ), - * &xHigherPriorityTaskWoken ); - * - * if( xBytesSent != strlen( pcStringToSend ) ) - * { - * // There was not enough free space in the stream buffer for the entire - * // string to be written, ut xBytesSent bytes were written. - * } - * - * // If xHigherPriorityTaskWoken was set to pdTRUE inside - * // xStreamBufferSendFromISR() then a task that has a priority above the - * // priority of the currently executing task was unblocked and a context - * // switch should be performed to ensure the ISR returns to the unblocked - * // task. In most FreeRTOS ports this is done by simply passing - * // xHigherPriorityTaskWoken into taskYIELD_FROM_ISR(), which will test the - * // variables value, and perform the context switch if necessary. Check the - * // documentation for the port in use for port specific instructions. - * taskYIELD_FROM_ISR( xHigherPriorityTaskWoken ); - * } + * // A stream buffer that has already been created. + * StreamBufferHandle_t xStreamBuffer; + * + * void vAnInterruptServiceRoutine( void ) + * { + * size_t xBytesSent; + * char *pcStringToSend = "String to send"; + * BaseType_t xHigherPriorityTaskWoken = pdFALSE; // Initialised to pdFALSE. + * + * // Attempt to send the string to the stream buffer. + * xBytesSent = xStreamBufferSendFromISR( xStreamBuffer, + * ( void * ) pcStringToSend, + * strlen( pcStringToSend ), + * &xHigherPriorityTaskWoken ); + * + * if( xBytesSent != strlen( pcStringToSend ) ) + * { + * // There was not enough free space in the stream buffer for the entire + * // string to be written, ut xBytesSent bytes were written. + * } + * + * // If xHigherPriorityTaskWoken was set to pdTRUE inside + * // xStreamBufferSendFromISR() then a task that has a priority above the + * // priority of the currently executing task was unblocked and a context + * // switch should be performed to ensure the ISR returns to the unblocked + * // task. In most FreeRTOS ports this is done by simply passing + * // xHigherPriorityTaskWoken into taskYIELD_FROM_ISR(), which will test the + * // variables value, and perform the context switch if necessary. Check the + * // documentation for the port in use for port specific instructions. + * taskYIELD_FROM_ISR( xHigherPriorityTaskWoken ); + * } * @endcode + * @cond + * \defgroup xStreamBufferSendFromISR xStreamBufferSendFromISR + * @endcond * \ingroup StreamBufferManagement */ size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer, - const void *pvTxData, - size_t xDataLengthBytes, - BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; + const void * pvTxData, + size_t xDataLengthBytes, + BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * size_t xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer, + * void *pvRxData, + * size_t xBufferLengthBytes, + * TickType_t xTicksToWait ); + * @endcode + * @endcond + * * Receives bytes from a stream buffer. * * ***NOTE***: Uniquely among FreeRTOS objects, the stream buffer @@ -393,7 +460,7 @@ size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer, * (such as xStreamBufferSend()) inside a critical section and set the send * block time to 0. Likewise, if there are to be multiple different readers * then the application writer must place each call to a reading API function - * (such as xStreamBufferRead()) inside a critical section and set the receive + * (such as xStreamBufferReceive()) inside a critical section and set the receive * block time to 0. * * Use xStreamBufferReceive() to read from a stream buffer from a task. Use @@ -428,37 +495,50 @@ size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer, * * Example use: * @code{c} - * void vAFunction( StreamBuffer_t xStreamBuffer ) - * { - * uint8_t ucRxData[ 20 ]; - * size_t xReceivedBytes; - * const TickType_t xBlockTime = pdMS_TO_TICKS( 20 ); - * - * // Receive up to another sizeof( ucRxData ) bytes from the stream buffer. - * // Wait in the Blocked state (so not using any CPU processing time) for a - * // maximum of 100ms for the full sizeof( ucRxData ) number of bytes to be - * // available. - * xReceivedBytes = xStreamBufferReceive( xStreamBuffer, - * ( void * ) ucRxData, - * sizeof( ucRxData ), - * xBlockTime ); - * - * if( xReceivedBytes > 0 ) - * { - * // A ucRxData contains another xRecievedBytes bytes of data, which can - * // be processed here.... - * } - * } + * void vAFunction( StreamBuffer_t xStreamBuffer ) + * { + * uint8_t ucRxData[ 20 ]; + * size_t xReceivedBytes; + * const TickType_t xBlockTime = pdMS_TO_TICKS( 20 ); + * + * // Receive up to another sizeof( ucRxData ) bytes from the stream buffer. + * // Wait in the Blocked state (so not using any CPU processing time) for a + * // maximum of 100ms for the full sizeof( ucRxData ) number of bytes to be + * // available. + * xReceivedBytes = xStreamBufferReceive( xStreamBuffer, + * ( void * ) ucRxData, + * sizeof( ucRxData ), + * xBlockTime ); + * + * if( xReceivedBytes > 0 ) + * { + * // A ucRxData contains another xRecievedBytes bytes of data, which can + * // be processed here.... + * } + * } * @endcode + * @cond + * \defgroup xStreamBufferReceive xStreamBufferReceive + * @endcond * \ingroup StreamBufferManagement */ size_t xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer, - void *pvRxData, - size_t xBufferLengthBytes, - TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; - + void * pvRxData, + size_t xBufferLengthBytes, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * size_t xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer, + * void *pvRxData, + * size_t xBufferLengthBytes, + * BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * @endcond + * * An interrupt safe version of the API function that receives bytes from a * stream buffer. * @@ -495,46 +575,57 @@ size_t xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer, * * Example use: * @code{c} - * // A stream buffer that has already been created. - * StreamBuffer_t xStreamBuffer; - * - * void vAnInterruptServiceRoutine( void ) - * { - * uint8_t ucRxData[ 20 ]; - * size_t xReceivedBytes; - * BaseType_t xHigherPriorityTaskWoken = pdFALSE; // Initialised to pdFALSE. - * - * // Receive the next stream from the stream buffer. - * xReceivedBytes = xStreamBufferReceiveFromISR( xStreamBuffer, - * ( void * ) ucRxData, - * sizeof( ucRxData ), - * &xHigherPriorityTaskWoken ); - * - * if( xReceivedBytes > 0 ) - * { - * // ucRxData contains xReceivedBytes read from the stream buffer. - * // Process the stream here.... - * } - * - * // If xHigherPriorityTaskWoken was set to pdTRUE inside - * // xStreamBufferReceiveFromISR() then a task that has a priority above the - * // priority of the currently executing task was unblocked and a context - * // switch should be performed to ensure the ISR returns to the unblocked - * // task. In most FreeRTOS ports this is done by simply passing - * // xHigherPriorityTaskWoken into taskYIELD_FROM_ISR(), which will test the - * // variables value, and perform the context switch if necessary. Check the - * // documentation for the port in use for port specific instructions. - * taskYIELD_FROM_ISR( xHigherPriorityTaskWoken ); - * } + * // A stream buffer that has already been created. + * StreamBuffer_t xStreamBuffer; + * + * void vAnInterruptServiceRoutine( void ) + * { + * uint8_t ucRxData[ 20 ]; + * size_t xReceivedBytes; + * BaseType_t xHigherPriorityTaskWoken = pdFALSE; // Initialised to pdFALSE. + * + * // Receive the next stream from the stream buffer. + * xReceivedBytes = xStreamBufferReceiveFromISR( xStreamBuffer, + * ( void * ) ucRxData, + * sizeof( ucRxData ), + * &xHigherPriorityTaskWoken ); + * + * if( xReceivedBytes > 0 ) + * { + * // ucRxData contains xReceivedBytes read from the stream buffer. + * // Process the stream here.... + * } + * + * // If xHigherPriorityTaskWoken was set to pdTRUE inside + * // xStreamBufferReceiveFromISR() then a task that has a priority above the + * // priority of the currently executing task was unblocked and a context + * // switch should be performed to ensure the ISR returns to the unblocked + * // task. In most FreeRTOS ports this is done by simply passing + * // xHigherPriorityTaskWoken into taskYIELD_FROM_ISR(), which will test the + * // variables value, and perform the context switch if necessary. Check the + * // documentation for the port in use for port specific instructions. + * taskYIELD_FROM_ISR( xHigherPriorityTaskWoken ); + * } * @endcode + * @cond + * \defgroup xStreamBufferReceiveFromISR xStreamBufferReceiveFromISR + * @endcond * \ingroup StreamBufferManagement */ size_t xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer, - void *pvRxData, - size_t xBufferLengthBytes, - BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; + void * pvRxData, + size_t xBufferLengthBytes, + BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * void vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ); + * @endcode + * @endcond + * * Deletes a stream buffer that was previously created using a call to * xStreamBufferCreate() or xStreamBufferCreateStatic(). If the stream * buffer was created using dynamic memory (that is, by xStreamBufferCreate()), @@ -545,11 +636,22 @@ size_t xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer, * * @param xStreamBuffer The handle of the stream buffer to be deleted. * + * @cond + * \defgroup vStreamBufferDelete vStreamBufferDelete + * @endcond * \ingroup StreamBufferManagement */ void vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * BaseType_t xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ); + * @endcode + * @endcond + * * Queries a stream buffer to see if it is full. A stream buffer is full if it * does not have any free space, and therefore cannot accept any more data. * @@ -558,11 +660,22 @@ void vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTI * @return If the stream buffer is full then pdTRUE is returned. Otherwise * pdFALSE is returned. * + * @cond + * \defgroup xStreamBufferIsFull xStreamBufferIsFull + * @endcond * \ingroup StreamBufferManagement */ BaseType_t xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * BaseType_t xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ); + * @endcode + * @endcond + * * Queries a stream buffer to see if it is empty. A stream buffer is empty if * it does not contain any data. * @@ -571,11 +684,22 @@ BaseType_t xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_ * @return If the stream buffer is empty then pdTRUE is returned. Otherwise * pdFALSE is returned. * + * @cond + * \defgroup xStreamBufferIsEmpty xStreamBufferIsEmpty + * @endcond * \ingroup StreamBufferManagement */ BaseType_t xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * BaseType_t xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ); + * @endcode + * @endcond + * * Resets a stream buffer to its initial, empty, state. Any data that was in * the stream buffer is discarded. A stream buffer can only be reset if there * are no tasks blocked waiting to either send to or receive from the stream @@ -587,11 +711,22 @@ BaseType_t xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED * a task blocked waiting to send to or read from the stream buffer then the * stream buffer is not reset and pdFAIL is returned. * + * @cond + * \defgroup xStreamBufferReset xStreamBufferReset + * @endcond * \ingroup StreamBufferManagement */ BaseType_t xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * size_t xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ); + * @endcode + * @endcond + * * Queries a stream buffer to see how much free space it contains, which is * equal to the amount of data that can be sent to the stream buffer before it * is full. @@ -601,12 +736,22 @@ BaseType_t xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_F * @return The number of bytes that can be written to the stream buffer before * the stream buffer would be full. * + * @cond * \defgroup xStreamBufferSpacesAvailable xStreamBufferSpacesAvailable + * @endcond * \ingroup StreamBufferManagement */ size_t xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * size_t xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ); + * @endcode + * @endcond + * * Queries a stream buffer to see how much data it contains, which is equal to * the number of bytes that can be read from the stream buffer before the stream * buffer would be empty. @@ -616,12 +761,22 @@ size_t xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ) PRIVIL * @return The number of bytes that can be read from the stream buffer before * the stream buffer would be empty. * + * @cond * \defgroup xStreamBufferBytesAvailable xStreamBufferBytesAvailable + * @endcond * \ingroup StreamBufferManagement */ size_t xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, size_t xTriggerLevel ); + * @endcode + * @endcond + * * A stream buffer's trigger level is the number of bytes that must be in the * stream buffer before a task that is blocked on the stream buffer to * wait for data is moved out of the blocked state. For example, if a task is @@ -647,11 +802,23 @@ size_t xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ) PRIVILE * then the trigger level will be updated and pdTRUE is returned. Otherwise * pdFALSE is returned. * + * @cond + * \defgroup xStreamBufferSetTriggerLevel xStreamBufferSetTriggerLevel + * @endcond * \ingroup StreamBufferManagement */ -BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, size_t xTriggerLevel ) PRIVILEGED_FUNCTION; +BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, + size_t xTriggerLevel ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * BaseType_t xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * @endcond + * * For advanced users only. * * The sbSEND_COMPLETED() macro is called from within the FreeRTOS APIs when @@ -679,11 +846,23 @@ BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, siz * @return If a task was removed from the Blocked state then pdTRUE is returned. * Otherwise pdFALSE is returned. * + * @cond + * \defgroup xStreamBufferSendCompletedFromISR xStreamBufferSendCompletedFromISR + * @endcond * \ingroup StreamBufferManagement */ -BaseType_t xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; +BaseType_t xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer, + BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * BaseType_t xStreamBufferReceiveCompletedFromISR( StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * @endcond + * * For advanced users only. * * The sbRECEIVE_COMPLETED() macro is called from within the FreeRTOS APIs when @@ -712,34 +891,41 @@ BaseType_t xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer * @return If a task was removed from the Blocked state then pdTRUE is returned. * Otherwise pdFALSE is returned. * + * @cond + * \defgroup xStreamBufferReceiveCompletedFromISR xStreamBufferReceiveCompletedFromISR + * @endcond * \ingroup StreamBufferManagement */ -BaseType_t xStreamBufferReceiveCompletedFromISR( StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; +BaseType_t xStreamBufferReceiveCompletedFromISR( StreamBufferHandle_t xStreamBuffer, + BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; /** @cond */ /* Functions below here are not part of the public API. */ StreamBufferHandle_t xStreamBufferGenericCreate( size_t xBufferSizeBytes, - size_t xTriggerLevelBytes, - BaseType_t xIsMessageBuffer ) PRIVILEGED_FUNCTION; + size_t xTriggerLevelBytes, + BaseType_t xIsMessageBuffer ) PRIVILEGED_FUNCTION; StreamBufferHandle_t xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes, - size_t xTriggerLevelBytes, - BaseType_t xIsMessageBuffer, - uint8_t * const pucStreamBufferStorageArea, - StaticStreamBuffer_t * const pxStaticStreamBuffer ) PRIVILEGED_FUNCTION; + size_t xTriggerLevelBytes, + BaseType_t xIsMessageBuffer, + uint8_t * const pucStreamBufferStorageArea, + StaticStreamBuffer_t * const pxStaticStreamBuffer ) PRIVILEGED_FUNCTION; size_t xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; -#if( configUSE_TRACE_FACILITY == 1 ) - void vStreamBufferSetStreamBufferNumber( StreamBufferHandle_t xStreamBuffer, UBaseType_t uxStreamBufferNumber ) PRIVILEGED_FUNCTION; - UBaseType_t uxStreamBufferGetStreamBufferNumber( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; - uint8_t ucStreamBufferGetStreamBufferType( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; +#if ( configUSE_TRACE_FACILITY == 1 ) + void vStreamBufferSetStreamBufferNumber( StreamBufferHandle_t xStreamBuffer, + UBaseType_t uxStreamBufferNumber ) PRIVILEGED_FUNCTION; + UBaseType_t uxStreamBufferGetStreamBufferNumber( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; + uint8_t ucStreamBufferGetStreamBufferType( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; #endif /** @endcond */ +/* *INDENT-OFF* */ #if defined( __cplusplus ) -} + } #endif +/* *INDENT-ON* */ -#endif /* !defined( STREAM_BUFFER_H ) */ +#endif /* !defined( STREAM_BUFFER_H ) */ diff --git a/tools/sdk/esp32c3/include/freertos/include/freertos/task.h b/tools/sdk/esp32c3/include/freertos/include/freertos/task.h index 559945805ee..9135b76f014 100644 --- a/tools/sdk/esp32c3/include/freertos/include/freertos/task.h +++ b/tools/sdk/esp32c3/include/freertos/include/freertos/task.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ @@ -30,69 +29,89 @@ #define INC_TASK_H #ifndef INC_FREERTOS_H - #error "include FreeRTOS.h must appear in source files before include task.h" + #error "include FreeRTOS.h must appear in source files before include task.h" #endif #include "list.h" +#ifdef ESP_PLATFORM // IDF-3793 #include "freertos/portmacro.h" +#endif // ESP_PLATFORM +/* *INDENT-OFF* */ #ifdef __cplusplus -extern "C" { + extern "C" { #endif +/* *INDENT-ON* */ /*----------------------------------------------------------- * MACROS AND DEFINITIONS *----------------------------------------------------------*/ -#define tskKERNEL_VERSION_NUMBER "V10.2.1" -#define tskKERNEL_VERSION_MAJOR 10 -#define tskKERNEL_VERSION_MINOR 2 -#define tskKERNEL_VERSION_BUILD 1 +#define tskKERNEL_VERSION_NUMBER "V10.4.3" +#define tskKERNEL_VERSION_MAJOR 10 +#define tskKERNEL_VERSION_MINOR 4 +#define tskKERNEL_VERSION_BUILD 3 /* MPU region parameters passed in ulParameters * of MemoryRegion_t struct. */ -#define tskMPU_REGION_READ_ONLY ( 1UL << 0UL ) -#define tskMPU_REGION_READ_WRITE ( 1UL << 1UL ) -#define tskMPU_REGION_EXECUTE_NEVER ( 1UL << 2UL ) -#define tskMPU_REGION_NORMAL_MEMORY ( 1UL << 3UL ) -#define tskMPU_REGION_DEVICE_MEMORY ( 1UL << 4UL ) +#define tskMPU_REGION_READ_ONLY ( 1UL << 0UL ) +#define tskMPU_REGION_READ_WRITE ( 1UL << 1UL ) +#define tskMPU_REGION_EXECUTE_NEVER ( 1UL << 2UL ) +#define tskMPU_REGION_NORMAL_MEMORY ( 1UL << 3UL ) +#define tskMPU_REGION_DEVICE_MEMORY ( 1UL << 4UL ) + +/* The direct to task notification feature used to have only a single notification + * per task. Now there is an array of notifications per task that is dimensioned by + * configTASK_NOTIFICATION_ARRAY_ENTRIES. For backward compatibility, any use of the + * original direct to task notification defaults to using the first index in the + * array. */ +#define tskDEFAULT_INDEX_TO_NOTIFY ( 0 ) + +#define tskNO_AFFINITY ( 0x7FFFFFFF ) -#define tskNO_AFFINITY ( 0x7FFFFFFF ) /** + * task. h + * * Type by which tasks are referenced. For example, a call to xTaskCreate * returns (via a pointer parameter) an TaskHandle_t variable that can then * be used as a parameter to vTaskDelete to delete the task. * + * @cond + * \defgroup TaskHandle_t TaskHandle_t + * @endcond * \ingroup Tasks */ -struct tskTaskControlBlock; /* The old naming convention is used to prevent breaking kernel aware debuggers. */ -//typedef struct tskTaskControlBlock* TaskHandle_t; +struct tskTaskControlBlock; /* The old naming convention is used to prevent breaking kernel aware debuggers. */ +#ifdef ESP_PLATFORM // IDF-3769 typedef void* TaskHandle_t; +#else +typedef struct tskTaskControlBlock* TaskHandle_t; +#endif // ESP_PLATFORM /** * Defines the prototype to which the application task hook function must * conform. */ -typedef BaseType_t (*TaskHookFunction_t)( void * ); +typedef BaseType_t (* TaskHookFunction_t)( void * ); /** 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. */ - eInvalid /* Used as an 'invalid state' value. */ + 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. */ + eInvalid /* Used as an 'invalid state' value. */ } eTaskState; /* 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 */ @@ -101,8 +120,8 @@ typedef enum */ typedef struct xTIME_OUT { - BaseType_t xOverflowCount; - TickType_t xTimeOnEntering; + BaseType_t xOverflowCount; + TickType_t xTimeOnEntering; } TimeOut_t; /** @@ -110,9 +129,9 @@ typedef struct xTIME_OUT */ typedef struct xMEMORY_REGION { - void *pvBaseAddress; - uint32_t ulLengthInBytes; - uint32_t ulParameters; + void * pvBaseAddress; + uint32_t ulLengthInBytes; + uint32_t ulParameters; } MemoryRegion_t; /* @@ -120,50 +139,36 @@ typedef struct xMEMORY_REGION */ typedef struct xTASK_PARAMETERS { - TaskFunction_t pvTaskCode; - const char * const pcName; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ - configSTACK_DEPTH_TYPE usStackDepth; - void *pvParameters; - UBaseType_t uxPriority; - StackType_t *puxStackBuffer; - MemoryRegion_t xRegions[ portNUM_CONFIGURABLE_REGIONS ]; - #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) - StaticTask_t * const pxTaskBuffer; - #endif + TaskFunction_t pvTaskCode; + const char * const pcName; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + configSTACK_DEPTH_TYPE usStackDepth; + void * pvParameters; + UBaseType_t uxPriority; + StackType_t * puxStackBuffer; + MemoryRegion_t xRegions[ portNUM_CONFIGURABLE_REGIONS ]; + #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) + StaticTask_t * const pxTaskBuffer; + #endif } TaskParameters_t; - -/* - * 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. */ - configSTACK_DEPTH_TYPE 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 https://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. */ + configSTACK_DEPTH_TYPE 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. */ #if configTASKLIST_INCLUDE_COREID - BaseType_t xCoreID; /*!< Core this task is pinned to (0, 1, or -1 for tskNO_AFFINITY). This field is present if CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID is set. */ + BaseType_t xCoreID; /*!< Core this task is pinned to (0, 1, or -1 for tskNO_AFFINITY). This field is present if CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID is set. */ #endif } 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*/ -} TaskSnapshot_t; - /** @endcond */ /** @@ -171,9 +176,9 @@ typedef struct xTASK_SNAPSHOT */ 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; /** @@ -181,61 +186,104 @@ typedef enum * * \ingroup TaskUtils */ -#define tskIDLE_PRIORITY ( ( UBaseType_t ) 0U ) +#define tskIDLE_PRIORITY ( ( UBaseType_t ) 0U ) /** + * task. h + * * Macro for forcing a context switch. * + * @cond + * \defgroup taskYIELD taskYIELD + * @endcond * \ingroup SchedulerControl */ -#define taskYIELD() portYIELD() +#define taskYIELD() portYIELD() /** + * task. h + * * 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) * so must be used with care! * + * @cond + * \defgroup taskENTER_CRITICAL taskENTER_CRITICAL + * @endcond * \ingroup SchedulerControl */ -#define taskENTER_CRITICAL( x ) portENTER_CRITICAL( x ) +#ifdef ESP_PLATFORM +#define taskENTER_CRITICAL( x ) portENTER_CRITICAL( x ) +#else +#define taskENTER_CRITICAL( ) portENTER_CRITICAL( ) +#endif // ESP_PLATFORM #define taskENTER_CRITICAL_FROM_ISR( ) portSET_INTERRUPT_MASK_FROM_ISR() -#define taskENTER_CRITICAL_ISR(mux) portENTER_CRITICAL_ISR(mux) + +#ifdef ESP_PLATFORM +#define taskENTER_CRITICAL_ISR( x ) portENTER_CRITICAL_ISR( x ) +#else +#define taskENTER_CRITICAL_ISR( ) portENTER_CRITICAL_ISR( ) +#endif // ESP_PLATFORM /** + * task. h + * * 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) * so must be used with care! * + * @cond + * \defgroup taskEXIT_CRITICAL taskEXIT_CRITICAL + * @endcond * \ingroup SchedulerControl */ -#define taskEXIT_CRITICAL( x ) portEXIT_CRITICAL( x ) + +#ifdef ESP_PLATFORM +#define taskEXIT_CRITICAL( x ) portEXIT_CRITICAL( x ) +#else +#define taskEXIT_CRITICAL( ) portEXIT_CRITICAL( ) +#endif // ESP_PLATFORM #define taskEXIT_CRITICAL_FROM_ISR( x ) portCLEAR_INTERRUPT_MASK_FROM_ISR( x ) -#define taskEXIT_CRITICAL_ISR(mux) portEXIT_CRITICAL_ISR(mux) +#ifdef ESP_PLATFORM +#define taskEXIT_CRITICAL_ISR( x ) portEXIT_CRITICAL_ISR( x ) +#else +#define taskEXIT_CRITICAL_ISR( ) portEXIT_CRITICAL_ISR( ) +#endif // ESP_PLATFORM /** + * task. h + * * Macro to disable all maskable interrupts. * + * @cond + * \defgroup taskDISABLE_INTERRUPTS taskDISABLE_INTERRUPTS + * @endcond * \ingroup SchedulerControl */ -#define taskDISABLE_INTERRUPTS() portDISABLE_INTERRUPTS() +#define taskDISABLE_INTERRUPTS() portDISABLE_INTERRUPTS() /** + * task. h + * * Macro to enable microcontroller interrupts. * + * @cond + * \defgroup taskENABLE_INTERRUPTS taskENABLE_INTERRUPTS + * @endcond * \ingroup SchedulerControl */ -#define taskENABLE_INTERRUPTS() portENABLE_INTERRUPTS() +#define taskENABLE_INTERRUPTS() portENABLE_INTERRUPTS() /* Definitions returned by xTaskGetSchedulerState(). taskSCHEDULER_SUSPENDED is -0 to generate more optimal code when configASSERT() is defined as the constant -is used in assert() statements. */ -#define taskSCHEDULER_SUSPENDED ( ( BaseType_t ) 0 ) -#define taskSCHEDULER_NOT_STARTED ( ( BaseType_t ) 1 ) -#define taskSCHEDULER_RUNNING ( ( BaseType_t ) 2 ) + * 0 to generate more optimal code when configASSERT() is defined as the constant + * is used in assert() statements. */ +#define taskSCHEDULER_SUSPENDED ( ( BaseType_t ) 0 ) +#define taskSCHEDULER_NOT_STARTED ( ( BaseType_t ) 1 ) +#define taskSCHEDULER_RUNNING ( ( BaseType_t ) 2 ) /*----------------------------------------------------------- @@ -283,13 +331,13 @@ is used in assert() statements. */ * \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); + 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 @@ -301,7 +349,7 @@ is used in assert() statements. */ * second block is used by the task as its stack. If a task is created using * xTaskCreate() then both blocks of memory are automatically dynamically * allocated inside the xTaskCreate() function. (see - * http://www.freertos.org/a00111.html). If a task is created using + * https://www.FreeRTOS.org/a00111.html). If a task is created using * xTaskCreateStatic() then the application writer must provide the required * memory. xTaskCreateStatic() therefore allows a task to be created without * using any dynamic memory allocation. @@ -345,50 +393,52 @@ is used in assert() statements. */ * * Example usage: * @code{c} - * // Task to be created. - * void vTaskCode( void * pvParameters ) - * { + * // 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; + * // 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 ); + * configASSERT( xHandle ); * * // Use the handle to delete the task. - * if( xHandle != NULL ) - * { - * vTaskDelete( xHandle ); - * } - * } + * if( xHandle != NULL ) + * { + * vTaskDelete( xHandle ); + * } + * } * @endcode + * @cond + * \defgroup xTaskCreate xTaskCreate + * @endcond * \ingroup Tasks */ +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) -#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - - 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 ); - } + 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 @@ -439,14 +489,14 @@ is used in assert() statements. */ * \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 ); + 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 */ /** @@ -497,71 +547,80 @@ is used in assert() statements. */ * Example usage: * @code{c} * - * // Dimensions the buffer that the task being created will use as its stack. - * // NOTE: This is the number of bytes the stack will hold, not the number of - * // words as found in vanilla FreeRTOS. - * #define STACK_SIZE 200 + * // Dimensions the buffer that the task being created will use as its stack. + * // NOTE: This is the number of bytes the stack will hold, not the number of + * // words as found in vanilla FreeRTOS. + * #define STACK_SIZE 200 * - * // Structure that will hold the TCB of the task being created. - * StaticTask_t xTaskBuffer; + * // 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 ]; + * // 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 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 ); * - * // 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 bytes, not words. - * ( 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 ); - * } + * 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 bytes, not words. + * ( 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 ) - 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 ); - } + 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 + * @code{c} + * BaseType_t xTaskCreateRestricted( TaskParameters_t *pxTaskDefinition, TaskHandle_t *pxCreatedTask ); + * @endcode + * @endcond + * + * Only available when configSUPPORT_DYNAMIC_ALLOCATION is set to 1. + * * xTaskCreateRestricted() should only be used in systems that include an MPU * implementation. * @@ -572,12 +631,12 @@ is used in assert() statements. */ * See xTaskCreateRestrictedStatic() for a version that does not use any * dynamic memory allocation. * - * param pxTaskDefinition Pointer to a structure that contains a member + * @param pxTaskDefinition Pointer to a structure that contains a member * for each of the normal xTaskCreate() parameters (see the xTaskCreate() API * documentation) plus an optional stack buffer and the memory region * definitions. * - * param pxCreatedTask Used to pass back a handle by which the created task + * @param pxCreatedTask Used to pass back a handle by which the created task * can be referenced. * * return pdPASS if the task was successfully created and added to a ready @@ -588,54 +647,65 @@ is used in assert() statements. */ * // 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 } - * } + * 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 ); + * // 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(); + * // Start the scheduler. + * vTaskStartScheduler(); * - * // Will only get here if there was insufficient memory to create the idle - * // and/or timer task. - * for( ;; ); + * // Will only get here if there was insufficient memory to create the idle + * // and/or timer task. + * for( ;; ); * } * @endcode + * @cond + * \defgroup xTaskCreateRestricted xTaskCreateRestricted + * @endcond * \ingroup Tasks */ -#if( portUSING_MPU_WRAPPERS == 1 ) - BaseType_t xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ); +#if ( portUSING_MPU_WRAPPERS == 1 ) + BaseType_t xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition, + TaskHandle_t * pxCreatedTask ); #endif -/* - * xTaskCreateRestrictedStatic() should only be used in systems that include an - * MPU implementation. +/** + * @cond + * task. h + * @code{c} + * BaseType_t xTaskCreateRestrictedStatic( TaskParameters_t *pxTaskDefinition, TaskHandle_t *pxCreatedTask ); + * @endcode + * @endcond * * Only available when configSUPPORT_STATIC_ALLOCATION is set to 1. * + * xTaskCreateRestrictedStatic() should only be used in systems that include an + * MPU implementation. + * * Internally, within the FreeRTOS implementation, tasks use two blocks of * memory. The first block is used to hold the task's data structures. The * second block is used by the task as its stack. If a task is created using @@ -647,14 +717,14 @@ is used in assert() statements. */ * xTaskCreateRestrictedStatic() therefore allows a memory protected task to be * created without using any dynamic memory allocation. * - * param pxTaskDefinition Pointer to a structure that contains a member + * @param pxTaskDefinition Pointer to a structure that contains a member * for each of the normal xTaskCreate() parameters (see the xTaskCreate() API * documentation) plus an optional stack buffer and the memory region * definitions. If configSUPPORT_STATIC_ALLOCATION is set to 1 the structure * contains an additional member, which is used to point to a variable of type * StaticTask_t - which is then used to hold the task's data structure. * - * param pxCreatedTask Used to pass back a handle by which the created task + * @param pxCreatedTask Used to pass back a handle by which the created task * can be referenced. * * return pdPASS if the task was successfully created and added to a ready @@ -669,62 +739,72 @@ is used in assert() statements. */ * static PRIVILEGED_DATA StaticTask_t xTaskBuffer; * 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 BYTES. - * 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 } - * } - * - * &xTaskBuffer; // Holds the task's data structure. + * 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 BYTES. + * 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 } + * } + * + * &xTaskBuffer; // Holds the task's data structure. * }; * * 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 ); + * // 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(); + * // Start the scheduler. + * vTaskStartScheduler(); * - * // Will only get here if there was insufficient memory to create the idle - * // and/or timer task. - * for( ;; ); + * // Will only get here if there was insufficient memory to create the idle + * // and/or timer task. + * for( ;; ); * } * @endcode + * @cond + * \defgroup xTaskCreateRestrictedStatic xTaskCreateRestrictedStatic + * @endcond * \ingroup Tasks */ -#if( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) - BaseType_t xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ); +#if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) + BaseType_t xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition, + TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION; #endif -/* +/** + * @cond + * task. h + * @code{c} + * void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions ); + * @endcode + * @endcond + * * 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(). * - * param xTask The handle of the task being updated. + * @param xTask The handle of the task being updated. * - * param pxRegions A pointer to an MemoryRegion_t structure that contains the + * @param pxRegions A pointer to an MemoryRegion_t structure that contains the * new memory region definitions. * * Example usage: - * * @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 @@ -732,38 +812,49 @@ is used in assert() statements. */ * // 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 } + * // 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). + * // 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 + * @cond + * \defgroup xTaskCreateRestricted xTaskCreateRestricted + * @endcond * \ingroup Tasks */ -void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions ) PRIVILEGED_FUNCTION; +void vTaskAllocateMPURegions( TaskHandle_t xTask, + const MemoryRegion_t * const pxRegions ) PRIVILEGED_FUNCTION; /** - * 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. + * @cond + * task. h + * @code{c} + * void vTaskDelete( TaskHandle_t xTask ); + * @endcode + * @endcond * * 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 * memory from tasks that have been deleted. It is therefore important that * the idle task is not starved of microcontroller processing time if your @@ -779,17 +870,20 @@ void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const p * * Example usage: * @code{c} - * void vOtherFunction( void ) - * { - * TaskHandle_t xHandle; + * void vOtherFunction( void ) + * { + * TaskHandle_t xHandle; * - * // Create the task, storing the handle. - * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &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 ); - * } + * // Use the handle to delete the task. + * vTaskDelete( xHandle ); + * } * @endcode + * @cond + * \defgroup vTaskDelete vTaskDelete + * @endcond * \ingroup Tasks */ void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION; @@ -799,7 +893,10 @@ void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION; *----------------------------------------------------------*/ /** - * Delay a task for a given number of ticks. + * task. h + * @code{c} + * void vTaskDelay( const TickType_t xTicksToDelay ); + * @endcode * * Delay a task for a given number of ticks. The actual time that the * task remains blocked depends on the tick rate. The constant @@ -809,6 +906,7 @@ void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION; * 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 @@ -816,7 +914,7 @@ void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION; * of controlling the frequency of a periodic task as the path taken through the * code, as well as other task and interrupt activity, will effect the frequency * at which vTaskDelay() gets called and therefore the time at which the task - * next executes. See vTaskDelayUntil() for an alternative API function designed + * next executes. See xTaskDelayUntil() for an alternative API function designed * to facilitate fixed frequency execution. It does this by specifying an * absolute time (rather than a relative time) at which the calling task should * unblock. @@ -826,27 +924,34 @@ void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION; * * Example usage: * @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 ); - * } - * } + * 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 + * + * @cond + * \defgroup vTaskDelay vTaskDelay + * @endcond * \ingroup TaskCtrl */ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION; /** - * Delay a task until a specified time. + * task. h + * @code{c} + * BaseType_t xTaskDelayUntil( TickType_t *pxPreviousWakeTime, const TickType_t xTimeIncrement ); + * @endcode * - * INCLUDE_vTaskDelayUntil must be defined as 1 for this function to be available. + * INCLUDE_xTaskDelayUntil 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 @@ -861,46 +966,73 @@ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION; * each time it executes]. * * Whereas vTaskDelay () specifies a wake time relative to the time at which the function - * is called, vTaskDelayUntil () specifies the absolute (exact) time at which it wishes to + * is called, xTaskDelayUntil () specifies the absolute (exact) time at which it wishes to * unblock. * - * The constant portTICK_PERIOD_MS can be used to calculate real time from the tick - * rate - with the resolution of one tick period. + * The macro pdMS_TO_TICKS() can be used to calculate the number of ticks from a + * time specified in milliseconds with a resolution of one tick period. * * @param pxPreviousWakeTime Pointer to a variable that holds the time at which the * task was last unblocked. The variable must be initialised with the current time * prior to its first use (see the example below). Following this the variable is - * automatically updated within vTaskDelayUntil (). + * automatically updated within xTaskDelayUntil (). * * @param xTimeIncrement The cycle time period. The task will be unblocked at - * time *pxPreviousWakeTime + xTimeIncrement. Calling vTaskDelayUntil with the + * time *pxPreviousWakeTime + xTimeIncrement. Calling xTaskDelayUntil with the * same xTimeIncrement parameter value will cause the task to execute with * a fixed interface period. * + * @return Value which can be used to check whether the task was actually delayed. + * Will be pdTRUE if the task way delayed and pdFALSE otherwise. A task will not + * be delayed if the next expected wake time is in the past. + * * Example usage: * @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. - * } - * } + * // Perform an action every 10 ticks. + * void vTaskFunction( void * pvParameters ) + * { + * TickType_t xLastWakeTime; + * const TickType_t xFrequency = 10; + * BaseType_t xWasDelayed; + * + * // Initialise the xLastWakeTime variable with the current time. + * xLastWakeTime = xTaskGetTickCount (); + * for( ;; ) + * { + * // Wait for the next cycle. + * xWasDelayed = xTaskDelayUntil( &xLastWakeTime, xFrequency ); + * + * // Perform action here. xWasDelayed value can be used to determine + * // whether a deadline was missed if the code here took too long. + * } + * } * @endcode + * @cond + * \defgroup xTaskDelayUntil xTaskDelayUntil + * @endcond * \ingroup TaskCtrl */ -void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION; +BaseType_t xTaskDelayUntil( TickType_t * const pxPreviousWakeTime, + const TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION; + +/* + * vTaskDelayUntil() is the older version of xTaskDelayUntil() and does not + * return a value. + */ +#define vTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ) \ +{ \ + ( void ) xTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ); \ +} + /** + * @cond + * task. h + * @code{c} + * BaseType_t xTaskAbortDelay( TaskHandle_t xTask ); + * @endcode + * @endcond + * * INCLUDE_xTaskAbortDelay must be defined as 1 in FreeRTOSConfig.h for this * function to be available. * @@ -912,22 +1044,36 @@ void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xT * task will leave the Blocked state, and return from whichever function call * placed the task into the Blocked state. * + * There is no 'FromISR' version of this function as an interrupt would need to + * know which object a task was blocked on in order to know which actions to + * take. For example, if the task was blocked on a queue the interrupt handler + * would then need to know if the queue was locked. + * * @param xTask The handle of the task to remove from the Blocked state. * * @return If the task referenced by xTask was not in the Blocked state then * pdFAIL is returned. Otherwise pdPASS is returned. * + * @cond * \defgroup xTaskAbortDelay xTaskAbortDelay + * @endcond * \ingroup TaskCtrl */ BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; /** - * Obtain the priority of any task. + * @cond + * task. h + * @code{c} + * UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask ); + * @endcode + * @endcond * * 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. * @@ -935,9 +1081,9 @@ BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; * * Example usage: * @code{c} - * void vAFunction( void ) - * { - * TaskHandle_t xHandle; + * void vAFunction( void ) + * { + * TaskHandle_t xHandle; * * // Create a task, storing the handle. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle ); @@ -961,23 +1107,39 @@ BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; * } * } * @endcode + * @cond + * \defgroup uxTaskPriorityGet uxTaskPriorityGet + * @endcond * \ingroup TaskCtrl */ UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION; /** + * @cond + * task. h + * @code{c} + * UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask ); + * @endcode + * @endcond + * * A version of uxTaskPriorityGet() that can be used from an ISR. */ UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION; /** - * Obtain the state of any task. - * - * States are encoded by the eTaskState enumerated type. + * @cond + * task. h + * @code{c} + * eTaskState eTaskGetState( TaskHandle_t xTask ); + * @endcode + * @endcond * * 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 @@ -987,11 +1149,17 @@ UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask ) PRIVILEGED_FUNC eTaskState eTaskGetState( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; /** - * Populates a TaskStatus_t structure with information about a task. + * @cond + * task. h + * @code{c} + * void vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState ); + * @endcode + * @endcond * * configUSE_TRACE_FACILITY must be defined as 1 for this function to be * available. See the configuration section for more information. * + * Populates a TaskStatus_t structure with information about a task. * * @param xTask Handle of the task being queried. If xTask is NULL then * information will be returned about the calling task. @@ -1022,29 +1190,42 @@ eTaskState eTaskGetState( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; * TaskHandle_t xHandle; * TaskStatus_t xTaskDetails; * - * // Obtain the handle of a task from its name. - * xHandle = xTaskGetHandle( "Task_Name" ); + * // Obtain the handle of a task from its name. + * xHandle = xTaskGetHandle( "Task_Name" ); * - * // Check the handle is not NULL. - * configASSERT( xHandle ); + * // Check the handle is not NULL. + * configASSERT( xHandle ); * - * // Use the handle to obtain further information about the task. - * vTaskGetInfo( xHandle, - * &xTaskDetails, - * pdTRUE, // Include the high water mark in xTaskDetails. - * eInvalid ); // Include the task state in xTaskDetails. + * // Use the handle to obtain further information about the task. + * vTaskGetInfo( xHandle, + * &xTaskDetails, + * pdTRUE, // Include the high water mark in xTaskDetails. + * eInvalid ); // Include the task state in xTaskDetails. * } * @endcode + * @cond + * \defgroup vTaskGetInfo vTaskGetInfo + * @endcond * \ingroup TaskCtrl */ -void vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState ) PRIVILEGED_FUNCTION; +void vTaskGetInfo( TaskHandle_t xTask, + TaskStatus_t * pxTaskStatus, + BaseType_t xGetFreeStackSpace, + eTaskState eState ) PRIVILEGED_FUNCTION; /** - * Set the priority of any task. + * @cond + * task. h + * @code{c} + * void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority ); + * @endcode + * @endcond * * 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. * @@ -1055,9 +1236,9 @@ void vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xG * * Example usage: * @code{c} - * void vAFunction( void ) - * { - * TaskHandle_t xHandle; + * void vAFunction( void ) + * { + * TaskHandle_t xHandle; * * // Create a task, storing the handle. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle ); @@ -1071,14 +1252,23 @@ void vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xG * * // Use a NULL handle to raise our priority to the same value. * vTaskPrioritySet( NULL, tskIDLE_PRIORITY + 1 ); - * } + * } * @endcode + * @cond + * \defgroup vTaskPrioritySet vTaskPrioritySet + * @endcond * \ingroup TaskCtrl */ -void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority ) PRIVILEGED_FUNCTION; +void vTaskPrioritySet( TaskHandle_t xTask, + UBaseType_t uxNewPriority ) PRIVILEGED_FUNCTION; /** - * Suspend a task. + * @cond + * task. h + * @code{c} + * void vTaskSuspend( TaskHandle_t xTaskToSuspend ); + * @endcode + * @endcond * * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available. * See the configuration section for more information. @@ -1095,9 +1285,9 @@ void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority ) PRIVILEGE * * Example usage: * @code{c} - * void vAFunction( void ) - * { - * TaskHandle_t xHandle; + * void vAFunction( void ) + * { + * TaskHandle_t xHandle; * * // Create a task, storing the handle. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle ); @@ -1120,18 +1310,28 @@ void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority ) PRIVILEGE * * // We cannot get here unless another task calls vTaskResume * // with our handle as the parameter. - * } + * } * @endcode + * @cond + * \defgroup vTaskSuspend vTaskSuspend + * @endcond * \ingroup TaskCtrl */ void vTaskSuspend( TaskHandle_t xTaskToSuspend ) PRIVILEGED_FUNCTION; /** - * Resumes a suspended task. + * @cond + * task. h + * @code{c} + * void vTaskResume( TaskHandle_t xTaskToResume ); + * @endcode + * @endcond * * 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 (). @@ -1140,9 +1340,9 @@ void vTaskSuspend( TaskHandle_t xTaskToSuspend ) PRIVILEGED_FUNCTION; * * Example usage: * @code{c} - * void vAFunction( void ) - * { - * TaskHandle_t xHandle; + * void vAFunction( void ) + * { + * TaskHandle_t xHandle; * * // Create a task, storing the handle. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle ); @@ -1165,18 +1365,28 @@ void vTaskSuspend( TaskHandle_t xTaskToSuspend ) PRIVILEGED_FUNCTION; * * // The created task will once again get microcontroller processing * // time in accordance with its priority within the system. - * } + * } * @endcode + * @cond + * \defgroup vTaskResume vTaskResume + * @endcond * \ingroup TaskCtrl */ void vTaskResume( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION; /** - * An implementation of vTaskResume() that can be called from within an ISR. + * @cond + * task. h + * @code{c} + * void xTaskResumeFromISR( TaskHandle_t xTaskToResume ); + * @endcode + * @endcond * * 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 (). @@ -1192,6 +1402,9 @@ 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. * + * @cond + * \defgroup vTaskResumeFromISR vTaskResumeFromISR + * @endcond * \ingroup TaskCtrl */ BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION; @@ -1201,21 +1414,27 @@ BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION; *----------------------------------------------------------*/ /** @cond */ /** - * Starts the real time kernel tick processing. + * @cond + * task. h + * @code{c} + * void vTaskStartScheduler( void ); + * @endcode + * @endcond * + * Starts the real time kernel tick processing. After calling the kernel + * has control over which tasks are executed and when. + * NOTE: In ESP-IDF the scheduler is started automatically during * application startup, vTaskStartScheduler() should not be called from * ESP-IDF applications. * - * 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: * @code{c} - * void vAFunction( void ) - * { + * void vAFunction( void ) + * { * // Create at least one task before starting the kernel. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL ); * @@ -1223,15 +1442,23 @@ BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION; * vTaskStartScheduler (); * * // Will not get here unless a task calls vTaskEndScheduler () - * } + * } * @endcode * + * @cond + * \defgroup vTaskStartScheduler vTaskStartScheduler + * @endcond * \ingroup SchedulerControl */ void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION; /** - * Stops the real time kernel tick. + * @cond + * task. h + * @code{c} + * void vTaskEndScheduler( void ); + * @endcode + * @endcond * * NOTE: At the time of writing only the x86 real mode port, which runs on a PC * in place of DOS, implements this function. @@ -1254,8 +1481,8 @@ void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION; * * Example usage: * @code{c} - * void vTaskCode( void * pvParameters ) - * { + * void vTaskCode( void * pvParameters ) + * { * for( ;; ) * { * // Task code goes here. @@ -1264,10 +1491,10 @@ void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION; * // so call ... * vTaskEndScheduler (); * } - * } + * } * - * void vAFunction( void ) - * { + * void vAFunction( void ) + * { * // Create at least one task before starting the kernel. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL ); * @@ -1277,8 +1504,12 @@ void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION; * // Will only get here when the vTaskCode () task has called * // vTaskEndScheduler (). When we get here we are back to single task * // execution. - * } + * } * @endcode + * + * @cond + * \defgroup vTaskEndScheduler vTaskEndScheduler + * @endcond * \ingroup SchedulerControl */ void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION; @@ -1286,9 +1517,15 @@ void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION; /** @endcond */ /** - * Suspends the scheduler without disabling interrupts. + * @cond + * task. h + * @code{c} + * void vTaskSuspendAll( void ); + * @endcode + * @endcond * - * Context switches will not occur while the scheduler is suspended. + * Suspends the scheduler without disabling interrupts. 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 @@ -1300,8 +1537,8 @@ void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION; * * Example usage: * @code{c} - * void vTask1( void * pvParameters ) - * { + * void vTask1( void * pvParameters ) + * { * for( ;; ) * { * // Task code goes here. @@ -1327,13 +1564,23 @@ void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION; * // The operation is complete. Restart the kernel. * xTaskResumeAll (); * } - * } + * } * @endcode + * @cond + * \defgroup vTaskSuspendAll vTaskSuspendAll + * @endcond * \ingroup SchedulerControl */ void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION; /** + * @cond + * task. h + * @code{c} + * BaseType_t xTaskResumeAll( void ); + * @endcode + * @endcond + * * Resumes scheduler activity after it was suspended by a call to * vTaskSuspendAll(). * @@ -1341,12 +1588,12 @@ void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION; * that were previously suspended by a call to vTaskSuspend(). * * @return If resuming the scheduler caused a context switch then pdTRUE is - * returned, otherwise pdFALSE is returned. + * returned, otherwise pdFALSE is returned. * * Example usage: * @code{c} - * void vTask1( void * pvParameters ) - * { + * void vTask1( void * pvParameters ) + * { * for( ;; ) * { * // Task code goes here. @@ -1377,8 +1624,11 @@ void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION; * taskYIELD (); * } * } - * } + * } * @endcode + * @cond + * \defgroup xTaskResumeAll xTaskResumeAll + * @endcond * \ingroup SchedulerControl */ BaseType_t xTaskResumeAll( void ) PRIVILEGED_FUNCTION; @@ -1388,16 +1638,29 @@ BaseType_t xTaskResumeAll( void ) PRIVILEGED_FUNCTION; *----------------------------------------------------------*/ /** - * Get tick count + * @cond + * task. h + * @code{c} + * TickType_t xTaskGetTickCount( void ); + * @endcode + * @endcond * * @return The count of ticks since vTaskStartScheduler was called. * + * @cond + * \defgroup xTaskGetTickCount xTaskGetTickCount + * @endcond * \ingroup TaskUtils */ TickType_t xTaskGetTickCount( void ) PRIVILEGED_FUNCTION; /** - * Get tick count from ISR + * @cond + * task. h + * @code{c} + * TickType_t xTaskGetTickCountFromISR( void ); + * @endcode + * @endcond * * @return The count of ticks since vTaskStartScheduler was called. * @@ -1406,44 +1669,73 @@ TickType_t xTaskGetTickCount( void ) PRIVILEGED_FUNCTION; * microcontroller being used or interrupt nesting is either not supported or * not being used. * + * @cond + * \defgroup xTaskGetTickCountFromISR xTaskGetTickCountFromISR + * @endcond * \ingroup TaskUtils */ TickType_t xTaskGetTickCountFromISR( void ) PRIVILEGED_FUNCTION; /** - * Get current number of tasks + * @cond + * task. h + * @code{c} + * uint16_t uxTaskGetNumberOfTasks( void ); + * @endcode + * @endcond * * @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. * + * @cond + * \defgroup uxTaskGetNumberOfTasks uxTaskGetNumberOfTasks + * @endcond * \ingroup TaskUtils */ UBaseType_t uxTaskGetNumberOfTasks( void ) PRIVILEGED_FUNCTION; /** - * Get task name + * @cond + * task. h + * @code{c} + * char *pcTaskGetName( TaskHandle_t xTaskToQuery ); + * @endcode + * @endcond * * @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. * + * @cond + * \defgroup pcTaskGetName pcTaskGetName + * @endcond * \ingroup TaskUtils */ -char *pcTaskGetName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ +char * pcTaskGetName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ /** - * @note This function takes a relatively long time to complete and should be + * @cond + * task. h + * @code{c} + * TaskHandle_t xTaskGetHandle( const char *pcNameToQuery ); + * @endcode + * @endcond + * + * NOTE: This function takes a relatively long time to complete and should be * used sparingly. * * @return The handle of the task that has the human readable name pcNameToQuery. * NULL is returned if no matching name is found. INCLUDE_xTaskGetHandle * must be set to 1 in FreeRTOSConfig.h for pcTaskGetHandle() to be available. * + * @cond + * \defgroup pcTaskGetHandle pcTaskGetHandle + * @endcond * \ingroup TaskUtils */ -TaskHandle_t xTaskGetHandle( const char *pcNameToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ +TaskHandle_t xTaskGetHandle( const char * pcNameToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ /** * Returns the high water mark of the stack associated with xTask. @@ -1513,109 +1805,195 @@ configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) PRIVIL uint8_t* pxTaskGetStackStart( TaskHandle_t xTask) PRIVILEGED_FUNCTION; /* When using trace macros it is sometimes necessary to include task.h before -FreeRTOS.h. When this is done TaskHookFunction_t will not yet have been defined, -so the following two prototypes will cause a compilation error. This can be -fixed by simply guarding against the inclusion of these two prototypes unless -they are explicitly required by the configUSE_APPLICATION_TASK_TAG configuration -constant. */ + * FreeRTOS.h. When this is done TaskHookFunction_t will not yet have been defined, + * so the following two prototypes will cause a compilation error. This can be + * fixed by simply guarding against the inclusion of these two prototypes unless + * they are explicitly required by the configUSE_APPLICATION_TASK_TAG configuration + * constant. */ #ifdef configUSE_APPLICATION_TASK_TAG - #if configUSE_APPLICATION_TASK_TAG == 1 - /** - * Sets pxHookFunction to be the task hook function used by the task xTask. - * @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; - - /** - * - * Returns the pxHookFunction value assigned to the task xTask. Do not - * call from an interrupt service routine - call - * xTaskGetApplicationTaskTagFromISR() instead. - */ - TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; - - /** - * - * Returns the pxHookFunction value assigned to the task xTask. Can - * be called from an interrupt service routine. - */ - TaskHookFunction_t xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; - #endif /* configUSE_APPLICATION_TASK_TAG ==1 */ + #if configUSE_APPLICATION_TASK_TAG == 1 +/** + * @cond + * task.h + * @code{c} + * void vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction ); + * @endcode + * @endcond + * + * Sets pxHookFunction to be the task hook function used by the task xTask. + * @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; + +/** + * @cond + * task.h + * @code{c} + * void xTaskGetApplicationTaskTag( TaskHandle_t xTask ); + * @endcode + * @endcond + * + * Returns the pxHookFunction value assigned to the task xTask. Do not + * call from an interrupt service routine - call + * xTaskGetApplicationTaskTagFromISR() instead. + */ + TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; + +/** + * @cond + * task.h + * @code{c} + * void xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask ); + * @endcode + * @endcond + * + * Returns the pxHookFunction value assigned to the task xTask. Can + * be called from an interrupt service routine. + */ + TaskHookFunction_t xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; + #endif /* configUSE_APPLICATION_TASK_TAG ==1 */ #endif /* ifdef configUSE_APPLICATION_TASK_TAG */ -#if( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) - - /** - * 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 ) - - /** - * 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 +#if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) + + /** + * 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 ) + + /** + * 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 +#if ( configCHECK_FOR_STACK_OVERFLOW > 0 ) + + /** + * @cond + * task.h + * @code{c} + * void vApplicationStackOverflowHook( TaskHandle_t xTask char *pcTaskName); + * @endcode + * @endcond + * The application stack overflow hook is called when a stack overflow is detected for a task. + * + * Details on stack overflow detection can be found here: https://www.FreeRTOS.org/Stacks-and-stack-overflow-checking.html + * + * @param xTask the task that just exceeded its stack boundaries. + * @param pcTaskName A character string containing the name of the offending task. + */ + void vApplicationStackOverflowHook( TaskHandle_t xTask, + char * pcTaskName ); + +#endif + +#if ( configUSE_TICK_HOOK > 0 ) + /** + * @cond + * task.h + * @code{c} + * void vApplicationTickHook( void ); + * @endcode + * @endcond + * + * This hook function is called in the system tick handler after any OS work is completed. + */ + void vApplicationTickHook( void ); /*lint !e526 Symbol not defined as it is an application callback. */ + +#endif + +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + /** + * @cond + * task.h + * @code{c} + * void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ) + * @endcode + * @endcond + * This function is used to provide a statically allocated block of memory to FreeRTOS to hold the Idle Task TCB. This function is required when + * configSUPPORT_STATIC_ALLOCATION is set. For more information see this URI: https://www.FreeRTOS.org/a00110.html#configSUPPORT_STATIC_ALLOCATION + * + * @param ppxIdleTaskTCBBuffer A handle to a statically allocated TCB buffer + * @param ppxIdleTaskStackBuffer A handle to a statically allocated Stack buffer for thie idle task + * @param pulIdleTaskStackSize A pointer to the number of elements that will fit in the allocated stack buffer + */ + void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, + StackType_t ** ppxIdleTaskStackBuffer, + uint32_t * pulIdleTaskStackSize ); /*lint !e526 Symbol not defined as it is an application callback. */ +#endif + /** - * Calls the hook function associated with xTask. Passing xTask as NULL has + * @cond + * task.h + * @code{c} + * BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter ); + * @endcode + * @endcond + * + * Calls the hook function associated with xTask. Passing xTask as NULL has * the effect of calling the Running tasks (the calling task) hook function. * * @param xTask Handle of the task to call the hook for. @@ -1623,7 +2001,8 @@ constant. */ * 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; +BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, + void * pvParameter ) PRIVILEGED_FUNCTION; /** * xTaskGetIdleTaskHandle() is only available if @@ -1644,7 +2023,7 @@ TaskHandle_t xTaskGetIdleTaskHandle( void ) PRIVILEGED_FUNCTION; * 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. @@ -1660,7 +2039,7 @@ TaskHandle_t xTaskGetIdleTaskHandle( void ) PRIVILEGED_FUNCTION; * @param pulTotalRunTime If configGENERATE_RUN_TIME_STATS is set to 1 in * FreeRTOSConfig.h then *pulTotalRunTime is set by uxTaskGetSystemState() to the * total run time (as defined by the run time stats clock, see - * http://www.freertos.org/rtos-run-time-stats.html) since the target booted. + * https://www.FreeRTOS.org/rtos-run-time-stats.html) since the target booted. * pulTotalRunTime can be set to NULL to omit the total run time information. * * @return The number of TaskStatus_t structures that were populated by @@ -1670,68 +2049,70 @@ TaskHandle_t xTaskGetIdleTaskHandle( void ) PRIVILEGED_FUNCTION; * * Example usage: * @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; + * // 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; + * // 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(); + * // 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 ) ); + * // 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 ); + * if( pxTaskStatusArray != NULL ) + * { + * // Generate raw status information about each task. + * uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, &ulTotalRunTime ); * - * // For percentage calculations. - * ulTotalRunTime /= 100UL; + * // 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++ ) + * // Avoid divide by zero errors. + * if( ulTotalRunTime > 0 ) * { - * // 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 ) + * // For each populated position in the pxTaskStatusArray array, + * // format the raw data as human readable ASCII data + * for( x = 0; x < uxArraySize; x++ ) * { - * sprintf( pcWriteBuffer, "%s\t\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage ); + * // 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 ); * } - * 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 ); + * // The array is no longer needed, free the memory it consumes. + * vPortFree( pxTaskStatusArray ); + * } * } - * } - * @endcode + * @endcode */ -UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const UBaseType_t uxArraySize, uint32_t * const pulTotalRunTime ) PRIVILEGED_FUNCTION; +UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, + const UBaseType_t uxArraySize, + uint32_t * const pulTotalRunTime ) PRIVILEGED_FUNCTION; /** * List all the current tasks. @@ -1740,7 +2121,7 @@ UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const * both be defined as 1 for this function to be available. See the * configuration section of the FreeRTOS.org website for more information. * - * @note This function will disable interrupts for its duration. It is + * NOTE 1: 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 @@ -1749,7 +2130,9 @@ UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const * Tasks are reported as blocked ('B'), ready ('R'), deleted ('D') or * suspended ('S'). * - * @note This function is provided for convenience only, and is used by many of the + * PLEASE 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 @@ -1772,9 +2155,12 @@ UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const * enough to contain the generated report. Approximately 40 bytes per * task should be sufficient. * + * @cond + * \defgroup vTaskList vTaskList + * @endcond * \ingroup TaskUtils */ -void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ +void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ /** * Get the state of running tasks as a string @@ -1787,7 +2173,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 This function will disable interrupts for its duration. It is + * NOTE 1: 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 @@ -1798,7 +2184,9 @@ 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 This function is provided for convenience only, and is used by many of the + * NOTE 2: + * + * 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 @@ -1822,42 +2210,69 @@ void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unquali * contain the generated report. Approximately 40 bytes per task should * be sufficient. * + * @cond + * \defgroup vTaskGetRunTimeStats vTaskGetRunTimeStats + * @endcond + * \ingroup TaskUtils + */ +void vTaskGetRunTimeStats( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + +/** + * @cond + * task. h + * @code + * uint32_t ulTaskGetIdleRunTimeCounter( void ); + * @endcode + * @endcond + * + * configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS + * must both be defined as 1 for this function to be available. The application + * must also then provide definitions for + * portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE() + * to configure a peripheral timer/counter and return the timers current count + * value respectively. The counter should be at least 10 times the frequency of + * the tick count. + * + * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total + * accumulated execution time being stored for each task. The resolution + * of the accumulated time value depends on the frequency of the timer + * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro. + * While uxTaskGetSystemState() and vTaskGetRunTimeStats() writes the total + * execution time of each task into a buffer, ulTaskGetIdleRunTimeCounter() + * returns the total execution time of just the idle task. + * + * @return The total run time of the idle task. This is the amount of time the + * idle task has actually been executing. The unit of time is dependent on the + * frequency configured using the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and + * portGET_RUN_TIME_COUNTER_VALUE() macros. + * + * @cond + * \defgroup ulTaskGetIdleRunTimeCounter ulTaskGetIdleRunTimeCounter + * @endcond * \ingroup TaskUtils */ -void vTaskGetRunTimeStats( char *pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ - -/** -* configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS -* must both be defined as 1 for this function to be available. The application -* must also then provide definitions for -* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE() -* to configure a peripheral timer/counter and return the timers current count -* value respectively. The counter should be at least 10 times the frequency of -* the tick count. -* -* Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total -* accumulated execution time being stored for each task. The resolution -* of the accumulated time value depends on the frequency of the timer -* configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro. -* While uxTaskGetSystemState() and vTaskGetRunTimeStats() writes the total -* execution time of each task into a buffer, ulTaskGetIdleRunTimeCounter() -* returns the total execution time of just the idle task. -* -* @return The total run time of the idle task. This is the amount of time the -* idle task has actually been executing. The unit of time is dependent on the -* frequency configured using the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and -* portGET_RUN_TIME_COUNTER_VALUE() macros. -* -* \ingroup TaskUtils -*/ uint32_t ulTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION; /** - * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this - * function to be available. + * task. h + * @code{c} + * BaseType_t xTaskNotifyIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction ); + * BaseType_t xTaskNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction ); + * @endcode * - * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private - * "notification value", which is a 32-bit unsigned integer (uint32_t). + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * + * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these + * functions to be available. + * + * Sends a direct to task notification to a task, with an optional value and + * action. + * + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. * * Events can be sent to a task using an intermediary object. Examples of such * objects are queues, semaphores, mutexes and event groups. Task notifications @@ -1865,28 +2280,46 @@ uint32_t ulTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION; * an intermediary object. * * A notification sent to a task can optionally perform an action, such as - * update, overwrite or increment the task's notification value. In that way - * task notifications can be used to send data to a task, or be used as light - * weight and fast binary or counting semaphores. + * update, overwrite or increment one of the task's notification values. In + * that way task notifications can be used to send data to a task, or be used as + * light weight and fast binary or counting semaphores. * - * A notification sent to a task will remain pending until it is cleared by the - * task calling xTaskNotifyWait() or ulTaskNotifyTake(). If the task was - * already in the Blocked state to wait for a notification when the notification - * arrives then the task will automatically be removed from the Blocked state - * (unblocked) and the notification cleared. - * - * A task can use xTaskNotifyWait() to [optionally] block to wait for a - * notification to be pending, or ulTaskNotifyTake() to [optionally] block - * to wait for its notification value to have a non-zero value. The task does + * A task can use xTaskNotifyWaitIndexed() to [optionally] block to wait for a + * notification to be pending, or ulTaskNotifyTakeIndexed() to [optionally] block + * to wait for a notification value to have a non-zero value. The task does * not consume any CPU time while it is in the Blocked state. * - * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * A notification sent to a task will remain pending until it is cleared by the + * task calling xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() (or their + * un-indexed equivalents). If the task was already in the Blocked state to + * wait for a notification when the notification arrives then the task will + * automatically be removed from the Blocked state (unblocked) and the + * notification cleared. + * + * **NOTE** Each notification within the array operates independently - a task + * can only block on one notification within the array at a time and will not be + * unblocked by a notification sent to any other array index. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. xTaskNotify() is the original API function, and remains backward + * compatible by always operating on the notification value at index 0 in the + * array. Calling xTaskNotify() is equivalent to calling xTaskNotifyIndexed() + * with the uxIndexToNotify parameter set to 0. * * @param xTaskToNotify The handle of the task being notified. The handle to a * task can be returned from the xTaskCreate() API function used to create the * task, and the handle of the currently running task can be obtained by calling * xTaskGetCurrentTaskHandle(). * + * @param uxIndexToNotify The index within the target task's array of + * notification values to which the notification is to be sent. uxIndexToNotify + * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotify() does + * not have this parameter and always sends notifications to index 0. + * * @param ulValue Data that can be sent with the notification. How the data is * used depends on the value of the eAction parameter. * @@ -1894,54 +2327,100 @@ uint32_t ulTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION; * 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. + * The target notification value is bitwise ORed with ulValue. + * xTaskNotifyIndexed() 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. + * The target notification value is incremented. ulValue is not used and + * xTaskNotifyIndexed() 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. + * The target notification value is set to the value of ulValue, even if the + * task being notified had not yet processed the previous notification at the + * same array index (the task already had a notification pending at that index). + * xTaskNotifyIndexed() 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. + * If the task being notified did not already have a notification pending at the + * same array index then the target notification value is set to ulValue and + * xTaskNotifyIndexed() will return pdPASS. If the task being notified already + * had a notification pending at the same array index 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. + * The task receives a notification at the specified array index without the + * notification value at that index being updated. ulValue is not used and + * xTaskNotifyIndexed() always returns pdPASS in this case. * - * @param pulPreviousNotificationValue Can be used to pass out the subject - * task's notification value before any bits are modified by the notify - * function. + * pulPreviousNotificationValue - + * Can be used to pass out the subject task's notification value before any + * bits are modified by the notify function. * * @return Dependent on the value of eAction. See the description of the * eAction parameter. * + * \defgroup xTaskNotifyIndexed xTaskNotifyIndexed * \ingroup TaskNotifications */ -BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue ) PRIVILEGED_FUNCTION; -#define xTaskNotify( xTaskToNotify, ulValue, eAction ) xTaskGenericNotify( ( xTaskToNotify ), ( ulValue ), ( eAction ), NULL ) -#define xTaskNotifyAndQuery( xTaskToNotify, ulValue, eAction, pulPreviousNotifyValue ) xTaskGenericNotify( ( xTaskToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) ) +BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, + UBaseType_t uxIndexToNotify, + uint32_t ulValue, + eNotifyAction eAction, + uint32_t * pulPreviousNotificationValue ) PRIVILEGED_FUNCTION; +#define xTaskNotify( xTaskToNotify, ulValue, eAction ) \ + xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), NULL ) +#define xTaskNotifyIndexed( xTaskToNotify, uxIndexToNotify, ulValue, eAction ) \ + xTaskGenericNotify( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), NULL ) /** - * Send task notification from an ISR. + * task. h + * @code{c} + * BaseType_t xTaskNotifyAndQueryIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotifyValue ); + * BaseType_t xTaskNotifyAndQuery( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotifyValue ); + * @endcode * - * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this - * function to be available. + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. * - * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private - * "notification value", which is a 32-bit unsigned integer (uint32_t). + * xTaskNotifyAndQueryIndexed() performs the same operation as + * xTaskNotifyIndexed() with the addition that it also returns the subject + * task's prior notification value (the notification value at the time the + * function is called rather than when the function returns) in the additional + * pulPreviousNotifyValue parameter. * - * A version of xTaskNotify() that can be used from an interrupt service routine - * (ISR). + * xTaskNotifyAndQuery() performs the same operation as xTaskNotify() with the + * addition that it also returns the subject task's prior notification value + * (the notification value as it was at the time the function is called, rather + * than when the function returns) in the additional pulPreviousNotifyValue + * parameter. + * + * \defgroup xTaskNotifyAndQueryIndexed xTaskNotifyAndQueryIndexed + * \ingroup TaskNotifications + */ +#define xTaskNotifyAndQuery( xTaskToNotify, ulValue, eAction, pulPreviousNotifyValue ) \ + xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) ) +#define xTaskNotifyAndQueryIndexed( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pulPreviousNotifyValue ) \ + xTaskGenericNotify( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) ) + +/** + * task. h + * @code{c} + * BaseType_t xTaskNotifyIndexedFromISR( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken ); + * BaseType_t xTaskNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * + * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these + * functions to be available. + * + * A version of xTaskNotifyIndexed() that can be used from an interrupt service + * routine (ISR). + * + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. * * Events can be sent to a task using an intermediary object. Examples of such * objects are queues, semaphores, mutexes and event groups. Task notifications @@ -1949,22 +2428,40 @@ BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNo * an intermediary object. * * A notification sent to a task can optionally perform an action, such as - * update, overwrite or increment the task's notification value. In that way - * task notifications can be used to send data to a task, or be used as light - * weight and fast binary or counting semaphores. + * update, overwrite or increment one of the task's notification values. In + * that way task notifications can be used to send data to a task, or be used as + * light weight and fast binary or counting semaphores. * - * A notification sent to a task will remain pending until it is cleared by the - * task calling xTaskNotifyWait() or ulTaskNotifyTake(). If the task was - * already in the Blocked state to wait for a notification when the notification - * arrives then the task will automatically be removed from the Blocked state - * (unblocked) and the notification cleared. - * - * A task can use xTaskNotifyWait() to [optionally] block to wait for a - * notification to be pending, or ulTaskNotifyTake() to [optionally] block - * to wait for its notification value to have a non-zero value. The task does + * A task can use xTaskNotifyWaitIndexed() to [optionally] block to wait for a + * notification to be pending, or ulTaskNotifyTakeIndexed() to [optionally] block + * to wait for a notification value to have a non-zero value. The task does * not consume any CPU time while it is in the Blocked state. * - * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * A notification sent to a task will remain pending until it is cleared by the + * task calling xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() (or their + * un-indexed equivalents). If the task was already in the Blocked state to + * wait for a notification when the notification arrives then the task will + * automatically be removed from the Blocked state (unblocked) and the + * notification cleared. + * + * **NOTE** Each notification within the array operates independently - a task + * can only block on one notification within the array at a time and will not be + * unblocked by a notification sent to any other array index. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. xTaskNotifyFromISR() is the original API function, and remains + * backward compatible by always operating on the notification value at index 0 + * within the array. Calling xTaskNotifyFromISR() is equivalent to calling + * xTaskNotifyIndexedFromISR() with the uxIndexToNotify parameter set to 0. + * + * @param uxIndexToNotify The index within the target task's array of + * notification values to which the notification is to be sent. uxIndexToNotify + * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyFromISR() + * does not have this parameter and always sends notifications to index 0. * * @param xTaskToNotify The handle of the task being notified. The handle to a * task can be returned from the xTaskCreate() API function used to create the @@ -1978,7 +2475,7 @@ BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNo * value, if at all. Valid values for eAction are as follows: * * eSetBits - - * The task's notification value is bitwise ORed with ulValue. xTaskNofify() + * The task's notification value is bitwise ORed with ulValue. xTaskNotify() * always returns pdPASS in this case. * * eIncrement - @@ -2002,9 +2499,6 @@ BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNo * updated. ulValue is not used and xTaskNotify() always returns pdPASS in * this case. * - * @param pulPreviousNotificationValue Can be used to pass out the subject task's - * notification value before any bits are modified by the notify function. - * * @param pxHigherPriorityTaskWoken xTaskNotifyFromISR() will set * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the * task to which the notification was sent to leave the Blocked state, and the @@ -2017,20 +2511,70 @@ BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNo * @return Dependent on the value of eAction. See the description of the * eAction parameter. * + * \defgroup xTaskNotifyIndexedFromISR xTaskNotifyIndexedFromISR + * \ingroup TaskNotifications + */ +BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, + UBaseType_t uxIndexToNotify, + uint32_t ulValue, + eNotifyAction eAction, + uint32_t * pulPreviousNotificationValue, + BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; +#define xTaskNotifyFromISR( xTaskToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) \ + xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) ) +#define xTaskNotifyIndexedFromISR( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) \ + xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) ) + +/** + * task. h + * @code{c} + * BaseType_t xTaskNotifyAndQueryIndexedFromISR( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken ); + * BaseType_t xTaskNotifyAndQueryFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * + * xTaskNotifyAndQueryIndexedFromISR() performs the same operation as + * xTaskNotifyIndexedFromISR() with the addition that it also returns the + * subject task's prior notification value (the notification value at the time + * the function is called rather than at the time the function returns) in the + * additional pulPreviousNotifyValue parameter. + * + * xTaskNotifyAndQueryFromISR() performs the same operation as + * xTaskNotifyFromISR() with the addition that it also returns the subject + * task's prior notification value (the notification value at the time the + * function is called rather than at the time the function returns) in the + * additional pulPreviousNotifyValue parameter. + * + * \defgroup xTaskNotifyAndQueryIndexedFromISR xTaskNotifyAndQueryIndexedFromISR * \ingroup TaskNotifications */ -BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; -#define xTaskNotifyFromISR( xTaskToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) ) -#define xTaskNotifyAndQueryFromISR( xTaskToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) ) +#define xTaskNotifyAndQueryIndexedFromISR( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) \ + xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) ) +#define xTaskNotifyAndQueryFromISR( xTaskToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) \ + xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) ) /** - * Wait for task notification + * task. h + * @code{c} + * BaseType_t xTaskNotifyWaitIndexed( UBaseType_t uxIndexToWaitOn, uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ); + * + * BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ); + * @endcode + * + * Waits for a direct to task notification to be pending at a given index within + * an array of direct to task notifications. + * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. * * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this * function to be available. * - * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private - * "notification value", which is a 32-bit unsigned integer (uint32_t). + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. * * Events can be sent to a task using an intermediary object. Examples of such * objects are queues, semaphores, mutexes and event groups. Task notifications @@ -2038,22 +2582,41 @@ BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulVal * an intermediary object. * * A notification sent to a task can optionally perform an action, such as - * update, overwrite or increment the task's notification value. In that way - * task notifications can be used to send data to a task, or be used as light - * weight and fast binary or counting semaphores. + * update, overwrite or increment one of the task's notification values. In + * that way task notifications can be used to send data to a task, or be used as + * light weight and fast binary or counting semaphores. * * A notification sent to a task will remain pending until it is cleared by the - * task calling xTaskNotifyWait() or ulTaskNotifyTake(). If the task was - * already in the Blocked state to wait for a notification when the notification - * arrives then the task will automatically be removed from the Blocked state - * (unblocked) and the notification cleared. - * - * A task can use xTaskNotifyWait() to [optionally] block to wait for a - * notification to be pending, or ulTaskNotifyTake() to [optionally] block - * to wait for its notification value to have a non-zero value. The task does + * task calling xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() (or their + * un-indexed equivalents). If the task was already in the Blocked state to + * wait for a notification when the notification arrives then the task will + * automatically be removed from the Blocked state (unblocked) and the + * notification cleared. + * + * A task can use xTaskNotifyWaitIndexed() to [optionally] block to wait for a + * notification to be pending, or ulTaskNotifyTakeIndexed() to [optionally] block + * to wait for a notification value to have a non-zero value. The task does * not consume any CPU time while it is in the Blocked state. * - * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * **NOTE** Each notification within the array operates independently - a task + * can only block on one notification within the array at a time and will not be + * unblocked by a notification sent to any other array index. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. xTaskNotifyWait() is the original API function, and remains backward + * compatible by always operating on the notification value at index 0 in the + * array. Calling xTaskNotifyWait() is equivalent to calling + * xTaskNotifyWaitIndexed() with the uxIndexToWaitOn parameter set to 0. + * + * @param uxIndexToWaitOn The index within the calling task's array of + * notification values on which the calling task will wait for a notification to + * be received. uxIndexToWaitOn must be less than + * configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyWait() does + * not have this parameter and always waits for notifications on index 0. * * @param ulBitsToClearOnEntry Bits that are set in ulBitsToClearOnEntry value * will be cleared in the calling task's notification value before the task @@ -2092,18 +2655,39 @@ BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulVal * already pending when xTaskNotifyWait was called) then pdPASS is * returned. Otherwise pdFAIL is returned. * + * \defgroup xTaskNotifyWaitIndexed xTaskNotifyWaitIndexed * \ingroup TaskNotifications */ -BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +BaseType_t xTaskGenericNotifyWait( UBaseType_t uxIndexToWaitOn, + uint32_t ulBitsToClearOnEntry, + uint32_t ulBitsToClearOnExit, + uint32_t * pulNotificationValue, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +#define xTaskNotifyWait( ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait ) \ + xTaskGenericNotifyWait( tskDEFAULT_INDEX_TO_NOTIFY, ( ulBitsToClearOnEntry ), ( ulBitsToClearOnExit ), ( pulNotificationValue ), ( xTicksToWait ) ) +#define xTaskNotifyWaitIndexed( uxIndexToWaitOn, ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait ) \ + xTaskGenericNotifyWait( ( uxIndexToWaitOn ), ( ulBitsToClearOnEntry ), ( ulBitsToClearOnExit ), ( pulNotificationValue ), ( xTicksToWait ) ) /** - * Simplified macro for sending task notification. + * task. h + * @code{c} + * BaseType_t xTaskNotifyGiveIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify ); + * BaseType_t xTaskNotifyGive( TaskHandle_t xTaskToNotify ); + * @endcode * - * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this macro - * to be available. + * Sends a direct to task notification to a particular index in the target + * task's notification array in a manner similar to giving a counting semaphore. + * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for more details. * - * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private - * "notification value", which is a 32-bit unsigned integer (uint32_t). + * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these + * macros to be available. + * + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. * * Events can be sent to a task using an intermediary object. Examples of such * objects are queues, semaphores, mutexes and event groups. Task notifications @@ -2111,46 +2695,76 @@ BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClea * an intermediary object. * * A notification sent to a task can optionally perform an action, such as - * update, overwrite or increment the task's notification value. In that way - * task notifications can be used to send data to a task, or be used as light - * weight and fast binary or counting semaphores. + * update, overwrite or increment one of the task's notification values. In + * that way task notifications can be used to send data to a task, or be used as + * light weight and fast binary or counting semaphores. * - * xTaskNotifyGive() is a helper macro intended for use when task notifications - * are used as light weight and faster binary or counting semaphore equivalents. - * Actual FreeRTOS semaphores are given using the xSemaphoreGive() API function, - * the equivalent action that instead uses a task notification is - * xTaskNotifyGive(). + * xTaskNotifyGiveIndexed() is a helper macro intended for use when task + * notifications are used as light weight and faster binary or counting + * semaphore equivalents. Actual FreeRTOS semaphores are given using the + * xSemaphoreGive() API function, the equivalent action that instead uses a task + * notification is xTaskNotifyGiveIndexed(). * * When task notifications are being used as a binary or counting semaphore * equivalent then the task being notified should wait for the notification - * using the ulTaskNotificationTake() API function rather than the - * xTaskNotifyWait() API function. - * - * See http://www.FreeRTOS.org/RTOS-task-notifications.html for more details. + * using the ulTaskNotificationTakeIndexed() API function rather than the + * xTaskNotifyWaitIndexed() API function. + * + * **NOTE** Each notification within the array operates independently - a task + * can only block on one notification within the array at a time and will not be + * unblocked by a notification sent to any other array index. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. xTaskNotifyGive() is the original API function, and remains backward + * compatible by always operating on the notification value at index 0 in the + * array. Calling xTaskNotifyGive() is equivalent to calling + * xTaskNotifyGiveIndexed() with the uxIndexToNotify parameter set to 0. * * @param xTaskToNotify The handle of the task being notified. The handle to a * task can be returned from the xTaskCreate() API function used to create the * task, and the handle of the currently running task can be obtained by calling * xTaskGetCurrentTaskHandle(). * + * @param uxIndexToNotify The index within the target task's array of + * notification values to which the notification is to be sent. uxIndexToNotify + * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyGive() + * does not have this parameter and always sends notifications to index 0. + * * @return xTaskNotifyGive() is a macro that calls xTaskNotify() with the * eAction parameter set to eIncrement - so pdPASS is always returned. * + * \defgroup xTaskNotifyGiveIndexed xTaskNotifyGiveIndexed * \ingroup TaskNotifications */ -#define xTaskNotifyGive( xTaskToNotify ) xTaskGenericNotify( ( xTaskToNotify ), ( 0 ), eIncrement, NULL ) +#define xTaskNotifyGive( xTaskToNotify ) \ + xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( 0 ), eIncrement, NULL ) +#define xTaskNotifyGiveIndexed( xTaskToNotify, uxIndexToNotify ) \ + xTaskGenericNotify( ( xTaskToNotify ), ( uxIndexToNotify ), ( 0 ), eIncrement, NULL ) /** - * Simplified macro for sending task notification from ISR. + * task. h + * @code{c} + * void vTaskNotifyGiveIndexedFromISR( TaskHandle_t xTaskHandle, UBaseType_t uxIndexToNotify, BaseType_t *pxHigherPriorityTaskWoken ); + * void vTaskNotifyGiveFromISR( TaskHandle_t xTaskHandle, BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * + * A version of xTaskNotifyGiveIndexed() that can be called from an interrupt + * service routine (ISR). + * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for more details. * * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this macro * to be available. * - * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private - * "notification value", which is a 32-bit unsigned integer (uint32_t). - * - * A version of xTaskNotifyGive() that can be called from an interrupt service - * routine (ISR). + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. * * Events can be sent to a task using an intermediary object. Examples of such * objects are queues, semaphores, mutexes and event groups. Task notifications @@ -2158,28 +2772,46 @@ BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClea * an intermediary object. * * A notification sent to a task can optionally perform an action, such as - * update, overwrite or increment the task's notification value. In that way - * task notifications can be used to send data to a task, or be used as light - * weight and fast binary or counting semaphores. + * update, overwrite or increment one of the task's notification values. In + * that way task notifications can be used to send data to a task, or be used as + * light weight and fast binary or counting semaphores. * - * vTaskNotifyGiveFromISR() is intended for use when task notifications are - * used as light weight and faster binary or counting semaphore equivalents. + * vTaskNotifyGiveIndexedFromISR() is intended for use when task notifications + * are used as light weight and faster binary or counting semaphore equivalents. * Actual FreeRTOS semaphores are given from an ISR using the * xSemaphoreGiveFromISR() API function, the equivalent action that instead uses - * a task notification is vTaskNotifyGiveFromISR(). + * a task notification is vTaskNotifyGiveIndexedFromISR(). * * When task notifications are being used as a binary or counting semaphore * equivalent then the task being notified should wait for the notification - * using the ulTaskNotificationTake() API function rather than the - * xTaskNotifyWait() API function. - * - * See http://www.FreeRTOS.org/RTOS-task-notifications.html for more details. + * using the ulTaskNotificationTakeIndexed() API function rather than the + * xTaskNotifyWaitIndexed() API function. + * + * **NOTE** Each notification within the array operates independently - a task + * can only block on one notification within the array at a time and will not be + * unblocked by a notification sent to any other array index. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. xTaskNotifyFromISR() is the original API function, and remains + * backward compatible by always operating on the notification value at index 0 + * within the array. Calling xTaskNotifyGiveFromISR() is equivalent to calling + * xTaskNotifyGiveIndexedFromISR() with the uxIndexToNotify parameter set to 0. * * @param xTaskToNotify The handle of the task being notified. The handle to a * task can be returned from the xTaskCreate() API function used to create the * task, and the handle of the currently running task can be obtained by calling * xTaskGetCurrentTaskHandle(). * + * @param uxIndexToNotify The index within the target task's array of + * notification values to which the notification is to be sent. uxIndexToNotify + * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. + * xTaskNotifyGiveFromISR() does not have this parameter and always sends + * notifications to index 0. + * * @param pxHigherPriorityTaskWoken vTaskNotifyGiveFromISR() will set * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the * task to which the notification was sent to leave the Blocked state, and the @@ -2189,18 +2821,38 @@ 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 vTaskNotifyGiveIndexedFromISR vTaskNotifyGiveIndexedFromISR * \ingroup TaskNotifications */ -void vTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; +void vTaskGenericNotifyGiveFromISR( TaskHandle_t xTaskToNotify, + UBaseType_t uxIndexToNotify, + BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; +#define vTaskNotifyGiveFromISR( xTaskToNotify, pxHigherPriorityTaskWoken ) \ + vTaskGenericNotifyGiveFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( pxHigherPriorityTaskWoken ) ); +#define vTaskNotifyGiveIndexedFromISR( xTaskToNotify, uxIndexToNotify, pxHigherPriorityTaskWoken ) \ + vTaskGenericNotifyGiveFromISR( ( xTaskToNotify ), ( uxIndexToNotify ), ( pxHigherPriorityTaskWoken ) ); /** - * Simplified macro for receiving task notification. + * task. h + * @code{c} + * uint32_t ulTaskNotifyTakeIndexed( UBaseType_t uxIndexToWaitOn, BaseType_t xClearCountOnExit, TickType_t xTicksToWait ); + * + * uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait ); + * @endcode + * + * Waits for a direct to task notification on a particular index in the calling + * task's notification array in a manner similar to taking a counting semaphore. + * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. * * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this * function to be available. * - * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private - * "notification value", which is a 32-bit unsigned integer (uint32_t). + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. * * Events can be sent to a task using an intermediary object. Examples of such * objects are queues, semaphores, mutexes and event groups. Task notifications @@ -2208,35 +2860,54 @@ void vTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPri * an intermediary object. * * A notification sent to a task can optionally perform an action, such as - * update, overwrite or increment the task's notification value. In that way - * task notifications can be used to send data to a task, or be used as light - * weight and fast binary or counting semaphores. + * update, overwrite or increment one of the task's notification values. In + * that way task notifications can be used to send data to a task, or be used as + * light weight and fast binary or counting semaphores. * - * ulTaskNotifyTake() is intended for use when a task notification is used as a - * faster and lighter weight binary or counting semaphore alternative. Actual - * FreeRTOS semaphores are taken using the xSemaphoreTake() API function, the - * equivalent action that instead uses a task notification is - * ulTaskNotifyTake(). + * ulTaskNotifyTakeIndexed() is intended for use when a task notification is + * used as a faster and lighter weight binary or counting semaphore alternative. + * Actual FreeRTOS semaphores are taken using the xSemaphoreTake() API function, + * the equivalent action that instead uses a task notification is + * ulTaskNotifyTakeIndexed(). * * When a task is using its notification value as a binary or counting semaphore - * other tasks should send notifications to it using the xTaskNotifyGive() - * macro, or xTaskNotify() function with the eAction parameter set to + * other tasks should send notifications to it using the xTaskNotifyGiveIndexed() + * macro, or xTaskNotifyIndex() function with the eAction parameter set to * eIncrement. * - * ulTaskNotifyTake() can either clear the task's notification value to - * zero on exit, in which case the notification value acts like a binary - * semaphore, or decrement the task's notification value on exit, in which case - * the notification value acts like a counting semaphore. + * ulTaskNotifyTakeIndexed() can either clear the task's notification value at + * the array index specified by the uxIndexToWaitOn parameter to zero on exit, + * in which case the notification value acts like a binary semaphore, or + * decrement the notification value on exit, in which case the notification + * value acts like a counting semaphore. * - * A task can use ulTaskNotifyTake() to [optionally] block to wait for a + * A task can use ulTaskNotifyTakeIndexed() to [optionally] block to wait for * the task's notification value to be non-zero. The task does not consume any * CPU time while it is in the Blocked state. * - * Where as xTaskNotifyWait() will return when a notification is pending, - * ulTaskNotifyTake() will return when the task's notification value is + * Where as xTaskNotifyWaitIndexed() will return when a notification is pending, + * ulTaskNotifyTakeIndexed() will return when the task's notification value is * not zero. * - * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * **NOTE** Each notification within the array operates independently - a task + * can only block on one notification within the array at a time and will not be + * unblocked by a notification sent to any other array index. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. ulTaskNotifyTake() is the original API function, and remains backward + * compatible by always operating on the notification value at index 0 in the + * array. Calling ulTaskNotifyTake() is equivalent to calling + * ulTaskNotifyTakeIndexed() with the uxIndexToWaitOn parameter set to 0. + * + * @param uxIndexToWaitOn The index within the calling task's array of + * notification values on which the calling task will wait for a notification to + * be non-zero. uxIndexToWaitOn must be less than + * configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyTake() does + * not have this parameter and always waits for notifications on index 0. * * @param xClearCountOnExit if xClearCountOnExit is pdFALSE then the task's * notification value is decremented when the function exits. In this way the @@ -2256,23 +2927,289 @@ 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 ulTaskNotifyTakeIndexed ulTaskNotifyTakeIndexed * \ingroup TaskNotifications */ -uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +uint32_t ulTaskGenericNotifyTake( UBaseType_t uxIndexToWaitOn, + BaseType_t xClearCountOnExit, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +#define ulTaskNotifyTake( xClearCountOnExit, xTicksToWait ) \ + ulTaskGenericNotifyTake( ( tskDEFAULT_INDEX_TO_NOTIFY ), ( xClearCountOnExit ), ( xTicksToWait ) ) +#define ulTaskNotifyTakeIndexed( uxIndexToWaitOn, xClearCountOnExit, xTicksToWait ) \ + ulTaskGenericNotifyTake( ( uxIndexToWaitOn ), ( xClearCountOnExit ), ( xTicksToWait ) ) /** + * task. h + * @code{c} + * BaseType_t xTaskNotifyStateClearIndexed( TaskHandle_t xTask, UBaseType_t uxIndexToCLear ); * - * If the notification state of the task referenced by the handle xTask is - * eNotified, then set the task's notification state to eNotWaitingNotification. - * The task's notification value is not altered. Set xTask to NULL to clear the - * notification state of the calling task. + * BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask ); + * @endcode + * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * + * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these + * functions to be available. + * + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. + * + * If a notification is sent to an index within the array of notifications then + * the notification at that index is said to be 'pending' until it is read or + * explicitly cleared by the receiving task. xTaskNotifyStateClearIndexed() + * is the function that clears a pending notification without reading the + * notification value. The notification value at the same array index is not + * altered. Set xTask to NULL to clear the notification state of the calling + * task. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. xTaskNotifyStateClear() is the original API function, and remains + * backward compatible by always operating on the notification value at index 0 + * within the array. Calling xTaskNotifyStateClear() is equivalent to calling + * xTaskNotifyStateClearIndexed() with the uxIndexToNotify parameter set to 0. + * + * @param xTask The handle of the RTOS task that will have a notification state + * cleared. Set xTask to NULL to clear a notification state in the calling + * task. To obtain a task's handle create the task using xTaskCreate() and + * make use of the pxCreatedTask parameter, or create the task using + * xTaskCreateStatic() and store the returned value, or use the task's name in + * a call to xTaskGetHandle(). + * + * @param uxIndexToClear The index within the target task's array of + * notification values to act upon. For example, setting uxIndexToClear to 1 + * will clear the state of the notification at index 1 within the array. + * uxIndexToClear must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. + * ulTaskNotifyStateClear() does not have this parameter and always acts on the + * notification at index 0. * * @return pdTRUE if the task's notification state was set to * eNotWaitingNotification, otherwise pdFALSE. * + * \defgroup xTaskNotifyStateClearIndexed xTaskNotifyStateClearIndexed * \ingroup TaskNotifications */ -BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask ); +BaseType_t xTaskGenericNotifyStateClear( TaskHandle_t xTask, + UBaseType_t uxIndexToClear ) PRIVILEGED_FUNCTION; +#define xTaskNotifyStateClear( xTask ) \ + xTaskGenericNotifyStateClear( ( xTask ), ( tskDEFAULT_INDEX_TO_NOTIFY ) ) +#define xTaskNotifyStateClearIndexed( xTask, uxIndexToClear ) \ + xTaskGenericNotifyStateClear( ( xTask ), ( uxIndexToClear ) ) + +/** + * task. h + * @code{c} + * uint32_t ulTaskNotifyValueClearIndexed( TaskHandle_t xTask, UBaseType_t uxIndexToClear, uint32_t ulBitsToClear ); + * + * uint32_t ulTaskNotifyValueClear( TaskHandle_t xTask, uint32_t ulBitsToClear ); + * @endcode + * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * + * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these + * functions to be available. + * + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. + * + * ulTaskNotifyValueClearIndexed() clears the bits specified by the + * ulBitsToClear bit mask in the notification value at array index uxIndexToClear + * of the task referenced by xTask. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. ulTaskNotifyValueClear() is the original API function, and remains + * backward compatible by always operating on the notification value at index 0 + * within the array. Calling ulTaskNotifyValueClear() is equivalent to calling + * ulTaskNotifyValueClearIndexed() with the uxIndexToClear parameter set to 0. + * + * @param xTask The handle of the RTOS task that will have bits in one of its + * notification values cleared. Set xTask to NULL to clear bits in a + * notification value of the calling task. To obtain a task's handle create the + * task using xTaskCreate() and make use of the pxCreatedTask parameter, or + * create the task using xTaskCreateStatic() and store the returned value, or + * use the task's name in a call to xTaskGetHandle(). + * + * @param uxIndexToClear The index within the target task's array of + * notification values in which to clear the bits. uxIndexToClear + * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. + * ulTaskNotifyValueClear() does not have this parameter and always clears bits + * in the notification value at index 0. + * + * @param ulBitsToClear Bit mask of the bits to clear in the notification value of + * xTask. Set a bit to 1 to clear the corresponding bits in the task's notification + * value. Set ulBitsToClear to 0xffffffff (UINT_MAX on 32-bit architectures) to clear + * the notification value to 0. Set ulBitsToClear to 0 to query the task's + * notification value without clearing any bits. + * + * + * @return The value of the target task's notification value before the bits + * specified by ulBitsToClear were cleared. + * \defgroup ulTaskNotifyValueClear ulTaskNotifyValueClear + * \ingroup TaskNotifications + */ +uint32_t ulTaskGenericNotifyValueClear( TaskHandle_t xTask, + UBaseType_t uxIndexToClear, + uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION; +#define ulTaskNotifyValueClear( xTask, ulBitsToClear ) \ + ulTaskGenericNotifyValueClear( ( xTask ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulBitsToClear ) ) +#define ulTaskNotifyValueClearIndexed( xTask, uxIndexToClear, ulBitsToClear ) \ + ulTaskGenericNotifyValueClear( ( xTask ), ( uxIndexToClear ), ( ulBitsToClear ) ) + +/** + * @cond + * task.h + * @code{c} + * void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ); + * @endcode + * @endcond + * + * Capture the current time for future use with xTaskCheckForTimeOut(). + * + * @param pxTimeOut Pointer to a timeout object into which the current time + * is to be captured. The captured time includes the tick count and the number + * of times the tick count has overflowed since the system first booted. + * \defgroup vTaskSetTimeOutState vTaskSetTimeOutState + * @cond + * \ingroup TaskCtrl + * @endcond + */ +void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION; + +/** + * @cond + * task.h + * @code + * BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait ); + * @endcode + * @endcond + * + * Determines if pxTicksToWait ticks has passed since a time was captured + * using a call to vTaskSetTimeOutState(). The captured time includes the tick + * count and the number of times the tick count has overflowed. + * + * @param pxTimeOut The time status as captured previously using + * vTaskSetTimeOutState. If the timeout has not yet occurred, it is updated + * to reflect the current time status. + * @param pxTicksToWait The number of ticks to check for timeout i.e. if + * pxTicksToWait ticks have passed since pxTimeOut was last updated (either by + * vTaskSetTimeOutState() or xTaskCheckForTimeOut()), the timeout has occurred. + * If the timeout has not occurred, pxTicksToWait is updated to reflect the + * number of remaining ticks. + * + * @return If timeout has occurred, pdTRUE is returned. Otherwise pdFALSE is + * returned and pxTicksToWait is updated to reflect the number of remaining + * ticks. + * + * @see https://www.FreeRTOS.org/xTaskCheckForTimeOut.html + * + * Example Usage: + * @code + * // Driver library function used to receive uxWantedBytes from an Rx buffer + * // that is filled by a UART interrupt. If there are not enough bytes in the + * // Rx buffer then the task enters the Blocked state until it is notified that + * // more data has been placed into the buffer. If there is still not enough + * // data then the task re-enters the Blocked state, and xTaskCheckForTimeOut() + * // is used to re-calculate the Block time to ensure the total amount of time + * // spent in the Blocked state does not exceed MAX_TIME_TO_WAIT. This + * // continues until either the buffer contains at least uxWantedBytes bytes, + * // or the total amount of time spent in the Blocked state reaches + * // MAX_TIME_TO_WAIT – at which point the task reads however many bytes are + * // available up to a maximum of uxWantedBytes. + * + * size_t xUART_Receive( uint8_t *pucBuffer, size_t uxWantedBytes ) + * { + * size_t uxReceived = 0; + * TickType_t xTicksToWait = MAX_TIME_TO_WAIT; + * TimeOut_t xTimeOut; + * + * // Initialize xTimeOut. This records the time at which this function + * // was entered. + * vTaskSetTimeOutState( &xTimeOut ); + * + * // Loop until the buffer contains the wanted number of bytes, or a + * // timeout occurs. + * while( UART_bytes_in_rx_buffer( pxUARTInstance ) < uxWantedBytes ) + * { + * // The buffer didn't contain enough data so this task is going to + * // enter the Blocked state. Adjusting xTicksToWait to account for + * // any time that has been spent in the Blocked state within this + * // function so far to ensure the total amount of time spent in the + * // Blocked state does not exceed MAX_TIME_TO_WAIT. + * if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) != pdFALSE ) + * { + * //Timed out before the wanted number of bytes were available, + * // exit the loop. + * break; + * } + * + * // Wait for a maximum of xTicksToWait ticks to be notified that the + * // receive interrupt has placed more data into the buffer. + * ulTaskNotifyTake( pdTRUE, xTicksToWait ); + * } + * + * // Attempt to read uxWantedBytes from the receive buffer into pucBuffer. + * // The actual number of bytes read (which might be less than + * // uxWantedBytes) is returned. + * uxReceived = UART_read_from_receive_buffer( pxUARTInstance, + * pucBuffer, + * uxWantedBytes ); + * + * return uxReceived; + * } + * @endcode + * @cond + * \defgroup xTaskCheckForTimeOut xTaskCheckForTimeOut + * @endcond + * \ingroup TaskCtrl + */ +BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, + TickType_t * const pxTicksToWait ) PRIVILEGED_FUNCTION; + +/** + * @cond + * task.h + * @code{c} + * BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp ); + * @endcode + * @endcond + * + * This function corrects the tick count value after the application code has held + * interrupts disabled for an extended period resulting in tick interrupts having + * been missed. + * + * This function is similar to vTaskStepTick(), however, unlike + * vTaskStepTick(), xTaskCatchUpTicks() may move the tick count forward past a + * time at which a task should be removed from the blocked state. That means + * tasks may have to be removed from the blocked state as the tick count is + * moved. + * + * @param xTicksToCatchUp The number of tick interrupts that have been missed due to + * interrupts being disabled. Its value is not computed automatically, so must be + * computed by the application writer. + * + * @return pdTRUE if moving the tick count forward resulted in a task leaving the + * blocked state and a context switch being performed. Otherwise pdFALSE. + * + * \defgroup xTaskCatchUpTicks xTaskCatchUpTicks + * @cond + * \ingroup TaskCtrl + * @endcond + */ +BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) PRIVILEGED_FUNCTION; + /*----------------------------------------------------------- * SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES @@ -2299,7 +3236,6 @@ TaskHandle_t xTaskGetCurrentTaskHandleForCPU( BaseType_t cpuid ); */ TaskHandle_t xTaskGetIdleTaskHandleForCPU( UBaseType_t cpuid ); - /* * Get the current core affinity of a task */ @@ -2339,7 +3275,7 @@ BaseType_t xTaskIncrementTick( void ) PRIVILEGED_FUNCTION; * xItemValue value, and inserts the list item at the end of the list. * * The 'ordered' version uses the existing event list item value (which is the - * owning tasks priority) to insert the list item into the event list is task + * owning task's priority) to insert the list item into the event list in task * priority order. * * @param pxEventList The list containing tasks that are blocked waiting @@ -2349,12 +3285,15 @@ BaseType_t xTaskIncrementTick( void ) PRIVILEGED_FUNCTION; * event list is not ordered by task priority. * * @param xTicksToWait The maximum amount of time that the task should wait - * for the event to occur. This is specified in kernel ticks,the constant + * for the event to occur. This is specified in kernel ticks, the constant * portTICK_PERIOD_MS can be used to convert kernel ticks into a real time * period. */ -void vTaskPlaceOnEventList( List_t * const pxEventList, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; -void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, const TickType_t xItemValue, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +void vTaskPlaceOnEventList( List_t * const pxEventList, + const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, + const TickType_t xItemValue, + const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; /* * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN @@ -2367,7 +3306,9 @@ void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, const TickType_t xIte * indefinitely, whereas vTaskPlaceOnEventList() does. * */ -void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION; +void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, + TickType_t xTicksToWait, + const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION; /* * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN @@ -2394,7 +3335,8 @@ void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, TickType_t xTi * making the call, otherwise pdFALSE. */ BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList ) PRIVILEGED_FUNCTION; -BaseType_t xTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, const TickType_t xItemValue ) PRIVILEGED_FUNCTION; +BaseType_t xTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, + const TickType_t xItemValue ) PRIVILEGED_FUNCTION; /* * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY @@ -2404,7 +3346,7 @@ BaseType_t xTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, cons * Sets the pointer to the current TCB to the TCB of the highest priority task * that is ready to run. */ -void vTaskSwitchContext( void ) PRIVILEGED_FUNCTION; +portDONT_DISCARD void vTaskSwitchContext( void ) PRIVILEGED_FUNCTION; /* * THESE FUNCTIONS MUST NOT BE USED FROM APPLICATION CODE. THEY ARE USED BY @@ -2417,17 +3359,6 @@ TickType_t uxTaskResetEventItemValue( void ) PRIVILEGED_FUNCTION; */ TaskHandle_t xTaskGetCurrentTaskHandle( void ) PRIVILEGED_FUNCTION; -/* - * Capture the current time status for future reference. - */ -void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION; - -/* - * Compare the time status now with that previously captured to see if the - * timeout has expired. - */ -BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait ) PRIVILEGED_FUNCTION; - /* * Shortcut used by the queue implementation to prevent unnecessary call to * taskYIELD(); @@ -2460,7 +3391,8 @@ BaseType_t xTaskPriorityDisinherit( TaskHandle_t const pxMutexHolder ) PRIVILEGE * the highest priority task that is still waiting for the mutex (if there were * more than one task waiting for the mutex). */ -void vTaskPriorityDisinheritAfterTimeout( TaskHandle_t const pxMutexHolder, UBaseType_t uxHighestPriorityWaitingTask ) PRIVILEGED_FUNCTION; +void vTaskPriorityDisinheritAfterTimeout( TaskHandle_t const pxMutexHolder, + UBaseType_t uxHighestPriorityWaitingTask ) PRIVILEGED_FUNCTION; /* * Get the uxTCBNumber assigned to the task referenced by the xTask parameter. @@ -2476,7 +3408,8 @@ BaseType_t xTaskGetAffinity( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; * Set the uxTaskNumber of the task referenced by the xTask parameter to * uxHandle. */ -void vTaskSetTaskNumber( TaskHandle_t xTask, const UBaseType_t uxHandle ) PRIVILEGED_FUNCTION; +void vTaskSetTaskNumber( TaskHandle_t xTask, + const UBaseType_t uxHandle ) PRIVILEGED_FUNCTION; /* * Only available when configUSE_TICKLESS_IDLE is set to 1. @@ -2488,19 +3421,6 @@ void vTaskSetTaskNumber( TaskHandle_t xTask, const UBaseType_t uxHandle ) PRIVIL */ void vTaskStepTick( const TickType_t xTicksToJump ) PRIVILEGED_FUNCTION; -/* Correct the tick count value after the application code has held -interrupts disabled for an extended period. xTicksToCatchUp is the number -of tick interrupts that have been missed due to interrupts being disabled. -Its value is not computed automatically, so must be computed by the -application writer. - -This function is similar to vTaskStepTick(), however, unlike -vTaskStepTick(), xTaskCatchUpTicks() may move the tick count forward past a -time at which a task should be removed from the blocked state. That means -tasks may have to be removed from the blocked state as the tick count is -moved. */ -BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) PRIVILEGED_FUNCTION; - /* * Only available when configUSE_TICKLESS_IDLE is set to 1. * Provided for use within portSUPPRESS_TICKS_AND_SLEEP() to allow the port @@ -2524,44 +3444,20 @@ eSleepModeStatus eTaskConfirmSleepModeStatus( void ) PRIVILEGED_FUNCTION; TaskHandle_t pvTaskIncrementMutexHeldCount( void ) PRIVILEGED_FUNCTION; /* - * For internal use only. Same as vTaskSetTimeOutState(), but without a critial + * For internal use only. Same as vTaskSetTimeOutState(), but without a critical * section. */ void vTaskInternalSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION; -/* - * This function fills array with TaskSnapshot_t structures for every task in the system. - * Used by panic handling code to get snapshots of all tasks in the system. - * Only available when configENABLE_TASK_SNAPSHOT is set to 1. - * @param pxTaskSnapshotArray Pointer to array of TaskSnapshot_t structures to store tasks snapshot data. - * @param uxArraySize Size of tasks snapshots array. - * @param pxTcbSz Pointer to store size of TCB. - * @return Number of elements stored in array. - */ -UBaseType_t uxTaskGetSnapshotAll( TaskSnapshot_t * const pxTaskSnapshotArray, const UBaseType_t uxArraySize, UBaseType_t * const pxTcbSz ); - -/* - * This function iterates over all tasks in the system. - * Used by panic handling code to iterate over tasks in the system. - * Only available when configENABLE_TASK_SNAPSHOT is set to 1. - * @note This function should not be used while FreeRTOS is running (as it doesn't acquire any locks). - * @param pxTask task handle. - * @return Handle for the next task. If pxTask is NULL, returns hadnle for the first task. - */ -TaskHandle_t pxTaskGetNext( TaskHandle_t pxTask ); - -/* - * This function fills TaskSnapshot_t structure for specified task. - * Used by panic handling code to get snapshot of a task. - * Only available when configENABLE_TASK_SNAPSHOT is set to 1. - * @note This function should not be used while FreeRTOS is running (as it doesn't acquire any locks). - * @param pxTask task handle. - * @param pxTaskSnapshot address of TaskSnapshot_t structure to fill. - */ -void vTaskGetSnapshot( TaskHandle_t pxTask, TaskSnapshot_t *pxTaskSnapshot ); +#ifdef ESP_PLATFORM +/* TODO: IDF-3683 */ +#include "freertos/task_snapshot.h" +#endif // ESP_PLATFORM /** @endcond */ + #ifdef __cplusplus -} + } #endif +/* *INDENT-ON* */ #endif /* INC_TASK_H */ diff --git a/tools/sdk/esp32c3/include/freertos/include/freertos/timers.h b/tools/sdk/esp32c3/include/freertos/include/freertos/timers.h index 9a5e23385ff..a8bc4f38c78 100644 --- a/tools/sdk/esp32c3/include/freertos/include/freertos/timers.h +++ b/tools/sdk/esp32c3/include/freertos/include/freertos/timers.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ @@ -30,41 +29,43 @@ #define TIMERS_H #ifndef INC_FREERTOS_H - #error "include FreeRTOS.h must appear in source files before include timers.h" + #error "include FreeRTOS.h must appear in source files before include timers.h" #endif /*lint -save -e537 This headers are only multiply included if the application code -happens to also be including task.h. */ + * happens to also be including task.h. */ #include "task.h" /*lint -restore */ +/* *INDENT-OFF* */ #ifdef __cplusplus -extern "C" { + extern "C" { #endif +/* *INDENT-ON* */ /*----------------------------------------------------------- * MACROS AND DEFINITIONS *----------------------------------------------------------*/ /* IDs for commands that can be sent/received on the timer queue. These are to -be used solely through the macros that make up the public software timer API, -as defined below. The commands that are sent from interrupts must use the -highest numbers as tmrFIRST_FROM_ISR_COMMAND is used to determine if the task -or interrupt version of the queue send function should be used. */ -#define tmrCOMMAND_EXECUTE_CALLBACK_FROM_ISR ( ( BaseType_t ) -2 ) -#define tmrCOMMAND_EXECUTE_CALLBACK ( ( BaseType_t ) -1 ) -#define tmrCOMMAND_START_DONT_TRACE ( ( BaseType_t ) 0 ) -#define tmrCOMMAND_START ( ( BaseType_t ) 1 ) -#define tmrCOMMAND_RESET ( ( BaseType_t ) 2 ) -#define tmrCOMMAND_STOP ( ( BaseType_t ) 3 ) -#define tmrCOMMAND_CHANGE_PERIOD ( ( BaseType_t ) 4 ) -#define tmrCOMMAND_DELETE ( ( BaseType_t ) 5 ) + * be used solely through the macros that make up the public software timer API, + * as defined below. The commands that are sent from interrupts must use the + * highest numbers as tmrFIRST_FROM_ISR_COMMAND is used to determine if the task + * or interrupt version of the queue send function should be used. */ +#define tmrCOMMAND_EXECUTE_CALLBACK_FROM_ISR ( ( BaseType_t ) -2 ) +#define tmrCOMMAND_EXECUTE_CALLBACK ( ( BaseType_t ) -1 ) +#define tmrCOMMAND_START_DONT_TRACE ( ( BaseType_t ) 0 ) +#define tmrCOMMAND_START ( ( BaseType_t ) 1 ) +#define tmrCOMMAND_RESET ( ( BaseType_t ) 2 ) +#define tmrCOMMAND_STOP ( ( BaseType_t ) 3 ) +#define tmrCOMMAND_CHANGE_PERIOD ( ( BaseType_t ) 4 ) +#define tmrCOMMAND_DELETE ( ( BaseType_t ) 5 ) -#define tmrFIRST_FROM_ISR_COMMAND ( ( BaseType_t ) 6 ) -#define tmrCOMMAND_START_FROM_ISR ( ( BaseType_t ) 6 ) -#define tmrCOMMAND_RESET_FROM_ISR ( ( BaseType_t ) 7 ) -#define tmrCOMMAND_STOP_FROM_ISR ( ( BaseType_t ) 8 ) -#define tmrCOMMAND_CHANGE_PERIOD_FROM_ISR ( ( BaseType_t ) 9 ) +#define tmrFIRST_FROM_ISR_COMMAND ( ( BaseType_t ) 6 ) +#define tmrCOMMAND_START_FROM_ISR ( ( BaseType_t ) 6 ) +#define tmrCOMMAND_RESET_FROM_ISR ( ( BaseType_t ) 7 ) +#define tmrCOMMAND_STOP_FROM_ISR ( ( BaseType_t ) 8 ) +#define tmrCOMMAND_CHANGE_PERIOD_FROM_ISR ( ( BaseType_t ) 9 ) /** @@ -74,20 +75,30 @@ or interrupt version of the queue send function should be used. */ * (for example, xTimerStart(), xTimerReset(), etc.). */ struct tmrTimerControl; /* The old naming convention is used to prevent breaking kernel aware debuggers. */ -//typedef struct tmrTimerControl * TimerHandle_t; +#ifdef ESP_PLATFORM // IDF-3768 typedef void* TimerHandle_t; +#else +typedef struct tmrTimerControl * TimerHandle_t; +#endif // ESP_PLATFORM /* * Defines the prototype to which timer callback functions must conform. */ -typedef void (*TimerCallbackFunction_t)( TimerHandle_t xTimer ); +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 ); +typedef void (* PendedFunction_t)( void *, + uint32_t ); /** + * TimerHandle_t xTimerCreate( const char * const pcTimerName, + * TickType_t xTimerPeriodInTicks, + * UBaseType_t uxAutoReload, + * void * pvTimerID, + * TimerCallbackFunction_t pxCallbackFunction ); + * * Creates a new software timer instance, and returns a handle by which the * created software timer can be referenced. * @@ -95,7 +106,7 @@ typedef void (*PendedFunction_t)( void *, uint32_t ); * 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 + * https://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. @@ -115,7 +126,7 @@ typedef void (*PendedFunction_t)( void *, uint32_t ); * 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. + * equal to 1000. Time timer period must be greater than 0. * * @param uxAutoReload If uxAutoReload is set to pdTRUE then the timer will * expire repeatedly with a frequency set by the xTimerPeriodInTicks parameter. @@ -129,7 +140,7 @@ typedef void (*PendedFunction_t)( void *, uint32_t ); * * @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 );". + * which is "void vCallbackFunction( TimerHandle_t xTimer );". * * @return If the timer is successfully created then a handle to the newly * created timer is returned. If the timer cannot be created (because either @@ -137,7 +148,7 @@ typedef void (*PendedFunction_t)( void *, uint32_t ); * structures, or the timer period was set to 0) then NULL is returned. * * Example usage: - * @code{c} + * @verbatim * #define NUM_TIMERS 5 * * // An array to hold handles to the created timers. @@ -155,8 +166,8 @@ typedef void (*PendedFunction_t)( void *, uint32_t ); * int32_t lArrayIndex; * const int32_t xMaxExpiryCountBeforeStopping = 10; * - * // Optionally do something if the pxTimer parameter is NULL. - * configASSERT( pxTimer ); + * // Optionally do something if the pxTimer parameter is NULL. + * configASSERT( pxTimer ); * * // Which timer expired? * lArrayIndex = ( int32_t ) pvTimerGetTimerID( pxTimer ); @@ -216,138 +227,145 @@ typedef void (*PendedFunction_t)( void *, uint32_t ); * // Should not reach here. * for( ;; ); * } - * @endcode + * @endverbatim */ -#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - TimerHandle_t xTimerCreate( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ - const TickType_t xTimerPeriodInTicks, - const UBaseType_t uxAutoReload, - void * const pvTimerID, - TimerCallbackFunction_t pxCallbackFunction ) PRIVILEGED_FUNCTION; +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + TimerHandle_t xTimerCreate( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + const TickType_t xTimerPeriodInTicks, + const UBaseType_t uxAutoReload, + void * const pvTimerID, + TimerCallbackFunction_t pxCallbackFunction ) PRIVILEGED_FUNCTION; #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; +/** + * TimerHandle_t xTimerCreateStatic(const char * const pcTimerName, + * TickType_t xTimerPeriodInTicks, + * UBaseType_t uxAutoReload, + * void * pvTimerID, + * TimerCallbackFunction_t pxCallbackFunction, + * StaticTimer_t *pxTimerBuffer ); + * + * 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 + * https://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. The timer period must be greater than 0. + * + * @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: + * @verbatim + * + * // 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( ;; ); + * } + * @endverbatim + */ +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + TimerHandle_t xTimerCreateStatic( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + const TickType_t xTimerPeriodInTicks, + const UBaseType_t uxAutoReload, + void * const pvTimerID, + TimerCallbackFunction_t pxCallbackFunction, + StaticTimer_t * pxTimerBuffer ) PRIVILEGED_FUNCTION; #endif /* configSUPPORT_STATIC_ALLOCATION */ /** @@ -370,7 +388,7 @@ typedef void (*PendedFunction_t)( void *, uint32_t ); * * See the xTimerCreate() API function example usage scenario. */ -void *pvTimerGetTimerID( const TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; +void * pvTimerGetTimerID( const TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /** * void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ); @@ -391,7 +409,8 @@ void *pvTimerGetTimerID( const TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; * * See the xTimerCreate() API function example usage scenario. */ -void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ) PRIVILEGED_FUNCTION; +void vTimerSetTimerID( TimerHandle_t xTimer, + void * pvNewID ) PRIVILEGED_FUNCTION; /** * BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer ); @@ -413,7 +432,7 @@ void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ) PRIVILEGED_FUNCTION * pdFALSE will be returned if the timer is active. * * Example usage: - * @code{c} + * @verbatim * // This function assumes xTimer has already been created. * void vAFunction( TimerHandle_t xTimer ) * { @@ -426,11 +445,15 @@ void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ) PRIVILEGED_FUNCTION * // xTimer is not active, do something else. * } * } - * @endcode + * @endverbatim */ BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /** + * @cond + * TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ); + * @endcond + * * xTimerGetTimerDaemonTaskHandle() is only available if * INCLUDE_xTimerGetTimerDaemonTaskHandle is set to 1 in FreeRTOSConfig.h. * @@ -489,9 +512,12 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * See the xTimerCreate() API function example usage scenario. * */ -#define xTimerStart( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START, ( xTaskGetTickCount() ), NULL, ( xTicksToWait ) ) +#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 @@ -529,9 +555,14 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * See the xTimerCreate() API function example usage scenario. * */ -#define xTimerStop( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP, 0U, NULL, ( xTicksToWait ) ) +#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 @@ -573,7 +604,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * configTIMER_TASK_PRIORITY configuration constant. * * Example usage: - * @code{c} + * @verbatim * // 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 @@ -603,11 +634,14 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * } * } * } - * @endcode + * @endverbatim */ - #define xTimerChangePeriod( xTimer, xNewPeriod, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD, ( xNewPeriod ), NULL, ( xTicksToWait ) ) +#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 @@ -641,9 +675,12 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * * See the xTimerChangePeriod() API function example usage scenario. */ -#define xTimerDelete( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_DELETE, 0U, NULL, ( xTicksToWait ) ) +#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 @@ -689,7 +726,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * configuration constant. * * Example usage: - * @code{c} + * @verbatim * // 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. @@ -761,11 +798,15 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * // Should not reach here. * for( ;; ); * } - * @endcode + * @endverbatim */ -#define xTimerReset( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_RESET, ( xTaskGetTickCount() ), NULL, ( xTicksToWait ) ) +#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. * @@ -793,7 +834,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * configuration constant. * * Example usage: - * @code{c} + * @verbatim * // 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 @@ -844,11 +885,15 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * // depends on the FreeRTOS port being used). * } * } - * @endcode + * @endverbatim */ -#define xTimerStartFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START_FROM_ISR, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U ) +#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. * @@ -874,7 +919,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * priority is set by the configTIMER_TASK_PRIORITY configuration constant. * * Example usage: - * @code{c} + * @verbatim * // This scenario assumes xTimer has already been created and started. When * // an interrupt occurs, the timer should be simply stopped. * @@ -904,11 +949,16 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * // depends on the FreeRTOS port being used). * } * } - * @endcode + * @endverbatim */ -#define xTimerStopFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP_FROM_ISR, 0, ( pxHigherPriorityTaskWoken ), 0U ) +#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. * @@ -943,7 +993,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * priority is set by the configTIMER_TASK_PRIORITY configuration constant. * * Example usage: - * @code{c} + * @verbatim * // This scenario assumes xTimer has already been created and started. When * // an interrupt occurs, the period of xTimer should be changed to 500ms. * @@ -973,11 +1023,15 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * // depends on the FreeRTOS port being used). * } * } - * @endcode + * @endverbatim */ -#define xTimerChangePeriodFromISR( xTimer, xNewPeriod, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD_FROM_ISR, ( xNewPeriod ), ( pxHigherPriorityTaskWoken ), 0U ) +#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. * @@ -1005,7 +1059,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * task priority is set by the configTIMER_TASK_PRIORITY configuration constant. * * Example usage: - * @code{c} + * @verbatim * // 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 @@ -1056,12 +1110,19 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * // depends on the FreeRTOS port being used). * } * } - * @endcode + * @endverbatim */ -#define xTimerResetFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_RESET_FROM_ISR, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U ) +#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'). @@ -1103,75 +1164,87 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * timer daemon task, otherwise pdFALSE is returned. * * Example usage: - * @code{c} + * @verbatim * - * // The callback function that will execute in the context of the daemon task. + * // The callback function that will execute in the context of the daemon task. * // Note callback functions must all use this same prototype. * void vProcessInterface( void *pvParameter1, uint32_t ulParameter2 ) - * { - * BaseType_t xInterfaceToService; + * { + * BaseType_t xInterfaceToService; * - * // The interface that requires servicing is passed in the second + * // The interface that requires servicing is passed in the second * // parameter. The first parameter is not used in this case. - * xInterfaceToService = ( BaseType_t ) ulParameter2; + * xInterfaceToService = ( BaseType_t ) ulParameter2; * - * // ...Perform the processing here... - * } + * // ...Perform the processing here... + * } * - * // An ISR that receives data packets from multiple interfaces + * // An ISR that receives data packets from multiple interfaces * void vAnISR( void ) - * { - * BaseType_t xInterfaceToService, xHigherPriorityTaskWoken; + * { + * BaseType_t xInterfaceToService, xHigherPriorityTaskWoken; * - * // Query the hardware to determine which interface needs processing. - * xInterfaceToService = prvCheckInterfaces(); + * // Query the hardware to determine which interface needs processing. + * xInterfaceToService = prvCheckInterfaces(); * * // The actual processing is to be deferred to a task. Request the * // vProcessInterface() callback function is executed, passing in the - * // number of the interface that needs processing. The interface to - * // service is passed in the second parameter. The first parameter is - * // not used in this case. - * xHigherPriorityTaskWoken = pdFALSE; - * xTimerPendFunctionCallFromISR( vProcessInterface, NULL, ( uint32_t ) xInterfaceToService, &xHigherPriorityTaskWoken ); - * - * // 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 + * // number of the interface that needs processing. The interface to + * // service is passed in the second parameter. The first parameter is + * // not used in this case. + * xHigherPriorityTaskWoken = pdFALSE; + * xTimerPendFunctionCallFromISR( vProcessInterface, NULL, ( uint32_t ) xInterfaceToService, &xHigherPriorityTaskWoken ); + * + * // 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 ); + * + * } + * @endverbatim */ -BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; +BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend, + void * pvParameter1, + uint32_t ulParameter2, + BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; - /** - * 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'). - * - * @param xFunctionToPend The function to execute from the timer service/ - * daemon task. The function must conform to the PendedFunction_t - * prototype. - * - * @param pvParameter1 The value of the callback function's first parameter. - * The parameter has a void * type to allow it to be used to pass any type. - * For example, unsigned longs can be cast to a void *, or the void * can be - * used to point to a structure. - * - * @param ulParameter2 The value of the callback function's second parameter. - * - * @param xTicksToWait Calling this function will result in a message being - * sent to the timer daemon task on a queue. xTicksToWait is the amount of - * time the calling task should remain in the Blocked state (so not using any - * processing time) for space to become available on the timer queue if the - * queue is found to be full. - * - * @return pdPASS is returned if the message was successfully sent to the - * timer daemon task, otherwise pdFALSE is returned. - * - */ -BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +/** + * 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'). + * + * @param xFunctionToPend The function to execute from the timer service/ + * daemon task. The function must conform to the PendedFunction_t + * prototype. + * + * @param pvParameter1 The value of the callback function's first parameter. + * The parameter has a void * type to allow it to be used to pass any type. + * For example, unsigned longs can be cast to a void *, or the void * can be + * used to point to a structure. + * + * @param ulParameter2 The value of the callback function's second parameter. + * + * @param xTicksToWait Calling this function will result in a message being + * sent to the timer daemon task on a queue. xTicksToWait is the amount of + * time the calling task should remain in the Blocked state (so not using any + * processing time) for space to become available on the timer queue if the + * queue is found to be full. + * + * @return pdPASS is returned if the message was successfully sent to the + * timer daemon task, otherwise pdFALSE is returned. + * + */ +BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, + void * pvParameter1, + uint32_t ulParameter2, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; /** * const char * const pcTimerGetName( TimerHandle_t xTimer ); @@ -1187,8 +1260,8 @@ const char * pcTimerGetName( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /*lint /** * void vTimerSetReloadMode( TimerHandle_t xTimer, const UBaseType_t uxAutoReload ); * - * Updates a timer to be either an autoreload timer, in which case the timer - * automatically resets itself each time it expires, or a one shot timer, in + * Updates a timer to be either an auto-reload timer, in which case the timer + * automatically resets itself each time it expires, or a one-shot timer, in * which case the timer will only expire once unless it is manually restarted. * * @param xTimer The handle of the timer being updated. @@ -1199,7 +1272,22 @@ const char * pcTimerGetName( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /*lint * uxAutoReload is set to pdFALSE then the timer will be a one-shot timer and * enter the dormant state after it expires. */ -void vTimerSetReloadMode( TimerHandle_t xTimer, const UBaseType_t uxAutoReload ) PRIVILEGED_FUNCTION; +void vTimerSetReloadMode( TimerHandle_t xTimer, + const UBaseType_t uxAutoReload ) PRIVILEGED_FUNCTION; + +/** + * UBaseType_t uxTimerGetReloadMode( TimerHandle_t xTimer ); + * + * Queries a timer to determine if it is an auto-reload timer, in which case the timer + * automatically resets itself each time it expires, or a one-shot timer, in + * which case the timer will only expire once unless it is manually restarted. + * + * @param xTimer The handle of the timer being queried. + * + * @return If the timer is an auto-reload timer then pdTRUE is returned, otherwise + * pdFALSE is returned. + */ +UBaseType_t uxTimerGetReloadMode( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /** * TickType_t xTimerGetPeriod( TimerHandle_t xTimer ); @@ -1213,18 +1301,18 @@ void vTimerSetReloadMode( TimerHandle_t xTimer, const UBaseType_t uxAutoReload ) TickType_t xTimerGetPeriod( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /** -* TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer ); -* -* 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 ); + * + * 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; /** @cond */ @@ -1234,16 +1322,46 @@ TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; * for use by the kernel only. */ 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; +BaseType_t xTimerGenericCommand( TimerHandle_t xTimer, + const BaseType_t xCommandID, + const TickType_t xOptionalValue, + BaseType_t * const pxHigherPriorityTaskWoken, + const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; -#if( configUSE_TRACE_FACILITY == 1 ) - void vTimerSetTimerNumber( TimerHandle_t xTimer, UBaseType_t uxTimerNumber ) PRIVILEGED_FUNCTION; - UBaseType_t uxTimerGetTimerNumber( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; +#if ( configUSE_TRACE_FACILITY == 1 ) + void vTimerSetTimerNumber( TimerHandle_t xTimer, + UBaseType_t uxTimerNumber ) PRIVILEGED_FUNCTION; + UBaseType_t uxTimerGetTimerNumber( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; #endif /** @endcond */ +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + + /** + * @cond + * task.h + * @code{c} + * void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, StackType_t ** ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize ) + * @endcode + * @endcond + * + * This function is used to provide a statically allocated block of memory to FreeRTOS to hold the Timer Task TCB. This function is required when + * configSUPPORT_STATIC_ALLOCATION is set. For more information see this URI: https://www.FreeRTOS.org/a00110.html#configSUPPORT_STATIC_ALLOCATION + * + * @param ppxTimerTaskTCBBuffer A handle to a statically allocated TCB buffer + * @param ppxTimerTaskStackBuffer A handle to a statically allocated Stack buffer for thie idle task + * @param pulTimerTaskStackSize A pointer to the number of elements that will fit in the allocated stack buffer + */ + void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, + StackType_t ** ppxTimerTaskStackBuffer, + uint32_t * pulTimerTaskStackSize ); + +#endif + +/* *INDENT-OFF* */ #ifdef __cplusplus -} + } #endif +/* *INDENT-ON* */ #endif /* TIMERS_H */ diff --git a/tools/sdk/esp32c3/include/freertos/port/riscv/include/freertos/FreeRTOSConfig.h b/tools/sdk/esp32c3/include/freertos/port/riscv/include/freertos/FreeRTOSConfig_arch.h similarity index 100% rename from tools/sdk/esp32c3/include/freertos/port/riscv/include/freertos/FreeRTOSConfig.h rename to tools/sdk/esp32c3/include/freertos/port/riscv/include/freertos/FreeRTOSConfig_arch.h diff --git a/tools/sdk/esp32c3/include/freertos/port/riscv/include/freertos/portmacro.h b/tools/sdk/esp32c3/include/freertos/port/riscv/include/freertos/portmacro.h index 9ead3fea267..cb58b422658 100644 --- a/tools/sdk/esp32c3/include/freertos/port/riscv/include/freertos/portmacro.h +++ b/tools/sdk/esp32c3/include/freertos/port/riscv/include/freertos/portmacro.h @@ -1,5 +1,5 @@ /* - * FreeRTOS Kernel V10.2.1 + * FreeRTOS Kernel V10.4.3 * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of diff --git a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/adc_hal.h b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/adc_hal.h index 9993f9e8d91..1425acf0e17 100644 --- a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/adc_hal.h +++ b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/adc_hal.h @@ -97,23 +97,6 @@ void adc_hal_digi_monitor_config(adc_digi_monitor_idx_t mon_idx, adc_digi_monito */ void adc_hal_digi_monitor_enable(adc_digi_monitor_idx_t mon_idx, bool enable); -/*--------------------------------------------------------------- - Common setting ----------------------------------------------------------------*/ - -/** - * Config ADC2 module arbiter. - * The arbiter is to improve the use efficiency of ADC2. After the control right is robbed by the high priority, - * the low priority controller will read the invalid ADC2 data, and the validity of the data can be judged by the flag bit in the data. - * - * @note Only ADC2 support arbiter. - * @note The arbiter's working clock is APB_CLK. When the APB_CLK clock drops below 8 MHz, the arbiter must be in shield mode. - * @note Default priority: Wi-Fi > RTC > Digital; - * - * @param config Refer to `adc_arbiter_t`. - */ -void adc_hal_arbiter_config(adc_arbiter_t *config); - #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/adc_ll.h b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/adc_ll.h index a2fd21f2b51..49ff4a23f43 100644 --- a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/adc_ll.h +++ b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/adc_ll.h @@ -15,6 +15,7 @@ #include #include +#include "hal/misc.h" #include "regi2c_ctrl.h" #include "esp_attr.h" @@ -94,11 +95,11 @@ typedef enum { static inline void adc_ll_digi_set_fsm_time(uint32_t rst_wait, uint32_t start_wait, uint32_t standby_wait) { // Internal FSM reset wait time - APB_SARADC.fsm_wait.rstb_wait = rst_wait; + HAL_FORCE_MODIFY_U32_REG_FIELD(APB_SARADC.fsm_wait, rstb_wait, rst_wait); // Internal FSM start wait time - APB_SARADC.fsm_wait.xpd_wait = start_wait; + HAL_FORCE_MODIFY_U32_REG_FIELD(APB_SARADC.fsm_wait, xpd_wait, start_wait); // Internal FSM standby wait time - APB_SARADC.fsm_wait.standby_wait = standby_wait; + HAL_FORCE_MODIFY_U32_REG_FIELD(APB_SARADC.fsm_wait, standby_wait, standby_wait); } /** @@ -124,7 +125,7 @@ static inline void adc_ll_set_sample_cycle(uint32_t sample_cycle) static inline void adc_ll_digi_set_clk_div(uint32_t div) { /* ADC clock devided from digital controller clock clk */ - APB_SARADC.ctrl.sar_clk_div = div; + HAL_FORCE_MODIFY_U32_REG_FIELD(APB_SARADC.ctrl, sar_clk_div, div); } /** @@ -135,7 +136,7 @@ static inline void adc_ll_digi_set_clk_div(uint32_t div) */ static inline void adc_ll_digi_set_convert_limit_num(uint32_t meas_num) { - APB_SARADC.ctrl2.max_meas_num = meas_num; + HAL_FORCE_MODIFY_U32_REG_FIELD(APB_SARADC.ctrl2, max_meas_num, meas_num); } /** @@ -267,7 +268,7 @@ static inline void adc_ll_digi_trigger_disable(void) */ static inline void adc_ll_digi_controller_clk_div(uint32_t div_num, uint32_t div_b, uint32_t div_a) { - APB_SARADC.apb_adc_clkm_conf.clkm_div_num = div_num; + HAL_FORCE_MODIFY_U32_REG_FIELD(APB_SARADC.apb_adc_clkm_conf, clkm_div_num, div_num); APB_SARADC.apb_adc_clkm_conf.clkm_div_b = div_b; APB_SARADC.apb_adc_clkm_conf.clkm_div_a = div_a; } @@ -404,7 +405,7 @@ static inline void adc_ll_digi_monitor_disable(adc_digi_monitor_idx_t idx) */ static inline void adc_ll_digi_dma_set_eof_num(uint32_t num) { - APB_SARADC.dma_conf.apb_adc_eof_num = num; + HAL_FORCE_MODIFY_U32_REG_FIELD(APB_SARADC.dma_conf, apb_adc_eof_num, num); } /** diff --git a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/aes_ll.h b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/aes_ll.h index 0eb7fabc64a..e18c44e58ef 100644 --- a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/aes_ll.h +++ b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/aes_ll.h @@ -1,4 +1,4 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD +// Copyright 2020-2021 Espressif Systems (Shanghai) CO LTD // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ #pragma once #include +#include #include "soc/hwcrypto_reg.h" #include "hal/aes_types.h" @@ -39,16 +40,17 @@ typedef enum { * @param key Key to be written to the AES hardware * @param key_word_len Number of words in the key * - * @return volatile number of bytes written to hardware, used for fault injection check + * @return Number of bytes written to hardware, used for fault injection check */ static inline uint8_t aes_ll_write_key(const uint8_t *key, size_t key_word_len) { /* This variable is used for fault injection checks, so marked volatile to avoid optimisation */ volatile uint8_t key_in_hardware = 0; - uint32_t *key_words = (uint32_t *)key; - + /* Memcpy to avoid potential unaligned access */ + uint32_t key_word; for (int i = 0; i < key_word_len; i++) { - REG_WRITE(AES_KEY_BASE + i * 4, *(key_words + i)); + memcpy(&key_word, key + 4 * i, 4); + REG_WRITE(AES_KEY_BASE + i * 4, key_word); key_in_hardware += 4; } return key_in_hardware; @@ -76,22 +78,12 @@ static inline void aes_ll_set_mode(int mode, uint8_t key_bytes) */ static inline void aes_ll_write_block(const void *input) { - const uint32_t *input_words = (const uint32_t *)input; - uint32_t i0, i1, i2, i3; - - /* Storing i0,i1,i2,i3 in registers, not in an array - helps a lot with optimisations at -Os level */ - i0 = input_words[0]; - REG_WRITE(AES_TEXT_IN_BASE, i0); - - i1 = input_words[1]; - REG_WRITE(AES_TEXT_IN_BASE + 4, i1); + uint32_t input_word; - i2 = input_words[2]; - REG_WRITE(AES_TEXT_IN_BASE + 8, i2); - - i3 = input_words[3]; - REG_WRITE(AES_TEXT_IN_BASE + 12, i3); + for (int i = 0; i < AES_BLOCK_WORDS; i++) { + memcpy(&input_word, (uint8_t*)input + 4 * i, 4); + REG_WRITE(AES_TEXT_IN_BASE + i * 4, input_word); + } } /** @@ -101,11 +93,13 @@ static inline void aes_ll_write_block(const void *input) */ static inline void aes_ll_read_block(void *output) { - uint32_t *output_words = (uint32_t *)output; + uint32_t output_word; const size_t REG_WIDTH = sizeof(uint32_t); for (size_t i = 0; i < AES_BLOCK_WORDS; i++) { - output_words[i] = REG_READ(AES_TEXT_OUT_BASE + (i * REG_WIDTH)); + output_word = REG_READ(AES_TEXT_OUT_BASE + (i * REG_WIDTH)); + /* Memcpy to avoid potential unaligned access */ + memcpy( (uint8_t*)output + i * 4, &output_word, sizeof(output_word)); } } @@ -179,11 +173,13 @@ static inline void aes_ll_set_num_blocks(size_t num_blocks) */ static inline void aes_ll_set_iv(const uint8_t *iv) { - uint32_t *iv_words = (uint32_t *)iv; uint32_t *reg_addr_buf = (uint32_t *)(AES_IV_BASE); + uint32_t iv_word; for (int i = 0; i < IV_WORDS; i++ ) { - REG_WRITE(®_addr_buf[i], iv_words[i]); + /* Memcpy to avoid potential unaligned access */ + memcpy(&iv_word, iv + 4 * i, sizeof(iv_word)); + REG_WRITE(®_addr_buf[i], iv_word); } } @@ -192,11 +188,13 @@ static inline void aes_ll_set_iv(const uint8_t *iv) */ static inline void aes_ll_read_iv(uint8_t *iv) { - uint32_t *iv_words = (uint32_t *)iv; + uint32_t iv_word; const size_t REG_WIDTH = sizeof(uint32_t); for (size_t i = 0; i < IV_WORDS; i++) { - iv_words[i] = REG_READ(AES_IV_BASE + (i * REG_WIDTH)); + iv_word = REG_READ(AES_IV_BASE + (i * REG_WIDTH)); + /* Memcpy to avoid potential unaligned access */ + memcpy(iv + i * 4, &iv_word, sizeof(iv_word)); } } diff --git a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/cpu_ll.h b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/cpu_ll.h index 5c9e56dfc92..fe0f11d4346 100644 --- a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/cpu_ll.h +++ b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/cpu_ll.h @@ -28,6 +28,11 @@ #define CSR_PCMR_MACHINE 0x7e1 #define CSR_PCCR_MACHINE 0x7e2 +/*fast gpio*/ +#define CSR_GPIO_OEN_USER 0x803 +#define CSR_GPIO_IN_USER 0x804 +#define CSR_GPIO_OUT_USER 0x805 + #ifdef __cplusplus extern "C" { #endif @@ -137,7 +142,7 @@ static inline void cpu_ll_clear_watchpoint(int id) FORCE_INLINE_ATTR bool cpu_ll_is_debugger_attached(void) { - return REG_GET_BIT(ASSIST_DEBUG_C0RE_0_DEBUG_MODE_REG, ASSIST_DEBUG_CORE_0_DEBUG_MODULE_ACTIVE); + return REG_GET_BIT(ASSIST_DEBUG_CORE_0_DEBUG_MODE_REG, ASSIST_DEBUG_CORE_0_DEBUG_MODULE_ACTIVE); } static inline void cpu_ll_break(void) @@ -163,6 +168,34 @@ static inline void cpu_ll_waiti(void) asm volatile ("wfi\n"); } +static inline void cpu_ll_enable_dedic_gpio_output(uint32_t mask) +{ + RV_WRITE_CSR(CSR_GPIO_OEN_USER, mask); +} + +static inline void cpu_ll_write_dedic_gpio_all(uint32_t value) +{ + RV_WRITE_CSR(CSR_GPIO_OUT_USER, value); +} + +static inline uint32_t cpu_ll_read_dedic_gpio_in(void) +{ + uint32_t value = RV_READ_CSR(CSR_GPIO_IN_USER); + return value; +} + +static inline uint32_t cpu_ll_read_dedic_gpio_out(void) +{ + uint32_t value = RV_READ_CSR(CSR_GPIO_OUT_USER); + return value; +} + +static inline void cpu_ll_write_dedic_gpio_mask(uint32_t mask, uint32_t value) +{ + RV_SET_CSR(CSR_GPIO_OUT_USER, mask & value); + RV_CLEAR_CSR(CSR_GPIO_OUT_USER, mask & ~(value)); +} + #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/gpio_ll.h b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/gpio_ll.h index 6ba4d601b9f..6214bc06e32 100644 --- a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/gpio_ll.h +++ b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/gpio_ll.h @@ -24,6 +24,7 @@ #include "soc/soc.h" #include "soc/gpio_periph.h" +#include "soc/gpio_struct.h" #include "soc/rtc_cntl_reg.h" #include "hal/gpio_types.h" #include "stdlib.h" @@ -334,6 +335,7 @@ static inline void gpio_ll_get_drive_capability(gpio_dev_t *hw, gpio_num_t gpio_ */ static inline void gpio_ll_deep_sleep_hold_en(gpio_dev_t *hw) { + CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_UNHOLD); SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_AUTOHOLD_EN_M); } diff --git a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/gpspi_flash_ll.h b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/gpspi_flash_ll.h index f80fc83b260..212e03a06d0 100644 --- a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/gpspi_flash_ll.h +++ b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/gpspi_flash_ll.h @@ -24,11 +24,13 @@ #include #include "soc/spi_periph.h" +#include "soc/spi_struct.h" #include "hal/spi_types.h" #include "hal/spi_flash_types.h" #include // For MIN/MAX #include #include +#include "hal/misc.h" #ifdef __cplusplus extern "C" { @@ -148,12 +150,21 @@ static inline void gpspi_flash_ll_set_buffer_data(spi_dev_t *dev, const void *bu */ static inline void gpspi_flash_ll_user_start(spi_dev_t *dev) { - dev->ctrl.hold_pol = 1; dev->cmd.update = 1; while (dev->cmd.update); dev->cmd.usr = 1; } +/** + * Set HD pin high when flash work at spi mode. + * + * @param dev Beginning address of the peripheral registers. + */ +static inline void gpspi_flash_ll_set_hold_pol(spi_dev_t *dev, uint32_t pol_val) +{ + dev->ctrl.hold_pol = pol_val; +} + /** * Check whether the host is idle to perform new commands. * @@ -354,7 +365,7 @@ static inline void gpspi_flash_ll_set_address(spi_dev_t *dev, uint32_t addr) static inline void gpspi_flash_ll_set_dummy(spi_dev_t *dev, uint32_t dummy_n) { dev->user.usr_dummy = dummy_n ? 1 : 0; - dev->user1.usr_dummy_cyclelen = dummy_n - 1; + HAL_FORCE_MODIFY_U32_REG_FIELD(dev->user1, usr_dummy_cyclelen, dummy_n - 1); } /** diff --git a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/i2c_ll.h b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/i2c_ll.h index 85c946c23bb..31743005b6e 100644 --- a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/i2c_ll.h +++ b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/i2c_ll.h @@ -15,8 +15,11 @@ // The LL layer for I2C register operations #pragma once + +#include "hal/misc.h" #include "soc/i2c_periph.h" #include "soc/soc_caps.h" +#include "soc/i2c_struct.h" #include "hal/i2c_types.h" #include "soc/rtc_cntl_reg.h" #include "esp_rom_sys.h" @@ -154,7 +157,7 @@ static inline void i2c_ll_update(i2c_dev_t *hw) */ static inline void i2c_ll_set_bus_timing(i2c_dev_t *hw, i2c_clk_cal_t *bus_cfg) { - hw->clk_conf.sclk_div_num = bus_cfg->clkm_div - 1; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->clk_conf, sclk_div_num, bus_cfg->clkm_div - 1); //scl period hw->scl_low_period.period = bus_cfg->scl_low - 1; hw->scl_high_period.period = bus_cfg->scl_high; @@ -576,7 +579,7 @@ static inline void i2c_ll_get_scl_timing(i2c_dev_t *hw, int *high_period, int *l static inline void i2c_ll_write_txfifo(i2c_dev_t *hw, uint8_t *ptr, uint8_t len) { for (int i = 0; i< len; i++) { - hw->fifo_data.data = ptr[i]; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->fifo_data, data, ptr[i]); } } @@ -592,7 +595,7 @@ static inline void i2c_ll_write_txfifo(i2c_dev_t *hw, uint8_t *ptr, uint8_t len) static inline void i2c_ll_read_rxfifo(i2c_dev_t *hw, uint8_t *ptr, uint8_t len) { for(int i = 0; i < len; i++) { - ptr[i] = hw->fifo_data.data; + ptr[i] = HAL_FORCE_READ_U32_REG_FIELD(hw->fifo_data, data); } } @@ -801,9 +804,12 @@ static inline void i2c_ll_master_fsm_rst(i2c_dev_t *hw) static inline void i2c_ll_master_clr_bus(i2c_dev_t *hw) { hw->scl_sp_conf.scl_rst_slv_num = 9; - hw->scl_sp_conf.scl_rst_slv_en = 0; - hw->ctr.conf_upgate = 1; hw->scl_sp_conf.scl_rst_slv_en = 1; + hw->ctr.conf_upgate = 1; + // hardward will clear scl_rst_slv_en after sending SCL pulses, + // and we should set conf_upgate bit to synchronize register value. + while (hw->scl_sp_conf.scl_rst_slv_en); + hw->ctr.conf_upgate = 1; } /** diff --git a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/i2s_ll.h b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/i2s_ll.h index 4a6042cf127..670db91616b 100644 --- a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/i2s_ll.h +++ b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/i2s_ll.h @@ -1,4 +1,4 @@ -// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD +// Copyright 2021 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. @@ -12,899 +12,822 @@ // See the License for the specific language governing permissions and // limitations under the License. +// The LL layer for I2S register operations /******************************************************************************* * NOTICE * The hal is not public api, don't use in application code. - * See readme.md in soc/include/hal/readme.md + * See readme.md in hal/include/hal/readme.md ******************************************************************************/ -// The LL layer for ESP32-S3 I2S register operations - #pragma once - #include -#include +#include "hal/misc.h" #include "soc/i2s_periph.h" +#include "soc/i2s_struct.h" #include "hal/i2s_types.h" #ifdef __cplusplus extern "C" { #endif -// Get I2S hardware instance with giving i2s num -#define I2S_LL_GET_HW(num) (((num) == 0) ? (&I2S0) : NULL) - -#define I2S_INTR_IN_SUC_EOF BIT(9) -#define I2S_INTR_OUT_EOF BIT(12) -#define I2S_INTR_IN_DSCR_ERR BIT(13) -#define I2S_INTR_OUT_DSCR_ERR BIT(14) -#define I2S_INTR_MAX (0xFFFFFFFF) - -/** - * @brief Reset rx fifo - * - * @param hw Peripheral I2S hardware instance address. - */ -static inline void i2s_ll_reset_rx_fifo(i2s_dev_t *hw) -{ - abort(); // TODO ESP32-C3 IDF-2098 - - -} - -/** - * @brief Reset tx fifo - * - * @param hw Peripheral I2S hardware instance address. - */ -static inline void i2s_ll_reset_tx_fifo(i2s_dev_t *hw) -{ - abort(); // TODO ESP32-C3 IDF-2098 - +#define I2S_LL_GET_HW(num) (&I2S0) -} +#define I2S_LL_TDM_CH_MASK (0xffff) +#define I2S_LL_PDM_BCK_FACTOR (64) +#define I2S_LL_BASE_CLK (2*APB_CLK_FREQ) -/** - * @brief Enable rx interrupt - * - * @param hw Peripheral I2S hardware instance address. - */ -static inline void i2s_ll_enable_rx_intr(i2s_dev_t *hw) -{ - abort(); // TODO ESP32-C3 IDF-2098 +#define I2S_LL_MCLK_DIVIDER_BIT_WIDTH (9) +#define I2S_LL_MCLK_DIVIDER_MAX ((1 << I2S_LL_MCLK_DIVIDER_BIT_WIDTH) - 1) - -} +/* I2S clock configuration structure */ +typedef struct { + uint16_t mclk_div; // I2S module clock devider, Fmclk = Fsclk /(mclk_div+b/a) + uint16_t a; + uint16_t b; // The decimal part of module clock devider, the decimal is: b/a +} i2s_ll_mclk_div_t; /** - * @brief Disable rx interrupt + * @brief I2S module general init, enable I2S clock. * * @param hw Peripheral I2S hardware instance address. */ -static inline void i2s_ll_disable_rx_intr(i2s_dev_t *hw) +static inline void i2s_ll_enable_clock(i2s_dev_t *hw) { - abort(); // TODO ESP32-C3 IDF-2098 - - + hw->tx_clkm_conf.clk_en = 1; } /** - * @brief Disable tx interrupt + * @brief I2S module disable I2S clock. * * @param hw Peripheral I2S hardware instance address. */ -static inline void i2s_ll_disable_tx_intr(i2s_dev_t *hw) +static inline void i2s_ll_disable_clock(i2s_dev_t *hw) { - abort(); // TODO ESP32-C3 IDF-2098 - - -} - -/** - * @brief Enable tx interrupt - * - * @param hw Peripheral I2S hardware instance address. - */ -static inline void i2s_ll_enable_tx_intr(i2s_dev_t *hw) -{ - abort(); // TODO ESP32-C3 IDF-2098 - - -} - -/** - * @brief Reset dma in - * - * @param hw Peripheral I2S hardware instance address. - */ -static inline void i2s_ll_reset_dma_in(i2s_dev_t *hw) -{ - abort(); // TODO ESP32-C3 IDF-2098 - - -} - -/** - * @brief Reset dma out - * - * @param hw Peripheral I2S hardware instance address. - */ -static inline void i2s_ll_reset_dma_out(i2s_dev_t *hw) -{ - abort(); // TODO ESP32-C3 IDF-2098 - - -} - -/** - * @brief Reset tx - * - * @param hw Peripheral I2S hardware instance address. - */ -static inline void i2s_ll_reset_tx(i2s_dev_t *hw) -{ - abort(); // TODO ESP32-C3 IDF-2098 - - + hw->tx_clkm_conf.clk_en = 0; } /** - * @brief Reset rx + * @brief Enable I2S tx module clock * * @param hw Peripheral I2S hardware instance address. */ -static inline void i2s_ll_reset_rx(i2s_dev_t *hw) +static inline void i2s_ll_tx_enable_clock(i2s_dev_t *hw) { - abort(); // TODO ESP32-C3 IDF-2098 - - + hw->tx_clkm_conf.tx_clk_active = 1; } /** - * @brief Start out link + * @brief Enable I2S rx module clock * * @param hw Peripheral I2S hardware instance address. */ -static inline void i2s_ll_start_out_link(i2s_dev_t *hw) +static inline void i2s_ll_rx_enable_clock(i2s_dev_t *hw) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->rx_clkm_conf.rx_clk_active = 1; } /** - * @brief Start tx + * @brief I2S mclk use tx module clock * * @param hw Peripheral I2S hardware instance address. */ -static inline void i2s_ll_start_tx(i2s_dev_t *hw) +static inline void i2s_ll_mclk_use_tx_clk(i2s_dev_t *hw) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->rx_clkm_conf.mclk_sel = 0; } /** - * @brief Start in link + * @brief I2S mclk use rx module clock * * @param hw Peripheral I2S hardware instance address. */ -static inline void i2s_ll_start_in_link(i2s_dev_t *hw) +static inline void i2s_ll_mclk_use_rx_clk(i2s_dev_t *hw) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->rx_clkm_conf.mclk_sel = 1; } /** - * @brief Start rx + * @brief Enable I2S TX slave mode * * @param hw Peripheral I2S hardware instance address. + * @param slave_en Set true to enable slave mode */ -static inline void i2s_ll_start_rx(i2s_dev_t *hw) +static inline void i2s_ll_tx_set_slave_mod(i2s_dev_t *hw, bool slave_en) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->tx_conf.tx_slave_mod = slave_en; } /** - * @brief Stop out link + * @brief Enable I2S RX slave mode * * @param hw Peripheral I2S hardware instance address. + * @param slave_en Set true to enable slave mode */ -static inline void i2s_ll_stop_out_link(i2s_dev_t *hw) +static inline void i2s_ll_rx_set_slave_mod(i2s_dev_t *hw, bool slave_en) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->rx_conf.rx_slave_mod = slave_en; } /** - * @brief Stop tx + * @brief Reset I2S TX module * * @param hw Peripheral I2S hardware instance address. */ -static inline void i2s_ll_stop_tx(i2s_dev_t *hw) +static inline void i2s_ll_tx_reset(i2s_dev_t *hw) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->tx_conf.tx_reset = 1; + hw->tx_conf.tx_reset = 0; } /** - * @brief Stop in link + * @brief Reset I2S RX module * * @param hw Peripheral I2S hardware instance address. */ -static inline void i2s_ll_stop_in_link(i2s_dev_t *hw) +static inline void i2s_ll_rx_reset(i2s_dev_t *hw) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->rx_conf.rx_reset = 1; + hw->rx_conf.rx_reset = 0; } /** - * @brief Stop rx + * @brief Reset I2S TX FIFO * * @param hw Peripheral I2S hardware instance address. */ -static inline void i2s_ll_stop_rx(i2s_dev_t *hw) +static inline void i2s_ll_tx_reset_fifo(i2s_dev_t *hw) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->tx_conf.tx_fifo_reset = 1; + hw->tx_conf.tx_fifo_reset = 0; } /** - * @brief Enable dma + * @brief Reset I2S RX FIFO * * @param hw Peripheral I2S hardware instance address. */ -static inline void i2s_ll_enable_dma(i2s_dev_t *hw) +static inline void i2s_ll_rx_reset_fifo(i2s_dev_t *hw) { - abort(); // TODO ESP32-C3 IDF-2098 - // //Enable and configure DMA - // typeof(hw->lc_conf) lc_conf; - // lc_conf.val = 0; - // lc_conf.out_eof_mode = 1; - + hw->rx_conf.rx_fifo_reset = 1; + hw->rx_conf.rx_fifo_reset = 0; } /** - * @brief Get I2S interrupt status + * @brief Set TX source clock * * @param hw Peripheral I2S hardware instance address. - * @param val value to get interrupt status + * @param src I2S source clock. */ -static inline void i2s_ll_get_intr_status(i2s_dev_t *hw, uint32_t *val) +static inline void i2s_ll_tx_clk_set_src(i2s_dev_t *hw, i2s_clock_src_t src) { - abort(); // TODO ESP32-C3 IDF-2098 - // *val = hw->int_st.val; + hw->tx_clkm_conf.tx_clk_sel = 2; } /** - * @brief Clear I2S interrupt status + * @brief Set RX source clock * * @param hw Peripheral I2S hardware instance address. - * @param val value to clear interrupt status + * @param src I2S source clock, ESP32-C3 only support `I2S_CLK_D2CLK` */ -static inline void i2s_ll_clear_intr_status(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_clk_set_src(i2s_dev_t *hw, i2s_clock_src_t src) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->rx_clkm_conf.rx_clk_sel = 2; } /** - * @brief Get I2S out eof des address + * @brief Set I2S tx bck div num * * @param hw Peripheral I2S hardware instance address. - * @param val value to get out eof des address + * @param val value to set tx bck div num */ -static inline void i2s_ll_get_out_eof_des_addr(i2s_dev_t *hw, uint32_t *val) +static inline void i2s_ll_tx_set_bck_div_num(i2s_dev_t *hw, uint32_t val) { - abort(); // TODO ESP32-C3 IDF-2098 - // *val = hw->out_eof_des_addr; + hw->tx_conf1.tx_bck_div_num = val - 1; } /** - * @brief Get I2S in eof des address + * @brief Configure I2S TX clock devider * * @param hw Peripheral I2S hardware instance address. - * @param val value to get in eof des address + * @param set Pointer to I2S clock devider configuration paramater */ -static inline void i2s_ll_get_in_eof_des_addr(i2s_dev_t *hw, uint32_t *val) +static inline void i2s_ll_tx_set_clk(i2s_dev_t *hw, i2s_ll_mclk_div_t *set) { - abort(); // TODO ESP32-C3 IDF-2098 - // *val = hw->in_eof_des_addr; + if (set->a == 0 || set->b == 0) { + hw->tx_clkm_div_conf.tx_clkm_div_x = 0; + hw->tx_clkm_div_conf.tx_clkm_div_y = 0; + hw->tx_clkm_div_conf.tx_clkm_div_z = 0; + } else { + if (set->b > set->a / 2) { + hw->tx_clkm_div_conf.tx_clkm_div_x = set->a / (set->a - set->b) - 1; + hw->tx_clkm_div_conf.tx_clkm_div_y = set->a % (set->a - set->b); + hw->tx_clkm_div_conf.tx_clkm_div_z = set->a - set->b; + hw->tx_clkm_div_conf.tx_clkm_div_yn1 = 1; + } else { + hw->tx_clkm_div_conf.tx_clkm_div_x = set->a / set->b - 1; + hw->tx_clkm_div_conf.tx_clkm_div_y = set->a % set->b + 1; + hw->tx_clkm_div_conf.tx_clkm_div_z = set->b; + hw->tx_clkm_div_conf.tx_clkm_div_yn1 = 0; + } + } + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->tx_clkm_conf, tx_clkm_div_num, set->mclk_div); } /** - * @brief Get I2S tx fifo mode + * @brief Set I2S rx bck div num * * @param hw Peripheral I2S hardware instance address. - * @param val value to get tx fifo mode + * @param val value to set rx bck div num */ -static inline void i2s_ll_get_tx_fifo_mod(i2s_dev_t *hw, uint32_t *val) +static inline void i2s_ll_rx_set_bck_div_num(i2s_dev_t *hw, uint32_t val) { - abort(); // TODO ESP32-C3 IDF-2098 - // *val = hw->fifo_conf.tx_fifo_mod; + hw->rx_conf1.rx_bck_div_num = val - 1; } /** - * @brief Set I2S tx fifo mode + * @brief Configure I2S RX clock devider * * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx fifo mode + * @param set Pointer to I2S clock devider configuration paramater */ -static inline void i2s_ll_set_tx_fifo_mod(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_set_clk(i2s_dev_t *hw, i2s_ll_mclk_div_t *set) { - abort(); // TODO ESP32-C3 IDF-2098 - + if (set->a == 0 || set->b == 0) { + hw->rx_clkm_div_conf.rx_clkm_div_x = 0; + hw->rx_clkm_div_conf.rx_clkm_div_y = 0; + hw->rx_clkm_div_conf.rx_clkm_div_z = 0; + } else { + if (set->b > set->a / 2) { + hw->rx_clkm_div_conf.rx_clkm_div_x = set->a / (set->a - set->b) - 1; + hw->rx_clkm_div_conf.rx_clkm_div_y = set->a % (set->a - set->b); + hw->rx_clkm_div_conf.rx_clkm_div_z = set->a - set->b; + hw->rx_clkm_div_conf.rx_clkm_div_yn1 = 1; + } else { + hw->rx_clkm_div_conf.rx_clkm_div_x = set->a / set->b - 1; + hw->rx_clkm_div_conf.rx_clkm_div_y = set->a % set->b + 1; + hw->rx_clkm_div_conf.rx_clkm_div_z = set->b; + hw->rx_clkm_div_conf.rx_clkm_div_yn1 = 0; + } + } + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->rx_clkm_conf, rx_clkm_div_num, set->mclk_div); } /** - * @brief Get I2S rx fifo mode + * @brief Start I2S TX * * @param hw Peripheral I2S hardware instance address. - * @param val value to get rx fifo mode */ -static inline void i2s_ll_get_rx_fifo_mod(i2s_dev_t *hw, uint32_t *val) +static inline void i2s_ll_tx_start(i2s_dev_t *hw) { - abort(); // TODO ESP32-C3 IDF-2098 - // *val = hw->fifo_conf.rx_fifo_mod; + hw->tx_conf.tx_update = 0; + hw->tx_conf.tx_update = 1; + hw->tx_conf.tx_start = 1; } /** - * @brief Set I2S rx fifo mode + * @brief Start I2S RX * * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx fifo mode */ -static inline void i2s_ll_set_rx_fifo_mod(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_start(i2s_dev_t *hw) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->rx_conf.rx_update = 0; + hw->rx_conf.rx_update = 1; + hw->rx_conf.rx_start = 1; } /** - * @brief Set I2S tx chan mode + * @brief Stop I2S TX * * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx chan mode */ -static inline void i2s_ll_set_tx_chan_mod(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_stop(i2s_dev_t *hw) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->tx_conf.tx_start = 0; } /** - * @brief Set I2S rx chan mode + * @brief Stop I2S RX * * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx chan mode */ -static inline void i2s_ll_set_rx_chan_mod(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_stop(i2s_dev_t *hw) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->rx_conf.rx_start = 0; } /** - * @brief Set I2S out link address + * @brief Configure TX WS signal width * * @param hw Peripheral I2S hardware instance address. - * @param val value to set out link address + * @param width WS width in BCK cycle */ -static inline void i2s_ll_set_out_link_addr(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_set_ws_width(i2s_dev_t *hw, int width) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->tx_conf1.tx_tdm_ws_width = width - 1; } /** - * @brief Set I2S in link address + * @brief Configure RX WS signal width * * @param hw Peripheral I2S hardware instance address. - * @param val value to set in link address + * @param width WS width in BCK cycle */ -static inline void i2s_ll_set_in_link_addr(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_set_ws_width(i2s_dev_t *hw, int width) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->rx_conf1.rx_tdm_ws_width = width - 1; } /** - * @brief Set I2S rx eof num + * @brief Configure the received length to trigger in_suc_eof interrupt * * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx eof num + * @param eof_num the byte length to trigger in_suc_eof interrupt */ -static inline void i2s_ll_set_rx_eof_num(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_set_eof_num(i2s_dev_t *hw, int eof_num) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->rx_eof_num.rx_eof_num = eof_num; } /** - * @brief Get I2S tx pdm fp + * @brief Congfigure TX chan bit and audio data bit * * @param hw Peripheral I2S hardware instance address. - * @param val value to get tx pdm fp + * @param chan_bit The chan bit width + * @param data_bit The audio data bit width */ -static inline void i2s_ll_get_tx_pdm_fp(i2s_dev_t *hw, uint32_t *val) +static inline void i2s_ll_tx_set_sample_bit(i2s_dev_t *hw, uint8_t chan_bit, int data_bit) { - abort(); // TODO ESP32-C3 IDF-2098 - // *val = hw->pdm_freq_conf.tx_pdm_fp; + hw->tx_conf1.tx_bits_mod = data_bit - 1; + hw->tx_conf1.tx_tdm_chan_bits = chan_bit - 1; } /** - * @brief Get I2S tx pdm fs + * @brief Congfigure RX chan bit and audio data bit * * @param hw Peripheral I2S hardware instance address. - * @param val value to get tx pdm fs + * @param chan_bit The chan bit width + * @param data_bit The audio data bit width */ -static inline void i2s_ll_get_tx_pdm_fs(i2s_dev_t *hw, uint32_t *val) +static inline void i2s_ll_rx_set_sample_bit(i2s_dev_t *hw, uint8_t chan_bit, int data_bit) { - abort(); // TODO ESP32-C3 IDF-2098 - // *val = hw->pdm_freq_conf.tx_pdm_fs; + hw->rx_conf1.rx_bits_mod = data_bit - 1; + hw->rx_conf1.rx_tdm_chan_bits = chan_bit - 1; } /** - * @brief Set I2S tx pdm fp + * @brief Configure RX half_sample_bit * * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx pdm fp + * @param half_sample_bits half sample bit width */ -static inline void i2s_ll_set_tx_pdm_fp(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_set_half_sample_bit(i2s_dev_t *hw, int half_sample_bits) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->tx_conf1.tx_half_sample_bits = half_sample_bits - 1; } /** - * @brief Set I2S tx pdm fs + * @brief Configure RX half_sample_bit * * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx pdm fs + * @param half_sample_bits half sample bit width */ -static inline void i2s_ll_set_tx_pdm_fs(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_set_half_sample_bit(i2s_dev_t *hw, int half_sample_bits) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->rx_conf1.rx_half_sample_bits = half_sample_bits - 1; } /** - * @brief Get I2S rx sinc dsr 16 en + * @brief Enable TX MSB shift, the data will be launch at the first BCK clock * * @param hw Peripheral I2S hardware instance address. - * @param val value to get rx sinc dsr 16 en + * @param msb_shift_enable Set true to enable MSB shift */ -static inline void i2s_ll_get_rx_sinc_dsr_16_en(i2s_dev_t *hw, bool *val) +static inline void i2s_ll_tx_enable_msb_shift(i2s_dev_t *hw, bool msb_shift_enable) { - abort(); // TODO ESP32-C3 IDF-2098 - // *val = hw->pdm_conf.rx_sinc_dsr_16_en; + hw->tx_conf1.tx_msb_shift = msb_shift_enable; } /** - * @brief Set I2S clkm div num + * @brief Enable RX MSB shift, the data will be launch at the first BCK clock * * @param hw Peripheral I2S hardware instance address. - * @param val value to set clkm div num + * @param msb_shift_enable Set true to enable MSB shift */ -static inline void i2s_ll_set_clkm_div_num(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_enable_msb_shift(i2s_dev_t *hw, bool msb_shift_enable) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->rx_conf1.rx_msb_shift = msb_shift_enable; } /** - * @brief Set I2S clkm div b + * @brief Configure TX total chan number * * @param hw Peripheral I2S hardware instance address. - * @param val value to set clkm div b + * @param total_num Total chan number */ -static inline void i2s_ll_set_clkm_div_b(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_set_chan_num(i2s_dev_t *hw, int total_num) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->tx_tdm_ctrl.tx_tdm_tot_chan_num = total_num - 1; } /** - * @brief Set I2S clkm div a + * @brief Configure RX total chan number * * @param hw Peripheral I2S hardware instance address. - * @param val value to set clkm div a + * @param total_num Total chan number */ -static inline void i2s_ll_set_clkm_div_a(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_set_chan_num(i2s_dev_t *hw, int total_num) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->rx_tdm_ctrl.rx_tdm_tot_chan_num = total_num - 1; } /** - * @brief Set I2S tx bck div num + * @brief Set the bimap of the active TX chan, only the active chan can launch audio data. * * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx bck div num + * @param chan_mask mask of tx active chan */ -static inline void i2s_ll_set_tx_bck_div_num(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_set_active_chan_mask(i2s_dev_t *hw, uint32_t chan_mask) { - abort(); // TODO ESP32-C3 IDF-2098 - + typeof(hw->tx_tdm_ctrl) tdm_ctrl_reg = hw->tx_tdm_ctrl; + tdm_ctrl_reg.val &= ~I2S_LL_TDM_CH_MASK; + tdm_ctrl_reg.val |= chan_mask & I2S_LL_TDM_CH_MASK; + hw->tx_tdm_ctrl.val = tdm_ctrl_reg.val; } /** - * @brief Set I2S rx bck div num + * @brief Set the bimap of the active RX chan, only the active chan can receive audio data. * * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx bck div num + * @param chan_mask mask of rx active chan */ -static inline void i2s_ll_set_rx_bck_div_num(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_set_active_chan_mask(i2s_dev_t *hw, uint32_t chan_mask) { - abort(); // TODO ESP32-C3 IDF-2098 - + typeof(hw->rx_tdm_ctrl) tdm_ctrl_reg = hw->rx_tdm_ctrl; + tdm_ctrl_reg.val &= ~I2S_LL_TDM_CH_MASK; + tdm_ctrl_reg.val |= chan_mask & I2S_LL_TDM_CH_MASK; + hw->rx_tdm_ctrl.val = tdm_ctrl_reg.val; } /** - * @brief Set I2S clk sel + * @brief Set TX WS signal pol level * * @param hw Peripheral I2S hardware instance address. - * @param val value to set clk sel + * @param ws_pol_level pin level of WS(output) when receiving left channel data */ -static inline void i2s_ll_set_clk_sel(i2s_dev_t *hw, uint32_t val) +static inline void i2s_tx_set_ws_idle_pol(i2s_dev_t *hw, int ws_pol_level) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->tx_conf.tx_ws_idle_pol = ws_pol_level; } /** - * @brief Set I2S tx bits mod + * @brief Set RX WS signal pol level * * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx bits mod + * @param ws_pol_level pin level of WS(input) when receiving left channel data */ -static inline void i2s_ll_set_tx_bits_mod(i2s_dev_t *hw, uint32_t val) +static inline void i2s_rx_set_ws_idle_pol(i2s_dev_t *hw, int ws_pol_level) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->rx_conf.rx_ws_idle_pol = ws_pol_level; } /** - * @brief Set I2S rx bits mod + * @brief Enable TX PDM mode. * * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx bits mod + * @param pdm_enable Set true to TX enable PDM mode */ -static inline void i2s_ll_set_rx_bits_mod(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_enable_pdm(i2s_dev_t *hw, bool pdm_enable) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->tx_conf.tx_pdm_en = pdm_enable; + hw->tx_conf.tx_tdm_en = !pdm_enable; + hw->tx_pcm2pdm_conf.pcm2pdm_conv_en = pdm_enable; } /** - * @brief Set I2S rx sinc dsr 16 en + * @brief Set I2S TX PDM prescale * * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx sinc dsr 16 en + * @param prescale I2S TX PDM prescale */ -static inline void i2s_ll_set_rx_sinc_dsr_16_en(i2s_dev_t *hw, bool val) +static inline void i2s_ll_tx_set_pdm_prescale(i2s_dev_t *hw, bool prescale) { - abort(); // TODO ESP32-C3 IDF-2098 - + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->tx_pcm2pdm_conf, tx_pdm_prescale, prescale); } /** - * @brief Set I2S dscr en + * @brief Set I2S TX PDM high pass filter scaling * * @param hw Peripheral I2S hardware instance address. - * @param val value to set dscr en + * @param sig_scale I2S TX PDM signal scaling before transmit to the filter */ -static inline void i2s_ll_set_dscr_en(i2s_dev_t *hw, bool val) +static inline void i2s_ll_tx_set_pdm_hp_scale(i2s_dev_t *hw, i2s_pdm_sig_scale_t sig_scale) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->tx_pcm2pdm_conf.tx_pdm_hp_in_shift = sig_scale; } /** - * @brief Set I2S lcd en + * @brief Set I2S TX PDM low pass filter scaling * * @param hw Peripheral I2S hardware instance address. - * @param val value to set lcd en + * @param sig_scale I2S TX PDM signal scaling before transmit to the filter */ -static inline void i2s_ll_set_lcd_en(i2s_dev_t *hw, bool val) +static inline void i2s_ll_tx_set_pdm_lp_scale(i2s_dev_t *hw, i2s_pdm_sig_scale_t sig_scale) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->tx_pcm2pdm_conf.tx_pdm_lp_in_shift = sig_scale; } /** - * @brief Set I2S camera en + * @brief Set I2S TX PDM sinc filter scaling * * @param hw Peripheral I2S hardware instance address. - * @param val value to set camera en + * @param sig_scale I2S TX PDM signal scaling before transmit to the filter */ -static inline void i2s_ll_set_camera_en(i2s_dev_t *hw, bool val) +static inline void i2s_ll_tx_set_pdm_sinc_scale(i2s_dev_t *hw, i2s_pdm_sig_scale_t sig_scale) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->tx_pcm2pdm_conf.tx_pdm_sinc_in_shift = sig_scale; } /** - * @brief Set I2S pcm2pdm conv en + * @brief Set I2S TX PDM sigma-delta filter scaling * * @param hw Peripheral I2S hardware instance address. - * @param val value to set pcm2pdm conv en + * @param sig_scale I2S TX PDM signal scaling before transmit to the filter */ -static inline void i2s_ll_set_pcm2pdm_conv_en(i2s_dev_t *hw, bool val) +static inline void i2s_ll_tx_set_pdm_sd_scale(i2s_dev_t *hw, i2s_pdm_sig_scale_t sig_scale) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->tx_pcm2pdm_conf.tx_pdm_sigmadelta_in_shift = sig_scale; } /** - * @brief Set I2S TX to MSB Alignment Standard + * @brief Set I2S TX PDM high pass filter param0 * * @param hw Peripheral I2S hardware instance address. + * @param param The fourth parameter of PDM TX IIR_HP filter stage 1 is (504 + I2S_TX_IIR_HP_MULT12_0[2:0]) */ -static inline void i2s_ll_set_tx_format_msb_align(i2s_dev_t *hw) -{ -} - - -static inline void i2s_ll_set_rx_format_msb_align(i2s_dev_t *hw) +static inline void i2s_ll_tx_set_pdm_hp_filter_param0(i2s_dev_t *hw, uint32_t param) { + hw->tx_pcm2pdm_conf1.tx_iir_hp_mult12_0 = param; } /** - * @brief Set I2S TX to PCM long standard + * @brief Set I2S TX PDM high pass filter param5 * * @param hw Peripheral I2S hardware instance address. + * @param param The fourth parameter of PDM TX IIR_HP filter stage 2 is (504 + I2S_TX_IIR_HP_MULT12_5[2:0]) */ -static inline void i2s_ll_set_tx_pcm_long(i2s_dev_t *hw) +static inline void i2s_ll_tx_set_pdm_hp_filter_param5(i2s_dev_t *hw, uint32_t param) { + hw->tx_pcm2pdm_conf1.tx_iir_hp_mult12_5 = param; } /** - * @brief Set I2S RX to PCM long standard + * @brief Enable I2S TX PDM high pass filter * * @param hw Peripheral I2S hardware instance address. + * @param enable Set true to enable I2S TX PDM high pass filter, set false to bypass it */ -static inline void i2s_ll_set_rx_pcm_long(i2s_dev_t *hw) +static inline void i2s_ll_tx_enable_pdm_hp_filter(i2s_dev_t *hw, bool enable) { + hw->tx_pcm2pdm_conf.tx_pdm_hp_bypass = !enable; } /** - * @brief Set I2S RX to PCM short standard + * @brief Enable I2S TX PDM sigma-delta codec * * @param hw Peripheral I2S hardware instance address. + * @param dither I2S TX PDM sigmadelta dither value */ -static inline void i2s_ll_set_rx_pcm_short(i2s_dev_t *hw) +static inline void i2s_ll_tx_enable_pdm_sd_codec(i2s_dev_t *hw, bool enable) { + hw->tx_pcm2pdm_conf.tx_pdm_dac_2out_en = enable; + hw->tx_pcm2pdm_conf.tx_pdm_dac_mode_en = enable; } /** - * @brief Set I2S RX to philip standard + * @brief Set I2S TX PDM sigma-delta codec dither * * @param hw Peripheral I2S hardware instance address. + * @param dither I2S TX PDM sigmadelta dither value */ -static inline void i2s_ll_set_rx_format_philip(i2s_dev_t *hw) +static inline void i2s_ll_tx_set_pdm_sd_dither(i2s_dev_t *hw, uint32_t dither) { + hw->tx_pcm2pdm_conf.tx_pdm_sigmadelta_dither = dither; } /** - * @brief Set I2S TX to PCM short standard + * @brief Set I2S TX PDM sigma-delta codec dither * * @param hw Peripheral I2S hardware instance address. + * @param dither2 I2S TX PDM sigmadelta dither2 value */ -static inline void i2s_ll_set_tx_pcm_short(i2s_dev_t *hw) +static inline void i2s_ll_tx_set_pdm_sd_dither2(i2s_dev_t *hw, uint32_t dither2) { + hw->tx_pcm2pdm_conf.tx_pdm_sigmadelta_dither2 = dither2; } /** - * @brief Set I2S TX to philip standard + * @brief Configure I2S TX PDM sample rate + * Fpdm = 64*Fpcm*fp/fs * * @param hw Peripheral I2S hardware instance address. + * @param fp The fp value of TX PDM filter module group0. + * @param fs The fs value of TX PDM filter module group0. */ -static inline void i2s_ll_set_tx_format_philip(i2s_dev_t *hw) +static inline void i2s_ll_tx_set_pdm_fpfs(i2s_dev_t *hw, uint32_t fp, uint32_t fs) { + hw->tx_pcm2pdm_conf1.tx_pdm_fp = fp; + hw->tx_pcm2pdm_conf1.tx_pdm_fs = fs; + hw->tx_pcm2pdm_conf.tx_pdm_sinc_osr2 = fp / fs; } /** - * @brief Set I2S pdm2pcm conv en + * @brief Get I2S TX PDM fp configuration paramater * * @param hw Peripheral I2S hardware instance address. - * @param val value to set pdm2pcm conv en + * @return + * - fp configuration paramater */ -static inline void i2s_ll_set_pdm2pcm_conv_en(i2s_dev_t *hw, bool val) +static inline uint32_t i2s_ll_tx_get_pdm_fp(i2s_dev_t *hw) { - abort(); // TODO ESP32-C3 IDF-2098 - + return hw->tx_pcm2pdm_conf1.tx_pdm_fp; } /** - * @brief Set I2S rx pdm en + * @brief Get I2S TX PDM fs configuration paramater * * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx pdm en + * @return + * - fs configuration paramater */ -static inline void i2s_ll_set_rx_pdm_en(i2s_dev_t *hw, bool val) +static inline uint32_t i2s_ll_tx_get_pdm_fs(i2s_dev_t *hw) { - abort(); // TODO ESP32-C3 IDF-2098 - + return hw->tx_pcm2pdm_conf1.tx_pdm_fs; } /** - * @brief Set I2S tx pdm en + * @brief Enable RX PDM mode. + * @note ESP32-C3 doesn't support pdm in rx mode, disable anyway * * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx pdm en + * @param pdm_enable Set true to RX enable PDM mode (ignored) */ -static inline void i2s_ll_set_tx_pdm_en(i2s_dev_t *hw, bool val) +static inline void i2s_ll_rx_enable_pdm(i2s_dev_t *hw, bool pdm_enable) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->rx_conf.rx_pdm_en = 0; + hw->rx_conf.rx_tdm_en = 1; } /** - * @brief Set I2S tx fifo mod force en + * @brief Configura TX a/u-law decompress or compress * * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx fifo mod force en + * @param pcm_cfg PCM configuration paramater */ -static inline void i2s_ll_set_tx_fifo_mod_force_en(i2s_dev_t *hw, bool val) +static inline void i2s_ll_tx_set_pcm_type(i2s_dev_t *hw, i2s_pcm_compress_t pcm_cfg) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->tx_conf.tx_pcm_conf = pcm_cfg; + hw->tx_conf.tx_pcm_bypass = !pcm_cfg; } /** - * @brief Set I2S rx fifo mod force en + * @brief Configure RX a/u-law decompress or compress * * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx fifo mod force en + * @param pcm_cfg PCM configuration paramater */ -static inline void i2s_ll_set_rx_fifo_mod_force_en(i2s_dev_t *hw, bool val) +static inline void i2s_ll_rx_set_pcm_type(i2s_dev_t *hw, i2s_pcm_compress_t pcm_cfg) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->rx_conf.rx_pcm_conf = pcm_cfg; + hw->rx_conf.rx_pcm_bypass = !pcm_cfg; } /** - * @brief Set I2S tx right first + * @brief Enable TX audio data left alignment * * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx right first + * @param ena Set true to enable left alignment */ -static inline void i2s_ll_set_tx_right_first(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_enable_left_align(i2s_dev_t *hw, bool ena) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->tx_conf.tx_left_align = ena; } /** - * @brief Set I2S rx right first + * @brief Enable RX audio data left alignment * * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx right first + * @param ena Set true to enable left alignment */ -static inline void i2s_ll_set_rx_right_first(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_enable_left_align(i2s_dev_t *hw, bool ena) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->rx_conf.rx_left_align = ena; } /** - * @brief Set I2S tx slave mod + * @brief Enable TX big endian mode * * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx slave mod + * @param ena Set true to enable big endian mode */ -static inline void i2s_ll_set_tx_slave_mod(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_enable_big_endian(i2s_dev_t *hw, bool ena) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->rx_conf.rx_big_endian = ena; } /** - * @brief Set I2S rx slave mod + * @brief Enable RX big endian mode * * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx slave mod + * @param ena Set true to enable big endian mode */ -static inline void i2s_ll_set_rx_slave_mod(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_enable_big_endian(i2s_dev_t *hw, bool ena) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->tx_conf.tx_big_endian = ena; } /** - * @brief Get I2S tx msb right + * @brief Configure TX bit order * * @param hw Peripheral I2S hardware instance address. - * @param val value to get tx msb right + * @param lsb_order_ena Set true to enable LSB bit order */ -static inline void i2s_ll_get_tx_msb_right(i2s_dev_t *hw, uint32_t *val) +static inline void i2s_ll_tx_set_bit_order(i2s_dev_t *hw, bool lsb_order_ena) { - abort(); // TODO ESP32-C3 IDF-2098 - // *val = hw->conf.tx_msb_right; + hw->tx_conf.tx_bit_order = lsb_order_ena; } /** - * @brief Get I2S rx msb right + * @brief Configure RX bit order * * @param hw Peripheral I2S hardware instance address. - * @param val value to get rx msb right + * @param lsb_order_ena Set true to enable LSB bit order */ -static inline void i2s_ll_get_rx_msb_right(i2s_dev_t *hw, uint32_t *val) +static inline void i2s_ll_rx_set_bit_order(i2s_dev_t *hw, bool lsb_order_ena) { - abort(); // TODO ESP32-C3 IDF-2098 - // *val = hw->conf.rx_msb_right; + hw->rx_conf.rx_bit_order = lsb_order_ena; } /** - * @brief Set I2S tx msb right + * @brief Configure TX skip mask enable * * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx msb right + * @param skip_mask_ena Set true to skip inactive channels. */ -static inline void i2s_ll_set_tx_msb_right(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_set_skip_mask(i2s_dev_t *hw, bool skip_mask_ena) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->tx_tdm_ctrl.tx_tdm_skip_msk_en = skip_mask_ena; } -/** - * @brief Set I2S rx msb right - * - * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx msb right - */ -static inline void i2s_ll_set_rx_msb_right(i2s_dev_t *hw, uint32_t val) -{ - abort(); // TODO ESP32-C3 IDF-2098 - -} /** - * @brief Set I2S tx mono + * @brief Configure single data * * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx mono + * @param data Single data to be set */ -static inline void i2s_ll_set_tx_mono(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_set_single_data(i2s_dev_t *hw, uint32_t data) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->conf_single_data = data; } /** - * @brief Set I2S rx mono + * @brief Enable TX mono mode + * @note MONO in hardware means only one channel got data, but another doesn't + * MONO in software means two channel share same data + * This function aims to use MONO in software meaning + * so 'tx_mono' and 'tx_chan_equal' should be enabled at the same time * * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx mono + * @param mono_ena Set true to enable mono mde. */ -static inline void i2s_ll_set_rx_mono(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_enable_mono_mode(i2s_dev_t *hw, bool mono_ena) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->tx_conf.tx_mono = mono_ena; + hw->tx_conf.tx_chan_equal = mono_ena; } /** - * @brief Set I2S tx sinc osr2 + * @brief Enable RX mono mode * * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx sinc osr2 + * @param mono_ena Set true to enable mono mde. */ -static inline void i2s_ll_set_tx_sinc_osr2(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_enable_mono_mode(i2s_dev_t *hw, bool mono_ena) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->rx_conf.rx_mono = mono_ena; + hw->rx_conf.rx_mono_fst_vld = mono_ena; } /** - * @brief Set I2S sig loopback + * @brief Enable loopback mode * * @param hw Peripheral I2S hardware instance address. - * @param val value to set sig loopback + * @param ena Set true to share BCK and WS signal for tx module and rx module. */ -static inline void i2s_ll_set_sig_loopback(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_share_bck_ws(i2s_dev_t *hw, bool ena) { - abort(); // TODO ESP32-C3 IDF-2098 - + hw->tx_conf.sig_loopback = ena; } #ifdef __cplusplus diff --git a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/ledc_ll.h b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/ledc_ll.h index eafae904bad..fb495b03198 100644 --- a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/ledc_ll.h +++ b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/ledc_ll.h @@ -19,6 +19,7 @@ #include "hal/ledc_types.h" #include "soc/ledc_periph.h" +#include "soc/ledc_struct.h" #ifdef __cplusplus extern "C" { diff --git a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/mwdt_ll.h b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/mwdt_ll.h index c1fd5be9d6c..944108439e9 100644 --- a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/mwdt_ll.h +++ b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/mwdt_ll.h @@ -24,6 +24,7 @@ extern "C" { #include #include #include "soc/timer_periph.h" +#include "soc/timer_group_struct.h" #include "hal/wdt_types.h" #include "esp_attr.h" @@ -42,6 +43,13 @@ _Static_assert(WDT_RESET_SIG_LENGTH_800ns == TIMG_WDT_RESET_LENGTH_800_NS, "Add _Static_assert(WDT_RESET_SIG_LENGTH_1_6us == TIMG_WDT_RESET_LENGTH_1600_NS, "Add mapping to LL watchdog timeout behavior, since it's no longer naturally compatible with wdt_reset_sig_length_t"); _Static_assert(WDT_RESET_SIG_LENGTH_3_2us == TIMG_WDT_RESET_LENGTH_3200_NS, "Add mapping to LL watchdog timeout behavior, since it's no longer naturally compatible with wdt_reset_sig_length_t"); +#define FORCE_MODIFY_WHOLE_REG(i, j, k) \ +{ \ + typeof(i) temp_reg = (i); \ + temp_reg.j = (k); \ + (i) = temp_reg; \ +} + /** * @brief Enable the MWDT * @@ -49,7 +57,7 @@ _Static_assert(WDT_RESET_SIG_LENGTH_3_2us == TIMG_WDT_RESET_LENGTH_3200_NS, "Add */ FORCE_INLINE_ATTR void mwdt_ll_enable(timg_dev_t *hw) { - hw->wdt_config0.en = 1; + hw->wdtconfig0.wdt_en = 1; } /** @@ -62,7 +70,7 @@ FORCE_INLINE_ATTR void mwdt_ll_enable(timg_dev_t *hw) */ FORCE_INLINE_ATTR void mwdt_ll_disable(timg_dev_t *hw) { - hw->wdt_config0.en = 0; + hw->wdtconfig0.wdt_en = 0; } /** @@ -73,7 +81,7 @@ FORCE_INLINE_ATTR void mwdt_ll_disable(timg_dev_t *hw) */ FORCE_INLINE_ATTR bool mwdt_ll_check_if_enabled(timg_dev_t *hw) { - return (hw->wdt_config0.en) ? true : false; + return (hw->wdtconfig0.wdt_en) ? true : false; } /** @@ -88,26 +96,26 @@ FORCE_INLINE_ATTR void mwdt_ll_config_stage(timg_dev_t *hw, wdt_stage_t stage, u { switch (stage) { case WDT_STAGE0: - hw->wdt_config0.stg0 = behavior; - hw->wdt_config2 = timeout; + hw->wdtconfig0.wdt_stg0 = behavior; + hw->wdtconfig2.wdt_stg0_hold = timeout; break; case WDT_STAGE1: - hw->wdt_config0.stg1 = behavior; - hw->wdt_config3 = timeout; + hw->wdtconfig0.wdt_stg1 = behavior; + hw->wdtconfig3.wdt_stg1_hold = timeout; break; case WDT_STAGE2: - hw->wdt_config0.stg2 = behavior; - hw->wdt_config4 = timeout; + hw->wdtconfig0.wdt_stg2 = behavior; + hw->wdtconfig4.wdt_stg2_hold = timeout; break; case WDT_STAGE3: - hw->wdt_config0.stg3 = behavior; - hw->wdt_config5 = timeout; + hw->wdtconfig0.wdt_stg3 = behavior; + hw->wdtconfig5.wdt_stg3_hold = timeout; break; default: break; } //Config registers are updated asynchronously - hw->wdt_config0.conf_update_en = 1; + hw->wdtconfig0.wdt_conf_update_en = 1; } /** @@ -120,22 +128,22 @@ FORCE_INLINE_ATTR void mwdt_ll_disable_stage(timg_dev_t *hw, uint32_t stage) { switch (stage) { case WDT_STAGE0: - hw->wdt_config0.stg0 = WDT_STAGE_ACTION_OFF; + hw->wdtconfig0.wdt_stg0 = WDT_STAGE_ACTION_OFF; break; case WDT_STAGE1: - hw->wdt_config0.stg1 = WDT_STAGE_ACTION_OFF; + hw->wdtconfig0.wdt_stg1 = WDT_STAGE_ACTION_OFF; break; case WDT_STAGE2: - hw->wdt_config0.stg2 = WDT_STAGE_ACTION_OFF; + hw->wdtconfig0.wdt_stg2 = WDT_STAGE_ACTION_OFF; break; case WDT_STAGE3: - hw->wdt_config0.stg3 = WDT_STAGE_ACTION_OFF; + hw->wdtconfig0.wdt_stg3 = WDT_STAGE_ACTION_OFF; break; default: break; } //Config registers are updated asynchronously - hw->wdt_config0.conf_update_en = 1; + hw->wdtconfig0.wdt_conf_update_en = 1; } /** @@ -146,9 +154,9 @@ FORCE_INLINE_ATTR void mwdt_ll_disable_stage(timg_dev_t *hw, uint32_t stage) */ FORCE_INLINE_ATTR void mwdt_ll_set_cpu_reset_length(timg_dev_t *hw, wdt_reset_sig_length_t length) { - hw->wdt_config0.cpu_reset_length = length; + hw->wdtconfig0.wdt_cpu_reset_length = length; //Config registers are updated asynchronously - hw->wdt_config0.conf_update_en = 1; + hw->wdtconfig0.wdt_conf_update_en = 1; } /** @@ -159,9 +167,9 @@ FORCE_INLINE_ATTR void mwdt_ll_set_cpu_reset_length(timg_dev_t *hw, wdt_reset_si */ FORCE_INLINE_ATTR void mwdt_ll_set_sys_reset_length(timg_dev_t *hw, wdt_reset_sig_length_t length) { - hw->wdt_config0.sys_reset_length = length; + hw->wdtconfig0.wdt_sys_reset_length = length; //Config registers are updated asynchronously - hw->wdt_config0.conf_update_en = 1; + hw->wdtconfig0.wdt_conf_update_en = 1; } /** @@ -176,9 +184,9 @@ FORCE_INLINE_ATTR void mwdt_ll_set_sys_reset_length(timg_dev_t *hw, wdt_reset_si */ FORCE_INLINE_ATTR void mwdt_ll_set_flashboot_en(timg_dev_t *hw, bool enable) { - hw->wdt_config0.flashboot_mod_en = (enable) ? 1 : 0; + hw->wdtconfig0.wdt_flashboot_mod_en = (enable) ? 1 : 0; //Config registers are updated asynchronously - hw->wdt_config0.conf_update_en = 1; + hw->wdtconfig0.wdt_conf_update_en = 1; } /** @@ -189,9 +197,11 @@ FORCE_INLINE_ATTR void mwdt_ll_set_flashboot_en(timg_dev_t *hw, bool enable) */ FORCE_INLINE_ATTR void mwdt_ll_set_prescaler(timg_dev_t *hw, uint32_t prescaler) { - hw->wdt_config1.clk_prescale = prescaler; + // In case the compiler optimise a 32bit instruction (e.g. s32i) into 8/16bit instruction (e.g. s8i, which is not allowed to access a register) + // We take care of the "read-modify-write" procedure by ourselves. + FORCE_MODIFY_WHOLE_REG(hw->wdtconfig1, wdt_clk_prescale, prescaler); //Config registers are updated asynchronously - hw->wdt_config0.conf_update_en = 1; + hw->wdtconfig0.wdt_conf_update_en = 1; } /** @@ -203,7 +213,7 @@ FORCE_INLINE_ATTR void mwdt_ll_set_prescaler(timg_dev_t *hw, uint32_t prescaler) */ FORCE_INLINE_ATTR void mwdt_ll_feed(timg_dev_t *hw) { - hw->wdt_feed = 1; + hw->wdtfeed.wdt_feed = 1; } /** @@ -215,7 +225,7 @@ FORCE_INLINE_ATTR void mwdt_ll_feed(timg_dev_t *hw) */ FORCE_INLINE_ATTR void mwdt_ll_write_protect_enable(timg_dev_t *hw) { - hw->wdt_wprotect = 0; + hw->wdtwprotect.wdt_wkey = 0; } /** @@ -225,7 +235,7 @@ FORCE_INLINE_ATTR void mwdt_ll_write_protect_enable(timg_dev_t *hw) */ FORCE_INLINE_ATTR void mwdt_ll_write_protect_disable(timg_dev_t *hw) { - hw->wdt_wprotect = TIMG_WDT_WKEY_VALUE; + hw->wdtwprotect.wdt_wkey = TIMG_WDT_WKEY_VALUE; } /** @@ -235,7 +245,7 @@ FORCE_INLINE_ATTR void mwdt_ll_write_protect_disable(timg_dev_t *hw) */ FORCE_INLINE_ATTR void mwdt_ll_clear_intr_status(timg_dev_t *hw) { - hw->int_clr.wdt = 1; + hw->int_clr_timers.wdt_int_clr = 1; } /** @@ -246,7 +256,7 @@ FORCE_INLINE_ATTR void mwdt_ll_clear_intr_status(timg_dev_t *hw) */ FORCE_INLINE_ATTR void mwdt_ll_set_intr_enable(timg_dev_t *hw, bool enable) { - hw->int_ena.wdt = (enable) ? 1 : 0; + hw->int_ena_timers.wdt_int_ena = (enable) ? 1 : 0; } #ifdef __cplusplus diff --git a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/rmt_ll.h b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/rmt_ll.h index f5427d150a7..0f703aebc75 100644 --- a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/rmt_ll.h +++ b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/rmt_ll.h @@ -16,6 +16,7 @@ #include #include #include +#include "hal/misc.h" #include "soc/rmt_struct.h" #ifdef __cplusplus @@ -58,7 +59,7 @@ static inline void rmt_ll_set_group_clock_src(rmt_dev_t *dev, uint32_t channel, // Formula: rmt_sclk = module_clock_src / (1 + div_num + div_a / div_b) dev->sys_conf.sclk_active = 0; dev->sys_conf.sclk_sel = src; - dev->sys_conf.sclk_div_num = div_num; + HAL_FORCE_MODIFY_U32_REG_FIELD(dev->sys_conf, sclk_div_num, div_num); dev->sys_conf.sclk_div_a = div_a; dev->sys_conf.sclk_div_b = div_b; dev->sys_conf.sclk_active = 1; @@ -140,22 +141,22 @@ static inline uint32_t rmt_ll_rx_get_mem_blocks(rmt_dev_t *dev, uint32_t channel static inline void rmt_ll_tx_set_channel_clock_div(rmt_dev_t *dev, uint32_t channel, uint32_t div) { - dev->tx_conf[channel].div_cnt = div; + HAL_FORCE_MODIFY_U32_REG_FIELD(dev->tx_conf[channel], div_cnt, div); } static inline void rmt_ll_rx_set_channel_clock_div(rmt_dev_t *dev, uint32_t channel, uint32_t div) { - dev->rx_conf[channel].conf0.div_cnt = div; + HAL_FORCE_MODIFY_U32_REG_FIELD(dev->rx_conf[channel].conf0, div_cnt, div); } static inline uint32_t rmt_ll_tx_get_channel_clock_div(rmt_dev_t *dev, uint32_t channel) { - return dev->tx_conf[channel].div_cnt; + return HAL_FORCE_READ_U32_REG_FIELD(dev->tx_conf[channel], div_cnt); } static inline uint32_t rmt_ll_rx_get_channel_clock_div(rmt_dev_t *dev, uint32_t channel) { - return dev->rx_conf[channel].conf0.div_cnt; + return HAL_FORCE_READ_U32_REG_FIELD(dev->rx_conf[channel].conf0, div_cnt); } static inline void rmt_ll_tx_enable_pingpong(rmt_dev_t *dev, uint32_t channel, bool enable) @@ -231,7 +232,7 @@ static inline void rmt_ll_rx_enable_filter(rmt_dev_t *dev, uint32_t channel, boo static inline void rmt_ll_rx_set_filter_thres(rmt_dev_t *dev, uint32_t channel, uint32_t thres) { - dev->rx_conf[channel].conf1.rx_filter_thres = thres; + HAL_FORCE_MODIFY_U32_REG_FIELD(dev->rx_conf[channel].conf1, rx_filter_thres, thres); } static inline void rmt_ll_tx_enable_idle(rmt_dev_t *dev, uint32_t channel, bool enable) @@ -441,14 +442,14 @@ static inline void rmt_ll_rx_set_carrier_high_low_ticks(rmt_dev_t *dev, uint32_t static inline void rmt_ll_tx_get_carrier_high_low_ticks(rmt_dev_t *dev, uint32_t channel, uint32_t *high_ticks, uint32_t *low_ticks) { - *high_ticks = dev->tx_carrier[channel].high; - *low_ticks = dev->tx_carrier[channel].low; + *high_ticks = HAL_FORCE_READ_U32_REG_FIELD(dev->tx_carrier[channel], high); + *low_ticks = HAL_FORCE_READ_U32_REG_FIELD(dev->tx_carrier[channel], low); } static inline void rmt_ll_rx_get_carrier_high_low_ticks(rmt_dev_t *dev, uint32_t channel, uint32_t *high_ticks, uint32_t *low_ticks) { - *high_ticks = dev->rx_carrier[channel].high_thres; - *low_ticks = dev->rx_carrier[channel].low_thres; + *high_ticks = HAL_FORCE_READ_U32_REG_FIELD(dev->rx_carrier[channel], high_thres); + *low_ticks = HAL_FORCE_READ_U32_REG_FIELD(dev->rx_carrier[channel], low_thres); } static inline void rmt_ll_tx_enable_carrier_modulation(rmt_dev_t *dev, uint32_t channel, bool enable) diff --git a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/rtc_cntl_ll.h b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/rtc_cntl_ll.h index 72385568a47..9f298bbf09b 100644 --- a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/rtc_cntl_ll.h +++ b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/rtc_cntl_ll.h @@ -17,7 +17,7 @@ #include "soc/soc.h" #include "soc/rtc.h" #include "soc/rtc_cntl_reg.h" -#include "soc/apb_ctrl_reg.h" +#include "soc/syscon_reg.h" #ifdef __cplusplus extern "C" { @@ -47,12 +47,18 @@ static inline void rtc_cntl_ll_gpio_clear_wakeup_pins(void) REG_SET_BIT(RTC_CNTL_GPIO_WAKEUP_REG, RTC_CNTL_GPIO_WAKEUP_STATUS_CLR); } -static inline void rtc_cntl_ll_enable_cpu_retention(uint32_t addr) +static inline void rtc_cntl_ll_set_cpu_retention_link_addr(uint32_t addr) +{ + REG_SET_FIELD(SYSCON_RETENTION_CTRL_REG, SYSCON_RETENTION_LINK_ADDR, (uint32_t)addr); +} + +static inline void rtc_cntl_ll_enable_cpu_retention_clock(void) { - /* write memory address to register */ - REG_SET_FIELD(APB_CTRL_RETENTION_CTRL_REG, APB_CTRL_RETENTION_LINK_ADDR, (uint32_t)addr); - /* Enable clock */ REG_SET_BIT(RTC_CNTL_CLK_CONF_REG, RTC_CNTL_DIG_CLK8M_EN); +} + +static inline void rtc_cntl_ll_enable_cpu_retention(void) +{ /* Enable retention when cpu sleep enable */ REG_SET_BIT(RTC_CNTL_RETENTION_CTRL_REG, RTC_CNTL_RETENTION_EN); } diff --git a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/rwdt_ll.h b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/rwdt_ll.h index 87ae4f7294b..0986ce3dec5 100644 --- a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/rwdt_ll.h +++ b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/rwdt_ll.h @@ -23,8 +23,10 @@ extern "C" { #include #include +#include "hal/misc.h" #include "hal/wdt_types.h" #include "soc/rtc_cntl_periph.h" +#include "soc/rtc_cntl_struct.h" #include "soc/efuse_reg.h" #include "esp_attr.h" @@ -239,7 +241,7 @@ FORCE_INLINE_ATTR void rwdt_ll_set_chip_reset_en(rtc_cntl_dev_t *hw, bool enable */ FORCE_INLINE_ATTR void rwdt_ll_set_chip_reset_width(rtc_cntl_dev_t *hw, uint32_t width) { - hw->wdt_config0.chip_reset_width = width; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->wdt_config0, chip_reset_width, width); } /** diff --git a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/sigmadelta_ll.h b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/sigmadelta_ll.h index 87f75dab9ed..f6c37054a37 100644 --- a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/sigmadelta_ll.h +++ b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/sigmadelta_ll.h @@ -22,7 +22,9 @@ #pragma once #include +#include "hal/misc.h" #include "soc/sigmadelta_periph.h" +#include "soc/gpio_sd_struct.h" #include "hal/sigmadelta_types.h" #ifdef __cplusplus @@ -53,7 +55,7 @@ static inline void sigmadelta_ll_set_en(gpio_sd_dev_t *hw, bool en) */ static inline void sigmadelta_ll_set_duty(gpio_sd_dev_t *hw, sigmadelta_channel_t channel, int8_t duty) { - hw->channel[channel].duty = duty; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->channel[channel], duty, (uint32_t)duty); } /** @@ -65,7 +67,7 @@ static inline void sigmadelta_ll_set_duty(gpio_sd_dev_t *hw, sigmadelta_channel_ */ static inline void sigmadelta_ll_set_prescale(gpio_sd_dev_t *hw, sigmadelta_channel_t channel, uint8_t prescale) { - hw->channel[channel].prescale = prescale; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->channel[channel], prescale, prescale); } #ifdef __cplusplus diff --git a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/spi_ll.h b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/spi_ll.h index 8d2c1079f58..38e1676d041 100644 --- a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/spi_ll.h +++ b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/spi_ll.h @@ -27,9 +27,11 @@ #include "esp_attr.h" #include "esp_types.h" #include "soc/spi_periph.h" +#include "soc/spi_struct.h" #include "soc/lldesc.h" #include "hal/assert.h" #include "hal/misc.h" +#include "hal/spi_types.h" #ifdef __cplusplus extern "C" { @@ -37,6 +39,9 @@ extern "C" { /// Interrupt not used. Don't use in app. #define SPI_LL_UNUSED_INT_MASK (SPI_TRANS_DONE_INT_ENA | SPI_SLV_WR_DMA_DONE_INT_ENA | SPI_SLV_RD_DMA_DONE_INT_ENA | SPI_SLV_WR_BUF_DONE_INT_ENA | SPI_SLV_RD_BUF_DONE_INT_ENA) +/// These 2 masks together will set SPI transaction to one line mode +#define SPI_LL_ONE_LINE_CTRL_MASK (SPI_FREAD_QUAD | SPI_FREAD_DUAL | SPI_FCMD_QUAD | SPI_FCMD_DUAL | SPI_FADDR_QUAD | SPI_FADDR_DUAL) +#define SPI_LL_ONE_LINE_USER_MASK (SPI_FWRITE_QUAD | SPI_FWRITE_DUAL) /// Swap the bit order to its correct place to send #define HAL_SPI_SWAP_DATA_TX(data, len) HAL_SWAP32((uint32_t)(data) << (32 - len)) /// This is the expected clock frequency @@ -51,15 +56,6 @@ extern "C" { typedef uint32_t spi_ll_clock_val_t; typedef spi_dev_t spi_dma_dev_t; -/** IO modes supported by the master. */ -typedef enum { - SPI_LL_IO_MODE_NORMAL = 0, ///< 1-bit mode for all phases - SPI_LL_IO_MODE_DIO, ///< 2-bit mode for address and data phases, 1-bit mode for command phase - SPI_LL_IO_MODE_DUAL, ///< 2-bit mode for data phases only, 1-bit mode for command and address phases - SPI_LL_IO_MODE_QIO, ///< 4-bit mode for address and data phases, 1-bit mode for command phase - SPI_LL_IO_MODE_QUAD, ///< 4-bit mode for data phases only, 1-bit mode for command and address phases -} spi_ll_io_mode_t; - // Type definition of all supported interrupts typedef enum { SPI_LL_INTR_TRANS_DONE = BIT(0), ///< A transaction has done @@ -354,7 +350,7 @@ static inline void spi_ll_write_buffer(spi_dev_t *hw, const uint8_t *buffer_to_s */ static inline void spi_ll_write_buffer_byte(spi_dev_t *hw, int byte_id, uint8_t *data, int len) { - HAL_ASSERT(byte_id+len <= 64); + HAL_ASSERT(byte_id + len <= 64); HAL_ASSERT(len > 0); HAL_ASSERT(byte_id >= 0); @@ -362,10 +358,14 @@ static inline void spi_ll_write_buffer_byte(spi_dev_t *hw, int byte_id, uint8_t uint32_t word; int offset = byte_id % 4; int copy_len = 4 - offset; - if (copy_len > len) copy_len = len; + if (copy_len > len) { + copy_len = len; + } //read-modify-write - if (copy_len != 4) word = hw->data_buf[byte_id / 4]; //read + if (copy_len != 4) { + word = hw->data_buf[byte_id / 4]; //read + } memcpy(((uint8_t *)&word) + offset, data, copy_len); //modify hw->data_buf[byte_id / 4] = word; //write @@ -409,7 +409,9 @@ static inline void spi_ll_read_buffer_byte(spi_dev_t *hw, int byte_id, uint8_t * uint32_t word = hw->data_buf[byte_id / 4]; int offset = byte_id % 4; int copy_len = 4 - offset; - if (copy_len > len) copy_len = len; + if (copy_len > len) { + copy_len = len; + } memcpy(out_data, ((uint8_t *)&word) + offset, copy_len); byte_id += copy_len; @@ -540,41 +542,23 @@ static inline void spi_ll_set_sio_mode(spi_dev_t *hw, int sio_mode) } /** - * Configure the io mode for the master to work at. + * Configure the SPI transaction line mode for the master to use. * - * @param hw Beginning address of the peripheral registers. - * @param io_mode IO mode to work at, see ``spi_ll_io_mode_t``. + * @param hw Beginning address of the peripheral registers. + * @param line_mode SPI transaction line mode to use, see ``spi_line_mode_t``. */ -static inline void spi_ll_master_set_io_mode(spi_dev_t *hw, spi_ll_io_mode_t io_mode) -{ - if (io_mode == SPI_LL_IO_MODE_DIO || io_mode == SPI_LL_IO_MODE_DUAL) { - hw->ctrl.fcmd_dual = (io_mode == SPI_LL_IO_MODE_DIO) ? 1 : 0; - hw->ctrl.faddr_dual = (io_mode == SPI_LL_IO_MODE_DIO) ? 1 : 0; - hw->ctrl.fread_dual = 1; - hw->user.fwrite_dual = 1; - hw->ctrl.fcmd_quad = 0; - hw->ctrl.faddr_quad = 0; - hw->ctrl.fread_quad = 0; - hw->user.fwrite_quad = 0; - } else if (io_mode == SPI_LL_IO_MODE_QIO || io_mode == SPI_LL_IO_MODE_QUAD) { - hw->ctrl.fcmd_quad = (io_mode == SPI_LL_IO_MODE_QIO) ? 1 : 0; - hw->ctrl.faddr_quad = (io_mode == SPI_LL_IO_MODE_QIO) ? 1 : 0; - hw->ctrl.fread_quad = 1; - hw->user.fwrite_quad = 1; - hw->ctrl.fcmd_dual = 0; - hw->ctrl.faddr_dual = 0; - hw->ctrl.fread_dual = 0; - hw->user.fwrite_dual = 0; - } else { - hw->ctrl.fcmd_dual = 0; - hw->ctrl.faddr_dual = 0; - hw->ctrl.fread_dual = 0; - hw->user.fwrite_dual = 0; - hw->ctrl.fcmd_quad = 0; - hw->ctrl.faddr_quad = 0; - hw->ctrl.fread_quad = 0; - hw->user.fwrite_quad = 0; - } +static inline void spi_ll_master_set_line_mode(spi_dev_t *hw, spi_line_mode_t line_mode) +{ + hw->ctrl.val &= ~SPI_LL_ONE_LINE_CTRL_MASK; + hw->user.val &= ~SPI_LL_ONE_LINE_USER_MASK; + hw->ctrl.fcmd_dual = (line_mode.cmd_lines == 2); + hw->ctrl.fcmd_quad = (line_mode.cmd_lines == 4); + hw->ctrl.faddr_dual = (line_mode.addr_lines == 2); + hw->ctrl.faddr_quad = (line_mode.addr_lines == 4); + hw->ctrl.fread_dual = (line_mode.data_lines == 2); + hw->user.fwrite_dual = (line_mode.data_lines == 2); + hw->ctrl.fread_quad = (line_mode.data_lines == 4); + hw->user.fwrite_quad = (line_mode.data_lines == 4); } /** @@ -610,7 +594,8 @@ static inline void spi_ll_master_select_cs(spi_dev_t *hw, int cs_id) * @param hw Beginning address of the peripheral registers. * @param keep_active if 0 don't keep CS activated, else keep CS activated */ -static inline void spi_ll_master_keep_cs(spi_dev_t *hw, int keep_active) { +static inline void spi_ll_master_keep_cs(spi_dev_t *hw, int keep_active) +{ hw->misc.cs_keep_active = (keep_active != 0) ? 1 : 0; } @@ -917,13 +902,13 @@ static inline void spi_ll_set_command(spi_dev_t *hw, uint16_t cmd, int cmdlen, b { if (lsbfirst) { // The output command start from bit0 to bit 15, kept as is. - hw->user2.usr_command_value = cmd; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->user2, usr_command_value, cmd); } else { /* Output command will be sent from bit 7 to 0 of command_value, and * then bit 15 to 8 of the same register field. Shift and swap to send * more straightly. */ - hw->user2.usr_command_value = HAL_SPI_SWAP_DATA_TX(cmd, cmdlen); + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->user2, usr_command_value, HAL_SPI_SWAP_DATA_TX(cmd, cmdlen)); } } @@ -939,7 +924,7 @@ static inline void spi_ll_set_command(spi_dev_t *hw, uint16_t cmd, int cmdlen, b static inline void spi_ll_set_dummy(spi_dev_t *hw, int dummy_n) { hw->user.usr_dummy = dummy_n ? 1 : 0; - hw->user1.usr_dummy_cyclelen = dummy_n - 1; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->user1, usr_dummy_cyclelen, dummy_n - 1); } /** @@ -994,35 +979,35 @@ static inline uint32_t spi_ll_slave_get_rcv_bitlen(spi_dev_t *hw) item(SPI_LL_INTR_CMDA, dma_int_ena.cmda, dma_int_raw.cmda, dma_int_clr.cmda=1) -static inline void spi_ll_enable_intr(spi_dev_t* hw, spi_ll_intr_t intr_mask) +static inline void spi_ll_enable_intr(spi_dev_t *hw, spi_ll_intr_t intr_mask) { #define ENA_INTR(intr_bit, en_reg, ...) if (intr_mask & (intr_bit)) hw->en_reg = 1; FOR_EACH_ITEM(ENA_INTR, INTR_LIST); #undef ENA_INTR } -static inline void spi_ll_disable_intr(spi_dev_t* hw, spi_ll_intr_t intr_mask) +static inline void spi_ll_disable_intr(spi_dev_t *hw, spi_ll_intr_t intr_mask) { #define DIS_INTR(intr_bit, en_reg, ...) if (intr_mask & (intr_bit)) hw->en_reg = 0; FOR_EACH_ITEM(DIS_INTR, INTR_LIST); #undef DIS_INTR } -static inline void spi_ll_set_intr(spi_dev_t* hw, spi_ll_intr_t intr_mask) +static inline void spi_ll_set_intr(spi_dev_t *hw, spi_ll_intr_t intr_mask) { #define SET_INTR(intr_bit, _, st_reg, ...) if (intr_mask & (intr_bit)) hw->st_reg = 1; FOR_EACH_ITEM(SET_INTR, INTR_LIST); #undef SET_INTR } -static inline void spi_ll_clear_intr(spi_dev_t* hw, spi_ll_intr_t intr_mask) +static inline void spi_ll_clear_intr(spi_dev_t *hw, spi_ll_intr_t intr_mask) { #define CLR_INTR(intr_bit, _, __, clr_reg) if (intr_mask & (intr_bit)) hw->clr_reg; FOR_EACH_ITEM(CLR_INTR, INTR_LIST); #undef CLR_INTR } -static inline bool spi_ll_get_intr(spi_dev_t* hw, spi_ll_intr_t intr_mask) +static inline bool spi_ll_get_intr(spi_dev_t *hw, spi_ll_intr_t intr_mask) { #define GET_INTR(intr_bit, _, st_reg, ...) if (intr_mask & (intr_bit) && hw->st_reg) return true; FOR_EACH_ITEM(GET_INTR, INTR_LIST); @@ -1076,7 +1061,7 @@ static inline void spi_ll_enable_int(spi_dev_t *hw) /*------------------------------------------------------------------------------ * Slave HD *----------------------------------------------------------------------------*/ -static inline void spi_ll_slave_hd_set_len_cond(spi_dev_t* hw, spi_ll_trans_len_cond_t cond_mask) +static inline void spi_ll_slave_hd_set_len_cond(spi_dev_t *hw, spi_ll_trans_len_cond_t cond_mask) { hw->slave.rdbuf_bitlen_en = (cond_mask & SPI_LL_TRANS_LEN_COND_RDBUF) ? 1 : 0; hw->slave.wrbuf_bitlen_en = (cond_mask & SPI_LL_TRANS_LEN_COND_WRBUF) ? 1 : 0; @@ -1084,12 +1069,12 @@ static inline void spi_ll_slave_hd_set_len_cond(spi_dev_t* hw, spi_ll_trans_len_ hw->slave.wrdma_bitlen_en = (cond_mask & SPI_LL_TRANS_LEN_COND_WRDMA) ? 1 : 0; } -static inline int spi_ll_slave_get_rx_byte_len(spi_dev_t* hw) +static inline int spi_ll_slave_get_rx_byte_len(spi_dev_t *hw) { return hw->slave1.data_bitlen / 8; } -static inline uint32_t spi_ll_slave_hd_get_last_addr(spi_dev_t* hw) +static inline uint32_t spi_ll_slave_hd_get_last_addr(spi_dev_t *hw) { return hw->slave1.last_addr; } diff --git a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/spimem_flash_ll.h b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/spimem_flash_ll.h index 7641c3d723c..92c8748dd49 100644 --- a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/spimem_flash_ll.h +++ b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/spimem_flash_ll.h @@ -28,6 +28,7 @@ #include #include "soc/spi_periph.h" +#include "soc/spi_mem_struct.h" #include "hal/spi_types.h" #include "hal/spi_flash_types.h" @@ -157,7 +158,7 @@ static inline void spimem_flash_ll_auto_resume_init(spi_mem_dev_t *dev, bool aut */ static inline void spimem_flash_ll_suspend_cmd_setup(spi_mem_dev_t *dev, uint32_t sus_cmd) { - dev->flash_sus_cmd.flash_pes_command = sus_cmd; + HAL_FORCE_MODIFY_U32_REG_FIELD(dev->flash_sus_cmd, flash_pes_command, sus_cmd); } /** @@ -169,7 +170,7 @@ static inline void spimem_flash_ll_suspend_cmd_setup(spi_mem_dev_t *dev, uint32_ */ static inline void spimem_flash_ll_resume_cmd_setup(spi_mem_dev_t *dev, uint32_t res_cmd) { - dev->flash_sus_cmd.flash_per_command = res_cmd; + HAL_FORCE_MODIFY_U32_REG_FIELD(dev->flash_sus_cmd, flash_per_command, res_cmd); } /** @@ -181,7 +182,7 @@ static inline void spimem_flash_ll_resume_cmd_setup(spi_mem_dev_t *dev, uint32_t */ static inline void spimem_flash_ll_rd_sus_cmd_setup(spi_mem_dev_t *dev, uint32_t pesr_cmd) { - dev->flash_sus_cmd.wait_pesr_command = pesr_cmd; + HAL_FORCE_MODIFY_U32_REG_FIELD(dev->flash_sus_cmd, wait_pesr_command, pesr_cmd); } /** @@ -218,7 +219,7 @@ static inline void spimem_flash_ll_res_check_sus_setup(spi_mem_dev_t *dev, bool static inline void spimem_flash_ll_set_read_sus_status(spi_mem_dev_t *dev, uint32_t sus_conf) { dev->flash_sus_ctrl.frd_sus_2b = 0; - dev->flash_sus_ctrl.pesr_end_msk = sus_conf; + HAL_FORCE_MODIFY_U32_REG_FIELD(dev->flash_sus_ctrl, pesr_end_msk, sus_conf); } /** @@ -229,7 +230,7 @@ static inline void spimem_flash_ll_set_read_sus_status(spi_mem_dev_t *dev, uint3 */ static inline void spimem_flash_ll_auto_wait_idle_init(spi_mem_dev_t *dev, bool auto_waiti) { - dev->flash_waiti_ctrl.waiti_cmd = 0x05; + HAL_FORCE_MODIFY_U32_REG_FIELD(dev->flash_waiti_ctrl, waiti_cmd, 0x05); dev->flash_sus_ctrl.flash_per_wait_en = auto_waiti; dev->flash_sus_ctrl.flash_pes_wait_en = auto_waiti; } diff --git a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/systimer_ll.h b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/systimer_ll.h index 769f68703fe..3628978f685 100644 --- a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/systimer_ll.h +++ b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/systimer_ll.h @@ -124,6 +124,11 @@ __attribute__((always_inline)) static inline void systimer_ll_set_alarm_period(s dev->target_conf[alarm_id].target_period = period; } +__attribute__((always_inline)) static inline uint32_t systimer_ll_get_alarm_period(systimer_dev_t *dev, uint32_t alarm_id) +{ + return dev->target_conf[alarm_id].target_period; +} + __attribute__((always_inline)) static inline void systimer_ll_apply_alarm_value(systimer_dev_t *dev, uint32_t alarm_id) { dev->comp_load[alarm_id].val = 0x01; diff --git a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/timer_ll.h b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/timer_ll.h index 8547fab25fe..5e51b102f18 100644 --- a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/timer_ll.h +++ b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/timer_ll.h @@ -22,7 +22,9 @@ extern "C" { #endif #include +#include "hal/misc.h" #include "soc/timer_periph.h" +#include "soc/timer_group_struct.h" #include "hal/timer_types.h" #include "hal/assert.h" @@ -52,11 +54,11 @@ static inline void timer_ll_set_divider(timg_dev_t *hw, timer_idx_t timer_num, u if (divider >= 65536) { divider = 0; } - int timer_en = hw->hw_timer[timer_num].config.enable; - hw->hw_timer[timer_num].config.enable = 0; - hw->hw_timer[timer_num].config.divcnt_rst = 1; - hw->hw_timer[timer_num].config.divider = divider; - hw->hw_timer[timer_num].config.enable = timer_en; + int timer_en = hw->hw_timer[timer_num].config.tx_en; + hw->hw_timer[timer_num].config.tx_en = 0; + hw->hw_timer[timer_num].config.tx_divcnt_rst = 1; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->hw_timer[timer_num].config, tx_divider, divider); + hw->hw_timer[timer_num].config.tx_en = timer_en; } /** @@ -70,7 +72,7 @@ static inline void timer_ll_set_divider(timg_dev_t *hw, timer_idx_t timer_num, u */ static inline void timer_ll_get_divider(timg_dev_t *hw, timer_idx_t timer_num, uint32_t *divider) { - uint32_t d = hw->hw_timer[timer_num].config.divider; + uint32_t d = HAL_FORCE_READ_U32_REG_FIELD(hw->hw_timer[timer_num].config, tx_divider); if (d == 0) { d = 65536; } else if (d == 1) { @@ -90,9 +92,9 @@ static inline void timer_ll_get_divider(timg_dev_t *hw, timer_idx_t timer_num, u */ static inline void timer_ll_set_counter_value(timg_dev_t *hw, timer_idx_t timer_num, uint64_t load_val) { - hw->hw_timer[timer_num].load_high.load_hi = (uint32_t) (load_val >> 32); - hw->hw_timer[timer_num].load_low = (uint32_t) load_val; - hw->hw_timer[timer_num].reload = 1; + hw->hw_timer[timer_num].loadhi.tx_load_hi = (uint32_t) (load_val >> 32); + hw->hw_timer[timer_num].loadlo.tx_load_lo = (uint32_t) load_val; + hw->hw_timer[timer_num].load.tx_load = 1; } /** @@ -106,9 +108,9 @@ static inline void timer_ll_set_counter_value(timg_dev_t *hw, timer_idx_t timer_ */ FORCE_INLINE_ATTR void timer_ll_get_counter_value(timg_dev_t *hw, timer_idx_t timer_num, uint64_t *timer_val) { - hw->hw_timer[timer_num].update.update = 1; - while (hw->hw_timer[timer_num].update.update) {} - *timer_val = ((uint64_t) hw->hw_timer[timer_num].cnt_high.hi << 32) | (hw->hw_timer[timer_num].cnt_low); + hw->hw_timer[timer_num].update.tx_update = 1; + while (hw->hw_timer[timer_num].update.tx_update) {} + *timer_val = ((uint64_t) hw->hw_timer[timer_num].hi.tx_hi << 32) | (hw->hw_timer[timer_num].lo.tx_lo); } /** @@ -122,7 +124,7 @@ FORCE_INLINE_ATTR void timer_ll_get_counter_value(timg_dev_t *hw, timer_idx_t ti */ static inline void timer_ll_set_counter_increase(timg_dev_t *hw, timer_idx_t timer_num, bool increase_en) { - hw->hw_timer[timer_num].config.increase = increase_en; + hw->hw_timer[timer_num].config.tx_increase = increase_en; } /** @@ -137,7 +139,7 @@ static inline void timer_ll_set_counter_increase(timg_dev_t *hw, timer_idx_t tim */ static inline bool timer_ll_get_counter_increase(timg_dev_t *hw, timer_idx_t timer_num) { - return hw->hw_timer[timer_num].config.increase; + return hw->hw_timer[timer_num].config.tx_increase; } /** @@ -151,7 +153,7 @@ static inline bool timer_ll_get_counter_increase(timg_dev_t *hw, timer_idx_t tim */ FORCE_INLINE_ATTR void timer_ll_set_counter_enable(timg_dev_t *hw, timer_idx_t timer_num, bool counter_en) { - hw->hw_timer[timer_num].config.enable = counter_en; + hw->hw_timer[timer_num].config.tx_en = counter_en; } /** @@ -166,7 +168,7 @@ FORCE_INLINE_ATTR void timer_ll_set_counter_enable(timg_dev_t *hw, timer_idx_t t */ static inline bool timer_ll_get_counter_enable(timg_dev_t *hw, timer_idx_t timer_num) { - return hw->hw_timer[timer_num].config.enable; + return hw->hw_timer[timer_num].config.tx_en; } /** @@ -180,7 +182,7 @@ static inline bool timer_ll_get_counter_enable(timg_dev_t *hw, timer_idx_t timer */ static inline void timer_ll_set_auto_reload(timg_dev_t *hw, timer_idx_t timer_num, bool auto_reload_en) { - hw->hw_timer[timer_num].config.autoreload = auto_reload_en; + hw->hw_timer[timer_num].config.tx_autoreload = auto_reload_en; } /** @@ -195,7 +197,7 @@ static inline void timer_ll_set_auto_reload(timg_dev_t *hw, timer_idx_t timer_nu */ FORCE_INLINE_ATTR bool timer_ll_get_auto_reload(timg_dev_t *hw, timer_idx_t timer_num) { - return hw->hw_timer[timer_num].config.autoreload; + return hw->hw_timer[timer_num].config.tx_autoreload; } /** @@ -209,8 +211,8 @@ FORCE_INLINE_ATTR bool timer_ll_get_auto_reload(timg_dev_t *hw, timer_idx_t time */ FORCE_INLINE_ATTR void timer_ll_set_alarm_value(timg_dev_t *hw, timer_idx_t timer_num, uint64_t alarm_value) { - hw->hw_timer[timer_num].alarm_high.alarm_hi = (uint32_t) (alarm_value >> 32); - hw->hw_timer[timer_num].alarm_low = (uint32_t) alarm_value; + hw->hw_timer[timer_num].alarmhi.tx_alarm_hi = (uint32_t) (alarm_value >> 32); + hw->hw_timer[timer_num].alarmlo.tx_alarm_lo = (uint32_t) alarm_value; } /** @@ -224,7 +226,7 @@ FORCE_INLINE_ATTR void timer_ll_set_alarm_value(timg_dev_t *hw, timer_idx_t time */ static inline void timer_ll_get_alarm_value(timg_dev_t *hw, timer_idx_t timer_num, uint64_t *alarm_value) { - *alarm_value = ((uint64_t) hw->hw_timer[timer_num].alarm_high.alarm_hi << 32) | (hw->hw_timer[timer_num].alarm_low); + *alarm_value = ((uint64_t) hw->hw_timer[timer_num].alarmhi.tx_alarm_hi << 32) | (hw->hw_timer[timer_num].alarmlo.tx_alarm_lo); } /** @@ -238,7 +240,7 @@ static inline void timer_ll_get_alarm_value(timg_dev_t *hw, timer_idx_t timer_nu */ FORCE_INLINE_ATTR void timer_ll_set_alarm_enable(timg_dev_t *hw, timer_idx_t timer_num, bool alarm_en) { - hw->hw_timer[timer_num].config.alarm_en = alarm_en; + hw->hw_timer[timer_num].config.tx_alarm_en = alarm_en; } /** @@ -253,7 +255,7 @@ FORCE_INLINE_ATTR void timer_ll_set_alarm_enable(timg_dev_t *hw, timer_idx_t tim */ static inline bool timer_ll_get_alarm_enable(timg_dev_t *hw, timer_idx_t timer_num) { - return hw->hw_timer[timer_num].config.alarm_en; + return hw->hw_timer[timer_num].config.tx_alarm_en; } /** @@ -266,7 +268,7 @@ static inline bool timer_ll_get_alarm_enable(timg_dev_t *hw, timer_idx_t timer_n */ FORCE_INLINE_ATTR void timer_ll_intr_enable(timg_dev_t *hw, timer_idx_t timer_num) { - hw->int_ena.val |= BIT(timer_num); + hw->int_ena_timers.val |= BIT(timer_num); } /** @@ -279,7 +281,7 @@ FORCE_INLINE_ATTR void timer_ll_intr_enable(timg_dev_t *hw, timer_idx_t timer_nu */ FORCE_INLINE_ATTR void timer_ll_intr_disable(timg_dev_t *hw, timer_idx_t timer_num) { - hw->int_ena.val &= (~BIT(timer_num)); + hw->int_ena_timers.val &= (~BIT(timer_num)); } /** @@ -292,7 +294,7 @@ FORCE_INLINE_ATTR void timer_ll_intr_disable(timg_dev_t *hw, timer_idx_t timer_n */ FORCE_INLINE_ATTR void timer_ll_clear_intr_status(timg_dev_t *hw, timer_idx_t timer_num) { - hw->int_clr.val |= BIT(timer_num); + hw->int_clr_timers.val |= BIT(timer_num); } /** @@ -305,7 +307,7 @@ FORCE_INLINE_ATTR void timer_ll_clear_intr_status(timg_dev_t *hw, timer_idx_t ti */ FORCE_INLINE_ATTR void timer_ll_get_intr_status(timg_dev_t *hw, uint32_t *intr_status) { - *intr_status = hw->int_st.val & 0x01; + *intr_status = hw->int_st_timers.val & 0x01; } /** @@ -319,7 +321,7 @@ FORCE_INLINE_ATTR void timer_ll_get_intr_status(timg_dev_t *hw, uint32_t *intr_s FORCE_INLINE_ATTR void timer_ll_get_intr_raw_status(timer_group_t group_num, uint32_t *intr_raw_status) { timg_dev_t *hw = TIMER_LL_GET_HW(group_num); - *intr_raw_status = hw->int_raw.val & 0x01; + *intr_raw_status = hw->int_raw_timers.val & 0x01; } /** @@ -391,7 +393,7 @@ static inline bool timer_ll_get_edge_int_enable(timg_dev_t *hw, timer_idx_t time */ static inline uint32_t timer_ll_get_intr_status_reg(timg_dev_t *hw) { - return (uint32_t) & (hw->int_st.val); + return (uint32_t) & (hw->int_st_timers.val); } static inline uint32_t timer_ll_get_intr_mask_bit(timg_dev_t *hw, timer_idx_t timer_num) @@ -409,7 +411,7 @@ static inline uint32_t timer_ll_get_intr_mask_bit(timg_dev_t *hw, timer_idx_t ti */ static inline void timer_ll_set_use_xtal(timg_dev_t *hw, timer_idx_t timer_num, bool use_xtal_en) { - hw->hw_timer[timer_num].config.use_xtal = use_xtal_en; + hw->hw_timer[timer_num].config.tx_use_xtal = use_xtal_en; } /** @@ -423,7 +425,7 @@ static inline void timer_ll_set_use_xtal(timg_dev_t *hw, timer_idx_t timer_num, */ static inline bool timer_ll_get_use_xtal(timg_dev_t *hw, timer_idx_t timer_num) { - return hw->hw_timer[timer_num].config.use_xtal; + return hw->hw_timer[timer_num].config.tx_use_xtal; } #ifdef __cplusplus diff --git a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/twai_ll.h b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/twai_ll.h index 92e04011185..371d4dd361d 100644 --- a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/twai_ll.h +++ b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/twai_ll.h @@ -31,6 +31,7 @@ extern "C" { #include "hal/misc.h" #include "hal/twai_types.h" #include "soc/twai_periph.h" +#include "soc/twai_struct.h" /* ------------------------- Defines and Typedefs --------------------------- */ @@ -399,7 +400,7 @@ static inline void twai_ll_clear_err_code_cap(twai_dev_t *hw) */ static inline void twai_ll_set_err_warn_lim(twai_dev_t *hw, uint32_t ewl) { - hw->error_warning_limit_reg.ewl = ewl; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->error_warning_limit_reg, ewl, ewl); } /** @@ -439,7 +440,7 @@ static inline uint32_t twai_ll_get_rec(twai_dev_t *hw) */ static inline void twai_ll_set_rec(twai_dev_t *hw, uint32_t rec) { - hw->rx_error_counter_reg.rxerr = rec; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->rx_error_counter_reg, rxerr, rec); } /* ------------------------ TX Error Count Register ------------------------- */ @@ -467,7 +468,7 @@ static inline uint32_t twai_ll_get_tec(twai_dev_t *hw) */ static inline void twai_ll_set_tec(twai_dev_t *hw, uint32_t tec) { - hw->tx_error_counter_reg.txerr = tec; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->tx_error_counter_reg, txerr, tec); } /* ---------------------- Acceptance Filter Registers ----------------------- */ @@ -486,8 +487,8 @@ static inline void twai_ll_set_acc_filter(twai_dev_t* hw, uint32_t code, uint32_ uint32_t code_swapped = HAL_SWAP32(code); uint32_t mask_swapped = HAL_SWAP32(mask); for (int i = 0; i < 4; i++) { - hw->acceptance_filter.acr[i].byte = ((code_swapped >> (i * 8)) & 0xFF); - hw->acceptance_filter.amr[i].byte = ((mask_swapped >> (i * 8)) & 0xFF); + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->acceptance_filter.acr[i], byte, ((code_swapped >> (i * 8)) & 0xFF)); + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->acceptance_filter.amr[i], byte, ((mask_swapped >> (i * 8)) & 0xFF)); } hw->mode_reg.afm = single_filter; } @@ -522,7 +523,7 @@ static inline void twai_ll_get_rx_buffer(twai_dev_t *hw, twai_ll_frame_buffer_t { //Copy RX buffer registers into frame for (int i = 0; i < 13; i++) { - rx_frame->bytes[i] = hw->tx_rx_buffer[i].byte; + rx_frame->bytes[i] = HAL_FORCE_READ_U32_REG_FIELD(hw->tx_rx_buffer[i], byte); } } @@ -652,14 +653,14 @@ static inline void twai_ll_set_clkout(twai_dev_t *hw, uint32_t divider) { if (divider >= 2 && divider <= 490) { hw->clock_divider_reg.co = 0; - hw->clock_divider_reg.cd = (divider / 2) - 1; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->clock_divider_reg, cd, (divider / 2) - 1); } else if (divider == 1) { //Setting the divider reg to max value (255) means a divider of 1 hw->clock_divider_reg.co = 0; - hw->clock_divider_reg.cd = 255; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->clock_divider_reg, cd, 255); } else { hw->clock_divider_reg.co = 1; - hw->clock_divider_reg.cd = 0; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->clock_divider_reg, cd, 0); } } diff --git a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/uart_ll.h b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/uart_ll.h index 64f2f40b87b..f94296327a2 100644 --- a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/uart_ll.h +++ b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/uart_ll.h @@ -17,8 +17,11 @@ #pragma once + +#include "hal/misc.h" #include "hal/uart_types.h" #include "soc/uart_periph.h" +#include "soc/uart_struct.h" #ifdef __cplusplus extern "C" { @@ -163,7 +166,7 @@ static inline void uart_ll_set_baudrate(uart_dev_t *hw, uint32_t baud) // an integer part and a fractional part. hw->clk_div.div_int = clk_div >> 4; hw->clk_div.div_frag = clk_div & 0xf; - hw->clk_conf.sclk_div_num = sclk_div - 1; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->clk_conf, sclk_div_num, sclk_div - 1); #undef DIV_UP } @@ -178,7 +181,7 @@ static inline uint32_t uart_ll_get_baudrate(uart_dev_t *hw) { uint32_t sclk_freq = uart_ll_get_sclk_freq(hw); typeof(hw->clk_div) div_reg = hw->clk_div; - return ((sclk_freq << 4)) / (((div_reg.div_int << 4) | div_reg.div_frag) * (hw->clk_conf.sclk_div_num + 1)); + return ((sclk_freq << 4)) / (((div_reg.div_int << 4) | div_reg.div_frag) * (HAL_FORCE_READ_U32_REG_FIELD(hw->clk_conf, sclk_div_num) + 1)); } /** @@ -451,7 +454,7 @@ static inline void uart_ll_set_tx_idle_num(uart_dev_t *hw, uint32_t idle_num) static inline void uart_ll_tx_break(uart_dev_t *hw, uint32_t break_num) { if (break_num > 0) { - hw->txbrk_conf.tx_brk_num = break_num; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->txbrk_conf, tx_brk_num, break_num); hw->conf0.txd_brk = 1; } else { hw->conf0.txd_brk = 0; @@ -518,8 +521,8 @@ static inline void uart_ll_set_sw_flow_ctrl(uart_dev_t *hw, uart_sw_flowctrl_t * hw->flow_conf.sw_flow_con_en = 1; hw->swfc_conf1.xon_threshold = flow_ctrl->xon_thrd; hw->swfc_conf0.xoff_threshold = flow_ctrl->xoff_thrd; - hw->swfc_conf1.xon_char = flow_ctrl->xon_char; - hw->swfc_conf0.xoff_char = flow_ctrl->xoff_char; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->swfc_conf1, xon_char, flow_ctrl->xon_char); + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->swfc_conf0, xoff_char, flow_ctrl->xoff_char); } else { hw->flow_conf.sw_flow_con_en = 0; hw->flow_conf.xonoff_del = 0; @@ -541,11 +544,11 @@ static inline void uart_ll_set_sw_flow_ctrl(uart_dev_t *hw, uart_sw_flowctrl_t * */ static inline void uart_ll_set_at_cmd_char(uart_dev_t *hw, uart_at_cmd_t *cmd_char) { - hw->at_cmd_char.data = cmd_char->cmd_char; - hw->at_cmd_char.char_num = cmd_char->char_num; - hw->at_cmd_postcnt.post_idle_num = cmd_char->post_idle; - hw->at_cmd_precnt.pre_idle_num = cmd_char->pre_idle; - hw->at_cmd_gaptout.rx_gap_tout = cmd_char->gap_tout; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->at_cmd_char, data, cmd_char->cmd_char); + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->at_cmd_char, char_num, cmd_char->char_num); + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->at_cmd_postcnt, post_idle_num, cmd_char->post_idle); + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->at_cmd_precnt, pre_idle_num, cmd_char->pre_idle); + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->at_cmd_gaptout, rx_gap_tout, cmd_char->gap_tout); } /** @@ -734,8 +737,8 @@ static inline void uart_ll_set_mode(uart_dev_t *hw, uart_mode_t mode) */ static inline void uart_ll_get_at_cmd_char(uart_dev_t *hw, uint8_t *cmd_char, uint8_t *char_num) { - *cmd_char = hw->at_cmd_char.data; - *char_num = hw->at_cmd_char.char_num; + *cmd_char = HAL_FORCE_READ_U32_REG_FIELD(hw->at_cmd_char, data); + *char_num = HAL_FORCE_READ_U32_REG_FIELD(hw->at_cmd_char, char_num); } /** @@ -890,6 +893,67 @@ static inline uint16_t uart_ll_max_tout_thrd(uart_dev_t *hw) return UART_RX_TOUT_THRHD_V; } +/** + * @brief Configure the auto baudrate. + * + * @param hw Beginning address of the peripheral registers. + * @param enable Boolean marking whether the auto baudrate should be enabled or not. + */ +static inline void uart_ll_set_autobaud_en(uart_dev_t *hw, bool enable) +{ + hw->conf0.autobaud_en = enable ? 1 : 0; +} + +/** + * @brief Get the RXD edge count. + * + * @param hw Beginning address of the peripheral registers. + */ +static inline uint32_t uart_ll_get_rxd_edge_cnt(uart_dev_t *hw) +{ + return hw->rxd_cnt.edge_cnt; +} + +/** + * @brief Get the positive pulse minimum count. + * + * @param hw Beginning address of the peripheral registers. + */ +static inline uint32_t uart_ll_get_pos_pulse_cnt(uart_dev_t *hw) +{ + return hw->pospulse.min_cnt; +} + +/** + * @brief Get the negative pulse minimum count. + * + * @param hw Beginning address of the peripheral registers. + */ +static inline uint32_t uart_ll_get_neg_pulse_cnt(uart_dev_t *hw) +{ + return hw->negpulse.min_cnt; +} + +/** + * @brief Get the high pulse minimum count. + * + * @param hw Beginning address of the peripheral registers. + */ +static inline uint32_t uart_ll_get_high_pulse_cnt(uart_dev_t *hw) +{ + return hw->highpulse.min_cnt; +} + +/** + * @brief Get the low pulse minimum count. + * + * @param hw Beginning address of the peripheral registers. + */ +static inline uint32_t uart_ll_get_low_pulse_cnt(uart_dev_t *hw) +{ + return hw->lowpulse.min_cnt; +} + /** * @brief Force UART xoff. * diff --git a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/uhci_ll.h b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/uhci_ll.h index 235d28ab3a3..a766797ea0f 100644 --- a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/uhci_ll.h +++ b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/uhci_ll.h @@ -18,9 +18,13 @@ #pragma once #include -#include "uhci_types.h" +#include "hal/uhci_types.h" #include "soc/uhci_struct.h" +#ifdef __cplusplus +extern "C" { +#endif + #define UHCI_LL_GET_HW(num) (((num) == 0) ? (&UHCI0) : (NULL)) typedef enum { @@ -128,3 +132,7 @@ static inline void uhci_ll_set_eof_mode(uhci_dev_t *hw, uint32_t eof_mode) hw->conf0.len_eof_en = 1; } } + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/usb_serial_jtag_ll.h b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/usb_serial_jtag_ll.h index 6702eebbc22..8e295a4181a 100644 --- a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/usb_serial_jtag_ll.h +++ b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/usb_serial_jtag_ll.h @@ -51,18 +51,6 @@ static inline void usb_serial_jtag_ll_ena_intr_mask(uint32_t mask) USB_SERIAL_JTAG.int_ena.val |= mask; } -/** - * @brief Clear the USB_SERIAL_JTAG interrupt based on the given mask. - * - * @param mask The bitmap of the interrupts bits need to be cleared. - * - * @return None - */ -static inline void usb_serial_jtag_ll_clr_intr_sts_mask(uint32_t mask) -{ - USB_SERIAL_JTAG.int_clr.val = mask; -} - /** * @brief Disable the USB_SERIAL_JTAG interrupt based on the given mask. * diff --git a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/xt_wdt_ll.h b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/xt_wdt_ll.h new file mode 100644 index 00000000000..65b36253e58 --- /dev/null +++ b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/xt_wdt_ll.h @@ -0,0 +1,101 @@ +/* + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +// The LL layer for xtal32k WDT register operations. +// Note that most of the register operations in this layer are non-atomic operations. + +#pragma once + +#include +#include "soc/rtc_cntl_periph.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define XT_WDT_LL_XTAL32_DEAD_INTR_MASK RTC_CNTL_XTAL32K_DEAD_INT_ST_M + +/** + * @brief Enable the XT_WDT + * + * @param hw Start address of the peripheral registers. + */ +inline void xt_wdt_ll_enable(rtc_cntl_dev_t *hw, bool enable) +{ + hw->ext_xtl_conf.xtal32k_wdt_en = enable; +} + +/** + * @brief Check if the XT_WDT is enabled + * + * @param hw Start address of the peripheral registers. + * @return True if XT WDT is enabled + */ +inline bool xt_wdt_ll_check_if_enabled(rtc_cntl_dev_t *hw) +{ + return (hw->ext_xtl_conf.xtal32k_wdt_en) ? true : false; +} + +/** + * @brief Set the watchdog timeout value + * + * @param hw Start address of the peripheral registers. + * @param timeout timeout value in RTC_CLK cycles + */ +inline void xt_wdt_ll_set_timeout(rtc_cntl_dev_t *hw, uint8_t timeout) +{ + hw->xtal32k_conf.xtal32k_wdt_timeout = timeout; +} + + +/** + * @brief Reset the XT_WDT + * + * @param hw Start address of the peripheral registers. + */ +inline void xt_wdt_ll_reset(rtc_cntl_dev_t *hw) +{ + hw->ext_xtl_conf.xtal32k_wdt_reset = 1; + hw->ext_xtl_conf.xtal32k_wdt_reset = 0; +} + + +/** + * @brief Set the backup clock value + * + * @param hw Start address of the peripheral registers. + * @param backup_clk_val Backup clock value, see TRM for definition + */ +inline void xt_wdt_ll_set_backup_clk_factor(rtc_cntl_dev_t *hw, uint32_t backup_clk_val) +{ + hw->xtal32k_clk_factor = backup_clk_val; +} + +/** + * @brief Enable the auto-backup clock feature + * + * @param hw Start address of the peripheral registers. + * @param enable True - enable, False - disable + */ +inline void xt_wdt_ll_auto_backup_enable(rtc_cntl_dev_t *hw, bool enable) +{ + hw->ext_xtl_conf.xtal32k_auto_backup = enable; +} + +/** + * @brief Enable the timeout interrupt + * + * @param hw Start address of the peripheral registers. + * @param enable True - enable, False - disable + */ +inline void xt_wdt_ll_intr_enable(rtc_cntl_dev_t *hw, bool enable) +{ + hw->int_ena.rtc_xtal32k_dead = enable; +} + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32c3/include/hal/include/hal/adc_hal.h b/tools/sdk/esp32c3/include/hal/include/hal/adc_hal.h index 1c1a399a4d3..807d620c639 100644 --- a/tools/sdk/esp32c3/include/hal/include/hal/adc_hal.h +++ b/tools/sdk/esp32c3/include/hal/include/hal/adc_hal.h @@ -114,6 +114,22 @@ void adc_hal_init(void); #define adc_hal_amp_disable() adc_ll_amp_disable() #endif +#if SOC_ADC_ARBITER_SUPPORTED +//No ADC2 controller arbiter on ESP32 +/** + * Config ADC2 module arbiter. + * The arbiter is to improve the use efficiency of ADC2. After the control right is robbed by the high priority, + * the low priority controller will read the invalid ADC2 data, and the validity of the data can be judged by the flag bit in the data. + * + * @note Only ADC2 support arbiter. + * @note The arbiter's working clock is APB_CLK. When the APB_CLK clock drops below 8 MHz, the arbiter must be in shield mode. + * @note Default priority: Wi-Fi > RTC > Digital; + * + * @param config Refer to ``adc_arbiter_t``. + */ +void adc_hal_arbiter_config(adc_arbiter_t *config); +#endif //#if SOC_ADC_ARBITER_SUPPORTED + /*--------------------------------------------------------------- PWDET(Power detect) controller setting ---------------------------------------------------------------*/ @@ -260,7 +276,7 @@ esp_err_t adc_hal_convert(adc_ll_num_t adc_n, int channel, int *out_raw); /*--------------------------------------------------------------- ADC calibration setting ---------------------------------------------------------------*/ -#if SOC_ADC_HW_CALIBRATION_V1 +#if SOC_ADC_CALIBRATION_V1_SUPPORTED // ESP32-S2, C3 and H2 support HW offset calibration. /** @@ -296,7 +312,7 @@ void adc_hal_set_calibration_param(adc_ll_num_t adc_n, uint32_t param); */ uint32_t adc_hal_self_calibration(adc_ll_num_t adc_n, adc_channel_t channel, adc_atten_t atten, bool internal_gnd); -#endif //SOC_ADC_HW_CALIBRATION_V1 +#endif //SOC_ADC_CALIBRATION_V1_SUPPORTED #if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32H2 /*--------------------------------------------------------------- diff --git a/tools/sdk/esp32c3/include/hal/include/hal/ds_hal.h b/tools/sdk/esp32c3/include/hal/include/hal/ds_hal.h index 253fab9f962..40d5c358936 100644 --- a/tools/sdk/esp32c3/include/hal/include/hal/ds_hal.h +++ b/tools/sdk/esp32c3/include/hal/include/hal/ds_hal.h @@ -21,7 +21,7 @@ #pragma once #if CONFIG_IDF_TARGET_ESP32 - #error "ESP32 doesn't have a DS peripheral" +#error "ESP32 doesn't have a DS peripheral" #endif #include diff --git a/tools/sdk/esp32c3/include/hal/include/hal/i2s_hal.h b/tools/sdk/esp32c3/include/hal/include/hal/i2s_hal.h index 6964bfdf947..a08813db808 100644 --- a/tools/sdk/esp32c3/include/hal/include/hal/i2s_hal.h +++ b/tools/sdk/esp32c3/include/hal/include/hal/i2s_hal.h @@ -1,4 +1,4 @@ -// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD +// Copyright 2020 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. @@ -25,13 +25,47 @@ #include "soc/i2s_periph.h" #include "soc/soc_caps.h" -#include "hal/i2s_ll.h" #include "hal/i2s_types.h" +#include "hal/i2s_ll.h" #ifdef __cplusplus extern "C" { #endif +/** + * @brief I2S clock configuration + */ +typedef struct { + uint32_t sclk; /*!< I2S module clock */ + uint32_t mclk; /*!< I2S master clock */ + uint32_t bclk; /*!< I2S bit clock */ + uint16_t mclk_div; /*!< I2S master clock division */ + uint16_t bclk_div; /*!< I2S bit clock division*/ +} i2s_hal_clock_cfg_t; + + +/** + * @brief I2S HAL configurations + */ +typedef struct { + i2s_mode_t mode; /*!< I2S work mode, using ored mask of `i2s_mode_t`*/ + uint32_t sample_rate; /*!< I2S sample rate*/ + i2s_comm_format_t comm_fmt; /*!< I2S communication format */ + i2s_channel_fmt_t chan_fmt; /*!< I2S channel format, there are total 16 channels in TDM mode.*/ + uint32_t sample_bits; /*!< I2S sample bits in one channel */ + uint32_t chan_bits; /*!< I2S total bits in one channel. Should not be smaller than 'sample_bits', default '0' means equal to 'sample_bits' */ + uint32_t active_chan; /*!< I2S active channel number */ + uint32_t total_chan; /*!< Total number of I2S channels */ + +#if SOC_I2S_SUPPORTS_TDM + uint32_t chan_mask; /*!< Active channel bit mask, set value in `i2s_channel_t` to enable specific channel, the bit map of active channel can not exceed (0x1<dev, status) +#define i2s_hal_enable_module_clock(hal) i2s_ll_enable_clock((hal)->dev); /** - * @brief Clear I2S interrupt status + * @brief Disable I2S module clock * * @param hal Context of the HAL layer - * @param mask interrupt status mask */ -#define i2s_hal_clear_intr_status(hal, mask) i2s_ll_clear_intr_status((hal)->dev, mask) +#define i2s_hal_disable_module_clock(hal) i2s_ll_disable_clock((hal)->dev); /** - * @brief Get I2S out eof des address + * @brief Reset I2S TX channel * * @param hal Context of the HAL layer - * @param addr out eof des address */ -#define i2s_hal_get_out_eof_des_addr(hal, addr) i2s_ll_get_out_eof_des_addr((hal)->dev, addr) +#define i2s_hal_reset_tx(hal) i2s_ll_tx_reset((hal)->dev) /** - * @brief Get I2S in eof des address + * @brief Reset I2S TX fifo * * @param hal Context of the HAL layer - * @param addr in eof des address */ -#define i2s_hal_get_in_eof_des_addr(hal, addr) i2s_ll_get_in_eof_des_addr((hal)->dev, addr) +#define i2s_hal_reset_tx_fifo(hal) i2s_ll_tx_reset_fifo((hal)->dev) /** - * @brief Enable I2S rx interrupt + * @brief Reset I2S RX channel * * @param hal Context of the HAL layer */ -#define i2s_hal_enable_rx_intr(hal) i2s_ll_enable_rx_intr((hal)->dev) +#define i2s_hal_reset_rx(hal) i2s_ll_rx_reset((hal)->dev) /** - * @brief Disable I2S rx interrupt + * @brief Reset I2S RX fifo * * @param hal Context of the HAL layer */ -#define i2s_hal_disable_rx_intr(hal) i2s_ll_disable_rx_intr((hal)->dev) +#define i2s_hal_reset_rx_fifo(hal) i2s_ll_rx_reset_fifo((hal)->dev) /** - * @brief Disable I2S tx interrupt + * @brief Get I2S hardware instance and enable I2S module clock + * @note This function should be called first before other hal layer function is called * * @param hal Context of the HAL layer + * @param i2s_num The uart port number, the max port number is (I2S_NUM_MAX -1) */ -#define i2s_hal_disable_tx_intr(hal) i2s_ll_disable_tx_intr((hal)->dev) +void i2s_hal_init(i2s_hal_context_t *hal, int i2s_num); /** - * @brief Enable I2S tx interrupt + * @brief Configure I2S source clock * * @param hal Context of the HAL layer + * @param sel The source clock index */ -#define i2s_hal_enable_tx_intr(hal) i2s_ll_enable_tx_intr((hal)->dev) +void i2s_hal_set_clock_src(i2s_hal_context_t *hal, i2s_clock_src_t sel); /** - * @brief Set I2S tx mode + * @brief Set Tx channel style * * @param hal Context of the HAL layer - * @param ch i2s channel - * @param bits bits per sample + * @param hal_cfg I2S hal configuration structer, refer to `i2s_hal_config_t` */ -void i2s_hal_set_tx_mode(i2s_hal_context_t *hal, i2s_channel_t ch, i2s_bits_per_sample_t bits); +void i2s_hal_tx_set_channel_style(i2s_hal_context_t *hal, const i2s_hal_config_t *hal_cfg); /** - * @brief Set I2S rx mode + * @brief Set Rx channel style * * @param hal Context of the HAL layer - * @param ch i2s channel - * @param bits bits per sample + * @param hal_cfg I2S hal configuration structer, refer to `i2s_hal_config_t` */ -void i2s_hal_set_rx_mode(i2s_hal_context_t *hal, i2s_channel_t ch, i2s_bits_per_sample_t bits); +void i2s_hal_rx_set_channel_style(i2s_hal_context_t *hal, const i2s_hal_config_t *hal_cfg); /** - * @brief Set I2S out link address + * @brief Initialize I2S hardware * * @param hal Context of the HAL layer - * @param addr out link address + * @param hal_cfg I2S hal configuration structer, refer to `i2s_hal_config_t` */ -#define i2s_hal_set_out_link_addr(hal, addr) i2s_ll_set_out_link_addr((hal)->dev, addr) +void i2s_hal_config_param(i2s_hal_context_t *hal, const i2s_hal_config_t *hal_cfg); /** - * @brief Set I2S out link address + * @brief Enable I2S master full-duplex mode * * @param hal Context of the HAL layer - * @param addr out link address */ -#define i2s_hal_set_out_link_addr(hal, addr) i2s_ll_set_out_link_addr((hal)->dev, addr) +void i2s_hal_enable_master_fd_mode(i2s_hal_context_t *hal); /** - * @brief Set I2S out link address + * @brief Enable I2S slave full-duplex mode * * @param hal Context of the HAL layer - * @param addr out link address */ -#define i2s_hal_set_out_link_addr(hal, addr) i2s_ll_set_out_link_addr((hal)->dev, addr) +void i2s_hal_enable_slave_fd_mode(i2s_hal_context_t *hal); /** - * @brief Set I2S in link + * @brief Start I2S tx * * @param hal Context of the HAL layer - * @param rx_eof_num in link eof num - * @param addr in link address */ -void i2s_hal_set_in_link(i2s_hal_context_t *hal, uint32_t rx_eof_num, uint32_t addr); +#define i2s_hal_start_tx(hal) i2s_ll_tx_start((hal)->dev) /** - * @brief Set I2S clk div + * @brief Start I2S rx * * @param hal Context of the HAL layer - * @param div_num i2s clkm div num - * @param div_a i2s clkm div a - * @param div_b i2s clkm div b - * @param tx_bck_div tx bck div num - * @param rx_bck_div rx bck div num */ -void i2s_hal_set_clk_div(i2s_hal_context_t *hal, int div_num, int div_a, int div_b, int tx_bck_div, int rx_bck_div); +#define i2s_hal_start_rx(hal) i2s_ll_rx_start((hal)->dev) /** - * @brief Set I2S clock sel + * @brief Stop I2S tx * * @param hal Context of the HAL layer - * @param sel clock sel */ -#define i2s_hal_set_clock_sel(hal, sel) i2s_ll_set_clk_sel((hal)->dev, sel) +#define i2s_hal_stop_tx(hal) i2s_ll_tx_stop((hal)->dev) /** - * @brief Set I2S tx bits mod + * @brief Stop I2S rx * * @param hal Context of the HAL layer - * @param bits bit width per sample. */ -void i2s_hal_set_tx_bits_mod(i2s_hal_context_t *hal, i2s_bits_per_sample_t bits); +#define i2s_hal_stop_rx(hal) i2s_ll_rx_stop((hal)->dev) /** - * @brief Set I2S rx bits mod + * @brief Set the received data length to trigger `in_suc_eof` interrupt. * * @param hal Context of the HAL layer - * @param bits bit width per sample. + * @param eof_byte The byte length that trigger in_suc_eof interrupt. */ -void i2s_hal_set_rx_bits_mod(i2s_hal_context_t *hal, i2s_bits_per_sample_t bits); +#define i2s_hal_set_rx_eof_num(hal, eof_byte) i2s_ll_rx_set_eof_num((hal)->dev, eof_byte) /** - * @brief Reset I2S TX & RX module, including DMA and FIFO + * @brief Set I2S TX sample bit * * @param hal Context of the HAL layer + * @param chan_bit I2S TX chan bit + * @param data_bit The sample data bit length. */ -void i2s_hal_reset(i2s_hal_context_t *hal); +#define i2s_hal_set_tx_sample_bit(hal, chan_bit, data_bit) i2s_ll_tx_set_sample_bit((hal)->dev, chan_bit, data_bit) /** - * @brief Start I2S tx + * @brief Set I2S RX sample bit * * @param hal Context of the HAL layer + * @param chan_bit I2S RX chan bit + * @param data_bit The sample data bit length. */ -void i2s_hal_start_tx(i2s_hal_context_t *hal); +#define i2s_hal_set_rx_sample_bit(hal, chan_bit, data_bit) i2s_ll_rx_set_sample_bit((hal)->dev, chan_bit, data_bit) /** - * @brief Start I2S rx + * @brief Configure I2S TX module clock devider * * @param hal Context of the HAL layer + * @param clk_cfg I2S clock configuration */ -void i2s_hal_start_rx(i2s_hal_context_t *hal); +void i2s_hal_tx_clock_config(i2s_hal_context_t *hal, i2s_hal_clock_cfg_t *clk_cfg); /** - * @brief Stop I2S tx + * @brief Configure I2S RX module clock devider * * @param hal Context of the HAL layer + * @param clk_cfg I2S clock configuration */ -void i2s_hal_stop_tx(i2s_hal_context_t *hal); +void i2s_hal_rx_clock_config(i2s_hal_context_t *hal, i2s_hal_clock_cfg_t *clk_cfg); /** - * @brief Stop I2S rx + * @brief Set I2S tx clock source * * @param hal Context of the HAL layer + * @param clk_src i2s tx clock source (see 'i2s_clock_src_t') */ -void i2s_hal_stop_rx(i2s_hal_context_t *hal); +#define i2s_hal_tx_set_clock_source(hal, clk_src) i2s_ll_tx_clk_set_src((hal)->dev, clk_src) /** - * @brief Config I2S param + * @brief Set I2S rx clock source * * @param hal Context of the HAL layer - * @param i2s_config I2S configurations - see i2s_config_t struct + * @param clk_src i2s rx clock source (see 'i2s_clock_src_t') */ -void i2s_hal_config_param(i2s_hal_context_t *hal, const i2s_config_t *i2s_config); +#define i2s_hal_rx_set_clock_source(hal, clk_src) i2s_ll_rx_clk_set_src((hal)->dev, clk_src) /** - * @brief Enable I2S sig loopback + * @brief Enable I2S tx slave mode * * @param hal Context of the HAL layer + * @param enable set 'true' to enable tx slave mode */ -#define i2s_hal_enable_sig_loopback(hal) i2s_ll_set_sig_loopback((hal)->dev, 1) +#define i2s_hal_tx_enable_slave_mode(hal, enable) i2s_ll_tx_set_slave_mod((hal)->dev, enable) /** - * @brief Enable I2S master mode + * @brief Enable I2S rx slave mode * * @param hal Context of the HAL layer + * @param enable set 'true' to enable rx slave mode */ -void i2s_hal_enable_master_mode(i2s_hal_context_t *hal); +#define i2s_hal_rx_enable_slave_mode(hal, enable) i2s_ll_rx_set_slave_mod((hal)->dev, enable) /** - * @brief Enable I2S slave mode + * @brief Enable loopback mode * * @param hal Context of the HAL layer */ -void i2s_hal_enable_slave_mode(i2s_hal_context_t *hal); +#define i2s_hal_enable_sig_loopback(hal) i2s_ll_share_bck_ws((hal)->dev, true) /** - * @brief Init the I2S hal and set the I2S to the default configuration. This function should be called first before other hal layer function is called + * @brief Set I2S configuration for common TX mode + * @note Common mode is for non-PDM mode like philip/MSB/PCM * * @param hal Context of the HAL layer - * @param i2s_num The uart port number, the max port number is (I2S_NUM_MAX -1) + * @param hal_cfg hal configuration structure */ -void i2s_hal_init(i2s_hal_context_t *hal, int i2s_num); +void i2s_hal_tx_set_common_mode(i2s_hal_context_t *hal, const i2s_hal_config_t *hal_cfg); + +/** + * @brief Set I2S configuration for common RX mode + * @note Common mode is for non-PDM mode like philip/MSB/PCM + * + * @param hal Context of the HAL layer + * @param hal_cfg hal configuration structure + */ +void i2s_hal_rx_set_common_mode(i2s_hal_context_t *hal, const i2s_hal_config_t *hal_cfg); + +#if SOC_I2S_SUPPORTS_PCM +/** + * @brief Configure I2S TX PCM encoder or decoder. + * + * @param hal Context of the HAL layer + * @param cfg PCM configure paramater, refer to `i2s_pcm_compress_t` + */ +#define i2s_hal_tx_pcm_cfg(hal, cfg) i2s_ll_tx_set_pcm_type((hal)->dev, cfg) + +/** + * @brief Configure I2S RX PCM encoder or decoder. + * + * @param hal Context of the HAL layer + * @param cfg PCM configure paramater, refer to `i2s_pcm_compress_t` + */ +#define i2s_hal_rx_pcm_cfg(hal, cfg) i2s_ll_rx_set_pcm_type((hal)->dev, cfg) +#endif + +#if SOC_I2S_SUPPORTS_PDM_TX +/** + * @brief Configure I2S TX PDM sample rate + * Fpdm = 64*Fpcm*fp/fs + * + * @param hal Context of the HAL layer + * @param fp TX PDM fp paramater configuration + * @param fs TX PDM fs paramater configuration + */ +#define i2s_hal_set_tx_pdm_fpfs(hal, fp, fs) i2s_ll_tx_set_pdm_fpfs((hal)->dev, fp, fs) + +/** + * @brief Get I2S TX PDM fp + * + * @param hal Context of the HAL layer + * @return + * - fp configuration paramater + */ +#define i2s_hal_get_tx_pdm_fp(hal) i2s_ll_tx_get_pdm_fp((hal)->dev) + +/** + * @brief Get I2S TX PDM fs + * + * @param hal Context of the HAL layer + * @return + * - fs configuration paramater + */ +#define i2s_hal_get_tx_pdm_fs(hal) i2s_ll_tx_get_pdm_fs((hal)->dev) + +/** + * @brief Set I2S default configuration for PDM TX mode + * + * @param hal Context of the HAL layer + * @param sample_rate PDM sample rate + */ +void i2s_hal_tx_set_pdm_mode_default(i2s_hal_context_t *hal, uint32_t sample_rate); +#endif + +#if SOC_I2S_SUPPORTS_PDM_RX + +/** + * @brief Configure RX PDM downsample + * + * @param hal Context of the HAL layer + * @param dsr PDM downsample configuration paramater + */ +#define i2s_hal_set_rx_pdm_dsr(hal, dsr) i2s_ll_rx_set_pdm_dsr((hal)->dev, dsr) + +/** + * @brief Get RX PDM downsample configuration + * + * @param hal Context of the HAL layer + * @param dsr Pointer to accept PDM downsample configuration + */ +#define i2s_hal_get_rx_pdm_dsr(hal, dsr) i2s_ll_rx_get_pdm_dsr((hal)->dev, dsr) + +/** + * @brief Set I2S default configuration for PDM R mode + * + * @param hal Context of the HAL layer + */ +void i2s_hal_rx_set_pdm_mode_default(i2s_hal_context_t *hal); +#endif -#if SOC_I2S_SUPPORTS_PDM +#if !SOC_GDMA_SUPPORTED /** - * @brief Set I2S tx pdm + * @brief Enable I2S TX DMA * * @param hal Context of the HAL layer - * @param fp tx pdm fp - * @param fs tx pdm fs */ -void i2s_hal_tx_pdm_cfg(i2s_hal_context_t *hal, uint32_t fp, uint32_t fs); +#define i2s_hal_enable_tx_dma(hal) i2s_ll_enable_dma((hal)->dev,true) /** - * @brief Get I2S tx pdm + * @brief Enable I2S RX DMA * * @param hal Context of the HAL layer - * @param dsr rx pdm dsr */ -void i2s_hal_rx_pdm_cfg(i2s_hal_context_t *hal, uint32_t dsr); +#define i2s_hal_enable_rx_dma(hal) i2s_ll_enable_dma((hal)->dev,true) /** - * @brief Get I2S tx pdm configuration + * @brief Disable I2S TX DMA * * @param hal Context of the HAL layer - * @param fp Pointer to receive tx PDM fp configuration - * @param fs Pointer to receive tx PDM fs configuration */ -void i2s_hal_get_tx_pdm(i2s_hal_context_t *hal, uint32_t *fp, uint32_t *fs); +#define i2s_hal_disable_tx_dma(hal) i2s_ll_enable_dma((hal)->dev,false) + +/** + * @brief Disable I2S RX DMA + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_disable_rx_dma(hal) i2s_ll_enable_dma((hal)->dev,false) + +/** + * @brief Get I2S interrupt status + * + * @param hal Context of the HAL layer + * @return + * - module interrupt status + */ +#define i2s_hal_get_intr_status(hal) i2s_ll_get_intr_status((hal)->dev) + +/** + * @brief Get I2S interrupt status + * + * @param hal Context of the HAL layer + * @param mask Interrupt mask to be cleared. + */ +#define i2s_hal_clear_intr_status(hal, mask) i2s_ll_clear_intr_status((hal)->dev, mask) + +/** + * @brief Enable I2S RX interrupt + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_enable_rx_intr(hal) i2s_ll_rx_enable_intr((hal)->dev) + +/** + * @brief Disable I2S RX interrupt + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_disable_rx_intr(hal) i2s_ll_rx_disable_intr((hal)->dev) + +/** + * @brief Disable I2S TX interrupt + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_disable_tx_intr(hal) i2s_ll_tx_disable_intr((hal)->dev) + +/** + * @brief Enable I2S TX interrupt + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_enable_tx_intr(hal) i2s_ll_tx_enable_intr((hal)->dev) + +/** + * @brief Configure TX DMA descriptor address and start TX DMA + * + * @param hal Context of the HAL layer + * @param link_addr DMA descriptor link address. + */ +#define i2s_hal_start_tx_link(hal, link_addr) i2s_ll_tx_start_link((hal)->dev, link_addr) + +/** + * @brief Configure RX DMA descriptor address and start RX DMA + * + * @param hal Context of the HAL layer + * @param link_addr DMA descriptor link address. + */ +#define i2s_hal_start_rx_link(hal, link_addr) i2s_ll_rx_start_link((hal)->dev, link_addr) + +/** + * @brief Stop TX DMA link + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_stop_tx_link(hal) i2s_ll_tx_stop_link((hal)->dev) + +/** + * @brief Stop RX DMA link + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_stop_rx_link(hal) i2s_ll_rx_stop_link((hal)->dev) + +/** + * @brief Reset RX DMA + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_reset_rxdma(hal) i2s_ll_rx_reset_dma((hal)->dev) + +/** + * @brief Reset TX DMA + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_reset_txdma(hal) i2s_ll_tx_reset_dma((hal)->dev) + +/** + * @brief Get I2S out eof descriptor address + * + * @param hal Context of the HAL layer + * @param addr Pointer to accept out eof des address + */ +#define i2s_hal_get_out_eof_des_addr(hal, addr) i2s_ll_tx_get_eof_des_addr((hal)->dev, addr) + +/** + * @brief Get I2S in suc eof descriptor address + * + * @param hal Context of the HAL layer + * @param addr Pointer to accept in suc eof des address + */ +#define i2s_hal_get_in_eof_des_addr(hal, addr) i2s_ll_rx_get_eof_des_addr((hal)->dev, addr) +#endif + +#if SOC_I2S_SUPPORTS_ADC +/** + * @brief Enable Builtin DAC + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_enable_builtin_dac(hal) i2s_ll_enable_builtin_dac((hal)->dev, true); + +/** + * @brief Enable Builtin ADC + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_enable_builtin_adc(hal) i2s_ll_enable_builtin_adc((hal)->dev, true); + +/** + * @brief Disable Builtin ADC + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_disable_builtin_adc(hal) i2s_ll_enable_builtin_adc((hal)->dev, false); +#endif +#if SOC_I2S_SUPPORTS_DAC /** - * @brief Get I2S rx pdm configuration + * @brief Disable Builtin DAC * * @param hal Context of the HAL layer - * @param dsr rx pdm dsr */ -void i2s_hal_get_rx_pdm(i2s_hal_context_t *hal, uint32_t *dsr); +#define i2s_hal_disable_builtin_dac(hal) i2s_ll_enable_builtin_dac((hal)->dev, false); #endif #ifdef __cplusplus diff --git a/tools/sdk/esp32c3/include/hal/include/hal/i2s_types.h b/tools/sdk/esp32c3/include/hal/include/hal/i2s_types.h index ba150cc7b34..48d745eb2fa 100644 --- a/tools/sdk/esp32c3/include/hal/include/hal/i2s_types.h +++ b/tools/sdk/esp32c3/include/hal/include/hal/i2s_types.h @@ -1,4 +1,4 @@ -// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD +// Copyright 2020 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. @@ -16,6 +16,7 @@ #include #include +#include #include #include "soc/soc_caps.h" @@ -24,34 +25,59 @@ extern "C" { #endif /** - * @brief I2S port number, the max port number is (I2S_NUM_MAX -1). + * @brief I2S bit width per sample. + * */ typedef enum { - I2S_NUM_0 = 0, /*!< I2S port 0 */ -#if SOC_I2S_NUM > 1 - I2S_NUM_1 = 1, /*!< I2S port 1 */ -#endif - I2S_NUM_MAX, /*!< I2S port max */ -} i2s_port_t; + I2S_BITS_PER_SAMPLE_8BIT = 8, /*!< data bit-width: 8 */ + I2S_BITS_PER_SAMPLE_16BIT = 16, /*!< data bit-width: 16 */ + I2S_BITS_PER_SAMPLE_24BIT = 24, /*!< data bit-width: 24 */ + I2S_BITS_PER_SAMPLE_32BIT = 32, /*!< data bit-width: 32 */ +} i2s_bits_per_sample_t; /** - * @brief I2S bit width per sample. + * @brief I2S bit width per chan. * */ typedef enum { - I2S_BITS_PER_SAMPLE_8BIT = 8, /*!< I2S bits per sample: 8-bits*/ - I2S_BITS_PER_SAMPLE_16BIT = 16, /*!< I2S bits per sample: 16-bits*/ - I2S_BITS_PER_SAMPLE_24BIT = 24, /*!< I2S bits per sample: 24-bits*/ - I2S_BITS_PER_SAMPLE_32BIT = 32, /*!< I2S bits per sample: 32-bits*/ -} i2s_bits_per_sample_t; + I2S_BITS_PER_CHAN_DEFAULT = (0), /*!< channel bit-width equals to data bit-width */ + I2S_BITS_PER_CHAN_8BIT = (8), /*!< channel bit-width: 8 */ + I2S_BITS_PER_CHAN_16BIT = (16), /*!< channel bit-width: 16 */ + I2S_BITS_PER_CHAN_24BIT = (24), /*!< channel bit-width: 24 */ + I2S_BITS_PER_CHAN_32BIT = (32), /*!< channel bit-width: 32 */ +} i2s_bits_per_chan_t; /** * @brief I2S channel. * */ typedef enum { - I2S_CHANNEL_MONO = 1, /*!< I2S 1 channel (mono)*/ - I2S_CHANNEL_STEREO = 2 /*!< I2S 2 channel (stereo)*/ + I2S_CHANNEL_MONO = (0x01 << 31) | 0x03, /*!< I2S channel (mono), two channel enabled. In this mode, you only need to send one channel data but the fifo will copy same data for another channel automatically, then both channels will transmit same data. The highest bit is for differentiating I2S_CHANNEL_STEREO since they both use two channels */ + I2S_CHANNEL_STEREO = 0x03, /*!< I2S channel (stereo), two channel enabled. In this mode, two channels will transmit different data. */ +#if SOC_I2S_SUPPORTS_TDM + // Bit map of active chan. + // There are 16 channels in TDM mode. + // For TX module, only the active channel send the audio data, the inactive channel send a constant(configurable) or will be skiped if 'skip_msk' is set. + // For RX module, only receive the audio data in active channels, the data in inactive channels will be ignored. + // the bit map of active channel can not exceed (0x1< 0, then the clock output for i2s is fixed and equal to the fixed_mclk value.*/ -} i2s_config_t; - -/** - * @brief I2S event types - * + * @brief The multiple of mclk to sample rate */ typedef enum { - I2S_EVENT_DMA_ERROR, - I2S_EVENT_TX_DONE, /*!< I2S DMA finish sent 1 buffer*/ - I2S_EVENT_RX_DONE, /*!< I2S DMA finish received 1 buffer*/ - I2S_EVENT_MAX, /*!< I2S event max index*/ -} i2s_event_type_t; + I2S_MCLK_MULTIPLE_DEFAULT = 0, /*!< Default value. mclk = sample_rate * 256 */ + I2S_MCLK_MULTIPLE_128 = 128, /*!< mclk = sample_rate * 128 */ + I2S_MCLK_MULTIPLE_256 = 256, /*!< mclk = sample_rate * 256 */ + I2S_MCLK_MULTIPLE_384 = 384, /*!< mclk = sample_rate * 384 */ +} i2s_mclk_multiple_t; -#if SOC_I2S_SUPPORTS_ADC_DAC +#if SOC_I2S_SUPPORTS_DAC /** * @brief I2S DAC mode for i2s_set_dac_mode. * - * @note PDM and built-in DAC functions are only supported on I2S0 for current ESP32 chip. + * @note Built-in DAC functions are only supported on I2S0 for current ESP32 chip. */ typedef enum { I2S_DAC_CHANNEL_DISABLE = 0, /*!< Disable I2S built-in DAC signals*/ @@ -157,29 +167,23 @@ typedef enum { I2S_DAC_CHANNEL_BOTH_EN = 0x3, /*!< Enable both of the I2S built-in DAC channels.*/ I2S_DAC_CHANNEL_MAX = 0x4, /*!< I2S built-in DAC mode max index*/ } i2s_dac_mode_t; -#endif //SOC_I2S_SUPPORTS_ADC_DAC +#endif //SOC_I2S_SUPPORTS_DAC +#if SOC_I2S_SUPPORTS_PCM /** - * @brief Event structure used in I2S event queue + * @brief A/U-law decompress or compress configuration. * */ -typedef struct { - i2s_event_type_t type; /*!< I2S event type */ - size_t size; /*!< I2S data size for I2S_DATA event*/ -} i2s_event_t; +typedef enum { + I2S_PCM_DISABLE = 0, /*!< Disable A/U law decopress or compress*/ + I2S_PCM_A_DECOMPRESS, /*!< A-law decompress*/ + I2S_PCM_A_COMPRESS, /*!< A-law compress*/ + I2S_PCM_U_DECOMPRESS, /*!< U-law decompress*/ + I2S_PCM_U_COMPRESS, /*!< U-law compress*/ +} i2s_pcm_compress_t; +#endif -/** - * @brief I2S pin number for i2s_set_pin - * - */ -typedef struct { - int bck_io_num; /*!< BCK in out pin*/ - int ws_io_num; /*!< WS in out pin*/ - int data_out_num; /*!< DATA out pin*/ - int data_in_num; /*!< DATA in pin*/ -} i2s_pin_config_t; - -#if SOC_I2S_SUPPORTS_PDM +#if SOC_I2S_SUPPORTS_PDM_RX /** * @brief I2S PDM RX downsample mode */ @@ -188,18 +192,17 @@ typedef enum { I2S_PDM_DSR_16S, /*!< downsampling number is 16 for PDM RX mode*/ I2S_PDM_DSR_MAX, } i2s_pdm_dsr_t; +#endif -/** - * @brief PDM PCM convter enable/disable. - * - */ +#if SOC_I2S_SUPPORTS_PDM_TX typedef enum { - PDM_PCM_CONV_ENABLE, /*!< Enable PDM PCM convert*/ - PDM_PCM_CONV_DISABLE, /*!< Disable PDM PCM convert*/ -} pdm_pcm_conv_t; + I2S_PDM_SIG_SCALING_DIV_2 = 0, /*!< I2S TX PDM sigmadelta signal scaling: /2 */ + I2S_PDM_SIG_SCALING_MUL_1 = 1, /*!< I2S TX PDM sigmadelta signal scaling: x1 */ + I2S_PDM_SIG_SCALING_MUL_2 = 2, /*!< I2S TX PDM sigmadelta signal scaling: x2 */ + I2S_PDM_SIG_SCALING_MUL_4 = 3, /*!< I2S TX PDM sigmadelta signal scaling: x4 */ +} i2s_pdm_sig_scale_t; #endif - #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32c3/include/hal/include/hal/lcd_hal.h b/tools/sdk/esp32c3/include/hal/include/hal/lcd_hal.h index a6bcba166c6..76e28dda0e4 100644 --- a/tools/sdk/esp32c3/include/hal/include/hal/lcd_hal.h +++ b/tools/sdk/esp32c3/include/hal/include/hal/lcd_hal.h @@ -24,10 +24,10 @@ extern "C" { #endif -#include "soc/lcd_cam_struct.h" +typedef struct lcd_cam_dev_t *lcd_soc_handle_t; typedef struct { - lcd_cam_dev_t *dev; + lcd_soc_handle_t dev; } lcd_hal_context_t; void lcd_hal_init(lcd_hal_context_t *hal, int id); diff --git a/tools/sdk/esp32c3/include/hal/include/hal/lcd_types.h b/tools/sdk/esp32c3/include/hal/include/hal/lcd_types.h new file mode 100644 index 00000000000..69dab14801d --- /dev/null +++ b/tools/sdk/esp32c3/include/hal/include/hal/lcd_types.h @@ -0,0 +1,42 @@ +// Copyright 2021 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 + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief LCD clock source + * @note User should select the clock source based on the real requirement: + * ╔═════════════════════╦══════════════════════════╦════════════════════════════╗ + * ║ LCD clock source ║ Features ║ Power Management ║ + * ╠═════════════════════╬══════════════════════════╬════════════════════════════╣ + * ║ LCD_CLK_SRC_PLL160M ║ High resolution, fixed ║ ESP_PM_APB_FREQ_MAX lock ║ + * ╠═════════════════════╬══════════════════════════╬════════════════════════════╣ + * ║ LCD_CLK_SRC_APLL ║ Configurable resolution ║ ESP_PM_NO_LIGHT_SLEEP lock ║ + * ╠═════════════════════╬══════════════════════════╬════════════════════════════╣ + * ║ LCD_CLK_SRC_XTAL ║ Medium resolution, fixed ║ No PM lock ║ + * ╚═════════════════════╩══════════════════════════╩════════════════════════════╝ + */ +typedef enum { + LCD_CLK_SRC_PLL160M, /*!< Select PLL160M as the source clock */ + LCD_CLK_SRC_APLL, /*!< Select APLL as the source clock */ + LCD_CLK_SRC_XTAL, /*!< Select XTAL as the source clock */ +} lcd_clock_source_t; + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32c3/include/hal/include/hal/mcpwm_types.h b/tools/sdk/esp32c3/include/hal/include/hal/mcpwm_types.h index 77f9c80c12b..b9c37315bc4 100644 --- a/tools/sdk/esp32c3/include/hal/include/hal/mcpwm_types.h +++ b/tools/sdk/esp32c3/include/hal/include/hal/mcpwm_types.h @@ -37,7 +37,7 @@ typedef enum { MCPWM_TIMER_START_NO_STOP, /*!< MCPWM timer starts couting */ MCPWM_TIMER_START_STOP_AT_ZERO, /*!< MCPWM timer starts counting and stops when couting to zero */ MCPWM_TIMER_START_STOP_AT_PEAK, /*!< MCPWM timer starts counting and stops when counting to peak */ -} mcpwm_timer_operate_cmd_t; +} mcpwm_timer_execute_cmd_t; typedef enum { MCPWM_GEN_ACTION_KEEP, /*!< Generator action: Keep the same level */ @@ -47,6 +47,6 @@ typedef enum { } mcpwm_generator_action_t; typedef enum { - MCPWM_FAULT_REACTION_CBC, /*!< Reaction on fault signal: recover cycle by cycle */ - MCPWM_FAULT_REACTION_OST, /*!< Reaction on fault signal: one shot trip */ -} mcpwm_fault_reaction_t; + MCPWM_TRIP_TYPE_CBC, /*!< CBC trip type, shut down the operator cycle by cycle*/ + MCPWM_TRIP_TYPE_OST, /*!< OST trip type, shut down the operator in one shot */ +} mcpwm_trip_type_t; diff --git a/tools/sdk/esp32c3/include/hal/include/hal/memprot_types.h b/tools/sdk/esp32c3/include/hal/include/hal/memprot_types.h new file mode 100644 index 00000000000..42231f43eaf --- /dev/null +++ b/tools/sdk/esp32c3/include/hal/include/hal/memprot_types.h @@ -0,0 +1,35 @@ +// Copyright 2015-2021 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 + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Memprot LL error codes + * + */ +typedef enum { + MEMP_LL_OK = 0, + MEMP_LL_FAIL = 1, + MEMP_LL_ERR_SPLIT_ADDR_INVALID = 2, + MEMP_LL_ERR_SPLIT_ADDR_UNALIGNED = 3, + MEMP_LL_ERR_UNI_BLOCK_INVALID = 4 +} memprot_ll_err_t; + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32c3/include/hal/include/hal/pcnt_hal.h b/tools/sdk/esp32c3/include/hal/include/hal/pcnt_hal.h index 8d2253e46e3..3d10c8d8c68 100644 --- a/tools/sdk/esp32c3/include/hal/include/hal/pcnt_hal.h +++ b/tools/sdk/esp32c3/include/hal/include/hal/pcnt_hal.h @@ -23,10 +23,7 @@ #pragma once -#include -#include "soc/pcnt_periph.h" -#include "hal/pcnt_types.h" -#include "hal/pcnt_ll.h" +#include "soc/pcnt_struct.h" #ifdef __cplusplus extern "C" { @@ -35,188 +32,18 @@ extern "C" { /** * Context that should be maintained by both the driver and the HAL */ - typedef struct { - pcnt_dev_t *dev; + pcnt_dev_t *dev; /*!< PCNT peripheral register base address */ } pcnt_hal_context_t; /** - * @brief Set PCNT counter mode - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - * @param channel PCNT channel number - * @param pos_mode Counter mode when detecting positive edge - * @param neg_mode Counter mode when detecting negative edge - * @param hctrl_mode Counter mode when control signal is high level - * @param lctrl_mode Counter mode when control signal is low level - */ -#define pcnt_hal_set_mode(hal, unit, channel, pos_mode, neg_mode, hctrl_mode, lctrl_mode) pcnt_ll_set_mode((hal)->dev, unit, channel, pos_mode, neg_mode, hctrl_mode, lctrl_mode) - -/** - * @brief Get pulse counter value - * - * @param hal Context of the HAL layer - * @param unit Pulse Counter unit number - * @param count Pointer to accept counter value - */ -#define pcnt_hal_get_counter_value(hal, unit, count) pcnt_ll_get_counter_value((hal)->dev, unit, count) - -/** - * @brief Pause PCNT counter of PCNT unit - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - */ -#define pcnt_hal_counter_pause(hal, unit) pcnt_ll_counter_pause((hal)->dev, unit) - -/** - * @brief Resume counting for PCNT counter - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number, select from unit_t - */ -#define pcnt_hal_counter_resume(hal, unit) pcnt_ll_counter_resume((hal)->dev, unit) - -/** - * @brief Clear and reset PCNT counter value to zero - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number, select from unit_t - */ -#define pcnt_hal_counter_clear(hal, unit) pcnt_ll_counter_clear((hal)->dev, unit) - -/** - * @brief Enable PCNT interrupt for PCNT unit - * @note - * Each Pulse counter unit has five watch point events that share the same interrupt. - * Configure events with pcnt_event_enable() and pcnt_event_disable() - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - */ -#define pcnt_hal_intr_enable(hal, unit) pcnt_ll_intr_enable((hal)->dev, unit) - -/** - * @brief Disable PCNT interrupt for PCNT unit - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - */ -#define pcnt_hal_intr_disable(hal, unit) pcnt_ll_intr_disable((hal)->dev, unit) - -/** - * @brief Get PCNT interrupt status - * - * @param hal Context of the HAL layer - * @param mask The interrupt status mask to be cleared. Pointer to accept value interrupt status mask. - */ -#define pcnt_hal_get_intr_status(hal, mask) pcnt_ll_get_intr_status((hal)->dev, mask) - -/** - * @brief Clear PCNT interrupt status - * - * @param hal Context of the HAL layer - * @param mask The interrupt status mask to be cleared. - */ -#define pcnt_hal_clear_intr_status(hal, mask) pcnt_ll_clear_intr_status((hal)->dev, mask) - -/** - * @brief Enable PCNT event of PCNT unit - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - * @param evt_type Watch point event type. - * All enabled events share the same interrupt (one interrupt per pulse counter unit). - */ -#define pcnt_hal_event_enable(hal, unit, evt_type) pcnt_ll_event_enable((hal)->dev, unit, evt_type) - -/** - * @brief Disable PCNT event of PCNT unit - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - * @param evt_type Watch point event type. - * All enabled events share the same interrupt (one interrupt per pulse counter unit). - */ -#define pcnt_hal_event_disable(hal, unit, evt_type) pcnt_ll_event_disable((hal)->dev, unit, evt_type) - -/** - * @brief Set PCNT event value of PCNT unit - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - * @param evt_type Watch point event type. - * All enabled events share the same interrupt (one interrupt per pulse counter unit). - * - * @param value Counter value for PCNT event - */ -#define pcnt_hal_set_event_value(hal, unit, evt_type, value) pcnt_ll_set_event_value((hal)->dev, unit, evt_type, value) - -/** - * @brief Get PCNT event value of PCNT unit - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - * @param evt_type Watch point event type. - * All enabled events share the same interrupt (one interrupt per pulse counter unit). - * @param value Pointer to accept counter value for PCNT event - */ -#define pcnt_hal_get_event_value(hal, unit, evt_type, value) pcnt_ll_get_event_value((hal)->dev, unit, evt_type, value) - -/** - * @brief Get PCNT event status - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - * @return event status word - */ -#define pcnt_hal_get_event_status(hal, unit) pcnt_ll_get_event_status((hal)->dev, unit) - -/** - * @brief Set PCNT filter value - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - * @param filter_val PCNT signal filter value, counter in APB_CLK cycles. - * Any pulses lasting shorter than this will be ignored when the filter is enabled. - * @note - * filter_val is a 10-bit value, so the maximum filter_val should be limited to 1023. - */ -#define pcnt_hal_set_filter_value(hal, unit, filter_val) pcnt_ll_set_filter_value((hal)->dev, unit, filter_val) - -/** - * @brief Get PCNT filter value - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - * @param filter_val Pointer to accept PCNT filter value. - */ -#define pcnt_hal_get_filter_value(hal, unit, filter_val) pcnt_ll_get_filter_value((hal)->dev, unit, filter_val) - -/** - * @brief Enable PCNT input filter - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - */ -#define pcnt_hal_filter_enable(hal, unit) pcnt_ll_filter_enable((hal)->dev, unit) - -/** - * @brief Disable PCNT input filter - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - */ -#define pcnt_hal_filter_disable(hal, unit) pcnt_ll_filter_disable((hal)->dev, unit) - -/** - * @brief Init the PCNT hal and set the PCNT to the default configuration. This function should be called first before other hal layer function is called + * @brief Init the PCNT hal and set the PCNT to the default configuration. + * @note This function should be called first before other hal layer function is called. * * @param hal Context of the HAL layer - * @param pcnt_num The uart port number, the max port number is (PCNT_NUM_MAX -1) + * @param group_id PCNT group ID */ -void pcnt_hal_init(pcnt_hal_context_t *hal, int pcnt_num); +void pcnt_hal_init(pcnt_hal_context_t *hal, int group_id); #ifdef __cplusplus } diff --git a/tools/sdk/esp32c3/include/hal/include/hal/pcnt_types.h b/tools/sdk/esp32c3/include/hal/include/hal/pcnt_types.h index 6f09177b53a..0696e756cc9 100644 --- a/tools/sdk/esp32c3/include/hal/include/hal/pcnt_types.h +++ b/tools/sdk/esp32c3/include/hal/include/hal/pcnt_types.h @@ -1,4 +1,4 @@ -// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD +// Copyright 2015-2021 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. @@ -18,93 +18,36 @@ extern "C" { #endif -#include "soc/soc_caps.h" - -#define PCNT_PIN_NOT_USED (-1) /*!< When selected for a pin, this pin will not be used */ - -/** - * @brief PCNT port number, the max port number is (PCNT_PORT_MAX - 1). - */ -typedef enum { - PCNT_PORT_0 = 0, /*!< PCNT port 0 */ - PCNT_PORT_MAX, /*!< PCNT port max */ -} pcnt_port_t; - -/** - * @brief Selection of all available PCNT units - */ -typedef enum { - PCNT_UNIT_0 = 0, /*!< PCNT unit 0 */ - PCNT_UNIT_1 = 1, /*!< PCNT unit 1 */ - PCNT_UNIT_2 = 2, /*!< PCNT unit 2 */ - PCNT_UNIT_3 = 3, /*!< PCNT unit 3 */ -#if SOC_PCNT_UNIT_NUM > 4 - PCNT_UNIT_4 = 4, /*!< PCNT unit 4 */ - PCNT_UNIT_5 = 5, /*!< PCNT unit 5 */ - PCNT_UNIT_6 = 6, /*!< PCNT unit 6 */ - PCNT_UNIT_7 = 7, /*!< PCNT unit 7 */ -#endif - PCNT_UNIT_MAX, -} pcnt_unit_t; - /** - * @brief Selection of available modes that determine the counter's action depending on the state of the control signal's input GPIO - * @note Configuration covers two actions, one for high, and one for low level on the control input + * @brief PCNT channel action on control level + * */ typedef enum { - PCNT_MODE_KEEP = 0, /*!< Control mode: won't change counter mode*/ - PCNT_MODE_REVERSE = 1, /*!< Control mode: invert counter mode(increase -> decrease, decrease -> increase) */ - PCNT_MODE_DISABLE = 2, /*!< Control mode: Inhibit counter(counter value will not change in this condition) */ - PCNT_MODE_MAX -} pcnt_ctrl_mode_t; + PCNT_CHANNEL_LEVEL_ACTION_KEEP, /*!< Keep current count mode */ + PCNT_CHANNEL_LEVEL_ACTION_INVERSE, /*!< Invert current count mode (increase -> decrease, decrease -> increase) */ + PCNT_CHANNEL_LEVEL_ACTION_HOLD, /*!< Hold current count value */ +} pcnt_channel_level_action_t; /** - * @brief Selection of available modes that determine the counter's action on the edge of the pulse signal's input GPIO - * @note Configuration covers two actions, one for positive, and one for negative edge on the pulse input + * @brief PCNT channel action on signal edge + * */ typedef enum { - PCNT_COUNT_DIS = 0, /*!< Counter mode: Inhibit counter(counter value will not change in this condition) */ - PCNT_COUNT_INC = 1, /*!< Counter mode: Increase counter value */ - PCNT_COUNT_DEC = 2, /*!< Counter mode: Decrease counter value */ - PCNT_COUNT_MAX -} pcnt_count_mode_t; + PCNT_CHANNEL_EDGE_ACTION_HOLD, /*!< Hold current count value */ + PCNT_CHANNEL_EDGE_ACTION_INCREASE, /*!< Increase count value */ + PCNT_CHANNEL_EDGE_ACTION_DECREASE, /*!< Decrease count value */ +} pcnt_channel_edge_action_t; /** - * @brief Selection of channels available for a single PCNT unit + * @brief PCNT unit counter value's sign + * */ typedef enum { - PCNT_CHANNEL_0 = 0x00, /*!< PCNT channel 0 */ - PCNT_CHANNEL_1 = 0x01, /*!< PCNT channel 1 */ - PCNT_CHANNEL_MAX, -} pcnt_channel_t; - -/** - * @brief Selection of counter's events the may trigger an interrupt - */ -typedef enum { - PCNT_EVT_THRES_1 = BIT(2), /*!< PCNT watch point event: threshold1 value event */ - PCNT_EVT_THRES_0 = BIT(3), /*!< PCNT watch point event: threshold0 value event */ - PCNT_EVT_L_LIM = BIT(4), /*!< PCNT watch point event: Minimum counter value */ - PCNT_EVT_H_LIM = BIT(5), /*!< PCNT watch point event: Maximum counter value */ - PCNT_EVT_ZERO = BIT(6), /*!< PCNT watch point event: counter value zero event */ - PCNT_EVT_MAX -} pcnt_evt_type_t; - -/** - * @brief Pulse Counter configuration for a single channel - */ -typedef struct { - int pulse_gpio_num; /*!< Pulse input GPIO number, if you want to use GPIO16, enter pulse_gpio_num = 16, a negative value will be ignored */ - int ctrl_gpio_num; /*!< Control signal input GPIO number, a negative value will be ignored */ - pcnt_ctrl_mode_t lctrl_mode; /*!< PCNT low control mode */ - pcnt_ctrl_mode_t hctrl_mode; /*!< PCNT high control mode */ - pcnt_count_mode_t pos_mode; /*!< PCNT positive edge count mode */ - pcnt_count_mode_t neg_mode; /*!< PCNT negative edge count mode */ - int16_t counter_h_lim; /*!< Maximum counter value */ - int16_t counter_l_lim; /*!< Minimum counter value */ - pcnt_unit_t unit; /*!< PCNT unit number */ - pcnt_channel_t channel; /*!< the PCNT channel */ -} pcnt_config_t; + PCNT_UNIT_COUNT_SIGN_ZERO_POS, /*!< positive value to zero */ + PCNT_UNIT_COUNT_SIGN_ZERO_NEG, /*!< negative value to zero */ + PCNT_UNIT_COUNT_SIGN_NEG, /*!< counter value negative */ + PCNT_UNIT_COUNT_SIGN_POS, /*!< counter value positive */ +} pcnt_unit_count_sign_t; #ifdef __cplusplus } diff --git a/tools/sdk/esp32c3/include/hal/include/hal/rtc_hal.h b/tools/sdk/esp32c3/include/hal/include/hal/rtc_hal.h index 8d74f4c4cd8..90f965ed58c 100644 --- a/tools/sdk/esp32c3/include/hal/include/hal/rtc_hal.h +++ b/tools/sdk/esp32c3/include/hal/include/hal/rtc_hal.h @@ -14,12 +14,36 @@ #pragma once +#include "soc/soc_caps.h" #include "hal/gpio_types.h" #include "hal/rtc_cntl_ll.h" #if !CONFIG_IDF_TARGET_ESP32C3 && !CONFIG_IDF_TARGET_ESP32H2 #include "hal/rtc_io_ll.h" #endif +typedef struct rtc_cntl_sleep_retent { +#if SOC_PM_SUPPORT_CPU_PD + void *cpu_pd_mem; /* Internal ram address for cpu retention */ +#endif // SOC_PM_SUPPORT_CPU_PD +#if SOC_PM_SUPPORT_TAGMEM_PD + struct { + void *link_addr; /* Internal ram address for tagmem retention */ + struct { + uint32_t start_point: 8, /* the row of start for i-cache tag memory */ + vld_size: 8, /* valid size of i-cache tag memory, unit: 4 i-cache tagmem blocks */ + size: 8, /* i-cache tag memory size, unit: 4 i-cache tagmem blocks */ + enable: 1; /* enable or disable i-cache tagmem retention */ + } icache; + struct { + uint32_t start_point: 9, /* the row of start for d-cache tag memory */ + vld_size: 9, /* valid size of d-cache tag memory, unit: 4 d-cache tagmem blocks */ + size: 9, /* d-cache tag memory size, unit: 4 d-cache tagmem blocks */ + enable: 1; /* enable or disable d-cache tagmem retention */ + } dcache; + } tagmem; +#endif // SOC_PM_SUPPORT_TAGMEM_PD +} rtc_cntl_sleep_retent_t; + #define RTC_HAL_DMA_LINK_NODE_SIZE (16) #if SOC_PM_SUPPORT_EXT_WAKEUP @@ -46,9 +70,21 @@ void * rtc_cntl_hal_dma_link_init(void *elem, void *buff, int size, void *next); +#if SOC_PM_SUPPORT_CPU_PD + void rtc_cntl_hal_enable_cpu_retention(void *addr); -#define rtc_cntl_hal_disable_cpu_retention() rtc_cntl_ll_disable_cpu_retention() +void rtc_cntl_hal_disable_cpu_retention(void *addr); + +#endif + +#if SOC_PM_SUPPORT_TAGMEM_PD + +void rtc_cntl_hal_enable_tagmem_retention(void *addr); + +void rtc_cntl_hal_disable_tagmem_retention(void *addr); + +#endif /* * Enable wakeup from ULP coprocessor. diff --git a/tools/sdk/esp32c3/include/hal/include/hal/spi_flash_hal.h b/tools/sdk/esp32c3/include/hal/include/hal/spi_flash_hal.h index dbbb5ff53b5..ae37016fa2d 100644 --- a/tools/sdk/esp32c3/include/hal/include/hal/spi_flash_hal.h +++ b/tools/sdk/esp32c3/include/hal/include/hal/spi_flash_hal.h @@ -51,20 +51,41 @@ typedef struct { uint32_t flags; ///< Flags for configurations with one set of driver code. (e.g. QPI mode, auto-suspend mode, 64-bit address mode, etc.) #define SPI_FLASH_HOST_CONTEXT_FLAG_AUTO_SUSPEND BIT(0) ///< When the auto-suspend is setup in configuration. #define SPI_FLASH_HOST_CONTEXT_FLAG_AUTO_RESUME BIT(1) ///< Setup auto-resume feature. +#define SPI_FLASH_HOST_CONTEXT_FLAG_OCTAL_MODE BIT(2) ///< Flash works under octal spi mode. spi_flash_sus_cmd_conf sus_cfg; ///< To store suspend command/mask information. + uint32_t slicer_flags; /// Slicer flags for configuring how to slice data correctly while reading or writing. +#define SPI_FLASH_HOST_CONTEXT_SLICER_FLAG_DTR BIT(0) ///< Slice data according to DTR mode, the address and length must be even (A0=0). } spi_flash_hal_context_t; -_Static_assert(sizeof(spi_flash_hal_context_t) == 36, "size of spi_flash_hal_context_t incorrect. Please check data compatibility with the ROM"); +_Static_assert(sizeof(spi_flash_hal_context_t) == 40, "size of spi_flash_hal_context_t incorrect. Please check data compatibility with the ROM"); + +/// This struct provide MSPI Flash necessary timing related config, should be consistent with that in union in `spi_flash_hal_config_t`. +typedef struct { + uint32_t extra_dummy; + uint32_t cs_hold; + uint8_t cs_setup; + spi_flash_ll_clock_reg_t clock_config; +} spi_flash_hal_timing_config_t; /// Configuration structure for the SPI driver. typedef struct { - spi_host_device_t host_id; ///< SPI peripheral ID. - int cs_num; ///< Which cs pin is used, 0-(SOC_SPI_PERIPH_CS_NUM-1). + union { + struct { + uint32_t extra_dummy; ///< extra dummy for timing compensation. + uint32_t cs_hold; ///< CS hold time config used by the host + uint8_t cs_setup; ///< (cycles-1) of prepare phase by spi clock + spi_flash_ll_clock_reg_t clock_config; ///< (optional) Clock configuration for Octal flash. + }; + spi_flash_hal_timing_config_t timing_reg; ///< Reconfigure timing tuning regs. + }; bool iomux; ///< Whether the IOMUX is used, used for timing compensation. int input_delay_ns; ///< Input delay on the MISO pin after the launch clock, used for timing compensation. esp_flash_speed_t speed;///< SPI flash clock speed to work at. - uint32_t cs_hold; ///< CS hold time config used by the host - uint8_t cs_setup; ///< (cycles-1) of prepare phase by spi clock + spi_host_device_t host_id; ///< SPI peripheral ID. + int cs_num; ///< Which cs pin is used, 0-(SOC_SPI_PERIPH_CS_NUM-1). bool auto_sus_en; ///< Auto suspend feature enable bit 1: enable, 0: disable. + bool octal_mode_en; ///< Octal spi flash mode enable bit 1: enable, 0: disable. + bool using_timing_tuning; ///< System exist SPI0/1 timing tuning, using value from system directely if set to 1. + esp_flash_io_mode_t default_io_mode; ///< Default flash io mode. } spi_flash_hal_config_t; /** diff --git a/tools/sdk/esp32c3/include/hal/include/hal/spi_flash_types.h b/tools/sdk/esp32c3/include/hal/include/hal/spi_flash_types.h index 0cc605595f2..c9d5035e60e 100644 --- a/tools/sdk/esp32c3/include/hal/include/hal/spi_flash_types.h +++ b/tools/sdk/esp32c3/include/hal/include/hal/spi_flash_types.h @@ -37,6 +37,7 @@ typedef struct { #define SPI_FLASH_TRANS_FLAG_BYTE_SWAP BIT(2) ///< Used for DTR mode, to swap the bytes of a pair of rising/falling edge uint16_t command; ///< Command to send uint8_t dummy_bitlen; ///< Basic dummy bits to use + uint32_t io_mode; ///< Flash working mode when `SPI_FLASH_IGNORE_BASEIO` is specified. } spi_flash_trans_t; /** @@ -54,6 +55,7 @@ typedef enum { ESP_FLASH_26MHZ, ///< The flash runs under 26MHz ESP_FLASH_40MHZ, ///< The flash runs under 40MHz ESP_FLASH_80MHZ, ///< The flash runs under 80MHz + ESP_FLASH_120MHZ, ///< The flash runs under 120MHz, 120MHZ can only be used by main flash after timing tuning in system. Do not use this directely in any API. ESP_FLASH_SPEED_MAX, ///< The maximum frequency supported by the host is ``ESP_FLASH_SPEED_MAX-1``. } esp_flash_speed_t; @@ -71,7 +73,9 @@ typedef enum { SPI_FLASH_DIO, ///< Both address & data transferred using dual I/O SPI_FLASH_QOUT, ///< Data read using quad I/O SPI_FLASH_QIO, ///< Both address & data transferred using quad I/O - +#define SPI_FLASH_OPI_FLAG 16 ///< A flag for flash work in opi mode, the io mode below are opi, above are SPI/QSPI mode. DO NOT use this value in any API. + SPI_FLASH_OPI_STR = SPI_FLASH_OPI_FLAG,///< Only support on OPI flash, flash read and write under STR mode + SPI_FLASH_OPI_DTR,///< Only support on OPI flash, flash read and write under DTR mode SPI_FLASH_READ_MODE_MAX, ///< The fastest io mode supported by the host is ``ESP_FLASH_READ_MODE_MAX-1``. } esp_flash_io_mode_t; diff --git a/tools/sdk/esp32c3/include/hal/include/hal/spi_hal.h b/tools/sdk/esp32c3/include/hal/include/hal/spi_hal.h index b37c7c92504..5be7db32ea9 100644 --- a/tools/sdk/esp32c3/include/hal/include/hal/spi_hal.h +++ b/tools/sdk/esp32c3/include/hal/include/hal/spi_hal.h @@ -38,6 +38,7 @@ #include #include "soc/lldesc.h" #include "soc/soc_caps.h" +#include "hal/spi_types.h" /** * Input parameters to the ``spi_hal_cal_clock_conf`` to calculate the timing configuration @@ -100,7 +101,7 @@ typedef struct { uint64_t addr; ///< Address value to be sent uint8_t *send_buffer; ///< Data to be sent uint8_t *rcv_buffer; ///< Buffer to hold the receive data. - spi_ll_io_mode_t io_mode; ///< IO mode of the master + spi_line_mode_t line_mode; ///< SPI line mode of this transaction int cs_keep_active; ///< Keep CS active after transaction } spi_hal_trans_config_t; diff --git a/tools/sdk/esp32c3/include/hal/include/hal/spi_types.h b/tools/sdk/esp32c3/include/hal/include/hal/spi_types.h index 400b922a5c6..169069c5c62 100644 --- a/tools/sdk/esp32c3/include/hal/include/hal/spi_types.h +++ b/tools/sdk/esp32c3/include/hal/include/hal/spi_types.h @@ -14,8 +14,9 @@ #pragma once +#include #include "esp_attr.h" -#include +#include "esp_bit_defs.h" #include "soc/soc_caps.h" #include "sdkconfig.h" @@ -45,6 +46,15 @@ typedef enum { } spi_event_t; FLAG_ATTR(spi_event_t) +/** + * @brief Line mode of SPI transaction phases: CMD, ADDR, DOUT/DIN. + */ +typedef struct { + uint8_t cmd_lines; ///< The line width of command phase, e.g. 2-line-cmd-phase. + uint8_t addr_lines; ///< The line width of address phase, e.g. 1-line-addr-phase. + uint8_t data_lines; ///< The line width of data phase, e.g. 4-line-data-phase. +} spi_line_mode_t; + /** @cond */ //Doxy command to hide preprocessor definitions from docs */ diff --git a/tools/sdk/esp32c3/include/hal/include/hal/timer_hal.h b/tools/sdk/esp32c3/include/hal/include/hal/timer_hal.h index f8c91739d91..cb3d5e0671d 100644 --- a/tools/sdk/esp32c3/include/hal/include/hal/timer_hal.h +++ b/tools/sdk/esp32c3/include/hal/include/hal/timer_hal.h @@ -59,6 +59,15 @@ void timer_hal_init(timer_hal_context_t *hal, timer_group_t group_num, timer_idx */ void timer_hal_get_status_reg_mask_bit(timer_hal_context_t *hal, uint32_t *status_reg, uint32_t *mask_bit); +/** + * @brief Reset timer peripheral + * + * @param hal Context of the HAL layer + * + * @return None + */ +void timer_hal_reset_periph(timer_hal_context_t *hal); + /** * @brief Set timer clock prescale value * diff --git a/tools/sdk/esp32c3/include/hal/include/hal/uhci_types.h b/tools/sdk/esp32c3/include/hal/include/hal/uhci_types.h new file mode 100644 index 00000000000..7122e2a41a9 --- /dev/null +++ b/tools/sdk/esp32c3/include/hal/include/hal/uhci_types.h @@ -0,0 +1,54 @@ +// Copyright 2015-2019 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. + + + +// Though the UHCI driver hasn't been published, some types are defined here +// for users to develop over the HAL. See example: controller_hci_uart_esp32c3 + +#pragma once + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief UHCI escape sequence + */ +typedef struct { + uint8_t seper_chr; /*!< escape sequence character */ + uint8_t sub_chr1; /*!< escape sequence sub-character 1 */ + uint8_t sub_chr2; /*!< escape sequence sub-character 2 */ + bool sub_chr_en; /*!< enable use of sub-chaacter of escape sequence */ +} uhci_seper_chr_t; + +/** + * @brief UHCI software flow control + */ +typedef struct { + uint8_t xon_chr; /*!< character for XON */ + uint8_t xon_sub1; /*!< sub-character 1 for XON */ + uint8_t xon_sub2; /*!< sub-character 2 for XON */ + uint8_t xoff_chr; /*!< character 2 for XOFF */ + uint8_t xoff_sub1; /*!< sub-character 1 for XOFF */ + uint8_t xoff_sub2; /*!< sub-character 2 for XOFF */ + uint8_t flow_en; /*!< enable use of software flow control */ +} uhci_swflow_ctrl_sub_chr_t; + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32c3/include/hal/include/hal/usb_phy_hal.h b/tools/sdk/esp32c3/include/hal/include/hal/usb_phy_hal.h new file mode 100644 index 00000000000..fe77eb87446 --- /dev/null +++ b/tools/sdk/esp32c3/include/hal/include/hal/usb_phy_hal.h @@ -0,0 +1,81 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "usb_types_private.h" +#include "usb_phy_types.h" +#include "soc/soc_caps.h" +#include "soc/usb_wrap_struct.h" +#if SOC_USB_SERIAL_JTAG_SUPPORTED +#include "soc/usb_serial_jtag_struct.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Context that should be maintained by both the driver and the HAL + */ +typedef struct { + usb_wrap_dev_t *wrap_dev; /**< Pointer to base address of USB Wrapper registers */ +#if SOC_USB_SERIAL_JTAG_SUPPORTED + usb_serial_jtag_dev_t *jtag_dev; /**< Pointer to base address of USB Serial JTAG registers */ +#endif +} usb_phy_hal_context_t; + +/** + * @brief Init the USB PHY hal. This function should be called first before other hal layer function is called + * + * @param hal Context of the HAL layer + */ +void usb_phy_hal_init(usb_phy_hal_context_t *hal); + +/** + * @brief Configure internal/external PHY for USB_OTG + * + * @param hal Context of the HAL layer + * @param phy_target USB PHY target + */ +void usb_phy_hal_otg_conf(usb_phy_hal_context_t *hal, usb_phy_target_t phy_target); + +#if SOC_USB_SERIAL_JTAG_SUPPORTED +/** + * @brief Configure internal/external PHY for USB_Serial_JTAG + * + * @param hal Context of the HAL layer + * @param phy_target USB PHY target + */ +void usb_phy_hal_jtag_conf(usb_phy_hal_context_t *hal, usb_phy_target_t phy_target); +#endif + +/** + * @brief Configure pullup/pulldown loads for the D+/D- as a host + * + * @param hal Context of the HAL layer + */ +void usb_phy_hal_int_load_conf_host(usb_phy_hal_context_t *hal); + +/** + * @brief Configure pullup/pulldown loads for the D+/D- as a device + * + * @param hal Context of the HAL layer + * @param speed USB speed + */ +void usb_phy_hal_int_load_conf_dev(usb_phy_hal_context_t *hal, usb_priv_speed_t speed); + +/** + * @brief Enable/Disable test mode for internal PHY to mimick host-device disconnection + * + * @param hal Context of the HAL layer + * @param disconn Whether to disconnect + */ +void usb_phy_hal_int_mimick_disconn(usb_phy_hal_context_t *hal, bool disconn); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32c3/include/hal/include/hal/usb_phy_types.h b/tools/sdk/esp32c3/include/hal/include/hal/usb_phy_types.h new file mode 100644 index 00000000000..1f5ac431efa --- /dev/null +++ b/tools/sdk/esp32c3/include/hal/include/hal/usb_phy_types.h @@ -0,0 +1,63 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* +Note: This header file contains USB2.0 related types and macros that can be used by code specific to the DWC_OTG +controller (i.e., the HW specific layers of the USB host stack). Thus, this header is only meant to be used below (and +including) the HAL layer. For types and macros that are HW implementation agnostic (i.e., HCD layer and above), add them +to the "usb/usb_types_ch9.h" header instead. +*/ + +#pragma once + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** + * @brief USB PHY target + */ +typedef enum { + USB_PHY_TARGET_INT, /**< USB target is internal PHY */ + USB_PHY_TARGET_EXT, /**< USB target is external PHY */ + USB_PHY_TARGET_MAX, +} usb_phy_target_t; + +/** + * @brief USB PHY source + */ +typedef enum { + USB_PHY_CTRL_OTG, /**< PHY controller is USB OTG */ +#if SOC_USB_SERIAL_JTAG_SUPPORTED + USB_PHY_CTRL_SERIAL_JTAG, /**< PHY controller is USB Serial JTAG */ +#endif + USB_PHY_CTRL_MAX, +} usb_phy_controller_t; + +/** + * @brief USB OTG mode + */ +typedef enum { + USB_PHY_MODE_DEFAULT, /**< USB OTG default mode */ + USB_OTG_MODE_HOST, /**< USB OTG host mode */ + USB_OTG_MODE_DEVICE, /**< USB OTG device mode */ + USB_OTG_MODE_MAX, +} usb_otg_mode_t; + +/** + * @brief USB speed + */ +typedef enum { + USB_PHY_SPEED_UNDEFINED, + USB_PHY_SPEED_LOW, /**< USB Low Speed (1.5 Mbit/s) */ + USB_PHY_SPEED_FULL, /**< USB Full Speed (12 Mbit/s) */ + USB_PHY_SPEED_MAX, +} usb_phy_speed_t; + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32c3/include/hal/include/hal/usb_types_private.h b/tools/sdk/esp32c3/include/hal/include/hal/usb_types_private.h index 868fdee5891..5cce6b66af4 100644 --- a/tools/sdk/esp32c3/include/hal/include/hal/usb_types_private.h +++ b/tools/sdk/esp32c3/include/hal/include/hal/usb_types_private.h @@ -16,7 +16,7 @@ Note: This header file contains USB2.0 related types and macros that can be used by code specific to the DWC_OTG controller (i.e., the HW specific layers of the USB host stack). Thus, this header is only meant to be used below (and including) the HAL layer. For types and macros that are HW implementation agnostic (i.e., HCD layer and above), add them -to the "usb.h" header instead. +to the "usb/usb_types_ch9.h" header instead. */ #pragma once diff --git a/tools/sdk/esp32c3/include/hal/include/hal/usbh_hal.h b/tools/sdk/esp32c3/include/hal/include/hal/usbh_hal.h index 1ff721c373b..b315f6c0b14 100644 --- a/tools/sdk/esp32c3/include/hal/include/hal/usbh_hal.h +++ b/tools/sdk/esp32c3/include/hal/include/hal/usbh_hal.h @@ -151,7 +151,7 @@ typedef struct { //Channel control, status, and information union { struct { - uint32_t active: 1; /**< The channel is enabled */ + uint32_t active: 1; /**< Debugging bit to indicate whether channel is enabled */ uint32_t halt_requested: 1; /**< A halt has been requested */ uint32_t error_pending: 1; /**< The channel is waiting for the error to be handled */ uint32_t reserved: 1; @@ -811,6 +811,8 @@ usbh_hal_chan_t *usbh_hal_get_chan_pending_intr(usbh_hal_context_t *hal); * - Returns the corresponding event for that channel * * @param chan_obj Channel object + * @note If the host port has an error (e.g., a sudden disconnect or an port error), any active channels will not + * receive an interrupt. Each active channel must be manually halted. * @return usbh_hal_chan_event_t Channel event */ usbh_hal_chan_event_t usbh_hal_chan_decode_intr(usbh_hal_chan_t *chan_obj); diff --git a/tools/sdk/esp32c3/include/hal/include/hal/xt_wdt_hal.h b/tools/sdk/esp32c3/include/hal/include/hal/xt_wdt_hal.h new file mode 100644 index 00000000000..bd08f2a989f --- /dev/null +++ b/tools/sdk/esp32c3/include/hal/include/hal/xt_wdt_hal.h @@ -0,0 +1,61 @@ +/* + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include +#include + +#include "hal/xt_wdt_ll.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + rtc_cntl_dev_t *dev; /* Pointer to the RTC register struct */ +} xt_wdt_hal_context_t; /* HAL context struct */ + +typedef struct { + uint32_t timeout; /* Watchdog timer timeout in RTC_CLK cycles*/ +} xt_wdt_hal_config_t; /* HAL config parameter struct */ + +/* ---------------------------- Init and Config ----------------------------- */ + +/** + * @brief Initialize the WDTs associated HAL context + * + * Prepares the register for enabling the WDT and sets the timeout value + * + * @param hal Pointer to the HAL layer context + * @param config Pointer to config struct + */ +void xt_wdt_hal_init(xt_wdt_hal_context_t *hal, const xt_wdt_hal_config_t *config); + + +/** + * @brief Enable or disable the WDT + * + * @param hal Pointer to the HAL layer context + * @param enable true for enable WDT, false for disable + */ +void xt_wdt_hal_enable(xt_wdt_hal_context_t *hal, bool enable); + +/** + * @brief Enable the automatic RTC backup clock with the given frequency + * + * Calculates and sets the necessary hardware parameters to meet the desired + * backup clock frequency + * + * @param hal Pointer to the HAL layer context + * @param rtc_clk_frequency_khz desired frequency for the backup clock + * @return uint32_t the calculated clock factor value + */ +uint32_t xt_wdt_hal_enable_backup_clk(xt_wdt_hal_context_t *hal, uint32_t rtc_clk_frequency_khz); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32c3/include/hal/platform_port/include/hal/log.h b/tools/sdk/esp32c3/include/hal/platform_port/include/hal/log.h index 28bde429d49..6d5cbda3817 100644 --- a/tools/sdk/esp32c3/include/hal/platform_port/include/hal/log.h +++ b/tools/sdk/esp32c3/include/hal/platform_port/include/hal/log.h @@ -21,3 +21,9 @@ #define HAL_LOGI(...) ESP_LOGI(__VA_ARGS__) #define HAL_LOGD(...) ESP_LOGD(__VA_ARGS__) #define HAL_LOGV(...) ESP_LOGV(__VA_ARGS__) + +#define HAL_EARLY_LOGE(...) ESP_EARLY_LOGE(__VA_ARGS__) +#define HAL_EARLY_LOGW(...) ESP_EARLY_LOGW(__VA_ARGS__) +#define HAL_EARLY_LOGI(...) ESP_EARLY_LOGI(__VA_ARGS__) +#define HAL_EARLY_LOGD(...) ESP_EARLY_LOGD(__VA_ARGS__) +#define HAL_EARLY_LOGV(...) ESP_EARLY_LOGV(__VA_ARGS__) diff --git a/tools/sdk/esp32c3/include/hal/platform_port/include/hal/misc.h b/tools/sdk/esp32c3/include/hal/platform_port/include/hal/misc.h index 472ec8be2a3..4afb49653ff 100644 --- a/tools/sdk/esp32c3/include/hal/platform_port/include/hal/misc.h +++ b/tools/sdk/esp32c3/include/hal/platform_port/include/hal/misc.h @@ -16,3 +16,44 @@ #define HAL_SWAP16(d) __builtin_bswap16((d)) #define HAL_SWAP32(d) __builtin_bswap32((d)) #define HAL_SWAP64(d) __builtin_bswap64((d)) + +/** @cond */ //Doxy command to hide preprocessor definitions from docs */ + +/** + * @brief Macro to force a 32-bit read, modify, then write on a peripheral register + * + * Due to a GCC bug, the compiler may still try to optimize read/writes to peripheral register fields by using 8/16 bit + * access, even if they are marked volatile (i.e., -fstrict-volatile-bitfields has no effect). + * + * For ESP chips, the peripheral bus only allows 32-bit read/writes. The following macro works around the compiler issue + * by forcing a 32-bit read/modify/write. + * + * @note This macro should only be called on register fields of xxx_struct.h type headers, as it depends on the presence + * of a 'val' field of the register union. + * @note Current implementation reads into a uint32_t instead of copy base_reg direclty to temp_reg. The reason being + * that C++ does not create a copy constructor for volatile structs. + */ +#define HAL_FORCE_MODIFY_U32_REG_FIELD(base_reg, reg_field, field_val) \ +{ \ + uint32_t temp_val = base_reg.val; \ + typeof(base_reg) temp_reg; \ + temp_reg.val = temp_val; \ + temp_reg.reg_field = (field_val); \ + (base_reg).val = temp_reg.val; \ +} + +/** + * @brief Macro to force a 32-bit read on a peripheral register + * + * @note This macro should only be called on register fields of xxx_struct.h type headers. See description above for + * more details. + * @note Current implementation reads into a uint32_t. See description above for more details. + */ +#define HAL_FORCE_READ_U32_REG_FIELD(base_reg, reg_field) ({ \ + uint32_t temp_val = base_reg.val; \ + typeof(base_reg) temp_reg; \ + temp_reg.val = temp_val; \ + temp_reg.reg_field; \ +}) + +/** @endcond */ diff --git a/tools/sdk/esp32c3/include/idf_test/include/idf_performance.h b/tools/sdk/esp32c3/include/idf_test/include/idf_performance.h index 18816813a78..9d99070b953 100644 --- a/tools/sdk/esp32c3/include/idf_test/include/idf_performance.h +++ b/tools/sdk/esp32c3/include/idf_test/include/idf_performance.h @@ -50,6 +50,20 @@ #define IDF_PERFORMANCE_MIN_UDP_TX_THROUGHPUT 50 #endif +// throughput performance by ethernet iperf +#ifndef IDF_PERFORMANCE_MIN_TCP_RX_ETH_THROUGHPUT +#define IDF_PERFORMANCE_MIN_TCP_RX_ETH_THROUGHPUT 20 +#endif +#ifndef IDF_PERFORMANCE_MIN_TCP_TX_ETH_THROUGHPUT +#define IDF_PERFORMANCE_MIN_TCP_TX_ETH_THROUGHPUT 30 +#endif +#ifndef IDF_PERFORMANCE_MIN_UDP_RX_ETH_THROUGHPUT +#define IDF_PERFORMANCE_MIN_UDP_RX_ETH_THROUGHPUT 50 +#endif +#ifndef IDF_PERFORMANCE_MIN_UDP_TX_ETH_THROUGHPUT +#define IDF_PERFORMANCE_MIN_UDP_TX_ETH_THROUGHPUT 70 +#endif + // events dispatched per second by event loop library #ifndef IDF_PERFORMANCE_MIN_EVENT_DISPATCH #define IDF_PERFORMANCE_MIN_EVENT_DISPATCH 25000 diff --git a/tools/sdk/esp32c3/include/ieee802154/include/esp_ieee802154.h b/tools/sdk/esp32c3/include/ieee802154/include/esp_ieee802154.h index a8d4678e924..e31a5ca37e5 100644 --- a/tools/sdk/esp32c3/include/ieee802154/include/esp_ieee802154.h +++ b/tools/sdk/esp32c3/include/ieee802154/include/esp_ieee802154.h @@ -192,6 +192,24 @@ void esp_ieee802154_get_extended_address(uint8_t *ext_addr); */ void esp_ieee802154_set_extended_address(const uint8_t *ext_addr); +/** + * @brief Get the device coordinator. + * + * @return + * - True The coordinator is enabled. + * - False The coordinator is disabled. + * + */ +bool esp_ieee802154_get_coordinator(void); + +/** + * @brief Set the device coordinator role. + * + * @param[in] enable The coordinator role to be set. + * + */ +void esp_ieee802154_set_coordinator(bool enable); + /** * @brief Get the auto frame pending mode. * diff --git a/tools/sdk/esp32c3/include/ieee802154/include/esp_ieee802154_types.h b/tools/sdk/esp32c3/include/ieee802154/include/esp_ieee802154_types.h index 6979991cc32..823e3cdcf3f 100644 --- a/tools/sdk/esp32c3/include/ieee802154/include/esp_ieee802154_types.h +++ b/tools/sdk/esp32c3/include/ieee802154/include/esp_ieee802154_types.h @@ -41,6 +41,8 @@ typedef enum { ESP_IEEE802154_TX_ERR_NO_ACK, /*!< No Ack frame received until timeout */ ESP_IEEE802154_TX_ERR_INVALID_ACK, /*!< Invalid Ack frame */ ESP_IEEE802154_TX_ERR_COEXIST, /*!< Rejected by coexist system */ + ESP_IEEE802154_TX_ERR_COEXIST_REJ, /*!< Rejected by coexist system before transmitting frame */ + ESP_IEEE802154_TX_ERR_COEXIST_ACK, /*!< Rejected by coexist system when receiving ack */ } esp_ieee802154_tx_error_t; /** @@ -60,6 +62,7 @@ typedef enum { ESP_IEEE802154_AUTO_PENDING_DISABLE, /*!< Frame pending bit always set to 1 in the ack to Data Request */ ESP_IEEE802154_AUTO_PENDING_ENABLE, /*!< Frame pending bit set to 1 if src address matches, in the ack to Data Request */ ESP_IEEE802154_AUTO_PENDING_ENHANCED, /*!< Frame pending bit set to 1 if src address matches, in all ack frames */ + ESP_IEEE802154_AUTO_PENDING_ZIGBEE, /*!< Frame pending bit set to 0 only if src address is short address and matches in table, in the ack to Data Request */ } esp_ieee802154_pending_mode_t; /** diff --git a/tools/sdk/esp32c3/include/json/cJSON/cJSON.h b/tools/sdk/esp32c3/include/json/cJSON/cJSON.h index e97e5f4cdc4..92907a2cd38 100644 --- a/tools/sdk/esp32c3/include/json/cJSON/cJSON.h +++ b/tools/sdk/esp32c3/include/json/cJSON/cJSON.h @@ -81,7 +81,7 @@ then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJ /* project version */ #define CJSON_VERSION_MAJOR 1 #define CJSON_VERSION_MINOR 7 -#define CJSON_VERSION_PATCH 14 +#define CJSON_VERSION_PATCH 15 #include @@ -256,7 +256,7 @@ CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * cons /* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from strings. * The input pointer json cannot point to a read-only address area, such as a string constant, - * but should point to a readable and writable adress area. */ + * but should point to a readable and writable address area. */ CJSON_PUBLIC(void) cJSON_Minify(char *json); /* Helper functions for creating and adding items to an object at the same time. diff --git a/tools/sdk/esp32c3/include/log/include/esp_log.h b/tools/sdk/esp32c3/include/log/include/esp_log.h index cf7bcd601a2..0e3148f62dc 100644 --- a/tools/sdk/esp32c3/include/log/include/esp_log.h +++ b/tools/sdk/esp32c3/include/log/include/esp_log.h @@ -10,9 +10,7 @@ #include #include #include "sdkconfig.h" -#if !defined(CONFIG_IDF_TARGET_LINUX) #include "esp_rom_sys.h" -#endif // !CONFIG_IDF_TARGET_LINUX #if CONFIG_IDF_TARGET_ESP32 #include "esp32/rom/ets_sys.h" // will be removed in idf v5.0 #elif CONFIG_IDF_TARGET_ESP32S2 @@ -90,6 +88,9 @@ esp_log_level_t esp_log_level_get(const char* tag); * output to some other destination, such as file or network. Returns the original * log handler, which may be necessary to return output to the previous destination. * + * @note Please note that function callback here must be re-entrant as it can be + * invoked in parallel from multiple thread context. + * * @param func new Function used for output. Must have same signature as vprintf. * * @return func old Function used for output. diff --git a/tools/sdk/esp32c3/include/lwip/include/apps/dhcpserver/dhcpserver.h b/tools/sdk/esp32c3/include/lwip/include/apps/dhcpserver/dhcpserver.h index 39a58bbfa94..262ebf43d85 100644 --- a/tools/sdk/esp32c3/include/lwip/include/apps/dhcpserver/dhcpserver.h +++ b/tools/sdk/esp32c3/include/lwip/include/apps/dhcpserver/dhcpserver.h @@ -17,6 +17,10 @@ #include "sdkconfig.h" #include "lwip/ip_addr.h" +#ifdef __cplusplus +extern "C" { +#endif + typedef struct dhcps_state{ s16_t state; } dhcps_state; @@ -91,4 +95,8 @@ void dhcps_dns_setserver(const ip_addr_t *dnsserver); ip4_addr_t dhcps_dns_getserver(void); void dhcps_set_new_lease_cb(dhcps_cb_t cb); +#ifdef __cplusplus +} #endif + +#endif /* __DHCPS_H__ */ diff --git a/tools/sdk/esp32c3/include/lwip/include/apps/dhcpserver/dhcpserver_options.h b/tools/sdk/esp32c3/include/lwip/include/apps/dhcpserver/dhcpserver_options.h index 38d46f6bff2..31a67992831 100644 --- a/tools/sdk/esp32c3/include/lwip/include/apps/dhcpserver/dhcpserver_options.h +++ b/tools/sdk/esp32c3/include/lwip/include/apps/dhcpserver/dhcpserver_options.h @@ -13,6 +13,9 @@ // limitations under the License. #pragma once +#ifdef __cplusplus +extern "C" { +#endif /** DHCP Options This macros are not part of the public dhcpserver.h interface. @@ -132,3 +135,7 @@ typedef enum DOMAIN_SEARCH = 119, CLASSLESS_ROUTE = 121, } dhcp_msg_option; + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32c3/include/lwip/port/esp32/include/lwipopts.h b/tools/sdk/esp32c3/include/lwip/port/esp32/include/lwipopts.h index 72e2bc4a97a..4bc2ad13960 100644 --- a/tools/sdk/esp32c3/include/lwip/port/esp32/include/lwipopts.h +++ b/tools/sdk/esp32c3/include/lwip/port/esp32/include/lwipopts.h @@ -33,9 +33,7 @@ #define __LWIPOPTS_H__ #include -#include #include -#include #include #include #include @@ -44,6 +42,7 @@ #include "esp_system.h" #include "sdkconfig.h" #include "netif/dhcp_state.h" +#include "sntp/sntp_get_set_time.h" /* Enable all Espressif-only options */ @@ -595,7 +594,7 @@ * LWIP_TCPIP_CORE_LOCKING: (EXPERIMENTAL!) * Don't use it if you're not an active lwIP project member */ -#define LWIP_TCPIP_CORE_LOCKING 0 +#define LWIP_TCPIP_CORE_LOCKING CONFIG_LWIP_TCPIP_CORE_LOCKING /* ------------------------------------ @@ -910,6 +909,15 @@ #define TCP_DEBUG LWIP_DBG_OFF #endif +/** + * SNTP_DEBUG: Enable debugging for SNTP. + */ +#ifdef CONFIG_LWIP_SNTP_DEBUG +#define SNTP_DEBUG LWIP_DBG_ON +#else +#define SNTP_DEBUG LWIP_DBG_OFF +#endif + /** * MEMP_DEBUG: Enable debugging in memp.c. */ @@ -970,6 +978,8 @@ #define LWIP_ND6_RDNSS_MAX_DNS_SERVERS CONFIG_LWIP_IPV6_RDNSS_MAX_DNS_SERVERS +#define LWIP_IPV6_DHCP6 CONFIG_LWIP_IPV6_DHCP6 + /* Enable all Espressif-only options */ #define ESP_LWIP 1 @@ -1044,7 +1054,11 @@ #define CHECKSUM_CHECK_ICMP CONFIG_LWIP_CHECKSUM_CHECK_ICMP #define LWIP_NETCONN_FULLDUPLEX 1 +#if LWIP_TCPIP_CORE_LOCKING +#define LWIP_NETCONN_SEM_PER_THREAD 0 +#else #define LWIP_NETCONN_SEM_PER_THREAD 1 +#endif /* LWIP_TCPIP_CORE_LOCKING */ #define LWIP_DHCP_MAX_NTP_SERVERS CONFIG_LWIP_DHCP_MAX_NTP_SERVERS #define LWIP_TIMEVAL_PRIVATE 0 @@ -1054,25 +1068,15 @@ ------------ SNTP options ------------ -------------------------------------- */ -/* - * SNTP update delay - in milliseconds - */ - -/* - * Forward declarations of weak definitions from lwip's sntp.c which could - * be redefined by user application. This is needed to provide custom definition - * of the below macros in lwip's sntp.c. - * Full declaration is provided in IDF's port layer in esp_sntp.h - */ -#ifdef __cplusplus -#define LWIP_FORWARD_DECLARE_C_CXX extern "C" -#else -#define LWIP_FORWARD_DECLARE_C_CXX -#endif -LWIP_FORWARD_DECLARE_C_CXX void sntp_sync_time(struct timeval *tv); +// Max number of SNTP servers handled (default equal to LWIP_DHCP_MAX_NTP_SERVERS) +#if defined CONFIG_LWIP_SNTP_MAX_SERVERS +#define SNTP_MAX_SERVERS CONFIG_LWIP_SNTP_MAX_SERVERS +#endif // CONFIG_LWIP_SNTP_MAX_SERVERS -LWIP_FORWARD_DECLARE_C_CXX uint32_t sntp_get_sync_interval(void); +#ifdef CONFIG_LWIP_DHCP_GET_NTP_SRV +#define LWIP_DHCP_GET_NTP_SRV CONFIG_LWIP_DHCP_GET_NTP_SRV +#endif // CONFIG_LWIP_DHCP_GET_NTP_SRV /** Set this to 1 to support DNS names (or IP address strings) to set sntp servers * One server address/name can be defined as default if SNTP_SERVER_DNS == 1: @@ -1083,22 +1087,9 @@ LWIP_FORWARD_DECLARE_C_CXX uint32_t sntp_get_sync_interval(void); // It disables a check of SNTP_UPDATE_DELAY it is done in sntp_set_sync_interval #define SNTP_SUPPRESS_DELAY_CHECK -#define SNTP_UPDATE_DELAY (sntp_get_sync_interval()) - -#define SNTP_SET_SYSTEM_TIME_US(sec, us) \ - do { \ - struct timeval tv = { .tv_sec = sec, .tv_usec = us }; \ - sntp_sync_time(&tv); \ - } while (0); - -#define SNTP_GET_SYSTEM_TIME(sec, us) \ - do { \ - struct timeval tv = { .tv_sec = 0, .tv_usec = 0 }; \ - gettimeofday(&tv, NULL); \ - (sec) = tv.tv_sec; \ - (us) = tv.tv_usec; \ - sntp_set_sync_status(SNTP_SYNC_STATUS_RESET); \ - } while (0); +#define SNTP_UPDATE_DELAY (sntp_get_sync_interval()) +#define SNTP_SET_SYSTEM_TIME_US(sec, us) (sntp_set_system_time(sec, us)) +#define SNTP_GET_SYSTEM_TIME(sec, us) (sntp_get_system_time(&(sec), &(us))) #define SOC_SEND_LOG //printf diff --git a/tools/sdk/esp32c3/include/lwip/port/esp32/include/sntp/sntp_get_set_time.h b/tools/sdk/esp32c3/include/lwip/port/esp32/include/sntp/sntp_get_set_time.h new file mode 100644 index 00000000000..19916208044 --- /dev/null +++ b/tools/sdk/esp32c3/include/lwip/port/esp32/include/sntp/sntp_get_set_time.h @@ -0,0 +1,55 @@ +// Copyright 2021 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 __SNTP_GET_SET_TIME_H__ +#define __SNTP_GET_SET_TIME_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * Declarations of functions used in lwipopts.h to redefine + * default sntp macros, such as: + * - SNTP_UPDATE_DELAY() + * - SNTP_SET_SYSTEM_TIME_US() + * - SNTP_GET_SYSTEM_TIME() + */ + +/* + * @brief Get the sync interval of SNTP operation + * Full definition is provided in IDF's layer in esp_sntp.c + */ +uint32_t sntp_get_sync_interval(void); + +/** + * @brief system time setter used in the sntp module + * @note The lwip sntp uses u32_t types for sec and us arguments + */ +void sntp_set_system_time(uint32_t sec, uint32_t us); + +/** + * @brief system time getter used in the sntp module + * @note The lwip sntp uses u32_t types for sec and us arguments + */ +void sntp_get_system_time(uint32_t* sec, uint32_t* us); + +#ifdef __cplusplus +} +#endif + +#endif //__SNTP_GET_SET_TIME_H__ diff --git a/tools/sdk/esp32c3/include/mdns/include/mdns.h b/tools/sdk/esp32c3/include/mdns/include/mdns.h index 7089eabe6a9..4bb288d4174 100644 --- a/tools/sdk/esp32c3/include/mdns/include/mdns.h +++ b/tools/sdk/esp32c3/include/mdns/include/mdns.h @@ -75,10 +75,13 @@ typedef struct mdns_result_s { struct mdns_result_s * next; /*!< next result, or NULL for the last result in the list */ mdns_if_t tcpip_if; /*!< interface index */ + uint32_t ttl; /*!< time to live */ mdns_ip_protocol_t ip_protocol; /*!< ip_protocol type of the interface (v4/v6) */ // PTR char * instance_name; /*!< instance name */ + char * service_type; /*!< service type */ + char * proto; /*!< srevice protocol */ // SRV char * hostname; /*!< hostname */ uint16_t port; /*!< service port */ @@ -90,6 +93,8 @@ typedef struct mdns_result_s { mdns_ip_addr_t * addr; /*!< linked list of IP addresses found */ } mdns_result_t; +typedef void (*mdns_query_notify_t)(mdns_search_once_t *search); + /** * @brief Initialize mDNS on given interface * @@ -519,11 +524,13 @@ bool mdns_query_async_get_results(mdns_search_once_t* search, uint32_t timeout, * @param type type of query (MDNS_TYPE_*) * @param timeout time in milliseconds during which mDNS query is active * @param max_results maximum results to be collected + * @param notifier Notification function to be called when the result is ready, can be NULL * * @return mdns_search_once_s pointer to new search object if query initiated successfully. * NULL otherwise. */ -mdns_search_once_t* mdns_query_async_new(const char * name, const char * service_type, const char * proto, uint16_t type, uint32_t timeout, size_t max_results); +mdns_search_once_t *mdns_query_async_new(const char *name, const char *service_type, const char *proto, uint16_t type, + uint32_t timeout, size_t max_results, mdns_query_notify_t notifier); /** * @brief Query mDNS for host or service diff --git a/tools/sdk/esp32c3/include/newlib/platform_include/assert.h b/tools/sdk/esp32c3/include/newlib/platform_include/assert.h index 85222861480..39db39a6f04 100644 --- a/tools/sdk/esp32c3/include/newlib/platform_include/assert.h +++ b/tools/sdk/esp32c3/include/newlib/platform_include/assert.h @@ -19,6 +19,7 @@ #pragma once #include #include +#include #include_next @@ -31,16 +32,21 @@ */ #undef assert +/* __FILENAME__ points to the file name instead of path + filename + * e.g __FILE__ points to "/apps/test.c" where as __FILENAME__ points to "test.c" + */ +#define __FILENAME__ (__builtin_strrchr( "/" __FILE__, '/') + 1) + #if defined(NDEBUG) -# define assert(__e) ((void)(__e)) +#define assert(__e) ((void)(__e)) #elif CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT -#define assert(__e) __builtin_expect(!!(__e), 1) ? (void)0 : abort() +#define assert(__e) (__builtin_expect(!!(__e), 1) ? (void)0 : __assert_func(NULL, 0, NULL, NULL)) #else // !CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT -#define assert(__e) (__builtin_expect(!!(__e), 1) ? (void)0 : __assert_func (__FILE__, __LINE__, \ +#define assert(__e) (__builtin_expect(!!(__e), 1) ? (void)0 : __assert_func (__FILENAME__, __LINE__, \ __ASSERT_FUNC, #__e)) #endif diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/apb_ctrl_struct.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/apb_ctrl_struct.h index 9b832df8dda..dd20d378943 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/apb_ctrl_struct.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/apb_ctrl_struct.h @@ -17,7 +17,7 @@ extern "C" { #endif -typedef volatile struct { +typedef volatile struct apb_ctrl_dev_s { union { struct { uint32_t pre_div: 10; diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/apb_saradc_struct.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/apb_saradc_struct.h index c3ea73f1502..c75e582f7de 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/apb_saradc_struct.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/apb_saradc_struct.h @@ -17,7 +17,7 @@ extern "C" { #endif -typedef volatile struct { +typedef volatile struct apb_saradc_dev_s { union { struct { uint32_t start_force: 1; diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/assist_debug_reg.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/assist_debug_reg.h index a0c1e9c9d8c..2b13d1f5f41 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/assist_debug_reg.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/assist_debug_reg.h @@ -652,7 +652,7 @@ extern "C" { #define ASSIST_DEBUG_LOG_MEM_FULL_FLAG_V 0x1 #define ASSIST_DEBUG_LOG_MEM_FULL_FLAG_S 0 -#define ASSIST_DEBUG_C0RE_0_LASTPC_BEFORE_EXCEPTION_REG (DR_REG_ASSIST_DEBUG_BASE + 0x094) +#define ASSIST_DEBUG_CORE_0_LASTPC_BEFORE_EXCEPTION_REG (DR_REG_ASSIST_DEBUG_BASE + 0x094) /* ASSIST_DEBUG_CORE_0_LASTPC_BEFORE_EXC : RO ;bitpos:[31:0] ;default: 32'b0 ; */ /*description: */ #define ASSIST_DEBUG_CORE_0_LASTPC_BEFORE_EXC 0xFFFFFFFF @@ -660,7 +660,7 @@ extern "C" { #define ASSIST_DEBUG_CORE_0_LASTPC_BEFORE_EXC_V 0xFFFFFFFF #define ASSIST_DEBUG_CORE_0_LASTPC_BEFORE_EXC_S 0 -#define ASSIST_DEBUG_C0RE_0_DEBUG_MODE_REG (DR_REG_ASSIST_DEBUG_BASE + 0x098) +#define ASSIST_DEBUG_CORE_0_DEBUG_MODE_REG (DR_REG_ASSIST_DEBUG_BASE + 0x098) /* ASSIST_DEBUG_CORE_0_DEBUG_MODULE_ACTIVE : RO ;bitpos:[1] ;default: 1'b0 ; */ /*description: */ #define ASSIST_DEBUG_CORE_0_DEBUG_MODULE_ACTIVE (BIT(1)) diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/efuse_reg.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/efuse_reg.h index ddaff7285c6..aca7304f530 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/efuse_reg.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/efuse_reg.h @@ -141,12 +141,12 @@ extern "C" { #define EFUSE_DIS_ICACHE_M (BIT(8)) #define EFUSE_DIS_ICACHE_V 0x1 #define EFUSE_DIS_ICACHE_S 8 -/* EFUSE_DIS_RTC_RAM_BOOT : R/W ;bitpos:[7] ;default: 1'b0 ; */ -/*description: Set this bit to disable boot from RTC RAM.*/ -#define EFUSE_DIS_RTC_RAM_BOOT (BIT(7)) -#define EFUSE_DIS_RTC_RAM_BOOT_M (BIT(7)) -#define EFUSE_DIS_RTC_RAM_BOOT_V 0x1 -#define EFUSE_DIS_RTC_RAM_BOOT_S 7 +/* EFUSE_RPT4_RESERVED5 : R/W ;bitpos:[7] ;default: 1'b0 ; */ +/*description: Reserved.*/ +#define EFUSE_RPT4_RESERVED5 (BIT(7)) +#define EFUSE_RPT4_RESERVED5_M (BIT(7)) +#define EFUSE_RPT4_RESERVED5_V 0x1 +#define EFUSE_RPT4_RESERVED5_S 7 /* EFUSE_RD_DIS : R/W ;bitpos:[6:0] ;default: 7'h0 ; */ /*description: Set this bit to disable reading from BlOCK4-10.*/ #define EFUSE_RD_DIS 0x0000007F @@ -516,12 +516,12 @@ extern "C" { #define EFUSE_DIS_ICACHE_M (BIT(8)) #define EFUSE_DIS_ICACHE_V 0x1 #define EFUSE_DIS_ICACHE_S 8 -/* EFUSE_DIS_RTC_RAM_BOOT : RO ;bitpos:[7] ;default: 1'b0 ; */ -/*description: The value of DIS_RTC_RAM_BOOT.*/ -#define EFUSE_DIS_RTC_RAM_BOOT (BIT(7)) -#define EFUSE_DIS_RTC_RAM_BOOT_M (BIT(7)) -#define EFUSE_DIS_RTC_RAM_BOOT_V 0x1 -#define EFUSE_DIS_RTC_RAM_BOOT_S 7 +/* EFUSE_RPT4_RESERVED5 : RO ;bitpos:[7] ;default: 1'b0 ; */ +/*description: Reserved.*/ +#define EFUSE_RPT4_RESERVED5 (BIT(7)) +#define EFUSE_RPT4_RESERVED5_M (BIT(7)) +#define EFUSE_RPT4_RESERVED5_V 0x1 +#define EFUSE_RPT4_RESERVED5_S 7 /* EFUSE_RD_DIS : RO ;bitpos:[6:0] ;default: 7'h0 ; */ /*description: The value of RD_DIS.*/ #define EFUSE_RD_DIS 0x0000007F @@ -1486,12 +1486,12 @@ extern "C" { #define EFUSE_DIS_ICACHE_ERR_M (BIT(8)) #define EFUSE_DIS_ICACHE_ERR_V 0x1 #define EFUSE_DIS_ICACHE_ERR_S 8 -/* EFUSE_DIS_RTC_RAM_BOOT_ERR : RO ;bitpos:[7] ;default: 1'b0 ; */ -/*description: If DIS_RTC_RAM_BOOT is 1 then it indicates a programming error.*/ -#define EFUSE_DIS_RTC_RAM_BOOT_ERR (BIT(7)) -#define EFUSE_DIS_RTC_RAM_BOOT_ERR_M (BIT(7)) -#define EFUSE_DIS_RTC_RAM_BOOT_ERR_V 0x1 -#define EFUSE_DIS_RTC_RAM_BOOT_ERR_S 7 +/* EFUSE_RPT4_RESERVED5_ERR : RO ;bitpos:[7] ;default: 1'b0 ; */ +/*description: Reserved..*/ +#define EFUSE_RPT4_RESERVED5_ERR (BIT(7)) +#define EFUSE_RPT4_RESERVED5_ERR_M (BIT(7)) +#define EFUSE_RPT4_RESERVED5_ERR_V 0x1 +#define EFUSE_RPT4_RESERVED5_ERR_S 7 /* EFUSE_RD_DIS_ERR : RO ;bitpos:[6:0] ;default: 7'h0 ; */ /*description: If any bit in RD_DIS is 1 then it indicates a programming error.*/ #define EFUSE_RD_DIS_ERR 0x0000007F @@ -1691,7 +1691,7 @@ extern "C" { #define EFUSE_DIS_DOWNLOAD_MODE_ERR_V 0x1 #define EFUSE_DIS_DOWNLOAD_MODE_ERR_S 0 -#define EFUSE_RD_REPEAT_ERR4_REG (DR_REG_EFUSE_BASE + 0x190) +#define EFUSE_RD_REPEAT_ERR4_REG (DR_REG_EFUSE_BASE + 0x18C) /* EFUSE_RPT4_RESERVED4_ERR : RO ;bitpos:[23:0] ;default: 24'h0 ; */ /*description: Reserved.*/ #define EFUSE_RPT4_RESERVED4_ERR 0x00FFFFFF diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/efuse_struct.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/efuse_struct.h index 1c51e71475d..24915ba8104 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/efuse_struct.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/efuse_struct.h @@ -17,12 +17,12 @@ extern "C" { #endif -typedef volatile struct { +typedef volatile struct efuse_dev_s { uint32_t pgm_data0; /*Register 0 that stores data to be programmed.*/ union { struct { uint32_t rd_dis: 7; /*Set this bit to disable reading from BlOCK4-10.*/ - uint32_t dis_rtc_ram_boot: 1; /*Set this bit to disable boot from RTC RAM.*/ + uint32_t rpt4_reserved5: 1; /*Reserved*/ uint32_t dis_icache: 1; /*Set this bit to disable Icache.*/ uint32_t dis_usb_jtag: 1; /*Set this bit to disable function of usb switch to jtag in module of usb device.*/ uint32_t dis_download_icache: 1; /*Set this bit to disable Icache in download mode (boot_mode[3:0] is 0 1 2 3 6 7).*/ @@ -106,7 +106,7 @@ typedef volatile struct { union { struct { uint32_t rd_dis: 7; /*The value of RD_DIS.*/ - uint32_t dis_rtc_ram_boot: 1; /*The value of DIS_RTC_RAM_BOOT.*/ + uint32_t rpt4_reserved5: 1; /*Reserved*/ uint32_t dis_icache: 1; /*The value of DIS_ICACHE.*/ uint32_t dis_usb_jtag: 1; /*The value of DIS_USB_JTAG.*/ uint32_t dis_download_icache: 1; /*The value of DIS_DOWNLOAD_ICACHE.*/ @@ -274,7 +274,7 @@ typedef volatile struct { union { struct { uint32_t rd_dis_err: 7; /*If any bit in RD_DIS is 1 then it indicates a programming error.*/ - uint32_t dis_rtc_ram_boot_err: 1; /*If DIS_RTC_RAM_BOOT is 1 then it indicates a programming error.*/ + uint32_t rpt4_reserved5_err: 1; /*Reserved.*/ uint32_t dis_icache_err: 1; /*If DIS_ICACHE is 1 then it indicates a programming error.*/ uint32_t dis_usb_jtag_err: 1; /*If DIS_USB_JTAG is 1 then it indicates a programming error.*/ uint32_t dis_download_icache: 1; /*If DIS_DOWNLOAD_ICACHE is 1 then it indicates a programming error.*/ @@ -342,7 +342,6 @@ typedef volatile struct { }; uint32_t val; } rd_repeat_err3; - uint32_t reserved_18c; union { struct { uint32_t rpt4_reserved4_err:24; /*Reserved.*/ @@ -350,6 +349,7 @@ typedef volatile struct { }; uint32_t val; } rd_repeat_err4; + uint32_t reserved_190; uint32_t reserved_194; uint32_t reserved_198; uint32_t reserved_19c; diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/gdma_struct.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/gdma_struct.h index 446ff4c1122..dde520f5edc 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/gdma_struct.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/gdma_struct.h @@ -19,7 +19,7 @@ extern "C" { #endif -typedef volatile struct { +typedef volatile struct gdma_dev_s { struct { union { struct { diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/gpio_sd_struct.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/gpio_sd_struct.h index cc73cebd03d..45e21d58e1c 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/gpio_sd_struct.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/gpio_sd_struct.h @@ -17,7 +17,7 @@ extern "C" { #endif -typedef volatile struct { +typedef volatile struct gpio_sd_dev_s { union { struct { uint32_t duty: 8; diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/gpio_sig_map.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/gpio_sig_map.h index 45be68b3e5c..61aa95a3c45 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/gpio_sig_map.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/gpio_sig_map.h @@ -53,26 +53,26 @@ #define GPIO_WLAN_PRIO_IDX 18 #define GPIO_BT_ACTIVE_IDX 19 #define GPIO_WLAN_ACTIVE_IDX 19 -#define BB_DIAG0_IDX 20 -#define BB_DIAG1_IDX 21 -#define BB_DIAG2_IDX 22 -#define BB_DIAG3_IDX 23 -#define BB_DIAG4_IDX 24 -#define BB_DIAG5_IDX 25 -#define BB_DIAG6_IDX 26 -#define BB_DIAG7_IDX 27 -#define BB_DIAG8_IDX 28 -#define BB_DIAG9_IDX 29 -#define BB_DIAG10_IDX 30 -#define BB_DIAG11_IDX 31 -#define BB_DIAG12_IDX 32 -#define BB_DIAG13_IDX 33 -#define BB_DIAG14_IDX 34 -#define BB_DIAG15_IDX 35 -#define BB_DIAG16_IDX 36 -#define BB_DIAG17_IDX 37 -#define BB_DIAG18_IDX 38 -#define BB_DIAG19_IDX 39 +#define CPU_GPIO_IN0_IDX 28 +#define CPU_GPIO_OUT0_IDX 28 +#define CPU_GPIO_IN1_IDX 29 +#define CPU_GPIO_OUT1_IDX 29 +#define CPU_GPIO_IN2_IDX 30 +#define CPU_GPIO_OUT2_IDX 30 +#define CPU_GPIO_IN3_IDX 31 +#define CPU_GPIO_OUT3_IDX 31 +#define CPU_GPIO_IN4_IDX 32 +#define CPU_GPIO_OUT4_IDX 32 +#define CPU_GPIO_IN5_IDX 33 +#define CPU_GPIO_OUT5_IDX 33 +#define CPU_GPIO_IN6_IDX 34 +#define CPU_GPIO_OUT6_IDX 34 +#define CPU_GPIO_IN7_IDX 35 +#define CPU_GPIO_OUT7_IDX 35 +#define USB_JTAG_TCK_OUT_IDX 36 +#define USB_JTAG_TMS_OUT_IDX 37 +#define USB_JTAG_TDI_OUT_IDX 38 +#define USB_JTAG_TDO_OUT_IDX 39 #define USB_EXTPHY_VP_IDX 40 #define USB_EXTPHY_OEN_IDX 40 #define USB_EXTPHY_VM_IDX 41 @@ -179,6 +179,7 @@ #define CLK_OUT_OUT2_IDX 124 #define CLK_OUT_OUT3_IDX 125 #define SPICS1_OUT_IDX 126 +#define USB_JTAG_TRST_OUT_IDX 127 #define SIG_GPIO_OUT_IDX 128 #define GPIO_MAP_DATE_IDX 0x2006130 #endif /* _SOC_GPIO_SIG_MAP_H_ */ diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/gpio_struct.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/gpio_struct.h index f260adbd2ab..45f5e55412c 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/gpio_struct.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/gpio_struct.h @@ -18,7 +18,7 @@ extern "C" { #endif -typedef volatile struct { +typedef volatile struct gpio_dev_s { uint32_t bt_select; /**/ union { struct { diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/hwcrypto_reg.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/hwcrypto_reg.h index 68446273887..474b07faa3b 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/hwcrypto_reg.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/hwcrypto_reg.h @@ -133,6 +133,7 @@ #define HMAC_SET_MESSAGE_END_REG ((DR_REG_HMAC_BASE) + 0x58) #define HMAC_SET_RESULT_FINISH_REG ((DR_REG_HMAC_BASE) + 0x5c) #define HMAC_SET_INVALIDATE_JTAG_REG ((DR_REG_HMAC_BASE) + 0x60) +#define HMAC_INVALIDATE_JTAG BIT(0) #define HMAC_SET_INVALIDATE_DS_REG ((DR_REG_HMAC_BASE) + 0x64) #define HMAC_QUERY_ERROR_REG ((DR_REG_HMAC_BASE) + 0x68) #define HMAC_QUERY_BUSY_REG ((DR_REG_HMAC_BASE) + 0x6c) diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/i2c_struct.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/i2c_struct.h index 22c6c470413..ccd5fdb5b05 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/i2c_struct.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/i2c_struct.h @@ -20,7 +20,7 @@ extern "C" { #endif #include "soc.h" -typedef volatile struct { +typedef volatile struct i2c_dev_s { union { struct { uint32_t period : 9; diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/i2s_struct.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/i2s_struct.h index 2f9c862b856..44334a87892 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/i2s_struct.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/i2s_struct.h @@ -17,7 +17,7 @@ extern "C" { #endif -typedef volatile struct { +typedef volatile struct i2s_dev_s { uint32_t reserved_0; uint32_t reserved_4; uint32_t reserved_8; diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/io_mux_reg.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/io_mux_reg.h index 3f338ea92d5..e9a0795167b 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/io_mux_reg.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/io_mux_reg.h @@ -124,9 +124,6 @@ #define GPIO_PAD_PULLDOWN(num) do{PIN_PULLUP_DIS(IOMUX_REG_GPIO##num);PIN_PULLDWN_EN(IOMUX_REG_GPIO##num);}while(0) #define GPIO_PAD_SET_DRV(num, drv) PIN_SET_DRV(IOMUX_REG_GPIO##num, drv) -#define U0RXD_GPIO_NUM 20 -#define U0TXD_GPIO_NUM 21 - #define SPI_HD_GPIO_NUM 12 #define SPI_WP_GPIO_NUM 13 #define SPI_CS0_GPIO_NUM 14 diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/ledc_struct.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/ledc_struct.h index 9e5a2a96c1e..0eb8c18268b 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/ledc_struct.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/ledc_struct.h @@ -17,7 +17,7 @@ extern "C" { #endif -typedef volatile struct { +typedef volatile struct ledc_dev_s { struct { struct { union { diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/periph_defs.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/periph_defs.h index da304aef31f..73c99352730 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/periph_defs.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/periph_defs.h @@ -76,7 +76,7 @@ typedef enum { ETS_LEDC_INTR_SOURCE, /**< interrupt of LED PWM, level*/ ETS_EFUSE_INTR_SOURCE, /**< interrupt of efuse, level, not likely to use*/ ETS_TWAI_INTR_SOURCE, /**< interrupt of can, level*/ - ETS_USB_INTR_SOURCE, /**< interrupt of USB, level*/ + ETS_USB_SERIAL_JTAG_INTR_SOURCE, /**< interrupt of USB, level*/ ETS_RTC_CORE_INTR_SOURCE, /**< interrupt of rtc core, level, include rtc watchdog*/ ETS_RMT_INTR_SOURCE, /**< interrupt of remote controller, level*/ ETS_I2C_EXT0_INTR_SOURCE, /**< interrupt of I2C controller1, level*/ @@ -102,8 +102,8 @@ typedef enum { ETS_SHA_INTR_SOURCE, /**< interrupt of SHA accelerator, level*/ ETS_FROM_CPU_INTR0_SOURCE, /**< interrupt0 generated from a CPU, level*/ /* Used for FreeRTOS */ ETS_FROM_CPU_INTR1_SOURCE, /**< interrupt1 generated from a CPU, level*/ /* Used for FreeRTOS */ - ETS_FROM_CPU_INTR2_SOURCE, /**< interrupt2 generated from a CPU, level*/ /* Used for DPORT Access */ - ETS_FROM_CPU_INTR3_SOURCE, /**< interrupt3 generated from a CPU, level*/ /* Used for DPORT Access */ + ETS_FROM_CPU_INTR2_SOURCE, /**< interrupt2 generated from a CPU, level*/ + ETS_FROM_CPU_INTR3_SOURCE, /**< interrupt3 generated from a CPU, level*/ ETS_ASSIST_DEBUG_INTR_SOURCE, /**< interrupt of Assist debug module, LEVEL*/ ETS_DMA_APBPERI_PMS_INTR_SOURCE, ETS_CORE0_IRAM0_PMS_INTR_SOURCE, diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/reset_reasons.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/reset_reasons.h index 0bb99f5851b..c624619bb38 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/reset_reasons.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/reset_reasons.h @@ -52,6 +52,8 @@ typedef enum { RESET_REASON_SYS_SUPER_WDT = 0x12, // Super watch dog resets the digital core and rtc module RESET_REASON_SYS_CLK_GLITCH = 0x13, // Glitch on clock resets the digital core and rtc module RESET_REASON_CORE_EFUSE_CRC = 0x14, // eFuse CRC error resets the digital core + RESET_REASON_CORE_USB_UART = 0x15, // USB UART resets the digital core + RESET_REASON_CORE_USB_JTAG = 0x16, // USB JTAG resets the digital core RESET_REASON_CORE_PWR_GLITCH = 0x17, // Glitch on power resets the digital core } soc_reset_reason_t; diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/rmt_struct.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/rmt_struct.h index 7fc1890b128..b9b7533b3d1 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/rmt_struct.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/rmt_struct.h @@ -20,7 +20,7 @@ extern "C" { #endif -typedef volatile struct { +typedef volatile struct rmt_dev_s { uint32_t data_ch[4]; /**/ union { struct { @@ -291,11 +291,9 @@ typedef struct { } rmt_item32_t; //Allow access to RMT memory using RMTMEM.chan[0].data32[8] -typedef volatile struct { +typedef volatile struct rmt_mem_s { struct { - union { - rmt_item32_t data32[48]; - }; + rmt_item32_t data32[48]; } chan[4]; } rmt_mem_t; diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/rtc.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/rtc.h index 3fda6cb8a77..40e6ec81d14 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/rtc.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/rtc.h @@ -206,7 +206,8 @@ typedef enum { typedef enum { RTC_CAL_RTC_MUX = 0, //!< Currently selected RTC SLOW_CLK RTC_CAL_8MD256 = 1, //!< Internal 8 MHz RC oscillator, divided by 256 - RTC_CAL_32K_XTAL = 2 //!< External 32 kHz XTAL + RTC_CAL_32K_XTAL = 2, //!< External 32 kHz XTAL + RTC_CAL_INTERNAL_OSC = 3 //!< Internal 150 kHz oscillator } rtc_cal_sel_t; /** diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/rtc_cntl_struct.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/rtc_cntl_struct.h index 358ebaded73..9478048648a 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/rtc_cntl_struct.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/rtc_cntl_struct.h @@ -17,7 +17,7 @@ extern "C" { #endif -typedef volatile struct { +typedef volatile struct rtc_cntl_dev_s { union { struct { uint32_t sw_stall_appcpu_c0: 2; /*{reg_sw_stall_appcpu_c1[5:0] reg_sw_stall_appcpu_c0[1:0]} == 0x86 will stall APP CPU*/ diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/rtc_i2c_struct.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/rtc_i2c_struct.h index 5141eebcd62..9f97a70cad1 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/rtc_i2c_struct.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/rtc_i2c_struct.h @@ -17,7 +17,7 @@ extern "C" { #endif -typedef volatile struct { +typedef volatile struct rtc_i2c_dev_s { union { struct { uint32_t period: 20; /*time period that scl = 0*/ diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/sensitive_struct.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/sensitive_struct.h index a24ccf64028..ba860e45cd7 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/sensitive_struct.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/sensitive_struct.h @@ -20,7 +20,7 @@ extern "C" { #endif #include "soc.h" -typedef volatile struct { +typedef volatile struct sensitive_dev_s { union { struct { uint32_t reg_rom_table_lock : 1; /*rom_table_lock*/ @@ -959,8 +959,7 @@ typedef volatile struct { union { struct { uint32_t reg_clk_en : 1; /*clk_en*/ - uint32_t reserved1 : 31; - uint32_t reservedNone : None; /*SENSITIVE_CLOCK_GATE_REG_REG*/ + uint32_t reserved1 : 31; /*SENSITIVE_CLOCK_GATE_REG_REG*/ }; uint32_t val; } clock_gate; diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/soc.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/soc.h index da55b8661eb..72dbb15a609 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/soc.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/soc.h @@ -268,57 +268,13 @@ // Start (highest address) of ROM boot stack, only relevant during early boot #define SOC_ROM_STACK_START 0x3fcebf10 -//interrupt cpu using table, Please see the core-isa.h -/************************************************************************************************************* - * Intr num Level Type PRO CPU usage - * 0 1 extern level Panic - * 1 1 extern level WMAC - * 2 1 extern level - * 3 1 extern level - * 4 1 extern level WBB - * 5 1 extern level BT/BLE Controller - * 6 1 timer FreeRTOS Tick(L1) - * 7 1 software - * 8 1 extern level BT/BLE BB(RX/TX) - * 9 1 extern level - * 10 1 extern edge - * 11 3 profiling - * 12 1 extern level - * 13 1 extern level - * 14 7 nmi Reserved - * 15 3 timer FreeRTOS Tick(L3) - * 16 5 timer - * 17 1 extern level - * 18 1 extern level - * 19 2 extern level - * 20 2 extern level - * 21 2 extern level - * 22 3 extern edge - * 23 3 extern level - * 24 4 extern level TG1_WDT - * 25 4 extern level CACHEERR - * 26 5 extern level - * 27 3 extern level Reserved - * 28 4 extern edge Reserved - * 29 3 software Reserved - * 30 4 extern edge Reserved - * 31 5 extern level - ************************************************************************************************************* - */ - -//CPU0 Interrupt number reserved, not touch this. -#define ETS_WMAC_INUM 1 -//#define ETS_BT_HOST_INUM 1 -#define ETS_WBB_INUM 4 -#define ETS_SYSTICK_INUM 9 -#define ETS_TG0_T1_INUM 10 /* use edge interrupt */ -#define ETS_CPU_INTR0_INUM 12 /* used as freertos soft intr */ -#define ETS_FRC1_INUM 22 +//On RISC-V CPUs, the interrupt sources are all external interrupts, whose type, source and priority are configured by SW. +//There is no HW NMI conception. SW should controlled the masked levels through INT_THRESH_REG. + +//CPU0 Interrupt number reserved in riscv/vector.S, not touch this. #define ETS_T1_WDT_INUM 24 #define ETS_CACHEERR_INUM 25 #define ETS_MEMPROT_ERR_INUM 26 -#define ETS_DPORT_INUM 28 - //CPU0 Max valid interrupt number #define ETS_MAX_INUM 31 diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/soc_caps.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/soc_caps.h index 65a923d26cc..0406c5665af 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/soc_caps.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/soc_caps.h @@ -6,6 +6,7 @@ #pragma once #define SOC_CPU_CORES_NUM 1 +#define SOC_DEDICATED_GPIO_SUPPORTED 1 #define SOC_GDMA_SUPPORTED 1 #define SOC_TWAI_SUPPORTED 1 #define SOC_BT_SUPPORTED 1 @@ -14,7 +15,9 @@ #define SOC_ASYNC_MEMCPY_SUPPORTED 1 #define SOC_USB_SERIAL_JTAG_SUPPORTED 1 #define SOC_TEMP_SENSOR_SUPPORTED 1 -#define SOC_FLASH_ENCRYPTION_XTS_AES 1 +#define SOC_FLASH_ENCRYPTION_XTS_AES 1 +#define SOC_XT_WDT_SUPPORTED 1 + /*-------------------------- COMMON CAPS ---------------------------------------*/ #define SOC_SUPPORTS_SECURE_DL_MODE 1 @@ -32,19 +35,31 @@ #define SOC_AES_SUPPORT_AES_256 (1) /*-------------------------- ADC CAPS -------------------------------*/ +/*!< SAR ADC Module*/ +#define SOC_ADC_ARBITER_SUPPORTED 1 +#define SOC_ADC_FILTER_SUPPORTED 1 +#define SOC_ADC_MONITOR_SUPPORTED 1 #define SOC_ADC_PERIPH_NUM (2) -#define SOC_ADC_PATT_LEN_MAX (16) #define SOC_ADC_CHANNEL_NUM(PERIPH_NUM) ((PERIPH_NUM==0)? 5 : 1) #define SOC_ADC_MAX_CHANNEL_NUM (5) -#define SOC_ADC_MAX_BITWIDTH (12) + +/*!< Digital */ +#define SOC_ADC_DIGI_CONTROLLER_NUM (1) +#define SOC_ADC_PATT_LEN_MAX (8) /*!< One pattern table, each contains 8 items. Each item takes 1 byte */ +#define SOC_ADC_DIGI_MAX_BITWIDTH (12) #define SOC_ADC_DIGI_FILTER_NUM (2) #define SOC_ADC_DIGI_MONITOR_NUM (2) -#define SOC_ADC_HW_CALIBRATION_V1 (1) /*!< support HW offset calibration */ -#define SOC_ADC_SUPPORT_DMA_MODE(PERIPH_NUM) 1 -//F_sample = F_digi_con / 2 / interval. F_digi_con = 5M for now. 30 <= interva <= 4095 +/*!< F_sample = F_digi_con / 2 / interval. F_digi_con = 5M for now. 30 <= interva <= 4095 */ #define SOC_ADC_SAMPLE_FREQ_THRES_HIGH 83333 #define SOC_ADC_SAMPLE_FREQ_THRES_LOW 611 +/*!< RTC */ +#define SOC_ADC_MAX_BITWIDTH (12) + +/*!< Calibration */ +#define SOC_ADC_CALIBRATION_V1_SUPPORTED (1) /*!< support HW offset calibration version 1*/ + + /*-------------------------- APB BACKUP DMA CAPS -------------------------------*/ #define SOC_APB_BACKUP_DMA (1) @@ -94,6 +109,11 @@ // Support to configure sleep status #define SOC_GPIO_SUPPORT_SLP_SWITCH (1) +/*-------------------------- Dedicated GPIO CAPS -----------------------------*/ +#define SOC_DEDIC_GPIO_OUT_CHANNELS_NUM (8) /*!< 8 outward channels on each CPU core */ +#define SOC_DEDIC_GPIO_IN_CHANNELS_NUM (8) /*!< 8 inward channels on each CPU core */ +#define SOC_DEDIC_PERIPH_AUTO_ENABLE (1) /*!< The dedicated GPIO peripheral is enabled automatically */ + /*-------------------------- I2C CAPS ----------------------------------------*/ // ESP32-C3 have 2 I2C. #define SOC_I2C_NUM (1) @@ -108,11 +128,10 @@ /*-------------------------- I2S CAPS ----------------------------------------*/ #define SOC_I2S_NUM (1) - -#define SOC_I2S_APLL_MIN_FREQ (250000000) -#define SOC_I2S_APLL_MAX_FREQ (500000000) -#define SOC_I2S_APLL_MIN_RATE (10675) //in Hz, I2S Clock rate limited by hardware -#define SOC_I2S_MAX_BUFFER_SIZE (4 * 1024 * 1024) //the maximum RAM can be allocated +#define SOC_I2S_SUPPORTS_PCM (1) +#define SOC_I2S_SUPPORTS_PDM_TX (1) +#define SOC_I2S_SUPPORTS_PDM_CODEC (1) +#define SOC_I2S_SUPPORTS_TDM (1) /*-------------------------- LEDC CAPS ---------------------------------------*/ #define SOC_LEDC_SUPPORT_XTAL_CLOCK (1) @@ -239,7 +258,6 @@ /*-------------------------- UART CAPS ---------------------------------------*/ // ESP32-C3 has 2 UARTs #define SOC_UART_NUM (2) - #define SOC_UART_FIFO_LEN (128) /*!< The UART hardware FIFO length */ #define SOC_UART_BITRATE_MAX (5000000) /*!< Max bit rate supported by UART */ diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/spi_mem_struct.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/spi_mem_struct.h index e0f62b0d155..cde08c0207d 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/spi_mem_struct.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/spi_mem_struct.h @@ -17,7 +17,7 @@ extern "C" { #endif -typedef volatile struct { +typedef volatile struct spi_mem_dev_s { union { struct { uint32_t mst_st: 4; /*The current status of SPI1 master FSM.*/ diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/spi_struct.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/spi_struct.h index cc22595dd0e..4011c8fed90 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/spi_struct.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/spi_struct.h @@ -19,7 +19,7 @@ extern "C" { #endif -typedef volatile struct { +typedef volatile struct spi_dev_s { union { struct { uint32_t conf_bitlen : 18; /*Define the APB cycles of SPI_CONF state. Can be configured in CONF state.*/ diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/syscon_struct.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/syscon_struct.h index 2a9485aa87b..b8afdf6ec8b 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/syscon_struct.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/syscon_struct.h @@ -17,26 +17,26 @@ extern "C" { #endif -typedef volatile struct { +typedef volatile struct syscon_dev_s { union { struct { - uint32_t apb_ctrl_pre_div_cnt: 10; - uint32_t apb_ctrl_clk_320m_en: 1; - uint32_t clk_en: 1; - uint32_t apb_ctrl_rst_tick_cnt: 1; - uint32_t reserved13: 19; + uint32_t pre_div_cnt: 10; + uint32_t clk_320m_en: 1; + uint32_t clk_en: 1; + uint32_t rst_tick_cnt: 1; + uint32_t reserved13: 19; }; uint32_t val; - } apb_ctrl_sysclk_conf; + } sysclk_conf; union { struct { - uint32_t apb_ctrl_xtal_tick_num: 8; - uint32_t apb_ctrl_ck8m_tick_num: 8; - uint32_t apb_ctrl_tick_enable: 1; - uint32_t reserved17: 15; + uint32_t xtal_tick_num: 8; + uint32_t ck8m_tick_num: 8; + uint32_t tick_enable: 1; + uint32_t reserved17: 15; }; uint32_t val; - } apb_ctrl_tick_conf; + } tick_conf; union { struct { uint32_t clk20_oen: 1; @@ -53,7 +53,7 @@ typedef volatile struct { uint32_t reserved11: 21; }; uint32_t val; - } apb_ctrl_clk_out_en; + } clk_out_en; uint32_t wifi_bb_cfg; /**/ uint32_t wifi_bb_cfg_2; /**/ uint32_t wifi_clk_en; /**/ @@ -161,7 +161,7 @@ typedef volatile struct { uint32_t reserved1: 31; }; uint32_t val; - } apb_ctrl_sdio_ctrl; + } sdio_ctrl; union { struct { uint32_t redcy_sig0: 31; @@ -472,7 +472,7 @@ typedef volatile struct { uint32_t reserved_3f0; uint32_t reserved_3f4; uint32_t reserved_3f8; - uint32_t apb_ctrl_date; /*Version control*/ + uint32_t date; /*Version control*/ } syscon_dev_t; extern syscon_dev_t SYSCON; #ifdef __cplusplus diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/system_struct.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/system_struct.h index f07fab0affb..5e04cec828b 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/system_struct.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/system_struct.h @@ -20,7 +20,7 @@ extern "C" { #endif #include "soc.h" -typedef volatile struct { +typedef volatile struct system_dev_s { union { struct { uint32_t reserved0 : 6; /*reserved*/ diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/systimer_struct.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/systimer_struct.h index af41b1f3e22..f10bc1f126c 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/systimer_struct.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/systimer_struct.h @@ -88,6 +88,7 @@ typedef union { * update timer_unit0 */ uint32_t timer_unit_update: 1; + uint32_t reserved31: 1; }; uint32_t val; } systimer_unit_op_reg_t; @@ -102,6 +103,7 @@ typedef struct { * timer unit load high 32 bit */ uint32_t timer_unit_load_hi: 20; + uint32_t reserved20: 12; }; uint32_t val; } hi; @@ -126,6 +128,7 @@ typedef struct { * timer target high 32 bit */ uint32_t timer_target_hi: 20; + uint32_t reserved20: 12; }; uint32_t val; } hi; @@ -172,6 +175,7 @@ typedef struct { * timer read value high 20bit */ uint32_t timer_unit_value_hi: 20; + uint32_t reserved20: 12; }; uint32_t val; } hi; @@ -195,6 +199,7 @@ typedef union { * timer comp load value */ uint32_t timer_comp_load: 1; + uint32_t reserved1: 31; }; uint32_t val; } systimer_comp_load_reg_t; @@ -208,6 +213,7 @@ typedef union { * timer unit load value */ uint32_t timer_unit_load: 1; + uint32_t reserved1: 31; }; uint32_t val; } systimer_unit_load_reg_t; @@ -230,6 +236,7 @@ typedef union { * interupt2 enable */ uint32_t target2_int_ena: 1; + uint32_t reserved3: 29; }; uint32_t val; } systimer_int_ena_reg_t; @@ -251,6 +258,7 @@ typedef union { * interupt2 raw */ uint32_t target2_int_raw: 1; + uint32_t reserved3: 29; }; uint32_t val; } systimer_int_raw_reg_t; @@ -272,6 +280,7 @@ typedef union { * interupt2 clear */ uint32_t target2_int_clr: 1; + uint32_t reserved3: 29; }; uint32_t val; } systimer_int_clr_reg_t; @@ -293,6 +302,7 @@ typedef union { * reg_target2_int_st */ uint32_t target2_int_st: 1; + uint32_t reserved3: 29; }; uint32_t val; } systimer_int_st_reg_t; diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/timer_group_reg.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/timer_group_reg.h index 05ae6fb42ea..4d591035fc8 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/timer_group_reg.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/timer_group_reg.h @@ -1,24 +1,17 @@ -// Copyright 2020 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 _SOC_TIMG_REG_H_ -#define _SOC_TIMG_REG_H_ - - +/** + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#pragma once + +#include +#include "soc/soc.h" #ifdef __cplusplus extern "C" { #endif -#include "soc.h" + +#define DR_REG_TIMG_BASE(i) REG_TIMG_BASE(i) /* The value that needs to be written to TIMG_WDT_WKEY to write-enable the wdt registers */ #define TIMG_WDT_WKEY_VALUE 0x50D83AA1 @@ -29,413 +22,559 @@ extern "C" { #define TIMG_WDT_STG_SEL_RESET_CPU 2 #define TIMG_WDT_STG_SEL_RESET_SYSTEM 3 -#define TIMG_WDT_RESET_LENGTH_100_NS 0 -#define TIMG_WDT_RESET_LENGTH_200_NS 1 -#define TIMG_WDT_RESET_LENGTH_300_NS 2 -#define TIMG_WDT_RESET_LENGTH_400_NS 3 -#define TIMG_WDT_RESET_LENGTH_500_NS 4 -#define TIMG_WDT_RESET_LENGTH_800_NS 5 -#define TIMG_WDT_RESET_LENGTH_1600_NS 6 -#define TIMG_WDT_RESET_LENGTH_3200_NS 7 - -#define TIMG_T0CONFIG_REG(i) (REG_TIMG_BASE(i) + 0x0000) -/* TIMG_T0_EN : R/W ;bitpos:[31] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_T0_EN (BIT(31)) -#define TIMG_T0_EN_M (BIT(31)) -#define TIMG_T0_EN_V 0x1 -#define TIMG_T0_EN_S 31 -/* TIMG_T0_INCREASE : R/W ;bitpos:[30] ;default: 1'h1 ; */ -/*description: */ -#define TIMG_T0_INCREASE (BIT(30)) -#define TIMG_T0_INCREASE_M (BIT(30)) -#define TIMG_T0_INCREASE_V 0x1 -#define TIMG_T0_INCREASE_S 30 -/* TIMG_T0_AUTORELOAD : R/W ;bitpos:[29] ;default: 1'h1 ; */ -/*description: */ -#define TIMG_T0_AUTORELOAD (BIT(29)) -#define TIMG_T0_AUTORELOAD_M (BIT(29)) -#define TIMG_T0_AUTORELOAD_V 0x1 -#define TIMG_T0_AUTORELOAD_S 29 -/* TIMG_T0_DIVIDER : R/W ;bitpos:[28:13] ;default: 16'h1 ; */ -/*description: */ -#define TIMG_T0_DIVIDER 0x0000FFFF -#define TIMG_T0_DIVIDER_M ((TIMG_T0_DIVIDER_V)<<(TIMG_T0_DIVIDER_S)) -#define TIMG_T0_DIVIDER_V 0xFFFF -#define TIMG_T0_DIVIDER_S 13 -/* TIMG_T0_DIVCNT_RST : WT ;bitpos:[12] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_T0_DIVCNT_RST (BIT(12)) -#define TIMG_T0_DIVCNT_RST_M (BIT(12)) -#define TIMG_T0_DIVCNT_RST_V 0x1 -#define TIMG_T0_DIVCNT_RST_S 12 -/* TIMG_T0_ALARM_EN : R/W/SC ;bitpos:[10] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_T0_ALARM_EN (BIT(10)) -#define TIMG_T0_ALARM_EN_M (BIT(10)) -#define TIMG_T0_ALARM_EN_V 0x1 -#define TIMG_T0_ALARM_EN_S 10 -/* TIMG_T0_USE_XTAL : R/W ;bitpos:[9] ;default: 1'd0 ; */ -/*description: */ -#define TIMG_T0_USE_XTAL (BIT(9)) -#define TIMG_T0_USE_XTAL_M (BIT(9)) -#define TIMG_T0_USE_XTAL_V 0x1 +/* Possible values for TIMG_WDT_CPU_RESET_LENGTH and TIMG_WDT_SYS_RESET_LENGTH */ +#define TIMG_WDT_RESET_LENGTH_100_NS 0 +#define TIMG_WDT_RESET_LENGTH_200_NS 1 +#define TIMG_WDT_RESET_LENGTH_300_NS 2 +#define TIMG_WDT_RESET_LENGTH_400_NS 3 +#define TIMG_WDT_RESET_LENGTH_500_NS 4 +#define TIMG_WDT_RESET_LENGTH_800_NS 5 +#define TIMG_WDT_RESET_LENGTH_1600_NS 6 +#define TIMG_WDT_RESET_LENGTH_3200_NS 7 + +/** TIMG_T0CONFIG_REG register + * Timer 0 configuration register + */ +#define TIMG_T0CONFIG_REG(i) (DR_REG_TIMG_BASE(i) + 0x0) +/** TIMG_T0_USE_XTAL : R/W; bitpos: [9]; default: 0; + * 1: Use XTAL_CLK as the source clock of timer group. 0: Use APB_CLK as the source + * clock of timer group. + */ +#define TIMG_T0_USE_XTAL (BIT(9)) +#define TIMG_T0_USE_XTAL_M (TIMG_T0_USE_XTAL_V << TIMG_T0_USE_XTAL_S) +#define TIMG_T0_USE_XTAL_V 0x00000001U #define TIMG_T0_USE_XTAL_S 9 +/** TIMG_T0_ALARM_EN : R/W/SC; bitpos: [10]; default: 0; + * When set, the alarm is enabled. This bit is automatically cleared once an + * alarm occurs. + */ +#define TIMG_T0_ALARM_EN (BIT(10)) +#define TIMG_T0_ALARM_EN_M (TIMG_T0_ALARM_EN_V << TIMG_T0_ALARM_EN_S) +#define TIMG_T0_ALARM_EN_V 0x00000001U +#define TIMG_T0_ALARM_EN_S 10 +/** TIMG_T0_DIVCNT_RST : WT; bitpos: [12]; default: 0; + * When set, Timer 0 's clock divider counter will be reset. + */ +#define TIMG_T0_DIVCNT_RST (BIT(12)) +#define TIMG_T0_DIVCNT_RST_M (TIMG_T0_DIVCNT_RST_V << TIMG_T0_DIVCNT_RST_S) +#define TIMG_T0_DIVCNT_RST_V 0x00000001U +#define TIMG_T0_DIVCNT_RST_S 12 +/** TIMG_T0_DIVIDER : R/W; bitpos: [28:13]; default: 1; + * Timer 0 clock (T0_clk) prescaler value. + */ +#define TIMG_T0_DIVIDER 0x0000FFFFU +#define TIMG_T0_DIVIDER_M (TIMG_T0_DIVIDER_V << TIMG_T0_DIVIDER_S) +#define TIMG_T0_DIVIDER_V 0x0000FFFFU +#define TIMG_T0_DIVIDER_S 13 +/** TIMG_T0_AUTORELOAD : R/W; bitpos: [29]; default: 1; + * When set, timer 0 auto-reload at alarm is enabled. + */ +#define TIMG_T0_AUTORELOAD (BIT(29)) +#define TIMG_T0_AUTORELOAD_M (TIMG_T0_AUTORELOAD_V << TIMG_T0_AUTORELOAD_S) +#define TIMG_T0_AUTORELOAD_V 0x00000001U +#define TIMG_T0_AUTORELOAD_S 29 +/** TIMG_T0_INCREASE : R/W; bitpos: [30]; default: 1; + * When set, the timer 0 time-base counter will increment every clock tick. When + * cleared, the timer 0 time-base counter will decrement. + */ +#define TIMG_T0_INCREASE (BIT(30)) +#define TIMG_T0_INCREASE_M (TIMG_T0_INCREASE_V << TIMG_T0_INCREASE_S) +#define TIMG_T0_INCREASE_V 0x00000001U +#define TIMG_T0_INCREASE_S 30 +/** TIMG_T0_EN : R/W; bitpos: [31]; default: 0; + * When set, the timer 0 time-base counter is enabled. + */ +#define TIMG_T0_EN (BIT(31)) +#define TIMG_T0_EN_M (TIMG_T0_EN_V << TIMG_T0_EN_S) +#define TIMG_T0_EN_V 0x00000001U +#define TIMG_T0_EN_S 31 -#define TIMG_T0LO_REG(i) (REG_TIMG_BASE(i) + 0x0004) -/* TIMG_T0_LO : RO ;bitpos:[31:0] ;default: 32'h0 ; */ -/*description: */ -#define TIMG_T0_LO 0xFFFFFFFF -#define TIMG_T0_LO_M ((TIMG_T0_LO_V)<<(TIMG_T0_LO_S)) -#define TIMG_T0_LO_V 0xFFFFFFFF +/** TIMG_T0LO_REG register + * Timer 0 current value, low 32 bits + */ +#define TIMG_T0LO_REG(i) (DR_REG_TIMG_BASE(i) + 0x4) +/** TIMG_T0_LO : RO; bitpos: [31:0]; default: 0; + * After writing to TIMG_T0UPDATE_REG, the low 32 bits of the time-base counter + * of timer 0 can be read here. + */ +#define TIMG_T0_LO 0xFFFFFFFFU +#define TIMG_T0_LO_M (TIMG_T0_LO_V << TIMG_T0_LO_S) +#define TIMG_T0_LO_V 0xFFFFFFFFU #define TIMG_T0_LO_S 0 -#define TIMG_T0HI_REG(i) (REG_TIMG_BASE(i) + 0x0008) -/* TIMG_T0_HI : RO ;bitpos:[21:0] ;default: 22'h0 ; */ -/*description: */ -#define TIMG_T0_HI 0x003FFFFF -#define TIMG_T0_HI_M ((TIMG_T0_HI_V)<<(TIMG_T0_HI_S)) -#define TIMG_T0_HI_V 0x3FFFFF +/** TIMG_T0HI_REG register + * Timer $x current value, high 22 bits + */ +#define TIMG_T0HI_REG(i) (DR_REG_TIMG_BASE(i) + 0x8) +/** TIMG_T0_HI : RO; bitpos: [21:0]; default: 0; + * After writing to TIMG_T$xUPDATE_REG, the high 22 bits of the time-base counter + * of timer $x can be read here. + */ +#define TIMG_T0_HI 0x003FFFFFU +#define TIMG_T0_HI_M (TIMG_T0_HI_V << TIMG_T0_HI_S) +#define TIMG_T0_HI_V 0x003FFFFFU #define TIMG_T0_HI_S 0 -#define TIMG_T0UPDATE_REG(i) (REG_TIMG_BASE(i) + 0x000c) -/* TIMG_T0_UPDATE : R/W/SC ;bitpos:[31] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_T0_UPDATE (BIT(31)) -#define TIMG_T0_UPDATE_M (BIT(31)) -#define TIMG_T0_UPDATE_V 0x1 +/** TIMG_T0UPDATE_REG register + * Write to copy current timer value to TIMGn_T$x_(LO/HI)_REG + */ +#define TIMG_T0UPDATE_REG(i) (DR_REG_TIMG_BASE(i) + 0xc) +/** TIMG_T0_UPDATE : R/W/SC; bitpos: [31]; default: 0; + * After writing 0 or 1 to TIMG_T$xUPDATE_REG, the counter value is latched. + */ +#define TIMG_T0_UPDATE (BIT(31)) +#define TIMG_T0_UPDATE_M (TIMG_T0_UPDATE_V << TIMG_T0_UPDATE_S) +#define TIMG_T0_UPDATE_V 0x00000001U #define TIMG_T0_UPDATE_S 31 -#define TIMG_T0ALARMLO_REG(i) (REG_TIMG_BASE(i) + 0x0010) -/* TIMG_T0_ALARM_LO : R/W ;bitpos:[31:0] ;default: 32'h0 ; */ -/*description: */ -#define TIMG_T0_ALARM_LO 0xFFFFFFFF -#define TIMG_T0_ALARM_LO_M ((TIMG_T0_ALARM_LO_V)<<(TIMG_T0_ALARM_LO_S)) -#define TIMG_T0_ALARM_LO_V 0xFFFFFFFF +/** TIMG_T0ALARMLO_REG register + * Timer $x alarm value, low 32 bits + */ +#define TIMG_T0ALARMLO_REG(i) (DR_REG_TIMG_BASE(i) + 0x10) +/** TIMG_T0_ALARM_LO : R/W; bitpos: [31:0]; default: 0; + * Timer $x alarm trigger time-base counter value, low 32 bits. + */ +#define TIMG_T0_ALARM_LO 0xFFFFFFFFU +#define TIMG_T0_ALARM_LO_M (TIMG_T0_ALARM_LO_V << TIMG_T0_ALARM_LO_S) +#define TIMG_T0_ALARM_LO_V 0xFFFFFFFFU #define TIMG_T0_ALARM_LO_S 0 -#define TIMG_T0ALARMHI_REG(i) (REG_TIMG_BASE(i) + 0x0014) -/* TIMG_T0_ALARM_HI : R/W ;bitpos:[21:0] ;default: 22'h0 ; */ -/*description: */ -#define TIMG_T0_ALARM_HI 0x003FFFFF -#define TIMG_T0_ALARM_HI_M ((TIMG_T0_ALARM_HI_V)<<(TIMG_T0_ALARM_HI_S)) -#define TIMG_T0_ALARM_HI_V 0x3FFFFF +/** TIMG_T0ALARMHI_REG register + * Timer $x alarm value, high bits + */ +#define TIMG_T0ALARMHI_REG(i) (DR_REG_TIMG_BASE(i) + 0x14) +/** TIMG_T0_ALARM_HI : R/W; bitpos: [21:0]; default: 0; + * Timer $x alarm trigger time-base counter value, high 22 bits. + */ +#define TIMG_T0_ALARM_HI 0x003FFFFFU +#define TIMG_T0_ALARM_HI_M (TIMG_T0_ALARM_HI_V << TIMG_T0_ALARM_HI_S) +#define TIMG_T0_ALARM_HI_V 0x003FFFFFU #define TIMG_T0_ALARM_HI_S 0 -#define TIMG_T0LOADLO_REG(i) (REG_TIMG_BASE(i) + 0x0018) -/* TIMG_T0_LOAD_LO : R/W ;bitpos:[31:0] ;default: 32'h0 ; */ -/*description: */ -#define TIMG_T0_LOAD_LO 0xFFFFFFFF -#define TIMG_T0_LOAD_LO_M ((TIMG_T0_LOAD_LO_V)<<(TIMG_T0_LOAD_LO_S)) -#define TIMG_T0_LOAD_LO_V 0xFFFFFFFF +/** TIMG_T0LOADLO_REG register + * Timer $x reload value, low 32 bits + */ +#define TIMG_T0LOADLO_REG(i) (DR_REG_TIMG_BASE(i) + 0x18) +/** TIMG_T0_LOAD_LO : R/W; bitpos: [31:0]; default: 0; + * Low 32 bits of the value that a reload will load onto timer $x time-base + * Counter. + */ +#define TIMG_T0_LOAD_LO 0xFFFFFFFFU +#define TIMG_T0_LOAD_LO_M (TIMG_T0_LOAD_LO_V << TIMG_T0_LOAD_LO_S) +#define TIMG_T0_LOAD_LO_V 0xFFFFFFFFU #define TIMG_T0_LOAD_LO_S 0 -#define TIMG_T0LOADHI_REG(i) (REG_TIMG_BASE(i) + 0x001c) -/* TIMG_T0_LOAD_HI : R/W ;bitpos:[21:0] ;default: 22'h0 ; */ -/*description: */ -#define TIMG_T0_LOAD_HI 0x003FFFFF -#define TIMG_T0_LOAD_HI_M ((TIMG_T0_LOAD_HI_V)<<(TIMG_T0_LOAD_HI_S)) -#define TIMG_T0_LOAD_HI_V 0x3FFFFF +/** TIMG_T0LOADHI_REG register + * Timer $x reload value, high 22 bits + */ +#define TIMG_T0LOADHI_REG(i) (DR_REG_TIMG_BASE(i) + 0x1c) +/** TIMG_T0_LOAD_HI : R/W; bitpos: [21:0]; default: 0; + * High 22 bits of the value that a reload will load onto timer $x time-base + * counter. + */ +#define TIMG_T0_LOAD_HI 0x003FFFFFU +#define TIMG_T0_LOAD_HI_M (TIMG_T0_LOAD_HI_V << TIMG_T0_LOAD_HI_S) +#define TIMG_T0_LOAD_HI_V 0x003FFFFFU #define TIMG_T0_LOAD_HI_S 0 -#define TIMG_T0LOAD_REG(i) (REG_TIMG_BASE(i) + 0x0020) -/* TIMG_T0_LOAD : WT ;bitpos:[31:0] ;default: 32'h0 ; */ -/*description: */ -#define TIMG_T0_LOAD 0xFFFFFFFF -#define TIMG_T0_LOAD_M ((TIMG_T0_LOAD_V)<<(TIMG_T0_LOAD_S)) -#define TIMG_T0_LOAD_V 0xFFFFFFFF +/** TIMG_T0LOAD_REG register + * Write to reload timer from TIMG_T$x_(LOADLOLOADHI)_REG + */ +#define TIMG_T0LOAD_REG(i) (DR_REG_TIMG_BASE(i) + 0x20) +/** TIMG_T0_LOAD : WT; bitpos: [31:0]; default: 0; + * + * Write any value to trigger a timer $x time-base counter reload. + */ +#define TIMG_T0_LOAD 0xFFFFFFFFU +#define TIMG_T0_LOAD_M (TIMG_T0_LOAD_V << TIMG_T0_LOAD_S) +#define TIMG_T0_LOAD_V 0xFFFFFFFFU #define TIMG_T0_LOAD_S 0 -#define TIMG_WDTCONFIG0_REG(i) (REG_TIMG_BASE(i) + 0x0048) -/* TIMG_WDT_EN : R/W ;bitpos:[31] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_WDT_EN (BIT(31)) -#define TIMG_WDT_EN_M (BIT(31)) -#define TIMG_WDT_EN_V 0x1 -#define TIMG_WDT_EN_S 31 -/* TIMG_WDT_STG0 : R/W ;bitpos:[30:29] ;default: 2'd0 ; */ -/*description: */ -#define TIMG_WDT_STG0 0x00000003 -#define TIMG_WDT_STG0_M ((TIMG_WDT_STG0_V)<<(TIMG_WDT_STG0_S)) -#define TIMG_WDT_STG0_V 0x3 -#define TIMG_WDT_STG0_S 29 -/* TIMG_WDT_STG1 : R/W ;bitpos:[28:27] ;default: 2'd0 ; */ -/*description: */ -#define TIMG_WDT_STG1 0x00000003 -#define TIMG_WDT_STG1_M ((TIMG_WDT_STG1_V)<<(TIMG_WDT_STG1_S)) -#define TIMG_WDT_STG1_V 0x3 -#define TIMG_WDT_STG1_S 27 -/* TIMG_WDT_STG2 : R/W ;bitpos:[26:25] ;default: 2'd0 ; */ -/*description: */ -#define TIMG_WDT_STG2 0x00000003 -#define TIMG_WDT_STG2_M ((TIMG_WDT_STG2_V)<<(TIMG_WDT_STG2_S)) -#define TIMG_WDT_STG2_V 0x3 -#define TIMG_WDT_STG2_S 25 -/* TIMG_WDT_STG3 : R/W ;bitpos:[24:23] ;default: 2'd0 ; */ -/*description: */ -#define TIMG_WDT_STG3 0x00000003 -#define TIMG_WDT_STG3_M ((TIMG_WDT_STG3_V)<<(TIMG_WDT_STG3_S)) -#define TIMG_WDT_STG3_V 0x3 -#define TIMG_WDT_STG3_S 23 -/* TIMG_WDT_CONF_UPDATE_EN : WT ;bitpos:[22] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_WDT_CONF_UPDATE_EN (BIT(22)) -#define TIMG_WDT_CONF_UPDATE_EN_M (BIT(22)) -#define TIMG_WDT_CONF_UPDATE_EN_V 0x1 -#define TIMG_WDT_CONF_UPDATE_EN_S 22 -/* TIMG_WDT_USE_XTAL : R/W ;bitpos:[21] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_WDT_USE_XTAL (BIT(21)) -#define TIMG_WDT_USE_XTAL_M (BIT(21)) -#define TIMG_WDT_USE_XTAL_V 0x1 -#define TIMG_WDT_USE_XTAL_S 21 -/* TIMG_WDT_CPU_RESET_LENGTH : R/W ;bitpos:[20:18] ;default: 3'h1 ; */ -/*description: */ -#define TIMG_WDT_CPU_RESET_LENGTH 0x00000007 -#define TIMG_WDT_CPU_RESET_LENGTH_M ((TIMG_WDT_CPU_RESET_LENGTH_V)<<(TIMG_WDT_CPU_RESET_LENGTH_S)) -#define TIMG_WDT_CPU_RESET_LENGTH_V 0x7 -#define TIMG_WDT_CPU_RESET_LENGTH_S 18 -/* TIMG_WDT_SYS_RESET_LENGTH : R/W ;bitpos:[17:15] ;default: 3'h1 ; */ -/*description: */ -#define TIMG_WDT_SYS_RESET_LENGTH 0x00000007 -#define TIMG_WDT_SYS_RESET_LENGTH_M ((TIMG_WDT_SYS_RESET_LENGTH_V)<<(TIMG_WDT_SYS_RESET_LENGTH_S)) -#define TIMG_WDT_SYS_RESET_LENGTH_V 0x7 -#define TIMG_WDT_SYS_RESET_LENGTH_S 15 -/* TIMG_WDT_FLASHBOOT_MOD_EN : R/W ;bitpos:[14] ;default: 1'h1 ; */ -/*description: */ -#define TIMG_WDT_FLASHBOOT_MOD_EN (BIT(14)) -#define TIMG_WDT_FLASHBOOT_MOD_EN_M (BIT(14)) -#define TIMG_WDT_FLASHBOOT_MOD_EN_V 0x1 -#define TIMG_WDT_FLASHBOOT_MOD_EN_S 14 -/* TIMG_WDT_PROCPU_RESET_EN : R/W ;bitpos:[13] ;default: 1'd0 ; */ -/*description: */ -#define TIMG_WDT_PROCPU_RESET_EN (BIT(13)) -#define TIMG_WDT_PROCPU_RESET_EN_M (BIT(13)) -#define TIMG_WDT_PROCPU_RESET_EN_V 0x1 -#define TIMG_WDT_PROCPU_RESET_EN_S 13 -/* TIMG_WDT_APPCPU_RESET_EN : R/W ;bitpos:[12] ;default: 1'd0 ; */ -/*description: */ -#define TIMG_WDT_APPCPU_RESET_EN (BIT(12)) -#define TIMG_WDT_APPCPU_RESET_EN_M (BIT(12)) -#define TIMG_WDT_APPCPU_RESET_EN_V 0x1 +/** TIMG_WDTCONFIG0_REG register + * Watchdog timer configuration register + */ +#define TIMG_WDTCONFIG0_REG(i) (DR_REG_TIMG_BASE(i) + 0x48) +/** TIMG_WDT_APPCPU_RESET_EN : R/W; bitpos: [12]; default: 0; + * WDT reset CPU enable. + */ +#define TIMG_WDT_APPCPU_RESET_EN (BIT(12)) +#define TIMG_WDT_APPCPU_RESET_EN_M (TIMG_WDT_APPCPU_RESET_EN_V << TIMG_WDT_APPCPU_RESET_EN_S) +#define TIMG_WDT_APPCPU_RESET_EN_V 0x00000001U #define TIMG_WDT_APPCPU_RESET_EN_S 12 +/** TIMG_WDT_PROCPU_RESET_EN : R/W; bitpos: [13]; default: 0; + * WDT reset CPU enable. + */ +#define TIMG_WDT_PROCPU_RESET_EN (BIT(13)) +#define TIMG_WDT_PROCPU_RESET_EN_M (TIMG_WDT_PROCPU_RESET_EN_V << TIMG_WDT_PROCPU_RESET_EN_S) +#define TIMG_WDT_PROCPU_RESET_EN_V 0x00000001U +#define TIMG_WDT_PROCPU_RESET_EN_S 13 +/** TIMG_WDT_FLASHBOOT_MOD_EN : R/W; bitpos: [14]; default: 1; + * When set, Flash boot protection is enabled. + */ +#define TIMG_WDT_FLASHBOOT_MOD_EN (BIT(14)) +#define TIMG_WDT_FLASHBOOT_MOD_EN_M (TIMG_WDT_FLASHBOOT_MOD_EN_V << TIMG_WDT_FLASHBOOT_MOD_EN_S) +#define TIMG_WDT_FLASHBOOT_MOD_EN_V 0x00000001U +#define TIMG_WDT_FLASHBOOT_MOD_EN_S 14 +/** TIMG_WDT_SYS_RESET_LENGTH : R/W; bitpos: [17:15]; default: 1; + * System reset signal length selection. 0: 100 ns, 1: 200 ns, + * 2: 300 ns, 3: 400 ns, 4: 500 ns, 5: 800 ns, 6: 1.6 us, 7: 3.2 us. + */ +#define TIMG_WDT_SYS_RESET_LENGTH 0x00000007U +#define TIMG_WDT_SYS_RESET_LENGTH_M (TIMG_WDT_SYS_RESET_LENGTH_V << TIMG_WDT_SYS_RESET_LENGTH_S) +#define TIMG_WDT_SYS_RESET_LENGTH_V 0x00000007U +#define TIMG_WDT_SYS_RESET_LENGTH_S 15 +/** TIMG_WDT_CPU_RESET_LENGTH : R/W; bitpos: [20:18]; default: 1; + * CPU reset signal length selection. 0: 100 ns, 1: 200 ns, + * 2: 300 ns, 3: 400 ns, 4: 500 ns, 5: 800 ns, 6: 1.6 us, 7: 3.2 us. + */ +#define TIMG_WDT_CPU_RESET_LENGTH 0x00000007U +#define TIMG_WDT_CPU_RESET_LENGTH_M (TIMG_WDT_CPU_RESET_LENGTH_V << TIMG_WDT_CPU_RESET_LENGTH_S) +#define TIMG_WDT_CPU_RESET_LENGTH_V 0x00000007U +#define TIMG_WDT_CPU_RESET_LENGTH_S 18 +/** TIMG_WDT_USE_XTAL : R/W; bitpos: [21]; default: 0; + * choose WDT clock:0-apb_clk; 1-xtal_clk. + */ +#define TIMG_WDT_USE_XTAL (BIT(21)) +#define TIMG_WDT_USE_XTAL_M (TIMG_WDT_USE_XTAL_V << TIMG_WDT_USE_XTAL_S) +#define TIMG_WDT_USE_XTAL_V 0x00000001U +#define TIMG_WDT_USE_XTAL_S 21 +/** TIMG_WDT_CONF_UPDATE_EN : WT; bitpos: [22]; default: 0; + * update the WDT configuration registers + */ +#define TIMG_WDT_CONF_UPDATE_EN (BIT(22)) +#define TIMG_WDT_CONF_UPDATE_EN_M (TIMG_WDT_CONF_UPDATE_EN_V << TIMG_WDT_CONF_UPDATE_EN_S) +#define TIMG_WDT_CONF_UPDATE_EN_V 0x00000001U +#define TIMG_WDT_CONF_UPDATE_EN_S 22 +/** TIMG_WDT_STG3 : R/W; bitpos: [24:23]; default: 0; + * Stage 3 configuration. 0: off, 1: interrupt, 2: reset CPU, 3: reset system. + */ +#define TIMG_WDT_STG3 0x00000003U +#define TIMG_WDT_STG3_M (TIMG_WDT_STG3_V << TIMG_WDT_STG3_S) +#define TIMG_WDT_STG3_V 0x00000003U +#define TIMG_WDT_STG3_S 23 +/** TIMG_WDT_STG2 : R/W; bitpos: [26:25]; default: 0; + * Stage 2 configuration. 0: off, 1: interrupt, 2: reset CPU, 3: reset system. + */ +#define TIMG_WDT_STG2 0x00000003U +#define TIMG_WDT_STG2_M (TIMG_WDT_STG2_V << TIMG_WDT_STG2_S) +#define TIMG_WDT_STG2_V 0x00000003U +#define TIMG_WDT_STG2_S 25 +/** TIMG_WDT_STG1 : R/W; bitpos: [28:27]; default: 0; + * Stage 1 configuration. 0: off, 1: interrupt, 2: reset CPU, 3: reset system. + */ +#define TIMG_WDT_STG1 0x00000003U +#define TIMG_WDT_STG1_M (TIMG_WDT_STG1_V << TIMG_WDT_STG1_S) +#define TIMG_WDT_STG1_V 0x00000003U +#define TIMG_WDT_STG1_S 27 +/** TIMG_WDT_STG0 : R/W; bitpos: [30:29]; default: 0; + * Stage 0 configuration. 0: off, 1: interrupt, 2: reset CPU, 3: reset system. + */ +#define TIMG_WDT_STG0 0x00000003U +#define TIMG_WDT_STG0_M (TIMG_WDT_STG0_V << TIMG_WDT_STG0_S) +#define TIMG_WDT_STG0_V 0x00000003U +#define TIMG_WDT_STG0_S 29 +/** TIMG_WDT_EN : R/W; bitpos: [31]; default: 0; + * When set, MWDT is enabled. + */ +#define TIMG_WDT_EN (BIT(31)) +#define TIMG_WDT_EN_M (TIMG_WDT_EN_V << TIMG_WDT_EN_S) +#define TIMG_WDT_EN_V 0x00000001U +#define TIMG_WDT_EN_S 31 -#define TIMG_WDTCONFIG1_REG(i) (REG_TIMG_BASE(i) + 0x004c) -/* TIMG_WDT_CLK_PRESCALE : R/W ;bitpos:[31:16] ;default: 16'h1 ; */ -/*description: */ -#define TIMG_WDT_CLK_PRESCALE 0x0000FFFF -#define TIMG_WDT_CLK_PRESCALE_M ((TIMG_WDT_CLK_PRESCALE_V)<<(TIMG_WDT_CLK_PRESCALE_S)) -#define TIMG_WDT_CLK_PRESCALE_V 0xFFFF -#define TIMG_WDT_CLK_PRESCALE_S 16 -/* TIMG_WDT_DIVCNT_RST : WT ;bitpos:[0] ;default: 1'b0 ; */ -/*description: */ -#define TIMG_WDT_DIVCNT_RST (BIT(0)) -#define TIMG_WDT_DIVCNT_RST_M (BIT(0)) -#define TIMG_WDT_DIVCNT_RST_V 0x1 +/** TIMG_WDTCONFIG1_REG register + * Watchdog timer prescaler register + */ +#define TIMG_WDTCONFIG1_REG(i) (DR_REG_TIMG_BASE(i) + 0x4c) +/** TIMG_WDT_DIVCNT_RST : WT; bitpos: [0]; default: 0; + * When set, WDT 's clock divider counter will be reset. + */ +#define TIMG_WDT_DIVCNT_RST (BIT(0)) +#define TIMG_WDT_DIVCNT_RST_M (TIMG_WDT_DIVCNT_RST_V << TIMG_WDT_DIVCNT_RST_S) +#define TIMG_WDT_DIVCNT_RST_V 0x00000001U #define TIMG_WDT_DIVCNT_RST_S 0 +/** TIMG_WDT_CLK_PRESCALE : R/W; bitpos: [31:16]; default: 1; + * MWDT clock prescaler value. MWDT clock period = 12.5 ns * + * TIMG_WDT_CLK_PRESCALE. + */ +#define TIMG_WDT_CLK_PRESCALE 0x0000FFFFU +#define TIMG_WDT_CLK_PRESCALE_M (TIMG_WDT_CLK_PRESCALE_V << TIMG_WDT_CLK_PRESCALE_S) +#define TIMG_WDT_CLK_PRESCALE_V 0x0000FFFFU +#define TIMG_WDT_CLK_PRESCALE_S 16 -#define TIMG_WDTCONFIG2_REG(i) (REG_TIMG_BASE(i) + 0x0050) -/* TIMG_WDT_STG0_HOLD : R/W ;bitpos:[31:0] ;default: 32'd26000000 ; */ -/*description: */ -#define TIMG_WDT_STG0_HOLD 0xFFFFFFFF -#define TIMG_WDT_STG0_HOLD_M ((TIMG_WDT_STG0_HOLD_V)<<(TIMG_WDT_STG0_HOLD_S)) -#define TIMG_WDT_STG0_HOLD_V 0xFFFFFFFF +/** TIMG_WDTCONFIG2_REG register + * Watchdog timer stage 0 timeout value + */ +#define TIMG_WDTCONFIG2_REG(i) (DR_REG_TIMG_BASE(i) + 0x50) +/** TIMG_WDT_STG0_HOLD : R/W; bitpos: [31:0]; default: 26000000; + * Stage 0 timeout value, in MWDT clock cycles. + */ +#define TIMG_WDT_STG0_HOLD 0xFFFFFFFFU +#define TIMG_WDT_STG0_HOLD_M (TIMG_WDT_STG0_HOLD_V << TIMG_WDT_STG0_HOLD_S) +#define TIMG_WDT_STG0_HOLD_V 0xFFFFFFFFU #define TIMG_WDT_STG0_HOLD_S 0 -#define TIMG_WDTCONFIG3_REG(i) (REG_TIMG_BASE(i) + 0x0054) -/* TIMG_WDT_STG1_HOLD : R/W ;bitpos:[31:0] ;default: 32'h7ffffff ; */ -/*description: */ -#define TIMG_WDT_STG1_HOLD 0xFFFFFFFF -#define TIMG_WDT_STG1_HOLD_M ((TIMG_WDT_STG1_HOLD_V)<<(TIMG_WDT_STG1_HOLD_S)) -#define TIMG_WDT_STG1_HOLD_V 0xFFFFFFFF +/** TIMG_WDTCONFIG3_REG register + * Watchdog timer stage 1 timeout value + */ +#define TIMG_WDTCONFIG3_REG(i) (DR_REG_TIMG_BASE(i) + 0x54) +/** TIMG_WDT_STG1_HOLD : R/W; bitpos: [31:0]; default: 134217727; + * Stage 1 timeout value, in MWDT clock cycles. + */ +#define TIMG_WDT_STG1_HOLD 0xFFFFFFFFU +#define TIMG_WDT_STG1_HOLD_M (TIMG_WDT_STG1_HOLD_V << TIMG_WDT_STG1_HOLD_S) +#define TIMG_WDT_STG1_HOLD_V 0xFFFFFFFFU #define TIMG_WDT_STG1_HOLD_S 0 -#define TIMG_WDTCONFIG4_REG(i) (REG_TIMG_BASE(i) + 0x0058) -/* TIMG_WDT_STG2_HOLD : R/W ;bitpos:[31:0] ;default: 32'hfffff ; */ -/*description: */ -#define TIMG_WDT_STG2_HOLD 0xFFFFFFFF -#define TIMG_WDT_STG2_HOLD_M ((TIMG_WDT_STG2_HOLD_V)<<(TIMG_WDT_STG2_HOLD_S)) -#define TIMG_WDT_STG2_HOLD_V 0xFFFFFFFF +/** TIMG_WDTCONFIG4_REG register + * Watchdog timer stage 2 timeout value + */ +#define TIMG_WDTCONFIG4_REG(i) (DR_REG_TIMG_BASE(i) + 0x58) +/** TIMG_WDT_STG2_HOLD : R/W; bitpos: [31:0]; default: 1048575; + * Stage 2 timeout value, in MWDT clock cycles. + */ +#define TIMG_WDT_STG2_HOLD 0xFFFFFFFFU +#define TIMG_WDT_STG2_HOLD_M (TIMG_WDT_STG2_HOLD_V << TIMG_WDT_STG2_HOLD_S) +#define TIMG_WDT_STG2_HOLD_V 0xFFFFFFFFU #define TIMG_WDT_STG2_HOLD_S 0 -#define TIMG_WDTCONFIG5_REG(i) (REG_TIMG_BASE(i) + 0x005c) -/* TIMG_WDT_STG3_HOLD : R/W ;bitpos:[31:0] ;default: 32'hfffff ; */ -/*description: */ -#define TIMG_WDT_STG3_HOLD 0xFFFFFFFF -#define TIMG_WDT_STG3_HOLD_M ((TIMG_WDT_STG3_HOLD_V)<<(TIMG_WDT_STG3_HOLD_S)) -#define TIMG_WDT_STG3_HOLD_V 0xFFFFFFFF +/** TIMG_WDTCONFIG5_REG register + * Watchdog timer stage 3 timeout value + */ +#define TIMG_WDTCONFIG5_REG(i) (DR_REG_TIMG_BASE(i) + 0x5c) +/** TIMG_WDT_STG3_HOLD : R/W; bitpos: [31:0]; default: 1048575; + * Stage 3 timeout value, in MWDT clock cycles. + */ +#define TIMG_WDT_STG3_HOLD 0xFFFFFFFFU +#define TIMG_WDT_STG3_HOLD_M (TIMG_WDT_STG3_HOLD_V << TIMG_WDT_STG3_HOLD_S) +#define TIMG_WDT_STG3_HOLD_V 0xFFFFFFFFU #define TIMG_WDT_STG3_HOLD_S 0 -#define TIMG_WDTFEED_REG(i) (REG_TIMG_BASE(i) + 0x0060) -/* TIMG_WDT_FEED : WT ;bitpos:[31:0] ;default: 32'h0 ; */ -/*description: */ -#define TIMG_WDT_FEED 0xFFFFFFFF -#define TIMG_WDT_FEED_M ((TIMG_WDT_FEED_V)<<(TIMG_WDT_FEED_S)) -#define TIMG_WDT_FEED_V 0xFFFFFFFF +/** TIMG_WDTFEED_REG register + * Write to feed the watchdog timer + */ +#define TIMG_WDTFEED_REG(i) (DR_REG_TIMG_BASE(i) + 0x60) +/** TIMG_WDT_FEED : WT; bitpos: [31:0]; default: 0; + * Write any value to feed the MWDT. (WO) + */ +#define TIMG_WDT_FEED 0xFFFFFFFFU +#define TIMG_WDT_FEED_M (TIMG_WDT_FEED_V << TIMG_WDT_FEED_S) +#define TIMG_WDT_FEED_V 0xFFFFFFFFU #define TIMG_WDT_FEED_S 0 -#define TIMG_WDTWPROTECT_REG(i) (REG_TIMG_BASE(i) + 0x0064) -/* TIMG_WDT_WKEY : R/W ;bitpos:[31:0] ;default: 32'h50d83aa1 ; */ -/*description: */ -#define TIMG_WDT_WKEY 0xFFFFFFFF -#define TIMG_WDT_WKEY_M ((TIMG_WDT_WKEY_V)<<(TIMG_WDT_WKEY_S)) -#define TIMG_WDT_WKEY_V 0xFFFFFFFF +/** TIMG_WDTWPROTECT_REG register + * Watchdog write protect register + */ +#define TIMG_WDTWPROTECT_REG(i) (DR_REG_TIMG_BASE(i) + 0x64) +/** TIMG_WDT_WKEY : R/W; bitpos: [31:0]; default: 1356348065; + * If the register contains a different value than its reset value, write + * protection is enabled. + */ +#define TIMG_WDT_WKEY 0xFFFFFFFFU +#define TIMG_WDT_WKEY_M (TIMG_WDT_WKEY_V << TIMG_WDT_WKEY_S) +#define TIMG_WDT_WKEY_V 0xFFFFFFFFU #define TIMG_WDT_WKEY_S 0 -#define TIMG_RTCCALICFG_REG(i) (REG_TIMG_BASE(i) + 0x0068) -/* TIMG_RTC_CALI_START : R/W ;bitpos:[31] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_RTC_CALI_START (BIT(31)) -#define TIMG_RTC_CALI_START_M (BIT(31)) -#define TIMG_RTC_CALI_START_V 0x1 -#define TIMG_RTC_CALI_START_S 31 -/* TIMG_RTC_CALI_MAX : R/W ;bitpos:[30:16] ;default: 15'h1 ; */ -/*description: */ -#define TIMG_RTC_CALI_MAX 0x00007FFF -#define TIMG_RTC_CALI_MAX_M ((TIMG_RTC_CALI_MAX_V)<<(TIMG_RTC_CALI_MAX_S)) -#define TIMG_RTC_CALI_MAX_V 0x7FFF -#define TIMG_RTC_CALI_MAX_S 16 -/* TIMG_RTC_CALI_RDY : RO ;bitpos:[15] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_RTC_CALI_RDY (BIT(15)) -#define TIMG_RTC_CALI_RDY_M (BIT(15)) -#define TIMG_RTC_CALI_RDY_V 0x1 -#define TIMG_RTC_CALI_RDY_S 15 -/* TIMG_RTC_CALI_CLK_SEL : R/W ;bitpos:[14:13] ;default: 2'h1 ; */ -/*description: */ -#define TIMG_RTC_CALI_CLK_SEL 0x00000003 -#define TIMG_RTC_CALI_CLK_SEL_M ((TIMG_RTC_CALI_CLK_SEL_V)<<(TIMG_RTC_CALI_CLK_SEL_S)) -#define TIMG_RTC_CALI_CLK_SEL_V 0x3 -#define TIMG_RTC_CALI_CLK_SEL_S 13 -/* TIMG_RTC_CALI_START_CYCLING : R/W ;bitpos:[12] ;default: 1'd1 ; */ -/*description: */ -#define TIMG_RTC_CALI_START_CYCLING (BIT(12)) -#define TIMG_RTC_CALI_START_CYCLING_M (BIT(12)) -#define TIMG_RTC_CALI_START_CYCLING_V 0x1 +/** TIMG_RTCCALICFG_REG register + * RTC calibration configure register + */ +#define TIMG_RTCCALICFG_REG(i) (DR_REG_TIMG_BASE(i) + 0x68) +/** TIMG_RTC_CALI_START_CYCLING : R/W; bitpos: [12]; default: 1; + * Reserved + */ +#define TIMG_RTC_CALI_START_CYCLING (BIT(12)) +#define TIMG_RTC_CALI_START_CYCLING_M (TIMG_RTC_CALI_START_CYCLING_V << TIMG_RTC_CALI_START_CYCLING_S) +#define TIMG_RTC_CALI_START_CYCLING_V 0x00000001U #define TIMG_RTC_CALI_START_CYCLING_S 12 +/** TIMG_RTC_CALI_CLK_SEL : R/W; bitpos: [14:13]; default: 1; + * 0:rtc slow clock. 1:clk_8m, 2:xtal_32k. + */ +#define TIMG_RTC_CALI_CLK_SEL 0x00000003U +#define TIMG_RTC_CALI_CLK_SEL_M (TIMG_RTC_CALI_CLK_SEL_V << TIMG_RTC_CALI_CLK_SEL_S) +#define TIMG_RTC_CALI_CLK_SEL_V 0x00000003U +#define TIMG_RTC_CALI_CLK_SEL_S 13 +/** TIMG_RTC_CALI_RDY : RO; bitpos: [15]; default: 0; + * Reserved + */ +#define TIMG_RTC_CALI_RDY (BIT(15)) +#define TIMG_RTC_CALI_RDY_M (TIMG_RTC_CALI_RDY_V << TIMG_RTC_CALI_RDY_S) +#define TIMG_RTC_CALI_RDY_V 0x00000001U +#define TIMG_RTC_CALI_RDY_S 15 +/** TIMG_RTC_CALI_MAX : R/W; bitpos: [30:16]; default: 1; + * Reserved + */ +#define TIMG_RTC_CALI_MAX 0x00007FFFU +#define TIMG_RTC_CALI_MAX_M (TIMG_RTC_CALI_MAX_V << TIMG_RTC_CALI_MAX_S) +#define TIMG_RTC_CALI_MAX_V 0x00007FFFU +#define TIMG_RTC_CALI_MAX_S 16 +/** TIMG_RTC_CALI_START : R/W; bitpos: [31]; default: 0; + * Reserved + */ +#define TIMG_RTC_CALI_START (BIT(31)) +#define TIMG_RTC_CALI_START_M (TIMG_RTC_CALI_START_V << TIMG_RTC_CALI_START_S) +#define TIMG_RTC_CALI_START_V 0x00000001U +#define TIMG_RTC_CALI_START_S 31 -#define TIMG_RTCCALICFG1_REG(i) (REG_TIMG_BASE(i) + 0x006c) -/* TIMG_RTC_CALI_VALUE : RO ;bitpos:[31:7] ;default: 25'h0 ; */ -/*description: */ -#define TIMG_RTC_CALI_VALUE 0x01FFFFFF -#define TIMG_RTC_CALI_VALUE_M ((TIMG_RTC_CALI_VALUE_V)<<(TIMG_RTC_CALI_VALUE_S)) -#define TIMG_RTC_CALI_VALUE_V 0x1FFFFFF -#define TIMG_RTC_CALI_VALUE_S 7 -/* TIMG_RTC_CALI_CYCLING_DATA_VLD : RO ;bitpos:[0] ;default: 1'b0 ; */ -/*description: */ -#define TIMG_RTC_CALI_CYCLING_DATA_VLD (BIT(0)) -#define TIMG_RTC_CALI_CYCLING_DATA_VLD_M (BIT(0)) -#define TIMG_RTC_CALI_CYCLING_DATA_VLD_V 0x1 +/** TIMG_RTCCALICFG1_REG register + * RTC calibration configure1 register + */ +#define TIMG_RTCCALICFG1_REG(i) (DR_REG_TIMG_BASE(i) + 0x6c) +/** TIMG_RTC_CALI_CYCLING_DATA_VLD : RO; bitpos: [0]; default: 0; + * Reserved + */ +#define TIMG_RTC_CALI_CYCLING_DATA_VLD (BIT(0)) +#define TIMG_RTC_CALI_CYCLING_DATA_VLD_M (TIMG_RTC_CALI_CYCLING_DATA_VLD_V << TIMG_RTC_CALI_CYCLING_DATA_VLD_S) +#define TIMG_RTC_CALI_CYCLING_DATA_VLD_V 0x00000001U #define TIMG_RTC_CALI_CYCLING_DATA_VLD_S 0 +/** TIMG_RTC_CALI_VALUE : RO; bitpos: [31:7]; default: 0; + * Reserved + */ +#define TIMG_RTC_CALI_VALUE 0x01FFFFFFU +#define TIMG_RTC_CALI_VALUE_M (TIMG_RTC_CALI_VALUE_V << TIMG_RTC_CALI_VALUE_S) +#define TIMG_RTC_CALI_VALUE_V 0x01FFFFFFU +#define TIMG_RTC_CALI_VALUE_S 7 -#define TIMG_INT_ENA_TIMERS_REG(i) (REG_TIMG_BASE(i) + 0x0070) -/* TIMG_WDT_INT_ENA : R/W ;bitpos:[1] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_WDT_INT_ENA (BIT(1)) -#define TIMG_WDT_INT_ENA_M (BIT(1)) -#define TIMG_WDT_INT_ENA_V 0x1 -#define TIMG_WDT_INT_ENA_S 1 -/* TIMG_T0_INT_ENA : R/W ;bitpos:[0] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_T0_INT_ENA (BIT(0)) -#define TIMG_T0_INT_ENA_M (BIT(0)) -#define TIMG_T0_INT_ENA_V 0x1 +/** TIMG_INT_ENA_TIMERS_REG register + * Interrupt enable bits + */ +#define TIMG_INT_ENA_TIMERS_REG(i) (DR_REG_TIMG_BASE(i) + 0x70) +/** TIMG_T0_INT_ENA : R/W; bitpos: [0]; default: 0; + * The interrupt enable bit for the TIMG_T$x_INT interrupt. + */ +#define TIMG_T0_INT_ENA (BIT(0)) +#define TIMG_T0_INT_ENA_M (TIMG_T0_INT_ENA_V << TIMG_T0_INT_ENA_S) +#define TIMG_T0_INT_ENA_V 0x00000001U #define TIMG_T0_INT_ENA_S 0 +/** TIMG_WDT_INT_ENA : R/W; bitpos: [1]; default: 0; + * The interrupt enable bit for the TIMG_WDT_INT interrupt. + */ +#define TIMG_WDT_INT_ENA (BIT(1)) +#define TIMG_WDT_INT_ENA_M (TIMG_WDT_INT_ENA_V << TIMG_WDT_INT_ENA_S) +#define TIMG_WDT_INT_ENA_V 0x00000001U +#define TIMG_WDT_INT_ENA_S 1 -#define TIMG_INT_RAW_TIMERS_REG(i) (REG_TIMG_BASE(i) + 0x0074) -/* TIMG_WDT_INT_RAW : R/SS/WTC ;bitpos:[1] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_WDT_INT_RAW (BIT(1)) -#define TIMG_WDT_INT_RAW_M (BIT(1)) -#define TIMG_WDT_INT_RAW_V 0x1 -#define TIMG_WDT_INT_RAW_S 1 -/* TIMG_T0_INT_RAW : R/SS/WTC ;bitpos:[0] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_T0_INT_RAW (BIT(0)) -#define TIMG_T0_INT_RAW_M (BIT(0)) -#define TIMG_T0_INT_RAW_V 0x1 +/** TIMG_INT_RAW_TIMERS_REG register + * Raw interrupt status + */ +#define TIMG_INT_RAW_TIMERS_REG(i) (DR_REG_TIMG_BASE(i) + 0x74) +/** TIMG_T0_INT_RAW : R/SS/WTC; bitpos: [0]; default: 0; + * The raw interrupt status bit for the TIMG_T$x_INT interrupt. + */ +#define TIMG_T0_INT_RAW (BIT(0)) +#define TIMG_T0_INT_RAW_M (TIMG_T0_INT_RAW_V << TIMG_T0_INT_RAW_S) +#define TIMG_T0_INT_RAW_V 0x00000001U #define TIMG_T0_INT_RAW_S 0 +/** TIMG_WDT_INT_RAW : R/SS/WTC; bitpos: [1]; default: 0; + * The raw interrupt status bit for the TIMG_WDT_INT interrupt. + */ +#define TIMG_WDT_INT_RAW (BIT(1)) +#define TIMG_WDT_INT_RAW_M (TIMG_WDT_INT_RAW_V << TIMG_WDT_INT_RAW_S) +#define TIMG_WDT_INT_RAW_V 0x00000001U +#define TIMG_WDT_INT_RAW_S 1 -#define TIMG_INT_ST_TIMERS_REG(i) (REG_TIMG_BASE(i) + 0x0078) -/* TIMG_WDT_INT_ST : RO ;bitpos:[1] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_WDT_INT_ST (BIT(1)) -#define TIMG_WDT_INT_ST_M (BIT(1)) -#define TIMG_WDT_INT_ST_V 0x1 -#define TIMG_WDT_INT_ST_S 1 -/* TIMG_T0_INT_ST : RO ;bitpos:[0] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_T0_INT_ST (BIT(0)) -#define TIMG_T0_INT_ST_M (BIT(0)) -#define TIMG_T0_INT_ST_V 0x1 +/** TIMG_INT_ST_TIMERS_REG register + * Masked interrupt status + */ +#define TIMG_INT_ST_TIMERS_REG(i) (DR_REG_TIMG_BASE(i) + 0x78) +/** TIMG_T0_INT_ST : RO; bitpos: [0]; default: 0; + * The masked interrupt status bit for the TIMG_T$x_INT interrupt. + */ +#define TIMG_T0_INT_ST (BIT(0)) +#define TIMG_T0_INT_ST_M (TIMG_T0_INT_ST_V << TIMG_T0_INT_ST_S) +#define TIMG_T0_INT_ST_V 0x00000001U #define TIMG_T0_INT_ST_S 0 +/** TIMG_WDT_INT_ST : RO; bitpos: [1]; default: 0; + * The masked interrupt status bit for the TIMG_WDT_INT interrupt. + */ +#define TIMG_WDT_INT_ST (BIT(1)) +#define TIMG_WDT_INT_ST_M (TIMG_WDT_INT_ST_V << TIMG_WDT_INT_ST_S) +#define TIMG_WDT_INT_ST_V 0x00000001U +#define TIMG_WDT_INT_ST_S 1 -#define TIMG_INT_CLR_TIMERS_REG(i) (REG_TIMG_BASE(i) + 0x007c) -/* TIMG_WDT_INT_CLR : WT ;bitpos:[1] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_WDT_INT_CLR (BIT(1)) -#define TIMG_WDT_INT_CLR_M (BIT(1)) -#define TIMG_WDT_INT_CLR_V 0x1 -#define TIMG_WDT_INT_CLR_S 1 -/* TIMG_T0_INT_CLR : WT ;bitpos:[0] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_T0_INT_CLR (BIT(0)) -#define TIMG_T0_INT_CLR_M (BIT(0)) -#define TIMG_T0_INT_CLR_V 0x1 +/** TIMG_INT_CLR_TIMERS_REG register + * Interrupt clear bits + */ +#define TIMG_INT_CLR_TIMERS_REG(i) (DR_REG_TIMG_BASE(i) + 0x7c) +/** TIMG_T0_INT_CLR : WT; bitpos: [0]; default: 0; + * Set this bit to clear the TIMG_T$x_INT interrupt. + */ +#define TIMG_T0_INT_CLR (BIT(0)) +#define TIMG_T0_INT_CLR_M (TIMG_T0_INT_CLR_V << TIMG_T0_INT_CLR_S) +#define TIMG_T0_INT_CLR_V 0x00000001U #define TIMG_T0_INT_CLR_S 0 +/** TIMG_WDT_INT_CLR : WT; bitpos: [1]; default: 0; + * Set this bit to clear the TIMG_WDT_INT interrupt. + */ +#define TIMG_WDT_INT_CLR (BIT(1)) +#define TIMG_WDT_INT_CLR_M (TIMG_WDT_INT_CLR_V << TIMG_WDT_INT_CLR_S) +#define TIMG_WDT_INT_CLR_V 0x00000001U +#define TIMG_WDT_INT_CLR_S 1 -#define TIMG_RTCCALICFG2_REG(i) (REG_TIMG_BASE(i) + 0x0080) -/* TIMG_RTC_CALI_TIMEOUT_THRES : R/W ;bitpos:[31:7] ;default: 25'h1ffffff ; */ -/*description: timeout if cali value counts over threshold*/ -#define TIMG_RTC_CALI_TIMEOUT_THRES 0x01FFFFFF -#define TIMG_RTC_CALI_TIMEOUT_THRES_M ((TIMG_RTC_CALI_TIMEOUT_THRES_V)<<(TIMG_RTC_CALI_TIMEOUT_THRES_S)) -#define TIMG_RTC_CALI_TIMEOUT_THRES_V 0x1FFFFFF -#define TIMG_RTC_CALI_TIMEOUT_THRES_S 7 -/* TIMG_RTC_CALI_TIMEOUT_RST_CNT : R/W ;bitpos:[6:3] ;default: 4'd3 ; */ -/*description: Cycles that release calibration timeout reset*/ -#define TIMG_RTC_CALI_TIMEOUT_RST_CNT 0x0000000F -#define TIMG_RTC_CALI_TIMEOUT_RST_CNT_M ((TIMG_RTC_CALI_TIMEOUT_RST_CNT_V)<<(TIMG_RTC_CALI_TIMEOUT_RST_CNT_S)) -#define TIMG_RTC_CALI_TIMEOUT_RST_CNT_V 0xF -#define TIMG_RTC_CALI_TIMEOUT_RST_CNT_S 3 -/* TIMG_RTC_CALI_TIMEOUT : RO ;bitpos:[0] ;default: 1'h0 ; */ -/*description: timeout indicator*/ -#define TIMG_RTC_CALI_TIMEOUT (BIT(0)) -#define TIMG_RTC_CALI_TIMEOUT_M (BIT(0)) -#define TIMG_RTC_CALI_TIMEOUT_V 0x1 +/** TIMG_RTCCALICFG2_REG register + * Timer group calibration register + */ +#define TIMG_RTCCALICFG2_REG(i) (DR_REG_TIMG_BASE(i) + 0x80) +/** TIMG_RTC_CALI_TIMEOUT : RO; bitpos: [0]; default: 0; + * RTC calibration timeout indicator + */ +#define TIMG_RTC_CALI_TIMEOUT (BIT(0)) +#define TIMG_RTC_CALI_TIMEOUT_M (TIMG_RTC_CALI_TIMEOUT_V << TIMG_RTC_CALI_TIMEOUT_S) +#define TIMG_RTC_CALI_TIMEOUT_V 0x00000001U #define TIMG_RTC_CALI_TIMEOUT_S 0 +/** TIMG_RTC_CALI_TIMEOUT_RST_CNT : R/W; bitpos: [6:3]; default: 3; + * Cycles that release calibration timeout reset + */ +#define TIMG_RTC_CALI_TIMEOUT_RST_CNT 0x0000000FU +#define TIMG_RTC_CALI_TIMEOUT_RST_CNT_M (TIMG_RTC_CALI_TIMEOUT_RST_CNT_V << TIMG_RTC_CALI_TIMEOUT_RST_CNT_S) +#define TIMG_RTC_CALI_TIMEOUT_RST_CNT_V 0x0000000FU +#define TIMG_RTC_CALI_TIMEOUT_RST_CNT_S 3 +/** TIMG_RTC_CALI_TIMEOUT_THRES : R/W; bitpos: [31:7]; default: 33554431; + * Threshold value for the RTC calibration timer. If the calibration timer's value + * exceeds this threshold, a timeout is triggered. + */ +#define TIMG_RTC_CALI_TIMEOUT_THRES 0x01FFFFFFU +#define TIMG_RTC_CALI_TIMEOUT_THRES_M (TIMG_RTC_CALI_TIMEOUT_THRES_V << TIMG_RTC_CALI_TIMEOUT_THRES_S) +#define TIMG_RTC_CALI_TIMEOUT_THRES_V 0x01FFFFFFU +#define TIMG_RTC_CALI_TIMEOUT_THRES_S 7 -#define TIMG_NTIMERS_DATE_REG(i) (REG_TIMG_BASE(i) + 0x00f8) -/* TIMG_NTIMERS_DATE : R/W ;bitpos:[27:0] ;default: 28'h2006191 ; */ -/*description: */ -#define TIMG_NTIMERS_DATE 0x0FFFFFFF -#define TIMG_NTIMERS_DATE_M ((TIMG_NTIMERS_DATE_V)<<(TIMG_NTIMERS_DATE_S)) -#define TIMG_NTIMERS_DATE_V 0xFFFFFFF -#define TIMG_NTIMERS_DATE_S 0 - -#define TIMG_CLK_REG(i) (REG_TIMG_BASE(i) + 0x00fc) -/* TIMG_CLK_EN : R/W ;bitpos:[31] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_CLK_EN (BIT(31)) -#define TIMG_CLK_EN_M (BIT(31)) -#define TIMG_CLK_EN_V 0x1 -#define TIMG_CLK_EN_S 31 -/* TIMG_TIMER_CLK_IS_ACTIVE : R/W ;bitpos:[30] ;default: 1'h1 ; */ -/*description: */ -#define TIMG_TIMER_CLK_IS_ACTIVE (BIT(30)) -#define TIMG_TIMER_CLK_IS_ACTIVE_M (BIT(30)) -#define TIMG_TIMER_CLK_IS_ACTIVE_V 0x1 -#define TIMG_TIMER_CLK_IS_ACTIVE_S 30 -/* TIMG_WDT_CLK_IS_ACTIVE : R/W ;bitpos:[29] ;default: 1'h1 ; */ -/*description: */ -#define TIMG_WDT_CLK_IS_ACTIVE (BIT(29)) -#define TIMG_WDT_CLK_IS_ACTIVE_M (BIT(29)) -#define TIMG_WDT_CLK_IS_ACTIVE_V 0x1 +/** TIMG_NTIMERS_DATE_REG register + * Timer version control register + */ +#define TIMG_NTIMERS_DATE_REG(i) (DR_REG_TIMG_BASE(i) + 0xf8) +/** TIMG_NTIMGS_DATE : R/W; bitpos: [27:0]; default: 33579409; + * Timer version control register + */ +#define TIMG_NTIMGS_DATE 0x0FFFFFFFU +#define TIMG_NTIMGS_DATE_M (TIMG_NTIMGS_DATE_V << TIMG_NTIMGS_DATE_S) +#define TIMG_NTIMGS_DATE_V 0x0FFFFFFFU +#define TIMG_NTIMGS_DATE_S 0 + +/** TIMG_REGCLK_REG register + * Timer group clock gate register + */ +#define TIMG_REGCLK_REG(i) (DR_REG_TIMG_BASE(i) + 0xfc) +/** TIMG_WDT_CLK_IS_ACTIVE : R/W; bitpos: [29]; default: 1; + * enable WDT's clock + */ +#define TIMG_WDT_CLK_IS_ACTIVE (BIT(29)) +#define TIMG_WDT_CLK_IS_ACTIVE_M (TIMG_WDT_CLK_IS_ACTIVE_V << TIMG_WDT_CLK_IS_ACTIVE_S) +#define TIMG_WDT_CLK_IS_ACTIVE_V 0x00000001U #define TIMG_WDT_CLK_IS_ACTIVE_S 29 +/** TIMG_TIMER_CLK_IS_ACTIVE : R/W; bitpos: [30]; default: 1; + * enable Timer $x's clock + */ +#define TIMG_TIMER_CLK_IS_ACTIVE (BIT(30)) +#define TIMG_TIMER_CLK_IS_ACTIVE_M (TIMG_TIMER_CLK_IS_ACTIVE_V << TIMG_TIMER_CLK_IS_ACTIVE_S) +#define TIMG_TIMER_CLK_IS_ACTIVE_V 0x00000001U +#define TIMG_TIMER_CLK_IS_ACTIVE_S 30 +/** TIMG_CLK_EN : R/W; bitpos: [31]; default: 0; + * Register clock gate signal. 1: Registers can be read and written to by software. 0: + * Registers can not be read or written to by software. + */ +#define TIMG_CLK_EN (BIT(31)) +#define TIMG_CLK_EN_M (TIMG_CLK_EN_V << TIMG_CLK_EN_S) +#define TIMG_CLK_EN_V 0x00000001U +#define TIMG_CLK_EN_S 31 #ifdef __cplusplus } #endif - - - -#endif /*_SOC_TIMG_REG_H_ */ diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/timer_group_struct.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/timer_group_struct.h index 6bae30720c0..13311b302ea 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/timer_group_struct.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/timer_group_struct.h @@ -1,222 +1,561 @@ -// Copyright 2020 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 _SOC_TIMG_STRUCT_H_ -#define _SOC_TIMG_STRUCT_H_ +/** + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#pragma once + +#include #ifdef __cplusplus extern "C" { #endif -typedef volatile struct { - struct { - union { - struct { - uint32_t reserved0: 9; - uint32_t use_xtal: 1; - uint32_t alarm_en: 1; - uint32_t reserved11: 1; - uint32_t divcnt_rst: 1; - uint32_t divider: 16; - uint32_t autoreload: 1; - uint32_t increase: 1; - uint32_t enable: 1; - }; - uint32_t val; - } config; - uint32_t cnt_low; /**/ - union { - struct { - uint32_t hi: 22; - uint32_t reserved22:10; - }; - uint32_t val; - } cnt_high; - union { - struct { - uint32_t reserved0: 31; - uint32_t update: 1; - }; - uint32_t val; - } update; - uint32_t alarm_low; /**/ - union { - struct { - uint32_t alarm_hi: 22; - uint32_t reserved22: 10; - }; - uint32_t val; - } alarm_high; - uint32_t load_low; /**/ - union { - struct { - uint32_t load_hi: 22; - uint32_t reserved22:10; - }; - uint32_t val; - } load_high; - uint32_t reload; /**/ - } hw_timer[1]; - uint32_t reserved_24; - uint32_t reserved_28; - uint32_t reserved_2c; - uint32_t reserved_30; - uint32_t reserved_34; - uint32_t reserved_38; - uint32_t reserved_3c; - uint32_t reserved_40; - uint32_t reserved_44; - union { - struct { - uint32_t reserved0: 12; - uint32_t appcpu_reset_en: 1; - uint32_t procpu_reset_en: 1; - uint32_t flashboot_mod_en: 1; - uint32_t sys_reset_length: 3; - uint32_t cpu_reset_length: 3; - uint32_t use_xtal: 1; - uint32_t conf_update_en: 1; - uint32_t stg3: 2; - uint32_t stg2: 2; - uint32_t stg1: 2; - uint32_t stg0: 2; - uint32_t en: 1; - }; - uint32_t val; - } wdt_config0; - union { - struct { - uint32_t divcnt_rst: 1; - uint32_t reserved1: 15; - uint32_t clk_prescale: 16; - }; - uint32_t val; - } wdt_config1; - uint32_t wdt_config2; /**/ - uint32_t wdt_config3; /**/ - uint32_t wdt_config4; /**/ - uint32_t wdt_config5; /**/ - uint32_t wdt_feed; /**/ - uint32_t wdt_wprotect; /**/ - union { - struct { - uint32_t reserved0: 12; - uint32_t start_cycling: 1; - uint32_t clk_sel: 2; - uint32_t rdy: 1; - uint32_t max: 15; - uint32_t start: 1; - }; - uint32_t val; - } rtc_cali_cfg; - union { - struct { - uint32_t cycling_data_vld: 1; - uint32_t reserved1: 6; - uint32_t value: 25; - }; - uint32_t val; - } rtc_cali_cfg1; - union { - struct { - uint32_t t0: 1; - uint32_t wdt: 1; - uint32_t reserved2: 30; - }; - uint32_t val; - } int_ena; - union { - struct { - uint32_t t0: 1; - uint32_t wdt: 1; - uint32_t reserved2: 30; - }; - uint32_t val; - } int_raw; - union { - struct { - uint32_t t0: 1; - uint32_t wdt: 1; - uint32_t reserved2: 30; - }; - uint32_t val; - } int_st; - union { - struct { - uint32_t t0: 1; - uint32_t wdt: 1; - uint32_t reserved2: 30; - }; - uint32_t val; - } int_clr; - union { - struct { - uint32_t timeout: 1; /*timeout indicator*/ - uint32_t reserved1: 2; - uint32_t timeout_rst_cnt: 4; /*Cycles that release calibration timeout reset*/ - uint32_t timeout_thres: 25; /*timeout if cali value counts over threshold*/ - }; - uint32_t val; - } rtc_cali_cfg2; - uint32_t reserved_84; - uint32_t reserved_88; - uint32_t reserved_8c; - uint32_t reserved_90; - uint32_t reserved_94; - uint32_t reserved_98; - uint32_t reserved_9c; - uint32_t reserved_a0; - uint32_t reserved_a4; - uint32_t reserved_a8; - uint32_t reserved_ac; - uint32_t reserved_b0; - uint32_t reserved_b4; - uint32_t reserved_b8; - uint32_t reserved_bc; - uint32_t reserved_c0; - uint32_t reserved_c4; - uint32_t reserved_c8; - uint32_t reserved_cc; - uint32_t reserved_d0; - uint32_t reserved_d4; - uint32_t reserved_d8; - uint32_t reserved_dc; - uint32_t reserved_e0; - uint32_t reserved_e4; - uint32_t reserved_e8; - uint32_t reserved_ec; - uint32_t reserved_f0; - uint32_t reserved_f4; - union { - struct { - uint32_t date: 28; - uint32_t reserved28: 4; - }; - uint32_t val; - } timg_date; - union { - struct { - uint32_t reserved0: 29; - uint32_t wdt_clk_is_active: 1; - uint32_t timer_clk_is_active: 1; - uint32_t en: 1; - }; - uint32_t val; - } clk; +/** Group: T0 Control and configuration registers */ +/** Type of txconfig register + * Timer x configuration register + */ +typedef union { + struct { + uint32_t reserved_0:9; + /** tx_use_xtal : R/W; bitpos: [9]; default: 0; + * 1: Use XTAL_CLK as the source clock of timer group. 0: Use APB_CLK as the source + * clock of timer group. + */ + uint32_t tx_use_xtal:1; + /** tx_alarm_en : R/W/SC; bitpos: [10]; default: 0; + * When set, the alarm is enabled. This bit is automatically cleared once an + * alarm occurs. + */ + uint32_t tx_alarm_en:1; + uint32_t reserved_11:1; + /** tx_divcnt_rst : WT; bitpos: [12]; default: 0; + * When set, Timer x 's clock divider counter will be reset. + */ + uint32_t tx_divcnt_rst:1; + /** tx_divider : R/W; bitpos: [28:13]; default: 1; + * Timer x clock (Tx_clk) prescaler value. + */ + uint32_t tx_divider:16; + /** tx_autoreload : R/W; bitpos: [29]; default: 1; + * When set, timer x auto-reload at alarm is enabled. + */ + uint32_t tx_autoreload:1; + /** tx_increase : R/W; bitpos: [30]; default: 1; + * When set, the timer x time-base counter will increment every clock tick. When + * cleared, the timer x time-base counter will decrement. + */ + uint32_t tx_increase:1; + /** tx_en : R/W; bitpos: [31]; default: 0; + * When set, the timer x time-base counter is enabled. + */ + uint32_t tx_en:1; + }; + uint32_t val; +} timg_txconfig_reg_t; + +/** Type of txlo register + * Timer x current value, low 32 bits + */ +typedef union { + struct { + /** tx_lo : RO; bitpos: [31:0]; default: 0; + * After writing to TIMG_TxUPDATE_REG, the low 32 bits of the time-base counter + * of timer x can be read here. + */ + uint32_t tx_lo:32; + }; + uint32_t val; +} timg_txlo_reg_t; + +/** Type of txhi register + * Timer $x current value, high 22 bits + */ +typedef union { + struct { + /** tx_hi : RO; bitpos: [21:0]; default: 0; + * After writing to TIMG_T$xUPDATE_REG, the high 22 bits of the time-base counter + * of timer $x can be read here. + */ + uint32_t tx_hi:22; + uint32_t reserved_22:10; + }; + uint32_t val; +} timg_txhi_reg_t; + +/** Type of txupdate register + * Write to copy current timer value to TIMGn_T$x_(LO/HI)_REG + */ +typedef union { + struct { + uint32_t reserved_0:31; + /** tx_update : R/W/SC; bitpos: [31]; default: 0; + * After writing 0 or 1 to TIMG_T$xUPDATE_REG, the counter value is latched. + */ + uint32_t tx_update:1; + }; + uint32_t val; +} timg_txupdate_reg_t; + +/** Type of txalarmlo register + * Timer $x alarm value, low 32 bits + */ +typedef union { + struct { + /** tx_alarm_lo : R/W; bitpos: [31:0]; default: 0; + * Timer $x alarm trigger time-base counter value, low 32 bits. + */ + uint32_t tx_alarm_lo:32; + }; + uint32_t val; +} timg_txalarmlo_reg_t; + +/** Type of txalarmhi register + * Timer $x alarm value, high bits + */ +typedef union { + struct { + /** tx_alarm_hi : R/W; bitpos: [21:0]; default: 0; + * Timer $x alarm trigger time-base counter value, high 22 bits. + */ + uint32_t tx_alarm_hi:22; + uint32_t reserved_22:10; + }; + uint32_t val; +} timg_txalarmhi_reg_t; + +/** Type of txloadlo register + * Timer $x reload value, low 32 bits + */ +typedef union { + struct { + /** tx_load_lo : R/W; bitpos: [31:0]; default: 0; + * Low 32 bits of the value that a reload will load onto timer $x time-base + * Counter. + */ + uint32_t tx_load_lo:32; + }; + uint32_t val; +} timg_txloadlo_reg_t; + +/** Type of txloadhi register + * Timer $x reload value, high 22 bits + */ +typedef union { + struct { + /** tx_load_hi : R/W; bitpos: [21:0]; default: 0; + * High 22 bits of the value that a reload will load onto timer $x time-base + * counter. + */ + uint32_t tx_load_hi:22; + uint32_t reserved_22:10; + }; + uint32_t val; +} timg_txloadhi_reg_t; + +/** Type of txload register + * Write to reload timer from TIMG_T$x_(LOADLOLOADHI)_REG + */ +typedef union { + struct { + /** tx_load : WT; bitpos: [31:0]; default: 0; + * + * Write any value to trigger a timer $x time-base counter reload. + */ + uint32_t tx_load:32; + }; + uint32_t val; +} timg_txload_reg_t; + + +/** Group: WDT Control and configuration registers */ +/** Type of wdtconfig0 register + * Watchdog timer configuration register + */ +typedef union { + struct { + uint32_t reserved_0:12; + /** wdt_appcpu_reset_en : R/W; bitpos: [12]; default: 0; + * WDT reset CPU enable. + */ + uint32_t wdt_appcpu_reset_en:1; + /** wdt_procpu_reset_en : R/W; bitpos: [13]; default: 0; + * WDT reset CPU enable. + */ + uint32_t wdt_procpu_reset_en:1; + /** wdt_flashboot_mod_en : R/W; bitpos: [14]; default: 1; + * When set, Flash boot protection is enabled. + */ + uint32_t wdt_flashboot_mod_en:1; + /** wdt_sys_reset_length : R/W; bitpos: [17:15]; default: 1; + * System reset signal length selection. 0: 100 ns, 1: 200 ns, + * 2: 300 ns, 3: 400 ns, 4: 500 ns, 5: 800 ns, 6: 1.6 us, 7: 3.2 us. + */ + uint32_t wdt_sys_reset_length:3; + /** wdt_cpu_reset_length : R/W; bitpos: [20:18]; default: 1; + * CPU reset signal length selection. 0: 100 ns, 1: 200 ns, + * 2: 300 ns, 3: 400 ns, 4: 500 ns, 5: 800 ns, 6: 1.6 us, 7: 3.2 us. + */ + uint32_t wdt_cpu_reset_length:3; + /** wdt_use_xtal : R/W; bitpos: [21]; default: 0; + * choose WDT clock:0-apb_clk; 1-xtal_clk. + */ + uint32_t wdt_use_xtal:1; + /** wdt_conf_update_en : WT; bitpos: [22]; default: 0; + * update the WDT configuration registers + */ + uint32_t wdt_conf_update_en:1; + /** wdt_stg3 : R/W; bitpos: [24:23]; default: 0; + * Stage 3 configuration. 0: off, 1: interrupt, 2: reset CPU, 3: reset system. + */ + uint32_t wdt_stg3:2; + /** wdt_stg2 : R/W; bitpos: [26:25]; default: 0; + * Stage 2 configuration. 0: off, 1: interrupt, 2: reset CPU, 3: reset system. + */ + uint32_t wdt_stg2:2; + /** wdt_stg1 : R/W; bitpos: [28:27]; default: 0; + * Stage 1 configuration. 0: off, 1: interrupt, 2: reset CPU, 3: reset system. + */ + uint32_t wdt_stg1:2; + /** wdt_stg0 : R/W; bitpos: [30:29]; default: 0; + * Stage 0 configuration. 0: off, 1: interrupt, 2: reset CPU, 3: reset system. + */ + uint32_t wdt_stg0:2; + /** wdt_en : R/W; bitpos: [31]; default: 0; + * When set, MWDT is enabled. + */ + uint32_t wdt_en:1; + }; + uint32_t val; +} timg_wdtconfig0_reg_t; + +/** Type of wdtconfig1 register + * Watchdog timer prescaler register + */ +typedef union { + struct { + /** wdt_divcnt_rst : WT; bitpos: [0]; default: 0; + * When set, WDT 's clock divider counter will be reset. + */ + uint32_t wdt_divcnt_rst:1; + uint32_t reserved_1:15; + /** wdt_clk_prescale : R/W; bitpos: [31:16]; default: 1; + * MWDT clock prescaler value. MWDT clock period = 12.5 ns * + * TIMG_WDT_CLK_PRESCALE. + */ + uint32_t wdt_clk_prescale:16; + }; + uint32_t val; +} timg_wdtconfig1_reg_t; + +/** Type of wdtconfig2 register + * Watchdog timer stage 0 timeout value + */ +typedef union { + struct { + /** wdt_stg0_hold : R/W; bitpos: [31:0]; default: 26000000; + * Stage 0 timeout value, in MWDT clock cycles. + */ + uint32_t wdt_stg0_hold:32; + }; + uint32_t val; +} timg_wdtconfig2_reg_t; + +/** Type of wdtconfig3 register + * Watchdog timer stage 1 timeout value + */ +typedef union { + struct { + /** wdt_stg1_hold : R/W; bitpos: [31:0]; default: 134217727; + * Stage 1 timeout value, in MWDT clock cycles. + */ + uint32_t wdt_stg1_hold:32; + }; + uint32_t val; +} timg_wdtconfig3_reg_t; + +/** Type of wdtconfig4 register + * Watchdog timer stage 2 timeout value + */ +typedef union { + struct { + /** wdt_stg2_hold : R/W; bitpos: [31:0]; default: 1048575; + * Stage 2 timeout value, in MWDT clock cycles. + */ + uint32_t wdt_stg2_hold:32; + }; + uint32_t val; +} timg_wdtconfig4_reg_t; + +/** Type of wdtconfig5 register + * Watchdog timer stage 3 timeout value + */ +typedef union { + struct { + /** wdt_stg3_hold : R/W; bitpos: [31:0]; default: 1048575; + * Stage 3 timeout value, in MWDT clock cycles. + */ + uint32_t wdt_stg3_hold:32; + }; + uint32_t val; +} timg_wdtconfig5_reg_t; + +/** Type of wdtfeed register + * Write to feed the watchdog timer + */ +typedef union { + struct { + /** wdt_feed : WT; bitpos: [31:0]; default: 0; + * Write any value to feed the MWDT. (WO) + */ + uint32_t wdt_feed:32; + }; + uint32_t val; +} timg_wdtfeed_reg_t; + +/** Type of wdtwprotect register + * Watchdog write protect register + */ +typedef union { + struct { + /** wdt_wkey : R/W; bitpos: [31:0]; default: 1356348065; + * If the register contains a different value than its reset value, write + * protection is enabled. + */ + uint32_t wdt_wkey:32; + }; + uint32_t val; +} timg_wdtwprotect_reg_t; + + +/** Group: RTC CALI Control and configuration registers */ +/** Type of rtccalicfg register + * RTC calibration configure register + */ +typedef union { + struct { + uint32_t reserved_0:12; + /** rtc_cali_start_cycling : R/W; bitpos: [12]; default: 1; + * Reserved + */ + uint32_t rtc_cali_start_cycling:1; + /** rtc_cali_clk_sel : R/W; bitpos: [14:13]; default: 1; + * 0:rtc slow clock. 1:clk_8m, 2:xtal_32k. + */ + uint32_t rtc_cali_clk_sel:2; + /** rtc_cali_rdy : RO; bitpos: [15]; default: 0; + * Reserved + */ + uint32_t rtc_cali_rdy:1; + /** rtc_cali_max : R/W; bitpos: [30:16]; default: 1; + * Reserved + */ + uint32_t rtc_cali_max:15; + /** rtc_cali_start : R/W; bitpos: [31]; default: 0; + * Reserved + */ + uint32_t rtc_cali_start:1; + }; + uint32_t val; +} timg_rtccalicfg_reg_t; + +/** Type of rtccalicfg1 register + * RTC calibration configure1 register + */ +typedef union { + struct { + /** rtc_cali_cycling_data_vld : RO; bitpos: [0]; default: 0; + * Reserved + */ + uint32_t rtc_cali_cycling_data_vld:1; + uint32_t reserved_1:6; + /** rtc_cali_value : RO; bitpos: [31:7]; default: 0; + * Reserved + */ + uint32_t rtc_cali_value:25; + }; + uint32_t val; +} timg_rtccalicfg1_reg_t; + +/** Type of rtccalicfg2 register + * Timer group calibration register + */ +typedef union { + struct { + /** rtc_cali_timeout : RO; bitpos: [0]; default: 0; + * RTC calibration timeout indicator + */ + uint32_t rtc_cali_timeout:1; + uint32_t reserved_1:2; + /** rtc_cali_timeout_rst_cnt : R/W; bitpos: [6:3]; default: 3; + * Cycles that release calibration timeout reset + */ + uint32_t rtc_cali_timeout_rst_cnt:4; + /** rtc_cali_timeout_thres : R/W; bitpos: [31:7]; default: 33554431; + * Threshold value for the RTC calibration timer. If the calibration timer's value + * exceeds this threshold, a timeout is triggered. + */ + uint32_t rtc_cali_timeout_thres:25; + }; + uint32_t val; +} timg_rtccalicfg2_reg_t; + + +/** Group: Interrupt registers */ +/** Type of int_ena_timers register + * Interrupt enable bits + */ +typedef union { + struct { + /** t0_int_ena : R/W; bitpos: [0]; default: 0; + * The interrupt enable bit for the TIMG_T$x_INT interrupt. + */ + uint32_t t0_int_ena:1; + /** wdt_int_ena : R/W; bitpos: [1]; default: 0; + * The interrupt enable bit for the TIMG_WDT_INT interrupt. + */ + uint32_t wdt_int_ena:1; + uint32_t reserved_2:30; + }; + uint32_t val; +} timg_int_ena_timers_reg_t; + +/** Type of int_raw_timers register + * Raw interrupt status + */ +typedef union { + struct { + /** t0_int_raw : R/SS/WTC; bitpos: [0]; default: 0; + * The raw interrupt status bit for the TIMG_T$x_INT interrupt. + */ + uint32_t t0_int_raw:1; + /** wdt_int_raw : R/SS/WTC; bitpos: [1]; default: 0; + * The raw interrupt status bit for the TIMG_WDT_INT interrupt. + */ + uint32_t wdt_int_raw:1; + uint32_t reserved_2:30; + }; + uint32_t val; +} timg_int_raw_timers_reg_t; + +/** Type of int_st_timers register + * Masked interrupt status + */ +typedef union { + struct { + /** t0_int_st : RO; bitpos: [0]; default: 0; + * The masked interrupt status bit for the TIMG_T$x_INT interrupt. + */ + uint32_t t0_int_st:1; + /** wdt_int_st : RO; bitpos: [1]; default: 0; + * The masked interrupt status bit for the TIMG_WDT_INT interrupt. + */ + uint32_t wdt_int_st:1; + uint32_t reserved_2:30; + }; + uint32_t val; +} timg_int_st_timers_reg_t; + +/** Type of int_clr_timers register + * Interrupt clear bits + */ +typedef union { + struct { + /** t0_int_clr : WT; bitpos: [0]; default: 0; + * Set this bit to clear the TIMG_T$x_INT interrupt. + */ + uint32_t t0_int_clr:1; + /** wdt_int_clr : WT; bitpos: [1]; default: 0; + * Set this bit to clear the TIMG_WDT_INT interrupt. + */ + uint32_t wdt_int_clr:1; + uint32_t reserved_2:30; + }; + uint32_t val; +} timg_int_clr_timers_reg_t; + + +/** Group: Version register */ +/** Type of ntimers_date register + * Timer version control register + */ +typedef union { + struct { + /** ntimgs_date : R/W; bitpos: [27:0]; default: 33579409; + * Timer version control register + */ + uint32_t ntimgs_date:28; + uint32_t reserved_28:4; + }; + uint32_t val; +} timg_ntimers_date_reg_t; + + +/** Group: Clock configuration registers */ +/** Type of regclk register + * Timer group clock gate register + */ +typedef union { + struct { + uint32_t reserved_0:29; + /** wdt_clk_is_active : R/W; bitpos: [29]; default: 1; + * enable WDT's clock + */ + uint32_t wdt_clk_is_active:1; + /** timer_clk_is_active : R/W; bitpos: [30]; default: 1; + * enable Timer $x's clock + */ + uint32_t timer_clk_is_active:1; + /** clk_en : R/W; bitpos: [31]; default: 0; + * Register clock gate signal. 1: Registers can be read and written to by software. 0: + * Registers can not be read or written to by software. + */ + uint32_t clk_en:1; + }; + uint32_t val; +} timg_regclk_reg_t; + +typedef struct { + volatile timg_txconfig_reg_t config; + volatile timg_txlo_reg_t lo; + volatile timg_txhi_reg_t hi; + volatile timg_txupdate_reg_t update; + volatile timg_txalarmlo_reg_t alarmlo; + volatile timg_txalarmhi_reg_t alarmhi; + volatile timg_txloadlo_reg_t loadlo; + volatile timg_txloadhi_reg_t loadhi; + volatile timg_txload_reg_t load; +} timg_hwtimer_reg_t; + +typedef struct { + volatile timg_hwtimer_reg_t hw_timer[1]; + uint32_t reserved_024[9]; + volatile timg_wdtconfig0_reg_t wdtconfig0; + volatile timg_wdtconfig1_reg_t wdtconfig1; + volatile timg_wdtconfig2_reg_t wdtconfig2; + volatile timg_wdtconfig3_reg_t wdtconfig3; + volatile timg_wdtconfig4_reg_t wdtconfig4; + volatile timg_wdtconfig5_reg_t wdtconfig5; + volatile timg_wdtfeed_reg_t wdtfeed; + volatile timg_wdtwprotect_reg_t wdtwprotect; + volatile timg_rtccalicfg_reg_t rtccalicfg; + volatile timg_rtccalicfg1_reg_t rtccalicfg1; + volatile timg_int_ena_timers_reg_t int_ena_timers; + volatile timg_int_raw_timers_reg_t int_raw_timers; + volatile timg_int_st_timers_reg_t int_st_timers; + volatile timg_int_clr_timers_reg_t int_clr_timers; + volatile timg_rtccalicfg2_reg_t rtccalicfg2; + uint32_t reserved_084[29]; + volatile timg_ntimers_date_reg_t ntimers_date; + volatile timg_regclk_reg_t regclk; } timg_dev_t; + extern timg_dev_t TIMERG0; extern timg_dev_t TIMERG1; + +#ifndef __cplusplus +_Static_assert(sizeof(timg_dev_t) == 0x100, "Invalid size of timg_dev_t structure"); +#endif + #ifdef __cplusplus } #endif - -#endif /* _SOC_TIMG_STRUCT_H_ */ diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/twai_struct.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/twai_struct.h index 64cb80e5ed0..fafc36393a7 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/twai_struct.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/twai_struct.h @@ -35,10 +35,10 @@ typedef volatile struct twai_dev_s { uint32_t lom: 1; /* MOD.1 Listen Only Mode */ uint32_t stm: 1; /* MOD.2 Self Test Mode */ uint32_t afm: 1; /* MOD.3 Acceptance Filter Mode */ - uint32_t reserved28: 28; /* Internal Reserved. MOD.4 Sleep Mode not supported */ + uint32_t reserved4: 28; /* Internal Reserved. MOD.4 Sleep Mode not supported */ }; uint32_t val; - } mode_reg; /* Address 0 */ + } mode_reg; /* Address 0x0000 */ union { struct { uint32_t tr: 1; /* CMR.0 Transmission Request */ @@ -46,10 +46,10 @@ typedef volatile struct twai_dev_s { uint32_t rrb: 1; /* CMR.2 Release Receive Buffer */ uint32_t cdo: 1; /* CMR.3 Clear Data Overrun */ uint32_t srr: 1; /* CMR.4 Self Reception Request */ - uint32_t reserved27: 27; /* Internal Reserved */ + uint32_t reserved5: 27; /* Internal Reserved */ }; uint32_t val; - } command_reg; /* Address 1 */ + } command_reg; /* Address 0x0004 */ union { struct { uint32_t rbs: 1; /* SR.0 Receive Buffer Status */ @@ -61,97 +61,99 @@ typedef volatile struct twai_dev_s { uint32_t es: 1; /* SR.6 Error Status */ uint32_t bs: 1; /* SR.7 Bus Status */ uint32_t ms: 1; /* SR.8 Miss Status */ - uint32_t reserved23: 23; /* Internal Reserved */ + uint32_t reserved9: 23; /* Internal Reserved */ }; uint32_t val; - } status_reg; /* Address 2 */ + } status_reg; /* Address 0x0008 */ union { struct { uint32_t ri: 1; /* IR.0 Receive Interrupt */ uint32_t ti: 1; /* IR.1 Transmit Interrupt */ uint32_t ei: 1; /* IR.2 Error Interrupt */ - uint32_t reserved2: 2; /* Internal Reserved (Data Overrun interrupt and Wake-up not supported) */ + uint32_t doi: 1; /* IR.3 Data Overrun Interrupt */ + uint32_t reserved4: 1; /* Internal Reserved (Wake-up not supported) */ uint32_t epi: 1; /* IR.5 Error Passive Interrupt */ uint32_t ali: 1; /* IR.6 Arbitration Lost Interrupt */ uint32_t bei: 1; /* IR.7 Bus Error Interrupt */ - uint32_t reserved24: 24; /* Internal Reserved */ + uint32_t reserved8: 24; /* Internal Reserved */ }; uint32_t val; - } interrupt_reg; /* Address 3 */ + } interrupt_reg; /* Address 0x000C */ union { struct { uint32_t rie: 1; /* IER.0 Receive Interrupt Enable */ uint32_t tie: 1; /* IER.1 Transmit Interrupt Enable */ uint32_t eie: 1; /* IER.2 Error Interrupt Enable */ - uint32_t reserved2: 2; /* Internal Reserved (Data Overrun interrupt and Wake-up not supported) */ + uint32_t doie: 1; /* IER.3 Data Overrun Interrupt Enable */ + uint32_t reserved4: 1; /* Internal Reserved (Wake-up not supported) */ uint32_t epie: 1; /* IER.5 Error Passive Interrupt Enable */ uint32_t alie: 1; /* IER.6 Arbitration Lost Interrupt Enable */ uint32_t beie: 1; /* IER.7 Bus Error Interrupt Enable */ - uint32_t reserved24: 24; /* Internal Reserved */ + uint32_t reserved8: 24; /* Internal Reserved */ }; uint32_t val; - } interrupt_enable_reg; /* Address 4 */ - uint32_t reserved_05; /* Address 5 */ + } interrupt_enable_reg; /* Address 0x0010 */ + uint32_t reserved_14; union { struct { uint32_t brp: 13; /* BTR0[12:0] Baud Rate Prescaler */ - uint32_t reserved1: 1; /* Internal Reserved */ + uint32_t reserved13: 1; /* Internal Reserved */ uint32_t sjw: 2; /* BTR0[15:14] Synchronization Jump Width*/ uint32_t reserved16: 16; /* Internal Reserved */ }; uint32_t val; - } bus_timing_0_reg; /* Address 6 */ + } bus_timing_0_reg; /* Address 0x0018 */ union { struct { uint32_t tseg1: 4; /* BTR1[3:0] Timing Segment 1 */ uint32_t tseg2: 3; /* BTR1[6:4] Timing Segment 2 */ uint32_t sam: 1; /* BTR1.7 Sampling*/ - uint32_t reserved24: 24; /* Internal Reserved */ + uint32_t reserved8: 24; /* Internal Reserved */ }; uint32_t val; - } bus_timing_1_reg; /* Address 7 */ - uint32_t reserved_08; /* Address 8 (Output control not supported) */ - uint32_t reserved_09; /* Address 9 (Test Register not supported) */ - uint32_t reserved_10; /* Address 10 */ + } bus_timing_1_reg; /* Address 0x001C */ + uint32_t reserved_20; /* Address 0x0020 (Output control not supported) */ + uint32_t reserved_24; /* Address 0x0024 (Test Register not supported) */ + uint32_t reserved_28; /* Address 0x0028 */ //Capture and Counter Registers union { struct { uint32_t alc: 5; /* ALC[4:0] Arbitration lost capture */ - uint32_t reserved27: 27; /* Internal Reserved */ + uint32_t reserved5: 27; /* Internal Reserved */ }; uint32_t val; - } arbitration_lost_captue_reg; /* Address 11 */ + } arbitration_lost_captue_reg; /* Address 0x002C */ union { struct { uint32_t seg: 5; /* ECC[4:0] Error Code Segment 0 to 5 */ uint32_t dir: 1; /* ECC.5 Error Direction (TX/RX) */ uint32_t errc: 2; /* ECC[7:6] Error Code */ - uint32_t reserved24: 24; /* Internal Reserved */ + uint32_t reserved8: 24; /* Internal Reserved */ }; uint32_t val; - } error_code_capture_reg; /* Address 12 */ + } error_code_capture_reg; /* Address 0x0030 */ union { struct { uint32_t ewl: 8; /* EWL[7:0] Error Warning Limit */ - uint32_t reserved24: 24; /* Internal Reserved */ + uint32_t reserved8: 24; /* Internal Reserved */ }; uint32_t val; - } error_warning_limit_reg; /* EWLR[7:0] Error Warning Limit: Address 13 */ + } error_warning_limit_reg; /* Address 0x0034 */ union { struct { uint32_t rxerr: 8; /* RXERR[7:0] Receive Error Counter */ - uint32_t reserved24: 24; /* Internal Reserved */ + uint32_t reserved8: 24; /* Internal Reserved */ }; uint32_t val; - } rx_error_counter_reg; /* Address 12 */ + } rx_error_counter_reg; /* Address 0x0038 */ union { struct { uint32_t txerr: 8; /* TXERR[7:0] Receive Error Counter */ - uint32_t reserved24: 24; /* Internal Reserved */ + uint32_t reserved8: 24; /* Internal Reserved */ }; uint32_t val; - } tx_error_counter_reg; /* Address 15 */ + } tx_error_counter_reg; /* Address 0x003C */ //Shared Registers (TX Buff/RX Buff/Acc Filter) union { @@ -159,45 +161,49 @@ typedef volatile struct twai_dev_s { union { struct { uint32_t byte: 8; /* ACRx[7:0] Acceptance Code */ - uint32_t reserved24: 24; /* Internal Reserved */ + uint32_t reserved8: 24; /* Internal Reserved */ }; uint32_t val; } acr[4]; union { struct { uint32_t byte: 8; /* AMRx[7:0] Acceptance Mask */ - uint32_t reserved24: 24; /* Internal Reserved */ + uint32_t reserved8: 24; /* Internal Reserved */ }; uint32_t val; } amr[4]; - uint32_t reserved32[5]; + uint32_t reserved_60; + uint32_t reserved_64; + uint32_t reserved_68; + uint32_t reserved_6c; + uint32_t reserved_70; } acceptance_filter; union { struct { - uint32_t byte: 8; - uint32_t reserved24: 24; + uint32_t byte: 8; /* TX/RX Byte X [7:0] */ + uint32_t reserved24: 24; /* Internal Reserved */ }; uint32_t val; } tx_rx_buffer[13]; - }; /* Address 16-28 TX/RX Buffer and Acc Filter*/; + }; /* Address 0x0040 - 0x0070 */ //Misc Registers union { struct { uint32_t rmc: 7; /* RMC[6:0] RX Message Counter */ - uint32_t reserved25: 25; /* Internal Reserved */ + uint32_t reserved7: 25; /* Internal Reserved */ }; uint32_t val; - } rx_message_counter_reg; /* Address 29 */ - uint32_t reserved_30; /* Address 30 (RX Buffer Start Address not supported) */ + } rx_message_counter_reg; /* Address 0x0074 */ + uint32_t reserved_78; /* Address 0x0078 (RX Buffer Start Address not supported) */ union { struct { uint32_t cd: 8; /* CDR[7:0] CLKOUT frequency selector based of fOSC */ uint32_t co: 1; /* CDR.8 CLKOUT enable/disable */ - uint32_t reserved24: 23; /* Internal Reserved */ + uint32_t reserved9: 23; /* Internal Reserved */ }; uint32_t val; - } clock_divider_reg; /* Address 31 */ + } clock_divider_reg; /* Address 0x007C */ } twai_dev_t; _Static_assert(sizeof(twai_dev_t) == 128, "TWAI registers should be 32 * 4 bytes"); diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/uart_pins.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/uart_pins.h new file mode 100644 index 00000000000..26b225a3465 --- /dev/null +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/uart_pins.h @@ -0,0 +1,44 @@ +// Copyright 2015-2021 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/io_mux_reg.h" + +/* Specify the number of pins for UART */ +#define SOC_UART_PINS_COUNT (4) + +/* Specify the GPIO pin number for each UART signal in the IOMUX */ +#define U0RXD_GPIO_NUM 20 +#define U0TXD_GPIO_NUM 21 +#define U0RTS_GPIO_NUM (-1) +#define U0CTS_GPIO_NUM (-1) + +#define U1RXD_GPIO_NUM (-1) +#define U1TXD_GPIO_NUM (-1) +#define U1RTS_GPIO_NUM (-1) +#define U1CTS_GPIO_NUM (-1) + +/* The following defines are necessary for reconfiguring the UART + * to use IOMUX, at runtime. */ +#define U0TXD_MUX_FUNC (FUNC_U0TXD_U0TXD) +#define U0RXD_MUX_FUNC (FUNC_U0RXD_U0RXD) +/* No func for the following pins, they shall not be used */ +#define U0RTS_MUX_FUNC (-1) +#define U0CTS_MUX_FUNC (-1) +/* Same goes for UART1 */ +#define U1TXD_MUX_FUNC (-1) +#define U1RXD_MUX_FUNC (-1) +#define U1RTS_MUX_FUNC (-1) +#define U1CTS_MUX_FUNC (-1) diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/uart_struct.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/uart_struct.h index ad9ca42ff73..82f8ef66860 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/uart_struct.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/uart_struct.h @@ -17,7 +17,7 @@ extern "C" { #endif -typedef volatile struct { +typedef volatile struct uart_dev_s { union { struct { uint32_t rw_byte; /*a*/ diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/uhci_struct.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/uhci_struct.h index a89c4d01261..164f1a1334e 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/uhci_struct.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/uhci_struct.h @@ -17,7 +17,7 @@ extern "C" { #endif -typedef volatile struct { +typedef volatile struct uhci_dev_s { union { struct { uint32_t tx_rst: 1; /*Write 1 then write 0 to this bit to reset decode state machine.*/ diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/usb_serial_jtag_struct.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/usb_serial_jtag_struct.h index 5ae44587a62..c1cfced04bb 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/usb_serial_jtag_struct.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/usb_serial_jtag_struct.h @@ -20,7 +20,7 @@ extern "C" { #endif #include "soc.h" -typedef volatile struct { +typedef volatile struct usb_serial_jtag_dev_s { union { struct { uint32_t rdwr_byte : 32; /*Although only low 8-bits is valid, but change it to 32bits to avoid there's no read/modify/write behaviour*/ /*Write and read byte data to/from UART Tx/Rx FIFO through this field. When USB_SERIAL_JTAG_SERIAL_IN_EMPTY_INT is set then user can write data (up to 64 bytes) into UART Tx FIFO. When USB_SERIAL_JTAG_SERIAL_OUT_RECV_PKT_INT is set, user can check USB_SERIAL_JTAG_OUT_EP1_WR_ADDR and USB_SERIAL_JTAG_OUT_EP0_RD_ADDR to know how many data is received, then read that amount of data from UART Rx FIFO. */ diff --git a/tools/sdk/esp32c3/include/soc/include/soc/adc_periph.h b/tools/sdk/esp32c3/include/soc/include/soc/adc_periph.h index 796ea18e906..437d8ad6e6a 100644 --- a/tools/sdk/esp32c3/include/soc/include/soc/adc_periph.h +++ b/tools/sdk/esp32c3/include/soc/include/soc/adc_periph.h @@ -18,7 +18,7 @@ #include "soc/soc_caps.h" #include "soc/syscon_struct.h" -#if SOC_ADC_SUPPORT_RTC_CTRL +#if SOC_ADC_RTC_CTRL_SUPPORTED #include "soc/sens_reg.h" #include "soc/sens_struct.h" #endif diff --git a/tools/sdk/esp32c3/include/soc/include/soc/i2s_periph.h b/tools/sdk/esp32c3/include/soc/include/soc/i2s_periph.h index a2b9c542744..167c84700fd 100644 --- a/tools/sdk/esp32c3/include/soc/include/soc/i2s_periph.h +++ b/tools/sdk/esp32c3/include/soc/include/soc/i2s_periph.h @@ -1,4 +1,4 @@ -// Copyright 2019 Espressif Systems (Shanghai) PTE LTD +// Copyright 2020 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. @@ -27,16 +27,21 @@ extern "C" { Stores a bunch of per-I2S-peripheral data. */ typedef struct { - const uint8_t o_bck_in_sig; - const uint8_t o_ws_in_sig; - const uint8_t o_bck_out_sig; - const uint8_t o_ws_out_sig; - const uint8_t o_data_out_sig; - const uint8_t i_bck_in_sig; - const uint8_t i_ws_in_sig; - const uint8_t i_bck_out_sig; - const uint8_t i_ws_out_sig; - const uint8_t i_data_in_sig; + const uint8_t mck_out_sig; + + const uint8_t m_tx_bck_sig; + const uint8_t m_rx_bck_sig; + const uint8_t m_tx_ws_sig; + const uint8_t m_rx_ws_sig; + + const uint8_t s_tx_bck_sig; + const uint8_t s_rx_bck_sig; + const uint8_t s_tx_ws_sig; + const uint8_t s_rx_ws_sig; + + const uint8_t data_out_sig; + const uint8_t data_in_sig; + const uint8_t irq; const periph_module_t module; } i2s_signal_conn_t; diff --git a/tools/sdk/esp32c3/include/soc/include/soc/lcd_periph.h b/tools/sdk/esp32c3/include/soc/include/soc/lcd_periph.h index 6b1071b316c..d7d3ebc68bf 100644 --- a/tools/sdk/esp32c3/include/soc/include/soc/lcd_periph.h +++ b/tools/sdk/esp32c3/include/soc/include/soc/lcd_periph.h @@ -21,6 +21,7 @@ extern "C" { #endif +#if SOC_LCDCAM_SUPPORTED typedef struct { struct { const periph_module_t module; @@ -41,6 +42,19 @@ typedef struct { } panels[SOC_LCD_RGB_PANELS]; } lcd_signal_conn_t; +#endif // SOC_LCDCAM_SUPPORTED + +#if SOC_I2S_LCD_I80_VARIANT +typedef struct { + struct { + const periph_module_t module; + const int irq_id; + const int data_sigs[SOC_LCD_I80_BUS_WIDTH]; + const int wr_sig; + } buses[SOC_LCD_I80_BUSES]; +} lcd_signal_conn_t; +#endif // SOC_I2S_LCD_I80_VARIANT + extern const lcd_signal_conn_t lcd_periph_signals; #ifdef __cplusplus diff --git a/tools/sdk/esp32c3/include/soc/include/soc/mcpwm_periph.h b/tools/sdk/esp32c3/include/soc/include/soc/mcpwm_periph.h index ae5809c91ef..d807600c4a7 100644 --- a/tools/sdk/esp32c3/include/soc/include/soc/mcpwm_periph.h +++ b/tools/sdk/esp32c3/include/soc/include/soc/mcpwm_periph.h @@ -34,13 +34,13 @@ typedef struct { } operators[SOC_MCPWM_OPERATORS_PER_GROUP]; struct { const uint32_t fault_sig; - } detectors[SOC_MCPWM_FAULT_DETECTORS_PER_GROUP]; + } gpio_faults[SOC_MCPWM_GPIO_FAULTS_PER_GROUP]; struct { const uint32_t cap_sig; } captures[SOC_MCPWM_CAPTURE_CHANNELS_PER_TIMER]; struct { const uint32_t sync_sig; - } ext_syncers[SOC_MCPWM_EXT_SYNCERS_PER_GROUP]; + } gpio_synchros[SOC_MCPWM_GPIO_SYNCHROS_PER_GROUP]; } groups[SOC_MCPWM_GROUPS]; } mcpwm_signal_conn_t; diff --git a/tools/sdk/esp32c3/include/soc/include/soc/pcnt_periph.h b/tools/sdk/esp32c3/include/soc/include/soc/pcnt_periph.h index fa0f58221d5..966950c8461 100644 --- a/tools/sdk/esp32c3/include/soc/include/soc/pcnt_periph.h +++ b/tools/sdk/esp32c3/include/soc/include/soc/pcnt_periph.h @@ -1,4 +1,4 @@ -// Copyright 2019 Espressif Systems (Shanghai) PTE LTD +// Copyright 2019-2020 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. @@ -27,12 +27,14 @@ extern "C" { typedef struct { struct { struct { - const uint32_t pulse_sig; - const uint32_t control_sig; - } channels[SOC_PCNT_UNIT_CHANNEL_NUM]; - } units[SOC_PCNT_UNIT_NUM]; - const uint32_t irq; - const periph_module_t module; + struct { + const uint32_t pulse_sig; + const uint32_t control_sig; + } channels[SOC_PCNT_CHANNELS_PER_UNIT]; + } units[SOC_PCNT_UNITS_PER_GROUP]; + const uint32_t irq; + const periph_module_t module; + } groups[SOC_PCNT_GROUPS]; } pcnt_signal_conn_t; extern const pcnt_signal_conn_t pcnt_periph_signals; diff --git a/tools/sdk/esp32c3/include/soc/include/soc/rtc_io_periph.h b/tools/sdk/esp32c3/include/soc/include/soc/rtc_io_periph.h index e9309771c63..618b64cd8f7 100644 --- a/tools/sdk/esp32c3/include/soc/include/soc/rtc_io_periph.h +++ b/tools/sdk/esp32c3/include/soc/include/soc/rtc_io_periph.h @@ -27,7 +27,7 @@ #include "soc/rtc_cntl_reg.h" #include "soc/rtc_cntl_struct.h" -#if SOC_ADC_SUPPORT_RTC_CTRL +#if SOC_ADC_RTC_CTRL_SUPPORTED #include "soc/sens_struct.h" #endif diff --git a/tools/sdk/esp32c3/include/soc/include/soc/sdio_slave_periph.h b/tools/sdk/esp32c3/include/soc/include/soc/sdio_slave_periph.h index d39f72f5269..0f748ae12e5 100644 --- a/tools/sdk/esp32c3/include/soc/include/soc/sdio_slave_periph.h +++ b/tools/sdk/esp32c3/include/soc/include/soc/sdio_slave_periph.h @@ -15,9 +15,12 @@ #pragma once #include //include soc related (generated) definitions +#include "soc/soc_caps.h" #include "soc/soc_pins.h" +#ifdef SOC_SDIO_SLAVE_SUPPORTED #include "soc/slc_reg.h" #include "soc/slc_struct.h" +#endif #include "soc/host_reg.h" #include "soc/host_struct.h" #include "soc/hinf_reg.h" diff --git a/tools/sdk/esp32c3/include/soc/include/soc/spi_periph.h b/tools/sdk/esp32c3/include/soc/include/soc/spi_periph.h index 4ddb8b3f1ef..7aa38650356 100644 --- a/tools/sdk/esp32c3/include/soc/include/soc/spi_periph.h +++ b/tools/sdk/esp32c3/include/soc/include/soc/spi_periph.h @@ -30,8 +30,7 @@ #endif #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif #if CONFIG_IDF_TARGET_ESP32S2 @@ -41,8 +40,6 @@ extern "C" #define SPI_FWRITE_QIO 0 #endif - - /* Stores a bunch of per-spi-peripheral data. */ @@ -53,10 +50,22 @@ typedef struct { const uint8_t spiq_out; const uint8_t spiwp_out; const uint8_t spihd_out; +#if SOC_SPI_SUPPORT_OCT + const uint8_t spid4_out; + const uint8_t spid5_out; + const uint8_t spid6_out; + const uint8_t spid7_out; +#endif // SOC_SPI_SUPPORT_OCT const uint8_t spid_in; //GPIO mux input signals const uint8_t spiq_in; const uint8_t spiwp_in; const uint8_t spihd_in; +#if SOC_SPI_SUPPORT_OCT + const uint8_t spid4_in; + const uint8_t spid5_in; + const uint8_t spid6_in; + const uint8_t spid7_in; +#endif // SOC_SPI_SUPPORT_OCT const uint8_t spics_out[3]; // /CS GPIO output mux signals const uint8_t spics_in; const uint8_t spidqs_out; diff --git a/tools/sdk/esp32c3/include/soc/include/soc/uart_periph.h b/tools/sdk/esp32c3/include/soc/include/soc/uart_periph.h index f7e47099328..320b947c3b8 100644 --- a/tools/sdk/esp32c3/include/soc/include/soc/uart_periph.h +++ b/tools/sdk/esp32c3/include/soc/include/soc/uart_periph.h @@ -18,16 +18,40 @@ #include "soc/uart_struct.h" #include "soc/periph_defs.h" #include "soc/gpio_sig_map.h" +#include "soc/io_mux_reg.h" +#include "soc/uart_pins.h" #ifdef __cplusplus extern "C" { #endif +#define SOC_UART_TX_PIN_IDX (0) +#define SOC_UART_RX_PIN_IDX (1) +#define SOC_UART_RTS_PIN_IDX (2) +#define SOC_UART_CTS_PIN_IDX (3) + +/** + * @brief Macro that can be used to retrieve the signal of a certain pin for a + * certain UART. + */ +#define UART_PERIPH_SIGNAL(IDX, PIN) (uart_periph_signal[(IDX)].pins[(PIN)].signal) + +typedef struct { + /* Default GPIO number for this UART pin in the IOMUX. + * This value can be -1 if there is no default GPIO for a pin. + * For example, ESP32-C3 doesn't have any default GPIO for + * U0CTS and U0RTS. */ + int32_t default_gpio : 15; + /* Func which should be assigned to the GPIO to be used as UART */ + int32_t iomux_func : 4; + /* Marks if the current UART pin is input (or not) */ + uint32_t input : 1; + /* Signal in the GPIO signal map. */ + uint32_t signal : 12; +} uart_periph_sig_t; + typedef struct { - const uint8_t tx_sig; - const uint8_t rx_sig; - const uint8_t rts_sig; - const uint8_t cts_sig; + const uart_periph_sig_t pins[SOC_UART_PINS_COUNT]; const uint8_t irq; const periph_module_t module; } uart_signal_conn_t; diff --git a/tools/sdk/esp32c3/include/soc/include/soc/usb_phy_periph.h b/tools/sdk/esp32c3/include/soc/include/soc/usb_phy_periph.h new file mode 100644 index 00000000000..802d1720cec --- /dev/null +++ b/tools/sdk/esp32c3/include/soc/include/soc/usb_phy_periph.h @@ -0,0 +1,35 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once +#include +#include "soc/soc_caps.h" +#include "soc/periph_defs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + Stores a bunch of USB-peripheral data. +*/ +typedef struct { + const uint8_t extphy_vp_in; + const uint8_t extphy_vm_in; + const uint8_t extphy_rcv_in; + const uint8_t extphy_oen_out; + const uint8_t extphy_vpo_out; + const uint8_t extphy_vmo_out; + const uint8_t extphy_suspend_in; + const uint8_t extphy_speed_in; + const periph_module_t module; +} usb_phy_signal_conn_t; + +extern const usb_phy_signal_conn_t usb_phy_periph_signal; + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32c3/include/spi_flash/include/esp_partition.h b/tools/sdk/esp32c3/include/spi_flash/include/esp_partition.h index e59babb451b..36baea29860 100644 --- a/tools/sdk/esp32c3/include/spi_flash/include/esp_partition.h +++ b/tools/sdk/esp32c3/include/spi_flash/include/esp_partition.h @@ -87,6 +87,7 @@ typedef enum { ESP_PARTITION_SUBTYPE_DATA_COREDUMP = 0x03, //!< COREDUMP partition ESP_PARTITION_SUBTYPE_DATA_NVS_KEYS = 0x04, //!< Partition for NVS keys ESP_PARTITION_SUBTYPE_DATA_EFUSE_EM = 0x05, //!< Partition for emulate eFuse bits + ESP_PARTITION_SUBTYPE_DATA_UNDEFINED = 0x06, //!< Undefined (or unspecified) data partition ESP_PARTITION_SUBTYPE_DATA_ESPHTTPD = 0x80, //!< ESPHTTPD partition ESP_PARTITION_SUBTYPE_DATA_FAT = 0x81, //!< FAT partition diff --git a/tools/sdk/esp32c3/include/spi_flash/include/spi_flash/spi_flash_defs.h b/tools/sdk/esp32c3/include/spi_flash/include/spi_flash/spi_flash_defs.h index cf26fda1486..1ff0bfdea5c 100644 --- a/tools/sdk/esp32c3/include/spi_flash/include/spi_flash/spi_flash_defs.h +++ b/tools/sdk/esp32c3/include/spi_flash/include/spi_flash/spi_flash_defs.h @@ -68,3 +68,7 @@ #define SPI_FLASH_FASTRD_DUMMY_BITLEN 8 #define SPI_FLASH_SLOWRD_ADDR_BITLEN 24 #define SPI_FLASH_SLOWRD_DUMMY_BITLEN 0 +#define SPI_FLASH_OPISTR_ADDR_BITLEN 32 +#define SPI_FLASH_OPISTR_DUMMY_BITLEN 20 +#define SPI_FLASH_OPIDTR_ADDR_BITLEN 32 +#define SPI_FLASH_OPIDTR_DUMMY_BITLEN 40 diff --git a/tools/sdk/esp32c3/include/spi_flash/include/spi_flash_chip_driver.h b/tools/sdk/esp32c3/include/spi_flash/include/spi_flash_chip_driver.h index 9a143d84d2e..d2ef25bf6de 100644 --- a/tools/sdk/esp32c3/include/spi_flash/include/spi_flash_chip_driver.h +++ b/tools/sdk/esp32c3/include/spi_flash/include/spi_flash_chip_driver.h @@ -206,6 +206,11 @@ struct spi_flash_chip_t { * Get the capabilities of the flash chip. See SPI_FLASH_CHIP_CAP_* macros as reference. */ spi_flash_caps_t (*get_chip_caps)(esp_flash_t *chip); + + /** + * Configure the host registers to use the specified read mode set in the ``chip->read_mode``. + */ + esp_err_t (*config_host_io_mode)(esp_flash_t *chip, uint32_t flags); }; /* Pointer to an array of pointers to all known drivers for flash chips. This array is used diff --git a/tools/sdk/esp32c3/include/spi_flash/include/spi_flash_chip_generic.h b/tools/sdk/esp32c3/include/spi_flash/include/spi_flash_chip_generic.h index 9e99f73e44b..019a6966a40 100644 --- a/tools/sdk/esp32c3/include/spi_flash/include/spi_flash_chip_generic.h +++ b/tools/sdk/esp32c3/include/spi_flash/include/spi_flash_chip_generic.h @@ -370,14 +370,15 @@ esp_err_t spi_flash_common_set_io_mode(esp_flash_t *chip, esp_flash_wrsr_func_t * transactions. Also prepare the command to be sent in read functions. * * @param chip Pointer to SPI flash chip to use. If NULL, esp_flash_default_chip is substituted. - * @param addr_32bit Whether 32 bit commands will be used (Currently only W25Q256 and GD25Q256 are supported) + * @param flags Special rules to configure io mode, (i.e. Whether 32 bit commands will be used (Currently only W25Q256 and GD25Q256 are supported)) * * @return * - ESP_OK if success * - ESP_ERR_FLASH_NOT_INITIALISED if chip not initialized properly * - or other error passed from the ``configure_host_mode`` function of host driver */ -esp_err_t spi_flash_chip_generic_config_host_io_mode(esp_flash_t *chip, bool addr_32bit); +esp_err_t spi_flash_chip_generic_config_host_io_mode(esp_flash_t *chip, uint32_t flags); +#define SPI_FLASH_CONFIG_IO_MODE_32B_ADDR BIT(0) /** * @brief Handle explicit yield requests @@ -396,5 +397,15 @@ esp_err_t spi_flash_chip_generic_yield(esp_flash_t* chip, uint32_t wip); */ esp_err_t spi_flash_chip_generic_suspend_cmd_conf(esp_flash_t *chip); +/** + * + * @brief Read the chip unique ID unsupported function. + * + * @param chip Pointer to SPI flash chip to use. + * @param flash_unique_id Pointer to store output unique id (Although this function is an unsupported function, but the parameter should be kept for the consistence of the function pointer). + * @return Always ESP_ERR_NOT_SUPPORTED. + */ +esp_err_t spi_flash_chip_generic_read_unique_id_none(esp_flash_t *chip, uint64_t* flash_unique_id); + /// Default timeout configuration used by most chips -const flash_chip_op_timeout_t spi_flash_chip_generic_timeout; +extern const flash_chip_op_timeout_t spi_flash_chip_generic_timeout; diff --git a/tools/sdk/esp32c3/include/spi_flash/include/spi_flash_chip_mxic.h b/tools/sdk/esp32c3/include/spi_flash/include/spi_flash_chip_mxic.h index f998c1564e5..201ad496e2a 100644 --- a/tools/sdk/esp32c3/include/spi_flash/include/spi_flash_chip_mxic.h +++ b/tools/sdk/esp32c3/include/spi_flash/include/spi_flash_chip_mxic.h @@ -25,3 +25,10 @@ * is not found. */ extern const spi_flash_chip_t esp_flash_chip_mxic; + +/** + * MXIC OPI flash chip_drv, uses all the above functions for its operations. In + * default autodetection, this is used as a catchall if a more specific chip_drv + * is not found. + */ +extern const spi_flash_chip_t esp_flash_chip_mxic_opi; diff --git a/tools/sdk/esp32c3/include/spi_flash/include/spi_flash_private.h b/tools/sdk/esp32c3/include/spi_flash/include/spi_flash_private.h index f792faef657..9d822fb9475 100644 --- a/tools/sdk/esp32c3/include/spi_flash/include/spi_flash_private.h +++ b/tools/sdk/esp32c3/include/spi_flash/include/spi_flash_private.h @@ -26,6 +26,8 @@ #elif CONFIG_IDF_TARGET_ESP32S3 #include "esp32s3/rom/spi_flash.h" #endif +#include "esp_flash.h" +#include "hal/spi_flash_hal.h" #ifdef __cplusplus extern "C" { @@ -38,13 +40,15 @@ esp_err_t esp_opiflash_init(void); /** * @brief Make MSPI work under 20Mhz + * @param control_spi1 Select whether to control SPI1. For tuning, we need to use SPI1. After tuning (during startup stage), let the flash driver to control SPI1 */ -void spi_timing_enter_mspi_low_speed_mode(void); +void spi_timing_enter_mspi_low_speed_mode(bool control_spi1); /** * @brief Make MSPI work under the frequency as users set + * @param control_spi1 Select whether to control SPI1. For tuning, we need to use SPI1. After tuning (during startup stage), let the flash driver to control SPI1 */ -void spi_timing_enter_mspi_high_speed_mode(void); +void spi_timing_enter_mspi_high_speed_mode(bool control_spi1); /** * @brief Tune MSPI flash timing to make it work under high frequency @@ -56,12 +60,34 @@ void spi_timing_flash_tuning(void); */ void spi_timing_psram_tuning(void); +/** + * @brief To initislize the MSPI pins + */ +void esp_mspi_pin_init(void); + /** * @brief Set SPI1 registers to make ROM functions work * @note This function is used for setting SPI1 registers to the state that ROM SPI functions work */ void spi_flash_set_rom_required_regs(void); +/** + * @brief Initialize main flash + * @param chip Pointer to main SPI flash(SPI1 CS0) chip to use.. + */ +esp_err_t esp_flash_init_main(esp_flash_t *chip); + +/** + * @brief Should be only used by SPI1 Flash driver to know the necessary timing registers + * @param out_timing_config Pointer to timing_tuning parameters. + */ +void spi_timing_get_flash_timing_param(spi_flash_hal_timing_config_t *out_timing_config); + +/** + * @brief Judge if the flash in tuned + */ +bool spi_timine_config_flash_is_tuned(void); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32c3/include/wpa_supplicant/include/esp_supplicant/esp_dpp.h b/tools/sdk/esp32c3/include/wpa_supplicant/esp_supplicant/include/esp_dpp.h similarity index 100% rename from tools/sdk/esp32c3/include/wpa_supplicant/include/esp_supplicant/esp_dpp.h rename to tools/sdk/esp32c3/include/wpa_supplicant/esp_supplicant/include/esp_dpp.h diff --git a/tools/sdk/esp32c3/include/wpa_supplicant/include/esp_supplicant/esp_rrm.h b/tools/sdk/esp32c3/include/wpa_supplicant/esp_supplicant/include/esp_rrm.h similarity index 100% rename from tools/sdk/esp32c3/include/wpa_supplicant/include/esp_supplicant/esp_rrm.h rename to tools/sdk/esp32c3/include/wpa_supplicant/esp_supplicant/include/esp_rrm.h diff --git a/tools/sdk/esp32c3/include/wpa_supplicant/include/esp_supplicant/esp_wnm.h b/tools/sdk/esp32c3/include/wpa_supplicant/esp_supplicant/include/esp_wnm.h similarity index 100% rename from tools/sdk/esp32c3/include/wpa_supplicant/include/esp_supplicant/esp_wnm.h rename to tools/sdk/esp32c3/include/wpa_supplicant/esp_supplicant/include/esp_wnm.h diff --git a/tools/sdk/esp32c3/include/wpa_supplicant/include/esp_supplicant/esp_wpa.h b/tools/sdk/esp32c3/include/wpa_supplicant/esp_supplicant/include/esp_wpa.h similarity index 100% rename from tools/sdk/esp32c3/include/wpa_supplicant/include/esp_supplicant/esp_wpa.h rename to tools/sdk/esp32c3/include/wpa_supplicant/esp_supplicant/include/esp_wpa.h diff --git a/tools/sdk/esp32c3/include/wpa_supplicant/include/esp_supplicant/esp_wpa2.h b/tools/sdk/esp32c3/include/wpa_supplicant/esp_supplicant/include/esp_wpa2.h similarity index 100% rename from tools/sdk/esp32c3/include/wpa_supplicant/include/esp_supplicant/esp_wpa2.h rename to tools/sdk/esp32c3/include/wpa_supplicant/esp_supplicant/include/esp_wpa2.h diff --git a/tools/sdk/esp32c3/include/wpa_supplicant/include/esp_supplicant/esp_wps.h b/tools/sdk/esp32c3/include/wpa_supplicant/esp_supplicant/include/esp_wps.h similarity index 100% rename from tools/sdk/esp32c3/include/wpa_supplicant/include/esp_supplicant/esp_wps.h rename to tools/sdk/esp32c3/include/wpa_supplicant/esp_supplicant/include/esp_wps.h diff --git a/tools/sdk/esp32c3/ld/esp32c3.peripherals.ld b/tools/sdk/esp32c3/ld/esp32c3.peripherals.ld index 494cbb9b6b2..710ae9aeea6 100644 --- a/tools/sdk/esp32c3/ld/esp32c3.peripherals.ld +++ b/tools/sdk/esp32c3/ld/esp32c3.peripherals.ld @@ -7,7 +7,7 @@ PROVIDE ( SIGMADELTA = 0x60004f00 ); PROVIDE ( RTCCNTL = 0x60008000 ); PROVIDE ( RTCIO = 0x60008400 ); PROVIDE ( HINF = 0x6000B000 ); -PROVIDE ( I2S1 = 0x6002d000 ); +PROVIDE ( I2S0 = 0x6002d000 ); PROVIDE ( I2C0 = 0x60013000 ); PROVIDE ( UHCI0 = 0x60014000 ); PROVIDE ( UHCI1 = 0x6000c000 ); diff --git a/tools/sdk/esp32c3/ld/esp32c3.rom.api.ld b/tools/sdk/esp32c3/ld/esp32c3.rom.api.ld index 5530bf0dce3..e05d9b8aa41 100644 --- a/tools/sdk/esp32c3/ld/esp32c3.rom.api.ld +++ b/tools/sdk/esp32c3/ld/esp32c3.rom.api.ld @@ -1,5 +1,11 @@ /** ROM APIs */ + +/* user may provide newer version of tjpgd */ +/* so here directly assign the symbols with the ROM API address to make sure one from rom is correctly linked */ +PROVIDE ( esp_rom_tjpgd_decomp = 0x40000108 ); +PROVIDE ( esp_rom_tjpgd_prepare = 0x40000104 ); + PROVIDE ( esp_rom_crc32_le = crc32_le ); PROVIDE ( esp_rom_crc16_le = crc16_le ); PROVIDE ( esp_rom_crc8_le = crc8_le ); diff --git a/tools/sdk/esp32c3/ld/esp32c3.rom.ld b/tools/sdk/esp32c3/ld/esp32c3.rom.ld index dcafa5edd24..4b42f866e5f 100644 --- a/tools/sdk/esp32c3/ld/esp32c3.rom.ld +++ b/tools/sdk/esp32c3/ld/esp32c3.rom.ld @@ -89,8 +89,8 @@ tinfl_decompress_mem_to_mem = 0x40000100; ***************************************/ /* Functions */ -jd_prepare = 0x40000104; -jd_decomp = 0x40000108; +PROVIDE( jd_prepare = 0x40000104 ); +PROVIDE( jd_decomp = 0x40000108 ); /*************************************** @@ -260,7 +260,7 @@ PROVIDE( esp_flash_chip_driver_initialized = 0x400002fc ); PROVIDE( esp_flash_read_id = 0x40000300 ); PROVIDE( esp_flash_get_size = 0x40000304 ); PROVIDE( esp_flash_erase_chip = 0x40000308 ); -PROVIDE( esp_flash_erase_region = 0x4000030c ); +PROVIDE( rom_esp_flash_erase_region = 0x4000030c ); PROVIDE( esp_flash_get_chip_write_protect = 0x40000310 ); PROVIDE( esp_flash_set_chip_write_protect = 0x40000314 ); PROVIDE( esp_flash_get_protectable_regions = 0x40000318 ); @@ -1606,7 +1606,7 @@ rcSetTxAmpduLimit = 0x4000176c; rcTxUpdatePer = 0x40001770; rcUpdateAckSnr = 0x40001774; rcUpdateRate = 0x40001778; -rcUpdateTxDone = 0x4000177c; +/* rcUpdateTxDone = 0x4000177c; */ rcUpdateTxDoneAmpdu2 = 0x40001780; rcUpSched = 0x40001784; rssi_margin = 0x40001788; diff --git a/tools/sdk/esp32c3/ld/libbtdm_app.a b/tools/sdk/esp32c3/ld/libbtdm_app.a index dfb9909af20..6c0defb2e79 100644 Binary files a/tools/sdk/esp32c3/ld/libbtdm_app.a and b/tools/sdk/esp32c3/ld/libbtdm_app.a differ diff --git a/tools/sdk/esp32c3/ld/memory.ld b/tools/sdk/esp32c3/ld/memory.ld index 3267ab1f551..250e0796cbc 100644 --- a/tools/sdk/esp32c3/ld/memory.ld +++ b/tools/sdk/esp32c3/ld/memory.ld @@ -1,3 +1,8 @@ +/* + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /** * ESP32-C3 Linker Script Memory Layout * This file describes the memory layout (memory blocks) by virtual memory addresses. @@ -11,6 +16,17 @@ */ /* List of deprecated options */ +/* + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* CPU instruction prefetch padding size for flash mmap scenario */ +_esp_flash_mmap_prefetch_pad_size = 16; +/* CPU instruction prefetch padding size for memory protection scenario */ +_esp_memprot_prefetch_pad_size = 16; +/* Memory alignment size for PMS */ +_esp_memprot_align_size = 512; MEMORY { /** diff --git a/tools/sdk/esp32c3/ld/sections.ld b/tools/sdk/esp32c3/ld/sections.ld index fca4b594bca..2338ee8b467 100644 --- a/tools/sdk/esp32c3/ld/sections.ld +++ b/tools/sdk/esp32c3/ld/sections.ld @@ -2,6 +2,12 @@ /* Espressif IoT Development Framework Linker Script */ /* Generated from: /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/ld/esp32c3/sections.ld.in */ +/* + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + /* Default entry point */ ENTRY(call_start_cpu0); @@ -157,7 +163,7 @@ SECTIONS *libesp_system.a:esp_system.*(.literal.esp_system_abort .text.esp_system_abort) *libesp_system.a:ubsan.*(.literal .literal.* .text .text.*) *libfreertos.a:(EXCLUDE_FILE(*libfreertos.a:port.* *libfreertos.a:port_common.*) .literal EXCLUDE_FILE(*libfreertos.a:port.* *libfreertos.a:port_common.*) .literal.* EXCLUDE_FILE(*libfreertos.a:port.* *libfreertos.a:port_common.*) .text EXCLUDE_FILE(*libfreertos.a:port.* *libfreertos.a:port_common.*) .text.*) - *libfreertos.a:port.*(.text .text.prvTaskExitError .text.pxPortInitialiseStack .text.vApplicationStackOverflowHook .text.vPortCPUAcquireMutex .text.vPortCPUAcquireMutexTimeout .text.vPortCPUInitializeMutex .text.vPortCPUReleaseMutex .text.vPortClearInterruptMask .text.vPortEndScheduler .text.vPortEnterCritical .text.vPortExitCritical .text.vPortSetInterruptMask .text.vPortSetStackWatchpoint .text.vPortSetupTimer .text.vPortYield .text.vPortYieldFromISR .text.vPortYieldOtherCore .text.xPortGetTickRateHz .text.xPortInIsrContext .text.xPortStartScheduler) + *libfreertos.a:port.*(.text .text.prvTaskExitError .text.pxPortInitialiseStack .text.vApplicationStackOverflowHook .text.vPortCPUAcquireMutex .text.vPortCPUAcquireMutexTimeout .text.vPortCPUInitializeMutex .text.vPortCPUReleaseMutex .text.vPortClearInterruptMask .text.vPortEndScheduler .text.vPortEnterCritical .text.vPortExitCritical .text.vPortSetInterruptMask .text.vPortSetStackWatchpoint .text.vPortYield .text.vPortYieldFromISR .text.vPortYieldOtherCore .text.xPortGetTickRateHz .text.xPortInIsrContext .text.xPortStartScheduler) *libfreertos.a:port_common.*(.text .text.esp_startup_start_app_common) *libgcc.a:_divsf3.*(.literal .literal.* .text .text.*) *libgcc.a:lib2funcs.*(.literal .literal.* .text .text.*) @@ -182,6 +188,7 @@ SECTIONS *liblog.a:log_freertos.*(.literal.esp_log_impl_unlock .text.esp_log_impl_unlock) *liblog.a:log_freertos.*(.literal.esp_log_timestamp .text.esp_log_timestamp) *libnewlib.a:abort.*(.literal .literal.* .text .text.*) + *libnewlib.a:assert.*(.literal .literal.* .text .text.*) *libnewlib.a:heap.*(.literal .literal.* .text .text.*) *libnewlib.a:stdatomic.*(.literal .literal.* .text .text.*) *libriscv.a:interrupt.*(.literal .literal.* .text .text.*) @@ -260,6 +267,7 @@ SECTIONS *libheap.a:heap_tlsf.*(.rodata .rodata.*) *libheap.a:multi_heap.*(.rodata .rodata.*) *libnewlib.a:abort.*(.rodata .rodata.*) + *libnewlib.a:assert.*(.rodata .rodata.*) *libnewlib.a:heap.*(.rodata .rodata.*) *libnewlib.a:stdatomic.*(.rodata .rodata.*) _nimble_data_start = ABSOLUTE(.); @@ -303,8 +311,8 @@ SECTIONS _bss_start = ABSOLUTE(.); *(.bss .bss.*) - *(.ext_ram.bss .ext_ram.bss.*) *(.dynbss .dynsbss .gnu.linkonce.b .gnu.linkonce.b.* .gnu.linkonce.sb .gnu.linkonce.sb.* .gnu.linkonce.sb2 .gnu.linkonce.sb2.* .sbss .sbss.* .sbss2 .sbss2.* .scommon .share.mem) + *(.ext_ram.bss .ext_ram.bss.*) *(COMMON) _bt_bss_start = ABSOLUTE(.); *libbt.a:(.bss .bss.* COMMON) @@ -343,7 +351,7 @@ SECTIONS _instruction_reserved_start = ABSOLUTE(.); _text_start = ABSOLUTE(.); - *(EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libgcc.a:lib2funcs.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libriscv.a:interrupt.* *libriscv.a:vectors.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .literal EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libgcc.a:lib2funcs.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libriscv.a:interrupt.* *libriscv.a:vectors.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .literal.* EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libgcc.a:lib2funcs.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libriscv.a:interrupt.* *libriscv.a:vectors.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .text EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libgcc.a:lib2funcs.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libriscv.a:interrupt.* *libriscv.a:vectors.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .text.*) + *(EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libgcc.a:lib2funcs.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:assert.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libriscv.a:interrupt.* *libriscv.a:vectors.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .literal EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libgcc.a:lib2funcs.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:assert.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libriscv.a:interrupt.* *libriscv.a:vectors.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .literal.* EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libgcc.a:lib2funcs.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:assert.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libriscv.a:interrupt.* *libriscv.a:vectors.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .text EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libgcc.a:lib2funcs.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:assert.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libriscv.a:interrupt.* *libriscv.a:vectors.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .text.*) *(.wifi0iram .wifi0iram.*) *(.wifiorslpiram .wifiorslpiram.*) *(.wifirxiram .wifirxiram.*) @@ -369,7 +377,7 @@ SECTIONS * safe access to up to 16 bytes after the last real instruction, add * dummy bytes to ensure this */ - . += 16; + . += _esp_flash_mmap_prefetch_pad_size; _text_end = ABSOLUTE(.); _instruction_reserved_end = ABSOLUTE(.); @@ -417,7 +425,7 @@ SECTIONS { _flash_rodata_start = ABSOLUTE(.); - *(EXCLUDE_FILE(*libgcov.a *libphy.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_hw_support.a:rtc_clk.* *libesp_system.a:esp_err.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libnewlib.a:abort.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .rodata EXCLUDE_FILE(*libgcov.a *libphy.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_hw_support.a:rtc_clk.* *libesp_system.a:esp_err.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libnewlib.a:abort.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .rodata.*) + *(EXCLUDE_FILE(*libgcov.a *libphy.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_hw_support.a:rtc_clk.* *libesp_system.a:esp_err.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libnewlib.a:abort.* *libnewlib.a:assert.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .rodata EXCLUDE_FILE(*libgcov.a *libphy.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_hw_support.a:rtc_clk.* *libesp_system.a:esp_err.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libnewlib.a:abort.* *libnewlib.a:assert.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .rodata.*) *(.rodata_wlog_error .rodata_wlog_error.*) *(.irom1.text) /* catch stray ICACHE_RODATA_ATTR */ @@ -513,8 +521,9 @@ SECTIONS /* Marks the end of IRAM code segment */ .iram0.text_end (NOLOAD) : { - /* C3 memprot requires 512 B alignment for split lines */ - . = ALIGN (0x200); + /* ESP32-C3 memprot requires 16B padding for possible CPU prefetch and 512B alignment for PMS split lines */ + . += _esp_memprot_prefetch_pad_size; + . = ALIGN(_esp_memprot_align_size); /* iram_end_test section exists for use by memprot unit tests only */ *(.iram_end_test) _iram_text_end = ABSOLUTE(.); diff --git a/tools/sdk/esp32c3/lib/libapp_trace.a b/tools/sdk/esp32c3/lib/libapp_trace.a index a34c8f64c4f..f41ecffbefc 100644 Binary files a/tools/sdk/esp32c3/lib/libapp_trace.a and b/tools/sdk/esp32c3/lib/libapp_trace.a differ diff --git a/tools/sdk/esp32c3/lib/libapp_update.a b/tools/sdk/esp32c3/lib/libapp_update.a index 1067acf00a0..a76a5a0d19e 100644 Binary files a/tools/sdk/esp32c3/lib/libapp_update.a and b/tools/sdk/esp32c3/lib/libapp_update.a differ diff --git a/tools/sdk/esp32c3/lib/libasio.a b/tools/sdk/esp32c3/lib/libasio.a index 3b5e286f518..e501be2ec82 100644 Binary files a/tools/sdk/esp32c3/lib/libasio.a and b/tools/sdk/esp32c3/lib/libasio.a differ diff --git a/tools/sdk/esp32c3/lib/libbootloader_support.a b/tools/sdk/esp32c3/lib/libbootloader_support.a index 8df3f29df30..8dee3407a13 100644 Binary files a/tools/sdk/esp32c3/lib/libbootloader_support.a and b/tools/sdk/esp32c3/lib/libbootloader_support.a differ diff --git a/tools/sdk/esp32c3/lib/libbt.a b/tools/sdk/esp32c3/lib/libbt.a index 1da513fa9ec..97808822530 100644 Binary files a/tools/sdk/esp32c3/lib/libbt.a and b/tools/sdk/esp32c3/lib/libbt.a differ diff --git a/tools/sdk/esp32c3/lib/libcbor.a b/tools/sdk/esp32c3/lib/libcbor.a index 450982ca23a..a219da6d5a6 100644 Binary files a/tools/sdk/esp32c3/lib/libcbor.a and b/tools/sdk/esp32c3/lib/libcbor.a differ diff --git a/tools/sdk/esp32c3/lib/libcoap.a b/tools/sdk/esp32c3/lib/libcoap.a index 8237ecd6659..407310ba1cb 100644 Binary files a/tools/sdk/esp32c3/lib/libcoap.a and b/tools/sdk/esp32c3/lib/libcoap.a differ diff --git a/tools/sdk/esp32c3/lib/libcoexist.a b/tools/sdk/esp32c3/lib/libcoexist.a index 63ca61e6781..6f03cab0b8e 100644 Binary files a/tools/sdk/esp32c3/lib/libcoexist.a and b/tools/sdk/esp32c3/lib/libcoexist.a differ diff --git a/tools/sdk/esp32c3/lib/libconsole.a b/tools/sdk/esp32c3/lib/libconsole.a index 756dc0fe7a4..91bd32add2d 100644 Binary files a/tools/sdk/esp32c3/lib/libconsole.a and b/tools/sdk/esp32c3/lib/libconsole.a differ diff --git a/tools/sdk/esp32c3/lib/libcore.a b/tools/sdk/esp32c3/lib/libcore.a index b5cb732188e..10e7ca5a83b 100644 Binary files a/tools/sdk/esp32c3/lib/libcore.a and b/tools/sdk/esp32c3/lib/libcore.a differ diff --git a/tools/sdk/esp32c3/lib/libcxx.a b/tools/sdk/esp32c3/lib/libcxx.a index 54097a0d58d..9617dd86b74 100644 Binary files a/tools/sdk/esp32c3/lib/libcxx.a and b/tools/sdk/esp32c3/lib/libcxx.a differ diff --git a/tools/sdk/esp32c3/lib/libdriver.a b/tools/sdk/esp32c3/lib/libdriver.a index 0a9452b0fb5..71809d7ec58 100644 Binary files a/tools/sdk/esp32c3/lib/libdriver.a and b/tools/sdk/esp32c3/lib/libdriver.a differ diff --git a/tools/sdk/esp32c3/lib/libefuse.a b/tools/sdk/esp32c3/lib/libefuse.a index 82e146db9cf..f4bb53d7dae 100644 Binary files a/tools/sdk/esp32c3/lib/libefuse.a and b/tools/sdk/esp32c3/lib/libefuse.a differ diff --git a/tools/sdk/esp32c3/lib/libesp-tls.a b/tools/sdk/esp32c3/lib/libesp-tls.a index 1024583b4d0..4e304a6646f 100644 Binary files a/tools/sdk/esp32c3/lib/libesp-tls.a and b/tools/sdk/esp32c3/lib/libesp-tls.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_adc_cal.a b/tools/sdk/esp32c3/lib/libesp_adc_cal.a index e1c5cb80d85..757dbdaf9da 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_adc_cal.a and b/tools/sdk/esp32c3/lib/libesp_adc_cal.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_common.a b/tools/sdk/esp32c3/lib/libesp_common.a index b3c608656a2..577a8884b7f 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_common.a and b/tools/sdk/esp32c3/lib/libesp_common.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_eth.a b/tools/sdk/esp32c3/lib/libesp_eth.a index c7224bd70fb..457368b2747 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_eth.a and b/tools/sdk/esp32c3/lib/libesp_eth.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_event.a b/tools/sdk/esp32c3/lib/libesp_event.a index 6731890ec9f..eb12ef2bb70 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_event.a and b/tools/sdk/esp32c3/lib/libesp_event.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_gdbstub.a b/tools/sdk/esp32c3/lib/libesp_gdbstub.a index 8c2bfcd4748..e7c39833d73 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_gdbstub.a and b/tools/sdk/esp32c3/lib/libesp_gdbstub.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_hid.a b/tools/sdk/esp32c3/lib/libesp_hid.a index 9a5a416b6fb..f976d5ab228 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_hid.a and b/tools/sdk/esp32c3/lib/libesp_hid.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_http_client.a b/tools/sdk/esp32c3/lib/libesp_http_client.a index defe600d19c..f82ad10086d 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_http_client.a and b/tools/sdk/esp32c3/lib/libesp_http_client.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_http_server.a b/tools/sdk/esp32c3/lib/libesp_http_server.a index 695a50c5026..78a0206aab2 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_http_server.a and b/tools/sdk/esp32c3/lib/libesp_http_server.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_https_ota.a b/tools/sdk/esp32c3/lib/libesp_https_ota.a index d2bddf2e66a..e1702191f75 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_https_ota.a and b/tools/sdk/esp32c3/lib/libesp_https_ota.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_https_server.a b/tools/sdk/esp32c3/lib/libesp_https_server.a index 9d34bad80ed..41c852b2f76 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_https_server.a and b/tools/sdk/esp32c3/lib/libesp_https_server.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_hw_support.a b/tools/sdk/esp32c3/lib/libesp_hw_support.a index 2add3fc4ddc..441d8231622 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_hw_support.a and b/tools/sdk/esp32c3/lib/libesp_hw_support.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_ipc.a b/tools/sdk/esp32c3/lib/libesp_ipc.a index a9e2866be2f..cb9181592e1 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_ipc.a and b/tools/sdk/esp32c3/lib/libesp_ipc.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_lcd.a b/tools/sdk/esp32c3/lib/libesp_lcd.a index 98deb0772bb..d5f9a5d15a7 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_lcd.a and b/tools/sdk/esp32c3/lib/libesp_lcd.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_littlefs.a b/tools/sdk/esp32c3/lib/libesp_littlefs.a index eb633465efc..10ece18e6f5 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_littlefs.a and b/tools/sdk/esp32c3/lib/libesp_littlefs.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_local_ctrl.a b/tools/sdk/esp32c3/lib/libesp_local_ctrl.a index f250809fe95..79208e5d357 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_local_ctrl.a and b/tools/sdk/esp32c3/lib/libesp_local_ctrl.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_netif.a b/tools/sdk/esp32c3/lib/libesp_netif.a index 2bd02105dcb..3deef9ca7dc 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_netif.a and b/tools/sdk/esp32c3/lib/libesp_netif.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_phy.a b/tools/sdk/esp32c3/lib/libesp_phy.a index 8c1c737edd1..b2b9885f59f 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_phy.a and b/tools/sdk/esp32c3/lib/libesp_phy.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_pm.a b/tools/sdk/esp32c3/lib/libesp_pm.a index ca179e03416..f32146b8ca0 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_pm.a and b/tools/sdk/esp32c3/lib/libesp_pm.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_ringbuf.a b/tools/sdk/esp32c3/lib/libesp_ringbuf.a index 0287bd2b615..d08c234dc5b 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_ringbuf.a and b/tools/sdk/esp32c3/lib/libesp_ringbuf.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_rom.a b/tools/sdk/esp32c3/lib/libesp_rom.a index a40874959f0..b913f014ead 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_rom.a and b/tools/sdk/esp32c3/lib/libesp_rom.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_serial_slave_link.a b/tools/sdk/esp32c3/lib/libesp_serial_slave_link.a index 75be4ef3af9..3a5cbd2b6ad 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_serial_slave_link.a and b/tools/sdk/esp32c3/lib/libesp_serial_slave_link.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_system.a b/tools/sdk/esp32c3/lib/libesp_system.a index db292afc28b..f8421329011 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_system.a and b/tools/sdk/esp32c3/lib/libesp_system.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_timer.a b/tools/sdk/esp32c3/lib/libesp_timer.a index 8ca90dd8d13..d74a2ac003b 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_timer.a and b/tools/sdk/esp32c3/lib/libesp_timer.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_websocket_client.a b/tools/sdk/esp32c3/lib/libesp_websocket_client.a index 5759d46a4c0..d02f65a06fa 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_websocket_client.a and b/tools/sdk/esp32c3/lib/libesp_websocket_client.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_wifi.a b/tools/sdk/esp32c3/lib/libesp_wifi.a index 3abbd08d561..3a89f878c94 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_wifi.a and b/tools/sdk/esp32c3/lib/libesp_wifi.a differ diff --git a/tools/sdk/esp32c3/lib/libespcoredump.a b/tools/sdk/esp32c3/lib/libespcoredump.a index 5ec841fe52f..4af35b8b809 100644 Binary files a/tools/sdk/esp32c3/lib/libespcoredump.a and b/tools/sdk/esp32c3/lib/libespcoredump.a differ diff --git a/tools/sdk/esp32c3/lib/libespnow.a b/tools/sdk/esp32c3/lib/libespnow.a index e7fc74167da..0d53db2568a 100644 Binary files a/tools/sdk/esp32c3/lib/libespnow.a and b/tools/sdk/esp32c3/lib/libespnow.a differ diff --git a/tools/sdk/esp32c3/lib/libexpat.a b/tools/sdk/esp32c3/lib/libexpat.a index 04a8b9228ae..b2c4044a5b2 100644 Binary files a/tools/sdk/esp32c3/lib/libexpat.a and b/tools/sdk/esp32c3/lib/libexpat.a differ diff --git a/tools/sdk/esp32c3/lib/libfatfs.a b/tools/sdk/esp32c3/lib/libfatfs.a index 2ee33f287ef..86f197e368c 100644 Binary files a/tools/sdk/esp32c3/lib/libfatfs.a and b/tools/sdk/esp32c3/lib/libfatfs.a differ diff --git a/tools/sdk/esp32c3/lib/libfreemodbus.a b/tools/sdk/esp32c3/lib/libfreemodbus.a index fdf173ce0b7..b46ecaac145 100644 Binary files a/tools/sdk/esp32c3/lib/libfreemodbus.a and b/tools/sdk/esp32c3/lib/libfreemodbus.a differ diff --git a/tools/sdk/esp32c3/lib/libfreertos.a b/tools/sdk/esp32c3/lib/libfreertos.a index f92ab48d0fe..ac3c0fd50d1 100644 Binary files a/tools/sdk/esp32c3/lib/libfreertos.a and b/tools/sdk/esp32c3/lib/libfreertos.a differ diff --git a/tools/sdk/esp32c3/lib/libhal.a b/tools/sdk/esp32c3/lib/libhal.a index 6557d2b08ff..12ad247f09c 100644 Binary files a/tools/sdk/esp32c3/lib/libhal.a and b/tools/sdk/esp32c3/lib/libhal.a differ diff --git a/tools/sdk/esp32c3/lib/libheap.a b/tools/sdk/esp32c3/lib/libheap.a index e44ac81ef17..240bbab74e0 100644 Binary files a/tools/sdk/esp32c3/lib/libheap.a and b/tools/sdk/esp32c3/lib/libheap.a differ diff --git a/tools/sdk/esp32c3/lib/libjson.a b/tools/sdk/esp32c3/lib/libjson.a index d06a69ea087..4ceb6b0a9a3 100644 Binary files a/tools/sdk/esp32c3/lib/libjson.a and b/tools/sdk/esp32c3/lib/libjson.a differ diff --git a/tools/sdk/esp32c3/lib/liblibsodium.a b/tools/sdk/esp32c3/lib/liblibsodium.a index 09e2d39437f..8c9e365ef88 100644 Binary files a/tools/sdk/esp32c3/lib/liblibsodium.a and b/tools/sdk/esp32c3/lib/liblibsodium.a differ diff --git a/tools/sdk/esp32c3/lib/liblog.a b/tools/sdk/esp32c3/lib/liblog.a index 8fa8d06e470..4be299b20b5 100644 Binary files a/tools/sdk/esp32c3/lib/liblog.a and b/tools/sdk/esp32c3/lib/liblog.a differ diff --git a/tools/sdk/esp32c3/lib/liblwip.a b/tools/sdk/esp32c3/lib/liblwip.a index 85c39596b38..668266754ba 100644 Binary files a/tools/sdk/esp32c3/lib/liblwip.a and b/tools/sdk/esp32c3/lib/liblwip.a differ diff --git a/tools/sdk/esp32c3/lib/libmbedcrypto.a b/tools/sdk/esp32c3/lib/libmbedcrypto.a index 16db3e212e1..b1cb253b4d7 100644 Binary files a/tools/sdk/esp32c3/lib/libmbedcrypto.a and b/tools/sdk/esp32c3/lib/libmbedcrypto.a differ diff --git a/tools/sdk/esp32c3/lib/libmbedtls.a b/tools/sdk/esp32c3/lib/libmbedtls.a index 61beddc0fb0..3abdde11dd3 100644 Binary files a/tools/sdk/esp32c3/lib/libmbedtls.a and b/tools/sdk/esp32c3/lib/libmbedtls.a differ diff --git a/tools/sdk/esp32c3/lib/libmbedx509.a b/tools/sdk/esp32c3/lib/libmbedx509.a index 006d9a1063e..3311a8bc098 100644 Binary files a/tools/sdk/esp32c3/lib/libmbedx509.a and b/tools/sdk/esp32c3/lib/libmbedx509.a differ diff --git a/tools/sdk/esp32c3/lib/libmdns.a b/tools/sdk/esp32c3/lib/libmdns.a index fb12f82efa3..b3df4d78b13 100644 Binary files a/tools/sdk/esp32c3/lib/libmdns.a and b/tools/sdk/esp32c3/lib/libmdns.a differ diff --git a/tools/sdk/esp32c3/lib/libmesh.a b/tools/sdk/esp32c3/lib/libmesh.a index c704dbca944..ac0bceb375b 100644 Binary files a/tools/sdk/esp32c3/lib/libmesh.a and b/tools/sdk/esp32c3/lib/libmesh.a differ diff --git a/tools/sdk/esp32c3/lib/libmqtt.a b/tools/sdk/esp32c3/lib/libmqtt.a index b539791538e..7b2acfde2a4 100644 Binary files a/tools/sdk/esp32c3/lib/libmqtt.a and b/tools/sdk/esp32c3/lib/libmqtt.a differ diff --git a/tools/sdk/esp32c3/lib/libnet80211.a b/tools/sdk/esp32c3/lib/libnet80211.a index cef2683a011..79f91f7f17d 100644 Binary files a/tools/sdk/esp32c3/lib/libnet80211.a and b/tools/sdk/esp32c3/lib/libnet80211.a differ diff --git a/tools/sdk/esp32c3/lib/libnewlib.a b/tools/sdk/esp32c3/lib/libnewlib.a index a08643fd313..e0ebeacbfd1 100644 Binary files a/tools/sdk/esp32c3/lib/libnewlib.a and b/tools/sdk/esp32c3/lib/libnewlib.a differ diff --git a/tools/sdk/esp32c3/lib/libnghttp.a b/tools/sdk/esp32c3/lib/libnghttp.a index 8eddb169cda..ff7116554b6 100644 Binary files a/tools/sdk/esp32c3/lib/libnghttp.a and b/tools/sdk/esp32c3/lib/libnghttp.a differ diff --git a/tools/sdk/esp32c3/lib/libnvs_flash.a b/tools/sdk/esp32c3/lib/libnvs_flash.a index b5ae5210279..72bb887799b 100644 Binary files a/tools/sdk/esp32c3/lib/libnvs_flash.a and b/tools/sdk/esp32c3/lib/libnvs_flash.a differ diff --git a/tools/sdk/esp32c3/lib/libopenssl.a b/tools/sdk/esp32c3/lib/libopenssl.a index c954fa8d35e..4019e41f7a4 100644 Binary files a/tools/sdk/esp32c3/lib/libopenssl.a and b/tools/sdk/esp32c3/lib/libopenssl.a differ diff --git a/tools/sdk/esp32c3/lib/libpp.a b/tools/sdk/esp32c3/lib/libpp.a index e3303ea3a26..4891f8b5c92 100644 Binary files a/tools/sdk/esp32c3/lib/libpp.a and b/tools/sdk/esp32c3/lib/libpp.a differ diff --git a/tools/sdk/esp32c3/lib/libprotobuf-c.a b/tools/sdk/esp32c3/lib/libprotobuf-c.a index fb617e7bb26..2427732f9a7 100644 Binary files a/tools/sdk/esp32c3/lib/libprotobuf-c.a and b/tools/sdk/esp32c3/lib/libprotobuf-c.a differ diff --git a/tools/sdk/esp32c3/lib/libprotocomm.a b/tools/sdk/esp32c3/lib/libprotocomm.a index 6f5d35f47cb..b604bd05cd1 100644 Binary files a/tools/sdk/esp32c3/lib/libprotocomm.a and b/tools/sdk/esp32c3/lib/libprotocomm.a differ diff --git a/tools/sdk/esp32c3/lib/libpthread.a b/tools/sdk/esp32c3/lib/libpthread.a index c48f7233bd1..b16b6ff4e64 100644 Binary files a/tools/sdk/esp32c3/lib/libpthread.a and b/tools/sdk/esp32c3/lib/libpthread.a differ diff --git a/tools/sdk/esp32c3/lib/libriscv.a b/tools/sdk/esp32c3/lib/libriscv.a index a789864ffd1..fbb3ae7cc3b 100644 Binary files a/tools/sdk/esp32c3/lib/libriscv.a and b/tools/sdk/esp32c3/lib/libriscv.a differ diff --git a/tools/sdk/esp32c3/lib/libsdmmc.a b/tools/sdk/esp32c3/lib/libsdmmc.a index 5d4b496d58e..04cbb827fc5 100644 Binary files a/tools/sdk/esp32c3/lib/libsdmmc.a and b/tools/sdk/esp32c3/lib/libsdmmc.a differ diff --git a/tools/sdk/esp32c3/lib/libsmartconfig.a b/tools/sdk/esp32c3/lib/libsmartconfig.a index 6422d44d19d..bd9cc0d4cee 100644 Binary files a/tools/sdk/esp32c3/lib/libsmartconfig.a and b/tools/sdk/esp32c3/lib/libsmartconfig.a differ diff --git a/tools/sdk/esp32c3/lib/libsoc.a b/tools/sdk/esp32c3/lib/libsoc.a index 873bd66b22c..77e18e1335a 100644 Binary files a/tools/sdk/esp32c3/lib/libsoc.a and b/tools/sdk/esp32c3/lib/libsoc.a differ diff --git a/tools/sdk/esp32c3/lib/libspi_flash.a b/tools/sdk/esp32c3/lib/libspi_flash.a index 46caf04f104..ac3b0ee32af 100644 Binary files a/tools/sdk/esp32c3/lib/libspi_flash.a and b/tools/sdk/esp32c3/lib/libspi_flash.a differ diff --git a/tools/sdk/esp32c3/lib/libspiffs.a b/tools/sdk/esp32c3/lib/libspiffs.a index 79fa1d28c2e..120571b2b86 100644 Binary files a/tools/sdk/esp32c3/lib/libspiffs.a and b/tools/sdk/esp32c3/lib/libspiffs.a differ diff --git a/tools/sdk/esp32c3/lib/libtcp_transport.a b/tools/sdk/esp32c3/lib/libtcp_transport.a index 0348541c763..42d386c8e1a 100644 Binary files a/tools/sdk/esp32c3/lib/libtcp_transport.a and b/tools/sdk/esp32c3/lib/libtcp_transport.a differ diff --git a/tools/sdk/esp32c3/lib/libtcpip_adapter.a b/tools/sdk/esp32c3/lib/libtcpip_adapter.a index ba120e3035f..316d8562b49 100644 Binary files a/tools/sdk/esp32c3/lib/libtcpip_adapter.a and b/tools/sdk/esp32c3/lib/libtcpip_adapter.a differ diff --git a/tools/sdk/esp32c3/lib/libunity.a b/tools/sdk/esp32c3/lib/libunity.a index 991a5fe1787..d35d93ca03f 100644 Binary files a/tools/sdk/esp32c3/lib/libunity.a and b/tools/sdk/esp32c3/lib/libunity.a differ diff --git a/tools/sdk/esp32c3/lib/libvfs.a b/tools/sdk/esp32c3/lib/libvfs.a index d52d723ee2b..4b644d301c0 100644 Binary files a/tools/sdk/esp32c3/lib/libvfs.a and b/tools/sdk/esp32c3/lib/libvfs.a differ diff --git a/tools/sdk/esp32c3/lib/libwapi.a b/tools/sdk/esp32c3/lib/libwapi.a index 6acb10bf69d..549b78aad96 100644 Binary files a/tools/sdk/esp32c3/lib/libwapi.a and b/tools/sdk/esp32c3/lib/libwapi.a differ diff --git a/tools/sdk/esp32c3/lib/libwear_levelling.a b/tools/sdk/esp32c3/lib/libwear_levelling.a index 33d805c0fe1..8e320e50db7 100644 Binary files a/tools/sdk/esp32c3/lib/libwear_levelling.a and b/tools/sdk/esp32c3/lib/libwear_levelling.a differ diff --git a/tools/sdk/esp32c3/lib/libwifi_provisioning.a b/tools/sdk/esp32c3/lib/libwifi_provisioning.a index 5329693776e..08e7562e415 100644 Binary files a/tools/sdk/esp32c3/lib/libwifi_provisioning.a and b/tools/sdk/esp32c3/lib/libwifi_provisioning.a differ diff --git a/tools/sdk/esp32c3/lib/libwpa_supplicant.a b/tools/sdk/esp32c3/lib/libwpa_supplicant.a index 7d4dd17f85a..60617dc9981 100644 Binary files a/tools/sdk/esp32c3/lib/libwpa_supplicant.a and b/tools/sdk/esp32c3/lib/libwpa_supplicant.a differ diff --git a/tools/sdk/esp32c3/sdkconfig b/tools/sdk/esp32c3/sdkconfig index 616ed46e954..85edbebed07 100644 --- a/tools/sdk/esp32c3/sdkconfig +++ b/tools/sdk/esp32c3/sdkconfig @@ -62,6 +62,7 @@ CONFIG_BOOTLOADER_WDT_TIME_MS=9000 # CONFIG_BOOTLOADER_SKIP_VALIDATE_ALWAYS is not set CONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0 # CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC is not set +CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT=y # end of Bootloader config # @@ -92,6 +93,7 @@ CONFIG_ESPTOOLPY_BAUD_OTHER_VAL=115200 CONFIG_ESPTOOLPY_FLASHMODE_DIO=y # CONFIG_ESPTOOLPY_FLASHMODE_DOUT is not set CONFIG_ESPTOOLPY_FLASHMODE="dio" +# CONFIG_ESPTOOLPY_FLASHFREQ_120M is not set CONFIG_ESPTOOLPY_FLASHFREQ_80M=y # CONFIG_ESPTOOLPY_FLASHFREQ_40M is not set # CONFIG_ESPTOOLPY_FLASHFREQ_26M is not set @@ -232,19 +234,10 @@ CONFIG_APPTRACE_LOCK_ENABLE=y # Bluetooth # CONFIG_BT_ENABLED=y -CONFIG_BT_CTRL_ESP32C3=y CONFIG_BT_SOC_SUPPORT_5_0=y -CONFIG_BTDM_CTRL_BR_EDR_SCO_DATA_PATH_EFF=0 -CONFIG_BTDM_CTRL_PCM_ROLE_EFF=0 -CONFIG_BTDM_CTRL_PCM_POLAR_EFF=0 -CONFIG_BTDM_CTRL_BLE_MAX_CONN_EFF=0 -CONFIG_BTDM_CTRL_BR_EDR_MAX_ACL_CONN_EFF=0 -CONFIG_BTDM_CTRL_BR_EDR_MAX_SYNC_CONN_EFF=0 -CONFIG_BTDM_CTRL_PINNED_TO_CORE=0 -CONFIG_BTDM_BLE_SLEEP_CLOCK_ACCURACY_INDEX_EFF=1 # -# Bluetooth controller(ESP32C3 Bluetooth Low Energy) +# Bluetooth controller # CONFIG_BT_CTRL_MODE_EFF=1 CONFIG_BT_CTRL_BLE_MAX_ACT=10 @@ -308,12 +301,7 @@ CONFIG_BT_CTRL_SLEEP_MODE_EFF=0 CONFIG_BT_CTRL_SLEEP_CLOCK_EFF=0 CONFIG_BT_CTRL_HCI_TL_EFF=1 # CONFIG_BT_CTRL_AGC_RECORRECT_EN is not set -# end of Bluetooth controller(ESP32C3 Bluetooth Low Energy) - -# -# MODEM SLEEP Options -# -# end of MODEM SLEEP Options +# end of Bluetooth controller CONFIG_BT_BLUEDROID_ENABLED=y # CONFIG_BT_NIMBLE_ENABLED is not set @@ -524,11 +512,7 @@ CONFIG_BT_BLE_ESTAB_LINK_CONN_TOUT=30 CONFIG_BT_BLE_RPA_SUPPORTED=y CONFIG_BT_BLE_50_FEATURES_SUPPORTED=y CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y -CONFIG_BT_RESERVE_DRAM=0xdb5c # end of Bluedroid Options - -CONFIG_BT_NIMBLE_ENABLE_CONN_REATTEMPT=y -CONFIG_BT_NIMBLE_USE_ESP_TIMER=y # end of Bluetooth # CONFIG_BLE_MESH is not set @@ -553,6 +537,12 @@ CONFIG_COAP_LOG_DEFAULT_LEVEL=0 CONFIG_ADC_DISABLE_DAC=y # end of ADC configuration +# +# MCPWM configuration +# +# CONFIG_MCPWM_ISR_IN_IRAM is not set +# end of MCPWM configuration + # # SPI configuration # @@ -589,6 +579,8 @@ CONFIG_EFUSE_MAX_BLK_LEN=256 CONFIG_ESP_TLS_USING_MBEDTLS=y CONFIG_ESP_TLS_USE_DS_PERIPHERAL=y CONFIG_ESP_TLS_SERVER=y +# CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS is not set +# CONFIG_ESP_TLS_SERVER_SESSION_TICKETS is not set # CONFIG_ESP_TLS_PSK_VERIFICATION is not set # CONFIG_ESP_TLS_INSECURE is not set # end of ESP-TLS @@ -712,12 +704,25 @@ CONFIG_ESP32C3_UNIVERSAL_MAC_ADDRESSES=4 # Sleep Config # CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y +# CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND is not set # end of Sleep Config # end of Hardware Settings +# +# IPC (Inter-Processor Call) +# +CONFIG_ESP_IPC_TASK_STACK_SIZE=1024 +# end of IPC (Inter-Processor Call) + # # LCD and Touch Panel # + +# +# LCD Peripheral Configuration +# +CONFIG_LCD_PANEL_IO_FORMAT_BUF_SIZE=32 +# end of LCD Peripheral Configuration # end of LCD and Touch Panel # @@ -761,8 +766,11 @@ CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP=y # # Memory protection # +CONFIG_ESP_SYSTEM_MEMPROT_DEPCHECK=y CONFIG_ESP_SYSTEM_MEMPROT_FEATURE=y CONFIG_ESP_SYSTEM_MEMPROT_FEATURE_LOCK=y +CONFIG_ESP_SYSTEM_MEMPROT_CPU_PREFETCH_PAD_SIZE=16 +CONFIG_ESP_SYSTEM_MEMPROT_MEM_ALIGN_SIZE=512 # end of Memory protection CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE=32 @@ -785,8 +793,8 @@ CONFIG_ESP_TASK_WDT=y # CONFIG_ESP_TASK_WDT_PANIC is not set CONFIG_ESP_TASK_WDT_TIMEOUT_S=5 CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=y -CONFIG_ESP_IPC_TASK_STACK_SIZE=1024 # CONFIG_ESP_PANIC_HANDLER_IRAM is not set +CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_4=y # end of ESP System Settings # @@ -904,6 +912,8 @@ CONFIG_FMB_EVENT_QUEUE_TIMEOUT=20 CONFIG_FMB_TIMER_PORT_ENABLED=y CONFIG_FMB_TIMER_GROUP=0 CONFIG_FMB_TIMER_INDEX=0 +CONFIG_FMB_MASTER_TIMER_GROUP=0 +CONFIG_FMB_MASTER_TIMER_INDEX=0 # CONFIG_FMB_TIMER_ISR_IN_IRAM is not set # end of Modbus configuration @@ -912,8 +922,10 @@ CONFIG_FMB_TIMER_INDEX=0 # CONFIG_FREERTOS_UNICORE=y CONFIG_FREERTOS_NO_AFFINITY=0x7FFFFFFF -CONFIG_FREERTOS_CORETIMER_0=y -# CONFIG_FREERTOS_CORETIMER_1 is not set +CONFIG_FREERTOS_TICK_SUPPORT_SYSTIMER=y +CONFIG_FREERTOS_CORETIMER_SYSTIMER_LVL1=y +# CONFIG_FREERTOS_CORETIMER_SYSTIMER_LVL3 is not set +CONFIG_FREERTOS_SYSTICK_USES_SYSTIMER=y CONFIG_FREERTOS_OPTIMIZED_SCHEDULER=y CONFIG_FREERTOS_HZ=1000 CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION=y @@ -943,6 +955,8 @@ CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=y # CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set # CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH is not set CONFIG_FREERTOS_DEBUG_OCDAWARE=y +CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT=y +# CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH is not set # end of FreeRTOS # @@ -1005,6 +1019,7 @@ CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y # CONFIG_LWIP_LOCAL_HOSTNAME="espressif" # CONFIG_LWIP_NETIF_API is not set +# CONFIG_LWIP_TCPIP_CORE_LOCKING is not set CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y # CONFIG_LWIP_L2_TO_L3_COPY is not set # CONFIG_LWIP_IRAM_OPTIMIZATION is not set @@ -1043,7 +1058,6 @@ CONFIG_LWIP_IPV6=y # CONFIG_LWIP_IPV6_AUTOCONFIG is not set CONFIG_LWIP_IPV6_NUM_ADDRESSES=3 # CONFIG_LWIP_IPV6_FORWARD is not set -CONFIG_LWIP_IPV6_RDNSS_MAX_DNS_SERVERS=0 # CONFIG_LWIP_NETIF_STATUS_CALLBACK is not set CONFIG_LWIP_NETIF_LOOPBACK=y CONFIG_LWIP_LOOPBACK_MAX_PBUFS=8 @@ -1112,7 +1126,8 @@ CONFIG_LWIP_MAX_RAW_PCBS=16 # # SNTP # -CONFIG_LWIP_DHCP_MAX_NTP_SERVERS=1 +CONFIG_LWIP_SNTP_MAX_SERVERS=1 +# CONFIG_LWIP_DHCP_GET_NTP_SRV is not set CONFIG_LWIP_SNTP_UPDATE_DELAY=3600000 # end of SNTP @@ -1203,6 +1218,7 @@ CONFIG_MBEDTLS_SSL_RENEGOTIATION=y CONFIG_MBEDTLS_SSL_PROTO_TLS1=y CONFIG_MBEDTLS_SSL_PROTO_TLS1_1=y CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y +# CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1 is not set # CONFIG_MBEDTLS_SSL_PROTO_DTLS is not set CONFIG_MBEDTLS_SSL_ALPN=y CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS=y @@ -1274,6 +1290,7 @@ CONFIG_MDNS_TASK_AFFINITY=0x0 CONFIG_MDNS_SERVICE_ADD_TIMEOUT_MS=2000 # CONFIG_MDNS_STRICT_MODE is not set CONFIG_MDNS_TIMER_PERIOD_MS=100 +# CONFIG_MDNS_NETWORKING_SOCKET is not set # end of mDNS # @@ -1416,11 +1433,6 @@ CONFIG_WS_BUFFER_SIZE=1024 # end of Websocket # end of TCP Transport -# -# TinyUSB -# -# end of TinyUSB - # # Unity unit testing library # @@ -1542,10 +1554,6 @@ CONFIG_STACK_CHECK_NONE=y # CONFIG_ESP32_APPTRACE_DEST_TRAX is not set CONFIG_ESP32_APPTRACE_DEST_NONE=y CONFIG_ESP32_APPTRACE_LOCK_ENABLE=y -CONFIG_BTDM_CONTROLLER_BLE_MAX_CONN_EFF=0 -CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_ACL_CONN_EFF=0 -CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_SYNC_CONN_EFF=0 -CONFIG_BTDM_CONTROLLER_PINNED_TO_CORE=0 CONFIG_BLUEDROID_ENABLED=y # CONFIG_NIMBLE_ENABLED is not set CONFIG_BTC_TASK_STACK_SIZE=3072 @@ -1729,6 +1737,7 @@ CONFIG_ADC2_DISABLE_DAC=y CONFIG_POST_EVENTS_FROM_ISR=y CONFIG_POST_EVENTS_FROM_IRAM_ISR=y CONFIG_ESP_SYSTEM_PD_FLASH=y +CONFIG_IPC_TASK_STACK_SIZE=1024 CONFIG_ESP_SYSTEM_PM_POWER_DOWN_CPU=y # CONFIG_ESP32S2_PANIC_PRINT_HALT is not set CONFIG_ESP32S2_PANIC_PRINT_REBOOT=y @@ -1752,7 +1761,6 @@ CONFIG_TASK_WDT=y # CONFIG_TASK_WDT_PANIC is not set CONFIG_TASK_WDT_TIMEOUT_S=5 CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0=y -CONFIG_IPC_TASK_STACK_SIZE=1024 CONFIG_TIMER_TASK_STACK_SIZE=3584 CONFIG_SW_COEXIST_ENABLE=y # CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH is not set diff --git a/tools/sdk/esp32s2/bin/bootloader_dio_40m.bin b/tools/sdk/esp32s2/bin/bootloader_dio_40m.bin index 26897179e0b..38bb414d787 100644 Binary files a/tools/sdk/esp32s2/bin/bootloader_dio_40m.bin and b/tools/sdk/esp32s2/bin/bootloader_dio_40m.bin differ diff --git a/tools/sdk/esp32s2/bin/bootloader_dio_80m.bin b/tools/sdk/esp32s2/bin/bootloader_dio_80m.bin index 0f50b9b95e1..d454c318da5 100644 Binary files a/tools/sdk/esp32s2/bin/bootloader_dio_80m.bin and b/tools/sdk/esp32s2/bin/bootloader_dio_80m.bin differ diff --git a/tools/sdk/esp32s2/bin/bootloader_dout_40m.bin b/tools/sdk/esp32s2/bin/bootloader_dout_40m.bin index 7d970e6843f..425e8a4adec 100644 Binary files a/tools/sdk/esp32s2/bin/bootloader_dout_40m.bin and b/tools/sdk/esp32s2/bin/bootloader_dout_40m.bin differ diff --git a/tools/sdk/esp32s2/bin/bootloader_dout_80m.bin b/tools/sdk/esp32s2/bin/bootloader_dout_80m.bin index 4dfa45c127e..bd6f458ee2d 100644 Binary files a/tools/sdk/esp32s2/bin/bootloader_dout_80m.bin and b/tools/sdk/esp32s2/bin/bootloader_dout_80m.bin differ diff --git a/tools/sdk/esp32s2/bin/bootloader_qio_40m.bin b/tools/sdk/esp32s2/bin/bootloader_qio_40m.bin index 4b9005e16b4..f2ca21c91f3 100644 Binary files a/tools/sdk/esp32s2/bin/bootloader_qio_40m.bin and b/tools/sdk/esp32s2/bin/bootloader_qio_40m.bin differ diff --git a/tools/sdk/esp32s2/bin/bootloader_qio_80m.bin b/tools/sdk/esp32s2/bin/bootloader_qio_80m.bin index 20c06ac6c16..94e44340c3e 100644 Binary files a/tools/sdk/esp32s2/bin/bootloader_qio_80m.bin and b/tools/sdk/esp32s2/bin/bootloader_qio_80m.bin differ diff --git a/tools/sdk/esp32s2/bin/bootloader_qout_40m.bin b/tools/sdk/esp32s2/bin/bootloader_qout_40m.bin index cf7d987a2d6..838fec2d4a2 100644 Binary files a/tools/sdk/esp32s2/bin/bootloader_qout_40m.bin and b/tools/sdk/esp32s2/bin/bootloader_qout_40m.bin differ diff --git a/tools/sdk/esp32s2/bin/bootloader_qout_80m.bin b/tools/sdk/esp32s2/bin/bootloader_qout_80m.bin index b25fc18f865..e678a4d3e9c 100644 Binary files a/tools/sdk/esp32s2/bin/bootloader_qout_80m.bin and b/tools/sdk/esp32s2/bin/bootloader_qout_80m.bin differ diff --git a/tools/sdk/esp32s2/include/app_update/include/esp_ota_ops.h b/tools/sdk/esp32s2/include/app_update/include/esp_ota_ops.h index 6278ab7905c..ba07c013d90 100644 --- a/tools/sdk/esp32s2/include/app_update/include/esp_ota_ops.h +++ b/tools/sdk/esp32s2/include/app_update/include/esp_ota_ops.h @@ -244,6 +244,14 @@ const esp_partition_t* esp_ota_get_next_update_partition(const esp_partition_t * */ esp_err_t esp_ota_get_partition_description(const esp_partition_t *partition, esp_app_desc_t *app_desc); +/** + * @brief Returns number of ota partitions provided in partition table. + * + * @return + * - Number of OTA partitions + */ +uint8_t esp_ota_get_app_partition_count(void); + /** * @brief This function is called to indicate that the running app is working well. * diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/cdc/cdc.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/cdc/cdc.h index f59bf0f1aaf..5df47f70b4a 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/cdc/cdc.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/cdc/cdc.h @@ -215,6 +215,10 @@ typedef enum // Class Specific Functional Descriptor (Communication Interface) //--------------------------------------------------------------------+ +// Start of all packed definitions for compiler without per-type packed +TU_ATTR_PACKED_BEGIN +TU_ATTR_BIT_FIELD_ORDER_BEGIN + /// Header Functional Descriptor (Communication Interface) typedef struct TU_ATTR_PACKED { @@ -235,7 +239,7 @@ typedef struct TU_ATTR_PACKED }cdc_desc_func_union_t; #define cdc_desc_func_union_n_t(no_slave)\ - struct TU_ATTR_PACKED { \ + struct TU_ATTR_PACKED { \ uint8_t bLength ;\ uint8_t bDescriptorType ;\ uint8_t bDescriptorSubType ;\ @@ -254,7 +258,7 @@ typedef struct TU_ATTR_PACKED }cdc_desc_func_country_selection_t; #define cdc_desc_func_country_selection_n_t(no_country) \ - struct TU_ATTR_PACKED {\ + struct TU_ATTR_PACKED { \ uint8_t bLength ;\ uint8_t bDescriptorType ;\ uint8_t bDescriptorSubType ;\ @@ -283,7 +287,6 @@ typedef struct TU_ATTR_PACKED uint8_t bDataInterface; }cdc_desc_func_call_management_t; - typedef struct TU_ATTR_PACKED { uint8_t support_comm_request : 1; ///< Device supports the request combination of Set_Comm_Feature, Clear_Comm_Feature, and Get_Comm_Feature. @@ -295,8 +298,8 @@ typedef struct TU_ATTR_PACKED TU_VERIFY_STATIC(sizeof(cdc_acm_capability_t) == 1, "mostly problem with compiler"); -/// \brief Abstract Control Management Functional Descriptor -/// \details This functional descriptor describes the commands supported by by the Communications Class interface with SubClass code of \ref CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL +/// Abstract Control Management Functional Descriptor +/// This functional descriptor describes the commands supported by by the Communications Class interface with SubClass code of \ref CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL typedef struct TU_ATTR_PACKED { uint8_t bLength ; ///< Size of this descriptor in bytes. @@ -367,6 +370,7 @@ typedef struct TU_ATTR_PACKED } bmCapabilities; }cdc_desc_func_telephone_call_state_reporting_capabilities_t; +// TODO remove static inline uint8_t cdc_functional_desc_typeof(uint8_t const * p_desc) { return p_desc[2]; @@ -394,7 +398,8 @@ typedef struct TU_ATTR_PACKED TU_VERIFY_STATIC(sizeof(cdc_line_control_state_t) == 2, "size is not correct"); -/** @} */ +TU_ATTR_PACKED_END // End of all packed definitions +TU_ATTR_BIT_FIELD_ORDER_END #ifdef __cplusplus } diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/cdc/cdc_host.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/cdc/cdc_host.h index edcd258a84e..0d435138b8a 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/cdc/cdc_host.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/cdc/cdc_host.h @@ -121,11 +121,11 @@ void tuh_cdc_xfer_isr(uint8_t dev_addr, xfer_result_t event, cdc_pipeid_t pipe_i //--------------------------------------------------------------------+ // Internal Class Driver API //--------------------------------------------------------------------+ -void cdch_init (void); -uint16_t cdch_open (uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const *itf_desc, uint16_t max_len); -bool cdch_set_config (uint8_t dev_addr, uint8_t itf_num); -bool cdch_xfer_cb (uint8_t dev_addr, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes); -void cdch_close (uint8_t dev_addr); +void cdch_init (void); +bool cdch_open (uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const *itf_desc, uint16_t max_len); +bool cdch_set_config (uint8_t dev_addr, uint8_t itf_num); +bool cdch_xfer_cb (uint8_t dev_addr, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes); +void cdch_close (uint8_t dev_addr); #ifdef __cplusplus } diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/hid/hid.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/hid/hid.h index ec14c9c7c7c..9265a2ede76 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/hid/hid.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/hid/hid.h @@ -871,10 +871,10 @@ enum {0, 0 }, /* 0x07 */ \ {0, HID_KEY_BACKSPACE }, /* 0x08 Backspace */ \ {0, HID_KEY_TAB }, /* 0x09 Tab */ \ - {0, HID_KEY_RETURN }, /* 0x0A Line Feed */ \ + {0, HID_KEY_ENTER }, /* 0x0A Line Feed */ \ {0, 0 }, /* 0x0B */ \ {0, 0 }, /* 0x0C */ \ - {0, HID_KEY_RETURN }, /* 0x0D CR */ \ + {0, HID_KEY_ENTER }, /* 0x0D CR */ \ {0, 0 }, /* 0x0E */ \ {0, 0 }, /* 0x0F */ \ {0, 0 }, /* 0x10 */ \ diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/hid/hid_device.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/hid/hid_device.h index e2c950dd1bd..7f67fa9cff0 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/hid/hid_device.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/hid/hid_device.h @@ -195,16 +195,7 @@ static inline bool tud_hid_gamepad_report(uint8_t report_id, int8_t x, int8_t y HID_REPORT_COUNT ( 1 ) ,\ HID_REPORT_SIZE ( 8 ) ,\ HID_INPUT ( HID_CONSTANT ) ,\ - /* 6-byte Keycodes */ \ - HID_USAGE_PAGE ( HID_USAGE_PAGE_KEYBOARD ) ,\ - HID_USAGE_MIN ( 0 ) ,\ - HID_USAGE_MAX_N ( 255, 2 ) ,\ - HID_LOGICAL_MIN ( 0 ) ,\ - HID_LOGICAL_MAX_N( 255, 2 ) ,\ - HID_REPORT_COUNT ( 6 ) ,\ - HID_REPORT_SIZE ( 8 ) ,\ - HID_INPUT ( HID_DATA | HID_ARRAY | HID_ABSOLUTE ) ,\ - /* 5-bit LED Indicator Kana | Compose | ScrollLock | CapsLock | NumLock */ \ + /* Output 5-bit LED Indicator Kana | Compose | ScrollLock | CapsLock | NumLock */ \ HID_USAGE_PAGE ( HID_USAGE_PAGE_LED ) ,\ HID_USAGE_MIN ( 1 ) ,\ HID_USAGE_MAX ( 5 ) ,\ @@ -215,6 +206,15 @@ static inline bool tud_hid_gamepad_report(uint8_t report_id, int8_t x, int8_t y HID_REPORT_COUNT ( 1 ) ,\ HID_REPORT_SIZE ( 3 ) ,\ HID_OUTPUT ( HID_CONSTANT ) ,\ + /* 6-byte Keycodes */ \ + HID_USAGE_PAGE ( HID_USAGE_PAGE_KEYBOARD ) ,\ + HID_USAGE_MIN ( 0 ) ,\ + HID_USAGE_MAX_N ( 255, 2 ) ,\ + HID_LOGICAL_MIN ( 0 ) ,\ + HID_LOGICAL_MAX_N( 255, 2 ) ,\ + HID_REPORT_COUNT ( 6 ) ,\ + HID_REPORT_SIZE ( 8 ) ,\ + HID_INPUT ( HID_DATA | HID_ARRAY | HID_ABSOLUTE ) ,\ HID_COLLECTION_END \ // Mouse Report Descriptor Template @@ -364,14 +364,14 @@ static inline bool tud_hid_gamepad_report(uint8_t report_id, int8_t x, int8_t y /* Input */ \ HID_USAGE ( 0x02 ),\ HID_LOGICAL_MIN ( 0x00 ),\ - HID_LOGICAL_MAX ( 0xff ),\ + HID_LOGICAL_MAX_N ( 0xff, 2 ),\ HID_REPORT_SIZE ( 8 ),\ HID_REPORT_COUNT( report_size ),\ HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ),\ /* Output */ \ HID_USAGE ( 0x03 ),\ HID_LOGICAL_MIN ( 0x00 ),\ - HID_LOGICAL_MAX ( 0xff ),\ + HID_LOGICAL_MAX_N ( 0xff, 2 ),\ HID_REPORT_SIZE ( 8 ),\ HID_REPORT_COUNT( report_size ),\ HID_OUTPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ),\ diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/hid/hid_host.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/hid/hid_host.h index ef203123d97..fe09b03b2f6 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/hid/hid_host.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/hid/hid_host.h @@ -38,10 +38,15 @@ //--------------------------------------------------------------------+ // TODO Highspeed interrupt can be up to 512 bytes -#ifndef CFG_TUH_HID_EP_BUFSIZE -#define CFG_TUH_HID_EP_BUFSIZE 64 +#ifndef CFG_TUH_HID_EPIN_BUFSIZE +#define CFG_TUH_HID_EPIN_BUFSIZE 64 #endif +#ifndef CFG_TUH_HID_EPOUT_BUFSIZE +#define CFG_TUH_HID_EPOUT_BUFSIZE 64 +#endif + + typedef struct { uint8_t report_id; @@ -54,7 +59,7 @@ typedef struct } tuh_hid_report_info_t; //--------------------------------------------------------------------+ -// Application API +// Interface API //--------------------------------------------------------------------+ // Get the number of HID instances @@ -66,6 +71,14 @@ bool tuh_hid_mounted(uint8_t dev_addr, uint8_t instance); // Get interface supported protocol (bInterfaceProtocol) check out hid_interface_protocol_enum_t for possible values uint8_t tuh_hid_interface_protocol(uint8_t dev_addr, uint8_t instance); +// Parse report descriptor into array of report_info struct and return number of reports. +// For complicated report, application should write its own parser. +uint8_t tuh_hid_parse_report_descriptor(tuh_hid_report_info_t* reports_info_arr, uint8_t arr_count, uint8_t const* desc_report, uint16_t desc_len) TU_ATTR_UNUSED; + +//--------------------------------------------------------------------+ +// Control Endpoint API +//--------------------------------------------------------------------+ + // Get current protocol: HID_PROTOCOL_BOOT (0) or HID_PROTOCOL_REPORT (1) // Note: Device will be initialized in Boot protocol for simplicity. // Application can use set_protocol() to switch back to Report protocol. @@ -79,13 +92,18 @@ bool tuh_hid_set_protocol(uint8_t dev_addr, uint8_t instance, uint8_t protocol); // report_type is either Intput, Output or Feature, (value from hid_report_type_t) bool tuh_hid_set_report(uint8_t dev_addr, uint8_t instance, uint8_t report_id, uint8_t report_type, void* report, uint16_t len); -// Parse report descriptor into array of report_info struct and return number of reports. -// For complicated report, application should write its own parser. -uint8_t tuh_hid_parse_report_descriptor(tuh_hid_report_info_t* reports_info_arr, uint8_t arr_count, uint8_t const* desc_report, uint16_t desc_len) TU_ATTR_UNUSED; +//--------------------------------------------------------------------+ +// Interrupt Endpoint API +//--------------------------------------------------------------------+ // Check if the interface is ready to use //bool tuh_n_hid_n_ready(uint8_t dev_addr, uint8_t instance); +// Try to receive next report on Interrupt Endpoint. Immediately return +// - true If succeeded, tuh_hid_report_received_cb() callback will be invoked when report is available +// - false if failed to queue the transfer e.g endpoint is busy +bool tuh_hid_receive_report(uint8_t dev_addr, uint8_t instance); + // Send report using interrupt endpoint // If report_id > 0 (composite), it will be sent as 1st byte, then report contents. Otherwise only report content is sent. //void tuh_hid_send_report(uint8_t dev_addr, uint8_t instance, uint8_t report_id, uint8_t const* report, uint16_t len); @@ -97,6 +115,8 @@ uint8_t tuh_hid_parse_report_descriptor(tuh_hid_report_info_t* reports_info_arr, // Invoked when device with hid interface is mounted // Report descriptor is also available for use. tuh_hid_parse_report_descriptor() // can be used to parse common/simple enough descriptor. +// Note: if report descriptor length > CFG_TUH_ENUMERATION_BUFSIZE, it will be skipped +// therefore report_desc = NULL, desc_len = 0 void tuh_hid_mount_cb(uint8_t dev_addr, uint8_t instance, uint8_t const* report_desc, uint16_t desc_len); // Invoked when device with hid interface is un-mounted @@ -119,11 +139,11 @@ TU_ATTR_WEAK void tuh_hid_set_protocol_complete_cb(uint8_t dev_addr, uint8_t ins //--------------------------------------------------------------------+ // Internal Class Driver API //--------------------------------------------------------------------+ -void hidh_init (void); -uint16_t hidh_open (uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const *desc_itf, uint16_t max_len); -bool hidh_set_config (uint8_t dev_addr, uint8_t itf_num); -bool hidh_xfer_cb (uint8_t dev_addr, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes); -void hidh_close (uint8_t dev_addr); +void hidh_init (void); +bool hidh_open (uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const *desc_itf, uint16_t max_len); +bool hidh_set_config (uint8_t dev_addr, uint8_t itf_num); +bool hidh_xfer_cb (uint8_t dev_addr, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes); +void hidh_close (uint8_t dev_addr); #ifdef __cplusplus } diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/msc/msc_device.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/msc/msc_device.h index 8f90ef4ad59..d3269434081 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/msc/msc_device.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/msc/msc_device.h @@ -140,7 +140,7 @@ TU_ATTR_WEAK void tud_msc_write10_complete_cb(uint8_t lun); // Invoked when command in tud_msc_scsi_cb is complete TU_ATTR_WEAK void tud_msc_scsi_complete_cb(uint8_t lun, uint8_t const scsi_cmd[16]); -// Hook to make a mass storage device read-only. TODO remove +// Invoked to check if device is writable as part of SCSI WRITE10 TU_ATTR_WEAK bool tud_msc_is_writable_cb(uint8_t lun); //--------------------------------------------------------------------+ diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/msc/msc_host.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/msc/msc_host.h index 9e4217ba514..7718ad4fe0e 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/msc/msc_host.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/msc/msc_host.h @@ -106,11 +106,11 @@ TU_ATTR_WEAK void tuh_msc_umount_cb(uint8_t dev_addr); // Internal Class Driver API //--------------------------------------------------------------------+ -void msch_init (void); -uint16_t msch_open (uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const *desc_itf, uint16_t max_len); -bool msch_set_config (uint8_t dev_addr, uint8_t itf_num); -bool msch_xfer_cb (uint8_t dev_addr, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes); -void msch_close (uint8_t dev_addr); +void msch_init (void); +bool msch_open (uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const *desc_itf, uint16_t max_len); +bool msch_set_config (uint8_t dev_addr, uint8_t itf_num); +void msch_close (uint8_t dev_addr); +bool msch_xfer_cb (uint8_t dev_addr, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes); #ifdef __cplusplus } diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/vendor/vendor_device.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/vendor/vendor_device.h index 6d9c784c086..844693c68b7 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/vendor/vendor_device.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/vendor/vendor_device.h @@ -45,6 +45,7 @@ bool tud_vendor_n_mounted (uint8_t itf); uint32_t tud_vendor_n_available (uint8_t itf); uint32_t tud_vendor_n_read (uint8_t itf, void* buffer, uint32_t bufsize); bool tud_vendor_n_peek (uint8_t itf, uint8_t* u8); +void tud_vendor_n_read_flush (uint8_t itf); uint32_t tud_vendor_n_write (uint8_t itf, void const* buffer, uint32_t bufsize); uint32_t tud_vendor_n_write_available (uint8_t itf); @@ -59,6 +60,7 @@ static inline bool tud_vendor_mounted (void); static inline uint32_t tud_vendor_available (void); static inline uint32_t tud_vendor_read (void* buffer, uint32_t bufsize); static inline bool tud_vendor_peek (uint8_t* u8); +static inline void tud_vendor_read_flush (void); static inline uint32_t tud_vendor_write (void const* buffer, uint32_t bufsize); static inline uint32_t tud_vendor_write_str (char const* str); static inline uint32_t tud_vendor_write_available (void); @@ -99,6 +101,11 @@ static inline bool tud_vendor_peek (uint8_t* u8) return tud_vendor_n_peek(0, u8); } +static inline void tud_vendor_read_flush(void) +{ + tud_vendor_n_read_flush(0); +} + static inline uint32_t tud_vendor_write (void const* buffer, uint32_t bufsize) { return tud_vendor_n_write(0, buffer, bufsize); diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_common.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_common.h index c8a66a87912..1899b35cc3d 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_common.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_common.h @@ -73,6 +73,23 @@ #include "tusb_error.h" // TODO remove #include "tusb_timeout.h" // TODO remove +//--------------------------------------------------------------------+ +// Internal Helper used by Host and Device Stack +//--------------------------------------------------------------------+ + +// Check if endpoint descriptor is valid per USB specs +bool tu_edpt_validate(tusb_desc_endpoint_t const * desc_ep, tusb_speed_t speed); + +// Bind all endpoint of a interface descriptor to class driver +void tu_edpt_bind_driver(uint8_t ep2drv[][2], tusb_desc_interface_t const* p_desc, uint16_t desc_len, uint8_t driver_id); + +// Calculate total length of n interfaces (depending on IAD) +uint16_t tu_desc_get_interface_total_len(tusb_desc_interface_t const* desc_itf, uint8_t itf_count, uint16_t max_len); + +//--------------------------------------------------------------------+ +// Internal Inline Functions +//--------------------------------------------------------------------+ + //------------- Mem -------------// #define tu_memclr(buffer, size) memset((buffer), 0, (size)) #define tu_varclr(_var) tu_memclr(_var, sizeof(*(_var))) @@ -93,6 +110,9 @@ TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_u32_byte2(uint32_t u32) { return TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_u32_byte1(uint32_t u32) { return TU_U32_BYTE1(u32); } TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_u32_byte0(uint32_t u32) { return TU_U32_BYTE0(u32); } +TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_u32_high16(uint32_t u32) { return (uint16_t) (u32 >> 16); } +TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_u32_low16 (uint32_t u32) { return (uint16_t) (u32 & 0x0000ffffu); } + TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_u16_high(uint16_t u16) { return TU_U16_HIGH(u16); } TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_u16_low (uint16_t u16) { return TU_U16_LOW(u16); } @@ -352,12 +372,17 @@ typedef struct static inline const char* tu_lookup_find(tu_lookup_table_t const* p_table, uint32_t key) { + static char not_found[11]; + for(uint16_t i=0; icount; i++) { if (p_table->items[i].key == key) return p_table->items[i].data; } - return NULL; + // not found return the key value in hex + sprintf(not_found, "0x%08lX", (unsigned long) key); + + return not_found; } #endif // CFG_TUSB_DEBUG diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_compiler.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_compiler.h index 0dd9ba01667..3e85939b068 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_compiler.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_compiler.h @@ -32,6 +32,7 @@ #ifndef _TUSB_COMPILER_H_ #define _TUSB_COMPILER_H_ +#define TU_TOKEN(x) x #define TU_STRING(x) #x ///< stringify without expand #define TU_XSTRING(x) TU_STRING(x) ///< expand then stringify @@ -41,6 +42,8 @@ #define TU_XSTRCAT(a, b) TU_STRCAT(a, b) ///< expand then concat #define TU_XSTRCAT3(a, b, c) TU_STRCAT3(a, b, c) ///< expand then concat 3 tokens +#define TU_INCLUDE_PATH(_dir,_file) TU_XSTRING( TU_TOKEN(_dir)TU_TOKEN(_file) ) + #if defined __COUNTER__ && __COUNTER__ != __COUNTER__ #define _TU_COUNTER_ __COUNTER__ #else @@ -52,6 +55,8 @@ #define TU_VERIFY_STATIC _Static_assert #elif defined (__cplusplus) && __cplusplus >= 201103L #define TU_VERIFY_STATIC static_assert +#elif defined(__CCRX__) + #define TU_VERIFY_STATIC(const_expr, _mess) typedef char TU_XSTRCAT(Line, __LINE__)[(const_expr) ? 1 : 0]; #else #define TU_VERIFY_STATIC(const_expr, _mess) enum { TU_XSTRCAT(_verify_static_, _TU_COUNTER_) = 1/(!!(const_expr)) } #endif @@ -77,6 +82,11 @@ #define TU_ATTR_UNUSED __attribute__ ((unused)) // Function/Variable is meant to be possibly unused #define TU_ATTR_USED __attribute__ ((used)) // Function/Variable is meant to be used + #define TU_ATTR_PACKED_BEGIN + #define TU_ATTR_PACKED_END + #define TU_ATTR_BIT_FIELD_ORDER_BEGIN + #define TU_ATTR_BIT_FIELD_ORDER_END + // Endian conversion use well-known host to network (big endian) naming #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #define TU_BYTE_ORDER TU_LITTLE_ENDIAN @@ -101,6 +111,11 @@ #define TU_ATTR_UNUSED __attribute__ ((unused)) // Function/Variable is meant to be possibly unused #define TU_ATTR_USED __attribute__ ((used)) + #define TU_ATTR_PACKED_BEGIN + #define TU_ATTR_PACKED_END + #define TU_ATTR_BIT_FIELD_ORDER_BEGIN + #define TU_ATTR_BIT_FIELD_ORDER_END + // __BYTE_ORDER is defined in the TI ARM compiler, but not MSP430 (which is little endian) #if ((__BYTE_ORDER__) == (__ORDER_LITTLE_ENDIAN__)) || defined(__MSP430__) #define TU_BYTE_ORDER TU_LITTLE_ENDIAN @@ -122,6 +137,11 @@ #define TU_ATTR_UNUSED __attribute__ ((unused)) // Function/Variable is meant to be possibly unused #define TU_ATTR_USED __attribute__ ((used)) // Function/Variable is meant to be used + #define TU_ATTR_PACKED_BEGIN + #define TU_ATTR_PACKED_END + #define TU_ATTR_BIT_FIELD_ORDER_BEGIN + #define TU_ATTR_BIT_FIELD_ORDER_END + // Endian conversion use well-known host to network (big endian) naming #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #define TU_BYTE_ORDER TU_LITTLE_ENDIAN @@ -131,6 +151,32 @@ #define TU_BSWAP16(u16) (__iar_builtin_REV16(u16)) #define TU_BSWAP32(u32) (__iar_builtin_REV(u32)) + +#elif defined(__CCRX__) + #define TU_ATTR_ALIGNED(Bytes) + #define TU_ATTR_SECTION(sec_name) + #define TU_ATTR_PACKED + #define TU_ATTR_WEAK + #define TU_ATTR_ALWAYS_INLINE + #define TU_ATTR_DEPRECATED(mess) + #define TU_ATTR_UNUSED + #define TU_ATTR_USED + + #define TU_ATTR_PACKED_BEGIN _Pragma("pack") + #define TU_ATTR_PACKED_END _Pragma("packoption") + #define TU_ATTR_BIT_FIELD_ORDER_BEGIN _Pragma("bit_order right") + #define TU_ATTR_BIT_FIELD_ORDER_END _Pragma("bit_order") + + // Endian conversion use well-known host to network (big endian) naming + #if defined(__LIT) + #define TU_BYTE_ORDER TU_LITTLE_ENDIAN + #else + #define TU_BYTE_ORDER TU_BIG_ENDIAN + #endif + + #define TU_BSWAP16(u16) ((unsigned short)_builtin_revw((unsigned long)u16)) + #define TU_BSWAP32(u32) (_builtin_revl(u32)) + #else #error "Compiler attribute porting is required" #endif @@ -157,11 +203,11 @@ #define tu_htonl(u32) (u32) #define tu_ntohl(u32) (u32) - #define tu_htole16(u16) (tu_bswap16(u16)) - #define tu_le16toh(u16) (tu_bswap16(u16)) + #define tu_htole16(u16) (TU_BSWAP16(u16)) + #define tu_le16toh(u16) (TU_BSWAP16(u16)) - #define tu_htole32(u32) (tu_bswap32(u32)) - #define tu_le32toh(u32) (tu_bswap32(u32)) + #define tu_htole32(u32) (TU_BSWAP32(u32)) + #define tu_le32toh(u32) (TU_BSWAP32(u32)) #else #error Byte order is undefined diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_types.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_types.h index eab67ebd5db..f26983a7483 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_types.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_types.h @@ -262,6 +262,10 @@ enum // USB Descriptors //--------------------------------------------------------------------+ +// Start of all packed definitions for compiler without per-type packed +TU_ATTR_PACKED_BEGIN +TU_ATTR_BIT_FIELD_ORDER_BEGIN + /// USB Device Descriptor typedef struct TU_ATTR_PACKED { @@ -295,6 +299,8 @@ typedef struct TU_ATTR_PACKED uint8_t bNumDeviceCaps ; ///< Number of device capability descriptors in the BOS } tusb_desc_bos_t; +TU_VERIFY_STATIC( sizeof(tusb_desc_bos_t) == 5, "size is not correct"); + /// USB Configuration Descriptor typedef struct TU_ATTR_PACKED { @@ -326,6 +332,8 @@ typedef struct TU_ATTR_PACKED uint8_t iInterface ; ///< Index of string descriptor describing this interface } tusb_desc_interface_t; +TU_VERIFY_STATIC( sizeof(tusb_desc_interface_t) == 9, "size is not correct"); + /// USB Endpoint Descriptor typedef struct TU_ATTR_PACKED { @@ -342,9 +350,14 @@ typedef struct TU_ATTR_PACKED } bmAttributes ; ///< This field describes the endpoint's attributes when it is configured using the bConfigurationValue. \n Bits 1..0: Transfer Type \n- 00 = Control \n- 01 = Isochronous \n- 10 = Bulk \n- 11 = Interrupt \n If not an isochronous endpoint, bits 5..2 are reserved and must be set to zero. If isochronous, they are defined as follows: \n Bits 3..2: Synchronization Type \n- 00 = No Synchronization \n- 01 = Asynchronous \n- 10 = Adaptive \n- 11 = Synchronous \n Bits 5..4: Usage Type \n- 00 = Data endpoint \n- 01 = Feedback endpoint \n- 10 = Implicit feedback Data endpoint \n- 11 = Reserved \n Refer to Chapter 5 of USB 2.0 specification for more information. \n All other bits are reserved and must be reset to zero. Reserved bits must be ignored by the host. struct TU_ATTR_PACKED { +#if defined(__CCRX__) + //FIXME the original defined bit field has a problem with the CCRX toolchain, so only a size field is defined + uint16_t size; +#else uint16_t size : 11; ///< Maximum packet size this endpoint is capable of sending or receiving when this configuration is selected. \n For isochronous endpoints, this value is used to reserve the bus time in the schedule, required for the per-(micro)frame data payloads. The pipe may, on an ongoing basis, actually use less bandwidth than that reserved. The device reports, if necessary, the actual bandwidth used via its normal, non-USB defined mechanisms. \n For all endpoints, bits 10..0 specify the maximum packet size (in bytes). \n For high-speed isochronous and interrupt endpoints: \n Bits 12..11 specify the number of additional transaction opportunities per microframe: \n- 00 = None (1 transaction per microframe) \n- 01 = 1 additional (2 per microframe) \n- 10 = 2 additional (3 per microframe) \n- 11 = Reserved \n Bits 15..13 are reserved and must be set to zero. uint16_t hs_period_mult : 2; uint16_t TU_RESERVED : 3; +#endif }wMaxPacketSize; uint8_t bInterval ; ///< Interval for polling endpoint for data transfers. Expressed in frames or microframes depending on the device operating speed (i.e., either 1 millisecond or 125 us units). \n- For full-/high-speed isochronous endpoints, this value must be in the range from 1 to 16. The bInterval value is used as the exponent for a \f$ 2^(bInterval-1) \f$ value; e.g., a bInterval of 4 means a period of 8 (\f$ 2^(4-1) \f$). \n- For full-/low-speed interrupt endpoints, the value of this field may be from 1 to 255. \n- For high-speed interrupt endpoints, the bInterval value is used as the exponent for a \f$ 2^(bInterval-1) \f$ value; e.g., a bInterval of 4 means a period of 8 (\f$ 2^(4-1) \f$) . This value must be from 1 to 16. \n- For high-speed bulk/control OUT endpoints, the bInterval must specify the maximum NAK rate of the endpoint. A value of 0 indicates the endpoint never NAKs. Other values indicate at most 1 NAK each bInterval number of microframes. This value must be in the range from 0 to 255. \n Refer to Chapter 5 of USB 2.0 specification for more information. @@ -359,7 +372,7 @@ typedef struct TU_ATTR_PACKED uint8_t bNumInterfaces ; ///< Number of interfaces supported by this speed configuration uint8_t bConfigurationValue ; ///< Value to use to select configuration - uint8_t IConfiguration ; ///< Index of string descriptor + uint8_t iConfiguration ; ///< Index of string descriptor uint8_t bmAttributes ; ///< Same as Configuration descriptor uint8_t bMaxPower ; ///< Same as Configuration descriptor } tusb_desc_other_speed_t; @@ -374,11 +387,14 @@ typedef struct TU_ATTR_PACKED uint8_t bDeviceClass ; ///< Class Code uint8_t bDeviceSubClass ; ///< SubClass Code uint8_t bDeviceProtocol ; ///< Protocol Code + uint8_t bMaxPacketSize0 ; ///< Maximum packet size for other speed uint8_t bNumConfigurations ; ///< Number of Other-speed Configurations uint8_t bReserved ; ///< Reserved for future use, must be zero } tusb_desc_device_qualifier_t; +TU_VERIFY_STATIC( sizeof(tusb_desc_device_qualifier_t) == 10, "size is not correct"); + /// USB Interface Association Descriptor (IAD ECN) typedef struct TU_ATTR_PACKED { @@ -449,7 +465,7 @@ typedef struct TU_ATTR_PACKED /*------------------------------------------------------------------*/ /* Types *------------------------------------------------------------------*/ -typedef struct TU_ATTR_PACKED { +typedef struct TU_ATTR_PACKED{ union { struct TU_ATTR_PACKED { uint8_t recipient : 5; ///< Recipient type tusb_request_recipient_t. @@ -468,11 +484,9 @@ typedef struct TU_ATTR_PACKED { TU_VERIFY_STATIC( sizeof(tusb_control_request_t) == 8, "size is not correct"); -// TODO move to somewhere suitable -static inline uint8_t bm_request_type(uint8_t direction, uint8_t type, uint8_t recipient) -{ - return ((uint8_t) (direction << 7)) | ((uint8_t) (type << 5)) | (recipient); -} + +TU_ATTR_PACKED_END // End of all packed definitions +TU_ATTR_BIT_FIELD_ORDER_END //--------------------------------------------------------------------+ // Endpoint helper diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/dcd.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/dcd.h index 8bfad9b72bc..d43a0dd9a3a 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/dcd.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/dcd.h @@ -137,6 +137,11 @@ void dcd_edpt0_status_complete(uint8_t rhport, tusb_control_request_t const * re // Configure endpoint's registers according to descriptor bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * desc_ep); +// Close all non-control endpoints, cancel all pending transfers if any. +// Invoked when switching from a non-zero Configuration by SET_CONFIGURE therefore +// required for multiple configuration support. +void dcd_edpt_close_all (uint8_t rhport); + // Close an endpoint. // Since it is weak, caller must TU_ASSERT this function's existence before calling it. void dcd_edpt_close (uint8_t rhport, uint8_t ep_addr) TU_ATTR_WEAK; @@ -148,10 +153,11 @@ bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer // This API is optional, may be useful for register-based for transferring data. bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes) TU_ATTR_WEAK; -// Stall endpoint +// Stall endpoint, any queuing transfer should be removed from endpoint void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr); // clear stall, data toggle is also reset to DATA0 +// This API never calls with control endpoints, since it is auto cleared when receiving setup packet void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr); //--------------------------------------------------------------------+ diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/dcd_attr.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/dcd_attr.h index 306335642c7..a35fc0ac502 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/dcd_attr.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/dcd_attr.h @@ -60,7 +60,7 @@ #elif TU_CHECK_MCU(MIMXRT10XX) #define DCD_ATTR_ENDPOINT_MAX 8 -#elif TU_CHECK_MCU(MKL25ZXX) +#elif TU_CHECK_MCU(MKL25ZXX) || TU_CHECK_MCU(K32L2BXX) #define DCD_ATTR_ENDPOINT_MAX 16 //------------- Nordic -------------// @@ -141,11 +141,15 @@ #define DCD_ATTR_ENDPOINT_MAX 7 //------------- Renesas -------------// -#elif TU_CHECK_MCU(RX63X) || TU_CHECK_MCU(RX65X) +#elif TU_CHECK_MCU(RX63X) || TU_CHECK_MCU(RX65X) || TU_CHECK_MCU(RX72N) #define DCD_ATTR_ENDPOINT_MAX 10 //#elif TU_CHECK_MCU(MM32F327X) -// #define DCD_ATTR_ENDPOINT_MAX not knwon yet +// #define DCD_ATTR_ENDPOINT_MAX not known yet + +//------------- GigaDevice -------------// +#elif TU_CHECK_MCU(GD32VF103) + #define DCD_ATTR_ENDPOINT_MAX 4 #else #warning "DCD_ATTR_ENDPOINT_MAX is not defined for this MCU, default to 8" diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/usbd.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/usbd.h index 1405f691794..638d9309470 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/usbd.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/usbd.h @@ -100,10 +100,6 @@ bool tud_control_status(uint8_t rhport, tusb_control_request_t const * request); // Application return pointer to descriptor uint8_t const * tud_descriptor_device_cb(void); -// Invoked when received GET BOS DESCRIPTOR request -// Application return pointer to descriptor -TU_ATTR_WEAK uint8_t const * tud_descriptor_bos_cb(void); - // Invoked when received GET CONFIGURATION DESCRIPTOR request // Application return pointer to descriptor, whose contents must exist long enough for transfer to complete uint8_t const * tud_descriptor_configuration_cb(uint8_t index); @@ -112,10 +108,21 @@ uint8_t const * tud_descriptor_configuration_cb(uint8_t index); // Application return pointer to descriptor, whose contents must exist long enough for transfer to complete uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid); +// Invoked when received GET BOS DESCRIPTOR request +// Application return pointer to descriptor +TU_ATTR_WEAK uint8_t const * tud_descriptor_bos_cb(void); + // Invoked when received GET DEVICE QUALIFIER DESCRIPTOR request -// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete +// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete. +// device_qualifier descriptor describes information about a high-speed capable device that would +// change if the device were operating at the other speed. If not highspeed capable stall this request. TU_ATTR_WEAK uint8_t const* tud_descriptor_device_qualifier_cb(void); +// Invoked when received GET OTHER SEED CONFIGURATION DESCRIPTOR request +// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete +// Configuration descriptor in the other speed e.g if high speed then this is for full speed and vice versa +TU_ATTR_WEAK uint8_t const* tud_descriptor_other_speed_configuration_cb(uint8_t index); + // Invoked when device is mounted (configured) TU_ATTR_WEAK void tud_mount_cb(void); @@ -734,7 +741,7 @@ TU_ATTR_WEAK bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb /* Primary Interface */ #define TUD_BTH_PRI_ITF(_itfnum, _stridx, _ep_evt, _ep_evt_size, _ep_evt_interval, _ep_in, _ep_out, _ep_size) \ - 9, TUSB_DESC_INTERFACE, _itfnum, _stridx, 3, TUD_BT_APP_CLASS, TUD_BT_APP_SUBCLASS, TUD_BT_PROTOCOL_PRIMARY_CONTROLLER, 0, \ + 9, TUSB_DESC_INTERFACE, _itfnum, 0, 3, TUD_BT_APP_CLASS, TUD_BT_APP_SUBCLASS, TUD_BT_PROTOCOL_PRIMARY_CONTROLLER, _stridx, \ /* Endpoint In for events */ \ 7, TUSB_DESC_ENDPOINT, _ep_evt, TUSB_XFER_INTERRUPT, U16_TO_U8S_LE(_ep_evt_size), _ep_evt_interval, \ /* Endpoint In for ACL data */ \ diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/usbd_pvt.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/usbd_pvt.h index b8d34d7b6c2..7607b98957b 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/usbd_pvt.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/usbd_pvt.h @@ -56,7 +56,6 @@ typedef struct // Note: The drivers array must be accessible at all time when stack is active usbd_class_driver_t const* usbd_app_driver_get_cb(uint8_t* driver_count) TU_ATTR_WEAK; - typedef bool (*usbd_control_xfer_cb_t)(uint8_t rhport, uint8_t stage, tusb_control_request_t const * request); //--------------------------------------------------------------------+ @@ -82,7 +81,7 @@ bool usbd_edpt_claim(uint8_t rhport, uint8_t ep_addr); // Release an endpoint without submitting a transfer bool usbd_edpt_release(uint8_t rhport, uint8_t ep_addr); -// Check if endpoint transferring is complete +// Check if endpoint is busy transferring bool usbd_edpt_busy(uint8_t rhport, uint8_t ep_addr); // Stall endpoint @@ -94,6 +93,7 @@ void usbd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr); // Check if endpoint is stalled bool usbd_edpt_stalled(uint8_t rhport, uint8_t ep_addr); +// Check if endpoint is ready (not busy and not stalled) TU_ATTR_ALWAYS_INLINE static inline bool usbd_edpt_ready(uint8_t rhport, uint8_t ep_addr) { diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/hcd.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/hcd.h index 7a9aadc73e6..eb53d2e80e4 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/hcd.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/hcd.h @@ -30,6 +30,7 @@ #include "common/tusb_common.h" #include "osal/osal.h" #include "common/tusb_fifo.h" +#include "hcd_attr.h" #ifdef __cplusplus extern "C" { @@ -62,6 +63,7 @@ typedef struct struct { uint8_t hub_addr; uint8_t hub_port; + uint8_t speed; } connection; // XFER_COMPLETE @@ -84,12 +86,20 @@ typedef struct // Max number of endpoints per device enum { // TODO better computation - HCD_MAX_ENDPOINT = CFG_TUSB_HOST_DEVICE_MAX*(CFG_TUH_HUB + CFG_TUH_HID*2 + CFG_TUH_MSC*2 + CFG_TUH_CDC*3), + HCD_MAX_ENDPOINT = CFG_TUH_DEVICE_MAX*(CFG_TUH_HUB + CFG_TUH_HID*2 + CFG_TUH_MSC*2 + CFG_TUH_CDC*3), HCD_MAX_XFER = HCD_MAX_ENDPOINT*2, }; //#define HCD_MAX_ENDPOINT 16 //#define HCD_MAX_XFER 16 + +typedef struct { + uint8_t rhport; + uint8_t hub_addr; + uint8_t hub_port; + uint8_t speed; +} hcd_devtree_info_t; + #endif //--------------------------------------------------------------------+ @@ -140,9 +150,16 @@ bool hcd_edpt_xfer(uint8_t rhport, uint8_t dev_addr, uint8_t ep_addr, uint8_t * bool hcd_edpt_clear_stall(uint8_t dev_addr, uint8_t ep_addr); //--------------------------------------------------------------------+ -// Event API (implemented by stack) +// USBH implemented API //--------------------------------------------------------------------+ +// Get device tree information of a device +// USB device tree can be complicated and manged by USBH, this help HCD to retrieve +// needed topology info to carry out its work +extern void hcd_devtree_get_info(uint8_t dev_addr, hcd_devtree_info_t* devtree_info); + +//------------- Event API -------------// + // Called by HCD to notify stack extern void hcd_event_handler(hcd_event_t const* event, bool in_isr); diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/hcd_attr.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/hcd_attr.h new file mode 100644 index 00000000000..729fc407b03 --- /dev/null +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/hcd_attr.h @@ -0,0 +1,105 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2021, Ha Thach (tinyusb.org) + * + * 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. + * + * This file is part of the TinyUSB stack. + */ + +#ifndef TUSB_HCD_ATTR_H_ +#define TUSB_HCD_ATTR_H_ + +#include "tusb_option.h" + +// Attribute includes +// - ENDPOINT_MAX: max (logical) number of endpoint +// - PORT_HIGHSPEED: mask to indicate which port support highspeed mode, bit0 for port0 and so on. + +//------------- NXP -------------// +#if TU_CHECK_MCU(LPC175X_6X) || TU_CHECK_MCU(LPC177X_8X) || TU_CHECK_MCU(LPC40XX) + #define HCD_ATTR_OHCI + +#elif TU_CHECK_MCU(LPC18XX) || TU_CHECK_MCU(LPC43XX) + #define HCD_ATTR_EHCI_TRANSDIMENSION + +#elif TU_CHECK_MCU(LPC54XXX) + // #define HCD_ATTR_EHCI_NXP_PTD + +#elif TU_CHECK_MCU(LPC55XX) + // #define HCD_ATTR_EHCI_NXP_PTD + +#elif TU_CHECK_MCU(MIMXRT10XX) + #define HCD_ATTR_EHCI_TRANSDIMENSION + +#elif TU_CHECK_MCU(MKL25ZXX) + +//------------- Microchip -------------// +#elif TU_CHECK_MCU(SAMD21) || TU_CHECK_MCU(SAMD51) || TU_CHECK_MCU(SAME5X) || \ + TU_CHECK_MCU(SAMD11) || TU_CHECK_MCU(SAML21) || TU_CHECK_MCU(SAML22) + +#elif TU_CHECK_MCU(SAMG) + +#elif TU_CHECK_MCU(SAMX7X) + +//------------- ST -------------// +#elif TU_CHECK_MCU(STM32F0) || TU_CHECK_MCU(STM32F1) || TU_CHECK_MCU(STM32F3) || \ + TU_CHECK_MCU(STM32L0) || TU_CHECK_MCU(STM32L1) || TU_CHECK_MCU(STM32L4) + +#elif TU_CHECK_MCU(STM32F2) || TU_CHECK_MCU(STM32F4) || TU_CHECK_MCU(STM32F3) + +#elif TU_CHECK_MCU(STM32F7) + +#elif TU_CHECK_MCU(STM32H7) + +//------------- Sony -------------// +#elif TU_CHECK_MCU(CXD56) + +//------------- Nuvoton -------------// +#elif TU_CHECK_MCU(NUC505) + +//------------- Espressif -------------// +#elif TU_CHECK_MCU(ESP32S2) || TU_CHECK_MCU(ESP32S3) + +//------------- Raspberry Pi -------------// +#elif TU_CHECK_MCU(RP2040) + +//------------- Silabs -------------// +#elif TU_CHECK_MCU(EFM32GG) || TU_CHECK_MCU(EFM32GG11) || TU_CHECK_MCU(EFM32GG12) + +//------------- Renesas -------------// +#elif TU_CHECK_MCU(RX63X) || TU_CHECK_MCU(RX65X) || TU_CHECK_MCU(RX72N) + +//#elif TU_CHECK_MCU(MM32F327X) +// #define DCD_ATTR_ENDPOINT_MAX not known yet + +//------------- GigaDevice -------------// +#elif TU_CHECK_MCU(GD32VF103) + +#else +// #warning "DCD_ATTR_ENDPOINT_MAX is not defined for this MCU, default to 8" +#endif + +// Default to fullspeed if not defined +//#ifndef PORT_HIGHSPEED +// #define DCD_ATTR_PORT_HIGHSPEED 0x00 +//#endif + +#endif diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/hub.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/hub.h index c9ffe498547..c4d5441933e 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/hub.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/hub.h @@ -181,11 +181,11 @@ bool hub_status_pipe_queue(uint8_t dev_addr); //--------------------------------------------------------------------+ // Internal Class Driver API //--------------------------------------------------------------------+ -void hub_init (void); -uint16_t hub_open (uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const *itf_desc, uint16_t max_len); -bool hub_set_config (uint8_t dev_addr, uint8_t itf_num); -bool hub_xfer_cb (uint8_t dev_addr, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes); -void hub_close (uint8_t dev_addr); +void hub_init (void); +bool hub_open (uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const *itf_desc, uint16_t max_len); +bool hub_set_config (uint8_t dev_addr, uint8_t itf_num); +bool hub_xfer_cb (uint8_t dev_addr, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes); +void hub_close (uint8_t dev_addr); #ifdef __cplusplus } diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/usbh.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/usbh.h index 4de6e7ba6a0..8411cad283d 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/usbh.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/usbh.h @@ -57,16 +57,25 @@ void tuh_task(void); extern void hcd_int_handler(uint8_t rhport); #define tuh_int_handler hcd_int_handler -tusb_speed_t tuh_device_get_speed (uint8_t dev_addr); +bool tuh_vid_pid_get(uint8_t dev_addr, uint16_t* vid, uint16_t* pid); +tusb_speed_t tuh_speed_get(uint8_t dev_addr); -// Check if device is configured -bool tuh_device_configured(uint8_t dev_addr); +// Check if device is connected and configured +bool tuh_mounted(uint8_t dev_addr); + +// Check if device is suspended +static inline bool tuh_suspended(uint8_t dev_addr) +{ + // TODO implement suspend & resume on host + (void) dev_addr; + return false; +} // Check if device is ready to communicate with TU_ATTR_ALWAYS_INLINE -static inline bool tuh_device_ready(uint8_t dev_addr) +static inline bool tuh_ready(uint8_t dev_addr) { - return tuh_device_configured(dev_addr); + return tuh_mounted(dev_addr) && !tuh_suspended(dev_addr); } // Carry out control transfer diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/usbh_classdriver.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/usbh_classdriver.h index 0736fefa18f..8bc2622aade 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/usbh_classdriver.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/usbh_classdriver.h @@ -43,13 +43,11 @@ typedef struct { char const* name; #endif - uint8_t class_code; - - void (* const init )(void); - uint16_t (* const open )(uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const * itf_desc, uint16_t max_len); - bool (* const set_config )(uint8_t dev_addr, uint8_t itf_num); - bool (* const xfer_cb )(uint8_t dev_addr, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes); - void (* const close )(uint8_t dev_addr); + void (* const init )(void); + bool (* const open )(uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const * itf_desc, uint16_t max_len); + bool (* const set_config )(uint8_t dev_addr, uint8_t itf_num); + bool (* const xfer_cb )(uint8_t dev_addr, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes); + void (* const close )(uint8_t dev_addr); } usbh_class_driver_t; // Call by class driver to tell USBH that it has complete the enumeration @@ -73,6 +71,8 @@ bool usbh_edpt_xfer(uint8_t dev_addr, uint8_t ep_addr, uint8_t * buffer, uint16_ // If caller does not make any transfer, it must release endpoint for others. bool usbh_edpt_claim(uint8_t dev_addr, uint8_t ep_addr); +bool usbh_edpt_release(uint8_t dev_addr, uint8_t ep_addr); + // Check if endpoint transferring is complete bool usbh_edpt_busy(uint8_t dev_addr, uint8_t ep_addr); diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/usbh_hcd.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/usbh_hcd.h deleted file mode 100644 index b3856d6b779..00000000000 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/usbh_hcd.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Ha Thach (tinyusb.org) - * - * 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. - * - * This file is part of the TinyUSB stack. - */ - -/** \ingroup Group_HCD - * @{ */ - -#ifndef _TUSB_USBH_HCD_H_ -#define _TUSB_USBH_HCD_H_ - -#ifdef __cplusplus - extern "C" { -#endif - -//--------------------------------------------------------------------+ -// INCLUDE -//--------------------------------------------------------------------+ -#include "common/tusb_common.h" -#include "osal/osal.h" - -#ifndef CFG_TUH_EP_MAX -#define CFG_TUH_EP_MAX 9 -#endif - -//--------------------------------------------------------------------+ -// USBH-HCD common data structure -//--------------------------------------------------------------------+ - -// TODO move to usbh.c -typedef struct { - //------------- port -------------// - uint8_t rhport; - uint8_t hub_addr; - uint8_t hub_port; - uint8_t speed; - - //------------- device descriptor -------------// - uint16_t vendor_id; - uint16_t product_id; - uint8_t ep0_packet_size; - - //------------- configuration descriptor -------------// - // uint8_t interface_count; // bNumInterfaces alias - - //------------- device -------------// - struct TU_ATTR_PACKED - { - uint8_t connected : 1; - uint8_t addressed : 1; - uint8_t configured : 1; - uint8_t suspended : 1; - }; - - volatile uint8_t state; // device state, value from enum tusbh_device_state_t - - uint8_t itf2drv[16]; // map interface number to driver (0xff is invalid) - uint8_t ep2drv[CFG_TUH_EP_MAX][2]; // map endpoint to driver ( 0xff is invalid ) - - struct TU_ATTR_PACKED - { - volatile bool busy : 1; - volatile bool stalled : 1; - volatile bool claimed : 1; - - // TODO merge ep2drv here, 4-bit should be sufficient - }ep_status[CFG_TUH_EP_MAX][2]; - - // Mutex for claiming endpoint, only needed when using with preempted RTOS -#if CFG_TUSB_OS != OPT_OS_NONE - osal_mutex_def_t mutexdef; - osal_mutex_t mutex; -#endif - -} usbh_device_t; - -extern usbh_device_t _usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1]; // including zero-address - -#ifdef __cplusplus - } -#endif - -#endif /* _TUSB_USBH_HCD_H_ */ - -/** @} */ diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_freertos.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_freertos.h index 66070c273a7..4573e01f5ef 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_freertos.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_freertos.h @@ -28,10 +28,10 @@ #define _TUSB_OSAL_FREERTOS_H_ // FreeRTOS Headers -#include "FreeRTOS.h" -#include "semphr.h" -#include "queue.h" -#include "task.h" +#include TU_INCLUDE_PATH(CFG_TUSB_OS_INC_PATH,FreeRTOS.h) +#include TU_INCLUDE_PATH(CFG_TUSB_OS_INC_PATH,semphr.h) +#include TU_INCLUDE_PATH(CFG_TUSB_OS_INC_PATH,queue.h) +#include TU_INCLUDE_PATH(CFG_TUSB_OS_INC_PATH,task.h) #ifdef __cplusplus extern "C" { diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/ehci/ehci.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/ehci/ehci.h index 874195a0c27..c2bee67a5bd 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/ehci/ehci.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/ehci/ehci.h @@ -46,8 +46,6 @@ //--------------------------------------------------------------------+ // EHCI CONFIGURATION & CONSTANTS //--------------------------------------------------------------------+ -#define EHCI_CFG_FRAMELIST_SIZE_BITS 7 /// Framelist Size (NXP specific) (0:1024) - (1:512) - (2:256) - (3:128) - (4:64) - (5:32) - (6:16) - (7:8) -#define EHCI_FRAMELIST_SIZE (1024 >> EHCI_CFG_FRAMELIST_SIZE_BITS) // TODO merge OHCI with EHCI enum { @@ -55,9 +53,6 @@ enum { EHCI_MAX_SITD = 16 }; -//------------- Validation -------------// -TU_VERIFY_STATIC(EHCI_CFG_FRAMELIST_SIZE_BITS <= 7, "incorrect value"); - //--------------------------------------------------------------------+ // EHCI Data Structure //--------------------------------------------------------------------+ @@ -294,7 +289,7 @@ enum ehci_interrupt_mask_{ enum ehci_usbcmd_pos_ { EHCI_USBCMD_POS_RUN_STOP = 0, - EHCI_USBCMD_POS_FRAMELIST_SZIE = 2, + EHCI_USBCMD_POS_FRAMELIST_SIZE = 2, EHCI_USBCMD_POS_PERIOD_ENABLE = 4, EHCI_USBCMD_POS_ASYNC_ENABLE = 5, EHCI_USBCMD_POS_NXP_FRAMELIST_SIZE_MSB = 15, @@ -411,7 +406,7 @@ typedef volatile struct uint32_t wake_on_over_current_enable : 1; ///< Enables over-current conditions as wake-up events uint32_t nxp_phy_clock_disable : 1; ///< NXP customized: the PHY can be put into Low Power Suspend – Clock Disable when the downstream device has been put into suspend mode or when no downstream device is connected. Low power suspend is completely under the control of software. 0: enable PHY clock, 1: disable PHY clock uint32_t nxp_port_force_fullspeed : 1; ///< NXP customized: Writing this bit to a 1 will force the port to only connect at Full Speed. It disables the chirp sequence that allowsthe port to identify itself as High Speed. This is useful for testing FS configurations with a HS host, hub or device. - uint32_t : 1; + uint32_t TU_RESERVED : 1; uint32_t nxp_port_speed : 2; ///< NXP customized: This register field indicates the speed atwhich the port is operating. For HS mode operation in the host controllerand HS/FS operation in the device controller the port routing steers data to the Protocol engine. For FS and LS mode operation in the host controller, the port routing steers data to the Protocol Engine w/ Embedded Transaction Translator. 0x0: Fullspeed, 0x1: Lowspeed, 0x2: Highspeed uint32_t TU_RESERVED : 4; }portsc_bm; diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/ehci/hcd_ehci.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/ehci/ehci_api.h similarity index 79% rename from tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/ehci/hcd_ehci.h rename to tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/ehci/ehci_api.h index 480d11eda02..12e0a73d79d 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/ehci/hcd_ehci.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/ehci/ehci_api.h @@ -24,27 +24,19 @@ * This file is part of the TinyUSB stack. */ -#ifndef _TUSB_HCD_EHCI_H_ -#define _TUSB_HCD_EHCI_H_ +#ifndef _TUSB_EHCI_API_H_ +#define _TUSB_EHCI_API_H_ #ifdef __cplusplus extern "C" { #endif - -//--------------------------------------------------------------------+ -// API Implemented by HCD -//--------------------------------------------------------------------+ - -// Get operational address i.e EHCI Command register -uint32_t hcd_ehci_register_addr(uint8_t rhport); - //--------------------------------------------------------------------+ // API Implemented by EHCI //--------------------------------------------------------------------+ // Initialize EHCI driver -extern bool hcd_ehci_init (uint8_t rhport); +bool ehci_init(uint8_t rhport, uint32_t capability_reg, uint32_t operatial_reg); #ifdef __cplusplus } diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/microchip/samx7x/common_usb_regs.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/microchip/samx7x/common_usb_regs.h new file mode 100644 index 00000000000..d232f0bcba9 --- /dev/null +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/microchip/samx7x/common_usb_regs.h @@ -0,0 +1,2108 @@ + /* +* The MIT License (MIT) +* +* Copyright (c) 2019 Microchip Technology Inc. +* Copyright (c) 2018, hathach (tinyusb.org) +* Copyright (c) 2021, HiFiPhile +* +* 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. +* +* This file is part of the TinyUSB stack. +*/ + +#ifndef _COMMON_USB_REGS_H_ +#define _COMMON_USB_REGS_H_ + +#if CFG_TUSB_MCU == OPT_MCU_SAMX7X + +/* -------- DEVDMANXTDSC : (USBHS Offset: 0x00) (R/W 32) Device DMA Channel Next Descriptor Address Register -------- */ + +#define DEVDMANXTDSC_OFFSET (0x00) /**< (DEVDMANXTDSC) Device DMA Channel Next Descriptor Address Register Offset */ + +#define DEVDMANXTDSC_NXT_DSC_ADD_Pos 0 /**< (DEVDMANXTDSC) Next Descriptor Address Position */ +#define DEVDMANXTDSC_NXT_DSC_ADD (_U_(0xFFFFFFFF) << DEVDMANXTDSC_NXT_DSC_ADD_Pos) /**< (DEVDMANXTDSC) Next Descriptor Address Mask */ +#define DEVDMANXTDSC_Msk _U_(0xFFFFFFFF) /**< (DEVDMANXTDSC) Register Mask */ + + +/* -------- DEVDMAADDRESS : (USBHS Offset: 0x04) (R/W 32) Device DMA Channel Address Register -------- */ + +#define DEVDMAADDRESS_OFFSET (0x04) /**< (DEVDMAADDRESS) Device DMA Channel Address Register Offset */ + +#define DEVDMAADDRESS_BUFF_ADD_Pos 0 /**< (DEVDMAADDRESS) Buffer Address Position */ +#define DEVDMAADDRESS_BUFF_ADD (_U_(0xFFFFFFFF) << DEVDMAADDRESS_BUFF_ADD_Pos) /**< (DEVDMAADDRESS) Buffer Address Mask */ +#define DEVDMAADDRESS_Msk _U_(0xFFFFFFFF) /**< (DEVDMAADDRESS) Register Mask */ + + +/* -------- DEVDMACONTROL : (USBHS Offset: 0x08) (R/W 32) Device DMA Channel Control Register -------- */ + +#define DEVDMACONTROL_OFFSET (0x08) /**< (DEVDMACONTROL) Device DMA Channel Control Register Offset */ + +#define DEVDMACONTROL_CHANN_ENB_Pos 0 /**< (DEVDMACONTROL) Channel Enable Command Position */ +#define DEVDMACONTROL_CHANN_ENB (_U_(0x1) << DEVDMACONTROL_CHANN_ENB_Pos) /**< (DEVDMACONTROL) Channel Enable Command Mask */ +#define DEVDMACONTROL_LDNXT_DSC_Pos 1 /**< (DEVDMACONTROL) Load Next Channel Transfer Descriptor Enable Command Position */ +#define DEVDMACONTROL_LDNXT_DSC (_U_(0x1) << DEVDMACONTROL_LDNXT_DSC_Pos) /**< (DEVDMACONTROL) Load Next Channel Transfer Descriptor Enable Command Mask */ +#define DEVDMACONTROL_END_TR_EN_Pos 2 /**< (DEVDMACONTROL) End of Transfer Enable Control (OUT transfers only) Position */ +#define DEVDMACONTROL_END_TR_EN (_U_(0x1) << DEVDMACONTROL_END_TR_EN_Pos) /**< (DEVDMACONTROL) End of Transfer Enable Control (OUT transfers only) Mask */ +#define DEVDMACONTROL_END_B_EN_Pos 3 /**< (DEVDMACONTROL) End of Buffer Enable Control Position */ +#define DEVDMACONTROL_END_B_EN (_U_(0x1) << DEVDMACONTROL_END_B_EN_Pos) /**< (DEVDMACONTROL) End of Buffer Enable Control Mask */ +#define DEVDMACONTROL_END_TR_IT_Pos 4 /**< (DEVDMACONTROL) End of Transfer Interrupt Enable Position */ +#define DEVDMACONTROL_END_TR_IT (_U_(0x1) << DEVDMACONTROL_END_TR_IT_Pos) /**< (DEVDMACONTROL) End of Transfer Interrupt Enable Mask */ +#define DEVDMACONTROL_END_BUFFIT_Pos 5 /**< (DEVDMACONTROL) End of Buffer Interrupt Enable Position */ +#define DEVDMACONTROL_END_BUFFIT (_U_(0x1) << DEVDMACONTROL_END_BUFFIT_Pos) /**< (DEVDMACONTROL) End of Buffer Interrupt Enable Mask */ +#define DEVDMACONTROL_DESC_LD_IT_Pos 6 /**< (DEVDMACONTROL) Descriptor Loaded Interrupt Enable Position */ +#define DEVDMACONTROL_DESC_LD_IT (_U_(0x1) << DEVDMACONTROL_DESC_LD_IT_Pos) /**< (DEVDMACONTROL) Descriptor Loaded Interrupt Enable Mask */ +#define DEVDMACONTROL_BURST_LCK_Pos 7 /**< (DEVDMACONTROL) Burst Lock Enable Position */ +#define DEVDMACONTROL_BURST_LCK (_U_(0x1) << DEVDMACONTROL_BURST_LCK_Pos) /**< (DEVDMACONTROL) Burst Lock Enable Mask */ +#define DEVDMACONTROL_BUFF_LENGTH_Pos 16 /**< (DEVDMACONTROL) Buffer Byte Length (Write-only) Position */ +#define DEVDMACONTROL_BUFF_LENGTH (_U_(0xFFFF) << DEVDMACONTROL_BUFF_LENGTH_Pos) /**< (DEVDMACONTROL) Buffer Byte Length (Write-only) Mask */ +#define DEVDMACONTROL_Msk _U_(0xFFFF00FF) /**< (DEVDMACONTROL) Register Mask */ + + +/* -------- DEVDMASTATUS : (USBHS Offset: 0x0c) (R/W 32) Device DMA Channel Status Register -------- */ + +#define DEVDMASTATUS_OFFSET (0x0C) /**< (DEVDMASTATUS) Device DMA Channel Status Register Offset */ + +#define DEVDMASTATUS_CHANN_ENB_Pos 0 /**< (DEVDMASTATUS) Channel Enable Status Position */ +#define DEVDMASTATUS_CHANN_ENB (_U_(0x1) << DEVDMASTATUS_CHANN_ENB_Pos) /**< (DEVDMASTATUS) Channel Enable Status Mask */ +#define DEVDMASTATUS_CHANN_ACT_Pos 1 /**< (DEVDMASTATUS) Channel Active Status Position */ +#define DEVDMASTATUS_CHANN_ACT (_U_(0x1) << DEVDMASTATUS_CHANN_ACT_Pos) /**< (DEVDMASTATUS) Channel Active Status Mask */ +#define DEVDMASTATUS_END_TR_ST_Pos 4 /**< (DEVDMASTATUS) End of Channel Transfer Status Position */ +#define DEVDMASTATUS_END_TR_ST (_U_(0x1) << DEVDMASTATUS_END_TR_ST_Pos) /**< (DEVDMASTATUS) End of Channel Transfer Status Mask */ +#define DEVDMASTATUS_END_BF_ST_Pos 5 /**< (DEVDMASTATUS) End of Channel Buffer Status Position */ +#define DEVDMASTATUS_END_BF_ST (_U_(0x1) << DEVDMASTATUS_END_BF_ST_Pos) /**< (DEVDMASTATUS) End of Channel Buffer Status Mask */ +#define DEVDMASTATUS_DESC_LDST_Pos 6 /**< (DEVDMASTATUS) Descriptor Loaded Status Position */ +#define DEVDMASTATUS_DESC_LDST (_U_(0x1) << DEVDMASTATUS_DESC_LDST_Pos) /**< (DEVDMASTATUS) Descriptor Loaded Status Mask */ +#define DEVDMASTATUS_BUFF_COUNT_Pos 16 /**< (DEVDMASTATUS) Buffer Byte Count Position */ +#define DEVDMASTATUS_BUFF_COUNT (_U_(0xFFFF) << DEVDMASTATUS_BUFF_COUNT_Pos) /**< (DEVDMASTATUS) Buffer Byte Count Mask */ +#define DEVDMASTATUS_Msk _U_(0xFFFF0073) /**< (DEVDMASTATUS) Register Mask */ + + +/* -------- HSTDMANXTDSC : (USBHS Offset: 0x00) (R/W 32) Host DMA Channel Next Descriptor Address Register -------- */ + +#define HSTDMANXTDSC_OFFSET (0x00) /**< (HSTDMANXTDSC) Host DMA Channel Next Descriptor Address Register Offset */ + +#define HSTDMANXTDSC_NXT_DSC_ADD_Pos 0 /**< (HSTDMANXTDSC) Next Descriptor Address Position */ +#define HSTDMANXTDSC_NXT_DSC_ADD (_U_(0xFFFFFFFF) << HSTDMANXTDSC_NXT_DSC_ADD_Pos) /**< (HSTDMANXTDSC) Next Descriptor Address Mask */ +#define HSTDMANXTDSC_Msk _U_(0xFFFFFFFF) /**< (HSTDMANXTDSC) Register Mask */ + + +/* -------- HSTDMAADDRESS : (USBHS Offset: 0x04) (R/W 32) Host DMA Channel Address Register -------- */ + +#define HSTDMAADDRESS_OFFSET (0x04) /**< (HSTDMAADDRESS) Host DMA Channel Address Register Offset */ + +#define HSTDMAADDRESS_BUFF_ADD_Pos 0 /**< (HSTDMAADDRESS) Buffer Address Position */ +#define HSTDMAADDRESS_BUFF_ADD (_U_(0xFFFFFFFF) << HSTDMAADDRESS_BUFF_ADD_Pos) /**< (HSTDMAADDRESS) Buffer Address Mask */ +#define HSTDMAADDRESS_Msk _U_(0xFFFFFFFF) /**< (HSTDMAADDRESS) Register Mask */ + + +/* -------- HSTDMACONTROL : (USBHS Offset: 0x08) (R/W 32) Host DMA Channel Control Register -------- */ + +#define HSTDMACONTROL_OFFSET (0x08) /**< (HSTDMACONTROL) Host DMA Channel Control Register Offset */ + +#define HSTDMACONTROL_CHANN_ENB_Pos 0 /**< (HSTDMACONTROL) Channel Enable Command Position */ +#define HSTDMACONTROL_CHANN_ENB (_U_(0x1) << HSTDMACONTROL_CHANN_ENB_Pos) /**< (HSTDMACONTROL) Channel Enable Command Mask */ +#define HSTDMACONTROL_LDNXT_DSC_Pos 1 /**< (HSTDMACONTROL) Load Next Channel Transfer Descriptor Enable Command Position */ +#define HSTDMACONTROL_LDNXT_DSC (_U_(0x1) << HSTDMACONTROL_LDNXT_DSC_Pos) /**< (HSTDMACONTROL) Load Next Channel Transfer Descriptor Enable Command Mask */ +#define HSTDMACONTROL_END_TR_EN_Pos 2 /**< (HSTDMACONTROL) End of Transfer Enable Control (OUT transfers only) Position */ +#define HSTDMACONTROL_END_TR_EN (_U_(0x1) << HSTDMACONTROL_END_TR_EN_Pos) /**< (HSTDMACONTROL) End of Transfer Enable Control (OUT transfers only) Mask */ +#define HSTDMACONTROL_END_B_EN_Pos 3 /**< (HSTDMACONTROL) End of Buffer Enable Control Position */ +#define HSTDMACONTROL_END_B_EN (_U_(0x1) << HSTDMACONTROL_END_B_EN_Pos) /**< (HSTDMACONTROL) End of Buffer Enable Control Mask */ +#define HSTDMACONTROL_END_TR_IT_Pos 4 /**< (HSTDMACONTROL) End of Transfer Interrupt Enable Position */ +#define HSTDMACONTROL_END_TR_IT (_U_(0x1) << HSTDMACONTROL_END_TR_IT_Pos) /**< (HSTDMACONTROL) End of Transfer Interrupt Enable Mask */ +#define HSTDMACONTROL_END_BUFFIT_Pos 5 /**< (HSTDMACONTROL) End of Buffer Interrupt Enable Position */ +#define HSTDMACONTROL_END_BUFFIT (_U_(0x1) << HSTDMACONTROL_END_BUFFIT_Pos) /**< (HSTDMACONTROL) End of Buffer Interrupt Enable Mask */ +#define HSTDMACONTROL_DESC_LD_IT_Pos 6 /**< (HSTDMACONTROL) Descriptor Loaded Interrupt Enable Position */ +#define HSTDMACONTROL_DESC_LD_IT (_U_(0x1) << HSTDMACONTROL_DESC_LD_IT_Pos) /**< (HSTDMACONTROL) Descriptor Loaded Interrupt Enable Mask */ +#define HSTDMACONTROL_BURST_LCK_Pos 7 /**< (HSTDMACONTROL) Burst Lock Enable Position */ +#define HSTDMACONTROL_BURST_LCK (_U_(0x1) << HSTDMACONTROL_BURST_LCK_Pos) /**< (HSTDMACONTROL) Burst Lock Enable Mask */ +#define HSTDMACONTROL_BUFF_LENGTH_Pos 16 /**< (HSTDMACONTROL) Buffer Byte Length (Write-only) Position */ +#define HSTDMACONTROL_BUFF_LENGTH (_U_(0xFFFF) << HSTDMACONTROL_BUFF_LENGTH_Pos) /**< (HSTDMACONTROL) Buffer Byte Length (Write-only) Mask */ +#define HSTDMACONTROL_Msk _U_(0xFFFF00FF) /**< (HSTDMACONTROL) Register Mask */ + + +/* -------- HSTDMASTATUS : (USBHS Offset: 0x0c) (R/W 32) Host DMA Channel Status Register -------- */ + +#define HSTDMASTATUS_OFFSET (0x0C) /**< (HSTDMASTATUS) Host DMA Channel Status Register Offset */ + +#define HSTDMASTATUS_CHANN_ENB_Pos 0 /**< (HSTDMASTATUS) Channel Enable Status Position */ +#define HSTDMASTATUS_CHANN_ENB (_U_(0x1) << HSTDMASTATUS_CHANN_ENB_Pos) /**< (HSTDMASTATUS) Channel Enable Status Mask */ +#define HSTDMASTATUS_CHANN_ACT_Pos 1 /**< (HSTDMASTATUS) Channel Active Status Position */ +#define HSTDMASTATUS_CHANN_ACT (_U_(0x1) << HSTDMASTATUS_CHANN_ACT_Pos) /**< (HSTDMASTATUS) Channel Active Status Mask */ +#define HSTDMASTATUS_END_TR_ST_Pos 4 /**< (HSTDMASTATUS) End of Channel Transfer Status Position */ +#define HSTDMASTATUS_END_TR_ST (_U_(0x1) << HSTDMASTATUS_END_TR_ST_Pos) /**< (HSTDMASTATUS) End of Channel Transfer Status Mask */ +#define HSTDMASTATUS_END_BF_ST_Pos 5 /**< (HSTDMASTATUS) End of Channel Buffer Status Position */ +#define HSTDMASTATUS_END_BF_ST (_U_(0x1) << HSTDMASTATUS_END_BF_ST_Pos) /**< (HSTDMASTATUS) End of Channel Buffer Status Mask */ +#define HSTDMASTATUS_DESC_LDST_Pos 6 /**< (HSTDMASTATUS) Descriptor Loaded Status Position */ +#define HSTDMASTATUS_DESC_LDST (_U_(0x1) << HSTDMASTATUS_DESC_LDST_Pos) /**< (HSTDMASTATUS) Descriptor Loaded Status Mask */ +#define HSTDMASTATUS_BUFF_COUNT_Pos 16 /**< (HSTDMASTATUS) Buffer Byte Count Position */ +#define HSTDMASTATUS_BUFF_COUNT (_U_(0xFFFF) << HSTDMASTATUS_BUFF_COUNT_Pos) /**< (HSTDMASTATUS) Buffer Byte Count Mask */ +#define HSTDMASTATUS_Msk _U_(0xFFFF0073) /**< (HSTDMASTATUS) Register Mask */ + + +/* -------- DEVCTRL : (USBHS Offset: 0x00) (R/W 32) Device General Control Register -------- */ + +#define DEVCTRL_OFFSET (0x00) /**< (DEVCTRL) Device General Control Register Offset */ + +#define DEVCTRL_UADD_Pos 0 /**< (DEVCTRL) USB Address Position */ +#define DEVCTRL_UADD (_U_(0x7F) << DEVCTRL_UADD_Pos) /**< (DEVCTRL) USB Address Mask */ +#define DEVCTRL_ADDEN_Pos 7 /**< (DEVCTRL) Address Enable Position */ +#define DEVCTRL_ADDEN (_U_(0x1) << DEVCTRL_ADDEN_Pos) /**< (DEVCTRL) Address Enable Mask */ +#define DEVCTRL_DETACH_Pos 8 /**< (DEVCTRL) Detach Position */ +#define DEVCTRL_DETACH (_U_(0x1) << DEVCTRL_DETACH_Pos) /**< (DEVCTRL) Detach Mask */ +#define DEVCTRL_RMWKUP_Pos 9 /**< (DEVCTRL) Remote Wake-Up Position */ +#define DEVCTRL_RMWKUP (_U_(0x1) << DEVCTRL_RMWKUP_Pos) /**< (DEVCTRL) Remote Wake-Up Mask */ +#define DEVCTRL_SPDCONF_Pos 10 /**< (DEVCTRL) Mode Configuration Position */ +#define DEVCTRL_SPDCONF (_U_(0x3) << DEVCTRL_SPDCONF_Pos) /**< (DEVCTRL) Mode Configuration Mask */ +#define DEVCTRL_SPDCONF_NORMAL_Val _U_(0x0) /**< (DEVCTRL) The peripheral starts in Full-speed mode and performs a high-speed reset to switch to High-speed mode if the host is high-speed-capable. */ +#define DEVCTRL_SPDCONF_LOW_POWER_Val _U_(0x1) /**< (DEVCTRL) For a better consumption, if high speed is not needed. */ +#define DEVCTRL_SPDCONF_HIGH_SPEED_Val _U_(0x2) /**< (DEVCTRL) Forced high speed. */ +#define DEVCTRL_SPDCONF_FORCED_FS_Val _U_(0x3) /**< (DEVCTRL) The peripheral remains in Full-speed mode whatever the host speed capability. */ +#define DEVCTRL_SPDCONF_NORMAL (DEVCTRL_SPDCONF_NORMAL_Val << DEVCTRL_SPDCONF_Pos) /**< (DEVCTRL) The peripheral starts in Full-speed mode and performs a high-speed reset to switch to High-speed mode if the host is high-speed-capable. Position */ +#define DEVCTRL_SPDCONF_LOW_POWER (DEVCTRL_SPDCONF_LOW_POWER_Val << DEVCTRL_SPDCONF_Pos) /**< (DEVCTRL) For a better consumption, if high speed is not needed. Position */ +#define DEVCTRL_SPDCONF_HIGH_SPEED (DEVCTRL_SPDCONF_HIGH_SPEED_Val << DEVCTRL_SPDCONF_Pos) /**< (DEVCTRL) Forced high speed. Position */ +#define DEVCTRL_SPDCONF_FORCED_FS (DEVCTRL_SPDCONF_FORCED_FS_Val << DEVCTRL_SPDCONF_Pos) /**< (DEVCTRL) The peripheral remains in Full-speed mode whatever the host speed capability. Position */ +#define DEVCTRL_LS_Pos 12 /**< (DEVCTRL) Low-Speed Mode Force Position */ +#define DEVCTRL_LS (_U_(0x1) << DEVCTRL_LS_Pos) /**< (DEVCTRL) Low-Speed Mode Force Mask */ +#define DEVCTRL_TSTJ_Pos 13 /**< (DEVCTRL) Test mode J Position */ +#define DEVCTRL_TSTJ (_U_(0x1) << DEVCTRL_TSTJ_Pos) /**< (DEVCTRL) Test mode J Mask */ +#define DEVCTRL_TSTK_Pos 14 /**< (DEVCTRL) Test mode K Position */ +#define DEVCTRL_TSTK (_U_(0x1) << DEVCTRL_TSTK_Pos) /**< (DEVCTRL) Test mode K Mask */ +#define DEVCTRL_TSTPCKT_Pos 15 /**< (DEVCTRL) Test packet mode Position */ +#define DEVCTRL_TSTPCKT (_U_(0x1) << DEVCTRL_TSTPCKT_Pos) /**< (DEVCTRL) Test packet mode Mask */ +#define DEVCTRL_OPMODE2_Pos 16 /**< (DEVCTRL) Specific Operational mode Position */ +#define DEVCTRL_OPMODE2 (_U_(0x1) << DEVCTRL_OPMODE2_Pos) /**< (DEVCTRL) Specific Operational mode Mask */ +#define DEVCTRL_Msk _U_(0x1FFFF) /**< (DEVCTRL) Register Mask */ + +#define DEVCTRL_OPMODE_Pos 16 /**< (DEVCTRL Position) Specific Operational mode */ +#define DEVCTRL_OPMODE (_U_(0x1) << DEVCTRL_OPMODE_Pos) /**< (DEVCTRL Mask) OPMODE */ + +/* -------- DEVISR : (USBHS Offset: 0x04) (R/ 32) Device Global Interrupt Status Register -------- */ + +#define DEVISR_OFFSET (0x04) /**< (DEVISR) Device Global Interrupt Status Register Offset */ + +#define DEVISR_SUSP_Pos 0 /**< (DEVISR) Suspend Interrupt Position */ +#define DEVISR_SUSP (_U_(0x1) << DEVISR_SUSP_Pos) /**< (DEVISR) Suspend Interrupt Mask */ +#define DEVISR_MSOF_Pos 1 /**< (DEVISR) Micro Start of Frame Interrupt Position */ +#define DEVISR_MSOF (_U_(0x1) << DEVISR_MSOF_Pos) /**< (DEVISR) Micro Start of Frame Interrupt Mask */ +#define DEVISR_SOF_Pos 2 /**< (DEVISR) Start of Frame Interrupt Position */ +#define DEVISR_SOF (_U_(0x1) << DEVISR_SOF_Pos) /**< (DEVISR) Start of Frame Interrupt Mask */ +#define DEVISR_EORST_Pos 3 /**< (DEVISR) End of Reset Interrupt Position */ +#define DEVISR_EORST (_U_(0x1) << DEVISR_EORST_Pos) /**< (DEVISR) End of Reset Interrupt Mask */ +#define DEVISR_WAKEUP_Pos 4 /**< (DEVISR) Wake-Up Interrupt Position */ +#define DEVISR_WAKEUP (_U_(0x1) << DEVISR_WAKEUP_Pos) /**< (DEVISR) Wake-Up Interrupt Mask */ +#define DEVISR_EORSM_Pos 5 /**< (DEVISR) End of Resume Interrupt Position */ +#define DEVISR_EORSM (_U_(0x1) << DEVISR_EORSM_Pos) /**< (DEVISR) End of Resume Interrupt Mask */ +#define DEVISR_UPRSM_Pos 6 /**< (DEVISR) Upstream Resume Interrupt Position */ +#define DEVISR_UPRSM (_U_(0x1) << DEVISR_UPRSM_Pos) /**< (DEVISR) Upstream Resume Interrupt Mask */ +#define DEVISR_PEP_0_Pos 12 /**< (DEVISR) Endpoint 0 Interrupt Position */ +#define DEVISR_PEP_0 (_U_(0x1) << DEVISR_PEP_0_Pos) /**< (DEVISR) Endpoint 0 Interrupt Mask */ +#define DEVISR_PEP_1_Pos 13 /**< (DEVISR) Endpoint 1 Interrupt Position */ +#define DEVISR_PEP_1 (_U_(0x1) << DEVISR_PEP_1_Pos) /**< (DEVISR) Endpoint 1 Interrupt Mask */ +#define DEVISR_PEP_2_Pos 14 /**< (DEVISR) Endpoint 2 Interrupt Position */ +#define DEVISR_PEP_2 (_U_(0x1) << DEVISR_PEP_2_Pos) /**< (DEVISR) Endpoint 2 Interrupt Mask */ +#define DEVISR_PEP_3_Pos 15 /**< (DEVISR) Endpoint 3 Interrupt Position */ +#define DEVISR_PEP_3 (_U_(0x1) << DEVISR_PEP_3_Pos) /**< (DEVISR) Endpoint 3 Interrupt Mask */ +#define DEVISR_PEP_4_Pos 16 /**< (DEVISR) Endpoint 4 Interrupt Position */ +#define DEVISR_PEP_4 (_U_(0x1) << DEVISR_PEP_4_Pos) /**< (DEVISR) Endpoint 4 Interrupt Mask */ +#define DEVISR_PEP_5_Pos 17 /**< (DEVISR) Endpoint 5 Interrupt Position */ +#define DEVISR_PEP_5 (_U_(0x1) << DEVISR_PEP_5_Pos) /**< (DEVISR) Endpoint 5 Interrupt Mask */ +#define DEVISR_PEP_6_Pos 18 /**< (DEVISR) Endpoint 6 Interrupt Position */ +#define DEVISR_PEP_6 (_U_(0x1) << DEVISR_PEP_6_Pos) /**< (DEVISR) Endpoint 6 Interrupt Mask */ +#define DEVISR_PEP_7_Pos 19 /**< (DEVISR) Endpoint 7 Interrupt Position */ +#define DEVISR_PEP_7 (_U_(0x1) << DEVISR_PEP_7_Pos) /**< (DEVISR) Endpoint 7 Interrupt Mask */ +#define DEVISR_PEP_8_Pos 20 /**< (DEVISR) Endpoint 8 Interrupt Position */ +#define DEVISR_PEP_8 (_U_(0x1) << DEVISR_PEP_8_Pos) /**< (DEVISR) Endpoint 8 Interrupt Mask */ +#define DEVISR_PEP_9_Pos 21 /**< (DEVISR) Endpoint 9 Interrupt Position */ +#define DEVISR_PEP_9 (_U_(0x1) << DEVISR_PEP_9_Pos) /**< (DEVISR) Endpoint 9 Interrupt Mask */ +#define DEVISR_DMA_1_Pos 25 /**< (DEVISR) DMA Channel 1 Interrupt Position */ +#define DEVISR_DMA_1 (_U_(0x1) << DEVISR_DMA_1_Pos) /**< (DEVISR) DMA Channel 1 Interrupt Mask */ +#define DEVISR_DMA_2_Pos 26 /**< (DEVISR) DMA Channel 2 Interrupt Position */ +#define DEVISR_DMA_2 (_U_(0x1) << DEVISR_DMA_2_Pos) /**< (DEVISR) DMA Channel 2 Interrupt Mask */ +#define DEVISR_DMA_3_Pos 27 /**< (DEVISR) DMA Channel 3 Interrupt Position */ +#define DEVISR_DMA_3 (_U_(0x1) << DEVISR_DMA_3_Pos) /**< (DEVISR) DMA Channel 3 Interrupt Mask */ +#define DEVISR_DMA_4_Pos 28 /**< (DEVISR) DMA Channel 4 Interrupt Position */ +#define DEVISR_DMA_4 (_U_(0x1) << DEVISR_DMA_4_Pos) /**< (DEVISR) DMA Channel 4 Interrupt Mask */ +#define DEVISR_DMA_5_Pos 29 /**< (DEVISR) DMA Channel 5 Interrupt Position */ +#define DEVISR_DMA_5 (_U_(0x1) << DEVISR_DMA_5_Pos) /**< (DEVISR) DMA Channel 5 Interrupt Mask */ +#define DEVISR_DMA_6_Pos 30 /**< (DEVISR) DMA Channel 6 Interrupt Position */ +#define DEVISR_DMA_6 (_U_(0x1) << DEVISR_DMA_6_Pos) /**< (DEVISR) DMA Channel 6 Interrupt Mask */ +#define DEVISR_DMA_7_Pos 31 /**< (DEVISR) DMA Channel 7 Interrupt Position */ +#define DEVISR_DMA_7 (_U_(0x1) << DEVISR_DMA_7_Pos) /**< (DEVISR) DMA Channel 7 Interrupt Mask */ +#define DEVISR_Msk _U_(0xFE3FF07F) /**< (DEVISR) Register Mask */ + +#define DEVISR_PEP__Pos 12 /**< (DEVISR Position) Endpoint x Interrupt */ +#define DEVISR_PEP_ (_U_(0x3FF) << DEVISR_PEP__Pos) /**< (DEVISR Mask) PEP_ */ +#define DEVISR_DMA__Pos 25 /**< (DEVISR Position) DMA Channel 7 Interrupt */ +#define DEVISR_DMA_ (_U_(0x7F) << DEVISR_DMA__Pos) /**< (DEVISR Mask) DMA_ */ + +/* -------- DEVICR : (USBHS Offset: 0x08) (/W 32) Device Global Interrupt Clear Register -------- */ + +#define DEVICR_OFFSET (0x08) /**< (DEVICR) Device Global Interrupt Clear Register Offset */ + +#define DEVICR_SUSPC_Pos 0 /**< (DEVICR) Suspend Interrupt Clear Position */ +#define DEVICR_SUSPC (_U_(0x1) << DEVICR_SUSPC_Pos) /**< (DEVICR) Suspend Interrupt Clear Mask */ +#define DEVICR_MSOFC_Pos 1 /**< (DEVICR) Micro Start of Frame Interrupt Clear Position */ +#define DEVICR_MSOFC (_U_(0x1) << DEVICR_MSOFC_Pos) /**< (DEVICR) Micro Start of Frame Interrupt Clear Mask */ +#define DEVICR_SOFC_Pos 2 /**< (DEVICR) Start of Frame Interrupt Clear Position */ +#define DEVICR_SOFC (_U_(0x1) << DEVICR_SOFC_Pos) /**< (DEVICR) Start of Frame Interrupt Clear Mask */ +#define DEVICR_EORSTC_Pos 3 /**< (DEVICR) End of Reset Interrupt Clear Position */ +#define DEVICR_EORSTC (_U_(0x1) << DEVICR_EORSTC_Pos) /**< (DEVICR) End of Reset Interrupt Clear Mask */ +#define DEVICR_WAKEUPC_Pos 4 /**< (DEVICR) Wake-Up Interrupt Clear Position */ +#define DEVICR_WAKEUPC (_U_(0x1) << DEVICR_WAKEUPC_Pos) /**< (DEVICR) Wake-Up Interrupt Clear Mask */ +#define DEVICR_EORSMC_Pos 5 /**< (DEVICR) End of Resume Interrupt Clear Position */ +#define DEVICR_EORSMC (_U_(0x1) << DEVICR_EORSMC_Pos) /**< (DEVICR) End of Resume Interrupt Clear Mask */ +#define DEVICR_UPRSMC_Pos 6 /**< (DEVICR) Upstream Resume Interrupt Clear Position */ +#define DEVICR_UPRSMC (_U_(0x1) << DEVICR_UPRSMC_Pos) /**< (DEVICR) Upstream Resume Interrupt Clear Mask */ +#define DEVICR_Msk _U_(0x7F) /**< (DEVICR) Register Mask */ + + +/* -------- DEVIFR : (USBHS Offset: 0x0c) (/W 32) Device Global Interrupt Set Register -------- */ + +#define DEVIFR_OFFSET (0x0C) /**< (DEVIFR) Device Global Interrupt Set Register Offset */ + +#define DEVIFR_SUSPS_Pos 0 /**< (DEVIFR) Suspend Interrupt Set Position */ +#define DEVIFR_SUSPS (_U_(0x1) << DEVIFR_SUSPS_Pos) /**< (DEVIFR) Suspend Interrupt Set Mask */ +#define DEVIFR_MSOFS_Pos 1 /**< (DEVIFR) Micro Start of Frame Interrupt Set Position */ +#define DEVIFR_MSOFS (_U_(0x1) << DEVIFR_MSOFS_Pos) /**< (DEVIFR) Micro Start of Frame Interrupt Set Mask */ +#define DEVIFR_SOFS_Pos 2 /**< (DEVIFR) Start of Frame Interrupt Set Position */ +#define DEVIFR_SOFS (_U_(0x1) << DEVIFR_SOFS_Pos) /**< (DEVIFR) Start of Frame Interrupt Set Mask */ +#define DEVIFR_EORSTS_Pos 3 /**< (DEVIFR) End of Reset Interrupt Set Position */ +#define DEVIFR_EORSTS (_U_(0x1) << DEVIFR_EORSTS_Pos) /**< (DEVIFR) End of Reset Interrupt Set Mask */ +#define DEVIFR_WAKEUPS_Pos 4 /**< (DEVIFR) Wake-Up Interrupt Set Position */ +#define DEVIFR_WAKEUPS (_U_(0x1) << DEVIFR_WAKEUPS_Pos) /**< (DEVIFR) Wake-Up Interrupt Set Mask */ +#define DEVIFR_EORSMS_Pos 5 /**< (DEVIFR) End of Resume Interrupt Set Position */ +#define DEVIFR_EORSMS (_U_(0x1) << DEVIFR_EORSMS_Pos) /**< (DEVIFR) End of Resume Interrupt Set Mask */ +#define DEVIFR_UPRSMS_Pos 6 /**< (DEVIFR) Upstream Resume Interrupt Set Position */ +#define DEVIFR_UPRSMS (_U_(0x1) << DEVIFR_UPRSMS_Pos) /**< (DEVIFR) Upstream Resume Interrupt Set Mask */ +#define DEVIFR_DMA_1_Pos 25 /**< (DEVIFR) DMA Channel 1 Interrupt Set Position */ +#define DEVIFR_DMA_1 (_U_(0x1) << DEVIFR_DMA_1_Pos) /**< (DEVIFR) DMA Channel 1 Interrupt Set Mask */ +#define DEVIFR_DMA_2_Pos 26 /**< (DEVIFR) DMA Channel 2 Interrupt Set Position */ +#define DEVIFR_DMA_2 (_U_(0x1) << DEVIFR_DMA_2_Pos) /**< (DEVIFR) DMA Channel 2 Interrupt Set Mask */ +#define DEVIFR_DMA_3_Pos 27 /**< (DEVIFR) DMA Channel 3 Interrupt Set Position */ +#define DEVIFR_DMA_3 (_U_(0x1) << DEVIFR_DMA_3_Pos) /**< (DEVIFR) DMA Channel 3 Interrupt Set Mask */ +#define DEVIFR_DMA_4_Pos 28 /**< (DEVIFR) DMA Channel 4 Interrupt Set Position */ +#define DEVIFR_DMA_4 (_U_(0x1) << DEVIFR_DMA_4_Pos) /**< (DEVIFR) DMA Channel 4 Interrupt Set Mask */ +#define DEVIFR_DMA_5_Pos 29 /**< (DEVIFR) DMA Channel 5 Interrupt Set Position */ +#define DEVIFR_DMA_5 (_U_(0x1) << DEVIFR_DMA_5_Pos) /**< (DEVIFR) DMA Channel 5 Interrupt Set Mask */ +#define DEVIFR_DMA_6_Pos 30 /**< (DEVIFR) DMA Channel 6 Interrupt Set Position */ +#define DEVIFR_DMA_6 (_U_(0x1) << DEVIFR_DMA_6_Pos) /**< (DEVIFR) DMA Channel 6 Interrupt Set Mask */ +#define DEVIFR_DMA_7_Pos 31 /**< (DEVIFR) DMA Channel 7 Interrupt Set Position */ +#define DEVIFR_DMA_7 (_U_(0x1) << DEVIFR_DMA_7_Pos) /**< (DEVIFR) DMA Channel 7 Interrupt Set Mask */ +#define DEVIFR_Msk _U_(0xFE00007F) /**< (DEVIFR) Register Mask */ + +#define DEVIFR_DMA__Pos 25 /**< (DEVIFR Position) DMA Channel 7 Interrupt Set */ +#define DEVIFR_DMA_ (_U_(0x7F) << DEVIFR_DMA__Pos) /**< (DEVIFR Mask) DMA_ */ + +/* -------- DEVIMR : (USBHS Offset: 0x10) (R/ 32) Device Global Interrupt Mask Register -------- */ + +#define DEVIMR_OFFSET (0x10) /**< (DEVIMR) Device Global Interrupt Mask Register Offset */ + +#define DEVIMR_SUSPE_Pos 0 /**< (DEVIMR) Suspend Interrupt Mask Position */ +#define DEVIMR_SUSPE (_U_(0x1) << DEVIMR_SUSPE_Pos) /**< (DEVIMR) Suspend Interrupt Mask Mask */ +#define DEVIMR_MSOFE_Pos 1 /**< (DEVIMR) Micro Start of Frame Interrupt Mask Position */ +#define DEVIMR_MSOFE (_U_(0x1) << DEVIMR_MSOFE_Pos) /**< (DEVIMR) Micro Start of Frame Interrupt Mask Mask */ +#define DEVIMR_SOFE_Pos 2 /**< (DEVIMR) Start of Frame Interrupt Mask Position */ +#define DEVIMR_SOFE (_U_(0x1) << DEVIMR_SOFE_Pos) /**< (DEVIMR) Start of Frame Interrupt Mask Mask */ +#define DEVIMR_EORSTE_Pos 3 /**< (DEVIMR) End of Reset Interrupt Mask Position */ +#define DEVIMR_EORSTE (_U_(0x1) << DEVIMR_EORSTE_Pos) /**< (DEVIMR) End of Reset Interrupt Mask Mask */ +#define DEVIMR_WAKEUPE_Pos 4 /**< (DEVIMR) Wake-Up Interrupt Mask Position */ +#define DEVIMR_WAKEUPE (_U_(0x1) << DEVIMR_WAKEUPE_Pos) /**< (DEVIMR) Wake-Up Interrupt Mask Mask */ +#define DEVIMR_EORSME_Pos 5 /**< (DEVIMR) End of Resume Interrupt Mask Position */ +#define DEVIMR_EORSME (_U_(0x1) << DEVIMR_EORSME_Pos) /**< (DEVIMR) End of Resume Interrupt Mask Mask */ +#define DEVIMR_UPRSME_Pos 6 /**< (DEVIMR) Upstream Resume Interrupt Mask Position */ +#define DEVIMR_UPRSME (_U_(0x1) << DEVIMR_UPRSME_Pos) /**< (DEVIMR) Upstream Resume Interrupt Mask Mask */ +#define DEVIMR_PEP_0_Pos 12 /**< (DEVIMR) Endpoint 0 Interrupt Mask Position */ +#define DEVIMR_PEP_0 (_U_(0x1) << DEVIMR_PEP_0_Pos) /**< (DEVIMR) Endpoint 0 Interrupt Mask Mask */ +#define DEVIMR_PEP_1_Pos 13 /**< (DEVIMR) Endpoint 1 Interrupt Mask Position */ +#define DEVIMR_PEP_1 (_U_(0x1) << DEVIMR_PEP_1_Pos) /**< (DEVIMR) Endpoint 1 Interrupt Mask Mask */ +#define DEVIMR_PEP_2_Pos 14 /**< (DEVIMR) Endpoint 2 Interrupt Mask Position */ +#define DEVIMR_PEP_2 (_U_(0x1) << DEVIMR_PEP_2_Pos) /**< (DEVIMR) Endpoint 2 Interrupt Mask Mask */ +#define DEVIMR_PEP_3_Pos 15 /**< (DEVIMR) Endpoint 3 Interrupt Mask Position */ +#define DEVIMR_PEP_3 (_U_(0x1) << DEVIMR_PEP_3_Pos) /**< (DEVIMR) Endpoint 3 Interrupt Mask Mask */ +#define DEVIMR_PEP_4_Pos 16 /**< (DEVIMR) Endpoint 4 Interrupt Mask Position */ +#define DEVIMR_PEP_4 (_U_(0x1) << DEVIMR_PEP_4_Pos) /**< (DEVIMR) Endpoint 4 Interrupt Mask Mask */ +#define DEVIMR_PEP_5_Pos 17 /**< (DEVIMR) Endpoint 5 Interrupt Mask Position */ +#define DEVIMR_PEP_5 (_U_(0x1) << DEVIMR_PEP_5_Pos) /**< (DEVIMR) Endpoint 5 Interrupt Mask Mask */ +#define DEVIMR_PEP_6_Pos 18 /**< (DEVIMR) Endpoint 6 Interrupt Mask Position */ +#define DEVIMR_PEP_6 (_U_(0x1) << DEVIMR_PEP_6_Pos) /**< (DEVIMR) Endpoint 6 Interrupt Mask Mask */ +#define DEVIMR_PEP_7_Pos 19 /**< (DEVIMR) Endpoint 7 Interrupt Mask Position */ +#define DEVIMR_PEP_7 (_U_(0x1) << DEVIMR_PEP_7_Pos) /**< (DEVIMR) Endpoint 7 Interrupt Mask Mask */ +#define DEVIMR_PEP_8_Pos 20 /**< (DEVIMR) Endpoint 8 Interrupt Mask Position */ +#define DEVIMR_PEP_8 (_U_(0x1) << DEVIMR_PEP_8_Pos) /**< (DEVIMR) Endpoint 8 Interrupt Mask Mask */ +#define DEVIMR_PEP_9_Pos 21 /**< (DEVIMR) Endpoint 9 Interrupt Mask Position */ +#define DEVIMR_PEP_9 (_U_(0x1) << DEVIMR_PEP_9_Pos) /**< (DEVIMR) Endpoint 9 Interrupt Mask Mask */ +#define DEVIMR_DMA_1_Pos 25 /**< (DEVIMR) DMA Channel 1 Interrupt Mask Position */ +#define DEVIMR_DMA_1 (_U_(0x1) << DEVIMR_DMA_1_Pos) /**< (DEVIMR) DMA Channel 1 Interrupt Mask Mask */ +#define DEVIMR_DMA_2_Pos 26 /**< (DEVIMR) DMA Channel 2 Interrupt Mask Position */ +#define DEVIMR_DMA_2 (_U_(0x1) << DEVIMR_DMA_2_Pos) /**< (DEVIMR) DMA Channel 2 Interrupt Mask Mask */ +#define DEVIMR_DMA_3_Pos 27 /**< (DEVIMR) DMA Channel 3 Interrupt Mask Position */ +#define DEVIMR_DMA_3 (_U_(0x1) << DEVIMR_DMA_3_Pos) /**< (DEVIMR) DMA Channel 3 Interrupt Mask Mask */ +#define DEVIMR_DMA_4_Pos 28 /**< (DEVIMR) DMA Channel 4 Interrupt Mask Position */ +#define DEVIMR_DMA_4 (_U_(0x1) << DEVIMR_DMA_4_Pos) /**< (DEVIMR) DMA Channel 4 Interrupt Mask Mask */ +#define DEVIMR_DMA_5_Pos 29 /**< (DEVIMR) DMA Channel 5 Interrupt Mask Position */ +#define DEVIMR_DMA_5 (_U_(0x1) << DEVIMR_DMA_5_Pos) /**< (DEVIMR) DMA Channel 5 Interrupt Mask Mask */ +#define DEVIMR_DMA_6_Pos 30 /**< (DEVIMR) DMA Channel 6 Interrupt Mask Position */ +#define DEVIMR_DMA_6 (_U_(0x1) << DEVIMR_DMA_6_Pos) /**< (DEVIMR) DMA Channel 6 Interrupt Mask Mask */ +#define DEVIMR_DMA_7_Pos 31 /**< (DEVIMR) DMA Channel 7 Interrupt Mask Position */ +#define DEVIMR_DMA_7 (_U_(0x1) << DEVIMR_DMA_7_Pos) /**< (DEVIMR) DMA Channel 7 Interrupt Mask Mask */ +#define DEVIMR_Msk _U_(0xFE3FF07F) /**< (DEVIMR) Register Mask */ + +#define DEVIMR_PEP__Pos 12 /**< (DEVIMR Position) Endpoint x Interrupt Mask */ +#define DEVIMR_PEP_ (_U_(0x3FF) << DEVIMR_PEP__Pos) /**< (DEVIMR Mask) PEP_ */ +#define DEVIMR_DMA__Pos 25 /**< (DEVIMR Position) DMA Channel 7 Interrupt Mask */ +#define DEVIMR_DMA_ (_U_(0x7F) << DEVIMR_DMA__Pos) /**< (DEVIMR Mask) DMA_ */ + +/* -------- DEVIDR : (USBHS Offset: 0x14) (/W 32) Device Global Interrupt Disable Register -------- */ + +#define DEVIDR_OFFSET (0x14) /**< (DEVIDR) Device Global Interrupt Disable Register Offset */ + +#define DEVIDR_SUSPEC_Pos 0 /**< (DEVIDR) Suspend Interrupt Disable Position */ +#define DEVIDR_SUSPEC (_U_(0x1) << DEVIDR_SUSPEC_Pos) /**< (DEVIDR) Suspend Interrupt Disable Mask */ +#define DEVIDR_MSOFEC_Pos 1 /**< (DEVIDR) Micro Start of Frame Interrupt Disable Position */ +#define DEVIDR_MSOFEC (_U_(0x1) << DEVIDR_MSOFEC_Pos) /**< (DEVIDR) Micro Start of Frame Interrupt Disable Mask */ +#define DEVIDR_SOFEC_Pos 2 /**< (DEVIDR) Start of Frame Interrupt Disable Position */ +#define DEVIDR_SOFEC (_U_(0x1) << DEVIDR_SOFEC_Pos) /**< (DEVIDR) Start of Frame Interrupt Disable Mask */ +#define DEVIDR_EORSTEC_Pos 3 /**< (DEVIDR) End of Reset Interrupt Disable Position */ +#define DEVIDR_EORSTEC (_U_(0x1) << DEVIDR_EORSTEC_Pos) /**< (DEVIDR) End of Reset Interrupt Disable Mask */ +#define DEVIDR_WAKEUPEC_Pos 4 /**< (DEVIDR) Wake-Up Interrupt Disable Position */ +#define DEVIDR_WAKEUPEC (_U_(0x1) << DEVIDR_WAKEUPEC_Pos) /**< (DEVIDR) Wake-Up Interrupt Disable Mask */ +#define DEVIDR_EORSMEC_Pos 5 /**< (DEVIDR) End of Resume Interrupt Disable Position */ +#define DEVIDR_EORSMEC (_U_(0x1) << DEVIDR_EORSMEC_Pos) /**< (DEVIDR) End of Resume Interrupt Disable Mask */ +#define DEVIDR_UPRSMEC_Pos 6 /**< (DEVIDR) Upstream Resume Interrupt Disable Position */ +#define DEVIDR_UPRSMEC (_U_(0x1) << DEVIDR_UPRSMEC_Pos) /**< (DEVIDR) Upstream Resume Interrupt Disable Mask */ +#define DEVIDR_PEP_0_Pos 12 /**< (DEVIDR) Endpoint 0 Interrupt Disable Position */ +#define DEVIDR_PEP_0 (_U_(0x1) << DEVIDR_PEP_0_Pos) /**< (DEVIDR) Endpoint 0 Interrupt Disable Mask */ +#define DEVIDR_PEP_1_Pos 13 /**< (DEVIDR) Endpoint 1 Interrupt Disable Position */ +#define DEVIDR_PEP_1 (_U_(0x1) << DEVIDR_PEP_1_Pos) /**< (DEVIDR) Endpoint 1 Interrupt Disable Mask */ +#define DEVIDR_PEP_2_Pos 14 /**< (DEVIDR) Endpoint 2 Interrupt Disable Position */ +#define DEVIDR_PEP_2 (_U_(0x1) << DEVIDR_PEP_2_Pos) /**< (DEVIDR) Endpoint 2 Interrupt Disable Mask */ +#define DEVIDR_PEP_3_Pos 15 /**< (DEVIDR) Endpoint 3 Interrupt Disable Position */ +#define DEVIDR_PEP_3 (_U_(0x1) << DEVIDR_PEP_3_Pos) /**< (DEVIDR) Endpoint 3 Interrupt Disable Mask */ +#define DEVIDR_PEP_4_Pos 16 /**< (DEVIDR) Endpoint 4 Interrupt Disable Position */ +#define DEVIDR_PEP_4 (_U_(0x1) << DEVIDR_PEP_4_Pos) /**< (DEVIDR) Endpoint 4 Interrupt Disable Mask */ +#define DEVIDR_PEP_5_Pos 17 /**< (DEVIDR) Endpoint 5 Interrupt Disable Position */ +#define DEVIDR_PEP_5 (_U_(0x1) << DEVIDR_PEP_5_Pos) /**< (DEVIDR) Endpoint 5 Interrupt Disable Mask */ +#define DEVIDR_PEP_6_Pos 18 /**< (DEVIDR) Endpoint 6 Interrupt Disable Position */ +#define DEVIDR_PEP_6 (_U_(0x1) << DEVIDR_PEP_6_Pos) /**< (DEVIDR) Endpoint 6 Interrupt Disable Mask */ +#define DEVIDR_PEP_7_Pos 19 /**< (DEVIDR) Endpoint 7 Interrupt Disable Position */ +#define DEVIDR_PEP_7 (_U_(0x1) << DEVIDR_PEP_7_Pos) /**< (DEVIDR) Endpoint 7 Interrupt Disable Mask */ +#define DEVIDR_PEP_8_Pos 20 /**< (DEVIDR) Endpoint 8 Interrupt Disable Position */ +#define DEVIDR_PEP_8 (_U_(0x1) << DEVIDR_PEP_8_Pos) /**< (DEVIDR) Endpoint 8 Interrupt Disable Mask */ +#define DEVIDR_PEP_9_Pos 21 /**< (DEVIDR) Endpoint 9 Interrupt Disable Position */ +#define DEVIDR_PEP_9 (_U_(0x1) << DEVIDR_PEP_9_Pos) /**< (DEVIDR) Endpoint 9 Interrupt Disable Mask */ +#define DEVIDR_DMA_1_Pos 25 /**< (DEVIDR) DMA Channel 1 Interrupt Disable Position */ +#define DEVIDR_DMA_1 (_U_(0x1) << DEVIDR_DMA_1_Pos) /**< (DEVIDR) DMA Channel 1 Interrupt Disable Mask */ +#define DEVIDR_DMA_2_Pos 26 /**< (DEVIDR) DMA Channel 2 Interrupt Disable Position */ +#define DEVIDR_DMA_2 (_U_(0x1) << DEVIDR_DMA_2_Pos) /**< (DEVIDR) DMA Channel 2 Interrupt Disable Mask */ +#define DEVIDR_DMA_3_Pos 27 /**< (DEVIDR) DMA Channel 3 Interrupt Disable Position */ +#define DEVIDR_DMA_3 (_U_(0x1) << DEVIDR_DMA_3_Pos) /**< (DEVIDR) DMA Channel 3 Interrupt Disable Mask */ +#define DEVIDR_DMA_4_Pos 28 /**< (DEVIDR) DMA Channel 4 Interrupt Disable Position */ +#define DEVIDR_DMA_4 (_U_(0x1) << DEVIDR_DMA_4_Pos) /**< (DEVIDR) DMA Channel 4 Interrupt Disable Mask */ +#define DEVIDR_DMA_5_Pos 29 /**< (DEVIDR) DMA Channel 5 Interrupt Disable Position */ +#define DEVIDR_DMA_5 (_U_(0x1) << DEVIDR_DMA_5_Pos) /**< (DEVIDR) DMA Channel 5 Interrupt Disable Mask */ +#define DEVIDR_DMA_6_Pos 30 /**< (DEVIDR) DMA Channel 6 Interrupt Disable Position */ +#define DEVIDR_DMA_6 (_U_(0x1) << DEVIDR_DMA_6_Pos) /**< (DEVIDR) DMA Channel 6 Interrupt Disable Mask */ +#define DEVIDR_DMA_7_Pos 31 /**< (DEVIDR) DMA Channel 7 Interrupt Disable Position */ +#define DEVIDR_DMA_7 (_U_(0x1) << DEVIDR_DMA_7_Pos) /**< (DEVIDR) DMA Channel 7 Interrupt Disable Mask */ +#define DEVIDR_Msk _U_(0xFE3FF07F) /**< (DEVIDR) Register Mask */ + +#define DEVIDR_PEP__Pos 12 /**< (DEVIDR Position) Endpoint x Interrupt Disable */ +#define DEVIDR_PEP_ (_U_(0x3FF) << DEVIDR_PEP__Pos) /**< (DEVIDR Mask) PEP_ */ +#define DEVIDR_DMA__Pos 25 /**< (DEVIDR Position) DMA Channel 7 Interrupt Disable */ +#define DEVIDR_DMA_ (_U_(0x7F) << DEVIDR_DMA__Pos) /**< (DEVIDR Mask) DMA_ */ + +/* -------- DEVIER : (USBHS Offset: 0x18) (/W 32) Device Global Interrupt Enable Register -------- */ + +#define DEVIER_OFFSET (0x18) /**< (DEVIER) Device Global Interrupt Enable Register Offset */ + +#define DEVIER_SUSPES_Pos 0 /**< (DEVIER) Suspend Interrupt Enable Position */ +#define DEVIER_SUSPES (_U_(0x1) << DEVIER_SUSPES_Pos) /**< (DEVIER) Suspend Interrupt Enable Mask */ +#define DEVIER_MSOFES_Pos 1 /**< (DEVIER) Micro Start of Frame Interrupt Enable Position */ +#define DEVIER_MSOFES (_U_(0x1) << DEVIER_MSOFES_Pos) /**< (DEVIER) Micro Start of Frame Interrupt Enable Mask */ +#define DEVIER_SOFES_Pos 2 /**< (DEVIER) Start of Frame Interrupt Enable Position */ +#define DEVIER_SOFES (_U_(0x1) << DEVIER_SOFES_Pos) /**< (DEVIER) Start of Frame Interrupt Enable Mask */ +#define DEVIER_EORSTES_Pos 3 /**< (DEVIER) End of Reset Interrupt Enable Position */ +#define DEVIER_EORSTES (_U_(0x1) << DEVIER_EORSTES_Pos) /**< (DEVIER) End of Reset Interrupt Enable Mask */ +#define DEVIER_WAKEUPES_Pos 4 /**< (DEVIER) Wake-Up Interrupt Enable Position */ +#define DEVIER_WAKEUPES (_U_(0x1) << DEVIER_WAKEUPES_Pos) /**< (DEVIER) Wake-Up Interrupt Enable Mask */ +#define DEVIER_EORSMES_Pos 5 /**< (DEVIER) End of Resume Interrupt Enable Position */ +#define DEVIER_EORSMES (_U_(0x1) << DEVIER_EORSMES_Pos) /**< (DEVIER) End of Resume Interrupt Enable Mask */ +#define DEVIER_UPRSMES_Pos 6 /**< (DEVIER) Upstream Resume Interrupt Enable Position */ +#define DEVIER_UPRSMES (_U_(0x1) << DEVIER_UPRSMES_Pos) /**< (DEVIER) Upstream Resume Interrupt Enable Mask */ +#define DEVIER_PEP_0_Pos 12 /**< (DEVIER) Endpoint 0 Interrupt Enable Position */ +#define DEVIER_PEP_0 (_U_(0x1) << DEVIER_PEP_0_Pos) /**< (DEVIER) Endpoint 0 Interrupt Enable Mask */ +#define DEVIER_PEP_1_Pos 13 /**< (DEVIER) Endpoint 1 Interrupt Enable Position */ +#define DEVIER_PEP_1 (_U_(0x1) << DEVIER_PEP_1_Pos) /**< (DEVIER) Endpoint 1 Interrupt Enable Mask */ +#define DEVIER_PEP_2_Pos 14 /**< (DEVIER) Endpoint 2 Interrupt Enable Position */ +#define DEVIER_PEP_2 (_U_(0x1) << DEVIER_PEP_2_Pos) /**< (DEVIER) Endpoint 2 Interrupt Enable Mask */ +#define DEVIER_PEP_3_Pos 15 /**< (DEVIER) Endpoint 3 Interrupt Enable Position */ +#define DEVIER_PEP_3 (_U_(0x1) << DEVIER_PEP_3_Pos) /**< (DEVIER) Endpoint 3 Interrupt Enable Mask */ +#define DEVIER_PEP_4_Pos 16 /**< (DEVIER) Endpoint 4 Interrupt Enable Position */ +#define DEVIER_PEP_4 (_U_(0x1) << DEVIER_PEP_4_Pos) /**< (DEVIER) Endpoint 4 Interrupt Enable Mask */ +#define DEVIER_PEP_5_Pos 17 /**< (DEVIER) Endpoint 5 Interrupt Enable Position */ +#define DEVIER_PEP_5 (_U_(0x1) << DEVIER_PEP_5_Pos) /**< (DEVIER) Endpoint 5 Interrupt Enable Mask */ +#define DEVIER_PEP_6_Pos 18 /**< (DEVIER) Endpoint 6 Interrupt Enable Position */ +#define DEVIER_PEP_6 (_U_(0x1) << DEVIER_PEP_6_Pos) /**< (DEVIER) Endpoint 6 Interrupt Enable Mask */ +#define DEVIER_PEP_7_Pos 19 /**< (DEVIER) Endpoint 7 Interrupt Enable Position */ +#define DEVIER_PEP_7 (_U_(0x1) << DEVIER_PEP_7_Pos) /**< (DEVIER) Endpoint 7 Interrupt Enable Mask */ +#define DEVIER_PEP_8_Pos 20 /**< (DEVIER) Endpoint 8 Interrupt Enable Position */ +#define DEVIER_PEP_8 (_U_(0x1) << DEVIER_PEP_8_Pos) /**< (DEVIER) Endpoint 8 Interrupt Enable Mask */ +#define DEVIER_PEP_9_Pos 21 /**< (DEVIER) Endpoint 9 Interrupt Enable Position */ +#define DEVIER_PEP_9 (_U_(0x1) << DEVIER_PEP_9_Pos) /**< (DEVIER) Endpoint 9 Interrupt Enable Mask */ +#define DEVIER_DMA_1_Pos 25 /**< (DEVIER) DMA Channel 1 Interrupt Enable Position */ +#define DEVIER_DMA_1 (_U_(0x1) << DEVIER_DMA_1_Pos) /**< (DEVIER) DMA Channel 1 Interrupt Enable Mask */ +#define DEVIER_DMA_2_Pos 26 /**< (DEVIER) DMA Channel 2 Interrupt Enable Position */ +#define DEVIER_DMA_2 (_U_(0x1) << DEVIER_DMA_2_Pos) /**< (DEVIER) DMA Channel 2 Interrupt Enable Mask */ +#define DEVIER_DMA_3_Pos 27 /**< (DEVIER) DMA Channel 3 Interrupt Enable Position */ +#define DEVIER_DMA_3 (_U_(0x1) << DEVIER_DMA_3_Pos) /**< (DEVIER) DMA Channel 3 Interrupt Enable Mask */ +#define DEVIER_DMA_4_Pos 28 /**< (DEVIER) DMA Channel 4 Interrupt Enable Position */ +#define DEVIER_DMA_4 (_U_(0x1) << DEVIER_DMA_4_Pos) /**< (DEVIER) DMA Channel 4 Interrupt Enable Mask */ +#define DEVIER_DMA_5_Pos 29 /**< (DEVIER) DMA Channel 5 Interrupt Enable Position */ +#define DEVIER_DMA_5 (_U_(0x1) << DEVIER_DMA_5_Pos) /**< (DEVIER) DMA Channel 5 Interrupt Enable Mask */ +#define DEVIER_DMA_6_Pos 30 /**< (DEVIER) DMA Channel 6 Interrupt Enable Position */ +#define DEVIER_DMA_6 (_U_(0x1) << DEVIER_DMA_6_Pos) /**< (DEVIER) DMA Channel 6 Interrupt Enable Mask */ +#define DEVIER_DMA_7_Pos 31 /**< (DEVIER) DMA Channel 7 Interrupt Enable Position */ +#define DEVIER_DMA_7 (_U_(0x1) << DEVIER_DMA_7_Pos) /**< (DEVIER) DMA Channel 7 Interrupt Enable Mask */ +#define DEVIER_Msk _U_(0xFE3FF07F) /**< (DEVIER) Register Mask */ + +#define DEVIER_PEP__Pos 12 /**< (DEVIER Position) Endpoint x Interrupt Enable */ +#define DEVIER_PEP_ (_U_(0x3FF) << DEVIER_PEP__Pos) /**< (DEVIER Mask) PEP_ */ +#define DEVIER_DMA__Pos 25 /**< (DEVIER Position) DMA Channel 7 Interrupt Enable */ +#define DEVIER_DMA_ (_U_(0x7F) << DEVIER_DMA__Pos) /**< (DEVIER Mask) DMA_ */ + +/* -------- DEVEPT : (USBHS Offset: 0x1c) (R/W 32) Device Endpoint Register -------- */ + +#define DEVEPT_OFFSET (0x1C) /**< (DEVEPT) Device Endpoint Register Offset */ + +#define DEVEPT_EPEN0_Pos 0 /**< (DEVEPT) Endpoint 0 Enable Position */ +#define DEVEPT_EPEN0 (_U_(0x1) << DEVEPT_EPEN0_Pos) /**< (DEVEPT) Endpoint 0 Enable Mask */ +#define DEVEPT_EPEN1_Pos 1 /**< (DEVEPT) Endpoint 1 Enable Position */ +#define DEVEPT_EPEN1 (_U_(0x1) << DEVEPT_EPEN1_Pos) /**< (DEVEPT) Endpoint 1 Enable Mask */ +#define DEVEPT_EPEN2_Pos 2 /**< (DEVEPT) Endpoint 2 Enable Position */ +#define DEVEPT_EPEN2 (_U_(0x1) << DEVEPT_EPEN2_Pos) /**< (DEVEPT) Endpoint 2 Enable Mask */ +#define DEVEPT_EPEN3_Pos 3 /**< (DEVEPT) Endpoint 3 Enable Position */ +#define DEVEPT_EPEN3 (_U_(0x1) << DEVEPT_EPEN3_Pos) /**< (DEVEPT) Endpoint 3 Enable Mask */ +#define DEVEPT_EPEN4_Pos 4 /**< (DEVEPT) Endpoint 4 Enable Position */ +#define DEVEPT_EPEN4 (_U_(0x1) << DEVEPT_EPEN4_Pos) /**< (DEVEPT) Endpoint 4 Enable Mask */ +#define DEVEPT_EPEN5_Pos 5 /**< (DEVEPT) Endpoint 5 Enable Position */ +#define DEVEPT_EPEN5 (_U_(0x1) << DEVEPT_EPEN5_Pos) /**< (DEVEPT) Endpoint 5 Enable Mask */ +#define DEVEPT_EPEN6_Pos 6 /**< (DEVEPT) Endpoint 6 Enable Position */ +#define DEVEPT_EPEN6 (_U_(0x1) << DEVEPT_EPEN6_Pos) /**< (DEVEPT) Endpoint 6 Enable Mask */ +#define DEVEPT_EPEN7_Pos 7 /**< (DEVEPT) Endpoint 7 Enable Position */ +#define DEVEPT_EPEN7 (_U_(0x1) << DEVEPT_EPEN7_Pos) /**< (DEVEPT) Endpoint 7 Enable Mask */ +#define DEVEPT_EPEN8_Pos 8 /**< (DEVEPT) Endpoint 8 Enable Position */ +#define DEVEPT_EPEN8 (_U_(0x1) << DEVEPT_EPEN8_Pos) /**< (DEVEPT) Endpoint 8 Enable Mask */ +#define DEVEPT_EPEN9_Pos 9 /**< (DEVEPT) Endpoint 9 Enable Position */ +#define DEVEPT_EPEN9 (_U_(0x1) << DEVEPT_EPEN9_Pos) /**< (DEVEPT) Endpoint 9 Enable Mask */ +#define DEVEPT_EPRST0_Pos 16 /**< (DEVEPT) Endpoint 0 Reset Position */ +#define DEVEPT_EPRST0 (_U_(0x1) << DEVEPT_EPRST0_Pos) /**< (DEVEPT) Endpoint 0 Reset Mask */ +#define DEVEPT_EPRST1_Pos 17 /**< (DEVEPT) Endpoint 1 Reset Position */ +#define DEVEPT_EPRST1 (_U_(0x1) << DEVEPT_EPRST1_Pos) /**< (DEVEPT) Endpoint 1 Reset Mask */ +#define DEVEPT_EPRST2_Pos 18 /**< (DEVEPT) Endpoint 2 Reset Position */ +#define DEVEPT_EPRST2 (_U_(0x1) << DEVEPT_EPRST2_Pos) /**< (DEVEPT) Endpoint 2 Reset Mask */ +#define DEVEPT_EPRST3_Pos 19 /**< (DEVEPT) Endpoint 3 Reset Position */ +#define DEVEPT_EPRST3 (_U_(0x1) << DEVEPT_EPRST3_Pos) /**< (DEVEPT) Endpoint 3 Reset Mask */ +#define DEVEPT_EPRST4_Pos 20 /**< (DEVEPT) Endpoint 4 Reset Position */ +#define DEVEPT_EPRST4 (_U_(0x1) << DEVEPT_EPRST4_Pos) /**< (DEVEPT) Endpoint 4 Reset Mask */ +#define DEVEPT_EPRST5_Pos 21 /**< (DEVEPT) Endpoint 5 Reset Position */ +#define DEVEPT_EPRST5 (_U_(0x1) << DEVEPT_EPRST5_Pos) /**< (DEVEPT) Endpoint 5 Reset Mask */ +#define DEVEPT_EPRST6_Pos 22 /**< (DEVEPT) Endpoint 6 Reset Position */ +#define DEVEPT_EPRST6 (_U_(0x1) << DEVEPT_EPRST6_Pos) /**< (DEVEPT) Endpoint 6 Reset Mask */ +#define DEVEPT_EPRST7_Pos 23 /**< (DEVEPT) Endpoint 7 Reset Position */ +#define DEVEPT_EPRST7 (_U_(0x1) << DEVEPT_EPRST7_Pos) /**< (DEVEPT) Endpoint 7 Reset Mask */ +#define DEVEPT_EPRST8_Pos 24 /**< (DEVEPT) Endpoint 8 Reset Position */ +#define DEVEPT_EPRST8 (_U_(0x1) << DEVEPT_EPRST8_Pos) /**< (DEVEPT) Endpoint 8 Reset Mask */ +#define DEVEPT_EPRST9_Pos 25 /**< (DEVEPT) Endpoint 9 Reset Position */ +#define DEVEPT_EPRST9 (_U_(0x1) << DEVEPT_EPRST9_Pos) /**< (DEVEPT) Endpoint 9 Reset Mask */ +#define DEVEPT_Msk _U_(0x3FF03FF) /**< (DEVEPT) Register Mask */ + +#define DEVEPT_EPEN_Pos 0 /**< (DEVEPT Position) Endpoint x Enable */ +#define DEVEPT_EPEN (_U_(0x3FF) << DEVEPT_EPEN_Pos) /**< (DEVEPT Mask) EPEN */ +#define DEVEPT_EPRST_Pos 16 /**< (DEVEPT Position) Endpoint 9 Reset */ +#define DEVEPT_EPRST (_U_(0x3FF) << DEVEPT_EPRST_Pos) /**< (DEVEPT Mask) EPRST */ + +/* -------- DEVFNUM : (USBHS Offset: 0x20) (R/ 32) Device Frame Number Register -------- */ + +#define DEVFNUM_OFFSET (0x20) /**< (DEVFNUM) Device Frame Number Register Offset */ + +#define DEVFNUM_MFNUM_Pos 0 /**< (DEVFNUM) Micro Frame Number Position */ +#define DEVFNUM_MFNUM (_U_(0x7) << DEVFNUM_MFNUM_Pos) /**< (DEVFNUM) Micro Frame Number Mask */ +#define DEVFNUM_FNUM_Pos 3 /**< (DEVFNUM) Frame Number Position */ +#define DEVFNUM_FNUM (_U_(0x7FF) << DEVFNUM_FNUM_Pos) /**< (DEVFNUM) Frame Number Mask */ +#define DEVFNUM_FNCERR_Pos 15 /**< (DEVFNUM) Frame Number CRC Error Position */ +#define DEVFNUM_FNCERR (_U_(0x1) << DEVFNUM_FNCERR_Pos) /**< (DEVFNUM) Frame Number CRC Error Mask */ +#define DEVFNUM_Msk _U_(0xBFFF) /**< (DEVFNUM) Register Mask */ + + +/* -------- DEVEPTCFG : (USBHS Offset: 0x100) (R/W 32) Device Endpoint Configuration Register -------- */ + +#define DEVEPTCFG_OFFSET (0x100) /**< (DEVEPTCFG) Device Endpoint Configuration Register Offset */ + +#define DEVEPTCFG_ALLOC_Pos 1 /**< (DEVEPTCFG) Endpoint Memory Allocate Position */ +#define DEVEPTCFG_ALLOC (_U_(0x1) << DEVEPTCFG_ALLOC_Pos) /**< (DEVEPTCFG) Endpoint Memory Allocate Mask */ +#define DEVEPTCFG_EPBK_Pos 2 /**< (DEVEPTCFG) Endpoint Banks Position */ +#define DEVEPTCFG_EPBK (_U_(0x3) << DEVEPTCFG_EPBK_Pos) /**< (DEVEPTCFG) Endpoint Banks Mask */ +#define DEVEPTCFG_EPBK_1_BANK_Val _U_(0x0) /**< (DEVEPTCFG) Single-bank endpoint */ +#define DEVEPTCFG_EPBK_2_BANK_Val _U_(0x1) /**< (DEVEPTCFG) Double-bank endpoint */ +#define DEVEPTCFG_EPBK_3_BANK_Val _U_(0x2) /**< (DEVEPTCFG) Triple-bank endpoint */ +#define DEVEPTCFG_EPBK_1_BANK (DEVEPTCFG_EPBK_1_BANK_Val << DEVEPTCFG_EPBK_Pos) /**< (DEVEPTCFG) Single-bank endpoint Position */ +#define DEVEPTCFG_EPBK_2_BANK (DEVEPTCFG_EPBK_2_BANK_Val << DEVEPTCFG_EPBK_Pos) /**< (DEVEPTCFG) Double-bank endpoint Position */ +#define DEVEPTCFG_EPBK_3_BANK (DEVEPTCFG_EPBK_3_BANK_Val << DEVEPTCFG_EPBK_Pos) /**< (DEVEPTCFG) Triple-bank endpoint Position */ +#define DEVEPTCFG_EPSIZE_Pos 4 /**< (DEVEPTCFG) Endpoint Size Position */ +#define DEVEPTCFG_EPSIZE (_U_(0x7) << DEVEPTCFG_EPSIZE_Pos) /**< (DEVEPTCFG) Endpoint Size Mask */ +#define DEVEPTCFG_EPSIZE_8_BYTE_Val _U_(0x0) /**< (DEVEPTCFG) 8 bytes */ +#define DEVEPTCFG_EPSIZE_16_BYTE_Val _U_(0x1) /**< (DEVEPTCFG) 16 bytes */ +#define DEVEPTCFG_EPSIZE_32_BYTE_Val _U_(0x2) /**< (DEVEPTCFG) 32 bytes */ +#define DEVEPTCFG_EPSIZE_64_BYTE_Val _U_(0x3) /**< (DEVEPTCFG) 64 bytes */ +#define DEVEPTCFG_EPSIZE_128_BYTE_Val _U_(0x4) /**< (DEVEPTCFG) 128 bytes */ +#define DEVEPTCFG_EPSIZE_256_BYTE_Val _U_(0x5) /**< (DEVEPTCFG) 256 bytes */ +#define DEVEPTCFG_EPSIZE_512_BYTE_Val _U_(0x6) /**< (DEVEPTCFG) 512 bytes */ +#define DEVEPTCFG_EPSIZE_1024_BYTE_Val _U_(0x7) /**< (DEVEPTCFG) 1024 bytes */ +#define DEVEPTCFG_EPSIZE_8_BYTE (DEVEPTCFG_EPSIZE_8_BYTE_Val << DEVEPTCFG_EPSIZE_Pos) /**< (DEVEPTCFG) 8 bytes Position */ +#define DEVEPTCFG_EPSIZE_16_BYTE (DEVEPTCFG_EPSIZE_16_BYTE_Val << DEVEPTCFG_EPSIZE_Pos) /**< (DEVEPTCFG) 16 bytes Position */ +#define DEVEPTCFG_EPSIZE_32_BYTE (DEVEPTCFG_EPSIZE_32_BYTE_Val << DEVEPTCFG_EPSIZE_Pos) /**< (DEVEPTCFG) 32 bytes Position */ +#define DEVEPTCFG_EPSIZE_64_BYTE (DEVEPTCFG_EPSIZE_64_BYTE_Val << DEVEPTCFG_EPSIZE_Pos) /**< (DEVEPTCFG) 64 bytes Position */ +#define DEVEPTCFG_EPSIZE_128_BYTE (DEVEPTCFG_EPSIZE_128_BYTE_Val << DEVEPTCFG_EPSIZE_Pos) /**< (DEVEPTCFG) 128 bytes Position */ +#define DEVEPTCFG_EPSIZE_256_BYTE (DEVEPTCFG_EPSIZE_256_BYTE_Val << DEVEPTCFG_EPSIZE_Pos) /**< (DEVEPTCFG) 256 bytes Position */ +#define DEVEPTCFG_EPSIZE_512_BYTE (DEVEPTCFG_EPSIZE_512_BYTE_Val << DEVEPTCFG_EPSIZE_Pos) /**< (DEVEPTCFG) 512 bytes Position */ +#define DEVEPTCFG_EPSIZE_1024_BYTE (DEVEPTCFG_EPSIZE_1024_BYTE_Val << DEVEPTCFG_EPSIZE_Pos) /**< (DEVEPTCFG) 1024 bytes Position */ +#define DEVEPTCFG_EPDIR_Pos 8 /**< (DEVEPTCFG) Endpoint Direction Position */ +#define DEVEPTCFG_EPDIR (_U_(0x1) << DEVEPTCFG_EPDIR_Pos) /**< (DEVEPTCFG) Endpoint Direction Mask */ +#define DEVEPTCFG_EPDIR_OUT_Val _U_(0x0) /**< (DEVEPTCFG) The endpoint direction is OUT. */ +#define DEVEPTCFG_EPDIR_IN_Val _U_(0x1) /**< (DEVEPTCFG) The endpoint direction is IN (nor for control endpoints). */ +#define DEVEPTCFG_EPDIR_OUT (DEVEPTCFG_EPDIR_OUT_Val << DEVEPTCFG_EPDIR_Pos) /**< (DEVEPTCFG) The endpoint direction is OUT. Position */ +#define DEVEPTCFG_EPDIR_IN (DEVEPTCFG_EPDIR_IN_Val << DEVEPTCFG_EPDIR_Pos) /**< (DEVEPTCFG) The endpoint direction is IN (nor for control endpoints). Position */ +#define DEVEPTCFG_AUTOSW_Pos 9 /**< (DEVEPTCFG) Automatic Switch Position */ +#define DEVEPTCFG_AUTOSW (_U_(0x1) << DEVEPTCFG_AUTOSW_Pos) /**< (DEVEPTCFG) Automatic Switch Mask */ +#define DEVEPTCFG_EPTYPE_Pos 11 /**< (DEVEPTCFG) Endpoint Type Position */ +#define DEVEPTCFG_EPTYPE (_U_(0x3) << DEVEPTCFG_EPTYPE_Pos) /**< (DEVEPTCFG) Endpoint Type Mask */ +#define DEVEPTCFG_EPTYPE_CTRL_Val _U_(0x0) /**< (DEVEPTCFG) Control */ +#define DEVEPTCFG_EPTYPE_ISO_Val _U_(0x1) /**< (DEVEPTCFG) Isochronous */ +#define DEVEPTCFG_EPTYPE_BLK_Val _U_(0x2) /**< (DEVEPTCFG) Bulk */ +#define DEVEPTCFG_EPTYPE_INTRPT_Val _U_(0x3) /**< (DEVEPTCFG) Interrupt */ +#define DEVEPTCFG_EPTYPE_CTRL (DEVEPTCFG_EPTYPE_CTRL_Val << DEVEPTCFG_EPTYPE_Pos) /**< (DEVEPTCFG) Control Position */ +#define DEVEPTCFG_EPTYPE_ISO (DEVEPTCFG_EPTYPE_ISO_Val << DEVEPTCFG_EPTYPE_Pos) /**< (DEVEPTCFG) Isochronous Position */ +#define DEVEPTCFG_EPTYPE_BLK (DEVEPTCFG_EPTYPE_BLK_Val << DEVEPTCFG_EPTYPE_Pos) /**< (DEVEPTCFG) Bulk Position */ +#define DEVEPTCFG_EPTYPE_INTRPT (DEVEPTCFG_EPTYPE_INTRPT_Val << DEVEPTCFG_EPTYPE_Pos) /**< (DEVEPTCFG) Interrupt Position */ +#define DEVEPTCFG_NBTRANS_Pos 13 /**< (DEVEPTCFG) Number of transactions per microframe for isochronous endpoint Position */ +#define DEVEPTCFG_NBTRANS (_U_(0x3) << DEVEPTCFG_NBTRANS_Pos) /**< (DEVEPTCFG) Number of transactions per microframe for isochronous endpoint Mask */ +#define DEVEPTCFG_NBTRANS_0_TRANS_Val _U_(0x0) /**< (DEVEPTCFG) Reserved to endpoint that does not have the high-bandwidth isochronous capability. */ +#define DEVEPTCFG_NBTRANS_1_TRANS_Val _U_(0x1) /**< (DEVEPTCFG) Default value: one transaction per microframe. */ +#define DEVEPTCFG_NBTRANS_2_TRANS_Val _U_(0x2) /**< (DEVEPTCFG) Two transactions per microframe. This endpoint should be configured as double-bank. */ +#define DEVEPTCFG_NBTRANS_3_TRANS_Val _U_(0x3) /**< (DEVEPTCFG) Three transactions per microframe. This endpoint should be configured as triple-bank. */ +#define DEVEPTCFG_NBTRANS_0_TRANS (DEVEPTCFG_NBTRANS_0_TRANS_Val << DEVEPTCFG_NBTRANS_Pos) /**< (DEVEPTCFG) Reserved to endpoint that does not have the high-bandwidth isochronous capability. Position */ +#define DEVEPTCFG_NBTRANS_1_TRANS (DEVEPTCFG_NBTRANS_1_TRANS_Val << DEVEPTCFG_NBTRANS_Pos) /**< (DEVEPTCFG) Default value: one transaction per microframe. Position */ +#define DEVEPTCFG_NBTRANS_2_TRANS (DEVEPTCFG_NBTRANS_2_TRANS_Val << DEVEPTCFG_NBTRANS_Pos) /**< (DEVEPTCFG) Two transactions per microframe. This endpoint should be configured as double-bank. Position */ +#define DEVEPTCFG_NBTRANS_3_TRANS (DEVEPTCFG_NBTRANS_3_TRANS_Val << DEVEPTCFG_NBTRANS_Pos) /**< (DEVEPTCFG) Three transactions per microframe. This endpoint should be configured as triple-bank. Position */ +#define DEVEPTCFG_Msk _U_(0x7B7E) /**< (DEVEPTCFG) Register Mask */ + + +/* -------- DEVEPTISR : (USBHS Offset: 0x130) (R/ 32) Device Endpoint Interrupt Status Register -------- */ + +#define DEVEPTISR_OFFSET (0x130) /**< (DEVEPTISR) Device Endpoint Interrupt Status Register Offset */ + +#define DEVEPTISR_TXINI_Pos 0 /**< (DEVEPTISR) Transmitted IN Data Interrupt Position */ +#define DEVEPTISR_TXINI (_U_(0x1) << DEVEPTISR_TXINI_Pos) /**< (DEVEPTISR) Transmitted IN Data Interrupt Mask */ +#define DEVEPTISR_RXOUTI_Pos 1 /**< (DEVEPTISR) Received OUT Data Interrupt Position */ +#define DEVEPTISR_RXOUTI (_U_(0x1) << DEVEPTISR_RXOUTI_Pos) /**< (DEVEPTISR) Received OUT Data Interrupt Mask */ +#define DEVEPTISR_OVERFI_Pos 5 /**< (DEVEPTISR) Overflow Interrupt Position */ +#define DEVEPTISR_OVERFI (_U_(0x1) << DEVEPTISR_OVERFI_Pos) /**< (DEVEPTISR) Overflow Interrupt Mask */ +#define DEVEPTISR_SHORTPACKET_Pos 7 /**< (DEVEPTISR) Short Packet Interrupt Position */ +#define DEVEPTISR_SHORTPACKET (_U_(0x1) << DEVEPTISR_SHORTPACKET_Pos) /**< (DEVEPTISR) Short Packet Interrupt Mask */ +#define DEVEPTISR_DTSEQ_Pos 8 /**< (DEVEPTISR) Data Toggle Sequence Position */ +#define DEVEPTISR_DTSEQ (_U_(0x3) << DEVEPTISR_DTSEQ_Pos) /**< (DEVEPTISR) Data Toggle Sequence Mask */ +#define DEVEPTISR_DTSEQ_DATA0_Val _U_(0x0) /**< (DEVEPTISR) Data0 toggle sequence */ +#define DEVEPTISR_DTSEQ_DATA1_Val _U_(0x1) /**< (DEVEPTISR) Data1 toggle sequence */ +#define DEVEPTISR_DTSEQ_DATA2_Val _U_(0x2) /**< (DEVEPTISR) Reserved for high-bandwidth isochronous endpoint */ +#define DEVEPTISR_DTSEQ_MDATA_Val _U_(0x3) /**< (DEVEPTISR) Reserved for high-bandwidth isochronous endpoint */ +#define DEVEPTISR_DTSEQ_DATA0 (DEVEPTISR_DTSEQ_DATA0_Val << DEVEPTISR_DTSEQ_Pos) /**< (DEVEPTISR) Data0 toggle sequence Position */ +#define DEVEPTISR_DTSEQ_DATA1 (DEVEPTISR_DTSEQ_DATA1_Val << DEVEPTISR_DTSEQ_Pos) /**< (DEVEPTISR) Data1 toggle sequence Position */ +#define DEVEPTISR_DTSEQ_DATA2 (DEVEPTISR_DTSEQ_DATA2_Val << DEVEPTISR_DTSEQ_Pos) /**< (DEVEPTISR) Reserved for high-bandwidth isochronous endpoint Position */ +#define DEVEPTISR_DTSEQ_MDATA (DEVEPTISR_DTSEQ_MDATA_Val << DEVEPTISR_DTSEQ_Pos) /**< (DEVEPTISR) Reserved for high-bandwidth isochronous endpoint Position */ +#define DEVEPTISR_NBUSYBK_Pos 12 /**< (DEVEPTISR) Number of Busy Banks Position */ +#define DEVEPTISR_NBUSYBK (_U_(0x3) << DEVEPTISR_NBUSYBK_Pos) /**< (DEVEPTISR) Number of Busy Banks Mask */ +#define DEVEPTISR_NBUSYBK_0_BUSY_Val _U_(0x0) /**< (DEVEPTISR) 0 busy bank (all banks free) */ +#define DEVEPTISR_NBUSYBK_1_BUSY_Val _U_(0x1) /**< (DEVEPTISR) 1 busy bank */ +#define DEVEPTISR_NBUSYBK_2_BUSY_Val _U_(0x2) /**< (DEVEPTISR) 2 busy banks */ +#define DEVEPTISR_NBUSYBK_3_BUSY_Val _U_(0x3) /**< (DEVEPTISR) 3 busy banks */ +#define DEVEPTISR_NBUSYBK_0_BUSY (DEVEPTISR_NBUSYBK_0_BUSY_Val << DEVEPTISR_NBUSYBK_Pos) /**< (DEVEPTISR) 0 busy bank (all banks free) Position */ +#define DEVEPTISR_NBUSYBK_1_BUSY (DEVEPTISR_NBUSYBK_1_BUSY_Val << DEVEPTISR_NBUSYBK_Pos) /**< (DEVEPTISR) 1 busy bank Position */ +#define DEVEPTISR_NBUSYBK_2_BUSY (DEVEPTISR_NBUSYBK_2_BUSY_Val << DEVEPTISR_NBUSYBK_Pos) /**< (DEVEPTISR) 2 busy banks Position */ +#define DEVEPTISR_NBUSYBK_3_BUSY (DEVEPTISR_NBUSYBK_3_BUSY_Val << DEVEPTISR_NBUSYBK_Pos) /**< (DEVEPTISR) 3 busy banks Position */ +#define DEVEPTISR_CURRBK_Pos 14 /**< (DEVEPTISR) Current Bank Position */ +#define DEVEPTISR_CURRBK (_U_(0x3) << DEVEPTISR_CURRBK_Pos) /**< (DEVEPTISR) Current Bank Mask */ +#define DEVEPTISR_CURRBK_BANK0_Val _U_(0x0) /**< (DEVEPTISR) Current bank is bank0 */ +#define DEVEPTISR_CURRBK_BANK1_Val _U_(0x1) /**< (DEVEPTISR) Current bank is bank1 */ +#define DEVEPTISR_CURRBK_BANK2_Val _U_(0x2) /**< (DEVEPTISR) Current bank is bank2 */ +#define DEVEPTISR_CURRBK_BANK0 (DEVEPTISR_CURRBK_BANK0_Val << DEVEPTISR_CURRBK_Pos) /**< (DEVEPTISR) Current bank is bank0 Position */ +#define DEVEPTISR_CURRBK_BANK1 (DEVEPTISR_CURRBK_BANK1_Val << DEVEPTISR_CURRBK_Pos) /**< (DEVEPTISR) Current bank is bank1 Position */ +#define DEVEPTISR_CURRBK_BANK2 (DEVEPTISR_CURRBK_BANK2_Val << DEVEPTISR_CURRBK_Pos) /**< (DEVEPTISR) Current bank is bank2 Position */ +#define DEVEPTISR_RWALL_Pos 16 /**< (DEVEPTISR) Read/Write Allowed Position */ +#define DEVEPTISR_RWALL (_U_(0x1) << DEVEPTISR_RWALL_Pos) /**< (DEVEPTISR) Read/Write Allowed Mask */ +#define DEVEPTISR_CFGOK_Pos 18 /**< (DEVEPTISR) Configuration OK Status Position */ +#define DEVEPTISR_CFGOK (_U_(0x1) << DEVEPTISR_CFGOK_Pos) /**< (DEVEPTISR) Configuration OK Status Mask */ +#define DEVEPTISR_BYCT_Pos 20 /**< (DEVEPTISR) Byte Count Position */ +#define DEVEPTISR_BYCT (_U_(0x7FF) << DEVEPTISR_BYCT_Pos) /**< (DEVEPTISR) Byte Count Mask */ +#define DEVEPTISR_Msk _U_(0x7FF5F3A3) /**< (DEVEPTISR) Register Mask */ + +/* CTRL mode */ +#define DEVEPTISR_CTRL_RXSTPI_Pos 2 /**< (DEVEPTISR) Received SETUP Interrupt Position */ +#define DEVEPTISR_CTRL_RXSTPI (_U_(0x1) << DEVEPTISR_CTRL_RXSTPI_Pos) /**< (DEVEPTISR) Received SETUP Interrupt Mask */ +#define DEVEPTISR_CTRL_NAKOUTI_Pos 3 /**< (DEVEPTISR) NAKed OUT Interrupt Position */ +#define DEVEPTISR_CTRL_NAKOUTI (_U_(0x1) << DEVEPTISR_CTRL_NAKOUTI_Pos) /**< (DEVEPTISR) NAKed OUT Interrupt Mask */ +#define DEVEPTISR_CTRL_NAKINI_Pos 4 /**< (DEVEPTISR) NAKed IN Interrupt Position */ +#define DEVEPTISR_CTRL_NAKINI (_U_(0x1) << DEVEPTISR_CTRL_NAKINI_Pos) /**< (DEVEPTISR) NAKed IN Interrupt Mask */ +#define DEVEPTISR_CTRL_STALLEDI_Pos 6 /**< (DEVEPTISR) STALLed Interrupt Position */ +#define DEVEPTISR_CTRL_STALLEDI (_U_(0x1) << DEVEPTISR_CTRL_STALLEDI_Pos) /**< (DEVEPTISR) STALLed Interrupt Mask */ +#define DEVEPTISR_CTRL_CTRLDIR_Pos 17 /**< (DEVEPTISR) Control Direction Position */ +#define DEVEPTISR_CTRL_CTRLDIR (_U_(0x1) << DEVEPTISR_CTRL_CTRLDIR_Pos) /**< (DEVEPTISR) Control Direction Mask */ +#define DEVEPTISR_CTRL_Msk _U_(0x2005C) /**< (DEVEPTISR_CTRL) Register Mask */ + +/* ISO mode */ +#define DEVEPTISR_ISO_UNDERFI_Pos 2 /**< (DEVEPTISR) Underflow Interrupt Position */ +#define DEVEPTISR_ISO_UNDERFI (_U_(0x1) << DEVEPTISR_ISO_UNDERFI_Pos) /**< (DEVEPTISR) Underflow Interrupt Mask */ +#define DEVEPTISR_ISO_HBISOINERRI_Pos 3 /**< (DEVEPTISR) High Bandwidth Isochronous IN Underflow Error Interrupt Position */ +#define DEVEPTISR_ISO_HBISOINERRI (_U_(0x1) << DEVEPTISR_ISO_HBISOINERRI_Pos) /**< (DEVEPTISR) High Bandwidth Isochronous IN Underflow Error Interrupt Mask */ +#define DEVEPTISR_ISO_HBISOFLUSHI_Pos 4 /**< (DEVEPTISR) High Bandwidth Isochronous IN Flush Interrupt Position */ +#define DEVEPTISR_ISO_HBISOFLUSHI (_U_(0x1) << DEVEPTISR_ISO_HBISOFLUSHI_Pos) /**< (DEVEPTISR) High Bandwidth Isochronous IN Flush Interrupt Mask */ +#define DEVEPTISR_ISO_CRCERRI_Pos 6 /**< (DEVEPTISR) CRC Error Interrupt Position */ +#define DEVEPTISR_ISO_CRCERRI (_U_(0x1) << DEVEPTISR_ISO_CRCERRI_Pos) /**< (DEVEPTISR) CRC Error Interrupt Mask */ +#define DEVEPTISR_ISO_ERRORTRANS_Pos 10 /**< (DEVEPTISR) High-bandwidth Isochronous OUT Endpoint Transaction Error Interrupt Position */ +#define DEVEPTISR_ISO_ERRORTRANS (_U_(0x1) << DEVEPTISR_ISO_ERRORTRANS_Pos) /**< (DEVEPTISR) High-bandwidth Isochronous OUT Endpoint Transaction Error Interrupt Mask */ +#define DEVEPTISR_ISO_Msk _U_(0x45C) /**< (DEVEPTISR_ISO) Register Mask */ + +/* BLK mode */ +#define DEVEPTISR_BLK_RXSTPI_Pos 2 /**< (DEVEPTISR) Received SETUP Interrupt Position */ +#define DEVEPTISR_BLK_RXSTPI (_U_(0x1) << DEVEPTISR_BLK_RXSTPI_Pos) /**< (DEVEPTISR) Received SETUP Interrupt Mask */ +#define DEVEPTISR_BLK_NAKOUTI_Pos 3 /**< (DEVEPTISR) NAKed OUT Interrupt Position */ +#define DEVEPTISR_BLK_NAKOUTI (_U_(0x1) << DEVEPTISR_BLK_NAKOUTI_Pos) /**< (DEVEPTISR) NAKed OUT Interrupt Mask */ +#define DEVEPTISR_BLK_NAKINI_Pos 4 /**< (DEVEPTISR) NAKed IN Interrupt Position */ +#define DEVEPTISR_BLK_NAKINI (_U_(0x1) << DEVEPTISR_BLK_NAKINI_Pos) /**< (DEVEPTISR) NAKed IN Interrupt Mask */ +#define DEVEPTISR_BLK_STALLEDI_Pos 6 /**< (DEVEPTISR) STALLed Interrupt Position */ +#define DEVEPTISR_BLK_STALLEDI (_U_(0x1) << DEVEPTISR_BLK_STALLEDI_Pos) /**< (DEVEPTISR) STALLed Interrupt Mask */ +#define DEVEPTISR_BLK_CTRLDIR_Pos 17 /**< (DEVEPTISR) Control Direction Position */ +#define DEVEPTISR_BLK_CTRLDIR (_U_(0x1) << DEVEPTISR_BLK_CTRLDIR_Pos) /**< (DEVEPTISR) Control Direction Mask */ +#define DEVEPTISR_BLK_Msk _U_(0x2005C) /**< (DEVEPTISR_BLK) Register Mask */ + +/* INTRPT mode */ +#define DEVEPTISR_INTRPT_RXSTPI_Pos 2 /**< (DEVEPTISR) Received SETUP Interrupt Position */ +#define DEVEPTISR_INTRPT_RXSTPI (_U_(0x1) << DEVEPTISR_INTRPT_RXSTPI_Pos) /**< (DEVEPTISR) Received SETUP Interrupt Mask */ +#define DEVEPTISR_INTRPT_NAKOUTI_Pos 3 /**< (DEVEPTISR) NAKed OUT Interrupt Position */ +#define DEVEPTISR_INTRPT_NAKOUTI (_U_(0x1) << DEVEPTISR_INTRPT_NAKOUTI_Pos) /**< (DEVEPTISR) NAKed OUT Interrupt Mask */ +#define DEVEPTISR_INTRPT_NAKINI_Pos 4 /**< (DEVEPTISR) NAKed IN Interrupt Position */ +#define DEVEPTISR_INTRPT_NAKINI (_U_(0x1) << DEVEPTISR_INTRPT_NAKINI_Pos) /**< (DEVEPTISR) NAKed IN Interrupt Mask */ +#define DEVEPTISR_INTRPT_STALLEDI_Pos 6 /**< (DEVEPTISR) STALLed Interrupt Position */ +#define DEVEPTISR_INTRPT_STALLEDI (_U_(0x1) << DEVEPTISR_INTRPT_STALLEDI_Pos) /**< (DEVEPTISR) STALLed Interrupt Mask */ +#define DEVEPTISR_INTRPT_CTRLDIR_Pos 17 /**< (DEVEPTISR) Control Direction Position */ +#define DEVEPTISR_INTRPT_CTRLDIR (_U_(0x1) << DEVEPTISR_INTRPT_CTRLDIR_Pos) /**< (DEVEPTISR) Control Direction Mask */ +#define DEVEPTISR_INTRPT_Msk _U_(0x2005C) /**< (DEVEPTISR_INTRPT) Register Mask */ + + +/* -------- DEVEPTICR : (USBHS Offset: 0x160) (/W 32) Device Endpoint Interrupt Clear Register -------- */ + +#define DEVEPTICR_OFFSET (0x160) /**< (DEVEPTICR) Device Endpoint Interrupt Clear Register Offset */ + +#define DEVEPTICR_TXINIC_Pos 0 /**< (DEVEPTICR) Transmitted IN Data Interrupt Clear Position */ +#define DEVEPTICR_TXINIC (_U_(0x1) << DEVEPTICR_TXINIC_Pos) /**< (DEVEPTICR) Transmitted IN Data Interrupt Clear Mask */ +#define DEVEPTICR_RXOUTIC_Pos 1 /**< (DEVEPTICR) Received OUT Data Interrupt Clear Position */ +#define DEVEPTICR_RXOUTIC (_U_(0x1) << DEVEPTICR_RXOUTIC_Pos) /**< (DEVEPTICR) Received OUT Data Interrupt Clear Mask */ +#define DEVEPTICR_OVERFIC_Pos 5 /**< (DEVEPTICR) Overflow Interrupt Clear Position */ +#define DEVEPTICR_OVERFIC (_U_(0x1) << DEVEPTICR_OVERFIC_Pos) /**< (DEVEPTICR) Overflow Interrupt Clear Mask */ +#define DEVEPTICR_SHORTPACKETC_Pos 7 /**< (DEVEPTICR) Short Packet Interrupt Clear Position */ +#define DEVEPTICR_SHORTPACKETC (_U_(0x1) << DEVEPTICR_SHORTPACKETC_Pos) /**< (DEVEPTICR) Short Packet Interrupt Clear Mask */ +#define DEVEPTICR_Msk _U_(0xA3) /**< (DEVEPTICR) Register Mask */ + +/* CTRL mode */ +#define DEVEPTICR_CTRL_RXSTPIC_Pos 2 /**< (DEVEPTICR) Received SETUP Interrupt Clear Position */ +#define DEVEPTICR_CTRL_RXSTPIC (_U_(0x1) << DEVEPTICR_CTRL_RXSTPIC_Pos) /**< (DEVEPTICR) Received SETUP Interrupt Clear Mask */ +#define DEVEPTICR_CTRL_NAKOUTIC_Pos 3 /**< (DEVEPTICR) NAKed OUT Interrupt Clear Position */ +#define DEVEPTICR_CTRL_NAKOUTIC (_U_(0x1) << DEVEPTICR_CTRL_NAKOUTIC_Pos) /**< (DEVEPTICR) NAKed OUT Interrupt Clear Mask */ +#define DEVEPTICR_CTRL_NAKINIC_Pos 4 /**< (DEVEPTICR) NAKed IN Interrupt Clear Position */ +#define DEVEPTICR_CTRL_NAKINIC (_U_(0x1) << DEVEPTICR_CTRL_NAKINIC_Pos) /**< (DEVEPTICR) NAKed IN Interrupt Clear Mask */ +#define DEVEPTICR_CTRL_STALLEDIC_Pos 6 /**< (DEVEPTICR) STALLed Interrupt Clear Position */ +#define DEVEPTICR_CTRL_STALLEDIC (_U_(0x1) << DEVEPTICR_CTRL_STALLEDIC_Pos) /**< (DEVEPTICR) STALLed Interrupt Clear Mask */ +#define DEVEPTICR_CTRL_Msk _U_(0x5C) /**< (DEVEPTICR_CTRL) Register Mask */ + +/* ISO mode */ +#define DEVEPTICR_ISO_UNDERFIC_Pos 2 /**< (DEVEPTICR) Underflow Interrupt Clear Position */ +#define DEVEPTICR_ISO_UNDERFIC (_U_(0x1) << DEVEPTICR_ISO_UNDERFIC_Pos) /**< (DEVEPTICR) Underflow Interrupt Clear Mask */ +#define DEVEPTICR_ISO_HBISOINERRIC_Pos 3 /**< (DEVEPTICR) High Bandwidth Isochronous IN Underflow Error Interrupt Clear Position */ +#define DEVEPTICR_ISO_HBISOINERRIC (_U_(0x1) << DEVEPTICR_ISO_HBISOINERRIC_Pos) /**< (DEVEPTICR) High Bandwidth Isochronous IN Underflow Error Interrupt Clear Mask */ +#define DEVEPTICR_ISO_HBISOFLUSHIC_Pos 4 /**< (DEVEPTICR) High Bandwidth Isochronous IN Flush Interrupt Clear Position */ +#define DEVEPTICR_ISO_HBISOFLUSHIC (_U_(0x1) << DEVEPTICR_ISO_HBISOFLUSHIC_Pos) /**< (DEVEPTICR) High Bandwidth Isochronous IN Flush Interrupt Clear Mask */ +#define DEVEPTICR_ISO_CRCERRIC_Pos 6 /**< (DEVEPTICR) CRC Error Interrupt Clear Position */ +#define DEVEPTICR_ISO_CRCERRIC (_U_(0x1) << DEVEPTICR_ISO_CRCERRIC_Pos) /**< (DEVEPTICR) CRC Error Interrupt Clear Mask */ +#define DEVEPTICR_ISO_Msk _U_(0x5C) /**< (DEVEPTICR_ISO) Register Mask */ + +/* BLK mode */ +#define DEVEPTICR_BLK_RXSTPIC_Pos 2 /**< (DEVEPTICR) Received SETUP Interrupt Clear Position */ +#define DEVEPTICR_BLK_RXSTPIC (_U_(0x1) << DEVEPTICR_BLK_RXSTPIC_Pos) /**< (DEVEPTICR) Received SETUP Interrupt Clear Mask */ +#define DEVEPTICR_BLK_NAKOUTIC_Pos 3 /**< (DEVEPTICR) NAKed OUT Interrupt Clear Position */ +#define DEVEPTICR_BLK_NAKOUTIC (_U_(0x1) << DEVEPTICR_BLK_NAKOUTIC_Pos) /**< (DEVEPTICR) NAKed OUT Interrupt Clear Mask */ +#define DEVEPTICR_BLK_NAKINIC_Pos 4 /**< (DEVEPTICR) NAKed IN Interrupt Clear Position */ +#define DEVEPTICR_BLK_NAKINIC (_U_(0x1) << DEVEPTICR_BLK_NAKINIC_Pos) /**< (DEVEPTICR) NAKed IN Interrupt Clear Mask */ +#define DEVEPTICR_BLK_STALLEDIC_Pos 6 /**< (DEVEPTICR) STALLed Interrupt Clear Position */ +#define DEVEPTICR_BLK_STALLEDIC (_U_(0x1) << DEVEPTICR_BLK_STALLEDIC_Pos) /**< (DEVEPTICR) STALLed Interrupt Clear Mask */ +#define DEVEPTICR_BLK_Msk _U_(0x5C) /**< (DEVEPTICR_BLK) Register Mask */ + +/* INTRPT mode */ +#define DEVEPTICR_INTRPT_RXSTPIC_Pos 2 /**< (DEVEPTICR) Received SETUP Interrupt Clear Position */ +#define DEVEPTICR_INTRPT_RXSTPIC (_U_(0x1) << DEVEPTICR_INTRPT_RXSTPIC_Pos) /**< (DEVEPTICR) Received SETUP Interrupt Clear Mask */ +#define DEVEPTICR_INTRPT_NAKOUTIC_Pos 3 /**< (DEVEPTICR) NAKed OUT Interrupt Clear Position */ +#define DEVEPTICR_INTRPT_NAKOUTIC (_U_(0x1) << DEVEPTICR_INTRPT_NAKOUTIC_Pos) /**< (DEVEPTICR) NAKed OUT Interrupt Clear Mask */ +#define DEVEPTICR_INTRPT_NAKINIC_Pos 4 /**< (DEVEPTICR) NAKed IN Interrupt Clear Position */ +#define DEVEPTICR_INTRPT_NAKINIC (_U_(0x1) << DEVEPTICR_INTRPT_NAKINIC_Pos) /**< (DEVEPTICR) NAKed IN Interrupt Clear Mask */ +#define DEVEPTICR_INTRPT_STALLEDIC_Pos 6 /**< (DEVEPTICR) STALLed Interrupt Clear Position */ +#define DEVEPTICR_INTRPT_STALLEDIC (_U_(0x1) << DEVEPTICR_INTRPT_STALLEDIC_Pos) /**< (DEVEPTICR) STALLed Interrupt Clear Mask */ +#define DEVEPTICR_INTRPT_Msk _U_(0x5C) /**< (DEVEPTICR_INTRPT) Register Mask */ + + +/* -------- DEVEPTIFR : (USBHS Offset: 0x190) (/W 32) Device Endpoint Interrupt Set Register -------- */ + +#define DEVEPTIFR_OFFSET (0x190) /**< (DEVEPTIFR) Device Endpoint Interrupt Set Register Offset */ + +#define DEVEPTIFR_TXINIS_Pos 0 /**< (DEVEPTIFR) Transmitted IN Data Interrupt Set Position */ +#define DEVEPTIFR_TXINIS (_U_(0x1) << DEVEPTIFR_TXINIS_Pos) /**< (DEVEPTIFR) Transmitted IN Data Interrupt Set Mask */ +#define DEVEPTIFR_RXOUTIS_Pos 1 /**< (DEVEPTIFR) Received OUT Data Interrupt Set Position */ +#define DEVEPTIFR_RXOUTIS (_U_(0x1) << DEVEPTIFR_RXOUTIS_Pos) /**< (DEVEPTIFR) Received OUT Data Interrupt Set Mask */ +#define DEVEPTIFR_OVERFIS_Pos 5 /**< (DEVEPTIFR) Overflow Interrupt Set Position */ +#define DEVEPTIFR_OVERFIS (_U_(0x1) << DEVEPTIFR_OVERFIS_Pos) /**< (DEVEPTIFR) Overflow Interrupt Set Mask */ +#define DEVEPTIFR_SHORTPACKETS_Pos 7 /**< (DEVEPTIFR) Short Packet Interrupt Set Position */ +#define DEVEPTIFR_SHORTPACKETS (_U_(0x1) << DEVEPTIFR_SHORTPACKETS_Pos) /**< (DEVEPTIFR) Short Packet Interrupt Set Mask */ +#define DEVEPTIFR_NBUSYBKS_Pos 12 /**< (DEVEPTIFR) Number of Busy Banks Interrupt Set Position */ +#define DEVEPTIFR_NBUSYBKS (_U_(0x1) << DEVEPTIFR_NBUSYBKS_Pos) /**< (DEVEPTIFR) Number of Busy Banks Interrupt Set Mask */ +#define DEVEPTIFR_Msk _U_(0x10A3) /**< (DEVEPTIFR) Register Mask */ + +/* CTRL mode */ +#define DEVEPTIFR_CTRL_RXSTPIS_Pos 2 /**< (DEVEPTIFR) Received SETUP Interrupt Set Position */ +#define DEVEPTIFR_CTRL_RXSTPIS (_U_(0x1) << DEVEPTIFR_CTRL_RXSTPIS_Pos) /**< (DEVEPTIFR) Received SETUP Interrupt Set Mask */ +#define DEVEPTIFR_CTRL_NAKOUTIS_Pos 3 /**< (DEVEPTIFR) NAKed OUT Interrupt Set Position */ +#define DEVEPTIFR_CTRL_NAKOUTIS (_U_(0x1) << DEVEPTIFR_CTRL_NAKOUTIS_Pos) /**< (DEVEPTIFR) NAKed OUT Interrupt Set Mask */ +#define DEVEPTIFR_CTRL_NAKINIS_Pos 4 /**< (DEVEPTIFR) NAKed IN Interrupt Set Position */ +#define DEVEPTIFR_CTRL_NAKINIS (_U_(0x1) << DEVEPTIFR_CTRL_NAKINIS_Pos) /**< (DEVEPTIFR) NAKed IN Interrupt Set Mask */ +#define DEVEPTIFR_CTRL_STALLEDIS_Pos 6 /**< (DEVEPTIFR) STALLed Interrupt Set Position */ +#define DEVEPTIFR_CTRL_STALLEDIS (_U_(0x1) << DEVEPTIFR_CTRL_STALLEDIS_Pos) /**< (DEVEPTIFR) STALLed Interrupt Set Mask */ +#define DEVEPTIFR_CTRL_Msk _U_(0x5C) /**< (DEVEPTIFR_CTRL) Register Mask */ + +/* ISO mode */ +#define DEVEPTIFR_ISO_UNDERFIS_Pos 2 /**< (DEVEPTIFR) Underflow Interrupt Set Position */ +#define DEVEPTIFR_ISO_UNDERFIS (_U_(0x1) << DEVEPTIFR_ISO_UNDERFIS_Pos) /**< (DEVEPTIFR) Underflow Interrupt Set Mask */ +#define DEVEPTIFR_ISO_HBISOINERRIS_Pos 3 /**< (DEVEPTIFR) High Bandwidth Isochronous IN Underflow Error Interrupt Set Position */ +#define DEVEPTIFR_ISO_HBISOINERRIS (_U_(0x1) << DEVEPTIFR_ISO_HBISOINERRIS_Pos) /**< (DEVEPTIFR) High Bandwidth Isochronous IN Underflow Error Interrupt Set Mask */ +#define DEVEPTIFR_ISO_HBISOFLUSHIS_Pos 4 /**< (DEVEPTIFR) High Bandwidth Isochronous IN Flush Interrupt Set Position */ +#define DEVEPTIFR_ISO_HBISOFLUSHIS (_U_(0x1) << DEVEPTIFR_ISO_HBISOFLUSHIS_Pos) /**< (DEVEPTIFR) High Bandwidth Isochronous IN Flush Interrupt Set Mask */ +#define DEVEPTIFR_ISO_CRCERRIS_Pos 6 /**< (DEVEPTIFR) CRC Error Interrupt Set Position */ +#define DEVEPTIFR_ISO_CRCERRIS (_U_(0x1) << DEVEPTIFR_ISO_CRCERRIS_Pos) /**< (DEVEPTIFR) CRC Error Interrupt Set Mask */ +#define DEVEPTIFR_ISO_Msk _U_(0x5C) /**< (DEVEPTIFR_ISO) Register Mask */ + +/* BLK mode */ +#define DEVEPTIFR_BLK_RXSTPIS_Pos 2 /**< (DEVEPTIFR) Received SETUP Interrupt Set Position */ +#define DEVEPTIFR_BLK_RXSTPIS (_U_(0x1) << DEVEPTIFR_BLK_RXSTPIS_Pos) /**< (DEVEPTIFR) Received SETUP Interrupt Set Mask */ +#define DEVEPTIFR_BLK_NAKOUTIS_Pos 3 /**< (DEVEPTIFR) NAKed OUT Interrupt Set Position */ +#define DEVEPTIFR_BLK_NAKOUTIS (_U_(0x1) << DEVEPTIFR_BLK_NAKOUTIS_Pos) /**< (DEVEPTIFR) NAKed OUT Interrupt Set Mask */ +#define DEVEPTIFR_BLK_NAKINIS_Pos 4 /**< (DEVEPTIFR) NAKed IN Interrupt Set Position */ +#define DEVEPTIFR_BLK_NAKINIS (_U_(0x1) << DEVEPTIFR_BLK_NAKINIS_Pos) /**< (DEVEPTIFR) NAKed IN Interrupt Set Mask */ +#define DEVEPTIFR_BLK_STALLEDIS_Pos 6 /**< (DEVEPTIFR) STALLed Interrupt Set Position */ +#define DEVEPTIFR_BLK_STALLEDIS (_U_(0x1) << DEVEPTIFR_BLK_STALLEDIS_Pos) /**< (DEVEPTIFR) STALLed Interrupt Set Mask */ +#define DEVEPTIFR_BLK_Msk _U_(0x5C) /**< (DEVEPTIFR_BLK) Register Mask */ + +/* INTRPT mode */ +#define DEVEPTIFR_INTRPT_RXSTPIS_Pos 2 /**< (DEVEPTIFR) Received SETUP Interrupt Set Position */ +#define DEVEPTIFR_INTRPT_RXSTPIS (_U_(0x1) << DEVEPTIFR_INTRPT_RXSTPIS_Pos) /**< (DEVEPTIFR) Received SETUP Interrupt Set Mask */ +#define DEVEPTIFR_INTRPT_NAKOUTIS_Pos 3 /**< (DEVEPTIFR) NAKed OUT Interrupt Set Position */ +#define DEVEPTIFR_INTRPT_NAKOUTIS (_U_(0x1) << DEVEPTIFR_INTRPT_NAKOUTIS_Pos) /**< (DEVEPTIFR) NAKed OUT Interrupt Set Mask */ +#define DEVEPTIFR_INTRPT_NAKINIS_Pos 4 /**< (DEVEPTIFR) NAKed IN Interrupt Set Position */ +#define DEVEPTIFR_INTRPT_NAKINIS (_U_(0x1) << DEVEPTIFR_INTRPT_NAKINIS_Pos) /**< (DEVEPTIFR) NAKed IN Interrupt Set Mask */ +#define DEVEPTIFR_INTRPT_STALLEDIS_Pos 6 /**< (DEVEPTIFR) STALLed Interrupt Set Position */ +#define DEVEPTIFR_INTRPT_STALLEDIS (_U_(0x1) << DEVEPTIFR_INTRPT_STALLEDIS_Pos) /**< (DEVEPTIFR) STALLed Interrupt Set Mask */ +#define DEVEPTIFR_INTRPT_Msk _U_(0x5C) /**< (DEVEPTIFR_INTRPT) Register Mask */ + + +/* -------- DEVEPTIMR : (USBHS Offset: 0x1c0) (R/ 32) Device Endpoint Interrupt Mask Register -------- */ + +#define DEVEPTIMR_OFFSET (0x1C0) /**< (DEVEPTIMR) Device Endpoint Interrupt Mask Register Offset */ + +#define DEVEPTIMR_TXINE_Pos 0 /**< (DEVEPTIMR) Transmitted IN Data Interrupt Position */ +#define DEVEPTIMR_TXINE (_U_(0x1) << DEVEPTIMR_TXINE_Pos) /**< (DEVEPTIMR) Transmitted IN Data Interrupt Mask */ +#define DEVEPTIMR_RXOUTE_Pos 1 /**< (DEVEPTIMR) Received OUT Data Interrupt Position */ +#define DEVEPTIMR_RXOUTE (_U_(0x1) << DEVEPTIMR_RXOUTE_Pos) /**< (DEVEPTIMR) Received OUT Data Interrupt Mask */ +#define DEVEPTIMR_OVERFE_Pos 5 /**< (DEVEPTIMR) Overflow Interrupt Position */ +#define DEVEPTIMR_OVERFE (_U_(0x1) << DEVEPTIMR_OVERFE_Pos) /**< (DEVEPTIMR) Overflow Interrupt Mask */ +#define DEVEPTIMR_SHORTPACKETE_Pos 7 /**< (DEVEPTIMR) Short Packet Interrupt Position */ +#define DEVEPTIMR_SHORTPACKETE (_U_(0x1) << DEVEPTIMR_SHORTPACKETE_Pos) /**< (DEVEPTIMR) Short Packet Interrupt Mask */ +#define DEVEPTIMR_NBUSYBKE_Pos 12 /**< (DEVEPTIMR) Number of Busy Banks Interrupt Position */ +#define DEVEPTIMR_NBUSYBKE (_U_(0x1) << DEVEPTIMR_NBUSYBKE_Pos) /**< (DEVEPTIMR) Number of Busy Banks Interrupt Mask */ +#define DEVEPTIMR_KILLBK_Pos 13 /**< (DEVEPTIMR) Kill IN Bank Position */ +#define DEVEPTIMR_KILLBK (_U_(0x1) << DEVEPTIMR_KILLBK_Pos) /**< (DEVEPTIMR) Kill IN Bank Mask */ +#define DEVEPTIMR_FIFOCON_Pos 14 /**< (DEVEPTIMR) FIFO Control Position */ +#define DEVEPTIMR_FIFOCON (_U_(0x1) << DEVEPTIMR_FIFOCON_Pos) /**< (DEVEPTIMR) FIFO Control Mask */ +#define DEVEPTIMR_EPDISHDMA_Pos 16 /**< (DEVEPTIMR) Endpoint Interrupts Disable HDMA Request Position */ +#define DEVEPTIMR_EPDISHDMA (_U_(0x1) << DEVEPTIMR_EPDISHDMA_Pos) /**< (DEVEPTIMR) Endpoint Interrupts Disable HDMA Request Mask */ +#define DEVEPTIMR_RSTDT_Pos 18 /**< (DEVEPTIMR) Reset Data Toggle Position */ +#define DEVEPTIMR_RSTDT (_U_(0x1) << DEVEPTIMR_RSTDT_Pos) /**< (DEVEPTIMR) Reset Data Toggle Mask */ +#define DEVEPTIMR_Msk _U_(0x570A3) /**< (DEVEPTIMR) Register Mask */ + +/* CTRL mode */ +#define DEVEPTIMR_CTRL_RXSTPE_Pos 2 /**< (DEVEPTIMR) Received SETUP Interrupt Position */ +#define DEVEPTIMR_CTRL_RXSTPE (_U_(0x1) << DEVEPTIMR_CTRL_RXSTPE_Pos) /**< (DEVEPTIMR) Received SETUP Interrupt Mask */ +#define DEVEPTIMR_CTRL_NAKOUTE_Pos 3 /**< (DEVEPTIMR) NAKed OUT Interrupt Position */ +#define DEVEPTIMR_CTRL_NAKOUTE (_U_(0x1) << DEVEPTIMR_CTRL_NAKOUTE_Pos) /**< (DEVEPTIMR) NAKed OUT Interrupt Mask */ +#define DEVEPTIMR_CTRL_NAKINE_Pos 4 /**< (DEVEPTIMR) NAKed IN Interrupt Position */ +#define DEVEPTIMR_CTRL_NAKINE (_U_(0x1) << DEVEPTIMR_CTRL_NAKINE_Pos) /**< (DEVEPTIMR) NAKed IN Interrupt Mask */ +#define DEVEPTIMR_CTRL_STALLEDE_Pos 6 /**< (DEVEPTIMR) STALLed Interrupt Position */ +#define DEVEPTIMR_CTRL_STALLEDE (_U_(0x1) << DEVEPTIMR_CTRL_STALLEDE_Pos) /**< (DEVEPTIMR) STALLed Interrupt Mask */ +#define DEVEPTIMR_CTRL_NYETDIS_Pos 17 /**< (DEVEPTIMR) NYET Token Disable Position */ +#define DEVEPTIMR_CTRL_NYETDIS (_U_(0x1) << DEVEPTIMR_CTRL_NYETDIS_Pos) /**< (DEVEPTIMR) NYET Token Disable Mask */ +#define DEVEPTIMR_CTRL_STALLRQ_Pos 19 /**< (DEVEPTIMR) STALL Request Position */ +#define DEVEPTIMR_CTRL_STALLRQ (_U_(0x1) << DEVEPTIMR_CTRL_STALLRQ_Pos) /**< (DEVEPTIMR) STALL Request Mask */ +#define DEVEPTIMR_CTRL_Msk _U_(0xA005C) /**< (DEVEPTIMR_CTRL) Register Mask */ + +/* ISO mode */ +#define DEVEPTIMR_ISO_UNDERFE_Pos 2 /**< (DEVEPTIMR) Underflow Interrupt Position */ +#define DEVEPTIMR_ISO_UNDERFE (_U_(0x1) << DEVEPTIMR_ISO_UNDERFE_Pos) /**< (DEVEPTIMR) Underflow Interrupt Mask */ +#define DEVEPTIMR_ISO_HBISOINERRE_Pos 3 /**< (DEVEPTIMR) High Bandwidth Isochronous IN Underflow Error Interrupt Position */ +#define DEVEPTIMR_ISO_HBISOINERRE (_U_(0x1) << DEVEPTIMR_ISO_HBISOINERRE_Pos) /**< (DEVEPTIMR) High Bandwidth Isochronous IN Underflow Error Interrupt Mask */ +#define DEVEPTIMR_ISO_HBISOFLUSHE_Pos 4 /**< (DEVEPTIMR) High Bandwidth Isochronous IN Flush Interrupt Position */ +#define DEVEPTIMR_ISO_HBISOFLUSHE (_U_(0x1) << DEVEPTIMR_ISO_HBISOFLUSHE_Pos) /**< (DEVEPTIMR) High Bandwidth Isochronous IN Flush Interrupt Mask */ +#define DEVEPTIMR_ISO_CRCERRE_Pos 6 /**< (DEVEPTIMR) CRC Error Interrupt Position */ +#define DEVEPTIMR_ISO_CRCERRE (_U_(0x1) << DEVEPTIMR_ISO_CRCERRE_Pos) /**< (DEVEPTIMR) CRC Error Interrupt Mask */ +#define DEVEPTIMR_ISO_MDATAE_Pos 8 /**< (DEVEPTIMR) MData Interrupt Position */ +#define DEVEPTIMR_ISO_MDATAE (_U_(0x1) << DEVEPTIMR_ISO_MDATAE_Pos) /**< (DEVEPTIMR) MData Interrupt Mask */ +#define DEVEPTIMR_ISO_DATAXE_Pos 9 /**< (DEVEPTIMR) DataX Interrupt Position */ +#define DEVEPTIMR_ISO_DATAXE (_U_(0x1) << DEVEPTIMR_ISO_DATAXE_Pos) /**< (DEVEPTIMR) DataX Interrupt Mask */ +#define DEVEPTIMR_ISO_ERRORTRANSE_Pos 10 /**< (DEVEPTIMR) Transaction Error Interrupt Position */ +#define DEVEPTIMR_ISO_ERRORTRANSE (_U_(0x1) << DEVEPTIMR_ISO_ERRORTRANSE_Pos) /**< (DEVEPTIMR) Transaction Error Interrupt Mask */ +#define DEVEPTIMR_ISO_Msk _U_(0x75C) /**< (DEVEPTIMR_ISO) Register Mask */ + +/* BLK mode */ +#define DEVEPTIMR_BLK_RXSTPE_Pos 2 /**< (DEVEPTIMR) Received SETUP Interrupt Position */ +#define DEVEPTIMR_BLK_RXSTPE (_U_(0x1) << DEVEPTIMR_BLK_RXSTPE_Pos) /**< (DEVEPTIMR) Received SETUP Interrupt Mask */ +#define DEVEPTIMR_BLK_NAKOUTE_Pos 3 /**< (DEVEPTIMR) NAKed OUT Interrupt Position */ +#define DEVEPTIMR_BLK_NAKOUTE (_U_(0x1) << DEVEPTIMR_BLK_NAKOUTE_Pos) /**< (DEVEPTIMR) NAKed OUT Interrupt Mask */ +#define DEVEPTIMR_BLK_NAKINE_Pos 4 /**< (DEVEPTIMR) NAKed IN Interrupt Position */ +#define DEVEPTIMR_BLK_NAKINE (_U_(0x1) << DEVEPTIMR_BLK_NAKINE_Pos) /**< (DEVEPTIMR) NAKed IN Interrupt Mask */ +#define DEVEPTIMR_BLK_STALLEDE_Pos 6 /**< (DEVEPTIMR) STALLed Interrupt Position */ +#define DEVEPTIMR_BLK_STALLEDE (_U_(0x1) << DEVEPTIMR_BLK_STALLEDE_Pos) /**< (DEVEPTIMR) STALLed Interrupt Mask */ +#define DEVEPTIMR_BLK_NYETDIS_Pos 17 /**< (DEVEPTIMR) NYET Token Disable Position */ +#define DEVEPTIMR_BLK_NYETDIS (_U_(0x1) << DEVEPTIMR_BLK_NYETDIS_Pos) /**< (DEVEPTIMR) NYET Token Disable Mask */ +#define DEVEPTIMR_BLK_STALLRQ_Pos 19 /**< (DEVEPTIMR) STALL Request Position */ +#define DEVEPTIMR_BLK_STALLRQ (_U_(0x1) << DEVEPTIMR_BLK_STALLRQ_Pos) /**< (DEVEPTIMR) STALL Request Mask */ +#define DEVEPTIMR_BLK_Msk _U_(0xA005C) /**< (DEVEPTIMR_BLK) Register Mask */ + +/* INTRPT mode */ +#define DEVEPTIMR_INTRPT_RXSTPE_Pos 2 /**< (DEVEPTIMR) Received SETUP Interrupt Position */ +#define DEVEPTIMR_INTRPT_RXSTPE (_U_(0x1) << DEVEPTIMR_INTRPT_RXSTPE_Pos) /**< (DEVEPTIMR) Received SETUP Interrupt Mask */ +#define DEVEPTIMR_INTRPT_NAKOUTE_Pos 3 /**< (DEVEPTIMR) NAKed OUT Interrupt Position */ +#define DEVEPTIMR_INTRPT_NAKOUTE (_U_(0x1) << DEVEPTIMR_INTRPT_NAKOUTE_Pos) /**< (DEVEPTIMR) NAKed OUT Interrupt Mask */ +#define DEVEPTIMR_INTRPT_NAKINE_Pos 4 /**< (DEVEPTIMR) NAKed IN Interrupt Position */ +#define DEVEPTIMR_INTRPT_NAKINE (_U_(0x1) << DEVEPTIMR_INTRPT_NAKINE_Pos) /**< (DEVEPTIMR) NAKed IN Interrupt Mask */ +#define DEVEPTIMR_INTRPT_STALLEDE_Pos 6 /**< (DEVEPTIMR) STALLed Interrupt Position */ +#define DEVEPTIMR_INTRPT_STALLEDE (_U_(0x1) << DEVEPTIMR_INTRPT_STALLEDE_Pos) /**< (DEVEPTIMR) STALLed Interrupt Mask */ +#define DEVEPTIMR_INTRPT_NYETDIS_Pos 17 /**< (DEVEPTIMR) NYET Token Disable Position */ +#define DEVEPTIMR_INTRPT_NYETDIS (_U_(0x1) << DEVEPTIMR_INTRPT_NYETDIS_Pos) /**< (DEVEPTIMR) NYET Token Disable Mask */ +#define DEVEPTIMR_INTRPT_STALLRQ_Pos 19 /**< (DEVEPTIMR) STALL Request Position */ +#define DEVEPTIMR_INTRPT_STALLRQ (_U_(0x1) << DEVEPTIMR_INTRPT_STALLRQ_Pos) /**< (DEVEPTIMR) STALL Request Mask */ +#define DEVEPTIMR_INTRPT_Msk _U_(0xA005C) /**< (DEVEPTIMR_INTRPT) Register Mask */ + + +/* -------- DEVEPTIER : (USBHS Offset: 0x1f0) (/W 32) Device Endpoint Interrupt Enable Register -------- */ + +#define DEVEPTIER_OFFSET (0x1F0) /**< (DEVEPTIER) Device Endpoint Interrupt Enable Register Offset */ + +#define DEVEPTIER_TXINES_Pos 0 /**< (DEVEPTIER) Transmitted IN Data Interrupt Enable Position */ +#define DEVEPTIER_TXINES (_U_(0x1) << DEVEPTIER_TXINES_Pos) /**< (DEVEPTIER) Transmitted IN Data Interrupt Enable Mask */ +#define DEVEPTIER_RXOUTES_Pos 1 /**< (DEVEPTIER) Received OUT Data Interrupt Enable Position */ +#define DEVEPTIER_RXOUTES (_U_(0x1) << DEVEPTIER_RXOUTES_Pos) /**< (DEVEPTIER) Received OUT Data Interrupt Enable Mask */ +#define DEVEPTIER_OVERFES_Pos 5 /**< (DEVEPTIER) Overflow Interrupt Enable Position */ +#define DEVEPTIER_OVERFES (_U_(0x1) << DEVEPTIER_OVERFES_Pos) /**< (DEVEPTIER) Overflow Interrupt Enable Mask */ +#define DEVEPTIER_SHORTPACKETES_Pos 7 /**< (DEVEPTIER) Short Packet Interrupt Enable Position */ +#define DEVEPTIER_SHORTPACKETES (_U_(0x1) << DEVEPTIER_SHORTPACKETES_Pos) /**< (DEVEPTIER) Short Packet Interrupt Enable Mask */ +#define DEVEPTIER_NBUSYBKES_Pos 12 /**< (DEVEPTIER) Number of Busy Banks Interrupt Enable Position */ +#define DEVEPTIER_NBUSYBKES (_U_(0x1) << DEVEPTIER_NBUSYBKES_Pos) /**< (DEVEPTIER) Number of Busy Banks Interrupt Enable Mask */ +#define DEVEPTIER_KILLBKS_Pos 13 /**< (DEVEPTIER) Kill IN Bank Position */ +#define DEVEPTIER_KILLBKS (_U_(0x1) << DEVEPTIER_KILLBKS_Pos) /**< (DEVEPTIER) Kill IN Bank Mask */ +#define DEVEPTIER_FIFOCONS_Pos 14 /**< (DEVEPTIER) FIFO Control Position */ +#define DEVEPTIER_FIFOCONS (_U_(0x1) << DEVEPTIER_FIFOCONS_Pos) /**< (DEVEPTIER) FIFO Control Mask */ +#define DEVEPTIER_EPDISHDMAS_Pos 16 /**< (DEVEPTIER) Endpoint Interrupts Disable HDMA Request Enable Position */ +#define DEVEPTIER_EPDISHDMAS (_U_(0x1) << DEVEPTIER_EPDISHDMAS_Pos) /**< (DEVEPTIER) Endpoint Interrupts Disable HDMA Request Enable Mask */ +#define DEVEPTIER_RSTDTS_Pos 18 /**< (DEVEPTIER) Reset Data Toggle Enable Position */ +#define DEVEPTIER_RSTDTS (_U_(0x1) << DEVEPTIER_RSTDTS_Pos) /**< (DEVEPTIER) Reset Data Toggle Enable Mask */ +#define DEVEPTIER_Msk _U_(0x570A3) /**< (DEVEPTIER) Register Mask */ + +/* CTRL mode */ +#define DEVEPTIER_CTRL_RXSTPES_Pos 2 /**< (DEVEPTIER) Received SETUP Interrupt Enable Position */ +#define DEVEPTIER_CTRL_RXSTPES (_U_(0x1) << DEVEPTIER_CTRL_RXSTPES_Pos) /**< (DEVEPTIER) Received SETUP Interrupt Enable Mask */ +#define DEVEPTIER_CTRL_NAKOUTES_Pos 3 /**< (DEVEPTIER) NAKed OUT Interrupt Enable Position */ +#define DEVEPTIER_CTRL_NAKOUTES (_U_(0x1) << DEVEPTIER_CTRL_NAKOUTES_Pos) /**< (DEVEPTIER) NAKed OUT Interrupt Enable Mask */ +#define DEVEPTIER_CTRL_NAKINES_Pos 4 /**< (DEVEPTIER) NAKed IN Interrupt Enable Position */ +#define DEVEPTIER_CTRL_NAKINES (_U_(0x1) << DEVEPTIER_CTRL_NAKINES_Pos) /**< (DEVEPTIER) NAKed IN Interrupt Enable Mask */ +#define DEVEPTIER_CTRL_STALLEDES_Pos 6 /**< (DEVEPTIER) STALLed Interrupt Enable Position */ +#define DEVEPTIER_CTRL_STALLEDES (_U_(0x1) << DEVEPTIER_CTRL_STALLEDES_Pos) /**< (DEVEPTIER) STALLed Interrupt Enable Mask */ +#define DEVEPTIER_CTRL_NYETDISS_Pos 17 /**< (DEVEPTIER) NYET Token Disable Enable Position */ +#define DEVEPTIER_CTRL_NYETDISS (_U_(0x1) << DEVEPTIER_CTRL_NYETDISS_Pos) /**< (DEVEPTIER) NYET Token Disable Enable Mask */ +#define DEVEPTIER_CTRL_STALLRQS_Pos 19 /**< (DEVEPTIER) STALL Request Enable Position */ +#define DEVEPTIER_CTRL_STALLRQS (_U_(0x1) << DEVEPTIER_CTRL_STALLRQS_Pos) /**< (DEVEPTIER) STALL Request Enable Mask */ +#define DEVEPTIER_CTRL_Msk _U_(0xA005C) /**< (DEVEPTIER_CTRL) Register Mask */ + +/* ISO mode */ +#define DEVEPTIER_ISO_UNDERFES_Pos 2 /**< (DEVEPTIER) Underflow Interrupt Enable Position */ +#define DEVEPTIER_ISO_UNDERFES (_U_(0x1) << DEVEPTIER_ISO_UNDERFES_Pos) /**< (DEVEPTIER) Underflow Interrupt Enable Mask */ +#define DEVEPTIER_ISO_HBISOINERRES_Pos 3 /**< (DEVEPTIER) High Bandwidth Isochronous IN Underflow Error Interrupt Enable Position */ +#define DEVEPTIER_ISO_HBISOINERRES (_U_(0x1) << DEVEPTIER_ISO_HBISOINERRES_Pos) /**< (DEVEPTIER) High Bandwidth Isochronous IN Underflow Error Interrupt Enable Mask */ +#define DEVEPTIER_ISO_HBISOFLUSHES_Pos 4 /**< (DEVEPTIER) High Bandwidth Isochronous IN Flush Interrupt Enable Position */ +#define DEVEPTIER_ISO_HBISOFLUSHES (_U_(0x1) << DEVEPTIER_ISO_HBISOFLUSHES_Pos) /**< (DEVEPTIER) High Bandwidth Isochronous IN Flush Interrupt Enable Mask */ +#define DEVEPTIER_ISO_CRCERRES_Pos 6 /**< (DEVEPTIER) CRC Error Interrupt Enable Position */ +#define DEVEPTIER_ISO_CRCERRES (_U_(0x1) << DEVEPTIER_ISO_CRCERRES_Pos) /**< (DEVEPTIER) CRC Error Interrupt Enable Mask */ +#define DEVEPTIER_ISO_MDATAES_Pos 8 /**< (DEVEPTIER) MData Interrupt Enable Position */ +#define DEVEPTIER_ISO_MDATAES (_U_(0x1) << DEVEPTIER_ISO_MDATAES_Pos) /**< (DEVEPTIER) MData Interrupt Enable Mask */ +#define DEVEPTIER_ISO_DATAXES_Pos 9 /**< (DEVEPTIER) DataX Interrupt Enable Position */ +#define DEVEPTIER_ISO_DATAXES (_U_(0x1) << DEVEPTIER_ISO_DATAXES_Pos) /**< (DEVEPTIER) DataX Interrupt Enable Mask */ +#define DEVEPTIER_ISO_ERRORTRANSES_Pos 10 /**< (DEVEPTIER) Transaction Error Interrupt Enable Position */ +#define DEVEPTIER_ISO_ERRORTRANSES (_U_(0x1) << DEVEPTIER_ISO_ERRORTRANSES_Pos) /**< (DEVEPTIER) Transaction Error Interrupt Enable Mask */ +#define DEVEPTIER_ISO_Msk _U_(0x75C) /**< (DEVEPTIER_ISO) Register Mask */ + +/* BLK mode */ +#define DEVEPTIER_BLK_RXSTPES_Pos 2 /**< (DEVEPTIER) Received SETUP Interrupt Enable Position */ +#define DEVEPTIER_BLK_RXSTPES (_U_(0x1) << DEVEPTIER_BLK_RXSTPES_Pos) /**< (DEVEPTIER) Received SETUP Interrupt Enable Mask */ +#define DEVEPTIER_BLK_NAKOUTES_Pos 3 /**< (DEVEPTIER) NAKed OUT Interrupt Enable Position */ +#define DEVEPTIER_BLK_NAKOUTES (_U_(0x1) << DEVEPTIER_BLK_NAKOUTES_Pos) /**< (DEVEPTIER) NAKed OUT Interrupt Enable Mask */ +#define DEVEPTIER_BLK_NAKINES_Pos 4 /**< (DEVEPTIER) NAKed IN Interrupt Enable Position */ +#define DEVEPTIER_BLK_NAKINES (_U_(0x1) << DEVEPTIER_BLK_NAKINES_Pos) /**< (DEVEPTIER) NAKed IN Interrupt Enable Mask */ +#define DEVEPTIER_BLK_STALLEDES_Pos 6 /**< (DEVEPTIER) STALLed Interrupt Enable Position */ +#define DEVEPTIER_BLK_STALLEDES (_U_(0x1) << DEVEPTIER_BLK_STALLEDES_Pos) /**< (DEVEPTIER) STALLed Interrupt Enable Mask */ +#define DEVEPTIER_BLK_NYETDISS_Pos 17 /**< (DEVEPTIER) NYET Token Disable Enable Position */ +#define DEVEPTIER_BLK_NYETDISS (_U_(0x1) << DEVEPTIER_BLK_NYETDISS_Pos) /**< (DEVEPTIER) NYET Token Disable Enable Mask */ +#define DEVEPTIER_BLK_STALLRQS_Pos 19 /**< (DEVEPTIER) STALL Request Enable Position */ +#define DEVEPTIER_BLK_STALLRQS (_U_(0x1) << DEVEPTIER_BLK_STALLRQS_Pos) /**< (DEVEPTIER) STALL Request Enable Mask */ +#define DEVEPTIER_BLK_Msk _U_(0xA005C) /**< (DEVEPTIER_BLK) Register Mask */ + +/* INTRPT mode */ +#define DEVEPTIER_INTRPT_RXSTPES_Pos 2 /**< (DEVEPTIER) Received SETUP Interrupt Enable Position */ +#define DEVEPTIER_INTRPT_RXSTPES (_U_(0x1) << DEVEPTIER_INTRPT_RXSTPES_Pos) /**< (DEVEPTIER) Received SETUP Interrupt Enable Mask */ +#define DEVEPTIER_INTRPT_NAKOUTES_Pos 3 /**< (DEVEPTIER) NAKed OUT Interrupt Enable Position */ +#define DEVEPTIER_INTRPT_NAKOUTES (_U_(0x1) << DEVEPTIER_INTRPT_NAKOUTES_Pos) /**< (DEVEPTIER) NAKed OUT Interrupt Enable Mask */ +#define DEVEPTIER_INTRPT_NAKINES_Pos 4 /**< (DEVEPTIER) NAKed IN Interrupt Enable Position */ +#define DEVEPTIER_INTRPT_NAKINES (_U_(0x1) << DEVEPTIER_INTRPT_NAKINES_Pos) /**< (DEVEPTIER) NAKed IN Interrupt Enable Mask */ +#define DEVEPTIER_INTRPT_STALLEDES_Pos 6 /**< (DEVEPTIER) STALLed Interrupt Enable Position */ +#define DEVEPTIER_INTRPT_STALLEDES (_U_(0x1) << DEVEPTIER_INTRPT_STALLEDES_Pos) /**< (DEVEPTIER) STALLed Interrupt Enable Mask */ +#define DEVEPTIER_INTRPT_NYETDISS_Pos 17 /**< (DEVEPTIER) NYET Token Disable Enable Position */ +#define DEVEPTIER_INTRPT_NYETDISS (_U_(0x1) << DEVEPTIER_INTRPT_NYETDISS_Pos) /**< (DEVEPTIER) NYET Token Disable Enable Mask */ +#define DEVEPTIER_INTRPT_STALLRQS_Pos 19 /**< (DEVEPTIER) STALL Request Enable Position */ +#define DEVEPTIER_INTRPT_STALLRQS (_U_(0x1) << DEVEPTIER_INTRPT_STALLRQS_Pos) /**< (DEVEPTIER) STALL Request Enable Mask */ +#define DEVEPTIER_INTRPT_Msk _U_(0xA005C) /**< (DEVEPTIER_INTRPT) Register Mask */ + + +/* -------- DEVEPTIDR : (USBHS Offset: 0x220) (/W 32) Device Endpoint Interrupt Disable Register -------- */ + +#define DEVEPTIDR_OFFSET (0x220) /**< (DEVEPTIDR) Device Endpoint Interrupt Disable Register Offset */ + +#define DEVEPTIDR_TXINEC_Pos 0 /**< (DEVEPTIDR) Transmitted IN Interrupt Clear Position */ +#define DEVEPTIDR_TXINEC (_U_(0x1) << DEVEPTIDR_TXINEC_Pos) /**< (DEVEPTIDR) Transmitted IN Interrupt Clear Mask */ +#define DEVEPTIDR_RXOUTEC_Pos 1 /**< (DEVEPTIDR) Received OUT Data Interrupt Clear Position */ +#define DEVEPTIDR_RXOUTEC (_U_(0x1) << DEVEPTIDR_RXOUTEC_Pos) /**< (DEVEPTIDR) Received OUT Data Interrupt Clear Mask */ +#define DEVEPTIDR_OVERFEC_Pos 5 /**< (DEVEPTIDR) Overflow Interrupt Clear Position */ +#define DEVEPTIDR_OVERFEC (_U_(0x1) << DEVEPTIDR_OVERFEC_Pos) /**< (DEVEPTIDR) Overflow Interrupt Clear Mask */ +#define DEVEPTIDR_SHORTPACKETEC_Pos 7 /**< (DEVEPTIDR) Shortpacket Interrupt Clear Position */ +#define DEVEPTIDR_SHORTPACKETEC (_U_(0x1) << DEVEPTIDR_SHORTPACKETEC_Pos) /**< (DEVEPTIDR) Shortpacket Interrupt Clear Mask */ +#define DEVEPTIDR_NBUSYBKEC_Pos 12 /**< (DEVEPTIDR) Number of Busy Banks Interrupt Clear Position */ +#define DEVEPTIDR_NBUSYBKEC (_U_(0x1) << DEVEPTIDR_NBUSYBKEC_Pos) /**< (DEVEPTIDR) Number of Busy Banks Interrupt Clear Mask */ +#define DEVEPTIDR_FIFOCONC_Pos 14 /**< (DEVEPTIDR) FIFO Control Clear Position */ +#define DEVEPTIDR_FIFOCONC (_U_(0x1) << DEVEPTIDR_FIFOCONC_Pos) /**< (DEVEPTIDR) FIFO Control Clear Mask */ +#define DEVEPTIDR_EPDISHDMAC_Pos 16 /**< (DEVEPTIDR) Endpoint Interrupts Disable HDMA Request Clear Position */ +#define DEVEPTIDR_EPDISHDMAC (_U_(0x1) << DEVEPTIDR_EPDISHDMAC_Pos) /**< (DEVEPTIDR) Endpoint Interrupts Disable HDMA Request Clear Mask */ +#define DEVEPTIDR_Msk _U_(0x150A3) /**< (DEVEPTIDR) Register Mask */ + +/* CTRL mode */ +#define DEVEPTIDR_CTRL_RXSTPEC_Pos 2 /**< (DEVEPTIDR) Received SETUP Interrupt Clear Position */ +#define DEVEPTIDR_CTRL_RXSTPEC (_U_(0x1) << DEVEPTIDR_CTRL_RXSTPEC_Pos) /**< (DEVEPTIDR) Received SETUP Interrupt Clear Mask */ +#define DEVEPTIDR_CTRL_NAKOUTEC_Pos 3 /**< (DEVEPTIDR) NAKed OUT Interrupt Clear Position */ +#define DEVEPTIDR_CTRL_NAKOUTEC (_U_(0x1) << DEVEPTIDR_CTRL_NAKOUTEC_Pos) /**< (DEVEPTIDR) NAKed OUT Interrupt Clear Mask */ +#define DEVEPTIDR_CTRL_NAKINEC_Pos 4 /**< (DEVEPTIDR) NAKed IN Interrupt Clear Position */ +#define DEVEPTIDR_CTRL_NAKINEC (_U_(0x1) << DEVEPTIDR_CTRL_NAKINEC_Pos) /**< (DEVEPTIDR) NAKed IN Interrupt Clear Mask */ +#define DEVEPTIDR_CTRL_STALLEDEC_Pos 6 /**< (DEVEPTIDR) STALLed Interrupt Clear Position */ +#define DEVEPTIDR_CTRL_STALLEDEC (_U_(0x1) << DEVEPTIDR_CTRL_STALLEDEC_Pos) /**< (DEVEPTIDR) STALLed Interrupt Clear Mask */ +#define DEVEPTIDR_CTRL_NYETDISC_Pos 17 /**< (DEVEPTIDR) NYET Token Disable Clear Position */ +#define DEVEPTIDR_CTRL_NYETDISC (_U_(0x1) << DEVEPTIDR_CTRL_NYETDISC_Pos) /**< (DEVEPTIDR) NYET Token Disable Clear Mask */ +#define DEVEPTIDR_CTRL_STALLRQC_Pos 19 /**< (DEVEPTIDR) STALL Request Clear Position */ +#define DEVEPTIDR_CTRL_STALLRQC (_U_(0x1) << DEVEPTIDR_CTRL_STALLRQC_Pos) /**< (DEVEPTIDR) STALL Request Clear Mask */ +#define DEVEPTIDR_CTRL_Msk _U_(0xA005C) /**< (DEVEPTIDR_CTRL) Register Mask */ + +/* ISO mode */ +#define DEVEPTIDR_ISO_UNDERFEC_Pos 2 /**< (DEVEPTIDR) Underflow Interrupt Clear Position */ +#define DEVEPTIDR_ISO_UNDERFEC (_U_(0x1) << DEVEPTIDR_ISO_UNDERFEC_Pos) /**< (DEVEPTIDR) Underflow Interrupt Clear Mask */ +#define DEVEPTIDR_ISO_HBISOINERREC_Pos 3 /**< (DEVEPTIDR) High Bandwidth Isochronous IN Underflow Error Interrupt Clear Position */ +#define DEVEPTIDR_ISO_HBISOINERREC (_U_(0x1) << DEVEPTIDR_ISO_HBISOINERREC_Pos) /**< (DEVEPTIDR) High Bandwidth Isochronous IN Underflow Error Interrupt Clear Mask */ +#define DEVEPTIDR_ISO_HBISOFLUSHEC_Pos 4 /**< (DEVEPTIDR) High Bandwidth Isochronous IN Flush Interrupt Clear Position */ +#define DEVEPTIDR_ISO_HBISOFLUSHEC (_U_(0x1) << DEVEPTIDR_ISO_HBISOFLUSHEC_Pos) /**< (DEVEPTIDR) High Bandwidth Isochronous IN Flush Interrupt Clear Mask */ +#define DEVEPTIDR_ISO_MDATAEC_Pos 8 /**< (DEVEPTIDR) MData Interrupt Clear Position */ +#define DEVEPTIDR_ISO_MDATAEC (_U_(0x1) << DEVEPTIDR_ISO_MDATAEC_Pos) /**< (DEVEPTIDR) MData Interrupt Clear Mask */ +#define DEVEPTIDR_ISO_DATAXEC_Pos 9 /**< (DEVEPTIDR) DataX Interrupt Clear Position */ +#define DEVEPTIDR_ISO_DATAXEC (_U_(0x1) << DEVEPTIDR_ISO_DATAXEC_Pos) /**< (DEVEPTIDR) DataX Interrupt Clear Mask */ +#define DEVEPTIDR_ISO_ERRORTRANSEC_Pos 10 /**< (DEVEPTIDR) Transaction Error Interrupt Clear Position */ +#define DEVEPTIDR_ISO_ERRORTRANSEC (_U_(0x1) << DEVEPTIDR_ISO_ERRORTRANSEC_Pos) /**< (DEVEPTIDR) Transaction Error Interrupt Clear Mask */ +#define DEVEPTIDR_ISO_Msk _U_(0x71C) /**< (DEVEPTIDR_ISO) Register Mask */ + +/* BLK mode */ +#define DEVEPTIDR_BLK_RXSTPEC_Pos 2 /**< (DEVEPTIDR) Received SETUP Interrupt Clear Position */ +#define DEVEPTIDR_BLK_RXSTPEC (_U_(0x1) << DEVEPTIDR_BLK_RXSTPEC_Pos) /**< (DEVEPTIDR) Received SETUP Interrupt Clear Mask */ +#define DEVEPTIDR_BLK_NAKOUTEC_Pos 3 /**< (DEVEPTIDR) NAKed OUT Interrupt Clear Position */ +#define DEVEPTIDR_BLK_NAKOUTEC (_U_(0x1) << DEVEPTIDR_BLK_NAKOUTEC_Pos) /**< (DEVEPTIDR) NAKed OUT Interrupt Clear Mask */ +#define DEVEPTIDR_BLK_NAKINEC_Pos 4 /**< (DEVEPTIDR) NAKed IN Interrupt Clear Position */ +#define DEVEPTIDR_BLK_NAKINEC (_U_(0x1) << DEVEPTIDR_BLK_NAKINEC_Pos) /**< (DEVEPTIDR) NAKed IN Interrupt Clear Mask */ +#define DEVEPTIDR_BLK_STALLEDEC_Pos 6 /**< (DEVEPTIDR) STALLed Interrupt Clear Position */ +#define DEVEPTIDR_BLK_STALLEDEC (_U_(0x1) << DEVEPTIDR_BLK_STALLEDEC_Pos) /**< (DEVEPTIDR) STALLed Interrupt Clear Mask */ +#define DEVEPTIDR_BLK_NYETDISC_Pos 17 /**< (DEVEPTIDR) NYET Token Disable Clear Position */ +#define DEVEPTIDR_BLK_NYETDISC (_U_(0x1) << DEVEPTIDR_BLK_NYETDISC_Pos) /**< (DEVEPTIDR) NYET Token Disable Clear Mask */ +#define DEVEPTIDR_BLK_STALLRQC_Pos 19 /**< (DEVEPTIDR) STALL Request Clear Position */ +#define DEVEPTIDR_BLK_STALLRQC (_U_(0x1) << DEVEPTIDR_BLK_STALLRQC_Pos) /**< (DEVEPTIDR) STALL Request Clear Mask */ +#define DEVEPTIDR_BLK_Msk _U_(0xA005C) /**< (DEVEPTIDR_BLK) Register Mask */ + +/* INTRPT mode */ +#define DEVEPTIDR_INTRPT_RXSTPEC_Pos 2 /**< (DEVEPTIDR) Received SETUP Interrupt Clear Position */ +#define DEVEPTIDR_INTRPT_RXSTPEC (_U_(0x1) << DEVEPTIDR_INTRPT_RXSTPEC_Pos) /**< (DEVEPTIDR) Received SETUP Interrupt Clear Mask */ +#define DEVEPTIDR_INTRPT_NAKOUTEC_Pos 3 /**< (DEVEPTIDR) NAKed OUT Interrupt Clear Position */ +#define DEVEPTIDR_INTRPT_NAKOUTEC (_U_(0x1) << DEVEPTIDR_INTRPT_NAKOUTEC_Pos) /**< (DEVEPTIDR) NAKed OUT Interrupt Clear Mask */ +#define DEVEPTIDR_INTRPT_NAKINEC_Pos 4 /**< (DEVEPTIDR) NAKed IN Interrupt Clear Position */ +#define DEVEPTIDR_INTRPT_NAKINEC (_U_(0x1) << DEVEPTIDR_INTRPT_NAKINEC_Pos) /**< (DEVEPTIDR) NAKed IN Interrupt Clear Mask */ +#define DEVEPTIDR_INTRPT_STALLEDEC_Pos 6 /**< (DEVEPTIDR) STALLed Interrupt Clear Position */ +#define DEVEPTIDR_INTRPT_STALLEDEC (_U_(0x1) << DEVEPTIDR_INTRPT_STALLEDEC_Pos) /**< (DEVEPTIDR) STALLed Interrupt Clear Mask */ +#define DEVEPTIDR_INTRPT_NYETDISC_Pos 17 /**< (DEVEPTIDR) NYET Token Disable Clear Position */ +#define DEVEPTIDR_INTRPT_NYETDISC (_U_(0x1) << DEVEPTIDR_INTRPT_NYETDISC_Pos) /**< (DEVEPTIDR) NYET Token Disable Clear Mask */ +#define DEVEPTIDR_INTRPT_STALLRQC_Pos 19 /**< (DEVEPTIDR) STALL Request Clear Position */ +#define DEVEPTIDR_INTRPT_STALLRQC (_U_(0x1) << DEVEPTIDR_INTRPT_STALLRQC_Pos) /**< (DEVEPTIDR) STALL Request Clear Mask */ +#define DEVEPTIDR_INTRPT_Msk _U_(0xA005C) /**< (DEVEPTIDR_INTRPT) Register Mask */ + + +/* -------- HSTCTRL : (USBHS Offset: 0x400) (R/W 32) Host General Control Register -------- */ + +#define HSTCTRL_OFFSET (0x400) /**< (HSTCTRL) Host General Control Register Offset */ + +#define HSTCTRL_SOFE_Pos 8 /**< (HSTCTRL) Start of Frame Generation Enable Position */ +#define HSTCTRL_SOFE (_U_(0x1) << HSTCTRL_SOFE_Pos) /**< (HSTCTRL) Start of Frame Generation Enable Mask */ +#define HSTCTRL_RESET_Pos 9 /**< (HSTCTRL) Send USB Reset Position */ +#define HSTCTRL_RESET (_U_(0x1) << HSTCTRL_RESET_Pos) /**< (HSTCTRL) Send USB Reset Mask */ +#define HSTCTRL_RESUME_Pos 10 /**< (HSTCTRL) Send USB Resume Position */ +#define HSTCTRL_RESUME (_U_(0x1) << HSTCTRL_RESUME_Pos) /**< (HSTCTRL) Send USB Resume Mask */ +#define HSTCTRL_SPDCONF_Pos 12 /**< (HSTCTRL) Mode Configuration Position */ +#define HSTCTRL_SPDCONF (_U_(0x3) << HSTCTRL_SPDCONF_Pos) /**< (HSTCTRL) Mode Configuration Mask */ +#define HSTCTRL_SPDCONF_NORMAL_Val _U_(0x0) /**< (HSTCTRL) The host starts in Full-speed mode and performs a high-speed reset to switch to High-speed mode if the downstream peripheral is high-speed capable. */ +#define HSTCTRL_SPDCONF_LOW_POWER_Val _U_(0x1) /**< (HSTCTRL) For a better consumption, if high speed is not needed. */ +#define HSTCTRL_SPDCONF_HIGH_SPEED_Val _U_(0x2) /**< (HSTCTRL) Forced high speed. */ +#define HSTCTRL_SPDCONF_FORCED_FS_Val _U_(0x3) /**< (HSTCTRL) The host remains in Full-speed mode whatever the peripheral speed capability. */ +#define HSTCTRL_SPDCONF_NORMAL (HSTCTRL_SPDCONF_NORMAL_Val << HSTCTRL_SPDCONF_Pos) /**< (HSTCTRL) The host starts in Full-speed mode and performs a high-speed reset to switch to High-speed mode if the downstream peripheral is high-speed capable. Position */ +#define HSTCTRL_SPDCONF_LOW_POWER (HSTCTRL_SPDCONF_LOW_POWER_Val << HSTCTRL_SPDCONF_Pos) /**< (HSTCTRL) For a better consumption, if high speed is not needed. Position */ +#define HSTCTRL_SPDCONF_HIGH_SPEED (HSTCTRL_SPDCONF_HIGH_SPEED_Val << HSTCTRL_SPDCONF_Pos) /**< (HSTCTRL) Forced high speed. Position */ +#define HSTCTRL_SPDCONF_FORCED_FS (HSTCTRL_SPDCONF_FORCED_FS_Val << HSTCTRL_SPDCONF_Pos) /**< (HSTCTRL) The host remains in Full-speed mode whatever the peripheral speed capability. Position */ +#define HSTCTRL_Msk _U_(0x3700) /**< (HSTCTRL) Register Mask */ + + +/* -------- HSTISR : (USBHS Offset: 0x404) (R/ 32) Host Global Interrupt Status Register -------- */ + +#define HSTISR_OFFSET (0x404) /**< (HSTISR) Host Global Interrupt Status Register Offset */ + +#define HSTISR_DCONNI_Pos 0 /**< (HSTISR) Device Connection Interrupt Position */ +#define HSTISR_DCONNI (_U_(0x1) << HSTISR_DCONNI_Pos) /**< (HSTISR) Device Connection Interrupt Mask */ +#define HSTISR_DDISCI_Pos 1 /**< (HSTISR) Device Disconnection Interrupt Position */ +#define HSTISR_DDISCI (_U_(0x1) << HSTISR_DDISCI_Pos) /**< (HSTISR) Device Disconnection Interrupt Mask */ +#define HSTISR_RSTI_Pos 2 /**< (HSTISR) USB Reset Sent Interrupt Position */ +#define HSTISR_RSTI (_U_(0x1) << HSTISR_RSTI_Pos) /**< (HSTISR) USB Reset Sent Interrupt Mask */ +#define HSTISR_RSMEDI_Pos 3 /**< (HSTISR) Downstream Resume Sent Interrupt Position */ +#define HSTISR_RSMEDI (_U_(0x1) << HSTISR_RSMEDI_Pos) /**< (HSTISR) Downstream Resume Sent Interrupt Mask */ +#define HSTISR_RXRSMI_Pos 4 /**< (HSTISR) Upstream Resume Received Interrupt Position */ +#define HSTISR_RXRSMI (_U_(0x1) << HSTISR_RXRSMI_Pos) /**< (HSTISR) Upstream Resume Received Interrupt Mask */ +#define HSTISR_HSOFI_Pos 5 /**< (HSTISR) Host Start of Frame Interrupt Position */ +#define HSTISR_HSOFI (_U_(0x1) << HSTISR_HSOFI_Pos) /**< (HSTISR) Host Start of Frame Interrupt Mask */ +#define HSTISR_HWUPI_Pos 6 /**< (HSTISR) Host Wake-Up Interrupt Position */ +#define HSTISR_HWUPI (_U_(0x1) << HSTISR_HWUPI_Pos) /**< (HSTISR) Host Wake-Up Interrupt Mask */ +#define HSTISR_PEP_0_Pos 8 /**< (HSTISR) Pipe 0 Interrupt Position */ +#define HSTISR_PEP_0 (_U_(0x1) << HSTISR_PEP_0_Pos) /**< (HSTISR) Pipe 0 Interrupt Mask */ +#define HSTISR_PEP_1_Pos 9 /**< (HSTISR) Pipe 1 Interrupt Position */ +#define HSTISR_PEP_1 (_U_(0x1) << HSTISR_PEP_1_Pos) /**< (HSTISR) Pipe 1 Interrupt Mask */ +#define HSTISR_PEP_2_Pos 10 /**< (HSTISR) Pipe 2 Interrupt Position */ +#define HSTISR_PEP_2 (_U_(0x1) << HSTISR_PEP_2_Pos) /**< (HSTISR) Pipe 2 Interrupt Mask */ +#define HSTISR_PEP_3_Pos 11 /**< (HSTISR) Pipe 3 Interrupt Position */ +#define HSTISR_PEP_3 (_U_(0x1) << HSTISR_PEP_3_Pos) /**< (HSTISR) Pipe 3 Interrupt Mask */ +#define HSTISR_PEP_4_Pos 12 /**< (HSTISR) Pipe 4 Interrupt Position */ +#define HSTISR_PEP_4 (_U_(0x1) << HSTISR_PEP_4_Pos) /**< (HSTISR) Pipe 4 Interrupt Mask */ +#define HSTISR_PEP_5_Pos 13 /**< (HSTISR) Pipe 5 Interrupt Position */ +#define HSTISR_PEP_5 (_U_(0x1) << HSTISR_PEP_5_Pos) /**< (HSTISR) Pipe 5 Interrupt Mask */ +#define HSTISR_PEP_6_Pos 14 /**< (HSTISR) Pipe 6 Interrupt Position */ +#define HSTISR_PEP_6 (_U_(0x1) << HSTISR_PEP_6_Pos) /**< (HSTISR) Pipe 6 Interrupt Mask */ +#define HSTISR_PEP_7_Pos 15 /**< (HSTISR) Pipe 7 Interrupt Position */ +#define HSTISR_PEP_7 (_U_(0x1) << HSTISR_PEP_7_Pos) /**< (HSTISR) Pipe 7 Interrupt Mask */ +#define HSTISR_PEP_8_Pos 16 /**< (HSTISR) Pipe 8 Interrupt Position */ +#define HSTISR_PEP_8 (_U_(0x1) << HSTISR_PEP_8_Pos) /**< (HSTISR) Pipe 8 Interrupt Mask */ +#define HSTISR_PEP_9_Pos 17 /**< (HSTISR) Pipe 9 Interrupt Position */ +#define HSTISR_PEP_9 (_U_(0x1) << HSTISR_PEP_9_Pos) /**< (HSTISR) Pipe 9 Interrupt Mask */ +#define HSTISR_DMA_0_Pos 25 /**< (HSTISR) DMA Channel 0 Interrupt Position */ +#define HSTISR_DMA_0 (_U_(0x1) << HSTISR_DMA_0_Pos) /**< (HSTISR) DMA Channel 0 Interrupt Mask */ +#define HSTISR_DMA_1_Pos 26 /**< (HSTISR) DMA Channel 1 Interrupt Position */ +#define HSTISR_DMA_1 (_U_(0x1) << HSTISR_DMA_1_Pos) /**< (HSTISR) DMA Channel 1 Interrupt Mask */ +#define HSTISR_DMA_2_Pos 27 /**< (HSTISR) DMA Channel 2 Interrupt Position */ +#define HSTISR_DMA_2 (_U_(0x1) << HSTISR_DMA_2_Pos) /**< (HSTISR) DMA Channel 2 Interrupt Mask */ +#define HSTISR_DMA_3_Pos 28 /**< (HSTISR) DMA Channel 3 Interrupt Position */ +#define HSTISR_DMA_3 (_U_(0x1) << HSTISR_DMA_3_Pos) /**< (HSTISR) DMA Channel 3 Interrupt Mask */ +#define HSTISR_DMA_4_Pos 29 /**< (HSTISR) DMA Channel 4 Interrupt Position */ +#define HSTISR_DMA_4 (_U_(0x1) << HSTISR_DMA_4_Pos) /**< (HSTISR) DMA Channel 4 Interrupt Mask */ +#define HSTISR_DMA_5_Pos 30 /**< (HSTISR) DMA Channel 5 Interrupt Position */ +#define HSTISR_DMA_5 (_U_(0x1) << HSTISR_DMA_5_Pos) /**< (HSTISR) DMA Channel 5 Interrupt Mask */ +#define HSTISR_DMA_6_Pos 31 /**< (HSTISR) DMA Channel 6 Interrupt Position */ +#define HSTISR_DMA_6 (_U_(0x1) << HSTISR_DMA_6_Pos) /**< (HSTISR) DMA Channel 6 Interrupt Mask */ +#define HSTISR_Msk _U_(0xFE03FF7F) /**< (HSTISR) Register Mask */ + +#define HSTISR_PEP__Pos 8 /**< (HSTISR Position) Pipe x Interrupt */ +#define HSTISR_PEP_ (_U_(0x3FF) << HSTISR_PEP__Pos) /**< (HSTISR Mask) PEP_ */ +#define HSTISR_DMA__Pos 25 /**< (HSTISR Position) DMA Channel 6 Interrupt */ +#define HSTISR_DMA_ (_U_(0x7F) << HSTISR_DMA__Pos) /**< (HSTISR Mask) DMA_ */ + +/* -------- HSTICR : (USBHS Offset: 0x408) (/W 32) Host Global Interrupt Clear Register -------- */ + +#define HSTICR_OFFSET (0x408) /**< (HSTICR) Host Global Interrupt Clear Register Offset */ + +#define HSTICR_DCONNIC_Pos 0 /**< (HSTICR) Device Connection Interrupt Clear Position */ +#define HSTICR_DCONNIC (_U_(0x1) << HSTICR_DCONNIC_Pos) /**< (HSTICR) Device Connection Interrupt Clear Mask */ +#define HSTICR_DDISCIC_Pos 1 /**< (HSTICR) Device Disconnection Interrupt Clear Position */ +#define HSTICR_DDISCIC (_U_(0x1) << HSTICR_DDISCIC_Pos) /**< (HSTICR) Device Disconnection Interrupt Clear Mask */ +#define HSTICR_RSTIC_Pos 2 /**< (HSTICR) USB Reset Sent Interrupt Clear Position */ +#define HSTICR_RSTIC (_U_(0x1) << HSTICR_RSTIC_Pos) /**< (HSTICR) USB Reset Sent Interrupt Clear Mask */ +#define HSTICR_RSMEDIC_Pos 3 /**< (HSTICR) Downstream Resume Sent Interrupt Clear Position */ +#define HSTICR_RSMEDIC (_U_(0x1) << HSTICR_RSMEDIC_Pos) /**< (HSTICR) Downstream Resume Sent Interrupt Clear Mask */ +#define HSTICR_RXRSMIC_Pos 4 /**< (HSTICR) Upstream Resume Received Interrupt Clear Position */ +#define HSTICR_RXRSMIC (_U_(0x1) << HSTICR_RXRSMIC_Pos) /**< (HSTICR) Upstream Resume Received Interrupt Clear Mask */ +#define HSTICR_HSOFIC_Pos 5 /**< (HSTICR) Host Start of Frame Interrupt Clear Position */ +#define HSTICR_HSOFIC (_U_(0x1) << HSTICR_HSOFIC_Pos) /**< (HSTICR) Host Start of Frame Interrupt Clear Mask */ +#define HSTICR_HWUPIC_Pos 6 /**< (HSTICR) Host Wake-Up Interrupt Clear Position */ +#define HSTICR_HWUPIC (_U_(0x1) << HSTICR_HWUPIC_Pos) /**< (HSTICR) Host Wake-Up Interrupt Clear Mask */ +#define HSTICR_Msk _U_(0x7F) /**< (HSTICR) Register Mask */ + + +/* -------- HSTIFR : (USBHS Offset: 0x40c) (/W 32) Host Global Interrupt Set Register -------- */ + +#define HSTIFR_OFFSET (0x40C) /**< (HSTIFR) Host Global Interrupt Set Register Offset */ + +#define HSTIFR_DCONNIS_Pos 0 /**< (HSTIFR) Device Connection Interrupt Set Position */ +#define HSTIFR_DCONNIS (_U_(0x1) << HSTIFR_DCONNIS_Pos) /**< (HSTIFR) Device Connection Interrupt Set Mask */ +#define HSTIFR_DDISCIS_Pos 1 /**< (HSTIFR) Device Disconnection Interrupt Set Position */ +#define HSTIFR_DDISCIS (_U_(0x1) << HSTIFR_DDISCIS_Pos) /**< (HSTIFR) Device Disconnection Interrupt Set Mask */ +#define HSTIFR_RSTIS_Pos 2 /**< (HSTIFR) USB Reset Sent Interrupt Set Position */ +#define HSTIFR_RSTIS (_U_(0x1) << HSTIFR_RSTIS_Pos) /**< (HSTIFR) USB Reset Sent Interrupt Set Mask */ +#define HSTIFR_RSMEDIS_Pos 3 /**< (HSTIFR) Downstream Resume Sent Interrupt Set Position */ +#define HSTIFR_RSMEDIS (_U_(0x1) << HSTIFR_RSMEDIS_Pos) /**< (HSTIFR) Downstream Resume Sent Interrupt Set Mask */ +#define HSTIFR_RXRSMIS_Pos 4 /**< (HSTIFR) Upstream Resume Received Interrupt Set Position */ +#define HSTIFR_RXRSMIS (_U_(0x1) << HSTIFR_RXRSMIS_Pos) /**< (HSTIFR) Upstream Resume Received Interrupt Set Mask */ +#define HSTIFR_HSOFIS_Pos 5 /**< (HSTIFR) Host Start of Frame Interrupt Set Position */ +#define HSTIFR_HSOFIS (_U_(0x1) << HSTIFR_HSOFIS_Pos) /**< (HSTIFR) Host Start of Frame Interrupt Set Mask */ +#define HSTIFR_HWUPIS_Pos 6 /**< (HSTIFR) Host Wake-Up Interrupt Set Position */ +#define HSTIFR_HWUPIS (_U_(0x1) << HSTIFR_HWUPIS_Pos) /**< (HSTIFR) Host Wake-Up Interrupt Set Mask */ +#define HSTIFR_DMA_0_Pos 25 /**< (HSTIFR) DMA Channel 0 Interrupt Set Position */ +#define HSTIFR_DMA_0 (_U_(0x1) << HSTIFR_DMA_0_Pos) /**< (HSTIFR) DMA Channel 0 Interrupt Set Mask */ +#define HSTIFR_DMA_1_Pos 26 /**< (HSTIFR) DMA Channel 1 Interrupt Set Position */ +#define HSTIFR_DMA_1 (_U_(0x1) << HSTIFR_DMA_1_Pos) /**< (HSTIFR) DMA Channel 1 Interrupt Set Mask */ +#define HSTIFR_DMA_2_Pos 27 /**< (HSTIFR) DMA Channel 2 Interrupt Set Position */ +#define HSTIFR_DMA_2 (_U_(0x1) << HSTIFR_DMA_2_Pos) /**< (HSTIFR) DMA Channel 2 Interrupt Set Mask */ +#define HSTIFR_DMA_3_Pos 28 /**< (HSTIFR) DMA Channel 3 Interrupt Set Position */ +#define HSTIFR_DMA_3 (_U_(0x1) << HSTIFR_DMA_3_Pos) /**< (HSTIFR) DMA Channel 3 Interrupt Set Mask */ +#define HSTIFR_DMA_4_Pos 29 /**< (HSTIFR) DMA Channel 4 Interrupt Set Position */ +#define HSTIFR_DMA_4 (_U_(0x1) << HSTIFR_DMA_4_Pos) /**< (HSTIFR) DMA Channel 4 Interrupt Set Mask */ +#define HSTIFR_DMA_5_Pos 30 /**< (HSTIFR) DMA Channel 5 Interrupt Set Position */ +#define HSTIFR_DMA_5 (_U_(0x1) << HSTIFR_DMA_5_Pos) /**< (HSTIFR) DMA Channel 5 Interrupt Set Mask */ +#define HSTIFR_DMA_6_Pos 31 /**< (HSTIFR) DMA Channel 6 Interrupt Set Position */ +#define HSTIFR_DMA_6 (_U_(0x1) << HSTIFR_DMA_6_Pos) /**< (HSTIFR) DMA Channel 6 Interrupt Set Mask */ +#define HSTIFR_Msk _U_(0xFE00007F) /**< (HSTIFR) Register Mask */ + +#define HSTIFR_DMA__Pos 25 /**< (HSTIFR Position) DMA Channel 6 Interrupt Set */ +#define HSTIFR_DMA_ (_U_(0x7F) << HSTIFR_DMA__Pos) /**< (HSTIFR Mask) DMA_ */ + +/* -------- HSTIMR : (USBHS Offset: 0x410) (R/ 32) Host Global Interrupt Mask Register -------- */ + +#define HSTIMR_OFFSET (0x410) /**< (HSTIMR) Host Global Interrupt Mask Register Offset */ + +#define HSTIMR_DCONNIE_Pos 0 /**< (HSTIMR) Device Connection Interrupt Enable Position */ +#define HSTIMR_DCONNIE (_U_(0x1) << HSTIMR_DCONNIE_Pos) /**< (HSTIMR) Device Connection Interrupt Enable Mask */ +#define HSTIMR_DDISCIE_Pos 1 /**< (HSTIMR) Device Disconnection Interrupt Enable Position */ +#define HSTIMR_DDISCIE (_U_(0x1) << HSTIMR_DDISCIE_Pos) /**< (HSTIMR) Device Disconnection Interrupt Enable Mask */ +#define HSTIMR_RSTIE_Pos 2 /**< (HSTIMR) USB Reset Sent Interrupt Enable Position */ +#define HSTIMR_RSTIE (_U_(0x1) << HSTIMR_RSTIE_Pos) /**< (HSTIMR) USB Reset Sent Interrupt Enable Mask */ +#define HSTIMR_RSMEDIE_Pos 3 /**< (HSTIMR) Downstream Resume Sent Interrupt Enable Position */ +#define HSTIMR_RSMEDIE (_U_(0x1) << HSTIMR_RSMEDIE_Pos) /**< (HSTIMR) Downstream Resume Sent Interrupt Enable Mask */ +#define HSTIMR_RXRSMIE_Pos 4 /**< (HSTIMR) Upstream Resume Received Interrupt Enable Position */ +#define HSTIMR_RXRSMIE (_U_(0x1) << HSTIMR_RXRSMIE_Pos) /**< (HSTIMR) Upstream Resume Received Interrupt Enable Mask */ +#define HSTIMR_HSOFIE_Pos 5 /**< (HSTIMR) Host Start of Frame Interrupt Enable Position */ +#define HSTIMR_HSOFIE (_U_(0x1) << HSTIMR_HSOFIE_Pos) /**< (HSTIMR) Host Start of Frame Interrupt Enable Mask */ +#define HSTIMR_HWUPIE_Pos 6 /**< (HSTIMR) Host Wake-Up Interrupt Enable Position */ +#define HSTIMR_HWUPIE (_U_(0x1) << HSTIMR_HWUPIE_Pos) /**< (HSTIMR) Host Wake-Up Interrupt Enable Mask */ +#define HSTIMR_PEP_0_Pos 8 /**< (HSTIMR) Pipe 0 Interrupt Enable Position */ +#define HSTIMR_PEP_0 (_U_(0x1) << HSTIMR_PEP_0_Pos) /**< (HSTIMR) Pipe 0 Interrupt Enable Mask */ +#define HSTIMR_PEP_1_Pos 9 /**< (HSTIMR) Pipe 1 Interrupt Enable Position */ +#define HSTIMR_PEP_1 (_U_(0x1) << HSTIMR_PEP_1_Pos) /**< (HSTIMR) Pipe 1 Interrupt Enable Mask */ +#define HSTIMR_PEP_2_Pos 10 /**< (HSTIMR) Pipe 2 Interrupt Enable Position */ +#define HSTIMR_PEP_2 (_U_(0x1) << HSTIMR_PEP_2_Pos) /**< (HSTIMR) Pipe 2 Interrupt Enable Mask */ +#define HSTIMR_PEP_3_Pos 11 /**< (HSTIMR) Pipe 3 Interrupt Enable Position */ +#define HSTIMR_PEP_3 (_U_(0x1) << HSTIMR_PEP_3_Pos) /**< (HSTIMR) Pipe 3 Interrupt Enable Mask */ +#define HSTIMR_PEP_4_Pos 12 /**< (HSTIMR) Pipe 4 Interrupt Enable Position */ +#define HSTIMR_PEP_4 (_U_(0x1) << HSTIMR_PEP_4_Pos) /**< (HSTIMR) Pipe 4 Interrupt Enable Mask */ +#define HSTIMR_PEP_5_Pos 13 /**< (HSTIMR) Pipe 5 Interrupt Enable Position */ +#define HSTIMR_PEP_5 (_U_(0x1) << HSTIMR_PEP_5_Pos) /**< (HSTIMR) Pipe 5 Interrupt Enable Mask */ +#define HSTIMR_PEP_6_Pos 14 /**< (HSTIMR) Pipe 6 Interrupt Enable Position */ +#define HSTIMR_PEP_6 (_U_(0x1) << HSTIMR_PEP_6_Pos) /**< (HSTIMR) Pipe 6 Interrupt Enable Mask */ +#define HSTIMR_PEP_7_Pos 15 /**< (HSTIMR) Pipe 7 Interrupt Enable Position */ +#define HSTIMR_PEP_7 (_U_(0x1) << HSTIMR_PEP_7_Pos) /**< (HSTIMR) Pipe 7 Interrupt Enable Mask */ +#define HSTIMR_PEP_8_Pos 16 /**< (HSTIMR) Pipe 8 Interrupt Enable Position */ +#define HSTIMR_PEP_8 (_U_(0x1) << HSTIMR_PEP_8_Pos) /**< (HSTIMR) Pipe 8 Interrupt Enable Mask */ +#define HSTIMR_PEP_9_Pos 17 /**< (HSTIMR) Pipe 9 Interrupt Enable Position */ +#define HSTIMR_PEP_9 (_U_(0x1) << HSTIMR_PEP_9_Pos) /**< (HSTIMR) Pipe 9 Interrupt Enable Mask */ +#define HSTIMR_DMA_0_Pos 25 /**< (HSTIMR) DMA Channel 0 Interrupt Enable Position */ +#define HSTIMR_DMA_0 (_U_(0x1) << HSTIMR_DMA_0_Pos) /**< (HSTIMR) DMA Channel 0 Interrupt Enable Mask */ +#define HSTIMR_DMA_1_Pos 26 /**< (HSTIMR) DMA Channel 1 Interrupt Enable Position */ +#define HSTIMR_DMA_1 (_U_(0x1) << HSTIMR_DMA_1_Pos) /**< (HSTIMR) DMA Channel 1 Interrupt Enable Mask */ +#define HSTIMR_DMA_2_Pos 27 /**< (HSTIMR) DMA Channel 2 Interrupt Enable Position */ +#define HSTIMR_DMA_2 (_U_(0x1) << HSTIMR_DMA_2_Pos) /**< (HSTIMR) DMA Channel 2 Interrupt Enable Mask */ +#define HSTIMR_DMA_3_Pos 28 /**< (HSTIMR) DMA Channel 3 Interrupt Enable Position */ +#define HSTIMR_DMA_3 (_U_(0x1) << HSTIMR_DMA_3_Pos) /**< (HSTIMR) DMA Channel 3 Interrupt Enable Mask */ +#define HSTIMR_DMA_4_Pos 29 /**< (HSTIMR) DMA Channel 4 Interrupt Enable Position */ +#define HSTIMR_DMA_4 (_U_(0x1) << HSTIMR_DMA_4_Pos) /**< (HSTIMR) DMA Channel 4 Interrupt Enable Mask */ +#define HSTIMR_DMA_5_Pos 30 /**< (HSTIMR) DMA Channel 5 Interrupt Enable Position */ +#define HSTIMR_DMA_5 (_U_(0x1) << HSTIMR_DMA_5_Pos) /**< (HSTIMR) DMA Channel 5 Interrupt Enable Mask */ +#define HSTIMR_DMA_6_Pos 31 /**< (HSTIMR) DMA Channel 6 Interrupt Enable Position */ +#define HSTIMR_DMA_6 (_U_(0x1) << HSTIMR_DMA_6_Pos) /**< (HSTIMR) DMA Channel 6 Interrupt Enable Mask */ +#define HSTIMR_Msk _U_(0xFE03FF7F) /**< (HSTIMR) Register Mask */ + +#define HSTIMR_PEP__Pos 8 /**< (HSTIMR Position) Pipe x Interrupt Enable */ +#define HSTIMR_PEP_ (_U_(0x3FF) << HSTIMR_PEP__Pos) /**< (HSTIMR Mask) PEP_ */ +#define HSTIMR_DMA__Pos 25 /**< (HSTIMR Position) DMA Channel 6 Interrupt Enable */ +#define HSTIMR_DMA_ (_U_(0x7F) << HSTIMR_DMA__Pos) /**< (HSTIMR Mask) DMA_ */ + +/* -------- HSTIDR : (USBHS Offset: 0x414) (/W 32) Host Global Interrupt Disable Register -------- */ + +#define HSTIDR_OFFSET (0x414) /**< (HSTIDR) Host Global Interrupt Disable Register Offset */ + +#define HSTIDR_DCONNIEC_Pos 0 /**< (HSTIDR) Device Connection Interrupt Disable Position */ +#define HSTIDR_DCONNIEC (_U_(0x1) << HSTIDR_DCONNIEC_Pos) /**< (HSTIDR) Device Connection Interrupt Disable Mask */ +#define HSTIDR_DDISCIEC_Pos 1 /**< (HSTIDR) Device Disconnection Interrupt Disable Position */ +#define HSTIDR_DDISCIEC (_U_(0x1) << HSTIDR_DDISCIEC_Pos) /**< (HSTIDR) Device Disconnection Interrupt Disable Mask */ +#define HSTIDR_RSTIEC_Pos 2 /**< (HSTIDR) USB Reset Sent Interrupt Disable Position */ +#define HSTIDR_RSTIEC (_U_(0x1) << HSTIDR_RSTIEC_Pos) /**< (HSTIDR) USB Reset Sent Interrupt Disable Mask */ +#define HSTIDR_RSMEDIEC_Pos 3 /**< (HSTIDR) Downstream Resume Sent Interrupt Disable Position */ +#define HSTIDR_RSMEDIEC (_U_(0x1) << HSTIDR_RSMEDIEC_Pos) /**< (HSTIDR) Downstream Resume Sent Interrupt Disable Mask */ +#define HSTIDR_RXRSMIEC_Pos 4 /**< (HSTIDR) Upstream Resume Received Interrupt Disable Position */ +#define HSTIDR_RXRSMIEC (_U_(0x1) << HSTIDR_RXRSMIEC_Pos) /**< (HSTIDR) Upstream Resume Received Interrupt Disable Mask */ +#define HSTIDR_HSOFIEC_Pos 5 /**< (HSTIDR) Host Start of Frame Interrupt Disable Position */ +#define HSTIDR_HSOFIEC (_U_(0x1) << HSTIDR_HSOFIEC_Pos) /**< (HSTIDR) Host Start of Frame Interrupt Disable Mask */ +#define HSTIDR_HWUPIEC_Pos 6 /**< (HSTIDR) Host Wake-Up Interrupt Disable Position */ +#define HSTIDR_HWUPIEC (_U_(0x1) << HSTIDR_HWUPIEC_Pos) /**< (HSTIDR) Host Wake-Up Interrupt Disable Mask */ +#define HSTIDR_PEP_0_Pos 8 /**< (HSTIDR) Pipe 0 Interrupt Disable Position */ +#define HSTIDR_PEP_0 (_U_(0x1) << HSTIDR_PEP_0_Pos) /**< (HSTIDR) Pipe 0 Interrupt Disable Mask */ +#define HSTIDR_PEP_1_Pos 9 /**< (HSTIDR) Pipe 1 Interrupt Disable Position */ +#define HSTIDR_PEP_1 (_U_(0x1) << HSTIDR_PEP_1_Pos) /**< (HSTIDR) Pipe 1 Interrupt Disable Mask */ +#define HSTIDR_PEP_2_Pos 10 /**< (HSTIDR) Pipe 2 Interrupt Disable Position */ +#define HSTIDR_PEP_2 (_U_(0x1) << HSTIDR_PEP_2_Pos) /**< (HSTIDR) Pipe 2 Interrupt Disable Mask */ +#define HSTIDR_PEP_3_Pos 11 /**< (HSTIDR) Pipe 3 Interrupt Disable Position */ +#define HSTIDR_PEP_3 (_U_(0x1) << HSTIDR_PEP_3_Pos) /**< (HSTIDR) Pipe 3 Interrupt Disable Mask */ +#define HSTIDR_PEP_4_Pos 12 /**< (HSTIDR) Pipe 4 Interrupt Disable Position */ +#define HSTIDR_PEP_4 (_U_(0x1) << HSTIDR_PEP_4_Pos) /**< (HSTIDR) Pipe 4 Interrupt Disable Mask */ +#define HSTIDR_PEP_5_Pos 13 /**< (HSTIDR) Pipe 5 Interrupt Disable Position */ +#define HSTIDR_PEP_5 (_U_(0x1) << HSTIDR_PEP_5_Pos) /**< (HSTIDR) Pipe 5 Interrupt Disable Mask */ +#define HSTIDR_PEP_6_Pos 14 /**< (HSTIDR) Pipe 6 Interrupt Disable Position */ +#define HSTIDR_PEP_6 (_U_(0x1) << HSTIDR_PEP_6_Pos) /**< (HSTIDR) Pipe 6 Interrupt Disable Mask */ +#define HSTIDR_PEP_7_Pos 15 /**< (HSTIDR) Pipe 7 Interrupt Disable Position */ +#define HSTIDR_PEP_7 (_U_(0x1) << HSTIDR_PEP_7_Pos) /**< (HSTIDR) Pipe 7 Interrupt Disable Mask */ +#define HSTIDR_PEP_8_Pos 16 /**< (HSTIDR) Pipe 8 Interrupt Disable Position */ +#define HSTIDR_PEP_8 (_U_(0x1) << HSTIDR_PEP_8_Pos) /**< (HSTIDR) Pipe 8 Interrupt Disable Mask */ +#define HSTIDR_PEP_9_Pos 17 /**< (HSTIDR) Pipe 9 Interrupt Disable Position */ +#define HSTIDR_PEP_9 (_U_(0x1) << HSTIDR_PEP_9_Pos) /**< (HSTIDR) Pipe 9 Interrupt Disable Mask */ +#define HSTIDR_DMA_0_Pos 25 /**< (HSTIDR) DMA Channel 0 Interrupt Disable Position */ +#define HSTIDR_DMA_0 (_U_(0x1) << HSTIDR_DMA_0_Pos) /**< (HSTIDR) DMA Channel 0 Interrupt Disable Mask */ +#define HSTIDR_DMA_1_Pos 26 /**< (HSTIDR) DMA Channel 1 Interrupt Disable Position */ +#define HSTIDR_DMA_1 (_U_(0x1) << HSTIDR_DMA_1_Pos) /**< (HSTIDR) DMA Channel 1 Interrupt Disable Mask */ +#define HSTIDR_DMA_2_Pos 27 /**< (HSTIDR) DMA Channel 2 Interrupt Disable Position */ +#define HSTIDR_DMA_2 (_U_(0x1) << HSTIDR_DMA_2_Pos) /**< (HSTIDR) DMA Channel 2 Interrupt Disable Mask */ +#define HSTIDR_DMA_3_Pos 28 /**< (HSTIDR) DMA Channel 3 Interrupt Disable Position */ +#define HSTIDR_DMA_3 (_U_(0x1) << HSTIDR_DMA_3_Pos) /**< (HSTIDR) DMA Channel 3 Interrupt Disable Mask */ +#define HSTIDR_DMA_4_Pos 29 /**< (HSTIDR) DMA Channel 4 Interrupt Disable Position */ +#define HSTIDR_DMA_4 (_U_(0x1) << HSTIDR_DMA_4_Pos) /**< (HSTIDR) DMA Channel 4 Interrupt Disable Mask */ +#define HSTIDR_DMA_5_Pos 30 /**< (HSTIDR) DMA Channel 5 Interrupt Disable Position */ +#define HSTIDR_DMA_5 (_U_(0x1) << HSTIDR_DMA_5_Pos) /**< (HSTIDR) DMA Channel 5 Interrupt Disable Mask */ +#define HSTIDR_DMA_6_Pos 31 /**< (HSTIDR) DMA Channel 6 Interrupt Disable Position */ +#define HSTIDR_DMA_6 (_U_(0x1) << HSTIDR_DMA_6_Pos) /**< (HSTIDR) DMA Channel 6 Interrupt Disable Mask */ +#define HSTIDR_Msk _U_(0xFE03FF7F) /**< (HSTIDR) Register Mask */ + +#define HSTIDR_PEP__Pos 8 /**< (HSTIDR Position) Pipe x Interrupt Disable */ +#define HSTIDR_PEP_ (_U_(0x3FF) << HSTIDR_PEP__Pos) /**< (HSTIDR Mask) PEP_ */ +#define HSTIDR_DMA__Pos 25 /**< (HSTIDR Position) DMA Channel 6 Interrupt Disable */ +#define HSTIDR_DMA_ (_U_(0x7F) << HSTIDR_DMA__Pos) /**< (HSTIDR Mask) DMA_ */ + +/* -------- HSTIER : (USBHS Offset: 0x418) (/W 32) Host Global Interrupt Enable Register -------- */ + +#define HSTIER_OFFSET (0x418) /**< (HSTIER) Host Global Interrupt Enable Register Offset */ + +#define HSTIER_DCONNIES_Pos 0 /**< (HSTIER) Device Connection Interrupt Enable Position */ +#define HSTIER_DCONNIES (_U_(0x1) << HSTIER_DCONNIES_Pos) /**< (HSTIER) Device Connection Interrupt Enable Mask */ +#define HSTIER_DDISCIES_Pos 1 /**< (HSTIER) Device Disconnection Interrupt Enable Position */ +#define HSTIER_DDISCIES (_U_(0x1) << HSTIER_DDISCIES_Pos) /**< (HSTIER) Device Disconnection Interrupt Enable Mask */ +#define HSTIER_RSTIES_Pos 2 /**< (HSTIER) USB Reset Sent Interrupt Enable Position */ +#define HSTIER_RSTIES (_U_(0x1) << HSTIER_RSTIES_Pos) /**< (HSTIER) USB Reset Sent Interrupt Enable Mask */ +#define HSTIER_RSMEDIES_Pos 3 /**< (HSTIER) Downstream Resume Sent Interrupt Enable Position */ +#define HSTIER_RSMEDIES (_U_(0x1) << HSTIER_RSMEDIES_Pos) /**< (HSTIER) Downstream Resume Sent Interrupt Enable Mask */ +#define HSTIER_RXRSMIES_Pos 4 /**< (HSTIER) Upstream Resume Received Interrupt Enable Position */ +#define HSTIER_RXRSMIES (_U_(0x1) << HSTIER_RXRSMIES_Pos) /**< (HSTIER) Upstream Resume Received Interrupt Enable Mask */ +#define HSTIER_HSOFIES_Pos 5 /**< (HSTIER) Host Start of Frame Interrupt Enable Position */ +#define HSTIER_HSOFIES (_U_(0x1) << HSTIER_HSOFIES_Pos) /**< (HSTIER) Host Start of Frame Interrupt Enable Mask */ +#define HSTIER_HWUPIES_Pos 6 /**< (HSTIER) Host Wake-Up Interrupt Enable Position */ +#define HSTIER_HWUPIES (_U_(0x1) << HSTIER_HWUPIES_Pos) /**< (HSTIER) Host Wake-Up Interrupt Enable Mask */ +#define HSTIER_PEP_0_Pos 8 /**< (HSTIER) Pipe 0 Interrupt Enable Position */ +#define HSTIER_PEP_0 (_U_(0x1) << HSTIER_PEP_0_Pos) /**< (HSTIER) Pipe 0 Interrupt Enable Mask */ +#define HSTIER_PEP_1_Pos 9 /**< (HSTIER) Pipe 1 Interrupt Enable Position */ +#define HSTIER_PEP_1 (_U_(0x1) << HSTIER_PEP_1_Pos) /**< (HSTIER) Pipe 1 Interrupt Enable Mask */ +#define HSTIER_PEP_2_Pos 10 /**< (HSTIER) Pipe 2 Interrupt Enable Position */ +#define HSTIER_PEP_2 (_U_(0x1) << HSTIER_PEP_2_Pos) /**< (HSTIER) Pipe 2 Interrupt Enable Mask */ +#define HSTIER_PEP_3_Pos 11 /**< (HSTIER) Pipe 3 Interrupt Enable Position */ +#define HSTIER_PEP_3 (_U_(0x1) << HSTIER_PEP_3_Pos) /**< (HSTIER) Pipe 3 Interrupt Enable Mask */ +#define HSTIER_PEP_4_Pos 12 /**< (HSTIER) Pipe 4 Interrupt Enable Position */ +#define HSTIER_PEP_4 (_U_(0x1) << HSTIER_PEP_4_Pos) /**< (HSTIER) Pipe 4 Interrupt Enable Mask */ +#define HSTIER_PEP_5_Pos 13 /**< (HSTIER) Pipe 5 Interrupt Enable Position */ +#define HSTIER_PEP_5 (_U_(0x1) << HSTIER_PEP_5_Pos) /**< (HSTIER) Pipe 5 Interrupt Enable Mask */ +#define HSTIER_PEP_6_Pos 14 /**< (HSTIER) Pipe 6 Interrupt Enable Position */ +#define HSTIER_PEP_6 (_U_(0x1) << HSTIER_PEP_6_Pos) /**< (HSTIER) Pipe 6 Interrupt Enable Mask */ +#define HSTIER_PEP_7_Pos 15 /**< (HSTIER) Pipe 7 Interrupt Enable Position */ +#define HSTIER_PEP_7 (_U_(0x1) << HSTIER_PEP_7_Pos) /**< (HSTIER) Pipe 7 Interrupt Enable Mask */ +#define HSTIER_PEP_8_Pos 16 /**< (HSTIER) Pipe 8 Interrupt Enable Position */ +#define HSTIER_PEP_8 (_U_(0x1) << HSTIER_PEP_8_Pos) /**< (HSTIER) Pipe 8 Interrupt Enable Mask */ +#define HSTIER_PEP_9_Pos 17 /**< (HSTIER) Pipe 9 Interrupt Enable Position */ +#define HSTIER_PEP_9 (_U_(0x1) << HSTIER_PEP_9_Pos) /**< (HSTIER) Pipe 9 Interrupt Enable Mask */ +#define HSTIER_DMA_0_Pos 25 /**< (HSTIER) DMA Channel 0 Interrupt Enable Position */ +#define HSTIER_DMA_0 (_U_(0x1) << HSTIER_DMA_0_Pos) /**< (HSTIER) DMA Channel 0 Interrupt Enable Mask */ +#define HSTIER_DMA_1_Pos 26 /**< (HSTIER) DMA Channel 1 Interrupt Enable Position */ +#define HSTIER_DMA_1 (_U_(0x1) << HSTIER_DMA_1_Pos) /**< (HSTIER) DMA Channel 1 Interrupt Enable Mask */ +#define HSTIER_DMA_2_Pos 27 /**< (HSTIER) DMA Channel 2 Interrupt Enable Position */ +#define HSTIER_DMA_2 (_U_(0x1) << HSTIER_DMA_2_Pos) /**< (HSTIER) DMA Channel 2 Interrupt Enable Mask */ +#define HSTIER_DMA_3_Pos 28 /**< (HSTIER) DMA Channel 3 Interrupt Enable Position */ +#define HSTIER_DMA_3 (_U_(0x1) << HSTIER_DMA_3_Pos) /**< (HSTIER) DMA Channel 3 Interrupt Enable Mask */ +#define HSTIER_DMA_4_Pos 29 /**< (HSTIER) DMA Channel 4 Interrupt Enable Position */ +#define HSTIER_DMA_4 (_U_(0x1) << HSTIER_DMA_4_Pos) /**< (HSTIER) DMA Channel 4 Interrupt Enable Mask */ +#define HSTIER_DMA_5_Pos 30 /**< (HSTIER) DMA Channel 5 Interrupt Enable Position */ +#define HSTIER_DMA_5 (_U_(0x1) << HSTIER_DMA_5_Pos) /**< (HSTIER) DMA Channel 5 Interrupt Enable Mask */ +#define HSTIER_DMA_6_Pos 31 /**< (HSTIER) DMA Channel 6 Interrupt Enable Position */ +#define HSTIER_DMA_6 (_U_(0x1) << HSTIER_DMA_6_Pos) /**< (HSTIER) DMA Channel 6 Interrupt Enable Mask */ +#define HSTIER_Msk _U_(0xFE03FF7F) /**< (HSTIER) Register Mask */ + +#define HSTIER_PEP__Pos 8 /**< (HSTIER Position) Pipe x Interrupt Enable */ +#define HSTIER_PEP_ (_U_(0x3FF) << HSTIER_PEP__Pos) /**< (HSTIER Mask) PEP_ */ +#define HSTIER_DMA__Pos 25 /**< (HSTIER Position) DMA Channel 6 Interrupt Enable */ +#define HSTIER_DMA_ (_U_(0x7F) << HSTIER_DMA__Pos) /**< (HSTIER Mask) DMA_ */ + +/* -------- HSTPIP : (USBHS Offset: 0x41c) (R/W 32) Host Pipe Register -------- */ + +#define HSTPIP_OFFSET (0x41C) /**< (HSTPIP) Host Pipe Register Offset */ + +#define HSTPIP_PEN0_Pos 0 /**< (HSTPIP) Pipe 0 Enable Position */ +#define HSTPIP_PEN0 (_U_(0x1) << HSTPIP_PEN0_Pos) /**< (HSTPIP) Pipe 0 Enable Mask */ +#define HSTPIP_PEN1_Pos 1 /**< (HSTPIP) Pipe 1 Enable Position */ +#define HSTPIP_PEN1 (_U_(0x1) << HSTPIP_PEN1_Pos) /**< (HSTPIP) Pipe 1 Enable Mask */ +#define HSTPIP_PEN2_Pos 2 /**< (HSTPIP) Pipe 2 Enable Position */ +#define HSTPIP_PEN2 (_U_(0x1) << HSTPIP_PEN2_Pos) /**< (HSTPIP) Pipe 2 Enable Mask */ +#define HSTPIP_PEN3_Pos 3 /**< (HSTPIP) Pipe 3 Enable Position */ +#define HSTPIP_PEN3 (_U_(0x1) << HSTPIP_PEN3_Pos) /**< (HSTPIP) Pipe 3 Enable Mask */ +#define HSTPIP_PEN4_Pos 4 /**< (HSTPIP) Pipe 4 Enable Position */ +#define HSTPIP_PEN4 (_U_(0x1) << HSTPIP_PEN4_Pos) /**< (HSTPIP) Pipe 4 Enable Mask */ +#define HSTPIP_PEN5_Pos 5 /**< (HSTPIP) Pipe 5 Enable Position */ +#define HSTPIP_PEN5 (_U_(0x1) << HSTPIP_PEN5_Pos) /**< (HSTPIP) Pipe 5 Enable Mask */ +#define HSTPIP_PEN6_Pos 6 /**< (HSTPIP) Pipe 6 Enable Position */ +#define HSTPIP_PEN6 (_U_(0x1) << HSTPIP_PEN6_Pos) /**< (HSTPIP) Pipe 6 Enable Mask */ +#define HSTPIP_PEN7_Pos 7 /**< (HSTPIP) Pipe 7 Enable Position */ +#define HSTPIP_PEN7 (_U_(0x1) << HSTPIP_PEN7_Pos) /**< (HSTPIP) Pipe 7 Enable Mask */ +#define HSTPIP_PEN8_Pos 8 /**< (HSTPIP) Pipe 8 Enable Position */ +#define HSTPIP_PEN8 (_U_(0x1) << HSTPIP_PEN8_Pos) /**< (HSTPIP) Pipe 8 Enable Mask */ +#define HSTPIP_PRST0_Pos 16 /**< (HSTPIP) Pipe 0 Reset Position */ +#define HSTPIP_PRST0 (_U_(0x1) << HSTPIP_PRST0_Pos) /**< (HSTPIP) Pipe 0 Reset Mask */ +#define HSTPIP_PRST1_Pos 17 /**< (HSTPIP) Pipe 1 Reset Position */ +#define HSTPIP_PRST1 (_U_(0x1) << HSTPIP_PRST1_Pos) /**< (HSTPIP) Pipe 1 Reset Mask */ +#define HSTPIP_PRST2_Pos 18 /**< (HSTPIP) Pipe 2 Reset Position */ +#define HSTPIP_PRST2 (_U_(0x1) << HSTPIP_PRST2_Pos) /**< (HSTPIP) Pipe 2 Reset Mask */ +#define HSTPIP_PRST3_Pos 19 /**< (HSTPIP) Pipe 3 Reset Position */ +#define HSTPIP_PRST3 (_U_(0x1) << HSTPIP_PRST3_Pos) /**< (HSTPIP) Pipe 3 Reset Mask */ +#define HSTPIP_PRST4_Pos 20 /**< (HSTPIP) Pipe 4 Reset Position */ +#define HSTPIP_PRST4 (_U_(0x1) << HSTPIP_PRST4_Pos) /**< (HSTPIP) Pipe 4 Reset Mask */ +#define HSTPIP_PRST5_Pos 21 /**< (HSTPIP) Pipe 5 Reset Position */ +#define HSTPIP_PRST5 (_U_(0x1) << HSTPIP_PRST5_Pos) /**< (HSTPIP) Pipe 5 Reset Mask */ +#define HSTPIP_PRST6_Pos 22 /**< (HSTPIP) Pipe 6 Reset Position */ +#define HSTPIP_PRST6 (_U_(0x1) << HSTPIP_PRST6_Pos) /**< (HSTPIP) Pipe 6 Reset Mask */ +#define HSTPIP_PRST7_Pos 23 /**< (HSTPIP) Pipe 7 Reset Position */ +#define HSTPIP_PRST7 (_U_(0x1) << HSTPIP_PRST7_Pos) /**< (HSTPIP) Pipe 7 Reset Mask */ +#define HSTPIP_PRST8_Pos 24 /**< (HSTPIP) Pipe 8 Reset Position */ +#define HSTPIP_PRST8 (_U_(0x1) << HSTPIP_PRST8_Pos) /**< (HSTPIP) Pipe 8 Reset Mask */ +#define HSTPIP_Msk _U_(0x1FF01FF) /**< (HSTPIP) Register Mask */ + +#define HSTPIP_PEN_Pos 0 /**< (HSTPIP Position) Pipe x Enable */ +#define HSTPIP_PEN (_U_(0x1FF) << HSTPIP_PEN_Pos) /**< (HSTPIP Mask) PEN */ +#define HSTPIP_PRST_Pos 16 /**< (HSTPIP Position) Pipe 8 Reset */ +#define HSTPIP_PRST (_U_(0x1FF) << HSTPIP_PRST_Pos) /**< (HSTPIP Mask) PRST */ + +/* -------- HSTFNUM : (USBHS Offset: 0x420) (R/W 32) Host Frame Number Register -------- */ + +#define HSTFNUM_OFFSET (0x420) /**< (HSTFNUM) Host Frame Number Register Offset */ + +#define HSTFNUM_MFNUM_Pos 0 /**< (HSTFNUM) Micro Frame Number Position */ +#define HSTFNUM_MFNUM (_U_(0x7) << HSTFNUM_MFNUM_Pos) /**< (HSTFNUM) Micro Frame Number Mask */ +#define HSTFNUM_FNUM_Pos 3 /**< (HSTFNUM) Frame Number Position */ +#define HSTFNUM_FNUM (_U_(0x7FF) << HSTFNUM_FNUM_Pos) /**< (HSTFNUM) Frame Number Mask */ +#define HSTFNUM_FLENHIGH_Pos 16 /**< (HSTFNUM) Frame Length Position */ +#define HSTFNUM_FLENHIGH (_U_(0xFF) << HSTFNUM_FLENHIGH_Pos) /**< (HSTFNUM) Frame Length Mask */ +#define HSTFNUM_Msk _U_(0xFF3FFF) /**< (HSTFNUM) Register Mask */ + + +/* -------- HSTADDR1 : (USBHS Offset: 0x424) (R/W 32) Host Address 1 Register -------- */ + +#define HSTADDR1_OFFSET (0x424) /**< (HSTADDR1) Host Address 1 Register Offset */ + +#define HSTADDR1_HSTADDRP0_Pos 0 /**< (HSTADDR1) USB Host Address Position */ +#define HSTADDR1_HSTADDRP0 (_U_(0x7F) << HSTADDR1_HSTADDRP0_Pos) /**< (HSTADDR1) USB Host Address Mask */ +#define HSTADDR1_HSTADDRP1_Pos 8 /**< (HSTADDR1) USB Host Address Position */ +#define HSTADDR1_HSTADDRP1 (_U_(0x7F) << HSTADDR1_HSTADDRP1_Pos) /**< (HSTADDR1) USB Host Address Mask */ +#define HSTADDR1_HSTADDRP2_Pos 16 /**< (HSTADDR1) USB Host Address Position */ +#define HSTADDR1_HSTADDRP2 (_U_(0x7F) << HSTADDR1_HSTADDRP2_Pos) /**< (HSTADDR1) USB Host Address Mask */ +#define HSTADDR1_HSTADDRP3_Pos 24 /**< (HSTADDR1) USB Host Address Position */ +#define HSTADDR1_HSTADDRP3 (_U_(0x7F) << HSTADDR1_HSTADDRP3_Pos) /**< (HSTADDR1) USB Host Address Mask */ +#define HSTADDR1_Msk _U_(0x7F7F7F7F) /**< (HSTADDR1) Register Mask */ + + +/* -------- HSTADDR2 : (USBHS Offset: 0x428) (R/W 32) Host Address 2 Register -------- */ + +#define HSTADDR2_OFFSET (0x428) /**< (HSTADDR2) Host Address 2 Register Offset */ + +#define HSTADDR2_HSTADDRP4_Pos 0 /**< (HSTADDR2) USB Host Address Position */ +#define HSTADDR2_HSTADDRP4 (_U_(0x7F) << HSTADDR2_HSTADDRP4_Pos) /**< (HSTADDR2) USB Host Address Mask */ +#define HSTADDR2_HSTADDRP5_Pos 8 /**< (HSTADDR2) USB Host Address Position */ +#define HSTADDR2_HSTADDRP5 (_U_(0x7F) << HSTADDR2_HSTADDRP5_Pos) /**< (HSTADDR2) USB Host Address Mask */ +#define HSTADDR2_HSTADDRP6_Pos 16 /**< (HSTADDR2) USB Host Address Position */ +#define HSTADDR2_HSTADDRP6 (_U_(0x7F) << HSTADDR2_HSTADDRP6_Pos) /**< (HSTADDR2) USB Host Address Mask */ +#define HSTADDR2_HSTADDRP7_Pos 24 /**< (HSTADDR2) USB Host Address Position */ +#define HSTADDR2_HSTADDRP7 (_U_(0x7F) << HSTADDR2_HSTADDRP7_Pos) /**< (HSTADDR2) USB Host Address Mask */ +#define HSTADDR2_Msk _U_(0x7F7F7F7F) /**< (HSTADDR2) Register Mask */ + + +/* -------- HSTADDR3 : (USBHS Offset: 0x42c) (R/W 32) Host Address 3 Register -------- */ + +#define HSTADDR3_OFFSET (0x42C) /**< (HSTADDR3) Host Address 3 Register Offset */ + +#define HSTADDR3_HSTADDRP8_Pos 0 /**< (HSTADDR3) USB Host Address Position */ +#define HSTADDR3_HSTADDRP8 (_U_(0x7F) << HSTADDR3_HSTADDRP8_Pos) /**< (HSTADDR3) USB Host Address Mask */ +#define HSTADDR3_HSTADDRP9_Pos 8 /**< (HSTADDR3) USB Host Address Position */ +#define HSTADDR3_HSTADDRP9 (_U_(0x7F) << HSTADDR3_HSTADDRP9_Pos) /**< (HSTADDR3) USB Host Address Mask */ +#define HSTADDR3_Msk _U_(0x7F7F) /**< (HSTADDR3) Register Mask */ + + +/* -------- HSTPIPCFG : (USBHS Offset: 0x500) (R/W 32) Host Pipe Configuration Register -------- */ + +#define HSTPIPCFG_OFFSET (0x500) /**< (HSTPIPCFG) Host Pipe Configuration Register Offset */ + +#define HSTPIPCFG_ALLOC_Pos 1 /**< (HSTPIPCFG) Pipe Memory Allocate Position */ +#define HSTPIPCFG_ALLOC (_U_(0x1) << HSTPIPCFG_ALLOC_Pos) /**< (HSTPIPCFG) Pipe Memory Allocate Mask */ +#define HSTPIPCFG_PBK_Pos 2 /**< (HSTPIPCFG) Pipe Banks Position */ +#define HSTPIPCFG_PBK (_U_(0x3) << HSTPIPCFG_PBK_Pos) /**< (HSTPIPCFG) Pipe Banks Mask */ +#define HSTPIPCFG_PBK_1_BANK_Val _U_(0x0) /**< (HSTPIPCFG) Single-bank pipe */ +#define HSTPIPCFG_PBK_2_BANK_Val _U_(0x1) /**< (HSTPIPCFG) Double-bank pipe */ +#define HSTPIPCFG_PBK_3_BANK_Val _U_(0x2) /**< (HSTPIPCFG) Triple-bank pipe */ +#define HSTPIPCFG_PBK_1_BANK (HSTPIPCFG_PBK_1_BANK_Val << HSTPIPCFG_PBK_Pos) /**< (HSTPIPCFG) Single-bank pipe Position */ +#define HSTPIPCFG_PBK_2_BANK (HSTPIPCFG_PBK_2_BANK_Val << HSTPIPCFG_PBK_Pos) /**< (HSTPIPCFG) Double-bank pipe Position */ +#define HSTPIPCFG_PBK_3_BANK (HSTPIPCFG_PBK_3_BANK_Val << HSTPIPCFG_PBK_Pos) /**< (HSTPIPCFG) Triple-bank pipe Position */ +#define HSTPIPCFG_PSIZE_Pos 4 /**< (HSTPIPCFG) Pipe Size Position */ +#define HSTPIPCFG_PSIZE (_U_(0x7) << HSTPIPCFG_PSIZE_Pos) /**< (HSTPIPCFG) Pipe Size Mask */ +#define HSTPIPCFG_PSIZE_8_BYTE_Val _U_(0x0) /**< (HSTPIPCFG) 8 bytes */ +#define HSTPIPCFG_PSIZE_16_BYTE_Val _U_(0x1) /**< (HSTPIPCFG) 16 bytes */ +#define HSTPIPCFG_PSIZE_32_BYTE_Val _U_(0x2) /**< (HSTPIPCFG) 32 bytes */ +#define HSTPIPCFG_PSIZE_64_BYTE_Val _U_(0x3) /**< (HSTPIPCFG) 64 bytes */ +#define HSTPIPCFG_PSIZE_128_BYTE_Val _U_(0x4) /**< (HSTPIPCFG) 128 bytes */ +#define HSTPIPCFG_PSIZE_256_BYTE_Val _U_(0x5) /**< (HSTPIPCFG) 256 bytes */ +#define HSTPIPCFG_PSIZE_512_BYTE_Val _U_(0x6) /**< (HSTPIPCFG) 512 bytes */ +#define HSTPIPCFG_PSIZE_1024_BYTE_Val _U_(0x7) /**< (HSTPIPCFG) 1024 bytes */ +#define HSTPIPCFG_PSIZE_8_BYTE (HSTPIPCFG_PSIZE_8_BYTE_Val << HSTPIPCFG_PSIZE_Pos) /**< (HSTPIPCFG) 8 bytes Position */ +#define HSTPIPCFG_PSIZE_16_BYTE (HSTPIPCFG_PSIZE_16_BYTE_Val << HSTPIPCFG_PSIZE_Pos) /**< (HSTPIPCFG) 16 bytes Position */ +#define HSTPIPCFG_PSIZE_32_BYTE (HSTPIPCFG_PSIZE_32_BYTE_Val << HSTPIPCFG_PSIZE_Pos) /**< (HSTPIPCFG) 32 bytes Position */ +#define HSTPIPCFG_PSIZE_64_BYTE (HSTPIPCFG_PSIZE_64_BYTE_Val << HSTPIPCFG_PSIZE_Pos) /**< (HSTPIPCFG) 64 bytes Position */ +#define HSTPIPCFG_PSIZE_128_BYTE (HSTPIPCFG_PSIZE_128_BYTE_Val << HSTPIPCFG_PSIZE_Pos) /**< (HSTPIPCFG) 128 bytes Position */ +#define HSTPIPCFG_PSIZE_256_BYTE (HSTPIPCFG_PSIZE_256_BYTE_Val << HSTPIPCFG_PSIZE_Pos) /**< (HSTPIPCFG) 256 bytes Position */ +#define HSTPIPCFG_PSIZE_512_BYTE (HSTPIPCFG_PSIZE_512_BYTE_Val << HSTPIPCFG_PSIZE_Pos) /**< (HSTPIPCFG) 512 bytes Position */ +#define HSTPIPCFG_PSIZE_1024_BYTE (HSTPIPCFG_PSIZE_1024_BYTE_Val << HSTPIPCFG_PSIZE_Pos) /**< (HSTPIPCFG) 1024 bytes Position */ +#define HSTPIPCFG_PTOKEN_Pos 8 /**< (HSTPIPCFG) Pipe Token Position */ +#define HSTPIPCFG_PTOKEN (_U_(0x3) << HSTPIPCFG_PTOKEN_Pos) /**< (HSTPIPCFG) Pipe Token Mask */ +#define HSTPIPCFG_PTOKEN_SETUP_Val _U_(0x0) /**< (HSTPIPCFG) SETUP */ +#define HSTPIPCFG_PTOKEN_IN_Val _U_(0x1) /**< (HSTPIPCFG) IN */ +#define HSTPIPCFG_PTOKEN_OUT_Val _U_(0x2) /**< (HSTPIPCFG) OUT */ +#define HSTPIPCFG_PTOKEN_SETUP (HSTPIPCFG_PTOKEN_SETUP_Val << HSTPIPCFG_PTOKEN_Pos) /**< (HSTPIPCFG) SETUP Position */ +#define HSTPIPCFG_PTOKEN_IN (HSTPIPCFG_PTOKEN_IN_Val << HSTPIPCFG_PTOKEN_Pos) /**< (HSTPIPCFG) IN Position */ +#define HSTPIPCFG_PTOKEN_OUT (HSTPIPCFG_PTOKEN_OUT_Val << HSTPIPCFG_PTOKEN_Pos) /**< (HSTPIPCFG) OUT Position */ +#define HSTPIPCFG_AUTOSW_Pos 10 /**< (HSTPIPCFG) Automatic Switch Position */ +#define HSTPIPCFG_AUTOSW (_U_(0x1) << HSTPIPCFG_AUTOSW_Pos) /**< (HSTPIPCFG) Automatic Switch Mask */ +#define HSTPIPCFG_PTYPE_Pos 12 /**< (HSTPIPCFG) Pipe Type Position */ +#define HSTPIPCFG_PTYPE (_U_(0x3) << HSTPIPCFG_PTYPE_Pos) /**< (HSTPIPCFG) Pipe Type Mask */ +#define HSTPIPCFG_PTYPE_CTRL_Val _U_(0x0) /**< (HSTPIPCFG) Control */ +#define HSTPIPCFG_PTYPE_ISO_Val _U_(0x1) /**< (HSTPIPCFG) Isochronous */ +#define HSTPIPCFG_PTYPE_BLK_Val _U_(0x2) /**< (HSTPIPCFG) Bulk */ +#define HSTPIPCFG_PTYPE_INTRPT_Val _U_(0x3) /**< (HSTPIPCFG) Interrupt */ +#define HSTPIPCFG_PTYPE_CTRL (HSTPIPCFG_PTYPE_CTRL_Val << HSTPIPCFG_PTYPE_Pos) /**< (HSTPIPCFG) Control Position */ +#define HSTPIPCFG_PTYPE_ISO (HSTPIPCFG_PTYPE_ISO_Val << HSTPIPCFG_PTYPE_Pos) /**< (HSTPIPCFG) Isochronous Position */ +#define HSTPIPCFG_PTYPE_BLK (HSTPIPCFG_PTYPE_BLK_Val << HSTPIPCFG_PTYPE_Pos) /**< (HSTPIPCFG) Bulk Position */ +#define HSTPIPCFG_PTYPE_INTRPT (HSTPIPCFG_PTYPE_INTRPT_Val << HSTPIPCFG_PTYPE_Pos) /**< (HSTPIPCFG) Interrupt Position */ +#define HSTPIPCFG_PEPNUM_Pos 16 /**< (HSTPIPCFG) Pipe Endpoint Number Position */ +#define HSTPIPCFG_PEPNUM (_U_(0xF) << HSTPIPCFG_PEPNUM_Pos) /**< (HSTPIPCFG) Pipe Endpoint Number Mask */ +#define HSTPIPCFG_INTFRQ_Pos 24 /**< (HSTPIPCFG) Pipe Interrupt Request Frequency Position */ +#define HSTPIPCFG_INTFRQ (_U_(0xFF) << HSTPIPCFG_INTFRQ_Pos) /**< (HSTPIPCFG) Pipe Interrupt Request Frequency Mask */ +#define HSTPIPCFG_Msk _U_(0xFF0F377E) /**< (HSTPIPCFG) Register Mask */ + +/* CTRL_BULK mode */ +#define HSTPIPCFG_CTRL_BULK_PINGEN_Pos 20 /**< (HSTPIPCFG) Ping Enable Position */ +#define HSTPIPCFG_CTRL_BULK_PINGEN (_U_(0x1) << HSTPIPCFG_CTRL_BULK_PINGEN_Pos) /**< (HSTPIPCFG) Ping Enable Mask */ +#define HSTPIPCFG_CTRL_BULK_BINTERVAL_Pos 24 /**< (HSTPIPCFG) bInterval Parameter for the Bulk-Out/Ping Transaction Position */ +#define HSTPIPCFG_CTRL_BULK_BINTERVAL (_U_(0xFF) << HSTPIPCFG_CTRL_BULK_BINTERVAL_Pos) /**< (HSTPIPCFG) bInterval Parameter for the Bulk-Out/Ping Transaction Mask */ +#define HSTPIPCFG_CTRL_BULK_Msk _U_(0xFF100000) /**< (HSTPIPCFG_CTRL_BULK) Register Mask */ + + +/* -------- HSTPIPISR : (USBHS Offset: 0x530) (R/ 32) Host Pipe Status Register -------- */ + +#define HSTPIPISR_OFFSET (0x530) /**< (HSTPIPISR) Host Pipe Status Register Offset */ + +#define HSTPIPISR_RXINI_Pos 0 /**< (HSTPIPISR) Received IN Data Interrupt Position */ +#define HSTPIPISR_RXINI (_U_(0x1) << HSTPIPISR_RXINI_Pos) /**< (HSTPIPISR) Received IN Data Interrupt Mask */ +#define HSTPIPISR_TXOUTI_Pos 1 /**< (HSTPIPISR) Transmitted OUT Data Interrupt Position */ +#define HSTPIPISR_TXOUTI (_U_(0x1) << HSTPIPISR_TXOUTI_Pos) /**< (HSTPIPISR) Transmitted OUT Data Interrupt Mask */ +#define HSTPIPISR_PERRI_Pos 3 /**< (HSTPIPISR) Pipe Error Interrupt Position */ +#define HSTPIPISR_PERRI (_U_(0x1) << HSTPIPISR_PERRI_Pos) /**< (HSTPIPISR) Pipe Error Interrupt Mask */ +#define HSTPIPISR_NAKEDI_Pos 4 /**< (HSTPIPISR) NAKed Interrupt Position */ +#define HSTPIPISR_NAKEDI (_U_(0x1) << HSTPIPISR_NAKEDI_Pos) /**< (HSTPIPISR) NAKed Interrupt Mask */ +#define HSTPIPISR_OVERFI_Pos 5 /**< (HSTPIPISR) Overflow Interrupt Position */ +#define HSTPIPISR_OVERFI (_U_(0x1) << HSTPIPISR_OVERFI_Pos) /**< (HSTPIPISR) Overflow Interrupt Mask */ +#define HSTPIPISR_SHORTPACKETI_Pos 7 /**< (HSTPIPISR) Short Packet Interrupt Position */ +#define HSTPIPISR_SHORTPACKETI (_U_(0x1) << HSTPIPISR_SHORTPACKETI_Pos) /**< (HSTPIPISR) Short Packet Interrupt Mask */ +#define HSTPIPISR_DTSEQ_Pos 8 /**< (HSTPIPISR) Data Toggle Sequence Position */ +#define HSTPIPISR_DTSEQ (_U_(0x3) << HSTPIPISR_DTSEQ_Pos) /**< (HSTPIPISR) Data Toggle Sequence Mask */ +#define HSTPIPISR_DTSEQ_DATA0_Val _U_(0x0) /**< (HSTPIPISR) Data0 toggle sequence */ +#define HSTPIPISR_DTSEQ_DATA1_Val _U_(0x1) /**< (HSTPIPISR) Data1 toggle sequence */ +#define HSTPIPISR_DTSEQ_DATA0 (HSTPIPISR_DTSEQ_DATA0_Val << HSTPIPISR_DTSEQ_Pos) /**< (HSTPIPISR) Data0 toggle sequence Position */ +#define HSTPIPISR_DTSEQ_DATA1 (HSTPIPISR_DTSEQ_DATA1_Val << HSTPIPISR_DTSEQ_Pos) /**< (HSTPIPISR) Data1 toggle sequence Position */ +#define HSTPIPISR_NBUSYBK_Pos 12 /**< (HSTPIPISR) Number of Busy Banks Position */ +#define HSTPIPISR_NBUSYBK (_U_(0x3) << HSTPIPISR_NBUSYBK_Pos) /**< (HSTPIPISR) Number of Busy Banks Mask */ +#define HSTPIPISR_NBUSYBK_0_BUSY_Val _U_(0x0) /**< (HSTPIPISR) 0 busy bank (all banks free) */ +#define HSTPIPISR_NBUSYBK_1_BUSY_Val _U_(0x1) /**< (HSTPIPISR) 1 busy bank */ +#define HSTPIPISR_NBUSYBK_2_BUSY_Val _U_(0x2) /**< (HSTPIPISR) 2 busy banks */ +#define HSTPIPISR_NBUSYBK_3_BUSY_Val _U_(0x3) /**< (HSTPIPISR) 3 busy banks */ +#define HSTPIPISR_NBUSYBK_0_BUSY (HSTPIPISR_NBUSYBK_0_BUSY_Val << HSTPIPISR_NBUSYBK_Pos) /**< (HSTPIPISR) 0 busy bank (all banks free) Position */ +#define HSTPIPISR_NBUSYBK_1_BUSY (HSTPIPISR_NBUSYBK_1_BUSY_Val << HSTPIPISR_NBUSYBK_Pos) /**< (HSTPIPISR) 1 busy bank Position */ +#define HSTPIPISR_NBUSYBK_2_BUSY (HSTPIPISR_NBUSYBK_2_BUSY_Val << HSTPIPISR_NBUSYBK_Pos) /**< (HSTPIPISR) 2 busy banks Position */ +#define HSTPIPISR_NBUSYBK_3_BUSY (HSTPIPISR_NBUSYBK_3_BUSY_Val << HSTPIPISR_NBUSYBK_Pos) /**< (HSTPIPISR) 3 busy banks Position */ +#define HSTPIPISR_CURRBK_Pos 14 /**< (HSTPIPISR) Current Bank Position */ +#define HSTPIPISR_CURRBK (_U_(0x3) << HSTPIPISR_CURRBK_Pos) /**< (HSTPIPISR) Current Bank Mask */ +#define HSTPIPISR_CURRBK_BANK0_Val _U_(0x0) /**< (HSTPIPISR) Current bank is bank0 */ +#define HSTPIPISR_CURRBK_BANK1_Val _U_(0x1) /**< (HSTPIPISR) Current bank is bank1 */ +#define HSTPIPISR_CURRBK_BANK2_Val _U_(0x2) /**< (HSTPIPISR) Current bank is bank2 */ +#define HSTPIPISR_CURRBK_BANK0 (HSTPIPISR_CURRBK_BANK0_Val << HSTPIPISR_CURRBK_Pos) /**< (HSTPIPISR) Current bank is bank0 Position */ +#define HSTPIPISR_CURRBK_BANK1 (HSTPIPISR_CURRBK_BANK1_Val << HSTPIPISR_CURRBK_Pos) /**< (HSTPIPISR) Current bank is bank1 Position */ +#define HSTPIPISR_CURRBK_BANK2 (HSTPIPISR_CURRBK_BANK2_Val << HSTPIPISR_CURRBK_Pos) /**< (HSTPIPISR) Current bank is bank2 Position */ +#define HSTPIPISR_RWALL_Pos 16 /**< (HSTPIPISR) Read/Write Allowed Position */ +#define HSTPIPISR_RWALL (_U_(0x1) << HSTPIPISR_RWALL_Pos) /**< (HSTPIPISR) Read/Write Allowed Mask */ +#define HSTPIPISR_CFGOK_Pos 18 /**< (HSTPIPISR) Configuration OK Status Position */ +#define HSTPIPISR_CFGOK (_U_(0x1) << HSTPIPISR_CFGOK_Pos) /**< (HSTPIPISR) Configuration OK Status Mask */ +#define HSTPIPISR_PBYCT_Pos 20 /**< (HSTPIPISR) Pipe Byte Count Position */ +#define HSTPIPISR_PBYCT (_U_(0x7FF) << HSTPIPISR_PBYCT_Pos) /**< (HSTPIPISR) Pipe Byte Count Mask */ +#define HSTPIPISR_Msk _U_(0x7FF5F3BB) /**< (HSTPIPISR) Register Mask */ + +/* CTRL mode */ +#define HSTPIPISR_CTRL_TXSTPI_Pos 2 /**< (HSTPIPISR) Transmitted SETUP Interrupt Position */ +#define HSTPIPISR_CTRL_TXSTPI (_U_(0x1) << HSTPIPISR_CTRL_TXSTPI_Pos) /**< (HSTPIPISR) Transmitted SETUP Interrupt Mask */ +#define HSTPIPISR_CTRL_RXSTALLDI_Pos 6 /**< (HSTPIPISR) Received STALLed Interrupt Position */ +#define HSTPIPISR_CTRL_RXSTALLDI (_U_(0x1) << HSTPIPISR_CTRL_RXSTALLDI_Pos) /**< (HSTPIPISR) Received STALLed Interrupt Mask */ +#define HSTPIPISR_CTRL_Msk _U_(0x44) /**< (HSTPIPISR_CTRL) Register Mask */ + +/* ISO mode */ +#define HSTPIPISR_ISO_UNDERFI_Pos 2 /**< (HSTPIPISR) Underflow Interrupt Position */ +#define HSTPIPISR_ISO_UNDERFI (_U_(0x1) << HSTPIPISR_ISO_UNDERFI_Pos) /**< (HSTPIPISR) Underflow Interrupt Mask */ +#define HSTPIPISR_ISO_CRCERRI_Pos 6 /**< (HSTPIPISR) CRC Error Interrupt Position */ +#define HSTPIPISR_ISO_CRCERRI (_U_(0x1) << HSTPIPISR_ISO_CRCERRI_Pos) /**< (HSTPIPISR) CRC Error Interrupt Mask */ +#define HSTPIPISR_ISO_Msk _U_(0x44) /**< (HSTPIPISR_ISO) Register Mask */ + +/* BLK mode */ +#define HSTPIPISR_BLK_TXSTPI_Pos 2 /**< (HSTPIPISR) Transmitted SETUP Interrupt Position */ +#define HSTPIPISR_BLK_TXSTPI (_U_(0x1) << HSTPIPISR_BLK_TXSTPI_Pos) /**< (HSTPIPISR) Transmitted SETUP Interrupt Mask */ +#define HSTPIPISR_BLK_RXSTALLDI_Pos 6 /**< (HSTPIPISR) Received STALLed Interrupt Position */ +#define HSTPIPISR_BLK_RXSTALLDI (_U_(0x1) << HSTPIPISR_BLK_RXSTALLDI_Pos) /**< (HSTPIPISR) Received STALLed Interrupt Mask */ +#define HSTPIPISR_BLK_Msk _U_(0x44) /**< (HSTPIPISR_BLK) Register Mask */ + +/* INTRPT mode */ +#define HSTPIPISR_INTRPT_UNDERFI_Pos 2 /**< (HSTPIPISR) Underflow Interrupt Position */ +#define HSTPIPISR_INTRPT_UNDERFI (_U_(0x1) << HSTPIPISR_INTRPT_UNDERFI_Pos) /**< (HSTPIPISR) Underflow Interrupt Mask */ +#define HSTPIPISR_INTRPT_RXSTALLDI_Pos 6 /**< (HSTPIPISR) Received STALLed Interrupt Position */ +#define HSTPIPISR_INTRPT_RXSTALLDI (_U_(0x1) << HSTPIPISR_INTRPT_RXSTALLDI_Pos) /**< (HSTPIPISR) Received STALLed Interrupt Mask */ +#define HSTPIPISR_INTRPT_Msk _U_(0x44) /**< (HSTPIPISR_INTRPT) Register Mask */ + + +/* -------- HSTPIPICR : (USBHS Offset: 0x560) (/W 32) Host Pipe Clear Register -------- */ + +#define HSTPIPICR_OFFSET (0x560) /**< (HSTPIPICR) Host Pipe Clear Register Offset */ + +#define HSTPIPICR_RXINIC_Pos 0 /**< (HSTPIPICR) Received IN Data Interrupt Clear Position */ +#define HSTPIPICR_RXINIC (_U_(0x1) << HSTPIPICR_RXINIC_Pos) /**< (HSTPIPICR) Received IN Data Interrupt Clear Mask */ +#define HSTPIPICR_TXOUTIC_Pos 1 /**< (HSTPIPICR) Transmitted OUT Data Interrupt Clear Position */ +#define HSTPIPICR_TXOUTIC (_U_(0x1) << HSTPIPICR_TXOUTIC_Pos) /**< (HSTPIPICR) Transmitted OUT Data Interrupt Clear Mask */ +#define HSTPIPICR_NAKEDIC_Pos 4 /**< (HSTPIPICR) NAKed Interrupt Clear Position */ +#define HSTPIPICR_NAKEDIC (_U_(0x1) << HSTPIPICR_NAKEDIC_Pos) /**< (HSTPIPICR) NAKed Interrupt Clear Mask */ +#define HSTPIPICR_OVERFIC_Pos 5 /**< (HSTPIPICR) Overflow Interrupt Clear Position */ +#define HSTPIPICR_OVERFIC (_U_(0x1) << HSTPIPICR_OVERFIC_Pos) /**< (HSTPIPICR) Overflow Interrupt Clear Mask */ +#define HSTPIPICR_SHORTPACKETIC_Pos 7 /**< (HSTPIPICR) Short Packet Interrupt Clear Position */ +#define HSTPIPICR_SHORTPACKETIC (_U_(0x1) << HSTPIPICR_SHORTPACKETIC_Pos) /**< (HSTPIPICR) Short Packet Interrupt Clear Mask */ +#define HSTPIPICR_Msk _U_(0xB3) /**< (HSTPIPICR) Register Mask */ + +/* CTRL mode */ +#define HSTPIPICR_CTRL_TXSTPIC_Pos 2 /**< (HSTPIPICR) Transmitted SETUP Interrupt Clear Position */ +#define HSTPIPICR_CTRL_TXSTPIC (_U_(0x1) << HSTPIPICR_CTRL_TXSTPIC_Pos) /**< (HSTPIPICR) Transmitted SETUP Interrupt Clear Mask */ +#define HSTPIPICR_CTRL_RXSTALLDIC_Pos 6 /**< (HSTPIPICR) Received STALLed Interrupt Clear Position */ +#define HSTPIPICR_CTRL_RXSTALLDIC (_U_(0x1) << HSTPIPICR_CTRL_RXSTALLDIC_Pos) /**< (HSTPIPICR) Received STALLed Interrupt Clear Mask */ +#define HSTPIPICR_CTRL_Msk _U_(0x44) /**< (HSTPIPICR_CTRL) Register Mask */ + +/* ISO mode */ +#define HSTPIPICR_ISO_UNDERFIC_Pos 2 /**< (HSTPIPICR) Underflow Interrupt Clear Position */ +#define HSTPIPICR_ISO_UNDERFIC (_U_(0x1) << HSTPIPICR_ISO_UNDERFIC_Pos) /**< (HSTPIPICR) Underflow Interrupt Clear Mask */ +#define HSTPIPICR_ISO_CRCERRIC_Pos 6 /**< (HSTPIPICR) CRC Error Interrupt Clear Position */ +#define HSTPIPICR_ISO_CRCERRIC (_U_(0x1) << HSTPIPICR_ISO_CRCERRIC_Pos) /**< (HSTPIPICR) CRC Error Interrupt Clear Mask */ +#define HSTPIPICR_ISO_Msk _U_(0x44) /**< (HSTPIPICR_ISO) Register Mask */ + +/* BLK mode */ +#define HSTPIPICR_BLK_TXSTPIC_Pos 2 /**< (HSTPIPICR) Transmitted SETUP Interrupt Clear Position */ +#define HSTPIPICR_BLK_TXSTPIC (_U_(0x1) << HSTPIPICR_BLK_TXSTPIC_Pos) /**< (HSTPIPICR) Transmitted SETUP Interrupt Clear Mask */ +#define HSTPIPICR_BLK_RXSTALLDIC_Pos 6 /**< (HSTPIPICR) Received STALLed Interrupt Clear Position */ +#define HSTPIPICR_BLK_RXSTALLDIC (_U_(0x1) << HSTPIPICR_BLK_RXSTALLDIC_Pos) /**< (HSTPIPICR) Received STALLed Interrupt Clear Mask */ +#define HSTPIPICR_BLK_Msk _U_(0x44) /**< (HSTPIPICR_BLK) Register Mask */ + +/* INTRPT mode */ +#define HSTPIPICR_INTRPT_UNDERFIC_Pos 2 /**< (HSTPIPICR) Underflow Interrupt Clear Position */ +#define HSTPIPICR_INTRPT_UNDERFIC (_U_(0x1) << HSTPIPICR_INTRPT_UNDERFIC_Pos) /**< (HSTPIPICR) Underflow Interrupt Clear Mask */ +#define HSTPIPICR_INTRPT_RXSTALLDIC_Pos 6 /**< (HSTPIPICR) Received STALLed Interrupt Clear Position */ +#define HSTPIPICR_INTRPT_RXSTALLDIC (_U_(0x1) << HSTPIPICR_INTRPT_RXSTALLDIC_Pos) /**< (HSTPIPICR) Received STALLed Interrupt Clear Mask */ +#define HSTPIPICR_INTRPT_Msk _U_(0x44) /**< (HSTPIPICR_INTRPT) Register Mask */ + + +/* -------- HSTPIPIFR : (USBHS Offset: 0x590) (/W 32) Host Pipe Set Register -------- */ + +#define HSTPIPIFR_OFFSET (0x590) /**< (HSTPIPIFR) Host Pipe Set Register Offset */ + +#define HSTPIPIFR_RXINIS_Pos 0 /**< (HSTPIPIFR) Received IN Data Interrupt Set Position */ +#define HSTPIPIFR_RXINIS (_U_(0x1) << HSTPIPIFR_RXINIS_Pos) /**< (HSTPIPIFR) Received IN Data Interrupt Set Mask */ +#define HSTPIPIFR_TXOUTIS_Pos 1 /**< (HSTPIPIFR) Transmitted OUT Data Interrupt Set Position */ +#define HSTPIPIFR_TXOUTIS (_U_(0x1) << HSTPIPIFR_TXOUTIS_Pos) /**< (HSTPIPIFR) Transmitted OUT Data Interrupt Set Mask */ +#define HSTPIPIFR_PERRIS_Pos 3 /**< (HSTPIPIFR) Pipe Error Interrupt Set Position */ +#define HSTPIPIFR_PERRIS (_U_(0x1) << HSTPIPIFR_PERRIS_Pos) /**< (HSTPIPIFR) Pipe Error Interrupt Set Mask */ +#define HSTPIPIFR_NAKEDIS_Pos 4 /**< (HSTPIPIFR) NAKed Interrupt Set Position */ +#define HSTPIPIFR_NAKEDIS (_U_(0x1) << HSTPIPIFR_NAKEDIS_Pos) /**< (HSTPIPIFR) NAKed Interrupt Set Mask */ +#define HSTPIPIFR_OVERFIS_Pos 5 /**< (HSTPIPIFR) Overflow Interrupt Set Position */ +#define HSTPIPIFR_OVERFIS (_U_(0x1) << HSTPIPIFR_OVERFIS_Pos) /**< (HSTPIPIFR) Overflow Interrupt Set Mask */ +#define HSTPIPIFR_SHORTPACKETIS_Pos 7 /**< (HSTPIPIFR) Short Packet Interrupt Set Position */ +#define HSTPIPIFR_SHORTPACKETIS (_U_(0x1) << HSTPIPIFR_SHORTPACKETIS_Pos) /**< (HSTPIPIFR) Short Packet Interrupt Set Mask */ +#define HSTPIPIFR_NBUSYBKS_Pos 12 /**< (HSTPIPIFR) Number of Busy Banks Set Position */ +#define HSTPIPIFR_NBUSYBKS (_U_(0x1) << HSTPIPIFR_NBUSYBKS_Pos) /**< (HSTPIPIFR) Number of Busy Banks Set Mask */ +#define HSTPIPIFR_Msk _U_(0x10BB) /**< (HSTPIPIFR) Register Mask */ + +/* CTRL mode */ +#define HSTPIPIFR_CTRL_TXSTPIS_Pos 2 /**< (HSTPIPIFR) Transmitted SETUP Interrupt Set Position */ +#define HSTPIPIFR_CTRL_TXSTPIS (_U_(0x1) << HSTPIPIFR_CTRL_TXSTPIS_Pos) /**< (HSTPIPIFR) Transmitted SETUP Interrupt Set Mask */ +#define HSTPIPIFR_CTRL_RXSTALLDIS_Pos 6 /**< (HSTPIPIFR) Received STALLed Interrupt Set Position */ +#define HSTPIPIFR_CTRL_RXSTALLDIS (_U_(0x1) << HSTPIPIFR_CTRL_RXSTALLDIS_Pos) /**< (HSTPIPIFR) Received STALLed Interrupt Set Mask */ +#define HSTPIPIFR_CTRL_Msk _U_(0x44) /**< (HSTPIPIFR_CTRL) Register Mask */ + +/* ISO mode */ +#define HSTPIPIFR_ISO_UNDERFIS_Pos 2 /**< (HSTPIPIFR) Underflow Interrupt Set Position */ +#define HSTPIPIFR_ISO_UNDERFIS (_U_(0x1) << HSTPIPIFR_ISO_UNDERFIS_Pos) /**< (HSTPIPIFR) Underflow Interrupt Set Mask */ +#define HSTPIPIFR_ISO_CRCERRIS_Pos 6 /**< (HSTPIPIFR) CRC Error Interrupt Set Position */ +#define HSTPIPIFR_ISO_CRCERRIS (_U_(0x1) << HSTPIPIFR_ISO_CRCERRIS_Pos) /**< (HSTPIPIFR) CRC Error Interrupt Set Mask */ +#define HSTPIPIFR_ISO_Msk _U_(0x44) /**< (HSTPIPIFR_ISO) Register Mask */ + +/* BLK mode */ +#define HSTPIPIFR_BLK_TXSTPIS_Pos 2 /**< (HSTPIPIFR) Transmitted SETUP Interrupt Set Position */ +#define HSTPIPIFR_BLK_TXSTPIS (_U_(0x1) << HSTPIPIFR_BLK_TXSTPIS_Pos) /**< (HSTPIPIFR) Transmitted SETUP Interrupt Set Mask */ +#define HSTPIPIFR_BLK_RXSTALLDIS_Pos 6 /**< (HSTPIPIFR) Received STALLed Interrupt Set Position */ +#define HSTPIPIFR_BLK_RXSTALLDIS (_U_(0x1) << HSTPIPIFR_BLK_RXSTALLDIS_Pos) /**< (HSTPIPIFR) Received STALLed Interrupt Set Mask */ +#define HSTPIPIFR_BLK_Msk _U_(0x44) /**< (HSTPIPIFR_BLK) Register Mask */ + +/* INTRPT mode */ +#define HSTPIPIFR_INTRPT_UNDERFIS_Pos 2 /**< (HSTPIPIFR) Underflow Interrupt Set Position */ +#define HSTPIPIFR_INTRPT_UNDERFIS (_U_(0x1) << HSTPIPIFR_INTRPT_UNDERFIS_Pos) /**< (HSTPIPIFR) Underflow Interrupt Set Mask */ +#define HSTPIPIFR_INTRPT_RXSTALLDIS_Pos 6 /**< (HSTPIPIFR) Received STALLed Interrupt Set Position */ +#define HSTPIPIFR_INTRPT_RXSTALLDIS (_U_(0x1) << HSTPIPIFR_INTRPT_RXSTALLDIS_Pos) /**< (HSTPIPIFR) Received STALLed Interrupt Set Mask */ +#define HSTPIPIFR_INTRPT_Msk _U_(0x44) /**< (HSTPIPIFR_INTRPT) Register Mask */ + + +/* -------- HSTPIPIMR : (USBHS Offset: 0x5c0) (R/ 32) Host Pipe Mask Register -------- */ + +#define HSTPIPIMR_OFFSET (0x5C0) /**< (HSTPIPIMR) Host Pipe Mask Register Offset */ + +#define HSTPIPIMR_RXINE_Pos 0 /**< (HSTPIPIMR) Received IN Data Interrupt Enable Position */ +#define HSTPIPIMR_RXINE (_U_(0x1) << HSTPIPIMR_RXINE_Pos) /**< (HSTPIPIMR) Received IN Data Interrupt Enable Mask */ +#define HSTPIPIMR_TXOUTE_Pos 1 /**< (HSTPIPIMR) Transmitted OUT Data Interrupt Enable Position */ +#define HSTPIPIMR_TXOUTE (_U_(0x1) << HSTPIPIMR_TXOUTE_Pos) /**< (HSTPIPIMR) Transmitted OUT Data Interrupt Enable Mask */ +#define HSTPIPIMR_PERRE_Pos 3 /**< (HSTPIPIMR) Pipe Error Interrupt Enable Position */ +#define HSTPIPIMR_PERRE (_U_(0x1) << HSTPIPIMR_PERRE_Pos) /**< (HSTPIPIMR) Pipe Error Interrupt Enable Mask */ +#define HSTPIPIMR_NAKEDE_Pos 4 /**< (HSTPIPIMR) NAKed Interrupt Enable Position */ +#define HSTPIPIMR_NAKEDE (_U_(0x1) << HSTPIPIMR_NAKEDE_Pos) /**< (HSTPIPIMR) NAKed Interrupt Enable Mask */ +#define HSTPIPIMR_OVERFIE_Pos 5 /**< (HSTPIPIMR) Overflow Interrupt Enable Position */ +#define HSTPIPIMR_OVERFIE (_U_(0x1) << HSTPIPIMR_OVERFIE_Pos) /**< (HSTPIPIMR) Overflow Interrupt Enable Mask */ +#define HSTPIPIMR_SHORTPACKETIE_Pos 7 /**< (HSTPIPIMR) Short Packet Interrupt Enable Position */ +#define HSTPIPIMR_SHORTPACKETIE (_U_(0x1) << HSTPIPIMR_SHORTPACKETIE_Pos) /**< (HSTPIPIMR) Short Packet Interrupt Enable Mask */ +#define HSTPIPIMR_NBUSYBKE_Pos 12 /**< (HSTPIPIMR) Number of Busy Banks Interrupt Enable Position */ +#define HSTPIPIMR_NBUSYBKE (_U_(0x1) << HSTPIPIMR_NBUSYBKE_Pos) /**< (HSTPIPIMR) Number of Busy Banks Interrupt Enable Mask */ +#define HSTPIPIMR_FIFOCON_Pos 14 /**< (HSTPIPIMR) FIFO Control Position */ +#define HSTPIPIMR_FIFOCON (_U_(0x1) << HSTPIPIMR_FIFOCON_Pos) /**< (HSTPIPIMR) FIFO Control Mask */ +#define HSTPIPIMR_PDISHDMA_Pos 16 /**< (HSTPIPIMR) Pipe Interrupts Disable HDMA Request Enable Position */ +#define HSTPIPIMR_PDISHDMA (_U_(0x1) << HSTPIPIMR_PDISHDMA_Pos) /**< (HSTPIPIMR) Pipe Interrupts Disable HDMA Request Enable Mask */ +#define HSTPIPIMR_PFREEZE_Pos 17 /**< (HSTPIPIMR) Pipe Freeze Position */ +#define HSTPIPIMR_PFREEZE (_U_(0x1) << HSTPIPIMR_PFREEZE_Pos) /**< (HSTPIPIMR) Pipe Freeze Mask */ +#define HSTPIPIMR_RSTDT_Pos 18 /**< (HSTPIPIMR) Reset Data Toggle Position */ +#define HSTPIPIMR_RSTDT (_U_(0x1) << HSTPIPIMR_RSTDT_Pos) /**< (HSTPIPIMR) Reset Data Toggle Mask */ +#define HSTPIPIMR_Msk _U_(0x750BB) /**< (HSTPIPIMR) Register Mask */ + +/* CTRL mode */ +#define HSTPIPIMR_CTRL_TXSTPE_Pos 2 /**< (HSTPIPIMR) Transmitted SETUP Interrupt Enable Position */ +#define HSTPIPIMR_CTRL_TXSTPE (_U_(0x1) << HSTPIPIMR_CTRL_TXSTPE_Pos) /**< (HSTPIPIMR) Transmitted SETUP Interrupt Enable Mask */ +#define HSTPIPIMR_CTRL_RXSTALLDE_Pos 6 /**< (HSTPIPIMR) Received STALLed Interrupt Enable Position */ +#define HSTPIPIMR_CTRL_RXSTALLDE (_U_(0x1) << HSTPIPIMR_CTRL_RXSTALLDE_Pos) /**< (HSTPIPIMR) Received STALLed Interrupt Enable Mask */ +#define HSTPIPIMR_CTRL_Msk _U_(0x44) /**< (HSTPIPIMR_CTRL) Register Mask */ + +/* ISO mode */ +#define HSTPIPIMR_ISO_UNDERFIE_Pos 2 /**< (HSTPIPIMR) Underflow Interrupt Enable Position */ +#define HSTPIPIMR_ISO_UNDERFIE (_U_(0x1) << HSTPIPIMR_ISO_UNDERFIE_Pos) /**< (HSTPIPIMR) Underflow Interrupt Enable Mask */ +#define HSTPIPIMR_ISO_CRCERRE_Pos 6 /**< (HSTPIPIMR) CRC Error Interrupt Enable Position */ +#define HSTPIPIMR_ISO_CRCERRE (_U_(0x1) << HSTPIPIMR_ISO_CRCERRE_Pos) /**< (HSTPIPIMR) CRC Error Interrupt Enable Mask */ +#define HSTPIPIMR_ISO_Msk _U_(0x44) /**< (HSTPIPIMR_ISO) Register Mask */ + +/* BLK mode */ +#define HSTPIPIMR_BLK_TXSTPE_Pos 2 /**< (HSTPIPIMR) Transmitted SETUP Interrupt Enable Position */ +#define HSTPIPIMR_BLK_TXSTPE (_U_(0x1) << HSTPIPIMR_BLK_TXSTPE_Pos) /**< (HSTPIPIMR) Transmitted SETUP Interrupt Enable Mask */ +#define HSTPIPIMR_BLK_RXSTALLDE_Pos 6 /**< (HSTPIPIMR) Received STALLed Interrupt Enable Position */ +#define HSTPIPIMR_BLK_RXSTALLDE (_U_(0x1) << HSTPIPIMR_BLK_RXSTALLDE_Pos) /**< (HSTPIPIMR) Received STALLed Interrupt Enable Mask */ +#define HSTPIPIMR_BLK_Msk _U_(0x44) /**< (HSTPIPIMR_BLK) Register Mask */ + +/* INTRPT mode */ +#define HSTPIPIMR_INTRPT_UNDERFIE_Pos 2 /**< (HSTPIPIMR) Underflow Interrupt Enable Position */ +#define HSTPIPIMR_INTRPT_UNDERFIE (_U_(0x1) << HSTPIPIMR_INTRPT_UNDERFIE_Pos) /**< (HSTPIPIMR) Underflow Interrupt Enable Mask */ +#define HSTPIPIMR_INTRPT_RXSTALLDE_Pos 6 /**< (HSTPIPIMR) Received STALLed Interrupt Enable Position */ +#define HSTPIPIMR_INTRPT_RXSTALLDE (_U_(0x1) << HSTPIPIMR_INTRPT_RXSTALLDE_Pos) /**< (HSTPIPIMR) Received STALLed Interrupt Enable Mask */ +#define HSTPIPIMR_INTRPT_Msk _U_(0x44) /**< (HSTPIPIMR_INTRPT) Register Mask */ + + +/* -------- HSTPIPIER : (USBHS Offset: 0x5f0) (/W 32) Host Pipe Enable Register -------- */ + +#define HSTPIPIER_OFFSET (0x5F0) /**< (HSTPIPIER) Host Pipe Enable Register Offset */ + +#define HSTPIPIER_RXINES_Pos 0 /**< (HSTPIPIER) Received IN Data Interrupt Enable Position */ +#define HSTPIPIER_RXINES (_U_(0x1) << HSTPIPIER_RXINES_Pos) /**< (HSTPIPIER) Received IN Data Interrupt Enable Mask */ +#define HSTPIPIER_TXOUTES_Pos 1 /**< (HSTPIPIER) Transmitted OUT Data Interrupt Enable Position */ +#define HSTPIPIER_TXOUTES (_U_(0x1) << HSTPIPIER_TXOUTES_Pos) /**< (HSTPIPIER) Transmitted OUT Data Interrupt Enable Mask */ +#define HSTPIPIER_PERRES_Pos 3 /**< (HSTPIPIER) Pipe Error Interrupt Enable Position */ +#define HSTPIPIER_PERRES (_U_(0x1) << HSTPIPIER_PERRES_Pos) /**< (HSTPIPIER) Pipe Error Interrupt Enable Mask */ +#define HSTPIPIER_NAKEDES_Pos 4 /**< (HSTPIPIER) NAKed Interrupt Enable Position */ +#define HSTPIPIER_NAKEDES (_U_(0x1) << HSTPIPIER_NAKEDES_Pos) /**< (HSTPIPIER) NAKed Interrupt Enable Mask */ +#define HSTPIPIER_OVERFIES_Pos 5 /**< (HSTPIPIER) Overflow Interrupt Enable Position */ +#define HSTPIPIER_OVERFIES (_U_(0x1) << HSTPIPIER_OVERFIES_Pos) /**< (HSTPIPIER) Overflow Interrupt Enable Mask */ +#define HSTPIPIER_SHORTPACKETIES_Pos 7 /**< (HSTPIPIER) Short Packet Interrupt Enable Position */ +#define HSTPIPIER_SHORTPACKETIES (_U_(0x1) << HSTPIPIER_SHORTPACKETIES_Pos) /**< (HSTPIPIER) Short Packet Interrupt Enable Mask */ +#define HSTPIPIER_NBUSYBKES_Pos 12 /**< (HSTPIPIER) Number of Busy Banks Enable Position */ +#define HSTPIPIER_NBUSYBKES (_U_(0x1) << HSTPIPIER_NBUSYBKES_Pos) /**< (HSTPIPIER) Number of Busy Banks Enable Mask */ +#define HSTPIPIER_PDISHDMAS_Pos 16 /**< (HSTPIPIER) Pipe Interrupts Disable HDMA Request Enable Position */ +#define HSTPIPIER_PDISHDMAS (_U_(0x1) << HSTPIPIER_PDISHDMAS_Pos) /**< (HSTPIPIER) Pipe Interrupts Disable HDMA Request Enable Mask */ +#define HSTPIPIER_PFREEZES_Pos 17 /**< (HSTPIPIER) Pipe Freeze Enable Position */ +#define HSTPIPIER_PFREEZES (_U_(0x1) << HSTPIPIER_PFREEZES_Pos) /**< (HSTPIPIER) Pipe Freeze Enable Mask */ +#define HSTPIPIER_RSTDTS_Pos 18 /**< (HSTPIPIER) Reset Data Toggle Enable Position */ +#define HSTPIPIER_RSTDTS (_U_(0x1) << HSTPIPIER_RSTDTS_Pos) /**< (HSTPIPIER) Reset Data Toggle Enable Mask */ +#define HSTPIPIER_Msk _U_(0x710BB) /**< (HSTPIPIER) Register Mask */ + +/* CTRL mode */ +#define HSTPIPIER_CTRL_TXSTPES_Pos 2 /**< (HSTPIPIER) Transmitted SETUP Interrupt Enable Position */ +#define HSTPIPIER_CTRL_TXSTPES (_U_(0x1) << HSTPIPIER_CTRL_TXSTPES_Pos) /**< (HSTPIPIER) Transmitted SETUP Interrupt Enable Mask */ +#define HSTPIPIER_CTRL_RXSTALLDES_Pos 6 /**< (HSTPIPIER) Received STALLed Interrupt Enable Position */ +#define HSTPIPIER_CTRL_RXSTALLDES (_U_(0x1) << HSTPIPIER_CTRL_RXSTALLDES_Pos) /**< (HSTPIPIER) Received STALLed Interrupt Enable Mask */ +#define HSTPIPIER_CTRL_Msk _U_(0x44) /**< (HSTPIPIER_CTRL) Register Mask */ + +/* ISO mode */ +#define HSTPIPIER_ISO_UNDERFIES_Pos 2 /**< (HSTPIPIER) Underflow Interrupt Enable Position */ +#define HSTPIPIER_ISO_UNDERFIES (_U_(0x1) << HSTPIPIER_ISO_UNDERFIES_Pos) /**< (HSTPIPIER) Underflow Interrupt Enable Mask */ +#define HSTPIPIER_ISO_CRCERRES_Pos 6 /**< (HSTPIPIER) CRC Error Interrupt Enable Position */ +#define HSTPIPIER_ISO_CRCERRES (_U_(0x1) << HSTPIPIER_ISO_CRCERRES_Pos) /**< (HSTPIPIER) CRC Error Interrupt Enable Mask */ +#define HSTPIPIER_ISO_Msk _U_(0x44) /**< (HSTPIPIER_ISO) Register Mask */ + +/* BLK mode */ +#define HSTPIPIER_BLK_TXSTPES_Pos 2 /**< (HSTPIPIER) Transmitted SETUP Interrupt Enable Position */ +#define HSTPIPIER_BLK_TXSTPES (_U_(0x1) << HSTPIPIER_BLK_TXSTPES_Pos) /**< (HSTPIPIER) Transmitted SETUP Interrupt Enable Mask */ +#define HSTPIPIER_BLK_RXSTALLDES_Pos 6 /**< (HSTPIPIER) Received STALLed Interrupt Enable Position */ +#define HSTPIPIER_BLK_RXSTALLDES (_U_(0x1) << HSTPIPIER_BLK_RXSTALLDES_Pos) /**< (HSTPIPIER) Received STALLed Interrupt Enable Mask */ +#define HSTPIPIER_BLK_Msk _U_(0x44) /**< (HSTPIPIER_BLK) Register Mask */ + +/* INTRPT mode */ +#define HSTPIPIER_INTRPT_UNDERFIES_Pos 2 /**< (HSTPIPIER) Underflow Interrupt Enable Position */ +#define HSTPIPIER_INTRPT_UNDERFIES (_U_(0x1) << HSTPIPIER_INTRPT_UNDERFIES_Pos) /**< (HSTPIPIER) Underflow Interrupt Enable Mask */ +#define HSTPIPIER_INTRPT_RXSTALLDES_Pos 6 /**< (HSTPIPIER) Received STALLed Interrupt Enable Position */ +#define HSTPIPIER_INTRPT_RXSTALLDES (_U_(0x1) << HSTPIPIER_INTRPT_RXSTALLDES_Pos) /**< (HSTPIPIER) Received STALLed Interrupt Enable Mask */ +#define HSTPIPIER_INTRPT_Msk _U_(0x44) /**< (HSTPIPIER_INTRPT) Register Mask */ + + +/* -------- HSTPIPIDR : (USBHS Offset: 0x620) (/W 32) Host Pipe Disable Register -------- */ + +#define HSTPIPIDR_OFFSET (0x620) /**< (HSTPIPIDR) Host Pipe Disable Register Offset */ + +#define HSTPIPIDR_RXINEC_Pos 0 /**< (HSTPIPIDR) Received IN Data Interrupt Disable Position */ +#define HSTPIPIDR_RXINEC (_U_(0x1) << HSTPIPIDR_RXINEC_Pos) /**< (HSTPIPIDR) Received IN Data Interrupt Disable Mask */ +#define HSTPIPIDR_TXOUTEC_Pos 1 /**< (HSTPIPIDR) Transmitted OUT Data Interrupt Disable Position */ +#define HSTPIPIDR_TXOUTEC (_U_(0x1) << HSTPIPIDR_TXOUTEC_Pos) /**< (HSTPIPIDR) Transmitted OUT Data Interrupt Disable Mask */ +#define HSTPIPIDR_PERREC_Pos 3 /**< (HSTPIPIDR) Pipe Error Interrupt Disable Position */ +#define HSTPIPIDR_PERREC (_U_(0x1) << HSTPIPIDR_PERREC_Pos) /**< (HSTPIPIDR) Pipe Error Interrupt Disable Mask */ +#define HSTPIPIDR_NAKEDEC_Pos 4 /**< (HSTPIPIDR) NAKed Interrupt Disable Position */ +#define HSTPIPIDR_NAKEDEC (_U_(0x1) << HSTPIPIDR_NAKEDEC_Pos) /**< (HSTPIPIDR) NAKed Interrupt Disable Mask */ +#define HSTPIPIDR_OVERFIEC_Pos 5 /**< (HSTPIPIDR) Overflow Interrupt Disable Position */ +#define HSTPIPIDR_OVERFIEC (_U_(0x1) << HSTPIPIDR_OVERFIEC_Pos) /**< (HSTPIPIDR) Overflow Interrupt Disable Mask */ +#define HSTPIPIDR_SHORTPACKETIEC_Pos 7 /**< (HSTPIPIDR) Short Packet Interrupt Disable Position */ +#define HSTPIPIDR_SHORTPACKETIEC (_U_(0x1) << HSTPIPIDR_SHORTPACKETIEC_Pos) /**< (HSTPIPIDR) Short Packet Interrupt Disable Mask */ +#define HSTPIPIDR_NBUSYBKEC_Pos 12 /**< (HSTPIPIDR) Number of Busy Banks Disable Position */ +#define HSTPIPIDR_NBUSYBKEC (_U_(0x1) << HSTPIPIDR_NBUSYBKEC_Pos) /**< (HSTPIPIDR) Number of Busy Banks Disable Mask */ +#define HSTPIPIDR_FIFOCONC_Pos 14 /**< (HSTPIPIDR) FIFO Control Disable Position */ +#define HSTPIPIDR_FIFOCONC (_U_(0x1) << HSTPIPIDR_FIFOCONC_Pos) /**< (HSTPIPIDR) FIFO Control Disable Mask */ +#define HSTPIPIDR_PDISHDMAC_Pos 16 /**< (HSTPIPIDR) Pipe Interrupts Disable HDMA Request Disable Position */ +#define HSTPIPIDR_PDISHDMAC (_U_(0x1) << HSTPIPIDR_PDISHDMAC_Pos) /**< (HSTPIPIDR) Pipe Interrupts Disable HDMA Request Disable Mask */ +#define HSTPIPIDR_PFREEZEC_Pos 17 /**< (HSTPIPIDR) Pipe Freeze Disable Position */ +#define HSTPIPIDR_PFREEZEC (_U_(0x1) << HSTPIPIDR_PFREEZEC_Pos) /**< (HSTPIPIDR) Pipe Freeze Disable Mask */ +#define HSTPIPIDR_Msk _U_(0x350BB) /**< (HSTPIPIDR) Register Mask */ + +/* CTRL mode */ +#define HSTPIPIDR_CTRL_TXSTPEC_Pos 2 /**< (HSTPIPIDR) Transmitted SETUP Interrupt Disable Position */ +#define HSTPIPIDR_CTRL_TXSTPEC (_U_(0x1) << HSTPIPIDR_CTRL_TXSTPEC_Pos) /**< (HSTPIPIDR) Transmitted SETUP Interrupt Disable Mask */ +#define HSTPIPIDR_CTRL_RXSTALLDEC_Pos 6 /**< (HSTPIPIDR) Received STALLed Interrupt Disable Position */ +#define HSTPIPIDR_CTRL_RXSTALLDEC (_U_(0x1) << HSTPIPIDR_CTRL_RXSTALLDEC_Pos) /**< (HSTPIPIDR) Received STALLed Interrupt Disable Mask */ +#define HSTPIPIDR_CTRL_Msk _U_(0x44) /**< (HSTPIPIDR_CTRL) Register Mask */ + +/* ISO mode */ +#define HSTPIPIDR_ISO_UNDERFIEC_Pos 2 /**< (HSTPIPIDR) Underflow Interrupt Disable Position */ +#define HSTPIPIDR_ISO_UNDERFIEC (_U_(0x1) << HSTPIPIDR_ISO_UNDERFIEC_Pos) /**< (HSTPIPIDR) Underflow Interrupt Disable Mask */ +#define HSTPIPIDR_ISO_CRCERREC_Pos 6 /**< (HSTPIPIDR) CRC Error Interrupt Disable Position */ +#define HSTPIPIDR_ISO_CRCERREC (_U_(0x1) << HSTPIPIDR_ISO_CRCERREC_Pos) /**< (HSTPIPIDR) CRC Error Interrupt Disable Mask */ +#define HSTPIPIDR_ISO_Msk _U_(0x44) /**< (HSTPIPIDR_ISO) Register Mask */ + +/* BLK mode */ +#define HSTPIPIDR_BLK_TXSTPEC_Pos 2 /**< (HSTPIPIDR) Transmitted SETUP Interrupt Disable Position */ +#define HSTPIPIDR_BLK_TXSTPEC (_U_(0x1) << HSTPIPIDR_BLK_TXSTPEC_Pos) /**< (HSTPIPIDR) Transmitted SETUP Interrupt Disable Mask */ +#define HSTPIPIDR_BLK_RXSTALLDEC_Pos 6 /**< (HSTPIPIDR) Received STALLed Interrupt Disable Position */ +#define HSTPIPIDR_BLK_RXSTALLDEC (_U_(0x1) << HSTPIPIDR_BLK_RXSTALLDEC_Pos) /**< (HSTPIPIDR) Received STALLed Interrupt Disable Mask */ +#define HSTPIPIDR_BLK_Msk _U_(0x44) /**< (HSTPIPIDR_BLK) Register Mask */ + +/* INTRPT mode */ +#define HSTPIPIDR_INTRPT_UNDERFIEC_Pos 2 /**< (HSTPIPIDR) Underflow Interrupt Disable Position */ +#define HSTPIPIDR_INTRPT_UNDERFIEC (_U_(0x1) << HSTPIPIDR_INTRPT_UNDERFIEC_Pos) /**< (HSTPIPIDR) Underflow Interrupt Disable Mask */ +#define HSTPIPIDR_INTRPT_RXSTALLDEC_Pos 6 /**< (HSTPIPIDR) Received STALLed Interrupt Disable Position */ +#define HSTPIPIDR_INTRPT_RXSTALLDEC (_U_(0x1) << HSTPIPIDR_INTRPT_RXSTALLDEC_Pos) /**< (HSTPIPIDR) Received STALLed Interrupt Disable Mask */ +#define HSTPIPIDR_INTRPT_Msk _U_(0x44) /**< (HSTPIPIDR_INTRPT) Register Mask */ + + +/* -------- HSTPIPINRQ : (USBHS Offset: 0x650) (R/W 32) Host Pipe IN Request Register -------- */ + +#define HSTPIPINRQ_OFFSET (0x650) /**< (HSTPIPINRQ) Host Pipe IN Request Register Offset */ + +#define HSTPIPINRQ_INRQ_Pos 0 /**< (HSTPIPINRQ) IN Request Number before Freeze Position */ +#define HSTPIPINRQ_INRQ (_U_(0xFF) << HSTPIPINRQ_INRQ_Pos) /**< (HSTPIPINRQ) IN Request Number before Freeze Mask */ +#define HSTPIPINRQ_INMODE_Pos 8 /**< (HSTPIPINRQ) IN Request Mode Position */ +#define HSTPIPINRQ_INMODE (_U_(0x1) << HSTPIPINRQ_INMODE_Pos) /**< (HSTPIPINRQ) IN Request Mode Mask */ +#define HSTPIPINRQ_Msk _U_(0x1FF) /**< (HSTPIPINRQ) Register Mask */ + + +/* -------- HSTPIPERR : (USBHS Offset: 0x680) (R/W 32) Host Pipe Error Register -------- */ + +#define HSTPIPERR_OFFSET (0x680) /**< (HSTPIPERR) Host Pipe Error Register Offset */ + +#define HSTPIPERR_DATATGL_Pos 0 /**< (HSTPIPERR) Data Toggle Error Position */ +#define HSTPIPERR_DATATGL (_U_(0x1) << HSTPIPERR_DATATGL_Pos) /**< (HSTPIPERR) Data Toggle Error Mask */ +#define HSTPIPERR_DATAPID_Pos 1 /**< (HSTPIPERR) Data PID Error Position */ +#define HSTPIPERR_DATAPID (_U_(0x1) << HSTPIPERR_DATAPID_Pos) /**< (HSTPIPERR) Data PID Error Mask */ +#define HSTPIPERR_PID_Pos 2 /**< (HSTPIPERR) Data PID Error Position */ +#define HSTPIPERR_PID (_U_(0x1) << HSTPIPERR_PID_Pos) /**< (HSTPIPERR) Data PID Error Mask */ +#define HSTPIPERR_TIMEOUT_Pos 3 /**< (HSTPIPERR) Time-Out Error Position */ +#define HSTPIPERR_TIMEOUT (_U_(0x1) << HSTPIPERR_TIMEOUT_Pos) /**< (HSTPIPERR) Time-Out Error Mask */ +#define HSTPIPERR_CRC16_Pos 4 /**< (HSTPIPERR) CRC16 Error Position */ +#define HSTPIPERR_CRC16 (_U_(0x1) << HSTPIPERR_CRC16_Pos) /**< (HSTPIPERR) CRC16 Error Mask */ +#define HSTPIPERR_COUNTER_Pos 5 /**< (HSTPIPERR) Error Counter Position */ +#define HSTPIPERR_COUNTER (_U_(0x3) << HSTPIPERR_COUNTER_Pos) /**< (HSTPIPERR) Error Counter Mask */ +#define HSTPIPERR_Msk _U_(0x7F) /**< (HSTPIPERR) Register Mask */ + +#define HSTPIPERR_CRC_Pos 4 /**< (HSTPIPERR Position) CRCx6 Error */ +#define HSTPIPERR_CRC (_U_(0x1) << HSTPIPERR_CRC_Pos) /**< (HSTPIPERR Mask) CRC */ + +/* -------- CTRL : (USBHS Offset: 0x800) (R/W 32) General Control Register -------- */ + +#define CTRL_OFFSET (0x800) /**< (CTRL) General Control Register Offset */ + +#define CTRL_RDERRE_Pos 4 /**< (CTRL) Remote Device Connection Error Interrupt Enable Position */ +#define CTRL_RDERRE (_U_(0x1) << CTRL_RDERRE_Pos) /**< (CTRL) Remote Device Connection Error Interrupt Enable Mask */ +#define CTRL_VBUSHWC_Pos 8 /**< (CTRL) VBUS Hardware Control Position */ +#define CTRL_VBUSHWC (_U_(0x1) << CTRL_VBUSHWC_Pos) /**< (CTRL) VBUS Hardware Control Mask */ +#define CTRL_FRZCLK_Pos 14 /**< (CTRL) Freeze USB Clock Position */ +#define CTRL_FRZCLK (_U_(0x1) << CTRL_FRZCLK_Pos) /**< (CTRL) Freeze USB Clock Mask */ +#define CTRL_USBE_Pos 15 /**< (CTRL) USBHS Enable Position */ +#define CTRL_USBE (_U_(0x1) << CTRL_USBE_Pos) /**< (CTRL) USBHS Enable Mask */ +#define CTRL_UID_Pos 24 /**< (CTRL) UID Pin Enable Position */ +#define CTRL_UID (_U_(0x1) << CTRL_UID_Pos) /**< (CTRL) UID Pin Enable Mask */ +#define CTRL_UIMOD_Pos 25 /**< (CTRL) USBHS Mode Position */ +#define CTRL_UIMOD (_U_(0x1) << CTRL_UIMOD_Pos) /**< (CTRL) USBHS Mode Mask */ +#define CTRL_UIMOD_HOST_Val _U_(0x0) /**< (CTRL) The module is in USB Host mode. */ +#define CTRL_UIMOD_DEVICE_Val _U_(0x1) /**< (CTRL) The module is in USB Device mode. */ +#define CTRL_UIMOD_HOST (CTRL_UIMOD_HOST_Val << CTRL_UIMOD_Pos) /**< (CTRL) The module is in USB Host mode. Position */ +#define CTRL_UIMOD_DEVICE (CTRL_UIMOD_DEVICE_Val << CTRL_UIMOD_Pos) /**< (CTRL) The module is in USB Device mode. Position */ +#define CTRL_Msk _U_(0x300C110) /**< (CTRL) Register Mask */ + + +/* -------- SR : (USBHS Offset: 0x804) (R/ 32) General Status Register -------- */ + +#define SR_OFFSET (0x804) /**< (SR) General Status Register Offset */ + +#define SR_RDERRI_Pos 4 /**< (SR) Remote Device Connection Error Interrupt (Host mode only) Position */ +#define SR_RDERRI (_U_(0x1) << SR_RDERRI_Pos) /**< (SR) Remote Device Connection Error Interrupt (Host mode only) Mask */ +#define SR_SPEED_Pos 12 /**< (SR) Speed Status (Device mode only) Position */ +#define SR_SPEED (_U_(0x3) << SR_SPEED_Pos) /**< (SR) Speed Status (Device mode only) Mask */ +#define SR_SPEED_FULL_SPEED_Val _U_(0x0) /**< (SR) Full-Speed mode */ +#define SR_SPEED_HIGH_SPEED_Val _U_(0x1) /**< (SR) High-Speed mode */ +#define SR_SPEED_LOW_SPEED_Val _U_(0x2) /**< (SR) Low-Speed mode */ +#define SR_SPEED_FULL_SPEED (SR_SPEED_FULL_SPEED_Val << SR_SPEED_Pos) /**< (SR) Full-Speed mode Position */ +#define SR_SPEED_HIGH_SPEED (SR_SPEED_HIGH_SPEED_Val << SR_SPEED_Pos) /**< (SR) High-Speed mode Position */ +#define SR_SPEED_LOW_SPEED (SR_SPEED_LOW_SPEED_Val << SR_SPEED_Pos) /**< (SR) Low-Speed mode Position */ +#define SR_CLKUSABLE_Pos 14 /**< (SR) UTMI Clock Usable Position */ +#define SR_CLKUSABLE (_U_(0x1) << SR_CLKUSABLE_Pos) /**< (SR) UTMI Clock Usable Mask */ +#define SR_Msk _U_(0x7010) /**< (SR) Register Mask */ + + +/* -------- SCR : (USBHS Offset: 0x808) (/W 32) General Status Clear Register -------- */ + +#define SCR_OFFSET (0x808) /**< (SCR) General Status Clear Register Offset */ + +#define SCR_RDERRIC_Pos 4 /**< (SCR) Remote Device Connection Error Interrupt Clear Position */ +#define SCR_RDERRIC (_U_(0x1) << SCR_RDERRIC_Pos) /**< (SCR) Remote Device Connection Error Interrupt Clear Mask */ +#define SCR_Msk _U_(0x10) /**< (SCR) Register Mask */ + + +/* -------- SFR : (USBHS Offset: 0x80c) (/W 32) General Status Set Register -------- */ + +#define SFR_OFFSET (0x80C) /**< (SFR) General Status Set Register Offset */ + +#define SFR_RDERRIS_Pos 4 /**< (SFR) Remote Device Connection Error Interrupt Set Position */ +#define SFR_RDERRIS (_U_(0x1) << SFR_RDERRIS_Pos) /**< (SFR) Remote Device Connection Error Interrupt Set Mask */ +#define SFR_VBUSRQS_Pos 9 /**< (SFR) VBUS Request Set Position */ +#define SFR_VBUSRQS (_U_(0x1) << SFR_VBUSRQS_Pos) /**< (SFR) VBUS Request Set Mask */ +#define SFR_Msk _U_(0x210) /**< (SFR) Register Mask */ + + +/** \brief DEVDMA hardware registers */ +typedef struct +{ + __IO uint32_t DEVDMANXTDSC; /**< (DEVDMA Offset: 0x00) Device DMA Channel Next Descriptor Address Register */ + __IO uint32_t DEVDMAADDRESS; /**< (DEVDMA Offset: 0x04) Device DMA Channel Address Register */ + __IO uint32_t DEVDMACONTROL; /**< (DEVDMA Offset: 0x08) Device DMA Channel Control Register */ + __IO uint32_t DEVDMASTATUS; /**< (DEVDMA Offset: 0x0C) Device DMA Channel Status Register */ +} devdma_t; + +/** \brief HSTDMA hardware registers */ +typedef struct +{ + __IO uint32_t HSTDMANXTDSC; /**< (HSTDMA Offset: 0x00) Host DMA Channel Next Descriptor Address Register */ + __IO uint32_t HSTDMAADDRESS; /**< (HSTDMA Offset: 0x04) Host DMA Channel Address Register */ + __IO uint32_t HSTDMACONTROL; /**< (HSTDMA Offset: 0x08) Host DMA Channel Control Register */ + __IO uint32_t HSTDMASTATUS; /**< (HSTDMA Offset: 0x0C) Host DMA Channel Status Register */ +} hstdma_t; + +/** \brief USBHS hardware registers */ +typedef struct +{ + __IO uint32_t DEVCTRL; /**< (USBHS Offset: 0x00) Device General Control Register */ + __I uint32_t DEVISR; /**< (USBHS Offset: 0x04) Device Global Interrupt Status Register */ + __O uint32_t DEVICR; /**< (USBHS Offset: 0x08) Device Global Interrupt Clear Register */ + __O uint32_t DEVIFR; /**< (USBHS Offset: 0x0C) Device Global Interrupt Set Register */ + __I uint32_t DEVIMR; /**< (USBHS Offset: 0x10) Device Global Interrupt Mask Register */ + __O uint32_t DEVIDR; /**< (USBHS Offset: 0x14) Device Global Interrupt Disable Register */ + __O uint32_t DEVIER; /**< (USBHS Offset: 0x18) Device Global Interrupt Enable Register */ + __IO uint32_t DEVEPT; /**< (USBHS Offset: 0x1C) Device Endpoint Register */ + __I uint32_t DEVFNUM; /**< (USBHS Offset: 0x20) Device Frame Number Register */ + __I uint8_t Reserved1[220]; + __IO uint32_t DEVEPTCFG[10]; /**< (USBHS Offset: 0x100) Device Endpoint Configuration Register */ + __I uint8_t Reserved2[8]; + __I uint32_t DEVEPTISR[10]; /**< (USBHS Offset: 0x130) Device Endpoint Interrupt Status Register */ + __I uint8_t Reserved3[8]; + __O uint32_t DEVEPTICR[10]; /**< (USBHS Offset: 0x160) Device Endpoint Interrupt Clear Register */ + __I uint8_t Reserved4[8]; + __O uint32_t DEVEPTIFR[10]; /**< (USBHS Offset: 0x190) Device Endpoint Interrupt Set Register */ + __I uint8_t Reserved5[8]; + __I uint32_t DEVEPTIMR[10]; /**< (USBHS Offset: 0x1C0) Device Endpoint Interrupt Mask Register */ + __I uint8_t Reserved6[8]; + __O uint32_t DEVEPTIER[10]; /**< (USBHS Offset: 0x1F0) Device Endpoint Interrupt Enable Register */ + __I uint8_t Reserved7[8]; + __O uint32_t DEVEPTIDR[10]; /**< (USBHS Offset: 0x220) Device Endpoint Interrupt Disable Register */ + __I uint8_t Reserved8[200]; + devdma_t DEVDMA[7]; /**< Offset: 0x310 Device DMA Channel Next Descriptor Address Register */ + __I uint8_t Reserved9[128]; + __IO uint32_t HSTCTRL; /**< (USBHS Offset: 0x400) Host General Control Register */ + __I uint32_t HSTISR; /**< (USBHS Offset: 0x404) Host Global Interrupt Status Register */ + __O uint32_t HSTICR; /**< (USBHS Offset: 0x408) Host Global Interrupt Clear Register */ + __O uint32_t HSTIFR; /**< (USBHS Offset: 0x40C) Host Global Interrupt Set Register */ + __I uint32_t HSTIMR; /**< (USBHS Offset: 0x410) Host Global Interrupt Mask Register */ + __O uint32_t HSTIDR; /**< (USBHS Offset: 0x414) Host Global Interrupt Disable Register */ + __O uint32_t HSTIER; /**< (USBHS Offset: 0x418) Host Global Interrupt Enable Register */ + __IO uint32_t HSTPIP; /**< (USBHS Offset: 0x41C) Host Pipe Register */ + __IO uint32_t HSTFNUM; /**< (USBHS Offset: 0x420) Host Frame Number Register */ + __IO uint32_t HSTADDR1; /**< (USBHS Offset: 0x424) Host Address 1 Register */ + __IO uint32_t HSTADDR2; /**< (USBHS Offset: 0x428) Host Address 2 Register */ + __IO uint32_t HSTADDR3; /**< (USBHS Offset: 0x42C) Host Address 3 Register */ + __I uint8_t Reserved10[208]; + __IO uint32_t HSTPIPCFG[10]; /**< (USBHS Offset: 0x500) Host Pipe Configuration Register */ + __I uint8_t Reserved11[8]; + __I uint32_t HSTPIPISR[10]; /**< (USBHS Offset: 0x530) Host Pipe Status Register */ + __I uint8_t Reserved12[8]; + __O uint32_t HSTPIPICR[10]; /**< (USBHS Offset: 0x560) Host Pipe Clear Register */ + __I uint8_t Reserved13[8]; + __O uint32_t HSTPIPIFR[10]; /**< (USBHS Offset: 0x590) Host Pipe Set Register */ + __I uint8_t Reserved14[8]; + __I uint32_t HSTPIPIMR[10]; /**< (USBHS Offset: 0x5C0) Host Pipe Mask Register */ + __I uint8_t Reserved15[8]; + __O uint32_t HSTPIPIER[10]; /**< (USBHS Offset: 0x5F0) Host Pipe Enable Register */ + __I uint8_t Reserved16[8]; + __O uint32_t HSTPIPIDR[10]; /**< (USBHS Offset: 0x620) Host Pipe Disable Register */ + __I uint8_t Reserved17[8]; + __IO uint32_t HSTPIPINRQ[10]; /**< (USBHS Offset: 0x650) Host Pipe IN Request Register */ + __I uint8_t Reserved18[8]; + __IO uint32_t HSTPIPERR[10]; /**< (USBHS Offset: 0x680) Host Pipe Error Register */ + __I uint8_t Reserved19[104]; + hstdma_t HSTDMA[7]; /**< Offset: 0x710 Host DMA Channel Next Descriptor Address Register */ + __I uint8_t Reserved20[128]; + __IO uint32_t CTRL; /**< (USBHS Offset: 0x800) General Control Register */ + __I uint32_t SR; /**< (USBHS Offset: 0x804) General Status Register */ + __O uint32_t SCR; /**< (USBHS Offset: 0x808) General Status Clear Register */ + __O uint32_t SFR; /**< (USBHS Offset: 0x80C) General Status Set Register */ +} dcd_registers_t; + +#define USB_REG ((dcd_registers_t *)0x40038000U) /**< \brief (USBHS) Base Address */ + +#define EP_MAX 10 + +#define FIFO_RAM_ADDR 0xA0100000u + +// Errata: The DMA feature is not available for Pipe/Endpoint 7 +#define EP_DMA_SUPPORT(epnum) (epnum >= 1 && epnum <= 6) + +#else // TODO : SAM3U + + +#endif + +#endif /* _COMMON_USB_REGS_H_ */ diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/nxp/transdimension/common_transdimension.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/nxp/transdimension/common_transdimension.h index 7b94dac34f4..69074de418e 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/nxp/transdimension/common_transdimension.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/nxp/transdimension/common_transdimension.h @@ -127,7 +127,7 @@ typedef struct __I uint32_t ENDPTSTAT; ///< Endpoint Status __IO uint32_t ENDPTCOMPLETE; ///< Endpoint Complete __IO uint32_t ENDPTCTRL[8]; ///< Endpoint Control 0 - 7 -} dcd_registers_t; +} dcd_registers_t, hcd_registers_t; #ifdef __cplusplus } diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/ohci/ohci.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/ohci/ohci.h index 6a634592a4c..cd90aa45a9f 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/ohci/ohci.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/ohci/ohci.h @@ -159,7 +159,7 @@ typedef struct TU_ATTR_ALIGNED(256) struct { ohci_ed_t ed; ohci_gtd_t gtd; - }control[CFG_TUSB_HOST_DEVICE_MAX+1]; + }control[CFG_TUH_DEVICE_MAX+1]; // ochi_itd_t itd[OHCI_MAX_ITD]; // itd requires alignment of 32 ohci_ed_t ed_pool[HCD_MAX_ENDPOINT]; diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/raspberrypi/rp2040/rp2040_usb.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/raspberrypi/rp2040/rp2040_usb.h index 514152cd9a0..a9cf1dd07f4 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/raspberrypi/rp2040/rp2040_usb.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/raspberrypi/rp2040/rp2040_usb.h @@ -21,7 +21,7 @@ #define pico_trace(...) TU_LOG(3, __VA_ARGS__) // Hardware information per endpoint -struct hw_endpoint +typedef struct hw_endpoint { // Is this a valid struct bool configured; @@ -42,9 +42,6 @@ struct hw_endpoint // Buffer pointer in usb dpram uint8_t *hw_data_buf; - // Have we been stalled - bool stalled; - // Current transfer information bool active; uint16_t remaining_len; @@ -66,7 +63,7 @@ struct hw_endpoint // If interrupt endpoint uint8_t interrupt_num; #endif -}; +} hw_endpoint_t; void rp2040_usb_init(void); @@ -96,52 +93,4 @@ static inline uintptr_t hw_data_offset(uint8_t *buf) extern const char *ep_dir_string[]; -typedef union TU_ATTR_PACKED -{ - uint16_t u16; - struct TU_ATTR_PACKED - { - uint16_t xfer_len : 10; - uint16_t available : 1; - uint16_t stall : 1; - uint16_t reset_bufsel : 1; - uint16_t data_toggle : 1; - uint16_t last_buf : 1; - uint16_t full : 1; - }; -} rp2040_buffer_control_t; - -TU_VERIFY_STATIC(sizeof(rp2040_buffer_control_t) == 2, "size is not correct"); - -#if CFG_TUSB_DEBUG >= 3 -static inline void print_bufctrl16(uint32_t u16) -{ - rp2040_buffer_control_t bufctrl = { - .u16 = u16 - }; - - TU_LOG(3, "len = %u, available = %u, full = %u, last = %u, stall = %u, reset = %u, toggle = %u\r\n", - bufctrl.xfer_len, bufctrl.available, bufctrl.full, bufctrl.last_buf, bufctrl.stall, bufctrl.reset_bufsel, bufctrl.data_toggle); -} - -static inline void print_bufctrl32(uint32_t u32) -{ - uint16_t u16; - - u16 = u32 >> 16; - TU_LOG(3, " Buffer Control 1 0x%x: ", u16); - print_bufctrl16(u16); - - u16 = u32 & 0x0000ffff; - TU_LOG(3, " Buffer Control 0 0x%x: ", u16); - print_bufctrl16(u16); -} - -#else - -#define print_bufctrl16(u16) -#define print_bufctrl32(u32) - -#endif - #endif diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h index d26c700d2af..eca8bf57553 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h @@ -83,6 +83,10 @@ #include "stm32l0xx.h" #define PMA_LENGTH (1024u) +#elif CFG_TUSB_MCU == OPT_MCU_STM32L1 + #include "stm32l1xx.h" + #define PMA_LENGTH (512u) + #else #error You are using an untested or unimplemented STM32 variant. Please update the driver. // This includes L1x0, L1x1, L1x2, L4x2 and L4x3, G1x1, G1x3, and G1x4 diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/st/synopsys/synopsys_common.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/st/synopsys/synopsys_common.h new file mode 100644 index 00000000000..6f0602fe9c8 --- /dev/null +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/st/synopsys/synopsys_common.h @@ -0,0 +1,1465 @@ +/** + ****************************************************************************** + * @file synopsys_common.h + * @author MCD Application Team + * @brief CMSIS Cortex-M3 Device USB OTG peripheral Header File. + * This file contains the USB OTG peripheral register's definitions, bits + * definitions and memory mapping for STM32F1xx devices. + * + * This file contains: + * - Data structures and the address mapping for the USB OTG peripheral + * - The Peripheral's registers declarations and bits definition + * - Macros to access the peripheral's registers hardware + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +#include "stdint.h" + +#pragma once + +#ifdef __cplusplus + #define __I volatile +#else + #define __I volatile const +#endif +#define __O volatile +#define __IO volatile +#define __IM volatile const +#define __OM volatile +#define __IOM volatile + +/** + * @brief __USB_OTG_Core_register + */ + +typedef struct +{ + __IO uint32_t GOTGCTL; /*!< USB_OTG Control and Status Register Address offset: 000h */ + __IO uint32_t GOTGINT; /*!< USB_OTG Interrupt Register Address offset: 004h */ + __IO uint32_t GAHBCFG; /*!< Core AHB Configuration Register Address offset: 008h */ + __IO uint32_t GUSBCFG; /*!< Core USB Configuration Register Address offset: 00Ch */ + __IO uint32_t GRSTCTL; /*!< Core Reset Register Address offset: 010h */ + __IO uint32_t GINTSTS; /*!< Core Interrupt Register Address offset: 014h */ + __IO uint32_t GINTMSK; /*!< Core Interrupt Mask Register Address offset: 018h */ + __IO uint32_t GRXSTSR; /*!< Receive Sts Q Read Register Address offset: 01Ch */ + __IO uint32_t GRXSTSP; /*!< Receive Sts Q Read & POP Register Address offset: 020h */ + __IO uint32_t GRXFSIZ; /*!< Receive FIFO Size Register Address offset: 024h */ + __IO uint32_t DIEPTXF0_HNPTXFSIZ; /*!< EP0 / Non Periodic Tx FIFO Size Register Address offset: 028h */ + __IO uint32_t HNPTXSTS; /*!< Non Periodic Tx FIFO/Queue Sts reg Address offset: 02Ch */ + uint32_t Reserved30[2]; /*!< Reserved 030h*/ + __IO uint32_t GCCFG; /*!< General Purpose IO Register Address offset: 038h */ + __IO uint32_t CID; /*!< User ID Register Address offset: 03Ch */ + uint32_t Reserved40[48]; /*!< Reserved 040h-0FFh */ + __IO uint32_t HPTXFSIZ; /*!< Host Periodic Tx FIFO Size Reg Address offset: 100h */ + __IO uint32_t DIEPTXF[0x0F]; /*!< dev Periodic Transmit FIFO Address offset: 0x104 */ +} USB_OTG_GlobalTypeDef; + +/** + * @brief __device_Registers + */ + +typedef struct +{ + __IO uint32_t DCFG; /*!< dev Configuration Register Address offset: 800h*/ + __IO uint32_t DCTL; /*!< dev Control Register Address offset: 804h*/ + __IO uint32_t DSTS; /*!< dev Status Register (RO) Address offset: 808h*/ + uint32_t Reserved0C; /*!< Reserved 80Ch*/ + __IO uint32_t DIEPMSK; /*!< dev IN Endpoint Mask Address offset: 810h*/ + __IO uint32_t DOEPMSK; /*!< dev OUT Endpoint Mask Address offset: 814h*/ + __IO uint32_t DAINT; /*!< dev All Endpoints Itr Reg Address offset: 818h*/ + __IO uint32_t DAINTMSK; /*!< dev All Endpoints Itr Mask Address offset: 81Ch*/ + uint32_t Reserved20; /*!< Reserved 820h*/ + uint32_t Reserved9; /*!< Reserved 824h*/ + __IO uint32_t DVBUSDIS; /*!< dev VBUS discharge Register Address offset: 828h*/ + __IO uint32_t DVBUSPULSE; /*!< dev VBUS Pulse Register Address offset: 82Ch*/ + __IO uint32_t DTHRCTL; /*!< dev thr Address offset: 830h*/ + __IO uint32_t DIEPEMPMSK; /*!< dev empty msk Address offset: 834h*/ + __IO uint32_t DEACHINT; /*!< dedicated EP interrupt Address offset: 838h*/ + __IO uint32_t DEACHMSK; /*!< dedicated EP msk Address offset: 83Ch*/ + uint32_t Reserved40; /*!< dedicated EP mask Address offset: 840h*/ + __IO uint32_t DINEP1MSK; /*!< dedicated EP mask Address offset: 844h*/ + uint32_t Reserved44[15]; /*!< Reserved 844-87Ch*/ + __IO uint32_t DOUTEP1MSK; /*!< dedicated EP msk Address offset: 884h*/ +} USB_OTG_DeviceTypeDef; + +/** + * @brief __IN_Endpoint-Specific_Register + */ + +typedef struct +{ + __IO uint32_t DIEPCTL; /*!< dev IN Endpoint Control Reg 900h + (ep_num * 20h) + 00h*/ + uint32_t Reserved04; /*!< Reserved 900h + (ep_num * 20h) + 04h*/ + __IO uint32_t DIEPINT; /*!< dev IN Endpoint Itr Reg 900h + (ep_num * 20h) + 08h*/ + uint32_t Reserved0C; /*!< Reserved 900h + (ep_num * 20h) + 0Ch*/ + __IO uint32_t DIEPTSIZ; /*!< IN Endpoint Txfer Size 900h + (ep_num * 20h) + 10h*/ + __IO uint32_t DIEPDMA; /*!< IN Endpoint DMA Address Reg 900h + (ep_num * 20h) + 14h*/ + __IO uint32_t DTXFSTS; /*!< IN Endpoint Tx FIFO Status Reg 900h + (ep_num * 20h) + 18h*/ + uint32_t Reserved18; /*!< Reserved 900h+(ep_num*20h)+1Ch-900h+ (ep_num * 20h) + 1Ch*/ +} USB_OTG_INEndpointTypeDef; + +/** + * @brief __OUT_Endpoint-Specific_Registers + */ + +typedef struct +{ + __IO uint32_t DOEPCTL; /*!< dev OUT Endpoint Control Reg B00h + (ep_num * 20h) + 00h*/ + uint32_t Reserved04; /*!< Reserved B00h + (ep_num * 20h) + 04h*/ + __IO uint32_t DOEPINT; /*!< dev OUT Endpoint Itr Reg B00h + (ep_num * 20h) + 08h*/ + uint32_t Reserved0C; /*!< Reserved B00h + (ep_num * 20h) + 0Ch*/ + __IO uint32_t DOEPTSIZ; /*!< dev OUT Endpoint Txfer Size B00h + (ep_num * 20h) + 10h*/ + __IO uint32_t DOEPDMA; /*!< dev OUT Endpoint DMA Address B00h + (ep_num * 20h) + 14h*/ + uint32_t Reserved18[2]; /*!< Reserved B00h + (ep_num * 20h) + 18h - B00h + (ep_num * 20h) + 1Ch*/ +} USB_OTG_OUTEndpointTypeDef; + +/** + * @brief __Host_Mode_Register_Structures + */ + +typedef struct +{ + __IO uint32_t HCFG; /*!< Host Configuration Register 400h*/ + __IO uint32_t HFIR; /*!< Host Frame Interval Register 404h*/ + __IO uint32_t HFNUM; /*!< Host Frame Nbr/Frame Remaining 408h*/ + uint32_t Reserved40C; /*!< Reserved 40Ch*/ + __IO uint32_t HPTXSTS; /*!< Host Periodic Tx FIFO/ Queue Status 410h*/ + __IO uint32_t HAINT; /*!< Host All Channels Interrupt Register 414h*/ + __IO uint32_t HAINTMSK; /*!< Host All Channels Interrupt Mask 418h*/ +} USB_OTG_HostTypeDef; + +/** + * @brief __Host_Channel_Specific_Registers + */ + +typedef struct +{ + __IO uint32_t HCCHAR; + __IO uint32_t HCSPLT; + __IO uint32_t HCINT; + __IO uint32_t HCINTMSK; + __IO uint32_t HCTSIZ; + __IO uint32_t HCDMA; + uint32_t Reserved[2]; +} USB_OTG_HostChannelTypeDef; + +/*!< USB registers base address */ +#define USB_OTG_FS_PERIPH_BASE 0x50000000UL + +#define USB_OTG_GLOBAL_BASE 0x00000000UL +#define USB_OTG_DEVICE_BASE 0x00000800UL +#define USB_OTG_IN_ENDPOINT_BASE 0x00000900UL +#define USB_OTG_OUT_ENDPOINT_BASE 0x00000B00UL +#define USB_OTG_EP_REG_SIZE 0x00000020UL +#define USB_OTG_HOST_BASE 0x00000400UL +#define USB_OTG_HOST_PORT_BASE 0x00000440UL +#define USB_OTG_HOST_CHANNEL_BASE 0x00000500UL +#define USB_OTG_HOST_CHANNEL_SIZE 0x00000020UL +#define USB_OTG_PCGCCTL_BASE 0x00000E00UL +#define USB_OTG_FIFO_BASE 0x00001000UL +#define USB_OTG_FIFO_SIZE 0x00001000UL + +/******************************************************************************/ +/* */ +/* USB_OTG */ +/* */ +/******************************************************************************/ +/******************** Bit definition for USB_OTG_GOTGCTL register ***********/ +#define USB_OTG_GOTGCTL_SRQSCS_Pos (0U) +#define USB_OTG_GOTGCTL_SRQSCS_Msk (0x1UL << USB_OTG_GOTGCTL_SRQSCS_Pos) /*!< 0x00000001 */ +#define USB_OTG_GOTGCTL_SRQSCS USB_OTG_GOTGCTL_SRQSCS_Msk /*!< Session request success */ +#define USB_OTG_GOTGCTL_SRQ_Pos (1U) +#define USB_OTG_GOTGCTL_SRQ_Msk (0x1UL << USB_OTG_GOTGCTL_SRQ_Pos) /*!< 0x00000002 */ +#define USB_OTG_GOTGCTL_SRQ USB_OTG_GOTGCTL_SRQ_Msk /*!< Session request */ +#define USB_OTG_GOTGCTL_HNGSCS_Pos (8U) +#define USB_OTG_GOTGCTL_HNGSCS_Msk (0x1UL << USB_OTG_GOTGCTL_HNGSCS_Pos) /*!< 0x00000100 */ +#define USB_OTG_GOTGCTL_HNGSCS USB_OTG_GOTGCTL_HNGSCS_Msk /*!< Host set HNP enable */ +#define USB_OTG_GOTGCTL_HNPRQ_Pos (9U) +#define USB_OTG_GOTGCTL_HNPRQ_Msk (0x1UL << USB_OTG_GOTGCTL_HNPRQ_Pos) /*!< 0x00000200 */ +#define USB_OTG_GOTGCTL_HNPRQ USB_OTG_GOTGCTL_HNPRQ_Msk /*!< HNP request */ +#define USB_OTG_GOTGCTL_HSHNPEN_Pos (10U) +#define USB_OTG_GOTGCTL_HSHNPEN_Msk (0x1UL << USB_OTG_GOTGCTL_HSHNPEN_Pos) /*!< 0x00000400 */ +#define USB_OTG_GOTGCTL_HSHNPEN USB_OTG_GOTGCTL_HSHNPEN_Msk /*!< Host set HNP enable */ +#define USB_OTG_GOTGCTL_DHNPEN_Pos (11U) +#define USB_OTG_GOTGCTL_DHNPEN_Msk (0x1UL << USB_OTG_GOTGCTL_DHNPEN_Pos) /*!< 0x00000800 */ +#define USB_OTG_GOTGCTL_DHNPEN USB_OTG_GOTGCTL_DHNPEN_Msk /*!< Device HNP enabled */ +#define USB_OTG_GOTGCTL_CIDSTS_Pos (16U) +#define USB_OTG_GOTGCTL_CIDSTS_Msk (0x1UL << USB_OTG_GOTGCTL_CIDSTS_Pos) /*!< 0x00010000 */ +#define USB_OTG_GOTGCTL_CIDSTS USB_OTG_GOTGCTL_CIDSTS_Msk /*!< Connector ID status */ +#define USB_OTG_GOTGCTL_DBCT_Pos (17U) +#define USB_OTG_GOTGCTL_DBCT_Msk (0x1UL << USB_OTG_GOTGCTL_DBCT_Pos) /*!< 0x00020000 */ +#define USB_OTG_GOTGCTL_DBCT USB_OTG_GOTGCTL_DBCT_Msk /*!< Long/short debounce time */ +#define USB_OTG_GOTGCTL_ASVLD_Pos (18U) +#define USB_OTG_GOTGCTL_ASVLD_Msk (0x1UL << USB_OTG_GOTGCTL_ASVLD_Pos) /*!< 0x00040000 */ +#define USB_OTG_GOTGCTL_ASVLD USB_OTG_GOTGCTL_ASVLD_Msk /*!< A-session valid */ +#define USB_OTG_GOTGCTL_BSVLD_Pos (19U) +#define USB_OTG_GOTGCTL_BSVLD_Msk (0x1UL << USB_OTG_GOTGCTL_BSVLD_Pos) /*!< 0x00080000 */ +#define USB_OTG_GOTGCTL_BSVLD USB_OTG_GOTGCTL_BSVLD_Msk /*!< B-session valid */ + +/******************** Bit definition for USB_OTG_HCFG register ********************/ + +#define USB_OTG_HCFG_FSLSPCS_Pos (0U) +#define USB_OTG_HCFG_FSLSPCS_Msk (0x3UL << USB_OTG_HCFG_FSLSPCS_Pos) /*!< 0x00000003 */ +#define USB_OTG_HCFG_FSLSPCS USB_OTG_HCFG_FSLSPCS_Msk /*!< FS/LS PHY clock select */ +#define USB_OTG_HCFG_FSLSPCS_0 (0x1UL << USB_OTG_HCFG_FSLSPCS_Pos) /*!< 0x00000001 */ +#define USB_OTG_HCFG_FSLSPCS_1 (0x2UL << USB_OTG_HCFG_FSLSPCS_Pos) /*!< 0x00000002 */ +#define USB_OTG_HCFG_FSLSS_Pos (2U) +#define USB_OTG_HCFG_FSLSS_Msk (0x1UL << USB_OTG_HCFG_FSLSS_Pos) /*!< 0x00000004 */ +#define USB_OTG_HCFG_FSLSS USB_OTG_HCFG_FSLSS_Msk /*!< FS- and LS-only support */ + +/******************** Bit definition for USB_OTG_DCFG register ********************/ + +#define USB_OTG_DCFG_DSPD_Pos (0U) +#define USB_OTG_DCFG_DSPD_Msk (0x3UL << USB_OTG_DCFG_DSPD_Pos) /*!< 0x00000003 */ +#define USB_OTG_DCFG_DSPD USB_OTG_DCFG_DSPD_Msk /*!< Device speed */ +#define USB_OTG_DCFG_DSPD_0 (0x1UL << USB_OTG_DCFG_DSPD_Pos) /*!< 0x00000001 */ +#define USB_OTG_DCFG_DSPD_1 (0x2UL << USB_OTG_DCFG_DSPD_Pos) /*!< 0x00000002 */ +#define USB_OTG_DCFG_NZLSOHSK_Pos (2U) +#define USB_OTG_DCFG_NZLSOHSK_Msk (0x1UL << USB_OTG_DCFG_NZLSOHSK_Pos) /*!< 0x00000004 */ +#define USB_OTG_DCFG_NZLSOHSK USB_OTG_DCFG_NZLSOHSK_Msk /*!< Nonzero-length status OUT handshake */ + +#define USB_OTG_DCFG_DAD_Pos (4U) +#define USB_OTG_DCFG_DAD_Msk (0x7FUL << USB_OTG_DCFG_DAD_Pos) /*!< 0x000007F0 */ +#define USB_OTG_DCFG_DAD USB_OTG_DCFG_DAD_Msk /*!< Device address */ +#define USB_OTG_DCFG_DAD_0 (0x01UL << USB_OTG_DCFG_DAD_Pos) /*!< 0x00000010 */ +#define USB_OTG_DCFG_DAD_1 (0x02UL << USB_OTG_DCFG_DAD_Pos) /*!< 0x00000020 */ +#define USB_OTG_DCFG_DAD_2 (0x04UL << USB_OTG_DCFG_DAD_Pos) /*!< 0x00000040 */ +#define USB_OTG_DCFG_DAD_3 (0x08UL << USB_OTG_DCFG_DAD_Pos) /*!< 0x00000080 */ +#define USB_OTG_DCFG_DAD_4 (0x10UL << USB_OTG_DCFG_DAD_Pos) /*!< 0x00000100 */ +#define USB_OTG_DCFG_DAD_5 (0x20UL << USB_OTG_DCFG_DAD_Pos) /*!< 0x00000200 */ +#define USB_OTG_DCFG_DAD_6 (0x40UL << USB_OTG_DCFG_DAD_Pos) /*!< 0x00000400 */ + +#define USB_OTG_DCFG_PFIVL_Pos (11U) +#define USB_OTG_DCFG_PFIVL_Msk (0x3UL << USB_OTG_DCFG_PFIVL_Pos) /*!< 0x00001800 */ +#define USB_OTG_DCFG_PFIVL USB_OTG_DCFG_PFIVL_Msk /*!< Periodic (micro)frame interval */ +#define USB_OTG_DCFG_PFIVL_0 (0x1UL << USB_OTG_DCFG_PFIVL_Pos) /*!< 0x00000800 */ +#define USB_OTG_DCFG_PFIVL_1 (0x2UL << USB_OTG_DCFG_PFIVL_Pos) /*!< 0x00001000 */ + +#define USB_OTG_DCFG_PERSCHIVL_Pos (24U) +#define USB_OTG_DCFG_PERSCHIVL_Msk (0x3UL << USB_OTG_DCFG_PERSCHIVL_Pos) /*!< 0x03000000 */ +#define USB_OTG_DCFG_PERSCHIVL USB_OTG_DCFG_PERSCHIVL_Msk /*!< Periodic scheduling interval */ +#define USB_OTG_DCFG_PERSCHIVL_0 (0x1UL << USB_OTG_DCFG_PERSCHIVL_Pos) /*!< 0x01000000 */ +#define USB_OTG_DCFG_PERSCHIVL_1 (0x2UL << USB_OTG_DCFG_PERSCHIVL_Pos) /*!< 0x02000000 */ + +/******************** Bit definition for USB_OTG_PCGCR register ********************/ +#define USB_OTG_PCGCR_STPPCLK_Pos (0U) +#define USB_OTG_PCGCR_STPPCLK_Msk (0x1UL << USB_OTG_PCGCR_STPPCLK_Pos) /*!< 0x00000001 */ +#define USB_OTG_PCGCR_STPPCLK USB_OTG_PCGCR_STPPCLK_Msk /*!< Stop PHY clock */ +#define USB_OTG_PCGCR_GATEHCLK_Pos (1U) +#define USB_OTG_PCGCR_GATEHCLK_Msk (0x1UL << USB_OTG_PCGCR_GATEHCLK_Pos) /*!< 0x00000002 */ +#define USB_OTG_PCGCR_GATEHCLK USB_OTG_PCGCR_GATEHCLK_Msk /*!< Gate HCLK */ +#define USB_OTG_PCGCR_PHYSUSP_Pos (4U) +#define USB_OTG_PCGCR_PHYSUSP_Msk (0x1UL << USB_OTG_PCGCR_PHYSUSP_Pos) /*!< 0x00000010 */ +#define USB_OTG_PCGCR_PHYSUSP USB_OTG_PCGCR_PHYSUSP_Msk /*!< PHY suspended */ + +/******************** Bit definition for USB_OTG_GOTGINT register ********************/ +#define USB_OTG_GOTGINT_SEDET_Pos (2U) +#define USB_OTG_GOTGINT_SEDET_Msk (0x1UL << USB_OTG_GOTGINT_SEDET_Pos) /*!< 0x00000004 */ +#define USB_OTG_GOTGINT_SEDET USB_OTG_GOTGINT_SEDET_Msk /*!< Session end detected */ +#define USB_OTG_GOTGINT_SRSSCHG_Pos (8U) +#define USB_OTG_GOTGINT_SRSSCHG_Msk (0x1UL << USB_OTG_GOTGINT_SRSSCHG_Pos) /*!< 0x00000100 */ +#define USB_OTG_GOTGINT_SRSSCHG USB_OTG_GOTGINT_SRSSCHG_Msk /*!< Session request success status change */ +#define USB_OTG_GOTGINT_HNSSCHG_Pos (9U) +#define USB_OTG_GOTGINT_HNSSCHG_Msk (0x1UL << USB_OTG_GOTGINT_HNSSCHG_Pos) /*!< 0x00000200 */ +#define USB_OTG_GOTGINT_HNSSCHG USB_OTG_GOTGINT_HNSSCHG_Msk /*!< Host negotiation success status change */ +#define USB_OTG_GOTGINT_HNGDET_Pos (17U) +#define USB_OTG_GOTGINT_HNGDET_Msk (0x1UL << USB_OTG_GOTGINT_HNGDET_Pos) /*!< 0x00020000 */ +#define USB_OTG_GOTGINT_HNGDET USB_OTG_GOTGINT_HNGDET_Msk /*!< Host negotiation detected */ +#define USB_OTG_GOTGINT_ADTOCHG_Pos (18U) +#define USB_OTG_GOTGINT_ADTOCHG_Msk (0x1UL << USB_OTG_GOTGINT_ADTOCHG_Pos) /*!< 0x00040000 */ +#define USB_OTG_GOTGINT_ADTOCHG USB_OTG_GOTGINT_ADTOCHG_Msk /*!< A-device timeout change */ +#define USB_OTG_GOTGINT_DBCDNE_Pos (19U) +#define USB_OTG_GOTGINT_DBCDNE_Msk (0x1UL << USB_OTG_GOTGINT_DBCDNE_Pos) /*!< 0x00080000 */ +#define USB_OTG_GOTGINT_DBCDNE USB_OTG_GOTGINT_DBCDNE_Msk /*!< Debounce done */ + +/******************** Bit definition for USB_OTG_DCTL register ********************/ +#define USB_OTG_DCTL_RWUSIG_Pos (0U) +#define USB_OTG_DCTL_RWUSIG_Msk (0x1UL << USB_OTG_DCTL_RWUSIG_Pos) /*!< 0x00000001 */ +#define USB_OTG_DCTL_RWUSIG USB_OTG_DCTL_RWUSIG_Msk /*!< Remote wakeup signaling */ +#define USB_OTG_DCTL_SDIS_Pos (1U) +#define USB_OTG_DCTL_SDIS_Msk (0x1UL << USB_OTG_DCTL_SDIS_Pos) /*!< 0x00000002 */ +#define USB_OTG_DCTL_SDIS USB_OTG_DCTL_SDIS_Msk /*!< Soft disconnect */ +#define USB_OTG_DCTL_GINSTS_Pos (2U) +#define USB_OTG_DCTL_GINSTS_Msk (0x1UL << USB_OTG_DCTL_GINSTS_Pos) /*!< 0x00000004 */ +#define USB_OTG_DCTL_GINSTS USB_OTG_DCTL_GINSTS_Msk /*!< Global IN NAK status */ +#define USB_OTG_DCTL_GONSTS_Pos (3U) +#define USB_OTG_DCTL_GONSTS_Msk (0x1UL << USB_OTG_DCTL_GONSTS_Pos) /*!< 0x00000008 */ +#define USB_OTG_DCTL_GONSTS USB_OTG_DCTL_GONSTS_Msk /*!< Global OUT NAK status */ + +#define USB_OTG_DCTL_TCTL_Pos (4U) +#define USB_OTG_DCTL_TCTL_Msk (0x7UL << USB_OTG_DCTL_TCTL_Pos) /*!< 0x00000070 */ +#define USB_OTG_DCTL_TCTL USB_OTG_DCTL_TCTL_Msk /*!< Test control */ +#define USB_OTG_DCTL_TCTL_0 (0x1UL << USB_OTG_DCTL_TCTL_Pos) /*!< 0x00000010 */ +#define USB_OTG_DCTL_TCTL_1 (0x2UL << USB_OTG_DCTL_TCTL_Pos) /*!< 0x00000020 */ +#define USB_OTG_DCTL_TCTL_2 (0x4UL << USB_OTG_DCTL_TCTL_Pos) /*!< 0x00000040 */ +#define USB_OTG_DCTL_SGINAK_Pos (7U) +#define USB_OTG_DCTL_SGINAK_Msk (0x1UL << USB_OTG_DCTL_SGINAK_Pos) /*!< 0x00000080 */ +#define USB_OTG_DCTL_SGINAK USB_OTG_DCTL_SGINAK_Msk /*!< Set global IN NAK */ +#define USB_OTG_DCTL_CGINAK_Pos (8U) +#define USB_OTG_DCTL_CGINAK_Msk (0x1UL << USB_OTG_DCTL_CGINAK_Pos) /*!< 0x00000100 */ +#define USB_OTG_DCTL_CGINAK USB_OTG_DCTL_CGINAK_Msk /*!< Clear global IN NAK */ +#define USB_OTG_DCTL_SGONAK_Pos (9U) +#define USB_OTG_DCTL_SGONAK_Msk (0x1UL << USB_OTG_DCTL_SGONAK_Pos) /*!< 0x00000200 */ +#define USB_OTG_DCTL_SGONAK USB_OTG_DCTL_SGONAK_Msk /*!< Set global OUT NAK */ +#define USB_OTG_DCTL_CGONAK_Pos (10U) +#define USB_OTG_DCTL_CGONAK_Msk (0x1UL << USB_OTG_DCTL_CGONAK_Pos) /*!< 0x00000400 */ +#define USB_OTG_DCTL_CGONAK USB_OTG_DCTL_CGONAK_Msk /*!< Clear global OUT NAK */ +#define USB_OTG_DCTL_POPRGDNE_Pos (11U) +#define USB_OTG_DCTL_POPRGDNE_Msk (0x1UL << USB_OTG_DCTL_POPRGDNE_Pos) /*!< 0x00000800 */ +#define USB_OTG_DCTL_POPRGDNE USB_OTG_DCTL_POPRGDNE_Msk /*!< Power-on programming done */ + +/******************** Bit definition for USB_OTG_HFIR register ********************/ +#define USB_OTG_HFIR_FRIVL_Pos (0U) +#define USB_OTG_HFIR_FRIVL_Msk (0xFFFFUL << USB_OTG_HFIR_FRIVL_Pos) /*!< 0x0000FFFF */ +#define USB_OTG_HFIR_FRIVL USB_OTG_HFIR_FRIVL_Msk /*!< Frame interval */ + +/******************** Bit definition for USB_OTG_HFNUM register ********************/ +#define USB_OTG_HFNUM_FRNUM_Pos (0U) +#define USB_OTG_HFNUM_FRNUM_Msk (0xFFFFUL << USB_OTG_HFNUM_FRNUM_Pos) /*!< 0x0000FFFF */ +#define USB_OTG_HFNUM_FRNUM USB_OTG_HFNUM_FRNUM_Msk /*!< Frame number */ +#define USB_OTG_HFNUM_FTREM_Pos (16U) +#define USB_OTG_HFNUM_FTREM_Msk (0xFFFFUL << USB_OTG_HFNUM_FTREM_Pos) /*!< 0xFFFF0000 */ +#define USB_OTG_HFNUM_FTREM USB_OTG_HFNUM_FTREM_Msk /*!< Frame time remaining */ + +/******************** Bit definition for USB_OTG_DSTS register ********************/ +#define USB_OTG_DSTS_SUSPSTS_Pos (0U) +#define USB_OTG_DSTS_SUSPSTS_Msk (0x1UL << USB_OTG_DSTS_SUSPSTS_Pos) /*!< 0x00000001 */ +#define USB_OTG_DSTS_SUSPSTS USB_OTG_DSTS_SUSPSTS_Msk /*!< Suspend status */ + +#define USB_OTG_DSTS_ENUMSPD_Pos (1U) +#define USB_OTG_DSTS_ENUMSPD_Msk (0x3UL << USB_OTG_DSTS_ENUMSPD_Pos) /*!< 0x00000006 */ +#define USB_OTG_DSTS_ENUMSPD USB_OTG_DSTS_ENUMSPD_Msk /*!< Enumerated speed */ +#define USB_OTG_DSTS_ENUMSPD_0 (0x1UL << USB_OTG_DSTS_ENUMSPD_Pos) /*!< 0x00000002 */ +#define USB_OTG_DSTS_ENUMSPD_1 (0x2UL << USB_OTG_DSTS_ENUMSPD_Pos) /*!< 0x00000004 */ +#define USB_OTG_DSTS_EERR_Pos (3U) +#define USB_OTG_DSTS_EERR_Msk (0x1UL << USB_OTG_DSTS_EERR_Pos) /*!< 0x00000008 */ +#define USB_OTG_DSTS_EERR USB_OTG_DSTS_EERR_Msk /*!< Erratic error */ +#define USB_OTG_DSTS_FNSOF_Pos (8U) +#define USB_OTG_DSTS_FNSOF_Msk (0x3FFFUL << USB_OTG_DSTS_FNSOF_Pos) /*!< 0x003FFF00 */ +#define USB_OTG_DSTS_FNSOF USB_OTG_DSTS_FNSOF_Msk /*!< Frame number of the received SOF */ + +/******************** Bit definition for USB_OTG_GAHBCFG register ********************/ +#define USB_OTG_GAHBCFG_GINT_Pos (0U) +#define USB_OTG_GAHBCFG_GINT_Msk (0x1UL << USB_OTG_GAHBCFG_GINT_Pos) /*!< 0x00000001 */ +#define USB_OTG_GAHBCFG_GINT USB_OTG_GAHBCFG_GINT_Msk /*!< Global interrupt mask */ +#define USB_OTG_GAHBCFG_HBSTLEN_Pos (1U) +#define USB_OTG_GAHBCFG_HBSTLEN_Msk (0xFUL << USB_OTG_GAHBCFG_HBSTLEN_Pos) /*!< 0x0000001E */ +#define USB_OTG_GAHBCFG_HBSTLEN USB_OTG_GAHBCFG_HBSTLEN_Msk /*!< Burst length/type */ +#define USB_OTG_GAHBCFG_HBSTLEN_0 (0x0UL << USB_OTG_GAHBCFG_HBSTLEN_Pos) /*!< Single */ +#define USB_OTG_GAHBCFG_HBSTLEN_1 (0x1UL << USB_OTG_GAHBCFG_HBSTLEN_Pos) /*!< INCR */ +#define USB_OTG_GAHBCFG_HBSTLEN_2 (0x3UL << USB_OTG_GAHBCFG_HBSTLEN_Pos) /*!< INCR4 */ +#define USB_OTG_GAHBCFG_HBSTLEN_3 (0x5UL << USB_OTG_GAHBCFG_HBSTLEN_Pos) /*!< INCR8 */ +#define USB_OTG_GAHBCFG_HBSTLEN_4 (0x7UL << USB_OTG_GAHBCFG_HBSTLEN_Pos) /*!< INCR16 */ +#define USB_OTG_GAHBCFG_DMAEN_Pos (5U) +#define USB_OTG_GAHBCFG_DMAEN_Msk (0x1UL << USB_OTG_GAHBCFG_DMAEN_Pos) /*!< 0x00000020 */ +#define USB_OTG_GAHBCFG_DMAEN USB_OTG_GAHBCFG_DMAEN_Msk /*!< DMA enable */ +#define USB_OTG_GAHBCFG_TXFELVL_Pos (7U) +#define USB_OTG_GAHBCFG_TXFELVL_Msk (0x1UL << USB_OTG_GAHBCFG_TXFELVL_Pos) /*!< 0x00000080 */ +#define USB_OTG_GAHBCFG_TXFELVL USB_OTG_GAHBCFG_TXFELVL_Msk /*!< TxFIFO empty level */ +#define USB_OTG_GAHBCFG_PTXFELVL_Pos (8U) +#define USB_OTG_GAHBCFG_PTXFELVL_Msk (0x1UL << USB_OTG_GAHBCFG_PTXFELVL_Pos) /*!< 0x00000100 */ +#define USB_OTG_GAHBCFG_PTXFELVL USB_OTG_GAHBCFG_PTXFELVL_Msk /*!< Periodic TxFIFO empty level */ + +/******************** Bit definition for USB_OTG_GUSBCFG register ********************/ + +#define USB_OTG_GUSBCFG_TOCAL_Pos (0U) +#define USB_OTG_GUSBCFG_TOCAL_Msk (0x7UL << USB_OTG_GUSBCFG_TOCAL_Pos) /*!< 0x00000007 */ +#define USB_OTG_GUSBCFG_TOCAL USB_OTG_GUSBCFG_TOCAL_Msk /*!< FS timeout calibration */ +#define USB_OTG_GUSBCFG_TOCAL_0 (0x1UL << USB_OTG_GUSBCFG_TOCAL_Pos) /*!< 0x00000001 */ +#define USB_OTG_GUSBCFG_TOCAL_1 (0x2UL << USB_OTG_GUSBCFG_TOCAL_Pos) /*!< 0x00000002 */ +#define USB_OTG_GUSBCFG_TOCAL_2 (0x4UL << USB_OTG_GUSBCFG_TOCAL_Pos) /*!< 0x00000004 */ +#define USB_OTG_GUSBCFG_PHYSEL_Pos (6U) +#define USB_OTG_GUSBCFG_PHYSEL_Msk (0x1UL << USB_OTG_GUSBCFG_PHYSEL_Pos) /*!< 0x00000040 */ +#define USB_OTG_GUSBCFG_PHYSEL USB_OTG_GUSBCFG_PHYSEL_Msk /*!< USB 2.0 high-speed ULPI PHY or USB 1.1 full-speed serial transceiver select */ +#define USB_OTG_GUSBCFG_SRPCAP_Pos (8U) +#define USB_OTG_GUSBCFG_SRPCAP_Msk (0x1UL << USB_OTG_GUSBCFG_SRPCAP_Pos) /*!< 0x00000100 */ +#define USB_OTG_GUSBCFG_SRPCAP USB_OTG_GUSBCFG_SRPCAP_Msk /*!< SRP-capable */ +#define USB_OTG_GUSBCFG_HNPCAP_Pos (9U) +#define USB_OTG_GUSBCFG_HNPCAP_Msk (0x1UL << USB_OTG_GUSBCFG_HNPCAP_Pos) /*!< 0x00000200 */ +#define USB_OTG_GUSBCFG_HNPCAP USB_OTG_GUSBCFG_HNPCAP_Msk /*!< HNP-capable */ +#define USB_OTG_GUSBCFG_TRDT_Pos (10U) +#define USB_OTG_GUSBCFG_TRDT_Msk (0xFUL << USB_OTG_GUSBCFG_TRDT_Pos) /*!< 0x00003C00 */ +#define USB_OTG_GUSBCFG_TRDT USB_OTG_GUSBCFG_TRDT_Msk /*!< USB turnaround time */ +#define USB_OTG_GUSBCFG_TRDT_0 (0x1UL << USB_OTG_GUSBCFG_TRDT_Pos) /*!< 0x00000400 */ +#define USB_OTG_GUSBCFG_TRDT_1 (0x2UL << USB_OTG_GUSBCFG_TRDT_Pos) /*!< 0x00000800 */ +#define USB_OTG_GUSBCFG_TRDT_2 (0x4UL << USB_OTG_GUSBCFG_TRDT_Pos) /*!< 0x00001000 */ +#define USB_OTG_GUSBCFG_TRDT_3 (0x8UL << USB_OTG_GUSBCFG_TRDT_Pos) /*!< 0x00002000 */ +#define USB_OTG_GUSBCFG_PHYLPCS_Pos (15U) +#define USB_OTG_GUSBCFG_PHYLPCS_Msk (0x1UL << USB_OTG_GUSBCFG_PHYLPCS_Pos) /*!< 0x00008000 */ +#define USB_OTG_GUSBCFG_PHYLPCS USB_OTG_GUSBCFG_PHYLPCS_Msk /*!< PHY Low-power clock select */ +#define USB_OTG_GUSBCFG_ULPIFSLS_Pos (17U) +#define USB_OTG_GUSBCFG_ULPIFSLS_Msk (0x1UL << USB_OTG_GUSBCFG_ULPIFSLS_Pos) /*!< 0x00020000 */ +#define USB_OTG_GUSBCFG_ULPIFSLS USB_OTG_GUSBCFG_ULPIFSLS_Msk /*!< ULPI FS/LS select */ +#define USB_OTG_GUSBCFG_ULPIAR_Pos (18U) +#define USB_OTG_GUSBCFG_ULPIAR_Msk (0x1UL << USB_OTG_GUSBCFG_ULPIAR_Pos) /*!< 0x00040000 */ +#define USB_OTG_GUSBCFG_ULPIAR USB_OTG_GUSBCFG_ULPIAR_Msk /*!< ULPI Auto-resume */ +#define USB_OTG_GUSBCFG_ULPICSM_Pos (19U) +#define USB_OTG_GUSBCFG_ULPICSM_Msk (0x1UL << USB_OTG_GUSBCFG_ULPICSM_Pos) /*!< 0x00080000 */ +#define USB_OTG_GUSBCFG_ULPICSM USB_OTG_GUSBCFG_ULPICSM_Msk /*!< ULPI Clock SuspendM */ +#define USB_OTG_GUSBCFG_ULPIEVBUSD_Pos (20U) +#define USB_OTG_GUSBCFG_ULPIEVBUSD_Msk (0x1UL << USB_OTG_GUSBCFG_ULPIEVBUSD_Pos) /*!< 0x00100000 */ +#define USB_OTG_GUSBCFG_ULPIEVBUSD USB_OTG_GUSBCFG_ULPIEVBUSD_Msk /*!< ULPI External VBUS Drive */ +#define USB_OTG_GUSBCFG_ULPIEVBUSI_Pos (21U) +#define USB_OTG_GUSBCFG_ULPIEVBUSI_Msk (0x1UL << USB_OTG_GUSBCFG_ULPIEVBUSI_Pos) /*!< 0x00200000 */ +#define USB_OTG_GUSBCFG_ULPIEVBUSI USB_OTG_GUSBCFG_ULPIEVBUSI_Msk /*!< ULPI external VBUS indicator */ +#define USB_OTG_GUSBCFG_TSDPS_Pos (22U) +#define USB_OTG_GUSBCFG_TSDPS_Msk (0x1UL << USB_OTG_GUSBCFG_TSDPS_Pos) /*!< 0x00400000 */ +#define USB_OTG_GUSBCFG_TSDPS USB_OTG_GUSBCFG_TSDPS_Msk /*!< TermSel DLine pulsing selection */ +#define USB_OTG_GUSBCFG_PCCI_Pos (23U) +#define USB_OTG_GUSBCFG_PCCI_Msk (0x1UL << USB_OTG_GUSBCFG_PCCI_Pos) /*!< 0x00800000 */ +#define USB_OTG_GUSBCFG_PCCI USB_OTG_GUSBCFG_PCCI_Msk /*!< Indicator complement */ +#define USB_OTG_GUSBCFG_PTCI_Pos (24U) +#define USB_OTG_GUSBCFG_PTCI_Msk (0x1UL << USB_OTG_GUSBCFG_PTCI_Pos) /*!< 0x01000000 */ +#define USB_OTG_GUSBCFG_PTCI USB_OTG_GUSBCFG_PTCI_Msk /*!< Indicator pass through */ +#define USB_OTG_GUSBCFG_ULPIIPD_Pos (25U) +#define USB_OTG_GUSBCFG_ULPIIPD_Msk (0x1UL << USB_OTG_GUSBCFG_ULPIIPD_Pos) /*!< 0x02000000 */ +#define USB_OTG_GUSBCFG_ULPIIPD USB_OTG_GUSBCFG_ULPIIPD_Msk /*!< ULPI interface protect disable */ +#define USB_OTG_GUSBCFG_FHMOD_Pos (29U) +#define USB_OTG_GUSBCFG_FHMOD_Msk (0x1UL << USB_OTG_GUSBCFG_FHMOD_Pos) /*!< 0x20000000 */ +#define USB_OTG_GUSBCFG_FHMOD USB_OTG_GUSBCFG_FHMOD_Msk /*!< Forced host mode */ +#define USB_OTG_GUSBCFG_FDMOD_Pos (30U) +#define USB_OTG_GUSBCFG_FDMOD_Msk (0x1UL << USB_OTG_GUSBCFG_FDMOD_Pos) /*!< 0x40000000 */ +#define USB_OTG_GUSBCFG_FDMOD USB_OTG_GUSBCFG_FDMOD_Msk /*!< Forced peripheral mode */ +#define USB_OTG_GUSBCFG_CTXPKT_Pos (31U) +#define USB_OTG_GUSBCFG_CTXPKT_Msk (0x1UL << USB_OTG_GUSBCFG_CTXPKT_Pos) /*!< 0x80000000 */ +#define USB_OTG_GUSBCFG_CTXPKT USB_OTG_GUSBCFG_CTXPKT_Msk /*!< Corrupt Tx packet */ + +/******************** Bit definition for USB_OTG_GRSTCTL register ********************/ +#define USB_OTG_GRSTCTL_CSRST_Pos (0U) +#define USB_OTG_GRSTCTL_CSRST_Msk (0x1UL << USB_OTG_GRSTCTL_CSRST_Pos) /*!< 0x00000001 */ +#define USB_OTG_GRSTCTL_CSRST USB_OTG_GRSTCTL_CSRST_Msk /*!< Core soft reset */ +#define USB_OTG_GRSTCTL_HSRST_Pos (1U) +#define USB_OTG_GRSTCTL_HSRST_Msk (0x1UL << USB_OTG_GRSTCTL_HSRST_Pos) /*!< 0x00000002 */ +#define USB_OTG_GRSTCTL_HSRST USB_OTG_GRSTCTL_HSRST_Msk /*!< HCLK soft reset */ +#define USB_OTG_GRSTCTL_FCRST_Pos (2U) +#define USB_OTG_GRSTCTL_FCRST_Msk (0x1UL << USB_OTG_GRSTCTL_FCRST_Pos) /*!< 0x00000004 */ +#define USB_OTG_GRSTCTL_FCRST USB_OTG_GRSTCTL_FCRST_Msk /*!< Host frame counter reset */ +#define USB_OTG_GRSTCTL_RXFFLSH_Pos (4U) +#define USB_OTG_GRSTCTL_RXFFLSH_Msk (0x1UL << USB_OTG_GRSTCTL_RXFFLSH_Pos) /*!< 0x00000010 */ +#define USB_OTG_GRSTCTL_RXFFLSH USB_OTG_GRSTCTL_RXFFLSH_Msk /*!< RxFIFO flush */ +#define USB_OTG_GRSTCTL_TXFFLSH_Pos (5U) +#define USB_OTG_GRSTCTL_TXFFLSH_Msk (0x1UL << USB_OTG_GRSTCTL_TXFFLSH_Pos) /*!< 0x00000020 */ +#define USB_OTG_GRSTCTL_TXFFLSH USB_OTG_GRSTCTL_TXFFLSH_Msk /*!< TxFIFO flush */ + + +#define USB_OTG_GRSTCTL_TXFNUM_Pos (6U) +#define USB_OTG_GRSTCTL_TXFNUM_Msk (0x1FUL << USB_OTG_GRSTCTL_TXFNUM_Pos) /*!< 0x000007C0 */ +#define USB_OTG_GRSTCTL_TXFNUM USB_OTG_GRSTCTL_TXFNUM_Msk /*!< TxFIFO number */ +#define USB_OTG_GRSTCTL_TXFNUM_0 (0x01UL << USB_OTG_GRSTCTL_TXFNUM_Pos) /*!< 0x00000040 */ +#define USB_OTG_GRSTCTL_TXFNUM_1 (0x02UL << USB_OTG_GRSTCTL_TXFNUM_Pos) /*!< 0x00000080 */ +#define USB_OTG_GRSTCTL_TXFNUM_2 (0x04UL << USB_OTG_GRSTCTL_TXFNUM_Pos) /*!< 0x00000100 */ +#define USB_OTG_GRSTCTL_TXFNUM_3 (0x08UL << USB_OTG_GRSTCTL_TXFNUM_Pos) /*!< 0x00000200 */ +#define USB_OTG_GRSTCTL_TXFNUM_4 (0x10UL << USB_OTG_GRSTCTL_TXFNUM_Pos) /*!< 0x00000400 */ +#define USB_OTG_GRSTCTL_DMAREQ_Pos (30U) +#define USB_OTG_GRSTCTL_DMAREQ_Msk (0x1UL << USB_OTG_GRSTCTL_DMAREQ_Pos) /*!< 0x40000000 */ +#define USB_OTG_GRSTCTL_DMAREQ USB_OTG_GRSTCTL_DMAREQ_Msk /*!< DMA request signal */ +#define USB_OTG_GRSTCTL_AHBIDL_Pos (31U) +#define USB_OTG_GRSTCTL_AHBIDL_Msk (0x1UL << USB_OTG_GRSTCTL_AHBIDL_Pos) /*!< 0x80000000 */ +#define USB_OTG_GRSTCTL_AHBIDL USB_OTG_GRSTCTL_AHBIDL_Msk /*!< AHB master idle */ + +/******************** Bit definition for USB_OTG_DIEPMSK register ********************/ +#define USB_OTG_DIEPMSK_XFRCM_Pos (0U) +#define USB_OTG_DIEPMSK_XFRCM_Msk (0x1UL << USB_OTG_DIEPMSK_XFRCM_Pos) /*!< 0x00000001 */ +#define USB_OTG_DIEPMSK_XFRCM USB_OTG_DIEPMSK_XFRCM_Msk /*!< Transfer completed interrupt mask */ +#define USB_OTG_DIEPMSK_EPDM_Pos (1U) +#define USB_OTG_DIEPMSK_EPDM_Msk (0x1UL << USB_OTG_DIEPMSK_EPDM_Pos) /*!< 0x00000002 */ +#define USB_OTG_DIEPMSK_EPDM USB_OTG_DIEPMSK_EPDM_Msk /*!< Endpoint disabled interrupt mask */ +#define USB_OTG_DIEPMSK_TOM_Pos (3U) +#define USB_OTG_DIEPMSK_TOM_Msk (0x1UL << USB_OTG_DIEPMSK_TOM_Pos) /*!< 0x00000008 */ +#define USB_OTG_DIEPMSK_TOM USB_OTG_DIEPMSK_TOM_Msk /*!< Timeout condition mask (nonisochronous endpoints) */ +#define USB_OTG_DIEPMSK_ITTXFEMSK_Pos (4U) +#define USB_OTG_DIEPMSK_ITTXFEMSK_Msk (0x1UL << USB_OTG_DIEPMSK_ITTXFEMSK_Pos) /*!< 0x00000010 */ +#define USB_OTG_DIEPMSK_ITTXFEMSK USB_OTG_DIEPMSK_ITTXFEMSK_Msk /*!< IN token received when TxFIFO empty mask */ +#define USB_OTG_DIEPMSK_INEPNMM_Pos (5U) +#define USB_OTG_DIEPMSK_INEPNMM_Msk (0x1UL << USB_OTG_DIEPMSK_INEPNMM_Pos) /*!< 0x00000020 */ +#define USB_OTG_DIEPMSK_INEPNMM USB_OTG_DIEPMSK_INEPNMM_Msk /*!< IN token received with EP mismatch mask */ +#define USB_OTG_DIEPMSK_INEPNEM_Pos (6U) +#define USB_OTG_DIEPMSK_INEPNEM_Msk (0x1UL << USB_OTG_DIEPMSK_INEPNEM_Pos) /*!< 0x00000040 */ +#define USB_OTG_DIEPMSK_INEPNEM USB_OTG_DIEPMSK_INEPNEM_Msk /*!< IN endpoint NAK effective mask */ +#define USB_OTG_DIEPMSK_TXFURM_Pos (8U) +#define USB_OTG_DIEPMSK_TXFURM_Msk (0x1UL << USB_OTG_DIEPMSK_TXFURM_Pos) /*!< 0x00000100 */ +#define USB_OTG_DIEPMSK_TXFURM USB_OTG_DIEPMSK_TXFURM_Msk /*!< FIFO underrun mask */ +#define USB_OTG_DIEPMSK_BIM_Pos (9U) +#define USB_OTG_DIEPMSK_BIM_Msk (0x1UL << USB_OTG_DIEPMSK_BIM_Pos) /*!< 0x00000200 */ +#define USB_OTG_DIEPMSK_BIM USB_OTG_DIEPMSK_BIM_Msk /*!< BNA interrupt mask */ + +/******************** Bit definition for USB_OTG_HPTXSTS register ********************/ +#define USB_OTG_HPTXSTS_PTXFSAVL_Pos (0U) +#define USB_OTG_HPTXSTS_PTXFSAVL_Msk (0xFFFFUL << USB_OTG_HPTXSTS_PTXFSAVL_Pos) /*!< 0x0000FFFF */ +#define USB_OTG_HPTXSTS_PTXFSAVL USB_OTG_HPTXSTS_PTXFSAVL_Msk /*!< Periodic transmit data FIFO space available */ +#define USB_OTG_HPTXSTS_PTXQSAV_Pos (16U) +#define USB_OTG_HPTXSTS_PTXQSAV_Msk (0xFFUL << USB_OTG_HPTXSTS_PTXQSAV_Pos) /*!< 0x00FF0000 */ +#define USB_OTG_HPTXSTS_PTXQSAV USB_OTG_HPTXSTS_PTXQSAV_Msk /*!< Periodic transmit request queue space available */ +#define USB_OTG_HPTXSTS_PTXQSAV_0 (0x01UL << USB_OTG_HPTXSTS_PTXQSAV_Pos) /*!< 0x00010000 */ +#define USB_OTG_HPTXSTS_PTXQSAV_1 (0x02UL << USB_OTG_HPTXSTS_PTXQSAV_Pos) /*!< 0x00020000 */ +#define USB_OTG_HPTXSTS_PTXQSAV_2 (0x04UL << USB_OTG_HPTXSTS_PTXQSAV_Pos) /*!< 0x00040000 */ +#define USB_OTG_HPTXSTS_PTXQSAV_3 (0x08UL << USB_OTG_HPTXSTS_PTXQSAV_Pos) /*!< 0x00080000 */ +#define USB_OTG_HPTXSTS_PTXQSAV_4 (0x10UL << USB_OTG_HPTXSTS_PTXQSAV_Pos) /*!< 0x00100000 */ +#define USB_OTG_HPTXSTS_PTXQSAV_5 (0x20UL << USB_OTG_HPTXSTS_PTXQSAV_Pos) /*!< 0x00200000 */ +#define USB_OTG_HPTXSTS_PTXQSAV_6 (0x40UL << USB_OTG_HPTXSTS_PTXQSAV_Pos) /*!< 0x00400000 */ +#define USB_OTG_HPTXSTS_PTXQSAV_7 (0x80UL << USB_OTG_HPTXSTS_PTXQSAV_Pos) /*!< 0x00800000 */ + +#define USB_OTG_HPTXSTS_PTXQTOP_Pos (24U) +#define USB_OTG_HPTXSTS_PTXQTOP_Msk (0xFFUL << USB_OTG_HPTXSTS_PTXQTOP_Pos) /*!< 0xFF000000 */ +#define USB_OTG_HPTXSTS_PTXQTOP USB_OTG_HPTXSTS_PTXQTOP_Msk /*!< Top of the periodic transmit request queue */ +#define USB_OTG_HPTXSTS_PTXQTOP_0 (0x01UL << USB_OTG_HPTXSTS_PTXQTOP_Pos) /*!< 0x01000000 */ +#define USB_OTG_HPTXSTS_PTXQTOP_1 (0x02UL << USB_OTG_HPTXSTS_PTXQTOP_Pos) /*!< 0x02000000 */ +#define USB_OTG_HPTXSTS_PTXQTOP_2 (0x04UL << USB_OTG_HPTXSTS_PTXQTOP_Pos) /*!< 0x04000000 */ +#define USB_OTG_HPTXSTS_PTXQTOP_3 (0x08UL << USB_OTG_HPTXSTS_PTXQTOP_Pos) /*!< 0x08000000 */ +#define USB_OTG_HPTXSTS_PTXQTOP_4 (0x10UL << USB_OTG_HPTXSTS_PTXQTOP_Pos) /*!< 0x10000000 */ +#define USB_OTG_HPTXSTS_PTXQTOP_5 (0x20UL << USB_OTG_HPTXSTS_PTXQTOP_Pos) /*!< 0x20000000 */ +#define USB_OTG_HPTXSTS_PTXQTOP_6 (0x40UL << USB_OTG_HPTXSTS_PTXQTOP_Pos) /*!< 0x40000000 */ +#define USB_OTG_HPTXSTS_PTXQTOP_7 (0x80UL << USB_OTG_HPTXSTS_PTXQTOP_Pos) /*!< 0x80000000 */ + +/******************** Bit definition for USB_OTG_HAINT register ********************/ +#define USB_OTG_HAINT_HAINT_Pos (0U) +#define USB_OTG_HAINT_HAINT_Msk (0xFFFFUL << USB_OTG_HAINT_HAINT_Pos) /*!< 0x0000FFFF */ +#define USB_OTG_HAINT_HAINT USB_OTG_HAINT_HAINT_Msk /*!< Channel interrupts */ + +/******************** Bit definition for USB_OTG_DOEPMSK register ********************/ +#define USB_OTG_DOEPMSK_XFRCM_Pos (0U) +#define USB_OTG_DOEPMSK_XFRCM_Msk (0x1UL << USB_OTG_DOEPMSK_XFRCM_Pos) /*!< 0x00000001 */ +#define USB_OTG_DOEPMSK_XFRCM USB_OTG_DOEPMSK_XFRCM_Msk /*!< Transfer completed interrupt mask */ +#define USB_OTG_DOEPMSK_EPDM_Pos (1U) +#define USB_OTG_DOEPMSK_EPDM_Msk (0x1UL << USB_OTG_DOEPMSK_EPDM_Pos) /*!< 0x00000002 */ +#define USB_OTG_DOEPMSK_EPDM USB_OTG_DOEPMSK_EPDM_Msk /*!< Endpoint disabled interrupt mask */ +#define USB_OTG_DOEPMSK_AHBERRM_Pos (2U) +#define USB_OTG_DOEPMSK_AHBERRM_Msk (0x1UL << USB_OTG_DOEPMSK_AHBERRM_Pos) /*!< 0x00000004 */ +#define USB_OTG_DOEPMSK_AHBERRM USB_OTG_DOEPMSK_AHBERRM_Msk /*!< OUT transaction AHB Error interrupt mask */ +#define USB_OTG_DOEPMSK_STUPM_Pos (3U) +#define USB_OTG_DOEPMSK_STUPM_Msk (0x1UL << USB_OTG_DOEPMSK_STUPM_Pos) /*!< 0x00000008 */ +#define USB_OTG_DOEPMSK_STUPM USB_OTG_DOEPMSK_STUPM_Msk /*!< SETUP phase done mask */ +#define USB_OTG_DOEPMSK_OTEPDM_Pos (4U) +#define USB_OTG_DOEPMSK_OTEPDM_Msk (0x1UL << USB_OTG_DOEPMSK_OTEPDM_Pos) /*!< 0x00000010 */ +#define USB_OTG_DOEPMSK_OTEPDM USB_OTG_DOEPMSK_OTEPDM_Msk /*!< OUT token received when endpoint disabled mask */ +#define USB_OTG_DOEPMSK_OTEPSPRM_Pos (5U) +#define USB_OTG_DOEPMSK_OTEPSPRM_Msk (0x1UL << USB_OTG_DOEPMSK_OTEPSPRM_Pos) /*!< 0x00000020 */ +#define USB_OTG_DOEPMSK_OTEPSPRM USB_OTG_DOEPMSK_OTEPSPRM_Msk /*!< Status Phase Received mask */ +#define USB_OTG_DOEPMSK_B2BSTUP_Pos (6U) +#define USB_OTG_DOEPMSK_B2BSTUP_Msk (0x1UL << USB_OTG_DOEPMSK_B2BSTUP_Pos) /*!< 0x00000040 */ +#define USB_OTG_DOEPMSK_B2BSTUP USB_OTG_DOEPMSK_B2BSTUP_Msk /*!< Back-to-back SETUP packets received mask */ +#define USB_OTG_DOEPMSK_OPEM_Pos (8U) +#define USB_OTG_DOEPMSK_OPEM_Msk (0x1UL << USB_OTG_DOEPMSK_OPEM_Pos) /*!< 0x00000100 */ +#define USB_OTG_DOEPMSK_OPEM USB_OTG_DOEPMSK_OPEM_Msk /*!< OUT packet error mask */ +#define USB_OTG_DOEPMSK_BOIM_Pos (9U) +#define USB_OTG_DOEPMSK_BOIM_Msk (0x1UL << USB_OTG_DOEPMSK_BOIM_Pos) /*!< 0x00000200 */ +#define USB_OTG_DOEPMSK_BOIM USB_OTG_DOEPMSK_BOIM_Msk /*!< BNA interrupt mask */ +#define USB_OTG_DOEPMSK_BERRM_Pos (12U) +#define USB_OTG_DOEPMSK_BERRM_Msk (0x1UL << USB_OTG_DOEPMSK_BERRM_Pos) /*!< 0x00001000 */ +#define USB_OTG_DOEPMSK_BERRM USB_OTG_DOEPMSK_BERRM_Msk /*!< Babble error interrupt mask */ +#define USB_OTG_DOEPMSK_NAKM_Pos (13U) +#define USB_OTG_DOEPMSK_NAKM_Msk (0x1UL << USB_OTG_DOEPMSK_NAKM_Pos) /*!< 0x00002000 */ +#define USB_OTG_DOEPMSK_NAKM USB_OTG_DOEPMSK_NAKM_Msk /*!< OUT Packet NAK interrupt mask */ +#define USB_OTG_DOEPMSK_NYETM_Pos (14U) +#define USB_OTG_DOEPMSK_NYETM_Msk (0x1UL << USB_OTG_DOEPMSK_NYETM_Pos) /*!< 0x00004000 */ +#define USB_OTG_DOEPMSK_NYETM USB_OTG_DOEPMSK_NYETM_Msk /*!< NYET interrupt mask */ +/******************** Bit definition for USB_OTG_GINTSTS register ********************/ +#define USB_OTG_GINTSTS_CMOD_Pos (0U) +#define USB_OTG_GINTSTS_CMOD_Msk (0x1UL << USB_OTG_GINTSTS_CMOD_Pos) /*!< 0x00000001 */ +#define USB_OTG_GINTSTS_CMOD USB_OTG_GINTSTS_CMOD_Msk /*!< Current mode of operation */ +#define USB_OTG_GINTSTS_MMIS_Pos (1U) +#define USB_OTG_GINTSTS_MMIS_Msk (0x1UL << USB_OTG_GINTSTS_MMIS_Pos) /*!< 0x00000002 */ +#define USB_OTG_GINTSTS_MMIS USB_OTG_GINTSTS_MMIS_Msk /*!< Mode mismatch interrupt */ +#define USB_OTG_GINTSTS_OTGINT_Pos (2U) +#define USB_OTG_GINTSTS_OTGINT_Msk (0x1UL << USB_OTG_GINTSTS_OTGINT_Pos) /*!< 0x00000004 */ +#define USB_OTG_GINTSTS_OTGINT USB_OTG_GINTSTS_OTGINT_Msk /*!< OTG interrupt */ +#define USB_OTG_GINTSTS_SOF_Pos (3U) +#define USB_OTG_GINTSTS_SOF_Msk (0x1UL << USB_OTG_GINTSTS_SOF_Pos) /*!< 0x00000008 */ +#define USB_OTG_GINTSTS_SOF USB_OTG_GINTSTS_SOF_Msk /*!< Start of frame */ +#define USB_OTG_GINTSTS_RXFLVL_Pos (4U) +#define USB_OTG_GINTSTS_RXFLVL_Msk (0x1UL << USB_OTG_GINTSTS_RXFLVL_Pos) /*!< 0x00000010 */ +#define USB_OTG_GINTSTS_RXFLVL USB_OTG_GINTSTS_RXFLVL_Msk /*!< RxFIFO nonempty */ +#define USB_OTG_GINTSTS_NPTXFE_Pos (5U) +#define USB_OTG_GINTSTS_NPTXFE_Msk (0x1UL << USB_OTG_GINTSTS_NPTXFE_Pos) /*!< 0x00000020 */ +#define USB_OTG_GINTSTS_NPTXFE USB_OTG_GINTSTS_NPTXFE_Msk /*!< Nonperiodic TxFIFO empty */ +#define USB_OTG_GINTSTS_GINAKEFF_Pos (6U) +#define USB_OTG_GINTSTS_GINAKEFF_Msk (0x1UL << USB_OTG_GINTSTS_GINAKEFF_Pos) /*!< 0x00000040 */ +#define USB_OTG_GINTSTS_GINAKEFF USB_OTG_GINTSTS_GINAKEFF_Msk /*!< Global IN nonperiodic NAK effective */ +#define USB_OTG_GINTSTS_BOUTNAKEFF_Pos (7U) +#define USB_OTG_GINTSTS_BOUTNAKEFF_Msk (0x1UL << USB_OTG_GINTSTS_BOUTNAKEFF_Pos) /*!< 0x00000080 */ +#define USB_OTG_GINTSTS_BOUTNAKEFF USB_OTG_GINTSTS_BOUTNAKEFF_Msk /*!< Global OUT NAK effective */ +#define USB_OTG_GINTSTS_ESUSP_Pos (10U) +#define USB_OTG_GINTSTS_ESUSP_Msk (0x1UL << USB_OTG_GINTSTS_ESUSP_Pos) /*!< 0x00000400 */ +#define USB_OTG_GINTSTS_ESUSP USB_OTG_GINTSTS_ESUSP_Msk /*!< Early suspend */ +#define USB_OTG_GINTSTS_USBSUSP_Pos (11U) +#define USB_OTG_GINTSTS_USBSUSP_Msk (0x1UL << USB_OTG_GINTSTS_USBSUSP_Pos) /*!< 0x00000800 */ +#define USB_OTG_GINTSTS_USBSUSP USB_OTG_GINTSTS_USBSUSP_Msk /*!< USB suspend */ +#define USB_OTG_GINTSTS_USBRST_Pos (12U) +#define USB_OTG_GINTSTS_USBRST_Msk (0x1UL << USB_OTG_GINTSTS_USBRST_Pos) /*!< 0x00001000 */ +#define USB_OTG_GINTSTS_USBRST USB_OTG_GINTSTS_USBRST_Msk /*!< USB reset */ +#define USB_OTG_GINTSTS_ENUMDNE_Pos (13U) +#define USB_OTG_GINTSTS_ENUMDNE_Msk (0x1UL << USB_OTG_GINTSTS_ENUMDNE_Pos) /*!< 0x00002000 */ +#define USB_OTG_GINTSTS_ENUMDNE USB_OTG_GINTSTS_ENUMDNE_Msk /*!< Enumeration done */ +#define USB_OTG_GINTSTS_ISOODRP_Pos (14U) +#define USB_OTG_GINTSTS_ISOODRP_Msk (0x1UL << USB_OTG_GINTSTS_ISOODRP_Pos) /*!< 0x00004000 */ +#define USB_OTG_GINTSTS_ISOODRP USB_OTG_GINTSTS_ISOODRP_Msk /*!< Isochronous OUT packet dropped interrupt */ +#define USB_OTG_GINTSTS_EOPF_Pos (15U) +#define USB_OTG_GINTSTS_EOPF_Msk (0x1UL << USB_OTG_GINTSTS_EOPF_Pos) /*!< 0x00008000 */ +#define USB_OTG_GINTSTS_EOPF USB_OTG_GINTSTS_EOPF_Msk /*!< End of periodic frame interrupt */ +#define USB_OTG_GINTSTS_IEPINT_Pos (18U) +#define USB_OTG_GINTSTS_IEPINT_Msk (0x1UL << USB_OTG_GINTSTS_IEPINT_Pos) /*!< 0x00040000 */ +#define USB_OTG_GINTSTS_IEPINT USB_OTG_GINTSTS_IEPINT_Msk /*!< IN endpoint interrupt */ +#define USB_OTG_GINTSTS_OEPINT_Pos (19U) +#define USB_OTG_GINTSTS_OEPINT_Msk (0x1UL << USB_OTG_GINTSTS_OEPINT_Pos) /*!< 0x00080000 */ +#define USB_OTG_GINTSTS_OEPINT USB_OTG_GINTSTS_OEPINT_Msk /*!< OUT endpoint interrupt */ +#define USB_OTG_GINTSTS_IISOIXFR_Pos (20U) +#define USB_OTG_GINTSTS_IISOIXFR_Msk (0x1UL << USB_OTG_GINTSTS_IISOIXFR_Pos) /*!< 0x00100000 */ +#define USB_OTG_GINTSTS_IISOIXFR USB_OTG_GINTSTS_IISOIXFR_Msk /*!< Incomplete isochronous IN transfer */ +#define USB_OTG_GINTSTS_PXFR_INCOMPISOOUT_Pos (21U) +#define USB_OTG_GINTSTS_PXFR_INCOMPISOOUT_Msk (0x1UL << USB_OTG_GINTSTS_PXFR_INCOMPISOOUT_Pos) /*!< 0x00200000 */ +#define USB_OTG_GINTSTS_PXFR_INCOMPISOOUT USB_OTG_GINTSTS_PXFR_INCOMPISOOUT_Msk /*!< Incomplete periodic transfer */ +#define USB_OTG_GINTSTS_DATAFSUSP_Pos (22U) +#define USB_OTG_GINTSTS_DATAFSUSP_Msk (0x1UL << USB_OTG_GINTSTS_DATAFSUSP_Pos) /*!< 0x00400000 */ +#define USB_OTG_GINTSTS_DATAFSUSP USB_OTG_GINTSTS_DATAFSUSP_Msk /*!< Data fetch suspended */ +#define USB_OTG_GINTSTS_HPRTINT_Pos (24U) +#define USB_OTG_GINTSTS_HPRTINT_Msk (0x1UL << USB_OTG_GINTSTS_HPRTINT_Pos) /*!< 0x01000000 */ +#define USB_OTG_GINTSTS_HPRTINT USB_OTG_GINTSTS_HPRTINT_Msk /*!< Host port interrupt */ +#define USB_OTG_GINTSTS_HCINT_Pos (25U) +#define USB_OTG_GINTSTS_HCINT_Msk (0x1UL << USB_OTG_GINTSTS_HCINT_Pos) /*!< 0x02000000 */ +#define USB_OTG_GINTSTS_HCINT USB_OTG_GINTSTS_HCINT_Msk /*!< Host channels interrupt */ +#define USB_OTG_GINTSTS_PTXFE_Pos (26U) +#define USB_OTG_GINTSTS_PTXFE_Msk (0x1UL << USB_OTG_GINTSTS_PTXFE_Pos) /*!< 0x04000000 */ +#define USB_OTG_GINTSTS_PTXFE USB_OTG_GINTSTS_PTXFE_Msk /*!< Periodic TxFIFO empty */ +#define USB_OTG_GINTSTS_CIDSCHG_Pos (28U) +#define USB_OTG_GINTSTS_CIDSCHG_Msk (0x1UL << USB_OTG_GINTSTS_CIDSCHG_Pos) /*!< 0x10000000 */ +#define USB_OTG_GINTSTS_CIDSCHG USB_OTG_GINTSTS_CIDSCHG_Msk /*!< Connector ID status change */ +#define USB_OTG_GINTSTS_DISCINT_Pos (29U) +#define USB_OTG_GINTSTS_DISCINT_Msk (0x1UL << USB_OTG_GINTSTS_DISCINT_Pos) /*!< 0x20000000 */ +#define USB_OTG_GINTSTS_DISCINT USB_OTG_GINTSTS_DISCINT_Msk /*!< Disconnect detected interrupt */ +#define USB_OTG_GINTSTS_SRQINT_Pos (30U) +#define USB_OTG_GINTSTS_SRQINT_Msk (0x1UL << USB_OTG_GINTSTS_SRQINT_Pos) /*!< 0x40000000 */ +#define USB_OTG_GINTSTS_SRQINT USB_OTG_GINTSTS_SRQINT_Msk /*!< Session request/new session detected interrupt */ +#define USB_OTG_GINTSTS_WKUINT_Pos (31U) +#define USB_OTG_GINTSTS_WKUINT_Msk (0x1UL << USB_OTG_GINTSTS_WKUINT_Pos) /*!< 0x80000000 */ +#define USB_OTG_GINTSTS_WKUINT USB_OTG_GINTSTS_WKUINT_Msk /*!< Resume/remote wakeup detected interrupt */ + +/******************** Bit definition for USB_OTG_GINTMSK register ********************/ +#define USB_OTG_GINTMSK_MMISM_Pos (1U) +#define USB_OTG_GINTMSK_MMISM_Msk (0x1UL << USB_OTG_GINTMSK_MMISM_Pos) /*!< 0x00000002 */ +#define USB_OTG_GINTMSK_MMISM USB_OTG_GINTMSK_MMISM_Msk /*!< Mode mismatch interrupt mask */ +#define USB_OTG_GINTMSK_OTGINT_Pos (2U) +#define USB_OTG_GINTMSK_OTGINT_Msk (0x1UL << USB_OTG_GINTMSK_OTGINT_Pos) /*!< 0x00000004 */ +#define USB_OTG_GINTMSK_OTGINT USB_OTG_GINTMSK_OTGINT_Msk /*!< OTG interrupt mask */ +#define USB_OTG_GINTMSK_SOFM_Pos (3U) +#define USB_OTG_GINTMSK_SOFM_Msk (0x1UL << USB_OTG_GINTMSK_SOFM_Pos) /*!< 0x00000008 */ +#define USB_OTG_GINTMSK_SOFM USB_OTG_GINTMSK_SOFM_Msk /*!< Start of frame mask */ +#define USB_OTG_GINTMSK_RXFLVLM_Pos (4U) +#define USB_OTG_GINTMSK_RXFLVLM_Msk (0x1UL << USB_OTG_GINTMSK_RXFLVLM_Pos) /*!< 0x00000010 */ +#define USB_OTG_GINTMSK_RXFLVLM USB_OTG_GINTMSK_RXFLVLM_Msk /*!< Receive FIFO nonempty mask */ +#define USB_OTG_GINTMSK_NPTXFEM_Pos (5U) +#define USB_OTG_GINTMSK_NPTXFEM_Msk (0x1UL << USB_OTG_GINTMSK_NPTXFEM_Pos) /*!< 0x00000020 */ +#define USB_OTG_GINTMSK_NPTXFEM USB_OTG_GINTMSK_NPTXFEM_Msk /*!< Nonperiodic TxFIFO empty mask */ +#define USB_OTG_GINTMSK_GINAKEFFM_Pos (6U) +#define USB_OTG_GINTMSK_GINAKEFFM_Msk (0x1UL << USB_OTG_GINTMSK_GINAKEFFM_Pos) /*!< 0x00000040 */ +#define USB_OTG_GINTMSK_GINAKEFFM USB_OTG_GINTMSK_GINAKEFFM_Msk /*!< Global nonperiodic IN NAK effective mask */ +#define USB_OTG_GINTMSK_GONAKEFFM_Pos (7U) +#define USB_OTG_GINTMSK_GONAKEFFM_Msk (0x1UL << USB_OTG_GINTMSK_GONAKEFFM_Pos) /*!< 0x00000080 */ +#define USB_OTG_GINTMSK_GONAKEFFM USB_OTG_GINTMSK_GONAKEFFM_Msk /*!< Global OUT NAK effective mask */ +#define USB_OTG_GINTMSK_ESUSPM_Pos (10U) +#define USB_OTG_GINTMSK_ESUSPM_Msk (0x1UL << USB_OTG_GINTMSK_ESUSPM_Pos) /*!< 0x00000400 */ +#define USB_OTG_GINTMSK_ESUSPM USB_OTG_GINTMSK_ESUSPM_Msk /*!< Early suspend mask */ +#define USB_OTG_GINTMSK_USBSUSPM_Pos (11U) +#define USB_OTG_GINTMSK_USBSUSPM_Msk (0x1UL << USB_OTG_GINTMSK_USBSUSPM_Pos) /*!< 0x00000800 */ +#define USB_OTG_GINTMSK_USBSUSPM USB_OTG_GINTMSK_USBSUSPM_Msk /*!< USB suspend mask */ +#define USB_OTG_GINTMSK_USBRST_Pos (12U) +#define USB_OTG_GINTMSK_USBRST_Msk (0x1UL << USB_OTG_GINTMSK_USBRST_Pos) /*!< 0x00001000 */ +#define USB_OTG_GINTMSK_USBRST USB_OTG_GINTMSK_USBRST_Msk /*!< USB reset mask */ +#define USB_OTG_GINTMSK_ENUMDNEM_Pos (13U) +#define USB_OTG_GINTMSK_ENUMDNEM_Msk (0x1UL << USB_OTG_GINTMSK_ENUMDNEM_Pos) /*!< 0x00002000 */ +#define USB_OTG_GINTMSK_ENUMDNEM USB_OTG_GINTMSK_ENUMDNEM_Msk /*!< Enumeration done mask */ +#define USB_OTG_GINTMSK_ISOODRPM_Pos (14U) +#define USB_OTG_GINTMSK_ISOODRPM_Msk (0x1UL << USB_OTG_GINTMSK_ISOODRPM_Pos) /*!< 0x00004000 */ +#define USB_OTG_GINTMSK_ISOODRPM USB_OTG_GINTMSK_ISOODRPM_Msk /*!< Isochronous OUT packet dropped interrupt mask */ +#define USB_OTG_GINTMSK_EOPFM_Pos (15U) +#define USB_OTG_GINTMSK_EOPFM_Msk (0x1UL << USB_OTG_GINTMSK_EOPFM_Pos) /*!< 0x00008000 */ +#define USB_OTG_GINTMSK_EOPFM USB_OTG_GINTMSK_EOPFM_Msk /*!< End of periodic frame interrupt mask */ +#define USB_OTG_GINTMSK_EPMISM_Pos (17U) +#define USB_OTG_GINTMSK_EPMISM_Msk (0x1UL << USB_OTG_GINTMSK_EPMISM_Pos) /*!< 0x00020000 */ +#define USB_OTG_GINTMSK_EPMISM USB_OTG_GINTMSK_EPMISM_Msk /*!< Endpoint mismatch interrupt mask */ +#define USB_OTG_GINTMSK_IEPINT_Pos (18U) +#define USB_OTG_GINTMSK_IEPINT_Msk (0x1UL << USB_OTG_GINTMSK_IEPINT_Pos) /*!< 0x00040000 */ +#define USB_OTG_GINTMSK_IEPINT USB_OTG_GINTMSK_IEPINT_Msk /*!< IN endpoints interrupt mask */ +#define USB_OTG_GINTMSK_OEPINT_Pos (19U) +#define USB_OTG_GINTMSK_OEPINT_Msk (0x1UL << USB_OTG_GINTMSK_OEPINT_Pos) /*!< 0x00080000 */ +#define USB_OTG_GINTMSK_OEPINT USB_OTG_GINTMSK_OEPINT_Msk /*!< OUT endpoints interrupt mask */ +#define USB_OTG_GINTMSK_IISOIXFRM_Pos (20U) +#define USB_OTG_GINTMSK_IISOIXFRM_Msk (0x1UL << USB_OTG_GINTMSK_IISOIXFRM_Pos) /*!< 0x00100000 */ +#define USB_OTG_GINTMSK_IISOIXFRM USB_OTG_GINTMSK_IISOIXFRM_Msk /*!< Incomplete isochronous IN transfer mask */ +#define USB_OTG_GINTMSK_PXFRM_IISOOXFRM_Pos (21U) +#define USB_OTG_GINTMSK_PXFRM_IISOOXFRM_Msk (0x1UL << USB_OTG_GINTMSK_PXFRM_IISOOXFRM_Pos) /*!< 0x00200000 */ +#define USB_OTG_GINTMSK_PXFRM_IISOOXFRM USB_OTG_GINTMSK_PXFRM_IISOOXFRM_Msk /*!< Incomplete periodic transfer mask */ +#define USB_OTG_GINTMSK_FSUSPM_Pos (22U) +#define USB_OTG_GINTMSK_FSUSPM_Msk (0x1UL << USB_OTG_GINTMSK_FSUSPM_Pos) /*!< 0x00400000 */ +#define USB_OTG_GINTMSK_FSUSPM USB_OTG_GINTMSK_FSUSPM_Msk /*!< Data fetch suspended mask */ +#define USB_OTG_GINTMSK_PRTIM_Pos (24U) +#define USB_OTG_GINTMSK_PRTIM_Msk (0x1UL << USB_OTG_GINTMSK_PRTIM_Pos) /*!< 0x01000000 */ +#define USB_OTG_GINTMSK_PRTIM USB_OTG_GINTMSK_PRTIM_Msk /*!< Host port interrupt mask */ +#define USB_OTG_GINTMSK_HCIM_Pos (25U) +#define USB_OTG_GINTMSK_HCIM_Msk (0x1UL << USB_OTG_GINTMSK_HCIM_Pos) /*!< 0x02000000 */ +#define USB_OTG_GINTMSK_HCIM USB_OTG_GINTMSK_HCIM_Msk /*!< Host channels interrupt mask */ +#define USB_OTG_GINTMSK_PTXFEM_Pos (26U) +#define USB_OTG_GINTMSK_PTXFEM_Msk (0x1UL << USB_OTG_GINTMSK_PTXFEM_Pos) /*!< 0x04000000 */ +#define USB_OTG_GINTMSK_PTXFEM USB_OTG_GINTMSK_PTXFEM_Msk /*!< Periodic TxFIFO empty mask */ +#define USB_OTG_GINTMSK_CIDSCHGM_Pos (28U) +#define USB_OTG_GINTMSK_CIDSCHGM_Msk (0x1UL << USB_OTG_GINTMSK_CIDSCHGM_Pos) /*!< 0x10000000 */ +#define USB_OTG_GINTMSK_CIDSCHGM USB_OTG_GINTMSK_CIDSCHGM_Msk /*!< Connector ID status change mask */ +#define USB_OTG_GINTMSK_DISCINT_Pos (29U) +#define USB_OTG_GINTMSK_DISCINT_Msk (0x1UL << USB_OTG_GINTMSK_DISCINT_Pos) /*!< 0x20000000 */ +#define USB_OTG_GINTMSK_DISCINT USB_OTG_GINTMSK_DISCINT_Msk /*!< Disconnect detected interrupt mask */ +#define USB_OTG_GINTMSK_SRQIM_Pos (30U) +#define USB_OTG_GINTMSK_SRQIM_Msk (0x1UL << USB_OTG_GINTMSK_SRQIM_Pos) /*!< 0x40000000 */ +#define USB_OTG_GINTMSK_SRQIM USB_OTG_GINTMSK_SRQIM_Msk /*!< Session request/new session detected interrupt mask */ +#define USB_OTG_GINTMSK_WUIM_Pos (31U) +#define USB_OTG_GINTMSK_WUIM_Msk (0x1UL << USB_OTG_GINTMSK_WUIM_Pos) /*!< 0x80000000 */ +#define USB_OTG_GINTMSK_WUIM USB_OTG_GINTMSK_WUIM_Msk /*!< Resume/remote wakeup detected interrupt mask */ + +/******************** Bit definition for USB_OTG_DAINT register ********************/ +#define USB_OTG_DAINT_IEPINT_Pos (0U) +#define USB_OTG_DAINT_IEPINT_Msk (0xFFFFUL << USB_OTG_DAINT_IEPINT_Pos) /*!< 0x0000FFFF */ +#define USB_OTG_DAINT_IEPINT USB_OTG_DAINT_IEPINT_Msk /*!< IN endpoint interrupt bits */ +#define USB_OTG_DAINT_OEPINT_Pos (16U) +#define USB_OTG_DAINT_OEPINT_Msk (0xFFFFUL << USB_OTG_DAINT_OEPINT_Pos) /*!< 0xFFFF0000 */ +#define USB_OTG_DAINT_OEPINT USB_OTG_DAINT_OEPINT_Msk /*!< OUT endpoint interrupt bits */ + +/******************** Bit definition for USB_OTG_HAINTMSK register ********************/ +#define USB_OTG_HAINTMSK_HAINTM_Pos (0U) +#define USB_OTG_HAINTMSK_HAINTM_Msk (0xFFFFUL << USB_OTG_HAINTMSK_HAINTM_Pos) /*!< 0x0000FFFF */ +#define USB_OTG_HAINTMSK_HAINTM USB_OTG_HAINTMSK_HAINTM_Msk /*!< Channel interrupt mask */ + +/******************** Bit definition for USB_OTG_GRXSTSP register ********************/ +#define USB_OTG_GRXSTSP_EPNUM_Pos (0U) +#define USB_OTG_GRXSTSP_EPNUM_Msk (0xFUL << USB_OTG_GRXSTSP_EPNUM_Pos) /*!< 0x0000000F */ +#define USB_OTG_GRXSTSP_EPNUM USB_OTG_GRXSTSP_EPNUM_Msk /*!< IN EP interrupt mask bits */ +#define USB_OTG_GRXSTSP_BCNT_Pos (4U) +#define USB_OTG_GRXSTSP_BCNT_Msk (0x7FFUL << USB_OTG_GRXSTSP_BCNT_Pos) /*!< 0x00007FF0 */ +#define USB_OTG_GRXSTSP_BCNT USB_OTG_GRXSTSP_BCNT_Msk /*!< OUT EP interrupt mask bits */ +#define USB_OTG_GRXSTSP_DPID_Pos (15U) +#define USB_OTG_GRXSTSP_DPID_Msk (0x3UL << USB_OTG_GRXSTSP_DPID_Pos) /*!< 0x00018000 */ +#define USB_OTG_GRXSTSP_DPID USB_OTG_GRXSTSP_DPID_Msk /*!< OUT EP interrupt mask bits */ +#define USB_OTG_GRXSTSP_PKTSTS_Pos (17U) +#define USB_OTG_GRXSTSP_PKTSTS_Msk (0xFUL << USB_OTG_GRXSTSP_PKTSTS_Pos) /*!< 0x001E0000 */ +#define USB_OTG_GRXSTSP_PKTSTS USB_OTG_GRXSTSP_PKTSTS_Msk /*!< OUT EP interrupt mask bits */ + +/******************** Bit definition for USB_OTG_DAINTMSK register ********************/ +#define USB_OTG_DAINTMSK_IEPM_Pos (0U) +#define USB_OTG_DAINTMSK_IEPM_Msk (0xFFFFUL << USB_OTG_DAINTMSK_IEPM_Pos) /*!< 0x0000FFFF */ +#define USB_OTG_DAINTMSK_IEPM USB_OTG_DAINTMSK_IEPM_Msk /*!< IN EP interrupt mask bits */ +#define USB_OTG_DAINTMSK_OEPM_Pos (16U) +#define USB_OTG_DAINTMSK_OEPM_Msk (0xFFFFUL << USB_OTG_DAINTMSK_OEPM_Pos) /*!< 0xFFFF0000 */ +#define USB_OTG_DAINTMSK_OEPM USB_OTG_DAINTMSK_OEPM_Msk /*!< OUT EP interrupt mask bits */ + +/******************** Bit definition for USB_OTG_GRXFSIZ register ********************/ +#define USB_OTG_GRXFSIZ_RXFD_Pos (0U) +#define USB_OTG_GRXFSIZ_RXFD_Msk (0xFFFFUL << USB_OTG_GRXFSIZ_RXFD_Pos) /*!< 0x0000FFFF */ +#define USB_OTG_GRXFSIZ_RXFD USB_OTG_GRXFSIZ_RXFD_Msk /*!< RxFIFO depth */ + +/******************** Bit definition for USB_OTG_DVBUSDIS register ********************/ +#define USB_OTG_DVBUSDIS_VBUSDT_Pos (0U) +#define USB_OTG_DVBUSDIS_VBUSDT_Msk (0xFFFFUL << USB_OTG_DVBUSDIS_VBUSDT_Pos) /*!< 0x0000FFFF */ +#define USB_OTG_DVBUSDIS_VBUSDT USB_OTG_DVBUSDIS_VBUSDT_Msk /*!< Device VBUS discharge time */ + +/******************** Bit definition for OTG register ********************/ +#define USB_OTG_NPTXFSA_Pos (0U) +#define USB_OTG_NPTXFSA_Msk (0xFFFFUL << USB_OTG_NPTXFSA_Pos) /*!< 0x0000FFFF */ +#define USB_OTG_NPTXFSA USB_OTG_NPTXFSA_Msk /*!< Nonperiodic transmit RAM start address */ +#define USB_OTG_NPTXFD_Pos (16U) +#define USB_OTG_NPTXFD_Msk (0xFFFFUL << USB_OTG_NPTXFD_Pos) /*!< 0xFFFF0000 */ +#define USB_OTG_NPTXFD USB_OTG_NPTXFD_Msk /*!< Nonperiodic TxFIFO depth */ +#define USB_OTG_TX0FSA_Pos (0U) +#define USB_OTG_TX0FSA_Msk (0xFFFFUL << USB_OTG_TX0FSA_Pos) /*!< 0x0000FFFF */ +#define USB_OTG_TX0FSA USB_OTG_TX0FSA_Msk /*!< Endpoint 0 transmit RAM start address */ +#define USB_OTG_TX0FD_Pos (16U) +#define USB_OTG_TX0FD_Msk (0xFFFFUL << USB_OTG_TX0FD_Pos) /*!< 0xFFFF0000 */ +#define USB_OTG_TX0FD USB_OTG_TX0FD_Msk /*!< Endpoint 0 TxFIFO depth */ + +/******************** Bit definition for USB_OTG_DVBUSPULSE register ********************/ +#define USB_OTG_DVBUSPULSE_DVBUSP_Pos (0U) +#define USB_OTG_DVBUSPULSE_DVBUSP_Msk (0xFFFUL << USB_OTG_DVBUSPULSE_DVBUSP_Pos) /*!< 0x00000FFF */ +#define USB_OTG_DVBUSPULSE_DVBUSP USB_OTG_DVBUSPULSE_DVBUSP_Msk /*!< Device VBUS pulsing time */ + +/******************** Bit definition for USB_OTG_GNPTXSTS register ********************/ +#define USB_OTG_GNPTXSTS_NPTXFSAV_Pos (0U) +#define USB_OTG_GNPTXSTS_NPTXFSAV_Msk (0xFFFFUL << USB_OTG_GNPTXSTS_NPTXFSAV_Pos) /*!< 0x0000FFFF */ +#define USB_OTG_GNPTXSTS_NPTXFSAV USB_OTG_GNPTXSTS_NPTXFSAV_Msk /*!< Nonperiodic TxFIFO space available */ + +#define USB_OTG_GNPTXSTS_NPTQXSAV_Pos (16U) +#define USB_OTG_GNPTXSTS_NPTQXSAV_Msk (0xFFUL << USB_OTG_GNPTXSTS_NPTQXSAV_Pos) /*!< 0x00FF0000 */ +#define USB_OTG_GNPTXSTS_NPTQXSAV USB_OTG_GNPTXSTS_NPTQXSAV_Msk /*!< Nonperiodic transmit request queue space available */ +#define USB_OTG_GNPTXSTS_NPTQXSAV_0 (0x01UL << USB_OTG_GNPTXSTS_NPTQXSAV_Pos) /*!< 0x00010000 */ +#define USB_OTG_GNPTXSTS_NPTQXSAV_1 (0x02UL << USB_OTG_GNPTXSTS_NPTQXSAV_Pos) /*!< 0x00020000 */ +#define USB_OTG_GNPTXSTS_NPTQXSAV_2 (0x04UL << USB_OTG_GNPTXSTS_NPTQXSAV_Pos) /*!< 0x00040000 */ +#define USB_OTG_GNPTXSTS_NPTQXSAV_3 (0x08UL << USB_OTG_GNPTXSTS_NPTQXSAV_Pos) /*!< 0x00080000 */ +#define USB_OTG_GNPTXSTS_NPTQXSAV_4 (0x10UL << USB_OTG_GNPTXSTS_NPTQXSAV_Pos) /*!< 0x00100000 */ +#define USB_OTG_GNPTXSTS_NPTQXSAV_5 (0x20UL << USB_OTG_GNPTXSTS_NPTQXSAV_Pos) /*!< 0x00200000 */ +#define USB_OTG_GNPTXSTS_NPTQXSAV_6 (0x40UL << USB_OTG_GNPTXSTS_NPTQXSAV_Pos) /*!< 0x00400000 */ +#define USB_OTG_GNPTXSTS_NPTQXSAV_7 (0x80UL << USB_OTG_GNPTXSTS_NPTQXSAV_Pos) /*!< 0x00800000 */ + +#define USB_OTG_GNPTXSTS_NPTXQTOP_Pos (24U) +#define USB_OTG_GNPTXSTS_NPTXQTOP_Msk (0x7FUL << USB_OTG_GNPTXSTS_NPTXQTOP_Pos) /*!< 0x7F000000 */ +#define USB_OTG_GNPTXSTS_NPTXQTOP USB_OTG_GNPTXSTS_NPTXQTOP_Msk /*!< Top of the nonperiodic transmit request queue */ +#define USB_OTG_GNPTXSTS_NPTXQTOP_0 (0x01UL << USB_OTG_GNPTXSTS_NPTXQTOP_Pos) /*!< 0x01000000 */ +#define USB_OTG_GNPTXSTS_NPTXQTOP_1 (0x02UL << USB_OTG_GNPTXSTS_NPTXQTOP_Pos) /*!< 0x02000000 */ +#define USB_OTG_GNPTXSTS_NPTXQTOP_2 (0x04UL << USB_OTG_GNPTXSTS_NPTXQTOP_Pos) /*!< 0x04000000 */ +#define USB_OTG_GNPTXSTS_NPTXQTOP_3 (0x08UL << USB_OTG_GNPTXSTS_NPTXQTOP_Pos) /*!< 0x08000000 */ +#define USB_OTG_GNPTXSTS_NPTXQTOP_4 (0x10UL << USB_OTG_GNPTXSTS_NPTXQTOP_Pos) /*!< 0x10000000 */ +#define USB_OTG_GNPTXSTS_NPTXQTOP_5 (0x20UL << USB_OTG_GNPTXSTS_NPTXQTOP_Pos) /*!< 0x20000000 */ +#define USB_OTG_GNPTXSTS_NPTXQTOP_6 (0x40UL << USB_OTG_GNPTXSTS_NPTXQTOP_Pos) /*!< 0x40000000 */ + +/******************** Bit definition for USB_OTG_DTHRCTL register ********************/ +#define USB_OTG_DTHRCTL_NONISOTHREN_Pos (0U) +#define USB_OTG_DTHRCTL_NONISOTHREN_Msk (0x1UL << USB_OTG_DTHRCTL_NONISOTHREN_Pos) /*!< 0x00000001 */ +#define USB_OTG_DTHRCTL_NONISOTHREN USB_OTG_DTHRCTL_NONISOTHREN_Msk /*!< Nonisochronous IN endpoints threshold enable */ +#define USB_OTG_DTHRCTL_ISOTHREN_Pos (1U) +#define USB_OTG_DTHRCTL_ISOTHREN_Msk (0x1UL << USB_OTG_DTHRCTL_ISOTHREN_Pos) /*!< 0x00000002 */ +#define USB_OTG_DTHRCTL_ISOTHREN USB_OTG_DTHRCTL_ISOTHREN_Msk /*!< ISO IN endpoint threshold enable */ + +#define USB_OTG_DTHRCTL_TXTHRLEN_Pos (2U) +#define USB_OTG_DTHRCTL_TXTHRLEN_Msk (0x1FFUL << USB_OTG_DTHRCTL_TXTHRLEN_Pos) /*!< 0x000007FC */ +#define USB_OTG_DTHRCTL_TXTHRLEN USB_OTG_DTHRCTL_TXTHRLEN_Msk /*!< Transmit threshold length */ +#define USB_OTG_DTHRCTL_TXTHRLEN_0 (0x001UL << USB_OTG_DTHRCTL_TXTHRLEN_Pos) /*!< 0x00000004 */ +#define USB_OTG_DTHRCTL_TXTHRLEN_1 (0x002UL << USB_OTG_DTHRCTL_TXTHRLEN_Pos) /*!< 0x00000008 */ +#define USB_OTG_DTHRCTL_TXTHRLEN_2 (0x004UL << USB_OTG_DTHRCTL_TXTHRLEN_Pos) /*!< 0x00000010 */ +#define USB_OTG_DTHRCTL_TXTHRLEN_3 (0x008UL << USB_OTG_DTHRCTL_TXTHRLEN_Pos) /*!< 0x00000020 */ +#define USB_OTG_DTHRCTL_TXTHRLEN_4 (0x010UL << USB_OTG_DTHRCTL_TXTHRLEN_Pos) /*!< 0x00000040 */ +#define USB_OTG_DTHRCTL_TXTHRLEN_5 (0x020UL << USB_OTG_DTHRCTL_TXTHRLEN_Pos) /*!< 0x00000080 */ +#define USB_OTG_DTHRCTL_TXTHRLEN_6 (0x040UL << USB_OTG_DTHRCTL_TXTHRLEN_Pos) /*!< 0x00000100 */ +#define USB_OTG_DTHRCTL_TXTHRLEN_7 (0x080UL << USB_OTG_DTHRCTL_TXTHRLEN_Pos) /*!< 0x00000200 */ +#define USB_OTG_DTHRCTL_TXTHRLEN_8 (0x100UL << USB_OTG_DTHRCTL_TXTHRLEN_Pos) /*!< 0x00000400 */ +#define USB_OTG_DTHRCTL_RXTHREN_Pos (16U) +#define USB_OTG_DTHRCTL_RXTHREN_Msk (0x1UL << USB_OTG_DTHRCTL_RXTHREN_Pos) /*!< 0x00010000 */ +#define USB_OTG_DTHRCTL_RXTHREN USB_OTG_DTHRCTL_RXTHREN_Msk /*!< Receive threshold enable */ + +#define USB_OTG_DTHRCTL_RXTHRLEN_Pos (17U) +#define USB_OTG_DTHRCTL_RXTHRLEN_Msk (0x1FFUL << USB_OTG_DTHRCTL_RXTHRLEN_Pos) /*!< 0x03FE0000 */ +#define USB_OTG_DTHRCTL_RXTHRLEN USB_OTG_DTHRCTL_RXTHRLEN_Msk /*!< Receive threshold length */ +#define USB_OTG_DTHRCTL_RXTHRLEN_0 (0x001UL << USB_OTG_DTHRCTL_RXTHRLEN_Pos) /*!< 0x00020000 */ +#define USB_OTG_DTHRCTL_RXTHRLEN_1 (0x002UL << USB_OTG_DTHRCTL_RXTHRLEN_Pos) /*!< 0x00040000 */ +#define USB_OTG_DTHRCTL_RXTHRLEN_2 (0x004UL << USB_OTG_DTHRCTL_RXTHRLEN_Pos) /*!< 0x00080000 */ +#define USB_OTG_DTHRCTL_RXTHRLEN_3 (0x008UL << USB_OTG_DTHRCTL_RXTHRLEN_Pos) /*!< 0x00100000 */ +#define USB_OTG_DTHRCTL_RXTHRLEN_4 (0x010UL << USB_OTG_DTHRCTL_RXTHRLEN_Pos) /*!< 0x00200000 */ +#define USB_OTG_DTHRCTL_RXTHRLEN_5 (0x020UL << USB_OTG_DTHRCTL_RXTHRLEN_Pos) /*!< 0x00400000 */ +#define USB_OTG_DTHRCTL_RXTHRLEN_6 (0x040UL << USB_OTG_DTHRCTL_RXTHRLEN_Pos) /*!< 0x00800000 */ +#define USB_OTG_DTHRCTL_RXTHRLEN_7 (0x080UL << USB_OTG_DTHRCTL_RXTHRLEN_Pos) /*!< 0x01000000 */ +#define USB_OTG_DTHRCTL_RXTHRLEN_8 (0x100UL << USB_OTG_DTHRCTL_RXTHRLEN_Pos) /*!< 0x02000000 */ +#define USB_OTG_DTHRCTL_ARPEN_Pos (27U) +#define USB_OTG_DTHRCTL_ARPEN_Msk (0x1UL << USB_OTG_DTHRCTL_ARPEN_Pos) /*!< 0x08000000 */ +#define USB_OTG_DTHRCTL_ARPEN USB_OTG_DTHRCTL_ARPEN_Msk /*!< Arbiter parking enable */ + +/******************** Bit definition for USB_OTG_DIEPEMPMSK register ********************/ +#define USB_OTG_DIEPEMPMSK_INEPTXFEM_Pos (0U) +#define USB_OTG_DIEPEMPMSK_INEPTXFEM_Msk (0xFFFFUL << USB_OTG_DIEPEMPMSK_INEPTXFEM_Pos) /*!< 0x0000FFFF */ +#define USB_OTG_DIEPEMPMSK_INEPTXFEM USB_OTG_DIEPEMPMSK_INEPTXFEM_Msk /*!< IN EP Tx FIFO empty interrupt mask bits */ + +/******************** Bit definition for USB_OTG_DEACHINT register ********************/ +#define USB_OTG_DEACHINT_IEP1INT_Pos (1U) +#define USB_OTG_DEACHINT_IEP1INT_Msk (0x1UL << USB_OTG_DEACHINT_IEP1INT_Pos) /*!< 0x00000002 */ +#define USB_OTG_DEACHINT_IEP1INT USB_OTG_DEACHINT_IEP1INT_Msk /*!< IN endpoint 1interrupt bit */ +#define USB_OTG_DEACHINT_OEP1INT_Pos (17U) +#define USB_OTG_DEACHINT_OEP1INT_Msk (0x1UL << USB_OTG_DEACHINT_OEP1INT_Pos) /*!< 0x00020000 */ +#define USB_OTG_DEACHINT_OEP1INT USB_OTG_DEACHINT_OEP1INT_Msk /*!< OUT endpoint 1 interrupt bit */ + +/******************** Bit definition for USB_OTG_GCCFG register ********************/ +#define USB_OTG_GCCFG_PWRDWN_Pos (16U) +#define USB_OTG_GCCFG_PWRDWN_Msk (0x1UL << USB_OTG_GCCFG_PWRDWN_Pos) /*!< 0x00010000 */ +#define USB_OTG_GCCFG_PWRDWN USB_OTG_GCCFG_PWRDWN_Msk /*!< Power down */ +#define USB_OTG_GCCFG_VBUSASEN_Pos (18U) +#define USB_OTG_GCCFG_VBUSASEN_Msk (0x1UL << USB_OTG_GCCFG_VBUSASEN_Pos) /*!< 0x00040000 */ +#define USB_OTG_GCCFG_VBUSASEN USB_OTG_GCCFG_VBUSASEN_Msk /*!< Enable the VBUS sensing device */ +#define USB_OTG_GCCFG_VBUSBSEN_Pos (19U) +#define USB_OTG_GCCFG_VBUSBSEN_Msk (0x1UL << USB_OTG_GCCFG_VBUSBSEN_Pos) /*!< 0x00080000 */ +#define USB_OTG_GCCFG_VBUSBSEN USB_OTG_GCCFG_VBUSBSEN_Msk /*!< Enable the VBUS sensing device */ +#define USB_OTG_GCCFG_SOFOUTEN_Pos (20U) +#define USB_OTG_GCCFG_SOFOUTEN_Msk (0x1UL << USB_OTG_GCCFG_SOFOUTEN_Pos) /*!< 0x00100000 */ +#define USB_OTG_GCCFG_SOFOUTEN USB_OTG_GCCFG_SOFOUTEN_Msk /*!< SOF output enable */ + +/******************** Bit definition for USB_OTG_DEACHINTMSK register ********************/ +#define USB_OTG_DEACHINTMSK_IEP1INTM_Pos (1U) +#define USB_OTG_DEACHINTMSK_IEP1INTM_Msk (0x1UL << USB_OTG_DEACHINTMSK_IEP1INTM_Pos) /*!< 0x00000002 */ +#define USB_OTG_DEACHINTMSK_IEP1INTM USB_OTG_DEACHINTMSK_IEP1INTM_Msk /*!< IN Endpoint 1 interrupt mask bit */ +#define USB_OTG_DEACHINTMSK_OEP1INTM_Pos (17U) +#define USB_OTG_DEACHINTMSK_OEP1INTM_Msk (0x1UL << USB_OTG_DEACHINTMSK_OEP1INTM_Pos) /*!< 0x00020000 */ +#define USB_OTG_DEACHINTMSK_OEP1INTM USB_OTG_DEACHINTMSK_OEP1INTM_Msk /*!< OUT Endpoint 1 interrupt mask bit */ + +/******************** Bit definition for USB_OTG_CID register ********************/ +#define USB_OTG_CID_PRODUCT_ID_Pos (0U) +#define USB_OTG_CID_PRODUCT_ID_Msk (0xFFFFFFFFUL << USB_OTG_CID_PRODUCT_ID_Pos) /*!< 0xFFFFFFFF */ +#define USB_OTG_CID_PRODUCT_ID USB_OTG_CID_PRODUCT_ID_Msk /*!< Product ID field */ + +/******************** Bit definition for USB_OTG_DIEPEACHMSK1 register ********************/ +#define USB_OTG_DIEPEACHMSK1_XFRCM_Pos (0U) +#define USB_OTG_DIEPEACHMSK1_XFRCM_Msk (0x1UL << USB_OTG_DIEPEACHMSK1_XFRCM_Pos) /*!< 0x00000001 */ +#define USB_OTG_DIEPEACHMSK1_XFRCM USB_OTG_DIEPEACHMSK1_XFRCM_Msk /*!< Transfer completed interrupt mask */ +#define USB_OTG_DIEPEACHMSK1_EPDM_Pos (1U) +#define USB_OTG_DIEPEACHMSK1_EPDM_Msk (0x1UL << USB_OTG_DIEPEACHMSK1_EPDM_Pos) /*!< 0x00000002 */ +#define USB_OTG_DIEPEACHMSK1_EPDM USB_OTG_DIEPEACHMSK1_EPDM_Msk /*!< Endpoint disabled interrupt mask */ +#define USB_OTG_DIEPEACHMSK1_TOM_Pos (3U) +#define USB_OTG_DIEPEACHMSK1_TOM_Msk (0x1UL << USB_OTG_DIEPEACHMSK1_TOM_Pos) /*!< 0x00000008 */ +#define USB_OTG_DIEPEACHMSK1_TOM USB_OTG_DIEPEACHMSK1_TOM_Msk /*!< Timeout condition mask (nonisochronous endpoints) */ +#define USB_OTG_DIEPEACHMSK1_ITTXFEMSK_Pos (4U) +#define USB_OTG_DIEPEACHMSK1_ITTXFEMSK_Msk (0x1UL << USB_OTG_DIEPEACHMSK1_ITTXFEMSK_Pos) /*!< 0x00000010 */ +#define USB_OTG_DIEPEACHMSK1_ITTXFEMSK USB_OTG_DIEPEACHMSK1_ITTXFEMSK_Msk /*!< IN token received when TxFIFO empty mask */ +#define USB_OTG_DIEPEACHMSK1_INEPNMM_Pos (5U) +#define USB_OTG_DIEPEACHMSK1_INEPNMM_Msk (0x1UL << USB_OTG_DIEPEACHMSK1_INEPNMM_Pos) /*!< 0x00000020 */ +#define USB_OTG_DIEPEACHMSK1_INEPNMM USB_OTG_DIEPEACHMSK1_INEPNMM_Msk /*!< IN token received with EP mismatch mask */ +#define USB_OTG_DIEPEACHMSK1_INEPNEM_Pos (6U) +#define USB_OTG_DIEPEACHMSK1_INEPNEM_Msk (0x1UL << USB_OTG_DIEPEACHMSK1_INEPNEM_Pos) /*!< 0x00000040 */ +#define USB_OTG_DIEPEACHMSK1_INEPNEM USB_OTG_DIEPEACHMSK1_INEPNEM_Msk /*!< IN endpoint NAK effective mask */ +#define USB_OTG_DIEPEACHMSK1_TXFURM_Pos (8U) +#define USB_OTG_DIEPEACHMSK1_TXFURM_Msk (0x1UL << USB_OTG_DIEPEACHMSK1_TXFURM_Pos) /*!< 0x00000100 */ +#define USB_OTG_DIEPEACHMSK1_TXFURM USB_OTG_DIEPEACHMSK1_TXFURM_Msk /*!< FIFO underrun mask */ +#define USB_OTG_DIEPEACHMSK1_BIM_Pos (9U) +#define USB_OTG_DIEPEACHMSK1_BIM_Msk (0x1UL << USB_OTG_DIEPEACHMSK1_BIM_Pos) /*!< 0x00000200 */ +#define USB_OTG_DIEPEACHMSK1_BIM USB_OTG_DIEPEACHMSK1_BIM_Msk /*!< BNA interrupt mask */ +#define USB_OTG_DIEPEACHMSK1_NAKM_Pos (13U) +#define USB_OTG_DIEPEACHMSK1_NAKM_Msk (0x1UL << USB_OTG_DIEPEACHMSK1_NAKM_Pos) /*!< 0x00002000 */ +#define USB_OTG_DIEPEACHMSK1_NAKM USB_OTG_DIEPEACHMSK1_NAKM_Msk /*!< NAK interrupt mask */ + +/******************** Bit definition for USB_OTG_HPRT register ********************/ +#define USB_OTG_HPRT_PCSTS_Pos (0U) +#define USB_OTG_HPRT_PCSTS_Msk (0x1UL << USB_OTG_HPRT_PCSTS_Pos) /*!< 0x00000001 */ +#define USB_OTG_HPRT_PCSTS USB_OTG_HPRT_PCSTS_Msk /*!< Port connect status */ +#define USB_OTG_HPRT_PCDET_Pos (1U) +#define USB_OTG_HPRT_PCDET_Msk (0x1UL << USB_OTG_HPRT_PCDET_Pos) /*!< 0x00000002 */ +#define USB_OTG_HPRT_PCDET USB_OTG_HPRT_PCDET_Msk /*!< Port connect detected */ +#define USB_OTG_HPRT_PENA_Pos (2U) +#define USB_OTG_HPRT_PENA_Msk (0x1UL << USB_OTG_HPRT_PENA_Pos) /*!< 0x00000004 */ +#define USB_OTG_HPRT_PENA USB_OTG_HPRT_PENA_Msk /*!< Port enable */ +#define USB_OTG_HPRT_PENCHNG_Pos (3U) +#define USB_OTG_HPRT_PENCHNG_Msk (0x1UL << USB_OTG_HPRT_PENCHNG_Pos) /*!< 0x00000008 */ +#define USB_OTG_HPRT_PENCHNG USB_OTG_HPRT_PENCHNG_Msk /*!< Port enable/disable change */ +#define USB_OTG_HPRT_POCA_Pos (4U) +#define USB_OTG_HPRT_POCA_Msk (0x1UL << USB_OTG_HPRT_POCA_Pos) /*!< 0x00000010 */ +#define USB_OTG_HPRT_POCA USB_OTG_HPRT_POCA_Msk /*!< Port overcurrent active */ +#define USB_OTG_HPRT_POCCHNG_Pos (5U) +#define USB_OTG_HPRT_POCCHNG_Msk (0x1UL << USB_OTG_HPRT_POCCHNG_Pos) /*!< 0x00000020 */ +#define USB_OTG_HPRT_POCCHNG USB_OTG_HPRT_POCCHNG_Msk /*!< Port overcurrent change */ +#define USB_OTG_HPRT_PRES_Pos (6U) +#define USB_OTG_HPRT_PRES_Msk (0x1UL << USB_OTG_HPRT_PRES_Pos) /*!< 0x00000040 */ +#define USB_OTG_HPRT_PRES USB_OTG_HPRT_PRES_Msk /*!< Port resume */ +#define USB_OTG_HPRT_PSUSP_Pos (7U) +#define USB_OTG_HPRT_PSUSP_Msk (0x1UL << USB_OTG_HPRT_PSUSP_Pos) /*!< 0x00000080 */ +#define USB_OTG_HPRT_PSUSP USB_OTG_HPRT_PSUSP_Msk /*!< Port suspend */ +#define USB_OTG_HPRT_PRST_Pos (8U) +#define USB_OTG_HPRT_PRST_Msk (0x1UL << USB_OTG_HPRT_PRST_Pos) /*!< 0x00000100 */ +#define USB_OTG_HPRT_PRST USB_OTG_HPRT_PRST_Msk /*!< Port reset */ + +#define USB_OTG_HPRT_PLSTS_Pos (10U) +#define USB_OTG_HPRT_PLSTS_Msk (0x3UL << USB_OTG_HPRT_PLSTS_Pos) /*!< 0x00000C00 */ +#define USB_OTG_HPRT_PLSTS USB_OTG_HPRT_PLSTS_Msk /*!< Port line status */ +#define USB_OTG_HPRT_PLSTS_0 (0x1UL << USB_OTG_HPRT_PLSTS_Pos) /*!< 0x00000400 */ +#define USB_OTG_HPRT_PLSTS_1 (0x2UL << USB_OTG_HPRT_PLSTS_Pos) /*!< 0x00000800 */ +#define USB_OTG_HPRT_PPWR_Pos (12U) +#define USB_OTG_HPRT_PPWR_Msk (0x1UL << USB_OTG_HPRT_PPWR_Pos) /*!< 0x00001000 */ +#define USB_OTG_HPRT_PPWR USB_OTG_HPRT_PPWR_Msk /*!< Port power */ + +#define USB_OTG_HPRT_PTCTL_Pos (13U) +#define USB_OTG_HPRT_PTCTL_Msk (0xFUL << USB_OTG_HPRT_PTCTL_Pos) /*!< 0x0001E000 */ +#define USB_OTG_HPRT_PTCTL USB_OTG_HPRT_PTCTL_Msk /*!< Port test control */ +#define USB_OTG_HPRT_PTCTL_0 (0x1UL << USB_OTG_HPRT_PTCTL_Pos) /*!< 0x00002000 */ +#define USB_OTG_HPRT_PTCTL_1 (0x2UL << USB_OTG_HPRT_PTCTL_Pos) /*!< 0x00004000 */ +#define USB_OTG_HPRT_PTCTL_2 (0x4UL << USB_OTG_HPRT_PTCTL_Pos) /*!< 0x00008000 */ +#define USB_OTG_HPRT_PTCTL_3 (0x8UL << USB_OTG_HPRT_PTCTL_Pos) /*!< 0x00010000 */ + +#define USB_OTG_HPRT_PSPD_Pos (17U) +#define USB_OTG_HPRT_PSPD_Msk (0x3UL << USB_OTG_HPRT_PSPD_Pos) /*!< 0x00060000 */ +#define USB_OTG_HPRT_PSPD USB_OTG_HPRT_PSPD_Msk /*!< Port speed */ +#define USB_OTG_HPRT_PSPD_0 (0x1UL << USB_OTG_HPRT_PSPD_Pos) /*!< 0x00020000 */ +#define USB_OTG_HPRT_PSPD_1 (0x2UL << USB_OTG_HPRT_PSPD_Pos) /*!< 0x00040000 */ + +/******************** Bit definition for USB_OTG_DOEPEACHMSK1 register ********************/ +#define USB_OTG_DOEPEACHMSK1_XFRCM_Pos (0U) +#define USB_OTG_DOEPEACHMSK1_XFRCM_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_XFRCM_Pos) /*!< 0x00000001 */ +#define USB_OTG_DOEPEACHMSK1_XFRCM USB_OTG_DOEPEACHMSK1_XFRCM_Msk /*!< Transfer completed interrupt mask */ +#define USB_OTG_DOEPEACHMSK1_EPDM_Pos (1U) +#define USB_OTG_DOEPEACHMSK1_EPDM_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_EPDM_Pos) /*!< 0x00000002 */ +#define USB_OTG_DOEPEACHMSK1_EPDM USB_OTG_DOEPEACHMSK1_EPDM_Msk /*!< Endpoint disabled interrupt mask */ +#define USB_OTG_DOEPEACHMSK1_TOM_Pos (3U) +#define USB_OTG_DOEPEACHMSK1_TOM_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_TOM_Pos) /*!< 0x00000008 */ +#define USB_OTG_DOEPEACHMSK1_TOM USB_OTG_DOEPEACHMSK1_TOM_Msk /*!< Timeout condition mask */ +#define USB_OTG_DOEPEACHMSK1_ITTXFEMSK_Pos (4U) +#define USB_OTG_DOEPEACHMSK1_ITTXFEMSK_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_ITTXFEMSK_Pos) /*!< 0x00000010 */ +#define USB_OTG_DOEPEACHMSK1_ITTXFEMSK USB_OTG_DOEPEACHMSK1_ITTXFEMSK_Msk /*!< IN token received when TxFIFO empty mask */ +#define USB_OTG_DOEPEACHMSK1_INEPNMM_Pos (5U) +#define USB_OTG_DOEPEACHMSK1_INEPNMM_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_INEPNMM_Pos) /*!< 0x00000020 */ +#define USB_OTG_DOEPEACHMSK1_INEPNMM USB_OTG_DOEPEACHMSK1_INEPNMM_Msk /*!< IN token received with EP mismatch mask */ +#define USB_OTG_DOEPEACHMSK1_INEPNEM_Pos (6U) +#define USB_OTG_DOEPEACHMSK1_INEPNEM_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_INEPNEM_Pos) /*!< 0x00000040 */ +#define USB_OTG_DOEPEACHMSK1_INEPNEM USB_OTG_DOEPEACHMSK1_INEPNEM_Msk /*!< IN endpoint NAK effective mask */ +#define USB_OTG_DOEPEACHMSK1_TXFURM_Pos (8U) +#define USB_OTG_DOEPEACHMSK1_TXFURM_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_TXFURM_Pos) /*!< 0x00000100 */ +#define USB_OTG_DOEPEACHMSK1_TXFURM USB_OTG_DOEPEACHMSK1_TXFURM_Msk /*!< OUT packet error mask */ +#define USB_OTG_DOEPEACHMSK1_BIM_Pos (9U) +#define USB_OTG_DOEPEACHMSK1_BIM_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_BIM_Pos) /*!< 0x00000200 */ +#define USB_OTG_DOEPEACHMSK1_BIM USB_OTG_DOEPEACHMSK1_BIM_Msk /*!< BNA interrupt mask */ +#define USB_OTG_DOEPEACHMSK1_BERRM_Pos (12U) +#define USB_OTG_DOEPEACHMSK1_BERRM_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_BERRM_Pos) /*!< 0x00001000 */ +#define USB_OTG_DOEPEACHMSK1_BERRM USB_OTG_DOEPEACHMSK1_BERRM_Msk /*!< Bubble error interrupt mask */ +#define USB_OTG_DOEPEACHMSK1_NAKM_Pos (13U) +#define USB_OTG_DOEPEACHMSK1_NAKM_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_NAKM_Pos) /*!< 0x00002000 */ +#define USB_OTG_DOEPEACHMSK1_NAKM USB_OTG_DOEPEACHMSK1_NAKM_Msk /*!< NAK interrupt mask */ +#define USB_OTG_DOEPEACHMSK1_NYETM_Pos (14U) +#define USB_OTG_DOEPEACHMSK1_NYETM_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_NYETM_Pos) /*!< 0x00004000 */ +#define USB_OTG_DOEPEACHMSK1_NYETM USB_OTG_DOEPEACHMSK1_NYETM_Msk /*!< NYET interrupt mask */ + +/******************** Bit definition for USB_OTG_HPTXFSIZ register ********************/ +#define USB_OTG_HPTXFSIZ_PTXSA_Pos (0U) +#define USB_OTG_HPTXFSIZ_PTXSA_Msk (0xFFFFUL << USB_OTG_HPTXFSIZ_PTXSA_Pos) /*!< 0x0000FFFF */ +#define USB_OTG_HPTXFSIZ_PTXSA USB_OTG_HPTXFSIZ_PTXSA_Msk /*!< Host periodic TxFIFO start address */ +#define USB_OTG_HPTXFSIZ_PTXFD_Pos (16U) +#define USB_OTG_HPTXFSIZ_PTXFD_Msk (0xFFFFUL << USB_OTG_HPTXFSIZ_PTXFD_Pos) /*!< 0xFFFF0000 */ +#define USB_OTG_HPTXFSIZ_PTXFD USB_OTG_HPTXFSIZ_PTXFD_Msk /*!< Host periodic TxFIFO depth */ + +/******************** Bit definition for USB_OTG_DIEPCTL register ********************/ +#define USB_OTG_DIEPCTL_MPSIZ_Pos (0U) +#define USB_OTG_DIEPCTL_MPSIZ_Msk (0x7FFUL << USB_OTG_DIEPCTL_MPSIZ_Pos) /*!< 0x000007FF */ +#define USB_OTG_DIEPCTL_MPSIZ USB_OTG_DIEPCTL_MPSIZ_Msk /*!< Maximum packet size */ +#define USB_OTG_DIEPCTL_USBAEP_Pos (15U) +#define USB_OTG_DIEPCTL_USBAEP_Msk (0x1UL << USB_OTG_DIEPCTL_USBAEP_Pos) /*!< 0x00008000 */ +#define USB_OTG_DIEPCTL_USBAEP USB_OTG_DIEPCTL_USBAEP_Msk /*!< USB active endpoint */ +#define USB_OTG_DIEPCTL_EONUM_DPID_Pos (16U) +#define USB_OTG_DIEPCTL_EONUM_DPID_Msk (0x1UL << USB_OTG_DIEPCTL_EONUM_DPID_Pos) /*!< 0x00010000 */ +#define USB_OTG_DIEPCTL_EONUM_DPID USB_OTG_DIEPCTL_EONUM_DPID_Msk /*!< Even/odd frame */ +#define USB_OTG_DIEPCTL_NAKSTS_Pos (17U) +#define USB_OTG_DIEPCTL_NAKSTS_Msk (0x1UL << USB_OTG_DIEPCTL_NAKSTS_Pos) /*!< 0x00020000 */ +#define USB_OTG_DIEPCTL_NAKSTS USB_OTG_DIEPCTL_NAKSTS_Msk /*!< NAK status */ + +#define USB_OTG_DIEPCTL_EPTYP_Pos (18U) +#define USB_OTG_DIEPCTL_EPTYP_Msk (0x3UL << USB_OTG_DIEPCTL_EPTYP_Pos) /*!< 0x000C0000 */ +#define USB_OTG_DIEPCTL_EPTYP USB_OTG_DIEPCTL_EPTYP_Msk /*!< Endpoint type */ +#define USB_OTG_DIEPCTL_EPTYP_0 (0x1UL << USB_OTG_DIEPCTL_EPTYP_Pos) /*!< 0x00040000 */ +#define USB_OTG_DIEPCTL_EPTYP_1 (0x2UL << USB_OTG_DIEPCTL_EPTYP_Pos) /*!< 0x00080000 */ +#define USB_OTG_DIEPCTL_STALL_Pos (21U) +#define USB_OTG_DIEPCTL_STALL_Msk (0x1UL << USB_OTG_DIEPCTL_STALL_Pos) /*!< 0x00200000 */ +#define USB_OTG_DIEPCTL_STALL USB_OTG_DIEPCTL_STALL_Msk /*!< STALL handshake */ + +#define USB_OTG_DIEPCTL_TXFNUM_Pos (22U) +#define USB_OTG_DIEPCTL_TXFNUM_Msk (0xFUL << USB_OTG_DIEPCTL_TXFNUM_Pos) /*!< 0x03C00000 */ +#define USB_OTG_DIEPCTL_TXFNUM USB_OTG_DIEPCTL_TXFNUM_Msk /*!< TxFIFO number */ +#define USB_OTG_DIEPCTL_TXFNUM_0 (0x1UL << USB_OTG_DIEPCTL_TXFNUM_Pos) /*!< 0x00400000 */ +#define USB_OTG_DIEPCTL_TXFNUM_1 (0x2UL << USB_OTG_DIEPCTL_TXFNUM_Pos) /*!< 0x00800000 */ +#define USB_OTG_DIEPCTL_TXFNUM_2 (0x4UL << USB_OTG_DIEPCTL_TXFNUM_Pos) /*!< 0x01000000 */ +#define USB_OTG_DIEPCTL_TXFNUM_3 (0x8UL << USB_OTG_DIEPCTL_TXFNUM_Pos) /*!< 0x02000000 */ +#define USB_OTG_DIEPCTL_CNAK_Pos (26U) +#define USB_OTG_DIEPCTL_CNAK_Msk (0x1UL << USB_OTG_DIEPCTL_CNAK_Pos) /*!< 0x04000000 */ +#define USB_OTG_DIEPCTL_CNAK USB_OTG_DIEPCTL_CNAK_Msk /*!< Clear NAK */ +#define USB_OTG_DIEPCTL_SNAK_Pos (27U) +#define USB_OTG_DIEPCTL_SNAK_Msk (0x1UL << USB_OTG_DIEPCTL_SNAK_Pos) /*!< 0x08000000 */ +#define USB_OTG_DIEPCTL_SNAK USB_OTG_DIEPCTL_SNAK_Msk /*!< Set NAK */ +#define USB_OTG_DIEPCTL_SD0PID_SEVNFRM_Pos (28U) +#define USB_OTG_DIEPCTL_SD0PID_SEVNFRM_Msk (0x1UL << USB_OTG_DIEPCTL_SD0PID_SEVNFRM_Pos) /*!< 0x10000000 */ +#define USB_OTG_DIEPCTL_SD0PID_SEVNFRM USB_OTG_DIEPCTL_SD0PID_SEVNFRM_Msk /*!< Set DATA0 PID */ +#define USB_OTG_DIEPCTL_SODDFRM_Pos (29U) +#define USB_OTG_DIEPCTL_SODDFRM_Msk (0x1UL << USB_OTG_DIEPCTL_SODDFRM_Pos) /*!< 0x20000000 */ +#define USB_OTG_DIEPCTL_SODDFRM USB_OTG_DIEPCTL_SODDFRM_Msk /*!< Set odd frame */ +#define USB_OTG_DIEPCTL_EPDIS_Pos (30U) +#define USB_OTG_DIEPCTL_EPDIS_Msk (0x1UL << USB_OTG_DIEPCTL_EPDIS_Pos) /*!< 0x40000000 */ +#define USB_OTG_DIEPCTL_EPDIS USB_OTG_DIEPCTL_EPDIS_Msk /*!< Endpoint disable */ +#define USB_OTG_DIEPCTL_EPENA_Pos (31U) +#define USB_OTG_DIEPCTL_EPENA_Msk (0x1UL << USB_OTG_DIEPCTL_EPENA_Pos) /*!< 0x80000000 */ +#define USB_OTG_DIEPCTL_EPENA USB_OTG_DIEPCTL_EPENA_Msk /*!< Endpoint enable */ + +/******************** Bit definition for USB_OTG_HCCHAR register ********************/ +#define USB_OTG_HCCHAR_MPSIZ_Pos (0U) +#define USB_OTG_HCCHAR_MPSIZ_Msk (0x7FFUL << USB_OTG_HCCHAR_MPSIZ_Pos) /*!< 0x000007FF */ +#define USB_OTG_HCCHAR_MPSIZ USB_OTG_HCCHAR_MPSIZ_Msk /*!< Maximum packet size */ + +#define USB_OTG_HCCHAR_EPNUM_Pos (11U) +#define USB_OTG_HCCHAR_EPNUM_Msk (0xFUL << USB_OTG_HCCHAR_EPNUM_Pos) /*!< 0x00007800 */ +#define USB_OTG_HCCHAR_EPNUM USB_OTG_HCCHAR_EPNUM_Msk /*!< Endpoint number */ +#define USB_OTG_HCCHAR_EPNUM_0 (0x1UL << USB_OTG_HCCHAR_EPNUM_Pos) /*!< 0x00000800 */ +#define USB_OTG_HCCHAR_EPNUM_1 (0x2UL << USB_OTG_HCCHAR_EPNUM_Pos) /*!< 0x00001000 */ +#define USB_OTG_HCCHAR_EPNUM_2 (0x4UL << USB_OTG_HCCHAR_EPNUM_Pos) /*!< 0x00002000 */ +#define USB_OTG_HCCHAR_EPNUM_3 (0x8UL << USB_OTG_HCCHAR_EPNUM_Pos) /*!< 0x00004000 */ +#define USB_OTG_HCCHAR_EPDIR_Pos (15U) +#define USB_OTG_HCCHAR_EPDIR_Msk (0x1UL << USB_OTG_HCCHAR_EPDIR_Pos) /*!< 0x00008000 */ +#define USB_OTG_HCCHAR_EPDIR USB_OTG_HCCHAR_EPDIR_Msk /*!< Endpoint direction */ +#define USB_OTG_HCCHAR_LSDEV_Pos (17U) +#define USB_OTG_HCCHAR_LSDEV_Msk (0x1UL << USB_OTG_HCCHAR_LSDEV_Pos) /*!< 0x00020000 */ +#define USB_OTG_HCCHAR_LSDEV USB_OTG_HCCHAR_LSDEV_Msk /*!< Low-speed device */ + +#define USB_OTG_HCCHAR_EPTYP_Pos (18U) +#define USB_OTG_HCCHAR_EPTYP_Msk (0x3UL << USB_OTG_HCCHAR_EPTYP_Pos) /*!< 0x000C0000 */ +#define USB_OTG_HCCHAR_EPTYP USB_OTG_HCCHAR_EPTYP_Msk /*!< Endpoint type */ +#define USB_OTG_HCCHAR_EPTYP_0 (0x1UL << USB_OTG_HCCHAR_EPTYP_Pos) /*!< 0x00040000 */ +#define USB_OTG_HCCHAR_EPTYP_1 (0x2UL << USB_OTG_HCCHAR_EPTYP_Pos) /*!< 0x00080000 */ + +#define USB_OTG_HCCHAR_MC_Pos (20U) +#define USB_OTG_HCCHAR_MC_Msk (0x3UL << USB_OTG_HCCHAR_MC_Pos) /*!< 0x00300000 */ +#define USB_OTG_HCCHAR_MC USB_OTG_HCCHAR_MC_Msk /*!< Multi Count (MC) / Error Count (EC) */ +#define USB_OTG_HCCHAR_MC_0 (0x1UL << USB_OTG_HCCHAR_MC_Pos) /*!< 0x00100000 */ +#define USB_OTG_HCCHAR_MC_1 (0x2UL << USB_OTG_HCCHAR_MC_Pos) /*!< 0x00200000 */ + +#define USB_OTG_HCCHAR_DAD_Pos (22U) +#define USB_OTG_HCCHAR_DAD_Msk (0x7FUL << USB_OTG_HCCHAR_DAD_Pos) /*!< 0x1FC00000 */ +#define USB_OTG_HCCHAR_DAD USB_OTG_HCCHAR_DAD_Msk /*!< Device address */ +#define USB_OTG_HCCHAR_DAD_0 (0x01UL << USB_OTG_HCCHAR_DAD_Pos) /*!< 0x00400000 */ +#define USB_OTG_HCCHAR_DAD_1 (0x02UL << USB_OTG_HCCHAR_DAD_Pos) /*!< 0x00800000 */ +#define USB_OTG_HCCHAR_DAD_2 (0x04UL << USB_OTG_HCCHAR_DAD_Pos) /*!< 0x01000000 */ +#define USB_OTG_HCCHAR_DAD_3 (0x08UL << USB_OTG_HCCHAR_DAD_Pos) /*!< 0x02000000 */ +#define USB_OTG_HCCHAR_DAD_4 (0x10UL << USB_OTG_HCCHAR_DAD_Pos) /*!< 0x04000000 */ +#define USB_OTG_HCCHAR_DAD_5 (0x20UL << USB_OTG_HCCHAR_DAD_Pos) /*!< 0x08000000 */ +#define USB_OTG_HCCHAR_DAD_6 (0x40UL << USB_OTG_HCCHAR_DAD_Pos) /*!< 0x10000000 */ +#define USB_OTG_HCCHAR_ODDFRM_Pos (29U) +#define USB_OTG_HCCHAR_ODDFRM_Msk (0x1UL << USB_OTG_HCCHAR_ODDFRM_Pos) /*!< 0x20000000 */ +#define USB_OTG_HCCHAR_ODDFRM USB_OTG_HCCHAR_ODDFRM_Msk /*!< Odd frame */ +#define USB_OTG_HCCHAR_CHDIS_Pos (30U) +#define USB_OTG_HCCHAR_CHDIS_Msk (0x1UL << USB_OTG_HCCHAR_CHDIS_Pos) /*!< 0x40000000 */ +#define USB_OTG_HCCHAR_CHDIS USB_OTG_HCCHAR_CHDIS_Msk /*!< Channel disable */ +#define USB_OTG_HCCHAR_CHENA_Pos (31U) +#define USB_OTG_HCCHAR_CHENA_Msk (0x1UL << USB_OTG_HCCHAR_CHENA_Pos) /*!< 0x80000000 */ +#define USB_OTG_HCCHAR_CHENA USB_OTG_HCCHAR_CHENA_Msk /*!< Channel enable */ + +/******************** Bit definition for USB_OTG_HCSPLT register ********************/ + +#define USB_OTG_HCSPLT_PRTADDR_Pos (0U) +#define USB_OTG_HCSPLT_PRTADDR_Msk (0x7FUL << USB_OTG_HCSPLT_PRTADDR_Pos) /*!< 0x0000007F */ +#define USB_OTG_HCSPLT_PRTADDR USB_OTG_HCSPLT_PRTADDR_Msk /*!< Port address */ +#define USB_OTG_HCSPLT_PRTADDR_0 (0x01UL << USB_OTG_HCSPLT_PRTADDR_Pos) /*!< 0x00000001 */ +#define USB_OTG_HCSPLT_PRTADDR_1 (0x02UL << USB_OTG_HCSPLT_PRTADDR_Pos) /*!< 0x00000002 */ +#define USB_OTG_HCSPLT_PRTADDR_2 (0x04UL << USB_OTG_HCSPLT_PRTADDR_Pos) /*!< 0x00000004 */ +#define USB_OTG_HCSPLT_PRTADDR_3 (0x08UL << USB_OTG_HCSPLT_PRTADDR_Pos) /*!< 0x00000008 */ +#define USB_OTG_HCSPLT_PRTADDR_4 (0x10UL << USB_OTG_HCSPLT_PRTADDR_Pos) /*!< 0x00000010 */ +#define USB_OTG_HCSPLT_PRTADDR_5 (0x20UL << USB_OTG_HCSPLT_PRTADDR_Pos) /*!< 0x00000020 */ +#define USB_OTG_HCSPLT_PRTADDR_6 (0x40UL << USB_OTG_HCSPLT_PRTADDR_Pos) /*!< 0x00000040 */ + +#define USB_OTG_HCSPLT_HUBADDR_Pos (7U) +#define USB_OTG_HCSPLT_HUBADDR_Msk (0x7FUL << USB_OTG_HCSPLT_HUBADDR_Pos) /*!< 0x00003F80 */ +#define USB_OTG_HCSPLT_HUBADDR USB_OTG_HCSPLT_HUBADDR_Msk /*!< Hub address */ +#define USB_OTG_HCSPLT_HUBADDR_0 (0x01UL << USB_OTG_HCSPLT_HUBADDR_Pos) /*!< 0x00000080 */ +#define USB_OTG_HCSPLT_HUBADDR_1 (0x02UL << USB_OTG_HCSPLT_HUBADDR_Pos) /*!< 0x00000100 */ +#define USB_OTG_HCSPLT_HUBADDR_2 (0x04UL << USB_OTG_HCSPLT_HUBADDR_Pos) /*!< 0x00000200 */ +#define USB_OTG_HCSPLT_HUBADDR_3 (0x08UL << USB_OTG_HCSPLT_HUBADDR_Pos) /*!< 0x00000400 */ +#define USB_OTG_HCSPLT_HUBADDR_4 (0x10UL << USB_OTG_HCSPLT_HUBADDR_Pos) /*!< 0x00000800 */ +#define USB_OTG_HCSPLT_HUBADDR_5 (0x20UL << USB_OTG_HCSPLT_HUBADDR_Pos) /*!< 0x00001000 */ +#define USB_OTG_HCSPLT_HUBADDR_6 (0x40UL << USB_OTG_HCSPLT_HUBADDR_Pos) /*!< 0x00002000 */ + +#define USB_OTG_HCSPLT_XACTPOS_Pos (14U) +#define USB_OTG_HCSPLT_XACTPOS_Msk (0x3UL << USB_OTG_HCSPLT_XACTPOS_Pos) /*!< 0x0000C000 */ +#define USB_OTG_HCSPLT_XACTPOS USB_OTG_HCSPLT_XACTPOS_Msk /*!< XACTPOS */ +#define USB_OTG_HCSPLT_XACTPOS_0 (0x1UL << USB_OTG_HCSPLT_XACTPOS_Pos) /*!< 0x00004000 */ +#define USB_OTG_HCSPLT_XACTPOS_1 (0x2UL << USB_OTG_HCSPLT_XACTPOS_Pos) /*!< 0x00008000 */ +#define USB_OTG_HCSPLT_COMPLSPLT_Pos (16U) +#define USB_OTG_HCSPLT_COMPLSPLT_Msk (0x1UL << USB_OTG_HCSPLT_COMPLSPLT_Pos) /*!< 0x00010000 */ +#define USB_OTG_HCSPLT_COMPLSPLT USB_OTG_HCSPLT_COMPLSPLT_Msk /*!< Do complete split */ +#define USB_OTG_HCSPLT_SPLITEN_Pos (31U) +#define USB_OTG_HCSPLT_SPLITEN_Msk (0x1UL << USB_OTG_HCSPLT_SPLITEN_Pos) /*!< 0x80000000 */ +#define USB_OTG_HCSPLT_SPLITEN USB_OTG_HCSPLT_SPLITEN_Msk /*!< Split enable */ + +/******************** Bit definition for USB_OTG_HCINT register ********************/ +#define USB_OTG_HCINT_XFRC_Pos (0U) +#define USB_OTG_HCINT_XFRC_Msk (0x1UL << USB_OTG_HCINT_XFRC_Pos) /*!< 0x00000001 */ +#define USB_OTG_HCINT_XFRC USB_OTG_HCINT_XFRC_Msk /*!< Transfer completed */ +#define USB_OTG_HCINT_CHH_Pos (1U) +#define USB_OTG_HCINT_CHH_Msk (0x1UL << USB_OTG_HCINT_CHH_Pos) /*!< 0x00000002 */ +#define USB_OTG_HCINT_CHH USB_OTG_HCINT_CHH_Msk /*!< Channel halted */ +#define USB_OTG_HCINT_AHBERR_Pos (2U) +#define USB_OTG_HCINT_AHBERR_Msk (0x1UL << USB_OTG_HCINT_AHBERR_Pos) /*!< 0x00000004 */ +#define USB_OTG_HCINT_AHBERR USB_OTG_HCINT_AHBERR_Msk /*!< AHB error */ +#define USB_OTG_HCINT_STALL_Pos (3U) +#define USB_OTG_HCINT_STALL_Msk (0x1UL << USB_OTG_HCINT_STALL_Pos) /*!< 0x00000008 */ +#define USB_OTG_HCINT_STALL USB_OTG_HCINT_STALL_Msk /*!< STALL response received interrupt */ +#define USB_OTG_HCINT_NAK_Pos (4U) +#define USB_OTG_HCINT_NAK_Msk (0x1UL << USB_OTG_HCINT_NAK_Pos) /*!< 0x00000010 */ +#define USB_OTG_HCINT_NAK USB_OTG_HCINT_NAK_Msk /*!< NAK response received interrupt */ +#define USB_OTG_HCINT_ACK_Pos (5U) +#define USB_OTG_HCINT_ACK_Msk (0x1UL << USB_OTG_HCINT_ACK_Pos) /*!< 0x00000020 */ +#define USB_OTG_HCINT_ACK USB_OTG_HCINT_ACK_Msk /*!< ACK response received/transmitted interrupt */ +#define USB_OTG_HCINT_NYET_Pos (6U) +#define USB_OTG_HCINT_NYET_Msk (0x1UL << USB_OTG_HCINT_NYET_Pos) /*!< 0x00000040 */ +#define USB_OTG_HCINT_NYET USB_OTG_HCINT_NYET_Msk /*!< Response received interrupt */ +#define USB_OTG_HCINT_TXERR_Pos (7U) +#define USB_OTG_HCINT_TXERR_Msk (0x1UL << USB_OTG_HCINT_TXERR_Pos) /*!< 0x00000080 */ +#define USB_OTG_HCINT_TXERR USB_OTG_HCINT_TXERR_Msk /*!< Transaction error */ +#define USB_OTG_HCINT_BBERR_Pos (8U) +#define USB_OTG_HCINT_BBERR_Msk (0x1UL << USB_OTG_HCINT_BBERR_Pos) /*!< 0x00000100 */ +#define USB_OTG_HCINT_BBERR USB_OTG_HCINT_BBERR_Msk /*!< Babble error */ +#define USB_OTG_HCINT_FRMOR_Pos (9U) +#define USB_OTG_HCINT_FRMOR_Msk (0x1UL << USB_OTG_HCINT_FRMOR_Pos) /*!< 0x00000200 */ +#define USB_OTG_HCINT_FRMOR USB_OTG_HCINT_FRMOR_Msk /*!< Frame overrun */ +#define USB_OTG_HCINT_DTERR_Pos (10U) +#define USB_OTG_HCINT_DTERR_Msk (0x1UL << USB_OTG_HCINT_DTERR_Pos) /*!< 0x00000400 */ +#define USB_OTG_HCINT_DTERR USB_OTG_HCINT_DTERR_Msk /*!< Data toggle error */ + +/******************** Bit definition for USB_OTG_DIEPINT register ********************/ +#define USB_OTG_DIEPINT_XFRC_Pos (0U) +#define USB_OTG_DIEPINT_XFRC_Msk (0x1UL << USB_OTG_DIEPINT_XFRC_Pos) /*!< 0x00000001 */ +#define USB_OTG_DIEPINT_XFRC USB_OTG_DIEPINT_XFRC_Msk /*!< Transfer completed interrupt */ +#define USB_OTG_DIEPINT_EPDISD_Pos (1U) +#define USB_OTG_DIEPINT_EPDISD_Msk (0x1UL << USB_OTG_DIEPINT_EPDISD_Pos) /*!< 0x00000002 */ +#define USB_OTG_DIEPINT_EPDISD USB_OTG_DIEPINT_EPDISD_Msk /*!< Endpoint disabled interrupt */ +#define USB_OTG_DIEPINT_AHBERR_Pos (2U) +#define USB_OTG_DIEPINT_AHBERR_Msk (0x1UL << USB_OTG_DIEPINT_AHBERR_Pos) /*!< 0x00000004 */ +#define USB_OTG_DIEPINT_AHBERR USB_OTG_DIEPINT_AHBERR_Msk /*!< AHB Error (AHBErr) during an IN transaction */ +#define USB_OTG_DIEPINT_TOC_Pos (3U) +#define USB_OTG_DIEPINT_TOC_Msk (0x1UL << USB_OTG_DIEPINT_TOC_Pos) /*!< 0x00000008 */ +#define USB_OTG_DIEPINT_TOC USB_OTG_DIEPINT_TOC_Msk /*!< Timeout condition */ +#define USB_OTG_DIEPINT_ITTXFE_Pos (4U) +#define USB_OTG_DIEPINT_ITTXFE_Msk (0x1UL << USB_OTG_DIEPINT_ITTXFE_Pos) /*!< 0x00000010 */ +#define USB_OTG_DIEPINT_ITTXFE USB_OTG_DIEPINT_ITTXFE_Msk /*!< IN token received when TxFIFO is empty */ +#define USB_OTG_DIEPINT_INEPNM_Pos (5U) +#define USB_OTG_DIEPINT_INEPNM_Msk (0x1UL << USB_OTG_DIEPINT_INEPNM_Pos) /*!< 0x00000004 */ +#define USB_OTG_DIEPINT_INEPNM USB_OTG_DIEPINT_INEPNM_Msk /*!< IN token received with EP mismatch */ +#define USB_OTG_DIEPINT_INEPNE_Pos (6U) +#define USB_OTG_DIEPINT_INEPNE_Msk (0x1UL << USB_OTG_DIEPINT_INEPNE_Pos) /*!< 0x00000040 */ +#define USB_OTG_DIEPINT_INEPNE USB_OTG_DIEPINT_INEPNE_Msk /*!< IN endpoint NAK effective */ +#define USB_OTG_DIEPINT_TXFE_Pos (7U) +#define USB_OTG_DIEPINT_TXFE_Msk (0x1UL << USB_OTG_DIEPINT_TXFE_Pos) /*!< 0x00000080 */ +#define USB_OTG_DIEPINT_TXFE USB_OTG_DIEPINT_TXFE_Msk /*!< Transmit FIFO empty */ +#define USB_OTG_DIEPINT_TXFIFOUDRN_Pos (8U) +#define USB_OTG_DIEPINT_TXFIFOUDRN_Msk (0x1UL << USB_OTG_DIEPINT_TXFIFOUDRN_Pos) /*!< 0x00000100 */ +#define USB_OTG_DIEPINT_TXFIFOUDRN USB_OTG_DIEPINT_TXFIFOUDRN_Msk /*!< Transmit Fifo Underrun */ +#define USB_OTG_DIEPINT_BNA_Pos (9U) +#define USB_OTG_DIEPINT_BNA_Msk (0x1UL << USB_OTG_DIEPINT_BNA_Pos) /*!< 0x00000200 */ +#define USB_OTG_DIEPINT_BNA USB_OTG_DIEPINT_BNA_Msk /*!< Buffer not available interrupt */ +#define USB_OTG_DIEPINT_PKTDRPSTS_Pos (11U) +#define USB_OTG_DIEPINT_PKTDRPSTS_Msk (0x1UL << USB_OTG_DIEPINT_PKTDRPSTS_Pos) /*!< 0x00000800 */ +#define USB_OTG_DIEPINT_PKTDRPSTS USB_OTG_DIEPINT_PKTDRPSTS_Msk /*!< Packet dropped status */ +#define USB_OTG_DIEPINT_BERR_Pos (12U) +#define USB_OTG_DIEPINT_BERR_Msk (0x1UL << USB_OTG_DIEPINT_BERR_Pos) /*!< 0x00001000 */ +#define USB_OTG_DIEPINT_BERR USB_OTG_DIEPINT_BERR_Msk /*!< Babble error interrupt */ +#define USB_OTG_DIEPINT_NAK_Pos (13U) +#define USB_OTG_DIEPINT_NAK_Msk (0x1UL << USB_OTG_DIEPINT_NAK_Pos) /*!< 0x00002000 */ +#define USB_OTG_DIEPINT_NAK USB_OTG_DIEPINT_NAK_Msk /*!< NAK interrupt */ + +/******************** Bit definition for USB_OTG_HCINTMSK register ********************/ +#define USB_OTG_HCINTMSK_XFRCM_Pos (0U) +#define USB_OTG_HCINTMSK_XFRCM_Msk (0x1UL << USB_OTG_HCINTMSK_XFRCM_Pos) /*!< 0x00000001 */ +#define USB_OTG_HCINTMSK_XFRCM USB_OTG_HCINTMSK_XFRCM_Msk /*!< Transfer completed mask */ +#define USB_OTG_HCINTMSK_CHHM_Pos (1U) +#define USB_OTG_HCINTMSK_CHHM_Msk (0x1UL << USB_OTG_HCINTMSK_CHHM_Pos) /*!< 0x00000002 */ +#define USB_OTG_HCINTMSK_CHHM USB_OTG_HCINTMSK_CHHM_Msk /*!< Channel halted mask */ +#define USB_OTG_HCINTMSK_AHBERR_Pos (2U) +#define USB_OTG_HCINTMSK_AHBERR_Msk (0x1UL << USB_OTG_HCINTMSK_AHBERR_Pos) /*!< 0x00000004 */ +#define USB_OTG_HCINTMSK_AHBERR USB_OTG_HCINTMSK_AHBERR_Msk /*!< AHB error */ +#define USB_OTG_HCINTMSK_STALLM_Pos (3U) +#define USB_OTG_HCINTMSK_STALLM_Msk (0x1UL << USB_OTG_HCINTMSK_STALLM_Pos) /*!< 0x00000008 */ +#define USB_OTG_HCINTMSK_STALLM USB_OTG_HCINTMSK_STALLM_Msk /*!< STALL response received interrupt mask */ +#define USB_OTG_HCINTMSK_NAKM_Pos (4U) +#define USB_OTG_HCINTMSK_NAKM_Msk (0x1UL << USB_OTG_HCINTMSK_NAKM_Pos) /*!< 0x00000010 */ +#define USB_OTG_HCINTMSK_NAKM USB_OTG_HCINTMSK_NAKM_Msk /*!< NAK response received interrupt mask */ +#define USB_OTG_HCINTMSK_ACKM_Pos (5U) +#define USB_OTG_HCINTMSK_ACKM_Msk (0x1UL << USB_OTG_HCINTMSK_ACKM_Pos) /*!< 0x00000020 */ +#define USB_OTG_HCINTMSK_ACKM USB_OTG_HCINTMSK_ACKM_Msk /*!< ACK response received/transmitted interrupt mask */ +#define USB_OTG_HCINTMSK_NYET_Pos (6U) +#define USB_OTG_HCINTMSK_NYET_Msk (0x1UL << USB_OTG_HCINTMSK_NYET_Pos) /*!< 0x00000040 */ +#define USB_OTG_HCINTMSK_NYET USB_OTG_HCINTMSK_NYET_Msk /*!< response received interrupt mask */ +#define USB_OTG_HCINTMSK_TXERRM_Pos (7U) +#define USB_OTG_HCINTMSK_TXERRM_Msk (0x1UL << USB_OTG_HCINTMSK_TXERRM_Pos) /*!< 0x00000080 */ +#define USB_OTG_HCINTMSK_TXERRM USB_OTG_HCINTMSK_TXERRM_Msk /*!< Transaction error mask */ +#define USB_OTG_HCINTMSK_BBERRM_Pos (8U) +#define USB_OTG_HCINTMSK_BBERRM_Msk (0x1UL << USB_OTG_HCINTMSK_BBERRM_Pos) /*!< 0x00000100 */ +#define USB_OTG_HCINTMSK_BBERRM USB_OTG_HCINTMSK_BBERRM_Msk /*!< Babble error mask */ +#define USB_OTG_HCINTMSK_FRMORM_Pos (9U) +#define USB_OTG_HCINTMSK_FRMORM_Msk (0x1UL << USB_OTG_HCINTMSK_FRMORM_Pos) /*!< 0x00000200 */ +#define USB_OTG_HCINTMSK_FRMORM USB_OTG_HCINTMSK_FRMORM_Msk /*!< Frame overrun mask */ +#define USB_OTG_HCINTMSK_DTERRM_Pos (10U) +#define USB_OTG_HCINTMSK_DTERRM_Msk (0x1UL << USB_OTG_HCINTMSK_DTERRM_Pos) /*!< 0x00000400 */ +#define USB_OTG_HCINTMSK_DTERRM USB_OTG_HCINTMSK_DTERRM_Msk /*!< Data toggle error mask */ + +/******************** Bit definition for USB_OTG_DIEPTSIZ register ********************/ + +#define USB_OTG_DIEPTSIZ_XFRSIZ_Pos (0U) +#define USB_OTG_DIEPTSIZ_XFRSIZ_Msk (0x7FFFFUL << USB_OTG_DIEPTSIZ_XFRSIZ_Pos) /*!< 0x0007FFFF */ +#define USB_OTG_DIEPTSIZ_XFRSIZ USB_OTG_DIEPTSIZ_XFRSIZ_Msk /*!< Transfer size */ +#define USB_OTG_DIEPTSIZ_PKTCNT_Pos (19U) +#define USB_OTG_DIEPTSIZ_PKTCNT_Msk (0x3FFUL << USB_OTG_DIEPTSIZ_PKTCNT_Pos) /*!< 0x1FF80000 */ +#define USB_OTG_DIEPTSIZ_PKTCNT USB_OTG_DIEPTSIZ_PKTCNT_Msk /*!< Packet count */ +#define USB_OTG_DIEPTSIZ_MULCNT_Pos (29U) +#define USB_OTG_DIEPTSIZ_MULCNT_Msk (0x3UL << USB_OTG_DIEPTSIZ_MULCNT_Pos) /*!< 0x60000000 */ +#define USB_OTG_DIEPTSIZ_MULCNT USB_OTG_DIEPTSIZ_MULCNT_Msk /*!< Packet count */ +/******************** Bit definition for USB_OTG_HCTSIZ register ********************/ +#define USB_OTG_HCTSIZ_XFRSIZ_Pos (0U) +#define USB_OTG_HCTSIZ_XFRSIZ_Msk (0x7FFFFUL << USB_OTG_HCTSIZ_XFRSIZ_Pos) /*!< 0x0007FFFF */ +#define USB_OTG_HCTSIZ_XFRSIZ USB_OTG_HCTSIZ_XFRSIZ_Msk /*!< Transfer size */ +#define USB_OTG_HCTSIZ_PKTCNT_Pos (19U) +#define USB_OTG_HCTSIZ_PKTCNT_Msk (0x3FFUL << USB_OTG_HCTSIZ_PKTCNT_Pos) /*!< 0x1FF80000 */ +#define USB_OTG_HCTSIZ_PKTCNT USB_OTG_HCTSIZ_PKTCNT_Msk /*!< Packet count */ +#define USB_OTG_HCTSIZ_DOPING_Pos (31U) +#define USB_OTG_HCTSIZ_DOPING_Msk (0x1UL << USB_OTG_HCTSIZ_DOPING_Pos) /*!< 0x80000000 */ +#define USB_OTG_HCTSIZ_DOPING USB_OTG_HCTSIZ_DOPING_Msk /*!< Do PING */ +#define USB_OTG_HCTSIZ_DPID_Pos (29U) +#define USB_OTG_HCTSIZ_DPID_Msk (0x3UL << USB_OTG_HCTSIZ_DPID_Pos) /*!< 0x60000000 */ +#define USB_OTG_HCTSIZ_DPID USB_OTG_HCTSIZ_DPID_Msk /*!< Data PID */ +#define USB_OTG_HCTSIZ_DPID_0 (0x1UL << USB_OTG_HCTSIZ_DPID_Pos) /*!< 0x20000000 */ +#define USB_OTG_HCTSIZ_DPID_1 (0x2UL << USB_OTG_HCTSIZ_DPID_Pos) /*!< 0x40000000 */ + +/******************** Bit definition for USB_OTG_DIEPDMA register ********************/ +#define USB_OTG_DIEPDMA_DMAADDR_Pos (0U) +#define USB_OTG_DIEPDMA_DMAADDR_Msk (0xFFFFFFFFUL << USB_OTG_DIEPDMA_DMAADDR_Pos) /*!< 0xFFFFFFFF */ +#define USB_OTG_DIEPDMA_DMAADDR USB_OTG_DIEPDMA_DMAADDR_Msk /*!< DMA address */ + +/******************** Bit definition for USB_OTG_HCDMA register ********************/ +#define USB_OTG_HCDMA_DMAADDR_Pos (0U) +#define USB_OTG_HCDMA_DMAADDR_Msk (0xFFFFFFFFUL << USB_OTG_HCDMA_DMAADDR_Pos) /*!< 0xFFFFFFFF */ +#define USB_OTG_HCDMA_DMAADDR USB_OTG_HCDMA_DMAADDR_Msk /*!< DMA address */ + +/******************** Bit definition for USB_OTG_DTXFSTS register ********************/ +#define USB_OTG_DTXFSTS_INEPTFSAV_Pos (0U) +#define USB_OTG_DTXFSTS_INEPTFSAV_Msk (0xFFFFUL << USB_OTG_DTXFSTS_INEPTFSAV_Pos) /*!< 0x0000FFFF */ +#define USB_OTG_DTXFSTS_INEPTFSAV USB_OTG_DTXFSTS_INEPTFSAV_Msk /*!< IN endpoint TxFIFO space available */ + +/******************** Bit definition for USB_OTG_DIEPTXF register ********************/ +#define USB_OTG_DIEPTXF_INEPTXSA_Pos (0U) +#define USB_OTG_DIEPTXF_INEPTXSA_Msk (0xFFFFUL << USB_OTG_DIEPTXF_INEPTXSA_Pos) /*!< 0x0000FFFF */ +#define USB_OTG_DIEPTXF_INEPTXSA USB_OTG_DIEPTXF_INEPTXSA_Msk /*!< IN endpoint FIFOx transmit RAM start address */ +#define USB_OTG_DIEPTXF_INEPTXFD_Pos (16U) +#define USB_OTG_DIEPTXF_INEPTXFD_Msk (0xFFFFUL << USB_OTG_DIEPTXF_INEPTXFD_Pos) /*!< 0xFFFF0000 */ +#define USB_OTG_DIEPTXF_INEPTXFD USB_OTG_DIEPTXF_INEPTXFD_Msk /*!< IN endpoint TxFIFO depth */ + +/******************** Bit definition for USB_OTG_DOEPCTL register ********************/ + +#define USB_OTG_DOEPCTL_MPSIZ_Pos (0U) +#define USB_OTG_DOEPCTL_MPSIZ_Msk (0x7FFUL << USB_OTG_DOEPCTL_MPSIZ_Pos) /*!< 0x000007FF */ +#define USB_OTG_DOEPCTL_MPSIZ USB_OTG_DOEPCTL_MPSIZ_Msk /*!< Maximum packet size */ /*!> 16) & 0xFF; + flash_id = ID & 0xffff; + */ +uint32_t bootloader_read_flash_id(void); + #if SOC_CACHE_SUPPORT_WRAP /** * @brief Set the burst mode setting command for specified wrap mode. @@ -19,3 +31,22 @@ */ esp_err_t bootloader_flash_wrap_set(spi_flash_wrap_mode_t mode); #endif + +/** + * @brief Unlock Flash write protect. + * Please do not call this function in SDK. + * + * @note This can be overridden because it's attribute weak. + */ +esp_err_t bootloader_flash_unlock(void); + +/** + * @brief Startup flow recommended by XMC. Call at startup before any erase/write operation. + * + * @return ESP_OK When startup successfully, otherwise ESP_FAIL (indiciating you should reboot before erase/write). + */ +esp_err_t bootloader_flash_xmc_startup(void); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/async.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/async.h deleted file mode 100644 index e399929677d..00000000000 --- a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/async.h +++ /dev/null @@ -1,148 +0,0 @@ -/* - * async.h -- state management for asynchronous messages - * - * Copyright (C) 2010-2011 Olaf Bergmann - * - * This file is part of the CoAP library libcoap. Please see README for terms - * of use. - */ - -/** - * @file async.h - * @brief State management for asynchronous messages - */ - -#ifndef COAP_ASYNC_H_ -#define COAP_ASYNC_H_ - -#include "net.h" - -#ifndef WITHOUT_ASYNC - -/** - * @defgroup coap_async Asynchronous Messaging - * @{ - * Structure for managing asynchronous state of CoAP resources. A - * coap_resource_t object holds a list of coap_async_state_t objects that can be - * used to generate a separate response in case a result of an operation cannot - * be delivered in time, or the resource has been explicitly subscribed to with - * the option @c observe. - */ -typedef struct coap_async_state_t { - unsigned char flags; /**< holds the flags to control behaviour */ - - /** - * Holds the internal time when the object was registered with a - * resource. This field will be updated whenever - * coap_register_async() is called for a specific resource. - */ - coap_tick_t created; - - /** - * This field can be used to register opaque application data with the - * asynchronous state object. - */ - void *appdata; - coap_session_t *session; /**< transaction session */ - coap_tid_t id; /**< transaction id */ - struct coap_async_state_t *next; /**< internally used for linking */ - size_t tokenlen; /**< length of the token */ - uint8_t token[8]; /**< the token to use in a response */ -} coap_async_state_t; - -/* Definitions for Async Status Flags These flags can be used to control the - * behaviour of asynchronous response generation. - */ -#define COAP_ASYNC_CONFIRM 0x01 /**< send confirmable response */ -#define COAP_ASYNC_SEPARATE 0x02 /**< send separate response */ -#define COAP_ASYNC_OBSERVED 0x04 /**< the resource is being observed */ - -/** release application data on destruction */ -#define COAP_ASYNC_RELEASE_DATA 0x08 - -/** - * Allocates a new coap_async_state_t object and fills its fields according to - * the given @p request. The @p flags are used to control generation of empty - * ACK responses to stop retransmissions and to release registered @p data when - * the resource is deleted by coap_free_async(). This function returns a pointer - * to the registered coap_async_t object or @c NULL on error. Note that this - * function will return @c NULL in case that an object with the same identifier - * is already registered. - * - * @param context The context to use. - * @param session The session that is used for asynchronous transmissions. - * @param request The request that is handled asynchronously. - * @param flags Flags to control state management. - * @param data Opaque application data to register. Note that the - * storage occupied by @p data is released on destruction - * only if flag COAP_ASYNC_RELEASE_DATA is set. - * - * @return A pointer to the registered coap_async_state_t object or @c - * NULL in case of an error. - */ -coap_async_state_t * -coap_register_async(coap_context_t *context, - coap_session_t *session, - coap_pdu_t *request, - unsigned char flags, - void *data); - -/** - * Removes the state object identified by @p id from @p context. The removed - * object is returned in @p s, if found. Otherwise, @p s is undefined. This - * function returns @c 1 if the object was removed, @c 0 otherwise. Note that - * the storage allocated for the stored object is not released by this - * functions. You will have to call coap_free_async() to do so. - * - * @param context The context where the async object is registered. - * @param session The session that is used for asynchronous transmissions. - * @param id The identifier of the asynchronous transaction. - * @param s Will be set to the object identified by @p id after removal. - * - * @return @c 1 if object was removed and @p s updated, or @c 0 if no - * object was found with the given id. @p s is valid only if the - * return value is @c 1. - */ -int coap_remove_async(coap_context_t *context, - coap_session_t *session, - coap_tid_t id, - coap_async_state_t **s); - -/** - * Releases the memory that was allocated by coap_async_state_init() for the - * object @p s. The registered application data will be released automatically - * if COAP_ASYNC_RELEASE_DATA is set. - * - * @param state The object to delete. - */ -void -coap_free_async(coap_async_state_t *state); - -/** - * Retrieves the object identified by @p id from the list of asynchronous - * transactions that are registered with @p context. This function returns a - * pointer to that object or @c NULL if not found. - * - * @param context The context where the asynchronous objects are registered - * with. - * @param session The session that is used for asynchronous transmissions. - * @param id The id of the object to retrieve. - * - * @return A pointer to the object identified by @p id or @c NULL if - * not found. - */ -coap_async_state_t *coap_find_async(coap_context_t *context, coap_session_t *session, coap_tid_t id); - -/** - * Updates the time stamp of @p s. - * - * @param s The state object to update. - */ -COAP_STATIC_INLINE void -coap_touch_async(coap_async_state_t *s) { coap_ticks(&s->created); } - -/** @} */ - -#endif /* WITHOUT_ASYNC */ - -#endif /* COAP_ASYNC_H_ */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/bits.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/bits.h deleted file mode 100644 index 3b1871487c9..00000000000 --- a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/bits.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * bits.h -- bit vector manipulation - * - * Copyright (C) 2010-2011 Olaf Bergmann - * - * This file is part of the CoAP library libcoap. Please see README for terms - * of use. - */ - -/** - * @file bits.h - * @brief Bit vector manipulation - */ - -#ifndef COAP_BITS_H_ -#define COAP_BITS_H_ - -#include - -/** - * Sets the bit @p bit in bit-vector @p vec. This function returns @c 1 if bit - * was set or @c -1 on error (i.e. when the given bit does not fit in the - * vector). - * - * @param vec The bit-vector to change. - * @param size The size of @p vec in bytes. - * @param bit The bit to set in @p vec. - * - * @return @c -1 if @p bit does not fit into @p vec, @c 1 otherwise. - */ -COAP_STATIC_INLINE int -bits_setb(uint8_t *vec, size_t size, uint8_t bit) { - if (size <= ((size_t)bit >> 3)) - return -1; - - *(vec + (bit >> 3)) |= (uint8_t)(1 << (bit & 0x07)); - return 1; -} - -/** - * Clears the bit @p bit from bit-vector @p vec. This function returns @c 1 if - * bit was cleared or @c -1 on error (i.e. when the given bit does not fit in - * the vector). - * - * @param vec The bit-vector to change. - * @param size The size of @p vec in bytes. - * @param bit The bit to clear from @p vec. - * - * @return @c -1 if @p bit does not fit into @p vec, @c 1 otherwise. - */ -COAP_STATIC_INLINE int -bits_clrb(uint8_t *vec, size_t size, uint8_t bit) { - if (size <= ((size_t)bit >> 3)) - return -1; - - *(vec + (bit >> 3)) &= (uint8_t)(~(1 << (bit & 0x07))); - return 1; -} - -/** - * Gets the status of bit @p bit from bit-vector @p vec. This function returns - * @c 1 if the bit is set, @c 0 otherwise (even in case of an error). - * - * @param vec The bit-vector to read from. - * @param size The size of @p vec in bytes. - * @param bit The bit to get from @p vec. - * - * @return @c 1 if the bit is set, @c 0 otherwise. - */ -COAP_STATIC_INLINE int -bits_getb(const uint8_t *vec, size_t size, uint8_t bit) { - if (size <= ((size_t)bit >> 3)) - return -1; - - return (*(vec + (bit >> 3)) & (1 << (bit & 0x07))) != 0; -} - -#endif /* COAP_BITS_H_ */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/block.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/block.h deleted file mode 100644 index 848897639c9..00000000000 --- a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/block.h +++ /dev/null @@ -1,173 +0,0 @@ -/* - * block.h -- block transfer - * - * Copyright (C) 2010-2012,2014-2015 Olaf Bergmann - * - * This file is part of the CoAP library libcoap. Please see README for terms - * of use. - */ - -#ifndef COAP_BLOCK_H_ -#define COAP_BLOCK_H_ - -#include "encode.h" -#include "option.h" -#include "pdu.h" - -struct coap_resource_t; -struct coap_session_t; - -/** - * @defgroup block Block Transfer - * API functions for handling PDUs using CoAP BLOCK options - * @{ - */ - -#ifndef COAP_MAX_BLOCK_SZX -/** - * The largest value for the SZX component in a Block option. - */ -#define COAP_MAX_BLOCK_SZX 6 -#endif /* COAP_MAX_BLOCK_SZX */ - -/** - * Structure of Block options. - */ -typedef struct { - unsigned int num; /**< block number */ - unsigned int m:1; /**< 1 if more blocks follow, 0 otherwise */ - unsigned int szx:3; /**< block size */ -} coap_block_t; - -/** - * Returns the value of the least significant byte of a Block option @p opt. - * For zero-length options (i.e. num == m == szx == 0), COAP_OPT_BLOCK_LAST - * returns @c NULL. - */ -#define COAP_OPT_BLOCK_LAST(opt) \ - (coap_opt_length(opt) ? (coap_opt_value(opt) + (coap_opt_length(opt)-1)) : 0) - -/** Returns the value of the More-bit of a Block option @p opt. */ -#define COAP_OPT_BLOCK_MORE(opt) \ - (coap_opt_length(opt) ? (*COAP_OPT_BLOCK_LAST(opt) & 0x08) : 0) - -/** Returns the value of the SZX-field of a Block option @p opt. */ -#define COAP_OPT_BLOCK_SZX(opt) \ - (coap_opt_length(opt) ? (*COAP_OPT_BLOCK_LAST(opt) & 0x07) : 0) - -/** - * Returns the value of field @c num in the given block option @p block_opt. - */ -unsigned int coap_opt_block_num(const coap_opt_t *block_opt); - -/** - * Checks if more than @p num blocks are required to deliver @p data_len - * bytes of data for a block size of 1 << (@p szx + 4). - */ -COAP_STATIC_INLINE int -coap_more_blocks(size_t data_len, unsigned int num, uint16_t szx) { - return ((num+1) << (szx + 4)) < data_len; -} - -#if 0 -/** Sets the More-bit in @p block_opt */ -COAP_STATIC_INLINE void -coap_opt_block_set_m(coap_opt_t *block_opt, int m) { - if (m) - *(coap_opt_value(block_opt) + (coap_opt_length(block_opt) - 1)) |= 0x08; - else - *(coap_opt_value(block_opt) + (coap_opt_length(block_opt) - 1)) &= ~0x08; -} -#endif - -/** - * Initializes @p block from @p pdu. @p type must be either COAP_OPTION_BLOCK1 - * or COAP_OPTION_BLOCK2. When option @p type was found in @p pdu, @p block is - * initialized with values from this option and the function returns the value - * @c 1. Otherwise, @c 0 is returned. - * - * @param pdu The pdu to search for option @p type. - * @param type The option to search for (must be COAP_OPTION_BLOCK1 or - * COAP_OPTION_BLOCK2). - * @param block The block structure to initilize. - * - * @return @c 1 on success, @c 0 otherwise. - */ -int coap_get_block(coap_pdu_t *pdu, uint16_t type, coap_block_t *block); - -/** - * Writes a block option of type @p type to message @p pdu. If the requested - * block size is too large to fit in @p pdu, it is reduced accordingly. An - * exception is made for the final block when less space is required. The actual - * length of the resource is specified in @p data_length. - * - * This function may change *block to reflect the values written to @p pdu. As - * the function takes into consideration the remaining space @p pdu, no more - * options should be added after coap_write_block_opt() has returned. - * - * @param block The block structure to use. On return, this object is - * updated according to the values that have been written to - * @p pdu. - * @param type COAP_OPTION_BLOCK1 or COAP_OPTION_BLOCK2. - * @param pdu The message where the block option should be written. - * @param data_length The length of the actual data that will be added the @p - * pdu by calling coap_add_block(). - * - * @return @c 1 on success, or a negative value on error. - */ -int coap_write_block_opt(coap_block_t *block, - uint16_t type, - coap_pdu_t *pdu, - size_t data_length); - -/** - * Adds the @p block_num block of size 1 << (@p block_szx + 4) from source @p - * data to @p pdu. - * - * @param pdu The message to add the block. - * @param len The length of @p data. - * @param data The source data to fill the block with. - * @param block_num The actual block number. - * @param block_szx Encoded size of block @p block_number. - * - * @return @c 1 on success, @c 0 otherwise. - */ -int coap_add_block(coap_pdu_t *pdu, - unsigned int len, - const uint8_t *data, - unsigned int block_num, - unsigned char block_szx); - -/** - * Adds the appropriate part of @p data to the @p response pdu. If blocks are - * required, then the appropriate block will be added to the PDU and sent. - * Adds a ETAG option that is the hash of the entire data if the data is to be - * split into blocks - * Used by a GET request handler. - * - * @param resource The resource the data is associated with. - * @param session The coap session. - * @param request The requesting pdu. - * @param response The response pdu. - * @param token The token taken from the (original) requesting pdu. - * @param media_type The format of the data. - * @param maxage The maxmimum life of the data. If @c -1, then there - * is no maxage. - * @param length The total length of the data. - * @param data The entire data block to transmit. - * - */ -void -coap_add_data_blocked_response(struct coap_resource_t *resource, - struct coap_session_t *session, - coap_pdu_t *request, - coap_pdu_t *response, - const coap_binary_t *token, - uint16_t media_type, - int maxage, - size_t length, - const uint8_t* data); - -/**@}*/ - -#endif /* COAP_BLOCK_H_ */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/coap_dtls.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/coap_dtls.h deleted file mode 100644 index f0554f3dfea..00000000000 --- a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/coap_dtls.h +++ /dev/null @@ -1,611 +0,0 @@ -/* - * coap_dtls.h -- (Datagram) Transport Layer Support for libcoap - * - * Copyright (C) 2016 Olaf Bergmann - * Copyright (C) 2017 Jean-Claude Michelou - * - * This file is part of the CoAP library libcoap. Please see README for terms - * of use. - */ - -#ifndef COAP_DTLS_H_ -#define COAP_DTLS_H_ - -#include "coap_time.h" - -struct coap_context_t; -struct coap_session_t; -struct coap_dtls_pki_t; - -/** - * @defgroup dtls DTLS Support - * API functions for interfacing with DTLS libraries. - * @{ - */ - -/** - * Check whether DTLS is available. - * - * @return @c 1 if support for DTLS is enabled, or @c 0 otherwise. - */ -int coap_dtls_is_supported(void); - -/** - * Check whether TLS is available. - * - * @return @c 1 if support for TLS is enabled, or @c 0 otherwise. - */ -int coap_tls_is_supported(void); - -#define COAP_TLS_LIBRARY_NOTLS 0 /**< No DTLS library */ -#define COAP_TLS_LIBRARY_TINYDTLS 1 /**< Using TinyDTLS library */ -#define COAP_TLS_LIBRARY_OPENSSL 2 /**< Using OpenSSL library */ -#define COAP_TLS_LIBRARY_GNUTLS 3 /**< Using GnuTLS library */ - -/** - * The structure used for returning the underlying (D)TLS library - * information. - */ -typedef struct coap_tls_version_t { - uint64_t version; /**< (D)TLS runtime Library Version */ - int type; /**< Library type. One of COAP_TLS_LIBRARY_* */ - uint64_t built_version; /**< (D)TLS Built against Library Version */ -} coap_tls_version_t; - -/** - * Determine the type and version of the underlying (D)TLS library. - * - * @return The version and type of library libcoap was compiled against. - */ -coap_tls_version_t *coap_get_tls_library_version(void); - -/** - * Additional Security setup handler that can be set up by - * coap_context_set_pki(). - * Invoked when libcoap has done the validation checks at the TLS level, - * but the application needs to do some additional checks/changes/updates. - * - * @param tls_session The security session definition - e.g. SSL * for OpenSSL. - * NULL if server call-back. - * This will be dependent on the underlying TLS library - - * see coap_get_tls_library_version() - * @param setup_data A structure containing setup data originally passed into - * coap_context_set_pki() or coap_new_client_session_pki(). - * - * @return @c 1 if successful, else @c 0. - */ -typedef int (*coap_dtls_security_setup_t)(void* tls_session, - struct coap_dtls_pki_t *setup_data); - -/** - * CN Validation call-back that can be set up by coap_context_set_pki(). - * Invoked when libcoap has done the validation checks at the TLS level, - * but the application needs to check that the CN is allowed. - * CN is the SubjectAltName in the cert, if not present, then the leftmost - * Common Name (CN) component of the subject name. - * - * @param cn The determined CN from the certificate - * @param asn1_public_cert The ASN.1 DER encoded X.509 certificate - * @param asn1_length The ASN.1 length - * @param coap_session The CoAP session associated with the certificate update - * @param depth Depth in cert chain. If 0, then client cert, else a CA - * @param validated TLS layer can find no issues if 1 - * @param arg The same as was passed into coap_context_set_pki() - * in setup_data->cn_call_back_arg - * - * @return @c 1 if accepted, else @c 0 if to be rejected. - */ -typedef int (*coap_dtls_cn_callback_t)(const char *cn, - const uint8_t *asn1_public_cert, - size_t asn1_length, - struct coap_session_t *coap_session, - unsigned depth, - int validated, - void *arg); - -/** - * The enum used for determining the provided PKI ASN.1 (DER) Private Key - * formats. - */ -typedef enum coap_asn1_privatekey_type_t { - COAP_ASN1_PKEY_NONE, /**< NONE */ - COAP_ASN1_PKEY_RSA, /**< RSA type */ - COAP_ASN1_PKEY_RSA2, /**< RSA2 type */ - COAP_ASN1_PKEY_DSA, /**< DSA type */ - COAP_ASN1_PKEY_DSA1, /**< DSA1 type */ - COAP_ASN1_PKEY_DSA2, /**< DSA2 type */ - COAP_ASN1_PKEY_DSA3, /**< DSA3 type */ - COAP_ASN1_PKEY_DSA4, /**< DSA4 type */ - COAP_ASN1_PKEY_DH, /**< DH type */ - COAP_ASN1_PKEY_DHX, /**< DHX type */ - COAP_ASN1_PKEY_EC, /**< EC type */ - COAP_ASN1_PKEY_HMAC, /**< HMAC type */ - COAP_ASN1_PKEY_CMAC, /**< CMAC type */ - COAP_ASN1_PKEY_TLS1_PRF, /**< TLS1_PRF type */ - COAP_ASN1_PKEY_HKDF /**< HKDF type */ -} coap_asn1_privatekey_type_t; - -/** - * The enum used for determining the PKI key formats. - */ -typedef enum coap_pki_key_t { - COAP_PKI_KEY_PEM = 0, /**< The PKI key type is PEM */ - COAP_PKI_KEY_ASN1, /**< The PKI key type is ASN.1 (DER) */ -} coap_pki_key_t; - -/** - * The structure that holds the PKI PEM definitions. - */ -typedef struct coap_pki_key_pem_t { - const char *ca_file; /**< File location of Common CA in PEM format */ - const char *public_cert; /**< File location of Public Cert in PEM format */ - const char *private_key; /**< File location of Private Key in PEM format */ -} coap_pki_key_pem_t; - -/** - * The structure that holds the PKI ASN.1 (DER) definitions. - */ -typedef struct coap_pki_key_asn1_t { - const uint8_t *ca_cert; /**< ASN1 (DER) Common CA Cert */ - const uint8_t *public_cert; /**< ASN1 (DER) Public Cert */ - const uint8_t *private_key; /**< ASN1 (DER) Private Key */ - size_t ca_cert_len; /**< ASN1 CA Cert length */ - size_t public_cert_len; /**< ASN1 Public Cert length */ - size_t private_key_len; /**< ASN1 Private Key length */ - coap_asn1_privatekey_type_t private_key_type; /**< Private Key Type */ -} coap_pki_key_asn1_t; - -/** - * The structure that holds the PKI key information. - */ -typedef struct coap_dtls_key_t { - coap_pki_key_t key_type; /**< key format type */ - union { - coap_pki_key_pem_t pem; /**< for PEM keys */ - coap_pki_key_asn1_t asn1; /**< for ASN.1 (DER) keys */ - } key; -} coap_dtls_key_t; - -/** - * Server Name Indication (SNI) Validation call-back that can be set up by - * coap_context_set_pki(). - * Invoked if the SNI is not previously seen and prior to sending a certificate - * set back to the client so that the appropriate certificate set can be used - * based on the requesting SNI. - * - * @param sni The requested SNI - * @param arg The same as was passed into coap_context_set_pki() - * in setup_data->sni_call_back_arg - * - * @return New set of certificates to use, or @c NULL if SNI is to be rejected. - */ -typedef coap_dtls_key_t *(*coap_dtls_sni_callback_t)(const char *sni, - void* arg); - - -#define COAP_DTLS_PKI_SETUP_VERSION 1 /**< Latest PKI setup version */ - -/** - * The structure used for defining the PKI setup data to be used. - */ -typedef struct coap_dtls_pki_t { - uint8_t version; /** Set to 1 to support this version of the struct */ - - /* Options to enable different TLS functionality in libcoap */ - uint8_t verify_peer_cert; /**< 1 if peer cert is to be verified */ - uint8_t require_peer_cert; /**< 1 if peer cert is required */ - uint8_t allow_self_signed; /**< 1 if self signed certs are allowed */ - uint8_t allow_expired_certs; /**< 1 if expired certs are allowed */ - uint8_t cert_chain_validation; /**< 1 if to check cert_chain_verify_depth */ - uint8_t cert_chain_verify_depth; /**< recommended depth is 3 */ - uint8_t check_cert_revocation; /**< 1 if revocation checks wanted */ - uint8_t allow_no_crl; /**< 1 ignore if CRL not there */ - uint8_t allow_expired_crl; /**< 1 if expired crl is allowed */ - uint8_t reserved[6]; /**< Reserved - must be set to 0 for - future compatibility */ - /* Size of 6 chosen to align to next - * parameter, so if newly defined option - * it can use one of the reserverd slot so - * no need to change - * COAP_DTLS_PKI_SETUP_VERSION and just - * decrement the reserved[] count. - */ - - /** CN check call-back function. - * If not NULL, is called when the TLS connection has passed the configured - * TLS options above for the application to verify if the CN is valid. - */ - coap_dtls_cn_callback_t validate_cn_call_back; - void *cn_call_back_arg; /**< Passed in to the CN call-back function */ - - /** SNI check call-back function. - * If not @p NULL, called if the SNI is not previously seen and prior to - * sending a certificate set back to the client so that the appropriate - * certificate set can be used based on the requesting SNI. - */ - coap_dtls_sni_callback_t validate_sni_call_back; - void *sni_call_back_arg; /**< Passed in to the sni call-back function */ - - /** Additional Security call-back handler that is invoked when libcoap has - * done the standerd, defined validation checks at the TLS level, - * If not @p NULL, called from within the TLS Client Hello connection - * setup. - */ - coap_dtls_security_setup_t additional_tls_setup_call_back; - - char* client_sni; /**< If not NULL, SNI to use in client TLS setup. - Owned by the client app and must remain valid - during the call to coap_new_client_session_pki() */ - - coap_dtls_key_t pki_key; /**< PKI key definition */ -} coap_dtls_pki_t; - -/** @} */ - -/** - * @defgroup dtls_internal DTLS Support (Internal) - * Internal API functions for interfacing with DTLS libraries. - * @{ - */ - -/** - * Creates a new DTLS context for the given @p coap_context. This function - * returns a pointer to a new DTLS context object or @c NULL on error. - * - * Internal function. - * - * @param coap_context The CoAP context where the DTLS object shall be used. - * - * @return A DTLS context object or @c NULL on error. - */ -void * -coap_dtls_new_context(struct coap_context_t *coap_context); - -typedef enum coap_dtls_role_t { - COAP_DTLS_ROLE_CLIENT, /**< Internal function invoked for client */ - COAP_DTLS_ROLE_SERVER /**< Internal function invoked for server */ -} coap_dtls_role_t; - -/** - * Set the DTLS context's default PSK information. - * This does the PSK specifics following coap_dtls_new_context(). - * If @p COAP_DTLS_ROLE_SERVER, then identity hint will also get set. - * If @p COAP_DTLS_ROLE_SERVER, then the information will get put into the - * TLS library's context (from which sessions are derived). - * If @p COAP_DTLS_ROLE_CLIENT, then the information will get put into the - * TLS library's session. - * - * Internal function. - * - * @param coap_context The CoAP context. - * @param identity_hint The default PSK server identity hint sent to a client. - * Required parameter. If @p NULL, will be set to "". - * Empty string is a valid hint. - * This parameter is ignored if COAP_DTLS_ROLE_CLIENT - * @param role One of @p COAP_DTLS_ROLE_CLIENT or @p COAP_DTLS_ROLE_SERVER - * - * @return @c 1 if successful, else @c 0. - */ - -int -coap_dtls_context_set_psk(struct coap_context_t *coap_context, - const char *identity_hint, - coap_dtls_role_t role); - -/** - * Set the DTLS context's default server PKI information. - * This does the PKI specifics following coap_dtls_new_context(). - * If @p COAP_DTLS_ROLE_SERVER, then the information will get put into the - * TLS library's context (from which sessions are derived). - * If @p COAP_DTLS_ROLE_CLIENT, then the information will get put into the - * TLS library's session. - * - * Internal function. - * - * @param coap_context The CoAP context. - * @param setup_data Setup information defining how PKI is to be setup. - * Required parameter. If @p NULL, PKI will not be - * set up. - * @param role One of @p COAP_DTLS_ROLE_CLIENT or @p COAP_DTLS_ROLE_SERVER - * - * @return @c 1 if successful, else @c 0. - */ - -int -coap_dtls_context_set_pki(struct coap_context_t *coap_context, - coap_dtls_pki_t *setup_data, - coap_dtls_role_t role); - -/** - * Set the dtls context's default Root CA information for a client or server. - * - * Internal function. - * - * @param coap_context The current coap_context_t object. - * @param ca_file If not @p NULL, is the full path name of a PEM encoded - * file containing all the Root CAs to be used. - * @param ca_dir If not @p NULL, points to a directory containing PEM - * encoded files containing all the Root CAs to be used. - * - * @return @c 1 if successful, else @c 0. - */ - -int -coap_dtls_context_set_pki_root_cas(struct coap_context_t *coap_context, - const char *ca_file, - const char *ca_dir); - -/** - * Check whether one of the coap_dtls_context_set_{psk|pki}() functions have - * been called. - * - * Internal function. - * - * @param coap_context The current coap_context_t object. - * - * @return @c 1 if coap_dtls_context_set_{psk|pki}() called, else @c 0. - */ - -int coap_dtls_context_check_keys_enabled(struct coap_context_t *coap_context); - -/** - * Releases the storage allocated for @p dtls_context. - * - * Internal function. - * - * @param dtls_context The DTLS context as returned by coap_dtls_new_context(). - */ -void coap_dtls_free_context(void *dtls_context); - -/** - * Create a new client-side session. This should send a HELLO to the server. - * - * Internal function. - * - * @param coap_session The CoAP session. - * - * @return Opaque handle to underlying TLS library object containing security - * parameters for the session. -*/ -void *coap_dtls_new_client_session(struct coap_session_t *coap_session); - -/** - * Create a new DTLS server-side session. - * Called after coap_dtls_hello() has returned @c 1, signalling that a validated - * HELLO was received from a client. - * This should send a HELLO to the server. - * - * Internal function. - * - * @param coap_session The CoAP session. - * - * @return Opaque handle to underlying TLS library object containing security - * parameters for the DTLS session. - */ -void *coap_dtls_new_server_session(struct coap_session_t *coap_session); - -/** - * Terminates the DTLS session (may send an ALERT if necessary) then frees the - * underlying TLS library object containing security parameters for the session. - * - * Internal function. - * - * @param coap_session The CoAP session. - */ -void coap_dtls_free_session(struct coap_session_t *coap_session); - -/** - * Notify of a change in the CoAP session's MTU, for example after - * a PMTU update. - * - * Internal function. - * - * @param coap_session The CoAP session. - */ -void coap_dtls_session_update_mtu(struct coap_session_t *coap_session); - -/** - * Send data to a DTLS peer. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param data pointer to data. - * @param data_len Number of bytes to send. - * - * @return @c 0 if this would be blocking, @c -1 if there is an error or the - * number of cleartext bytes sent. - */ -int coap_dtls_send(struct coap_session_t *coap_session, - const uint8_t *data, - size_t data_len); - -/** - * Check if timeout is handled per CoAP session or per CoAP context. - * - * Internal function. - * - * @return @c 1 of timeout and retransmit is per context, @c 0 if it is - * per session. - */ -int coap_dtls_is_context_timeout(void); - -/** - * Do all pending retransmits and get next timeout - * - * Internal function. - * - * @param dtls_context The DTLS context. - * - * @return @c 0 if no event is pending or date of the next retransmit. - */ -coap_tick_t coap_dtls_get_context_timeout(void *dtls_context); - -/** - * Get next timeout for this session. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param now The current time in ticks. - * - * @return @c 0 If no event is pending or ticks time of the next retransmit. - */ -coap_tick_t coap_dtls_get_timeout(struct coap_session_t *coap_session, - coap_tick_t now); - -/** - * Handle a DTLS timeout expiration. - * - * Internal function. - * - * @param coap_session The CoAP session. - */ -void coap_dtls_handle_timeout(struct coap_session_t *coap_session); - -/** - * Handling incoming data from a DTLS peer. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param data Encrypted datagram. - * @param data_len Encrypted datagram size. - * - * @return Result of coap_handle_dgram on the decrypted CoAP PDU - * or @c -1 for error. - */ -int coap_dtls_receive(struct coap_session_t *coap_session, - const uint8_t *data, - size_t data_len); - -/** - * Handling client HELLO messages from a new candiate peer. - * Note that session->tls is empty. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param data Encrypted datagram. - * @param data_len Encrypted datagram size. - * - * @return @c 0 if a cookie verification message has been sent, @c 1 if the - * HELLO contains a valid cookie and a server session should be created, - * @c -1 if the message is invalid. - */ -int coap_dtls_hello(struct coap_session_t *coap_session, - const uint8_t *data, - size_t data_len); - -/** - * Get DTLS overhead over cleartext PDUs. - * - * Internal function. - * - * @param coap_session The CoAP session. - * - * @return Maximum number of bytes added by DTLS layer. - */ -unsigned int coap_dtls_get_overhead(struct coap_session_t *coap_session); - -/** - * Create a new TLS client-side session. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param connected Updated with whether the connection is connected yet or not. - * @c 0 is not connected, @c 1 is connected. - * - * @return Opaque handle to underlying TLS library object containing security - * parameters for the session. -*/ -void *coap_tls_new_client_session(struct coap_session_t *coap_session, int *connected); - -/** - * Create a TLS new server-side session. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param connected Updated with whether the connection is connected yet or not. - * @c 0 is not connected, @c 1 is connected. - * - * @return Opaque handle to underlying TLS library object containing security - * parameters for the session. - */ -void *coap_tls_new_server_session(struct coap_session_t *coap_session, int *connected); - -/** - * Terminates the TLS session (may send an ALERT if necessary) then frees the - * underlying TLS library object containing security parameters for the session. - * - * Internal function. - * - * @param coap_session The CoAP session. - */ -void coap_tls_free_session( struct coap_session_t *coap_session ); - -/** - * Send data to a TLS peer, with implicit flush. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param data Pointer to data. - * @param data_len Number of bytes to send. - * - * @return @c 0 if this should be retried, @c -1 if there is an error - * or the number of cleartext bytes sent. - */ -ssize_t coap_tls_write(struct coap_session_t *coap_session, - const uint8_t *data, - size_t data_len - ); - -/** - * Read some data from a TLS peer. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param data Pointer to data. - * @param data_len Maximum number of bytes to read. - * - * @return @c 0 if this should be retried, @c -1 if there is an error - * or the number of cleartext bytes read. - */ -ssize_t coap_tls_read(struct coap_session_t *coap_session, - uint8_t *data, - size_t data_len - ); - -/** - * Initialize the underlying (D)TLS Library layer. - * - * Internal function. - * - */ -void coap_dtls_startup(void); - -/** @} */ - -/** - * @ingroup logging - * Sets the (D)TLS logging level to the specified @p level. - * Note: coap_log_level() will influence output if at a specified level. - * - * @param level The logging level to use - LOG_* - */ -void coap_dtls_set_log_level(int level); - -/** - * @ingroup logging - * Get the current (D)TLS logging. - * - * @return The current log level (one of LOG_*). - */ -int coap_dtls_get_log_level(void); - - -#endif /* COAP_DTLS_H */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/coap_session.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/coap_session.h deleted file mode 100644 index 1dc0103e3e7..00000000000 --- a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/coap_session.h +++ /dev/null @@ -1,492 +0,0 @@ -/* coap_session.h -- Session management for libcoap -* -* Copyright (C) 2017 Jean-Claue Michelou -* -* This file is part of the CoAP library libcoap. Please see -* README for terms of use. -*/ - -#ifndef COAP_SESSION_H_ -#define COAP_SESSION_H_ - - -#include "coap_io.h" -#include "coap_time.h" -#include "pdu.h" - -struct coap_endpoint_t; -struct coap_context_t; -struct coap_queue_t; - -/** -* Abstraction of a fixed point number that can be used where necessary instead -* of a float. 1,000 fractional bits equals one integer -*/ -typedef struct coap_fixed_point_t { - uint16_t integer_part; /**< Integer part of fixed point variable */ - uint16_t fractional_part; /**< Fractional part of fixed point variable - 1/1000 (3 points) precision */ -} coap_fixed_point_t; - -#define COAP_DEFAULT_SESSION_TIMEOUT 300 -#define COAP_PARTIAL_SESSION_TIMEOUT_TICKS (30 * COAP_TICKS_PER_SECOND) -#define COAP_DEFAULT_MAX_HANDSHAKE_SESSIONS 100 - -#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS) -#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS) - -typedef uint8_t coap_session_type_t; -/** - * coap_session_type_t values - */ -#define COAP_SESSION_TYPE_CLIENT 1 /**< client-side */ -#define COAP_SESSION_TYPE_SERVER 2 /**< server-side */ -#define COAP_SESSION_TYPE_HELLO 3 /**< server-side ephemeral session for responding to a client hello */ - -typedef uint8_t coap_session_state_t; -/** - * coap_session_state_t values - */ -#define COAP_SESSION_STATE_NONE 0 -#define COAP_SESSION_STATE_CONNECTING 1 -#define COAP_SESSION_STATE_HANDSHAKE 2 -#define COAP_SESSION_STATE_CSM 3 -#define COAP_SESSION_STATE_ESTABLISHED 4 - -typedef struct coap_session_t { - struct coap_session_t *next; - coap_proto_t proto; /**< protocol used */ - coap_session_type_t type; /**< client or server side socket */ - coap_session_state_t state; /**< current state of relationaship with peer */ - unsigned ref; /**< reference count from queues */ - unsigned tls_overhead; /**< overhead of TLS layer */ - unsigned mtu; /**< path or CSM mtu */ - coap_address_t local_if; /**< optional local interface address */ - coap_address_t remote_addr; /**< remote address and port */ - coap_address_t local_addr; /**< local address and port */ - int ifindex; /**< interface index */ - coap_socket_t sock; /**< socket object for the session, if any */ - struct coap_endpoint_t *endpoint; /**< session's endpoint */ - struct coap_context_t *context; /**< session's context */ - void *tls; /**< security parameters */ - uint16_t tx_mid; /**< the last message id that was used in this session */ - uint8_t con_active; /**< Active CON request sent */ - struct coap_queue_t *delayqueue; /**< list of delayed messages waiting to be sent */ - size_t partial_write; /**< if > 0 indicates number of bytes already written from the pdu at the head of sendqueue */ - uint8_t read_header[8]; /**< storage space for header of incoming message header */ - size_t partial_read; /**< if > 0 indicates number of bytes already read for an incoming message */ - coap_pdu_t *partial_pdu; /**< incomplete incoming pdu */ - coap_tick_t last_rx_tx; - coap_tick_t last_tx_rst; - coap_tick_t last_ping; - coap_tick_t last_pong; - coap_tick_t csm_tx; - uint8_t *psk_identity; - size_t psk_identity_len; - uint8_t *psk_key; - size_t psk_key_len; - void *app; /**< application-specific data */ - unsigned int max_retransmit; /**< maximum re-transmit count (default 4) */ - coap_fixed_point_t ack_timeout; /**< timeout waiting for ack (default 2 secs) */ - coap_fixed_point_t ack_random_factor; /**< ack random factor backoff (default 1.5) */ - unsigned int dtls_timeout_count; /**< dtls setup retry counter */ - int dtls_event; /**< Tracking any (D)TLS events on this sesison */ -} coap_session_t; - -/** -* Increment reference counter on a session. -* -* @param session The CoAP session. -* @return same as session -*/ -coap_session_t *coap_session_reference(coap_session_t *session); - -/** -* Decrement reference counter on a session. -* Note that the session may be deleted as a result and should not be used -* after this call. -* -* @param session The CoAP session. -*/ -void coap_session_release(coap_session_t *session); - -/** -* Stores @p data with the given session. This function overwrites any value -* that has previously been stored with @p session. -*/ -void coap_session_set_app_data(coap_session_t *session, void *data); - -/** -* Returns any application-specific data that has been stored with @p -* session using the function coap_session_set_app_data(). This function will -* return @c NULL if no data has been stored. -*/ -void *coap_session_get_app_data(const coap_session_t *session); - -/** -* Notify session that it has failed. -* -* @param session The CoAP session. -* @param reason The reason why the session was disconnected. -*/ -void coap_session_disconnected(coap_session_t *session, coap_nack_reason_t reason); - -/** -* Notify session transport has just connected and CSM exchange can now start. -* -* @param session The CoAP session. -*/ -void coap_session_send_csm(coap_session_t *session); - -/** -* Notify session that it has just connected or reconnected. -* -* @param session The CoAP session. -*/ -void coap_session_connected(coap_session_t *session); - -/** -* Set the session MTU. This is the maximum message size that can be sent, -* excluding IP and UDP overhead. -* -* @param session The CoAP session. -* @param mtu maximum message size -*/ -void coap_session_set_mtu(coap_session_t *session, unsigned mtu); - -/** - * Get maximum acceptable PDU size - * - * @param session The CoAP session. - * @return maximum PDU size, not including header (but including token). - */ -size_t coap_session_max_pdu_size(const coap_session_t *session); - -/** -* Creates a new client session to the designated server. -* @param ctx The CoAP context. -* @param local_if Address of local interface. It is recommended to use NULL to let the operating system choose a suitable local interface. If an address is specified, the port number should be zero, which means that a free port is automatically selected. -* @param server The server's address. If the port number is zero, the default port for the protocol will be used. -* @param proto Protocol. -* -* @return A new CoAP session or NULL if failed. Call coap_session_release to free. -*/ -coap_session_t *coap_new_client_session( - struct coap_context_t *ctx, - const coap_address_t *local_if, - const coap_address_t *server, - coap_proto_t proto -); - -/** -* Creates a new client session to the designated server with PSK credentials -* @param ctx The CoAP context. -* @param local_if Address of local interface. It is recommended to use NULL to let the operating system choose a suitable local interface. If an address is specified, the port number should be zero, which means that a free port is automatically selected. -* @param server The server's address. If the port number is zero, the default port for the protocol will be used. -* @param proto Protocol. -* @param identity PSK client identity -* @param key PSK shared key -* @param key_len PSK shared key length -* -* @return A new CoAP session or NULL if failed. Call coap_session_release to free. -*/ -coap_session_t *coap_new_client_session_psk( - struct coap_context_t *ctx, - const coap_address_t *local_if, - const coap_address_t *server, - coap_proto_t proto, - const char *identity, - const uint8_t *key, - unsigned key_len -); - -struct coap_dtls_pki_t; - -/** -* Creates a new client session to the designated server with PKI credentials -* @param ctx The CoAP context. -* @param local_if Address of local interface. It is recommended to use NULL to -* let the operating system choose a suitable local interface. -* If an address is specified, the port number should be zero, -* which means that a free port is automatically selected. -* @param server The server's address. If the port number is zero, the default -* port for the protocol will be used. -* @param proto CoAP Protocol. -* @param setup_data PKI parameters. -* -* @return A new CoAP session or NULL if failed. Call coap_session_release() -* to free. -*/ -coap_session_t *coap_new_client_session_pki( - struct coap_context_t *ctx, - const coap_address_t *local_if, - const coap_address_t *server, - coap_proto_t proto, - struct coap_dtls_pki_t *setup_data -); - -/** -* Creates a new server session for the specified endpoint. -* @param ctx The CoAP context. -* @param ep An endpoint where an incoming connection request is pending. -* -* @return A new CoAP session or NULL if failed. Call coap_session_release to free. -*/ -coap_session_t *coap_new_server_session( - struct coap_context_t *ctx, - struct coap_endpoint_t *ep -); - -/** -* Function interface for datagram data transmission. This function returns -* the number of bytes that have been transmitted, or a value less than zero -* on error. -* -* @param session Session to send data on. -* @param data The data to send. -* @param datalen The actual length of @p data. -* -* @return The number of bytes written on success, or a value -* less than zero on error. -*/ -ssize_t coap_session_send(coap_session_t *session, - const uint8_t *data, size_t datalen); - -/** -* Function interface for stream data transmission. This function returns -* the number of bytes that have been transmitted, or a value less than zero -* on error. The number of bytes written may be less than datalen because of -* congestion control. -* -* @param session Session to send data on. -* @param data The data to send. -* @param datalen The actual length of @p data. -* -* @return The number of bytes written on success, or a value -* less than zero on error. -*/ -ssize_t coap_session_write(coap_session_t *session, - const uint8_t *data, size_t datalen); - -/** -* Send a pdu according to the session's protocol. This function returns -* the number of bytes that have been transmitted, or a value less than zero -* on error. -* -* @param session Session to send pdu on. -* @param pdu The pdu to send. -* -* @return The number of bytes written on success, or a value -* less than zero on error. -*/ -ssize_t coap_session_send_pdu(coap_session_t *session, coap_pdu_t *pdu); - - -/** - * @ingroup logging - * Get session description. - * - * @param session The CoAP session. - * @return description string. - */ -const char *coap_session_str(const coap_session_t *session); - -ssize_t -coap_session_delay_pdu(coap_session_t *session, coap_pdu_t *pdu, - struct coap_queue_t *node); -/** -* Abstraction of virtual endpoint that can be attached to coap_context_t. The -* tuple (handle, addr) must uniquely identify this endpoint. -*/ -typedef struct coap_endpoint_t { - struct coap_endpoint_t *next; - struct coap_context_t *context; /**< endpoint's context */ - coap_proto_t proto; /**< protocol used on this interface */ - uint16_t default_mtu; /**< default mtu for this interface */ - coap_socket_t sock; /**< socket object for the interface, if any */ - coap_address_t bind_addr; /**< local interface address */ - coap_session_t *sessions; /**< list of active sessions */ -} coap_endpoint_t; - -/** -* Create a new endpoint for communicating with peers. -* -* @param context The coap context that will own the new endpoint -* @param listen_addr Address the endpoint will listen for incoming requests on or originate outgoing requests from. Use NULL to specify that no incoming request will be accepted and use a random endpoint. -* @param proto Protocol used on this endpoint -*/ - -coap_endpoint_t *coap_new_endpoint(struct coap_context_t *context, const coap_address_t *listen_addr, coap_proto_t proto); - -/** -* Set the endpoint's default MTU. This is the maximum message size that can be -* sent, excluding IP and UDP overhead. -* -* @param endpoint The CoAP endpoint. -* @param mtu maximum message size -*/ -void coap_endpoint_set_default_mtu(coap_endpoint_t *endpoint, unsigned mtu); - -void coap_free_endpoint(coap_endpoint_t *ep); - - -/** - * @ingroup logging -* Get endpoint description. -* -* @param endpoint The CoAP endpoint. -* @return description string. -*/ -const char *coap_endpoint_str(const coap_endpoint_t *endpoint); - -/** -* Lookup the server session for the packet received on an endpoint, or create -* a new one. -* -* @param endpoint Active endpoint the packet was received on. -* @param packet Received packet. -* @param now The current time in ticks. -* @return The CoAP session or @c NULL if error. -*/ -coap_session_t *coap_endpoint_get_session(coap_endpoint_t *endpoint, - const struct coap_packet_t *packet, coap_tick_t now); - -/** - * Create a new DTLS session for the @p session. - * Note: the @p session is released if no DTLS server session can be created. - * - * @ingroup dtls_internal - * - * @param session Session to add DTLS session to - * @param now The current time in ticks. - * - * @return CoAP session or @c NULL if error. - */ -coap_session_t *coap_session_new_dtls_session(coap_session_t *session, - coap_tick_t now); - -coap_session_t *coap_session_get_by_peer(struct coap_context_t *ctx, - const struct coap_address_t *remote_addr, int ifindex); - -void coap_session_free(coap_session_t *session); -void coap_session_mfree(coap_session_t *session); - - /** - * @defgroup cc Rate Control - * The transmission parameters for CoAP rate control ("Congestion - * Control" in stream-oriented protocols) are defined in - * https://tools.ietf.org/html/rfc7252#section-4.8 - * @{ - */ - - /** - * Number of seconds when to expect an ACK or a response to an - * outstanding CON message. - * RFC 7252, Section 4.8 Default value of ACK_TIMEOUT is 2 - */ -#define COAP_DEFAULT_ACK_TIMEOUT ((coap_fixed_point_t){2,0}) - - /** - * A factor that is used to randomize the wait time before a message - * is retransmitted to prevent synchronization effects. - * RFC 7252, Section 4.8 Default value of ACK_RANDOM_FACTOR is 1.5 - */ -#define COAP_DEFAULT_ACK_RANDOM_FACTOR ((coap_fixed_point_t){1,500}) - - /** - * Number of message retransmissions before message sending is stopped - * RFC 7252, Section 4.8 Default value of MAX_RETRANSMIT is 4 - */ -#define COAP_DEFAULT_MAX_RETRANSMIT 4 - - /** - * The number of simultaneous outstanding interactions that a client - * maintains to a given server. - * RFC 7252, Section 4.8 Default value of NSTART is 1 - */ -#define COAP_DEFAULT_NSTART 1 - - /** @} */ - -/** -* Set the CoAP maximum retransmit count before failure -* -* Number of message retransmissions before message sending is stopped -* -* @param session The CoAP session. -* @param value The value to set to. The default is 4 and should not normally -* get changed. -*/ -void coap_session_set_max_retransmit(coap_session_t *session, - unsigned int value); - -/** -* Set the CoAP initial ack response timeout before the next re-transmit -* -* Number of seconds when to expect an ACK or a response to an -* outstanding CON message. -* -* @param session The CoAP session. -* @param value The value to set to. The default is 2 and should not normally -* get changed. -*/ -void coap_session_set_ack_timeout(coap_session_t *session, - coap_fixed_point_t value); - -/** -* Set the CoAP ack randomize factor -* -* A factor that is used to randomize the wait time before a message -* is retransmitted to prevent synchronization effects. -* -* @param session The CoAP session. -* @param value The value to set to. The default is 1.5 and should not normally -* get changed. -*/ -void coap_session_set_ack_random_factor(coap_session_t *session, - coap_fixed_point_t value); - -/** -* Get the CoAP maximum retransmit before failure -* -* Number of message retransmissions before message sending is stopped -* -* @param session The CoAP session. -* -* @return Current maximum retransmit value -*/ -unsigned int coap_session_get_max_transmit(coap_session_t *session); - -/** -* Get the CoAP initial ack response timeout before the next re-transmit -* -* Number of seconds when to expect an ACK or a response to an -* outstanding CON message. -* -* @param session The CoAP session. -* -* @return Current ack response timeout value -*/ -coap_fixed_point_t coap_session_get_ack_timeout(coap_session_t *session); - -/** -* Get the CoAP ack randomize factor -* -* A factor that is used to randomize the wait time before a message -* is retransmitted to prevent synchronization effects. -* -* @param session The CoAP session. -* -* @return Current ack randomize value -*/ -coap_fixed_point_t coap_session_get_ack_random_factor(coap_session_t *session); - -/** - * Send a ping message for the session. - * @param session The CoAP session. - * - * @return COAP_INVALID_TID if there is an error - */ -coap_tid_t coap_session_send_ping(coap_session_t *session); - -#endif /* COAP_SESSION_H */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/net.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/net.h deleted file mode 100644 index 7fccf3326c7..00000000000 --- a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/net.h +++ /dev/null @@ -1,746 +0,0 @@ -/* - * net.h -- CoAP network interface - * - * Copyright (C) 2010-2015 Olaf Bergmann - * - * This file is part of the CoAP library libcoap. Please see README for terms - * of use. - */ - -#ifndef COAP_NET_H_ -#define COAP_NET_H_ - -#include -#include -#include -#ifndef _WIN32 -#include -#endif -#include - -#ifdef WITH_LWIP -#include -#endif - -#include "coap_io.h" -#include "coap_dtls.h" -#include "coap_event.h" -#include "coap_time.h" -#include "option.h" -#include "pdu.h" -#include "prng.h" -#include "coap_session.h" - -struct coap_queue_t; - -/** - * Queue entry - */ -typedef struct coap_queue_t { - struct coap_queue_t *next; - coap_tick_t t; /**< when to send PDU for the next time */ - unsigned char retransmit_cnt; /**< retransmission counter, will be removed - * when zero */ - unsigned int timeout; /**< the randomized timeout value */ - coap_session_t *session; /**< the CoAP session */ - coap_tid_t id; /**< CoAP transaction id */ - coap_pdu_t *pdu; /**< the CoAP PDU to send */ -} coap_queue_t; - -/** - * Adds @p node to given @p queue, ordered by variable t in @p node. - * - * @param queue Queue to add to. - * @param node Node entry to add to Queue. - * - * @return @c 1 added to queue, @c 0 failure. - */ -int coap_insert_node(coap_queue_t **queue, coap_queue_t *node); - -/** - * Destroys specified @p node. - * - * @param node Node entry to remove. - * - * @return @c 1 node deleted from queue, @c 0 failure. - */ -int coap_delete_node(coap_queue_t *node); - -/** - * Removes all items from given @p queue and frees the allocated storage. - * - * @param queue The queue to delete. - */ -void coap_delete_all(coap_queue_t *queue); - -/** - * Creates a new node suitable for adding to the CoAP sendqueue. - * - * @return New node entry, or @c NULL if failure. - */ -coap_queue_t *coap_new_node(void); - -struct coap_resource_t; -struct coap_context_t; -#ifndef WITHOUT_ASYNC -struct coap_async_state_t; -#endif - -/** - * Response handler that is used as call-back in coap_context_t. - * - * @param context CoAP session. - * @param session CoAP session. - * @param sent The PDU that was transmitted. - * @param received The PDU that was received. - * @param id CoAP transaction ID. - */ -typedef void (*coap_response_handler_t)(struct coap_context_t *context, - coap_session_t *session, - coap_pdu_t *sent, - coap_pdu_t *received, - const coap_tid_t id); - -/** - * Negative Acknowedge handler that is used as call-back in coap_context_t. - * - * @param context CoAP session. - * @param session CoAP session. - * @param sent The PDU that was transmitted. - * @param reason The reason for the NACK. - * @param id CoAP transaction ID. - */ -typedef void (*coap_nack_handler_t)(struct coap_context_t *context, - coap_session_t *session, - coap_pdu_t *sent, - coap_nack_reason_t reason, - const coap_tid_t id); - -/** - * Recieved Ping handler that is used as call-back in coap_context_t. - * - * @param context CoAP session. - * @param session CoAP session. - * @param received The PDU that was received. - * @param id CoAP transaction ID. - */ -typedef void (*coap_ping_handler_t)(struct coap_context_t *context, - coap_session_t *session, - coap_pdu_t *received, - const coap_tid_t id); - -/** - * Recieved Pong handler that is used as call-back in coap_context_t. - * - * @param context CoAP session. - * @param session CoAP session. - * @param received The PDU that was received. - * @param id CoAP transaction ID. - */ -typedef void (*coap_pong_handler_t)(struct coap_context_t *context, - coap_session_t *session, - coap_pdu_t *received, - const coap_tid_t id); - -/** - * The CoAP stack's global state is stored in a coap_context_t object. - */ -typedef struct coap_context_t { - coap_opt_filter_t known_options; - struct coap_resource_t *resources; /**< hash table or list of known - resources */ - struct coap_resource_t *unknown_resource; /**< can be used for handling - unknown resources */ - -#ifndef WITHOUT_ASYNC - /** - * list of asynchronous transactions */ - struct coap_async_state_t *async_state; -#endif /* WITHOUT_ASYNC */ - - /** - * The time stamp in the first element of the sendqeue is relative - * to sendqueue_basetime. */ - coap_tick_t sendqueue_basetime; - coap_queue_t *sendqueue; - coap_endpoint_t *endpoint; /**< the endpoints used for listening */ - coap_session_t *sessions; /**< client sessions */ - -#ifdef WITH_CONTIKI - struct uip_udp_conn *conn; /**< uIP connection object */ - struct etimer retransmit_timer; /**< fires when the next packet must be sent */ - struct etimer notify_timer; /**< used to check resources periodically */ -#endif /* WITH_CONTIKI */ - -#ifdef WITH_LWIP - uint8_t timer_configured; /**< Set to 1 when a retransmission is - * scheduled using lwIP timers for this - * context, otherwise 0. */ -#endif /* WITH_LWIP */ - - coap_response_handler_t response_handler; - coap_nack_handler_t nack_handler; - coap_ping_handler_t ping_handler; - coap_pong_handler_t pong_handler; - - /** - * Callback function that is used to signal events to the - * application. This field is set by coap_set_event_handler(). - */ - coap_event_handler_t handle_event; - - ssize_t (*network_send)(coap_socket_t *sock, const coap_session_t *session, const uint8_t *data, size_t datalen); - - ssize_t (*network_read)(coap_socket_t *sock, struct coap_packet_t *packet); - - size_t(*get_client_psk)(const coap_session_t *session, const uint8_t *hint, size_t hint_len, uint8_t *identity, size_t *identity_len, size_t max_identity_len, uint8_t *psk, size_t max_psk_len); - size_t(*get_server_psk)(const coap_session_t *session, const uint8_t *identity, size_t identity_len, uint8_t *psk, size_t max_psk_len); - size_t(*get_server_hint)(const coap_session_t *session, uint8_t *hint, size_t max_hint_len); - - void *dtls_context; - uint8_t *psk_hint; - size_t psk_hint_len; - uint8_t *psk_key; - size_t psk_key_len; - - unsigned int session_timeout; /**< Number of seconds of inactivity after which an unused session will be closed. 0 means use default. */ - unsigned int max_idle_sessions; /**< Maximum number of simultaneous unused sessions per endpoint. 0 means no maximum. */ - unsigned int max_handshake_sessions; /**< Maximum number of simultaneous negotating sessions per endpoint. 0 means use default. */ - unsigned int ping_timeout; /**< Minimum inactivity time before sending a ping message. 0 means disabled. */ - unsigned int csm_timeout; /**< Timeout for waiting for a CSM from the remote side. 0 means disabled. */ - - void *app; /**< application-specific data */ -} coap_context_t; - -/** - * Registers a new message handler that is called whenever a response was - * received that matches an ongoing transaction. - * - * @param context The context to register the handler for. - * @param handler The response handler to register. - */ -COAP_STATIC_INLINE void -coap_register_response_handler(coap_context_t *context, - coap_response_handler_t handler) { - context->response_handler = handler; -} - -/** - * Registers a new message handler that is called whenever a confirmable - * message (request or response) is dropped after all retries have been - * exhausted, or a rst message was received, or a network or TLS level - * event was received that indicates delivering the message is not possible. - * - * @param context The context to register the handler for. - * @param handler The nack handler to register. - */ -COAP_STATIC_INLINE void -coap_register_nack_handler(coap_context_t *context, - coap_nack_handler_t handler) { - context->nack_handler = handler; -} - -/** - * Registers a new message handler that is called whenever a CoAP Ping - * message is received. - * - * @param context The context to register the handler for. - * @param handler The ping handler to register. - */ -COAP_STATIC_INLINE void -coap_register_ping_handler(coap_context_t *context, - coap_ping_handler_t handler) { - context->ping_handler = handler; -} - -/** - * Registers a new message handler that is called whenever a CoAP Pong - * message is received. - * - * @param context The context to register the handler for. - * @param handler The pong handler to register. - */ -COAP_STATIC_INLINE void -coap_register_pong_handler(coap_context_t *context, - coap_pong_handler_t handler) { - context->pong_handler = handler; -} - -/** - * Registers the option type @p type with the given context object @p ctx. - * - * @param ctx The context to use. - * @param type The option type to register. - */ -COAP_STATIC_INLINE void -coap_register_option(coap_context_t *ctx, uint16_t type) { - coap_option_setb(ctx->known_options, type); -} - -/** - * Set sendqueue_basetime in the given context object @p ctx to @p now. This - * function returns the number of elements in the queue head that have timed - * out. - */ -unsigned int coap_adjust_basetime(coap_context_t *ctx, coap_tick_t now); - -/** - * Returns the next pdu to send without removing from sendqeue. - */ -coap_queue_t *coap_peek_next( coap_context_t *context ); - -/** - * Returns the next pdu to send and removes it from the sendqeue. - */ -coap_queue_t *coap_pop_next( coap_context_t *context ); - -/** - * Creates a new coap_context_t object that will hold the CoAP stack status. - */ -coap_context_t *coap_new_context(const coap_address_t *listen_addr); - -/** - * Set the context's default PSK hint and/or key for a server. - * - * @param context The current coap_context_t object. - * @param hint The default PSK server hint sent to a client. If @p NULL, PSK - * authentication is disabled. Empty string is a valid hint. - * @param key The default PSK key. If @p NULL, PSK authentication will fail. - * @param key_len The default PSK key's length. If @p 0, PSK authentication will - * fail. - * - * @return @c 1 if successful, else @c 0. - */ -int coap_context_set_psk( coap_context_t *context, const char *hint, - const uint8_t *key, size_t key_len ); - -/** - * Set the context's default PKI information for a server. - * - * @param context The current coap_context_t object. - * @param setup_data If @p NULL, PKI authentication will fail. Certificate - * information required. - * - * @return @c 1 if successful, else @c 0. - */ -int -coap_context_set_pki(coap_context_t *context, - coap_dtls_pki_t *setup_data); - -/** - * Set the context's default Root CA information for a client or server. - * - * @param context The current coap_context_t object. - * @param ca_file If not @p NULL, is the full path name of a PEM encoded - * file containing all the Root CAs to be used. - * @param ca_dir If not @p NULL, points to a directory containing PEM - * encoded files containing all the Root CAs to be used. - * - * @return @c 1 if successful, else @c 0. - */ -int -coap_context_set_pki_root_cas(coap_context_t *context, - const char *ca_file, - const char *ca_dir); - -/** - * Set the context keepalive timer for sessions. - * A keepalive message will be sent after if a session has been inactive, - * i.e. no packet sent or received, for the given number of seconds. - * For reliable protocols, a PING message will be sent. If a PONG has not - * been received before the next PING is due to be sent, the session will - * considered as disconnected. - * - * @param context The coap_context_t object. - * @param seconds Number of seconds for the inactivity timer, or zero - * to disable CoAP-level keepalive messages. - * - * @return 1 if successful, else 0 - */ -void coap_context_set_keepalive(coap_context_t *context, unsigned int seconds); - -/** - * Returns a new message id and updates @p session->tx_mid accordingly. The - * message id is returned in network byte order to make it easier to read in - * tracing tools. - * - * @param session The current coap_session_t object. - * - * @return Incremented message id in network byte order. - */ -COAP_STATIC_INLINE uint16_t -coap_new_message_id(coap_session_t *session) { - return ++session->tx_mid; -} - -/** - * CoAP stack context must be released with coap_free_context(). This function - * clears all entries from the receive queue and send queue and deletes the - * resources that have been registered with @p context, and frees the attached - * endpoints. - * - * @param context The current coap_context_t object to free off. - */ -void coap_free_context(coap_context_t *context); - -/** - * Stores @p data with the given CoAP context. This function - * overwrites any value that has previously been stored with @p - * context. - * - * @param context The CoAP context. - * @param data The data to store with wih the context. Note that this data - * must be valid during the lifetime of @p context. - */ -void coap_set_app_data(coap_context_t *context, void *data); - -/** - * Returns any application-specific data that has been stored with @p - * context using the function coap_set_app_data(). This function will - * return @c NULL if no data has been stored. - * - * @param context The CoAP context. - * - * @return The data previously stored or @c NULL if not data stored. - */ -void *coap_get_app_data(const coap_context_t *context); - -/** - * Creates a new ACK PDU with specified error @p code. The options specified by - * the filter expression @p opts will be copied from the original request - * contained in @p request. Unless @c SHORT_ERROR_RESPONSE was defined at build - * time, the textual reason phrase for @p code will be added as payload, with - * Content-Type @c 0. - * This function returns a pointer to the new response message, or @c NULL on - * error. The storage allocated for the new message must be relased with - * coap_free(). - * - * @param request Specification of the received (confirmable) request. - * @param code The error code to set. - * @param opts An option filter that specifies which options to copy from - * the original request in @p node. - * - * @return A pointer to the new message or @c NULL on error. - */ -coap_pdu_t *coap_new_error_response(coap_pdu_t *request, - unsigned char code, - coap_opt_filter_t opts); - -/** - * Sends an error response with code @p code for request @p request to @p dst. - * @p opts will be passed to coap_new_error_response() to copy marked options - * from the request. This function returns the transaction id if the message was - * sent, or @c COAP_INVALID_TID otherwise. - * - * @param session The CoAP session. - * @param request The original request to respond to. - * @param code The response code. - * @param opts A filter that specifies the options to copy from the - * @p request. - * - * @return The transaction id if the message was sent, or @c - * COAP_INVALID_TID otherwise. - */ -coap_tid_t coap_send_error(coap_session_t *session, - coap_pdu_t *request, - unsigned char code, - coap_opt_filter_t opts); - -/** - * Helper funktion to create and send a message with @p type (usually ACK or - * RST). This function returns @c COAP_INVALID_TID when the message was not - * sent, a valid transaction id otherwise. - * - * @param session The CoAP session. - * @param request The request that should be responded to. - * @param type Which type to set. - * @return transaction id on success or @c COAP_INVALID_TID - * otherwise. - */ -coap_tid_t -coap_send_message_type(coap_session_t *session, coap_pdu_t *request, unsigned char type); - -/** - * Sends an ACK message with code @c 0 for the specified @p request to @p dst. - * This function returns the corresponding transaction id if the message was - * sent or @c COAP_INVALID_TID on error. - * - * @param session The CoAP session. - * @param request The request to be acknowledged. - * - * @return The transaction id if ACK was sent or @c - * COAP_INVALID_TID on error. - */ -coap_tid_t coap_send_ack(coap_session_t *session, coap_pdu_t *request); - -/** - * Sends an RST message with code @c 0 for the specified @p request to @p dst. - * This function returns the corresponding transaction id if the message was - * sent or @c COAP_INVALID_TID on error. - * - * @param session The CoAP session. - * @param request The request to be reset. - * - * @return The transaction id if RST was sent or @c - * COAP_INVALID_TID on error. - */ -COAP_STATIC_INLINE coap_tid_t -coap_send_rst(coap_session_t *session, coap_pdu_t *request) { - return coap_send_message_type(session, request, COAP_MESSAGE_RST); -} - -/** -* Sends a CoAP message to given peer. The memory that is -* allocated by pdu will be released by coap_send(). -* The caller must not use the pdu after calling coap_send(). -* -* @param session The CoAP session. -* @param pdu The CoAP PDU to send. -* -* @return The message id of the sent message or @c -* COAP_INVALID_TID on error. -*/ -coap_tid_t coap_send( coap_session_t *session, coap_pdu_t *pdu ); - -/** - * Handles retransmissions of confirmable messages - * - * @param context The CoAP context. - * @param node The node to retransmit. - * - * @return The message id of the sent message or @c - * COAP_INVALID_TID on error. - */ -coap_tid_t coap_retransmit(coap_context_t *context, coap_queue_t *node); - -/** -* For applications with their own message loop, send all pending retransmits and -* return the list of sockets with events to wait for and the next timeout -* The application should call coap_read, then coap_write again when any condition below is true: -* - data is available on any of the sockets with the COAP_SOCKET_WANT_READ -* - an incoming connection is pending in the listen queue and the COAP_SOCKET_WANT_ACCEPT flag is set -* - at least some data can be written without blocking on any of the sockets with the COAP_SOCKET_WANT_WRITE flag set -* - a connection event occured (success or failure) and the COAP_SOCKET_WANT_CONNECT flag is set -* - the timeout has expired -* Before calling coap_read or coap_write again, the application should position COAP_SOCKET_CAN_READ and COAP_SOCKET_CAN_WRITE flags as applicable. -* -* @param ctx The CoAP context -* @param sockets array of socket descriptors, filled on output -* @param max_sockets size of socket array. -* @param num_sockets pointer to the number of valid entries in the socket arrays on output -* @param now Current time. -* -* @return timeout as maxmimum number of milliseconds that the application should wait for network events or 0 if the application should wait forever. -*/ - -unsigned int -coap_write(coap_context_t *ctx, - coap_socket_t *sockets[], - unsigned int max_sockets, - unsigned int *num_sockets, - coap_tick_t now -); - -/** - * For applications with their own message loop, reads all data from the network. - * - * @param ctx The CoAP context - * @param now Current time - */ -void coap_read(coap_context_t *ctx, coap_tick_t now); - -/** - * The main message processing loop. - * - * @param ctx The CoAP context - * @param timeout_ms Minimum number of milliseconds to wait for new messages before returning. If zero the call will block until at least one packet is sent or received. - * - * @return number of milliseconds spent or @c -1 if there was an error - */ - -int coap_run_once( coap_context_t *ctx, unsigned int timeout_ms ); - -/** - * Parses and interprets a CoAP datagram with context @p ctx. This function - * returns @c 0 if the datagram was handled, or a value less than zero on - * error. - * - * @param ctx The current CoAP context. - * @param session The current CoAP session. - * @param data The received packet'd data. - * @param data_len The received packet'd data length. - * - * @return @c 0 if message was handled successfully, or less than zero on - * error. - */ -int coap_handle_dgram(coap_context_t *ctx, coap_session_t *session, uint8_t *data, size_t data_len); - -/** - * Invokes the event handler of @p context for the given @p event and - * @p data. - * - * @param context The CoAP context whose event handler is to be called. - * @param event The event to deliver. - * @param session The session related to @p event. - * @return The result from the associated event handler or 0 if none was - * registered. - */ -int coap_handle_event(coap_context_t *context, - coap_event_t event, - coap_session_t *session); -/** - * This function removes the element with given @p id from the list given list. - * If @p id was found, @p node is updated to point to the removed element. Note - * that the storage allocated by @p node is @b not released. The caller must do - * this manually using coap_delete_node(). This function returns @c 1 if the - * element with id @p id was found, @c 0 otherwise. For a return value of @c 0, - * the contents of @p node is undefined. - * - * @param queue The queue to search for @p id. - * @param session The session to look for. - * @param id The transaction id to look for. - * @param node If found, @p node is updated to point to the removed node. You - * must release the storage pointed to by @p node manually. - * - * @return @c 1 if @p id was found, @c 0 otherwise. - */ -int coap_remove_from_queue(coap_queue_t **queue, - coap_session_t *session, - coap_tid_t id, - coap_queue_t **node); - -coap_tid_t -coap_wait_ack( coap_context_t *context, coap_session_t *session, - coap_queue_t *node); - -/** - * Retrieves transaction from the queue. - * - * @param queue The transaction queue to be searched. - * @param session The session to find. - * @param id The transaction id to find. - * - * @return A pointer to the transaction object or @c NULL if not found. - */ -coap_queue_t *coap_find_transaction(coap_queue_t *queue, coap_session_t *session, coap_tid_t id); - -/** - * Cancels all outstanding messages for session @p session that have the specified - * token. - * - * @param context The context in use. - * @param session Session of the messages to remove. - * @param token Message token. - * @param token_length Actual length of @p token. - */ -void coap_cancel_all_messages(coap_context_t *context, - coap_session_t *session, - const uint8_t *token, - size_t token_length); - -/** -* Cancels all outstanding messages for session @p session. -* -* @param context The context in use. -* @param session Session of the messages to remove. -* @param reason The reasion for the session cancellation -*/ -void -coap_cancel_session_messages(coap_context_t *context, - coap_session_t *session, - coap_nack_reason_t reason); - -/** - * Dispatches the PDUs from the receive queue in given context. - */ -void coap_dispatch(coap_context_t *context, coap_session_t *session, - coap_pdu_t *pdu); - -/** - * Returns 1 if there are no messages to send or to dispatch in the context's - * queues. */ -int coap_can_exit(coap_context_t *context); - -/** - * Returns the current value of an internal tick counter. The counter counts \c - * COAP_TICKS_PER_SECOND ticks every second. - */ -void coap_ticks(coap_tick_t *); - -/** - * Verifies that @p pdu contains no unknown critical options. Options must be - * registered at @p ctx, using the function coap_register_option(). A basic set - * of options is registered automatically by coap_new_context(). This function - * returns @c 1 if @p pdu is ok, @c 0 otherwise. The given filter object @p - * unknown will be updated with the unknown options. As only @c COAP_MAX_OPT - * options can be signalled this way, remaining options must be examined - * manually. - * - * @code - coap_opt_filter_t f = COAP_OPT_NONE; - coap_opt_iterator_t opt_iter; - - if (coap_option_check_critical(ctx, pdu, f) == 0) { - coap_option_iterator_init(pdu, &opt_iter, f); - - while (coap_option_next(&opt_iter)) { - if (opt_iter.type & 0x01) { - ... handle unknown critical option in opt_iter ... - } - } - } - @endcode - * - * @param ctx The context where all known options are registered. - * @param pdu The PDU to check. - * @param unknown The output filter that will be updated to indicate the - * unknown critical options found in @p pdu. - * - * @return @c 1 if everything was ok, @c 0 otherwise. - */ -int coap_option_check_critical(coap_context_t *ctx, - coap_pdu_t *pdu, - coap_opt_filter_t unknown); - -/** - * Creates a new response for given @p request with the contents of @c - * .well-known/core. The result is NULL on error or a newly allocated PDU that - * must be either sent with coap_sent() or released by coap_delete_pdu(). - * - * @param context The current coap context to use. - * @param session The CoAP session. - * @param request The request for @c .well-known/core . - * - * @return A new 2.05 response for @c .well-known/core or NULL on error. - */ -coap_pdu_t *coap_wellknown_response(coap_context_t *context, - coap_session_t *session, - coap_pdu_t *request); - -/** - * Calculates the initial timeout based on the session CoAP transmission - * parameters 'ack_timeout', 'ack_random_factor', and COAP_TICKS_PER_SECOND. - * The calculation requires 'ack_timeout' and 'ack_random_factor' to be in - * Qx.FRAC_BITS fixed point notation, whereas the passed parameter @p r - * is interpreted as the fractional part of a Q0.MAX_BITS random value. - * - * @param session session timeout is associated with - * @param r random value as fractional part of a Q0.MAX_BITS fixed point - * value - * @return COAP_TICKS_PER_SECOND * 'ack_timeout' * - * (1 + ('ack_random_factor' - 1) * r) - */ -unsigned int coap_calc_timeout(coap_session_t *session, unsigned char r); - -/** - * Function interface for joining a multicast group for listening - * - * @param ctx The current context - * @param groupname The name of the group that is to be joined for listening - * - * @return 0 on success, -1 on error - */ -int -coap_join_mcast_group(coap_context_t *ctx, const char *groupname); - -#endif /* COAP_NET_H_ */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/pdu.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/pdu.h deleted file mode 100644 index 206e2643543..00000000000 --- a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/pdu.h +++ /dev/null @@ -1,543 +0,0 @@ -/* - * pdu.h -- CoAP message structure - * - * Copyright (C) 2010-2014 Olaf Bergmann - * - * This file is part of the CoAP library libcoap. Please see README for terms - * of use. - */ - -/** - * @file pdu.h - * @brief Pre-defined constants that reflect defaults for CoAP - */ - -#ifndef COAP_PDU_H_ -#define COAP_PDU_H_ - -#include "uri.h" - -struct coap_session_t; - -#ifdef WITH_LWIP -#include -#endif - -#include - -#define COAP_DEFAULT_PORT 5683 /* CoAP default UDP/TCP port */ -#define COAPS_DEFAULT_PORT 5684 /* CoAP default UDP/TCP port for secure transmission */ -#define COAP_DEFAULT_MAX_AGE 60 /* default maximum object lifetime in seconds */ -#ifndef COAP_DEFAULT_MTU -#define COAP_DEFAULT_MTU 1152 -#endif /* COAP_DEFAULT_MTU */ - -/* TCP Message format constants, do not modify */ -#define COAP_MESSAGE_SIZE_OFFSET_TCP8 13 -#define COAP_MESSAGE_SIZE_OFFSET_TCP16 269 /* 13 + 256 */ -#define COAP_MESSAGE_SIZE_OFFSET_TCP32 65805 /* 269 + 65536 */ - -/* Derived message size limits */ -#define COAP_MAX_MESSAGE_SIZE_TCP0 (COAP_MESSAGE_SIZE_OFFSET_TCP8-1) /* 12 */ -#define COAP_MAX_MESSAGE_SIZE_TCP8 (COAP_MESSAGE_SIZE_OFFSET_TCP16-1) /* 268 */ -#define COAP_MAX_MESSAGE_SIZE_TCP16 (COAP_MESSAGE_SIZE_OFFSET_TCP32-1) /* 65804 */ -#define COAP_MAX_MESSAGE_SIZE_TCP32 (COAP_MESSAGE_SIZE_OFFSET_TCP32+0xFFFFFFFF) - -#ifndef COAP_DEFAULT_MAX_PDU_RX_SIZE -#if defined(WITH_CONTIKI) || defined(WITH_LWIP) -#define COAP_DEFAULT_MAX_PDU_RX_SIZE (COAP_MAX_MESSAGE_SIZE_TCP16+4) -#else -/* 8 MiB max-message-size plus some space for options */ -#define COAP_DEFAULT_MAX_PDU_RX_SIZE (8*1024*1024+256) -#endif -#endif /* COAP_DEFAULT_MAX_PDU_RX_SIZE */ - -#ifndef COAP_DEBUG_BUF_SIZE -#if defined(WITH_CONTIKI) || defined(WITH_LWIP) -#define COAP_DEBUG_BUF_SIZE 128 -#else /* defined(WITH_CONTIKI) || defined(WITH_LWIP) */ -/* 1024 derived from RFC7252 4.6. Message Size max payload */ -#define COAP_DEBUG_BUF_SIZE (8 + 1024 * 2) -#endif /* defined(WITH_CONTIKI) || defined(WITH_LWIP) */ -#endif /* COAP_DEBUG_BUF_SIZE */ - -#define COAP_DEFAULT_VERSION 1 /* version of CoAP supported */ -#define COAP_DEFAULT_SCHEME "coap" /* the default scheme for CoAP URIs */ - -/** well-known resources URI */ -#define COAP_DEFAULT_URI_WELLKNOWN ".well-known/core" - -/* CoAP message types */ - -#define COAP_MESSAGE_CON 0 /* confirmable message (requires ACK/RST) */ -#define COAP_MESSAGE_NON 1 /* non-confirmable message (one-shot message) */ -#define COAP_MESSAGE_ACK 2 /* used to acknowledge confirmable messages */ -#define COAP_MESSAGE_RST 3 /* indicates error in received messages */ - -/* CoAP request methods */ - -#define COAP_REQUEST_GET 1 -#define COAP_REQUEST_POST 2 -#define COAP_REQUEST_PUT 3 -#define COAP_REQUEST_DELETE 4 -#define COAP_REQUEST_FETCH 5 /* RFC 8132 */ -#define COAP_REQUEST_PATCH 6 /* RFC 8132 */ -#define COAP_REQUEST_IPATCH 7 /* RFC 8132 */ - -/* - * CoAP option types (be sure to update coap_option_check_critical() when - * adding options - */ - -#define COAP_OPTION_IF_MATCH 1 /* C, opaque, 0-8 B, (none) */ -#define COAP_OPTION_URI_HOST 3 /* C, String, 1-255 B, destination address */ -#define COAP_OPTION_ETAG 4 /* E, opaque, 1-8 B, (none) */ -#define COAP_OPTION_IF_NONE_MATCH 5 /* empty, 0 B, (none) */ -#define COAP_OPTION_URI_PORT 7 /* C, uint, 0-2 B, destination port */ -#define COAP_OPTION_LOCATION_PATH 8 /* E, String, 0-255 B, - */ -#define COAP_OPTION_URI_PATH 11 /* C, String, 0-255 B, (none) */ -#define COAP_OPTION_CONTENT_FORMAT 12 /* E, uint, 0-2 B, (none) */ -#define COAP_OPTION_CONTENT_TYPE COAP_OPTION_CONTENT_FORMAT -#define COAP_OPTION_MAXAGE 14 /* E, uint, 0--4 B, 60 Seconds */ -#define COAP_OPTION_URI_QUERY 15 /* C, String, 1-255 B, (none) */ -#define COAP_OPTION_ACCEPT 17 /* C, uint, 0-2 B, (none) */ -#define COAP_OPTION_LOCATION_QUERY 20 /* E, String, 0-255 B, (none) */ -#define COAP_OPTION_SIZE2 28 /* E, uint, 0-4 B, (none) */ -#define COAP_OPTION_PROXY_URI 35 /* C, String, 1-1034 B, (none) */ -#define COAP_OPTION_PROXY_SCHEME 39 /* C, String, 1-255 B, (none) */ -#define COAP_OPTION_SIZE1 60 /* E, uint, 0-4 B, (none) */ - -/* option types from RFC 7641 */ - -#define COAP_OPTION_OBSERVE 6 /* E, empty/uint, 0 B/0-3 B, (none) */ -#define COAP_OPTION_SUBSCRIPTION COAP_OPTION_OBSERVE - -/* selected option types from RFC 7959 */ - -#define COAP_OPTION_BLOCK2 23 /* C, uint, 0--3 B, (none) */ -#define COAP_OPTION_BLOCK1 27 /* C, uint, 0--3 B, (none) */ - -/* selected option types from RFC 7967 */ - -#define COAP_OPTION_NORESPONSE 258 /* N, uint, 0--1 B, 0 */ - -#define COAP_MAX_OPT 65535 /**< the highest option number we know */ - -/* CoAP result codes (HTTP-Code / 100 * 40 + HTTP-Code % 100) */ - -/* As of draft-ietf-core-coap-04, response codes are encoded to base - * 32, i.e. the three upper bits determine the response class while - * the remaining five fine-grained information specific to that class. - */ -#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100) - -/* Determines the class of response code C */ -#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF) - -#ifndef SHORT_ERROR_RESPONSE -/** - * Returns a human-readable response phrase for the specified CoAP response @p - * code. This function returns @c NULL if not found. - * - * @param code The response code for which the literal phrase should be - * retrieved. - * - * @return A zero-terminated string describing the error, or @c NULL if not - * found. - */ -const char *coap_response_phrase(unsigned char code); - -#define COAP_ERROR_PHRASE_LENGTH 32 /**< maximum length of error phrase */ - -#else -#define coap_response_phrase(x) ((char *)NULL) - -#define COAP_ERROR_PHRASE_LENGTH 0 /**< maximum length of error phrase */ -#endif /* SHORT_ERROR_RESPONSE */ - -/* The following definitions exist for backwards compatibility */ -#if 0 /* this does not exist any more */ -#define COAP_RESPONSE_100 40 /* 100 Continue */ -#endif -#define COAP_RESPONSE_200 COAP_RESPONSE_CODE(200) /* 2.00 OK */ -#define COAP_RESPONSE_201 COAP_RESPONSE_CODE(201) /* 2.01 Created */ -#define COAP_RESPONSE_304 COAP_RESPONSE_CODE(203) /* 2.03 Valid */ -#define COAP_RESPONSE_400 COAP_RESPONSE_CODE(400) /* 4.00 Bad Request */ -#define COAP_RESPONSE_404 COAP_RESPONSE_CODE(404) /* 4.04 Not Found */ -#define COAP_RESPONSE_405 COAP_RESPONSE_CODE(405) /* 4.05 Method Not Allowed */ -#define COAP_RESPONSE_415 COAP_RESPONSE_CODE(415) /* 4.15 Unsupported Media Type */ -#define COAP_RESPONSE_500 COAP_RESPONSE_CODE(500) /* 5.00 Internal Server Error */ -#define COAP_RESPONSE_501 COAP_RESPONSE_CODE(501) /* 5.01 Not Implemented */ -#define COAP_RESPONSE_503 COAP_RESPONSE_CODE(503) /* 5.03 Service Unavailable */ -#define COAP_RESPONSE_504 COAP_RESPONSE_CODE(504) /* 5.04 Gateway Timeout */ -#if 0 /* these response codes do not have a valid code any more */ -# define COAP_RESPONSE_X_240 240 /* Token Option required by server */ -# define COAP_RESPONSE_X_241 241 /* Uri-Authority Option required by server */ -#endif -#define COAP_RESPONSE_X_242 COAP_RESPONSE_CODE(402) /* Critical Option not supported */ - -#define COAP_SIGNALING_CODE(N) (((N)/100 << 5) | (N)%100) -#define COAP_SIGNALING_CSM COAP_SIGNALING_CODE(701) -#define COAP_SIGNALING_PING COAP_SIGNALING_CODE(702) -#define COAP_SIGNALING_PONG COAP_SIGNALING_CODE(703) -#define COAP_SIGNALING_RELEASE COAP_SIGNALING_CODE(704) -#define COAP_SIGNALING_ABORT COAP_SIGNALING_CODE(705) - -/* Applies to COAP_SIGNALING_CSM */ -#define COAP_SIGNALING_OPTION_MAX_MESSAGE_SIZE 2 -#define COAP_SIGNALING_OPTION_BLOCK_WISE_TRANSFER 4 -/* Applies to COAP_SIGNALING_PING / COAP_SIGNALING_PONG */ -#define COAP_SIGNALING_OPTION_CUSTODY 2 -/* Applies to COAP_SIGNALING_RELEASE */ -#define COAP_SIGNALING_OPTION_ALTERNATIVE_ADDRESS 2 -#define COAP_SIGNALING_OPTION_HOLD_OFF 4 -/* Applies to COAP_SIGNALING_ABORT */ -#define COAP_SIGNALING_OPTION_BAD_CSM_OPTION 2 - -/* CoAP media type encoding */ - -#define COAP_MEDIATYPE_TEXT_PLAIN 0 /* text/plain (UTF-8) */ -#define COAP_MEDIATYPE_APPLICATION_LINK_FORMAT 40 /* application/link-format */ -#define COAP_MEDIATYPE_APPLICATION_XML 41 /* application/xml */ -#define COAP_MEDIATYPE_APPLICATION_OCTET_STREAM 42 /* application/octet-stream */ -#define COAP_MEDIATYPE_APPLICATION_RDF_XML 43 /* application/rdf+xml */ -#define COAP_MEDIATYPE_APPLICATION_EXI 47 /* application/exi */ -#define COAP_MEDIATYPE_APPLICATION_JSON 50 /* application/json */ -#define COAP_MEDIATYPE_APPLICATION_CBOR 60 /* application/cbor */ - -/* Content formats from RFC 8152 */ -#define COAP_MEDIATYPE_APPLICATION_COSE_SIGN 98 /* application/cose; cose-type="cose-sign" */ -#define COAP_MEDIATYPE_APPLICATION_COSE_SIGN1 18 /* application/cose; cose-type="cose-sign1" */ -#define COAP_MEDIATYPE_APPLICATION_COSE_ENCRYPT 96 /* application/cose; cose-type="cose-encrypt" */ -#define COAP_MEDIATYPE_APPLICATION_COSE_ENCRYPT0 16 /* application/cose; cose-type="cose-encrypt0" */ -#define COAP_MEDIATYPE_APPLICATION_COSE_MAC 97 /* application/cose; cose-type="cose-mac" */ -#define COAP_MEDIATYPE_APPLICATION_COSE_MAC0 17 /* application/cose; cose-type="cose-mac0" */ - -#define COAP_MEDIATYPE_APPLICATION_COSE_KEY 101 /* application/cose-key */ -#define COAP_MEDIATYPE_APPLICATION_COSE_KEY_SET 102 /* application/cose-key-set */ - -/* Content formats from RFC 8428 */ -#define COAP_MEDIATYPE_APPLICATION_SENML_JSON 110 /* application/senml+json */ -#define COAP_MEDIATYPE_APPLICATION_SENSML_JSON 111 /* application/sensml+json */ -#define COAP_MEDIATYPE_APPLICATION_SENML_CBOR 112 /* application/senml+cbor */ -#define COAP_MEDIATYPE_APPLICATION_SENSML_CBOR 113 /* application/sensml+cbor */ -#define COAP_MEDIATYPE_APPLICATION_SENML_EXI 114 /* application/senml-exi */ -#define COAP_MEDIATYPE_APPLICATION_SENSML_EXI 115 /* application/sensml-exi */ -#define COAP_MEDIATYPE_APPLICATION_SENML_XML 310 /* application/senml+xml */ -#define COAP_MEDIATYPE_APPLICATION_SENSML_XML 311 /* application/sensml+xml */ - -/* Note that identifiers for registered media types are in the range 0-65535. We - * use an unallocated type here and hope for the best. */ -#define COAP_MEDIATYPE_ANY 0xff /* any media type */ - -/** - * coap_tid_t is used to store CoAP transaction id, i.e. a hash value - * built from the remote transport address and the message id of a - * CoAP PDU. Valid transaction ids are greater or equal zero. - */ -typedef int coap_tid_t; - -/** Indicates an invalid transaction id. */ -#define COAP_INVALID_TID -1 - -/** - * Indicates that a response is suppressed. This will occur for error - * responses if the request was received via IP multicast. - */ -#define COAP_DROPPED_RESPONSE -2 - -#define COAP_PDU_DELAYED -3 - -#define COAP_OPT_LONG 0x0F /* OC == 0b1111 indicates that the option list - * in a CoAP message is limited by 0b11110000 - * marker */ - -#define COAP_OPT_END 0xF0 /* end marker */ - -#define COAP_PAYLOAD_START 0xFF /* payload marker */ - -/** - * @deprecated Use coap_optlist_t instead. - * - * Structures for more convenient handling of options. (To be used with ordered - * coap_list_t.) The option's data will be added to the end of the coap_option - * structure (see macro COAP_OPTION_DATA). - */ -COAP_DEPRECATED typedef struct { - uint16_t key; /* the option key (no delta coding) */ - unsigned int length; -} coap_option; - -#define COAP_OPTION_KEY(option) (option).key -#define COAP_OPTION_LENGTH(option) (option).length -#define COAP_OPTION_DATA(option) ((unsigned char *)&(option) + sizeof(coap_option)) - -/** - * structure for CoAP PDUs - * token, if any, follows the fixed size header, then options until - * payload marker (0xff), then the payload if stored inline. - * Memory layout is: - * <---header--->|<---token---><---options--->0xff<---payload---> - * header is addressed with a negative offset to token, its maximum size is - * max_hdr_size. - * options starts at token + token_length - * payload starts at data, its length is used_size - (data - token) - */ - -typedef struct coap_pdu_t { - uint8_t type; /**< message type */ - uint8_t code; /**< request method (value 1--10) or response code (value 40-255) */ - uint8_t max_hdr_size; /**< space reserved for protocol-specific header */ - uint8_t hdr_size; /**< actaul size used for protocol-specific header */ - uint8_t token_length; /**< length of Token */ - uint16_t tid; /**< transaction id, if any, in regular host byte order */ - uint16_t max_delta; /**< highest option number */ - size_t alloc_size; /**< allocated storage for token, options and payload */ - size_t used_size; /**< used bytes of storage for token, options and payload */ - size_t max_size; /**< maximum size for token, options and payload, or zero for variable size pdu */ - uint8_t *token; /**< first byte of token, if any, or options */ - uint8_t *data; /**< first byte of payload, if any */ -#ifdef WITH_LWIP - struct pbuf *pbuf; /**< lwIP PBUF. The package data will always reside - * inside the pbuf's payload, but this pointer - * has to be kept because no exact offset can be - * given. This field must not be accessed from - * outside, because the pbuf's reference count - * is checked to be 1 when the pbuf is assigned - * to the pdu, and the pbuf stays exclusive to - * this pdu. */ -#endif -} coap_pdu_t; - -#define COAP_PDU_IS_EMPTY(pdu) ((pdu)->code == 0) -#define COAP_PDU_IS_REQUEST(pdu) (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32) -#define COAP_PDU_IS_RESPONSE(pdu) ((pdu)->code >= 64 && (pdu)->code < 224) -#define COAP_PDU_IS_SIGNALING(pdu) ((pdu)->code >= 224) - -#define COAP_PDU_MAX_UDP_HEADER_SIZE 4 -#define COAP_PDU_MAX_TCP_HEADER_SIZE 6 - -#ifdef WITH_LWIP -/** - * Creates a CoAP PDU from an lwIP @p pbuf, whose reference is passed on to this - * function. - * - * The pbuf is checked for being contiguous, and for having only one reference. - * The reference is stored in the PDU and will be freed when the PDU is freed. - * - * (For now, these are fatal errors; in future, a new pbuf might be allocated, - * the data copied and the passed pbuf freed). - * - * This behaves like coap_pdu_init(0, 0, 0, pbuf->tot_len), and afterwards - * copying the contents of the pbuf to the pdu. - * - * @return A pointer to the new PDU object or @c NULL on error. - */ -coap_pdu_t * coap_pdu_from_pbuf(struct pbuf *pbuf); -#endif - -typedef uint8_t coap_proto_t; -/** -* coap_proto_t values -*/ -#define COAP_PROTO_NONE 0 -#define COAP_PROTO_UDP 1 -#define COAP_PROTO_DTLS 2 -#define COAP_PROTO_TCP 3 -#define COAP_PROTO_TLS 4 - -/** - * Creates a new CoAP PDU with at least enough storage space for the given - * @p size maximum message size. The function returns a pointer to the - * node coap_pdu_t object on success, or @c NULL on error. The storage allocated - * for the result must be released with coap_delete_pdu() if coap_send() is not - * called. - * - * @param type The type of the PDU (one of COAP_MESSAGE_CON, COAP_MESSAGE_NON, - * COAP_MESSAGE_ACK, COAP_MESSAGE_RST). - * @param code The message code. - * @param tid The transcation id to set or 0 if unknown / not applicable. - * @param size The maximum allowed number of byte for the message. - * @return A pointer to the new PDU object or @c NULL on error. - */ -coap_pdu_t * -coap_pdu_init(uint8_t type, uint8_t code, uint16_t tid, size_t size); - -/** - * Dynamically grows the size of @p pdu to @p new_size. The new size - * must not exceed the PDU's configure maximum size. On success, this - * function returns 1, otherwise 0. - * - * @param pdu The PDU to resize. - * @param new_size The new size in bytes. - * @return 1 if the operation succeeded, 0 otherwise. - */ -int coap_pdu_resize(coap_pdu_t *pdu, size_t new_size); - -/** - * Clears any contents from @p pdu and resets @c used_size, - * and @c data pointers. @c max_size is set to @p size, any - * other field is set to @c 0. Note that @p pdu must be a valid - * pointer to a coap_pdu_t object created e.g. by coap_pdu_init(). - */ -void coap_pdu_clear(coap_pdu_t *pdu, size_t size); - -/** - * Creates a new CoAP PDU. - */ -coap_pdu_t *coap_new_pdu(const struct coap_session_t *session); - -/** - * Dispose of an CoAP PDU and frees associated storage. - * Not that in general you should not call this function directly. - * When a PDU is sent with coap_send(), coap_delete_pdu() will be - * called automatically for you. - */ - -void coap_delete_pdu(coap_pdu_t *); - -/** -* Interprets @p data to determine the number of bytes in the header. -* This function returns @c 0 on error or a number greater than zero on success. -* -* @param proto Session's protocol -* @param data The first byte of raw data to parse as CoAP PDU. -* -* @return A value greater than zero on success or @c 0 on error. -*/ -size_t coap_pdu_parse_header_size(coap_proto_t proto, - const uint8_t *data); - -/** - * Parses @p data to extract the message size. - * @p length must be at least coap_pdu_parse_header_size(proto, data). - * This function returns @c 0 on error or a number greater than zero on success. - * - * @param proto Session's protocol - * @param data The raw data to parse as CoAP PDU. - * @param length The actual size of @p data. - * - * @return A value greater than zero on success or @c 0 on error. - */ -size_t coap_pdu_parse_size(coap_proto_t proto, - const uint8_t *data, - size_t length); - -/** - * Decode the protocol specific header for the specified PDU. - * @param pdu A newly received PDU. - * @param proto The target wire protocol. - * @return 1 for success or 0 on error. - */ - -int coap_pdu_parse_header(coap_pdu_t *pdu, coap_proto_t proto); - -/** - * Verify consistency in the given CoAP PDU structure and locate the data. - * This function returns @c 0 on error or a number greater than zero on - * success. - * This function only parses the token and options, up to the payload start - * marker. - * - * @param pdu The PDU structure to. - * - * @return 1 on success or @c 0 on error. - */ -int coap_pdu_parse_opt(coap_pdu_t *pdu); - -/** -* Parses @p data into the CoAP PDU structure given in @p result. -* The target pdu must be large enough to -* This function returns @c 0 on error or a number greater than zero on success. -* -* @param proto Session's protocol -* @param data The raw data to parse as CoAP PDU. -* @param length The actual size of @p data. -* @param pdu The PDU structure to fill. Note that the structure must -* provide space to hold at least the token and options -* part of the message. -* -* @return 1 on success or @c 0 on error. -*/ -int coap_pdu_parse(coap_proto_t proto, - const uint8_t *data, - size_t length, - coap_pdu_t *pdu); -/** - * Adds token of length @p len to @p pdu. - * Adding the token destroys any following contents of the pdu. Hence options - * and data must be added after coap_add_token() has been called. In @p pdu, - * length is set to @p len + @c 4, and max_delta is set to @c 0. This function - * returns @c 0 on error or a value greater than zero on success. - * - * @param pdu The PDU where the token is to be added. - * @param len The length of the new token. - * @param data The token to add. - * - * @return A value greater than zero on success, or @c 0 on error. - */ -int coap_add_token(coap_pdu_t *pdu, - size_t len, - const uint8_t *data); - -/** - * Adds option of given type to pdu that is passed as first - * parameter. - * coap_add_option() destroys the PDU's data, so coap_add_data() must be called - * after all options have been added. As coap_add_token() destroys the options - * following the token, the token must be added before coap_add_option() is - * called. This function returns the number of bytes written or @c 0 on error. - */ -size_t coap_add_option(coap_pdu_t *pdu, - uint16_t type, - size_t len, - const uint8_t *data); - -/** - * Adds option of given type to pdu that is passed as first parameter, but does - * not write a value. It works like coap_add_option with respect to calling - * sequence (i.e. after token and before data). This function returns a memory - * address to which the option data has to be written before the PDU can be - * sent, or @c NULL on error. - */ -uint8_t *coap_add_option_later(coap_pdu_t *pdu, - uint16_t type, - size_t len); - -/** - * Adds given data to the pdu that is passed as first parameter. Note that the - * PDU's data is destroyed by coap_add_option(). coap_add_data() must be called - * only once per PDU, otherwise the result is undefined. - */ -int coap_add_data(coap_pdu_t *pdu, - size_t len, - const uint8_t *data); - -/** - * Adds given data to the pdu that is passed as first parameter but does not - * copyt it. Note that the PDU's data is destroyed by coap_add_option(). - * coap_add_data() must be have been called once for this PDU, otherwise the - * result is undefined. - * The actual data must be copied at the returned location. - */ -uint8_t *coap_add_data_after(coap_pdu_t *pdu, size_t len); - -/** - * Retrieves the length and data pointer of specified PDU. Returns 0 on error or - * 1 if *len and *data have correct values. Note that these values are destroyed - * with the pdu. - */ -int coap_get_data(const coap_pdu_t *pdu, - size_t *len, - uint8_t **data); - -/** - * Compose the protocol specific header for the specified PDU. - * @param pdu A newly composed PDU. - * @param proto The target wire protocol. - * @return Number of header bytes prepended before pdu->token or 0 on error. - */ - -size_t coap_pdu_encode_header(coap_pdu_t *pdu, coap_proto_t proto); - -#endif /* COAP_PDU_H_ */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/prng.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/prng.h deleted file mode 100644 index c9510bf5602..00000000000 --- a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/prng.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * prng.h -- Pseudo Random Numbers - * - * Copyright (C) 2010-2011 Olaf Bergmann - * - * This file is part of the CoAP library libcoap. Please see README for terms - * of use. - */ - -/** - * @file prng.h - * @brief Pseudo Random Numbers - */ - -#ifndef COAP_PRNG_H_ -#define COAP_PRNG_H_ - -/** - * @defgroup prng Pseudo Random Numbers - * API functions for gerating pseudo random numbers - * @{ - */ - -#if defined(WITH_CONTIKI) -#include - -/** - * Fills \p buf with \p len random bytes. This is the default implementation for - * prng(). You might want to change prng() to use a better PRNG on your specific - * platform. - */ -COAP_STATIC_INLINE int -contiki_prng_impl(unsigned char *buf, size_t len) { - uint16_t v = random_rand(); - while (len > sizeof(v)) { - memcpy(buf, &v, sizeof(v)); - len -= sizeof(v); - buf += sizeof(v); - v = random_rand(); - } - - memcpy(buf, &v, len); - return 1; -} - -#define prng(Buf,Length) contiki_prng_impl((Buf), (Length)) -#define prng_init(Value) random_init((uint16_t)(Value)) -#elif defined(WITH_LWIP) && defined(LWIP_RAND) -COAP_STATIC_INLINE int -lwip_prng_impl(unsigned char *buf, size_t len) { - u32_t v = LWIP_RAND(); - while (len > sizeof(v)) { - memcpy(buf, &v, sizeof(v)); - len -= sizeof(v); - buf += sizeof(v); - v = LWIP_RAND(); - } - - memcpy(buf, &v, len); - return 1; -} - -#define prng(Buf,Length) lwip_prng_impl((Buf), (Length)) -#define prng_init(Value) -#elif defined(_WIN32) -#define prng_init(Value) -errno_t __cdecl rand_s( _Out_ unsigned int* _RandomValue ); - /** - * Fills \p buf with \p len random bytes. This is the default implementation for - * prng(). You might want to change prng() to use a better PRNG on your specific - * platform. - */ -COAP_STATIC_INLINE int -coap_prng_impl( unsigned char *buf, size_t len ) { - while ( len != 0 ) { - uint32_t r = 0; - size_t i; - if ( rand_s( &r ) != 0 ) - return 0; - for ( i = 0; i < len && i < 4; i++ ) { - *buf++ = (uint8_t)r; - r >>= 8; - } - len -= i; - } - return 1; -} - -#else -#include - - /** - * Fills \p buf with \p len random bytes. This is the default implementation for - * prng(). You might want to change prng() to use a better PRNG on your specific - * platform. - */ -COAP_STATIC_INLINE int -coap_prng_impl( unsigned char *buf, size_t len ) { - while ( len-- ) - *buf++ = rand() & 0xFF; - return 1; -} -#endif - - -#ifndef prng -/** - * Fills \p Buf with \p Length bytes of random data. - * - * @hideinitializer - */ -#define prng(Buf,Length) coap_prng_impl((Buf), (Length)) -#endif - -#ifndef prng_init -/** - * Called to set the PRNG seed. You may want to re-define this to allow for a - * better PRNG. - * - * @hideinitializer - */ -#define prng_init(Value) srand((unsigned long)(Value)) -#endif - -/** @} */ - -#endif /* COAP_PRNG_H_ */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/str.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/str.h deleted file mode 100644 index 6c1488c982d..00000000000 --- a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/str.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - * str.h -- strings to be used in the CoAP library - * - * Copyright (C) 2010-2011 Olaf Bergmann - * - * This file is part of the CoAP library libcoap. Please see README for terms - * of use. - */ - -#ifndef COAP_STR_H_ -#define COAP_STR_H_ - -#include - - -/** - * @defgroup string String handling support - * API functions for handling strings - * @{ - */ - -/** - * Coap string data definition - */ -typedef struct coap_string_t { - size_t length; /**< length of string */ - uint8_t *s; /**< string data */ -} coap_string_t; - -/** - * Coap string data definition with const data - */ -typedef struct coap_str_const_t { - size_t length; /**< length of string */ - const uint8_t *s; /**< string data */ -} coap_str_const_t; - -#define COAP_SET_STR(st,l,v) { (st)->length = (l), (st)->s = (v); } - -/** - * Coap binary data definition - */ -typedef struct coap_binary_t { - size_t length; /**< length of binary data */ - uint8_t *s; /**< binary data */ -} coap_binary_t; - -/** - * Returns a new string object with at least size+1 bytes storage allocated. - * The string must be released using coap_delete_string(). - * - * @param size The size to allocate for the binary string data. - * - * @return A pointer to the new object or @c NULL on error. - */ -coap_string_t *coap_new_string(size_t size); - -/** - * Deletes the given string and releases any memory allocated. - * - * @param string The string to free off. - */ -void coap_delete_string(coap_string_t *string); - -/** - * Returns a new const string object with at least size+1 bytes storage - * allocated, and the provided data copied into the string object. - * The string must be released using coap_delete_str_const(). - * - * @param data The data to put in the new string object. - * @param size The size to allocate for the binary string data. - * - * @return A pointer to the new object or @c NULL on error. - */ -coap_str_const_t *coap_new_str_const(const uint8_t *data, size_t size); - -/** - * Deletes the given const string and releases any memory allocated. - * - * @param string The string to free off. - */ -void coap_delete_str_const(coap_str_const_t *string); - -/** - * Take the specified byte array (text) and create a coap_str_const_t * - * - * WARNING: The byte array must be in the local scope and not a - * parameter in the function call as sizeof() will return the size of the - * pointer, not the size of the byte array, leading to unxepected results. - * - * @param string The const byte array to convert to a coap_str_const_t * - */ -#ifdef __cplusplus -namespace libcoap { - struct CoAPStrConst : coap_str_const_t { - operator coap_str_const_t *() { return this; } - }; -} -#define coap_make_str_const(CStr) \ - libcoap::CoAPStrConst{sizeof(CStr)-1, reinterpret_cast(CStr)} -#else /* __cplusplus */ -#define coap_make_str_const(string) \ - (&(coap_str_const_t){sizeof(string)-1,(const uint8_t *)(string)}) -#endif /* __cplusplus */ - -/** - * Compares the two strings for equality - * - * @param string1 The first string. - * @param string2 The second string. - * - * @return @c 1 if the strings are equal - * @c 0 otherwise. - */ -#define coap_string_equal(string1,string2) \ - ((string1)->length == (string2)->length && ((string1)->length == 0 || \ - memcmp((string1)->s, (string2)->s, (string1)->length) == 0)) - -/** @} */ - -#endif /* COAP_STR_H_ */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/subscribe.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/subscribe.h deleted file mode 100644 index ed635a6182a..00000000000 --- a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/subscribe.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * subscribe.h -- subscription handling for CoAP - * see RFC7641 - * - * Copyright (C) 2010-2012,2014-2015 Olaf Bergmann - * - * This file is part of the CoAP library libcoap. Please see README for terms - * of use. - */ - - -#ifndef COAP_SUBSCRIBE_H_ -#define COAP_SUBSCRIBE_H_ - -#include "address.h" -#include "coap_io.h" -#include "block.h" - -/** - * @defgroup observe Resource observation - * API functions for interfacing with the observe handling (RFC7641) - * @{ - */ - -/** - * The value COAP_OBSERVE_ESTABLISH in a GET request indicates a new observe - * relationship for (sender address, token) is requested. - */ -#define COAP_OBSERVE_ESTABLISH 0 - -/** - * The value COAP_OBSERVE_CANCEL in a GET request indicates that the observe - * relationship for (sender address, token) must be cancelled. - */ -#define COAP_OBSERVE_CANCEL 1 - -#ifndef COAP_OBS_MAX_NON -/** - * Number of notifications that may be sent non-confirmable before a confirmable - * message is sent to detect if observers are alive. The maximum allowed value - * here is @c 15. - */ -#define COAP_OBS_MAX_NON 5 -#endif /* COAP_OBS_MAX_NON */ - -#ifndef COAP_OBS_MAX_FAIL -/** - * Number of confirmable notifications that may fail (i.e. time out without - * being ACKed) before an observer is removed. The maximum value for - * COAP_OBS_MAX_FAIL is @c 3. - */ -#define COAP_OBS_MAX_FAIL 3 -#endif /* COAP_OBS_MAX_FAIL */ - -/** Subscriber information */ -typedef struct coap_subscription_t { - struct coap_subscription_t *next; /**< next element in linked list */ - coap_session_t *session; /**< subscriber session */ - - unsigned int non_cnt:4; /**< up to 15 non-confirmable notifies allowed */ - unsigned int fail_cnt:2; /**< up to 3 confirmable notifies can fail */ - unsigned int dirty:1; /**< set if the notification temporarily could not be - * sent (in that case, the resource's partially - * dirty flag is set too) */ - unsigned int has_block2:1; /**< GET request had Block2 definition */ - uint16_t tid; /**< transaction id, if any, in regular host byte order */ - coap_block_t block2; /**< GET request Block2 definition */ - size_t token_length; /**< actual length of token */ - unsigned char token[8]; /**< token used for subscription */ - coap_string_t *query; /**< query string used for subscription, if any */ -} coap_subscription_t; - -void coap_subscription_init(coap_subscription_t *); - -/** @} */ - -#endif /* COAP_SUBSCRIBE_H_ */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/address.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/address.h similarity index 81% rename from tools/sdk/esp32c3/include/coap/libcoap/include/coap2/address.h rename to tools/sdk/esp32s2/include/coap/libcoap/include/coap3/address.h index a51236d5a60..8b8d9a24fae 100644 --- a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/address.h +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/address.h @@ -3,6 +3,8 @@ * * Copyright (C) 2010-2011,2015-2016 Olaf Bergmann * + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ @@ -30,6 +32,22 @@ typedef struct coap_address_t { ip_addr_t addr; } coap_address_t; +/** + * Returns the port from @p addr in host byte order. + */ +COAP_STATIC_INLINE uint16_t +coap_address_get_port(const coap_address_t *addr) { + return ntohs(addr->port); +} + +/** + * Sets the port field of @p addr to @p port (in host byte order). + */ +COAP_STATIC_INLINE void +coap_address_set_port(coap_address_t *addr, uint16_t port) { + addr->port = htons(port); +} + #define _coap_address_equals_impl(A, B) \ ((A)->port == (B)->port \ && (!!ip_addr_cmp(&(A)->addr,&(B)->addr))) @@ -47,6 +65,22 @@ typedef struct coap_address_t { uint16_t port; } coap_address_t; +/** + * Returns the port from @p addr in host byte order. + */ +COAP_STATIC_INLINE uint16_t +coap_address_get_port(const coap_address_t *addr) { + return uip_ntohs(addr->port); +} + +/** + * Sets the port field of @p addr to @p port (in host byte order). + */ +COAP_STATIC_INLINE void +coap_address_set_port(coap_address_t *addr, uint16_t port) { + addr->port = uip_htons(port); +} + #define _coap_address_equals_impl(A,B) \ ((A)->port == (B)->port \ && uip_ipaddr_cmp(&((A)->addr),&((B)->addr))) @@ -68,6 +102,16 @@ typedef struct coap_address_t { } addr; } coap_address_t; +/** + * Returns the port from @p addr in host byte order. + */ +uint16_t coap_address_get_port(const coap_address_t *addr); + +/** + * Set the port field of @p addr to @p port (in host byte order). + */ +void coap_address_set_port(coap_address_t *addr, uint16_t port); + /** * Compares given address objects @p a and @p b. This function returns @c 1 if * addresses are equal, @c 0 otherwise. The parameters @p a and @p b must not be @@ -100,15 +144,7 @@ _coap_address_isany_impl(const coap_address_t *a) { * * @param addr The coap_address_t object to initialize. */ -COAP_STATIC_INLINE void -coap_address_init(coap_address_t *addr) { - assert(addr); - memset(addr, 0, sizeof(coap_address_t)); -#if !defined(WITH_LWIP) && !defined(WITH_CONTIKI) - /* lwip and Contiki have constant address sizes and doesn't need the .size part */ - addr->size = sizeof(addr->addr); -#endif -} +void coap_address_init(coap_address_t *addr); /* Convenience function to copy IPv6 addresses without garbage. */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/async.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/async.h new file mode 100644 index 00000000000..a61e0c09828 --- /dev/null +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/async.h @@ -0,0 +1,116 @@ +/* + * async.h -- state management for asynchronous messages + * + * Copyright (C) 2010-2011 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file async.h + * @brief State management for asynchronous messages + */ + +#ifndef COAP_ASYNC_H_ +#define COAP_ASYNC_H_ + +#include "net.h" + +/** + * @defgroup coap_async Asynchronous Messaging + * @{ + * API functions for Async "separate" messages. + * A coap_context_t object holds a list of coap_async_t objects that can + * be used to generate a separate response in the case a result of a request + * cannot be delivered immediately. + */ + +/** + * Returns @c 1 if libcoap was built with separate messages enabled, + * @c 0 otherwise. + */ +int coap_async_is_supported(void); + +/** + * Allocates a new coap_async_t object and fills its fields according to + * the given @p request. This function returns a pointer to the registered + * coap_async_t object or @c NULL on error. Note that this function will + * return @c NULL in case that an object with the same identifier is already + * registered. + * + * When the delay expires, a copy of the @p request will get sent to the + * appropriate request handler. + * + * @param session The session that is used for asynchronous transmissions. + * @param request The request that is handled asynchronously. + * @param delay The amount of time to delay before sending response, 0 means + * wait forever. + * + * @return A pointer to the registered coap_async_t object or @c + * NULL in case of an error. + */ +coap_async_t * +coap_register_async(coap_session_t *session, + const coap_pdu_t *request, + coap_tick_t delay); + +/** + * Update the delay timeout, so changing when the registered @p async triggers. + * + * When the new delay expires, a copy of the original request will get sent to + * the appropriate request handler. + * + * @param async The object to update. + * @param delay The amount of time to delay before sending response, 0 means + * wait forever. + */ +void +coap_async_set_delay(coap_async_t *async, coap_tick_t delay); + +/** + * Releases the memory that was allocated by coap_register_async() for the + * object @p async. + * + * @param session The session to use. + * @param async The object to delete. + */ +void +coap_free_async(coap_session_t *session, coap_async_t *async); + +/** + * Retrieves the object identified by @p token from the list of asynchronous + * transactions that are registered with @p context. This function returns a + * pointer to that object or @c NULL if not found. + * + * @param session The session that is used for asynchronous transmissions. + * @param token The PDU's token of the object to retrieve. + * + * @return A pointer to the object identified by @p token or @c NULL if + * not found. + */ +coap_async_t *coap_find_async(coap_session_t *session, coap_bin_const_t token); + +/** + * Set the application data pointer held in @p async. This overwrites any + * existing data pointer. + * + * @param async The async state object. + * @param app_data The pointer to the data. + */ +void coap_async_set_app_data(coap_async_t *async, void *app_data); + +/** + * Gets the application data pointer held in @p async. + * + * @param async The async state object. + * + * @return The applicaton data pointer. + */ +void *coap_async_get_app_data(const coap_async_t *async); + +/** @} */ + +#endif /* COAP_ASYNC_H_ */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/block.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/block.h new file mode 100644 index 00000000000..a2aac00fdc6 --- /dev/null +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/block.h @@ -0,0 +1,348 @@ +/* + * block.h -- block transfer + * + * Copyright (C) 2010-2012,2014-2015 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +#ifndef COAP_BLOCK_H_ +#define COAP_BLOCK_H_ + +#include "encode.h" +#include "option.h" +#include "pdu.h" + +/** + * @defgroup block Block Transfer + * API functions for handling PDUs using CoAP BLOCK options + * @{ + */ + +#ifndef COAP_MAX_BLOCK_SZX +/** + * The largest value for the SZX component in a Block option. + */ +#define COAP_MAX_BLOCK_SZX 6 +#endif /* COAP_MAX_BLOCK_SZX */ + +/** + * Structure of Block options. + */ +typedef struct { + unsigned int num; /**< block number */ + unsigned int m:1; /**< 1 if more blocks follow, 0 otherwise */ + unsigned int szx:3; /**< block size */ +} coap_block_t; + +#define COAP_BLOCK_USE_LIBCOAP 0x01 /* Use libcoap to do block requests */ +#define COAP_BLOCK_SINGLE_BODY 0x02 /* Deliver the data as a single body */ + +/** + * Returns the value of the least significant byte of a Block option @p opt. + * For zero-length options (i.e. num == m == szx == 0), COAP_OPT_BLOCK_LAST + * returns @c NULL. + */ +#define COAP_OPT_BLOCK_LAST(opt) \ + (coap_opt_length(opt) ? (coap_opt_value(opt) + (coap_opt_length(opt)-1)) : 0) + +/** Returns the value of the More-bit of a Block option @p opt. */ +#define COAP_OPT_BLOCK_MORE(opt) \ + (coap_opt_length(opt) ? (*COAP_OPT_BLOCK_LAST(opt) & 0x08) : 0) + +/** Returns the value of the SZX-field of a Block option @p opt. */ +#define COAP_OPT_BLOCK_SZX(opt) \ + (coap_opt_length(opt) ? (*COAP_OPT_BLOCK_LAST(opt) & 0x07) : 0) + +/** + * Returns the value of field @c num in the given block option @p block_opt. + */ +unsigned int coap_opt_block_num(const coap_opt_t *block_opt); + +/** + * Checks if more than @p num blocks are required to deliver @p data_len + * bytes of data for a block size of 1 << (@p szx + 4). + */ +COAP_STATIC_INLINE int +coap_more_blocks(size_t data_len, unsigned int num, uint16_t szx) { + return ((num+1) << (szx + 4)) < data_len; +} + +#if 0 +/** Sets the More-bit in @p block_opt */ +COAP_STATIC_INLINE void +coap_opt_block_set_m(coap_opt_t *block_opt, int m) { + if (m) + *(coap_opt_value(block_opt) + (coap_opt_length(block_opt) - 1)) |= 0x08; + else + *(coap_opt_value(block_opt) + (coap_opt_length(block_opt) - 1)) &= ~0x08; +} +#endif + +/** + * Initializes @p block from @p pdu. @p number must be either COAP_OPTION_BLOCK1 + * or COAP_OPTION_BLOCK2. When option @p number was found in @p pdu, @p block is + * initialized with values from this option and the function returns the value + * @c 1. Otherwise, @c 0 is returned. + * + * @param pdu The pdu to search for option @p number. + * @param number The option number to search for (must be COAP_OPTION_BLOCK1 or + * COAP_OPTION_BLOCK2). + * @param block The block structure to initilize. + * + * @return @c 1 on success, @c 0 otherwise. + */ +int coap_get_block(const coap_pdu_t *pdu, coap_option_num_t number, + coap_block_t *block); + +/** + * Writes a block option of type @p number to message @p pdu. If the requested + * block size is too large to fit in @p pdu, it is reduced accordingly. An + * exception is made for the final block when less space is required. The actual + * length of the resource is specified in @p data_length. + * + * This function may change *block to reflect the values written to @p pdu. As + * the function takes into consideration the remaining space @p pdu, no more + * options should be added after coap_write_block_opt() has returned. + * + * @param block The block structure to use. On return, this object is + * updated according to the values that have been written to + * @p pdu. + * @param number COAP_OPTION_BLOCK1 or COAP_OPTION_BLOCK2. + * @param pdu The message where the block option should be written. + * @param data_length The length of the actual data that will be added the @p + * pdu by calling coap_add_block(). + * + * @return @c 1 on success, or a negative value on error. + */ +int coap_write_block_opt(coap_block_t *block, + coap_option_num_t number, + coap_pdu_t *pdu, + size_t data_length); + +/** + * Adds the @p block_num block of size 1 << (@p block_szx + 4) from source @p + * data to @p pdu. + * + * @param pdu The message to add the block. + * @param len The length of @p data. + * @param data The source data to fill the block with. + * @param block_num The actual block number. + * @param block_szx Encoded size of block @p block_number. + * + * @return @c 1 on success, @c 0 otherwise. + */ +int coap_add_block(coap_pdu_t *pdu, + size_t len, + const uint8_t *data, + unsigned int block_num, + unsigned char block_szx); + +/** + * Re-assemble payloads into a body + * + * @param body_data The pointer to the data for the body holding the + * representation so far or NULL if the first time. + * @param length The length of @p data. + * @param data The payload data to update the body with. + * @param offset The offset of the @p data into the body. + * @param total The estimated total size of the body. + * + * @return The current representation of the body or @c NULL if error. + * If NULL, @p body_data will have been de-allocated. + */ +coap_binary_t * +coap_block_build_body(coap_binary_t *body_data, size_t length, + const uint8_t *data, size_t offset, size_t total); + +/** + * Adds the appropriate part of @p data to the @p response pdu. If blocks are + * required, then the appropriate block will be added to the PDU and sent. + * Adds a ETAG option that is the hash of the entire data if the data is to be + * split into blocks + * Used by a request handler. + * + * Note: The application will get called for every packet of a large body to + * process. Consider using coap_add_data_response_large() instead. + * + * @param request The requesting pdu. + * @param response The response pdu. + * @param media_type The format of the data. + * @param maxage The maxmimum life of the data. If @c -1, then there + * is no maxage. + * @param length The total length of the data. + * @param data The entire data block to transmit. + * + */ +void +coap_add_data_blocked_response(const coap_pdu_t *request, + coap_pdu_t *response, + uint16_t media_type, + int maxage, + size_t length, + const uint8_t* data); + +/** + * Callback handler for de-allocating the data based on @p app_ptr provided to + * coap_add_data_large_*() functions following transmission of the supplied + * data. + * + * @param session The session that this data is associated with + * @param app_ptr The application provided pointer provided to the + * coap_add_data_large_* functions. + */ +typedef void (*coap_release_large_data_t)(coap_session_t *session, + void *app_ptr); + +/** + * Associates given data with the @p pdu that is passed as second parameter. + * + * If all the data can be transmitted in a single PDU, this is functionally + * the same as coap_add_data() except @p release_func (if not NULL) will get + * invoked after data transmission. + * + * Used for a client request. + * + * If the data spans multiple PDUs, then the data will get transmitted using + * BLOCK1 option with the addition of the SIZE1 option. + * The underlying library will handle the transmission of the individual blocks. + * Once the body of data has been transmitted (or a failure occurred), then + * @p release_func (if not NULL) will get called so the application can + * de-allocate the @p data based on @p app_data. It is the responsibility of + * the application not to change the contents of @p data until the data + * transfer has completed. + * + * There is no need for the application to include the BLOCK1 option in the + * @p pdu. + * + * coap_add_data_large_request() (or the alternative coap_add_data_large_*() + * functions) must be called only once per PDU and must be the last PDU update + * before the PDU is transmitted. The (potentially) initial data will get + * transmitted when coap_send() is invoked. + * + * Note: COAP_BLOCK_USE_LIBCOAP must be set by coap_context_set_block_mode() + * for libcoap to work correctly when using this function. + * + * @param session The session to associate the data with. + * @param pdu The PDU to associate the data with. + * @param length The length of data to transmit. + * @param data The data to transmit. + * @param release_func The function to call to de-allocate @p data or @c NULL + * if the function is not required. + * @param app_ptr A Pointer that the application can provide for when + * release_func() is called. + * + * @return @c 1 if addition is successful, else @c 0. + */ +int coap_add_data_large_request(coap_session_t *session, + coap_pdu_t *pdu, + size_t length, + const uint8_t *data, + coap_release_large_data_t release_func, + void *app_ptr); + +/** + * Associates given data with the @p response pdu that is passed as fourth + * parameter. + * + * If all the data can be transmitted in a single PDU, this is functionally + * the same as coap_add_data() except @p release_func (if not NULL) will get + * invoked after data transmission. The MEDIA_TYPE, MAXAGE and ETAG options may + * be added in as appropriate. + * + * Used by a server request handler to create the response. + * + * If the data spans multiple PDUs, then the data will get transmitted using + * BLOCK2 (response) option with the addition of the SIZE2 and ETAG + * options. The underlying library will handle the transmission of the + * individual blocks. Once the body of data has been transmitted (or a + * failure occurred), then @p release_func (if not NULL) will get called so the + * application can de-allocate the @p data based on @p app_data. It is the + * responsibility of the application not to change the contents of @p data + * until the data transfer has completed. + * + * There is no need for the application to include the BLOCK2 option in the + * @p pdu. + * + * coap_add_data_large_response() (or the alternative coap_add_data_large*() + * functions) must be called only once per PDU and must be the last PDU update + * before returning from the request handler function. + * + * Note: COAP_BLOCK_USE_LIBCOAP must be set by coap_context_set_block_mode() + * for libcoap to work correctly when using this function. + * + * @param resource The resource the data is associated with. + * @param session The coap session. + * @param request The requesting pdu. + * @param response The response pdu. + * @param query The query taken from the (original) requesting pdu. + * @param media_type The format of the data. + * @param maxage The maxmimum life of the data. If @c -1, then there + * is no maxage. + * @param etag ETag to use if not 0. + * @param length The total length of the data. + * @param data The entire data block to transmit. + * @param release_func The function to call to de-allocate @p data or NULL if + * the function is not required. + * @param app_ptr A Pointer that the application can provide for when + * release_func() is called. + * + * @return @c 1 if addition is successful, else @c 0. + */ +int +coap_add_data_large_response(coap_resource_t *resource, + coap_session_t *session, + const coap_pdu_t *request, + coap_pdu_t *response, + const coap_string_t *query, + uint16_t media_type, + int maxage, + uint64_t etag, + size_t length, + const uint8_t *data, + coap_release_large_data_t release_func, + void *app_ptr); + +/** + * Set the context level CoAP block handling bits for handling RFC7959. + * These bits flow down to a session when a session is created and if the peer + * does not support something, an appropriate bit may get disabled in the + * session block_mode. + * The session block_mode then flows down into coap_crcv_t or coap_srcv_t where + * again an appropriate bit may get disabled. + * + * Note: This function must be called before the session is set up. + * + * Note: COAP_BLOCK_USE_LIBCOAP must be set if libcoap is to do all the + * block tracking and requesting, otherwise the application will have to do + * all of this work (the default if coap_context_set_block_mode() is not + * called). + * + * @param context The coap_context_t object. + * @param block_mode Zero or more COAP_BLOCK_ or'd options + */ +void coap_context_set_block_mode(coap_context_t *context, + uint8_t block_mode); + +/** + * Cancel an observe that is being tracked by the client large receive logic. + * (coap_context_set_block_mode() has to be called) + * This will trigger the sending of an observe cancel pdu to the server. + * + * @param session The session that is being used for the observe. + * @param token The original token used to initiate the observation. + * @param message_type The COAP_MESSAGE_ type (NON or CON) to send the observe + * cancel pdu as. + * + * @return @c 1 if observe cancel transmission initiation is successful, + * else @c 0. + */ +int coap_cancel_observe(coap_session_t *session, coap_binary_t *token, + coap_pdu_type_t message_type); + +/**@}*/ + +#endif /* COAP_BLOCK_H_ */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_asn1_internal.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_asn1_internal.h new file mode 100644 index 00000000000..5bb4e2a8dbe --- /dev/null +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_asn1_internal.h @@ -0,0 +1,89 @@ +/* + * coap_asn1_internal.h -- ASN.1 functions for libcoap + * + * Copyright (C) 2020 Jon Shallow + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_asn1_internal.h + * @brief COAP ASN.1 internal information + */ + +#ifndef COAP_ASN1_INTERNAL_H_ +#define COAP_ASN1_INTERNAL_H_ + + +/** + * @defgroup asn1 ASN.1 Support (Internal) + * CoAP ASN.1 Structures, Enums and Functions that are not exposed to + * applications + * @{ + */ + +typedef enum { + COAP_ASN1_NONE = 0, + COAP_ASN1_INTEGER = 2, + COAP_ASN1_BITSTRING = 3, + COAP_ASN1_OCTETSTRING = 4, + COAP_ASN1_IDENTIFIER = 6, +} coap_asn1_tag_t; + +/** + * Callback to validate the asn1 tag and data. + * + * Internal function. + * + * @param data The start of the tag and data + * @param size The size of the tag and data + * + * @return @c 1 if pass, else @c 0 if fail + */ +typedef int (*asn1_validate)(const uint8_t *data, size_t size); + +/** + * Get the asn1 length from the current @p ptr. + * + * Internal function. + * + * @param ptr The current asn.1 object length pointer + * + * @return The length of the asn.1 object. @p ptr is updated to be after the length. + */ +size_t asn1_len(const uint8_t **ptr); + +/** + * Get the asn1 tag from the current @p ptr. + * + * Internal function. + * + * @param ptr The current asn.1 object tag pointer + * @param constructed 1 if current tag is constructed + * @param class The current class of the tag + * + * @return The tag value.@p ptr is updated to be after the tag. + */ +coap_asn1_tag_t asn1_tag_c(const uint8_t **ptr, int *constructed, int *class); + +/** + * Get the asn1 tag and data from the current @p ptr. + * + * Internal function. + * + * @param ltag The tag to look for + * @param ptr The current asn.1 object pointer + * @param tlen The remaining size oof the asn.1 data + * @param validate Call validate to verify tag data or @c NULL + * + * @return The asn.1 tag and data or @c NULL if not found + */ +coap_binary_t *get_asn1_tag(coap_asn1_tag_t ltag, const uint8_t *ptr, + size_t tlen, asn1_validate validate); + +/** @} */ + +#endif /* COAP_ASN1_INTERNAL_H_ */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_async_internal.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_async_internal.h new file mode 100644 index 00000000000..a23b1c8e697 --- /dev/null +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_async_internal.h @@ -0,0 +1,67 @@ +/* + * coap_async_internal.h -- state management for asynchronous messages + * + * Copyright (C) 2010-2021 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_async_internal.h + * @brief CoAP async internal information + */ + +#ifndef COAP_ASYNC_INTERNAL_H_ +#define COAP_ASYNC_INTERNAL_H_ + +#include "coap3/net.h" + +#ifndef WITHOUT_ASYNC + +/** + * @defgroup coap_async_internal Asynchronous Messaging (Internal) + * @{ + * CoAP Async Structures, Enums and Functions that are not exposed to + * applications. + * A coap_context_t object holds a list of coap_async_t objects that can be + * used to generate a separate response in the case a result of a request cannot + * be delivered immediately. + */ +struct coap_async_t { + struct coap_async_t *next; /**< internally used for linking */ + coap_tick_t delay; /**< When to delay to before triggering the response + 0 indicates never trigger */ + coap_session_t *session; /**< transaction session */ + coap_pdu_t *pdu; /**< copy of request pdu */ + void* appdata; /** User definable data pointer */ +}; + +/** + * Checks if there are any pending Async requests - if so, send them off. + * Otherewise return the time remaining for the next Async to be triggered + * or 0 if nothing to do. + * + * @param context The current context. + * @param now The current time in ticks. + * + * @return The tick time before the next Async needs to go, else 0 if + * nothing to do. + */ +coap_tick_t coap_check_async(coap_context_t *context, coap_tick_t now); + +/** + * Removes and frees off all of the async entries for the given context. + * + * @param context The context to remove all async entries from. + */ +void +coap_delete_all_async(coap_context_t *context); + +/** @} */ + +#endif /* WITHOUT_ASYNC */ + +#endif /* COAP_ASYNC_INTERNAL_H_ */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_block_internal.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_block_internal.h new file mode 100644 index 00000000000..9abe81557fa --- /dev/null +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_block_internal.h @@ -0,0 +1,239 @@ +/* + * coap_block_internal.h -- Structures, Enums & Functions that are not + * exposed to application programming + * + * Copyright (C) 2010-2021 Olaf Bergmann + * Copyright (C) 2021 Jon Shallow + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_block_internal.h + * @brief COAP block internal information + */ + +#ifndef COAP_BLOCK_INTERNAL_H_ +#define COAP_BLOCK_INTERNAL_H_ + +#include "coap_pdu_internal.h" +#include "resource.h" + +/** + * @defgroup block_internal Block (Internal) + * Structures, Enums and Functions that are not exposed to applications + * @{ + */ + +typedef enum { + COAP_RECURSE_OK, + COAP_RECURSE_NO +} coap_recurse_t; + +struct coap_lg_range { + uint32_t begin; + uint32_t end; +}; + +#define COAP_RBLOCK_CNT 4 +/** + * Structure to keep track of received blocks + */ +typedef struct coap_rblock_t { + uint32_t used; + uint32_t retry; + struct coap_lg_range range[COAP_RBLOCK_CNT]; + coap_tick_t last_seen; +} coap_rblock_t; + +/** + * Structure to keep track of block1 specific information + * (Requests) + */ +typedef struct coap_l_block1_t { + coap_binary_t *app_token; /**< original PDU token */ + uint8_t token[8]; /**< last used token */ + size_t token_length; /**< length of token */ + uint32_t count; /**< the number of packets sent for payload */ +} coap_l_block1_t; + +/** + * Structure to keep track of block2 specific information + * (Responses) + */ +typedef struct coap_l_block2_t { + coap_resource_t *resource; /**< associated resource */ + coap_string_t *query; /**< Associated query for the resource */ + uint64_t etag; /**< ETag value */ + coap_time_t maxage_expire; /**< When this entry expires */ +} coap_l_block2_t; + +/** + * Structure to hold large body (many blocks) transmission information + */ +struct coap_lg_xmit_t { + struct coap_lg_xmit_t *next; + uint8_t blk_size; /**< large block transmission size */ + uint16_t option; /**< large block transmisson CoAP option */ + int last_block; /**< last acknowledged block number */ + const uint8_t *data; /**< large data ptr */ + size_t length; /**< large data length */ + size_t offset; /**< large data next offset to transmit */ + union { + coap_l_block1_t b1; + coap_l_block2_t b2; + } b; + coap_pdu_t pdu; /**< skeletal PDU */ + coap_tick_t last_payload; /**< Last time MAX_PAYLOAD was sent or 0 */ + coap_tick_t last_used; /**< Last time all data sent or 0 */ + coap_release_large_data_t release_func; /**< large data de-alloc function */ + void *app_ptr; /**< applicaton provided ptr for de-alloc function */ +}; + +/** + * Structure to hold large body (many blocks) client receive information + */ +struct coap_lg_crcv_t { + struct coap_lg_crcv_t *next; + uint8_t observe[3]; /**< Observe data (if set) (only 24 bits) */ + uint8_t observe_length;/**< Length of observe data */ + uint8_t observe_set; /**< Set if this is an observe receive PDU */ + uint8_t etag_set; /**< Set if ETag is in receive PDU */ + uint8_t etag_length; /**< ETag length */ + uint8_t etag[8]; /**< ETag for block checking */ + uint16_t content_format; /**< Content format for the set of blocks */ + uint8_t last_type; /**< Last request type (CON/NON) */ + uint8_t initial; /**< If set, has not been used yet */ + uint8_t szx; /**< size of individual blocks */ + size_t total_len; /**< Length as indicated by SIZE2 option */ + coap_binary_t *body_data; /**< Used for re-assembling entire body */ + coap_binary_t *app_token; /**< app requesting PDU token */ + uint8_t base_token[8]; /**< established base PDU token */ + size_t base_token_length; /**< length of token */ + uint8_t token[8]; /**< last used token */ + size_t token_length; /**< length of token */ + coap_pdu_t pdu; /**< skeletal PDU */ + coap_rblock_t rec_blocks; /** < list of received blocks */ + coap_tick_t last_used; /**< Last time all data sent or 0 */ + uint16_t block_option; /**< Block option in use */ +}; + +/** + * Structure to hold large body (many blocks) server receive information + */ +struct coap_lg_srcv_t { + struct coap_lg_srcv_t *next; + uint8_t observe[3]; /**< Observe data (if set) (only 24 bits) */ + uint8_t observe_length;/**< Length of observe data */ + uint8_t observe_set; /**< Set if this is an observe receive PDU */ + uint8_t rtag_set; /**< Set if RTag is in receive PDU */ + uint8_t rtag_length; /**< RTag length */ + uint8_t rtag[8]; /**< RTag for block checking */ + uint16_t content_format; /**< Content format for the set of blocks */ + uint8_t last_type; /**< Last request type (CON/NON) */ + uint8_t szx; /**< size of individual blocks */ + size_t total_len; /**< Length as indicated by SIZE1 option */ + coap_binary_t *body_data; /**< Used for re-assembling entire body */ + size_t amount_so_far; /**< Amount of data seen so far */ + coap_resource_t *resource; /**< associated resource */ + coap_str_const_t *uri_path; /** set to uri_path if unknown resource */ + coap_rblock_t rec_blocks; /** < list of received blocks */ + uint8_t last_token[8]; /**< last used token */ + size_t last_token_length; /**< length of token */ + coap_mid_t last_mid; /**< Last received mid for this set of packets */ + coap_tick_t last_used; /**< Last time data sent or 0 */ + uint16_t block_option; /**< Block option in use */ +}; + +coap_lg_crcv_t * coap_block_new_lg_crcv(coap_session_t *session, + coap_pdu_t *pdu); + +void coap_block_delete_lg_crcv(coap_session_t *session, + coap_lg_crcv_t *lg_crcv); + +coap_tick_t coap_block_check_lg_crcv_timeouts(coap_session_t *session, + coap_tick_t now); + +void coap_block_delete_lg_srcv(coap_session_t *session, + coap_lg_srcv_t *lg_srcv); + +coap_tick_t coap_block_check_lg_srcv_timeouts(coap_session_t *session, + coap_tick_t now); + +int coap_handle_request_send_block(coap_session_t *session, + coap_pdu_t *pdu, + coap_pdu_t *response, + coap_resource_t *resource, + coap_string_t *query); + +int coap_handle_request_put_block(coap_context_t *context, + coap_session_t *session, + coap_pdu_t *pdu, + coap_pdu_t *response, + coap_resource_t *resource, + coap_string_t *uri_path, + coap_opt_t *observe, + coap_string_t *query, + coap_method_handler_t h, + int *added_block); + +int coap_handle_response_send_block(coap_session_t *session, coap_pdu_t *rcvd); + +int coap_handle_response_get_block(coap_context_t *context, + coap_session_t *session, + coap_pdu_t *sent, + coap_pdu_t *rcvd, + coap_recurse_t recursive); + +void coap_block_delete_lg_xmit(coap_session_t *session, + coap_lg_xmit_t *lg_xmit); + +/** + * The function that does all the work for the coap_add_data_large*() + * functions. + * + * @param session The session to associate the data with. + * @param pdu The PDU to associate the data with. + * @param resource The resource to associate the data with (BLOCK2). + * @param query The query to associate the data with (BLOCK2). + * @param maxage The maxmimum life of the data. If @c -1, then there + * is no maxage (BLOCK2). + * @param etag ETag to use if not 0 (BLOCK2). + * @param length The length of data to transmit. + * @param data The data to transmit. + * @param release_func The function to call to de-allocate @p data or NULL if + * the function is not required. + * @param app_ptr A Pointer that the application can provide for when + * release_func() is called. + * + * @return @c 1 if transmission initiation is successful, else @c 0. + */ +int coap_add_data_large_internal(coap_session_t *session, + coap_pdu_t *pdu, + coap_resource_t *resource, + const coap_string_t *query, + int maxage, + uint64_t etag, + size_t length, + const uint8_t *data, + coap_release_large_data_t release_func, + void *app_ptr); + +/** + * The function checks that the code in a newly formed lg_xmit created by + * coap_add_data_large_response() is updated. + * + * @param session The session + * @param response The response PDU to to check + * @param resource The requested resource + * @param query The requested query + */ +void coap_check_code_lg_xmit(coap_session_t *session, coap_pdu_t *response, + coap_resource_t *resource, coap_string_t *query); + +/** @} */ + +#endif /* COAP_BLOCK_INTERNAL_H_ */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_cache.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_cache.h new file mode 100644 index 00000000000..a8d2fd7a84e --- /dev/null +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_cache.h @@ -0,0 +1,232 @@ +/* coap_cache.h -- Caching of CoAP requests +* +* Copyright (C) 2020 Olaf Bergmann +* + * SPDX-License-Identifier: BSD-2-Clause + * +* This file is part of the CoAP library libcoap. Please see +* README for terms of use. +*/ + +/** + * @file coap_cache.h + * @brief Provides a simple cache request storage for CoAP requests + */ + +#ifndef COAP_CACHE_H_ +#define COAP_CACHE_H_ + +#include "coap_forward_decls.h" + +/** + * @defgroup cache Cache Support + * API functions for CoAP Caching + * @{ + */ + +/** + * Callback to free off the app data when the cache-entry is + * being deleted / freed off. + * + * @param data The app data to be freed off. + */ +typedef void (*coap_cache_app_data_free_callback_t)(void *data); + +typedef enum coap_cache_session_based_t { + COAP_CACHE_NOT_SESSION_BASED, + COAP_CACHE_IS_SESSION_BASED +} coap_cache_session_based_t; + +typedef enum coap_cache_record_pdu_t { + COAP_CACHE_NOT_RECORD_PDU, + COAP_CACHE_RECORD_PDU +} coap_cache_record_pdu_t; + +/** + * Calculates a cache-key for the given CoAP PDU. See + * https://tools.ietf.org/html/rfc7252#section-5.6 + * for an explanation of CoAP cache keys. + * + * Specific CoAP options can be removed from the cache-key. Examples of + * this are the BLOCK1 and BLOCK2 options - which make no real sense including + * them in a client or server environment, but should be included in a proxy + * caching environment where things are cached on a per block basis. + * This is done globally by calling the coap_cache_ignore_options() + * function. + * + * NOTE: The returned cache-key needs to be freed off by the caller by + * calling coap_cache_delete_key(). + * + * @param session The session to add into cache-key if @p session_based + * is set. + * @param pdu The CoAP PDU for which a cache-key is to be + * calculated. + * @param session_based COAP_CACHE_IS_SESSION_BASED if session based + * cache-key, else COAP_CACHE_NOT_SESSION_BASED. + * + * @return The returned cache-key or @c NULL if failure. + */ +coap_cache_key_t *coap_cache_derive_key(const coap_session_t *session, + const coap_pdu_t *pdu, + coap_cache_session_based_t session_based); + +/** + * Calculates a cache-key for the given CoAP PDU. See + * https://tools.ietf.org/html/rfc7252#section-5.6 + * for an explanation of CoAP cache keys. + * + * Specific CoAP options can be removed from the cache-key. Examples of + * this are the BLOCK1 and BLOCK2 options - which make no real sense including + * them in a client or server environment, but should be included in a proxy + * caching environment where things are cached on a per block basis. + * This is done individually by specifying @p cache_ignore_count and + * @p cache_ignore_options . + * + * NOTE: The returned cache-key needs to be freed off by the caller by + * calling coap_cache_delete_key(). + * + * @param session The session to add into cache-key if @p session_based + * is set. + * @param pdu The CoAP PDU for which a cache-key is to be + * calculated. + * @param session_based COAP_CACHE_IS_SESSION_BASED if session based + * cache-key, else COAP_CACHE_NOT_SESSION_BASED. + * @param ignore_options The array of options to ignore. + * @param ignore_count The number of options to ignore. + * + * @return The returned cache-key or @c NULL if failure. + */ +coap_cache_key_t *coap_cache_derive_key_w_ignore(const coap_session_t *session, + const coap_pdu_t *pdu, + coap_cache_session_based_t session_based, + const uint16_t *ignore_options, + size_t ignore_count); + +/** + * Delete the cache-key. + * + * @param cache_key The cache-key to delete. + */ +void coap_delete_cache_key(coap_cache_key_t *cache_key); + +/** + * Define the CoAP options that are not to be included when calculating + * the cache-key. Options that are defined as Non-Cache and the Observe + * option are always ignored. + * + * @param context The context to save the ignored options information in. + * @param options The array of options to ignore. + * @param count The number of options to ignore. Use 0 to reset the + * options matching. + * + * @return @return @c 1 if successful, else @c 0. + */ +int coap_cache_ignore_options(coap_context_t *context, + const uint16_t *options, size_t count); + +/** + * Create a new cache-entry hash keyed by cache-key derived from the PDU. + * + * If @p session_based is set, then this cache-entry will get deleted when + * the session is freed off. + * If @p record_pdu is set, then the copied PDU will get freed off when + * this cache-entry is deleted. + * + * The cache-entry is maintained on a context hash list. + * + * @param session The session to use to derive the context from. + * @param pdu The pdu to use to generate the cache-key. + * @param record_pdu COAP_CACHE_RECORD_PDU if to take a copy of the PDU for + * later use, else COAP_CACHE_NOT_RECORD_PDU. + * @param session_based COAP_CACHE_IS_SESSION_BASED if to associate this + * cache-entry with the the session (which is embedded + * in the cache-entry), else COAP_CACHE_NOT_SESSION_BASED. + * @param idle_time Idle time in seconds before cache-entry is expired. + * If set to 0, it does not expire (but will get + * deleted if the session is deleted and it is session_based). + * + * @return The returned cache-key or @c NULL if failure. + */ +coap_cache_entry_t *coap_new_cache_entry(coap_session_t *session, + const coap_pdu_t *pdu, + coap_cache_record_pdu_t record_pdu, + coap_cache_session_based_t session_based, + unsigned int idle_time); + +/** + * Remove a cache-entry from the hash list and free off all the appropriate + * contents apart from app_data. + * + * @param context The context to use. + * @param cache_entry The cache-entry to remove. + */ +void coap_delete_cache_entry(coap_context_t *context, + coap_cache_entry_t *cache_entry); + +/** + * Searches for a cache-entry identified by @p cache_key. This + * function returns the corresponding cache-entry or @c NULL + * if not found. + * + * @param context The context to use. + * @param cache_key The cache-key to get the hashed coap-entry. + * + * @return The cache-entry for @p cache_key or @c NULL if not found. + */ +coap_cache_entry_t *coap_cache_get_by_key(coap_context_t *context, + const coap_cache_key_t *cache_key); + +/** + * Searches for a cache-entry corresponding to @p pdu. This + * function returns the corresponding cache-entry or @c NULL if not + * found. + * + * @param session The session to use. + * @param pdu The CoAP request to search for. + * @param session_based COAP_CACHE_IS_SESSION_BASED if session based + * cache-key to be used, else COAP_CACHE_NOT_SESSION_BASED. + * + * @return The cache-entry for @p request or @c NULL if not found. + */ +coap_cache_entry_t *coap_cache_get_by_pdu(coap_session_t *session, + const coap_pdu_t *pdu, + coap_cache_session_based_t session_based); + +/** + * Returns the PDU information stored in the @p coap_cache entry. + * + * @param cache_entry The CoAP cache entry. + * + * @return The PDU information stored in the cache_entry or NULL + * if the PDU was not initially copied. + */ +const coap_pdu_t *coap_cache_get_pdu(const coap_cache_entry_t *cache_entry); + +/** + * Stores @p data with the given cache entry. This function + * overwrites any value that has previously been stored with @p + * cache_entry. + * + * @param cache_entry The CoAP cache entry. + * @param data The data pointer to store with wih the cache entry. Note that + * this data must be valid during the lifetime of @p cache_entry. + * @param callback The callback to call to free off this data when the + * cache-entry is deleted, or @c NULL if not required. + */ +void coap_cache_set_app_data(coap_cache_entry_t *cache_entry, void *data, + coap_cache_app_data_free_callback_t callback); + +/** + * Returns any application-specific data that has been stored with @p + * cache_entry using the function coap_cache_set_app_data(). This function will + * return @c NULL if no data has been stored. + * + * @param cache_entry The CoAP cache entry. + * + * @return The data pointer previously stored or @c NULL if no data stored. + */ +void *coap_cache_get_app_data(const coap_cache_entry_t *cache_entry); + +/** @} */ + +#endif /* COAP_CACHE_H */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_cache_internal.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_cache_internal.h new file mode 100644 index 00000000000..29c0756875c --- /dev/null +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_cache_internal.h @@ -0,0 +1,111 @@ +/* + * coap_cache_internal.h -- Cache functions for libcoap + * + * Copyright (C) 2019--2020 Olaf Bergmann and others + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_cache_internal.h + * @brief COAP cache internal information + */ + +#ifndef COAP_CACHE_INTERNAL_H_ +#define COAP_CACHE_INTERNAL_H_ + +#include "coap_io.h" + +/** + * @defgroup cache_internal Cache Support (Internal) + * CoAP Cache Structures, Enums and Functions that are not exposed to + * applications + * @{ + */ + +/* Holds a digest in binary typically sha256 except for notls */ +typedef struct coap_digest_t { + uint8_t key[32]; +} coap_digest_t; + +struct coap_cache_key_t { + uint8_t key[32]; +}; + +struct coap_cache_entry_t { + UT_hash_handle hh; + coap_cache_key_t *cache_key; + coap_session_t *session; + coap_pdu_t *pdu; + void* app_data; + coap_tick_t expire_ticks; + unsigned int idle_timeout; + coap_cache_app_data_free_callback_t callback; +}; + +/** + * Expire coap_cache_entry_t entries + * + * Internal function. + * + * @param context The context holding the coap-entries to exire + */ +void coap_expire_cache_entries(coap_context_t *context); + +typedef void coap_digest_ctx_t; + +/** + * Initialize a coap_digest + * + * Internal function. + * + * @return The digest context or @c NULL if failure. + */ +coap_digest_ctx_t *coap_digest_setup(void); + +/** + * Free off coap_digest_ctx_t. Always done by + * coap_digest_final() + * + * Internal function. + * + * @param digest_ctx The coap_digest context. + */ +void coap_digest_free(coap_digest_ctx_t *digest_ctx); + +/** + * Update the coap_digest information with the next chunk of data + * + * Internal function. + * + * @param digest_ctx The coap_digest context. + * @param data Pointer to data. + * @param data_len Number of bytes. + * + * @return @c 1 success, @c 0 failure. + */ +int coap_digest_update(coap_digest_ctx_t *digest_ctx, + const uint8_t *data, + size_t data_len + ); + +/** + * Finalize the coap_digest information into the provided + * @p digest_buffer. + * + * Internal function. + * + * @param digest_ctx The coap_digest context. + * @param digest_buffer Pointer to digest buffer to update + * + * @return @c 1 success, @c 0 failure. + */ +int coap_digest_final(coap_digest_ctx_t *digest_ctx, + coap_digest_t *digest_buffer); + +/** @} */ + +#endif /* COAP_CACHE_INTERNAL_H_ */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap2/coap_debug.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_debug.h similarity index 78% rename from tools/sdk/esp32/include/coap/libcoap/include/coap2/coap_debug.h rename to tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_debug.h index e4631b71f2b..f8f70f64495 100644 --- a/tools/sdk/esp32/include/coap/libcoap/include/coap2/coap_debug.h +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_debug.h @@ -3,6 +3,8 @@ * * Copyright (C) 2010-2011,2014 Olaf Bergmann * + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ @@ -36,8 +38,16 @@ * Logging type. One of LOG_* from @b syslog. */ typedef short coap_log_t; -#else -/** Pre-defined log levels akin to what is used in \b syslog. */ +/* + LOG_DEBUG+2 gives ciphers in GnuTLS + Use COAP_LOG_CIPHERS to output Cipher Info in OpenSSL etc. + */ +#define COAP_LOG_CIPHERS (LOG_DEBUG+2) +#else /* !HAVE_SYSLOG_H */ +/** Pre-defined log levels akin to what is used in \b syslog + with LOG_CIPHERS added. */ + +#if !defined(RIOT_VERSION) typedef enum { LOG_EMERG=0, /**< Emergency */ LOG_ALERT, /**< Alert */ @@ -46,9 +56,29 @@ typedef enum { LOG_WARNING, /**< Warning */ LOG_NOTICE, /**< Notice */ LOG_INFO, /**< Information */ - LOG_DEBUG /**< Debug */ + LOG_DEBUG, /**< Debug */ + COAP_LOG_CIPHERS=LOG_DEBUG+2 /**< CipherInfo */ } coap_log_t; -#endif +#else /* RIOT_VERSION */ +/* RIOT defines a subset of the syslog levels in log.h with different + * numeric values. The remaining levels are defined here. Note that + * output granularity differs from what would be expected when + * adhering to the syslog levels. + */ +#include +typedef short coap_log_t; +#define LOG_EMERG (0) +#define LOG_ALERT (1) +#define LOG_CRIT (2) +#define LOG_ERR (3) +/* LOG_WARNING (4) */ +#define LOG_NOTICE (5) +/* LOG_INFO (6) */ +/* LOG_DEBUG (7) */ +#define COAP_LOG_CIPHERS (9) +#endif /* RIOT_VERSION */ + +#endif /* !HAVE_SYSLOG_H */ /** * Get the current logging level. @@ -65,7 +95,7 @@ coap_log_t coap_get_log_level(void); void coap_set_log_level(coap_log_t level); /** - * Logging call-back handler definition. + * Logging callback handler definition. * * @param level One of the LOG_* values. * @param message Zero-terminated string message to log. @@ -163,7 +193,15 @@ void coap_show_tls_version(coap_log_t level); */ char *coap_string_tls_version(char *buffer, size_t bufsize); -struct coap_address_t; +/** + * Build a string containing the current (D)TLS library support + * + * @param buffer The buffer to put the string into. + * @param bufsize The size of the buffer to put the string into. + * + * @return A pointer to the provided buffer. + */ +char *coap_string_tls_support(char *buffer, size_t bufsize); /** * Print the address into the defined buffer. @@ -176,7 +214,7 @@ struct coap_address_t; * * @return The amount written into the buffer. */ -size_t coap_print_addr(const struct coap_address_t *address, +size_t coap_print_addr(const coap_address_t *address, unsigned char *buffer, size_t size); /** @} */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_dtls.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_dtls.h new file mode 100644 index 00000000000..cbd369dfce6 --- /dev/null +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_dtls.h @@ -0,0 +1,479 @@ +/* + * coap_dtls.h -- (Datagram) Transport Layer Support for libcoap + * + * Copyright (C) 2016 Olaf Bergmann + * Copyright (C) 2017 Jean-Claude Michelou + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +#ifndef COAP_DTLS_H_ +#define COAP_DTLS_H_ + +#include "coap_time.h" +#include "str.h" + +/** + * @defgroup dtls DTLS Support + * API functions for interfacing with DTLS libraries. + * @{ + */ + +typedef struct coap_dtls_pki_t coap_dtls_pki_t; + +#ifndef COAP_DTLS_HINT_LENGTH +#define COAP_DTLS_HINT_LENGTH 128 +#endif + +typedef enum coap_dtls_role_t { + COAP_DTLS_ROLE_CLIENT, /**< Internal function invoked for client */ + COAP_DTLS_ROLE_SERVER /**< Internal function invoked for server */ +} coap_dtls_role_t; + +#define COAP_DTLS_RPK_CERT_CN "RPK" + +/** + * Check whether DTLS is available. + * + * @return @c 1 if support for DTLS is enabled, or @c 0 otherwise. + */ +int coap_dtls_is_supported(void); + +/** + * Check whether TLS is available. + * + * @return @c 1 if support for TLS is enabled, or @c 0 otherwise. + */ +int coap_tls_is_supported(void); + +typedef enum coap_tls_library_t { + COAP_TLS_LIBRARY_NOTLS = 0, /**< No DTLS library */ + COAP_TLS_LIBRARY_TINYDTLS, /**< Using TinyDTLS library */ + COAP_TLS_LIBRARY_OPENSSL, /**< Using OpenSSL library */ + COAP_TLS_LIBRARY_GNUTLS, /**< Using GnuTLS library */ + COAP_TLS_LIBRARY_MBEDTLS, /**< Using Mbed TLS library */ +} coap_tls_library_t; + +/** + * The structure used for returning the underlying (D)TLS library + * information. + */ +typedef struct coap_tls_version_t { + uint64_t version; /**< (D)TLS runtime Library Version */ + coap_tls_library_t type; /**< Library type. One of COAP_TLS_LIBRARY_* */ + uint64_t built_version; /**< (D)TLS Built against Library Version */ +} coap_tls_version_t; + +/** + * Determine the type and version of the underlying (D)TLS library. + * + * @return The version and type of library libcoap was compiled against. + */ +coap_tls_version_t *coap_get_tls_library_version(void); + +/** + * Additional Security setup handler that can be set up by + * coap_context_set_pki(). + * Invoked when libcoap has done the validation checks at the TLS level, + * but the application needs to do some additional checks/changes/updates. + * + * @param tls_session The security session definition - e.g. SSL * for OpenSSL. + * NULL if server callback. + * This will be dependent on the underlying TLS library - + * see coap_get_tls_library_version() + * @param setup_data A structure containing setup data originally passed into + * coap_context_set_pki() or coap_new_client_session_pki(). + * + * @return @c 1 if successful, else @c 0. + */ +typedef int (*coap_dtls_security_setup_t)(void* tls_session, + coap_dtls_pki_t *setup_data); + +/** + * CN Validation callback that can be set up by coap_context_set_pki(). + * Invoked when libcoap has done the validation checks at the TLS level, + * but the application needs to check that the CN is allowed. + * CN is the SubjectAltName in the cert, if not present, then the leftmost + * Common Name (CN) component of the subject name. + * NOTE: If using RPK, then the Public Key does not contain a CN, but the + * content of COAP_DTLS_RPK_CERT_CN is presented for the @p cn parameter. + * + * @param cn The determined CN from the certificate + * @param asn1_public_cert The ASN.1 DER encoded X.509 certificate + * @param asn1_length The ASN.1 length + * @param coap_session The CoAP session associated with the certificate update + * @param depth Depth in cert chain. If 0, then client cert, else a CA + * @param validated TLS layer can find no issues if 1 + * @param arg The same as was passed into coap_context_set_pki() + * in setup_data->cn_call_back_arg + * + * @return @c 1 if accepted, else @c 0 if to be rejected. + */ +typedef int (*coap_dtls_cn_callback_t)(const char *cn, + const uint8_t *asn1_public_cert, + size_t asn1_length, + coap_session_t *coap_session, + unsigned int depth, + int validated, + void *arg); + +/** + * The enum used for determining the provided PKI ASN.1 (DER) Private Key + * formats. + */ +typedef enum coap_asn1_privatekey_type_t { + COAP_ASN1_PKEY_NONE, /**< NONE */ + COAP_ASN1_PKEY_RSA, /**< RSA type */ + COAP_ASN1_PKEY_RSA2, /**< RSA2 type */ + COAP_ASN1_PKEY_DSA, /**< DSA type */ + COAP_ASN1_PKEY_DSA1, /**< DSA1 type */ + COAP_ASN1_PKEY_DSA2, /**< DSA2 type */ + COAP_ASN1_PKEY_DSA3, /**< DSA3 type */ + COAP_ASN1_PKEY_DSA4, /**< DSA4 type */ + COAP_ASN1_PKEY_DH, /**< DH type */ + COAP_ASN1_PKEY_DHX, /**< DHX type */ + COAP_ASN1_PKEY_EC, /**< EC type */ + COAP_ASN1_PKEY_HMAC, /**< HMAC type */ + COAP_ASN1_PKEY_CMAC, /**< CMAC type */ + COAP_ASN1_PKEY_TLS1_PRF, /**< TLS1_PRF type */ + COAP_ASN1_PKEY_HKDF /**< HKDF type */ +} coap_asn1_privatekey_type_t; + +/** + * The enum used for determining the PKI key formats. + */ +typedef enum coap_pki_key_t { + COAP_PKI_KEY_PEM = 0, /**< The PKI key type is PEM file */ + COAP_PKI_KEY_ASN1, /**< The PKI key type is ASN.1 (DER) buffer */ + COAP_PKI_KEY_PEM_BUF, /**< The PKI key type is PEM buffer */ + COAP_PKI_KEY_PKCS11, /**< The PKI key type is PKCS11 (DER) */ +} coap_pki_key_t; + +/** + * The structure that holds the PKI PEM definitions. + */ +typedef struct coap_pki_key_pem_t { + const char *ca_file; /**< File location of Common CA in PEM format */ + const char *public_cert; /**< File location of Public Cert */ + const char *private_key; /**< File location of Private Key in PEM format */ +} coap_pki_key_pem_t; + +/** + * The structure that holds the PKI PEM buffer definitions. + * The certificates and private key data must be in PEM format. + * + * Note: The Certs and Key should be NULL terminated strings for + * performance reasons (to save a potential buffer copy) and the length include + * this NULL terminator. It is not a requirement to have the NULL terminator + * though and the length must then reflect the actual data size. + */ +typedef struct coap_pki_key_pem_buf_t { + const uint8_t *ca_cert; /**< PEM buffer Common CA Cert */ + const uint8_t *public_cert; /**< PEM buffer Public Cert, or Public Key if RPK */ + const uint8_t *private_key; /**< PEM buffer Private Key + If RPK and 'EC PRIVATE KEY' this can be used + for both the public_cert and private_key */ + size_t ca_cert_len; /**< PEM buffer CA Cert length */ + size_t public_cert_len; /**< PEM buffer Public Cert length */ + size_t private_key_len; /**< PEM buffer Private Key length */ +} coap_pki_key_pem_buf_t; + +/** + * The structure that holds the PKI ASN.1 (DER) definitions. + */ +typedef struct coap_pki_key_asn1_t { + const uint8_t *ca_cert; /**< ASN1 (DER) Common CA Cert */ + const uint8_t *public_cert; /**< ASN1 (DER) Public Cert, or Public Key if RPK */ + const uint8_t *private_key; /**< ASN1 (DER) Private Key */ + size_t ca_cert_len; /**< ASN1 CA Cert length */ + size_t public_cert_len; /**< ASN1 Public Cert length */ + size_t private_key_len; /**< ASN1 Private Key length */ + coap_asn1_privatekey_type_t private_key_type; /**< Private Key Type */ +} coap_pki_key_asn1_t; + +/** + * The structure that holds the PKI PKCS11 definitions. + */ +typedef struct coap_pki_key_pkcs11_t { + const char *ca; /**< pkcs11: URI for Common CA Certificate */ + const char *public_cert; /**< pkcs11: URI for Public Cert */ + const char *private_key; /**< pkcs11: URI for Private Key */ + const char *user_pin; /**< User pin to access PKCS11. If NULL, then + pin-value= parameter must be set in + pkcs11: URI as a query. */ +} coap_pki_key_pkcs11_t; + +/** + * The structure that holds the PKI key information. + */ +typedef struct coap_dtls_key_t { + coap_pki_key_t key_type; /**< key format type */ + union { + coap_pki_key_pem_t pem; /**< for PEM file keys */ + coap_pki_key_pem_buf_t pem_buf; /**< for PEM memory keys */ + coap_pki_key_asn1_t asn1; /**< for ASN.1 (DER) memory keys */ + coap_pki_key_pkcs11_t pkcs11; /**< for PKCS11 keys */ + } key; +} coap_dtls_key_t; + +/** + * Server Name Indication (SNI) Validation callback that can be set up by + * coap_context_set_pki(). + * Invoked if the SNI is not previously seen and prior to sending a certificate + * set back to the client so that the appropriate certificate set can be used + * based on the requesting SNI. + * + * @param sni The requested SNI + * @param arg The same as was passed into coap_context_set_pki() + * in setup_data->sni_call_back_arg + * + * @return New set of certificates to use, or @c NULL if SNI is to be rejected. + */ +typedef coap_dtls_key_t *(*coap_dtls_pki_sni_callback_t)(const char *sni, + void* arg); + + +#define COAP_DTLS_PKI_SETUP_VERSION 1 /**< Latest PKI setup version */ + +/** + * The structure used for defining the PKI setup data to be used. + */ +struct coap_dtls_pki_t { + uint8_t version; /** Set to COAP_DTLS_PKI_SETUP_VERSION + to support this version of the struct */ + + /* Options to enable different TLS functionality in libcoap */ + uint8_t verify_peer_cert; /**< 1 if peer cert is to be verified */ + uint8_t check_common_ca; /**< 1 if peer cert is to be signed by + * the same CA as the local cert */ + uint8_t allow_self_signed; /**< 1 if self-signed certs are allowed. + * Ignored if check_common_ca set */ + uint8_t allow_expired_certs; /**< 1 if expired certs are allowed */ + uint8_t cert_chain_validation; /**< 1 if to check cert_chain_verify_depth */ + uint8_t cert_chain_verify_depth; /**< recommended depth is 3 */ + uint8_t check_cert_revocation; /**< 1 if revocation checks wanted */ + uint8_t allow_no_crl; /**< 1 ignore if CRL not there */ + uint8_t allow_expired_crl; /**< 1 if expired crl is allowed */ + uint8_t allow_bad_md_hash; /**< 1 if unsupported MD hashes are allowed */ + uint8_t allow_short_rsa_length; /**< 1 if small RSA keysizes are allowed */ + uint8_t is_rpk_not_cert; /**< 1 is RPK instead of Public Certificate. + * If set, PKI key format type cannot be + * COAP_PKI_KEY_PEM */ + uint8_t reserved[3]; /**< Reserved - must be set to 0 for + future compatibility */ + /* Size of 3 chosen to align to next + * parameter, so if newly defined option + * it can use one of the reserverd slot so + * no need to change + * COAP_DTLS_PKI_SETUP_VERSION and just + * decrement the reserved[] count. + */ + + /** CN check callback function. + * If not NULL, is called when the TLS connection has passed the configured + * TLS options above for the application to verify if the CN is valid. + */ + coap_dtls_cn_callback_t validate_cn_call_back; + void *cn_call_back_arg; /**< Passed in to the CN callback function */ + + /** SNI check callback function. + * If not @p NULL, called if the SNI is not previously seen and prior to + * sending a certificate set back to the client so that the appropriate + * certificate set can be used based on the requesting SNI. + */ + coap_dtls_pki_sni_callback_t validate_sni_call_back; + void *sni_call_back_arg; /**< Passed in to the sni callback function */ + + /** Additional Security callback handler that is invoked when libcoap has + * done the standard, defined validation checks at the TLS level, + * If not @p NULL, called from within the TLS Client Hello connection + * setup. + */ + coap_dtls_security_setup_t additional_tls_setup_call_back; + + char* client_sni; /**< If not NULL, SNI to use in client TLS setup. + Owned by the client app and must remain valid + during the call to coap_new_client_session_pki() */ + + coap_dtls_key_t pki_key; /**< PKI key definition */ +}; + +/** + * The structure that holds the Client PSK information. + */ +typedef struct coap_dtls_cpsk_info_t { + coap_bin_const_t identity; + coap_bin_const_t key; +} coap_dtls_cpsk_info_t; + +/** + * Identity Hint Validation callback that can be set up by + * coap_new_client_session_psk2(). + * Invoked when libcoap has done the validation checks at the TLS level, + * but the application needs to check that the Identity Hint is allowed, + * and thus needs to use the appropriate PSK information for the Identity + * Hint for the (D)TLS session. + * Note: Identity Hint is not supported in (D)TLS1.3. + * + * @param hint The server provided Identity Hint + * @param coap_session The CoAP session associated with the Identity Hint + * @param arg The same as was passed into coap_new_client_session_psk2() + * in setup_data->ih_call_back_arg + * + * @return New coap_dtls_cpsk_info_t object or @c NULL on error. + */ +typedef const coap_dtls_cpsk_info_t *(*coap_dtls_ih_callback_t)( + coap_str_const_t *hint, + coap_session_t *coap_session, + void *arg); + +#define COAP_DTLS_CPSK_SETUP_VERSION 1 /**< Latest CPSK setup version */ + +/** + * The structure used for defining the Client PSK setup data to be used. + */ +typedef struct coap_dtls_cpsk_t { + uint8_t version; /** Set to COAP_DTLS_CPSK_SETUP_VERSION + to support this version of the struct */ + + /* Options to enable different TLS functionality in libcoap */ + uint8_t reserved[7]; /**< Reserved - must be set to 0 for + future compatibility */ + /* Size of 7 chosen to align to next + * parameter, so if newly defined option + * it can use one of the reserverd slot so + * no need to change + * COAP_DTLS_CPSK_SETUP_VERSION and just + * decrement the reserved[] count. + */ + + /** Identity Hint check callback function. + * If not NULL, is called when the Identity Hint (TLS1.2 or earlier) is + * provided by the server. + * The appropriate Identity and Pre-shared Key to use can then be returned. + */ + coap_dtls_ih_callback_t validate_ih_call_back; + void *ih_call_back_arg; /**< Passed in to the Identity Hint callback + function */ + + char* client_sni; /**< If not NULL, SNI to use in client TLS setup. + Owned by the client app and must remain valid + during the call to coap_new_client_session_psk2() + Note: Not supported by TinyDTLS. */ + + coap_dtls_cpsk_info_t psk_info; /**< Client PSK definition */ +} coap_dtls_cpsk_t; + +/** + * The structure that holds the Server Pre-Shared Key and Identity + * Hint information. + */ +typedef struct coap_dtls_spsk_info_t { + coap_bin_const_t hint; + coap_bin_const_t key; +} coap_dtls_spsk_info_t; + + +/** + * Identity Validation callback that can be set up by + * coap_context_set_psk2(). + * Invoked when libcoap has done the validation checks at the TLS level, + * but the application needs to check that the Identity is allowed, + * and needs to use the appropriate Pre-Shared Key for the (D)TLS session. + * + * @param identity The client provided Identity + * @param coap_session The CoAP session associated with the Identity Hint + * @param arg The value as passed into coap_context_set_psk2() + * in setup_data->id_call_back_arg + * + * @return New coap_bin_const_t object containing the Pre-Shared Key or + @c NULL on error. + * Note: This information will be duplicated into an internal + * structure. + */ +typedef const coap_bin_const_t *(*coap_dtls_id_callback_t)( + coap_bin_const_t *identity, + coap_session_t *coap_session, + void *arg); +/** + * PSK SNI callback that can be set up by coap_context_set_psk2(). + * Invoked when libcoap has done the validation checks at the TLS level + * and the application needs to:- + * a) check that the SNI is allowed + * b) provide the appropriate PSK information for the (D)TLS session. + * + * @param sni The client provided SNI + * @param coap_session The CoAP session associated with the SNI + * @param arg The same as was passed into coap_context_set_psk2() + * in setup_data->sni_call_back_arg + * + * @return New coap_dtls_spsk_info_t object or @c NULL on error. + */ +typedef const coap_dtls_spsk_info_t *(*coap_dtls_psk_sni_callback_t)( + const char *sni, + coap_session_t *coap_session, + void *arg); + +#define COAP_DTLS_SPSK_SETUP_VERSION 1 /**< Latest SPSK setup version */ + +/** + * The structure used for defining the Server PSK setup data to be used. + */ +typedef struct coap_dtls_spsk_t { + uint8_t version; /** Set to COAP_DTLS_SPSK_SETUP_VERSION + to support this version of the struct */ + + /* Options to enable different TLS functionality in libcoap */ + uint8_t reserved[7]; /**< Reserved - must be set to 0 for + future compatibility */ + /* Size of 7 chosen to align to next + * parameter, so if newly defined option + * it can use one of the reserverd slot so + * no need to change + * COAP_DTLS_SPSK_SETUP_VERSION and just + * decrement the reserved[] count. + */ + + /** Identity check callback function. + * If not @p NULL, is called when the Identity is provided by the client. + * The appropriate Pre-Shared Key to use can then be returned. + */ + coap_dtls_id_callback_t validate_id_call_back; + void *id_call_back_arg; /**< Passed in to the Identity callback function */ + + /** SNI check callback function. + * If not @p NULL, called if the SNI is not previously seen and prior to + * sending PSK information back to the client so that the appropriate + * PSK information can be used based on the requesting SNI. + */ + coap_dtls_psk_sni_callback_t validate_sni_call_back; + void *sni_call_back_arg; /**< Passed in to the SNI callback function */ + + coap_dtls_spsk_info_t psk_info; /**< Server PSK definition */ +} coap_dtls_spsk_t; + + +/** @} */ + +/** + * @ingroup logging + * Sets the (D)TLS logging level to the specified @p level. + * Note: coap_log_level() will influence output if at a specified level. + * + * @param level The logging level to use - LOG_* + */ +void coap_dtls_set_log_level(int level); + +/** + * @ingroup logging + * Get the current (D)TLS logging. + * + * @return The current log level (one of LOG_*). + */ +int coap_dtls_get_log_level(void); + + +#endif /* COAP_DTLS_H */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_dtls_internal.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_dtls_internal.h new file mode 100644 index 00000000000..8ea09a4eb3e --- /dev/null +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_dtls_internal.h @@ -0,0 +1,345 @@ +/* + * coap_dtls_internal.h -- (Datagram) Transport Layer Support for libcoap + * + * Copyright (C) 2016 Olaf Bergmann + * Copyright (C) 2017 Jean-Claude Michelou + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +#ifndef COAP_DTLS_INTERNAL_H_ +#define COAP_DTLS_INTERNAL_H_ + +/** + * @defgroup dtls_internal DTLS Support (Internal) + * CoAP DTLS Structures, Enums and Functions that are not exposed to + * applications + * @{ + */ + +/* https://tools.ietf.org/html/rfc6347#section-4.2.4.1 */ +#ifndef COAP_DTLS_RETRANSMIT_MS +#define COAP_DTLS_RETRANSMIT_MS 1000 +#endif +#ifndef COAP_DTLS_RETRANSMIT_TOTAL_MS +#define COAP_DTLS_RETRANSMIT_TOTAL_MS 60000 +#endif + +#define COAP_DTLS_RETRANSMIT_COAP_TICKS (COAP_DTLS_RETRANSMIT_MS * COAP_TICKS_PER_SECOND / 1000) + +/** + * Creates a new DTLS context for the given @p coap_context. This function + * returns a pointer to a new DTLS context object or @c NULL on error. + * + * @param coap_context The CoAP context where the DTLS object shall be used. + * + * @return A DTLS context object or @c NULL on error. + */ +void * +coap_dtls_new_context(coap_context_t *coap_context); + +/** + * Set the DTLS context's default server PSK information. + * This does the PSK specifics following coap_dtls_new_context(). + * + * @param coap_context The CoAP context. + * @param setup_data A structure containing setup data originally passed into + * coap_context_set_psk2(). + * + * @return @c 1 if successful, else @c 0. + */ + +int +coap_dtls_context_set_spsk(coap_context_t *coap_context, + coap_dtls_spsk_t *setup_data); + +/** + * Set the DTLS context's default client PSK information. + * This does the PSK specifics following coap_dtls_new_context(). + * + * @param coap_context The CoAP context. + * @param setup_data A structure containing setup data originally passed into + * coap_new_client_session_psk2(). + * + * @return @c 1 if successful, else @c 0. + */ + +int +coap_dtls_context_set_cpsk(coap_context_t *coap_context, + coap_dtls_cpsk_t *setup_data); + +/** + * Set the DTLS context's default server PKI information. + * This does the PKI specifics following coap_dtls_new_context(). + * If @p COAP_DTLS_ROLE_SERVER, then the information will get put into the + * TLS library's context (from which sessions are derived). + * If @p COAP_DTLS_ROLE_CLIENT, then the information will get put into the + * TLS library's session. + * + * @param coap_context The CoAP context. + * @param setup_data Setup information defining how PKI is to be setup. + * Required parameter. If @p NULL, PKI will not be + * set up. + * @param role One of @p COAP_DTLS_ROLE_CLIENT or @p COAP_DTLS_ROLE_SERVER + * + * @return @c 1 if successful, else @c 0. + */ + +int +coap_dtls_context_set_pki(coap_context_t *coap_context, + const coap_dtls_pki_t *setup_data, + const coap_dtls_role_t role); + +/** + * Set the dtls context's default Root CA information for a client or server. + * + * @param coap_context The current coap_context_t object. + * @param ca_file If not @p NULL, is the full path name of a PEM encoded + * file containing all the Root CAs to be used. + * @param ca_dir If not @p NULL, points to a directory containing PEM + * encoded files containing all the Root CAs to be used. + * + * @return @c 1 if successful, else @c 0. + */ + +int +coap_dtls_context_set_pki_root_cas(coap_context_t *coap_context, + const char *ca_file, + const char *ca_dir); + +/** + * Check whether one of the coap_dtls_context_set_{psk|pki}() functions have + * been called. + * + * @param coap_context The current coap_context_t object. + * + * @return @c 1 if coap_dtls_context_set_{psk|pki}() called, else @c 0. + */ + +int coap_dtls_context_check_keys_enabled(coap_context_t *coap_context); + +/** + * Releases the storage allocated for @p dtls_context. + * + * @param dtls_context The DTLS context as returned by coap_dtls_new_context(). + */ +void coap_dtls_free_context(void *dtls_context); + +/** + * Create a new client-side session. This should send a HELLO to the server. + * + * @param coap_session The CoAP session. + * + * @return Opaque handle to underlying TLS library object containing security + * parameters for the session. +*/ +void *coap_dtls_new_client_session(coap_session_t *coap_session); + +/** + * Create a new DTLS server-side session. + * Called after coap_dtls_hello() has returned @c 1, signalling that a validated + * HELLO was received from a client. + * This should send a HELLO to the server. + * + * @param coap_session The CoAP session. + * + * @return Opaque handle to underlying TLS library object containing security + * parameters for the DTLS session. + */ +void *coap_dtls_new_server_session(coap_session_t *coap_session); + +/** + * Terminates the DTLS session (may send an ALERT if necessary) then frees the + * underlying TLS library object containing security parameters for the session. + * + * @param coap_session The CoAP session. + */ +void coap_dtls_free_session(coap_session_t *coap_session); + +/** + * Notify of a change in the CoAP session's MTU, for example after + * a PMTU update. + * + * @param coap_session The CoAP session. + */ +void coap_dtls_session_update_mtu(coap_session_t *coap_session); + +/** + * Send data to a DTLS peer. + * + * @param coap_session The CoAP session. + * @param data pointer to data. + * @param data_len Number of bytes to send. + * + * @return @c 0 if this would be blocking, @c -1 if there is an error or the + * number of cleartext bytes sent. + */ +int coap_dtls_send(coap_session_t *coap_session, + const uint8_t *data, + size_t data_len); + +/** + * Check if timeout is handled per CoAP session or per CoAP context. + * + * @return @c 1 of timeout and retransmit is per context, @c 0 if it is + * per session. + */ +int coap_dtls_is_context_timeout(void); + +/** + * Do all pending retransmits and get next timeout + * + * @param dtls_context The DTLS context. + * + * @return @c 0 if no event is pending or date of the next retransmit. + */ +coap_tick_t coap_dtls_get_context_timeout(void *dtls_context); + +/** + * Get next timeout for this session. + * + * @param coap_session The CoAP session. + * @param now The current time in ticks. + * + * @return @c 0 If no event is pending or ticks time of the next retransmit. + */ +coap_tick_t coap_dtls_get_timeout(coap_session_t *coap_session, + coap_tick_t now); + +/** + * Handle a DTLS timeout expiration. + * + * @param coap_session The CoAP session. + */ +void coap_dtls_handle_timeout(coap_session_t *coap_session); + +/** + * Handling incoming data from a DTLS peer. + * + * @param coap_session The CoAP session. + * @param data Encrypted datagram. + * @param data_len Encrypted datagram size. + * + * @return Result of coap_handle_dgram on the decrypted CoAP PDU + * or @c -1 for error. + */ +int coap_dtls_receive(coap_session_t *coap_session, + const uint8_t *data, + size_t data_len); + +/** + * Handling client HELLO messages from a new candiate peer. + * Note that session->tls is empty. + * + * @param coap_session The CoAP session. + * @param data Encrypted datagram. + * @param data_len Encrypted datagram size. + * + * @return @c 0 if a cookie verification message has been sent, @c 1 if the + * HELLO contains a valid cookie and a server session should be created, + * @c -1 if the message is invalid. + */ +int coap_dtls_hello(coap_session_t *coap_session, + const uint8_t *data, + size_t data_len); + +/** + * Get DTLS overhead over cleartext PDUs. + * + * @param coap_session The CoAP session. + * + * @return Maximum number of bytes added by DTLS layer. + */ +unsigned int coap_dtls_get_overhead(coap_session_t *coap_session); + +/** + * Create a new TLS client-side session. + * + * @param coap_session The CoAP session. + * @param connected Updated with whether the connection is connected yet or not. + * @c 0 is not connected, @c 1 is connected. + * + * @return Opaque handle to underlying TLS library object containing security + * parameters for the session. +*/ +void *coap_tls_new_client_session(coap_session_t *coap_session, int *connected); + +/** + * Create a TLS new server-side session. + * + * @param coap_session The CoAP session. + * @param connected Updated with whether the connection is connected yet or not. + * @c 0 is not connected, @c 1 is connected. + * + * @return Opaque handle to underlying TLS library object containing security + * parameters for the session. + */ +void *coap_tls_new_server_session(coap_session_t *coap_session, int *connected); + +/** + * Terminates the TLS session (may send an ALERT if necessary) then frees the + * underlying TLS library object containing security parameters for the session. + * + * @param coap_session The CoAP session. + */ +void coap_tls_free_session( coap_session_t *coap_session ); + +/** + * Send data to a TLS peer, with implicit flush. + * + * @param coap_session The CoAP session. + * @param data Pointer to data. + * @param data_len Number of bytes to send. + * + * @return @c 0 if this should be retried, @c -1 if there is an error + * or the number of cleartext bytes sent. + */ +ssize_t coap_tls_write(coap_session_t *coap_session, + const uint8_t *data, + size_t data_len + ); + +/** + * Read some data from a TLS peer. + * + * @param coap_session The CoAP session. + * @param data Pointer to data. + * @param data_len Maximum number of bytes to read. + * + * @return @c 0 if this should be retried, @c -1 if there is an error + * or the number of cleartext bytes read. + */ +ssize_t coap_tls_read(coap_session_t *coap_session, + uint8_t *data, + size_t data_len + ); + +/** + * Initialize the underlying (D)TLS Library layer. + * + */ +void coap_dtls_startup(void); + +/** + * Close down the underlying (D)TLS Library layer. + * + */ +void coap_dtls_shutdown(void); + +/** + * Get the actual (D)TLS object for the session. + * + * @param session The session. + * @param tls_lib Updated with the library type. + * + * @return The TLS information. + */ +void *coap_dtls_get_tls(const coap_session_t *session, + coap_tls_library_t *tls_lib); + +/** @} */ + +#endif /* COAP_DTLS_INTERNAL_H */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/coap_event.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_event.h similarity index 79% rename from tools/sdk/esp32c3/include/coap/libcoap/include/coap2/coap_event.h rename to tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_event.h index 81a3b0511fd..89b2a63967c 100644 --- a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/coap_event.h +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_event.h @@ -3,6 +3,8 @@ * * Copyright (C) 2016 Olaf Bergmann * + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ @@ -12,9 +14,6 @@ #include "libcoap.h" -struct coap_context_t; -struct coap_session_t; - /** * @defgroup events Event API * API functions for event delivery from lower-layer library functions. @@ -49,17 +48,20 @@ struct coap_session_t; #define COAP_EVENT_SESSION_CLOSED 0x2002 #define COAP_EVENT_SESSION_FAILED 0x2003 +/** + * BLOCK2 receive errors + */ +#define COAP_EVENT_PARTIAL_BLOCK 0x3001 + /** * Type for event handler functions that can be registered with a CoAP * context using the unction coap_set_event_handler(). When called by - * the library, the first argument will be the coap_context_t object - * where the handler function has been registered. The second argument - * is the event type that may be complemented by event-specific data - * passed as the third argument. + * the library, the first argument will be the current coap_session_t object + * which is associated with the original CoAP context. The second parameter + * is the event type. */ -typedef int (*coap_event_handler_t)(struct coap_context_t *, - coap_event_t event, - struct coap_session_t *session); +typedef int (*coap_event_handler_t)(coap_session_t *session, + const coap_event_t event); /** * Registers the function @p hnd as callback for events from the given @@ -70,9 +72,11 @@ typedef int (*coap_event_handler_t)(struct coap_context_t *, * @param hnd The event handler to be registered. @c NULL if to be * de-registered. */ -void coap_register_event_handler(struct coap_context_t *context, +void coap_register_event_handler(coap_context_t *context, coap_event_handler_t hnd); +/** @} */ + /** * Registers the function @p hnd as callback for events from the given * CoAP context @p context. Any event handler that has previously been @@ -84,7 +88,7 @@ void coap_register_event_handler(struct coap_context_t *context, * @param hnd The event handler to be registered. */ COAP_DEPRECATED -void coap_set_event_handler(struct coap_context_t *context, +void coap_set_event_handler(coap_context_t *context, coap_event_handler_t hnd); /** @@ -95,8 +99,6 @@ void coap_set_event_handler(struct coap_context_t *context, * @param context The CoAP context whose event handler is to be removed. */ COAP_DEPRECATED -void coap_clear_event_handler(struct coap_context_t *context); - -/** @} */ +void coap_clear_event_handler(coap_context_t *context); #endif /* COAP_EVENT_H */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_forward_decls.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_forward_decls.h new file mode 100644 index 00000000000..3bedbf7899a --- /dev/null +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_forward_decls.h @@ -0,0 +1,107 @@ +/* + * coap_forward_decls.h -- Forward declarations of structures that are + * opaque to application programming that use libcoap. + * + * Copyright (C) 2019-2021 Jon Shallow + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_forward_decls.h + * @brief COAP forward definitions + */ + +#ifndef COAP_FORWARD_DECLS_H_ +#define COAP_FORWARD_DECLS_H_ + +/* + * Define the forward declations for the structures (even non-opaque) + * so that applications (using coap.h) as well as libcoap builds + * can reference them (and makes .h file dependencies a lot simpler). + */ +struct coap_address_t; +struct coap_bin_const_t; +struct coap_dtls_pki_t; +struct coap_str_const_t; +struct coap_string_t; + +/* + * typedef all the opaque structures that are defined in coap_*_internal.h + */ + +/* ************* coap_async_internal.h ***************** */ + +/** + * Async Entry information. + */ +typedef struct coap_async_t coap_async_t; + +/* ************* coap_block_internal.h ***************** */ + +/* + * Block handling information. + */ +typedef struct coap_lg_xmit_t coap_lg_xmit_t; +typedef struct coap_lg_crcv_t coap_lg_crcv_t; +typedef struct coap_lg_srcv_t coap_lg_srcv_t; + +/* ************* coap_cache_internal.h ***************** */ + +/* + * Cache Entry information. + */ +typedef struct coap_cache_entry_t coap_cache_entry_t; +typedef struct coap_cache_key_t coap_cache_key_t; + +/* ************* coap_io_internal.h ***************** */ + +/** + * coap_socket_t and coap_packet_t information. + */ +typedef struct coap_packet_t coap_packet_t; +typedef struct coap_socket_t coap_socket_t; + +/* ************* coap_net_internal.h ***************** */ + +/* + * Net information. + */ +typedef struct coap_context_t coap_context_t; +typedef struct coap_queue_t coap_queue_t; + +/* ************* coap_pdu_internal.h ***************** */ + +/** + * PDU information. + */ +typedef struct coap_pdu_t coap_pdu_t; + +/* ************* coap_resource_internal.h ***************** */ + +/* + * Resource information. + */ +typedef struct coap_attr_t coap_attr_t; +typedef struct coap_resource_t coap_resource_t; + +/* ************* coap_session_internal.h ***************** */ + +/* + * Session information. + */ +typedef struct coap_addr_hash_t coap_addr_hash_t; +typedef struct coap_endpoint_t coap_endpoint_t; +typedef struct coap_session_t coap_session_t; + +/* ************* coap_subscribe_internal.h ***************** */ + +/* + * Observe subscriber information. + */ +typedef struct coap_subscription_t coap_subscription_t; + +#endif /* COAP_FORWARD_DECLS_H_ */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/coap_hashkey.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_hashkey.h similarity index 93% rename from tools/sdk/esp32c3/include/coap/libcoap/include/coap2/coap_hashkey.h rename to tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_hashkey.h index 252f34822d4..11a797bde7a 100644 --- a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/coap_hashkey.h +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_hashkey.h @@ -3,6 +3,8 @@ * * Copyright (C) 2010-2011 Olaf Bergmann * + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ @@ -31,7 +33,7 @@ typedef unsigned char coap_key_t[4]; * @param len The length of @p s. * @param h The result buffer to store the calculated hash key. */ -void coap_hash_impl(const unsigned char *s, unsigned int len, coap_key_t h); +void coap_hash_impl(const unsigned char *s, size_t len, coap_key_t h); #define coap_hash(String,Length,Result) \ coap_hash_impl((String),(Length),(Result)) diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_internal.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_internal.h new file mode 100644 index 00000000000..5eee5c12867 --- /dev/null +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_internal.h @@ -0,0 +1,65 @@ +/* + * coap_internal.h -- Structures, Enums & Functions that are not exposed to + * application programming + * + * Copyright (C) 2019-2021 Jon Shallow + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/* + * All libcoap library files should include this file which then pulls in all + * of the other appropriate header files. + * + * Note: This file should never be included in application code (with the + * possible exception of internal test suites). + */ + +/** + * @file coap_internal.h + * @brief Pulls together all the internal only header files + */ + +#ifndef COAP_INTERNAL_H_ +#define COAP_INTERNAL_H_ + +#include "coap_config.h" + +/* + * Correctly set up assert() based on NDEBUG for libcoap + */ +#if defined(HAVE_ASSERT_H) && !defined(assert) +# include +#endif + +#include "coap3/coap.h" + +/* + * Include all the header files that are for internal use only. + */ + +/* Not defined in coap.h - internal usage .h files */ +#include "utlist.h" +#include "uthash.h" +#include "coap_hashkey.h" +#include "coap_mutex.h" + +/* Specifically defined internal .h files */ +#include "coap_asn1_internal.h" +#include "coap_async_internal.h" +#include "coap_block_internal.h" +#include "coap_cache_internal.h" +#include "coap_dtls_internal.h" +#include "coap_io_internal.h" +#include "coap_net_internal.h" +#include "coap_pdu_internal.h" +#include "coap_session_internal.h" +#include "coap_resource_internal.h" +#include "coap_session_internal.h" +#include "coap_subscribe_internal.h" +#include "coap_tcp_internal.h" + +#endif /* COAP_INTERNAL_H_ */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_io.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_io.h new file mode 100644 index 00000000000..b27921f8be1 --- /dev/null +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_io.h @@ -0,0 +1,72 @@ +/* + * coap_io.h -- Default network I/O functions for libcoap + * + * Copyright (C) 2012-2013 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +#ifndef COAP_IO_H_ +#define COAP_IO_H_ + +#include + +#include "address.h" + +#ifdef RIOT_VERSION +#include "net/gnrc.h" +#endif /* RIOT_VERSION */ + +#ifndef COAP_RXBUFFER_SIZE +#define COAP_RXBUFFER_SIZE 1472 +#endif /* COAP_RXBUFFER_SIZE */ + +/* + * It may may make sense to define this larger on busy systems + * (lots of sessions, large number of which are active), by using + * -DCOAP_MAX_EPOLL_EVENTS=nn at compile time. + */ +#ifndef COAP_MAX_EPOLL_EVENTS +#define COAP_MAX_EPOLL_EVENTS 10 +#endif /* COAP_MAX_EPOLL_EVENTS */ + +#ifdef _WIN32 +typedef SOCKET coap_fd_t; +#define coap_closesocket closesocket +#define COAP_SOCKET_ERROR SOCKET_ERROR +#define COAP_INVALID_SOCKET INVALID_SOCKET +#else +typedef int coap_fd_t; +#define coap_closesocket close +#define COAP_SOCKET_ERROR (-1) +#define COAP_INVALID_SOCKET (-1) +#endif + +typedef uint16_t coap_socket_flags_t; + +typedef struct coap_addr_tuple_t { + coap_address_t remote; /**< remote address and port */ + coap_address_t local; /**< local address and port */ +} coap_addr_tuple_t; + +const char *coap_socket_strerror( void ); + +/** + * Check whether TCP is available. + * + * @return @c 1 if support for TCP is enabled, or @c 0 otherwise. + */ +int coap_tcp_is_supported(void); + +typedef enum { + COAP_NACK_TOO_MANY_RETRIES, + COAP_NACK_NOT_DELIVERABLE, + COAP_NACK_RST, + COAP_NACK_TLS_FAILED, + COAP_NACK_ICMP_ISSUE +} coap_nack_reason_t; + +#endif /* COAP_IO_H_ */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap2/coap_io.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_io_internal.h similarity index 62% rename from tools/sdk/esp32/include/coap/libcoap/include/coap2/coap_io.h rename to tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_io_internal.h index 1854501be89..241ef7f9955 100644 --- a/tools/sdk/esp32/include/coap/libcoap/include/coap2/coap_io.h +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_io_internal.h @@ -3,41 +3,24 @@ * * Copyright (C) 2012-2013 Olaf Bergmann * + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ -#ifndef COAP_IO_H_ -#define COAP_IO_H_ +#ifndef COAP_IO_INTERNAL_H_ +#define COAP_IO_INTERNAL_H_ -#include #include #include "address.h" -#ifndef COAP_RXBUFFER_SIZE -#define COAP_RXBUFFER_SIZE 1472 -#endif /* COAP_RXBUFFER_SIZE */ - -#ifdef _WIN32 -typedef SOCKET coap_fd_t; -#define coap_closesocket closesocket -#define COAP_SOCKET_ERROR SOCKET_ERROR -#define COAP_INVALID_SOCKET INVALID_SOCKET -#else -typedef int coap_fd_t; -#define coap_closesocket close -#define COAP_SOCKET_ERROR (-1) -#define COAP_INVALID_SOCKET (-1) -#endif - -struct coap_packet_t; -struct coap_session_t; -struct coap_pdu_t; +#ifdef RIOT_VERSION +#include "net/gnrc.h" +#endif /* RIOT_VERSION */ -typedef uint16_t coap_socket_flags_t; - -typedef struct coap_socket_t { +struct coap_socket_t { #if defined(WITH_LWIP) struct udp_pcb *pcb; #elif defined(WITH_CONTIKI) @@ -45,8 +28,14 @@ typedef struct coap_socket_t { #else coap_fd_t fd; #endif /* WITH_LWIP */ +#if defined(RIOT_VERSION) + gnrc_pktsnip_t *pkt; /* pointer to received packet for processing */ +#endif /* RIOT_VERSION */ coap_socket_flags_t flags; -} coap_socket_t; + coap_session_t *session; /* Used by the epoll logic for an active session. */ + coap_endpoint_t *endpoint; /* Used by the epoll logic for a listening + endpoint. */ +}; /** * coap_socket_flags_t values @@ -65,8 +54,10 @@ typedef struct coap_socket_t { #define COAP_SOCKET_CAN_CONNECT 0x0800 /**< non blocking client socket can now connect without blocking */ #define COAP_SOCKET_MULTICAST 0x1000 /**< socket is used for multicast communication */ -struct coap_endpoint_t *coap_malloc_endpoint( void ); -void coap_mfree_endpoint( struct coap_endpoint_t *ep ); +coap_endpoint_t *coap_malloc_endpoint( void ); +void coap_mfree_endpoint( coap_endpoint_t *ep ); + +const char *coap_socket_format_errno(int error); int coap_socket_connect_udp(coap_socket_t *sock, @@ -81,34 +72,10 @@ coap_socket_bind_udp(coap_socket_t *sock, const coap_address_t *listen_addr, coap_address_t *bound_addr ); -int -coap_socket_connect_tcp1(coap_socket_t *sock, - const coap_address_t *local_if, - const coap_address_t *server, - int default_port, - coap_address_t *local_addr, - coap_address_t *remote_addr); - -int -coap_socket_connect_tcp2(coap_socket_t *sock, - coap_address_t *local_addr, - coap_address_t *remote_addr); - -int -coap_socket_bind_tcp(coap_socket_t *sock, - const coap_address_t *listen_addr, - coap_address_t *bound_addr); - -int -coap_socket_accept_tcp(coap_socket_t *server, - coap_socket_t *new_client, - coap_address_t *local_addr, - coap_address_t *remote_addr); - void coap_socket_close(coap_socket_t *sock); ssize_t -coap_socket_send( coap_socket_t *sock, struct coap_session_t *session, +coap_socket_send( coap_socket_t *sock, coap_session_t *session, const uint8_t *data, size_t data_len ); ssize_t @@ -117,14 +84,15 @@ coap_socket_write(coap_socket_t *sock, const uint8_t *data, size_t data_len); ssize_t coap_socket_read(coap_socket_t *sock, uint8_t *data, size_t data_len); +void +coap_epoll_ctl_mod(coap_socket_t *sock, uint32_t events, const char *func); + #ifdef WITH_LWIP ssize_t -coap_socket_send_pdu( coap_socket_t *sock, struct coap_session_t *session, - struct coap_pdu_t *pdu ); +coap_socket_send_pdu( coap_socket_t *sock, coap_session_t *session, + coap_pdu_t *pdu ); #endif -const char *coap_socket_strerror( void ); - /** * Function interface for data transmission. This function returns the number of * bytes that have been transmitted, or a value less than zero on error. @@ -137,7 +105,7 @@ const char *coap_socket_strerror( void ); * @return The number of bytes written on success, or a value * less than zero on error. */ -ssize_t coap_network_send( coap_socket_t *sock, const struct coap_session_t *session, const uint8_t *data, size_t datalen ); +ssize_t coap_network_send( coap_socket_t *sock, const coap_session_t *session, const uint8_t *data, size_t datalen ); /** * Function interface for reading data. This function returns the number of @@ -150,7 +118,7 @@ ssize_t coap_network_send( coap_socket_t *sock, const struct coap_session_t *ses * @return The number of bytes received on success, or a value less than * zero on error. */ -ssize_t coap_network_read( coap_socket_t *sock, struct coap_packet_t *packet ); +ssize_t coap_network_read( coap_socket_t *sock, coap_packet_t *packet ); #ifndef coap_mcast_interface # define coap_mcast_interface(Local) 0 @@ -160,7 +128,7 @@ ssize_t coap_network_read( coap_socket_t *sock, struct coap_packet_t *packet ); * Given a packet, set msg and msg_len to an address and length of the packet's * data in memory. * */ -void coap_packet_get_memmapped(struct coap_packet_t *packet, +void coap_packet_get_memmapped(coap_packet_t *packet, unsigned char **address, size_t *length); @@ -169,7 +137,7 @@ void coap_packet_get_memmapped(struct coap_packet_t *packet, * Get the pbuf of a packet. The caller takes over responsibility for freeing * the pbuf. */ -struct pbuf *coap_packet_extract_pbuf(struct coap_packet_t *packet); +struct pbuf *coap_packet_extract_pbuf(coap_packet_t *packet); #endif #if defined(WITH_LWIP) @@ -183,28 +151,18 @@ struct pbuf *coap_packet_extract_pbuf(struct coap_packet_t *packet); */ struct coap_packet_t { struct pbuf *pbuf; - const struct coap_endpoint_t *local_interface; - coap_address_t src; /**< the packet's source address */ - coap_address_t dst; /**< the packet's destination address */ + const coap_endpoint_t *local_interface; + coap_addr_tuple_t addr_info; /**< local and remote addresses */ int ifindex; /**< the interface index */ // uint16_t srcport; }; #else struct coap_packet_t { - coap_address_t src; /**< the packet's source address */ - coap_address_t dst; /**< the packet's destination address */ + coap_addr_tuple_t addr_info; /**< local and remote addresses */ int ifindex; /**< the interface index */ size_t length; /**< length of payload */ unsigned char payload[COAP_RXBUFFER_SIZE]; /**< payload */ }; #endif -typedef struct coap_packet_t coap_packet_t; - -typedef enum { - COAP_NACK_TOO_MANY_RETRIES, - COAP_NACK_NOT_DELIVERABLE, - COAP_NACK_RST, - COAP_NACK_TLS_FAILED -} coap_nack_reason_t; -#endif /* COAP_IO_H_ */ +#endif /* COAP_IO_INTERNAL_H_ */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap2/coap_mutex.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_mutex.h similarity index 63% rename from tools/sdk/esp32/include/coap/libcoap/include/coap2/coap_mutex.h rename to tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_mutex.h index 99d7d335e47..44084fecb1c 100644 --- a/tools/sdk/esp32/include/coap/libcoap/include/coap2/coap_mutex.h +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_mutex.h @@ -2,6 +2,9 @@ * coap_mutex.h -- mutex utilities * * Copyright (C) 2019 Jon Shallow + * 2019 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause * * This file is part of the CoAP library libcoap. Please see README for terms * of use. @@ -15,8 +18,24 @@ #ifndef COAP_MUTEX_H_ #define COAP_MUTEX_H_ -#if defined(RIOT_VERSION) +/* + * Mutexes are currently only used if there is a constrained stack, + * and large static variables (instead of the large variable being on + * the stack) need to be protected. + */ +#if COAP_CONSTRAINED_STACK + +#if defined(HAVE_PTHREAD_H) && defined(HAVE_PTHREAD_MUTEX_LOCK) +#include + +typedef pthread_mutex_t coap_mutex_t; +#define COAP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER +#define coap_mutex_lock(a) pthread_mutex_lock(a) +#define coap_mutex_trylock(a) pthread_mutex_trylock(a) +#define coap_mutex_unlock(a) pthread_mutex_unlock(a) +#elif defined(RIOT_VERSION) +/* use RIOT's mutex API */ #include typedef mutex_t coap_mutex_t; @@ -25,26 +44,16 @@ typedef mutex_t coap_mutex_t; #define coap_mutex_trylock(a) mutex_trylock(a) #define coap_mutex_unlock(a) mutex_unlock(a) -#elif defined(WITH_CONTIKI) - -/* CONTIKI does not support mutex */ - +#else +/* define stub mutex functions */ typedef int coap_mutex_t; #define COAP_MUTEX_INITIALIZER 0 #define coap_mutex_lock(a) *(a) = 1 #define coap_mutex_trylock(a) *(a) = 1 #define coap_mutex_unlock(a) *(a) = 0 -#else /* ! RIOT_VERSION && ! WITH_CONTIKI */ - -#include - -typedef pthread_mutex_t coap_mutex_t; -#define COAP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER -#define coap_mutex_lock(a) pthread_mutex_lock(a) -#define coap_mutex_trylock(a) pthread_mutex_trylock(a) -#define coap_mutex_unlock(a) pthread_mutex_unlock(a) +#endif /* !RIOT_VERSION && !HAVE_PTHREAD_H && !HAVE_PTHREAD_MUTEX_LOCK */ -#endif /* ! RIOT_VERSION && ! WITH_CONTIKI */ +#endif /* COAP_CONSTRAINED_STACK */ #endif /* COAP_MUTEX_H_ */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_net_internal.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_net_internal.h new file mode 100644 index 00000000000..bf243f3d022 --- /dev/null +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_net_internal.h @@ -0,0 +1,366 @@ +/* + * coap_context_internal.h -- Structures, Enums & Functions that are not + * exposed to application programming + * + * Copyright (C) 2010-2021 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_net_internal.h + * @brief COAP net internal information + */ + +#ifndef COAP_NET_INTERNAL_H_ +#define COAP_NET_INTERNAL_H_ + +/** + * @defgroup context_internal Context Handling (Internal) + * CoAP Context Structures, Enums and Functions that are not exposed to + * applications + * @{ + */ + +/** + * Queue entry + */ +struct coap_queue_t { + struct coap_queue_t *next; + coap_tick_t t; /**< when to send PDU for the next time */ + unsigned char retransmit_cnt; /**< retransmission counter, will be removed + * when zero */ + unsigned int timeout; /**< the randomized timeout value */ + coap_session_t *session; /**< the CoAP session */ + coap_mid_t id; /**< CoAP message id */ + coap_pdu_t *pdu; /**< the CoAP PDU to send */ +}; + +/** + * The CoAP stack's global state is stored in a coap_context_t object. + */ +struct coap_context_t { + coap_opt_filter_t known_options; + coap_resource_t *resources; /**< hash table or list of known + resources */ + coap_resource_t *unknown_resource; /**< can be used for handling + unknown resources */ + coap_resource_t *proxy_uri_resource; /**< can be used for handling + proxy URI resources */ + coap_resource_release_userdata_handler_t release_userdata; + /**< function to release user_data + when resource is deleted */ + +#ifndef WITHOUT_ASYNC + /** + * list of asynchronous message ids */ + coap_async_t *async_state; +#endif /* WITHOUT_ASYNC */ + + /** + * The time stamp in the first element of the sendqeue is relative + * to sendqueue_basetime. */ + coap_tick_t sendqueue_basetime; + coap_queue_t *sendqueue; + coap_endpoint_t *endpoint; /**< the endpoints used for listening */ + coap_session_t *sessions; /**< client sessions */ + +#ifdef WITH_CONTIKI + struct uip_udp_conn *conn; /**< uIP connection object */ + struct etimer retransmit_timer; /**< fires when the next packet must be + sent */ + struct etimer notify_timer; /**< used to check resources periodically */ +#endif /* WITH_CONTIKI */ + +#ifdef WITH_LWIP + uint8_t timer_configured; /**< Set to 1 when a retransmission is + * scheduled using lwIP timers for this + * context, otherwise 0. */ +#endif /* WITH_LWIP */ + + coap_response_handler_t response_handler; + coap_nack_handler_t nack_handler; + coap_ping_handler_t ping_handler; + coap_pong_handler_t pong_handler; + + /** + * Callback function that is used to signal events to the + * application. This field is set by coap_set_event_handler(). + */ + coap_event_handler_t handle_event; + + ssize_t (*network_send)(coap_socket_t *sock, const coap_session_t *session, + const uint8_t *data, size_t datalen); + + ssize_t (*network_read)(coap_socket_t *sock, coap_packet_t *packet); + + size_t(*get_client_psk)(const coap_session_t *session, const uint8_t *hint, + size_t hint_len, uint8_t *identity, + size_t *identity_len, size_t max_identity_len, + uint8_t *psk, size_t max_psk_len); + size_t(*get_server_psk)(const coap_session_t *session, + const uint8_t *identity, size_t identity_len, + uint8_t *psk, size_t max_psk_len); + size_t(*get_server_hint)(const coap_session_t *session, uint8_t *hint, + size_t max_hint_len); + + void *dtls_context; + + coap_dtls_spsk_t spsk_setup_data; /**< Contains the initial PSK server setup + data */ + + unsigned int session_timeout; /**< Number of seconds of inactivity after + which an unused session will be closed. + 0 means use default. */ + unsigned int max_idle_sessions; /**< Maximum number of simultaneous unused + sessions per endpoint. 0 means no + maximum. */ + unsigned int max_handshake_sessions; /**< Maximum number of simultaneous + negotating sessions per endpoint. 0 + means use default. */ + unsigned int ping_timeout; /**< Minimum inactivity time before + sending a ping message. 0 means + disabled. */ + unsigned int csm_timeout; /**< Timeout for waiting for a CSM from + the remote side. 0 means disabled. */ + uint8_t observe_pending; /**< Observe response pending */ + uint8_t block_mode; /**< Zero or more COAP_BLOCK_ or'd options */ + uint64_t etag; /**< Next ETag to use */ + + coap_cache_entry_t *cache; /**< CoAP cache-entry cache */ + uint16_t *cache_ignore_options; /**< CoAP options to ignore when creating a + cache-key */ + size_t cache_ignore_count; /**< The number of CoAP options to ignore + when creating a cache-key */ + void *app; /**< application-specific data */ +#ifdef COAP_EPOLL_SUPPORT + int epfd; /**< External FD for epoll */ + int eptimerfd; /**< Internal FD for timeout */ + coap_tick_t next_timeout; /**< When the next timeout is to occur */ +#endif /* COAP_EPOLL_SUPPORT */ +}; + +/** + * Adds @p node to given @p queue, ordered by variable t in @p node. + * + * @param queue Queue to add to. + * @param node Node entry to add to Queue. + * + * @return @c 1 added to queue, @c 0 failure. + */ +int coap_insert_node(coap_queue_t **queue, coap_queue_t *node); + +/** + * Destroys specified @p node. + * + * @param node Node entry to remove. + * + * @return @c 1 node deleted from queue, @c 0 failure. + */ +int coap_delete_node(coap_queue_t *node); + +/** + * Removes all items from given @p queue and frees the allocated storage. + * + * Internal function. + * + * @param queue The queue to delete. + */ +void coap_delete_all(coap_queue_t *queue); + +/** + * Creates a new node suitable for adding to the CoAP sendqueue. + * + * @return New node entry, or @c NULL if failure. + */ +coap_queue_t *coap_new_node(void); + +/** + * Set sendqueue_basetime in the given context object @p ctx to @p now. This + * function returns the number of elements in the queue head that have timed + * out. + */ +unsigned int coap_adjust_basetime(coap_context_t *ctx, coap_tick_t now); + +/** + * Returns the next pdu to send without removing from sendqeue. + */ +coap_queue_t *coap_peek_next( coap_context_t *context ); + +/** + * Returns the next pdu to send and removes it from the sendqeue. + */ +coap_queue_t *coap_pop_next( coap_context_t *context ); + +/** + * Handles retransmissions of confirmable messages + * + * @param context The CoAP context. + * @param node The node to retransmit. + * + * @return The message id of the sent message or @c + * COAP_INVALID_MID on error. + */ +coap_mid_t coap_retransmit(coap_context_t *context, coap_queue_t *node); + +/** + * Parses and interprets a CoAP datagram with context @p ctx. This function + * returns @c 0 if the datagram was handled, or a value less than zero on + * error. + * + * @param ctx The current CoAP context. + * @param session The current CoAP session. + * @param data The received packet'd data. + * @param data_len The received packet'd data length. + * + * @return @c 0 if message was handled successfully, or less than zero on + * error. + */ +int coap_handle_dgram(coap_context_t *ctx, coap_session_t *session, uint8_t *data, size_t data_len); + +/** + * This function removes the element with given @p id from the list given list. + * If @p id was found, @p node is updated to point to the removed element. Note + * that the storage allocated by @p node is @b not released. The caller must do + * this manually using coap_delete_node(). This function returns @c 1 if the + * element with id @p id was found, @c 0 otherwise. For a return value of @c 0, + * the contents of @p node is undefined. + * + * @param queue The queue to search for @p id. + * @param session The session to look for. + * @param id The message id to look for. + * @param node If found, @p node is updated to point to the removed node. You + * must release the storage pointed to by @p node manually. + * + * @return @c 1 if @p id was found, @c 0 otherwise. + */ +int coap_remove_from_queue(coap_queue_t **queue, + coap_session_t *session, + coap_mid_t id, + coap_queue_t **node); + +coap_mid_t +coap_wait_ack( coap_context_t *context, coap_session_t *session, + coap_queue_t *node); + +/** + * Cancels all outstanding messages for session @p session that have the specified + * token. + * + * @param context The context in use. + * @param session Session of the messages to remove. + * @param token Message token. + * @param token_length Actual length of @p token. + */ +void coap_cancel_all_messages(coap_context_t *context, + coap_session_t *session, + const uint8_t *token, + size_t token_length); + +/** +* Cancels all outstanding messages for session @p session. +* +* @param context The context in use. +* @param session Session of the messages to remove. +* @param reason The reasion for the session cancellation +*/ +void +coap_cancel_session_messages(coap_context_t *context, + coap_session_t *session, + coap_nack_reason_t reason); + +/** + * Dispatches the PDUs from the receive queue in given context. + */ +void coap_dispatch(coap_context_t *context, coap_session_t *session, + coap_pdu_t *pdu); + +/** + * Verifies that @p pdu contains no unknown critical options. Options must be + * registered at @p ctx, using the function coap_register_option(). A basic set + * of options is registered automatically by coap_new_context(). This function + * returns @c 1 if @p pdu is ok, @c 0 otherwise. The given filter object @p + * unknown will be updated with the unknown options. As only @c COAP_MAX_OPT + * options can be signalled this way, remaining options must be examined + * manually. + * + * @code + coap_opt_filter_t f = COAP_OPT_NONE; + coap_opt_iterator_t opt_iter; + + if (coap_option_check_critical(ctx, pdu, f) == 0) { + coap_option_iterator_init(pdu, &opt_iter, f); + + while (coap_option_next(&opt_iter)) { + if (opt_iter.type & 0x01) { + ... handle unknown critical option in opt_iter ... + } + } + } + @endcode + * + * @param ctx The context where all known options are registered. + * @param pdu The PDU to check. + * @param unknown The output filter that will be updated to indicate the + * unknown critical options found in @p pdu. + * + * @return @c 1 if everything was ok, @c 0 otherwise. + */ +int coap_option_check_critical(coap_context_t *ctx, + coap_pdu_t *pdu, + coap_opt_filter_t *unknown); + +/** + * Creates a new response for given @p request with the contents of @c + * .well-known/core. The result is NULL on error or a newly allocated PDU that + * must be either sent with coap_sent() or released by coap_delete_pdu(). + * + * @param context The current coap context to use. + * @param session The CoAP session. + * @param request The request for @c .well-known/core . + * + * @return A new 2.05 response for @c .well-known/core or NULL on error. + */ +coap_pdu_t *coap_wellknown_response(coap_context_t *context, + coap_session_t *session, + coap_pdu_t *request); + +/** + * Calculates the initial timeout based on the session CoAP transmission + * parameters 'ack_timeout', 'ack_random_factor', and COAP_TICKS_PER_SECOND. + * The calculation requires 'ack_timeout' and 'ack_random_factor' to be in + * Qx.FRAC_BITS fixed point notation, whereas the passed parameter @p r + * is interpreted as the fractional part of a Q0.MAX_BITS random value. + * + * @param session session timeout is associated with + * @param r random value as fractional part of a Q0.MAX_BITS fixed point + * value + * @return COAP_TICKS_PER_SECOND * 'ack_timeout' * + * (1 + ('ack_random_factor' - 1) * r) + */ +unsigned int coap_calc_timeout(coap_session_t *session, unsigned char r); + +/** + * Sends a CoAP message to given peer. The memory that is + * allocated for the pdu will be released by coap_send_internal(). + * The caller must not use the pdu after calling coap_send_internal(). + * + * If the response body is split into multiple payloads using blocks, libcoap + * will handle asking for the subsequent blocks and any necessary recovery + * needed. + * + * @param session The CoAP session. + * @param pdu The CoAP PDU to send. + * + * @return The message id of the sent message or @c + * COAP_INVALID_MID on error. + */ +coap_mid_t coap_send_internal(coap_session_t *session, coap_pdu_t *pdu); + +/** @} */ + +#endif /* COAP_NET_INTERNAL_H_ */ + diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_pdu_internal.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_pdu_internal.h new file mode 100644 index 00000000000..0d8446c0d4c --- /dev/null +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_pdu_internal.h @@ -0,0 +1,300 @@ +/* + * coap_pdu_internal.h -- CoAP PDU structure + * + * Copyright (C) 2010-2021 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_pdu_internal.h + * @brief CoAP PDU internal information + */ + +#ifndef COAP_COAP_PDU_INTERNAL_H_ +#define COAP_COAP_PDU_INTERNAL_H_ + +#ifdef WITH_LWIP +#include +#endif + +#include + +/** + * @defgroup pdu_internal PDU (Internal) + * CoAP PDU Structures, Enums and Functions that are not exposed to + * applications + * @{ + */ + +#define COAP_DEFAULT_VERSION 1 /* version of CoAP supported */ + +/* TCP Message format constants, do not modify */ +#define COAP_MESSAGE_SIZE_OFFSET_TCP8 13 +#define COAP_MESSAGE_SIZE_OFFSET_TCP16 269 /* 13 + 256 */ +#define COAP_MESSAGE_SIZE_OFFSET_TCP32 65805 /* 269 + 65536 */ + +/* Derived message size limits */ +#define COAP_MAX_MESSAGE_SIZE_TCP0 (COAP_MESSAGE_SIZE_OFFSET_TCP8-1) /* 12 */ +#define COAP_MAX_MESSAGE_SIZE_TCP8 (COAP_MESSAGE_SIZE_OFFSET_TCP16-1) /* 268 */ +#define COAP_MAX_MESSAGE_SIZE_TCP16 (COAP_MESSAGE_SIZE_OFFSET_TCP32-1) /* 65804 */ +#define COAP_MAX_MESSAGE_SIZE_TCP32 (COAP_MESSAGE_SIZE_OFFSET_TCP32+0xFFFFFFFF) + +#ifndef COAP_DEBUG_BUF_SIZE +#if defined(WITH_CONTIKI) || defined(WITH_LWIP) +#define COAP_DEBUG_BUF_SIZE 128 +#else /* defined(WITH_CONTIKI) || defined(WITH_LWIP) */ +/* 1024 derived from RFC7252 4.6. Message Size max payload */ +#define COAP_DEBUG_BUF_SIZE (8 + 1024 * 2) +#endif /* defined(WITH_CONTIKI) || defined(WITH_LWIP) */ +#endif /* COAP_DEBUG_BUF_SIZE */ + +#ifndef COAP_DEFAULT_MAX_PDU_RX_SIZE +#if defined(WITH_CONTIKI) || defined(WITH_LWIP) +#define COAP_DEFAULT_MAX_PDU_RX_SIZE (COAP_MAX_MESSAGE_SIZE_TCP16+4UL) +#else +/* 8 MiB max-message-size plus some space for options */ +#define COAP_DEFAULT_MAX_PDU_RX_SIZE (8UL*1024*1024+256) +#endif +#endif /* COAP_DEFAULT_MAX_PDU_RX_SIZE */ + +/** + * Indicates that a response is suppressed. This will occur for error + * responses if the request was received via IP multicast. + */ +#define COAP_DROPPED_RESPONSE -2 + +#define COAP_PDU_DELAYED -3 + +#define COAP_PAYLOAD_START 0xFF /* payload marker */ + +#define COAP_PDU_IS_EMPTY(pdu) ((pdu)->code == 0) +#define COAP_PDU_IS_REQUEST(pdu) (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32) +#define COAP_PDU_IS_RESPONSE(pdu) ((pdu)->code >= 64 && (pdu)->code < 224) +#define COAP_PDU_IS_SIGNALING(pdu) ((pdu)->code >= 224) + +#define COAP_PDU_MAX_UDP_HEADER_SIZE 4 +#define COAP_PDU_MAX_TCP_HEADER_SIZE 6 + +/** + * structure for CoAP PDUs + * token, if any, follows the fixed size header, then options until + * payload marker (0xff), then the payload if stored inline. + * Memory layout is: + * <---header--->|<---token---><---options--->0xff<---payload---> + * header is addressed with a negative offset to token, its maximum size is + * max_hdr_size. + * options starts at token + token_length + * payload starts at data, its length is used_size - (data - token) + */ + +struct coap_pdu_t { + coap_pdu_type_t type; /**< message type */ + coap_pdu_code_t code; /**< request method (value 1--31) or response code + (value 64-255) */ + coap_mid_t mid; /**< message id, if any, in regular host byte + order */ + uint8_t max_hdr_size; /**< space reserved for protocol-specific header */ + uint8_t hdr_size; /**< actual size used for protocol-specific + header */ + uint8_t token_length; /**< length of Token */ + uint16_t max_opt; /**< highest option number in PDU */ + size_t alloc_size; /**< allocated storage for token, options and + payload */ + size_t used_size; /**< used bytes of storage for token, options and + payload */ + size_t max_size; /**< maximum size for token, options and payload, + or zero for variable size pdu */ + uint8_t *token; /**< first byte of token, if any, or options */ + uint8_t *data; /**< first byte of payload, if any */ +#ifdef WITH_LWIP + struct pbuf *pbuf; /**< lwIP PBUF. The package data will always reside + * inside the pbuf's payload, but this pointer + * has to be kept because no exact offset can be + * given. This field must not be accessed from + * outside, because the pbuf's reference count + * is checked to be 1 when the pbuf is assigned + * to the pdu, and the pbuf stays exclusive to + * this pdu. */ +#endif + const uint8_t *body_data; /**< Holds ptr to re-assembled data or NULL */ + size_t body_length; /**< Holds body data length */ + size_t body_offset; /**< Holds body data offset */ + size_t body_total; /**< Holds body data total size */ + coap_lg_xmit_t *lg_xmit; /**< Holds ptr to lg_xmit if sending a set of + blocks */ +}; + +/** + * Dynamically grows the size of @p pdu to @p new_size. The new size + * must not exceed the PDU's configure maximum size. On success, this + * function returns 1, otherwise 0. + * + * @param pdu The PDU to resize. + * @param new_size The new size in bytes. + * @return 1 if the operation succeeded, 0 otherwise. + */ +int coap_pdu_resize(coap_pdu_t *pdu, size_t new_size); + +/** + * Dynamically grows the size of @p pdu to @p new_size if needed. The new size + * must not exceed the PDU's configured maximum size. On success, this + * function returns 1, otherwise 0. + * + * @param pdu The PDU to resize. + * @param new_size The new size in bytes. + * @return 1 if the operation succeeded, 0 otherwise. + */ +int coap_pdu_check_resize(coap_pdu_t *pdu, size_t new_size); + +/** +* Interprets @p data to determine the number of bytes in the header. +* This function returns @c 0 on error or a number greater than zero on success. +* +* @param proto Session's protocol +* @param data The first byte of raw data to parse as CoAP PDU. +* +* @return A value greater than zero on success or @c 0 on error. +*/ +size_t coap_pdu_parse_header_size(coap_proto_t proto, + const uint8_t *data); + +/** + * Parses @p data to extract the message size. + * @p length must be at least coap_pdu_parse_header_size(proto, data). + * This function returns @c 0 on error or a number greater than zero on success. + * + * @param proto Session's protocol + * @param data The raw data to parse as CoAP PDU. + * @param length The actual size of @p data. + * + * @return A value greater than zero on success or @c 0 on error. + */ +size_t coap_pdu_parse_size(coap_proto_t proto, + const uint8_t *data, + size_t length); + +/** + * Decode the protocol specific header for the specified PDU. + * @param pdu A newly received PDU. + * @param proto The target wire protocol. + * @return 1 for success or 0 on error. + */ + +int coap_pdu_parse_header(coap_pdu_t *pdu, coap_proto_t proto); + +/** + * Verify consistency in the given CoAP PDU structure and locate the data. + * This function returns @c 0 on error or a number greater than zero on + * success. + * This function only parses the token and options, up to the payload start + * marker. + * + * @param pdu The PDU structure to check. + * + * @return 1 on success or @c 0 on error. + */ +int coap_pdu_parse_opt(coap_pdu_t *pdu); + +/** +* Parses @p data into the CoAP PDU structure given in @p result. +* The target pdu must be large enough to +* This function returns @c 0 on error or a number greater than zero on success. +* +* @param proto Session's protocol +* @param data The raw data to parse as CoAP PDU. +* @param length The actual size of @p data. +* @param pdu The PDU structure to fill. Note that the structure must +* provide space to hold at least the token and options +* part of the message. +* +* @return 1 on success or @c 0 on error. +*/ +int coap_pdu_parse(coap_proto_t proto, + const uint8_t *data, + size_t length, + coap_pdu_t *pdu); + +/** + * Clears any contents from @p pdu and resets @c used_size, + * and @c data pointers. @c max_size is set to @p size, any + * other field is set to @c 0. Note that @p pdu must be a valid + * pointer to a coap_pdu_t object created e.g. by coap_pdu_init(). + * + * @param pdu The PDU to clear. + * @param size The maximum size of the PDU. + */ +void coap_pdu_clear(coap_pdu_t *pdu, size_t size); + +/** + * Removes (first) option of given number from the @p pdu. + * + * @param pdu The PDU to remove the option from. + * @param number The number of the CoAP option to remove (first only removed). + * + * @return @c 1 if success else @c 0 if error. + */ +int coap_remove_option(coap_pdu_t *pdu, coap_option_num_t number); + +/** + * Inserts option of given number in the @p pdu with the appropriate data. + * The option will be inserted in the appropriate place in the options in + * the pdu. + * + * @param pdu The PDU where the option is to be inserted. + * @param number The number of the new option. + * @param len The length of the new option. + * @param data The data of the new option. + * + * @return The overall length of the option or @c 0 on failure. + */ +size_t coap_insert_option(coap_pdu_t *pdu, coap_option_num_t number, + size_t len, const uint8_t *data); + +/** + * Updates existing first option of given number in the @p pdu with the new + * data. + * + * @param pdu The PDU where the option is to be updated. + * @param number The number of the option to update (first only updated). + * @param len The length of the updated option. + * @param data The data of the updated option. + * + * @return The overall length of the updated option or @c 0 on failure. + */ +size_t coap_update_option(coap_pdu_t *pdu, + coap_option_num_t number, + size_t len, + const uint8_t *data); + +/** + * Compose the protocol specific header for the specified PDU. + * + * @param pdu A newly composed PDU. + * @param proto The target wire protocol. + * + * @return Number of header bytes prepended before pdu->token or 0 on error. + */ + +size_t coap_pdu_encode_header(coap_pdu_t *pdu, coap_proto_t proto); + + /** + * Updates token in @p pdu with length @p len and @p data. + * This function returns @c 0 on error or a value greater than zero on success. + * + * @param pdu The PDU where the token is to be updated. + * @param len The length of the new token. + * @param data The token to add. + * + * @return A value greater than zero on success, or @c 0 on error. + */ +int coap_update_token(coap_pdu_t *pdu, + size_t len, + const uint8_t *data); + +/** @} */ + +#endif /* COAP_COAP_PDU_INTERNAL_H_ */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_prng.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_prng.h new file mode 100644 index 00000000000..6d297afaec3 --- /dev/null +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_prng.h @@ -0,0 +1,113 @@ +/* + * coap_prng.h -- Pseudo Random Numbers + * + * Copyright (C) 2010-2020 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_prng.h + * @brief Pseudo Random Numbers + */ + +#ifndef COAP_PRNG_H_ +#define COAP_PRNG_H_ + +/** + * @defgroup coap_prng Pseudo Random Numbers + * API functions for gerating pseudo random numbers + * @{ + */ + +#if defined(WITH_CONTIKI) +#include + +/** + * Fills \p buf with \p len random bytes. This is the default implementation for + * coap_prng(). You might want to change contiki_prng_impl() to use a better + * PRNG on your specific platform. + */ +COAP_STATIC_INLINE int +contiki_prng_impl(unsigned char *buf, size_t len) { + uint16_t v = random_rand(); + while (len > sizeof(v)) { + memcpy(buf, &v, sizeof(v)); + len -= sizeof(v); + buf += sizeof(v); + v = random_rand(); + } + + memcpy(buf, &v, len); + return 1; +} + +#define coap_prng(Buf,Length) contiki_prng_impl((Buf), (Length)) +#define coap_prng_init(Value) random_init((uint16_t)(Value)) + +#elif defined(WITH_LWIP) && defined(LWIP_RAND) + +COAP_STATIC_INLINE int +lwip_prng_impl(unsigned char *buf, size_t len) { + u32_t v = LWIP_RAND(); + while (len > sizeof(v)) { + memcpy(buf, &v, sizeof(v)); + len -= sizeof(v); + buf += sizeof(v); + v = LWIP_RAND(); + } + + memcpy(buf, &v, len); + return 1; +} + +#define coap_prng(Buf,Length) lwip_prng_impl((Buf), (Length)) +#define coap_prng_init(Value) (void)Value + +#else + +/** + * Data type for random number generator function. The function must + * fill @p len bytes of random data into the buffer starting at @p + * out. On success, the function should return 1, zero otherwise. + */ +typedef int (*coap_rand_func_t)(void *out, size_t len); + +/** + * Replaces the current random number generation function with the + * default function @p rng. + * + * @param rng The random number generation function to use. + */ +void coap_set_prng(coap_rand_func_t rng); + +/** + * Seeds the default random number generation function with the given + * @p seed. The default random number generation function will use + * getrandom() if available, ignoring the seed. + * + * @param seed The seed for the pseudo random number generator. + */ +void coap_prng_init(unsigned int seed); + +/** + * Fills @p buf with @p len random bytes using the default pseudo + * random number generator. The default PRNG can be changed with + * coap_set_prng(). This function returns 1 when @p len random bytes + * have been written to @p buf, zero otherwise. + * + * @param buf The buffer to fill with random bytes. + * @param len The number of random bytes to write into @p buf. + * + * @return 1 on success, 0 otherwise. + */ +int coap_prng(void *buf, size_t len); + +#endif /* POSIX */ + +/** @} */ + +#endif /* COAP_PRNG_H_ */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_resource_internal.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_resource_internal.h new file mode 100644 index 00000000000..cbcc36a664c --- /dev/null +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_resource_internal.h @@ -0,0 +1,141 @@ +/* + * coap_resource_internal.h -- generic resource handling + * + * Copyright (C) 2010,2011,2014-2021 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_resource_internal.h + * @brief Generic resource internal handling + */ + +#ifndef COAP_RESOURCE_INTERNAL_H_ +#define COAP_RESOURCE_INTERNAL_H_ + +#include "uthash.h" + +/** + * @defgroup coap_resource_internal Resources (Internal) + * Structures, Enums and Functions that are not exposed to applications + * @{ + */ + +/** +* Abstraction of attribute associated with a resource. +*/ +struct coap_attr_t { + struct coap_attr_t *next; /**< Pointer to next in chain or NULL */ + coap_str_const_t *name; /**< Name of the attribute */ + coap_str_const_t *value; /**< Value of the attribute (can be NULL) */ + int flags; +}; + +/** +* Abstraction of resource that can be attached to coap_context_t. +* The key is uri_path. +*/ +struct coap_resource_t { + unsigned int dirty:1; /**< set to 1 if resource has changed */ + unsigned int partiallydirty:1; /**< set to 1 if some subscribers have not yet + * been notified of the last change */ + unsigned int observable:1; /**< can be observed */ + unsigned int cacheable:1; /**< can be cached */ + unsigned int is_unknown:1; /**< resource created for unknown handler */ + unsigned int is_proxy_uri:1; /**< resource created for proxy URI handler */ + + /** + * Used to store handlers for the seven coap methods @c GET, @c POST, @c PUT, + * @c DELETE, @c FETCH, @c PATCH and @c IPATCH. + * coap_dispatch() will pass incoming requests to handle_request() and then + * to the handler that corresponds to its request method or generate a 4.05 + * response if no handler is available. + */ + coap_method_handler_t handler[7]; + + UT_hash_handle hh; + + coap_attr_t *link_attr; /**< attributes to be included with the link format */ + coap_subscription_t *subscribers; /**< list of observers for this resource */ + + /** + * Request URI Path for this resource. This field will point into static + * or allocated memory which must remain there for the duration of the + * resource. + */ + coap_str_const_t *uri_path; /**< the key used for hash lookup for this + resource */ + int flags; /**< zero or more COAP_RESOURCE_FLAGS_* or'd together */ + + /** + * The next value for the Observe option. This field must be increased each + * time the resource changes. Only the lower 24 bits are sent. + */ + unsigned int observe; + + /** + * Pointer back to the context that 'owns' this resource. + */ + coap_context_t *context; + + /** + * Count of valid names this host is known by (proxy support) + */ + size_t proxy_name_count; + + /** + * Array valid names this host is known by (proxy support) + */ + coap_str_const_t ** proxy_name_list; + + /** + * This pointer is under user control. It can be used to store context for + * the coap handler. + */ + void *user_data; + +}; + +/** + * Deletes all resources from given @p context and frees their storage. + * + * @param context The CoAP context with the resources to be deleted. + */ +void coap_delete_all_resources(coap_context_t *context); + +#define RESOURCES_ADD(r, obj) \ + HASH_ADD(hh, (r), uri_path->s[0], (obj)->uri_path->length, (obj)) + +#define RESOURCES_DELETE(r, obj) \ + HASH_DELETE(hh, (r), (obj)) + +#define RESOURCES_ITER(r,tmp) \ + coap_resource_t *tmp, *rtmp; \ + HASH_ITER(hh, (r), tmp, rtmp) + +#define RESOURCES_FIND(r, k, res) { \ + HASH_FIND(hh, (r), (k)->s, (k)->length, (res)); \ + } + +/** + * Deletes an attribute. + * Note: This is for internal use only, as it is not deleted from its chain. + * + * @param attr Pointer to a previously created attribute. + * + */ +void coap_delete_attr(coap_attr_t *attr); + +coap_print_status_t coap_print_wellknown(coap_context_t *, + unsigned char *, + size_t *, size_t, + coap_opt_t *); + + +/** @} */ + +#endif /* COAP_RESOURCE_INTERNAL_H_ */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_riot.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_riot.h new file mode 100644 index 00000000000..fc4bfa2e655 --- /dev/null +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_riot.h @@ -0,0 +1,34 @@ +/* coap_riot.h -- RIOT-specific definitions for libcoap + * + * Copyright (C) 2019 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see + * README for terms of use. + */ + +#ifndef COAP_RIOT_H_ +#define COAP_RIOT_H_ + +#ifndef LIBCOAP_MSG_QUEUE_SIZE +/** + * Size of the queue for passing messages between the network + * interface and the coap stack. */ +#define LIBCOAP_MSG_QUEUE_SIZE (32U) +#endif /* LIBCOAP_MSG_QUEUE_SIZE */ + +#ifndef LIBCOAP_MAX_SOCKETS +/** + * Maximum number of sockets that are simultaneously considered for + * reading or writing. */ +#define LIBCOAP_MAX_SOCKETS (16U) +#endif /* LIBCOAP_MAX_SOCKETS */ + +/** + * This function must be called in the RIOT CoAP thread for + * RIOT-specific initialization. + */ +void coap_riot_startup(void); + +#endif /* COAP_RIOT_H_ */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_session.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_session.h new file mode 100644 index 00000000000..6c49b78e97d --- /dev/null +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_session.h @@ -0,0 +1,591 @@ +/* coap_session.h -- Session management for libcoap +* +* Copyright (C) 2017 Jean-Claue Michelou +* + * SPDX-License-Identifier: BSD-2-Clause + * +* This file is part of the CoAP library libcoap. Please see +* README for terms of use. +*/ + +/** + * @file coap_session.h + * @brief Defines the application visible session information + */ + +#ifndef COAP_SESSION_H_ +#define COAP_SESSION_H_ + +/** + * @defgroup session Sessions + * API functions for CoAP Sessions + * @{ + */ + +/** +* Abstraction of a fixed point number that can be used where necessary instead +* of a float. 1,000 fractional bits equals one integer +*/ +typedef struct coap_fixed_point_t { + uint16_t integer_part; /**< Integer part of fixed point variable */ + uint16_t fractional_part; /**< Fractional part of fixed point variable + 1/1000 (3 points) precision */ +} coap_fixed_point_t; + +#define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS) +#define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS) + +/** + * coap_session_type_t values + */ +typedef enum coap_session_type_t { + COAP_SESSION_TYPE_NONE = 0, /**< Not defined */ + COAP_SESSION_TYPE_CLIENT, /**< client-side */ + COAP_SESSION_TYPE_SERVER, /**< server-side */ + COAP_SESSION_TYPE_HELLO, /**< server-side ephemeral session for + responding to a client hello */ +} coap_session_type_t; + +/** + * coap_session_state_t values + */ +typedef enum coap_session_state_t { + COAP_SESSION_STATE_NONE = 0, + COAP_SESSION_STATE_CONNECTING, + COAP_SESSION_STATE_HANDSHAKE, + COAP_SESSION_STATE_CSM, + COAP_SESSION_STATE_ESTABLISHED, +} coap_session_state_t; + +/** + * Increment reference counter on a session. + * + * @param session The CoAP session. + * @return same as session + */ +coap_session_t *coap_session_reference(coap_session_t *session); + +/** + * Decrement reference counter on a session. + * Note that the session may be deleted as a result and should not be used + * after this call. + * + * @param session The CoAP session. + */ +void coap_session_release(coap_session_t *session); + +/** + * Notify session that it has failed. This cleans up any outstanding / queued + * transmissions, observations etc.. + * + * @param session The CoAP session. + * @param reason The reason why the session was disconnected. + */ +void coap_session_disconnected(coap_session_t *session, + coap_nack_reason_t reason); + +/** + * Stores @p data with the given session. This function overwrites any value + * that has previously been stored with @p session. + * + * @param session The CoAP session. + * @param data The pointer to the data to store. + */ +void coap_session_set_app_data(coap_session_t *session, void *data); + +/** + * Returns any application-specific data that has been stored with @p + * session using the function coap_session_set_app_data(). This function will + * return @c NULL if no data has been stored. + * + * @param session The CoAP session. + * + * @return Pointer to the stored data or @c NULL. + */ +void *coap_session_get_app_data(const coap_session_t *session); + +/** + * Get the remote IP address from the session. + * + * @param session The CoAP session. + * + * @return The session's remote address or @c NULL on failure. + */ +const coap_address_t *coap_session_get_addr_remote( + const coap_session_t *session); + +/** + * Get the local IP address from the session. + * + * @param session The CoAP session. + * + * @return The session's local address or @c NULL on failure. + */ +const coap_address_t *coap_session_get_addr_local( + const coap_session_t *session); + +/** + * Get the session protocol type + * + * @param session The CoAP session. + * + * @return The session's protocol type + */ +coap_proto_t coap_session_get_proto(const coap_session_t *session); + +/** + * Get the session type + * + * @param session The CoAP session. + * + * @return The session's type + */ +coap_session_type_t coap_session_get_type(const coap_session_t *session); + +/** + * Get the session state + * + * @param session The CoAP session. + * + * @return The session's state + */ +coap_session_state_t coap_session_get_state(const coap_session_t *session); + +/** + * Get the session if index + * + * @param session The CoAP session. + * + * @return The session's if index, or @c -1 on error. + */ +int coap_session_get_ifindex(const coap_session_t *session); + +/** + * Get the session TLS security ptr (TLS type dependent) + * + * OpenSSL: SSL* + * GnuTLS: gnutls_session_t (implicit *) + * Mbed TLS: mbedtls_ssl_context* + * TinyDTLS: struct dtls_context* + * + * @param session The CoAP session. + * @param tls_lib Updated with the library type. + * + * @return The session TLS ptr or @c NULL if not set up + */ +void *coap_session_get_tls(const coap_session_t *session, + coap_tls_library_t *tls_lib); + +/** + * Get the session context + * + * @param session The CoAP session. + * + * @return The session's context + */ +coap_context_t *coap_session_get_context(const coap_session_t *session); + +/** + * Set the session type to client. Typically used in a call-home server. + * The session needs to be of type COAP_SESSION_TYPE_SERVER. + * Note: If this function is successful, the session reference count is + * incremented and a subsequent coap_session_release() taking the + * reference count to 0 will cause the session to be freed off. + * + * @param session The CoAP session. + * + * @return @c 1 if updated, @c 0 on failure. + */ +int coap_session_set_type_client(coap_session_t *session); + +/** + * Set the session MTU. This is the maximum message size that can be sent, + * excluding IP and UDP overhead. + * + * @param session The CoAP session. + * @param mtu maximum message size + */ +void coap_session_set_mtu(coap_session_t *session, unsigned mtu); + +/** + * Get maximum acceptable PDU size + * + * @param session The CoAP session. + * @return maximum PDU size, not including header (but including token). + */ +size_t coap_session_max_pdu_size(const coap_session_t *session); + +/** +* Creates a new client session to the designated server. +* @param ctx The CoAP context. +* @param local_if Address of local interface. It is recommended to use NULL to let the operating system choose a suitable local interface. If an address is specified, the port number should be zero, which means that a free port is automatically selected. +* @param server The server's address. If the port number is zero, the default port for the protocol will be used. +* @param proto Protocol. +* +* @return A new CoAP session or NULL if failed. Call coap_session_release to free. +*/ +coap_session_t *coap_new_client_session( + coap_context_t *ctx, + const coap_address_t *local_if, + const coap_address_t *server, + coap_proto_t proto +); + +/** +* Creates a new client session to the designated server with PSK credentials +* @param ctx The CoAP context. +* @param local_if Address of local interface. It is recommended to use NULL to let the operating system choose a suitable local interface. If an address is specified, the port number should be zero, which means that a free port is automatically selected. +* @param server The server's address. If the port number is zero, the default port for the protocol will be used. +* @param proto Protocol. +* @param identity PSK client identity +* @param key PSK shared key +* @param key_len PSK shared key length +* +* @return A new CoAP session or NULL if failed. Call coap_session_release to free. +*/ +coap_session_t *coap_new_client_session_psk( + coap_context_t *ctx, + const coap_address_t *local_if, + const coap_address_t *server, + coap_proto_t proto, + const char *identity, + const uint8_t *key, + unsigned key_len +); + +/** +* Creates a new client session to the designated server with PSK credentials +* @param ctx The CoAP context. +* @param local_if Address of local interface. It is recommended to use NULL to +* let the operating system choose a suitable local interface. +* If an address is specified, the port number should be zero, +* which means that a free port is automatically selected. +* @param server The server's address. If the port number is zero, the default +* port for the protocol will be used. +* @param proto CoAP Protocol. +* @param setup_data PSK parameters. +* +* @return A new CoAP session or NULL if failed. Call coap_session_release() +* to free. +*/ +coap_session_t *coap_new_client_session_psk2( + coap_context_t *ctx, + const coap_address_t *local_if, + const coap_address_t *server, + coap_proto_t proto, + coap_dtls_cpsk_t *setup_data +); + +/** + * Get the server session's current Identity Hint (PSK). + * + * @param session The current coap_session_t object. + * + * @return @c hint if successful, else @c NULL. + */ +const coap_bin_const_t * coap_session_get_psk_hint( + const coap_session_t *session); + +/** + * Get the session's current pre-shared key (PSK). + * + * @param session The current coap_session_t object. + * + * @return @c psk_key if successful, else @c NULL. + */ +const coap_bin_const_t * coap_session_get_psk_key( + const coap_session_t *session); + +/** +* Creates a new client session to the designated server with PKI credentials +* @param ctx The CoAP context. +* @param local_if Address of local interface. It is recommended to use NULL to +* let the operating system choose a suitable local interface. +* If an address is specified, the port number should be zero, +* which means that a free port is automatically selected. +* @param server The server's address. If the port number is zero, the default +* port for the protocol will be used. +* @param proto CoAP Protocol. +* @param setup_data PKI parameters. +* +* @return A new CoAP session or NULL if failed. Call coap_session_release() +* to free. +*/ +coap_session_t *coap_new_client_session_pki( + coap_context_t *ctx, + const coap_address_t *local_if, + const coap_address_t *server, + coap_proto_t proto, + coap_dtls_pki_t *setup_data +); + +/** + * Initializes the token value to use as a starting point. + * + * @param session The current coap_session_t object. + * @param length The length of the token (0 - 8 bytes). + * @param token The token data. + * + */ +void coap_session_init_token(coap_session_t *session, size_t length, + const uint8_t *token); + +/** + * Creates a new token for use. + * + * @param session The current coap_session_t object. + * @param length Updated with the length of the new token. + * @param token Updated with the new token data (must be 8 bytes long). + * + */ +void coap_session_new_token(coap_session_t *session, size_t *length, + uint8_t *token); + +/** + * @ingroup logging + * Get session description. + * + * @param session The CoAP session. + * @return description string. + */ +const char *coap_session_str(const coap_session_t *session); + +/** +* Create a new endpoint for communicating with peers. +* +* @param context The coap context that will own the new endpoint +* @param listen_addr Address the endpoint will listen for incoming requests on or originate outgoing requests from. Use NULL to specify that no incoming request will be accepted and use a random endpoint. +* @param proto Protocol used on this endpoint +*/ + +coap_endpoint_t *coap_new_endpoint(coap_context_t *context, const coap_address_t *listen_addr, coap_proto_t proto); + +/** +* Set the endpoint's default MTU. This is the maximum message size that can be +* sent, excluding IP and UDP overhead. +* +* @param endpoint The CoAP endpoint. +* @param mtu maximum message size +*/ +void coap_endpoint_set_default_mtu(coap_endpoint_t *endpoint, unsigned mtu); + +void coap_free_endpoint(coap_endpoint_t *ep); + +/** @} */ + +/** + * @ingroup logging +* Get endpoint description. +* +* @param endpoint The CoAP endpoint. +* @return description string. +*/ +const char *coap_endpoint_str(const coap_endpoint_t *endpoint); + +coap_session_t *coap_session_get_by_peer(const coap_context_t *ctx, + const coap_address_t *remote_addr, int ifindex); + + /** + * @defgroup cc Rate Control + * The transmission parameters for CoAP rate control ("Congestion + * Control" in stream-oriented protocols) are defined in + * https://tools.ietf.org/html/rfc7252#section-4.8 + * @{ + */ + + /** + * Number of seconds when to expect an ACK or a response to an + * outstanding CON message. + * RFC 7252, Section 4.8 Default value of ACK_TIMEOUT is 2 + * + * Configurable using coap_session_set_ack_timeout() + */ +#define COAP_DEFAULT_ACK_TIMEOUT ((coap_fixed_point_t){2,0}) + + /** + * A factor that is used to randomize the wait time before a message + * is retransmitted to prevent synchronization effects. + * RFC 7252, Section 4.8 Default value of ACK_RANDOM_FACTOR is 1.5 + * + * Configurable using coap_session_set_ack_random_factor() + */ +#define COAP_DEFAULT_ACK_RANDOM_FACTOR ((coap_fixed_point_t){1,500}) + + /** + * Number of message retransmissions before message sending is stopped + * RFC 7252, Section 4.8 Default value of MAX_RETRANSMIT is 4 + * + * Configurable using coap_session_set_max_retransmit() + */ +#define COAP_DEFAULT_MAX_RETRANSMIT 4 + + /** + * The number of simultaneous outstanding interactions that a client + * maintains to a given server. + * RFC 7252, Section 4.8 Default value of NSTART is 1 + */ +#define COAP_DEFAULT_NSTART 1 + + /** + * The maximum number of seconds before sending back a response to a + * multicast request. + * RFC 7252, Section 4.8 DEFAULT_LEISURE is 5. + */ +#ifndef COAP_DEFAULT_LEISURE +#define COAP_DEFAULT_LEISURE (5U) +#endif /* COAP_DEFAULT_LEISURE */ + + /** + * The MAX_TRANSMIT_SPAN definition for the session (s). + * + * RFC 7252, Section 4.8.2 Calculation of MAX_TRAMSMIT_SPAN + * ACK_TIMEOUT * ((2 ** (MAX_RETRANSMIT)) - 1) * ACK_RANDOM_FACTOR + */ +#define COAP_MAX_TRANSMIT_SPAN(s) \ + ((s->ack_timeout.integer_part * 1000 + s->ack_timeout.fractional_part) * \ + ((1 << (s->max_retransmit)) -1) * \ + (s->ack_random_factor.integer_part * 1000 + \ + s->ack_random_factor.fractional_part) \ + / 1000000) + + /** + * The MAX_TRANSMIT_WAIT definition for the session (s). + * + * RFC 7252, Section 4.8.2 Calculation of MAX_TRAMSMIT_WAIT + * ACK_TIMEOUT * ((2 ** (MAX_RETRANSMIT + 1)) - 1) * ACK_RANDOM_FACTOR + */ +#define COAP_MAX_TRANSMIT_WAIT(s) \ + ((s->ack_timeout.integer_part * 1000 + s->ack_timeout.fractional_part) * \ + ((1 << (s->max_retransmit + 1)) -1) * \ + (s->ack_random_factor.integer_part * 1000 + \ + s->ack_random_factor.fractional_part) \ + / 1000000) + + /** + * The MAX_LATENCY definition. + * RFC 7252, Section 4.8.2 MAX_LATENCY is 100. + */ +#define COAP_MAX_LATENCY 100 + + /** + * The PROCESSING_DELAY definition for the session (s). + * + * RFC 7252, Section 4.8.2 Calculation of PROCESSING_DELAY + * PROCESSING_DELAY set to ACK_TIMEOUT + */ +#define COAP_PROCESSING_DELAY(s) \ + ((s->ack_timeout.integer_part * 1000 + s->ack_timeout.fractional_part + 500) \ + / 1000) + + /** + * The MAX_RTT definition for the session (s). + * + * RFC 7252, Section 4.8.2 Calculation of MAX_RTT + * (2 * MAX_LATENCY) + PROCESSING_DELAY + */ +#define COAP_MAX_RTT(s) \ + ((2 * COAP_MAX_LATENCY) + COAP_PROCESSING_DELAY(s)) + + /** + * The EXCHANGE_LIFETIME definition for the session (s). + * + * RFC 7252, Section 4.8.2 Calculation of EXCHANGE_LIFETIME + * MAX_TRANSMIT_SPAN + (2 * MAX_LATENCY) + PROCESSING_DELAY + */ +#define COAP_EXCHANGE_LIFETIME(s) \ + (COAP_MAX_TRANSMIT_SPAN(s) + (2 * COAP_MAX_LATENCY) + COAP_PROCESSING_DELAY(s)) + + /** + * The NON_LIFETIME definition for the session (s). + * + * RFC 7252, Section 4.8.2 Calculation of NON_LIFETIME + * MAX_TRANSMIT_SPAN + MAX_LATENCY + */ +#define COAP_NON_LIFETIME(s) \ + (COAP_MAX_TRANSMIT_SPAN(s) + COAP_MAX_LATENCY) + + /** @} */ + +/** +* Set the CoAP maximum retransmit count before failure +* +* Number of message retransmissions before message sending is stopped +* +* @param session The CoAP session. +* @param value The value to set to. The default is 4 and should not normally +* get changed. +*/ +void coap_session_set_max_retransmit(coap_session_t *session, + unsigned int value); + +/** +* Set the CoAP initial ack response timeout before the next re-transmit +* +* Number of seconds when to expect an ACK or a response to an +* outstanding CON message. +* +* @param session The CoAP session. +* @param value The value to set to. The default is 2 and should not normally +* get changed. +*/ +void coap_session_set_ack_timeout(coap_session_t *session, + coap_fixed_point_t value); + +/** +* Set the CoAP ack randomize factor +* +* A factor that is used to randomize the wait time before a message +* is retransmitted to prevent synchronization effects. +* +* @param session The CoAP session. +* @param value The value to set to. The default is 1.5 and should not normally +* get changed. +*/ +void coap_session_set_ack_random_factor(coap_session_t *session, + coap_fixed_point_t value); + +/** +* Get the CoAP maximum retransmit before failure +* +* Number of message retransmissions before message sending is stopped +* +* @param session The CoAP session. +* +* @return Current maximum retransmit value +*/ +unsigned int coap_session_get_max_retransmit(const coap_session_t *session); + +/** +* Get the CoAP initial ack response timeout before the next re-transmit +* +* Number of seconds when to expect an ACK or a response to an +* outstanding CON message. +* +* @param session The CoAP session. +* +* @return Current ack response timeout value +*/ +coap_fixed_point_t coap_session_get_ack_timeout(const coap_session_t *session); + +/** +* Get the CoAP ack randomize factor +* +* A factor that is used to randomize the wait time before a message +* is retransmitted to prevent synchronization effects. +* +* @param session The CoAP session. +* +* @return Current ack randomize value +*/ +coap_fixed_point_t coap_session_get_ack_random_factor( + const coap_session_t *session); + +/** + * Send a ping message for the session. + * @param session The CoAP session. + * + * @return COAP_INVALID_MID if there is an error + */ +coap_mid_t coap_session_send_ping(coap_session_t *session); + +#endif /* COAP_SESSION_H */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_session_internal.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_session_internal.h new file mode 100644 index 00000000000..1fd2de9ecf1 --- /dev/null +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_session_internal.h @@ -0,0 +1,295 @@ +/* + * coap_session_internal.h -- Structures, Enums & Functions that are not + * exposed to application programming + * + * Copyright (C) 2010-2019 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_session_internal.h + * @brief COAP session internal information + */ + +#ifndef COAP_SESSION_INTERNAL_H_ +#define COAP_SESSION_INTERNAL_H_ + +#include "coap_io_internal.h" + +#define COAP_DEFAULT_SESSION_TIMEOUT 300 +#define COAP_PARTIAL_SESSION_TIMEOUT_TICKS (30 * COAP_TICKS_PER_SECOND) +#define COAP_DEFAULT_MAX_HANDSHAKE_SESSIONS 100 + +/** + * @defgroup session_internal Sessions (Internal) + * CoAP Session Structures, Enums and Functions that are not exposed to + * applications + * @{ + */ + +/** + * Only used for servers for hashing incoming packets. Cannot have local IP + * address as this may be an initial multicast and subsequent unicast address + */ +struct coap_addr_hash_t { + coap_address_t remote; /**< remote address and port */ + uint16_t lport; /**< local port */ + coap_proto_t proto; /**< CoAP protocol */ +}; + +/** + * Abstraction of virtual session that can be attached to coap_context_t + * (client) or coap_endpoint_t (server). + */ +struct coap_session_t { + coap_proto_t proto; /**< protocol used */ + coap_session_type_t type; /**< client or server side socket */ + coap_session_state_t state; /**< current state of relationaship with + peer */ + unsigned ref; /**< reference count from queues */ + size_t tls_overhead; /**< overhead of TLS layer */ + size_t mtu; /**< path or CSM mtu */ + coap_addr_hash_t addr_hash; /**< Address hash for server incoming packets */ + UT_hash_handle hh; + coap_addr_tuple_t addr_info; /**< key: remote/local address info */ + int ifindex; /**< interface index */ + coap_socket_t sock; /**< socket object for the session, if + any */ + coap_endpoint_t *endpoint; /**< session's endpoint */ + coap_context_t *context; /**< session's context */ + void *tls; /**< security parameters */ + uint16_t tx_mid; /**< the last message id that was used in + this session */ + uint8_t con_active; /**< Active CON request sent */ + uint8_t csm_block_supported; /**< CSM TCP blocks supported */ + coap_mid_t last_ping_mid; /**< the last keepalive message id that was + used in this session */ + coap_queue_t *delayqueue; /**< list of delayed messages waiting to + be sent */ + coap_lg_xmit_t *lg_xmit; /**< list of large transmissions */ + coap_lg_crcv_t *lg_crcv; /**< Client list of expected large receives */ + coap_lg_srcv_t *lg_srcv; /**< Server list of expected large receives */ + size_t partial_write; /**< if > 0 indicates number of bytes + already written from the pdu at the + head of sendqueue */ + uint8_t read_header[8]; /**< storage space for header of incoming + message header */ + size_t partial_read; /**< if > 0 indicates number of bytes + already read for an incoming message */ + coap_pdu_t *partial_pdu; /**< incomplete incoming pdu */ + coap_tick_t last_rx_tx; + coap_tick_t last_tx_rst; + coap_tick_t last_ping; + coap_tick_t last_pong; + coap_tick_t csm_tx; + coap_dtls_cpsk_t cpsk_setup_data; /**< client provided PSK initial setup + data */ + coap_bin_const_t *psk_identity; /**< If client, this field contains the + current identity for server; When this + field is NULL, the current identity is + contained in cpsk_setup_data + + If server, this field contains the client + provided identity. + + Value maintained internally */ + coap_bin_const_t *psk_key; /**< If client, this field contains the + current pre-shared key for server; + When this field is NULL, the current + key is contained in cpsk_setup_data + + If server, this field contains the + client's current key. + + Value maintained internally */ + coap_bin_const_t *psk_hint; /**< If client, this field contains the + server provided identity hint. + + If server, this field contains the + current hint for the client; When this + field is NULL, the current hint is + contained in context->spsk_setup_data + + Value maintained internally */ + void *app; /**< application-specific data */ + unsigned int max_retransmit; /**< maximum re-transmit count (default + 4) */ + coap_fixed_point_t ack_timeout; /**< timeout waiting for ack (default 2 + secs) */ + coap_fixed_point_t ack_random_factor; /**< ack random factor backoff (default + 1.5) */ + unsigned int dtls_timeout_count; /**< dtls setup retry counter */ + int dtls_event; /**< Tracking any (D)TLS events on this + sesison */ + uint8_t block_mode; /**< Zero or more COAP_BLOCK_ or'd options */ + uint64_t tx_token; /**< Next token number to use */ +}; + +/** + * Abstraction of virtual endpoint that can be attached to coap_context_t. The + * keys (port, bind_addr) must uniquely identify this endpoint. + */ +struct coap_endpoint_t { + struct coap_endpoint_t *next; + coap_context_t *context; /**< endpoint's context */ + coap_proto_t proto; /**< protocol used on this interface */ + uint16_t default_mtu; /**< default mtu for this interface */ + coap_socket_t sock; /**< socket object for the interface, if + any */ + coap_address_t bind_addr; /**< local interface address */ + coap_session_t *sessions; /**< hash table or list of active sessions */ +}; + +/** + * Notify session transport has just connected and CSM exchange can now start. + * + * @param session The CoAP session. + */ +void coap_session_send_csm(coap_session_t *session); + +/** + * Notify session that it has just connected or reconnected. + * + * @param session The CoAP session. + */ +void coap_session_connected(coap_session_t *session); + +/** + * Refresh the session's current Identity Hint (PSK). + * Note: A copy of @p psk_hint is maintained in the session by libcoap. + * + * @param session The current coap_session_t object. + * @param psk_hint If NULL, the Identity Hint will revert to the + * initial Identity Hint used at session setup. + * + * @return @c 1 if successful, else @c 0. + */ +int coap_session_refresh_psk_hint(coap_session_t *session, + const coap_bin_const_t *psk_hint); + +/** + * Refresh the session's current pre-shared key (PSK). + * Note: A copy of @p psk_key is maintained in the session by libcoap. + * + * @param session The current coap_session_t object. + * @param psk_key If NULL, the pre-shared key will revert to the + * initial pre-shared key used as session setup. + * + * @return @c 1 if successful, else @c 0. + */ +int coap_session_refresh_psk_key(coap_session_t *session, + const coap_bin_const_t *psk_key); + +/** + * Creates a new server session for the specified endpoint. + * @param ctx The CoAP context. + * @param ep An endpoint where an incoming connection request is pending. + * + * @return A new CoAP session or NULL if failed. Call coap_session_release to + * add to unused queue. + */ +coap_session_t *coap_new_server_session( + coap_context_t *ctx, + coap_endpoint_t *ep +); + +/** + * Function interface for datagram data transmission. This function returns + * the number of bytes that have been transmitted, or a value less than zero + * on error. + * + * @param session Session to send data on. + * @param data The data to send. + * @param datalen The actual length of @p data. + * + * @return The number of bytes written on success, or a value + * less than zero on error. + */ +ssize_t coap_session_send(coap_session_t *session, + const uint8_t *data, size_t datalen); + +/** + * Function interface for stream data transmission. This function returns + * the number of bytes that have been transmitted, or a value less than zero + * on error. The number of bytes written may be less than datalen because of + * congestion control. + * + * @param session Session to send data on. + * @param data The data to send. + * @param datalen The actual length of @p data. + * + * @return The number of bytes written on success, or a value + * less than zero on error. + */ +ssize_t coap_session_write(coap_session_t *session, + const uint8_t *data, size_t datalen); + +/** + * Send a pdu according to the session's protocol. This function returns + * the number of bytes that have been transmitted, or a value less than zero + * on error. + * + * @param session Session to send pdu on. + * @param pdu The pdu to send. + * + * @return The number of bytes written on success, or a value + * less than zero on error. + */ +ssize_t coap_session_send_pdu(coap_session_t *session, coap_pdu_t *pdu); + +ssize_t +coap_session_delay_pdu(coap_session_t *session, coap_pdu_t *pdu, + coap_queue_t *node); + +/** + * Lookup the server session for the packet received on an endpoint, or create + * a new one. + * + * @param endpoint Active endpoint the packet was received on. + * @param packet Received packet. + * @param now The current time in ticks. + * @return The CoAP session or @c NULL if error. + */ +coap_session_t *coap_endpoint_get_session(coap_endpoint_t *endpoint, + const coap_packet_t *packet, coap_tick_t now); + +/** + * Create a new DTLS session for the @p session. + * Note: the @p session is released if no DTLS server session can be created. + * + * @ingroup dtls_internal + * + * @param session Session to add DTLS session to + * @param now The current time in ticks. + * + * @return CoAP session or @c NULL if error. + */ +coap_session_t *coap_session_new_dtls_session(coap_session_t *session, + coap_tick_t now); + +void coap_session_free(coap_session_t *session); +void coap_session_mfree(coap_session_t *session); + +/** @} */ + +#define SESSIONS_ADD(e, obj) \ + HASH_ADD(hh, (e), addr_hash, sizeof((obj)->addr_hash), (obj)) + +#define SESSIONS_DELETE(e, obj) \ + HASH_DELETE(hh, (e), (obj)) + +#define SESSIONS_ITER(e, el, rtmp) \ + HASH_ITER(hh, (e), el, rtmp) + +#define SESSIONS_ITER_SAFE(e, el, rtmp) \ +for ((el) = (e); (el) && ((rtmp) = (el)->hh.next, 1); (el) = (rtmp)) + +#define SESSIONS_FIND(e, k, res) { \ + HASH_FIND(hh, (e), &(k), sizeof(k), (res)); \ + } + +#endif /* COAP_SESSION_INTERNAL_H_ */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_subscribe_internal.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_subscribe_internal.h new file mode 100644 index 00000000000..b7702362bee --- /dev/null +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_subscribe_internal.h @@ -0,0 +1,151 @@ +/* + * coap_subscribe_internal.h -- Structures, Enums & Functions that are not + * exposed to application programming + * + * Copyright (C) 2010-2021 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_subscribe_internal.h + * @brief COAP subscribe internal information + */ + +#ifndef COAP_SUBSCRIBE_INTERNAL_H_ +#define COAP_SUBSCRIBE_INTERNAL_H_ + +/** + * @defgroup subscribe_internal Observe Subscription (Internal) + * CoAP Observe Subscription Structures, Enums and Functions that are not + * exposed to applications + * @{ + */ + +#ifndef COAP_OBS_MAX_NON +/** + * Number of notifications that may be sent non-confirmable before a confirmable + * message is sent to detect if observers are alive. The maximum allowed value + * here is @c 15. + */ +#define COAP_OBS_MAX_NON 5 +#endif /* COAP_OBS_MAX_NON */ + +#ifndef COAP_OBS_MAX_FAIL +/** + * Number of confirmable notifications that may fail (i.e. time out without + * being ACKed) before an observer is removed. The maximum value for + * COAP_OBS_MAX_FAIL is @c 3. + */ +#define COAP_OBS_MAX_FAIL 3 +#endif /* COAP_OBS_MAX_FAIL */ + +/** Subscriber information */ +struct coap_subscription_t { + struct coap_subscription_t *next; /**< next element in linked list */ + struct coap_session_t *session; /**< subscriber session */ + + unsigned int non_cnt:4; /**< up to 15 non-confirmable notifies allowed */ + unsigned int fail_cnt:2; /**< up to 3 confirmable notifies can fail */ + unsigned int dirty:1; /**< set if the notification temporarily could not be + * sent (in that case, the resource's partially + * dirty flag is set too) */ + coap_cache_key_t *cache_key; /** cache_key to identify requester */ + coap_pdu_t *pdu; /**< PDU to use for additional requests */ +}; + +void coap_subscription_init(coap_subscription_t *); + +/** + * Handles a failed observe notify. + * + * @param context The context holding the resource. + * @param session The session that the observe notify failed on. + * @param token The token used when the observe notify failed. + */ +void +coap_handle_failed_notify(coap_context_t *context, + coap_session_t *session, + const coap_binary_t *token); + +/** + * Checks all known resources to see if they are dirty and then notifies + * subscribed observers. + * + * @param context The context to check for dirty resources. + */ +void coap_check_notify(coap_context_t *context); + +/** + * Adds the specified peer as observer for @p resource. The subscription is + * identified by the given @p token. This function returns the registered + * subscription information if the @p observer has been added, or @c NULL on + * error. + * + * @param resource The observed resource. + * @param session The observer's session + * @param token The token that identifies this subscription. + * @param pdu The requesting pdu. + * + * @return A pointer to the added/updated subscription + * information or @c NULL on error. + */ +coap_subscription_t *coap_add_observer(coap_resource_t *resource, + coap_session_t *session, + const coap_binary_t *token, + const coap_pdu_t *pdu); + +/** + * Returns a subscription object for given @p peer. + * + * @param resource The observed resource. + * @param session The observer's session + * @param token The token that identifies this subscription or @c NULL for + * any token. + * @return A valid subscription if exists or @c NULL otherwise. + */ +coap_subscription_t *coap_find_observer(coap_resource_t *resource, + coap_session_t *session, + const coap_binary_t *token); + +/** + * Flags that data is ready to be sent to observers. + * + * @param context The CoAP context to use. + * @param session The observer's session + * @param token The corresponding token that has been used for the + * subscription. + */ +void coap_touch_observer(coap_context_t *context, + coap_session_t *session, + const coap_binary_t *token); + +/** + * Removes any subscription for @p observer from @p resource and releases the + * allocated storage. The result is @c 1 if an observation relationship with @p + * observer and @p token existed, @c 0 otherwise. + * + * @param resource The observed resource. + * @param session The observer's session. + * @param token The token that identifies this subscription or @c NULL for + * any token. + * @return @c 1 if the observer has been deleted, @c 0 otherwise. + */ +int coap_delete_observer(coap_resource_t *resource, + coap_session_t *session, + const coap_binary_t *token); + +/** + * Removes any subscription for @p session and releases the allocated storage. + * + * @param context The CoAP context to use. + * @param session The observer's session. + */ +void coap_delete_observers(coap_context_t *context, coap_session_t *session); + +/** @} */ + +#endif /* COAP_SUBSCRIBE_INTERNAL_H_ */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_tcp_internal.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_tcp_internal.h new file mode 100644 index 00000000000..4fd31b38d01 --- /dev/null +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_tcp_internal.h @@ -0,0 +1,111 @@ +/* + * coap_tcp_internal.h -- TCP functions for libcoap + * + * Copyright (C) 2019--2020 Olaf Bergmann and others + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file coap_tcp_internal.h + * @brief COAP tcp internal information + */ + +#ifndef COAP_TCP_INTERNAL_H_ +#define COAP_TCP_INTERNAL_H_ + +#include "coap_io.h" + +/** + * @defgroup tcp TCP Support (Internal) + * CoAP TCP Structures, Enums and Functions that are not exposed to + * applications + * @{ + */ + +#if !COAP_DISABLE_TCP + +/** + * Create a new TCP socket and initiate the connection + * + * Internal function. + * + * @param sock Where socket information is to be filled in + * @param local_if The local address to use or NULL + * @param server The address to connect to + * @param default_port The port to use if not set in @p server + * @param local_addr Filled in after connection initiation with + * the local address + * @param remote_addr Filled in after connection initiation with + * the remote address + * + * @return @c 1 if succesful, @c 0 if failure of some sort +*/ +int +coap_socket_connect_tcp1(coap_socket_t *sock, + const coap_address_t *local_if, + const coap_address_t *server, + int default_port, + coap_address_t *local_addr, + coap_address_t *remote_addr); + +/** + * Complete the TCP Connection + * + * Internal function. + * + * @param sock The socket information to use + * @param local_addr Filled in with the final local address + * @param remote_addr Filled in with the final remote address + * + * @return @c 1 if succesful, @c 0 if failure of some sort +*/ +int +coap_socket_connect_tcp2(coap_socket_t *sock, + coap_address_t *local_addr, + coap_address_t *remote_addr); + +/** + * Create a new TCP socket and then listen for new incoming TCP sessions + * + * Internal function. + * + * @param sock Where socket information is to be filled in + * @param listen_addr The address to be listening for new incoming sessions + * @param bound_addr Filled in with the address that the TCP layer + * is listening on for new incoming TCP sessions + * + * @return @c 1 if succesful, @c 0 if failure of some sort +*/ +int +coap_socket_bind_tcp(coap_socket_t *sock, + const coap_address_t *listen_addr, + coap_address_t *bound_addr); + +/** + * Accept a new incoming TCP session + * + * Internal function. + * + * @param server The socket information to use to accept the TCP connection + * @param new_client Filled in socket information with the new incoming + * session information + * @param local_addr Filled in with the local address + * @param remote_addr Filled in with the remote address + * + * @return @c 1 if succesful, @c 0 if failure of some sort +*/ +int +coap_socket_accept_tcp(coap_socket_t *server, + coap_socket_t *new_client, + coap_address_t *local_addr, + coap_address_t *remote_addr); + +#endif /* !COAP_DISABLE_TCP */ + +/** @} */ + +#endif /* COAP_TCP_INTERNAL_H_ */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap2/coap_time.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_time.h similarity index 80% rename from tools/sdk/esp32/include/coap/libcoap/include/coap2/coap_time.h rename to tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_time.h index e4a8e7c7c73..baa8650eaff 100644 --- a/tools/sdk/esp32/include/coap/libcoap/include/coap2/coap_time.h +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/coap_time.h @@ -3,6 +3,8 @@ * * Copyright (C) 2010-2019 Olaf Bergmann * + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ @@ -47,6 +49,10 @@ COAP_STATIC_INLINE coap_time_t coap_ticks_to_rt(coap_tick_t t) { return t / COAP_TICKS_PER_SECOND; } +COAP_STATIC_INLINE uint64_t coap_ticks_to_rt_us(coap_tick_t t) { + return (uint64_t)t * 1000000 / COAP_TICKS_PER_SECOND; +} + #elif defined(WITH_CONTIKI) #include "clock.h" @@ -75,7 +81,38 @@ COAP_STATIC_INLINE coap_time_t coap_ticks_to_rt(coap_tick_t t) { return t / COAP_TICKS_PER_SECOND; } -#else +COAP_STATIC_INLINE uint64_t coap_ticks_to_rt_us(coap_tick_t t) { + return (uint64_t)t * 1000000 / COAP_TICKS_PER_SECOND; +} + +#elif defined(RIOT_VERSION) +#include + +#define COAP_TICKS_PER_SECOND (XTIMER_HZ) + +typedef uint64_t coap_tick_t; +typedef int64_t coap_tick_diff_t; +typedef uint32_t coap_time_t; + +static inline void coap_clock_init(void) {} + +static inline void coap_ticks(coap_tick_t *t) { + *t = xtimer_now_usec64(); +} + +static inline coap_time_t coap_ticks_to_rt(coap_tick_t t) { + return t / 1000000UL; +} + +static inline uint64_t coap_ticks_to_rt_us(coap_tick_t t) { + return t; +} + +static inline coap_tick_t coap_ticks_from_rt_us(uint64_t t) { + return t / 1000000UL; +} +#else /* !WITH_LWIP && !WITH_CONTIKI && !RIOT_VERSION */ + #include /** diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap2/encode.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/encode.h similarity index 61% rename from tools/sdk/esp32/include/coap/libcoap/include/coap2/encode.h rename to tools/sdk/esp32s2/include/coap/libcoap/include/coap3/encode.h index b6d1524443c..a79146fc862 100644 --- a/tools/sdk/esp32/include/coap/libcoap/include/coap2/encode.h +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/encode.h @@ -3,6 +3,8 @@ * * Copyright (C) 2010-2012 Olaf Bergmann * + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ @@ -18,15 +20,6 @@ #include -#define Nn 8 /* duplicate definition of N if built on sky motes */ -#define ENCODE_HEADER_SIZE 4 -#define HIBIT (1 << (Nn - 1)) -#define EMASK ((1 << ENCODE_HEADER_SIZE) - 1) -#define MMASK ((1 << Nn) - 1 - EMASK) -#define MAX_VALUE ( (1 << Nn) - (1 << ENCODE_HEADER_SIZE) ) * (1 << ((1 << ENCODE_HEADER_SIZE) - 1)) - -#define COAP_PSEUDOFP_DECODE_8_4(r) (r < HIBIT ? r : (r & MMASK) << (r & EMASK)) - #ifndef HAVE_FLS /* include this only if fls() is not available */ extern int coap_fls(unsigned int i); @@ -41,28 +34,41 @@ extern int coap_flsll(long long i); #define coap_flsll(i) flsll(i) #endif -/* ls and s must be integer variables */ -#define COAP_PSEUDOFP_ENCODE_8_4_DOWN(v,ls) (v < HIBIT ? v : (ls = coap_fls(v) - Nn, (v >> ls) & MMASK) + ls) -#define COAP_PSEUDOFP_ENCODE_8_4_UP(v,ls,s) (v < HIBIT ? v : (ls = coap_fls(v) - Nn, (s = (((v + ((1<> ls) & MMASK)), s == 0 ? HIBIT + ls + 1 : s + ls)) +/** + * @defgroup encode Encode / Decode API + * API functions for endoding/decoding CoAP options. + * @{ + */ + +/** + * Decodes multiple-length byte sequences. @p buf points to an input byte + * sequence of length @p length. Returns the up to 4 byte decoded value. + * + * @param buf The input byte sequence to decode from + * @param length The length of the input byte sequence + * + * @return The decoded value + */ +unsigned int coap_decode_var_bytes(const uint8_t *buf, size_t length); /** * Decodes multiple-length byte sequences. @p buf points to an input byte - * sequence of length @p length. Returns the decoded value. + * sequence of length @p length. Returns the up to 8 byte decoded value. * * @param buf The input byte sequence to decode from * @param length The length of the input byte sequence * * @return The decoded value */ -unsigned int coap_decode_var_bytes(const uint8_t *buf, unsigned int length); +uint64_t coap_decode_var_bytes8(const uint8_t *buf, size_t length); /** * Encodes multiple-length byte sequences. @p buf points to an output buffer of - * sufficient length to store the encoded bytes. @p value is the value to - * encode. + * sufficient length to store the encoded bytes. @p value is the 4 byte value + * to encode. * Returns the number of bytes used to encode @p value or 0 on error. * - * @param buf The output buffer to decode into + * @param buf The output buffer to encode into * @param length The output buffer size to encode into (must be sufficient) * @param value The value to encode into the buffer * @@ -72,6 +78,24 @@ unsigned int coap_encode_var_safe(uint8_t *buf, size_t length, unsigned int value); +/** + * Encodes multiple-length byte sequences. @p buf points to an output buffer of + * sufficient length to store the encoded bytes. @p value is the 8 byte value + * to encode. + * Returns the number of bytes used to encode @p value or 0 on error. + * + * @param buf The output buffer to encode into + * @param length The output buffer size to encode into (must be sufficient) + * @param value The value to encode into the buffer + * + * @return The number of bytes used to encode @p value or @c 0 on error. + */ +unsigned int coap_encode_var_safe8(uint8_t *buf, + size_t length, + uint64_t value); + +/** @} */ + /** * @deprecated Use coap_encode_var_safe() instead. * Provided for backward compatibility. As @p value has a diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/libcoap.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/libcoap.h similarity index 86% rename from tools/sdk/esp32s2/include/coap/libcoap/include/coap2/libcoap.h rename to tools/sdk/esp32s2/include/coap/libcoap/include/coap3/libcoap.h index 77ba5db23e2..60ca3b64b90 100644 --- a/tools/sdk/esp32s2/include/coap/libcoap/include/coap2/libcoap.h +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/libcoap.h @@ -3,6 +3,8 @@ * * Copyright (C) 2015 Carsten Schoenert * + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ @@ -46,6 +48,13 @@ typedef USHORT in_port_t; # define COAP_DEPRECATED __attribute__ ((deprecated)) # endif #endif +#ifndef COAP_UNUSED +# ifdef __GNUC__ +# define COAP_UNUSED __attribute__((unused)) +# else /* __GNUC__ */ +# define COAP_UNUSED +# endif /* __GNUC__ */ +#endif /* COAP_UNUSED */ void coap_startup(void); diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap2/lwippools.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/lwippools.h similarity index 66% rename from tools/sdk/esp32/include/coap/libcoap/include/coap2/lwippools.h rename to tools/sdk/esp32s2/include/coap/libcoap/include/coap3/lwippools.h index cb90d8099db..445bce4a94a 100644 --- a/tools/sdk/esp32/include/coap/libcoap/include/coap2/lwippools.h +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/lwippools.h @@ -1,4 +1,6 @@ /* + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ @@ -9,10 +11,10 @@ * include this or include something more generic which includes this), and * MEMP_USE_CUSTOM_POOLS has to be set in lwipopts.h. */ -#include "coap_config.h" -#include -#include -#include +#include "coap_internal.h" +#include "net.h" +#include "resource.h" +#include "subscribe.h" #ifndef MEMP_NUM_COAPCONTEXT #define MEMP_NUM_COAPCONTEXT 1 @@ -67,6 +69,34 @@ #define MEMP_LEN_COAPSTRING 32 #endif +#ifndef MEMP_NUM_COAPCACHE_KEYS +#define MEMP_NUM_COAPCACHE_KEYS (2U) +#endif /* MEMP_NUM_COAPCACHE_KEYS */ + +#ifndef MEMP_NUM_COAPCACHE_ENTRIES +#define MEMP_NUM_COAPCACHE_ENTRIES (2U) +#endif /* MEMP_NUM_COAPCACHE_ENTRIES */ + +#ifndef MEMP_NUM_COAPPDUBUF +#define MEMP_NUM_COAPPDUBUF 2 +#endif + +#ifndef MEMP_LEN_COAPPDUBUF +#define MEMP_LEN_COAPPDUBUF 32 +#endif + +#ifndef MEMP_NUM_COAPLGXMIT +#define MEMP_NUM_COAPLGXMIT 2 +#endif + +#ifndef MEMP_NUM_COAPLGCRCV +#define MEMP_NUM_COAPLGCRCV 2 +#endif + +#ifndef MEMP_NUM_COAPLGSRCV +#define MEMP_NUM_COAPLGSRCV 2 +#endif + LWIP_MEMPOOL(COAP_CONTEXT, MEMP_NUM_COAPCONTEXT, sizeof(coap_context_t), "COAP_CONTEXT") LWIP_MEMPOOL(COAP_ENDPOINT, MEMP_NUM_COAPENDPOINT, sizeof(coap_endpoint_t), "COAP_ENDPOINT") LWIP_MEMPOOL(COAP_PACKET, MEMP_NUM_COAPPACKET, sizeof(coap_packet_t), "COAP_PACKET") @@ -78,4 +108,10 @@ LWIP_MEMPOOL(COAP_RESOURCE, MEMP_NUM_COAPRESOURCE, sizeof(coap_resource_t), "COA LWIP_MEMPOOL(COAP_RESOURCEATTR, MEMP_NUM_COAPRESOURCEATTR, sizeof(coap_attr_t), "COAP_RESOURCEATTR") LWIP_MEMPOOL(COAP_OPTLIST, MEMP_NUM_COAPOPTLIST, sizeof(coap_optlist_t)+MEMP_LEN_COAPOPTLIST, "COAP_OPTLIST") LWIP_MEMPOOL(COAP_STRING, MEMP_NUM_COAPSTRING, sizeof(coap_string_t)+MEMP_LEN_COAPSTRING, "COAP_STRING") +LWIP_MEMPOOL(COAP_CACHE_KEY, MEMP_NUM_COAPCACHE_KEYS, sizeof(coap_cache_key_t), "COAP_CACHE_KEY") +LWIP_MEMPOOL(COAP_CACHE_ENTRY, MEMP_NUM_COAPCACHE_ENTRIES, sizeof(coap_cache_entry_t), "COAP_CACHE_ENTRY") +LWIP_MEMPOOL(COAP_PDU_BUF, MEMP_NUM_COAPPDUBUF, MEMP_LEN_COAPPDUBUF, "COAP_PDU_BUF") +LWIP_MEMPOOL(COAP_LG_XMIT, MEMP_NUM_COAPLGXMIT, sizeof(coap_lg_xmit_t), "COAP_LG_XMIT") +LWIP_MEMPOOL(COAP_LG_CRCV, MEMP_NUM_COAPLGCRCV, sizeof(coap_lg_crcv_t), "COAP_LG_CRCV") +LWIP_MEMPOOL(COAP_LG_SRCV, MEMP_NUM_COAPLGSRCV, sizeof(coap_lg_srcv_t), "COAP_LG_SRCV") diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap2/mem.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/mem.h similarity index 81% rename from tools/sdk/esp32/include/coap/libcoap/include/coap2/mem.h rename to tools/sdk/esp32s2/include/coap/libcoap/include/coap3/mem.h index ea3c619fd30..c42008963da 100644 --- a/tools/sdk/esp32/include/coap/libcoap/include/coap2/mem.h +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/mem.h @@ -3,6 +3,8 @@ * * Copyright (C) 2010-2011,2014-2015 Olaf Bergmann * + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ @@ -43,6 +45,11 @@ typedef enum { #endif COAP_SESSION, COAP_OPTLIST, + COAP_CACHE_KEY, + COAP_CACHE_ENTRY, + COAP_LG_XMIT, + COAP_LG_CRCV, + COAP_LG_SRCV, } coap_memory_tag_t; #ifndef WITH_LWIP @@ -59,6 +66,22 @@ typedef enum { */ void *coap_malloc_type(coap_memory_tag_t type, size_t size); +/** + * Reallocates a chunk @p p of bytes created by coap_malloc_type() or + * coap_realloc_type() and returns a pointer to the newly allocated memory of + * @p size. + * Only COAP_STRING type is supported. + * + * Note: If there is an error, @p p will separately need to be released by + * coap_free_type(). + * + * @param type The type of object to be stored. + * @param p A pointer to memory that was allocated by coap_malloc_type(). + * @param size The number of bytes requested. + * @return A pointer to the allocated storage or @c NULL on error. + */ +void *coap_realloc_type(coap_memory_tag_t type, void *p, size_t size); + /** * Releases the memory that was allocated by coap_malloc_type(). The type tag @p * type must be the same that was used for allocating the object pointed to by diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/net.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/net.h new file mode 100644 index 00000000000..577a0b5d5a5 --- /dev/null +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/net.h @@ -0,0 +1,779 @@ +/* + * net.h -- CoAP network interface + * + * Copyright (C) 2010-2021 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +#ifndef COAP_NET_H_ +#define COAP_NET_H_ + +#include +#include +#ifndef _WIN32 +#include +#endif +#include + +#ifdef WITH_LWIP +#include +#endif + +#include "coap_io.h" +#include "coap_dtls.h" +#include "coap_event.h" +#include "pdu.h" +#include "coap_session.h" + +/** + * @defgroup context Context Handling + * API functions for handling PDUs using CoAP Contexts + * @{ + */ + +typedef enum coap_response_t { + COAP_RESPONSE_FAIL, /**< Response not liked - send CoAP RST packet */ + COAP_RESPONSE_OK /**< Response is fine */ +} coap_response_t; + +/** + * Response handler that is used as callback in coap_context_t. + * + * @param session CoAP session. + * @param sent The PDU that was transmitted. + * @param received The PDU that was received. + * @param mid CoAP transaction ID. + + * @return @c COAP_RESPONSE_OK if successful, else @c COAP_RESPONSE_FAIL which + * triggers sending a RST packet. + */ +typedef coap_response_t (*coap_response_handler_t)(coap_session_t *session, + const coap_pdu_t *sent, + const coap_pdu_t *received, + const coap_mid_t mid); + +/** + * Negative Acknowedge handler that is used as callback in coap_context_t. + * + * @param session CoAP session. + * @param sent The PDU that was transmitted. + * @param reason The reason for the NACK. + * @param mid CoAP message ID. + */ +typedef void (*coap_nack_handler_t)(coap_session_t *session, + const coap_pdu_t *sent, + const coap_nack_reason_t reason, + const coap_mid_t mid); + +/** + * Received Ping handler that is used as callback in coap_context_t. + * + * @param session CoAP session. + * @param received The PDU that was received. + * @param mid CoAP message ID. + */ +typedef void (*coap_ping_handler_t)(coap_session_t *session, + const coap_pdu_t *received, + const coap_mid_t mid); + +/** + * Received Pong handler that is used as callback in coap_context_t. + * + * @param session CoAP session. + * @param received The PDU that was received. + * @param mid CoAP message ID. + */ +typedef void (*coap_pong_handler_t)(coap_session_t *session, + const coap_pdu_t *received, + const coap_mid_t mid); + +/** + * Registers a new message handler that is called whenever a response is + * received. + * + * @param context The context to register the handler for. + * @param handler The response handler to register. + */ +void +coap_register_response_handler(coap_context_t *context, + coap_response_handler_t handler); + +/** + * Registers a new message handler that is called whenever a confirmable + * message (request or response) is dropped after all retries have been + * exhausted, or a rst message was received, or a network or TLS level + * event was received that indicates delivering the message is not possible. + * + * @param context The context to register the handler for. + * @param handler The nack handler to register. + */ +void +coap_register_nack_handler(coap_context_t *context, + coap_nack_handler_t handler); + +/** + * Registers a new message handler that is called whenever a CoAP Ping + * message is received. + * + * @param context The context to register the handler for. + * @param handler The ping handler to register. + */ +void +coap_register_ping_handler(coap_context_t *context, + coap_ping_handler_t handler); + +/** + * Registers a new message handler that is called whenever a CoAP Pong + * message is received. + * + * @param context The context to register the handler for. + * @param handler The pong handler to register. + */ +void +coap_register_pong_handler(coap_context_t *context, + coap_pong_handler_t handler); + +/** + * Registers the option type @p type with the given context object @p ctx. + * + * @param ctx The context to use. + * @param type The option type to register. + */ +void +coap_register_option(coap_context_t *ctx, uint16_t type); + +/** + * Creates a new coap_context_t object that will hold the CoAP stack status. + */ +coap_context_t *coap_new_context(const coap_address_t *listen_addr); + +/** + * Set the context's default PSK hint and/or key for a server. + * + * @param context The current coap_context_t object. + * @param hint The default PSK server hint sent to a client. If NULL, PSK + * authentication is disabled. Empty string is a valid hint. + * @param key The default PSK key. If NULL, PSK authentication will fail. + * @param key_len The default PSK key's length. If @p 0, PSK authentication will + * fail. + * + * @return @c 1 if successful, else @c 0. + */ +int coap_context_set_psk( coap_context_t *context, const char *hint, + const uint8_t *key, size_t key_len ); + +/** + * Set the context's default PSK hint and/or key for a server. + * + * @param context The current coap_context_t object. + * @param setup_data If NULL, PSK authentication will fail. PSK + * information required. + * + * @return @c 1 if successful, else @c 0. + */ +int coap_context_set_psk2(coap_context_t *context, + coap_dtls_spsk_t *setup_data); + +/** + * Set the context's default PKI information for a server. + * + * @param context The current coap_context_t object. + * @param setup_data If NULL, PKI authentication will fail. Certificate + * information required. + * + * @return @c 1 if successful, else @c 0. + */ +int +coap_context_set_pki(coap_context_t *context, + const coap_dtls_pki_t *setup_data); + +/** + * Set the context's default Root CA information for a client or server. + * + * @param context The current coap_context_t object. + * @param ca_file If not NULL, is the full path name of a PEM encoded + * file containing all the Root CAs to be used. + * @param ca_dir If not NULL, points to a directory containing PEM + * encoded files containing all the Root CAs to be used. + * + * @return @c 1 if successful, else @c 0. + */ +int +coap_context_set_pki_root_cas(coap_context_t *context, + const char *ca_file, + const char *ca_dir); + +/** + * Set the context keepalive timer for sessions. + * A keepalive message will be sent after if a session has been inactive, + * i.e. no packet sent or received, for the given number of seconds. + * For unreliable protocols, a CoAP Empty message will be sent. If a + * CoAP RST is not received, the CoAP Empty messages will get resent based + * on the Confirmable retry parameters until there is a failure timeout, + * at which point the session will be considered as disconnected. + * For reliable protocols, a CoAP PING message will be sent. If a CoAP PONG + * has not been received before the next PING is due to be sent, the session + * will be considered as disconnected. + * + * @param context The coap_context_t object. + * @param seconds Number of seconds for the inactivity timer, or zero + * to disable CoAP-level keepalive messages. + */ +void coap_context_set_keepalive(coap_context_t *context, unsigned int seconds); + +/** + * Get the libcoap internal file descriptor for using in an application's + * select() or returned as an event in an application's epoll_wait() call. + * + * @param context The coap_context_t object. + * + * @return The libcoap file descriptor or @c -1 if epoll is not available. + */ +int coap_context_get_coap_fd(const coap_context_t *context); + +/** + * Set the maximum idle sessions count. The number of server sessions that + * are currently not in use. If this number is exceeded, the least recently + * used server session is completely removed. + * 0 (the default) means that the number is not monitored. + * + * @param context The coap_context_t object. + * @param max_idle_sessions The maximum idle session count. + */ +void +coap_context_set_max_idle_sessions(coap_context_t *context, + unsigned int max_idle_sessions); + +/** + * Get the maximum idle sessions count. + * + * @param context The coap_context_t object. + * + * @return The count of max idle sessions. + */ +unsigned int +coap_context_get_max_idle_sessions(const coap_context_t *context); + +/** + * Set the session timeout value. The number of seconds of inactivity after + * which an unused server session will be closed. + * 0 means use default (300 secs). + * + * @param context The coap_context_t object. + * @param session_timeout The session timeout value. + */ +void +coap_context_set_session_timeout(coap_context_t *context, + unsigned int session_timeout); + +/** + * Get the session timeout value + * + * @param context The coap_context_t object. + * + * @return The session timeout value. + */ +unsigned int +coap_context_get_session_timeout(const coap_context_t *context); + +/** + * Set the CSM timeout value. The number of seconds to wait for a (TCP) CSM + * negotiation response from the peer. + * 0 (the default) means use wait forever. + * + * @param context The coap_context_t object. + * @param csm_tmeout The CSM timeout value. + */ +void +coap_context_set_csm_timeout(coap_context_t *context, + unsigned int csm_tmeout); + +/** + * Get the CSM timeout value + * + * @param context The coap_context_t object. + * + * @return The CSM timeout value. + */ +unsigned int +coap_context_get_csm_timeout(const coap_context_t *context); + +/** + * Set the maximum number of sessions in (D)TLS handshake value. If this number + * is exceeded, the least recently used server session in handshake is + * completely removed. + * 0 (the default) means that the number is not monitored. + * + * @param context The coap_context_t object. + * @param max_handshake_sessions The maximum number of sessions in handshake. + */ +void +coap_context_set_max_handshake_sessions(coap_context_t *context, + unsigned int max_handshake_sessions); + +/** + * Get the session timeout value + * + * @param context The coap_context_t object. + * + * @return The maximim number of sessions in (D)TLS handshake value. + */ +unsigned int +coap_context_get_max_handshake_sessions(const coap_context_t *context); + +/** + * Returns a new message id and updates @p session->tx_mid accordingly. The + * message id is returned in network byte order to make it easier to read in + * tracing tools. + * + * @param session The current coap_session_t object. + * + * @return Incremented message id in network byte order. + */ +uint16_t coap_new_message_id(coap_session_t *session); + +/** + * CoAP stack context must be released with coap_free_context(). This function + * clears all entries from the receive queue and send queue and deletes the + * resources that have been registered with @p context, and frees the attached + * endpoints. + * + * @param context The current coap_context_t object to free off. + */ +void coap_free_context(coap_context_t *context); + +/** + * Stores @p data with the given CoAP context. This function + * overwrites any value that has previously been stored with @p + * context. + * + * @param context The CoAP context. + * @param data The data to store with wih the context. Note that this data + * must be valid during the lifetime of @p context. + */ +void coap_set_app_data(coap_context_t *context, void *data); + +/** + * Returns any application-specific data that has been stored with @p + * context using the function coap_set_app_data(). This function will + * return @c NULL if no data has been stored. + * + * @param context The CoAP context. + * + * @return The data previously stored or @c NULL if not data stored. + */ +void *coap_get_app_data(const coap_context_t *context); + +/** + * Creates a new ACK PDU with specified error @p code. The options specified by + * the filter expression @p opts will be copied from the original request + * contained in @p request. Unless @c SHORT_ERROR_RESPONSE was defined at build + * time, the textual reason phrase for @p code will be added as payload, with + * Content-Type @c 0. + * This function returns a pointer to the new response message, or @c NULL on + * error. The storage allocated for the new message must be released with + * coap_free(). + * + * @param request Specification of the received (confirmable) request. + * @param code The error code to set. + * @param opts An option filter that specifies which options to copy from + * the original request in @p node. + * + * @return A pointer to the new message or @c NULL on error. + */ +coap_pdu_t *coap_new_error_response(const coap_pdu_t *request, + coap_pdu_code_t code, + coap_opt_filter_t *opts); + +/** + * Sends an error response with code @p code for request @p request to @p dst. + * @p opts will be passed to coap_new_error_response() to copy marked options + * from the request. This function returns the message id if the message was + * sent, or @c COAP_INVALID_MID otherwise. + * + * @param session The CoAP session. + * @param request The original request to respond to. + * @param code The response code. + * @param opts A filter that specifies the options to copy from the + * @p request. + * + * @return The message id if the message was sent, or @c + * COAP_INVALID_MID otherwise. + */ +coap_mid_t coap_send_error(coap_session_t *session, + const coap_pdu_t *request, + coap_pdu_code_t code, + coap_opt_filter_t *opts); + +/** + * Helper function to create and send a message with @p type (usually ACK or + * RST). This function returns @c COAP_INVALID_MID when the message was not + * sent, a valid transaction id otherwise. + * + * @param session The CoAP session. + * @param request The request that should be responded to. + * @param type Which type to set. + * @return message id on success or @c COAP_INVALID_MID + * otherwise. + */ +coap_mid_t +coap_send_message_type(coap_session_t *session, const coap_pdu_t *request, + coap_pdu_type_t type); + +/** + * Sends an ACK message with code @c 0 for the specified @p request to @p dst. + * This function returns the corresponding message id if the message was + * sent or @c COAP_INVALID_MID on error. + * + * @param session The CoAP session. + * @param request The request to be acknowledged. + * + * @return The message id if ACK was sent or @c + * COAP_INVALID_MID on error. + */ +coap_mid_t coap_send_ack(coap_session_t *session, const coap_pdu_t *request); + +/** + * Sends an RST message with code @c 0 for the specified @p request to @p dst. + * This function returns the corresponding message id if the message was + * sent or @c COAP_INVALID_MID on error. + * + * @param session The CoAP session. + * @param request The request to be reset. + * + * @return The message id if RST was sent or @c + * COAP_INVALID_MID on error. + */ +COAP_STATIC_INLINE coap_mid_t +coap_send_rst(coap_session_t *session, const coap_pdu_t *request) { + return coap_send_message_type(session, request, COAP_MESSAGE_RST); +} + +/** +* Sends a CoAP message to given peer. The memory that is +* allocated for the pdu will be released by coap_send(). +* The caller must not use the pdu after calling coap_send(). +* +* @param session The CoAP session. +* @param pdu The CoAP PDU to send. +* +* @return The message id of the sent message or @c +* COAP_INVALID_MID on error. +*/ +coap_mid_t coap_send( coap_session_t *session, coap_pdu_t *pdu ); + +#define coap_send_large(session, pdu) coap_send(session, pdu) + +/** + * Invokes the event handler of @p context for the given @p event and + * @p data. + * + * @param context The CoAP context whose event handler is to be called. + * @param event The event to deliver. + * @param session The session related to @p event. + * @return The result from the associated event handler or 0 if none was + * registered. + */ +int coap_handle_event(coap_context_t *context, + coap_event_t event, + coap_session_t *session); +/** + * Returns 1 if there are no messages to send or to dispatch in the context's + * queues. */ +int coap_can_exit(coap_context_t *context); + +/** + * Returns the current value of an internal tick counter. The counter counts \c + * COAP_TICKS_PER_SECOND ticks every second. + */ +void coap_ticks(coap_tick_t *); + +/** + * Function interface for joining a multicast group for listening for the + * currently defined endpoints that are UDP. + * + * @param ctx The current context. + * @param groupname The name of the group that is to be joined for listening. + * @param ifname Network interface to join the group on, or NULL if first + * appropriate interface is to be chosen by the O/S. + * + * @return 0 on success, -1 on error + */ +int +coap_join_mcast_group_intf(coap_context_t *ctx, const char *groupname, + const char *ifname); + +#define coap_join_mcast_group(ctx, groupname) \ + (coap_join_mcast_group_intf(ctx, groupname, NULL)) + +/** + * Function interface for defining the hop count (ttl) for sending + * multicast traffic + * + * @param session The current contexsion. + * @param hops The number of hops (ttl) to use before the multicast + * packet expires. + * + * @return 1 on success, 0 on error + */ +int +coap_mcast_set_hops(coap_session_t *session, size_t hops); + +/**@}*/ + +/** + * @defgroup app_io Application I/O Handling + * API functions for Application Input / Output + * @{ + */ + +#define COAP_IO_WAIT 0 +#define COAP_IO_NO_WAIT ((uint32_t)-1) + +/** + * The main I/O processing function. All pending network I/O is completed, + * and then optionally waits for the next input packet. + * + * This internally calls coap_io_prepare_io(), then select() for the appropriate + * sockets, updates COAP_SOCKET_CAN_xxx where appropriate and then calls + * coap_io_do_io() before returning with the time spent in the function. + * + * Alternatively, if libcoap is compiled with epoll support, this internally + * calls coap_io_prepare_epoll(), then epoll_wait() for waiting for any file + * descriptors that have (internally) been set up with epoll_ctl() and + * finally coap_io_do_epoll() before returning with the time spent in the + * function. + * + * @param ctx The CoAP context + * @param timeout_ms Minimum number of milliseconds to wait for new packets + * before returning after doing any processing. + * If COAP_IO_WAIT, the call will block until the next + * internal action (e.g. packet retransmit) if any, or block + * until the next packet is received whichever is the sooner + * and do the necessary processing. + * If COAP_IO_NO_WAIT, the function will return immediately + * after processing without waiting for any new input + * packets to arrive. + * + * @return Number of milliseconds spent in function or @c -1 if there was + * an error + */ +int coap_io_process(coap_context_t *ctx, uint32_t timeout_ms); + +#ifndef RIOT_VERSION +/** + * The main message processing loop with additional fds for internal select. + * + * @param ctx The CoAP context + * @param timeout_ms Minimum number of milliseconds to wait for new packets + * before returning after doing any processing. + * If COAP_IO_WAIT, the call will block until the next + * internal action (e.g. packet retransmit) if any, or block + * until the next packet is received whichever is the sooner + * and do the necessary processing. + * If COAP_IO_NO_WAIT, the function will return immediately + * after processing without waiting for any new input + * packets to arrive. + * @param nfds The maximum FD set in readfds, writefds or exceptfds + * plus one, + * @param readfds Read FDs to additionally check for in internal select() + * or NULL if not required. + * @param writefds Write FDs to additionally check for in internal select() + * or NULL if not required. + * @param exceptfds Except FDs to additionally check for in internal select() + * or NULL if not required. + * + * + * @return Number of milliseconds spent in coap_io_process_with_fds, or @c -1 + * if there was an error. If defined, readfds, writefds, exceptfds + * are updated as returned by the internal select() call. + */ +int coap_io_process_with_fds(coap_context_t *ctx, uint32_t timeout_ms, + int nfds, fd_set *readfds, fd_set *writefds, + fd_set *exceptfds); +#endif /* !RIOT_VERSION */ + +/**@}*/ + +/** + * @defgroup app_io_internal Application I/O Handling (Internal) + * Internal API functions for Application Input / Output + * @{ + */ + +/** +* Iterates through all the coap_socket_t structures embedded in endpoints or +* sessions associated with the @p ctx to determine which are wanting any +* read, write, accept or connect I/O (COAP_SOCKET_WANT_xxx is set). If set, +* the coap_socket_t is added to the @p sockets. +* +* Any now timed out delayed packet is transmitted, along with any packets +* associated with requested observable response. +* +* In addition, it returns when the next expected I/O is expected to take place +* (e.g. a packet retransmit). +* +* Prior to calling coap_io_do_io(), the @p sockets must be tested to see +* if any of the COAP_SOCKET_WANT_xxx have the appropriate information and if +* so, COAP_SOCKET_CAN_xxx is set. This typically will be done after using a +* select() call. +* +* Note: If epoll support is compiled into libcoap, coap_io_prepare_epoll() must +* be used instead of coap_io_prepare_io(). +* +* Internal function. +* +* @param ctx The CoAP context +* @param sockets Array of socket descriptors, filled on output +* @param max_sockets Size of socket array. +* @param num_sockets Pointer to the number of valid entries in the socket +* arrays on output. +* @param now Current time. +* +* @return timeout Maxmimum number of milliseconds that can be used by a +* select() to wait for network events or 0 if wait should be +* forever. +*/ +unsigned int +coap_io_prepare_io(coap_context_t *ctx, + coap_socket_t *sockets[], + unsigned int max_sockets, + unsigned int *num_sockets, + coap_tick_t now +); + +/** + * Processes any outstanding read, write, accept or connect I/O as indicated + * in the coap_socket_t structures (COAP_SOCKET_CAN_xxx set) embedded in + * endpoints or sessions associated with @p ctx. + * + * Note: If epoll support is compiled into libcoap, coap_io_do_epoll() must + * be used instead of coap_io_do_io(). + * + * Internal function. + * + * @param ctx The CoAP context + * @param now Current time + */ +void coap_io_do_io(coap_context_t *ctx, coap_tick_t now); + +/** + * Any now timed out delayed packet is transmitted, along with any packets + * associated with requested observable response. + * + * In addition, it returns when the next expected I/O is expected to take place + * (e.g. a packet retransmit). + * + * Note: If epoll support is compiled into libcoap, coap_io_prepare_epoll() must + * be used instead of coap_io_prepare_io(). + * + * Internal function. + * + * @param ctx The CoAP context + * @param now Current time. + * + * @return timeout Maxmimum number of milliseconds that can be used by a + * epoll_wait() to wait for network events or 0 if wait should be + * forever. + */ +unsigned int +coap_io_prepare_epoll(coap_context_t *ctx, coap_tick_t now); + +struct epoll_event; + +/** + * Process all the epoll events + * + * Note: If epoll support is compiled into libcoap, coap_io_do_epoll() must + * be used instead of coap_io_do_io(). + * + * Internal function + * + * @param ctx The current CoAP context. + * @param events The list of events returned from an epoll_wait() call. + * @param nevents The number of events. + * + */ +void coap_io_do_epoll(coap_context_t *ctx, struct epoll_event* events, + size_t nevents); + +/**@}*/ + +/** + * @deprecated Use coap_io_process() instead. + * + * This function just calls coap_io_process(). + * + * @param ctx The CoAP context + * @param timeout_ms Minimum number of milliseconds to wait for new packets + * before returning after doing any processing. + * If COAP_IO_WAIT, the call will block until the next + * internal action (e.g. packet retransmit) if any, or block + * until the next packet is received whichever is the sooner + * and do the necessary processing. + * If COAP_IO_NO_WAIT, the function will return immediately + * after processing without waiting for any new input + * packets to arrive. + * + * @return Number of milliseconds spent in function or @c -1 if there was + * an error + */ +COAP_STATIC_INLINE COAP_DEPRECATED int +coap_run_once(coap_context_t *ctx, uint32_t timeout_ms) +{ + return coap_io_process(ctx, timeout_ms); +} + +/** +* @deprecated Use coap_io_prepare_io() instead. +* +* This function just calls coap_io_prepare_io(). +* +* Internal function. +* +* @param ctx The CoAP context +* @param sockets Array of socket descriptors, filled on output +* @param max_sockets Size of socket array. +* @param num_sockets Pointer to the number of valid entries in the socket +* arrays on output. +* @param now Current time. +* +* @return timeout Maxmimum number of milliseconds that can be used by a +* select() to wait for network events or 0 if wait should be +* forever. +*/ +COAP_STATIC_INLINE COAP_DEPRECATED unsigned int +coap_write(coap_context_t *ctx, + coap_socket_t *sockets[], + unsigned int max_sockets, + unsigned int *num_sockets, + coap_tick_t now +) { + return coap_io_prepare_io(ctx, sockets, max_sockets, num_sockets, now); +} + +/** + * @deprecated Use coap_io_do_io() instead. + * + * This function just calls coap_io_do_io(). + * + * Internal function. + * + * @param ctx The CoAP context + * @param now Current time + */ +COAP_STATIC_INLINE COAP_DEPRECATED void +coap_read(coap_context_t *ctx, coap_tick_t now +) { + coap_io_do_io(ctx, now); +} + +/* Old definitions which may be hanging around in old code - be helpful! */ +#define COAP_RUN_NONBLOCK COAP_RUN_NONBLOCK_deprecated_use_COAP_IO_NO_WAIT +#define COAP_RUN_BLOCK COAP_RUN_BLOCK_deprecated_use_COAP_IO_WAIT + +#endif /* COAP_NET_H_ */ diff --git a/tools/sdk/esp32/include/coap/libcoap/include/coap2/option.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/option.h similarity index 77% rename from tools/sdk/esp32/include/coap/libcoap/include/coap2/option.h rename to tools/sdk/esp32s2/include/coap/libcoap/include/coap3/option.h index 3af9e71e706..c01e8f6688b 100644 --- a/tools/sdk/esp32/include/coap/libcoap/include/coap2/option.h +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/option.h @@ -3,6 +3,8 @@ * * Copyright (C) 2010-2013 Olaf Bergmann * + * SPDX-License-Identifier: BSD-2-Clause + * * This file is part of the CoAP library libcoap. Please see README for terms * of use. */ @@ -15,8 +17,7 @@ #ifndef COAP_OPTION_H_ #define COAP_OPTION_H_ -#include "bits.h" -#include "pdu.h" +typedef uint16_t coap_option_num_t; /** * Use byte-oriented access methods here because sliding a complex struct @@ -89,134 +90,66 @@ size_t coap_opt_size(const coap_opt_t *opt); #error COAP_OPT_FILTER_SHORT + COAP_OPT_FILTER_LONG must be less or equal 16 #endif /* (COAP_OPT_FILTER_SHORT + COAP_OPT_FILTER_LONG > 16) */ -/** The number of elements in coap_opt_filter_t. */ -#define COAP_OPT_FILTER_SIZE \ - (((COAP_OPT_FILTER_SHORT + 1) >> 1) + COAP_OPT_FILTER_LONG) +1 - -/** - * Fixed-size vector we use for option filtering. It is large enough - * to hold COAP_OPT_FILTER_SHORT entries with an option number between - * 0 and 255, and COAP_OPT_FILTER_LONG entries with an option number - * between 256 and 65535. Its internal structure is - * - * @code -struct { +/* + * mask contains a bit vector that indicates which fields in the long_opts[] + * and subsequent short_opts[] are used. The first COAP_OPT_FILTER_LONG bits + * correspond to the long option types that are stored in long_opts[] + * elements. The next COAP_OPT_FILTER_SHORT bits correspond to the short + * option types that are stored in short_opts[]. + */ +typedef struct coap_opt_filter_t { uint16_t mask; uint16_t long_opts[COAP_OPT_FILTER_LONG]; uint8_t short_opts[COAP_OPT_FILTER_SHORT]; -} - * @endcode - * - * The first element contains a bit vector that indicates which fields - * in the remaining array are used. The first COAP_OPT_FILTER_LONG - * bits correspond to the long option types that are stored in the - * elements from index 1 to COAP_OPT_FILTER_LONG. The next - * COAP_OPT_FILTER_SHORT bits correspond to the short option types - * that are stored in the elements from index COAP_OPT_FILTER_LONG + 1 - * to COAP_OPT_FILTER_LONG + COAP_OPT_FILTER_SHORT. The latter - * elements are treated as bytes. - */ -typedef uint16_t coap_opt_filter_t[COAP_OPT_FILTER_SIZE]; +} coap_opt_filter_t; /** Pre-defined filter that includes all options. */ #define COAP_OPT_ALL NULL /** - * Clears filter @p f. + * Clears filter @p filter. * - * @param f The filter to clear. + * @param filter The filter to clear. */ -COAP_STATIC_INLINE void -coap_option_filter_clear(coap_opt_filter_t f) { - memset(f, 0, sizeof(coap_opt_filter_t)); -} +void +coap_option_filter_clear(coap_opt_filter_t *filter); /** - * Sets the corresponding entry for @p type in @p filter. This + * Sets the corresponding entry for @p number in @p filter. This * function returns @c 1 if bit was set or @c 0 on error (i.e. when - * the given type does not fit in the filter). + * the given number does not fit in the filter). * * @param filter The filter object to change. - * @param type The type for which the bit should be set. + * @param number The option number for which the bit should be set. * * @return @c 1 if bit was set, @c 0 otherwise. */ -int coap_option_filter_set(coap_opt_filter_t filter, uint16_t type); +int coap_option_filter_set(coap_opt_filter_t *filter, coap_option_num_t number); /** - * Clears the corresponding entry for @p type in @p filter. This + * Clears the corresponding entry for @p number in @p filter. This * function returns @c 1 if bit was set or @c 0 on error (i.e. when - * the given type does not fit in the filter). + * the given number does not fit in the filter). * * @param filter The filter object to change. - * @param type The type that should be cleared from the filter. + * @param number The option number that should be cleared from the filter. * * @return @c 1 if bit was set, @c 0 otherwise. */ -int coap_option_filter_unset(coap_opt_filter_t filter, uint16_t type); +int coap_option_filter_unset(coap_opt_filter_t *filter, + coap_option_num_t number); /** - * Checks if @p type is contained in @p filter. This function returns + * Checks if @p number is contained in @p filter. This function returns * @c 1 if found, @c 0 if not, or @c -1 on error (i.e. when the given - * type does not fit in the filter). + * number does not fit in the filter). * * @param filter The filter object to search. - * @param type The type to search for. + * @param number The option number to search for. * - * @return @c 1 if @p type was found, @c 0 otherwise, or @c -1 on error. + * @return @c 1 if @p number was found, @c 0 otherwise, or @c -1 on error. */ -int coap_option_filter_get(coap_opt_filter_t filter, uint16_t type); - -/** - * Sets the corresponding bit for @p type in @p filter. This function returns @c - * 1 if bit was set or @c -1 on error (i.e. when the given type does not fit in - * the filter). - * - * @deprecated Use coap_option_filter_set() instead. - * - * @param filter The filter object to change. - * @param type The type for which the bit should be set. - * - * @return @c 1 if bit was set, @c -1 otherwise. - */ -COAP_STATIC_INLINE int -coap_option_setb(coap_opt_filter_t filter, uint16_t type) { - return coap_option_filter_set(filter, type) ? 1 : -1; -} - -/** - * Clears the corresponding bit for @p type in @p filter. This function returns - * @c 1 if bit was cleared or @c -1 on error (i.e. when the given type does not - * fit in the filter). - * - * @deprecated Use coap_option_filter_unset() instead. - * - * @param filter The filter object to change. - * @param type The type for which the bit should be cleared. - * - * @return @c 1 if bit was set, @c -1 otherwise. - */ -COAP_STATIC_INLINE int -coap_option_clrb(coap_opt_filter_t filter, uint16_t type) { - return coap_option_filter_unset(filter, type) ? 1 : -1; -} - -/** - * Gets the corresponding bit for @p type in @p filter. This function returns @c - * 1 if the bit is set @c 0 if not, or @c -1 on error (i.e. when the given type - * does not fit in the filter). - * - * @deprecated Use coap_option_filter_get() instead. - * - * @param filter The filter object to read bit from. - * @param type The type for which the bit should be read. - * - * @return @c 1 if bit was set, @c 0 if not, @c -1 on error. - */ -COAP_STATIC_INLINE int -coap_option_getb(coap_opt_filter_t filter, uint16_t type) { - return coap_option_filter_get(filter, type); -} +int coap_option_filter_get(coap_opt_filter_t *filter, coap_option_num_t number); /** * Iterator to run through PDU options. This object must be @@ -236,7 +169,7 @@ coap_option_getb(coap_opt_filter_t filter, uint16_t type) { */ typedef struct { size_t length; /**< remaining length of PDU */ - uint16_t type; /**< decoded option type */ + coap_option_num_t number; /**< decoded option number */ unsigned int bad:1; /**< iterator object is ok if not set */ unsigned int filtered:1; /**< denotes whether or not filter is used */ coap_opt_t *next_option; /**< pointer to the unparsed next option */ @@ -251,8 +184,8 @@ typedef struct { * * @param pdu The PDU the options of which should be walked through. * @param oi An iterator object that will be initilized. - * @param filter An optional option type filter. - * With @p type != @c COAP_OPT_ALL, coap_option_next() + * @param filter An optional option number filter. + * With @p number != @c COAP_OPT_ALL, coap_option_next() * will return only options matching this bitmask. * Fence-post options @c 14, @c 28, @c 42, ... are always * skipped. @@ -261,18 +194,18 @@ typedef struct { */ coap_opt_iterator_t *coap_option_iterator_init(const coap_pdu_t *pdu, coap_opt_iterator_t *oi, - const coap_opt_filter_t filter); + const coap_opt_filter_t *filter); /** * Updates the iterator @p oi to point to the next option. This function returns * a pointer to that option or @c NULL if no more options exist. The contents of * @p oi will be updated. In particular, @c oi->n specifies the current option's - * ordinal number (counted from @c 1), @c oi->type is the option's type code, - * and @c oi->option points to the beginning of the current option itself. When - * advanced past the last option, @c oi->option will be @c NULL. + * ordinal number (counted from @c 1), @c oi->number is the option's number + * value, and @c oi->option points to the beginning of the current option + * itself. When * advanced past the last option, @c oi->option will be @c NULL. * * Note that options are skipped whose corresponding bits in the filter - * specified with coap_option_iterator_init() are @c 0. Options with type codes + * specified with coap_option_iterator_init() are @c 0. Options with numbers * that do not fit in this filter hence will always be returned. * * @param oi The option iterator to update. @@ -282,20 +215,20 @@ coap_opt_iterator_t *coap_option_iterator_init(const coap_pdu_t *pdu, coap_opt_t *coap_option_next(coap_opt_iterator_t *oi); /** - * Retrieves the first option of type @p type from @p pdu. @p oi must point to a - * coap_opt_iterator_t object that will be initialized by this function to - * filter only options with code @p type. This function returns the first option - * with this type, or @c NULL if not found. + * Retrieves the first option of number @p number from @p pdu. @p oi must + * point to a coap_opt_iterator_t object that will be initialized by this + * function to filter only options with number @p number. This function returns + * the first option with this number, or @c NULL if not found. * * @param pdu The PDU to parse for options. - * @param type The option type code to search for. + * @param number The option number to search for. * @param oi An iterator object to use. * - * @return A pointer to the first option of type @p type, or @c NULL if + * @return A pointer to the first option of number @p number, or @c NULL if * not found. */ -coap_opt_t *coap_check_option(coap_pdu_t *pdu, - uint16_t type, +coap_opt_t *coap_check_option(const coap_pdu_t *pdu, + coap_option_num_t number, coap_opt_iterator_t *oi); /** @@ -349,18 +282,6 @@ size_t coap_opt_encode(coap_opt_t *opt, const uint8_t *val, size_t length); -/** - * Decodes the delta value of the next option. This function returns the number - * of bytes read or @c 0 on error. The caller of this function must ensure that - * it does not read over the boundaries of @p opt (e.g. by calling - * coap_opt_check_delta(). - * - * @param opt The option to examine. - * - * @return The number of bytes read or @c 0 on error. - */ -uint16_t coap_opt_delta(const coap_opt_t *opt); - /** * Returns the length of the given option. @p opt must point to an option jump * or the beginning of the option. This function returns @c 0 when @p opt is not @@ -374,7 +295,7 @@ uint16_t coap_opt_delta(const coap_opt_t *opt); * * @return The option's length or @c 0 when undefined. */ -uint16_t coap_opt_length(const coap_opt_t *opt); +uint32_t coap_opt_length(const coap_opt_t *opt); /** * Returns a pointer to the value of the given option. @p opt must point to an @@ -387,8 +308,6 @@ uint16_t coap_opt_length(const coap_opt_t *opt); */ const uint8_t *coap_opt_value(const coap_opt_t *opt); -/** @} */ - /** * Representation of chained list of CoAP options to install. * @@ -415,6 +334,12 @@ typedef struct coap_optlist_t { /** * Create a new optlist entry. * + * Note: Where possible, the option data needs to be stripped of leading zeros + * (big endian) to reduce the amount of data needed in the PDU, as well as in + * some cases the maximum data size of an opton can be exceeded if not stripped + * and hence be illegal. This is done by using coap_encode_var_safe() or + * coap_encode_var_safe8(). + * * @param number The option number (COAP_OPTION_*) * @param length The option length * @param data The option value data @@ -458,4 +383,57 @@ int coap_insert_optlist(coap_optlist_t **optlist_chain, */ void coap_delete_optlist(coap_optlist_t *optlist_chain); +/** @} */ + +/** + * Sets the corresponding bit for @p type in @p filter. This function returns @c + * 1 if bit was set or @c -1 on error (i.e. when the given type does not fit in + * the filter). + * + * @deprecated Use coap_option_filter_set() instead. + * + * @param filter The filter object to change. + * @param type The type for which the bit should be set. + * + * @return @c 1 if bit was set, @c -1 otherwise. + */ +COAP_STATIC_INLINE COAP_DEPRECATED int +coap_option_setb(coap_opt_filter_t *filter, uint16_t type) { + return coap_option_filter_set(filter, type) ? 1 : -1; +} + +/** + * Clears the corresponding bit for @p type in @p filter. This function returns + * @c 1 if bit was cleared or @c -1 on error (i.e. when the given type does not + * fit in the filter). + * + * @deprecated Use coap_option_filter_unset() instead. + * + * @param filter The filter object to change. + * @param type The type for which the bit should be cleared. + * + * @return @c 1 if bit was set, @c -1 otherwise. + */ +COAP_STATIC_INLINE COAP_DEPRECATED int +coap_option_clrb(coap_opt_filter_t *filter, uint16_t type) { + return coap_option_filter_unset(filter, type) ? 1 : -1; +} + +/** + * Gets the corresponding bit for @p type in @p filter. This function returns @c + * 1 if the bit is set @c 0 if not, or @c -1 on error (i.e. when the given type + * does not fit in the filter). + * + * @deprecated Use coap_option_filter_get() instead. + * + * @param filter The filter object to read bit from. + * @param type The type for which the bit should be read. + * + * @return @c 1 if bit was set, @c 0 if not, @c -1 on error. + */ +COAP_STATIC_INLINE COAP_DEPRECATED int +coap_option_getb(coap_opt_filter_t *filter, uint16_t type) { + return coap_option_filter_get(filter, type); +} + #endif /* COAP_OPTION_H_ */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/pdu.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/pdu.h new file mode 100644 index 00000000000..a22869b69ed --- /dev/null +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/pdu.h @@ -0,0 +1,572 @@ +/* + * pdu.h -- CoAP message structure + * + * Copyright (C) 2010-2014 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file pdu.h + * @brief Pre-defined constants that reflect defaults for CoAP + */ + +#ifndef COAP_PDU_H_ +#define COAP_PDU_H_ + +#include "uri.h" +#include "option.h" + +#ifdef WITH_LWIP +#include +#endif + +#include + +/** + * @defgroup pdu PDU + * API functions for PDUs + * @{ + */ + +#define COAP_DEFAULT_PORT 5683 /* CoAP default UDP/TCP port */ +#define COAPS_DEFAULT_PORT 5684 /* CoAP default UDP/TCP port for secure transmission */ +#define COAP_DEFAULT_MAX_AGE 60 /* default maximum object lifetime in seconds */ +#ifndef COAP_DEFAULT_MTU +#define COAP_DEFAULT_MTU 1152 +#endif /* COAP_DEFAULT_MTU */ + +#ifndef COAP_DEFAULT_HOP_LIMIT +#define COAP_DEFAULT_HOP_LIMIT 16 +#endif /* COAP_DEFAULT_HOP_LIMIT */ + +#define COAP_DEFAULT_SCHEME "coap" /* the default scheme for CoAP URIs */ + +/** well-known resources URI */ +#define COAP_DEFAULT_URI_WELLKNOWN ".well-known/core" + +/* CoAP message types */ + +/** + * CoAP PDU message type definitions + */ +typedef enum coap_pdu_type_t { + COAP_MESSAGE_CON, /* 0 confirmable message (requires ACK/RST) */ + COAP_MESSAGE_NON, /* 1 non-confirmable message (one-shot message) */ + COAP_MESSAGE_ACK, /* 2 used to acknowledge confirmable messages */ + COAP_MESSAGE_RST /* 3 indicates error in received messages */ +} coap_pdu_type_t; + +/** + * CoAP PDU Request methods + */ +typedef enum coap_request_t { + COAP_REQUEST_GET = 1, + COAP_REQUEST_POST, /* 2 */ + COAP_REQUEST_PUT, /* 3 */ + COAP_REQUEST_DELETE, /* 4 */ + COAP_REQUEST_FETCH, /* 5 RFC 8132 */ + COAP_REQUEST_PATCH, /* 6 RFC 8132 */ + COAP_REQUEST_IPATCH, /* 7 RFC 8132 */ +} coap_request_t; + +/* + * CoAP option numbers (be sure to update coap_option_check_critical() and + * coap_add_option() when adding options + */ + +/* + * The C, U, and N flags indicate the properties + * Critical, Unsafe, and NoCacheKey, respectively. + * If U is set, then N has no meaning as per + * https://tools.ietf.org/html/rfc7252#section-5.10 + * and is set to a -. + * + * Separately, R is for the options that can be repeated + * + * The least significant byte of the option is set as followed + * as per https://tools.ietf.org/html/rfc7252#section-5.4.6 + * + * 0 1 2 3 4 5 6 7 + * --+---+---+---+---+---+---+---+ + * | NoCacheKey| U | C | + * --+---+---+---+---+---+---+---+ + * + * https://tools.ietf.org/html/rfc8613#section-4 goes on to define E, I and U + * properties Encrypted and Integrity Protected, Integrity Protected Only, and + * Unprotected respectively. Integrity Protected Only is not currently used. + * + * An Option is tagged with CUNREIU with any of the letters replaced with _ if + * not set, or - for N if U is set (see above) for aiding understanding of the + * Option. + */ + +#define COAP_OPTION_IF_MATCH 1 /* C__RE__, opaque, 0-8 B, RFC7252 */ +#define COAP_OPTION_URI_HOST 3 /* CU-___U, String, 1-255 B, RFC7252 */ +#define COAP_OPTION_ETAG 4 /* ___RE__, opaque, 1-8 B, RFC7252 */ +#define COAP_OPTION_IF_NONE_MATCH 5 /* C___E__, empty, 0 B, RFC7252 */ +#define COAP_OPTION_OBSERVE 6 /* _U-_E_U, empty/uint,0/0-3 B, RFC7641 */ +#define COAP_OPTION_URI_PORT 7 /* CU-___U, uint, 0-2 B, RFC7252 */ +#define COAP_OPTION_LOCATION_PATH 8 /* ___RE__, String, 0-255 B, RFC7252 */ +#define COAP_OPTION_OSCORE 9 /* C_____U, *, 0-255 B, RFC8613 */ +#define COAP_OPTION_URI_PATH 11 /* CU-RE__, String, 0-255 B, RFC7252 */ +#define COAP_OPTION_CONTENT_FORMAT 12 /* ____E__, uint, 0-2 B, RFC7252 */ +#define COAP_OPTION_CONTENT_TYPE COAP_OPTION_CONTENT_FORMAT +/* COAP_OPTION_MAXAGE default 60 seconds if not set */ +#define COAP_OPTION_MAXAGE 14 /* _U-_E_U, uint, 0-4 B, RFC7252 */ +#define COAP_OPTION_URI_QUERY 15 /* CU-RE__, String, 1-255 B, RFC7252 */ +#define COAP_OPTION_HOP_LIMIT 16 /* ______U, uint, 1 B, RFC8768 */ +#define COAP_OPTION_ACCEPT 17 /* C___E__, uint, 0-2 B, RFC7252 */ +#define COAP_OPTION_LOCATION_QUERY 20 /* ___RE__, String, 0-255 B, RFC7252 */ +#define COAP_OPTION_BLOCK2 23 /* CU-_E_U, uint, 0-3 B, RFC7959 */ +#define COAP_OPTION_BLOCK1 27 /* CU-_E_U, uint, 0-3 B, RFC7959 */ +#define COAP_OPTION_SIZE2 28 /* __N_E_U, uint, 0-4 B, RFC7959 */ +#define COAP_OPTION_PROXY_URI 35 /* CU-___U, String, 1-1034 B, RFC7252 */ +#define COAP_OPTION_PROXY_SCHEME 39 /* CU-___U, String, 1-255 B, RFC7252 */ +#define COAP_OPTION_SIZE1 60 /* __N_E_U, uint, 0-4 B, RFC7252 */ +#define COAP_OPTION_NORESPONSE 258 /* _U-_E_U, uint, 0-1 B, RFC7967 */ + +#define COAP_MAX_OPT 65535 /**< the highest option number we know */ + +/* CoAP result codes (HTTP-Code / 100 * 40 + HTTP-Code % 100) */ + +/* As of draft-ietf-core-coap-04, response codes are encoded to base + * 32, i.e. the three upper bits determine the response class while + * the remaining five fine-grained information specific to that class. + */ +#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100) + +/* Determines the class of response code C */ +#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF) + +#ifndef SHORT_ERROR_RESPONSE +/** + * Returns a human-readable response phrase for the specified CoAP response @p + * code. This function returns @c NULL if not found. + * + * @param code The response code for which the literal phrase should be + * retrieved. + * + * @return A zero-terminated string describing the error, or @c NULL if not + * found. + */ +const char *coap_response_phrase(unsigned char code); + +#define COAP_ERROR_PHRASE_LENGTH 32 /**< maximum length of error phrase */ + +#else +#define coap_response_phrase(x) ((char *)NULL) + +#define COAP_ERROR_PHRASE_LENGTH 0 /**< maximum length of error phrase */ +#endif /* SHORT_ERROR_RESPONSE */ + +#define COAP_SIGNALING_CODE(N) (((N)/100 << 5) | (N)%100) + +typedef enum coap_pdu_signaling_proto_t { + COAP_SIGNALING_CSM = COAP_SIGNALING_CODE(701), + COAP_SIGNALING_PING = COAP_SIGNALING_CODE(702), + COAP_SIGNALING_PONG = COAP_SIGNALING_CODE(703), + COAP_SIGNALING_RELEASE = COAP_SIGNALING_CODE(704), + COAP_SIGNALING_ABORT = COAP_SIGNALING_CODE(705), +} coap_pdu_signaling_proto_t; + +/* Applies to COAP_SIGNALING_CSM */ +#define COAP_SIGNALING_OPTION_MAX_MESSAGE_SIZE 2 +#define COAP_SIGNALING_OPTION_BLOCK_WISE_TRANSFER 4 +/* Applies to COAP_SIGNALING_PING / COAP_SIGNALING_PONG */ +#define COAP_SIGNALING_OPTION_CUSTODY 2 +/* Applies to COAP_SIGNALING_RELEASE */ +#define COAP_SIGNALING_OPTION_ALTERNATIVE_ADDRESS 2 +#define COAP_SIGNALING_OPTION_HOLD_OFF 4 +/* Applies to COAP_SIGNALING_ABORT */ +#define COAP_SIGNALING_OPTION_BAD_CSM_OPTION 2 + +/* CoAP media type encoding */ + +#define COAP_MEDIATYPE_TEXT_PLAIN 0 /* text/plain (UTF-8) */ +#define COAP_MEDIATYPE_APPLICATION_LINK_FORMAT 40 /* application/link-format */ +#define COAP_MEDIATYPE_APPLICATION_XML 41 /* application/xml */ +#define COAP_MEDIATYPE_APPLICATION_OCTET_STREAM 42 /* application/octet-stream */ +#define COAP_MEDIATYPE_APPLICATION_RDF_XML 43 /* application/rdf+xml */ +#define COAP_MEDIATYPE_APPLICATION_EXI 47 /* application/exi */ +#define COAP_MEDIATYPE_APPLICATION_JSON 50 /* application/json */ +#define COAP_MEDIATYPE_APPLICATION_CBOR 60 /* application/cbor */ +#define COAP_MEDIATYPE_APPLICATION_CWT 61 /* application/cwt, RFC 8392 */ + +/* Content formats from RFC 8152 */ +#define COAP_MEDIATYPE_APPLICATION_COSE_SIGN 98 /* application/cose; cose-type="cose-sign" */ +#define COAP_MEDIATYPE_APPLICATION_COSE_SIGN1 18 /* application/cose; cose-type="cose-sign1" */ +#define COAP_MEDIATYPE_APPLICATION_COSE_ENCRYPT 96 /* application/cose; cose-type="cose-encrypt" */ +#define COAP_MEDIATYPE_APPLICATION_COSE_ENCRYPT0 16 /* application/cose; cose-type="cose-encrypt0" */ +#define COAP_MEDIATYPE_APPLICATION_COSE_MAC 97 /* application/cose; cose-type="cose-mac" */ +#define COAP_MEDIATYPE_APPLICATION_COSE_MAC0 17 /* application/cose; cose-type="cose-mac0" */ + +#define COAP_MEDIATYPE_APPLICATION_COSE_KEY 101 /* application/cose-key */ +#define COAP_MEDIATYPE_APPLICATION_COSE_KEY_SET 102 /* application/cose-key-set */ + +/* Content formats from RFC 8428 */ +#define COAP_MEDIATYPE_APPLICATION_SENML_JSON 110 /* application/senml+json */ +#define COAP_MEDIATYPE_APPLICATION_SENSML_JSON 111 /* application/sensml+json */ +#define COAP_MEDIATYPE_APPLICATION_SENML_CBOR 112 /* application/senml+cbor */ +#define COAP_MEDIATYPE_APPLICATION_SENSML_CBOR 113 /* application/sensml+cbor */ +#define COAP_MEDIATYPE_APPLICATION_SENML_EXI 114 /* application/senml-exi */ +#define COAP_MEDIATYPE_APPLICATION_SENSML_EXI 115 /* application/sensml-exi */ +#define COAP_MEDIATYPE_APPLICATION_SENML_XML 310 /* application/senml+xml */ +#define COAP_MEDIATYPE_APPLICATION_SENSML_XML 311 /* application/sensml+xml */ + +/* Content formats from RFC 8782 */ +#define COAP_MEDIATYPE_APPLICATION_DOTS_CBOR 271 /* application/dots+cbor */ + +/* Note that identifiers for registered media types are in the range 0-65535. We + * use an unallocated type here and hope for the best. */ +#define COAP_MEDIATYPE_ANY 0xff /* any media type */ + +/** + * coap_mid_t is used to store the CoAP Message ID of a CoAP PDU. + * Valid message ids are 0 to 2^16. Negative values are error codes. + */ +typedef int coap_mid_t; + +/** Indicates an invalid message id. */ +#define COAP_INVALID_MID -1 + +/** + * Indicates an invalid message id. + * @deprecated Use COAP_INVALID_MID instead. + */ +#define COAP_INVALID_TID COAP_INVALID_MID + +/** + * @deprecated Use coap_optlist_t instead. + * + * Structures for more convenient handling of options. (To be used with ordered + * coap_list_t.) The option's data will be added to the end of the coap_option + * structure (see macro COAP_OPTION_DATA). + */ +COAP_DEPRECATED typedef struct { + uint16_t key; /* the option key (no delta coding) */ + unsigned int length; +} coap_option; + +#define COAP_OPTION_KEY(option) (option).key +#define COAP_OPTION_LENGTH(option) (option).length +#define COAP_OPTION_DATA(option) ((unsigned char *)&(option) + sizeof(coap_option)) + +#ifdef WITH_LWIP +/** + * Creates a CoAP PDU from an lwIP @p pbuf, whose reference is passed on to this + * function. + * + * The pbuf is checked for being contiguous, and for having only one reference. + * The reference is stored in the PDU and will be freed when the PDU is freed. + * + * (For now, these are fatal errors; in future, a new pbuf might be allocated, + * the data copied and the passed pbuf freed). + * + * This behaves like coap_pdu_init(0, 0, 0, pbuf->tot_len), and afterwards + * copying the contents of the pbuf to the pdu. + * + * @return A pointer to the new PDU object or @c NULL on error. + */ +coap_pdu_t * coap_pdu_from_pbuf(struct pbuf *pbuf); +#endif + +/** +* CoAP protocol types +*/ +typedef enum coap_proto_t { + COAP_PROTO_NONE = 0, + COAP_PROTO_UDP, + COAP_PROTO_DTLS, + COAP_PROTO_TCP, + COAP_PROTO_TLS, +} coap_proto_t; + +/** + * Set of codes available for a PDU. + */ +typedef enum coap_pdu_code_t { + COAP_EMPTY_CODE = 0, + + COAP_REQUEST_CODE_GET = COAP_REQUEST_GET, + COAP_REQUEST_CODE_POST = COAP_REQUEST_POST, + COAP_REQUEST_CODE_PUT = COAP_REQUEST_PUT, + COAP_REQUEST_CODE_DELETE = COAP_REQUEST_DELETE, + COAP_REQUEST_CODE_FETCH = COAP_REQUEST_FETCH, + COAP_REQUEST_CODE_PATCH = COAP_REQUEST_PATCH, + COAP_REQUEST_CODE_IPATCH = COAP_REQUEST_IPATCH, + + COAP_RESPONSE_CODE_OK = COAP_RESPONSE_CODE(200), + COAP_RESPONSE_CODE_CREATED = COAP_RESPONSE_CODE(201), + COAP_RESPONSE_CODE_DELETED = COAP_RESPONSE_CODE(202), + COAP_RESPONSE_CODE_VALID = COAP_RESPONSE_CODE(203), + COAP_RESPONSE_CODE_CHANGED = COAP_RESPONSE_CODE(204), + COAP_RESPONSE_CODE_CONTENT = COAP_RESPONSE_CODE(205), + COAP_RESPONSE_CODE_CONTINUE = COAP_RESPONSE_CODE(231), + COAP_RESPONSE_CODE_BAD_REQUEST = COAP_RESPONSE_CODE(400), + COAP_RESPONSE_CODE_UNAUTHORIZED = COAP_RESPONSE_CODE(401), + COAP_RESPONSE_CODE_BAD_OPTION = COAP_RESPONSE_CODE(402), + COAP_RESPONSE_CODE_FORBIDDEN = COAP_RESPONSE_CODE(403), + COAP_RESPONSE_CODE_NOT_FOUND = COAP_RESPONSE_CODE(404), + COAP_RESPONSE_CODE_NOT_ALLOWED = COAP_RESPONSE_CODE(405), + COAP_RESPONSE_CODE_NOT_ACCEPTABLE = COAP_RESPONSE_CODE(406), + COAP_RESPONSE_CODE_INCOMPLETE = COAP_RESPONSE_CODE(408), + COAP_RESPONSE_CODE_CONFLICT = COAP_RESPONSE_CODE(409), + COAP_RESPONSE_CODE_PRECONDITION_FAILED = COAP_RESPONSE_CODE(412), + COAP_RESPONSE_CODE_REQUEST_TOO_LARGE = COAP_RESPONSE_CODE(413), + COAP_RESPONSE_CODE_UNSUPPORTED_CONTENT_FORMAT = COAP_RESPONSE_CODE(415), + COAP_RESPONSE_CODE_UNPROCESSABLE = COAP_RESPONSE_CODE(422), + COAP_RESPONSE_CODE_TOO_MANY_REQUESTS = COAP_RESPONSE_CODE(429), + COAP_RESPONSE_CODE_INTERNAL_ERROR = COAP_RESPONSE_CODE(500), + COAP_RESPONSE_CODE_NOT_IMPLEMENTED = COAP_RESPONSE_CODE(501), + COAP_RESPONSE_CODE_BAD_GATEWAY = COAP_RESPONSE_CODE(502), + COAP_RESPONSE_CODE_SERVICE_UNAVAILABLE = COAP_RESPONSE_CODE(503), + COAP_RESPONSE_CODE_GATEWAY_TIMEOUT = COAP_RESPONSE_CODE(504), + COAP_RESPONSE_CODE_PROXYING_NOT_SUPPORTED = COAP_RESPONSE_CODE(505), + COAP_RESPONSE_CODE_HOP_LIMIT_REACHED = COAP_RESPONSE_CODE(508), + + COAP_SIGNALING_CODE_CSM = COAP_SIGNALING_CSM, + COAP_SIGNALING_CODE_PING = COAP_SIGNALING_PING, + COAP_SIGNALING_CODE_PONG = COAP_SIGNALING_PONG, + COAP_SIGNALING_CODE_RELEASE = COAP_SIGNALING_RELEASE, + COAP_SIGNALING_CODE_ABORT = COAP_SIGNALING_ABORT +} coap_pdu_code_t; + +/** + * Creates a new CoAP PDU with at least enough storage space for the given + * @p size maximum message size. The function returns a pointer to the + * node coap_pdu_t object on success, or @c NULL on error. The storage allocated + * for the result must be released with coap_delete_pdu() if coap_send() + * is not called. + * + * @param type The type of the PDU (one of COAP_MESSAGE_CON, COAP_MESSAGE_NON, + * COAP_MESSAGE_ACK, COAP_MESSAGE_RST). + * @param code The message code of the PDU. + * @param mid The message id to set or 0 if unknown / not applicable. + * @param size The maximum allowed number of byte for the message. + * @return A pointer to the new PDU object or @c NULL on error. + */ +coap_pdu_t *coap_pdu_init(coap_pdu_type_t type, coap_pdu_code_t code, + coap_mid_t mid, size_t size); + +/** + * Creates a new CoAP PDU. + * + * @param type The type of the PDU (one of COAP_MESSAGE_CON, COAP_MESSAGE_NON, + * COAP_MESSAGE_ACK, COAP_MESSAGE_RST). + * @param code The message code of the PDU. + * @param session The session that will be using this PDU + * + * @return The skeletal PDU or @c NULL if failure. + */ +coap_pdu_t *coap_new_pdu(coap_pdu_type_t type, coap_pdu_code_t code, + coap_session_t *session); + +/** + * Dispose of an CoAP PDU and frees associated storage. + * Not that in general you should not call this function directly. + * When a PDU is sent with coap_send(), coap_delete_pdu() will be called + * automatically for you. + * + * @param pdu The PDU for free off. + */ +void coap_delete_pdu(coap_pdu_t *pdu); + +/** + * Duplicate an existing PDU. Specific options can be ignored and not copied + * across. The PDU data payload is not copied across. + * + * @param old_pdu The PDU to duplicate + * @param session The session that will be using this PDU. + * @param token_length The length of the token to use in this duplicated PDU. + * @param token The token to use in this duplicated PDU. + * @param drop_options A list of options not to copy into the duplicated PDU. + * If @c NULL, then all options are copied across. + * + * @return The duplicated PDU or @c NULL if failure. + */ +coap_pdu_t * +coap_pdu_duplicate(const coap_pdu_t *old_pdu, + coap_session_t *session, + size_t token_length, + const uint8_t *token, + coap_opt_filter_t *drop_options); + +/** + * Adds token of length @p len to @p pdu. + * Adding the token destroys any following contents of the pdu. Hence options + * and data must be added after coap_add_token() has been called. In @p pdu, + * length is set to @p len + @c 4, and max_delta is set to @c 0. This function + * returns @c 0 on error or a value greater than zero on success. + * + * @param pdu The PDU where the token is to be added. + * @param len The length of the new token. + * @param data The token to add. + * + * @return A value greater than zero on success, or @c 0 on error. + */ +int coap_add_token(coap_pdu_t *pdu, + size_t len, + const uint8_t *data); + +/** + * Adds option of given number to pdu that is passed as first + * parameter. + * coap_add_option() destroys the PDU's data, so coap_add_data() must be called + * after all options have been added. As coap_add_token() destroys the options + * following the token, the token must be added before coap_add_option() is + * called. This function returns the number of bytes written or @c 0 on error. + * + * Note: Where possible, the option data needs to be stripped of leading zeros + * (big endian) to reduce the amount of data needed in the PDU, as well as in + * some cases the maximum data size of an opton can be exceeded if not stripped + * and hence be illegal. This is done by using coap_encode_var_safe() or + * coap_encode_var_safe8(). + * + * @param pdu The PDU where the option is to be added. + * @param number The number of the new option. + * @param len The length of the new option. + * @param data The data of the new option. + * + * @return The overall length of the option or @c 0 on failure. + */ +size_t coap_add_option(coap_pdu_t *pdu, + coap_option_num_t number, + size_t len, + const uint8_t *data); + +/** + * Adds given data to the pdu that is passed as first parameter. Note that the + * PDU's data is destroyed by coap_add_option(). coap_add_data() must be called + * only once per PDU, otherwise the result is undefined. + * + * @param pdu The PDU where the data is to be added. + * @param len The length of the data. + * @param data The data to add. + * + * @return @c 1 if success, else @c 0 if failure. + */ +int coap_add_data(coap_pdu_t *pdu, + size_t len, + const uint8_t *data); + +/** + * Adds given data to the pdu that is passed as first parameter but does not + * copy it. Note that the PDU's data is destroyed by coap_add_option(). + * coap_add_data() must be have been called once for this PDU, otherwise the + * result is undefined. + * The actual data must be copied at the returned location. + * + * @param pdu The PDU where the data is to be added. + * @param len The length of the data. + * + * @return Where to copy the data of len to, or @c NULL is error. + */ +uint8_t *coap_add_data_after(coap_pdu_t *pdu, size_t len); + +/** + * Retrieves the length and data pointer of specified PDU. Returns 0 on error or + * 1 if *len and *data have correct values. Note that these values are destroyed + * with the pdu. + * + * @param pdu The specified PDU. + * @param len Returns the length of the current data + * @param data Returns the ptr to the current data + * + * @return @c 1 if len and data are correctly filled in, else + * @c 0 if there is no data. + */ +int coap_get_data(const coap_pdu_t *pdu, + size_t *len, + const uint8_t **data); + +/** + * Retrieves the data from a PDU, with support for large bodies of data that + * spans multiple PDUs. + * + * Note: The data pointed to on return is destroyed when the PDU is destroyed. + * + * @param pdu The specified PDU. + * @param len Returns the length of the current data + * @param data Returns the ptr to the current data + * @param offset Returns the offset of the current data from the start of the + * body comprising of many blocks (RFC7959) + * @param total Returns the total size of the body. + * If offset + length < total, then there is more data to follow. + * + * @return @c 1 if len, data, offset and total are correctly filled in, else + * @c 0 if there is no data. + */ +int coap_get_data_large(const coap_pdu_t *pdu, + size_t *len, + const uint8_t **data, + size_t *offset, + size_t *total); + +/** + * Gets the PDU code associated with @p pdu. + * + * @param pdu The PDU object. + * + * @return The PDU code. + */ +coap_pdu_code_t coap_pdu_get_code(const coap_pdu_t *pdu); + +/** + * Sets the PDU code in the @p pdu. + * + * @param pdu The PDU object. + * @param code The code to set in the PDU. + */ +void coap_pdu_set_code(coap_pdu_t *pdu, coap_pdu_code_t code); + +/** + * Gets the PDU type associated with @p pdu. + * + * @param pdu The PDU object. + * + * @return The PDU type. + */ +coap_pdu_type_t coap_pdu_get_type(const coap_pdu_t *pdu); + +/** + * Sets the PDU type in the @p pdu. + * + * @param pdu The PDU object. + * @param type The type to set for the PDU. + */ +void coap_pdu_set_type(coap_pdu_t *pdu, coap_pdu_type_t type); + +/** + * Gets the token associated with @p pdu. + * + * @param pdu The PDU object. + * + * @return The token information. + */ +coap_bin_const_t coap_pdu_get_token(const coap_pdu_t *pdu); + +/** + * Gets the message id associated with @p pdu. + * + * @param pdu The PDU object. + * + * @return The message id. + */ +coap_mid_t coap_pdu_get_mid(const coap_pdu_t *pdu); + +/** + * Sets the message id in the @p pdu. + * + * @param pdu The PDU object. + * @param mid The message id value to set in the PDU. + * + */ +void coap_pdu_set_mid(coap_pdu_t *pdu, coap_mid_t mid); + +/** @} */ + +#endif /* COAP_PDU_H_ */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/resource.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/resource.h similarity index 55% rename from tools/sdk/esp32c3/include/coap/libcoap/include/coap2/resource.h rename to tools/sdk/esp32s2/include/coap/libcoap/include/coap3/resource.h index 58018720e4e..2cd9aea48fa 100644 --- a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/resource.h +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/resource.h @@ -1,7 +1,9 @@ /* * resource.h -- generic resource handling * - * Copyright (C) 2010,2011,2014,2015 Olaf Bergmann + * Copyright (C) 2010,2011,2014-2021 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause * * This file is part of the CoAP library libcoap. Please see README for terms * of use. @@ -15,100 +17,62 @@ #ifndef COAP_RESOURCE_H_ #define COAP_RESOURCE_H_ -# include - #ifndef COAP_RESOURCE_CHECK_TIME /** The interval in seconds to check if resources have changed. */ #define COAP_RESOURCE_CHECK_TIME 2 #endif /* COAP_RESOURCE_CHECK_TIME */ -#include "uthash.h" #include "async.h" +#include "block.h" #include "str.h" #include "pdu.h" #include "net.h" #include "subscribe.h" /** - * Definition of message handler function (@sa coap_resource_t). + * @defgroup coap_resource Resource Configuraton + * API functions for setting up resources + * @{ + */ + +/** + * Definition of message handler function */ typedef void (*coap_method_handler_t) - (coap_context_t *, - struct coap_resource_t *, + (coap_resource_t *, coap_session_t *, - coap_pdu_t *, - coap_binary_t * /* token */, - coap_string_t * /* query string */, + const coap_pdu_t * /* request */, + const coap_string_t * /* query string */, coap_pdu_t * /* response */); #define COAP_ATTR_FLAGS_RELEASE_NAME 0x1 #define COAP_ATTR_FLAGS_RELEASE_VALUE 0x2 -typedef struct coap_attr_t { - struct coap_attr_t *next; - coap_str_const_t *name; - coap_str_const_t *value; - int flags; -} coap_attr_t; - /** The URI passed to coap_resource_init() is free'd by coap_delete_resource(). */ #define COAP_RESOURCE_FLAGS_RELEASE_URI 0x1 /** * Notifications will be sent non-confirmable by default. RFC 7641 Section 4.5 * https://tools.ietf.org/html/rfc7641#section-4.5 + * Libcoap will always send every fifth packet as confirmable. */ #define COAP_RESOURCE_FLAGS_NOTIFY_NON 0x0 /** - * Notifications will be sent confirmable by default. RFC 7641 Section 4.5 + * Notifications will be sent confirmable. RFC 7641 Section 4.5 * https://tools.ietf.org/html/rfc7641#section-4.5 */ #define COAP_RESOURCE_FLAGS_NOTIFY_CON 0x2 -typedef struct coap_resource_t { - unsigned int dirty:1; /**< set to 1 if resource has changed */ - unsigned int partiallydirty:1; /**< set to 1 if some subscribers have not yet - * been notified of the last change */ - unsigned int observable:1; /**< can be observed */ - unsigned int cacheable:1; /**< can be cached */ - unsigned int is_unknown:1; /**< resource created for unknown handler */ - - /** - * Used to store handlers for the seven coap methods @c GET, @c POST, @c PUT, - * @c DELETE, @c FETCH, @c PATCH and @c IPATCH. - * coap_dispatch() will pass incoming requests to the handler - * that corresponds to its request method or generate a 4.05 response if no - * handler is available. - */ - coap_method_handler_t handler[7]; - - UT_hash_handle hh; - - coap_attr_t *link_attr; /**< attributes to be included with the link format */ - coap_subscription_t *subscribers; /**< list of observers for this resource */ - - /** - * Request URI Path for this resource. This field will point into static - * or allocated memory which must remain there for the duration of the - * resource. - */ - coap_str_const_t *uri_path; /**< the key used for hash lookup for this resource */ - int flags; - - /** - * The next value for the Observe option. This field must be increased each - * time the resource changes. Only the lower 24 bits are sent. - */ - unsigned int observe; - - /** - * This pointer is under user control. It can be used to store context for - * the coap handler. - */ - void *user_data; - -} coap_resource_t; +/** + * Notifications will always be sent non-confirmable. This is in + * violation of RFC 7641 Section 4.5 + * https://tools.ietf.org/html/rfc7641#section-4.5 + * but required by the DOTS signal channel protocol which needs to operate in + * lossy DDoS attack environments. + * https://tools.ietf.org/html/rfc8782#section-4.4.2.1 + */ +#define COAP_RESOURCE_FLAGS_NOTIFY_NON_ALWAYS 0x4 /** * Creates a new resource object and initializes the link field to the string @@ -173,6 +137,45 @@ coap_resource_t *coap_resource_init(coap_str_const_t *uri_path, */ coap_resource_t *coap_resource_unknown_init(coap_method_handler_t put_handler); +/** + * Creates a new resource object for handling proxy URIs. + * This function returns the new coap_resource_t object. + * + * Note: There can only be one proxy resource handler per context - attaching + * a new one overrides the previous definition. + * + * @param handler The PUT/POST/GET etc. handler that handles all request types. + * @param host_name_count The number of provided host_name_list entries. A + * minimum of 1 must be provided. + * @param host_name_list Array of depth host_name_count names that this proxy + * is known by. + * + * @return A pointer to the new object or @c NULL on error. + */ +coap_resource_t *coap_resource_proxy_uri_init(coap_method_handler_t handler, + size_t host_name_count, const char *host_name_list[]); + +/** + * Returns the resource identified by the unique string @p uri_path. If no + * resource was found, this function returns @c NULL. + * + * @param context The context to look for this resource. + * @param uri_path The unique string uri of the resource. + * + * @return A pointer to the resource or @c NULL if not found. + */ +coap_resource_t *coap_get_resource_from_uri_path(coap_context_t *context, + coap_str_const_t *uri_path); + +/** + * Get the uri_path from a @p resource. + * + * @param resource The CoAP resource to check. + * + * @return The uri_path if it exists or @c NULL otherwise. + */ +coap_str_const_t* coap_resource_get_uri_path(coap_resource_t *resource); + /** * Sets the notification message type of resource @p resource to given * @p mode @@ -181,38 +184,43 @@ coap_resource_t *coap_resource_unknown_init(coap_method_handler_t put_handler); * @param mode Must be one of @c COAP_RESOURCE_FLAGS_NOTIFY_NON * or @c COAP_RESOURCE_FLAGS_NOTIFY_CON. */ -COAP_STATIC_INLINE void -coap_resource_set_mode(coap_resource_t *resource, int mode) { - resource->flags = (resource->flags & - ~(COAP_RESOURCE_FLAGS_NOTIFY_CON|COAP_RESOURCE_FLAGS_NOTIFY_NON)) | - (mode & (COAP_RESOURCE_FLAGS_NOTIFY_CON|COAP_RESOURCE_FLAGS_NOTIFY_NON)); -} +void coap_resource_set_mode(coap_resource_t *resource, int mode); /** * Sets the user_data. The user_data is exclusively used by the library-user - * and can be used as context in the handler functions. + * and can be used as user defined context in the handler functions. * - * @param r Resource to attach the data to - * @param data Data to attach to the user_data field. This pointer is only used for - * storage, the data remains under user control + * @param resource Resource to attach the data to + * @param data Data to attach to the user_data field. This pointer is + * only used for storage, the data remains under user control */ -COAP_STATIC_INLINE void -coap_resource_set_userdata(coap_resource_t *r, void *data) { - r->user_data = data; -} +void coap_resource_set_userdata(coap_resource_t *resource, void *data); /** * Gets the user_data. The user_data is exclusively used by the library-user * and can be used as context in the handler functions. * - * @param r Resource to retrieve the user_darta from + * @param resource Resource to retrieve the user_data from * * @return The user_data pointer */ -COAP_STATIC_INLINE void * -coap_resource_get_userdata(coap_resource_t *r) { - return r->user_data; -} +void *coap_resource_get_userdata(coap_resource_t *resource); + +/** + * Definition of release resource user_data callback function + */ +typedef void (*coap_resource_release_userdata_handler_t)(void *user_data); + +/** + * Defines the context wide callback to use to when the resource is deleted + * to release the data held in the resource's user_data. + * + * @param context The context to associate the release callback with + * @param callback The callback to invoke when the resource is deleted or NULL + * + */ +void coap_resource_release_userdata_handler(coap_context_t *context, + coap_resource_release_userdata_handler_t callback); /** * Registers the given @p resource for @p context. The resource must have been @@ -237,11 +245,16 @@ void coap_add_resource(coap_context_t *context, coap_resource_t *resource); int coap_delete_resource(coap_context_t *context, coap_resource_t *resource); /** - * Deletes all resources from given @p context and frees their storage. + * Registers the specified @p handler as message handler for the request type @p + * method * - * @param context The CoAP context with the resources to be deleted. + * @param resource The resource for which the handler shall be registered. + * @param method The CoAP request method to handle. + * @param handler The handler to register with @p resource. */ -void coap_delete_all_resources(coap_context_t *context); +void coap_register_handler(coap_resource_t *resource, + coap_request_t method, + coap_method_handler_t handler); /** * Registers a new attribute with the given @p resource. As the @@ -291,13 +304,13 @@ coap_attr_t *coap_find_attr(coap_resource_t *resource, coap_str_const_t *name); /** - * Deletes an attribute. - * Note: This is for internal use only, as it is not deleted from its chain. + * Returns @p attribute's value. * - * @param attr Pointer to a previously created attribute. + * @param attribute Pointer to attribute. * + * @return Attribute's value or @c NULL. */ -void coap_delete_attr(coap_attr_t *attr); +coap_str_const_t *coap_attr_get_value(coap_attr_t *attribute); /** * Status word to encode the result of conditional print or copy operations such @@ -341,17 +354,7 @@ coap_print_status_t coap_print_link(const coap_resource_t *resource, size_t *len, size_t *offset); -/** - * Registers the specified @p handler as message handler for the request type @p - * method - * - * @param resource The resource for which the handler shall be registered. - * @param method The CoAP request method to handle. - * @param handler The handler to register with @p resource. - */ -void coap_register_handler(coap_resource_t *resource, - unsigned char method, - coap_method_handler_t handler); +/** @} */ /** * Returns the resource identified by the unique string @p uri_path. If no @@ -365,155 +368,6 @@ void coap_register_handler(coap_resource_t *resource, coap_resource_t *coap_get_resource_from_uri_path(coap_context_t *context, coap_str_const_t *uri_path); -/** - * @addtogroup observe - */ - -/** - * Adds the specified peer as observer for @p resource. The subscription is - * identified by the given @p token. This function returns the registered - * subscription information if the @p observer has been added, or @c NULL on - * error. - * - * @param resource The observed resource. - * @param session The observer's session - * @param token The token that identifies this subscription. - * @param query The query string, if any. subscription will - take ownership of the string. - * @param has_block2 If Option Block2 defined. - * @param block2 Contents of Block2 if Block 2 defined. - * @return A pointer to the added/updated subscription - * information or @c NULL on error. - */ -coap_subscription_t *coap_add_observer(coap_resource_t *resource, - coap_session_t *session, - const coap_binary_t *token, - coap_string_t *query, - int has_block2, - coap_block_t block2); - -/** - * Returns a subscription object for given @p peer. - * - * @param resource The observed resource. - * @param session The observer's session - * @param token The token that identifies this subscription or @c NULL for - * any token. - * @return A valid subscription if exists or @c NULL otherwise. - */ -coap_subscription_t *coap_find_observer(coap_resource_t *resource, - coap_session_t *session, - const coap_binary_t *token); - -/** - * Marks an observer as alive. - * - * @param context The CoAP context to use. - * @param session The observer's session - * @param token The corresponding token that has been used for the - * subscription. - */ -void coap_touch_observer(coap_context_t *context, - coap_session_t *session, - const coap_binary_t *token); - -/** - * Removes any subscription for @p observer from @p resource and releases the - * allocated storage. The result is @c 1 if an observation relationship with @p - * observer and @p token existed, @c 0 otherwise. - * - * @param resource The observed resource. - * @param session The observer's session. - * @param token The token that identifies this subscription or @c NULL for - * any token. - * @return @c 1 if the observer has been deleted, @c 0 otherwise. - */ -int coap_delete_observer(coap_resource_t *resource, - coap_session_t *session, - const coap_binary_t *token); - -/** - * Removes any subscription for @p session and releases the allocated storage. - * - * @param context The CoAP context to use. - * @param session The observer's session. - */ -void coap_delete_observers(coap_context_t *context, coap_session_t *session); - -/** - * Checks for all known resources, if they are dirty and notifies subscribed - * observers. - */ -void coap_check_notify(coap_context_t *context); - -#define RESOURCES_ADD(r, obj) \ - HASH_ADD(hh, (r), uri_path->s[0], (obj)->uri_path->length, (obj)) - -#define RESOURCES_DELETE(r, obj) \ - HASH_DELETE(hh, (r), (obj)) - -#define RESOURCES_ITER(r,tmp) \ - coap_resource_t *tmp, *rtmp; \ - HASH_ITER(hh, (r), tmp, rtmp) - -#define RESOURCES_FIND(r, k, res) { \ - HASH_FIND(hh, (r), (k)->s, (k)->length, (res)); \ - } - -/** @} */ - -coap_print_status_t coap_print_wellknown(coap_context_t *, - unsigned char *, - size_t *, size_t, - coap_opt_t *); - -void -coap_handle_failed_notify(coap_context_t *, - coap_session_t *, - const coap_binary_t *); - -/** - * Set whether a @p resource is observable. If the resource is observable - * and the client has set the COAP_OPTION_OBSERVE in a request packet, then - * whenever the state of the resource changes (a call to - * coap_resource_trigger_observe()), an Observer response will get sent. - * - * @param resource The CoAP resource to use. - * @param mode @c 1 if Observable is to be set, @c 0 otherwise. - * - */ -COAP_STATIC_INLINE void -coap_resource_set_get_observable(coap_resource_t *resource, int mode) { - resource->observable = mode ? 1 : 0; -} - -/** - * Initiate the sending of an Observe packet for all observers of @p resource, - * optionally matching @p query if not NULL - * - * @param resource The CoAP resource to use. - * @param query The Query to match against or NULL - * - * @return @c 1 if the Observe has been triggered, @c 0 otherwise. - */ -int -coap_resource_notify_observers(coap_resource_t *resource, - const coap_string_t *query); - -/** - * Get the UriPath from a @p resource. - * - * @param resource The CoAP resource to check. - * - * @return The UriPath if it exists or @c NULL otherwise. - */ -COAP_STATIC_INLINE coap_str_const_t* -coap_resource_get_uri_path(coap_resource_t *resource) { - if (resource) - return resource->uri_path; - return NULL; -} - /** * @deprecated use coap_resource_notify_observers() instead. */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/str.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/str.h new file mode 100644 index 00000000000..dbf53d0c475 --- /dev/null +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/str.h @@ -0,0 +1,204 @@ +/* + * str.h -- strings to be used in the CoAP library + * + * Copyright (C) 2010-2011 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +#ifndef COAP_STR_H_ +#define COAP_STR_H_ + +#include + + +/** + * @defgroup string String handling support + * API functions for handling strings and binary data + * @{ + */ + +/* + * Note: string and binary use equivalent objects. + * string is likely to contain readable textual information, binary will not. + */ + +/** + * CoAP string data definition + */ +typedef struct coap_string_t { + size_t length; /**< length of string */ + uint8_t *s; /**< string data */ +} coap_string_t; + +/** + * CoAP string data definition with const data + */ +typedef struct coap_str_const_t { + size_t length; /**< length of string */ + const uint8_t *s; /**< read-only string data */ +} coap_str_const_t; + +#define COAP_SET_STR(st,l,v) { (st)->length = (l), (st)->s = (v); } + +/** + * CoAP binary data definition + */ +typedef struct coap_binary_t { + size_t length; /**< length of binary data */ + uint8_t *s; /**< binary data */ +} coap_binary_t; + +/** + * CoAP binary data definition with const data + */ +typedef struct coap_bin_const_t { + size_t length; /**< length of binary data */ + const uint8_t *s; /**< read-only binary data */ +} coap_bin_const_t; + +/** + * Returns a new string object with at least size+1 bytes storage allocated. + * It is the responsibility of the caller to fill in all the appropriate + * information. + * The string must be released using coap_delete_string(). + * + * @param size The size to allocate for the string data. + * + * @return A pointer to the new object or @c NULL on error. + */ +coap_string_t *coap_new_string(size_t size); + +/** + * Deletes the given string and releases any memory allocated. + * + * @param string The string to free off. + */ +void coap_delete_string(coap_string_t *string); + +/** + * Returns a new const string object with at least size+1 bytes storage + * allocated, and the provided data copied into the string object. + * The string must be released using coap_delete_str_const(). + * + * @param data The data to put in the new string object. + * @param size The size to allocate for the binary string data. + * + * @return A pointer to the new object or @c NULL on error. + */ +coap_str_const_t *coap_new_str_const(const uint8_t *data, size_t size); + +/** + * Deletes the given const string and releases any memory allocated. + * + * @param string The string to free off. + */ +void coap_delete_str_const(coap_str_const_t *string); + +/** + * Returns a new binary object with at least size bytes storage allocated. + * It is the responsibility of the caller to fill in all the appropriate + * information. + * The coap_binary_t object must be released using coap_delete_binary(). + * + * @param size The size to allocate for the binary data. + * + * @return A pointer to the new object or @c NULL on error. + */ +coap_binary_t *coap_new_binary(size_t size); + +/** + * Deletes the given coap_binary_t object and releases any memory allocated. + * + * @param binary The coap_binary_t object to free off. + */ +void coap_delete_binary(coap_binary_t *binary); + +/** + * Resizes the given coap_binary_t object. + * It is the responsibility of the caller to fill in all the appropriate + * additional information. + * + * Note: If there is an error, @p binary will separately need to be released by + * coap_delete_binary(). + * + * @param binary The coap_binary_t object to resize. + * @param new_size The new size to allocate for the binary data. + * + * @return A pointer to the new object or @c NULL on error. + */ +coap_binary_t *coap_resize_binary(coap_binary_t *binary, size_t new_size); + +/** + * Take the specified byte array (text) and create a coap_bin_const_t * + * Returns a new const binary object with at least size bytes storage + * allocated, and the provided data copied into the binary object. + * The binary data must be released using coap_delete_bin_const(). + * + * @param data The data to put in the new string object. + * @param size The size to allocate for the binary data. + * + * @return A pointer to the new object or @c NULL on error. + */ +coap_bin_const_t *coap_new_bin_const(const uint8_t *data, size_t size); + +/** + * Deletes the given const binary data and releases any memory allocated. + * + * @param binary The binary data to free off. + */ +void coap_delete_bin_const(coap_bin_const_t *binary); + +#ifndef COAP_MAX_STR_CONST_FUNC +#define COAP_MAX_STR_CONST_FUNC 2 +#endif /* COAP_MAX_STR_CONST_FUNC */ + +/** + * Take the specified byte array (text) and create a coap_str_const_t * + * + * Note: the array is 2 deep as there are up to two callings of + * coap_make_str_const in a function call. e.g. coap_add_attr(). + * Caution: If there are local variable assignments, these will cycle around + * the var[COAP_MAX_STR_CONST_FUNC] set. No current examples do this. + * + * @param string The const string to convert to a coap_str_const_t * + * + * @return A pointer to one of two static variables containing the + * coap_str_const_t * result + */ +coap_str_const_t *coap_make_str_const(const char *string); + +/** + * Compares the two strings for equality + * + * @param string1 The first string. + * @param string2 The second string. + * + * @return @c 1 if the strings are equal + * @c 0 otherwise. + */ +#define coap_string_equal(string1,string2) \ + ((string1)->length == (string2)->length && ((string1)->length == 0 || \ + ((string1)->s && (string2)->s && \ + memcmp((string1)->s, (string2)->s, (string1)->length) == 0))) + +/** + * Compares the two binary data for equality + * + * @param binary1 The first binary data. + * @param binary2 The second binary data. + * + * @return @c 1 if the binary data is equal + * @c 0 otherwise. + */ +#define coap_binary_equal(binary1,binary2) \ + ((binary1)->length == (binary2)->length && ((binary1)->length == 0 || \ + ((binary1)->s && (binary2)->s && \ + memcmp((binary1)->s, (binary2)->s, (binary1)->length) == 0))) + +/** @} */ + +#endif /* COAP_STR_H_ */ diff --git a/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/subscribe.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/subscribe.h new file mode 100644 index 00000000000..c3aabc2db04 --- /dev/null +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/subscribe.h @@ -0,0 +1,68 @@ +/* + * subscribe.h -- subscription handling for CoAP + * see RFC7641 + * + * Copyright (C) 2010-2012,2014-2021 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This file is part of the CoAP library libcoap. Please see README for terms + * of use. + */ + +/** + * @file subscribe.h + * @brief Defines the application visible subscribe information + */ + +#ifndef COAP_SUBSCRIBE_H_ +#define COAP_SUBSCRIBE_H_ + +/** + * @defgroup observe Resource Observation + * API functions for interfacing with the observe handling (RFC7641) + * @{ + */ + +/** + * The value COAP_OBSERVE_ESTABLISH in a GET/FETCH request option + * COAP_OPTION_OBSERVE indicates a new observe relationship for (sender + * address, token) is requested. + */ +#define COAP_OBSERVE_ESTABLISH 0 + +/** + * The value COAP_OBSERVE_CANCEL in a GET/FETCH request option + * COAP_OPTION_OBSERVE indicates that the observe relationship for (sender + * address, token) must be cancelled. + */ +#define COAP_OBSERVE_CANCEL 1 + +/** + * Set whether a @p resource is observable. If the resource is observable + * and the client has set the COAP_OPTION_OBSERVE in a request packet, then + * whenever the state of the resource changes (a call to + * coap_resource_trigger_observe()), an Observer response will get sent. + * + * @param resource The CoAP resource to use. + * @param mode @c 1 if Observable is to be set, @c 0 otherwise. + * + */ +void coap_resource_set_get_observable(coap_resource_t *resource, int mode); + +/** + * Initiate the sending of an Observe packet for all observers of @p resource, + * optionally matching @p query if not NULL + * + * @param resource The CoAP resource to use. + * @param query The Query to match against or NULL + * + * @return @c 1 if the Observe has been triggered, @c 0 otherwise. + */ +int +coap_resource_notify_observers(coap_resource_t *resource, + const coap_string_t *query); + +/** @} */ + +#endif /* COAP_SUBSCRIBE_H_ */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/uri.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/uri.h similarity index 67% rename from tools/sdk/esp32c3/include/coap/libcoap/include/coap2/uri.h rename to tools/sdk/esp32s2/include/coap/libcoap/include/coap3/uri.h index 4d1670115eb..8084483b500 100644 --- a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/uri.h +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/uri.h @@ -1,7 +1,9 @@ /* * uri.h -- helper functions for URI treatment * - * Copyright (C) 2010-2011,2016 Olaf Bergmann + * Copyright (C) 2010-2020 Olaf Bergmann + * + * SPDX-License-Identifier: BSD-2-Clause * * This file is part of the CoAP library libcoap. Please see README for terms * of use. @@ -13,25 +15,27 @@ #include #include "str.h" -struct coap_pdu_t; /** * The scheme specifiers. Secure schemes have an odd numeric value, * others are even. */ -enum coap_uri_scheme_t { - COAP_URI_SCHEME_COAP=0, - COAP_URI_SCHEME_COAPS=1, - COAP_URI_SCHEME_COAP_TCP=2, - COAP_URI_SCHEME_COAPS_TCP=3 -}; +typedef enum coap_uri_scheme_t { + COAP_URI_SCHEME_COAP = 0, + COAP_URI_SCHEME_COAPS, /* 1 */ + COAP_URI_SCHEME_COAP_TCP, /* 2 */ + COAP_URI_SCHEME_COAPS_TCP, /* 3 */ + COAP_URI_SCHEME_HTTP, /* 4 Proxy-Uri only */ + COAP_URI_SCHEME_HTTPS /* 5 Proxy-Uri only */ +} coap_uri_scheme_t; /** This mask can be used to check if a parsed URI scheme is secure. */ #define COAP_URI_SCHEME_SECURE_MASK 0x01 /** * Representation of parsed URI. Components may be filled from a string with - * coap_split_uri() and can be used as input for option-creation functions. + * coap_split_uri() or coap_split_proxy_uri() and can be used as input for + * option-creation functions. */ typedef struct { coap_str_const_t host; /**< host part of the URI */ @@ -79,17 +83,36 @@ coap_uri_t *coap_clone_uri(const coap_uri_t *uri); * Parses a given string into URI components. The identified syntactic * components are stored in the result parameter @p uri. Optional URI * components that are not specified will be set to { 0, 0 }, except for the - * port which is set to @c COAP_DEFAULT_PORT. This function returns @p 0 if - * parsing succeeded, a value less than zero otherwise. + * port which is set to the default port for the protocol. This function + * returns @p 0 if parsing succeeded, a value less than zero otherwise. * * @param str_var The string to split up. * @param len The actual length of @p str_var * @param uri The coap_uri_t object to store the result. + * * @return @c 0 on success, or < 0 on error. * */ int coap_split_uri(const uint8_t *str_var, size_t len, coap_uri_t *uri); +/** + * Parses a given string into URI components. The identified syntactic + * components are stored in the result parameter @p uri. Optional URI + * components that are not specified will be set to { 0, 0 }, except for the + * port which is set to default port for the protocol. This function returns + * @p 0 if parsing succeeded, a value less than zero otherwise. + * Note: This function enforces that the given string is in Proxy-Uri format + * as well as supports different schema such as http. + * + * @param str_var The string to split up. + * @param len The actual length of @p str_var + * @param uri The coap_uri_t object to store the result. + * + * @return @c 0 on success, or < 0 on error. + * + */ +int coap_split_proxy_uri(const uint8_t *str_var, size_t len, coap_uri_t *uri); + /** * Splits the given URI path into segments. Each segment is preceded * by an option pseudo-header with delta-value 0 and the actual length @@ -131,16 +154,22 @@ int coap_split_query(const uint8_t *s, /** * Extract query string from request PDU according to escape rules in 6.5.8. * @param request Request PDU. - * @return Reconstructed and escaped query string part. + * @return Reconstructed and escaped query string part or @c NULL if + * no query was contained in @p request. The coap_string_t + * object returned by this function must be released with + * coap_delete_string. */ -coap_string_t *coap_get_query(const struct coap_pdu_t *request); +coap_string_t *coap_get_query(const coap_pdu_t *request); /** * Extract uri_path string from request PDU * @param request Request PDU. - * @return Reconstructed and escaped uri path string part. + * @return Reconstructed and escaped uri path string part or @c NULL + * if no URI-Path was contained in @p request. The + * coap_string_t object returned by this function must be + * released with coap_delete_string. */ -coap_string_t *coap_get_uri_path(const struct coap_pdu_t *request); +coap_string_t *coap_get_uri_path(const coap_pdu_t *request); /** @} */ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/uthash.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/uthash.h similarity index 81% rename from tools/sdk/esp32c3/include/coap/libcoap/include/coap2/uthash.h rename to tools/sdk/esp32s2/include/coap/libcoap/include/coap3/uthash.h index 156eb8210c1..9a396b6179f 100644 --- a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/uthash.h +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/uthash.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2017, Troy D. Hanson http://troydhanson.github.com/uthash/ +Copyright (c) 2003-2021, Troy D. Hanson http://troydhanson.github.io/uthash/ All rights reserved. Redistribution and use in source and binary forms, with or without @@ -24,12 +24,22 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef UTHASH_H #define UTHASH_H -#define UTHASH_VERSION 2.0.2 +#define UTHASH_VERSION 2.3.0 #include /* memcmp, memset, strlen */ #include /* ptrdiff_t */ #include /* exit */ +#if defined(HASH_DEFINE_OWN_STDINT) && HASH_DEFINE_OWN_STDINT +/* This codepath is provided for backward compatibility, but I plan to remove it. */ +#warning "HASH_DEFINE_OWN_STDINT is deprecated; please use HASH_NO_STDINT instead" +typedef unsigned int uint32_t; +typedef unsigned char uint8_t; +#elif defined(HASH_NO_STDINT) && HASH_NO_STDINT +#else +#include /* uint8_t, uint32_t */ +#endif + /* These macros use decltype or the earlier __typeof GNU extension. As decltype is only available in newer compilers (VS2010 or gcc 4.3+ when compiling c++ source) this code uses whatever method is needed @@ -62,26 +72,6 @@ do { } while (0) #endif -/* a number of the hash function use uint32_t which isn't defined on Pre VS2010 */ -#if defined(_WIN32) -#if defined(_MSC_VER) && _MSC_VER >= 1600 -#include -#elif defined(__WATCOMC__) || defined(__MINGW32__) || defined(__CYGWIN__) -#include -#else -typedef unsigned int uint32_t; -typedef unsigned char uint8_t; -#endif -#elif defined(__GNUC__) && !defined(__VXWORKS__) -#include -#else -typedef unsigned int uint32_t; -typedef unsigned char uint8_t; -#endif - -#ifndef uthash_fatal -#define uthash_fatal(msg) exit(-1) /* fatal error (out of memory,etc) */ -#endif #ifndef uthash_malloc #define uthash_malloc(sz) malloc(sz) /* malloc fcn */ #endif @@ -91,13 +81,18 @@ typedef unsigned char uint8_t; #ifndef uthash_bzero #define uthash_bzero(a,n) memset(a,'\0',n) #endif -#ifndef uthash_memcmp -#define uthash_memcmp(a,b,n) memcmp(a,b,n) -#endif #ifndef uthash_strlen #define uthash_strlen(s) strlen(s) #endif +#ifndef HASH_FUNCTION +#define HASH_FUNCTION(keyptr,keylen,hashv) HASH_JEN(keyptr, keylen, hashv) +#endif + +#ifndef HASH_KEYCMP +#define HASH_KEYCMP(a,b,n) memcmp(a,b,n) +#endif + #ifndef uthash_noexpand_fyi #define uthash_noexpand_fyi(tbl) /* can be defined to log noexpand */ #endif @@ -105,6 +100,32 @@ typedef unsigned char uint8_t; #define uthash_expand_fyi(tbl) /* can be defined to log expands */ #endif +#ifndef HASH_NONFATAL_OOM +#define HASH_NONFATAL_OOM 0 +#endif + +#if HASH_NONFATAL_OOM +/* malloc failures can be recovered from */ + +#ifndef uthash_nonfatal_oom +#define uthash_nonfatal_oom(obj) do {} while (0) /* non-fatal OOM error */ +#endif + +#define HASH_RECORD_OOM(oomed) do { (oomed) = 1; } while (0) +#define IF_HASH_NONFATAL_OOM(x) x + +#else +/* malloc failures result in lost memory, hash tables are unusable */ + +#ifndef uthash_fatal +#define uthash_fatal(msg) exit(-1) /* fatal OOM error */ +#endif + +#define HASH_RECORD_OOM(oomed) uthash_fatal("out of memory") +#define IF_HASH_NONFATAL_OOM(x) + +#endif + /* initial number of buckets */ #define HASH_INITIAL_NUM_BUCKETS 32U /* initial number of buckets */ #define HASH_INITIAL_NUM_BUCKETS_LOG2 5U /* lg2 of initial number of buckets */ @@ -113,11 +134,21 @@ typedef unsigned char uint8_t; /* calculate the element whose hash handle address is hhp */ #define ELMT_FROM_HH(tbl,hhp) ((void*)(((char*)(hhp)) - ((tbl)->hho))) /* calculate the hash handle from element address elp */ -#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle *)(((char*)(elp)) + ((tbl)->hho))) +#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle*)(void*)(((char*)(elp)) + ((tbl)->hho))) + +#define HASH_ROLLBACK_BKT(hh, head, itemptrhh) \ +do { \ + struct UT_hash_handle *_hd_hh_item = (itemptrhh); \ + unsigned _hd_bkt; \ + HASH_TO_BKT(_hd_hh_item->hashv, (head)->hh.tbl->num_buckets, _hd_bkt); \ + (head)->hh.tbl->buckets[_hd_bkt].count++; \ + _hd_hh_item->hh_next = NULL; \ + _hd_hh_item->hh_prev = NULL; \ +} while (0) #define HASH_VALUE(keyptr,keylen,hashv) \ do { \ - HASH_FCN(keyptr, keylen, hashv); \ + HASH_FUNCTION(keyptr, keylen, hashv); \ } while (0) #define HASH_FIND_BYHASHVALUE(hh,head,keyptr,keylen,hashval,out) \ @@ -134,23 +165,27 @@ do { #define HASH_FIND(hh,head,keyptr,keylen,out) \ do { \ - unsigned _hf_hashv; \ - HASH_VALUE(keyptr, keylen, _hf_hashv); \ - HASH_FIND_BYHASHVALUE(hh, head, keyptr, keylen, _hf_hashv, out); \ + (out) = NULL; \ + if (head) { \ + unsigned _hf_hashv; \ + HASH_VALUE(keyptr, keylen, _hf_hashv); \ + HASH_FIND_BYHASHVALUE(hh, head, keyptr, keylen, _hf_hashv, out); \ + } \ } while (0) #ifdef HASH_BLOOM #define HASH_BLOOM_BITLEN (1UL << HASH_BLOOM) #define HASH_BLOOM_BYTELEN (HASH_BLOOM_BITLEN/8UL) + (((HASH_BLOOM_BITLEN%8UL)!=0UL) ? 1UL : 0UL) -#define HASH_BLOOM_MAKE(tbl) \ +#define HASH_BLOOM_MAKE(tbl,oomed) \ do { \ (tbl)->bloom_nbits = HASH_BLOOM; \ (tbl)->bloom_bv = (uint8_t*)uthash_malloc(HASH_BLOOM_BYTELEN); \ if (!(tbl)->bloom_bv) { \ - uthash_fatal("out of memory"); \ + HASH_RECORD_OOM(oomed); \ + } else { \ + uthash_bzero((tbl)->bloom_bv, HASH_BLOOM_BYTELEN); \ + (tbl)->bloom_sig = HASH_BLOOM_SIGNATURE; \ } \ - uthash_bzero((tbl)->bloom_bv, HASH_BLOOM_BYTELEN); \ - (tbl)->bloom_sig = HASH_BLOOM_SIGNATURE; \ } while (0) #define HASH_BLOOM_FREE(tbl) \ @@ -162,39 +197,49 @@ do { #define HASH_BLOOM_BITTEST(bv,idx) (bv[(idx)/8U] & (1U << ((idx)%8U))) #define HASH_BLOOM_ADD(tbl,hashv) \ - HASH_BLOOM_BITSET((tbl)->bloom_bv, (hashv & (uint32_t)((1UL << (tbl)->bloom_nbits) - 1U))) + HASH_BLOOM_BITSET((tbl)->bloom_bv, ((hashv) & (uint32_t)((1UL << (tbl)->bloom_nbits) - 1U))) #define HASH_BLOOM_TEST(tbl,hashv) \ - HASH_BLOOM_BITTEST((tbl)->bloom_bv, (hashv & (uint32_t)((1UL << (tbl)->bloom_nbits) - 1U))) + HASH_BLOOM_BITTEST((tbl)->bloom_bv, ((hashv) & (uint32_t)((1UL << (tbl)->bloom_nbits) - 1U))) #else -#define HASH_BLOOM_MAKE(tbl) +#define HASH_BLOOM_MAKE(tbl,oomed) #define HASH_BLOOM_FREE(tbl) #define HASH_BLOOM_ADD(tbl,hashv) #define HASH_BLOOM_TEST(tbl,hashv) (1) #define HASH_BLOOM_BYTELEN 0U #endif -#define HASH_MAKE_TABLE(hh,head) \ +#define HASH_MAKE_TABLE(hh,head,oomed) \ do { \ (head)->hh.tbl = (UT_hash_table*)uthash_malloc(sizeof(UT_hash_table)); \ if (!(head)->hh.tbl) { \ - uthash_fatal("out of memory"); \ - } \ - uthash_bzero((head)->hh.tbl, sizeof(UT_hash_table)); \ - (head)->hh.tbl->tail = &((head)->hh); \ - (head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \ - (head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \ - (head)->hh.tbl->hho = (char*)(&(head)->hh) - (char*)(head); \ - (head)->hh.tbl->buckets = (UT_hash_bucket*)uthash_malloc( \ - HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \ - if (!(head)->hh.tbl->buckets) { \ - uthash_fatal("out of memory"); \ + HASH_RECORD_OOM(oomed); \ + } else { \ + uthash_bzero((head)->hh.tbl, sizeof(UT_hash_table)); \ + (head)->hh.tbl->tail = &((head)->hh); \ + (head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \ + (head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \ + (head)->hh.tbl->hho = (char*)(&(head)->hh) - (char*)(head); \ + (head)->hh.tbl->buckets = (UT_hash_bucket*)uthash_malloc( \ + HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \ + (head)->hh.tbl->signature = HASH_SIGNATURE; \ + if (!(head)->hh.tbl->buckets) { \ + HASH_RECORD_OOM(oomed); \ + uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \ + } else { \ + uthash_bzero((head)->hh.tbl->buckets, \ + HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \ + HASH_BLOOM_MAKE((head)->hh.tbl, oomed); \ + IF_HASH_NONFATAL_OOM( \ + if (oomed) { \ + uthash_free((head)->hh.tbl->buckets, \ + HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket)); \ + uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \ + } \ + ) \ + } \ } \ - uthash_bzero((head)->hh.tbl->buckets, \ - HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \ - HASH_BLOOM_MAKE((head)->hh.tbl); \ - (head)->hh.tbl->signature = HASH_SIGNATURE; \ } while (0) #define HASH_REPLACE_BYHASHVALUE_INORDER(hh,head,fieldname,keylen_in,hashval,add,replaced,cmpfcn) \ @@ -264,17 +309,58 @@ do { } while (0) #endif -#define HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh,head,keyptr,keylen_in,hashval,add,cmpfcn) \ +#if HASH_NONFATAL_OOM + +#define HASH_ADD_TO_TABLE(hh,head,keyptr,keylen_in,hashval,add,oomed) \ +do { \ + if (!(oomed)) { \ + unsigned _ha_bkt; \ + (head)->hh.tbl->num_items++; \ + HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt); \ + HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], hh, &(add)->hh, oomed); \ + if (oomed) { \ + HASH_ROLLBACK_BKT(hh, head, &(add)->hh); \ + HASH_DELETE_HH(hh, head, &(add)->hh); \ + (add)->hh.tbl = NULL; \ + uthash_nonfatal_oom(add); \ + } else { \ + HASH_BLOOM_ADD((head)->hh.tbl, hashval); \ + HASH_EMIT_KEY(hh, head, keyptr, keylen_in); \ + } \ + } else { \ + (add)->hh.tbl = NULL; \ + uthash_nonfatal_oom(add); \ + } \ +} while (0) + +#else + +#define HASH_ADD_TO_TABLE(hh,head,keyptr,keylen_in,hashval,add,oomed) \ do { \ unsigned _ha_bkt; \ + (head)->hh.tbl->num_items++; \ + HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt); \ + HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], hh, &(add)->hh, oomed); \ + HASH_BLOOM_ADD((head)->hh.tbl, hashval); \ + HASH_EMIT_KEY(hh, head, keyptr, keylen_in); \ +} while (0) + +#endif + + +#define HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh,head,keyptr,keylen_in,hashval,add,cmpfcn) \ +do { \ + IF_HASH_NONFATAL_OOM( int _ha_oomed = 0; ) \ (add)->hh.hashv = (hashval); \ (add)->hh.key = (char*) (keyptr); \ (add)->hh.keylen = (unsigned) (keylen_in); \ if (!(head)) { \ (add)->hh.next = NULL; \ (add)->hh.prev = NULL; \ - (head) = (add); \ - HASH_MAKE_TABLE(hh, head); \ + HASH_MAKE_TABLE(hh, add, _ha_oomed); \ + IF_HASH_NONFATAL_OOM( if (!_ha_oomed) { ) \ + (head) = (add); \ + IF_HASH_NONFATAL_OOM( } ) \ } else { \ void *_hs_iter = (head); \ (add)->hh.tbl = (head)->hh.tbl; \ @@ -291,11 +377,7 @@ do { HASH_APPEND_LIST(hh, head, add); \ } \ } \ - (head)->hh.tbl->num_items++; \ - HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt); \ - HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], &(add)->hh); \ - HASH_BLOOM_ADD((head)->hh.tbl, hashval); \ - HASH_EMIT_KEY(hh, head, keyptr, keylen_in); \ + HASH_ADD_TO_TABLE(hh, head, keyptr, keylen_in, hashval, add, _ha_oomed); \ HASH_FSCK(hh, head, "HASH_ADD_KEYPTR_BYHASHVALUE_INORDER"); \ } while (0) @@ -314,24 +396,22 @@ do { #define HASH_ADD_KEYPTR_BYHASHVALUE(hh,head,keyptr,keylen_in,hashval,add) \ do { \ - unsigned _ha_bkt; \ + IF_HASH_NONFATAL_OOM( int _ha_oomed = 0; ) \ (add)->hh.hashv = (hashval); \ - (add)->hh.key = (const void *) (keyptr); \ + (add)->hh.key = (const void*) (keyptr); \ (add)->hh.keylen = (unsigned) (keylen_in); \ if (!(head)) { \ (add)->hh.next = NULL; \ (add)->hh.prev = NULL; \ - (head) = (add); \ - HASH_MAKE_TABLE(hh, head); \ + HASH_MAKE_TABLE(hh, add, _ha_oomed); \ + IF_HASH_NONFATAL_OOM( if (!_ha_oomed) { ) \ + (head) = (add); \ + IF_HASH_NONFATAL_OOM( } ) \ } else { \ (add)->hh.tbl = (head)->hh.tbl; \ HASH_APPEND_LIST(hh, head, add); \ } \ - (head)->hh.tbl->num_items++; \ - HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt); \ - HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], &(add)->hh); \ - HASH_BLOOM_ADD((head)->hh.tbl, hashval); \ - HASH_EMIT_KEY(hh, head, keyptr, keylen_in); \ + HASH_ADD_TO_TABLE(hh, head, keyptr, keylen_in, hashval, add, _ha_oomed); \ HASH_FSCK(hh, head, "HASH_ADD_KEYPTR_BYHASHVALUE"); \ } while (0) @@ -394,17 +474,25 @@ do { HASH_DEL_IN_BKT((head)->hh.tbl->buckets[_hd_bkt], _hd_hh_del); \ (head)->hh.tbl->num_items--; \ } \ - HASH_FSCK(hh, head, "HASH_DELETE"); \ + HASH_FSCK(hh, head, "HASH_DELETE_HH"); \ } while (0) - /* convenience forms of HASH_FIND/HASH_ADD/HASH_DEL */ #define HASH_FIND_STR(head,findstr,out) \ - HASH_FIND(hh,head,findstr,(unsigned)uthash_strlen(findstr),out) +do { \ + unsigned _uthash_hfstr_keylen = (unsigned)uthash_strlen(findstr); \ + HASH_FIND(hh, head, findstr, _uthash_hfstr_keylen, out); \ +} while (0) #define HASH_ADD_STR(head,strfield,add) \ - HASH_ADD(hh,head,strfield[0],(unsigned)uthash_strlen(add->strfield),add) +do { \ + unsigned _uthash_hastr_keylen = (unsigned)uthash_strlen((add)->strfield); \ + HASH_ADD(hh, head, strfield[0], _uthash_hastr_keylen, add); \ +} while (0) #define HASH_REPLACE_STR(head,strfield,add,replaced) \ - HASH_REPLACE(hh,head,strfield[0],(unsigned)uthash_strlen(add->strfield),add,replaced) +do { \ + unsigned _uthash_hrstr_keylen = (unsigned)uthash_strlen((add)->strfield); \ + HASH_REPLACE(hh, head, strfield[0], _uthash_hrstr_keylen, add, replaced); \ +} while (0) #define HASH_FIND_INT(head,findint,out) \ HASH_FIND(hh,head,findint,sizeof(int),out) #define HASH_ADD_INT(head,intfield,add) \ @@ -424,7 +512,8 @@ do { * This is for uthash developer only; it compiles away if HASH_DEBUG isn't defined. */ #ifdef HASH_DEBUG -#define HASH_OOPS(...) do { fprintf(stderr,__VA_ARGS__); exit(-1); } while (0) +#include /* fprintf, stderr */ +#define HASH_OOPS(...) do { fprintf(stderr, __VA_ARGS__); exit(-1); } while (0) #define HASH_FSCK(hh,head,where) \ do { \ struct UT_hash_handle *_thh; \ @@ -491,13 +580,6 @@ do { #define HASH_EMIT_KEY(hh,head,keyptr,fieldlen) #endif -/* default to Jenkin's hash unless overridden e.g. DHASH_FUNCTION=HASH_SAX */ -#ifdef HASH_FUNCTION -#define HASH_FCN HASH_FUNCTION -#else -#define HASH_FCN HASH_JEN -#endif - /* The Bernstein hash function, used in Perl prior to v5.6. Note (x<<5+x)=x*33. */ #define HASH_BER(key,keylen,hashv) \ do { \ @@ -596,8 +678,8 @@ do { case 4: _hj_i += ( (unsigned)_hj_key[3] << 24 ); /* FALLTHROUGH */ \ case 3: _hj_i += ( (unsigned)_hj_key[2] << 16 ); /* FALLTHROUGH */ \ case 2: _hj_i += ( (unsigned)_hj_key[1] << 8 ); /* FALLTHROUGH */ \ - case 1: _hj_i += _hj_key[0]; \ - default: ; /* does not happen */ \ + case 1: _hj_i += _hj_key[0]; /* FALLTHROUGH */ \ + default: ; \ } \ HASH_JEN_MIX(_hj_i, _hj_j, hashv); \ } while (0) @@ -645,6 +727,8 @@ do { case 1: hashv += *_sfh_key; \ hashv ^= hashv << 10; \ hashv += hashv >> 1; \ + break; \ + default: ; \ } \ \ /* Force "avalanching" of final 127 bits */ \ @@ -656,87 +740,6 @@ do { hashv += hashv >> 6; \ } while (0) -#ifdef HASH_USING_NO_STRICT_ALIASING -/* The MurmurHash exploits some CPU's (x86,x86_64) tolerance for unaligned reads. - * For other types of CPU's (e.g. Sparc) an unaligned read causes a bus error. - * MurmurHash uses the faster approach only on CPU's where we know it's safe. - * - * Note the preprocessor built-in defines can be emitted using: - * - * gcc -m64 -dM -E - < /dev/null (on gcc) - * cc -## a.c (where a.c is a simple test file) (Sun Studio) - */ -#if (defined(__i386__) || defined(__x86_64__) || defined(_M_IX86)) -#define MUR_GETBLOCK(p,i) p[i] -#else /* non intel */ -#define MUR_PLUS0_ALIGNED(p) (((unsigned long)p & 3UL) == 0UL) -#define MUR_PLUS1_ALIGNED(p) (((unsigned long)p & 3UL) == 1UL) -#define MUR_PLUS2_ALIGNED(p) (((unsigned long)p & 3UL) == 2UL) -#define MUR_PLUS3_ALIGNED(p) (((unsigned long)p & 3UL) == 3UL) -#define WP(p) ((uint32_t*)((unsigned long)(p) & ~3UL)) -#if (defined(__BIG_ENDIAN__) || defined(SPARC) || defined(__ppc__) || defined(__ppc64__)) -#define MUR_THREE_ONE(p) ((((*WP(p))&0x00ffffff) << 8) | (((*(WP(p)+1))&0xff000000) >> 24)) -#define MUR_TWO_TWO(p) ((((*WP(p))&0x0000ffff) <<16) | (((*(WP(p)+1))&0xffff0000) >> 16)) -#define MUR_ONE_THREE(p) ((((*WP(p))&0x000000ff) <<24) | (((*(WP(p)+1))&0xffffff00) >> 8)) -#else /* assume little endian non-intel */ -#define MUR_THREE_ONE(p) ((((*WP(p))&0xffffff00) >> 8) | (((*(WP(p)+1))&0x000000ff) << 24)) -#define MUR_TWO_TWO(p) ((((*WP(p))&0xffff0000) >>16) | (((*(WP(p)+1))&0x0000ffff) << 16)) -#define MUR_ONE_THREE(p) ((((*WP(p))&0xff000000) >>24) | (((*(WP(p)+1))&0x00ffffff) << 8)) -#endif -#define MUR_GETBLOCK(p,i) (MUR_PLUS0_ALIGNED(p) ? ((p)[i]) : \ - (MUR_PLUS1_ALIGNED(p) ? MUR_THREE_ONE(p) : \ - (MUR_PLUS2_ALIGNED(p) ? MUR_TWO_TWO(p) : \ - MUR_ONE_THREE(p)))) -#endif -#define MUR_ROTL32(x,r) (((x) << (r)) | ((x) >> (32 - (r)))) -#define MUR_FMIX(_h) \ -do { \ - _h ^= _h >> 16; \ - _h *= 0x85ebca6bu; \ - _h ^= _h >> 13; \ - _h *= 0xc2b2ae35u; \ - _h ^= _h >> 16; \ -} while (0) - -#define HASH_MUR(key,keylen,hashv) \ -do { \ - const uint8_t *_mur_data = (const uint8_t*)(key); \ - const int _mur_nblocks = (int)(keylen) / 4; \ - uint32_t _mur_h1 = 0xf88D5353u; \ - uint32_t _mur_c1 = 0xcc9e2d51u; \ - uint32_t _mur_c2 = 0x1b873593u; \ - uint32_t _mur_k1 = 0; \ - const uint8_t *_mur_tail; \ - const uint32_t *_mur_blocks = (const uint32_t*)(_mur_data+(_mur_nblocks*4)); \ - int _mur_i; \ - for (_mur_i = -_mur_nblocks; _mur_i != 0; _mur_i++) { \ - _mur_k1 = MUR_GETBLOCK(_mur_blocks,_mur_i); \ - _mur_k1 *= _mur_c1; \ - _mur_k1 = MUR_ROTL32(_mur_k1,15); \ - _mur_k1 *= _mur_c2; \ - \ - _mur_h1 ^= _mur_k1; \ - _mur_h1 = MUR_ROTL32(_mur_h1,13); \ - _mur_h1 = (_mur_h1*5U) + 0xe6546b64u; \ - } \ - _mur_tail = (const uint8_t*)(_mur_data + (_mur_nblocks*4)); \ - _mur_k1=0; \ - switch ((keylen) & 3U) { \ - case 0: break; \ - case 3: _mur_k1 ^= (uint32_t)_mur_tail[2] << 16; /* FALLTHROUGH */ \ - case 2: _mur_k1 ^= (uint32_t)_mur_tail[1] << 8; /* FALLTHROUGH */ \ - case 1: _mur_k1 ^= (uint32_t)_mur_tail[0]; \ - _mur_k1 *= _mur_c1; \ - _mur_k1 = MUR_ROTL32(_mur_k1,15); \ - _mur_k1 *= _mur_c2; \ - _mur_h1 ^= _mur_k1; \ - } \ - _mur_h1 ^= (uint32_t)(keylen); \ - MUR_FMIX(_mur_h1); \ - hashv = _mur_h1; \ -} while (0) -#endif /* HASH_USING_NO_STRICT_ALIASING */ - /* iterate over items in a known bucket to find desired item */ #define HASH_FIND_IN_BKT(tbl,hh,head,keyptr,keylen_in,hashval,out) \ do { \ @@ -747,7 +750,7 @@ do { } \ while ((out) != NULL) { \ if ((out)->hh.hashv == (hashval) && (out)->hh.keylen == (keylen_in)) { \ - if (uthash_memcmp((out)->hh.key, keyptr, keylen_in) == 0) { \ + if (HASH_KEYCMP((out)->hh.key, keyptr, keylen_in) == 0) { \ break; \ } \ } \ @@ -760,7 +763,7 @@ do { } while (0) /* add an item to a bucket */ -#define HASH_ADD_TO_BKT(head,addhh) \ +#define HASH_ADD_TO_BKT(head,hh,addhh,oomed) \ do { \ UT_hash_bucket *_ha_head = &(head); \ _ha_head->count++; \ @@ -772,7 +775,12 @@ do { _ha_head->hh_head = (addhh); \ if ((_ha_head->count >= ((_ha_head->expand_mult + 1U) * HASH_BKT_CAPACITY_THRESH)) \ && !(addhh)->tbl->noexpand) { \ - HASH_EXPAND_BUCKETS((addhh)->tbl); \ + HASH_EXPAND_BUCKETS(addhh,(addhh)->tbl, oomed); \ + IF_HASH_NONFATAL_OOM( \ + if (oomed) { \ + HASH_DEL_IN_BKT(head,addhh); \ + } \ + ) \ } \ } while (0) @@ -821,53 +829,56 @@ do { * ceil(n/b) = (n>>lb) + ( (n & (b-1)) ? 1:0) * */ -#define HASH_EXPAND_BUCKETS(tbl) \ +#define HASH_EXPAND_BUCKETS(hh,tbl,oomed) \ do { \ unsigned _he_bkt; \ unsigned _he_bkt_i; \ struct UT_hash_handle *_he_thh, *_he_hh_nxt; \ UT_hash_bucket *_he_new_buckets, *_he_newbkt; \ _he_new_buckets = (UT_hash_bucket*)uthash_malloc( \ - 2UL * (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \ + sizeof(struct UT_hash_bucket) * (tbl)->num_buckets * 2U); \ if (!_he_new_buckets) { \ - uthash_fatal("out of memory"); \ - } \ - uthash_bzero(_he_new_buckets, \ - 2UL * (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \ - (tbl)->ideal_chain_maxlen = \ - ((tbl)->num_items >> ((tbl)->log2_num_buckets+1U)) + \ - ((((tbl)->num_items & (((tbl)->num_buckets*2U)-1U)) != 0U) ? 1U : 0U); \ - (tbl)->nonideal_items = 0; \ - for (_he_bkt_i = 0; _he_bkt_i < (tbl)->num_buckets; _he_bkt_i++) { \ - _he_thh = (tbl)->buckets[ _he_bkt_i ].hh_head; \ - while (_he_thh != NULL) { \ - _he_hh_nxt = _he_thh->hh_next; \ - HASH_TO_BKT(_he_thh->hashv, (tbl)->num_buckets * 2U, _he_bkt); \ - _he_newbkt = &(_he_new_buckets[_he_bkt]); \ - if (++(_he_newbkt->count) > (tbl)->ideal_chain_maxlen) { \ - (tbl)->nonideal_items++; \ - _he_newbkt->expand_mult = _he_newbkt->count / (tbl)->ideal_chain_maxlen; \ - } \ - _he_thh->hh_prev = NULL; \ - _he_thh->hh_next = _he_newbkt->hh_head; \ - if (_he_newbkt->hh_head != NULL) { \ - _he_newbkt->hh_head->hh_prev = _he_thh; \ + HASH_RECORD_OOM(oomed); \ + } else { \ + uthash_bzero(_he_new_buckets, \ + sizeof(struct UT_hash_bucket) * (tbl)->num_buckets * 2U); \ + (tbl)->ideal_chain_maxlen = \ + ((tbl)->num_items >> ((tbl)->log2_num_buckets+1U)) + \ + ((((tbl)->num_items & (((tbl)->num_buckets*2U)-1U)) != 0U) ? 1U : 0U); \ + (tbl)->nonideal_items = 0; \ + for (_he_bkt_i = 0; _he_bkt_i < (tbl)->num_buckets; _he_bkt_i++) { \ + _he_thh = (tbl)->buckets[ _he_bkt_i ].hh_head; \ + while (_he_thh != NULL) { \ + _he_hh_nxt = _he_thh->hh_next; \ + HASH_TO_BKT(_he_thh->hashv, (tbl)->num_buckets * 2U, _he_bkt); \ + _he_newbkt = &(_he_new_buckets[_he_bkt]); \ + if (++(_he_newbkt->count) > (tbl)->ideal_chain_maxlen) { \ + (tbl)->nonideal_items++; \ + if (_he_newbkt->count > _he_newbkt->expand_mult * (tbl)->ideal_chain_maxlen) { \ + _he_newbkt->expand_mult++; \ + } \ + } \ + _he_thh->hh_prev = NULL; \ + _he_thh->hh_next = _he_newbkt->hh_head; \ + if (_he_newbkt->hh_head != NULL) { \ + _he_newbkt->hh_head->hh_prev = _he_thh; \ + } \ + _he_newbkt->hh_head = _he_thh; \ + _he_thh = _he_hh_nxt; \ } \ - _he_newbkt->hh_head = _he_thh; \ - _he_thh = _he_hh_nxt; \ } \ + uthash_free((tbl)->buckets, (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \ + (tbl)->num_buckets *= 2U; \ + (tbl)->log2_num_buckets++; \ + (tbl)->buckets = _he_new_buckets; \ + (tbl)->ineff_expands = ((tbl)->nonideal_items > ((tbl)->num_items >> 1)) ? \ + ((tbl)->ineff_expands+1U) : 0U; \ + if ((tbl)->ineff_expands > 1U) { \ + (tbl)->noexpand = 1; \ + uthash_noexpand_fyi(tbl); \ + } \ + uthash_expand_fyi(tbl); \ } \ - uthash_free((tbl)->buckets, (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \ - (tbl)->num_buckets *= 2U; \ - (tbl)->log2_num_buckets++; \ - (tbl)->buckets = _he_new_buckets; \ - (tbl)->ineff_expands = ((tbl)->nonideal_items > ((tbl)->num_items >> 1)) ? \ - ((tbl)->ineff_expands+1U) : 0U; \ - if ((tbl)->ineff_expands > 1U) { \ - (tbl)->noexpand = 1; \ - uthash_noexpand_fyi(tbl); \ - } \ - uthash_expand_fyi(tbl); \ } while (0) @@ -977,7 +988,8 @@ do { _src_hh = _src_hh->hh_next) { \ _elt = ELMT_FROM_HH((src)->hh_src.tbl, _src_hh); \ if (cond(_elt)) { \ - _dst_hh = (UT_hash_handle*)(((char*)_elt) + _dst_hho); \ + IF_HASH_NONFATAL_OOM( int _hs_oomed = 0; ) \ + _dst_hh = (UT_hash_handle*)(void*)(((char*)_elt) + _dst_hho); \ _dst_hh->key = _src_hh->key; \ _dst_hh->keylen = _src_hh->keylen; \ _dst_hh->hashv = _src_hh->hashv; \ @@ -988,14 +1000,30 @@ do { } \ if ((dst) == NULL) { \ DECLTYPE_ASSIGN(dst, _elt); \ - HASH_MAKE_TABLE(hh_dst, dst); \ + HASH_MAKE_TABLE(hh_dst, dst, _hs_oomed); \ + IF_HASH_NONFATAL_OOM( \ + if (_hs_oomed) { \ + uthash_nonfatal_oom(_elt); \ + (dst) = NULL; \ + continue; \ + } \ + ) \ } else { \ _dst_hh->tbl = (dst)->hh_dst.tbl; \ } \ HASH_TO_BKT(_dst_hh->hashv, _dst_hh->tbl->num_buckets, _dst_bkt); \ - HASH_ADD_TO_BKT(_dst_hh->tbl->buckets[_dst_bkt], _dst_hh); \ - HASH_BLOOM_ADD(_dst_hh->tbl, _dst_hh->hashv); \ + HASH_ADD_TO_BKT(_dst_hh->tbl->buckets[_dst_bkt], hh_dst, _dst_hh, _hs_oomed); \ (dst)->hh_dst.tbl->num_items++; \ + IF_HASH_NONFATAL_OOM( \ + if (_hs_oomed) { \ + HASH_ROLLBACK_BKT(hh_dst, dst, _dst_hh); \ + HASH_DELETE_HH(hh_dst, dst, _dst_hh); \ + _dst_hh->tbl = NULL; \ + uthash_nonfatal_oom(_elt); \ + continue; \ + } \ + ) \ + HASH_BLOOM_ADD(_dst_hh->tbl, _dst_hh->hashv); \ _last_elt = _elt; \ _last_elt_hh = _dst_hh; \ } \ diff --git a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/utlist.h b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/utlist.h similarity index 98% rename from tools/sdk/esp32c3/include/coap/libcoap/include/coap2/utlist.h rename to tools/sdk/esp32s2/include/coap/libcoap/include/coap3/utlist.h index 2f4c08406f4..1979448a7b9 100644 --- a/tools/sdk/esp32c3/include/coap/libcoap/include/coap2/utlist.h +++ b/tools/sdk/esp32s2/include/coap/libcoap/include/coap3/utlist.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2007-2017, Troy D. Hanson http://troydhanson.github.com/uthash/ +Copyright (c) 2007-2021, Troy D. Hanson http://troydhanson.github.io/uthash/ All rights reserved. Redistribution and use in source and binary forms, with or without @@ -24,7 +24,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef UTLIST_H #define UTLIST_H -#define UTLIST_VERSION 2.0.2 +#define UTLIST_VERSION 2.3.0 #include @@ -358,8 +358,8 @@ do { do { \ LDECLTYPE(head) _tmp; \ if (head) { \ - LL_LOWER_BOUND(head, _tmp, add, cmp); \ - LL_APPEND_ELEM(head, _tmp, add); \ + LL_LOWER_BOUND2(head, _tmp, add, cmp, next); \ + LL_APPEND_ELEM2(head, _tmp, add, next); \ } else { \ (head) = (add); \ (head)->next = NULL; \ @@ -651,14 +651,14 @@ do { } while (0) #define DL_INSERT_INORDER(head,add,cmp) \ - DL_INSERT_INORDER2(head,add,cmp,next) + DL_INSERT_INORDER2(head,add,cmp,prev,next) -#define DL_INSERT_INORDER2(head,add,cmp,next) \ +#define DL_INSERT_INORDER2(head,add,cmp,prev,next) \ do { \ LDECLTYPE(head) _tmp; \ if (head) { \ - DL_LOWER_BOUND(head, _tmp, add, cmp); \ - DL_APPEND_ELEM(head, _tmp, add); \ + DL_LOWER_BOUND2(head, _tmp, add, cmp, next); \ + DL_APPEND_ELEM2(head, _tmp, add, prev, next); \ } else { \ (head) = (add); \ (head)->prev = (head); \ @@ -825,7 +825,7 @@ do { /* Here are VS2008 / NO_DECLTYPE replacements for a few functions */ #undef DL_INSERT_INORDER2 -#define DL_INSERT_INORDER2(head,add,cmp,next) \ +#define DL_INSERT_INORDER2(head,add,cmp,prev,next) \ do { \ if ((head) == NULL) { \ (add)->prev = (add); \ @@ -838,7 +838,7 @@ do { (head) = (add); \ } else { \ char *_tmp = (char*)(head); \ - while ((char*)(head)->next != _tmp && (cmp((head)->next, add)) < 0) { \ + while ((head)->next && (cmp((head)->next, add)) < 0) { \ (head) = (head)->next; \ } \ (add)->prev = (head); \ @@ -892,14 +892,14 @@ do { } while (0) #define CDL_INSERT_INORDER(head,add,cmp) \ - CDL_INSERT_INORDER2(head,add,cmp,next) + CDL_INSERT_INORDER2(head,add,cmp,prev,next) -#define CDL_INSERT_INORDER2(head,add,cmp,next) \ +#define CDL_INSERT_INORDER2(head,add,cmp,prev,next) \ do { \ LDECLTYPE(head) _tmp; \ if (head) { \ - CDL_LOWER_BOUND(head, _tmp, add, cmp); \ - CDL_APPEND_ELEM(head, _tmp, add); \ + CDL_LOWER_BOUND2(head, _tmp, add, cmp, next); \ + CDL_APPEND_ELEM2(head, _tmp, add, prev, next); \ } else { \ (head) = (add); \ (head)->next = (head); \ @@ -1044,7 +1044,7 @@ do { /* Here are VS2008 / NO_DECLTYPE replacements for a few functions */ #undef CDL_INSERT_INORDER2 -#define CDL_INSERT_INORDER2(head,add,cmp,next) \ +#define CDL_INSERT_INORDER2(head,add,cmp,prev,next) \ do { \ if ((head) == NULL) { \ (add)->prev = (add); \ diff --git a/tools/sdk/esp32s2/include/coap/port/include/coap/coap_dtls.h b/tools/sdk/esp32s2/include/coap/port/include/coap/coap_dtls.h deleted file mode 100644 index 2dd0e88d2e5..00000000000 --- a/tools/sdk/esp32s2/include/coap/port/include/coap/coap_dtls.h +++ /dev/null @@ -1,631 +0,0 @@ -/* - * coap_dtls.h -- (Datagram) Transport Layer Support for libcoap - * - * Copyright (C) 2016 Olaf Bergmann - * Copyright (C) 2017 Jean-Claude Michelou - * - * This file is part of the CoAP library libcoap. Please see README for terms - * of use. - */ - -#ifndef COAP_DTLS_H_ -#define COAP_DTLS_H_ - -#include "coap_time.h" -#include "str.h" - -struct coap_context_t; -struct coap_session_t; -struct coap_dtls_pki_t; - -/** - * @defgroup dtls DTLS Support - * API functions for interfacing with DTLS libraries. - * @{ - */ - -/** - * Check whether DTLS is available. - * - * @return @c 1 if support for DTLS is enabled, or @c 0 otherwise. - */ -int coap_dtls_is_supported(void); - -/** - * Check whether TLS is available. - * - * @return @c 1 if support for TLS is enabled, or @c 0 otherwise. - */ -int coap_tls_is_supported(void); - -typedef enum coap_tls_library_t { - COAP_TLS_LIBRARY_NOTLS = 0, /**< No DTLS library */ - COAP_TLS_LIBRARY_TINYDTLS, /**< Using TinyDTLS library */ - COAP_TLS_LIBRARY_OPENSSL, /**< Using OpenSSL library */ - COAP_TLS_LIBRARY_GNUTLS, /**< Using GnuTLS library */ - COAP_TLS_LIBRARY_MBEDTLS, /**< Using MbedTLS library */ -} coap_tls_library_t; - -/** - * The structure used for returning the underlying (D)TLS library - * information. - */ -typedef struct coap_tls_version_t { - uint64_t version; /**< (D)TLS runtime Library Version */ - coap_tls_library_t type; /**< Library type. One of COAP_TLS_LIBRARY_* */ - uint64_t built_version; /**< (D)TLS Built against Library Version */ -} coap_tls_version_t; - -/** - * Determine the type and version of the underlying (D)TLS library. - * - * @return The version and type of library libcoap was compiled against. - */ -coap_tls_version_t *coap_get_tls_library_version(void); - -/** - * Additional Security setup handler that can be set up by - * coap_context_set_pki(). - * Invoked when libcoap has done the validation checks at the TLS level, - * but the application needs to do some additional checks/changes/updates. - * - * @param tls_session The security session definition - e.g. SSL * for OpenSSL. - * NULL if server call-back. - * This will be dependent on the underlying TLS library - - * see coap_get_tls_library_version() - * @param setup_data A structure containing setup data originally passed into - * coap_context_set_pki() or coap_new_client_session_pki(). - * - * @return @c 1 if successful, else @c 0. - */ -typedef int (*coap_dtls_security_setup_t)(void* tls_session, - struct coap_dtls_pki_t *setup_data); - -/** - * CN Validation call-back that can be set up by coap_context_set_pki(). - * Invoked when libcoap has done the validation checks at the TLS level, - * but the application needs to check that the CN is allowed. - * CN is the SubjectAltName in the cert, if not present, then the leftmost - * Common Name (CN) component of the subject name. - * - * @param cn The determined CN from the certificate - * @param asn1_public_cert The ASN.1 DER encoded X.509 certificate - * @param asn1_length The ASN.1 length - * @param coap_session The CoAP session associated with the certificate update - * @param depth Depth in cert chain. If 0, then client cert, else a CA - * @param validated TLS layer can find no issues if 1 - * @param arg The same as was passed into coap_context_set_pki() - * in setup_data->cn_call_back_arg - * - * @return @c 1 if accepted, else @c 0 if to be rejected. - */ -typedef int (*coap_dtls_cn_callback_t)(const char *cn, - const uint8_t *asn1_public_cert, - size_t asn1_length, - struct coap_session_t *coap_session, - unsigned depth, - int validated, - void *arg); - -/** - * The enum used for determining the provided PKI ASN.1 (DER) Private Key - * formats. - */ -typedef enum coap_asn1_privatekey_type_t { - COAP_ASN1_PKEY_NONE, /**< NONE */ - COAP_ASN1_PKEY_RSA, /**< RSA type */ - COAP_ASN1_PKEY_RSA2, /**< RSA2 type */ - COAP_ASN1_PKEY_DSA, /**< DSA type */ - COAP_ASN1_PKEY_DSA1, /**< DSA1 type */ - COAP_ASN1_PKEY_DSA2, /**< DSA2 type */ - COAP_ASN1_PKEY_DSA3, /**< DSA3 type */ - COAP_ASN1_PKEY_DSA4, /**< DSA4 type */ - COAP_ASN1_PKEY_DH, /**< DH type */ - COAP_ASN1_PKEY_DHX, /**< DHX type */ - COAP_ASN1_PKEY_EC, /**< EC type */ - COAP_ASN1_PKEY_HMAC, /**< HMAC type */ - COAP_ASN1_PKEY_CMAC, /**< CMAC type */ - COAP_ASN1_PKEY_TLS1_PRF, /**< TLS1_PRF type */ - COAP_ASN1_PKEY_HKDF /**< HKDF type */ -} coap_asn1_privatekey_type_t; - -/** - * The enum used for determining the PKI key formats. - */ -typedef enum coap_pki_key_t { - COAP_PKI_KEY_PEM = 0, /**< The PKI key type is PEM file */ - COAP_PKI_KEY_ASN1, /**< The PKI key type is ASN.1 (DER) */ - COAP_PKI_KEY_PEM_BUF, /**< The PKI key type is PEM buffer */ -} coap_pki_key_t; - -/** - * The structure that holds the PKI PEM definitions. - */ -typedef struct coap_pki_key_pem_t { - const char *ca_file; /**< File location of Common CA in PEM format */ - const char *public_cert; /**< File location of Public Cert in PEM format */ - const char *private_key; /**< File location of Private Key in PEM format */ -} coap_pki_key_pem_t; - -/** - * The structure that holds the PKI PEM buffer definitions. - */ -typedef struct coap_pki_key_pem_buf_t { - const uint8_t *ca_cert; /**< PEM buffer Common CA Cert */ - const uint8_t *public_cert; /**< PEM buffer Public Cert */ - const uint8_t *private_key; /**< PEM buffer Private Key */ - size_t ca_cert_len; /**< PEM buffer CA Cert length */ - size_t public_cert_len; /**< PEM buffer Public Cert length */ - size_t private_key_len; /**< PEM buffer Private Key length */ -} coap_pki_key_pem_buf_t; - -/** - * The structure that holds the PKI ASN.1 (DER) definitions. - */ -typedef struct coap_pki_key_asn1_t { - const uint8_t *ca_cert; /**< ASN1 (DER) Common CA Cert */ - const uint8_t *public_cert; /**< ASN1 (DER) Public Cert */ - const uint8_t *private_key; /**< ASN1 (DER) Private Key */ - size_t ca_cert_len; /**< ASN1 CA Cert length */ - size_t public_cert_len; /**< ASN1 Public Cert length */ - size_t private_key_len; /**< ASN1 Private Key length */ - coap_asn1_privatekey_type_t private_key_type; /**< Private Key Type */ -} coap_pki_key_asn1_t; - -/** - * The structure that holds the PKI key information. - */ -typedef struct coap_dtls_key_t { - coap_pki_key_t key_type; /**< key format type */ - union { - coap_pki_key_pem_t pem; /**< for PEM file keys */ - coap_pki_key_pem_buf_t pem_buf; /**< for PEM memory keys */ - coap_pki_key_asn1_t asn1; /**< for ASN.1 (DER) file keys */ - } key; -} coap_dtls_key_t; - -/** - * Server Name Indication (SNI) Validation call-back that can be set up by - * coap_context_set_pki(). - * Invoked if the SNI is not previously seen and prior to sending a certificate - * set back to the client so that the appropriate certificate set can be used - * based on the requesting SNI. - * - * @param sni The requested SNI - * @param arg The same as was passed into coap_context_set_pki() - * in setup_data->sni_call_back_arg - * - * @return New set of certificates to use, or @c NULL if SNI is to be rejected. - */ -typedef coap_dtls_key_t *(*coap_dtls_sni_callback_t)(const char *sni, - void* arg); - - -#define COAP_DTLS_PKI_SETUP_VERSION 1 /**< Latest PKI setup version */ - -/** - * The structure used for defining the PKI setup data to be used. - */ -typedef struct coap_dtls_pki_t { - uint8_t version; /** Set to 1 to support this version of the struct */ - - /* Options to enable different TLS functionality in libcoap */ - uint8_t verify_peer_cert; /**< 1 if peer cert is to be verified */ - uint8_t require_peer_cert; /**< 1 if peer cert is required */ - uint8_t allow_self_signed; /**< 1 if self signed certs are allowed */ - uint8_t allow_expired_certs; /**< 1 if expired certs are allowed */ - uint8_t cert_chain_validation; /**< 1 if to check cert_chain_verify_depth */ - uint8_t cert_chain_verify_depth; /**< recommended depth is 3 */ - uint8_t check_cert_revocation; /**< 1 if revocation checks wanted */ - uint8_t allow_no_crl; /**< 1 ignore if CRL not there */ - uint8_t allow_expired_crl; /**< 1 if expired crl is allowed */ - uint8_t allow_bad_md_hash; /**< 1 if expired certs are allowed */ - uint8_t allow_short_rsa_length; /**< 1 if expired certs are allowed */ - uint8_t reserved[4]; /**< Reserved - must be set to 0 for - future compatibility */ - /* Size of 4 chosen to align to next - * parameter, so if newly defined option - * it can use one of the reserverd slot so - * no need to change - * COAP_DTLS_PKI_SETUP_VERSION and just - * decrement the reserved[] count. - */ - - /** CN check call-back function. - * If not NULL, is called when the TLS connection has passed the configured - * TLS options above for the application to verify if the CN is valid. - */ - coap_dtls_cn_callback_t validate_cn_call_back; - void *cn_call_back_arg; /**< Passed in to the CN call-back function */ - - /** SNI check call-back function. - * If not @p NULL, called if the SNI is not previously seen and prior to - * sending a certificate set back to the client so that the appropriate - * certificate set can be used based on the requesting SNI. - */ - coap_dtls_sni_callback_t validate_sni_call_back; - void *sni_call_back_arg; /**< Passed in to the sni call-back function */ - - /** Additional Security call-back handler that is invoked when libcoap has - * done the standerd, defined validation checks at the TLS level, - * If not @p NULL, called from within the TLS Client Hello connection - * setup. - */ - coap_dtls_security_setup_t additional_tls_setup_call_back; - - char* client_sni; /**< If not NULL, SNI to use in client TLS setup. - Owned by the client app and must remain valid - during the call to coap_new_client_session_pki() */ - - coap_dtls_key_t pki_key; /**< PKI key definition */ -} coap_dtls_pki_t; - -/** @} */ - -/** - * @defgroup dtls_internal DTLS Support (Internal) - * Internal API functions for interfacing with DTLS libraries. - * @{ - */ - -/** - * Creates a new DTLS context for the given @p coap_context. This function - * returns a pointer to a new DTLS context object or @c NULL on error. - * - * Internal function. - * - * @param coap_context The CoAP context where the DTLS object shall be used. - * - * @return A DTLS context object or @c NULL on error. - */ -void * -coap_dtls_new_context(struct coap_context_t *coap_context); - -typedef enum coap_dtls_role_t { - COAP_DTLS_ROLE_CLIENT, /**< Internal function invoked for client */ - COAP_DTLS_ROLE_SERVER /**< Internal function invoked for server */ -} coap_dtls_role_t; - -/** - * Set the DTLS context's default PSK information. - * This does the PSK specifics following coap_dtls_new_context(). - * If @p COAP_DTLS_ROLE_SERVER, then identity hint will also get set. - * If @p COAP_DTLS_ROLE_SERVER, then the information will get put into the - * TLS library's context (from which sessions are derived). - * If @p COAP_DTLS_ROLE_CLIENT, then the information will get put into the - * TLS library's session. - * - * Internal function. - * - * @param coap_context The CoAP context. - * @param identity_hint The default PSK server identity hint sent to a client. - * Required parameter. If @p NULL, will be set to "". - * Empty string is a valid hint. - * This parameter is ignored if COAP_DTLS_ROLE_CLIENT - * @param role One of @p COAP_DTLS_ROLE_CLIENT or @p COAP_DTLS_ROLE_SERVER - * - * @return @c 1 if successful, else @c 0. - */ - -int -coap_dtls_context_set_psk(struct coap_context_t *coap_context, - const char *identity_hint, - coap_dtls_role_t role); - -/** - * Set the DTLS context's default server PKI information. - * This does the PKI specifics following coap_dtls_new_context(). - * If @p COAP_DTLS_ROLE_SERVER, then the information will get put into the - * TLS library's context (from which sessions are derived). - * If @p COAP_DTLS_ROLE_CLIENT, then the information will get put into the - * TLS library's session. - * - * Internal function. - * - * @param coap_context The CoAP context. - * @param setup_data Setup information defining how PKI is to be setup. - * Required parameter. If @p NULL, PKI will not be - * set up. - * @param role One of @p COAP_DTLS_ROLE_CLIENT or @p COAP_DTLS_ROLE_SERVER - * - * @return @c 1 if successful, else @c 0. - */ - -int -coap_dtls_context_set_pki(struct coap_context_t *coap_context, - coap_dtls_pki_t *setup_data, - coap_dtls_role_t role); - -/** - * Set the dtls context's default Root CA information for a client or server. - * - * Internal function. - * - * @param coap_context The current coap_context_t object. - * @param ca_file If not @p NULL, is the full path name of a PEM encoded - * file containing all the Root CAs to be used. - * @param ca_dir If not @p NULL, points to a directory containing PEM - * encoded files containing all the Root CAs to be used. - * - * @return @c 1 if successful, else @c 0. - */ - -int -coap_dtls_context_set_pki_root_cas(struct coap_context_t *coap_context, - const char *ca_file, - const char *ca_dir); - -/** - * Check whether one of the coap_dtls_context_set_{psk|pki}() functions have - * been called. - * - * Internal function. - * - * @param coap_context The current coap_context_t object. - * - * @return @c 1 if coap_dtls_context_set_{psk|pki}() called, else @c 0. - */ - -int coap_dtls_context_check_keys_enabled(struct coap_context_t *coap_context); - -/** - * Releases the storage allocated for @p dtls_context. - * - * Internal function. - * - * @param dtls_context The DTLS context as returned by coap_dtls_new_context(). - */ -void coap_dtls_free_context(void *dtls_context); - -/** - * Create a new client-side session. This should send a HELLO to the server. - * - * Internal function. - * - * @param coap_session The CoAP session. - * - * @return Opaque handle to underlying TLS library object containing security - * parameters for the session. -*/ -void *coap_dtls_new_client_session(struct coap_session_t *coap_session); - -/** - * Create a new DTLS server-side session. - * Called after coap_dtls_hello() has returned @c 1, signalling that a validated - * HELLO was received from a client. - * This should send a HELLO to the server. - * - * Internal function. - * - * @param coap_session The CoAP session. - * - * @return Opaque handle to underlying TLS library object containing security - * parameters for the DTLS session. - */ -void *coap_dtls_new_server_session(struct coap_session_t *coap_session); - -/** - * Terminates the DTLS session (may send an ALERT if necessary) then frees the - * underlying TLS library object containing security parameters for the session. - * - * Internal function. - * - * @param coap_session The CoAP session. - */ -void coap_dtls_free_session(struct coap_session_t *coap_session); - -/** - * Notify of a change in the CoAP session's MTU, for example after - * a PMTU update. - * - * Internal function. - * - * @param coap_session The CoAP session. - */ -void coap_dtls_session_update_mtu(struct coap_session_t *coap_session); - -/** - * Send data to a DTLS peer. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param data pointer to data. - * @param data_len Number of bytes to send. - * - * @return @c 0 if this would be blocking, @c -1 if there is an error or the - * number of cleartext bytes sent. - */ -int coap_dtls_send(struct coap_session_t *coap_session, - const uint8_t *data, - size_t data_len); - -/** - * Check if timeout is handled per CoAP session or per CoAP context. - * - * Internal function. - * - * @return @c 1 of timeout and retransmit is per context, @c 0 if it is - * per session. - */ -int coap_dtls_is_context_timeout(void); - -/** - * Do all pending retransmits and get next timeout - * - * Internal function. - * - * @param dtls_context The DTLS context. - * - * @return @c 0 if no event is pending or date of the next retransmit. - */ -coap_tick_t coap_dtls_get_context_timeout(void *dtls_context); - -/** - * Get next timeout for this session. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param now The current time in ticks. - * - * @return @c 0 If no event is pending or ticks time of the next retransmit. - */ -coap_tick_t coap_dtls_get_timeout(struct coap_session_t *coap_session, - coap_tick_t now); - -/** - * Handle a DTLS timeout expiration. - * - * Internal function. - * - * @param coap_session The CoAP session. - */ -void coap_dtls_handle_timeout(struct coap_session_t *coap_session); - -/** - * Handling incoming data from a DTLS peer. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param data Encrypted datagram. - * @param data_len Encrypted datagram size. - * - * @return Result of coap_handle_dgram on the decrypted CoAP PDU - * or @c -1 for error. - */ -int coap_dtls_receive(struct coap_session_t *coap_session, - const uint8_t *data, - size_t data_len); - -/** - * Handling client HELLO messages from a new candiate peer. - * Note that session->tls is empty. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param data Encrypted datagram. - * @param data_len Encrypted datagram size. - * - * @return @c 0 if a cookie verification message has been sent, @c 1 if the - * HELLO contains a valid cookie and a server session should be created, - * @c -1 if the message is invalid. - */ -int coap_dtls_hello(struct coap_session_t *coap_session, - const uint8_t *data, - size_t data_len); - -/** - * Get DTLS overhead over cleartext PDUs. - * - * Internal function. - * - * @param coap_session The CoAP session. - * - * @return Maximum number of bytes added by DTLS layer. - */ -unsigned int coap_dtls_get_overhead(struct coap_session_t *coap_session); - -/** - * Create a new TLS client-side session. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param connected Updated with whether the connection is connected yet or not. - * @c 0 is not connected, @c 1 is connected. - * - * @return Opaque handle to underlying TLS library object containing security - * parameters for the session. -*/ -void *coap_tls_new_client_session(struct coap_session_t *coap_session, int *connected); - -/** - * Create a TLS new server-side session. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param connected Updated with whether the connection is connected yet or not. - * @c 0 is not connected, @c 1 is connected. - * - * @return Opaque handle to underlying TLS library object containing security - * parameters for the session. - */ -void *coap_tls_new_server_session(struct coap_session_t *coap_session, int *connected); - -/** - * Terminates the TLS session (may send an ALERT if necessary) then frees the - * underlying TLS library object containing security parameters for the session. - * - * Internal function. - * - * @param coap_session The CoAP session. - */ -void coap_tls_free_session( struct coap_session_t *coap_session ); - -/** - * Send data to a TLS peer, with implicit flush. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param data Pointer to data. - * @param data_len Number of bytes to send. - * - * @return @c 0 if this should be retried, @c -1 if there is an error - * or the number of cleartext bytes sent. - */ -ssize_t coap_tls_write(struct coap_session_t *coap_session, - const uint8_t *data, - size_t data_len - ); - -/** - * Read some data from a TLS peer. - * - * Internal function. - * - * @param coap_session The CoAP session. - * @param data Pointer to data. - * @param data_len Maximum number of bytes to read. - * - * @return @c 0 if this should be retried, @c -1 if there is an error - * or the number of cleartext bytes read. - */ -ssize_t coap_tls_read(struct coap_session_t *coap_session, - uint8_t *data, - size_t data_len - ); - -/** - * Initialize the underlying (D)TLS Library layer. - * - * Internal function. - * - */ -void coap_dtls_startup(void); - -/** @} */ - -/** - * @ingroup logging - * Sets the (D)TLS logging level to the specified @p level. - * Note: coap_log_level() will influence output if at a specified level. - * - * @param level The logging level to use - LOG_* - */ -void coap_dtls_set_log_level(int level); - -/** - * @ingroup logging - * Get the current (D)TLS logging. - * - * @return The current log level (one of LOG_*). - */ -int coap_dtls_get_log_level(void); - - -#endif /* COAP_DTLS_H */ diff --git a/tools/sdk/esp32c3/include/coap/port/include/coap/coap.h b/tools/sdk/esp32s2/include/coap/port/include/coap3/coap.h similarity index 53% rename from tools/sdk/esp32c3/include/coap/port/include/coap/coap.h rename to tools/sdk/esp32s2/include/coap/port/include/coap3/coap.h index f048ca85714..c69d2734b3a 100644 --- a/tools/sdk/esp32c3/include/coap/port/include/coap/coap.h +++ b/tools/sdk/esp32s2/include/coap/port/include/coap3/coap.h @@ -21,27 +21,28 @@ extern "C" { #endif -#include "libcoap.h" +#include "coap3/libcoap.h" -#include "address.h" -#include "async.h" -#include "bits.h" -#include "block.h" -#include "coap_dtls.h" -#include "coap_event.h" -#include "coap_io.h" -#include "coap_time.h" -#include "coap_debug.h" -#include "encode.h" -#include "mem.h" -#include "net.h" -#include "option.h" -#include "pdu.h" -#include "prng.h" -#include "resource.h" -#include "str.h" -#include "subscribe.h" -#include "uri.h" +#include "coap3/coap_forward_decls.h" +#include "coap3/address.h" +#include "coap3/async.h" +#include "coap3/block.h" +#include "coap3/coap_cache.h" +#include "coap3/coap_dtls.h" +#include "coap3/coap_event.h" +#include "coap3/coap_io.h" +#include "coap3/coap_time.h" +#include "coap3/coap_debug.h" +#include "coap3/encode.h" +#include "coap3/mem.h" +#include "coap3/net.h" +#include "coap3/option.h" +#include "coap3/pdu.h" +#include "coap3/coap_prng.h" +#include "coap3/resource.h" +#include "coap3/str.h" +#include "coap3/subscribe.h" +#include "coap3/uri.h" #ifdef __cplusplus } diff --git a/tools/sdk/esp32s2/include/coap/port/include/coap_config_posix.h b/tools/sdk/esp32s2/include/coap/port/include/coap_config_posix.h index 3f6b7c605fc..b24335ad156 100644 --- a/tools/sdk/esp32s2/include/coap/port/include/coap_config_posix.h +++ b/tools/sdk/esp32s2/include/coap/port/include/coap_config_posix.h @@ -30,6 +30,7 @@ #define HAVE_NETDB_H #define HAVE_NETINET_IN_H #define HAVE_STRUCT_CMSGHDR +#define COAP_DISABLE_TCP 0 #define ipi_spec_dst ipi_addr struct in6_pktinfo { @@ -53,8 +54,6 @@ struct in6_pktinfo { #define COAP_CONSTRAINED_STACK 1 #define ESPIDF_VERSION -#define _POSIX_TIMERS 1 - #define gai_strerror(x) "gai_strerror() not supported" #endif /* WITH_POSIX */ diff --git a/tools/sdk/esp32s2/include/config/sdkconfig.h b/tools/sdk/esp32s2/include/config/sdkconfig.h index a32e423ec6f..48660a5006f 100644 --- a/tools/sdk/esp32s2/include/config/sdkconfig.h +++ b/tools/sdk/esp32s2/include/config/sdkconfig.h @@ -24,6 +24,7 @@ #define CONFIG_BOOTLOADER_WDT_TIME_MS 9000 #define CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP 1 #define CONFIG_BOOTLOADER_RESERVE_RTC_SIZE 0x10 +#define CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT 1 #define CONFIG_SECURE_BOOT_SUPPORTS_RSA 1 #define CONFIG_SECURE_TARGET_HAS_SECURE_ROM_DL_MODE 1 #define CONFIG_BOOT_ROM_LOG_ALWAYS_ON 1 @@ -95,35 +96,6 @@ #define CONFIG_COMPILER_WARN_WRITE_STRINGS 1 #define CONFIG_APPTRACE_DEST_NONE 1 #define CONFIG_APPTRACE_LOCK_ENABLE 1 -#define CONFIG_BTDM_CTRL_BR_EDR_SCO_DATA_PATH_EFF 0 -#define CONFIG_BTDM_CTRL_PCM_ROLE_EFF 0 -#define CONFIG_BTDM_CTRL_PCM_POLAR_EFF 0 -#define CONFIG_BTDM_CTRL_BLE_MAX_CONN_EFF 0 -#define CONFIG_BTDM_CTRL_BR_EDR_MAX_ACL_CONN_EFF 0 -#define CONFIG_BTDM_CTRL_BR_EDR_MAX_SYNC_CONN_EFF 0 -#define CONFIG_BTDM_CTRL_PINNED_TO_CORE 0 -#define CONFIG_BTDM_BLE_SLEEP_CLOCK_ACCURACY_INDEX_EFF 1 -#define CONFIG_BT_CTRL_MODE_EFF 1 -#define CONFIG_BT_CTRL_BLE_MAX_ACT 10 -#define CONFIG_BT_CTRL_BLE_MAX_ACT_EFF 10 -#define CONFIG_BT_CTRL_BLE_STATIC_ACL_TX_BUF_NB 0 -#define CONFIG_BT_CTRL_PINNED_TO_CORE 0 -#define CONFIG_BT_CTRL_HCI_TL 1 -#define CONFIG_BT_CTRL_ADV_DUP_FILT_MAX 30 -#define CONFIG_BT_CTRL_HW_CCA_EFF 0 -#define CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_EFF 0 -#define CONFIG_BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP 1 -#define CONFIG_BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_NUM 100 -#define CONFIG_BT_CTRL_BLE_ADV_REPORT_DISCARD_THRSHOLD 20 -#define CONFIG_BT_CTRL_BLE_SCAN_DUPL 1 -#define CONFIG_BT_CTRL_SCAN_DUPL_TYPE 0 -#define CONFIG_BT_CTRL_SCAN_DUPL_CACHE_SIZE 100 -#define CONFIG_BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_EFF 0 -#define CONFIG_BT_CTRL_SLEEP_MODE_EFF 0 -#define CONFIG_BT_CTRL_SLEEP_CLOCK_EFF 0 -#define CONFIG_BT_CTRL_HCI_TL_EFF 1 -#define CONFIG_BT_RESERVE_DRAM 0x0 -#define CONFIG_BT_NIMBLE_USE_ESP_TIMER 1 #define CONFIG_COAP_MBEDTLS_PSK 1 #define CONFIG_COAP_LOG_DEFAULT_LEVEL 0 #define CONFIG_ADC_DISABLE_DAC 1 @@ -178,6 +150,9 @@ #define CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_AP 1 #define CONFIG_ESP32S2_UNIVERSAL_MAC_ADDRESSES_TWO 1 #define CONFIG_ESP32S2_UNIVERSAL_MAC_ADDRESSES 2 +#define CONFIG_ESP_SLEEP_RTC_BUS_ISO_WORKAROUND 1 +#define CONFIG_ESP_IPC_TASK_STACK_SIZE 1024 +#define CONFIG_LCD_PANEL_IO_FORMAT_BUF_SIZE 32 #define CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL 120 #define CONFIG_ESP_NETIF_TCPIP_LWIP 1 #define CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER 1 @@ -188,8 +163,11 @@ #define CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE 1 #define CONFIG_ESP_SYSTEM_RTC_FAST_MEM_AS_HEAP_DEPCHECK 1 #define CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP 1 +#define CONFIG_ESP_SYSTEM_MEMPROT_DEPCHECK 1 #define CONFIG_ESP_SYSTEM_MEMPROT_FEATURE 1 #define CONFIG_ESP_SYSTEM_MEMPROT_FEATURE_LOCK 1 +#define CONFIG_ESP_SYSTEM_MEMPROT_CPU_PREFETCH_PAD_SIZE 16 +#define CONFIG_ESP_SYSTEM_MEMPROT_MEM_ALIGN_SIZE 4 #define CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE 32 #define CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE 2048 #define CONFIG_ESP_MAIN_TASK_STACK_SIZE 4096 @@ -206,7 +184,7 @@ #define CONFIG_ESP_TASK_WDT 1 #define CONFIG_ESP_TASK_WDT_PANIC 1 #define CONFIG_ESP_TASK_WDT_TIMEOUT_S 5 -#define CONFIG_ESP_IPC_TASK_STACK_SIZE 1024 +#define CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_4 1 #define CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER 1 #define CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER 1 #define CONFIG_ESP_TIMER_TASK_STACK_SIZE 4096 @@ -262,9 +240,13 @@ #define CONFIG_FMB_TIMER_PORT_ENABLED 1 #define CONFIG_FMB_TIMER_GROUP 0 #define CONFIG_FMB_TIMER_INDEX 0 +#define CONFIG_FMB_MASTER_TIMER_GROUP 0 +#define CONFIG_FMB_MASTER_TIMER_INDEX 0 #define CONFIG_FREERTOS_UNICORE 1 #define CONFIG_FREERTOS_NO_AFFINITY 0x7FFFFFFF +#define CONFIG_FREERTOS_TICK_SUPPORT_CORETIMER 1 #define CONFIG_FREERTOS_CORETIMER_0 1 +#define CONFIG_FREERTOS_SYSTICK_USES_CCOUNT 1 #define CONFIG_FREERTOS_OPTIMIZED_SCHEDULER 1 #define CONFIG_FREERTOS_HZ 1000 #define CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY 1 @@ -282,6 +264,7 @@ #define CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE 0 #define CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER 1 #define CONFIG_FREERTOS_DEBUG_OCDAWARE 1 +#define CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT 1 #define CONFIG_HAL_ASSERTION_EQUALS_SYSTEM 1 #define CONFIG_HAL_DEFAULT_ASSERTION_LEVEL 2 #define CONFIG_HEAP_POISONING_LIGHT 1 @@ -311,7 +294,6 @@ #define CONFIG_LWIP_DHCPS_MAX_STATION_NUM 8 #define CONFIG_LWIP_IPV6 1 #define CONFIG_LWIP_IPV6_NUM_ADDRESSES 3 -#define CONFIG_LWIP_IPV6_RDNSS_MAX_DNS_SERVERS 0 #define CONFIG_LWIP_NETIF_LOOPBACK 1 #define CONFIG_LWIP_LOOPBACK_MAX_PBUFS 8 #define CONFIG_LWIP_MAX_ACTIVE_TCP 16 @@ -344,7 +326,7 @@ #define CONFIG_LWIP_PPP_MPPE_SUPPORT 1 #define CONFIG_LWIP_ICMP 1 #define CONFIG_LWIP_MAX_RAW_PCBS 16 -#define CONFIG_LWIP_DHCP_MAX_NTP_SERVERS 1 +#define CONFIG_LWIP_SNTP_MAX_SERVERS 1 #define CONFIG_LWIP_SNTP_UPDATE_DELAY 3600000 #define CONFIG_LWIP_ESP_LWIP_ASSERT 1 #define CONFIG_LWIP_HOOK_TCP_ISN_DEFAULT 1 @@ -460,6 +442,9 @@ #define CONFIG_UNITY_ENABLE_FLOAT 1 #define CONFIG_UNITY_ENABLE_DOUBLE 1 #define CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER 1 +#define CONFIG_USB_OTG_SUPPORTED 1 +#define CONFIG_USB_HOST_CONTROL_TRANSFER_MAX_SIZE 256 +#define CONFIG_USB_HOST_HW_BUFFER_BIAS_BALANCED 1 #define CONFIG_VFS_SUPPORT_IO 1 #define CONFIG_VFS_SUPPORT_DIR 1 #define CONFIG_VFS_SUPPORT_SELECT 1 @@ -476,11 +461,6 @@ #define CONFIG_DSP_OPTIMIZATION 0 #define CONFIG_DSP_MAX_FFT_SIZE_4096 1 #define CONFIG_DSP_MAX_FFT_SIZE 4096 -#define CONFIG_C_IMPL 1 -#define CONFIG_MTMN_LITE_QUANT 1 -#define CONFIG_MFN56_1X 1 -#define CONFIG_HD_NANO1 1 -#define CONFIG_HP_NANO1 1 #define CONFIG_OV7670_SUPPORT 1 #define CONFIG_OV7725_SUPPORT 1 #define CONFIG_NT99141_SUPPORT 1 @@ -585,6 +565,15 @@ #define CONFIG_TIMER_TASK_STACK_SIZE CONFIG_ESP_TIMER_TASK_STACK_SIZE #define CONFIG_TOOLPREFIX CONFIG_SDK_TOOLPREFIX #define CONFIG_UDP_RECVMBOX_SIZE CONFIG_LWIP_UDP_RECVMBOX_SIZE +#define CONFIG_USB_CDC_ENABLED CONFIG_TINYUSB_CDC_ENABLED +#define CONFIG_USB_CDC_RX_BUFSIZE CONFIG_TINYUSB_CDC_RX_BUFSIZE +#define CONFIG_USB_CDC_TX_BUFSIZE CONFIG_TINYUSB_CDC_TX_BUFSIZE +#define CONFIG_USB_DEBUG_LEVEL CONFIG_TINYUSB_DEBUG_LEVEL +#define CONFIG_USB_DESC_CDC_STRING CONFIG_TINYUSB_DESC_CDC_STRING +#define CONFIG_USB_DESC_HID_STRING CONFIG_TINYUSB_DESC_HID_STRING +#define CONFIG_USB_DESC_MSC_STRING CONFIG_TINYUSB_DESC_MSC_STRING +#define CONFIG_USB_MSC_BUFSIZE CONFIG_TINYUSB_MSC_BUFSIZE +#define CONFIG_USB_MSC_ENABLED CONFIG_TINYUSB_MSC_ENABLED #define CONFIG_WARN_WRITE_STRINGS CONFIG_COMPILER_WARN_WRITE_STRINGS -#define CONFIG_ARDUINO_IDF_COMMIT "c69f0ec32" +#define CONFIG_ARDUINO_IDF_COMMIT "3e370c4296" #define CONFIG_ARDUINO_IDF_BRANCH "master" diff --git a/tools/sdk/esp32s2/include/driver/include/driver/i2s.h b/tools/sdk/esp32s2/include/driver/include/driver/i2s.h index 4ee73b594d7..aa649ed479c 100644 --- a/tools/sdk/esp32s2/include/driver/include/driver/i2s.h +++ b/tools/sdk/esp32s2/include/driver/include/driver/i2s.h @@ -13,12 +13,11 @@ #include "soc/i2s_periph.h" #include "soc/rtc_periph.h" #include "soc/soc_caps.h" -#include "hal/i2s_hal.h" #include "hal/i2s_types.h" #include "driver/periph_ctrl.h" #include "esp_intr_alloc.h" -#if SOC_I2S_SUPPORTS_ADC_DAC +#if SOC_I2S_SUPPORTS_ADC #include "driver/adc.h" #endif @@ -28,7 +27,119 @@ extern "C" { #define I2S_PIN_NO_CHANGE (-1) /*!< Use in i2s_pin_config_t for pins which should not be changed */ -typedef intr_handle_t i2s_isr_handle_t; +/** + * @brief I2S port number, the max port number is (I2S_NUM_MAX -1). + */ +typedef enum { + I2S_NUM_0 = 0, /*!< I2S port 0 */ +#if SOC_I2S_NUM > 1 + I2S_NUM_1 = 1, /*!< I2S port 1 */ +#endif + I2S_NUM_MAX, /*!< I2S port max */ +} i2s_port_t; + +#if SOC_I2S_SUPPORTS_PCM +/** + * @brief I2S PCM configuration + * + */ +typedef struct { + i2s_pcm_compress_t pcm_type; /*!< I2S PCM a/u-law decompress or compress type */ +} i2s_pcm_cfg_t; +#endif + +#if SOC_I2S_SUPPORTS_PDM_TX +/** + * @brief Default I2S PDM Up-Sampling Rate configuration + */ +#define I2S_PDM_DEFAULT_UPSAMPLE_CONFIG(rate) { \ + .sample_rate = rate, \ + .fp = 960, \ + .fs = (rate) / 100, \ + } + +/** + * @brief I2S PDM up-sample rate configuration + * @note TX PDM can only be set to the following two upsampling rate configurations: + * 1: fp = 960, fs = sample_rate / 100, in this case, Fpdm = 128*48000 + * 2: fp = 960, fs = 480, in this case, Fpdm = 128*Fpcm = 128*sample_rate + * If the pdm receiver do not care the pdm serial clock, it's recommended set Fpdm = 128*48000. + * Otherwise, the second configuration should be applied. + */ +typedef struct { + int sample_rate; /*!< I2S PDM sample rate */ + int fp; /*!< I2S PDM TX upsampling paramater. Normally it should be set to 960 */ + int fs; /*!< I2S PDM TX upsampling paramater. When it is set to 480, the pdm clock frequency Fpdm = 128 * sample_rate, when it is set to sample_rate / 100, Fpdm will be fixed to 128*48000 */ +} i2s_pdm_tx_upsample_cfg_t; +#endif + +/** + * @brief I2S pin number for i2s_set_pin + * + */ +typedef struct { + int mck_io_num; /*!< MCK in out pin*/ + int bck_io_num; /*!< BCK in out pin*/ + int ws_io_num; /*!< WS in out pin*/ + int data_out_num; /*!< DATA out pin*/ + int data_in_num; /*!< DATA in pin*/ +} i2s_pin_config_t; + +/** + * @brief I2S driver configuration parameters + * + */ +typedef struct { + + i2s_mode_t mode; /*!< I2S work mode */ + uint32_t sample_rate; /*!< I2S sample rate */ + i2s_bits_per_sample_t bits_per_sample; /*!< I2S sample bits in one channel */ + i2s_channel_fmt_t channel_format; /*!< I2S channel format.*/ + i2s_comm_format_t communication_format; /*!< I2S communication format */ + int 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 */ + int dma_buf_count; /*!< I2S DMA Buffer Count */ + int dma_buf_len; /*!< I2S DMA Buffer Length */ + bool use_apll; /*!< I2S using APLL as main I2S clock, enable it to get accurate clock */ + bool tx_desc_auto_clear; /*!< I2S auto clear tx descriptor if there is underflow condition (helps in avoiding noise in case of data unavailability) */ + int fixed_mclk; /*!< I2S using fixed MCLK output. If use_apll = true and fixed_mclk > 0, then the clock output for i2s is fixed and equal to the fixed_mclk value. If fixed_mclk set, mclk_multiple won't take effect */ + i2s_mclk_multiple_t mclk_multiple; /*!< The multiple of I2S master clock(MCLK) to sample rate */ + i2s_bits_per_chan_t bits_per_chan; /*!< I2S total bits in one channel, only take effect when larger than 'bits_per_sample', default '0' means equal to 'bits_per_sample' */ + +#if SOC_I2S_SUPPORTS_TDM + i2s_channel_t chan_mask; /*!< I2S active channel bit mask, set value in `i2s_channel_t` to enable specific channel, the bit map of active channel can not exceed (0x1< 4 + PCNT_UNIT_4, /*!< PCNT unit 4 */ + PCNT_UNIT_5, /*!< PCNT unit 5 */ + PCNT_UNIT_6, /*!< PCNT unit 6 */ + PCNT_UNIT_7, /*!< PCNT unit 7 */ +#endif + PCNT_UNIT_MAX, +} pcnt_unit_t; + +/** + * @brief Selection of channels available for a single PCNT unit + */ +typedef enum { + PCNT_CHANNEL_0, /*!< PCNT channel 0 */ + PCNT_CHANNEL_1, /*!< PCNT channel 1 */ + PCNT_CHANNEL_MAX, +} pcnt_channel_t; + +/** + * @brief Selection of counter's events the may trigger an interrupt + */ +typedef enum { + PCNT_EVT_THRES_1 = 1 << 2, /*!< PCNT watch point event: threshold1 value event */ + PCNT_EVT_THRES_0 = 1 << 3, /*!< PCNT watch point event: threshold0 value event */ + PCNT_EVT_L_LIM = 1 << 4, /*!< PCNT watch point event: Minimum counter value */ + PCNT_EVT_H_LIM = 1 << 5, /*!< PCNT watch point event: Maximum counter value */ + PCNT_EVT_ZERO = 1 << 6, /*!< PCNT watch point event: counter value zero event */ + PCNT_EVT_MAX +} pcnt_evt_type_t; + +/** + * @brief Selection of available modes that determine the counter's action depending on the state of the control signal's input GPIO + * @note Configuration covers two actions, one for high, and one for low level on the control input + */ +typedef pcnt_channel_level_action_t pcnt_ctrl_mode_t; +#define PCNT_MODE_KEEP PCNT_CHANNEL_LEVEL_ACTION_KEEP /*!< Control mode: won't change counter mode*/ +#define PCNT_MODE_REVERSE PCNT_CHANNEL_LEVEL_ACTION_INVERSE /*!< Control mode: invert counter mode(increase -> decrease, decrease -> increase) */ +#define PCNT_MODE_DISABLE PCNT_CHANNEL_LEVEL_ACTION_HOLD /*!< Control mode: Inhibit counter(counter value will not change in this condition) */ +#define PCNT_MODE_MAX 3 + +/** + * @brief Selection of available modes that determine the counter's action on the edge of the pulse signal's input GPIO + * @note Configuration covers two actions, one for positive, and one for negative edge on the pulse input + */ +typedef pcnt_channel_edge_action_t pcnt_count_mode_t; +#define PCNT_COUNT_DIS PCNT_CHANNEL_EDGE_ACTION_HOLD /*!< Counter mode: Inhibit counter(counter value will not change in this condition) */ +#define PCNT_COUNT_INC PCNT_CHANNEL_EDGE_ACTION_INCREASE /*!< Counter mode: Increase counter value */ +#define PCNT_COUNT_DEC PCNT_CHANNEL_EDGE_ACTION_DECREASE /*!< Counter mode: Decrease counter value */ +#define PCNT_COUNT_MAX 3 + +/** + * @brief Pulse Counter configuration for a single channel + */ +typedef struct { + int pulse_gpio_num; /*!< Pulse input GPIO number, if you want to use GPIO16, enter pulse_gpio_num = 16, a negative value will be ignored */ + int ctrl_gpio_num; /*!< Control signal input GPIO number, a negative value will be ignored */ + pcnt_ctrl_mode_t lctrl_mode; /*!< PCNT low control mode */ + pcnt_ctrl_mode_t hctrl_mode; /*!< PCNT high control mode */ + pcnt_count_mode_t pos_mode; /*!< PCNT positive edge count mode */ + pcnt_count_mode_t neg_mode; /*!< PCNT negative edge count mode */ + int16_t counter_h_lim; /*!< Maximum counter value */ + int16_t counter_l_lim; /*!< Minimum counter value */ + pcnt_unit_t unit; /*!< PCNT unit number */ + pcnt_channel_t channel; /*!< the PCNT channel */ +} pcnt_config_t; + /** * @brief Configure Pulse Counter unit * @note @@ -173,7 +257,6 @@ esp_err_t pcnt_get_event_value(pcnt_unit_t unit, pcnt_evt_type_t evt_type, int16 * @param unit PCNT unit number * @param status Pointer to accept event status word * @return - * * - ESP_OK Success * - ESP_ERR_INVALID_STATE pcnt driver has not been initialized * - ESP_ERR_INVALID_ARG Parameter error @@ -363,42 +446,6 @@ void pcnt_isr_service_uninstall(void); */ esp_err_t pcnt_isr_handler_remove(pcnt_unit_t unit); -/** - * @addtogroup pcnt-examples - * - * @{ - * - * EXAMPLE OF PCNT CONFIGURATION - * ============================== - * @code{c} - * //1. Config PCNT unit - * pcnt_config_t pcnt_config = { - * .pulse_gpio_num = 4, //set gpio4 as pulse input gpio - * .ctrl_gpio_num = 5, //set gpio5 as control gpio - * .channel = PCNT_CHANNEL_0, //use unit 0 channel 0 - * .lctrl_mode = PCNT_MODE_REVERSE, //when control signal is low, reverse the primary counter mode(inc->dec/dec->inc) - * .hctrl_mode = PCNT_MODE_KEEP, //when control signal is high, keep the primary counter mode - * .pos_mode = PCNT_COUNT_INC, //increment the counter - * .neg_mode = PCNT_COUNT_DIS, //keep the counter value - * .counter_h_lim = 10, - * .counter_l_lim = -10, - * }; - * pcnt_unit_config(&pcnt_config); //init unit - * @endcode - * - * EXAMPLE OF PCNT EVENT SETTING - * ============================== - * @code{c} - * //2. Configure PCNT watchpoint event. - * pcnt_set_event_value(PCNT_UNIT_0, PCNT_EVT_THRES_1, 5); //set thres1 value - * pcnt_event_enable(PCNT_UNIT_0, PCNT_EVT_THRES_1); //enable thres1 event - * @endcode - * - * For more examples please refer to PCNT example code in IDF_PATH/examples - * - * @} - */ - #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32s2/include/driver/include/driver/spi_common.h b/tools/sdk/esp32s2/include/driver/include/driver/spi_common.h index f6b12255a53..830b8efd8c2 100644 --- a/tools/sdk/esp32s2/include/driver/include/driver/spi_common.h +++ b/tools/sdk/esp32s2/include/driver/include/driver/spi_common.h @@ -63,7 +63,8 @@ extern "C" #define SPICOMMON_BUSFLAG_DUAL (1<<6) ///< Check MOSI and MISO pins can output. Or indicates bus able to work under DIO mode. #define SPICOMMON_BUSFLAG_WPHD (1<<7) ///< Check existing of WP and HD pins. Or indicates WP & HD pins initialized. #define SPICOMMON_BUSFLAG_QUAD (SPICOMMON_BUSFLAG_DUAL|SPICOMMON_BUSFLAG_WPHD) ///< Check existing of MOSI/MISO/WP/HD pins as output. Or indicates bus able to work under QIO mode. - +#define SPICOMMON_BUSFLAG_IO4_IO7 (1<<8) ///< Check existing of IO4~IO7 pins. Or indicates IO4~IO7 pins initialized. +#define SPICOMMON_BUSFLAG_OCTAL (SPICOMMON_BUSFLAG_QUAD|SPICOMMON_BUSFLAG_IO4_IO7) ///< Check existing of MOSI/MISO/WP/HD/SPIIO4/SPIIO5/SPIIO6/SPIIO7 pins as output. Or indicates bus able to work under octal mode. #define SPICOMMON_BUSFLAG_NATIVE_PINS SPICOMMON_BUSFLAG_IOMUX_PINS /** @@ -95,18 +96,34 @@ typedef spi_common_dma_t spi_dma_chan_t; * @note Be advised that the slave driver does not use the quadwp/quadhd lines and fields in spi_bus_config_t refering to these lines will be ignored and can thus safely be left uninitialized. */ typedef struct { - int mosi_io_num; ///< GPIO pin for Master Out Slave In (=spi_d) signal, or -1 if not used. - int miso_io_num; ///< GPIO pin for Master In Slave Out (=spi_q) signal, or -1 if not used. - int sclk_io_num; ///< GPIO pin for Spi CLocK signal, or -1 if not used. - int quadwp_io_num; ///< GPIO pin for WP (Write Protect) signal which is used as D2 in 4-bit communication modes, or -1 if not used. - int quadhd_io_num; ///< GPIO pin for HD (HolD) signal which is used as D3 in 4-bit communication modes, or -1 if not used. - int max_transfer_sz; ///< Maximum transfer size, in bytes. Defaults to 4092 if 0 when DMA enabled, or to `SOC_SPI_MAXIMUM_BUFFER_SIZE` if DMA is disabled. - uint32_t flags; ///< Abilities of bus to be checked by the driver. Or-ed value of ``SPICOMMON_BUSFLAG_*`` flags. - int intr_flags; /**< Interrupt flag for the bus to set the priority, and IRAM attribute, see - * ``esp_intr_alloc.h``. Note that the EDGE, INTRDISABLED attribute are ignored - * by the driver. Note that if ESP_INTR_FLAG_IRAM is set, ALL the callbacks of - * the driver, and their callee functions, should be put in the IRAM. - */ + union { + int mosi_io_num; ///< GPIO pin for Master Out Slave In (=spi_d) signal, or -1 if not used. + int data0_io_num; ///< GPIO pin for spi data0 signal in quad/octal mode, or -1 if not used. + }; + union { + int miso_io_num; ///< GPIO pin for Master In Slave Out (=spi_q) signal, or -1 if not used. + int data1_io_num; ///< GPIO pin for spi data1 signal in quad/octal mode, or -1 if not used. + }; + int sclk_io_num; ///< GPIO pin for SPI Clock signal, or -1 if not used. + union { + int quadwp_io_num; ///< GPIO pin for WP (Write Protect) signal, or -1 if not used. + int data2_io_num; ///< GPIO pin for spi data2 signal in quad/octal mode, or -1 if not used. + }; + union { + int quadhd_io_num; ///< GPIO pin for HD (Hold) signal, or -1 if not used. + int data3_io_num; ///< GPIO pin for spi data3 signal in quad/octal mode, or -1 if not used. + }; + int data4_io_num; ///< GPIO pin for spi data4 signal in octal mode, or -1 if not used. + int data5_io_num; ///< GPIO pin for spi data5 signal in octal mode, or -1 if not used. + int data6_io_num; ///< GPIO pin for spi data6 signal in octal mode, or -1 if not used. + int data7_io_num; ///< GPIO pin for spi data7 signal in octal mode, or -1 if not used. + int max_transfer_sz; ///< Maximum transfer size, in bytes. Defaults to 4092 if 0 when DMA enabled, or to `SOC_SPI_MAXIMUM_BUFFER_SIZE` if DMA is disabled. + uint32_t flags; ///< Abilities of bus to be checked by the driver. Or-ed value of ``SPICOMMON_BUSFLAG_*`` flags. + int intr_flags; /**< Interrupt flag for the bus to set the priority, and IRAM attribute, see + * ``esp_intr_alloc.h``. Note that the EDGE, INTRDISABLED attribute are ignored + * by the driver. Note that if ESP_INTR_FLAG_IRAM is set, ALL the callbacks of + * the driver, and their callee functions, should be put in the IRAM. + */ } spi_bus_config_t; diff --git a/tools/sdk/esp32s2/include/driver/include/driver/spi_common_internal.h b/tools/sdk/esp32s2/include/driver/include/driver/spi_common_internal.h index 31baaa75d70..90826c0a8e9 100644 --- a/tools/sdk/esp32s2/include/driver/include/driver/spi_common_internal.h +++ b/tools/sdk/esp32s2/include/driver/include/driver/spi_common_internal.h @@ -155,6 +155,8 @@ esp_err_t spicommon_slave_free_dma(spi_host_device_t host_id); * - ``SPICOMMON_BUSFLAG_DUAL``: Make sure both MISO and MOSI are output capable so that DIO mode is capable. * - ``SPICOMMON_BUSFLAG_WPHD`` Make sure WP and HD are set to valid output GPIOs. * - ``SPICOMMON_BUSFLAG_QUAD``: Combination of ``SPICOMMON_BUSFLAG_DUAL`` and ``SPICOMMON_BUSFLAG_WPHD``. + * - ``SPICOMMON_BUSFLAG_IO4_IO7``: Make sure spi data4 ~ spi data7 are set to valid output GPIOs. + * - ``SPICOMMON_BUSFLAG_OCTAL``: Combination of ``SPICOMMON_BUSFLAG_QUAL`` and ``SPICOMMON_BUSFLAG_IO4_IO7``. * @param[out] flags_o A SPICOMMON_BUSFLAG_* flag combination of bus abilities will be written to this address. * Leave to NULL if not needed. * - ``SPICOMMON_BUSFLAG_IOMUX_PINS``: The bus is connected to iomux pins. @@ -163,6 +165,8 @@ esp_err_t spicommon_slave_free_dma(spi_host_device_t host_id); * - ``SPICOMMON_BUSFLAG_DUAL``: The bus is capable with DIO mode. * - ``SPICOMMON_BUSFLAG_WPHD`` The bus has WP and HD connected. * - ``SPICOMMON_BUSFLAG_QUAD``: Combination of ``SPICOMMON_BUSFLAG_DUAL`` and ``SPICOMMON_BUSFLAG_WPHD``. + * - ``SPICOMMON_BUSFLAG_IO4_IO7``: The bus has spi data4 ~ spi data7 connected. + * - ``SPICOMMON_BUSFLAG_OCTAL``: Combination of ``SPICOMMON_BUSFLAG_QUAL`` and ``SPICOMMON_BUSFLAG_IO4_IO7``. * @return * - ESP_ERR_INVALID_ARG if parameter is invalid * - ESP_OK on success diff --git a/tools/sdk/esp32s2/include/driver/include/driver/spi_master.h b/tools/sdk/esp32s2/include/driver/include/driver/spi_master.h index 8582a332766..d6a202f848a 100644 --- a/tools/sdk/esp32s2/include/driver/include/driver/spi_master.h +++ b/tools/sdk/esp32s2/include/driver/include/driver/spi_master.h @@ -104,8 +104,11 @@ typedef struct { #define SPI_TRANS_VARIABLE_CMD (1<<5) ///< Use the ``command_bits`` in ``spi_transaction_ext_t`` rather than default value in ``spi_device_interface_config_t``. #define SPI_TRANS_VARIABLE_ADDR (1<<6) ///< Use the ``address_bits`` in ``spi_transaction_ext_t`` rather than default value in ``spi_device_interface_config_t``. #define SPI_TRANS_VARIABLE_DUMMY (1<<7) ///< Use the ``dummy_bits`` in ``spi_transaction_ext_t`` rather than default value in ``spi_device_interface_config_t``. -#define SPI_TRANS_SET_CD (1<<7) ///< Set the CD pin #define SPI_TRANS_CS_KEEP_ACTIVE (1<<8) ///< Keep CS active after data transfer +#define SPI_TRANS_MULTILINE_CMD (1<<9) ///< The data lines used at command phase is the same as data phase (otherwise, only one data line is used at command phase) +#define SPI_TRANS_MODE_OCT (1<<10) ///< Transmit/receive data in 8-bit mode +#define SPI_TRANS_MULTILINE_ADDR SPI_TRANS_MODE_DIOQIO_ADDR ///< The data lines used at address phase is the same as data phase (otherwise, only one data line is used at address phase) + /** * This structure describes one SPI transaction. The descriptor should not be modified until the transaction finishes. */ @@ -148,7 +151,7 @@ typedef struct { } spi_transaction_ext_t ; -typedef struct spi_device_t* spi_device_handle_t; ///< Handle for a device on a SPI bus +typedef struct spi_device_t *spi_device_handle_t; ///< Handle for a device on a SPI bus /** * @brief Allocate a device on a SPI bus * @@ -341,7 +344,7 @@ void spi_device_release_bus(spi_device_handle_t dev); * * @return Actual working frequency that most fit. */ -int spi_cal_clock(int fapb, int hz, int duty_cycle, uint32_t* reg_o) __attribute__((deprecated)); +int spi_cal_clock(int fapb, int hz, int duty_cycle, uint32_t *reg_o) __attribute__((deprecated)); /** * @brief Calculate the working frequency that is most close to desired frequency. @@ -368,7 +371,7 @@ int spi_get_actual_clock(int fapb, int hz, int duty_cycle); * * @note If **dummy_o* is not zero, it means dummy bits should be applied in half duplex mode, and full duplex mode may not work. */ -void spi_get_timing(bool gpio_is_used, int input_delay_ns, int eff_clk, int* dummy_o, int* cycles_remain_o); +void spi_get_timing(bool gpio_is_used, int input_delay_ns, int eff_clk, int *dummy_o, int *cycles_remain_o); /** * @brief Get the frequency limit of current configurations. diff --git a/tools/sdk/esp32s2/include/driver/include/driver/timer.h b/tools/sdk/esp32s2/include/driver/include/driver/timer.h index 204fc9db27d..a3ab39267cd 100644 --- a/tools/sdk/esp32s2/include/driver/include/driver/timer.h +++ b/tools/sdk/esp32s2/include/driver/include/driver/timer.h @@ -130,8 +130,9 @@ esp_err_t timer_set_counter_mode(timer_group_t group_num, timer_idx_t timer_num, esp_err_t timer_set_auto_reload(timer_group_t group_num, timer_idx_t timer_num, timer_autoreload_t reload); /** - * @brief Set hardware timer source clock divider. Timer groups clock are divider from APB clock. - * + * @brief Set hardware divider of the source clock to the timer group. + * By default, the source clock is APB clock running at 80 MHz. + * For more information, please check Chapter Reset and Clock in Chip Technical Reference Manual. * @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1 * @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1] * @param divider Timer clock divider value. The divider's range is from from 2 to 65536. diff --git a/tools/sdk/esp32s2/include/driver/include/driver/twai.h b/tools/sdk/esp32s2/include/driver/include/driver/twai.h index ce616fe1251..70f88a4da10 100644 --- a/tools/sdk/esp32s2/include/driver/include/driver/twai.h +++ b/tools/sdk/esp32s2/include/driver/include/driver/twai.h @@ -47,23 +47,24 @@ extern "C" { */ #define TWAI_ALERT_TX_IDLE 0x00000001 /**< Alert(1): No more messages to transmit */ #define TWAI_ALERT_TX_SUCCESS 0x00000002 /**< Alert(2): The previous transmission was successful */ -#define TWAI_ALERT_BELOW_ERR_WARN 0x00000004 /**< Alert(4): Both error counters have dropped below error warning limit */ -#define TWAI_ALERT_ERR_ACTIVE 0x00000008 /**< Alert(8): TWAI controller has become error active */ -#define TWAI_ALERT_RECOVERY_IN_PROGRESS 0x00000010 /**< Alert(16): TWAI controller is undergoing bus recovery */ -#define TWAI_ALERT_BUS_RECOVERED 0x00000020 /**< Alert(32): TWAI controller has successfully completed bus recovery */ -#define TWAI_ALERT_ARB_LOST 0x00000040 /**< Alert(64): The previous transmission lost arbitration */ -#define TWAI_ALERT_ABOVE_ERR_WARN 0x00000080 /**< Alert(128): One of the error counters have exceeded the error warning limit */ -#define TWAI_ALERT_BUS_ERROR 0x00000100 /**< Alert(256): A (Bit, Stuff, CRC, Form, ACK) error has occurred on the bus */ -#define TWAI_ALERT_TX_FAILED 0x00000200 /**< Alert(512): The previous transmission has failed (for single shot transmission) */ -#define TWAI_ALERT_RX_QUEUE_FULL 0x00000400 /**< Alert(1024): The RX queue is full causing a frame to be lost */ -#define TWAI_ALERT_ERR_PASS 0x00000800 /**< Alert(2048): TWAI controller has become error passive */ -#define TWAI_ALERT_BUS_OFF 0x00001000 /**< Alert(4096): Bus-off condition occurred. TWAI controller can no longer influence bus */ -#define TWAI_ALERT_RX_FIFO_OVERRUN 0x00002000 /**< Alert(8192): An RX FIFO overrun has occurred */ -#define TWAI_ALERT_TX_RETRIED 0x00004000 /**< Alert(16384): An message transmission was cancelled and retried due to an errata workaround */ -#define TWAI_ALERT_PERIPH_RESET 0x00008000 /**< Alert(32768): The TWAI controller was reset */ -#define TWAI_ALERT_ALL 0x0000FFFF /**< Bit mask to enable all alerts during configuration */ +#define TWAI_ALERT_RX_DATA 0x00000004 /**< Alert(4): A frame has been received and added to the RX queue */ +#define TWAI_ALERT_BELOW_ERR_WARN 0x00000008 /**< Alert(8): Both error counters have dropped below error warning limit */ +#define TWAI_ALERT_ERR_ACTIVE 0x00000010 /**< Alert(16): TWAI controller has become error active */ +#define TWAI_ALERT_RECOVERY_IN_PROGRESS 0x00000020 /**< Alert(32): TWAI controller is undergoing bus recovery */ +#define TWAI_ALERT_BUS_RECOVERED 0x00000040 /**< Alert(64): TWAI controller has successfully completed bus recovery */ +#define TWAI_ALERT_ARB_LOST 0x00000080 /**< Alert(128): The previous transmission lost arbitration */ +#define TWAI_ALERT_ABOVE_ERR_WARN 0x00000100 /**< Alert(256): One of the error counters have exceeded the error warning limit */ +#define TWAI_ALERT_BUS_ERROR 0x00000200 /**< Alert(512): A (Bit, Stuff, CRC, Form, ACK) error has occurred on the bus */ +#define TWAI_ALERT_TX_FAILED 0x00000400 /**< Alert(1024): The previous transmission has failed (for single shot transmission) */ +#define TWAI_ALERT_RX_QUEUE_FULL 0x00000800 /**< Alert(2048): The RX queue is full causing a frame to be lost */ +#define TWAI_ALERT_ERR_PASS 0x00001000 /**< Alert(4096): TWAI controller has become error passive */ +#define TWAI_ALERT_BUS_OFF 0x00002000 /**< Alert(8192): Bus-off condition occurred. TWAI controller can no longer influence bus */ +#define TWAI_ALERT_RX_FIFO_OVERRUN 0x00004000 /**< Alert(16384): An RX FIFO overrun has occurred */ +#define TWAI_ALERT_TX_RETRIED 0x00008000 /**< Alert(32768): An message transmission was cancelled and retried due to an errata workaround */ +#define TWAI_ALERT_PERIPH_RESET 0x00010000 /**< Alert(65536): The TWAI controller was reset */ +#define TWAI_ALERT_ALL 0x0001FFFF /**< Bit mask to enable all alerts during configuration */ #define TWAI_ALERT_NONE 0x00000000 /**< Bit mask to disable all alerts during configuration */ -#define TWAI_ALERT_AND_LOG 0x00010000 /**< Bit mask to enable alerts to also be logged when they occur. Note that logging from the ISR is disabled if CONFIG_TWAI_ISR_IN_IRAM is enabled (see docs). */ +#define TWAI_ALERT_AND_LOG 0x00020000 /**< Bit mask to enable alerts to also be logged when they occur. Note that logging from the ISR is disabled if CONFIG_TWAI_ISR_IN_IRAM is enabled (see docs). */ /** @endcond */ diff --git a/tools/sdk/esp32s2/include/driver/include/driver/uart.h b/tools/sdk/esp32s2/include/driver/include/driver/uart.h index 311f21a8334..76aa424fa27 100644 --- a/tools/sdk/esp32s2/include/driver/include/driver/uart.h +++ b/tools/sdk/esp32s2/include/driver/include/driver/uart.h @@ -28,7 +28,10 @@ extern "C" { #endif #define UART_NUM_MAX (SOC_UART_NUM) /*!< UART port max */ -#define UART_PIN_NO_CHANGE (-1) /*!< Constant for uart_set_pin function which indicates that UART pin should not be changed */ +/* @brief When calling `uart_set_pin`, instead of GPIO number, `UART_PIN_NO_CHANGE` + * can be provided to keep the currently allocated pin. + */ +#define UART_PIN_NO_CHANGE (-1) #define UART_FIFO_LEN SOC_UART_FIFO_LEN ///< Length of the UART HW FIFO #define UART_BITRATE_MAX SOC_UART_BITRATE_MAX ///< Maximum configurable bitrate @@ -380,14 +383,23 @@ esp_err_t uart_isr_register(uart_port_t uart_num, void (*fn)(void*), void * arg, esp_err_t uart_isr_free(uart_port_t uart_num); /** - * @brief Set UART pin number + * @brief Assign signals of a UART peripheral to GPIO pins + * + * @note If the GPIO number configured for a UART signal matches one of the + * IOMUX signals for that GPIO, the signal will be connected directly + * via the IOMUX. Otherwise the GPIO and signal will be connected via + * the GPIO Matrix. For example, if on an ESP32 the call + * `uart_set_pin(0, 1, 3, -1, -1)` is performed, as GPIO1 is UART0's + * default TX pin and GPIO3 is UART0's default RX pin, both will be + * connected to respectively U0TXD and U0RXD through the IOMUX, totally + * bypassing the GPIO matrix. + * The check is performed on a per-pin basis. Thus, it is possible to have + * RX pin binded to a GPIO through the GPIO matrix, whereas TX is binded + * to its GPIO through the IOMUX. * * @note Internal signal can be output to multiple GPIO pads. * Only one GPIO pad can connect with input signal. * - * @note Instead of GPIO number a macro 'UART_PIN_NO_CHANGE' may be provided - to keep the currently allocated pin. - * * @param uart_num UART port number, the max port number is (UART_NUM_MAX -1). * @param tx_io_num UART TX pin GPIO number. * @param rx_io_num UART RX pin GPIO number. diff --git a/tools/sdk/esp32s2/include/driver/include/esp_private/i2s_platform.h b/tools/sdk/esp32s2/include/driver/include/esp_private/i2s_platform.h new file mode 100644 index 00000000000..ff1ebdf17a6 --- /dev/null +++ b/tools/sdk/esp32s2/include/driver/include/esp_private/i2s_platform.h @@ -0,0 +1,48 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +// DO NOT USE THESE APIS IN YOUR APPLICATIONS +// The following APIs are for internal use, public to other IDF components, but not for users' applications. + +#pragma once + +#include "esp_err.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Register an I2S or I2S variant driver object to platform + * + * @note This private API is used to avoid applications from using the same I2S instance for different purpose. + * @note This function will help enable the peripheral APB clock as well. + * + * @param driver_obj Driver object + * @param port_id I2S port number + * @return + * - ESP_OK: The specific I2S port is free and register the new device object successfully + * - ESP_ERR_INVALID_ARG: Invalid argument, e.g. wrong port_id + * - ESP_ERR_NOT_FOUND: Specific I2S port is not available + */ +esp_err_t i2s_priv_register_object(void *driver_obj, int port_id); + +/** + * @brief Deregister I2S or I2S variant driver object from platform + * + * @note This function will help disable the peripheral APB clock as well. + * + * @param port_id I2S port number + * @return + * - ESP_OK: Deregister I2S port successfully (i.e. that I2S port can used used by other users after this function returns) + * - ESP_ERR_INVALID_ARG: Invalid argument, e.g. wrong port_id + * - ESP_ERR_INVALID_STATE: Specific I2S port is free already + */ +esp_err_t i2s_priv_deregister_object(int port_id); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32s2/include/efuse/esp32s2/include/esp_efuse_table.h b/tools/sdk/esp32s2/include/efuse/esp32s2/include/esp_efuse_table.h index 22dbec14b29..f2a1d9ce3fb 100644 --- a/tools/sdk/esp32s2/include/efuse/esp32s2/include/esp_efuse_table.h +++ b/tools/sdk/esp32s2/include/efuse/esp32s2/include/esp_efuse_table.h @@ -9,7 +9,7 @@ extern "C" { #endif -// md5_digest_table bc8611ed5c3a91ac0a8ba29879968d70 +// md5_digest_table 614c862c2cfa8ccda3a79183ce767255 // This file was generated from the file esp_efuse_table.csv. DO NOT CHANGE THIS FILE MANUALLY. // If you want to change some fields, you need to change esp_efuse_table.csv file // then run `efuse_common_table` or `efuse_custom_table` command it will generate this file. @@ -108,12 +108,14 @@ extern const esp_efuse_desc_t* ESP_EFUSE_SPI_PAD_CONFIG_D5[]; extern const esp_efuse_desc_t* ESP_EFUSE_SPI_PAD_CONFIG_D6[]; extern const esp_efuse_desc_t* ESP_EFUSE_SPI_PAD_CONFIG_D7[]; extern const esp_efuse_desc_t* ESP_EFUSE_WAFER_VERSION[]; -extern const esp_efuse_desc_t* ESP_EFUSE_PKG_VERSION[]; +extern const esp_efuse_desc_t* ESP_EFUSE_FLASH_VERSION[]; extern const esp_efuse_desc_t* ESP_EFUSE_BLOCK1_VERSION[]; -extern const esp_efuse_desc_t* ESP_EFUSE_SYS_DATA_PART0[]; +extern const esp_efuse_desc_t* ESP_EFUSE_PSRAM_VERSION[]; +extern const esp_efuse_desc_t* ESP_EFUSE_PKG_VERSION[]; extern const esp_efuse_desc_t* ESP_EFUSE_OPTIONAL_UNIQUE_ID[]; extern const esp_efuse_desc_t* ESP_EFUSE_BLOCK2_VERSION[]; extern const esp_efuse_desc_t* ESP_EFUSE_USER_DATA[]; +extern const esp_efuse_desc_t* ESP_EFUSE_USER_DATA_MAC_CUSTOM[]; extern const esp_efuse_desc_t* ESP_EFUSE_KEY0[]; extern const esp_efuse_desc_t* ESP_EFUSE_KEY1[]; extern const esp_efuse_desc_t* ESP_EFUSE_KEY2[]; diff --git a/tools/sdk/esp32s2/include/esp-dsp/modules/fft/include/dsps_fft2r.h b/tools/sdk/esp32s2/include/esp-dsp/modules/fft/include/dsps_fft2r.h index 01e9e03d620..da306bf13b3 100644 --- a/tools/sdk/esp32s2/include/esp-dsp/modules/fft/include/dsps_fft2r.h +++ b/tools/sdk/esp32s2/include/esp-dsp/modules/fft/include/dsps_fft2r.h @@ -72,8 +72,8 @@ esp_err_t dsps_fft2r_init_sc16(int16_t *fft_table_buff, int table_size); * * @return */ -void dsps_fft2r_deinit_fc32(); -void dsps_fft2r_deinit_sc16(); +void dsps_fft2r_deinit_fc32(void); +void dsps_fft2r_deinit_sc16(void); /**@}*/ /**@{*/ diff --git a/tools/sdk/esp32s2/include/esp-dsp/modules/fft/include/dsps_fft4r.h b/tools/sdk/esp32s2/include/esp-dsp/modules/fft/include/dsps_fft4r.h index c7d91408b04..0f87b6f0f5d 100644 --- a/tools/sdk/esp32s2/include/esp-dsp/modules/fft/include/dsps_fft4r.h +++ b/tools/sdk/esp32s2/include/esp-dsp/modules/fft/include/dsps_fft4r.h @@ -67,7 +67,7 @@ esp_err_t dsps_fft4r_init_fc32(float *fft_table_buff, int max_fft_size); * * @return */ -void dsps_fft4r_deinit_fc32(); +void dsps_fft4r_deinit_fc32(void); /**@}*/ /**@{*/ diff --git a/tools/sdk/esp32s2/include/esp-face/face_detection/include/fd_forward.h b/tools/sdk/esp32s2/include/esp-face/face_detection/include/fd_forward.h deleted file mode 100644 index 878c8c481c8..00000000000 --- a/tools/sdk/esp32s2/include/esp-face/face_detection/include/fd_forward.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * ESPRESSIF MIT License - * - * Copyright (c) 2018 - * - * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, - * it is 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. - * - */ -#pragma once - -#if __cplusplus -extern "C" -{ -#endif - -#include "image_util.h" -#include "dl_lib_matrix3d.h" -#include "mtmn.h" - - typedef enum - { - FAST = 0, /*!< fast resize type */ - NORMAL = 1, /*!< normal resize type */ - } mtmn_resize_type; - - typedef struct - { - float score; /*!< score threshold for filter candidates by score */ - float nms; /*!< nms threshold for nms process */ - int candidate_number; /*!< candidate number limitation for each net */ - } threshold_config_t; - - typedef struct - { - int w; /*!< net width */ - int h; /*!< net height */ - threshold_config_t threshold; /*!< threshold of net */ - } net_config_t; - - typedef struct - { - float min_face; /*!< The minimum size of a detectable face */ - float pyramid; /*!< The scale of the gradient scaling for the input images */ - int pyramid_times; /*!< The pyramid resizing times */ - threshold_config_t p_threshold; /*!< The thresholds for P-Net. For details, see the definition of threshold_config_t */ - threshold_config_t r_threshold; /*!< The thresholds for R-Net. For details, see the definition of threshold_config_t */ - threshold_config_t o_threshold; /*!< The thresholds for O-Net. For details, see the definition of threshold_config_t */ - mtmn_resize_type type; /*!< The image resize type. 'pyramid' will lose efficacy, when 'type'==FAST. */ - } mtmn_config_t; - - /** - * @brief Get the initial MTMN model configuration - * - * @return mtmn_config_t MTMN configuration - */ - static inline mtmn_config_t mtmn_init_config() - { - mtmn_config_t mtmn_config; - mtmn_config.type = FAST; - mtmn_config.min_face = 80; - mtmn_config.pyramid = 0.707; - mtmn_config.pyramid_times = 4; - mtmn_config.p_threshold.score = 0.6; - mtmn_config.p_threshold.nms = 0.7; - mtmn_config.p_threshold.candidate_number = 20; - mtmn_config.r_threshold.score = 0.7; - mtmn_config.r_threshold.nms = 0.7; - mtmn_config.r_threshold.candidate_number = 10; - mtmn_config.o_threshold.score = 0.7; - mtmn_config.o_threshold.nms = 0.7; - mtmn_config.o_threshold.candidate_number = 1; - - return mtmn_config; - } - - /** - * @brief Do MTMN face detection, return box and landmark infomation. - * - * @param image_matrix Image matrix, rgb888 format - * @param config Configuration of MTMN i.e. score threshold, nms threshold, candidate number threshold, pyramid, min face size - * @return box_array_t* A list of boxes and score. - */ - box_array_t *face_detect(dl_matrix3du_t *image_matrix, - mtmn_config_t *config); - -#if __cplusplus -} -#endif diff --git a/tools/sdk/esp32s2/include/esp-face/face_recognition/include/fr_flash.h b/tools/sdk/esp32s2/include/esp-face/face_recognition/include/fr_flash.h deleted file mode 100644 index 5da0ddcc182..00000000000 --- a/tools/sdk/esp32s2/include/esp-face/face_recognition/include/fr_flash.h +++ /dev/null @@ -1,82 +0,0 @@ -#pragma once - -#if __cplusplus -extern "C" -{ -#endif - -#include "fr_forward.h" - -#define FR_FLASH_TYPE 32 -#define FR_FLASH_SUBTYPE 32 -#define FR_FLASH_PARTITION_NAME "fr" -#define FR_FLASH_INFO_FLAG 12138 - - /** - * @brief Produce face id according to the input aligned face, and save it to dest_id and flash. - * - * @param l Face id list - * @param aligned_face An aligned face - * @return -2 Flash partition not found - * @return 0 Enrollment finish - * @return >=1 The left piece of aligned faces should be input - */ - int8_t enroll_face_id_to_flash(face_id_list *l, - dl_matrix3du_t *aligned_face); - - /** - * @brief Produce face id according to the input aligned face, and save the id-name pairs to dest_id and flash. - * - * @param l Face id list - * @param new_id An aligned face - * @param name name corresponding to face id - * @return -2 Flash partition not found - * @return 0 Enrollment finish - * @return >=1 The left piece of aligned faces should be input - */ - int8_t enroll_face_id_to_flash_with_name(face_id_name_list *l, - dl_matrix3d_t *new_id, - char *name); - /** - * @brief Read the enrolled face IDs from the flash. - * - * @param l Face id list - * @return int8_t The number of IDs remaining in flash - */ - int8_t read_face_id_from_flash(face_id_list *l); - - /** - * @brief Read the enrolled face IDs and their corresponding names from the flash. - * - * @param l Face id list - * @return int8_t The number of IDs remaining in flash - */ - int8_t read_face_id_from_flash_with_name(face_id_name_list *l); - - /** - * @brief Delete the enrolled face IDs in the flash. - * - * @param l Face id list - * @return int8_t The number of IDs remaining in flash - */ - int8_t delete_face_id_in_flash(face_id_list *l); - - /** - * @brief Delete the enrolled face ID corresponding to the name in the flash. - * - * @param l Face id list - * @param name The name that needs to be deleted - * @return int8_t The number of IDs remaining in flash - */ - int8_t delete_face_id_in_flash_with_name(face_id_name_list *l, char *name); - - /** - * @brief Delete all the enrolled face IDs and names paris in the flash. - * - * @param l Face id list - */ - void delete_face_all_in_flash_with_name(face_id_name_list *l); - -#if __cplusplus -} -#endif diff --git a/tools/sdk/esp32s2/include/esp-face/face_recognition/include/fr_forward.h b/tools/sdk/esp32s2/include/esp-face/face_recognition/include/fr_forward.h deleted file mode 100644 index 32c55168eb6..00000000000 --- a/tools/sdk/esp32s2/include/esp-face/face_recognition/include/fr_forward.h +++ /dev/null @@ -1,194 +0,0 @@ -#pragma once - -#if __cplusplus -extern "C" -{ -#endif - -#include "image_util.h" -#include "dl_lib_matrix3d.h" -#include "frmn.h" - -#define FACE_WIDTH 56 -#define FACE_HEIGHT 56 -#define FACE_ID_SIZE 512 -#define FACE_REC_THRESHOLD 0.55 - -#define LEFT_EYE_X 0 -#define LEFT_EYE_Y 1 -#define RIGHT_EYE_X 6 -#define RIGHT_EYE_Y 7 -#define NOSE_X 4 -#define NOSE_Y 5 -#define LEFT_MOUTH_X 2 -#define LEFT_MOUTH_Y 3 -#define RIGHT_MOUTH_X 8 -#define RIGHT_MOUTH_Y 9 - -#define EYE_DIST_SET 16.5f -#define NOSE_EYE_RATIO_THRES_MIN 0.49f -#define NOSE_EYE_RATIO_THRES_MAX 2.04f - - -#define ENROLL_NAME_LEN 16 - typedef struct tag_face_id_node - { - struct tag_face_id_node *next; /*!< next face id node */ - char id_name[ENROLL_NAME_LEN]; /*!< name corresponding to the face id */ - dl_matrix3d_t *id_vec; /*!< face id */ - } face_id_node; - - typedef struct - { - face_id_node *head; /*!< head pointer of the id list */ - face_id_node *tail; /*!< tail pointer of the id list */ - uint8_t count; /*!< number of enrolled ids */ - uint8_t confirm_times; /*!< images needed for one enrolling */ - } face_id_name_list; - - typedef struct - { - uint8_t head; /*!< head index of the id list */ - uint8_t tail; /*!< tail index of the id list */ - uint8_t count; /*!< number of enrolled ids */ - uint8_t size; /*!< max len of id list */ - uint8_t confirm_times; /*!< images needed for one enrolling */ - dl_matrix3d_t **id_list; /*!< stores face id vectors */ - } face_id_list; - - /** - * @brief Initialize face id list. - * - * @param l Face id list - * @param size Size of list, one list contains one vector - * @param confirm_times Enroll times for one id - */ - void face_id_init(face_id_list *l, uint8_t size, uint8_t confirm_times); - - /** - * @brief Initialize face id list with name. - * - * @param l Face id list - * @param size Size of list, one list contains one vector - * @param confirm_times Enroll times for one id - */ - void face_id_name_init(face_id_name_list *l, uint8_t size, uint8_t confirm_times); - - /** - * @brief Alloc memory for aligned face. - * - * @return dl_matrix3du_t* Size: 1xFACE_WIDTHxFACE_HEIGHTx3 - */ - dl_matrix3du_t *aligned_face_alloc(); - - /**@{*/ - /** - * @brief Align detected face to average face according to landmark. - * - * @param onet_boxes Output of MTMN with box and landmark - * @param src Image matrix, rgb888 format - * @param dest Output image - * @return ESP_OK Input face is good for recognition - * @return ESP_FAIL Input face is not good for recognition - */ - int8_t align_face_rot(box_array_t *onet_boxes, - dl_matrix3du_t *src, - dl_matrix3du_t *dest); - - int8_t align_face_sim(box_array_t *onet_boxes, - dl_matrix3du_t *src, - dl_matrix3du_t *dest); - - inline int8_t align_face(box_array_t *onet_boxes, - dl_matrix3du_t *src, - dl_matrix3du_t *dest) - { - return align_face_sim(onet_boxes, src, dest); - } - /**@}*/ - - /** - * @brief Run the face recognition model to get the face feature - * - * @param aligned_face A 56x56x3 image, the variable need to do align_face first - * @return face_id A 512 vector, size (1, 1, 1, 512) - */ - dl_matrix3d_t *get_face_id(dl_matrix3du_t *aligned_face); - - /** - * @brief Add src_id to dest_id - * - * @param dest_id Face id after accumulation - * @param src_id Face id to be added - */ - void add_face_id(dl_matrix3d_t *dest_id, - dl_matrix3d_t *src_id); - - /** - * @brief Match face with the id_list, and return matched_id. - * - * @param l An ID list - * @param algined_face An aligned face - * @return int8_t Matched face id - */ - int8_t recognize_face(face_id_list *l, dl_matrix3du_t *algined_face); - - /** - * @brief Match face id with the id_list, and return matched face id node. - * - * @param l - * @param face_id - * @return face_id_node* - */ - face_id_node *recognize_face_with_name(face_id_name_list *l, dl_matrix3d_t *face_id); - - /** - * @brief Produce face id according to the input aligned face, and save it to dest_id. - * - * @param l Face id list - * @param aligned_face An aligned face - * @param enroll_confirm_times Confirm times for each face id enrollment - * @return -1 Wrong input enroll_confirm_times - * @return 0 Enrollment finish - * @return >=1 The left piece of aligned faces should be input - */ - int8_t enroll_face(face_id_list *l, dl_matrix3du_t *aligned_face); - - /** - * @brief Produce face id according to the input aligned face, and save the id-name pairs to dest_id - * - * @param l Face id list with name - * @param new_id A face id that need to be enrolled - * @param name name corresponding to the face id - * @return int8_t The left piece of aligned faces should be input - */ - int8_t enroll_face_with_name(face_id_name_list *l, - dl_matrix3d_t *new_id, - char *name); - - /** - * @brief Delete the enrolled face IDs - * - * @param l Face id list - * @return uint8_t The number of IDs remaining in face id list - */ - uint8_t delete_face(face_id_list *l); - - /** - * @brief Delete the enrolled face IDs and associated names - * - * @param l Face id list - * @param name The name that needs to be deleted - * @return int8_t The number of IDs remaining in face id list - */ - int8_t delete_face_with_name(face_id_name_list *l, char *name); - - /** - * @brief Delete all the enrolled face IDs and names paris - * - * @param l Face id list with names - */ - void delete_face_all_with_name(face_id_name_list *l); -#if __cplusplus -} -#endif diff --git a/tools/sdk/esp32s2/include/esp-face/image_util/include/esp_image.hpp b/tools/sdk/esp32s2/include/esp-face/image_util/include/esp_image.hpp deleted file mode 100644 index f5f924d6b6a..00000000000 --- a/tools/sdk/esp32s2/include/esp-face/image_util/include/esp_image.hpp +++ /dev/null @@ -1,344 +0,0 @@ -/* - * ESPRESSIF MIT License - * - * Copyright (c) 2018 - * - * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, - * it is 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. - * - */ -#pragma once - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -#include -#include - -#ifdef __cplusplus -} -#endif - -typedef enum -{ - IMAGE_RESIZE_BILINEAR = 0, /* -class Image -{ -public: - /** - * @brief Convert a RGB565 pixel to RGB888 - * - * @param input Pixel value in RGB565 - * @param output Pixel value in RGB888 - */ - static inline void pixel_rgb565_to_rgb888(uint16_t input, T *output) - { - output[2] = (input & 0x1F00) >> 5; //blue - output[1] = ((input & 0x7) << 5) | ((input & 0xE000) >> 11); //green - output[0] = input & 0xF8; //red - }; - - /** - * @brief Resize a RGB565 image to a RGB88 image - * - * @param dst_image The destination image - * @param y_start The start y index of where resized image located - * @param y_end The end y index of where resized image located - * @param x_start The start x index of where resized image located - * @param x_end The end x index of where resized image located - * @param channel The channel number of image - * @param src_image The source image - * @param src_h The height of source image - * @param src_w The width of source image - * @param dst_w The width of destination image - * @param shift_left The bit number of left shifting - * @param type The resize type - */ - static void resize_to_rgb888(T *dst_image, int y_start, int y_end, int x_start, int x_end, int channel, uint16_t *src_image, int src_h, int src_w, int dst_w, int shift_left, image_resize_t type); - - /** - * @brief Resize a RGB888 image to a RGB88 image - * - * @param dst_image The destination image - * @param y_start The start y index of where resized image located - * @param y_end The end y index of where resized image located - * @param x_start The start x index of where resized image located - * @param x_end The end x index of where resized image located - * @param channel The channel number of image - * @param src_image The source image - * @param src_h The height of source image - * @param src_w The width of source image - * @param dst_w The width of destination image - * @param shift_left The bit number of left shifting - * @param type The resize type - */ - static void resize_to_rgb888(T *dst_image, int y_start, int y_end, int x_start, int x_end, int channel, uint8_t *src_image, int src_h, int src_w, int dst_w, int shift_left, image_resize_t type); - // static void resize_to_rgb565(uint16_t *dst_image, int y_start, int y_end, int x_start, int x_end, int channel, uint16_t *src_image, int src_h, int src_w, int dst_w, int shift_left, image_resize_t type); - // static void resize_to_rgb565(uint16_t *dst_image, int y_start, int y_end, int x_start, int x_end, int channel, uint8_t *src_image, int src_h, int src_w, int dst_w, int shift_left, image_resize_t type); -}; - -template -void Image::resize_to_rgb888(T *dst_image, int y_start, int y_end, int x_start, int x_end, int channel, uint16_t *src_image, int src_h, int src_w, int dst_w, int shift_left, image_resize_t type) -{ - assert(channel == 3); - float scale_y = (float)src_h / (y_end - y_start); - float scale_x = (float)src_w / (x_end - x_start); - int temp[13]; - - switch (type) - { - case IMAGE_RESIZE_BILINEAR: - for (size_t y = y_start; y < y_end; y++) - { - float ratio_y[2]; - ratio_y[0] = (float)((y + 0.5) * scale_y - 0.5); // y - int src_y = (int)ratio_y[0]; // y1 - ratio_y[0] -= src_y; // y - y1 - - if (src_y < 0) - { - ratio_y[0] = 0; - src_y = 0; - } - if (src_y > src_h - 2) - { - ratio_y[0] = 0; - src_y = src_h - 2; - } - ratio_y[1] = 1 - ratio_y[0]; // y2 - y - - int _dst_i = y * dst_w; - - int _src_row_0 = src_y * src_w; - int _src_row_1 = _src_row_0 + src_w; - - for (size_t x = x_start; x < x_end; x++) - { - float ratio_x[2]; - ratio_x[0] = (float)((x + 0.5) * scale_x - 0.5); // x - int src_x = (int)ratio_x[0]; // x1 - ratio_x[0] -= src_x; // x - x1 - - if (src_x < 0) - { - ratio_x[0] = 0; - src_x = 0; - } - if (src_x > src_w - 2) - { - ratio_x[0] = 0; - src_x = src_w - 2; - } - ratio_x[1] = 1 - ratio_x[0]; // x2 - x - - int dst_i = (_dst_i + x) * channel; - - int src_row_0 = _src_row_0 + src_x; - int src_row_1 = _src_row_1 + src_x; - - Image::pixel_rgb565_to_rgb888(src_image[src_row_0], temp); - Image::pixel_rgb565_to_rgb888(src_image[src_row_0 + 1], temp + 3); - Image::pixel_rgb565_to_rgb888(src_image[src_row_1], temp + 6); - Image::pixel_rgb565_to_rgb888(src_image[src_row_1 + 1], temp + 9); - - for (int c = 0; c < channel; c++) - { - temp[12] = round(temp[c] * ratio_x[1] * ratio_y[1] + temp[channel + c] * ratio_x[0] * ratio_y[1] + temp[channel + channel + c] * ratio_x[1] * ratio_y[0] + src_image[channel + channel + channel + c] * ratio_x[0] * ratio_y[0]); - dst_image[dst_i + c] = (shift_left > 0) ? (temp[12] << shift_left) : (temp[12] >> -shift_left); - } - } - } - break; - - case IMAGE_RESIZE_MEAN: - shift_left -= 2; - for (int y = y_start; y < y_end; y++) - { - int _dst_i = y * dst_w; - - float _src_row_0 = rintf(y * scale_y) * src_w; - float _src_row_1 = _src_row_0 + src_w; - - for (int x = x_start; x < x_end; x++) - { - int dst_i = (_dst_i + x) * channel; - - int src_row_0 = (_src_row_0 + rintf(x * scale_x)); - int src_row_1 = (_src_row_1 + rintf(x * scale_x)); - - Image::pixel_rgb565_to_rgb888(src_image[src_row_0], temp); - Image::pixel_rgb565_to_rgb888(src_image[src_row_0 + 1], temp + 3); - Image::pixel_rgb565_to_rgb888(src_image[src_row_1], temp + 6); - Image::pixel_rgb565_to_rgb888(src_image[src_row_1 + 1], temp + 9); - - dst_image[dst_i] = (shift_left > 0) ? ((temp[0] + temp[3] + temp[6] + temp[9]) << shift_left) : ((temp[0] + temp[3] + temp[6] + temp[9]) >> -shift_left); - dst_image[dst_i + 1] = (shift_left > 0) ? ((temp[1] + temp[4] + temp[7] + temp[10]) << shift_left) : ((temp[1] + temp[4] + temp[7] + temp[10]) >> -shift_left); - dst_image[dst_i + 2] = (shift_left > 0) ? ((temp[2] + temp[5] + temp[8] + temp[11]) << shift_left) : ((temp[1] + temp[4] + temp[7] + temp[10]) >> -shift_left); - } - } - - break; - - case IMAGE_RESIZE_NEAREST: - for (size_t y = y_start; y < y_end; y++) - { - int _dst_i = y * dst_w; - float _src_i = rintf(y * scale_y) * src_w; - - for (size_t x = x_start; x < x_end; x++) - { - int dst_i = (_dst_i + x) * channel; - int src_i = _src_i + rintf(x * scale_x); - - Image::pixel_rgb565_to_rgb888(src_image[src_i], temp); - - dst_image[dst_i] = (shift_left > 0) ? (temp[0] << shift_left) : (temp[0] >> -shift_left); - dst_image[dst_i + 1] = (shift_left > 0) ? (temp[1] << shift_left) : (temp[1] >> -shift_left); - dst_image[dst_i + 2] = (shift_left > 0) ? (temp[2] << shift_left) : (temp[2] >> -shift_left); - } - } - break; - - default: - break; - } -} - -template -void Image::resize_to_rgb888(T *dst_image, int y_start, int y_end, int x_start, int x_end, int channel, uint8_t *src_image, int src_h, int src_w, int dst_w, int shift_left, image_resize_t type) -{ - float scale_y = (float)src_h / (y_end - y_start); - float scale_x = (float)src_w / (x_end - x_start); - int temp; - - switch (type) - { - case IMAGE_RESIZE_BILINEAR: - for (size_t y = y_start; y < y_end; y++) - { - float ratio_y[2]; - ratio_y[0] = (float)((y + 0.5) * scale_y - 0.5); // y - int src_y = (int)ratio_y[0]; // y1 - ratio_y[0] -= src_y; // y - y1 - - if (src_y < 0) - { - ratio_y[0] = 0; - src_y = 0; - } - if (src_y > src_h - 2) - { - ratio_y[0] = 0; - src_y = src_h - 2; - } - ratio_y[1] = 1 - ratio_y[0]; // y2 - y - - int _dst_i = y * dst_w; - - int _src_row_0 = src_y * src_w; - int _src_row_1 = _src_row_0 + src_w; - - for (size_t x = x_start; x < x_end; x++) - { - float ratio_x[2]; - ratio_x[0] = (float)((x + 0.5) * scale_x - 0.5); // x - int src_x = (int)ratio_x[0]; // x1 - ratio_x[0] -= src_x; // x - x1 - - if (src_x < 0) - { - ratio_x[0] = 0; - src_x = 0; - } - if (src_x > src_w - 2) - { - ratio_x[0] = 0; - src_x = src_w - 2; - } - ratio_x[1] = 1 - ratio_x[0]; // x2 - x - - int dst_i = (_dst_i + x) * channel; - - int src_row_0 = (_src_row_0 + src_x) * channel; - int src_row_1 = (_src_row_1 + src_x) * channel; - - for (int c = 0; c < channel; c++) - { - temp = round(src_image[src_row_0 + c] * ratio_x[1] * ratio_y[1] + src_image[src_row_0 + channel + c] * ratio_x[0] * ratio_y[1] + src_image[src_row_1 + c] * ratio_x[1] * ratio_y[0] + src_image[src_row_1 + channel + c] * ratio_x[0] * ratio_y[0]); - dst_image[dst_i + c] = (shift_left > 0) ? (temp << shift_left) : (temp >> -shift_left); - } - } - } - break; - - case IMAGE_RESIZE_MEAN: - shift_left -= 2; - - for (size_t y = y_start; y < y_end; y++) - { - int _dst_i = y * dst_w; - - float _src_row_0 = rintf(y * scale_y) * src_w; - float _src_row_1 = _src_row_0 + src_w; - - for (size_t x = x_start; x < x_end; x++) - { - int dst_i = (_dst_i + x) * channel; - - int src_row_0 = (_src_row_0 + rintf(x * scale_x)) * channel; - int src_row_1 = (_src_row_1 + rintf(x * scale_x)) * channel; - - for (size_t c = 0; c < channel; c++) - { - temp = (int)src_image[src_row_0 + c] + (int)src_image[src_row_0 + channel + c] + (int)src_image[src_row_1 + c] + (int)src_image[src_row_1 + channel + c]; - dst_image[dst_i + c] = (shift_left > 0) ? (temp << shift_left) : (temp >> -shift_left); - } - } - } - break; - - case IMAGE_RESIZE_NEAREST: - for (size_t y = y_start; y < y_end; y++) - { - int _dst_i = y * dst_w; - float _src_i = rintf(y * scale_y) * src_w; - - for (size_t x = x_start; x < x_end; x++) - { - int dst_i = (_dst_i + x) * channel; - int src_i = (_src_i + rintf(x * scale_x)) * channel; - - for (size_t c = 0; c < channel; c++) - { - dst_image[dst_i + c] = (shift_left > 0) ? ((T)src_image[src_i + c] << shift_left) : ((T)src_image[src_i + c] >> -shift_left); - } - } - } - break; - - default: - break; - } -} \ No newline at end of file diff --git a/tools/sdk/esp32s2/include/esp-face/image_util/include/image_util.h b/tools/sdk/esp32s2/include/esp-face/image_util/include/image_util.h deleted file mode 100644 index f997b34154b..00000000000 --- a/tools/sdk/esp32s2/include/esp-face/image_util/include/image_util.h +++ /dev/null @@ -1,548 +0,0 @@ -/* - * ESPRESSIF MIT License - * - * Copyright (c) 2018 - * - * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, - * it is 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. - * - */ -#pragma once -#ifdef __cplusplus -extern "C" -{ -#endif -#include -#include -#include "mtmn.h" - -#define LANDMARKS_NUM (10) - -#define MAX_VALID_COUNT_PER_IMAGE (30) - -#define DL_IMAGE_MIN(A, B) ((A) < (B) ? (A) : (B)) -#define DL_IMAGE_MAX(A, B) ((A) < (B) ? (B) : (A)) - -#define RGB565_MASK_RED 0xF800 -#define RGB565_MASK_GREEN 0x07E0 -#define RGB565_MASK_BLUE 0x001F - - typedef enum - { - BINARY, /*!< binary */ - } en_threshold_mode; - - typedef struct - { - fptp_t landmark_p[LANDMARKS_NUM]; /*!< landmark struct */ - } landmark_t; - - typedef struct - { - fptp_t box_p[4]; /*!< box struct */ - } box_t; - - typedef struct tag_box_list - { - uint8_t *category; /*!< The category of the corresponding box */ - fptp_t *score; /*!< The confidence score of the class corresponding to the box */ - box_t *box; /*!< Anchor boxes or predicted boxes*/ - landmark_t *landmark; /*!< The landmarks corresponding to the box */ - int len; /*!< The num of the boxes */ - } box_array_t; - - typedef struct tag_image_box - { - struct tag_image_box *next; /*!< Next image_box_t */ - uint8_t category; - fptp_t score; /*!< The confidence score of the class corresponding to the box */ - box_t box; /*!< Anchor boxes or predicted boxes */ - box_t offset; /*!< The predicted anchor-based offset */ - landmark_t landmark; /*!< The landmarks corresponding to the box */ - } image_box_t; - - typedef struct tag_image_list - { - image_box_t *head; /*!< The current head of the image_list */ - image_box_t *origin_head; /*!< The original head of the image_list */ - int len; /*!< Length of the image_list */ - } image_list_t; - - /** - * @brief Get the width and height of the box. - * - * @param box Input box - * @param w Resulting width of the box - * @param h Resulting height of the box - */ - static inline void image_get_width_and_height(box_t *box, float *w, float *h) - { - *w = box->box_p[2] - box->box_p[0] + 1; - *h = box->box_p[3] - box->box_p[1] + 1; - } - - /** - * @brief Get the area of the box. - * - * @param box Input box - * @param area Resulting area of the box - */ - static inline void image_get_area(box_t *box, float *area) - { - float w, h; - image_get_width_and_height(box, &w, &h); - *area = w * h; - } - - /** - * @brief calibrate the boxes by offset - * - * @param image_list Input boxes - * @param image_height Height of the original image - * @param image_width Width of the original image - */ - static inline void image_calibrate_by_offset(image_list_t *image_list, int image_height, int image_width) - { - for (image_box_t *head = image_list->head; head; head = head->next) - { - float w, h; - image_get_width_and_height(&(head->box), &w, &h); - head->box.box_p[0] = DL_IMAGE_MAX(0, head->box.box_p[0] + head->offset.box_p[0] * w); - head->box.box_p[1] = DL_IMAGE_MAX(0, head->box.box_p[1] + head->offset.box_p[1] * w); - head->box.box_p[2] += head->offset.box_p[2] * w; - if (head->box.box_p[2] > image_width) - { - head->box.box_p[2] = image_width - 1; - head->box.box_p[0] = image_width - w; - } - head->box.box_p[3] += head->offset.box_p[3] * h; - if (head->box.box_p[3] > image_height) - { - head->box.box_p[3] = image_height - 1; - head->box.box_p[1] = image_height - h; - } - } - } - - /** - * @brief calibrate the landmarks - * - * @param image_list Input landmarks - */ - static inline void image_landmark_calibrate(image_list_t *image_list) - { - for (image_box_t *head = image_list->head; head; head = head->next) - { - float w, h; - image_get_width_and_height(&(head->box), &w, &h); - head->landmark.landmark_p[0] = head->box.box_p[0] + head->landmark.landmark_p[0] * w; - head->landmark.landmark_p[1] = head->box.box_p[1] + head->landmark.landmark_p[1] * h; - - head->landmark.landmark_p[2] = head->box.box_p[0] + head->landmark.landmark_p[2] * w; - head->landmark.landmark_p[3] = head->box.box_p[1] + head->landmark.landmark_p[3] * h; - - head->landmark.landmark_p[4] = head->box.box_p[0] + head->landmark.landmark_p[4] * w; - head->landmark.landmark_p[5] = head->box.box_p[1] + head->landmark.landmark_p[5] * h; - - head->landmark.landmark_p[6] = head->box.box_p[0] + head->landmark.landmark_p[6] * w; - head->landmark.landmark_p[7] = head->box.box_p[1] + head->landmark.landmark_p[7] * h; - - head->landmark.landmark_p[8] = head->box.box_p[0] + head->landmark.landmark_p[8] * w; - head->landmark.landmark_p[9] = head->box.box_p[1] + head->landmark.landmark_p[9] * h; - } - } - - /** - * @brief Convert a rectangular box into a square box - * - * @param boxes Input box - * @param width Width of the orignal image - * @param height height of the orignal image - */ - static inline void image_rect2sqr(box_array_t *boxes, int width, int height) - { - for (int i = 0; i < boxes->len; i++) - { - box_t *box = &(boxes->box[i]); - - int x1 = round(box->box_p[0]); - int y1 = round(box->box_p[1]); - int x2 = round(box->box_p[2]); - int y2 = round(box->box_p[3]); - - int w = x2 - x1 + 1; - int h = y2 - y1 + 1; - int l = DL_IMAGE_MAX(w, h); - - box->box_p[0] = DL_IMAGE_MAX(round(DL_IMAGE_MAX(0, x1) + 0.5 * (w - l)), 0); - box->box_p[1] = DL_IMAGE_MAX(round(DL_IMAGE_MAX(0, y1) + 0.5 * (h - l)), 0); - - box->box_p[2] = box->box_p[0] + l - 1; - if (box->box_p[2] > width) - { - box->box_p[2] = width - 1; - box->box_p[0] = width - l; - } - box->box_p[3] = box->box_p[1] + l - 1; - if (box->box_p[3] > height) - { - box->box_p[3] = height - 1; - box->box_p[1] = height - l; - } - } - } - - /**@{*/ - /** - * @brief Convert RGB565 image to RGB888 image - * - * @param in Input RGB565 image - * @param dst Resulting RGB888 image - */ - static inline void rgb565_to_888(uint16_t in, uint8_t *dst) - { /*{{{*/ - in = (in & 0xFF) << 8 | (in & 0xFF00) >> 8; - dst[2] = (in & RGB565_MASK_BLUE) << 3; // blue - dst[1] = (in & RGB565_MASK_GREEN) >> 3; // green - dst[0] = (in & RGB565_MASK_RED) >> 8; // red - - // dst[0] = (in & 0x1F00) >> 5; - // dst[1] = ((in & 0x7) << 5) | ((in & 0xE000) >> 11); - // dst[2] = in & 0xF8; - } /*}}}*/ - - static inline void rgb565_to_888_q16(uint16_t in, int16_t *dst) - { /*{{{*/ - in = (in & 0xFF) << 8 | (in & 0xFF00) >> 8; - dst[2] = (in & RGB565_MASK_BLUE) << 3; // blue - dst[1] = (in & RGB565_MASK_GREEN) >> 3; // green - dst[0] = (in & RGB565_MASK_RED) >> 8; // red - - // dst[0] = (in & 0x1F00) >> 5; - // dst[1] = ((in & 0x7) << 5) | ((in & 0xE000) >> 11); - // dst[2] = in & 0xF8; - } /*}}}*/ - /**@}*/ - - /** - * @brief Convert RGB888 image to RGB565 image - * - * @param in Resulting RGB565 image - * @param r The red channel of the Input RGB888 image - * @param g The green channel of the Input RGB888 image - * @param b The blue channel of the Input RGB888 image - */ - static inline void rgb888_to_565(uint16_t *in, uint8_t r, uint8_t g, uint8_t b) - { /*{{{*/ - uint16_t rgb565 = 0; - rgb565 = ((r >> 3) << 11); - rgb565 |= ((g >> 2) << 5); - rgb565 |= (b >> 3); - rgb565 = (rgb565 & 0xFF) << 8 | (rgb565 & 0xFF00) >> 8; - *in = rgb565; - } /*}}}*/ - - /** - * @brief Filter out the resulting boxes whose confidence score is lower than the threshold and convert the boxes to the actual boxes on the original image.((x, y, w, h) -> (x1, y1, x2, y2)) - * - * @param score Confidence score of the boxes - * @param offset The predicted anchor-based offset - * @param landmark The landmarks corresponding to the box - * @param width Height of the original image - * @param height Width of the original image - * @param anchor_number Anchor number of the detection output feature map - * @param anchors_size The anchor size - * @param score_threshold Threshold of the confidence score - * @param stride - * @param resized_height_scale - * @param resized_width_scale - * @param do_regression - * @return image_list_t* - */ - image_list_t *image_get_valid_boxes(fptp_t *score, - fptp_t *offset, - fptp_t *landmark, - int width, - int height, - int anchor_number, - int *anchors_size, - fptp_t score_threshold, - int stride, - fptp_t resized_height_scale, - fptp_t resized_width_scale, - bool do_regression); - /** - * @brief Sort the resulting box lists by their confidence score. - * - * @param image_sorted_list The sorted box list. - * @param insert_list The box list that have not been sorted. - */ - void image_sort_insert_by_score(image_list_t *image_sorted_list, const image_list_t *insert_list); - - /** - * @brief Run NMS algorithm - * - * @param image_list The input boxes list - * @param nms_threshold NMS threshold - * @param same_area The flag of boxes with same area - */ - void image_nms_process(image_list_t *image_list, fptp_t nms_threshold, int same_area); - - /** - * @brief Resize an image to half size - * - * @param dimage The output image - * @param dw Width of the output image - * @param dh Height of the output image - * @param dc Channel of the output image - * @param simage Source image - * @param sw Width of the source image - * @param sc Channel of the source image - */ - void image_zoom_in_twice(uint8_t *dimage, - int dw, - int dh, - int dc, - uint8_t *simage, - int sw, - int sc); - - /** - * @brief Resize the image in RGB888 format via bilinear interpolation - * - * @param dst_image The output image - * @param src_image Source image - * @param dst_w Width of the output image - * @param dst_h Height of the output image - * @param dst_c Channel of the output image - * @param src_w Width of the source image - * @param src_h Height of the source image - */ - void image_resize_linear(uint8_t *dst_image, uint8_t *src_image, int dst_w, int dst_h, int dst_c, int src_w, int src_h); - - /** - * @brief Crop, rotate and zoom the image in RGB888 format, - * - * @param corp_image The output image - * @param src_image Source image - * @param rotate_angle Rotate angle - * @param ratio scaling ratio - * @param center Center of rotation - */ - void image_cropper(uint8_t *corp_image, uint8_t *src_image, int dst_w, int dst_h, int dst_c, int src_w, int src_h, float rotate_angle, float ratio, float *center); - - /** - * @brief Convert the rgb565 image to the rgb888 image - * - * @param m The output rgb888 image - * @param bmp The input rgb565 image - * @param count Total pixels of the rgb565 image - */ - void image_rgb565_to_888(uint8_t *m, uint16_t *bmp, int count); - - /** - * @brief Convert the rgb888 image to the rgb565 image - * - * @param bmp The output rgb565 image - * @param m The input rgb888 image - * @param count Total pixels of the rgb565 image - */ - void image_rgb888_to_565(uint16_t *bmp, uint8_t *m, int count); - - /** - * @brief draw rectangle on the rgb565 image - * - * @param buf Input image - * @param boxes Rectangle Boxes - * @param width Width of the input image - */ - void draw_rectangle_rgb565(uint16_t *buf, box_array_t *boxes, int width); - - /** - * @brief draw rectangle on the rgb888 image - * - * @param buf Input image - * @param boxes Rectangle Boxes - * @param width Width of the input image - */ - void draw_rectangle_rgb888(uint8_t *buf, box_array_t *boxes, int width); - - /** - * @brief Get the pixel difference of two images - * - * @param dst The output pixel difference - * @param src1 Input image 1 - * @param src2 Input image 2 - * @param count Total pixels of the input image - */ - void image_abs_diff(uint8_t *dst, uint8_t *src1, uint8_t *src2, int count); - - /** - * @brief Binarize an image to 0 and value. - * - * @param dst The output image - * @param src Source image - * @param threshold Threshold of binarization - * @param value The value of binarization - * @param count Total pixels of the input image - * @param mode Threshold mode - */ - void image_threshold(uint8_t *dst, uint8_t *src, int threshold, int value, int count, en_threshold_mode mode); - - /** - * @brief Erode the image - * - * @param dst The output image - * @param src Source image - * @param src_w Width of the source image - * @param src_h Height of the source image - * @param src_c Channel of the source image - */ - void image_erode(uint8_t *dst, uint8_t *src, int src_w, int src_h, int src_c); - - typedef float matrixType; - typedef struct - { - int w; /*!< width */ - int h; /*!< height */ - matrixType **array; /*!< array */ - } Matrix; - - /** - * @brief Allocate a 2d matrix - * - * @param h Height of matrix - * @param w Width of matrix - * @return Matrix* 2d matrix - */ - Matrix *matrix_alloc(int h, int w); - - /** - * @brief Free a 2d matrix - * - * @param m 2d matrix - */ - void matrix_free(Matrix *m); - - /** - * @brief Get the similarity matrix of similarity transformation - * - * @param srcx Source x coordinates - * @param srcy Source y coordinates - * @param dstx Destination x coordinates - * @param dsty Destination y coordinates - * @param num The number of the coordinates - * @return Matrix* The resulting transformation matrix - */ - Matrix *get_similarity_matrix(float *srcx, float *srcy, float *dstx, float *dsty, int num); - - /** - * @brief Get the affine transformation matrix - * - * @param srcx Source x coordinates - * @param srcy Source y coordinates - * @param dstx Destination x coordinates - * @param dsty Destination y coordinates - * @return Matrix* The resulting transformation matrix - */ - Matrix *get_affine_transform(float *srcx, float *srcy, float *dstx, float *dsty); - - /** - * @brief Applies an affine transformation to an image - * - * @param img Input image - * @param crop Dst output image that has the size dsize and the same type as src - * @param M Affine transformation matrix - */ - void warp_affine(dl_matrix3du_t *img, dl_matrix3du_t *crop, Matrix *M); - - /** - * @brief Resize the image in RGB888 format via bilinear interpolation, and quantify the output image - * - * @param dst_image Quantized output image - * @param src_image Input image - * @param dst_w Width of the output image - * @param dst_h Height of the output image - * @param dst_c Channel of the output image - * @param src_w Width of the input image - * @param src_h Height of the input image - * @param shift Shift parameter of quantization. - */ - void image_resize_linear_q(qtp_t *dst_image, uint8_t *src_image, int dst_w, int dst_h, int dst_c, int src_w, int src_h, int shift); - - /** - * @brief Preprocess the input image of object detection model. The process is like this: resize -> normalize -> quantify - * - * @param image Input image, RGB888 format. - * @param input_w Width of the input image. - * @param input_h Height of the input image. - * @param target_size Target size of the model input image. - * @param exponent Exponent of the quantized model input image. - * @param process_mode Process mode. 0: resize with padding to keep height == width. 1: resize without padding, height != width. - * @return dl_matrix3dq_t* The resulting preprocessed image. - */ - dl_matrix3dq_t *image_resize_normalize_quantize(uint8_t *image, int input_w, int input_h, int target_size, int exponent, int process_mode); - - /** - * @brief Resize the image in RGB565 format via mean neighbour interpolation, and quantify the output image - * - * @param dimage Quantized output image. - * @param simage Input image. - * @param dw Width of the allocated output image memory. - * @param dc Channel of the allocated output image memory. - * @param sw Width of the input image. - * @param sh Height of the input image. - * @param tw Target width of the output image. - * @param th Target height of the output image. - * @param shift Shift parameter of quantization. - */ - void image_resize_shift_fast(qtp_t *dimage, uint16_t *simage, int dw, int dc, int sw, int sh, int tw, int th, int shift); - - /** - * @brief Resize the image in RGB565 format via nearest neighbour interpolation, and quantify the output image - * - * @param dimage Quantized output image. - * @param simage Input image. - * @param dw Width of the allocated output image memory. - * @param dc Channel of the allocated output image memory. - * @param sw Width of the input image. - * @param sh Height of the input image. - * @param tw Target width of the output image. - * @param th Target height of the output image. - * @param shift Shift parameter of quantization. - */ - void image_resize_nearest_shift(qtp_t *dimage, uint16_t *simage, int dw, int dc, int sw, int sh, int tw, int th, int shift); - - /** - * @brief Crop the image in RGB565 format and resize it to target size, then quantify the output image - * - * @param dimage Quantized output image. - * @param simage Input image. - * @param dw Target size of the output image. - * @param sw Width of the input image. - * @param sh Height of the input image. - * @param x1 The x coordinate of the upper left corner of the cropped area - * @param y1 The y coordinate of the upper left corner of the cropped area - * @param x2 The x coordinate of the lower right corner of the cropped area - * @param y2 The y coordinate of the lower right corner of the cropped area - * @param shift Shift parameter of quantization. - */ - void image_crop_shift_fast(qtp_t *dimage, uint16_t *simage, int dw, int sw, int sh, int x1, int y1, int x2, int y2, int shift); - -#ifdef __cplusplus -} -#endif diff --git a/tools/sdk/esp32s2/include/esp-face/include/detect/dl_detect_define.hpp b/tools/sdk/esp32s2/include/esp-face/include/detect/dl_detect_define.hpp new file mode 100644 index 00000000000..cc53050cb9b --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/detect/dl_detect_define.hpp @@ -0,0 +1,17 @@ +#pragma once + +#include + +namespace dl +{ + namespace detect + { + typedef struct + { + int category; /* box; /* keypoint; /* +#include "sdkconfig.h" + +#define DL_LOG_LATENCY_UNIT 0 /* (high)) ? (high) : (x)) +#endif + +#ifndef DL_ABS +#define DL_ABS(x) ((x) < 0 ? (-(x)) : (x)) +#endif + +#ifndef DL_RIGHT_SHIFT +#define DL_RIGHT_SHIFT(x, shift) ((shift) > 0) ? ((x) >> (shift)) : ((x) << -(shift)) +#endif + +#ifndef DL_LEFT_SHIFT +#define DL_LEFT_SHIFT(x, shift) ((shift) > 0) ? ((x) << (shift)) : ((x) >> -(shift)) +#endif + +namespace dl +{ + typedef enum + { + Linear, /**/ + ReLU, /**/ + LeakyReLU, /**/ + PReLU, /**/ + // TODO: Sigmoid, /**/ + // TODO: Softmax, /**/ + PADDING_SAME, /**/ + PADDING_SAME_MXNET /**/ + } padding_type_t; +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32s2/include/esp-face/include/image/dl_image.hpp b/tools/sdk/esp32s2/include/esp-face/include/image/dl_image.hpp new file mode 100644 index 00000000000..c7fecdc49cc --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/image/dl_image.hpp @@ -0,0 +1,380 @@ +#pragma once + +#include +#include +#include +#include +#include "dl_define.hpp" +#include "dl_variable.hpp" +#include "dl_math_matrix.hpp" + +namespace dl +{ + namespace image + { + typedef enum + { + IMAGE_RESIZE_BILINEAR = 0, /*> 7; + return DL_CLIP(temp, 0, 255); + } + + /** + * @brief Convert RGB565 pixel to RGB888. + * + * @tparam T supports all integer types + * @param input pixel value in RGB565 + * @param output pixel value in RGB888 + */ + template + inline void convert_pixel_rgb565_to_rgb888(uint16_t input, T *output) + { + output[0] = (input & 0x1F00) >> 5; // blue + output[1] = ((input & 0x7) << 5) | ((input & 0xE000) >> 11); // green + output[2] = input & 0xF8; // red + } + + /** + * @brief Convert RGB565 pixel to Gray. + * + * @param input pixel value in RGB565 + * @return pixel value in Gray + */ + inline uint8_t convert_pixel_rgb565_to_gray(uint16_t input) + { + int blue = (input & 0x1F00) >> 5; // blue + int green = ((input & 0x7) << 5) | ((input & 0xE000) >> 11); // green + int red = input & 0xF8; // red + + return convert_pixel_rgb888_to_gray(red, green, blue); + } + + /** + * @brief Crop a patch from image and resize and store to destination image. + * If the cropping box is out of image, destination image will be padded with edge. + * + * The outer rectangle is the entire output image. + * The inner rectangle is where the resized image will be stored. + * In other world, this function could help you do padding while resize image. + * ___________________________(dst_w)__________________ + * | ___________________________ | + * | |(x_start, y_start) | | + * | | | | + * | | | | + * (dst_h)| | | | + * | | | | + * | | | | + * | |___________________________|(x_end, y_end) | + * |____________________________________________________| + * + * @tparam T suppot all integer types + * @param dst_image pointer of destination(output) image + * @param dst_width destination image width + * @param dst_channel destination image channel number + * @param dst_y_start start y of resized image in destination image + * @param dst_y_end end y of resized image in destination image + * @param dst_x_start start x of resized image in destination image + * @param dst_x_end end x of resized image in destination image + * @param src_image pointer of source image + * @param src_height source image height + * @param src_width source image width + * @param src_channel source image channel + * @param src_y_start start y of resized image in source image + * @param src_y_end end y of resized image in source image + * @param src_x_start start x of resized image in source image + * @param src_x_end end x of resized image in source image + * @param resize_type one of IMAGE_RESIZE_BILINEAR or IMAGE_RESIZE_MEAN or IMAGE_RESIZE_NEAREST + * @param shift_left bit left shift number implemented on output + */ + template + void crop_and_resize(T *dst_image, + int dst_width, + int dst_channel, + int dst_y_start, int dst_y_end, + int dst_x_start, int dst_x_end, + uint16_t *src_image, + int src_height, + int src_width, + int src_channel, + int src_y_start, int src_y_end, + int src_x_start, int src_x_end, + resize_type_t resize_type = IMAGE_RESIZE_NEAREST, + int shift_left = 0); + + /** + * @brief Crop a patch from image and resize and store to destination image. + * If the cropping box is out of image, destination image will be padded with edge. + * + * The outer rectangle is the entire output image. + * The inner rectangle is where the resized image will be stored. + * In other world, this function could help you do padding while resize image. + * ___________________________(dst_w)__________________ + * | ___________________________ | + * | |(x_start, y_start) | | + * | | | | + * | | | | + * (dst_h)| | | | + * | | | | + * | | | | + * | |___________________________|(x_end, y_end) | + * |____________________________________________________| + * + * @tparam T suppot all integer types + * @param dst_image pointer of destination(output) image + * @param dst_width destination image width + * @param dst_channel destination image channel number + * @param dst_y_start start y of resized image in destination image + * @param dst_y_end end y of resized image in destination image + * @param dst_x_start start x of resized image in destination image + * @param dst_x_end end x of resized image in destination image + * @param src_image pointer of source image + * @param src_height source image height + * @param src_width source image width + * @param src_channel source image channel + * @param src_y_start start y of resized image in source image + * @param src_y_end end y of resized image in source image + * @param src_x_start start x of resized image in source image + * @param src_x_end end x of resized image in source image + * @param resize_type one of IMAGE_RESIZE_BILINEAR or IMAGE_RESIZE_MEAN or IMAGE_RESIZE_NEAREST + * @param shift_left bit left shift number implemented on output + */ + template + void crop_and_resize(T *dst_image, + int dst_width, + int dst_channel, + int dst_y_start, int dst_y_end, + int dst_x_start, int dst_x_end, + uint8_t *src_image, + int src_height, + int src_width, + int src_channel, + int src_y_start, int src_y_end, + int src_x_start, int src_x_end, + resize_type_t resize_type = IMAGE_RESIZE_NEAREST, + int shift_left = 0); + + /** + * @brief Draw a filled rectangle on RGB888 image. + * + * @param image pointer of input image + * @param image_height height of input image + * @param image_width width of input image + * @param x1 left up corner x + * @param y1 left up corner y + * @param x2 right bottom corner x + * @param y2 right bottom corner y + * @param color 0x 00| 00| 00| 00 + * reserved|channel 0|channel 1|channel 2 + */ + void draw_filled_rectangle(uint8_t *image, const uint32_t image_height, const uint32_t image_width, + uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2, + const uint32_t color = 0x00FF0000); + + /** + * @brief Draw a filled rectangle on RGB565 image. + * + * @param image pointer of input image + * @param image_height height of input image + * @param image_width width of input image + * @param x1 left up corner x + * @param y1 left up corner y + * @param x2 right bottom corner x + * @param y2 right bottom corner y + * @param color 0b 000| 00000| 00000| 000 + * channel 1[2:0]|channel 0|channel 2|channel 1[5:3] + */ + void draw_filled_rectangle(uint16_t *image, const uint32_t image_height, const uint32_t image_width, + uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2, + const uint16_t color = 0b0001111100000000); + + /** + * @brief Draw a point on RGB888 image. + * + * @param image pointer of input image + * @param image_height height of input image + * @param image_width width of input image + * @param x point x + * @param y point y + * @param size size of point + * @param color 0x 00| 00| 00| 00 + * reserved|channel 0|channel 1|channel 2 + */ + void draw_point(uint8_t *image, const uint32_t image_height, const uint32_t image_width, + const uint32_t x, const uint32_t y, const uint32_t size, + const uint32_t color = 0x00FF0000); + + /** + * @brief Draw a point on RGB565 image. + * + * @param image pointer of input image + * @param image_height height of input image + * @param image_width width of input image + * @param x point x + * @param y point y + * @param size size of point + * @param color 0b 000| 00000| 00000| 000 + * channel 1[2:0]|channel 0|channel 2|channel 1[5:3] + */ + void draw_point(uint16_t *image, const uint32_t image_height, const uint32_t image_width, + const uint32_t x, const uint32_t y, const uint32_t size, + uint16_t color = 0b0001111100000000); + + /** + * @brief Draw a hollow rectangle on RGB888 image. + * + * @param image pointer of input image + * @param image_height height of input image + * @param image_width width of input image + * @param x1 left up corner x + * @param y1 left up corner y + * @param x2 right bottom corner x + * @param y2 right bottom corner y + * @param color 0x 00| 00| 00| 00 + * reserved|channel 0|channel 1|channel 2 + */ + void draw_hollow_rectangle(uint8_t *image, const uint32_t image_height, const uint32_t image_width, + uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2, + uint32_t color = 0x00FF0000); + + /** + * @brief Draw a hollow rectangle on RGB565 image. + * + * @param image pointer of input image + * @param image_height height of input image + * @param image_width width of input image + * @param x1 left up corner x + * @param y1 left up corner y + * @param x2 right bottom corner x + * @param y2 right bottom corner y + * @param color 0b 000| 00000| 00000| 000 + * channel 1[2:0]|channel 0|channel 2|channel 1[5:3] + */ + void draw_hollow_rectangle(uint16_t *image, const uint32_t image_height, const uint32_t image_width, + uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2, + const uint16_t color = 0b0001111100000000); + + /** + * @brief Detect target moving by activated detection point number. Each cross in the figure below is a detection point. + * Once abs(frame_1_detection_point[i] - frame_2_detection_point[i]) > threshold, this detection point is activated. + * This function will return the number of activated detection point. + * + * __stride__________________________ + * | | | | | + * stride | | | | | + * | | | | | + * |________|________|________| | + * | | | | | + * | | | | | + * | | | | | + * |________|________|________| height + * | | | | | + * | | | | | + * | | | | | + * |________|________|________| | + * | | | | | + * | | | | | + * | | | | | + * |________|________|________|___|___ + * | | + * |__________width___________| + * | | + * + * Time consumption: + * Frame shape = (240, 240) + * Both frame are in PSRAM + * On ESP32-S3 with CPU 240MHz, QSPI 80MHz + * + * stride latency + * 1 28316us + * 2 8770us + * 4 3622us + * 8 1990us + * 16 880us + * 32 260us + * + * + * In a application, outside this function, threshold of activated detection point number is needed. + * Once activated detection point number > number_threshold, this two frame are judged target moved. + * How to determine the number_threshold? + * Let's assume that the minimize shape of target is (target_min_height, target_max_width). + * Then, the number_threshold = [target_min_height / stride] * [target_max_width / stride] * ratio, + * where ratio is in (0, 1), the smaller the ratio is, the more sensitive the detector is, the more false detected. + * + * + * @param f1 one frame in RGB565 + * @param f2 another frame in RGB565 + * @param height height of frame + * @param width width of frame + * @param stride stride of detection point, the smaller the stride is, the more reliable the detector is. + * @param threshold activation threshold of each detection point + * @return activated detection point number + */ + uint32_t get_moving_point_number(uint16_t *f1, uint16_t *f2, const uint32_t height, const uint32_t width, const uint32_t stride, const uint32_t threshold = 5); + + /** + * @brief Detect target moving by activated detection point number. Each cross in the figure below is a detection point. + * Once abs(frame_1_detection_point[i] - frame_2_detection_point[i]) > threshold, this detection point is activated. + * This function will return the number of activated detection point. + * + * __stride__________________________ + * | | | | | + * stride | | | | | + * | | | | | + * |________|________|________| | + * | | | | | + * | | | | | + * | | | | | + * |________|________|________| height + * | | | | | + * | | | | | + * | | | | | + * |________|________|________| | + * | | | | | + * | | | | | + * | | | | | + * |________|________|________|___|___ + * | | + * |__________width___________| + * | | + * + * + * In a application, outside this function, threshold of activated detection point number is needed. + * Once activated detection point number > number_threshold, this two frame are judged target moved. + * How to determine the number_threshold? + * Let's assume that the minimize shape of target is (target_min_height, target_max_width). + * Then, the number_threshold = [target_min_height / stride] * [target_max_width / stride] * ratio, + * where ratio is in (0, 1), the smaller the ratio is, the more sensitive the detector is, the more false detected. + * + * + * @param f1 one frame in RGB888 + * @param f2 another frame in RGB888 + * @param height height of frame + * @param width width of frame + * @param stride stride of detection point, the smaller the stride is, the more reliable the detector is. + * @param threshold activation threshold of each detection point + * @return activated detection point number + */ + uint32_t get_moving_point_number(uint8_t *f1, uint8_t *f2, const uint32_t height, const uint32_t width, const uint32_t stride, const uint32_t threshold = 5); + + + template + void warp_affine(dl::Tensor *input, dl::Tensor *output, dl::math::Matrix *M_inv); + template + void warp_affine(uint16_t *input, std::vector shape, dl::Tensor *output, dl::math::Matrix *M_inv); + + } // namespace image +} // namespace dl diff --git a/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_add2d.hpp b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_add2d.hpp new file mode 100644 index 00000000000..f0c5964b3d1 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_add2d.hpp @@ -0,0 +1,127 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn_add2d.hpp" +#include "dl_layer_base.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief Activation(Add2D(input0, input1)). + * NOTE: addition is element-wise, i.e., output[i,j,k] = input0[i,j,k] + input1[i,j,k] + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class Add2D : public Layer + { + private: + const Activation *activation; /**/ + const int output_exponent; /**/ + Tensor *output; /**/ + bool inplace; /**/ + + public: + /** + * @brief Construct a new Add2D object. + * + * @param output_exponent exponent of output + * @param activation activation of add2d, if you don't specify anything, no activation is applied + * @param name name of add2d + * @param inplace true: the output will store to input0 + * false: the output will store to a seperate memeory + */ + Add2D(const int output_exponent, const Activation *activation = NULL, const char *name = NULL, bool inplace = false) : Layer(name), activation(activation), output_exponent(output_exponent), output(NULL) + { + this->inplace = inplace; + } + + /** + * @brief Destroy the Add2D object + */ + ~Add2D() + { + if((!this->inplace) && (this->output != NULL)) + { + delete this->output; + } + } + + /** + * @brief Update output shape. + * NOTE: input0.shape must equal to input1.shape. + * + * @param input0 as one input + * @param input1 as another input + */ + void build(Tensor &input0, Tensor &input1) + { + assert(input0.is_same_shape(input1)); + + if (!this->inplace) + { + if (this->output == NULL) + { + this->output = new Tensor; + } + this->output->set_exponent(this->output_exponent); + this->output->set_shape(input0.shape); + this->output->free_element(); + } + else + { + this->output = &input0; + } + } + + /** + * @brief Get the output + * + * @return Tensor& Add2D result + */ + Tensor &get_output() + { + return *this->output; + } + + /** + * @brief Call Add2D operation. + * + * @param input0 as one input + * @param input1 as another input + * @param assign_core not effective yet + * @return Tensor& added result + */ + Tensor &call(Tensor &input0, Tensor &input1, const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_LAYER_LATENCY_INIT(); + + if (!this->inplace) + { + DL_LOG_LAYER_LATENCY_START(); + this->output->apply_element(); + this->output->set_exponent(this->output_exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + DL_LOG_LAYER_LATENCY_START(); + nn::add2d(*this->output, input0, input1, this->activation, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "add2d"); + } + else + { + DL_LOG_LAYER_LATENCY_START(); + nn::add2d(*this->output, input0, input1, this->activation, assign_core, this->output_exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "add2d"); + } + + return *this->output; + } + }; + } // namespace layer +} // namespace dl diff --git a/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_avg_pool2d.hpp b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_avg_pool2d.hpp new file mode 100644 index 00000000000..f78b262beb9 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_avg_pool2d.hpp @@ -0,0 +1,137 @@ +#pragma once + +#include +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn_avg_pool2d.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief AvgPool2D(input). + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class AvgPool2D : public Layer + { + private: + const int output_exponent; /**/ + std::vector filter_shape; /**/ + const int stride_y; /**/ + const int stride_x; /**/ + const padding_type_t padding_type; /**/ + std::vector padding; /**/ + Tensor *output; /**/ + + public: + + /** + * @brief Construct a new AvgPool2D object. + * + * @param output_exponent exponent of output + * @param filter_shape filter shape in [filter_height, filter_width] + * @param padding_type one of PADDING_VALID or PADDING_SAME or PADDING_SAME_MXNET, + * - PADDING_VALID means no padding + * PADDING_SAME and PADDING_SAME_MXNET results in padding with zeros evenly to the left/right or up/down of the input + * such that output has the same height/width dimension as the input, + * - PADDING_SAME results padding in TensorFlow style + * - PADDING_SAME_MXNET results padding in MXNET style + * @param stride_y stride in height + * @param stride_x stride in width + * @param name name of layer + */ + AvgPool2D(const int output_exponent, + const std::vector filter_shape, + const padding_type_t padding_type = PADDING_VALID, + const int stride_y = 1, + const int stride_x = 1, + const char *name = NULL) : Layer(name), + output_exponent(output_exponent), + filter_shape(filter_shape), + stride_y(stride_y), + stride_x(stride_x), + padding_type(padding_type) + { + this->output = new Tensor; + } + + /** + * @brief Destroy the AvgPool2D object. + * + */ + ~AvgPool2D() + { + if(this->output != NULL) + { + delete this->output; + } + } + + /** + * @brief Update output shape and padding. + * + * @param input as an input + */ + void build(Tensor &input) + { + assert(input.shape[0] > 0); + assert(input.shape[1] > 0); + std::vector output_shape = nn::get_output_shape(input.shape, filter_shape, this->stride_y, this->stride_x, this->padding_type); + this->output->set_shape(output_shape); + this->output->set_exponent(this->output_exponent); + + this->padding = nn::get_pad_size(output_shape, input.shape, filter_shape, this->stride_y, this->stride_x, this->padding_type); + input.set_padding_size(this->padding); + this->output->free_element(); + } + + + /** + * @brief Get the output + * + * @return Tensor& AvgPool2D result + */ + Tensor &get_output() + { + return *this->output; + } + + /** + * @brief Call AvgPool2D operation + * + * @param input as an input + * @param autoload_enable one of true or false, + * - true: load input and output from PSRAM to CACHE automatically + * - false: do not + * @param assign_core not effective yet + * @return AvgPool2D result + */ + Tensor &call(Tensor &input, uint8_t autoload_enable = 0) + { + DL_LOG_LAYER_LATENCY_INIT(); + + DL_LOG_LAYER_LATENCY_START(); + this->output->apply_element(); + this->output->set_exponent(this->output_exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + if (autoload_enable) + { + dl::tool::cache::autoload_func((uint32_t)(this->output->element), this->output->get_size() * sizeof(feature_t), + (uint32_t)(input.element), input.get_size() * sizeof(feature_t)); + } + + DL_LOG_LAYER_LATENCY_START(); + nn::avg_pool2d(*this->output, input, this->padding, this->filter_shape, this->stride_y, this->stride_x); + DL_LOG_LAYER_LATENCY_END(this->name, "avg_pool2d"); + + return *this->output; + } + }; + } // namespace layer +} // namespace dl diff --git a/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_base.hpp b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_base.hpp new file mode 100644 index 00000000000..5c7d28d52b1 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_base.hpp @@ -0,0 +1,55 @@ +#pragma once +#include "dl_tool.hpp" +#include "dl_tool_cache.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief Base class for layer. + * + */ + class Layer + { + public: + char *name; /**/ + + /** + * @brief Construct a new Layer object. + * + * @param name name of layer. + */ + Layer(const char *name = NULL); + + /** + * @brief Destroy the Layer object. Return resource. + * + */ + ~Layer(); + }; + } // namespace layer +} // namespace dl + +#if DL_LOG_LAYER_LATENCY +/** + * @brief Initialize. + */ +#define DL_LOG_LAYER_LATENCY_INIT() dl::tool::Latency latency + +/** + * @brief Time starts. + */ +#define DL_LOG_LAYER_LATENCY_START() latency.start() + +/** + * @brief Time ends and printed. + */ +#define DL_LOG_LAYER_LATENCY_END(prefix, key) \ + latency.end(); \ + latency.print(prefix, key) +#else +#define DL_LOG_LAYER_LATENCY_INIT() +#define DL_LOG_LAYER_LATENCY_START() +#define DL_LOG_LAYER_LATENCY_END(prefix, key) +#endif diff --git a/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_concat2d.hpp b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_concat2d.hpp new file mode 100644 index 00000000000..a086f1ccfde --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_concat2d.hpp @@ -0,0 +1,179 @@ +#pragma once + +#include +#include + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_tool.hpp" +#include "dl_layer_base.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief Concat2D(input1, input2, input3, ...). + * + * @tparam feature_t support all kinds of integer and float data type + */ + template + class Concat2D : Layer + { + private: + std::vector *> output_vec; /**/ + std::vector offset; /**/ + std::vector channel; /**/ + Tensor *output; /**/ + int output_exponent; /**/ + public: + + /** + * @brief Construct a new Concat2D object. + * + * @param name name of layer + */ + Concat2D(const char *name = NULL) : Layer(name) { + this->output = new Tensor; + } + + /** + * @brief Destroy the Concat2D object + */ + ~Concat2D() + { + if (this->output != NULL) + { + delete this->output; + } + } + + /** + * @brief Collect inputs' channel and memory offset, called in Model.build(). + * + * @param args pointers of concatenated Tensor + */ + void build(std::vector *> args) + { + assert(args.size() > 0); + + this->output_vec = args; + + this->offset = std::vector(args.size()); + this->channel = std::vector(args.size()); + + this->output_exponent = args[0]->exponent; + this->offset[0] = 0; + this->channel[0] = args[0]->shape[2]; + std::vector output_shape = args[0]->shape; + + for (int i = 1; i < args.size(); i++) + { + assert(output_shape[0] == args[i]->shape[0]); // height + assert(output_shape[1] == args[i]->shape[1]); // width + // assert(this->output_exponent == args[i]->exponent); // exponent + + this->offset[i] = output_shape[2]; + this->channel[i] = args[i]->shape[2]; + output_shape[2] += args[i]->shape[2]; + } + this->output->set_shape(output_shape); + this->output->set_exponent(this->output_exponent); + this->output->free_element(); + } + + /** + * @brief Get the output + * + * @return Tensor& Concat2d result + */ + Tensor &get_output() + { + return *this->output; + } + + /** + * @brief Get the maximum padding among inputs and output-> Then, set to this->output. Called at the end of Model.build(). + * NOTE: Some special situations like C = Concat2D_1(A, B), E = Concat2D_2(C, D), where A, B, C, D, E are Tensor. + * For avoiding memory copy, we apply an entire element for E, and take it apart for A, B, D. + * A, B, C, D and E will become other layer's inputs so that result different size of padding. + * For get the maximum padding, we should call at the end of Model.build(), + * Concat2D_1.backward(); // max_padding_temp = get_max_padding(A, B, C), padding of A, B and C are set to max_padding_temp. + * Concat2D_2.backward(); // max_padding = get_max_padding(max_padding_temp, get_max_padding(D, E)) , padding of C, D and E are set to max_padding. + * However, padding of A and B is still max_padding_temp. + * Concat2D_1.backward(); // padding of A and B are set to max_padding. + * Or, + * Concat2D_2.backward(); + * Concat2D_1.backward(); + * Concat2D_2.backward(); + */ + void backward() + { + std::vector max_padding = this->output->padding; + int max_channel_with_padding = this->output->shape_with_padding[2]; + for (int i = 0; i < this->output_vec.size(); i++) + { + for (int j = 0; j < max_padding.size(); j++) + { + max_padding[j] = DL_MAX(max_padding[j], this->output_vec[i]->padding[j]); + } + max_channel_with_padding = DL_MAX(max_channel_with_padding, this->output_vec[i]->shape_with_padding[2]); + } + + this->output->set_padding_size(max_padding); + this->output->shape_with_padding[2] = max_channel_with_padding; + for (int i = 0; i < this->output_vec.size(); i++) + { + this->output_vec[i]->set_padding_size(max_padding); + this->output_vec[i]->shape_with_padding[2] = max_channel_with_padding; +#if CONFIG_DEBUG_MODE + assert(this->output->shape_with_padding[0] == this->output_vec[i]->shape_with_padding[0]); + assert(this->output->shape_with_padding[1] == this->output_vec[i]->shape_with_padding[1]); + assert(this->output->shape_with_padding[2] == this->output_vec[i]->shape_with_padding[2]); +#endif + } + } + + /** + * @brief Calloc an entire element for concatnate result. Take the entire element apart and deliver element pointers to concatenated layer. + * NOTE: For example, C = Concat2D(A, B). We apply an entire element for C and deliver two element pointers to A and B. + * Let's assume that A result is produced first. We should call Concat2D.calloc_element() just before A result is produced + * to make sure the element of A is ready and could be filled. + */ + void calloc_element() + { + DL_LOG_LAYER_LATENCY_INIT(); + + DL_LOG_LAYER_LATENCY_START(); + this->output->calloc_element(); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + DL_LOG_LAYER_LATENCY_START(); + for (int i = 0; i < this->offset.size(); i++) + { + this->output_vec[i]->element = this->output->element + this->offset[i]; + this->output_vec[i]->set_auto_free(false); + } + DL_LOG_LAYER_LATENCY_END(this->name, "deliver"); + } + + void apply_element() + { + DL_LOG_LAYER_LATENCY_INIT(); + + DL_LOG_LAYER_LATENCY_START(); + this->output->apply_element(); + this->output->set_exponent(this->output_exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + DL_LOG_LAYER_LATENCY_START(); + for (int i = 0; i < this->offset.size(); i++) + { + this->output_vec[i]->element = this->output->element + this->offset[i]; + this->output_vec[i]->set_auto_free(false); + } + DL_LOG_LAYER_LATENCY_END(this->name, "deliver"); + } + }; + } // namespace layer +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_conv2d.hpp b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_conv2d.hpp new file mode 100644 index 00000000000..a7c2229db09 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_conv2d.hpp @@ -0,0 +1,157 @@ +#pragma once + +#include "dl_nn_conv2d.hpp" +#include "dl_layer_base.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief Activation(Conv2D(input, filter) + bias). + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class Conv2D : public Layer + { + private: + const int output_exponent; /**/ + const Filter *filter; /**/ + const int stride_y; /**/ + const int stride_x; /**/ + const padding_type_t padding_type; /**/ + const Bias *bias; /**/ + const Activation *activation; /**/ + std::vector padding; /**/ + Tensor *output; /**/ + + public: + + /** + * @brief Construct a new Conv2D object. + * + * @param output_exponent exponent of output + * @param filter filter of Conv2D + * @param bias bias of Conv2D, if you don't specify anything, no bias is added + * @param activation activation of Conv2D, if you don't specify anything, no activation is applied + * @param padding_type one of PADDING_VALID or PADDING_SAME or PADDING_SAME_MXNET, + * - PADDING_VALID means no padding + * PADDING_SAME and PADDING_SAME_MXNET results in padding with zeros evenly to the left/right or up/down of the input + * such that output has the same height/width dimension as the input, + * - PADDING_SAME results padding in TensorFlow style + * - PADDING_SAME_MXNET results padding in MXNET style + * @param stride_y stride in height + * @param stride_x stride in width + * @param name name of layer + */ + Conv2D(const int output_exponent, + const Filter *filter, + const Bias *bias = NULL, + const Activation *activation = NULL, + const padding_type_t padding_type = PADDING_VALID, + const int stride_y = 1, + const int stride_x = 1, + const char *name = NULL) : Layer(name), + output_exponent(output_exponent), + filter(filter), + stride_y(stride_y), + stride_x(stride_x), + padding_type(padding_type), + bias(bias), + activation(activation) + { + this->output = new Tensor; + } + + /** + * @brief Destroy the Conv2D object. + * + */ + ~Conv2D() + { + if (this->output != NULL) + { + delete this->output; + } + } + + /** + * @brief Update output padding and input padding. + * + * @param input as an input + */ + void build(Tensor &input) + { + assert(input.shape[0] > 0); + assert(input.shape[1] > 0); + + std::vector output_shape = nn::get_output_shape(input.shape, this->filter->shape_with_dilation, this->stride_y, this->stride_x, this->padding_type, true); + this->output->set_shape(output_shape); + this->output->set_exponent(this->output_exponent); + this->output->free_element(); + + this->padding = nn::get_pad_size(output_shape, input.shape, this->filter->shape_with_dilation, this->stride_y, this->stride_x, this->padding_type); + input.set_padding_size(this->padding); + } + + /** + * @brief Get the output + * + * @return Tensor& Conv2D result + */ + Tensor &get_output() + { + return *this->output; + } + + /** + * @brief Call Conv2D operation + * + * @param input as an input. + * @param autoload_enable one of true or false, + * - true: load input and output from PSRAM to CACHE automatically + * - false: do not + * @param assign_core not effective yet + * @return Conv2D result + */ + Tensor &call(Tensor &input, bool autoload_enable = false, const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_LAYER_LATENCY_INIT(); + + DL_LOG_LAYER_LATENCY_START(); + this->output->apply_element(); + this->output->set_exponent(this->output_exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + if (autoload_enable) + { + dl::tool::cache::autoload_func((uint32_t)(this->output->element), this->output->get_size() * sizeof(feature_t), + (uint32_t)(input.element), input.get_size() * sizeof(feature_t)); + } + + DL_LOG_LAYER_LATENCY_START(); + nn::conv2d(*this->output, input, this->padding, *(this->filter), this->stride_y, this->stride_x, this->bias, this->activation, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "conv2d"); + return *this->output; + } + + /** + * @brief Preload the filter to Cache. + * NOTE: Call this layer's preload() before previous layer's call() such that filter could be loaded while previous layer is doing calculation. + */ + void preload() + { + size_t size = sizeof(feature_t); + int shape_size = this->filter->shape.size(); + for (int i = 0; i < shape_size; ++i) + { + size *= filter->shape[i]; + } + dl::tool::cache::preload_func((uint32_t)(this->filter->element), size); + } + }; + } // namespace layer +} // namespace dl diff --git a/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_depthwise_conv2d.hpp b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_depthwise_conv2d.hpp new file mode 100644 index 00000000000..37475353209 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_depthwise_conv2d.hpp @@ -0,0 +1,158 @@ +#pragma once + +#include "dl_nn_depthwise_conv2d.hpp" +#include "dl_layer_base.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief Activation(DepthwiseConv2D(filter, input) + bias). + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class DepthwiseConv2D : public Layer + { + private: + const int output_exponent; /**/ + const Filter *filter; /**/ + const int stride_y; /**/ + const int stride_x; /**/ + const padding_type_t padding_type; /**/ + const Bias *bias; /**/ + const Activation *activation; /**/ + std::vector padding; /**/ + Tensor *output; /**/ + + public: + + /** + * @brief Construct a new DepthwiseConv2D object. + * + * @param output_exponent exponent of output + * @param filter filter of DepthwiseConv2D + * @param bias bias of DepthwiseConv2D, if you don't specify anything, no bias is added + * @param activation activation of DepthwiseConv2D, if you don't specify anything, no activation is applied + * @param padding_type one of PADDING_VALID or PADDING_SAME or PADDING_SAME_MXNET, + * - PADDING_VALID means no padding + * PADDING_SAME and PADDING_SAME_MXNET results in padding with zeros evenly to the left/right or up/down of the input + * such that output has the same height/width dimension as the input + * - PADDING_SAME results padding in TensorFlow style + * - PADDING_SAME_MXNET results padding in MXNET style + * @param stride_y - stride in height + * @param stride_x - stride in width + * @param name name of layer + */ + DepthwiseConv2D(const int output_exponent, + const Filter *filter, + const Bias *bias = NULL, + const Activation *activation = NULL, + const padding_type_t padding_type = PADDING_VALID, + const int stride_y = 1, + const int stride_x = 1, + const char *name = NULL) : Layer(name), + output_exponent(output_exponent), + filter(filter), + stride_y(stride_y), + stride_x(stride_x), + padding_type(padding_type), + bias(bias), + activation(activation) + { + this->output = new Tensor; + } + + /** + * @brief Destroy the DepthwiseConv2D object. + * + */ + ~DepthwiseConv2D() + { + if (this->output != NULL) + { + delete this->output; + } + } + + /** + * @brief Update output shape and padding. + * + * @param input as an input + */ + void build(Tensor &input) + { + assert(input.shape[0] > 0); + assert(input.shape[1] > 0); + + std::vector output_shape = nn::get_output_shape(input.shape, this->filter->shape_with_dilation, this->stride_y, this->stride_x, this->padding_type); + this->output->set_shape(output_shape); + this->output->set_exponent(this->output_exponent); + + this->padding = nn::get_pad_size(output_shape, input.shape, this->filter->shape_with_dilation, this->stride_y, this->stride_x, this->padding_type); + input.set_padding_size(this->padding); + this->output->free_element(); + } + + /** + * @brief Get the output + * + * @return Tensor& DepthwiseConv2D result + */ + Tensor &get_output() + { + return *this->output; + } + + /** + * @brief Call DepthwiseConv2D operation. + * + * @param input as an input + * @param autoload_enable one of true or false, + * - true: load input and output from PSRAM to CACHE automatically + * - false: do not + * @param assign_core not effective yet + * @return DepthwiseConv2D result + */ + Tensor &call(Tensor &input, bool autoload_enable = false, const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_LAYER_LATENCY_INIT(); + + DL_LOG_LAYER_LATENCY_START(); + this->output->apply_element(); + this->output->set_exponent(this->output_exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + if (autoload_enable) + { + dl::tool::cache::autoload_func((uint32_t)(this->output->element), this->output->get_size() * sizeof(feature_t), + (uint32_t)(input.element), input.get_size() * sizeof(feature_t)); + } + + DL_LOG_LAYER_LATENCY_START(); + nn::depthwise_conv2d(*this->output, input, this->padding, *(this->filter), this->stride_y, this->stride_x, this->bias, this->activation, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "depthwise_conv2d"); + + return *this->output; + } + + /** + * @brief Preload the filter to Cache. + * NOTE: Call this layer's preload() before previous layer's call() such that filter could be loaded while previous layer is calculating. + */ + void preload() + { + size_t size = sizeof(feature_t); + int shape_size = this->filter->shape.size(); + for (int i = 0; i < shape_size; ++i) + { + size *= filter->shape[i]; + } + dl::tool::cache::preload_func((uint32_t)(this->filter->element), size); + } + }; + } // namespace layer +} // namespace dl diff --git a/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_global_avg_pool2d.hpp b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_global_avg_pool2d.hpp new file mode 100644 index 00000000000..044c5f61847 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_global_avg_pool2d.hpp @@ -0,0 +1,111 @@ +#pragma once + +#include +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn_global_avg_pool2d.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief GlobalAveragePool2D(input). + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class GlobalAveragePool2D : public Layer + { + private: + const int output_exponent; /**/ + Tensor *output; /**/ + public: + /** + * @brief Construct a new GlobalAveragePool2D object. + * + * @param output_exponent exponent of output + * @param name name of layer + */ + GlobalAveragePool2D(const int output_exponent, const char *name = NULL) : Layer(name), + output_exponent(output_exponent) + + { + this->output = new Tensor; + } + + /** + * @brief Destroy the GlobalAveragePool2D object. + * + */ + ~GlobalAveragePool2D() + { + if (this->output != NULL) + { + delete this->output; + } + } + + /** + * @brief Update output shape. + * + * @param input as an input + */ + void build(Tensor &input) + { + assert(input.shape[0] > 0); + assert(input.shape[1] > 0); + + std::vector output_shape(input.shape.size(), 1); + output_shape[2] = input.shape[2]; + this->output->set_shape(output_shape); + this->output->set_exponent(this->output_exponent); + this->output->free_element(); + } + + /** + * @brief Get the output + * + * @return Tensor& GlobalAveragePool2D result + */ + Tensor &get_output() + { + return *this->output; + } + + /** + * @brief Call GlobalAveragePool2D operation + * + * @param input as an input + * @param autoload_enable one of true or false, + * - true: load input and output from PSRAM to CACHE automatically + * - false: do not + * @param assign_core not effective yet + * @return GlobalAveragePool2D result + */ + Tensor &call(Tensor &input, uint8_t autoload_enable = 0) + { + DL_LOG_LAYER_LATENCY_INIT(); + + DL_LOG_LAYER_LATENCY_START(); + this->output->apply_element(); + this->output->set_exponent(this->output_exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + if (autoload_enable) + { + dl::tool::cache::autoload_func((uint32_t)(this->output->element), this->output->get_size() * sizeof(feature_t), + (uint32_t)(input.element), input.get_size() * sizeof(feature_t)); + } + + DL_LOG_LAYER_LATENCY_START(); + nn::global_avg_pool2d(*this->output, input); + DL_LOG_LAYER_LATENCY_END(this->name, "global_avg_pool2d"); + + return *this->output; + } + }; + } // namespace layer +} // namespace dl diff --git a/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_global_max_pool2d.hpp b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_global_max_pool2d.hpp new file mode 100644 index 00000000000..aa146823b78 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_global_max_pool2d.hpp @@ -0,0 +1,108 @@ +#pragma once + +#include +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn_global_max_pool2d.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief GlobalMaxPool2D(input). + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class GlobalMaxPool2D : public Layer + { + private: + Tensor *output; /**/ + public: + + /** + * @brief Construct a new GlobalMaxPool2D object. + * + * @param name name of layer + */ + GlobalMaxPool2D(const char *name = NULL) : Layer(name) + { + this->output = new Tensor; + } + + /** + * @brief Destroy the GlobalMaxPool2D object. + * + */ + ~GlobalMaxPool2D() + { + if (this->output != NULL) + { + delete this->output; + } + } + + /** + * @brief Update output shape and exponent. + * + * @param input as an input + */ + void build(Tensor &input) + { + assert(input.shape[0] > 0); + assert(input.shape[1] > 0); + this->output->set_exponent(input.exponent); + + std::vector output_shape(input.shape.size(), 1); + output_shape[2] = input.shape[2]; + this->output->set_shape(output_shape); + this->output->free_element(); + } + + /** + * @brief Get the output + * + * @return Tensor& GlobalMaxPool2D result + */ + Tensor &get_output() + { + return *this->output; + } + + /** + * @brief Call GlobalMaxPool2D operation + * + * @param input as an input + * @param autoload_enable one of true or false, + * - true: load input and output from PSRAM to CACHE automatically + * - false: do not + * @param assign_core not effective yet + * @return GlobalMaxPool2D result + */ + Tensor &call(Tensor &input, uint8_t autoload_enable = 0) + { + DL_LOG_LAYER_LATENCY_INIT(); + + DL_LOG_LAYER_LATENCY_START(); + this->output->apply_element(); + this->output->set_exponent(input.exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + if (autoload_enable) + { + dl::tool::cache::autoload_func((uint32_t)(this->output->element), this->output->get_size() * sizeof(feature_t), + (uint32_t)(input.element), input.get_size() * sizeof(feature_t)); + } + + DL_LOG_LAYER_LATENCY_START(); + nn::global_max_pool2d(*this->output, input); + DL_LOG_LAYER_LATENCY_END(this->name, "global_max_pool2d"); + + return *this->output; + } + }; + } // namespace layer +} // namespace dl diff --git a/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_leakyrelu.hpp b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_leakyrelu.hpp new file mode 100644 index 00000000000..f18d9b1c522 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_leakyrelu.hpp @@ -0,0 +1,125 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn_LeakyReLU.hpp" +#include "dl_layer_base.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief LeakyReLU(input). + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class LeakyReLU : public Layer + { + private: + feature_t activation_alpha; /**/ + int activation_exponent; /**/ + Tensor *output; /**/ + bool inplace; /**/ + public: + + /** + * @brief Construct a new LeakyReLU object + * + * @param activation_alpha quantized alpha + * @param activation_exponent exponent of quantized alpha + * @param name name of leakyrelu + * @param inplace true: the output will store to input0 + * false: the output will store to a seperate memeory + */ + LeakyReLU(const int activation_alpha, const int activation_exponent, const char *name = NULL, bool inplace = false) : Layer(name), output(NULL) + { + this->activation_alpha = activation_alpha; + this->activation_exponent = activation_exponent; + this->inplace = inplace; + } + + /** + * @brief Destroy the LeakyReLU object + * + */ + ~LeakyReLU() + { + if ((!this->inplace) && (this->output != NULL)) + { + delete this->output; + } + } + + /** + * @brief Update output shape and exponent + * + * @param input as an input + */ + void build(Tensor &input) + { + if(!this->inplace) + { + if(this->output != NULL) + { + this->output = new Tensor; + } + this->output->set_shape(input.shape); + this->output->set_exponent(input.exponent); + this->output->free_element(); + } + else + { + this->output = &input; + } + + } + + /** + * @brief Get the output + * + * @return Tensor& LeakyReLU result + */ + Tensor &get_output() + { + return *this->output; + } + + /** + * @brief Call LeakyReLU operation. + * + * @param input as an input + * @param assign_core not effective yet + * @return LeakyReLU result + */ + Tensor &call(Tensor &input, const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_LAYER_LATENCY_INIT(); + + if(!this->inplace) + { + DL_LOG_LAYER_LATENCY_START(); + this->output->apply_element(); + this->output->set_exponent(input.exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + DL_LOG_LAYER_LATENCY_START(); + nn::leakyrelu(*this->output, input, this->activation_alpha, this->activation_exponent, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "leakyrelu"); + } + else + { + DL_LOG_LAYER_LATENCY_START(); + nn::leakyrelu(*this->output, input, this->activation_alpha, this->activation_exponent, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "leakyrelu"); + } + + return *this->output; + } + }; + } // namespace layer +} // namespace dl diff --git a/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_max2d.hpp b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_max2d.hpp new file mode 100644 index 00000000000..8a775a2e0f0 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_max2d.hpp @@ -0,0 +1,125 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_tool.hpp" +#include "dl_nn_max2d.hpp" +#include "dl_layer_base.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief Max2D(input0, input1). + * NOTE: maximum is element-wise, i.e., output[i,j,k] = max(input0[i,j,k], input1[i,j,k]) + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class Max2D : public Layer + { + private: + Tensor *output; /**/ + bool inplace; /**/ + public: + + /** + * @brief Construct a new Max2D object. + * + * @param name name of max2d + * @param inplace true: the output will store to input0 + * false: the output will store to a seperate memeory + */ + Max2D(const char *name = NULL, bool inplace = false) : Layer(name), output(NULL) + { + this->inplace = inplace; + } + + /** + * @brief Destroy the Max2D object + * + */ + ~Max2D() + { + if ((!this->inplace) && (this->output != NULL)) + { + delete this->output; + } + } + + /** + * @brief Update output shape and exponent + * NOTE: input0.shape must equal to input1.shape. + * input0.exponent must equal to input1.exponent. + * + * @param input0 as one input + * @param input1 as another input + */ + void build(Tensor &input0, Tensor &input1) + { + assert(input0.is_same_shape(input1)); + assert(input0.exponent == input1.exponent); + + if(!this->inplace) + { + if(this->output != NULL) + { + this->output = new Tensor; + } + this->output->set_exponent(this->output_exponent); + this->output->set_shape(input0.shape); + this->output->free_element(); + } + else + this->output = &input0; + } + + /** + * @brief Get the output + * + * @return Tensor& Max2D result + */ + Tensor &get_output() + { + return *this->output; + } + + /** + * @brief Call Max2D operation. + * + * @param input0 as one input + * @param input1 as another input + * @param assign_core not effective yet + * @return Max2D result + */ + Tensor &call(Tensor &input0, Tensor &input1, const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_LAYER_LATENCY_INIT(); + + if(!this->inplace) + { + DL_LOG_LAYER_LATENCY_START(); + this->output->apply_element(); + this->output->set_exponent(input0.exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + DL_LOG_LAYER_LATENCY_START(); + nn::max2d(*this->output, input0, input1, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "max2d"); + } + else + { + DL_LOG_LAYER_LATENCY_START(); + nn::max2d(*this->output, input0, input1, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "max2d"); + } + + return *this->output; + } + }; + } // namespace layer +} // namespace dl diff --git a/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_max_pool2d.hpp b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_max_pool2d.hpp new file mode 100644 index 00000000000..f836a983b34 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_max_pool2d.hpp @@ -0,0 +1,132 @@ +#pragma once + +#include +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn_max_pool2d.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief MaxPool2D(input). + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class MaxPool2D : public Layer + { + private: + std::vector filter_shape; /**/ + const int stride_y; /**/ + const int stride_x; /**/ + const padding_type_t padding_type; /**/ + std::vector padding; /**/ + Tensor *output; /**/ + + public: + + /** + * @brief Construct a new MaxPool2D object. + * + * @param filter_shape filter shape in [filter_height, filter_width] + * @param padding_type one of PADDING_VALID or PADDING_SAME or PADDING_SAME_MXNET, + * - PADDING_VALID means no padding + * PADDING_SAME and PADDING_SAME_MXNET results in padding with zeros evenly to the left/right or up/down of the input + * such that output has the same height/width dimension as the input, + * - PADDING_SAME results padding in TensorFlow style + * - PADDING_SAME_MXNET results padding in MXNET style + * @param stride_y stride in height + * @param stride_x stride in width + * @param name name of layer + */ + MaxPool2D(const std::vector filter_shape, + const padding_type_t padding_type = PADDING_VALID, + const int stride_y = 1, + const int stride_x = 1, + const char *name = NULL) : Layer(name), + filter_shape(filter_shape), + stride_y(stride_y), + stride_x(stride_x), + padding_type(padding_type) + { + this->output = new Tensor; + } + + /** + * @brief Destroy the MaxPool2D object. + * + */ + ~MaxPool2D() + { + if (this->output != NULL) + { + delete this->output; + } + } + + /** + * @brief Update output shape and padding. + * + * @param input as an input + */ + void build(Tensor &input) + { + assert(input.shape[0] > 0); + assert(input.shape[1] > 0); + this->output->set_exponent(input.exponent); + std::vector output_shape = nn::get_output_shape(input.shape, filter_shape, this->stride_y, this->stride_x, this->padding_type); + this->output->set_shape(output_shape); + + this->padding = nn::get_pad_size(output_shape, input.shape, filter_shape, this->stride_y, this->stride_x, this->padding_type); + input.set_padding_size(this->padding); + this->output->free_element(); + } + + /** + * @brief Get the output + * + * @return Tensor& MaxPool2D result + */ + Tensor &get_output() + { + return *this->output; + } + + /** + * @brief Call MaxPool2D operation + * + * @param input as an input + * @param autoload_enable one of true or false, + * - true: load input and output from PSRAM to CACHE automatically + * - false: do not + * @param assign_core not effective yet + * @return MaxPool2D result + */ + Tensor &call(Tensor &input, uint8_t autoload_enable = 0) + { + DL_LOG_LAYER_LATENCY_INIT(); + + DL_LOG_LAYER_LATENCY_START(); + this->output->apply_element(); + this->output->set_exponent(input.exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + if (autoload_enable) + { + dl::tool::cache::autoload_func((uint32_t)(this->output->element), this->output->get_size() * sizeof(feature_t), + (uint32_t)(input.element), input.get_size() * sizeof(feature_t)); + } + + DL_LOG_LAYER_LATENCY_START(); + nn::max_pool2d(*this->output, input, this->padding, this->filter_shape, this->stride_y, this->stride_x); + DL_LOG_LAYER_LATENCY_END(this->name, "max_pool2d"); + + return *this->output; + } + }; + } // namespace layer +} // namespace dl diff --git a/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_min2d.hpp b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_min2d.hpp new file mode 100644 index 00000000000..71d39c9b285 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_min2d.hpp @@ -0,0 +1,126 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_tool.hpp" +#include "dl_nn_min2d.hpp" +#include "dl_layer_base.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief Min2D(input0, input1). + * NOTE: minimum is element-wise, i.e., output[i,j,k] = min(input0[i,j,k], input1[i,j,k]) + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class Min2D : public Layer + { + private: + Tensor *output; /**/ + bool inplace; /**/ + public: + + /** + * @brief Construct a new Min2D object + * + * @param name name of min2d + * @param inplace true: the output will store to input0 + * false: the output will store to a seperate memeory + */ + Min2D(const char *name = NULL, bool inplace = false) : Layer(name), output(NULL) + { + this->inplace = inplace; + } + + /** + * @brief Destroy the Min2D object + * + */ + ~Min2D() + { + if ((!this->inplace) && (this->output != NULL)) + { + delete this->output; + } + } + + /** + * @brief Update output shape and exponent + * NOTE: input0.shape must equal to input1.shape. + * input0.exponent must equal to input1.exponent. + * + * @param input0 as one input + * @param input1 as another input + */ + void build(Tensor &input0, Tensor &input1) + { + assert(input0.is_same_shape(input1)); + assert(input0.exponent == input1.exponent); + + if(!this->inplace) + { + if(this->output != NULL) + { + this->output = new Tensor; + } + this->output->set_shape(input0.shape); + this->output->set_exponent(input0.exponent); + this->output->free_element(); + } + else + this->output = &input0; + + } + + /** + * @brief Get the output + * + * @return Tensor& Min2D result + */ + Tensor &get_output() + { + return *this->output; + } + + /** + * @brief Call Min2D operation + * + * @param input0 as one input + * @param input1 as another input + * @param assign_core not effective yet + * @return Min2D result + */ + Tensor &call(Tensor &input0, Tensor &input1, const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_LAYER_LATENCY_INIT(); + + if(!this->inplace) + { + DL_LOG_LAYER_LATENCY_START(); + this->output->apply_element(); + this->output->set_exponent(input0.exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + DL_LOG_LAYER_LATENCY_START(); + nn::min2d(*this->output, input0, input1, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "min2d"); + } + else + { + DL_LOG_LAYER_LATENCY_START(); + nn::min2d(*this->output, input0, input1, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "min2d"); + } + + return *this->output; + } + }; + } // namespace layer +} // namespace dl diff --git a/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_model.hpp b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_model.hpp new file mode 100644 index 00000000000..2064ef2d33a --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_model.hpp @@ -0,0 +1,52 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief Neural Network Model. + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class Model + { + private: + std::vector input_shape; /**/ + + public: + /** + * @brief Destroy the Model object. + * + */ + virtual ~Model() {} + + /** + * @brief Build a model including update output shape and input padding of each layer. + * + * @param input as an input + */ + virtual void build(Tensor &input) = 0; + + /** + * @brief Call the model layer by layer. + * + * @param input as an input. + */ + virtual void call(Tensor &input) = 0; + + /** + * @brief If input.shape changes, call Model.build(), otherwise, do not. Then call Model.call(). + * + * @param input as an input + */ + void forward(Tensor &input); + }; + } // namespace layer +} // namespace dl diff --git a/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_mul2d.hpp b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_mul2d.hpp new file mode 100644 index 00000000000..0edfc9a93f0 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_mul2d.hpp @@ -0,0 +1,128 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn_mul2d.hpp" +#include "dl_layer_base.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief Activation(Multiply2D(input0, input1)). + * NOTE: multiplication is element-wise, i.e., output[i,j,k] = input0[i,j,k] * input1[i,j,k] + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class Mul2D : public Layer + { + private: + const int output_exponent; /**/ + const Activation *activation; /**/ + Tensor *output; /**/ + bool inplace; /**/ + public: + const int output_exponent; /**/ + + /** + * @brief Construct a new Mul2D object. + * + * @param output_exponent exponent of output + * @param activation activation of Mul2D, if you don't specify anything, no activation is applied + * @param name name of layer + * @param inplace true: the output will store to input0 + * false: the output will store to a seperate memeory + */ + Mul2D(const int output_exponent, const Activation *activation = NULL, const char *name = NULL, bool inplace = false) : Layer(name), + output_exponent(output_exponent),activation(activation), output(NULL) + { + this->inplace = inplace; + } + + /** + * @brief Destroy the Multiply2D object. + */ + ~Mul2D() + { + if ((!this->inplace) && (this->output != NULL)) + { + delete this->output; + } + } + + /** + * @brief Update output shape. + * NOTE: input0.shape must equal to input1.shape. + * + * @param input0 as one input + * @param input1 as another input + */ + void build(Tensor &input0, Tensor &input1) + { + assert(input0.is_same_shape(input1)); + + if (!this->inplace) + { + if(this->output != NULL) + { + this->output = new Tensor; + } + this->output->set_exponent(this->output_exponent); + this->output->set_shape(input0.shape); + this->output->free_element(); + } + + else + this->output = &input0; + } + + /** + * @brief Get the output + * + * @return Tensor& Mul2D result + */ + Tensor &get_output() + { + return *this->output; + } + + /** + * @brief Call Mul2D operation. + * + * @param input0 as one input + * @param input1 as another input + * @param assign_core not effective yet + * @return Mul2D result + */ + Tensor &call(Tensor &input0, Tensor &input1, const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_LAYER_LATENCY_INIT(); + + if (!this->inplace) + { + DL_LOG_LAYER_LATENCY_START(); + this->output->apply_element(); + this->output->set_exponent(this->output_exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + DL_LOG_LAYER_LATENCY_START(); + nn::mul2d(*this->output, input0, input1, this->activation, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "mul2d"); + } + else + { + DL_LOG_LAYER_LATENCY_START(); + nn::mul2d(*this->output, input0, input1, this->activation, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "mul2d"); + } + + return *this->output; + } + }; + } // namespace layer +} // namespace dl diff --git a/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_prelu.hpp b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_prelu.hpp new file mode 100644 index 00000000000..4781a669130 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_prelu.hpp @@ -0,0 +1,124 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn_prelu.hpp" +#include "dl_layer_base.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief PReLU(input). + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class PReLU : public Layer + { + private: + feature_t *activation_element; /**/ + int activation_exponent; /**/ + Tensor *output; /**/ + bool inplace; /**/ + public: + + /** + * @brief Construct a new PReLU object + * + * @param activation_element quantized alpha elements along channel axis + * @param activation_exponent exponent of quantized alpha elements + * @param name name of prelu + * @param inplace true: the output will store to input0 + * false: the output will store to a seperate memeory + */ + PReLU(const feature_t *activation_element, const int activation_exponent = 0, const char *name = NULL, bool inplace = false) : Layer(name), output(NULL) + { + this->activation_element = activation_element; + this->activation_exponent = activation_exponent; + this->inplace = inplace; + } + + /** + * @brief Destroy the PReLU object + * + */ + ~PReLU() + { + if ((!this->inplace) && (this->output != NULL)) + { + delete this->output; + } + } + + /** + * @brief Update output shape and exponent + * + * @param input as an input + */ + void build(Tensor &input) + { + if(!this->inplace) + { + if(this->output != NULL) + { + this->output = new Tensor; + } + this->output->set_exponent(input.exponent); + this->output->set_shape(input.shape); + this->output->free_element(); + } + else + { + this->output = &input; + } + } + + /** + * @brief Get the output + * + * @return Tensor& PReLU result + */ + Tensor &get_output() + { + return *this->output; + } + + /** + * @brief Call PReLU operation. + * + * @param input as an input + * @param assign_core not effective yet + * @return PReLU result + */ + Tensor &call(Tensor &input, const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_LAYER_LATENCY_INIT(); + + if(!this->inplace) + { + DL_LOG_LAYER_LATENCY_START(); + this->output->set_exponent(input.exponent); + this->output->apply_element(); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + DL_LOG_LAYER_LATENCY_START(); + nn::prelu(*this->output, input, this->activation_element, this->activation_exponent, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "leakyrelu"); + } + else + { + DL_LOG_LAYER_LATENCY_START(); + nn::prelu(*this->output, input, this->activation_element, this->activation_exponent, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "leakyrelu"); + } + + return *this->output; + } + }; + } // namespace layer +} // namespace dl diff --git a/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_relu.hpp b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_relu.hpp new file mode 100644 index 00000000000..e70663b798c --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_relu.hpp @@ -0,0 +1,120 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_tool.hpp" +#include "dl_nn_relu.hpp" +#include "dl_layer_base.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief ReLU(input). + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class ReLU : public Layer + { + private: + Tensor *output; /**/ + bool inplace; /**/ + public: + + + /** + * @brief Construct a new ReLU object + * + * @param name name of relu + * @param inplace true: the output will store to input0 + * false: the output will store to a seperate memeory + */ + ReLU(const char *name = NULL, bool inplace = false) : Layer(name), output(NULL) + { + this->inplace = inplace; + } + + /** + * @brief Destroy the ReLU object + * + */ + ~ReLU() + { + if ((!this->inplace) && (this->output != NULL)) + { + delete this->output; + } + } + + /** + * @brief Update output shape and exponent + * + * @param input as an input + */ + void build(Tensor &input) + { + if(!this->inplace) + { + if(this->output != NULL) + { + this->output = new Tensor; + } + this->output->set_exponent(input.exponent); + this->output->set_shape(input.shape); + this->output->free_element(); + } + else + { + this->output = &input; + } + } + + /** + * @brief Get the output + * + * @return Tensor& ReLU result + */ + Tensor &get_output() + { + return *this->output; + } + + /** + * @brief Call ReLU operation. + * + * @param input as an input + * @param assign_core not effective yet + * @return ReLU result + */ + Tensor &call(Tensor &input, const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_LAYER_LATENCY_INIT(); + + if(!this->inplace) + { + DL_LOG_LAYER_LATENCY_START(); + this->output->apply_element(); + this->output->set_exponent(input.exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + DL_LOG_LAYER_LATENCY_START(); + nn::relu(*this->output, input, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "relu"); + } + else + { + DL_LOG_LAYER_LATENCY_START(); + nn::relu(*this->output, input, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "relu"); + } + + return *this->output; + } + }; + } // namespace layer +} // namespace dl diff --git a/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_sub2d.hpp b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_sub2d.hpp new file mode 100644 index 00000000000..e3453c08b97 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/layer/dl_layer_sub2d.hpp @@ -0,0 +1,124 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn_sub2d.hpp" +#include "dl_layer_base.hpp" + +namespace dl +{ + namespace layer + { + /** + * @brief Activation(Sub2D(input0, input1)). + * NOTE: subtraction is element-wise, i.e., output[i,j,k] = input0[i,j,k] - input1[i,j,k] + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class Sub2D : public Layer + { + private: + const int output_exponent; /**/ + const Activation *activation; /**/ + Tensor *output; /**/ + bool inplace; /**/ + public: + + /** + * @brief Construct a new Sub2D object. + * + * @param output_exponent exponent of output + * @param activation activation of Mul2D, if you don't specify anything, no activation is applied + * @param name name of layer + * @param inplace true: the output will store to input0 + * false: the output will store to a seperate memeory + */ + Sub2D(const int output_exponent, const Activation *activation = NULL, const char *name = NULL, bool inplace = false) : Layer(name), + output_exponent(output_exponent), activation(activation), output(NULL) + { + this->inplace = inplace; + } + + /** + * @brief Destroy the Sub2D object. + */ + ~Sub2D() + { + if ((!this->inplace) && (this->output != NULL)) + { + delete this->output; + } + } + + /** + * @brief Update output shape. + * NOTE: input0.shape must equal to input1.shape. + * + * @param input0 as one input + * @param input1 as another input + */ + void build(Tensor &input0, Tensor &input1) + { + assert(input0.is_same_shape(input1)); + if (!this->inplace) + { + if(this->output != NULL) + { + this->output = new Tensor; + } + this->output->set_exponent(this->output_exponent); + this->output->set_shape(input0.shape); + this->output->free_element(); + } + else + this->output = &input0; + } + + /** + * @brief Get the output + * + * @return Tensor& Sub2D result + */ + Tensor &get_output() + { + return *this->output; + } + + /** + * @brief Call Sub2D operation. + * + * @param input0 as one input + * @param input1 as another input + * @param assign_core not effective yet + * @return Sub2D result + */ + Tensor &call(Tensor &input0, Tensor &input1, const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_LAYER_LATENCY_INIT(); + + if (!this->inplace) + { + DL_LOG_LAYER_LATENCY_START(); + this->output.apply_element(); + this->output->set_exponent(input0.exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "apply"); + + DL_LOG_LAYER_LATENCY_START(); + nn::sub2d(this->output, input0, input1, this->activation, assign_core); + DL_LOG_LAYER_LATENCY_END(this->name, "sub2d"); + } + else + { + DL_LOG_LAYER_LATENCY_START(); + nn::sub2d(this->output, input0, input1, this->activation, assign_core, this->output_exponent); + DL_LOG_LAYER_LATENCY_END(this->name, "sub2d"); + } + return *this->output; + } + }; + } // namespace layer +} // namespace dl diff --git a/tools/sdk/esp32s2/include/esp-face/include/math/dl_math.hpp b/tools/sdk/esp32s2/include/esp-face/include/math/dl_math.hpp new file mode 100644 index 00000000000..d3f2b94d3de --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/math/dl_math.hpp @@ -0,0 +1,188 @@ +#pragma once + +#include "dl_define.hpp" + +namespace dl +{ + namespace math + { + /** + * @brief x^a. + * + * @param x as a base + * @param a as an exponent + * @return x^a + */ + inline float power(float x, int a) + { + if (a > 0) + { + return x * power(x, a - 1); + } + else if (a < 0) + { + return 1 / (x * power(x, -a - 1)); + } + else + { + return 1.f; + } + } + + /** + * @brief sqrt(x). + * + * @param x as a base + * @return sqrt(x) + */ + inline float sqrt_quick(float x) + { + const int result = 0x1fbb4000 + (*(int *)&x >> 1); + return *(float *)&result; + } + + /** + * @brief 1/sqrt(x). + * + * @param x as a base + * @return 1/sqrt(x) + */ + inline float sqrt_reciprocal_quick(float x) + { + float xhalf = 0.5f * x; + int i = *(int *)&x; // get bits for floating value + i = 0x5f375a86 - (i >> 1); // gives initial guess y0 + x = *(float *)&i; // convert bits back to float + x = x * (1.5f - xhalf * x * x); // Newton step, repeating increases accuracy + return x; + } + + static const float EN = 0.00001f; + + /** + * @brief sqrt(x). + * + * @param x as a base + * @return sqrt(x) + */ + inline float sqrt_newton(float x) + { + /** + * Use Newton iteration method to find the square root + * */ + if (x == 0.f) + return 0.f; + float result = x; + float last_value; + do + { + last_value = result; + result = (last_value + x / last_value) * 0.5; + } while (DL_ABS(result - last_value) > EN); + return result; + } + + /** + * @brief n-th root of x. + * + * @param x as a base + * @param n root times + * @return n-th root of x + */ + inline float root_newton(float x, int n) + { + if (n == 2) + return sqrt_newton(x); + if (n == 0) + return 1.f; + if (n == 1) + return x; + if (x == 0.f) + return 0.f; + float result = x; + float last_value; + float _n = (float)((n - 1) * n); + do + { + last_value = result; + result = _n * last_value + x / (n * power(last_value, n - 1)); + } while (DL_ABS(result - last_value) > EN); + return result; + } + + /** + * @brief atan(x). + * + * @param x as an input + * @return atan(x) in range [-pi/2, pi/2] + */ + inline float atan(float x) + { + return x * (0.78539816 - (DL_ABS(x) - 1) * (0.2447 + 0.0663 * DL_ABS(x))); + // float s = x*x; + // return ((-0.0464964749 * s + 0.15931422) * s - 0.327622764) * s * x + x; + } + + // TODO:@yuanjiong + /** + * @brief + * + * @param x + * @param y + * @return in range [-pi, pi] + */ + inline float atan2(float x, float y) + { + float ax = DL_ABS(x); + float ay = DL_ABS(y); + float eps = 1e-8; + float a = DL_MIN(ax, ay) / (DL_MAX(ax, ay) + eps); + float r = atan(a); //[0, pi/2] + if (ay > ax) + r = 1.57079633 - r; + if (x < 0) + r = 3.14159265 - r; + if (y < 0) + r = -r; + + return r; + } + + /** + * @brief acos(x). + * + * @param x as an input + * @return acos(x) in range [-pi/2, pi/2] + */ + inline float acos(float x) + { + return atan2(x, sqrt_newton(1.0 - x * x)); + } + + /** + * @brief asin(x). + * + * @param x as an input + * @return asin(x) in range [0, pi] + */ + inline float asin(float x) + { + return atan2(sqrt_newton(1.0 - x * x), x); + } + + /** + * @brief e^x + * + * @param x exponent + * @param steps iteration steps + * @return e^x + */ + inline float exp_fast(double x, int steps) + { + x = 1.0 + x / (1 << steps); + for (int i = 0; i < steps; i++) + x *= x; + return x; + } + } +} \ No newline at end of file diff --git a/tools/sdk/esp32s2/include/esp-face/include/math/dl_math_matrix.hpp b/tools/sdk/esp32s2/include/esp-face/include/math/dl_math_matrix.hpp new file mode 100644 index 00000000000..30718f85c32 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/math/dl_math_matrix.hpp @@ -0,0 +1,397 @@ +#pragma once + +#include +#include +#include +#include +#include "dl_define.hpp" +#include "dl_tool.hpp" +#include "dl_variable.hpp" +#include "esp_timer.h" + +namespace dl +{ + namespace math + { + /** + * @brief the Matrix class + * + * @tparam T + */ + template + class Matrix + { + public: + T **array; + int h; + int w; + Matrix() : h(0), w(0) + { + this->array = NULL; + } + + Matrix(int h, int w) : h(h), w(w) + { + this->calloc_element(); + } + + Matrix(int h, int w, T s) : h(h), w(w) + { + this->calloc_element(); + this->set_value(s); + } + + Matrix(const Matrix &mat) : h(mat.h), w(mat.w) + { + this->calloc_element(); + this->set_value(mat); + } + virtual ~Matrix() + { + if (this->array != NULL) + { + for (int i = 0; i < this->h; i++) + { + free(this->array[i]); + } + free(this->array); + this->array = NULL; + } + } + + /** + * @brief calloc the matrix element + * + */ + void calloc_element() + { + if ((this->h > 0) && (this->w > 0)) + { + this->array = (T **)calloc(this->h, sizeof(T *)); + for (int i = 0; i < this->h; i++) + { + this->array[i] = (T *)calloc(this->w, sizeof(T)); + } + } + else + { + this->array = NULL; + } + } + + /** + * @brief Set the matrix element to random number. + * + * @param thresh the max abs value of the element. + */ + void set_random(T thresh = 1) + { + unsigned int seed = esp_timer_get_time(); + srand(seed); + for (int i = 0; i < this->h; i++) + { + for (int j = 0; j < this->w; j++) + { + this->array[i][j] = ((T)rand()) / (T)(RAND_MAX)*thresh; + } + } + } + + /** + * @brief Set the small value to zero + * + * @param thresh the threshold of small value + */ + void set_zero(T thresh = 1e-8) + { + for (int i = 0; i < this->h; i++) + { + for (int j = 0; j < this->w; j++) + { + if (DL_ABS(this->array[i][j]) < thresh) + { + this->array[i][j] = 0; + } + } + } + } + + /** + * @brief Set the matrix value from a vector + * + * @tparam TT + * @param mat the input vector + */ + template + void set_value(std::vector mat) + { + int area = this->w * this->h; + assert(area == mat.size()); + int index = 0; + for (int i = 0; i < this->h; i++) + { + for (int j = 0; j < this->w; j++) + { + this->array[i][j] = (T)(mat[index++]); + } + } + } + + /** + * @brief Set the matrix value from another matrix. + * + * @tparam TT + * @param mat the input matrix. + */ + template + void set_value(const Matrix &mat) + { + assert((this->h == mat.h) && (this->w == mat.w)); + for (int i = 0; i < this->h; i++) + { + for (int j = 0; j < this->w; j++) + { + this->array[i][j] = (T)(mat.array[i][j]); + } + } + } + + /** + * @brief Set a part of the matrix value from another matrix. + * + * @param h_start the start index of height + * @param h_end the end index of height + * @param w_start the start index of width + * @param w_end the end index of width + * @param mat the input matrix + */ + void set_value(int h_start, int h_end, int w_start, int w_end, const Matrix &mat) + { + int h = h_end - h_start; + int w = w_end - w_start; + + assert((h == mat.h) && (w == mat.w)); + assert((h_end <= this->h) && (w_end <= this->w) && (h_start >= 0) && (w_start >= 0)); + for (int i = 0; i < h; i++) + { + for (int j = 0; j < w; j++) + { + this->array[i + h_start][j + w_start] = mat.array[i][j]; + } + } + } + + /** + * @brief Set the matrix value to a constant. + * + * @tparam TT + * @param s the input value. + */ + template + void set_value(TT s) + { + for (int i = 0; i < this->h; i++) + { + for (int j = 0; j < this->w; j++) + { + this->array[i][j] = (T)s; + } + } + } + + /** + * @brief print the matrix element. + * + */ + void print_value() const + { + printf("h: %d, w: %d\n", this->h, this->w); + for (int i = 0; i < this->h; i++) + { + for (int j = 0; j < this->w; j++) + { + printf("%f ", (float)(this->array[i][j])); + } + printf("\n"); + } + } + + /** + * @brief do matrix multiply + * + * @param input the input matrix + * @return Matrix the output matrix + */ + Matrix matmul(const Matrix &input) const; + + /** + * @brief transpose the matrix + * + * @return Matrix the transposed matrix + */ + Matrix transpose() const; + + /** + * @brief get the inverse matrix + * + * @return Matrix the output matrix + */ + Matrix inverse() const; + + /** + * @brief get the diagonal of the matrix + * + * @return Matrix the diagonal + */ + Matrix diagonal() const; + + /** + * @brief slice the matrix + * + * @param h_start the start index of height + * @param h_end the end index of height + * @param w_start the start index of width + * @param w_end the end index of width + * @return Matrix the output. + */ + Matrix slice(int h_start, int h_end, int w_start, int w_end) const; + + /** + * @brief get an identity matrix + * + * @param n the dim of the identity matrix + * @return Matrix the output + */ + static Matrix identity(int n) + { + Matrix A(n, n); + for (int i = 0; i < n; ++i) + { + A.array[i][i] = 1; + } + return A; + } + + /** + * @brief get a diag matrix + * + * @param d the diagonal value. + * @return Matrix the output + */ + static Matrix diag(const Matrix &d) + { + assert(d.h == 1); + Matrix A(d.w, d.w); + for (int i = 0; i < d.w; ++i) + { + A.array[i][i] = d.array[0][i]; + } + return A; + } + + + static Matrix arange(uint32_t n) + { + Matrix A(1, n); + for (int i = 0; i < n; ++i) + { + A.array[0][i] = i; + } + return A; + } + + static Matrix arange(uint32_t n1, uint32_t n2) + { + int len = n2 - n1; + assert(len > 0); + Matrix A(1, len); + for (int i = 0; i < len; ++i) + { + A.array[0][i] = n1 + i; + } + + return A; + } + + /** + * @brief get the F_norm of the matrix + * + * @return T the output F_norm + */ + T F_norm() const + { + T f_n = 0.0; + for (int i = 0; i < this->h; ++i) + { + for (int j = 0; j < this->w; ++j) + { + f_n += (this->array[i][j] * this->array[i][j]); + } + } + f_n = sqrt_newton(f_n); + return f_n; + } + + Matrix &operator=(const Matrix &A) + { + if ((A.h == this->h) && (A.w == this->w)) + { + for (int i = 0; i < A.h; ++i) + { + for (int j = 0; j < A.w; ++j) + { + this->array[i][j] = A.array[i][j]; + } + } + } + else + { + if (this->array != NULL) + { + for (int i = 0; i < this->h; ++i) + { + free(this->array[i]); + } + free(this->array); + this->array = NULL; + } + this->h = A.h; + this->w = A.w; + if ((A.h > 0) && (A.w > 0)) + { + this->calloc_element(); + this->set_value(A); + } + } + return *this; + } + }; + + /** + * @brief Get the affine transform matrix + * + * @param source_coord the source coordinates + * @param dest_coord the target coordinates + * @return Matrix the output matrix + */ + Matrix get_affine_transform(Matrix &source_coord, Matrix &dest_coord); + + /** + * @brief Get the similarity transform matrix + * + * @param source_coord the source coordinates + * @param dest_coord the target coordinates + * @return Matrix the output matrix + */ + Matrix get_similarity_transform(Matrix &source_coord, Matrix &dest_coord); + + /** + * @brief Get the perspective transform matrix + * + * @param source_coord the source coordinates + * @param dest_coord the target coordinates + * @return Matrix the output matrix + */ + Matrix get_perspective_transform(Matrix &source_coord, Matrix &dest_coord); + } // namespace math +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32s2/include/esp-face/include/model_zoo/cat_face_detect_mn03.hpp b/tools/sdk/esp32s2/include/esp-face/include/model_zoo/cat_face_detect_mn03.hpp new file mode 100644 index 00000000000..6d952dc44ab --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/model_zoo/cat_face_detect_mn03.hpp @@ -0,0 +1,47 @@ +#pragma once + +#include +#include +#include +#include "dl_detect_define.hpp" + +/** + * @brief Hardware Requirement. + * - flash 310kB + */ + +class CatFaceDetectMN03 +{ +private: + void *model; + +public: + /** + * @brief Construct a new Cat Face Detect MN03 object. + * + * @param score_threshold predicted boxes with score lower than the threshold will be filtered out + * @param nms_threshold predicted boxes with IoU higher than the threshold will be filtered out + * @param top_k first k highest score boxes will be remained + * @param resize_scale resize scale to implement on input image + */ + CatFaceDetectMN03(const float score_threshold, const float nms_threshold, const int top_k, const float resize_scale); + + /** + * @brief Destroy the Cat Face Detect MN03 object. + * + */ + ~CatFaceDetectMN03(); + + /** + * @brief Inference. + * + * @tparam T supports uint8_t and uint16_t + * - uint8_t: input image is RGB888 + * - uint16_t: input image is RGB565 + * @param input_element pointer of input image + * @param input_shape shape of input image + * @return detection result + */ + template + std::list &infer(T *input_element, std::vector input_shape); +}; diff --git a/tools/sdk/esp32s2/include/esp-face/include/model_zoo/face_recognition_112_v1_s16.hpp b/tools/sdk/esp32s2/include/esp-face/include/model_zoo/face_recognition_112_v1_s16.hpp new file mode 100644 index 00000000000..91f7747fe3f --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/model_zoo/face_recognition_112_v1_s16.hpp @@ -0,0 +1,30 @@ +#pragma once + +#include "dl_variable.hpp" +#include "face_recognition_tool.hpp" +#include "face_recognizer.hpp" +#include + +using namespace dl; + +/** + * @brief face recognition model v1 + * input size: 112 x 112 x 3 + * quantization mode: S16 + * + */ +class FaceRecognition112V1S16 : public FaceRecognizer +{ + public: + /** + * @brief Construct a new Face_Recognition_112_V1_S16 object + * + */ + FaceRecognition112V1S16(); + + /** + * @brief Destroy the Face_Recognition_112_V1_S16 object + * + */ + ~FaceRecognition112V1S16(); +}; \ No newline at end of file diff --git a/tools/sdk/esp32s2/include/esp-face/include/model_zoo/face_recognition_112_v1_s8.hpp b/tools/sdk/esp32s2/include/esp-face/include/model_zoo/face_recognition_112_v1_s8.hpp new file mode 100644 index 00000000000..ba377713ca2 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/model_zoo/face_recognition_112_v1_s8.hpp @@ -0,0 +1,30 @@ +#pragma once + +#include "dl_variable.hpp" +#include "face_recognition_tool.hpp" +#include "face_recognizer.hpp" +#include + +using namespace dl; + +/** + * @brief face recognition model v1 + * input size: 112 x 112 x 3 + * quantization mode: S8 + * + */ +class FaceRecognition112V1S8 : public FaceRecognizer +{ + public: + /** + * @brief Construct a new Face_Recognition_112_V1_S8 object + * + */ + FaceRecognition112V1S8(); + + /** + * @brief Destroy the Face Recognition_112_V1_S8 object + * + */ + ~FaceRecognition112V1S8(); +}; \ No newline at end of file diff --git a/tools/sdk/esp32s2/include/esp-face/include/model_zoo/face_recognition_tool.hpp b/tools/sdk/esp32s2/include/esp-face/include/model_zoo/face_recognition_tool.hpp new file mode 100644 index 00000000000..12fe8a842a2 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/model_zoo/face_recognition_tool.hpp @@ -0,0 +1,162 @@ +#pragma once + +#include "dl_variable.hpp" +#include "dl_define.hpp" +#include "dl_tool.hpp" +#include "dl_math.hpp" +#include "dl_math_matrix.hpp" +#include +#include +#include +#include +#include + +/** + * @brief struct of face similarity + * + */ +typedef struct +{ + int id; + std::string name; + float similarity; +} face_info_t; + + +/** + * @brief Face ID + * + * @tparam feature_t + */ +template +class FaceID +{ +public: + int id; /**/ + dl::Tensor id_emb; /**/ + std::string name; /**/ + + /** + * @brief Construct a new Face ID object + * + * @param id id index + * @param id_emb id embedding + * @param name id name + */ + FaceID(int id, dl::Tensor &id_emb, std::string name = ""); + + /** + * @brief Destroy the Face ID object + * + */ + ~FaceID() {} + + /** + * @brief print the face id information + * + */ + void print(); +}; + +namespace face_recognition_tool +{ + /** + * @brief l2 normalize the feautre + * + * @param feature + */ + void l2_norm(dl::Tensor &feature); + + /** + * @brief calculate the cosine distance of the input ids + * + * @param id_1 id 1 + * @param id_2 id 2 + * @param normalized_ids true: the input ids have been normalized. + * false: the input ids have not been normlized + * @param type 0: cos dist: [-1, 1] + * 1: normalzied cos dist: [0, 1] + * @return float the cosine distance + */ + float cos_distance(dl::Tensor &id_1, dl::Tensor &id_2, bool normalized_ids = true, int8_t type = 0); + + /** + * @brief transform the image to the input of a mfn model + * + * @tparam T + * @param image the input image. + * @param free_input true: free the input image. + * false: do not free the input image. + * @param do_padding true: pad the result. + * false: do not pad the result. + * @return dl::Tensor* + */ + template + dl::Tensor *transform_mfn_input(dl::Tensor &image, bool free_input = false, bool do_padding = true); + + /** + * @brief transform the image to the input of a mfn model + * + * @tparam T + * @param image the input image. + * @param output the preprocessed image. + * @param free_input true: free the input image. + * false: do not free the input image. + * @param do_padding true: pad the result. + * false: do not pad the result + */ + template + void transform_mfn_input(dl::Tensor &image, dl::Tensor &output, bool free_input = false, bool do_padding = true); + + /** + * @brief transform the mfn output embedding to a floating embedding + * + * @tparam T + * @param input the input embedding. + * @param norm true: normalize the output embedding. + * false: do not normalize the output embedding. + * @param free_input true: free the input embedding. + * false: do not free the input embedding. + * @return dl::Tensor* + */ + template + dl::Tensor *transform_mfn_output(dl::Tensor &input, bool norm = true, bool free_input = false); + + /** + * @brief transform the mfn output embedding to a floating embedding + * + * @tparam T + * @param input the input embedding. + * @param output the output embedding. + * @param norm true: normalize the output embedding. + * false: do not normalize the output embedding. + * @param free_input true: free the input embedding. + * false: do not free the input embedding. + */ + template + void transform_mfn_output(dl::Tensor &input, dl::Tensor &output, bool norm = true, bool free_input = false); + + /** + * @brief get the aligned face. + * + * @tparam T + * @param input input tensor + * @param output the output aligned face. + * @param landmarks the landmarks of the face. + */ + template + void align_face(dl::Tensor *input, dl::Tensor *output, std::vector &landmarks); + + /** + * @brief get the aligned face. + * + * @tparam T + * @param input input image with rgb565 format. + * @param shape the shape of the input image. + * @param output the output aligned face. + * @param landmarks the landmarks of the face. + */ + template + void align_face(uint16_t *input, std::vector shape, dl::Tensor *output, std::vector &landmarks); + +} // namespace face_recognition_tool diff --git a/tools/sdk/esp32s2/include/esp-face/include/model_zoo/face_recognizer.hpp b/tools/sdk/esp32s2/include/esp-face/include/model_zoo/face_recognizer.hpp new file mode 100644 index 00000000000..864881c984a --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/model_zoo/face_recognizer.hpp @@ -0,0 +1,220 @@ +#pragma once + +#include "dl_variable.hpp" +#include "face_recognition_tool.hpp" +#include + +using namespace dl; + +/** + * @brief + * + * @tparam feature_t + */ +template +class FaceRecognizer +{ + public: + /** + * @brief Construct a new Face Recognizer object + * + */ + FaceRecognizer(); + + /** + * @brief Destroy the Face Recognizer object + * + */ + virtual ~FaceRecognizer(); + + void *model; + + /** + * @brief Set the face recognition threshold [-1, 1], default thresh: 0.55 + * Note: If the similarity of two faces is greater than the threshold, they will be judged as the same person + * + * @param thresh + */ + void set_thresh(float thresh); + + /** + * @brief Get the current threshold of recognizer. + * + * @return float current threshold. + */ + float get_thresh(); + + /** + * @brief Get the input shape of the recognizer. + * + * @return std::vector the input shape of the recognizer. + */ + std::vector get_input_shape(); + + /** + * @brief do forward + * + * @param model_input the input data of the face recognition model. + * Note: the input data should have been preprocessed. + * @return Tensor& the output of the face recognition model. + */ + Tensor &forward(Tensor &model_input); + + /** + * @brief recognize face + * + * @param image_input the pointer of the input image with format bgr565. + * @param shape the shape of the input image + * @param landmarks face landmarks coordinates + * @return face_info_t the recognition result. + */ + face_info_t recognize(uint16_t *image_input, std::vector shape, std::vector &landmarks); + + /** + * @brief recognize face + * + * @param image_input the pointer of the input image with format bgr565. + * @param shape the shape of the input image + * @param aligned_face the Tensor to store the intermeidate aligned face. + * @param landmarks face landmarks coordinates + * @return face_info_t the recognition result. + */ + face_info_t recognize(uint16_t *image_input, std::vector shape, Tensor &aligned_face, std::vector &landmarks); + + /** + * @brief recognize face + * + * @param image_input the Tensor of input image with format bgr888. + * @param landmarks face landmarks coordinates + * @return face_info_t the recognition result. + */ + face_info_t recognize(Tensor &image_input, std::vector &landmarks); + + /** + * @brief recognize face + * + * @param image_input the Tensor of input image with format bgr888. + * @param aligned_face the Tensor to store the intermeidate aligned face. + * @param landmarks face landmarks coordinates + * @return face_info_t the recognition result. + */ + face_info_t recognize(Tensor &image_input, Tensor &aligned_face, std::vector &landmarks); + + /** + * @brief recognize face + * + * @param aligned_face the Tensor of the input aligned face with format bgr888. + * @return face_info_t the recognition result. + */ + face_info_t recognize(Tensor &aligned_face); + + /** + * @brief recognize the face embedding. + * + * @param emb the normalized face embbeding. + * @return face_info_t the recognition result. + */ + face_info_t recognize(Tensor &emb); + + /** + * @brief Get the index of the enrolled ids + * + * @return std::vector a vector of face ids index + */ + std::vector get_enrolled_ids(); + + /** + * @brief Get the face embedding + * + * @param id the face id index + * @return Tensor the face embedding of the face id index. + * if there is no matched id return the embedding of last input image. + */ + Tensor &get_face_emb(int id=-1); + + /** + * @brief Get the number of enrolled id + * + * @return int the number of enrolled id + */ + int get_enrolled_id_num(); + + /** + * @brief enroll face id + * + * @param image_input the pointer of the input image with format bgr565. + * @param shape the shape of the input image + * @param landmarks face landmarks coordinates + * @param name name of the face id. + * @return int the face id index of the enrolled embedding. + */ + int enroll_id(uint16_t *image_input, std::vector shape, std::vector &landmarks, std::string name=""); + + /** + * @brief enroll face id + * + * @param image_input the pointer of the input image with format bgr565. + * @param shape the shape of the input image + * @param aligned_face the Tensor to store the intermeidate aligned face. + * @param landmarks face landmarks coordinates + * @param name name of the face id. + * @return int the face id index of the enrolled embedding. + */ + int enroll_id(uint16_t *image_input, std::vector shape, Tensor &aligned_face, std::vector &landmarks, std::string name=""); + + /** + * @brief enroll face id + * + * @param image_input the Tensor of input image with format bgr888. + * @param landmarks face landmarks coordinates + * @param name name of the face id. + * @return int the face id index of the enrolled embedding. + */ + int enroll_id(Tensor &image_input, std::vector &landmarks, std::string name=""); + + /** + * @brief enroll face id + * + * @param image_input the Tensor of input image with format bgr888. + * @param aligned_face the Tensor to store the intermeidate aligned face. + * @param landmarks face landmarks coordinates + * @param name name of the face id. + * @return int the face id index of the enrolled embedding. + */ + int enroll_id(Tensor &image_input, Tensor &aligned_face, std::vector &landmarks, std::string name=""); + + /** + * @brief enroll face id + * + * @param aligned_face the Tensor of the input aligned face with format bgr888. + * @param name name of the face id. + * @return int the face id index of the enrolled embedding. + */ + int enroll_id(Tensor &aligned_face, std::string name=""); + + /** + * @brief enroll the normalzied face embedding. + * + * @param emb the normalized face embbeding. + * @param name name of the face id. + * @return int the face id index of the enrolled embedding. + */ + int enroll_id(Tensor &emb, std::string name=""); + + /** + * @brief delete the last enrolled face id. + * + * @return int the number of remained face ids. + * if the face ids list is empty, return -1 + */ + int delete_id(); + + /** + * @brief delete the face id with id index. + * + * @param id face id index. + * @return int the number of remained face ids. + * if there is no matched id return -1 + */ + int delete_id(int id); +}; \ No newline at end of file diff --git a/tools/sdk/esp32s2/include/esp-face/include/model_zoo/human_face_detect_mnp01.hpp b/tools/sdk/esp32s2/include/esp-face/include/model_zoo/human_face_detect_mnp01.hpp new file mode 100644 index 00000000000..62a25f0350c --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/model_zoo/human_face_detect_mnp01.hpp @@ -0,0 +1,41 @@ +#pragma once + +#include +#include +#include "dl_detect_define.hpp" + +class HumanFaceDetectMNP01 +{ +private: + void *model; + +public: + /** + * @brief Construct a new Human Face Detect MNP01 object. + * + * @param score_threshold predicted boxes with score lower than the threshold will be filtered out + * @param nms_threshold predicted boxes with IoU higher than the threshold will be filtered out + * @param top_k first k highest score boxes will be remained + */ + HumanFaceDetectMNP01(const float score_threshold, const float nms_threshold, const int top_k); + + /** + * @brief Destroy the Human Face Detect MNP01 object. + * + */ + ~HumanFaceDetectMNP01(); + + /** + * @brief Inference. + * + * @tparam T supports uint16_t and uint8_t, + * - uint16_t: input image is RGB565 + * - uint8_t: input image is RGB888 + * @param input_element pointer of input image + * @param input_shape shape of input image + * @param candidates candidate boxes on input image + * @return detection result + */ + template + std::list &infer(T *input_element, std::vector input_shape, std::list &candidates); +}; diff --git a/tools/sdk/esp32s2/include/esp-face/include/model_zoo/human_face_detect_msr01.hpp b/tools/sdk/esp32s2/include/esp-face/include/model_zoo/human_face_detect_msr01.hpp new file mode 100644 index 00000000000..94ba6ac909a --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/model_zoo/human_face_detect_msr01.hpp @@ -0,0 +1,40 @@ +#pragma once + +#include +#include +#include "dl_detect_define.hpp" + +class HumanFaceDetectMSR01 +{ +private: + void *model; + +public: + /** + * @brief Construct a new Human Face Detect MSR01 object + * + * @param score_threshold predicted boxes with score lower than the threshold will be filtered out + * @param nms_threshold predicted boxes with IoU higher than the threshold will be filtered out + * @param top_k first k highest score boxes will be remained + * @param resize_scale resize scale to implement on input image + */ + HumanFaceDetectMSR01(const float score_threshold, const float nms_threshold, const int top_k, float resize_scale); + + /** + * @brief Destroy the Human Face Detect MSR01 object + */ + ~HumanFaceDetectMSR01(); + + /** + * @brief Inference. + * + * @tparam T supports uint8_t and uint16_t + * - uint8_t: input image is RGB888 + * - uint16_t: input image is RGB565 + * @param input_element pointer of input image + * @param input_shape shape of input image + * @return detection result + */ + template + std::list &infer(T *input_element, std::vector input_shape); +}; diff --git a/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn.hpp b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn.hpp new file mode 100644 index 00000000000..6dba8016f26 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn.hpp @@ -0,0 +1,61 @@ +#pragma once +#include +#include "dl_define.hpp" +#include "dl_tool.hpp" + +namespace dl +{ + namespace nn + { + /** + * @brief Get the output shape object + * + * @param input_shape input shape + * @param filter_shape filter shape with dilation + * @param stride_y stride in height + * @param stride_x stride in width + * @param pad_type one of PADDING_VALID or PADDING_SAME or PADDING_SAME_MXNET + * @param is_conv2d one of true or false, + * - true: serve for Conv2D + * - false: serve for other operations + * @return std::vector + */ + std::vector get_output_shape(const std::vector &input_shape, const std::vector &filter_shape, const int stride_y, const int stride_x, const padding_type_t pad_type, const bool is_conv2d = false); + + /** + * @brief Get the pad size object + * + * @param output_shape output shape + * @param input_shape input shape + * @param filter_shape filter shape with dilation + * @param stride_y stride in height + * @param stride_x stride in width + * @param padding_type one of PADDING_VALID or PADDING_SAME or PADDING_SAME_MXNET + * @return padding size + */ + std::vector get_pad_size(const std::vector &output_shape, const std::vector &input_shape, const std::vector &filter_shape, const int stride_y, const int stride_x, const padding_type_t padding_type); + } // namespace nn +} // namespace dl + +#if DL_LOG_NN_LATENCY +/** + * @brief Initialize. + */ +#define DL_LOG_NN_LATENCY_INIT() dl::tool::Latency latency + +/** + * @brief Time starts. + */ +#define DL_LOG_NN_LATENCY_START() latency.start() + +/** + * @brief Time ends and printed. + */ +#define DL_LOG_NN_LATENCY_END(key) \ + latency.end(); \ + latency.print("nn", key) +#else +#define DL_LOG_NN_LATENCY_INIT() +#define DL_LOG_NN_LATENCY_START() +#define DL_LOG_NN_LATENCY_END(key) +#endif diff --git a/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_add2d.hpp b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_add2d.hpp new file mode 100644 index 00000000000..d296be5350b --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_add2d.hpp @@ -0,0 +1,91 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn.hpp" + +namespace dl +{ + namespace nn + { + /** + * @brief activation(add2d(input0, input1)). + * + * @param output as an output + * @param input0 as one input + * @param input1 as another input + * @param activation activation of add2d, if you don't specify anything, no activation is applied + * @param assign_core not effective yet + * @param output_exponent exponent of output, only and must specify if inplace operation happens + */ + void add2d(Tensor &output, + Tensor &input0, + Tensor &input1, + const Activation *const activation = NULL, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE, + const int output_exponent = INT_MIN); + + /** + * @brief activation(add2d(input0, input1)). + * + * @param output as an output + * @param input0 as one input + * @param input1 as another input + * @param activation activation of add2d, if you don't specify anything, no activation is applied + * @param assign_core not effective yet + * @param output_exponent exponent of output, only and must specify if inplace operation happens + */ + void add2d(Tensor &output, + Tensor &input0, + Tensor &input1, + const Activation *const activation = NULL, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE, const int output_exponent = INT_MIN); + + /** + * @brief activation(add2d(input0, input1)) + * + * @tparam inplace: whether directly store the output to input0 + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + * @param output_exponent exponent of output + * @param input0 as one input + * @param input1 as another input + * @param activation activation of add2d, if you don't specify anything, no activation is applied + * @param assign_core not effective yet + * @param inplace whether directly store the output to input0 + * @return add2d result or no return(result store to input0) + */ + template + auto add2d(const int output_exponent, + Tensor &input0, + Tensor &input1, + const Activation *activation, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) -> typename std::conditional>::type + { + assert(input0.is_same_shape(input1)); + + DL_LOG_NN_LATENCY_INIT(); + + Tensor output; + if constexpr(!inplace) + { + DL_LOG_NN_LATENCY_START(); + output.set_exponent(output_exponent).set_shape(input0.shape).apply_element(); + DL_LOG_NN_LATENCY_END("apply"); + + DL_LOG_NN_LATENCY_START(); + add2d(output, input0, input1, activation, assign_core); + DL_LOG_NN_LATENCY_END("add2d"); + return output; + } + else + { + DL_LOG_NN_LATENCY_START(); + add2d(input0, input0, input1, activation, assign_core, output_exponent); + input0.set_exponent(output_exponent); + DL_LOG_NN_LATENCY_END("add2d"); + } + } + } // namespace nn +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_avg_pool2d.hpp b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_avg_pool2d.hpp new file mode 100644 index 00000000000..5b298d98c44 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_avg_pool2d.hpp @@ -0,0 +1,102 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn.hpp" +#include + +namespace dl +{ + namespace nn + { + /** + * @brief avg_pool2d(input). + * + * @param output as an output + * @param input as an input + * @param padding padding size needed in [top, bottom, left, right] of this operation + * @param filter_shape filter_shape in [filter_height, filter_width] + * @param stride_y stride in height + * @param stride_x stride in width + * @param assign_core not effective yet + */ + void avg_pool2d(Tensor &output, + Tensor &input, + std::vector &padding, + std::vector &filter_shape, + const int stride_y, + const int stride_x, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief avg_pool2d(input). + * + * @param output as an output + * @param input as an input + * @param padding padding size needed in [top, bottom, left, right] of this operation + * @param filter_shape filter_shape in [filter_height, filter_width] + * @param stride_y stride in height + * @param stride_x stride in width + * @param assign_core not effective yet + */ + void avg_pool2d(Tensor &output, + Tensor &input, + std::vector &padding, + std::vector &filter_shape, + const int stride_y, + const int stride_x, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief avg_pool2d(input). + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + * @param output_exponent exponent of output + * @param input as an input + * @param filter_shape filter_shape in [filter_height, filter_width] + * @param stride_y stride in height + * @param stride_x stride in width + * @param padding_type one of PADDING_VALID or PADDING_SAME or PADDING_SAME_MXNET, + * - PADDING_VALID: no padding + * PADDING_SAME and PADDING_SAME_MXNET results in padding with zeros evenly to the left/right or up/down of the input + * such that output has the same height/width dimension as the input, + * - PADDING_SAME results padding in TensorFlow style + * - PADDING_SAME_MXNET results padding in MXNET style + * @param assign_core not effective yet + * @return avg_pool2d result + */ + template + Tensor avg_pool2d(const int output_exponent, + Tensor &input, + std::vector filter_shape, + const int stride_y, + const int stride_x, + const padding_type_t padding_type, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_NN_LATENCY_INIT(); + + DL_LOG_NN_LATENCY_START(); + std::vector output_shape = get_output_shape(input.shape, filter_shape, stride_y, stride_x, padding_type); + Tensor output; + output.set_exponent(output_exponent).set_shape(output_shape).apply_element(); + DL_LOG_NN_LATENCY_END("apply"); + + DL_LOG_NN_LATENCY_START(); + if (padding_type == PADDING_SAME || padding_type == PADDING_SAME_MXNET) + { + std::vector padding = get_pad_size(output_shape, input.shape, filter_shape, stride_y, stride_x, padding_type); + input.set_padding_size(padding); + } + DL_LOG_NN_LATENCY_END("padding"); + + DL_LOG_NN_LATENCY_START(); + avg_pool2d(output, input, input.padding, filter_shape, stride_y, stride_x, assign_core); + DL_LOG_NN_LATENCY_END("avg_pool2d"); + + return output; + } + } // namespace nn +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_concat2d.hpp b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_concat2d.hpp new file mode 100644 index 00000000000..adcae1e7a7d --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_concat2d.hpp @@ -0,0 +1,22 @@ +#pragma once + +#include +#include "dl_variable.hpp" + +namespace dl +{ + namespace nn + { + /** + * @brief concat2d(input_1, input_2, ...) + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + * @param output as an output + * @param inputs a bundle of inputs to be concatenated + */ + template + void concat2d(Tensor &output, std::vector> inputs); + } // namespace nn +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_conv2d.hpp b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_conv2d.hpp new file mode 100644 index 00000000000..77e2c617d04 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_conv2d.hpp @@ -0,0 +1,116 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn.hpp" + +namespace dl +{ + namespace nn + { + /** + * @brief activation(conv2d(input, filter) + bias). + * NOTE: When padding_type is SAME, make sure padding is already added in input. + * + * @param output as an output + * @param input as an input + * @param padding padding size needed in [top, bottom, left, right] of this operation + * @param filter filter of conv2d + * @param stride_y stride in height + * @param stride_x stride in width + * @param bias bias of conv2d, if you don't specify anything, no bias is added + * @param activation activation of conv2d, if you don't specify anything, no activation is applied + * @param assign_core not effective yet + */ + void conv2d(Tensor &output, + Tensor &input, + std::vector &padding, + const Filter &filter, + const int stride_y, + const int stride_x, + const Bias *const bias = NULL, + const Activation *const activation = NULL, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief activation(conv2d(input, filter) + bias). + * NOTE: When padding_type is SAME, make sure padding is already added in input. + * + * @param output as an output + * @param input as an input + * @param padding padding size needed in [top, bottom, left, right] of this operation + * @param filter filter of conv2d + * @param stride_y stride in height + * @param stride_x stride in width + * @param bias bias of conv2d, if you don't specify anything, no bias is added + * @param activation activation of conv2d, if you don't specify anything, no activation is applied + * @param assign_core not effective yet + */ + void conv2d(Tensor &output, + Tensor &input, + std::vector &padding, + const Filter &filter, + const int stride_y, + const int stride_x, + const Bias *const bias = NULL, + const Activation *const activation = NULL, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief activation(conv2d(input, filter) + bias). + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + * @param output_exponent exponent of output + * @param input as an input + * @param filter Filter of conv2d + * @param stride_y stride in height + * @param stride_x stride in width + * @param padding_type one of PADDING_VALID or PADDING_SAME or PADDING_SAME_MXNET, + * - PADDING_VALID: no padding + * PADDING_SAME and PADDING_SAME_MXNET results in padding with zeros evenly to the left/right or up/down of the input + * such that output has the same height/width dimension as the input, + * - PADDING_SAME results padding in TensorFlow style + * - PADDING_SAME_MXNET results padding in MXNET style + * @param bias bias of conv2d, if you don't specify anything, no bias is added + * @param activation activation of conv2d, if you don't specify anything, no activation is applied + * @param assign_core not effective yet + * @return conv2d result + */ + template + Tensor conv2d(const int output_exponent, + Tensor &input, + const Filter &filter, + const int stride_y, + const int stride_x, + const padding_type_t padding_type, + const Bias *bias, + const Activation *activation, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_NN_LATENCY_INIT(); + + DL_LOG_NN_LATENCY_START(); + std::vector output_shape = get_output_shape(input.shape, filter.shape_with_dilation, stride_y, stride_x, padding_type, true); + Tensor output; + output.set_exponent(output_exponent).set_shape(output_shape).apply_element(); + DL_LOG_NN_LATENCY_END("apply"); + + DL_LOG_NN_LATENCY_START(); + if (padding_type == PADDING_SAME || padding_type == PADDING_SAME_MXNET) + { + std::vector padding = get_pad_size(output_shape, input.shape, filter.shape_with_dilation, stride_y, stride_x, padding_type); + input.set_padding_size(padding); + input.set_padding_value(padding, 0); + } + DL_LOG_NN_LATENCY_END("padding"); + + DL_LOG_NN_LATENCY_START(); + conv2d(output, input, input.padding, filter, stride_y, stride_x, bias, activation, assign_core); + DL_LOG_NN_LATENCY_END("conv2d"); + + return output; + } + } // namespace nn +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_depthwise_conv2d.hpp b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_depthwise_conv2d.hpp new file mode 100644 index 00000000000..6e972bfd81b --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_depthwise_conv2d.hpp @@ -0,0 +1,116 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn.hpp" + +namespace dl +{ + namespace nn + { + /** + * @brief activate(depthwise_conv2d(input, filter) + bias) + * NOTE: When padding_type is SAME, make sure padding is already added in input + * + * @param output as an output + * @param input as an input + * @param padding padding size needed in [top, bottom, left, right] of this operation + * @param filter Filter of depthwise_conv2d + * @param stride_y stride in height + * @param stride_x stride in width + * @param bias bias of depthwise_conv2d, if you don't specify anything, no bias is added + * @param activation activation of depthwise_conv2d, if you don't specify anything, no activation is applied + * @param assign_core not effective yet + */ + void depthwise_conv2d(Tensor &output, + Tensor &input, + std::vector &padding, + const Filter &filter, + const int stride_y, + const int stride_x, + const Bias *bias = NULL, + const Activation *activation = NULL, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief activate(depthwise_conv2d(input, filter) + bias) + * NOTE: When padding_type is SAME, make sure padding is already added in input + * + * @param output as an output + * @param input as an input + * @param padding padding size needed in [top, bottom, left, right] of this operation + * @param filter filter of depthwise_conv2d + * @param stride_y stride in height + * @param stride_x stride in width + * @param bias bias of depthwise_conv2d, if you don't specify anything, no bias is added + * @param activation activation of depthwise_conv2d, if you don't specify anything, no activation is applied + * @param assign_core not effective yet + */ + void depthwise_conv2d(Tensor &output, + Tensor &input, + std::vector &padding, + const Filter &filter, + const int stride_y, + const int stride_x, + const Bias *bias = NULL, + const Activation *activation = NULL, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief activation(depthwise_conv2d(input, filter) + bias) + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + * @param output_exponent exponent of output + * @param input as an input + * @param filter filter of depthwise_conv2d + * @param stride_y stride in height + * @param stride_x stride in width + * @param pad_type one of PADDING_VALID or PADDING_SAME or PADDING_SAME_MXNET, + * - PADDING_VALID means no padding + * PADDING_SAME and PADDING_SAME_MXNET results in padding with zeros evenly to the left/right or up/down of the input + * such that output has the same height/width dimension as the input, + * - PADDING_SAME results padding in TensorFlow style + * - PADDING_SAME_MXNET results padding in MXNET style + * @param bias bias of depthwise_conv2d, if you don't specify anything, no bias is added + * @param activation activation of depthwise_conv2d, if you don't specify anything, no activation is applied + * @param assign_core not effective yet + * @return depthwise_conv2d result + */ + template + Tensor depthwise_conv2d(const int output_exponent, + Tensor &input, + const Filter &filter, + const int stride_y, + const int stride_x, + const padding_type_t padding_type, + const Bias *bias, + const Activation *activation, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_NN_LATENCY_INIT(); + + DL_LOG_NN_LATENCY_START(); + std::vector output_shape = get_output_shape(input.shape, filter.shape_with_dilation, stride_y, stride_x, padding_type); + Tensor output; + output.set_exponent(output_exponent).set_shape(output_shape).apply_element(); + DL_LOG_NN_LATENCY_END("apply"); + + DL_LOG_NN_LATENCY_START(); + if (padding_type == PADDING_SAME || padding_type == PADDING_SAME_MXNET) + { + std::vector padding = get_pad_size(output_shape, input.shape, filter.shape_with_dilation, stride_y, stride_x, padding_type); + input.set_padding_size(padding); + input.set_padding_value(padding, 0); + } + DL_LOG_NN_LATENCY_END("padding"); + + DL_LOG_NN_LATENCY_START(); + depthwise_conv2d(output, input, input.padding, filter, stride_y, stride_x, bias, activation, assign_core); + DL_LOG_NN_LATENCY_END("depthwise_conv2d"); + + return output; + } + } // namespace nn +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_global_avg_pool2d.hpp b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_global_avg_pool2d.hpp new file mode 100644 index 00000000000..723ca9eddc4 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_global_avg_pool2d.hpp @@ -0,0 +1,66 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn.hpp" +#include + +namespace dl +{ + namespace nn + { + /** + * @brief global_avg_pool2d(input). + * + * @param output as an output + * @param input as an input + * @param assign_core not effective yet + */ + void global_avg_pool2d(Tensor &output, + Tensor &input, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief global_avg_pool2d(input). + * + * @param output as an output + * @param input as an input + * @param assign_core not effective yet + */ + void global_avg_pool2d(Tensor &output, + Tensor &input, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief global_avg_pool2d(input). + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + * @param output_exponent exponent of output + * @param input as an input + * @param assign_core not effective yet + * @return global_avg_pool2d result + */ + template + Tensor global_avg_pool2d(const int output_exponent, + Tensor &input, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_NN_LATENCY_INIT(); + + DL_LOG_NN_LATENCY_START(); + std::vector output_shape(input.shape.size(), 1); + output_shape[2] = input.shape[2]; + Tensor output; + output.set_exponent(output_exponent).set_shape(output_shape).apply_element(); + DL_LOG_NN_LATENCY_END("apply"); + + DL_LOG_NN_LATENCY_START(); + global_avg_pool2d(output, input, assign_core); + DL_LOG_NN_LATENCY_END("global_avg_pool2d"); + + return output; + } + } // namespace nn +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_global_max_pool2d.hpp b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_global_max_pool2d.hpp new file mode 100644 index 00000000000..945645cfd55 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_global_max_pool2d.hpp @@ -0,0 +1,64 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn.hpp" +#include + +namespace dl +{ + namespace nn + { + /** + * @brief global_max_pool2d(input). + * + * @param output as an output + * @param input as an input + * @param assign_core not effective yet + */ + void global_max_pool2d(Tensor &output, + Tensor &input, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief global_max_pool2d(input). + * + * @param output as an output + * @param input as an input + * @param assign_core not effective yet + */ + void global_max_pool2d(Tensor &output, + Tensor &input, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief global_max_pool2d(input). + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + * @param input as an input + * @param assign_core not effective yet + * @return global_max_pool2d result + */ + template + Tensor global_max_pool2d(Tensor &input, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_NN_LATENCY_INIT(); + + DL_LOG_NN_LATENCY_START(); + std::vector output_shape(input.shape.size(), 1); + output_shape[2] = input.shape[2]; + Tensor output; + output.set_exponent(input.exponent).set_shape(output_shape).apply_element(); + DL_LOG_NN_LATENCY_END("apply"); + + DL_LOG_NN_LATENCY_START(); + global_max_pool2d(output, input, assign_core); + DL_LOG_NN_LATENCY_END("global_max_pool2d"); + + return output; + } + } // namespace nn +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_leakyrelu.hpp b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_leakyrelu.hpp new file mode 100644 index 00000000000..d3738fc44ca --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_leakyrelu.hpp @@ -0,0 +1,82 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn.hpp" + +namespace dl +{ + namespace nn + { + /** + * @brief leakyrelu(input). + * + * @param output as an output + * @param input as an input + * @param activation_alpha quantized alpha + * @param activation_exponent exponent of quantized alpha + * @param assign_core not effective yet + */ + void leakyrelu(Tensor &output, + Tensor &input, + const int16_t activation_alpha, + const int activation_exponent, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief leakyrelu(input). + * + * @param output as an output + * @param input as an input + * @param activation_alpha quantized alpha + * @param activation_exponent exponent of quantized alpha + * @param assign_core not effective yet + */ + void leakyrelu(Tensor &output, + Tensor &input, + const int8_t activation_alpha, + const int activation_exponent, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief leakyrelu(input) + * + * @tparam inplace: whether directly store the output to input + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + * @param input as an input + * @param activation_alpha quantized alpha + * @param activation_exponent exponent of quantized alpha + * @param assign_core not effective yet + * @return leakyrelu result or no return(result store to input) + */ + template + auto leakyrelu(Tensor &input, + const int activation_alpha, + const int activation_exponent, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) -> typename std::conditional>::type + { + DL_LOG_NN_LATENCY_INIT(); + Tensor output; + if constexpr(!inplace) + { + DL_LOG_NN_LATENCY_START(); + output.set_exponent(input.exponent).set_shape(input.shape).apply_element(); + DL_LOG_NN_LATENCY_END("apply"); + + DL_LOG_NN_LATENCY_START(); + leakyrelu(output, input, activation_alpha, activation_exponent, assign_core); + DL_LOG_NN_LATENCY_END("leakyrelu"); + + return output; + } + else + { + DL_LOG_NN_LATENCY_START(); + leakyrelu(input, input, activation_alpha, activation_exponent, assign_core); + DL_LOG_NN_LATENCY_END("leakyrelu"); + } + } + } // namespace nn +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_max2d.hpp b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_max2d.hpp new file mode 100644 index 00000000000..0a5e8f43221 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_max2d.hpp @@ -0,0 +1,81 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn.hpp" + +namespace dl +{ + namespace nn + { + /** + * @brief max2d(input0, input1) + * + * @param output as an output + * @param input0 as one input + * @param input1 as another input + * @param assign_core not effective yet + */ + void max2d(Tensor &output, + Tensor &input0, + Tensor &input1, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief max2d(input0, input1) + * + * @param output as an output + * @param input0 as one input + * @param input1 as another input + * @param assign_core not effective yet + * @param output_exponent exponent of output, only and must specify if inplace operation happens + */ + void max2d(Tensor &output, + Tensor &input0, + Tensor &input1, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief max2d(input0, input1) + * + * @tparam inplace: whether directly store the output to input0 + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + * @param input0 as one input + * @param input1 as another input + * @param assign_core not effective yet + * @return max2d result or no return(result store to input0) + */ + template + auto max2d(Tensor &input0, + Tensor &input1, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) -> typename std::conditional>::type + { + assert(input0.is_same_shape(input1)); + assert(input0.exponent == input1.exponent); + + DL_LOG_NN_LATENCY_INIT(); + Tensor output; + + if constexpr(!inplace) + { + DL_LOG_NN_LATENCY_START(); + output.set_exponent(input0.exponent).set_shape(input0.shape).apply_element(); + DL_LOG_NN_LATENCY_END("apply"); + + DL_LOG_NN_LATENCY_START(); + max2d(output, input0, input1, assign_core); + DL_LOG_NN_LATENCY_END("max2d"); + + return output; + } + else + { + DL_LOG_NN_LATENCY_START(); + max2d(input0, input0, input1, assign_core); + DL_LOG_NN_LATENCY_END("max2d"); + } + } + } // namespace nn +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_max_pool2d.hpp b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_max_pool2d.hpp new file mode 100644 index 00000000000..7f95f3d4278 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_max_pool2d.hpp @@ -0,0 +1,101 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn.hpp" +#include + +namespace dl +{ + namespace nn + { + /** + * @brief max_pool2d(input). + * + * @param output as an output + * @param input as an input + * @param padding padding size needed in [top, bottom, left, right] of this operation + * @param filter_shape filter shape in [filter_height, filter_width] + * @param stride_y stride in height + * @param stride_x stride in width + * @param assign_core not effective yet + */ + void max_pool2d(Tensor &output, + Tensor &input, + std::vector &padding, + std::vector &filter_shape, + const int stride_y, + const int stride_x, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief max_pool2d(input). + * + * @param output as an output + * @param input as an input + * @param padding padding size needed in [top, bottom, left, right] of this operation + * @param filter_shape filter shape in [filter_height, filter_width] + * @param stride_y stride in height + * @param stride_x stride in width + * @param assign_core not effective yet + */ + void max_pool2d(Tensor &output, + Tensor &input, + std::vector &padding, + std::vector &filter_shape, + const int stride_y, + const int stride_x, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief max_pool2d(input). + * + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + * @param input as an input + * @param filter_shape filter shape in [filter_height, filter_width] + * @param stride_y stride in height + * @param stride_x stride in width + * @param padding_type one of PADDING_VALID or PADDING_SAME or PADDING_SAME_MXNET, + * - PADDING_VALID: no padding + * PADDING_SAME and PADDING_SAME_MXNET results in padding with zeros evenly to the left/right or up/down of the input + * such that output has the same height/width dimension as the input, + * - PADDING_SAME results padding in TensorFlow style + * - PADDING_SAME_MXNET results padding in MXNET style + * @param assign_core not effective yet + * @return max_pool2d result + */ + template + Tensor max_pool2d(Tensor &input, + std::vector filter_shape, + const int stride_y, + const int stride_x, + const padding_type_t padding_type, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) + { + DL_LOG_NN_LATENCY_INIT(); + + DL_LOG_NN_LATENCY_START(); + std::vector output_shape = get_output_shape(input.shape, filter_shape, stride_y, stride_x, padding_type); + Tensor output; + output.set_exponent(input.exponent).set_shape(output_shape).apply_element(); + DL_LOG_NN_LATENCY_END("apply"); + + DL_LOG_NN_LATENCY_START(); + if (padding_type == PADDING_SAME || padding_type == PADDING_SAME_MXNET) + { + std::vector padding = get_pad_size(output_shape, input.shape, filter_shape, stride_y, stride_x, padding_type); + input.set_padding_size(padding); + input.set_padding_value(padding, 0); + } + DL_LOG_NN_LATENCY_END("padding"); + + DL_LOG_NN_LATENCY_START(); + max_pool2d(output, input, input.padding, filter_shape, stride_y, stride_x, assign_core); + DL_LOG_NN_LATENCY_END("max_pool2d"); + + return output; + } + } // namespace nn +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_min2d.hpp b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_min2d.hpp new file mode 100644 index 00000000000..71cb87d50d5 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_min2d.hpp @@ -0,0 +1,80 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn.hpp" + +namespace dl +{ + namespace nn + { + /** + * @brief min2d(input0, input1) + * + * @param output as an output + * @param input0 as one input + * @param input1 as another input + * @param assign_core + */ + void min2d(Tensor &output, + Tensor &input0, + Tensor &input1, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief min2d(input0, input1) + * + * @param output as an output + * @param input0 as one input + * @param input1 as another input + * @param assign_core + */ + void min2d(Tensor &output, + Tensor &input0, + Tensor &input1, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief min2d(input0, input1) + * + * @tparam inplace: whether directly store the output to input0 + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + * @param input0 as one input + * @param input1 as another input + * @param assign_core not effective yet + * @return min2d result or no return(result store to input0) + */ + template + auto min2d(Tensor &input0, + Tensor &input1, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) -> typename std::conditional>::type + { + assert(input0.is_same_shape(input1)); + assert(input0.exponent == input1.exponent); + + DL_LOG_NN_LATENCY_INIT(); + Tensor output; + + if constexpr(!inplace) + { + DL_LOG_NN_LATENCY_START(); + output.set_exponent(input0.exponent).set_shape(input0.shape).apply_element(); + DL_LOG_NN_LATENCY_END("apply"); + + DL_LOG_NN_LATENCY_START(); + min2d(output, input0, input1, assign_core); + DL_LOG_NN_LATENCY_END("min2d"); + + return output; + } + else + { + DL_LOG_NN_LATENCY_START(); + min2d(input0, input0, input1, assign_core); + DL_LOG_NN_LATENCY_END("min2d"); + } + } + } // namespace nn +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_mul2d.hpp b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_mul2d.hpp new file mode 100644 index 00000000000..410528a05a3 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_mul2d.hpp @@ -0,0 +1,91 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn.hpp" + +namespace dl +{ + namespace nn + { + /** + * @brief activation(mul2d(input0, input1)). + * + * @param output as an output + * @param input0 as one input + * @param input1 as another input + * @param activation activation of mul2d, if you don't specify anything, no activation is applied + * @param assign_core not effective yet + * @param output_exponent exponent of output, only and must specify if inplace operation happens + */ + void mul2d(Tensor &output, + Tensor &input0, + Tensor &input1, + const Activation *const activation = NULL, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE, + const int output_exponent = INT_MIN); + + /** + * @brief activation(mul2d(input0, input1)). + * + * @param output as an output + * @param input0 as one input + * @param input1 as another input + * @param activation activation of mul2d, if you don't specify anything, no activation is applied + * @param assign_core not effective yet + * @param output_exponent exponent of output, only and must specify if inplace operation happens + */ + void mul2d(Tensor &output, + Tensor &input0, + Tensor &input1, + const Activation *const activation = NULL, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE, + const int output_exponent = INT_MIN); + + /** + * @brief activation(mul2d(input0, input1)). + * + * @tparam inplace: whether directly store the output to input0 + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + * @param output_exponent exponent of output + * @param input0 as one input + * @param input1 as another input + * @param activation activation of mul2d, if you don't specify anything, no activation is applied + * @param assign_core not effective yet + * @return mul2d result or no return(result store to input0) + */ + template + auto mul2d(const int output_exponent, + Tensor &input0, + Tensor &input1, + const Activation *activation, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) -> typename std::conditional>::type + { + assert(input0.is_same_shape(input1)); + + DL_LOG_NN_LATENCY_INIT(); + Tensor output; + + if constexpr(!inplace) + { + DL_LOG_NN_LATENCY_START(); + output.set_exponent(output_exponent).set_shape(input0.shape).apply_element(); + DL_LOG_NN_LATENCY_END("apply"); + + DL_LOG_NN_LATENCY_START(); + mul2d(output, input0, input1, activation, assign_core); + DL_LOG_NN_LATENCY_END("mul2d"); + + return output; + } + else + { + DL_LOG_NN_LATENCY_START(); + mul2d(input0, input0, input1, activation, assign_core, output_exponent); + DL_LOG_NN_LATENCY_END("mul2d"); + } + } + } // namespace nn +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_prelu.hpp b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_prelu.hpp new file mode 100644 index 00000000000..fb4315d9fc3 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_prelu.hpp @@ -0,0 +1,82 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn.hpp" + +namespace dl +{ + namespace nn + { + /** + * @brief prelu(input). + * + * @param output as an output + * @param input as an input + * @param activation_element quantized alpha elements along channel axis + * @param activation_exponent exponent of quantized alpha elements + * @param assign_core not effective yet + */ + void prelu(Tensor &output, + Tensor &input, + const int16_t *activation_element, + const int activation_exponent, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief prelu(input). + * + * @param output as an output + * @param input as an input + * @param activation_element quantized alpha elements along channel axis + * @param activation_exponent exponent of quantized alpha elements + * @param assign_core not effective yet + */ + void prelu(Tensor &output, + Tensor &input, + const int8_t *activation_element, + const int activation_exponent, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief prelu(input) + * + * @tparam inplace: whether directly store the output to input + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + * @param input as an input + * @param activation_element quantized alpha elements along channel axis + * @param activation_exponent exponent of quantized alpha elements + * @param assign_core not effective yet + * @return prelu result or no return(result store to input) + */ + template + auto prelu(Tensor &input, + const feature_t *activation_element, + const int activation_exponent, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) -> typename std::conditional>::type + { + DL_LOG_NN_LATENCY_INIT(); + Tensor output; + if constexpr(!inplace) + { + DL_LOG_NN_LATENCY_START(); + output.set_exponent(input.exponent).set_shape(input.shape).apply_element(); + DL_LOG_NN_LATENCY_END("apply"); + + DL_LOG_NN_LATENCY_START(); + prelu(output, input, activation_element, activation_exponent, assign_core); + DL_LOG_NN_LATENCY_END("prelu"); + + return output; + } + else + { + DL_LOG_NN_LATENCY_START(); + prelu(input, input, activation_element, activation_exponent, assign_core); + DL_LOG_NN_LATENCY_END("prelu"); + } + } + } // namespace nn +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_relu.hpp b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_relu.hpp new file mode 100644 index 00000000000..e4159fdf898 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_relu.hpp @@ -0,0 +1,70 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn.hpp" + +namespace dl +{ + namespace nn + { + /** + * @brief relu(input). + * + * @param output as an output + * @param input as an input + * @param assign_core not effective yet + */ + void relu(Tensor &output, + Tensor &input, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief relu(input). + * + * @param output as an output + * @param input as an input + * @param assign_core not effective yet + */ + void relu(Tensor &output, + Tensor &input, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE); + + /** + * @brief relu(input) + * + * @tparam inplace: whether directly store the output to input + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + * @param input as an input + * @param assign_core not effective yet + * @return relu result or no return(result store to input) + */ + template + auto relu(Tensor &input, const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) -> typename std::conditional>::type + { + DL_LOG_NN_LATENCY_INIT(); + Tensor output; + + if constexpr(!inplace) + { + DL_LOG_NN_LATENCY_START(); + output.set_exponent(input.exponent).set_shape(input.shape).apply_element(); + DL_LOG_NN_LATENCY_END("apply"); + + DL_LOG_NN_LATENCY_START(); + relu(output, input, assign_core); + DL_LOG_NN_LATENCY_END("relu"); + + return output; + } + else + { + DL_LOG_NN_LATENCY_START(); + relu(input, input, assign_core); + DL_LOG_NN_LATENCY_END("relu"); + } + } + } // namespace nn +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_sub2d.hpp b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_sub2d.hpp new file mode 100644 index 00000000000..385188e4ba2 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_sub2d.hpp @@ -0,0 +1,90 @@ +#pragma once + +#include "dl_constant.hpp" +#include "dl_variable.hpp" +#include "dl_nn.hpp" + +namespace dl +{ + namespace nn + { + /** + * @brief activation(sub2d(input0, input1)). + * + * @param output as an output + * @param input0 as one input + * @param input1 as another input + * @param activation activation of sub2d, if you don't specify anything, no activation is applied + * @param assign_core not effective yet + * @param output_exponent exponent of output, only and must specify if inplace operation happens + */ + void sub2d(Tensor &output, + Tensor &input0, + Tensor &input1, + const Activation *const activation = NULL, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE, + const int output_exponent = INT_MIN); + + /** + * @brief activation(sub2d(input0, input1)). + * + * @param output as an output + * @param input0 as one input + * @param input1 as another input + * @param activation activation of sub2d, if you don't specify anything, no activation is applied + * @param assign_core not effective yet + * @param output_exponent exponent of output, only and must specify if inplace operation happens + */ + void sub2d(Tensor &output, + Tensor &input0, + Tensor &input1, + const Activation *const activation = NULL, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE, + const int output_exponent = INT_MIN); + + /** + * @brief activation(sub2d(input0, input1)). + * + * @tparam inplace: whether directly store the output to input0 + * @tparam feature_t supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + * @param output_exponent exponent of output + * @param input0 as one input + * @param input1 as another input + * @param activation activation of sub2d, if you don't specify anything, no activation is applied + * @param assign_core not effective yet + * @return sub2d result or no return(result store to input0) + */ + template + auto sub2d(const int output_exponent, + Tensor &input0, + Tensor &input1, + const Activation *activation, + const std::vector &assign_core = CONFIG_DEFAULT_ASSIGN_CORE) -> typename std::conditional>::type + { + assert(input0.is_same_shape(input1)); + + DL_LOG_NN_LATENCY_INIT(); + Tensor output; + if constexpr(!inplace) + { + DL_LOG_NN_LATENCY_START(); + output.set_exponent(output_exponent).set_shape(input0.shape).apply_element(); + DL_LOG_NN_LATENCY_END("apply"); + + DL_LOG_NN_LATENCY_START(); + sub2d(output, input0, input1, activation, assign_core); + DL_LOG_NN_LATENCY_END("sub2d"); + + return output; + } + else + { + DL_LOG_NN_LATENCY_START(); + sub2d(input0, input0, input1, activation, assign_core, output_exponent); + DL_LOG_NN_LATENCY_END("sub2d"); + } + } + } // namespace nn +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32s2/include/esp-face/include/tool/dl_tool.hpp b/tools/sdk/esp32s2/include/esp-face/include/tool/dl_tool.hpp new file mode 100644 index 00000000000..f8e0871a04f --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/tool/dl_tool.hpp @@ -0,0 +1,377 @@ +#pragma once + +#include +#include +#include +#include + +#include "esp_system.h" +#include "esp_timer.h" +#include "freertos/FreeRTOS.h" + +#include "dl_define.hpp" + +extern "C" +{ +#if CONFIG_TIE728_BOOST + void dl_tie728_memset_8b(void *ptr, const int value, const int n); + void dl_tie728_memset_16b(void *ptr, const int value, const int n); + void dl_tie728_memset_32b(void *ptr, const int value, const int n); +#endif +} + +namespace dl +{ + namespace tool + { + /** + * @brief Set memory zero. + * + * @param ptr pointer of memory + * @param n byte number + */ + void set_zero(void *ptr, const int n); + + /** + * @brief Set array value. + * + * @tparam T supports all data type, sizeof(T) equals to 1, 2 and 4 will boost by instruction + * @param ptr pointer of array + * @param value value to set + * @param len length of array + */ + template + void set_value(T *ptr, const T value, const int len) + { +#if CONFIG_TIE728_BOOST + int *temp = (int *)&value; + if (sizeof(T) == 1) + dl_tie728_memset_8b(ptr, *temp, len); + else if (sizeof(T) == 2) + dl_tie728_memset_16b(ptr, *temp, len); + else if (sizeof(T) == 4) + dl_tie728_memset_32b(ptr, *temp, len); + else +#endif + for (size_t i = 0; i < len; i++) + ptr[i] = value; + } + + /** + * @brief Copy memory. + * + * @param dst pointer of destination + * @param src pointer of source + * @param n byte number + */ + void copy_memory(void *dst, void *src, const int n); + + /** + * @brief Apply memory without initialized. Must use free_aligned() to free the memory. + * + * @param number number of elements + * @param size size of element + * @param align number of aligned, e.g., 16 means 16-byte aligned + * @return pointer of allocated memory. NULL for failed + */ + inline void *malloc_aligned(int number, int size, int align = 0) + { + int n = number * size; + n >>= 4; + n += 2; + n <<= 4; + int total_size = n + align + sizeof(void *) + sizeof(int); + void *res = malloc(total_size); +#if DL_SPIRAM_SUPPORT + if (NULL == res) + res = heap_caps_malloc(total_size, MALLOC_CAP_SPIRAM); +#endif + if (NULL == res) + { + printf("Fail to malloc %d bytes from DRAM(%d bytyes) and PSRAM(%d bytes), PSRAM is %s.\n", + total_size, + heap_caps_get_free_size(MALLOC_CAP_INTERNAL), + heap_caps_get_free_size(MALLOC_CAP_SPIRAM), + DL_SPIRAM_SUPPORT ? "on" : "off"); + return NULL; + } + void **data = (void **)res + 2; // 4-byte for pointer, 4-bytes for n + void **aligned; + if (align) + aligned = (void **)(((size_t)data + (align - 1)) & -align); + else + aligned = data; + + aligned[-1] = res; + int *temp = (int *)aligned; + temp[-2] = n; + + return (void *)aligned; + } + + /** + * @brief Apply memory with zero-initialized. Must use dl_lib_free() to free the memory. + * + * @param number number of elements + * @param size size of element + * @param align number of aligned, e.g., 16 means 16-byte aligned + * @return pointer of allocated memory. NULL for failed + */ + inline void *calloc_aligned(int number, int size, int align = 0) + { + + void *aligned = malloc_aligned(number, size, align); + int n = *((int *)aligned - 2); + set_zero(aligned, n); + + return (void *)aligned; + } + + /** + * @brief Free the calloc_aligned() and malloc_aligned() memory + * + * @param address pointer of memory to free + */ + inline void free_aligned(void *address) + { + if (NULL == address) + return; + + free(((void **)address)[-1]); + } + + /** + * @brief Truncate the input into int8_t range. + * + * @tparam T supports all integer types + * @param output as an output + * @param input as an input + */ + template + void truncate(int8_t &output, T input) + { + if (input >= DL_Q8_MAX) + output = DL_Q8_MAX; + else if (input <= DL_Q8_MIN) + output = DL_Q8_MIN; + else + output = input; + } + + /** + * @brief Truncate the input into int16_t range. + * + * @tparam T supports all integer types + * @param output as an output + * @param input as an input + */ + template + void truncate(int16_t &output, T input) + { + if (input >= DL_Q16_MAX) + output = DL_Q16_MAX; + else if (input <= DL_Q16_MIN) + output = DL_Q16_MIN; + else + output = input; + } + + /** + * @brief Calculate the exponent of quantizing 1/n into max_value range. + * + * @param n 1/n: value to be quantized + * @param max_value the max_range + */ + inline int calculate_exponent(int n, int max_value) + { + int exp = 0; + int tmp = 1 / n; + while (tmp < max_value) + { + exp += 1; + tmp = (1 << exp) / n; + } + exp -= 1; + + return exp; + } + + /** + * @brief Print vector in format "[x1, x2, ...]\n". + * + * @param array to print + */ + inline void print_vector(std::vector &array, const char *message = NULL) + { + if (message) + printf("%s: ", message); + + printf("["); + for (int i = 0; i < array.size(); i++) + { + printf(", %d" + (i ? 0 : 2), array[i]); + } + printf("]\n"); + } + + /** + * @brief Get the cycle object + * + * @return cycle count + */ + inline uint32_t get_cycle() + { + uint32_t ccount; + __asm__ __volatile__("rsr %0, ccount" + : "=a"(ccount) + : + : "memory"); + return ccount; + } + + class Latency + { + private: + const uint32_t size; /**/ + + public: + /** + * @brief Construct a new Latency object. + * + * @param size + */ + Latency(const uint32_t size = 1) : size(size), + period(0), + sum(0), + count(0), + next(0) + { + this->queue = (this->size > 1) ? (uint32_t *)calloc(this->size, sizeof(uint32_t)) : NULL; + } + + /** + * @brief Destroy the Latency object. + * + */ + ~Latency() + { + if (this->queue) + free(this->queue); + } + + /** + * @brief Record the start timestamp. + * + */ + void start() + { +#if DL_LOG_LATENCY_UNIT + this->timestamp = get_cycle(); +#else + this->timestamp = esp_timer_get_time(); +#endif + } + + /** + * @brief Record the period. + * + */ + void end() + { +#if DL_LOG_LATENCY_UNIT + this->period = get_cycle() - this->timestamp; +#else + this->period = esp_timer_get_time() - this->timestamp; +#endif + if (this->queue) + { + this->sum -= this->queue[this->next]; + this->queue[this->next] = this->period; + this->sum += this->queue[this->next]; + this->next++; + this->next = this->next % this->size; + if (this->count < this->size) + { + this->count++; + } + } + } + + /** + * @brief Return the period. + * + * @return this->timestamp_end - this->timestamp + */ + uint32_t get_period() + { + return this->period; + } + + /** + * @brief Get the average period. + * + * @return average latency + */ + uint32_t get_average_period() + { + return this->queue ? (this->sum / this->count) : this->period; + } + + /** + * @brief Clear the period + * + */ + void clear_period() + { + this->period = 0; + } + + /** + * @brief Print in format "latency: {this->period} {unit}\n". + */ + void print() + { +#if DL_LOG_LATENCY_UNIT + printf("latency: %15u cycle\n", this->get_average_period()); +#else + printf("latency: %15u us\n", this->get_average_period()); +#endif + } + + /** + * @brief Print in format "{message}: {this->period} {unit}\n". + * + * @param message message of print + */ + void print(const char *message) + { +#if DL_LOG_LATENCY_UNIT + printf("%s: %15u cycle\n", message, this->get_average_period()); +#else + printf("%s: %15u us\n", message, this->get_average_period()); +#endif + } + + /** + * @brief Print in format "{prefix}::{key}: {this->period} {unit}\n". + * + * @param prefix prefix of print + * @param key key of print + */ + void print(const char *prefix, const char *key) + { +#if DL_LOG_LATENCY_UNIT + printf("%s::%s: %u cycle\n", prefix, key, this->get_average_period()); +#else + printf("%s::%s: %u us\n", prefix, key, this->get_average_period()); +#endif + } + }; + } // namespace tool +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32s2/include/esp-face/include/tool/dl_tool_cache.hpp b/tools/sdk/esp32s2/include/esp-face/include/tool/dl_tool_cache.hpp new file mode 100644 index 00000000000..74c81717a58 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/tool/dl_tool_cache.hpp @@ -0,0 +1,74 @@ +#pragma once + +#include + +#if CONFIG_IDF_TARGET_ESP32S3 +#include "esp32s3/rom/cache.h" +#include "soc/extmem_reg.h" +#endif + +namespace dl +{ + namespace tool + { + namespace cache + { + /** + * @brief Initialize preload. + * + * @param preload One of 1 or 0, + * - 1: turn on the preload + * - 0: turn off the preload + * @return + * - 1: Initialize successfully + * - 0: Initialize successfully, autoload has been turned off + * - -1: Initialize failed, the chip does not support preload + */ + int8_t preload_init(uint8_t preload = 1); + + /** + * @brief Preload memory. + * + * @param addr the start address of data to be preloaded + * @param size the size of the data in byte to be preloaded + */ + void preload_func(uint32_t addr, uint32_t size); + + /** + * @brief Initialize autoload. + * + * @param autoload One of 1 or 0, + * - 1: turn on the autoload + * - 0: turn off the autoload + * @param trigger One of 0 or 1 or 2, + * - 0: miss, TODO:@yuanjiong + * - 1: hit, TODO:@yuanjiong + * - 2: both,TODO:@yuanjiong + * @param line_size the number of cache lines to be autoloaded + * @return status, + * - 1: Initialize sucessfully + * - 0: Initialize suceesfully, preload has been turned off + * - -1: Initialize failed, the chip does not support autoload + */ + int8_t autoload_init(uint8_t autoload = 1, uint8_t trigger = 2, uint8_t line_size = 0); + + /** + * @brief Autoload memory. + * + * @param addr1 the start address of data1 to be autoloaded + * @param size1 the size of the data1 in byte to be preloaded + * @param addr2 the start address of data2 to be autoloaded + * @param size2 the size of the data2 in byte to be preloaded + */ + void autoload_func(uint32_t addr1, uint32_t size1, uint32_t addr2, uint32_t size2); + + /** + * @brief Autoload memory. + * + * @param addr1 the start address of data1 to be autoloaded + * @param size1 the size of the data1 in byte to be preloaded + */ + void autoload_func(uint32_t addr1, uint32_t size1); + } + } // namespace tool +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32s2/include/esp-face/include/typedef/dl_constant.hpp b/tools/sdk/esp32s2/include/esp-face/include/typedef/dl_constant.hpp new file mode 100644 index 00000000000..73e3b0832e7 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/typedef/dl_constant.hpp @@ -0,0 +1,125 @@ +#pragma once + +#include "dl_define.hpp" +#include + +namespace dl +{ + /** + * @brief Base class of Filter, Bias, Activation. + * + * @tparam T supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize, + * - int8_t: stands for operation in int8_t quantize. + */ + template + class Constant + { + public: + const T *element; /**/ + const int exponent; /**/ + const std::vector shape; /**/ + + /** + * @brief Construct a new Constant object. + * + * @param element point to element. + * @param exponent exponent of element. + * @param shape shape of Constant. + */ + Constant(const T *element, const int exponent, const std::vector shape); + }; + + /** + * @brief Filter. + * NOTE: The shape format of filter is fixed, but the element sequence depands on optimization method. + * - 1D: reserved + * - 2D: shape format is [filter_height, filter_width, input_channel, output_channel]. dilation format is [height, width] + * + * @tparam T supports int16_t and int8_t, + * - int16_t: stands for operation in int16_t quantize, + * - int8_t: stands for operation in int8_t quantize. + */ + template + class Filter : public Constant + { + public: + const std::vector dilation; /**/ + /**/ + std::vector shape_with_dilation; /**/ + /**/ + std::vector channel_exponent; /**/ + + /** + * @brief Construct a new Filter object. + * + * @param element point to element + * @param exponent exponent of element + * @param shape shape of Filter, + * - 1D: reserved + * - 2D: [filter_height, filter_width, input_channel, output_channel] + * @param dilation dilation of Filter + * - 1D: reserved + * - 2D: [dilation_in_height, dilation_in_width] + */ + Filter(const T *element, const int exponent, const std::vector shape, const std::vector dilation = {1, 1}); + + /** + * @brief Construct a new Filter object. + * + * @param element point to element + * @param channel_exponent exponent for per-channel + * @param shape shape of element + * @param dilation dilation of Filter + * - 1D: reserved + * - 2D: [dilation_in_height, dilation_in_width] + */ + Filter(const T *element, const std::vector channel_exponent, const std::vector shape, const std::vector dilation = {1, 1}); + + /** + * @brief Print the n-th filter. + * + * @param n index of output_channel + * @param message to print + */ + void print2d_n(const int n, const char *message) const; + }; + + /** + * @brief Bias. + * + * @tparam T supports int16_t and int8_t + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class Bias : public Constant + { + public: + using Constant::Constant; + }; + + /** + * @brief Activation. + * + * @tparam T supports int16_t and int8_t + * - int16_t: stands for operation in int16_t quantize + * - int8_t: stands for operation in int8_t quantize + */ + template + class Activation : public Constant + { + public: + const activation_type_t type; /* shape = {0}); + }; +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32s2/include/esp-face/include/typedef/dl_variable.hpp b/tools/sdk/esp32s2/include/esp-face/include/typedef/dl_variable.hpp new file mode 100644 index 00000000000..bf6e8630856 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp-face/include/typedef/dl_variable.hpp @@ -0,0 +1,734 @@ +#pragma once + +#include +#include +#include + +#include "dl_tool.hpp" + +namespace dl +{ + /** + * @brief Tensor + * + * @tparam T support uint8_t, int8_t, int16_t and float. + */ + template + class Tensor + { + private: + int size; /* shape; /* shape_with_padding; /* padding; /*element + */ + Tensor(Tensor &input, bool deep) : size(input.size), + auto_free(input.auto_free), + exponent(input.exponent), + shape(input.shape), + shape_with_padding(input.shape_with_padding), + padding(input.padding) + { + if (deep) + { + int size_real = input.shape_with_padding.size() ? input.shape_with_padding[0] * input.shape_with_padding[1] * input.shape_with_padding[2] : 0; + T *new_element = (T *)tool::calloc_aligned(size_real, sizeof(T), 16); + tool::copy_memory(new_element, input.element, size_real * sizeof(T)); + this->element = new_element; + } + else + { + this->element = input.element; + } + } + + /** + * @brief Destroy the Tensor object + * + */ + ~Tensor() + { + if (this->auto_free) + this->free_element(); + } + + /** + * @brief Set the auto free object. + * + * @param auto_free one of true or false + * - true: free element when object destroyed + * - false: do not + * @return self + */ + Tensor &set_auto_free(const bool auto_free) + { + this->auto_free = auto_free; + return *this; + } + + /** + * @brief Set the element. + * + * @param element point to element memory + * @return self + */ + Tensor &set_element(T *element, const bool auto_free = false) + { + assert(this->element == NULL); + this->element = element; + this->auto_free = auto_free; + + return *this; + } + + /** + * @brief Set the exponent. + * + * @param exponent exponent of element + * @return self + */ + Tensor &set_exponent(const int exponent) + { + this->exponent = exponent; + + return *this; + } + + /** + * @brief Set the shape of Tensor. Initial this->padding = {0}. Initial this->size = -1. + * + * @param shape shape in + * - 2D: [height, width] + * @return self + */ + Tensor &set_shape(const std::vector shape) + { + for (int i = 0; i < shape.size(); ++i) + { + assert(shape[i] > 0); + } + this->shape = shape; + this->shape_with_padding = shape; + this->size = -1; + this->padding = std::vector(((this->shape.size() - 1) << 1), 0); + return *this; + } + + /** + * @brief Set the padding size object. + * + * @param padding padding size in + * - 2D: [top, bottom, left, right] + * @return self + */ + Tensor &set_padding_size(std::vector &padding) + { + assert(this->shape.size()); // call Tensor.set_shape() first + assert(this->shape.size() == 3); // TODO: || this->shape.size() == 2 + + if (this->shape.size() == 3) + { + std::vector new_padding = this->padding; + bool dont_update = true; + + if (padding[0] > this->padding[0]) + { + new_padding[0] = padding[0]; + dont_update = false; + } + + if (padding[1] > this->padding[1]) + { + new_padding[1] = padding[1]; + dont_update = false; + } + + if (padding[2] > this->padding[2]) + { + new_padding[2] = padding[2]; + dont_update = false; + } + + if (padding[3] > this->padding[3]) + { + new_padding[3] = padding[3]; + dont_update = false; + } + + if (dont_update) + { + return *this; + } + + std::vector new_shape_with_padding = this->shape; + + new_shape_with_padding[0] += (new_padding[0] + new_padding[1]); + new_shape_with_padding[1] += (new_padding[2] + new_padding[3]); + int new_size = new_shape_with_padding[0] * new_shape_with_padding[1] * new_shape_with_padding[2]; + + if (this->element) // if this->element != NULL, do padding by copy memory + { + T *new_element = (T *)tool::malloc_aligned(new_size, sizeof(T), 16); + T *dst = new_element + ((new_padding[0] * new_shape_with_padding[1]) + new_padding[2]) * new_shape_with_padding[2]; + T *src = this->get_element_ptr(); + int offset_dst_next_y = new_shape_with_padding[1] * new_shape_with_padding[2]; // width * channel + int src_copy_length = this->shape[1] * this->shape[2]; // width * channel + int offset_src_next_y = this->shape_with_padding[1] * this->shape_with_padding[2]; // width * channel + for (int y = 0; y < this->shape[0]; y++) + { + tool::copy_memory(dst, src, src_copy_length * sizeof(T)); + dst += offset_dst_next_y; + src += offset_src_next_y; + } + + if (this->auto_free) + tool::free_aligned(this->element); + this->element = new_element; + this->auto_free = true; + } + this->padding = new_padding; + this->shape_with_padding = new_shape_with_padding; + this->size = new_size; + } + else if (this->shape.size() == 2) + { + printf("Tensor.set_padding_size with this->shape.size() == 2 not implement yet.\n"); + } + + return *this; + } + + /** + * @brief Set the padding value object. + * + * @param padding padding size in + * - 2D: [top, bottom, left, right] + * @param value value to set + * @return self + */ + Tensor &set_padding_value(std::vector &padding, T value); + + /** + * @brief Get the element pointer. + * + * @param padding padding size in + * - 2D: [top, bottom, left, right] + * @return pointer to memory with padding + */ + T *get_element_ptr(const std::vector padding = {0, 0, 0, 0}) + { + assert(this->shape.size() == 3); // TODO: || this->shape.size() == 2 + + if (this->shape.size() == 3) + { + return this->element + ((this->padding[0] - padding[0]) * this->shape_with_padding[1] + (this->padding[2] - padding[2])) * this->shape_with_padding[2]; + } + else if (this->shape.size() == 2) + { + printf("Tensor.get_element_ptr with this->shape.size() == 2 is not implemented.\n"); + } + + return NULL; + } + + /** + * @brief Get the element value. + * + * @param index index in + * - 2D: [y, x, c] + * @param with_padding one of true or false, + * - true: make padding size in count + * - false: do not + * @return element value + */ + T &get_element_value(const std::vector index, const bool with_padding = false) + { + assert(index.size() == this->shape.size()); + assert(this->shape.size() == 3); // TODO: || this->shape() == 2 + + int i = 0; + if (this->shape.size() == 3) + { + int y = index[0]; + int x = index[1]; + int c = index[2]; + i = with_padding ? (y * this->shape_with_padding[1] + x) * this->shape_with_padding[2] + c : ((y + this->padding[0]) * this->shape_with_padding[1] + x + this->padding[2]) * this->shape_with_padding[2] + c; + } + else if (this->shape.size() == 2) + { + printf("Tensor.get_element_value with this->shape.size() == 2 is not implemented.\n"); + } + + return this->element[i]; + } + + /** + * @brief Get the size of element. + * + * @return size of element including padding + */ + int get_size() + { + if (this->size == -1) // didn't call Tensor.set_padding_size() before + { + this->size = 1; + for (std::vector::iterator d = this->shape.begin(); d != this->shape.end(); d++) + this->size *= *d; + } + + return this->size; + } + + /** + * @brief Apply memory with zero-initialized only if this->element is NULL. + * + * @param auto_free one of true or false + * - true: free element when object destroyed + * - false: do not + * @return + * - true: on success + * - false: if applying failed + */ + bool calloc_element(const bool auto_free = true) + { + if (this->element != NULL) + return false; + + this->element = (T *)dl::tool::calloc_aligned(this->get_size(), sizeof(T), 16); + this->auto_free = auto_free; + + return true; + } + + /** + * @brief Apply memory without initialized only if this->element is NULL. + * + * @param auto_free one of true or false + * - true: free element when object destroyed + * - false: do not + * @return + * - true: on success + * - false: if applying failed + */ + bool malloc_element(const bool auto_free = true) + { + if (this->element != NULL) + return false; + + this->element = (T *)tool::malloc_aligned(this->get_size(), sizeof(T), 16); + this->auto_free = auto_free; + + return true; + } + + /** + * @brief If this->element != NULL no memory will be applied and no value will be set in padding. + * Else apply memory without initialized and set value to padding. + * + * @param padding_value value to set in padding + * @param auto_free one of true of false + * - true: free element when object destroyed + * - false: do not + * @return + * - true: apply memory and set padding value successfully + * - false: no memory applied and no padding value set + */ + bool apply_element(const T padding_value = 0, const bool auto_free = true) + { + if (this->element != NULL) + return false; + + this->element = (T *)tool::malloc_aligned(this->get_size(), sizeof(T), 16); + this->set_padding_value(this->padding, padding_value); + this->auto_free = auto_free; + + return true; + } + + /** + * @brief free element only if this->element != NULL + * set this->element to NULL, after free + * @brief Free element if this->element is not NULL. + */ + void free_element() + { + if (this->auto_free && this->element) + { + tool::free_aligned(this->element); + this->element = NULL; + } + } + + /** + * @brief Print the shape of Tensor in format "shape = ({top_padding} + {height} + {bottom_padding}, {left_padding} + {width} + {right_padding}, {channel}(channel_with_padding))\n". + */ + void print_shape() + { + printf("shape = (%d + %d + %d, %d + %d + %d, %d(%d))\n", + this->padding[0], this->shape[0], this->padding[1], + this->padding[2], this->shape[1], this->padding[3], + this->shape[2], this->shape_with_padding[2]); + } + + /** + * @brief Take numpy for example, this function print Tensor[y_start:y_end, x_start:x_end, c_start:c_end]. + * + * inner box is effective value of Tensor, "0" around is padding. + * + * (with padding) + * 00000000000000000000000000000000000000000000000000 + * 00000000000000000000000000000000000000000000000000 + * 00000000000000000000000000000000000000000000000000 + * 000000(without padding) 00000000 + * 000000 00000000 + * 000000 00000000 + * 000000 effective value 00000000 + * 000000 00000000 + * 000000 00000000 + * 00000000000000000000000000000000000000000000000000 + * 00000000000000000000000000000000000000000000000000 + * 00000000000000000000000000000000000000000000000000 + * + * @param y_start start index in height + * @param y_end end index in height + * @param x_start start index in width + * @param x_end end index in width + * @param c_start start index in channel + * @param c_end end index in channel + * @param message to print + * @param axis print aligned this axis, effective only if all y_end - y_start, x_end - x_start and c_end - c_start equals to 1 + * @param with_padding one of true or false, + * - true: count from (with padding) in upper image + * - false: count from (without padding) in upper image + */ + void print(int y_start, int y_end, + int x_start, int x_end, + int c_start, int c_end, + const char *message, int axis = 0, const bool with_padding = false) + { + assert(y_end > y_start); + assert(x_end > x_start); + assert(c_end > c_start); + + y_start = DL_MAX(y_start, 0); + x_start = DL_MAX(x_start, 0); + c_start = DL_MAX(c_start, 0); + if (with_padding) + { + y_end = DL_MIN(y_end, this->shape_with_padding[0]); + x_end = DL_MIN(x_end, this->shape_with_padding[1]); + c_end = DL_MIN(c_end, this->shape_with_padding[2]); + } + else + { + y_end = DL_MIN(y_end, this->shape[0]); + x_end = DL_MIN(x_end, this->shape[1]); + c_end = DL_MIN(c_end, this->shape[2]); + } + + printf("%s[%d:%d, %d:%d, %d:%d] | ", message, y_start, y_end, x_start, x_end, c_start, c_end); + this->print_shape(); + + if (y_end - y_start == 1) + { + if (x_end - x_start == 1) + { + for (int c = c_start; c < c_end; c++) + printf("%7d", c); + printf("\n"); + + for (int c = c_start; c < c_end; c++) + printf("%7d", this->get_element_value({y_start, x_start, c}, with_padding)); + printf("\n"); + + return; + } + else + { + if (c_end - c_start == 1) + { + for (int x = x_start; x < x_end; x++) + printf("%7d", x); + printf("\n"); + + for (int x = x_start; x < x_end; x++) + printf("%7d", this->get_element_value({y_start, x, c_start}, with_padding)); + printf("\n"); + + return; + } + } + } + else + { + if (x_end - x_start == 1) + { + if (c_end - c_start == 1) + { + for (int y = y_start; y < y_end; y++) + printf("%7d", y); + printf("\n"); + + for (int y = y_start; y < y_end; y++) + printf("%7d", this->get_element_value({y, x_start, c_start}, with_padding)); + printf("\n"); + + return; + } + } + } + + if (y_end - y_start == 1) + axis = 0; + + if (x_end - x_start == 1) + axis = 1; + + if (c_end - c_start == 1) + axis = 2; + + if (axis == 0) + { + // ______c + // | + // | + // x + // + for (int y = y_start; y < y_end; y++) + { + printf("y = %d\n ", y); + + for (int c = c_start; c < c_end; c++) + printf("%7d", c); + printf("\n"); + + for (int x = x_start; x < x_end; x++) + { + printf("%5d", x); + for (int c = c_start; c < c_end; c++) + printf("%7d", this->get_element_value({y, x, c}, with_padding)); + printf("\n"); + } + printf("\n"); + } + } + else if (axis == 1) + { + // ______c + // | + // | + // y + // + for (int x = x_start; x < x_end; x++) + { + printf("x = %d\n ", x); + + for (int c = c_start; c < c_end; c++) + printf("%7d", c); + printf("\n"); + + for (int y = y_start; y < y_end; y++) + { + printf("%5d", y); + for (int c = c_start; c < c_end; c++) + printf("%7d", this->get_element_value({y, x, c}, with_padding)); + printf("\n"); + } + printf("\n"); + } + } + else + { + // ______x + // | + // | + // y + // + for (int c = c_start; c < c_end; c++) + { + printf("c = %d\n ", c); + + for (int x = x_start; x < x_end; x++) + printf("%7d", x); + printf("\n"); + + for (int y = y_start; y < y_end; y++) + { + printf("%5d", y); + for (int x = x_start; x < x_end; x++) + printf("%7d", this->get_element_value({y, x, c}, with_padding)); + printf("\n"); + } + printf("\n"); + } + } + + return; + } + + /** + * @brief print all the element of the Tensor. + * + * @param message to print + * @param with_padding one of true or false, + * - true: the padding element will also be printed + * - false: the padding element will not be printed + */ + void print_all(const char *message, const bool with_padding = false) + { + int y_end; + int x_end; + int c_end; + if (with_padding) + { + y_end = this->shape_with_padding[0]; + x_end = this->shape_with_padding[1]; + c_end = this->shape_with_padding[2]; + } + else + { + y_end = this->shape[0]; + x_end = this->shape[1]; + c_end = this->shape[2]; + } + + printf("\n%s | ", message); + this->print_shape(); + + for (int y = 0; y < y_end; y++) + { + for (int x = 0; x < x_end; x++) + { + for (int c = 0; c < c_end; c++) + printf("%d ", this->get_element_value({y, x, c}, with_padding)); + } + } + printf("\n"); + return; + } + + /** + * @brief Check the element value with input ground-truth. + * + * @param gt_element ground-truth value of element + * @param bias permissible error + * @param info one of true or false + * - true: print shape and result + * - false: do not + * @return + * - true: in permissible error + * - false: not + */ + bool check_element(T *gt_element, int bias = 2, bool info = true) + { + if (info) + this->print_shape(); + int i = 0; + for (int y = 0; y < this->shape[0]; y++) + { + for (int x = 0; x < this->shape[1]; x++) + { + for (int c = 0; c < this->shape[2]; c++) + { + int a = this->get_element_value({y, x, c}); + int b = gt_element[i]; + int offset = DL_ABS(a - b); + if (offset > bias) + { + printf("element[%d, %d, %d]: %d v.s. %d\n", y, x, c, a, b); + return false; + } + i++; + } + } + } + + if (info) + printf("PASS\n"); + + return true; + } + + /** + * @brief Check the shape is the same as the shape of input. + * + * @param input an input tensor + * @return + * - true: same shape + * - false: not + */ + bool is_same_shape(Tensor &input) + { + if (input.shape.size() != this->shape.size()) + { + return false; + } + for (int i = 0; i < this->shape.size(); i++) + { + if (input.shape[i] != this->shape[i]) + { + return false; + } + } + return true; + } + + Tensor &operator=(const Tensor &input) + { + this->size = input.size; + this->auto_free = input.auto_free; + this->exponent = input.exponent; + this->shape = input.shape; + this->padding = input.padding; + int size_real_tmp = this->shape_with_padding.size() ? this->shape_with_padding[0] * this->shape_with_padding[1] * this->shape_with_padding[2] : 0; + int size_input_real = input.shape_with_padding.size() ? input.shape_with_padding[0] * input.shape_with_padding[1] * input.shape_with_padding[2] : 0; + this->shape_with_padding = input.shape_with_padding; + if (this->element) + { + if (size_real_tmp != size_input_real) + { + tool::free_aligned(this->element); + T *new_element = (T *)tool::calloc_aligned(size_input_real, sizeof(T), 16); + tool::copy_memory(new_element, input.element, size_input_real * sizeof(T)); + this->element = new_element; + } + else + { + tool::copy_memory(this->element, input.element, size_input_real * sizeof(T)); + } + } + else + { + T *new_element = (T *)tool::calloc_aligned(size_input_real, sizeof(T), 16); + tool::copy_memory(new_element, input.element, size_input_real * sizeof(T)); + this->element = new_element; + } + return *this; + } + }; +} // namespace dl \ No newline at end of file diff --git a/tools/sdk/esp32s2/include/esp-face/lib/include/cat_face_3.h b/tools/sdk/esp32s2/include/esp-face/lib/include/cat_face_3.h deleted file mode 100644 index 42d6fa85821..00000000000 --- a/tools/sdk/esp32s2/include/esp-face/lib/include/cat_face_3.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * ESPRESSIF MIT License - * - * Copyright (c) 2018 - * - * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, - * it is free of charge, to any person_body 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. - * - */ - -#pragma once - -#ifdef __cplusplus -extern "C" -{ -#endif -#include "dl_lib_matrix3d.h" -#include "dl_lib_matrix3dq.h" -#include "freertos/FreeRTOS.h" -#include "detection.h" - - extern detection_model_t cat_face_3_model; - -#ifdef __cplusplus -} -#endif diff --git a/tools/sdk/esp32s2/include/esp-face/lib/include/detection.h b/tools/sdk/esp32s2/include/esp-face/lib/include/detection.h deleted file mode 100644 index 0bba4f49b6f..00000000000 --- a/tools/sdk/esp32s2/include/esp-face/lib/include/detection.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * ESPRESSIF MIT License - * - * Copyright (c) 2018 - * - * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, - * it is 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. - * - */ -#pragma once - -#ifdef __cplusplus -extern "C" -{ -#endif -#include "dl_lib_matrix3d.h" -#include "dl_lib_matrix3dq.h" -#include "freertos/FreeRTOS.h" - - typedef enum - { - Anchor_Point, /* -#include -#include -#include -#include -#include - -#if CONFIG_SPIRAM_SUPPORT || CONFIG_ESP32_SPIRAM_SUPPORT -#include "freertos/FreeRTOS.h" -#define DL_SPIRAM_SUPPORT 1 -#else -#define DL_SPIRAM_SUPPORT 0 -#endif - - -#ifndef max -#define max(x, y) (((x) < (y)) ? (y) : (x)) -#endif - -#ifndef min -#define min(x, y) (((x) < (y)) ? (x) : (y)) -#endif - -typedef float fptp_t; -typedef uint8_t uc_t; - -typedef enum -{ - DL_SUCCESS = 0, - DL_FAIL = 1, -} dl_error_type; - -typedef enum -{ - PADDING_VALID = 0, /*!< Valid padding */ - PADDING_SAME = 1, /*!< Same padding, from right to left, free input */ - PADDING_SAME_DONT_FREE_INPUT = 2, /*!< Same padding, from right to left, do not free input */ - PADDING_SAME_MXNET = 3, /*!< Same padding, from left to right */ -} dl_padding_type; - -typedef enum -{ - DL_POOLING_MAX = 0, /*!< Max pooling */ - DL_POOLING_AVG = 1, /*!< Average pooling */ -} dl_pooling_type; -/* - * Matrix for 3d - * @Warning: the sequence of variables is fixed, cannot be modified, otherwise there will be errors in esp_dsp_dot_float - */ -typedef struct -{ - int w; /*!< Width */ - int h; /*!< Height */ - int c; /*!< Channel */ - int n; /*!< Number of filter, input and output must be 1 */ - int stride; /*!< Step between lines */ - fptp_t *item; /*!< Data */ -} dl_matrix3d_t; - -typedef struct -{ - int w; /*!< Width */ - int h; /*!< Height */ - int c; /*!< Channel */ - int n; /*!< Number of filter, input and output must be 1 */ - int stride; /*!< Step between lines */ - uc_t *item; /*!< Data */ -} dl_matrix3du_t; - -typedef enum -{ - UPSAMPLE_NEAREST_NEIGHBOR = 0, /*!< Use nearest neighbor interpolation as the upsample method*/ - UPSAMPLE_BILINEAR = 1, /*!< Use nearest bilinear interpolation as the upsample method*/ -} dl_upsample_type; - -typedef struct -{ - int stride_x; /*!< Strides of width */ - int stride_y; /*!< Strides of height */ - dl_padding_type padding; /*!< Padding type */ -} dl_matrix3d_mobilenet_config_t; - -/* - * @brief Allocate a zero-initialized space. Must use 'dl_lib_free' to free the memory. - * - * @param cnt Count of units. - * @param size Size of unit. - * @param align Align of memory. If not required, set 0. - * @return Pointer of allocated memory. Null for failed. - */ -static void *dl_lib_calloc(int cnt, int size, int align) -{ - int total_size = cnt * size + align + sizeof(void *); - void *res = malloc(total_size); - if (NULL == res) - { -#if DL_SPIRAM_SUPPORT - res = heap_caps_malloc(total_size, MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM); - } - if (NULL == res) - { - printf("Item psram alloc failed. Size: %d x %d\n", cnt, size); -#else - printf("Item alloc failed. Size: %d x %d, SPIRAM_FLAG: %d\n", cnt, size, DL_SPIRAM_SUPPORT); -#endif - return NULL; - } - bzero(res, total_size); - void **data = (void **)res + 1; - void **aligned; - if (align) - aligned = (void **)(((size_t)data + (align - 1)) & -align); - else - aligned = data; - - aligned[-1] = res; - return (void *)aligned; -} - -/** - * @brief Free the memory space allocated by 'dl_lib_calloc' - * - */ -static inline void dl_lib_free(void *d) -{ - if (NULL == d) - return; - - free(((void **)d)[-1]); -} - -/* - * @brief Allocate a 3D matrix with float items, the access sequence is NHWC - * - * @param n Number of matrix3d, for filters it is out channels, for others it is 1 - * @param w Width of matrix3d - * @param h Height of matrix3d - * @param c Channel of matrix3d - * @return 3d matrix - */ -static inline dl_matrix3d_t *dl_matrix3d_alloc(int n, int w, int h, int c) -{ - dl_matrix3d_t *r = (dl_matrix3d_t *)dl_lib_calloc(1, sizeof(dl_matrix3d_t), 0); - if (NULL == r) - { - printf("internal r failed.\n"); - return NULL; - } - fptp_t *items = (fptp_t *)dl_lib_calloc(n * w * h * c, sizeof(fptp_t), 0); - if (NULL == items) - { - printf("matrix3d item alloc failed.\n"); - dl_lib_free(r); - return NULL; - } - - r->w = w; - r->h = h; - r->c = c; - r->n = n; - r->stride = w * c; - r->item = items; - - return r; -} - -/* - * @brief Allocate a 3D matrix with 8-bits items, the access sequence is NHWC - * - * @param n Number of matrix3d, for filters it is out channels, for others it is 1 - * @param w Width of matrix3d - * @param h Height of matrix3d - * @param c Channel of matrix3d - * @return 3d matrix - */ -static inline dl_matrix3du_t *dl_matrix3du_alloc(int n, int w, int h, int c) -{ - dl_matrix3du_t *r = (dl_matrix3du_t *)dl_lib_calloc(1, sizeof(dl_matrix3du_t), 0); - if (NULL == r) - { - printf("internal r failed.\n"); - return NULL; - } - uc_t *items = (uc_t *)dl_lib_calloc(n * w * h * c, sizeof(uc_t), 0); - if (NULL == items) - { - printf("matrix3du item alloc failed.\n"); - dl_lib_free(r); - return NULL; - } - - r->w = w; - r->h = h; - r->c = c; - r->n = n; - r->stride = w * c; - r->item = items; - - return r; -} - -/* - * @brief Free a matrix3d - * - * @param m matrix3d with float items - */ -static inline void dl_matrix3d_free(dl_matrix3d_t *m) -{ - if (NULL == m) - return; - if (NULL == m->item) - { - dl_lib_free(m); - return; - } - dl_lib_free(m->item); - dl_lib_free(m); -} - -/* - * @brief Free a matrix3d - * - * @param m matrix3d with 8-bits items - */ -static inline void dl_matrix3du_free(dl_matrix3du_t *m) -{ - if (NULL == m) - return; - if (NULL == m->item) - { - dl_lib_free(m); - return; - } - dl_lib_free(m->item); - dl_lib_free(m); -} - - -/* - * @brief Dot product with a vector and matrix - * - * @param out Space to put the result - * @param in input vector - * @param f filter matrix - */ -void dl_matrix3dff_dot_product(dl_matrix3d_t *out, dl_matrix3d_t *in, dl_matrix3d_t *f); - -/** - * @brief Do a softmax operation on a matrix3d - * - * @param in Input matrix3d - */ -void dl_matrix3d_softmax(dl_matrix3d_t *m); - -/** - * @brief Copy a range of float items from an existing matrix to a preallocated matrix - * - * @param dst The destination slice matrix - * @param src The source matrix to slice - * @param x X-offset of the origin of the returned matrix within the sliced matrix - * @param y Y-offset of the origin of the returned matrix within the sliced matrix - * @param w Width of the resulting matrix - * @param h Height of the resulting matrix - */ -void dl_matrix3d_slice_copy(dl_matrix3d_t *dst, - dl_matrix3d_t *src, - int x, - int y, - int w, - int h); - -/** - * @brief Copy a range of 8-bits items from an existing matrix to a preallocated matrix - * - * @param dst The destination slice matrix - * @param src The source matrix to slice - * @param x X-offset of the origin of the returned matrix within the sliced matrix - * @param y Y-offset of the origin of the returned matrix within the sliced matrix - * @param w Width of the resulting matrix - * @param h Height of the resulting matrix - */ -void dl_matrix3du_slice_copy(dl_matrix3du_t *dst, - dl_matrix3du_t *src, - int x, - int y, - int w, - int h); - -/** - * @brief Transform a sliced matrix block from nhwc to nchw, the block needs to be memory continous. - * - * @param out The destination sliced matrix in nchw - * @param in The source sliced matrix in nhwc - */ -void dl_matrix3d_sliced_transform_nchw(dl_matrix3d_t *out, - dl_matrix3d_t *in); - -/** - * @brief Do a general CNN layer pass, dimension is (number, width, height, channel) - * - * @param in Input matrix3d - * @param filter Weights of the neurons - * @param bias Bias for the CNN layer - * @param stride_x The step length of the convolution window in x(width) direction - * @param stride_y The step length of the convolution window in y(height) direction - * @param padding One of VALID or SAME - * @param mode Do convolution using C implement or xtensa implement, 0 or 1, with respect - * If ESP_PLATFORM is not defined, this value is not used. Default is 0 - * @return dl_matrix3d_t* The result of CNN layer - */ -dl_matrix3d_t *dl_matrix3d_conv(dl_matrix3d_t *in, - dl_matrix3d_t *filter, - dl_matrix3d_t *bias, - int stride_x, - int stride_y, - int padding, - int mode); - -/** - * @brief Do a global average pooling layer pass, dimension is (number, width, height, channel) - * - * @param in Input matrix3d - * - * @return The result of global average pooling layer - */ -dl_matrix3d_t *dl_matrix3d_global_pool(dl_matrix3d_t *in); - -/** - * @brief Calculate pooling layer of a feature map - * - * @param in Input matrix, size (1, w, h, c) - * @param f_w Window width - * @param f_h Window height - * @param stride_x Stride in horizontal direction - * @param stride_y Stride in vertical direction - * @param padding Padding type: PADDING_VALID and PADDING_SAME - * @param pooling_type Pooling type: DL_POOLING_MAX and POOLING_AVG - * @return dl_matrix3d_t* Resulting matrix, size (1, w', h', c) - */ -dl_matrix3d_t *dl_matrix3d_pooling(dl_matrix3d_t *in, - int f_w, - int f_h, - int stride_x, - int stride_y, - dl_padding_type padding, - dl_pooling_type pooling_type); -/** - * @brief Do a batch normalization operation, update the input matrix3d: input = input * scale + offset - * - * @param m Input matrix3d - * @param scale scale matrix3d, scale = gamma/((moving_variance+sigma)^(1/2)) - * @param Offset Offset matrix3d, offset = beta-(moving_mean*gamma/((moving_variance+sigma)^(1/2))) - */ -void dl_matrix3d_batch_normalize(dl_matrix3d_t *m, - dl_matrix3d_t *scale, - dl_matrix3d_t *offset); - -/** - * @brief Add a pair of matrix3d item-by-item: res=in_1+in_2 - * - * @param in_1 First Floating point input matrix3d - * @param in_2 Second Floating point input matrix3d - * - * @return dl_matrix3d_t* Added data - */ -dl_matrix3d_t *dl_matrix3d_add(dl_matrix3d_t *in_1, dl_matrix3d_t *in_2); - -/** - * @brief Concatenate the channels of two matrix3ds into a new matrix3d - * - * @param in_1 First Floating point input matrix3d - * @param in_2 Second Floating point input matrix3d - * - * @return dl_matrix3d_t* A newly allocated matrix3d with as avlues in_1|in_2 - */ -dl_matrix3d_t *dl_matrix3d_concat(dl_matrix3d_t *in_1, dl_matrix3d_t *in_2); - -/** - * @brief Concatenate the channels of four matrix3ds into a new matrix3d - * - * @param in_1 First Floating point input matrix3d - * @param in_2 Second Floating point input matrix3d - * @param in_3 Third Floating point input matrix3d - * @param in_4 Fourth Floating point input matrix3d - * - * @return A newly allocated matrix3d with as avlues in_1|in_2|in_3|in_4 - */ -dl_matrix3d_t *dl_matrix3d_concat_4(dl_matrix3d_t *in_1, - dl_matrix3d_t *in_2, - dl_matrix3d_t *in_3, - dl_matrix3d_t *in_4); - -/** - * @brief Concatenate the channels of eight matrix3ds into a new matrix3d - * - * @param in_1 First Floating point input matrix3d - * @param in_2 Second Floating point input matrix3d - * @param in_3 Third Floating point input matrix3d - * @param in_4 Fourth Floating point input matrix3d - * @param in_5 Fifth Floating point input matrix3d - * @param in_6 Sixth Floating point input matrix3d - * @param in_7 Seventh Floating point input matrix3d - * @param in_8 eighth Floating point input matrix3d - * - * @return A newly allocated matrix3d with as avlues in_1|in_2|in_3|in_4|in_5|in_6|in_7|in_8 - */ -dl_matrix3d_t *dl_matrix3d_concat_8(dl_matrix3d_t *in_1, - dl_matrix3d_t *in_2, - dl_matrix3d_t *in_3, - dl_matrix3d_t *in_4, - dl_matrix3d_t *in_5, - dl_matrix3d_t *in_6, - dl_matrix3d_t *in_7, - dl_matrix3d_t *in_8); - -/** - * @brief Do a mobilefacenet block forward, dimension is (number, width, height, channel) - * - * @param in Input matrix3d - * @param pw Weights of the pointwise conv layer - * @param pw_bn_scale The scale params of the batch_normalize layer after the pointwise conv layer - * @param pw_bn_offset The offset params of the batch_normalize layer after the pointwise conv layer - * @param dw Weights of the depthwise conv layer - * @param dw_bn_scale The scale params of the batch_normalize layer after the depthwise conv layer - * @param dw_bn_offset The offset params of the batch_normalize layer after the depthwise conv layer - * @param pw_linear Weights of the pointwise linear conv layer - * @param pw_linear_bn_scale The scale params of the batch_normalize layer after the pointwise linear conv layer - * @param pw_linear_bn_offset The offset params of the batch_normalize layer after the pointwise linear conv layer - * @param stride_x The step length of the convolution window in x(width) direction - * @param stride_y The step length of the convolution window in y(height) direction - * @param padding One of VALID or SAME - * @param mode Do convolution using C implement or xtensa implement, 0 or 1, with respect - * If ESP_PLATFORM is not defined, this value is not used. Default is 0 - * @return The result of a mobilefacenet block - */ -dl_matrix3d_t *dl_matrix3d_mobilefaceblock(dl_matrix3d_t *in, - dl_matrix3d_t *pw, - dl_matrix3d_t *pw_bn_scale, - dl_matrix3d_t *pw_bn_offset, - dl_matrix3d_t *dw, - dl_matrix3d_t *dw_bn_scale, - dl_matrix3d_t *dw_bn_offset, - dl_matrix3d_t *pw_linear, - dl_matrix3d_t *pw_linear_bn_scale, - dl_matrix3d_t *pw_linear_bn_offset, - int stride_x, - int stride_y, - int padding, - int mode, - int shortcut); - -/** - * @brief Do a mobilefacenet block forward with 1x1 split conv, dimension is (number, width, height, channel) - * - * @param in Input matrix3d - * @param pw_1 Weights of the pointwise conv layer 1 - * @param pw_2 Weights of the pointwise conv layer 2 - * @param pw_bn_scale The scale params of the batch_normalize layer after the pointwise conv layer - * @param pw_bn_offset The offset params of the batch_normalize layer after the pointwise conv layer - * @param dw Weights of the depthwise conv layer - * @param dw_bn_scale The scale params of the batch_normalize layer after the depthwise conv layer - * @param dw_bn_offset The offset params of the batch_normalize layer after the depthwise conv layer - * @param pw_linear_1 Weights of the pointwise linear conv layer 1 - * @param pw_linear_2 Weights of the pointwise linear conv layer 2 - * @param pw_linear_bn_scale The scale params of the batch_normalize layer after the pointwise linear conv layer - * @param pw_linear_bn_offset The offset params of the batch_normalize layer after the pointwise linear conv layer - * @param stride_x The step length of the convolution window in x(width) direction - * @param stride_y The step length of the convolution window in y(height) direction - * @param padding One of VALID or SAME - * @param mode Do convolution using C implement or xtensa implement, 0 or 1, with respect - * If ESP_PLATFORM is not defined, this value is not used. Default is 0 - * @return The result of a mobilefacenet block - */ -dl_matrix3d_t *dl_matrix3d_mobilefaceblock_split(dl_matrix3d_t *in, - dl_matrix3d_t *pw_1, - dl_matrix3d_t *pw_2, - dl_matrix3d_t *pw_bn_scale, - dl_matrix3d_t *pw_bn_offset, - dl_matrix3d_t *dw, - dl_matrix3d_t *dw_bn_scale, - dl_matrix3d_t *dw_bn_offset, - dl_matrix3d_t *pw_linear_1, - dl_matrix3d_t *pw_linear_2, - dl_matrix3d_t *pw_linear_bn_scale, - dl_matrix3d_t *pw_linear_bn_offset, - int stride_x, - int stride_y, - int padding, - int mode, - int shortcut); - -/** - * @brief Initialize the matrix3d feature map to bias - * - * @param out The matrix3d feature map needs to be initialized - * @param bias The bias of a convlotion operation - */ -void dl_matrix3d_init_bias(dl_matrix3d_t *out, dl_matrix3d_t *bias); - -/** - * @brief Do a elementwise multiplication of two matrix3ds - * - * @param out Preallocated matrix3d, size (n, w, h, c) - * @param in1 Input matrix 1, size (n, w, h, c) - * @param in2 Input matrix 2, size (n, w, h, c) - */ -void dl_matrix3d_multiply(dl_matrix3d_t *out, dl_matrix3d_t *in1, dl_matrix3d_t *in2); - -// -// Activation -// - -/** - * @brief Do a standard relu operation, update the input matrix3d - * - * @param m Floating point input matrix3d - */ -void dl_matrix3d_relu(dl_matrix3d_t *m); - -/** - * @brief Do a relu (Rectifier Linear Unit) operation, update the input matrix3d - * - * @param in Floating point input matrix3d - * @param clip If value is higher than this, it will be clipped to this value - */ -void dl_matrix3d_relu_clip(dl_matrix3d_t *m, fptp_t clip); - -/** - * @brief Do a Prelu (Rectifier Linear Unit) operation, update the input matrix3d - * - * @param in Floating point input matrix3d - * @param alpha If value is less than zero, it will be updated by multiplying this factor - */ -void dl_matrix3d_p_relu(dl_matrix3d_t *in, dl_matrix3d_t *alpha); - -/** - * @brief Do a leaky relu (Rectifier Linear Unit) operation, update the input matrix3d - * - * @param in Floating point input matrix3d - * @param alpha If value is less than zero, it will be updated by multiplying this factor - */ -void dl_matrix3d_leaky_relu(dl_matrix3d_t *m, fptp_t alpha); - -// -// Conv 1x1 -// -/** - * @brief Do 1x1 convolution with a matrix3d - * - * @param out Preallocated matrix3d, size (1, w, h, n) - * @param in Input matrix, size (1, w, h, c) - * @param filter 1x1 filter, size (n, 1, 1, c) - */ -void dl_matrix3dff_conv_1x1(dl_matrix3d_t *out, - dl_matrix3d_t *in, - dl_matrix3d_t *filter); - -/** - * @brief Do 1x1 convolution with a matrix3d, with bias adding - * - * @param out Preallocated matrix3d, size (1, w, h, n) - * @param in Input matrix, size (1, w, h, c) - * @param filter 1x1 filter, size (n, 1, 1, c) - * @param bias Bias, size (1, 1, 1, n) - */ -void dl_matrix3dff_conv_1x1_with_bias(dl_matrix3d_t *out, - dl_matrix3d_t *in, - dl_matrix3d_t *filter, - dl_matrix3d_t *bias); - -/** - * @brief Do 1x1 convolution with an 8-bit fixed point matrix - * - * @param out Preallocated matrix3d, size (1, w, h, n) - * @param in Input matrix, size (1, w, h, c) - * @param filter 1x1 filter, size (n, 1, 1, c) - */ -void dl_matrix3duf_conv_1x1(dl_matrix3d_t *out, - dl_matrix3du_t *in, - dl_matrix3d_t *filter); - -/** - * @brief Do 1x1 convolution with an 8-bit fixed point matrix, with bias adding - * - * @param out Preallocated matrix3d, size (1, w, h, n) - * @param in Input matrix, size (1, w, h, c) - * @param filter 1x1 filter, size (n, 1, 1, c) - * @param bias Bias, size (1, 1, 1, n) - */ -void dl_matrix3duf_conv_1x1_with_bias(dl_matrix3d_t *out, - dl_matrix3du_t *in, - dl_matrix3d_t *filter, - dl_matrix3d_t *bias); - -// -// Conv 3x3 -// - -/** - * @brief Do 3x3 convolution with a matrix3d, without padding - * - * @param out Preallocated matrix3d, size (1, w, h, n) - * @param in Input matrix, size (1, w, h, c) - * @param f 3x3 filter, size (n, 3, 3, c) - * @param step_x Stride of width - * @param step_y Stride of height - */ -void dl_matrix3dff_conv_3x3_op(dl_matrix3d_t *out, - dl_matrix3d_t *in, - dl_matrix3d_t *f, - int step_x, - int step_y); - -/** - * @brief Do 3x3 convolution with a matrix3d, with bias adding - * - * @param input Input matrix, size (1, w, h, c) - * @param filter 3x3 filter, size (n, 3, 3, c) - * @param bias Bias, size (1, 1, 1, n) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type - * @return dl_matrix3d_t* Resulting matrix3d - */ -dl_matrix3d_t *dl_matrix3dff_conv_3x3(dl_matrix3d_t *in, - dl_matrix3d_t *filter, - dl_matrix3d_t *bias, - int stride_x, - int stride_y, - dl_padding_type padding); - -// -// Conv Common -// - -/** - * @brief Do a general convolution layer pass with an 8-bit fixed point matrix, size is (number, width, height, channel) - * - * @param in Input image - * @param filter Weights of the neurons - * @param bias Bias for the CNN layer - * @param stride_x The step length of the convolution window in x(width) direction - * @param stride_y The step length of the convolution window in y(height) direction - * @param padding Padding type - * @return dl_matrix3d_t* Resulting matrix3d - */ -dl_matrix3d_t *dl_matrix3duf_conv_common(dl_matrix3du_t *in, - dl_matrix3d_t *filter, - dl_matrix3d_t *bias, - int stride_x, - int stride_y, - dl_padding_type padding); - -/** - * @brief Do a general convolution layer pass, size is (number, width, height, channel) - * - * @param in Input image - * @param filter Weights of the neurons - * @param bias Bias for the CNN layer - * @param stride_x The step length of the convolution window in x(width) direction - * @param stride_y The step length of the convolution window in y(height) direction - * @param padding Padding type - * @return dl_matrix3d_t* Resulting matrix3d - */ -dl_matrix3d_t *dl_matrix3dff_conv_common(dl_matrix3d_t *in, - dl_matrix3d_t *filter, - dl_matrix3d_t *bias, - int stride_x, - int stride_y, - dl_padding_type padding); - -// -// Depthwise 3x3 -// - -/** - * @brief Do 3x3 depthwise convolution with a float matrix3d - * - * @param in Input matrix, size (1, w, h, c) - * @param filter 3x3 filter, size (1, 3, 3, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type, 0: valid, 1: same - * @return dl_matrix3d_t* Resulting float matrix3d - */ -dl_matrix3d_t *dl_matrix3dff_depthwise_conv_3x3(dl_matrix3d_t *in, - dl_matrix3d_t *filter, - int stride_x, - int stride_y, - int padding); - -/** - * @brief Do 3x3 depthwise convolution with a 8-bit fixed point matrix - * - * @param in Input matrix, size (1, w, h, c) - * @param filter 3x3 filter, size (1, 3, 3, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type, 0: valid, 1: same - * @return dl_matrix3d_t* Resulting float matrix3d - */ -dl_matrix3d_t *dl_matrix3duf_depthwise_conv_3x3(dl_matrix3du_t *in, - dl_matrix3d_t *filter, - int stride_x, - int stride_y, - int padding); - -/** - * @brief Do 3x3 depthwise convolution with a float matrix3d, without padding - * - * @param out Preallocated matrix3d, size (1, w, h, n) - * @param in Input matrix, size (1, w, h, c) - * @param f 3x3 filter, size (1, 3, 3, c) - * @param step_x Stride of width - * @param step_y Stride of height - */ -void dl_matrix3dff_depthwise_conv_3x3_op(dl_matrix3d_t *out, - dl_matrix3d_t *in, - dl_matrix3d_t *f, - int step_x, - int step_y); - -// -// Depthwise Common -// - -/** - * @brief Do a depthwise CNN layer pass, dimension is (number, width, height, channel) - * - * @param in Input matrix3d - * @param filter Weights of the neurons - * @param stride_x The step length of the convolution window in x(width) direction - * @param stride_y The step length of the convolution window in y(height) direction - * @param padding One of VALID or SAME - * @param mode Do convolution using C implement or xtensa implement, 0 or 1, with respect - * If ESP_PLATFORM is not defined, this value is not used. Default is 0 - * @return The result of depthwise CNN layer - */ -dl_matrix3d_t *dl_matrix3dff_depthwise_conv_common(dl_matrix3d_t *in, - dl_matrix3d_t *filter, - int stride_x, - int stride_y, - dl_padding_type padding); - -// -// FC -// -/** - * @brief Do a general fully connected layer pass, dimension is (number, width, height, channel) - * - * @param in Input matrix3d, size is (1, w, 1, 1) - * @param filter Weights of the neurons, size is (1, w, h, 1) - * @param bias Bias for the fc layer, size is (1, 1, 1, h) - * @return The result of fc layer, size is (1, 1, 1, h) - */ -void dl_matrix3dff_fc(dl_matrix3d_t *out, - dl_matrix3d_t *in, - dl_matrix3d_t *filter); - -/** - * @brief Do fully connected layer forward, with bias adding - * - * @param out Preallocated resulting matrix, size (1, 1, 1, h) - * @param in Input matrix, size (1, 1, 1, w) - * @param filter Filter matrix, size (1, w, h, 1) - * @param bias Bias matrix, size (1, 1, 1, h) - */ -void dl_matrix3dff_fc_with_bias(dl_matrix3d_t *out, - dl_matrix3d_t *in, - dl_matrix3d_t *filter, - dl_matrix3d_t *bias); - -// -// Mobilenet -// - -/** - * @brief Do a mobilenet block forward, dimension is (number, width, height, channel) - * - * @param in Input matrix3d - * @param filter Weights of the neurons - * @param stride_x The step length of the convolution window in x(width) direction - * @param stride_y The step length of the convolution window in y(height) direction - * @param padding One of VALID or SAME - * @param mode Do convolution using C implement or xtensa implement, 0 or 1, with respect - * If ESP_PLATFORM is not defined, this value is not used. Default is 0 - * @return The result of depthwise CNN layer - */ -dl_matrix3d_t *dl_matrix3dff_mobilenet(dl_matrix3d_t *in, - dl_matrix3d_t *dilate_filter, - dl_matrix3d_t *dilate_prelu, - dl_matrix3d_t *depthwise_filter, - dl_matrix3d_t *depthwise_prelu, - dl_matrix3d_t *compress_filter, - dl_matrix3d_t *bias, - dl_matrix3d_mobilenet_config_t config); - -/** - * @brief Do a mobilenet block forward, dimension is (number, width, height, channel) - * - * @param in Input matrix3du - * @param filter Weights of the neurons - * @param stride_x The step length of the convolution window in x(width) direction - * @param stride_y The step length of the convolution window in y(height) direction - * @param padding One of VALID or SAME - * @param mode Do convolution using C implement or xtensa implement, 0 or 1, with respect - * If ESP_PLATFORM is not defined, this value is not used. Default is 0 - * @return The result of depthwise CNN layer - */ -dl_matrix3d_t *dl_matrix3duf_mobilenet(dl_matrix3du_t *in, - dl_matrix3d_t *dilate_filter, - dl_matrix3d_t *dilate_prelu, - dl_matrix3d_t *depthwise_filter, - dl_matrix3d_t *depthwise_prelu, - dl_matrix3d_t *compress_filter, - dl_matrix3d_t *bias, - dl_matrix3d_mobilenet_config_t config); diff --git a/tools/sdk/esp32s2/include/esp-face/lib/include/dl_lib_matrix3dq.h b/tools/sdk/esp32s2/include/esp-face/lib/include/dl_lib_matrix3dq.h deleted file mode 100644 index 0d982b4a0e0..00000000000 --- a/tools/sdk/esp32s2/include/esp-face/lib/include/dl_lib_matrix3dq.h +++ /dev/null @@ -1,1441 +0,0 @@ -#pragma once -#include "dl_lib_matrix3d.h" - -typedef int16_t qtp_t; - -/** - * Matrix for input, filter, and output - * @Warning: the sequence of variables is fixed, cannot be modified, otherwise there will be errors in - * some handwrite xtensa instruction functions - */ -typedef struct -{ - /******* fix start *******/ - int w; /*!< Width */ - int h; /*!< Height */ - int c; /*!< Channel */ - int n; /*!< Number of filter, input and output must be 1 */ - int stride; /*!< Step between lines */ - int exponent; /*!< Exponent for quantization */ - qtp_t *item; /*!< Data */ - /******* fix end *******/ -} dl_matrix3dq_t; - -#ifndef DL_QTP_SHIFT -#define DL_QTP_SHIFT 15 -#define DL_ITMQ(m, x, y) m->itemq[(y) + (x)*m->stride] -#define DL_QTP_RANGE ((1 << DL_QTP_SHIFT) - 1) -#define DL_QTP_MAX 32767 -#define DL_QTP_MIN -32768 - -#define DL_QTP_EXP_NA 255 //non-applicable exponent because matrix is null - -#define DL_SHIFT_AUTO 32 -#endif - -/** - * Implementation of matrix relative operations - */ -typedef enum -{ - DL_C_IMPL = 0, /*!< ANSI C */ - DL_XTENSA_IMPL = 1 /*!< Handwrite xtensa instruction */ -} dl_conv_mode; - -/** - * Configuration of mobilenet operation - */ -typedef struct -{ - int stride_x; /*!< Strides of width */ - int stride_y; /*!< Strides of height */ - dl_padding_type padding; /*!< Padding type */ - dl_conv_mode mode; /*!< Implementation mode */ - int dilate_exponent; /*!< Exponent of dilation filter */ - int depthwise_exponent; /*!< Exponent of depthwise filter */ - int compress_exponent; /*!< Exponent of compress filter */ -} dl_matrix3dq_mobilenet_config_t; - -typedef struct -{ - int stride_x; /*!< Strides of width */ - int stride_y; /*!< Strides of height */ - dl_padding_type padding; /*!< Padding type */ - dl_conv_mode mode; /*!< Implementation mode */ - int dw1_exponent; /*!< Exponent of dw1 filter */ - int pw1_exponent; /*!< Exponent of pw1 filter */ - int dw2_exponent; /*!< Exponent of dw2 filter */ - int pw2_exponent; /*!< Exponent of pw2 filter */ - int shortcut; /*!< Shortcut connection flag */ - int save_input; /*!< Input save flag */ -} dl_matrix3dq_blazeblock_config_t; - -// -// Utility -// - -/* - * @brief Allocate a 3d quantised matrix - * - * @param n Number of filters, for input and output, should be 1 - * @param w Width of matrix - * @param h Height of matrix - * @param c Channel of matrix - * @param e Exponent of matrix data - * @return 3d quantized matrix - */ -static inline dl_matrix3dq_t *dl_matrix3dq_alloc(int n, int w, int h, int c, int e) -{ - dl_matrix3dq_t *r = (dl_matrix3dq_t *)dl_lib_calloc(1, sizeof(dl_matrix3dq_t), 0); - if (NULL == r) - { - printf("dl_matrix3dq alloc failed.\n"); - return NULL; - } - - qtp_t *items = (qtp_t *)dl_lib_calloc(n * w * h * c, sizeof(qtp_t), 16); - if (NULL == items) - { - printf("matrix3dq item alloc failed.\n"); - dl_lib_free(r); - return NULL; - } - - r->w = w; - r->h = h; - r->c = c; - r->n = n; - r->exponent = e; - r->stride = w * c; - r->item = items; - - return r; -} - -/* - * @brief Free a 3d quantized matrix - * - * @param m 3d quantised matrix - */ -static inline void dl_matrix3dq_free(dl_matrix3dq_t *m) -{ - if (NULL == m) - return; - if (NULL == m->item) - { - dl_lib_free(m); - return; - } - dl_lib_free(m->item); - dl_lib_free(m); -} - - -/** - * @brief Copy a range of items from an existing matrix to a preallocated matrix - * - * @param dst The resulting slice matrix - * @param src Old matrix to slice. - * @param x X-offset of the origin of the returned matrix within the sliced matrix - * @param y Y-offset of the origin of the returned matrix within the sliced matrix - * @param w Width of the resulting matrix - * @param h Height of the resulting matrix - */ -void dl_matrix3dq_slice_copy(dl_matrix3dq_t *dst, dl_matrix3dq_t *src, int x, int y, int w, int h); - -/** - * @brief Transform a sliced matrix block from nhwc to nchw, the block needs to be memory continous. - * - * @param out The destination sliced matrix in nchw - * @param in The source sliced matrix in nhwc - */ -void dl_matrix3dq_sliced_transform_nchw(dl_matrix3dq_t *out, - dl_matrix3dq_t *in); - -/** - * @brief Transform a fixed point matrix to a float point matrix - * - * @param m Quantized matrix - * @return Float point matrix - */ -dl_matrix3d_t *dl_matrix3d_from_matrixq(dl_matrix3dq_t *m); - -/** - * @brief Transform a float point matrix to a fixed point matrix with pre-defined exponent - * - * @param m Float point matrix - * @param exponent Exponent for resulting matrix - * @return Fixed point matrix - */ -dl_matrix3dq_t *dl_matrixq_from_matrix3d_qmf(dl_matrix3d_t *m, int exponent); - -/** - * @brief Transform a float point matrix to a fixed point matrix. The exponent is defined by the distribution of the input matrix. - * - * @param m Float point matrix - * @return Fixed point matrix - */ -dl_matrix3dq_t *dl_matrixq_from_matrix3d(dl_matrix3d_t *m); - -/** - * @brief Truncate the overflowed 16bit number - * - * @param value Input value - * @param location Location tag - * @return qtp_t Truncated value - */ -qtp_t dl_matrix3dq_quant_range_exceeded_checking(int64_t value, char *location); - -/** - * @brief Reform a quantized matrix with exponent - * - * @param out Preallocated resulting matrix - * @param in Input matrix - * @param exponent Exponent for resulting matrix - */ -void dl_matrix3dq_shift_exponent(dl_matrix3dq_t *out, dl_matrix3dq_t *in, int exponent); - -/** - * @brief Do batch normalization for a quantized matrix - * - * @param m Input and output quantized matrix, data will be updated - * @param scale Scale of batch-norm - * @param offset Offset of batch-norm - */ -void dl_matrix3dq_batch_normalize(dl_matrix3dq_t *m, dl_matrix3dq_t *scale, dl_matrix3dq_t *offset); - -/** - * @brief Add two quantized matrix with a pre-defined exponent - * - * @param in_1 Adder 1 - * @param in_2 Adder 2 - * @param exponent Exponent for resulting matrix - * @return dl_matrix3dq_t* Result of accumulation of two matrix - */ -dl_matrix3dq_t *dl_matrix3dq_add(dl_matrix3dq_t *in_1, dl_matrix3dq_t *in_2, int exponent); - -/** - * @brief Add two quantized matrix with different channels - * - * @param in_1 Adder 1 - * @param in_2 Adder 2 - * @param exponent Exponent for resulting matrix - * @return dl_matrix3dq_t* Result of accumulation of two matrix - */ -dl_matrix3dq_t *dl_matrix3dq_add_channel_diff(dl_matrix3dq_t *in_1, dl_matrix3dq_t *in_2, int exponent); - -// -// Activation -// -/** - * @brief Do relu for a quantized matrix - * - * @param in Input and output quantized matrix, data will be updated - */ -void dl_matrix3dq_relu(dl_matrix3dq_t *in); - -/** - * @brief Do relu with clips for a quantized matrix - * - * @param in Input and output quantized matrix, data will be updated - * @param clip Float point value to limit the maximum data - */ -void dl_matrix3dq_relu_clip(dl_matrix3dq_t *in, fptp_t clip); - -/** - * @brief Do leaky relu for a quantized matrix - * - * @param in Input and output quantized matrix, data will be updated - * @param alpha Float point value to multiply for those less than zero - * @param clip Float point value to limit the maximum data - */ -void dl_matrix3dq_leaky_relu(dl_matrix3dq_t *in, fptp_t alpha, fptp_t clip); - -/** - * @brief Do prelu for a quantized matrix - * - * @param in Input and output quantized matrix, data will be updated - * @param alpha Quantized matrix to multiply for those less than zero - */ -void dl_matrix3dq_p_relu(dl_matrix3dq_t *in, dl_matrix3dq_t *alpha); - -// -// Concat -// -/** - * @brief Concatenate two quantized matrix in channel - * - * @param in_1 Quantized matrix to be concatenated - * @param in_2 Quantized matrix to be concatenated - * @return Quantized matrix with the same width and height of in_1 and in_2, and with the sum of channel number of in_1 and in_2 - */ -dl_matrix3dq_t *dl_matrix3dq_concat(dl_matrix3dq_t *in_1, - dl_matrix3dq_t *in_2); - -/** - * @brief Concatenate four quantized matrix in channel - * - * @param in_1 Quantized matrix to be concatenated - * @param in_2 Quantized matrix to be concatenated - * @param in_3 Quantized matrix to be concatenated - * @param in_4 Quantized matrix to be concatenated - * @return Quantized matrix with the same width and height of all inputs, and with the sum of channel number of all inputs - */ -dl_matrix3dq_t *dl_matrix3dq_concat_4(dl_matrix3dq_t *in_1, - dl_matrix3dq_t *in_2, - dl_matrix3dq_t *in_3, - dl_matrix3dq_t *in_4); - -/** - * @brief Concatenate four quantized matrix in channel - * - * @param in_1 Quantized matrix to be concatenated - * @param in_2 Quantized matrix to be concatenated - * @param in_3 Quantized matrix to be concatenated - * @param in_4 Quantized matrix to be concatenated - * @param in_5 Quantized matrix to be concatenated - * @param in_6 Quantized matrix to be concatenated - * @param in_7 Quantized matrix to be concatenated - * @param in_8 Quantized matrix to be concatenated - * @return Quantized matrix with the same width and height of all inputs, and with the sum of channel number of all inputs - */ -dl_matrix3dq_t *dl_matrix3dq_concat_8(dl_matrix3dq_t *in_1, - dl_matrix3dq_t *in_2, - dl_matrix3dq_t *in_3, - dl_matrix3dq_t *in_4, - dl_matrix3dq_t *in_5, - dl_matrix3dq_t *in_6, - dl_matrix3dq_t *in_7, - dl_matrix3dq_t *in_8); - -// -// Conv 1x1 -// -/** - * @brief Do 1x1 convolution with a quantized matrix - * - * @param out Preallocated quantized matrix, size (1, w, h, n) - * @param in Input matrix, size (1, w, h, c) - * @param filter 1x1 filter, size (n, 1, 1, c) - * @param mode Implementation mode - * @param name Layer name to debug - */ -void dl_matrix3dqq_conv_1x1(dl_matrix3dq_t *out, - dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - dl_conv_mode mode, - char *name); - -/** - * @brief Do 1x1 convolution with a quantized matrix, with relu activation - * - * @param out Preallocated quantized matrix, size (1, w, h, n) - * @param in Input matrix, size (1, w, h, c) - * @param filter 1x1 filter, size (n, 1, 1, c) - * @param mode Implementation mode - * @param name Layer name to debug - */ -void dl_matrix3dqq_conv_1x1_with_relu(dl_matrix3dq_t *out, - dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - dl_conv_mode mode, - char *name); - -/** - * @brief Do 1x1 convolution with a quantized matrix, with bias adding - * - * @param out Preallocated quantized matrix, size (1, w, h, n) - * @param in Input matrix, size (1, w, h, c) - * @param filter 1x1 filter, size (n, 1, 1, c) - * @param bias Bias, size (1, 1, 1, n) - * @param mode Implementation mode - * @param name Layer name to debug - */ -void dl_matrix3dqq_conv_1x1_with_bias(dl_matrix3dq_t *out, - dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *bias, - dl_conv_mode mode, - char *name); - -/** - * @brief Do 1x1 convolution with a quantized matrix, with bias adding - * - * @param out Preallocated quantized matrix, size (1, w, h, n) - * @param in Input matrix, size (1, w, h, c) - * @param filter 1x1 filter, size (n, 1, 1, c) - * @param bias Bias, size (1, 1, 1, n) - * @param mode Implementation mode - * @param name Layer name to debug - */ -void dl_matrix3dqq_conv_1x1_with_bias_relu(dl_matrix3dq_t *out, - dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *bias, - dl_conv_mode mode, - char *name); - -/** - * @brief Do 1x1 convolution with a quantized matrix, with prelu activation - * - * @param out Preallocated quantized matrix, size (1, w, h, n) - * @param in Input matrix, size (1, w, h, c) - * @param filter 1x1 filter, size (n, 1, 1, c) - * @param prelu prelu params, size (1, 1, 1, n) - * @param mode Implementation mode - * @param name Layer name to debug - */ -void dl_matrix3dqq_conv_1x1_with_prelu(dl_matrix3dq_t *out, - dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *prelu, - dl_conv_mode mode, - char *name); - -/** - * @brief Do 1x1 convolution with an 8-bit fixed point matrix - * - * @param out Preallocated quantized matrix, size (1, w, h, n) - * @param in Input matrix, size (1, w, h, c) - * @param filter 1x1 filter, size (n, 1, 1, c) - * @param mode Implementation mode - * @param name Layer name to debug - */ -void dl_matrix3duq_conv_1x1(dl_matrix3dq_t *out, - dl_matrix3du_t *in, - dl_matrix3dq_t *filter, - dl_conv_mode mode, - char *name); - -/** - * @brief Do 1x1 convolution with an 8-bit fixed point matrix, with bias adding - * - * @param out Preallocated quantized matrix, size (1, w, h, n) - * @param in Input matrix, size (1, w, h, c) - * @param filter 1x1 filter, size (n, 1, 1, c) - * @param bias Bias, size (1, 1, 1, n) - * @param mode Implementation mode - * @param name Layer name to debug - */ -void dl_matrix3duq_conv_1x1_with_bias(dl_matrix3dq_t *out, - dl_matrix3du_t *in, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *bias, - dl_conv_mode mode, - char *name); - -// -// Conv 3x3 -// - -/** - * @brief Do 3x3 convolution with a quantized matrix - * - * @param input Input matrix, size (1, w, h, c) - * @param filter 3x3 filter, size (n, 3, 3, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type, 0: valid, 1: same - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_conv_3x3(dl_matrix3dq_t *input, - dl_matrix3dq_t *filter, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); - -/** - * @brief Do 3x3 convolution with a quantized matrix, with bias adding - * - * @param input Input matrix, size (1, w, h, c) - * @param filter 3x3 filter, size (n, 3, 3, c) - * @param bias Bias, size (1, 1, 1, n) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_conv_3x3_with_bias(dl_matrix3dq_t *input, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *bias, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); - -/** - * @brief Do 3x3 convolution with a quantized matrix, with bias adding, relu activation - * - * @param input Input matrix, size (1, w, h, c) - * @param filter 3x3 filter, size (n, 3, 3, c) - * @param bias Bias, size (1, 1, 1, n) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_conv_3x3_with_bias_relu(dl_matrix3dq_t *input, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *bias, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); - -/** - * @brief Do 3x3 convolution with an 8-bit fixed point matrix, with bias adding - * - * @param input Input matrix, size (1, w, h, c) - * @param filter 3x3 filter, size (n, 3, 3, c) - * @param bias Bias, size (1, 1, 1, n) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3duq_conv_3x3_with_bias(dl_matrix3du_t *input, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *bias, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); - -/** - * @brief Do 3x3 convolution with an 8-bit fixed point matrix, with bias adding, prelu activation - * - * @param input Input matrix, size (1, w, h, c) - * @param filter 3x3 filter, size (n, 3, 3, c) - * @param bias Bias, size (1, 1, 1, n) - * @param prelu prelu params, size (1, 1, 1, n) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3duq_conv_3x3_with_bias_prelu(dl_matrix3du_t *input, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *bias, - dl_matrix3dq_t *prelu, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); - - -/** - * @brief Do 3x3 convolution with a quantized matrix, with bias adding, prelu activation - * - * @param input Input matrix, size (1, w, h, c) - * @param filter 3x3 filter, size (n, 3, 3, c) - * @param bias Bias, size (1, 1, 1, n) - * @param prelu prelu params, size (1, 1, 1, n) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_conv_3x3_with_bias_prelu(dl_matrix3dq_t *input, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *bias, - dl_matrix3dq_t *prelu, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); -// -// Conv common -// - -/** - * @brief Do a general convolution layer pass, size is (number, width, height, channel) - * - * @param in Input image - * @param filter Weights of the neurons - * @param bias Bias for the CNN layer. - * @param stride_x The step length of the convolution window in x(width) direction - * @param stride_y The step length of the convolution window in y(height) direction - * @param padding One of VALID or SAME - * @param mode Do convolution using C implement or xtensa implement, 0 or 1, with respect. - * If ESP_PLATFORM is not defined, this value is not used. - * @return The result of CNN layer. - */ -dl_matrix3dq_t *dl_matrix3dqq_conv_common(dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *bias, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - dl_conv_mode mode); - -/** - * @brief Do a general convolution layer pass for an 8-bit fixed point matrix, size is (number, width, height, channel) - * - * @param in Input image - * @param filter Weights of the neurons - * @param bias Bias for the CNN layer. - * @param stride_x The step length of the convolution window in x(width) direction - * @param stride_y The step length of the convolution window in y(height) direction - * @param padding One of VALID or SAME - * @param mode Do convolution using C implement or xtensa implement, 0 or 1, with respect. - * If ESP_PLATFORM is not defined, this value is not used. - * @return The result of CNN layer. - */ -dl_matrix3dq_t *dl_matrix3duq_conv_common(dl_matrix3du_t *in, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *bias, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - dl_conv_mode mode); - -// -// Depthwise 3x3 -// -/** - * @brief Do 3x3 depthwise convolution with an 8-bit fixed point matrix - * - * @param in Input matrix, size (1, w, h, c) - * @param filter 3x3 filter, size (1, 3, 3, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type, 0: valid, 1: same - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3duq_depthwise_conv_3x3(dl_matrix3du_t *in, - dl_matrix3dq_t *filter, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); - -/** - * @brief Do 3x3 depthwise convolution with a quantized matrix - * - * @param in Input matrix, size (1, w, h, c) - * @param filter 3x3 filter, size (1, 3, 3, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type, 0: valid, 1: same - * @param relu ReLU, 0: don't, 1: do - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_3x3(dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - int stride_x, - int stride_y, - dl_padding_type padding, - int relu, - int exponent, - char *name); - -#if CONFIG_DEVELOPING_CODE -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_3x3_2(dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); - -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_3x3_3(dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); -#endif - -/** - * @brief Do 3x3 depthwise convolution with a quantized matrix, with bias adding - * - * @param in Input matrix, size (1, w, h, c) - * @param f 3x3 filter, size (1, 3, 3, c) - * @param bias Bias, size (1, 1, 1, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type, 0: valid, 1: same - * @param exponent Exponent for resulting matrix - * @param relu Whether to use relu activation - * @param name Layer name to debug - * @return Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_3x3_with_bias(dl_matrix3dq_t *in, - dl_matrix3dq_t *f, - dl_matrix3dq_t *bias, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - int relu, - char *name); - -/** - * @brief Do 3x3 depthwise convolution with a quantized matrix, with bias adding and stride 1 - * - * @param in Input matrix, size (1, w, h, c) - * @param f 3x3 filter, size (1, 3, 3, c) - * @param bias Bias, size (1, 1, 1, c) - * @param padding Padding type, 0: valid, 1: same - * @param exponent Exponent for resulting matrix - * @param relu Whether to use relu activation - * @param name Layer name to debug - * @return Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_3x3s1_with_bias(dl_matrix3dq_t *in, - dl_matrix3dq_t *f, - dl_matrix3dq_t *bias, - dl_padding_type padding, - int exponent, - int relu, - char *name); - -/** - * @brief Do 3x3 depthwise convolution with a quantized matrix, with prelu activation - * - * @param in Input matrix, size (1, w, h, c) - * @param filter 3x3 filter, size (1, 3, 3, c) - * @param prelu prelu params, size (1, 1, 1, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_3x3_with_prelu(dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *prelu, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); - -/** - * @brief Do 3x3 depthwise convolution with a quantized matrix, with bias adding and prelu activation - * - * @param in Input matrix, size (1, w, h, c) - * @param f 3x3 filter, size (1, 3, 3, c) - * @param bias Bias, size (1, 1, 1, c) - * @param prelu prelu params, size (1, 1, 1, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_3x3_with_bias_prelu(dl_matrix3dq_t *in, - dl_matrix3dq_t *f, - dl_matrix3dq_t *bias, - dl_matrix3dq_t *prelu, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); - -/** - * @brief Do global depthwise convolution with a quantized matrix, with bias adding - * - * @param in Input matrix, size (1, w, h, c) - * @param filter filter, size (1, w, h, c) - * @param bias Bias, size (1, 1, 1, c) - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_global_depthwise_conv_with_bias(dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *bias, - int exponent, - char *name); - - - -// -// Depthwise 2x2 -// -/** - * @brief Do 2x2 depthwise convolution with a quantized matrix - * - * @param in Input matrix, size (1, w, h, c) - * @param filter 2x2 filter, size (1, 2, 2, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type, 0: valid, 1: same - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_2x2(dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); - -/** - * @brief Do 2x2 depthwise convolution with a quantized matrix, with bias adding - * - * @param in Input matrix, size (1, w, h, c) - * @param f 2x2 filter, size (1, 2, 2, c) - * @param bias Bias, size (1, 1, 1, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type, 0: valid, 1: same - * @param exponent Exponent for resulting matrix - * @param relu Whether to use relu activation - * @param name Layer name to debug - * @return Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_2x2_with_bias(dl_matrix3dq_t *in, - dl_matrix3dq_t *f, - dl_matrix3dq_t *bias, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - int relu, - char *name); - -/** - * @brief Do 2x2 depthwise convolution with a quantized matrix, with prelu activation - * - * @param in Input matrix, size (1, w, h, c) - * @param filter 2x2 filter, size (1, 2, 2, c) - * @param prelu prelu params, size (1, 1, 1, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_2x2_with_prelu(dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *prelu, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); - -/** - * @brief Do 2x2 depthwise convolution with a quantized matrix, with bias adding and prelu activation - * - * @param in Input matrix, size (1, w, h, c) - * @param f 2x2 filter, size (1, 2, 2, c) - * @param bias Bias, size (1, 1, 1, c) - * @param prelu prelu params, size (1, 1, 1, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_2x2_with_bias_prelu(dl_matrix3dq_t *in, - dl_matrix3dq_t *f, - dl_matrix3dq_t *bias, - dl_matrix3dq_t *prelu, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); - -// -// Depthwise 5x5 -// -/** - * @brief Do 5x5 depthwise convolution with a quantized matrix - * - * @param in Input matrix, size (1, w, h, c) - * @param filter 5x5 filter, size (1, 5, 5, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type, 0: valid, 1: same - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_5x5(dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); - -/** - * @brief Do 5x5 depthwise convolution with a quantized matrix, with bias adding - * - * @param in Input matrix, size (1, w, h, c) - * @param f 5x5 filter, size (1, 5, 5, c) - * @param bias Bias, size (1, 1, 1, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type, 0: valid, 1: same - * @param exponent Exponent for resulting matrix - * @param relu Whether to use relu activation - * @param name Layer name to debug - * @return Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_5x5_with_bias(dl_matrix3dq_t *in, - dl_matrix3dq_t *f, - dl_matrix3dq_t *bias, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - int relu, - char *name); - -/** - * @brief Do 5x5 depthwise convolution with a quantized matrix, with prelu activation - * - * @param in Input matrix, size (1, w, h, c) - * @param filter 5x5 filter, size (1, 5, 5, c) - * @param prelu prelu params, size (1, 1, 1, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_5x5_with_prelu(dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *prelu, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); - -/** - * @brief Do 5x5 depthwise convolution with a quantized matrix, with bias adding and prelu activation - * - * @param in Input matrix, size (1, w, h, c) - * @param f 5x5 filter, size (1, 5, 5, c) - * @param bias Bias, size (1, 1, 1, c) - * @param prelu prelu params, size (1, 1, 1, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type - * @param exponent Exponent for resulting matrix - * @param name Layer name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_5x5_with_bias_prelu(dl_matrix3dq_t *in, - dl_matrix3dq_t *f, - dl_matrix3dq_t *bias, - dl_matrix3dq_t *prelu, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - char *name); - -// -// Depthwise Common -// -#if CONFIG_DEVELOPING_CODE -/** - * @brief Do a general depthwise convolution layer pass with a quantized matrix - * - * @param in Input matrix, size (1, w, h, c) - * @param filter Weights of the neurons, size (1, k_w, k_h, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type - * @param exponent Exponent for resulting matrix - * @param mode Implementation mode - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_depthwise_conv_common(dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - dl_conv_mode mode); - -/** - * @brief Do a general depthwise convolution layer pass with an 8-bit fixed point matrix - * - * @param in Input matrix, size (1, w, h, c) - * @param filter Weights of the neurons, size (1, k_w, k_h, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type - * @param exponent Exponent for resulting matrix - * @param mode Implementation mode - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3duq_depthwise_conv_common(dl_matrix3du_t *in, - dl_matrix3dq_t *filter, - int stride_x, - int stride_y, - dl_padding_type padding, - int exponent, - dl_conv_mode mode); -#endif - -// -// Dot Product -// - -/** - * @brief Do dot product operation with a quantized matrix - * - * @param out Preallocated resulting matrix, size (1, 1, 1, h) - * @param in Input matrix, size (1, 1, 1, w) - * @param filter Filter matrix, size (1, w, h, 1) - * @param mode Implementation mode - */ -void dl_matrix3dqq_dot_product(dl_matrix3dq_t *out, - dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - dl_conv_mode mode); - -// -// FC -// -/** - * @brief Do fully connected layer forward. - * - * @param out Preallocated resulting matrix, size (1, 1, 1, h) - * @param in Input matrix, size (1, 1, 1, w) - * @param filter Filter matrix, size (1, w, h, 1) - * @param mode Implementation mode - * @param name Layer name to debug - */ -void dl_matrix3dqq_fc(dl_matrix3dq_t *out, - dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - dl_conv_mode mode, - char *name); - -/** - * @brief Do fully connected layer forward, with bias adding - * - * @param out Preallocated resulting matrix, size (1, 1, 1, h) - * @param in Input matrix, size (1, 1, 1, w) - * @param filter Filter matrix, size (1, w, h, 1) - * @param bias Bias matrix, size (1, 1, 1, h) - * @param mode Implementation mode - * @param name Layer name to debug - */ -void dl_matrix3dqq_fc_with_bias(dl_matrix3dq_t *out, - dl_matrix3dq_t *in, - dl_matrix3dq_t *filter, - dl_matrix3dq_t *bias, - dl_conv_mode mode, - char *name); - -// -// Mobilefaceblock -// -/** - * @brief Do mobilefacenet process with splited pointwise 1x1 convolution, the process sequence is 1x1 pointwise->bn->relu->3x3 depthwise->bn->relu->1x1 pointwise->bn - * - * @param in Input matrix, size (1, w, h, c) - * @param pw_1 Pointwise 1x1 filter, size (n1/2, 1, 1, c) - * @param pw_2 Pointwise 1x1 filter, size (n1/2, 1, 1, c) - * @param pw_bias Pointwise bias, size (1, 1, 1, n1) - * @param dw Depthwise 3x3 filter, size (1, 3, 3, n1) - * @param dw_bias Depthwise bias, size (1, 1, 1, n1) - * @param pw_linear_1 Pointwise 1x1 filter, size (n2/2, 1, 1, n1) - * @param pw_linear_2 Pointwise 1x1 filter, size (n2/2, 1, 1, n1) - * @param pw_linear_bias Pointwise bias, size (1, 1, 1, n2) - * @param pw_exponent Exponent for pointwise resulting matrix - * @param dw_exponent Exponent for depthwise resulting matrix - * @param pw_linear_exponent Exponent for pointwise resulting matrix - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type, 0: valid, 1: same - * @param mode Implementation mode - * @param shortcut Whether has a shortcut at pointwise linear - * @return Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_mobilefaceblock_split(dl_matrix3dq_t *in, - dl_matrix3dq_t *pw_1, - dl_matrix3dq_t *pw_2, - dl_matrix3dq_t *pw_bias, - dl_matrix3dq_t *dw, - dl_matrix3dq_t *dw_bias, - dl_matrix3dq_t *pw_linear_1, - dl_matrix3dq_t *pw_linear_2, - dl_matrix3dq_t *pw_linear_bias, - int pw_exponent, - int dw_exponent, - int pw_linear_exponent, - int stride_x, - int stride_y, - dl_padding_type padding, - dl_conv_mode mode, - int shortcut); - -/** - * @brief Do mobilefacenet process, the process sequence is 1x1 pointwise->bn->relu->3x3 depthwise->bn->relu->1x1 pointwise->bn - * - * @param in Input matrix, size (1, w, h, c) - * @param pw Pointwise 1x1 filter, size (n1, 1, 1, c) - * @param pw_bias Pointwise bias, size (1, 1, 1, n1) - * @param dw Depthwise 3x3 filter, size (1, 3, 3, n1) - * @param dw_bias Depthwise bias, size (1, 1, 1, n1) - * @param pw_linear Pointwise 1x1 filter, size (n2, 1, 1, n1) - * @param pw_linear_bias Pointwise bias, size (1, 1, 1, n2) - * @param pw_exponent Exponent for pointwise resulting matrix - * @param dw_exponent Exponent for depthwise resulting matrix - * @param pw_linear_exponent Exponent for pointwise resulting matrix - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Padding type, 0: valid, 1: same - * @param mode Implementation mode - * @param shortcut Whether has a shortcut at pointwise linear - * @return Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_mobilefaceblock(dl_matrix3dq_t *in, - dl_matrix3dq_t *pw, - dl_matrix3dq_t *pw_bias, - dl_matrix3dq_t *dw, - dl_matrix3dq_t *dw_bias, - dl_matrix3dq_t *pw_linear, - dl_matrix3dq_t *pw_linear_bias, - int pw_exponent, - int dw_exponent, - int pw_linear_exponent, - int stride_x, - int stride_y, - dl_padding_type padding, - dl_conv_mode mode, - int shortcut); - -/** - * @brief Do mobilefacenet process, the process sequence is 1x1 pointwise->bn->prelu->3x3 depthwise->bn->prelu->1x1 pointwise->bn - * - * @param in Input matrix, size (1, w, h, c) - * @param pw Pointwise 1x1 filter, size (n1, 1, 1, c) - * @param pw_bias Pointwise bias, size (1, 1, 1, n1) - * @param pw_prelu Pointwise prelu, size (1, 1, 1, n1) - * @param dw Depthwise 3x3 filter, size (1, 3, 3, n1) - * @param dw_bias Depthwise bias, size (1, 1, 1, n1) - * @param dw_prelu Depthwise prelu, size(1, 1, 1, n1) - * @param pw_linear Pointwise 1x1 filter, size (n2, 1, 1, n1) - * @param pw_linear_bias Pointwise bias, size (1, 1, 1, n2) - * @param pw_exponent Exponent for pointwise resulting matrix - * @param dw_exponent Exponent for depthwise resulting matrix - * @param pw_linear_exponent Exponent for pointwise resulting matrix - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param padding Depthwise Convlution Padding type - * @param mode Implementation mode - * @param shortcut Whether has a shortcut at pointwise linear - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_mobilefaceblock_prelu(dl_matrix3dq_t *in, - dl_matrix3dq_t *pw, - dl_matrix3dq_t *pw_bias, - dl_matrix3dq_t *pw_prelu, - dl_matrix3dq_t *dw, - dl_matrix3dq_t *dw_bias, - dl_matrix3dq_t *dw_prelu, - dl_matrix3dq_t *pw_linear, - dl_matrix3dq_t *pw_linear_bias, - int pw_exponent, - int dw_exponent, - int pw_linear_exponent, - int stride_x, - int stride_y, - dl_padding_type padding, - dl_conv_mode mode, - int shortcut); - -/**@{*/ -/** - * @brief Do mobilefacenet process, the process sequence is 1x1 pointwise->bn->prelu->3x3 depthwise->bn->prelu->1x1 pointwise->bn - * - * Compared to ‘dl_matrix3dqq_mobilefaceblock_prelu’, this family of functions 'dl_matrix3dqq_mobilefaceblock_prelu_split_x1_x2' - * split the first pointwise convlution into x1 pointwise convlutions, and split the second pointwise convlution into x2 pointwise convlutions. - * - * - */ -dl_matrix3dq_t *dl_matrix3dqq_mobilefaceblock_prelu_split_2_2(dl_matrix3dq_t *in, - dl_matrix3dq_t *pw_1, - dl_matrix3dq_t *pw_2, - dl_matrix3dq_t *pw_bias, - dl_matrix3dq_t *pw_prelu, - dl_matrix3dq_t *dw, - dl_matrix3dq_t *dw_bias, - dl_matrix3dq_t *dw_prelu, - dl_matrix3dq_t *pw_linear_1, - dl_matrix3dq_t *pw_linear_2, - dl_matrix3dq_t *pw_linear_bias, - int pw_exponent, - int dw_exponent, - int pw_linear_exponent, - int stride_x, - int stride_y, - dl_padding_type padding, - dl_conv_mode mode, - int shortcut); - -dl_matrix3dq_t *dl_matrix3dqq_mobilefaceblock_prelu_split_4_4(dl_matrix3dq_t *in, - dl_matrix3dq_t *pw_1, - dl_matrix3dq_t *pw_2, - dl_matrix3dq_t *pw_3, - dl_matrix3dq_t *pw_4, - dl_matrix3dq_t *pw_bias, - dl_matrix3dq_t *pw_prelu, - dl_matrix3dq_t *dw, - dl_matrix3dq_t *dw_bias, - dl_matrix3dq_t *dw_prelu, - dl_matrix3dq_t *pw_linear_1, - dl_matrix3dq_t *pw_linear_2, - dl_matrix3dq_t *pw_linear_3, - dl_matrix3dq_t *pw_linear_4, - dl_matrix3dq_t *pw_linear_bias, - int pw_exponent, - int dw_exponent, - int pw_linear_exponent, - int stride_x, - int stride_y, - dl_padding_type padding, - dl_conv_mode mode, - int shortcut); - -dl_matrix3dq_t *dl_matrix3dqq_mobilefaceblock_prelu_split_1_2(dl_matrix3dq_t *in, - dl_matrix3dq_t *pw, - dl_matrix3dq_t *pw_bias, - dl_matrix3dq_t *pw_prelu, - dl_matrix3dq_t *dw, - dl_matrix3dq_t *dw_bias, - dl_matrix3dq_t *dw_prelu, - dl_matrix3dq_t *pw_linear_1, - dl_matrix3dq_t *pw_linear_2, - dl_matrix3dq_t *pw_linear_bias, - int pw_exponent, - int dw_exponent, - int pw_linear_exponent, - int stride_x, - int stride_y, - dl_padding_type padding, - dl_conv_mode mode, - int shortcut); -/**@}*/ - -// -// blazeblock -// - -/** - * @brief Do blazeblock process, the process sequence is depthwise->bn->1x1 pointwise->bn->shortcut->relu - * - * @param in Input matrix, size (1, w, h, c) - * @param dw1_kernel Depthwise filter, size (1, k, k, c) - * @param dw1_bias Depthwise bias, size (1, 1, 1, c) - * @param pw1_kernel Pointwise 1x1 filter, size (n, 1, 1, c) - * @param pw1_bias Pointwise bias, size (1, 1, 1, n) - * @param config blazeblock configuration - * @param name Layer name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_blazeblock(dl_matrix3dq_t *in, - dl_matrix3dq_t *dw1_kernel, - dl_matrix3dq_t *dw1_bias, - dl_matrix3dq_t *pw1_kernel, - dl_matrix3dq_t *pw1_bias, - dl_matrix3dq_blazeblock_config_t config, - char *name); - -/** - * @brief Do double blazeblock process, the process sequence is depthwise->bn->1x1 pointwise->bn->relu->depthwise->bn->1x1 pointwise->bn->shortcut->relu - * - * @param in Input matrix, size (1, w, h, c) - * @param dw1_kernel Depthwise filter, size (1, k, k, c) - * @param dw1_bias Depthwise bias, size (1, 1, 1, c) - * @param pw1_kernel Pointwise 1x1 filter, size (n1, 1, 1, c) - * @param pw1_bias Pointwise bias, size (1, 1, 1, n1) - * @param dw2_kernel Depthwise filter, size (1, k, k, n1) - * @param dw2_bias Depthwise bias, size (1, 1, 1, n1) - * @param pw2_kernel Pointwise 1x1 filter, size (n2, 1, 1, n1) - * @param pw2_bias Pointwise bias, size (1, 1, 1, n2) - * @param config blazeblock configuration - * @param name Layer name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_double_blazeblock(dl_matrix3dq_t *in, - dl_matrix3dq_t *dw1_kernel, - dl_matrix3dq_t *dw1_bias, - dl_matrix3dq_t *pw1_kernel, - dl_matrix3dq_t *pw1_bias, - dl_matrix3dq_t *dw2_kernel, - dl_matrix3dq_t *dw2_bias, - dl_matrix3dq_t *pw2_kernel, - dl_matrix3dq_t *pw2_bias, - dl_matrix3dq_blazeblock_config_t config, - char *name); -// -// Mobilenet -// - -/** - * @brief Do mobilenet process, the process sequence is 1x1 dilated->prelu->3x3 depthwise->prelu->1x1 compress->bias - * - * @param in Input matrix, size (1, w, h, c) - * @param dilate Pointwise 1x1 filter, size (n1, 1, 1, c) - * @param dilate_prelu Pointwise prelu, size (1, 1, 1, n1) - * @param depthwise Depthwise 3x3 filter, size (1, 3, 3, n1) - * @param depthwise_prelu Depthwise prelu, size (1, 1, 1, n1) - * @param compress Pointwise 1x1 filter, size (n2, 1, 1, n1) - * @param bias Pointwise bias, size (1, 1, 1, n2) - * @param config Mobilenet configuration - * @param name Block name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3dqq_mobilenet(dl_matrix3dq_t *in, - dl_matrix3dq_t *dilate, - dl_matrix3dq_t *dilate_prelu, - dl_matrix3dq_t *depthwise, - dl_matrix3dq_t *depth_prelu, - dl_matrix3dq_t *compress, - dl_matrix3dq_t *bias, - dl_matrix3dq_mobilenet_config_t config, - char *name); - -/** - * @brief Do mobilenet process, the process sequence is 1x1 dilated->prelu->3x3 depthwise->prelu->1x1 compress->bias - * - * @param in Input matrix, 8-bit fixed point, size (1, w, h, c) - * @param dilate Pointwise 1x1 filter, size (n1, 1, 1, c) - * @param dilate_prelu Pointwise prelu, size (1, 1, 1, n1) - * @param depthwise Depthwise 3x3 filter, size (1, 3, 3, n1) - * @param depthwise_prelu Depthwise prelu, size (1, 1, 1, n1) - * @param compress Pointwise 1x1 filter, size (n2, 1, 1, n1) - * @param bias Pointwise bias, size (1, 1, 1, n2) - * @param config Mobilenet configuration - * @param name Block name to debug - * @return dl_matrix3dq_t* Resulting quantized matrix - */ -dl_matrix3dq_t *dl_matrix3duq_mobilenet(dl_matrix3du_t *in, - dl_matrix3dq_t *dilate, - dl_matrix3dq_t *dilate_prelu, - dl_matrix3dq_t *depthwise, - dl_matrix3dq_t *depth_prelu, - dl_matrix3dq_t *compress, - dl_matrix3dq_t *bias, - dl_matrix3dq_mobilenet_config_t config, - char *name); - -// -// Padding -// - -/**@{*/ -/** - * @brief This family of functions do a padding operation before a convlution - * - * @param padded_input the padded result pointer - * @param output_height the output height pointer - * @param output_width the output width pointer - * @param input Input matrix, size (1, w, h, c) - * @param stride_x Stride of width - * @param stride_y Stride of height - * @param kernel_size Kernel size of the next convlution - * @param padding_type Padding type - * @return dl_error_type Return DL_SUCCESS if padding successfully, else return DL_FAIL - */ -dl_error_type dl_matrix3dqq_padding(dl_matrix3dq_t **padded_input, - int *output_height, - int *output_width, - dl_matrix3dq_t *input, - int stride_x, - int stride_y, - int kernel_size, - dl_padding_type padding_type); - -dl_error_type dl_matrix3duq_padding(dl_matrix3du_t **padded_input, - int *output_height, - int *output_width, - dl_matrix3du_t *input, - int stride_x, - int stride_y, - int kernel_size, - dl_padding_type padding_type); -/**@}*/ - -// -// Upsample -// -/** - * @brief Upsample a feature map to twice the size - * - * @param in Input matrix, size (1, w, h, c) - * @param upsample upsample type - * @return dl_matrix3dq_t* Resulting matrix, size (1, 2*w, 2*h, c) - */ -dl_matrix3dq_t *dl_matrix3dqq_upsample_2x(dl_matrix3dq_t *in, - dl_upsample_type upsample); - -// -// Pooling -// -/** - * @brief Calculate average value of a feature map - * - * @param in Input matrix, size (1, w, h, c) - * @return dl_matrix3dq_t* Resulting matrix, size (1, 1, 1, c) - */ -dl_matrix3dq_t *dl_matrix3dq_global_pool(dl_matrix3dq_t *in); - -/** - * @brief Calculate pooling layer of a feature map - * - * @param in Input matrix, size (1, w, h, c) - * @param f_w Window width - * @param f_h Window height - * @param stride_x Stride in horizontal direction - * @param stride_y Stride in vertical direction - * @param padding Padding type: PADDING_VALID and PADDING_SAME - * @param pooling_type Pooling type: DL_POOLING_MAX and POOLING_AVG - * @return dl_matrix3dq_t* Resulting matrix, size (1, w', h', c) - */ -dl_matrix3dq_t *dl_matrix3dq_pooling(dl_matrix3dq_t *in, - int f_w, - int f_h, - int stride_x, - int stride_y, - dl_padding_type padding, - dl_pooling_type pooling_type); diff --git a/tools/sdk/esp32s2/include/esp-face/lib/include/frmn.h b/tools/sdk/esp32s2/include/esp-face/lib/include/frmn.h deleted file mode 100644 index c1f08a0fadc..00000000000 --- a/tools/sdk/esp32s2/include/esp-face/lib/include/frmn.h +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once - -#if __cplusplus -extern "C" -{ -#endif - -#include "dl_lib_matrix3d.h" -#include "dl_lib_matrix3dq.h" - - /** - * @brief Forward the face recognition process with frmn model. Calculate in float. - * - * @param in Image matrix, rgb888 format, size is 56x56, normalized - * @return dl_matrix3d_t* Face ID feature vector, size is 512 - */ - dl_matrix3d_t *frmn(dl_matrix3d_t *in); - - /**@{*/ - /** - * @brief Forward the face recognition process with specified model. Calculate in quantization. - * - * @param in Image matrix, rgb888 format, size is 56x56, normalized - * @param mode 0: C implement; 1: handwrite xtensa instruction implement - * @return Face ID feature vector, size is 512 - */ - dl_matrix3dq_t *frmn_q(dl_matrix3dq_t *in, dl_conv_mode mode); - - dl_matrix3dq_t *frmn2p_q(dl_matrix3dq_t *in, dl_conv_mode mode); - - dl_matrix3dq_t *mfn56_42m_q(dl_matrix3dq_t *in, dl_conv_mode mode); - - dl_matrix3dq_t *mfn56_72m_q(dl_matrix3dq_t *in, dl_conv_mode mode); - - dl_matrix3dq_t *mfn56_112m_q(dl_matrix3dq_t *in, dl_conv_mode mode); - - dl_matrix3dq_t *mfn56_156m_q(dl_matrix3dq_t *in, dl_conv_mode mode); - - /**@}*/ - -#if __cplusplus -} -#endif diff --git a/tools/sdk/esp32s2/include/esp-face/lib/include/hd_model.h b/tools/sdk/esp32s2/include/esp-face/lib/include/hd_model.h deleted file mode 100644 index 0bc28d70ddc..00000000000 --- a/tools/sdk/esp32s2/include/esp-face/lib/include/hd_model.h +++ /dev/null @@ -1,66 +0,0 @@ -#pragma once - -#if __cplusplus -extern "C" -{ -#endif - -#include "dl_lib_matrix3d.h" -#include "dl_lib_matrix3dq.h" - - typedef struct - { - int num; /*!< The total number of the boxes */ - dl_matrix3d_t *cls; /*!< The class feature map corresponding to the box. size: (height, width, anchor_num, 1) */ - dl_matrix3d_t *score; /*!< The confidence score feature map of the class corresponding to the box. size: (height, width, anchor_num, 1) */ - dl_matrix3d_t *boxes; /*!< (x, y, w, h) of the boxes. x and y are the center coordinates. size:(height, width, anchor_num, 4) */ - } detection_result_t; - - /** - * @brief Forward the hand detection process with hd_nano1 model. Calculate in quantization. - * - * @param in A normalized image matrix in rgb888 format, its width and height must be integer multiples of 16. - * @param mode 0: C implement; 1: handwrite xtensa instruction implement - * @return detection_result_t** Detection results - */ - detection_result_t **hd_nano1_q(dl_matrix3dq_t *in, dl_conv_mode mode); - - /** - * @brief Forward the hand detection process with hd_lite1 model. Calculate in quantization. - * - * @param in A normalized image matrix in rgb888 format, its width and height must be integer multiples of 32. - * @param mode 0: C implement; 1: handwrite xtensa instruction implement. - * @return detection_result_t** Detection results. - */ - detection_result_t **hd_lite1_q(dl_matrix3dq_t *in, dl_conv_mode mode); - - /** - * @brief Free the single detection result. - * - * @param m The single detection result. - */ - void detection_result_free(detection_result_t *m); - - /** - * @brief Free the detection result group from different feature map. - * - * @param m The detection result group - * @param length The number of the detection results - */ - void detection_results_free(detection_result_t **m, int length); - - /** - * @brief Test the result of hand detection model. - * - */ - void hd_test(); - - /** - * @brief Test the forward time of hand detection model. - * - */ - void hd_time_test(); - -#if __cplusplus -} -#endif diff --git a/tools/sdk/esp32s2/include/esp-face/lib/include/hp_model.h b/tools/sdk/esp32s2/include/esp-face/lib/include/hp_model.h deleted file mode 100644 index ad9080c5473..00000000000 --- a/tools/sdk/esp32s2/include/esp-face/lib/include/hp_model.h +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once - -#if __cplusplus -extern "C" -{ -#endif - -#include "dl_lib_matrix3d.h" -#include "dl_lib_matrix3dq.h" - - /** - * @brief Forward the hand pose estimation process with hp_nano1_ls16 model. Calculate in quantization. - * - * @param in A normalized image matrix in rgb888 format, its size is (1, 128, 128, 3). - * @param mode 0: C implement; 1: handwrite xtensa instruction implement - * @return dl_matrix3d_t* The resulting hand joint point coordinates, the size is (1, 1, 21, 2) - */ - dl_matrix3d_t *hp_nano1_ls16_q(dl_matrix3dq_t *in, dl_conv_mode mode); - - /** - * @brief Forward the hand pose estimation process with hp_lite1 model. Calculate in quantization. - * - * @param in A normalized image matrix in rgb888 format, its size is (1, 128, 128, 3). - * @param mode 0: C implement; 1: handwrite xtensa instruction implement - * @return dl_matrix3d_t* The resulting hand joint point coordinates, the size is (1, 1, 21, 2) - */ - dl_matrix3d_t *hp_lite1_q(dl_matrix3dq_t *in, dl_conv_mode mode); - - /** - * @brief Test the result of hand pose estimation model. - * - */ - void hp_test(); - - /** - * @brief Test the forward time of hand pose estimation model. - * - */ - void hp_time_test(); - -#if __cplusplus -} -#endif \ No newline at end of file diff --git a/tools/sdk/esp32s2/include/esp-face/lib/include/lssh.h b/tools/sdk/esp32s2/include/esp-face/lib/include/lssh.h deleted file mode 100644 index 69c661c58e5..00000000000 --- a/tools/sdk/esp32s2/include/esp-face/lib/include/lssh.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * ESPRESSIF MIT License - * - * Copyright (c) 2018 - * - * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, - * it is 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. - * - */ -#pragma once - -#ifdef __cplusplus -extern "C" -{ -#endif -#include "dl_lib_matrix3d.h" -#include "dl_lib_matrix3dq.h" -#include "freertos/FreeRTOS.h" - - typedef struct - { - int resized_height; - int resized_width; - fptp_t y_resize_scale; - fptp_t x_resize_scale; - int enabled_top_k; - fptp_t score_threshold; - fptp_t nms_threshold; - - dl_conv_mode mode; - } lssh_config_t; - - typedef struct - { - int *anchor_size; - int stride; - int boundary; - } lssh_module_config_t; - - typedef struct - { - lssh_module_config_t *module_config; - int number; - } lssh_modules_config_t; - - typedef struct - { - dl_matrix3d_t *category; - dl_matrix3d_t *box_offset; - dl_matrix3d_t *landmark_offset; - } lssh_module_result_t; - - /** - * @brief - * - * @param value - */ - void lssh_module_result_free(lssh_module_result_t value); - - /** - * @brief - * - * @param values - * @param length - */ - void lssh_module_results_free(lssh_module_result_t *values, int length); - - ///////////////////////// - //////sparse_mn_5_q////// - ///////////////////////// - extern lssh_modules_config_t sparse_mn_5_modules_config; - lssh_module_result_t *sparse_mn_5_q_without_landmark(dl_matrix3du_t *image, bool free_image, int enabled_top_k, dl_conv_mode mode); - lssh_module_result_t *sparse_mn_5_q_with_landmark(dl_matrix3du_t *image, bool free_image, int enabled_top_k, dl_conv_mode mode); - -#ifdef __cplusplus -} -#endif diff --git a/tools/sdk/esp32s2/include/esp-face/lib/include/mtmn.h b/tools/sdk/esp32s2/include/esp-face/lib/include/mtmn.h deleted file mode 100644 index 609a82ea488..00000000000 --- a/tools/sdk/esp32s2/include/esp-face/lib/include/mtmn.h +++ /dev/null @@ -1,142 +0,0 @@ -/* - * ESPRESSIF MIT License - * - * Copyright (c) 2018 - * - * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, - * it is 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. - * - */ -#pragma once - -#ifdef __cplusplus -extern "C" -{ -#endif -#include "dl_lib_matrix3d.h" -#include "dl_lib_matrix3dq.h" - - /** - * Detection results with MTMN. - * - */ - typedef struct - { - dl_matrix3d_t *category; /*!< Classification result after softmax, channel is 2 */ - dl_matrix3d_t *offset; /*!< Bounding box offset of 2 points: top-left and bottom-right, channel is 4 */ - dl_matrix3d_t *landmark; /*!< Offsets of 5 landmarks: - * - Left eye - * - Mouth leftside - * - Nose - * - Right eye - * - Mouth rightside - * - * channel is 10 - * */ - } mtmn_net_t; - - - /** - * @brief Free a mtmn_net_t - * - * @param p A mtmn_net_t pointer - * - */ - - void mtmn_net_t_free(mtmn_net_t *p); - - /** - * @brief Forward the pnet process, coarse detection. Calculate in float. - * - * @param in Image matrix, rgb888 format, size is 320x240 - * @return Scores for every pixel, and box offset with respect. - */ - mtmn_net_t *pnet_lite_f(dl_matrix3du_t *in); - - /** - * @brief Forward the rnet process, fine determine the boxes from pnet. Calculate in float. - * - * @param in Image matrix, rgb888 format - * @param threshold Score threshold to detect human face - * @return Scores for every box, and box offset with respect. - */ - mtmn_net_t *rnet_lite_f_with_score_verify(dl_matrix3du_t *in, float threshold); - - /** - * @brief Forward the onet process, fine determine the boxes from rnet. Calculate in float. - * - * @param in Image matrix, rgb888 format - * @param threshold Score threshold to detect human face - * @return Scores for every box, box offset, and landmark with respect. - */ - mtmn_net_t *onet_lite_f_with_score_verify(dl_matrix3du_t *in, float threshold); - - /** - * @brief Forward the pnet process, coarse detection. Calculate in quantization. - * - * @param in Image matrix, rgb888 format, size is 320x240 - * @return Scores for every pixel, and box offset with respect. - */ - mtmn_net_t *pnet_lite_q(dl_matrix3du_t *in, dl_conv_mode mode); - - /** - * @brief Forward the rnet process, fine determine the boxes from pnet. Calculate in quantization. - * - * @param in Image matrix, rgb888 format - * @param threshold Score threshold to detect human face - * @return Scores for every box, and box offset with respect. - */ - mtmn_net_t *rnet_lite_q_with_score_verify(dl_matrix3du_t *in, float threshold, dl_conv_mode mode); - - /** - * @brief Forward the onet process, fine determine the boxes from rnet. Calculate in quantization. - * - * @param in Image matrix, rgb888 format - * @param threshold Score threshold to detect human face - * @return Scores for every box, box offset, and landmark with respect. - */ - mtmn_net_t *onet_lite_q_with_score_verify(dl_matrix3du_t *in, float threshold, dl_conv_mode mode); - - /** - * @brief Forward the pnet process, coarse detection. Calculate in quantization. - * - * @param in Image matrix, rgb888 format, size is 320x240 - * @return Scores for every pixel, and box offset with respect. - */ - mtmn_net_t *pnet_heavy_q(dl_matrix3du_t *in, dl_conv_mode mode); - - /** - * @brief Forward the rnet process, fine determine the boxes from pnet. Calculate in quantization. - * - * @param in Image matrix, rgb888 format - * @param threshold Score threshold to detect human face - * @return Scores for every box, and box offset with respect. - */ - mtmn_net_t *rnet_heavy_q_with_score_verify(dl_matrix3du_t *in, float threshold, dl_conv_mode mode); - - /** - * @brief Forward the onet process, fine determine the boxes from rnet. Calculate in quantization. - * - * @param in Image matrix, rgb888 format - * @param threshold Score threshold to detect human face - * @return Scores for every box, box offset, and landmark with respect. - */ - mtmn_net_t *onet_heavy_q_with_score_verify(dl_matrix3du_t *in, float threshold, dl_conv_mode mode); - -#ifdef __cplusplus -} -#endif diff --git a/tools/sdk/esp32s2/include/esp-face/object_detection/include/object_detection.h b/tools/sdk/esp32s2/include/esp-face/object_detection/include/object_detection.h deleted file mode 100644 index 8627a24684d..00000000000 --- a/tools/sdk/esp32s2/include/esp-face/object_detection/include/object_detection.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * ESPRESSIF MIT License - * - * Copyright (c) 2018 - * - * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, - * it is 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. - * - */ -#pragma once - -#if __cplusplus -extern "C" -{ -#endif - -#include "image_util.h" -#include "detection.h" -// Include models -#include "cat_face_3.h" - - /** - * @brief update detection hyperparameter - * - * @param model The detection model - * @param resize_scale The resize scale of input image - * @param score_threshold Score threshold, used to filter candidates by score - * @param nms_threshold NMS threshold, used to filter out overlapping boxes - * @param image_height Input image height - * @param image_width Input image width - */ - void update_detection_model(detection_model_t *model, fptp_t resize_scale, fptp_t score_threshold, fptp_t nms_threshold, int image_height, int image_width); - - /** - * @brief - * - * @param image The input image - * @param model A 'detection_model_t' type point of detection model - * @return box_array_t* The detection result with box and corresponding score and category - */ - box_array_t *detect_object(dl_matrix3du_t *image, detection_model_t *model); - -#if __cplusplus -} -#endif diff --git a/tools/sdk/esp32s2/include/esp-face/pose_estimation/include/pe_forward.h b/tools/sdk/esp32s2/include/esp-face/pose_estimation/include/pe_forward.h deleted file mode 100644 index 0d52b1f803e..00000000000 --- a/tools/sdk/esp32s2/include/esp-face/pose_estimation/include/pe_forward.h +++ /dev/null @@ -1,153 +0,0 @@ -/* - * ESPRESSIF MIT License - * - * Copyright (c) 2018 - * - * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, - * it is 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. - * - */ -#pragma once - -#if __cplusplus -extern "C" -{ -#endif - -#include "image_util.h" -#include "dl_lib_matrix3d.h" -#include "hd_model.h" -#include "hp_model.h" - -#define INPUT_EXPONENT -10 -#define SCORE_THRESHOLD 0.5 -#define NMS_THRESHOLD 0.45 - -#if CONFIG_HD_LITE1 - #define HP_TARGET_SIZE 128 -#else - #define HP_TARGET_SIZE 128 -#endif - - typedef struct - { - int target_size; /*!< The input size of hand detection network */ - fptp_t score_threshold; /*!< score threshold, used to filter candidates by score */ - fptp_t nms_threshold; /*!< nms threshold, used to filter out overlapping boxes */ - } hd_config_t; - - /** - * @brief Get the default hand detection network configuration - * - * @return hd_config_t The default configuration - */ - static inline hd_config_t hd_init_config() - { - hd_config_t hd_config; - hd_config.target_size = 96; - hd_config.score_threshold = SCORE_THRESHOLD; - hd_config.nms_threshold = NMS_THRESHOLD; - return hd_config; - } - - typedef struct tag_od_box_list - { - fptp_t *score; /*!< The confidence score of the class corresponding to the box */ - qtp_t *cls; /*!< The class corresponding to the box */ - box_t *box; /*!< (x1, y1, x2, y2) of the boxes */ - int len; /*!< The number of the boxes */ - } od_box_array_t; - - typedef struct tag_od_image_box - { - struct tag_od_image_box *next; /*!< Next od_image_box_t */ - fptp_t score; /*!< The confidence score of the class corresponding to the box */ - qtp_t cls; /*!< The class corresponding to the box */ - box_t box; /*!< (x1, y1, x2, y2) of the boxes */ - } od_image_box_t; - - typedef struct tag_od_image_list - { - od_image_box_t *head; /*!< The current head of the od_image_list */ - od_image_box_t *origin_head; /*!< The original head of the od_image_list */ - int len; /*!< Length of the od_image_list */ - } od_image_list_t; - - /** - * @brief Sort the resulting box lists by their confidence score. - * - * @param image_sorted_list The sorted box list. - * @param insert_list The box list that have not been sorted. - */ - void od_image_sort_insert_by_score(od_image_list_t *image_sorted_list, const od_image_list_t *insert_list); - - /** - * @brief Filter out the resulting boxes whose confidence score is lower than the threshold and convert the boxes to the actual boxes on the original image.((x, y, w, h) -> (x1, y1, x2, y2)) - * - * @param score Confidence score of the boxes. - * @param cls Class of the boxes. - * @param boxes (x, y, w, h) of the boxes. x and y are the center coordinates. - * @param height Height of the detection output feature map. - * @param width Width of the detection output feature map. - * @param anchor_number Anchor number of the detection output feature map. - * @param score_threshold Threshold of the confidence score. - * @param resize_scale Resize scale: target_size/orignal_size. - * @param padding_w Width padding in preporcess. - * @param padding_h Height padding in preporcess. - * @return od_image_list_t* Resulting valid boxes. - */ - od_image_list_t *od_image_get_valid_boxes(fptp_t *score, - fptp_t *cls, - fptp_t *boxes, - int height, - int width, - int anchor_number, - fptp_t score_threshold, - fptp_t resize_scale, - int padding_w, - int padding_h); - - /** - * @brief Run NMS algorithm - * - * @param image_list The input boxes list - * @param nms_threshold NMS threshold - */ - void od_image_nms_process(od_image_list_t *image_list, fptp_t nms_threshold); - - /** - * @brief Do hand detection, return box infomation. - * - * @param image Image matrix, rgb888 format - * @param hd_config Configuration of hand detection - * @return od_box_array_t* A list of boxes, score and class. - */ - od_box_array_t *hand_detection_forward(dl_matrix3du_t *image, hd_config_t hd_config); - - /** - * @brief Do hand pose estimation, return 21 landmarks of each hand. - * - * @param image Image matrix, rgb888 format - * @param od_boxes The output of the hand detection network - * @param target_size The input size of hand pose estimation network - * @return dl_matrix3d_t* The coordinates of 21 landmarks on the input image for each hand, size (n, 1, 21, 2) - */ - dl_matrix3d_t *handpose_estimation_forward(dl_matrix3du_t *image, od_box_array_t *od_boxes, int target_size); - -#if __cplusplus -} -#endif diff --git a/tools/sdk/esp32s2/include/esp-tls/esp_tls.h b/tools/sdk/esp32s2/include/esp-tls/esp_tls.h index 9330f9dd699..588f70d83f9 100644 --- a/tools/sdk/esp32s2/include/esp-tls/esp_tls.h +++ b/tools/sdk/esp32s2/include/esp-tls/esp_tls.h @@ -20,6 +20,9 @@ #include "mbedtls/ctr_drbg.h" #include "mbedtls/error.h" #include "mbedtls/certs.h" +#ifdef CONFIG_ESP_TLS_SERVER_SESSION_TICKETS +#include "mbedtls/ssl_ticket.h" +#endif #elif CONFIG_ESP_TLS_USING_WOLFSSL #include "wolfssl/wolfcrypt/settings.h" #include "wolfssl/ssl.h" @@ -54,6 +57,15 @@ typedef struct psk_key_hint { const char* hint; /*!< hint in PSK authentication mode in string format */ } psk_hint_key_t; +/** + * @brief esp-tls client session ticket ctx + */ +#ifdef CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS +typedef struct esp_tls_client_session { + mbedtls_ssl_session saved_session; +} esp_tls_client_session_t; +#endif /* CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS */ + /** * @brief Keep alive parameters structure */ @@ -168,9 +180,27 @@ typedef struct esp_tls_cfg { directly with esp_tls_plain_tcp_connect() API */ struct ifreq *if_name; /*!< The name of interface for data to go through. Use the default interface without setting */ + +#ifdef CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS + esp_tls_client_session_t *client_session; /*! Pointer for the client session ticket context. */ +#endif /* CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS */ } esp_tls_cfg_t; #ifdef CONFIG_ESP_TLS_SERVER +#if defined(CONFIG_ESP_TLS_SERVER_SESSION_TICKETS) +/** + * @brief Data structures necessary to support TLS session tickets according to RFC5077 + */ +typedef struct esp_tls_server_session_ticket_ctx { + mbedtls_entropy_context entropy; /*!< mbedTLS entropy context structure */ + + mbedtls_ctr_drbg_context ctr_drbg; /*!< mbedTLS ctr drbg context structure. + CTR_DRBG is deterministic random + bit generation based on AES-256 */ + mbedtls_ssl_ticket_context ticket_ctx; /*!< Session ticket generation context */ +} esp_tls_server_session_ticket_ctx_t; +#endif + typedef struct esp_tls_cfg_server { const char **alpn_protos; /*!< Application protocols required for HTTP2. If HTTP2/ALPN support is required, a list @@ -222,7 +252,39 @@ typedef struct esp_tls_cfg_server { unsigned int serverkey_password_len; /*!< String length of the password pointed to by serverkey_password */ +#if defined(CONFIG_ESP_TLS_SERVER_SESSION_TICKETS) + esp_tls_server_session_ticket_ctx_t * ticket_ctx; /*!< Session ticket generation context. + You have to call esp_tls_cfg_server_session_tickets_init + to use it. + Call esp_tls_cfg_server_session_tickets_free + to free the data associated with this context. */ +#endif } esp_tls_cfg_server_t; + +/** + * @brief Initialize the server side TLS session ticket context + * + * This function initializes the server side tls session ticket context + * which holds all necessary data structures to enable tls session tickets + * according to RFC5077. + * Use esp_tls_cfg_server_session_tickets_free to free the data. + * + * @param[in] cfg server configuration as esp_tls_cfg_server_t + * @return + * ESP_OK if setup succeeded + * ESP_ERR_INVALID_ARG if context is already initialized + * ESP_ERR_NO_MEM if memory allocation failed + * ESP_ERR_NOT_SUPPORTED if session tickets are not available due to build configuration + * ESP_FAIL if setup failed + */ +esp_err_t esp_tls_cfg_server_session_tickets_init(esp_tls_cfg_server_t *cfg); + +/** + * @brief Free the server side TLS session ticket context + * + * @param cfg server configuration as esp_tls_cfg_server_t + */ +void esp_tls_cfg_server_session_tickets_free(esp_tls_cfg_server_t *cfg); #endif /* ! CONFIG_ESP_TLS_SERVER */ /** @@ -404,6 +466,10 @@ int esp_tls_conn_http_new_async(const char *url, const esp_tls_cfg_t *cfg, esp_t * of bytes actually written to the TLS/SSL connection. * - <0 if write operation was not successful, because either an * error occured or an action must be taken by the calling process. + * - ESP_TLS_ERR_SSL_WANT_READ/ + * ESP_TLS_ERR_SSL_WANT_WRITE. + * if the handshake is incomplete and waiting for data to be available for reading. + * In this case this functions needs to be called again when the underlying transport is ready for operation. */ static inline ssize_t esp_tls_conn_write(esp_tls_t *tls, const void *data, size_t datalen) { @@ -609,6 +675,20 @@ void esp_tls_server_session_delete(esp_tls_t *tls); */ esp_err_t esp_tls_plain_tcp_connect(const char *host, int hostlen, int port, const esp_tls_cfg_t *cfg, esp_tls_error_handle_t error_handle, int *sockfd); +#ifdef CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS +/** + * @brief Obtain the client session ticket + * + * This function should be called when the TLS connection is already established. + * This can be passed again in the esp_tls_cfg_t structure, to appropriate tls session create (e.g. esp_tls_conn_http_new) API for session resumption. + * + * @param[in] esp_tls context as esp_tls_t + * @return + * Pointer to the saved client session. + * NULL on Failure + */ +esp_tls_client_session_t *esp_tls_get_client_session(esp_tls_t *tls); +#endif /* CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS */ #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32s2/include/esp-tls/esp_tls_errors.h b/tools/sdk/esp32s2/include/esp-tls/esp_tls_errors.h index 5dfe74791c5..ad104895aaf 100644 --- a/tools/sdk/esp32s2/include/esp-tls/esp_tls_errors.h +++ b/tools/sdk/esp32s2/include/esp-tls/esp_tls_errors.h @@ -14,35 +14,42 @@ extern "C" { #endif #define ESP_ERR_ESP_TLS_BASE 0x8000 /*!< Starting number of ESP-TLS error codes */ + +/* generic esp-tls error codes */ #define ESP_ERR_ESP_TLS_CANNOT_RESOLVE_HOSTNAME (ESP_ERR_ESP_TLS_BASE + 0x01) /*!< Error if hostname couldn't be resolved upon tls connection */ #define ESP_ERR_ESP_TLS_CANNOT_CREATE_SOCKET (ESP_ERR_ESP_TLS_BASE + 0x02) /*!< Failed to create socket */ #define ESP_ERR_ESP_TLS_UNSUPPORTED_PROTOCOL_FAMILY (ESP_ERR_ESP_TLS_BASE + 0x03) /*!< Unsupported protocol family */ #define ESP_ERR_ESP_TLS_FAILED_CONNECT_TO_HOST (ESP_ERR_ESP_TLS_BASE + 0x04) /*!< Failed to connect to host */ #define ESP_ERR_ESP_TLS_SOCKET_SETOPT_FAILED (ESP_ERR_ESP_TLS_BASE + 0x05) /*!< failed to set/get socket option */ -#define ESP_ERR_MBEDTLS_CERT_PARTLY_OK (ESP_ERR_ESP_TLS_BASE + 0x06) /*!< mbedtls parse certificates was partly successful */ -#define ESP_ERR_MBEDTLS_CTR_DRBG_SEED_FAILED (ESP_ERR_ESP_TLS_BASE + 0x07) /*!< mbedtls api returned error */ -#define ESP_ERR_MBEDTLS_SSL_SET_HOSTNAME_FAILED (ESP_ERR_ESP_TLS_BASE + 0x08) /*!< mbedtls api returned error */ -#define ESP_ERR_MBEDTLS_SSL_CONFIG_DEFAULTS_FAILED (ESP_ERR_ESP_TLS_BASE + 0x09) /*!< mbedtls api returned error */ -#define ESP_ERR_MBEDTLS_SSL_CONF_ALPN_PROTOCOLS_FAILED (ESP_ERR_ESP_TLS_BASE + 0x0A) /*!< mbedtls api returned error */ -#define ESP_ERR_MBEDTLS_X509_CRT_PARSE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x0B) /*!< mbedtls api returned error */ -#define ESP_ERR_MBEDTLS_SSL_CONF_OWN_CERT_FAILED (ESP_ERR_ESP_TLS_BASE + 0x0C) /*!< mbedtls api returned error */ -#define ESP_ERR_MBEDTLS_SSL_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x0D) /*!< mbedtls api returned error */ -#define ESP_ERR_MBEDTLS_SSL_WRITE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x0E) /*!< mbedtls api returned error */ -#define ESP_ERR_MBEDTLS_PK_PARSE_KEY_FAILED (ESP_ERR_ESP_TLS_BASE + 0x0F) /*!< mbedtls api returned failed */ -#define ESP_ERR_MBEDTLS_SSL_HANDSHAKE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x10) /*!< mbedtls api returned failed */ -#define ESP_ERR_MBEDTLS_SSL_CONF_PSK_FAILED (ESP_ERR_ESP_TLS_BASE + 0x11) /*!< mbedtls api returned failed */ -#define ESP_ERR_ESP_TLS_CONNECTION_TIMEOUT (ESP_ERR_ESP_TLS_BASE + 0x12) /*!< new connection in esp_tls_low_level_conn connection timeouted */ -#define ESP_ERR_WOLFSSL_SSL_SET_HOSTNAME_FAILED (ESP_ERR_ESP_TLS_BASE + 0x13) /*!< wolfSSL api returned error */ -#define ESP_ERR_WOLFSSL_SSL_CONF_ALPN_PROTOCOLS_FAILED (ESP_ERR_ESP_TLS_BASE + 0x14) /*!< wolfSSL api returned error */ -#define ESP_ERR_WOLFSSL_CERT_VERIFY_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x15) /*!< wolfSSL api returned error */ -#define ESP_ERR_WOLFSSL_KEY_VERIFY_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x16) /*!< wolfSSL api returned error */ -#define ESP_ERR_WOLFSSL_SSL_HANDSHAKE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x17) /*!< wolfSSL api returned failed */ -#define ESP_ERR_WOLFSSL_CTX_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x18) /*!< wolfSSL api returned failed */ -#define ESP_ERR_WOLFSSL_SSL_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x19) /*!< wolfSSL api returned failed */ -#define ESP_ERR_WOLFSSL_SSL_WRITE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x1A) /*!< wolfSSL api returned failed */ +#define ESP_ERR_ESP_TLS_CONNECTION_TIMEOUT (ESP_ERR_ESP_TLS_BASE + 0x06) /*!< new connection in esp_tls_low_level_conn connection timeouted */ +#define ESP_ERR_ESP_TLS_SE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x07) /*< esp-tls use Secure Element returned failed */ +#define ESP_ERR_ESP_TLS_TCP_CLOSED_FIN (ESP_ERR_ESP_TLS_BASE + 0x08) /*< esp-tls's TPC transport connection has benn closed (in a clean way) */ + +/* mbedtls specific error codes */ +#define ESP_ERR_MBEDTLS_CERT_PARTLY_OK (ESP_ERR_ESP_TLS_BASE + 0x10) /*!< mbedtls parse certificates was partly successful */ +#define ESP_ERR_MBEDTLS_CTR_DRBG_SEED_FAILED (ESP_ERR_ESP_TLS_BASE + 0x11) /*!< mbedtls api returned error */ +#define ESP_ERR_MBEDTLS_SSL_SET_HOSTNAME_FAILED (ESP_ERR_ESP_TLS_BASE + 0x12) /*!< mbedtls api returned error */ +#define ESP_ERR_MBEDTLS_SSL_CONFIG_DEFAULTS_FAILED (ESP_ERR_ESP_TLS_BASE + 0x13) /*!< mbedtls api returned error */ +#define ESP_ERR_MBEDTLS_SSL_CONF_ALPN_PROTOCOLS_FAILED (ESP_ERR_ESP_TLS_BASE + 0x14) /*!< mbedtls api returned error */ +#define ESP_ERR_MBEDTLS_X509_CRT_PARSE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x15) /*!< mbedtls api returned error */ +#define ESP_ERR_MBEDTLS_SSL_CONF_OWN_CERT_FAILED (ESP_ERR_ESP_TLS_BASE + 0x16) /*!< mbedtls api returned error */ +#define ESP_ERR_MBEDTLS_SSL_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x17) /*!< mbedtls api returned error */ +#define ESP_ERR_MBEDTLS_SSL_WRITE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x18) /*!< mbedtls api returned error */ +#define ESP_ERR_MBEDTLS_PK_PARSE_KEY_FAILED (ESP_ERR_ESP_TLS_BASE + 0x19) /*!< mbedtls api returned failed */ +#define ESP_ERR_MBEDTLS_SSL_HANDSHAKE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x1A) /*!< mbedtls api returned failed */ +#define ESP_ERR_MBEDTLS_SSL_CONF_PSK_FAILED (ESP_ERR_ESP_TLS_BASE + 0x1B) /*!< mbedtls api returned failed */ +#define ESP_ERR_MBEDTLS_SSL_TICKET_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x1C) /*!< mbedtls api returned failed */ + +/* wolfssl specific error codes */ +#define ESP_ERR_WOLFSSL_SSL_SET_HOSTNAME_FAILED (ESP_ERR_ESP_TLS_BASE + 0x31) /*!< wolfSSL api returned error */ +#define ESP_ERR_WOLFSSL_SSL_CONF_ALPN_PROTOCOLS_FAILED (ESP_ERR_ESP_TLS_BASE + 0x32) /*!< wolfSSL api returned error */ +#define ESP_ERR_WOLFSSL_CERT_VERIFY_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x33) /*!< wolfSSL api returned error */ +#define ESP_ERR_WOLFSSL_KEY_VERIFY_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x34) /*!< wolfSSL api returned error */ +#define ESP_ERR_WOLFSSL_SSL_HANDSHAKE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x35) /*!< wolfSSL api returned failed */ +#define ESP_ERR_WOLFSSL_CTX_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x36) /*!< wolfSSL api returned failed */ +#define ESP_ERR_WOLFSSL_SSL_SETUP_FAILED (ESP_ERR_ESP_TLS_BASE + 0x37) /*!< wolfSSL api returned failed */ +#define ESP_ERR_WOLFSSL_SSL_WRITE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x38) /*!< wolfSSL api returned failed */ -#define ESP_ERR_ESP_TLS_SE_FAILED (ESP_ERR_ESP_TLS_BASE + 0x1B) /*< esp-tls use Secure Element returned failed */ -#define ESP_ERR_ESP_TLS_TCP_CLOSED_FIN (ESP_ERR_ESP_TLS_BASE + 0x1C) /*< esp-tls's TPC transport connection has benn closed (in a clean way) */ /** * Definition of errors reported from IO API (potentially non-blocking) in case of error: diff --git a/tools/sdk/esp32s2/include/esp-tls/private_include/esp_tls_mbedtls.h b/tools/sdk/esp32s2/include/esp-tls/private_include/esp_tls_mbedtls.h index 78694fc858e..c1c5d4f3288 100644 --- a/tools/sdk/esp32s2/include/esp-tls/private_include/esp_tls_mbedtls.h +++ b/tools/sdk/esp32s2/include/esp-tls/private_include/esp_tls_mbedtls.h @@ -76,6 +76,22 @@ int esp_mbedtls_server_session_create(esp_tls_cfg_server_t *cfg, int sockfd, esp * /note :- The function can only be used with mbedtls ssl library */ void esp_mbedtls_server_session_delete(esp_tls_t *tls); + +#ifdef CONFIG_ESP_TLS_SERVER_SESSION_TICKETS +/** + * Internal function to setup server side session ticket context + * + * /note :- The function can only be used with mbedtls ssl library + */ +esp_err_t esp_mbedtls_server_session_ticket_ctx_init(esp_tls_server_session_ticket_ctx_t *cfg); + +/** + * Internal function to free server side session ticket context + * + * /note :- The function can only be used with mbedtls ssl library + */ +void esp_mbedtls_server_session_ticket_ctx_free(esp_tls_server_session_ticket_ctx_t *cfg); +#endif #endif /** @@ -83,6 +99,13 @@ void esp_mbedtls_server_session_delete(esp_tls_t *tls); */ esp_err_t set_client_config(const char *hostname, size_t hostlen, esp_tls_cfg_t *cfg, esp_tls_t *tls); +#ifdef CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS +/** + * Internal Callback for mbedtls_get_client_session + */ +esp_tls_client_session_t *esp_mbedtls_get_client_session(esp_tls_t *tls); +#endif + /** * Internal Callback for mbedtls_init_global_ca_store */ diff --git a/tools/sdk/esp32s2/include/esp32-camera/driver/include/esp_camera.h b/tools/sdk/esp32s2/include/esp32-camera/driver/include/esp_camera.h index bfb729b58b6..b6047d312ae 100755 --- a/tools/sdk/esp32s2/include/esp32-camera/driver/include/esp_camera.h +++ b/tools/sdk/esp32s2/include/esp32-camera/driver/include/esp_camera.h @@ -83,6 +83,14 @@ typedef enum { CAMERA_GRAB_LATEST /*!< Except when 1 frame buffer is used, queue will always contain the last 'fb_count' frames */ } camera_grab_mode_t; +/** + * @brief Camera frame buffer location + */ +typedef enum { + CAMERA_FB_IN_PSRAM, /*!< Frame buffer is placed in external PSRAM */ + CAMERA_FB_IN_DRAM /*!< Frame buffer is placed in internal DRAM */ +} camera_fb_location_t; + /** * @brief Configuration structure for camera initialization */ @@ -114,6 +122,7 @@ typedef struct { int jpeg_quality; /*!< Quality of JPEG output. 0-63 lower means higher quality */ size_t fb_count; /*!< Number of frame buffers to be allocated. If more than one, then each frame will be acquired (double speed) */ + camera_fb_location_t fb_location; /*!< The location where the frame buffer will be allocated */ camera_grab_mode_t grab_mode; /*!< When buffers should be filled */ } camera_config_t; diff --git a/tools/sdk/esp32s2/include/esp_adc_cal/include/esp_adc_cal.h b/tools/sdk/esp32s2/include/esp_adc_cal/include/esp_adc_cal.h index 9adf28078de..171b2ed8501 100644 --- a/tools/sdk/esp32s2/include/esp_adc_cal/include/esp_adc_cal.h +++ b/tools/sdk/esp32s2/include/esp_adc_cal/include/esp_adc_cal.h @@ -30,6 +30,7 @@ typedef enum { ESP_ADC_CAL_VAL_EFUSE_VREF = 0, /**< Characterization based on reference voltage stored in eFuse*/ ESP_ADC_CAL_VAL_EFUSE_TP = 1, /**< Characterization based on Two Point values stored in eFuse*/ ESP_ADC_CAL_VAL_DEFAULT_VREF = 2, /**< Characterization based on default reference voltage*/ + ESP_ADC_CAL_VAL_EFUSE_TP_FIT = 3, /**< Characterization based on Two Point values and fitting curve coefficients stored in eFuse */ ESP_ADC_CAL_VAL_MAX, ESP_ADC_CAL_VAL_NOT_SUPPORTED = ESP_ADC_CAL_VAL_MAX, } esp_adc_cal_value_t; @@ -48,6 +49,7 @@ typedef struct { uint32_t vref; /**< Vref used by lookup table*/ const uint32_t *low_curve; /**< Pointer to low Vref curve of lookup table (NULL if unused)*/ const uint32_t *high_curve; /**< Pointer to high Vref curve of lookup table (NULL if unused)*/ + uint8_t version; /**< ADC Calibration */ } esp_adc_cal_characteristics_t; /** @@ -129,8 +131,8 @@ uint32_t esp_adc_cal_raw_to_voltage(uint32_t adc_reading, const esp_adc_cal_char * * @return * - ESP_OK: ADC read and converted to mV - * - ESP_ERR_TIMEOUT: Error, timed out attempting to read ADC * - ESP_ERR_INVALID_ARG: Error due to invalid arguments + * - ESP_ERR_INVALID_STATE: Reading result is invalid. Try to read again. */ esp_err_t esp_adc_cal_get_voltage(adc_channel_t channel, const esp_adc_cal_characteristics_t *chars, uint32_t *voltage); diff --git a/tools/sdk/esp32s2/include/esp_common/include/esp_attr.h b/tools/sdk/esp32s2/include/esp_common/include/esp_attr.h index 21e52bd67bc..7b73af76634 100644 --- a/tools/sdk/esp32s2/include/esp_common/include/esp_attr.h +++ b/tools/sdk/esp32s2/include/esp_common/include/esp_attr.h @@ -89,6 +89,14 @@ extern "C" { // Forces data into noinit section to avoid initialization after restart. #define __NOINIT_ATTR _SECTION_ATTR_IMPL(".noinit", __COUNTER__) +#if CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY +// Forces data into external memory noinit section to avoid initialization after restart. +#define EXT_RAM_NOINIT_ATTR _SECTION_ATTR_IMPL(".ext_ram_noinit", __COUNTER__) +#else +// Place in internal noinit section +#define EXT_RAM_NOINIT_ATTR __NOINIT_ATTR +#endif + // Forces data into RTC slow memory of .noinit section. // Any variable marked with this attribute will keep its value // after restart or during a deep sleep / wake cycle. @@ -155,4 +163,3 @@ FORCE_INLINE_ATTR TYPE& operator<<=(TYPE& a, int b) { a <<= b; return a; } } #endif #endif /* __ESP_ATTR_H__ */ - diff --git a/tools/sdk/esp32s2/include/esp_eth/include/esp_eth.h b/tools/sdk/esp32s2/include/esp_eth/include/esp_eth.h index d204b50898a..6aea512a692 100644 --- a/tools/sdk/esp32s2/include/esp_eth/include/esp_eth.h +++ b/tools/sdk/esp32s2/include/esp_eth/include/esp_eth.h @@ -265,12 +265,24 @@ esp_err_t esp_eth_receive(esp_eth_handle_t hdl, uint8_t *buf, uint32_t *length) * * @param[in] hdl: handle of Ethernet driver * @param[in] cmd: IO control command -* @param[in] data: specificed data for command +* @param[in, out] data: address of data for `set` command or address where to store the data when used with `get` command * * @return * - ESP_OK: process io command successfully * - ESP_ERR_INVALID_ARG: process io command failed because of some invalid argument * - ESP_FAIL: process io command failed because some other error occurred +* +* The following IO control commands are supported: +* @li @c ETH_CMD_S_MAC_ADDR sets Ethernet interface MAC address. @c data argument is pointer to MAC address buffer with expected size of 6 bytes. +* @li @c ETH_CMD_G_MAC_ADDR gets Ethernet interface MAC address. @c data argument is pointer to a buffer to which MAC address is to be copied. The buffer size must be at least 6 bytes. +* @li @c ETH_CMD_S_PHY_ADDR sets PHY address in range of <0-31>. @c data argument is pointer to memory of uint32_t datatype from where the configuration option is read. +* @li @c ETH_CMD_G_PHY_ADDR gets PHY address. @c data argument is pointer to memory of uint32_t datatype to which the PHY address is to be stored. +* @li @c ETH_CMD_G_SPEED gets current Ethernet link speed. @c data argument is pointer to memory of eth_speed_t datatype to which the speed is to be stored. +* @li @c ETH_CMD_S_PROMISCUOUS sets/resets Ethernet interface promiscuous mode. @c data argument is pointer to memory of bool datatype from which the configuration option is read. +* @li @c ETH_CMD_S_FLOW_CTRL sets/resets Ethernet interface flow control. @c data argument is pointer to memory of bool datatype from which the configuration option is read. +* @li @c ETH_CMD_G_DUPLEX_MODE gets current Ethernet link duplex mode. @c data argument is pointer to memory of eth_duplex_t datatype to which the duplex mode is to be stored. +* @li @c ETH_CMD_S_PHY_LOOPBACK sets/resets PHY to/from loopback mode. @c data argument is pointer to memory of bool datatype from which the configuration option is read. +* */ esp_err_t esp_eth_ioctl(esp_eth_handle_t hdl, esp_eth_io_cmd_t cmd, void *data); diff --git a/tools/sdk/esp32s2/include/esp_eth/include/esp_eth_com.h b/tools/sdk/esp32s2/include/esp_eth/include/esp_eth_com.h index 46409ed710a..7ce0538fbe8 100644 --- a/tools/sdk/esp32s2/include/esp_eth/include/esp_eth_com.h +++ b/tools/sdk/esp32s2/include/esp_eth/include/esp_eth_com.h @@ -89,6 +89,7 @@ typedef enum { ETH_CMD_S_PROMISCUOUS, /*!< Set promiscuous mode */ ETH_CMD_S_FLOW_CTRL, /*!< Set flow control */ ETH_CMD_G_DUPLEX_MODE, /*!< Get Duplex mode */ + ETH_CMD_S_PHY_LOOPBACK,/*!< Set PHY loopback */ } esp_eth_io_cmd_t; /** diff --git a/tools/sdk/esp32s2/include/esp_eth/include/esp_eth_mac.h b/tools/sdk/esp32s2/include/esp_eth/include/esp_eth_mac.h index f1e790c756d..db462728a18 100644 --- a/tools/sdk/esp32s2/include/esp_eth/include/esp_eth_mac.h +++ b/tools/sdk/esp32s2/include/esp_eth/include/esp_eth_mac.h @@ -391,7 +391,7 @@ typedef struct { #define ETH_MAC_DEFAULT_CONFIG() \ { \ .sw_reset_timeout_ms = 100, \ - .rx_task_stack_size = 4096, \ + .rx_task_stack_size = 2048, \ .rx_task_prio = 15, \ .smi_mdc_gpio_num = 23, \ .smi_mdio_gpio_num = 18, \ diff --git a/tools/sdk/esp32s2/include/esp_eth/include/esp_eth_netif_glue.h b/tools/sdk/esp32s2/include/esp_eth/include/esp_eth_netif_glue.h index 5e88b5ba5e1..d577fc00b7b 100644 --- a/tools/sdk/esp32s2/include/esp_eth/include/esp_eth_netif_glue.h +++ b/tools/sdk/esp32s2/include/esp_eth/include/esp_eth_netif_glue.h @@ -19,6 +19,12 @@ extern "C" { #endif +/** + * @brief Handle of netif glue - an intermediate layer between netif and Ethernet driver + * + */ +typedef struct esp_eth_netif_glue_t* esp_eth_netif_glue_handle_t; + /** * @brief Create a netif glue for Ethernet driver * @note netif glue is used to attach io driver to TCP/IP netif @@ -26,20 +32,23 @@ extern "C" { * @param eth_hdl Ethernet driver handle * @return glue object, which inherits esp_netif_driver_base_t */ -void *esp_eth_new_netif_glue(esp_eth_handle_t eth_hdl); +esp_eth_netif_glue_handle_t esp_eth_new_netif_glue(esp_eth_handle_t eth_hdl); /** * @brief Delete netif glue of Ethernet driver * - * @param glue netif glue + * @param eth_netif_glue netif glue * @return -ESP_OK: delete netif glue successfully */ -esp_err_t esp_eth_del_netif_glue(void *glue); +esp_err_t esp_eth_del_netif_glue(esp_eth_netif_glue_handle_t eth_netif_glue); /** * @brief Register default IP layer handlers for Ethernet * * @note: Ethernet handle might not yet properly initialized when setting up these default handlers + * @warning: This function is deprecated and is kept here only for compatibility reasons. Registration + * of default IP layer handlers for Ethernet is now handled automatically. Do not call this + * function if you want to use multiple Ethernet instances at a time. * * @param[in] esp_netif esp network interface handle created for Ethernet driver * @return @@ -47,12 +56,15 @@ esp_err_t esp_eth_del_netif_glue(void *glue); * - ESP_OK: set default IP layer handlers successfully * - others: other failure occurred during register esp_event handler */ - -esp_err_t esp_eth_set_default_handlers(void *esp_netif); +esp_err_t esp_eth_set_default_handlers(void *esp_netif) __attribute__ ((deprecated)); /** * @brief Unregister default IP layer handlers for Ethernet * + * @warning: This function is deprecated and is kept here only for compatibility reasons. Unregistration + * of default IP layer handlers for Ethernet is now handled automatically if not registered + * by calling esp_eth_set_default_handlers. + * * @param[in] esp_netif esp network interface handle created for Ethernet driver * @return * - ESP_ERR_INVALID_ARG: invalid parameter (esp_netif is NULL) diff --git a/tools/sdk/esp32s2/include/esp_eth/include/esp_eth_phy.h b/tools/sdk/esp32s2/include/esp_eth/include/esp_eth_phy.h index c9d32b367c0..f85b7d43043 100644 --- a/tools/sdk/esp32s2/include/esp_eth/include/esp_eth_phy.h +++ b/tools/sdk/esp32s2/include/esp_eth/include/esp_eth_phy.h @@ -1,4 +1,4 @@ -// Copyright 2019 Espressif Systems (Shanghai) PTE LTD +// Copyright 2019-2021 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. @@ -173,6 +173,19 @@ struct esp_eth_phy_s { */ esp_err_t (*advertise_pause_ability)(esp_eth_phy_t *phy, uint32_t ability); + /** + * @brief + * + * @param[in] phy: Ethernet PHY instance + * @param[in] enable: enables or disables PHY loopback + * + * @return + * - ESP_OK: configures PHY instance loopback function successfully + * - ESP_FAIL: PHY instance loopback configuration failed because some error occurred + * + */ + esp_err_t (*loopback)(esp_eth_phy_t *phy, bool enable); + /** * @brief Free memory of Ethernet PHY instance * @@ -231,16 +244,32 @@ esp_eth_phy_t *esp_eth_phy_new_ip101(const eth_phy_config_t *config); */ esp_eth_phy_t *esp_eth_phy_new_rtl8201(const eth_phy_config_t *config); +/** +* @brief Create a PHY instance of LAN87xx +* +* @param[in] config: configuration of PHY +* +* @return +* - instance: create PHY instance successfully +* - NULL: create PHY instance failed because some error occurred +*/ +esp_eth_phy_t *esp_eth_phy_new_lan87xx(const eth_phy_config_t *config); + /** * @brief Create a PHY instance of LAN8720 * +* @note For ESP-IDF backwards compatibility reasons. In all other cases, use esp_eth_phy_new_lan87xx instead. +* * @param[in] config: configuration of PHY * * @return * - instance: create PHY instance successfully * - NULL: create PHY instance failed because some error occurred */ -esp_eth_phy_t *esp_eth_phy_new_lan8720(const eth_phy_config_t *config); +static inline esp_eth_phy_t *esp_eth_phy_new_lan8720(const eth_phy_config_t *config) +{ + return esp_eth_phy_new_lan87xx(config); +} /** * @brief Create a PHY instance of DP83848 diff --git a/tools/sdk/esp32s2/include/esp_event/include/esp_event.h b/tools/sdk/esp32s2/include/esp_event/include/esp_event.h index 2d39422db57..2c069b0c684 100644 --- a/tools/sdk/esp32s2/include/esp_event/include/esp_event.h +++ b/tools/sdk/esp32s2/include/esp_event/include/esp_event.h @@ -23,7 +23,10 @@ #include "freertos/semphr.h" #include "esp_event_base.h" +// Legacy event loop not implemented on Linux target +#if !CONFIG_IDF_TARGET_LINUX #include "esp_event_legacy.h" +#endif #ifdef __cplusplus extern "C" { diff --git a/tools/sdk/esp32s2/include/esp_hid/include/esp_hid_common.h b/tools/sdk/esp32s2/include/esp_hid/include/esp_hid_common.h index 9fd7a2c6375..d7582cbc841 100644 --- a/tools/sdk/esp32s2/include/esp_hid/include/esp_hid_common.h +++ b/tools/sdk/esp32s2/include/esp_hid/include/esp_hid_common.h @@ -126,6 +126,21 @@ typedef enum { ESP_HID_COD_MIN_MAX } esp_hid_cod_min_t; +/* HID transaction Types */ +typedef enum { + ESP_HID_TRANS_HANDSHAKE = 0, + ESP_HID_TRANS_CONTROL = 1, + ESP_HID_TRANS_GET_REPORT = 4, + ESP_HID_TRANS_SET_REPORT = 5, + ESP_HID_TRANS_GET_PROTOCOL = 6, + ESP_HID_TRANS_SET_PROTOCOL = 7, + ESP_HID_TRANS_GET_IDLE = 8, + ESP_HID_TRANS_SET_IDLE = 9, + ESP_HID_TRANS_DATA = 10, + ESP_HID_TRANS_DATAC = 11, + ESP_HID_TRANS_MAX +} esp_hid_trans_type_t; + /** * @brief HID report item structure */ diff --git a/tools/sdk/esp32s2/include/esp_hid/include/esp_hidd.h b/tools/sdk/esp32s2/include/esp_hid/include/esp_hidd.h index ef596c6b2ba..3e1bfc2c06f 100644 --- a/tools/sdk/esp32s2/include/esp_hid/include/esp_hidd.h +++ b/tools/sdk/esp32s2/include/esp_hid/include/esp_hidd.h @@ -53,11 +53,28 @@ typedef struct esp_hidd_dev_s esp_hidd_dev_t; * @brief HIDD callback parameters union */ typedef union { + /** + * @brief ESP_HIDD_START_EVENT + * @note Used only for Classic Bluetooth. + */ + struct { + esp_err_t status; /*!< HID device operation status */ + } start; /*!< HID callback param of ESP_HIDD_START_EVENT */ + + /** + * @brief ESP_HIDD_STOP_EVENT + * @note Used only for Classic Bluetooth. + */ + struct { + esp_err_t status; /*!< HID device operation status */ + } stop; /*!< HID callback param of ESP_HIDD_STOP_EVENT */ + /** * @brief ESP_HIDD_CONNECT_EVENT */ struct { esp_hidd_dev_t *dev; /*!< HID device structure */ + esp_err_t status; /*!< HID device operation status, used only for Classic Bluetooth */ } connect; /*!< HID callback param of ESP_HIDD_CONNECT_EVENT */ /** @@ -66,6 +83,7 @@ typedef union { struct { esp_hidd_dev_t *dev; /*!< HID device structure */ int reason; /*!< Indicate the reason of disconnection */ + esp_err_t status; /*!< HID device operation status, used only for Classic Bluetooth */ } disconnect; /*!< HID callback param of ESP_HIDD_DISCONNECT_EVENT */ /** @@ -90,6 +108,8 @@ typedef union { uint16_t length; /*!< data length */ uint8_t *data; /*!< The pointer to the data */ uint8_t map_index; /*!< HID config report map index */ + uint8_t trans_type; /*!< HID device feature transaction type, used only for Classic Bluetooth */ + uint8_t report_type; /*!< HID device feature report type, used only for Classic Bluetooth */ } feature; /*!< HID callback param of ESP_HIDD_FEATURE_EVENT */ /** diff --git a/tools/sdk/esp32s2/include/esp_hid/include/esp_hidh.h b/tools/sdk/esp32s2/include/esp_hid/include/esp_hidh.h index d3d10021034..d49f76e6807 100644 --- a/tools/sdk/esp32s2/include/esp_hid/include/esp_hidh.h +++ b/tools/sdk/esp32s2/include/esp_hid/include/esp_hidh.h @@ -42,6 +42,8 @@ typedef enum { ESP_HIDH_INPUT_EVENT, /*!< Received HID device INPUT report */ ESP_HIDH_FEATURE_EVENT, /*!< Received HID device FEATURE report */ ESP_HIDH_CLOSE_EVENT, /*!< HID device closed */ + ESP_HIDH_START_EVENT, /*!< HID host stack started, used only for Classic Bluetooth */ + ESP_HIDH_STOP_EVENT, /*!< HID host stack stopped, used only for Classic Bluetooth */ ESP_HIDH_MAX_EVENT, /*!< HID events end marker */ } esp_hidh_event_t; @@ -49,11 +51,28 @@ typedef enum { * @brief HIDH callback parameters union */ typedef union { + /** + * @brief ESP_HIDH_START_EVENT + * @note Used only for Classic Bluetooth. + */ + struct { + esp_err_t status; /*!< HID host operation status */ + } start; /*!< HID callback param of ESP_HIDH_START_EVENT */ + + /** + * @brief ESP_HIDH_STOP_EVENT + * @note Used only for Classic Bluetooth. + */ + struct { + esp_err_t status; /*!< HID host operation status */ + } stop; /*!< HID callback param of ESP_HIDH_STOP_EVENT */ + /** * @brief ESP_HIDH_OPEN_EVENT */ struct { esp_hidh_dev_t *dev; /*!< HID Remote bluetooth device */ + esp_err_t status; /*!< HID host operation status, used only for Classic Bluetooth */ } open; /*!< HID callback param of ESP_HIDH_OPEN_EVENT */ /** @@ -62,6 +81,7 @@ typedef union { struct { esp_hidh_dev_t *dev; /*!< HID Remote bluetooth device. */ int reason; /*!< Reason why the connection was closed. BLE Only */ + esp_err_t status; /*!< HID host operation status, used only for Classic Bluetooth */ } close; /*!< HID callback param of ESP_HIDH_CLOSE_EVENT */ /** @@ -70,6 +90,7 @@ typedef union { struct { esp_hidh_dev_t *dev; /*!< HID Remote bluetooth device */ uint8_t level; /*!< Battery Level (0-100%) */ + esp_err_t status; /*!< HID host operation status */ } battery; /*!< HID callback param of ESP_HIDH_BATTERY_EVENT */ /** @@ -80,7 +101,7 @@ typedef union { esp_hid_usage_t usage; /*!< HID report usage */ uint16_t report_id; /*!< HID report index */ uint16_t length; /*!< HID data length */ - uint8_t *data; /*!< The pointer to the HID data */ + uint8_t *data; /*!< The pointer to the HID data */ uint8_t map_index; /*!< HID report map index */ } input; /*!< HID callback param of ESP_HIDH_INPUT_EVENT */ @@ -92,8 +113,10 @@ typedef union { esp_hid_usage_t usage; /*!< HID report usage */ uint16_t report_id; /*!< HID report index */ uint16_t length; /*!< HID data length */ - uint8_t *data; /*!< The pointer to the HID data */ + uint8_t *data; /*!< The pointer to the HID data */ uint8_t map_index; /*!< HID report map index */ + esp_err_t status; /*!< HID host operation status, used only for Classic Bluetooth */ + esp_hid_trans_type_t trans_type; /*!< HID host feature transaction type, used only for Classic Bluetooth */ } feature; /*!< HID callback param of ESP_HIDH_FEATURE_EVENT */ } esp_hidh_event_data_t; @@ -101,6 +124,7 @@ typedef union { typedef struct { esp_event_handler_t callback; uint16_t event_stack_size; + void *callback_arg; } esp_hidh_config_t; /** @@ -136,6 +160,14 @@ esp_err_t esp_hidh_dev_close(esp_hidh_dev_t *dev); */ esp_err_t esp_hidh_dev_free(esp_hidh_dev_t *dev); +/** + * @brief Check if the device still exists. + * @param dev : pointer to the device + * + * @return: true if exists + */ +bool esp_hidh_dev_exists(esp_hidh_dev_t *dev); + /** * @brief Send an OUTPUT report to the device * @param dev : pointer to the device @@ -173,6 +205,79 @@ esp_err_t esp_hidh_dev_feature_set(esp_hidh_dev_t *dev, size_t map_index, size_t */ esp_err_t esp_hidh_dev_feature_get(esp_hidh_dev_t *dev, size_t map_index, size_t report_id, size_t max_len, uint8_t *data, size_t *length); +/** + * @brief Set_Report command. + * @note For now, this function used only for Classic Bluetooth. + * + * @param dev : pointer to the device + * @param map_index : index of the device report map + * @param report_id : id of the HID FEATURE report + * @param report_type : report type, defines in `esp_hid_common.h` + * @param data : pointer to the data to send + * @param length : length of the data to send + * + * @return: ESP_OK on success + */ +esp_err_t esp_hidh_dev_set_report(esp_hidh_dev_t *dev, size_t map_index, size_t report_id, int report_type, + uint8_t *data, size_t length); + +/** + * @brief Get_Report command. + * @note For now, this function used only for Classic Bluetooth. + * + * @param dev : pointer to the device + * @param map_index : index of the device report map + * @param report_id : id of the HID FEATURE report + * @param report_type : report type, defines in `esp_hid_common.h` + * @param max_len : size of the buffer that will hold the data + * + * @return: ESP_OK on success + */ +esp_err_t esp_hidh_dev_get_report(esp_hidh_dev_t *dev, size_t map_index, size_t report_id, int report_type, + size_t max_len); + +/** + * @brief Get_Idle Command. + * @note For now, this function used only for Classic Bluetooth. + * + * @param dev : pointer to the device + * + * @return: ESP_OK on success + */ +esp_err_t esp_hidh_dev_get_idle(esp_hidh_dev_t *dev); + +/** + * @brief Set_Idle Command. + * @note For now, this function used only for Classic Bluetooth. + * + * @param dev : pointer to the device + * @param idle_time : idle_time + * + * @return: ESP_OK on success + */ +esp_err_t esp_hidh_dev_set_idle(esp_hidh_dev_t *dev, uint8_t idle_time); + +/** + * @brief Get_Protocol Command. + * @note For now, this function used only for Classic Bluetooth. + * + * @param dev : pointer to the device + * + * @return: ESP_OK on success + */ +esp_err_t esp_hidh_dev_get_protocol(esp_hidh_dev_t *dev); + +/** + * @brief Set_Protocol Command. + * @note For now, this function used only for Classic Bluetooth. + * + * @param dev : pointer to the device + * @param protocol_mode : protocol_mode + * + * @return: ESP_OK on success + */ +esp_err_t esp_hidh_dev_set_protocol(esp_hidh_dev_t *dev, uint8_t protocol_mode); + /** * @brief Dump the properties of HID Device to UART * @param dev : pointer to the HID Device diff --git a/tools/sdk/esp32s2/include/esp_http_client/include/esp_http_client.h b/tools/sdk/esp32s2/include/esp_http_client/include/esp_http_client.h index ab7e3c2e328..820c4168f66 100644 --- a/tools/sdk/esp32s2/include/esp_http_client/include/esp_http_client.h +++ b/tools/sdk/esp32s2/include/esp_http_client/include/esp_http_client.h @@ -113,6 +113,8 @@ typedef struct { size_t client_cert_len; /*!< Length of the buffer pointed to by client_cert_pem. May be 0 for null-terminated pem */ const char *client_key_pem; /*!< SSL client key, PEM format as string, if the server requires to verify client */ size_t client_key_len; /*!< Length of the buffer pointed to by client_key_pem. May be 0 for null-terminated pem */ + const char *client_key_password; /*!< Client key decryption password string */ + size_t client_key_password_len; /*!< String length of the password pointed to by client_key_password */ const char *user_agent; /*!< The User Agent string to send with HTTP requests */ esp_http_client_method_t method; /*!< HTTP Method */ int timeout_ms; /*!< Network timeout in milliseconds */ diff --git a/tools/sdk/esp32s2/include/esp_http_server/include/esp_http_server.h b/tools/sdk/esp32s2/include/esp_http_server/include/esp_http_server.h index d14a943c108..1c8b78583ff 100644 --- a/tools/sdk/esp32s2/include/esp_http_server/include/esp_http_server.h +++ b/tools/sdk/esp32s2/include/esp_http_server/include/esp_http_server.h @@ -941,6 +941,24 @@ esp_err_t httpd_req_get_url_query_str(httpd_req_t *r, char *buf, size_t buf_len) */ esp_err_t httpd_query_key_value(const char *qry, const char *key, char *val, size_t val_size); +/** + * @brief Get the value string of a cookie value from the "Cookie" request headers by cookie name. + * + * @param[in] req Pointer to the HTTP request + * @param[in] cookie_name The cookie name to be searched in the request + * @param[out] val Pointer to the buffer into which the value of cookie will be copied if the cookie is found + * @param[inout] val_size Pointer to size of the user buffer "val". This variable will contain cookie length if + * ESP_OK is returned and required buffer length incase ESP_ERR_HTTPD_RESULT_TRUNC is returned. + * + * @return + * - ESP_OK : Key is found in the cookie string and copied to buffer + * - ESP_ERR_NOT_FOUND : Key not found + * - ESP_ERR_INVALID_ARG : Null arguments + * - ESP_ERR_HTTPD_RESULT_TRUNC : Value string truncated + * - ESP_ERR_NO_MEM : Memory allocation failure + */ +esp_err_t httpd_req_get_cookie_val(httpd_req_t *req, const char *cookie_name, char *val, size_t *val_size); + /** * @brief Test if a URI matches the given wildcard template. * @@ -1585,6 +1603,11 @@ typedef struct httpd_ws_frame { size_t len; /*!< Length of the WebSocket data */ } httpd_ws_frame_t; +/** + * @brief Transfer complete callback + */ +typedef void (*transfer_complete_cb)(esp_err_t err, int socket, void *arg); + /** * @brief Receive and parse a WebSocket frame * @@ -1645,6 +1668,35 @@ esp_err_t httpd_ws_send_frame_async(httpd_handle_t hd, int fd, httpd_ws_frame_t */ httpd_ws_client_info_t httpd_ws_get_fd_info(httpd_handle_t hd, int fd); +/** + * @brief Sends data to to specified websocket synchronously + * + * @param[in] handle Server instance data + * @param[in] socket Socket descriptor + * @param[in] frame Websocket frame + * @return + * - ESP_OK : On successful + * - ESP_FAIL : When socket errors occurs + * - ESP_ERR_NO_MEM : Unable to allocate memory + */ +esp_err_t httpd_ws_send_data(httpd_handle_t handle, int socket, httpd_ws_frame_t *frame); + +/** + * @brief Sends data to to specified websocket asynchronously + * + * @param[in] handle Server instance data + * @param[in] socket Socket descriptor + * @param[in] frame Websocket frame + * @param[in] callback Callback invoked after sending data + * @param[in] arg User data passed to provided callback + * @return + * - ESP_OK : On successful + * - ESP_FAIL : When socket errors occurs + * - ESP_ERR_NO_MEM : Unable to allocate memory + */ +esp_err_t httpd_ws_send_data_async(httpd_handle_t handle, int socket, httpd_ws_frame_t *frame, + transfer_complete_cb callback, void *arg); + #endif /* CONFIG_HTTPD_WS_SUPPORT */ /** End of WebSocket related stuff * @} diff --git a/tools/sdk/esp32s2/include/esp_https_server/include/esp_https_server.h b/tools/sdk/esp32s2/include/esp_https_server/include/esp_https_server.h index 52f9dc2132a..00565a963ad 100644 --- a/tools/sdk/esp32s2/include/esp_https_server/include/esp_https_server.h +++ b/tools/sdk/esp32s2/include/esp_https_server/include/esp_https_server.h @@ -63,6 +63,9 @@ struct httpd_ssl_config { /** Port used when transport mode is insecure (default 80) */ uint16_t port_insecure; + + /** Enable tls session tickets */ + bool session_tickets; }; typedef struct httpd_ssl_config httpd_ssl_config_t; @@ -109,6 +112,7 @@ typedef struct httpd_ssl_config httpd_ssl_config_t; .transport_mode = HTTPD_SSL_TRANSPORT_SECURE, \ .port_secure = 443, \ .port_insecure = 80, \ + .session_tickets = false, \ } /** diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/esp_async_memcpy.h b/tools/sdk/esp32s2/include/esp_hw_support/include/esp_async_memcpy.h index e95f9638e76..c45c61b2d15 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/esp_async_memcpy.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/esp_async_memcpy.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/esp_chip_info.h b/tools/sdk/esp32s2/include/esp_hw_support/include/esp_chip_info.h index d04dcaf4245..69d23c08d36 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/esp_chip_info.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/esp_chip_info.h @@ -1,16 +1,8 @@ -// Copyright 2021 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. +/* + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once @@ -30,7 +22,7 @@ extern "C" { typedef enum { CHIP_ESP32 = 1, //!< ESP32 CHIP_ESP32S2 = 2, //!< ESP32-S2 - CHIP_ESP32S3 = 4, //!< ESP32-S3 + CHIP_ESP32S3 = 9, //!< ESP32-S3 CHIP_ESP32C3 = 5, //!< ESP32-C3 CHIP_ESP32H2 = 6, //!< ESP32-H2 } esp_chip_model_t; diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/esp_cpu.h b/tools/sdk/esp32s2/include/esp_hw_support/include/esp_cpu.h index e1536e979b8..2a810aba440 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/esp_cpu.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/esp_cpu.h @@ -1,16 +1,8 @@ -// Copyright 2010-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. +/* + * SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_CPU_H #define _ESP_CPU_H diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/esp_crc.h b/tools/sdk/esp32s2/include/esp_hw_support/include/esp_crc.h index 6294a7b6218..f12dcf767dd 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/esp_crc.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/esp_crc.h @@ -1,16 +1,8 @@ -// Copyright 2015-2019 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #ifdef __cplusplus diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/esp_fault.h b/tools/sdk/esp32s2/include/esp_hw_support/include/esp_fault.h index fe9de334259..910ba59d06c 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/esp_fault.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/esp_fault.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include "sdkconfig.h" #include "soc/rtc_cntl_reg.h" #include "esp_rom_sys.h" diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/esp_interface.h b/tools/sdk/esp32s2/include/esp_hw_support/include/esp_interface.h index 950c05bb22c..fdb4c0056ce 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/esp_interface.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/esp_interface.h @@ -1,16 +1,8 @@ -// 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef __ESP_INTERFACE_H__ diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/esp_intr.h b/tools/sdk/esp32s2/include/esp_hw_support/include/esp_intr.h index c29dc9bfd1a..0818ed3feab 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/esp_intr.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/esp_intr.h @@ -1,16 +1,8 @@ -// Copyright 2010-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. +/* + * SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #warning esp_intr.h is deprecated, please include esp_intr_alloc.h instead diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/esp_intr_alloc.h b/tools/sdk/esp32s2/include/esp_hw_support/include/esp_intr_alloc.h index 33f70b95970..a26fde9394f 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/esp_intr_alloc.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/esp_intr_alloc.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/esp_mac.h b/tools/sdk/esp32s2/include/esp_hw_support/include/esp_mac.h index 75e01ebbd16..f0efddfc2f7 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/esp_mac.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/esp_mac.h @@ -1,16 +1,8 @@ -// Copyright 2021 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. +/* + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once @@ -79,6 +71,7 @@ esp_err_t esp_base_mac_addr_set(const uint8_t *mac); * 8 bytes for EUI-64(used for IEEE 802.15.4) * * @return ESP_OK on success + * ESP_ERR_INVALID_ARG mac is NULL * ESP_ERR_INVALID_MAC base MAC address has not been set */ esp_err_t esp_base_mac_addr_get(uint8_t *mac); @@ -100,8 +93,10 @@ esp_err_t esp_base_mac_addr_get(uint8_t *mac); * 8 bytes for EUI-64(used for IEEE 802.15.4) * * @return ESP_OK on success - * ESP_ERR_INVALID_VERSION An invalid MAC version field was read from BLK3 of EFUSE - * ESP_ERR_INVALID_CRC An invalid MAC CRC was read from BLK3 of EFUSE + * ESP_ERR_INVALID_ARG mac is NULL + * ESP_ERR_INVALID_MAC CUSTOM_MAC address has not been set, all zeros (for esp32-xx) + * ESP_ERR_INVALID_VERSION An invalid MAC version field was read from BLK3 of EFUSE (for esp32) + * ESP_ERR_INVALID_CRC An invalid MAC CRC was read from BLK3 of EFUSE (for esp32) */ esp_err_t esp_efuse_mac_get_custom(uint8_t *mac); @@ -113,6 +108,7 @@ esp_err_t esp_efuse_mac_get_custom(uint8_t *mac); * 8 bytes for EUI-64(used for IEEE 802.15.4) * * @return ESP_OK on success + * ESP_ERR_INVALID_ARG mac is NULL */ esp_err_t esp_efuse_mac_get_default(uint8_t *mac); diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/esp_private/esp_clk.h b/tools/sdk/esp32s2/include/esp_hw_support/include/esp_private/esp_clk.h index 14326898bd7..5a4666fdddf 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/esp_private/esp_clk.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/esp_private/esp_clk.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/esp_private/sleep_gpio.h b/tools/sdk/esp32s2/include/esp_hw_support/include/esp_private/sleep_gpio.h new file mode 100644 index 00000000000..abab21871a4 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/esp_private/sleep_gpio.h @@ -0,0 +1,46 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once +#include +#include "sdkconfig.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file sleep_gpio.h + * + * This file contains declarations of GPIO related functions in light sleep mode. + */ + +#if SOC_GPIO_SUPPORT_SLP_SWITCH && CONFIG_GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL + +/** + * @brief Save GPIO pull-up and pull-down configuration information in the wake-up state + * + * In light sleep mode, the pull-up and pull-down resistors of GPIO will cause + * leakage current when the system sleeps. In order to reduce the power + * consumption of system sleep, it needs to save the configuration information + * of all GPIO pull-up and pull-down resistors and disable the pull-up and + * pull-down resistors of GPIO before the system enters sleep. + */ +void gpio_sleep_mode_config_apply(void); + +/** + * @brief Restore GPIO pull-up and pull-down configuration information in the wake-up state + * + * In light sleep mode, after the system wakes up, it needs to restore all GPIO + * pull-up and pull-down configurations before the last sleep. + */ +void gpio_sleep_mode_config_unapply(void); + +#endif // SOC_GPIO_SUPPORT_SLP_SWITCH && CONFIG_GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/esp_private/sleep_mac_bb.h b/tools/sdk/esp32s2/include/esp_hw_support/include/esp_private/sleep_mac_bb.h new file mode 100644 index 00000000000..6b4019639d8 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/esp_private/sleep_mac_bb.h @@ -0,0 +1,43 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once +#include +#include "sdkconfig.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file sleep_mac_bb.h + * + * This file contains declarations of MAC and baseband power consumption related functions in light sleep mode. + */ + +#if CONFIG_MAC_BB_PD + +/** + * @brief A callback function completes MAC and baseband power down operation + * + * In light sleep mode, execute Wi-Fi and Bluetooth module MAC and baseband + * power down and backup register configuration information operations. + */ +void mac_bb_power_down_cb_execute(void); + +/** + * @brief A callback function completes MAC and baseband power up operation + * + * In light sleep mode, execute Wi-Fi and Bluetooth module MAC and baseband + * power up and restore register configuration information operations. + */ +void mac_bb_power_up_cb_execute(void); + +#endif // CONFIG_MAC_BB_PD + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/esp_private/sleep_retention.h b/tools/sdk/esp32s2/include/esp_hw_support/include/esp_private/sleep_retention.h new file mode 100644 index 00000000000..001e559c0c7 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/esp_private/sleep_retention.h @@ -0,0 +1,55 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once +#include +#include "sdkconfig.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file sleep_retention.h + * + * This file contains declarations of memory retention related functions in light sleeo mode. + */ + +#if SOC_PM_SUPPORT_CPU_PD + +/** + * @brief Whether to allow the cpu power domain to be powered off. + * + * In light sleep mode, only when the system can provide enough memory + * for cpu retention, the cpu power domain can be powered off. + */ +bool cpu_domain_pd_allowed(void); + +#endif + +#if SOC_PM_SUPPORT_CPU_PD || SOC_PM_SUPPORT_TAGMEM_PD + +/** + * @brief Enable memory retention of some modules. + * + * In light sleep mode, before the system goes to sleep, enable the memory + * retention of modules such as CPU and I/D-cache tag memory. + */ +void sleep_enable_memory_retention(void); + +/** + * @brief Disable memory retention of some modules. + * + * In light sleep mode, after the system exits sleep, disable the memory + * retention of moudles such as CPU and I/D-cache tag memory. + */ +void sleep_disable_memory_retention(void); + +#endif // SOC_PM_SUPPORT_CPU_PD || SOC_PM_SUPPORT_TAGMEM_PD + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/esp_random.h b/tools/sdk/esp32s2/include/esp_hw_support/include/esp_random.h index cf4f408b513..a6b8a884b69 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/esp_random.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/esp_random.h @@ -1,16 +1,8 @@ -// Copyright 2021 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. +/* + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/esp_sleep.h b/tools/sdk/esp32s2/include/esp_hw_support/include/esp_sleep.h index 000d020aebb..cfdfbc04186 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/esp_sleep.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/esp_sleep.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once @@ -49,7 +41,9 @@ typedef enum { ESP_PD_DOMAIN_RTC_SLOW_MEM, //!< RTC slow memory ESP_PD_DOMAIN_RTC_FAST_MEM, //!< RTC fast memory ESP_PD_DOMAIN_XTAL, //!< XTAL oscillator +#if SOC_PM_SUPPORT_CPU_PD ESP_PD_DOMAIN_CPU, //!< CPU core +#endif ESP_PD_DOMAIN_VDDSDIO, //!< VDD_SDIO ESP_PD_DOMAIN_MAX //!< Number of domains } esp_sleep_pd_domain_t; @@ -380,6 +374,8 @@ esp_err_t esp_light_sleep_start(void); * * This function does not return. * + * @note The device will wake up immediately if the deep-sleep time is set to 0 + * * @param time_in_us deep-sleep time, unit: microsecond */ void esp_deep_sleep(uint64_t time_in_us) __attribute__((noreturn)); diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/clk_ctrl_os.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/clk_ctrl_os.h index f4d769b8014..b5eff46930c 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/clk_ctrl_os.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/clk_ctrl_os.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include "soc/rtc.h" diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/compare_set.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/compare_set.h index ddbaeb7e3d6..b5a35fa701a 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/compare_set.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/compare_set.h @@ -1,16 +1,8 @@ -// Copyright 2015-2019 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/cpu.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/cpu.h index 0e4d1688ca3..526171bc1ce 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/cpu.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/cpu.h @@ -1,16 +1,8 @@ -// Copyright 2010-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. +/* + * SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _SOC_CPU_H #define _SOC_CPU_H diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32/clk.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32/clk.h index 31902ebad01..a9ed3028527 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32/clk.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32/clk.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include "esp_private/esp_clk.h" diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32/dport_access.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32/dport_access.h index 4f473940ad4..8e04674951a 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32/dport_access.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32/dport_access.h @@ -3,30 +3,28 @@ * * SPDX-License-Identifier: Apache-2.0 */ -#include - -#include -#ifndef _ESP_DPORT_ACCESS_H_ -#define _ESP_DPORT_ACCESS_H_ +#pragma once +#include +#include #include "xtensa/xtruntime.h" #ifdef __cplusplus extern "C" { #endif -void esp_dport_access_stall_other_cpu_start(void); -void esp_dport_access_stall_other_cpu_end(void); -void esp_dport_access_int_init(void); -void esp_dport_access_int_pause(void); -void esp_dport_access_int_resume(void); +void esp_dport_access_stall_other_cpu_start(void) __attribute__ ((deprecated)); +void esp_dport_access_stall_other_cpu_end(void) __attribute__ ((deprecated)); +void esp_dport_access_int_init(void) __attribute__ ((deprecated)); +void esp_dport_access_int_pause(void) __attribute__ ((deprecated)); +void esp_dport_access_int_resume(void) __attribute__ ((deprecated)); void esp_dport_access_read_buffer(uint32_t *buff_out, uint32_t address, uint32_t num_words); uint32_t esp_dport_access_reg_read(uint32_t reg); uint32_t esp_dport_access_sequence_reg_read(uint32_t reg); //This routine does not stop the dport routines in any way that is recoverable. Please //only call in case of panic(). -void esp_dport_access_int_abort(void); +void esp_dport_access_int_abort(void) __attribute__ ((deprecated)); #if defined(BOOTLOADER_BUILD) || !defined(CONFIG_ESP32_DPORT_WORKAROUND) || !defined(ESP_PLATFORM) #define DPORT_STALL_OTHER_CPU_START() @@ -34,8 +32,9 @@ void esp_dport_access_int_abort(void); #define DPORT_INTERRUPT_DISABLE() #define DPORT_INTERRUPT_RESTORE() #else -#define DPORT_STALL_OTHER_CPU_START() esp_dport_access_stall_other_cpu_start() -#define DPORT_STALL_OTHER_CPU_END() esp_dport_access_stall_other_cpu_end() +#include "esp_ipc_isr.h" +#define DPORT_STALL_OTHER_CPU_START() esp_ipc_isr_stall_other_cpu() +#define DPORT_STALL_OTHER_CPU_END() esp_ipc_isr_release_other_cpu() #define DPORT_INTERRUPT_DISABLE() unsigned int intLvl = XTOS_SET_INTLEVEL(CONFIG_ESP32_DPORT_DIS_INTERRUPT_LVL) #define DPORT_INTERRUPT_RESTORE() XTOS_RESTORE_JUST_INTLEVEL(intLvl) #endif @@ -43,5 +42,3 @@ void esp_dport_access_int_abort(void); #ifdef __cplusplus } #endif - -#endif /* _ESP_DPORT_ACCESS_H_ */ diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32/spiram.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32/spiram.h index e58712d1fa6..a6086f3d311 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32/spiram.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32/spiram.h @@ -85,6 +85,15 @@ size_t esp_spiram_get_size(void); */ void esp_spiram_writeback_cache(void); +/** + * @brief get psram CS IO + * + * This interface should be called after PSRAM is enabled, otherwise it will + * return an invalid value -1/0xff. + * + * @return psram CS IO or -1/0xff if psram not enabled + */ +uint8_t esp_spiram_get_cs_io(void); /** diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32c3/clk.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32c3/clk.h index 31902ebad01..a9ed3028527 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32c3/clk.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32c3/clk.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include "esp_private/esp_clk.h" diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32c3/dport_access.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32c3/dport_access.h index f3f7007a9cb..e5aedd2e1b1 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32c3/dport_access.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32c3/dport_access.h @@ -1,16 +1,8 @@ -// Copyright 2010-2020 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. +/* + * SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_DPORT_ACCESS_H_ #define _ESP_DPORT_ACCESS_H_ diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32c3/esp_crypto_lock.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32c3/esp_crypto_lock.h index 3149d34692b..67a08741b51 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32c3/esp_crypto_lock.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32c3/esp_crypto_lock.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32c3/esp_ds.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32c3/esp_ds.h index 911e44c8379..9d59aa71c6f 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32c3/esp_ds.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32c3/esp_ds.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32c3/esp_hmac.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32c3/esp_hmac.h index 391ba12fe15..26e2bc71a05 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32c3/esp_hmac.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32c3/esp_hmac.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_HMAC_H_ #define _ESP_HMAC_H_ @@ -60,6 +52,35 @@ esp_err_t esp_hmac_calculate(hmac_key_id_t key_id, size_t message_len, uint8_t *hmac); +/** + * @brief Use HMAC peripheral in Downstream mode to re-enable the JTAG, if it is not permanently disabled by HW. + * In downstream mode, HMAC calculations performed by peripheral are used internally and not provided back to user. + * + * @param key_id Determines which of the 6 key blocks in the efuses should be used for the HMAC calculation. + * The corresponding purpose field of the key block in the efuse must be set to HMAC downstream purpose. + * + * @param token Pre calculated HMAC value of the 32-byte 0x00 using SHA-256 and the known private HMAC key. The key is already + * programmed to a eFuse key block. The key block number is provided as the first parameter to this function. + * + * @return + * * ESP_OK, if the calculation was successful, + * if the calculated HMAC value matches with provided token, + * JTAG will be re-enable otherwise JTAG will remain disabled. + * Return value does not indicate the JTAG status. + * * ESP_FAIL, if the hmac calculation failed or JTAG is permanently disabled by EFUSE_HARD_DIS_JTAG eFuse parameter. + * * ESP_ERR_INVALID_ARG, invalid input arguments + */ +esp_err_t esp_hmac_jtag_enable(hmac_key_id_t key_id, const uint8_t *token); + +/** + * @brief Disable the JTAG which might be enabled using the HMAC downstream mode. This function just clears the result generated + * by calling esp_hmac_jtag_enable() API. + * + * @return + * * ESP_OK return ESP_OK after writing the HMAC_SET_INVALIDATE_JTAG_REG with value 1. + */ +esp_err_t esp_hmac_jtag_disable(void); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32c3/memprot.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32c3/memprot.h index 0d7e6ca40df..818cd677dc8 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32c3/memprot.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32c3/memprot.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /* INTERNAL API diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32c3/rtc.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32c3/rtc.h index b090ae5cfbe..4d46831ded3 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32c3/rtc.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32c3/rtc.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32h2/clk.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32h2/clk.h index 31902ebad01..a9ed3028527 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32h2/clk.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32h2/clk.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include "esp_private/esp_clk.h" diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32h2/dport_access.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32h2/dport_access.h index f3f7007a9cb..e5aedd2e1b1 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32h2/dport_access.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32h2/dport_access.h @@ -1,16 +1,8 @@ -// Copyright 2010-2020 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. +/* + * SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_DPORT_ACCESS_H_ #define _ESP_DPORT_ACCESS_H_ diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32h2/esp_crypto_lock.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32h2/esp_crypto_lock.h index 3149d34692b..67a08741b51 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32h2/esp_crypto_lock.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32h2/esp_crypto_lock.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32h2/esp_ds.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32h2/esp_ds.h index 79e963fc6bd..6bad7075587 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32h2/esp_ds.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32h2/esp_ds.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32h2/esp_hmac.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32h2/esp_hmac.h index 391ba12fe15..26e2bc71a05 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32h2/esp_hmac.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32h2/esp_hmac.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_HMAC_H_ #define _ESP_HMAC_H_ @@ -60,6 +52,35 @@ esp_err_t esp_hmac_calculate(hmac_key_id_t key_id, size_t message_len, uint8_t *hmac); +/** + * @brief Use HMAC peripheral in Downstream mode to re-enable the JTAG, if it is not permanently disabled by HW. + * In downstream mode, HMAC calculations performed by peripheral are used internally and not provided back to user. + * + * @param key_id Determines which of the 6 key blocks in the efuses should be used for the HMAC calculation. + * The corresponding purpose field of the key block in the efuse must be set to HMAC downstream purpose. + * + * @param token Pre calculated HMAC value of the 32-byte 0x00 using SHA-256 and the known private HMAC key. The key is already + * programmed to a eFuse key block. The key block number is provided as the first parameter to this function. + * + * @return + * * ESP_OK, if the calculation was successful, + * if the calculated HMAC value matches with provided token, + * JTAG will be re-enable otherwise JTAG will remain disabled. + * Return value does not indicate the JTAG status. + * * ESP_FAIL, if the hmac calculation failed or JTAG is permanently disabled by EFUSE_HARD_DIS_JTAG eFuse parameter. + * * ESP_ERR_INVALID_ARG, invalid input arguments + */ +esp_err_t esp_hmac_jtag_enable(hmac_key_id_t key_id, const uint8_t *token); + +/** + * @brief Disable the JTAG which might be enabled using the HMAC downstream mode. This function just clears the result generated + * by calling esp_hmac_jtag_enable() API. + * + * @return + * * ESP_OK return ESP_OK after writing the HMAC_SET_INVALIDATE_JTAG_REG with value 1. + */ +esp_err_t esp_hmac_jtag_disable(void); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32h2/memprot.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32h2/memprot.h index 2567b604b00..75228580ffd 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32h2/memprot.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32h2/memprot.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /* INTERNAL API diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32h2/rtc.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32h2/rtc.h index cca748df919..75460416c7d 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32h2/rtc.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32h2/rtc.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/clk.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/clk.h index 31902ebad01..a9ed3028527 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/clk.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/clk.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include "esp_private/esp_clk.h" diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/dport_access.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/dport_access.h index 6ba6fd65556..e5aedd2e1b1 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/dport_access.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/dport_access.h @@ -1,16 +1,8 @@ -// Copyright 2010-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. +/* + * SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_DPORT_ACCESS_H_ #define _ESP_DPORT_ACCESS_H_ diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/esp_crypto_lock.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/esp_crypto_lock.h index e1df0399f30..2c337c93714 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/esp_crypto_lock.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/esp_crypto_lock.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/esp_ds.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/esp_ds.h index 12906377ee5..2ef0bd00fbe 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/esp_ds.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/esp_ds.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/esp_hmac.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/esp_hmac.h index 5fa836c47d8..409217c06bc 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/esp_hmac.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/esp_hmac.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_HMAC_H_ #define _ESP_HMAC_H_ diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/memprot.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/memprot.h index c63fb395e6d..0ebd6474578 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/memprot.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/memprot.h @@ -1,17 +1,8 @@ -// Copyright 2020 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. - +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /* INTERNAL API * generic interface to MMU memory protection features @@ -21,6 +12,7 @@ #include #include #include "esp_attr.h" +#include "esp_err.h" #ifdef __cplusplus extern "C" { @@ -51,6 +43,8 @@ extern "C" { #define MEMPROT_UNLOCK false #define DEF_SPLIT_LINE NULL +#define MEMPROT_INVALID_ADDRESS -1 + //memory range types typedef enum { MEMPROT_NONE = 0x00000000, @@ -77,23 +71,27 @@ typedef enum { uint32_t *IRAM_ATTR esp_memprot_get_split_addr(mem_type_prot_t mem_type); /** - * @brief Initializes illegal memory access control (MMU) for required memory section. + * @brief Initializes illegal memory access control for required memory section. * * All memory access interrupts share ETS_MEMACCESS_ERR_INUM input channel, it is caller's * responsibility to properly detect actual intr. source as well as possible prioritization in case * of multiple source reported during one intr.handling routine run * - * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @param mem_type Memory protection area type (see mem_type_prot_t enum)\ + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_intr_init(mem_type_prot_t mem_type); +esp_err_t esp_memprot_intr_init(mem_type_prot_t mem_type); /** * @brief Enable/disable the memory protection interrupt * * @param mem_type Memory protection area type (see mem_type_prot_t enum) * @param enable enable/disable + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_intr_ena(mem_type_prot_t mem_type, bool enable); +esp_err_t esp_memprot_intr_ena(mem_type_prot_t mem_type, bool enable); /** * @brief Sets a request for clearing interrupt-on flag for specified memory region (register write) @@ -102,8 +100,10 @@ void esp_memprot_intr_ena(mem_type_prot_t mem_type, bool enable); * Should be used only after the real interrupt appears, typically as the last step in interrupt handler's routine. * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_clear_intr(mem_type_prot_t mem_type); +esp_err_t esp_memprot_clear_intr(mem_type_prot_t mem_type); /** * @brief Detects which memory protection interrupt is active @@ -122,10 +122,11 @@ mem_type_prot_t IRAM_ATTR esp_memprot_get_active_intr_memtype(void); * @brief Gets interrupt status register contents for specified memory region * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @param fault_reg_val Contents of status register * - * @return Contents of status register + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -uint32_t esp_memprot_get_fault_reg(mem_type_prot_t mem_type); +esp_err_t esp_memprot_get_fault_reg(mem_type_prot_t mem_type, uint32_t *fault_reg_val); /** * @brief Get details of given interrupt status @@ -138,8 +139,9 @@ uint32_t esp_memprot_get_fault_reg(mem_type_prot_t mem_type); * @param op_subtype Additional info for op_type [out] * IRAM0: 0 - instruction segment access, 1 - data segment access * DRAM0: 0 - non-atomic operation, 1 - atomic operation + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void IRAM_ATTR esp_memprot_get_fault_status(mem_type_prot_t mem_type, uint32_t **faulting_address, uint32_t *op_type, uint32_t *op_subtype); +esp_err_t IRAM_ATTR esp_memprot_get_fault_status(mem_type_prot_t mem_type, uint32_t **faulting_address, uint32_t *op_type, uint32_t *op_subtype); /** * @brief Gets string representation of required memory region identifier @@ -163,26 +165,30 @@ bool esp_memprot_is_locked_any(void); * Locks can be unlocked only by digital system reset * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_set_lock(mem_type_prot_t mem_type); +esp_err_t esp_memprot_set_lock(mem_type_prot_t mem_type); /** * @brief Gets lock status for required memory region * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @param locked Settings locked: true/false (locked/unlocked) * - * @return true/false (locked/unlocked) + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -bool esp_memprot_get_lock(mem_type_prot_t mem_type); +esp_err_t esp_memprot_get_lock(mem_type_prot_t mem_type, bool *locked); /** * @brief Gets permission control configuration register contents for required memory region * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @param conf_reg_val Permission control register contents * - * @return Permission control register contents + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -uint32_t esp_memprot_get_conf_reg(mem_type_prot_t mem_type); +esp_err_t esp_memprot_get_conf_reg(mem_type_prot_t mem_type, uint32_t *conf_reg_val); /** * @brief Gets interrupt permission settings for unified management block @@ -190,21 +196,23 @@ uint32_t esp_memprot_get_conf_reg(mem_type_prot_t mem_type); * Gets interrupt permission settings register contents for required memory region, returns settings for unified management blocks * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @param perm_reg Permission settings register contents * - * @return Permission settings register contents + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -uint32_t esp_memprot_get_perm_uni_reg(mem_type_prot_t mem_type); +esp_err_t esp_memprot_get_perm_uni_reg(mem_type_prot_t mem_type, uint32_t *perm_reg); /** * @brief Gets interrupt permission settings for split management block * - * Gets interrupt permission settings register contents for required memory region, returns settings for split management blocks + * Gets interrupt permission settings register contents for required memory region (unified management blocks) * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @return split_reg Unified management settings register contents * - * @return Permission settings register contents + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -uint32_t esp_memprot_get_perm_split_reg(mem_type_prot_t mem_type); +esp_err_t esp_memprot_get_perm_split_reg(mem_type_prot_t mem_type, uint32_t *split_reg); /** * @brief Detects whether any of the memory protection interrupts is enabled @@ -217,28 +225,30 @@ bool esp_memprot_is_intr_ena_any(void); * @brief Gets interrupt-enabled flag for given memory region * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @param enable_bit Interrupt-enabled flag * - * @return Interrupt-enabled value + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -uint32_t esp_memprot_get_intr_ena_bit(mem_type_prot_t mem_type); +esp_err_t esp_memprot_get_intr_ena_bit(mem_type_prot_t mem_type, uint32_t *enable_bit); /** * @brief Gets interrupt-active flag for given memory region * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @param intr_on_bit Interrupt-active flag * - * @return Interrupt-active value - */ -uint32_t esp_memprot_get_intr_on_bit(mem_type_prot_t mem_type); + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ +esp_err_t esp_memprot_get_intr_on_bit(mem_type_prot_t mem_type, uint32_t *intr_on_bit); /** * @brief Gets interrupt-clear request flag for given memory region * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @param clear_bit Interrupt-clear request flag * - * @return Interrupt-clear request value + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -uint32_t esp_memprot_get_intr_clr_bit(mem_type_prot_t mem_type); +esp_err_t esp_memprot_get_intr_clr_bit(mem_type_prot_t mem_type, uint32_t *clear_bit); /** * @brief Gets read permission value for specified block and memory region @@ -248,10 +258,11 @@ uint32_t esp_memprot_get_intr_clr_bit(mem_type_prot_t mem_type); * * @param mem_type Memory protection area type (see mem_type_prot_t enum) * @param block Memory block identifier (0-3) + * @param read_bit Read permission value for required block * - * @return Read permission value for required block + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -uint32_t esp_memprot_get_uni_block_read_bit(mem_type_prot_t mem_type, uint32_t block); +esp_err_t esp_memprot_get_uni_block_read_bit(mem_type_prot_t mem_type, uint32_t block, uint32_t *read_bit); /** * @brief Gets write permission value for specified block and memory region @@ -261,10 +272,11 @@ uint32_t esp_memprot_get_uni_block_read_bit(mem_type_prot_t mem_type, uint32_t b * * @param mem_type Memory protection area type (see mem_type_prot_t enum) * @param block Memory block identifier (0-3) + * @param write_bit Write permission value for required block * - * @return Write permission value for required block + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -uint32_t esp_memprot_get_uni_block_write_bit(mem_type_prot_t mem_type, uint32_t block); +esp_err_t esp_memprot_get_uni_block_write_bit(mem_type_prot_t mem_type, uint32_t block, uint32_t *write_bit); /** * @brief Gets execute permission value for specified block and memory region @@ -274,10 +286,11 @@ uint32_t esp_memprot_get_uni_block_write_bit(mem_type_prot_t mem_type, uint32_t * * @param mem_type Memory protection area type (see mem_type_prot_t enum) * @param block Memory block identifier (0-3) + * @param exec_bit Execute permission value for required block * - * @return Execute permission value for required block + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -uint32_t esp_memprot_get_uni_block_exec_bit(mem_type_prot_t mem_type, uint32_t block); +esp_err_t esp_memprot_get_uni_block_exec_bit(mem_type_prot_t mem_type, uint32_t block, uint32_t *exec_bit); /** * @brief Sets permissions for specified block in DRAM region @@ -289,8 +302,10 @@ uint32_t esp_memprot_get_uni_block_exec_bit(mem_type_prot_t mem_type, uint32_t b * @param block Memory block identifier (0-3) * @param write_perm Write permission flag * @param read_perm Read permission flag + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_set_uni_block_perm_dram(mem_type_prot_t mem_type, uint32_t block, bool write_perm, bool read_perm); +esp_err_t esp_memprot_set_uni_block_perm_dram(mem_type_prot_t mem_type, uint32_t block, bool write_perm, bool read_perm); /** * @brief Sets permissions for high and low memory segment in DRAM region @@ -305,8 +320,10 @@ void esp_memprot_set_uni_block_perm_dram(mem_type_prot_t mem_type, uint32_t bloc * @param lr Low segment Read permission flag * @param hw High segment Write permission flag * @param hr High segment Read permission flag + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_set_prot_dram(mem_type_prot_t mem_type, uint32_t *split_addr, bool lw, bool lr, bool hw, bool hr); +esp_err_t esp_memprot_set_prot_dram(mem_type_prot_t mem_type, uint32_t *split_addr, bool lw, bool lr, bool hw, bool hr); /** * @brief Sets permissions for specified block in IRAM region @@ -314,12 +331,17 @@ void esp_memprot_set_prot_dram(mem_type_prot_t mem_type, uint32_t *split_addr, b * Sets Read, Write and Execute permission for specified unified-management block (0-3) in given memory region. * Applicable only to IRAM memory types * - * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @param mem_type Memory protection area type (MEMPROT_IRAM0_SRAM) * @param block Memory block identifier (0-3) * @param write_perm Write permission flag + * @param read_perm Read permission flag * @param exec_perm Execute permission flag + * + * @return ESP_OK on success + * ESP_ERR_NOT_SUPPORTED on invalid mem_type + * ESP_ERR_INVALID_ARG on incorrect block number */ -void esp_memprot_set_uni_block_perm_iram(mem_type_prot_t mem_type, uint32_t block, bool write_perm, bool read_perm, bool exec_perm); +esp_err_t esp_memprot_set_uni_block_perm_iram(mem_type_prot_t mem_type, uint32_t block, bool write_perm, bool read_perm, bool exec_perm); /** * @brief Sets permissions for high and low memory segment in IRAM region @@ -336,8 +358,10 @@ void esp_memprot_set_uni_block_perm_iram(mem_type_prot_t mem_type, uint32_t bloc * @param hw High segment Write permission flag * @param hr High segment Read permission flag * @param hx High segment Execute permission flag + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_set_prot_iram(mem_type_prot_t mem_type, uint32_t *split_addr, bool lw, bool lr, bool lx, bool hw, bool hr, bool hx); +esp_err_t esp_memprot_set_prot_iram(mem_type_prot_t mem_type, uint32_t *split_addr, bool lw, bool lr, bool lx, bool hw, bool hr, bool hx); /** * @brief Activates memory protection for all supported memory region types @@ -347,8 +371,10 @@ void esp_memprot_set_prot_iram(mem_type_prot_t mem_type, uint32_t *split_addr, b * @param invoke_panic_handler map mem.prot interrupt to ETS_MEMACCESS_ERR_INUM and thus invokes panic handler when fired ('true' not suitable for testing) * @param lock_feature sets LOCK bit, see esp_memprot_set_lock() ('true' not suitable for testing) * @param mem_type_mask holds a set of required memory protection types (bitmask built of mem_type_prot_t). NULL means default (MEMPROT_ALL in this version) + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_set_prot(bool invoke_panic_handler, bool lock_feature, uint32_t *mem_type_mask); +esp_err_t esp_memprot_set_prot(bool invoke_panic_handler, bool lock_feature, uint32_t *mem_type_mask); /** * @brief Get permission settings bits for IRAM0 split mgmt. Only IRAM0 memory types allowed @@ -360,8 +386,10 @@ void esp_memprot_set_prot(bool invoke_panic_handler, bool lock_feature, uint32_t * @param hw High segment Write permission flag * @param hr High segment Read permission flag * @param hx High segment Execute permission flag + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_get_perm_split_bits_iram(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *lx, bool *hw, bool *hr, bool *hx); +esp_err_t esp_memprot_get_perm_split_bits_iram(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *lx, bool *hw, bool *hr, bool *hx); /** * @brief Get permission settings bits for DRAM0 split mgmt. Only DRAM0 memory types allowed @@ -371,8 +399,10 @@ void esp_memprot_get_perm_split_bits_iram(mem_type_prot_t mem_type, bool *lw, bo * @param lr Low segment Read permission flag * @param hw High segment Write permission flag * @param hr High segment Read permission flag + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_get_perm_split_bits_dram(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *hw, bool *hr); +esp_err_t esp_memprot_get_perm_split_bits_dram(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *hw, bool *hr); /** * @brief Sets permissions for high and low memory segment in PERIBUS1 region @@ -386,8 +416,10 @@ void esp_memprot_get_perm_split_bits_dram(mem_type_prot_t mem_type, bool *lw, bo * @param lr Low segment Read permission flag * @param hw High segment Write permission flag * @param hr High segment Read permission flag + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_set_prot_peri1(mem_type_prot_t mem_type, uint32_t *split_addr, bool lw, bool lr, bool hw, bool hr); +esp_err_t esp_memprot_set_prot_peri1(mem_type_prot_t mem_type, uint32_t *split_addr, bool lw, bool lr, bool hw, bool hr); /** * @brief Get permission settings bits for PERIBUS1 split mgmt. Only PERIBUS1 memory types allowed @@ -397,8 +429,10 @@ void esp_memprot_set_prot_peri1(mem_type_prot_t mem_type, uint32_t *split_addr, * @param lr Low segment Read permission flag * @param hw High segment Write permission flag * @param hr High segment Read permission flag + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_get_perm_split_bits_peri1(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *hw, bool *hr); +esp_err_t esp_memprot_get_perm_split_bits_peri1(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *hw, bool *hr); /** * @brief Get permission settings bits for PERIBUS2 split mgmt. Only PERIBUS2 memory types allowed @@ -410,25 +444,32 @@ void esp_memprot_get_perm_split_bits_peri1(mem_type_prot_t mem_type, bool *lw, b * @param hw High segment Write permission flag * @param hr High segment Read permission flag * @param hx High segment Execute permission flag + * + * @return ESP_OK on success, ESP_ERR_INVALID_ARG on failure */ -void esp_memprot_get_perm_split_bits_peri2(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *lx, bool *hw, bool *hr, bool *hx); +esp_err_t esp_memprot_get_perm_split_bits_peri2(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *lx, bool *hw, bool *hr, bool *hx); /** - * @brief Sets permissions for high and low memory segment in PERIBUS2 region + * @brief Configures the memory protection for high and low segment in PERIBUS2 region * * Sets Read Write permission for both low and high memory segments given by splitting address. * Applicable only to PERIBUS2 memory types * - * @param mem_type Memory protection area type (see mem_type_prot_t enum) - * @param split_addr Address to split the memory region to lower and higher segment + * @param mem_type Memory protection area type (MEMPROT_PERI2_RTCSLOW_0, MEMPROT_PERI2_RTCSLOW_1) + * @param split_addr Address to split the memory region to lower and higher segment (32bit aligned) * @param lw Low segment Write permission flag * @param lr Low segment Read permission flag * @param lx Low segment Execute permission flag * @param hw High segment Write permission flag * @param hr High segment Read permission flag * @param hx High segment Execute permission flag + * + * @return ESP_OK on success + * ESP_ERR_NOT_SUPPORTED on invalid mem_type + * ESP_ERR_INVALID_STATE on splitting address out of PERIBUS2 range + * ESP_ERR_INVALID_SIZE on splitting address not 32-bit aligned */ -void esp_memprot_set_prot_peri2(mem_type_prot_t mem_type, uint32_t *split_addr, bool lw, bool lr, bool lx, bool hw, bool hr, bool hx); +esp_err_t esp_memprot_set_prot_peri2(mem_type_prot_t mem_type, uint32_t *split_addr, bool lw, bool lr, bool lx, bool hw, bool hr, bool hx); /** * @brief Get permissions for specified memory type. Irrelevant bits are ignored @@ -440,8 +481,12 @@ void esp_memprot_set_prot_peri2(mem_type_prot_t mem_type, uint32_t *split_addr, * @param hw High segment Write permission flag * @param hr High segment Read permission flag * @param hx High segment Execute permission flag + * + * @return ESP_OK on success + * ESP_ERR_INVALID_ARG on NULL lw/lr/lx/hw/hr/hx args + * ESP_ERR_NOT_SUPPORTED on invalid mem_type */ -void esp_memprot_get_permissions(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *lx, bool *hw, bool *hr, bool *hx); +esp_err_t esp_memprot_get_permissions(mem_type_prot_t mem_type, bool *lw, bool *lr, bool *lx, bool *hw, bool *hr, bool *hx); /** * @brief Get Read permission settings for low and high regions of given memory type @@ -449,8 +494,12 @@ void esp_memprot_get_permissions(mem_type_prot_t mem_type, bool *lw, bool *lr, b * @param mem_type Memory protection area type (see mem_type_prot_t enum) * @param lr Low segment Read permission flag * @param hr High segment Read permission flag + * + * @return ESP_OK on success + * ESP_ERR_INVALID_ARG on NULL lr/hr args + * ESP_ERR_NOT_SUPPORTED on invalid mem_type */ -void esp_memprot_get_perm_read(mem_type_prot_t mem_type, bool *lr, bool *hr); +esp_err_t esp_memprot_get_perm_read(mem_type_prot_t mem_type, bool *lr, bool *hr); /** * @brief Get Write permission settings for low and high regions of given memory type @@ -458,23 +507,33 @@ void esp_memprot_get_perm_read(mem_type_prot_t mem_type, bool *lr, bool *hr); * @param mem_type Memory protection area type (see mem_type_prot_t enum) * @param lr Low segment Write permission flag * @param hr High segment Write permission flag + * + * @return ESP_OK on success + * ESP_ERR_INVALID_ARG on NULL lw/hw args + * ESP_ERR_NOT_SUPPORTED on invalid mem_type */ -void esp_memprot_get_perm_write(mem_type_prot_t mem_type, bool *lw, bool *hw); +esp_err_t esp_memprot_get_perm_write(mem_type_prot_t mem_type, bool *lw, bool *hw); /** * @brief Get Execute permission settings for low and high regions of given memory type * Applicable only to IBUS-compatible memory types * - * @param mem_type Memory protection area type (see mem_type_prot_t enum) - * @param lr Low segment Exec permission flag - * @param hr High segment Exec permission flag + * @param mem_type Memory protection area type (MEMPROT_IRAM0_SRAM, MEMPROT_IRAM0_RTCFAST, MEMPROT_PERI2_RTCSLOW_0, MEMPROT_PERI2_RTCSLOW_1) + * @param lx Low segment Exec permission flag + * @param hx High segment Exec permission flag + * + * @return ESP_OK on success + * ESP_ERR_INVALID_ARG on NULL lx/hx args + * ESP_ERR_NOT_SUPPORTED on invalid mem_type */ -void esp_memprot_get_perm_exec(mem_type_prot_t mem_type, bool *lx, bool *hx); +esp_err_t esp_memprot_get_perm_exec(mem_type_prot_t mem_type, bool *lx, bool *hx); /** * @brief Returns the lowest address in required memory region * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * + * @return Required address or MEMPROT_INVALID_ADDRESS for invalid mem_type */ uint32_t esp_memprot_get_low_limit(mem_type_prot_t mem_type); @@ -482,6 +541,8 @@ uint32_t esp_memprot_get_low_limit(mem_type_prot_t mem_type); * @brief Returns the highest address in required memory region * * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * + * @return Required address or MEMPROT_INVALID_ADDRESS for invalid mem_type */ uint32_t esp_memprot_get_high_limit(mem_type_prot_t mem_type); @@ -491,8 +552,11 @@ uint32_t esp_memprot_get_high_limit(mem_type_prot_t mem_type); * @param mem_type Memory protection area type (see mem_type_prot_t enum) * @param lr Low segment Read permission flag * @param hr High segment Read permission flag + * + * @return ESP_OK on success + * ESP_ERR_NOT_SUPPORTED on invalid mem_type */ -void esp_memprot_set_read_perm(mem_type_prot_t mem_type, bool lr, bool hr); +esp_err_t esp_memprot_set_read_perm(mem_type_prot_t mem_type, bool lr, bool hr); /** * @brief Sets WRITE permission bit for required memory region @@ -500,17 +564,23 @@ void esp_memprot_set_read_perm(mem_type_prot_t mem_type, bool lr, bool hr); * @param mem_type Memory protection area type (see mem_type_prot_t enum) * @param lr Low segment Write permission flag * @param hr High segment Write permission flag + * + * @return ESP_OK on success + * ESP_ERR_NOT_SUPPORTED on invalid mem_type */ -void esp_memprot_set_write_perm(mem_type_prot_t mem_type, bool lw, bool hw); +esp_err_t esp_memprot_set_write_perm(mem_type_prot_t mem_type, bool lw, bool hw); /** * @brief Sets EXECUTE permission bit for required memory region * - * @param mem_type Memory protection area type (see mem_type_prot_t enum) + * @param mem_type Memory protection area type (MEMPROT_IRAM0_SRAM, MEMPROT_IRAM0_RTCFAST, MEMPROT_PERI2_RTCSLOW_0, MEMPROT_PERI2_RTCSLOW_1) * @param lr Low segment Exec permission flag * @param hr High segment Exec permission flag + * + * @return ESP_OK on success + * ESP_ERR_NOT_SUPPORTED on invalid mem_type */ -void esp_memprot_set_exec_perm(mem_type_prot_t mem_type, bool lx, bool hx); +esp_err_t esp_memprot_set_exec_perm(mem_type_prot_t mem_type, bool lx, bool hx); #ifdef __cplusplus diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/rtc.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/rtc.h index 296292e21db..3ab96b37872 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/rtc.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/rtc.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/spiram.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/spiram.h index cc2b4c85497..70d07e61a85 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/spiram.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s2/spiram.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef __ESP_SPIRAM_H @@ -78,6 +70,15 @@ size_t esp_spiram_get_size(void); */ void esp_spiram_writeback_cache(void); +/** + * @brief get psram CS IO + * + * This interface should be called after PSRAM is enabled, otherwise it will + * return an invalid value -1/0xff. + * + * @return psram CS IO or -1/0xff if psram not enabled + */ +uint8_t esp_spiram_get_cs_io(void); /** @@ -91,6 +92,15 @@ void esp_spiram_writeback_cache(void); */ esp_err_t esp_spiram_reserve_dma_pool(size_t size); +/** + * @brief If SPI RAM(PSRAM) has been initialized + * + * @return + * - true SPI RAM has been initialized successfully + * - false SPI RAM hasn't been initialized or initialized failed + */ +bool esp_spiram_is_initialized(void); + #if CONFIG_SPIRAM_FETCH_INSTRUCTIONS extern int _instruction_reserved_start, _instruction_reserved_end; diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s3/clk.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s3/clk.h index 31902ebad01..a9ed3028527 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s3/clk.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s3/clk.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include "esp_private/esp_clk.h" diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s3/dport_access.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s3/dport_access.h index f3f7007a9cb..e5aedd2e1b1 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s3/dport_access.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s3/dport_access.h @@ -1,16 +1,8 @@ -// Copyright 2010-2020 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. +/* + * SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_DPORT_ACCESS_H_ #define _ESP_DPORT_ACCESS_H_ diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s3/esp_crypto_lock.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s3/esp_crypto_lock.h index 781ac077803..074754a86b2 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s3/esp_crypto_lock.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s3/esp_crypto_lock.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once @@ -26,6 +18,34 @@ extern "C" { * Other unrelated components must not use it. */ +/** + * @brief Acquire lock for Digital Signature(DS) cryptography peripheral + * + * Internally also takes the HMAC lock, as the DS depends on the HMAC peripheral + */ +void esp_crypto_ds_lock_acquire(void); + +/** + * @brief Release lock for Digital Signature(DS) cryptography peripheral + * + * Internally also releases the HMAC lock, as the DS depends on the HMAC peripheral + */ +void esp_crypto_ds_lock_release(void); + +/** + * @brief Acquire lock for HMAC cryptography peripheral + * + * Internally also takes the SHA & AES lock, as the HMAC depends on the SHA peripheral + */ +void esp_crypto_hmac_lock_acquire(void); + +/** + * @brief Release lock for HMAC cryptography peripheral + * + * Internally also releases the SHA & AES lock, as the HMAC depends on the SHA peripheral + */ +void esp_crypto_hmac_lock_release(void); + /** * @brief Acquire lock for the SHA and AES cryptography peripheral. * diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s3/esp_ds.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s3/esp_ds.h new file mode 100644 index 00000000000..46a1d22a543 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s3/esp_ds.h @@ -0,0 +1,192 @@ +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once +#include + +#include "esp_hmac.h" +#include "esp_err.h" +#include "soc/soc_caps.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ESP32S3_ERR_HW_CRYPTO_DS_HMAC_FAIL ESP_ERR_HW_CRYPTO_BASE + 0x1 /*!< HMAC peripheral problem */ +#define ESP32S3_ERR_HW_CRYPTO_DS_INVALID_KEY ESP_ERR_HW_CRYPTO_BASE + 0x2 /*!< given HMAC key isn't correct, + HMAC peripheral problem */ +#define ESP32S3_ERR_HW_CRYPTO_DS_INVALID_DIGEST ESP_ERR_HW_CRYPTO_BASE + 0x4 /*!< message digest check failed, + result is invalid */ +#define ESP32S3_ERR_HW_CRYPTO_DS_INVALID_PADDING ESP_ERR_HW_CRYPTO_BASE + 0x5 /*!< padding check failed, but result + is produced anyway and can be read*/ + +#define ESP_DS_IV_LEN 16 + +/* Length of parameter 'C' stored in flash */ +#define ESP_DS_C_LEN (12672 / 8) + +typedef struct esp_ds_context esp_ds_context_t; + +typedef enum { + ESP_DS_RSA_1024 = (1024 / 32) - 1, + ESP_DS_RSA_2048 = (2048 / 32) - 1, + ESP_DS_RSA_3072 = (3072 / 32) - 1, + ESP_DS_RSA_4096 = (4096 / 32) - 1 +} esp_digital_signature_length_t; + +/** + * Encrypted private key data. Recommended to store in flash in this format. + * + * @note This struct has to match to one from the ROM code! This documentation is mostly taken from there. + */ +typedef struct esp_digital_signature_data { + /** + * RSA LENGTH register parameters + * (number of words in RSA key & operands, minus one). + * + * Max value 127 (for RSA 4096). + * + * This value must match the length field encrypted and stored in 'c', + * or invalid results will be returned. (The DS peripheral will + * always use the value in 'c', not this value, so an attacker can't + * alter the DS peripheral results this way, it will just truncate or + * extend the message and the resulting signature in software.) + * + * @note In IDF, the enum type length is the same as of type unsigned, so they can be used interchangably. + * See the ROM code for the original declaration of struct \c ets_ds_data_t. + */ + esp_digital_signature_length_t rsa_length; + + /** + * IV value used to encrypt 'c' + */ + uint8_t iv[ESP_DS_IV_LEN]; + + /** + * Encrypted Digital Signature parameters. Result of AES-CBC encryption + * of plaintext values. Includes an encrypted message digest. + */ + uint8_t c[ESP_DS_C_LEN]; +} esp_ds_data_t; + +/** Plaintext parameters used by Digital Signature. + * + * Not used for signing with DS peripheral, but can be encrypted + * in-device by calling esp_ds_encrypt_params() + * + * @note This documentation is mostly taken from the ROM code. + */ +typedef struct { + uint32_t Y[SOC_RSA_MAX_BIT_LEN / 32]; //!< RSA exponent + uint32_t M[SOC_RSA_MAX_BIT_LEN / 32]; //!< RSA modulus + uint32_t Rb[SOC_RSA_MAX_BIT_LEN / 32]; //!< RSA r inverse operand + uint32_t M_prime; //!< RSA M prime operand + esp_digital_signature_length_t length; //!< RSA length +} esp_ds_p_data_t; + +/** + * Sign the message. + * + * This function is a wrapper around \c esp_ds_finish_sign() and \c esp_ds_start_sign(), so do not use them + * in parallel. + * It blocks until the signing is finished and then returns the signature. + * + * @note This function locks the HMAC, SHA, AES and RSA components during its entire execution time. + * + * @param message the message to be signed; its length is determined by data->rsa_length + * @param data the encrypted signing key data (AES encrypted RSA key + IV) + * @param key_id the HMAC key ID determining the HMAC key of the HMAC which will be used to decrypt the + * signing key data + * @param signature the destination of the signature, should be (data->rsa_length + 1)*4 bytes long + * + * @return + * - ESP_OK if successful, the signature was written to the parameter \c signature. + * - ESP_ERR_INVALID_ARG if one of the parameters is NULL or data->rsa_length is too long or 0 + * - ESP_ERR_HW_CRYPTO_DS_HMAC_FAIL if there was an HMAC failure during retrieval of the decryption key + * - ESP_ERR_NO_MEM if there hasn't been enough memory to allocate the context object + * - ESP_ERR_HW_CRYPTO_DS_INVALID_KEY if there's a problem with passing the HMAC key to the DS component + * - ESP_ERR_HW_CRYPTO_DS_INVALID_DIGEST if the message digest didn't match; the signature is invalid. + * - ESP_ERR_HW_CRYPTO_DS_INVALID_PADDING if the message padding is incorrect, the signature can be read though + * since the message digest matches. + */ +esp_err_t esp_ds_sign(const void *message, + const esp_ds_data_t *data, + hmac_key_id_t key_id, + void *signature); + +/** + * Start the signing process. + * + * This function yields a context object which needs to be passed to \c esp_ds_finish_sign() to finish the signing + * process. + * + * @note This function locks the HMAC, SHA, AES and RSA components, so the user has to ensure to call + * \c esp_ds_finish_sign() in a timely manner. + * + * @param message the message to be signed; its length is determined by data->rsa_length + * @param data the encrypted signing key data (AES encrypted RSA key + IV) + * @param key_id the HMAC key ID determining the HMAC key of the HMAC which will be used to decrypt the + * signing key data + * @param esp_ds_ctx the context object which is needed for finishing the signing process later + * + * @return + * - ESP_OK if successful, the ds operation was started now and has to be finished with \c esp_ds_finish_sign() + * - ESP_ERR_INVALID_ARG if one of the parameters is NULL or data->rsa_length is too long or 0 + * - ESP_ERR_HW_CRYPTO_DS_HMAC_FAIL if there was an HMAC failure during retrieval of the decryption key + * - ESP_ERR_NO_MEM if there hasn't been enough memory to allocate the context object + * - ESP_ERR_HW_CRYPTO_DS_INVALID_KEY if there's a problem with passing the HMAC key to the DS component + */ +esp_err_t esp_ds_start_sign(const void *message, + const esp_ds_data_t *data, + hmac_key_id_t key_id, + esp_ds_context_t **esp_ds_ctx); + +/** + * Return true if the DS peripheral is busy, otherwise false. + * + * @note Only valid if \c esp_ds_start_sign() was called before. + */ +bool esp_ds_is_busy(void); + +/** + * Finish the signing process. + * + * @param signature the destination of the signature, should be (data->rsa_length + 1)*4 bytes long + * @param esp_ds_ctx the context object retreived by \c esp_ds_start_sign() + * + * @return + * - ESP_OK if successful, the ds operation has been finished and the result is written to signature. + * - ESP_ERR_INVALID_ARG if one of the parameters is NULL + * - ESP_ERR_HW_CRYPTO_DS_INVALID_DIGEST if the message digest didn't match; the signature is invalid. + * - ESP_ERR_HW_CRYPTO_DS_INVALID_PADDING if the message padding is incorrect, the signature can be read though + * since the message digest matches. + */ +esp_err_t esp_ds_finish_sign(void *signature, esp_ds_context_t *esp_ds_ctx); + +/** + * Encrypt the private key parameters. + * + * @param data Output buffer to store encrypted data, suitable for later use generating signatures. + * The allocated memory must be in internal memory and word aligned since it's filled by DMA. Both is asserted + * at run time. + * @param iv Pointer to 16 byte IV buffer, will be copied into 'data'. Should be randomly generated bytes each time. + * @param p_data Pointer to input plaintext key data. The expectation is this data will be deleted after this process + * is done and 'data' is stored. + * @param key Pointer to 32 bytes of key data. Type determined by key_type parameter. The expectation is the + * corresponding HMAC key will be stored to efuse and then permanently erased. + * + * @return + * - ESP_OK if successful, the ds operation has been finished and the result is written to signature. + * - ESP_ERR_INVALID_ARG if one of the parameters is NULL or p_data->rsa_length is too long + */ +esp_err_t esp_ds_encrypt_params(esp_ds_data_t *data, + const void *iv, + const esp_ds_p_data_t *p_data, + const void *key); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s3/esp_hmac.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s3/esp_hmac.h new file mode 100644 index 00000000000..101dce556b6 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s3/esp_hmac.h @@ -0,0 +1,84 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "esp_err.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The possible efuse keys for the HMAC peripheral + */ +typedef enum { + HMAC_KEY0 = 0, + HMAC_KEY1, + HMAC_KEY2, + HMAC_KEY3, + HMAC_KEY4, + HMAC_KEY5, + HMAC_KEY_MAX +} hmac_key_id_t; + +/** + * @brief + * Calculate the HMAC of a given message. + * + * Calculate the HMAC \c hmac of a given message \c message with length \c message_len. + * SHA256 is used for the calculation (fixed on ESP32S3). + * + * @note Uses the HMAC peripheral in "upstream" mode. + * + * @param key_id Determines which of the 6 key blocks in the efuses should be used for the HMAC calcuation. + * The corresponding purpose field of the key block in the efuse must be set to the HMAC upstream purpose value. + * @param message the message for which to calculate the HMAC + * @param message_len message length + * @param [out] hmac the hmac result; the buffer behind the provided pointer must be 32 bytes long + * + * @return + * * ESP_OK, if the calculation was successful, + * * ESP_ERR_INVALID_ARG if message or hmac is a nullptr or if key_id out of range + * * ESP_FAIL, if the hmac calculation failed + */ +esp_err_t esp_hmac_calculate(hmac_key_id_t key_id, + const void *message, + size_t message_len, + uint8_t *hmac); + +/** + * @brief Use HMAC peripheral in Downstream mode to re-enable the JTAG, if it is not permanently disabled by HW. + * In downstream mode, HMAC calculations performed by peripheral are used internally and not provided back to user. + * + * @param key_id Determines which of the 6 key blocks in the efuses should be used for the HMAC calculation. + * The corresponding purpose field of the key block in the efuse must be set to HMAC downstream purpose. + * + * @param token Pre calculated HMAC value of the 32-byte 0x00 using SHA-256 and the known private HMAC key. The key is already + * programmed to a eFuse key block. The key block number is provided as the first parameter to this function. + * + * @return + * * ESP_OK, if the calculation was successful, + * if the calculated HMAC value matches with provided token, + * JTAG will be re-enable otherwise JTAG will remain disabled. + * Return value does not indicate the JTAG status. + * * ESP_FAIL, if the hmac calculation failed or JTAG is permanently disabled by EFUSE_HARD_DIS_JTAG eFuse parameter. + * * ESP_ERR_INVALID_ARG, invalid input arguments + */ +esp_err_t esp_hmac_jtag_enable(hmac_key_id_t key_id, const uint8_t *token); + +/** + * @brief Disable the JTAG which might be enabled using the HMAC downstream mode. This function just clears the result generated + * by calling esp_hmac_jtag_enable() API. + * + * @return + * * ESP_OK return ESP_OK after writing the HMAC_SET_INVALIDATE_JTAG_REG with value 1. + */ +esp_err_t esp_hmac_jtag_disable(void); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s3/memprot.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s3/memprot.h index 7e47a8cfa33..948e0676680 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s3/memprot.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s3/memprot.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /* INTERNAL API diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s3/rtc.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s3/rtc.h index 296292e21db..3ab96b37872 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s3/rtc.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s3/rtc.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s3/spiram.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s3/spiram.h index 105a60543e0..067c3d27bf8 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s3/spiram.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/esp32s3/spiram.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef __ESP_SPIRAM_H @@ -78,7 +70,24 @@ size_t esp_spiram_get_size(void); */ void esp_spiram_writeback_cache(void); +/** + * @brief If SPI RAM(PSRAM) has been initialized + * + * @return + * - true SPI RAM has been initialized successfully + * - false SPI RAM hasn't been initialized or initialized failed + */ +bool esp_spiram_is_initialized(void); +/** + * @brief get psram CS IO + * + * This interface should be called after PSRAM is enabled, otherwise it will + * return an invalid value -1/0xff. + * + * @return psram CS IO or -1/0xff if psram not enabled + */ +uint8_t esp_spiram_get_cs_io(void); /** * @brief Reserve a pool of internal memory for specific DMA/internal allocations @@ -91,6 +100,15 @@ void esp_spiram_writeback_cache(void); */ esp_err_t esp_spiram_reserve_dma_pool(size_t size); +/** + * @brief If SPI RAM(PSRAM) has been initialized + * + * @return + * - true SPI RAM has been initialized successfully + * - false SPI RAM hasn't been initialized or initialized failed + */ +bool esp_spiram_is_initialized(void); + #if CONFIG_SPIRAM_FETCH_INSTRUCTIONS extern int _instruction_reserved_start, _instruction_reserved_end; diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/rtc_wdt.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/rtc_wdt.h index 7d13e6a4f75..97d1d8425bd 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/rtc_wdt.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/rtc_wdt.h @@ -1,16 +1,8 @@ -// Copyright 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. +/* + * SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /* Recommendation of using API RTC_WDT. 1) Setting and enabling rtc_wdt: diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/spinlock.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/spinlock.h index 66baa93066b..97cc9e514ab 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/spinlock.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/spinlock.h @@ -1,16 +1,8 @@ -// Copyright 2015-2019 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc_log.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc_log.h index ea2ecce8f80..64268433fb9 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc_log.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc_log.h @@ -1,16 +1,8 @@ -// Copyright 2016-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2016-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include "esp_rom_sys.h" diff --git a/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/private_include/regi2c_apll.h b/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/private_include/regi2c_apll.h index d63ceb1f48a..d62caa1daf7 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/private_include/regi2c_apll.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/private_include/regi2c_apll.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/private_include/regi2c_bbpll.h b/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/private_include/regi2c_bbpll.h index edc9938842d..e7423b1e6e3 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/private_include/regi2c_bbpll.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/private_include/regi2c_bbpll.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/private_include/regi2c_brownout.h b/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/private_include/regi2c_brownout.h index 0b8b618bba8..8073b72a27d 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/private_include/regi2c_brownout.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/private_include/regi2c_brownout.h @@ -1,16 +1,8 @@ -// Copyright 2020 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. +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/private_include/regi2c_saradc.h b/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/private_include/regi2c_saradc.h index 2345e0a5aae..388f9c6221a 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/private_include/regi2c_saradc.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/private_include/regi2c_saradc.h @@ -1,16 +1,8 @@ -// Copyright 2019-2020 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. +/* + * SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/private_include/regi2c_ulp.h b/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/private_include/regi2c_ulp.h index 4be3a499d29..43a8c0d41e7 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/private_include/regi2c_ulp.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/private_include/regi2c_ulp.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/regi2c_ctrl.h b/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/regi2c_ctrl.h index 51a0a22dcbb..741c0b1020b 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/regi2c_ctrl.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/regi2c_ctrl.h @@ -1,16 +1,8 @@ -// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/rtc_clk_common.h b/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/rtc_clk_common.h index d4dad103add..570c34c865c 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/rtc_clk_common.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/rtc_clk_common.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/spiram_psram.h b/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/spiram_psram.h index ea7908f0305..819bdc62038 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/spiram_psram.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/port/esp32s2/spiram_psram.h @@ -1,16 +1,8 @@ -// 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. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _PSRAM_H @@ -76,5 +68,11 @@ typedef enum { esp_err_t esp_spiram_wrap_set(spiram_wrap_mode_t mode); +/** + * @brief get psram CS IO + * + * @return psram CS IO + */ +uint8_t psram_get_cs_io(void); #endif diff --git a/tools/sdk/esp32s2/include/esp_ipc/include/esp_ipc.h b/tools/sdk/esp32s2/include/esp_ipc/include/esp_ipc.h index 477b3d0af4e..5e02c460bce 100644 --- a/tools/sdk/esp32s2/include/esp_ipc/include/esp_ipc.h +++ b/tools/sdk/esp32s2/include/esp_ipc/include/esp_ipc.h @@ -20,6 +20,9 @@ #ifdef __cplusplus extern "C" { #endif + +#if !defined(CONFIG_FREERTOS_UNICORE) || defined(CONFIG_APPTRACE_GCOV_ENABLE) + /** @cond */ typedef void (*esp_ipc_func_t)(void* arg); /** @endcond */ @@ -85,6 +88,7 @@ esp_err_t esp_ipc_call(uint32_t cpu_id, esp_ipc_func_t func, void* arg); */ esp_err_t esp_ipc_call_blocking(uint32_t cpu_id, esp_ipc_func_t func, void* arg); +#endif // not CONFIG_FREERTOS_UNICORE or CONFIG_APPTRACE_GCOV_ENABLE #ifdef __cplusplus } diff --git a/tools/sdk/esp32s2/include/esp_ipc/include/esp_ipc_isr.h b/tools/sdk/esp32s2/include/esp_ipc/include/esp_ipc_isr.h new file mode 100644 index 00000000000..7b6e060f1d5 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp_ipc/include/esp_ipc_isr.h @@ -0,0 +1,117 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "sdkconfig.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef CONFIG_ESP_IPC_ISR_ENABLE + +/** @cond */ +typedef void (*esp_ipc_isr_func_t)(void* arg); +/** @endcond */ + +/** + * @brief Initialize inter-processor call module which based on #4 high-interrupt. + * + * This function is called on CPU start and should not be called from the application. + * + * This function starts two tasks, one on each CPU. These tasks register + * #4 High-interrupt and after that, the tasks are deleted. + * The next API functions work with this functionality: + * esp_ipc_isr_asm_call + * esp_ipc_isr_asm_call_blocking + * They allow to run an asm function on other CPU. + */ +void esp_ipc_isr_init(void); + +/** + * @brief Execute an asm function on the other CPU (uses the #4 high-priority interrupt) + * + * @note In single-core mode, it is not available. + * This function calls the #4 high-priority interrupt on the other CPU. + * The given function is called in the context of the interrupt by CALLX0 command and + * operates with registers a2, a3, a4. + * + * @param[in] func Pointer to a function of type void func(void* arg) to be executed + * @param[in] arg Arbitrary argument of type void* to be passed into the function + */ +void esp_ipc_isr_asm_call(esp_ipc_isr_func_t func, void* arg); + +/** + * @brief Execute an asm function on the other CPU and blocks until it completes (uses the #4 high-priority interrupt) + * + * @note In single-core mode, it is not available. + * This function calls the #4 high-priority interrupt on the other CPU. + * The given function is called in the context of the interrupt by CALLX0 command. + * + * @param[in] func Pointer to a function of type void func(void* arg) to be executed + * @param[in] arg Arbitrary argument of type void* to be passed into the function + */ +void esp_ipc_isr_asm_call_blocking(esp_ipc_isr_func_t func, void* arg); + +/** + * @brief Stall the other CPU and the current CPU disables interrupts with level 3 and lower. + * + * @note In single-core mode, it is not available. + * This function calls the #4 high-priority interrupt on the other CPU. + * The esp_ipc_isr_finish_cmd() function is called on the other CPU in the context of the #4 high-priority interrupt. + * The esp_ipc_isr_finish_cmd is called by CALLX0 command. + * It is waiting for the end command. The command will be sent by esp_ipc_isr_release_other_cpu(). + * This function is used for DPORT workaround. + * + * This function blocks other CPU until the release call esp_ipc_isr_release_other_cpu(). + * + * This fucntion is used for the DPORT workaround: stall other cpu that this cpu is pending to access dport register start. + */ +void esp_ipc_isr_stall_other_cpu(void); + +/** + * @brief Release the other CPU + * + * @note In single-core mode, it is not available. + * This function will send the end command to release the stall other CPU. + * This function is used for DPORT workaround: stall other cpu that this cpu is pending to access dport register end. + * + */ +void esp_ipc_isr_release_other_cpu(void); + +/** + * @brief Pause stall the other CPU + */ +void esp_ipc_isr_stall_pause(void); + +/** + * @brief Abort stall the other CPU + * + * This routine does not stop the stall routines in any way that is recoverable. + * Please only call in case of panic(). + * Used in panic code: the enter_critical stuff may be messed up so we just stop everything without checking the mux. + */ +void esp_ipc_isr_stall_abort(void); + +/** + * @brief Resume stall the other CPU + */ +void esp_ipc_isr_stall_resume(void); + +#else // not CONFIG_ESP_IPC_ISR_ENABLE + +#define esp_ipc_isr_stall_other_cpu() +#define esp_ipc_isr_release_other_cpu() +#define esp_ipc_isr_stall_pause() +#define esp_ipc_isr_stall_abort() +#define esp_ipc_isr_stall_resume() + +#endif // CONFIG_ESP_IPC_ISR_ENABLE + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32s2/include/esp_lcd/include/esp_lcd_panel_io.h b/tools/sdk/esp32s2/include/esp_lcd/include/esp_lcd_panel_io.h index c362180f53e..eebcabf42b4 100644 --- a/tools/sdk/esp32s2/include/esp_lcd/include/esp_lcd_panel_io.h +++ b/tools/sdk/esp32s2/include/esp_lcd/include/esp_lcd_panel_io.h @@ -9,6 +9,7 @@ #include "esp_err.h" #include "esp_lcd_types.h" #include "soc/soc_caps.h" +#include "hal/lcd_types.h" #ifdef __cplusplus extern "C" { @@ -28,14 +29,13 @@ typedef struct esp_lcd_i80_bus_t *esp_lcd_i80_bus_handle_t; /*!< Type of LCD i * * @param[in] io LCD panel IO handle, which is created by other factory API like `esp_lcd_new_panel_io_spi()` * @param[in] lcd_cmd The specific LCD command - * @param[in] lcd_cmd_bits Length of LCD command, in bits (e.g. 8 bits or 16 bits) * @param[in] param Buffer that holds the command specific parameters, set to NULL if no parameter is needed for the command * @param[in] param_size Size of `param` in memory, in bytes, set to zero if no parameter is needed for the command * @return * - ESP_ERR_INVALID_ARG if parameter is invalid * - ESP_OK on success */ -esp_err_t esp_lcd_panel_io_tx_param(esp_lcd_panel_io_handle_t io, int lcd_cmd, int lcd_cmd_bits, const void *param, size_t param_size); +esp_err_t esp_lcd_panel_io_tx_param(esp_lcd_panel_io_handle_t io, int lcd_cmd, const void *param, size_t param_size); /** * @brief Transmit LCD RGB data @@ -47,14 +47,13 @@ esp_err_t esp_lcd_panel_io_tx_param(esp_lcd_panel_io_handle_t io, int lcd_cmd, i * * @param[in] io LCD panel IO handle, which is created by factory API like `esp_lcd_new_panel_io_spi()` * @param[in] lcd_cmd The specific LCD command - * @param[in] lcd_cmd_bits Length of LCD command, in bits (e.g. 8 bits or 16 bits) * @param[in] color Buffer that holds the RGB color data * @param[in] color_size Size of `color` in memory, in bytes * @return * - ESP_ERR_INVALID_ARG if parameter is invalid * - ESP_OK on success */ -esp_err_t esp_lcd_panel_io_tx_color(esp_lcd_panel_io_handle_t io, int lcd_cmd, int lcd_cmd_bits, const void *color, size_t color_size); +esp_err_t esp_lcd_panel_io_tx_color(esp_lcd_panel_io_handle_t io, int lcd_cmd, const void *color, size_t color_size); /** * @brief Destory LCD panel IO handle (deinitialize panel and free all corresponding resource) @@ -76,10 +75,13 @@ typedef struct { unsigned int pclk_hz; /*!< Frequency of pixel clock */ size_t trans_queue_depth; /*!< Size of internal transaction queue */ bool (*on_color_trans_done)(esp_lcd_panel_io_handle_t panel_io, void *user_data, void *event_data); /*!< Callback, invoked when color data transfer has finished */ - void *user_data; /*!< User private data, passed directly to on_trans_frame_done's user_data */ + void *user_data; /*!< User private data, passed directly to on_trans_frame_done's user_data */ + int lcd_cmd_bits; /*!< Bit-width of LCD command */ + int lcd_param_bits; /*!< Bit-width of LCD parameter */ struct { unsigned int dc_as_cmd_phase: 1; /*!< D/C line value is encoded into SPI transaction command phase */ unsigned int dc_low_on_data: 1; /*!< If this flag is enabled, DC line = 0 means transfer data, DC line = 1 means transfer command; vice versa */ + unsigned int octal_mode: 1; /*!< transmit with octal mode (8 data lines), this mode is used to simulate Intel 8080 timing */ } flags; } esp_lcd_panel_io_spi_config_t; @@ -102,6 +104,8 @@ typedef struct { void *user_data; /*!< User private data, passed directly to on_trans_frame_done's user_data */ size_t control_phase_bytes; /*!< I2C LCD panel will encode control information (e.g. D/C seclection) into control phase, in several bytes */ unsigned int dc_bit_offset; /*!< Offset of the D/C selection bit in control phase */ + int lcd_cmd_bits; /*!< Bit-width of LCD command */ + int lcd_param_bits; /*!< Bit-width of LCD parameter */ struct { unsigned int dc_low_on_data: 1; /*!< If this flag is enabled, DC line = 0 means transfer data, DC line = 1 means transfer command; vice versa */ } flags; @@ -127,8 +131,9 @@ esp_err_t esp_lcd_new_panel_io_i2c(esp_lcd_i2c_bus_handle_t bus, const esp_lcd_p typedef struct { int dc_gpio_num; /*!< GPIO used for D/C line */ int wr_gpio_num; /*!< GPIO used for WR line */ + lcd_clock_source_t clk_src; /*!< Clock source for the I80 LCD peripheral */ int data_gpio_nums[SOC_LCD_I80_BUS_WIDTH]; /*!< GPIOs used for data lines */ - size_t data_width; /*!< Number of data lines, 8 or 16 */ + size_t bus_width; /*!< Number of data lines, 8 or 16 */ size_t max_transfer_bytes; /*!< Maximum transfer size, this determines the length of internal DMA link */ } esp_lcd_i80_bus_config_t; @@ -160,11 +165,13 @@ esp_err_t esp_lcd_del_i80_bus(esp_lcd_i80_bus_handle_t bus); * @brief Panel IO configuration structure, for intel 8080 interface */ typedef struct { - int cs_gpio_num; /*!< GPIO used for CS line */ + int cs_gpio_num; /*!< GPIO used for CS line, set to -1 will declaim exclusively use of I80 bus */ unsigned int pclk_hz; /*!< Frequency of pixel clock */ size_t trans_queue_depth; /*!< Transaction queue size, larger queue, higher throughput */ bool (*on_color_trans_done)(esp_lcd_panel_io_handle_t panel_io, void *user_data, void *event_data); /*!< Callback, invoked when color data was tranferred done */ - void *user_data; /*!< User private data, passed directly to on_trans_done's user_data */ + void *user_data; /*!< User private data, passed directly to on_trans_done's user_data */ + int lcd_cmd_bits; /*!< Bit-width of LCD command */ + int lcd_param_bits; /*!< Bit-width of LCD parameter */ struct { unsigned int dc_idle_level: 1; /*!< Level of DC line in IDLE phase */ unsigned int dc_cmd_level: 1; /*!< Level of DC line in CMD phase */ @@ -172,7 +179,7 @@ typedef struct { unsigned int dc_data_level: 1; /*!< Level of DC line in DATA phase */ } dc_levels; /*!< Each i80 device might have its own D/C control logic */ struct { - unsigned int invert_cs: 1; /*!< Whether to invert the CS line */ + unsigned int cs_active_high: 1; /*!< If set, a high level of CS line will select the device, otherwise, CS line is low level active */ unsigned int reverse_color_bits: 1; /*!< Reverse the data bits, D[N:0] -> D[0:N] */ unsigned int swap_color_bytes: 1; /*!< Swap adjacent two color bytes */ unsigned int pclk_active_neg: 1; /*!< The display will write data lines when there's a falling edge on WR signal (a.k.a the PCLK) */ diff --git a/tools/sdk/esp32s2/include/esp_lcd/include/esp_lcd_panel_rgb.h b/tools/sdk/esp32s2/include/esp_lcd/include/esp_lcd_panel_rgb.h index 0847e84bd21..2ddd2b6b9a6 100644 --- a/tools/sdk/esp32s2/include/esp_lcd/include/esp_lcd_panel_rgb.h +++ b/tools/sdk/esp32s2/include/esp_lcd/include/esp_lcd_panel_rgb.h @@ -9,6 +9,7 @@ #include "esp_err.h" #include "esp_lcd_types.h" #include "soc/soc_caps.h" +#include "hal/lcd_types.h" #ifdef __cplusplus extern "C" { @@ -41,6 +42,7 @@ typedef struct { * @brief LCD RGB panel configuration structure */ typedef struct { + lcd_clock_source_t clk_src; /*!< Clock source for the RGB LCD peripheral */ esp_lcd_rgb_timing_t timings; /*!< RGB timing parameters */ size_t data_width; /*!< Number of data lines */ int hsync_gpio_num; /*!< GPIO used for HSYNC signal */ @@ -54,6 +56,7 @@ typedef struct { struct { unsigned int disp_active_low: 1; /*!< If this flag is enabled, a low level of display control signal can turn the screen on; vice versa */ unsigned int relax_on_idle: 1; /*!< If this flag is enabled, the host won't refresh the LCD if nothing changed in host's frame buffer (this is usefull for LCD with built-in GRAM) */ + unsigned int fb_in_psram: 1; /*!< If this flag is enabled, the frame buffer will be allocated from PSRAM preferentially */ } flags; } esp_lcd_rgb_panel_config_t; diff --git a/tools/sdk/esp32s2/include/esp_lcd/include/esp_lcd_panel_vendor.h b/tools/sdk/esp32s2/include/esp_lcd/include/esp_lcd_panel_vendor.h index ac98cc3913d..dde8be68d3b 100644 --- a/tools/sdk/esp32s2/include/esp_lcd/include/esp_lcd_panel_vendor.h +++ b/tools/sdk/esp32s2/include/esp_lcd/include/esp_lcd_panel_vendor.h @@ -39,6 +39,19 @@ typedef struct { */ esp_err_t esp_lcd_new_panel_st7789(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config, esp_lcd_panel_handle_t *ret_panel); +/** + * @brief Create LCD panel for model NT35510 + * + * @param[in] io LCD panel IO handle + * @param[in] panel_dev_config general panel device configuration + * @param[out] ret_panel Returned LCD panel handle + * @return + * - ESP_ERR_INVALID_ARG if parameter is invalid + * - ESP_ERR_NO_MEM if out of memory + * - ESP_OK on success + */ +esp_err_t esp_lcd_new_panel_nt35510(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config, esp_lcd_panel_handle_t *ret_panel); + /** * @brief Create LCD panel for model SSD1306 * diff --git a/tools/sdk/esp32s2/include/esp_lcd/interface/esp_lcd_panel_io_interface.h b/tools/sdk/esp32s2/include/esp_lcd/interface/esp_lcd_panel_io_interface.h index b6b85564cd5..2faa6fab268 100644 --- a/tools/sdk/esp32s2/include/esp_lcd/interface/esp_lcd_panel_io_interface.h +++ b/tools/sdk/esp32s2/include/esp_lcd/interface/esp_lcd_panel_io_interface.h @@ -25,14 +25,13 @@ struct esp_lcd_panel_io_t { * * @param[in] io LCD panel IO handle, which is created by other factory API like `esp_lcd_new_panel_io_spi()` * @param[in] lcd_cmd The specific LCD command - * @param[in] lcd_cmd_bits Length of LCD command, in bits (e.g. 8 bits or 16 bits) * @param[in] param Buffer that holds the command specific parameters, set to NULL if no parameter is needed for the command * @param[in] param_size Size of `param` in memory, in bytes, set to zero if no parameter is needed for the command * @return * - ESP_ERR_INVALID_ARG if parameter is invalid * - ESP_OK on success */ - esp_err_t (*tx_param)(esp_lcd_panel_io_t *io, int lcd_cmd, int lcd_cmd_bits, const void *param, size_t param_size); + esp_err_t (*tx_param)(esp_lcd_panel_io_t *io, int lcd_cmd, const void *param, size_t param_size); /** * @brief Transmit LCD RGB data @@ -41,14 +40,13 @@ struct esp_lcd_panel_io_t { * * @param[in] io LCD panel IO handle, which is created by other factory API like `esp_lcd_new_panel_io_spi()` * @param[in] lcd_cmd The specific LCD command - * @param[in] lcd_cmd_bits Length of LCD command, in bits (e.g. 8 bits or 16 bits) * @param[in] color Buffer that holds the RGB color data * @param[in] color_size Size of `color` in memory, in bytes * @return * - ESP_ERR_INVALID_ARG if parameter is invalid * - ESP_OK on success */ - esp_err_t (*tx_color)(esp_lcd_panel_io_t *io, int lcd_cmd, int lcd_cmd_bits, const void *color, size_t color_size); + esp_err_t (*tx_color)(esp_lcd_panel_io_t *io, int lcd_cmd, const void *color, size_t color_size); /** * @brief Destory LCD panel IO handle (deinitialize all and free resource) diff --git a/tools/sdk/esp32s2/include/esp_littlefs/src/littlefs/lfs.h b/tools/sdk/esp32s2/include/esp_littlefs/src/littlefs/lfs.h index 35bbbabfa7b..ad491627fe1 100644 --- a/tools/sdk/esp32s2/include/esp_littlefs/src/littlefs/lfs.h +++ b/tools/sdk/esp32s2/include/esp_littlefs/src/littlefs/lfs.h @@ -9,6 +9,7 @@ #include #include +#include "lfs_util.h" #ifdef __cplusplus extern "C" @@ -21,7 +22,7 @@ extern "C" // Software library version // Major (top-nibble), incremented on backwards incompatible changes // Minor (bottom-nibble), incremented on feature additions -#define LFS_VERSION 0x00020002 +#define LFS_VERSION 0x00020004 #define LFS_VERSION_MAJOR (0xffff & (LFS_VERSION >> 16)) #define LFS_VERSION_MINOR (0xffff & (LFS_VERSION >> 0)) @@ -123,20 +124,25 @@ enum lfs_type { enum lfs_open_flags { // open flags LFS_O_RDONLY = 1, // Open a file as read only +#ifndef LFS_READONLY LFS_O_WRONLY = 2, // Open a file as write only LFS_O_RDWR = 3, // Open a file as read and write LFS_O_CREAT = 0x0100, // Create a file if it does not exist LFS_O_EXCL = 0x0200, // Fail if a file already exists LFS_O_TRUNC = 0x0400, // Truncate the existing file to zero size LFS_O_APPEND = 0x0800, // Move to end of file on every write +#endif // internally used flags +#ifndef LFS_READONLY LFS_F_DIRTY = 0x010000, // File does not match storage LFS_F_WRITING = 0x020000, // File has been written since last flush +#endif LFS_F_READING = 0x040000, // File has been read since last flush - LFS_F_ERRED = 0x080000, // An error occured during write +#ifndef LFS_READONLY + LFS_F_ERRED = 0x080000, // An error occurred during write +#endif LFS_F_INLINE = 0x100000, // Currently inlined in directory entry - LFS_F_OPENED = 0x200000, // File has been opened }; // File seek flags @@ -174,6 +180,16 @@ struct lfs_config { // are propogated to the user. int (*sync)(const struct lfs_config *c); +#ifdef LFS_THREADSAFE + // Lock the underlying block device. Negative error codes + // are propogated to the user. + int (*lock)(const struct lfs_config *c); + + // Unlock the underlying block device. Negative error codes + // are propogated to the user. + int (*unlock)(const struct lfs_config *c); +#endif + // Minimum size of a block read. All read operations will be a // multiple of this value. lfs_size_t read_size; @@ -191,7 +207,7 @@ struct lfs_config { // Number of erasable blocks on the device. lfs_size_t block_count; - // Number of erase cycles before littlefs evicts metadata logs and moves + // Number of erase cycles before littlefs evicts metadata logs and moves // the metadata to another block. Suggested values are in the // range 100-1000, with large values having better performance at the cost // of less consistent wear distribution. @@ -240,6 +256,12 @@ struct lfs_config { // larger attributes size but must be <= LFS_ATTR_MAX. Defaults to // LFS_ATTR_MAX when zero. lfs_size_t attr_max; + + // Optional upper limit on total space given to metadata pairs in bytes. On + // devices with large blocks (e.g. 128kB) setting this to a low size (2-8kB) + // can help bound the metadata compaction time. Must be <= block_size. + // Defaults to block_size when zero. + lfs_size_t metadata_max; }; // File info structure @@ -399,6 +421,7 @@ typedef struct lfs { /// Filesystem functions /// +#ifndef LFS_READONLY // Format a block device with the littlefs // // Requires a littlefs object and config struct. This clobbers the littlefs @@ -407,6 +430,7 @@ typedef struct lfs { // // Returns a negative error code on failure. int lfs_format(lfs_t *lfs, const struct lfs_config *config); +#endif // Mounts a littlefs // @@ -426,12 +450,15 @@ int lfs_unmount(lfs_t *lfs); /// General operations /// +#ifndef LFS_READONLY // Removes a file or directory // // If removing a directory, the directory must be empty. // Returns a negative error code on failure. int lfs_remove(lfs_t *lfs, const char *path); +#endif +#ifndef LFS_READONLY // Rename or move a file or directory // // If the destination exists, it must match the source in type. @@ -439,6 +466,7 @@ int lfs_remove(lfs_t *lfs, const char *path); // // Returns a negative error code on failure. int lfs_rename(lfs_t *lfs, const char *oldpath, const char *newpath); +#endif // Find info about a file or directory // @@ -461,6 +489,7 @@ int lfs_stat(lfs_t *lfs, const char *path, struct lfs_info *info); lfs_ssize_t lfs_getattr(lfs_t *lfs, const char *path, uint8_t type, void *buffer, lfs_size_t size); +#ifndef LFS_READONLY // Set custom attributes // // Custom attributes are uniquely identified by an 8-bit type and limited @@ -470,13 +499,16 @@ lfs_ssize_t lfs_getattr(lfs_t *lfs, const char *path, // Returns a negative error code on failure. int lfs_setattr(lfs_t *lfs, const char *path, uint8_t type, const void *buffer, lfs_size_t size); +#endif +#ifndef LFS_READONLY // Removes a custom attribute // // If an attribute is not found, nothing happens. // // Returns a negative error code on failure. int lfs_removeattr(lfs_t *lfs, const char *path, uint8_t type); +#endif /// File operations /// @@ -525,6 +557,7 @@ int lfs_file_sync(lfs_t *lfs, lfs_file_t *file); lfs_ssize_t lfs_file_read(lfs_t *lfs, lfs_file_t *file, void *buffer, lfs_size_t size); +#ifndef LFS_READONLY // Write data to file // // Takes a buffer and size indicating the data to write. The file will not @@ -533,6 +566,7 @@ lfs_ssize_t lfs_file_read(lfs_t *lfs, lfs_file_t *file, // Returns the number of bytes written, or a negative error code on failure. lfs_ssize_t lfs_file_write(lfs_t *lfs, lfs_file_t *file, const void *buffer, lfs_size_t size); +#endif // Change the position of the file // @@ -541,10 +575,12 @@ lfs_ssize_t lfs_file_write(lfs_t *lfs, lfs_file_t *file, lfs_soff_t lfs_file_seek(lfs_t *lfs, lfs_file_t *file, lfs_soff_t off, int whence); +#ifndef LFS_READONLY // Truncates the size of the file to the specified size // // Returns a negative error code on failure. int lfs_file_truncate(lfs_t *lfs, lfs_file_t *file, lfs_off_t size); +#endif // Return the position of the file // @@ -567,10 +603,12 @@ lfs_soff_t lfs_file_size(lfs_t *lfs, lfs_file_t *file); /// Directory operations /// +#ifndef LFS_READONLY // Create a directory // // Returns a negative error code on failure. int lfs_mkdir(lfs_t *lfs, const char *path); +#endif // Open a directory // @@ -632,6 +670,7 @@ lfs_ssize_t lfs_fs_size(lfs_t *lfs); // Returns a negative error code on failure. int lfs_fs_traverse(lfs_t *lfs, int (*cb)(void*, lfs_block_t), void *data); +#ifndef LFS_READONLY #ifdef LFS_MIGRATE // Attempts to migrate a previous version of littlefs // @@ -646,6 +685,7 @@ int lfs_fs_traverse(lfs_t *lfs, int (*cb)(void*, lfs_block_t), void *data); // Returns a negative error code on failure. int lfs_migrate(lfs_t *lfs, const struct lfs_config *cfg); #endif +#endif #ifdef __cplusplus diff --git a/tools/sdk/esp32s2/include/esp_littlefs/src/littlefs/lfs_util.h b/tools/sdk/esp32s2/include/esp_littlefs/src/littlefs/lfs_util.h index dbb4c5ba866..fc1b0c2ae86 100644 --- a/tools/sdk/esp32s2/include/esp_littlefs/src/littlefs/lfs_util.h +++ b/tools/sdk/esp32s2/include/esp_littlefs/src/littlefs/lfs_util.h @@ -49,6 +49,7 @@ extern "C" // code footprint // Logging functions +#ifndef LFS_TRACE #ifdef LFS_YES_TRACE #define LFS_TRACE_(fmt, ...) \ printf("%s:%d:trace: " fmt "%s\n", __FILE__, __LINE__, __VA_ARGS__) @@ -56,7 +57,9 @@ extern "C" #else #define LFS_TRACE(...) #endif +#endif +#ifndef LFS_DEBUG #ifndef LFS_NO_DEBUG #define LFS_DEBUG_(fmt, ...) \ printf("%s:%d:debug: " fmt "%s\n", __FILE__, __LINE__, __VA_ARGS__) @@ -64,7 +67,9 @@ extern "C" #else #define LFS_DEBUG(...) #endif +#endif +#ifndef LFS_WARN #ifndef LFS_NO_WARN #define LFS_WARN_(fmt, ...) \ printf("%s:%d:warn: " fmt "%s\n", __FILE__, __LINE__, __VA_ARGS__) @@ -72,7 +77,9 @@ extern "C" #else #define LFS_WARN(...) #endif +#endif +#ifndef LFS_ERROR #ifndef LFS_NO_ERROR #define LFS_ERROR_(fmt, ...) \ printf("%s:%d:error: " fmt "%s\n", __FILE__, __LINE__, __VA_ARGS__) @@ -80,13 +87,16 @@ extern "C" #else #define LFS_ERROR(...) #endif +#endif // Runtime assertions +#ifndef LFS_ASSERT #ifndef LFS_NO_ASSERT #define LFS_ASSERT(test) assert(test) #else #define LFS_ASSERT(test) #endif +#endif // Builtin functions, these may be replaced by more efficient diff --git a/tools/sdk/esp32s2/include/esp_local_ctrl/include/esp_local_ctrl.h b/tools/sdk/esp32s2/include/esp_local_ctrl/include/esp_local_ctrl.h index 9f4f89daa31..8322412eb3a 100644 --- a/tools/sdk/esp32s2/include/esp_local_ctrl/include/esp_local_ctrl.h +++ b/tools/sdk/esp32s2/include/esp_local_ctrl/include/esp_local_ctrl.h @@ -228,6 +228,37 @@ typedef union { esp_local_ctrl_transport_config_httpd_t *httpd; } esp_local_ctrl_transport_config_t; +/** + * @brief Security types for esp_local_control + */ +typedef enum esp_local_ctrl_proto_sec { + PROTOCOM_SEC0 = 0, + PROTOCOM_SEC1, + PROTOCOM_SEC_CUSTOM, +} esp_local_ctrl_proto_sec_t; + +/** + * Protocom security configs + */ +typedef struct esp_local_ctrl_proto_sec_cfg { + /** + * This sets protocom security version, sec0/sec1 or custom + * If custom, user must provide handle via `proto_sec_custom_handle` below + */ + esp_local_ctrl_proto_sec_t version; + + /** + * Custom security handle if security is set custom via `proto_sec` above + * This handle must follow `protocomm_security_t` signature + */ + void *custom_handle; + + /** + * Proof of possession to be used for local control. Could be NULL. + */ + void *pop; +} esp_local_ctrl_proto_sec_cfg_t; + /** * @brief Configuration structure to pass to `esp_local_ctrl_start()` */ @@ -242,6 +273,11 @@ typedef struct esp_local_ctrl_config { */ esp_local_ctrl_transport_config_t transport_config; + /** + * Security version and POP + */ + esp_local_ctrl_proto_sec_cfg_t proto_sec; + /** * Register handlers for responding to get/set requests on properties */ diff --git a/tools/sdk/esp32s2/include/esp_netif/include/esp_netif_ppp.h b/tools/sdk/esp32s2/include/esp_netif/include/esp_netif_ppp.h index 413910c4331..159388e80ea 100644 --- a/tools/sdk/esp32s2/include/esp_netif/include/esp_netif_ppp.h +++ b/tools/sdk/esp32s2/include/esp_netif/include/esp_netif_ppp.h @@ -38,6 +38,11 @@ typedef struct esp_netif_ppp_config { */ #define NETIF_PP_PHASE_OFFSET (0x100) +/** @brief event id offset for internal errors + * + */ +#define NETIF_PPP_INTERNAL_ERR_OFFSET (0x200) + /** @brief event ids for different PPP related events * */ @@ -68,6 +73,7 @@ typedef enum { NETIF_PPP_PHASE_RUNNING = NETIF_PP_PHASE_OFFSET + 10, NETIF_PPP_PHASE_TERMINATE = NETIF_PP_PHASE_OFFSET + 11, NETIF_PPP_PHASE_DISCONNECT = NETIF_PP_PHASE_OFFSET + 12, + NETIF_PPP_CONNECT_FAILED = NETIF_PPP_INTERNAL_ERR_OFFSET + 0, } esp_netif_ppp_status_event_t; /** @brief definitions of different authorisation types @@ -89,7 +95,8 @@ typedef enum { * @param[in] user User name * @param[in] passwd Password * - * @return ESP_OK on success, ESP_ERR_ESP_NETIF_INVALID_PARAMS if netif null or not PPP + * @return ESP_OK on success, + * ESP_ERR_ESP_NETIF_INVALID_PARAMS if the supplied netif is not of PPP type, or netif is null */ esp_err_t esp_netif_ppp_set_auth(esp_netif_t *netif, esp_netif_auth_type_t authtype, const char *user, const char *passwd); @@ -98,10 +105,20 @@ esp_err_t esp_netif_ppp_set_auth(esp_netif_t *netif, esp_netif_auth_type_t autht * @param[in] esp_netif Handle to esp-netif instance * @param[in] config Pointer to PPP netif configuration structure * - * @return ESP_OK on success, ESP_ERR_ESP_NETIF_INVALID_PARAMS if netif null or not PPP + * @return ESP_OK on success, + * ESP_ERR_ESP_NETIF_INVALID_PARAMS if the supplied netif is not of PPP type, or netif is null */ esp_err_t esp_netif_ppp_set_params(esp_netif_t *netif, const esp_netif_ppp_config_t *config); +/** @brief Gets parameters configured in the supplied esp-netif. + * + * @param[in] esp_netif Handle to esp-netif instance + * @param[out] config Pointer to PPP netif configuration structure + * + * @return ESP_OK on success, + * ESP_ERR_ESP_NETIF_INVALID_PARAMS if the supplied netif is not of PPP type, or netif is null + */ +esp_err_t esp_netif_ppp_get_params(esp_netif_t *netif, esp_netif_ppp_config_t *config); #ifdef __cplusplus } diff --git a/tools/sdk/esp32s2/include/esp_phy/include/phy.h b/tools/sdk/esp32s2/include/esp_phy/include/phy.h index c0eadbf2ba4..51b972bb6ca 100644 --- a/tools/sdk/esp32s2/include/esp_phy/include/phy.h +++ b/tools/sdk/esp32s2/include/esp_phy/include/phy.h @@ -69,7 +69,7 @@ void phy_wakeup_init(void); */ void phy_close_rf(void); -#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2 +#if !CONFIG_IDF_TARGET_ESP32 /** * @brief Disable PHY temperature sensor. */ diff --git a/tools/sdk/esp32s2/include/esp_rom/include/esp32/rom/spi_flash.h b/tools/sdk/esp32s2/include/esp_rom/include/esp32/rom/spi_flash.h index 6d162343f34..500ba300cbb 100644 --- a/tools/sdk/esp32s2/include/esp_rom/include/esp32/rom/spi_flash.h +++ b/tools/sdk/esp32s2/include/esp_rom/include/esp32/rom/spi_flash.h @@ -260,7 +260,7 @@ esp_rom_spiflash_result_t esp_rom_spiflash_read_status(esp_rom_spiflash_chip_t * esp_rom_spiflash_result_t esp_rom_spiflash_read_statushigh(esp_rom_spiflash_chip_t *spi, uint32_t *status); /** - * @brief Write status to Falsh status register. + * @brief Write status to Flash status register. * Please do not call this function in SDK. * * @param esp_rom_spiflash_chip_t *spi : The information for Flash, which is exported from ld file. diff --git a/tools/sdk/esp32s2/include/esp_rom/include/esp32c3/rom/newlib.h b/tools/sdk/esp32s2/include/esp_rom/include/esp32c3/rom/newlib.h deleted file mode 100644 index a852bdb7f5b..00000000000 --- a/tools/sdk/esp32s2/include/esp_rom/include/esp32c3/rom/newlib.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2020 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 -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Global variables used by newlib in ROM - - Note that any of these symbols which are used by both ROM & IDF will have duplicate copies - in each "side" of the memory. However they're all pointers, and the pointers will be to the same - thing, so it's not a big memory waste and functionality is the same. - - Some variables which look like they should be here, but aren't: - - - __sf_fake_stdin, __sf_fake_stdout, __sf_fake_stderr - These are defined in ROM because ROM includes findfp.c, - but only used if _REENT_INIT or _REENT_INIT_PTR are ever called and ROM doesn't use these macros anywhere unless - printf() or similar is called without initializing reent first. ESP-IDF sets up its own minimal reent structures. - - - __lock___sinit_recursive_mutex, etc. - these are combined into common_recursive_mutex & common_mutex to save space -*/ -typedef struct { - _LOCK_T common_recursive_mutex; - _LOCK_T common_mutex; - struct _reent *global_reent; -} esp_rom_newlib_global_data_t; - -/* Called from IDF newlib component setup - to initialize common data shared between ROM and IDF -*/ -void esp_rom_newlib_init_global_data(const esp_rom_newlib_global_data_t *data); - -#ifdef __cplusplus -} -#endif diff --git a/tools/sdk/esp32s2/include/esp_rom/include/esp32c3/rom/rtc.h b/tools/sdk/esp32s2/include/esp_rom/include/esp32c3/rom/rtc.h index 76ece7e8194..2a7f6cb6140 100644 --- a/tools/sdk/esp32s2/include/esp_rom/include/esp32c3/rom/rtc.h +++ b/tools/sdk/esp32s2/include/esp_rom/include/esp32c3/rom/rtc.h @@ -85,8 +85,7 @@ typedef enum { NO_MEAN = 0, POWERON_RESET = 1, /**<1, Vbat power on reset*/ RTC_SW_SYS_RESET = 3, /**<3, Software reset digital core*/ - DEEPSLEEP_RESET = 5, /**<3, Deep Sleep reset digital core*/ - SDIO_RESET = 6, /**<6, Reset by SLC module, reset digital core*/ + DEEPSLEEP_RESET = 5, /**<5, Deep Sleep reset digital core*/ TG0WDT_SYS_RESET = 7, /**<7, Timer Group0 Watch dog reset digital core*/ TG1WDT_SYS_RESET = 8, /**<8, Timer Group1 Watch dog reset digital core*/ RTCWDT_SYS_RESET = 9, /**<9, RTC Watch dog Reset digital core*/ @@ -96,8 +95,13 @@ typedef enum { RTCWDT_CPU_RESET = 13, /**<13, RTC Watch dog Reset CPU*/ RTCWDT_BROWN_OUT_RESET = 15, /**<15, Reset when the vdd voltage is not stable*/ RTCWDT_RTC_RESET = 16, /**<16, RTC Watch dog reset digital core and rtc module*/ - TG1WDT_CPU_RESET = 17, /**<11, Time Group1 reset CPU*/ - SUPER_WDT_RESET = 18, /**<11, super watchdog reset digital core and rtc module*/ + TG1WDT_CPU_RESET = 17, /**<17, Time Group1 reset CPU*/ + SUPER_WDT_RESET = 18, /**<18, super watchdog reset digital core and rtc module*/ + GLITCH_RTC_RESET = 19, /**<19, glitch reset digital core and rtc module*/ + EFUSE_RESET = 20, /**<20, efuse reset digital core*/ + USB_UART_CHIP_RESET = 21, /**<21, usb uart reset digital core */ + USB_JTAG_CHIP_RESET = 22, /**<22, usb jtag reset digital core */ + POWER_GLITCH_RESET = 23, /**<23, power glitch reset digital core and rtc module*/ } RESET_REASON; // Check if the reset reason defined in ROM is compatible with soc/reset_reasons.h @@ -112,7 +116,13 @@ _Static_assert((soc_reset_reason_t)RTC_SW_CPU_RESET == RESET_REASON_CPU0_SW, "RT _Static_assert((soc_reset_reason_t)RTCWDT_CPU_RESET == RESET_REASON_CPU0_RTC_WDT, "RTCWDT_CPU_RESET != RESET_REASON_CPU0_RTC_WDT"); _Static_assert((soc_reset_reason_t)RTCWDT_BROWN_OUT_RESET == RESET_REASON_SYS_BROWN_OUT, "RTCWDT_BROWN_OUT_RESET != RESET_REASON_SYS_BROWN_OUT"); _Static_assert((soc_reset_reason_t)RTCWDT_RTC_RESET == RESET_REASON_SYS_RTC_WDT, "RTCWDT_RTC_RESET != RESET_REASON_SYS_RTC_WDT"); +_Static_assert((soc_reset_reason_t)TG1WDT_CPU_RESET == RESET_REASON_CPU0_MWDT1, "TG1WDT_CPU_RESET != RESET_REASON_CPU0_MWDT1"); _Static_assert((soc_reset_reason_t)SUPER_WDT_RESET == RESET_REASON_SYS_SUPER_WDT, "SUPER_WDT_RESET != RESET_REASON_SYS_SUPER_WDT"); +_Static_assert((soc_reset_reason_t)GLITCH_RTC_RESET == RESET_REASON_SYS_CLK_GLITCH, "GLITCH_RTC_RESET != RESET_REASON_SYS_CLK_GLITCH"); +_Static_assert((soc_reset_reason_t)EFUSE_RESET == RESET_REASON_CORE_EFUSE_CRC, "EFUSE_RESET != RESET_REASON_CORE_EFUSE_CRC"); +_Static_assert((soc_reset_reason_t)USB_UART_CHIP_RESET == RESET_REASON_CORE_USB_UART, "USB_UART_CHIP_RESET != RESET_REASON_CORE_USB_UART"); +_Static_assert((soc_reset_reason_t)USB_JTAG_CHIP_RESET == RESET_REASON_CORE_USB_JTAG, "USB_JTAG_CHIP_RESET != RESET_REASON_CORE_USB_JTAG"); +_Static_assert((soc_reset_reason_t)POWER_GLITCH_RESET == RESET_REASON_CORE_PWR_GLITCH, "POWER_GLITCH_RESET != RESET_REASON_CORE_PWR_GLITCH"); typedef enum { NO_SLEEP = 0, diff --git a/tools/sdk/esp32s2/include/esp_rom/include/esp32h2/rom/newlib.h b/tools/sdk/esp32s2/include/esp_rom/include/esp32h2/rom/newlib.h deleted file mode 100644 index a852bdb7f5b..00000000000 --- a/tools/sdk/esp32s2/include/esp_rom/include/esp32h2/rom/newlib.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2020 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 -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Global variables used by newlib in ROM - - Note that any of these symbols which are used by both ROM & IDF will have duplicate copies - in each "side" of the memory. However they're all pointers, and the pointers will be to the same - thing, so it's not a big memory waste and functionality is the same. - - Some variables which look like they should be here, but aren't: - - - __sf_fake_stdin, __sf_fake_stdout, __sf_fake_stderr - These are defined in ROM because ROM includes findfp.c, - but only used if _REENT_INIT or _REENT_INIT_PTR are ever called and ROM doesn't use these macros anywhere unless - printf() or similar is called without initializing reent first. ESP-IDF sets up its own minimal reent structures. - - - __lock___sinit_recursive_mutex, etc. - these are combined into common_recursive_mutex & common_mutex to save space -*/ -typedef struct { - _LOCK_T common_recursive_mutex; - _LOCK_T common_mutex; - struct _reent *global_reent; -} esp_rom_newlib_global_data_t; - -/* Called from IDF newlib component setup - to initialize common data shared between ROM and IDF -*/ -void esp_rom_newlib_init_global_data(const esp_rom_newlib_global_data_t *data); - -#ifdef __cplusplus -} -#endif diff --git a/tools/sdk/esp32s2/include/esp_rom/include/esp32h2/rom/rtc.h b/tools/sdk/esp32s2/include/esp_rom/include/esp32h2/rom/rtc.h index 76ece7e8194..ad4f45c2ca7 100644 --- a/tools/sdk/esp32s2/include/esp_rom/include/esp32h2/rom/rtc.h +++ b/tools/sdk/esp32s2/include/esp_rom/include/esp32h2/rom/rtc.h @@ -85,8 +85,7 @@ typedef enum { NO_MEAN = 0, POWERON_RESET = 1, /**<1, Vbat power on reset*/ RTC_SW_SYS_RESET = 3, /**<3, Software reset digital core*/ - DEEPSLEEP_RESET = 5, /**<3, Deep Sleep reset digital core*/ - SDIO_RESET = 6, /**<6, Reset by SLC module, reset digital core*/ + DEEPSLEEP_RESET = 5, /**<5, Deep Sleep reset digital core*/ TG0WDT_SYS_RESET = 7, /**<7, Timer Group0 Watch dog reset digital core*/ TG1WDT_SYS_RESET = 8, /**<8, Timer Group1 Watch dog reset digital core*/ RTCWDT_SYS_RESET = 9, /**<9, RTC Watch dog Reset digital core*/ @@ -96,8 +95,14 @@ typedef enum { RTCWDT_CPU_RESET = 13, /**<13, RTC Watch dog Reset CPU*/ RTCWDT_BROWN_OUT_RESET = 15, /**<15, Reset when the vdd voltage is not stable*/ RTCWDT_RTC_RESET = 16, /**<16, RTC Watch dog reset digital core and rtc module*/ - TG1WDT_CPU_RESET = 17, /**<11, Time Group1 reset CPU*/ - SUPER_WDT_RESET = 18, /**<11, super watchdog reset digital core and rtc module*/ + TG1WDT_CPU_RESET = 17, /**<17, Time Group1 reset CPU*/ + SUPER_WDT_RESET = 18, /**<18, super watchdog reset digital core and rtc module*/ + GLITCH_RTC_RESET = 19, /**<19, glitch reset digital core and rtc module*/ + EFUSE_RESET = 20, /**<20, efuse reset digital core*/ + USB_UART_CHIP_RESET = 21, /**<21, usb uart reset digital core */ + USB_JTAG_CHIP_RESET = 22, /**<22, usb jtag reset digital core */ + POWER_GLITCH_RESET = 23, /**<23, power glitch reset digital core and rtc module*/ + JTAG_RESET = 24, /**<24, jtag reset CPU*/ } RESET_REASON; // Check if the reset reason defined in ROM is compatible with soc/reset_reasons.h @@ -112,7 +117,14 @@ _Static_assert((soc_reset_reason_t)RTC_SW_CPU_RESET == RESET_REASON_CPU0_SW, "RT _Static_assert((soc_reset_reason_t)RTCWDT_CPU_RESET == RESET_REASON_CPU0_RTC_WDT, "RTCWDT_CPU_RESET != RESET_REASON_CPU0_RTC_WDT"); _Static_assert((soc_reset_reason_t)RTCWDT_BROWN_OUT_RESET == RESET_REASON_SYS_BROWN_OUT, "RTCWDT_BROWN_OUT_RESET != RESET_REASON_SYS_BROWN_OUT"); _Static_assert((soc_reset_reason_t)RTCWDT_RTC_RESET == RESET_REASON_SYS_RTC_WDT, "RTCWDT_RTC_RESET != RESET_REASON_SYS_RTC_WDT"); +_Static_assert((soc_reset_reason_t)TG1WDT_CPU_RESET == RESET_REASON_CPU0_MWDT1, "TG1WDT_CPU_RESET != RESET_REASON_CPU0_MWDT1"); _Static_assert((soc_reset_reason_t)SUPER_WDT_RESET == RESET_REASON_SYS_SUPER_WDT, "SUPER_WDT_RESET != RESET_REASON_SYS_SUPER_WDT"); +_Static_assert((soc_reset_reason_t)GLITCH_RTC_RESET == RESET_REASON_SYS_CLK_GLITCH, "GLITCH_RTC_RESET != RESET_REASON_SYS_CLK_GLITCH"); +_Static_assert((soc_reset_reason_t)EFUSE_RESET == RESET_REASON_CORE_EFUSE_CRC, "EFUSE_RESET != RESET_REASON_CORE_EFUSE_CRC"); +_Static_assert((soc_reset_reason_t)USB_UART_CHIP_RESET == RESET_REASON_CORE_USB_UART, "USB_UART_CHIP_RESET != RESET_REASON_CORE_USB_UART"); +_Static_assert((soc_reset_reason_t)USB_JTAG_CHIP_RESET == RESET_REASON_CORE_USB_JTAG, "USB_JTAG_CHIP_RESET != RESET_REASON_CORE_USB_JTAG"); +_Static_assert((soc_reset_reason_t)POWER_GLITCH_RESET == RESET_REASON_CORE_PWR_GLITCH, "POWER_GLITCH_RESET != RESET_REASON_CORE_PWR_GLITCH"); +_Static_assert((soc_reset_reason_t)JTAG_RESET == RESET_REASON_CPU_JTAG, "JTAG_RESET != RESET_REASON_CPU_JTAG"); typedef enum { NO_SLEEP = 0, diff --git a/tools/sdk/esp32s2/include/esp_rom/include/esp32s2/rom/opi_flash.h b/tools/sdk/esp32s2/include/esp_rom/include/esp32s2/rom/opi_flash.h index c985810b678..bb209f67f05 100644 --- a/tools/sdk/esp32s2/include/esp_rom/include/esp32s2/rom/opi_flash.h +++ b/tools/sdk/esp32s2/include/esp_rom/include/esp32s2/rom/opi_flash.h @@ -40,7 +40,6 @@ typedef struct { #define ESP_ROM_SPIFLASH_BP2 BIT4 #define ESP_ROM_SPIFLASH_WR_PROTECT (ESP_ROM_SPIFLASH_BP0|ESP_ROM_SPIFLASH_BP1|ESP_ROM_SPIFLASH_BP2) #define ESP_ROM_SPIFLASH_QE BIT9 -#define ESP_ROM_SPIFLASH_BP_MASK_ISSI (BIT7 | BIT5 | BIT4 | BIT3 | BIT2) #define FLASH_OP_MODE_RDCMD_DOUT 0x3B #define ESP_ROM_FLASH_SECTOR_SIZE 0x1000 diff --git a/tools/sdk/esp32s2/include/esp_rom/include/esp32s2/rom/spi_flash.h b/tools/sdk/esp32s2/include/esp_rom/include/esp32s2/rom/spi_flash.h index c93b4e27c18..beb2fcdf309 100644 --- a/tools/sdk/esp32s2/include/esp_rom/include/esp32s2/rom/spi_flash.h +++ b/tools/sdk/esp32s2/include/esp_rom/include/esp32s2/rom/spi_flash.h @@ -119,7 +119,6 @@ extern "C" { #define ESP_ROM_SPIFLASH_BP2 BIT4 #define ESP_ROM_SPIFLASH_WR_PROTECT (ESP_ROM_SPIFLASH_BP0|ESP_ROM_SPIFLASH_BP1|ESP_ROM_SPIFLASH_BP2) #define ESP_ROM_SPIFLASH_QE BIT9 -#define ESP_ROM_SPIFLASH_BP_MASK_ISSI (BIT7 | BIT5 | BIT4 | BIT3 | BIT2) #define FLASH_ID_GD25LQ32C 0xC86016 diff --git a/tools/sdk/esp32s2/include/esp_rom/include/esp32s2/rom/usb/cpio.h b/tools/sdk/esp32s2/include/esp_rom/include/esp32s2/rom/usb/cpio.h index 5603b3f541a..886b5080fb4 100644 --- a/tools/sdk/esp32s2/include/esp_rom/include/esp32s2/rom/usb/cpio.h +++ b/tools/sdk/esp32s2/include/esp_rom/include/esp32s2/rom/usb/cpio.h @@ -79,7 +79,7 @@ typedef enum { * The initial time with reason=CPIO_RSN_FILE_INITIAL, when more data is available with * CPIO_RSN_FILE_MORE and finally with CPIO_RSN_FILE_END. For these calls, fileinfo * will again contain file information. buff will be the information contained in the - * file at offset buff_offset, and the lenght of this buffer will be in buff_len. + * file at offset buff_offset, and the length of this buffer will be in buff_len. * * The library guarantees to feed all file data to the callback consequitively, so * within the same file, the buff_offset from a call will always be (buff_offset+buff_len) diff --git a/tools/sdk/esp32s2/include/esp_rom/include/esp32s3/rom/apb_backup_dma.h b/tools/sdk/esp32s2/include/esp_rom/include/esp32s3/rom/apb_backup_dma.h new file mode 100644 index 00000000000..324135cb836 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp_rom/include/esp32s3/rom/apb_backup_dma.h @@ -0,0 +1,17 @@ +/* + * SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +void ets_apb_backup_init_lock_func(void(* _apb_backup_lock)(void), void(* _apb_backup_unlock)(void)); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32s2/include/esp_rom/include/esp32s3/rom/cache.h b/tools/sdk/esp32s2/include/esp_rom/include/esp32s3/rom/cache.h index 0ec6308f7cd..27780446fe0 100644 --- a/tools/sdk/esp32s2/include/esp_rom/include/esp32s3/rom/cache.h +++ b/tools/sdk/esp32s2/include/esp_rom/include/esp32s3/rom/cache.h @@ -103,6 +103,11 @@ typedef enum { CACHE_AUTOLOAD_NEGATIVE = 1, /*!< cache autoload step is negative */ } cache_autoload_order_t; +typedef enum { + CACHE_AUTOLOAD_REGION0 = 0, /*!< cache autoload region0 */ + CACHE_AUTOLOAD_REGION1 = 1, /*!< cache autoload region1 */ +} cache_autoload_region_t; + #define CACHE_AUTOLOAD_STEP(i) ((i) - 1) typedef enum { @@ -144,14 +149,17 @@ struct dcache_tag_item { }; struct autoload_config { + uint8_t ena; /*!< autoload enable */ uint8_t order; /*!< autoload step is positive or negative */ uint8_t trigger; /*!< autoload trigger */ - uint8_t ena0; /*!< autoload region0 enable */ - uint8_t ena1; /*!< autoload region1 enable */ - uint32_t addr0; /*!< autoload region0 start address */ - uint32_t size0; /*!< autoload region0 size */ - uint32_t addr1; /*!< autoload region1 start address */ - uint32_t size1; /*!< autoload region1 size */ + uint8_t size; /*!< autoload size */ +}; + +struct autoload_region_config { + uint8_t region; /*!< autoload region*/ + uint8_t ena; /*!< autoload region enable */ + uint32_t addr; /*!< autoload region start address */ + uint32_t size; /*!< autoload region size */ }; struct tag_group_info { @@ -160,6 +168,7 @@ struct tag_group_info { uint32_t vaddr_offset; /*!< virtual address offset of the cache ways */ uint32_t tag_addr[MAX_CACHE_WAYS]; /*!< tag memory address, only [0~mode.ways-1] is valid to use */ uint32_t cache_memory_offset[MAX_CACHE_WAYS]; /*!< cache memory address, only [0~mode.ways-1] is valid to use */ + uint8_t use_legacy; /*!< 1 for using legacy tag api, 0 for using 2rd tag api */ }; struct lock_config { @@ -168,6 +177,39 @@ struct lock_config { uint16_t group; /*!< manual lock group, 0 or 1*/ }; +struct cache_internal_stub_table { + uint32_t (* icache_line_size)(void); + uint32_t (* dcache_line_size)(void); + uint32_t (* icache_addr)(uint32_t addr); + uint32_t (* dcache_addr)(uint32_t addr); + void (* invalidate_icache_items)(uint32_t addr, uint32_t items); + void (* invalidate_dcache_items)(uint32_t addr, uint32_t items); + void (* clean_items)(uint32_t addr, uint32_t items); + void (* writeback_items)(uint32_t addr, uint32_t items); + void (* lock_icache_items)(uint32_t addr, uint32_t items); + void (* lock_dcache_items)(uint32_t addr, uint32_t items); + void (* unlock_icache_items)(uint32_t addr, uint32_t items); + void (* unlock_dcache_items)(uint32_t addr, uint32_t items); + void (* occupy_items)(uint32_t addr, uint32_t items); + uint32_t (* suspend_icache_autoload)(void); + void (* resume_icache_autoload)(uint32_t autoload); + uint32_t (* suspend_dcache_autoload)(void); + void (* resume_dcache_autoload)(uint32_t autoload); + void (* freeze_icache_enable)(cache_freeze_mode_t mode); + void (* freeze_icache_disable)(void); + void (* freeze_dcache_enable)(cache_freeze_mode_t mode); + void (* freeze_dcache_disable)(void); + int (* op_addr)(uint32_t op_icache, uint32_t start_addr, uint32_t size, uint32_t cache_line_size, uint32_t max_sync_num, void(* cache_Iop)(uint32_t, uint32_t), void(* cache_Dop)(uint32_t, uint32_t)); +}; + +typedef void (* cache_op_start)(void); +typedef void (* cache_op_end)(void); + +typedef struct { + cache_op_start start; + cache_op_end end; +} cache_op_cb_t; + #define ESP_ROM_ERR_INVALID_ARG 1 #define MMU_SET_ADDR_ALIGNED_ERROR 2 #define MMU_SET_PASE_SIZE_ERROR 3 @@ -190,7 +232,7 @@ void Cache_MMU_Init(void); * @brief Set ICache mmu mapping. * Please do not call this function in your SDK application. * - * @param uint32_t ext_ram : DPORT_MMU_ACCESS_FLASH for flash, DPORT_MMU_ACCESS_SPIRAM for spiram, DPORT_MMU_INVALID for invalid. + * @param uint32_t ext_ram : MMU_ACCESS_FLASH for flash, MMU_ACCESS_SPIRAM for spiram, MMU_INVALID for invalid. * * @param uint32_t vaddr : virtual address in CPU address space. * Can be Iram0,Iram1,Irom0,Drom0 and AHB buses address. @@ -217,7 +259,7 @@ int Cache_Ibus_MMU_Set(uint32_t ext_ram, uint32_t vaddr, uint32_t paddr, uint32 * @brief Set DCache mmu mapping. * Please do not call this function in your SDK application. * - * @param uint32_t ext_ram : DPORT_MMU_ACCESS_FLASH for flash, DPORT_MMU_ACCESS_SPIRAM for spiram, DPORT_MMU_INVALID for invalid. + * @param uint32_t ext_ram : MMU_ACCESS_FLASH for flash, MMU_ACCESS_SPIRAM for spiram, MMU_INVALID for invalid. * * @param uint32_t vaddr : virtual address in CPU address space. * Can be DRam0, DRam1, DRom0, DPort and AHB buses address. @@ -272,9 +314,9 @@ uint32_t Cache_Flash_To_SPIRAM_Copy(uint32_t bus, uint32_t bus_start_addr, uint3 * @brief allocate memory to used by ICache. * Please do not call this function in your SDK application. * - * @param cache_array_t icache_low : the data array bank used by icache low part, can be CACHE_MEMORY_INVALID, CACHE_MEMORY_IBANK0, CACHE_MEMORY_IBANK1 + * @param cache_array_t icache_low : the data array bank used by icache low part. Due to timing constraint, can only be CACHE_MEMORY_INVALID, CACHE_MEMORY_IBANK0 * - * @param cache_array_t icache_high : the data array bank used by icache high part, can be CACHE_MEMORY_INVALID, CACHE_MEMORY_IBANK0, CACHE_MEMORY_IBANK1 only if icache_low and icache_high is not CACHE_MEMORY_INVALID + * @param cache_array_t icache_high : the data array bank used by icache high part. Due to timing constraint, can only be CACHE_MEMORY_INVALID, or CACHE_MEMORY_IBANK1 only if icache_low and icache_high is CACHE_MEMORY_IBANK0 * * return none */ @@ -284,9 +326,9 @@ void Cache_Occupy_ICache_MEMORY(cache_array_t icache_low, cache_array_t icache_h * @brief allocate memory to used by DCache. * Please do not call this function in your SDK application. * - * @param cache_array_t dcache_low : the data array bank used by dcache low part, can be CACHE_MEMORY_INVALID, CACHE_MEMORY_DBANK0, CACHE_MEMORY_DBANK1 + * @param cache_array_t dcache_low : the data array bank used by dcache low part. Due to timing constraint, can only be CACHE_MEMORY_INVALID, CACHE_MEMORY_DBANK1 * - * @param cache_array_t dcache1_high : the data array bank used by dcache high part, can be CACHE_MEMORY_INVALID, CACHE_MEMORY_DBANK0, CACHE_MEMORY_DBANK1 only if dcache_low0 and dcache_low1 is not CACHE_MEMORY_INVALID + * @param cache_array_t dcache1_high : the data array bank used by dcache high part. Due to timing constraint, can only be CACHE_MEMORY_INVALID, or CACHE_MEMORY_DBANK0 only if dcache_low0 and dcache_low1 is CACHE_MEMORY_DBANK1 * * return none */ @@ -310,7 +352,7 @@ void Cache_Get_Mode(struct cache_mode *mode); * * @param cache_ways_t ways : the associate ways of cache, can be CACHE_4WAYS_ASSOC and CACHE_8WAYS_ASSOC * - * @param cache_line_size_t cache_line_size : the cache line size, can be CACHE_LINE_SIZE_16B, CACHE_LINE_SIZE_32B and CACHE_LINE_SIZE_64B + * @param cache_line_size_t cache_line_size : the cache line size, can be CACHE_LINE_SIZE_16B and CACHE_LINE_SIZE_32B * * return none */ @@ -320,9 +362,9 @@ void Cache_Set_ICache_Mode(cache_size_t cache_size, cache_ways_t ways, cache_lin * @brief set DCache modes: cache size, associate ways and cache line size. * Please do not call this function in your SDK application. * - * @param cache_size_t cache_size : the cache size, can be CACHE_SIZE_8KB and CACHE_SIZE_16KB + * @param cache_size_t cache_size : the cache size, can be CACHE_SIZE_HALF and CACHE_SIZE_FULL * - * @param cache_ways_t ways : the associate ways of cache, can be CACHE_4WAYS_ASSOC and CACHE_8WAYS_ASSOC + * @param cache_ways_t ways : the associate ways of cache, can be CACHE_4WAYS_ASSOC and CACHE_8WAYS_ASSOC, only CACHE_4WAYS_ASSOC works * * @param cache_line_size_t cache_line_size : the cache line size, can be CACHE_LINE_SIZE_16B, CACHE_LINE_SIZE_32B and CACHE_LINE_SIZE_64B * @@ -351,7 +393,7 @@ uint32_t Cache_Address_Through_ICache(uint32_t addr); uint32_t Cache_Address_Through_DCache(uint32_t addr); /** - * @brief Init mmu owner register to make i/d cache use half mmu entries. + * @brief Init Cache for ROM boot, including resetting the Dcache, initializing Owner, MMU, setting DCache mode, Enabling DCache, unmasking bus. * * @param None * @@ -636,6 +678,16 @@ void Cache_End_DCache_Preload(uint32_t autoload); */ void Cache_Config_ICache_Autoload(const struct autoload_config *config); +/** + * @brief Config region autoload parameters of ICache. + * Please do not call this function in your SDK application. + * + * @param struct autoload_region_config * config : region autoload parameters. + * + * @return ESP_ROM_ERR_INVALID_ARG : invalid param, 0 : success + */ +int Cache_Config_ICache_Region_Autoload(const struct autoload_region_config *config); + /** * @brief Enable auto preload for ICache. * Please do not call this function in your SDK application. @@ -666,6 +718,16 @@ void Cache_Disable_ICache_Autoload(void); */ void Cache_Config_DCache_Autoload(const struct autoload_config *config); +/** + * @brief Config region autoload parameters of DCache. + * Please do not call this function in your SDK application. + * + * @param struct autoload_region_config * config : region autoload parameters. + * + * @return ESP_ROM_ERR_INVALID_ARG : invalid param, 0 : success + */ +int Cache_Config_DCache_Region_Autoload(const struct autoload_region_config *config); + /** * @brief Enable auto preload for DCache. * Please do not call this function in your SDK application. @@ -1008,7 +1070,24 @@ void Cache_Freeze_DCache_Disable(void); * * @return None */ -void Cache_Travel_Tag_Memory(struct cache_mode *mode, uint32_t filter_addr, void (* process)(struct tag_group_info *)); +void Cache_Travel_Tag_Memory(struct cache_mode * mode, uint32_t filter_addr, void (* process)(struct tag_group_info *)); + +/** + * @brief Travel tag memory to run a call back function, using 2nd tag registers. + * ICache and DCache are suspend when doing this. + * The callback will get the parameter tag_group_info, which will include a group of tag memory addresses and cache memory addresses. + * Please do not call this function in your SDK application. + * + * @param struct cache_mode * mode : the cache to check and the cache mode. + * + * @param uint32_t filter_addr : only the cache lines which may include the filter_address will be returned to the call back function. + * 0 for do not filter, all cache lines will be returned. + * + * @param void (* process)(struct tag_group_info *) : call back function, which may be called many times, a group(the addresses in the group are in the same position in the cache ways) a time. + * + * @return None + */ +void Cache_Travel_Tag_Memory2(struct cache_mode * mode, uint32_t filter_addr, void (* process)(struct tag_group_info *)); /** * @brief Get the virtual address from cache mode, cache tag and the virtual address offset of cache ways. @@ -1092,6 +1171,8 @@ int flash2spiram_rodata_offset(void); uint32_t flash_instr_rodata_start_page(uint32_t bus); uint32_t flash_instr_rodata_end_page(uint32_t bus); +extern struct cache_internal_stub_table* rom_cache_internal_table_ptr; +extern cache_op_cb_t rom_cache_op_cb; #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32s2/include/esp_rom/include/esp32s3/rom/rsa_pss.h b/tools/sdk/esp32s2/include/esp_rom/include/esp32s3/rom/rsa_pss.h index b9ced67a1a2..71ae5892263 100644 --- a/tools/sdk/esp32s2/include/esp_rom/include/esp32s3/rom/rsa_pss.h +++ b/tools/sdk/esp32s2/include/esp_rom/include/esp32s3/rom/rsa_pss.h @@ -32,7 +32,7 @@ typedef struct { uint32_t mdash; } ets_rsa_pubkey_t; -bool ets_rsa_pss_verify(const ets_rsa_pubkey_t *key, const uint8_t *sig, const uint8_t *digest); +bool ets_rsa_pss_verify(const ets_rsa_pubkey_t *key, const uint8_t *sig, const uint8_t *digest, uint8_t *verified_digest); void ets_mgf1_sha256(const uint8_t *mgfSeed, size_t seedLen, size_t maskLen, uint8_t *mask); diff --git a/tools/sdk/esp32s2/include/esp_rom/include/esp32s3/rom/rtc.h b/tools/sdk/esp32s2/include/esp_rom/include/esp32s3/rom/rtc.h index 09d2376ef38..d928c4dee44 100644 --- a/tools/sdk/esp32s2/include/esp_rom/include/esp32s3/rom/rtc.h +++ b/tools/sdk/esp32s2/include/esp_rom/include/esp32s3/rom/rtc.h @@ -92,6 +92,9 @@ typedef enum { SUPER_WDT_RESET = 18, /**<18, super watchdog reset digital core and rtc module*/ GLITCH_RTC_RESET = 19, /**<19, glitch reset digital core and rtc module*/ EFUSE_RESET = 20, /**<20, efuse reset digital core*/ + USB_UART_CHIP_RESET = 21, /**<21, usb uart reset digital core */ + USB_JTAG_CHIP_RESET = 22, /**<22, usb jtag reset digital core */ + POWER_GLITCH_RESET = 23, /**<23, power glitch reset digital core and rtc module*/ } RESET_REASON; // Check if the reset reason defined in ROM is compatible with soc/reset_reasons.h @@ -106,9 +109,13 @@ _Static_assert((soc_reset_reason_t)RTC_SW_CPU_RESET == RESET_REASON_CPU0_SW, "RT _Static_assert((soc_reset_reason_t)RTCWDT_CPU_RESET == RESET_REASON_CPU0_RTC_WDT, "RTCWDT_CPU_RESET != RESET_REASON_CPU0_RTC_WDT"); _Static_assert((soc_reset_reason_t)RTCWDT_BROWN_OUT_RESET == RESET_REASON_SYS_BROWN_OUT, "RTCWDT_BROWN_OUT_RESET != RESET_REASON_SYS_BROWN_OUT"); _Static_assert((soc_reset_reason_t)RTCWDT_RTC_RESET == RESET_REASON_SYS_RTC_WDT, "RTCWDT_RTC_RESET != RESET_REASON_SYS_RTC_WDT"); +_Static_assert((soc_reset_reason_t)TG1WDT_CPU_RESET == RESET_REASON_CPU0_MWDT1, "TG1WDT_CPU_RESET != RESET_REASON_CPU0_MWDT1"); _Static_assert((soc_reset_reason_t)SUPER_WDT_RESET == RESET_REASON_SYS_SUPER_WDT, "SUPER_WDT_RESET != RESET_REASON_SYS_SUPER_WDT"); _Static_assert((soc_reset_reason_t)GLITCH_RTC_RESET == RESET_REASON_SYS_CLK_GLITCH, "GLITCH_RTC_RESET != RESET_REASON_SYS_CLK_GLITCH"); _Static_assert((soc_reset_reason_t)EFUSE_RESET == RESET_REASON_CORE_EFUSE_CRC, "EFUSE_RESET != RESET_REASON_CORE_EFUSE_CRC"); +_Static_assert((soc_reset_reason_t)USB_UART_CHIP_RESET == RESET_REASON_CORE_USB_UART, "USB_UART_CHIP_RESET != RESET_REASON_CORE_USB_UART"); +_Static_assert((soc_reset_reason_t)USB_JTAG_CHIP_RESET == RESET_REASON_CORE_USB_JTAG, "USB_JTAG_CHIP_RESET != RESET_REASON_CORE_USB_JTAG"); +_Static_assert((soc_reset_reason_t)POWER_GLITCH_RESET == RESET_REASON_CORE_PWR_GLITCH, "POWER_GLITCH_RESET != RESET_REASON_CORE_PWR_GLITCH"); typedef enum { NO_SLEEP = 0, diff --git a/tools/sdk/esp32s2/include/esp_rom/include/esp32s3/rom/spi_flash.h b/tools/sdk/esp32s2/include/esp_rom/include/esp32s3/rom/spi_flash.h index 8c5170b5a8e..293306c9b97 100644 --- a/tools/sdk/esp32s2/include/esp_rom/include/esp32s3/rom/spi_flash.h +++ b/tools/sdk/esp32s2/include/esp_rom/include/esp32s3/rom/spi_flash.h @@ -111,7 +111,6 @@ extern "C" { #define ESP_ROM_SPIFLASH_BP2 BIT4 #define ESP_ROM_SPIFLASH_WR_PROTECT (ESP_ROM_SPIFLASH_BP0|ESP_ROM_SPIFLASH_BP1|ESP_ROM_SPIFLASH_BP2) #define ESP_ROM_SPIFLASH_QE BIT9 -#define ESP_ROM_SPIFLASH_BP_MASK_ISSI (BIT7 | BIT5 | BIT4 | BIT3 | BIT2) #define FLASH_ID_GD25LQ32C 0xC86016 diff --git a/tools/sdk/esp32s2/include/esp_rom/include/esp32s3/rom/usb/cpio.h b/tools/sdk/esp32s2/include/esp_rom/include/esp32s3/rom/usb/cpio.h index 5603b3f541a..886b5080fb4 100644 --- a/tools/sdk/esp32s2/include/esp_rom/include/esp32s3/rom/usb/cpio.h +++ b/tools/sdk/esp32s2/include/esp_rom/include/esp32s3/rom/usb/cpio.h @@ -79,7 +79,7 @@ typedef enum { * The initial time with reason=CPIO_RSN_FILE_INITIAL, when more data is available with * CPIO_RSN_FILE_MORE and finally with CPIO_RSN_FILE_END. For these calls, fileinfo * will again contain file information. buff will be the information contained in the - * file at offset buff_offset, and the lenght of this buffer will be in buff_len. + * file at offset buff_offset, and the length of this buffer will be in buff_len. * * The library guarantees to feed all file data to the callback consequitively, so * within the same file, the buff_offset from a call will always be (buff_offset+buff_len) diff --git a/tools/sdk/esp32s2/include/esp_rom/include/esp_rom_sys.h b/tools/sdk/esp32s2/include/esp_rom/include/esp_rom_sys.h index 9bf73adea5c..946cb7af791 100644 --- a/tools/sdk/esp32s2/include/esp_rom/include/esp_rom_sys.h +++ b/tools/sdk/esp32s2/include/esp_rom/include/esp_rom_sys.h @@ -13,7 +13,7 @@ // limitations under the License. #pragma once - +#include "sdkconfig.h" #include #include "soc/reset_reasons.h" diff --git a/tools/sdk/esp32s2/include/esp_rom/include/esp_rom_tjpgd.h b/tools/sdk/esp32s2/include/esp_rom/include/esp_rom_tjpgd.h new file mode 100644 index 00000000000..318519ba749 --- /dev/null +++ b/tools/sdk/esp32s2/include/esp_rom/include/esp_rom_tjpgd.h @@ -0,0 +1,152 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/*-----------------------------------------------------------------------------/ +/ TJpgDec - Tiny JPEG Decompressor R0.01b (C)ChaN, 2012 +/-----------------------------------------------------------------------------/ +/ The TJpgDec is a generic JPEG decompressor module for tiny embedded systems. +/ This is a free software that opened for education, research and commercial +/ developments under license policy of following terms. +/ +/ Copyright (C) 2012, ChaN, all right reserved. +/ +/ * The TJpgDec module is a free software and there is NO WARRANTY. +/ * No restriction on use. You can use, modify and redistribute it for +/ personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY. +/ * Redistributions of source code must retain the above copyright notice. +/ +/-----------------------------------------------------------------------------*/ + +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Error code */ +typedef enum { + JDR_OK = 0, /* 0: Succeeded */ + JDR_INTR, /* 1: Interrupted by output function */ + JDR_INP, /* 2: Device error or wrong termination of input stream */ + JDR_MEM1, /* 3: Insufficient memory pool for the image */ + JDR_MEM2, /* 4: Insufficient stream input buffer */ + JDR_PAR, /* 5: Parameter error */ + JDR_FMT1, /* 6: Data format error (may be damaged data) */ + JDR_FMT2, /* 7: Right format but not supported */ + JDR_FMT3 /* 8: Not supported JPEG standard */ +} esp_rom_tjpgd_result_t; + +/* Rectangular structure */ +typedef struct { + uint16_t left; /* Left end */ + uint16_t right; /* Right end */ + uint16_t top; /* Top end */ + uint16_t bottom;/* Bottom end */ +} esp_rom_tjpgd_rect_t; + +typedef struct JDEC_s esp_rom_tjpgd_dec_t; + +/** + * @brief Type of user defined input function to read data from input stream + * @param dec Specifies the decompression object of the decompression session + * @param buffer Specifies the pointer to the read buffer to store the read data. A NULL specifies to remove the data from input stream + * @param ndata Specifies number of bytes to read/remove from the input stream + * + * @return number of bytes read/removed. When a zero is returned, the esp_rom_tjpgd_prepare and esp_rom_tjpgd_decomp function aborts with JDR_INP + */ +typedef uint32_t (*esp_rom_tjpgd_input_function_t)(esp_rom_tjpgd_dec_t *dec, uint8_t *buffer, uint32_t ndata); + +/** + * @brief User defined output function to write decompressed pixels to the output device + * + * This function is the data output interface of the TJpgDec module. + * The corresponding decompression session can be identified by the pointer to the device identifier jdec->device passed to the 5th argument of jd_prepare function. + * The bitmap is sent to the frame buffer or display device in this function. + * The first pixel in the bitmap is the left-top of the rectangular, the second one is next right and last pixel is the bottom-right of the rectangular. + * The size of rectangular varies from 1x1 to 16x16 depends on clipping, scaling and sampling factor of the image. + * If the rectangular is out of the frame buffer, it should be clipped in this function. + * + * The pixel format is currently configured to RGB888 + * + * @param dec Specifies the decompression object of the decompression session + * @param bitmap Specifies the RGB bitmap to be output + * @param rect Specifies rectangular region in the image to output the RGB bitmap + * + * @return Normally returns 1. It lets TJpgDec to continue the decompressing process. + * When a 0 is returned, the esp_rom_tjpgd_decomp function aborts with JDR_INTR. + * This is useful to interrupt the decompression process + */ +typedef uint32_t (*esp_rom_tjpgd_output_function_t)(esp_rom_tjpgd_dec_t *dec, void *bitmap, esp_rom_tjpgd_rect_t *rect); + +struct JDEC_s { + uint32_t dctr; /* Number of bytes available in the input buffer */ + uint8_t *dptr; /* Current data read ptr */ + uint8_t *inbuf; /* Bit stream input buffer */ + uint8_t dmsk; /* Current bit in the current read byte */ + uint8_t scale; /* Output scaling ratio */ + uint8_t msx, msy; /* MCU size in unit of block (width, height) */ + uint8_t qtid[3]; /* Quantization table ID of each component */ + int16_t dcv[3]; /* Previous DC element of each component */ + uint16_t nrst; /* Restart inverval */ + uint32_t width, height; /* Size of the input image (pixel) */ + uint8_t *huffbits[2][2]; /* Huffman bit distribution tables [id][dcac] */ + uint16_t *huffcode[2][2]; /* Huffman code word tables [id][dcac] */ + uint8_t *huffdata[2][2]; /* Huffman decoded data tables [id][dcac] */ + int32_t *qttbl[4]; /* Dequaitizer tables [id] */ + void *workbuf; /* Working buffer for IDCT and RGB output */ + uint8_t *mcubuf; /* Working buffer for the MCU */ + void *pool; /* Pointer to available memory pool */ + uint32_t sz_pool; /* Size of momory pool (bytes available) */ + esp_rom_tjpgd_input_function_t infunc; /* Pointer to jpeg stream input function */ + void *device; /* Pointer to I/O device identifiler for the session */ +}; + +/* TJpgDec API functions */ + +/** + * @brief Analyzes the JPEG data and create a decompression object for subsequent decompression process. + * @param dec Specifies the decompression object to be initialized. The decompression object is used for subsequent decompression process. + * @param infunc Specifies the user defined data input function. + * @param work Specifies pointer to the work area for this session. It should be aligned to word boundary or it can result an exception. + * @param sz_work Specifies size of the work area in unit of byte. + * TJpgDec requires upto 3092 bytes of work area depends on the built-in parameter tables of the JPEG image. + * Thus 3092 bytes of work area is sufficient for most case. + * @param dev Specifies pointer to the user defined device identifier for this session. + * It is stored to the member device in the decompression object. It can be referred by I/O functions to identify the current session. + * When I/O device is fixed in the project or this feature is not needed, set NULL and do not care about this. + * + * @return + * - JDR_OK Function succeeded and decompression object is valid. + * - JDR_INP An error occurred in input function due to hard error or wrong stream termination. + * - JDR_MEM1 Insufficient work area for this JPEG image. + * - JDR_MEM2 Insufficient input buffer for this JPEG image. JD_SZBUF may be too small. + * - JDR_PAR Parameter error. Given pointer to the work area is NULL. + * - JDR_FMT1 Data format error. The JPEG data can be collapsed. + * - JDR_FMT2 Right format but not supported. May be a grayscale image. + * - JDR_FMT3 Not supported JPEG standard. May be a progressive JPEG image. + */ +esp_rom_tjpgd_result_t esp_rom_tjpgd_prepare(esp_rom_tjpgd_dec_t *dec, esp_rom_tjpgd_input_function_t infunc, void *work, uint32_t sz_work, void *dev); + +/** + * @brief Decompress the JPEG image and output it as RGB data. + * @param dec Specifies the valid decompressor object. + * @param outfunc Specifies the user defined data output function. The esp_rom_tjpgd_decomp function calls this function to output the decompressed JPEG image in RGB form. + * @param scale Specifies scaling factor N for output. The output image is descaled to 1 / 2 ^ N (N = 0 to 3). + * + * @return + * - JDR_OK Function succeeded. + * - JDR_INTR The decompression process is interrupted by output function. + * - JDR_INP An error occured in input function due to hard error or wrong stream termination. + * - JDR_PAR Parameter error. Given scale factor is invalid. + * - JDR_FMT1 Data format error. The JPEG data can be collapted. + */ +esp_rom_tjpgd_result_t esp_rom_tjpgd_decomp(esp_rom_tjpgd_dec_t *dec, esp_rom_tjpgd_output_function_t outfunc, uint8_t scale); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32s2/include/esp_rom/include/linux/soc/reset_reasons.h b/tools/sdk/esp32s2/include/esp_rom/include/linux/soc/reset_reasons.h new file mode 100644 index 00000000000..7cc86ffddfb --- /dev/null +++ b/tools/sdk/esp32s2/include/esp_rom/include/linux/soc/reset_reasons.h @@ -0,0 +1,31 @@ +// Copyright 2021 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 + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Dummy to satisfy the requirement for this type on Linux targets. + * Look at other reset_reasons.h files in IDF. + */ +typedef enum { + RESET_REASON_CHIP_POWER_ON = 0x01, // Power on reset +} soc_reset_reason_t; + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32s2/include/esp_serial_slave_link/include/esp_serial_slave_link/essl.h b/tools/sdk/esp32s2/include/esp_serial_slave_link/include/esp_serial_slave_link/essl.h index 505edcdc2f6..f03274a4013 100644 --- a/tools/sdk/esp32s2/include/esp_serial_slave_link/include/esp_serial_slave_link/essl.h +++ b/tools/sdk/esp32s2/include/esp_serial_slave_link/include/esp_serial_slave_link/essl.h @@ -29,42 +29,48 @@ typedef struct essl_dev_t* essl_handle_t; * * @param handle Handle of an ESSL device. * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. - * @return ESP_OK if success, or other value returned from lower layer `init`. + * @return + * - ESP_OK: If success + * - ESP_ERR_NOT_SUPPORTED: Current device does not support this function. + * - Other value returned from lower layer `init`. */ esp_err_t essl_init(essl_handle_t handle, uint32_t wait_ms); -/** Wait for interrupt of an ESP slave device. +/** Wait for interrupt of an ESSL slave device. * * @param handle Handle of an ESSL device. * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. * * @return - * - ESP_OK if success + * - ESP_OK: If success + * - ESP_ERR_NOT_SUPPORTED: Current device does not support this function. * - One of the error codes from SDMMC host controller */ esp_err_t essl_wait_for_ready(essl_handle_t handle, uint32_t wait_ms); /** Get buffer num for the host to send data to the slave. The buffers are size of ``buffer_size``. * - * @param handle Handle of an ESSL device. - * @param out_tx_num Output of buffer num that host can send data to an ESP slave. + * @param handle Handle of a ESSL device. + * @param out_tx_num Output of buffer num that host can send data to ESSL slave. * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. * * @return - * - ESP_OK Success - * - One of the error codes from SDMMC host controller + * - ESP_OK: Success + * - ESP_ERR_NOT_SUPPORTED: This API is not supported in this mode + * - One of the error codes from SDMMC/SPI host controller */ esp_err_t essl_get_tx_buffer_num(essl_handle_t handle, uint32_t *out_tx_num, uint32_t wait_ms); -/** Get amount of data the ESP slave preparing to send to host. +/** Get the size, in bytes, of the data that the ESSL slave is ready to send * * @param handle Handle of an ESSL device. - * @param out_rx_size Output of data size to read from slave. + * @param out_rx_size Output of data size to read from slave, in bytes * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. * * @return - * - ESP_OK Success - * - One of the error codes from SDMMC host controller + * - ESP_OK: Success + * - ESP_ERR_NOT_SUPPORTED: This API is not supported in this mode + * - One of the error codes from SDMMC/SPI host controller */ esp_err_t essl_get_rx_data_size(essl_handle_t handle, uint32_t *out_rx_size, uint32_t wait_ms); @@ -72,10 +78,15 @@ esp_err_t essl_get_rx_data_size(essl_handle_t handle, uint32_t *out_rx_size, uin /** Reset the counters of this component. Usually you don't need to do this unless you know the slave is reset. * * @param handle Handle of an ESSL device. + * + * @return + * - ESP_OK: Success + * - ESP_ERR_NOT_SUPPORTED: This API is not supported in this mode + * - ESP_ERR_INVALID_ARG: Invalid argument, handle is not init. */ esp_err_t essl_reset_cnt(essl_handle_t handle); -/** Send a packet to the ESP slave. The slave receive the packet into buffers whose size is ``buffer_size`` (configured during initialization). +/** Send a packet to the ESSL Slave. The Slave receives the packet into buffers whose size is ``buffer_size`` (configured during initialization). * * @param handle Handle of an ESSL device. * @param start Start address of the packet to send @@ -84,12 +95,15 @@ esp_err_t essl_reset_cnt(essl_handle_t handle); * * @return * - ESP_OK Success - * - ESP_ERR_TIMEOUT No buffer to use, or error ftrom SDMMC host controller - * - One of the error codes from SDMMC host controller + * - ESP_ERR_INVALID_ARG: Invalid argument, handle is not init or other argument is not valid. + * - ESP_ERR_TIMEOUT: No buffer to use, or error ftrom SDMMC host controller. + * - ESP_ERR_NOT_FOUND: Slave is not ready for receiving. + * - ESP_ERR_NOT_SUPPORTED: This API is not supported in this mode + * - One of the error codes from SDMMC/SPI host controller. */ esp_err_t essl_send_packet(essl_handle_t handle, const void *start, size_t length, uint32_t wait_ms); -/** Get a packet from an ESP slave. +/** Get a packet from ESSL slave. * * @param handle Handle of an ESSL device. * @param[out] out_data Data output address @@ -98,16 +112,19 @@ esp_err_t essl_send_packet(essl_handle_t handle, const void *start, size_t lengt * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. * * @return - * - ESP_OK Success, all the data are read from the slave. - * - ESP_ERR_NOT_FINISHED Read success, while there're data remaining. - * - One of the error codes from SDMMC host controller + * - ESP_OK Success: All the data has been read from the slave. + * - ESP_ERR_INVALID_ARG: Invalid argument, The handle is not initialized or the other arguments are invalid. + * - ESP_ERR_NOT_FINISHED: Read was successful, but there is still data remaining. + * - ESP_ERR_NOT_FOUND: Slave is not ready to send data. + * - ESP_ERR_NOT_SUPPORTED: This API is not supported in this mode + * - One of the error codes from SDMMC/SPI host controller. */ esp_err_t essl_get_packet(essl_handle_t handle, void *out_data, size_t size, size_t *out_length, uint32_t wait_ms); -/** Write general purpose R/W registers (8-bit) of an ESP slave. +/** Write general purpose R/W registers (8-bit) of ESSL slave. * * @param handle Handle of an ESSL device. - * @param addr Address of register to write. Valid address: 0-59. + * @param addr Address of register to write. For SDIO, valid address: 0-59. For SPI, see ``essl_spi.h`` * @param value Value to write to the register. * @param value_o Output of the returned written value. * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. @@ -116,22 +133,20 @@ esp_err_t essl_get_packet(essl_handle_t handle, void *out_data, size_t size, siz * * @return * - ESP_OK Success - * - ESP_ERR_INVALID_ARG Address not valid. - * - One of the error codes from SDMMC host controller + * - One of the error codes from SDMMC/SPI host controller */ esp_err_t essl_write_reg(essl_handle_t handle, uint8_t addr, uint8_t value, uint8_t *value_o, uint32_t wait_ms); -/** Read general purpose R/W registers (8-bit) of an ESP slave. +/** Read general purpose R/W registers (8-bit) of ESSL slave. * - * @param handle Handle of an ESSL device. - * @param add Address of register to read. Valid address: 0-27, 32-63 (28-31 reserved, return interrupt bits on read). + * @param handle Handle of a ``essl`` device. + * @param add Address of register to read. For SDIO, Valid address: 0-27, 32-63 (28-31 reserved, return interrupt bits on read). For SPI, see ``essl_spi.h`` * @param value_o Output value read from the register. * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. * * @return * - ESP_OK Success - * - ESP_ERR_INVALID_ARG Address not valid. - * - One of the error codes from SDMMC host controller + * - One of the error codes from SDMMC/SPI host controller */ esp_err_t essl_read_reg(essl_handle_t handle, uint8_t add, uint8_t *value_o, uint32_t wait_ms); @@ -141,25 +156,26 @@ esp_err_t essl_read_reg(essl_handle_t handle, uint8_t add, uint8_t *value_o, uin * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. * * @return - * - ESP_ERR_NOT_SUPPORTED Currently our driver doesnot support SDIO with SPI interface. - * - ESP_OK If interrupt triggered. - * - ESP_ERR_TIMEOUT No interrupts before timeout. + * - ESP_OK: If interrupt is triggered. + * - ESP_ERR_NOT_SUPPORTED: Current device does not support this function. + * - ESP_ERR_TIMEOUT: No interrupts before timeout. */ esp_err_t essl_wait_int(essl_handle_t handle, uint32_t wait_ms); -/** Clear interrupt bits of an ESP slave. All the bits set in the mask will be cleared, while other bits will stay the same. +/** Clear interrupt bits of ESSL slave. All the bits set in the mask will be cleared, while other bits will stay the same. * * @param handle Handle of an ESSL device. * @param intr_mask Mask of interrupt bits to clear. * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. * * @return - * - ESP_OK Success - * - One of the error codes from SDMMC host controller + * - ESP_OK: Success + * - ESP_ERR_NOT_SUPPORTED: Current device does not support this function. + * - One of the error codes from SDMMC host controller */ esp_err_t essl_clear_intr(essl_handle_t handle, uint32_t intr_mask, uint32_t wait_ms); -/** Get interrupt bits of an ESP slave. +/** Get interrupt bits of ESSL slave. * * @param handle Handle of an ESSL device. * @param intr_raw Output of the raw interrupt bits. Set to NULL if only masked bits are read. @@ -167,25 +183,27 @@ esp_err_t essl_clear_intr(essl_handle_t handle, uint32_t intr_mask, uint32_t wai * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. * * @return - * - ESP_OK Success - * - ESP_INVALID_ARG if both ``intr_raw`` and ``intr_st`` are NULL. - * - One of the error codes from SDMMC host controller + * - ESP_OK: Success + * - ESP_INVALID_ARG: If both ``intr_raw`` and ``intr_st`` are NULL. + * - ESP_ERR_NOT_SUPPORTED: Current device does not support this function. + * - One of the error codes from SDMMC host controller */ esp_err_t essl_get_intr(essl_handle_t handle, uint32_t *intr_raw, uint32_t *intr_st, uint32_t wait_ms); -/** Set interrupt enable bits of an ESP slave. The slave only sends interrupt on the line when there is a bit both the raw status and the enable are set. +/** Set interrupt enable bits of ESSL slave. The slave only sends interrupt on the line when there is a bit both the raw status and the enable are set. * * @param handle Handle of an ESSL device. * @param ena_mask Mask of the interrupt bits to enable. * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. * * @return - * - ESP_OK Success - * - One of the error codes from SDMMC host controller + * - ESP_OK: Success + * - ESP_ERR_NOT_SUPPORTED: Current device does not support this function. + * - One of the error codes from SDMMC host controller */ esp_err_t essl_set_intr_ena(essl_handle_t handle, uint32_t ena_mask, uint32_t wait_ms); -/** Get interrupt enable bits of an ESP slave. +/** Get interrupt enable bits of ESSL slave. * * @param handle Handle of an ESSL device. * @param ena_mask_o Output of interrupt bit enable mask. @@ -204,7 +222,8 @@ esp_err_t essl_get_intr_ena(essl_handle_t handle, uint32_t *ena_mask_o, uint32_t * @param wait_ms Millisecond to wait before timeout, will not wait at all if set to 0-9. * * @return - * - ESP_OK Success - * - One of the error codes from SDMMC host controller + * - ESP_OK: Success + * - ESP_ERR_NOT_SUPPORTED: Current device does not support this function. + * - One of the error codes from SDMMC host controller */ esp_err_t essl_send_slave_intr(essl_handle_t handle, uint32_t intr_mask, uint32_t wait_ms); diff --git a/tools/sdk/esp32s2/include/esp_serial_slave_link/include/esp_serial_slave_link/essl_spi.h b/tools/sdk/esp32s2/include/esp_serial_slave_link/include/esp_serial_slave_link/essl_spi.h index a6c3c40c04f..22721d17ece 100644 --- a/tools/sdk/esp32s2/include/esp_serial_slave_link/include/esp_serial_slave_link/essl_spi.h +++ b/tools/sdk/esp32s2/include/esp_serial_slave_link/include/esp_serial_slave_link/essl_spi.h @@ -23,22 +23,141 @@ extern "C" { #endif +/// Configuration of ESSL SPI device +typedef struct { + spi_device_handle_t *spi; ///< Pointer to SPI device handle. + uint32_t tx_buf_size; ///< The pre-negotiated Master TX buffer size used by both the host and the slave. + uint8_t tx_sync_reg; ///< The pre-negotiated register ID for Master-TX-SLAVE-RX synchronization. 1 word (4 Bytes) will be reserved for the synchronization. + uint8_t rx_sync_reg; ///< The pre-negotiated register ID for Master-RX-Slave-TX synchronization. 1 word (4 Bytes) will be reserved for the synchronization. +} essl_spi_config_t; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// APIs for DMA Append Mode +// This mode has a better performance for continuous Half Duplex SPI transactions. +// +// * You can use the ``essl_spi_init_dev`` and ``essl_spi_deinit_dev`` together with APIs in ``essl.h`` to communicate +// with ESP SPI Slaves in Half Duplex DMA Append Mode. See example for SPI SLAVE HALFDUPLEX APPEND MODE. +// * You can also use the following APIs to create your own logic. +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @brief Initialize the ESSL SPI device function list and get its handle + * + * @param[out] out_handle Output of the handle + * @param init_config Configuration for the ESSL SPI device + * @return + * - ESP_OK: On success + * - ESP_ERR_NO_MEM: Memory exhausted + * - ESP_ERR_INVALID_STATE: SPI driver is not initialized + * - ESP_ERR_INVALID_ARG: Wrong register ID + */ +esp_err_t essl_spi_init_dev(essl_handle_t *out_handle, const essl_spi_config_t *init_config); + +/** + * @brief Deinitialize the ESSL SPI device and free the memory used by the device + * + * @param handle Handle of the ESSL SPI device + * @return + * - ESP_OK: On success + * - ESP_ERR_INVALID_STATE: ESSL SPI is not in use + */ +esp_err_t essl_spi_deinit_dev(essl_handle_t handle); + +/** + * @brief Read from the shared registers + * + * @note The registers for Master/Slave synchronization are reserved. Do not use them. (see `rx_sync_reg` in `essl_spi_config_t`) + * + * @param arg Context of the component. (Member ``arg`` from ``essl_handle_t``) + * @param addr Address of the shared registers. (Valid: 0 ~ SOC_SPI_MAXIMUM_BUFFER_SIZE, registers for M/S sync are reserved, see note1). + * @param[out] out_value Read buffer for the shared registers. + * @param wait_ms Time to wait before timeout (reserved for future use, user should set this to 0). + * @return + * - ESP_OK: success + * - ESP_ERR_INVALID_STATE: ESSL SPI has not been initialized. + * - ESP_ERR_INVALID_ARG: The address argument is not valid. See note 1. + * - or other return value from :cpp:func:`spi_device_transmit`. + */ +esp_err_t essl_spi_read_reg(void *arg, uint8_t addr, uint8_t *out_value, uint32_t wait_ms); + +/** + * @brief Get a packet from Slave + * + * @param arg Context of the component. (Member ``arg`` from ``essl_handle_t``) + * @param[out] out_data Output data address + * @param size The size of the output data. + * @param wait_ms Time to wait before timeout (reserved for future use, user should set this to 0). + * @return + * - ESP_OK: On Success + * - ESP_ERR_INVALID_STATE: ESSL SPI has not been initialized. + * - ESP_ERR_INVALID_ARG: The output data address is neither DMA capable nor 4 byte-aligned + * - ESP_ERR_INVALID_SIZE: Master requires ``size`` bytes of data but Slave did not load enough bytes. + */ +esp_err_t essl_spi_get_packet(void *arg, void *out_data, size_t size, uint32_t wait_ms); + +/** + * @brief Write to the shared registers + * + * @note The registers for Master/Slave synchronization are reserved. Do not use them. (see `tx_sync_reg` in `essl_spi_config_t`) + * @note Feature of checking the actual written value (``out_value``) is not supported. + * + * @param arg Context of the component. (Member ``arg`` from ``essl_handle_t``) + * @param addr Address of the shared registers. (Valid: 0 ~ SOC_SPI_MAXIMUM_BUFFER_SIZE, registers for M/S sync are reserved, see note1) + * @param value Buffer for data to send, should be align to 4. + * @param[out] out_value Not supported, should be set to NULL. + * @param wait_ms Time to wait before timeout (reserved for future use, user should set this to 0). + * @return + * - ESP_OK: success + * - ESP_ERR_INVALID_STATE: ESSL SPI has not been initialized. + * - ESP_ERR_INVALID_ARG: The address argument is not valid. See note 1. + * - ESP_ERR_NOT_SUPPORTED: Should set ``out_value`` to NULL. See note 2. + * - or other return value from :cpp:func:`spi_device_transmit`. + * + */ +esp_err_t essl_spi_write_reg(void *arg, uint8_t addr, uint8_t value, uint8_t *out_value, uint32_t wait_ms); + +/** + * @brief Send a packet to Slave + * + * @param arg Context of the component. (Member ``arg`` from ``essl_handle_t``) + * @param data Address of the data to send + * @param size Size of the data to send. + * @param wait_ms Time to wait before timeout (reserved for future use, user should set this to 0). + * @return + * - ESP_OK: On success + * - ESP_ERR_INVALID_STATE: ESSL SPI has not been initialized. + * - ESP_ERR_INVALID_ARG: The data address is not DMA capable + * - ESP_ERR_INVALID_SIZE: Master will send ``size`` bytes of data but Slave did not load enough RX buffer + */ +esp_err_t essl_spi_send_packet(void *arg, const void *data, size_t size, uint32_t wait_ms); + +/** + * @brief Reset the counter in Master context + * + * @note Shall only be called if the slave has reset its counter. Else, Slave and Master would be desynchronized + * + * @param arg Context of the component. (Member ``arg`` from ``essl_handle_t``) + */ +void essl_spi_reset_cnt(void *arg); + //////////////////////////////////////////////////////////////////////////////// // Basic commands to communicate with the SPI Slave HD on ESP32-S2 //////////////////////////////////////////////////////////////////////////////// - /** * @brief Read the shared buffer from the slave in ISR way * + * @note The slave's HW doesn't guarantee the data in one SPI transaction is consistent. It sends data in unit of byte. + * In other words, if the slave SW attempts to update the shared register when a rdbuf SPI transaction is in-flight, + * the data got by the master will be the combination of bytes of different writes of slave SW. + * * @note ``out_data`` should be prepared in words and in the DRAM. The buffer may be written in words * by the DMA. When a byte is written, the remaining bytes in the same word will also be * overwritten, even the ``len`` is shorter than a word. * - * @param spi SPI device handle representing the slave - * @param out_data Buffer for read data, strongly suggested to be in the DRAM and align to 4 - * @param addr Address of the slave shared buffer - * @param len Length to read - * @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send. + * @param spi SPI device handle representing the slave + * @param[out] out_data Buffer for read data, strongly suggested to be in the DRAM and aligned to 4 + * @param addr Address of the slave shared buffer + * @param len Length to read + * @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send. * @return * - ESP_OK: on success * - or other return value from :cpp:func:`spi_device_transmit`. @@ -52,11 +171,11 @@ esp_err_t essl_spi_rdbuf(spi_device_handle_t spi, uint8_t *out_data, int addr, i * by the DMA. When a byte is written, the remaining bytes in the same word will also be * overwritten, even the ``len`` is shorter than a word. * - * @param spi SPI device handle representing the slave - * @param out_data Buffer for read data, strongly suggested to be in the DRAM and align to 4 - * @param addr Address of the slave shared buffer - * @param len Length to read - * @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send. + * @param spi SPI device handle representing the slave + * @param[out] out_data Buffer for read data, strongly suggested to be in the DRAM and aligned to 4 + * @param addr Address of the slave shared buffer + * @param len Length to read + * @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send. * @return * - ESP_OK: on success * - or other return value from :cpp:func:`spi_device_transmit`. @@ -71,7 +190,7 @@ esp_err_t essl_spi_rdbuf_polling(spi_device_handle_t spi, uint8_t *out_data, int * overwritten, even the ``len`` is shorter than a word. * * @param spi SPI device handle representing the slave - * @param data Buffer for data to send, strongly suggested to be in the DRAM and align to 4 + * @param data Buffer for data to send, strongly suggested to be in the DRAM * @param addr Address of the slave shared buffer, * @param len Length to write * @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send. @@ -89,7 +208,7 @@ esp_err_t essl_spi_wrbuf(spi_device_handle_t spi, const uint8_t *data, int addr, * overwritten, even the ``len`` is shorter than a word. * * @param spi SPI device handle representing the slave - * @param data Buffer for data to send, strongly suggested to be in the DRAM and align to 4 + * @param data Buffer for data to send, strongly suggested to be in the DRAM * @param addr Address of the slave shared buffer, * @param len Length to write * @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send. @@ -105,10 +224,10 @@ esp_err_t essl_spi_wrbuf_polling(spi_device_handle_t spi, const uint8_t *data, i * @note This function combines several :cpp:func:`essl_spi_rddma_seg` and one * :cpp:func:`essl_spi_rddma_done` at the end. Used when the slave is working in segment mode. * - * @param spi SPI device handle representing the slave - * @param out_data Buffer to hold the received data, strongly suggested to be in the DRAM and align to 4 - * @param len Total length of data to receive. - * @param seg_len Length of each segment, which is not larger than the maximum transaction length + * @param spi SPI device handle representing the slave + * @param[out] out_data Buffer to hold the received data, strongly suggested to be in the DRAM and aligned to 4 + * @param len Total length of data to receive. + * @param seg_len Length of each segment, which is not larger than the maximum transaction length * allowed for the spi device. Suggested to be multiples of 4. When set < 0, means send * all data in one segment (the ``rddma_done`` will still be sent.) * @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send. @@ -123,10 +242,10 @@ esp_err_t essl_spi_rddma(spi_device_handle_t spi, uint8_t *out_data, int len, in * * @note To read long buffer, call :cpp:func:`essl_spi_rddma` instead. * - * @param spi SPI device handle representing the slave - * @param out_data Buffer to hold the received data, strongly suggested to be in the DRAM and align to 4 - * @param seg_len Length of this segment - * @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send. + * @param spi SPI device handle representing the slave + * @param[out] out_data Buffer to hold the received data. strongly suggested to be in the DRAM and aligned to 4 + * @param seg_len Length of this segment + * @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send. * @return * - ESP_OK: success * - or other return value from :cpp:func:`spi_device_transmit`. @@ -155,7 +274,7 @@ esp_err_t essl_spi_rddma_done(spi_device_handle_t spi, uint32_t flags); * :cpp:func:`essl_spi_wrdma_done` at the end. Used when the slave is working in segment mode. * * @param spi SPI device handle representing the slave - * @param data Buffer for data to send, strongly suggested to be in the DRAM and align to 4 + * @param data Buffer for data to send, strongly suggested to be in the DRAM * @param len Total length of data to send. * @param seg_len Length of each segment, which is not larger than the maximum transaction length * allowed for the spi device. Suggested to be multiples of 4. When set < 0, means send @@ -173,7 +292,7 @@ esp_err_t essl_spi_wrdma(spi_device_handle_t spi, const uint8_t *data, int len, * @note To send long buffer, call :cpp:func:`essl_spi_wrdma` instead. * * @param spi SPI device handle representing the slave - * @param data Buffer for data to send, strongly suggested to be in the DRAM and align to 4 + * @param data Buffer for data to send, strongly suggested to be in the DRAM * @param seg_len Length of this segment * @param flags `SPI_TRANS_*` flags to control the transaction mode of the transaction to send. * @return diff --git a/tools/sdk/esp32s2/include/esp_system/include/esp_private/dbg_stubs.h b/tools/sdk/esp32s2/include/esp_system/include/esp_private/dbg_stubs.h index f3f5fba3b7b..ead23447bc7 100644 --- a/tools/sdk/esp32s2/include/esp_system/include/esp_private/dbg_stubs.h +++ b/tools/sdk/esp32s2/include/esp_system/include/esp_private/dbg_stubs.h @@ -24,13 +24,19 @@ extern "C" { * Debug stubs entries IDs */ typedef enum { - ESP_DBG_STUB_CONTROL_DATA, ///< stubs descriptor entry + ESP_DBG_STUB_MAGIC_NUM, + ESP_DBG_STUB_TABLE_SIZE, + ESP_DBG_STUB_CONTROL_DATA, ///< stubs descriptor entry ESP_DBG_STUB_ENTRY_FIRST, - ESP_DBG_STUB_ENTRY_GCOV ///< GCOV entry - = ESP_DBG_STUB_ENTRY_FIRST, + ESP_DBG_STUB_ENTRY_GCOV ///< GCOV entry + = ESP_DBG_STUB_ENTRY_FIRST, + ESP_DBG_STUB_ENTRY_CAPABILITIES, ESP_DBG_STUB_ENTRY_MAX } esp_dbg_stub_id_t; +#define ESP_DBG_STUB_MAGIC_NUM_VAL 0xFEEDBEEF +#define ESP_DBG_STUB_CAP_GCOV_TASK (1 << 0) + /** * @brief Initializes debug stubs. * @@ -45,12 +51,24 @@ void esp_dbg_stubs_init(void); * * @param id Stub ID. * @param entry Stub entry. Usually it is stub entry function address, - * but can be any value meaningfull for OpenOCD command/code. - * + * but can be any value meaningfull for OpenOCD command/code + * such as capabilities * @return ESP_OK on success, otherwise see esp_err_t */ esp_err_t esp_dbg_stub_entry_set(esp_dbg_stub_id_t id, uint32_t entry); +/** + * @brief Retrives the corresponding stub entry + * + * @param id Stub ID. + * @param entry Stub entry. Usually it is stub entry function address, + * but can be any value meaningfull for OpenOCD command/code + * such as capabilities + * + * @return ESP_OK on success, otherwise see esp_err_t + */ +esp_err_t esp_dbg_stub_entry_get(esp_dbg_stub_id_t id, uint32_t *entry); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32s2/include/esp_system/include/esp_task.h b/tools/sdk/esp32s2/include/esp_system/include/esp_task.h index 37d78bca6e8..adca9cde6bc 100644 --- a/tools/sdk/esp32s2/include/esp_system/include/esp_task.h +++ b/tools/sdk/esp32s2/include/esp_system/include/esp_task.h @@ -52,7 +52,11 @@ #define ESP_TASK_TIMER_PRIO (ESP_TASK_PRIO_MAX - 3) #define ESP_TASK_TIMER_STACK (CONFIG_ESP_TIMER_TASK_STACK_SIZE + TASK_EXTRA_STACK_SIZE) #define ESP_TASKD_EVENT_PRIO (ESP_TASK_PRIO_MAX - 5) +#if CONFIG_LWIP_TCPIP_CORE_LOCKING +#define ESP_TASKD_EVENT_STACK (CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE + TASK_EXTRA_STACK_SIZE + 2048) +#else #define ESP_TASKD_EVENT_STACK (CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE + TASK_EXTRA_STACK_SIZE) +#endif /* CONFIG_LWIP_TCPIP_CORE_LOCKING */ #define ESP_TASK_TCPIP_PRIO (ESP_TASK_PRIO_MAX - 7) #define ESP_TASK_TCPIP_STACK (CONFIG_LWIP_TCPIP_TASK_STACK_SIZE + TASK_EXTRA_STACK_SIZE) #define ESP_TASK_MAIN_PRIO (ESP_TASK_PRIO_MIN + 1) diff --git a/tools/sdk/esp32s2/include/esp_system/include/esp_xt_wdt.h b/tools/sdk/esp32s2/include/esp_system/include/esp_xt_wdt.h new file mode 100644 index 00000000000..3b39d8056dc --- /dev/null +++ b/tools/sdk/esp32s2/include/esp_system/include/esp_xt_wdt.h @@ -0,0 +1,63 @@ +/* + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include + +#include "esp_err.h" +#include "esp_intr_alloc.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief esp_xt_wdt configuration struct + * + */ +typedef struct { + uint8_t timeout; /*!< Watchdog timeout */ + bool auto_backup_clk_enable; /*!< Enable automatic switch to backup clock at timeout */ +} esp_xt_wdt_config_t; + +/* Callback function for WDT interrupt*/ +typedef void (*esp_xt_callback_t)(void *arg); + +/** + * @brief Initializes the xtal32k watchdog timer + * + * @param cfg Pointer to configuration struct + * @return esp_err_t + * - ESP_OK: XTWDT was successfully enabled + * - ESP_ERR_NO_MEM: Failed to allocate ISR + */ +esp_err_t esp_xt_wdt_init(const esp_xt_wdt_config_t *cfg); + +/** + * @brief Register a callback function that will be called when the watchdog + * times out. + * + * @note This function will be called from an interrupt context where the cache might be disabled. + * Thus the function should be placed in IRAM and must not perform any blocking operations. + * + * Only one callback function can be registered, any call to esp_xt_wdt_register_callback + * will override the previous callback function. + * + * @param func The callback function to register + * @param arg Pointer to argument that will be passed to the callback function + */ +void esp_xt_wdt_register_callback(esp_xt_callback_t func, void *arg); + +/** + * @brief Restores the xtal32k clock and re-enables the WDT + * + */ +void esp_xt_wdt_restore_clk(void); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32s2/include/esp_wifi/include/esp_mesh.h b/tools/sdk/esp32s2/include/esp_wifi/include/esp_mesh.h index ab8f8a4c86f..f146b5e730e 100644 --- a/tools/sdk/esp32s2/include/esp_wifi/include/esp_mesh.h +++ b/tools/sdk/esp32s2/include/esp_wifi/include/esp_mesh.h @@ -505,8 +505,13 @@ typedef struct { * @brief Mesh softAP configuration */ typedef struct { - uint8_t password[64]; /**< mesh softAP password */ - uint8_t max_connection; /**< max number of stations allowed to connect in, max 10 */ + uint8_t password[64]; /**< mesh softAP password */ + /** + * max number of stations allowed to connect in, default 6, max 10 + * = max_connection + nonmesh_max_connection + */ + uint8_t max_connection; /**< max mesh connections */ + uint8_t nonmesh_max_connection; /**< max non-mesh connections */ } mesh_ap_cfg_t; /** @@ -947,7 +952,8 @@ esp_err_t esp_mesh_set_ap_authmode(wifi_auth_mode_t authmode); wifi_auth_mode_t esp_mesh_get_ap_authmode(void); /** - * @brief Set mesh softAP max connection value + * @brief Set mesh max connection value + * - Set mesh softAP max connection = mesh max connection + non-mesh max connection * * @attention This API shall be called before mesh is started. * @@ -960,12 +966,19 @@ wifi_auth_mode_t esp_mesh_get_ap_authmode(void); esp_err_t esp_mesh_set_ap_connections(int connections); /** - * @brief Get mesh softAP max connection configuration + * @brief Get mesh max connection configuration * - * @return the number of max connections + * @return the number of mesh max connections */ int esp_mesh_get_ap_connections(void); +/** + * @brief Get non-mesh max connection configuration + * + * @return the number of non-mesh max connections + */ +int esp_mesh_get_non_mesh_connections(void); + /** * @brief Get current layer value over the mesh network * diff --git a/tools/sdk/esp32s2/include/esp_wifi/include/esp_wifi.h b/tools/sdk/esp32s2/include/esp_wifi/include/esp_wifi.h index dfd43bff440..51e03234841 100644 --- a/tools/sdk/esp32s2/include/esp_wifi/include/esp_wifi.h +++ b/tools/sdk/esp32s2/include/esp_wifi/include/esp_wifi.h @@ -1224,7 +1224,7 @@ esp_err_t esp_wifi_config_11b_rate(wifi_interface_t ifx, bool disable); * @attention 1. This API should be called after esp_wifi_init() and before esp_wifi_start(). * * @param ifx Interface to be configured. - * @param rate Only support 1M, 6M and MCS0_LGI + * @param rate Phy rate to be configured. * * @return * - ESP_OK: succeed @@ -1289,6 +1289,20 @@ esp_err_t esp_wifi_set_country_code(const char *country, bool ieee80211d_enabled */ esp_err_t esp_wifi_get_country_code(char *country); +/** + * @brief Config 80211 tx rate of specified interface + * + * @attention 1. This API should be called after esp_wifi_init() and before esp_wifi_start(). + * + * @param ifx Interface to be configured. + * @param rate Phy rate to be configured. + * + * @return + * - ESP_OK: succeed + * - others: failed + */ +esp_err_t esp_wifi_config_80211_tx_rate(wifi_interface_t ifx, wifi_phy_rate_t rate); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32s2/include/esp_wifi/include/esp_wifi_default.h b/tools/sdk/esp32s2/include/esp_wifi/include/esp_wifi_default.h index 958977bf25e..908ea2c113c 100644 --- a/tools/sdk/esp32s2/include/esp_wifi/include/esp_wifi_default.h +++ b/tools/sdk/esp32s2/include/esp_wifi/include/esp_wifi_default.h @@ -50,7 +50,7 @@ esp_err_t esp_netif_attach_wifi_ap(esp_netif_t *esp_netif); esp_err_t esp_wifi_set_default_wifi_sta_handlers(void); /** - * @brief Sets default wifi event handlers for STA interface + * @brief Sets default wifi event handlers for AP interface * * @return * - ESP_OK on success, error returned from esp_event_handler_register if failed diff --git a/tools/sdk/esp32s2/include/esp_wifi/include/esp_wifi_types.h b/tools/sdk/esp32s2/include/esp_wifi/include/esp_wifi_types.h index 03b8ae6a75e..503e8d7bb05 100644 --- a/tools/sdk/esp32s2/include/esp_wifi/include/esp_wifi_types.h +++ b/tools/sdk/esp32s2/include/esp_wifi/include/esp_wifi_types.h @@ -272,7 +272,8 @@ typedef struct { uint32_t phy_11g:1; /**< bit: 1 flag to identify if 11g mode is enabled or not */ uint32_t phy_11n:1; /**< bit: 2 flag to identify if 11n mode is enabled or not */ uint32_t phy_lr:1; /**< bit: 3 flag to identify if low rate is enabled or not */ - uint32_t reserved:28; /**< bit: 4..31 reserved */ + uint32_t is_mesh_child:1;/**< bit: 4 flag to identify mesh child */ + uint32_t reserved:27; /**< bit: 5..31 reserved */ } wifi_sta_info_t; #define ESP_WIFI_MAX_CONN_NUM (10) /**< max number of stations which can connect to ESP32 soft-AP */ @@ -669,12 +670,14 @@ typedef struct { typedef struct { uint8_t mac[6]; /**< MAC address of the station connected to ESP32 soft-AP */ uint8_t aid; /**< the aid that ESP32 soft-AP gives to the station connected to */ + bool is_mesh_child; /**< flag to identify mesh child */ } wifi_event_ap_staconnected_t; /** Argument structure for WIFI_EVENT_AP_STADISCONNECTED event */ typedef struct { uint8_t mac[6]; /**< MAC address of the station disconnects to ESP32 soft-AP */ uint8_t aid; /**< the aid that ESP32 soft-AP gave to the station disconnects to */ + bool is_mesh_child; /**< flag to identify mesh child */ } wifi_event_ap_stadisconnected_t; /** Argument structure for WIFI_EVENT_AP_PROBEREQRECVED event */ diff --git a/tools/sdk/esp32s2/include/freemodbus/common/include/esp_modbus_master.h b/tools/sdk/esp32s2/include/freemodbus/common/include/esp_modbus_master.h index 621348e1933..5d7539b08d9 100644 --- a/tools/sdk/esp32s2/include/freemodbus/common/include/esp_modbus_master.h +++ b/tools/sdk/esp32s2/include/freemodbus/common/include/esp_modbus_master.h @@ -232,7 +232,7 @@ esp_err_t mbc_master_get_cid_info(uint16_t cid, const mb_parameter_descriptor_t* * @return * - esp_err_t ESP_OK - request was successful and value buffer contains * representation of actual parameter data from slave - * - esp_err_t ESP_ERR_INVALID_ARG - invalid argument of function + * - esp_err_t ESP_ERR_INVALID_ARG - invalid argument of function or parameter descriptor * - esp_err_t ESP_ERR_INVALID_RESPONSE - an invalid response from slave * - esp_err_t ESP_ERR_INVALID_STATE - invalid state during data processing or allocation failure * - esp_err_t ESP_ERR_TIMEOUT - operation timed out and no response from slave @@ -253,7 +253,7 @@ esp_err_t mbc_master_get_parameter(uint16_t cid, char* name, uint8_t* value, uin * * @return * - esp_err_t ESP_OK - request was successful and value was saved in the slave device registers - * - esp_err_t ESP_ERR_INVALID_ARG - invalid argument of function + * - esp_err_t ESP_ERR_INVALID_ARG - invalid argument of function or parameter descriptor * - esp_err_t ESP_ERR_INVALID_RESPONSE - an invalid response from slave during processing of parameter * - esp_err_t ESP_ERR_INVALID_STATE - invalid state during data processing or allocation failure * - esp_err_t ESP_ERR_TIMEOUT - operation timed out and no response from slave diff --git a/tools/sdk/esp32c3/include/freertos/include/freertos/FreeRTOSConfig.h b/tools/sdk/esp32s2/include/freertos/include/esp_additions/freertos/FreeRTOSConfig.h similarity index 95% rename from tools/sdk/esp32c3/include/freertos/include/freertos/FreeRTOSConfig.h rename to tools/sdk/esp32s2/include/freertos/include/esp_additions/freertos/FreeRTOSConfig.h index c64cb980d85..a01a56e9fd4 100644 --- a/tools/sdk/esp32c3/include/freertos/include/freertos/FreeRTOSConfig.h +++ b/tools/sdk/esp32s2/include/freertos/include/esp_additions/freertos/FreeRTOSConfig.h @@ -71,10 +71,16 @@ #define FREERTOS_CONFIG_H #include "sdkconfig.h" -// The arch-specific FreeRTOSConfig.h in port//include. -#include_next "freertos/FreeRTOSConfig.h" -#if !(defined(FREERTOS_CONFIG_XTENSA_H) || defined(FREERTOS_CONFIG_RISCV_H)) +/* for likely and unlikely */ +#include "esp_compiler.h" + +// The arch-specific FreeRTOSConfig_arch.h in port//include. +#include "freertos/FreeRTOSConfig_arch.h" + +#if !(defined(FREERTOS_CONFIG_XTENSA_H) \ + || defined(FREERTOS_CONFIG_RISCV_H) \ + || defined(FREERTOS_CONFIG_LINUX_H)) #error "Needs architecture-speific FreeRTOSConfig.h!" #endif @@ -244,7 +250,9 @@ kept at 1. */ #define configKERNEL_INTERRUPT_PRIORITY 1 +#if !CONFIG_IDF_TARGET_LINUX #define configUSE_NEWLIB_REENTRANT 1 +#endif #define configSUPPORT_DYNAMIC_ALLOCATION 1 #define configSUPPORT_STATIC_ALLOCATION 1 @@ -273,11 +281,11 @@ extern void vPortCleanUpTCB ( void *pxTCB ); #endif //configUSE_TICKLESS_IDLE -#if CONFIG_ESP_COREDUMP_ENABLE +#if CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT #define configENABLE_TASK_SNAPSHOT 1 #endif #ifndef configENABLE_TASK_SNAPSHOT -#define configENABLE_TASK_SNAPSHOT 1 +#define configENABLE_TASK_SNAPSHOT 0 #endif #if CONFIG_SYSVIEW_ENABLE @@ -293,4 +301,9 @@ extern void vPortCleanUpTCB ( void *pxTCB ); #define configCHECK_MUTEX_GIVEN_BY_OWNER 0 #endif + +#define configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H 1 + +#define configTASK_NOTIFICATION_ARRAY_ENTRIES 1 + #endif /* FREERTOS_CONFIG_H */ diff --git a/tools/sdk/esp32s2/include/freertos/include/esp_additions/freertos/task_snapshot.h b/tools/sdk/esp32s2/include/freertos/include/esp_additions/freertos/task_snapshot.h new file mode 100644 index 00000000000..1ad04cce694 --- /dev/null +++ b/tools/sdk/esp32s2/include/freertos/include/esp_additions/freertos/task_snapshot.h @@ -0,0 +1,90 @@ +// Copyright 2015-2021 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 "freertos/FreeRTOS.h" +#include "freertos/task.h" + +#if ( configENABLE_TASK_SNAPSHOT == 1 ) + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Check `freertos_tasks_c_additions.h` file for more info + * about these functions declaration. + */ +UBaseType_t pxTCBGetSize ( void ); +ListItem_t* pxTCBGetStateListItem ( void *pxTCB ); +StackType_t* pxTCBGetStartOfStack ( void *pxTCB ); +StackType_t* pxTCBGetTopOfStack ( void *pxTCB ); +StackType_t* pxTCBGetEndOfStack ( void *pxTCB ); +List_t* pxListGetReadyTask ( UBaseType_t idx ); +List_t* pxListGetReadyPendingTask ( UBaseType_t idx ); +List_t* pxGetDelayedTaskList ( void ); +List_t* pxGetOverflowDelayedTaskList ( void ); +List_t* pxGetTasksWaitingTermination ( void ); +List_t* pxGetSuspendedTaskList ( void ); + +/** + * 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*/ +} TaskSnapshot_t; + + +/* + * This function fills array with TaskSnapshot_t structures for every task in the system. + * Used by panic handling code to get snapshots of all tasks in the system. + * Only available when configENABLE_TASK_SNAPSHOT is set to 1. + * @param pxTaskSnapshotArray Pointer to array of TaskSnapshot_t structures to store tasks snapshot data. + * @param uxArraySize Size of tasks snapshots array. + * @param pxTcbSz Pointer to store size of TCB. + * @return Number of elements stored in array. + */ +UBaseType_t uxTaskGetSnapshotAll( TaskSnapshot_t * const pxTaskSnapshotArray, const UBaseType_t uxArraySize, UBaseType_t * const pxTcbSz ); + +/* + * This function iterates over all tasks in the system. + * Used by panic handling code to iterate over tasks in the system. + * Only available when configENABLE_TASK_SNAPSHOT is set to 1. + * @note This function should not be used while FreeRTOS is running (as it doesn't acquire any locks). + * @param pxTask task handle. + * @return Handle for the next task. If pxTask is NULL, returns hadnle for the first task. + */ +TaskHandle_t pxTaskGetNext( TaskHandle_t pxTask ); + +/* + * This function fills TaskSnapshot_t structure for specified task. + * Used by panic handling code to get snapshot of a task. + * Only available when configENABLE_TASK_SNAPSHOT is set to 1. + * @note This function should not be used while FreeRTOS is running (as it doesn't acquire any locks). + * @param pxTask task handle. + * @param pxTaskSnapshot address of TaskSnapshot_t structure to fill. + */ +void vTaskGetSnapshot( TaskHandle_t pxTask, TaskSnapshot_t *pxTaskSnapshot ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/tools/sdk/esp32s2/include/freertos/include/esp_additions/freertos_tasks_c_additions.h b/tools/sdk/esp32s2/include/freertos/include/esp_additions/freertos_tasks_c_additions.h new file mode 100644 index 00000000000..464c0b3ffb9 --- /dev/null +++ b/tools/sdk/esp32s2/include/freertos/include/esp_additions/freertos_tasks_c_additions.h @@ -0,0 +1,80 @@ +// Copyright 2015-2021 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 + +/** + * This file will be included in `tasks.c` file, thus, it must NOT be included + * by any (other) file. + * The functions below only consist in getters for the static variables in + * `tasks.c` file. + * The only source files that should call these functions are the ones in + * `/additions` directory. + */ + +#if ( configENABLE_TASK_SNAPSHOT == 1 ) + + UBaseType_t pxTCBGetSize ( void ) + { + return sizeof(TCB_t); + } + + ListItem_t* pxTCBGetStateListItem ( void *pxTCB ) + { + return &(((TCB_t*)pxTCB)->xStateListItem); + } + + StackType_t* pxTCBGetStartOfStack ( void *pxTCB ) + { + return (StackType_t*) ((TCB_t*)pxTCB)->pxStack; + } + + StackType_t* pxTCBGetTopOfStack ( void *pxTCB ) + { + return (StackType_t*) ((TCB_t*)pxTCB)->pxTopOfStack; + } + + StackType_t* pxTCBGetEndOfStack ( void *pxTCB ) + { + return (StackType_t*) ((TCB_t*)pxTCB)->pxEndOfStack; + } + + + List_t* pxListGetReadyTask ( UBaseType_t idx ) + { + return &( pxReadyTasksLists[idx] ); + } + + List_t* pxListGetReadyPendingTask ( UBaseType_t idx ) + { + return &( xPendingReadyList[idx] ); + } + + List_t* pxGetDelayedTaskList ( void ) { + return pxDelayedTaskList; + } + + List_t* pxGetOverflowDelayedTaskList ( void ) { + return pxOverflowDelayedTaskList; + } + + List_t* pxGetTasksWaitingTermination ( void ) { + return &xTasksWaitingTermination; + } + + List_t* pxGetSuspendedTaskList ( void ) { + return &xSuspendedTaskList; + } + +#endif diff --git a/tools/sdk/esp32s2/include/freertos/include/freertos/FreeRTOS.h b/tools/sdk/esp32s2/include/freertos/include/freertos/FreeRTOS.h index 2c9c5b13d00..eb0ee6be357 100644 --- a/tools/sdk/esp32s2/include/freertos/include/freertos/FreeRTOS.h +++ b/tools/sdk/esp32s2/include/freertos/include/freertos/FreeRTOS.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ #ifndef INC_FREERTOS_H @@ -46,16 +45,16 @@ * contains the typedefs required to build FreeRTOS. Read the instructions * in FreeRTOS/source/stdint.readme for more information. */ -#include /* READ COMMENT ABOVE. */ +#include /* READ COMMENT ABOVE. */ +/* *INDENT-OFF* */ #ifdef __cplusplus -extern "C" { + extern "C" { #endif -/* for likely and unlikely */ -#include "esp_compiler.h" +/* *INDENT-ON* */ /* Application specific configuration options. */ -#include "freertos/FreeRTOSConfig.h" +#include "FreeRTOSConfig.h" /* Basic FreeRTOS definitions. */ #include "projdefs.h" @@ -65,13 +64,14 @@ extern "C" { /* Must be defaulted before configUSE_NEWLIB_REENTRANT is used below. */ #ifndef configUSE_NEWLIB_REENTRANT - #define configUSE_NEWLIB_REENTRANT 0 + #define configUSE_NEWLIB_REENTRANT 0 #endif /* Required if struct _reent is used. */ #if ( configUSE_NEWLIB_REENTRANT == 1 ) - #include + #include #endif + /* * Check all the required application specific macros have been defined. * These macros are application specific and (as downloaded) are defined @@ -79,503 +79,545 @@ extern "C" { */ #ifndef configMINIMAL_STACK_SIZE - #error Missing definition: configMINIMAL_STACK_SIZE must be defined in FreeRTOSConfig.h. configMINIMAL_STACK_SIZE defines the size (in words) of the stack allocated to the idle task. Refer to the demo project provided for your port for a suitable value. + #error Missing definition: configMINIMAL_STACK_SIZE must be defined in FreeRTOSConfig.h. configMINIMAL_STACK_SIZE defines the size (in words) of the stack allocated to the idle task. Refer to the demo project provided for your port for a suitable value. #endif #ifndef configMAX_PRIORITIES - #error Missing definition: configMAX_PRIORITIES must be defined in FreeRTOSConfig.h. See the Configuration section of the FreeRTOS API documentation for details. + #error Missing definition: configMAX_PRIORITIES must be defined in FreeRTOSConfig.h. See the Configuration section of the FreeRTOS API documentation for details. #endif #if configMAX_PRIORITIES < 1 - #error configMAX_PRIORITIES must be defined to be greater than or equal to 1. + #error configMAX_PRIORITIES must be defined to be greater than or equal to 1. #endif #ifndef configUSE_PREEMPTION - #error Missing definition: configUSE_PREEMPTION must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. + #error Missing definition: configUSE_PREEMPTION must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. #endif #ifndef configUSE_IDLE_HOOK - #error Missing definition: configUSE_IDLE_HOOK must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. + #error Missing definition: configUSE_IDLE_HOOK must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. #endif #ifndef configUSE_TICK_HOOK - #error Missing definition: configUSE_TICK_HOOK must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. + #error Missing definition: configUSE_TICK_HOOK must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. #endif #ifndef configUSE_16_BIT_TICKS - #error Missing definition: configUSE_16_BIT_TICKS must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. + #error Missing definition: configUSE_16_BIT_TICKS must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details. #endif #ifndef configUSE_CO_ROUTINES - #define configUSE_CO_ROUTINES 0 + #define configUSE_CO_ROUTINES 0 #endif #ifndef INCLUDE_vTaskPrioritySet - #define INCLUDE_vTaskPrioritySet 0 + #define INCLUDE_vTaskPrioritySet 0 #endif #ifndef INCLUDE_uxTaskPriorityGet - #define INCLUDE_uxTaskPriorityGet 0 + #define INCLUDE_uxTaskPriorityGet 0 #endif #ifndef INCLUDE_vTaskDelete - #define INCLUDE_vTaskDelete 0 + #define INCLUDE_vTaskDelete 0 #endif #ifndef INCLUDE_vTaskSuspend - #define INCLUDE_vTaskSuspend 0 + #define INCLUDE_vTaskSuspend 0 +#endif + +#ifdef INCLUDE_xTaskDelayUntil + #ifdef INCLUDE_vTaskDelayUntil + /* INCLUDE_vTaskDelayUntil was replaced by INCLUDE_xTaskDelayUntil. Backward + * compatibility is maintained if only one or the other is defined, but + * there is a conflict if both are defined. */ + #error INCLUDE_vTaskDelayUntil and INCLUDE_xTaskDelayUntil are both defined. INCLUDE_vTaskDelayUntil is no longer required and should be removed + #endif #endif -#ifndef INCLUDE_vTaskDelayUntil - #define INCLUDE_vTaskDelayUntil 0 +#ifndef INCLUDE_xTaskDelayUntil + #ifdef INCLUDE_vTaskDelayUntil + /* If INCLUDE_vTaskDelayUntil is set but INCLUDE_xTaskDelayUntil is not then + * the project's FreeRTOSConfig.h probably pre-dates the introduction of + * xTaskDelayUntil and setting INCLUDE_xTaskDelayUntil to whatever + * INCLUDE_vTaskDelayUntil is set to will ensure backward compatibility. + */ + #define INCLUDE_xTaskDelayUntil INCLUDE_vTaskDelayUntil + #endif +#endif + +#ifndef INCLUDE_xTaskDelayUntil + #define INCLUDE_xTaskDelayUntil 0 #endif #ifndef INCLUDE_vTaskDelay - #define INCLUDE_vTaskDelay 0 + #define INCLUDE_vTaskDelay 0 #endif #ifndef INCLUDE_xTaskGetIdleTaskHandle - #define INCLUDE_xTaskGetIdleTaskHandle 0 + #define INCLUDE_xTaskGetIdleTaskHandle 0 #endif #ifndef INCLUDE_xTaskAbortDelay - #define INCLUDE_xTaskAbortDelay 0 + #define INCLUDE_xTaskAbortDelay 0 #endif #ifndef INCLUDE_xQueueGetMutexHolder - #define INCLUDE_xQueueGetMutexHolder 0 + #define INCLUDE_xQueueGetMutexHolder 0 #endif #ifndef INCLUDE_xSemaphoreGetMutexHolder - #define INCLUDE_xSemaphoreGetMutexHolder INCLUDE_xQueueGetMutexHolder + #define INCLUDE_xSemaphoreGetMutexHolder INCLUDE_xQueueGetMutexHolder #endif #ifndef INCLUDE_xTaskGetHandle - #define INCLUDE_xTaskGetHandle 0 + #define INCLUDE_xTaskGetHandle 0 #endif #ifndef INCLUDE_uxTaskGetStackHighWaterMark - #define INCLUDE_uxTaskGetStackHighWaterMark 0 + #define INCLUDE_uxTaskGetStackHighWaterMark 0 #endif #ifndef INCLUDE_uxTaskGetStackHighWaterMark2 - #define INCLUDE_uxTaskGetStackHighWaterMark2 0 + #define INCLUDE_uxTaskGetStackHighWaterMark2 0 #endif #ifndef INCLUDE_eTaskGetState - #define INCLUDE_eTaskGetState 0 + #define INCLUDE_eTaskGetState 0 #endif #ifndef INCLUDE_xTaskResumeFromISR - #define INCLUDE_xTaskResumeFromISR 1 + #define INCLUDE_xTaskResumeFromISR 1 #endif #ifndef INCLUDE_xTimerPendFunctionCall - #define INCLUDE_xTimerPendFunctionCall 0 + #define INCLUDE_xTimerPendFunctionCall 0 #endif #ifndef INCLUDE_xTaskGetSchedulerState - #define INCLUDE_xTaskGetSchedulerState 0 + #define INCLUDE_xTaskGetSchedulerState 0 #endif #ifndef INCLUDE_xTaskGetCurrentTaskHandle - #define INCLUDE_xTaskGetCurrentTaskHandle 0 + #define INCLUDE_xTaskGetCurrentTaskHandle 0 #endif #if configUSE_CO_ROUTINES != 0 - #ifndef configMAX_CO_ROUTINE_PRIORITIES - #error configMAX_CO_ROUTINE_PRIORITIES must be greater than or equal to 1. - #endif + #ifndef configMAX_CO_ROUTINE_PRIORITIES + #error configMAX_CO_ROUTINE_PRIORITIES must be greater than or equal to 1. + #endif #endif #ifndef configUSE_DAEMON_TASK_STARTUP_HOOK - #define configUSE_DAEMON_TASK_STARTUP_HOOK 0 + #define configUSE_DAEMON_TASK_STARTUP_HOOK 0 #endif #ifndef configUSE_APPLICATION_TASK_TAG - #define configUSE_APPLICATION_TASK_TAG 0 + #define configUSE_APPLICATION_TASK_TAG 0 #endif #ifndef configNUM_THREAD_LOCAL_STORAGE_POINTERS - #define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0 + #define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0 #endif #ifndef configUSE_RECURSIVE_MUTEXES - #define configUSE_RECURSIVE_MUTEXES 0 + #define configUSE_RECURSIVE_MUTEXES 0 #endif #ifndef configUSE_MUTEXES - #define configUSE_MUTEXES 0 + #define configUSE_MUTEXES 0 #endif #ifndef configUSE_TIMERS - #define configUSE_TIMERS 0 + #define configUSE_TIMERS 0 #endif #ifndef configUSE_COUNTING_SEMAPHORES - #define configUSE_COUNTING_SEMAPHORES 0 + #define configUSE_COUNTING_SEMAPHORES 0 #endif #ifndef configUSE_ALTERNATIVE_API - #define configUSE_ALTERNATIVE_API 0 + #define configUSE_ALTERNATIVE_API 0 #endif #ifndef portCRITICAL_NESTING_IN_TCB - #define portCRITICAL_NESTING_IN_TCB 0 + #define portCRITICAL_NESTING_IN_TCB 0 #endif #ifndef configMAX_TASK_NAME_LEN - #define configMAX_TASK_NAME_LEN 16 + #define configMAX_TASK_NAME_LEN 16 #endif #ifndef configIDLE_SHOULD_YIELD - #define configIDLE_SHOULD_YIELD 1 + #define configIDLE_SHOULD_YIELD 1 #endif #if configMAX_TASK_NAME_LEN < 1 - #error configMAX_TASK_NAME_LEN must be set to a minimum of 1 in FreeRTOSConfig.h + #error configMAX_TASK_NAME_LEN must be set to a minimum of 1 in FreeRTOSConfig.h #endif #ifndef configASSERT - #define configASSERT( x ) - #define configASSERT_DEFINED 0 + #define configASSERT( x ) + #define configASSERT_DEFINED 0 #else - #define configASSERT_DEFINED 1 + #define configASSERT_DEFINED 1 #endif -/* configPRECONDITION should be resolve to configASSERT. - The CBMC proofs need a way to track assumptions and assertions. - A configPRECONDITION statement should express an implicit invariant or assumption made. - A configASSERT statement should express an invariant that must hold explicit before calling - the code. */ +/* configPRECONDITION should be defined as configASSERT. + * The CBMC proofs need a way to track assumptions and assertions. + * A configPRECONDITION statement should express an implicit invariant or + * assumption made. A configASSERT statement should express an invariant that must + * hold explicit before calling the code. */ #ifndef configPRECONDITION - #define configPRECONDITION( X ) configASSERT(X) - #define configPRECONDITION_DEFINED 0 + #define configPRECONDITION( X ) configASSERT( X ) + #define configPRECONDITION_DEFINED 0 #else - #define configPRECONDITION_DEFINED 1 + #define configPRECONDITION_DEFINED 1 #endif #ifndef portMEMORY_BARRIER - #define portMEMORY_BARRIER() + #define portMEMORY_BARRIER() +#endif + +#ifndef portSOFTWARE_BARRIER + #define portSOFTWARE_BARRIER() #endif /* The timers module relies on xTaskGetSchedulerState(). */ #if configUSE_TIMERS == 1 - #ifndef configTIMER_TASK_PRIORITY - #error If configUSE_TIMERS is set to 1 then configTIMER_TASK_PRIORITY must also be defined. - #endif /* configTIMER_TASK_PRIORITY */ + #ifndef configTIMER_TASK_PRIORITY + #error If configUSE_TIMERS is set to 1 then configTIMER_TASK_PRIORITY must also be defined. + #endif /* configTIMER_TASK_PRIORITY */ - #ifndef configTIMER_QUEUE_LENGTH - #error If configUSE_TIMERS is set to 1 then configTIMER_QUEUE_LENGTH must also be defined. - #endif /* configTIMER_QUEUE_LENGTH */ + #ifndef configTIMER_QUEUE_LENGTH + #error If configUSE_TIMERS is set to 1 then configTIMER_QUEUE_LENGTH must also be defined. + #endif /* configTIMER_QUEUE_LENGTH */ - #ifndef configTIMER_TASK_STACK_DEPTH - #error If configUSE_TIMERS is set to 1 then configTIMER_TASK_STACK_DEPTH must also be defined. - #endif /* configTIMER_TASK_STACK_DEPTH */ + #ifndef configTIMER_TASK_STACK_DEPTH + #error If configUSE_TIMERS is set to 1 then configTIMER_TASK_STACK_DEPTH must also be defined. + #endif /* configTIMER_TASK_STACK_DEPTH */ #endif /* configUSE_TIMERS */ #ifndef portSET_INTERRUPT_MASK_FROM_ISR - #define portSET_INTERRUPT_MASK_FROM_ISR() 0 + #define portSET_INTERRUPT_MASK_FROM_ISR() 0 #endif #ifndef portCLEAR_INTERRUPT_MASK_FROM_ISR - #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusValue ) ( void ) uxSavedStatusValue + #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusValue ) ( void ) uxSavedStatusValue #endif #ifndef portCLEAN_UP_TCB - #define portCLEAN_UP_TCB( pxTCB ) ( void ) pxTCB + #define portCLEAN_UP_TCB( pxTCB ) ( void ) pxTCB #endif #ifndef portPRE_TASK_DELETE_HOOK - #define portPRE_TASK_DELETE_HOOK( pvTaskToDelete, pxYieldPending ) + #define portPRE_TASK_DELETE_HOOK( pvTaskToDelete, pxYieldPending ) #endif #ifndef portSETUP_TCB - #define portSETUP_TCB( pxTCB ) ( void ) pxTCB + #define portSETUP_TCB( pxTCB ) ( void ) pxTCB #endif #ifndef configQUEUE_REGISTRY_SIZE - #define configQUEUE_REGISTRY_SIZE 0U + #define configQUEUE_REGISTRY_SIZE 0U #endif #if ( configQUEUE_REGISTRY_SIZE < 1 ) - #define vQueueAddToRegistry( xQueue, pcName ) - #define vQueueUnregisterQueue( xQueue ) - #define pcQueueGetName( xQueue ) + #define vQueueAddToRegistry( xQueue, pcName ) + #define vQueueUnregisterQueue( xQueue ) + #define pcQueueGetName( xQueue ) #endif #ifndef portPOINTER_SIZE_TYPE - #define portPOINTER_SIZE_TYPE uint32_t + #define portPOINTER_SIZE_TYPE uint32_t #endif /* Remove any unused trace macros. */ #ifndef traceSTART - /* Used to perform any necessary initialisation - for example, open a file - into which trace is to be written. */ - #define traceSTART() + +/* Used to perform any necessary initialisation - for example, open a file + * into which trace is to be written. */ + #define traceSTART() #endif #ifndef traceEND - /* Use to close a trace, for example close a file into which trace has been - written. */ - #define traceEND() + +/* Use to close a trace, for example close a file into which trace has been + * written. */ + #define traceEND() #endif #ifndef traceTASK_SWITCHED_IN - /* Called after a task has been selected to run. pxCurrentTCB holds a pointer - to the task control block of the selected task. */ - #define traceTASK_SWITCHED_IN() + +/* Called after a task has been selected to run. pxCurrentTCB holds a pointer + * to the task control block of the selected task. */ + #define traceTASK_SWITCHED_IN() #endif #ifndef traceINCREASE_TICK_COUNT - /* Called before stepping the tick count after waking from tickless idle - sleep. */ - #define traceINCREASE_TICK_COUNT( x ) + +/* Called before stepping the tick count after waking from tickless idle + * sleep. */ + #define traceINCREASE_TICK_COUNT( x ) #endif #ifndef traceLOW_POWER_IDLE_BEGIN - /* Called immediately before entering tickless idle. */ - #define traceLOW_POWER_IDLE_BEGIN() + /* Called immediately before entering tickless idle. */ + #define traceLOW_POWER_IDLE_BEGIN() #endif -#ifndef traceLOW_POWER_IDLE_END - /* Called when returning to the Idle task after a tickless idle. */ - #define traceLOW_POWER_IDLE_END() +#ifndef traceLOW_POWER_IDLE_END + /* Called when returning to the Idle task after a tickless idle. */ + #define traceLOW_POWER_IDLE_END() #endif #ifndef traceTASK_SWITCHED_OUT - /* Called before a task has been selected to run. pxCurrentTCB holds a pointer - to the task control block of the task being switched out. */ - #define traceTASK_SWITCHED_OUT() + +/* Called before a task has been selected to run. pxCurrentTCB holds a pointer + * to the task control block of the task being switched out. */ + #define traceTASK_SWITCHED_OUT() #endif #ifndef traceTASK_PRIORITY_INHERIT - /* Called when a task attempts to take a mutex that is already held by a - lower priority task. pxTCBOfMutexHolder is a pointer to the TCB of the task - that holds the mutex. uxInheritedPriority is the priority the mutex holder - will inherit (the priority of the task that is attempting to obtain the - muted. */ - #define traceTASK_PRIORITY_INHERIT( pxTCBOfMutexHolder, uxInheritedPriority ) + +/* Called when a task attempts to take a mutex that is already held by a + * lower priority task. pxTCBOfMutexHolder is a pointer to the TCB of the task + * that holds the mutex. uxInheritedPriority is the priority the mutex holder + * will inherit (the priority of the task that is attempting to obtain the + * muted. */ + #define traceTASK_PRIORITY_INHERIT( pxTCBOfMutexHolder, uxInheritedPriority ) #endif #ifndef traceTASK_PRIORITY_DISINHERIT - /* Called when a task releases a mutex, the holding of which had resulted in - the task inheriting the priority of a higher priority task. - pxTCBOfMutexHolder is a pointer to the TCB of the task that is releasing the - mutex. uxOriginalPriority is the task's configured (base) priority. */ - #define traceTASK_PRIORITY_DISINHERIT( pxTCBOfMutexHolder, uxOriginalPriority ) + +/* Called when a task releases a mutex, the holding of which had resulted in + * the task inheriting the priority of a higher priority task. + * pxTCBOfMutexHolder is a pointer to the TCB of the task that is releasing the + * mutex. uxOriginalPriority is the task's configured (base) priority. */ + #define traceTASK_PRIORITY_DISINHERIT( pxTCBOfMutexHolder, uxOriginalPriority ) #endif #ifndef traceBLOCKING_ON_QUEUE_RECEIVE - /* Task is about to block because it cannot read from a - queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore - upon which the read was attempted. pxCurrentTCB points to the TCB of the - task that attempted the read. */ - #define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ) + +/* Task is about to block because it cannot read from a + * queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore + * upon which the read was attempted. pxCurrentTCB points to the TCB of the + * task that attempted the read. */ + #define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ) #endif #ifndef traceBLOCKING_ON_QUEUE_PEEK - /* Task is about to block because it cannot read from a - queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore - upon which the read was attempted. pxCurrentTCB points to the TCB of the - task that attempted the read. */ - #define traceBLOCKING_ON_QUEUE_PEEK( pxQueue ) + +/* Task is about to block because it cannot read from a + * queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore + * upon which the read was attempted. pxCurrentTCB points to the TCB of the + * task that attempted the read. */ + #define traceBLOCKING_ON_QUEUE_PEEK( pxQueue ) #endif #ifndef traceBLOCKING_ON_QUEUE_SEND - /* Task is about to block because it cannot write to a - queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore - upon which the write was attempted. pxCurrentTCB points to the TCB of the - task that attempted the write. */ - #define traceBLOCKING_ON_QUEUE_SEND( pxQueue ) + +/* Task is about to block because it cannot write to a + * queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore + * upon which the write was attempted. pxCurrentTCB points to the TCB of the + * task that attempted the write. */ + #define traceBLOCKING_ON_QUEUE_SEND( pxQueue ) #endif #ifndef configCHECK_FOR_STACK_OVERFLOW - #define configCHECK_FOR_STACK_OVERFLOW 0 + #define configCHECK_FOR_STACK_OVERFLOW 0 #endif #ifndef configRECORD_STACK_HIGH_ADDRESS - #define configRECORD_STACK_HIGH_ADDRESS 0 + #define configRECORD_STACK_HIGH_ADDRESS 0 #endif #ifndef configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H - #define configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H 0 + #define configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H 0 #endif /* The following event macros are embedded in the kernel API calls. */ #ifndef traceMOVED_TASK_TO_READY_STATE - #define traceMOVED_TASK_TO_READY_STATE( pxTCB ) + #define traceMOVED_TASK_TO_READY_STATE( pxTCB ) #endif #ifndef tracePOST_MOVED_TASK_TO_READY_STATE - #define tracePOST_MOVED_TASK_TO_READY_STATE( pxTCB ) + #define tracePOST_MOVED_TASK_TO_READY_STATE( pxTCB ) #endif #ifndef traceQUEUE_CREATE - #define traceQUEUE_CREATE( pxNewQueue ) + #define traceQUEUE_CREATE( pxNewQueue ) #endif #ifndef traceQUEUE_CREATE_FAILED - #define traceQUEUE_CREATE_FAILED( ucQueueType ) + #define traceQUEUE_CREATE_FAILED( ucQueueType ) #endif #ifndef traceCREATE_MUTEX - #define traceCREATE_MUTEX( pxNewQueue ) + #define traceCREATE_MUTEX( pxNewQueue ) #endif #ifndef traceCREATE_MUTEX_FAILED - #define traceCREATE_MUTEX_FAILED() + #define traceCREATE_MUTEX_FAILED() #endif #ifndef traceGIVE_MUTEX_RECURSIVE - #define traceGIVE_MUTEX_RECURSIVE( pxMutex ) + #define traceGIVE_MUTEX_RECURSIVE( pxMutex ) #endif #ifndef traceGIVE_MUTEX_RECURSIVE_FAILED - #define traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex ) + #define traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex ) #endif #ifndef traceTAKE_MUTEX_RECURSIVE - #define traceTAKE_MUTEX_RECURSIVE( pxMutex ) + #define traceTAKE_MUTEX_RECURSIVE( pxMutex ) #endif #ifndef traceTAKE_MUTEX_RECURSIVE_FAILED - #define traceTAKE_MUTEX_RECURSIVE_FAILED( pxMutex ) + #define traceTAKE_MUTEX_RECURSIVE_FAILED( pxMutex ) #endif #ifndef traceCREATE_COUNTING_SEMAPHORE - #define traceCREATE_COUNTING_SEMAPHORE() + #define traceCREATE_COUNTING_SEMAPHORE() #endif #ifndef traceCREATE_COUNTING_SEMAPHORE_FAILED - #define traceCREATE_COUNTING_SEMAPHORE_FAILED() + #define traceCREATE_COUNTING_SEMAPHORE_FAILED() #endif +#ifndef traceQUEUE_SET_SEND + #define traceQUEUE_SET_SEND traceQUEUE_SEND +#endif + +#ifdef ESP_PLATFORM #ifndef traceQUEUE_SEMAPHORE_RECEIVE - #define traceQUEUE_SEMAPHORE_RECEIVE( pxQueue ) + #define traceQUEUE_SEMAPHORE_RECEIVE( pxQueue ) #endif +#endif // ESP_PLATFORM #ifndef traceQUEUE_SEND - #define traceQUEUE_SEND( pxQueue ) + #define traceQUEUE_SEND( pxQueue ) #endif #ifndef traceQUEUE_SEND_FAILED - #define traceQUEUE_SEND_FAILED( pxQueue ) + #define traceQUEUE_SEND_FAILED( pxQueue ) #endif #ifndef traceQUEUE_RECEIVE - #define traceQUEUE_RECEIVE( pxQueue ) + #define traceQUEUE_RECEIVE( pxQueue ) #endif #ifndef traceQUEUE_PEEK - #define traceQUEUE_PEEK( pxQueue ) + #define traceQUEUE_PEEK( pxQueue ) #endif #ifndef traceQUEUE_PEEK_FAILED - #define traceQUEUE_PEEK_FAILED( pxQueue ) + #define traceQUEUE_PEEK_FAILED( pxQueue ) #endif #ifndef traceQUEUE_PEEK_FROM_ISR - #define traceQUEUE_PEEK_FROM_ISR( pxQueue ) + #define traceQUEUE_PEEK_FROM_ISR( pxQueue ) #endif #ifndef traceQUEUE_RECEIVE_FAILED - #define traceQUEUE_RECEIVE_FAILED( pxQueue ) + #define traceQUEUE_RECEIVE_FAILED( pxQueue ) #endif #ifndef traceQUEUE_SEND_FROM_ISR - #define traceQUEUE_SEND_FROM_ISR( pxQueue ) + #define traceQUEUE_SEND_FROM_ISR( pxQueue ) #endif #ifndef traceQUEUE_SEND_FROM_ISR_FAILED - #define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ) + #define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ) #endif #ifndef traceQUEUE_RECEIVE_FROM_ISR - #define traceQUEUE_RECEIVE_FROM_ISR( pxQueue ) + #define traceQUEUE_RECEIVE_FROM_ISR( pxQueue ) #endif #ifndef traceQUEUE_RECEIVE_FROM_ISR_FAILED - #define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue ) + #define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue ) #endif #ifndef traceQUEUE_PEEK_FROM_ISR_FAILED - #define traceQUEUE_PEEK_FROM_ISR_FAILED( pxQueue ) + #define traceQUEUE_PEEK_FROM_ISR_FAILED( pxQueue ) #endif #ifndef traceQUEUE_DELETE - #define traceQUEUE_DELETE( pxQueue ) + #define traceQUEUE_DELETE( pxQueue ) #endif +#ifdef ESP_PLATFORM #ifndef traceQUEUE_GIVE_FROM_ISR - #define traceQUEUE_GIVE_FROM_ISR( pxQueue ) + #define traceQUEUE_GIVE_FROM_ISR( pxQueue ) #endif #ifndef traceQUEUE_GIVE_FROM_ISR_FAILED - #define traceQUEUE_GIVE_FROM_ISR_FAILED( pxQueue ) + #define traceQUEUE_GIVE_FROM_ISR_FAILED( pxQueue ) #endif +#endif // ESP_PLATFORM #ifndef traceTASK_CREATE - #define traceTASK_CREATE( pxNewTCB ) + #define traceTASK_CREATE( pxNewTCB ) #endif #ifndef traceTASK_CREATE_FAILED - #define traceTASK_CREATE_FAILED() + #define traceTASK_CREATE_FAILED() #endif #ifndef traceTASK_DELETE - #define traceTASK_DELETE( pxTaskToDelete ) + #define traceTASK_DELETE( pxTaskToDelete ) #endif #ifndef traceTASK_DELAY_UNTIL - #define traceTASK_DELAY_UNTIL( x ) + #define traceTASK_DELAY_UNTIL( x ) #endif #ifndef traceTASK_DELAY - #define traceTASK_DELAY() + #define traceTASK_DELAY() #endif #ifndef traceTASK_PRIORITY_SET - #define traceTASK_PRIORITY_SET( pxTask, uxNewPriority ) + #define traceTASK_PRIORITY_SET( pxTask, uxNewPriority ) #endif #ifndef traceTASK_SUSPEND - #define traceTASK_SUSPEND( pxTaskToSuspend ) + #define traceTASK_SUSPEND( pxTaskToSuspend ) #endif #ifndef traceTASK_RESUME - #define traceTASK_RESUME( pxTaskToResume ) + #define traceTASK_RESUME( pxTaskToResume ) #endif #ifndef traceTASK_RESUME_FROM_ISR - #define traceTASK_RESUME_FROM_ISR( pxTaskToResume ) + #define traceTASK_RESUME_FROM_ISR( pxTaskToResume ) #endif #ifndef traceTASK_INCREMENT_TICK - #define traceTASK_INCREMENT_TICK( xTickCount ) + #define traceTASK_INCREMENT_TICK( xTickCount ) #endif #ifndef traceTIMER_CREATE - #define traceTIMER_CREATE( pxNewTimer ) + #define traceTIMER_CREATE( pxNewTimer ) #endif #ifndef traceTIMER_CREATE_FAILED - #define traceTIMER_CREATE_FAILED() + #define traceTIMER_CREATE_FAILED() #endif #ifndef traceTIMER_COMMAND_SEND - #define traceTIMER_COMMAND_SEND( xTimer, xMessageID, xMessageValueValue, xReturn ) + #define traceTIMER_COMMAND_SEND( xTimer, xMessageID, xMessageValueValue, xReturn ) #endif #ifndef traceTIMER_EXPIRED - #define traceTIMER_EXPIRED( pxTimer ) + #define traceTIMER_EXPIRED( pxTimer ) #endif #ifndef traceTIMER_COMMAND_RECEIVED - #define traceTIMER_COMMAND_RECEIVED( pxTimer, xMessageID, xMessageValue ) + #define traceTIMER_COMMAND_RECEIVED( pxTimer, xMessageID, xMessageValue ) #endif #ifndef traceMALLOC @@ -587,445 +629,470 @@ extern "C" { #endif #ifndef traceEVENT_GROUP_CREATE - #define traceEVENT_GROUP_CREATE( xEventGroup ) + #define traceEVENT_GROUP_CREATE( xEventGroup ) #endif #ifndef traceEVENT_GROUP_CREATE_FAILED - #define traceEVENT_GROUP_CREATE_FAILED() + #define traceEVENT_GROUP_CREATE_FAILED() #endif #ifndef traceEVENT_GROUP_SYNC_BLOCK - #define traceEVENT_GROUP_SYNC_BLOCK( xEventGroup, uxBitsToSet, uxBitsToWaitFor ) + #define traceEVENT_GROUP_SYNC_BLOCK( xEventGroup, uxBitsToSet, uxBitsToWaitFor ) #endif #ifndef traceEVENT_GROUP_SYNC_END - #define traceEVENT_GROUP_SYNC_END( xEventGroup, uxBitsToSet, uxBitsToWaitFor, xTimeoutOccurred ) ( void ) xTimeoutOccurred + #define traceEVENT_GROUP_SYNC_END( xEventGroup, uxBitsToSet, uxBitsToWaitFor, xTimeoutOccurred ) ( void ) xTimeoutOccurred #endif #ifndef traceEVENT_GROUP_WAIT_BITS_BLOCK - #define traceEVENT_GROUP_WAIT_BITS_BLOCK( xEventGroup, uxBitsToWaitFor ) + #define traceEVENT_GROUP_WAIT_BITS_BLOCK( xEventGroup, uxBitsToWaitFor ) #endif #ifndef traceEVENT_GROUP_WAIT_BITS_END - #define traceEVENT_GROUP_WAIT_BITS_END( xEventGroup, uxBitsToWaitFor, xTimeoutOccurred ) ( void ) xTimeoutOccurred + #define traceEVENT_GROUP_WAIT_BITS_END( xEventGroup, uxBitsToWaitFor, xTimeoutOccurred ) ( void ) xTimeoutOccurred #endif #ifndef traceEVENT_GROUP_CLEAR_BITS - #define traceEVENT_GROUP_CLEAR_BITS( xEventGroup, uxBitsToClear ) + #define traceEVENT_GROUP_CLEAR_BITS( xEventGroup, uxBitsToClear ) #endif #ifndef traceEVENT_GROUP_CLEAR_BITS_FROM_ISR - #define traceEVENT_GROUP_CLEAR_BITS_FROM_ISR( xEventGroup, uxBitsToClear ) + #define traceEVENT_GROUP_CLEAR_BITS_FROM_ISR( xEventGroup, uxBitsToClear ) #endif #ifndef traceEVENT_GROUP_SET_BITS - #define traceEVENT_GROUP_SET_BITS( xEventGroup, uxBitsToSet ) + #define traceEVENT_GROUP_SET_BITS( xEventGroup, uxBitsToSet ) #endif #ifndef traceEVENT_GROUP_SET_BITS_FROM_ISR - #define traceEVENT_GROUP_SET_BITS_FROM_ISR( xEventGroup, uxBitsToSet ) + #define traceEVENT_GROUP_SET_BITS_FROM_ISR( xEventGroup, uxBitsToSet ) #endif #ifndef traceEVENT_GROUP_DELETE - #define traceEVENT_GROUP_DELETE( xEventGroup ) + #define traceEVENT_GROUP_DELETE( xEventGroup ) #endif #ifndef tracePEND_FUNC_CALL - #define tracePEND_FUNC_CALL(xFunctionToPend, pvParameter1, ulParameter2, ret) + #define tracePEND_FUNC_CALL( xFunctionToPend, pvParameter1, ulParameter2, ret ) #endif #ifndef tracePEND_FUNC_CALL_FROM_ISR - #define tracePEND_FUNC_CALL_FROM_ISR(xFunctionToPend, pvParameter1, ulParameter2, ret) + #define tracePEND_FUNC_CALL_FROM_ISR( xFunctionToPend, pvParameter1, ulParameter2, ret ) #endif #ifndef traceQUEUE_REGISTRY_ADD - #define traceQUEUE_REGISTRY_ADD(xQueue, pcQueueName) + #define traceQUEUE_REGISTRY_ADD( xQueue, pcQueueName ) #endif #ifndef traceTASK_NOTIFY_TAKE_BLOCK - #define traceTASK_NOTIFY_TAKE_BLOCK() + #define traceTASK_NOTIFY_TAKE_BLOCK( uxIndexToWait ) #endif #ifndef traceTASK_NOTIFY_TAKE - #define traceTASK_NOTIFY_TAKE() + #define traceTASK_NOTIFY_TAKE( uxIndexToWait ) #endif #ifndef traceTASK_NOTIFY_WAIT_BLOCK - #define traceTASK_NOTIFY_WAIT_BLOCK() + #define traceTASK_NOTIFY_WAIT_BLOCK( uxIndexToWait ) #endif #ifndef traceTASK_NOTIFY_WAIT - #define traceTASK_NOTIFY_WAIT() + #define traceTASK_NOTIFY_WAIT( uxIndexToWait ) #endif #ifndef traceTASK_NOTIFY - #define traceTASK_NOTIFY() + #define traceTASK_NOTIFY( uxIndexToNotify ) #endif #ifndef traceTASK_NOTIFY_FROM_ISR - #define traceTASK_NOTIFY_FROM_ISR() + #define traceTASK_NOTIFY_FROM_ISR( uxIndexToNotify ) #endif #ifndef traceTASK_NOTIFY_GIVE_FROM_ISR - #define traceTASK_NOTIFY_GIVE_FROM_ISR() + #define traceTASK_NOTIFY_GIVE_FROM_ISR( uxIndexToNotify ) #endif #ifndef traceSTREAM_BUFFER_CREATE_FAILED - #define traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer ) + #define traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer ) #endif #ifndef traceSTREAM_BUFFER_CREATE_STATIC_FAILED - #define traceSTREAM_BUFFER_CREATE_STATIC_FAILED( xReturn, xIsMessageBuffer ) + #define traceSTREAM_BUFFER_CREATE_STATIC_FAILED( xReturn, xIsMessageBuffer ) #endif #ifndef traceSTREAM_BUFFER_CREATE - #define traceSTREAM_BUFFER_CREATE( pxStreamBuffer, xIsMessageBuffer ) + #define traceSTREAM_BUFFER_CREATE( pxStreamBuffer, xIsMessageBuffer ) #endif #ifndef traceSTREAM_BUFFER_DELETE - #define traceSTREAM_BUFFER_DELETE( xStreamBuffer ) + #define traceSTREAM_BUFFER_DELETE( xStreamBuffer ) #endif #ifndef traceSTREAM_BUFFER_RESET - #define traceSTREAM_BUFFER_RESET( xStreamBuffer ) + #define traceSTREAM_BUFFER_RESET( xStreamBuffer ) #endif #ifndef traceBLOCKING_ON_STREAM_BUFFER_SEND - #define traceBLOCKING_ON_STREAM_BUFFER_SEND( xStreamBuffer ) + #define traceBLOCKING_ON_STREAM_BUFFER_SEND( xStreamBuffer ) #endif #ifndef traceSTREAM_BUFFER_SEND - #define traceSTREAM_BUFFER_SEND( xStreamBuffer, xBytesSent ) + #define traceSTREAM_BUFFER_SEND( xStreamBuffer, xBytesSent ) #endif #ifndef traceSTREAM_BUFFER_SEND_FAILED - #define traceSTREAM_BUFFER_SEND_FAILED( xStreamBuffer ) + #define traceSTREAM_BUFFER_SEND_FAILED( xStreamBuffer ) #endif #ifndef traceSTREAM_BUFFER_SEND_FROM_ISR - #define traceSTREAM_BUFFER_SEND_FROM_ISR( xStreamBuffer, xBytesSent ) + #define traceSTREAM_BUFFER_SEND_FROM_ISR( xStreamBuffer, xBytesSent ) #endif #ifndef traceBLOCKING_ON_STREAM_BUFFER_RECEIVE - #define traceBLOCKING_ON_STREAM_BUFFER_RECEIVE( xStreamBuffer ) + #define traceBLOCKING_ON_STREAM_BUFFER_RECEIVE( xStreamBuffer ) #endif #ifndef traceSTREAM_BUFFER_RECEIVE - #define traceSTREAM_BUFFER_RECEIVE( xStreamBuffer, xReceivedLength ) + #define traceSTREAM_BUFFER_RECEIVE( xStreamBuffer, xReceivedLength ) #endif #ifndef traceSTREAM_BUFFER_RECEIVE_FAILED - #define traceSTREAM_BUFFER_RECEIVE_FAILED( xStreamBuffer ) + #define traceSTREAM_BUFFER_RECEIVE_FAILED( xStreamBuffer ) #endif #ifndef traceSTREAM_BUFFER_RECEIVE_FROM_ISR - #define traceSTREAM_BUFFER_RECEIVE_FROM_ISR( xStreamBuffer, xReceivedLength ) + #define traceSTREAM_BUFFER_RECEIVE_FROM_ISR( xStreamBuffer, xReceivedLength ) #endif +#ifdef ESP_PLATFORM #ifndef traceISR_EXIT_TO_SCHEDULER - #define traceISR_EXIT_TO_SCHEDULER() + #define traceISR_EXIT_TO_SCHEDULER() #endif #ifndef traceISR_EXIT - #define traceISR_EXIT() + #define traceISR_EXIT() #endif #ifndef traceISR_ENTER - #define traceISR_ENTER(_n_) + #define traceISR_ENTER(_n_) #endif +#endif // ESP_PLATFORM #ifndef configGENERATE_RUN_TIME_STATS - #define configGENERATE_RUN_TIME_STATS 0 + #define configGENERATE_RUN_TIME_STATS 0 #endif #if ( configGENERATE_RUN_TIME_STATS == 1 ) - #ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS - #error If configGENERATE_RUN_TIME_STATS is defined then portCONFIGURE_TIMER_FOR_RUN_TIME_STATS must also be defined. portCONFIGURE_TIMER_FOR_RUN_TIME_STATS should call a port layer function to setup a peripheral timer/counter that can then be used as the run time counter time base. - #endif /* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS */ + #ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS + #error If configGENERATE_RUN_TIME_STATS is defined then portCONFIGURE_TIMER_FOR_RUN_TIME_STATS must also be defined. portCONFIGURE_TIMER_FOR_RUN_TIME_STATS should call a port layer function to setup a peripheral timer/counter that can then be used as the run time counter time base. + #endif /* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS */ - #ifndef portGET_RUN_TIME_COUNTER_VALUE - #ifndef portALT_GET_RUN_TIME_COUNTER_VALUE - #error If configGENERATE_RUN_TIME_STATS is defined then either portGET_RUN_TIME_COUNTER_VALUE or portALT_GET_RUN_TIME_COUNTER_VALUE must also be defined. See the examples provided and the FreeRTOS web site for more information. - #endif /* portALT_GET_RUN_TIME_COUNTER_VALUE */ - #endif /* portGET_RUN_TIME_COUNTER_VALUE */ + #ifndef portGET_RUN_TIME_COUNTER_VALUE + #ifndef portALT_GET_RUN_TIME_COUNTER_VALUE + #error If configGENERATE_RUN_TIME_STATS is defined then either portGET_RUN_TIME_COUNTER_VALUE or portALT_GET_RUN_TIME_COUNTER_VALUE must also be defined. See the examples provided and the FreeRTOS web site for more information. + #endif /* portALT_GET_RUN_TIME_COUNTER_VALUE */ + #endif /* portGET_RUN_TIME_COUNTER_VALUE */ #endif /* configGENERATE_RUN_TIME_STATS */ #ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS - #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() + #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() #endif #ifndef configUSE_MALLOC_FAILED_HOOK - #define configUSE_MALLOC_FAILED_HOOK 0 + #define configUSE_MALLOC_FAILED_HOOK 0 #endif #ifndef portPRIVILEGE_BIT - #define portPRIVILEGE_BIT ( ( UBaseType_t ) 0x00 ) + #define portPRIVILEGE_BIT ( ( UBaseType_t ) 0x00 ) #endif #ifndef portYIELD_WITHIN_API - #define portYIELD_WITHIN_API portYIELD + #define portYIELD_WITHIN_API portYIELD #endif #ifndef portSUPPRESS_TICKS_AND_SLEEP - #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) + #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) #endif #ifndef configEXPECTED_IDLE_TIME_BEFORE_SLEEP - #define configEXPECTED_IDLE_TIME_BEFORE_SLEEP 2 + #define configEXPECTED_IDLE_TIME_BEFORE_SLEEP 2 #endif #if configEXPECTED_IDLE_TIME_BEFORE_SLEEP < 2 - #error configEXPECTED_IDLE_TIME_BEFORE_SLEEP must not be less than 2 + #error configEXPECTED_IDLE_TIME_BEFORE_SLEEP must not be less than 2 #endif #ifndef configUSE_TICKLESS_IDLE - #define configUSE_TICKLESS_IDLE 0 + #define configUSE_TICKLESS_IDLE 0 #endif #ifndef configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING - #define configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING( x ) + #define configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING( x ) #endif #ifndef configPRE_SLEEP_PROCESSING - #define configPRE_SLEEP_PROCESSING( x ) + #define configPRE_SLEEP_PROCESSING( x ) #endif #ifndef configPOST_SLEEP_PROCESSING - #define configPOST_SLEEP_PROCESSING( x ) + #define configPOST_SLEEP_PROCESSING( x ) #endif #ifndef configUSE_QUEUE_SETS - #define configUSE_QUEUE_SETS 0 + #define configUSE_QUEUE_SETS 0 #endif #ifndef portTASK_USES_FLOATING_POINT - #define portTASK_USES_FLOATING_POINT() + #define portTASK_USES_FLOATING_POINT() #endif #ifndef portALLOCATE_SECURE_CONTEXT - #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) + #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize ) #endif #ifndef portDONT_DISCARD - #define portDONT_DISCARD + #define portDONT_DISCARD #endif #ifndef configUSE_TIME_SLICING - #define configUSE_TIME_SLICING 1 + #define configUSE_TIME_SLICING 1 #endif #ifndef configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS - #define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS 0 + #define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS 0 #endif #ifndef configUSE_STATS_FORMATTING_FUNCTIONS - #define configUSE_STATS_FORMATTING_FUNCTIONS 0 + #define configUSE_STATS_FORMATTING_FUNCTIONS 0 #endif #ifndef portASSERT_IF_INTERRUPT_PRIORITY_INVALID - #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() + #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() #endif #ifndef configUSE_TRACE_FACILITY - #define configUSE_TRACE_FACILITY 0 + #define configUSE_TRACE_FACILITY 0 #endif #ifndef mtCOVERAGE_TEST_MARKER - #define mtCOVERAGE_TEST_MARKER() + #define mtCOVERAGE_TEST_MARKER() #endif #ifndef mtCOVERAGE_TEST_DELAY - #define mtCOVERAGE_TEST_DELAY() + #define mtCOVERAGE_TEST_DELAY() #endif #ifndef portASSERT_IF_IN_ISR - #define portASSERT_IF_IN_ISR() + #define portASSERT_IF_IN_ISR() #endif #ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION - #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 + #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 #endif #ifndef configAPPLICATION_ALLOCATED_HEAP - #define configAPPLICATION_ALLOCATED_HEAP 0 + #define configAPPLICATION_ALLOCATED_HEAP 0 #endif #ifndef configUSE_TASK_NOTIFICATIONS - #define configUSE_TASK_NOTIFICATIONS 1 + #define configUSE_TASK_NOTIFICATIONS 1 +#endif + +#ifndef configTASK_NOTIFICATION_ARRAY_ENTRIES + #define configTASK_NOTIFICATION_ARRAY_ENTRIES 1 +#endif + +#if configTASK_NOTIFICATION_ARRAY_ENTRIES < 1 + #error configTASK_NOTIFICATION_ARRAY_ENTRIES must be at least 1 #endif #ifndef configUSE_POSIX_ERRNO - #define configUSE_POSIX_ERRNO 0 + #define configUSE_POSIX_ERRNO 0 #endif #ifndef portTICK_TYPE_IS_ATOMIC - #define portTICK_TYPE_IS_ATOMIC 0 + #define portTICK_TYPE_IS_ATOMIC 0 #endif #ifndef configSUPPORT_STATIC_ALLOCATION - /* Defaults to 0 for backward compatibility. */ - #define configSUPPORT_STATIC_ALLOCATION 0 + /* Defaults to 0 for backward compatibility. */ + #define configSUPPORT_STATIC_ALLOCATION 0 #endif #ifndef configSUPPORT_DYNAMIC_ALLOCATION - /* Defaults to 1 for backward compatibility. */ - #define configSUPPORT_DYNAMIC_ALLOCATION 1 + /* Defaults to 1 for backward compatibility. */ + #define configSUPPORT_DYNAMIC_ALLOCATION 1 +#endif + +#ifndef configSTACK_ALLOCATION_FROM_SEPARATE_HEAP + /* Defaults to 0 for backward compatibility. */ + #define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0 #endif #ifndef configSTACK_DEPTH_TYPE - /* Defaults to uint16_t for backward compatibility, but can be overridden - in FreeRTOSConfig.h if uint16_t is too restrictive. */ - #define configSTACK_DEPTH_TYPE uint16_t + +/* Defaults to uint16_t for backward compatibility, but can be overridden + * in FreeRTOSConfig.h if uint16_t is too restrictive. */ + #define configSTACK_DEPTH_TYPE uint16_t #endif #ifndef configMESSAGE_BUFFER_LENGTH_TYPE - /* Defaults to size_t for backward compatibility, but can be overridden - in FreeRTOSConfig.h if lengths will always be less than the number of bytes - in a size_t. */ - #define configMESSAGE_BUFFER_LENGTH_TYPE size_t + +/* Defaults to size_t for backward compatibility, but can be overridden + * in FreeRTOSConfig.h if lengths will always be less than the number of bytes + * in a size_t. */ + #define configMESSAGE_BUFFER_LENGTH_TYPE size_t #endif /* Sanity check the configuration. */ -#if( configUSE_TICKLESS_IDLE != 0 ) - #if( INCLUDE_vTaskSuspend != 1 ) - #error INCLUDE_vTaskSuspend must be set to 1 if configUSE_TICKLESS_IDLE is not set to 0 - #endif /* INCLUDE_vTaskSuspend */ +#if ( configUSE_TICKLESS_IDLE != 0 ) + #if ( INCLUDE_vTaskSuspend != 1 ) + #error INCLUDE_vTaskSuspend must be set to 1 if configUSE_TICKLESS_IDLE is not set to 0 + #endif /* INCLUDE_vTaskSuspend */ #endif /* configUSE_TICKLESS_IDLE */ -#if( ( configSUPPORT_STATIC_ALLOCATION == 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 0 ) ) - #error configSUPPORT_STATIC_ALLOCATION and configSUPPORT_DYNAMIC_ALLOCATION cannot both be 0, but can both be 1. +#if ( ( configSUPPORT_STATIC_ALLOCATION == 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 0 ) ) + #error configSUPPORT_STATIC_ALLOCATION and configSUPPORT_DYNAMIC_ALLOCATION cannot both be 0, but can both be 1. #endif -#if( ( configUSE_RECURSIVE_MUTEXES == 1 ) && ( configUSE_MUTEXES != 1 ) ) - #error configUSE_MUTEXES must be set to 1 to use recursive mutexes +#if ( ( configUSE_RECURSIVE_MUTEXES == 1 ) && ( configUSE_MUTEXES != 1 ) ) + #error configUSE_MUTEXES must be set to 1 to use recursive mutexes #endif #ifndef configINITIAL_TICK_COUNT - #define configINITIAL_TICK_COUNT 0 + #define configINITIAL_TICK_COUNT 0 #endif -#if( portTICK_TYPE_IS_ATOMIC == 0 ) - /* Either variables of tick type cannot be read atomically, or - portTICK_TYPE_IS_ATOMIC was not set - map the critical sections used when - the tick count is returned to the standard critical section macros. */ - #define portTICK_TYPE_ENTER_CRITICAL(mux) portENTER_CRITICAL(mux) - #define portTICK_TYPE_EXIT_CRITICAL(mux) portEXIT_CRITICAL(mux) - #define portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR() portSET_INTERRUPT_MASK_FROM_ISR() - #define portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( x ) portCLEAR_INTERRUPT_MASK_FROM_ISR( ( x ) ) +#if ( portTICK_TYPE_IS_ATOMIC == 0 ) + +/* Either variables of tick type cannot be read atomically, or + * portTICK_TYPE_IS_ATOMIC was not set - map the critical sections used when + * the tick count is returned to the standard critical section macros. */ + #define portTICK_TYPE_ENTER_CRITICAL(mux) portENTER_CRITICAL(mux) + #define portTICK_TYPE_EXIT_CRITICAL(mux) portEXIT_CRITICAL(mux) + #define portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR() portSET_INTERRUPT_MASK_FROM_ISR() + #define portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( x ) portCLEAR_INTERRUPT_MASK_FROM_ISR( ( x ) ) #else - /* The tick type can be read atomically, so critical sections used when the - tick count is returned can be defined away. */ - #define portTICK_TYPE_ENTER_CRITICAL() - #define portTICK_TYPE_EXIT_CRITICAL() - #define portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR() 0 - #define portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( x ) ( void ) x -#endif + +/* The tick type can be read atomically, so critical sections used when the + * tick count is returned can be defined away. */ + #define portTICK_TYPE_ENTER_CRITICAL() + #define portTICK_TYPE_EXIT_CRITICAL() + #define portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR() 0 + #define portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( x ) ( void ) x +#endif /* if ( portTICK_TYPE_IS_ATOMIC == 0 ) */ /* Definitions to allow backward compatibility with FreeRTOS versions prior to -V8 if desired. */ + * V8 if desired. */ #ifndef configENABLE_BACKWARD_COMPATIBILITY - #define configENABLE_BACKWARD_COMPATIBILITY 1 + #define configENABLE_BACKWARD_COMPATIBILITY 1 #endif #ifndef configPRINTF - /* configPRINTF() was not defined, so define it away to nothing. To use - configPRINTF() then define it as follows (where MyPrintFunction() is - provided by the application writer): - void MyPrintFunction(const char *pcFormat, ... ); - #define configPRINTF( X ) MyPrintFunction X - - Then call like a standard printf() function, but placing brackets around - all parameters so they are passed as a single parameter. For example: - configPRINTF( ("Value = %d", MyVariable) ); */ - #define configPRINTF( X ) +/* configPRINTF() was not defined, so define it away to nothing. To use + * configPRINTF() then define it as follows (where MyPrintFunction() is + * provided by the application writer): + * + * void MyPrintFunction(const char *pcFormat, ... ); + #define configPRINTF( X ) MyPrintFunction X + * + * Then call like a standard printf() function, but placing brackets around + * all parameters so they are passed as a single parameter. For example: + * configPRINTF( ("Value = %d", MyVariable) ); */ + #define configPRINTF( X ) #endif #ifndef configMAX - /* The application writer has not provided their own MAX macro, so define - the following generic implementation. */ - #define configMAX( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) ) + +/* The application writer has not provided their own MAX macro, so define + * the following generic implementation. */ + #define configMAX( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) ) #endif #ifndef configMIN - /* The application writer has not provided their own MAX macro, so define - the following generic implementation. */ - #define configMIN( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) ) + +/* The application writer has not provided their own MIN macro, so define + * the following generic implementation. */ + #define configMIN( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) ) #endif #if configENABLE_BACKWARD_COMPATIBILITY == 1 - #define eTaskStateGet eTaskGetState - #define portTickType TickType_t - #define xTaskHandle TaskHandle_t - #define xQueueHandle QueueHandle_t - #define xSemaphoreHandle SemaphoreHandle_t - #define xQueueSetHandle QueueSetHandle_t - #define xQueueSetMemberHandle QueueSetMemberHandle_t - #define xTimeOutType TimeOut_t - #define xMemoryRegion MemoryRegion_t - #define xTaskParameters TaskParameters_t - #define xTaskStatusType TaskStatus_t - #define xTimerHandle TimerHandle_t - #define xCoRoutineHandle CoRoutineHandle_t - #define pdTASK_HOOK_CODE TaskHookFunction_t - #define portTICK_RATE_MS portTICK_PERIOD_MS - #define pcTaskGetTaskName pcTaskGetName - #define pcTimerGetTimerName pcTimerGetName - #define pcQueueGetQueueName pcQueueGetName - #define vTaskGetTaskInfo vTaskGetInfo - - /* Backward compatibility within the scheduler code only - these definitions - are not really required but are included for completeness. */ - #define tmrTIMER_CALLBACK TimerCallbackFunction_t - #define pdTASK_CODE TaskFunction_t - #define xListItem ListItem_t - #define xList List_t - - /* For libraries that break the list data hiding, and access list structure - members directly (which is not supposed to be done). */ - #define pxContainer pvContainer + #define eTaskStateGet eTaskGetState + #define portTickType TickType_t + #define xTaskHandle TaskHandle_t + #define xQueueHandle QueueHandle_t + #define xSemaphoreHandle SemaphoreHandle_t + #define xQueueSetHandle QueueSetHandle_t + #define xQueueSetMemberHandle QueueSetMemberHandle_t + #define xTimeOutType TimeOut_t + #define xMemoryRegion MemoryRegion_t + #define xTaskParameters TaskParameters_t + #define xTaskStatusType TaskStatus_t + #define xTimerHandle TimerHandle_t + #define xCoRoutineHandle CoRoutineHandle_t + #define pdTASK_HOOK_CODE TaskHookFunction_t + #define portTICK_RATE_MS portTICK_PERIOD_MS + #define pcTaskGetTaskName pcTaskGetName + #define pcTimerGetTimerName pcTimerGetName + #define pcQueueGetQueueName pcQueueGetName + #define vTaskGetTaskInfo vTaskGetInfo + #define xTaskGetIdleRunTimeCounter ulTaskGetIdleRunTimeCounter + +/* Backward compatibility within the scheduler code only - these definitions + * are not really required but are included for completeness. */ + #define tmrTIMER_CALLBACK TimerCallbackFunction_t + #define pdTASK_CODE TaskFunction_t + #define xListItem ListItem_t + #define xList List_t + +/* For libraries that break the list data hiding, and access list structure + * members directly (which is not supposed to be done). */ + #define pxContainer pvContainer #endif /* configENABLE_BACKWARD_COMPATIBILITY */ +#ifdef ESP_PLATFORM #ifndef configESP32_PER_TASK_DATA - #define configESP32_PER_TASK_DATA 1 + #define configESP32_PER_TASK_DATA 1 #endif +#endif // ESP_PLATFORM -#if( configUSE_ALTERNATIVE_API != 0 ) - #error The alternative API was deprecated some time ago, and was removed in FreeRTOS V9.0 0 +#if ( configUSE_ALTERNATIVE_API != 0 ) + #error The alternative API was deprecated some time ago, and was removed in FreeRTOS V9.0 0 #endif /* Set configUSE_TASK_FPU_SUPPORT to 0 to omit floating point support even -if floating point hardware is otherwise supported by the FreeRTOS port in use. -This constant is not supported by all FreeRTOS ports that include floating -point support. */ + * if floating point hardware is otherwise supported by the FreeRTOS port in use. + * This constant is not supported by all FreeRTOS ports that include floating + * point support. */ #ifndef configUSE_TASK_FPU_SUPPORT - #define configUSE_TASK_FPU_SUPPORT 1 + #define configUSE_TASK_FPU_SUPPORT 1 #endif /* Set configENABLE_MPU to 1 to enable MPU support and 0 to disable it. This is -currently used in ARMv8M ports. */ + * currently used in ARMv8M ports. */ #ifndef configENABLE_MPU - #define configENABLE_MPU 0 + #define configENABLE_MPU 0 #endif /* Set configENABLE_FPU to 1 to enable FPU support and 0 to disable it. This is -currently used in ARMv8M ports. */ + * currently used in ARMv8M ports. */ #ifndef configENABLE_FPU - #define configENABLE_FPU 1 + #define configENABLE_FPU 1 #endif /* Set configENABLE_TRUSTZONE to 1 enable TrustZone support and 0 to disable it. -This is currently used in ARMv8M ports. */ + * This is currently used in ARMv8M ports. */ #ifndef configENABLE_TRUSTZONE - #define configENABLE_TRUSTZONE 1 + #define configENABLE_TRUSTZONE 1 #endif /* Set configRUN_FREERTOS_SECURE_ONLY to 1 to run the FreeRTOS ARMv8M port on -the Secure Side only. */ + * the Secure Side only. */ #ifndef configRUN_FREERTOS_SECURE_ONLY - #define configRUN_FREERTOS_SECURE_ONLY 0 + #define configRUN_FREERTOS_SECURE_ONLY 0 #endif /* Sometimes the FreeRTOSConfig.h settings only allow a task to be created using @@ -1070,55 +1137,56 @@ the Secure Side only. */ * | | | | xTaskCreateRestrictedStatic | | | | * +-----+---------+--------+-----------------------------+-----------------------------------+------------------+-----------+ */ -#define tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE ( ( ( portUSING_MPU_WRAPPERS == 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) || \ - ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) ) +#define tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE \ + ( ( ( portUSING_MPU_WRAPPERS == 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) || \ + ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) ) /* * In line with software engineering best practice, FreeRTOS implements a strict * data hiding policy, so the real structures used by FreeRTOS to maintain the * state of tasks, queues, semaphores, etc. are not accessible to the application * code. However, if the application writer wants to statically allocate such - * an object then the size of the object needs to be know. Dummy structures + * an object then the size of the object needs to be known. Dummy structures * that are guaranteed to have the same size and alignment requirements of the * real objects are used for this purpose. The dummy list and list item * structures below are used for inclusion in such a dummy structure. */ struct xSTATIC_LIST_ITEM { - #if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) - TickType_t xDummy1; - #endif - TickType_t xDummy2; - void *pvDummy3[ 4 ]; - #if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) - TickType_t xDummy4; - #endif + #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) + TickType_t xDummy1; + #endif + TickType_t xDummy2; + void * pvDummy3[ 4 ]; + #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) + TickType_t xDummy4; + #endif }; typedef struct xSTATIC_LIST_ITEM StaticListItem_t; /* See the comments above the struct xSTATIC_LIST_ITEM definition. */ struct xSTATIC_MINI_LIST_ITEM { - #if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) - TickType_t xDummy1; - #endif - TickType_t xDummy2; - void *pvDummy3[ 2 ]; + #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) + TickType_t xDummy1; + #endif + TickType_t xDummy2; + void * pvDummy3[ 2 ]; }; typedef struct xSTATIC_MINI_LIST_ITEM StaticMiniListItem_t; /* See the comments above the struct xSTATIC_LIST_ITEM definition. */ typedef struct xSTATIC_LIST { - #if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) - TickType_t xDummy1; - #endif - UBaseType_t uxDummy2; - void *pvDummy3; - StaticMiniListItem_t xDummy4; - #if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) - TickType_t xDummy5; - #endif + #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) + TickType_t xDummy1; + #endif + UBaseType_t uxDummy2; + void * pvDummy3; + StaticMiniListItem_t xDummy4; + #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) + TickType_t xDummy5; + #endif } StaticList_t; /* @@ -1127,7 +1195,7 @@ typedef struct xSTATIC_LIST * strict data hiding policy. This means the Task 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 task then - * the size of the task object needs to be know. The StaticTask_t structure + * the size of the task object needs to be known. The StaticTask_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 @@ -1136,56 +1204,56 @@ typedef struct xSTATIC_LIST */ typedef struct xSTATIC_TCB { - void *pxDummy1; - #if ( portUSING_MPU_WRAPPERS == 1 ) - xMPU_SETTINGS xDummy2; - #endif - StaticListItem_t xDummy3[ 2 ]; - UBaseType_t uxDummy5; - void *pxDummy6; - uint8_t ucDummy7[ configMAX_TASK_NAME_LEN ]; - BaseType_t xDummyCore; - #if ( ( portSTACK_GROWTH > 0 ) || ( configRECORD_STACK_HIGH_ADDRESS == 1 ) ) - void *pxDummy8; - #endif - #if ( portCRITICAL_NESTING_IN_TCB == 1 ) - UBaseType_t uxDummy9; - #endif - #if ( configUSE_TRACE_FACILITY == 1 ) - UBaseType_t uxDummy10[ 2 ]; - #endif - #if ( configUSE_MUTEXES == 1 ) - UBaseType_t uxDummy12[ 2 ]; - #endif - #if ( configUSE_APPLICATION_TASK_TAG == 1 ) - void *pxDummy14; - #endif - #if( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) - void *pvDummy15[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ]; - #if ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS ) - void *pvDummyLocalStorageCallBack[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ]; - #endif - #endif - #if ( configGENERATE_RUN_TIME_STATS == 1 ) - uint32_t ulDummy16; - #endif - #if ( configUSE_NEWLIB_REENTRANT == 1 ) - struct _reent xDummy17; - #endif - #if ( configUSE_TASK_NOTIFICATIONS == 1 ) - uint32_t ulDummy18; - uint8_t ucDummy19; - #endif - #if ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) - uint8_t uxDummy20; - #endif - - #if( INCLUDE_xTaskAbortDelay == 1 ) - uint8_t ucDummy21; - #endif - #if ( configUSE_POSIX_ERRNO == 1 ) - int iDummy22; - #endif + void * pxDummy1; + #if ( portUSING_MPU_WRAPPERS == 1 ) + xMPU_SETTINGS xDummy2; + #endif + StaticListItem_t xDummy3[ 2 ]; + UBaseType_t uxDummy5; + void * pxDummy6; + uint8_t ucDummy7[ configMAX_TASK_NAME_LEN ]; + BaseType_t xDummyCore; + #if ( ( portSTACK_GROWTH > 0 ) || ( configRECORD_STACK_HIGH_ADDRESS == 1 ) ) + void * pxDummy8; + #endif + #if ( portCRITICAL_NESTING_IN_TCB == 1 ) + UBaseType_t uxDummy9; + #endif + #if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxDummy10[ 2 ]; + #endif + #if ( configUSE_MUTEXES == 1 ) + UBaseType_t uxDummy12[ 2 ]; + #endif + #if ( configUSE_APPLICATION_TASK_TAG == 1 ) + void * pxDummy14; + #endif + #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) + void * pvDummy15[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ]; + #if ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS ) + void *pvDummyLocalStorageCallBack[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ]; + #endif + #endif + #if ( configGENERATE_RUN_TIME_STATS == 1 ) + uint32_t ulDummy16; + #endif + #if ( configUSE_NEWLIB_REENTRANT == 1 ) + struct _reent xDummy17; + #endif + #if ( configUSE_TASK_NOTIFICATIONS == 1 ) + uint32_t ulDummy18[ configTASK_NOTIFICATION_ARRAY_ENTRIES ]; + uint8_t ucDummy19[ configTASK_NOTIFICATION_ARRAY_ENTRIES ]; + #endif + #if ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) + uint8_t uxDummy20; + #endif + + #if ( INCLUDE_xTaskAbortDelay == 1 ) + uint8_t ucDummy21; + #endif + #if ( configUSE_POSIX_ERRNO == 1 ) + int iDummy22; + #endif } StaticTask_t; /* @@ -1194,7 +1262,7 @@ typedef struct xSTATIC_TCB * strict data hiding policy. This means the Queue 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 queue - * then the size of the queue object needs to be know. The StaticQueue_t + * then the size of the queue object needs to be known. The StaticQueue_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 @@ -1204,33 +1272,31 @@ typedef struct xSTATIC_TCB */ typedef struct xSTATIC_QUEUE { - void *pvDummy1[ 3 ]; - - union - { - void *pvDummy2; - UBaseType_t uxDummy2; - } u; - - StaticList_t xDummy3[ 2 ]; - UBaseType_t uxDummy4[ 3 ]; - uint8_t ucDummy5[ 2 ]; - - #if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) - uint8_t ucDummy6; - #endif - - #if ( configUSE_QUEUE_SETS == 1 ) - void *pvDummy7; - #endif - - #if ( configUSE_TRACE_FACILITY == 1 ) - UBaseType_t uxDummy8; - uint8_t ucDummy9; - #endif - - portMUX_TYPE xDummy10; - + void * pvDummy1[ 3 ]; + + union + { + void * pvDummy2; + UBaseType_t uxDummy2; + } u; + + StaticList_t xDummy3[ 2 ]; + UBaseType_t uxDummy4[ 3 ]; + uint8_t ucDummy5[ 2 ]; + + #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) + uint8_t ucDummy6; + #endif + + #if ( configUSE_QUEUE_SETS == 1 ) + void * pvDummy7; + #endif + + #if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxDummy8; + uint8_t ucDummy9; + #endif + portMUX_TYPE xDummy10; } StaticQueue_t; typedef StaticQueue_t StaticSemaphore_t; @@ -1250,19 +1316,17 @@ typedef StaticQueue_t StaticSemaphore_t; */ typedef struct xSTATIC_EVENT_GROUP { - TickType_t xDummy1; - StaticList_t xDummy2; + 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 xDummy5; + #if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxDummy3; + #endif + #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) + uint8_t ucDummy4; + #endif + portMUX_TYPE xDummy5; } StaticEventGroup_t; /* @@ -1271,7 +1335,7 @@ typedef struct xSTATIC_EVENT_GROUP * 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. + * create a software timer then the size of the queue object needs to be known. * 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 @@ -1281,49 +1345,49 @@ typedef struct xSTATIC_EVENT_GROUP */ typedef struct xSTATIC_TIMER { - void *pvDummy1; - StaticListItem_t xDummy2; - TickType_t xDummy3; - void *pvDummy5; - TaskFunction_t pvDummy6; - #if( configUSE_TRACE_FACILITY == 1 ) - UBaseType_t uxDummy7; - #endif - uint8_t ucDummy8; + void * pvDummy1; + StaticListItem_t xDummy2; + TickType_t xDummy3; + void * pvDummy5; + TaskFunction_t pvDummy6; + #if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxDummy7; + #endif + uint8_t ucDummy8; } StaticTimer_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 stream buffer 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 stream buffer then the size of the stream buffer object needs to be -* know. The StaticStreamBuffer_t structure below is provided for this purpose. -* Its size 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. -*/ + * 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 stream buffer 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 stream buffer then the size of the stream buffer object needs to be + * known. The StaticStreamBuffer_t structure below is provided for this + * purpose. Its size 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_STREAM_BUFFER { - size_t uxDummy1[ 4 ]; - void * pvDummy2[ 3 ]; - uint8_t ucDummy3; - #if ( configUSE_TRACE_FACILITY == 1 ) - UBaseType_t uxDummy4; - #endif - - portMUX_TYPE xDummy5; - + size_t uxDummy1[ 4 ]; + void * pvDummy2[ 3 ]; + uint8_t ucDummy3; + #if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxDummy4; + #endif + portMUX_TYPE xDummy5; } StaticStreamBuffer_t; /* Message buffers are built on stream buffers. */ typedef StaticStreamBuffer_t StaticMessageBuffer_t; +/* *INDENT-OFF* */ #ifdef __cplusplus -} + } #endif +/* *INDENT-ON* */ #endif /* INC_FREERTOS_H */ diff --git a/tools/sdk/esp32s2/include/freertos/include/freertos/StackMacros.h b/tools/sdk/esp32s2/include/freertos/include/freertos/StackMacros.h new file mode 100644 index 00000000000..8d09f10cd1d --- /dev/null +++ b/tools/sdk/esp32s2/include/freertos/include/freertos/StackMacros.h @@ -0,0 +1,32 @@ +/* + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * 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. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + + +#ifndef _MSC_VER /* Visual Studio doesn't support #warning. */ + #warning The name of this file has changed to stack_macros.h. Please update your code accordingly. This source file (which has the original name) will be removed in future released. +#endif + +#include "stack_macros.h" diff --git a/tools/sdk/esp32s2/include/freertos/include/freertos/atomic.h b/tools/sdk/esp32s2/include/freertos/include/freertos/atomic.h index df52a0f01fd..a47b96723cc 100644 --- a/tools/sdk/esp32s2/include/freertos/include/freertos/atomic.h +++ b/tools/sdk/esp32s2/include/freertos/include/freertos/atomic.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,19 +19,18 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ /** * @file atomic.h * @brief FreeRTOS atomic operation support. * - * This file implements atomic by disabling interrupts globally. - * Implementation with architecture specific atomic instructions - * are to be provided under each compiler directory. + * This file implements atomic functions by disabling interrupts globally. + * Implementations with architecture specific atomic instructions can be + * provided under each compiler directory. */ #ifndef ATOMIC_H @@ -44,45 +43,50 @@ /* Standard includes. */ #include +/* *INDENT-OFF* */ #ifdef __cplusplus -extern "C" { + extern "C" { #endif +/* *INDENT-ON* */ -/* Port specific definitions -- entering/exiting critical section. +/* + * Port specific definitions -- entering/exiting critical section. * Refer template -- ./lib/FreeRTOS/portable/Compiler/Arch/portmacro.h * * Every call to ATOMIC_EXIT_CRITICAL() must be closely paired with * ATOMIC_ENTER_CRITICAL(). - * */ + * + */ #if defined( portSET_INTERRUPT_MASK_FROM_ISR ) - /* Nested interrupt scheme is supported in this port. */ - #define ATOMIC_ENTER_CRITICAL() \ - UBaseType_t uxCriticalSectionType = portSET_INTERRUPT_MASK_FROM_ISR() +/* Nested interrupt scheme is supported in this port. */ + #define ATOMIC_ENTER_CRITICAL() \ + UBaseType_t uxCriticalSectionType = portSET_INTERRUPT_MASK_FROM_ISR() - #define ATOMIC_EXIT_CRITICAL() \ - portCLEAR_INTERRUPT_MASK_FROM_ISR( uxCriticalSectionType ) + #define ATOMIC_EXIT_CRITICAL() \ + portCLEAR_INTERRUPT_MASK_FROM_ISR( uxCriticalSectionType ) #else - /* Nested interrupt scheme is NOT supported in this port. */ - #define ATOMIC_ENTER_CRITICAL() portENTER_CRITICAL() - #define ATOMIC_EXIT_CRITICAL() portEXIT_CRITICAL() +/* Nested interrupt scheme is NOT supported in this port. */ + #define ATOMIC_ENTER_CRITICAL() portENTER_CRITICAL() + #define ATOMIC_EXIT_CRITICAL() portEXIT_CRITICAL() #endif /* portSET_INTERRUPT_MASK_FROM_ISR() */ -/* Port specific definition -- "always inline". - * Inline is compiler specific, and may not always get inlined depending on your optimization level. - * Also, inline is considerred as performance optimization for atomic. - * Thus, if portFORCE_INLINE is not provided by portmacro.h, instead of resulting error, - * simply define it. +/* + * Port specific definition -- "always inline". + * Inline is compiler specific, and may not always get inlined depending on your + * optimization level. Also, inline is considered as performance optimization + * for atomic. Thus, if portFORCE_INLINE is not provided by portmacro.h, + * instead of resulting error, simply define it away. */ #ifndef portFORCE_INLINE #define portFORCE_INLINE #endif -#define ATOMIC_COMPARE_AND_SWAP_SUCCESS 0x1U /**< Compare and swap succeeded, swapped. */ -#define ATOMIC_COMPARE_AND_SWAP_FAILURE 0x0U /**< Compare and swap failed, did not swap. */ +#define ATOMIC_COMPARE_AND_SWAP_SUCCESS 0x1U /**< Compare and swap succeeded, swapped. */ +#define ATOMIC_COMPARE_AND_SWAP_FAILURE 0x0U /**< Compare and swap failed, did not swap. */ /*----------------------------- Swap && CAS ------------------------------*/ @@ -91,66 +95,67 @@ extern "C" { * * @brief Performs an atomic compare-and-swap operation on the specified values. * - * @param[in, out] pDestination Pointer to memory location from where value is + * @param[in, out] pulDestination Pointer to memory location from where value is * to be loaded and checked. * @param[in] ulExchange If condition meets, write this value to memory. * @param[in] ulComparand Swap condition. * * @return Unsigned integer of value 1 or 0. 1 for swapped, 0 for not swapped. * - * @note This function only swaps *pDestination with ulExchange, if previous - * *pDestination value equals ulComparand. + * @note This function only swaps *pulDestination with ulExchange, if previous + * *pulDestination value equals ulComparand. */ -static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32( - uint32_t volatile * pDestination, - uint32_t ulExchange, - uint32_t ulComparand ) +static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32( uint32_t volatile * pulDestination, + uint32_t ulExchange, + uint32_t ulComparand ) { - - uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE; + uint32_t ulReturnValue; ATOMIC_ENTER_CRITICAL(); - - if ( *pDestination == ulComparand ) { - *pDestination = ulExchange; - ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS; + if( *pulDestination == ulComparand ) + { + *pulDestination = ulExchange; + ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS; + } + else + { + ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE; + } } - ATOMIC_EXIT_CRITICAL(); return ulReturnValue; - } +/*-----------------------------------------------------------*/ /** * Atomic swap (pointers) * - * @brief Atomically sets the address pointed to by *ppDestination to the value - * of *pExchange. + * @brief Atomically sets the address pointed to by *ppvDestination to the value + * of *pvExchange. * - * @param[in, out] ppDestination Pointer to memory location from where a pointer - * value is to be loaded and written back to. - * @param[in] pExchange Pointer value to be written to *ppDestination. + * @param[in, out] ppvDestination Pointer to memory location from where a pointer + * value is to be loaded and written back to. + * @param[in] pvExchange Pointer value to be written to *ppvDestination. * - * @return The initial value of *ppDestination. + * @return The initial value of *ppvDestination. */ -static portFORCE_INLINE void * Atomic_SwapPointers_p32( - void * volatile * ppDestination, - void * pExchange ) +static portFORCE_INLINE void * Atomic_SwapPointers_p32( void * volatile * ppvDestination, + void * pvExchange ) { void * pReturnValue; ATOMIC_ENTER_CRITICAL(); - - pReturnValue = *ppDestination; - - *ppDestination = pExchange; - + { + pReturnValue = *ppvDestination; + *ppvDestination = pvExchange; + } ATOMIC_EXIT_CRITICAL(); return pReturnValue; } +/*-----------------------------------------------------------*/ /** * Atomic compare-and-swap (pointers) @@ -158,30 +163,30 @@ static portFORCE_INLINE void * Atomic_SwapPointers_p32( * @brief Performs an atomic compare-and-swap operation on the specified pointer * values. * - * @param[in, out] ppDestination Pointer to memory location from where a pointer - * value is to be loaded and checked. - * @param[in] pExchange If condition meets, write this value to memory. - * @param[in] pComparand Swap condition. + * @param[in, out] ppvDestination Pointer to memory location from where a pointer + * value is to be loaded and checked. + * @param[in] pvExchange If condition meets, write this value to memory. + * @param[in] pvComparand Swap condition. * * @return Unsigned integer of value 1 or 0. 1 for swapped, 0 for not swapped. * - * @note This function only swaps *ppDestination with pExchange, if previous - * *ppDestination value equals pComparand. + * @note This function only swaps *ppvDestination with pvExchange, if previous + * *ppvDestination value equals pvComparand. */ -static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32( - void * volatile * ppDestination, - void * pExchange, void * pComparand ) +static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32( void * volatile * ppvDestination, + void * pvExchange, + void * pvComparand ) { uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE; ATOMIC_ENTER_CRITICAL(); - - if ( *ppDestination == pComparand ) { - *ppDestination = pExchange; - ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS; + if( *ppvDestination == pvComparand ) + { + *ppvDestination = pvExchange; + ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS; + } } - ATOMIC_EXIT_CRITICAL(); return ulReturnValue; @@ -195,28 +200,27 @@ static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32( * * @brief Atomically adds count to the value of the specified pointer points to. * - * @param[in,out] pAddend Pointer to memory location from where value is to be + * @param[in,out] pulAddend Pointer to memory location from where value is to be * loaded and written back to. - * @param[in] ulCount Value to be added to *pAddend. + * @param[in] ulCount Value to be added to *pulAddend. * - * @return previous *pAddend value. + * @return previous *pulAddend value. */ -static portFORCE_INLINE uint32_t Atomic_Add_u32( - uint32_t volatile * pAddend, - uint32_t ulCount ) +static portFORCE_INLINE uint32_t Atomic_Add_u32( uint32_t volatile * pulAddend, + uint32_t ulCount ) { uint32_t ulCurrent; ATOMIC_ENTER_CRITICAL(); - - ulCurrent = *pAddend; - - *pAddend += ulCount; - + { + ulCurrent = *pulAddend; + *pulAddend += ulCount; + } ATOMIC_EXIT_CRITICAL(); return ulCurrent; } +/*-----------------------------------------------------------*/ /** * Atomic subtract @@ -224,74 +228,72 @@ static portFORCE_INLINE uint32_t Atomic_Add_u32( * @brief Atomically subtracts count from the value of the specified pointer * pointers to. * - * @param[in,out] pAddend Pointer to memory location from where value is to be + * @param[in,out] pulAddend Pointer to memory location from where value is to be * loaded and written back to. - * @param[in] ulCount Value to be subtract from *pAddend. + * @param[in] ulCount Value to be subtract from *pulAddend. * - * @return previous *pAddend value. + * @return previous *pulAddend value. */ -static portFORCE_INLINE uint32_t Atomic_Subtract_u32( - uint32_t volatile * pAddend, - uint32_t ulCount ) +static portFORCE_INLINE uint32_t Atomic_Subtract_u32( uint32_t volatile * pulAddend, + uint32_t ulCount ) { uint32_t ulCurrent; ATOMIC_ENTER_CRITICAL(); - - ulCurrent = *pAddend; - - *pAddend -= ulCount; - + { + ulCurrent = *pulAddend; + *pulAddend -= ulCount; + } ATOMIC_EXIT_CRITICAL(); return ulCurrent; } +/*-----------------------------------------------------------*/ /** * Atomic increment * * @brief Atomically increments the value of the specified pointer points to. * - * @param[in,out] pAddend Pointer to memory location from where value is to be + * @param[in,out] pulAddend Pointer to memory location from where value is to be * loaded and written back to. * - * @return *pAddend value before increment. + * @return *pulAddend value before increment. */ -static portFORCE_INLINE uint32_t Atomic_Increment_u32( uint32_t volatile * pAddend ) +static portFORCE_INLINE uint32_t Atomic_Increment_u32( uint32_t volatile * pulAddend ) { uint32_t ulCurrent; ATOMIC_ENTER_CRITICAL(); - - ulCurrent = *pAddend; - - *pAddend += 1; - + { + ulCurrent = *pulAddend; + *pulAddend += 1; + } ATOMIC_EXIT_CRITICAL(); return ulCurrent; } +/*-----------------------------------------------------------*/ /** * Atomic decrement * * @brief Atomically decrements the value of the specified pointer points to * - * @param[in,out] pAddend Pointer to memory location from where value is to be + * @param[in,out] pulAddend Pointer to memory location from where value is to be * loaded and written back to. * - * @return *pAddend value before decrement. + * @return *pulAddend value before decrement. */ -static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pAddend ) +static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pulAddend ) { uint32_t ulCurrent; ATOMIC_ENTER_CRITICAL(); - - ulCurrent = *pAddend; - - *pAddend -= 1; - + { + ulCurrent = *pulAddend; + *pulAddend -= 1; + } ATOMIC_EXIT_CRITICAL(); return ulCurrent; @@ -304,115 +306,112 @@ static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pAdde * * @brief Performs an atomic OR operation on the specified values. * - * @param [in, out] pDestination Pointer to memory location from where value is + * @param [in, out] pulDestination Pointer to memory location from where value is * to be loaded and written back to. - * @param [in] ulValue Value to be ORed with *pDestination. + * @param [in] ulValue Value to be ORed with *pulDestination. * - * @return The original value of *pDestination. + * @return The original value of *pulDestination. */ -static portFORCE_INLINE uint32_t Atomic_OR_u32( - uint32_t volatile * pDestination, - uint32_t ulValue ) +static portFORCE_INLINE uint32_t Atomic_OR_u32( uint32_t volatile * pulDestination, + uint32_t ulValue ) { uint32_t ulCurrent; ATOMIC_ENTER_CRITICAL(); - - ulCurrent = *pDestination; - - *pDestination |= ulValue; - + { + ulCurrent = *pulDestination; + *pulDestination |= ulValue; + } ATOMIC_EXIT_CRITICAL(); return ulCurrent; } +/*-----------------------------------------------------------*/ /** * Atomic AND * * @brief Performs an atomic AND operation on the specified values. * - * @param [in, out] pDestination Pointer to memory location from where value is + * @param [in, out] pulDestination Pointer to memory location from where value is * to be loaded and written back to. - * @param [in] ulValue Value to be ANDed with *pDestination. + * @param [in] ulValue Value to be ANDed with *pulDestination. * - * @return The original value of *pDestination. + * @return The original value of *pulDestination. */ -static portFORCE_INLINE uint32_t Atomic_AND_u32( - uint32_t volatile * pDestination, - uint32_t ulValue ) +static portFORCE_INLINE uint32_t Atomic_AND_u32( uint32_t volatile * pulDestination, + uint32_t ulValue ) { uint32_t ulCurrent; ATOMIC_ENTER_CRITICAL(); - - ulCurrent = *pDestination; - - *pDestination &= ulValue; - + { + ulCurrent = *pulDestination; + *pulDestination &= ulValue; + } ATOMIC_EXIT_CRITICAL(); return ulCurrent; } +/*-----------------------------------------------------------*/ /** * Atomic NAND * * @brief Performs an atomic NAND operation on the specified values. * - * @param [in, out] pDestination Pointer to memory location from where value is + * @param [in, out] pulDestination Pointer to memory location from where value is * to be loaded and written back to. - * @param [in] ulValue Value to be NANDed with *pDestination. + * @param [in] ulValue Value to be NANDed with *pulDestination. * - * @return The original value of *pDestination. + * @return The original value of *pulDestination. */ -static portFORCE_INLINE uint32_t Atomic_NAND_u32( - uint32_t volatile * pDestination, - uint32_t ulValue ) +static portFORCE_INLINE uint32_t Atomic_NAND_u32( uint32_t volatile * pulDestination, + uint32_t ulValue ) { uint32_t ulCurrent; ATOMIC_ENTER_CRITICAL(); - - ulCurrent = *pDestination; - - *pDestination = ~(ulCurrent & ulValue); - + { + ulCurrent = *pulDestination; + *pulDestination = ~( ulCurrent & ulValue ); + } ATOMIC_EXIT_CRITICAL(); return ulCurrent; } +/*-----------------------------------------------------------*/ /** * Atomic XOR * * @brief Performs an atomic XOR operation on the specified values. * - * @param [in, out] pDestination Pointer to memory location from where value is + * @param [in, out] pulDestination Pointer to memory location from where value is * to be loaded and written back to. - * @param [in] ulValue Value to be XORed with *pDestination. + * @param [in] ulValue Value to be XORed with *pulDestination. * - * @return The original value of *pDestination. + * @return The original value of *pulDestination. */ -static portFORCE_INLINE uint32_t Atomic_XOR_u32( - uint32_t volatile * pDestination, - uint32_t ulValue ) +static portFORCE_INLINE uint32_t Atomic_XOR_u32( uint32_t volatile * pulDestination, + uint32_t ulValue ) { uint32_t ulCurrent; ATOMIC_ENTER_CRITICAL(); - - ulCurrent = *pDestination; - - *pDestination ^= ulValue; - + { + ulCurrent = *pulDestination; + *pulDestination ^= ulValue; + } ATOMIC_EXIT_CRITICAL(); return ulCurrent; } +/* *INDENT-OFF* */ #ifdef __cplusplus -} + } #endif +/* *INDENT-ON* */ #endif /* ATOMIC_H */ diff --git a/tools/sdk/esp32s2/include/freertos/include/freertos/croutine.h b/tools/sdk/esp32s2/include/freertos/include/freertos/croutine.h index 8b3b41b9051..99322d219f2 100644 --- a/tools/sdk/esp32s2/include/freertos/include/freertos/croutine.h +++ b/tools/sdk/esp32s2/include/freertos/include/freertos/croutine.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,51 +19,56 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ #ifndef CO_ROUTINE_H #define CO_ROUTINE_H #ifndef INC_FREERTOS_H - #error "include FreeRTOS.h must appear in source files before include croutine.h" + #error "include FreeRTOS.h must appear in source files before include croutine.h" #endif #include "list.h" +/* *INDENT-OFF* */ #ifdef __cplusplus -extern "C" { + extern "C" { #endif +/* *INDENT-ON* */ /* Used to hide the implementation of the co-routine control block. The -control block structure however has to be included in the header due to -the macro implementation of the co-routine functionality. */ + * control block structure however has to be included in the header due to + * the macro implementation of the co-routine functionality. */ typedef void * CoRoutineHandle_t; /* Defines the prototype to which co-routine functions must conform. */ -typedef void (*crCOROUTINE_CODE)( CoRoutineHandle_t, UBaseType_t ); +typedef void (* crCOROUTINE_CODE)( CoRoutineHandle_t, + UBaseType_t ); typedef struct corCoRoutineControlBlock { - crCOROUTINE_CODE pxCoRoutineFunction; - ListItem_t xGenericListItem; /*< List item used to place the CRCB in ready and blocked queues. */ - ListItem_t xEventListItem; /*< List item used to place the CRCB in event lists. */ - UBaseType_t uxPriority; /*< The priority of the co-routine in relation to other co-routines. */ - UBaseType_t uxIndex; /*< Used to distinguish between co-routines when multiple co-routines use the same co-routine function. */ - uint16_t uxState; /*< Used internally by the co-routine implementation. */ -} CRCB_t; /* Co-routine control block. Note must be identical in size down to uxPriority with TCB_t. */ + crCOROUTINE_CODE pxCoRoutineFunction; + ListItem_t xGenericListItem; /*< List item used to place the CRCB in ready and blocked queues. */ + ListItem_t xEventListItem; /*< List item used to place the CRCB in event lists. */ + UBaseType_t uxPriority; /*< The priority of the co-routine in relation to other co-routines. */ + UBaseType_t uxIndex; /*< Used to distinguish between co-routines when multiple co-routines use the same co-routine function. */ + uint16_t uxState; /*< Used internally by the co-routine implementation. */ +} CRCB_t; /* Co-routine control block. Note must be identical in size down to uxPriority with TCB_t. */ /** + * @cond * croutine. h - *
- BaseType_t xCoRoutineCreate(
-                                 crCOROUTINE_CODE pxCoRoutineCode,
-                                 UBaseType_t uxPriority,
-                                 UBaseType_t uxIndex
-                               );
+ * @code{c} + * BaseType_t xCoRoutineCreate( + * crCOROUTINE_CODE pxCoRoutineCode, + * UBaseType_t uxPriority, + * UBaseType_t uxIndex + * ); + * @endcode + * @endcond * * Create a new co-routine and add it to the list of co-routines that are * ready to run. @@ -83,59 +88,65 @@ typedef struct corCoRoutineControlBlock * list, otherwise an error code defined with ProjDefs.h. * * Example usage: -
- // Co-routine to be created.
- void vFlashCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- // This may not be necessary for const variables.
- static const char cLedToFlash[ 2 ] = { 5, 6 };
- static const TickType_t uxFlashRates[ 2 ] = { 200, 400 };
-
-     // Must start every co-routine with a call to crSTART();
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-         // This co-routine just delays for a fixed period, then toggles
-         // an LED.  Two co-routines are created using this function, so
-         // the uxIndex parameter is used to tell the co-routine which
-         // LED to flash and how int32_t to delay.  This assumes xQueue has
-         // already been created.
-         vParTestToggleLED( cLedToFlash[ uxIndex ] );
-         crDELAY( xHandle, uxFlashRates[ uxIndex ] );
-     }
-
-     // Must end every co-routine with a call to crEND();
-     crEND();
- }
-
- // Function that creates two co-routines.
- void vOtherFunction( void )
- {
- uint8_t ucParameterToPass;
- TaskHandle_t xHandle;
-
-     // Create two co-routines at priority 0.  The first is given index 0
-     // so (from the code above) toggles LED 5 every 200 ticks.  The second
-     // is given index 1 so toggles LED 6 every 400 ticks.
-     for( uxIndex = 0; uxIndex < 2; uxIndex++ )
-     {
-         xCoRoutineCreate( vFlashCoRoutine, 0, uxIndex );
-     }
- }
-   
+ * @code{c} + * // Co-routine to be created. + * void vFlashCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) + * { + * // Variables in co-routines must be declared static if they must maintain value across a blocking call. + * // This may not be necessary for const variables. + * static const char cLedToFlash[ 2 ] = { 5, 6 }; + * static const TickType_t uxFlashRates[ 2 ] = { 200, 400 }; + * + * // Must start every co-routine with a call to crSTART(); + * crSTART( xHandle ); + * + * for( ;; ) + * { + * // This co-routine just delays for a fixed period, then toggles + * // an LED. Two co-routines are created using this function, so + * // the uxIndex parameter is used to tell the co-routine which + * // LED to flash and how int32_t to delay. This assumes xQueue has + * // already been created. + * vParTestToggleLED( cLedToFlash[ uxIndex ] ); + * crDELAY( xHandle, uxFlashRates[ uxIndex ] ); + * } + * + * // Must end every co-routine with a call to crEND(); + * crEND(); + * } + * + * // Function that creates two co-routines. + * void vOtherFunction( void ) + * { + * uint8_t ucParameterToPass; + * TaskHandle_t xHandle; + * + * // Create two co-routines at priority 0. The first is given index 0 + * // so (from the code above) toggles LED 5 every 200 ticks. The second + * // is given index 1 so toggles LED 6 every 400 ticks. + * for( uxIndex = 0; uxIndex < 2; uxIndex++ ) + * { + * xCoRoutineCreate( vFlashCoRoutine, 0, uxIndex ); + * } + * } + * @endcode + * @cond * \defgroup xCoRoutineCreate xCoRoutineCreate + * @endcond * \ingroup Tasks */ -BaseType_t xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, UBaseType_t uxPriority, UBaseType_t uxIndex ); +BaseType_t xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, + UBaseType_t uxPriority, + UBaseType_t uxIndex ); /** + * @cond * croutine. h - *
- void vCoRoutineSchedule( void );
- * + * @code{c} + * void vCoRoutineSchedule( void ); + * @endcode + * @endcond * Run a co-routine. * * vCoRoutineSchedule() executes the highest priority co-routine that is able @@ -148,103 +159,127 @@ BaseType_t xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, UBaseType_t uxPri * hook). * * Example usage: -
- // This idle task hook will schedule a co-routine each time it is called.
- // The rest of the idle task will execute between co-routine calls.
- void vApplicationIdleHook( void )
- {
-	vCoRoutineSchedule();
- }
-
- // Alternatively, if you do not require any other part of the idle task to
- // execute, the idle task hook can call vCoRoutineScheduler() within an
- // infinite loop.
- void vApplicationIdleHook( void )
- {
-    for( ;; )
-    {
-        vCoRoutineSchedule();
-    }
- }
- 
+ * @code{c} + * // This idle task hook will schedule a co-routine each time it is called. + * // The rest of the idle task will execute between co-routine calls. + * void vApplicationIdleHook( void ) + * { + * vCoRoutineSchedule(); + * } + * + * // Alternatively, if you do not require any other part of the idle task to + * // execute, the idle task hook can call vCoRoutineScheduler() within an + * // infinite loop. + * void vApplicationIdleHook( void ) + * { + * for( ;; ) + * { + * vCoRoutineSchedule(); + * } + * } + * @endcode + * @endcode + * @cond * \defgroup vCoRoutineSchedule vCoRoutineSchedule + * @endcond * \ingroup Tasks */ void vCoRoutineSchedule( void ); /** + * @cond * croutine. h - *
- crSTART( CoRoutineHandle_t xHandle );
+ * @code{c} + * crSTART( CoRoutineHandle_t xHandle ); + * @endcode + * @endcond * * This macro MUST always be called at the start of a co-routine function. * * Example usage: -
- // Co-routine to be created.
- void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- static int32_t ulAVariable;
-
-     // Must start every co-routine with a call to crSTART();
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-          // Co-routine functionality goes here.
-     }
-
-     // Must end every co-routine with a call to crEND();
-     crEND();
- }
+ * @code{c} + * // Co-routine to be created. + * void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) + * { + * // Variables in co-routines must be declared static if they must maintain value across a blocking call. + * static int32_t ulAVariable; + * + * // Must start every co-routine with a call to crSTART(); + * crSTART( xHandle ); + * + * for( ;; ) + * { + * // Co-routine functionality goes here. + * } + * + * // Must end every co-routine with a call to crEND(); + * crEND(); + * } + * @endcode + * @cond * \defgroup crSTART crSTART + * @endcond * \ingroup Tasks */ -#define crSTART( pxCRCB ) switch( ( ( CRCB_t * )( pxCRCB ) )->uxState ) { case 0: +#define crSTART( pxCRCB ) \ + switch( ( ( CRCB_t * ) ( pxCRCB ) )->uxState ) { \ + case 0: /** + * @cond * croutine. h - *
- crEND();
+ * @code{c} + * crEND(); + * @endcode + * @endcond * * This macro MUST always be called at the end of a co-routine function. * * Example usage: -
- // Co-routine to be created.
- void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- static int32_t ulAVariable;
-
-     // Must start every co-routine with a call to crSTART();
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-          // Co-routine functionality goes here.
-     }
-
-     // Must end every co-routine with a call to crEND();
-     crEND();
- }
+ * @code{c} + * // Co-routine to be created. + * void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) + * { + * // Variables in co-routines must be declared static if they must maintain value across a blocking call. + * static int32_t ulAVariable; + * + * // Must start every co-routine with a call to crSTART(); + * crSTART( xHandle ); + * + * for( ;; ) + * { + * // Co-routine functionality goes here. + * } + * + * // Must end every co-routine with a call to crEND(); + * crEND(); + * } + * @endcode + * @cond * \defgroup crSTART crSTART + * @endcond * \ingroup Tasks */ -#define crEND() } +#define crEND() } /* * These macros are intended for internal use by the co-routine implementation * only. The macros should not be used directly by application writers. */ -#define crSET_STATE0( xHandle ) ( ( CRCB_t * )( xHandle ) )->uxState = (__LINE__ * 2); return; case (__LINE__ * 2): -#define crSET_STATE1( xHandle ) ( ( CRCB_t * )( xHandle ) )->uxState = ((__LINE__ * 2)+1); return; case ((__LINE__ * 2)+1): +#define crSET_STATE0( xHandle ) \ + ( ( CRCB_t * ) ( xHandle ) )->uxState = ( __LINE__ * 2 ); return; \ + case ( __LINE__ * 2 ): +#define crSET_STATE1( xHandle ) \ + ( ( CRCB_t * ) ( xHandle ) )->uxState = ( ( __LINE__ * 2 ) + 1 ); return; \ + case ( ( __LINE__ * 2 ) + 1 ): /** + * @cond * croutine. h - *
- crDELAY( CoRoutineHandle_t xHandle, TickType_t xTicksToDelay );
+ * @code{c} + * crDELAY( CoRoutineHandle_t xHandle, TickType_t xTicksToDelay ); + * @endcode + * @endcond * * Delay a co-routine for a fixed period of time. * @@ -261,48 +296,54 @@ void vCoRoutineSchedule( void ); * can be used to convert ticks to milliseconds. * * Example usage: -
- // Co-routine to be created.
- void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- // This may not be necessary for const variables.
- // We are to delay for 200ms.
- static const xTickType xDelayTime = 200 / portTICK_PERIOD_MS;
-
-     // Must start every co-routine with a call to crSTART();
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-        // Delay for 200ms.
-        crDELAY( xHandle, xDelayTime );
-
-        // Do something here.
-     }
-
-     // Must end every co-routine with a call to crEND();
-     crEND();
- }
+ * @code{c} + * // Co-routine to be created. + * void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) + * { + * // Variables in co-routines must be declared static if they must maintain value across a blocking call. + * // This may not be necessary for const variables. + * // We are to delay for 200ms. + * static const xTickType xDelayTime = 200 / portTICK_PERIOD_MS; + * + * // Must start every co-routine with a call to crSTART(); + * crSTART( xHandle ); + * + * for( ;; ) + * { + * // Delay for 200ms. + * crDELAY( xHandle, xDelayTime ); + * + * // Do something here. + * } + * + * // Must end every co-routine with a call to crEND(); + * crEND(); + * } + * @endcode + * @cond * \defgroup crDELAY crDELAY + * @endcond * \ingroup Tasks */ -#define crDELAY( xHandle, xTicksToDelay ) \ - if( ( xTicksToDelay ) > 0 ) \ - { \ - vCoRoutineAddToDelayedList( ( xTicksToDelay ), NULL ); \ - } \ - crSET_STATE0( ( xHandle ) ); +#define crDELAY( xHandle, xTicksToDelay ) \ + if( ( xTicksToDelay ) > 0 ) \ + { \ + vCoRoutineAddToDelayedList( ( xTicksToDelay ), NULL ); \ + } \ + crSET_STATE0( ( xHandle ) ); /** - *
- crQUEUE_SEND(
-                  CoRoutineHandle_t xHandle,
-                  QueueHandle_t pxQueue,
-                  void *pvItemToQueue,
-                  TickType_t xTicksToWait,
-                  BaseType_t *pxResult
-             )
+ * @cond + * @code{c} + * crQUEUE_SEND( + * CoRoutineHandle_t xHandle, + * QueueHandle_t pxQueue, + * void *pvItemToQueue, + * TickType_t xTicksToWait, + * BaseType_t *pxResult + * ) + * @endcode + * @endcond * * The macro's crQUEUE_SEND() and crQUEUE_RECEIVE() are the co-routine * equivalent to the xQueueSend() and xQueueReceive() functions used by tasks. @@ -342,66 +383,72 @@ void vCoRoutineSchedule( void ); * error defined within ProjDefs.h. * * Example usage: -
- // Co-routine function that blocks for a fixed period then posts a number onto
- // a queue.
- static void prvCoRoutineFlashTask( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- static BaseType_t xNumberToPost = 0;
- static BaseType_t xResult;
-
-    // Co-routines must begin with a call to crSTART().
-    crSTART( xHandle );
-
-    for( ;; )
-    {
-        // This assumes the queue has already been created.
-        crQUEUE_SEND( xHandle, xCoRoutineQueue, &xNumberToPost, NO_DELAY, &xResult );
-
-        if( xResult != pdPASS )
-        {
-            // The message was not posted!
-        }
-
-        // Increment the number to be posted onto the queue.
-        xNumberToPost++;
-
-        // Delay for 100 ticks.
-        crDELAY( xHandle, 100 );
-    }
-
-    // Co-routines must end with a call to crEND().
-    crEND();
- }
+ * @code{c} + * // Co-routine function that blocks for a fixed period then posts a number onto + * // a queue. + * static void prvCoRoutineFlashTask( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) + * { + * // Variables in co-routines must be declared static if they must maintain value across a blocking call. + * static BaseType_t xNumberToPost = 0; + * static BaseType_t xResult; + * + * // Co-routines must begin with a call to crSTART(). + * crSTART( xHandle ); + * + * for( ;; ) + * { + * // This assumes the queue has already been created. + * crQUEUE_SEND( xHandle, xCoRoutineQueue, &xNumberToPost, NO_DELAY, &xResult ); + * + * if( xResult != pdPASS ) + * { + * // The message was not posted! + * } + * + * // Increment the number to be posted onto the queue. + * xNumberToPost++; + * + * // Delay for 100 ticks. + * crDELAY( xHandle, 100 ); + * } + * + * // Co-routines must end with a call to crEND(). + * crEND(); + * } + * @endcode + * @cond * \defgroup crQUEUE_SEND crQUEUE_SEND + * @endcond * \ingroup Tasks */ -#define crQUEUE_SEND( xHandle, pxQueue, pvItemToQueue, xTicksToWait, pxResult ) \ -{ \ - *( pxResult ) = xQueueCRSend( ( pxQueue) , ( pvItemToQueue) , ( xTicksToWait ) ); \ - if( *( pxResult ) == errQUEUE_BLOCKED ) \ - { \ - crSET_STATE0( ( xHandle ) ); \ - *pxResult = xQueueCRSend( ( pxQueue ), ( pvItemToQueue ), 0 ); \ - } \ - if( *pxResult == errQUEUE_YIELD ) \ - { \ - crSET_STATE1( ( xHandle ) ); \ - *pxResult = pdPASS; \ - } \ -} +#define crQUEUE_SEND( xHandle, pxQueue, pvItemToQueue, xTicksToWait, pxResult ) \ + { \ + *( pxResult ) = xQueueCRSend( ( pxQueue ), ( pvItemToQueue ), ( xTicksToWait ) ); \ + if( *( pxResult ) == errQUEUE_BLOCKED ) \ + { \ + crSET_STATE0( ( xHandle ) ); \ + *pxResult = xQueueCRSend( ( pxQueue ), ( pvItemToQueue ), 0 ); \ + } \ + if( *pxResult == errQUEUE_YIELD ) \ + { \ + crSET_STATE1( ( xHandle ) ); \ + *pxResult = pdPASS; \ + } \ + } /** + * @cond * croutine. h - *
-  crQUEUE_RECEIVE(
-                     CoRoutineHandle_t xHandle,
-                     QueueHandle_t pxQueue,
-                     void *pvBuffer,
-                     TickType_t xTicksToWait,
-                     BaseType_t *pxResult
-                 )
+ * @code{c} + * crQUEUE_RECEIVE( + * CoRoutineHandle_t xHandle, + * QueueHandle_t pxQueue, + * void *pvBuffer, + * TickType_t xTicksToWait, + * BaseType_t *pxResult + * ) + * @endcode + * @endcond * * The macro's crQUEUE_SEND() and crQUEUE_RECEIVE() are the co-routine * equivalent to the xQueueSend() and xQueueReceive() functions used by tasks. @@ -440,58 +487,64 @@ void vCoRoutineSchedule( void ); * an error code as defined within ProjDefs.h. * * Example usage: -
- // A co-routine receives the number of an LED to flash from a queue.  It
- // blocks on the queue until the number is received.
- static void prvCoRoutineFlashWorkTask( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // Variables in co-routines must be declared static if they must maintain value across a blocking call.
- static BaseType_t xResult;
- static UBaseType_t uxLEDToFlash;
-
-    // All co-routines must start with a call to crSTART().
-    crSTART( xHandle );
-
-    for( ;; )
-    {
-        // Wait for data to become available on the queue.
-        crQUEUE_RECEIVE( xHandle, xCoRoutineQueue, &uxLEDToFlash, portMAX_DELAY, &xResult );
-
-        if( xResult == pdPASS )
-        {
-            // We received the LED to flash - flash it!
-            vParTestToggleLED( uxLEDToFlash );
-        }
-    }
-
-    crEND();
- }
+ * @code{c} + * // A co-routine receives the number of an LED to flash from a queue. It + * // blocks on the queue until the number is received. + * static void prvCoRoutineFlashWorkTask( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) + * { + * // Variables in co-routines must be declared static if they must maintain value across a blocking call. + * static BaseType_t xResult; + * static UBaseType_t uxLEDToFlash; + * + * // All co-routines must start with a call to crSTART(). + * crSTART( xHandle ); + * + * for( ;; ) + * { + * // Wait for data to become available on the queue. + * crQUEUE_RECEIVE( xHandle, xCoRoutineQueue, &uxLEDToFlash, portMAX_DELAY, &xResult ); + * + * if( xResult == pdPASS ) + * { + * // We received the LED to flash - flash it! + * vParTestToggleLED( uxLEDToFlash ); + * } + * } + * + * crEND(); + * } + * @endcode + * @cond * \defgroup crQUEUE_RECEIVE crQUEUE_RECEIVE + * @endcond * \ingroup Tasks */ -#define crQUEUE_RECEIVE( xHandle, pxQueue, pvBuffer, xTicksToWait, pxResult ) \ -{ \ - *( pxResult ) = xQueueCRReceive( ( pxQueue) , ( pvBuffer ), ( xTicksToWait ) ); \ - if( *( pxResult ) == errQUEUE_BLOCKED ) \ - { \ - crSET_STATE0( ( xHandle ) ); \ - *( pxResult ) = xQueueCRReceive( ( pxQueue) , ( pvBuffer ), 0 ); \ - } \ - if( *( pxResult ) == errQUEUE_YIELD ) \ - { \ - crSET_STATE1( ( xHandle ) ); \ - *( pxResult ) = pdPASS; \ - } \ -} +#define crQUEUE_RECEIVE( xHandle, pxQueue, pvBuffer, xTicksToWait, pxResult ) \ + { \ + *( pxResult ) = xQueueCRReceive( ( pxQueue ), ( pvBuffer ), ( xTicksToWait ) ); \ + if( *( pxResult ) == errQUEUE_BLOCKED ) \ + { \ + crSET_STATE0( ( xHandle ) ); \ + *( pxResult ) = xQueueCRReceive( ( pxQueue ), ( pvBuffer ), 0 ); \ + } \ + if( *( pxResult ) == errQUEUE_YIELD ) \ + { \ + crSET_STATE1( ( xHandle ) ); \ + *( pxResult ) = pdPASS; \ + } \ + } /** + * @cond * croutine. h - *
-  crQUEUE_SEND_FROM_ISR(
-                            QueueHandle_t pxQueue,
-                            void *pvItemToQueue,
-                            BaseType_t xCoRoutinePreviouslyWoken
-                       )
+ * @code{c} + * crQUEUE_SEND_FROM_ISR( + * QueueHandle_t pxQueue, + * void *pvItemToQueue, + * BaseType_t xCoRoutinePreviouslyWoken + * ) + * @endcode + * @endcond * * The macro's crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() are the * co-routine equivalent to the xQueueSendFromISR() and xQueueReceiveFromISR() @@ -526,69 +579,76 @@ void vCoRoutineSchedule( void ); * the ISR. * * Example usage: -
- // A co-routine that blocks on a queue waiting for characters to be received.
- static void vReceivingCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- char cRxedChar;
- BaseType_t xResult;
-
-     // All co-routines must start with a call to crSTART().
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-         // Wait for data to become available on the queue.  This assumes the
-         // queue xCommsRxQueue has already been created!
-         crQUEUE_RECEIVE( xHandle, xCommsRxQueue, &uxLEDToFlash, portMAX_DELAY, &xResult );
-
-         // Was a character received?
-         if( xResult == pdPASS )
-         {
-             // Process the character here.
-         }
-     }
-
-     // All co-routines must end with a call to crEND().
-     crEND();
- }
-
- // An ISR that uses a queue to send characters received on a serial port to
- // a co-routine.
- void vUART_ISR( void )
- {
- char cRxedChar;
- BaseType_t xCRWokenByPost = pdFALSE;
-
-     // We loop around reading characters until there are none left in the UART.
-     while( UART_RX_REG_NOT_EMPTY() )
-     {
-         // Obtain the character from the UART.
-         cRxedChar = UART_RX_REG;
-
-         // Post the character onto a queue.  xCRWokenByPost will be pdFALSE
-         // the first time around the loop.  If the post causes a co-routine
-         // to be woken (unblocked) then xCRWokenByPost will be set to pdTRUE.
-         // In this manner we can ensure that if more than one co-routine is
-         // blocked on the queue only one is woken by this ISR no matter how
-         // many characters are posted to the queue.
-         xCRWokenByPost = crQUEUE_SEND_FROM_ISR( xCommsRxQueue, &cRxedChar, xCRWokenByPost );
-     }
- }
+ * @code{c} + * // A co-routine that blocks on a queue waiting for characters to be received. + * static void vReceivingCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) + * { + * char cRxedChar; + * BaseType_t xResult; + * + * // All co-routines must start with a call to crSTART(). + * crSTART( xHandle ); + * + * for( ;; ) + * { + * // Wait for data to become available on the queue. This assumes the + * // queue xCommsRxQueue has already been created! + * crQUEUE_RECEIVE( xHandle, xCommsRxQueue, &uxLEDToFlash, portMAX_DELAY, &xResult ); + * + * // Was a character received? + * if( xResult == pdPASS ) + * { + * // Process the character here. + * } + * } + * + * // All co-routines must end with a call to crEND(). + * crEND(); + * } + * + * // An ISR that uses a queue to send characters received on a serial port to + * // a co-routine. + * void vUART_ISR( void ) + * { + * char cRxedChar; + * BaseType_t xCRWokenByPost = pdFALSE; + * + * // We loop around reading characters until there are none left in the UART. + * while( UART_RX_REG_NOT_EMPTY() ) + * { + * // Obtain the character from the UART. + * cRxedChar = UART_RX_REG; + * + * // Post the character onto a queue. xCRWokenByPost will be pdFALSE + * // the first time around the loop. If the post causes a co-routine + * // to be woken (unblocked) then xCRWokenByPost will be set to pdTRUE. + * // In this manner we can ensure that if more than one co-routine is + * // blocked on the queue only one is woken by this ISR no matter how + * // many characters are posted to the queue. + * xCRWokenByPost = crQUEUE_SEND_FROM_ISR( xCommsRxQueue, &cRxedChar, xCRWokenByPost ); + * } + * } + * @endcode + * @cond * \defgroup crQUEUE_SEND_FROM_ISR crQUEUE_SEND_FROM_ISR + * @endcond * \ingroup Tasks */ -#define crQUEUE_SEND_FROM_ISR( pxQueue, pvItemToQueue, xCoRoutinePreviouslyWoken ) xQueueCRSendFromISR( ( pxQueue ), ( pvItemToQueue ), ( xCoRoutinePreviouslyWoken ) ) +#define crQUEUE_SEND_FROM_ISR( pxQueue, pvItemToQueue, xCoRoutinePreviouslyWoken ) \ + xQueueCRSendFromISR( ( pxQueue ), ( pvItemToQueue ), ( xCoRoutinePreviouslyWoken ) ) /** + * @cond * croutine. h - *
-  crQUEUE_SEND_FROM_ISR(
-                            QueueHandle_t pxQueue,
-                            void *pvBuffer,
-                            BaseType_t * pxCoRoutineWoken
-                       )
+ * @code{c} + * crQUEUE_SEND_FROM_ISR( + * QueueHandle_t pxQueue, + * void *pvBuffer, + * BaseType_t * pxCoRoutineWoken + * ) + * @endcode + * @endcond * * The macro's crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() are the * co-routine equivalent to the xQueueSendFromISR() and xQueueReceiveFromISR() @@ -623,75 +683,79 @@ void vCoRoutineSchedule( void ); * pdFALSE. * * Example usage: -
- // A co-routine that posts a character to a queue then blocks for a fixed
- // period.  The character is incremented each time.
- static void vSendingCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
- {
- // cChar holds its value while this co-routine is blocked and must therefore
- // be declared static.
- static char cCharToTx = 'a';
- BaseType_t xResult;
-
-     // All co-routines must start with a call to crSTART().
-     crSTART( xHandle );
-
-     for( ;; )
-     {
-         // Send the next character to the queue.
-         crQUEUE_SEND( xHandle, xCoRoutineQueue, &cCharToTx, NO_DELAY, &xResult );
-
-         if( xResult == pdPASS )
-         {
-             // The character was successfully posted to the queue.
-         }
-		 else
-		 {
-			// Could not post the character to the queue.
-		 }
-
-         // Enable the UART Tx interrupt to cause an interrupt in this
-		 // hypothetical UART.  The interrupt will obtain the character
-		 // from the queue and send it.
-		 ENABLE_RX_INTERRUPT();
-
-		 // Increment to the next character then block for a fixed period.
-		 // cCharToTx will maintain its value across the delay as it is
-		 // declared static.
-		 cCharToTx++;
-		 if( cCharToTx > 'x' )
-		 {
-			cCharToTx = 'a';
-		 }
-		 crDELAY( 100 );
-     }
-
-     // All co-routines must end with a call to crEND().
-     crEND();
- }
-
- // An ISR that uses a queue to receive characters to send on a UART.
- void vUART_ISR( void )
- {
- char cCharToTx;
- BaseType_t xCRWokenByPost = pdFALSE;
-
-     while( UART_TX_REG_EMPTY() )
-     {
-         // Are there any characters in the queue waiting to be sent?
-		 // xCRWokenByPost will automatically be set to pdTRUE if a co-routine
-		 // is woken by the post - ensuring that only a single co-routine is
-		 // woken no matter how many times we go around this loop.
-         if( crQUEUE_RECEIVE_FROM_ISR( pxQueue, &cCharToTx, &xCRWokenByPost ) )
-		 {
-			 SEND_CHARACTER( cCharToTx );
-		 }
-     }
- }
+ * @code{c} + * // A co-routine that posts a character to a queue then blocks for a fixed + * // period. The character is incremented each time. + * static void vSendingCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) + * { + * // cChar holds its value while this co-routine is blocked and must therefore + * // be declared static. + * static char cCharToTx = 'a'; + * BaseType_t xResult; + * + * // All co-routines must start with a call to crSTART(). + * crSTART( xHandle ); + * + * for( ;; ) + * { + * // Send the next character to the queue. + * crQUEUE_SEND( xHandle, xCoRoutineQueue, &cCharToTx, NO_DELAY, &xResult ); + * + * if( xResult == pdPASS ) + * { + * // The character was successfully posted to the queue. + * } + * else + * { + * // Could not post the character to the queue. + * } + * + * // Enable the UART Tx interrupt to cause an interrupt in this + * // hypothetical UART. The interrupt will obtain the character + * // from the queue and send it. + * ENABLE_RX_INTERRUPT(); + * + * // Increment to the next character then block for a fixed period. + * // cCharToTx will maintain its value across the delay as it is + * // declared static. + * cCharToTx++; + * if( cCharToTx > 'x' ) + * { + * cCharToTx = 'a'; + * } + * crDELAY( 100 ); + * } + * + * // All co-routines must end with a call to crEND(). + * crEND(); + * } + * + * // An ISR that uses a queue to receive characters to send on a UART. + * void vUART_ISR( void ) + * { + * char cCharToTx; + * BaseType_t xCRWokenByPost = pdFALSE; + * + * while( UART_TX_REG_EMPTY() ) + * { + * // Are there any characters in the queue waiting to be sent? + * // xCRWokenByPost will automatically be set to pdTRUE if a co-routine + * // is woken by the post - ensuring that only a single co-routine is + * // woken no matter how many times we go around this loop. + * if( crQUEUE_RECEIVE_FROM_ISR( pxQueue, &cCharToTx, &xCRWokenByPost ) ) + * { + * SEND_CHARACTER( cCharToTx ); + * } + * } + * } + * @endcode + * @cond * \defgroup crQUEUE_RECEIVE_FROM_ISR crQUEUE_RECEIVE_FROM_ISR + * @endcond * \ingroup Tasks */ -#define crQUEUE_RECEIVE_FROM_ISR( pxQueue, pvBuffer, pxCoRoutineWoken ) xQueueCRReceiveFromISR( ( pxQueue ), ( pvBuffer ), ( pxCoRoutineWoken ) ) +#define crQUEUE_RECEIVE_FROM_ISR( pxQueue, pvBuffer, pxCoRoutineWoken ) \ + xQueueCRReceiveFromISR( ( pxQueue ), ( pvBuffer ), ( pxCoRoutineWoken ) ) /* * This function is intended for internal use by the co-routine macros only. @@ -702,7 +766,8 @@ void vCoRoutineSchedule( void ); * Removes the current co-routine from its ready list and places it in the * appropriate delayed list. */ -void vCoRoutineAddToDelayedList( TickType_t xTicksToDelay, List_t *pxEventList ); +void vCoRoutineAddToDelayedList( TickType_t xTicksToDelay, + List_t * pxEventList ); /* * This function is intended for internal use by the queue implementation only. @@ -711,10 +776,12 @@ void vCoRoutineAddToDelayedList( TickType_t xTicksToDelay, List_t *pxEventList ) * Removes the highest priority co-routine from the event list and places it in * the pending ready list. */ -BaseType_t xCoRoutineRemoveFromEventList( const List_t *pxEventList ); +BaseType_t xCoRoutineRemoveFromEventList( const List_t * pxEventList ); +/* *INDENT-OFF* */ #ifdef __cplusplus -} + } #endif +/* *INDENT-ON* */ #endif /* CO_ROUTINE_H */ diff --git a/tools/sdk/esp32s2/include/freertos/include/freertos/deprecated_definitions.h b/tools/sdk/esp32s2/include/freertos/include/freertos/deprecated_definitions.h index 70fc403bd28..d3b942666d0 100644 --- a/tools/sdk/esp32s2/include/freertos/include/freertos/deprecated_definitions.h +++ b/tools/sdk/esp32s2/include/freertos/include/freertos/deprecated_definitions.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ #ifndef DEPRECATED_DEFINITIONS_H @@ -30,158 +29,158 @@ /* Each FreeRTOS port has a unique portmacro.h header file. Originally a -pre-processor definition was used to ensure the pre-processor found the correct -portmacro.h file for the port being used. That scheme was deprecated in favour -of setting the compiler's include path such that it found the correct -portmacro.h file - removing the need for the constant and allowing the -portmacro.h file to be located anywhere in relation to the port being used. The -definitions below remain in the code for backward compatibility only. New -projects should not use them. */ + * pre-processor definition was used to ensure the pre-processor found the correct + * portmacro.h file for the port being used. That scheme was deprecated in favour + * of setting the compiler's include path such that it found the correct + * portmacro.h file - removing the need for the constant and allowing the + * portmacro.h file to be located anywhere in relation to the port being used. The + * definitions below remain in the code for backward compatibility only. New + * projects should not use them. */ #ifdef OPEN_WATCOM_INDUSTRIAL_PC_PORT - #include "..\..\Source\portable\owatcom\16bitdos\pc\portmacro.h" - typedef void ( __interrupt __far *pxISR )(); + #include "..\..\Source\portable\owatcom\16bitdos\pc\portmacro.h" + typedef void ( __interrupt __far * pxISR )(); #endif #ifdef OPEN_WATCOM_FLASH_LITE_186_PORT - #include "..\..\Source\portable\owatcom\16bitdos\flsh186\portmacro.h" - typedef void ( __interrupt __far *pxISR )(); + #include "..\..\Source\portable\owatcom\16bitdos\flsh186\portmacro.h" + typedef void ( __interrupt __far * pxISR )(); #endif #ifdef GCC_MEGA_AVR - #include "../portable/GCC/ATMega323/portmacro.h" + #include "../portable/GCC/ATMega323/portmacro.h" #endif #ifdef IAR_MEGA_AVR - #include "../portable/IAR/ATMega323/portmacro.h" + #include "../portable/IAR/ATMega323/portmacro.h" #endif #ifdef MPLAB_PIC24_PORT - #include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h" + #include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h" #endif #ifdef MPLAB_DSPIC_PORT - #include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h" + #include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h" #endif #ifdef MPLAB_PIC18F_PORT - #include "../../Source/portable/MPLAB/PIC18F/portmacro.h" + #include "../../Source/portable/MPLAB/PIC18F/portmacro.h" #endif #ifdef MPLAB_PIC32MX_PORT - #include "../../Source/portable/MPLAB/PIC32MX/portmacro.h" + #include "../../Source/portable/MPLAB/PIC32MX/portmacro.h" #endif #ifdef _FEDPICC - #include "libFreeRTOS/Include/portmacro.h" + #include "libFreeRTOS/Include/portmacro.h" #endif #ifdef SDCC_CYGNAL - #include "../../Source/portable/SDCC/Cygnal/portmacro.h" + #include "../../Source/portable/SDCC/Cygnal/portmacro.h" #endif #ifdef GCC_ARM7 - #include "../../Source/portable/GCC/ARM7_LPC2000/portmacro.h" + #include "../../Source/portable/GCC/ARM7_LPC2000/portmacro.h" #endif #ifdef GCC_ARM7_ECLIPSE - #include "portmacro.h" + #include "portmacro.h" #endif #ifdef ROWLEY_LPC23xx - #include "../../Source/portable/GCC/ARM7_LPC23xx/portmacro.h" + #include "../../Source/portable/GCC/ARM7_LPC23xx/portmacro.h" #endif #ifdef IAR_MSP430 - #include "..\..\Source\portable\IAR\MSP430\portmacro.h" + #include "..\..\Source\portable\IAR\MSP430\portmacro.h" #endif #ifdef GCC_MSP430 - #include "../../Source/portable/GCC/MSP430F449/portmacro.h" + #include "../../Source/portable/GCC/MSP430F449/portmacro.h" #endif #ifdef ROWLEY_MSP430 - #include "../../Source/portable/Rowley/MSP430F449/portmacro.h" + #include "../../Source/portable/Rowley/MSP430F449/portmacro.h" #endif #ifdef ARM7_LPC21xx_KEIL_RVDS - #include "..\..\Source\portable\RVDS\ARM7_LPC21xx\portmacro.h" + #include "..\..\Source\portable\RVDS\ARM7_LPC21xx\portmacro.h" #endif #ifdef SAM7_GCC - #include "../../Source/portable/GCC/ARM7_AT91SAM7S/portmacro.h" + #include "../../Source/portable/GCC/ARM7_AT91SAM7S/portmacro.h" #endif #ifdef SAM7_IAR - #include "..\..\Source\portable\IAR\AtmelSAM7S64\portmacro.h" + #include "..\..\Source\portable\IAR\AtmelSAM7S64\portmacro.h" #endif #ifdef SAM9XE_IAR - #include "..\..\Source\portable\IAR\AtmelSAM9XE\portmacro.h" + #include "..\..\Source\portable\IAR\AtmelSAM9XE\portmacro.h" #endif #ifdef LPC2000_IAR - #include "..\..\Source\portable\IAR\LPC2000\portmacro.h" + #include "..\..\Source\portable\IAR\LPC2000\portmacro.h" #endif #ifdef STR71X_IAR - #include "..\..\Source\portable\IAR\STR71x\portmacro.h" + #include "..\..\Source\portable\IAR\STR71x\portmacro.h" #endif #ifdef STR75X_IAR - #include "..\..\Source\portable\IAR\STR75x\portmacro.h" + #include "..\..\Source\portable\IAR\STR75x\portmacro.h" #endif #ifdef STR75X_GCC - #include "..\..\Source\portable\GCC\STR75x\portmacro.h" + #include "..\..\Source\portable\GCC\STR75x\portmacro.h" #endif #ifdef STR91X_IAR - #include "..\..\Source\portable\IAR\STR91x\portmacro.h" + #include "..\..\Source\portable\IAR\STR91x\portmacro.h" #endif #ifdef GCC_H8S - #include "../../Source/portable/GCC/H8S2329/portmacro.h" + #include "../../Source/portable/GCC/H8S2329/portmacro.h" #endif #ifdef GCC_AT91FR40008 - #include "../../Source/portable/GCC/ARM7_AT91FR40008/portmacro.h" + #include "../../Source/portable/GCC/ARM7_AT91FR40008/portmacro.h" #endif #ifdef RVDS_ARMCM3_LM3S102 - #include "../../Source/portable/RVDS/ARM_CM3/portmacro.h" + #include "../../Source/portable/RVDS/ARM_CM3/portmacro.h" #endif #ifdef GCC_ARMCM3_LM3S102 - #include "../../Source/portable/GCC/ARM_CM3/portmacro.h" + #include "../../Source/portable/GCC/ARM_CM3/portmacro.h" #endif #ifdef GCC_ARMCM3 - #include "../../Source/portable/GCC/ARM_CM3/portmacro.h" + #include "../../Source/portable/GCC/ARM_CM3/portmacro.h" #endif #ifdef IAR_ARM_CM3 - #include "../../Source/portable/IAR/ARM_CM3/portmacro.h" + #include "../../Source/portable/IAR/ARM_CM3/portmacro.h" #endif #ifdef IAR_ARMCM3_LM - #include "../../Source/portable/IAR/ARM_CM3/portmacro.h" + #include "../../Source/portable/IAR/ARM_CM3/portmacro.h" #endif #ifdef HCS12_CODE_WARRIOR - #include "../../Source/portable/CodeWarrior/HCS12/portmacro.h" + #include "../../Source/portable/CodeWarrior/HCS12/portmacro.h" #endif #ifdef MICROBLAZE_GCC - #include "../../Source/portable/GCC/MicroBlaze/portmacro.h" + #include "../../Source/portable/GCC/MicroBlaze/portmacro.h" #endif #ifdef TERN_EE - #include "..\..\Source\portable\Paradigm\Tern_EE\small\portmacro.h" + #include "..\..\Source\portable\Paradigm\Tern_EE\small\portmacro.h" #endif #ifdef GCC_HCS12 - #include "../../Source/portable/GCC/HCS12/portmacro.h" + #include "../../Source/portable/GCC/HCS12/portmacro.h" #endif #ifdef GCC_MCF5235 @@ -189,90 +188,92 @@ projects should not use them. */ #endif #ifdef COLDFIRE_V2_GCC - #include "../../../Source/portable/GCC/ColdFire_V2/portmacro.h" + #include "../../../Source/portable/GCC/ColdFire_V2/portmacro.h" #endif #ifdef COLDFIRE_V2_CODEWARRIOR - #include "../../Source/portable/CodeWarrior/ColdFire_V2/portmacro.h" + #include "../../Source/portable/CodeWarrior/ColdFire_V2/portmacro.h" #endif #ifdef GCC_PPC405 - #include "../../Source/portable/GCC/PPC405_Xilinx/portmacro.h" + #include "../../Source/portable/GCC/PPC405_Xilinx/portmacro.h" #endif #ifdef GCC_PPC440 - #include "../../Source/portable/GCC/PPC440_Xilinx/portmacro.h" + #include "../../Source/portable/GCC/PPC440_Xilinx/portmacro.h" #endif #ifdef _16FX_SOFTUNE - #include "..\..\Source\portable\Softune\MB96340\portmacro.h" + #include "..\..\Source\portable\Softune\MB96340\portmacro.h" #endif #ifdef BCC_INDUSTRIAL_PC_PORT - /* A short file name has to be used in place of the normal - FreeRTOSConfig.h when using the Borland compiler. */ - #include "frconfig.h" - #include "..\portable\BCC\16BitDOS\PC\prtmacro.h" - typedef void ( __interrupt __far *pxISR )(); + +/* A short file name has to be used in place of the normal + * FreeRTOSConfig.h when using the Borland compiler. */ + #include "frconfig.h" + #include "..\portable\BCC\16BitDOS\PC\prtmacro.h" + typedef void ( __interrupt __far * pxISR )(); #endif #ifdef BCC_FLASH_LITE_186_PORT - /* A short file name has to be used in place of the normal - FreeRTOSConfig.h when using the Borland compiler. */ - #include "frconfig.h" - #include "..\portable\BCC\16BitDOS\flsh186\prtmacro.h" - typedef void ( __interrupt __far *pxISR )(); + +/* A short file name has to be used in place of the normal + * FreeRTOSConfig.h when using the Borland compiler. */ + #include "frconfig.h" + #include "..\portable\BCC\16BitDOS\flsh186\prtmacro.h" + typedef void ( __interrupt __far * pxISR )(); #endif #ifdef __GNUC__ - #ifdef __AVR32_AVR32A__ - #include "portmacro.h" - #endif + #ifdef __AVR32_AVR32A__ + #include "portmacro.h" + #endif #endif #ifdef __ICCAVR32__ - #ifdef __CORE__ - #if __CORE__ == __AVR32A__ - #include "portmacro.h" - #endif - #endif + #ifdef __CORE__ + #if __CORE__ == __AVR32A__ + #include "portmacro.h" + #endif + #endif #endif #ifdef __91467D - #include "portmacro.h" + #include "portmacro.h" #endif #ifdef __96340 - #include "portmacro.h" + #include "portmacro.h" #endif #ifdef __IAR_V850ES_Fx3__ - #include "../../Source/portable/IAR/V850ES/portmacro.h" + #include "../../Source/portable/IAR/V850ES/portmacro.h" #endif #ifdef __IAR_V850ES_Jx3__ - #include "../../Source/portable/IAR/V850ES/portmacro.h" + #include "../../Source/portable/IAR/V850ES/portmacro.h" #endif #ifdef __IAR_V850ES_Jx3_L__ - #include "../../Source/portable/IAR/V850ES/portmacro.h" + #include "../../Source/portable/IAR/V850ES/portmacro.h" #endif #ifdef __IAR_V850ES_Jx2__ - #include "../../Source/portable/IAR/V850ES/portmacro.h" + #include "../../Source/portable/IAR/V850ES/portmacro.h" #endif #ifdef __IAR_V850ES_Hx2__ - #include "../../Source/portable/IAR/V850ES/portmacro.h" + #include "../../Source/portable/IAR/V850ES/portmacro.h" #endif #ifdef __IAR_78K0R_Kx3__ - #include "../../Source/portable/IAR/78K0R/portmacro.h" + #include "../../Source/portable/IAR/78K0R/portmacro.h" #endif #ifdef __IAR_78K0R_Kx3L__ - #include "../../Source/portable/IAR/78K0R/portmacro.h" + #include "../../Source/portable/IAR/78K0R/portmacro.h" #endif #endif /* DEPRECATED_DEFINITIONS_H */ diff --git a/tools/sdk/esp32s2/include/freertos/include/freertos/event_groups.h b/tools/sdk/esp32s2/include/freertos/include/freertos/event_groups.h index 5773e8d9071..84505ddaaa0 100644 --- a/tools/sdk/esp32s2/include/freertos/include/freertos/event_groups.h +++ b/tools/sdk/esp32s2/include/freertos/include/freertos/event_groups.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,25 +19,26 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ #ifndef EVENT_GROUPS_H #define EVENT_GROUPS_H #ifndef INC_FREERTOS_H - #error "include FreeRTOS.h" must appear in source files before "include event_groups.h" + #error "include FreeRTOS.h" must appear in source files before "include event_groups.h" #endif /* FreeRTOS includes. */ #include "timers.h" +/* *INDENT-OFF* */ #ifdef __cplusplus -extern "C" { + extern "C" { #endif +/* *INDENT-ON* */ /** * An event group is a collection of bits to which an application can assign a @@ -63,6 +64,9 @@ extern "C" { * used to create a synchronisation point between multiple tasks (a * 'rendezvous'). * + * @cond + * \defgroup EventGroup EventGroup + * @endcond */ @@ -74,34 +78,45 @@ extern "C" { * xEventGroupCreate() returns an EventGroupHandle_t variable that can then * be used as a parameter to other event group functions. * + * @cond * \defgroup EventGroupHandle_t EventGroupHandle_t + * @endcond * \ingroup EventGroup */ struct EventGroupDef_t; -//typedef struct EventGroupDef_t * EventGroupHandle_t; +#ifdef ESP_PLATFORM // IDF-3770 typedef void * EventGroupHandle_t; - +#else +typedef struct EventGroupDef_t * EventGroupHandle_t; +#endif // ESP_PLATFORM /* * The type that holds event bits always matches TickType_t - therefore the * number of bits it holds is set by configUSE_16_BIT_TICKS (16 bits if set to 1, * 32 bits if set to 0. * + * @cond * \defgroup EventBits_t EventBits_t + * @endcond * \ingroup EventGroup */ -typedef TickType_t EventBits_t; +typedef TickType_t EventBits_t; /** - * + * @cond + * event_groups.h + * @code{c} + * EventGroupHandle_t xEventGroupCreate( void ); + * @endcode + * @endcond * * 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 + * 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 + * (see https://www.FreeRTOS.org/a00111.html). If an event group is created + * using xEventGroupCreateStatic() 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. @@ -116,42 +131,52 @@ typedef TickType_t EventBits_t; * * @return If the event group was created then a handle to the event group is * returned. If there was insufficient FreeRTOS heap available to create the - * event group then NULL is returned. See http://www.freertos.org/a00111.html + * event group then NULL is returned. See https://www.FreeRTOS.org/a00111.html * * Example usage: * @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. - * } + * // 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 + * @cond + * \defgroup xEventGroupCreate xEventGroupCreate + * @endcond * \ingroup EventGroup */ -#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - EventGroupHandle_t xEventGroupCreate( void ) PRIVILEGED_FUNCTION; +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + EventGroupHandle_t xEventGroupCreate( void ) PRIVILEGED_FUNCTION; #endif /** + * @cond + * event_groups.h + * @code{c} + * EventGroupHandle_t xEventGroupCreateStatic( EventGroupHandle_t * pxEventGroupBuffer ); + * @endcode + * @endcond + * * 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 + * 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 + * (see https://www.FreeRTOS.org/a00111.html). If an event group is created + * using xEventGroupCreateStatic() 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. @@ -173,25 +198,36 @@ typedef TickType_t EventBits_t; * * 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 ); + * // 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; +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + EventGroupHandle_t xEventGroupCreateStatic( StaticEventGroup_t * pxEventGroupBuffer ) PRIVILEGED_FUNCTION; #endif /** + * @cond + * event_groups.h + * @code{c} + * EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup, + * const EventBits_t uxBitsToWaitFor, + * const BaseType_t xClearOnExit, + * const BaseType_t xWaitForAllBits, + * const TickType_t xTicksToWait ); + * @endcode + * @endcond + * * [Potentially] block to wait for one or more bits to be set within a * previously created event group. * @@ -235,47 +271,60 @@ typedef TickType_t EventBits_t; * * Example usage: * @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} + * #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 + * @cond + * \defgroup xEventGroupWaitBits xEventGroupWaitBits + * @endcond * \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; +EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup, + const EventBits_t uxBitsToWaitFor, + const BaseType_t xClearOnExit, + const BaseType_t xWaitForAllBits, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; /** + * @cond + * event_groups.h + * @code{c} + * EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear ); + * @endcode + * @endcond * * Clear bits within an event group. This function cannot be called from an * interrupt. @@ -290,44 +339,54 @@ EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup, const EventBits * * Example usage: * @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. - * } - * } + * #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 + * @cond + * \defgroup xEventGroupClearBits xEventGroupClearBits + * @endcond * \ingroup EventGroup */ -EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear ) PRIVILEGED_FUNCTION; +EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, + const EventBits_t uxBitsToClear ) PRIVILEGED_FUNCTION; /** + * @cond + * event_groups.h + * @code{c} + * BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ); + * @endcode + * @endcond * * A version of xEventGroupClearBits() that can be called from an interrupt. * @@ -353,35 +412,46 @@ EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBit * * Example usage: * @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. - * } - * } + * #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 + * @cond + * \defgroup xEventGroupClearBitsFromISR xEventGroupClearBitsFromISR + * @endcond * \ingroup EventGroup */ -#if( configUSE_TRACE_FACILITY == 1 ) - BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear ) PRIVILEGED_FUNCTION; +#if ( configUSE_TRACE_FACILITY == 1 ) + BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup, + const EventBits_t uxBitsToClear ) PRIVILEGED_FUNCTION; #else - #define xEventGroupClearBitsFromISR( xEventGroup, uxBitsToClear ) xTimerPendFunctionCallFromISR( vEventGroupClearBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToClear, NULL ) + #define xEventGroupClearBitsFromISR( xEventGroup, uxBitsToClear ) \ + xTimerPendFunctionCallFromISR( vEventGroupClearBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToClear, NULL ) #endif /** + * @cond + * event_groups.h + * @code{c} + * EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ); + * @endcode + * @endcond * * Set bits within an event group. * This function cannot be called from an interrupt. xEventGroupSetBitsFromISR() @@ -408,49 +478,59 @@ EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBit * * Example usage: * @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} + * #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 + * @cond + * \defgroup xEventGroupSetBits xEventGroupSetBits + * @endcond * \ingroup EventGroup */ -EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ) PRIVILEGED_FUNCTION; +EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, + const EventBits_t uxBitsToSet ) PRIVILEGED_FUNCTION; /** + * @cond + * event_groups.h + * @code{c} + * BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * @endcond * * A version of xEventGroupSetBits() that can be called from an interrupt. * @@ -484,46 +564,61 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_ * * Example usage: * @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 ); - * } - * } + * #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 + * @cond + * \defgroup xEventGroupSetBitsFromISR xEventGroupSetBitsFromISR + * @endcond * \ingroup EventGroup */ -#if( configUSE_TRACE_FACILITY == 1 ) - BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; +#if ( configUSE_TRACE_FACILITY == 1 ) + BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, + const EventBits_t uxBitsToSet, + BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; #else - #define xEventGroupSetBitsFromISR( xEventGroup, uxBitsToSet, pxHigherPriorityTaskWoken ) xTimerPendFunctionCallFromISR( vEventGroupSetBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToSet, pxHigherPriorityTaskWoken ) + #define xEventGroupSetBitsFromISR( xEventGroup, uxBitsToSet, pxHigherPriorityTaskWoken ) \ + xTimerPendFunctionCallFromISR( vEventGroupSetBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToSet, pxHigherPriorityTaskWoken ) #endif /** + * @cond + * event_groups.h + * @code{c} + * EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, + * const EventBits_t uxBitsToSet, + * const EventBits_t uxBitsToWaitFor, + * TickType_t xTicksToWait ); + * @endcode + * @endcond * * 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 @@ -563,86 +658,98 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_ * * Example usage: * @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. - * } - * } + * // 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. - * } + * } + * + * 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 synchronisation 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 synchronisation was made by all + * // three tasks, so there is no need to test the return value. * } + * } * * @endcode + * @cond + * \defgroup xEventGroupSync xEventGroupSync + * @endcond * \ingroup EventGroup */ -EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, + const EventBits_t uxBitsToSet, + const EventBits_t uxBitsToWaitFor, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; /** + * @cond + * event_groups.h + * @code{c} + * EventBits_t xEventGroupGetBits( EventGroupHandle_t xEventGroup ); + * @endcode + * @endcond * * Returns the current value of the bits in an event group. This function * cannot be used from an interrupt. @@ -651,11 +758,20 @@ EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t u * * @return The event group bits at the time xEventGroupGetBits() was called. * + * @cond + * \defgroup xEventGroupGetBits xEventGroupGetBits + * @endcond * \ingroup EventGroup */ -#define xEventGroupGetBits( xEventGroup ) xEventGroupClearBits( xEventGroup, 0 ) +#define xEventGroupGetBits( xEventGroup ) xEventGroupClearBits( xEventGroup, 0 ) /** + * @cond + * event_groups.h + * @code{c} + * EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup ); + * @endcode + * @endcond * * A version of xEventGroupGetBits() that can be called from an ISR. * @@ -663,11 +779,21 @@ EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t u * * @return The event group bits at the time xEventGroupGetBitsFromISR() was called. * + * @cond + * \defgroup xEventGroupGetBitsFromISR xEventGroupGetBitsFromISR + * @endcond * \ingroup EventGroup */ EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION; /** + * @cond + * event_groups.h + * @code{c} + * void xEventGroupDelete( EventGroupHandle_t xEventGroup ); + * @endcode + * @endcond + * * Delete an event group that was previously created by a call to * xEventGroupCreate(). Tasks that are blocked on the event group will be * unblocked and obtain 0 as the event group's value. @@ -679,19 +805,24 @@ void vEventGroupDelete( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION; /** @cond */ /* For internal use only. */ -void vEventGroupSetBitsCallback( void *pvEventGroup, const uint32_t ulBitsToSet ) PRIVILEGED_FUNCTION; -void vEventGroupClearBitsCallback( void *pvEventGroup, const uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION; +void vEventGroupSetBitsCallback( void * pvEventGroup, + const uint32_t ulBitsToSet ) PRIVILEGED_FUNCTION; +void vEventGroupClearBitsCallback( void * pvEventGroup, + const uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION; -#if (configUSE_TRACE_FACILITY == 1) - UBaseType_t uxEventGroupGetNumber( void* xEventGroup ) PRIVILEGED_FUNCTION; - void vEventGroupSetNumber( void* xEventGroup, UBaseType_t uxEventGroupNumber ) PRIVILEGED_FUNCTION; +#if ( configUSE_TRACE_FACILITY == 1 ) + UBaseType_t uxEventGroupGetNumber( void * xEventGroup ) PRIVILEGED_FUNCTION; + void vEventGroupSetNumber( void * xEventGroup, + UBaseType_t uxEventGroupNumber ) PRIVILEGED_FUNCTION; #endif /** @endcond */ +/* *INDENT-OFF* */ #ifdef __cplusplus -} + } #endif +/* *INDENT-ON* */ #endif /* EVENT_GROUPS_H */ diff --git a/tools/sdk/esp32s2/include/freertos/include/freertos/list.h b/tools/sdk/esp32s2/include/freertos/include/freertos/list.h index d06481e29bf..f76328f8e03 100644 --- a/tools/sdk/esp32s2/include/freertos/include/freertos/list.h +++ b/tools/sdk/esp32s2/include/freertos/include/freertos/list.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ /* @@ -54,7 +53,7 @@ */ #ifndef INC_FREERTOS_H - #error FreeRTOS.h must be included before list.h + #error "FreeRTOS.h must be included before list.h" #endif #ifndef LIST_H @@ -89,47 +88,49 @@ * "#define configLIST_VOLATILE volatile" */ #ifndef configLIST_VOLATILE - #define configLIST_VOLATILE + #define configLIST_VOLATILE #endif /* configSUPPORT_CROSS_MODULE_OPTIMISATION */ +/* *INDENT-OFF* */ #ifdef __cplusplus -extern "C" { + extern "C" { #endif +/* *INDENT-ON* */ /* Macros that can be used to place known values within the list structures, -then check that the known values do not get corrupted during the execution of -the application. These may catch the list data structures being overwritten in -memory. They will not catch data errors caused by incorrect configuration or -use of FreeRTOS.*/ -#if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 0 ) - /* Define the macros to do nothing. */ - #define listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE - #define listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE - #define listFIRST_LIST_INTEGRITY_CHECK_VALUE - #define listSECOND_LIST_INTEGRITY_CHECK_VALUE - #define listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) - #define listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) - #define listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList ) - #define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList ) - #define listTEST_LIST_ITEM_INTEGRITY( pxItem ) - #define listTEST_LIST_INTEGRITY( pxList ) -#else - /* Define macros that add new members into the list structures. */ - #define listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE TickType_t xListItemIntegrityValue1; - #define listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE TickType_t xListItemIntegrityValue2; - #define listFIRST_LIST_INTEGRITY_CHECK_VALUE TickType_t xListIntegrityValue1; - #define listSECOND_LIST_INTEGRITY_CHECK_VALUE TickType_t xListIntegrityValue2; - - /* Define macros that set the new structure members to known values. */ - #define listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) ( pxItem )->xListItemIntegrityValue1 = pdINTEGRITY_CHECK_VALUE - #define listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) ( pxItem )->xListItemIntegrityValue2 = pdINTEGRITY_CHECK_VALUE - #define listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList ) ( pxList )->xListIntegrityValue1 = pdINTEGRITY_CHECK_VALUE - #define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList ) ( pxList )->xListIntegrityValue2 = pdINTEGRITY_CHECK_VALUE - - /* Define macros that will assert if one of the structure members does not - contain its expected value. */ - #define listTEST_LIST_ITEM_INTEGRITY( pxItem ) configASSERT( ( ( pxItem )->xListItemIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxItem )->xListItemIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) ) - #define listTEST_LIST_INTEGRITY( pxList ) configASSERT( ( ( pxList )->xListIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxList )->xListIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) ) + * then check that the known values do not get corrupted during the execution of + * the application. These may catch the list data structures being overwritten in + * memory. They will not catch data errors caused by incorrect configuration or + * use of FreeRTOS.*/ +#if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 0 ) + /* Define the macros to do nothing. */ + #define listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE + #define listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE + #define listFIRST_LIST_INTEGRITY_CHECK_VALUE + #define listSECOND_LIST_INTEGRITY_CHECK_VALUE + #define listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) + #define listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) + #define listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList ) + #define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList ) + #define listTEST_LIST_ITEM_INTEGRITY( pxItem ) + #define listTEST_LIST_INTEGRITY( pxList ) +#else /* if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 0 ) */ + /* Define macros that add new members into the list structures. */ + #define listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE TickType_t xListItemIntegrityValue1; + #define listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE TickType_t xListItemIntegrityValue2; + #define listFIRST_LIST_INTEGRITY_CHECK_VALUE TickType_t xListIntegrityValue1; + #define listSECOND_LIST_INTEGRITY_CHECK_VALUE TickType_t xListIntegrityValue2; + +/* Define macros that set the new structure members to known values. */ + #define listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) ( pxItem )->xListItemIntegrityValue1 = pdINTEGRITY_CHECK_VALUE + #define listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) ( pxItem )->xListItemIntegrityValue2 = pdINTEGRITY_CHECK_VALUE + #define listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList ) ( pxList )->xListIntegrityValue1 = pdINTEGRITY_CHECK_VALUE + #define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList ) ( pxList )->xListIntegrityValue2 = pdINTEGRITY_CHECK_VALUE + +/* Define macros that will assert if one of the structure members does not + * contain its expected value. */ + #define listTEST_LIST_ITEM_INTEGRITY( pxItem ) configASSERT( ( ( pxItem )->xListItemIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxItem )->xListItemIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) ) + #define listTEST_LIST_INTEGRITY( pxList ) configASSERT( ( ( pxList )->xListIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxList )->xListIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) ) #endif /* configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES */ @@ -139,22 +140,22 @@ use of FreeRTOS.*/ struct xLIST; struct xLIST_ITEM { - listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ - configLIST_VOLATILE TickType_t xItemValue; /*< The value being listed. In most cases this is used to sort the list in descending order. */ - struct xLIST_ITEM * configLIST_VOLATILE pxNext; /*< Pointer to the next ListItem_t in the list. */ - struct xLIST_ITEM * configLIST_VOLATILE pxPrevious; /*< Pointer to the previous ListItem_t in the list. */ - void * pvOwner; /*< Pointer to the object (normally a TCB) that contains the list item. There is therefore a two way link between the object containing the list item and the list item itself. */ - struct xLIST * configLIST_VOLATILE pxContainer; /*< Pointer to the list in which this list item is placed (if any). */ - listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ + listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ + configLIST_VOLATILE TickType_t xItemValue; /*< The value being listed. In most cases this is used to sort the list in descending order. */ + struct xLIST_ITEM * configLIST_VOLATILE pxNext; /*< Pointer to the next ListItem_t in the list. */ + struct xLIST_ITEM * configLIST_VOLATILE pxPrevious; /*< Pointer to the previous ListItem_t in the list. */ + void * pvOwner; /*< Pointer to the object (normally a TCB) that contains the list item. There is therefore a two way link between the object containing the list item and the list item itself. */ + struct xLIST * configLIST_VOLATILE pxContainer; /*< Pointer to the list in which this list item is placed (if any). */ + listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ }; -typedef struct xLIST_ITEM ListItem_t; /* For some reason lint wants this as two separate definitions. */ +typedef struct xLIST_ITEM ListItem_t; /* For some reason lint wants this as two separate definitions. */ struct xMINI_LIST_ITEM { - listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ - configLIST_VOLATILE TickType_t xItemValue; - struct xLIST_ITEM * configLIST_VOLATILE pxNext; - struct xLIST_ITEM * configLIST_VOLATILE pxPrevious; + listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ + configLIST_VOLATILE TickType_t xItemValue; + struct xLIST_ITEM * configLIST_VOLATILE pxNext; + struct xLIST_ITEM * configLIST_VOLATILE pxPrevious; }; typedef struct xMINI_LIST_ITEM MiniListItem_t; @@ -163,11 +164,11 @@ typedef struct xMINI_LIST_ITEM MiniListItem_t; */ typedef struct xLIST { - listFIRST_LIST_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ - volatile UBaseType_t uxNumberOfItems; - ListItem_t * configLIST_VOLATILE pxIndex; /*< Used to walk through the list. Points to the last item returned by a call to listGET_OWNER_OF_NEXT_ENTRY (). */ - MiniListItem_t xListEnd; /*< List item that contains the maximum possible item value meaning it is always at the end of the list and is therefore used as a marker. */ - listSECOND_LIST_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ + listFIRST_LIST_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ + volatile UBaseType_t uxNumberOfItems; + ListItem_t * configLIST_VOLATILE pxIndex; /*< Used to walk through the list. Points to the last item returned by a call to listGET_OWNER_OF_NEXT_ENTRY (). */ + MiniListItem_t xListEnd; /*< List item that contains the maximum possible item value meaning it is always at the end of the list and is therefore used as a marker. */ + listSECOND_LIST_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ } List_t; /* @@ -177,7 +178,7 @@ typedef struct xLIST * \page listSET_LIST_ITEM_OWNER listSET_LIST_ITEM_OWNER * \ingroup LinkedList */ -#define listSET_LIST_ITEM_OWNER( pxListItem, pxOwner ) ( ( pxListItem )->pvOwner = ( void * ) ( pxOwner ) ) +#define listSET_LIST_ITEM_OWNER( pxListItem, pxOwner ) ( ( pxListItem )->pvOwner = ( void * ) ( pxOwner ) ) /* * Access macro to get the owner of a list item. The owner of a list item @@ -186,7 +187,7 @@ typedef struct xLIST * \page listGET_LIST_ITEM_OWNER listSET_LIST_ITEM_OWNER * \ingroup LinkedList */ -#define listGET_LIST_ITEM_OWNER( pxListItem ) ( ( pxListItem )->pvOwner ) +#define listGET_LIST_ITEM_OWNER( pxListItem ) ( ( pxListItem )->pvOwner ) /* * Access macro to set the value of the list item. In most cases the value is @@ -195,7 +196,7 @@ typedef struct xLIST * \page listSET_LIST_ITEM_VALUE listSET_LIST_ITEM_VALUE * \ingroup LinkedList */ -#define listSET_LIST_ITEM_VALUE( pxListItem, xValue ) ( ( pxListItem )->xItemValue = ( xValue ) ) +#define listSET_LIST_ITEM_VALUE( pxListItem, xValue ) ( ( pxListItem )->xItemValue = ( xValue ) ) /* * Access macro to retrieve the value of the list item. The value can @@ -205,7 +206,7 @@ typedef struct xLIST * \page listGET_LIST_ITEM_VALUE listGET_LIST_ITEM_VALUE * \ingroup LinkedList */ -#define listGET_LIST_ITEM_VALUE( pxListItem ) ( ( pxListItem )->xItemValue ) +#define listGET_LIST_ITEM_VALUE( pxListItem ) ( ( pxListItem )->xItemValue ) /* * Access macro to retrieve the value of the list item at the head of a given @@ -214,7 +215,7 @@ typedef struct xLIST * \page listGET_LIST_ITEM_VALUE listGET_LIST_ITEM_VALUE * \ingroup LinkedList */ -#define listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxList ) ( ( ( pxList )->xListEnd ).pxNext->xItemValue ) +#define listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxList ) ( ( ( pxList )->xListEnd ).pxNext->xItemValue ) /* * Return the list item at the head of the list. @@ -222,7 +223,7 @@ typedef struct xLIST * \page listGET_HEAD_ENTRY listGET_HEAD_ENTRY * \ingroup LinkedList */ -#define listGET_HEAD_ENTRY( pxList ) ( ( ( pxList )->xListEnd ).pxNext ) +#define listGET_HEAD_ENTRY( pxList ) ( ( ( pxList )->xListEnd ).pxNext ) /* * Return the next list item. @@ -230,7 +231,7 @@ typedef struct xLIST * \page listGET_NEXT listGET_NEXT * \ingroup LinkedList */ -#define listGET_NEXT( pxListItem ) ( ( pxListItem )->pxNext ) +#define listGET_NEXT( pxListItem ) ( ( pxListItem )->pxNext ) /* * Return the list item that marks the end of the list @@ -238,7 +239,7 @@ typedef struct xLIST * \page listGET_END_MARKER listGET_END_MARKER * \ingroup LinkedList */ -#define listGET_END_MARKER( pxList ) ( ( ListItem_t const * ) ( &( ( pxList )->xListEnd ) ) ) +#define listGET_END_MARKER( pxList ) ( ( ListItem_t const * ) ( &( ( pxList )->xListEnd ) ) ) /* * Access macro to determine if a list contains any items. The macro will @@ -247,12 +248,12 @@ typedef struct xLIST * \page listLIST_IS_EMPTY listLIST_IS_EMPTY * \ingroup LinkedList */ -#define listLIST_IS_EMPTY( pxList ) ( ( ( pxList )->uxNumberOfItems == ( UBaseType_t ) 0 ) ? pdTRUE : pdFALSE ) +#define listLIST_IS_EMPTY( pxList ) ( ( ( pxList )->uxNumberOfItems == ( UBaseType_t ) 0 ) ? pdTRUE : pdFALSE ) /* * Access macro to return the number of items in the list. */ -#define listCURRENT_LIST_LENGTH( pxList ) ( ( pxList )->uxNumberOfItems ) +#define listCURRENT_LIST_LENGTH( pxList ) ( ( pxList )->uxNumberOfItems ) /* * Access function to obtain the owner of the next entry in a list. @@ -274,18 +275,18 @@ typedef struct xLIST * \page listGET_OWNER_OF_NEXT_ENTRY listGET_OWNER_OF_NEXT_ENTRY * \ingroup LinkedList */ -#define listGET_OWNER_OF_NEXT_ENTRY( pxTCB, pxList ) \ -{ \ -List_t * const pxConstList = ( pxList ); \ - /* Increment the index to the next item and return the item, ensuring */ \ - /* we don't return the marker used at the end of the list. */ \ - ( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \ - if( ( void * ) ( pxConstList )->pxIndex == ( void * ) &( ( pxConstList )->xListEnd ) ) \ - { \ - ( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \ - } \ - ( pxTCB ) = ( pxConstList )->pxIndex->pvOwner; \ -} +#define listGET_OWNER_OF_NEXT_ENTRY( pxTCB, pxList ) \ + { \ + List_t * const pxConstList = ( pxList ); \ + /* Increment the index to the next item and return the item, ensuring */ \ + /* we don't return the marker used at the end of the list. */ \ + ( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \ + if( ( void * ) ( pxConstList )->pxIndex == ( void * ) &( ( pxConstList )->xListEnd ) ) \ + { \ + ( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \ + } \ + ( pxTCB ) = ( pxConstList )->pxIndex->pvOwner; \ + } /* @@ -304,7 +305,7 @@ List_t * const pxConstList = ( pxList ); \ * \page listGET_OWNER_OF_HEAD_ENTRY listGET_OWNER_OF_HEAD_ENTRY * \ingroup LinkedList */ -#define listGET_OWNER_OF_HEAD_ENTRY( pxList ) ( (&( ( pxList )->xListEnd ))->pxNext->pvOwner ) +#define listGET_OWNER_OF_HEAD_ENTRY( pxList ) ( ( &( ( pxList )->xListEnd ) )->pxNext->pvOwner ) /* * Check to see if a list item is within a list. The list item maintains a @@ -315,7 +316,7 @@ List_t * const pxConstList = ( pxList ); \ * @param pxListItem The list item we want to know if is in the list. * @return pdTRUE if the list item is in the list, otherwise pdFALSE. */ -#define listIS_CONTAINED_WITHIN( pxList, pxListItem ) ( ( ( pxListItem )->pxContainer == ( pxList ) ) ? ( pdTRUE ) : ( pdFALSE ) ) +#define listIS_CONTAINED_WITHIN( pxList, pxListItem ) ( ( ( pxListItem )->pxContainer == ( pxList ) ) ? ( pdTRUE ) : ( pdFALSE ) ) /* * Return the list a list item is contained within (referenced from). @@ -323,14 +324,14 @@ List_t * const pxConstList = ( pxList ); \ * @param pxListItem The list item being queried. * @return A pointer to the List_t object that references the pxListItem */ -#define listLIST_ITEM_CONTAINER( pxListItem ) ( ( pxListItem )->pxContainer ) +#define listLIST_ITEM_CONTAINER( pxListItem ) ( ( pxListItem )->pxContainer ) /* * This provides a crude means of knowing if a list has been initialised, as * pxList->xListEnd.xItemValue is set to portMAX_DELAY by the vListInitialise() * function. */ -#define listLIST_IS_INITIALISED( pxList ) ( ( pxList )->xListEnd.xItemValue == portMAX_DELAY ) +#define listLIST_IS_INITIALISED( pxList ) ( ( pxList )->xListEnd.xItemValue == portMAX_DELAY ) /* * Must be called before a list is used! This initialises all the members @@ -366,7 +367,8 @@ void vListInitialiseItem( ListItem_t * const pxItem ) PRIVILEGED_FUNCTION; * \page vListInsert vListInsert * \ingroup LinkedList */ -void vListInsert( List_t * const pxList, ListItem_t * const pxNewListItem ) PRIVILEGED_FUNCTION; +void vListInsert( List_t * const pxList, + ListItem_t * const pxNewListItem ) PRIVILEGED_FUNCTION; /* * Insert a list item into a list. The item will be inserted in a position @@ -387,7 +389,8 @@ void vListInsert( List_t * const pxList, ListItem_t * const pxNewListItem ) PRIV * \page vListInsertEnd vListInsertEnd * \ingroup LinkedList */ -void vListInsertEnd( List_t * const pxList, ListItem_t * const pxNewListItem ) PRIVILEGED_FUNCTION; +void vListInsertEnd( List_t * const pxList, + ListItem_t * const pxNewListItem ) PRIVILEGED_FUNCTION; /* * Remove an item from a list. The list item has a pointer to the list that @@ -404,8 +407,10 @@ void vListInsertEnd( List_t * const pxList, ListItem_t * const pxNewListItem ) P */ UBaseType_t uxListRemove( ListItem_t * const pxItemToRemove ) PRIVILEGED_FUNCTION; +/* *INDENT-OFF* */ #ifdef __cplusplus -} + } #endif +/* *INDENT-ON* */ -#endif +#endif /* ifndef LIST_H */ diff --git a/tools/sdk/esp32s2/include/freertos/include/freertos/message_buffer.h b/tools/sdk/esp32s2/include/freertos/include/freertos/message_buffer.h index a49324da437..e57c589fbac 100644 --- a/tools/sdk/esp32s2/include/freertos/include/freertos/message_buffer.h +++ b/tools/sdk/esp32s2/include/freertos/include/freertos/message_buffer.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ @@ -63,15 +62,17 @@ #define FREERTOS_MESSAGE_BUFFER_H #ifndef INC_FREERTOS_H - #error "include FreeRTOS.h must appear in source files before include message_buffer.h" + #error "include FreeRTOS.h must appear in source files before include message_buffer.h" #endif /* Message buffers are built onto of stream buffers. */ #include "stream_buffer.h" +/* *INDENT-OFF* */ #if defined( __cplusplus ) -extern "C" { + extern "C" { #endif +/* *INDENT-ON* */ /** * Type by which message buffers are referenced. For example, a call to @@ -84,6 +85,14 @@ typedef void * MessageBufferHandle_t; /*-----------------------------------------------------------*/ /** + * @cond + * message_buffer.h + * + * @code{c} + * MessageBufferHandle_t xMessageBufferCreate( size_t xBufferSizeBytes ); + * @endcode + * @endcond + * * Creates a new message buffer using dynamically allocated memory. See * xMessageBufferCreateStatic() for a version that uses statically allocated * memory (memory that is allocated at compile time). @@ -113,28 +122,41 @@ typedef void * MessageBufferHandle_t; * MessageBufferHandle_t xMessageBuffer; * const size_t xMessageBufferSizeBytes = 100; * - * // Create a message buffer that can hold 100 bytes. The memory used to hold - * // both the message buffer structure and the messages themselves is allocated - * // dynamically. Each message added to the buffer consumes an additional 4 - * // bytes which are used to hold the lengh of the message. - * xMessageBuffer = xMessageBufferCreate( xMessageBufferSizeBytes ); - * - * if( xMessageBuffer == NULL ) - * { - * // There was not enough heap memory space available to create the - * // message buffer. - * } - * else - * { - * // The message buffer was created successfully and can now be used. - * } + * // Create a message buffer that can hold 100 bytes. The memory used to hold + * // both the message buffer structure and the messages themselves is allocated + * // dynamically. Each message added to the buffer consumes an additional 4 + * // bytes which are used to hold the lengh of the message. + * xMessageBuffer = xMessageBufferCreate( xMessageBufferSizeBytes ); + * + * if( xMessageBuffer == NULL ) + * { + * // There was not enough heap memory space available to create the + * // message buffer. + * } + * else + * { + * // The message buffer was created successfully and can now be used. + * } * * @endcode + * @cond + * \defgroup xMessageBufferCreate xMessageBufferCreate + * @endcond * \ingroup MessageBufferManagement */ -#define xMessageBufferCreate( xBufferSizeBytes ) ( MessageBufferHandle_t ) xStreamBufferGenericCreate( xBufferSizeBytes, ( size_t ) 0, pdTRUE ) +#define xMessageBufferCreate( xBufferSizeBytes ) \ + ( MessageBufferHandle_t ) xStreamBufferGenericCreate( xBufferSizeBytes, ( size_t ) 0, pdTRUE ) /** + * @cond + * message_buffer.h + * + * @code{c} + * MessageBufferHandle_t xMessageBufferCreateStatic( size_t xBufferSizeBytes, + * uint8_t *pucMessageBufferStorageArea, + * StaticMessageBuffer_t *pxStaticMessageBuffer ); + * @endcode + * @endcond * Creates a new message buffer using statically allocated memory. See * xMessageBufferCreate() for a version that uses dynamically allocated memory. * @@ -176,23 +198,38 @@ typedef void * MessageBufferHandle_t; * { * MessageBufferHandle_t xMessageBuffer; * - * xMessageBuffer = xMessageBufferCreateStatic( sizeof( ucBufferStorage ), - * ucBufferStorage, - * &xMessageBufferStruct ); + * xMessageBuffer = xMessageBufferCreateStatic( sizeof( ucBufferStorage ), + * ucBufferStorage, + * &xMessageBufferStruct ); * - * // As neither the pucMessageBufferStorageArea or pxStaticMessageBuffer - * // parameters were NULL, xMessageBuffer will not be NULL, and can be used to - * // reference the created message buffer in other message buffer API calls. + * // As neither the pucMessageBufferStorageArea or pxStaticMessageBuffer + * // parameters were NULL, xMessageBuffer will not be NULL, and can be used to + * // reference the created message buffer in other message buffer API calls. * - * // Other code that uses the message buffer can go here. + * // Other code that uses the message buffer can go here. * } * * @endcode + * @cond + * \defgroup xMessageBufferCreateStatic xMessageBufferCreateStatic + * @endcond * \ingroup MessageBufferManagement */ -#define xMessageBufferCreateStatic( xBufferSizeBytes, pucMessageBufferStorageArea, pxStaticMessageBuffer ) ( MessageBufferHandle_t ) xStreamBufferGenericCreateStatic( xBufferSizeBytes, 0, pdTRUE, pucMessageBufferStorageArea, pxStaticMessageBuffer ) +#define xMessageBufferCreateStatic( xBufferSizeBytes, pucMessageBufferStorageArea, pxStaticMessageBuffer ) \ + ( MessageBufferHandle_t ) xStreamBufferGenericCreateStatic( xBufferSizeBytes, 0, pdTRUE, pucMessageBufferStorageArea, pxStaticMessageBuffer ) /** + * @cond + * message_buffer.h + * + * @code{c} + * size_t xMessageBufferSend( MessageBufferHandle_t xMessageBuffer, + * const void *pvTxData, + * size_t xDataLengthBytes, + * TickType_t xTicksToWait ); + * @endcode + * @endcond + * * Sends a discrete message to the message buffer. The message can be any * length that fits within the buffer's free space, and is copied into the * buffer. @@ -256,32 +293,47 @@ typedef void * MessageBufferHandle_t; * char *pcStringToSend = "String to send"; * const TickType_t x100ms = pdMS_TO_TICKS( 100 ); * - * // Send an array to the message buffer, blocking for a maximum of 100ms to - * // wait for enough space to be available in the message buffer. - * xBytesSent = xMessageBufferSend( xMessageBuffer, ( void * ) ucArrayToSend, sizeof( ucArrayToSend ), x100ms ); - * - * if( xBytesSent != sizeof( ucArrayToSend ) ) - * { - * // The call to xMessageBufferSend() times out before there was enough - * // space in the buffer for the data to be written. - * } - * - * // Send the string to the message buffer. Return immediately if there is - * // not enough space in the buffer. - * xBytesSent = xMessageBufferSend( xMessageBuffer, ( void * ) pcStringToSend, strlen( pcStringToSend ), 0 ); - * - * if( xBytesSent != strlen( pcStringToSend ) ) - * { - * // The string could not be added to the message buffer because there was - * // not enough free space in the buffer. - * } + * // Send an array to the message buffer, blocking for a maximum of 100ms to + * // wait for enough space to be available in the message buffer. + * xBytesSent = xMessageBufferSend( xMessageBuffer, ( void * ) ucArrayToSend, sizeof( ucArrayToSend ), x100ms ); + * + * if( xBytesSent != sizeof( ucArrayToSend ) ) + * { + * // The call to xMessageBufferSend() times out before there was enough + * // space in the buffer for the data to be written. + * } + * + * // Send the string to the message buffer. Return immediately if there is + * // not enough space in the buffer. + * xBytesSent = xMessageBufferSend( xMessageBuffer, ( void * ) pcStringToSend, strlen( pcStringToSend ), 0 ); + * + * if( xBytesSent != strlen( pcStringToSend ) ) + * { + * // The string could not be added to the message buffer because there was + * // not enough free space in the buffer. + * } * } * @endcode + * @cond + * \defgroup xMessageBufferSend xMessageBufferSend + * @endcond * \ingroup MessageBufferManagement */ -#define xMessageBufferSend( xMessageBuffer, pvTxData, xDataLengthBytes, xTicksToWait ) xStreamBufferSend( ( StreamBufferHandle_t ) xMessageBuffer, pvTxData, xDataLengthBytes, xTicksToWait ) +#define xMessageBufferSend( xMessageBuffer, pvTxData, xDataLengthBytes, xTicksToWait ) \ + xStreamBufferSend( ( StreamBufferHandle_t ) xMessageBuffer, pvTxData, xDataLengthBytes, xTicksToWait ) /** + * @cond + * message_buffer.h + * + * @code{c} + * size_t xMessageBufferSendFromISR( MessageBufferHandle_t xMessageBuffer, + * const void *pvTxData, + * size_t xDataLengthBytes, + * BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * @endcond + * * Interrupt safe version of the API function that sends a discrete message to * the message buffer. The message can be any length that fits within the * buffer's free space, and is copied into the buffer. @@ -348,34 +400,49 @@ typedef void * MessageBufferHandle_t; * char *pcStringToSend = "String to send"; * BaseType_t xHigherPriorityTaskWoken = pdFALSE; // Initialised to pdFALSE. * - * // Attempt to send the string to the message buffer. - * xBytesSent = xMessageBufferSendFromISR( xMessageBuffer, - * ( void * ) pcStringToSend, - * strlen( pcStringToSend ), - * &xHigherPriorityTaskWoken ); - * - * if( xBytesSent != strlen( pcStringToSend ) ) - * { - * // The string could not be added to the message buffer because there was - * // not enough free space in the buffer. - * } - * - * // If xHigherPriorityTaskWoken was set to pdTRUE inside - * // xMessageBufferSendFromISR() then a task that has a priority above the - * // priority of the currently executing task was unblocked and a context - * // switch should be performed to ensure the ISR returns to the unblocked - * // task. In most FreeRTOS ports this is done by simply passing - * // xHigherPriorityTaskWoken into portYIELD_FROM_ISR(), which will test the - * // variables value, and perform the context switch if necessary. Check the - * // documentation for the port in use for port specific instructions. - * portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); + * // Attempt to send the string to the message buffer. + * xBytesSent = xMessageBufferSendFromISR( xMessageBuffer, + * ( void * ) pcStringToSend, + * strlen( pcStringToSend ), + * &xHigherPriorityTaskWoken ); + * + * if( xBytesSent != strlen( pcStringToSend ) ) + * { + * // The string could not be added to the message buffer because there was + * // not enough free space in the buffer. + * } + * + * // If xHigherPriorityTaskWoken was set to pdTRUE inside + * // xMessageBufferSendFromISR() then a task that has a priority above the + * // priority of the currently executing task was unblocked and a context + * // switch should be performed to ensure the ISR returns to the unblocked + * // task. In most FreeRTOS ports this is done by simply passing + * // xHigherPriorityTaskWoken into portYIELD_FROM_ISR(), which will test the + * // variables value, and perform the context switch if necessary. Check the + * // documentation for the port in use for port specific instructions. + * portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); * } * @endcode + * @cond + * \defgroup xMessageBufferSendFromISR xMessageBufferSendFromISR + * @endcond * \ingroup MessageBufferManagement */ -#define xMessageBufferSendFromISR( xMessageBuffer, pvTxData, xDataLengthBytes, pxHigherPriorityTaskWoken ) xStreamBufferSendFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pvTxData, xDataLengthBytes, pxHigherPriorityTaskWoken ) +#define xMessageBufferSendFromISR( xMessageBuffer, pvTxData, xDataLengthBytes, pxHigherPriorityTaskWoken ) \ + xStreamBufferSendFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pvTxData, xDataLengthBytes, pxHigherPriorityTaskWoken ) /** + * @cond + * message_buffer.h + * + * @code{c} + * size_t xMessageBufferReceive( MessageBufferHandle_t xMessageBuffer, + * void *pvRxData, + * size_t xBufferLengthBytes, + * TickType_t xTicksToWait ); + * @endcode + * @endcond + * * Receives a discrete message from a message buffer. Messages can be of * variable length and are copied out of the buffer. * @@ -434,27 +501,42 @@ typedef void * MessageBufferHandle_t; * size_t xReceivedBytes; * const TickType_t xBlockTime = pdMS_TO_TICKS( 20 ); * - * // Receive the next message from the message buffer. Wait in the Blocked - * // state (so not using any CPU processing time) for a maximum of 100ms for - * // a message to become available. - * xReceivedBytes = xMessageBufferReceive( xMessageBuffer, - * ( void * ) ucRxData, - * sizeof( ucRxData ), - * xBlockTime ); - * - * if( xReceivedBytes > 0 ) - * { - * // A ucRxData contains a message that is xReceivedBytes long. Process - * // the message here.... - * } + * // Receive the next message from the message buffer. Wait in the Blocked + * // state (so not using any CPU processing time) for a maximum of 100ms for + * // a message to become available. + * xReceivedBytes = xMessageBufferReceive( xMessageBuffer, + * ( void * ) ucRxData, + * sizeof( ucRxData ), + * xBlockTime ); + * + * if( xReceivedBytes > 0 ) + * { + * // A ucRxData contains a message that is xReceivedBytes long. Process + * // the message here.... + * } * } * @endcode + * @cond + * \defgroup xMessageBufferReceive xMessageBufferReceive + * @endcond * \ingroup MessageBufferManagement */ -#define xMessageBufferReceive( xMessageBuffer, pvRxData, xBufferLengthBytes, xTicksToWait ) xStreamBufferReceive( ( StreamBufferHandle_t ) xMessageBuffer, pvRxData, xBufferLengthBytes, xTicksToWait ) +#define xMessageBufferReceive( xMessageBuffer, pvRxData, xBufferLengthBytes, xTicksToWait ) \ + xStreamBufferReceive( ( StreamBufferHandle_t ) xMessageBuffer, pvRxData, xBufferLengthBytes, xTicksToWait ) /** + * @cond + * message_buffer.h + * + * @code{c} + * size_t xMessageBufferReceiveFromISR( MessageBufferHandle_t xMessageBuffer, + * void *pvRxData, + * size_t xBufferLengthBytes, + * BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * @endcond + * * An interrupt safe version of the API function that receives a discrete * message from a message buffer. Messages can be of variable length and are * copied out of the buffer. @@ -517,34 +599,46 @@ typedef void * MessageBufferHandle_t; * size_t xReceivedBytes; * BaseType_t xHigherPriorityTaskWoken = pdFALSE; // Initialised to pdFALSE. * - * // Receive the next message from the message buffer. - * xReceivedBytes = xMessageBufferReceiveFromISR( xMessageBuffer, - * ( void * ) ucRxData, - * sizeof( ucRxData ), - * &xHigherPriorityTaskWoken ); - * - * if( xReceivedBytes > 0 ) - * { - * // A ucRxData contains a message that is xReceivedBytes long. Process - * // the message here.... - * } - * - * // If xHigherPriorityTaskWoken was set to pdTRUE inside - * // xMessageBufferReceiveFromISR() then a task that has a priority above the - * // priority of the currently executing task was unblocked and a context - * // switch should be performed to ensure the ISR returns to the unblocked - * // task. In most FreeRTOS ports this is done by simply passing - * // xHigherPriorityTaskWoken into portYIELD_FROM_ISR(), which will test the - * // variables value, and perform the context switch if necessary. Check the - * // documentation for the port in use for port specific instructions. - * portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); + * // Receive the next message from the message buffer. + * xReceivedBytes = xMessageBufferReceiveFromISR( xMessageBuffer, + * ( void * ) ucRxData, + * sizeof( ucRxData ), + * &xHigherPriorityTaskWoken ); + * + * if( xReceivedBytes > 0 ) + * { + * // A ucRxData contains a message that is xReceivedBytes long. Process + * // the message here.... + * } + * + * // If xHigherPriorityTaskWoken was set to pdTRUE inside + * // xMessageBufferReceiveFromISR() then a task that has a priority above the + * // priority of the currently executing task was unblocked and a context + * // switch should be performed to ensure the ISR returns to the unblocked + * // task. In most FreeRTOS ports this is done by simply passing + * // xHigherPriorityTaskWoken into portYIELD_FROM_ISR(), which will test the + * // variables value, and perform the context switch if necessary. Check the + * // documentation for the port in use for port specific instructions. + * portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); * } * @endcode + * @cond + * \defgroup xMessageBufferReceiveFromISR xMessageBufferReceiveFromISR + * @endcond * \ingroup MessageBufferManagement */ -#define xMessageBufferReceiveFromISR( xMessageBuffer, pvRxData, xBufferLengthBytes, pxHigherPriorityTaskWoken ) xStreamBufferReceiveFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pvRxData, xBufferLengthBytes, pxHigherPriorityTaskWoken ) +#define xMessageBufferReceiveFromISR( xMessageBuffer, pvRxData, xBufferLengthBytes, pxHigherPriorityTaskWoken ) \ + xStreamBufferReceiveFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pvRxData, xBufferLengthBytes, pxHigherPriorityTaskWoken ) /** + * @cond + * message_buffer.h + * + * @code{c} + * void vMessageBufferDelete( MessageBufferHandle_t xMessageBuffer ); + * @endcode + * @endcond + * * Deletes a message buffer that was previously created using a call to * xMessageBufferCreate() or xMessageBufferCreateStatic(). If the message * buffer was created using dynamic memory (that is, by xMessageBufferCreate()), @@ -556,9 +650,17 @@ typedef void * MessageBufferHandle_t; * @param xMessageBuffer The handle of the message buffer to be deleted. * */ -#define vMessageBufferDelete( xMessageBuffer ) vStreamBufferDelete( ( StreamBufferHandle_t ) xMessageBuffer ) +#define vMessageBufferDelete( xMessageBuffer ) \ + vStreamBufferDelete( ( StreamBufferHandle_t ) xMessageBuffer ) /** + * @cond + * message_buffer.h + * @code{c} + * BaseType_t xMessageBufferIsFull( MessageBufferHandle_t xMessageBuffer ) ); + * @endcode + * @endcond + * * Tests to see if a message buffer is full. A message buffer is full if it * cannot accept any more messages, of any size, until space is made available * by a message being removed from the message buffer. @@ -568,9 +670,17 @@ typedef void * MessageBufferHandle_t; * @return If the message buffer referenced by xMessageBuffer is full then * pdTRUE is returned. Otherwise pdFALSE is returned. */ -#define xMessageBufferIsFull( xMessageBuffer ) xStreamBufferIsFull( ( StreamBufferHandle_t ) xMessageBuffer ) +#define xMessageBufferIsFull( xMessageBuffer ) \ + xStreamBufferIsFull( ( StreamBufferHandle_t ) xMessageBuffer ) /** + * @cond + * message_buffer.h + * @code{c} + * BaseType_t xMessageBufferIsEmpty( MessageBufferHandle_t xMessageBuffer ) ); + * @endcode + * @endcond + * * Tests to see if a message buffer is empty (does not contain any messages). * * @param xMessageBuffer The handle of the message buffer being queried. @@ -579,9 +689,17 @@ typedef void * MessageBufferHandle_t; * pdTRUE is returned. Otherwise pdFALSE is returned. * */ -#define xMessageBufferIsEmpty( xMessageBuffer ) xStreamBufferIsEmpty( ( StreamBufferHandle_t ) xMessageBuffer ) +#define xMessageBufferIsEmpty( xMessageBuffer ) \ + xStreamBufferIsEmpty( ( StreamBufferHandle_t ) xMessageBuffer ) /** + * @cond + * message_buffer.h + * @code{c} + * BaseType_t xMessageBufferReset( MessageBufferHandle_t xMessageBuffer ); + * @endcode + * @endcond + * * Resets a message buffer to its initial empty state, discarding any message it * contained. * @@ -594,12 +712,23 @@ typedef void * MessageBufferHandle_t; * the message queue to wait for space to become available, or to wait for a * a message to be available, then pdFAIL is returned. * + * @cond + * \defgroup xMessageBufferReset xMessageBufferReset + * @endcond * \ingroup MessageBufferManagement */ -#define xMessageBufferReset( xMessageBuffer ) xStreamBufferReset( ( StreamBufferHandle_t ) xMessageBuffer ) +#define xMessageBufferReset( xMessageBuffer ) \ + xStreamBufferReset( ( StreamBufferHandle_t ) xMessageBuffer ) /** + * @cond + * message_buffer.h + * @code{c} + * size_t xMessageBufferSpaceAvailable( MessageBufferHandle_t xMessageBuffer ) ); + * @endcode + * @endcond + * * Returns the number of bytes of free space in the message buffer. * * @param xMessageBuffer The handle of the message buffer being queried. @@ -611,12 +740,24 @@ typedef void * MessageBufferHandle_t; * architecture, so if xMessageBufferSpacesAvailable() returns 10, then the size * of the largest message that can be written to the message buffer is 6 bytes. * + * @cond + * \defgroup xMessageBufferSpaceAvailable xMessageBufferSpaceAvailable + * @endcond * \ingroup MessageBufferManagement */ -#define xMessageBufferSpaceAvailable( xMessageBuffer ) xStreamBufferSpacesAvailable( ( StreamBufferHandle_t ) xMessageBuffer ) -#define xMessageBufferSpacesAvailable( xMessageBuffer ) xStreamBufferSpacesAvailable( ( StreamBufferHandle_t ) xMessageBuffer ) /* Corrects typo in original macro name. */ +#define xMessageBufferSpaceAvailable( xMessageBuffer ) \ + xStreamBufferSpacesAvailable( ( StreamBufferHandle_t ) xMessageBuffer ) +#define xMessageBufferSpacesAvailable( xMessageBuffer ) \ + xStreamBufferSpacesAvailable( ( StreamBufferHandle_t ) xMessageBuffer ) /* Corrects typo in original macro name. */ /** + * @cond + * message_buffer.h + * @code{c} + * size_t xMessageBufferNextLengthBytes( MessageBufferHandle_t xMessageBuffer ) ); + * @endcode + * @endcond + * * Returns the length (in bytes) of the next message in a message buffer. * Useful if xMessageBufferReceive() returned 0 because the size of the buffer * passed into xMessageBufferReceive() was too small to hold the next message. @@ -626,11 +767,23 @@ typedef void * MessageBufferHandle_t; * @return The length (in bytes) of the next message in the message buffer, or 0 * if the message buffer is empty. * + * @cond + * \defgroup xMessageBufferNextLengthBytes xMessageBufferNextLengthBytes + * @endcond * \ingroup MessageBufferManagement */ -#define xMessageBufferNextLengthBytes( xMessageBuffer ) xStreamBufferNextMessageLengthBytes( ( StreamBufferHandle_t ) xMessageBuffer ) PRIVILEGED_FUNCTION; +#define xMessageBufferNextLengthBytes( xMessageBuffer ) \ + xStreamBufferNextMessageLengthBytes( ( StreamBufferHandle_t ) xMessageBuffer ) PRIVILEGED_FUNCTION; /** + * @cond + * message_buffer.h + * + * @code{c} + * BaseType_t xMessageBufferSendCompletedFromISR( MessageBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * @endcond + * * For advanced users only. * * The sbSEND_COMPLETED() macro is called from within the FreeRTOS APIs when @@ -658,11 +811,23 @@ typedef void * MessageBufferHandle_t; * @return If a task was removed from the Blocked state then pdTRUE is returned. * Otherwise pdFALSE is returned. * + * @cond + * \defgroup xMessageBufferSendCompletedFromISR xMessageBufferSendCompletedFromISR + * @endcond * \ingroup StreamBufferManagement */ -#define xMessageBufferSendCompletedFromISR( xMessageBuffer, pxHigherPriorityTaskWoken ) xStreamBufferSendCompletedFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pxHigherPriorityTaskWoken ) +#define xMessageBufferSendCompletedFromISR( xMessageBuffer, pxHigherPriorityTaskWoken ) \ + xStreamBufferSendCompletedFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pxHigherPriorityTaskWoken ) /** + * @cond + * message_buffer.h + * + * @code{c} + * BaseType_t xMessageBufferReceiveCompletedFromISR( MessageBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * @endcond + * * For advanced users only. * * The sbRECEIVE_COMPLETED() macro is called from within the FreeRTOS APIs when @@ -691,12 +856,18 @@ typedef void * MessageBufferHandle_t; * @return If a task was removed from the Blocked state then pdTRUE is returned. * Otherwise pdFALSE is returned. * + * @cond + * \defgroup xMessageBufferReceiveCompletedFromISR xMessageBufferReceiveCompletedFromISR + * @endcond * \ingroup StreamBufferManagement */ -#define xMessageBufferReceiveCompletedFromISR( xMessageBuffer, pxHigherPriorityTaskWoken ) xStreamBufferReceiveCompletedFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pxHigherPriorityTaskWoken ) +#define xMessageBufferReceiveCompletedFromISR( xMessageBuffer, pxHigherPriorityTaskWoken ) \ + xStreamBufferReceiveCompletedFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pxHigherPriorityTaskWoken ) +/* *INDENT-OFF* */ #if defined( __cplusplus ) -} /* extern "C" */ + } /* extern "C" */ #endif +/* *INDENT-ON* */ -#endif /* !defined( FREERTOS_MESSAGE_BUFFER_H ) */ +#endif /* !defined( FREERTOS_MESSAGE_BUFFER_H ) */ diff --git a/tools/sdk/esp32s2/include/freertos/include/freertos/mpu_prototypes.h b/tools/sdk/esp32s2/include/freertos/include/freertos/mpu_prototypes.h new file mode 100644 index 00000000000..ceb74f3e5bc --- /dev/null +++ b/tools/sdk/esp32s2/include/freertos/include/freertos/mpu_prototypes.h @@ -0,0 +1,257 @@ +/* + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * 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. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +/* + * When the MPU is used the standard (non MPU) API functions are mapped to + * equivalents that start "MPU_", the prototypes for which are defined in this + * header files. This will cause the application code to call the MPU_ version + * which wraps the non-MPU version with privilege promoting then demoting code, + * so the kernel code always runs will full privileges. + */ + + +#ifndef MPU_PROTOTYPES_H +#define MPU_PROTOTYPES_H + +/* MPU versions of tasks.h API functions. */ +BaseType_t MPU_xTaskCreate( TaskFunction_t pxTaskCode, + const char * const pcName, + const uint16_t usStackDepth, + void * const pvParameters, + UBaseType_t uxPriority, + TaskHandle_t * const pxCreatedTask ) FREERTOS_SYSTEM_CALL; +TaskHandle_t MPU_xTaskCreateStatic( 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 ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskDelete( TaskHandle_t xTaskToDelete ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskDelay( const TickType_t xTicksToDelay ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskDelayUntil( TickType_t * const pxPreviousWakeTime, + const TickType_t xTimeIncrement ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskAbortDelay( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxTaskPriorityGet( const TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +eTaskState MPU_eTaskGetState( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskGetInfo( TaskHandle_t xTask, + TaskStatus_t * pxTaskStatus, + BaseType_t xGetFreeStackSpace, + eTaskState eState ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskPrioritySet( TaskHandle_t xTask, + UBaseType_t uxNewPriority ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskSuspend( TaskHandle_t xTaskToSuspend ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskResume( TaskHandle_t xTaskToResume ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskStartScheduler( void ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskSuspendAll( void ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskResumeAll( void ) FREERTOS_SYSTEM_CALL; +TickType_t MPU_xTaskGetTickCount( void ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxTaskGetNumberOfTasks( void ) FREERTOS_SYSTEM_CALL; +char * MPU_pcTaskGetName( TaskHandle_t xTaskToQuery ) FREERTOS_SYSTEM_CALL; +TaskHandle_t MPU_xTaskGetHandle( const char * pcNameToQuery ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +configSTACK_DEPTH_TYPE MPU_uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskSetApplicationTaskTag( TaskHandle_t xTask, + TaskHookFunction_t pxHookFunction ) FREERTOS_SYSTEM_CALL; +TaskHookFunction_t MPU_xTaskGetApplicationTaskTag( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, + BaseType_t xIndex, + void * pvValue ) FREERTOS_SYSTEM_CALL; +void * MPU_pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, + BaseType_t xIndex ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask, + void * pvParameter ) FREERTOS_SYSTEM_CALL; +TaskHandle_t MPU_xTaskGetIdleTaskHandle( void ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, + const UBaseType_t uxArraySize, + uint32_t * const pulTotalRunTime ) FREERTOS_SYSTEM_CALL; +uint32_t MPU_ulTaskGetIdleRunTimeCounter( void ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskList( char * pcWriteBuffer ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskGetRunTimeStats( char * pcWriteBuffer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskGenericNotify( TaskHandle_t xTaskToNotify, + UBaseType_t uxIndexToNotify, + uint32_t ulValue, + eNotifyAction eAction, + uint32_t * pulPreviousNotificationValue ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskGenericNotifyWait( UBaseType_t uxIndexToWaitOn, + uint32_t ulBitsToClearOnEntry, + uint32_t ulBitsToClearOnExit, + uint32_t * pulNotificationValue, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +uint32_t MPU_ulTaskGenericNotifyTake( UBaseType_t uxIndexToWaitOn, + BaseType_t xClearCountOnExit, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskGenericNotifyStateClear( TaskHandle_t xTask, + UBaseType_t uxIndexToClear ) FREERTOS_SYSTEM_CALL; +uint32_t MPU_ulTaskGenericNotifyValueClear( TaskHandle_t xTask, + UBaseType_t uxIndexToClear, + uint32_t ulBitsToClear ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskIncrementTick( void ) FREERTOS_SYSTEM_CALL; +TaskHandle_t MPU_xTaskGetCurrentTaskHandle( void ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, + TickType_t * const pxTicksToWait ) FREERTOS_SYSTEM_CALL; +void MPU_vTaskMissedYield( void ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskGetSchedulerState( void ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) FREERTOS_SYSTEM_CALL; + +/* MPU versions of queue.h API functions. */ +BaseType_t MPU_xQueueGenericSend( QueueHandle_t xQueue, + const void * const pvItemToQueue, + TickType_t xTicksToWait, + const BaseType_t xCopyPosition ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueReceive( QueueHandle_t xQueue, + void * const pvBuffer, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueuePeek( QueueHandle_t xQueue, + void * const pvBuffer, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueSemaphoreTake( QueueHandle_t xQueue, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxQueueMessagesWaiting( const QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxQueueSpacesAvailable( const QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; +void MPU_vQueueDelete( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; +QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType ) FREERTOS_SYSTEM_CALL; +QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType, + StaticQueue_t * pxStaticQueue ) FREERTOS_SYSTEM_CALL; +QueueHandle_t MPU_xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, + const UBaseType_t uxInitialCount ) FREERTOS_SYSTEM_CALL; +QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, + const UBaseType_t uxInitialCount, + StaticQueue_t * pxStaticQueue ) FREERTOS_SYSTEM_CALL; +TaskHandle_t MPU_xQueueGetMutexHolder( QueueHandle_t xSemaphore ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueTakeMutexRecursive( QueueHandle_t xMutex, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueGiveMutexRecursive( QueueHandle_t pxMutex ) FREERTOS_SYSTEM_CALL; +void MPU_vQueueAddToRegistry( QueueHandle_t xQueue, + const char * pcName ) FREERTOS_SYSTEM_CALL; +void MPU_vQueueUnregisterQueue( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; +const char * MPU_pcQueueGetName( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; +QueueHandle_t MPU_xQueueGenericCreate( const UBaseType_t uxQueueLength, + const UBaseType_t uxItemSize, + const uint8_t ucQueueType ) FREERTOS_SYSTEM_CALL; +QueueHandle_t MPU_xQueueGenericCreateStatic( const UBaseType_t uxQueueLength, + const UBaseType_t uxItemSize, + uint8_t * pucQueueStorage, + StaticQueue_t * pxStaticQueue, + const uint8_t ucQueueType ) FREERTOS_SYSTEM_CALL; +QueueSetHandle_t MPU_xQueueCreateSet( const UBaseType_t uxEventQueueLength ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, + QueueSetHandle_t xQueueSet ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, + QueueSetHandle_t xQueueSet ) FREERTOS_SYSTEM_CALL; +QueueSetMemberHandle_t MPU_xQueueSelectFromSet( QueueSetHandle_t xQueueSet, + const TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xQueueGenericReset( QueueHandle_t xQueue, + BaseType_t xNewQueue ) FREERTOS_SYSTEM_CALL; +void MPU_vQueueSetQueueNumber( QueueHandle_t xQueue, + UBaseType_t uxQueueNumber ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxQueueGetQueueNumber( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; +uint8_t MPU_ucQueueGetQueueType( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL; + +/* MPU versions of timers.h API functions. */ +TimerHandle_t MPU_xTimerCreate( const char * const pcTimerName, + const TickType_t xTimerPeriodInTicks, + const UBaseType_t uxAutoReload, + void * const pvTimerID, + TimerCallbackFunction_t pxCallbackFunction ) FREERTOS_SYSTEM_CALL; +TimerHandle_t MPU_xTimerCreateStatic( const char * const pcTimerName, + const TickType_t xTimerPeriodInTicks, + const UBaseType_t uxAutoReload, + void * const pvTimerID, + TimerCallbackFunction_t pxCallbackFunction, + StaticTimer_t * pxTimerBuffer ) FREERTOS_SYSTEM_CALL; +void * MPU_pvTimerGetTimerID( const TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL; +void MPU_vTimerSetTimerID( TimerHandle_t xTimer, + void * pvNewID ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTimerIsTimerActive( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL; +TaskHandle_t MPU_xTimerGetTimerDaemonTaskHandle( void ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, + void * pvParameter1, + uint32_t ulParameter2, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +const char * MPU_pcTimerGetName( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL; +void MPU_vTimerSetReloadMode( TimerHandle_t xTimer, + const UBaseType_t uxAutoReload ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxTimerGetReloadMode( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL; +TickType_t MPU_xTimerGetPeriod( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL; +TickType_t MPU_xTimerGetExpiryTime( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTimerCreateTimerTask( void ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xTimerGenericCommand( TimerHandle_t xTimer, + const BaseType_t xCommandID, + const TickType_t xOptionalValue, + BaseType_t * const pxHigherPriorityTaskWoken, + const TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; + +/* MPU versions of event_group.h API functions. */ +EventGroupHandle_t MPU_xEventGroupCreate( void ) FREERTOS_SYSTEM_CALL; +EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t * pxEventGroupBuffer ) FREERTOS_SYSTEM_CALL; +EventBits_t MPU_xEventGroupWaitBits( EventGroupHandle_t xEventGroup, + const EventBits_t uxBitsToWaitFor, + const BaseType_t xClearOnExit, + const BaseType_t xWaitForAllBits, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +EventBits_t MPU_xEventGroupClearBits( EventGroupHandle_t xEventGroup, + const EventBits_t uxBitsToClear ) FREERTOS_SYSTEM_CALL; +EventBits_t MPU_xEventGroupSetBits( EventGroupHandle_t xEventGroup, + const EventBits_t uxBitsToSet ) FREERTOS_SYSTEM_CALL; +EventBits_t MPU_xEventGroupSync( EventGroupHandle_t xEventGroup, + const EventBits_t uxBitsToSet, + const EventBits_t uxBitsToWaitFor, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +void MPU_vEventGroupDelete( EventGroupHandle_t xEventGroup ) FREERTOS_SYSTEM_CALL; +UBaseType_t MPU_uxEventGroupGetNumber( void * xEventGroup ) FREERTOS_SYSTEM_CALL; + +/* MPU versions of message/stream_buffer.h API functions. */ +size_t MPU_xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, + const void * pvTxData, + size_t xDataLengthBytes, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +size_t MPU_xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer, + void * pvRxData, + size_t xBufferLengthBytes, + TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL; +size_t MPU_xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +void MPU_vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +size_t MPU_xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +size_t MPU_xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL; +BaseType_t MPU_xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, + size_t xTriggerLevel ) FREERTOS_SYSTEM_CALL; +StreamBufferHandle_t MPU_xStreamBufferGenericCreate( size_t xBufferSizeBytes, + size_t xTriggerLevelBytes, + BaseType_t xIsMessageBuffer ) FREERTOS_SYSTEM_CALL; +StreamBufferHandle_t MPU_xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes, + size_t xTriggerLevelBytes, + BaseType_t xIsMessageBuffer, + uint8_t * const pucStreamBufferStorageArea, + StaticStreamBuffer_t * const pxStaticStreamBuffer ) FREERTOS_SYSTEM_CALL; + + + +#endif /* MPU_PROTOTYPES_H */ diff --git a/tools/sdk/esp32s2/include/freertos/include/freertos/mpu_wrappers.h b/tools/sdk/esp32s2/include/freertos/include/freertos/mpu_wrappers.h index 7cbad5da080..c02dcd0c41e 100644 --- a/tools/sdk/esp32s2/include/freertos/include/freertos/mpu_wrappers.h +++ b/tools/sdk/esp32s2/include/freertos/include/freertos/mpu_wrappers.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,166 +19,165 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ #ifndef MPU_WRAPPERS_H #define MPU_WRAPPERS_H /* This file redefines API functions to be called through a wrapper macro, but -only for ports that are using the MPU. */ + * only for ports that are using the MPU. */ #if portUSING_MPU_WRAPPERS - /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE will be defined when this file is - included from queue.c or task.c to prevent it from having an effect within - those files. */ - #ifndef MPU_WRAPPERS_INCLUDED_FROM_API_FILE - - /* - * Map standard (non MPU) API functions to equivalents that start - * "MPU_". This will cause the application code to call the MPU_ - * version, which wraps the non-MPU version with privilege promoting - * then demoting code, so the kernel code always runs will full - * privileges. - */ - - /* Map standard tasks.h API functions to the MPU equivalents. */ - #define xTaskCreate MPU_xTaskCreate - #define xTaskCreateStatic MPU_xTaskCreateStatic - #define xTaskCreateRestricted MPU_xTaskCreateRestricted - #define vTaskAllocateMPURegions MPU_vTaskAllocateMPURegions - #define vTaskDelete MPU_vTaskDelete - #define vTaskDelay MPU_vTaskDelay - #define vTaskDelayUntil MPU_vTaskDelayUntil - #define xTaskAbortDelay MPU_xTaskAbortDelay - #define uxTaskPriorityGet MPU_uxTaskPriorityGet - #define eTaskGetState MPU_eTaskGetState - #define vTaskGetInfo MPU_vTaskGetInfo - #define vTaskPrioritySet MPU_vTaskPrioritySet - #define vTaskSuspend MPU_vTaskSuspend - #define vTaskResume MPU_vTaskResume - #define vTaskSuspendAll MPU_vTaskSuspendAll - #define xTaskResumeAll MPU_xTaskResumeAll - #define xTaskGetTickCount MPU_xTaskGetTickCount - #define uxTaskGetNumberOfTasks MPU_uxTaskGetNumberOfTasks - #define pcTaskGetName MPU_pcTaskGetName - #define xTaskGetHandle MPU_xTaskGetHandle - #define uxTaskGetStackHighWaterMark MPU_uxTaskGetStackHighWaterMark - #define uxTaskGetStackHighWaterMark2 MPU_uxTaskGetStackHighWaterMark2 - #define vTaskSetApplicationTaskTag MPU_vTaskSetApplicationTaskTag - #define xTaskGetApplicationTaskTag MPU_xTaskGetApplicationTaskTag - // #define vTaskSetThreadLocalStoragePointer MPU_vTaskSetThreadLocalStoragePointer - // #define pvTaskGetThreadLocalStoragePointer MPU_pvTaskGetThreadLocalStoragePointer - #define xTaskCallApplicationTaskHook MPU_xTaskCallApplicationTaskHook - #define xTaskGetIdleTaskHandle MPU_xTaskGetIdleTaskHandle - #define uxTaskGetSystemState MPU_uxTaskGetSystemState - #define vTaskList MPU_vTaskList - #define vTaskGetRunTimeStats MPU_vTaskGetRunTimeStats - #define ulTaskGetIdleRunTimeCounter MPU_ulTaskGetIdleRunTimeCounter - #define xTaskGenericNotify MPU_xTaskGenericNotify - #define xTaskNotifyWait MPU_xTaskNotifyWait - #define ulTaskNotifyTake MPU_ulTaskNotifyTake - #define xTaskNotifyStateClear MPU_xTaskNotifyStateClear - #define xTaskCatchUpTicks MPU_xTaskCatchUpTicks - - #define xTaskGetCurrentTaskHandle MPU_xTaskGetCurrentTaskHandle - #define vTaskSetTimeOutState MPU_vTaskSetTimeOutState - #define xTaskCheckForTimeOut MPU_xTaskCheckForTimeOut - #define xTaskGetSchedulerState MPU_xTaskGetSchedulerState - - /* Map standard queue.h API functions to the MPU equivalents. */ - #define xQueueGenericSend MPU_xQueueGenericSend - #define xQueueReceive MPU_xQueueReceive - #define xQueuePeek MPU_xQueuePeek - #define xQueueSemaphoreTake MPU_xQueueSemaphoreTake - #define uxQueueMessagesWaiting MPU_uxQueueMessagesWaiting - #define uxQueueSpacesAvailable MPU_uxQueueSpacesAvailable - #define vQueueDelete MPU_vQueueDelete - #define xQueueCreateMutex MPU_xQueueCreateMutex - #define xQueueCreateMutexStatic MPU_xQueueCreateMutexStatic - #define xQueueCreateCountingSemaphore MPU_xQueueCreateCountingSemaphore - #define xQueueCreateCountingSemaphoreStatic MPU_xQueueCreateCountingSemaphoreStatic - #define xQueueGetMutexHolder MPU_xQueueGetMutexHolder - #define xQueueTakeMutexRecursive MPU_xQueueTakeMutexRecursive - #define xQueueGiveMutexRecursive MPU_xQueueGiveMutexRecursive - #define xQueueGenericCreate MPU_xQueueGenericCreate - #define xQueueGenericCreateStatic MPU_xQueueGenericCreateStatic - #define xQueueCreateSet MPU_xQueueCreateSet - #define xQueueAddToSet MPU_xQueueAddToSet - #define xQueueRemoveFromSet MPU_xQueueRemoveFromSet - #define xQueueSelectFromSet MPU_xQueueSelectFromSet - #define xQueueGenericReset MPU_xQueueGenericReset - - #if( configQUEUE_REGISTRY_SIZE > 0 ) - #define vQueueAddToRegistry MPU_vQueueAddToRegistry - #define vQueueUnregisterQueue MPU_vQueueUnregisterQueue - #define pcQueueGetName MPU_pcQueueGetName - #endif - - /* Map standard timer.h API functions to the MPU equivalents. */ - #define xTimerCreate MPU_xTimerCreate - #define xTimerCreateStatic MPU_xTimerCreateStatic - #define pvTimerGetTimerID MPU_pvTimerGetTimerID - #define vTimerSetTimerID MPU_vTimerSetTimerID - #define xTimerIsTimerActive MPU_xTimerIsTimerActive - #define xTimerGetTimerDaemonTaskHandle MPU_xTimerGetTimerDaemonTaskHandle - #define xTimerPendFunctionCall MPU_xTimerPendFunctionCall - #define pcTimerGetName MPU_pcTimerGetName - #define vTimerSetReloadMode MPU_vTimerSetReloadMode - #define xTimerGetPeriod MPU_xTimerGetPeriod - #define xTimerGetExpiryTime MPU_xTimerGetExpiryTime - #define xTimerGenericCommand MPU_xTimerGenericCommand - - /* Map standard event_group.h API functions to the MPU equivalents. */ - #define xEventGroupCreate MPU_xEventGroupCreate - #define xEventGroupCreateStatic MPU_xEventGroupCreateStatic - #define xEventGroupWaitBits MPU_xEventGroupWaitBits - #define xEventGroupClearBits MPU_xEventGroupClearBits - #define xEventGroupSetBits MPU_xEventGroupSetBits - #define xEventGroupSync MPU_xEventGroupSync - #define vEventGroupDelete MPU_vEventGroupDelete - - /* Map standard message/stream_buffer.h API functions to the MPU - equivalents. */ - #define xStreamBufferSend MPU_xStreamBufferSend - #define xStreamBufferReceive MPU_xStreamBufferReceive - #define xStreamBufferNextMessageLengthBytes MPU_xStreamBufferNextMessageLengthBytes - #define vStreamBufferDelete MPU_vStreamBufferDelete - #define xStreamBufferIsFull MPU_xStreamBufferIsFull - #define xStreamBufferIsEmpty MPU_xStreamBufferIsEmpty - #define xStreamBufferReset MPU_xStreamBufferReset - #define xStreamBufferSpacesAvailable MPU_xStreamBufferSpacesAvailable - #define xStreamBufferBytesAvailable MPU_xStreamBufferBytesAvailable - #define xStreamBufferSetTriggerLevel MPU_xStreamBufferSetTriggerLevel - #define xStreamBufferGenericCreate MPU_xStreamBufferGenericCreate - #define xStreamBufferGenericCreateStatic MPU_xStreamBufferGenericCreateStatic - - - /* Remove the privileged function macro, but keep the PRIVILEGED_DATA - macro so applications can place data in privileged access sections - (useful when using statically allocated objects). */ - #define PRIVILEGED_FUNCTION - #define PRIVILEGED_DATA __attribute__((section("privileged_data"))) - #define FREERTOS_SYSTEM_CALL - - #else /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */ - - /* Ensure API functions go in the privileged execution section. */ - #define PRIVILEGED_FUNCTION __attribute__((section("privileged_functions"))) - #define PRIVILEGED_DATA __attribute__((section("privileged_data"))) - #define FREERTOS_SYSTEM_CALL __attribute__((section( "freertos_system_calls"))) - - #endif /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */ +/* MPU_WRAPPERS_INCLUDED_FROM_API_FILE will be defined when this file is + * included from queue.c or task.c to prevent it from having an effect within + * those files. */ + #ifndef MPU_WRAPPERS_INCLUDED_FROM_API_FILE + +/* + * Map standard (non MPU) API functions to equivalents that start + * "MPU_". This will cause the application code to call the MPU_ + * version, which wraps the non-MPU version with privilege promoting + * then demoting code, so the kernel code always runs will full + * privileges. + */ + +/* Map standard tasks.h API functions to the MPU equivalents. */ + #define xTaskCreate MPU_xTaskCreate + #define xTaskCreateStatic MPU_xTaskCreateStatic + #define xTaskCreateRestricted MPU_xTaskCreateRestricted + #define vTaskAllocateMPURegions MPU_vTaskAllocateMPURegions + #define vTaskDelete MPU_vTaskDelete + #define vTaskDelay MPU_vTaskDelay + #define vTaskDelayUntil MPU_vTaskDelayUntil + #define xTaskAbortDelay MPU_xTaskAbortDelay + #define uxTaskPriorityGet MPU_uxTaskPriorityGet + #define eTaskGetState MPU_eTaskGetState + #define vTaskGetInfo MPU_vTaskGetInfo + #define vTaskPrioritySet MPU_vTaskPrioritySet + #define vTaskSuspend MPU_vTaskSuspend + #define vTaskResume MPU_vTaskResume + #define vTaskSuspendAll MPU_vTaskSuspendAll + #define xTaskResumeAll MPU_xTaskResumeAll + #define xTaskGetTickCount MPU_xTaskGetTickCount + #define uxTaskGetNumberOfTasks MPU_uxTaskGetNumberOfTasks + #define pcTaskGetName MPU_pcTaskGetName + #define xTaskGetHandle MPU_xTaskGetHandle + #define uxTaskGetStackHighWaterMark MPU_uxTaskGetStackHighWaterMark + #define uxTaskGetStackHighWaterMark2 MPU_uxTaskGetStackHighWaterMark2 + #define vTaskSetApplicationTaskTag MPU_vTaskSetApplicationTaskTag + #define xTaskGetApplicationTaskTag MPU_xTaskGetApplicationTaskTag + // #define vTaskSetThreadLocalStoragePointer MPU_vTaskSetThreadLocalStoragePointer + // #define pvTaskGetThreadLocalStoragePointer MPU_pvTaskGetThreadLocalStoragePointer + #define xTaskCallApplicationTaskHook MPU_xTaskCallApplicationTaskHook + #define xTaskGetIdleTaskHandle MPU_xTaskGetIdleTaskHandle + #define uxTaskGetSystemState MPU_uxTaskGetSystemState + #define vTaskList MPU_vTaskList + #define vTaskGetRunTimeStats MPU_vTaskGetRunTimeStats + #define ulTaskGetIdleRunTimeCounter MPU_ulTaskGetIdleRunTimeCounter + #define xTaskGenericNotify MPU_xTaskGenericNotify + #define xTaskNotifyWait MPU_xTaskNotifyWait + #define ulTaskNotifyTake MPU_ulTaskNotifyTake + #define xTaskNotifyStateClear MPU_xTaskNotifyStateClear + #define xTaskCatchUpTicks MPU_xTaskCatchUpTicks + + #define xTaskGetCurrentTaskHandle MPU_xTaskGetCurrentTaskHandle + #define vTaskSetTimeOutState MPU_vTaskSetTimeOutState + #define xTaskCheckForTimeOut MPU_xTaskCheckForTimeOut + #define xTaskGetSchedulerState MPU_xTaskGetSchedulerState + + /* Map standard queue.h API functions to the MPU equivalents. */ + #define xQueueGenericSend MPU_xQueueGenericSend + #define xQueueReceive MPU_xQueueReceive + #define xQueuePeek MPU_xQueuePeek + #define xQueueSemaphoreTake MPU_xQueueSemaphoreTake + #define uxQueueMessagesWaiting MPU_uxQueueMessagesWaiting + #define uxQueueSpacesAvailable MPU_uxQueueSpacesAvailable + #define vQueueDelete MPU_vQueueDelete + #define xQueueCreateMutex MPU_xQueueCreateMutex + #define xQueueCreateMutexStatic MPU_xQueueCreateMutexStatic + #define xQueueCreateCountingSemaphore MPU_xQueueCreateCountingSemaphore + #define xQueueCreateCountingSemaphoreStatic MPU_xQueueCreateCountingSemaphoreStatic + #define xQueueGetMutexHolder MPU_xQueueGetMutexHolder + #define xQueueTakeMutexRecursive MPU_xQueueTakeMutexRecursive + #define xQueueGiveMutexRecursive MPU_xQueueGiveMutexRecursive + #define xQueueGenericCreate MPU_xQueueGenericCreate + #define xQueueGenericCreateStatic MPU_xQueueGenericCreateStatic + #define xQueueCreateSet MPU_xQueueCreateSet + #define xQueueAddToSet MPU_xQueueAddToSet + #define xQueueRemoveFromSet MPU_xQueueRemoveFromSet + #define xQueueSelectFromSet MPU_xQueueSelectFromSet + #define xQueueGenericReset MPU_xQueueGenericReset + + #if ( configQUEUE_REGISTRY_SIZE > 0 ) + #define vQueueAddToRegistry MPU_vQueueAddToRegistry + #define vQueueUnregisterQueue MPU_vQueueUnregisterQueue + #define pcQueueGetName MPU_pcQueueGetName + #endif + +/* Map standard timer.h API functions to the MPU equivalents. */ + #define xTimerCreate MPU_xTimerCreate + #define xTimerCreateStatic MPU_xTimerCreateStatic + #define pvTimerGetTimerID MPU_pvTimerGetTimerID + #define vTimerSetTimerID MPU_vTimerSetTimerID + #define xTimerIsTimerActive MPU_xTimerIsTimerActive + #define xTimerGetTimerDaemonTaskHandle MPU_xTimerGetTimerDaemonTaskHandle + #define xTimerPendFunctionCall MPU_xTimerPendFunctionCall + #define pcTimerGetName MPU_pcTimerGetName + #define vTimerSetReloadMode MPU_vTimerSetReloadMode + #define xTimerGetPeriod MPU_xTimerGetPeriod + #define xTimerGetExpiryTime MPU_xTimerGetExpiryTime + #define xTimerGenericCommand MPU_xTimerGenericCommand + +/* Map standard event_group.h API functions to the MPU equivalents. */ + #define xEventGroupCreate MPU_xEventGroupCreate + #define xEventGroupCreateStatic MPU_xEventGroupCreateStatic + #define xEventGroupWaitBits MPU_xEventGroupWaitBits + #define xEventGroupClearBits MPU_xEventGroupClearBits + #define xEventGroupSetBits MPU_xEventGroupSetBits + #define xEventGroupSync MPU_xEventGroupSync + #define vEventGroupDelete MPU_vEventGroupDelete + +/* Map standard message/stream_buffer.h API functions to the MPU + * equivalents. */ + #define xStreamBufferSend MPU_xStreamBufferSend + #define xStreamBufferReceive MPU_xStreamBufferReceive + #define xStreamBufferNextMessageLengthBytes MPU_xStreamBufferNextMessageLengthBytes + #define vStreamBufferDelete MPU_vStreamBufferDelete + #define xStreamBufferIsFull MPU_xStreamBufferIsFull + #define xStreamBufferIsEmpty MPU_xStreamBufferIsEmpty + #define xStreamBufferReset MPU_xStreamBufferReset + #define xStreamBufferSpacesAvailable MPU_xStreamBufferSpacesAvailable + #define xStreamBufferBytesAvailable MPU_xStreamBufferBytesAvailable + #define xStreamBufferSetTriggerLevel MPU_xStreamBufferSetTriggerLevel + #define xStreamBufferGenericCreate MPU_xStreamBufferGenericCreate + #define xStreamBufferGenericCreateStatic MPU_xStreamBufferGenericCreateStatic + + +/* Remove the privileged function macro, but keep the PRIVILEGED_DATA + * macro so applications can place data in privileged access sections + * (useful when using statically allocated objects). */ + #define PRIVILEGED_FUNCTION + #define PRIVILEGED_DATA __attribute__( ( section( "privileged_data" ) ) ) + #define FREERTOS_SYSTEM_CALL + + #else /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */ + +/* Ensure API functions go in the privileged execution section. */ + #define PRIVILEGED_FUNCTION __attribute__( ( section( "privileged_functions" ) ) ) + #define PRIVILEGED_DATA __attribute__( ( section( "privileged_data" ) ) ) + #define FREERTOS_SYSTEM_CALL __attribute__( ( section( "freertos_system_calls" ) ) ) + + #endif /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */ #else /* portUSING_MPU_WRAPPERS */ - #define PRIVILEGED_FUNCTION - #define PRIVILEGED_DATA - #define FREERTOS_SYSTEM_CALL - #define portUSING_MPU_WRAPPERS 0 + #define PRIVILEGED_FUNCTION + #define PRIVILEGED_DATA + #define FREERTOS_SYSTEM_CALL + #define portUSING_MPU_WRAPPERS 0 #endif /* portUSING_MPU_WRAPPERS */ diff --git a/tools/sdk/esp32s2/include/freertos/include/freertos/portable.h b/tools/sdk/esp32s2/include/freertos/include/freertos/portable.h index 0c39bb9f6d8..acc337cb968 100644 --- a/tools/sdk/esp32s2/include/freertos/include/freertos/portable.h +++ b/tools/sdk/esp32s2/include/freertos/include/freertos/portable.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ /*----------------------------------------------------------- @@ -33,68 +32,70 @@ #define PORTABLE_H /* Each FreeRTOS port has a unique portmacro.h header file. Originally a -pre-processor definition was used to ensure the pre-processor found the correct -portmacro.h file for the port being used. That scheme was deprecated in favour -of setting the compiler's include path such that it found the correct -portmacro.h file - removing the need for the constant and allowing the -portmacro.h file to be located anywhere in relation to the port being used. -Purely for reasons of backward compatibility the old method is still valid, but -to make it clear that new projects should not use it, support for the port -specific constants has been moved into the deprecated_definitions.h header -file. */ + * pre-processor definition was used to ensure the pre-processor found the correct + * portmacro.h file for the port being used. That scheme was deprecated in favour + * of setting the compiler's include path such that it found the correct + * portmacro.h file - removing the need for the constant and allowing the + * portmacro.h file to be located anywhere in relation to the port being used. + * Purely for reasons of backward compatibility the old method is still valid, but + * to make it clear that new projects should not use it, support for the port + * specific constants has been moved into the deprecated_definitions.h header + * file. */ #include "deprecated_definitions.h" /* If portENTER_CRITICAL is not defined then including deprecated_definitions.h -did not result in a portmacro.h header file being included - and it should be -included here. In this case the path to the correct portmacro.h header file -must be set in the compiler's include path. */ + * did not result in a portmacro.h header file being included - and it should be + * included here. In this case the path to the correct portmacro.h header file + * must be set in the compiler's include path. */ #ifndef portENTER_CRITICAL - #include "freertos/portmacro.h" + #include "freertos/portmacro.h" #endif #if portBYTE_ALIGNMENT == 32 - #define portBYTE_ALIGNMENT_MASK ( 0x001f ) + #define portBYTE_ALIGNMENT_MASK ( 0x001f ) #endif #if portBYTE_ALIGNMENT == 16 - #define portBYTE_ALIGNMENT_MASK ( 0x000f ) + #define portBYTE_ALIGNMENT_MASK ( 0x000f ) #endif #if portBYTE_ALIGNMENT == 8 - #define portBYTE_ALIGNMENT_MASK ( 0x0007 ) + #define portBYTE_ALIGNMENT_MASK ( 0x0007 ) #endif #if portBYTE_ALIGNMENT == 4 - #define portBYTE_ALIGNMENT_MASK ( 0x0003 ) + #define portBYTE_ALIGNMENT_MASK ( 0x0003 ) #endif #if portBYTE_ALIGNMENT == 2 - #define portBYTE_ALIGNMENT_MASK ( 0x0001 ) + #define portBYTE_ALIGNMENT_MASK ( 0x0001 ) #endif #if portBYTE_ALIGNMENT == 1 - #define portBYTE_ALIGNMENT_MASK ( 0x0000 ) + #define portBYTE_ALIGNMENT_MASK ( 0x0000 ) #endif #ifndef portBYTE_ALIGNMENT_MASK - #error "Invalid portBYTE_ALIGNMENT definition" + #error "Invalid portBYTE_ALIGNMENT definition" #endif #ifndef portNUM_CONFIGURABLE_REGIONS - #define portNUM_CONFIGURABLE_REGIONS 1 + #define portNUM_CONFIGURABLE_REGIONS 1 #endif #ifndef portHAS_STACK_OVERFLOW_CHECKING - #define portHAS_STACK_OVERFLOW_CHECKING 0 + #define portHAS_STACK_OVERFLOW_CHECKING 0 #endif #ifndef portARCH_NAME - #define portARCH_NAME NULL + #define portARCH_NAME NULL #endif +/* *INDENT-OFF* */ #ifdef __cplusplus -extern "C" { + extern "C" { #endif +/* *INDENT-ON* */ #include "mpu_wrappers.h" @@ -104,40 +105,52 @@ extern "C" { * the order that the port expects to find them. * */ -#if( portUSING_MPU_WRAPPERS == 1 ) - #if( portHAS_STACK_OVERFLOW_CHECKING == 1 ) - StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; - #else - StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; - #endif -#else - #if( portHAS_STACK_OVERFLOW_CHECKING == 1 ) - StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters ) PRIVILEGED_FUNCTION; - #else - StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) PRIVILEGED_FUNCTION; - #endif +#if ( portUSING_MPU_WRAPPERS == 1 ) + #if ( portHAS_STACK_OVERFLOW_CHECKING == 1 ) + StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, + StackType_t * pxEndOfStack, + TaskFunction_t pxCode, + void * pvParameters, + BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; + #else + StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, + TaskFunction_t pxCode, + void * pvParameters, + BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; + #endif +#else /* if ( portUSING_MPU_WRAPPERS == 1 ) */ + #if ( portHAS_STACK_OVERFLOW_CHECKING == 1 ) + StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, + StackType_t * pxEndOfStack, + TaskFunction_t pxCode, + void * pvParameters ) PRIVILEGED_FUNCTION; + #else + StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, + TaskFunction_t pxCode, + void * pvParameters ) PRIVILEGED_FUNCTION; + #endif #endif #ifdef configUSE_FREERTOS_PROVIDED_HEAP /* Used by heap_5.c to define the start address and size of each memory region -that together comprise the total FreeRTOS heap space. */ + * that together comprise the total FreeRTOS heap space. */ typedef struct HeapRegion { - uint8_t *pucStartAddress; - size_t xSizeInBytes; + uint8_t * pucStartAddress; + size_t xSizeInBytes; } HeapRegion_t; /* Used to pass information about the heap out of vPortGetHeapStats(). */ typedef struct xHeapStats { - size_t xAvailableHeapSpaceInBytes; /* The total heap size currently available - this is the sum of all the free blocks, not the largest block that can be allocated. */ - size_t xSizeOfLargestFreeBlockInBytes; /* The maximum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */ - size_t xSizeOfSmallestFreeBlockInBytes; /* The minimum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */ - size_t xNumberOfFreeBlocks; /* The number of free memory blocks within the heap at the time vPortGetHeapStats() is called. */ - size_t xMinimumEverFreeBytesRemaining; /* The minimum amount of total free memory (sum of all free blocks) there has been in the heap since the system booted. */ - size_t xNumberOfSuccessfulAllocations; /* The number of calls to pvPortMalloc() that have returned a valid memory block. */ - size_t xNumberOfSuccessfulFrees; /* The number of calls to vPortFree() that has successfully freed a block of memory. */ + size_t xAvailableHeapSpaceInBytes; /* The total heap size currently available - this is the sum of all the free blocks, not the largest block that can be allocated. */ + size_t xSizeOfLargestFreeBlockInBytes; /* The maximum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */ + size_t xSizeOfSmallestFreeBlockInBytes; /* The minimum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */ + size_t xNumberOfFreeBlocks; /* The number of free memory blocks within the heap at the time vPortGetHeapStats() is called. */ + size_t xMinimumEverFreeBytesRemaining; /* The minimum amount of total free memory (sum of all free blocks) there has been in the heap since the system booted. */ + size_t xNumberOfSuccessfulAllocations; /* The number of calls to pvPortMalloc() that have returned a valid memory block. */ + size_t xNumberOfSuccessfulFrees; /* The number of calls to vPortFree() that has successfully freed a block of memory. */ } HeapStats_t; /* @@ -157,16 +170,24 @@ void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) PRIVILEG * Returns a HeapStats_t structure filled with information about the current * heap state. */ -void vPortGetHeapStats( HeapStats_t *pxHeapStats ); +void vPortGetHeapStats( HeapStats_t * pxHeapStats ); + /* * Map to the memory management routines required for the port. */ -void *pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION; -void vPortFree( void *pv ) PRIVILEGED_FUNCTION; +void * pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION; +void vPortFree( void * pv ) PRIVILEGED_FUNCTION; void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION; size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION; size_t xPortGetMinimumEverFreeHeapSize( void ) PRIVILEGED_FUNCTION; +#if( configSTACK_ALLOCATION_FROM_SEPARATE_HEAP == 1 ) + void *pvPortMallocStack( size_t xSize ) PRIVILEGED_FUNCTION; + void vPortFreeStack( void *pv ) PRIVILEGED_FUNCTION; +#else + #define pvPortMallocStack pvPortMalloc + #define vPortFreeStack vPortFree +#endif #else // configUSE_FREERTOS_PROVIDED_HEAP /* @@ -196,8 +217,25 @@ BaseType_t xPortStartScheduler( void ) PRIVILEGED_FUNCTION; */ void vPortEndScheduler( void ) PRIVILEGED_FUNCTION; +/* + * The structures and methods of manipulating the MPU are contained within the + * port layer. + * + * Fills the xMPUSettings structure with the memory region information + * contained in xRegions. + */ +#if ( portUSING_MPU_WRAPPERS == 1 ) + struct xMEMORY_REGION; + void vPortStoreTaskMPUSettings( xMPU_SETTINGS * xMPUSettings, + const struct xMEMORY_REGION * const xRegions, + StackType_t * pxBottomOfStack, + uint32_t ulStackDepth ) PRIVILEGED_FUNCTION; +#endif + +/* *INDENT-OFF* */ #ifdef __cplusplus -} + } #endif +/* *INDENT-ON* */ #endif /* PORTABLE_H */ diff --git a/tools/sdk/esp32s2/include/freertos/include/freertos/projdefs.h b/tools/sdk/esp32s2/include/freertos/include/freertos/projdefs.h index ce647fb6fb1..ec8022ca0b0 100644 --- a/tools/sdk/esp32s2/include/freertos/include/freertos/projdefs.h +++ b/tools/sdk/esp32s2/include/freertos/include/freertos/projdefs.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ #ifndef PROJDEFS_H @@ -32,95 +31,95 @@ * Defines the prototype to which task functions must conform. Defined in this * file to ensure the type is known before portable.h is included. */ -typedef void (*TaskFunction_t)( void * ); +typedef void (* TaskFunction_t)( void * ); /* Converts a time in milliseconds to a time in ticks. This macro can be -overridden by a macro of the same name defined in FreeRTOSConfig.h in case the -definition here is not suitable for your application. */ + * overridden by a macro of the same name defined in FreeRTOSConfig.h in case the + * definition here is not suitable for your application. */ #ifndef pdMS_TO_TICKS - #define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000 ) ) + #define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000U ) ) #endif - +#ifdef ESP_PLATFORM #ifndef pdTICKS_TO_MS - #define pdTICKS_TO_MS( xTicks ) ( ( uint32_t ) ( xTicks ) * 1000 / configTICK_RATE_HZ ) + #define pdTICKS_TO_MS( xTicks ) ( ( uint32_t ) ( xTicks ) * 1000 / configTICK_RATE_HZ ) #endif +#endif // ESP_PLATFORM +#define pdFALSE ( ( BaseType_t ) 0 ) +#define pdTRUE ( ( BaseType_t ) 1 ) -#define pdFALSE ( ( BaseType_t ) 0 ) -#define pdTRUE ( ( BaseType_t ) 1 ) - -#define pdPASS ( pdTRUE ) -#define pdFAIL ( pdFALSE ) -#define errQUEUE_EMPTY ( ( BaseType_t ) 0 ) -#define errQUEUE_FULL ( ( BaseType_t ) 0 ) +#define pdPASS ( pdTRUE ) +#define pdFAIL ( pdFALSE ) +#define errQUEUE_EMPTY ( ( BaseType_t ) 0 ) +#define errQUEUE_FULL ( ( BaseType_t ) 0 ) /* FreeRTOS error definitions. */ -#define errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY ( -1 ) -#define errQUEUE_BLOCKED ( -4 ) -#define errQUEUE_YIELD ( -5 ) +#define errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY ( -1 ) +#define errQUEUE_BLOCKED ( -4 ) +#define errQUEUE_YIELD ( -5 ) /* Macros used for basic data corruption checks. */ #ifndef configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES - #define configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 0 + #define configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 0 #endif -#if( configUSE_16_BIT_TICKS == 1 ) - #define pdINTEGRITY_CHECK_VALUE 0x5a5a +#if ( configUSE_16_BIT_TICKS == 1 ) + #define pdINTEGRITY_CHECK_VALUE 0x5a5a #else - #define pdINTEGRITY_CHECK_VALUE 0x5a5a5a5aUL + #define pdINTEGRITY_CHECK_VALUE 0x5a5a5a5aUL #endif /* The following errno values are used by FreeRTOS+ components, not FreeRTOS -itself. */ -#define pdFREERTOS_ERRNO_NONE 0 /* No errors */ -#define pdFREERTOS_ERRNO_ENOENT 2 /* No such file or directory */ -#define pdFREERTOS_ERRNO_EINTR 4 /* Interrupted system call */ -#define pdFREERTOS_ERRNO_EIO 5 /* I/O error */ -#define pdFREERTOS_ERRNO_ENXIO 6 /* No such device or address */ -#define pdFREERTOS_ERRNO_EBADF 9 /* Bad file number */ -#define pdFREERTOS_ERRNO_EAGAIN 11 /* No more processes */ -#define pdFREERTOS_ERRNO_EWOULDBLOCK 11 /* Operation would block */ -#define pdFREERTOS_ERRNO_ENOMEM 12 /* Not enough memory */ -#define pdFREERTOS_ERRNO_EACCES 13 /* Permission denied */ -#define pdFREERTOS_ERRNO_EFAULT 14 /* Bad address */ -#define pdFREERTOS_ERRNO_EBUSY 16 /* Mount device busy */ -#define pdFREERTOS_ERRNO_EEXIST 17 /* File exists */ -#define pdFREERTOS_ERRNO_EXDEV 18 /* Cross-device link */ -#define pdFREERTOS_ERRNO_ENODEV 19 /* No such device */ -#define pdFREERTOS_ERRNO_ENOTDIR 20 /* Not a directory */ -#define pdFREERTOS_ERRNO_EISDIR 21 /* Is a directory */ -#define pdFREERTOS_ERRNO_EINVAL 22 /* Invalid argument */ -#define pdFREERTOS_ERRNO_ENOSPC 28 /* No space left on device */ -#define pdFREERTOS_ERRNO_ESPIPE 29 /* Illegal seek */ -#define pdFREERTOS_ERRNO_EROFS 30 /* Read only file system */ -#define pdFREERTOS_ERRNO_EUNATCH 42 /* Protocol driver not attached */ -#define pdFREERTOS_ERRNO_EBADE 50 /* Invalid exchange */ -#define pdFREERTOS_ERRNO_EFTYPE 79 /* Inappropriate file type or format */ -#define pdFREERTOS_ERRNO_ENMFILE 89 /* No more files */ -#define pdFREERTOS_ERRNO_ENOTEMPTY 90 /* Directory not empty */ -#define pdFREERTOS_ERRNO_ENAMETOOLONG 91 /* File or path name too long */ -#define pdFREERTOS_ERRNO_EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ -#define pdFREERTOS_ERRNO_ENOBUFS 105 /* No buffer space available */ -#define pdFREERTOS_ERRNO_ENOPROTOOPT 109 /* Protocol not available */ -#define pdFREERTOS_ERRNO_EADDRINUSE 112 /* Address already in use */ -#define pdFREERTOS_ERRNO_ETIMEDOUT 116 /* Connection timed out */ -#define pdFREERTOS_ERRNO_EINPROGRESS 119 /* Connection already in progress */ -#define pdFREERTOS_ERRNO_EALREADY 120 /* Socket already connected */ -#define pdFREERTOS_ERRNO_EADDRNOTAVAIL 125 /* Address not available */ -#define pdFREERTOS_ERRNO_EISCONN 127 /* Socket is already connected */ -#define pdFREERTOS_ERRNO_ENOTCONN 128 /* Socket is not connected */ -#define pdFREERTOS_ERRNO_ENOMEDIUM 135 /* No medium inserted */ -#define pdFREERTOS_ERRNO_EILSEQ 138 /* An invalid UTF-16 sequence was encountered. */ -#define pdFREERTOS_ERRNO_ECANCELED 140 /* Operation canceled. */ + * itself. */ +#define pdFREERTOS_ERRNO_NONE 0 /* No errors */ +#define pdFREERTOS_ERRNO_ENOENT 2 /* No such file or directory */ +#define pdFREERTOS_ERRNO_EINTR 4 /* Interrupted system call */ +#define pdFREERTOS_ERRNO_EIO 5 /* I/O error */ +#define pdFREERTOS_ERRNO_ENXIO 6 /* No such device or address */ +#define pdFREERTOS_ERRNO_EBADF 9 /* Bad file number */ +#define pdFREERTOS_ERRNO_EAGAIN 11 /* No more processes */ +#define pdFREERTOS_ERRNO_EWOULDBLOCK 11 /* Operation would block */ +#define pdFREERTOS_ERRNO_ENOMEM 12 /* Not enough memory */ +#define pdFREERTOS_ERRNO_EACCES 13 /* Permission denied */ +#define pdFREERTOS_ERRNO_EFAULT 14 /* Bad address */ +#define pdFREERTOS_ERRNO_EBUSY 16 /* Mount device busy */ +#define pdFREERTOS_ERRNO_EEXIST 17 /* File exists */ +#define pdFREERTOS_ERRNO_EXDEV 18 /* Cross-device link */ +#define pdFREERTOS_ERRNO_ENODEV 19 /* No such device */ +#define pdFREERTOS_ERRNO_ENOTDIR 20 /* Not a directory */ +#define pdFREERTOS_ERRNO_EISDIR 21 /* Is a directory */ +#define pdFREERTOS_ERRNO_EINVAL 22 /* Invalid argument */ +#define pdFREERTOS_ERRNO_ENOSPC 28 /* No space left on device */ +#define pdFREERTOS_ERRNO_ESPIPE 29 /* Illegal seek */ +#define pdFREERTOS_ERRNO_EROFS 30 /* Read only file system */ +#define pdFREERTOS_ERRNO_EUNATCH 42 /* Protocol driver not attached */ +#define pdFREERTOS_ERRNO_EBADE 50 /* Invalid exchange */ +#define pdFREERTOS_ERRNO_EFTYPE 79 /* Inappropriate file type or format */ +#define pdFREERTOS_ERRNO_ENMFILE 89 /* No more files */ +#define pdFREERTOS_ERRNO_ENOTEMPTY 90 /* Directory not empty */ +#define pdFREERTOS_ERRNO_ENAMETOOLONG 91 /* File or path name too long */ +#define pdFREERTOS_ERRNO_EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ +#define pdFREERTOS_ERRNO_ENOBUFS 105 /* No buffer space available */ +#define pdFREERTOS_ERRNO_ENOPROTOOPT 109 /* Protocol not available */ +#define pdFREERTOS_ERRNO_EADDRINUSE 112 /* Address already in use */ +#define pdFREERTOS_ERRNO_ETIMEDOUT 116 /* Connection timed out */ +#define pdFREERTOS_ERRNO_EINPROGRESS 119 /* Connection already in progress */ +#define pdFREERTOS_ERRNO_EALREADY 120 /* Socket already connected */ +#define pdFREERTOS_ERRNO_EADDRNOTAVAIL 125 /* Address not available */ +#define pdFREERTOS_ERRNO_EISCONN 127 /* Socket is already connected */ +#define pdFREERTOS_ERRNO_ENOTCONN 128 /* Socket is not connected */ +#define pdFREERTOS_ERRNO_ENOMEDIUM 135 /* No medium inserted */ +#define pdFREERTOS_ERRNO_EILSEQ 138 /* An invalid UTF-16 sequence was encountered. */ +#define pdFREERTOS_ERRNO_ECANCELED 140 /* Operation canceled. */ /* The following endian values are used by FreeRTOS+ components, not FreeRTOS -itself. */ -#define pdFREERTOS_LITTLE_ENDIAN 0 -#define pdFREERTOS_BIG_ENDIAN 1 + * itself. */ +#define pdFREERTOS_LITTLE_ENDIAN 0 +#define pdFREERTOS_BIG_ENDIAN 1 /* Re-defining endian values for generic naming. */ -#define pdLITTLE_ENDIAN pdFREERTOS_LITTLE_ENDIAN -#define pdBIG_ENDIAN pdFREERTOS_BIG_ENDIAN +#define pdLITTLE_ENDIAN pdFREERTOS_LITTLE_ENDIAN +#define pdBIG_ENDIAN pdFREERTOS_BIG_ENDIAN #endif /* PROJDEFS_H */ diff --git a/tools/sdk/esp32s2/include/freertos/include/freertos/queue.h b/tools/sdk/esp32s2/include/freertos/include/freertos/queue.h index 8c35465316e..81cccc05df3 100644 --- a/tools/sdk/esp32s2/include/freertos/include/freertos/queue.h +++ b/tools/sdk/esp32s2/include/freertos/include/freertos/queue.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ @@ -30,12 +29,14 @@ #define QUEUE_H #ifndef INC_FREERTOS_H - #error "include FreeRTOS.h" must appear in source files before "include queue.h" + #error "include FreeRTOS.h" must appear in source files before "include queue.h" #endif +/* *INDENT-OFF* */ #ifdef __cplusplus -extern "C" { + extern "C" { #endif +/* *INDENT-ON* */ #include "task.h" @@ -45,42 +46,64 @@ extern "C" { * xQueueSend(), xQueueReceive(), etc. */ struct QueueDefinition; /* Using old naming convention so as not to break kernel aware debuggers. */ -typedef struct QueueDefinition * QueueHandle_t; +typedef struct QueueDefinition * QueueHandle_t; /** * Type by which queue sets are referenced. For example, a call to * xQueueCreateSet() returns an xQueueSet variable that can then be used as a * parameter to xQueueSelectFromSet(), xQueueAddToSet(), etc. */ -typedef struct QueueDefinition * QueueSetHandle_t; +typedef struct QueueDefinition * QueueSetHandle_t; /** * Queue sets can contain both queues and semaphores, so the * QueueSetMemberHandle_t is defined as a type to be used where a parameter or * return value can be either an QueueHandle_t or an SemaphoreHandle_t. */ -typedef struct QueueDefinition * QueueSetMemberHandle_t; +typedef struct QueueDefinition * QueueSetMemberHandle_t; /** @cond */ /* For internal use only. */ -#define queueSEND_TO_BACK ( ( BaseType_t ) 0 ) -#define queueSEND_TO_FRONT ( ( BaseType_t ) 1 ) -#define queueOVERWRITE ( ( BaseType_t ) 2 ) +#define queueSEND_TO_BACK ( ( BaseType_t ) 0 ) +#define queueSEND_TO_FRONT ( ( BaseType_t ) 1 ) +#define queueOVERWRITE ( ( BaseType_t ) 2 ) /* For internal use only. These definitions *must* match those in queue.c. */ -#define queueQUEUE_TYPE_BASE ( ( uint8_t ) 0U ) -#define queueQUEUE_TYPE_SET ( ( uint8_t ) 0U ) -#define queueQUEUE_TYPE_MUTEX ( ( uint8_t ) 1U ) -#define queueQUEUE_TYPE_COUNTING_SEMAPHORE ( ( uint8_t ) 2U ) -#define queueQUEUE_TYPE_BINARY_SEMAPHORE ( ( uint8_t ) 3U ) -#define queueQUEUE_TYPE_RECURSIVE_MUTEX ( ( uint8_t ) 4U ) +#define queueQUEUE_TYPE_BASE ( ( uint8_t ) 0U ) +#define queueQUEUE_TYPE_SET ( ( uint8_t ) 0U ) +#define queueQUEUE_TYPE_MUTEX ( ( uint8_t ) 1U ) +#define queueQUEUE_TYPE_COUNTING_SEMAPHORE ( ( uint8_t ) 2U ) +#define queueQUEUE_TYPE_BINARY_SEMAPHORE ( ( uint8_t ) 3U ) +#define queueQUEUE_TYPE_RECURSIVE_MUTEX ( ( uint8_t ) 4U ) /** @endcond */ /** - * Creates a new queue instance. This allocates the storage required by the - * new queue and returns a handle for the queue. + * @cond + * queue. h + * @code{c} + * QueueHandle_t xQueueCreate( + * UBaseType_t uxQueueLength, + * UBaseType_t uxItemSize + * ); + * @endcode + * @endcond + * + * Creates a new queue instance, and returns a handle by which the new queue + * can be referenced. + * + * Internally, within the FreeRTOS implementation, queues use two blocks of + * memory. The first block is used to hold the queue's data structures. The + * second block is used to hold items placed into the queue. If a queue is + * created using xQueueCreate() then both blocks of memory are automatically + * dynamically allocated inside the xQueueCreate() function. (see + * https://www.FreeRTOS.org/a00111.html). If a queue is created using + * xQueueCreateStatic() then the application writer must provide the memory that + * will get used by the queue. xQueueCreateStatic() therefore allows a queue to + * be created without using any dynamic memory allocation. + * + * https://www.FreeRTOS.org/Embedded-RTOS-Queues.html * * @param uxQueueLength The maximum number of items that the queue can contain. * @@ -95,15 +118,15 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * * Example usage: * @code{c} - * struct AMessage - * { + * struct AMessage + * { * char ucMessageID; * char ucData[ 20 ]; - * }; + * }; * - * void vATask( void *pvParameters ) - * { - * QueueHandle_t xQueue1, xQueue2; + * void vATask( void *pvParameters ) + * { + * QueueHandle_t xQueue1, xQueue2; * * // Create a queue capable of containing 10 uint32_t values. * xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) ); @@ -121,15 +144,29 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * } * * // ... Rest of task code. - * } + * } * @endcode + * @cond + * \defgroup xQueueCreate xQueueCreate + * @endcond * \ingroup QueueManagement */ -#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - #define xQueueCreate( uxQueueLength, uxItemSize ) xQueueGenericCreate( ( uxQueueLength ), ( uxItemSize ), ( queueQUEUE_TYPE_BASE ) ) +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + #define xQueueCreate( uxQueueLength, uxItemSize ) xQueueGenericCreate( ( uxQueueLength ), ( uxItemSize ), ( queueQUEUE_TYPE_BASE ) ) #endif /** + * @cond + * queue. h + * @code{c} + * QueueHandle_t xQueueCreateStatic( + * UBaseType_t uxQueueLength, + * UBaseType_t uxItemSize, + * uint8_t *pucQueueStorageBuffer, + * StaticQueue_t *pxQueueBuffer + * ); + * @endcode + * @endcond * Creates a new queue instance, and returns a handle by which the new queue * can be referenced. * @@ -138,12 +175,12 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * second block is used to hold items placed into the queue. If a queue is * created using xQueueCreate() then both blocks of memory are automatically * dynamically allocated inside the xQueueCreate() function. (see - * http://www.freertos.org/a00111.html). If a queue is created using + * https://www.FreeRTOS.org/a00111.html). If a queue is created using * xQueueCreateStatic() then the application writer must provide the memory that * will get used by the queue. xQueueCreateStatic() therefore allows a queue to * be created without using any dynamic memory allocation. * - * http://www.FreeRTOS.org/Embedded-RTOS-Queues.html + * https://www.FreeRTOS.org/Embedded-RTOS-Queues.html * * @param uxQueueLength The maximum number of items that the queue can contain. * @@ -184,7 +221,7 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * * void vATask( void *pvParameters ) * { - * QueueHandle_t xQueue1; + * 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. @@ -198,13 +235,27 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * // ... Rest of task code. * } * @endcode + * @cond + * \defgroup xQueueCreateStatic xQueueCreateStatic + * @endcond * \ingroup QueueManagement */ -#if( configSUPPORT_STATIC_ALLOCATION == 1 ) - #define xQueueCreateStatic( uxQueueLength, uxItemSize, pucQueueStorage, pxQueueBuffer ) xQueueGenericCreateStatic( ( uxQueueLength ), ( uxItemSize ), ( pucQueueStorage ), ( pxQueueBuffer ), ( queueQUEUE_TYPE_BASE ) ) +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + #define xQueueCreateStatic( uxQueueLength, uxItemSize, pucQueueStorage, pxQueueBuffer ) xQueueGenericCreateStatic( ( uxQueueLength ), ( uxItemSize ), ( pucQueueStorage ), ( pxQueueBuffer ), ( queueQUEUE_TYPE_BASE ) ) #endif /* configSUPPORT_STATIC_ALLOCATION */ /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueSendToToFront( + * QueueHandle_t xQueue, + * const void *pvItemToQueue, + * TickType_t xTicksToWait + * ); + * @endcode + * @endcond + * * Post an item to the front of a queue. The item is queued by copy, not by * reference. This function must not be called from an interrupt service * routine. See xQueueSendFromISR () for an alternative which may be used @@ -227,18 +278,18 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * * Example usage: * @code{c} - * struct AMessage - * { + * struct AMessage + * { * char ucMessageID; * char ucData[ 20 ]; - * } xMessage; + * } xMessage; * - * uint32_t ulVar = 10UL; + * uint32_t ulVar = 10UL; * - * void vATask( void *pvParameters ) - * { - * QueueHandle_t xQueue1, xQueue2; - * struct AMessage *pxMessage; + * 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 ) ); @@ -268,13 +319,28 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * } * * // ... Rest of task code. - * } + * } * @endcode + * @cond + * \defgroup xQueueSend xQueueSend + * @endcond * \ingroup QueueManagement */ -#define xQueueSendToFront( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_FRONT ) +#define xQueueSendToFront( xQueue, pvItemToQueue, xTicksToWait ) \ + xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_FRONT ) /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueSendToBack( + * QueueHandle_t xQueue, + * const void *pvItemToQueue, + * TickType_t xTicksToWait + * ); + * @endcode + * @endcond + * * This is a macro that calls xQueueGenericSend(). * * Post an item to the back of a queue. The item is queued by copy, not by @@ -299,18 +365,18 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * * Example usage: * @code{c} - * struct AMessage - * { + * struct AMessage + * { * char ucMessageID; * char ucData[ 20 ]; - * } xMessage; + * } xMessage; * - * uint32_t ulVar = 10UL; + * uint32_t ulVar = 10UL; * - * void vATask( void *pvParameters ) - * { - * QueueHandle_t xQueue1, xQueue2; - * struct AMessage *pxMessage; + * 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 ) ); @@ -340,13 +406,28 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * } * * // ... Rest of task code. - * } + * } * @endcode + * @cond + * \defgroup xQueueSend xQueueSend + * @endcond * \ingroup QueueManagement */ -#define xQueueSendToBack( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK ) +#define xQueueSendToBack( xQueue, pvItemToQueue, xTicksToWait ) \ + xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK ) /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueSend( + * QueueHandle_t xQueue, + * const void * pvItemToQueue, + * TickType_t xTicksToWait + * ); + * @endcode + * @endcond + * * 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 @@ -373,18 +454,18 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * * Example usage: * @code{c} - * struct AMessage - * { + * struct AMessage + * { * char ucMessageID; * char ucData[ 20 ]; - * } xMessage; + * } xMessage; * - * uint32_t ulVar = 10UL; + * uint32_t ulVar = 10UL; * - * void vATask( void *pvParameters ) - * { - * QueueHandle_t xQueue1, xQueue2; - * struct AMessage *pxMessage; + * 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 ) ); @@ -414,13 +495,27 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * } * * // ... Rest of task code. - * } + * } * @endcode + * @cond + * \defgroup xQueueSend xQueueSend + * @endcond * \ingroup QueueManagement */ -#define xQueueSend( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK ) +#define xQueueSend( xQueue, pvItemToQueue, xTicksToWait ) \ + xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK ) /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueOverwrite( + * QueueHandle_t xQueue, + * const void * pvItemToQueue + * ); + * @endcode + * @endcond + * * Only for use with queues that have a length of one - so the queue is either * empty or full. * @@ -445,10 +540,10 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * Example usage: * @code{c} * - * void vFunction( void *pvParameters ) - * { - * QueueHandle_t xQueue; - * uint32_t ulVarToSend, ulValReceived; + * 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 @@ -490,12 +585,28 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * // ... * } * @endcode + * @cond + * \defgroup xQueueOverwrite xQueueOverwrite + * @endcond * \ingroup QueueManagement */ -#define xQueueOverwrite( xQueue, pvItemToQueue ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), 0, queueOVERWRITE ) +#define xQueueOverwrite( xQueue, pvItemToQueue ) \ + xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), 0, queueOVERWRITE ) /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueGenericSend( + * QueueHandle_t xQueue, + * const void * pvItemToQueue, + * TickType_t xTicksToWait + * BaseType_t xCopyPosition + * ); + * @endcode + * @endcond + * * It is preferred that the macros xQueueSend(), xQueueSendToFront() and * xQueueSendToBack() are used in place of calling this function directly. * @@ -524,18 +635,18 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * * Example usage: * @code{c} - * struct AMessage - * { + * struct AMessage + * { * char ucMessageID; * char ucData[ 20 ]; - * } xMessage; + * } xMessage; * - * uint32_t ulVar = 10UL; + * uint32_t ulVar = 10UL; * - * void vATask( void *pvParameters ) - * { - * QueueHandle_t xQueue1, xQueue2; - * struct AMessage *pxMessage; + * 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 ) ); @@ -565,13 +676,30 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t; * } * * // ... Rest of task code. - * } + * } * @endcode + * @cond + * \defgroup xQueueSend xQueueSend + * @endcond * \ingroup QueueManagement */ -BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, const BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION; +BaseType_t xQueueGenericSend( QueueHandle_t xQueue, + const void * const pvItemToQueue, + TickType_t xTicksToWait, + const BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION; /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueuePeek( + * QueueHandle_t xQueue, + * void * const pvBuffer, + * TickType_t xTicksToWait + * ); + * @endcode + * @endcond + * * Receive an item from a queue without removing the item from the queue. * The item is received by copy so a buffer of adequate size must be * provided. The number of bytes copied into the buffer was defined when @@ -592,7 +720,7 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQ * * @param xTicksToWait The maximum amount of time the task should block * waiting for an item to receive should the queue be empty at the time - * of the call. The time is defined in tick periods so the constant + * of the call. The time is defined in tick periods so the constant * portTICK_PERIOD_MS should be used to convert to real time if this is required. * xQueuePeek() will return immediately if xTicksToWait is 0 and the queue * is empty. @@ -602,18 +730,18 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQ * * Example usage: * @code{c} - * struct AMessage - * { + * struct AMessage + * { * char ucMessageID; * char ucData[ 20 ]; - * } xMessage; + * } xMessage; * - * QueueHandle_t xQueue; + * QueueHandle_t xQueue; * - * // Task to create a queue and post a value. - * void vATask( void *pvParameters ) - * { - * struct AMessage *pxMessage; + * // 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. @@ -631,12 +759,12 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQ * 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; + * // Task to peek the data from the queue. + * void vADifferentTask( void *pvParameters ) + * { + * struct AMessage *pxRxedMessage; * * if( xQueue != 0 ) * { @@ -650,13 +778,28 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQ * } * * // ... Rest of task code. - * } + * } * @endcode + * @cond + * \defgroup xQueuePeek xQueuePeek + * @endcond * \ingroup QueueManagement */ -BaseType_t xQueuePeek( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +BaseType_t xQueuePeek( QueueHandle_t xQueue, + void * const pvBuffer, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueuePeekFromISR( + * QueueHandle_t xQueue, + * void *pvBuffer, + * ); + * @endcode + * @endcond + * * A version of xQueuePeek() that can be called from an interrupt service * routine (ISR). * @@ -677,11 +820,26 @@ BaseType_t xQueuePeek( QueueHandle_t xQueue, void * const pvBuffer, TickType_t x * @return pdTRUE if an item was successfully received from the queue, * otherwise pdFALSE. * + * @cond + * \defgroup xQueuePeekFromISR xQueuePeekFromISR + * @endcond * \ingroup QueueManagement */ -BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, void * const pvBuffer ) PRIVILEGED_FUNCTION; +BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, + void * const pvBuffer ) PRIVILEGED_FUNCTION; /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueReceive( + * QueueHandle_t xQueue, + * void *pvBuffer, + * TickType_t xTicksToWait + * ); + * @endcode + * @endcond + * * Receive an item from a queue. The item is received by copy so a buffer of * adequate size must be provided. The number of bytes copied into the buffer * was defined when the queue was created. @@ -699,7 +857,7 @@ BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, void * const pvBuffer ) PRIV * * @param xTicksToWait The maximum amount of time the task should block * waiting for an item to receive should the queue be empty at the time - * of the call. xQueueReceive() will return immediately if xTicksToWait + * of the call. xQueueReceive() will return immediately if xTicksToWait * is zero and the queue is empty. The time is defined in tick periods so the * constant portTICK_PERIOD_MS should be used to convert to real time if this is * required. @@ -709,72 +867,94 @@ BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, void * const pvBuffer ) PRIV * * Example usage: * @code{c} - * struct AMessage - * { - * char ucMessageID; - * char ucData[ 20 ]; - * } xMessage; + * struct AMessage + * { + * char ucMessageID; + * char ucData[ 20 ]; + * } xMessage; + * + * QueueHandle_t xQueue; * - * QueueHandle_t xQueue; + * // Task to create a queue and post a value. + * void vATask( void *pvParameters ) + * { + * struct AMessage *pxMessage; * - * // Task to create a queue and post a value. - * void vATask( void *pvParameters ) + * // 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 ) * { - * struct AMessage *pxMessage; + * // Failed to create the queue. + * } * - * // 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 ); * - * // 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. + * } * - * // ... Rest of task code. - * } + * // Task to receive from the queue. + * void vADifferentTask( void *pvParameters ) + * { + * struct AMessage *pxRxedMessage; * - * // Task to receive from the queue. - * void vADifferentTask( void *pvParameters ) + * if( xQueue != 0 ) * { - * 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. + * // 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 + * @cond + * \defgroup xQueueReceive xQueueReceive + * @endcond * \ingroup QueueManagement */ -BaseType_t xQueueReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +BaseType_t xQueueReceive( QueueHandle_t xQueue, + void * const pvBuffer, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; /** + * @cond + * queue. h + * @code{c} + * UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue ); + * @endcode + * @endcond + * * 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. * + * @cond + * \defgroup uxQueueMessagesWaiting uxQueueMessagesWaiting + * @endcond * \ingroup QueueManagement */ UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; /** + * @cond + * queue. h + * @code{c} + * UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue ); + * @endcode + * @endcond + * * 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. @@ -783,21 +963,45 @@ UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue ) PRIVILEGED_FUNC * * @return The number of spaces available in the queue. * + * @cond + * \defgroup uxQueueMessagesWaiting uxQueueMessagesWaiting + * @endcond * \ingroup QueueManagement */ UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; /** + * @cond + * queue. h + * @code{c} + * void vQueueDelete( QueueHandle_t xQueue ); + * @endcode + * @endcond + * * 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. * + * @cond + * \defgroup vQueueDelete vQueueDelete + * @endcond * \ingroup QueueManagement */ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueSendToFrontFromISR( + * QueueHandle_t xQueue, + * const void *pvItemToQueue, + * BaseType_t *pxHigherPriorityTaskWoken + * ); + * @endcode + * @endcond + * * This is a macro that calls xQueueGenericSendFromISR(). * * Post an item to the front of a queue. It is safe to use this macro from @@ -826,38 +1030,54 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; * Example usage for buffered IO (where the ISR can obtain more than one value * per call): * @code{c} - * void vBufferISR( void ) - * { - * char cIn; - * BaseType_t xHigherPrioritTaskWoken; + * void vBufferISR( void ) + * { + * char cIn; + * BaseType_t xHigherPrioritTaskWoken; * - * // We have not woken a task at the start of the ISR. - * xHigherPriorityTaskWoken = pdFALSE; + * // 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 ); + * // 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 ); + * // Post the byte. + * xQueueSendToFrontFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken ); * - * } while( portINPUT_BYTE( BUFFER_COUNT ) ); + * } while( portINPUT_BYTE( BUFFER_COUNT ) ); * - * // Now the buffer is empty we can switch context if necessary. - * if( xHigherPriorityTaskWoken ) - * { - * portYIELD_FROM_ISR (); - * } + * // Now the buffer is empty we can switch context if necessary. + * if( xHigherPriorityTaskWoken ) + * { + * portYIELD_FROM_ISR (); * } + * } * @endcode + * + * @cond + * \defgroup xQueueSendFromISR xQueueSendFromISR + * @endcond * \ingroup QueueManagement */ -#define xQueueSendToFrontFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_FRONT ) +#define xQueueSendToFrontFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) \ + xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_FRONT ) /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueSendToBackFromISR( + * QueueHandle_t xQueue, + * const void *pvItemToQueue, + * BaseType_t *pxHigherPriorityTaskWoken + * ); + * @endcode + * @endcond + * * This is a macro that calls xQueueGenericSendFromISR(). * * Post an item to the back of a queue. It is safe to use this macro from @@ -886,37 +1106,53 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; * Example usage for buffered IO (where the ISR can obtain more than one value * per call): * @code{c} - * void vBufferISR( void ) - * { - * char cIn; - * BaseType_t xHigherPriorityTaskWoken; + * void vBufferISR( void ) + * { + * char cIn; + * BaseType_t xHigherPriorityTaskWoken; * - * // We have not woken a task at the start of the ISR. - * xHigherPriorityTaskWoken = pdFALSE; + * // 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 ); + * // 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 ); + * // Post the byte. + * xQueueSendToBackFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken ); * - * } while( portINPUT_BYTE( BUFFER_COUNT ) ); + * } while( portINPUT_BYTE( BUFFER_COUNT ) ); * - * // Now the buffer is empty we can switch context if necessary. - * if( xHigherPriorityTaskWoken ) - * { - * portYIELD_FROM_ISR (); - * } + * // Now the buffer is empty we can switch context if necessary. + * if( xHigherPriorityTaskWoken ) + * { + * portYIELD_FROM_ISR (); * } + * } * @endcode + * + * @cond + * \defgroup xQueueSendFromISR xQueueSendFromISR + * @endcond * \ingroup QueueManagement */ -#define xQueueSendToBackFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK ) +#define xQueueSendToBackFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) \ + xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK ) /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueOverwriteFromISR( + * QueueHandle_t xQueue, + * const void * pvItemToQueue, + * BaseType_t *pxHigherPriorityTaskWoken + * ); + * @endcode + * @endcond + * * A version of xQueueOverwrite() that can be used in an interrupt service * routine (ISR). * @@ -947,15 +1183,16 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; * * Example usage: * @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 ) ); + * 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 ) @@ -964,35 +1201,50 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; * BaseType_t xHigherPriorityTaskWoken = pdFALSE; * uint32_t ulVarToSend, ulValReceived; * - * // Write the value 10 to the queue using xQueueOverwriteFromISR(). - * ulVarToSend = 10; - * xQueueOverwriteFromISR( xQueue, &ulVarToSend, &xHigherPriorityTaskWoken ); + * // 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 ); + * // 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. + * // 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. - * } + * 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 + * @cond + * \defgroup xQueueOverwriteFromISR xQueueOverwriteFromISR + * @endcond * \ingroup QueueManagement */ -#define xQueueOverwriteFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueOVERWRITE ) +#define xQueueOverwriteFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) \ + xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueOVERWRITE ) /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueSendFromISR( + * QueueHandle_t xQueue, + * const void *pvItemToQueue, + * BaseType_t *pxHigherPriorityTaskWoken + * ); + * @endcode + * @endcond + * * 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() @@ -1024,40 +1276,57 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; * Example usage for buffered IO (where the ISR can obtain more than one value * per call): * @code{c} - * void vBufferISR( void ) - * { - * char cIn; - * BaseType_t xHigherPriorityTaskWoken; + * void vBufferISR( void ) + * { + * char cIn; + * BaseType_t xHigherPriorityTaskWoken; * - * // We have not woken a task at the start of the ISR. - * xHigherPriorityTaskWoken = pdFALSE; + * // 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 ); + * // 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 ); + * // Post the byte. + * xQueueSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken ); * - * } while( portINPUT_BYTE( BUFFER_COUNT ) ); + * } 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 (); - * } + * // Now the buffer is empty we can switch context if necessary. + * if( xHigherPriorityTaskWoken ) + * { + * // Actual macro used here is port specific. + * portYIELD_FROM_ISR (); * } + * } * @endcode * + * @cond + * \defgroup xQueueSendFromISR xQueueSendFromISR + * @endcond * \ingroup QueueManagement */ -#define xQueueSendFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK ) +#define xQueueSendFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) \ + xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK ) +/** @cond */ /**@{*/ /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueGenericSendFromISR( + * QueueHandle_t xQueue, + * const void *pvItemToQueue, + * BaseType_t *pxHigherPriorityTaskWoken, + * BaseType_t xCopyPosition + * ); + * @endcode + * @endcond + * * It is preferred that the macros xQueueSendFromISR(), * xQueueSendToFrontFromISR() and xQueueSendToBackFromISR() be used in place * of calling this function directly. xQueueGiveFromISR() is an @@ -1093,40 +1362,57 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; * Example usage for buffered IO (where the ISR can obtain more than one value * per call): * @code{c} - * void vBufferISR( void ) - * { - * char cIn; - * BaseType_t xHigherPriorityTaskWokenByPost; + * void vBufferISR( void ) + * { + * char cIn; + * BaseType_t xHigherPriorityTaskWokenByPost; * - * // We have not woken a task at the start of the ISR. - * xHigherPriorityTaskWokenByPost = pdFALSE; + * // 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 ); + * // 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 ); + * // Post each byte. + * xQueueGenericSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWokenByPost, queueSEND_TO_BACK ); * - * } while( portINPUT_BYTE( BUFFER_COUNT ) ); + * } 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(); - * } + * // 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; +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; /**@}*/ +/** @endcond */ /** + * @cond + * queue. h + * @code{c} + * BaseType_t xQueueReceiveFromISR( + * QueueHandle_t xQueue, + * void *pvBuffer, + * BaseType_t *pxTaskWoken + * ); + * @endcode + * @endcond + * * Receive an item from a queue. It is safe to use this function from within an * interrupt service routine. * @@ -1146,63 +1432,69 @@ BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue, BaseType_t * const pxHigherP * * Example usage: * @code{c} - * QueueHandle_t xQueue; * - * // Function to create a queue and post some values. - * void vAFunction( void *pvParameters ) + * 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) ) * { - * 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 ); + * // 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. * } * - * // ISR that outputs all the characters received on the queue. - * void vISR_Routine( void ) + * if( cTaskWokenByPost != ( char ) pdFALSE; * { - * 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 (); - * } + * taskYIELD (); * } + * } * @endcode + * @cond + * \defgroup xQueueReceiveFromISR xQueueReceiveFromISR + * @endcond * \ingroup QueueManagement */ -BaseType_t xQueueReceiveFromISR( QueueHandle_t xQueue, void * const pvBuffer, BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; +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 @@ -1213,7 +1505,7 @@ BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUN UBaseType_t uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; /** @cond */ -/** +/* * The functions defined above are for passing data to and from tasks. The * functions below are the equivalents for passing data to and from * co-routines. @@ -1222,10 +1514,18 @@ UBaseType_t uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue ) PRIVILEG * should not be called directly from application code. Instead use the macro * wrappers defined within croutine.h. */ -BaseType_t xQueueCRSendFromISR( QueueHandle_t xQueue, const void *pvItemToQueue, BaseType_t xCoRoutinePreviouslyWoken ); -BaseType_t xQueueCRReceiveFromISR( QueueHandle_t xQueue, void *pvBuffer, BaseType_t *pxTaskWoken ); -BaseType_t xQueueCRSend( QueueHandle_t xQueue, const void *pvItemToQueue, TickType_t xTicksToWait ); -BaseType_t xQueueCRReceive( QueueHandle_t xQueue, void *pvBuffer, TickType_t xTicksToWait ); +BaseType_t xQueueCRSendFromISR( QueueHandle_t xQueue, + const void * pvItemToQueue, + BaseType_t xCoRoutinePreviouslyWoken ); +BaseType_t xQueueCRReceiveFromISR( QueueHandle_t xQueue, + void * pvBuffer, + BaseType_t * pxTaskWoken ); +BaseType_t xQueueCRSend( QueueHandle_t xQueue, + const void * pvItemToQueue, + TickType_t xTicksToWait ); +BaseType_t xQueueCRReceive( QueueHandle_t xQueue, + void * pvBuffer, + TickType_t xTicksToWait ); /** * For internal use only. Use xSemaphoreCreateMutex(), @@ -1233,10 +1533,15 @@ BaseType_t xQueueCRReceive( QueueHandle_t xQueue, void *pvBuffer, TickType_t xTi * these functions directly. */ QueueHandle_t xQueueCreateMutex( const uint8_t ucQueueType ) PRIVILEGED_FUNCTION; -QueueHandle_t xQueueCreateMutexStatic( const uint8_t ucQueueType, StaticQueue_t *pxStaticQueue ) PRIVILEGED_FUNCTION; -QueueHandle_t xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount ) PRIVILEGED_FUNCTION; -QueueHandle_t xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount, StaticQueue_t *pxStaticQueue ) PRIVILEGED_FUNCTION; -BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +QueueHandle_t xQueueCreateMutexStatic( const uint8_t ucQueueType, + StaticQueue_t * pxStaticQueue ) PRIVILEGED_FUNCTION; +QueueHandle_t xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, + const UBaseType_t uxInitialCount ) PRIVILEGED_FUNCTION; +QueueHandle_t xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, + const UBaseType_t uxInitialCount, + StaticQueue_t * pxStaticQueue ) PRIVILEGED_FUNCTION; +BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; TaskHandle_t xQueueGetMutexHolder( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION; TaskHandle_t xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION; @@ -1244,7 +1549,8 @@ TaskHandle_t xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore ) PRIVILEGED_ * For internal use only. Use xSemaphoreTakeMutexRecursive() or * xSemaphoreGiveMutexRecursive() instead of calling these functions directly. */ -BaseType_t xQueueTakeMutexRecursive( QueueHandle_t xMutex, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +BaseType_t xQueueTakeMutexRecursive( QueueHandle_t xMutex, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION; /** @endcond */ @@ -1253,7 +1559,7 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION; * Reset a queue back to its original empty state. The return value is now * obsolete and is always set to pdPASS. */ -#define xQueueReset( xQueue ) xQueueGenericReset( xQueue, pdFALSE ) +#define xQueueReset( xQueue ) xQueueGenericReset( xQueue, pdFALSE ) /** * The registry is provided as a means for kernel aware debuggers to @@ -1277,8 +1583,9 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION; * stores a pointer to the string - so the string must be persistent (global or * preferably in ROM/Flash), not on the stack. */ -#if( configQUEUE_REGISTRY_SIZE > 0 ) - void vQueueAddToRegistry( QueueHandle_t xQueue, const char *pcQueueName ) PRIVILEGED_FUNCTION; /**lint !e971 Unqualified char types are allowed for strings and single characters only. */ +#if ( configQUEUE_REGISTRY_SIZE > 0 ) + void vQueueAddToRegistry( QueueHandle_t xQueue, + const char * pcQueueName ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ #endif /** @@ -1291,8 +1598,8 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION; * * @param xQueue The handle of the queue being removed from the registry. */ -#if( configQUEUE_REGISTRY_SIZE > 0 ) - void vQueueUnregisterQueue( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; +#if ( configQUEUE_REGISTRY_SIZE > 0 ) + void vQueueUnregisterQueue( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; #endif /** @@ -1306,26 +1613,32 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION; * queue is returned. If the queue is not in the registry then NULL is * 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. */ +#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. */ #endif /** - * Generic version of the function used to creaet a queue using dynamic memory + * Generic version of the function used to create 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. */ -#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - QueueHandle_t xQueueGenericCreate( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, const uint8_t ucQueueType ) PRIVILEGED_FUNCTION; +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + 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 + * Generic version of the function used to create 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. */ -#if( configSUPPORT_STATIC_ALLOCATION == 1 ) - QueueHandle_t xQueueGenericCreateStatic( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, uint8_t *pucQueueStorage, StaticQueue_t *pxStaticQueue, const uint8_t ucQueueType ) PRIVILEGED_FUNCTION; +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + QueueHandle_t xQueueGenericCreateStatic( const UBaseType_t uxQueueLength, + const UBaseType_t uxItemSize, + uint8_t * pucQueueStorage, + StaticQueue_t * pxStaticQueue, + const uint8_t ucQueueType ) PRIVILEGED_FUNCTION; #endif /** @@ -1342,7 +1655,7 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION; * or semaphores contained in the set is in a state where a queue read or * semaphore take operation would be successful. * - * Note 1: See the documentation on http://wwwFreeRTOS.org/RTOS-queue-sets.html + * Note 1: See the documentation on https://www.FreeRTOS.org/RTOS-queue-sets.html * for reasons why queue sets are very rarely needed in practice as there are * simpler methods of blocking on multiple objects. * @@ -1400,7 +1713,8 @@ QueueSetHandle_t xQueueCreateSet( const UBaseType_t uxEventQueueLength ) PRIVILE * queue set because it is already a member of a different queue set then pdFAIL * is returned. */ -BaseType_t xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION; +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 @@ -1419,7 +1733,8 @@ BaseType_t xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHan * then pdPASS is returned. If the queue was not in the queue set, or the * queue (or semaphore) was not empty, then pdFAIL is returned. */ -BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION; +BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, + QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION; /** * xQueueSelectFromSet() selects from the members of a queue set a queue or @@ -1431,7 +1746,7 @@ BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueS * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this * function. * - * Note 1: See the documentation on http://wwwFreeRTOS.org/RTOS-queue-sets.html + * Note 1: See the documentation on https://www.FreeRTOS.org/RTOS-queue-sets.html * for reasons why queue sets are very rarely needed in practice as there are * simpler methods of blocking on multiple objects. * @@ -1455,7 +1770,8 @@ BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueS * in the queue set that is available, or NULL if no such queue or semaphore * exists before before the specified block time expires. */ -QueueSetMemberHandle_t xQueueSelectFromSet( QueueSetHandle_t xQueueSet, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +QueueSetMemberHandle_t xQueueSelectFromSet( QueueSetHandle_t xQueueSet, + const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; /** * A version of xQueueSelectFromSet() that can be used from an ISR. @@ -1465,16 +1781,22 @@ QueueSetMemberHandle_t xQueueSelectFromSetFromISR( QueueSetHandle_t xQueueSet ) /** @cond */ /* Not public API functions. */ -void vQueueWaitForMessageRestricted( QueueHandle_t xQueue, TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION; -BaseType_t xQueueGenericReset( QueueHandle_t xQueue, BaseType_t xNewQueue ) PRIVILEGED_FUNCTION; -void vQueueSetQueueNumber( QueueHandle_t xQueue, UBaseType_t uxQueueNumber ) PRIVILEGED_FUNCTION; +void vQueueWaitForMessageRestricted( QueueHandle_t xQueue, + TickType_t xTicksToWait, + const BaseType_t xWaitIndefinitely ) 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 */ +/* *INDENT-OFF* */ #ifdef __cplusplus -} + } #endif +/* *INDENT-ON* */ #endif /* QUEUE_H */ diff --git a/tools/sdk/esp32s2/include/freertos/include/freertos/semphr.h b/tools/sdk/esp32s2/include/freertos/include/freertos/semphr.h index 971d74d496c..7e99c0b396c 100644 --- a/tools/sdk/esp32s2/include/freertos/include/freertos/semphr.h +++ b/tools/sdk/esp32s2/include/freertos/include/freertos/semphr.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,35 +19,36 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ #ifndef SEMAPHORE_H #define SEMAPHORE_H #ifndef INC_FREERTOS_H - #error "include FreeRTOS.h" must appear in source files before "include semphr.h" + #error "include FreeRTOS.h" must appear in source files before "include semphr.h" #endif #include "queue.h" typedef QueueHandle_t SemaphoreHandle_t; -#define semBINARY_SEMAPHORE_QUEUE_LENGTH ( ( uint8_t ) 1U ) -#define semSEMAPHORE_QUEUE_ITEM_LENGTH ( ( uint8_t ) 0U ) -#define semGIVE_BLOCK_TIME ( ( TickType_t ) 0U ) +#define semBINARY_SEMAPHORE_QUEUE_LENGTH ( ( uint8_t ) 1U ) +#define semSEMAPHORE_QUEUE_ITEM_LENGTH ( ( uint8_t ) 0U ) +#define semGIVE_BLOCK_TIME ( ( TickType_t ) 0U ) /** @cond */ /** * semphr. h - *
vSemaphoreCreateBinary( SemaphoreHandle_t xSemaphore )
+ * @code{c} + * vSemaphoreCreateBinary( SemaphoreHandle_t xSemaphore ); + * @endcode * * In many usage scenarios it is faster and more memory efficient to use a * direct to task notification in place of a binary semaphore! - * http://www.freertos.org/RTOS-task-notifications.html + * https://www.FreeRTOS.org/RTOS-task-notifications.html * * This old vSemaphoreCreateBinary() macro is now deprecated in favour of the * xSemaphoreCreateBinary() function. Note that binary semaphores created using @@ -72,48 +73,58 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @code{c} - * SemaphoreHandle_t xSemaphore = NULL; + * 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 ); + * 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. - * } + * if( xSemaphore != NULL ) + * { + * // The semaphore was created successfully. + * // The semaphore can now be used. * } + * } * @endcode + * @cond + * \defgroup vSemaphoreCreateBinary vSemaphoreCreateBinary + * @endcond * \ingroup Semaphores */ -#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - #define vSemaphoreCreateBinary( xSemaphore ) \ - { \ - ( xSemaphore ) = xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE ); \ - if( ( xSemaphore ) != NULL ) \ - { \ - ( void ) xSemaphoreGive( ( xSemaphore ) ); \ - } \ - } +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + #define vSemaphoreCreateBinary( xSemaphore ) \ + { \ + ( xSemaphore ) = xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE ); \ + if( ( xSemaphore ) != NULL ) \ + { \ + ( void ) xSemaphoreGive( ( xSemaphore ) ); \ + } \ + } #endif /** @endcond */ /** + * @cond + * semphr. h + * @code{c} + * SemaphoreHandle_t xSemaphoreCreateBinary( void ); + * @endcode + * @endcond + * * Creates a new binary semaphore instance, and returns a handle by which the * new semaphore can be referenced. * * In many usage scenarios it is faster and more memory efficient to use a * direct to task notification in place of a binary semaphore! - * http://www.freertos.org/RTOS-task-notifications.html + * https://www.FreeRTOS.org/RTOS-task-notifications.html * * Internally, within the FreeRTOS implementation, binary semaphores use a block * of memory, in which the semaphore structure is stored. If a binary semaphore * is created using xSemaphoreCreateBinary() then the required memory is * automatically dynamically allocated inside the xSemaphoreCreateBinary() - * function. (see http://www.freertos.org/a00111.html). If a binary semaphore + * function. (see https://www.FreeRTOS.org/a00111.html). If a binary semaphore * is created using xSemaphoreCreateBinaryStatic() then the application writer * must provide the memory. xSemaphoreCreateBinaryStatic() therefore allows a * binary semaphore to be created without using any dynamic memory allocation. @@ -137,40 +148,50 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @code{c} - * SemaphoreHandle_t xSemaphore = NULL; + * 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(); + * 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. - * } + * if( xSemaphore != NULL ) + * { + * // The semaphore was created successfully. + * // The semaphore can now be used. * } + * } * @endcode + * @cond + * \defgroup xSemaphoreCreateBinary xSemaphoreCreateBinary + * @endcond * \ingroup Semaphores */ -#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - #define xSemaphoreCreateBinary() xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE ) +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + #define xSemaphoreCreateBinary() xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE ) #endif /** + * @cond + * semphr. h + * @code{c} + * SemaphoreHandle_t xSemaphoreCreateBinaryStatic( StaticSemaphore_t *pxSemaphoreBuffer ); + * @endcode + * @endcond + * * Creates a new binary semaphore instance, and returns a handle by which the * new semaphore can be referenced. * * NOTE: In many usage scenarios it is faster and more memory efficient to use a * direct to task notification in place of a binary semaphore! - * http://www.freertos.org/RTOS-task-notifications.html + * https://www.FreeRTOS.org/RTOS-task-notifications.html * * Internally, within the FreeRTOS implementation, binary semaphores use a block * of memory, in which the semaphore structure is stored. If a binary semaphore * is created using xSemaphoreCreateBinary() then the required memory is * automatically dynamically allocated inside the xSemaphoreCreateBinary() - * function. (see http://www.freertos.org/a00111.html). If a binary semaphore + * function. (see https://www.FreeRTOS.org/a00111.html). If a binary semaphore * is created using xSemaphoreCreateBinaryStatic() then the application writer * must provide the memory. xSemaphoreCreateBinaryStatic() therefore allows a * binary semaphore to be created without using any dynamic memory allocation. @@ -191,38 +212,51 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @code{c} - * SemaphoreHandle_t xSemaphore = NULL; - * StaticSemaphore_t xSemaphoreBuffer; - * - * void vATask( void * pvParameters ) - * { - * // Semaphore cannot be used before a call to xSemaphoreCreateBinary() or - * // xSemaphoreCreateBinaryStatic(). - * // 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 = xSemaphoreCreateBinaryStatic( &xSemaphoreBuffer ); - * - * // Rest of task code goes here. - * } + * SemaphoreHandle_t xSemaphore = NULL; + * StaticSemaphore_t xSemaphoreBuffer; + * + * void vATask( void * pvParameters ) + * { + * // Semaphore cannot be used before a call to xSemaphoreCreateBinary() or + * // xSemaphoreCreateBinaryStatic(). + * // 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 = xSemaphoreCreateBinaryStatic( &xSemaphoreBuffer ); + * + * // Rest of task code goes here. + * } * @endcode + * @cond + * \defgroup xSemaphoreCreateBinaryStatic xSemaphoreCreateBinaryStatic + * @endcond * \ingroup Semaphores */ -#if( configSUPPORT_STATIC_ALLOCATION == 1 ) - #define xSemaphoreCreateBinaryStatic( pxStaticSemaphore ) xQueueGenericCreateStatic( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, NULL, pxStaticSemaphore, queueQUEUE_TYPE_BINARY_SEMAPHORE ) +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + #define xSemaphoreCreateBinaryStatic( pxStaticSemaphore ) xQueueGenericCreateStatic( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, NULL, pxStaticSemaphore, queueQUEUE_TYPE_BINARY_SEMAPHORE ) #endif /* configSUPPORT_STATIC_ALLOCATION */ /** + * @cond + * semphr. h + * @code{c} + * xSemaphoreTake( + * SemaphoreHandle_t xSemaphore, + * TickType_t xBlockTime + * ); + * @endcode + * @endcond + * * Macro to obtain a semaphore. The semaphore must have previously been * created with a call to xSemaphoreCreateBinary(), xSemaphoreCreateMutex() or * xSemaphoreCreateCounting(). * - * @param xSemaphore A handle to the semaphore being taken - obtained when + * param xSemaphore A handle to the semaphore being taken - obtained when * the semaphore was created. * - * @param xBlockTime The time in ticks to wait for the semaphore to become + * param xBlockTime The time in ticks to wait for the semaphore to become * available. The macro portTICK_PERIOD_MS can be used to convert this to a * real time. A block time of zero can be used to poll the semaphore. A block * time of portMAX_DELAY can be used to block indefinitely (provided @@ -233,48 +267,61 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @code{c} - * SemaphoreHandle_t xSemaphore = NULL; + * 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 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. + * // 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. - * } - * } + * 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 + * @cond + * \defgroup xSemaphoreTake xSemaphoreTake + * @endcond * \ingroup Semaphores */ -#define xSemaphoreTake( xSemaphore, xBlockTime ) xQueueSemaphoreTake( ( xSemaphore ), ( xBlockTime ) ) +#define xSemaphoreTake( xSemaphore, xBlockTime ) xQueueSemaphoreTake( ( xSemaphore ), ( xBlockTime ) ) /** + * @cond + * semphr. h + * @code{c} + * xSemaphoreTakeRecursive( + * SemaphoreHandle_t xMutex, + * TickType_t xBlockTime + * ); + * @endcode + * @endcond + * * Macro to recursively obtain, or 'take', a mutex type semaphore. * The mutex must have previously been created using a call to * xSemaphoreCreateRecursiveMutex(); @@ -305,76 +352,63 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @code{c} - * SemaphoreHandle_t xMutex = NULL; + * 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 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. + * // 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. - * } - * } + * 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 + * @cond + * \defgroup xSemaphoreTakeRecursive xSemaphoreTakeRecursive + * @endcond * \ingroup Semaphores */ -#define xSemaphoreTakeRecursive( xMutex, xBlockTime ) xQueueTakeMutexRecursive( ( xMutex ), ( xBlockTime ) ) - -/** @cond */ -/* - * xSemaphoreAltTake() is an alternative version of xSemaphoreTake(). - * - * The source code that implements the alternative (Alt) API is much - * simpler because it executes everything from within a critical section. - * This is the approach taken by many other RTOSes, but FreeRTOS.org has the - * preferred fully featured API too. The fully featured API has more - * complex code that takes longer to execute, but makes much less use of - * critical sections. Therefore the alternative API sacrifices interrupt - * responsiveness to gain execution speed, whereas the fully featured API - * sacrifices execution speed to ensure better interrupt responsiveness. - */ -#define xSemaphoreAltTake( xSemaphore, xBlockTime ) xQueueAltGenericReceive( ( QueueHandle_t ) ( xSemaphore ), NULL, ( xBlockTime ), pdFALSE ) -/** @endcond */ +#define xSemaphoreTakeRecursive( xMutex, xBlockTime ) xQueueTakeMutexRecursive( ( xMutex ), ( xBlockTime ) ) /** * Macro to release a semaphore. The semaphore must have previously been @@ -397,47 +431,54 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @code{c} - * SemaphoreHandle_t xSemaphore = NULL; + * SemaphoreHandle_t xSemaphore = NULL; * - * void vATask( void * pvParameters ) - * { - * // Create the semaphore to guard a shared resource. - * vSemaphoreCreateBinary( xSemaphore ); + * 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. - * } - * } - * } + * 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 + * @cond + * \defgroup xSemaphoreGive xSemaphoreGive + * @endcond * \ingroup Semaphores */ -#define xSemaphoreGive( xSemaphore ) xQueueGenericSend( ( QueueHandle_t ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK ) +#define xSemaphoreGive( xSemaphore ) xQueueGenericSend( ( QueueHandle_t ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK ) /** + * @cond * semphr. h - *
xSemaphoreGiveRecursive( SemaphoreHandle_t xMutex )
+ * @code{c} + * xSemaphoreGiveRecursive( SemaphoreHandle_t xMutex ); + * @endcode + * @endcond * * Macro to recursively release, or 'give', a mutex type semaphore. * The mutex must have previously been created using a call to @@ -462,78 +503,64 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @code{c} - * SemaphoreHandle_t xMutex = NULL; + * 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 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. + * // 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. - * } - * } + * 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 + * @cond + * \defgroup xSemaphoreGiveRecursive xSemaphoreGiveRecursive + * @endcond * \ingroup Semaphores */ -#define xSemaphoreGiveRecursive( xMutex ) xQueueGiveMutexRecursive( ( xMutex ) ) - -/** @cond */ -/* - * xSemaphoreAltGive() is an alternative version of xSemaphoreGive(). - * - * The source code that implements the alternative (Alt) API is much - * simpler because it executes everything from within a critical section. - * This is the approach taken by many other RTOSes, but FreeRTOS.org has the - * preferred fully featured API too. The fully featured API has more - * complex code that takes longer to execute, but makes much less use of - * critical sections. Therefore the alternative API sacrifices interrupt - * responsiveness to gain execution speed, whereas the fully featured API - * sacrifices execution speed to ensure better interrupt responsiveness. - */ -#define xSemaphoreAltGive( xSemaphore ) xQueueAltGenericSend( ( QueueHandle_t ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK ) - -/** @endcond */ +#define xSemaphoreGiveRecursive( xMutex ) xQueueGiveMutexRecursive( ( xMutex ) ) /** * Macro to release a semaphore. The semaphore must have previously been @@ -557,68 +584,81 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @code{c} - * \#define LONG_TIME 0xffff - * \#define TICKS_TO_WAIT 10 - * SemaphoreHandle_t xSemaphore = NULL; - * - * // Repetitive task. - * void vATask( void * pvParameters ) + * #define LONG_TIME 0xffff + * #define TICKS_TO_WAIT 10 + * SemaphoreHandle_t xSemaphore = NULL; + * + * // Repetitive task. + * void vATask( void * pvParameters ) + * { + * for( ;; ) * { - * for( ;; ) - * { - * // We want this task to run every 10 ticks of a timer. The semaphore - * // was created before this task was started. + * // 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. + * // 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. - * } - * } + * // 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; + * // Timer ISR + * void vTimerISR( void * pvParameters ) + * { + * static uint8_t ucLocalTickCount = 0; + * static BaseType_t xHigherPriorityTaskWoken; * - * // A timer tick has occurred. + * // A timer tick has occurred. * - * // ... Do other time functions. + * // ... 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 ); + * // 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; - * } + * // 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. - * } + * 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 + * @cond + * \defgroup xSemaphoreGiveFromISR xSemaphoreGiveFromISR + * @endcond * \ingroup Semaphores */ -#define xSemaphoreGiveFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueGiveFromISR( ( QueueHandle_t ) ( xSemaphore ), ( pxHigherPriorityTaskWoken ) ) +#define xSemaphoreGiveFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueGiveFromISR( ( QueueHandle_t ) ( xSemaphore ), ( pxHigherPriorityTaskWoken ) ) /** + * @cond + * semphr. h + * @code{c} + * xSemaphoreTakeFromISR( + * SemaphoreHandle_t xSemaphore, + * BaseType_t *pxHigherPriorityTaskWoken + * ); + * @endcode + * @endcond + * * Macro to take a semaphore from an ISR. The semaphore must have * previously been created with a call to xSemaphoreCreateBinary() or * xSemaphoreCreateCounting(). @@ -643,17 +683,24 @@ typedef QueueHandle_t SemaphoreHandle_t; * @return pdTRUE if the semaphore was successfully taken, otherwise * pdFALSE */ -#define xSemaphoreTakeFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueReceiveFromISR( ( QueueHandle_t ) ( xSemaphore ), NULL, ( pxHigherPriorityTaskWoken ) ) +#define xSemaphoreTakeFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueReceiveFromISR( ( QueueHandle_t ) ( xSemaphore ), NULL, ( pxHigherPriorityTaskWoken ) ) /** - * Macro that implements a mutex semaphore by using the existing queue - * mechanism. + * @cond + * semphr. h + * @code{c} + * SemaphoreHandle_t xSemaphoreCreateMutex( void ); + * @endcode + * @endcond + * + * Creates a new mutex type semaphore instance, and returns a handle by which + * the new mutex can be referenced. * * Internally, within the FreeRTOS implementation, mutex semaphores use a block * of memory, in which the mutex structure is stored. If a mutex is created * using xSemaphoreCreateMutex() then the required memory is automatically * dynamically allocated inside the xSemaphoreCreateMutex() function. (see - * http://www.freertos.org/a00111.html). If a mutex is created using + * https://www.FreeRTOS.org/a00111.html). If a mutex is created using * xSemaphoreCreateMutexStatic() then the application writer must provided the * memory. xSemaphoreCreateMutexStatic() therefore allows a mutex to be created * without using any dynamic memory allocation. @@ -679,28 +726,38 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @code{c} - * SemaphoreHandle_t xSemaphore; + * 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(); + * 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. - * } + * if( xSemaphore != NULL ) + * { + * // The semaphore was created successfully. + * // The semaphore can now be used. * } + * } * @endcode + * @cond + * \defgroup xSemaphoreCreateMutex xSemaphoreCreateMutex + * @endcond * \ingroup Semaphores */ -#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - #define xSemaphoreCreateMutex() xQueueCreateMutex( queueQUEUE_TYPE_MUTEX ) +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + #define xSemaphoreCreateMutex() xQueueCreateMutex( queueQUEUE_TYPE_MUTEX ) #endif /** + * @cond + * semphr. h + * @code{c} + * SemaphoreHandle_t xSemaphoreCreateMutexStatic( StaticSemaphore_t *pxMutexBuffer ); + * @endcode + * @endcond + * * Creates a new mutex type semaphore instance, and returns a handle by which * the new mutex can be referenced. * @@ -708,7 +765,7 @@ typedef QueueHandle_t SemaphoreHandle_t; * of memory, in which the mutex structure is stored. If a mutex is created * using xSemaphoreCreateMutex() then the required memory is automatically * dynamically allocated inside the xSemaphoreCreateMutex() function. (see - * http://www.freertos.org/a00111.html). If a mutex is created using + * https://www.FreeRTOS.org/a00111.html). If a mutex is created using * xSemaphoreCreateMutexStatic() then the application writer must provided the * memory. xSemaphoreCreateMutexStatic() therefore allows a mutex to be created * without using any dynamic memory allocation. @@ -736,25 +793,28 @@ typedef QueueHandle_t SemaphoreHandle_t; * mutex is returned. If pxMutexBuffer was NULL then NULL is returned. * * Example usage: - * @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. - * } + * @code{c} + * 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 + * @cond + * \defgroup xSemaphoreCreateMutexStatic xSemaphoreCreateMutexStatic + * @endcond * \ingroup Semaphores */ - #if( configSUPPORT_STATIC_ALLOCATION == 1 ) - #define xSemaphoreCreateMutexStatic( pxMutexBuffer ) xQueueCreateMutexStatic( queueQUEUE_TYPE_MUTEX, ( pxMutexBuffer ) ) +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + #define xSemaphoreCreateMutexStatic( pxMutexBuffer ) xQueueCreateMutexStatic( queueQUEUE_TYPE_MUTEX, ( pxMutexBuffer ) ) #endif /* configSUPPORT_STATIC_ALLOCATION */ @@ -796,7 +856,7 @@ typedef QueueHandle_t SemaphoreHandle_t; * service routines. * * @return xSemaphore Handle to the created mutex semaphore. Should be of type - * SemaphoreHandle_t. + * SemaphoreHandle_t. * * Example usage: * @code{c} @@ -818,7 +878,7 @@ typedef QueueHandle_t SemaphoreHandle_t; * \ingroup Semaphores */ #if( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_RECURSIVE_MUTEXES == 1 ) ) - #define xSemaphoreCreateRecursiveMutex() xQueueCreateMutex( queueQUEUE_TYPE_RECURSIVE_MUTEX ) + #define xSemaphoreCreateRecursiveMutex() xQueueCreateMutex( queueQUEUE_TYPE_RECURSIVE_MUTEX ) #endif /** @@ -830,7 +890,7 @@ typedef QueueHandle_t SemaphoreHandle_t; * created using xSemaphoreCreateRecursiveMutex() then the required memory is * automatically dynamically allocated inside the * xSemaphoreCreateRecursiveMutex() function. (see - * http://www.freertos.org/a00111.html). If a recursive mutex is created using + * https://www.FreeRTOS.org/a00111.html). If a recursive mutex is created using * xSemaphoreCreateRecursiveMutexStatic() then the application writer must * provide the memory that will get used by the mutex. * xSemaphoreCreateRecursiveMutexStatic() therefore allows a recursive mutex to @@ -867,7 +927,7 @@ typedef QueueHandle_t SemaphoreHandle_t; * returned. * * Example usage: - * @code + * @code{c} * SemaphoreHandle_t xSemaphore; * StaticSemaphore_t xMutexBuffer; * @@ -886,24 +946,31 @@ typedef QueueHandle_t SemaphoreHandle_t; * @endcode * \ingroup Semaphores */ -#if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_RECURSIVE_MUTEXES == 1 ) ) - #define xSemaphoreCreateRecursiveMutexStatic( pxStaticSemaphore ) xQueueCreateMutexStatic( queueQUEUE_TYPE_RECURSIVE_MUTEX, pxStaticSemaphore ) +#if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_RECURSIVE_MUTEXES == 1 ) ) + #define xSemaphoreCreateRecursiveMutexStatic( pxStaticSemaphore ) xQueueCreateMutexStatic( queueQUEUE_TYPE_RECURSIVE_MUTEX, pxStaticSemaphore ) #endif /* configSUPPORT_STATIC_ALLOCATION */ /** + * @cond + * semphr. h + * @code{c} + * SemaphoreHandle_t xSemaphoreCreateCounting( UBaseType_t uxMaxCount, UBaseType_t uxInitialCount ); + * @endcode + * @endcond + * * Creates a new counting semaphore instance, and returns a handle by which the * new counting semaphore can be referenced. * * In many usage scenarios it is faster and more memory efficient to use a * direct to task notification in place of a counting semaphore! - * http://www.freertos.org/RTOS-task-notifications.html + * https://www.FreeRTOS.org/RTOS-task-notifications.html * * Internally, within the FreeRTOS implementation, counting semaphores use a * block of memory, in which the counting semaphore structure is stored. If a * counting semaphore is created using xSemaphoreCreateCounting() then the * required memory is automatically dynamically allocated inside the * xSemaphoreCreateCounting() function. (see - * http://www.freertos.org/a00111.html). If a counting semaphore is created + * https://www.FreeRTOS.org/a00111.html). If a counting semaphore is created * using xSemaphoreCreateCountingStatic() then the application writer can * instead optionally provide the memory that will get used by the counting * semaphore. xSemaphoreCreateCountingStatic() therefore allows a counting @@ -942,44 +1009,54 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @code{c} - * SemaphoreHandle_t xSemaphore; + * SemaphoreHandle_t xSemaphore; * - * void vATask( void * pvParameters ) - * { - * SemaphoreHandle_t xSemaphore = NULL; + * 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 ); + * // 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. - * } + * if( xSemaphore != NULL ) + * { + * // The semaphore was created successfully. + * // The semaphore can now be used. * } + * } * @endcode + * @cond + * \defgroup xSemaphoreCreateCounting xSemaphoreCreateCounting + * @endcond * \ingroup Semaphores */ -#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - #define xSemaphoreCreateCounting( uxMaxCount, uxInitialCount ) xQueueCreateCountingSemaphore( ( uxMaxCount ), ( uxInitialCount ) ) +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + #define xSemaphoreCreateCounting( uxMaxCount, uxInitialCount ) xQueueCreateCountingSemaphore( ( uxMaxCount ), ( uxInitialCount ) ) #endif /** + * @cond + * semphr. h + * @code{c} + * SemaphoreHandle_t xSemaphoreCreateCountingStatic( UBaseType_t uxMaxCount, UBaseType_t uxInitialCount, StaticSemaphore_t *pxSemaphoreBuffer ); + * @endcode + * @endcond + * * Creates a new counting semaphore instance, and returns a handle by which the * new counting semaphore can be referenced. * * In many usage scenarios it is faster and more memory efficient to use a * direct to task notification in place of a counting semaphore! - * http://www.freertos.org/RTOS-task-notifications.html + * https://www.FreeRTOS.org/RTOS-task-notifications.html * * Internally, within the FreeRTOS implementation, counting semaphores use a * block of memory, in which the counting semaphore structure is stored. If a * counting semaphore is created using xSemaphoreCreateCounting() then the * required memory is automatically dynamically allocated inside the * xSemaphoreCreateCounting() function. (see - * http://www.freertos.org/a00111.html). If a counting semaphore is created + * https://www.FreeRTOS.org/a00111.html). If a counting semaphore is created * using xSemaphoreCreateCountingStatic() then the application writer must * provide the memory. xSemaphoreCreateCountingStatic() therefore allows a * counting semaphore to be created without using any dynamic memory allocation. @@ -1022,42 +1099,62 @@ typedef QueueHandle_t SemaphoreHandle_t; * * Example usage: * @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. - * } + * 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 + * @cond + * \defgroup xSemaphoreCreateCountingStatic xSemaphoreCreateCountingStatic + * @endcond * \ingroup Semaphores */ -#if( configSUPPORT_STATIC_ALLOCATION == 1 ) - #define xSemaphoreCreateCountingStatic( uxMaxCount, uxInitialCount, pxSemaphoreBuffer ) xQueueCreateCountingSemaphoreStatic( ( uxMaxCount ), ( uxInitialCount ), ( pxSemaphoreBuffer ) ) +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + #define xSemaphoreCreateCountingStatic( uxMaxCount, uxInitialCount, pxSemaphoreBuffer ) xQueueCreateCountingSemaphoreStatic( ( uxMaxCount ), ( uxInitialCount ), ( pxSemaphoreBuffer ) ) #endif /* configSUPPORT_STATIC_ALLOCATION */ /** + * @cond + * semphr. h + * @code{c} + * void vSemaphoreDelete( SemaphoreHandle_t xSemaphore ); + * @endcode + * @endcond + * * 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. * + * @cond + * \defgroup vSemaphoreDelete vSemaphoreDelete + * @endcond * \ingroup Semaphores */ -#define vSemaphoreDelete( xSemaphore ) vQueueDelete( ( QueueHandle_t ) ( xSemaphore ) ) +#define vSemaphoreDelete( xSemaphore ) vQueueDelete( ( QueueHandle_t ) ( xSemaphore ) ) /** + * @cond + * semphr.h + * @code{c} + * TaskHandle_t xSemaphoreGetMutexHolder( SemaphoreHandle_t xMutex ); + * @endcode + * @endcond + * * 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. @@ -1067,20 +1164,30 @@ typedef QueueHandle_t SemaphoreHandle_t; * the holder may change between the function exiting and the returned value * being tested. */ -#define xSemaphoreGetMutexHolder( xSemaphore ) xQueueGetMutexHolder( ( xSemaphore ) ) +#define xSemaphoreGetMutexHolder( xSemaphore ) xQueueGetMutexHolder( ( xSemaphore ) ) /** + * @cond + * semphr.h + * @code{c} + * TaskHandle_t xSemaphoreGetMutexHolderFromISR( SemaphoreHandle_t xMutex ); + * @endcode + * @endcond * * 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. * */ -#define xSemaphoreGetMutexHolderFromISR( xSemaphore ) xQueueGetMutexHolderFromISR( ( xSemaphore ) ) +#define xSemaphoreGetMutexHolderFromISR( xSemaphore ) xQueueGetMutexHolderFromISR( ( xSemaphore ) ) /** + * @cond * semphr.h - *
UBaseType_t uxSemaphoreGetCount( SemaphoreHandle_t xSemaphore );
+ * @code{c} + * UBaseType_t uxSemaphoreGetCount( SemaphoreHandle_t xSemaphore ); + * @endcode + * @endcond * * If the semaphore is a counting semaphore then uxSemaphoreGetCount() returns * its current count value. If the semaphore is a binary semaphore then @@ -1088,6 +1195,6 @@ typedef QueueHandle_t SemaphoreHandle_t; * semaphore is not available. * */ -#define uxSemaphoreGetCount( xSemaphore ) uxQueueMessagesWaiting( ( QueueHandle_t ) ( xSemaphore ) ) +#define uxSemaphoreGetCount( xSemaphore ) uxQueueMessagesWaiting( ( QueueHandle_t ) ( xSemaphore ) ) #endif /* SEMAPHORE_H */ diff --git a/tools/sdk/esp32s2/include/freertos/include/freertos/stack_macros.h b/tools/sdk/esp32s2/include/freertos/include/freertos/stack_macros.h index b8eca4246f9..249c4ef840d 100644 --- a/tools/sdk/esp32s2/include/freertos/include/freertos/stack_macros.h +++ b/tools/sdk/esp32s2/include/freertos/include/freertos/stack_macros.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ #ifndef STACK_MACROS_H @@ -46,94 +45,94 @@ #if( configCHECK_FOR_STACK_OVERFLOW == 0 ) - /* FreeRTOSConfig.h is not set to check for stack overflows. */ - #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() - #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() + /* FreeRTOSConfig.h is not set to check for stack overflows. */ + #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() + #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() #endif /* configCHECK_FOR_STACK_OVERFLOW == 0 */ /*-----------------------------------------------------------*/ #if( configCHECK_FOR_STACK_OVERFLOW == 1 ) - /* FreeRTOSConfig.h is only set to use the first method of - overflow checking. */ - #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() + /* FreeRTOSConfig.h is only set to use the first method of + overflow checking. */ + #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() #endif /*-----------------------------------------------------------*/ #if( ( configCHECK_FOR_STACK_OVERFLOW > 0 ) && ( portSTACK_GROWTH < 0 ) ) - /* Only the current stack state is to be checked. */ - #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() \ - { \ - /* Is the currently saved stack pointer within the stack limit? */ \ - if( pxCurrentTCB[ xPortGetCoreID() ]->pxTopOfStack <= pxCurrentTCB[ xPortGetCoreID() ]->pxStack ) \ - { \ - vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB[ xPortGetCoreID() ], pxCurrentTCB[ xPortGetCoreID() ]->pcTaskName ); \ - } \ - } +/* Only the current stack state is to be checked. */ + #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() \ + { \ + /* Is the currently saved stack pointer within the stack limit? */ \ + if( pxCurrentTCB[ xPortGetCoreID() ]->pxTopOfStack <= pxCurrentTCB[ xPortGetCoreID() ]->pxStack ) \ + { \ + vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB[ xPortGetCoreID() ], pxCurrentTCB[ xPortGetCoreID() ]->pcTaskName ); \ + } \ + } #endif /* configCHECK_FOR_STACK_OVERFLOW > 0 */ /*-----------------------------------------------------------*/ #if( ( configCHECK_FOR_STACK_OVERFLOW > 0 ) && ( portSTACK_GROWTH > 0 ) ) - /* Only the current stack state is to be checked. */ - #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() \ - { \ - \ - /* Is the currently saved stack pointer within the stack limit? */ \ - if( pxCurrentTCB[ xPortGetCoreID() ]->pxTopOfStack >= pxCurrentTCB[ xPortGetCoreID() ]->pxEndOfStack ) \ - { \ - vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB[ xPortGetCoreID() ], pxCurrentTCB[ xPortGetCoreID() ]->pcTaskName ); \ - } \ - } +/* Only the current stack state is to be checked. */ + #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() \ + { \ + \ + /* Is the currently saved stack pointer within the stack limit? */ \ + if( pxCurrentTCB[ xPortGetCoreID() ]->pxTopOfStack >= pxCurrentTCB[ xPortGetCoreID() ]->pxEndOfStack ) \ + { \ + vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB[ xPortGetCoreID() ], pxCurrentTCB[ xPortGetCoreID() ]->pcTaskName ); \ + } \ + } #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ /*-----------------------------------------------------------*/ -#if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) ) - - #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() \ - { \ - static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ - \ - \ - /* Has the extremity of the task stack ever been written over? */ \ - if( memcmp( ( void * ) pxCurrentTCB[ xPortGetCoreID() ]->pxStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ - { \ - vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB[ xPortGetCoreID() ], pxCurrentTCB[ xPortGetCoreID() ]->pcTaskName ); \ - } \ - } +#if ( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) ) + + #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() \ + { \ + static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ + \ + \ + /* Has the extremity of the task stack ever been written over? */ \ + if( memcmp( ( void * ) pxCurrentTCB[ xPortGetCoreID() ]->pxStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ + { \ + vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB[ xPortGetCoreID() ], pxCurrentTCB[ xPortGetCoreID() ]->pcTaskName ); \ + } \ + } #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ /*-----------------------------------------------------------*/ -#if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) ) - - #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() \ - { \ - int8_t *pcEndOfStack = ( int8_t * ) pxCurrentTCB[ xPortGetCoreID() ]->pxEndOfStack; \ - static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ - \ - \ - pcEndOfStack -= sizeof( ucExpectedStackBytes ); \ - \ - /* Has the extremity of the task stack ever been written over? */ \ - if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ - { \ - vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB[ xPortGetCoreID() ], pxCurrentTCB[ xPortGetCoreID() ]->pcTaskName ); \ - } \ - } +#if ( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) ) + + #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() \ + { \ + int8_t *pcEndOfStack = ( int8_t * ) pxCurrentTCB[ xPortGetCoreID() ]->pxEndOfStack; \ + static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ + \ + \ + pcEndOfStack -= sizeof( ucExpectedStackBytes ); \ + \ + /* Has the extremity of the task stack ever been written over? */ \ + if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ + { \ + vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB[ xPortGetCoreID() ], pxCurrentTCB[ xPortGetCoreID() ]->pcTaskName ); \ + } \ + } #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ diff --git a/tools/sdk/esp32s2/include/freertos/include/freertos/stream_buffer.h b/tools/sdk/esp32s2/include/freertos/include/freertos/stream_buffer.h index 1a3d8f5190c..9e58cff120c 100644 --- a/tools/sdk/esp32s2/include/freertos/include/freertos/stream_buffer.h +++ b/tools/sdk/esp32s2/include/freertos/include/freertos/stream_buffer.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ /* @@ -43,7 +42,7 @@ * (such as xStreamBufferSend()) inside a critical section and set the send * block time to 0. Likewise, if there are to be multiple different readers * then the application writer must place each call to a reading API function - * (such as xStreamBufferRead()) inside a critical section section and set the + * (such as xStreamBufferReceive()) inside a critical section section and set the * receive block time to 0. * */ @@ -52,12 +51,14 @@ #define STREAM_BUFFER_H #ifndef INC_FREERTOS_H - #error "include FreeRTOS.h must appear in source files before include stream_buffer.h" + #error "include FreeRTOS.h must appear in source files before include stream_buffer.h" #endif +/* *INDENT-OFF* */ #if defined( __cplusplus ) -extern "C" { + extern "C" { #endif +/* *INDENT-ON* */ /** * Type by which stream buffers are referenced. For example, a call to @@ -68,7 +69,16 @@ extern "C" { struct StreamBufferDef_t; typedef struct StreamBufferDef_t * StreamBufferHandle_t; + /** + * @cond + * message_buffer.h + * + * @code{c} + * StreamBufferHandle_t xStreamBufferCreate( size_t xBufferSizeBytes, size_t xTriggerLevelBytes ); + * @endcode + * @endcond + * * Creates a new stream buffer using dynamically allocated memory. See * xStreamBufferCreateStatic() for a version that uses statically allocated * memory (memory that is allocated at compile time). @@ -103,32 +113,46 @@ typedef struct StreamBufferDef_t * StreamBufferHandle_t; * Example use: * @code{c} * - * void vAFunction( void ) - * { - * StreamBufferHandle_t xStreamBuffer; - * const size_t xStreamBufferSizeBytes = 100, xTriggerLevel = 10; - * - * // Create a stream buffer that can hold 100 bytes. The memory used to hold - * // both the stream buffer structure and the data in the stream buffer is - * // allocated dynamically. - * xStreamBuffer = xStreamBufferCreate( xStreamBufferSizeBytes, xTriggerLevel ); - * - * if( xStreamBuffer == NULL ) - * { - * // There was not enough heap memory space available to create the - * // stream buffer. - * } - * else - * { - * // The stream buffer was created successfully and can now be used. - * } - * } + * void vAFunction( void ) + * { + * StreamBufferHandle_t xStreamBuffer; + * const size_t xStreamBufferSizeBytes = 100, xTriggerLevel = 10; + * + * // Create a stream buffer that can hold 100 bytes. The memory used to hold + * // both the stream buffer structure and the data in the stream buffer is + * // allocated dynamically. + * xStreamBuffer = xStreamBufferCreate( xStreamBufferSizeBytes, xTriggerLevel ); + * + * if( xStreamBuffer == NULL ) + * { + * // There was not enough heap memory space available to create the + * // stream buffer. + * } + * else + * { + * // The stream buffer was created successfully and can now be used. + * } + * } * @endcode + * @cond + * \defgroup xStreamBufferCreate xStreamBufferCreate + * @endcond * \ingroup StreamBufferManagement */ -#define xStreamBufferCreate( xBufferSizeBytes, xTriggerLevelBytes ) xStreamBufferGenericCreate( xBufferSizeBytes, xTriggerLevelBytes, pdFALSE ) +#define xStreamBufferCreate( xBufferSizeBytes, xTriggerLevelBytes ) xStreamBufferGenericCreate( xBufferSizeBytes, xTriggerLevelBytes, pdFALSE ) /** + * @cond + * stream_buffer.h + * + * @code{c} + * StreamBufferHandle_t xStreamBufferCreateStatic( size_t xBufferSizeBytes, + * size_t xTriggerLevelBytes, + * uint8_t *pucStreamBufferStorageArea, + * StaticStreamBuffer_t *pxStaticStreamBuffer ); + * @endcode + * @endcond + * * Creates a new stream buffer using statically allocated memory. See * xStreamBufferCreate() for a version that uses dynamically allocated memory. * @@ -167,40 +191,55 @@ typedef struct StreamBufferDef_t * StreamBufferHandle_t; * Example use: * @code{c} * - * // Used to dimension the array used to hold the streams. The available space - * // will actually be one less than this, so 999. - * #define STORAGE_SIZE_BYTES 1000 + * // Used to dimension the array used to hold the streams. The available space + * // will actually be one less than this, so 999. + * #define STORAGE_SIZE_BYTES 1000 * - * // Defines the memory that will actually hold the streams within the stream - * // buffer. - * static uint8_t ucStorageBuffer[ STORAGE_SIZE_BYTES ]; + * // Defines the memory that will actually hold the streams within the stream + * // buffer. + * static uint8_t ucStorageBuffer[ STORAGE_SIZE_BYTES ]; * - * // The variable used to hold the stream buffer structure. - * StaticStreamBuffer_t xStreamBufferStruct; + * // The variable used to hold the stream buffer structure. + * StaticStreamBuffer_t xStreamBufferStruct; * - * void MyFunction( void ) - * { - * StreamBufferHandle_t xStreamBuffer; - * const size_t xTriggerLevel = 1; + * void MyFunction( void ) + * { + * StreamBufferHandle_t xStreamBuffer; + * const size_t xTriggerLevel = 1; * - * xStreamBuffer = xStreamBufferCreateStatic( sizeof( ucBufferStorage ), - * xTriggerLevel, - * ucBufferStorage, - * &xStreamBufferStruct ); + * xStreamBuffer = xStreamBufferCreateStatic( sizeof( ucBufferStorage ), + * xTriggerLevel, + * ucBufferStorage, + * &xStreamBufferStruct ); * - * // As neither the pucStreamBufferStorageArea or pxStaticStreamBuffer - * // parameters were NULL, xStreamBuffer will not be NULL, and can be used to - * // reference the created stream buffer in other stream buffer API calls. + * // As neither the pucStreamBufferStorageArea or pxStaticStreamBuffer + * // parameters were NULL, xStreamBuffer will not be NULL, and can be used to + * // reference the created stream buffer in other stream buffer API calls. * - * // Other code that uses the stream buffer can go here. - * } + * // Other code that uses the stream buffer can go here. + * } * * @endcode + * @cond + * \defgroup xStreamBufferCreateStatic xStreamBufferCreateStatic + * @endcond * \ingroup StreamBufferManagement */ -#define xStreamBufferCreateStatic( xBufferSizeBytes, xTriggerLevelBytes, pucStreamBufferStorageArea, pxStaticStreamBuffer ) xStreamBufferGenericCreateStatic( xBufferSizeBytes, xTriggerLevelBytes, pdFALSE, pucStreamBufferStorageArea, pxStaticStreamBuffer ) +#define xStreamBufferCreateStatic( xBufferSizeBytes, xTriggerLevelBytes, pucStreamBufferStorageArea, pxStaticStreamBuffer ) \ + xStreamBufferGenericCreateStatic( xBufferSizeBytes, xTriggerLevelBytes, pdFALSE, pucStreamBufferStorageArea, pxStaticStreamBuffer ) /** + * @cond + * stream_buffer.h + * + * @code{c} + * size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, + * const void *pvTxData, + * size_t xDataLengthBytes, + * TickType_t xTicksToWait ); + * @endcode + * @endcond + * * Sends bytes to a stream buffer. The bytes are copied into the stream buffer. * * ***NOTE***: Uniquely among FreeRTOS objects, the stream buffer @@ -215,7 +254,7 @@ typedef struct StreamBufferDef_t * StreamBufferHandle_t; * (such as xStreamBufferSend()) inside a critical section and set the send * block time to 0. Likewise, if there are to be multiple different readers * then the application writer must place each call to a reading API function - * (such as xStreamBufferRead()) inside a critical section and set the receive + * (such as xStreamBufferReceive()) inside a critical section and set the receive * block time to 0. * * Use xStreamBufferSend() to write to a stream buffer from a task. Use @@ -250,44 +289,58 @@ typedef struct StreamBufferDef_t * StreamBufferHandle_t; * * Example use: * @code{c} - * void vAFunction( StreamBufferHandle_t xStreamBuffer ) - * { - * size_t xBytesSent; - * uint8_t ucArrayToSend[] = { 0, 1, 2, 3 }; - * char *pcStringToSend = "String to send"; - * const TickType_t x100ms = pdMS_TO_TICKS( 100 ); - * - * // Send an array to the stream buffer, blocking for a maximum of 100ms to - * // wait for enough space to be available in the stream buffer. - * xBytesSent = xStreamBufferSend( xStreamBuffer, ( void * ) ucArrayToSend, sizeof( ucArrayToSend ), x100ms ); - * - * if( xBytesSent != sizeof( ucArrayToSend ) ) - * { - * // The call to xStreamBufferSend() times out before there was enough - * // space in the buffer for the data to be written, but it did - * // successfully write xBytesSent bytes. - * } - * - * // Send the string to the stream buffer. Return immediately if there is not - * // enough space in the buffer. - * xBytesSent = xStreamBufferSend( xStreamBuffer, ( void * ) pcStringToSend, strlen( pcStringToSend ), 0 ); - * - * if( xBytesSent != strlen( pcStringToSend ) ) - * { - * // The entire string could not be added to the stream buffer because - * // there was not enough free space in the buffer, but xBytesSent bytes - * // were sent. Could try again to send the remaining bytes. - * } - * } + * void vAFunction( StreamBufferHandle_t xStreamBuffer ) + * { + * size_t xBytesSent; + * uint8_t ucArrayToSend[] = { 0, 1, 2, 3 }; + * char *pcStringToSend = "String to send"; + * const TickType_t x100ms = pdMS_TO_TICKS( 100 ); + * + * // Send an array to the stream buffer, blocking for a maximum of 100ms to + * // wait for enough space to be available in the stream buffer. + * xBytesSent = xStreamBufferSend( xStreamBuffer, ( void * ) ucArrayToSend, sizeof( ucArrayToSend ), x100ms ); + * + * if( xBytesSent != sizeof( ucArrayToSend ) ) + * { + * // The call to xStreamBufferSend() times out before there was enough + * // space in the buffer for the data to be written, but it did + * // successfully write xBytesSent bytes. + * } + * + * // Send the string to the stream buffer. Return immediately if there is not + * // enough space in the buffer. + * xBytesSent = xStreamBufferSend( xStreamBuffer, ( void * ) pcStringToSend, strlen( pcStringToSend ), 0 ); + * + * if( xBytesSent != strlen( pcStringToSend ) ) + * { + * // The entire string could not be added to the stream buffer because + * // there was not enough free space in the buffer, but xBytesSent bytes + * // were sent. Could try again to send the remaining bytes. + * } + * } * @endcode + * @cond + * \defgroup xStreamBufferSend xStreamBufferSend + * @endcond * \ingroup StreamBufferManagement */ size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, - const void *pvTxData, - size_t xDataLengthBytes, - TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; + const void * pvTxData, + size_t xDataLengthBytes, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer, + * const void *pvTxData, + * size_t xDataLengthBytes, + * BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * @endcond + * * Interrupt safe version of the API function that sends a stream of bytes to * the stream buffer. * @@ -303,7 +356,7 @@ size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, * (such as xStreamBufferSend()) inside a critical section and set the send * block time to 0. Likewise, if there are to be multiple different readers * then the application writer must place each call to a reading API function - * (such as xStreamBufferRead()) inside a critical section and set the receive + * (such as xStreamBufferReceive()) inside a critical section and set the receive * block time to 0. * * Use xStreamBufferSend() to write to a stream buffer from a task. Use @@ -339,46 +392,60 @@ size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, * * Example use: * @code{c} - * //A stream buffer that has already been created. - * StreamBufferHandle_t xStreamBuffer; - * - * void vAnInterruptServiceRoutine( void ) - * { - * size_t xBytesSent; - * char *pcStringToSend = "String to send"; - * BaseType_t xHigherPriorityTaskWoken = pdFALSE; // Initialised to pdFALSE. - * - * // Attempt to send the string to the stream buffer. - * xBytesSent = xStreamBufferSendFromISR( xStreamBuffer, - * ( void * ) pcStringToSend, - * strlen( pcStringToSend ), - * &xHigherPriorityTaskWoken ); - * - * if( xBytesSent != strlen( pcStringToSend ) ) - * { - * // There was not enough free space in the stream buffer for the entire - * // string to be written, ut xBytesSent bytes were written. - * } - * - * // If xHigherPriorityTaskWoken was set to pdTRUE inside - * // xStreamBufferSendFromISR() then a task that has a priority above the - * // priority of the currently executing task was unblocked and a context - * // switch should be performed to ensure the ISR returns to the unblocked - * // task. In most FreeRTOS ports this is done by simply passing - * // xHigherPriorityTaskWoken into taskYIELD_FROM_ISR(), which will test the - * // variables value, and perform the context switch if necessary. Check the - * // documentation for the port in use for port specific instructions. - * taskYIELD_FROM_ISR( xHigherPriorityTaskWoken ); - * } + * // A stream buffer that has already been created. + * StreamBufferHandle_t xStreamBuffer; + * + * void vAnInterruptServiceRoutine( void ) + * { + * size_t xBytesSent; + * char *pcStringToSend = "String to send"; + * BaseType_t xHigherPriorityTaskWoken = pdFALSE; // Initialised to pdFALSE. + * + * // Attempt to send the string to the stream buffer. + * xBytesSent = xStreamBufferSendFromISR( xStreamBuffer, + * ( void * ) pcStringToSend, + * strlen( pcStringToSend ), + * &xHigherPriorityTaskWoken ); + * + * if( xBytesSent != strlen( pcStringToSend ) ) + * { + * // There was not enough free space in the stream buffer for the entire + * // string to be written, ut xBytesSent bytes were written. + * } + * + * // If xHigherPriorityTaskWoken was set to pdTRUE inside + * // xStreamBufferSendFromISR() then a task that has a priority above the + * // priority of the currently executing task was unblocked and a context + * // switch should be performed to ensure the ISR returns to the unblocked + * // task. In most FreeRTOS ports this is done by simply passing + * // xHigherPriorityTaskWoken into taskYIELD_FROM_ISR(), which will test the + * // variables value, and perform the context switch if necessary. Check the + * // documentation for the port in use for port specific instructions. + * taskYIELD_FROM_ISR( xHigherPriorityTaskWoken ); + * } * @endcode + * @cond + * \defgroup xStreamBufferSendFromISR xStreamBufferSendFromISR + * @endcond * \ingroup StreamBufferManagement */ size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer, - const void *pvTxData, - size_t xDataLengthBytes, - BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; + const void * pvTxData, + size_t xDataLengthBytes, + BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * size_t xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer, + * void *pvRxData, + * size_t xBufferLengthBytes, + * TickType_t xTicksToWait ); + * @endcode + * @endcond + * * Receives bytes from a stream buffer. * * ***NOTE***: Uniquely among FreeRTOS objects, the stream buffer @@ -393,7 +460,7 @@ size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer, * (such as xStreamBufferSend()) inside a critical section and set the send * block time to 0. Likewise, if there are to be multiple different readers * then the application writer must place each call to a reading API function - * (such as xStreamBufferRead()) inside a critical section and set the receive + * (such as xStreamBufferReceive()) inside a critical section and set the receive * block time to 0. * * Use xStreamBufferReceive() to read from a stream buffer from a task. Use @@ -428,37 +495,50 @@ size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer, * * Example use: * @code{c} - * void vAFunction( StreamBuffer_t xStreamBuffer ) - * { - * uint8_t ucRxData[ 20 ]; - * size_t xReceivedBytes; - * const TickType_t xBlockTime = pdMS_TO_TICKS( 20 ); - * - * // Receive up to another sizeof( ucRxData ) bytes from the stream buffer. - * // Wait in the Blocked state (so not using any CPU processing time) for a - * // maximum of 100ms for the full sizeof( ucRxData ) number of bytes to be - * // available. - * xReceivedBytes = xStreamBufferReceive( xStreamBuffer, - * ( void * ) ucRxData, - * sizeof( ucRxData ), - * xBlockTime ); - * - * if( xReceivedBytes > 0 ) - * { - * // A ucRxData contains another xRecievedBytes bytes of data, which can - * // be processed here.... - * } - * } + * void vAFunction( StreamBuffer_t xStreamBuffer ) + * { + * uint8_t ucRxData[ 20 ]; + * size_t xReceivedBytes; + * const TickType_t xBlockTime = pdMS_TO_TICKS( 20 ); + * + * // Receive up to another sizeof( ucRxData ) bytes from the stream buffer. + * // Wait in the Blocked state (so not using any CPU processing time) for a + * // maximum of 100ms for the full sizeof( ucRxData ) number of bytes to be + * // available. + * xReceivedBytes = xStreamBufferReceive( xStreamBuffer, + * ( void * ) ucRxData, + * sizeof( ucRxData ), + * xBlockTime ); + * + * if( xReceivedBytes > 0 ) + * { + * // A ucRxData contains another xRecievedBytes bytes of data, which can + * // be processed here.... + * } + * } * @endcode + * @cond + * \defgroup xStreamBufferReceive xStreamBufferReceive + * @endcond * \ingroup StreamBufferManagement */ size_t xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer, - void *pvRxData, - size_t xBufferLengthBytes, - TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; - + void * pvRxData, + size_t xBufferLengthBytes, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * size_t xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer, + * void *pvRxData, + * size_t xBufferLengthBytes, + * BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * @endcond + * * An interrupt safe version of the API function that receives bytes from a * stream buffer. * @@ -495,46 +575,57 @@ size_t xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer, * * Example use: * @code{c} - * // A stream buffer that has already been created. - * StreamBuffer_t xStreamBuffer; - * - * void vAnInterruptServiceRoutine( void ) - * { - * uint8_t ucRxData[ 20 ]; - * size_t xReceivedBytes; - * BaseType_t xHigherPriorityTaskWoken = pdFALSE; // Initialised to pdFALSE. - * - * // Receive the next stream from the stream buffer. - * xReceivedBytes = xStreamBufferReceiveFromISR( xStreamBuffer, - * ( void * ) ucRxData, - * sizeof( ucRxData ), - * &xHigherPriorityTaskWoken ); - * - * if( xReceivedBytes > 0 ) - * { - * // ucRxData contains xReceivedBytes read from the stream buffer. - * // Process the stream here.... - * } - * - * // If xHigherPriorityTaskWoken was set to pdTRUE inside - * // xStreamBufferReceiveFromISR() then a task that has a priority above the - * // priority of the currently executing task was unblocked and a context - * // switch should be performed to ensure the ISR returns to the unblocked - * // task. In most FreeRTOS ports this is done by simply passing - * // xHigherPriorityTaskWoken into taskYIELD_FROM_ISR(), which will test the - * // variables value, and perform the context switch if necessary. Check the - * // documentation for the port in use for port specific instructions. - * taskYIELD_FROM_ISR( xHigherPriorityTaskWoken ); - * } + * // A stream buffer that has already been created. + * StreamBuffer_t xStreamBuffer; + * + * void vAnInterruptServiceRoutine( void ) + * { + * uint8_t ucRxData[ 20 ]; + * size_t xReceivedBytes; + * BaseType_t xHigherPriorityTaskWoken = pdFALSE; // Initialised to pdFALSE. + * + * // Receive the next stream from the stream buffer. + * xReceivedBytes = xStreamBufferReceiveFromISR( xStreamBuffer, + * ( void * ) ucRxData, + * sizeof( ucRxData ), + * &xHigherPriorityTaskWoken ); + * + * if( xReceivedBytes > 0 ) + * { + * // ucRxData contains xReceivedBytes read from the stream buffer. + * // Process the stream here.... + * } + * + * // If xHigherPriorityTaskWoken was set to pdTRUE inside + * // xStreamBufferReceiveFromISR() then a task that has a priority above the + * // priority of the currently executing task was unblocked and a context + * // switch should be performed to ensure the ISR returns to the unblocked + * // task. In most FreeRTOS ports this is done by simply passing + * // xHigherPriorityTaskWoken into taskYIELD_FROM_ISR(), which will test the + * // variables value, and perform the context switch if necessary. Check the + * // documentation for the port in use for port specific instructions. + * taskYIELD_FROM_ISR( xHigherPriorityTaskWoken ); + * } * @endcode + * @cond + * \defgroup xStreamBufferReceiveFromISR xStreamBufferReceiveFromISR + * @endcond * \ingroup StreamBufferManagement */ size_t xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer, - void *pvRxData, - size_t xBufferLengthBytes, - BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; + void * pvRxData, + size_t xBufferLengthBytes, + BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * void vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ); + * @endcode + * @endcond + * * Deletes a stream buffer that was previously created using a call to * xStreamBufferCreate() or xStreamBufferCreateStatic(). If the stream * buffer was created using dynamic memory (that is, by xStreamBufferCreate()), @@ -545,11 +636,22 @@ size_t xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer, * * @param xStreamBuffer The handle of the stream buffer to be deleted. * + * @cond + * \defgroup vStreamBufferDelete vStreamBufferDelete + * @endcond * \ingroup StreamBufferManagement */ void vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * BaseType_t xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ); + * @endcode + * @endcond + * * Queries a stream buffer to see if it is full. A stream buffer is full if it * does not have any free space, and therefore cannot accept any more data. * @@ -558,11 +660,22 @@ void vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTI * @return If the stream buffer is full then pdTRUE is returned. Otherwise * pdFALSE is returned. * + * @cond + * \defgroup xStreamBufferIsFull xStreamBufferIsFull + * @endcond * \ingroup StreamBufferManagement */ BaseType_t xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * BaseType_t xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ); + * @endcode + * @endcond + * * Queries a stream buffer to see if it is empty. A stream buffer is empty if * it does not contain any data. * @@ -571,11 +684,22 @@ BaseType_t xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_ * @return If the stream buffer is empty then pdTRUE is returned. Otherwise * pdFALSE is returned. * + * @cond + * \defgroup xStreamBufferIsEmpty xStreamBufferIsEmpty + * @endcond * \ingroup StreamBufferManagement */ BaseType_t xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * BaseType_t xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ); + * @endcode + * @endcond + * * Resets a stream buffer to its initial, empty, state. Any data that was in * the stream buffer is discarded. A stream buffer can only be reset if there * are no tasks blocked waiting to either send to or receive from the stream @@ -587,11 +711,22 @@ BaseType_t xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED * a task blocked waiting to send to or read from the stream buffer then the * stream buffer is not reset and pdFAIL is returned. * + * @cond + * \defgroup xStreamBufferReset xStreamBufferReset + * @endcond * \ingroup StreamBufferManagement */ BaseType_t xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * size_t xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ); + * @endcode + * @endcond + * * Queries a stream buffer to see how much free space it contains, which is * equal to the amount of data that can be sent to the stream buffer before it * is full. @@ -601,12 +736,22 @@ BaseType_t xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_F * @return The number of bytes that can be written to the stream buffer before * the stream buffer would be full. * + * @cond * \defgroup xStreamBufferSpacesAvailable xStreamBufferSpacesAvailable + * @endcond * \ingroup StreamBufferManagement */ size_t xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * size_t xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ); + * @endcode + * @endcond + * * Queries a stream buffer to see how much data it contains, which is equal to * the number of bytes that can be read from the stream buffer before the stream * buffer would be empty. @@ -616,12 +761,22 @@ size_t xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ) PRIVIL * @return The number of bytes that can be read from the stream buffer before * the stream buffer would be empty. * + * @cond * \defgroup xStreamBufferBytesAvailable xStreamBufferBytesAvailable + * @endcond * \ingroup StreamBufferManagement */ size_t xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, size_t xTriggerLevel ); + * @endcode + * @endcond + * * A stream buffer's trigger level is the number of bytes that must be in the * stream buffer before a task that is blocked on the stream buffer to * wait for data is moved out of the blocked state. For example, if a task is @@ -647,11 +802,23 @@ size_t xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ) PRIVILE * then the trigger level will be updated and pdTRUE is returned. Otherwise * pdFALSE is returned. * + * @cond + * \defgroup xStreamBufferSetTriggerLevel xStreamBufferSetTriggerLevel + * @endcond * \ingroup StreamBufferManagement */ -BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, size_t xTriggerLevel ) PRIVILEGED_FUNCTION; +BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, + size_t xTriggerLevel ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * BaseType_t xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * @endcond + * * For advanced users only. * * The sbSEND_COMPLETED() macro is called from within the FreeRTOS APIs when @@ -679,11 +846,23 @@ BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, siz * @return If a task was removed from the Blocked state then pdTRUE is returned. * Otherwise pdFALSE is returned. * + * @cond + * \defgroup xStreamBufferSendCompletedFromISR xStreamBufferSendCompletedFromISR + * @endcond * \ingroup StreamBufferManagement */ -BaseType_t xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; +BaseType_t xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer, + BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; /** + * @cond + * stream_buffer.h + * + * @code{c} + * BaseType_t xStreamBufferReceiveCompletedFromISR( StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * @endcond + * * For advanced users only. * * The sbRECEIVE_COMPLETED() macro is called from within the FreeRTOS APIs when @@ -712,34 +891,41 @@ BaseType_t xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer * @return If a task was removed from the Blocked state then pdTRUE is returned. * Otherwise pdFALSE is returned. * + * @cond + * \defgroup xStreamBufferReceiveCompletedFromISR xStreamBufferReceiveCompletedFromISR + * @endcond * \ingroup StreamBufferManagement */ -BaseType_t xStreamBufferReceiveCompletedFromISR( StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; +BaseType_t xStreamBufferReceiveCompletedFromISR( StreamBufferHandle_t xStreamBuffer, + BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; /** @cond */ /* Functions below here are not part of the public API. */ StreamBufferHandle_t xStreamBufferGenericCreate( size_t xBufferSizeBytes, - size_t xTriggerLevelBytes, - BaseType_t xIsMessageBuffer ) PRIVILEGED_FUNCTION; + size_t xTriggerLevelBytes, + BaseType_t xIsMessageBuffer ) PRIVILEGED_FUNCTION; StreamBufferHandle_t xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes, - size_t xTriggerLevelBytes, - BaseType_t xIsMessageBuffer, - uint8_t * const pucStreamBufferStorageArea, - StaticStreamBuffer_t * const pxStaticStreamBuffer ) PRIVILEGED_FUNCTION; + size_t xTriggerLevelBytes, + BaseType_t xIsMessageBuffer, + uint8_t * const pucStreamBufferStorageArea, + StaticStreamBuffer_t * const pxStaticStreamBuffer ) PRIVILEGED_FUNCTION; size_t xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; -#if( configUSE_TRACE_FACILITY == 1 ) - void vStreamBufferSetStreamBufferNumber( StreamBufferHandle_t xStreamBuffer, UBaseType_t uxStreamBufferNumber ) PRIVILEGED_FUNCTION; - UBaseType_t uxStreamBufferGetStreamBufferNumber( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; - uint8_t ucStreamBufferGetStreamBufferType( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; +#if ( configUSE_TRACE_FACILITY == 1 ) + void vStreamBufferSetStreamBufferNumber( StreamBufferHandle_t xStreamBuffer, + UBaseType_t uxStreamBufferNumber ) PRIVILEGED_FUNCTION; + UBaseType_t uxStreamBufferGetStreamBufferNumber( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; + uint8_t ucStreamBufferGetStreamBufferType( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; #endif /** @endcond */ +/* *INDENT-OFF* */ #if defined( __cplusplus ) -} + } #endif +/* *INDENT-ON* */ -#endif /* !defined( STREAM_BUFFER_H ) */ +#endif /* !defined( STREAM_BUFFER_H ) */ diff --git a/tools/sdk/esp32s2/include/freertos/include/freertos/task.h b/tools/sdk/esp32s2/include/freertos/include/freertos/task.h index 559945805ee..9135b76f014 100644 --- a/tools/sdk/esp32s2/include/freertos/include/freertos/task.h +++ b/tools/sdk/esp32s2/include/freertos/include/freertos/task.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ @@ -30,69 +29,89 @@ #define INC_TASK_H #ifndef INC_FREERTOS_H - #error "include FreeRTOS.h must appear in source files before include task.h" + #error "include FreeRTOS.h must appear in source files before include task.h" #endif #include "list.h" +#ifdef ESP_PLATFORM // IDF-3793 #include "freertos/portmacro.h" +#endif // ESP_PLATFORM +/* *INDENT-OFF* */ #ifdef __cplusplus -extern "C" { + extern "C" { #endif +/* *INDENT-ON* */ /*----------------------------------------------------------- * MACROS AND DEFINITIONS *----------------------------------------------------------*/ -#define tskKERNEL_VERSION_NUMBER "V10.2.1" -#define tskKERNEL_VERSION_MAJOR 10 -#define tskKERNEL_VERSION_MINOR 2 -#define tskKERNEL_VERSION_BUILD 1 +#define tskKERNEL_VERSION_NUMBER "V10.4.3" +#define tskKERNEL_VERSION_MAJOR 10 +#define tskKERNEL_VERSION_MINOR 4 +#define tskKERNEL_VERSION_BUILD 3 /* MPU region parameters passed in ulParameters * of MemoryRegion_t struct. */ -#define tskMPU_REGION_READ_ONLY ( 1UL << 0UL ) -#define tskMPU_REGION_READ_WRITE ( 1UL << 1UL ) -#define tskMPU_REGION_EXECUTE_NEVER ( 1UL << 2UL ) -#define tskMPU_REGION_NORMAL_MEMORY ( 1UL << 3UL ) -#define tskMPU_REGION_DEVICE_MEMORY ( 1UL << 4UL ) +#define tskMPU_REGION_READ_ONLY ( 1UL << 0UL ) +#define tskMPU_REGION_READ_WRITE ( 1UL << 1UL ) +#define tskMPU_REGION_EXECUTE_NEVER ( 1UL << 2UL ) +#define tskMPU_REGION_NORMAL_MEMORY ( 1UL << 3UL ) +#define tskMPU_REGION_DEVICE_MEMORY ( 1UL << 4UL ) + +/* The direct to task notification feature used to have only a single notification + * per task. Now there is an array of notifications per task that is dimensioned by + * configTASK_NOTIFICATION_ARRAY_ENTRIES. For backward compatibility, any use of the + * original direct to task notification defaults to using the first index in the + * array. */ +#define tskDEFAULT_INDEX_TO_NOTIFY ( 0 ) + +#define tskNO_AFFINITY ( 0x7FFFFFFF ) -#define tskNO_AFFINITY ( 0x7FFFFFFF ) /** + * task. h + * * Type by which tasks are referenced. For example, a call to xTaskCreate * returns (via a pointer parameter) an TaskHandle_t variable that can then * be used as a parameter to vTaskDelete to delete the task. * + * @cond + * \defgroup TaskHandle_t TaskHandle_t + * @endcond * \ingroup Tasks */ -struct tskTaskControlBlock; /* The old naming convention is used to prevent breaking kernel aware debuggers. */ -//typedef struct tskTaskControlBlock* TaskHandle_t; +struct tskTaskControlBlock; /* The old naming convention is used to prevent breaking kernel aware debuggers. */ +#ifdef ESP_PLATFORM // IDF-3769 typedef void* TaskHandle_t; +#else +typedef struct tskTaskControlBlock* TaskHandle_t; +#endif // ESP_PLATFORM /** * Defines the prototype to which the application task hook function must * conform. */ -typedef BaseType_t (*TaskHookFunction_t)( void * ); +typedef BaseType_t (* TaskHookFunction_t)( void * ); /** 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. */ - eInvalid /* Used as an 'invalid state' value. */ + 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. */ + eInvalid /* Used as an 'invalid state' value. */ } eTaskState; /* 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 */ @@ -101,8 +120,8 @@ typedef enum */ typedef struct xTIME_OUT { - BaseType_t xOverflowCount; - TickType_t xTimeOnEntering; + BaseType_t xOverflowCount; + TickType_t xTimeOnEntering; } TimeOut_t; /** @@ -110,9 +129,9 @@ typedef struct xTIME_OUT */ typedef struct xMEMORY_REGION { - void *pvBaseAddress; - uint32_t ulLengthInBytes; - uint32_t ulParameters; + void * pvBaseAddress; + uint32_t ulLengthInBytes; + uint32_t ulParameters; } MemoryRegion_t; /* @@ -120,50 +139,36 @@ typedef struct xMEMORY_REGION */ typedef struct xTASK_PARAMETERS { - TaskFunction_t pvTaskCode; - const char * const pcName; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ - configSTACK_DEPTH_TYPE usStackDepth; - void *pvParameters; - UBaseType_t uxPriority; - StackType_t *puxStackBuffer; - MemoryRegion_t xRegions[ portNUM_CONFIGURABLE_REGIONS ]; - #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) - StaticTask_t * const pxTaskBuffer; - #endif + TaskFunction_t pvTaskCode; + const char * const pcName; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + configSTACK_DEPTH_TYPE usStackDepth; + void * pvParameters; + UBaseType_t uxPriority; + StackType_t * puxStackBuffer; + MemoryRegion_t xRegions[ portNUM_CONFIGURABLE_REGIONS ]; + #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) + StaticTask_t * const pxTaskBuffer; + #endif } TaskParameters_t; - -/* - * 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. */ - configSTACK_DEPTH_TYPE 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 https://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. */ + configSTACK_DEPTH_TYPE 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. */ #if configTASKLIST_INCLUDE_COREID - BaseType_t xCoreID; /*!< Core this task is pinned to (0, 1, or -1 for tskNO_AFFINITY). This field is present if CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID is set. */ + BaseType_t xCoreID; /*!< Core this task is pinned to (0, 1, or -1 for tskNO_AFFINITY). This field is present if CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID is set. */ #endif } 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*/ -} TaskSnapshot_t; - /** @endcond */ /** @@ -171,9 +176,9 @@ typedef struct xTASK_SNAPSHOT */ 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; /** @@ -181,61 +186,104 @@ typedef enum * * \ingroup TaskUtils */ -#define tskIDLE_PRIORITY ( ( UBaseType_t ) 0U ) +#define tskIDLE_PRIORITY ( ( UBaseType_t ) 0U ) /** + * task. h + * * Macro for forcing a context switch. * + * @cond + * \defgroup taskYIELD taskYIELD + * @endcond * \ingroup SchedulerControl */ -#define taskYIELD() portYIELD() +#define taskYIELD() portYIELD() /** + * task. h + * * 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) * so must be used with care! * + * @cond + * \defgroup taskENTER_CRITICAL taskENTER_CRITICAL + * @endcond * \ingroup SchedulerControl */ -#define taskENTER_CRITICAL( x ) portENTER_CRITICAL( x ) +#ifdef ESP_PLATFORM +#define taskENTER_CRITICAL( x ) portENTER_CRITICAL( x ) +#else +#define taskENTER_CRITICAL( ) portENTER_CRITICAL( ) +#endif // ESP_PLATFORM #define taskENTER_CRITICAL_FROM_ISR( ) portSET_INTERRUPT_MASK_FROM_ISR() -#define taskENTER_CRITICAL_ISR(mux) portENTER_CRITICAL_ISR(mux) + +#ifdef ESP_PLATFORM +#define taskENTER_CRITICAL_ISR( x ) portENTER_CRITICAL_ISR( x ) +#else +#define taskENTER_CRITICAL_ISR( ) portENTER_CRITICAL_ISR( ) +#endif // ESP_PLATFORM /** + * task. h + * * 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) * so must be used with care! * + * @cond + * \defgroup taskEXIT_CRITICAL taskEXIT_CRITICAL + * @endcond * \ingroup SchedulerControl */ -#define taskEXIT_CRITICAL( x ) portEXIT_CRITICAL( x ) + +#ifdef ESP_PLATFORM +#define taskEXIT_CRITICAL( x ) portEXIT_CRITICAL( x ) +#else +#define taskEXIT_CRITICAL( ) portEXIT_CRITICAL( ) +#endif // ESP_PLATFORM #define taskEXIT_CRITICAL_FROM_ISR( x ) portCLEAR_INTERRUPT_MASK_FROM_ISR( x ) -#define taskEXIT_CRITICAL_ISR(mux) portEXIT_CRITICAL_ISR(mux) +#ifdef ESP_PLATFORM +#define taskEXIT_CRITICAL_ISR( x ) portEXIT_CRITICAL_ISR( x ) +#else +#define taskEXIT_CRITICAL_ISR( ) portEXIT_CRITICAL_ISR( ) +#endif // ESP_PLATFORM /** + * task. h + * * Macro to disable all maskable interrupts. * + * @cond + * \defgroup taskDISABLE_INTERRUPTS taskDISABLE_INTERRUPTS + * @endcond * \ingroup SchedulerControl */ -#define taskDISABLE_INTERRUPTS() portDISABLE_INTERRUPTS() +#define taskDISABLE_INTERRUPTS() portDISABLE_INTERRUPTS() /** + * task. h + * * Macro to enable microcontroller interrupts. * + * @cond + * \defgroup taskENABLE_INTERRUPTS taskENABLE_INTERRUPTS + * @endcond * \ingroup SchedulerControl */ -#define taskENABLE_INTERRUPTS() portENABLE_INTERRUPTS() +#define taskENABLE_INTERRUPTS() portENABLE_INTERRUPTS() /* Definitions returned by xTaskGetSchedulerState(). taskSCHEDULER_SUSPENDED is -0 to generate more optimal code when configASSERT() is defined as the constant -is used in assert() statements. */ -#define taskSCHEDULER_SUSPENDED ( ( BaseType_t ) 0 ) -#define taskSCHEDULER_NOT_STARTED ( ( BaseType_t ) 1 ) -#define taskSCHEDULER_RUNNING ( ( BaseType_t ) 2 ) + * 0 to generate more optimal code when configASSERT() is defined as the constant + * is used in assert() statements. */ +#define taskSCHEDULER_SUSPENDED ( ( BaseType_t ) 0 ) +#define taskSCHEDULER_NOT_STARTED ( ( BaseType_t ) 1 ) +#define taskSCHEDULER_RUNNING ( ( BaseType_t ) 2 ) /*----------------------------------------------------------- @@ -283,13 +331,13 @@ is used in assert() statements. */ * \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); + 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 @@ -301,7 +349,7 @@ is used in assert() statements. */ * second block is used by the task as its stack. If a task is created using * xTaskCreate() then both blocks of memory are automatically dynamically * allocated inside the xTaskCreate() function. (see - * http://www.freertos.org/a00111.html). If a task is created using + * https://www.FreeRTOS.org/a00111.html). If a task is created using * xTaskCreateStatic() then the application writer must provide the required * memory. xTaskCreateStatic() therefore allows a task to be created without * using any dynamic memory allocation. @@ -345,50 +393,52 @@ is used in assert() statements. */ * * Example usage: * @code{c} - * // Task to be created. - * void vTaskCode( void * pvParameters ) - * { + * // 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; + * // 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 ); + * configASSERT( xHandle ); * * // Use the handle to delete the task. - * if( xHandle != NULL ) - * { - * vTaskDelete( xHandle ); - * } - * } + * if( xHandle != NULL ) + * { + * vTaskDelete( xHandle ); + * } + * } * @endcode + * @cond + * \defgroup xTaskCreate xTaskCreate + * @endcond * \ingroup Tasks */ +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) -#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - - 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 ); - } + 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 @@ -439,14 +489,14 @@ is used in assert() statements. */ * \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 ); + 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 */ /** @@ -497,71 +547,80 @@ is used in assert() statements. */ * Example usage: * @code{c} * - * // Dimensions the buffer that the task being created will use as its stack. - * // NOTE: This is the number of bytes the stack will hold, not the number of - * // words as found in vanilla FreeRTOS. - * #define STACK_SIZE 200 + * // Dimensions the buffer that the task being created will use as its stack. + * // NOTE: This is the number of bytes the stack will hold, not the number of + * // words as found in vanilla FreeRTOS. + * #define STACK_SIZE 200 * - * // Structure that will hold the TCB of the task being created. - * StaticTask_t xTaskBuffer; + * // 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 ]; + * // 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 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 ); * - * // 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 bytes, not words. - * ( 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 ); - * } + * 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 bytes, not words. + * ( 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 ) - 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 ); - } + 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 + * @code{c} + * BaseType_t xTaskCreateRestricted( TaskParameters_t *pxTaskDefinition, TaskHandle_t *pxCreatedTask ); + * @endcode + * @endcond + * + * Only available when configSUPPORT_DYNAMIC_ALLOCATION is set to 1. + * * xTaskCreateRestricted() should only be used in systems that include an MPU * implementation. * @@ -572,12 +631,12 @@ is used in assert() statements. */ * See xTaskCreateRestrictedStatic() for a version that does not use any * dynamic memory allocation. * - * param pxTaskDefinition Pointer to a structure that contains a member + * @param pxTaskDefinition Pointer to a structure that contains a member * for each of the normal xTaskCreate() parameters (see the xTaskCreate() API * documentation) plus an optional stack buffer and the memory region * definitions. * - * param pxCreatedTask Used to pass back a handle by which the created task + * @param pxCreatedTask Used to pass back a handle by which the created task * can be referenced. * * return pdPASS if the task was successfully created and added to a ready @@ -588,54 +647,65 @@ is used in assert() statements. */ * // 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 } - * } + * 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 ); + * // 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(); + * // Start the scheduler. + * vTaskStartScheduler(); * - * // Will only get here if there was insufficient memory to create the idle - * // and/or timer task. - * for( ;; ); + * // Will only get here if there was insufficient memory to create the idle + * // and/or timer task. + * for( ;; ); * } * @endcode + * @cond + * \defgroup xTaskCreateRestricted xTaskCreateRestricted + * @endcond * \ingroup Tasks */ -#if( portUSING_MPU_WRAPPERS == 1 ) - BaseType_t xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ); +#if ( portUSING_MPU_WRAPPERS == 1 ) + BaseType_t xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition, + TaskHandle_t * pxCreatedTask ); #endif -/* - * xTaskCreateRestrictedStatic() should only be used in systems that include an - * MPU implementation. +/** + * @cond + * task. h + * @code{c} + * BaseType_t xTaskCreateRestrictedStatic( TaskParameters_t *pxTaskDefinition, TaskHandle_t *pxCreatedTask ); + * @endcode + * @endcond * * Only available when configSUPPORT_STATIC_ALLOCATION is set to 1. * + * xTaskCreateRestrictedStatic() should only be used in systems that include an + * MPU implementation. + * * Internally, within the FreeRTOS implementation, tasks use two blocks of * memory. The first block is used to hold the task's data structures. The * second block is used by the task as its stack. If a task is created using @@ -647,14 +717,14 @@ is used in assert() statements. */ * xTaskCreateRestrictedStatic() therefore allows a memory protected task to be * created without using any dynamic memory allocation. * - * param pxTaskDefinition Pointer to a structure that contains a member + * @param pxTaskDefinition Pointer to a structure that contains a member * for each of the normal xTaskCreate() parameters (see the xTaskCreate() API * documentation) plus an optional stack buffer and the memory region * definitions. If configSUPPORT_STATIC_ALLOCATION is set to 1 the structure * contains an additional member, which is used to point to a variable of type * StaticTask_t - which is then used to hold the task's data structure. * - * param pxCreatedTask Used to pass back a handle by which the created task + * @param pxCreatedTask Used to pass back a handle by which the created task * can be referenced. * * return pdPASS if the task was successfully created and added to a ready @@ -669,62 +739,72 @@ is used in assert() statements. */ * static PRIVILEGED_DATA StaticTask_t xTaskBuffer; * 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 BYTES. - * 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 } - * } - * - * &xTaskBuffer; // Holds the task's data structure. + * 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 BYTES. + * 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 } + * } + * + * &xTaskBuffer; // Holds the task's data structure. * }; * * 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 ); + * // 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(); + * // Start the scheduler. + * vTaskStartScheduler(); * - * // Will only get here if there was insufficient memory to create the idle - * // and/or timer task. - * for( ;; ); + * // Will only get here if there was insufficient memory to create the idle + * // and/or timer task. + * for( ;; ); * } * @endcode + * @cond + * \defgroup xTaskCreateRestrictedStatic xTaskCreateRestrictedStatic + * @endcond * \ingroup Tasks */ -#if( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) - BaseType_t xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ); +#if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) + BaseType_t xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition, + TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION; #endif -/* +/** + * @cond + * task. h + * @code{c} + * void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions ); + * @endcode + * @endcond + * * 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(). * - * param xTask The handle of the task being updated. + * @param xTask The handle of the task being updated. * - * param pxRegions A pointer to an MemoryRegion_t structure that contains the + * @param pxRegions A pointer to an MemoryRegion_t structure that contains the * new memory region definitions. * * Example usage: - * * @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 @@ -732,38 +812,49 @@ is used in assert() statements. */ * // 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 } + * // 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). + * // 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 + * @cond + * \defgroup xTaskCreateRestricted xTaskCreateRestricted + * @endcond * \ingroup Tasks */ -void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions ) PRIVILEGED_FUNCTION; +void vTaskAllocateMPURegions( TaskHandle_t xTask, + const MemoryRegion_t * const pxRegions ) PRIVILEGED_FUNCTION; /** - * 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. + * @cond + * task. h + * @code{c} + * void vTaskDelete( TaskHandle_t xTask ); + * @endcode + * @endcond * * 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 * memory from tasks that have been deleted. It is therefore important that * the idle task is not starved of microcontroller processing time if your @@ -779,17 +870,20 @@ void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const p * * Example usage: * @code{c} - * void vOtherFunction( void ) - * { - * TaskHandle_t xHandle; + * void vOtherFunction( void ) + * { + * TaskHandle_t xHandle; * - * // Create the task, storing the handle. - * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &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 ); - * } + * // Use the handle to delete the task. + * vTaskDelete( xHandle ); + * } * @endcode + * @cond + * \defgroup vTaskDelete vTaskDelete + * @endcond * \ingroup Tasks */ void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION; @@ -799,7 +893,10 @@ void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION; *----------------------------------------------------------*/ /** - * Delay a task for a given number of ticks. + * task. h + * @code{c} + * void vTaskDelay( const TickType_t xTicksToDelay ); + * @endcode * * Delay a task for a given number of ticks. The actual time that the * task remains blocked depends on the tick rate. The constant @@ -809,6 +906,7 @@ void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION; * 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 @@ -816,7 +914,7 @@ void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION; * of controlling the frequency of a periodic task as the path taken through the * code, as well as other task and interrupt activity, will effect the frequency * at which vTaskDelay() gets called and therefore the time at which the task - * next executes. See vTaskDelayUntil() for an alternative API function designed + * next executes. See xTaskDelayUntil() for an alternative API function designed * to facilitate fixed frequency execution. It does this by specifying an * absolute time (rather than a relative time) at which the calling task should * unblock. @@ -826,27 +924,34 @@ void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION; * * Example usage: * @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 ); - * } - * } + * 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 + * + * @cond + * \defgroup vTaskDelay vTaskDelay + * @endcond * \ingroup TaskCtrl */ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION; /** - * Delay a task until a specified time. + * task. h + * @code{c} + * BaseType_t xTaskDelayUntil( TickType_t *pxPreviousWakeTime, const TickType_t xTimeIncrement ); + * @endcode * - * INCLUDE_vTaskDelayUntil must be defined as 1 for this function to be available. + * INCLUDE_xTaskDelayUntil 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 @@ -861,46 +966,73 @@ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION; * each time it executes]. * * Whereas vTaskDelay () specifies a wake time relative to the time at which the function - * is called, vTaskDelayUntil () specifies the absolute (exact) time at which it wishes to + * is called, xTaskDelayUntil () specifies the absolute (exact) time at which it wishes to * unblock. * - * The constant portTICK_PERIOD_MS can be used to calculate real time from the tick - * rate - with the resolution of one tick period. + * The macro pdMS_TO_TICKS() can be used to calculate the number of ticks from a + * time specified in milliseconds with a resolution of one tick period. * * @param pxPreviousWakeTime Pointer to a variable that holds the time at which the * task was last unblocked. The variable must be initialised with the current time * prior to its first use (see the example below). Following this the variable is - * automatically updated within vTaskDelayUntil (). + * automatically updated within xTaskDelayUntil (). * * @param xTimeIncrement The cycle time period. The task will be unblocked at - * time *pxPreviousWakeTime + xTimeIncrement. Calling vTaskDelayUntil with the + * time *pxPreviousWakeTime + xTimeIncrement. Calling xTaskDelayUntil with the * same xTimeIncrement parameter value will cause the task to execute with * a fixed interface period. * + * @return Value which can be used to check whether the task was actually delayed. + * Will be pdTRUE if the task way delayed and pdFALSE otherwise. A task will not + * be delayed if the next expected wake time is in the past. + * * Example usage: * @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. - * } - * } + * // Perform an action every 10 ticks. + * void vTaskFunction( void * pvParameters ) + * { + * TickType_t xLastWakeTime; + * const TickType_t xFrequency = 10; + * BaseType_t xWasDelayed; + * + * // Initialise the xLastWakeTime variable with the current time. + * xLastWakeTime = xTaskGetTickCount (); + * for( ;; ) + * { + * // Wait for the next cycle. + * xWasDelayed = xTaskDelayUntil( &xLastWakeTime, xFrequency ); + * + * // Perform action here. xWasDelayed value can be used to determine + * // whether a deadline was missed if the code here took too long. + * } + * } * @endcode + * @cond + * \defgroup xTaskDelayUntil xTaskDelayUntil + * @endcond * \ingroup TaskCtrl */ -void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION; +BaseType_t xTaskDelayUntil( TickType_t * const pxPreviousWakeTime, + const TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION; + +/* + * vTaskDelayUntil() is the older version of xTaskDelayUntil() and does not + * return a value. + */ +#define vTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ) \ +{ \ + ( void ) xTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ); \ +} + /** + * @cond + * task. h + * @code{c} + * BaseType_t xTaskAbortDelay( TaskHandle_t xTask ); + * @endcode + * @endcond + * * INCLUDE_xTaskAbortDelay must be defined as 1 in FreeRTOSConfig.h for this * function to be available. * @@ -912,22 +1044,36 @@ void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xT * task will leave the Blocked state, and return from whichever function call * placed the task into the Blocked state. * + * There is no 'FromISR' version of this function as an interrupt would need to + * know which object a task was blocked on in order to know which actions to + * take. For example, if the task was blocked on a queue the interrupt handler + * would then need to know if the queue was locked. + * * @param xTask The handle of the task to remove from the Blocked state. * * @return If the task referenced by xTask was not in the Blocked state then * pdFAIL is returned. Otherwise pdPASS is returned. * + * @cond * \defgroup xTaskAbortDelay xTaskAbortDelay + * @endcond * \ingroup TaskCtrl */ BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; /** - * Obtain the priority of any task. + * @cond + * task. h + * @code{c} + * UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask ); + * @endcode + * @endcond * * 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. * @@ -935,9 +1081,9 @@ BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; * * Example usage: * @code{c} - * void vAFunction( void ) - * { - * TaskHandle_t xHandle; + * void vAFunction( void ) + * { + * TaskHandle_t xHandle; * * // Create a task, storing the handle. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle ); @@ -961,23 +1107,39 @@ BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; * } * } * @endcode + * @cond + * \defgroup uxTaskPriorityGet uxTaskPriorityGet + * @endcond * \ingroup TaskCtrl */ UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION; /** + * @cond + * task. h + * @code{c} + * UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask ); + * @endcode + * @endcond + * * A version of uxTaskPriorityGet() that can be used from an ISR. */ UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION; /** - * Obtain the state of any task. - * - * States are encoded by the eTaskState enumerated type. + * @cond + * task. h + * @code{c} + * eTaskState eTaskGetState( TaskHandle_t xTask ); + * @endcode + * @endcond * * 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 @@ -987,11 +1149,17 @@ UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask ) PRIVILEGED_FUNC eTaskState eTaskGetState( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; /** - * Populates a TaskStatus_t structure with information about a task. + * @cond + * task. h + * @code{c} + * void vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState ); + * @endcode + * @endcond * * configUSE_TRACE_FACILITY must be defined as 1 for this function to be * available. See the configuration section for more information. * + * Populates a TaskStatus_t structure with information about a task. * * @param xTask Handle of the task being queried. If xTask is NULL then * information will be returned about the calling task. @@ -1022,29 +1190,42 @@ eTaskState eTaskGetState( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; * TaskHandle_t xHandle; * TaskStatus_t xTaskDetails; * - * // Obtain the handle of a task from its name. - * xHandle = xTaskGetHandle( "Task_Name" ); + * // Obtain the handle of a task from its name. + * xHandle = xTaskGetHandle( "Task_Name" ); * - * // Check the handle is not NULL. - * configASSERT( xHandle ); + * // Check the handle is not NULL. + * configASSERT( xHandle ); * - * // Use the handle to obtain further information about the task. - * vTaskGetInfo( xHandle, - * &xTaskDetails, - * pdTRUE, // Include the high water mark in xTaskDetails. - * eInvalid ); // Include the task state in xTaskDetails. + * // Use the handle to obtain further information about the task. + * vTaskGetInfo( xHandle, + * &xTaskDetails, + * pdTRUE, // Include the high water mark in xTaskDetails. + * eInvalid ); // Include the task state in xTaskDetails. * } * @endcode + * @cond + * \defgroup vTaskGetInfo vTaskGetInfo + * @endcond * \ingroup TaskCtrl */ -void vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState ) PRIVILEGED_FUNCTION; +void vTaskGetInfo( TaskHandle_t xTask, + TaskStatus_t * pxTaskStatus, + BaseType_t xGetFreeStackSpace, + eTaskState eState ) PRIVILEGED_FUNCTION; /** - * Set the priority of any task. + * @cond + * task. h + * @code{c} + * void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority ); + * @endcode + * @endcond * * 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. * @@ -1055,9 +1236,9 @@ void vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xG * * Example usage: * @code{c} - * void vAFunction( void ) - * { - * TaskHandle_t xHandle; + * void vAFunction( void ) + * { + * TaskHandle_t xHandle; * * // Create a task, storing the handle. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle ); @@ -1071,14 +1252,23 @@ void vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xG * * // Use a NULL handle to raise our priority to the same value. * vTaskPrioritySet( NULL, tskIDLE_PRIORITY + 1 ); - * } + * } * @endcode + * @cond + * \defgroup vTaskPrioritySet vTaskPrioritySet + * @endcond * \ingroup TaskCtrl */ -void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority ) PRIVILEGED_FUNCTION; +void vTaskPrioritySet( TaskHandle_t xTask, + UBaseType_t uxNewPriority ) PRIVILEGED_FUNCTION; /** - * Suspend a task. + * @cond + * task. h + * @code{c} + * void vTaskSuspend( TaskHandle_t xTaskToSuspend ); + * @endcode + * @endcond * * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available. * See the configuration section for more information. @@ -1095,9 +1285,9 @@ void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority ) PRIVILEGE * * Example usage: * @code{c} - * void vAFunction( void ) - * { - * TaskHandle_t xHandle; + * void vAFunction( void ) + * { + * TaskHandle_t xHandle; * * // Create a task, storing the handle. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle ); @@ -1120,18 +1310,28 @@ void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority ) PRIVILEGE * * // We cannot get here unless another task calls vTaskResume * // with our handle as the parameter. - * } + * } * @endcode + * @cond + * \defgroup vTaskSuspend vTaskSuspend + * @endcond * \ingroup TaskCtrl */ void vTaskSuspend( TaskHandle_t xTaskToSuspend ) PRIVILEGED_FUNCTION; /** - * Resumes a suspended task. + * @cond + * task. h + * @code{c} + * void vTaskResume( TaskHandle_t xTaskToResume ); + * @endcode + * @endcond * * 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 (). @@ -1140,9 +1340,9 @@ void vTaskSuspend( TaskHandle_t xTaskToSuspend ) PRIVILEGED_FUNCTION; * * Example usage: * @code{c} - * void vAFunction( void ) - * { - * TaskHandle_t xHandle; + * void vAFunction( void ) + * { + * TaskHandle_t xHandle; * * // Create a task, storing the handle. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle ); @@ -1165,18 +1365,28 @@ void vTaskSuspend( TaskHandle_t xTaskToSuspend ) PRIVILEGED_FUNCTION; * * // The created task will once again get microcontroller processing * // time in accordance with its priority within the system. - * } + * } * @endcode + * @cond + * \defgroup vTaskResume vTaskResume + * @endcond * \ingroup TaskCtrl */ void vTaskResume( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION; /** - * An implementation of vTaskResume() that can be called from within an ISR. + * @cond + * task. h + * @code{c} + * void xTaskResumeFromISR( TaskHandle_t xTaskToResume ); + * @endcode + * @endcond * * 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 (). @@ -1192,6 +1402,9 @@ 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. * + * @cond + * \defgroup vTaskResumeFromISR vTaskResumeFromISR + * @endcond * \ingroup TaskCtrl */ BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION; @@ -1201,21 +1414,27 @@ BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION; *----------------------------------------------------------*/ /** @cond */ /** - * Starts the real time kernel tick processing. + * @cond + * task. h + * @code{c} + * void vTaskStartScheduler( void ); + * @endcode + * @endcond * + * Starts the real time kernel tick processing. After calling the kernel + * has control over which tasks are executed and when. + * NOTE: In ESP-IDF the scheduler is started automatically during * application startup, vTaskStartScheduler() should not be called from * ESP-IDF applications. * - * 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: * @code{c} - * void vAFunction( void ) - * { + * void vAFunction( void ) + * { * // Create at least one task before starting the kernel. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL ); * @@ -1223,15 +1442,23 @@ BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION; * vTaskStartScheduler (); * * // Will not get here unless a task calls vTaskEndScheduler () - * } + * } * @endcode * + * @cond + * \defgroup vTaskStartScheduler vTaskStartScheduler + * @endcond * \ingroup SchedulerControl */ void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION; /** - * Stops the real time kernel tick. + * @cond + * task. h + * @code{c} + * void vTaskEndScheduler( void ); + * @endcode + * @endcond * * NOTE: At the time of writing only the x86 real mode port, which runs on a PC * in place of DOS, implements this function. @@ -1254,8 +1481,8 @@ void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION; * * Example usage: * @code{c} - * void vTaskCode( void * pvParameters ) - * { + * void vTaskCode( void * pvParameters ) + * { * for( ;; ) * { * // Task code goes here. @@ -1264,10 +1491,10 @@ void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION; * // so call ... * vTaskEndScheduler (); * } - * } + * } * - * void vAFunction( void ) - * { + * void vAFunction( void ) + * { * // Create at least one task before starting the kernel. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL ); * @@ -1277,8 +1504,12 @@ void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION; * // Will only get here when the vTaskCode () task has called * // vTaskEndScheduler (). When we get here we are back to single task * // execution. - * } + * } * @endcode + * + * @cond + * \defgroup vTaskEndScheduler vTaskEndScheduler + * @endcond * \ingroup SchedulerControl */ void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION; @@ -1286,9 +1517,15 @@ void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION; /** @endcond */ /** - * Suspends the scheduler without disabling interrupts. + * @cond + * task. h + * @code{c} + * void vTaskSuspendAll( void ); + * @endcode + * @endcond * - * Context switches will not occur while the scheduler is suspended. + * Suspends the scheduler without disabling interrupts. 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 @@ -1300,8 +1537,8 @@ void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION; * * Example usage: * @code{c} - * void vTask1( void * pvParameters ) - * { + * void vTask1( void * pvParameters ) + * { * for( ;; ) * { * // Task code goes here. @@ -1327,13 +1564,23 @@ void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION; * // The operation is complete. Restart the kernel. * xTaskResumeAll (); * } - * } + * } * @endcode + * @cond + * \defgroup vTaskSuspendAll vTaskSuspendAll + * @endcond * \ingroup SchedulerControl */ void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION; /** + * @cond + * task. h + * @code{c} + * BaseType_t xTaskResumeAll( void ); + * @endcode + * @endcond + * * Resumes scheduler activity after it was suspended by a call to * vTaskSuspendAll(). * @@ -1341,12 +1588,12 @@ void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION; * that were previously suspended by a call to vTaskSuspend(). * * @return If resuming the scheduler caused a context switch then pdTRUE is - * returned, otherwise pdFALSE is returned. + * returned, otherwise pdFALSE is returned. * * Example usage: * @code{c} - * void vTask1( void * pvParameters ) - * { + * void vTask1( void * pvParameters ) + * { * for( ;; ) * { * // Task code goes here. @@ -1377,8 +1624,11 @@ void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION; * taskYIELD (); * } * } - * } + * } * @endcode + * @cond + * \defgroup xTaskResumeAll xTaskResumeAll + * @endcond * \ingroup SchedulerControl */ BaseType_t xTaskResumeAll( void ) PRIVILEGED_FUNCTION; @@ -1388,16 +1638,29 @@ BaseType_t xTaskResumeAll( void ) PRIVILEGED_FUNCTION; *----------------------------------------------------------*/ /** - * Get tick count + * @cond + * task. h + * @code{c} + * TickType_t xTaskGetTickCount( void ); + * @endcode + * @endcond * * @return The count of ticks since vTaskStartScheduler was called. * + * @cond + * \defgroup xTaskGetTickCount xTaskGetTickCount + * @endcond * \ingroup TaskUtils */ TickType_t xTaskGetTickCount( void ) PRIVILEGED_FUNCTION; /** - * Get tick count from ISR + * @cond + * task. h + * @code{c} + * TickType_t xTaskGetTickCountFromISR( void ); + * @endcode + * @endcond * * @return The count of ticks since vTaskStartScheduler was called. * @@ -1406,44 +1669,73 @@ TickType_t xTaskGetTickCount( void ) PRIVILEGED_FUNCTION; * microcontroller being used or interrupt nesting is either not supported or * not being used. * + * @cond + * \defgroup xTaskGetTickCountFromISR xTaskGetTickCountFromISR + * @endcond * \ingroup TaskUtils */ TickType_t xTaskGetTickCountFromISR( void ) PRIVILEGED_FUNCTION; /** - * Get current number of tasks + * @cond + * task. h + * @code{c} + * uint16_t uxTaskGetNumberOfTasks( void ); + * @endcode + * @endcond * * @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. * + * @cond + * \defgroup uxTaskGetNumberOfTasks uxTaskGetNumberOfTasks + * @endcond * \ingroup TaskUtils */ UBaseType_t uxTaskGetNumberOfTasks( void ) PRIVILEGED_FUNCTION; /** - * Get task name + * @cond + * task. h + * @code{c} + * char *pcTaskGetName( TaskHandle_t xTaskToQuery ); + * @endcode + * @endcond * * @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. * + * @cond + * \defgroup pcTaskGetName pcTaskGetName + * @endcond * \ingroup TaskUtils */ -char *pcTaskGetName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ +char * pcTaskGetName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ /** - * @note This function takes a relatively long time to complete and should be + * @cond + * task. h + * @code{c} + * TaskHandle_t xTaskGetHandle( const char *pcNameToQuery ); + * @endcode + * @endcond + * + * NOTE: This function takes a relatively long time to complete and should be * used sparingly. * * @return The handle of the task that has the human readable name pcNameToQuery. * NULL is returned if no matching name is found. INCLUDE_xTaskGetHandle * must be set to 1 in FreeRTOSConfig.h for pcTaskGetHandle() to be available. * + * @cond + * \defgroup pcTaskGetHandle pcTaskGetHandle + * @endcond * \ingroup TaskUtils */ -TaskHandle_t xTaskGetHandle( const char *pcNameToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ +TaskHandle_t xTaskGetHandle( const char * pcNameToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ /** * Returns the high water mark of the stack associated with xTask. @@ -1513,109 +1805,195 @@ configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) PRIVIL uint8_t* pxTaskGetStackStart( TaskHandle_t xTask) PRIVILEGED_FUNCTION; /* When using trace macros it is sometimes necessary to include task.h before -FreeRTOS.h. When this is done TaskHookFunction_t will not yet have been defined, -so the following two prototypes will cause a compilation error. This can be -fixed by simply guarding against the inclusion of these two prototypes unless -they are explicitly required by the configUSE_APPLICATION_TASK_TAG configuration -constant. */ + * FreeRTOS.h. When this is done TaskHookFunction_t will not yet have been defined, + * so the following two prototypes will cause a compilation error. This can be + * fixed by simply guarding against the inclusion of these two prototypes unless + * they are explicitly required by the configUSE_APPLICATION_TASK_TAG configuration + * constant. */ #ifdef configUSE_APPLICATION_TASK_TAG - #if configUSE_APPLICATION_TASK_TAG == 1 - /** - * Sets pxHookFunction to be the task hook function used by the task xTask. - * @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; - - /** - * - * Returns the pxHookFunction value assigned to the task xTask. Do not - * call from an interrupt service routine - call - * xTaskGetApplicationTaskTagFromISR() instead. - */ - TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; - - /** - * - * Returns the pxHookFunction value assigned to the task xTask. Can - * be called from an interrupt service routine. - */ - TaskHookFunction_t xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; - #endif /* configUSE_APPLICATION_TASK_TAG ==1 */ + #if configUSE_APPLICATION_TASK_TAG == 1 +/** + * @cond + * task.h + * @code{c} + * void vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction ); + * @endcode + * @endcond + * + * Sets pxHookFunction to be the task hook function used by the task xTask. + * @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; + +/** + * @cond + * task.h + * @code{c} + * void xTaskGetApplicationTaskTag( TaskHandle_t xTask ); + * @endcode + * @endcond + * + * Returns the pxHookFunction value assigned to the task xTask. Do not + * call from an interrupt service routine - call + * xTaskGetApplicationTaskTagFromISR() instead. + */ + TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; + +/** + * @cond + * task.h + * @code{c} + * void xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask ); + * @endcode + * @endcond + * + * Returns the pxHookFunction value assigned to the task xTask. Can + * be called from an interrupt service routine. + */ + TaskHookFunction_t xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; + #endif /* configUSE_APPLICATION_TASK_TAG ==1 */ #endif /* ifdef configUSE_APPLICATION_TASK_TAG */ -#if( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) - - /** - * 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 ) - - /** - * 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 +#if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) + + /** + * 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 ) + + /** + * 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 +#if ( configCHECK_FOR_STACK_OVERFLOW > 0 ) + + /** + * @cond + * task.h + * @code{c} + * void vApplicationStackOverflowHook( TaskHandle_t xTask char *pcTaskName); + * @endcode + * @endcond + * The application stack overflow hook is called when a stack overflow is detected for a task. + * + * Details on stack overflow detection can be found here: https://www.FreeRTOS.org/Stacks-and-stack-overflow-checking.html + * + * @param xTask the task that just exceeded its stack boundaries. + * @param pcTaskName A character string containing the name of the offending task. + */ + void vApplicationStackOverflowHook( TaskHandle_t xTask, + char * pcTaskName ); + +#endif + +#if ( configUSE_TICK_HOOK > 0 ) + /** + * @cond + * task.h + * @code{c} + * void vApplicationTickHook( void ); + * @endcode + * @endcond + * + * This hook function is called in the system tick handler after any OS work is completed. + */ + void vApplicationTickHook( void ); /*lint !e526 Symbol not defined as it is an application callback. */ + +#endif + +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + /** + * @cond + * task.h + * @code{c} + * void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ) + * @endcode + * @endcond + * This function is used to provide a statically allocated block of memory to FreeRTOS to hold the Idle Task TCB. This function is required when + * configSUPPORT_STATIC_ALLOCATION is set. For more information see this URI: https://www.FreeRTOS.org/a00110.html#configSUPPORT_STATIC_ALLOCATION + * + * @param ppxIdleTaskTCBBuffer A handle to a statically allocated TCB buffer + * @param ppxIdleTaskStackBuffer A handle to a statically allocated Stack buffer for thie idle task + * @param pulIdleTaskStackSize A pointer to the number of elements that will fit in the allocated stack buffer + */ + void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, + StackType_t ** ppxIdleTaskStackBuffer, + uint32_t * pulIdleTaskStackSize ); /*lint !e526 Symbol not defined as it is an application callback. */ +#endif + /** - * Calls the hook function associated with xTask. Passing xTask as NULL has + * @cond + * task.h + * @code{c} + * BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter ); + * @endcode + * @endcond + * + * Calls the hook function associated with xTask. Passing xTask as NULL has * the effect of calling the Running tasks (the calling task) hook function. * * @param xTask Handle of the task to call the hook for. @@ -1623,7 +2001,8 @@ constant. */ * 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; +BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, + void * pvParameter ) PRIVILEGED_FUNCTION; /** * xTaskGetIdleTaskHandle() is only available if @@ -1644,7 +2023,7 @@ TaskHandle_t xTaskGetIdleTaskHandle( void ) PRIVILEGED_FUNCTION; * 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. @@ -1660,7 +2039,7 @@ TaskHandle_t xTaskGetIdleTaskHandle( void ) PRIVILEGED_FUNCTION; * @param pulTotalRunTime If configGENERATE_RUN_TIME_STATS is set to 1 in * FreeRTOSConfig.h then *pulTotalRunTime is set by uxTaskGetSystemState() to the * total run time (as defined by the run time stats clock, see - * http://www.freertos.org/rtos-run-time-stats.html) since the target booted. + * https://www.FreeRTOS.org/rtos-run-time-stats.html) since the target booted. * pulTotalRunTime can be set to NULL to omit the total run time information. * * @return The number of TaskStatus_t structures that were populated by @@ -1670,68 +2049,70 @@ TaskHandle_t xTaskGetIdleTaskHandle( void ) PRIVILEGED_FUNCTION; * * Example usage: * @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; + * // 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; + * // 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(); + * // 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 ) ); + * // 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 ); + * if( pxTaskStatusArray != NULL ) + * { + * // Generate raw status information about each task. + * uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, &ulTotalRunTime ); * - * // For percentage calculations. - * ulTotalRunTime /= 100UL; + * // 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++ ) + * // Avoid divide by zero errors. + * if( ulTotalRunTime > 0 ) * { - * // 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 ) + * // For each populated position in the pxTaskStatusArray array, + * // format the raw data as human readable ASCII data + * for( x = 0; x < uxArraySize; x++ ) * { - * sprintf( pcWriteBuffer, "%s\t\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage ); + * // 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 ); * } - * 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 ); + * // The array is no longer needed, free the memory it consumes. + * vPortFree( pxTaskStatusArray ); + * } * } - * } - * @endcode + * @endcode */ -UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const UBaseType_t uxArraySize, uint32_t * const pulTotalRunTime ) PRIVILEGED_FUNCTION; +UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, + const UBaseType_t uxArraySize, + uint32_t * const pulTotalRunTime ) PRIVILEGED_FUNCTION; /** * List all the current tasks. @@ -1740,7 +2121,7 @@ UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const * both be defined as 1 for this function to be available. See the * configuration section of the FreeRTOS.org website for more information. * - * @note This function will disable interrupts for its duration. It is + * NOTE 1: 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 @@ -1749,7 +2130,9 @@ UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const * Tasks are reported as blocked ('B'), ready ('R'), deleted ('D') or * suspended ('S'). * - * @note This function is provided for convenience only, and is used by many of the + * PLEASE 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 @@ -1772,9 +2155,12 @@ UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const * enough to contain the generated report. Approximately 40 bytes per * task should be sufficient. * + * @cond + * \defgroup vTaskList vTaskList + * @endcond * \ingroup TaskUtils */ -void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ +void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ /** * Get the state of running tasks as a string @@ -1787,7 +2173,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 This function will disable interrupts for its duration. It is + * NOTE 1: 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 @@ -1798,7 +2184,9 @@ 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 This function is provided for convenience only, and is used by many of the + * NOTE 2: + * + * 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 @@ -1822,42 +2210,69 @@ void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unquali * contain the generated report. Approximately 40 bytes per task should * be sufficient. * + * @cond + * \defgroup vTaskGetRunTimeStats vTaskGetRunTimeStats + * @endcond + * \ingroup TaskUtils + */ +void vTaskGetRunTimeStats( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + +/** + * @cond + * task. h + * @code + * uint32_t ulTaskGetIdleRunTimeCounter( void ); + * @endcode + * @endcond + * + * configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS + * must both be defined as 1 for this function to be available. The application + * must also then provide definitions for + * portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE() + * to configure a peripheral timer/counter and return the timers current count + * value respectively. The counter should be at least 10 times the frequency of + * the tick count. + * + * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total + * accumulated execution time being stored for each task. The resolution + * of the accumulated time value depends on the frequency of the timer + * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro. + * While uxTaskGetSystemState() and vTaskGetRunTimeStats() writes the total + * execution time of each task into a buffer, ulTaskGetIdleRunTimeCounter() + * returns the total execution time of just the idle task. + * + * @return The total run time of the idle task. This is the amount of time the + * idle task has actually been executing. The unit of time is dependent on the + * frequency configured using the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and + * portGET_RUN_TIME_COUNTER_VALUE() macros. + * + * @cond + * \defgroup ulTaskGetIdleRunTimeCounter ulTaskGetIdleRunTimeCounter + * @endcond * \ingroup TaskUtils */ -void vTaskGetRunTimeStats( char *pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ - -/** -* configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS -* must both be defined as 1 for this function to be available. The application -* must also then provide definitions for -* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE() -* to configure a peripheral timer/counter and return the timers current count -* value respectively. The counter should be at least 10 times the frequency of -* the tick count. -* -* Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total -* accumulated execution time being stored for each task. The resolution -* of the accumulated time value depends on the frequency of the timer -* configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro. -* While uxTaskGetSystemState() and vTaskGetRunTimeStats() writes the total -* execution time of each task into a buffer, ulTaskGetIdleRunTimeCounter() -* returns the total execution time of just the idle task. -* -* @return The total run time of the idle task. This is the amount of time the -* idle task has actually been executing. The unit of time is dependent on the -* frequency configured using the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and -* portGET_RUN_TIME_COUNTER_VALUE() macros. -* -* \ingroup TaskUtils -*/ uint32_t ulTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION; /** - * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this - * function to be available. + * task. h + * @code{c} + * BaseType_t xTaskNotifyIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction ); + * BaseType_t xTaskNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction ); + * @endcode * - * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private - * "notification value", which is a 32-bit unsigned integer (uint32_t). + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * + * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these + * functions to be available. + * + * Sends a direct to task notification to a task, with an optional value and + * action. + * + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. * * Events can be sent to a task using an intermediary object. Examples of such * objects are queues, semaphores, mutexes and event groups. Task notifications @@ -1865,28 +2280,46 @@ uint32_t ulTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION; * an intermediary object. * * A notification sent to a task can optionally perform an action, such as - * update, overwrite or increment the task's notification value. In that way - * task notifications can be used to send data to a task, or be used as light - * weight and fast binary or counting semaphores. + * update, overwrite or increment one of the task's notification values. In + * that way task notifications can be used to send data to a task, or be used as + * light weight and fast binary or counting semaphores. * - * A notification sent to a task will remain pending until it is cleared by the - * task calling xTaskNotifyWait() or ulTaskNotifyTake(). If the task was - * already in the Blocked state to wait for a notification when the notification - * arrives then the task will automatically be removed from the Blocked state - * (unblocked) and the notification cleared. - * - * A task can use xTaskNotifyWait() to [optionally] block to wait for a - * notification to be pending, or ulTaskNotifyTake() to [optionally] block - * to wait for its notification value to have a non-zero value. The task does + * A task can use xTaskNotifyWaitIndexed() to [optionally] block to wait for a + * notification to be pending, or ulTaskNotifyTakeIndexed() to [optionally] block + * to wait for a notification value to have a non-zero value. The task does * not consume any CPU time while it is in the Blocked state. * - * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * A notification sent to a task will remain pending until it is cleared by the + * task calling xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() (or their + * un-indexed equivalents). If the task was already in the Blocked state to + * wait for a notification when the notification arrives then the task will + * automatically be removed from the Blocked state (unblocked) and the + * notification cleared. + * + * **NOTE** Each notification within the array operates independently - a task + * can only block on one notification within the array at a time and will not be + * unblocked by a notification sent to any other array index. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. xTaskNotify() is the original API function, and remains backward + * compatible by always operating on the notification value at index 0 in the + * array. Calling xTaskNotify() is equivalent to calling xTaskNotifyIndexed() + * with the uxIndexToNotify parameter set to 0. * * @param xTaskToNotify The handle of the task being notified. The handle to a * task can be returned from the xTaskCreate() API function used to create the * task, and the handle of the currently running task can be obtained by calling * xTaskGetCurrentTaskHandle(). * + * @param uxIndexToNotify The index within the target task's array of + * notification values to which the notification is to be sent. uxIndexToNotify + * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotify() does + * not have this parameter and always sends notifications to index 0. + * * @param ulValue Data that can be sent with the notification. How the data is * used depends on the value of the eAction parameter. * @@ -1894,54 +2327,100 @@ uint32_t ulTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION; * 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. + * The target notification value is bitwise ORed with ulValue. + * xTaskNotifyIndexed() 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. + * The target notification value is incremented. ulValue is not used and + * xTaskNotifyIndexed() 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. + * The target notification value is set to the value of ulValue, even if the + * task being notified had not yet processed the previous notification at the + * same array index (the task already had a notification pending at that index). + * xTaskNotifyIndexed() 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. + * If the task being notified did not already have a notification pending at the + * same array index then the target notification value is set to ulValue and + * xTaskNotifyIndexed() will return pdPASS. If the task being notified already + * had a notification pending at the same array index 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. + * The task receives a notification at the specified array index without the + * notification value at that index being updated. ulValue is not used and + * xTaskNotifyIndexed() always returns pdPASS in this case. * - * @param pulPreviousNotificationValue Can be used to pass out the subject - * task's notification value before any bits are modified by the notify - * function. + * pulPreviousNotificationValue - + * Can be used to pass out the subject task's notification value before any + * bits are modified by the notify function. * * @return Dependent on the value of eAction. See the description of the * eAction parameter. * + * \defgroup xTaskNotifyIndexed xTaskNotifyIndexed * \ingroup TaskNotifications */ -BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue ) PRIVILEGED_FUNCTION; -#define xTaskNotify( xTaskToNotify, ulValue, eAction ) xTaskGenericNotify( ( xTaskToNotify ), ( ulValue ), ( eAction ), NULL ) -#define xTaskNotifyAndQuery( xTaskToNotify, ulValue, eAction, pulPreviousNotifyValue ) xTaskGenericNotify( ( xTaskToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) ) +BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, + UBaseType_t uxIndexToNotify, + uint32_t ulValue, + eNotifyAction eAction, + uint32_t * pulPreviousNotificationValue ) PRIVILEGED_FUNCTION; +#define xTaskNotify( xTaskToNotify, ulValue, eAction ) \ + xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), NULL ) +#define xTaskNotifyIndexed( xTaskToNotify, uxIndexToNotify, ulValue, eAction ) \ + xTaskGenericNotify( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), NULL ) /** - * Send task notification from an ISR. + * task. h + * @code{c} + * BaseType_t xTaskNotifyAndQueryIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotifyValue ); + * BaseType_t xTaskNotifyAndQuery( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotifyValue ); + * @endcode * - * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this - * function to be available. + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. * - * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private - * "notification value", which is a 32-bit unsigned integer (uint32_t). + * xTaskNotifyAndQueryIndexed() performs the same operation as + * xTaskNotifyIndexed() with the addition that it also returns the subject + * task's prior notification value (the notification value at the time the + * function is called rather than when the function returns) in the additional + * pulPreviousNotifyValue parameter. * - * A version of xTaskNotify() that can be used from an interrupt service routine - * (ISR). + * xTaskNotifyAndQuery() performs the same operation as xTaskNotify() with the + * addition that it also returns the subject task's prior notification value + * (the notification value as it was at the time the function is called, rather + * than when the function returns) in the additional pulPreviousNotifyValue + * parameter. + * + * \defgroup xTaskNotifyAndQueryIndexed xTaskNotifyAndQueryIndexed + * \ingroup TaskNotifications + */ +#define xTaskNotifyAndQuery( xTaskToNotify, ulValue, eAction, pulPreviousNotifyValue ) \ + xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) ) +#define xTaskNotifyAndQueryIndexed( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pulPreviousNotifyValue ) \ + xTaskGenericNotify( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) ) + +/** + * task. h + * @code{c} + * BaseType_t xTaskNotifyIndexedFromISR( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken ); + * BaseType_t xTaskNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * + * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these + * functions to be available. + * + * A version of xTaskNotifyIndexed() that can be used from an interrupt service + * routine (ISR). + * + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. * * Events can be sent to a task using an intermediary object. Examples of such * objects are queues, semaphores, mutexes and event groups. Task notifications @@ -1949,22 +2428,40 @@ BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNo * an intermediary object. * * A notification sent to a task can optionally perform an action, such as - * update, overwrite or increment the task's notification value. In that way - * task notifications can be used to send data to a task, or be used as light - * weight and fast binary or counting semaphores. + * update, overwrite or increment one of the task's notification values. In + * that way task notifications can be used to send data to a task, or be used as + * light weight and fast binary or counting semaphores. * - * A notification sent to a task will remain pending until it is cleared by the - * task calling xTaskNotifyWait() or ulTaskNotifyTake(). If the task was - * already in the Blocked state to wait for a notification when the notification - * arrives then the task will automatically be removed from the Blocked state - * (unblocked) and the notification cleared. - * - * A task can use xTaskNotifyWait() to [optionally] block to wait for a - * notification to be pending, or ulTaskNotifyTake() to [optionally] block - * to wait for its notification value to have a non-zero value. The task does + * A task can use xTaskNotifyWaitIndexed() to [optionally] block to wait for a + * notification to be pending, or ulTaskNotifyTakeIndexed() to [optionally] block + * to wait for a notification value to have a non-zero value. The task does * not consume any CPU time while it is in the Blocked state. * - * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * A notification sent to a task will remain pending until it is cleared by the + * task calling xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() (or their + * un-indexed equivalents). If the task was already in the Blocked state to + * wait for a notification when the notification arrives then the task will + * automatically be removed from the Blocked state (unblocked) and the + * notification cleared. + * + * **NOTE** Each notification within the array operates independently - a task + * can only block on one notification within the array at a time and will not be + * unblocked by a notification sent to any other array index. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. xTaskNotifyFromISR() is the original API function, and remains + * backward compatible by always operating on the notification value at index 0 + * within the array. Calling xTaskNotifyFromISR() is equivalent to calling + * xTaskNotifyIndexedFromISR() with the uxIndexToNotify parameter set to 0. + * + * @param uxIndexToNotify The index within the target task's array of + * notification values to which the notification is to be sent. uxIndexToNotify + * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyFromISR() + * does not have this parameter and always sends notifications to index 0. * * @param xTaskToNotify The handle of the task being notified. The handle to a * task can be returned from the xTaskCreate() API function used to create the @@ -1978,7 +2475,7 @@ BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNo * value, if at all. Valid values for eAction are as follows: * * eSetBits - - * The task's notification value is bitwise ORed with ulValue. xTaskNofify() + * The task's notification value is bitwise ORed with ulValue. xTaskNotify() * always returns pdPASS in this case. * * eIncrement - @@ -2002,9 +2499,6 @@ BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNo * updated. ulValue is not used and xTaskNotify() always returns pdPASS in * this case. * - * @param pulPreviousNotificationValue Can be used to pass out the subject task's - * notification value before any bits are modified by the notify function. - * * @param pxHigherPriorityTaskWoken xTaskNotifyFromISR() will set * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the * task to which the notification was sent to leave the Blocked state, and the @@ -2017,20 +2511,70 @@ BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNo * @return Dependent on the value of eAction. See the description of the * eAction parameter. * + * \defgroup xTaskNotifyIndexedFromISR xTaskNotifyIndexedFromISR + * \ingroup TaskNotifications + */ +BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, + UBaseType_t uxIndexToNotify, + uint32_t ulValue, + eNotifyAction eAction, + uint32_t * pulPreviousNotificationValue, + BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; +#define xTaskNotifyFromISR( xTaskToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) \ + xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) ) +#define xTaskNotifyIndexedFromISR( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) \ + xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) ) + +/** + * task. h + * @code{c} + * BaseType_t xTaskNotifyAndQueryIndexedFromISR( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken ); + * BaseType_t xTaskNotifyAndQueryFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * + * xTaskNotifyAndQueryIndexedFromISR() performs the same operation as + * xTaskNotifyIndexedFromISR() with the addition that it also returns the + * subject task's prior notification value (the notification value at the time + * the function is called rather than at the time the function returns) in the + * additional pulPreviousNotifyValue parameter. + * + * xTaskNotifyAndQueryFromISR() performs the same operation as + * xTaskNotifyFromISR() with the addition that it also returns the subject + * task's prior notification value (the notification value at the time the + * function is called rather than at the time the function returns) in the + * additional pulPreviousNotifyValue parameter. + * + * \defgroup xTaskNotifyAndQueryIndexedFromISR xTaskNotifyAndQueryIndexedFromISR * \ingroup TaskNotifications */ -BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; -#define xTaskNotifyFromISR( xTaskToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) ) -#define xTaskNotifyAndQueryFromISR( xTaskToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) ) +#define xTaskNotifyAndQueryIndexedFromISR( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) \ + xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) ) +#define xTaskNotifyAndQueryFromISR( xTaskToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) \ + xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) ) /** - * Wait for task notification + * task. h + * @code{c} + * BaseType_t xTaskNotifyWaitIndexed( UBaseType_t uxIndexToWaitOn, uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ); + * + * BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ); + * @endcode + * + * Waits for a direct to task notification to be pending at a given index within + * an array of direct to task notifications. + * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. * * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this * function to be available. * - * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private - * "notification value", which is a 32-bit unsigned integer (uint32_t). + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. * * Events can be sent to a task using an intermediary object. Examples of such * objects are queues, semaphores, mutexes and event groups. Task notifications @@ -2038,22 +2582,41 @@ BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulVal * an intermediary object. * * A notification sent to a task can optionally perform an action, such as - * update, overwrite or increment the task's notification value. In that way - * task notifications can be used to send data to a task, or be used as light - * weight and fast binary or counting semaphores. + * update, overwrite or increment one of the task's notification values. In + * that way task notifications can be used to send data to a task, or be used as + * light weight and fast binary or counting semaphores. * * A notification sent to a task will remain pending until it is cleared by the - * task calling xTaskNotifyWait() or ulTaskNotifyTake(). If the task was - * already in the Blocked state to wait for a notification when the notification - * arrives then the task will automatically be removed from the Blocked state - * (unblocked) and the notification cleared. - * - * A task can use xTaskNotifyWait() to [optionally] block to wait for a - * notification to be pending, or ulTaskNotifyTake() to [optionally] block - * to wait for its notification value to have a non-zero value. The task does + * task calling xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() (or their + * un-indexed equivalents). If the task was already in the Blocked state to + * wait for a notification when the notification arrives then the task will + * automatically be removed from the Blocked state (unblocked) and the + * notification cleared. + * + * A task can use xTaskNotifyWaitIndexed() to [optionally] block to wait for a + * notification to be pending, or ulTaskNotifyTakeIndexed() to [optionally] block + * to wait for a notification value to have a non-zero value. The task does * not consume any CPU time while it is in the Blocked state. * - * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * **NOTE** Each notification within the array operates independently - a task + * can only block on one notification within the array at a time and will not be + * unblocked by a notification sent to any other array index. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. xTaskNotifyWait() is the original API function, and remains backward + * compatible by always operating on the notification value at index 0 in the + * array. Calling xTaskNotifyWait() is equivalent to calling + * xTaskNotifyWaitIndexed() with the uxIndexToWaitOn parameter set to 0. + * + * @param uxIndexToWaitOn The index within the calling task's array of + * notification values on which the calling task will wait for a notification to + * be received. uxIndexToWaitOn must be less than + * configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyWait() does + * not have this parameter and always waits for notifications on index 0. * * @param ulBitsToClearOnEntry Bits that are set in ulBitsToClearOnEntry value * will be cleared in the calling task's notification value before the task @@ -2092,18 +2655,39 @@ BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulVal * already pending when xTaskNotifyWait was called) then pdPASS is * returned. Otherwise pdFAIL is returned. * + * \defgroup xTaskNotifyWaitIndexed xTaskNotifyWaitIndexed * \ingroup TaskNotifications */ -BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +BaseType_t xTaskGenericNotifyWait( UBaseType_t uxIndexToWaitOn, + uint32_t ulBitsToClearOnEntry, + uint32_t ulBitsToClearOnExit, + uint32_t * pulNotificationValue, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +#define xTaskNotifyWait( ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait ) \ + xTaskGenericNotifyWait( tskDEFAULT_INDEX_TO_NOTIFY, ( ulBitsToClearOnEntry ), ( ulBitsToClearOnExit ), ( pulNotificationValue ), ( xTicksToWait ) ) +#define xTaskNotifyWaitIndexed( uxIndexToWaitOn, ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait ) \ + xTaskGenericNotifyWait( ( uxIndexToWaitOn ), ( ulBitsToClearOnEntry ), ( ulBitsToClearOnExit ), ( pulNotificationValue ), ( xTicksToWait ) ) /** - * Simplified macro for sending task notification. + * task. h + * @code{c} + * BaseType_t xTaskNotifyGiveIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify ); + * BaseType_t xTaskNotifyGive( TaskHandle_t xTaskToNotify ); + * @endcode * - * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this macro - * to be available. + * Sends a direct to task notification to a particular index in the target + * task's notification array in a manner similar to giving a counting semaphore. + * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for more details. * - * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private - * "notification value", which is a 32-bit unsigned integer (uint32_t). + * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these + * macros to be available. + * + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. * * Events can be sent to a task using an intermediary object. Examples of such * objects are queues, semaphores, mutexes and event groups. Task notifications @@ -2111,46 +2695,76 @@ BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClea * an intermediary object. * * A notification sent to a task can optionally perform an action, such as - * update, overwrite or increment the task's notification value. In that way - * task notifications can be used to send data to a task, or be used as light - * weight and fast binary or counting semaphores. + * update, overwrite or increment one of the task's notification values. In + * that way task notifications can be used to send data to a task, or be used as + * light weight and fast binary or counting semaphores. * - * xTaskNotifyGive() is a helper macro intended for use when task notifications - * are used as light weight and faster binary or counting semaphore equivalents. - * Actual FreeRTOS semaphores are given using the xSemaphoreGive() API function, - * the equivalent action that instead uses a task notification is - * xTaskNotifyGive(). + * xTaskNotifyGiveIndexed() is a helper macro intended for use when task + * notifications are used as light weight and faster binary or counting + * semaphore equivalents. Actual FreeRTOS semaphores are given using the + * xSemaphoreGive() API function, the equivalent action that instead uses a task + * notification is xTaskNotifyGiveIndexed(). * * When task notifications are being used as a binary or counting semaphore * equivalent then the task being notified should wait for the notification - * using the ulTaskNotificationTake() API function rather than the - * xTaskNotifyWait() API function. - * - * See http://www.FreeRTOS.org/RTOS-task-notifications.html for more details. + * using the ulTaskNotificationTakeIndexed() API function rather than the + * xTaskNotifyWaitIndexed() API function. + * + * **NOTE** Each notification within the array operates independently - a task + * can only block on one notification within the array at a time and will not be + * unblocked by a notification sent to any other array index. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. xTaskNotifyGive() is the original API function, and remains backward + * compatible by always operating on the notification value at index 0 in the + * array. Calling xTaskNotifyGive() is equivalent to calling + * xTaskNotifyGiveIndexed() with the uxIndexToNotify parameter set to 0. * * @param xTaskToNotify The handle of the task being notified. The handle to a * task can be returned from the xTaskCreate() API function used to create the * task, and the handle of the currently running task can be obtained by calling * xTaskGetCurrentTaskHandle(). * + * @param uxIndexToNotify The index within the target task's array of + * notification values to which the notification is to be sent. uxIndexToNotify + * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyGive() + * does not have this parameter and always sends notifications to index 0. + * * @return xTaskNotifyGive() is a macro that calls xTaskNotify() with the * eAction parameter set to eIncrement - so pdPASS is always returned. * + * \defgroup xTaskNotifyGiveIndexed xTaskNotifyGiveIndexed * \ingroup TaskNotifications */ -#define xTaskNotifyGive( xTaskToNotify ) xTaskGenericNotify( ( xTaskToNotify ), ( 0 ), eIncrement, NULL ) +#define xTaskNotifyGive( xTaskToNotify ) \ + xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( 0 ), eIncrement, NULL ) +#define xTaskNotifyGiveIndexed( xTaskToNotify, uxIndexToNotify ) \ + xTaskGenericNotify( ( xTaskToNotify ), ( uxIndexToNotify ), ( 0 ), eIncrement, NULL ) /** - * Simplified macro for sending task notification from ISR. + * task. h + * @code{c} + * void vTaskNotifyGiveIndexedFromISR( TaskHandle_t xTaskHandle, UBaseType_t uxIndexToNotify, BaseType_t *pxHigherPriorityTaskWoken ); + * void vTaskNotifyGiveFromISR( TaskHandle_t xTaskHandle, BaseType_t *pxHigherPriorityTaskWoken ); + * @endcode + * + * A version of xTaskNotifyGiveIndexed() that can be called from an interrupt + * service routine (ISR). + * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for more details. * * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this macro * to be available. * - * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private - * "notification value", which is a 32-bit unsigned integer (uint32_t). - * - * A version of xTaskNotifyGive() that can be called from an interrupt service - * routine (ISR). + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. * * Events can be sent to a task using an intermediary object. Examples of such * objects are queues, semaphores, mutexes and event groups. Task notifications @@ -2158,28 +2772,46 @@ BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClea * an intermediary object. * * A notification sent to a task can optionally perform an action, such as - * update, overwrite or increment the task's notification value. In that way - * task notifications can be used to send data to a task, or be used as light - * weight and fast binary or counting semaphores. + * update, overwrite or increment one of the task's notification values. In + * that way task notifications can be used to send data to a task, or be used as + * light weight and fast binary or counting semaphores. * - * vTaskNotifyGiveFromISR() is intended for use when task notifications are - * used as light weight and faster binary or counting semaphore equivalents. + * vTaskNotifyGiveIndexedFromISR() is intended for use when task notifications + * are used as light weight and faster binary or counting semaphore equivalents. * Actual FreeRTOS semaphores are given from an ISR using the * xSemaphoreGiveFromISR() API function, the equivalent action that instead uses - * a task notification is vTaskNotifyGiveFromISR(). + * a task notification is vTaskNotifyGiveIndexedFromISR(). * * When task notifications are being used as a binary or counting semaphore * equivalent then the task being notified should wait for the notification - * using the ulTaskNotificationTake() API function rather than the - * xTaskNotifyWait() API function. - * - * See http://www.FreeRTOS.org/RTOS-task-notifications.html for more details. + * using the ulTaskNotificationTakeIndexed() API function rather than the + * xTaskNotifyWaitIndexed() API function. + * + * **NOTE** Each notification within the array operates independently - a task + * can only block on one notification within the array at a time and will not be + * unblocked by a notification sent to any other array index. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. xTaskNotifyFromISR() is the original API function, and remains + * backward compatible by always operating on the notification value at index 0 + * within the array. Calling xTaskNotifyGiveFromISR() is equivalent to calling + * xTaskNotifyGiveIndexedFromISR() with the uxIndexToNotify parameter set to 0. * * @param xTaskToNotify The handle of the task being notified. The handle to a * task can be returned from the xTaskCreate() API function used to create the * task, and the handle of the currently running task can be obtained by calling * xTaskGetCurrentTaskHandle(). * + * @param uxIndexToNotify The index within the target task's array of + * notification values to which the notification is to be sent. uxIndexToNotify + * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. + * xTaskNotifyGiveFromISR() does not have this parameter and always sends + * notifications to index 0. + * * @param pxHigherPriorityTaskWoken vTaskNotifyGiveFromISR() will set * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the * task to which the notification was sent to leave the Blocked state, and the @@ -2189,18 +2821,38 @@ 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 vTaskNotifyGiveIndexedFromISR vTaskNotifyGiveIndexedFromISR * \ingroup TaskNotifications */ -void vTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; +void vTaskGenericNotifyGiveFromISR( TaskHandle_t xTaskToNotify, + UBaseType_t uxIndexToNotify, + BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; +#define vTaskNotifyGiveFromISR( xTaskToNotify, pxHigherPriorityTaskWoken ) \ + vTaskGenericNotifyGiveFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( pxHigherPriorityTaskWoken ) ); +#define vTaskNotifyGiveIndexedFromISR( xTaskToNotify, uxIndexToNotify, pxHigherPriorityTaskWoken ) \ + vTaskGenericNotifyGiveFromISR( ( xTaskToNotify ), ( uxIndexToNotify ), ( pxHigherPriorityTaskWoken ) ); /** - * Simplified macro for receiving task notification. + * task. h + * @code{c} + * uint32_t ulTaskNotifyTakeIndexed( UBaseType_t uxIndexToWaitOn, BaseType_t xClearCountOnExit, TickType_t xTicksToWait ); + * + * uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait ); + * @endcode + * + * Waits for a direct to task notification on a particular index in the calling + * task's notification array in a manner similar to taking a counting semaphore. + * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. * * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this * function to be available. * - * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private - * "notification value", which is a 32-bit unsigned integer (uint32_t). + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. * * Events can be sent to a task using an intermediary object. Examples of such * objects are queues, semaphores, mutexes and event groups. Task notifications @@ -2208,35 +2860,54 @@ void vTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPri * an intermediary object. * * A notification sent to a task can optionally perform an action, such as - * update, overwrite or increment the task's notification value. In that way - * task notifications can be used to send data to a task, or be used as light - * weight and fast binary or counting semaphores. + * update, overwrite or increment one of the task's notification values. In + * that way task notifications can be used to send data to a task, or be used as + * light weight and fast binary or counting semaphores. * - * ulTaskNotifyTake() is intended for use when a task notification is used as a - * faster and lighter weight binary or counting semaphore alternative. Actual - * FreeRTOS semaphores are taken using the xSemaphoreTake() API function, the - * equivalent action that instead uses a task notification is - * ulTaskNotifyTake(). + * ulTaskNotifyTakeIndexed() is intended for use when a task notification is + * used as a faster and lighter weight binary or counting semaphore alternative. + * Actual FreeRTOS semaphores are taken using the xSemaphoreTake() API function, + * the equivalent action that instead uses a task notification is + * ulTaskNotifyTakeIndexed(). * * When a task is using its notification value as a binary or counting semaphore - * other tasks should send notifications to it using the xTaskNotifyGive() - * macro, or xTaskNotify() function with the eAction parameter set to + * other tasks should send notifications to it using the xTaskNotifyGiveIndexed() + * macro, or xTaskNotifyIndex() function with the eAction parameter set to * eIncrement. * - * ulTaskNotifyTake() can either clear the task's notification value to - * zero on exit, in which case the notification value acts like a binary - * semaphore, or decrement the task's notification value on exit, in which case - * the notification value acts like a counting semaphore. + * ulTaskNotifyTakeIndexed() can either clear the task's notification value at + * the array index specified by the uxIndexToWaitOn parameter to zero on exit, + * in which case the notification value acts like a binary semaphore, or + * decrement the notification value on exit, in which case the notification + * value acts like a counting semaphore. * - * A task can use ulTaskNotifyTake() to [optionally] block to wait for a + * A task can use ulTaskNotifyTakeIndexed() to [optionally] block to wait for * the task's notification value to be non-zero. The task does not consume any * CPU time while it is in the Blocked state. * - * Where as xTaskNotifyWait() will return when a notification is pending, - * ulTaskNotifyTake() will return when the task's notification value is + * Where as xTaskNotifyWaitIndexed() will return when a notification is pending, + * ulTaskNotifyTakeIndexed() will return when the task's notification value is * not zero. * - * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * **NOTE** Each notification within the array operates independently - a task + * can only block on one notification within the array at a time and will not be + * unblocked by a notification sent to any other array index. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. ulTaskNotifyTake() is the original API function, and remains backward + * compatible by always operating on the notification value at index 0 in the + * array. Calling ulTaskNotifyTake() is equivalent to calling + * ulTaskNotifyTakeIndexed() with the uxIndexToWaitOn parameter set to 0. + * + * @param uxIndexToWaitOn The index within the calling task's array of + * notification values on which the calling task will wait for a notification to + * be non-zero. uxIndexToWaitOn must be less than + * configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyTake() does + * not have this parameter and always waits for notifications on index 0. * * @param xClearCountOnExit if xClearCountOnExit is pdFALSE then the task's * notification value is decremented when the function exits. In this way the @@ -2256,23 +2927,289 @@ 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 ulTaskNotifyTakeIndexed ulTaskNotifyTakeIndexed * \ingroup TaskNotifications */ -uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +uint32_t ulTaskGenericNotifyTake( UBaseType_t uxIndexToWaitOn, + BaseType_t xClearCountOnExit, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +#define ulTaskNotifyTake( xClearCountOnExit, xTicksToWait ) \ + ulTaskGenericNotifyTake( ( tskDEFAULT_INDEX_TO_NOTIFY ), ( xClearCountOnExit ), ( xTicksToWait ) ) +#define ulTaskNotifyTakeIndexed( uxIndexToWaitOn, xClearCountOnExit, xTicksToWait ) \ + ulTaskGenericNotifyTake( ( uxIndexToWaitOn ), ( xClearCountOnExit ), ( xTicksToWait ) ) /** + * task. h + * @code{c} + * BaseType_t xTaskNotifyStateClearIndexed( TaskHandle_t xTask, UBaseType_t uxIndexToCLear ); * - * If the notification state of the task referenced by the handle xTask is - * eNotified, then set the task's notification state to eNotWaitingNotification. - * The task's notification value is not altered. Set xTask to NULL to clear the - * notification state of the calling task. + * BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask ); + * @endcode + * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * + * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these + * functions to be available. + * + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. + * + * If a notification is sent to an index within the array of notifications then + * the notification at that index is said to be 'pending' until it is read or + * explicitly cleared by the receiving task. xTaskNotifyStateClearIndexed() + * is the function that clears a pending notification without reading the + * notification value. The notification value at the same array index is not + * altered. Set xTask to NULL to clear the notification state of the calling + * task. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. xTaskNotifyStateClear() is the original API function, and remains + * backward compatible by always operating on the notification value at index 0 + * within the array. Calling xTaskNotifyStateClear() is equivalent to calling + * xTaskNotifyStateClearIndexed() with the uxIndexToNotify parameter set to 0. + * + * @param xTask The handle of the RTOS task that will have a notification state + * cleared. Set xTask to NULL to clear a notification state in the calling + * task. To obtain a task's handle create the task using xTaskCreate() and + * make use of the pxCreatedTask parameter, or create the task using + * xTaskCreateStatic() and store the returned value, or use the task's name in + * a call to xTaskGetHandle(). + * + * @param uxIndexToClear The index within the target task's array of + * notification values to act upon. For example, setting uxIndexToClear to 1 + * will clear the state of the notification at index 1 within the array. + * uxIndexToClear must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. + * ulTaskNotifyStateClear() does not have this parameter and always acts on the + * notification at index 0. * * @return pdTRUE if the task's notification state was set to * eNotWaitingNotification, otherwise pdFALSE. * + * \defgroup xTaskNotifyStateClearIndexed xTaskNotifyStateClearIndexed * \ingroup TaskNotifications */ -BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask ); +BaseType_t xTaskGenericNotifyStateClear( TaskHandle_t xTask, + UBaseType_t uxIndexToClear ) PRIVILEGED_FUNCTION; +#define xTaskNotifyStateClear( xTask ) \ + xTaskGenericNotifyStateClear( ( xTask ), ( tskDEFAULT_INDEX_TO_NOTIFY ) ) +#define xTaskNotifyStateClearIndexed( xTask, uxIndexToClear ) \ + xTaskGenericNotifyStateClear( ( xTask ), ( uxIndexToClear ) ) + +/** + * task. h + * @code{c} + * uint32_t ulTaskNotifyValueClearIndexed( TaskHandle_t xTask, UBaseType_t uxIndexToClear, uint32_t ulBitsToClear ); + * + * uint32_t ulTaskNotifyValueClear( TaskHandle_t xTask, uint32_t ulBitsToClear ); + * @endcode + * + * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details. + * + * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these + * functions to be available. + * + * Each task has a private array of "notification values" (or 'notifications'), + * each of which is a 32-bit unsigned integer (uint32_t). The constant + * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the + * array, and (for backward compatibility) defaults to 1 if left undefined. + * Prior to FreeRTOS V10.4.0 there was only one notification value per task. + * + * ulTaskNotifyValueClearIndexed() clears the bits specified by the + * ulBitsToClear bit mask in the notification value at array index uxIndexToClear + * of the task referenced by xTask. + * + * Backward compatibility information: + * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and + * all task notification API functions operated on that value. Replacing the + * single notification value with an array of notification values necessitated a + * new set of API functions that could address specific notifications within the + * array. ulTaskNotifyValueClear() is the original API function, and remains + * backward compatible by always operating on the notification value at index 0 + * within the array. Calling ulTaskNotifyValueClear() is equivalent to calling + * ulTaskNotifyValueClearIndexed() with the uxIndexToClear parameter set to 0. + * + * @param xTask The handle of the RTOS task that will have bits in one of its + * notification values cleared. Set xTask to NULL to clear bits in a + * notification value of the calling task. To obtain a task's handle create the + * task using xTaskCreate() and make use of the pxCreatedTask parameter, or + * create the task using xTaskCreateStatic() and store the returned value, or + * use the task's name in a call to xTaskGetHandle(). + * + * @param uxIndexToClear The index within the target task's array of + * notification values in which to clear the bits. uxIndexToClear + * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. + * ulTaskNotifyValueClear() does not have this parameter and always clears bits + * in the notification value at index 0. + * + * @param ulBitsToClear Bit mask of the bits to clear in the notification value of + * xTask. Set a bit to 1 to clear the corresponding bits in the task's notification + * value. Set ulBitsToClear to 0xffffffff (UINT_MAX on 32-bit architectures) to clear + * the notification value to 0. Set ulBitsToClear to 0 to query the task's + * notification value without clearing any bits. + * + * + * @return The value of the target task's notification value before the bits + * specified by ulBitsToClear were cleared. + * \defgroup ulTaskNotifyValueClear ulTaskNotifyValueClear + * \ingroup TaskNotifications + */ +uint32_t ulTaskGenericNotifyValueClear( TaskHandle_t xTask, + UBaseType_t uxIndexToClear, + uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION; +#define ulTaskNotifyValueClear( xTask, ulBitsToClear ) \ + ulTaskGenericNotifyValueClear( ( xTask ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulBitsToClear ) ) +#define ulTaskNotifyValueClearIndexed( xTask, uxIndexToClear, ulBitsToClear ) \ + ulTaskGenericNotifyValueClear( ( xTask ), ( uxIndexToClear ), ( ulBitsToClear ) ) + +/** + * @cond + * task.h + * @code{c} + * void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ); + * @endcode + * @endcond + * + * Capture the current time for future use with xTaskCheckForTimeOut(). + * + * @param pxTimeOut Pointer to a timeout object into which the current time + * is to be captured. The captured time includes the tick count and the number + * of times the tick count has overflowed since the system first booted. + * \defgroup vTaskSetTimeOutState vTaskSetTimeOutState + * @cond + * \ingroup TaskCtrl + * @endcond + */ +void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION; + +/** + * @cond + * task.h + * @code + * BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait ); + * @endcode + * @endcond + * + * Determines if pxTicksToWait ticks has passed since a time was captured + * using a call to vTaskSetTimeOutState(). The captured time includes the tick + * count and the number of times the tick count has overflowed. + * + * @param pxTimeOut The time status as captured previously using + * vTaskSetTimeOutState. If the timeout has not yet occurred, it is updated + * to reflect the current time status. + * @param pxTicksToWait The number of ticks to check for timeout i.e. if + * pxTicksToWait ticks have passed since pxTimeOut was last updated (either by + * vTaskSetTimeOutState() or xTaskCheckForTimeOut()), the timeout has occurred. + * If the timeout has not occurred, pxTicksToWait is updated to reflect the + * number of remaining ticks. + * + * @return If timeout has occurred, pdTRUE is returned. Otherwise pdFALSE is + * returned and pxTicksToWait is updated to reflect the number of remaining + * ticks. + * + * @see https://www.FreeRTOS.org/xTaskCheckForTimeOut.html + * + * Example Usage: + * @code + * // Driver library function used to receive uxWantedBytes from an Rx buffer + * // that is filled by a UART interrupt. If there are not enough bytes in the + * // Rx buffer then the task enters the Blocked state until it is notified that + * // more data has been placed into the buffer. If there is still not enough + * // data then the task re-enters the Blocked state, and xTaskCheckForTimeOut() + * // is used to re-calculate the Block time to ensure the total amount of time + * // spent in the Blocked state does not exceed MAX_TIME_TO_WAIT. This + * // continues until either the buffer contains at least uxWantedBytes bytes, + * // or the total amount of time spent in the Blocked state reaches + * // MAX_TIME_TO_WAIT – at which point the task reads however many bytes are + * // available up to a maximum of uxWantedBytes. + * + * size_t xUART_Receive( uint8_t *pucBuffer, size_t uxWantedBytes ) + * { + * size_t uxReceived = 0; + * TickType_t xTicksToWait = MAX_TIME_TO_WAIT; + * TimeOut_t xTimeOut; + * + * // Initialize xTimeOut. This records the time at which this function + * // was entered. + * vTaskSetTimeOutState( &xTimeOut ); + * + * // Loop until the buffer contains the wanted number of bytes, or a + * // timeout occurs. + * while( UART_bytes_in_rx_buffer( pxUARTInstance ) < uxWantedBytes ) + * { + * // The buffer didn't contain enough data so this task is going to + * // enter the Blocked state. Adjusting xTicksToWait to account for + * // any time that has been spent in the Blocked state within this + * // function so far to ensure the total amount of time spent in the + * // Blocked state does not exceed MAX_TIME_TO_WAIT. + * if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) != pdFALSE ) + * { + * //Timed out before the wanted number of bytes were available, + * // exit the loop. + * break; + * } + * + * // Wait for a maximum of xTicksToWait ticks to be notified that the + * // receive interrupt has placed more data into the buffer. + * ulTaskNotifyTake( pdTRUE, xTicksToWait ); + * } + * + * // Attempt to read uxWantedBytes from the receive buffer into pucBuffer. + * // The actual number of bytes read (which might be less than + * // uxWantedBytes) is returned. + * uxReceived = UART_read_from_receive_buffer( pxUARTInstance, + * pucBuffer, + * uxWantedBytes ); + * + * return uxReceived; + * } + * @endcode + * @cond + * \defgroup xTaskCheckForTimeOut xTaskCheckForTimeOut + * @endcond + * \ingroup TaskCtrl + */ +BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, + TickType_t * const pxTicksToWait ) PRIVILEGED_FUNCTION; + +/** + * @cond + * task.h + * @code{c} + * BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp ); + * @endcode + * @endcond + * + * This function corrects the tick count value after the application code has held + * interrupts disabled for an extended period resulting in tick interrupts having + * been missed. + * + * This function is similar to vTaskStepTick(), however, unlike + * vTaskStepTick(), xTaskCatchUpTicks() may move the tick count forward past a + * time at which a task should be removed from the blocked state. That means + * tasks may have to be removed from the blocked state as the tick count is + * moved. + * + * @param xTicksToCatchUp The number of tick interrupts that have been missed due to + * interrupts being disabled. Its value is not computed automatically, so must be + * computed by the application writer. + * + * @return pdTRUE if moving the tick count forward resulted in a task leaving the + * blocked state and a context switch being performed. Otherwise pdFALSE. + * + * \defgroup xTaskCatchUpTicks xTaskCatchUpTicks + * @cond + * \ingroup TaskCtrl + * @endcond + */ +BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) PRIVILEGED_FUNCTION; + /*----------------------------------------------------------- * SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES @@ -2299,7 +3236,6 @@ TaskHandle_t xTaskGetCurrentTaskHandleForCPU( BaseType_t cpuid ); */ TaskHandle_t xTaskGetIdleTaskHandleForCPU( UBaseType_t cpuid ); - /* * Get the current core affinity of a task */ @@ -2339,7 +3275,7 @@ BaseType_t xTaskIncrementTick( void ) PRIVILEGED_FUNCTION; * xItemValue value, and inserts the list item at the end of the list. * * The 'ordered' version uses the existing event list item value (which is the - * owning tasks priority) to insert the list item into the event list is task + * owning task's priority) to insert the list item into the event list in task * priority order. * * @param pxEventList The list containing tasks that are blocked waiting @@ -2349,12 +3285,15 @@ BaseType_t xTaskIncrementTick( void ) PRIVILEGED_FUNCTION; * event list is not ordered by task priority. * * @param xTicksToWait The maximum amount of time that the task should wait - * for the event to occur. This is specified in kernel ticks,the constant + * for the event to occur. This is specified in kernel ticks, the constant * portTICK_PERIOD_MS can be used to convert kernel ticks into a real time * period. */ -void vTaskPlaceOnEventList( List_t * const pxEventList, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; -void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, const TickType_t xItemValue, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +void vTaskPlaceOnEventList( List_t * const pxEventList, + const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, + const TickType_t xItemValue, + const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; /* * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN @@ -2367,7 +3306,9 @@ void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, const TickType_t xIte * indefinitely, whereas vTaskPlaceOnEventList() does. * */ -void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION; +void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, + TickType_t xTicksToWait, + const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION; /* * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN @@ -2394,7 +3335,8 @@ void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, TickType_t xTi * making the call, otherwise pdFALSE. */ BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList ) PRIVILEGED_FUNCTION; -BaseType_t xTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, const TickType_t xItemValue ) PRIVILEGED_FUNCTION; +BaseType_t xTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, + const TickType_t xItemValue ) PRIVILEGED_FUNCTION; /* * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY @@ -2404,7 +3346,7 @@ BaseType_t xTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, cons * Sets the pointer to the current TCB to the TCB of the highest priority task * that is ready to run. */ -void vTaskSwitchContext( void ) PRIVILEGED_FUNCTION; +portDONT_DISCARD void vTaskSwitchContext( void ) PRIVILEGED_FUNCTION; /* * THESE FUNCTIONS MUST NOT BE USED FROM APPLICATION CODE. THEY ARE USED BY @@ -2417,17 +3359,6 @@ TickType_t uxTaskResetEventItemValue( void ) PRIVILEGED_FUNCTION; */ TaskHandle_t xTaskGetCurrentTaskHandle( void ) PRIVILEGED_FUNCTION; -/* - * Capture the current time status for future reference. - */ -void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION; - -/* - * Compare the time status now with that previously captured to see if the - * timeout has expired. - */ -BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait ) PRIVILEGED_FUNCTION; - /* * Shortcut used by the queue implementation to prevent unnecessary call to * taskYIELD(); @@ -2460,7 +3391,8 @@ BaseType_t xTaskPriorityDisinherit( TaskHandle_t const pxMutexHolder ) PRIVILEGE * the highest priority task that is still waiting for the mutex (if there were * more than one task waiting for the mutex). */ -void vTaskPriorityDisinheritAfterTimeout( TaskHandle_t const pxMutexHolder, UBaseType_t uxHighestPriorityWaitingTask ) PRIVILEGED_FUNCTION; +void vTaskPriorityDisinheritAfterTimeout( TaskHandle_t const pxMutexHolder, + UBaseType_t uxHighestPriorityWaitingTask ) PRIVILEGED_FUNCTION; /* * Get the uxTCBNumber assigned to the task referenced by the xTask parameter. @@ -2476,7 +3408,8 @@ BaseType_t xTaskGetAffinity( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; * Set the uxTaskNumber of the task referenced by the xTask parameter to * uxHandle. */ -void vTaskSetTaskNumber( TaskHandle_t xTask, const UBaseType_t uxHandle ) PRIVILEGED_FUNCTION; +void vTaskSetTaskNumber( TaskHandle_t xTask, + const UBaseType_t uxHandle ) PRIVILEGED_FUNCTION; /* * Only available when configUSE_TICKLESS_IDLE is set to 1. @@ -2488,19 +3421,6 @@ void vTaskSetTaskNumber( TaskHandle_t xTask, const UBaseType_t uxHandle ) PRIVIL */ void vTaskStepTick( const TickType_t xTicksToJump ) PRIVILEGED_FUNCTION; -/* Correct the tick count value after the application code has held -interrupts disabled for an extended period. xTicksToCatchUp is the number -of tick interrupts that have been missed due to interrupts being disabled. -Its value is not computed automatically, so must be computed by the -application writer. - -This function is similar to vTaskStepTick(), however, unlike -vTaskStepTick(), xTaskCatchUpTicks() may move the tick count forward past a -time at which a task should be removed from the blocked state. That means -tasks may have to be removed from the blocked state as the tick count is -moved. */ -BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) PRIVILEGED_FUNCTION; - /* * Only available when configUSE_TICKLESS_IDLE is set to 1. * Provided for use within portSUPPRESS_TICKS_AND_SLEEP() to allow the port @@ -2524,44 +3444,20 @@ eSleepModeStatus eTaskConfirmSleepModeStatus( void ) PRIVILEGED_FUNCTION; TaskHandle_t pvTaskIncrementMutexHeldCount( void ) PRIVILEGED_FUNCTION; /* - * For internal use only. Same as vTaskSetTimeOutState(), but without a critial + * For internal use only. Same as vTaskSetTimeOutState(), but without a critical * section. */ void vTaskInternalSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION; -/* - * This function fills array with TaskSnapshot_t structures for every task in the system. - * Used by panic handling code to get snapshots of all tasks in the system. - * Only available when configENABLE_TASK_SNAPSHOT is set to 1. - * @param pxTaskSnapshotArray Pointer to array of TaskSnapshot_t structures to store tasks snapshot data. - * @param uxArraySize Size of tasks snapshots array. - * @param pxTcbSz Pointer to store size of TCB. - * @return Number of elements stored in array. - */ -UBaseType_t uxTaskGetSnapshotAll( TaskSnapshot_t * const pxTaskSnapshotArray, const UBaseType_t uxArraySize, UBaseType_t * const pxTcbSz ); - -/* - * This function iterates over all tasks in the system. - * Used by panic handling code to iterate over tasks in the system. - * Only available when configENABLE_TASK_SNAPSHOT is set to 1. - * @note This function should not be used while FreeRTOS is running (as it doesn't acquire any locks). - * @param pxTask task handle. - * @return Handle for the next task. If pxTask is NULL, returns hadnle for the first task. - */ -TaskHandle_t pxTaskGetNext( TaskHandle_t pxTask ); - -/* - * This function fills TaskSnapshot_t structure for specified task. - * Used by panic handling code to get snapshot of a task. - * Only available when configENABLE_TASK_SNAPSHOT is set to 1. - * @note This function should not be used while FreeRTOS is running (as it doesn't acquire any locks). - * @param pxTask task handle. - * @param pxTaskSnapshot address of TaskSnapshot_t structure to fill. - */ -void vTaskGetSnapshot( TaskHandle_t pxTask, TaskSnapshot_t *pxTaskSnapshot ); +#ifdef ESP_PLATFORM +/* TODO: IDF-3683 */ +#include "freertos/task_snapshot.h" +#endif // ESP_PLATFORM /** @endcond */ + #ifdef __cplusplus -} + } #endif +/* *INDENT-ON* */ #endif /* INC_TASK_H */ diff --git a/tools/sdk/esp32s2/include/freertos/include/freertos/timers.h b/tools/sdk/esp32s2/include/freertos/include/freertos/timers.h index 9a5e23385ff..a8bc4f38c78 100644 --- a/tools/sdk/esp32s2/include/freertos/include/freertos/timers.h +++ b/tools/sdk/esp32s2/include/freertos/include/freertos/timers.h @@ -1,6 +1,6 @@ /* - * FreeRTOS Kernel V10.2.1 - * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.3 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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 @@ -19,10 +19,9 @@ * 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. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ @@ -30,41 +29,43 @@ #define TIMERS_H #ifndef INC_FREERTOS_H - #error "include FreeRTOS.h must appear in source files before include timers.h" + #error "include FreeRTOS.h must appear in source files before include timers.h" #endif /*lint -save -e537 This headers are only multiply included if the application code -happens to also be including task.h. */ + * happens to also be including task.h. */ #include "task.h" /*lint -restore */ +/* *INDENT-OFF* */ #ifdef __cplusplus -extern "C" { + extern "C" { #endif +/* *INDENT-ON* */ /*----------------------------------------------------------- * MACROS AND DEFINITIONS *----------------------------------------------------------*/ /* IDs for commands that can be sent/received on the timer queue. These are to -be used solely through the macros that make up the public software timer API, -as defined below. The commands that are sent from interrupts must use the -highest numbers as tmrFIRST_FROM_ISR_COMMAND is used to determine if the task -or interrupt version of the queue send function should be used. */ -#define tmrCOMMAND_EXECUTE_CALLBACK_FROM_ISR ( ( BaseType_t ) -2 ) -#define tmrCOMMAND_EXECUTE_CALLBACK ( ( BaseType_t ) -1 ) -#define tmrCOMMAND_START_DONT_TRACE ( ( BaseType_t ) 0 ) -#define tmrCOMMAND_START ( ( BaseType_t ) 1 ) -#define tmrCOMMAND_RESET ( ( BaseType_t ) 2 ) -#define tmrCOMMAND_STOP ( ( BaseType_t ) 3 ) -#define tmrCOMMAND_CHANGE_PERIOD ( ( BaseType_t ) 4 ) -#define tmrCOMMAND_DELETE ( ( BaseType_t ) 5 ) + * be used solely through the macros that make up the public software timer API, + * as defined below. The commands that are sent from interrupts must use the + * highest numbers as tmrFIRST_FROM_ISR_COMMAND is used to determine if the task + * or interrupt version of the queue send function should be used. */ +#define tmrCOMMAND_EXECUTE_CALLBACK_FROM_ISR ( ( BaseType_t ) -2 ) +#define tmrCOMMAND_EXECUTE_CALLBACK ( ( BaseType_t ) -1 ) +#define tmrCOMMAND_START_DONT_TRACE ( ( BaseType_t ) 0 ) +#define tmrCOMMAND_START ( ( BaseType_t ) 1 ) +#define tmrCOMMAND_RESET ( ( BaseType_t ) 2 ) +#define tmrCOMMAND_STOP ( ( BaseType_t ) 3 ) +#define tmrCOMMAND_CHANGE_PERIOD ( ( BaseType_t ) 4 ) +#define tmrCOMMAND_DELETE ( ( BaseType_t ) 5 ) -#define tmrFIRST_FROM_ISR_COMMAND ( ( BaseType_t ) 6 ) -#define tmrCOMMAND_START_FROM_ISR ( ( BaseType_t ) 6 ) -#define tmrCOMMAND_RESET_FROM_ISR ( ( BaseType_t ) 7 ) -#define tmrCOMMAND_STOP_FROM_ISR ( ( BaseType_t ) 8 ) -#define tmrCOMMAND_CHANGE_PERIOD_FROM_ISR ( ( BaseType_t ) 9 ) +#define tmrFIRST_FROM_ISR_COMMAND ( ( BaseType_t ) 6 ) +#define tmrCOMMAND_START_FROM_ISR ( ( BaseType_t ) 6 ) +#define tmrCOMMAND_RESET_FROM_ISR ( ( BaseType_t ) 7 ) +#define tmrCOMMAND_STOP_FROM_ISR ( ( BaseType_t ) 8 ) +#define tmrCOMMAND_CHANGE_PERIOD_FROM_ISR ( ( BaseType_t ) 9 ) /** @@ -74,20 +75,30 @@ or interrupt version of the queue send function should be used. */ * (for example, xTimerStart(), xTimerReset(), etc.). */ struct tmrTimerControl; /* The old naming convention is used to prevent breaking kernel aware debuggers. */ -//typedef struct tmrTimerControl * TimerHandle_t; +#ifdef ESP_PLATFORM // IDF-3768 typedef void* TimerHandle_t; +#else +typedef struct tmrTimerControl * TimerHandle_t; +#endif // ESP_PLATFORM /* * Defines the prototype to which timer callback functions must conform. */ -typedef void (*TimerCallbackFunction_t)( TimerHandle_t xTimer ); +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 ); +typedef void (* PendedFunction_t)( void *, + uint32_t ); /** + * TimerHandle_t xTimerCreate( const char * const pcTimerName, + * TickType_t xTimerPeriodInTicks, + * UBaseType_t uxAutoReload, + * void * pvTimerID, + * TimerCallbackFunction_t pxCallbackFunction ); + * * Creates a new software timer instance, and returns a handle by which the * created software timer can be referenced. * @@ -95,7 +106,7 @@ typedef void (*PendedFunction_t)( void *, uint32_t ); * 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 + * https://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. @@ -115,7 +126,7 @@ typedef void (*PendedFunction_t)( void *, uint32_t ); * 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. + * equal to 1000. Time timer period must be greater than 0. * * @param uxAutoReload If uxAutoReload is set to pdTRUE then the timer will * expire repeatedly with a frequency set by the xTimerPeriodInTicks parameter. @@ -129,7 +140,7 @@ typedef void (*PendedFunction_t)( void *, uint32_t ); * * @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 );". + * which is "void vCallbackFunction( TimerHandle_t xTimer );". * * @return If the timer is successfully created then a handle to the newly * created timer is returned. If the timer cannot be created (because either @@ -137,7 +148,7 @@ typedef void (*PendedFunction_t)( void *, uint32_t ); * structures, or the timer period was set to 0) then NULL is returned. * * Example usage: - * @code{c} + * @verbatim * #define NUM_TIMERS 5 * * // An array to hold handles to the created timers. @@ -155,8 +166,8 @@ typedef void (*PendedFunction_t)( void *, uint32_t ); * int32_t lArrayIndex; * const int32_t xMaxExpiryCountBeforeStopping = 10; * - * // Optionally do something if the pxTimer parameter is NULL. - * configASSERT( pxTimer ); + * // Optionally do something if the pxTimer parameter is NULL. + * configASSERT( pxTimer ); * * // Which timer expired? * lArrayIndex = ( int32_t ) pvTimerGetTimerID( pxTimer ); @@ -216,138 +227,145 @@ typedef void (*PendedFunction_t)( void *, uint32_t ); * // Should not reach here. * for( ;; ); * } - * @endcode + * @endverbatim */ -#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) - TimerHandle_t xTimerCreate( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ - const TickType_t xTimerPeriodInTicks, - const UBaseType_t uxAutoReload, - void * const pvTimerID, - TimerCallbackFunction_t pxCallbackFunction ) PRIVILEGED_FUNCTION; +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) + TimerHandle_t xTimerCreate( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + const TickType_t xTimerPeriodInTicks, + const UBaseType_t uxAutoReload, + void * const pvTimerID, + TimerCallbackFunction_t pxCallbackFunction ) PRIVILEGED_FUNCTION; #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; +/** + * TimerHandle_t xTimerCreateStatic(const char * const pcTimerName, + * TickType_t xTimerPeriodInTicks, + * UBaseType_t uxAutoReload, + * void * pvTimerID, + * TimerCallbackFunction_t pxCallbackFunction, + * StaticTimer_t *pxTimerBuffer ); + * + * 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 + * https://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. The timer period must be greater than 0. + * + * @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: + * @verbatim + * + * // 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( ;; ); + * } + * @endverbatim + */ +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + TimerHandle_t xTimerCreateStatic( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + const TickType_t xTimerPeriodInTicks, + const UBaseType_t uxAutoReload, + void * const pvTimerID, + TimerCallbackFunction_t pxCallbackFunction, + StaticTimer_t * pxTimerBuffer ) PRIVILEGED_FUNCTION; #endif /* configSUPPORT_STATIC_ALLOCATION */ /** @@ -370,7 +388,7 @@ typedef void (*PendedFunction_t)( void *, uint32_t ); * * See the xTimerCreate() API function example usage scenario. */ -void *pvTimerGetTimerID( const TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; +void * pvTimerGetTimerID( const TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /** * void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ); @@ -391,7 +409,8 @@ void *pvTimerGetTimerID( const TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; * * See the xTimerCreate() API function example usage scenario. */ -void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ) PRIVILEGED_FUNCTION; +void vTimerSetTimerID( TimerHandle_t xTimer, + void * pvNewID ) PRIVILEGED_FUNCTION; /** * BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer ); @@ -413,7 +432,7 @@ void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ) PRIVILEGED_FUNCTION * pdFALSE will be returned if the timer is active. * * Example usage: - * @code{c} + * @verbatim * // This function assumes xTimer has already been created. * void vAFunction( TimerHandle_t xTimer ) * { @@ -426,11 +445,15 @@ void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ) PRIVILEGED_FUNCTION * // xTimer is not active, do something else. * } * } - * @endcode + * @endverbatim */ BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /** + * @cond + * TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ); + * @endcond + * * xTimerGetTimerDaemonTaskHandle() is only available if * INCLUDE_xTimerGetTimerDaemonTaskHandle is set to 1 in FreeRTOSConfig.h. * @@ -489,9 +512,12 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * See the xTimerCreate() API function example usage scenario. * */ -#define xTimerStart( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START, ( xTaskGetTickCount() ), NULL, ( xTicksToWait ) ) +#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 @@ -529,9 +555,14 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * See the xTimerCreate() API function example usage scenario. * */ -#define xTimerStop( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP, 0U, NULL, ( xTicksToWait ) ) +#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 @@ -573,7 +604,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * configTIMER_TASK_PRIORITY configuration constant. * * Example usage: - * @code{c} + * @verbatim * // 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 @@ -603,11 +634,14 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * } * } * } - * @endcode + * @endverbatim */ - #define xTimerChangePeriod( xTimer, xNewPeriod, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD, ( xNewPeriod ), NULL, ( xTicksToWait ) ) +#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 @@ -641,9 +675,12 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * * See the xTimerChangePeriod() API function example usage scenario. */ -#define xTimerDelete( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_DELETE, 0U, NULL, ( xTicksToWait ) ) +#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 @@ -689,7 +726,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * configuration constant. * * Example usage: - * @code{c} + * @verbatim * // 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. @@ -761,11 +798,15 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * // Should not reach here. * for( ;; ); * } - * @endcode + * @endverbatim */ -#define xTimerReset( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_RESET, ( xTaskGetTickCount() ), NULL, ( xTicksToWait ) ) +#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. * @@ -793,7 +834,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * configuration constant. * * Example usage: - * @code{c} + * @verbatim * // 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 @@ -844,11 +885,15 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * // depends on the FreeRTOS port being used). * } * } - * @endcode + * @endverbatim */ -#define xTimerStartFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START_FROM_ISR, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U ) +#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. * @@ -874,7 +919,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * priority is set by the configTIMER_TASK_PRIORITY configuration constant. * * Example usage: - * @code{c} + * @verbatim * // This scenario assumes xTimer has already been created and started. When * // an interrupt occurs, the timer should be simply stopped. * @@ -904,11 +949,16 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * // depends on the FreeRTOS port being used). * } * } - * @endcode + * @endverbatim */ -#define xTimerStopFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP_FROM_ISR, 0, ( pxHigherPriorityTaskWoken ), 0U ) +#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. * @@ -943,7 +993,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * priority is set by the configTIMER_TASK_PRIORITY configuration constant. * * Example usage: - * @code{c} + * @verbatim * // This scenario assumes xTimer has already been created and started. When * // an interrupt occurs, the period of xTimer should be changed to 500ms. * @@ -973,11 +1023,15 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * // depends on the FreeRTOS port being used). * } * } - * @endcode + * @endverbatim */ -#define xTimerChangePeriodFromISR( xTimer, xNewPeriod, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD_FROM_ISR, ( xNewPeriod ), ( pxHigherPriorityTaskWoken ), 0U ) +#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. * @@ -1005,7 +1059,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * task priority is set by the configTIMER_TASK_PRIORITY configuration constant. * * Example usage: - * @code{c} + * @verbatim * // 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 @@ -1056,12 +1110,19 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * // depends on the FreeRTOS port being used). * } * } - * @endcode + * @endverbatim */ -#define xTimerResetFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_RESET_FROM_ISR, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U ) +#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'). @@ -1103,75 +1164,87 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION; * timer daemon task, otherwise pdFALSE is returned. * * Example usage: - * @code{c} + * @verbatim * - * // The callback function that will execute in the context of the daemon task. + * // The callback function that will execute in the context of the daemon task. * // Note callback functions must all use this same prototype. * void vProcessInterface( void *pvParameter1, uint32_t ulParameter2 ) - * { - * BaseType_t xInterfaceToService; + * { + * BaseType_t xInterfaceToService; * - * // The interface that requires servicing is passed in the second + * // The interface that requires servicing is passed in the second * // parameter. The first parameter is not used in this case. - * xInterfaceToService = ( BaseType_t ) ulParameter2; + * xInterfaceToService = ( BaseType_t ) ulParameter2; * - * // ...Perform the processing here... - * } + * // ...Perform the processing here... + * } * - * // An ISR that receives data packets from multiple interfaces + * // An ISR that receives data packets from multiple interfaces * void vAnISR( void ) - * { - * BaseType_t xInterfaceToService, xHigherPriorityTaskWoken; + * { + * BaseType_t xInterfaceToService, xHigherPriorityTaskWoken; * - * // Query the hardware to determine which interface needs processing. - * xInterfaceToService = prvCheckInterfaces(); + * // Query the hardware to determine which interface needs processing. + * xInterfaceToService = prvCheckInterfaces(); * * // The actual processing is to be deferred to a task. Request the * // vProcessInterface() callback function is executed, passing in the - * // number of the interface that needs processing. The interface to - * // service is passed in the second parameter. The first parameter is - * // not used in this case. - * xHigherPriorityTaskWoken = pdFALSE; - * xTimerPendFunctionCallFromISR( vProcessInterface, NULL, ( uint32_t ) xInterfaceToService, &xHigherPriorityTaskWoken ); - * - * // 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 + * // number of the interface that needs processing. The interface to + * // service is passed in the second parameter. The first parameter is + * // not used in this case. + * xHigherPriorityTaskWoken = pdFALSE; + * xTimerPendFunctionCallFromISR( vProcessInterface, NULL, ( uint32_t ) xInterfaceToService, &xHigherPriorityTaskWoken ); + * + * // 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 ); + * + * } + * @endverbatim */ -BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; +BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend, + void * pvParameter1, + uint32_t ulParameter2, + BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; - /** - * 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'). - * - * @param xFunctionToPend The function to execute from the timer service/ - * daemon task. The function must conform to the PendedFunction_t - * prototype. - * - * @param pvParameter1 The value of the callback function's first parameter. - * The parameter has a void * type to allow it to be used to pass any type. - * For example, unsigned longs can be cast to a void *, or the void * can be - * used to point to a structure. - * - * @param ulParameter2 The value of the callback function's second parameter. - * - * @param xTicksToWait Calling this function will result in a message being - * sent to the timer daemon task on a queue. xTicksToWait is the amount of - * time the calling task should remain in the Blocked state (so not using any - * processing time) for space to become available on the timer queue if the - * queue is found to be full. - * - * @return pdPASS is returned if the message was successfully sent to the - * timer daemon task, otherwise pdFALSE is returned. - * - */ -BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; +/** + * 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'). + * + * @param xFunctionToPend The function to execute from the timer service/ + * daemon task. The function must conform to the PendedFunction_t + * prototype. + * + * @param pvParameter1 The value of the callback function's first parameter. + * The parameter has a void * type to allow it to be used to pass any type. + * For example, unsigned longs can be cast to a void *, or the void * can be + * used to point to a structure. + * + * @param ulParameter2 The value of the callback function's second parameter. + * + * @param xTicksToWait Calling this function will result in a message being + * sent to the timer daemon task on a queue. xTicksToWait is the amount of + * time the calling task should remain in the Blocked state (so not using any + * processing time) for space to become available on the timer queue if the + * queue is found to be full. + * + * @return pdPASS is returned if the message was successfully sent to the + * timer daemon task, otherwise pdFALSE is returned. + * + */ +BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, + void * pvParameter1, + uint32_t ulParameter2, + TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; /** * const char * const pcTimerGetName( TimerHandle_t xTimer ); @@ -1187,8 +1260,8 @@ const char * pcTimerGetName( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /*lint /** * void vTimerSetReloadMode( TimerHandle_t xTimer, const UBaseType_t uxAutoReload ); * - * Updates a timer to be either an autoreload timer, in which case the timer - * automatically resets itself each time it expires, or a one shot timer, in + * Updates a timer to be either an auto-reload timer, in which case the timer + * automatically resets itself each time it expires, or a one-shot timer, in * which case the timer will only expire once unless it is manually restarted. * * @param xTimer The handle of the timer being updated. @@ -1199,7 +1272,22 @@ const char * pcTimerGetName( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /*lint * uxAutoReload is set to pdFALSE then the timer will be a one-shot timer and * enter the dormant state after it expires. */ -void vTimerSetReloadMode( TimerHandle_t xTimer, const UBaseType_t uxAutoReload ) PRIVILEGED_FUNCTION; +void vTimerSetReloadMode( TimerHandle_t xTimer, + const UBaseType_t uxAutoReload ) PRIVILEGED_FUNCTION; + +/** + * UBaseType_t uxTimerGetReloadMode( TimerHandle_t xTimer ); + * + * Queries a timer to determine if it is an auto-reload timer, in which case the timer + * automatically resets itself each time it expires, or a one-shot timer, in + * which case the timer will only expire once unless it is manually restarted. + * + * @param xTimer The handle of the timer being queried. + * + * @return If the timer is an auto-reload timer then pdTRUE is returned, otherwise + * pdFALSE is returned. + */ +UBaseType_t uxTimerGetReloadMode( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /** * TickType_t xTimerGetPeriod( TimerHandle_t xTimer ); @@ -1213,18 +1301,18 @@ void vTimerSetReloadMode( TimerHandle_t xTimer, const UBaseType_t uxAutoReload ) TickType_t xTimerGetPeriod( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /** -* TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer ); -* -* 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 ); + * + * 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; /** @cond */ @@ -1234,16 +1322,46 @@ TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; * for use by the kernel only. */ 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; +BaseType_t xTimerGenericCommand( TimerHandle_t xTimer, + const BaseType_t xCommandID, + const TickType_t xOptionalValue, + BaseType_t * const pxHigherPriorityTaskWoken, + const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; -#if( configUSE_TRACE_FACILITY == 1 ) - void vTimerSetTimerNumber( TimerHandle_t xTimer, UBaseType_t uxTimerNumber ) PRIVILEGED_FUNCTION; - UBaseType_t uxTimerGetTimerNumber( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; +#if ( configUSE_TRACE_FACILITY == 1 ) + void vTimerSetTimerNumber( TimerHandle_t xTimer, + UBaseType_t uxTimerNumber ) PRIVILEGED_FUNCTION; + UBaseType_t uxTimerGetTimerNumber( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; #endif /** @endcond */ +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + + /** + * @cond + * task.h + * @code{c} + * void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, StackType_t ** ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize ) + * @endcode + * @endcond + * + * This function is used to provide a statically allocated block of memory to FreeRTOS to hold the Timer Task TCB. This function is required when + * configSUPPORT_STATIC_ALLOCATION is set. For more information see this URI: https://www.FreeRTOS.org/a00110.html#configSUPPORT_STATIC_ALLOCATION + * + * @param ppxTimerTaskTCBBuffer A handle to a statically allocated TCB buffer + * @param ppxTimerTaskStackBuffer A handle to a statically allocated Stack buffer for thie idle task + * @param pulTimerTaskStackSize A pointer to the number of elements that will fit in the allocated stack buffer + */ + void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, + StackType_t ** ppxTimerTaskStackBuffer, + uint32_t * pulTimerTaskStackSize ); + +#endif + +/* *INDENT-OFF* */ #ifdef __cplusplus -} + } #endif +/* *INDENT-ON* */ #endif /* TIMERS_H */ diff --git a/tools/sdk/esp32s2/include/freertos/port/xtensa/include/freertos/FreeRTOSConfig.h b/tools/sdk/esp32s2/include/freertos/port/xtensa/include/freertos/FreeRTOSConfig_arch.h similarity index 100% rename from tools/sdk/esp32s2/include/freertos/port/xtensa/include/freertos/FreeRTOSConfig.h rename to tools/sdk/esp32s2/include/freertos/port/xtensa/include/freertos/FreeRTOSConfig_arch.h diff --git a/tools/sdk/esp32s2/include/freertos/port/xtensa/include/freertos/portmacro.h b/tools/sdk/esp32s2/include/freertos/port/xtensa/include/freertos/portmacro.h index eeabdf786a9..248c86d15c7 100644 --- a/tools/sdk/esp32s2/include/freertos/port/xtensa/include/freertos/portmacro.h +++ b/tools/sdk/esp32s2/include/freertos/port/xtensa/include/freertos/portmacro.h @@ -1,5 +1,5 @@ /* - * FreeRTOS Kernel V10.2.1 + * FreeRTOS Kernel V10.4.3 * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of diff --git a/tools/sdk/esp32s2/include/freertos/port/xtensa/include/freertos/xtensa_rtos.h b/tools/sdk/esp32s2/include/freertos/port/xtensa/include/freertos/xtensa_rtos.h index d1b40237990..b7793d68038 100644 --- a/tools/sdk/esp32s2/include/freertos/port/xtensa/include/freertos/xtensa_rtos.h +++ b/tools/sdk/esp32s2/include/freertos/port/xtensa/include/freertos/xtensa_rtos.h @@ -50,6 +50,7 @@ Should be included by all Xtensa generic and RTOS port-specific sources. #include #include +#include "sdkconfig.h" /* Include any RTOS specific definitions that are needed by this header. @@ -145,7 +146,9 @@ May be coded in or called from C or assembly, per ABI conventions. RTOS may optionally define XT_TICK_PER_SEC in its own way (eg. macro). */ // void XT_RTOS_TIMER_INT(void) +#ifdef CONFIG_FREERTOS_SYSTICK_USES_CCOUNT #define XT_RTOS_TIMER_INT _frxt_timer_int +#endif #define XT_TICK_PER_SEC configTICK_RATE_HZ /* diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/adc_hal.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/adc_hal.h index ac80417ff39..a49618f07c7 100644 --- a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/adc_hal.h +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/adc_hal.h @@ -197,23 +197,6 @@ void adc_hal_digi_monitor_config(adc_ll_num_t adc_n, adc_digi_monitor_t *config) */ #define adc_hal_rtc_reset() adc_ll_rtc_reset() -/*--------------------------------------------------------------- - Common setting ----------------------------------------------------------------*/ - -/** - * Config ADC2 module arbiter. - * The arbiter is to improve the use efficiency of ADC2. After the control right is robbed by the high priority, - * the low priority controller will read the invalid ADC2 data, and the validity of the data can be judged by the flag bit in the data. - * - * @note Only ADC2 support arbiter. - * @note The arbiter's working clock is APB_CLK. When the APB_CLK clock drops below 8 MHz, the arbiter must be in shield mode. - * @note Default priority: Wi-Fi > RTC > Digital; - * - * @param config Refer to ``adc_arbiter_t``. - */ -void adc_hal_arbiter_config(adc_arbiter_t *config); - #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/adc_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/adc_ll.h index ffad47a5c34..a44f50915f1 100644 --- a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/adc_ll.h +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/adc_ll.h @@ -1,9 +1,11 @@ #pragma once #include +#include "hal/misc.h" #include "soc/adc_periph.h" #include "hal/adc_types.h" #include "soc/apb_saradc_struct.h" +#include "soc/sens_struct.h" #include "soc/apb_saradc_reg.h" #include "soc/rtc_cntl_struct.h" #include "soc/rtc_cntl_reg.h" @@ -83,11 +85,11 @@ typedef enum { static inline void adc_ll_digi_set_fsm_time(uint32_t rst_wait, uint32_t start_wait, uint32_t standby_wait) { // Internal FSM reset wait time - APB_SARADC.fsm_wait.rstb_wait = rst_wait; + HAL_FORCE_MODIFY_U32_REG_FIELD(APB_SARADC.fsm_wait, rstb_wait, rst_wait); // Internal FSM start wait time - APB_SARADC.fsm_wait.xpd_wait = start_wait; + HAL_FORCE_MODIFY_U32_REG_FIELD(APB_SARADC.fsm_wait, xpd_wait, start_wait); // Internal FSM standby wait time - APB_SARADC.fsm_wait.standby_wait = standby_wait; + HAL_FORCE_MODIFY_U32_REG_FIELD(APB_SARADC.fsm_wait, standby_wait, standby_wait); } /** @@ -115,7 +117,7 @@ static inline void adc_ll_set_sample_cycle(uint32_t sample_cycle) static inline void adc_ll_digi_set_clk_div(uint32_t div) { /* ADC clock devided from digital controller clock clk */ - APB_SARADC.ctrl.sar_clk_div = div; + HAL_FORCE_MODIFY_U32_REG_FIELD(APB_SARADC.ctrl, sar_clk_div, div); } /** @@ -136,7 +138,7 @@ static inline void adc_ll_digi_set_output_format(adc_digi_output_format_t format */ static inline void adc_ll_digi_set_convert_limit_num(uint32_t meas_num) { - APB_SARADC.ctrl2.max_meas_num = meas_num; + HAL_FORCE_MODIFY_U32_REG_FIELD(APB_SARADC.ctrl2, max_meas_num, meas_num); } /** @@ -307,7 +309,7 @@ static inline void adc_ll_digi_trigger_disable(void) */ static inline void adc_ll_digi_controller_clk_div(uint32_t div_num, uint32_t div_b, uint32_t div_a) { - APB_SARADC.apb_adc_clkm_conf.clkm_div_num = div_num; + HAL_FORCE_MODIFY_U32_REG_FIELD(APB_SARADC.apb_adc_clkm_conf, clkm_div_num, div_num); APB_SARADC.apb_adc_clkm_conf.clkm_div_b = div_b; APB_SARADC.apb_adc_clkm_conf.clkm_div_a = div_a; } @@ -427,9 +429,9 @@ static inline void adc_ll_digi_filter_enable(adc_ll_num_t adc_n, bool enable) static inline uint32_t adc_ll_digi_filter_read_data(adc_ll_num_t adc_n) { if (adc_n == ADC_NUM_1) { - return APB_SARADC.filter_status.adc1_filter_data; + return HAL_FORCE_READ_U32_REG_FIELD(APB_SARADC.filter_status, adc1_filter_data); } else { // adc_n == ADC_NUM_2 - return APB_SARADC.filter_status.adc2_filter_data; + return HAL_FORCE_READ_U32_REG_FIELD(APB_SARADC.filter_status, adc2_filter_data); } } @@ -595,7 +597,7 @@ static inline uint32_t adc_ll_digi_get_intr_status(adc_ll_num_t adc_n) */ static inline void adc_ll_digi_dma_set_eof_num(uint32_t num) { - APB_SARADC.dma_conf.apb_adc_eof_num = num; + HAL_FORCE_MODIFY_U32_REG_FIELD(APB_SARADC.dma_conf, apb_adc_eof_num, num); } /** @@ -710,7 +712,7 @@ static inline void adc_ll_rtc_disable_channel(adc_ll_num_t adc_n) static inline void adc_ll_rtc_start_convert(adc_ll_num_t adc_n, int channel) { if (adc_n == ADC_NUM_1) { - while (SENS.sar_slave_addr1.meas_status != 0); + while (HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_slave_addr1, meas_status) != 0) {} SENS.sar_meas1_ctrl2.meas1_start_sar = 0; SENS.sar_meas1_ctrl2.meas1_start_sar = 1; } else { // adc_n == ADC_NUM_2 @@ -749,9 +751,9 @@ static inline int adc_ll_rtc_get_convert_value(adc_ll_num_t adc_n) { int ret_val = 0; if (adc_n == ADC_NUM_1) { - ret_val = SENS.sar_meas1_ctrl2.meas1_data_sar; + ret_val = HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_meas1_ctrl2, meas1_data_sar); } else { // adc_n == ADC_NUM_2 - ret_val = SENS.sar_meas2_ctrl2.meas2_data_sar; + ret_val = HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_meas2_ctrl2, meas2_data_sar); } return ret_val; } @@ -906,9 +908,9 @@ static inline adc_ll_power_t adc_ll_get_power_manage(void) static inline void adc_ll_set_sar_clk_div(adc_ll_num_t adc_n, uint32_t div) { if (adc_n == ADC_NUM_1) { - SENS.sar_reader1_ctrl.sar1_clk_div = div; + HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.sar_reader1_ctrl, sar1_clk_div, div); } else { // adc_n == ADC_NUM_2 - SENS.sar_reader2_ctrl.sar2_clk_div = div; + HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.sar_reader2_ctrl, sar2_clk_div, div); } } diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/aes_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/aes_ll.h index 9056216517d..653253d06d3 100644 --- a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/aes_ll.h +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/aes_ll.h @@ -1,4 +1,4 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD +// Copyright 2020-2021 Espressif Systems (Shanghai) CO LTD // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ #pragma once #include +#include #include "soc/hwcrypto_reg.h" #include "hal/aes_types.h" @@ -46,10 +47,11 @@ static inline uint8_t aes_ll_write_key(const uint8_t *key, size_t key_word_len) { /* This variable is used for fault injection checks, so marked volatile to avoid optimisation */ volatile uint8_t key_in_hardware = 0; - uint32_t *key_words = (uint32_t *)key; - + /* Memcpy to avoid potential unaligned access */ + uint32_t key_word; for (int i = 0; i < key_word_len; i++) { - REG_WRITE(AES_KEY_BASE + i * 4, *(key_words + i)); + memcpy(&key_word, key + 4 * i, 4); + REG_WRITE(AES_KEY_BASE + i * 4, key_word); key_in_hardware += 4; } return key_in_hardware; @@ -77,22 +79,12 @@ static inline void aes_ll_set_mode(int mode, uint8_t key_bytes) */ static inline void aes_ll_write_block(const void *input) { - const uint32_t *input_words = (const uint32_t *)input; - uint32_t i0, i1, i2, i3; - - /* Storing i0,i1,i2,i3 in registers not an array - helps a lot with optimisations at -Os level */ - i0 = input_words[0]; - REG_WRITE(AES_TEXT_IN_BASE, i0); - - i1 = input_words[1]; - REG_WRITE(AES_TEXT_IN_BASE + 4, i1); + uint32_t input_word; - i2 = input_words[2]; - REG_WRITE(AES_TEXT_IN_BASE + 8, i2); - - i3 = input_words[3]; - REG_WRITE(AES_TEXT_IN_BASE + 12, i3); + for (int i = 0; i < AES_BLOCK_WORDS; i++) { + memcpy(&input_word, (uint8_t*)input + 4 * i, 4); + REG_WRITE(AES_TEXT_IN_BASE + i * 4, input_word); + } } /** @@ -102,11 +94,13 @@ static inline void aes_ll_write_block(const void *input) */ static inline void aes_ll_read_block(void *output) { - uint32_t *output_words = (uint32_t *)output; + uint32_t output_word; const size_t REG_WIDTH = sizeof(uint32_t); for (size_t i = 0; i < AES_BLOCK_WORDS; i++) { - output_words[i] = REG_READ(AES_TEXT_OUT_BASE + (i * REG_WIDTH)); + output_word = REG_READ(AES_TEXT_OUT_BASE + (i * REG_WIDTH)); + /* Memcpy to avoid potential unaligned access */ + memcpy( (uint8_t*)output + i * 4, &output_word, sizeof(output_word)); } } @@ -190,11 +184,13 @@ static inline void aes_ll_set_num_blocks(size_t num_blocks) */ static inline void aes_ll_set_iv(const uint8_t *iv) { - uint32_t *iv_words = (uint32_t *)iv; uint32_t *reg_addr_buf = (uint32_t *)(AES_IV_BASE); + uint32_t iv_word; for (int i = 0; i < IV_WORDS; i++ ) { - REG_WRITE(®_addr_buf[i], iv_words[i]); + /* Memcpy to avoid potential unaligned access */ + memcpy(&iv_word, iv + 4 * i, sizeof(iv_word)); + REG_WRITE(®_addr_buf[i], iv_word); } } @@ -203,11 +199,13 @@ static inline void aes_ll_set_iv(const uint8_t *iv) */ static inline void aes_ll_read_iv(uint8_t *iv) { - uint32_t *iv_words = (uint32_t *)iv; + uint32_t iv_word; const size_t REG_WIDTH = sizeof(uint32_t); for (size_t i = 0; i < IV_WORDS; i++) { - iv_words[i] = REG_READ(AES_IV_BASE + (i * REG_WIDTH)); + iv_word = REG_READ(AES_IV_BASE + (i * REG_WIDTH)); + /* Memcpy to avoid potential unaligned access */ + memcpy(iv + i * 4, &iv_word, sizeof(iv_word)); } } @@ -247,13 +245,14 @@ static inline void aes_ll_interrupt_clear(void) */ static inline void aes_ll_gcm_read_hash(uint8_t *gcm_hash) { - uint32_t *hash_words = (uint32_t *)gcm_hash; const size_t REG_WIDTH = sizeof(uint32_t); + uint32_t hash_word; for (size_t i = 0; i < AES_BLOCK_WORDS; i++) { - hash_words[i] = REG_READ(AES_H_BASE + (i * REG_WIDTH)); + hash_word = REG_READ(AES_H_BASE + (i * REG_WIDTH)); + /* Memcpy to avoid potential unaligned access */ + memcpy(gcm_hash + i * 4, &hash_word, sizeof(hash_word)); } - } /** @@ -277,11 +276,13 @@ static inline void aes_ll_gcm_set_aad_num_blocks(size_t aad_num_blocks) */ static inline void aes_ll_gcm_set_j0(const uint8_t *j0) { - uint32_t *j0_words = (uint32_t *)j0; uint32_t *reg_addr_buf = (uint32_t *)(AES_J_BASE); + uint32_t j0_word; for (int i = 0; i < AES_BLOCK_WORDS; i++ ) { - REG_WRITE(®_addr_buf[i], j0_words[i]); + /* Memcpy to avoid potential unaligned access */ + memcpy(&j0_word, j0 + 4 * i, sizeof(j0_word)); + REG_WRITE(®_addr_buf[i], j0_word); } } @@ -304,11 +305,13 @@ static inline void aes_ll_gcm_set_num_valid_bit(size_t num_valid_bits) */ static inline void aes_ll_gcm_read_tag(uint8_t *tag) { - uint32_t *tag_words = (uint32_t *)tag; + uint32_t tag_word; const size_t REG_WIDTH = sizeof(uint32_t); for (size_t i = 0; i < TAG_WORDS; i++) { - tag_words[i] = REG_READ(AES_T_BASE + (i * REG_WIDTH)); + tag_word = REG_READ(AES_T_BASE + (i * REG_WIDTH)); + /* Memcpy to avoid potential unaligned access */ + memcpy(tag + i * 4, &tag_word, sizeof(tag_word)); } } diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/clk_gate_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/clk_gate_ll.h index ab0e04dee6b..7a2bbe6cf21 100644 --- a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/clk_gate_ll.h +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/clk_gate_ll.h @@ -43,8 +43,6 @@ static inline uint32_t periph_ll_get_clk_en_mask(periph_module_t periph) return DPORT_I2C_EXT1_CLK_EN; case PERIPH_I2S0_MODULE: return DPORT_I2S0_CLK_EN; - case PERIPH_I2S1_MODULE: - return DPORT_I2S1_CLK_EN; case PERIPH_TIMG0_MODULE: return DPORT_TIMERGROUP_CLK_EN; case PERIPH_TIMG1_MODULE: @@ -115,8 +113,6 @@ static inline uint32_t periph_ll_get_rst_en_mask(periph_module_t periph, bool en return DPORT_I2C_EXT1_RST; case PERIPH_I2S0_MODULE: return DPORT_I2S0_RST; - case PERIPH_I2S1_MODULE: - return DPORT_I2S1_RST; case PERIPH_TIMG0_MODULE: return DPORT_TIMERGROUP_RST; case PERIPH_TIMG1_MODULE: diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/dac_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/dac_ll.h index 11f3284f110..28c8ae2066e 100644 --- a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/dac_ll.h +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/dac_ll.h @@ -21,9 +21,12 @@ #pragma once #include +#include "hal/misc.h" #include "soc/dac_periph.h" #include "hal/dac_types.h" #include "soc/apb_saradc_struct.h" +#include "soc/sens_struct.h" +#include "soc/rtc_io_struct.h" #include "soc/apb_saradc_reg.h" #ifdef __cplusplus @@ -74,10 +77,10 @@ static inline void dac_ll_update_output_value(dac_channel_t channel, uint8_t val { if (channel == DAC_CHANNEL_1) { SENS.sar_dac_ctrl2.dac_cw_en1 = 0; - RTCIO.pad_dac[channel].dac = value; + HAL_FORCE_MODIFY_U32_REG_FIELD(RTCIO.pad_dac[channel], dac, value); } else if (channel == DAC_CHANNEL_2) { SENS.sar_dac_ctrl2.dac_cw_en2 = 0; - RTCIO.pad_dac[channel].dac = value; + HAL_FORCE_MODIFY_U32_REG_FIELD(RTCIO.pad_dac[channel], dac, value); } } @@ -145,7 +148,7 @@ static inline void dac_ll_cw_set_channel(dac_channel_t channel, bool enable) static inline void dac_ll_cw_set_freq(uint32_t freq) { uint32_t sw_freq = freq * 0xFFFF / RTC_FAST_CLK_FREQ_APPROX; - SENS.sar_dac_ctrl1.sw_fstep = (sw_freq > 0xFFFF) ? 0xFFFF : sw_freq; + HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.sar_dac_ctrl1, sw_fstep, (sw_freq > 0xFFFF) ? 0xFFFF : sw_freq); } /** @@ -192,12 +195,12 @@ static inline void dac_ll_cw_set_dc_offset(dac_channel_t channel, int8_t offset) if (SENS.sar_dac_ctrl2.dac_inv1 == DAC_CW_PHASE_180) { offset = 0 - offset; } - SENS.sar_dac_ctrl2.dac_dc1 = offset ? offset : (-128 - offset); + HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.sar_dac_ctrl2, dac_dc1, offset ? offset : (-128 - offset)); } else if (channel == DAC_CHANNEL_2) { if (SENS.sar_dac_ctrl2.dac_inv2 == DAC_CW_PHASE_180) { offset = 0 - offset; } - SENS.sar_dac_ctrl2.dac_dc2 = offset ? offset : (-128 - offset); + HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.sar_dac_ctrl2, dac_dc2, offset ? offset : (-128 - offset)); } } diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/dedic_gpio_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/dedic_gpio_ll.h index 3cbf29b7bb5..8fcdd0e7a60 100644 --- a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/dedic_gpio_ll.h +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/dedic_gpio_ll.h @@ -19,6 +19,7 @@ extern "C" { #include #include +#include "hal/misc.h" #include "soc/dedic_gpio_struct.h" static inline void dedic_gpio_ll_enable_instruction_access_out(dedic_dev_t *dev, uint32_t channel_mask, bool enable) @@ -61,12 +62,12 @@ static inline void dedic_gpio_ll_toggle_channel(dedic_dev_t *dev, uint32_t chann static inline uint32_t dedic_gpio_ll_read_out_all(dedic_dev_t *dev) { - return dev->gpio_out_scan.gpio_out_status; + return HAL_FORCE_READ_U32_REG_FIELD(dev->gpio_out_scan, gpio_out_status); } static inline uint32_t dedic_gpio_ll_read_in_all(dedic_dev_t *dev) { - return dev->gpio_in_scan.gpio_in_status; + return HAL_FORCE_READ_U32_REG_FIELD(dev->gpio_in_scan, gpio_in_status); } static inline void dedic_gpio_ll_set_input_delay(dedic_dev_t *dev, uint32_t channel, uint32_t delay_cpu_clks) diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/gpio_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/gpio_ll.h index d6330db630d..34cdc464bcb 100644 --- a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/gpio_ll.h +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/gpio_ll.h @@ -26,6 +26,7 @@ #include "soc/gpio_periph.h" #include "soc/rtc_cntl_reg.h" #include "soc/rtc_io_reg.h" +#include "soc/gpio_struct.h" #include "hal/gpio_types.h" #ifdef __cplusplus diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/gpspi_flash_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/gpspi_flash_ll.h index 44612385b33..79fc727bdd9 100644 --- a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/gpspi_flash_ll.h +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/gpspi_flash_ll.h @@ -24,11 +24,13 @@ #include #include "soc/spi_periph.h" +#include "soc/spi_struct.h" #include "hal/spi_types.h" #include "hal/spi_flash_types.h" #include // For MIN/MAX #include #include +#include "hal/misc.h" #ifdef __cplusplus extern "C" { @@ -147,6 +149,16 @@ static inline void gpspi_flash_ll_user_start(spi_dev_t *dev) dev->cmd.usr = 1; } +/** + * Set HD pin high when flash work at spi mode. + * + * @param dev Beginning address of the peripheral registers. + */ +static inline void gpspi_flash_ll_set_hold_pol(spi_dev_t *dev, uint32_t pol_val) +{ + // Not support on esp32s2 +} + /** * Check whether the host is idle to perform new commands. * @@ -347,7 +359,7 @@ static inline void gpspi_flash_ll_set_address(spi_dev_t *dev, uint32_t addr) static inline void gpspi_flash_ll_set_dummy(spi_dev_t *dev, uint32_t dummy_n) { dev->user.usr_dummy = dummy_n ? 1 : 0; - dev->user1.usr_dummy_cyclelen = dummy_n - 1; + HAL_FORCE_MODIFY_U32_REG_FIELD(dev->user1, usr_dummy_cyclelen, dummy_n - 1); } /** diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/i2c_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/i2c_ll.h index 81fb326b552..1d2b8a0c137 100644 --- a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/i2c_ll.h +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/i2c_ll.h @@ -16,6 +16,7 @@ #pragma once #include "soc/i2c_periph.h" +#include "soc/i2c_struct.h" #include "hal/i2c_types.h" #ifdef __cplusplus diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/i2s_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/i2s_ll.h index 3e0a7eeb207..6f453221eec 100644 --- a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/i2s_ll.h +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/i2s_ll.h @@ -1,4 +1,4 @@ -// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD +// Copyright 2020 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. @@ -23,7 +23,9 @@ #pragma once #include +#include "hal/misc.h" #include "soc/i2s_periph.h" +#include "soc/i2s_struct.h" #include "hal/i2s_types.h" #ifdef __cplusplus @@ -31,348 +33,434 @@ extern "C" { #endif // Get I2S hardware instance with giving i2s num -#define I2S_LL_GET_HW(num) (((num) == 0) ? (&I2S0) : NULL) +#define I2S_LL_GET_HW(num) (((num) == 0) ? (&I2S0) : NULL) -#define I2S_INTR_IN_SUC_EOF BIT(9) -#define I2S_INTR_OUT_EOF BIT(12) -#define I2S_INTR_IN_DSCR_ERR BIT(13) -#define I2S_INTR_OUT_DSCR_ERR BIT(14) -#define I2S_INTR_MAX (0xFFFFFFFF) +#define I2S_LL_BASE_CLK (2 * APB_CLK_FREQ) + +#define I2S_LL_MCLK_DIVIDER_BIT_WIDTH (6) +#define I2S_LL_MCLK_DIVIDER_MAX ((1 << I2S_LL_MCLK_DIVIDER_BIT_WIDTH) - 1) + +/* I2S clock configuration structure */ +typedef struct { + uint16_t mclk_div; // I2S module clock devider, Fmclk = Fsclk /(mclk_div+b/a) + uint16_t a; + uint16_t b; // The decimal part of module clock devider, the decimal is: b/a +} i2s_ll_mclk_div_t; + +#define I2S_LL_EVENT_TX_EOF (1 << 12) +#define I2S_LL_BCK_MAX_PRESCALE (64) /** - * @brief Reset rx fifo + * @brief Enable DMA descriptor owner check * * @param hw Peripheral I2S hardware instance address. + * @param en whether to enable owner check */ -static inline void i2s_ll_reset_rx_fifo(i2s_dev_t *hw) +static inline void i2s_ll_dma_enable_owner_check(i2s_dev_t *hw, bool en) { - hw->conf.rx_fifo_reset = 1; - hw->conf.rx_fifo_reset = 0; + hw->lc_conf.check_owner = en; } /** - * @brief Reset tx fifo + * @brief Enable DMA descriptor write back * * @param hw Peripheral I2S hardware instance address. + * @param en whether to enable write back */ -static inline void i2s_ll_reset_tx_fifo(i2s_dev_t *hw) +static inline void i2s_ll_dma_enable_auto_write_back(i2s_dev_t *hw, bool en) { - hw->conf.tx_fifo_reset = 1; - hw->conf.tx_fifo_reset = 0; + hw->lc_conf.out_auto_wrback = en; } /** - * @brief Enable rx interrupt + * @brief I2S DMA generate EOF event on data in FIFO poped out * * @param hw Peripheral I2S hardware instance address. + * @param en True to enable, False to disable */ -static inline void i2s_ll_enable_rx_intr(i2s_dev_t *hw) +static inline void i2s_ll_dma_enable_eof_on_fifo_empty(i2s_dev_t *hw, bool en) { - hw->int_ena.in_suc_eof = 1; - hw->int_ena.in_dscr_err = 1; + hw->lc_conf.out_eof_mode = en; } /** - * @brief Disable rx interrupt + * @brief I2S module general init, enable I2S clock. * * @param hw Peripheral I2S hardware instance address. */ -static inline void i2s_ll_disable_rx_intr(i2s_dev_t *hw) +static inline void i2s_ll_enable_clock(i2s_dev_t *hw) { - hw->int_ena.in_suc_eof = 0; - hw->int_ena.in_dscr_err = 0; + if (hw->clkm_conf.clk_en == 0) { + hw->clkm_conf.clk_sel = 2; + hw->clkm_conf.clk_en = 1; + hw->conf2.val = 0; + } } /** - * @brief Disable tx interrupt + * @brief I2S module disable clock. * * @param hw Peripheral I2S hardware instance address. */ -static inline void i2s_ll_disable_tx_intr(i2s_dev_t *hw) +static inline void i2s_ll_disable_clock(i2s_dev_t *hw) { - hw->int_ena.out_eof = 0; - hw->int_ena.out_dscr_err = 0; + if (hw->clkm_conf.clk_en == 1) { + hw->clkm_conf.clk_en = 0; + } } /** - * @brief Enable tx interrupt + * @brief I2S tx msb right enable * * @param hw Peripheral I2S hardware instance address. + * @param enable Set true to enable tx msb right */ -static inline void i2s_ll_enable_tx_intr(i2s_dev_t *hw) +static inline void i2s_ll_tx_enable_msb_right(i2s_dev_t *hw, bool enable) { - hw->int_ena.out_eof = 1; - hw->int_ena.out_dscr_err = 1; + hw->conf.tx_msb_right = enable; } /** - * @brief Reset dma in + * @brief I2S rx msb right enable * * @param hw Peripheral I2S hardware instance address. + * @param enable Set true to enable rx msb right */ -static inline void i2s_ll_reset_dma_in(i2s_dev_t *hw) +static inline void i2s_ll_rx_enable_msb_right(i2s_dev_t *hw, bool enable) { - hw->lc_conf.in_rst = 1; - hw->lc_conf.in_rst = 0; + hw->conf.rx_msb_right = enable; } /** - * @brief Reset dma out + * @brief I2S tx right channel first * * @param hw Peripheral I2S hardware instance address. + * @param enable Set true to enable send right channel first */ -static inline void i2s_ll_reset_dma_out(i2s_dev_t *hw) +static inline void i2s_ll_tx_enable_right_first(i2s_dev_t *hw, bool enable) { - hw->lc_conf.out_rst = 1; - hw->lc_conf.out_rst = 0; + hw->conf.tx_right_first = enable; +} + +/** + * @brief I2S rx right channel first + * + * @param hw Peripheral I2S hardware instance address. + * @param enable Set true to enable receive right channel first + */ +static inline void i2s_ll_rx_enable_right_first(i2s_dev_t *hw, bool enable) +{ + hw->conf.rx_right_first = enable; +} + +/** + * @brief I2S tx fifo module force enable + * + * @param hw Peripheral I2S hardware instance address. + * @param enable Set true to enable tx fifo module + */ +static inline void i2s_ll_tx_force_enable_fifo_mod(i2s_dev_t *hw, bool enable) +{ + hw->fifo_conf.tx_fifo_mod_force_en = enable; +} + +/** + * @brief I2S rx fifo module force enable + * + * @param hw Peripheral I2S hardware instance address. + * @param enable Set true to enable rx fifo module + */ +static inline void i2s_ll_rx_force_enable_fifo_mod(i2s_dev_t *hw, bool enable) +{ + hw->fifo_conf.rx_fifo_mod_force_en = enable; +} + +/** + * @brief Enable I2S TX slave mode + * + * @param hw Peripheral I2S hardware instance address. + * @param slave_en Set true to enable slave mode + */ +static inline void i2s_ll_tx_set_slave_mod(i2s_dev_t *hw, bool slave_en) +{ + hw->conf.tx_slave_mod = slave_en; +} + +/** + * @brief Enable I2S RX slave mode + * + * @param hw Peripheral I2S hardware instance address. + * @param slave_en Set true to enable slave mode + */ +static inline void i2s_ll_rx_set_slave_mod(i2s_dev_t *hw, bool slave_en) +{ + hw->conf.rx_slave_mod = slave_en; } /** - * @brief Reset tx + * @brief Reset TX module * * @param hw Peripheral I2S hardware instance address. */ -static inline void i2s_ll_reset_tx(i2s_dev_t *hw) +static inline void i2s_ll_tx_reset(i2s_dev_t *hw) { hw->conf.tx_reset = 1; hw->conf.tx_reset = 0; } /** - * @brief Reset rx + * @brief Reset RX module * * @param hw Peripheral I2S hardware instance address. */ -static inline void i2s_ll_reset_rx(i2s_dev_t *hw) +static inline void i2s_ll_rx_reset(i2s_dev_t *hw) { hw->conf.rx_reset = 1; hw->conf.rx_reset = 0; } /** - * @brief Start out link + * @brief Reset TX FIFO * * @param hw Peripheral I2S hardware instance address. */ -static inline void i2s_ll_start_out_link(i2s_dev_t *hw) +static inline void i2s_ll_tx_reset_fifo(i2s_dev_t *hw) { - hw->out_link.start = 1; + hw->conf.tx_fifo_reset = 1; + hw->conf.tx_fifo_reset = 0; } /** - * @brief Start tx + * @brief Reset RX FIFO * * @param hw Peripheral I2S hardware instance address. */ -static inline void i2s_ll_start_tx(i2s_dev_t *hw) +static inline void i2s_ll_rx_reset_fifo(i2s_dev_t *hw) { - hw->conf.tx_start = 1; + hw->conf.rx_fifo_reset = 1; + hw->conf.rx_fifo_reset = 0; } /** - * @brief Start in link + * @brief Set TX source clock * * @param hw Peripheral I2S hardware instance address. + * @param src I2S source clock */ -static inline void i2s_ll_start_in_link(i2s_dev_t *hw) +static inline void i2s_ll_tx_clk_set_src(i2s_dev_t *hw, i2s_clock_src_t src) { - hw->in_link.start = 1; + hw->clkm_conf.clk_sel = (src == I2S_CLK_APLL) ? 1 : 2; } /** - * @brief Start rx + * @brief Set RX source clock * * @param hw Peripheral I2S hardware instance address. + * @param src I2S source clock */ -static inline void i2s_ll_start_rx(i2s_dev_t *hw) +static inline void i2s_ll_rx_clk_set_src(i2s_dev_t *hw, i2s_clock_src_t src) { - hw->conf.rx_start = 1; + hw->clkm_conf.clk_sel = (src == I2S_CLK_APLL) ? 1 : 2; } /** - * @brief Stop out link + * @brief Set I2S tx bck div num * * @param hw Peripheral I2S hardware instance address. + * @param val value to set tx bck div num */ -static inline void i2s_ll_stop_out_link(i2s_dev_t *hw) +static inline void i2s_ll_tx_set_bck_div_num(i2s_dev_t *hw, uint32_t val) { - hw->out_link.stop = 1; + hw->sample_rate_conf.tx_bck_div_num = val; } /** - * @brief Stop tx + * @brief Configure I2S TX clock devider * * @param hw Peripheral I2S hardware instance address. + * @param set Pointer to I2S clock devider configuration paramater */ -static inline void i2s_ll_stop_tx(i2s_dev_t *hw) +static inline void i2s_ll_tx_set_clk(i2s_dev_t *hw, i2s_ll_mclk_div_t *set) { - hw->conf.tx_start = 0; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->clkm_conf, clkm_div_num, set->mclk_div); + hw->clkm_conf.clkm_div_b = set->b; + hw->clkm_conf.clkm_div_a = set->a; } /** - * @brief Stop in link + * @brief Set I2S rx bck div num * * @param hw Peripheral I2S hardware instance address. + * @param val value to set rx bck div num */ -static inline void i2s_ll_stop_in_link(i2s_dev_t *hw) +static inline void i2s_ll_rx_set_bck_div_num(i2s_dev_t *hw, uint32_t val) { - hw->in_link.stop = 1; + hw->sample_rate_conf.rx_bck_div_num = val; } /** - * @brief Stop rx + * @brief Configure I2S RX clock devider * * @param hw Peripheral I2S hardware instance address. + * @param set Pointer to I2S clock devider configuration paramater */ -static inline void i2s_ll_stop_rx(i2s_dev_t *hw) +static inline void i2s_ll_rx_set_clk(i2s_dev_t *hw, i2s_ll_mclk_div_t *set) { - hw->conf.rx_start = 0; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->clkm_conf, clkm_div_num, set->mclk_div); + hw->clkm_conf.clkm_div_b = set->b; + hw->clkm_conf.clkm_div_a = set->a; } /** - * @brief Enable dma + * @brief Enable interrupt by mask * * @param hw Peripheral I2S hardware instance address. + * @param mask Interrupt event mask + * @param en true to enable, false to disable */ -static inline void i2s_ll_enable_dma(i2s_dev_t *hw) +static inline void i2s_ll_enable_intr(i2s_dev_t *hw, uint32_t mask, bool en) { - //Enable and configure DMA - typeof(hw->lc_conf) lc_conf; - lc_conf.val = 0; - lc_conf.out_eof_mode = 1; - hw->lc_conf.val = lc_conf.val; + if (en) { + hw->int_ena.val |= mask; + } else { + hw->int_ena.val &= ~mask; + } } /** - * @brief Get I2S interrupt status + * @brief Enable TX interrupt * * @param hw Peripheral I2S hardware instance address. - * @param val value to get interrupt status */ -static inline void i2s_ll_get_intr_status(i2s_dev_t *hw, uint32_t *val) +static inline void i2s_ll_tx_enable_intr(i2s_dev_t *hw) { - *val = hw->int_st.val; + hw->int_ena.out_eof = 1; + hw->int_ena.out_dscr_err = 1; } /** - * @brief Clear I2S interrupt status + * @brief Disable TX interrupt * * @param hw Peripheral I2S hardware instance address. - * @param val value to clear interrupt status */ -static inline void i2s_ll_clear_intr_status(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_disable_intr(i2s_dev_t *hw) { - hw->int_clr.val = val; + hw->int_ena.out_eof = 0; + hw->int_ena.out_dscr_err = 0; } /** - * @brief Get I2S out eof des address + * @brief Enable RX interrupt * * @param hw Peripheral I2S hardware instance address. - * @param val value to get out eof des address */ -static inline void i2s_ll_get_out_eof_des_addr(i2s_dev_t *hw, uint32_t *val) +static inline void i2s_ll_rx_enable_intr(i2s_dev_t *hw) { - *val = hw->out_eof_des_addr; + hw->int_ena.in_suc_eof = 1; + hw->int_ena.in_dscr_err = 1; } /** - * @brief Get I2S in eof des address + * @brief Disable RX interrupt * * @param hw Peripheral I2S hardware instance address. - * @param val value to get in eof des address */ -static inline void i2s_ll_get_in_eof_des_addr(i2s_dev_t *hw, uint32_t *val) +static inline void i2s_ll_rx_disable_intr(i2s_dev_t *hw) { - *val = hw->in_eof_des_addr; + hw->int_ena.in_suc_eof = 0; + hw->int_ena.in_dscr_err = 0; } /** - * @brief Get I2S tx fifo mode + * @brief Get interrupt status register address * * @param hw Peripheral I2S hardware instance address. - * @param val value to get tx fifo mode + * @return interrupt status register address */ -static inline void i2s_ll_get_tx_fifo_mod(i2s_dev_t *hw, uint32_t *val) +static inline volatile void *i2s_ll_get_intr_status_reg(i2s_dev_t *hw) { - *val = hw->fifo_conf.tx_fifo_mod; + return &hw->int_st; } /** - * @brief Set I2S tx fifo mode + * @brief Get I2S interrupt status * * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx fifo mode + * @return + * - module interrupt status */ -static inline void i2s_ll_set_tx_fifo_mod(i2s_dev_t *hw, uint32_t val) +static inline uint32_t i2s_ll_get_intr_status(i2s_dev_t *hw) { - hw->fifo_conf.tx_fifo_mod = val; + return hw->int_st.val; } /** - * @brief Get I2S rx fifo mode + * @brief Clear I2S interrupt status * * @param hw Peripheral I2S hardware instance address. - * @param val value to get rx fifo mode + * @param clr_mask Interrupt mask to be cleared. */ -static inline void i2s_ll_get_rx_fifo_mod(i2s_dev_t *hw, uint32_t *val) +static inline void i2s_ll_clear_intr_status(i2s_dev_t *hw, uint32_t clr_mask) { - *val = hw->fifo_conf.rx_fifo_mod; + hw->int_clr.val = clr_mask; } /** - * @brief Set I2S rx fifo mode + * @brief Reset dma out * * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx fifo mode */ -static inline void i2s_ll_set_rx_fifo_mod(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_reset_dma(i2s_dev_t *hw) { - hw->fifo_conf.rx_fifo_mod = val; + hw->lc_conf.out_rst = 1; + hw->lc_conf.out_rst = 0; } /** - * @brief Set I2S tx chan mode + * @brief Reset dma in * * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx chan mode */ -static inline void i2s_ll_set_tx_chan_mod(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_reset_dma(i2s_dev_t *hw) { - hw->conf_chan.tx_chan_mod = val; + hw->lc_conf.in_rst = 1; + hw->lc_conf.in_rst = 0; } /** - * @brief Set I2S rx chan mode + * @brief Enable TX PDM mode. + * @note ESP32-S2 doesn't support pdm + * This function is used to be compatible with those support pdm * - * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx chan mode + * @param hw Peripheral I2S hardware instance address (ignored) + * @param pdm_enable Set true to TX enable PDM mode (ignored) */ -static inline void i2s_ll_set_rx_chan_mod(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_enable_pdm(i2s_dev_t *hw, bool pdm_enable) { - hw->conf_chan.rx_chan_mod = val; + // Remain empty } /** - * @brief Set I2S tx dma equal + * @brief Enable RX PDM mode. + * @note ESP32-S2 doesn't support pdm + * This function is used to be compatible with those support pdm * - * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx dma equal + * @param hw Peripheral I2S hardware instance address (ignored) + * @param pdm_enable Set true to RX enable PDM mode (ignored) */ -static inline void i2s_ll_set_tx_dma_equal(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_enable_pdm(i2s_dev_t *hw, bool pdm_enable) { - hw->conf.tx_dma_equal = val; + // Remain empty } /** - * @brief Set I2S rx dma equal + * @brief Start out link * * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx dma equal */ -static inline void i2s_ll_set_rx_dma_equal(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_start_out_link(i2s_dev_t *hw) { - hw->conf.rx_dma_equal = val; + hw->out_link.start = 1; } /** @@ -387,377 +475,394 @@ static inline void i2s_ll_set_out_link_addr(i2s_dev_t *hw, uint32_t val) } /** - * @brief Set I2S in link address + * @brief Start TX module * * @param hw Peripheral I2S hardware instance address. - * @param val value to set in link address */ -static inline void i2s_ll_set_in_link_addr(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_start(i2s_dev_t *hw) { - hw->in_link.addr = val; + hw->conf.tx_start = 1; } /** - * @brief Set I2S rx eof num + * @brief Start RX module * * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx eof num */ -static inline void i2s_ll_set_rx_eof_num(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_start(i2s_dev_t *hw) { - hw->rx_eof_num = val; + hw->conf.rx_start = 1; } /** - * @brief Set I2S clkm div num + * @brief Configure TX DMA descriptor address and start TX DMA * * @param hw Peripheral I2S hardware instance address. - * @param val value to set clkm div num + * @param link_addr DMA descriptor link address. */ -static inline void i2s_ll_set_clkm_div_num(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_start_link(i2s_dev_t *hw, uint32_t link_addr) { - hw->clkm_conf.clkm_div_num = val; + i2s_ll_set_out_link_addr(hw, link_addr); + i2s_ll_start_out_link(hw); } /** - * @brief Set I2S clkm div b + * @brief Configure RX DMA descriptor address and start TX DMA * * @param hw Peripheral I2S hardware instance address. - * @param val value to set clkm div b + * @param link_addr DMA descriptor link address. */ -static inline void i2s_ll_set_clkm_div_b(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_start_link(i2s_dev_t *hw, uint32_t link_addr) { - hw->clkm_conf.clkm_div_b = val; + hw->in_link.addr = link_addr; + hw->in_link.start = 1; } /** - * @brief Set I2S clkm div a + * @brief Stop TX module * * @param hw Peripheral I2S hardware instance address. - * @param val value to set clkm div a */ -static inline void i2s_ll_set_clkm_div_a(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_stop(i2s_dev_t *hw) { - hw->clkm_conf.clkm_div_a = val; + hw->conf.tx_start = 0; } /** - * @brief Set I2S tx bck div num + * @brief Stop RX module * * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx bck div num */ -static inline void i2s_ll_set_tx_bck_div_num(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_stop(i2s_dev_t *hw) { - hw->sample_rate_conf.tx_bck_div_num = val; + hw->conf.rx_start = 0; } /** - * @brief Set I2S rx bck div num + * @brief Stop out link * * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx bck div num */ -static inline void i2s_ll_set_rx_bck_div_num(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_stop_link(i2s_dev_t *hw) { - hw->sample_rate_conf.rx_bck_div_num = val; + hw->out_link.stop = 1; } /** - * @brief Set I2S clk sel + * @brief Stop in link * * @param hw Peripheral I2S hardware instance address. - * @param val value to set clk sel */ -static inline void i2s_ll_set_clk_sel(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_stop_link(i2s_dev_t *hw) { - hw->clkm_conf.clk_sel = (val == 1) ? 1 : 2; + hw->in_link.stop = 1; } /** - * @brief Set I2S tx bits mod + * @brief Get I2S out eof descriptor address * * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx bits mod + * @param eof_addr Pointer to accept out eof des address */ -static inline void i2s_ll_set_tx_bits_mod(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_get_eof_des_addr(i2s_dev_t *hw, uint32_t *eof_addr) { - hw->sample_rate_conf.tx_bits_mod = val; + *eof_addr = hw->out_eof_des_addr; } /** - * @brief Set I2S rx bits mod + * @brief Get I2S in eof descriptor address * * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx bits mod + * @param eof_addr Pointer to accept in eof des address */ -static inline void i2s_ll_set_rx_bits_mod(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_get_eof_des_addr(i2s_dev_t *hw, uint32_t *eof_addr) { - hw->sample_rate_conf.rx_bits_mod = val; + *eof_addr = hw->in_eof_des_addr; } /** - * @brief Set I2S dscr en + * @brief Configure the received length to trigger in_suc_eof interrupt * * @param hw Peripheral I2S hardware instance address. - * @param val value to set dscr en + * @param eof_num the byte length to trigger in_suc_eof interrupt */ -static inline void i2s_ll_set_dscr_en(i2s_dev_t *hw, bool val) +static inline void i2s_ll_rx_set_eof_num(i2s_dev_t *hw, uint32_t eof_num) { - hw->fifo_conf.dscr_en = val; + hw->rx_eof_num = eof_num; } /** - * @brief Set I2S lcd en + * @brief Congfigure TX chan bit and audio data bit, on ESP32-S2, sample_bit should equals to data_bit * * @param hw Peripheral I2S hardware instance address. - * @param val value to set lcd en + * @param chan_bit The chan bit width + * @param data_bit The audio data bit width */ -static inline void i2s_ll_set_lcd_en(i2s_dev_t *hw, bool val) +static inline void i2s_ll_tx_set_sample_bit(i2s_dev_t *hw, uint8_t chan_bit, int data_bit) { - hw->conf2.lcd_en = val; + hw->fifo_conf.tx_fifo_mod = (chan_bit <= I2S_BITS_PER_SAMPLE_16BIT ? 0 : 2); + hw->sample_rate_conf.tx_bits_mod = data_bit; } /** - * @brief Set I2S camera en + * @brief Congfigure RX chan bit and audio data bit, on ESP32-S2, sample_bit should equals to data_bit * * @param hw Peripheral I2S hardware instance address. - * @param val value to set camera en + * @param chan_bit The chan bit width + * @param data_bit The audio data bit width */ -static inline void i2s_ll_set_camera_en(i2s_dev_t *hw, bool val) +static inline void i2s_ll_rx_set_sample_bit(i2s_dev_t *hw, uint8_t chan_bit, int data_bit) { - hw->conf2.camera_en = val; + hw->fifo_conf.rx_fifo_mod = (chan_bit <= I2S_BITS_PER_SAMPLE_16BIT ? 0 : 2); + hw->sample_rate_conf.rx_bits_mod = data_bit; } /** - * @brief Set I2S tx fifo mod force en + * @brief Enable I2S DMA * * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx fifo mod force en + * @param ena Set true to enable DMA */ -static inline void i2s_ll_set_tx_fifo_mod_force_en(i2s_dev_t *hw, bool val) +static inline void i2s_ll_enable_dma(i2s_dev_t *hw, bool ena) { - hw->fifo_conf.tx_fifo_mod_force_en = val; + hw->fifo_conf.dscr_en = ena; } /** - * @brief Set I2S rx fifo mod force en + * @brief Set I2S TX to philip standard * * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx fifo mod force en */ -static inline void i2s_ll_set_rx_fifo_mod_force_en(i2s_dev_t *hw, bool val) +static inline void i2s_ll_tx_set_format_philip(i2s_dev_t *hw) { - hw->fifo_conf.rx_fifo_mod_force_en = val; + hw->conf.tx_short_sync = 0; + hw->conf.tx_msb_shift = 1; } /** - * @brief Set I2S tx right first + * @brief Set I2S RX to philip standard * * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx right first */ -static inline void i2s_ll_set_tx_right_first(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_set_format_philip(i2s_dev_t *hw) { - hw->conf.tx_right_first = val; + hw->conf.rx_short_sync = 0; + hw->conf.rx_msb_shift = 1; } /** - * @brief Set I2S rx right first + * @brief Set I2S TX to MSB Alignment Standard * * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx right first */ -static inline void i2s_ll_set_rx_right_first(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_set_format_msb_align(i2s_dev_t *hw) { - hw->conf.rx_right_first = val; + hw->conf.tx_short_sync = 0; + hw->conf.tx_msb_shift = 0; } /** - * @brief Set I2S tx slave mod + * @brief Set I2S RX to MSB Alignment Standard * * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx slave mod */ -static inline void i2s_ll_set_tx_slave_mod(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_set_format_msb_align(i2s_dev_t *hw) { - hw->conf.tx_slave_mod = val; + hw->conf.rx_short_sync = 0; + hw->conf.rx_msb_shift = 0; } /** - * @brief Set I2S rx slave mod + * @brief Set I2S TX to PCM short standard * * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx slave mod */ -static inline void i2s_ll_set_rx_slave_mod(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_set_pcm_short(i2s_dev_t *hw) { - hw->conf.rx_slave_mod = val; + hw->conf.tx_short_sync = 1; + hw->conf.tx_msb_shift = 0; } /** - * @brief Get I2S tx msb right + * @brief Set I2S RX to PCM short standard * * @param hw Peripheral I2S hardware instance address. - * @param val value to get tx msb right */ -static inline void i2s_ll_get_tx_msb_right(i2s_dev_t *hw, uint32_t *val) +static inline void i2s_ll_rx_set_pcm_short(i2s_dev_t *hw) { - *val = hw->conf.tx_msb_right; + hw->conf.rx_short_sync = 1; + hw->conf.rx_msb_shift = 0; } /** - * @brief Get I2S rx msb right + * @brief Set I2S TX to PCM long standard * * @param hw Peripheral I2S hardware instance address. - * @param val value to get rx msb right */ -static inline void i2s_ll_get_rx_msb_right(i2s_dev_t *hw, uint32_t *val) +static inline void i2s_ll_tx_set_pcm_long(i2s_dev_t *hw) { - *val = hw->conf.rx_msb_right; + hw->conf.tx_short_sync = 0; + hw->conf.tx_msb_shift = 0; } /** - * @brief Set I2S tx msb right + * @brief Set I2S RX to PCM long standard * * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx msb right */ -static inline void i2s_ll_set_tx_msb_right(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_set_pcm_long(i2s_dev_t *hw) { - hw->conf.tx_msb_right = val; + hw->conf.rx_short_sync = 0; + hw->conf.rx_msb_shift = 0; } /** - * @brief Set I2S rx msb right + * @brief Configure TX WS signal width * * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx msb right + * @param width WS width in BCK cycle */ -static inline void i2s_ll_set_rx_msb_right(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_set_ws_width(i2s_dev_t *hw, int width) { - hw->conf.rx_msb_right = val; + hw->conf.tx_short_sync = width == 1 ? 1 : 0; } /** - * @brief Set I2S tx mono + * @brief Configure RX WS signal width * * @param hw Peripheral I2S hardware instance address. - * @param val value to set tx mono + * @param width WS width in BCK cycle */ -static inline void i2s_ll_set_tx_mono(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_set_ws_width(i2s_dev_t *hw, int width) { - hw->conf.tx_mono = val; + hw->conf.rx_short_sync = width == 1 ? 1 : 0; } /** - * @brief Set I2S rx mono + * @brief Enable TX MSB shift, the data will be launch at the first BCK clock * * @param hw Peripheral I2S hardware instance address. - * @param val value to set rx mono + * @param msb_shift_enable Set true to enable MSB shift */ -static inline void i2s_ll_set_rx_mono(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_tx_enable_msb_shift(i2s_dev_t *hw, bool msb_shift_enable) { - hw->conf.rx_mono = val; + hw->conf.tx_msb_shift = msb_shift_enable; } /** - * @brief Set I2S sig loopback + * @brief Enable RX MSB shift, the data will be launch at the first BCK clock * * @param hw Peripheral I2S hardware instance address. - * @param val value to set sig loopback + * @param msb_shift_enable Set true to enable MSB shift */ -static inline void i2s_ll_set_sig_loopback(i2s_dev_t *hw, uint32_t val) +static inline void i2s_ll_rx_enable_msb_shift(i2s_dev_t *hw, bool msb_shift_enable) { - hw->conf.sig_loopback = val; + hw->conf.rx_msb_shift = msb_shift_enable; } /** - * @brief Set I2S TX to philip standard + * @brief Set I2S tx chan mode * * @param hw Peripheral I2S hardware instance address. + * @param val value to set tx chan mode */ -static inline void i2s_ll_set_tx_format_philip(i2s_dev_t *hw) +static inline void i2s_ll_tx_set_chan_mod(i2s_dev_t *hw, uint32_t val) { - hw->conf.tx_short_sync = 0; - hw->conf.tx_msb_shift = 1; + hw->conf_chan.tx_chan_mod = val; } /** - * @brief Set I2S RX to philip standard + * @brief Set I2S tx bits mod * * @param hw Peripheral I2S hardware instance address. + * @param val value to set tx bits mod */ -static inline void i2s_ll_set_rx_format_philip(i2s_dev_t *hw) +static inline void i2s_ll_tx_set_bits_mod(i2s_dev_t *hw, uint32_t val) { - hw->conf.rx_short_sync = 0; - hw->conf.rx_msb_shift = 1; + hw->sample_rate_conf.tx_bits_mod = val; } /** - * @brief Set I2S TX to MSB Alignment Standard + * @brief Set I2S tx dma equal * * @param hw Peripheral I2S hardware instance address. + * @param val value to set tx dma equal */ -static inline void i2s_ll_set_tx_format_msb_align(i2s_dev_t *hw) +static inline void i2s_ll_tx_enable_dma_equal(i2s_dev_t *hw, bool en) { - hw->conf.tx_short_sync = 0; - hw->conf.tx_msb_shift = 0; + hw->conf.tx_dma_equal = en; } /** - * @brief Set I2S RX to MSB Alignment Standard + * @brief Enable TX mono mode * * @param hw Peripheral I2S hardware instance address. + * @param mono_ena Set true to enable mono mde. */ -static inline void i2s_ll_set_rx_format_msb_align(i2s_dev_t *hw) +static inline void i2s_ll_tx_enable_mono_mode(i2s_dev_t *hw, bool mono_ena) { - hw->conf.rx_short_sync = 0; - hw->conf.rx_msb_shift = 0; + int data_bit = hw->sample_rate_conf.tx_bits_mod; + hw->fifo_conf.tx_fifo_mod = data_bit <= I2S_BITS_PER_SAMPLE_16BIT ? mono_ena : 2 + mono_ena; + hw->conf.tx_dma_equal = mono_ena; + hw->conf_chan.tx_chan_mod = mono_ena; } /** - * @brief Set I2S TX to PCM short standard + * @brief Enable RX mono mode * * @param hw Peripheral I2S hardware instance address. + * @param mono_ena Set true to enable mono mde. */ -static inline void i2s_ll_set_tx_pcm_short(i2s_dev_t *hw) +static inline void i2s_ll_rx_enable_mono_mode(i2s_dev_t *hw, bool mono_ena) { - hw->conf.tx_short_sync = 1; - hw->conf.tx_msb_shift = 0; + int data_bit = hw->sample_rate_conf.rx_bits_mod; + hw->fifo_conf.rx_fifo_mod = data_bit <= I2S_BITS_PER_SAMPLE_16BIT ? mono_ena : 2 + mono_ena; + hw->conf.rx_dma_equal = mono_ena; + hw->conf_chan.rx_chan_mod = mono_ena; } /** - * @brief Set I2S RX to PCM short standard + * @brief Enable I2S loopback mode * * @param hw Peripheral I2S hardware instance address. + * @param loopback_en Set true to share BCK and WS signal for tx module and rx module. */ -static inline void i2s_ll_set_rx_pcm_short(i2s_dev_t *hw) +static inline void i2s_ll_share_bck_ws(i2s_dev_t *hw, bool loopback_en) { - hw->conf.rx_short_sync = 1; - hw->conf.rx_msb_shift = 0; + hw->conf.sig_loopback = loopback_en; } /** - * @brief Set I2S TX to PCM long standard + * @brief Enable I2S LCD mode * * @param hw Peripheral I2S hardware instance address. + * @param enable Set true to enable LCD mode. */ -static inline void i2s_ll_set_tx_pcm_long(i2s_dev_t *hw) +static inline void i2s_ll_enable_lcd(i2s_dev_t *hw, bool enable) { - hw->conf.tx_short_sync = 0; - hw->conf.tx_msb_shift = 0; + hw->conf2.lcd_en = enable; } /** - * @brief Set I2S RX to PCM long standard + * @brief Set whether to continue I2S signal on bus when TX FIFO is empty * * @param hw Peripheral I2S hardware instance address. + * @param en whether to stop when tx fifo is empty */ -static inline void i2s_ll_set_rx_pcm_long(i2s_dev_t *hw) +static inline void i2s_ll_tx_stop_on_fifo_empty(i2s_dev_t *hw, bool en) { - hw->conf.rx_short_sync = 0; - hw->conf.rx_msb_shift = 0; + hw->conf1.tx_stop_en = en; +} + +/** + * @brief Set whether to bypass the internal PCM module + * + * @param hw Peripheral I2S hardware instance address. + * @param bypass whether to bypass the PCM module + */ +static inline void i2s_ll_tx_bypass_pcm(i2s_dev_t *hw, bool bypass) +{ + hw->conf1.tx_pcm_bypass = bypass; } #ifdef __cplusplus diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/ledc_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/ledc_ll.h index 19d61f127fb..677a2e36d38 100644 --- a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/ledc_ll.h +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/ledc_ll.h @@ -19,6 +19,7 @@ #include "hal/ledc_types.h" #include "soc/ledc_periph.h" +#include "soc/ledc_struct.h" #ifdef __cplusplus extern "C" { diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/memprot_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/memprot_ll.h index eeaa73dcc83..fa77e2f3ab3 100644 --- a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/memprot_ll.h +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/memprot_ll.h @@ -14,7 +14,9 @@ #pragma once -#include "hal/assert.h" +#include +#include "soc/memprot_defs.h" +#include "hal/memprot_types.h" #ifdef __cplusplus extern "C" { @@ -25,23 +27,18 @@ extern "C" { * === IRAM0 common * ======================================================================================== */ -//IRAM0 interrupt status bitmasks -#define IRAM0_INTR_ST_OP_TYPE_BIT BIT(1) //instruction: 0, data: 1 -#define IRAM0_INTR_ST_OP_RW_BIT BIT(0) //read: 0, write: 1 -#define CONF_REG_ADDRESS_SHIFT 2 - -static inline void esp_memprot_iram0_clear_intr(void) +static inline void memprot_ll_iram0_clear_intr(void) { DPORT_SET_PERI_REG_MASK(DPORT_PMS_PRO_IRAM0_4_REG, DPORT_PMS_PRO_IRAM0_ILG_CLR); DPORT_CLEAR_PERI_REG_MASK(DPORT_PMS_PRO_IRAM0_4_REG, DPORT_PMS_PRO_IRAM0_ILG_CLR); } -static inline uint32_t esp_memprot_iram0_get_intr_source_num(void) +static inline uint32_t memprot_ll_iram0_get_intr_source_num(void) { return ETS_PMS_PRO_IRAM0_ILG_INTR_SOURCE; } -static inline void esp_memprot_iram0_intr_ena(bool enable) +static inline void memprot_ll_iram0_intr_ena(bool enable) { if (enable) { DPORT_SET_PERI_REG_MASK(DPORT_PMS_PRO_IRAM0_4_REG, DPORT_PMS_PRO_IRAM0_ILG_EN); @@ -50,55 +47,55 @@ static inline void esp_memprot_iram0_intr_ena(bool enable) } } -static inline uint32_t esp_memprot_iram0_get_conf_reg(void) +static inline uint32_t memprot_ll_iram0_get_conf_reg(void) { return DPORT_READ_PERI_REG(DPORT_PMS_PRO_IRAM0_4_REG); } -static inline uint32_t esp_memprot_iram0_get_fault_reg(void) +static inline uint32_t memprot_ll_iram0_get_fault_reg(void) { return DPORT_READ_PERI_REG(DPORT_PMS_PRO_IRAM0_5_REG); } -static inline void esp_memprot_iram0_get_fault_op_type(uint32_t *op_type, uint32_t *op_subtype) +static inline void memprot_ll_iram0_get_fault_op_type(uint32_t *op_type, uint32_t *op_subtype) { - uint32_t status_bits = esp_memprot_iram0_get_fault_reg(); + uint32_t status_bits = memprot_ll_iram0_get_fault_reg(); *op_type = (uint32_t)status_bits & IRAM0_INTR_ST_OP_RW_BIT; *op_subtype = (uint32_t)status_bits & IRAM0_INTR_ST_OP_TYPE_BIT; } -static inline bool esp_memprot_iram0_is_assoc_intr(void) +static inline bool memprot_ll_iram0_is_assoc_intr(void) { return DPORT_GET_PERI_REG_MASK(DPORT_PMS_PRO_IRAM0_4_REG, DPORT_PMS_PRO_IRAM0_ILG_INTR) > 0; } -static inline uint32_t esp_memprot_iram0_get_intr_ena_bit(void) +static inline uint32_t memprot_ll_iram0_get_intr_ena_bit(void) { return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_4_REG, DPORT_PMS_PRO_IRAM0_ILG_EN); } -static inline uint32_t esp_memprot_iram0_get_intr_on_bit(void) +static inline uint32_t memprot_ll_iram0_get_intr_on_bit(void) { return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_4_REG, DPORT_PMS_PRO_IRAM0_ILG_INTR); } -static inline uint32_t esp_memprot_iram0_get_intr_clr_bit(void) +static inline uint32_t memprot_ll_iram0_get_intr_clr_bit(void) { return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_4_REG, DPORT_PMS_PRO_IRAM0_ILG_CLR); } //resets automatically on CPU restart -static inline void esp_memprot_iram0_set_lock(void) +static inline void memprot_ll_iram0_set_lock(void) { DPORT_WRITE_PERI_REG( DPORT_PMS_PRO_IRAM0_0_REG, DPORT_PMS_PRO_IRAM0_LOCK); } -static inline uint32_t esp_memprot_iram0_get_lock_reg(void) +static inline uint32_t memprot_ll_iram0_get_lock_reg(void) { return DPORT_READ_PERI_REG(DPORT_PMS_PRO_IRAM0_0_REG); } -static inline uint32_t esp_memprot_iram0_get_lock_bit(void) +static inline uint32_t memprot_ll_iram0_get_lock_bit(void) { return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_0_REG, DPORT_PMS_PRO_IRAM0_LOCK); } @@ -108,52 +105,26 @@ static inline uint32_t esp_memprot_iram0_get_lock_bit(void) * === IRAM0 SRAM * ======================================================================================== */ -#define IRAM0_SRAM_BASE_ADDRESS 0x40000000 -#define IRAM0_SRAM_ADDRESS_LOW 0x40020000 -#define IRAM0_SRAM_ADDRESS_HIGH 0x4006FFFF - -#define IRAM0_SRAM_TOTAL_UNI_BLOCKS 4 -#define IRAM0_SRAM_UNI_BLOCK_0 0 -#define IRAM0_SRAM_UNI_BLOCK_1 1 -#define IRAM0_SRAM_UNI_BLOCK_2 2 -#define IRAM0_SRAM_UNI_BLOCK_3 3 - -//unified management (SRAM blocks 0-3) -#define IRAM0_SRAM_UNI_BLOCK_0_LOW 0x40020000 -#define IRAM0_SRAM_UNI_BLOCK_1_LOW 0x40022000 -#define IRAM0_SRAM_UNI_BLOCK_2_LOW 0x40024000 -#define IRAM0_SRAM_UNI_BLOCK_3_LOW 0x40026000 - -//split management (SRAM blocks 4-21) -#define IRAM0_SRAM_SPL_BLOCK_LOW 0x40028000 //block 4 low -#define IRAM0_SRAM_SPL_BLOCK_HIGH 0x4006FFFF //block 21 high - -#define IRAM0_INTR_ST_FAULTADDR_M 0x003FFFFC //bits 21:6 in the reg, as well as in real address -#define IRAM0_SRAM_INTR_ST_FAULTADDR_HI 0x40000000 //high nonsignificant bits 31:22 of the faulting address - constant - -#define IRAM0_SRAM_ADDR_TO_CONF_REG(addr) (((addr >> CONF_REG_ADDRESS_SHIFT) & DPORT_PMS_PRO_IRAM0_SRAM_4_SPLTADDR) << DPORT_PMS_PRO_IRAM0_SRAM_4_SPLTADDR_S) - -static inline uint32_t *esp_memprot_iram0_sram_get_fault_address(void) +static inline intptr_t memprot_ll_iram0_sram_get_fault_address(void) { - uint32_t status_bits = esp_memprot_iram0_get_fault_reg(); - return (uint32_t *)((status_bits & IRAM0_INTR_ST_FAULTADDR_M) | IRAM0_SRAM_INTR_ST_FAULTADDR_HI); + uint32_t status_bits = memprot_ll_iram0_get_fault_reg(); + return (intptr_t)((status_bits & IRAM0_INTR_ST_FAULTADDR_M) | IRAM0_SRAM_INTR_ST_FAULTADDR_HI); } -static inline bool esp_memprot_iram0_sram_is_intr_mine(void) +static inline bool memprot_ll_iram0_sram_is_intr_mine(void) { - if (esp_memprot_iram0_is_assoc_intr()) { - uint32_t *faulting_address = esp_memprot_iram0_sram_get_fault_address(); - return (uint32_t)faulting_address >= IRAM0_SRAM_ADDRESS_LOW && (uint32_t)faulting_address <= IRAM0_SRAM_ADDRESS_HIGH; + if (memprot_ll_iram0_is_assoc_intr()) { + uint32_t faulting_address = (uint32_t)memprot_ll_iram0_sram_get_fault_address(); + return faulting_address >= IRAM0_SRAM_ADDRESS_LOW && faulting_address <= IRAM0_SRAM_ADDRESS_HIGH; } return false; } //block 0-3 -static inline void esp_memprot_iram0_sram_set_uni_block_perm(uint32_t block, bool write_perm, bool read_perm, bool exec_perm) +static inline bool memprot_ll_iram0_sram_set_uni_block_perm(uint32_t block, bool write_perm, bool read_perm, bool exec_perm) { - HAL_ASSERT(block < IRAM0_SRAM_TOTAL_UNI_BLOCKS); - uint32_t write_bit, read_bit, exec_bit; + switch (block) { case IRAM0_SRAM_UNI_BLOCK_0: write_bit = DPORT_PMS_PRO_IRAM0_SRAM_0_W; @@ -176,7 +147,7 @@ static inline void esp_memprot_iram0_sram_set_uni_block_perm(uint32_t block, boo exec_bit = DPORT_PMS_PRO_IRAM0_SRAM_3_F; break; default: - abort(); + return false; } if (write_perm) { @@ -196,66 +167,78 @@ static inline void esp_memprot_iram0_sram_set_uni_block_perm(uint32_t block, boo } else { DPORT_CLEAR_PERI_REG_MASK(DPORT_PMS_PRO_IRAM0_1_REG, exec_bit); } + + return true; } -static inline uint32_t esp_memprot_iram0_sram_get_uni_block_read_bit(uint32_t block) +static inline bool memprot_ll_iram0_sram_get_uni_block_read_bit(uint32_t block, uint32_t *read_bit) { - HAL_ASSERT(block < IRAM0_SRAM_TOTAL_UNI_BLOCKS); - switch (block) { case IRAM0_SRAM_UNI_BLOCK_0: - return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_1_REG, DPORT_PMS_PRO_IRAM0_SRAM_0_R); + *read_bit = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_1_REG, DPORT_PMS_PRO_IRAM0_SRAM_0_R); + break; case IRAM0_SRAM_UNI_BLOCK_1: - return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_1_REG, DPORT_PMS_PRO_IRAM0_SRAM_1_R); + *read_bit = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_1_REG, DPORT_PMS_PRO_IRAM0_SRAM_1_R); + break; case IRAM0_SRAM_UNI_BLOCK_2: - return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_1_REG, DPORT_PMS_PRO_IRAM0_SRAM_2_R); + *read_bit = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_1_REG, DPORT_PMS_PRO_IRAM0_SRAM_2_R); + break; case IRAM0_SRAM_UNI_BLOCK_3: - return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_1_REG, DPORT_PMS_PRO_IRAM0_SRAM_3_R); + *read_bit = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_1_REG, DPORT_PMS_PRO_IRAM0_SRAM_3_R); + break; default: - abort(); + return false; } + + return true; } -static inline uint32_t esp_memprot_iram0_sram_get_uni_block_write_bit(uint32_t block) +static inline bool memprot_ll_iram0_sram_get_uni_block_write_bit(uint32_t block, uint32_t *write_bit) { - HAL_ASSERT(block < IRAM0_SRAM_TOTAL_UNI_BLOCKS); - switch (block) { case IRAM0_SRAM_UNI_BLOCK_0: - return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_1_REG, DPORT_PMS_PRO_IRAM0_SRAM_0_W); + *write_bit = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_1_REG, DPORT_PMS_PRO_IRAM0_SRAM_0_W); + break; case IRAM0_SRAM_UNI_BLOCK_1: - return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_1_REG, DPORT_PMS_PRO_IRAM0_SRAM_1_W); + *write_bit = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_1_REG, DPORT_PMS_PRO_IRAM0_SRAM_1_W); + break; case IRAM0_SRAM_UNI_BLOCK_2: - return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_1_REG, DPORT_PMS_PRO_IRAM0_SRAM_2_W); + *write_bit = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_1_REG, DPORT_PMS_PRO_IRAM0_SRAM_2_W); + break; case IRAM0_SRAM_UNI_BLOCK_3: - return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_1_REG, DPORT_PMS_PRO_IRAM0_SRAM_3_W); + *write_bit = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_1_REG, DPORT_PMS_PRO_IRAM0_SRAM_3_W); + break; default: - abort(); + return false; } + + return true; } -static inline uint32_t esp_memprot_iram0_sram_get_uni_block_exec_bit(uint32_t block) +static inline bool memprot_ll_iram0_sram_get_uni_block_exec_bit(uint32_t block, uint32_t *exec_bit) { - HAL_ASSERT(block < IRAM0_SRAM_TOTAL_UNI_BLOCKS); - switch (block) { case IRAM0_SRAM_UNI_BLOCK_0: - return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_1_REG, DPORT_PMS_PRO_IRAM0_SRAM_0_F); + *exec_bit = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_1_REG, DPORT_PMS_PRO_IRAM0_SRAM_0_F); + break; case IRAM0_SRAM_UNI_BLOCK_1: - return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_1_REG, DPORT_PMS_PRO_IRAM0_SRAM_1_F); + *exec_bit = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_1_REG, DPORT_PMS_PRO_IRAM0_SRAM_1_F); + break; case IRAM0_SRAM_UNI_BLOCK_2: - return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_1_REG, DPORT_PMS_PRO_IRAM0_SRAM_2_F); + *exec_bit = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_1_REG, DPORT_PMS_PRO_IRAM0_SRAM_2_F); + break; case IRAM0_SRAM_UNI_BLOCK_3: - return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_1_REG, DPORT_PMS_PRO_IRAM0_SRAM_3_F); + *exec_bit = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_1_REG, DPORT_PMS_PRO_IRAM0_SRAM_3_F); + break; default: - abort(); + return false; } + + return true; } -static inline void esp_memprot_iram0_sram_get_uni_block_sgnf_bits(uint32_t block, uint32_t *write_bit, uint32_t *read_bit, uint32_t *exec_bit) +static inline bool memprot_ll_iram0_sram_get_uni_block_sgnf_bits(uint32_t block, uint32_t *write_bit, uint32_t *read_bit, uint32_t *exec_bit) { - HAL_ASSERT(block < IRAM0_SRAM_TOTAL_UNI_BLOCKS); - switch (block) { case IRAM0_SRAM_UNI_BLOCK_0: *write_bit = DPORT_PMS_PRO_IRAM0_SRAM_0_W; @@ -278,25 +261,33 @@ static inline void esp_memprot_iram0_sram_get_uni_block_sgnf_bits(uint32_t block *exec_bit = DPORT_PMS_PRO_IRAM0_SRAM_3_F; break; default: - abort(); + return false; } + + return true; } -static inline uint32_t esp_memprot_iram0_sram_get_perm_uni_reg(void) +static inline uint32_t memprot_ll_iram0_sram_get_perm_uni_reg(void) { return DPORT_READ_PERI_REG(DPORT_PMS_PRO_IRAM0_1_REG); } -static inline uint32_t esp_memprot_iram0_sram_get_perm_split_reg(void) +static inline uint32_t memprot_ll_iram0_sram_get_perm_split_reg(void) { return DPORT_READ_PERI_REG(DPORT_PMS_PRO_IRAM0_2_REG); } -static inline void esp_memprot_iram0_sram_set_prot(uint32_t *split_addr, bool lw, bool lr, bool lx, bool hw, bool hr, bool hx) +static inline memprot_ll_err_t memprot_ll_iram0_sram_set_prot(uint32_t *split_addr, bool lw, bool lr, bool lx, bool hw, bool hr, bool hx) { uint32_t addr = (uint32_t)split_addr; - HAL_ASSERT(addr <= IRAM0_SRAM_SPL_BLOCK_HIGH); - HAL_ASSERT(addr % 0x4 == 0); + + //sanity check: split address required above unified mgmt region & 32bit aligned + if (addr > IRAM0_SRAM_SPL_BLOCK_HIGH) { + return MEMP_LL_ERR_SPLIT_ADDR_INVALID; + } + if (addr % 0x4 != 0) { + return MEMP_LL_ERR_SPLIT_ADDR_UNALIGNED; + } //find possible split.address in low region blocks int uni_blocks_low = -1; @@ -318,7 +309,9 @@ static inline void esp_memprot_iram0_sram_set_prot(uint32_t *split_addr, bool lw uint32_t uni_block_perm = 0; for (int x = 0; x < IRAM0_SRAM_TOTAL_UNI_BLOCKS; x++) { - esp_memprot_iram0_sram_get_uni_block_sgnf_bits(x, &write_bit, &read_bit, &exec_bit); + if (!memprot_ll_iram0_sram_get_uni_block_sgnf_bits(x, &write_bit, &read_bit, &exec_bit)) { + return MEMP_LL_ERR_UNI_BLOCK_INVALID; + } if (x <= uni_blocks_low) { if (lw) { uni_block_perm |= write_bit; @@ -346,7 +339,7 @@ static inline void esp_memprot_iram0_sram_set_prot(uint32_t *split_addr, bool lw uint32_t reg_split_addr = 0; if (addr >= IRAM0_SRAM_SPL_BLOCK_LOW) { - reg_split_addr = IRAM0_SRAM_ADDR_TO_CONF_REG( addr ); //cfg reg - [16:0] + reg_split_addr = IRAM0_SRAM_ADDR_TO_CONF_REG(addr); //cfg reg - [16:0] } //prepare high & low permission mask (bits: [22:20] high range, [19:17] low range) @@ -373,9 +366,11 @@ static inline void esp_memprot_iram0_sram_set_prot(uint32_t *split_addr, bool lw //write IRAM SRAM uni & splt cfg. registers DPORT_WRITE_PERI_REG(DPORT_PMS_PRO_IRAM0_1_REG, uni_block_perm); DPORT_WRITE_PERI_REG(DPORT_PMS_PRO_IRAM0_2_REG, (uint32_t)(reg_split_addr | permission_mask)); + + return MEMP_LL_OK; } -static inline void esp_memprot_iram0_sram_get_split_sgnf_bits(bool *lw, bool *lr, bool *lx, bool *hw, bool *hr, bool *hx) +static inline void memprot_ll_iram0_sram_get_split_sgnf_bits(bool *lw, bool *lr, bool *lx, bool *hw, bool *hr, bool *hx) { *lw = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_2_REG, DPORT_PMS_PRO_IRAM0_SRAM_4_L_W); *lr = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_2_REG, DPORT_PMS_PRO_IRAM0_SRAM_4_L_R); @@ -385,19 +380,19 @@ static inline void esp_memprot_iram0_sram_get_split_sgnf_bits(bool *lw, bool *lr *hx = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_2_REG, DPORT_PMS_PRO_IRAM0_SRAM_4_H_F); } -static inline void esp_memprot_iram0_sram_set_read_perm(bool lr, bool hr) +static inline void memprot_ll_iram0_sram_set_read_perm(bool lr, bool hr) { DPORT_REG_SET_FIELD(DPORT_PMS_PRO_IRAM0_2_REG, DPORT_PMS_PRO_IRAM0_SRAM_4_L_R, lr ? 1 : 0); DPORT_REG_SET_FIELD(DPORT_PMS_PRO_IRAM0_2_REG, DPORT_PMS_PRO_IRAM0_SRAM_4_H_R, hr ? 1 : 0); } -static inline void esp_memprot_iram0_sram_set_write_perm(bool lw, bool hw) +static inline void memprot_ll_iram0_sram_set_write_perm(bool lw, bool hw) { DPORT_REG_SET_FIELD(DPORT_PMS_PRO_IRAM0_2_REG, DPORT_PMS_PRO_IRAM0_SRAM_4_L_W, lw ? 1 : 0); DPORT_REG_SET_FIELD(DPORT_PMS_PRO_IRAM0_2_REG, DPORT_PMS_PRO_IRAM0_SRAM_4_H_W, hw ? 1 : 0); } -static inline void esp_memprot_iram0_sram_set_exec_perm(bool lx, bool hx) +static inline void memprot_ll_iram0_sram_set_exec_perm(bool lx, bool hx) { DPORT_REG_SET_FIELD(DPORT_PMS_PRO_IRAM0_2_REG, DPORT_PMS_PRO_IRAM0_SRAM_4_L_F, lx ? 1 : 0); DPORT_REG_SET_FIELD(DPORT_PMS_PRO_IRAM0_2_REG, DPORT_PMS_PRO_IRAM0_SRAM_4_H_F, hx ? 1 : 0); @@ -409,37 +404,37 @@ static inline void esp_memprot_iram0_sram_set_exec_perm(bool lx, bool hx) * === IRAM0 RTC FAST * ======================================================================================== */ -#define IRAM0_RTCFAST_ADDRESS_LOW 0x40070000 -#define IRAM0_RTCFAST_ADDRESS_HIGH 0x40071FFF -#define IRAM0_RTCFAST_INTR_ST_FAULTADDR_HI 0x40070000 //RTCFAST faulting address high bits (31:22, constant) - -#define IRAM0_RTCFAST_ADDR_TO_CONF_REG(addr) (((addr >> CONF_REG_ADDRESS_SHIFT) & DPORT_PMS_PRO_IRAM0_RTCFAST_SPLTADDR) << DPORT_PMS_PRO_IRAM0_RTCFAST_SPLTADDR_S) - - -static inline uint32_t *esp_memprot_iram0_rtcfast_get_fault_address(void) +static inline intptr_t memprot_ll_iram0_rtcfast_get_fault_address(void) { - uint32_t status_bits = esp_memprot_iram0_get_fault_reg(); - return (uint32_t *)((status_bits & IRAM0_INTR_ST_FAULTADDR_M) | IRAM0_RTCFAST_INTR_ST_FAULTADDR_HI); + uint32_t status_bits = memprot_ll_iram0_get_fault_reg(); + return (intptr_t)((status_bits & IRAM0_INTR_ST_FAULTADDR_M) | IRAM0_RTCFAST_INTR_ST_FAULTADDR_HI); } -static inline bool esp_memprot_iram0_rtcfast_is_intr_mine(void) +static inline bool memprot_ll_iram0_rtcfast_is_intr_mine(void) { - if (esp_memprot_iram0_is_assoc_intr()) { - uint32_t *faulting_address = esp_memprot_iram0_rtcfast_get_fault_address(); - return (uint32_t)faulting_address >= IRAM0_RTCFAST_ADDRESS_LOW && (uint32_t)faulting_address <= IRAM0_RTCFAST_ADDRESS_HIGH; + if (memprot_ll_iram0_is_assoc_intr()) { + uint32_t faulting_address = (uint32_t)memprot_ll_iram0_rtcfast_get_fault_address(); + return faulting_address >= IRAM0_RTCFAST_ADDRESS_LOW && faulting_address <= IRAM0_RTCFAST_ADDRESS_HIGH; } return false; } -static inline uint32_t esp_memprot_iram0_rtcfast_get_perm_split_reg(void) +static inline uint32_t memprot_ll_iram0_rtcfast_get_perm_split_reg(void) { return DPORT_READ_PERI_REG(DPORT_PMS_PRO_IRAM0_3_REG); } -static inline void esp_memprot_iram0_rtcfast_set_prot(uint32_t *split_addr, bool lw, bool lr, bool lx, bool hw, bool hr, bool hx) +static inline memprot_ll_err_t memprot_ll_iram0_rtcfast_set_prot(uint32_t *split_addr, bool lw, bool lr, bool lx, bool hw, bool hr, bool hx) { uint32_t addr = (uint32_t)split_addr; - HAL_ASSERT(addr % 0x4 == 0); + + //32bit aligned + if (addr < IRAM0_RTCFAST_ADDRESS_LOW || addr > IRAM0_RTCFAST_ADDRESS_HIGH) { + return MEMP_LL_ERR_SPLIT_ADDR_INVALID; + } + if (addr % 0x4 != 0) { + return MEMP_LL_ERR_SPLIT_ADDR_UNALIGNED; + } //conf reg [10:0] uint32_t reg_split_addr = IRAM0_RTCFAST_ADDR_TO_CONF_REG(addr); @@ -467,9 +462,11 @@ static inline void esp_memprot_iram0_rtcfast_set_prot(uint32_t *split_addr, bool //write IRAM0 RTCFAST cfg register DPORT_WRITE_PERI_REG(DPORT_PMS_PRO_IRAM0_3_REG, reg_split_addr | permission_mask); + + return MEMP_LL_OK; } -static inline void esp_memprot_iram0_rtcfast_get_split_sgnf_bits(bool *lw, bool *lr, bool *lx, bool *hw, bool *hr, bool *hx) +static inline void memprot_ll_iram0_rtcfast_get_split_sgnf_bits(bool *lw, bool *lr, bool *lx, bool *hw, bool *hr, bool *hx) { *lw = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_3_REG, DPORT_PMS_PRO_IRAM0_RTCFAST_L_W); *lr = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_3_REG, DPORT_PMS_PRO_IRAM0_RTCFAST_L_R); @@ -479,19 +476,19 @@ static inline void esp_memprot_iram0_rtcfast_get_split_sgnf_bits(bool *lw, bool *hx = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_IRAM0_3_REG, DPORT_PMS_PRO_IRAM0_RTCFAST_H_F); } -static inline void esp_memprot_iram0_rtcfast_set_read_perm(bool lr, bool hr) +static inline void memprot_ll_iram0_rtcfast_set_read_perm(bool lr, bool hr) { DPORT_REG_SET_FIELD(DPORT_PMS_PRO_IRAM0_3_REG, DPORT_PMS_PRO_IRAM0_RTCFAST_L_R, lr ? 1 : 0); DPORT_REG_SET_FIELD(DPORT_PMS_PRO_IRAM0_3_REG, DPORT_PMS_PRO_IRAM0_RTCFAST_H_R, hr ? 1 : 0); } -static inline void esp_memprot_iram0_rtcfast_set_write_perm(bool lw, bool hw) +static inline void memprot_ll_iram0_rtcfast_set_write_perm(bool lw, bool hw) { DPORT_REG_SET_FIELD(DPORT_PMS_PRO_IRAM0_3_REG, DPORT_PMS_PRO_IRAM0_RTCFAST_L_W, lw ? 1 : 0); DPORT_REG_SET_FIELD(DPORT_PMS_PRO_IRAM0_3_REG, DPORT_PMS_PRO_IRAM0_RTCFAST_H_W, hw ? 1 : 0); } -static inline void esp_memprot_iram0_rtcfast_set_exec_perm(bool lx, bool hx) +static inline void memprot_ll_iram0_rtcfast_set_exec_perm(bool lx, bool hx) { DPORT_REG_SET_FIELD(DPORT_PMS_PRO_IRAM0_3_REG, DPORT_PMS_PRO_IRAM0_RTCFAST_L_F, lx ? 1 : 0); DPORT_REG_SET_FIELD(DPORT_PMS_PRO_IRAM0_3_REG, DPORT_PMS_PRO_IRAM0_RTCFAST_H_F, hx ? 1 : 0); @@ -503,19 +500,12 @@ static inline void esp_memprot_iram0_rtcfast_set_exec_perm(bool lx, bool hx) * === DRAM0 common * ======================================================================================== */ -//DRAM0 interrupt status bitmasks -#define DRAM0_INTR_ST_FAULTADDR_M 0x03FFFFC0 //(bits 25:6 in the reg) -#define DRAM0_INTR_ST_FAULTADDR_S 0x4 //(bits 21:2 of real address) -#define DRAM0_INTR_ST_OP_RW_BIT BIT(4) //read: 0, write: 1 -#define DRAM0_INTR_ST_OP_ATOMIC_BIT BIT(5) //non-atomic: 0, atomic: 1 - - -static inline uint32_t esp_memprot_dram0_get_intr_source_num(void) +static inline uint32_t memprot_ll_dram0_get_intr_source_num(void) { return ETS_PMS_PRO_DRAM0_ILG_INTR_SOURCE; } -static inline void esp_memprot_dram0_intr_ena(bool enable) +static inline void memprot_ll_dram0_intr_ena(bool enable) { if (enable) { DPORT_SET_PERI_REG_MASK(DPORT_PMS_PRO_DRAM0_3_REG, DPORT_PMS_PRO_DRAM0_ILG_EN); @@ -524,112 +514,87 @@ static inline void esp_memprot_dram0_intr_ena(bool enable) } } -static inline bool esp_memprot_dram0_is_assoc_intr(void) +static inline bool memprot_ll_dram0_is_assoc_intr(void) { return DPORT_GET_PERI_REG_MASK(DPORT_PMS_PRO_DRAM0_3_REG, DPORT_PMS_PRO_DRAM0_ILG_INTR) > 0; } -static inline void esp_memprot_dram0_clear_intr(void) +static inline void memprot_ll_dram0_clear_intr(void) { DPORT_SET_PERI_REG_MASK(DPORT_PMS_PRO_DRAM0_3_REG, DPORT_PMS_PRO_DRAM0_ILG_CLR); DPORT_CLEAR_PERI_REG_MASK(DPORT_PMS_PRO_DRAM0_3_REG, DPORT_PMS_PRO_DRAM0_ILG_CLR); } -static inline uint32_t esp_memprot_dram0_get_intr_ena_bit(void) +static inline uint32_t memprot_ll_dram0_get_intr_ena_bit(void) { return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DRAM0_3_REG, DPORT_PMS_PRO_DRAM0_ILG_EN); } -static inline uint32_t esp_memprot_dram0_get_intr_on_bit(void) +static inline uint32_t memprot_ll_dram0_get_intr_on_bit(void) { return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DRAM0_3_REG, DPORT_PMS_PRO_DRAM0_ILG_INTR); } -static inline uint32_t esp_memprot_dram0_get_intr_clr_bit(void) +static inline uint32_t memprot_ll_dram0_get_intr_clr_bit(void) { return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DRAM0_3_REG, DPORT_PMS_PRO_DRAM0_ILG_CLR); } //lock resets automatically on CPU restart -static inline void esp_memprot_dram0_set_lock(void) +static inline void memprot_ll_dram0_set_lock(void) { DPORT_WRITE_PERI_REG(DPORT_PMS_PRO_DRAM0_0_REG, DPORT_PMS_PRO_DRAM0_LOCK); } -static inline uint32_t esp_memprot_dram0_get_lock_reg(void) +static inline uint32_t memprot_ll_dram0_get_lock_reg(void) { return DPORT_READ_PERI_REG(DPORT_PMS_PRO_DRAM0_0_REG); } -static inline uint32_t esp_memprot_dram0_get_lock_bit(void) +static inline uint32_t memprot_ll_dram0_get_lock_bit(void) { return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DRAM0_0_REG, DPORT_PMS_PRO_DRAM0_LOCK); } -static inline uint32_t esp_memprot_dram0_get_conf_reg(void) +static inline uint32_t memprot_ll_dram0_get_conf_reg(void) { return DPORT_READ_PERI_REG(DPORT_PMS_PRO_DRAM0_3_REG); } -static inline uint32_t esp_memprot_dram0_get_fault_reg(void) +static inline uint32_t memprot_ll_dram0_get_fault_reg(void) { return DPORT_READ_PERI_REG(DPORT_PMS_PRO_DRAM0_4_REG); } -static inline void esp_memprot_dram0_get_fault_op_type(uint32_t *op_type, uint32_t *op_subtype) +static inline void memprot_ll_dram0_get_fault_op_type(uint32_t *op_type, uint32_t *op_subtype) { - uint32_t status_bits = esp_memprot_dram0_get_fault_reg(); + uint32_t status_bits = memprot_ll_dram0_get_fault_reg(); *op_type = status_bits & DRAM0_INTR_ST_OP_RW_BIT; *op_subtype = status_bits & DRAM0_INTR_ST_OP_ATOMIC_BIT; } - /** * ======================================================================================== * === DRAM0 SRAM * ======================================================================================== */ -#define DRAM0_SRAM_ADDRESS_LOW 0x3FFB0000 -#define DRAM0_SRAM_ADDRESS_HIGH 0x3FFFFFFF - -#define DRAM0_SRAM_TOTAL_UNI_BLOCKS 4 -#define DRAM0_SRAM_UNI_BLOCK_0 0 -#define DRAM0_SRAM_UNI_BLOCK_1 1 -#define DRAM0_SRAM_UNI_BLOCK_2 2 -#define DRAM0_SRAM_UNI_BLOCK_3 3 - -//unified management (SRAM blocks 0-3) -#define DRAM0_SRAM_UNI_BLOCK_0_LOW 0x3FFB0000 -#define DRAM0_SRAM_UNI_BLOCK_1_LOW 0x3FFB2000 -#define DRAM0_SRAM_UNI_BLOCK_2_LOW 0x3FFB4000 -#define DRAM0_SRAM_UNI_BLOCK_3_LOW 0x3FFB6000 - -//split management (SRAM blocks 4-21) -#define DRAM0_SRAM_SPL_BLOCK_HIGH 0x3FFFFFFF //block 21 high -#define DRAM0_SRAM_INTR_ST_FAULTADDR_HI 0x3FF00000 //SRAM high bits 31:22 of the faulting address - constant - -#define DRAM0_SRAM_ADDR_TO_CONF_REG(addr) (((addr >> CONF_REG_ADDRESS_SHIFT) & DPORT_PMS_PRO_DRAM0_SRAM_4_SPLTADDR) << DPORT_PMS_PRO_DRAM0_SRAM_4_SPLTADDR_S) - - -static inline uint32_t *esp_memprot_dram0_sram_get_fault_address(void) +static inline intptr_t memprot_ll_dram0_sram_get_fault_address(void) { - uint32_t status_bits = esp_memprot_dram0_get_fault_reg(); - return (uint32_t *)(((status_bits & DRAM0_INTR_ST_FAULTADDR_M) >> DRAM0_INTR_ST_FAULTADDR_S) | DRAM0_SRAM_INTR_ST_FAULTADDR_HI); + uint32_t status_bits = memprot_ll_dram0_get_fault_reg(); + return (intptr_t)(((status_bits & DRAM0_INTR_ST_FAULTADDR_M) >> DRAM0_INTR_ST_FAULTADDR_S) | DRAM0_SRAM_INTR_ST_FAULTADDR_HI); } -static inline bool esp_memprot_dram0_sram_is_intr_mine(void) +static inline bool memprot_ll_dram0_sram_is_intr_mine(void) { - if (esp_memprot_dram0_is_assoc_intr()) { - uint32_t *faulting_address = esp_memprot_dram0_sram_get_fault_address(); - return (uint32_t)faulting_address >= DRAM0_SRAM_ADDRESS_LOW && (uint32_t)faulting_address <= DRAM0_SRAM_ADDRESS_HIGH; + if (memprot_ll_dram0_is_assoc_intr()) { + uint32_t faulting_address = (uint32_t)memprot_ll_dram0_sram_get_fault_address(); + return faulting_address >= DRAM0_SRAM_ADDRESS_LOW && faulting_address <= DRAM0_SRAM_ADDRESS_HIGH; } return false; } -static inline void esp_memprot_dram0_sram_get_uni_block_sgnf_bits(uint32_t block, uint32_t *write_bit, uint32_t *read_bit) +static inline bool memprot_ll_dram0_sram_get_uni_block_sgnf_bits(uint32_t block, uint32_t *write_bit, uint32_t *read_bit) { - HAL_ASSERT(block < DRAM0_SRAM_TOTAL_UNI_BLOCKS); - switch (block) { case DRAM0_SRAM_UNI_BLOCK_0: *write_bit = DPORT_PMS_PRO_DRAM0_SRAM_0_W; @@ -648,79 +613,97 @@ static inline void esp_memprot_dram0_sram_get_uni_block_sgnf_bits(uint32_t block *read_bit = DPORT_PMS_PRO_DRAM0_SRAM_3_R; break; default: - abort(); + return false; } + + return true; } -static inline void esp_memprot_dram0_sram_set_uni_block_perm(uint32_t block, bool write_perm, bool read_perm) +static inline memprot_ll_err_t memprot_ll_dram0_sram_set_uni_block_perm(uint32_t block, bool write_perm, bool read_perm) { - HAL_ASSERT(block < DRAM0_SRAM_TOTAL_UNI_BLOCKS); - - uint32_t write_bit, read_bit; - esp_memprot_dram0_sram_get_uni_block_sgnf_bits(block, &write_bit, &read_bit); + //get block-specific WR flags offset within the conf.register + uint32_t write_bit_offset, read_bit_offset; + if (!memprot_ll_dram0_sram_get_uni_block_sgnf_bits(block, &write_bit_offset, &read_bit_offset)) { + return MEMP_LL_ERR_UNI_BLOCK_INVALID; + } + //set/reset required flags if (write_perm) { - DPORT_SET_PERI_REG_MASK(DPORT_PMS_PRO_DRAM0_1_REG, write_bit); + DPORT_SET_PERI_REG_MASK(DPORT_PMS_PRO_DRAM0_1_REG, write_bit_offset); } else { - DPORT_CLEAR_PERI_REG_MASK(DPORT_PMS_PRO_DRAM0_1_REG, write_bit); + DPORT_CLEAR_PERI_REG_MASK(DPORT_PMS_PRO_DRAM0_1_REG, write_bit_offset); } if (read_perm) { - DPORT_SET_PERI_REG_MASK(DPORT_PMS_PRO_DRAM0_1_REG, read_bit); + DPORT_SET_PERI_REG_MASK(DPORT_PMS_PRO_DRAM0_1_REG, read_bit_offset); } else { - DPORT_CLEAR_PERI_REG_MASK(DPORT_PMS_PRO_DRAM0_1_REG, read_bit); + DPORT_CLEAR_PERI_REG_MASK(DPORT_PMS_PRO_DRAM0_1_REG, read_bit_offset); } + + return MEMP_LL_OK; } -static inline uint32_t esp_memprot_dram0_sram_get_uni_block_read_bit(uint32_t block) +static inline bool memprot_ll_dram0_sram_get_uni_block_read_bit(uint32_t block, uint32_t *read_bit) { - HAL_ASSERT(block < DRAM0_SRAM_TOTAL_UNI_BLOCKS); - switch (block) { case DRAM0_SRAM_UNI_BLOCK_0: - return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DRAM0_1_REG, DPORT_PMS_PRO_DRAM0_SRAM_0_R); + *read_bit = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DRAM0_1_REG, DPORT_PMS_PRO_DRAM0_SRAM_0_R); + break; case DRAM0_SRAM_UNI_BLOCK_1: - return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DRAM0_1_REG, DPORT_PMS_PRO_DRAM0_SRAM_1_R); + *read_bit = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DRAM0_1_REG, DPORT_PMS_PRO_DRAM0_SRAM_1_R); + break; case DRAM0_SRAM_UNI_BLOCK_2: - return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DRAM0_1_REG, DPORT_PMS_PRO_DRAM0_SRAM_2_R); + *read_bit = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DRAM0_1_REG, DPORT_PMS_PRO_DRAM0_SRAM_2_R); + break; case DRAM0_SRAM_UNI_BLOCK_3: - return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DRAM0_1_REG, DPORT_PMS_PRO_DRAM0_SRAM_3_R); + *read_bit = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DRAM0_1_REG, DPORT_PMS_PRO_DRAM0_SRAM_3_R); + break; default: - abort(); + return false; } + + return true; } -static inline uint32_t esp_memprot_dram0_sram_get_uni_block_write_bit(uint32_t block) +static inline bool memprot_ll_dram0_sram_get_uni_block_write_bit(uint32_t block, uint32_t *write_bit) { - HAL_ASSERT(block < DRAM0_SRAM_TOTAL_UNI_BLOCKS); - switch (block) { case DRAM0_SRAM_UNI_BLOCK_0: - return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DRAM0_1_REG, DPORT_PMS_PRO_DRAM0_SRAM_0_W); + *write_bit = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DRAM0_1_REG, DPORT_PMS_PRO_DRAM0_SRAM_0_W); + break; case DRAM0_SRAM_UNI_BLOCK_1: - return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DRAM0_1_REG, DPORT_PMS_PRO_DRAM0_SRAM_1_W); + *write_bit = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DRAM0_1_REG, DPORT_PMS_PRO_DRAM0_SRAM_1_W); + break; case DRAM0_SRAM_UNI_BLOCK_2: - return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DRAM0_1_REG, DPORT_PMS_PRO_DRAM0_SRAM_2_W); + *write_bit = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DRAM0_1_REG, DPORT_PMS_PRO_DRAM0_SRAM_2_W); + break; case DRAM0_SRAM_UNI_BLOCK_3: - return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DRAM0_1_REG, DPORT_PMS_PRO_DRAM0_SRAM_3_W); + *write_bit = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DRAM0_1_REG, DPORT_PMS_PRO_DRAM0_SRAM_3_W); + break; default: - abort(); + return false; } + + return true; } //DRAM0 has both unified blocks and split address configured in 1 register -static inline uint32_t esp_memprot_dram0_sram_get_perm_reg(void) +static inline uint32_t memprot_ll_dram0_sram_get_perm_reg(void) { return DPORT_READ_PERI_REG(DPORT_PMS_PRO_DRAM0_1_REG); } -static inline void esp_memprot_dram0_sram_set_prot(uint32_t *split_addr, bool lw, bool lr, bool hw, bool hr) +static inline memprot_ll_err_t memprot_ll_dram0_sram_set_prot(uint32_t *split_addr, bool lw, bool lr, bool hw, bool hr) { uint32_t addr = (uint32_t)split_addr; - //low boundary check provided by LD script. see comment in esp_memprot_iram0_sram_set_prot() - HAL_ASSERT(addr <= DRAM0_SRAM_SPL_BLOCK_HIGH); - HAL_ASSERT(addr % 0x4 == 0 ); + //low boundary check provided by LD script. see comment in memprot_ll_iram0_sram_set_prot() + if (addr > DRAM0_SRAM_SPL_BLOCK_HIGH) { + return MEMP_LL_ERR_SPLIT_ADDR_INVALID; + } + if (addr % 0x4 != 0) { + return MEMP_LL_ERR_SPLIT_ADDR_UNALIGNED; + } //set low region int uni_blocks_low = -1; @@ -740,7 +723,9 @@ static inline void esp_memprot_dram0_sram_set_prot(uint32_t *split_addr, bool lw //set unified mgmt region uint32_t write_bit, read_bit, uni_block_perm = 0; for (int x = 0; x < DRAM0_SRAM_TOTAL_UNI_BLOCKS; x++) { - esp_memprot_dram0_sram_get_uni_block_sgnf_bits(x, &write_bit, &read_bit); + if (!memprot_ll_dram0_sram_get_uni_block_sgnf_bits(x, &write_bit, &read_bit)) { + return MEMP_LL_ERR_UNI_BLOCK_INVALID; + } if (x <= uni_blocks_low) { if (lw) { uni_block_perm |= write_bit; @@ -778,9 +763,11 @@ static inline void esp_memprot_dram0_sram_set_prot(uint32_t *split_addr, bool lw //write DRAM0 SRAM cfg register DPORT_WRITE_PERI_REG(DPORT_PMS_PRO_DRAM0_1_REG, reg_split_addr | permission_mask | uni_block_perm); + + return MEMP_LL_OK; } -static inline void esp_memprot_dram0_sram_get_split_sgnf_bits(bool *lw, bool *lr, bool *hw, bool *hr) +static inline void memprot_ll_dram0_sram_get_split_sgnf_bits(bool *lw, bool *lr, bool *hw, bool *hr) { *lw = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DRAM0_1_REG, DPORT_PMS_PRO_DRAM0_SRAM_4_L_W); *lr = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DRAM0_1_REG, DPORT_PMS_PRO_DRAM0_SRAM_4_L_R); @@ -788,13 +775,13 @@ static inline void esp_memprot_dram0_sram_get_split_sgnf_bits(bool *lw, bool *lr *hr = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DRAM0_1_REG, DPORT_PMS_PRO_DRAM0_SRAM_4_H_R); } -static inline void esp_memprot_dram0_sram_set_read_perm(bool lr, bool hr) +static inline void memprot_ll_dram0_sram_set_read_perm(bool lr, bool hr) { DPORT_REG_SET_FIELD(DPORT_PMS_PRO_DRAM0_1_REG, DPORT_PMS_PRO_DRAM0_SRAM_4_L_R, lr ? 1 : 0); DPORT_REG_SET_FIELD(DPORT_PMS_PRO_DRAM0_1_REG, DPORT_PMS_PRO_DRAM0_SRAM_4_H_R, hr ? 1 : 0); } -static inline void esp_memprot_dram0_sram_set_write_perm(bool lw, bool hw) +static inline void memprot_ll_dram0_sram_set_write_perm(bool lw, bool hw) { DPORT_REG_SET_FIELD(DPORT_PMS_PRO_DRAM0_1_REG, DPORT_PMS_PRO_DRAM0_SRAM_4_L_W, lw ? 1 : 0); DPORT_REG_SET_FIELD(DPORT_PMS_PRO_DRAM0_1_REG, DPORT_PMS_PRO_DRAM0_SRAM_4_H_W, hw ? 1 : 0); @@ -806,34 +793,35 @@ static inline void esp_memprot_dram0_sram_set_write_perm(bool lw, bool hw) * === DRAM0 RTC FAST * ======================================================================================== */ -#define DRAM0_RTCFAST_ADDRESS_LOW 0x3FF9E000 -#define DRAM0_RTCFAST_ADDRESS_HIGH 0x3FF9FFFF -#define DRAM0_RTCFAST_INTR_ST_FAULTADDR_HI 0x3FF00000 //RTCFAST high bits 31:22 of the faulting address - constant -#define DRAM0_RTCFAST_ADDR_TO_CONF_REG(addr) (((addr >> CONF_REG_ADDRESS_SHIFT) & DPORT_PMS_PRO_DRAM0_RTCFAST_SPLTADDR) << DPORT_PMS_PRO_DRAM0_RTCFAST_SPLTADDR_S) - - -static inline uint32_t *esp_memprot_dram0_rtcfast_get_fault_address(void) +static inline intptr_t memprot_ll_dram0_rtcfast_get_fault_address(void) { - uint32_t status_bits = esp_memprot_dram0_get_fault_reg(); - return (uint32_t *)(((status_bits & DRAM0_INTR_ST_FAULTADDR_M) >> DRAM0_INTR_ST_FAULTADDR_S) | DRAM0_RTCFAST_INTR_ST_FAULTADDR_HI); + uint32_t status_bits = memprot_ll_dram0_get_fault_reg(); + return (intptr_t)(((status_bits & DRAM0_INTR_ST_FAULTADDR_M) >> DRAM0_INTR_ST_FAULTADDR_S) | DRAM0_RTCFAST_INTR_ST_FAULTADDR_HI); } -static inline bool esp_memprot_dram0_rtcfast_is_intr_mine(void) +static inline bool memprot_ll_dram0_rtcfast_is_intr_mine(void) { - if (esp_memprot_dram0_is_assoc_intr()) { - uint32_t *faulting_address = esp_memprot_dram0_rtcfast_get_fault_address(); - return (uint32_t)faulting_address >= DRAM0_RTCFAST_ADDRESS_LOW && (uint32_t)faulting_address <= DRAM0_RTCFAST_ADDRESS_HIGH; + if (memprot_ll_dram0_is_assoc_intr()) { + uint32_t faulting_address = (uint32_t)memprot_ll_dram0_rtcfast_get_fault_address(); + return faulting_address >= DRAM0_RTCFAST_ADDRESS_LOW && faulting_address <= DRAM0_RTCFAST_ADDRESS_HIGH; } return false; } -static inline void esp_memprot_dram0_rtcfast_set_prot(uint32_t *split_addr, bool lw, bool lr, bool hw, bool hr) +static inline memprot_ll_err_t memprot_ll_dram0_rtcfast_set_prot(uint32_t *split_addr, bool lw, bool lr, bool hw, bool hr) { uint32_t addr = (uint32_t)split_addr; - HAL_ASSERT(addr % 0x4 == 0); + + //addr: 32bit aligned, inside corresponding range + if (addr < DRAM0_RTCFAST_ADDRESS_LOW || addr > DRAM0_RTCFAST_ADDRESS_HIGH) { + return MEMP_LL_ERR_SPLIT_ADDR_INVALID; + } + if (addr % 0x4 != 0) { + return MEMP_LL_ERR_SPLIT_ADDR_UNALIGNED; + } //conf reg [10:0] - uint32_t reg_split_addr = DRAM0_RTCFAST_ADDR_TO_CONF_REG( addr ); + uint32_t reg_split_addr = DRAM0_RTCFAST_ADDR_TO_CONF_REG(addr); //prepare high & low permission mask uint32_t permission_mask = 0; @@ -852,9 +840,11 @@ static inline void esp_memprot_dram0_rtcfast_set_prot(uint32_t *split_addr, bool //write DRAM0 RTC FAST cfg register DPORT_WRITE_PERI_REG(DPORT_PMS_PRO_DRAM0_2_REG, reg_split_addr | permission_mask); + + return MEMP_LL_OK; } -static inline void esp_memprot_dram0_rtcfast_get_split_sgnf_bits(bool *lw, bool *lr, bool *hw, bool *hr) +static inline void memprot_ll_dram0_rtcfast_get_split_sgnf_bits(bool *lw, bool *lr, bool *hw, bool *hr) { *lw = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DRAM0_2_REG, DPORT_PMS_PRO_DRAM0_RTCFAST_L_W); *lr = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DRAM0_2_REG, DPORT_PMS_PRO_DRAM0_RTCFAST_L_R); @@ -862,18 +852,18 @@ static inline void esp_memprot_dram0_rtcfast_get_split_sgnf_bits(bool *lw, bool *hr = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DRAM0_2_REG, DPORT_PMS_PRO_DRAM0_RTCFAST_H_R); } -static inline uint32_t esp_memprot_dram0_rtcfast_get_perm_split_reg(void) +static inline uint32_t memprot_ll_dram0_rtcfast_get_perm_split_reg(void) { return DPORT_READ_PERI_REG(DPORT_PMS_PRO_DRAM0_2_REG); } -static inline void esp_memprot_dram0_rtcfast_set_read_perm(bool lr, bool hr) +static inline void memprot_ll_dram0_rtcfast_set_read_perm(bool lr, bool hr) { DPORT_REG_SET_FIELD(DPORT_PMS_PRO_DRAM0_2_REG, DPORT_PMS_PRO_DRAM0_RTCFAST_L_R, lr ? 1 : 0); DPORT_REG_SET_FIELD(DPORT_PMS_PRO_DRAM0_2_REG, DPORT_PMS_PRO_DRAM0_RTCFAST_H_R, hr ? 1 : 0); } -static inline void esp_memprot_dram0_rtcfast_set_write_perm(bool lw, bool hw) +static inline void memprot_ll_dram0_rtcfast_set_write_perm(bool lw, bool hw) { DPORT_REG_SET_FIELD(DPORT_PMS_PRO_DRAM0_2_REG, DPORT_PMS_PRO_DRAM0_RTCFAST_L_W, lw ? 1 : 0); DPORT_REG_SET_FIELD(DPORT_PMS_PRO_DRAM0_2_REG, DPORT_PMS_PRO_DRAM0_RTCFAST_H_W, hw ? 1 : 0); diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/memprot_peri_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/memprot_peri_ll.h index d699df6cf41..4611f7a35d7 100644 --- a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/memprot_peri_ll.h +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/memprot_peri_ll.h @@ -14,38 +14,31 @@ #pragma once -#include "hal/assert.h" +#include +#include "soc/memprot_defs.h" +#include "hal/memprot_types.h" #ifdef __cplusplus extern "C" { #endif -#define RTCSLOW_MEMORY_SIZE 0x00002000 - /** * ======================================================================================== * === PeriBus1 common * ======================================================================================== */ -//PeriBus1 interrupt status bitmasks -#define PERI1_INTR_ST_OP_TYPE_BIT BIT(4) //0: non-atomic, 1: atomic -#define PERI1_INTR_ST_OP_HIGH_BITS BIT(5) //0: high bits = unchanged, 1: high bits = 0x03F40000 -#define PERI1_INTR_ST_FAULTADDR_M 0x03FFFFC0 //(bits 25:6 in the reg) -#define PERI1_INTR_ST_FAULTADDR_S 0x4 //(bits 21:2 of real address) - - -static inline void esp_memprot_peri1_clear_intr(void) +static inline void memprot_ll_peri1_clear_intr(void) { DPORT_SET_PERI_REG_MASK(DPORT_PMS_PRO_DPORT_6_REG, DPORT_PMS_PRO_DPORT_ILG_CLR); DPORT_CLEAR_PERI_REG_MASK(DPORT_PMS_PRO_DPORT_6_REG, DPORT_PMS_PRO_DPORT_ILG_CLR); } -static inline uint32_t esp_memprot_peri1_get_intr_source_num(void) +static inline uint32_t memprot_ll_peri1_get_intr_source_num(void) { return ETS_PMS_PRO_DPORT_ILG_INTR_SOURCE; } -static inline void esp_memprot_peri1_intr_ena(bool enable) +static inline void memprot_ll_peri1_intr_ena(bool enable) { if (enable) { DPORT_SET_PERI_REG_MASK(DPORT_PMS_PRO_DPORT_6_REG, DPORT_PMS_PRO_DPORT_ILG_EN); @@ -54,95 +47,94 @@ static inline void esp_memprot_peri1_intr_ena(bool enable) } } -static inline uint32_t esp_memprot_peri1_get_ctrl_reg(void) +static inline uint32_t memprot_ll_peri1_get_ctrl_reg(void) { return DPORT_READ_PERI_REG(DPORT_PMS_PRO_DPORT_6_REG); } -static inline uint32_t esp_memprot_peri1_get_fault_reg(void) +static inline uint32_t memprot_ll_peri1_get_fault_reg(void) { return DPORT_READ_PERI_REG(DPORT_PMS_PRO_DPORT_7_REG); } -static inline void esp_memprot_peri1_get_fault_op_type(uint32_t *op_type, uint32_t *op_subtype) +static inline void memprot_ll_peri1_get_fault_op_type(uint32_t *op_type, uint32_t *op_subtype) { - uint32_t status_bits = esp_memprot_peri1_get_fault_reg(); + uint32_t status_bits = memprot_ll_peri1_get_fault_reg(); //*op_type = (uint32_t)status_bits & PERI1_INTR_ST_OP_RW_BIT; *op_type = 0; //! DPORT_PMS_PRO_DPORT_7_REG is missing op_type bit *op_subtype = (uint32_t)status_bits & PERI1_INTR_ST_OP_TYPE_BIT; } -static inline bool esp_memprot_peri1_is_assoc_intr(void) +static inline bool memprot_ll_peri1_is_assoc_intr(void) { return DPORT_GET_PERI_REG_MASK(DPORT_PMS_PRO_DPORT_7_REG, DPORT_PMS_PRO_DPORT_ILG_INTR) > 0; } -static inline uint32_t esp_memprot_peri1_get_intr_ena_bit(void) +static inline uint32_t memprot_ll_peri1_get_intr_ena_bit(void) { return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DPORT_6_REG, DPORT_PMS_PRO_DPORT_ILG_EN); } -static inline uint32_t esp_memprot_peri1_get_intr_on_bit(void) +static inline uint32_t memprot_ll_peri1_get_intr_on_bit(void) { return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DPORT_6_REG, DPORT_PMS_PRO_DPORT_ILG_INTR); } -static inline uint32_t esp_memprot_peri1_get_intr_clr_bit(void) +static inline uint32_t memprot_ll_peri1_get_intr_clr_bit(void) { return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DPORT_6_REG, DPORT_PMS_PRO_DPORT_ILG_CLR); } -static inline uint32_t esp_memprot_peri1_get_lock_reg(void) +static inline uint32_t memprot_ll_peri1_get_lock_reg(void) { return DPORT_READ_PERI_REG(DPORT_PMS_PRO_DPORT_0_REG); } //resets automatically on CPU restart -static inline void esp_memprot_peri1_set_lock(void) +static inline void memprot_ll_peri1_set_lock(void) { DPORT_WRITE_PERI_REG(DPORT_PMS_PRO_DPORT_0_REG, DPORT_PMS_PRO_DPORT_LOCK); } -static inline uint32_t esp_memprot_peri1_get_lock_bit(void) +static inline uint32_t memprot_ll_peri1_get_lock_bit(void) { return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DPORT_0_REG, DPORT_PMS_PRO_DPORT_LOCK); } - /** * ======================================================================================== * === PeriBus1 RTC SLOW * ======================================================================================== */ -#define PERI1_RTCSLOW_ADDRESS_BASE 0x3F421000 -#define PERI1_RTCSLOW_ADDRESS_LOW PERI1_RTCSLOW_ADDRESS_BASE -#define PERI1_RTCSLOW_ADDRESS_HIGH PERI1_RTCSLOW_ADDRESS_LOW + RTCSLOW_MEMORY_SIZE -#define PERI1_RTCSLOW_INTR_ST_FAULTADDR_HI_0 0x3F400000 - -#define PERI1_RTCSLOW_ADDR_TO_CONF_REG(addr) (((addr >> CONF_REG_ADDRESS_SHIFT) & DPORT_PMS_PRO_DPORT_RTCSLOW_SPLTADDR) << DPORT_PMS_PRO_DPORT_RTCSLOW_SPLTADDR_S) - -static inline uint32_t *esp_memprot_peri1_rtcslow_get_fault_address(void) +static inline intptr_t memprot_ll_peri1_rtcslow_get_fault_address(void) { - uint32_t status_bits = esp_memprot_peri1_get_fault_reg(); + uint32_t status_bits = memprot_ll_peri1_get_fault_reg(); uint32_t fault_address = (status_bits & PERI1_INTR_ST_FAULTADDR_M) >> PERI1_INTR_ST_FAULTADDR_S; uint32_t high_bits = (status_bits & PERI1_INTR_ST_OP_HIGH_BITS) ? PERI1_RTCSLOW_INTR_ST_FAULTADDR_HI_0 : 0; - return (uint32_t *)(fault_address | high_bits); + return (intptr_t)(fault_address | high_bits); } -static inline bool esp_memprot_peri1_rtcslow_is_intr_mine(void) +static inline bool memprot_ll_peri1_rtcslow_is_intr_mine(void) { - if (esp_memprot_dram0_is_assoc_intr()) { - uint32_t *faulting_address = esp_memprot_peri1_rtcslow_get_fault_address(); - return (uint32_t)faulting_address >= PERI1_RTCSLOW_ADDRESS_LOW && (uint32_t)faulting_address <= PERI1_RTCSLOW_ADDRESS_HIGH; + if (memprot_ll_dram0_is_assoc_intr()) { + uint32_t faulting_address = (uint32_t)memprot_ll_peri1_rtcslow_get_fault_address(); + return faulting_address >= PERI1_RTCSLOW_ADDRESS_LOW && faulting_address <= PERI1_RTCSLOW_ADDRESS_HIGH; } return false; } -static inline void esp_memprot_peri1_rtcslow_set_prot(uint32_t *split_addr, bool lw, bool lr, bool hw, bool hr) +static inline memprot_ll_err_t memprot_ll_peri1_rtcslow_set_prot(uint32_t *split_addr, bool lw, bool lr, bool hw, bool hr) { uint32_t addr = (uint32_t)split_addr; - HAL_ASSERT(addr % 0x4 == 0); + + //check corresponding range fit & aligment to 32bit boundaries + if (addr < PERI1_RTCSLOW_ADDRESS_LOW || addr > PERI1_RTCSLOW_ADDRESS_HIGH) { + return MEMP_LL_ERR_SPLIT_ADDR_INVALID; + } + if (addr % 0x4 != 0) { + return MEMP_LL_ERR_SPLIT_ADDR_UNALIGNED; + } uint32_t reg_split_addr = PERI1_RTCSLOW_ADDR_TO_CONF_REG(addr); @@ -163,9 +155,11 @@ static inline void esp_memprot_peri1_rtcslow_set_prot(uint32_t *split_addr, bool //write PERIBUS1 RTC SLOW cfg register DPORT_WRITE_PERI_REG(DPORT_PMS_PRO_DPORT_1_REG, reg_split_addr | permission_mask); + + return MEMP_LL_OK; } -static inline void esp_memprot_peri1_rtcslow_get_split_sgnf_bits(bool *lw, bool *lr, bool *hw, bool *hr) +static inline void memprot_ll_peri1_rtcslow_get_split_sgnf_bits(bool *lw, bool *lr, bool *hw, bool *hr) { *lw = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DPORT_1_REG, DPORT_PMS_PRO_DPORT_RTCSLOW_L_W); *lr = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DPORT_1_REG, DPORT_PMS_PRO_DPORT_RTCSLOW_L_R); @@ -173,46 +167,40 @@ static inline void esp_memprot_peri1_rtcslow_get_split_sgnf_bits(bool *lw, bool *hr = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_DPORT_1_REG, DPORT_PMS_PRO_DPORT_RTCSLOW_H_R); } -static inline void esp_memprot_peri1_rtcslow_set_read_perm(bool lr, bool hr) +static inline void memprot_ll_peri1_rtcslow_set_read_perm(bool lr, bool hr) { DPORT_REG_SET_FIELD(DPORT_PMS_PRO_DPORT_1_REG, DPORT_PMS_PRO_DPORT_RTCSLOW_L_R, lr ? 1 : 0); DPORT_REG_SET_FIELD(DPORT_PMS_PRO_DPORT_1_REG, DPORT_PMS_PRO_DPORT_RTCSLOW_H_R, hr ? 1 : 0); } -static inline void esp_memprot_peri1_rtcslow_set_write_perm(bool lw, bool hw) +static inline void memprot_ll_peri1_rtcslow_set_write_perm(bool lw, bool hw) { DPORT_REG_SET_FIELD(DPORT_PMS_PRO_DPORT_1_REG, DPORT_PMS_PRO_DPORT_RTCSLOW_L_W, lw ? 1 : 0); DPORT_REG_SET_FIELD(DPORT_PMS_PRO_DPORT_1_REG, DPORT_PMS_PRO_DPORT_RTCSLOW_H_W, hw ? 1 : 0); } -static inline uint32_t esp_memprot_peri1_rtcslow_get_conf_reg(void) +static inline uint32_t memprot_ll_peri1_rtcslow_get_conf_reg(void) { return DPORT_READ_PERI_REG(DPORT_PMS_PRO_DPORT_1_REG); } - /** * ======================================================================================== * === PeriBus2 common * ======================================================================================== */ -//PeriBus2 interrupt status bitmasks -#define PERI2_INTR_ST_OP_TYPE_BIT BIT(1) //instruction: 0, data: 1 -#define PERI2_INTR_ST_OP_RW_BIT BIT(0) //read: 0, write: 1 -#define PERI2_INTR_ST_FAULTADDR_M 0xFFFFFFFC //(bits 31:2 in the reg) - -static inline void esp_memprot_peri2_clear_intr(void) +static inline void memprot_ll_peri2_clear_intr(void) { DPORT_SET_PERI_REG_MASK(DPORT_PMS_PRO_AHB_3_REG, DPORT_PMS_PRO_AHB_ILG_CLR); DPORT_CLEAR_PERI_REG_MASK(DPORT_PMS_PRO_AHB_3_REG, DPORT_PMS_PRO_AHB_ILG_CLR); } -static inline uint32_t esp_memprot_peri2_get_intr_source_num(void) +static inline uint32_t memprot_ll_peri2_get_intr_source_num(void) { return ETS_PMS_PRO_AHB_ILG_INTR_SOURCE; } -static inline void esp_memprot_peri2_intr_ena(bool enable) +static inline void memprot_ll_peri2_intr_ena(bool enable) { if (enable) { DPORT_SET_PERI_REG_MASK(DPORT_PMS_PRO_AHB_3_REG, DPORT_PMS_PRO_AHB_ILG_EN); @@ -221,90 +209,90 @@ static inline void esp_memprot_peri2_intr_ena(bool enable) } } -static inline uint32_t esp_memprot_peri2_get_ctrl_reg(void) +static inline uint32_t memprot_ll_peri2_get_ctrl_reg(void) { return DPORT_READ_PERI_REG(DPORT_PMS_PRO_AHB_3_REG); } -static inline uint32_t esp_memprot_peri2_get_fault_reg(void) +static inline uint32_t memprot_ll_peri2_get_fault_reg(void) { return DPORT_READ_PERI_REG(DPORT_PMS_PRO_AHB_4_REG); } -static inline void esp_memprot_peri2_get_fault_op_type(uint32_t *op_type, uint32_t *op_subtype) +static inline void memprot_ll_peri2_get_fault_op_type(uint32_t *op_type, uint32_t *op_subtype) { - uint32_t status_bits = esp_memprot_peri2_get_fault_reg(); + uint32_t status_bits = memprot_ll_peri2_get_fault_reg(); *op_type = (uint32_t)status_bits & PERI2_INTR_ST_OP_RW_BIT; *op_subtype = (uint32_t)status_bits & PERI2_INTR_ST_OP_TYPE_BIT; } -static inline bool esp_memprot_peri2_is_assoc_intr(void) +static inline bool memprot_ll_peri2_is_assoc_intr(void) { return DPORT_GET_PERI_REG_MASK(DPORT_PMS_PRO_AHB_3_REG, DPORT_PMS_PRO_AHB_ILG_INTR) > 0; } -static inline uint32_t esp_memprot_peri2_get_intr_ena_bit(void) +static inline uint32_t memprot_ll_peri2_get_intr_ena_bit(void) { return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_AHB_3_REG, DPORT_PMS_PRO_AHB_ILG_EN); } -static inline uint32_t esp_memprot_peri2_get_intr_on_bit(void) +static inline uint32_t memprot_ll_peri2_get_intr_on_bit(void) { return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_AHB_3_REG, DPORT_PMS_PRO_AHB_ILG_INTR); } -static inline uint32_t esp_memprot_peri2_get_intr_clr_bit(void) +static inline uint32_t memprot_ll_peri2_get_intr_clr_bit(void) { return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_AHB_3_REG, DPORT_PMS_PRO_AHB_ILG_CLR); } -static inline uint32_t esp_memprot_peri2_get_lock_reg(void) +static inline uint32_t memprot_ll_peri2_get_lock_reg(void) { return DPORT_READ_PERI_REG(DPORT_PMS_PRO_AHB_0_REG); } //resets automatically on CPU restart -static inline void esp_memprot_peri2_set_lock(void) +static inline void memprot_ll_peri2_set_lock(void) { DPORT_WRITE_PERI_REG(DPORT_PMS_PRO_AHB_0_REG, DPORT_PMS_PRO_AHB_LOCK); } -static inline uint32_t esp_memprot_peri2_get_lock_bit(void) +static inline uint32_t memprot_ll_peri2_get_lock_bit(void) { return DPORT_REG_GET_FIELD(DPORT_PMS_PRO_AHB_0_REG, DPORT_PMS_PRO_AHB_LOCK); } -static inline uint32_t *esp_memprot_peri2_rtcslow_get_fault_address(void) +static inline intptr_t memprot_ll_peri2_rtcslow_get_fault_address(void) { - uint32_t status_bits = esp_memprot_peri2_get_fault_reg(); - return (uint32_t *)(status_bits & PERI2_INTR_ST_FAULTADDR_M); + uint32_t status_bits = memprot_ll_peri2_get_fault_reg(); + return (intptr_t)(status_bits & PERI2_INTR_ST_FAULTADDR_M); } - /** * ======================================================================================== * === PeriBus2 RTC SLOW 0 (AHB0) * ======================================================================================== */ -#define PERI2_RTCSLOW_0_ADDRESS_BASE 0x50000000 -#define PERI2_RTCSLOW_0_ADDRESS_LOW PERI2_RTCSLOW_0_ADDRESS_BASE -#define PERI2_RTCSLOW_0_ADDRESS_HIGH PERI2_RTCSLOW_0_ADDRESS_LOW + RTCSLOW_MEMORY_SIZE - -#define PERI2_RTCSLOW_0_ADDR_TO_CONF_REG(addr) (((addr >> CONF_REG_ADDRESS_SHIFT) & DPORT_PMS_PRO_AHB_RTCSLOW_0_SPLTADDR) << DPORT_PMS_PRO_AHB_RTCSLOW_0_SPLTADDR_S) - -static inline bool esp_memprot_peri2_rtcslow_0_is_intr_mine(void) +static inline bool memprot_ll_peri2_rtcslow_0_is_intr_mine(void) { - if (esp_memprot_peri2_is_assoc_intr()) { - uint32_t *faulting_address = esp_memprot_peri2_rtcslow_get_fault_address(); - return (uint32_t)faulting_address >= PERI2_RTCSLOW_0_ADDRESS_LOW && (uint32_t)faulting_address <= PERI2_RTCSLOW_0_ADDRESS_HIGH; + if (memprot_ll_peri2_is_assoc_intr()) { + uint32_t faulting_address = (uint32_t)memprot_ll_peri2_rtcslow_get_fault_address(); + return faulting_address >= PERI2_RTCSLOW_0_ADDRESS_LOW && faulting_address <= PERI2_RTCSLOW_0_ADDRESS_HIGH; } return false; } -static inline void esp_memprot_peri2_rtcslow_0_set_prot(uint32_t *split_addr, bool lw, bool lr, bool lx, bool hw, bool hr, bool hx) +static inline memprot_ll_err_t memprot_ll_peri2_rtcslow_0_set_prot(uint32_t *split_addr, bool lw, bool lr, bool lx, bool hw, bool hr, bool hx) { uint32_t addr = (uint32_t)split_addr; - HAL_ASSERT(addr % 0x4 == 0); + + //check corresponding range fit & aligment to 32bit boundaries + if (addr < PERI2_RTCSLOW_0_ADDRESS_LOW || addr > PERI2_RTCSLOW_0_ADDRESS_HIGH) { + return MEMP_LL_ERR_SPLIT_ADDR_INVALID; + } + if (addr % 0x4 != 0) { + return MEMP_LL_ERR_SPLIT_ADDR_UNALIGNED; + } uint32_t reg_split_addr = PERI2_RTCSLOW_0_ADDR_TO_CONF_REG(addr); @@ -331,9 +319,11 @@ static inline void esp_memprot_peri2_rtcslow_0_set_prot(uint32_t *split_addr, bo //write PERIBUS1 RTC SLOW cfg register DPORT_WRITE_PERI_REG(DPORT_PMS_PRO_AHB_1_REG, reg_split_addr | permission_mask); + + return MEMP_LL_OK; } -static inline void esp_memprot_peri2_rtcslow_0_get_split_sgnf_bits(bool *lw, bool *lr, bool *lx, bool *hw, bool *hr, bool *hx) +static inline void memprot_ll_peri2_rtcslow_0_get_split_sgnf_bits(bool *lw, bool *lr, bool *lx, bool *hw, bool *hr, bool *hx) { *lw = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_AHB_1_REG, DPORT_PMS_PRO_AHB_RTCSLOW_0_L_W); *lr = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_AHB_1_REG, DPORT_PMS_PRO_AHB_RTCSLOW_0_L_R); @@ -343,25 +333,25 @@ static inline void esp_memprot_peri2_rtcslow_0_get_split_sgnf_bits(bool *lw, boo *hx = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_AHB_1_REG, DPORT_PMS_PRO_AHB_RTCSLOW_0_H_F); } -static inline void esp_memprot_peri2_rtcslow_0_set_read_perm(bool lr, bool hr) +static inline void memprot_ll_peri2_rtcslow_0_set_read_perm(bool lr, bool hr) { DPORT_REG_SET_FIELD(DPORT_PMS_PRO_AHB_1_REG, DPORT_PMS_PRO_AHB_RTCSLOW_0_L_R, lr ? 1 : 0); DPORT_REG_SET_FIELD(DPORT_PMS_PRO_AHB_1_REG, DPORT_PMS_PRO_AHB_RTCSLOW_0_H_R, hr ? 1 : 0); } -static inline void esp_memprot_peri2_rtcslow_0_set_write_perm(bool lw, bool hw) +static inline void memprot_ll_peri2_rtcslow_0_set_write_perm(bool lw, bool hw) { DPORT_REG_SET_FIELD(DPORT_PMS_PRO_AHB_1_REG, DPORT_PMS_PRO_AHB_RTCSLOW_0_L_W, lw ? 1 : 0); DPORT_REG_SET_FIELD(DPORT_PMS_PRO_AHB_1_REG, DPORT_PMS_PRO_AHB_RTCSLOW_0_H_W, hw ? 1 : 0); } -static inline void esp_memprot_peri2_rtcslow_0_set_exec_perm(bool lx, bool hx) +static inline void memprot_ll_peri2_rtcslow_0_set_exec_perm(bool lx, bool hx) { DPORT_REG_SET_FIELD(DPORT_PMS_PRO_AHB_1_REG, DPORT_PMS_PRO_AHB_RTCSLOW_0_L_F, lx ? 1 : 0); DPORT_REG_SET_FIELD(DPORT_PMS_PRO_AHB_1_REG, DPORT_PMS_PRO_AHB_RTCSLOW_0_H_F, hx ? 1 : 0); } -static inline uint32_t esp_memprot_peri2_rtcslow_0_get_conf_reg(void) +static inline uint32_t memprot_ll_peri2_rtcslow_0_get_conf_reg(void) { return DPORT_READ_PERI_REG(DPORT_PMS_PRO_DPORT_1_REG); } @@ -371,25 +361,26 @@ static inline uint32_t esp_memprot_peri2_rtcslow_0_get_conf_reg(void) * === PeriBus2 RTC SLOW 1 (AHB1) * ======================================================================================== */ -#define PERI2_RTCSLOW_1_ADDRESS_BASE 0x60021000 -#define PERI2_RTCSLOW_1_ADDRESS_LOW PERI2_RTCSLOW_1_ADDRESS_BASE -#define PERI2_RTCSLOW_1_ADDRESS_HIGH PERI2_RTCSLOW_1_ADDRESS_LOW + RTCSLOW_MEMORY_SIZE - -#define PERI2_RTCSLOW_1_ADDR_TO_CONF_REG(addr) (((addr >> CONF_REG_ADDRESS_SHIFT) & DPORT_PMS_PRO_AHB_RTCSLOW_1_SPLTADDR) << DPORT_PMS_PRO_AHB_RTCSLOW_1_SPLTADDR_S) - -static inline bool esp_memprot_peri2_rtcslow_1_is_intr_mine(void) +static inline bool memprot_ll_peri2_rtcslow_1_is_intr_mine(void) { - if (esp_memprot_peri2_is_assoc_intr()) { - uint32_t *faulting_address = esp_memprot_peri2_rtcslow_get_fault_address(); - return (uint32_t)faulting_address >= PERI2_RTCSLOW_1_ADDRESS_LOW && (uint32_t)faulting_address <= PERI2_RTCSLOW_1_ADDRESS_HIGH; + if (memprot_ll_peri2_is_assoc_intr()) { + uint32_t faulting_address = (uint32_t)memprot_ll_peri2_rtcslow_get_fault_address(); + return faulting_address >= PERI2_RTCSLOW_1_ADDRESS_LOW && faulting_address <= PERI2_RTCSLOW_1_ADDRESS_HIGH; } return false; } -static inline void esp_memprot_peri2_rtcslow_1_set_prot(uint32_t *split_addr, bool lw, bool lr, bool lx, bool hw, bool hr, bool hx) +static inline memprot_ll_err_t memprot_ll_peri2_rtcslow_1_set_prot(uint32_t *split_addr, bool lw, bool lr, bool lx, bool hw, bool hr, bool hx) { uint32_t addr = (uint32_t)split_addr; - HAL_ASSERT(addr % 0x4 == 0); + + //check corresponding range fit & aligment to 32bit boundaries + if (addr < PERI2_RTCSLOW_1_ADDRESS_LOW || addr > PERI2_RTCSLOW_1_ADDRESS_HIGH) { + return MEMP_LL_ERR_SPLIT_ADDR_INVALID; + } + if (addr % 0x4 != 0) { + return MEMP_LL_ERR_SPLIT_ADDR_UNALIGNED; + } uint32_t reg_split_addr = PERI2_RTCSLOW_1_ADDR_TO_CONF_REG(addr); @@ -416,9 +407,11 @@ static inline void esp_memprot_peri2_rtcslow_1_set_prot(uint32_t *split_addr, bo //write PERIBUS1 RTC SLOW cfg register DPORT_WRITE_PERI_REG(DPORT_PMS_PRO_AHB_2_REG, reg_split_addr | permission_mask); + + return MEMP_LL_OK; } -static inline void esp_memprot_peri2_rtcslow_1_get_split_sgnf_bits(bool *lw, bool *lr, bool *lx, bool *hw, bool *hr, bool *hx) +static inline void memprot_ll_peri2_rtcslow_1_get_split_sgnf_bits(bool *lw, bool *lr, bool *lx, bool *hw, bool *hr, bool *hx) { *lw = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_AHB_2_REG, DPORT_PMS_PRO_AHB_RTCSLOW_1_L_W); *lr = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_AHB_2_REG, DPORT_PMS_PRO_AHB_RTCSLOW_1_L_R); @@ -428,25 +421,25 @@ static inline void esp_memprot_peri2_rtcslow_1_get_split_sgnf_bits(bool *lw, boo *hx = DPORT_REG_GET_FIELD(DPORT_PMS_PRO_AHB_2_REG, DPORT_PMS_PRO_AHB_RTCSLOW_1_H_F); } -static inline void esp_memprot_peri2_rtcslow_1_set_read_perm(bool lr, bool hr) +static inline void memprot_ll_peri2_rtcslow_1_set_read_perm(bool lr, bool hr) { DPORT_REG_SET_FIELD(DPORT_PMS_PRO_AHB_2_REG, DPORT_PMS_PRO_AHB_RTCSLOW_1_L_R, lr ? 1 : 0); DPORT_REG_SET_FIELD(DPORT_PMS_PRO_AHB_2_REG, DPORT_PMS_PRO_AHB_RTCSLOW_1_H_R, hr ? 1 : 0); } -static inline void esp_memprot_peri2_rtcslow_1_set_write_perm(bool lw, bool hw) +static inline void memprot_ll_peri2_rtcslow_1_set_write_perm(bool lw, bool hw) { DPORT_REG_SET_FIELD(DPORT_PMS_PRO_AHB_2_REG, DPORT_PMS_PRO_AHB_RTCSLOW_1_L_W, lw ? 1 : 0); DPORT_REG_SET_FIELD(DPORT_PMS_PRO_AHB_2_REG, DPORT_PMS_PRO_AHB_RTCSLOW_1_H_W, hw ? 1 : 0); } -static inline void esp_memprot_peri2_rtcslow_1_set_exec_perm(bool lx, bool hx) +static inline void memprot_ll_peri2_rtcslow_1_set_exec_perm(bool lx, bool hx) { DPORT_REG_SET_FIELD(DPORT_PMS_PRO_AHB_2_REG, DPORT_PMS_PRO_AHB_RTCSLOW_1_L_F, lx ? 1 : 0); DPORT_REG_SET_FIELD(DPORT_PMS_PRO_AHB_2_REG, DPORT_PMS_PRO_AHB_RTCSLOW_1_H_F, hx ? 1 : 0); } -static inline uint32_t esp_memprot_peri2_rtcslow_1_get_conf_reg(void) +static inline uint32_t memprot_ll_peri2_rtcslow_1_get_conf_reg(void) { return DPORT_READ_PERI_REG(DPORT_PMS_PRO_DPORT_2_REG); } diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/mwdt_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/mwdt_ll.h index f909678b397..6d50f740b6b 100644 --- a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/mwdt_ll.h +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/mwdt_ll.h @@ -24,6 +24,7 @@ extern "C" { #include #include #include "soc/timer_periph.h" +#include "soc/timer_group_struct.h" #include "hal/wdt_types.h" #include "esp_attr.h" @@ -42,6 +43,13 @@ _Static_assert(WDT_RESET_SIG_LENGTH_800ns == TIMG_WDT_RESET_LENGTH_800_NS, "Add _Static_assert(WDT_RESET_SIG_LENGTH_1_6us == TIMG_WDT_RESET_LENGTH_1600_NS, "Add mapping to LL watchdog timeout behavior, since it's no longer naturally compatible with wdt_reset_sig_length_t"); _Static_assert(WDT_RESET_SIG_LENGTH_3_2us == TIMG_WDT_RESET_LENGTH_3200_NS, "Add mapping to LL watchdog timeout behavior, since it's no longer naturally compatible with wdt_reset_sig_length_t"); +#define FORCE_MODIFY_WHOLE_REG(i, j, k) \ +{ \ + typeof(i) temp_reg = (i); \ + temp_reg.j = (k); \ + (i) = temp_reg; \ +} + /** * @brief Enable the MWDT * @@ -49,7 +57,7 @@ _Static_assert(WDT_RESET_SIG_LENGTH_3_2us == TIMG_WDT_RESET_LENGTH_3200_NS, "Add */ FORCE_INLINE_ATTR void mwdt_ll_enable(timg_dev_t *hw) { - hw->wdt_config0.en = 1; + hw->wdtconfig0.wdt_en = 1; } /** @@ -62,7 +70,7 @@ FORCE_INLINE_ATTR void mwdt_ll_enable(timg_dev_t *hw) */ FORCE_INLINE_ATTR void mwdt_ll_disable(timg_dev_t *hw) { - hw->wdt_config0.en = 0; + hw->wdtconfig0.wdt_en = 0; } /** @@ -73,7 +81,7 @@ FORCE_INLINE_ATTR void mwdt_ll_disable(timg_dev_t *hw) */ FORCE_INLINE_ATTR bool mwdt_ll_check_if_enabled(timg_dev_t *hw) { - return (hw->wdt_config0.en) ? true : false; + return (hw->wdtconfig0.wdt_en) ? true : false; } /** @@ -88,20 +96,20 @@ FORCE_INLINE_ATTR void mwdt_ll_config_stage(timg_dev_t *hw, wdt_stage_t stage, u { switch (stage) { case WDT_STAGE0: - hw->wdt_config0.stg0 = behavior; - hw->wdt_config2 = timeout; + hw->wdtconfig0.wdt_stg0 = behavior; + hw->wdtconfig2.wdt_stg0_hold = timeout; break; case WDT_STAGE1: - hw->wdt_config0.stg1 = behavior; - hw->wdt_config3 = timeout; + hw->wdtconfig0.wdt_stg1 = behavior; + hw->wdtconfig3.wdt_stg1_hold = timeout; break; case WDT_STAGE2: - hw->wdt_config0.stg2 = behavior; - hw->wdt_config4 = timeout; + hw->wdtconfig0.wdt_stg2 = behavior; + hw->wdtconfig4.wdt_stg2_hold = timeout; break; case WDT_STAGE3: - hw->wdt_config0.stg3 = behavior; - hw->wdt_config5 = timeout; + hw->wdtconfig0.wdt_stg3 = behavior; + hw->wdtconfig5.wdt_stg3_hold = timeout; break; default: break; @@ -118,16 +126,16 @@ FORCE_INLINE_ATTR void mwdt_ll_disable_stage(timg_dev_t *hw, uint32_t stage) { switch (stage) { case WDT_STAGE0: - hw->wdt_config0.stg0 = WDT_STAGE_ACTION_OFF; + hw->wdtconfig0.wdt_stg0 = WDT_STAGE_ACTION_OFF; break; case WDT_STAGE1: - hw->wdt_config0.stg1 = WDT_STAGE_ACTION_OFF; + hw->wdtconfig0.wdt_stg1 = WDT_STAGE_ACTION_OFF; break; case WDT_STAGE2: - hw->wdt_config0.stg2 = WDT_STAGE_ACTION_OFF; + hw->wdtconfig0.wdt_stg2 = WDT_STAGE_ACTION_OFF; break; case WDT_STAGE3: - hw->wdt_config0.stg3 = WDT_STAGE_ACTION_OFF; + hw->wdtconfig0.wdt_stg3 = WDT_STAGE_ACTION_OFF; break; default: break; @@ -142,7 +150,7 @@ FORCE_INLINE_ATTR void mwdt_ll_disable_stage(timg_dev_t *hw, uint32_t stage) */ FORCE_INLINE_ATTR void mwdt_ll_set_edge_intr(timg_dev_t *hw, bool enable) { - hw->wdt_config0.edge_int_en = (enable) ? 1 : 0; + hw->wdtconfig0.wdt_edge_int_en = (enable) ? 1 : 0; } /** @@ -153,7 +161,7 @@ FORCE_INLINE_ATTR void mwdt_ll_set_edge_intr(timg_dev_t *hw, bool enable) */ FORCE_INLINE_ATTR void mwdt_ll_set_level_intr(timg_dev_t *hw, bool enable) { - hw->wdt_config0.level_int_en = (enable) ? 1 : 0; + hw->wdtconfig0.wdt_level_int_en = (enable) ? 1 : 0; } /** @@ -164,7 +172,7 @@ FORCE_INLINE_ATTR void mwdt_ll_set_level_intr(timg_dev_t *hw, bool enable) */ FORCE_INLINE_ATTR void mwdt_ll_set_cpu_reset_length(timg_dev_t *hw, wdt_reset_sig_length_t length) { - hw->wdt_config0.cpu_reset_length = length; + hw->wdtconfig0.wdt_cpu_reset_length = length; } /** @@ -175,7 +183,7 @@ FORCE_INLINE_ATTR void mwdt_ll_set_cpu_reset_length(timg_dev_t *hw, wdt_reset_si */ FORCE_INLINE_ATTR void mwdt_ll_set_sys_reset_length(timg_dev_t *hw, wdt_reset_sig_length_t length) { - hw->wdt_config0.sys_reset_length = length; + hw->wdtconfig0.wdt_sys_reset_length = length; } /** @@ -190,7 +198,7 @@ FORCE_INLINE_ATTR void mwdt_ll_set_sys_reset_length(timg_dev_t *hw, wdt_reset_si */ FORCE_INLINE_ATTR void mwdt_ll_set_flashboot_en(timg_dev_t* hw, bool enable) { - hw->wdt_config0.flashboot_mod_en = (enable) ? 1 : 0; + hw->wdtconfig0.wdt_flashboot_mod_en = (enable) ? 1 : 0; } /** @@ -201,7 +209,9 @@ FORCE_INLINE_ATTR void mwdt_ll_set_flashboot_en(timg_dev_t* hw, bool enable) */ FORCE_INLINE_ATTR void mwdt_ll_set_prescaler(timg_dev_t *hw, uint32_t prescaler) { - hw->wdt_config1.clk_prescale = prescaler; + // In case the compiler optimise a 32bit instruction (e.g. s32i) into 8/16bit instruction (e.g. s8i, which is not allowed to access a register) + // We take care of the "read-modify-write" procedure by ourselves. + FORCE_MODIFY_WHOLE_REG(hw->wdtconfig1, wdt_clk_prescaler, prescaler); } /** @@ -213,7 +223,7 @@ FORCE_INLINE_ATTR void mwdt_ll_set_prescaler(timg_dev_t *hw, uint32_t prescaler) */ FORCE_INLINE_ATTR void mwdt_ll_feed(timg_dev_t *hw) { - hw->wdt_feed = 1; + hw->wdtfeed.wdt_feed = 1; } /** @@ -225,7 +235,7 @@ FORCE_INLINE_ATTR void mwdt_ll_feed(timg_dev_t *hw) */ FORCE_INLINE_ATTR void mwdt_ll_write_protect_enable(timg_dev_t *hw) { - hw->wdt_wprotect = 0; + hw->wdtwprotect.wdt_wkey = 0; } /** @@ -235,7 +245,7 @@ FORCE_INLINE_ATTR void mwdt_ll_write_protect_enable(timg_dev_t *hw) */ FORCE_INLINE_ATTR void mwdt_ll_write_protect_disable(timg_dev_t *hw) { - hw->wdt_wprotect = TIMG_WDT_WKEY_VALUE; + hw->wdtwprotect.wdt_wkey = TIMG_WDT_WKEY_VALUE; } /** @@ -245,7 +255,7 @@ FORCE_INLINE_ATTR void mwdt_ll_write_protect_disable(timg_dev_t *hw) */ FORCE_INLINE_ATTR void mwdt_ll_clear_intr_status(timg_dev_t* hw) { - hw->int_clr.wdt = 1; + hw->int_clr_timers.wdt_int_clr = 1; } /** @@ -256,7 +266,7 @@ FORCE_INLINE_ATTR void mwdt_ll_clear_intr_status(timg_dev_t* hw) */ FORCE_INLINE_ATTR void mwdt_ll_set_intr_enable(timg_dev_t* hw, bool enable) { - hw->int_ena.wdt = (enable) ? 1 : 0; + hw->int_ena_timers.wdt_int_ena = (enable) ? 1 : 0; } #ifdef __cplusplus diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/pcnt_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/pcnt_ll.h index 11dad5cf359..b9286fa92fd 100644 --- a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/pcnt_ll.h +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/pcnt_ll.h @@ -1,4 +1,4 @@ -// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD +// Copyright 2015-2021 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. @@ -22,323 +22,386 @@ #pragma once -#include "soc/pcnt_periph.h" +#include +#include +#include "soc/pcnt_struct.h" #include "hal/pcnt_types.h" #ifdef __cplusplus extern "C" { #endif -// Get PCNT hardware instance with giving pcnt num #define PCNT_LL_GET_HW(num) (((num) == 0) ? (&PCNT) : NULL) +#define PCNT_LL_MAX_GLITCH_WIDTH 1023 + +typedef enum { + PCNT_LL_EVENT_THRES1, + PCNT_LL_EVENT_THRES0, + PCNT_LL_EVENT_LOW_LIMIT, + PCNT_LL_EVENT_HIGH_LIMIT, + PCNT_LL_EVENT_ZERO_CROSS, + PCNT_LL_EVENT_MAX +} pcnt_ll_event_id_t; + +#define PCNT_LL_EVENT_MASK ((1 << PCNT_LL_EVENT_MAX) - 1) /** - * @brief Set PCNT channel edge mode + * @brief Set PCNT channel edge action * * @param hw Peripheral PCNT hardware instance address. * @param unit PCNT unit number * @param channel PCNT channel number - * @param pos_mode Counter mode when detecting positive edge - * @param neg_mode Counter mode when detecting negative edge + * @param pos_act Counter action when detecting positive edge + * @param neg_act Counter action when detecting negative edge */ -static inline void pcnt_ll_set_edge_mode(pcnt_dev_t *hw, pcnt_unit_t unit, pcnt_channel_t channel, pcnt_count_mode_t pos_mode, pcnt_count_mode_t neg_mode) +static inline void pcnt_ll_set_edge_action(pcnt_dev_t *hw, uint32_t unit, uint32_t channel, pcnt_channel_edge_action_t pos_act, pcnt_channel_edge_action_t neg_act) { - typeof(hw->conf_unit[unit].conf0) conf0_reg = hw->conf_unit[unit].conf0; if (channel == 0) { - conf0_reg.ch0_pos_mode = pos_mode; - conf0_reg.ch0_neg_mode = neg_mode; + hw->conf_unit[unit].conf0.ch0_pos_mode_un = pos_act; + hw->conf_unit[unit].conf0.ch0_neg_mode_un = neg_act; } else { - conf0_reg.ch1_pos_mode = pos_mode; - conf0_reg.ch1_neg_mode = neg_mode; + hw->conf_unit[unit].conf0.ch1_pos_mode_un = pos_act; + hw->conf_unit[unit].conf0.ch1_neg_mode_un = neg_act; } - hw->conf_unit[unit].conf0 = conf0_reg; } /** - * @brief Set PCNT channel level mode + * @brief Set PCNT channel level action * * @param hw Peripheral PCNT hardware instance address. * @param unit PCNT unit number * @param channel PCNT channel number - * @param hctrl_mode Counter mode when control signal is high level - * @param lctrl_mode Counter mode when control signal is low level + * @param high_act Counter action when control signal is high level + * @param low_act Counter action when control signal is low level */ -static inline void pcnt_ll_set_level_mode(pcnt_dev_t *hw, pcnt_unit_t unit, pcnt_channel_t channel, pcnt_ctrl_mode_t hctrl_mode, pcnt_ctrl_mode_t lctrl_mode) +static inline void pcnt_ll_set_level_action(pcnt_dev_t *hw, uint32_t unit, uint32_t channel, pcnt_channel_level_action_t high_act, pcnt_channel_level_action_t low_act) { - typeof(hw->conf_unit[unit].conf0) conf0_reg = hw->conf_unit[unit].conf0; if (channel == 0) { - conf0_reg.ch0_hctrl_mode = hctrl_mode; - conf0_reg.ch0_lctrl_mode = lctrl_mode; + hw->conf_unit[unit].conf0.ch0_hctrl_mode_un = high_act; + hw->conf_unit[unit].conf0.ch0_lctrl_mode_un = low_act; } else { - conf0_reg.ch1_hctrl_mode = hctrl_mode; - conf0_reg.ch1_lctrl_mode = lctrl_mode; + hw->conf_unit[unit].conf0.ch1_hctrl_mode_un = high_act; + hw->conf_unit[unit].conf0.ch1_lctrl_mode_un = low_act; } - hw->conf_unit[unit].conf0 = conf0_reg; } /** - * @brief Set PCNT counter mode + * @brief Get pulse counter value + * + * @param hw Peripheral PCNT hardware instance address. + * @param unit Pulse Counter unit number + * @return PCNT count value (a signed integer) + */ +static inline int pcnt_ll_get_count(pcnt_dev_t *hw, uint32_t unit) +{ + pcnt_un_cnt_reg_t cnt_reg = hw->cnt_unit[unit]; + int16_t value = cnt_reg.pulse_cnt_un; + return value; +} + +/** + * @brief Pause PCNT counter of PCNT unit * * @param hw Peripheral PCNT hardware instance address. * @param unit PCNT unit number - * @param channel PCNT channel number - * @param pos_mode Counter mode when detecting positive edge - * @param neg_mode Counter mode when detecting negative edge - * @param hctrl_mode Counter mode when control signal is high level - * @param lctrl_mode Counter mode when control signal is low level */ -static inline void pcnt_ll_set_mode(pcnt_dev_t *hw, pcnt_unit_t unit, pcnt_channel_t channel, pcnt_count_mode_t pos_mode, pcnt_count_mode_t neg_mode, pcnt_ctrl_mode_t hctrl_mode, pcnt_ctrl_mode_t lctrl_mode) +static inline void pcnt_ll_stop_count(pcnt_dev_t *hw, uint32_t unit) { - pcnt_ll_set_edge_mode(hw, unit, channel, pos_mode, neg_mode); - pcnt_ll_set_level_mode(hw, unit, channel, hctrl_mode, lctrl_mode); + hw->ctrl.val |= 1 << (2 * unit + 1); } /** - * @brief Get pulse counter value + * @brief Resume counting for PCNT counter * * @param hw Peripheral PCNT hardware instance address. - * @param unit Pulse Counter unit number - * @param count Pointer to accept counter value + * @param unit PCNT unit number, select from uint32_t */ -static inline void pcnt_ll_get_counter_value(pcnt_dev_t *hw, pcnt_unit_t unit, int16_t *count) +static inline void pcnt_ll_start_count(pcnt_dev_t *hw, uint32_t unit) { - *count = (int16_t) hw->cnt_unit[unit].cnt_val; + hw->ctrl.val &= ~(1 << (2 * unit + 1)); } /** - * @brief Pause PCNT counter of PCNT unit + * @brief Clear PCNT counter value to zero * * @param hw Peripheral PCNT hardware instance address. - * @param unit PCNT unit number + * @param unit PCNT unit number, select from uint32_t */ -static inline void pcnt_ll_counter_pause(pcnt_dev_t *hw, pcnt_unit_t unit) +static inline void pcnt_ll_clear_count(pcnt_dev_t *hw, uint32_t unit) { - hw->ctrl.val |= BIT(PCNT_CNT_PAUSE_U0_S + (unit * 2)); + hw->ctrl.val |= 1 << (2 * unit); + hw->ctrl.val &= ~(1 << (2 * unit)); } /** - * @brief Resume counting for PCNT counter + * @brief Enable PCNT interrupt for PCNT unit + * @note Each PCNT unit has five watch point events that share the same interrupt bit. * * @param hw Peripheral PCNT hardware instance address. - * @param unit PCNT unit number, select from pcnt_unit_t + * @param unit_mask PCNT units mask + * @param enable True to enable interrupt, False to disable interrupt */ -static inline void pcnt_ll_counter_resume(pcnt_dev_t *hw, pcnt_unit_t unit) +static inline void pcnt_ll_enable_intr(pcnt_dev_t *hw, uint32_t unit_mask, bool enable) { - hw->ctrl.val &= (~(BIT(PCNT_CNT_PAUSE_U0_S + (unit * 2)))); + if (enable) { + hw->int_ena.val |= unit_mask; + } else { + hw->int_ena.val &= ~unit_mask; + } } /** - * @brief Clear and reset PCNT counter value to zero + * @brief Get PCNT interrupt status * * @param hw Peripheral PCNT hardware instance address. - * @param unit PCNT unit number, select from pcnt_unit_t + * @return Interrupt status word */ -static inline void pcnt_ll_counter_clear(pcnt_dev_t *hw, pcnt_unit_t unit) +__attribute__((always_inline)) static inline uint32_t pcnt_ll_get_intr_status(pcnt_dev_t *hw) { - uint32_t reset_bit = BIT(PCNT_PULSE_CNT_RST_U0_S + (unit * 2)); - hw->ctrl.val |= reset_bit; - hw->ctrl.val &= ~reset_bit; + return hw->int_st.val; } /** - * @brief Enable PCNT interrupt for PCNT unit - * @note - * Each Pulse counter unit has five watch point events that share the same interrupt. - * Configure events with pcnt_event_enable() and pcnt_event_disable() + * @brief Clear PCNT interrupt status * * @param hw Peripheral PCNT hardware instance address. - * @param unit PCNT unit number + * @param status value to clear interrupt status */ -static inline void pcnt_ll_intr_enable(pcnt_dev_t *hw, pcnt_unit_t unit) +__attribute__((always_inline)) static inline void pcnt_ll_clear_intr_status(pcnt_dev_t *hw, uint32_t status) { - hw->int_ena.val |= BIT(PCNT_CNT_THR_EVENT_U0_INT_ENA_S + unit); + hw->int_clr.val = status; } /** - * @brief Disable PCNT interrupt for PCNT unit + * @brief Enable PCNT high limit event * * @param hw Peripheral PCNT hardware instance address. * @param unit PCNT unit number + * @param enable true to enable, false to disable */ -static inline void pcnt_ll_intr_disable(pcnt_dev_t *hw, pcnt_unit_t unit) +static inline void pcnt_ll_enable_high_limit_event(pcnt_dev_t *hw, uint32_t unit, bool enable) { - hw->int_ena.val &= (~(BIT(PCNT_CNT_THR_EVENT_U0_INT_ENA_S + unit))); + hw->conf_unit[unit].conf0.thr_h_lim_en_un = enable; } /** - * @brief Get PCNT interrupt status + * @brief Enable PCNT low limit event * * @param hw Peripheral PCNT hardware instance address. - * @param status Pointer to accept value + * @param unit PCNT unit number + * @param enable true to enable, false to disable */ -static inline void pcnt_ll_get_intr_status(pcnt_dev_t *hw, uint32_t *status) +static inline void pcnt_ll_enable_low_limit_event(pcnt_dev_t *hw, uint32_t unit, bool enable) { - *status = hw->int_st.val; + hw->conf_unit[unit].conf0.thr_l_lim_en_un = enable; } /** - * @brief Clear PCNT interrupt status + * @brief Enable PCNT zero cross event * * @param hw Peripheral PCNT hardware instance address. - * @param status value to clear interrupt status + * @param unit PCNT unit number + * @param enable true to enable, false to disable */ -static inline void pcnt_ll_clear_intr_status(pcnt_dev_t *hw, uint32_t status) +static inline void pcnt_ll_enable_zero_cross_event(pcnt_dev_t *hw, uint32_t unit, bool enable) { - hw->int_clr.val = status; + hw->conf_unit[unit].conf0.thr_zero_en_un = enable; } /** - * @brief Enable PCNT event of PCNT unit + * @brief Enable PCNT threshold event * * @param hw Peripheral PCNT hardware instance address. * @param unit PCNT unit number - * @param evt_type Watch point event type. - * All enabled events share the same interrupt (one interrupt per pulse counter unit). + * @param thres Threshold ID + * @param enable true to enable, false to disable */ -static inline void pcnt_ll_event_enable(pcnt_dev_t *hw, pcnt_unit_t unit, pcnt_evt_type_t evt_type) +static inline void pcnt_ll_enable_thres_event(pcnt_dev_t *hw, uint32_t unit, uint32_t thres, bool enable) { - if (evt_type == PCNT_EVT_L_LIM) { - hw->conf_unit[unit].conf0.thr_l_lim_en = 1; - } else if (evt_type == PCNT_EVT_H_LIM) { - hw->conf_unit[unit].conf0.thr_h_lim_en = 1; - } else if (evt_type == PCNT_EVT_THRES_0) { - hw->conf_unit[unit].conf0.thr_thres0_en = 1; - } else if (evt_type == PCNT_EVT_THRES_1) { - hw->conf_unit[unit].conf0.thr_thres1_en = 1; - } else if (evt_type == PCNT_EVT_ZERO) { - hw->conf_unit[unit].conf0.thr_zero_en = 1; + if (thres == 0) { + hw->conf_unit[unit].conf0.thr_thres0_en_un = enable; + } else { + hw->conf_unit[unit].conf0.thr_thres1_en_un = enable; } } /** - * @brief Disable PCNT event of PCNT unit + * @brief Disable all PCNT threshold events + * + * @param hw Peripheral PCNT hardware instance address. + * @param unit unit number + */ +static inline void pcnt_ll_disable_all_events(pcnt_dev_t *hw, uint32_t unit) +{ + hw->conf_unit[unit].conf0.val &= ~(PCNT_LL_EVENT_MASK << 11); +} + +/** + * @brief Set PCNT high limit value * * @param hw Peripheral PCNT hardware instance address. * @param unit PCNT unit number - * @param evt_type Watch point event type. - * All enabled events share the same interrupt (one interrupt per pulse counter unit). + * @param value PCNT high limit value */ -static inline void pcnt_ll_event_disable(pcnt_dev_t *hw, pcnt_unit_t unit, pcnt_evt_type_t evt_type) +static inline void pcnt_ll_set_high_limit_value(pcnt_dev_t *hw, uint32_t unit, int value) { - if (evt_type == PCNT_EVT_L_LIM) { - hw->conf_unit[unit].conf0.thr_l_lim_en = 0; - } else if (evt_type == PCNT_EVT_H_LIM) { - hw->conf_unit[unit].conf0.thr_h_lim_en = 0; - } else if (evt_type == PCNT_EVT_THRES_0) { - hw->conf_unit[unit].conf0.thr_thres0_en = 0; - } else if (evt_type == PCNT_EVT_THRES_1) { - hw->conf_unit[unit].conf0.thr_thres1_en = 0; - } else if (evt_type == PCNT_EVT_ZERO) { - hw->conf_unit[unit].conf0.thr_zero_en = 0; - } + pcnt_un_conf2_reg_t conf2_reg = hw->conf_unit[unit].conf2; + conf2_reg.cnt_h_lim_un = value; + hw->conf_unit[unit].conf2 = conf2_reg; } /** - * @brief Set PCNT event value of PCNT unit + * @brief Set PCNT low limit value * * @param hw Peripheral PCNT hardware instance address. * @param unit PCNT unit number - * @param evt_type Watch point event type. - * All enabled events share the same interrupt (one interrupt per pulse counter unit). + * @param value PCNT low limit value + */ +static inline void pcnt_ll_set_low_limit_value(pcnt_dev_t *hw, uint32_t unit, int value) +{ + pcnt_un_conf2_reg_t conf2_reg = hw->conf_unit[unit].conf2; + conf2_reg.cnt_l_lim_un = value; + hw->conf_unit[unit].conf2 = conf2_reg; +} + +/** + * @brief Set PCNT threshold value * - * @param value Counter value for PCNT event + * @param hw Peripheral PCNT hardware instance address. + * @param unit PCNT unit number + * @param thres Threshold ID + * @param value PCNT threshold value */ -static inline void pcnt_ll_set_event_value(pcnt_dev_t *hw, pcnt_unit_t unit, pcnt_evt_type_t evt_type, int16_t value) +static inline void pcnt_ll_set_thres_value(pcnt_dev_t *hw, uint32_t unit, uint32_t thres, int value) { - if (evt_type == PCNT_EVT_L_LIM) { - hw->conf_unit[unit].conf2.cnt_l_lim = value; - } else if (evt_type == PCNT_EVT_H_LIM) { - hw->conf_unit[unit].conf2.cnt_h_lim = value; - } else if (evt_type == PCNT_EVT_THRES_0) { - hw->conf_unit[unit].conf1.cnt_thres0 = value; - } else if (evt_type == PCNT_EVT_THRES_1) { - hw->conf_unit[unit].conf1.cnt_thres1 = value; + pcnt_un_conf1_reg_t conf1_reg = hw->conf_unit[unit].conf1; + if (thres == 0) { + conf1_reg.cnt_thres0_un = value; + } else { + conf1_reg.cnt_thres1_un = value; } + hw->conf_unit[unit].conf1 = conf1_reg; +} + +/** + * @brief Get PCNT high limit value + * + * @param hw Peripheral PCNT hardware instance address. + * @param unit PCNT unit number + * @return PCNT high limit value + */ +static inline int pcnt_ll_get_high_limit_value(pcnt_dev_t *hw, uint32_t unit) +{ + pcnt_un_conf2_reg_t conf2_reg = hw->conf_unit[unit].conf2; + int16_t value = conf2_reg.cnt_h_lim_un; + return value; +} + +/** + * @brief Get PCNT low limit value + * + * @param hw Peripheral PCNT hardware instance address. + * @param unit PCNT unit number + * @return PCNT high limit value + */ +static inline int pcnt_ll_get_low_limit_value(pcnt_dev_t *hw, uint32_t unit) +{ + pcnt_un_conf2_reg_t conf2_reg = hw->conf_unit[unit].conf2; + int16_t value = conf2_reg.cnt_l_lim_un; + return value; } /** - * @brief Get PCNT event value of PCNT unit + * @brief Get PCNT threshold value * * @param hw Peripheral PCNT hardware instance address. * @param unit PCNT unit number - * @param evt_type Watch point event type. - * All enabled events share the same interrupt (one interrupt per pulse counter unit). - * @param value Pointer to accept counter value for PCNT event + * @param thres Threshold ID + * @return PCNT threshold value */ -static inline void pcnt_ll_get_event_value(pcnt_dev_t *hw, pcnt_unit_t unit, pcnt_evt_type_t evt_type, int16_t *value) +static inline int pcnt_ll_get_thres_value(pcnt_dev_t *hw, uint32_t unit, uint32_t thres) { - if (evt_type == PCNT_EVT_L_LIM) { - *value = (int16_t) hw->conf_unit[unit].conf2.cnt_l_lim; - } else if (evt_type == PCNT_EVT_H_LIM) { - *value = (int16_t) hw->conf_unit[unit].conf2.cnt_h_lim; - } else if (evt_type == PCNT_EVT_THRES_0) { - *value = (int16_t) hw->conf_unit[unit].conf1.cnt_thres0; - } else if (evt_type == PCNT_EVT_THRES_1) { - *value = (int16_t) hw->conf_unit[unit].conf1.cnt_thres1; + int16_t value; + pcnt_un_conf1_reg_t conf1_reg = hw->conf_unit[unit].conf1; + if (thres == 0) { + value = conf1_reg.cnt_thres0_un; } else { - *value = 0; + value = conf1_reg.cnt_thres1_un; } + return value; } /** - * @brief Get PCNT event status + * @brief Get PCNT unit runtime status * * @param hw Peripheral PCNT hardware instance address. * @param unit PCNT unit number - * @return event status word + * @return PCNT unit runtime status */ -static inline uint32_t pcnt_ll_get_event_status(pcnt_dev_t *hw, pcnt_unit_t unit) +static inline uint32_t pcnt_ll_get_unit_status(pcnt_dev_t *hw, uint32_t unit) { return hw->status_unit[unit].val; } /** - * @brief Set PCNT filter value + * @brief Get PCNT count sign * * @param hw Peripheral PCNT hardware instance address. * @param unit PCNT unit number - * @param filter_val PCNT signal filter value, counter in APB_CLK cycles. - * Any pulses lasting shorter than this will be ignored when the filter is enabled. - * @note - * filter_val is a 10-bit value, so the maximum filter_val should be limited to 1023. + * @return Count sign + */ +static inline pcnt_unit_count_sign_t pcnt_ll_get_count_sign(pcnt_dev_t *hw, uint32_t unit) +{ + return hw->status_unit[unit].val & 0x03; +} + +/** + * @brief Get PCNT event status + * + * @param hw Peripheral PCNT hardware instance address. + * @param unit PCNT unit number + * @return Event status word */ -static inline void pcnt_ll_set_filter_value(pcnt_dev_t *hw, pcnt_unit_t unit, uint16_t filter_val) +static inline uint32_t pcnt_ll_get_event_status(pcnt_dev_t *hw, uint32_t unit) { - hw->conf_unit[unit].conf0.filter_thres = filter_val; + return hw->status_unit[unit].val >> 2; } /** - * @brief Get PCNT filter value + * @brief Set PCNT glitch filter threshold * * @param hw Peripheral PCNT hardware instance address. * @param unit PCNT unit number - * @param filter_val Pointer to accept PCNT filter value. + * @param filter_val PCNT signal filter value, counter in APB_CLK cycles. + * Any pulses lasting shorter than this will be ignored when the filter is enabled. */ -static inline void pcnt_ll_get_filter_value(pcnt_dev_t *hw, pcnt_unit_t unit, uint16_t *filter_val) +static inline void pcnt_ll_set_glitch_filter_thres(pcnt_dev_t *hw, uint32_t unit, uint32_t filter_val) { - *filter_val = hw->conf_unit[unit].conf0.filter_thres; + hw->conf_unit[unit].conf0.filter_thres_un = filter_val; } /** - * @brief Enable PCNT input filter + * @brief Get PCNT glitch filter threshold * * @param hw Peripheral PCNT hardware instance address. * @param unit PCNT unit number + * @return glitch filter threshold */ -static inline void pcnt_ll_filter_enable(pcnt_dev_t *hw, pcnt_unit_t unit) +static inline uint32_t pcnt_ll_get_glitch_filter_thres(pcnt_dev_t *hw, uint32_t unit) { - hw->conf_unit[unit].conf0.filter_en = 1; + return hw->conf_unit[unit].conf0.filter_thres_un; } /** - * @brief Disable PCNT input filter + * @brief Enable PCNT glitch filter * * @param hw Peripheral PCNT hardware instance address. * @param unit PCNT unit number + * @param enable True to enable the filter, False to disable the filter */ -static inline void pcnt_ll_filter_disable(pcnt_dev_t *hw, pcnt_unit_t unit) +static inline void pcnt_ll_enable_glitch_filter(pcnt_dev_t *hw, uint32_t unit, bool enable) { - hw->conf_unit[unit].conf0.filter_en = 0; + hw->conf_unit[unit].conf0.filter_en_un = enable; } #ifdef __cplusplus diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/rmt_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/rmt_ll.h index 0354afc766c..958fe7aef5d 100644 --- a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/rmt_ll.h +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/rmt_ll.h @@ -15,6 +15,7 @@ #include #include +#include "hal/misc.h" #include "soc/rmt_struct.h" #ifdef __cplusplus @@ -126,23 +127,23 @@ static inline uint32_t rmt_ll_rx_get_mem_blocks(rmt_dev_t *dev, uint32_t channel static inline void rmt_ll_tx_set_channel_clock_div(rmt_dev_t *dev, uint32_t channel, uint32_t div) { - dev->conf_ch[channel].conf0.div_cnt = div; + HAL_FORCE_MODIFY_U32_REG_FIELD(dev->conf_ch[channel].conf0, div_cnt, div); } static inline void rmt_ll_rx_set_channel_clock_div(rmt_dev_t *dev, uint32_t channel, uint32_t div) { - dev->conf_ch[channel].conf0.div_cnt = div; + HAL_FORCE_MODIFY_U32_REG_FIELD(dev->conf_ch[channel].conf0, div_cnt, div); } static inline uint32_t rmt_ll_tx_get_channel_clock_div(rmt_dev_t *dev, uint32_t channel) { - uint32_t div = dev->conf_ch[channel].conf0.div_cnt; + uint32_t div = HAL_FORCE_READ_U32_REG_FIELD(dev->conf_ch[channel].conf0, div_cnt); return div == 0 ? 256 : div; } static inline uint32_t rmt_ll_rx_get_channel_clock_div(rmt_dev_t *dev, uint32_t channel) { - uint32_t div = dev->conf_ch[channel].conf0.div_cnt; + uint32_t div = HAL_FORCE_READ_U32_REG_FIELD(dev->conf_ch[channel].conf0, div_cnt); return div == 0 ? 256 : div; } @@ -153,12 +154,12 @@ static inline void rmt_ll_tx_enable_pingpong(rmt_dev_t *dev, uint32_t channel, b static inline void rmt_ll_rx_set_idle_thres(rmt_dev_t *dev, uint32_t channel, uint32_t thres) { - dev->conf_ch[channel].conf0.idle_thres = thres; + HAL_FORCE_MODIFY_U32_REG_FIELD(dev->conf_ch[channel].conf0, idle_thres, thres); } static inline uint32_t rmt_ll_rx_get_idle_thres(rmt_dev_t *dev, uint32_t channel) { - return dev->conf_ch[channel].conf0.idle_thres; + return HAL_FORCE_READ_U32_REG_FIELD(dev->conf_ch[channel].conf0, idle_thres); } static inline void rmt_ll_rx_set_mem_owner(rmt_dev_t *dev, uint32_t channel, uint8_t owner) @@ -219,7 +220,7 @@ static inline void rmt_ll_rx_enable_filter(rmt_dev_t *dev, uint32_t channel, boo static inline void rmt_ll_rx_set_filter_thres(rmt_dev_t *dev, uint32_t channel, uint32_t thres) { - dev->conf_ch[channel].conf1.rx_filter_thres = thres; + HAL_FORCE_MODIFY_U32_REG_FIELD(dev->conf_ch[channel].conf1, rx_filter_thres, thres); } static inline void rmt_ll_tx_enable_idle(rmt_dev_t *dev, uint32_t channel, bool enable) @@ -415,14 +416,14 @@ static inline void rmt_ll_rx_set_carrier_high_low_ticks(rmt_dev_t *dev, uint32_t static inline void rmt_ll_tx_get_carrier_high_low_ticks(rmt_dev_t *dev, uint32_t channel, uint32_t *high_ticks, uint32_t *low_ticks) { - *high_ticks = dev->carrier_duty_ch[channel].high; - *low_ticks = dev->carrier_duty_ch[channel].low; + *high_ticks = HAL_FORCE_READ_U32_REG_FIELD(dev->carrier_duty_ch[channel], high); + *low_ticks = HAL_FORCE_READ_U32_REG_FIELD(dev->carrier_duty_ch[channel], low); } static inline void rmt_ll_rx_get_carrier_high_low_ticks(rmt_dev_t *dev, uint32_t channel, uint32_t *high_ticks, uint32_t *low_ticks) { - *high_ticks = dev->ch_rx_carrier_rm[channel].carrier_high_thres_ch; - *low_ticks = dev->ch_rx_carrier_rm[channel].carrier_low_thres_ch; + *high_ticks = HAL_FORCE_READ_U32_REG_FIELD(dev->ch_rx_carrier_rm[channel], carrier_high_thres_ch); + *low_ticks = HAL_FORCE_READ_U32_REG_FIELD(dev->ch_rx_carrier_rm[channel], carrier_low_thres_ch); } static inline void rmt_ll_tx_enable_carrier_modulation(rmt_dev_t *dev, uint32_t channel, bool enable) diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/rtc_io_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/rtc_io_ll.h index c519f700306..cdd19466b6e 100644 --- a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/rtc_io_ll.h +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/rtc_io_ll.h @@ -22,6 +22,8 @@ #include #include "soc/rtc_io_periph.h" +#include "soc/rtc_io_struct.h" +#include "soc/sens_struct.h" #include "hal/rtc_io_types.h" #include "hal/gpio_types.h" diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/rwdt_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/rwdt_ll.h index 681c2fdf4f1..f3cc3c0cc42 100644 --- a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/rwdt_ll.h +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/rwdt_ll.h @@ -23,8 +23,10 @@ extern "C" { #include #include +#include "hal/misc.h" #include "hal/wdt_types.h" #include "soc/rtc_cntl_periph.h" +#include "soc/rtc_cntl_struct.h" #include "soc/efuse_reg.h" #include "esp_attr.h" @@ -239,7 +241,7 @@ FORCE_INLINE_ATTR void rwdt_ll_set_chip_reset_en(rtc_cntl_dev_t* hw, bool enable */ FORCE_INLINE_ATTR void rwdt_ll_set_chip_reset_width(rtc_cntl_dev_t *hw, uint32_t width) { - hw->wdt_config0.chip_reset_width = width; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->wdt_config0, chip_reset_width, width); } /** diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/sigmadelta_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/sigmadelta_ll.h index e06464a5fff..20406e19fd6 100644 --- a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/sigmadelta_ll.h +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/sigmadelta_ll.h @@ -22,7 +22,9 @@ #pragma once #include +#include "hal/misc.h" #include "soc/sigmadelta_periph.h" +#include "soc/gpio_sd_struct.h" #include "hal/sigmadelta_types.h" #ifdef __cplusplus @@ -53,7 +55,7 @@ static inline void sigmadelta_ll_set_en(gpio_sd_dev_t *hw, bool en) */ static inline void sigmadelta_ll_set_duty(gpio_sd_dev_t *hw, sigmadelta_channel_t channel, int8_t duty) { - hw->channel[channel].duty = duty; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->channel[channel], duty, (uint32_t)duty); } /** @@ -65,7 +67,7 @@ static inline void sigmadelta_ll_set_duty(gpio_sd_dev_t *hw, sigmadelta_channel_ */ static inline void sigmadelta_ll_set_prescale(gpio_sd_dev_t *hw, sigmadelta_channel_t channel, uint8_t prescale) { - hw->channel[channel].prescale = prescale; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->channel[channel], prescale, prescale); } #ifdef __cplusplus diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/spi_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/spi_ll.h index 855036d05d6..b81b36c53be 100644 --- a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/spi_ll.h +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/spi_ll.h @@ -27,9 +27,11 @@ #include "esp_types.h" #include "esp_attr.h" #include "soc/spi_periph.h" +#include "soc/spi_struct.h" #include "soc/lldesc.h" #include "hal/assert.h" #include "hal/misc.h" +#include "hal/spi_types.h" #ifdef __cplusplus extern "C" { @@ -39,6 +41,10 @@ extern "C" { #define SPI_LL_DMA_FIFO_RST_MASK (SPI_AHBM_RST | SPI_AHBM_FIFO_RST) /// Interrupt not used. Don't use in app. #define SPI_LL_UNUSED_INT_MASK (SPI_INT_TRANS_DONE_EN | SPI_INT_WR_DMA_DONE_EN | SPI_INT_RD_DMA_DONE_EN | SPI_INT_WR_BUF_DONE_EN | SPI_INT_RD_BUF_DONE_EN) +/// These 2 masks together will set SPI transaction to one line mode +#define SPI_LL_ONE_LINE_CTRL_MASK (SPI_FREAD_OCT | SPI_FREAD_QUAD | SPI_FREAD_DUAL | SPI_FCMD_OCT | \ + SPI_FCMD_QUAD | SPI_FCMD_DUAL | SPI_FADDR_OCT | SPI_FADDR_QUAD | SPI_FADDR_DUAL) +#define SPI_LL_ONE_LINE_USER_MASK (SPI_FWRITE_OCT | SPI_FWRITE_QUAD | SPI_FWRITE_DUAL) /// Swap the bit order to its correct place to send #define HAL_SPI_SWAP_DATA_TX(data, len) HAL_SWAP32((uint32_t)(data) << (32 - len)) /// This is the expected clock frequency @@ -55,15 +61,6 @@ typedef uint32_t spi_ll_clock_val_t; //On ESP32-S2 and earlier chips, DMA registers are part of SPI registers. So set the registers of SPI peripheral to control DMA. typedef spi_dev_t spi_dma_dev_t; -/** IO modes supported by the master. */ -typedef enum { - SPI_LL_IO_MODE_NORMAL = 0, ///< 1-bit mode for all phases - SPI_LL_IO_MODE_DIO, ///< 2-bit mode for address and data phases, 1-bit mode for command phase - SPI_LL_IO_MODE_DUAL, ///< 2-bit mode for data phases only, 1-bit mode for command and address phases - SPI_LL_IO_MODE_QIO, ///< 4-bit mode for address and data phases, 1-bit mode for command phase - SPI_LL_IO_MODE_QUAD, ///< 4-bit mode for data phases only, 1-bit mode for command and address phases -} spi_ll_io_mode_t; - /// Type definition of all supported interrupts typedef enum { SPI_LL_INTR_TRANS_DONE = BIT(0), ///< A transaction has done @@ -348,14 +345,16 @@ static inline void spi_ll_read_buffer(spi_dev_t *hw, uint8_t *buffer_to_rcv, siz static inline void spi_ll_read_buffer_byte(spi_dev_t *hw, int byte_addr, uint8_t *out_data, int len) { - while (len>0) { - uint32_t word = hw->data_buf[byte_addr/4]; + while (len > 0) { + uint32_t word = hw->data_buf[byte_addr / 4]; int offset = byte_addr % 4; int copy_len = 4 - offset; - if (copy_len > len) copy_len = len; + if (copy_len > len) { + copy_len = len; + } - memcpy(out_data, ((uint8_t*)&word)+offset, copy_len); + memcpy(out_data, ((uint8_t *)&word) + offset, copy_len); byte_addr += copy_len; out_data += copy_len; len -= copy_len; @@ -373,10 +372,14 @@ static inline void spi_ll_write_buffer_byte(spi_dev_t *hw, int byte_addr, uint8_ int offset = byte_addr % 4; int copy_len = 4 - offset; - if (copy_len > len) copy_len = len; + if (copy_len > len) { + copy_len = len; + } //read-modify-write - if (copy_len != 4) word = hw->data_buf[byte_addr / 4]; + if (copy_len != 4) { + word = hw->data_buf[byte_addr / 4]; + } memcpy(((uint8_t *)&word) + offset, data, copy_len); hw->data_buf[byte_addr / 4] = word; @@ -508,41 +511,27 @@ static inline void spi_ll_set_sio_mode(spi_dev_t *hw, int sio_mode) } /** - * Configure the io mode for the master to work at. + * Configure the SPI transaction line mode for the master to use. * - * @param hw Beginning address of the peripheral registers. - * @param io_mode IO mode to work at, see ``spi_ll_io_mode_t``. - */ -static inline void spi_ll_master_set_io_mode(spi_dev_t *hw, spi_ll_io_mode_t io_mode) -{ - if (io_mode == SPI_LL_IO_MODE_DIO || io_mode == SPI_LL_IO_MODE_DUAL) { - hw->ctrl.fcmd_dual= (io_mode == SPI_LL_IO_MODE_DIO) ? 1 : 0; - hw->ctrl.faddr_dual= (io_mode == SPI_LL_IO_MODE_DIO) ? 1 : 0; - hw->ctrl.fread_dual=1; - hw->user.fwrite_dual=1; - hw->ctrl.fcmd_quad = 0; - hw->ctrl.faddr_quad = 0; - hw->ctrl.fread_quad = 0; - hw->user.fwrite_quad = 0; - } else if (io_mode == SPI_LL_IO_MODE_QIO || io_mode == SPI_LL_IO_MODE_QUAD) { - hw->ctrl.fcmd_quad = (io_mode == SPI_LL_IO_MODE_QIO) ? 1 : 0; - hw->ctrl.faddr_quad = (io_mode == SPI_LL_IO_MODE_QIO) ? 1 : 0; - hw->ctrl.fread_quad=1; - hw->user.fwrite_quad=1; - hw->ctrl.fcmd_dual = 0; - hw->ctrl.faddr_dual = 0; - hw->ctrl.fread_dual = 0; - hw->user.fwrite_dual = 0; - } else { - hw->ctrl.fcmd_dual = 0; - hw->ctrl.faddr_dual = 0; - hw->ctrl.fread_dual = 0; - hw->user.fwrite_dual = 0; - hw->ctrl.fcmd_quad = 0; - hw->ctrl.faddr_quad = 0; - hw->ctrl.fread_quad = 0; - hw->user.fwrite_quad = 0; - } + * @param hw Beginning address of the peripheral registers. + * @param line_mode SPI transaction line mode to use, see ``spi_line_mode_t``. + */ +static inline void spi_ll_master_set_line_mode(spi_dev_t *hw, spi_line_mode_t line_mode) +{ + hw->ctrl.val &= ~SPI_LL_ONE_LINE_CTRL_MASK; + hw->user.val &= ~SPI_LL_ONE_LINE_USER_MASK; + hw->ctrl.fcmd_dual = (line_mode.cmd_lines == 2); + hw->ctrl.fcmd_quad = (line_mode.cmd_lines == 4); + hw->ctrl.fcmd_oct = (line_mode.cmd_lines == 8); + hw->ctrl.faddr_dual = (line_mode.addr_lines == 2); + hw->ctrl.faddr_quad = (line_mode.addr_lines == 4); + hw->ctrl.faddr_oct = (line_mode.addr_lines == 8); + hw->ctrl.fread_dual = (line_mode.data_lines == 2); + hw->user.fwrite_dual = (line_mode.data_lines == 2); + hw->ctrl.fread_quad = (line_mode.data_lines == 4); + hw->user.fwrite_quad = (line_mode.data_lines == 4); + hw->ctrl.fread_oct = (line_mode.data_lines == 8); + hw->user.fwrite_oct = (line_mode.data_lines == 8); } static inline void spi_ll_slave_set_seg_mode(spi_dev_t *hw, bool seg_trans) @@ -572,7 +561,8 @@ static inline void spi_ll_master_select_cs(spi_dev_t *hw, int cs_id) * @param hw Beginning address of the peripheral registers. * @param keep_active if 0 don't keep CS activated, else keep CS activated */ -static inline void spi_ll_master_keep_cs(spi_dev_t *hw, int keep_active) { +static inline void spi_ll_master_keep_cs(spi_dev_t *hw, int keep_active) +{ hw->misc.cs_keep_active = (keep_active != 0) ? 1 : 0; } @@ -745,7 +735,7 @@ static inline void spi_ll_set_miso_delay(spi_dev_t *hw, int delay_mode, int dela static inline void spi_ll_set_dummy(spi_dev_t *hw, int dummy_n) { hw->user.usr_dummy = dummy_n ? 1 : 0; - hw->user1.usr_dummy_cyclelen = dummy_n - 1; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->user1, usr_dummy_cyclelen, dummy_n - 1); } /** @@ -906,13 +896,13 @@ static inline void spi_ll_set_command(spi_dev_t *hw, uint16_t cmd, int cmdlen, b { if (lsbfirst) { // The output command start from bit0 to bit 15, kept as is. - hw->user2.usr_command_value = cmd; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->user2, usr_command_value, cmd); } else { /* Output command will be sent from bit 7 to 0 of command_value, and * then bit 15 to 8 of the same register field. Shift and swap to send * more straightly. */ - hw->user2.usr_command_value = HAL_SPI_SWAP_DATA_TX(cmd, cmdlen); + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->user2, usr_command_value, HAL_SPI_SWAP_DATA_TX(cmd, cmdlen)); } } @@ -985,35 +975,35 @@ static inline uint32_t spi_ll_slave_get_rcv_bitlen(spi_dev_t *hw) item(SPI_LL_INTR_CMDA, dma_int_ena.cmda, dma_int_raw.cmda, dma_int_clr.cmda=1) -static inline void spi_ll_enable_intr(spi_dev_t* hw, spi_ll_intr_t intr_mask) +static inline void spi_ll_enable_intr(spi_dev_t *hw, spi_ll_intr_t intr_mask) { #define ENA_INTR(intr_bit, en_reg, ...) if (intr_mask & (intr_bit)) hw->en_reg = 1; FOR_EACH_ITEM(ENA_INTR, INTR_LIST); #undef ENA_INTR } -static inline void spi_ll_disable_intr(spi_dev_t* hw, spi_ll_intr_t intr_mask) +static inline void spi_ll_disable_intr(spi_dev_t *hw, spi_ll_intr_t intr_mask) { #define DIS_INTR(intr_bit, en_reg, ...) if (intr_mask & (intr_bit)) hw->en_reg = 0; FOR_EACH_ITEM(DIS_INTR, INTR_LIST); #undef DIS_INTR } -static inline void spi_ll_set_intr(spi_dev_t* hw, spi_ll_intr_t intr_mask) +static inline void spi_ll_set_intr(spi_dev_t *hw, spi_ll_intr_t intr_mask) { #define SET_INTR(intr_bit, _, st_reg, ...) if (intr_mask & (intr_bit)) hw->st_reg = 1; FOR_EACH_ITEM(SET_INTR, INTR_LIST); #undef SET_INTR } -static inline void spi_ll_clear_intr(spi_dev_t* hw, spi_ll_intr_t intr_mask) +static inline void spi_ll_clear_intr(spi_dev_t *hw, spi_ll_intr_t intr_mask) { #define CLR_INTR(intr_bit, _, __, clr_reg) if (intr_mask & (intr_bit)) hw->clr_reg; FOR_EACH_ITEM(CLR_INTR, INTR_LIST); #undef CLR_INTR } -static inline bool spi_ll_get_intr(spi_dev_t* hw, spi_ll_intr_t intr_mask) +static inline bool spi_ll_get_intr(spi_dev_t *hw, spi_ll_intr_t intr_mask) { #define GET_INTR(intr_bit, _, st_reg, ...) if (intr_mask & (intr_bit) && hw->st_reg) return true; FOR_EACH_ITEM(GET_INTR, INTR_LIST); @@ -1067,7 +1057,7 @@ static inline void spi_ll_enable_int(spi_dev_t *hw) /*------------------------------------------------------------------------------ * Slave HD *----------------------------------------------------------------------------*/ -static inline void spi_ll_slave_hd_set_len_cond(spi_dev_t* hw, spi_ll_trans_len_cond_t cond_mask) +static inline void spi_ll_slave_hd_set_len_cond(spi_dev_t *hw, spi_ll_trans_len_cond_t cond_mask) { hw->slv_rd_byte.rdbuf_bytelen_en = (cond_mask & SPI_LL_TRANS_LEN_COND_RDBUF) ? 1 : 0; hw->slv_rd_byte.wrbuf_bytelen_en = (cond_mask & SPI_LL_TRANS_LEN_COND_WRBUF) ? 1 : 0; @@ -1075,14 +1065,14 @@ static inline void spi_ll_slave_hd_set_len_cond(spi_dev_t* hw, spi_ll_trans_len_ hw->slv_rd_byte.wrdma_bytelen_en = (cond_mask & SPI_LL_TRANS_LEN_COND_WRDMA) ? 1 : 0; } -static inline int spi_ll_slave_get_rx_byte_len(spi_dev_t* hw) +static inline int spi_ll_slave_get_rx_byte_len(spi_dev_t *hw) { return hw->slv_rd_byte.data_bytelen; } -static inline uint32_t spi_ll_slave_hd_get_last_addr(spi_dev_t* hw) +static inline uint32_t spi_ll_slave_hd_get_last_addr(spi_dev_t *hw) { - return hw->slave1.last_addr; + return HAL_FORCE_READ_U32_REG_FIELD(hw->slave1, last_addr); } /*------------------------------------------------------------------------------ diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/spimem_flash_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/spimem_flash_ll.h index b04020eb519..2bbd6e90ff9 100644 --- a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/spimem_flash_ll.h +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/spimem_flash_ll.h @@ -28,6 +28,7 @@ #include #include "soc/spi_periph.h" +#include "soc/spi_mem_struct.h" #include "hal/spi_types.h" #include "hal/spi_flash_types.h" @@ -167,7 +168,7 @@ static inline void spimem_flash_ll_set_read_sus_status(spi_mem_dev_t *dev, uint3 */ static inline void spimem_flash_ll_suspend_cmd_setup(spi_mem_dev_t *dev, uint32_t sus_cmd) { - dev->flash_sus_ctrl.flash_pes_command = sus_cmd; + HAL_FORCE_MODIFY_U32_REG_FIELD(dev->flash_sus_ctrl, flash_pes_command, sus_cmd); } /** @@ -179,7 +180,7 @@ static inline void spimem_flash_ll_suspend_cmd_setup(spi_mem_dev_t *dev, uint32_ */ static inline void spimem_flash_ll_resume_cmd_setup(spi_mem_dev_t *dev, uint32_t res_cmd) { - dev->flash_sus_ctrl.flash_per_command = res_cmd; + HAL_FORCE_MODIFY_U32_REG_FIELD(dev->flash_sus_ctrl, flash_per_command, res_cmd); } /** @@ -226,7 +227,7 @@ static inline void spimem_flash_ll_res_check_sus_setup(spi_mem_dev_t *dev, bool */ static inline void spimem_flash_ll_auto_wait_idle_init(spi_mem_dev_t *dev, bool auto_waiti) { - dev->flash_waiti_ctrl.waiti_cmd = 0x05; // Set the command to send, to fetch flash status reg value. + HAL_FORCE_MODIFY_U32_REG_FIELD(dev->flash_waiti_ctrl, waiti_cmd, 0x05); // Set the command to send, to fetch flash status reg value. dev->flash_waiti_ctrl.waiti_en = auto_waiti; // enable auto wait-idle function. } @@ -516,7 +517,7 @@ static inline void spimem_flash_ll_set_usr_address(spi_mem_dev_t *dev, uint32_t static inline void spimem_flash_ll_set_dummy(spi_mem_dev_t *dev, uint32_t dummy_n) { dev->user.usr_dummy = dummy_n ? 1 : 0; - dev->user1.usr_dummy_cyclelen = dummy_n - 1; + HAL_FORCE_MODIFY_U32_REG_FIELD(dev->user1, usr_dummy_cyclelen, dummy_n - 1); } /** diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/systimer_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/systimer_ll.h index f1c0ef0adfe..60666742431 100644 --- a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/systimer_ll.h +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/systimer_ll.h @@ -135,6 +135,11 @@ __attribute__((always_inline)) static inline void systimer_ll_set_alarm_period(s dev->target_conf[alarm_id].target_period = period; } +__attribute__((always_inline)) static inline uint32_t systimer_ll_get_alarm_period(systimer_dev_t *dev, uint32_t alarm_id) +{ + return dev->target_conf[alarm_id].target_period; +} + __attribute__((always_inline)) static inline void systimer_ll_apply_alarm_value(systimer_dev_t *dev, uint32_t alarm_id) { (void)dev; diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/timer_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/timer_ll.h index 522b58f4254..59921e2364a 100644 --- a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/timer_ll.h +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/timer_ll.h @@ -22,7 +22,9 @@ extern "C" { #endif #include +#include "hal/misc.h" #include "soc/timer_periph.h" +#include "soc/timer_group_struct.h" #include "hal/timer_types.h" #include "hal/assert.h" @@ -48,10 +50,10 @@ static inline void timer_ll_set_divider(timg_dev_t *hw, timer_idx_t timer_num, u if (divider >= 65536) { divider = 0; } - int timer_en = hw->hw_timer[timer_num].config.enable; - hw->hw_timer[timer_num].config.enable = 0; - hw->hw_timer[timer_num].config.divider = divider; - hw->hw_timer[timer_num].config.enable = timer_en; + int timer_en = hw->hw_timer[timer_num].config.tx_en; + hw->hw_timer[timer_num].config.tx_en = 0; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->hw_timer[timer_num].config, tx_divider, divider); + hw->hw_timer[timer_num].config.tx_en = timer_en; } /** @@ -65,7 +67,7 @@ static inline void timer_ll_set_divider(timg_dev_t *hw, timer_idx_t timer_num, u */ static inline void timer_ll_get_divider(timg_dev_t *hw, timer_idx_t timer_num, uint32_t *divider) { - uint32_t d = hw->hw_timer[timer_num].config.divider; + uint32_t d = HAL_FORCE_READ_U32_REG_FIELD(hw->hw_timer[timer_num].config, tx_divider); if (d == 0) { d = 65536; } else if (d == 1) { @@ -85,9 +87,9 @@ static inline void timer_ll_get_divider(timg_dev_t *hw, timer_idx_t timer_num, u */ static inline void timer_ll_set_counter_value(timg_dev_t *hw, timer_idx_t timer_num, uint64_t load_val) { - hw->hw_timer[timer_num].load_high = (uint32_t) (load_val >> 32); - hw->hw_timer[timer_num].load_low = (uint32_t) load_val; - hw->hw_timer[timer_num].reload = 1; + hw->hw_timer[timer_num].loadhi.tx_load_hi = (uint32_t) (load_val >> 32); + hw->hw_timer[timer_num].loadlo.tx_load_lo = (uint32_t) load_val; + hw->hw_timer[timer_num].load.tx_load = 1; } /** @@ -101,9 +103,9 @@ static inline void timer_ll_set_counter_value(timg_dev_t *hw, timer_idx_t timer_ */ FORCE_INLINE_ATTR void timer_ll_get_counter_value(timg_dev_t *hw, timer_idx_t timer_num, uint64_t *timer_val) { - hw->hw_timer[timer_num].update.update = 1; - while (hw->hw_timer[timer_num].update.update) {} - *timer_val = ((uint64_t) hw->hw_timer[timer_num].cnt_high << 32) | (hw->hw_timer[timer_num].cnt_low); + hw->hw_timer[timer_num].update.tx_update = 1; + while (hw->hw_timer[timer_num].update.tx_update) {} + *timer_val = ((uint64_t) hw->hw_timer[timer_num].hi.tx_hi << 32) | (hw->hw_timer[timer_num].lo.tx_lo); } /** @@ -117,7 +119,7 @@ FORCE_INLINE_ATTR void timer_ll_get_counter_value(timg_dev_t *hw, timer_idx_t ti */ static inline void timer_ll_set_counter_increase(timg_dev_t *hw, timer_idx_t timer_num, bool increase_en) { - hw->hw_timer[timer_num].config.increase = increase_en; + hw->hw_timer[timer_num].config.tx_increase = increase_en; } /** @@ -132,7 +134,7 @@ static inline void timer_ll_set_counter_increase(timg_dev_t *hw, timer_idx_t tim */ static inline bool timer_ll_get_counter_increase(timg_dev_t *hw, timer_idx_t timer_num) { - return hw->hw_timer[timer_num].config.increase; + return hw->hw_timer[timer_num].config.tx_increase; } /** @@ -146,7 +148,7 @@ static inline bool timer_ll_get_counter_increase(timg_dev_t *hw, timer_idx_t tim */ FORCE_INLINE_ATTR void timer_ll_set_counter_enable(timg_dev_t *hw, timer_idx_t timer_num, bool counter_en) { - hw->hw_timer[timer_num].config.enable = counter_en; + hw->hw_timer[timer_num].config.tx_en = counter_en; } /** @@ -161,7 +163,7 @@ FORCE_INLINE_ATTR void timer_ll_set_counter_enable(timg_dev_t *hw, timer_idx_t t */ static inline bool timer_ll_get_counter_enable(timg_dev_t *hw, timer_idx_t timer_num) { - return hw->hw_timer[timer_num].config.enable; + return hw->hw_timer[timer_num].config.tx_en; } /** @@ -175,7 +177,7 @@ static inline bool timer_ll_get_counter_enable(timg_dev_t *hw, timer_idx_t timer */ static inline void timer_ll_set_auto_reload(timg_dev_t *hw, timer_idx_t timer_num, bool auto_reload_en) { - hw->hw_timer[timer_num].config.autoreload = auto_reload_en; + hw->hw_timer[timer_num].config.tx_autoreload = auto_reload_en; } /** @@ -190,7 +192,7 @@ static inline void timer_ll_set_auto_reload(timg_dev_t *hw, timer_idx_t timer_nu */ FORCE_INLINE_ATTR bool timer_ll_get_auto_reload(timg_dev_t *hw, timer_idx_t timer_num) { - return hw->hw_timer[timer_num].config.autoreload; + return hw->hw_timer[timer_num].config.tx_autoreload; } /** @@ -204,8 +206,8 @@ FORCE_INLINE_ATTR bool timer_ll_get_auto_reload(timg_dev_t *hw, timer_idx_t time */ FORCE_INLINE_ATTR void timer_ll_set_alarm_value(timg_dev_t *hw, timer_idx_t timer_num, uint64_t alarm_value) { - hw->hw_timer[timer_num].alarm_high = (uint32_t) (alarm_value >> 32); - hw->hw_timer[timer_num].alarm_low = (uint32_t) alarm_value; + hw->hw_timer[timer_num].alarmhi.tx_alarm_hi = (uint32_t) (alarm_value >> 32); + hw->hw_timer[timer_num].alarmlo.tx_alarm_lo = (uint32_t) alarm_value; } /** @@ -219,7 +221,7 @@ FORCE_INLINE_ATTR void timer_ll_set_alarm_value(timg_dev_t *hw, timer_idx_t time */ static inline void timer_ll_get_alarm_value(timg_dev_t *hw, timer_idx_t timer_num, uint64_t *alarm_value) { - *alarm_value = ((uint64_t) hw->hw_timer[timer_num].alarm_high << 32) | (hw->hw_timer[timer_num].alarm_low); + *alarm_value = ((uint64_t) hw->hw_timer[timer_num].alarmhi.tx_alarm_hi << 32) | (hw->hw_timer[timer_num].alarmlo.tx_alarm_lo); } /** @@ -233,7 +235,7 @@ static inline void timer_ll_get_alarm_value(timg_dev_t *hw, timer_idx_t timer_nu */ FORCE_INLINE_ATTR void timer_ll_set_alarm_enable(timg_dev_t *hw, timer_idx_t timer_num, bool alarm_en) { - hw->hw_timer[timer_num].config.alarm_en = alarm_en; + hw->hw_timer[timer_num].config.tx_alarm_en = alarm_en; } /** @@ -248,7 +250,7 @@ FORCE_INLINE_ATTR void timer_ll_set_alarm_enable(timg_dev_t *hw, timer_idx_t tim */ static inline bool timer_ll_get_alarm_enable(timg_dev_t *hw, timer_idx_t timer_num) { - return hw->hw_timer[timer_num].config.alarm_en; + return hw->hw_timer[timer_num].config.tx_alarm_en; } /** @@ -261,8 +263,8 @@ static inline bool timer_ll_get_alarm_enable(timg_dev_t *hw, timer_idx_t timer_n */ FORCE_INLINE_ATTR void timer_ll_intr_enable(timg_dev_t *hw, timer_idx_t timer_num) { - hw->int_ena.val |= BIT(timer_num); - hw->hw_timer[timer_num].config.level_int_en = 1; + hw->int_ena_timers.val |= BIT(timer_num); + hw->hw_timer[timer_num].config.tx_level_int_en = 1; } /** @@ -275,8 +277,8 @@ FORCE_INLINE_ATTR void timer_ll_intr_enable(timg_dev_t *hw, timer_idx_t timer_nu */ FORCE_INLINE_ATTR void timer_ll_intr_disable(timg_dev_t *hw, timer_idx_t timer_num) { - hw->int_ena.val &= (~BIT(timer_num)); - hw->hw_timer[timer_num].config.level_int_en = 0; + hw->int_ena_timers.val &= (~BIT(timer_num)); + hw->hw_timer[timer_num].config.tx_level_int_en = 0; } /** @@ -289,7 +291,7 @@ FORCE_INLINE_ATTR void timer_ll_intr_disable(timg_dev_t *hw, timer_idx_t timer_n */ FORCE_INLINE_ATTR void timer_ll_clear_intr_status(timg_dev_t *hw, timer_idx_t timer_num) { - hw->int_clr.val |= BIT(timer_num); + hw->int_clr_timers.val |= BIT(timer_num); } /** @@ -302,7 +304,7 @@ FORCE_INLINE_ATTR void timer_ll_clear_intr_status(timg_dev_t *hw, timer_idx_t ti */ FORCE_INLINE_ATTR void timer_ll_get_intr_status(timg_dev_t *hw, uint32_t *intr_status) { - *intr_status = hw->int_st.val & 0x03; + *intr_status = hw->int_st_timers.val & 0x03; } /** @@ -316,7 +318,7 @@ FORCE_INLINE_ATTR void timer_ll_get_intr_status(timg_dev_t *hw, uint32_t *intr_s FORCE_INLINE_ATTR void timer_ll_get_intr_raw_status(timer_group_t group_num, uint32_t *intr_raw_status) { timg_dev_t *hw = TIMER_LL_GET_HW(group_num); - *intr_raw_status = hw->int_raw.val & 0x03; + *intr_raw_status = hw->int_raw_timers.val & 0x03; } /** @@ -330,7 +332,7 @@ FORCE_INLINE_ATTR void timer_ll_get_intr_raw_status(timer_group_t group_num, uin */ static inline void timer_ll_set_level_int_enable(timg_dev_t *hw, timer_idx_t timer_num, bool level_int_en) { - hw->hw_timer[timer_num].config.level_int_en = level_int_en; + hw->hw_timer[timer_num].config.tx_level_int_en = level_int_en; } /** @@ -345,7 +347,7 @@ static inline void timer_ll_set_level_int_enable(timg_dev_t *hw, timer_idx_t tim */ static inline bool timer_ll_get_level_int_enable(timg_dev_t *hw, timer_idx_t timer_num) { - return hw->hw_timer[timer_num].config.level_int_en; + return hw->hw_timer[timer_num].config.tx_level_int_en; } /** @@ -359,7 +361,7 @@ static inline bool timer_ll_get_level_int_enable(timg_dev_t *hw, timer_idx_t tim */ static inline void timer_ll_set_edge_int_enable(timg_dev_t *hw, timer_idx_t timer_num, bool edge_int_en) { - hw->hw_timer[timer_num].config.edge_int_en = edge_int_en; + hw->hw_timer[timer_num].config.tx_edge_int_en = edge_int_en; } /** @@ -374,7 +376,7 @@ static inline void timer_ll_set_edge_int_enable(timg_dev_t *hw, timer_idx_t time */ static inline bool timer_ll_get_edge_int_enable(timg_dev_t *hw, timer_idx_t timer_num) { - return hw->hw_timer[timer_num].config.edge_int_en; + return hw->hw_timer[timer_num].config.tx_edge_int_en; } /** @@ -386,7 +388,7 @@ static inline bool timer_ll_get_edge_int_enable(timg_dev_t *hw, timer_idx_t time */ static inline uint32_t timer_ll_get_intr_status_reg(timg_dev_t *hw) { - return (uint32_t) & (hw->int_st.val); + return (uint32_t) & (hw->int_st_timers.val); } static inline uint32_t timer_ll_get_intr_mask_bit(timg_dev_t *hw, timer_idx_t timer_num) @@ -404,7 +406,7 @@ static inline uint32_t timer_ll_get_intr_mask_bit(timg_dev_t *hw, timer_idx_t ti */ static inline void timer_ll_set_use_xtal(timg_dev_t *hw, timer_idx_t timer_num, bool use_xtal_en) { - hw->hw_timer[timer_num].config.use_xtal = use_xtal_en; + hw->hw_timer[timer_num].config.tx_use_xtal = use_xtal_en; } /** @@ -418,7 +420,7 @@ static inline void timer_ll_set_use_xtal(timg_dev_t *hw, timer_idx_t timer_num, */ static inline bool timer_ll_get_use_xtal(timg_dev_t *hw, timer_idx_t timer_num) { - return hw->hw_timer[timer_num].config.use_xtal; + return hw->hw_timer[timer_num].config.tx_use_xtal; } #ifdef __cplusplus diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/touch_sensor_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/touch_sensor_ll.h index 2fa8227153a..30c3cc10147 100644 --- a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/touch_sensor_ll.h +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/touch_sensor_ll.h @@ -24,8 +24,12 @@ #include #include +#include "hal/misc.h" #include "soc/touch_sensor_periph.h" #include "soc/soc_caps.h" +#include "soc/sens_struct.h" +#include "soc/rtc_cntl_struct.h" +#include "soc/rtc_io_struct.h" #include "hal/touch_sensor_types.h" #ifdef __cplusplus @@ -47,9 +51,9 @@ extern "C" { static inline void touch_ll_set_meas_times(uint16_t meas_time) { //The times of charge and discharge in each measure process of touch channels. - RTCCNTL.touch_ctrl1.touch_meas_num = meas_time; + HAL_FORCE_MODIFY_U32_REG_FIELD(RTCCNTL.touch_ctrl1, touch_meas_num, meas_time); //the waiting cycles (in 8MHz) between TOUCH_START and TOUCH_XPD - RTCCNTL.touch_ctrl2.touch_xpd_wait = SOC_TOUCH_PAD_MEASURE_WAIT_MAX; //wait volt stable + HAL_FORCE_MODIFY_U32_REG_FIELD(RTCCNTL.touch_ctrl2, touch_xpd_wait, SOC_TOUCH_PAD_MEASURE_WAIT_MAX); //wait volt stable } /** @@ -59,7 +63,7 @@ static inline void touch_ll_set_meas_times(uint16_t meas_time) */ static inline void touch_ll_get_measure_times(uint16_t *meas_time) { - *meas_time = RTCCNTL.touch_ctrl1.touch_meas_num; + *meas_time = HAL_FORCE_READ_U32_REG_FIELD(RTCCNTL.touch_ctrl1, touch_meas_num); } /** @@ -73,7 +77,7 @@ static inline void touch_ll_get_measure_times(uint16_t *meas_time) static inline void touch_ll_set_sleep_time(uint16_t sleep_time) { // touch sensor sleep cycle Time = sleep_cycle / RTC_SLOW_CLK(90k) - RTCCNTL.touch_ctrl1.touch_sleep_cycles = sleep_time; + HAL_FORCE_MODIFY_U32_REG_FIELD(RTCCNTL.touch_ctrl1, touch_sleep_cycles, sleep_time); } /** @@ -83,7 +87,7 @@ static inline void touch_ll_set_sleep_time(uint16_t sleep_time) */ static inline void touch_ll_get_sleep_time(uint16_t *sleep_time) { - *sleep_time = RTCCNTL.touch_ctrl1.touch_sleep_cycles; + *sleep_time = HAL_FORCE_READ_U32_REG_FIELD(RTCCNTL.touch_ctrl1, touch_sleep_cycles); } /** @@ -990,7 +994,7 @@ static inline void touch_ll_proximity_get_channel_num(touch_pad_t prox_pad[]) */ static inline void touch_ll_proximity_set_meas_times(uint32_t times) { - RTCCNTL.touch_approach.touch_approach_meas_time = times; + HAL_FORCE_MODIFY_U32_REG_FIELD(RTCCNTL.touch_approach, touch_approach_meas_time, times); } /** @@ -1000,7 +1004,7 @@ static inline void touch_ll_proximity_set_meas_times(uint32_t times) */ static inline void touch_ll_proximity_get_meas_times(uint32_t *times) { - *times = RTCCNTL.touch_approach.touch_approach_meas_time; + *times = HAL_FORCE_READ_U32_REG_FIELD(RTCCNTL.touch_approach, touch_approach_meas_time); } /** @@ -1011,11 +1015,11 @@ static inline void touch_ll_proximity_get_meas_times(uint32_t *times) static inline void touch_ll_proximity_read_meas_cnt(touch_pad_t touch_num, uint32_t *cnt) { if (SENS.sar_touch_conf.touch_approach_pad0 == touch_num) { - *cnt = SENS.sar_touch_appr_status.touch_approach_pad0_cnt; + *cnt = HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_touch_appr_status, touch_approach_pad0_cnt); } else if (SENS.sar_touch_conf.touch_approach_pad1 == touch_num) { - *cnt = SENS.sar_touch_appr_status.touch_approach_pad1_cnt; + *cnt = HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_touch_appr_status, touch_approach_pad1_cnt); } else if (SENS.sar_touch_conf.touch_approach_pad2 == touch_num) { - *cnt = SENS.sar_touch_appr_status.touch_approach_pad2_cnt; + *cnt = HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_touch_appr_status, touch_approach_pad2_cnt); } } @@ -1163,7 +1167,7 @@ static inline void touch_ll_sleep_read_debounce(uint32_t *debounce) */ static inline void touch_ll_sleep_read_proximity_cnt(uint32_t *approach_cnt) { - *approach_cnt = SENS.sar_touch_appr_status.touch_slp_approach_cnt; + *approach_cnt = HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_touch_appr_status, touch_slp_approach_cnt); } /** diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/twai_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/twai_ll.h index 106f3adc6fd..7a04c18aef5 100644 --- a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/twai_ll.h +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/twai_ll.h @@ -31,6 +31,7 @@ extern "C" { #include "hal/misc.h" #include "hal/twai_types.h" #include "soc/twai_periph.h" +#include "soc/twai_struct.h" /* ------------------------- Defines and Typedefs --------------------------- */ @@ -399,7 +400,7 @@ static inline void twai_ll_clear_err_code_cap(twai_dev_t *hw) */ static inline void twai_ll_set_err_warn_lim(twai_dev_t *hw, uint32_t ewl) { - hw->error_warning_limit_reg.ewl = ewl; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->error_warning_limit_reg, ewl, ewl); } /** @@ -439,7 +440,7 @@ static inline uint32_t twai_ll_get_rec(twai_dev_t *hw) */ static inline void twai_ll_set_rec(twai_dev_t *hw, uint32_t rec) { - hw->rx_error_counter_reg.rxerr = rec; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->rx_error_counter_reg, rxerr, rec); } /* ------------------------ TX Error Count Register ------------------------- */ @@ -467,7 +468,7 @@ static inline uint32_t twai_ll_get_tec(twai_dev_t *hw) */ static inline void twai_ll_set_tec(twai_dev_t *hw, uint32_t tec) { - hw->tx_error_counter_reg.txerr = tec; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->tx_error_counter_reg, txerr, tec); } /* ---------------------- Acceptance Filter Registers ----------------------- */ @@ -486,8 +487,8 @@ static inline void twai_ll_set_acc_filter(twai_dev_t* hw, uint32_t code, uint32_ uint32_t code_swapped = HAL_SWAP32(code); uint32_t mask_swapped = HAL_SWAP32(mask); for (int i = 0; i < 4; i++) { - hw->acceptance_filter.acr[i].byte = ((code_swapped >> (i * 8)) & 0xFF); - hw->acceptance_filter.amr[i].byte = ((mask_swapped >> (i * 8)) & 0xFF); + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->acceptance_filter.acr[i], byte, ((code_swapped >> (i * 8)) & 0xFF)); + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->acceptance_filter.amr[i], byte, ((mask_swapped >> (i * 8)) & 0xFF)); } hw->mode_reg.afm = single_filter; } @@ -522,7 +523,7 @@ static inline void twai_ll_get_rx_buffer(twai_dev_t *hw, twai_ll_frame_buffer_t { //Copy RX buffer registers into frame for (int i = 0; i < 13; i++) { - rx_frame->bytes[i] = hw->tx_rx_buffer[i].byte; + rx_frame->bytes[i] = HAL_FORCE_READ_U32_REG_FIELD(hw->tx_rx_buffer[i], byte); } } @@ -652,14 +653,14 @@ static inline void twai_ll_set_clkout(twai_dev_t *hw, uint32_t divider) { if (divider >= 2 && divider <= 490) { hw->clock_divider_reg.co = 0; - hw->clock_divider_reg.cd = (divider / 2) - 1; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->clock_divider_reg, cd, (divider / 2) - 1); } else if (divider == 1) { //Setting the divider reg to max value (255) means a divider of 1 hw->clock_divider_reg.co = 0; - hw->clock_divider_reg.cd = 255; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->clock_divider_reg, cd, 255); } else { hw->clock_divider_reg.co = 1; - hw->clock_divider_reg.cd = 0; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->clock_divider_reg, cd, 0); } } diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/uart_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/uart_ll.h index 6c9ee531aa1..9309d3b8f22 100644 --- a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/uart_ll.h +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/uart_ll.h @@ -17,8 +17,11 @@ #pragma once + +#include "hal/misc.h" #include "hal/uart_types.h" #include "soc/uart_periph.h" +#include "soc/uart_struct.h" #include "esp_attr.h" #ifdef __cplusplus @@ -403,7 +406,7 @@ FORCE_INLINE_ATTR void uart_ll_set_tx_idle_num(uart_dev_t *hw, uint32_t idle_num FORCE_INLINE_ATTR void uart_ll_tx_break(uart_dev_t *hw, uint32_t break_num) { if(break_num > 0) { - hw->idle_conf.tx_brk_num = break_num; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->idle_conf, tx_brk_num, break_num); hw->conf0.txd_brk = 1; } else { hw->conf0.txd_brk = 0; @@ -470,8 +473,8 @@ FORCE_INLINE_ATTR void uart_ll_set_sw_flow_ctrl(uart_dev_t *hw, uart_sw_flowctrl hw->flow_conf.sw_flow_con_en = 1; hw->swfc_conf1.xon_threshold = flow_ctrl->xon_thrd; hw->swfc_conf0.xoff_threshold = flow_ctrl->xoff_thrd; - hw->swfc_conf1.xon_char = flow_ctrl->xon_char; - hw->swfc_conf0.xoff_char = flow_ctrl->xoff_char; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->swfc_conf1, xon_char, flow_ctrl->xon_char); + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->swfc_conf0, xoff_char, flow_ctrl->xoff_char); } else { hw->flow_conf.sw_flow_con_en = 0; hw->flow_conf.xonoff_del = 0; @@ -493,11 +496,11 @@ FORCE_INLINE_ATTR void uart_ll_set_sw_flow_ctrl(uart_dev_t *hw, uart_sw_flowctrl */ FORCE_INLINE_ATTR void uart_ll_set_at_cmd_char(uart_dev_t *hw, uart_at_cmd_t *cmd_char) { - hw->at_cmd_char.data = cmd_char->cmd_char; - hw->at_cmd_char.char_num = cmd_char->char_num; - hw->at_cmd_postcnt.post_idle_num = cmd_char->post_idle; - hw->at_cmd_precnt.pre_idle_num = cmd_char->pre_idle; - hw->at_cmd_gaptout.rx_gap_tout = cmd_char->gap_tout; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->at_cmd_char, data, cmd_char->cmd_char); + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->at_cmd_char, char_num, cmd_char->char_num); + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->at_cmd_postcnt, post_idle_num, cmd_char->post_idle); + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->at_cmd_precnt, pre_idle_num, cmd_char->pre_idle); + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->at_cmd_gaptout, rx_gap_tout, cmd_char->gap_tout); } /** @@ -679,8 +682,8 @@ FORCE_INLINE_ATTR void uart_ll_set_mode(uart_dev_t *hw, uart_mode_t mode) */ FORCE_INLINE_ATTR void uart_ll_get_at_cmd_char(uart_dev_t *hw, uint8_t *cmd_char, uint8_t *char_num) { - *cmd_char = hw->at_cmd_char.data; - *char_num = hw->at_cmd_char.char_num; + *cmd_char = HAL_FORCE_READ_U32_REG_FIELD(hw->at_cmd_char, data); + *char_num = HAL_FORCE_READ_U32_REG_FIELD(hw->at_cmd_char, char_num); } /** @@ -827,6 +830,67 @@ FORCE_INLINE_ATTR uint16_t uart_ll_max_tout_thrd(uart_dev_t *hw) return UART_RX_TOUT_THRHD_V; } +/** + * @brief Configure the auto baudrate. + * + * @param hw Beginning address of the peripheral registers. + * @param enable Boolean marking whether the auto baudrate should be enabled or not. + */ +FORCE_INLINE_ATTR void uart_ll_set_autobaud_en(uart_dev_t *hw, bool enable) +{ + hw->auto_baud.en = enable ? 1 : 0; +} + +/** + * @brief Get the RXD edge count. + * + * @param hw Beginning address of the peripheral registers. + */ +FORCE_INLINE_ATTR uint32_t uart_ll_get_rxd_edge_cnt(uart_dev_t *hw) +{ + return hw->rxd_cnt.edge_cnt; +} + +/** + * @brief Get the positive pulse minimum count. + * + * @param hw Beginning address of the peripheral registers. + */ +FORCE_INLINE_ATTR uint32_t uart_ll_get_pos_pulse_cnt(uart_dev_t *hw) +{ + return hw->pospulse.min_cnt; +} + +/** + * @brief Get the negative pulse minimum count. + * + * @param hw Beginning address of the peripheral registers. + */ +FORCE_INLINE_ATTR uint32_t uart_ll_get_neg_pulse_cnt(uart_dev_t *hw) +{ + return hw->negpulse.min_cnt; +} + +/** + * @brief Get the high pulse minimum count. + * + * @param hw Beginning address of the peripheral registers. + */ +FORCE_INLINE_ATTR uint32_t uart_ll_get_high_pulse_cnt(uart_dev_t *hw) +{ + return hw->highpulse.min_cnt; +} + +/** + * @brief Get the low pulse minimum count. + * + * @param hw Beginning address of the peripheral registers. + */ +FORCE_INLINE_ATTR uint32_t uart_ll_get_low_pulse_cnt(uart_dev_t *hw) +{ + return hw->lowpulse.min_cnt; +} + /** * @brief Force UART xoff. * diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/usb_phy_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/usb_phy_ll.h new file mode 100644 index 00000000000..ed175cf9ced --- /dev/null +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/usb_phy_ll.h @@ -0,0 +1,83 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include +#include "soc/soc.h" +#include "soc/system_reg.h" +#include "soc/usb_wrap_struct.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Configures the internal PHY for USB_OTG + * + * @param hw Start address of the USB Wrap registers + */ +static inline void usb_phy_ll_int_otg_enable(usb_wrap_dev_t *hw) +{ + //Enable internal PHY + hw->otg_conf.pad_enable = 1; + hw->otg_conf.phy_sel = 0; +} + +/** + * @brief Configures the external PHY for USB_OTG + * + * @param hw Start address of the USB Wrap registers + */ +static inline void usb_phy_ll_ext_otg_enable(usb_wrap_dev_t *hw) +{ + //Enable external PHY + hw->otg_conf.phy_sel = 1; +} + +/** + * @brief Configures port loads for the internal PHY + * + * @param hw Start address of the USB Wrap registers + * @param dp_pu D+ pullup load + * @param dp_pd D+ pulldown load + * @param dm_pu D- pullup load + * @param dm_pd D- pulldown load + */ +static inline void usb_phy_ll_int_load_conf(usb_wrap_dev_t *hw, bool dp_pu, bool dp_pd, bool dm_pu, bool dm_pd) +{ + usb_wrap_otg_conf_reg_t conf = hw->otg_conf; + conf.pad_pull_override = 1; + conf.dp_pullup = dp_pu; + conf.dp_pulldown = dp_pd; + conf.dm_pullup = dm_pu; + conf.dm_pulldown = dm_pd; + hw->otg_conf = conf; +} + +/** + * @brief Enable the internal PHY's test mode + * + * @param hw Start address of the USB Wrap registers + * @param en Whether to enable the internal PHY's test mode + */ +static inline void usb_phy_ll_int_enable_test_mode(usb_wrap_dev_t *hw, bool en) +{ + if (en) { + // Clear USB_WRAP_TEST_CONF_REG + hw->test_conf.val = 0; + // Set USB test pad oen + hw->test_conf.test_usb_wrap_oe = 1; + // Enable USB test mode + hw->test_conf.test_enable = 1; + } else { + hw->test_conf.test_enable = 0; + } +} + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/xt_wdt_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/xt_wdt_ll.h new file mode 100644 index 00000000000..65b36253e58 --- /dev/null +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/xt_wdt_ll.h @@ -0,0 +1,101 @@ +/* + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +// The LL layer for xtal32k WDT register operations. +// Note that most of the register operations in this layer are non-atomic operations. + +#pragma once + +#include +#include "soc/rtc_cntl_periph.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define XT_WDT_LL_XTAL32_DEAD_INTR_MASK RTC_CNTL_XTAL32K_DEAD_INT_ST_M + +/** + * @brief Enable the XT_WDT + * + * @param hw Start address of the peripheral registers. + */ +inline void xt_wdt_ll_enable(rtc_cntl_dev_t *hw, bool enable) +{ + hw->ext_xtl_conf.xtal32k_wdt_en = enable; +} + +/** + * @brief Check if the XT_WDT is enabled + * + * @param hw Start address of the peripheral registers. + * @return True if XT WDT is enabled + */ +inline bool xt_wdt_ll_check_if_enabled(rtc_cntl_dev_t *hw) +{ + return (hw->ext_xtl_conf.xtal32k_wdt_en) ? true : false; +} + +/** + * @brief Set the watchdog timeout value + * + * @param hw Start address of the peripheral registers. + * @param timeout timeout value in RTC_CLK cycles + */ +inline void xt_wdt_ll_set_timeout(rtc_cntl_dev_t *hw, uint8_t timeout) +{ + hw->xtal32k_conf.xtal32k_wdt_timeout = timeout; +} + + +/** + * @brief Reset the XT_WDT + * + * @param hw Start address of the peripheral registers. + */ +inline void xt_wdt_ll_reset(rtc_cntl_dev_t *hw) +{ + hw->ext_xtl_conf.xtal32k_wdt_reset = 1; + hw->ext_xtl_conf.xtal32k_wdt_reset = 0; +} + + +/** + * @brief Set the backup clock value + * + * @param hw Start address of the peripheral registers. + * @param backup_clk_val Backup clock value, see TRM for definition + */ +inline void xt_wdt_ll_set_backup_clk_factor(rtc_cntl_dev_t *hw, uint32_t backup_clk_val) +{ + hw->xtal32k_clk_factor = backup_clk_val; +} + +/** + * @brief Enable the auto-backup clock feature + * + * @param hw Start address of the peripheral registers. + * @param enable True - enable, False - disable + */ +inline void xt_wdt_ll_auto_backup_enable(rtc_cntl_dev_t *hw, bool enable) +{ + hw->ext_xtl_conf.xtal32k_auto_backup = enable; +} + +/** + * @brief Enable the timeout interrupt + * + * @param hw Start address of the peripheral registers. + * @param enable True - enable, False - disable + */ +inline void xt_wdt_ll_intr_enable(rtc_cntl_dev_t *hw, bool enable) +{ + hw->int_ena.rtc_xtal32k_dead = enable; +} + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32s2/include/hal/include/hal/adc_hal.h b/tools/sdk/esp32s2/include/hal/include/hal/adc_hal.h index 1c1a399a4d3..807d620c639 100644 --- a/tools/sdk/esp32s2/include/hal/include/hal/adc_hal.h +++ b/tools/sdk/esp32s2/include/hal/include/hal/adc_hal.h @@ -114,6 +114,22 @@ void adc_hal_init(void); #define adc_hal_amp_disable() adc_ll_amp_disable() #endif +#if SOC_ADC_ARBITER_SUPPORTED +//No ADC2 controller arbiter on ESP32 +/** + * Config ADC2 module arbiter. + * The arbiter is to improve the use efficiency of ADC2. After the control right is robbed by the high priority, + * the low priority controller will read the invalid ADC2 data, and the validity of the data can be judged by the flag bit in the data. + * + * @note Only ADC2 support arbiter. + * @note The arbiter's working clock is APB_CLK. When the APB_CLK clock drops below 8 MHz, the arbiter must be in shield mode. + * @note Default priority: Wi-Fi > RTC > Digital; + * + * @param config Refer to ``adc_arbiter_t``. + */ +void adc_hal_arbiter_config(adc_arbiter_t *config); +#endif //#if SOC_ADC_ARBITER_SUPPORTED + /*--------------------------------------------------------------- PWDET(Power detect) controller setting ---------------------------------------------------------------*/ @@ -260,7 +276,7 @@ esp_err_t adc_hal_convert(adc_ll_num_t adc_n, int channel, int *out_raw); /*--------------------------------------------------------------- ADC calibration setting ---------------------------------------------------------------*/ -#if SOC_ADC_HW_CALIBRATION_V1 +#if SOC_ADC_CALIBRATION_V1_SUPPORTED // ESP32-S2, C3 and H2 support HW offset calibration. /** @@ -296,7 +312,7 @@ void adc_hal_set_calibration_param(adc_ll_num_t adc_n, uint32_t param); */ uint32_t adc_hal_self_calibration(adc_ll_num_t adc_n, adc_channel_t channel, adc_atten_t atten, bool internal_gnd); -#endif //SOC_ADC_HW_CALIBRATION_V1 +#endif //SOC_ADC_CALIBRATION_V1_SUPPORTED #if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32H2 /*--------------------------------------------------------------- diff --git a/tools/sdk/esp32s2/include/hal/include/hal/ds_hal.h b/tools/sdk/esp32s2/include/hal/include/hal/ds_hal.h index 253fab9f962..40d5c358936 100644 --- a/tools/sdk/esp32s2/include/hal/include/hal/ds_hal.h +++ b/tools/sdk/esp32s2/include/hal/include/hal/ds_hal.h @@ -21,7 +21,7 @@ #pragma once #if CONFIG_IDF_TARGET_ESP32 - #error "ESP32 doesn't have a DS peripheral" +#error "ESP32 doesn't have a DS peripheral" #endif #include diff --git a/tools/sdk/esp32s2/include/hal/include/hal/i2s_hal.h b/tools/sdk/esp32s2/include/hal/include/hal/i2s_hal.h index 6964bfdf947..a08813db808 100644 --- a/tools/sdk/esp32s2/include/hal/include/hal/i2s_hal.h +++ b/tools/sdk/esp32s2/include/hal/include/hal/i2s_hal.h @@ -1,4 +1,4 @@ -// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD +// Copyright 2020 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. @@ -25,13 +25,47 @@ #include "soc/i2s_periph.h" #include "soc/soc_caps.h" -#include "hal/i2s_ll.h" #include "hal/i2s_types.h" +#include "hal/i2s_ll.h" #ifdef __cplusplus extern "C" { #endif +/** + * @brief I2S clock configuration + */ +typedef struct { + uint32_t sclk; /*!< I2S module clock */ + uint32_t mclk; /*!< I2S master clock */ + uint32_t bclk; /*!< I2S bit clock */ + uint16_t mclk_div; /*!< I2S master clock division */ + uint16_t bclk_div; /*!< I2S bit clock division*/ +} i2s_hal_clock_cfg_t; + + +/** + * @brief I2S HAL configurations + */ +typedef struct { + i2s_mode_t mode; /*!< I2S work mode, using ored mask of `i2s_mode_t`*/ + uint32_t sample_rate; /*!< I2S sample rate*/ + i2s_comm_format_t comm_fmt; /*!< I2S communication format */ + i2s_channel_fmt_t chan_fmt; /*!< I2S channel format, there are total 16 channels in TDM mode.*/ + uint32_t sample_bits; /*!< I2S sample bits in one channel */ + uint32_t chan_bits; /*!< I2S total bits in one channel. Should not be smaller than 'sample_bits', default '0' means equal to 'sample_bits' */ + uint32_t active_chan; /*!< I2S active channel number */ + uint32_t total_chan; /*!< Total number of I2S channels */ + +#if SOC_I2S_SUPPORTS_TDM + uint32_t chan_mask; /*!< Active channel bit mask, set value in `i2s_channel_t` to enable specific channel, the bit map of active channel can not exceed (0x1<dev, status) +#define i2s_hal_enable_module_clock(hal) i2s_ll_enable_clock((hal)->dev); /** - * @brief Clear I2S interrupt status + * @brief Disable I2S module clock * * @param hal Context of the HAL layer - * @param mask interrupt status mask */ -#define i2s_hal_clear_intr_status(hal, mask) i2s_ll_clear_intr_status((hal)->dev, mask) +#define i2s_hal_disable_module_clock(hal) i2s_ll_disable_clock((hal)->dev); /** - * @brief Get I2S out eof des address + * @brief Reset I2S TX channel * * @param hal Context of the HAL layer - * @param addr out eof des address */ -#define i2s_hal_get_out_eof_des_addr(hal, addr) i2s_ll_get_out_eof_des_addr((hal)->dev, addr) +#define i2s_hal_reset_tx(hal) i2s_ll_tx_reset((hal)->dev) /** - * @brief Get I2S in eof des address + * @brief Reset I2S TX fifo * * @param hal Context of the HAL layer - * @param addr in eof des address */ -#define i2s_hal_get_in_eof_des_addr(hal, addr) i2s_ll_get_in_eof_des_addr((hal)->dev, addr) +#define i2s_hal_reset_tx_fifo(hal) i2s_ll_tx_reset_fifo((hal)->dev) /** - * @brief Enable I2S rx interrupt + * @brief Reset I2S RX channel * * @param hal Context of the HAL layer */ -#define i2s_hal_enable_rx_intr(hal) i2s_ll_enable_rx_intr((hal)->dev) +#define i2s_hal_reset_rx(hal) i2s_ll_rx_reset((hal)->dev) /** - * @brief Disable I2S rx interrupt + * @brief Reset I2S RX fifo * * @param hal Context of the HAL layer */ -#define i2s_hal_disable_rx_intr(hal) i2s_ll_disable_rx_intr((hal)->dev) +#define i2s_hal_reset_rx_fifo(hal) i2s_ll_rx_reset_fifo((hal)->dev) /** - * @brief Disable I2S tx interrupt + * @brief Get I2S hardware instance and enable I2S module clock + * @note This function should be called first before other hal layer function is called * * @param hal Context of the HAL layer + * @param i2s_num The uart port number, the max port number is (I2S_NUM_MAX -1) */ -#define i2s_hal_disable_tx_intr(hal) i2s_ll_disable_tx_intr((hal)->dev) +void i2s_hal_init(i2s_hal_context_t *hal, int i2s_num); /** - * @brief Enable I2S tx interrupt + * @brief Configure I2S source clock * * @param hal Context of the HAL layer + * @param sel The source clock index */ -#define i2s_hal_enable_tx_intr(hal) i2s_ll_enable_tx_intr((hal)->dev) +void i2s_hal_set_clock_src(i2s_hal_context_t *hal, i2s_clock_src_t sel); /** - * @brief Set I2S tx mode + * @brief Set Tx channel style * * @param hal Context of the HAL layer - * @param ch i2s channel - * @param bits bits per sample + * @param hal_cfg I2S hal configuration structer, refer to `i2s_hal_config_t` */ -void i2s_hal_set_tx_mode(i2s_hal_context_t *hal, i2s_channel_t ch, i2s_bits_per_sample_t bits); +void i2s_hal_tx_set_channel_style(i2s_hal_context_t *hal, const i2s_hal_config_t *hal_cfg); /** - * @brief Set I2S rx mode + * @brief Set Rx channel style * * @param hal Context of the HAL layer - * @param ch i2s channel - * @param bits bits per sample + * @param hal_cfg I2S hal configuration structer, refer to `i2s_hal_config_t` */ -void i2s_hal_set_rx_mode(i2s_hal_context_t *hal, i2s_channel_t ch, i2s_bits_per_sample_t bits); +void i2s_hal_rx_set_channel_style(i2s_hal_context_t *hal, const i2s_hal_config_t *hal_cfg); /** - * @brief Set I2S out link address + * @brief Initialize I2S hardware * * @param hal Context of the HAL layer - * @param addr out link address + * @param hal_cfg I2S hal configuration structer, refer to `i2s_hal_config_t` */ -#define i2s_hal_set_out_link_addr(hal, addr) i2s_ll_set_out_link_addr((hal)->dev, addr) +void i2s_hal_config_param(i2s_hal_context_t *hal, const i2s_hal_config_t *hal_cfg); /** - * @brief Set I2S out link address + * @brief Enable I2S master full-duplex mode * * @param hal Context of the HAL layer - * @param addr out link address */ -#define i2s_hal_set_out_link_addr(hal, addr) i2s_ll_set_out_link_addr((hal)->dev, addr) +void i2s_hal_enable_master_fd_mode(i2s_hal_context_t *hal); /** - * @brief Set I2S out link address + * @brief Enable I2S slave full-duplex mode * * @param hal Context of the HAL layer - * @param addr out link address */ -#define i2s_hal_set_out_link_addr(hal, addr) i2s_ll_set_out_link_addr((hal)->dev, addr) +void i2s_hal_enable_slave_fd_mode(i2s_hal_context_t *hal); /** - * @brief Set I2S in link + * @brief Start I2S tx * * @param hal Context of the HAL layer - * @param rx_eof_num in link eof num - * @param addr in link address */ -void i2s_hal_set_in_link(i2s_hal_context_t *hal, uint32_t rx_eof_num, uint32_t addr); +#define i2s_hal_start_tx(hal) i2s_ll_tx_start((hal)->dev) /** - * @brief Set I2S clk div + * @brief Start I2S rx * * @param hal Context of the HAL layer - * @param div_num i2s clkm div num - * @param div_a i2s clkm div a - * @param div_b i2s clkm div b - * @param tx_bck_div tx bck div num - * @param rx_bck_div rx bck div num */ -void i2s_hal_set_clk_div(i2s_hal_context_t *hal, int div_num, int div_a, int div_b, int tx_bck_div, int rx_bck_div); +#define i2s_hal_start_rx(hal) i2s_ll_rx_start((hal)->dev) /** - * @brief Set I2S clock sel + * @brief Stop I2S tx * * @param hal Context of the HAL layer - * @param sel clock sel */ -#define i2s_hal_set_clock_sel(hal, sel) i2s_ll_set_clk_sel((hal)->dev, sel) +#define i2s_hal_stop_tx(hal) i2s_ll_tx_stop((hal)->dev) /** - * @brief Set I2S tx bits mod + * @brief Stop I2S rx * * @param hal Context of the HAL layer - * @param bits bit width per sample. */ -void i2s_hal_set_tx_bits_mod(i2s_hal_context_t *hal, i2s_bits_per_sample_t bits); +#define i2s_hal_stop_rx(hal) i2s_ll_rx_stop((hal)->dev) /** - * @brief Set I2S rx bits mod + * @brief Set the received data length to trigger `in_suc_eof` interrupt. * * @param hal Context of the HAL layer - * @param bits bit width per sample. + * @param eof_byte The byte length that trigger in_suc_eof interrupt. */ -void i2s_hal_set_rx_bits_mod(i2s_hal_context_t *hal, i2s_bits_per_sample_t bits); +#define i2s_hal_set_rx_eof_num(hal, eof_byte) i2s_ll_rx_set_eof_num((hal)->dev, eof_byte) /** - * @brief Reset I2S TX & RX module, including DMA and FIFO + * @brief Set I2S TX sample bit * * @param hal Context of the HAL layer + * @param chan_bit I2S TX chan bit + * @param data_bit The sample data bit length. */ -void i2s_hal_reset(i2s_hal_context_t *hal); +#define i2s_hal_set_tx_sample_bit(hal, chan_bit, data_bit) i2s_ll_tx_set_sample_bit((hal)->dev, chan_bit, data_bit) /** - * @brief Start I2S tx + * @brief Set I2S RX sample bit * * @param hal Context of the HAL layer + * @param chan_bit I2S RX chan bit + * @param data_bit The sample data bit length. */ -void i2s_hal_start_tx(i2s_hal_context_t *hal); +#define i2s_hal_set_rx_sample_bit(hal, chan_bit, data_bit) i2s_ll_rx_set_sample_bit((hal)->dev, chan_bit, data_bit) /** - * @brief Start I2S rx + * @brief Configure I2S TX module clock devider * * @param hal Context of the HAL layer + * @param clk_cfg I2S clock configuration */ -void i2s_hal_start_rx(i2s_hal_context_t *hal); +void i2s_hal_tx_clock_config(i2s_hal_context_t *hal, i2s_hal_clock_cfg_t *clk_cfg); /** - * @brief Stop I2S tx + * @brief Configure I2S RX module clock devider * * @param hal Context of the HAL layer + * @param clk_cfg I2S clock configuration */ -void i2s_hal_stop_tx(i2s_hal_context_t *hal); +void i2s_hal_rx_clock_config(i2s_hal_context_t *hal, i2s_hal_clock_cfg_t *clk_cfg); /** - * @brief Stop I2S rx + * @brief Set I2S tx clock source * * @param hal Context of the HAL layer + * @param clk_src i2s tx clock source (see 'i2s_clock_src_t') */ -void i2s_hal_stop_rx(i2s_hal_context_t *hal); +#define i2s_hal_tx_set_clock_source(hal, clk_src) i2s_ll_tx_clk_set_src((hal)->dev, clk_src) /** - * @brief Config I2S param + * @brief Set I2S rx clock source * * @param hal Context of the HAL layer - * @param i2s_config I2S configurations - see i2s_config_t struct + * @param clk_src i2s rx clock source (see 'i2s_clock_src_t') */ -void i2s_hal_config_param(i2s_hal_context_t *hal, const i2s_config_t *i2s_config); +#define i2s_hal_rx_set_clock_source(hal, clk_src) i2s_ll_rx_clk_set_src((hal)->dev, clk_src) /** - * @brief Enable I2S sig loopback + * @brief Enable I2S tx slave mode * * @param hal Context of the HAL layer + * @param enable set 'true' to enable tx slave mode */ -#define i2s_hal_enable_sig_loopback(hal) i2s_ll_set_sig_loopback((hal)->dev, 1) +#define i2s_hal_tx_enable_slave_mode(hal, enable) i2s_ll_tx_set_slave_mod((hal)->dev, enable) /** - * @brief Enable I2S master mode + * @brief Enable I2S rx slave mode * * @param hal Context of the HAL layer + * @param enable set 'true' to enable rx slave mode */ -void i2s_hal_enable_master_mode(i2s_hal_context_t *hal); +#define i2s_hal_rx_enable_slave_mode(hal, enable) i2s_ll_rx_set_slave_mod((hal)->dev, enable) /** - * @brief Enable I2S slave mode + * @brief Enable loopback mode * * @param hal Context of the HAL layer */ -void i2s_hal_enable_slave_mode(i2s_hal_context_t *hal); +#define i2s_hal_enable_sig_loopback(hal) i2s_ll_share_bck_ws((hal)->dev, true) /** - * @brief Init the I2S hal and set the I2S to the default configuration. This function should be called first before other hal layer function is called + * @brief Set I2S configuration for common TX mode + * @note Common mode is for non-PDM mode like philip/MSB/PCM * * @param hal Context of the HAL layer - * @param i2s_num The uart port number, the max port number is (I2S_NUM_MAX -1) + * @param hal_cfg hal configuration structure */ -void i2s_hal_init(i2s_hal_context_t *hal, int i2s_num); +void i2s_hal_tx_set_common_mode(i2s_hal_context_t *hal, const i2s_hal_config_t *hal_cfg); + +/** + * @brief Set I2S configuration for common RX mode + * @note Common mode is for non-PDM mode like philip/MSB/PCM + * + * @param hal Context of the HAL layer + * @param hal_cfg hal configuration structure + */ +void i2s_hal_rx_set_common_mode(i2s_hal_context_t *hal, const i2s_hal_config_t *hal_cfg); + +#if SOC_I2S_SUPPORTS_PCM +/** + * @brief Configure I2S TX PCM encoder or decoder. + * + * @param hal Context of the HAL layer + * @param cfg PCM configure paramater, refer to `i2s_pcm_compress_t` + */ +#define i2s_hal_tx_pcm_cfg(hal, cfg) i2s_ll_tx_set_pcm_type((hal)->dev, cfg) + +/** + * @brief Configure I2S RX PCM encoder or decoder. + * + * @param hal Context of the HAL layer + * @param cfg PCM configure paramater, refer to `i2s_pcm_compress_t` + */ +#define i2s_hal_rx_pcm_cfg(hal, cfg) i2s_ll_rx_set_pcm_type((hal)->dev, cfg) +#endif + +#if SOC_I2S_SUPPORTS_PDM_TX +/** + * @brief Configure I2S TX PDM sample rate + * Fpdm = 64*Fpcm*fp/fs + * + * @param hal Context of the HAL layer + * @param fp TX PDM fp paramater configuration + * @param fs TX PDM fs paramater configuration + */ +#define i2s_hal_set_tx_pdm_fpfs(hal, fp, fs) i2s_ll_tx_set_pdm_fpfs((hal)->dev, fp, fs) + +/** + * @brief Get I2S TX PDM fp + * + * @param hal Context of the HAL layer + * @return + * - fp configuration paramater + */ +#define i2s_hal_get_tx_pdm_fp(hal) i2s_ll_tx_get_pdm_fp((hal)->dev) + +/** + * @brief Get I2S TX PDM fs + * + * @param hal Context of the HAL layer + * @return + * - fs configuration paramater + */ +#define i2s_hal_get_tx_pdm_fs(hal) i2s_ll_tx_get_pdm_fs((hal)->dev) + +/** + * @brief Set I2S default configuration for PDM TX mode + * + * @param hal Context of the HAL layer + * @param sample_rate PDM sample rate + */ +void i2s_hal_tx_set_pdm_mode_default(i2s_hal_context_t *hal, uint32_t sample_rate); +#endif + +#if SOC_I2S_SUPPORTS_PDM_RX + +/** + * @brief Configure RX PDM downsample + * + * @param hal Context of the HAL layer + * @param dsr PDM downsample configuration paramater + */ +#define i2s_hal_set_rx_pdm_dsr(hal, dsr) i2s_ll_rx_set_pdm_dsr((hal)->dev, dsr) + +/** + * @brief Get RX PDM downsample configuration + * + * @param hal Context of the HAL layer + * @param dsr Pointer to accept PDM downsample configuration + */ +#define i2s_hal_get_rx_pdm_dsr(hal, dsr) i2s_ll_rx_get_pdm_dsr((hal)->dev, dsr) + +/** + * @brief Set I2S default configuration for PDM R mode + * + * @param hal Context of the HAL layer + */ +void i2s_hal_rx_set_pdm_mode_default(i2s_hal_context_t *hal); +#endif -#if SOC_I2S_SUPPORTS_PDM +#if !SOC_GDMA_SUPPORTED /** - * @brief Set I2S tx pdm + * @brief Enable I2S TX DMA * * @param hal Context of the HAL layer - * @param fp tx pdm fp - * @param fs tx pdm fs */ -void i2s_hal_tx_pdm_cfg(i2s_hal_context_t *hal, uint32_t fp, uint32_t fs); +#define i2s_hal_enable_tx_dma(hal) i2s_ll_enable_dma((hal)->dev,true) /** - * @brief Get I2S tx pdm + * @brief Enable I2S RX DMA * * @param hal Context of the HAL layer - * @param dsr rx pdm dsr */ -void i2s_hal_rx_pdm_cfg(i2s_hal_context_t *hal, uint32_t dsr); +#define i2s_hal_enable_rx_dma(hal) i2s_ll_enable_dma((hal)->dev,true) /** - * @brief Get I2S tx pdm configuration + * @brief Disable I2S TX DMA * * @param hal Context of the HAL layer - * @param fp Pointer to receive tx PDM fp configuration - * @param fs Pointer to receive tx PDM fs configuration */ -void i2s_hal_get_tx_pdm(i2s_hal_context_t *hal, uint32_t *fp, uint32_t *fs); +#define i2s_hal_disable_tx_dma(hal) i2s_ll_enable_dma((hal)->dev,false) + +/** + * @brief Disable I2S RX DMA + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_disable_rx_dma(hal) i2s_ll_enable_dma((hal)->dev,false) + +/** + * @brief Get I2S interrupt status + * + * @param hal Context of the HAL layer + * @return + * - module interrupt status + */ +#define i2s_hal_get_intr_status(hal) i2s_ll_get_intr_status((hal)->dev) + +/** + * @brief Get I2S interrupt status + * + * @param hal Context of the HAL layer + * @param mask Interrupt mask to be cleared. + */ +#define i2s_hal_clear_intr_status(hal, mask) i2s_ll_clear_intr_status((hal)->dev, mask) + +/** + * @brief Enable I2S RX interrupt + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_enable_rx_intr(hal) i2s_ll_rx_enable_intr((hal)->dev) + +/** + * @brief Disable I2S RX interrupt + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_disable_rx_intr(hal) i2s_ll_rx_disable_intr((hal)->dev) + +/** + * @brief Disable I2S TX interrupt + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_disable_tx_intr(hal) i2s_ll_tx_disable_intr((hal)->dev) + +/** + * @brief Enable I2S TX interrupt + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_enable_tx_intr(hal) i2s_ll_tx_enable_intr((hal)->dev) + +/** + * @brief Configure TX DMA descriptor address and start TX DMA + * + * @param hal Context of the HAL layer + * @param link_addr DMA descriptor link address. + */ +#define i2s_hal_start_tx_link(hal, link_addr) i2s_ll_tx_start_link((hal)->dev, link_addr) + +/** + * @brief Configure RX DMA descriptor address and start RX DMA + * + * @param hal Context of the HAL layer + * @param link_addr DMA descriptor link address. + */ +#define i2s_hal_start_rx_link(hal, link_addr) i2s_ll_rx_start_link((hal)->dev, link_addr) + +/** + * @brief Stop TX DMA link + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_stop_tx_link(hal) i2s_ll_tx_stop_link((hal)->dev) + +/** + * @brief Stop RX DMA link + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_stop_rx_link(hal) i2s_ll_rx_stop_link((hal)->dev) + +/** + * @brief Reset RX DMA + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_reset_rxdma(hal) i2s_ll_rx_reset_dma((hal)->dev) + +/** + * @brief Reset TX DMA + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_reset_txdma(hal) i2s_ll_tx_reset_dma((hal)->dev) + +/** + * @brief Get I2S out eof descriptor address + * + * @param hal Context of the HAL layer + * @param addr Pointer to accept out eof des address + */ +#define i2s_hal_get_out_eof_des_addr(hal, addr) i2s_ll_tx_get_eof_des_addr((hal)->dev, addr) + +/** + * @brief Get I2S in suc eof descriptor address + * + * @param hal Context of the HAL layer + * @param addr Pointer to accept in suc eof des address + */ +#define i2s_hal_get_in_eof_des_addr(hal, addr) i2s_ll_rx_get_eof_des_addr((hal)->dev, addr) +#endif + +#if SOC_I2S_SUPPORTS_ADC +/** + * @brief Enable Builtin DAC + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_enable_builtin_dac(hal) i2s_ll_enable_builtin_dac((hal)->dev, true); + +/** + * @brief Enable Builtin ADC + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_enable_builtin_adc(hal) i2s_ll_enable_builtin_adc((hal)->dev, true); + +/** + * @brief Disable Builtin ADC + * + * @param hal Context of the HAL layer + */ +#define i2s_hal_disable_builtin_adc(hal) i2s_ll_enable_builtin_adc((hal)->dev, false); +#endif +#if SOC_I2S_SUPPORTS_DAC /** - * @brief Get I2S rx pdm configuration + * @brief Disable Builtin DAC * * @param hal Context of the HAL layer - * @param dsr rx pdm dsr */ -void i2s_hal_get_rx_pdm(i2s_hal_context_t *hal, uint32_t *dsr); +#define i2s_hal_disable_builtin_dac(hal) i2s_ll_enable_builtin_dac((hal)->dev, false); #endif #ifdef __cplusplus diff --git a/tools/sdk/esp32s2/include/hal/include/hal/i2s_types.h b/tools/sdk/esp32s2/include/hal/include/hal/i2s_types.h index ba150cc7b34..48d745eb2fa 100644 --- a/tools/sdk/esp32s2/include/hal/include/hal/i2s_types.h +++ b/tools/sdk/esp32s2/include/hal/include/hal/i2s_types.h @@ -1,4 +1,4 @@ -// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD +// Copyright 2020 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. @@ -16,6 +16,7 @@ #include #include +#include #include #include "soc/soc_caps.h" @@ -24,34 +25,59 @@ extern "C" { #endif /** - * @brief I2S port number, the max port number is (I2S_NUM_MAX -1). + * @brief I2S bit width per sample. + * */ typedef enum { - I2S_NUM_0 = 0, /*!< I2S port 0 */ -#if SOC_I2S_NUM > 1 - I2S_NUM_1 = 1, /*!< I2S port 1 */ -#endif - I2S_NUM_MAX, /*!< I2S port max */ -} i2s_port_t; + I2S_BITS_PER_SAMPLE_8BIT = 8, /*!< data bit-width: 8 */ + I2S_BITS_PER_SAMPLE_16BIT = 16, /*!< data bit-width: 16 */ + I2S_BITS_PER_SAMPLE_24BIT = 24, /*!< data bit-width: 24 */ + I2S_BITS_PER_SAMPLE_32BIT = 32, /*!< data bit-width: 32 */ +} i2s_bits_per_sample_t; /** - * @brief I2S bit width per sample. + * @brief I2S bit width per chan. * */ typedef enum { - I2S_BITS_PER_SAMPLE_8BIT = 8, /*!< I2S bits per sample: 8-bits*/ - I2S_BITS_PER_SAMPLE_16BIT = 16, /*!< I2S bits per sample: 16-bits*/ - I2S_BITS_PER_SAMPLE_24BIT = 24, /*!< I2S bits per sample: 24-bits*/ - I2S_BITS_PER_SAMPLE_32BIT = 32, /*!< I2S bits per sample: 32-bits*/ -} i2s_bits_per_sample_t; + I2S_BITS_PER_CHAN_DEFAULT = (0), /*!< channel bit-width equals to data bit-width */ + I2S_BITS_PER_CHAN_8BIT = (8), /*!< channel bit-width: 8 */ + I2S_BITS_PER_CHAN_16BIT = (16), /*!< channel bit-width: 16 */ + I2S_BITS_PER_CHAN_24BIT = (24), /*!< channel bit-width: 24 */ + I2S_BITS_PER_CHAN_32BIT = (32), /*!< channel bit-width: 32 */ +} i2s_bits_per_chan_t; /** * @brief I2S channel. * */ typedef enum { - I2S_CHANNEL_MONO = 1, /*!< I2S 1 channel (mono)*/ - I2S_CHANNEL_STEREO = 2 /*!< I2S 2 channel (stereo)*/ + I2S_CHANNEL_MONO = (0x01 << 31) | 0x03, /*!< I2S channel (mono), two channel enabled. In this mode, you only need to send one channel data but the fifo will copy same data for another channel automatically, then both channels will transmit same data. The highest bit is for differentiating I2S_CHANNEL_STEREO since they both use two channels */ + I2S_CHANNEL_STEREO = 0x03, /*!< I2S channel (stereo), two channel enabled. In this mode, two channels will transmit different data. */ +#if SOC_I2S_SUPPORTS_TDM + // Bit map of active chan. + // There are 16 channels in TDM mode. + // For TX module, only the active channel send the audio data, the inactive channel send a constant(configurable) or will be skiped if 'skip_msk' is set. + // For RX module, only receive the audio data in active channels, the data in inactive channels will be ignored. + // the bit map of active channel can not exceed (0x1< 0, then the clock output for i2s is fixed and equal to the fixed_mclk value.*/ -} i2s_config_t; - -/** - * @brief I2S event types - * + * @brief The multiple of mclk to sample rate */ typedef enum { - I2S_EVENT_DMA_ERROR, - I2S_EVENT_TX_DONE, /*!< I2S DMA finish sent 1 buffer*/ - I2S_EVENT_RX_DONE, /*!< I2S DMA finish received 1 buffer*/ - I2S_EVENT_MAX, /*!< I2S event max index*/ -} i2s_event_type_t; + I2S_MCLK_MULTIPLE_DEFAULT = 0, /*!< Default value. mclk = sample_rate * 256 */ + I2S_MCLK_MULTIPLE_128 = 128, /*!< mclk = sample_rate * 128 */ + I2S_MCLK_MULTIPLE_256 = 256, /*!< mclk = sample_rate * 256 */ + I2S_MCLK_MULTIPLE_384 = 384, /*!< mclk = sample_rate * 384 */ +} i2s_mclk_multiple_t; -#if SOC_I2S_SUPPORTS_ADC_DAC +#if SOC_I2S_SUPPORTS_DAC /** * @brief I2S DAC mode for i2s_set_dac_mode. * - * @note PDM and built-in DAC functions are only supported on I2S0 for current ESP32 chip. + * @note Built-in DAC functions are only supported on I2S0 for current ESP32 chip. */ typedef enum { I2S_DAC_CHANNEL_DISABLE = 0, /*!< Disable I2S built-in DAC signals*/ @@ -157,29 +167,23 @@ typedef enum { I2S_DAC_CHANNEL_BOTH_EN = 0x3, /*!< Enable both of the I2S built-in DAC channels.*/ I2S_DAC_CHANNEL_MAX = 0x4, /*!< I2S built-in DAC mode max index*/ } i2s_dac_mode_t; -#endif //SOC_I2S_SUPPORTS_ADC_DAC +#endif //SOC_I2S_SUPPORTS_DAC +#if SOC_I2S_SUPPORTS_PCM /** - * @brief Event structure used in I2S event queue + * @brief A/U-law decompress or compress configuration. * */ -typedef struct { - i2s_event_type_t type; /*!< I2S event type */ - size_t size; /*!< I2S data size for I2S_DATA event*/ -} i2s_event_t; +typedef enum { + I2S_PCM_DISABLE = 0, /*!< Disable A/U law decopress or compress*/ + I2S_PCM_A_DECOMPRESS, /*!< A-law decompress*/ + I2S_PCM_A_COMPRESS, /*!< A-law compress*/ + I2S_PCM_U_DECOMPRESS, /*!< U-law decompress*/ + I2S_PCM_U_COMPRESS, /*!< U-law compress*/ +} i2s_pcm_compress_t; +#endif -/** - * @brief I2S pin number for i2s_set_pin - * - */ -typedef struct { - int bck_io_num; /*!< BCK in out pin*/ - int ws_io_num; /*!< WS in out pin*/ - int data_out_num; /*!< DATA out pin*/ - int data_in_num; /*!< DATA in pin*/ -} i2s_pin_config_t; - -#if SOC_I2S_SUPPORTS_PDM +#if SOC_I2S_SUPPORTS_PDM_RX /** * @brief I2S PDM RX downsample mode */ @@ -188,18 +192,17 @@ typedef enum { I2S_PDM_DSR_16S, /*!< downsampling number is 16 for PDM RX mode*/ I2S_PDM_DSR_MAX, } i2s_pdm_dsr_t; +#endif -/** - * @brief PDM PCM convter enable/disable. - * - */ +#if SOC_I2S_SUPPORTS_PDM_TX typedef enum { - PDM_PCM_CONV_ENABLE, /*!< Enable PDM PCM convert*/ - PDM_PCM_CONV_DISABLE, /*!< Disable PDM PCM convert*/ -} pdm_pcm_conv_t; + I2S_PDM_SIG_SCALING_DIV_2 = 0, /*!< I2S TX PDM sigmadelta signal scaling: /2 */ + I2S_PDM_SIG_SCALING_MUL_1 = 1, /*!< I2S TX PDM sigmadelta signal scaling: x1 */ + I2S_PDM_SIG_SCALING_MUL_2 = 2, /*!< I2S TX PDM sigmadelta signal scaling: x2 */ + I2S_PDM_SIG_SCALING_MUL_4 = 3, /*!< I2S TX PDM sigmadelta signal scaling: x4 */ +} i2s_pdm_sig_scale_t; #endif - #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32s2/include/hal/include/hal/lcd_hal.h b/tools/sdk/esp32s2/include/hal/include/hal/lcd_hal.h index a6bcba166c6..76e28dda0e4 100644 --- a/tools/sdk/esp32s2/include/hal/include/hal/lcd_hal.h +++ b/tools/sdk/esp32s2/include/hal/include/hal/lcd_hal.h @@ -24,10 +24,10 @@ extern "C" { #endif -#include "soc/lcd_cam_struct.h" +typedef struct lcd_cam_dev_t *lcd_soc_handle_t; typedef struct { - lcd_cam_dev_t *dev; + lcd_soc_handle_t dev; } lcd_hal_context_t; void lcd_hal_init(lcd_hal_context_t *hal, int id); diff --git a/tools/sdk/esp32s2/include/hal/include/hal/lcd_types.h b/tools/sdk/esp32s2/include/hal/include/hal/lcd_types.h new file mode 100644 index 00000000000..69dab14801d --- /dev/null +++ b/tools/sdk/esp32s2/include/hal/include/hal/lcd_types.h @@ -0,0 +1,42 @@ +// Copyright 2021 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 + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief LCD clock source + * @note User should select the clock source based on the real requirement: + * ╔═════════════════════╦══════════════════════════╦════════════════════════════╗ + * ║ LCD clock source ║ Features ║ Power Management ║ + * ╠═════════════════════╬══════════════════════════╬════════════════════════════╣ + * ║ LCD_CLK_SRC_PLL160M ║ High resolution, fixed ║ ESP_PM_APB_FREQ_MAX lock ║ + * ╠═════════════════════╬══════════════════════════╬════════════════════════════╣ + * ║ LCD_CLK_SRC_APLL ║ Configurable resolution ║ ESP_PM_NO_LIGHT_SLEEP lock ║ + * ╠═════════════════════╬══════════════════════════╬════════════════════════════╣ + * ║ LCD_CLK_SRC_XTAL ║ Medium resolution, fixed ║ No PM lock ║ + * ╚═════════════════════╩══════════════════════════╩════════════════════════════╝ + */ +typedef enum { + LCD_CLK_SRC_PLL160M, /*!< Select PLL160M as the source clock */ + LCD_CLK_SRC_APLL, /*!< Select APLL as the source clock */ + LCD_CLK_SRC_XTAL, /*!< Select XTAL as the source clock */ +} lcd_clock_source_t; + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32s2/include/hal/include/hal/mcpwm_types.h b/tools/sdk/esp32s2/include/hal/include/hal/mcpwm_types.h index 77f9c80c12b..b9c37315bc4 100644 --- a/tools/sdk/esp32s2/include/hal/include/hal/mcpwm_types.h +++ b/tools/sdk/esp32s2/include/hal/include/hal/mcpwm_types.h @@ -37,7 +37,7 @@ typedef enum { MCPWM_TIMER_START_NO_STOP, /*!< MCPWM timer starts couting */ MCPWM_TIMER_START_STOP_AT_ZERO, /*!< MCPWM timer starts counting and stops when couting to zero */ MCPWM_TIMER_START_STOP_AT_PEAK, /*!< MCPWM timer starts counting and stops when counting to peak */ -} mcpwm_timer_operate_cmd_t; +} mcpwm_timer_execute_cmd_t; typedef enum { MCPWM_GEN_ACTION_KEEP, /*!< Generator action: Keep the same level */ @@ -47,6 +47,6 @@ typedef enum { } mcpwm_generator_action_t; typedef enum { - MCPWM_FAULT_REACTION_CBC, /*!< Reaction on fault signal: recover cycle by cycle */ - MCPWM_FAULT_REACTION_OST, /*!< Reaction on fault signal: one shot trip */ -} mcpwm_fault_reaction_t; + MCPWM_TRIP_TYPE_CBC, /*!< CBC trip type, shut down the operator cycle by cycle*/ + MCPWM_TRIP_TYPE_OST, /*!< OST trip type, shut down the operator in one shot */ +} mcpwm_trip_type_t; diff --git a/tools/sdk/esp32s2/include/hal/include/hal/memprot_types.h b/tools/sdk/esp32s2/include/hal/include/hal/memprot_types.h new file mode 100644 index 00000000000..42231f43eaf --- /dev/null +++ b/tools/sdk/esp32s2/include/hal/include/hal/memprot_types.h @@ -0,0 +1,35 @@ +// Copyright 2015-2021 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 + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Memprot LL error codes + * + */ +typedef enum { + MEMP_LL_OK = 0, + MEMP_LL_FAIL = 1, + MEMP_LL_ERR_SPLIT_ADDR_INVALID = 2, + MEMP_LL_ERR_SPLIT_ADDR_UNALIGNED = 3, + MEMP_LL_ERR_UNI_BLOCK_INVALID = 4 +} memprot_ll_err_t; + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32s2/include/hal/include/hal/pcnt_hal.h b/tools/sdk/esp32s2/include/hal/include/hal/pcnt_hal.h index 8d2253e46e3..3d10c8d8c68 100644 --- a/tools/sdk/esp32s2/include/hal/include/hal/pcnt_hal.h +++ b/tools/sdk/esp32s2/include/hal/include/hal/pcnt_hal.h @@ -23,10 +23,7 @@ #pragma once -#include -#include "soc/pcnt_periph.h" -#include "hal/pcnt_types.h" -#include "hal/pcnt_ll.h" +#include "soc/pcnt_struct.h" #ifdef __cplusplus extern "C" { @@ -35,188 +32,18 @@ extern "C" { /** * Context that should be maintained by both the driver and the HAL */ - typedef struct { - pcnt_dev_t *dev; + pcnt_dev_t *dev; /*!< PCNT peripheral register base address */ } pcnt_hal_context_t; /** - * @brief Set PCNT counter mode - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - * @param channel PCNT channel number - * @param pos_mode Counter mode when detecting positive edge - * @param neg_mode Counter mode when detecting negative edge - * @param hctrl_mode Counter mode when control signal is high level - * @param lctrl_mode Counter mode when control signal is low level - */ -#define pcnt_hal_set_mode(hal, unit, channel, pos_mode, neg_mode, hctrl_mode, lctrl_mode) pcnt_ll_set_mode((hal)->dev, unit, channel, pos_mode, neg_mode, hctrl_mode, lctrl_mode) - -/** - * @brief Get pulse counter value - * - * @param hal Context of the HAL layer - * @param unit Pulse Counter unit number - * @param count Pointer to accept counter value - */ -#define pcnt_hal_get_counter_value(hal, unit, count) pcnt_ll_get_counter_value((hal)->dev, unit, count) - -/** - * @brief Pause PCNT counter of PCNT unit - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - */ -#define pcnt_hal_counter_pause(hal, unit) pcnt_ll_counter_pause((hal)->dev, unit) - -/** - * @brief Resume counting for PCNT counter - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number, select from unit_t - */ -#define pcnt_hal_counter_resume(hal, unit) pcnt_ll_counter_resume((hal)->dev, unit) - -/** - * @brief Clear and reset PCNT counter value to zero - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number, select from unit_t - */ -#define pcnt_hal_counter_clear(hal, unit) pcnt_ll_counter_clear((hal)->dev, unit) - -/** - * @brief Enable PCNT interrupt for PCNT unit - * @note - * Each Pulse counter unit has five watch point events that share the same interrupt. - * Configure events with pcnt_event_enable() and pcnt_event_disable() - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - */ -#define pcnt_hal_intr_enable(hal, unit) pcnt_ll_intr_enable((hal)->dev, unit) - -/** - * @brief Disable PCNT interrupt for PCNT unit - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - */ -#define pcnt_hal_intr_disable(hal, unit) pcnt_ll_intr_disable((hal)->dev, unit) - -/** - * @brief Get PCNT interrupt status - * - * @param hal Context of the HAL layer - * @param mask The interrupt status mask to be cleared. Pointer to accept value interrupt status mask. - */ -#define pcnt_hal_get_intr_status(hal, mask) pcnt_ll_get_intr_status((hal)->dev, mask) - -/** - * @brief Clear PCNT interrupt status - * - * @param hal Context of the HAL layer - * @param mask The interrupt status mask to be cleared. - */ -#define pcnt_hal_clear_intr_status(hal, mask) pcnt_ll_clear_intr_status((hal)->dev, mask) - -/** - * @brief Enable PCNT event of PCNT unit - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - * @param evt_type Watch point event type. - * All enabled events share the same interrupt (one interrupt per pulse counter unit). - */ -#define pcnt_hal_event_enable(hal, unit, evt_type) pcnt_ll_event_enable((hal)->dev, unit, evt_type) - -/** - * @brief Disable PCNT event of PCNT unit - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - * @param evt_type Watch point event type. - * All enabled events share the same interrupt (one interrupt per pulse counter unit). - */ -#define pcnt_hal_event_disable(hal, unit, evt_type) pcnt_ll_event_disable((hal)->dev, unit, evt_type) - -/** - * @brief Set PCNT event value of PCNT unit - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - * @param evt_type Watch point event type. - * All enabled events share the same interrupt (one interrupt per pulse counter unit). - * - * @param value Counter value for PCNT event - */ -#define pcnt_hal_set_event_value(hal, unit, evt_type, value) pcnt_ll_set_event_value((hal)->dev, unit, evt_type, value) - -/** - * @brief Get PCNT event value of PCNT unit - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - * @param evt_type Watch point event type. - * All enabled events share the same interrupt (one interrupt per pulse counter unit). - * @param value Pointer to accept counter value for PCNT event - */ -#define pcnt_hal_get_event_value(hal, unit, evt_type, value) pcnt_ll_get_event_value((hal)->dev, unit, evt_type, value) - -/** - * @brief Get PCNT event status - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - * @return event status word - */ -#define pcnt_hal_get_event_status(hal, unit) pcnt_ll_get_event_status((hal)->dev, unit) - -/** - * @brief Set PCNT filter value - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - * @param filter_val PCNT signal filter value, counter in APB_CLK cycles. - * Any pulses lasting shorter than this will be ignored when the filter is enabled. - * @note - * filter_val is a 10-bit value, so the maximum filter_val should be limited to 1023. - */ -#define pcnt_hal_set_filter_value(hal, unit, filter_val) pcnt_ll_set_filter_value((hal)->dev, unit, filter_val) - -/** - * @brief Get PCNT filter value - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - * @param filter_val Pointer to accept PCNT filter value. - */ -#define pcnt_hal_get_filter_value(hal, unit, filter_val) pcnt_ll_get_filter_value((hal)->dev, unit, filter_val) - -/** - * @brief Enable PCNT input filter - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - */ -#define pcnt_hal_filter_enable(hal, unit) pcnt_ll_filter_enable((hal)->dev, unit) - -/** - * @brief Disable PCNT input filter - * - * @param hal Context of the HAL layer - * @param unit PCNT unit number - */ -#define pcnt_hal_filter_disable(hal, unit) pcnt_ll_filter_disable((hal)->dev, unit) - -/** - * @brief Init the PCNT hal and set the PCNT to the default configuration. This function should be called first before other hal layer function is called + * @brief Init the PCNT hal and set the PCNT to the default configuration. + * @note This function should be called first before other hal layer function is called. * * @param hal Context of the HAL layer - * @param pcnt_num The uart port number, the max port number is (PCNT_NUM_MAX -1) + * @param group_id PCNT group ID */ -void pcnt_hal_init(pcnt_hal_context_t *hal, int pcnt_num); +void pcnt_hal_init(pcnt_hal_context_t *hal, int group_id); #ifdef __cplusplus } diff --git a/tools/sdk/esp32s2/include/hal/include/hal/pcnt_types.h b/tools/sdk/esp32s2/include/hal/include/hal/pcnt_types.h index 6f09177b53a..0696e756cc9 100644 --- a/tools/sdk/esp32s2/include/hal/include/hal/pcnt_types.h +++ b/tools/sdk/esp32s2/include/hal/include/hal/pcnt_types.h @@ -1,4 +1,4 @@ -// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD +// Copyright 2015-2021 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. @@ -18,93 +18,36 @@ extern "C" { #endif -#include "soc/soc_caps.h" - -#define PCNT_PIN_NOT_USED (-1) /*!< When selected for a pin, this pin will not be used */ - -/** - * @brief PCNT port number, the max port number is (PCNT_PORT_MAX - 1). - */ -typedef enum { - PCNT_PORT_0 = 0, /*!< PCNT port 0 */ - PCNT_PORT_MAX, /*!< PCNT port max */ -} pcnt_port_t; - -/** - * @brief Selection of all available PCNT units - */ -typedef enum { - PCNT_UNIT_0 = 0, /*!< PCNT unit 0 */ - PCNT_UNIT_1 = 1, /*!< PCNT unit 1 */ - PCNT_UNIT_2 = 2, /*!< PCNT unit 2 */ - PCNT_UNIT_3 = 3, /*!< PCNT unit 3 */ -#if SOC_PCNT_UNIT_NUM > 4 - PCNT_UNIT_4 = 4, /*!< PCNT unit 4 */ - PCNT_UNIT_5 = 5, /*!< PCNT unit 5 */ - PCNT_UNIT_6 = 6, /*!< PCNT unit 6 */ - PCNT_UNIT_7 = 7, /*!< PCNT unit 7 */ -#endif - PCNT_UNIT_MAX, -} pcnt_unit_t; - /** - * @brief Selection of available modes that determine the counter's action depending on the state of the control signal's input GPIO - * @note Configuration covers two actions, one for high, and one for low level on the control input + * @brief PCNT channel action on control level + * */ typedef enum { - PCNT_MODE_KEEP = 0, /*!< Control mode: won't change counter mode*/ - PCNT_MODE_REVERSE = 1, /*!< Control mode: invert counter mode(increase -> decrease, decrease -> increase) */ - PCNT_MODE_DISABLE = 2, /*!< Control mode: Inhibit counter(counter value will not change in this condition) */ - PCNT_MODE_MAX -} pcnt_ctrl_mode_t; + PCNT_CHANNEL_LEVEL_ACTION_KEEP, /*!< Keep current count mode */ + PCNT_CHANNEL_LEVEL_ACTION_INVERSE, /*!< Invert current count mode (increase -> decrease, decrease -> increase) */ + PCNT_CHANNEL_LEVEL_ACTION_HOLD, /*!< Hold current count value */ +} pcnt_channel_level_action_t; /** - * @brief Selection of available modes that determine the counter's action on the edge of the pulse signal's input GPIO - * @note Configuration covers two actions, one for positive, and one for negative edge on the pulse input + * @brief PCNT channel action on signal edge + * */ typedef enum { - PCNT_COUNT_DIS = 0, /*!< Counter mode: Inhibit counter(counter value will not change in this condition) */ - PCNT_COUNT_INC = 1, /*!< Counter mode: Increase counter value */ - PCNT_COUNT_DEC = 2, /*!< Counter mode: Decrease counter value */ - PCNT_COUNT_MAX -} pcnt_count_mode_t; + PCNT_CHANNEL_EDGE_ACTION_HOLD, /*!< Hold current count value */ + PCNT_CHANNEL_EDGE_ACTION_INCREASE, /*!< Increase count value */ + PCNT_CHANNEL_EDGE_ACTION_DECREASE, /*!< Decrease count value */ +} pcnt_channel_edge_action_t; /** - * @brief Selection of channels available for a single PCNT unit + * @brief PCNT unit counter value's sign + * */ typedef enum { - PCNT_CHANNEL_0 = 0x00, /*!< PCNT channel 0 */ - PCNT_CHANNEL_1 = 0x01, /*!< PCNT channel 1 */ - PCNT_CHANNEL_MAX, -} pcnt_channel_t; - -/** - * @brief Selection of counter's events the may trigger an interrupt - */ -typedef enum { - PCNT_EVT_THRES_1 = BIT(2), /*!< PCNT watch point event: threshold1 value event */ - PCNT_EVT_THRES_0 = BIT(3), /*!< PCNT watch point event: threshold0 value event */ - PCNT_EVT_L_LIM = BIT(4), /*!< PCNT watch point event: Minimum counter value */ - PCNT_EVT_H_LIM = BIT(5), /*!< PCNT watch point event: Maximum counter value */ - PCNT_EVT_ZERO = BIT(6), /*!< PCNT watch point event: counter value zero event */ - PCNT_EVT_MAX -} pcnt_evt_type_t; - -/** - * @brief Pulse Counter configuration for a single channel - */ -typedef struct { - int pulse_gpio_num; /*!< Pulse input GPIO number, if you want to use GPIO16, enter pulse_gpio_num = 16, a negative value will be ignored */ - int ctrl_gpio_num; /*!< Control signal input GPIO number, a negative value will be ignored */ - pcnt_ctrl_mode_t lctrl_mode; /*!< PCNT low control mode */ - pcnt_ctrl_mode_t hctrl_mode; /*!< PCNT high control mode */ - pcnt_count_mode_t pos_mode; /*!< PCNT positive edge count mode */ - pcnt_count_mode_t neg_mode; /*!< PCNT negative edge count mode */ - int16_t counter_h_lim; /*!< Maximum counter value */ - int16_t counter_l_lim; /*!< Minimum counter value */ - pcnt_unit_t unit; /*!< PCNT unit number */ - pcnt_channel_t channel; /*!< the PCNT channel */ -} pcnt_config_t; + PCNT_UNIT_COUNT_SIGN_ZERO_POS, /*!< positive value to zero */ + PCNT_UNIT_COUNT_SIGN_ZERO_NEG, /*!< negative value to zero */ + PCNT_UNIT_COUNT_SIGN_NEG, /*!< counter value negative */ + PCNT_UNIT_COUNT_SIGN_POS, /*!< counter value positive */ +} pcnt_unit_count_sign_t; #ifdef __cplusplus } diff --git a/tools/sdk/esp32s2/include/hal/include/hal/rtc_hal.h b/tools/sdk/esp32s2/include/hal/include/hal/rtc_hal.h index 8d74f4c4cd8..90f965ed58c 100644 --- a/tools/sdk/esp32s2/include/hal/include/hal/rtc_hal.h +++ b/tools/sdk/esp32s2/include/hal/include/hal/rtc_hal.h @@ -14,12 +14,36 @@ #pragma once +#include "soc/soc_caps.h" #include "hal/gpio_types.h" #include "hal/rtc_cntl_ll.h" #if !CONFIG_IDF_TARGET_ESP32C3 && !CONFIG_IDF_TARGET_ESP32H2 #include "hal/rtc_io_ll.h" #endif +typedef struct rtc_cntl_sleep_retent { +#if SOC_PM_SUPPORT_CPU_PD + void *cpu_pd_mem; /* Internal ram address for cpu retention */ +#endif // SOC_PM_SUPPORT_CPU_PD +#if SOC_PM_SUPPORT_TAGMEM_PD + struct { + void *link_addr; /* Internal ram address for tagmem retention */ + struct { + uint32_t start_point: 8, /* the row of start for i-cache tag memory */ + vld_size: 8, /* valid size of i-cache tag memory, unit: 4 i-cache tagmem blocks */ + size: 8, /* i-cache tag memory size, unit: 4 i-cache tagmem blocks */ + enable: 1; /* enable or disable i-cache tagmem retention */ + } icache; + struct { + uint32_t start_point: 9, /* the row of start for d-cache tag memory */ + vld_size: 9, /* valid size of d-cache tag memory, unit: 4 d-cache tagmem blocks */ + size: 9, /* d-cache tag memory size, unit: 4 d-cache tagmem blocks */ + enable: 1; /* enable or disable d-cache tagmem retention */ + } dcache; + } tagmem; +#endif // SOC_PM_SUPPORT_TAGMEM_PD +} rtc_cntl_sleep_retent_t; + #define RTC_HAL_DMA_LINK_NODE_SIZE (16) #if SOC_PM_SUPPORT_EXT_WAKEUP @@ -46,9 +70,21 @@ void * rtc_cntl_hal_dma_link_init(void *elem, void *buff, int size, void *next); +#if SOC_PM_SUPPORT_CPU_PD + void rtc_cntl_hal_enable_cpu_retention(void *addr); -#define rtc_cntl_hal_disable_cpu_retention() rtc_cntl_ll_disable_cpu_retention() +void rtc_cntl_hal_disable_cpu_retention(void *addr); + +#endif + +#if SOC_PM_SUPPORT_TAGMEM_PD + +void rtc_cntl_hal_enable_tagmem_retention(void *addr); + +void rtc_cntl_hal_disable_tagmem_retention(void *addr); + +#endif /* * Enable wakeup from ULP coprocessor. diff --git a/tools/sdk/esp32s2/include/hal/include/hal/spi_flash_hal.h b/tools/sdk/esp32s2/include/hal/include/hal/spi_flash_hal.h index dbbb5ff53b5..ae37016fa2d 100644 --- a/tools/sdk/esp32s2/include/hal/include/hal/spi_flash_hal.h +++ b/tools/sdk/esp32s2/include/hal/include/hal/spi_flash_hal.h @@ -51,20 +51,41 @@ typedef struct { uint32_t flags; ///< Flags for configurations with one set of driver code. (e.g. QPI mode, auto-suspend mode, 64-bit address mode, etc.) #define SPI_FLASH_HOST_CONTEXT_FLAG_AUTO_SUSPEND BIT(0) ///< When the auto-suspend is setup in configuration. #define SPI_FLASH_HOST_CONTEXT_FLAG_AUTO_RESUME BIT(1) ///< Setup auto-resume feature. +#define SPI_FLASH_HOST_CONTEXT_FLAG_OCTAL_MODE BIT(2) ///< Flash works under octal spi mode. spi_flash_sus_cmd_conf sus_cfg; ///< To store suspend command/mask information. + uint32_t slicer_flags; /// Slicer flags for configuring how to slice data correctly while reading or writing. +#define SPI_FLASH_HOST_CONTEXT_SLICER_FLAG_DTR BIT(0) ///< Slice data according to DTR mode, the address and length must be even (A0=0). } spi_flash_hal_context_t; -_Static_assert(sizeof(spi_flash_hal_context_t) == 36, "size of spi_flash_hal_context_t incorrect. Please check data compatibility with the ROM"); +_Static_assert(sizeof(spi_flash_hal_context_t) == 40, "size of spi_flash_hal_context_t incorrect. Please check data compatibility with the ROM"); + +/// This struct provide MSPI Flash necessary timing related config, should be consistent with that in union in `spi_flash_hal_config_t`. +typedef struct { + uint32_t extra_dummy; + uint32_t cs_hold; + uint8_t cs_setup; + spi_flash_ll_clock_reg_t clock_config; +} spi_flash_hal_timing_config_t; /// Configuration structure for the SPI driver. typedef struct { - spi_host_device_t host_id; ///< SPI peripheral ID. - int cs_num; ///< Which cs pin is used, 0-(SOC_SPI_PERIPH_CS_NUM-1). + union { + struct { + uint32_t extra_dummy; ///< extra dummy for timing compensation. + uint32_t cs_hold; ///< CS hold time config used by the host + uint8_t cs_setup; ///< (cycles-1) of prepare phase by spi clock + spi_flash_ll_clock_reg_t clock_config; ///< (optional) Clock configuration for Octal flash. + }; + spi_flash_hal_timing_config_t timing_reg; ///< Reconfigure timing tuning regs. + }; bool iomux; ///< Whether the IOMUX is used, used for timing compensation. int input_delay_ns; ///< Input delay on the MISO pin after the launch clock, used for timing compensation. esp_flash_speed_t speed;///< SPI flash clock speed to work at. - uint32_t cs_hold; ///< CS hold time config used by the host - uint8_t cs_setup; ///< (cycles-1) of prepare phase by spi clock + spi_host_device_t host_id; ///< SPI peripheral ID. + int cs_num; ///< Which cs pin is used, 0-(SOC_SPI_PERIPH_CS_NUM-1). bool auto_sus_en; ///< Auto suspend feature enable bit 1: enable, 0: disable. + bool octal_mode_en; ///< Octal spi flash mode enable bit 1: enable, 0: disable. + bool using_timing_tuning; ///< System exist SPI0/1 timing tuning, using value from system directely if set to 1. + esp_flash_io_mode_t default_io_mode; ///< Default flash io mode. } spi_flash_hal_config_t; /** diff --git a/tools/sdk/esp32s2/include/hal/include/hal/spi_flash_types.h b/tools/sdk/esp32s2/include/hal/include/hal/spi_flash_types.h index 0cc605595f2..c9d5035e60e 100644 --- a/tools/sdk/esp32s2/include/hal/include/hal/spi_flash_types.h +++ b/tools/sdk/esp32s2/include/hal/include/hal/spi_flash_types.h @@ -37,6 +37,7 @@ typedef struct { #define SPI_FLASH_TRANS_FLAG_BYTE_SWAP BIT(2) ///< Used for DTR mode, to swap the bytes of a pair of rising/falling edge uint16_t command; ///< Command to send uint8_t dummy_bitlen; ///< Basic dummy bits to use + uint32_t io_mode; ///< Flash working mode when `SPI_FLASH_IGNORE_BASEIO` is specified. } spi_flash_trans_t; /** @@ -54,6 +55,7 @@ typedef enum { ESP_FLASH_26MHZ, ///< The flash runs under 26MHz ESP_FLASH_40MHZ, ///< The flash runs under 40MHz ESP_FLASH_80MHZ, ///< The flash runs under 80MHz + ESP_FLASH_120MHZ, ///< The flash runs under 120MHz, 120MHZ can only be used by main flash after timing tuning in system. Do not use this directely in any API. ESP_FLASH_SPEED_MAX, ///< The maximum frequency supported by the host is ``ESP_FLASH_SPEED_MAX-1``. } esp_flash_speed_t; @@ -71,7 +73,9 @@ typedef enum { SPI_FLASH_DIO, ///< Both address & data transferred using dual I/O SPI_FLASH_QOUT, ///< Data read using quad I/O SPI_FLASH_QIO, ///< Both address & data transferred using quad I/O - +#define SPI_FLASH_OPI_FLAG 16 ///< A flag for flash work in opi mode, the io mode below are opi, above are SPI/QSPI mode. DO NOT use this value in any API. + SPI_FLASH_OPI_STR = SPI_FLASH_OPI_FLAG,///< Only support on OPI flash, flash read and write under STR mode + SPI_FLASH_OPI_DTR,///< Only support on OPI flash, flash read and write under DTR mode SPI_FLASH_READ_MODE_MAX, ///< The fastest io mode supported by the host is ``ESP_FLASH_READ_MODE_MAX-1``. } esp_flash_io_mode_t; diff --git a/tools/sdk/esp32s2/include/hal/include/hal/spi_hal.h b/tools/sdk/esp32s2/include/hal/include/hal/spi_hal.h index b37c7c92504..5be7db32ea9 100644 --- a/tools/sdk/esp32s2/include/hal/include/hal/spi_hal.h +++ b/tools/sdk/esp32s2/include/hal/include/hal/spi_hal.h @@ -38,6 +38,7 @@ #include #include "soc/lldesc.h" #include "soc/soc_caps.h" +#include "hal/spi_types.h" /** * Input parameters to the ``spi_hal_cal_clock_conf`` to calculate the timing configuration @@ -100,7 +101,7 @@ typedef struct { uint64_t addr; ///< Address value to be sent uint8_t *send_buffer; ///< Data to be sent uint8_t *rcv_buffer; ///< Buffer to hold the receive data. - spi_ll_io_mode_t io_mode; ///< IO mode of the master + spi_line_mode_t line_mode; ///< SPI line mode of this transaction int cs_keep_active; ///< Keep CS active after transaction } spi_hal_trans_config_t; diff --git a/tools/sdk/esp32s2/include/hal/include/hal/spi_types.h b/tools/sdk/esp32s2/include/hal/include/hal/spi_types.h index 400b922a5c6..169069c5c62 100644 --- a/tools/sdk/esp32s2/include/hal/include/hal/spi_types.h +++ b/tools/sdk/esp32s2/include/hal/include/hal/spi_types.h @@ -14,8 +14,9 @@ #pragma once +#include #include "esp_attr.h" -#include +#include "esp_bit_defs.h" #include "soc/soc_caps.h" #include "sdkconfig.h" @@ -45,6 +46,15 @@ typedef enum { } spi_event_t; FLAG_ATTR(spi_event_t) +/** + * @brief Line mode of SPI transaction phases: CMD, ADDR, DOUT/DIN. + */ +typedef struct { + uint8_t cmd_lines; ///< The line width of command phase, e.g. 2-line-cmd-phase. + uint8_t addr_lines; ///< The line width of address phase, e.g. 1-line-addr-phase. + uint8_t data_lines; ///< The line width of data phase, e.g. 4-line-data-phase. +} spi_line_mode_t; + /** @cond */ //Doxy command to hide preprocessor definitions from docs */ diff --git a/tools/sdk/esp32s2/include/hal/include/hal/timer_hal.h b/tools/sdk/esp32s2/include/hal/include/hal/timer_hal.h index f8c91739d91..cb3d5e0671d 100644 --- a/tools/sdk/esp32s2/include/hal/include/hal/timer_hal.h +++ b/tools/sdk/esp32s2/include/hal/include/hal/timer_hal.h @@ -59,6 +59,15 @@ void timer_hal_init(timer_hal_context_t *hal, timer_group_t group_num, timer_idx */ void timer_hal_get_status_reg_mask_bit(timer_hal_context_t *hal, uint32_t *status_reg, uint32_t *mask_bit); +/** + * @brief Reset timer peripheral + * + * @param hal Context of the HAL layer + * + * @return None + */ +void timer_hal_reset_periph(timer_hal_context_t *hal); + /** * @brief Set timer clock prescale value * diff --git a/tools/sdk/esp32s2/include/hal/include/hal/uhci_types.h b/tools/sdk/esp32s2/include/hal/include/hal/uhci_types.h new file mode 100644 index 00000000000..7122e2a41a9 --- /dev/null +++ b/tools/sdk/esp32s2/include/hal/include/hal/uhci_types.h @@ -0,0 +1,54 @@ +// Copyright 2015-2019 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. + + + +// Though the UHCI driver hasn't been published, some types are defined here +// for users to develop over the HAL. See example: controller_hci_uart_esp32c3 + +#pragma once + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief UHCI escape sequence + */ +typedef struct { + uint8_t seper_chr; /*!< escape sequence character */ + uint8_t sub_chr1; /*!< escape sequence sub-character 1 */ + uint8_t sub_chr2; /*!< escape sequence sub-character 2 */ + bool sub_chr_en; /*!< enable use of sub-chaacter of escape sequence */ +} uhci_seper_chr_t; + +/** + * @brief UHCI software flow control + */ +typedef struct { + uint8_t xon_chr; /*!< character for XON */ + uint8_t xon_sub1; /*!< sub-character 1 for XON */ + uint8_t xon_sub2; /*!< sub-character 2 for XON */ + uint8_t xoff_chr; /*!< character 2 for XOFF */ + uint8_t xoff_sub1; /*!< sub-character 1 for XOFF */ + uint8_t xoff_sub2; /*!< sub-character 2 for XOFF */ + uint8_t flow_en; /*!< enable use of software flow control */ +} uhci_swflow_ctrl_sub_chr_t; + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32s2/include/hal/include/hal/usb_phy_hal.h b/tools/sdk/esp32s2/include/hal/include/hal/usb_phy_hal.h new file mode 100644 index 00000000000..fe77eb87446 --- /dev/null +++ b/tools/sdk/esp32s2/include/hal/include/hal/usb_phy_hal.h @@ -0,0 +1,81 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "usb_types_private.h" +#include "usb_phy_types.h" +#include "soc/soc_caps.h" +#include "soc/usb_wrap_struct.h" +#if SOC_USB_SERIAL_JTAG_SUPPORTED +#include "soc/usb_serial_jtag_struct.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Context that should be maintained by both the driver and the HAL + */ +typedef struct { + usb_wrap_dev_t *wrap_dev; /**< Pointer to base address of USB Wrapper registers */ +#if SOC_USB_SERIAL_JTAG_SUPPORTED + usb_serial_jtag_dev_t *jtag_dev; /**< Pointer to base address of USB Serial JTAG registers */ +#endif +} usb_phy_hal_context_t; + +/** + * @brief Init the USB PHY hal. This function should be called first before other hal layer function is called + * + * @param hal Context of the HAL layer + */ +void usb_phy_hal_init(usb_phy_hal_context_t *hal); + +/** + * @brief Configure internal/external PHY for USB_OTG + * + * @param hal Context of the HAL layer + * @param phy_target USB PHY target + */ +void usb_phy_hal_otg_conf(usb_phy_hal_context_t *hal, usb_phy_target_t phy_target); + +#if SOC_USB_SERIAL_JTAG_SUPPORTED +/** + * @brief Configure internal/external PHY for USB_Serial_JTAG + * + * @param hal Context of the HAL layer + * @param phy_target USB PHY target + */ +void usb_phy_hal_jtag_conf(usb_phy_hal_context_t *hal, usb_phy_target_t phy_target); +#endif + +/** + * @brief Configure pullup/pulldown loads for the D+/D- as a host + * + * @param hal Context of the HAL layer + */ +void usb_phy_hal_int_load_conf_host(usb_phy_hal_context_t *hal); + +/** + * @brief Configure pullup/pulldown loads for the D+/D- as a device + * + * @param hal Context of the HAL layer + * @param speed USB speed + */ +void usb_phy_hal_int_load_conf_dev(usb_phy_hal_context_t *hal, usb_priv_speed_t speed); + +/** + * @brief Enable/Disable test mode for internal PHY to mimick host-device disconnection + * + * @param hal Context of the HAL layer + * @param disconn Whether to disconnect + */ +void usb_phy_hal_int_mimick_disconn(usb_phy_hal_context_t *hal, bool disconn); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32s2/include/hal/include/hal/usb_phy_types.h b/tools/sdk/esp32s2/include/hal/include/hal/usb_phy_types.h new file mode 100644 index 00000000000..1f5ac431efa --- /dev/null +++ b/tools/sdk/esp32s2/include/hal/include/hal/usb_phy_types.h @@ -0,0 +1,63 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* +Note: This header file contains USB2.0 related types and macros that can be used by code specific to the DWC_OTG +controller (i.e., the HW specific layers of the USB host stack). Thus, this header is only meant to be used below (and +including) the HAL layer. For types and macros that are HW implementation agnostic (i.e., HCD layer and above), add them +to the "usb/usb_types_ch9.h" header instead. +*/ + +#pragma once + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** + * @brief USB PHY target + */ +typedef enum { + USB_PHY_TARGET_INT, /**< USB target is internal PHY */ + USB_PHY_TARGET_EXT, /**< USB target is external PHY */ + USB_PHY_TARGET_MAX, +} usb_phy_target_t; + +/** + * @brief USB PHY source + */ +typedef enum { + USB_PHY_CTRL_OTG, /**< PHY controller is USB OTG */ +#if SOC_USB_SERIAL_JTAG_SUPPORTED + USB_PHY_CTRL_SERIAL_JTAG, /**< PHY controller is USB Serial JTAG */ +#endif + USB_PHY_CTRL_MAX, +} usb_phy_controller_t; + +/** + * @brief USB OTG mode + */ +typedef enum { + USB_PHY_MODE_DEFAULT, /**< USB OTG default mode */ + USB_OTG_MODE_HOST, /**< USB OTG host mode */ + USB_OTG_MODE_DEVICE, /**< USB OTG device mode */ + USB_OTG_MODE_MAX, +} usb_otg_mode_t; + +/** + * @brief USB speed + */ +typedef enum { + USB_PHY_SPEED_UNDEFINED, + USB_PHY_SPEED_LOW, /**< USB Low Speed (1.5 Mbit/s) */ + USB_PHY_SPEED_FULL, /**< USB Full Speed (12 Mbit/s) */ + USB_PHY_SPEED_MAX, +} usb_phy_speed_t; + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32s2/include/hal/include/hal/usb_types_private.h b/tools/sdk/esp32s2/include/hal/include/hal/usb_types_private.h index 868fdee5891..5cce6b66af4 100644 --- a/tools/sdk/esp32s2/include/hal/include/hal/usb_types_private.h +++ b/tools/sdk/esp32s2/include/hal/include/hal/usb_types_private.h @@ -16,7 +16,7 @@ Note: This header file contains USB2.0 related types and macros that can be used by code specific to the DWC_OTG controller (i.e., the HW specific layers of the USB host stack). Thus, this header is only meant to be used below (and including) the HAL layer. For types and macros that are HW implementation agnostic (i.e., HCD layer and above), add them -to the "usb.h" header instead. +to the "usb/usb_types_ch9.h" header instead. */ #pragma once diff --git a/tools/sdk/esp32s2/include/hal/include/hal/usbh_hal.h b/tools/sdk/esp32s2/include/hal/include/hal/usbh_hal.h index 1ff721c373b..b315f6c0b14 100644 --- a/tools/sdk/esp32s2/include/hal/include/hal/usbh_hal.h +++ b/tools/sdk/esp32s2/include/hal/include/hal/usbh_hal.h @@ -151,7 +151,7 @@ typedef struct { //Channel control, status, and information union { struct { - uint32_t active: 1; /**< The channel is enabled */ + uint32_t active: 1; /**< Debugging bit to indicate whether channel is enabled */ uint32_t halt_requested: 1; /**< A halt has been requested */ uint32_t error_pending: 1; /**< The channel is waiting for the error to be handled */ uint32_t reserved: 1; @@ -811,6 +811,8 @@ usbh_hal_chan_t *usbh_hal_get_chan_pending_intr(usbh_hal_context_t *hal); * - Returns the corresponding event for that channel * * @param chan_obj Channel object + * @note If the host port has an error (e.g., a sudden disconnect or an port error), any active channels will not + * receive an interrupt. Each active channel must be manually halted. * @return usbh_hal_chan_event_t Channel event */ usbh_hal_chan_event_t usbh_hal_chan_decode_intr(usbh_hal_chan_t *chan_obj); diff --git a/tools/sdk/esp32s2/include/hal/include/hal/xt_wdt_hal.h b/tools/sdk/esp32s2/include/hal/include/hal/xt_wdt_hal.h new file mode 100644 index 00000000000..bd08f2a989f --- /dev/null +++ b/tools/sdk/esp32s2/include/hal/include/hal/xt_wdt_hal.h @@ -0,0 +1,61 @@ +/* + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include +#include + +#include "hal/xt_wdt_ll.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + rtc_cntl_dev_t *dev; /* Pointer to the RTC register struct */ +} xt_wdt_hal_context_t; /* HAL context struct */ + +typedef struct { + uint32_t timeout; /* Watchdog timer timeout in RTC_CLK cycles*/ +} xt_wdt_hal_config_t; /* HAL config parameter struct */ + +/* ---------------------------- Init and Config ----------------------------- */ + +/** + * @brief Initialize the WDTs associated HAL context + * + * Prepares the register for enabling the WDT and sets the timeout value + * + * @param hal Pointer to the HAL layer context + * @param config Pointer to config struct + */ +void xt_wdt_hal_init(xt_wdt_hal_context_t *hal, const xt_wdt_hal_config_t *config); + + +/** + * @brief Enable or disable the WDT + * + * @param hal Pointer to the HAL layer context + * @param enable true for enable WDT, false for disable + */ +void xt_wdt_hal_enable(xt_wdt_hal_context_t *hal, bool enable); + +/** + * @brief Enable the automatic RTC backup clock with the given frequency + * + * Calculates and sets the necessary hardware parameters to meet the desired + * backup clock frequency + * + * @param hal Pointer to the HAL layer context + * @param rtc_clk_frequency_khz desired frequency for the backup clock + * @return uint32_t the calculated clock factor value + */ +uint32_t xt_wdt_hal_enable_backup_clk(xt_wdt_hal_context_t *hal, uint32_t rtc_clk_frequency_khz); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32s2/include/hal/platform_port/include/hal/log.h b/tools/sdk/esp32s2/include/hal/platform_port/include/hal/log.h index 28bde429d49..6d5cbda3817 100644 --- a/tools/sdk/esp32s2/include/hal/platform_port/include/hal/log.h +++ b/tools/sdk/esp32s2/include/hal/platform_port/include/hal/log.h @@ -21,3 +21,9 @@ #define HAL_LOGI(...) ESP_LOGI(__VA_ARGS__) #define HAL_LOGD(...) ESP_LOGD(__VA_ARGS__) #define HAL_LOGV(...) ESP_LOGV(__VA_ARGS__) + +#define HAL_EARLY_LOGE(...) ESP_EARLY_LOGE(__VA_ARGS__) +#define HAL_EARLY_LOGW(...) ESP_EARLY_LOGW(__VA_ARGS__) +#define HAL_EARLY_LOGI(...) ESP_EARLY_LOGI(__VA_ARGS__) +#define HAL_EARLY_LOGD(...) ESP_EARLY_LOGD(__VA_ARGS__) +#define HAL_EARLY_LOGV(...) ESP_EARLY_LOGV(__VA_ARGS__) diff --git a/tools/sdk/esp32s2/include/hal/platform_port/include/hal/misc.h b/tools/sdk/esp32s2/include/hal/platform_port/include/hal/misc.h index 472ec8be2a3..4afb49653ff 100644 --- a/tools/sdk/esp32s2/include/hal/platform_port/include/hal/misc.h +++ b/tools/sdk/esp32s2/include/hal/platform_port/include/hal/misc.h @@ -16,3 +16,44 @@ #define HAL_SWAP16(d) __builtin_bswap16((d)) #define HAL_SWAP32(d) __builtin_bswap32((d)) #define HAL_SWAP64(d) __builtin_bswap64((d)) + +/** @cond */ //Doxy command to hide preprocessor definitions from docs */ + +/** + * @brief Macro to force a 32-bit read, modify, then write on a peripheral register + * + * Due to a GCC bug, the compiler may still try to optimize read/writes to peripheral register fields by using 8/16 bit + * access, even if they are marked volatile (i.e., -fstrict-volatile-bitfields has no effect). + * + * For ESP chips, the peripheral bus only allows 32-bit read/writes. The following macro works around the compiler issue + * by forcing a 32-bit read/modify/write. + * + * @note This macro should only be called on register fields of xxx_struct.h type headers, as it depends on the presence + * of a 'val' field of the register union. + * @note Current implementation reads into a uint32_t instead of copy base_reg direclty to temp_reg. The reason being + * that C++ does not create a copy constructor for volatile structs. + */ +#define HAL_FORCE_MODIFY_U32_REG_FIELD(base_reg, reg_field, field_val) \ +{ \ + uint32_t temp_val = base_reg.val; \ + typeof(base_reg) temp_reg; \ + temp_reg.val = temp_val; \ + temp_reg.reg_field = (field_val); \ + (base_reg).val = temp_reg.val; \ +} + +/** + * @brief Macro to force a 32-bit read on a peripheral register + * + * @note This macro should only be called on register fields of xxx_struct.h type headers. See description above for + * more details. + * @note Current implementation reads into a uint32_t. See description above for more details. + */ +#define HAL_FORCE_READ_U32_REG_FIELD(base_reg, reg_field) ({ \ + uint32_t temp_val = base_reg.val; \ + typeof(base_reg) temp_reg; \ + temp_reg.val = temp_val; \ + temp_reg.reg_field; \ +}) + +/** @endcond */ diff --git a/tools/sdk/esp32s2/include/idf_test/include/idf_performance.h b/tools/sdk/esp32s2/include/idf_test/include/idf_performance.h index 18816813a78..9d99070b953 100644 --- a/tools/sdk/esp32s2/include/idf_test/include/idf_performance.h +++ b/tools/sdk/esp32s2/include/idf_test/include/idf_performance.h @@ -50,6 +50,20 @@ #define IDF_PERFORMANCE_MIN_UDP_TX_THROUGHPUT 50 #endif +// throughput performance by ethernet iperf +#ifndef IDF_PERFORMANCE_MIN_TCP_RX_ETH_THROUGHPUT +#define IDF_PERFORMANCE_MIN_TCP_RX_ETH_THROUGHPUT 20 +#endif +#ifndef IDF_PERFORMANCE_MIN_TCP_TX_ETH_THROUGHPUT +#define IDF_PERFORMANCE_MIN_TCP_TX_ETH_THROUGHPUT 30 +#endif +#ifndef IDF_PERFORMANCE_MIN_UDP_RX_ETH_THROUGHPUT +#define IDF_PERFORMANCE_MIN_UDP_RX_ETH_THROUGHPUT 50 +#endif +#ifndef IDF_PERFORMANCE_MIN_UDP_TX_ETH_THROUGHPUT +#define IDF_PERFORMANCE_MIN_UDP_TX_ETH_THROUGHPUT 70 +#endif + // events dispatched per second by event loop library #ifndef IDF_PERFORMANCE_MIN_EVENT_DISPATCH #define IDF_PERFORMANCE_MIN_EVENT_DISPATCH 25000 diff --git a/tools/sdk/esp32s2/include/ieee802154/include/esp_ieee802154.h b/tools/sdk/esp32s2/include/ieee802154/include/esp_ieee802154.h index a8d4678e924..e31a5ca37e5 100644 --- a/tools/sdk/esp32s2/include/ieee802154/include/esp_ieee802154.h +++ b/tools/sdk/esp32s2/include/ieee802154/include/esp_ieee802154.h @@ -192,6 +192,24 @@ void esp_ieee802154_get_extended_address(uint8_t *ext_addr); */ void esp_ieee802154_set_extended_address(const uint8_t *ext_addr); +/** + * @brief Get the device coordinator. + * + * @return + * - True The coordinator is enabled. + * - False The coordinator is disabled. + * + */ +bool esp_ieee802154_get_coordinator(void); + +/** + * @brief Set the device coordinator role. + * + * @param[in] enable The coordinator role to be set. + * + */ +void esp_ieee802154_set_coordinator(bool enable); + /** * @brief Get the auto frame pending mode. * diff --git a/tools/sdk/esp32s2/include/ieee802154/include/esp_ieee802154_types.h b/tools/sdk/esp32s2/include/ieee802154/include/esp_ieee802154_types.h index 6979991cc32..823e3cdcf3f 100644 --- a/tools/sdk/esp32s2/include/ieee802154/include/esp_ieee802154_types.h +++ b/tools/sdk/esp32s2/include/ieee802154/include/esp_ieee802154_types.h @@ -41,6 +41,8 @@ typedef enum { ESP_IEEE802154_TX_ERR_NO_ACK, /*!< No Ack frame received until timeout */ ESP_IEEE802154_TX_ERR_INVALID_ACK, /*!< Invalid Ack frame */ ESP_IEEE802154_TX_ERR_COEXIST, /*!< Rejected by coexist system */ + ESP_IEEE802154_TX_ERR_COEXIST_REJ, /*!< Rejected by coexist system before transmitting frame */ + ESP_IEEE802154_TX_ERR_COEXIST_ACK, /*!< Rejected by coexist system when receiving ack */ } esp_ieee802154_tx_error_t; /** @@ -60,6 +62,7 @@ typedef enum { ESP_IEEE802154_AUTO_PENDING_DISABLE, /*!< Frame pending bit always set to 1 in the ack to Data Request */ ESP_IEEE802154_AUTO_PENDING_ENABLE, /*!< Frame pending bit set to 1 if src address matches, in the ack to Data Request */ ESP_IEEE802154_AUTO_PENDING_ENHANCED, /*!< Frame pending bit set to 1 if src address matches, in all ack frames */ + ESP_IEEE802154_AUTO_PENDING_ZIGBEE, /*!< Frame pending bit set to 0 only if src address is short address and matches in table, in the ack to Data Request */ } esp_ieee802154_pending_mode_t; /** diff --git a/tools/sdk/esp32s2/include/json/cJSON/cJSON.h b/tools/sdk/esp32s2/include/json/cJSON/cJSON.h index e97e5f4cdc4..92907a2cd38 100644 --- a/tools/sdk/esp32s2/include/json/cJSON/cJSON.h +++ b/tools/sdk/esp32s2/include/json/cJSON/cJSON.h @@ -81,7 +81,7 @@ then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJ /* project version */ #define CJSON_VERSION_MAJOR 1 #define CJSON_VERSION_MINOR 7 -#define CJSON_VERSION_PATCH 14 +#define CJSON_VERSION_PATCH 15 #include @@ -256,7 +256,7 @@ CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * cons /* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from strings. * The input pointer json cannot point to a read-only address area, such as a string constant, - * but should point to a readable and writable adress area. */ + * but should point to a readable and writable address area. */ CJSON_PUBLIC(void) cJSON_Minify(char *json); /* Helper functions for creating and adding items to an object at the same time. diff --git a/tools/sdk/esp32s2/include/log/include/esp_log.h b/tools/sdk/esp32s2/include/log/include/esp_log.h index cf7bcd601a2..0e3148f62dc 100644 --- a/tools/sdk/esp32s2/include/log/include/esp_log.h +++ b/tools/sdk/esp32s2/include/log/include/esp_log.h @@ -10,9 +10,7 @@ #include #include #include "sdkconfig.h" -#if !defined(CONFIG_IDF_TARGET_LINUX) #include "esp_rom_sys.h" -#endif // !CONFIG_IDF_TARGET_LINUX #if CONFIG_IDF_TARGET_ESP32 #include "esp32/rom/ets_sys.h" // will be removed in idf v5.0 #elif CONFIG_IDF_TARGET_ESP32S2 @@ -90,6 +88,9 @@ esp_log_level_t esp_log_level_get(const char* tag); * output to some other destination, such as file or network. Returns the original * log handler, which may be necessary to return output to the previous destination. * + * @note Please note that function callback here must be re-entrant as it can be + * invoked in parallel from multiple thread context. + * * @param func new Function used for output. Must have same signature as vprintf. * * @return func old Function used for output. diff --git a/tools/sdk/esp32s2/include/lwip/include/apps/dhcpserver/dhcpserver.h b/tools/sdk/esp32s2/include/lwip/include/apps/dhcpserver/dhcpserver.h index 39a58bbfa94..262ebf43d85 100644 --- a/tools/sdk/esp32s2/include/lwip/include/apps/dhcpserver/dhcpserver.h +++ b/tools/sdk/esp32s2/include/lwip/include/apps/dhcpserver/dhcpserver.h @@ -17,6 +17,10 @@ #include "sdkconfig.h" #include "lwip/ip_addr.h" +#ifdef __cplusplus +extern "C" { +#endif + typedef struct dhcps_state{ s16_t state; } dhcps_state; @@ -91,4 +95,8 @@ void dhcps_dns_setserver(const ip_addr_t *dnsserver); ip4_addr_t dhcps_dns_getserver(void); void dhcps_set_new_lease_cb(dhcps_cb_t cb); +#ifdef __cplusplus +} #endif + +#endif /* __DHCPS_H__ */ diff --git a/tools/sdk/esp32s2/include/lwip/include/apps/dhcpserver/dhcpserver_options.h b/tools/sdk/esp32s2/include/lwip/include/apps/dhcpserver/dhcpserver_options.h index 38d46f6bff2..31a67992831 100644 --- a/tools/sdk/esp32s2/include/lwip/include/apps/dhcpserver/dhcpserver_options.h +++ b/tools/sdk/esp32s2/include/lwip/include/apps/dhcpserver/dhcpserver_options.h @@ -13,6 +13,9 @@ // limitations under the License. #pragma once +#ifdef __cplusplus +extern "C" { +#endif /** DHCP Options This macros are not part of the public dhcpserver.h interface. @@ -132,3 +135,7 @@ typedef enum DOMAIN_SEARCH = 119, CLASSLESS_ROUTE = 121, } dhcp_msg_option; + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32s2/include/lwip/port/esp32/include/lwipopts.h b/tools/sdk/esp32s2/include/lwip/port/esp32/include/lwipopts.h index 72e2bc4a97a..4bc2ad13960 100644 --- a/tools/sdk/esp32s2/include/lwip/port/esp32/include/lwipopts.h +++ b/tools/sdk/esp32s2/include/lwip/port/esp32/include/lwipopts.h @@ -33,9 +33,7 @@ #define __LWIPOPTS_H__ #include -#include #include -#include #include #include #include @@ -44,6 +42,7 @@ #include "esp_system.h" #include "sdkconfig.h" #include "netif/dhcp_state.h" +#include "sntp/sntp_get_set_time.h" /* Enable all Espressif-only options */ @@ -595,7 +594,7 @@ * LWIP_TCPIP_CORE_LOCKING: (EXPERIMENTAL!) * Don't use it if you're not an active lwIP project member */ -#define LWIP_TCPIP_CORE_LOCKING 0 +#define LWIP_TCPIP_CORE_LOCKING CONFIG_LWIP_TCPIP_CORE_LOCKING /* ------------------------------------ @@ -910,6 +909,15 @@ #define TCP_DEBUG LWIP_DBG_OFF #endif +/** + * SNTP_DEBUG: Enable debugging for SNTP. + */ +#ifdef CONFIG_LWIP_SNTP_DEBUG +#define SNTP_DEBUG LWIP_DBG_ON +#else +#define SNTP_DEBUG LWIP_DBG_OFF +#endif + /** * MEMP_DEBUG: Enable debugging in memp.c. */ @@ -970,6 +978,8 @@ #define LWIP_ND6_RDNSS_MAX_DNS_SERVERS CONFIG_LWIP_IPV6_RDNSS_MAX_DNS_SERVERS +#define LWIP_IPV6_DHCP6 CONFIG_LWIP_IPV6_DHCP6 + /* Enable all Espressif-only options */ #define ESP_LWIP 1 @@ -1044,7 +1054,11 @@ #define CHECKSUM_CHECK_ICMP CONFIG_LWIP_CHECKSUM_CHECK_ICMP #define LWIP_NETCONN_FULLDUPLEX 1 +#if LWIP_TCPIP_CORE_LOCKING +#define LWIP_NETCONN_SEM_PER_THREAD 0 +#else #define LWIP_NETCONN_SEM_PER_THREAD 1 +#endif /* LWIP_TCPIP_CORE_LOCKING */ #define LWIP_DHCP_MAX_NTP_SERVERS CONFIG_LWIP_DHCP_MAX_NTP_SERVERS #define LWIP_TIMEVAL_PRIVATE 0 @@ -1054,25 +1068,15 @@ ------------ SNTP options ------------ -------------------------------------- */ -/* - * SNTP update delay - in milliseconds - */ - -/* - * Forward declarations of weak definitions from lwip's sntp.c which could - * be redefined by user application. This is needed to provide custom definition - * of the below macros in lwip's sntp.c. - * Full declaration is provided in IDF's port layer in esp_sntp.h - */ -#ifdef __cplusplus -#define LWIP_FORWARD_DECLARE_C_CXX extern "C" -#else -#define LWIP_FORWARD_DECLARE_C_CXX -#endif -LWIP_FORWARD_DECLARE_C_CXX void sntp_sync_time(struct timeval *tv); +// Max number of SNTP servers handled (default equal to LWIP_DHCP_MAX_NTP_SERVERS) +#if defined CONFIG_LWIP_SNTP_MAX_SERVERS +#define SNTP_MAX_SERVERS CONFIG_LWIP_SNTP_MAX_SERVERS +#endif // CONFIG_LWIP_SNTP_MAX_SERVERS -LWIP_FORWARD_DECLARE_C_CXX uint32_t sntp_get_sync_interval(void); +#ifdef CONFIG_LWIP_DHCP_GET_NTP_SRV +#define LWIP_DHCP_GET_NTP_SRV CONFIG_LWIP_DHCP_GET_NTP_SRV +#endif // CONFIG_LWIP_DHCP_GET_NTP_SRV /** Set this to 1 to support DNS names (or IP address strings) to set sntp servers * One server address/name can be defined as default if SNTP_SERVER_DNS == 1: @@ -1083,22 +1087,9 @@ LWIP_FORWARD_DECLARE_C_CXX uint32_t sntp_get_sync_interval(void); // It disables a check of SNTP_UPDATE_DELAY it is done in sntp_set_sync_interval #define SNTP_SUPPRESS_DELAY_CHECK -#define SNTP_UPDATE_DELAY (sntp_get_sync_interval()) - -#define SNTP_SET_SYSTEM_TIME_US(sec, us) \ - do { \ - struct timeval tv = { .tv_sec = sec, .tv_usec = us }; \ - sntp_sync_time(&tv); \ - } while (0); - -#define SNTP_GET_SYSTEM_TIME(sec, us) \ - do { \ - struct timeval tv = { .tv_sec = 0, .tv_usec = 0 }; \ - gettimeofday(&tv, NULL); \ - (sec) = tv.tv_sec; \ - (us) = tv.tv_usec; \ - sntp_set_sync_status(SNTP_SYNC_STATUS_RESET); \ - } while (0); +#define SNTP_UPDATE_DELAY (sntp_get_sync_interval()) +#define SNTP_SET_SYSTEM_TIME_US(sec, us) (sntp_set_system_time(sec, us)) +#define SNTP_GET_SYSTEM_TIME(sec, us) (sntp_get_system_time(&(sec), &(us))) #define SOC_SEND_LOG //printf diff --git a/tools/sdk/esp32s2/include/lwip/port/esp32/include/sntp/sntp_get_set_time.h b/tools/sdk/esp32s2/include/lwip/port/esp32/include/sntp/sntp_get_set_time.h new file mode 100644 index 00000000000..19916208044 --- /dev/null +++ b/tools/sdk/esp32s2/include/lwip/port/esp32/include/sntp/sntp_get_set_time.h @@ -0,0 +1,55 @@ +// Copyright 2021 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 __SNTP_GET_SET_TIME_H__ +#define __SNTP_GET_SET_TIME_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * Declarations of functions used in lwipopts.h to redefine + * default sntp macros, such as: + * - SNTP_UPDATE_DELAY() + * - SNTP_SET_SYSTEM_TIME_US() + * - SNTP_GET_SYSTEM_TIME() + */ + +/* + * @brief Get the sync interval of SNTP operation + * Full definition is provided in IDF's layer in esp_sntp.c + */ +uint32_t sntp_get_sync_interval(void); + +/** + * @brief system time setter used in the sntp module + * @note The lwip sntp uses u32_t types for sec and us arguments + */ +void sntp_set_system_time(uint32_t sec, uint32_t us); + +/** + * @brief system time getter used in the sntp module + * @note The lwip sntp uses u32_t types for sec and us arguments + */ +void sntp_get_system_time(uint32_t* sec, uint32_t* us); + +#ifdef __cplusplus +} +#endif + +#endif //__SNTP_GET_SET_TIME_H__ diff --git a/tools/sdk/esp32s2/include/mdns/include/mdns.h b/tools/sdk/esp32s2/include/mdns/include/mdns.h index 7089eabe6a9..4bb288d4174 100644 --- a/tools/sdk/esp32s2/include/mdns/include/mdns.h +++ b/tools/sdk/esp32s2/include/mdns/include/mdns.h @@ -75,10 +75,13 @@ typedef struct mdns_result_s { struct mdns_result_s * next; /*!< next result, or NULL for the last result in the list */ mdns_if_t tcpip_if; /*!< interface index */ + uint32_t ttl; /*!< time to live */ mdns_ip_protocol_t ip_protocol; /*!< ip_protocol type of the interface (v4/v6) */ // PTR char * instance_name; /*!< instance name */ + char * service_type; /*!< service type */ + char * proto; /*!< srevice protocol */ // SRV char * hostname; /*!< hostname */ uint16_t port; /*!< service port */ @@ -90,6 +93,8 @@ typedef struct mdns_result_s { mdns_ip_addr_t * addr; /*!< linked list of IP addresses found */ } mdns_result_t; +typedef void (*mdns_query_notify_t)(mdns_search_once_t *search); + /** * @brief Initialize mDNS on given interface * @@ -519,11 +524,13 @@ bool mdns_query_async_get_results(mdns_search_once_t* search, uint32_t timeout, * @param type type of query (MDNS_TYPE_*) * @param timeout time in milliseconds during which mDNS query is active * @param max_results maximum results to be collected + * @param notifier Notification function to be called when the result is ready, can be NULL * * @return mdns_search_once_s pointer to new search object if query initiated successfully. * NULL otherwise. */ -mdns_search_once_t* mdns_query_async_new(const char * name, const char * service_type, const char * proto, uint16_t type, uint32_t timeout, size_t max_results); +mdns_search_once_t *mdns_query_async_new(const char *name, const char *service_type, const char *proto, uint16_t type, + uint32_t timeout, size_t max_results, mdns_query_notify_t notifier); /** * @brief Query mDNS for host or service diff --git a/tools/sdk/esp32s2/include/newlib/platform_include/assert.h b/tools/sdk/esp32s2/include/newlib/platform_include/assert.h index 85222861480..39db39a6f04 100644 --- a/tools/sdk/esp32s2/include/newlib/platform_include/assert.h +++ b/tools/sdk/esp32s2/include/newlib/platform_include/assert.h @@ -19,6 +19,7 @@ #pragma once #include #include +#include #include_next @@ -31,16 +32,21 @@ */ #undef assert +/* __FILENAME__ points to the file name instead of path + filename + * e.g __FILE__ points to "/apps/test.c" where as __FILENAME__ points to "test.c" + */ +#define __FILENAME__ (__builtin_strrchr( "/" __FILE__, '/') + 1) + #if defined(NDEBUG) -# define assert(__e) ((void)(__e)) +#define assert(__e) ((void)(__e)) #elif CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT -#define assert(__e) __builtin_expect(!!(__e), 1) ? (void)0 : abort() +#define assert(__e) (__builtin_expect(!!(__e), 1) ? (void)0 : __assert_func(NULL, 0, NULL, NULL)) #else // !CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT -#define assert(__e) (__builtin_expect(!!(__e), 1) ? (void)0 : __assert_func (__FILE__, __LINE__, \ +#define assert(__e) (__builtin_expect(!!(__e), 1) ? (void)0 : __assert_func (__FILENAME__, __LINE__, \ __ASSERT_FUNC, #__e)) #endif diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/apb_ctrl_struct.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/apb_ctrl_struct.h index d05c2c9a006..dbf2e4e3ef0 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/apb_ctrl_struct.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/apb_ctrl_struct.h @@ -17,7 +17,7 @@ extern "C" { #endif -typedef volatile struct { +typedef volatile struct apb_ctrl_dev_s { union { struct { uint32_t pre_div: 10; diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/apb_saradc_struct.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/apb_saradc_struct.h index e9811dab60c..505596f994f 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/apb_saradc_struct.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/apb_saradc_struct.h @@ -17,7 +17,7 @@ extern "C" { #endif -typedef volatile struct { +typedef volatile struct apb_saradc_dev_s { union { struct { uint32_t start_force: 1; diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/cache_memory.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/cache_memory.h index 06de5a4323f..5c182bd6c42 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/cache_memory.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/cache_memory.h @@ -67,7 +67,7 @@ extern "C" { #define BUS_DROM0_CACHE_SIZE BUS_SIZE(DROM0) #define BUS_DRAM0_CACHE_SIZE BUS_SIZE(DRAM0_CACHE) #define BUS_DRAM1_CACHE_SIZE BUS_SIZE(DRAM1) -#define BUS_DPORT_CACHE_SIZE BUS_SIZE(DPORT) +#define BUS_DPORT_CACHE_SIZE BUS_SIZE(DPORT_CACHE) #define PRO_CACHE_IBUS0 0 #define PRO_CACHE_IBUS0_MMU_START 0 diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/cp_dma_struct.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/cp_dma_struct.h index 208c82939c7..15fb42e451c 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/cp_dma_struct.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/cp_dma_struct.h @@ -69,6 +69,7 @@ typedef union { * This is the interrupt raw bit. Triggered when crc calculation is done. */ uint32_t dma_crc_done_int_raw: 1; + uint32_t reserved9: 23; }; uint32_t val; } cp_dma_int_raw_reg_t; @@ -123,6 +124,7 @@ typedef union { * cp_crc_done_int_ena is set to 1. */ uint32_t dma_crc_done_int_st: 1; + uint32_t reserved9: 23; }; uint32_t val; } cp_dma_int_st_reg_t; @@ -168,6 +170,7 @@ typedef union { * This is the interrupt enable bit for cp_crc_done_int interrupt. */ uint32_t dma_crc_done_int_ena: 1; + uint32_t reserved9: 23; }; uint32_t val; } cp_dma_int_ena_reg_t; @@ -213,6 +216,7 @@ typedef union { * Set this bit to clear cp_crc_done_int interrupt. */ uint32_t dma_crc_done_int_clr: 1; + uint32_t reserved9: 23; }; uint32_t val; } cp_dma_int_clr_reg_t; @@ -491,6 +495,7 @@ typedef union { * Copy DMA FIFO empty signal. */ uint32_t dma_fifo_empty: 1; + uint32_t reserved24: 8; }; uint32_t val; } cp_dma_in_st_reg_t; @@ -516,6 +521,7 @@ typedef union { * Copy DMA FIFO full signal. */ uint32_t dma_fifo_full: 1; + uint32_t reserved24: 8; }; uint32_t val; } cp_dma_out_st_reg_t; diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/dedic_gpio_struct.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/dedic_gpio_struct.h index 3ccd588b973..04aae779ad2 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/dedic_gpio_struct.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/dedic_gpio_struct.h @@ -31,6 +31,7 @@ typedef union { * gpio. */ uint32_t gpio_out_drt_vlaue: 8; + uint32_t reserved8: 24; }; uint32_t val; } dedic_gpio_out_drt_reg_t; @@ -49,6 +50,7 @@ typedef union { * channel's output would be masked. */ uint32_t gpio_out_msk: 8; + uint32_t reserved16: 16; }; uint32_t val; } dedic_gpio_out_msk_reg_t; @@ -98,6 +100,7 @@ typedef union { * clear output value; 3: inverse output value. */ uint32_t gpio_out_idv_ch7: 2; + uint32_t reserved16: 16; }; uint32_t val; } dedic_gpio_out_idv_reg_t; @@ -147,6 +150,7 @@ typedef union { * select CPU instructors. */ uint32_t gpio_out_cpu_sel7: 1; + uint32_t reserved8: 24; }; uint32_t val; } dedic_gpio_out_cpu_reg_t; @@ -196,6 +200,7 @@ typedef union { * 3: three clock delay. */ uint32_t gpio_in_dly_ch7: 2; + uint32_t reserved16: 16; }; uint32_t val; } dedic_gpio_in_dly_reg_t; @@ -285,6 +290,7 @@ typedef union { * 6/7: falling and raising edge trigger. */ uint32_t gpio_intr_mode_ch7: 3; + uint32_t reserved24: 8; }; uint32_t val; } dedic_gpio_intr_rcgn_reg_t; @@ -301,6 +307,7 @@ typedef union { * DEDIC_GPIO_OUT_IDV_REG. */ uint32_t gpio_out_status: 8; + uint32_t reserved8: 24; }; uint32_t val; } dedic_gpio_out_scan_reg_t; @@ -314,6 +321,7 @@ typedef union { * gpio in value after configured by DEDIC_GPIO_IN_DLY_REG. */ uint32_t gpio_in_status: 8; + uint32_t reserved8: 24; }; uint32_t val; } dedic_gpio_in_scan_reg_t; @@ -365,6 +373,7 @@ typedef union { * change configured by DEDIC_GPIO_INTR_RCGN_REG. */ uint32_t gpio7_int_raw: 1; + uint32_t reserved8: 24; }; uint32_t val; } dedic_gpio_intr_raw_reg_t; @@ -406,6 +415,7 @@ typedef union { * This enable bit for reg_gpio7_int_st register. */ uint32_t gpio7_int_ena: 1; + uint32_t reserved8: 24; }; uint32_t val; } dedic_gpio_intr_rls_reg_t; @@ -447,6 +457,7 @@ typedef union { * This is the status bit for reg_gpio7_int_raw when reg_gpio7_int_ena is set to 1. */ uint32_t gpio7_int_st: 1; + uint32_t reserved8: 24; }; uint32_t val; } dedic_gpio_intr_st_reg_t; @@ -488,6 +499,7 @@ typedef union { * Set this bit to clear the reg_gpio7_int_raw interrupt. */ uint32_t gpio7_int_clr: 1; + uint32_t reserved8: 24; }; uint32_t val; } dedic_gpio_intr_clr_reg_t; diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/efuse_reg.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/efuse_reg.h index 4d76d1115c9..f7be21c6edd 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/efuse_reg.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/efuse_reg.h @@ -917,18 +917,18 @@ extern "C" { #define EFUSE_SPI_PAD_CONF_1_S 0 #define EFUSE_RD_MAC_SPI_SYS_3_REG (DR_REG_EFUSE_BASE + 0x050) -/* EFUSE_SYS_DATA_PART0_0 : RO ;bitpos:[31:25] ;default: 7'h0 ; */ -/*description: Stores the fist 7 bits of the zeroth part of system data.*/ -#define EFUSE_SYS_DATA_PART0_0 0x0000007F -#define EFUSE_SYS_DATA_PART0_0_M ((EFUSE_SYS_DATA_PART0_0_V)<<(EFUSE_SYS_DATA_PART0_0_S)) -#define EFUSE_SYS_DATA_PART0_0_V 0x7F -#define EFUSE_SYS_DATA_PART0_0_S 25 -/* EFUSE_PKG_VERSION : RO ;bitpos:[24:21] ;default: 4'h0 ; */ -/*description: Package version 0:ESP32-S2, 1:ESP32-S2FH16, 2:ESP32-S2FH32 */ -#define EFUSE_PKG_VERSION 0x0000000F -#define EFUSE_PKG_VERSION_M ((EFUSE_PKG_VERSION_V)<<(EFUSE_PKG_VERSION_S)) -#define EFUSE_PKG_VERSION_V 0xF -#define EFUSE_PKG_VERSION_S 21 +/* EFUSE_PSRAM_VERSION : RO ;bitpos:[31:28] ;default: 4'h0 ; */ +/*description: PSRAM version */ +#define EFUSE_PSRAM_VERSION 0x0000000F +#define EFUSE_PSRAM_VERSION_M ((EFUSE_PSRAM_VERSION_V)<<(EFUSE_PSRAM_VERSION_S)) +#define EFUSE_PSRAM_VERSION_V 0xF +#define EFUSE_PSRAM_VERSION_S 28 +/* EFUSE_FLASH_VERSION : RO ;bitpos:[24:21] ;default: 4'h0 ; */ +/*description: Flash version */ +#define EFUSE_FLASH_VERSION 0x0000000F +#define EFUSE_FLASH_VERSION_M ((EFUSE_FLASH_VERSION_V)<<(EFUSE_FLASH_VERSION_S)) +#define EFUSE_FLASH_VERSION_V 0xF +#define EFUSE_FLASH_VERSION_S 21 /* EFUSE_WAFER_VERSION : RO ;bitpos:[20:18] ;default: 3'h0 ; */ /*description: WAFER version 0:A */ #define EFUSE_WAFER_VERSION 0x00000007 @@ -943,12 +943,18 @@ extern "C" { #define EFUSE_SPI_PAD_CONF_2_S 0 #define EFUSE_RD_MAC_SPI_SYS_4_REG (DR_REG_EFUSE_BASE + 0x054) -/* EFUSE_SYS_DATA_PART0_1 : RO ;bitpos:[31:0] ;default: 32'h0 ; */ +/* EFUSE_SYS_DATA_PART0_1 : RO ;bitpos:[31:4] ;default: 28'h0 ; */ /*description: Stores the fist 32 bits of the zeroth part of system data.*/ -#define EFUSE_SYS_DATA_PART0_1 0xFFFFFFFF +#define EFUSE_SYS_DATA_PART0_1 0x0FFFFFFF #define EFUSE_SYS_DATA_PART0_1_M ((EFUSE_SYS_DATA_PART0_1_V)<<(EFUSE_SYS_DATA_PART0_1_S)) -#define EFUSE_SYS_DATA_PART0_1_V 0xFFFFFFFF -#define EFUSE_SYS_DATA_PART0_1_S 0 +#define EFUSE_SYS_DATA_PART0_1_V 0x0FFFFFFF +#define EFUSE_SYS_DATA_PART0_1_S 4 +/* EFUSE_PKG_VERSION : RO ;bitpos:[3:0] ;default: 4'h0 ; */ +/*description: Package version */ +#define EFUSE_PKG_VERSION 0x0000000F +#define EFUSE_PKG_VERSION_M ((EFUSE_PKG_VERSION_V)<<(EFUSE_PKG_VERSION_S)) +#define EFUSE_PKG_VERSION_V 0xF +#define EFUSE_PKG_VERSION_S 0 #define EFUSE_RD_MAC_SPI_SYS_5_REG (DR_REG_EFUSE_BASE + 0x058) /* EFUSE_SYS_DATA_PART0_2 : RO ;bitpos:[31:0] ;default: 32'h0 ; */ @@ -1902,7 +1908,7 @@ extern "C" { #define EFUSE_DIS_DOWNLOAD_MODE_ERR_V 0x1 #define EFUSE_DIS_DOWNLOAD_MODE_ERR_S 0 -#define EFUSE_RD_REPEAT_ERR4_REG (DR_REG_EFUSE_BASE + 0x190) +#define EFUSE_RD_REPEAT_ERR4_REG (DR_REG_EFUSE_BASE + 0x18C) /* EFUSE_RPT1_RESERVED0_ERR : RO ;bitpos:[31:24] ;default: 8'h0 ; */ /*description: Reserved.*/ #define EFUSE_RPT1_RESERVED0_ERR 0x000000FF diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/efuse_struct.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/efuse_struct.h index a9679c267c4..d2ef6454948 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/efuse_struct.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/efuse_struct.h @@ -17,7 +17,7 @@ extern "C" { #endif -typedef volatile struct { +typedef volatile struct efuse_dev_s { uint32_t pgm_data0; /**/ union { struct { @@ -357,7 +357,6 @@ typedef volatile struct { }; uint32_t val; } rd_repeat_err3; - uint32_t reserved_18c; union { struct { uint32_t rd_chip_version_err:24; @@ -365,6 +364,18 @@ typedef volatile struct { }; uint32_t val; } rd_repeat_err4; + uint32_t reserved_190; + uint32_t reserved_194; + uint32_t reserved_198; + uint32_t reserved_19c; + uint32_t reserved_1a0; + uint32_t reserved_1a4; + uint32_t reserved_1a8; + uint32_t reserved_1ac; + uint32_t reserved_1b0; + uint32_t reserved_1b4; + uint32_t reserved_1b8; + uint32_t reserved_1bc; union { struct { uint32_t rd_mac_spi_8m_err_num: 3; @@ -500,17 +511,6 @@ typedef volatile struct { }; uint32_t val; } wr_tim_conf1; - uint32_t reserved_1cc; - uint32_t reserved_1d0; - uint32_t reserved_1d4; - uint32_t reserved_1d8; - uint32_t reserved_1dc; - uint32_t reserved_1e0; - uint32_t reserved_1e4; - uint32_t reserved_1e8; - uint32_t reserved_1ec; - uint32_t reserved_1f0; - uint32_t reserved_1f4; uint32_t reserved_1f8; uint32_t date; /**/ } efuse_dev_t; diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/gpio_sd_struct.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/gpio_sd_struct.h index 6c28df52a8e..71131ae881d 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/gpio_sd_struct.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/gpio_sd_struct.h @@ -17,7 +17,7 @@ extern "C" { #endif -typedef volatile struct { +typedef volatile struct gpio_sd_dev_s { union { struct { uint32_t duty: 8; diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/gpio_struct.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/gpio_struct.h index 70e82ee1fe6..0dc1efdfdaa 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/gpio_struct.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/gpio_struct.h @@ -17,7 +17,7 @@ extern "C" { #endif -typedef volatile struct { +typedef volatile struct gpio_dev_s { uint32_t bt_select; /**/ uint32_t out; /**/ uint32_t out_w1ts; /**/ diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/i2c_struct.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/i2c_struct.h index e54038aaea8..150384992be 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/i2c_struct.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/i2c_struct.h @@ -17,7 +17,7 @@ extern "C" { #endif -typedef volatile struct { +typedef volatile struct i2c_dev_s { union { struct { uint32_t period: 14; diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/i2s_struct.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/i2s_struct.h index 789f2c21c26..99220407e72 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/i2s_struct.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/i2s_struct.h @@ -17,7 +17,7 @@ extern "C" { #endif -typedef volatile struct { +typedef volatile struct i2s_dev_s { uint32_t reserved_0; uint32_t reserved_4; union { diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/io_mux_reg.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/io_mux_reg.h index fe480c91e5c..f5682eedaba 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/io_mux_reg.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/io_mux_reg.h @@ -145,11 +145,6 @@ #define GPIO_PAD_PULLUP(num) do{PIN_PULLUP_DIS(IOMUX_REG_GPIO##num);PIN_PULLDWN_EN(IOMUX_REG_GPIO##num);}while(0) #define GPIO_PAD_SET_DRV(num, drv) PIN_SET_DRV(IOMUX_REG_GPIO##num, drv) -#define U1RXD_GPIO_NUM 18 -#define U1TXD_GPIO_NUM 17 -#define U0RXD_GPIO_NUM 44 -#define U0TXD_GPIO_NUM 43 - #define SPI_CS1_GPIO_NUM 26 #define SPI_HD_GPIO_NUM 27 #define SPI_WP_GPIO_NUM 28 diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/ledc_struct.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/ledc_struct.h index a6f02a788b7..b38edb0d61a 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/ledc_struct.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/ledc_struct.h @@ -17,7 +17,7 @@ extern "C" { #endif -typedef volatile struct { +typedef volatile struct ledc_dev_s { struct { struct { union { diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/memprot_defs.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/memprot_defs.h new file mode 100644 index 00000000000..f4b4ab9423b --- /dev/null +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/memprot_defs.h @@ -0,0 +1,131 @@ +// Copyright 2020 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/soc.h" +#include "soc/sensitive_reg.h" + +#ifdef __cplusplus +extern "C" { +#endif + +//IRAM0 interrupt status bitmasks +#define IRAM0_INTR_ST_OP_TYPE_BIT BIT(1) //instruction: 0, data: 1 +#define IRAM0_INTR_ST_OP_RW_BIT BIT(0) //read: 0, write: 1 + +#define CONF_REG_ADDRESS_SHIFT 2 + +//IRAM0 range +#define IRAM0_SRAM_BASE_ADDRESS 0x40000000 +#define IRAM0_SRAM_ADDRESS_LOW 0x40020000 +#define IRAM0_SRAM_ADDRESS_HIGH 0x4006FFFF + +//IRAM0 unified managemnt blocks +#define IRAM0_SRAM_TOTAL_UNI_BLOCKS 4 +#define IRAM0_SRAM_UNI_BLOCK_0 0 +#define IRAM0_SRAM_UNI_BLOCK_1 1 +#define IRAM0_SRAM_UNI_BLOCK_2 2 +#define IRAM0_SRAM_UNI_BLOCK_3 3 + +//unified management addr range (blocks 0-3) +#define IRAM0_SRAM_UNI_BLOCK_0_LOW 0x40020000 +#define IRAM0_SRAM_UNI_BLOCK_1_LOW 0x40022000 +#define IRAM0_SRAM_UNI_BLOCK_2_LOW 0x40024000 +#define IRAM0_SRAM_UNI_BLOCK_3_LOW 0x40026000 + +//split management addr range (blocks 4-21) +#define IRAM0_SRAM_SPL_BLOCK_LOW 0x40028000 //block 4 low +#define IRAM0_SRAM_SPL_BLOCK_HIGH 0x4006FFFF //block 21 high + +#define IRAM0_INTR_ST_FAULTADDR_M 0x003FFFFC //bits 21:6 in the reg, as well as in real address +#define IRAM0_SRAM_INTR_ST_FAULTADDR_HI 0x40000000 //high nonsignificant bits 31:22 of the faulting address - constant + +#define IRAM0_SRAM_ADDR_TO_CONF_REG(addr) (((addr >> CONF_REG_ADDRESS_SHIFT) & DPORT_PMS_PRO_IRAM0_SRAM_4_SPLTADDR) << DPORT_PMS_PRO_IRAM0_SRAM_4_SPLTADDR_S) + +//IRAM0 RTCFAST +#define IRAM0_RTCFAST_ADDRESS_LOW 0x40070000 +#define IRAM0_RTCFAST_ADDRESS_HIGH 0x40071FFF +#define IRAM0_RTCFAST_INTR_ST_FAULTADDR_HI 0x40070000 //RTCFAST faulting address high bits (31:22, constant) + +#define IRAM0_RTCFAST_ADDR_TO_CONF_REG(addr) (((addr >> CONF_REG_ADDRESS_SHIFT) & DPORT_PMS_PRO_IRAM0_RTCFAST_SPLTADDR) << DPORT_PMS_PRO_IRAM0_RTCFAST_SPLTADDR_S) + +//DRAM0 interrupt status bitmasks +#define DRAM0_INTR_ST_FAULTADDR_M 0x03FFFFC0 //(bits 25:6 in the reg) +#define DRAM0_INTR_ST_FAULTADDR_S 0x4 //(bits 21:2 of real address) +#define DRAM0_INTR_ST_OP_RW_BIT BIT(4) //read: 0, write: 1 +#define DRAM0_INTR_ST_OP_ATOMIC_BIT BIT(5) //non-atomic: 0, atomic: 1 + +#define DRAM0_SRAM_ADDRESS_LOW 0x3FFB0000 +#define DRAM0_SRAM_ADDRESS_HIGH 0x3FFFFFFF + +#define DRAM0_SRAM_TOTAL_UNI_BLOCKS 4 +#define DRAM0_SRAM_UNI_BLOCK_0 0 +#define DRAM0_SRAM_UNI_BLOCK_1 1 +#define DRAM0_SRAM_UNI_BLOCK_2 2 +#define DRAM0_SRAM_UNI_BLOCK_3 3 + +//unified management (SRAM blocks 0-3) +#define DRAM0_SRAM_UNI_BLOCK_0_LOW 0x3FFB0000 +#define DRAM0_SRAM_UNI_BLOCK_1_LOW 0x3FFB2000 +#define DRAM0_SRAM_UNI_BLOCK_2_LOW 0x3FFB4000 +#define DRAM0_SRAM_UNI_BLOCK_3_LOW 0x3FFB6000 + +//split management (SRAM blocks 4-21) +#define DRAM0_SRAM_SPL_BLOCK_HIGH 0x3FFFFFFF //block 21 high +#define DRAM0_SRAM_INTR_ST_FAULTADDR_HI 0x3FF00000 //SRAM high bits 31:22 of the faulting address - constant + +#define DRAM0_SRAM_ADDR_TO_CONF_REG(addr) (((addr >> CONF_REG_ADDRESS_SHIFT) & DPORT_PMS_PRO_DRAM0_SRAM_4_SPLTADDR) << DPORT_PMS_PRO_DRAM0_SRAM_4_SPLTADDR_S) + +//DRAM0 RTCFAST +#define DRAM0_RTCFAST_ADDRESS_LOW 0x3FF9E000 +#define DRAM0_RTCFAST_ADDRESS_HIGH 0x3FF9FFFF +#define DRAM0_RTCFAST_INTR_ST_FAULTADDR_HI 0x3FF00000 //RTCFAST high bits 31:22 of the faulting address - constant +#define DRAM0_RTCFAST_ADDR_TO_CONF_REG(addr) (((addr >> CONF_REG_ADDRESS_SHIFT) & DPORT_PMS_PRO_DRAM0_RTCFAST_SPLTADDR) << DPORT_PMS_PRO_DRAM0_RTCFAST_SPLTADDR_S) + +//RTCSLOW +#define RTCSLOW_MEMORY_SIZE 0x00002000 + +//PeriBus1 interrupt status bitmasks +#define PERI1_INTR_ST_OP_TYPE_BIT BIT(4) //0: non-atomic, 1: atomic +#define PERI1_INTR_ST_OP_HIGH_BITS BIT(5) //0: high bits = unchanged, 1: high bits = 0x03F40000 +#define PERI1_INTR_ST_FAULTADDR_M 0x03FFFFC0 //(bits 25:6 in the reg) +#define PERI1_INTR_ST_FAULTADDR_S 0x4 //(bits 21:2 of real address) + +#define PERI1_RTCSLOW_ADDRESS_BASE 0x3F421000 +#define PERI1_RTCSLOW_ADDRESS_LOW PERI1_RTCSLOW_ADDRESS_BASE +#define PERI1_RTCSLOW_ADDRESS_HIGH PERI1_RTCSLOW_ADDRESS_LOW + RTCSLOW_MEMORY_SIZE +#define PERI1_RTCSLOW_INTR_ST_FAULTADDR_HI_0 0x3F400000 + +#define PERI1_RTCSLOW_ADDR_TO_CONF_REG(addr) (((addr >> CONF_REG_ADDRESS_SHIFT) & DPORT_PMS_PRO_DPORT_RTCSLOW_SPLTADDR) << DPORT_PMS_PRO_DPORT_RTCSLOW_SPLTADDR_S) + +//PeriBus2 interrupt status bitmasks +#define PERI2_INTR_ST_OP_TYPE_BIT BIT(1) //instruction: 0, data: 1 +#define PERI2_INTR_ST_OP_RW_BIT BIT(0) //read: 0, write: 1 +#define PERI2_INTR_ST_FAULTADDR_M 0xFFFFFFFC //(bits 31:2 in the reg) + +#define PERI2_RTCSLOW_0_ADDRESS_BASE 0x50000000 +#define PERI2_RTCSLOW_0_ADDRESS_LOW PERI2_RTCSLOW_0_ADDRESS_BASE +#define PERI2_RTCSLOW_0_ADDRESS_HIGH PERI2_RTCSLOW_0_ADDRESS_LOW + RTCSLOW_MEMORY_SIZE + +#define PERI2_RTCSLOW_0_ADDR_TO_CONF_REG(addr) (((addr >> CONF_REG_ADDRESS_SHIFT) & DPORT_PMS_PRO_AHB_RTCSLOW_0_SPLTADDR) << DPORT_PMS_PRO_AHB_RTCSLOW_0_SPLTADDR_S) + +#define PERI2_RTCSLOW_1_ADDRESS_BASE 0x60021000 +#define PERI2_RTCSLOW_1_ADDRESS_LOW PERI2_RTCSLOW_1_ADDRESS_BASE +#define PERI2_RTCSLOW_1_ADDRESS_HIGH PERI2_RTCSLOW_1_ADDRESS_LOW + RTCSLOW_MEMORY_SIZE + +#define PERI2_RTCSLOW_1_ADDR_TO_CONF_REG(addr) (((addr >> CONF_REG_ADDRESS_SHIFT) & DPORT_PMS_PRO_AHB_RTCSLOW_1_SPLTADDR) << DPORT_PMS_PRO_AHB_RTCSLOW_1_SPLTADDR_S) + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/pcnt_reg.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/pcnt_reg.h index 7195e1b1fb8..b6198c86fbd 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/pcnt_reg.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/pcnt_reg.h @@ -1,860 +1,1236 @@ -// Copyright 2017-2019 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 _SOC_PCNT_REG_H_ -#define _SOC_PCNT_REG_H_ +/** Copyright 2021 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 +#include "soc/soc.h" #ifdef __cplusplus extern "C" { #endif -#include "soc.h" -#define PCNT_U0_CONF0_REG (DR_REG_PCNT_BASE + 0x0000) -/* PCNT_CH1_LCTRL_MODE_U0 : R/W ;bitpos:[31:30] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH1_LCTRL_MODE_U0 0x00000003 -#define PCNT_CH1_LCTRL_MODE_U0_M ((PCNT_CH1_LCTRL_MODE_U0_V)<<(PCNT_CH1_LCTRL_MODE_U0_S)) -#define PCNT_CH1_LCTRL_MODE_U0_V 0x3 -#define PCNT_CH1_LCTRL_MODE_U0_S 30 -/* PCNT_CH1_HCTRL_MODE_U0 : R/W ;bitpos:[29:28] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH1_HCTRL_MODE_U0 0x00000003 -#define PCNT_CH1_HCTRL_MODE_U0_M ((PCNT_CH1_HCTRL_MODE_U0_V)<<(PCNT_CH1_HCTRL_MODE_U0_S)) -#define PCNT_CH1_HCTRL_MODE_U0_V 0x3 -#define PCNT_CH1_HCTRL_MODE_U0_S 28 -/* PCNT_CH1_POS_MODE_U0 : R/W ;bitpos:[27:26] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH1_POS_MODE_U0 0x00000003 -#define PCNT_CH1_POS_MODE_U0_M ((PCNT_CH1_POS_MODE_U0_V)<<(PCNT_CH1_POS_MODE_U0_S)) -#define PCNT_CH1_POS_MODE_U0_V 0x3 -#define PCNT_CH1_POS_MODE_U0_S 26 -/* PCNT_CH1_NEG_MODE_U0 : R/W ;bitpos:[25:24] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH1_NEG_MODE_U0 0x00000003 -#define PCNT_CH1_NEG_MODE_U0_M ((PCNT_CH1_NEG_MODE_U0_V)<<(PCNT_CH1_NEG_MODE_U0_S)) -#define PCNT_CH1_NEG_MODE_U0_V 0x3 -#define PCNT_CH1_NEG_MODE_U0_S 24 -/* PCNT_CH0_LCTRL_MODE_U0 : R/W ;bitpos:[23:22] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH0_LCTRL_MODE_U0 0x00000003 -#define PCNT_CH0_LCTRL_MODE_U0_M ((PCNT_CH0_LCTRL_MODE_U0_V)<<(PCNT_CH0_LCTRL_MODE_U0_S)) -#define PCNT_CH0_LCTRL_MODE_U0_V 0x3 -#define PCNT_CH0_LCTRL_MODE_U0_S 22 -/* PCNT_CH0_HCTRL_MODE_U0 : R/W ;bitpos:[21:20] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH0_HCTRL_MODE_U0 0x00000003 -#define PCNT_CH0_HCTRL_MODE_U0_M ((PCNT_CH0_HCTRL_MODE_U0_V)<<(PCNT_CH0_HCTRL_MODE_U0_S)) -#define PCNT_CH0_HCTRL_MODE_U0_V 0x3 -#define PCNT_CH0_HCTRL_MODE_U0_S 20 -/* PCNT_CH0_POS_MODE_U0 : R/W ;bitpos:[19:18] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH0_POS_MODE_U0 0x00000003 -#define PCNT_CH0_POS_MODE_U0_M ((PCNT_CH0_POS_MODE_U0_V)<<(PCNT_CH0_POS_MODE_U0_S)) -#define PCNT_CH0_POS_MODE_U0_V 0x3 -#define PCNT_CH0_POS_MODE_U0_S 18 -/* PCNT_CH0_NEG_MODE_U0 : R/W ;bitpos:[17:16] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH0_NEG_MODE_U0 0x00000003 -#define PCNT_CH0_NEG_MODE_U0_M ((PCNT_CH0_NEG_MODE_U0_V)<<(PCNT_CH0_NEG_MODE_U0_S)) -#define PCNT_CH0_NEG_MODE_U0_V 0x3 -#define PCNT_CH0_NEG_MODE_U0_S 16 -/* PCNT_THR_THRES1_EN_U0 : R/W ;bitpos:[15] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_THR_THRES1_EN_U0 (BIT(15)) -#define PCNT_THR_THRES1_EN_U0_M (BIT(15)) -#define PCNT_THR_THRES1_EN_U0_V 0x1 -#define PCNT_THR_THRES1_EN_U0_S 15 -/* PCNT_THR_THRES0_EN_U0 : R/W ;bitpos:[14] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_THR_THRES0_EN_U0 (BIT(14)) -#define PCNT_THR_THRES0_EN_U0_M (BIT(14)) -#define PCNT_THR_THRES0_EN_U0_V 0x1 -#define PCNT_THR_THRES0_EN_U0_S 14 -/* PCNT_THR_L_LIM_EN_U0 : R/W ;bitpos:[13] ;default: 1'b1 ; */ -/*description: */ -#define PCNT_THR_L_LIM_EN_U0 (BIT(13)) -#define PCNT_THR_L_LIM_EN_U0_M (BIT(13)) -#define PCNT_THR_L_LIM_EN_U0_V 0x1 -#define PCNT_THR_L_LIM_EN_U0_S 13 -/* PCNT_THR_H_LIM_EN_U0 : R/W ;bitpos:[12] ;default: 1'b1 ; */ -/*description: */ -#define PCNT_THR_H_LIM_EN_U0 (BIT(12)) -#define PCNT_THR_H_LIM_EN_U0_M (BIT(12)) -#define PCNT_THR_H_LIM_EN_U0_V 0x1 -#define PCNT_THR_H_LIM_EN_U0_S 12 -/* PCNT_THR_ZERO_EN_U0 : R/W ;bitpos:[11] ;default: 1'b1 ; */ -/*description: */ -#define PCNT_THR_ZERO_EN_U0 (BIT(11)) -#define PCNT_THR_ZERO_EN_U0_M (BIT(11)) -#define PCNT_THR_ZERO_EN_U0_V 0x1 -#define PCNT_THR_ZERO_EN_U0_S 11 -/* PCNT_FILTER_EN_U0 : R/W ;bitpos:[10] ;default: 1'b1 ; */ -/*description: */ -#define PCNT_FILTER_EN_U0 (BIT(10)) -#define PCNT_FILTER_EN_U0_M (BIT(10)) -#define PCNT_FILTER_EN_U0_V 0x1 -#define PCNT_FILTER_EN_U0_S 10 -/* PCNT_FILTER_THRES_U0 : R/W ;bitpos:[9:0] ;default: 10'h10 ; */ -/*description: */ -#define PCNT_FILTER_THRES_U0 0x000003FF -#define PCNT_FILTER_THRES_U0_M ((PCNT_FILTER_THRES_U0_V)<<(PCNT_FILTER_THRES_U0_S)) -#define PCNT_FILTER_THRES_U0_V 0x3FF + +/** PCNT_U0_CONF0_REG register + * Configuration register 0 for unit 0 + */ +#define PCNT_U0_CONF0_REG (DR_REG_PCNT_BASE + 0x0) +/** PCNT_FILTER_THRES_U0 : R/W; bitpos: [9:0]; default: 16; + * This sets the maximum threshold, in APB_CLK cycles, for the filter. + * + * Any pulses with width less than this will be ignored when the filter is enabled. + */ +#define PCNT_FILTER_THRES_U0 0x000003FFU +#define PCNT_FILTER_THRES_U0_M (PCNT_FILTER_THRES_U0_V << PCNT_FILTER_THRES_U0_S) +#define PCNT_FILTER_THRES_U0_V 0x000003FFU #define PCNT_FILTER_THRES_U0_S 0 +/** PCNT_FILTER_EN_U0 : R/W; bitpos: [10]; default: 1; + * This is the enable bit for unit 0's input filter. + */ +#define PCNT_FILTER_EN_U0 (BIT(10)) +#define PCNT_FILTER_EN_U0_M (PCNT_FILTER_EN_U0_V << PCNT_FILTER_EN_U0_S) +#define PCNT_FILTER_EN_U0_V 0x00000001U +#define PCNT_FILTER_EN_U0_S 10 +/** PCNT_THR_ZERO_EN_U0 : R/W; bitpos: [11]; default: 1; + * This is the enable bit for unit 0's zero comparator. + */ +#define PCNT_THR_ZERO_EN_U0 (BIT(11)) +#define PCNT_THR_ZERO_EN_U0_M (PCNT_THR_ZERO_EN_U0_V << PCNT_THR_ZERO_EN_U0_S) +#define PCNT_THR_ZERO_EN_U0_V 0x00000001U +#define PCNT_THR_ZERO_EN_U0_S 11 +/** PCNT_THR_H_LIM_EN_U0 : R/W; bitpos: [12]; default: 1; + * This is the enable bit for unit 0's thr_h_lim comparator. + */ +#define PCNT_THR_H_LIM_EN_U0 (BIT(12)) +#define PCNT_THR_H_LIM_EN_U0_M (PCNT_THR_H_LIM_EN_U0_V << PCNT_THR_H_LIM_EN_U0_S) +#define PCNT_THR_H_LIM_EN_U0_V 0x00000001U +#define PCNT_THR_H_LIM_EN_U0_S 12 +/** PCNT_THR_L_LIM_EN_U0 : R/W; bitpos: [13]; default: 1; + * This is the enable bit for unit 0's thr_l_lim comparator. + */ +#define PCNT_THR_L_LIM_EN_U0 (BIT(13)) +#define PCNT_THR_L_LIM_EN_U0_M (PCNT_THR_L_LIM_EN_U0_V << PCNT_THR_L_LIM_EN_U0_S) +#define PCNT_THR_L_LIM_EN_U0_V 0x00000001U +#define PCNT_THR_L_LIM_EN_U0_S 13 +/** PCNT_THR_THRES0_EN_U0 : R/W; bitpos: [14]; default: 0; + * This is the enable bit for unit 0's thres0 comparator. + */ +#define PCNT_THR_THRES0_EN_U0 (BIT(14)) +#define PCNT_THR_THRES0_EN_U0_M (PCNT_THR_THRES0_EN_U0_V << PCNT_THR_THRES0_EN_U0_S) +#define PCNT_THR_THRES0_EN_U0_V 0x00000001U +#define PCNT_THR_THRES0_EN_U0_S 14 +/** PCNT_THR_THRES1_EN_U0 : R/W; bitpos: [15]; default: 0; + * This is the enable bit for unit 0's thres1 comparator. + */ +#define PCNT_THR_THRES1_EN_U0 (BIT(15)) +#define PCNT_THR_THRES1_EN_U0_M (PCNT_THR_THRES1_EN_U0_V << PCNT_THR_THRES1_EN_U0_S) +#define PCNT_THR_THRES1_EN_U0_V 0x00000001U +#define PCNT_THR_THRES1_EN_U0_S 15 +/** PCNT_CH0_NEG_MODE_U0 : R/W; bitpos: [17:16]; default: 0; + * This register sets the behavior when the signal input of channel 0 detects a + * negative edge. + * + * 1: Increase the counter;2: Decrease the counter;0, 3: No effect on counter + */ +#define PCNT_CH0_NEG_MODE_U0 0x00000003U +#define PCNT_CH0_NEG_MODE_U0_M (PCNT_CH0_NEG_MODE_U0_V << PCNT_CH0_NEG_MODE_U0_S) +#define PCNT_CH0_NEG_MODE_U0_V 0x00000003U +#define PCNT_CH0_NEG_MODE_U0_S 16 +/** PCNT_CH0_POS_MODE_U0 : R/W; bitpos: [19:18]; default: 0; + * This register sets the behavior when the signal input of channel 0 detects a + * positive edge. + * + * 1: Increase the counter;2: Decrease the counter;0, 3: No effect on counter + */ +#define PCNT_CH0_POS_MODE_U0 0x00000003U +#define PCNT_CH0_POS_MODE_U0_M (PCNT_CH0_POS_MODE_U0_V << PCNT_CH0_POS_MODE_U0_S) +#define PCNT_CH0_POS_MODE_U0_V 0x00000003U +#define PCNT_CH0_POS_MODE_U0_S 18 +/** PCNT_CH0_HCTRL_MODE_U0 : R/W; bitpos: [21:20]; default: 0; + * This register configures how the CH0_POS_MODE/CH0_NEG_MODE settings will be + * modified when the control signal is high. + * + * 0: No modification;1: Invert behavior (increase -> decrease, decrease -> + * increase);2, 3: Inhibit counter modification + */ +#define PCNT_CH0_HCTRL_MODE_U0 0x00000003U +#define PCNT_CH0_HCTRL_MODE_U0_M (PCNT_CH0_HCTRL_MODE_U0_V << PCNT_CH0_HCTRL_MODE_U0_S) +#define PCNT_CH0_HCTRL_MODE_U0_V 0x00000003U +#define PCNT_CH0_HCTRL_MODE_U0_S 20 +/** PCNT_CH0_LCTRL_MODE_U0 : R/W; bitpos: [23:22]; default: 0; + * This register configures how the CH0_POS_MODE/CH0_NEG_MODE settings will be + * modified when the control signal is low. + * + * 0: No modification;1: Invert behavior (increase -> decrease, decrease -> + * increase);2, 3: Inhibit counter modification + */ +#define PCNT_CH0_LCTRL_MODE_U0 0x00000003U +#define PCNT_CH0_LCTRL_MODE_U0_M (PCNT_CH0_LCTRL_MODE_U0_V << PCNT_CH0_LCTRL_MODE_U0_S) +#define PCNT_CH0_LCTRL_MODE_U0_V 0x00000003U +#define PCNT_CH0_LCTRL_MODE_U0_S 22 +/** PCNT_CH1_NEG_MODE_U0 : R/W; bitpos: [25:24]; default: 0; + * This register sets the behavior when the signal input of channel 1 detects a + * negative edge. + * + * 1: Increment the counter;2: Decrement the counter;0, 3: No effect on counter + */ +#define PCNT_CH1_NEG_MODE_U0 0x00000003U +#define PCNT_CH1_NEG_MODE_U0_M (PCNT_CH1_NEG_MODE_U0_V << PCNT_CH1_NEG_MODE_U0_S) +#define PCNT_CH1_NEG_MODE_U0_V 0x00000003U +#define PCNT_CH1_NEG_MODE_U0_S 24 +/** PCNT_CH1_POS_MODE_U0 : R/W; bitpos: [27:26]; default: 0; + * This register sets the behavior when the signal input of channel 1 detects a + * positive edge. + * + * 1: Increment the counter;2: Decrement the counter;0, 3: No effect on counter + */ +#define PCNT_CH1_POS_MODE_U0 0x00000003U +#define PCNT_CH1_POS_MODE_U0_M (PCNT_CH1_POS_MODE_U0_V << PCNT_CH1_POS_MODE_U0_S) +#define PCNT_CH1_POS_MODE_U0_V 0x00000003U +#define PCNT_CH1_POS_MODE_U0_S 26 +/** PCNT_CH1_HCTRL_MODE_U0 : R/W; bitpos: [29:28]; default: 0; + * This register configures how the CH0_POS_MODE/CH0_NEG_MODE settings will be + * modified when the control signal is high. + * + * 0: No modification;1: Invert behavior (increase -> decrease, decrease -> + * increase);2, 3: Inhibit counter modification + */ +#define PCNT_CH1_HCTRL_MODE_U0 0x00000003U +#define PCNT_CH1_HCTRL_MODE_U0_M (PCNT_CH1_HCTRL_MODE_U0_V << PCNT_CH1_HCTRL_MODE_U0_S) +#define PCNT_CH1_HCTRL_MODE_U0_V 0x00000003U +#define PCNT_CH1_HCTRL_MODE_U0_S 28 +/** PCNT_CH1_LCTRL_MODE_U0 : R/W; bitpos: [31:30]; default: 0; + * This register configures how the CH0_POS_MODE/CH0_NEG_MODE settings will be + * modified when the control signal is low. + * + * 0: No modification;1: Invert behavior (increase -> decrease, decrease -> + * increase);2, 3: Inhibit counter modification + */ +#define PCNT_CH1_LCTRL_MODE_U0 0x00000003U +#define PCNT_CH1_LCTRL_MODE_U0_M (PCNT_CH1_LCTRL_MODE_U0_V << PCNT_CH1_LCTRL_MODE_U0_S) +#define PCNT_CH1_LCTRL_MODE_U0_V 0x00000003U +#define PCNT_CH1_LCTRL_MODE_U0_S 30 -#define PCNT_U0_CONF1_REG (DR_REG_PCNT_BASE + 0x0004) -/* PCNT_CNT_THRES1_U0 : R/W ;bitpos:[31:16] ;default: 10'h0 ; */ -/*description: */ -#define PCNT_CNT_THRES1_U0 0x0000FFFF -#define PCNT_CNT_THRES1_U0_M ((PCNT_CNT_THRES1_U0_V)<<(PCNT_CNT_THRES1_U0_S)) -#define PCNT_CNT_THRES1_U0_V 0xFFFF -#define PCNT_CNT_THRES1_U0_S 16 -/* PCNT_CNT_THRES0_U0 : R/W ;bitpos:[15:0] ;default: 10'h0 ; */ -/*description: */ -#define PCNT_CNT_THRES0_U0 0x0000FFFF -#define PCNT_CNT_THRES0_U0_M ((PCNT_CNT_THRES0_U0_V)<<(PCNT_CNT_THRES0_U0_S)) -#define PCNT_CNT_THRES0_U0_V 0xFFFF +/** PCNT_U0_CONF1_REG register + * Configuration register 1 for unit 0 + */ +#define PCNT_U0_CONF1_REG (DR_REG_PCNT_BASE + 0x4) +/** PCNT_CNT_THRES0_U0 : R/W; bitpos: [15:0]; default: 0; + * This register is used to configure the thres0 value for unit 0. + */ +#define PCNT_CNT_THRES0_U0 0x0000FFFFU +#define PCNT_CNT_THRES0_U0_M (PCNT_CNT_THRES0_U0_V << PCNT_CNT_THRES0_U0_S) +#define PCNT_CNT_THRES0_U0_V 0x0000FFFFU #define PCNT_CNT_THRES0_U0_S 0 +/** PCNT_CNT_THRES1_U0 : R/W; bitpos: [31:16]; default: 0; + * This register is used to configure the thres1 value for unit 0. + */ +#define PCNT_CNT_THRES1_U0 0x0000FFFFU +#define PCNT_CNT_THRES1_U0_M (PCNT_CNT_THRES1_U0_V << PCNT_CNT_THRES1_U0_S) +#define PCNT_CNT_THRES1_U0_V 0x0000FFFFU +#define PCNT_CNT_THRES1_U0_S 16 -#define PCNT_U0_CONF2_REG (DR_REG_PCNT_BASE + 0x0008) -/* PCNT_CNT_L_LIM_U0 : R/W ;bitpos:[31:16] ;default: 10'h0 ; */ -/*description: */ -#define PCNT_CNT_L_LIM_U0 0x0000FFFF -#define PCNT_CNT_L_LIM_U0_M ((PCNT_CNT_L_LIM_U0_V)<<(PCNT_CNT_L_LIM_U0_S)) -#define PCNT_CNT_L_LIM_U0_V 0xFFFF -#define PCNT_CNT_L_LIM_U0_S 16 -/* PCNT_CNT_H_LIM_U0 : R/W ;bitpos:[15:0] ;default: 10'h0 ; */ -/*description: */ -#define PCNT_CNT_H_LIM_U0 0x0000FFFF -#define PCNT_CNT_H_LIM_U0_M ((PCNT_CNT_H_LIM_U0_V)<<(PCNT_CNT_H_LIM_U0_S)) -#define PCNT_CNT_H_LIM_U0_V 0xFFFF +/** PCNT_U0_CONF2_REG register + * Configuration register 2 for unit 0 + */ +#define PCNT_U0_CONF2_REG (DR_REG_PCNT_BASE + 0x8) +/** PCNT_CNT_H_LIM_U0 : R/W; bitpos: [15:0]; default: 0; + * This register is used to configure the thr_h_lim value for unit 0. + */ +#define PCNT_CNT_H_LIM_U0 0x0000FFFFU +#define PCNT_CNT_H_LIM_U0_M (PCNT_CNT_H_LIM_U0_V << PCNT_CNT_H_LIM_U0_S) +#define PCNT_CNT_H_LIM_U0_V 0x0000FFFFU #define PCNT_CNT_H_LIM_U0_S 0 +/** PCNT_CNT_L_LIM_U0 : R/W; bitpos: [31:16]; default: 0; + * This register is used to configure the thr_l_lim value for unit 0. + */ +#define PCNT_CNT_L_LIM_U0 0x0000FFFFU +#define PCNT_CNT_L_LIM_U0_M (PCNT_CNT_L_LIM_U0_V << PCNT_CNT_L_LIM_U0_S) +#define PCNT_CNT_L_LIM_U0_V 0x0000FFFFU +#define PCNT_CNT_L_LIM_U0_S 16 -#define PCNT_U1_CONF0_REG (DR_REG_PCNT_BASE + 0x000c) -/* PCNT_CH1_LCTRL_MODE_U1 : R/W ;bitpos:[31:30] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH1_LCTRL_MODE_U1 0x00000003 -#define PCNT_CH1_LCTRL_MODE_U1_M ((PCNT_CH1_LCTRL_MODE_U1_V)<<(PCNT_CH1_LCTRL_MODE_U1_S)) -#define PCNT_CH1_LCTRL_MODE_U1_V 0x3 -#define PCNT_CH1_LCTRL_MODE_U1_S 30 -/* PCNT_CH1_HCTRL_MODE_U1 : R/W ;bitpos:[29:28] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH1_HCTRL_MODE_U1 0x00000003 -#define PCNT_CH1_HCTRL_MODE_U1_M ((PCNT_CH1_HCTRL_MODE_U1_V)<<(PCNT_CH1_HCTRL_MODE_U1_S)) -#define PCNT_CH1_HCTRL_MODE_U1_V 0x3 -#define PCNT_CH1_HCTRL_MODE_U1_S 28 -/* PCNT_CH1_POS_MODE_U1 : R/W ;bitpos:[27:26] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH1_POS_MODE_U1 0x00000003 -#define PCNT_CH1_POS_MODE_U1_M ((PCNT_CH1_POS_MODE_U1_V)<<(PCNT_CH1_POS_MODE_U1_S)) -#define PCNT_CH1_POS_MODE_U1_V 0x3 -#define PCNT_CH1_POS_MODE_U1_S 26 -/* PCNT_CH1_NEG_MODE_U1 : R/W ;bitpos:[25:24] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH1_NEG_MODE_U1 0x00000003 -#define PCNT_CH1_NEG_MODE_U1_M ((PCNT_CH1_NEG_MODE_U1_V)<<(PCNT_CH1_NEG_MODE_U1_S)) -#define PCNT_CH1_NEG_MODE_U1_V 0x3 -#define PCNT_CH1_NEG_MODE_U1_S 24 -/* PCNT_CH0_LCTRL_MODE_U1 : R/W ;bitpos:[23:22] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH0_LCTRL_MODE_U1 0x00000003 -#define PCNT_CH0_LCTRL_MODE_U1_M ((PCNT_CH0_LCTRL_MODE_U1_V)<<(PCNT_CH0_LCTRL_MODE_U1_S)) -#define PCNT_CH0_LCTRL_MODE_U1_V 0x3 -#define PCNT_CH0_LCTRL_MODE_U1_S 22 -/* PCNT_CH0_HCTRL_MODE_U1 : R/W ;bitpos:[21:20] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH0_HCTRL_MODE_U1 0x00000003 -#define PCNT_CH0_HCTRL_MODE_U1_M ((PCNT_CH0_HCTRL_MODE_U1_V)<<(PCNT_CH0_HCTRL_MODE_U1_S)) -#define PCNT_CH0_HCTRL_MODE_U1_V 0x3 -#define PCNT_CH0_HCTRL_MODE_U1_S 20 -/* PCNT_CH0_POS_MODE_U1 : R/W ;bitpos:[19:18] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH0_POS_MODE_U1 0x00000003 -#define PCNT_CH0_POS_MODE_U1_M ((PCNT_CH0_POS_MODE_U1_V)<<(PCNT_CH0_POS_MODE_U1_S)) -#define PCNT_CH0_POS_MODE_U1_V 0x3 -#define PCNT_CH0_POS_MODE_U1_S 18 -/* PCNT_CH0_NEG_MODE_U1 : R/W ;bitpos:[17:16] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH0_NEG_MODE_U1 0x00000003 -#define PCNT_CH0_NEG_MODE_U1_M ((PCNT_CH0_NEG_MODE_U1_V)<<(PCNT_CH0_NEG_MODE_U1_S)) -#define PCNT_CH0_NEG_MODE_U1_V 0x3 -#define PCNT_CH0_NEG_MODE_U1_S 16 -/* PCNT_THR_THRES1_EN_U1 : R/W ;bitpos:[15] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_THR_THRES1_EN_U1 (BIT(15)) -#define PCNT_THR_THRES1_EN_U1_M (BIT(15)) -#define PCNT_THR_THRES1_EN_U1_V 0x1 -#define PCNT_THR_THRES1_EN_U1_S 15 -/* PCNT_THR_THRES0_EN_U1 : R/W ;bitpos:[14] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_THR_THRES0_EN_U1 (BIT(14)) -#define PCNT_THR_THRES0_EN_U1_M (BIT(14)) -#define PCNT_THR_THRES0_EN_U1_V 0x1 -#define PCNT_THR_THRES0_EN_U1_S 14 -/* PCNT_THR_L_LIM_EN_U1 : R/W ;bitpos:[13] ;default: 1'b1 ; */ -/*description: */ -#define PCNT_THR_L_LIM_EN_U1 (BIT(13)) -#define PCNT_THR_L_LIM_EN_U1_M (BIT(13)) -#define PCNT_THR_L_LIM_EN_U1_V 0x1 -#define PCNT_THR_L_LIM_EN_U1_S 13 -/* PCNT_THR_H_LIM_EN_U1 : R/W ;bitpos:[12] ;default: 1'b1 ; */ -/*description: */ -#define PCNT_THR_H_LIM_EN_U1 (BIT(12)) -#define PCNT_THR_H_LIM_EN_U1_M (BIT(12)) -#define PCNT_THR_H_LIM_EN_U1_V 0x1 -#define PCNT_THR_H_LIM_EN_U1_S 12 -/* PCNT_THR_ZERO_EN_U1 : R/W ;bitpos:[11] ;default: 1'b1 ; */ -/*description: */ -#define PCNT_THR_ZERO_EN_U1 (BIT(11)) -#define PCNT_THR_ZERO_EN_U1_M (BIT(11)) -#define PCNT_THR_ZERO_EN_U1_V 0x1 -#define PCNT_THR_ZERO_EN_U1_S 11 -/* PCNT_FILTER_EN_U1 : R/W ;bitpos:[10] ;default: 1'b1 ; */ -/*description: */ -#define PCNT_FILTER_EN_U1 (BIT(10)) -#define PCNT_FILTER_EN_U1_M (BIT(10)) -#define PCNT_FILTER_EN_U1_V 0x1 -#define PCNT_FILTER_EN_U1_S 10 -/* PCNT_FILTER_THRES_U1 : R/W ;bitpos:[9:0] ;default: 10'h10 ; */ -/*description: */ -#define PCNT_FILTER_THRES_U1 0x000003FF -#define PCNT_FILTER_THRES_U1_M ((PCNT_FILTER_THRES_U1_V)<<(PCNT_FILTER_THRES_U1_S)) -#define PCNT_FILTER_THRES_U1_V 0x3FF +/** PCNT_U1_CONF0_REG register + * Configuration register 0 for unit 1 + */ +#define PCNT_U1_CONF0_REG (DR_REG_PCNT_BASE + 0xc) +/** PCNT_FILTER_THRES_U1 : R/W; bitpos: [9:0]; default: 16; + * This sets the maximum threshold, in APB_CLK cycles, for the filter. + * + * Any pulses with width less than this will be ignored when the filter is enabled. + */ +#define PCNT_FILTER_THRES_U1 0x000003FFU +#define PCNT_FILTER_THRES_U1_M (PCNT_FILTER_THRES_U1_V << PCNT_FILTER_THRES_U1_S) +#define PCNT_FILTER_THRES_U1_V 0x000003FFU #define PCNT_FILTER_THRES_U1_S 0 +/** PCNT_FILTER_EN_U1 : R/W; bitpos: [10]; default: 1; + * This is the enable bit for unit 1's input filter. + */ +#define PCNT_FILTER_EN_U1 (BIT(10)) +#define PCNT_FILTER_EN_U1_M (PCNT_FILTER_EN_U1_V << PCNT_FILTER_EN_U1_S) +#define PCNT_FILTER_EN_U1_V 0x00000001U +#define PCNT_FILTER_EN_U1_S 10 +/** PCNT_THR_ZERO_EN_U1 : R/W; bitpos: [11]; default: 1; + * This is the enable bit for unit 1's zero comparator. + */ +#define PCNT_THR_ZERO_EN_U1 (BIT(11)) +#define PCNT_THR_ZERO_EN_U1_M (PCNT_THR_ZERO_EN_U1_V << PCNT_THR_ZERO_EN_U1_S) +#define PCNT_THR_ZERO_EN_U1_V 0x00000001U +#define PCNT_THR_ZERO_EN_U1_S 11 +/** PCNT_THR_H_LIM_EN_U1 : R/W; bitpos: [12]; default: 1; + * This is the enable bit for unit 1's thr_h_lim comparator. + */ +#define PCNT_THR_H_LIM_EN_U1 (BIT(12)) +#define PCNT_THR_H_LIM_EN_U1_M (PCNT_THR_H_LIM_EN_U1_V << PCNT_THR_H_LIM_EN_U1_S) +#define PCNT_THR_H_LIM_EN_U1_V 0x00000001U +#define PCNT_THR_H_LIM_EN_U1_S 12 +/** PCNT_THR_L_LIM_EN_U1 : R/W; bitpos: [13]; default: 1; + * This is the enable bit for unit 1's thr_l_lim comparator. + */ +#define PCNT_THR_L_LIM_EN_U1 (BIT(13)) +#define PCNT_THR_L_LIM_EN_U1_M (PCNT_THR_L_LIM_EN_U1_V << PCNT_THR_L_LIM_EN_U1_S) +#define PCNT_THR_L_LIM_EN_U1_V 0x00000001U +#define PCNT_THR_L_LIM_EN_U1_S 13 +/** PCNT_THR_THRES0_EN_U1 : R/W; bitpos: [14]; default: 0; + * This is the enable bit for unit 1's thres0 comparator. + */ +#define PCNT_THR_THRES0_EN_U1 (BIT(14)) +#define PCNT_THR_THRES0_EN_U1_M (PCNT_THR_THRES0_EN_U1_V << PCNT_THR_THRES0_EN_U1_S) +#define PCNT_THR_THRES0_EN_U1_V 0x00000001U +#define PCNT_THR_THRES0_EN_U1_S 14 +/** PCNT_THR_THRES1_EN_U1 : R/W; bitpos: [15]; default: 0; + * This is the enable bit for unit 1's thres1 comparator. + */ +#define PCNT_THR_THRES1_EN_U1 (BIT(15)) +#define PCNT_THR_THRES1_EN_U1_M (PCNT_THR_THRES1_EN_U1_V << PCNT_THR_THRES1_EN_U1_S) +#define PCNT_THR_THRES1_EN_U1_V 0x00000001U +#define PCNT_THR_THRES1_EN_U1_S 15 +/** PCNT_CH0_NEG_MODE_U1 : R/W; bitpos: [17:16]; default: 0; + * This register sets the behavior when the signal input of channel 0 detects a + * negative edge. + * + * 1: Increase the counter;2: Decrease the counter;0, 3: No effect on counter + */ +#define PCNT_CH0_NEG_MODE_U1 0x00000003U +#define PCNT_CH0_NEG_MODE_U1_M (PCNT_CH0_NEG_MODE_U1_V << PCNT_CH0_NEG_MODE_U1_S) +#define PCNT_CH0_NEG_MODE_U1_V 0x00000003U +#define PCNT_CH0_NEG_MODE_U1_S 16 +/** PCNT_CH0_POS_MODE_U1 : R/W; bitpos: [19:18]; default: 0; + * This register sets the behavior when the signal input of channel 0 detects a + * positive edge. + * + * 1: Increase the counter;2: Decrease the counter;0, 3: No effect on counter + */ +#define PCNT_CH0_POS_MODE_U1 0x00000003U +#define PCNT_CH0_POS_MODE_U1_M (PCNT_CH0_POS_MODE_U1_V << PCNT_CH0_POS_MODE_U1_S) +#define PCNT_CH0_POS_MODE_U1_V 0x00000003U +#define PCNT_CH0_POS_MODE_U1_S 18 +/** PCNT_CH0_HCTRL_MODE_U1 : R/W; bitpos: [21:20]; default: 0; + * This register configures how the CH1_POS_MODE/CH1_NEG_MODE settings will be + * modified when the control signal is high. + * + * 0: No modification;1: Invert behavior (increase -> decrease, decrease -> + * increase);2, 3: Inhibit counter modification + */ +#define PCNT_CH0_HCTRL_MODE_U1 0x00000003U +#define PCNT_CH0_HCTRL_MODE_U1_M (PCNT_CH0_HCTRL_MODE_U1_V << PCNT_CH0_HCTRL_MODE_U1_S) +#define PCNT_CH0_HCTRL_MODE_U1_V 0x00000003U +#define PCNT_CH0_HCTRL_MODE_U1_S 20 +/** PCNT_CH0_LCTRL_MODE_U1 : R/W; bitpos: [23:22]; default: 0; + * This register configures how the CH1_POS_MODE/CH1_NEG_MODE settings will be + * modified when the control signal is low. + * + * 0: No modification;1: Invert behavior (increase -> decrease, decrease -> + * increase);2, 3: Inhibit counter modification + */ +#define PCNT_CH0_LCTRL_MODE_U1 0x00000003U +#define PCNT_CH0_LCTRL_MODE_U1_M (PCNT_CH0_LCTRL_MODE_U1_V << PCNT_CH0_LCTRL_MODE_U1_S) +#define PCNT_CH0_LCTRL_MODE_U1_V 0x00000003U +#define PCNT_CH0_LCTRL_MODE_U1_S 22 +/** PCNT_CH1_NEG_MODE_U1 : R/W; bitpos: [25:24]; default: 0; + * This register sets the behavior when the signal input of channel 1 detects a + * negative edge. + * + * 1: Increment the counter;2: Decrement the counter;0, 3: No effect on counter + */ +#define PCNT_CH1_NEG_MODE_U1 0x00000003U +#define PCNT_CH1_NEG_MODE_U1_M (PCNT_CH1_NEG_MODE_U1_V << PCNT_CH1_NEG_MODE_U1_S) +#define PCNT_CH1_NEG_MODE_U1_V 0x00000003U +#define PCNT_CH1_NEG_MODE_U1_S 24 +/** PCNT_CH1_POS_MODE_U1 : R/W; bitpos: [27:26]; default: 0; + * This register sets the behavior when the signal input of channel 1 detects a + * positive edge. + * + * 1: Increment the counter;2: Decrement the counter;0, 3: No effect on counter + */ +#define PCNT_CH1_POS_MODE_U1 0x00000003U +#define PCNT_CH1_POS_MODE_U1_M (PCNT_CH1_POS_MODE_U1_V << PCNT_CH1_POS_MODE_U1_S) +#define PCNT_CH1_POS_MODE_U1_V 0x00000003U +#define PCNT_CH1_POS_MODE_U1_S 26 +/** PCNT_CH1_HCTRL_MODE_U1 : R/W; bitpos: [29:28]; default: 0; + * This register configures how the CH1_POS_MODE/CH1_NEG_MODE settings will be + * modified when the control signal is high. + * + * 0: No modification;1: Invert behavior (increase -> decrease, decrease -> + * increase);2, 3: Inhibit counter modification + */ +#define PCNT_CH1_HCTRL_MODE_U1 0x00000003U +#define PCNT_CH1_HCTRL_MODE_U1_M (PCNT_CH1_HCTRL_MODE_U1_V << PCNT_CH1_HCTRL_MODE_U1_S) +#define PCNT_CH1_HCTRL_MODE_U1_V 0x00000003U +#define PCNT_CH1_HCTRL_MODE_U1_S 28 +/** PCNT_CH1_LCTRL_MODE_U1 : R/W; bitpos: [31:30]; default: 0; + * This register configures how the CH1_POS_MODE/CH1_NEG_MODE settings will be + * modified when the control signal is low. + * + * 0: No modification;1: Invert behavior (increase -> decrease, decrease -> + * increase);2, 3: Inhibit counter modification + */ +#define PCNT_CH1_LCTRL_MODE_U1 0x00000003U +#define PCNT_CH1_LCTRL_MODE_U1_M (PCNT_CH1_LCTRL_MODE_U1_V << PCNT_CH1_LCTRL_MODE_U1_S) +#define PCNT_CH1_LCTRL_MODE_U1_V 0x00000003U +#define PCNT_CH1_LCTRL_MODE_U1_S 30 -#define PCNT_U1_CONF1_REG (DR_REG_PCNT_BASE + 0x0010) -/* PCNT_CNT_THRES1_U1 : R/W ;bitpos:[31:16] ;default: 10'h0 ; */ -/*description: */ -#define PCNT_CNT_THRES1_U1 0x0000FFFF -#define PCNT_CNT_THRES1_U1_M ((PCNT_CNT_THRES1_U1_V)<<(PCNT_CNT_THRES1_U1_S)) -#define PCNT_CNT_THRES1_U1_V 0xFFFF -#define PCNT_CNT_THRES1_U1_S 16 -/* PCNT_CNT_THRES0_U1 : R/W ;bitpos:[15:0] ;default: 10'h0 ; */ -/*description: */ -#define PCNT_CNT_THRES0_U1 0x0000FFFF -#define PCNT_CNT_THRES0_U1_M ((PCNT_CNT_THRES0_U1_V)<<(PCNT_CNT_THRES0_U1_S)) -#define PCNT_CNT_THRES0_U1_V 0xFFFF +/** PCNT_U1_CONF1_REG register + * Configuration register 1 for unit 1 + */ +#define PCNT_U1_CONF1_REG (DR_REG_PCNT_BASE + 0x10) +/** PCNT_CNT_THRES0_U1 : R/W; bitpos: [15:0]; default: 0; + * This register is used to configure the thres0 value for unit 1. + */ +#define PCNT_CNT_THRES0_U1 0x0000FFFFU +#define PCNT_CNT_THRES0_U1_M (PCNT_CNT_THRES0_U1_V << PCNT_CNT_THRES0_U1_S) +#define PCNT_CNT_THRES0_U1_V 0x0000FFFFU #define PCNT_CNT_THRES0_U1_S 0 +/** PCNT_CNT_THRES1_U1 : R/W; bitpos: [31:16]; default: 0; + * This register is used to configure the thres1 value for unit 1. + */ +#define PCNT_CNT_THRES1_U1 0x0000FFFFU +#define PCNT_CNT_THRES1_U1_M (PCNT_CNT_THRES1_U1_V << PCNT_CNT_THRES1_U1_S) +#define PCNT_CNT_THRES1_U1_V 0x0000FFFFU +#define PCNT_CNT_THRES1_U1_S 16 -#define PCNT_U1_CONF2_REG (DR_REG_PCNT_BASE + 0x0014) -/* PCNT_CNT_L_LIM_U1 : R/W ;bitpos:[31:16] ;default: 10'h0 ; */ -/*description: */ -#define PCNT_CNT_L_LIM_U1 0x0000FFFF -#define PCNT_CNT_L_LIM_U1_M ((PCNT_CNT_L_LIM_U1_V)<<(PCNT_CNT_L_LIM_U1_S)) -#define PCNT_CNT_L_LIM_U1_V 0xFFFF -#define PCNT_CNT_L_LIM_U1_S 16 -/* PCNT_CNT_H_LIM_U1 : R/W ;bitpos:[15:0] ;default: 10'h0 ; */ -/*description: */ -#define PCNT_CNT_H_LIM_U1 0x0000FFFF -#define PCNT_CNT_H_LIM_U1_M ((PCNT_CNT_H_LIM_U1_V)<<(PCNT_CNT_H_LIM_U1_S)) -#define PCNT_CNT_H_LIM_U1_V 0xFFFF +/** PCNT_U1_CONF2_REG register + * Configuration register 2 for unit 1 + */ +#define PCNT_U1_CONF2_REG (DR_REG_PCNT_BASE + 0x14) +/** PCNT_CNT_H_LIM_U1 : R/W; bitpos: [15:0]; default: 0; + * This register is used to configure the thr_h_lim value for unit 1. + */ +#define PCNT_CNT_H_LIM_U1 0x0000FFFFU +#define PCNT_CNT_H_LIM_U1_M (PCNT_CNT_H_LIM_U1_V << PCNT_CNT_H_LIM_U1_S) +#define PCNT_CNT_H_LIM_U1_V 0x0000FFFFU #define PCNT_CNT_H_LIM_U1_S 0 +/** PCNT_CNT_L_LIM_U1 : R/W; bitpos: [31:16]; default: 0; + * This register is used to configure the thr_l_lim value for unit 1. + */ +#define PCNT_CNT_L_LIM_U1 0x0000FFFFU +#define PCNT_CNT_L_LIM_U1_M (PCNT_CNT_L_LIM_U1_V << PCNT_CNT_L_LIM_U1_S) +#define PCNT_CNT_L_LIM_U1_V 0x0000FFFFU +#define PCNT_CNT_L_LIM_U1_S 16 -#define PCNT_U2_CONF0_REG (DR_REG_PCNT_BASE + 0x0018) -/* PCNT_CH1_LCTRL_MODE_U2 : R/W ;bitpos:[31:30] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH1_LCTRL_MODE_U2 0x00000003 -#define PCNT_CH1_LCTRL_MODE_U2_M ((PCNT_CH1_LCTRL_MODE_U2_V)<<(PCNT_CH1_LCTRL_MODE_U2_S)) -#define PCNT_CH1_LCTRL_MODE_U2_V 0x3 -#define PCNT_CH1_LCTRL_MODE_U2_S 30 -/* PCNT_CH1_HCTRL_MODE_U2 : R/W ;bitpos:[29:28] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH1_HCTRL_MODE_U2 0x00000003 -#define PCNT_CH1_HCTRL_MODE_U2_M ((PCNT_CH1_HCTRL_MODE_U2_V)<<(PCNT_CH1_HCTRL_MODE_U2_S)) -#define PCNT_CH1_HCTRL_MODE_U2_V 0x3 -#define PCNT_CH1_HCTRL_MODE_U2_S 28 -/* PCNT_CH1_POS_MODE_U2 : R/W ;bitpos:[27:26] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH1_POS_MODE_U2 0x00000003 -#define PCNT_CH1_POS_MODE_U2_M ((PCNT_CH1_POS_MODE_U2_V)<<(PCNT_CH1_POS_MODE_U2_S)) -#define PCNT_CH1_POS_MODE_U2_V 0x3 -#define PCNT_CH1_POS_MODE_U2_S 26 -/* PCNT_CH1_NEG_MODE_U2 : R/W ;bitpos:[25:24] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH1_NEG_MODE_U2 0x00000003 -#define PCNT_CH1_NEG_MODE_U2_M ((PCNT_CH1_NEG_MODE_U2_V)<<(PCNT_CH1_NEG_MODE_U2_S)) -#define PCNT_CH1_NEG_MODE_U2_V 0x3 -#define PCNT_CH1_NEG_MODE_U2_S 24 -/* PCNT_CH0_LCTRL_MODE_U2 : R/W ;bitpos:[23:22] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH0_LCTRL_MODE_U2 0x00000003 -#define PCNT_CH0_LCTRL_MODE_U2_M ((PCNT_CH0_LCTRL_MODE_U2_V)<<(PCNT_CH0_LCTRL_MODE_U2_S)) -#define PCNT_CH0_LCTRL_MODE_U2_V 0x3 -#define PCNT_CH0_LCTRL_MODE_U2_S 22 -/* PCNT_CH0_HCTRL_MODE_U2 : R/W ;bitpos:[21:20] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH0_HCTRL_MODE_U2 0x00000003 -#define PCNT_CH0_HCTRL_MODE_U2_M ((PCNT_CH0_HCTRL_MODE_U2_V)<<(PCNT_CH0_HCTRL_MODE_U2_S)) -#define PCNT_CH0_HCTRL_MODE_U2_V 0x3 -#define PCNT_CH0_HCTRL_MODE_U2_S 20 -/* PCNT_CH0_POS_MODE_U2 : R/W ;bitpos:[19:18] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH0_POS_MODE_U2 0x00000003 -#define PCNT_CH0_POS_MODE_U2_M ((PCNT_CH0_POS_MODE_U2_V)<<(PCNT_CH0_POS_MODE_U2_S)) -#define PCNT_CH0_POS_MODE_U2_V 0x3 -#define PCNT_CH0_POS_MODE_U2_S 18 -/* PCNT_CH0_NEG_MODE_U2 : R/W ;bitpos:[17:16] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH0_NEG_MODE_U2 0x00000003 -#define PCNT_CH0_NEG_MODE_U2_M ((PCNT_CH0_NEG_MODE_U2_V)<<(PCNT_CH0_NEG_MODE_U2_S)) -#define PCNT_CH0_NEG_MODE_U2_V 0x3 -#define PCNT_CH0_NEG_MODE_U2_S 16 -/* PCNT_THR_THRES1_EN_U2 : R/W ;bitpos:[15] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_THR_THRES1_EN_U2 (BIT(15)) -#define PCNT_THR_THRES1_EN_U2_M (BIT(15)) -#define PCNT_THR_THRES1_EN_U2_V 0x1 -#define PCNT_THR_THRES1_EN_U2_S 15 -/* PCNT_THR_THRES0_EN_U2 : R/W ;bitpos:[14] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_THR_THRES0_EN_U2 (BIT(14)) -#define PCNT_THR_THRES0_EN_U2_M (BIT(14)) -#define PCNT_THR_THRES0_EN_U2_V 0x1 -#define PCNT_THR_THRES0_EN_U2_S 14 -/* PCNT_THR_L_LIM_EN_U2 : R/W ;bitpos:[13] ;default: 1'b1 ; */ -/*description: */ -#define PCNT_THR_L_LIM_EN_U2 (BIT(13)) -#define PCNT_THR_L_LIM_EN_U2_M (BIT(13)) -#define PCNT_THR_L_LIM_EN_U2_V 0x1 -#define PCNT_THR_L_LIM_EN_U2_S 13 -/* PCNT_THR_H_LIM_EN_U2 : R/W ;bitpos:[12] ;default: 1'b1 ; */ -/*description: */ -#define PCNT_THR_H_LIM_EN_U2 (BIT(12)) -#define PCNT_THR_H_LIM_EN_U2_M (BIT(12)) -#define PCNT_THR_H_LIM_EN_U2_V 0x1 -#define PCNT_THR_H_LIM_EN_U2_S 12 -/* PCNT_THR_ZERO_EN_U2 : R/W ;bitpos:[11] ;default: 1'b1 ; */ -/*description: */ -#define PCNT_THR_ZERO_EN_U2 (BIT(11)) -#define PCNT_THR_ZERO_EN_U2_M (BIT(11)) -#define PCNT_THR_ZERO_EN_U2_V 0x1 -#define PCNT_THR_ZERO_EN_U2_S 11 -/* PCNT_FILTER_EN_U2 : R/W ;bitpos:[10] ;default: 1'b1 ; */ -/*description: */ -#define PCNT_FILTER_EN_U2 (BIT(10)) -#define PCNT_FILTER_EN_U2_M (BIT(10)) -#define PCNT_FILTER_EN_U2_V 0x1 -#define PCNT_FILTER_EN_U2_S 10 -/* PCNT_FILTER_THRES_U2 : R/W ;bitpos:[9:0] ;default: 10'h10 ; */ -/*description: */ -#define PCNT_FILTER_THRES_U2 0x000003FF -#define PCNT_FILTER_THRES_U2_M ((PCNT_FILTER_THRES_U2_V)<<(PCNT_FILTER_THRES_U2_S)) -#define PCNT_FILTER_THRES_U2_V 0x3FF +/** PCNT_U2_CONF0_REG register + * Configuration register 0 for unit 2 + */ +#define PCNT_U2_CONF0_REG (DR_REG_PCNT_BASE + 0x18) +/** PCNT_FILTER_THRES_U2 : R/W; bitpos: [9:0]; default: 16; + * This sets the maximum threshold, in APB_CLK cycles, for the filter. + * + * Any pulses with width less than this will be ignored when the filter is enabled. + */ +#define PCNT_FILTER_THRES_U2 0x000003FFU +#define PCNT_FILTER_THRES_U2_M (PCNT_FILTER_THRES_U2_V << PCNT_FILTER_THRES_U2_S) +#define PCNT_FILTER_THRES_U2_V 0x000003FFU #define PCNT_FILTER_THRES_U2_S 0 +/** PCNT_FILTER_EN_U2 : R/W; bitpos: [10]; default: 1; + * This is the enable bit for unit 2's input filter. + */ +#define PCNT_FILTER_EN_U2 (BIT(10)) +#define PCNT_FILTER_EN_U2_M (PCNT_FILTER_EN_U2_V << PCNT_FILTER_EN_U2_S) +#define PCNT_FILTER_EN_U2_V 0x00000001U +#define PCNT_FILTER_EN_U2_S 10 +/** PCNT_THR_ZERO_EN_U2 : R/W; bitpos: [11]; default: 1; + * This is the enable bit for unit 2's zero comparator. + */ +#define PCNT_THR_ZERO_EN_U2 (BIT(11)) +#define PCNT_THR_ZERO_EN_U2_M (PCNT_THR_ZERO_EN_U2_V << PCNT_THR_ZERO_EN_U2_S) +#define PCNT_THR_ZERO_EN_U2_V 0x00000001U +#define PCNT_THR_ZERO_EN_U2_S 11 +/** PCNT_THR_H_LIM_EN_U2 : R/W; bitpos: [12]; default: 1; + * This is the enable bit for unit 2's thr_h_lim comparator. + */ +#define PCNT_THR_H_LIM_EN_U2 (BIT(12)) +#define PCNT_THR_H_LIM_EN_U2_M (PCNT_THR_H_LIM_EN_U2_V << PCNT_THR_H_LIM_EN_U2_S) +#define PCNT_THR_H_LIM_EN_U2_V 0x00000001U +#define PCNT_THR_H_LIM_EN_U2_S 12 +/** PCNT_THR_L_LIM_EN_U2 : R/W; bitpos: [13]; default: 1; + * This is the enable bit for unit 2's thr_l_lim comparator. + */ +#define PCNT_THR_L_LIM_EN_U2 (BIT(13)) +#define PCNT_THR_L_LIM_EN_U2_M (PCNT_THR_L_LIM_EN_U2_V << PCNT_THR_L_LIM_EN_U2_S) +#define PCNT_THR_L_LIM_EN_U2_V 0x00000001U +#define PCNT_THR_L_LIM_EN_U2_S 13 +/** PCNT_THR_THRES0_EN_U2 : R/W; bitpos: [14]; default: 0; + * This is the enable bit for unit 2's thres0 comparator. + */ +#define PCNT_THR_THRES0_EN_U2 (BIT(14)) +#define PCNT_THR_THRES0_EN_U2_M (PCNT_THR_THRES0_EN_U2_V << PCNT_THR_THRES0_EN_U2_S) +#define PCNT_THR_THRES0_EN_U2_V 0x00000001U +#define PCNT_THR_THRES0_EN_U2_S 14 +/** PCNT_THR_THRES1_EN_U2 : R/W; bitpos: [15]; default: 0; + * This is the enable bit for unit 2's thres1 comparator. + */ +#define PCNT_THR_THRES1_EN_U2 (BIT(15)) +#define PCNT_THR_THRES1_EN_U2_M (PCNT_THR_THRES1_EN_U2_V << PCNT_THR_THRES1_EN_U2_S) +#define PCNT_THR_THRES1_EN_U2_V 0x00000001U +#define PCNT_THR_THRES1_EN_U2_S 15 +/** PCNT_CH0_NEG_MODE_U2 : R/W; bitpos: [17:16]; default: 0; + * This register sets the behavior when the signal input of channel 0 detects a + * negative edge. + * + * 1: Increase the counter;2: Decrease the counter;0, 3: No effect on counter + */ +#define PCNT_CH0_NEG_MODE_U2 0x00000003U +#define PCNT_CH0_NEG_MODE_U2_M (PCNT_CH0_NEG_MODE_U2_V << PCNT_CH0_NEG_MODE_U2_S) +#define PCNT_CH0_NEG_MODE_U2_V 0x00000003U +#define PCNT_CH0_NEG_MODE_U2_S 16 +/** PCNT_CH0_POS_MODE_U2 : R/W; bitpos: [19:18]; default: 0; + * This register sets the behavior when the signal input of channel 0 detects a + * positive edge. + * + * 1: Increase the counter;2: Decrease the counter;0, 3: No effect on counter + */ +#define PCNT_CH0_POS_MODE_U2 0x00000003U +#define PCNT_CH0_POS_MODE_U2_M (PCNT_CH0_POS_MODE_U2_V << PCNT_CH0_POS_MODE_U2_S) +#define PCNT_CH0_POS_MODE_U2_V 0x00000003U +#define PCNT_CH0_POS_MODE_U2_S 18 +/** PCNT_CH0_HCTRL_MODE_U2 : R/W; bitpos: [21:20]; default: 0; + * This register configures how the CH2_POS_MODE/CH2_NEG_MODE settings will be + * modified when the control signal is high. + * + * 0: No modification;1: Invert behavior (increase -> decrease, decrease -> + * increase);2, 3: Inhibit counter modification + */ +#define PCNT_CH0_HCTRL_MODE_U2 0x00000003U +#define PCNT_CH0_HCTRL_MODE_U2_M (PCNT_CH0_HCTRL_MODE_U2_V << PCNT_CH0_HCTRL_MODE_U2_S) +#define PCNT_CH0_HCTRL_MODE_U2_V 0x00000003U +#define PCNT_CH0_HCTRL_MODE_U2_S 20 +/** PCNT_CH0_LCTRL_MODE_U2 : R/W; bitpos: [23:22]; default: 0; + * This register configures how the CH2_POS_MODE/CH2_NEG_MODE settings will be + * modified when the control signal is low. + * + * 0: No modification;1: Invert behavior (increase -> decrease, decrease -> + * increase);2, 3: Inhibit counter modification + */ +#define PCNT_CH0_LCTRL_MODE_U2 0x00000003U +#define PCNT_CH0_LCTRL_MODE_U2_M (PCNT_CH0_LCTRL_MODE_U2_V << PCNT_CH0_LCTRL_MODE_U2_S) +#define PCNT_CH0_LCTRL_MODE_U2_V 0x00000003U +#define PCNT_CH0_LCTRL_MODE_U2_S 22 +/** PCNT_CH1_NEG_MODE_U2 : R/W; bitpos: [25:24]; default: 0; + * This register sets the behavior when the signal input of channel 1 detects a + * negative edge. + * + * 1: Increment the counter;2: Decrement the counter;0, 3: No effect on counter + */ +#define PCNT_CH1_NEG_MODE_U2 0x00000003U +#define PCNT_CH1_NEG_MODE_U2_M (PCNT_CH1_NEG_MODE_U2_V << PCNT_CH1_NEG_MODE_U2_S) +#define PCNT_CH1_NEG_MODE_U2_V 0x00000003U +#define PCNT_CH1_NEG_MODE_U2_S 24 +/** PCNT_CH1_POS_MODE_U2 : R/W; bitpos: [27:26]; default: 0; + * This register sets the behavior when the signal input of channel 1 detects a + * positive edge. + * + * 1: Increment the counter;2: Decrement the counter;0, 3: No effect on counter + */ +#define PCNT_CH1_POS_MODE_U2 0x00000003U +#define PCNT_CH1_POS_MODE_U2_M (PCNT_CH1_POS_MODE_U2_V << PCNT_CH1_POS_MODE_U2_S) +#define PCNT_CH1_POS_MODE_U2_V 0x00000003U +#define PCNT_CH1_POS_MODE_U2_S 26 +/** PCNT_CH1_HCTRL_MODE_U2 : R/W; bitpos: [29:28]; default: 0; + * This register configures how the CH2_POS_MODE/CH2_NEG_MODE settings will be + * modified when the control signal is high. + * + * 0: No modification;1: Invert behavior (increase -> decrease, decrease -> + * increase);2, 3: Inhibit counter modification + */ +#define PCNT_CH1_HCTRL_MODE_U2 0x00000003U +#define PCNT_CH1_HCTRL_MODE_U2_M (PCNT_CH1_HCTRL_MODE_U2_V << PCNT_CH1_HCTRL_MODE_U2_S) +#define PCNT_CH1_HCTRL_MODE_U2_V 0x00000003U +#define PCNT_CH1_HCTRL_MODE_U2_S 28 +/** PCNT_CH1_LCTRL_MODE_U2 : R/W; bitpos: [31:30]; default: 0; + * This register configures how the CH2_POS_MODE/CH2_NEG_MODE settings will be + * modified when the control signal is low. + * + * 0: No modification;1: Invert behavior (increase -> decrease, decrease -> + * increase);2, 3: Inhibit counter modification + */ +#define PCNT_CH1_LCTRL_MODE_U2 0x00000003U +#define PCNT_CH1_LCTRL_MODE_U2_M (PCNT_CH1_LCTRL_MODE_U2_V << PCNT_CH1_LCTRL_MODE_U2_S) +#define PCNT_CH1_LCTRL_MODE_U2_V 0x00000003U +#define PCNT_CH1_LCTRL_MODE_U2_S 30 -#define PCNT_U2_CONF1_REG (DR_REG_PCNT_BASE + 0x001c) -/* PCNT_CNT_THRES1_U2 : R/W ;bitpos:[31:16] ;default: 10'h0 ; */ -/*description: */ -#define PCNT_CNT_THRES1_U2 0x0000FFFF -#define PCNT_CNT_THRES1_U2_M ((PCNT_CNT_THRES1_U2_V)<<(PCNT_CNT_THRES1_U2_S)) -#define PCNT_CNT_THRES1_U2_V 0xFFFF -#define PCNT_CNT_THRES1_U2_S 16 -/* PCNT_CNT_THRES0_U2 : R/W ;bitpos:[15:0] ;default: 10'h0 ; */ -/*description: */ -#define PCNT_CNT_THRES0_U2 0x0000FFFF -#define PCNT_CNT_THRES0_U2_M ((PCNT_CNT_THRES0_U2_V)<<(PCNT_CNT_THRES0_U2_S)) -#define PCNT_CNT_THRES0_U2_V 0xFFFF +/** PCNT_U2_CONF1_REG register + * Configuration register 1 for unit 2 + */ +#define PCNT_U2_CONF1_REG (DR_REG_PCNT_BASE + 0x1c) +/** PCNT_CNT_THRES0_U2 : R/W; bitpos: [15:0]; default: 0; + * This register is used to configure the thres0 value for unit 2. + */ +#define PCNT_CNT_THRES0_U2 0x0000FFFFU +#define PCNT_CNT_THRES0_U2_M (PCNT_CNT_THRES0_U2_V << PCNT_CNT_THRES0_U2_S) +#define PCNT_CNT_THRES0_U2_V 0x0000FFFFU #define PCNT_CNT_THRES0_U2_S 0 +/** PCNT_CNT_THRES1_U2 : R/W; bitpos: [31:16]; default: 0; + * This register is used to configure the thres1 value for unit 2. + */ +#define PCNT_CNT_THRES1_U2 0x0000FFFFU +#define PCNT_CNT_THRES1_U2_M (PCNT_CNT_THRES1_U2_V << PCNT_CNT_THRES1_U2_S) +#define PCNT_CNT_THRES1_U2_V 0x0000FFFFU +#define PCNT_CNT_THRES1_U2_S 16 -#define PCNT_U2_CONF2_REG (DR_REG_PCNT_BASE + 0x0020) -/* PCNT_CNT_L_LIM_U2 : R/W ;bitpos:[31:16] ;default: 10'h0 ; */ -/*description: */ -#define PCNT_CNT_L_LIM_U2 0x0000FFFF -#define PCNT_CNT_L_LIM_U2_M ((PCNT_CNT_L_LIM_U2_V)<<(PCNT_CNT_L_LIM_U2_S)) -#define PCNT_CNT_L_LIM_U2_V 0xFFFF -#define PCNT_CNT_L_LIM_U2_S 16 -/* PCNT_CNT_H_LIM_U2 : R/W ;bitpos:[15:0] ;default: 10'h0 ; */ -/*description: */ -#define PCNT_CNT_H_LIM_U2 0x0000FFFF -#define PCNT_CNT_H_LIM_U2_M ((PCNT_CNT_H_LIM_U2_V)<<(PCNT_CNT_H_LIM_U2_S)) -#define PCNT_CNT_H_LIM_U2_V 0xFFFF +/** PCNT_U2_CONF2_REG register + * Configuration register 2 for unit 2 + */ +#define PCNT_U2_CONF2_REG (DR_REG_PCNT_BASE + 0x20) +/** PCNT_CNT_H_LIM_U2 : R/W; bitpos: [15:0]; default: 0; + * This register is used to configure the thr_h_lim value for unit 2. + */ +#define PCNT_CNT_H_LIM_U2 0x0000FFFFU +#define PCNT_CNT_H_LIM_U2_M (PCNT_CNT_H_LIM_U2_V << PCNT_CNT_H_LIM_U2_S) +#define PCNT_CNT_H_LIM_U2_V 0x0000FFFFU #define PCNT_CNT_H_LIM_U2_S 0 +/** PCNT_CNT_L_LIM_U2 : R/W; bitpos: [31:16]; default: 0; + * This register is used to configure the thr_l_lim value for unit 2. + */ +#define PCNT_CNT_L_LIM_U2 0x0000FFFFU +#define PCNT_CNT_L_LIM_U2_M (PCNT_CNT_L_LIM_U2_V << PCNT_CNT_L_LIM_U2_S) +#define PCNT_CNT_L_LIM_U2_V 0x0000FFFFU +#define PCNT_CNT_L_LIM_U2_S 16 -#define PCNT_U3_CONF0_REG (DR_REG_PCNT_BASE + 0x0024) -/* PCNT_CH1_LCTRL_MODE_U3 : R/W ;bitpos:[31:30] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH1_LCTRL_MODE_U3 0x00000003 -#define PCNT_CH1_LCTRL_MODE_U3_M ((PCNT_CH1_LCTRL_MODE_U3_V)<<(PCNT_CH1_LCTRL_MODE_U3_S)) -#define PCNT_CH1_LCTRL_MODE_U3_V 0x3 -#define PCNT_CH1_LCTRL_MODE_U3_S 30 -/* PCNT_CH1_HCTRL_MODE_U3 : R/W ;bitpos:[29:28] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH1_HCTRL_MODE_U3 0x00000003 -#define PCNT_CH1_HCTRL_MODE_U3_M ((PCNT_CH1_HCTRL_MODE_U3_V)<<(PCNT_CH1_HCTRL_MODE_U3_S)) -#define PCNT_CH1_HCTRL_MODE_U3_V 0x3 -#define PCNT_CH1_HCTRL_MODE_U3_S 28 -/* PCNT_CH1_POS_MODE_U3 : R/W ;bitpos:[27:26] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH1_POS_MODE_U3 0x00000003 -#define PCNT_CH1_POS_MODE_U3_M ((PCNT_CH1_POS_MODE_U3_V)<<(PCNT_CH1_POS_MODE_U3_S)) -#define PCNT_CH1_POS_MODE_U3_V 0x3 -#define PCNT_CH1_POS_MODE_U3_S 26 -/* PCNT_CH1_NEG_MODE_U3 : R/W ;bitpos:[25:24] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH1_NEG_MODE_U3 0x00000003 -#define PCNT_CH1_NEG_MODE_U3_M ((PCNT_CH1_NEG_MODE_U3_V)<<(PCNT_CH1_NEG_MODE_U3_S)) -#define PCNT_CH1_NEG_MODE_U3_V 0x3 -#define PCNT_CH1_NEG_MODE_U3_S 24 -/* PCNT_CH0_LCTRL_MODE_U3 : R/W ;bitpos:[23:22] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH0_LCTRL_MODE_U3 0x00000003 -#define PCNT_CH0_LCTRL_MODE_U3_M ((PCNT_CH0_LCTRL_MODE_U3_V)<<(PCNT_CH0_LCTRL_MODE_U3_S)) -#define PCNT_CH0_LCTRL_MODE_U3_V 0x3 -#define PCNT_CH0_LCTRL_MODE_U3_S 22 -/* PCNT_CH0_HCTRL_MODE_U3 : R/W ;bitpos:[21:20] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH0_HCTRL_MODE_U3 0x00000003 -#define PCNT_CH0_HCTRL_MODE_U3_M ((PCNT_CH0_HCTRL_MODE_U3_V)<<(PCNT_CH0_HCTRL_MODE_U3_S)) -#define PCNT_CH0_HCTRL_MODE_U3_V 0x3 -#define PCNT_CH0_HCTRL_MODE_U3_S 20 -/* PCNT_CH0_POS_MODE_U3 : R/W ;bitpos:[19:18] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH0_POS_MODE_U3 0x00000003 -#define PCNT_CH0_POS_MODE_U3_M ((PCNT_CH0_POS_MODE_U3_V)<<(PCNT_CH0_POS_MODE_U3_S)) -#define PCNT_CH0_POS_MODE_U3_V 0x3 -#define PCNT_CH0_POS_MODE_U3_S 18 -/* PCNT_CH0_NEG_MODE_U3 : R/W ;bitpos:[17:16] ;default: 2'd0 ; */ -/*description: */ -#define PCNT_CH0_NEG_MODE_U3 0x00000003 -#define PCNT_CH0_NEG_MODE_U3_M ((PCNT_CH0_NEG_MODE_U3_V)<<(PCNT_CH0_NEG_MODE_U3_S)) -#define PCNT_CH0_NEG_MODE_U3_V 0x3 -#define PCNT_CH0_NEG_MODE_U3_S 16 -/* PCNT_THR_THRES1_EN_U3 : R/W ;bitpos:[15] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_THR_THRES1_EN_U3 (BIT(15)) -#define PCNT_THR_THRES1_EN_U3_M (BIT(15)) -#define PCNT_THR_THRES1_EN_U3_V 0x1 -#define PCNT_THR_THRES1_EN_U3_S 15 -/* PCNT_THR_THRES0_EN_U3 : R/W ;bitpos:[14] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_THR_THRES0_EN_U3 (BIT(14)) -#define PCNT_THR_THRES0_EN_U3_M (BIT(14)) -#define PCNT_THR_THRES0_EN_U3_V 0x1 -#define PCNT_THR_THRES0_EN_U3_S 14 -/* PCNT_THR_L_LIM_EN_U3 : R/W ;bitpos:[13] ;default: 1'b1 ; */ -/*description: */ -#define PCNT_THR_L_LIM_EN_U3 (BIT(13)) -#define PCNT_THR_L_LIM_EN_U3_M (BIT(13)) -#define PCNT_THR_L_LIM_EN_U3_V 0x1 -#define PCNT_THR_L_LIM_EN_U3_S 13 -/* PCNT_THR_H_LIM_EN_U3 : R/W ;bitpos:[12] ;default: 1'b1 ; */ -/*description: */ -#define PCNT_THR_H_LIM_EN_U3 (BIT(12)) -#define PCNT_THR_H_LIM_EN_U3_M (BIT(12)) -#define PCNT_THR_H_LIM_EN_U3_V 0x1 -#define PCNT_THR_H_LIM_EN_U3_S 12 -/* PCNT_THR_ZERO_EN_U3 : R/W ;bitpos:[11] ;default: 1'b1 ; */ -/*description: */ -#define PCNT_THR_ZERO_EN_U3 (BIT(11)) -#define PCNT_THR_ZERO_EN_U3_M (BIT(11)) -#define PCNT_THR_ZERO_EN_U3_V 0x1 -#define PCNT_THR_ZERO_EN_U3_S 11 -/* PCNT_FILTER_EN_U3 : R/W ;bitpos:[10] ;default: 1'b1 ; */ -/*description: */ -#define PCNT_FILTER_EN_U3 (BIT(10)) -#define PCNT_FILTER_EN_U3_M (BIT(10)) -#define PCNT_FILTER_EN_U3_V 0x1 -#define PCNT_FILTER_EN_U3_S 10 -/* PCNT_FILTER_THRES_U3 : R/W ;bitpos:[9:0] ;default: 10'h10 ; */ -/*description: */ -#define PCNT_FILTER_THRES_U3 0x000003FF -#define PCNT_FILTER_THRES_U3_M ((PCNT_FILTER_THRES_U3_V)<<(PCNT_FILTER_THRES_U3_S)) -#define PCNT_FILTER_THRES_U3_V 0x3FF +/** PCNT_U3_CONF0_REG register + * Configuration register 0 for unit 3 + */ +#define PCNT_U3_CONF0_REG (DR_REG_PCNT_BASE + 0x24) +/** PCNT_FILTER_THRES_U3 : R/W; bitpos: [9:0]; default: 16; + * This sets the maximum threshold, in APB_CLK cycles, for the filter. + * + * Any pulses with width less than this will be ignored when the filter is enabled. + */ +#define PCNT_FILTER_THRES_U3 0x000003FFU +#define PCNT_FILTER_THRES_U3_M (PCNT_FILTER_THRES_U3_V << PCNT_FILTER_THRES_U3_S) +#define PCNT_FILTER_THRES_U3_V 0x000003FFU #define PCNT_FILTER_THRES_U3_S 0 +/** PCNT_FILTER_EN_U3 : R/W; bitpos: [10]; default: 1; + * This is the enable bit for unit 3's input filter. + */ +#define PCNT_FILTER_EN_U3 (BIT(10)) +#define PCNT_FILTER_EN_U3_M (PCNT_FILTER_EN_U3_V << PCNT_FILTER_EN_U3_S) +#define PCNT_FILTER_EN_U3_V 0x00000001U +#define PCNT_FILTER_EN_U3_S 10 +/** PCNT_THR_ZERO_EN_U3 : R/W; bitpos: [11]; default: 1; + * This is the enable bit for unit 3's zero comparator. + */ +#define PCNT_THR_ZERO_EN_U3 (BIT(11)) +#define PCNT_THR_ZERO_EN_U3_M (PCNT_THR_ZERO_EN_U3_V << PCNT_THR_ZERO_EN_U3_S) +#define PCNT_THR_ZERO_EN_U3_V 0x00000001U +#define PCNT_THR_ZERO_EN_U3_S 11 +/** PCNT_THR_H_LIM_EN_U3 : R/W; bitpos: [12]; default: 1; + * This is the enable bit for unit 3's thr_h_lim comparator. + */ +#define PCNT_THR_H_LIM_EN_U3 (BIT(12)) +#define PCNT_THR_H_LIM_EN_U3_M (PCNT_THR_H_LIM_EN_U3_V << PCNT_THR_H_LIM_EN_U3_S) +#define PCNT_THR_H_LIM_EN_U3_V 0x00000001U +#define PCNT_THR_H_LIM_EN_U3_S 12 +/** PCNT_THR_L_LIM_EN_U3 : R/W; bitpos: [13]; default: 1; + * This is the enable bit for unit 3's thr_l_lim comparator. + */ +#define PCNT_THR_L_LIM_EN_U3 (BIT(13)) +#define PCNT_THR_L_LIM_EN_U3_M (PCNT_THR_L_LIM_EN_U3_V << PCNT_THR_L_LIM_EN_U3_S) +#define PCNT_THR_L_LIM_EN_U3_V 0x00000001U +#define PCNT_THR_L_LIM_EN_U3_S 13 +/** PCNT_THR_THRES0_EN_U3 : R/W; bitpos: [14]; default: 0; + * This is the enable bit for unit 3's thres0 comparator. + */ +#define PCNT_THR_THRES0_EN_U3 (BIT(14)) +#define PCNT_THR_THRES0_EN_U3_M (PCNT_THR_THRES0_EN_U3_V << PCNT_THR_THRES0_EN_U3_S) +#define PCNT_THR_THRES0_EN_U3_V 0x00000001U +#define PCNT_THR_THRES0_EN_U3_S 14 +/** PCNT_THR_THRES1_EN_U3 : R/W; bitpos: [15]; default: 0; + * This is the enable bit for unit 3's thres1 comparator. + */ +#define PCNT_THR_THRES1_EN_U3 (BIT(15)) +#define PCNT_THR_THRES1_EN_U3_M (PCNT_THR_THRES1_EN_U3_V << PCNT_THR_THRES1_EN_U3_S) +#define PCNT_THR_THRES1_EN_U3_V 0x00000001U +#define PCNT_THR_THRES1_EN_U3_S 15 +/** PCNT_CH0_NEG_MODE_U3 : R/W; bitpos: [17:16]; default: 0; + * This register sets the behavior when the signal input of channel 0 detects a + * negative edge. + * + * 1: Increase the counter;2: Decrease the counter;0, 3: No effect on counter + */ +#define PCNT_CH0_NEG_MODE_U3 0x00000003U +#define PCNT_CH0_NEG_MODE_U3_M (PCNT_CH0_NEG_MODE_U3_V << PCNT_CH0_NEG_MODE_U3_S) +#define PCNT_CH0_NEG_MODE_U3_V 0x00000003U +#define PCNT_CH0_NEG_MODE_U3_S 16 +/** PCNT_CH0_POS_MODE_U3 : R/W; bitpos: [19:18]; default: 0; + * This register sets the behavior when the signal input of channel 0 detects a + * positive edge. + * + * 1: Increase the counter;2: Decrease the counter;0, 3: No effect on counter + */ +#define PCNT_CH0_POS_MODE_U3 0x00000003U +#define PCNT_CH0_POS_MODE_U3_M (PCNT_CH0_POS_MODE_U3_V << PCNT_CH0_POS_MODE_U3_S) +#define PCNT_CH0_POS_MODE_U3_V 0x00000003U +#define PCNT_CH0_POS_MODE_U3_S 18 +/** PCNT_CH0_HCTRL_MODE_U3 : R/W; bitpos: [21:20]; default: 0; + * This register configures how the CH3_POS_MODE/CH3_NEG_MODE settings will be + * modified when the control signal is high. + * + * 0: No modification;1: Invert behavior (increase -> decrease, decrease -> + * increase);2, 3: Inhibit counter modification + */ +#define PCNT_CH0_HCTRL_MODE_U3 0x00000003U +#define PCNT_CH0_HCTRL_MODE_U3_M (PCNT_CH0_HCTRL_MODE_U3_V << PCNT_CH0_HCTRL_MODE_U3_S) +#define PCNT_CH0_HCTRL_MODE_U3_V 0x00000003U +#define PCNT_CH0_HCTRL_MODE_U3_S 20 +/** PCNT_CH0_LCTRL_MODE_U3 : R/W; bitpos: [23:22]; default: 0; + * This register configures how the CH3_POS_MODE/CH3_NEG_MODE settings will be + * modified when the control signal is low. + * + * 0: No modification;1: Invert behavior (increase -> decrease, decrease -> + * increase);2, 3: Inhibit counter modification + */ +#define PCNT_CH0_LCTRL_MODE_U3 0x00000003U +#define PCNT_CH0_LCTRL_MODE_U3_M (PCNT_CH0_LCTRL_MODE_U3_V << PCNT_CH0_LCTRL_MODE_U3_S) +#define PCNT_CH0_LCTRL_MODE_U3_V 0x00000003U +#define PCNT_CH0_LCTRL_MODE_U3_S 22 +/** PCNT_CH1_NEG_MODE_U3 : R/W; bitpos: [25:24]; default: 0; + * This register sets the behavior when the signal input of channel 1 detects a + * negative edge. + * + * 1: Increment the counter;2: Decrement the counter;0, 3: No effect on counter + */ +#define PCNT_CH1_NEG_MODE_U3 0x00000003U +#define PCNT_CH1_NEG_MODE_U3_M (PCNT_CH1_NEG_MODE_U3_V << PCNT_CH1_NEG_MODE_U3_S) +#define PCNT_CH1_NEG_MODE_U3_V 0x00000003U +#define PCNT_CH1_NEG_MODE_U3_S 24 +/** PCNT_CH1_POS_MODE_U3 : R/W; bitpos: [27:26]; default: 0; + * This register sets the behavior when the signal input of channel 1 detects a + * positive edge. + * + * 1: Increment the counter;2: Decrement the counter;0, 3: No effect on counter + */ +#define PCNT_CH1_POS_MODE_U3 0x00000003U +#define PCNT_CH1_POS_MODE_U3_M (PCNT_CH1_POS_MODE_U3_V << PCNT_CH1_POS_MODE_U3_S) +#define PCNT_CH1_POS_MODE_U3_V 0x00000003U +#define PCNT_CH1_POS_MODE_U3_S 26 +/** PCNT_CH1_HCTRL_MODE_U3 : R/W; bitpos: [29:28]; default: 0; + * This register configures how the CH3_POS_MODE/CH3_NEG_MODE settings will be + * modified when the control signal is high. + * + * 0: No modification;1: Invert behavior (increase -> decrease, decrease -> + * increase);2, 3: Inhibit counter modification + */ +#define PCNT_CH1_HCTRL_MODE_U3 0x00000003U +#define PCNT_CH1_HCTRL_MODE_U3_M (PCNT_CH1_HCTRL_MODE_U3_V << PCNT_CH1_HCTRL_MODE_U3_S) +#define PCNT_CH1_HCTRL_MODE_U3_V 0x00000003U +#define PCNT_CH1_HCTRL_MODE_U3_S 28 +/** PCNT_CH1_LCTRL_MODE_U3 : R/W; bitpos: [31:30]; default: 0; + * This register configures how the CH3_POS_MODE/CH3_NEG_MODE settings will be + * modified when the control signal is low. + * + * 0: No modification;1: Invert behavior (increase -> decrease, decrease -> + * increase);2, 3: Inhibit counter modification + */ +#define PCNT_CH1_LCTRL_MODE_U3 0x00000003U +#define PCNT_CH1_LCTRL_MODE_U3_M (PCNT_CH1_LCTRL_MODE_U3_V << PCNT_CH1_LCTRL_MODE_U3_S) +#define PCNT_CH1_LCTRL_MODE_U3_V 0x00000003U +#define PCNT_CH1_LCTRL_MODE_U3_S 30 -#define PCNT_U3_CONF1_REG (DR_REG_PCNT_BASE + 0x0028) -/* PCNT_CNT_THRES1_U3 : R/W ;bitpos:[31:16] ;default: 10'h0 ; */ -/*description: */ -#define PCNT_CNT_THRES1_U3 0x0000FFFF -#define PCNT_CNT_THRES1_U3_M ((PCNT_CNT_THRES1_U3_V)<<(PCNT_CNT_THRES1_U3_S)) -#define PCNT_CNT_THRES1_U3_V 0xFFFF -#define PCNT_CNT_THRES1_U3_S 16 -/* PCNT_CNT_THRES0_U3 : R/W ;bitpos:[15:0] ;default: 10'h0 ; */ -/*description: */ -#define PCNT_CNT_THRES0_U3 0x0000FFFF -#define PCNT_CNT_THRES0_U3_M ((PCNT_CNT_THRES0_U3_V)<<(PCNT_CNT_THRES0_U3_S)) -#define PCNT_CNT_THRES0_U3_V 0xFFFF +/** PCNT_U3_CONF1_REG register + * Configuration register 1 for unit 3 + */ +#define PCNT_U3_CONF1_REG (DR_REG_PCNT_BASE + 0x28) +/** PCNT_CNT_THRES0_U3 : R/W; bitpos: [15:0]; default: 0; + * This register is used to configure the thres0 value for unit 3. + */ +#define PCNT_CNT_THRES0_U3 0x0000FFFFU +#define PCNT_CNT_THRES0_U3_M (PCNT_CNT_THRES0_U3_V << PCNT_CNT_THRES0_U3_S) +#define PCNT_CNT_THRES0_U3_V 0x0000FFFFU #define PCNT_CNT_THRES0_U3_S 0 +/** PCNT_CNT_THRES1_U3 : R/W; bitpos: [31:16]; default: 0; + * This register is used to configure the thres1 value for unit 3. + */ +#define PCNT_CNT_THRES1_U3 0x0000FFFFU +#define PCNT_CNT_THRES1_U3_M (PCNT_CNT_THRES1_U3_V << PCNT_CNT_THRES1_U3_S) +#define PCNT_CNT_THRES1_U3_V 0x0000FFFFU +#define PCNT_CNT_THRES1_U3_S 16 -#define PCNT_U3_CONF2_REG (DR_REG_PCNT_BASE + 0x002c) -/* PCNT_CNT_L_LIM_U3 : R/W ;bitpos:[31:16] ;default: 10'h0 ; */ -/*description: */ -#define PCNT_CNT_L_LIM_U3 0x0000FFFF -#define PCNT_CNT_L_LIM_U3_M ((PCNT_CNT_L_LIM_U3_V)<<(PCNT_CNT_L_LIM_U3_S)) -#define PCNT_CNT_L_LIM_U3_V 0xFFFF -#define PCNT_CNT_L_LIM_U3_S 16 -/* PCNT_CNT_H_LIM_U3 : R/W ;bitpos:[15:0] ;default: 10'h0 ; */ -/*description: */ -#define PCNT_CNT_H_LIM_U3 0x0000FFFF -#define PCNT_CNT_H_LIM_U3_M ((PCNT_CNT_H_LIM_U3_V)<<(PCNT_CNT_H_LIM_U3_S)) -#define PCNT_CNT_H_LIM_U3_V 0xFFFF +/** PCNT_U3_CONF2_REG register + * Configuration register 2 for unit 3 + */ +#define PCNT_U3_CONF2_REG (DR_REG_PCNT_BASE + 0x2c) +/** PCNT_CNT_H_LIM_U3 : R/W; bitpos: [15:0]; default: 0; + * This register is used to configure the thr_h_lim value for unit 3. + */ +#define PCNT_CNT_H_LIM_U3 0x0000FFFFU +#define PCNT_CNT_H_LIM_U3_M (PCNT_CNT_H_LIM_U3_V << PCNT_CNT_H_LIM_U3_S) +#define PCNT_CNT_H_LIM_U3_V 0x0000FFFFU #define PCNT_CNT_H_LIM_U3_S 0 +/** PCNT_CNT_L_LIM_U3 : R/W; bitpos: [31:16]; default: 0; + * This register is used to configure the thr_l_lim value for unit 3. + */ +#define PCNT_CNT_L_LIM_U3 0x0000FFFFU +#define PCNT_CNT_L_LIM_U3_M (PCNT_CNT_L_LIM_U3_V << PCNT_CNT_L_LIM_U3_S) +#define PCNT_CNT_L_LIM_U3_V 0x0000FFFFU +#define PCNT_CNT_L_LIM_U3_S 16 -#define PCNT_U0_CNT_REG (DR_REG_PCNT_BASE + 0x0030) -/* PCNT_PULSE_CNT_U0 : RO ;bitpos:[15:0] ;default: 16'h0 ; */ -/*description: */ -#define PCNT_PULSE_CNT_U0 0x0000FFFF -#define PCNT_PULSE_CNT_U0_M ((PCNT_PULSE_CNT_U0_V)<<(PCNT_PULSE_CNT_U0_S)) -#define PCNT_PULSE_CNT_U0_V 0xFFFF +/** PCNT_U0_CNT_REG register + * Counter value for unit 0 + */ +#define PCNT_U0_CNT_REG (DR_REG_PCNT_BASE + 0x30) +/** PCNT_PULSE_CNT_U0 : RO; bitpos: [15:0]; default: 0; + * This register stores the current pulse count value for unit 0. + */ +#define PCNT_PULSE_CNT_U0 0x0000FFFFU +#define PCNT_PULSE_CNT_U0_M (PCNT_PULSE_CNT_U0_V << PCNT_PULSE_CNT_U0_S) +#define PCNT_PULSE_CNT_U0_V 0x0000FFFFU #define PCNT_PULSE_CNT_U0_S 0 -#define PCNT_U1_CNT_REG (DR_REG_PCNT_BASE + 0x0034) -/* PCNT_PULSE_CNT_U1 : RO ;bitpos:[15:0] ;default: 16'h0 ; */ -/*description: */ -#define PCNT_PULSE_CNT_U1 0x0000FFFF -#define PCNT_PULSE_CNT_U1_M ((PCNT_PULSE_CNT_U1_V)<<(PCNT_PULSE_CNT_U1_S)) -#define PCNT_PULSE_CNT_U1_V 0xFFFF +/** PCNT_U1_CNT_REG register + * Counter value for unit 1 + */ +#define PCNT_U1_CNT_REG (DR_REG_PCNT_BASE + 0x34) +/** PCNT_PULSE_CNT_U1 : RO; bitpos: [15:0]; default: 0; + * This register stores the current pulse count value for unit 1. + */ +#define PCNT_PULSE_CNT_U1 0x0000FFFFU +#define PCNT_PULSE_CNT_U1_M (PCNT_PULSE_CNT_U1_V << PCNT_PULSE_CNT_U1_S) +#define PCNT_PULSE_CNT_U1_V 0x0000FFFFU #define PCNT_PULSE_CNT_U1_S 0 -#define PCNT_U2_CNT_REG (DR_REG_PCNT_BASE + 0x0038) -/* PCNT_PULSE_CNT_U2 : RO ;bitpos:[15:0] ;default: 16'h0 ; */ -/*description: */ -#define PCNT_PULSE_CNT_U2 0x0000FFFF -#define PCNT_PULSE_CNT_U2_M ((PCNT_PULSE_CNT_U2_V)<<(PCNT_PULSE_CNT_U2_S)) -#define PCNT_PULSE_CNT_U2_V 0xFFFF +/** PCNT_U2_CNT_REG register + * Counter value for unit 2 + */ +#define PCNT_U2_CNT_REG (DR_REG_PCNT_BASE + 0x38) +/** PCNT_PULSE_CNT_U2 : RO; bitpos: [15:0]; default: 0; + * This register stores the current pulse count value for unit 2. + */ +#define PCNT_PULSE_CNT_U2 0x0000FFFFU +#define PCNT_PULSE_CNT_U2_M (PCNT_PULSE_CNT_U2_V << PCNT_PULSE_CNT_U2_S) +#define PCNT_PULSE_CNT_U2_V 0x0000FFFFU #define PCNT_PULSE_CNT_U2_S 0 -#define PCNT_U3_CNT_REG (DR_REG_PCNT_BASE + 0x003c) -/* PCNT_PULSE_CNT_U3 : RO ;bitpos:[15:0] ;default: 16'h0 ; */ -/*description: */ -#define PCNT_PULSE_CNT_U3 0x0000FFFF -#define PCNT_PULSE_CNT_U3_M ((PCNT_PULSE_CNT_U3_V)<<(PCNT_PULSE_CNT_U3_S)) -#define PCNT_PULSE_CNT_U3_V 0xFFFF +/** PCNT_U3_CNT_REG register + * Counter value for unit 3 + */ +#define PCNT_U3_CNT_REG (DR_REG_PCNT_BASE + 0x3c) +/** PCNT_PULSE_CNT_U3 : RO; bitpos: [15:0]; default: 0; + * This register stores the current pulse count value for unit 3. + */ +#define PCNT_PULSE_CNT_U3 0x0000FFFFU +#define PCNT_PULSE_CNT_U3_M (PCNT_PULSE_CNT_U3_V << PCNT_PULSE_CNT_U3_S) +#define PCNT_PULSE_CNT_U3_V 0x0000FFFFU #define PCNT_PULSE_CNT_U3_S 0 -#define PCNT_INT_RAW_REG (DR_REG_PCNT_BASE + 0x0040) -/* PCNT_CNT_THR_EVENT_U3_INT_RAW : RO ;bitpos:[3] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_EVENT_U3_INT_RAW (BIT(3)) -#define PCNT_CNT_THR_EVENT_U3_INT_RAW_M (BIT(3)) -#define PCNT_CNT_THR_EVENT_U3_INT_RAW_V 0x1 -#define PCNT_CNT_THR_EVENT_U3_INT_RAW_S 3 -/* PCNT_CNT_THR_EVENT_U2_INT_RAW : RO ;bitpos:[2] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_EVENT_U2_INT_RAW (BIT(2)) -#define PCNT_CNT_THR_EVENT_U2_INT_RAW_M (BIT(2)) -#define PCNT_CNT_THR_EVENT_U2_INT_RAW_V 0x1 -#define PCNT_CNT_THR_EVENT_U2_INT_RAW_S 2 -/* PCNT_CNT_THR_EVENT_U1_INT_RAW : RO ;bitpos:[1] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_EVENT_U1_INT_RAW (BIT(1)) -#define PCNT_CNT_THR_EVENT_U1_INT_RAW_M (BIT(1)) -#define PCNT_CNT_THR_EVENT_U1_INT_RAW_V 0x1 -#define PCNT_CNT_THR_EVENT_U1_INT_RAW_S 1 -/* PCNT_CNT_THR_EVENT_U0_INT_RAW : RO ;bitpos:[0] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_EVENT_U0_INT_RAW (BIT(0)) -#define PCNT_CNT_THR_EVENT_U0_INT_RAW_M (BIT(0)) -#define PCNT_CNT_THR_EVENT_U0_INT_RAW_V 0x1 +/** PCNT_INT_RAW_REG register + * Interrupt raw status register + */ +#define PCNT_INT_RAW_REG (DR_REG_PCNT_BASE + 0x40) +/** PCNT_CNT_THR_EVENT_U0_INT_RAW : RO; bitpos: [0]; default: 0; + * The raw interrupt status bit for the PCNT_CNT_THR_EVENT_U0_INT interrupt. + */ +#define PCNT_CNT_THR_EVENT_U0_INT_RAW (BIT(0)) +#define PCNT_CNT_THR_EVENT_U0_INT_RAW_M (PCNT_CNT_THR_EVENT_U0_INT_RAW_V << PCNT_CNT_THR_EVENT_U0_INT_RAW_S) +#define PCNT_CNT_THR_EVENT_U0_INT_RAW_V 0x00000001U #define PCNT_CNT_THR_EVENT_U0_INT_RAW_S 0 +/** PCNT_CNT_THR_EVENT_U1_INT_RAW : RO; bitpos: [1]; default: 0; + * The raw interrupt status bit for the PCNT_CNT_THR_EVENT_U1_INT interrupt. + */ +#define PCNT_CNT_THR_EVENT_U1_INT_RAW (BIT(1)) +#define PCNT_CNT_THR_EVENT_U1_INT_RAW_M (PCNT_CNT_THR_EVENT_U1_INT_RAW_V << PCNT_CNT_THR_EVENT_U1_INT_RAW_S) +#define PCNT_CNT_THR_EVENT_U1_INT_RAW_V 0x00000001U +#define PCNT_CNT_THR_EVENT_U1_INT_RAW_S 1 +/** PCNT_CNT_THR_EVENT_U2_INT_RAW : RO; bitpos: [2]; default: 0; + * The raw interrupt status bit for the PCNT_CNT_THR_EVENT_U2_INT interrupt. + */ +#define PCNT_CNT_THR_EVENT_U2_INT_RAW (BIT(2)) +#define PCNT_CNT_THR_EVENT_U2_INT_RAW_M (PCNT_CNT_THR_EVENT_U2_INT_RAW_V << PCNT_CNT_THR_EVENT_U2_INT_RAW_S) +#define PCNT_CNT_THR_EVENT_U2_INT_RAW_V 0x00000001U +#define PCNT_CNT_THR_EVENT_U2_INT_RAW_S 2 +/** PCNT_CNT_THR_EVENT_U3_INT_RAW : RO; bitpos: [3]; default: 0; + * The raw interrupt status bit for the PCNT_CNT_THR_EVENT_U3_INT interrupt. + */ +#define PCNT_CNT_THR_EVENT_U3_INT_RAW (BIT(3)) +#define PCNT_CNT_THR_EVENT_U3_INT_RAW_M (PCNT_CNT_THR_EVENT_U3_INT_RAW_V << PCNT_CNT_THR_EVENT_U3_INT_RAW_S) +#define PCNT_CNT_THR_EVENT_U3_INT_RAW_V 0x00000001U +#define PCNT_CNT_THR_EVENT_U3_INT_RAW_S 3 -#define PCNT_INT_ST_REG (DR_REG_PCNT_BASE + 0x0044) -/* PCNT_CNT_THR_EVENT_U3_INT_ST : RO ;bitpos:[3] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_EVENT_U3_INT_ST (BIT(3)) -#define PCNT_CNT_THR_EVENT_U3_INT_ST_M (BIT(3)) -#define PCNT_CNT_THR_EVENT_U3_INT_ST_V 0x1 -#define PCNT_CNT_THR_EVENT_U3_INT_ST_S 3 -/* PCNT_CNT_THR_EVENT_U2_INT_ST : RO ;bitpos:[2] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_EVENT_U2_INT_ST (BIT(2)) -#define PCNT_CNT_THR_EVENT_U2_INT_ST_M (BIT(2)) -#define PCNT_CNT_THR_EVENT_U2_INT_ST_V 0x1 -#define PCNT_CNT_THR_EVENT_U2_INT_ST_S 2 -/* PCNT_CNT_THR_EVENT_U1_INT_ST : RO ;bitpos:[1] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_EVENT_U1_INT_ST (BIT(1)) -#define PCNT_CNT_THR_EVENT_U1_INT_ST_M (BIT(1)) -#define PCNT_CNT_THR_EVENT_U1_INT_ST_V 0x1 -#define PCNT_CNT_THR_EVENT_U1_INT_ST_S 1 -/* PCNT_CNT_THR_EVENT_U0_INT_ST : RO ;bitpos:[0] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_EVENT_U0_INT_ST (BIT(0)) -#define PCNT_CNT_THR_EVENT_U0_INT_ST_M (BIT(0)) -#define PCNT_CNT_THR_EVENT_U0_INT_ST_V 0x1 +/** PCNT_INT_ST_REG register + * Interrupt status register + */ +#define PCNT_INT_ST_REG (DR_REG_PCNT_BASE + 0x44) +/** PCNT_CNT_THR_EVENT_U0_INT_ST : RO; bitpos: [0]; default: 0; + * The masked interrupt status bit for the PCNT_CNT_THR_EVENT_U0_INT interrupt. + */ +#define PCNT_CNT_THR_EVENT_U0_INT_ST (BIT(0)) +#define PCNT_CNT_THR_EVENT_U0_INT_ST_M (PCNT_CNT_THR_EVENT_U0_INT_ST_V << PCNT_CNT_THR_EVENT_U0_INT_ST_S) +#define PCNT_CNT_THR_EVENT_U0_INT_ST_V 0x00000001U #define PCNT_CNT_THR_EVENT_U0_INT_ST_S 0 +/** PCNT_CNT_THR_EVENT_U1_INT_ST : RO; bitpos: [1]; default: 0; + * The masked interrupt status bit for the PCNT_CNT_THR_EVENT_U1_INT interrupt. + */ +#define PCNT_CNT_THR_EVENT_U1_INT_ST (BIT(1)) +#define PCNT_CNT_THR_EVENT_U1_INT_ST_M (PCNT_CNT_THR_EVENT_U1_INT_ST_V << PCNT_CNT_THR_EVENT_U1_INT_ST_S) +#define PCNT_CNT_THR_EVENT_U1_INT_ST_V 0x00000001U +#define PCNT_CNT_THR_EVENT_U1_INT_ST_S 1 +/** PCNT_CNT_THR_EVENT_U2_INT_ST : RO; bitpos: [2]; default: 0; + * The masked interrupt status bit for the PCNT_CNT_THR_EVENT_U2_INT interrupt. + */ +#define PCNT_CNT_THR_EVENT_U2_INT_ST (BIT(2)) +#define PCNT_CNT_THR_EVENT_U2_INT_ST_M (PCNT_CNT_THR_EVENT_U2_INT_ST_V << PCNT_CNT_THR_EVENT_U2_INT_ST_S) +#define PCNT_CNT_THR_EVENT_U2_INT_ST_V 0x00000001U +#define PCNT_CNT_THR_EVENT_U2_INT_ST_S 2 +/** PCNT_CNT_THR_EVENT_U3_INT_ST : RO; bitpos: [3]; default: 0; + * The masked interrupt status bit for the PCNT_CNT_THR_EVENT_U3_INT interrupt. + */ +#define PCNT_CNT_THR_EVENT_U3_INT_ST (BIT(3)) +#define PCNT_CNT_THR_EVENT_U3_INT_ST_M (PCNT_CNT_THR_EVENT_U3_INT_ST_V << PCNT_CNT_THR_EVENT_U3_INT_ST_S) +#define PCNT_CNT_THR_EVENT_U3_INT_ST_V 0x00000001U +#define PCNT_CNT_THR_EVENT_U3_INT_ST_S 3 -#define PCNT_INT_ENA_REG (DR_REG_PCNT_BASE + 0x0048) -/* PCNT_CNT_THR_EVENT_U3_INT_ENA : R/W ;bitpos:[3] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_EVENT_U3_INT_ENA (BIT(3)) -#define PCNT_CNT_THR_EVENT_U3_INT_ENA_M (BIT(3)) -#define PCNT_CNT_THR_EVENT_U3_INT_ENA_V 0x1 -#define PCNT_CNT_THR_EVENT_U3_INT_ENA_S 3 -/* PCNT_CNT_THR_EVENT_U2_INT_ENA : R/W ;bitpos:[2] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_EVENT_U2_INT_ENA (BIT(2)) -#define PCNT_CNT_THR_EVENT_U2_INT_ENA_M (BIT(2)) -#define PCNT_CNT_THR_EVENT_U2_INT_ENA_V 0x1 -#define PCNT_CNT_THR_EVENT_U2_INT_ENA_S 2 -/* PCNT_CNT_THR_EVENT_U1_INT_ENA : R/W ;bitpos:[1] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_EVENT_U1_INT_ENA (BIT(1)) -#define PCNT_CNT_THR_EVENT_U1_INT_ENA_M (BIT(1)) -#define PCNT_CNT_THR_EVENT_U1_INT_ENA_V 0x1 -#define PCNT_CNT_THR_EVENT_U1_INT_ENA_S 1 -/* PCNT_CNT_THR_EVENT_U0_INT_ENA : R/W ;bitpos:[0] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_EVENT_U0_INT_ENA (BIT(0)) -#define PCNT_CNT_THR_EVENT_U0_INT_ENA_M (BIT(0)) -#define PCNT_CNT_THR_EVENT_U0_INT_ENA_V 0x1 +/** PCNT_INT_ENA_REG register + * Interrupt enable register + */ +#define PCNT_INT_ENA_REG (DR_REG_PCNT_BASE + 0x48) +/** PCNT_CNT_THR_EVENT_U0_INT_ENA : R/W; bitpos: [0]; default: 0; + * The interrupt enable bit for the PCNT_CNT_THR_EVENT_U0_INT interrupt. + */ +#define PCNT_CNT_THR_EVENT_U0_INT_ENA (BIT(0)) +#define PCNT_CNT_THR_EVENT_U0_INT_ENA_M (PCNT_CNT_THR_EVENT_U0_INT_ENA_V << PCNT_CNT_THR_EVENT_U0_INT_ENA_S) +#define PCNT_CNT_THR_EVENT_U0_INT_ENA_V 0x00000001U #define PCNT_CNT_THR_EVENT_U0_INT_ENA_S 0 +/** PCNT_CNT_THR_EVENT_U1_INT_ENA : R/W; bitpos: [1]; default: 0; + * The interrupt enable bit for the PCNT_CNT_THR_EVENT_U1_INT interrupt. + */ +#define PCNT_CNT_THR_EVENT_U1_INT_ENA (BIT(1)) +#define PCNT_CNT_THR_EVENT_U1_INT_ENA_M (PCNT_CNT_THR_EVENT_U1_INT_ENA_V << PCNT_CNT_THR_EVENT_U1_INT_ENA_S) +#define PCNT_CNT_THR_EVENT_U1_INT_ENA_V 0x00000001U +#define PCNT_CNT_THR_EVENT_U1_INT_ENA_S 1 +/** PCNT_CNT_THR_EVENT_U2_INT_ENA : R/W; bitpos: [2]; default: 0; + * The interrupt enable bit for the PCNT_CNT_THR_EVENT_U2_INT interrupt. + */ +#define PCNT_CNT_THR_EVENT_U2_INT_ENA (BIT(2)) +#define PCNT_CNT_THR_EVENT_U2_INT_ENA_M (PCNT_CNT_THR_EVENT_U2_INT_ENA_V << PCNT_CNT_THR_EVENT_U2_INT_ENA_S) +#define PCNT_CNT_THR_EVENT_U2_INT_ENA_V 0x00000001U +#define PCNT_CNT_THR_EVENT_U2_INT_ENA_S 2 +/** PCNT_CNT_THR_EVENT_U3_INT_ENA : R/W; bitpos: [3]; default: 0; + * The interrupt enable bit for the PCNT_CNT_THR_EVENT_U3_INT interrupt. + */ +#define PCNT_CNT_THR_EVENT_U3_INT_ENA (BIT(3)) +#define PCNT_CNT_THR_EVENT_U3_INT_ENA_M (PCNT_CNT_THR_EVENT_U3_INT_ENA_V << PCNT_CNT_THR_EVENT_U3_INT_ENA_S) +#define PCNT_CNT_THR_EVENT_U3_INT_ENA_V 0x00000001U +#define PCNT_CNT_THR_EVENT_U3_INT_ENA_S 3 -#define PCNT_INT_CLR_REG (DR_REG_PCNT_BASE + 0x004c) -/* PCNT_CNT_THR_EVENT_U3_INT_CLR : WO ;bitpos:[3] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_EVENT_U3_INT_CLR (BIT(3)) -#define PCNT_CNT_THR_EVENT_U3_INT_CLR_M (BIT(3)) -#define PCNT_CNT_THR_EVENT_U3_INT_CLR_V 0x1 -#define PCNT_CNT_THR_EVENT_U3_INT_CLR_S 3 -/* PCNT_CNT_THR_EVENT_U2_INT_CLR : WO ;bitpos:[2] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_EVENT_U2_INT_CLR (BIT(2)) -#define PCNT_CNT_THR_EVENT_U2_INT_CLR_M (BIT(2)) -#define PCNT_CNT_THR_EVENT_U2_INT_CLR_V 0x1 -#define PCNT_CNT_THR_EVENT_U2_INT_CLR_S 2 -/* PCNT_CNT_THR_EVENT_U1_INT_CLR : WO ;bitpos:[1] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_EVENT_U1_INT_CLR (BIT(1)) -#define PCNT_CNT_THR_EVENT_U1_INT_CLR_M (BIT(1)) -#define PCNT_CNT_THR_EVENT_U1_INT_CLR_V 0x1 -#define PCNT_CNT_THR_EVENT_U1_INT_CLR_S 1 -/* PCNT_CNT_THR_EVENT_U0_INT_CLR : WO ;bitpos:[0] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_EVENT_U0_INT_CLR (BIT(0)) -#define PCNT_CNT_THR_EVENT_U0_INT_CLR_M (BIT(0)) -#define PCNT_CNT_THR_EVENT_U0_INT_CLR_V 0x1 +/** PCNT_INT_CLR_REG register + * Interrupt clear register + */ +#define PCNT_INT_CLR_REG (DR_REG_PCNT_BASE + 0x4c) +/** PCNT_CNT_THR_EVENT_U0_INT_CLR : WO; bitpos: [0]; default: 0; + * Set this bit to clear the PCNT_CNT_THR_EVENT_U0_INT interrupt. + */ +#define PCNT_CNT_THR_EVENT_U0_INT_CLR (BIT(0)) +#define PCNT_CNT_THR_EVENT_U0_INT_CLR_M (PCNT_CNT_THR_EVENT_U0_INT_CLR_V << PCNT_CNT_THR_EVENT_U0_INT_CLR_S) +#define PCNT_CNT_THR_EVENT_U0_INT_CLR_V 0x00000001U #define PCNT_CNT_THR_EVENT_U0_INT_CLR_S 0 +/** PCNT_CNT_THR_EVENT_U1_INT_CLR : WO; bitpos: [1]; default: 0; + * Set this bit to clear the PCNT_CNT_THR_EVENT_U1_INT interrupt. + */ +#define PCNT_CNT_THR_EVENT_U1_INT_CLR (BIT(1)) +#define PCNT_CNT_THR_EVENT_U1_INT_CLR_M (PCNT_CNT_THR_EVENT_U1_INT_CLR_V << PCNT_CNT_THR_EVENT_U1_INT_CLR_S) +#define PCNT_CNT_THR_EVENT_U1_INT_CLR_V 0x00000001U +#define PCNT_CNT_THR_EVENT_U1_INT_CLR_S 1 +/** PCNT_CNT_THR_EVENT_U2_INT_CLR : WO; bitpos: [2]; default: 0; + * Set this bit to clear the PCNT_CNT_THR_EVENT_U2_INT interrupt. + */ +#define PCNT_CNT_THR_EVENT_U2_INT_CLR (BIT(2)) +#define PCNT_CNT_THR_EVENT_U2_INT_CLR_M (PCNT_CNT_THR_EVENT_U2_INT_CLR_V << PCNT_CNT_THR_EVENT_U2_INT_CLR_S) +#define PCNT_CNT_THR_EVENT_U2_INT_CLR_V 0x00000001U +#define PCNT_CNT_THR_EVENT_U2_INT_CLR_S 2 +/** PCNT_CNT_THR_EVENT_U3_INT_CLR : WO; bitpos: [3]; default: 0; + * Set this bit to clear the PCNT_CNT_THR_EVENT_U3_INT interrupt. + */ +#define PCNT_CNT_THR_EVENT_U3_INT_CLR (BIT(3)) +#define PCNT_CNT_THR_EVENT_U3_INT_CLR_M (PCNT_CNT_THR_EVENT_U3_INT_CLR_V << PCNT_CNT_THR_EVENT_U3_INT_CLR_S) +#define PCNT_CNT_THR_EVENT_U3_INT_CLR_V 0x00000001U +#define PCNT_CNT_THR_EVENT_U3_INT_CLR_S 3 -#define PCNT_U0_STATUS_REG (DR_REG_PCNT_BASE + 0x0050) -/* PCNT_CNT_THR_ZERO_LAT_U0 : RO ;bitpos:[6] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_ZERO_LAT_U0 (BIT(6)) -#define PCNT_CNT_THR_ZERO_LAT_U0_M (BIT(6)) -#define PCNT_CNT_THR_ZERO_LAT_U0_V 0x1 -#define PCNT_CNT_THR_ZERO_LAT_U0_S 6 -/* PCNT_CNT_THR_H_LIM_LAT_U0 : RO ;bitpos:[5] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_H_LIM_LAT_U0 (BIT(5)) -#define PCNT_CNT_THR_H_LIM_LAT_U0_M (BIT(5)) -#define PCNT_CNT_THR_H_LIM_LAT_U0_V 0x1 -#define PCNT_CNT_THR_H_LIM_LAT_U0_S 5 -/* PCNT_CNT_THR_L_LIM_LAT_U0 : RO ;bitpos:[4] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_L_LIM_LAT_U0 (BIT(4)) -#define PCNT_CNT_THR_L_LIM_LAT_U0_M (BIT(4)) -#define PCNT_CNT_THR_L_LIM_LAT_U0_V 0x1 -#define PCNT_CNT_THR_L_LIM_LAT_U0_S 4 -/* PCNT_CNT_THR_THRES0_LAT_U0 : RO ;bitpos:[3] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_THRES0_LAT_U0 (BIT(3)) -#define PCNT_CNT_THR_THRES0_LAT_U0_M (BIT(3)) -#define PCNT_CNT_THR_THRES0_LAT_U0_V 0x1 -#define PCNT_CNT_THR_THRES0_LAT_U0_S 3 -/* PCNT_CNT_THR_THRES1_LAT_U0 : RO ;bitpos:[2] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_THRES1_LAT_U0 (BIT(2)) -#define PCNT_CNT_THR_THRES1_LAT_U0_M (BIT(2)) -#define PCNT_CNT_THR_THRES1_LAT_U0_V 0x1 -#define PCNT_CNT_THR_THRES1_LAT_U0_S 2 -/* PCNT_CNT_THR_ZERO_MODE_U0 : RO ;bitpos:[1:0] ;default: 2'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_ZERO_MODE_U0 0x00000003 -#define PCNT_CNT_THR_ZERO_MODE_U0_M ((PCNT_CNT_THR_ZERO_MODE_U0_V)<<(PCNT_CNT_THR_ZERO_MODE_U0_S)) -#define PCNT_CNT_THR_ZERO_MODE_U0_V 0x3 +/** PCNT_U0_STATUS_REG register + * PNCT UNIT0 status register + */ +#define PCNT_U0_STATUS_REG (DR_REG_PCNT_BASE + 0x50) +/** PCNT_CNT_THR_ZERO_MODE_U0 : RO; bitpos: [1:0]; default: 0; + * The pulse counter status of PCNT_U0 corresponding to 0. 0: pulse counter decreases + * from positive to 0. 1: pulse counter increases from negative to 0. 2: pulse counter + * is negative. 3: pulse counter is positive. + */ +#define PCNT_CNT_THR_ZERO_MODE_U0 0x00000003U +#define PCNT_CNT_THR_ZERO_MODE_U0_M (PCNT_CNT_THR_ZERO_MODE_U0_V << PCNT_CNT_THR_ZERO_MODE_U0_S) +#define PCNT_CNT_THR_ZERO_MODE_U0_V 0x00000003U #define PCNT_CNT_THR_ZERO_MODE_U0_S 0 +/** PCNT_CNT_THR_THRES1_LAT_U0 : RO; bitpos: [2]; default: 0; + * The latched value of thres1 event of PCNT_U0 when threshold event interrupt is + * valid. 1: the current pulse counter equals to thres1 and thres1 event is valid. 0: + * others + */ +#define PCNT_CNT_THR_THRES1_LAT_U0 (BIT(2)) +#define PCNT_CNT_THR_THRES1_LAT_U0_M (PCNT_CNT_THR_THRES1_LAT_U0_V << PCNT_CNT_THR_THRES1_LAT_U0_S) +#define PCNT_CNT_THR_THRES1_LAT_U0_V 0x00000001U +#define PCNT_CNT_THR_THRES1_LAT_U0_S 2 +/** PCNT_CNT_THR_THRES0_LAT_U0 : RO; bitpos: [3]; default: 0; + * The latched value of thres0 event of PCNT_U0 when threshold event interrupt is + * valid. 1: the current pulse counter equals to thres0 and thres0 event is valid. 0: + * others + */ +#define PCNT_CNT_THR_THRES0_LAT_U0 (BIT(3)) +#define PCNT_CNT_THR_THRES0_LAT_U0_M (PCNT_CNT_THR_THRES0_LAT_U0_V << PCNT_CNT_THR_THRES0_LAT_U0_S) +#define PCNT_CNT_THR_THRES0_LAT_U0_V 0x00000001U +#define PCNT_CNT_THR_THRES0_LAT_U0_S 3 +/** PCNT_CNT_THR_L_LIM_LAT_U0 : RO; bitpos: [4]; default: 0; + * The latched value of low limit event of PCNT_U0 when threshold event interrupt is + * valid. 1: the current pulse counter equals to thr_l_lim and low limit event is + * valid. 0: others + */ +#define PCNT_CNT_THR_L_LIM_LAT_U0 (BIT(4)) +#define PCNT_CNT_THR_L_LIM_LAT_U0_M (PCNT_CNT_THR_L_LIM_LAT_U0_V << PCNT_CNT_THR_L_LIM_LAT_U0_S) +#define PCNT_CNT_THR_L_LIM_LAT_U0_V 0x00000001U +#define PCNT_CNT_THR_L_LIM_LAT_U0_S 4 +/** PCNT_CNT_THR_H_LIM_LAT_U0 : RO; bitpos: [5]; default: 0; + * The latched value of high limit event of PCNT_U0 when threshold event interrupt is + * valid. 1: the current pulse counter equals to thr_h_lim and high limit event is + * valid. 0: others + */ +#define PCNT_CNT_THR_H_LIM_LAT_U0 (BIT(5)) +#define PCNT_CNT_THR_H_LIM_LAT_U0_M (PCNT_CNT_THR_H_LIM_LAT_U0_V << PCNT_CNT_THR_H_LIM_LAT_U0_S) +#define PCNT_CNT_THR_H_LIM_LAT_U0_V 0x00000001U +#define PCNT_CNT_THR_H_LIM_LAT_U0_S 5 +/** PCNT_CNT_THR_ZERO_LAT_U0 : RO; bitpos: [6]; default: 0; + * The latched value of zero threshold event of PCNT_U0 when threshold event interrupt + * is valid. 1: the current pulse counter equals to 0 and zero threshold event is + * valid. 0: others + */ +#define PCNT_CNT_THR_ZERO_LAT_U0 (BIT(6)) +#define PCNT_CNT_THR_ZERO_LAT_U0_M (PCNT_CNT_THR_ZERO_LAT_U0_V << PCNT_CNT_THR_ZERO_LAT_U0_S) +#define PCNT_CNT_THR_ZERO_LAT_U0_V 0x00000001U +#define PCNT_CNT_THR_ZERO_LAT_U0_S 6 -#define PCNT_U1_STATUS_REG (DR_REG_PCNT_BASE + 0x0054) -/* PCNT_CNT_THR_ZERO_LAT_U1 : RO ;bitpos:[6] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_ZERO_LAT_U1 (BIT(6)) -#define PCNT_CNT_THR_ZERO_LAT_U1_M (BIT(6)) -#define PCNT_CNT_THR_ZERO_LAT_U1_V 0x1 -#define PCNT_CNT_THR_ZERO_LAT_U1_S 6 -/* PCNT_CNT_THR_H_LIM_LAT_U1 : RO ;bitpos:[5] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_H_LIM_LAT_U1 (BIT(5)) -#define PCNT_CNT_THR_H_LIM_LAT_U1_M (BIT(5)) -#define PCNT_CNT_THR_H_LIM_LAT_U1_V 0x1 -#define PCNT_CNT_THR_H_LIM_LAT_U1_S 5 -/* PCNT_CNT_THR_L_LIM_LAT_U1 : RO ;bitpos:[4] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_L_LIM_LAT_U1 (BIT(4)) -#define PCNT_CNT_THR_L_LIM_LAT_U1_M (BIT(4)) -#define PCNT_CNT_THR_L_LIM_LAT_U1_V 0x1 -#define PCNT_CNT_THR_L_LIM_LAT_U1_S 4 -/* PCNT_CNT_THR_THRES0_LAT_U1 : RO ;bitpos:[3] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_THRES0_LAT_U1 (BIT(3)) -#define PCNT_CNT_THR_THRES0_LAT_U1_M (BIT(3)) -#define PCNT_CNT_THR_THRES0_LAT_U1_V 0x1 -#define PCNT_CNT_THR_THRES0_LAT_U1_S 3 -/* PCNT_CNT_THR_THRES1_LAT_U1 : RO ;bitpos:[2] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_THRES1_LAT_U1 (BIT(2)) -#define PCNT_CNT_THR_THRES1_LAT_U1_M (BIT(2)) -#define PCNT_CNT_THR_THRES1_LAT_U1_V 0x1 -#define PCNT_CNT_THR_THRES1_LAT_U1_S 2 -/* PCNT_CNT_THR_ZERO_MODE_U1 : RO ;bitpos:[1:0] ;default: 2'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_ZERO_MODE_U1 0x00000003 -#define PCNT_CNT_THR_ZERO_MODE_U1_M ((PCNT_CNT_THR_ZERO_MODE_U1_V)<<(PCNT_CNT_THR_ZERO_MODE_U1_S)) -#define PCNT_CNT_THR_ZERO_MODE_U1_V 0x3 +/** PCNT_U1_STATUS_REG register + * PNCT UNIT1 status register + */ +#define PCNT_U1_STATUS_REG (DR_REG_PCNT_BASE + 0x54) +/** PCNT_CNT_THR_ZERO_MODE_U1 : RO; bitpos: [1:0]; default: 0; + * The pulse counter status of PCNT_U1 corresponding to 0. 0: pulse counter decreases + * from positive to 0. 1: pulse counter increases from negative to 0. 2: pulse counter + * is negative. 3: pulse counter is positive. + */ +#define PCNT_CNT_THR_ZERO_MODE_U1 0x00000003U +#define PCNT_CNT_THR_ZERO_MODE_U1_M (PCNT_CNT_THR_ZERO_MODE_U1_V << PCNT_CNT_THR_ZERO_MODE_U1_S) +#define PCNT_CNT_THR_ZERO_MODE_U1_V 0x00000003U #define PCNT_CNT_THR_ZERO_MODE_U1_S 0 +/** PCNT_CNT_THR_THRES1_LAT_U1 : RO; bitpos: [2]; default: 0; + * The latched value of thres1 event of PCNT_U1 when threshold event interrupt is + * valid. 1: the current pulse counter equals to thres1 and thres1 event is valid. 0: + * others + */ +#define PCNT_CNT_THR_THRES1_LAT_U1 (BIT(2)) +#define PCNT_CNT_THR_THRES1_LAT_U1_M (PCNT_CNT_THR_THRES1_LAT_U1_V << PCNT_CNT_THR_THRES1_LAT_U1_S) +#define PCNT_CNT_THR_THRES1_LAT_U1_V 0x00000001U +#define PCNT_CNT_THR_THRES1_LAT_U1_S 2 +/** PCNT_CNT_THR_THRES0_LAT_U1 : RO; bitpos: [3]; default: 0; + * The latched value of thres0 event of PCNT_U1 when threshold event interrupt is + * valid. 1: the current pulse counter equals to thres0 and thres0 event is valid. 0: + * others + */ +#define PCNT_CNT_THR_THRES0_LAT_U1 (BIT(3)) +#define PCNT_CNT_THR_THRES0_LAT_U1_M (PCNT_CNT_THR_THRES0_LAT_U1_V << PCNT_CNT_THR_THRES0_LAT_U1_S) +#define PCNT_CNT_THR_THRES0_LAT_U1_V 0x00000001U +#define PCNT_CNT_THR_THRES0_LAT_U1_S 3 +/** PCNT_CNT_THR_L_LIM_LAT_U1 : RO; bitpos: [4]; default: 0; + * The latched value of low limit event of PCNT_U1 when threshold event interrupt is + * valid. 1: the current pulse counter equals to thr_l_lim and low limit event is + * valid. 0: others + */ +#define PCNT_CNT_THR_L_LIM_LAT_U1 (BIT(4)) +#define PCNT_CNT_THR_L_LIM_LAT_U1_M (PCNT_CNT_THR_L_LIM_LAT_U1_V << PCNT_CNT_THR_L_LIM_LAT_U1_S) +#define PCNT_CNT_THR_L_LIM_LAT_U1_V 0x00000001U +#define PCNT_CNT_THR_L_LIM_LAT_U1_S 4 +/** PCNT_CNT_THR_H_LIM_LAT_U1 : RO; bitpos: [5]; default: 0; + * The latched value of high limit event of PCNT_U1 when threshold event interrupt is + * valid. 1: the current pulse counter equals to thr_h_lim and high limit event is + * valid. 0: others + */ +#define PCNT_CNT_THR_H_LIM_LAT_U1 (BIT(5)) +#define PCNT_CNT_THR_H_LIM_LAT_U1_M (PCNT_CNT_THR_H_LIM_LAT_U1_V << PCNT_CNT_THR_H_LIM_LAT_U1_S) +#define PCNT_CNT_THR_H_LIM_LAT_U1_V 0x00000001U +#define PCNT_CNT_THR_H_LIM_LAT_U1_S 5 +/** PCNT_CNT_THR_ZERO_LAT_U1 : RO; bitpos: [6]; default: 0; + * The latched value of zero threshold event of PCNT_U1 when threshold event interrupt + * is valid. 1: the current pulse counter equals to 0 and zero threshold event is + * valid. 0: others + */ +#define PCNT_CNT_THR_ZERO_LAT_U1 (BIT(6)) +#define PCNT_CNT_THR_ZERO_LAT_U1_M (PCNT_CNT_THR_ZERO_LAT_U1_V << PCNT_CNT_THR_ZERO_LAT_U1_S) +#define PCNT_CNT_THR_ZERO_LAT_U1_V 0x00000001U +#define PCNT_CNT_THR_ZERO_LAT_U1_S 6 -#define PCNT_U2_STATUS_REG (DR_REG_PCNT_BASE + 0x0058) -/* PCNT_CNT_THR_ZERO_LAT_U2 : RO ;bitpos:[6] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_ZERO_LAT_U2 (BIT(6)) -#define PCNT_CNT_THR_ZERO_LAT_U2_M (BIT(6)) -#define PCNT_CNT_THR_ZERO_LAT_U2_V 0x1 -#define PCNT_CNT_THR_ZERO_LAT_U2_S 6 -/* PCNT_CNT_THR_H_LIM_LAT_U2 : RO ;bitpos:[5] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_H_LIM_LAT_U2 (BIT(5)) -#define PCNT_CNT_THR_H_LIM_LAT_U2_M (BIT(5)) -#define PCNT_CNT_THR_H_LIM_LAT_U2_V 0x1 -#define PCNT_CNT_THR_H_LIM_LAT_U2_S 5 -/* PCNT_CNT_THR_L_LIM_LAT_U2 : RO ;bitpos:[4] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_L_LIM_LAT_U2 (BIT(4)) -#define PCNT_CNT_THR_L_LIM_LAT_U2_M (BIT(4)) -#define PCNT_CNT_THR_L_LIM_LAT_U2_V 0x1 -#define PCNT_CNT_THR_L_LIM_LAT_U2_S 4 -/* PCNT_CNT_THR_THRES0_LAT_U2 : RO ;bitpos:[3] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_THRES0_LAT_U2 (BIT(3)) -#define PCNT_CNT_THR_THRES0_LAT_U2_M (BIT(3)) -#define PCNT_CNT_THR_THRES0_LAT_U2_V 0x1 -#define PCNT_CNT_THR_THRES0_LAT_U2_S 3 -/* PCNT_CNT_THR_THRES1_LAT_U2 : RO ;bitpos:[2] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_THRES1_LAT_U2 (BIT(2)) -#define PCNT_CNT_THR_THRES1_LAT_U2_M (BIT(2)) -#define PCNT_CNT_THR_THRES1_LAT_U2_V 0x1 -#define PCNT_CNT_THR_THRES1_LAT_U2_S 2 -/* PCNT_CNT_THR_ZERO_MODE_U2 : RO ;bitpos:[1:0] ;default: 2'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_ZERO_MODE_U2 0x00000003 -#define PCNT_CNT_THR_ZERO_MODE_U2_M ((PCNT_CNT_THR_ZERO_MODE_U2_V)<<(PCNT_CNT_THR_ZERO_MODE_U2_S)) -#define PCNT_CNT_THR_ZERO_MODE_U2_V 0x3 +/** PCNT_U2_STATUS_REG register + * PNCT UNIT2 status register + */ +#define PCNT_U2_STATUS_REG (DR_REG_PCNT_BASE + 0x58) +/** PCNT_CNT_THR_ZERO_MODE_U2 : RO; bitpos: [1:0]; default: 0; + * The pulse counter status of PCNT_U2 corresponding to 0. 0: pulse counter decreases + * from positive to 0. 1: pulse counter increases from negative to 0. 2: pulse counter + * is negative. 3: pulse counter is positive. + */ +#define PCNT_CNT_THR_ZERO_MODE_U2 0x00000003U +#define PCNT_CNT_THR_ZERO_MODE_U2_M (PCNT_CNT_THR_ZERO_MODE_U2_V << PCNT_CNT_THR_ZERO_MODE_U2_S) +#define PCNT_CNT_THR_ZERO_MODE_U2_V 0x00000003U #define PCNT_CNT_THR_ZERO_MODE_U2_S 0 +/** PCNT_CNT_THR_THRES1_LAT_U2 : RO; bitpos: [2]; default: 0; + * The latched value of thres1 event of PCNT_U2 when threshold event interrupt is + * valid. 1: the current pulse counter equals to thres1 and thres1 event is valid. 0: + * others + */ +#define PCNT_CNT_THR_THRES1_LAT_U2 (BIT(2)) +#define PCNT_CNT_THR_THRES1_LAT_U2_M (PCNT_CNT_THR_THRES1_LAT_U2_V << PCNT_CNT_THR_THRES1_LAT_U2_S) +#define PCNT_CNT_THR_THRES1_LAT_U2_V 0x00000001U +#define PCNT_CNT_THR_THRES1_LAT_U2_S 2 +/** PCNT_CNT_THR_THRES0_LAT_U2 : RO; bitpos: [3]; default: 0; + * The latched value of thres0 event of PCNT_U2 when threshold event interrupt is + * valid. 1: the current pulse counter equals to thres0 and thres0 event is valid. 0: + * others + */ +#define PCNT_CNT_THR_THRES0_LAT_U2 (BIT(3)) +#define PCNT_CNT_THR_THRES0_LAT_U2_M (PCNT_CNT_THR_THRES0_LAT_U2_V << PCNT_CNT_THR_THRES0_LAT_U2_S) +#define PCNT_CNT_THR_THRES0_LAT_U2_V 0x00000001U +#define PCNT_CNT_THR_THRES0_LAT_U2_S 3 +/** PCNT_CNT_THR_L_LIM_LAT_U2 : RO; bitpos: [4]; default: 0; + * The latched value of low limit event of PCNT_U2 when threshold event interrupt is + * valid. 1: the current pulse counter equals to thr_l_lim and low limit event is + * valid. 0: others + */ +#define PCNT_CNT_THR_L_LIM_LAT_U2 (BIT(4)) +#define PCNT_CNT_THR_L_LIM_LAT_U2_M (PCNT_CNT_THR_L_LIM_LAT_U2_V << PCNT_CNT_THR_L_LIM_LAT_U2_S) +#define PCNT_CNT_THR_L_LIM_LAT_U2_V 0x00000001U +#define PCNT_CNT_THR_L_LIM_LAT_U2_S 4 +/** PCNT_CNT_THR_H_LIM_LAT_U2 : RO; bitpos: [5]; default: 0; + * The latched value of high limit event of PCNT_U2 when threshold event interrupt is + * valid. 1: the current pulse counter equals to thr_h_lim and high limit event is + * valid. 0: others + */ +#define PCNT_CNT_THR_H_LIM_LAT_U2 (BIT(5)) +#define PCNT_CNT_THR_H_LIM_LAT_U2_M (PCNT_CNT_THR_H_LIM_LAT_U2_V << PCNT_CNT_THR_H_LIM_LAT_U2_S) +#define PCNT_CNT_THR_H_LIM_LAT_U2_V 0x00000001U +#define PCNT_CNT_THR_H_LIM_LAT_U2_S 5 +/** PCNT_CNT_THR_ZERO_LAT_U2 : RO; bitpos: [6]; default: 0; + * The latched value of zero threshold event of PCNT_U2 when threshold event interrupt + * is valid. 1: the current pulse counter equals to 0 and zero threshold event is + * valid. 0: others + */ +#define PCNT_CNT_THR_ZERO_LAT_U2 (BIT(6)) +#define PCNT_CNT_THR_ZERO_LAT_U2_M (PCNT_CNT_THR_ZERO_LAT_U2_V << PCNT_CNT_THR_ZERO_LAT_U2_S) +#define PCNT_CNT_THR_ZERO_LAT_U2_V 0x00000001U +#define PCNT_CNT_THR_ZERO_LAT_U2_S 6 -#define PCNT_U3_STATUS_REG (DR_REG_PCNT_BASE + 0x005c) -/* PCNT_CNT_THR_ZERO_LAT_U3 : RO ;bitpos:[6] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_ZERO_LAT_U3 (BIT(6)) -#define PCNT_CNT_THR_ZERO_LAT_U3_M (BIT(6)) -#define PCNT_CNT_THR_ZERO_LAT_U3_V 0x1 -#define PCNT_CNT_THR_ZERO_LAT_U3_S 6 -/* PCNT_CNT_THR_H_LIM_LAT_U3 : RO ;bitpos:[5] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_H_LIM_LAT_U3 (BIT(5)) -#define PCNT_CNT_THR_H_LIM_LAT_U3_M (BIT(5)) -#define PCNT_CNT_THR_H_LIM_LAT_U3_V 0x1 -#define PCNT_CNT_THR_H_LIM_LAT_U3_S 5 -/* PCNT_CNT_THR_L_LIM_LAT_U3 : RO ;bitpos:[4] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_L_LIM_LAT_U3 (BIT(4)) -#define PCNT_CNT_THR_L_LIM_LAT_U3_M (BIT(4)) -#define PCNT_CNT_THR_L_LIM_LAT_U3_V 0x1 -#define PCNT_CNT_THR_L_LIM_LAT_U3_S 4 -/* PCNT_CNT_THR_THRES0_LAT_U3 : RO ;bitpos:[3] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_THRES0_LAT_U3 (BIT(3)) -#define PCNT_CNT_THR_THRES0_LAT_U3_M (BIT(3)) -#define PCNT_CNT_THR_THRES0_LAT_U3_V 0x1 -#define PCNT_CNT_THR_THRES0_LAT_U3_S 3 -/* PCNT_CNT_THR_THRES1_LAT_U3 : RO ;bitpos:[2] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_THRES1_LAT_U3 (BIT(2)) -#define PCNT_CNT_THR_THRES1_LAT_U3_M (BIT(2)) -#define PCNT_CNT_THR_THRES1_LAT_U3_V 0x1 -#define PCNT_CNT_THR_THRES1_LAT_U3_S 2 -/* PCNT_CNT_THR_ZERO_MODE_U3 : RO ;bitpos:[1:0] ;default: 2'b0 ; */ -/*description: */ -#define PCNT_CNT_THR_ZERO_MODE_U3 0x00000003 -#define PCNT_CNT_THR_ZERO_MODE_U3_M ((PCNT_CNT_THR_ZERO_MODE_U3_V)<<(PCNT_CNT_THR_ZERO_MODE_U3_S)) -#define PCNT_CNT_THR_ZERO_MODE_U3_V 0x3 +/** PCNT_U3_STATUS_REG register + * PNCT UNIT3 status register + */ +#define PCNT_U3_STATUS_REG (DR_REG_PCNT_BASE + 0x5c) +/** PCNT_CNT_THR_ZERO_MODE_U3 : RO; bitpos: [1:0]; default: 0; + * The pulse counter status of PCNT_U3 corresponding to 0. 0: pulse counter decreases + * from positive to 0. 1: pulse counter increases from negative to 0. 2: pulse counter + * is negative. 3: pulse counter is positive. + */ +#define PCNT_CNT_THR_ZERO_MODE_U3 0x00000003U +#define PCNT_CNT_THR_ZERO_MODE_U3_M (PCNT_CNT_THR_ZERO_MODE_U3_V << PCNT_CNT_THR_ZERO_MODE_U3_S) +#define PCNT_CNT_THR_ZERO_MODE_U3_V 0x00000003U #define PCNT_CNT_THR_ZERO_MODE_U3_S 0 +/** PCNT_CNT_THR_THRES1_LAT_U3 : RO; bitpos: [2]; default: 0; + * The latched value of thres1 event of PCNT_U3 when threshold event interrupt is + * valid. 1: the current pulse counter equals to thres1 and thres1 event is valid. 0: + * others + */ +#define PCNT_CNT_THR_THRES1_LAT_U3 (BIT(2)) +#define PCNT_CNT_THR_THRES1_LAT_U3_M (PCNT_CNT_THR_THRES1_LAT_U3_V << PCNT_CNT_THR_THRES1_LAT_U3_S) +#define PCNT_CNT_THR_THRES1_LAT_U3_V 0x00000001U +#define PCNT_CNT_THR_THRES1_LAT_U3_S 2 +/** PCNT_CNT_THR_THRES0_LAT_U3 : RO; bitpos: [3]; default: 0; + * The latched value of thres0 event of PCNT_U3 when threshold event interrupt is + * valid. 1: the current pulse counter equals to thres0 and thres0 event is valid. 0: + * others + */ +#define PCNT_CNT_THR_THRES0_LAT_U3 (BIT(3)) +#define PCNT_CNT_THR_THRES0_LAT_U3_M (PCNT_CNT_THR_THRES0_LAT_U3_V << PCNT_CNT_THR_THRES0_LAT_U3_S) +#define PCNT_CNT_THR_THRES0_LAT_U3_V 0x00000001U +#define PCNT_CNT_THR_THRES0_LAT_U3_S 3 +/** PCNT_CNT_THR_L_LIM_LAT_U3 : RO; bitpos: [4]; default: 0; + * The latched value of low limit event of PCNT_U3 when threshold event interrupt is + * valid. 1: the current pulse counter equals to thr_l_lim and low limit event is + * valid. 0: others + */ +#define PCNT_CNT_THR_L_LIM_LAT_U3 (BIT(4)) +#define PCNT_CNT_THR_L_LIM_LAT_U3_M (PCNT_CNT_THR_L_LIM_LAT_U3_V << PCNT_CNT_THR_L_LIM_LAT_U3_S) +#define PCNT_CNT_THR_L_LIM_LAT_U3_V 0x00000001U +#define PCNT_CNT_THR_L_LIM_LAT_U3_S 4 +/** PCNT_CNT_THR_H_LIM_LAT_U3 : RO; bitpos: [5]; default: 0; + * The latched value of high limit event of PCNT_U3 when threshold event interrupt is + * valid. 1: the current pulse counter equals to thr_h_lim and high limit event is + * valid. 0: others + */ +#define PCNT_CNT_THR_H_LIM_LAT_U3 (BIT(5)) +#define PCNT_CNT_THR_H_LIM_LAT_U3_M (PCNT_CNT_THR_H_LIM_LAT_U3_V << PCNT_CNT_THR_H_LIM_LAT_U3_S) +#define PCNT_CNT_THR_H_LIM_LAT_U3_V 0x00000001U +#define PCNT_CNT_THR_H_LIM_LAT_U3_S 5 +/** PCNT_CNT_THR_ZERO_LAT_U3 : RO; bitpos: [6]; default: 0; + * The latched value of zero threshold event of PCNT_U3 when threshold event interrupt + * is valid. 1: the current pulse counter equals to 0 and zero threshold event is + * valid. 0: others + */ +#define PCNT_CNT_THR_ZERO_LAT_U3 (BIT(6)) +#define PCNT_CNT_THR_ZERO_LAT_U3_M (PCNT_CNT_THR_ZERO_LAT_U3_V << PCNT_CNT_THR_ZERO_LAT_U3_S) +#define PCNT_CNT_THR_ZERO_LAT_U3_V 0x00000001U +#define PCNT_CNT_THR_ZERO_LAT_U3_S 6 -#define PCNT_CTRL_REG (DR_REG_PCNT_BASE + 0x0060) -/* PCNT_CLK_EN : R/W ;bitpos:[16] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CLK_EN (BIT(16)) -#define PCNT_CLK_EN_M (BIT(16)) -#define PCNT_CLK_EN_V 0x1 -#define PCNT_CLK_EN_S 16 -/* PCNT_CNT_PAUSE_U3 : R/W ;bitpos:[7] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_PAUSE_U3 (BIT(7)) -#define PCNT_CNT_PAUSE_U3_M (BIT(7)) -#define PCNT_CNT_PAUSE_U3_V 0x1 -#define PCNT_CNT_PAUSE_U3_S 7 -/* PCNT_PULSE_CNT_RST_U3 : R/W ;bitpos:[6] ;default: 1'b1 ; */ -/*description: */ -#define PCNT_PULSE_CNT_RST_U3 (BIT(6)) -#define PCNT_PULSE_CNT_RST_U3_M (BIT(6)) -#define PCNT_PULSE_CNT_RST_U3_V 0x1 -#define PCNT_PULSE_CNT_RST_U3_S 6 -/* PCNT_CNT_PAUSE_U2 : R/W ;bitpos:[5] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_PAUSE_U2 (BIT(5)) -#define PCNT_CNT_PAUSE_U2_M (BIT(5)) -#define PCNT_CNT_PAUSE_U2_V 0x1 -#define PCNT_CNT_PAUSE_U2_S 5 -/* PCNT_PULSE_CNT_RST_U2 : R/W ;bitpos:[4] ;default: 1'b1 ; */ -/*description: */ -#define PCNT_PULSE_CNT_RST_U2 (BIT(4)) -#define PCNT_PULSE_CNT_RST_U2_M (BIT(4)) -#define PCNT_PULSE_CNT_RST_U2_V 0x1 -#define PCNT_PULSE_CNT_RST_U2_S 4 -/* PCNT_CNT_PAUSE_U1 : R/W ;bitpos:[3] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_PAUSE_U1 (BIT(3)) -#define PCNT_CNT_PAUSE_U1_M (BIT(3)) -#define PCNT_CNT_PAUSE_U1_V 0x1 -#define PCNT_CNT_PAUSE_U1_S 3 -/* PCNT_PULSE_CNT_RST_U1 : R/W ;bitpos:[2] ;default: 1'b1 ; */ -/*description: */ -#define PCNT_PULSE_CNT_RST_U1 (BIT(2)) -#define PCNT_PULSE_CNT_RST_U1_M (BIT(2)) -#define PCNT_PULSE_CNT_RST_U1_V 0x1 -#define PCNT_PULSE_CNT_RST_U1_S 2 -/* PCNT_CNT_PAUSE_U0 : R/W ;bitpos:[1] ;default: 1'b0 ; */ -/*description: */ -#define PCNT_CNT_PAUSE_U0 (BIT(1)) -#define PCNT_CNT_PAUSE_U0_M (BIT(1)) -#define PCNT_CNT_PAUSE_U0_V 0x1 -#define PCNT_CNT_PAUSE_U0_S 1 -/* PCNT_PULSE_CNT_RST_U0 : R/W ;bitpos:[0] ;default: 1'b1 ; */ -/*description: */ -#define PCNT_PULSE_CNT_RST_U0 (BIT(0)) -#define PCNT_PULSE_CNT_RST_U0_M (BIT(0)) -#define PCNT_PULSE_CNT_RST_U0_V 0x1 +/** PCNT_CTRL_REG register + * Control register for all counters + */ +#define PCNT_CTRL_REG (DR_REG_PCNT_BASE + 0x60) +/** PCNT_PULSE_CNT_RST_U0 : R/W; bitpos: [0]; default: 1; + * Set this bit to clear unit 0's counter. + */ +#define PCNT_PULSE_CNT_RST_U0 (BIT(0)) +#define PCNT_PULSE_CNT_RST_U0_M (PCNT_PULSE_CNT_RST_U0_V << PCNT_PULSE_CNT_RST_U0_S) +#define PCNT_PULSE_CNT_RST_U0_V 0x00000001U #define PCNT_PULSE_CNT_RST_U0_S 0 +/** PCNT_CNT_PAUSE_U0 : R/W; bitpos: [1]; default: 0; + * Set this bit to freeze unit 0's counter. + */ +#define PCNT_CNT_PAUSE_U0 (BIT(1)) +#define PCNT_CNT_PAUSE_U0_M (PCNT_CNT_PAUSE_U0_V << PCNT_CNT_PAUSE_U0_S) +#define PCNT_CNT_PAUSE_U0_V 0x00000001U +#define PCNT_CNT_PAUSE_U0_S 1 +/** PCNT_PULSE_CNT_RST_U1 : R/W; bitpos: [2]; default: 1; + * Set this bit to clear unit 1's counter. + */ +#define PCNT_PULSE_CNT_RST_U1 (BIT(2)) +#define PCNT_PULSE_CNT_RST_U1_M (PCNT_PULSE_CNT_RST_U1_V << PCNT_PULSE_CNT_RST_U1_S) +#define PCNT_PULSE_CNT_RST_U1_V 0x00000001U +#define PCNT_PULSE_CNT_RST_U1_S 2 +/** PCNT_CNT_PAUSE_U1 : R/W; bitpos: [3]; default: 0; + * Set this bit to freeze unit 1's counter. + */ +#define PCNT_CNT_PAUSE_U1 (BIT(3)) +#define PCNT_CNT_PAUSE_U1_M (PCNT_CNT_PAUSE_U1_V << PCNT_CNT_PAUSE_U1_S) +#define PCNT_CNT_PAUSE_U1_V 0x00000001U +#define PCNT_CNT_PAUSE_U1_S 3 +/** PCNT_PULSE_CNT_RST_U2 : R/W; bitpos: [4]; default: 1; + * Set this bit to clear unit 2's counter. + */ +#define PCNT_PULSE_CNT_RST_U2 (BIT(4)) +#define PCNT_PULSE_CNT_RST_U2_M (PCNT_PULSE_CNT_RST_U2_V << PCNT_PULSE_CNT_RST_U2_S) +#define PCNT_PULSE_CNT_RST_U2_V 0x00000001U +#define PCNT_PULSE_CNT_RST_U2_S 4 +/** PCNT_CNT_PAUSE_U2 : R/W; bitpos: [5]; default: 0; + * Set this bit to freeze unit 2's counter. + */ +#define PCNT_CNT_PAUSE_U2 (BIT(5)) +#define PCNT_CNT_PAUSE_U2_M (PCNT_CNT_PAUSE_U2_V << PCNT_CNT_PAUSE_U2_S) +#define PCNT_CNT_PAUSE_U2_V 0x00000001U +#define PCNT_CNT_PAUSE_U2_S 5 +/** PCNT_PULSE_CNT_RST_U3 : R/W; bitpos: [6]; default: 1; + * Set this bit to clear unit 3's counter. + */ +#define PCNT_PULSE_CNT_RST_U3 (BIT(6)) +#define PCNT_PULSE_CNT_RST_U3_M (PCNT_PULSE_CNT_RST_U3_V << PCNT_PULSE_CNT_RST_U3_S) +#define PCNT_PULSE_CNT_RST_U3_V 0x00000001U +#define PCNT_PULSE_CNT_RST_U3_S 6 +/** PCNT_CNT_PAUSE_U3 : R/W; bitpos: [7]; default: 0; + * Set this bit to freeze unit 3's counter. + */ +#define PCNT_CNT_PAUSE_U3 (BIT(7)) +#define PCNT_CNT_PAUSE_U3_M (PCNT_CNT_PAUSE_U3_V << PCNT_CNT_PAUSE_U3_S) +#define PCNT_CNT_PAUSE_U3_V 0x00000001U +#define PCNT_CNT_PAUSE_U3_S 7 +/** PCNT_CLK_EN : R/W; bitpos: [16]; default: 0; + * The registers clock gate enable signal of PCNT module. 1: the registers can be read + * and written by application. 0: the registers can not be read or written by + * application + */ +#define PCNT_CLK_EN (BIT(16)) +#define PCNT_CLK_EN_M (PCNT_CLK_EN_V << PCNT_CLK_EN_S) +#define PCNT_CLK_EN_V 0x00000001U +#define PCNT_CLK_EN_S 16 -#define PCNT_DATE_REG (DR_REG_PCNT_BASE + 0x00fc) -/* PCNT_DATE : R/W ;bitpos:[31:0] ;default: 32'h18072600 ; */ -/*description: */ -#define PCNT_DATE 0xFFFFFFFF -#define PCNT_DATE_M ((PCNT_DATE_V)<<(PCNT_DATE_S)) -#define PCNT_DATE_V 0xFFFFFFFF +/** PCNT_DATE_REG register + * PCNT version control register + */ +#define PCNT_DATE_REG (DR_REG_PCNT_BASE + 0xfc) +/** PCNT_DATE : R/W; bitpos: [31:0]; default: 419898881; + * This is the PCNT version control register. + */ +#define PCNT_DATE 0xFFFFFFFFU +#define PCNT_DATE_M (PCNT_DATE_V << PCNT_DATE_S) +#define PCNT_DATE_V 0xFFFFFFFFU #define PCNT_DATE_S 0 #ifdef __cplusplus } #endif - - - -#endif /*_SOC_PCNT_REG_H_ */ diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/pcnt_struct.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/pcnt_struct.h index b0c811f9cb7..1d65a7309bf 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/pcnt_struct.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/pcnt_struct.h @@ -1,177 +1,416 @@ -// Copyright 2017-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. -#ifndef _SOC_PCNT_STRUCT_H_ -#define _SOC_PCNT_STRUCT_H_ +/** Copyright 2021 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 + #ifdef __cplusplus extern "C" { #endif -typedef volatile struct { +/** Group: Configuration Register */ +/** Type of un_conf0 register + * Configuration register 0 for unit n + */ +typedef union { + struct { + /** filter_thres_un : R/W; bitpos: [9:0]; default: 16; + * This sets the maximum threshold, in APB_CLK cycles, for the filter. + * + * Any pulses with width less than this will be ignored when the filter is enabled. + */ + uint32_t filter_thres_un: 10; + /** filter_en_un : R/W; bitpos: [10]; default: 1; + * This is the enable bit for unit n's input filter. + */ + uint32_t filter_en_un: 1; + /** thr_zero_en_un : R/W; bitpos: [11]; default: 1; + * This is the enable bit for unit n's zero comparator. + */ + uint32_t thr_zero_en_un: 1; + /** thr_h_lim_en_un : R/W; bitpos: [12]; default: 1; + * This is the enable bit for unit n's thr_h_lim comparator. + */ + uint32_t thr_h_lim_en_un: 1; + /** thr_l_lim_en_un : R/W; bitpos: [13]; default: 1; + * This is the enable bit for unit n's thr_l_lim comparator. + */ + uint32_t thr_l_lim_en_un: 1; + /** thr_thres0_en_un : R/W; bitpos: [14]; default: 0; + * This is the enable bit for unit n's thres0 comparator. + */ + uint32_t thr_thres0_en_un: 1; + /** thr_thres1_en_un : R/W; bitpos: [15]; default: 0; + * This is the enable bit for unit n's thres1 comparator. + */ + uint32_t thr_thres1_en_un: 1; + /** ch0_neg_mode_un : R/W; bitpos: [17:16]; default: 0; + * This register sets the behavior when the signal input of channel 0 detects a + * negative edge. + * + * 1: Increase the counter;2: Decrease the counter;0, 3: No effect on counter + */ + uint32_t ch0_neg_mode_un: 2; + /** ch0_pos_mode_un : R/W; bitpos: [19:18]; default: 0; + * This register sets the behavior when the signal input of channel 0 detects a + * positive edge. + * + * 1: Increase the counter;2: Decrease the counter;0, 3: No effect on counter + */ + uint32_t ch0_pos_mode_un: 2; + /** ch0_hctrl_mode_un : R/W; bitpos: [21:20]; default: 0; + * This register configures how the CHn_POS_MODE/CHn_NEG_MODE settings will be + * modified when the control signal is high. + * + * 0: No modification;1: Invert behavior (increase -> decrease, decrease -> + * increase);2, 3: Inhibit counter modification + */ + uint32_t ch0_hctrl_mode_un: 2; + /** ch0_lctrl_mode_un : R/W; bitpos: [23:22]; default: 0; + * This register configures how the CHn_POS_MODE/CHn_NEG_MODE settings will be + * modified when the control signal is low. + * + * 0: No modification;1: Invert behavior (increase -> decrease, decrease -> + * increase);2, 3: Inhibit counter modification + */ + uint32_t ch0_lctrl_mode_un: 2; + /** ch1_neg_mode_un : R/W; bitpos: [25:24]; default: 0; + * This register sets the behavior when the signal input of channel 1 detects a + * negative edge. + * + * 1: Increment the counter;2: Decrement the counter;0, 3: No effect on counter + */ + uint32_t ch1_neg_mode_un: 2; + /** ch1_pos_mode_un : R/W; bitpos: [27:26]; default: 0; + * This register sets the behavior when the signal input of channel 1 detects a + * positive edge. + * + * 1: Increment the counter;2: Decrement the counter;0, 3: No effect on counter + */ + uint32_t ch1_pos_mode_un: 2; + /** ch1_hctrl_mode_un : R/W; bitpos: [29:28]; default: 0; + * This register configures how the CHn_POS_MODE/CHn_NEG_MODE settings will be + * modified when the control signal is high. + * + * 0: No modification;1: Invert behavior (increase -> decrease, decrease -> + * increase);2, 3: Inhibit counter modification + */ + uint32_t ch1_hctrl_mode_un: 2; + /** ch1_lctrl_mode_un : R/W; bitpos: [31:30]; default: 0; + * This register configures how the CHn_POS_MODE/CHn_NEG_MODE settings will be + * modified when the control signal is low. + * + * 0: No modification;1: Invert behavior (increase -> decrease, decrease -> + * increase);2, 3: Inhibit counter modification + */ + uint32_t ch1_lctrl_mode_un: 2; + }; + uint32_t val; +} pcnt_un_conf0_reg_t; + +/** Type of un_conf1 register + * Configuration register 1 for unit n + */ +typedef union { + struct { + /** cnt_thres0_un : R/W; bitpos: [15:0]; default: 0; + * This register is used to configure the thres0 value for unit n. + */ + uint32_t cnt_thres0_un: 16; + /** cnt_thres1_un : R/W; bitpos: [31:16]; default: 0; + * This register is used to configure the thres1 value for unit n. + */ + uint32_t cnt_thres1_un: 16; + }; + uint32_t val; +} pcnt_un_conf1_reg_t; + +/** Type of un_conf2 register + * Configuration register 2 for unit n + */ +typedef union { + struct { + /** cnt_h_lim_un : R/W; bitpos: [15:0]; default: 0; + * This register is used to configure the thr_h_lim value for unit n. + */ + uint32_t cnt_h_lim_un: 16; + /** cnt_l_lim_un : R/W; bitpos: [31:16]; default: 0; + * This register is used to configure the thr_l_lim value for unit n. + */ + uint32_t cnt_l_lim_un: 16; + }; + uint32_t val; +} pcnt_un_conf2_reg_t; + + +/** Type of ctrl register + * Control register for all counters + */ +typedef union { + struct { + /** pulse_cnt_rst_u0 : R/W; bitpos: [0]; default: 1; + * Set this bit to clear unit 0's counter. + */ + uint32_t pulse_cnt_rst_u0: 1; + /** cnt_pause_u0 : R/W; bitpos: [1]; default: 0; + * Set this bit to freeze unit 0's counter. + */ + uint32_t cnt_pause_u0: 1; + /** pulse_cnt_rst_u1 : R/W; bitpos: [2]; default: 1; + * Set this bit to clear unit 1's counter. + */ + uint32_t pulse_cnt_rst_u1: 1; + /** cnt_pause_u1 : R/W; bitpos: [3]; default: 0; + * Set this bit to freeze unit 1's counter. + */ + uint32_t cnt_pause_u1: 1; + /** pulse_cnt_rst_u2 : R/W; bitpos: [4]; default: 1; + * Set this bit to clear unit 2's counter. + */ + uint32_t pulse_cnt_rst_u2: 1; + /** cnt_pause_u2 : R/W; bitpos: [5]; default: 0; + * Set this bit to freeze unit 2's counter. + */ + uint32_t cnt_pause_u2: 1; + /** pulse_cnt_rst_u3 : R/W; bitpos: [6]; default: 1; + * Set this bit to clear unit 3's counter. + */ + uint32_t pulse_cnt_rst_u3: 1; + /** cnt_pause_u3 : R/W; bitpos: [7]; default: 0; + * Set this bit to freeze unit 3's counter. + */ + uint32_t cnt_pause_u3: 1; + uint32_t reserved_8: 8; + /** clk_en : R/W; bitpos: [16]; default: 0; + * The registers clock gate enable signal of PCNT module. 1: the registers can be read + * and written by application. 0: the registers can not be read or written by + * application + */ + uint32_t clk_en: 1; + uint32_t reserved_17: 15; + }; + uint32_t val; +} pcnt_ctrl_reg_t; + + +/** Group: Status Register */ +/** Type of un_cnt register + * Counter value for unit n + */ +typedef union { + struct { + /** pulse_cnt_un : RO; bitpos: [15:0]; default: 0; + * This register stores the current pulse count value for unit n. + */ + uint32_t pulse_cnt_un: 16; + uint32_t reserved_16: 16; + }; + uint32_t val; +} pcnt_un_cnt_reg_t; + +/** Type of un_status register + * PNCT UNITn status register + */ +typedef union { + struct { + /** cnt_thr_zero_mode_un : RO; bitpos: [1:0]; default: 0; + * The pulse counter status of PCNT_Un corresponding to 0. 0: pulse counter decreases + * from positive to 0. 1: pulse counter increases from negative to 0. 2: pulse counter + * is negative. 3: pulse counter is positive. + */ + uint32_t cnt_thr_zero_mode_un: 2; + /** cnt_thr_thres1_lat_un : RO; bitpos: [2]; default: 0; + * The latched value of thres1 event of PCNT_Un when threshold event interrupt is + * valid. 1: the current pulse counter equals to thres1 and thres1 event is valid. 0: + * others + */ + uint32_t cnt_thr_thres1_lat_un: 1; + /** cnt_thr_thres0_lat_un : RO; bitpos: [3]; default: 0; + * The latched value of thres0 event of PCNT_Un when threshold event interrupt is + * valid. 1: the current pulse counter equals to thres0 and thres0 event is valid. 0: + * others + */ + uint32_t cnt_thr_thres0_lat_un: 1; + /** cnt_thr_l_lim_lat_un : RO; bitpos: [4]; default: 0; + * The latched value of low limit event of PCNT_Un when threshold event interrupt is + * valid. 1: the current pulse counter equals to thr_l_lim and low limit event is + * valid. 0: others + */ + uint32_t cnt_thr_l_lim_lat_un: 1; + /** cnt_thr_h_lim_lat_un : RO; bitpos: [5]; default: 0; + * The latched value of high limit event of PCNT_Un when threshold event interrupt is + * valid. 1: the current pulse counter equals to thr_h_lim and high limit event is + * valid. 0: others + */ + uint32_t cnt_thr_h_lim_lat_un: 1; + /** cnt_thr_zero_lat_un : RO; bitpos: [6]; default: 0; + * The latched value of zero threshold event of PCNT_Un when threshold event interrupt + * is valid. 1: the current pulse counter equals to 0 and zero threshold event is + * valid. 0: others + */ + uint32_t cnt_thr_zero_lat_un: 1; + uint32_t reserved_7: 25; + }; + uint32_t val; +} pcnt_un_status_reg_t; + + +/** Group: Interrupt Register */ +/** Type of int_raw register + * Interrupt raw status register + */ +typedef union { struct { - union { - struct { - uint32_t filter_thres: 10; - uint32_t filter_en: 1; - uint32_t thr_zero_en: 1; - uint32_t thr_h_lim_en: 1; - uint32_t thr_l_lim_en: 1; - uint32_t thr_thres0_en: 1; - uint32_t thr_thres1_en: 1; - uint32_t ch0_neg_mode: 2; - uint32_t ch0_pos_mode: 2; - uint32_t ch0_hctrl_mode: 2; - uint32_t ch0_lctrl_mode: 2; - uint32_t ch1_neg_mode: 2; - uint32_t ch1_pos_mode: 2; - uint32_t ch1_hctrl_mode: 2; - uint32_t ch1_lctrl_mode: 2; - }; - uint32_t val; - } conf0; - union { - struct { - uint32_t cnt_thres0: 16; - uint32_t cnt_thres1: 16; - }; - uint32_t val; - } conf1; - union { - struct { - uint32_t cnt_h_lim: 16; - uint32_t cnt_l_lim: 16; - }; - uint32_t val; - } conf2; + /** cnt_thr_event_u0_int_raw : RO; bitpos: [0]; default: 0; + * The raw interrupt status bit for the PCNT_CNT_THR_EVENT_U0_INT interrupt. + */ + uint32_t cnt_thr_event_u0_int_raw: 1; + /** cnt_thr_event_u1_int_raw : RO; bitpos: [1]; default: 0; + * The raw interrupt status bit for the PCNT_CNT_THR_EVENT_U1_INT interrupt. + */ + uint32_t cnt_thr_event_u1_int_raw: 1; + /** cnt_thr_event_u2_int_raw : RO; bitpos: [2]; default: 0; + * The raw interrupt status bit for the PCNT_CNT_THR_EVENT_U2_INT interrupt. + */ + uint32_t cnt_thr_event_u2_int_raw: 1; + /** cnt_thr_event_u3_int_raw : RO; bitpos: [3]; default: 0; + * The raw interrupt status bit for the PCNT_CNT_THR_EVENT_U3_INT interrupt. + */ + uint32_t cnt_thr_event_u3_int_raw: 1; + uint32_t reserved_4: 28; + }; + uint32_t val; +} pcnt_int_raw_reg_t; + +/** Type of int_st register + * Interrupt status register + */ +typedef union { + struct { + /** cnt_thr_event_u0_int_st : RO; bitpos: [0]; default: 0; + * The masked interrupt status bit for the PCNT_CNT_THR_EVENT_U0_INT interrupt. + */ + uint32_t cnt_thr_event_u0_int_st: 1; + /** cnt_thr_event_u1_int_st : RO; bitpos: [1]; default: 0; + * The masked interrupt status bit for the PCNT_CNT_THR_EVENT_U1_INT interrupt. + */ + uint32_t cnt_thr_event_u1_int_st: 1; + /** cnt_thr_event_u2_int_st : RO; bitpos: [2]; default: 0; + * The masked interrupt status bit for the PCNT_CNT_THR_EVENT_U2_INT interrupt. + */ + uint32_t cnt_thr_event_u2_int_st: 1; + /** cnt_thr_event_u3_int_st : RO; bitpos: [3]; default: 0; + * The masked interrupt status bit for the PCNT_CNT_THR_EVENT_U3_INT interrupt. + */ + uint32_t cnt_thr_event_u3_int_st: 1; + uint32_t reserved_4: 28; + }; + uint32_t val; +} pcnt_int_st_reg_t; + +/** Type of int_ena register + * Interrupt enable register + */ +typedef union { + struct { + /** cnt_thr_event_u0_int_ena : R/W; bitpos: [0]; default: 0; + * The interrupt enable bit for the PCNT_CNT_THR_EVENT_U0_INT interrupt. + */ + uint32_t cnt_thr_event_u0_int_ena: 1; + /** cnt_thr_event_u1_int_ena : R/W; bitpos: [1]; default: 0; + * The interrupt enable bit for the PCNT_CNT_THR_EVENT_U1_INT interrupt. + */ + uint32_t cnt_thr_event_u1_int_ena: 1; + /** cnt_thr_event_u2_int_ena : R/W; bitpos: [2]; default: 0; + * The interrupt enable bit for the PCNT_CNT_THR_EVENT_U2_INT interrupt. + */ + uint32_t cnt_thr_event_u2_int_ena: 1; + /** cnt_thr_event_u3_int_ena : R/W; bitpos: [3]; default: 0; + * The interrupt enable bit for the PCNT_CNT_THR_EVENT_U3_INT interrupt. + */ + uint32_t cnt_thr_event_u3_int_ena: 1; + uint32_t reserved_4: 28; + }; + uint32_t val; +} pcnt_int_ena_reg_t; + +/** Type of int_clr register + * Interrupt clear register + */ +typedef union { + struct { + /** cnt_thr_event_u0_int_clr : WO; bitpos: [0]; default: 0; + * Set this bit to clear the PCNT_CNT_THR_EVENT_U0_INT interrupt. + */ + uint32_t cnt_thr_event_u0_int_clr: 1; + /** cnt_thr_event_u1_int_clr : WO; bitpos: [1]; default: 0; + * Set this bit to clear the PCNT_CNT_THR_EVENT_U1_INT interrupt. + */ + uint32_t cnt_thr_event_u1_int_clr: 1; + /** cnt_thr_event_u2_int_clr : WO; bitpos: [2]; default: 0; + * Set this bit to clear the PCNT_CNT_THR_EVENT_U2_INT interrupt. + */ + uint32_t cnt_thr_event_u2_int_clr: 1; + /** cnt_thr_event_u3_int_clr : WO; bitpos: [3]; default: 0; + * Set this bit to clear the PCNT_CNT_THR_EVENT_U3_INT interrupt. + */ + uint32_t cnt_thr_event_u3_int_clr: 1; + uint32_t reserved_4: 28; + }; + uint32_t val; +} pcnt_int_clr_reg_t; + + +/** Group: Version Register */ +/** Type of date register + * PCNT version control register + */ +typedef union { + struct { + /** date : R/W; bitpos: [31:0]; default: 419898881; + * This is the PCNT version control register. + */ + uint32_t date: 32; + }; + uint32_t val; +} pcnt_date_reg_t; + + +typedef struct { + volatile struct { + pcnt_un_conf0_reg_t conf0; + pcnt_un_conf1_reg_t conf1; + pcnt_un_conf2_reg_t conf2; } conf_unit[4]; - union { - struct { - uint32_t cnt_val: 16; - uint32_t reserved16: 16; - }; - uint32_t val; - } cnt_unit[4]; - union { - struct { - uint32_t cnt_thr_event_u0: 1; - uint32_t cnt_thr_event_u1: 1; - uint32_t cnt_thr_event_u2: 1; - uint32_t cnt_thr_event_u3: 1; - uint32_t reserved4: 28; - }; - uint32_t val; - } int_raw; - union { - struct { - uint32_t cnt_thr_event_u0: 1; - uint32_t cnt_thr_event_u1: 1; - uint32_t cnt_thr_event_u2: 1; - uint32_t cnt_thr_event_u3: 1; - uint32_t reserved4: 28; - }; - uint32_t val; - } int_st; - union { - struct { - uint32_t cnt_thr_event_u0: 1; - uint32_t cnt_thr_event_u1: 1; - uint32_t cnt_thr_event_u2: 1; - uint32_t cnt_thr_event_u3: 1; - uint32_t reserved4: 28; - }; - uint32_t val; - } int_ena; - union { - struct { - uint32_t cnt_thr_event_u0: 1; - uint32_t cnt_thr_event_u1: 1; - uint32_t cnt_thr_event_u2: 1; - uint32_t cnt_thr_event_u3: 1; - uint32_t reserved4: 28; - }; - uint32_t val; - } int_clr; - union { - struct { - uint32_t cnt_mode: 2; - uint32_t thres1_lat: 1; - uint32_t thres0_lat: 1; - uint32_t l_lim_lat: 1; - uint32_t h_lim_lat: 1; - uint32_t zero_lat: 1; - uint32_t reserved7: 25; - }; - uint32_t val; - } status_unit[4]; - union { - struct { - uint32_t cnt_rst_u0: 1; - uint32_t cnt_pause_u0: 1; - uint32_t cnt_rst_u1: 1; - uint32_t cnt_pause_u1: 1; - uint32_t cnt_rst_u2: 1; - uint32_t cnt_pause_u2: 1; - uint32_t cnt_rst_u3: 1; - uint32_t cnt_pause_u3: 1; - uint32_t reserved8: 8; - uint32_t clk_en: 1; - uint32_t reserved17: 15; - }; - uint32_t val; - } ctrl; - uint32_t reserved_64; - uint32_t reserved_68; - uint32_t reserved_6c; - uint32_t reserved_70; - uint32_t reserved_74; - uint32_t reserved_78; - uint32_t reserved_7c; - uint32_t reserved_80; - uint32_t reserved_84; - uint32_t reserved_88; - uint32_t reserved_8c; - uint32_t reserved_90; - uint32_t reserved_94; - uint32_t reserved_98; - uint32_t reserved_9c; - uint32_t reserved_a0; - uint32_t reserved_a4; - uint32_t reserved_a8; - uint32_t reserved_ac; - uint32_t reserved_b0; - uint32_t reserved_b4; - uint32_t reserved_b8; - uint32_t reserved_bc; - uint32_t reserved_c0; - uint32_t reserved_c4; - uint32_t reserved_c8; - uint32_t reserved_cc; - uint32_t reserved_d0; - uint32_t reserved_d4; - uint32_t reserved_d8; - uint32_t reserved_dc; - uint32_t reserved_e0; - uint32_t reserved_e4; - uint32_t reserved_e8; - uint32_t reserved_ec; - uint32_t reserved_f0; - uint32_t reserved_f4; - uint32_t reserved_f8; - uint32_t date; /**/ + volatile pcnt_un_cnt_reg_t cnt_unit[4]; + volatile pcnt_int_raw_reg_t int_raw; + volatile pcnt_int_st_reg_t int_st; + volatile pcnt_int_ena_reg_t int_ena; + volatile pcnt_int_clr_reg_t int_clr; + volatile pcnt_un_status_reg_t status_unit[4]; + volatile pcnt_ctrl_reg_t ctrl; + uint32_t reserved_064[38]; + volatile pcnt_date_reg_t date; } pcnt_dev_t; + +#ifndef __cplusplus +_Static_assert(sizeof(pcnt_dev_t) == 0x100, "Invalid size of pcnt_dev_t structure"); +#endif + extern pcnt_dev_t PCNT; + #ifdef __cplusplus } #endif - -#endif /* _SOC_PCNT_STRUCT_H_ */ diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/periph_defs.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/periph_defs.h index 2bd5071f80b..1b8a65c6dcf 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/periph_defs.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/periph_defs.h @@ -27,7 +27,6 @@ typedef enum { PERIPH_I2C0_MODULE, PERIPH_I2C1_MODULE, PERIPH_I2S0_MODULE, - PERIPH_I2S1_MODULE, PERIPH_TIMG0_MODULE, PERIPH_TIMG1_MODULE, PERIPH_UHCI0_MODULE, @@ -86,15 +85,14 @@ typedef enum { ETS_DEDICATED_GPIO_INTR_SOURCE, /**< interrupt of dedicated GPIO, level*/ ETS_FROM_CPU_INTR0_SOURCE, /**< interrupt0 generated from a CPU, level*/ /* Used for FreeRTOS */ ETS_FROM_CPU_INTR1_SOURCE, /**< interrupt1 generated from a CPU, level*/ /* Used for FreeRTOS */ - ETS_FROM_CPU_INTR2_SOURCE, /**< interrupt2 generated from a CPU, level*/ /* Used for DPORT Access */ - ETS_FROM_CPU_INTR3_SOURCE, /**< interrupt3 generated from a CPU, level*/ /* Used for DPORT Access */ + ETS_FROM_CPU_INTR2_SOURCE, /**< interrupt2 generated from a CPU, level*/ + ETS_FROM_CPU_INTR3_SOURCE, /**< interrupt3 generated from a CPU, level*/ ETS_SPI1_INTR_SOURCE = 32, /**< interrupt of SPI1, level, SPI1 is for flash read/write, do not use this*/ ETS_SPI2_INTR_SOURCE, /**< interrupt of SPI2, level*/ ETS_SPI3_INTR_SOURCE, /**< interrupt of SPI3, level*/ ETS_I2S0_INTR_SOURCE, /**< interrupt of I2S0, level*/ - ETS_I2S1_INTR_SOURCE, /**< interrupt of I2S1, level*/ - ETS_UART0_INTR_SOURCE, /**< interrupt of UART0, level*/ + ETS_UART0_INTR_SOURCE = 37, /**< interrupt of UART0, level*/ ETS_UART1_INTR_SOURCE, /**< interrupt of UART1, level*/ ETS_UART2_INTR_SOURCE, /**< interrupt of UART2, level*/ ETS_SDIO_HOST_INTR_SOURCE, /**< interrupt of SD/SDIO/MMC HOST, level*/ diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/rmt_struct.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/rmt_struct.h index b92c42a775f..5e430040939 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/rmt_struct.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/rmt_struct.h @@ -20,7 +20,7 @@ extern "C" { #endif -typedef volatile struct { +typedef volatile struct rmt_dev_s { uint32_t data_ch[4]; /* Data FIFO, Can only be accessed by PeriBus2 */ struct { union { @@ -300,11 +300,9 @@ typedef struct { } rmt_item32_t; //Allow access to RMT memory using RMTMEM.chan[0].data32[8] -typedef volatile struct { +typedef volatile struct rmt_mem_s { struct { - union { - rmt_item32_t data32[64]; - }; + rmt_item32_t data32[64]; } chan[4]; } rmt_mem_t; extern rmt_mem_t RMTMEM; diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/rtc.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/rtc.h index 52322db983b..1877bb1cfe8 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/rtc.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/rtc.h @@ -215,7 +215,8 @@ typedef enum { typedef enum { RTC_CAL_RTC_MUX = 0, //!< Currently selected RTC SLOW_CLK RTC_CAL_8MD256 = 1, //!< Internal 8 MHz RC oscillator, divided by 256 - RTC_CAL_32K_XTAL = 2 //!< External 32 kHz XTAL + RTC_CAL_32K_XTAL = 2, //!< External 32 kHz XTAL + RTC_CAL_INTERNAL_OSC = 3 //!< Internal 150 kHz oscillator } rtc_cal_sel_t; /** diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/rtc_cntl_struct.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/rtc_cntl_struct.h index 4a901a3231e..695d18c616f 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/rtc_cntl_struct.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/rtc_cntl_struct.h @@ -19,7 +19,7 @@ extern "C" { #include -typedef volatile struct { +typedef volatile struct rtc_cntl_dev_s { union { struct { uint32_t sw_stall_appcpu_c0: 2; /*{reg_sw_stall_appcpu_c1[5:0] reg_sw_stall_appcpu_c0[1:0]} == 0x86 will stall APP CPU*/ diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/rtc_i2c_struct.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/rtc_i2c_struct.h index 2b9e6532d6f..8f46d82fa3e 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/rtc_i2c_struct.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/rtc_i2c_struct.h @@ -17,7 +17,7 @@ extern "C" { #endif -typedef volatile struct { +typedef volatile struct rtc_i2c_dev_s { union { struct { uint32_t period: 20; /*time period that scl = 0*/ diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/rtc_io_struct.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/rtc_io_struct.h index c38c9fd4ab4..6d4c883ed0b 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/rtc_io_struct.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/rtc_io_struct.h @@ -17,7 +17,7 @@ extern "C" { #endif -typedef volatile struct { +typedef volatile struct rtc_io_dev_s { union { struct { uint32_t reserved0: 10; diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/sens_struct.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/sens_struct.h index 5f56714ee64..5a029dd9fee 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/sens_struct.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/sens_struct.h @@ -17,7 +17,7 @@ extern "C" { #endif -typedef volatile struct { +typedef volatile struct sens_dev_s { union { struct { uint32_t sar1_clk_div: 8; /*clock divider*/ diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/soc.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/soc.h index 5084c23c50f..ae4cf0103a2 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/soc.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/soc.h @@ -299,23 +299,23 @@ //interrupt cpu using table, Please see the core-isa.h /************************************************************************************************************* - * Intr num Level Type PRO CPU usage APP CPU uasge - * 0 1 extern level WMAC Reserved - * 1 1 extern level BT/BLE Host HCI DMA BT/BLE Host HCI DMA + * Intr num Level Type PRO CPU usage + * 0 1 extern level WMAC + * 1 1 extern level BT/BLE Host HCI DMA * 2 1 extern level * 3 1 extern level * 4 1 extern level WBB - * 5 1 extern level BT/BLE Controller BT/BLE Controller - * 6 1 timer FreeRTOS Tick(L1) FreeRTOS Tick(L1) - * 7 1 software BT/BLE VHCI BT/BLE VHCI - * 8 1 extern level BT/BLE BB(RX/TX) BT/BLE BB(RX/TX) + * 5 1 extern level BT/BLE Controller + * 6 1 timer FreeRTOS Tick(L1) + * 7 1 software BT/BLE VHCI + * 8 1 extern level BT/BLE BB(RX/TX) * 9 1 extern level * 10 1 extern edge * 11 3 profiling * 12 1 extern level * 13 1 extern level - * 14 7 nmi Reserved Reserved - * 15 3 timer FreeRTOS Tick(L3) FreeRTOS Tick(L3) + * 14 7 nmi Reserved + * 15 3 timer FreeRTOS Tick(L3) * 16 5 timer * 17 1 extern level * 18 1 extern level @@ -327,10 +327,10 @@ * 24 4 extern level TG1_WDT * 25 4 extern level CACHEERR * 26 5 extern level - * 27 3 extern level Reserved Reserved - * 28 4 extern edge DPORT ACCESS DPORT ACCESS - * 29 3 software Reserved Reserved - * 30 4 extern edge Reserved Reserved + * 27 3 extern level Reserved + * 28 4 extern edge Reserved + * 29 3 software Reserved + * 30 4 extern edge Reserved * 31 5 extern level ************************************************************************************************************* */ @@ -343,7 +343,6 @@ #define ETS_FRC1_INUM 22 #define ETS_T1_WDT_INUM 24 #define ETS_MEMACCESS_ERR_INUM 25 -#define ETS_DPORT_INUM 28 //CPU0 Interrupt number used in ROM, should be cancelled in SDK #define ETS_SLC_INUM 1 diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/soc_caps.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/soc_caps.h index 63326b098a2..b33af28f369 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/soc_caps.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/soc_caps.h @@ -44,7 +44,7 @@ #define SOC_DEDICATED_GPIO_SUPPORTED 1 #define SOC_SUPPORTS_SECURE_DL_MODE 1 #define SOC_RISCV_COPROC_SUPPORTED 1 -#define SOC_USB_SUPPORTED 1 +#define SOC_USB_OTG_SUPPORTED 1 #define SOC_PCNT_SUPPORTED 1 #define SOC_ULP_SUPPORTED 1 #define SOC_RTC_SLOW_MEM_SUPPORTED 1 @@ -59,24 +59,32 @@ #define SOC_FLASH_ENCRYPTION_XTS_AES 1 #define SOC_FLASH_ENCRYPTION_XTS_AES_256 1 #define SOC_PSRAM_DMA_CAPABLE 1 +#define SOC_XT_WDT_SUPPORTED 1 /*-------------------------- ADC CAPS ----------------------------------------*/ -#define SOC_ADC_PERIPH_NUM (2) -#define SOC_ADC_PATT_LEN_MAX (16) -#define SOC_ADC_CHANNEL_NUM(PERIPH_NUM) (10) -#define SOC_ADC_MAX_CHANNEL_NUM (10) -#define SOC_ADC_MAX_BITWIDTH (13) -#define SOC_ADC_HW_CALIBRATION_V1 (1) /*!< support HW offset calibration */ - - -/** - * Check if adc support digital controller (DMA) mode. - * @value - * - 1 : support; - * - 0 : not support; - */ -#define SOC_ADC_SUPPORT_DMA_MODE(PERIPH_NUM) ((PERIPH_NUM==0)? 1: 1) -#define SOC_ADC_SUPPORT_RTC_CTRL 1 +/*!< SAR ADC Module*/ +#define SOC_ADC_RTC_CTRL_SUPPORTED 1 +#define SOC_ADC_ARBITER_SUPPORTED 1 +#define SOC_ADC_FILTER_SUPPORTED 1 +#define SOC_ADC_MONITOR_SUPPORTED 1 +#define SOC_ADC_PERIPH_NUM (2) +#define SOC_ADC_CHANNEL_NUM(PERIPH_NUM) (10) +#define SOC_ADC_MAX_CHANNEL_NUM (10) + +/*!< Digital */ +#define SOC_ADC_DIGI_CONTROLLER_NUM (2) +#define SOC_ADC_PATT_LEN_MAX (32) /*!< Two pattern table, each contains 16 items. Each item takes 1 byte */ +#define SOC_ADC_DIGI_MAX_BITWIDTH (12) +/*!< F_sample = F_digi_con / 2 / interval. F_digi_con = 5M for now. 30 <= interva <= 4095 */ +#define SOC_ADC_SAMPLE_FREQ_THRES_HIGH 83333 +#define SOC_ADC_SAMPLE_FREQ_THRES_LOW 611 + +/*!< RTC */ +#define SOC_ADC_MAX_BITWIDTH (13) + +/*!< Calibration */ +#define SOC_ADC_CALIBRATION_V1_SUPPORTED (1) /*!< support HW offset calibration version 1*/ + /*-------------------------- BROWNOUT CAPS -----------------------------------*/ #define SOC_BROWNOUT_RESET_SUPPORTED 1 @@ -118,6 +126,7 @@ #define SOC_DEDIC_GPIO_IN_CHANNELS_NUM (8) /*!< 8 inward channels on each CPU core */ #define SOC_DEDIC_GPIO_ALLOW_REG_ACCESS (1) /*!< Allow access dedicated GPIO channel by register */ #define SOC_DEDIC_GPIO_HAS_INTERRUPT (1) /*!< Dedicated GPIO has its own interrupt source */ +#define SOC_DEDIC_GPIO_OUT_AUTO_ENABLE (1) /*!< Dedicated GPIO output attribution is enabled automatically */ /*-------------------------- I2C CAPS ----------------------------------------*/ // ESP32-S2 have 2 I2C. @@ -134,16 +143,20 @@ #define SOC_I2C_SUPPORT_APB (1) /*-------------------------- I2S CAPS ----------------------------------------*/ -// ESP32-S2 have 2 I2S -#define SOC_I2S_NUM (1) - -#define SOC_I2S_SUPPORTS_DMA_EQUAL (1) // ESP32-S2 need dma equal - -#define SOC_I2S_MAX_BUFFER_SIZE (4 * 1024 * 1024) //the maximum RAM can be allocated - -#define SOC_I2S_APLL_MIN_FREQ (250000000) -#define SOC_I2S_APLL_MAX_FREQ (500000000) -#define SOC_I2S_APLL_MIN_RATE (10675) //in Hz, I2S Clock rate limited by hardware +// ESP32-S2 have 1 I2S +#define SOC_I2S_NUM (1) +#define SOC_I2S_SUPPORTS_APLL (1)// ESP32-S2 support APLL +#define SOC_I2S_SUPPORTS_DMA_EQUAL (1) +#define SOC_I2S_APLL_MIN_FREQ (250000000) +#define SOC_I2S_APLL_MAX_FREQ (500000000) +#define SOC_I2S_APLL_MIN_RATE (10675) //in Hz, I2S Clock rate limited by hardware +#define SOC_I2S_LCD_I80_VARIANT (1) + +/*-------------------------- LCD CAPS ----------------------------------------*/ +/* Notes: On esp32-s2, LCD intel 8080 timing is generated by I2S peripheral */ +#define SOC_LCD_I80_SUPPORTED (1) /*!< Intel 8080 LCD is supported */ +#define SOC_LCD_I80_BUSES (1) /*!< Only I2S0 has LCD mode */ +#define SOC_LCD_I80_BUS_WIDTH (24) /*!< Intel 8080 bus width */ /*-------------------------- LEDC CAPS ---------------------------------------*/ #define SOC_LEDC_SUPPORT_XTAL_CLOCK (1) @@ -159,10 +172,10 @@ #define SOC_MPU_REGION_WO_SUPPORTED 0 /*-------------------------- PCNT CAPS ---------------------------------------*/ -// ESP32-S2 have 1 PCNT peripheral -#define SOC_PCNT_PORT_NUM (1) -#define SOC_PCNT_UNIT_NUM (4) // ESP32-S2 only have 4 unit -#define SOC_PCNT_UNIT_CHANNEL_NUM (2) +#define SOC_PCNT_GROUPS (1) +#define SOC_PCNT_UNITS_PER_GROUP (4) +#define SOC_PCNT_CHANNELS_PER_UNIT (2) +#define SOC_PCNT_THRES_POINT_PER_UNIT (2) /*-------------------------- RMT CAPS ----------------------------------------*/ #define SOC_RMT_GROUPS (1) /*!< One RMT group */ @@ -213,6 +226,7 @@ #define SOC_SPI_PERIPH_SUPPORT_CONTROL_DUMMY_OUTPUT 1 #define SOC_MEMSPI_IS_INDEPENDENT 1 +#define SOC_SPI_SUPPORT_OCT 1 /*-------------------------- SYSTIMER CAPS ----------------------------------*/ #define SOC_SYSTIMER_COUNTER_NUM (1) // Number of counter units @@ -241,7 +255,7 @@ #define SOC_TWAI_SUPPORTS_RX_STATUS 1 /*-------------------------- UART CAPS ---------------------------------------*/ -// ESP32-S2 have 2 UART. +// ESP32-S2 has 2 UART. #define SOC_UART_NUM (2) #define SOC_UART_SUPPORT_REF_TICK (1) /*!< Support REF_TICK as the clock source */ #define SOC_UART_FIFO_LEN (128) /*!< The UART hardware FIFO length */ diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/spi_pins.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/spi_pins.h index c334e01fe1c..81ea5f0d2a1 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/spi_pins.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/spi_pins.h @@ -22,21 +22,37 @@ #define SPI_IOMUX_PIN_NUM_MISO 31 #define SPI_IOMUX_PIN_NUM_WP 28 -#define SPI2_FUNC_NUM FSPI_FUNC_NUM -#define SPI2_IOMUX_PIN_NUM_HD FSPI_IOMUX_PIN_NUM_HD -#define SPI2_IOMUX_PIN_NUM_CS FSPI_IOMUX_PIN_NUM_CS -#define SPI2_IOMUX_PIN_NUM_MOSI FSPI_IOMUX_PIN_NUM_MOSI -#define SPI2_IOMUX_PIN_NUM_CLK FSPI_IOMUX_PIN_NUM_CLK -#define SPI2_IOMUX_PIN_NUM_MISO FSPI_IOMUX_PIN_NUM_MISO -#define SPI2_IOMUX_PIN_NUM_WP FSPI_IOMUX_PIN_NUM_WP +// There are 2 sets of GPIO pins which could be routed to FSPICS0, FSPICLK, FSPID, FSPIQ, FSPIHD, FSPIWP. +// However, there is only one set of GPIO pins which could be routed to FSPIIO4, FSPIIO5, FSPIIO6, FSPIIO7. +// As default (when we are not going to use Octal SPI), we make use of SPI2_FUNC_NUM to route one of the 2 sets of GPIO pins to FSPICS0 ~ FSPIWP as follows. +#define SPI2_FUNC_NUM 4 +#define SPI2_IOMUX_PIN_NUM_HD 9 +#define SPI2_IOMUX_PIN_NUM_CS 10 +#define SPI2_IOMUX_PIN_NUM_MOSI 11 +#define SPI2_IOMUX_PIN_NUM_CLK 12 +#define SPI2_IOMUX_PIN_NUM_MISO 13 +#define SPI2_IOMUX_PIN_NUM_WP 14 + +// When using Octal SPI, we make use of SPI2_FUNC_NUM_OCT to route them as follows. +#define SPI2_FUNC_NUM_OCT 2 +#define SPI2_IOMUX_PIN_NUM_HD_OCT 33 +#define SPI2_IOMUX_PIN_NUM_CS_OCT 34 +#define SPI2_IOMUX_PIN_NUM_MOSI_OCT 35 +#define SPI2_IOMUX_PIN_NUM_CLK_OCT 36 +#define SPI2_IOMUX_PIN_NUM_MISO_OCT 37 +#define SPI2_IOMUX_PIN_NUM_WP_OCT 38 +#define SPI2_IOMUX_PIN_NUM_IO4_OCT 10 +#define SPI2_IOMUX_PIN_NUM_IO5_OCT 11 +#define SPI2_IOMUX_PIN_NUM_IO6_OCT 12 +#define SPI2_IOMUX_PIN_NUM_IO7_OCT 13 //SPI3 has no iomux pins //Following Macros are deprecated. Please use the Macros above -#define FSPI_FUNC_NUM 4 -#define FSPI_IOMUX_PIN_NUM_HD 9 -#define FSPI_IOMUX_PIN_NUM_CS 10 -#define FSPI_IOMUX_PIN_NUM_MOSI 11 -#define FSPI_IOMUX_PIN_NUM_CLK 12 -#define FSPI_IOMUX_PIN_NUM_MISO 13 -#define FSPI_IOMUX_PIN_NUM_WP 14 +#define FSPI_FUNC_NUM SPI2_FUNC_NUM +#define FSPI_IOMUX_PIN_NUM_HD SPI2_IOMUX_PIN_NUM_HD +#define FSPI_IOMUX_PIN_NUM_CS SPI2_IOMUX_PIN_NUM_CS +#define FSPI_IOMUX_PIN_NUM_MOSI SPI2_IOMUX_PIN_NUM_MOSI +#define FSPI_IOMUX_PIN_NUM_CLK SPI2_IOMUX_PIN_NUM_CLK +#define FSPI_IOMUX_PIN_NUM_MISO SPI2_IOMUX_PIN_NUM_MISO +#define FSPI_IOMUX_PIN_NUM_WP SPI2_IOMUX_PIN_NUM_WP diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/syscon_struct.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/syscon_struct.h index d40e2dff507..6509b9a751e 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/syscon_struct.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/syscon_struct.h @@ -17,7 +17,7 @@ extern "C" { #endif -typedef volatile struct { +typedef volatile struct syscon_dev_s { union { struct { uint32_t pre_div: 10; @@ -29,7 +29,7 @@ typedef volatile struct { uint32_t reserved16: 16; }; uint32_t val; - } apb_ctrl_sysclk_conf; + } sysclk_conf; union { struct { uint32_t xtal_tick: 8; @@ -38,7 +38,7 @@ typedef volatile struct { uint32_t reserved17: 15; }; uint32_t val; - } apb_ctrl_tick_conf; + } tick_conf; union { struct { uint32_t clk20_oen: 1; @@ -55,7 +55,7 @@ typedef volatile struct { uint32_t reserved11: 21; }; uint32_t val; - } apb_ctrl_clk_out_en; + } clk_out_en; union { struct { uint32_t peri_io_swap: 8; diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/systimer_struct.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/systimer_struct.h index 48b1d79276e..23783b39f45 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/systimer_struct.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/systimer_struct.h @@ -91,6 +91,7 @@ typedef union { * system timer accumulation step when using PLL */ uint32_t timer_pll_step: 10; + uint32_t reserved20: 12; }; uint32_t val; } systimer_step_reg_t; @@ -201,6 +202,7 @@ typedef union { * system timer target2 interrupt enable */ uint32_t systimer_int2_ena: 1; + uint32_t reserved3: 29; }; uint32_t val; } systimer_int_ena_reg_t; @@ -222,6 +224,7 @@ typedef union { * system timer target2 interrupt raw */ uint32_t systimer_int2_raw: 1; + uint32_t reserved3: 29; }; uint32_t val; } systimer_int_raw_reg_t; @@ -243,6 +246,7 @@ typedef union { * system timer target2 interrupt clear */ uint32_t systimer_int2_clr: 1; + uint32_t reserved3: 29; }; uint32_t val; } systimer_int_clr_reg_t; diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/timer_group_reg.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/timer_group_reg.h index fdef7ff2776..a74c3e2e5e1 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/timer_group_reg.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/timer_group_reg.h @@ -1,24 +1,17 @@ -// Copyright 2017-2019 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 _SOC_TIMG_REG_H_ -#define _SOC_TIMG_REG_H_ - - +/** + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#pragma once + +#include +#include "soc/soc.h" #ifdef __cplusplus extern "C" { #endif -#include "soc.h" + +#define DR_REG_TIMG_BASE(i) REG_TIMG_BASE(i) /* The value that needs to be written to TIMG_WDT_WKEY to write-enable the wdt registers */ #define TIMG_WDT_WKEY_VALUE 0x50D83AA1 @@ -39,694 +32,984 @@ extern "C" { #define TIMG_WDT_RESET_LENGTH_1600_NS 6 #define TIMG_WDT_RESET_LENGTH_3200_NS 7 -#define TIMG_T0CONFIG_REG(i) (REG_TIMG_BASE(i) + 0x0000) -/* TIMG_T0_EN : R/W ;bitpos:[31] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_T0_EN (BIT(31)) -#define TIMG_T0_EN_M (BIT(31)) -#define TIMG_T0_EN_V 0x1 -#define TIMG_T0_EN_S 31 -/* TIMG_T0_INCREASE : R/W ;bitpos:[30] ;default: 1'h1 ; */ -/*description: */ -#define TIMG_T0_INCREASE (BIT(30)) -#define TIMG_T0_INCREASE_M (BIT(30)) -#define TIMG_T0_INCREASE_V 0x1 -#define TIMG_T0_INCREASE_S 30 -/* TIMG_T0_AUTORELOAD : R/W ;bitpos:[29] ;default: 1'h1 ; */ -/*description: */ -#define TIMG_T0_AUTORELOAD (BIT(29)) -#define TIMG_T0_AUTORELOAD_M (BIT(29)) -#define TIMG_T0_AUTORELOAD_V 0x1 -#define TIMG_T0_AUTORELOAD_S 29 -/* TIMG_T0_DIVIDER : R/W ;bitpos:[28:13] ;default: 16'h1 ; */ -/*description: */ -#define TIMG_T0_DIVIDER 0x0000FFFF -#define TIMG_T0_DIVIDER_M ((TIMG_T0_DIVIDER_V)<<(TIMG_T0_DIVIDER_S)) -#define TIMG_T0_DIVIDER_V 0xFFFF -#define TIMG_T0_DIVIDER_S 13 -/* TIMG_T0_EDGE_INT_EN : R/W ;bitpos:[12] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_T0_EDGE_INT_EN (BIT(12)) -#define TIMG_T0_EDGE_INT_EN_M (BIT(12)) -#define TIMG_T0_EDGE_INT_EN_V 0x1 -#define TIMG_T0_EDGE_INT_EN_S 12 -/* TIMG_T0_LEVEL_INT_EN : R/W ;bitpos:[11] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_T0_LEVEL_INT_EN (BIT(11)) -#define TIMG_T0_LEVEL_INT_EN_M (BIT(11)) -#define TIMG_T0_LEVEL_INT_EN_V 0x1 -#define TIMG_T0_LEVEL_INT_EN_S 11 -/* TIMG_T0_ALARM_EN : R/W ;bitpos:[10] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_T0_ALARM_EN (BIT(10)) -#define TIMG_T0_ALARM_EN_M (BIT(10)) -#define TIMG_T0_ALARM_EN_V 0x1 +/** TIMG_T0CONFIG_REG register + * Timer 0 configuration register + */ +#define TIMG_T0CONFIG_REG(i) (DR_REG_TIMG_BASE(i) + 0x0) +/** TIMG_T0_USE_XTAL : R/W; bitpos: [9]; default: 0; + * 1: Use XTAL_CLK as the source clock of timer group. 0: Use APB_CLK as the source + * clock of timer group. + */ +#define TIMG_T0_USE_XTAL (BIT(9)) +#define TIMG_T0_USE_XTAL_M (TIMG_T0_USE_XTAL_V << TIMG_T0_USE_XTAL_S) +#define TIMG_T0_USE_XTAL_V 0x00000001U +#define TIMG_T0_USE_XTAL_S 9 +/** TIMG_T0_ALARM_EN : R/W; bitpos: [10]; default: 0; + * When set, the alarm is enabled. This bit is automatically cleared once an + * + * alarm occurs. + */ +#define TIMG_T0_ALARM_EN (BIT(10)) +#define TIMG_T0_ALARM_EN_M (TIMG_T0_ALARM_EN_V << TIMG_T0_ALARM_EN_S) +#define TIMG_T0_ALARM_EN_V 0x00000001U #define TIMG_T0_ALARM_EN_S 10 -/* TIMG_T0_USE_XTAL : R/W ;bitpos:[9] ;default: 1'd0 ; */ -/*description: */ -#define TIMG_T0_USE_XTAL (BIT(9)) -#define TIMG_T0_USE_XTAL_M (BIT(9)) -#define TIMG_T0_USE_XTAL_V 0x1 +/** TIMG_T0_LEVEL_INT_EN : R/W; bitpos: [11]; default: 0; + * When set, an alarm will generate a level type interrupt. + */ +#define TIMG_T0_LEVEL_INT_EN (BIT(11)) +#define TIMG_T0_LEVEL_INT_EN_M (TIMG_T0_LEVEL_INT_EN_V << TIMG_T0_LEVEL_INT_EN_S) +#define TIMG_T0_LEVEL_INT_EN_V 0x00000001U +#define TIMG_T0_LEVEL_INT_EN_S 11 +/** TIMG_T0_EDGE_INT_EN : R/W; bitpos: [12]; default: 0; + * When set, an alarm will generate an edge type interrupt. + */ +#define TIMG_T0_EDGE_INT_EN (BIT(12)) +#define TIMG_T0_EDGE_INT_EN_M (TIMG_T0_EDGE_INT_EN_V << TIMG_T0_EDGE_INT_EN_S) +#define TIMG_T0_EDGE_INT_EN_V 0x00000001U +#define TIMG_T0_EDGE_INT_EN_S 12 +/** TIMG_T0_DIVIDER : R/W; bitpos: [28:13]; default: 1; + * Timer 0 clock (T0_clk) prescaler value. + */ +#define TIMG_T0_DIVIDER 0x0000FFFFU +#define TIMG_T0_DIVIDER_M (TIMG_T0_DIVIDER_V << TIMG_T0_DIVIDER_S) +#define TIMG_T0_DIVIDER_V 0x0000FFFFU +#define TIMG_T0_DIVIDER_S 13 +/** TIMG_T0_AUTORELOAD : R/W; bitpos: [29]; default: 1; + * When set, timer 0 auto-reload at alarm is enabled. + */ +#define TIMG_T0_AUTORELOAD (BIT(29)) +#define TIMG_T0_AUTORELOAD_M (TIMG_T0_AUTORELOAD_V << TIMG_T0_AUTORELOAD_S) +#define TIMG_T0_AUTORELOAD_V 0x00000001U +#define TIMG_T0_AUTORELOAD_S 29 +/** TIMG_T0_INCREASE : R/W; bitpos: [30]; default: 1; + * When set, the timer 0 time-base counter will increment every clock tick. When + * + * cleared, the timer 0 time-base counter will decrement. + */ +#define TIMG_T0_INCREASE (BIT(30)) +#define TIMG_T0_INCREASE_M (TIMG_T0_INCREASE_V << TIMG_T0_INCREASE_S) +#define TIMG_T0_INCREASE_V 0x00000001U +#define TIMG_T0_INCREASE_S 30 +/** TIMG_T0_EN : R/W; bitpos: [31]; default: 0; + * When set, the timer 0 time-base counter is enabled. + */ +#define TIMG_T0_EN (BIT(31)) +#define TIMG_T0_EN_M (TIMG_T0_EN_V << TIMG_T0_EN_S) +#define TIMG_T0_EN_V 0x00000001U +#define TIMG_T0_EN_S 31 + +/** TIMG_T0LO_REG register + * Timer 0 current value, low 32 bits + */ +#define TIMG_T0LO_REG(i) (DR_REG_TIMG_BASE(i) + 0x4) +/** TIMG_T0_LO : RO; bitpos: [31:0]; default: 0; + * After writing to TIMG_T0UPDATE_REG, the low 32 bits of the time-base counter + * + * of timer 0 can be read here. + */ +#define TIMG_T0_LO 0xFFFFFFFFU +#define TIMG_T0_LO_M (TIMG_T0_LO_V << TIMG_T0_LO_S) +#define TIMG_T0_LO_V 0xFFFFFFFFU +#define TIMG_T0_LO_S 0 + +/** TIMG_T0HI_REG register + * Timer 0 current value, high 32 bits + */ +#define TIMG_T0HI_REG(i) (DR_REG_TIMG_BASE(i) + 0x8) +/** TIMG_T0_HI : RO; bitpos: [31:0]; default: 0; + * After writing to TIMG_T0UPDATE_REG, the high 32 bits of the time-base counter + * + * of timer 0 can be read here. + */ +#define TIMG_T0_HI 0xFFFFFFFFU +#define TIMG_T0_HI_M (TIMG_T0_HI_V << TIMG_T0_HI_S) +#define TIMG_T0_HI_V 0xFFFFFFFFU +#define TIMG_T0_HI_S 0 + +/** TIMG_T0UPDATE_REG register + * Write to copy current timer value to TIMGn_T0_(LO/HI)_REG + */ +#define TIMG_T0UPDATE_REG(i) (DR_REG_TIMG_BASE(i) + 0xc) +/** TIMG_T0_UPDATE : R/W; bitpos: [31]; default: 0; + * After writing 0 or 1 to TIMG_T0UPDATE_REG, the counter value is latched. + */ +#define TIMG_T0_UPDATE (BIT(31)) +#define TIMG_T0_UPDATE_M (TIMG_T0_UPDATE_V << TIMG_T0_UPDATE_S) +#define TIMG_T0_UPDATE_V 0x00000001U +#define TIMG_T0_UPDATE_S 31 + +/** TIMG_T0ALARMLO_REG register + * Timer 0 alarm value, low 32 bits + */ +#define TIMG_T0ALARMLO_REG(i) (DR_REG_TIMG_BASE(i) + 0x10) +/** TIMG_T0_ALARM_LO : R/W; bitpos: [31:0]; default: 0; + * Timer 0 alarm trigger time-base counter value, low 32 bits. + */ +#define TIMG_T0_ALARM_LO 0xFFFFFFFFU +#define TIMG_T0_ALARM_LO_M (TIMG_T0_ALARM_LO_V << TIMG_T0_ALARM_LO_S) +#define TIMG_T0_ALARM_LO_V 0xFFFFFFFFU +#define TIMG_T0_ALARM_LO_S 0 + +/** TIMG_T0ALARMHI_REG register + * Timer 0 alarm value, high bits + */ +#define TIMG_T0ALARMHI_REG(i) (DR_REG_TIMG_BASE(i) + 0x14) +/** TIMG_T0_ALARM_HI : R/W; bitpos: [31:0]; default: 0; + * + * + * Timer 0 alarm trigger time-base counter value, high 32 bits. + */ +#define TIMG_T0_ALARM_HI 0xFFFFFFFFU +#define TIMG_T0_ALARM_HI_M (TIMG_T0_ALARM_HI_V << TIMG_T0_ALARM_HI_S) +#define TIMG_T0_ALARM_HI_V 0xFFFFFFFFU +#define TIMG_T0_ALARM_HI_S 0 + +/** TIMG_T0LOADLO_REG register + * Timer 0 reload value, low 32 bits + */ +#define TIMG_T0LOADLO_REG(i) (DR_REG_TIMG_BASE(i) + 0x18) +/** TIMG_T0_LOAD_LO : R/W; bitpos: [31:0]; default: 0; + * + * + * Low 32 bits of the value that a reload will load onto timer 0 time-base + * + * Counter. + */ +#define TIMG_T0_LOAD_LO 0xFFFFFFFFU +#define TIMG_T0_LOAD_LO_M (TIMG_T0_LOAD_LO_V << TIMG_T0_LOAD_LO_S) +#define TIMG_T0_LOAD_LO_V 0xFFFFFFFFU +#define TIMG_T0_LOAD_LO_S 0 + +/** TIMG_T0LOADHI_REG register + * Timer 0 reload value, high 32 bits + */ +#define TIMG_T0LOADHI_REG(i) (DR_REG_TIMG_BASE(i) + 0x1c) +/** TIMG_T0_LOAD_HI : R/W; bitpos: [31:0]; default: 0; + * + * + * High 32 bits of the value that a reload will load onto timer 0 time-base + * + * counter. + */ +#define TIMG_T0_LOAD_HI 0xFFFFFFFFU +#define TIMG_T0_LOAD_HI_M (TIMG_T0_LOAD_HI_V << TIMG_T0_LOAD_HI_S) +#define TIMG_T0_LOAD_HI_V 0xFFFFFFFFU +#define TIMG_T0_LOAD_HI_S 0 + +/** TIMG_T0LOAD_REG register + * Write to reload timer from TIMG_T0_(LOADLOLOADHI)_REG + */ +#define TIMG_T0LOAD_REG(i) (DR_REG_TIMG_BASE(i) + 0x20) +/** TIMG_T0_LOAD : WO; bitpos: [31:0]; default: 0; + * + * + * Write any value to trigger a timer 0 time-base counter reload. + */ +#define TIMG_T0_LOAD 0xFFFFFFFFU +#define TIMG_T0_LOAD_M (TIMG_T0_LOAD_V << TIMG_T0_LOAD_S) +#define TIMG_T0_LOAD_V 0xFFFFFFFFU +#define TIMG_T0_LOAD_S 0 + +/** TIMG_T1CONFIG_REG register + * Timer 1 configuration register + */ +#define TIMG_T1CONFIG_REG(i) (DR_REG_TIMG_BASE(i) + 0x24) +/** TIMG_T0_USE_XTAL : R/W; bitpos: [9]; default: 0; + * 1: Use XTAL_CLK as the source clock of timer group. 0: Use APB_CLK as the source + * clock of timer group. + */ +#define TIMG_T0_USE_XTAL (BIT(9)) +#define TIMG_T0_USE_XTAL_M (TIMG_T0_USE_XTAL_V << TIMG_T0_USE_XTAL_S) +#define TIMG_T0_USE_XTAL_V 0x00000001U #define TIMG_T0_USE_XTAL_S 9 +/** TIMG_T0_ALARM_EN : R/W; bitpos: [10]; default: 0; + * When set, the alarm is enabled. This bit is automatically cleared once an + * + * alarm occurs. + */ +#define TIMG_T0_ALARM_EN (BIT(10)) +#define TIMG_T0_ALARM_EN_M (TIMG_T0_ALARM_EN_V << TIMG_T0_ALARM_EN_S) +#define TIMG_T0_ALARM_EN_V 0x00000001U +#define TIMG_T0_ALARM_EN_S 10 +/** TIMG_T0_LEVEL_INT_EN : R/W; bitpos: [11]; default: 0; + * When set, an alarm will generate a level type interrupt. + */ +#define TIMG_T0_LEVEL_INT_EN (BIT(11)) +#define TIMG_T0_LEVEL_INT_EN_M (TIMG_T0_LEVEL_INT_EN_V << TIMG_T0_LEVEL_INT_EN_S) +#define TIMG_T0_LEVEL_INT_EN_V 0x00000001U +#define TIMG_T0_LEVEL_INT_EN_S 11 +/** TIMG_T0_EDGE_INT_EN : R/W; bitpos: [12]; default: 0; + * When set, an alarm will generate an edge type interrupt. + */ +#define TIMG_T0_EDGE_INT_EN (BIT(12)) +#define TIMG_T0_EDGE_INT_EN_M (TIMG_T0_EDGE_INT_EN_V << TIMG_T0_EDGE_INT_EN_S) +#define TIMG_T0_EDGE_INT_EN_V 0x00000001U +#define TIMG_T0_EDGE_INT_EN_S 12 +/** TIMG_T0_DIVIDER : R/W; bitpos: [28:13]; default: 1; + * Timer 1 clock (T1_clk) prescaler value. + */ +#define TIMG_T0_DIVIDER 0x0000FFFFU +#define TIMG_T0_DIVIDER_M (TIMG_T0_DIVIDER_V << TIMG_T0_DIVIDER_S) +#define TIMG_T0_DIVIDER_V 0x0000FFFFU +#define TIMG_T0_DIVIDER_S 13 +/** TIMG_T0_AUTORELOAD : R/W; bitpos: [29]; default: 1; + * When set, timer 1 auto-reload at alarm is enabled. + */ +#define TIMG_T0_AUTORELOAD (BIT(29)) +#define TIMG_T0_AUTORELOAD_M (TIMG_T0_AUTORELOAD_V << TIMG_T0_AUTORELOAD_S) +#define TIMG_T0_AUTORELOAD_V 0x00000001U +#define TIMG_T0_AUTORELOAD_S 29 +/** TIMG_T0_INCREASE : R/W; bitpos: [30]; default: 1; + * When set, the timer 1 time-base counter will increment every clock tick. When + * + * cleared, the timer 1 time-base counter will decrement. + */ +#define TIMG_T0_INCREASE (BIT(30)) +#define TIMG_T0_INCREASE_M (TIMG_T0_INCREASE_V << TIMG_T0_INCREASE_S) +#define TIMG_T0_INCREASE_V 0x00000001U +#define TIMG_T0_INCREASE_S 30 +/** TIMG_T0_EN : R/W; bitpos: [31]; default: 0; + * When set, the timer 1 time-base counter is enabled. + */ +#define TIMG_T0_EN (BIT(31)) +#define TIMG_T0_EN_M (TIMG_T0_EN_V << TIMG_T0_EN_S) +#define TIMG_T0_EN_V 0x00000001U +#define TIMG_T0_EN_S 31 -#define TIMG_T0LO_REG(i) (REG_TIMG_BASE(i) + 0x0004) -/* TIMG_T0_LO : RO ;bitpos:[31:0] ;default: 32'h0 ; */ -/*description: */ -#define TIMG_T0_LO 0xFFFFFFFF -#define TIMG_T0_LO_M ((TIMG_T0_LO_V)<<(TIMG_T0_LO_S)) -#define TIMG_T0_LO_V 0xFFFFFFFF +/** TIMG_T1LO_REG register + * Timer 1 current value, low 32 bits + */ +#define TIMG_T1LO_REG(i) (DR_REG_TIMG_BASE(i) + 0x28) +/** TIMG_T0_LO : RO; bitpos: [31:0]; default: 0; + * After writing to TIMG_T1UPDATE_REG, the low 32 bits of the time-base counter + * + * of timer 1 can be read here. + */ +#define TIMG_T0_LO 0xFFFFFFFFU +#define TIMG_T0_LO_M (TIMG_T0_LO_V << TIMG_T0_LO_S) +#define TIMG_T0_LO_V 0xFFFFFFFFU #define TIMG_T0_LO_S 0 -#define TIMG_T0HI_REG(i) (REG_TIMG_BASE(i) + 0x0008) -/* TIMG_T0_HI : RO ;bitpos:[31:0] ;default: 32'h0 ; */ -/*description: */ -#define TIMG_T0_HI 0xFFFFFFFF -#define TIMG_T0_HI_M ((TIMG_T0_HI_V)<<(TIMG_T0_HI_S)) -#define TIMG_T0_HI_V 0xFFFFFFFF +/** TIMG_T1HI_REG register + * Timer 1 current value, high 32 bits + */ +#define TIMG_T1HI_REG(i) (DR_REG_TIMG_BASE(i) + 0x2c) +/** TIMG_T0_HI : RO; bitpos: [31:0]; default: 0; + * After writing to TIMG_T1UPDATE_REG, the high 32 bits of the time-base counter + * + * of timer 1 can be read here. + */ +#define TIMG_T0_HI 0xFFFFFFFFU +#define TIMG_T0_HI_M (TIMG_T0_HI_V << TIMG_T0_HI_S) +#define TIMG_T0_HI_V 0xFFFFFFFFU #define TIMG_T0_HI_S 0 -#define TIMG_T0UPDATE_REG(i) (REG_TIMG_BASE(i) + 0x000c) -/* TIMG_T0_UPDATE : R/W ;bitpos:[31] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_T0_UPDATE (BIT(31)) -#define TIMG_T0_UPDATE_M (BIT(31)) -#define TIMG_T0_UPDATE_V 0x1 +/** TIMG_T1UPDATE_REG register + * Write to copy current timer value to TIMGn_T1_(LO/HI)_REG + */ +#define TIMG_T1UPDATE_REG(i) (DR_REG_TIMG_BASE(i) + 0x30) +/** TIMG_T0_UPDATE : R/W; bitpos: [31]; default: 0; + * After writing 0 or 1 to TIMG_T1UPDATE_REG, the counter value is latched. + */ +#define TIMG_T0_UPDATE (BIT(31)) +#define TIMG_T0_UPDATE_M (TIMG_T0_UPDATE_V << TIMG_T0_UPDATE_S) +#define TIMG_T0_UPDATE_V 0x00000001U #define TIMG_T0_UPDATE_S 31 -#define TIMG_T0ALARMLO_REG(i) (REG_TIMG_BASE(i) + 0x0010) -/* TIMG_T0_ALARM_LO : R/W ;bitpos:[31:0] ;default: 32'h0 ; */ -/*description: */ -#define TIMG_T0_ALARM_LO 0xFFFFFFFF -#define TIMG_T0_ALARM_LO_M ((TIMG_T0_ALARM_LO_V)<<(TIMG_T0_ALARM_LO_S)) -#define TIMG_T0_ALARM_LO_V 0xFFFFFFFF +/** TIMG_T1ALARMLO_REG register + * Timer 1 alarm value, low 32 bits + */ +#define TIMG_T1ALARMLO_REG(i) (DR_REG_TIMG_BASE(i) + 0x34) +/** TIMG_T0_ALARM_LO : R/W; bitpos: [31:0]; default: 0; + * Timer 1 alarm trigger time-base counter value, low 32 bits. + */ +#define TIMG_T0_ALARM_LO 0xFFFFFFFFU +#define TIMG_T0_ALARM_LO_M (TIMG_T0_ALARM_LO_V << TIMG_T0_ALARM_LO_S) +#define TIMG_T0_ALARM_LO_V 0xFFFFFFFFU #define TIMG_T0_ALARM_LO_S 0 -#define TIMG_T0ALARMHI_REG(i) (REG_TIMG_BASE(i) + 0x0014) -/* TIMG_T0_ALARM_HI : R/W ;bitpos:[31:0] ;default: 32'h0 ; */ -/*description: */ -#define TIMG_T0_ALARM_HI 0xFFFFFFFF -#define TIMG_T0_ALARM_HI_M ((TIMG_T0_ALARM_HI_V)<<(TIMG_T0_ALARM_HI_S)) -#define TIMG_T0_ALARM_HI_V 0xFFFFFFFF +/** TIMG_T1ALARMHI_REG register + * Timer 1 alarm value, high bits + */ +#define TIMG_T1ALARMHI_REG(i) (DR_REG_TIMG_BASE(i) + 0x38) +/** TIMG_T0_ALARM_HI : R/W; bitpos: [31:0]; default: 0; + * + * + * Timer 1 alarm trigger time-base counter value, high 32 bits. + */ +#define TIMG_T0_ALARM_HI 0xFFFFFFFFU +#define TIMG_T0_ALARM_HI_M (TIMG_T0_ALARM_HI_V << TIMG_T0_ALARM_HI_S) +#define TIMG_T0_ALARM_HI_V 0xFFFFFFFFU #define TIMG_T0_ALARM_HI_S 0 -#define TIMG_T0LOADLO_REG(i) (REG_TIMG_BASE(i) + 0x0018) -/* TIMG_T0_LOAD_LO : R/W ;bitpos:[31:0] ;default: 32'h0 ; */ -/*description: */ -#define TIMG_T0_LOAD_LO 0xFFFFFFFF -#define TIMG_T0_LOAD_LO_M ((TIMG_T0_LOAD_LO_V)<<(TIMG_T0_LOAD_LO_S)) -#define TIMG_T0_LOAD_LO_V 0xFFFFFFFF +/** TIMG_T1LOADLO_REG register + * Timer 1 reload value, low 32 bits + */ +#define TIMG_T1LOADLO_REG(i) (DR_REG_TIMG_BASE(i) + 0x3c) +/** TIMG_T0_LOAD_LO : R/W; bitpos: [31:0]; default: 0; + * + * + * Low 32 bits of the value that a reload will load onto timer 1 time-base + * + * Counter. + */ +#define TIMG_T0_LOAD_LO 0xFFFFFFFFU +#define TIMG_T0_LOAD_LO_M (TIMG_T0_LOAD_LO_V << TIMG_T0_LOAD_LO_S) +#define TIMG_T0_LOAD_LO_V 0xFFFFFFFFU #define TIMG_T0_LOAD_LO_S 0 -#define TIMG_T0LOADHI_REG(i) (REG_TIMG_BASE(i) + 0x001c) -/* TIMG_T0_LOAD_HI : R/W ;bitpos:[31:0] ;default: 32'h0 ; */ -/*description: */ -#define TIMG_T0_LOAD_HI 0xFFFFFFFF -#define TIMG_T0_LOAD_HI_M ((TIMG_T0_LOAD_HI_V)<<(TIMG_T0_LOAD_HI_S)) -#define TIMG_T0_LOAD_HI_V 0xFFFFFFFF +/** TIMG_T1LOADHI_REG register + * Timer 1 reload value, high 32 bits + */ +#define TIMG_T1LOADHI_REG(i) (DR_REG_TIMG_BASE(i) + 0x40) +/** TIMG_T0_LOAD_HI : R/W; bitpos: [31:0]; default: 0; + * + * + * High 32 bits of the value that a reload will load onto timer 1 time-base + * + * counter. + */ +#define TIMG_T0_LOAD_HI 0xFFFFFFFFU +#define TIMG_T0_LOAD_HI_M (TIMG_T0_LOAD_HI_V << TIMG_T0_LOAD_HI_S) +#define TIMG_T0_LOAD_HI_V 0xFFFFFFFFU #define TIMG_T0_LOAD_HI_S 0 -#define TIMG_T0LOAD_REG(i) (REG_TIMG_BASE(i) + 0x0020) -/* TIMG_T0_LOAD : WO ;bitpos:[31:0] ;default: 32'h0 ; */ -/*description: */ -#define TIMG_T0_LOAD 0xFFFFFFFF -#define TIMG_T0_LOAD_M ((TIMG_T0_LOAD_V)<<(TIMG_T0_LOAD_S)) -#define TIMG_T0_LOAD_V 0xFFFFFFFF +/** TIMG_T1LOAD_REG register + * Write to reload timer from TIMG_T0_(LOADLOLOADHI)_REG + */ +#define TIMG_T1LOAD_REG(i) (DR_REG_TIMG_BASE(i) + 0x44) +/** TIMG_T0_LOAD : WO; bitpos: [31:0]; default: 0; + * + * + * Write any value to trigger a timer 1 time-base counter reload. + */ +#define TIMG_T0_LOAD 0xFFFFFFFFU +#define TIMG_T0_LOAD_M (TIMG_T0_LOAD_V << TIMG_T0_LOAD_S) +#define TIMG_T0_LOAD_V 0xFFFFFFFFU #define TIMG_T0_LOAD_S 0 -#define TIMG_T1CONFIG_REG(i) (REG_TIMG_BASE(i) + 0x0024) -/* TIMG_T1_EN : R/W ;bitpos:[31] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_T1_EN (BIT(31)) -#define TIMG_T1_EN_M (BIT(31)) -#define TIMG_T1_EN_V 0x1 -#define TIMG_T1_EN_S 31 -/* TIMG_T1_INCREASE : R/W ;bitpos:[30] ;default: 1'h1 ; */ -/*description: */ -#define TIMG_T1_INCREASE (BIT(30)) -#define TIMG_T1_INCREASE_M (BIT(30)) -#define TIMG_T1_INCREASE_V 0x1 -#define TIMG_T1_INCREASE_S 30 -/* TIMG_T1_AUTORELOAD : R/W ;bitpos:[29] ;default: 1'h1 ; */ -/*description: */ -#define TIMG_T1_AUTORELOAD (BIT(29)) -#define TIMG_T1_AUTORELOAD_M (BIT(29)) -#define TIMG_T1_AUTORELOAD_V 0x1 -#define TIMG_T1_AUTORELOAD_S 29 -/* TIMG_T1_DIVIDER : R/W ;bitpos:[28:13] ;default: 16'h1 ; */ -/*description: */ -#define TIMG_T1_DIVIDER 0x0000FFFF -#define TIMG_T1_DIVIDER_M ((TIMG_T1_DIVIDER_V)<<(TIMG_T1_DIVIDER_S)) -#define TIMG_T1_DIVIDER_V 0xFFFF -#define TIMG_T1_DIVIDER_S 13 -/* TIMG_T1_EDGE_INT_EN : R/W ;bitpos:[12] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_T1_EDGE_INT_EN (BIT(12)) -#define TIMG_T1_EDGE_INT_EN_M (BIT(12)) -#define TIMG_T1_EDGE_INT_EN_V 0x1 -#define TIMG_T1_EDGE_INT_EN_S 12 -/* TIMG_T1_LEVEL_INT_EN : R/W ;bitpos:[11] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_T1_LEVEL_INT_EN (BIT(11)) -#define TIMG_T1_LEVEL_INT_EN_M (BIT(11)) -#define TIMG_T1_LEVEL_INT_EN_V 0x1 -#define TIMG_T1_LEVEL_INT_EN_S 11 -/* TIMG_T1_ALARM_EN : R/W ;bitpos:[10] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_T1_ALARM_EN (BIT(10)) -#define TIMG_T1_ALARM_EN_M (BIT(10)) -#define TIMG_T1_ALARM_EN_V 0x1 -#define TIMG_T1_ALARM_EN_S 10 -/* TIMG_T1_USE_XTAL : R/W ;bitpos:[9] ;default: 1'd0 ; */ -/*description: */ -#define TIMG_T1_USE_XTAL (BIT(9)) -#define TIMG_T1_USE_XTAL_M (BIT(9)) -#define TIMG_T1_USE_XTAL_V 0x1 -#define TIMG_T1_USE_XTAL_S 9 - -#define TIMG_T1LO_REG(i) (REG_TIMG_BASE(i) + 0x0028) -/* TIMG_T1_LO : RO ;bitpos:[31:0] ;default: 32'h0 ; */ -/*description: */ -#define TIMG_T1_LO 0xFFFFFFFF -#define TIMG_T1_LO_M ((TIMG_T1_LO_V)<<(TIMG_T1_LO_S)) -#define TIMG_T1_LO_V 0xFFFFFFFF -#define TIMG_T1_LO_S 0 - -#define TIMG_T1HI_REG(i) (REG_TIMG_BASE(i) + 0x002c) -/* TIMG_T1_HI : RO ;bitpos:[31:0] ;default: 32'h0 ; */ -/*description: */ -#define TIMG_T1_HI 0xFFFFFFFF -#define TIMG_T1_HI_M ((TIMG_T1_HI_V)<<(TIMG_T1_HI_S)) -#define TIMG_T1_HI_V 0xFFFFFFFF -#define TIMG_T1_HI_S 0 - -#define TIMG_T1UPDATE_REG(i) (REG_TIMG_BASE(i) + 0x0030) -/* TIMG_T1_UPDATE : R/W ;bitpos:[31] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_T1_UPDATE (BIT(31)) -#define TIMG_T1_UPDATE_M (BIT(31)) -#define TIMG_T1_UPDATE_V 0x1 -#define TIMG_T1_UPDATE_S 31 - -#define TIMG_T1ALARMLO_REG(i) (REG_TIMG_BASE(i) + 0x0034) -/* TIMG_T1_ALARM_LO : R/W ;bitpos:[31:0] ;default: 32'h0 ; */ -/*description: */ -#define TIMG_T1_ALARM_LO 0xFFFFFFFF -#define TIMG_T1_ALARM_LO_M ((TIMG_T1_ALARM_LO_V)<<(TIMG_T1_ALARM_LO_S)) -#define TIMG_T1_ALARM_LO_V 0xFFFFFFFF -#define TIMG_T1_ALARM_LO_S 0 - -#define TIMG_T1ALARMHI_REG(i) (REG_TIMG_BASE(i) + 0x0038) -/* TIMG_T1_ALARM_HI : R/W ;bitpos:[31:0] ;default: 32'h0 ; */ -/*description: */ -#define TIMG_T1_ALARM_HI 0xFFFFFFFF -#define TIMG_T1_ALARM_HI_M ((TIMG_T1_ALARM_HI_V)<<(TIMG_T1_ALARM_HI_S)) -#define TIMG_T1_ALARM_HI_V 0xFFFFFFFF -#define TIMG_T1_ALARM_HI_S 0 - -#define TIMG_T1LOADLO_REG(i) (REG_TIMG_BASE(i) + 0x003c) -/* TIMG_T1_LOAD_LO : R/W ;bitpos:[31:0] ;default: 32'h0 ; */ -/*description: */ -#define TIMG_T1_LOAD_LO 0xFFFFFFFF -#define TIMG_T1_LOAD_LO_M ((TIMG_T1_LOAD_LO_V)<<(TIMG_T1_LOAD_LO_S)) -#define TIMG_T1_LOAD_LO_V 0xFFFFFFFF -#define TIMG_T1_LOAD_LO_S 0 - -#define TIMG_T1LOADHI_REG(i) (REG_TIMG_BASE(i) + 0x0040) -/* TIMG_T1_LOAD_HI : R/W ;bitpos:[31:0] ;default: 32'h0 ; */ -/*description: */ -#define TIMG_T1_LOAD_HI 0xFFFFFFFF -#define TIMG_T1_LOAD_HI_M ((TIMG_T1_LOAD_HI_V)<<(TIMG_T1_LOAD_HI_S)) -#define TIMG_T1_LOAD_HI_V 0xFFFFFFFF -#define TIMG_T1_LOAD_HI_S 0 - -#define TIMG_T1LOAD_REG(i) (REG_TIMG_BASE(i) + 0x0044) -/* TIMG_T1_LOAD : WO ;bitpos:[31:0] ;default: 32'h0 ; */ -/*description: */ -#define TIMG_T1_LOAD 0xFFFFFFFF -#define TIMG_T1_LOAD_M ((TIMG_T1_LOAD_V)<<(TIMG_T1_LOAD_S)) -#define TIMG_T1_LOAD_V 0xFFFFFFFF -#define TIMG_T1_LOAD_S 0 - -#define TIMG_WDTCONFIG0_REG(i) (REG_TIMG_BASE(i) + 0x0048) -/* TIMG_WDT_EN : R/W ;bitpos:[31] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_WDT_EN (BIT(31)) -#define TIMG_WDT_EN_M (BIT(31)) -#define TIMG_WDT_EN_V 0x1 -#define TIMG_WDT_EN_S 31 -/* TIMG_WDT_STG0 : R/W ;bitpos:[30:29] ;default: 1'd0 ; */ -/*description: */ -#define TIMG_WDT_STG0 0x00000003 -#define TIMG_WDT_STG0_M ((TIMG_WDT_STG0_V)<<(TIMG_WDT_STG0_S)) -#define TIMG_WDT_STG0_V 0x3 -#define TIMG_WDT_STG0_S 29 -/* TIMG_WDT_STG1 : R/W ;bitpos:[28:27] ;default: 1'd0 ; */ -/*description: */ -#define TIMG_WDT_STG1 0x00000003 -#define TIMG_WDT_STG1_M ((TIMG_WDT_STG1_V)<<(TIMG_WDT_STG1_S)) -#define TIMG_WDT_STG1_V 0x3 -#define TIMG_WDT_STG1_S 27 -/* TIMG_WDT_STG2 : R/W ;bitpos:[26:25] ;default: 1'd0 ; */ -/*description: */ -#define TIMG_WDT_STG2 0x00000003 -#define TIMG_WDT_STG2_M ((TIMG_WDT_STG2_V)<<(TIMG_WDT_STG2_S)) -#define TIMG_WDT_STG2_V 0x3 -#define TIMG_WDT_STG2_S 25 -/* TIMG_WDT_STG3 : R/W ;bitpos:[24:23] ;default: 1'd0 ; */ -/*description: */ -#define TIMG_WDT_STG3 0x00000003 -#define TIMG_WDT_STG3_M ((TIMG_WDT_STG3_V)<<(TIMG_WDT_STG3_S)) -#define TIMG_WDT_STG3_V 0x3 -#define TIMG_WDT_STG3_S 23 -/* TIMG_WDT_EDGE_INT_EN : R/W ;bitpos:[22] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_WDT_EDGE_INT_EN (BIT(22)) -#define TIMG_WDT_EDGE_INT_EN_M (BIT(22)) -#define TIMG_WDT_EDGE_INT_EN_V 0x1 -#define TIMG_WDT_EDGE_INT_EN_S 22 -/* TIMG_WDT_LEVEL_INT_EN : R/W ;bitpos:[21] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_WDT_LEVEL_INT_EN (BIT(21)) -#define TIMG_WDT_LEVEL_INT_EN_M (BIT(21)) -#define TIMG_WDT_LEVEL_INT_EN_V 0x1 -#define TIMG_WDT_LEVEL_INT_EN_S 21 -/* TIMG_WDT_CPU_RESET_LENGTH : R/W ;bitpos:[20:18] ;default: 3'h1 ; */ -/*description: */ -#define TIMG_WDT_CPU_RESET_LENGTH 0x00000007 -#define TIMG_WDT_CPU_RESET_LENGTH_M ((TIMG_WDT_CPU_RESET_LENGTH_V)<<(TIMG_WDT_CPU_RESET_LENGTH_S)) -#define TIMG_WDT_CPU_RESET_LENGTH_V 0x7 -#define TIMG_WDT_CPU_RESET_LENGTH_S 18 -/* TIMG_WDT_SYS_RESET_LENGTH : R/W ;bitpos:[17:15] ;default: 3'h1 ; */ -/*description: */ -#define TIMG_WDT_SYS_RESET_LENGTH 0x00000007 -#define TIMG_WDT_SYS_RESET_LENGTH_M ((TIMG_WDT_SYS_RESET_LENGTH_V)<<(TIMG_WDT_SYS_RESET_LENGTH_S)) -#define TIMG_WDT_SYS_RESET_LENGTH_V 0x7 -#define TIMG_WDT_SYS_RESET_LENGTH_S 15 -/* TIMG_WDT_FLASHBOOT_MOD_EN : R/W ;bitpos:[14] ;default: 1'h1 ; */ -/*description: */ -#define TIMG_WDT_FLASHBOOT_MOD_EN (BIT(14)) -#define TIMG_WDT_FLASHBOOT_MOD_EN_M (BIT(14)) -#define TIMG_WDT_FLASHBOOT_MOD_EN_V 0x1 -#define TIMG_WDT_FLASHBOOT_MOD_EN_S 14 -/* TIMG_WDT_PROCPU_RESET_EN : R/W ;bitpos:[13] ;default: 1'd0 ; */ -/*description: */ -#define TIMG_WDT_PROCPU_RESET_EN (BIT(13)) -#define TIMG_WDT_PROCPU_RESET_EN_M (BIT(13)) -#define TIMG_WDT_PROCPU_RESET_EN_V 0x1 -#define TIMG_WDT_PROCPU_RESET_EN_S 13 -/* TIMG_WDT_APPCPU_RESET_EN : R/W ;bitpos:[12] ;default: 1'd0 ; */ -/*description: */ -#define TIMG_WDT_APPCPU_RESET_EN (BIT(12)) -#define TIMG_WDT_APPCPU_RESET_EN_M (BIT(12)) -#define TIMG_WDT_APPCPU_RESET_EN_V 0x1 +/** TIMG_WDTCONFIG0_REG register + * Watchdog timer configuration register + */ +#define TIMG_WDTCONFIG0_REG(i) (DR_REG_TIMG_BASE(i) + 0x48) +/** TIMG_WDT_APPCPU_RESET_EN : R/W; bitpos: [12]; default: 0; + * Reserved + */ +#define TIMG_WDT_APPCPU_RESET_EN (BIT(12)) +#define TIMG_WDT_APPCPU_RESET_EN_M (TIMG_WDT_APPCPU_RESET_EN_V << TIMG_WDT_APPCPU_RESET_EN_S) +#define TIMG_WDT_APPCPU_RESET_EN_V 0x00000001U #define TIMG_WDT_APPCPU_RESET_EN_S 12 +/** TIMG_WDT_PROCPU_RESET_EN : R/W; bitpos: [13]; default: 0; + * WDT reset CPU enable. + */ +#define TIMG_WDT_PROCPU_RESET_EN (BIT(13)) +#define TIMG_WDT_PROCPU_RESET_EN_M (TIMG_WDT_PROCPU_RESET_EN_V << TIMG_WDT_PROCPU_RESET_EN_S) +#define TIMG_WDT_PROCPU_RESET_EN_V 0x00000001U +#define TIMG_WDT_PROCPU_RESET_EN_S 13 +/** TIMG_WDT_FLASHBOOT_MOD_EN : R/W; bitpos: [14]; default: 1; + * When set, Flash boot protection is enabled. + */ +#define TIMG_WDT_FLASHBOOT_MOD_EN (BIT(14)) +#define TIMG_WDT_FLASHBOOT_MOD_EN_M (TIMG_WDT_FLASHBOOT_MOD_EN_V << TIMG_WDT_FLASHBOOT_MOD_EN_S) +#define TIMG_WDT_FLASHBOOT_MOD_EN_V 0x00000001U +#define TIMG_WDT_FLASHBOOT_MOD_EN_S 14 +/** TIMG_WDT_SYS_RESET_LENGTH : R/W; bitpos: [17:15]; default: 1; + * System reset signal length selection. 0: 100 ns, 1: 200 ns, + * + * 2: 300 ns, 3: 400 ns, 4: 500 ns, 5: 800 ns, 6: 1.6 us, 7: 3.2 us. + */ +#define TIMG_WDT_SYS_RESET_LENGTH 0x00000007U +#define TIMG_WDT_SYS_RESET_LENGTH_M (TIMG_WDT_SYS_RESET_LENGTH_V << TIMG_WDT_SYS_RESET_LENGTH_S) +#define TIMG_WDT_SYS_RESET_LENGTH_V 0x00000007U +#define TIMG_WDT_SYS_RESET_LENGTH_S 15 +/** TIMG_WDT_CPU_RESET_LENGTH : R/W; bitpos: [20:18]; default: 1; + * CPU reset signal length selection. 0: 100 ns, 1: 200 ns, + * + * 2: 300 ns, 3: 400 ns, 4: 500 ns, 5: 800 ns, 6: 1.6 us, 7: 3.2 us. + */ +#define TIMG_WDT_CPU_RESET_LENGTH 0x00000007U +#define TIMG_WDT_CPU_RESET_LENGTH_M (TIMG_WDT_CPU_RESET_LENGTH_V << TIMG_WDT_CPU_RESET_LENGTH_S) +#define TIMG_WDT_CPU_RESET_LENGTH_V 0x00000007U +#define TIMG_WDT_CPU_RESET_LENGTH_S 18 +/** TIMG_WDT_LEVEL_INT_EN : R/W; bitpos: [21]; default: 0; + * When set, a level type interrupt will occur at the timeout of a stage + * + * configured to generate an interrupt. + */ +#define TIMG_WDT_LEVEL_INT_EN (BIT(21)) +#define TIMG_WDT_LEVEL_INT_EN_M (TIMG_WDT_LEVEL_INT_EN_V << TIMG_WDT_LEVEL_INT_EN_S) +#define TIMG_WDT_LEVEL_INT_EN_V 0x00000001U +#define TIMG_WDT_LEVEL_INT_EN_S 21 +/** TIMG_WDT_EDGE_INT_EN : R/W; bitpos: [22]; default: 0; + * When set, an edge type interrupt will occur at the timeout of a stage + * + * configured to generate an interrupt. + */ +#define TIMG_WDT_EDGE_INT_EN (BIT(22)) +#define TIMG_WDT_EDGE_INT_EN_M (TIMG_WDT_EDGE_INT_EN_V << TIMG_WDT_EDGE_INT_EN_S) +#define TIMG_WDT_EDGE_INT_EN_V 0x00000001U +#define TIMG_WDT_EDGE_INT_EN_S 22 +/** TIMG_WDT_STG3 : R/W; bitpos: [24:23]; default: 0; + * Stage 3 configuration. 0: off, 1: interrupt, 2: reset CPU, 3: reset system. + * + */ +#define TIMG_WDT_STG3 0x00000003U +#define TIMG_WDT_STG3_M (TIMG_WDT_STG3_V << TIMG_WDT_STG3_S) +#define TIMG_WDT_STG3_V 0x00000003U +#define TIMG_WDT_STG3_S 23 +/** TIMG_WDT_STG2 : R/W; bitpos: [26:25]; default: 0; + * Stage 2 configuration. 0: off, 1: interrupt, 2: reset CPU, 3: reset system. + * + */ +#define TIMG_WDT_STG2 0x00000003U +#define TIMG_WDT_STG2_M (TIMG_WDT_STG2_V << TIMG_WDT_STG2_S) +#define TIMG_WDT_STG2_V 0x00000003U +#define TIMG_WDT_STG2_S 25 +/** TIMG_WDT_STG1 : R/W; bitpos: [28:27]; default: 0; + * Stage 1 configuration. 0: off, 1: interrupt, 2: reset CPU, 3: reset system. + * + */ +#define TIMG_WDT_STG1 0x00000003U +#define TIMG_WDT_STG1_M (TIMG_WDT_STG1_V << TIMG_WDT_STG1_S) +#define TIMG_WDT_STG1_V 0x00000003U +#define TIMG_WDT_STG1_S 27 +/** TIMG_WDT_STG0 : R/W; bitpos: [30:29]; default: 0; + * Stage 0 configuration. 0: off, 1: interrupt, 2: reset CPU, 3: reset system. + * + */ +#define TIMG_WDT_STG0 0x00000003U +#define TIMG_WDT_STG0_M (TIMG_WDT_STG0_V << TIMG_WDT_STG0_S) +#define TIMG_WDT_STG0_V 0x00000003U +#define TIMG_WDT_STG0_S 29 +/** TIMG_WDT_EN : R/W; bitpos: [31]; default: 0; + * When set, MWDT is enabled. + */ +#define TIMG_WDT_EN (BIT(31)) +#define TIMG_WDT_EN_M (TIMG_WDT_EN_V << TIMG_WDT_EN_S) +#define TIMG_WDT_EN_V 0x00000001U +#define TIMG_WDT_EN_S 31 -#define TIMG_WDTCONFIG1_REG(i) (REG_TIMG_BASE(i) + 0x004c) -/* TIMG_WDT_CLK_PRESCALE : R/W ;bitpos:[31:16] ;default: 16'h1 ; */ -/*description: */ -#define TIMG_WDT_CLK_PRESCALE 0x0000FFFF -#define TIMG_WDT_CLK_PRESCALE_M ((TIMG_WDT_CLK_PRESCALE_V)<<(TIMG_WDT_CLK_PRESCALE_S)) -#define TIMG_WDT_CLK_PRESCALE_V 0xFFFF -#define TIMG_WDT_CLK_PRESCALE_S 16 - -#define TIMG_WDTCONFIG2_REG(i) (REG_TIMG_BASE(i) + 0x0050) -/* TIMG_WDT_STG0_HOLD : R/W ;bitpos:[31:0] ;default: 32'd26000000 ; */ -/*description: */ -#define TIMG_WDT_STG0_HOLD 0xFFFFFFFF -#define TIMG_WDT_STG0_HOLD_M ((TIMG_WDT_STG0_HOLD_V)<<(TIMG_WDT_STG0_HOLD_S)) -#define TIMG_WDT_STG0_HOLD_V 0xFFFFFFFF +/** TIMG_WDTCONFIG1_REG register + * Watchdog timer prescaler register + */ +#define TIMG_WDTCONFIG1_REG(i) (DR_REG_TIMG_BASE(i) + 0x4c) +/** TIMG_WDT_CLK_PRESCALER : R/W; bitpos: [31:16]; default: 1; + * MWDT clock prescaler value. MWDT clock period = 12.5 ns * + * + * TIMG_WDT_CLK_PRESCALE. + */ +#define TIMG_WDT_CLK_PRESCALER 0x0000FFFFU +#define TIMG_WDT_CLK_PRESCALER_M (TIMG_WDT_CLK_PRESCALER_V << TIMG_WDT_CLK_PRESCALER_S) +#define TIMG_WDT_CLK_PRESCALER_V 0x0000FFFFU +#define TIMG_WDT_CLK_PRESCALER_S 16 + +/** TIMG_WDTCONFIG2_REG register + * Watchdog timer stage 0 timeout value + */ +#define TIMG_WDTCONFIG2_REG(i) (DR_REG_TIMG_BASE(i) + 0x50) +/** TIMG_WDT_STG0_HOLD : R/W; bitpos: [31:0]; default: 26000000; + * Stage 0 timeout value, in MWDT clock cycles. + */ +#define TIMG_WDT_STG0_HOLD 0xFFFFFFFFU +#define TIMG_WDT_STG0_HOLD_M (TIMG_WDT_STG0_HOLD_V << TIMG_WDT_STG0_HOLD_S) +#define TIMG_WDT_STG0_HOLD_V 0xFFFFFFFFU #define TIMG_WDT_STG0_HOLD_S 0 -#define TIMG_WDTCONFIG3_REG(i) (REG_TIMG_BASE(i) + 0x0054) -/* TIMG_WDT_STG1_HOLD : R/W ;bitpos:[31:0] ;default: 32'h7ffffff ; */ -/*description: */ -#define TIMG_WDT_STG1_HOLD 0xFFFFFFFF -#define TIMG_WDT_STG1_HOLD_M ((TIMG_WDT_STG1_HOLD_V)<<(TIMG_WDT_STG1_HOLD_S)) -#define TIMG_WDT_STG1_HOLD_V 0xFFFFFFFF +/** TIMG_WDTCONFIG3_REG register + * Watchdog timer stage 1 timeout value + */ +#define TIMG_WDTCONFIG3_REG(i) (DR_REG_TIMG_BASE(i) + 0x54) +/** TIMG_WDT_STG1_HOLD : R/W; bitpos: [31:0]; default: 134217727; + * Stage 1 timeout value, in MWDT clock cycles. + */ +#define TIMG_WDT_STG1_HOLD 0xFFFFFFFFU +#define TIMG_WDT_STG1_HOLD_M (TIMG_WDT_STG1_HOLD_V << TIMG_WDT_STG1_HOLD_S) +#define TIMG_WDT_STG1_HOLD_V 0xFFFFFFFFU #define TIMG_WDT_STG1_HOLD_S 0 -#define TIMG_WDTCONFIG4_REG(i) (REG_TIMG_BASE(i) + 0x0058) -/* TIMG_WDT_STG2_HOLD : R/W ;bitpos:[31:0] ;default: 32'hfffff ; */ -/*description: */ -#define TIMG_WDT_STG2_HOLD 0xFFFFFFFF -#define TIMG_WDT_STG2_HOLD_M ((TIMG_WDT_STG2_HOLD_V)<<(TIMG_WDT_STG2_HOLD_S)) -#define TIMG_WDT_STG2_HOLD_V 0xFFFFFFFF +/** TIMG_WDTCONFIG4_REG register + * Watchdog timer stage 2 timeout value + */ +#define TIMG_WDTCONFIG4_REG(i) (DR_REG_TIMG_BASE(i) + 0x58) +/** TIMG_WDT_STG2_HOLD : R/W; bitpos: [31:0]; default: 1048575; + * Stage 2 timeout value, in MWDT clock cycles. + */ +#define TIMG_WDT_STG2_HOLD 0xFFFFFFFFU +#define TIMG_WDT_STG2_HOLD_M (TIMG_WDT_STG2_HOLD_V << TIMG_WDT_STG2_HOLD_S) +#define TIMG_WDT_STG2_HOLD_V 0xFFFFFFFFU #define TIMG_WDT_STG2_HOLD_S 0 -#define TIMG_WDTCONFIG5_REG(i) (REG_TIMG_BASE(i) + 0x005c) -/* TIMG_WDT_STG3_HOLD : R/W ;bitpos:[31:0] ;default: 32'hfffff ; */ -/*description: */ -#define TIMG_WDT_STG3_HOLD 0xFFFFFFFF -#define TIMG_WDT_STG3_HOLD_M ((TIMG_WDT_STG3_HOLD_V)<<(TIMG_WDT_STG3_HOLD_S)) -#define TIMG_WDT_STG3_HOLD_V 0xFFFFFFFF +/** TIMG_WDTCONFIG5_REG register + * Watchdog timer stage 3 timeout value + */ +#define TIMG_WDTCONFIG5_REG(i) (DR_REG_TIMG_BASE(i) + 0x5c) +/** TIMG_WDT_STG3_HOLD : R/W; bitpos: [31:0]; default: 1048575; + * Stage 3 timeout value, in MWDT clock cycles. + */ +#define TIMG_WDT_STG3_HOLD 0xFFFFFFFFU +#define TIMG_WDT_STG3_HOLD_M (TIMG_WDT_STG3_HOLD_V << TIMG_WDT_STG3_HOLD_S) +#define TIMG_WDT_STG3_HOLD_V 0xFFFFFFFFU #define TIMG_WDT_STG3_HOLD_S 0 -#define TIMG_WDTFEED_REG(i) (REG_TIMG_BASE(i) + 0x0060) -/* TIMG_WDT_FEED : WO ;bitpos:[31:0] ;default: 32'h0 ; */ -/*description: */ -#define TIMG_WDT_FEED 0xFFFFFFFF -#define TIMG_WDT_FEED_M ((TIMG_WDT_FEED_V)<<(TIMG_WDT_FEED_S)) -#define TIMG_WDT_FEED_V 0xFFFFFFFF +/** TIMG_WDTFEED_REG register + * Write to feed the watchdog timer + */ +#define TIMG_WDTFEED_REG(i) (DR_REG_TIMG_BASE(i) + 0x60) +/** TIMG_WDT_FEED : WO; bitpos: [31:0]; default: 0; + * Write any value to feed the MWDT. (WO) + */ +#define TIMG_WDT_FEED 0xFFFFFFFFU +#define TIMG_WDT_FEED_M (TIMG_WDT_FEED_V << TIMG_WDT_FEED_S) +#define TIMG_WDT_FEED_V 0xFFFFFFFFU #define TIMG_WDT_FEED_S 0 -#define TIMG_WDTWPROTECT_REG(i) (REG_TIMG_BASE(i) + 0x0064) -/* TIMG_WDT_WKEY : R/W ;bitpos:[31:0] ;default: 32'h50d83aa1 ; */ -/*description: */ -#define TIMG_WDT_WKEY 0xFFFFFFFF -#define TIMG_WDT_WKEY_M ((TIMG_WDT_WKEY_V)<<(TIMG_WDT_WKEY_S)) -#define TIMG_WDT_WKEY_V 0xFFFFFFFF +/** TIMG_WDTWPROTECT_REG register + * Watchdog write protect register + */ +#define TIMG_WDTWPROTECT_REG(i) (DR_REG_TIMG_BASE(i) + 0x64) +/** TIMG_WDT_WKEY : R/W; bitpos: [31:0]; default: 1356348065; + * If the register contains a different value than its reset value, write + * + * protection is enabled. + */ +#define TIMG_WDT_WKEY 0xFFFFFFFFU +#define TIMG_WDT_WKEY_M (TIMG_WDT_WKEY_V << TIMG_WDT_WKEY_S) +#define TIMG_WDT_WKEY_V 0xFFFFFFFFU #define TIMG_WDT_WKEY_S 0 -#define TIMG_RTCCALICFG_REG(i) (REG_TIMG_BASE(i) + 0x0068) -/* TIMG_RTC_CALI_START : R/W ;bitpos:[31] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_RTC_CALI_START (BIT(31)) -#define TIMG_RTC_CALI_START_M (BIT(31)) -#define TIMG_RTC_CALI_START_V 0x1 -#define TIMG_RTC_CALI_START_S 31 -/* TIMG_RTC_CALI_MAX : R/W ;bitpos:[30:16] ;default: 15'h1 ; */ -/*description: */ -#define TIMG_RTC_CALI_MAX 0x00007FFF -#define TIMG_RTC_CALI_MAX_M ((TIMG_RTC_CALI_MAX_V)<<(TIMG_RTC_CALI_MAX_S)) -#define TIMG_RTC_CALI_MAX_V 0x7FFF -#define TIMG_RTC_CALI_MAX_S 16 -/* TIMG_RTC_CALI_RDY : RO ;bitpos:[15] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_RTC_CALI_RDY (BIT(15)) -#define TIMG_RTC_CALI_RDY_M (BIT(15)) -#define TIMG_RTC_CALI_RDY_V 0x1 -#define TIMG_RTC_CALI_RDY_S 15 -/* TIMG_RTC_CALI_CLK_SEL : R/W ;bitpos:[14:13] ;default: 2'h1 ; */ -/*description: */ -#define TIMG_RTC_CALI_CLK_SEL 0x00000003 -#define TIMG_RTC_CALI_CLK_SEL_M ((TIMG_RTC_CALI_CLK_SEL_V)<<(TIMG_RTC_CALI_CLK_SEL_S)) -#define TIMG_RTC_CALI_CLK_SEL_V 0x3 -#define TIMG_RTC_CALI_CLK_SEL_S 13 -/* TIMG_RTC_CALI_START_CYCLING : R/W ;bitpos:[12] ;default: 1'd1 ; */ -/*description: */ -#define TIMG_RTC_CALI_START_CYCLING (BIT(12)) -#define TIMG_RTC_CALI_START_CYCLING_M (BIT(12)) -#define TIMG_RTC_CALI_START_CYCLING_V 0x1 +/** TIMG_RTCCALICFG_REG register + * RTC calibration configuration register + */ +#define TIMG_RTCCALICFG_REG(i) (DR_REG_TIMG_BASE(i) + 0x68) +/** TIMG_RTC_CALI_START_CYCLING : R/W; bitpos: [12]; default: 1; + * Reserved + */ +#define TIMG_RTC_CALI_START_CYCLING (BIT(12)) +#define TIMG_RTC_CALI_START_CYCLING_M (TIMG_RTC_CALI_START_CYCLING_V << TIMG_RTC_CALI_START_CYCLING_S) +#define TIMG_RTC_CALI_START_CYCLING_V 0x00000001U #define TIMG_RTC_CALI_START_CYCLING_S 12 +/** TIMG_RTC_CALI_CLK_SEL : R/W; bitpos: [14:13]; default: 1; + * 0:rtcslowclock. 1:clk_80m. 2:xtal_32k. + */ +#define TIMG_RTC_CALI_CLK_SEL 0x00000003U +#define TIMG_RTC_CALI_CLK_SEL_M (TIMG_RTC_CALI_CLK_SEL_V << TIMG_RTC_CALI_CLK_SEL_S) +#define TIMG_RTC_CALI_CLK_SEL_V 0x00000003U +#define TIMG_RTC_CALI_CLK_SEL_S 13 +/** TIMG_RTC_CALI_RDY : RO; bitpos: [15]; default: 0; + * Reserved + */ +#define TIMG_RTC_CALI_RDY (BIT(15)) +#define TIMG_RTC_CALI_RDY_M (TIMG_RTC_CALI_RDY_V << TIMG_RTC_CALI_RDY_S) +#define TIMG_RTC_CALI_RDY_V 0x00000001U +#define TIMG_RTC_CALI_RDY_S 15 +/** TIMG_RTC_CALI_MAX : R/W; bitpos: [30:16]; default: 1; + * Reserved + */ +#define TIMG_RTC_CALI_MAX 0x00007FFFU +#define TIMG_RTC_CALI_MAX_M (TIMG_RTC_CALI_MAX_V << TIMG_RTC_CALI_MAX_S) +#define TIMG_RTC_CALI_MAX_V 0x00007FFFU +#define TIMG_RTC_CALI_MAX_S 16 +/** TIMG_RTC_CALI_START : R/W; bitpos: [31]; default: 0; + * Reserved + */ +#define TIMG_RTC_CALI_START (BIT(31)) +#define TIMG_RTC_CALI_START_M (TIMG_RTC_CALI_START_V << TIMG_RTC_CALI_START_S) +#define TIMG_RTC_CALI_START_V 0x00000001U +#define TIMG_RTC_CALI_START_S 31 -#define TIMG_RTCCALICFG1_REG(i) (REG_TIMG_BASE(i) + 0x006c) -/* TIMG_RTC_CALI_VALUE : RO ;bitpos:[31:7] ;default: 25'h0 ; */ -/*description: */ -#define TIMG_RTC_CALI_VALUE 0x01FFFFFF -#define TIMG_RTC_CALI_VALUE_M ((TIMG_RTC_CALI_VALUE_V)<<(TIMG_RTC_CALI_VALUE_S)) -#define TIMG_RTC_CALI_VALUE_V 0x1FFFFFF -#define TIMG_RTC_CALI_VALUE_S 7 -/* TIMG_RTC_CALI_CYCLING_DATA_VLD : RO ;bitpos:[0] ;default: 1'b0 ; */ -/*description: */ -#define TIMG_RTC_CALI_CYCLING_DATA_VLD (BIT(0)) -#define TIMG_RTC_CALI_CYCLING_DATA_VLD_M (BIT(0)) -#define TIMG_RTC_CALI_CYCLING_DATA_VLD_V 0x1 +/** TIMG_RTCCALICFG1_REG register + * RTC calibration configuration1 register + */ +#define TIMG_RTCCALICFG1_REG(i) (DR_REG_TIMG_BASE(i) + 0x6c) +/** TIMG_RTC_CALI_CYCLING_DATA_VLD : RO; bitpos: [0]; default: 0; + * Reserved + */ +#define TIMG_RTC_CALI_CYCLING_DATA_VLD (BIT(0)) +#define TIMG_RTC_CALI_CYCLING_DATA_VLD_M (TIMG_RTC_CALI_CYCLING_DATA_VLD_V << TIMG_RTC_CALI_CYCLING_DATA_VLD_S) +#define TIMG_RTC_CALI_CYCLING_DATA_VLD_V 0x00000001U #define TIMG_RTC_CALI_CYCLING_DATA_VLD_S 0 +/** TIMG_RTC_CALI_VALUE : RO; bitpos: [31:7]; default: 0; + * Reserved + */ +#define TIMG_RTC_CALI_VALUE 0x01FFFFFFU +#define TIMG_RTC_CALI_VALUE_M (TIMG_RTC_CALI_VALUE_V << TIMG_RTC_CALI_VALUE_S) +#define TIMG_RTC_CALI_VALUE_V 0x01FFFFFFU +#define TIMG_RTC_CALI_VALUE_S 7 -#define TIMG_LACTCONFIG_REG(i) (REG_TIMG_BASE(i) + 0x0070) -/* TIMG_LACT_EN : R/W ;bitpos:[31] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_LACT_EN (BIT(31)) -#define TIMG_LACT_EN_M (BIT(31)) -#define TIMG_LACT_EN_V 0x1 -#define TIMG_LACT_EN_S 31 -/* TIMG_LACT_INCREASE : R/W ;bitpos:[30] ;default: 1'h1 ; */ -/*description: */ -#define TIMG_LACT_INCREASE (BIT(30)) -#define TIMG_LACT_INCREASE_M (BIT(30)) -#define TIMG_LACT_INCREASE_V 0x1 -#define TIMG_LACT_INCREASE_S 30 -/* TIMG_LACT_AUTORELOAD : R/W ;bitpos:[29] ;default: 1'h1 ; */ -/*description: */ -#define TIMG_LACT_AUTORELOAD (BIT(29)) -#define TIMG_LACT_AUTORELOAD_M (BIT(29)) -#define TIMG_LACT_AUTORELOAD_V 0x1 -#define TIMG_LACT_AUTORELOAD_S 29 -/* TIMG_LACT_DIVIDER : R/W ;bitpos:[28:13] ;default: 16'h1 ; */ -/*description: */ -#define TIMG_LACT_DIVIDER 0x0000FFFF -#define TIMG_LACT_DIVIDER_M ((TIMG_LACT_DIVIDER_V)<<(TIMG_LACT_DIVIDER_S)) -#define TIMG_LACT_DIVIDER_V 0xFFFF -#define TIMG_LACT_DIVIDER_S 13 -/* TIMG_LACT_EDGE_INT_EN : R/W ;bitpos:[12] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_LACT_EDGE_INT_EN (BIT(12)) -#define TIMG_LACT_EDGE_INT_EN_M (BIT(12)) -#define TIMG_LACT_EDGE_INT_EN_V 0x1 -#define TIMG_LACT_EDGE_INT_EN_S 12 -/* TIMG_LACT_LEVEL_INT_EN : R/W ;bitpos:[11] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_LACT_LEVEL_INT_EN (BIT(11)) -#define TIMG_LACT_LEVEL_INT_EN_M (BIT(11)) -#define TIMG_LACT_LEVEL_INT_EN_V 0x1 -#define TIMG_LACT_LEVEL_INT_EN_S 11 -/* TIMG_LACT_ALARM_EN : R/W ;bitpos:[10] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_LACT_ALARM_EN (BIT(10)) -#define TIMG_LACT_ALARM_EN_M (BIT(10)) -#define TIMG_LACT_ALARM_EN_V 0x1 -#define TIMG_LACT_ALARM_EN_S 10 -/* TIMG_LACT_LAC_EN : R/W ;bitpos:[9] ;default: 1'h1 ; */ -/*description: */ -#define TIMG_LACT_LAC_EN (BIT(9)) -#define TIMG_LACT_LAC_EN_M (BIT(9)) -#define TIMG_LACT_LAC_EN_V 0x1 -#define TIMG_LACT_LAC_EN_S 9 -/* TIMG_LACT_CPST_EN : R/W ;bitpos:[8] ;default: 1'h1 ; */ -/*description: */ -#define TIMG_LACT_CPST_EN (BIT(8)) -#define TIMG_LACT_CPST_EN_M (BIT(8)) -#define TIMG_LACT_CPST_EN_V 0x1 -#define TIMG_LACT_CPST_EN_S 8 -/* TIMG_LACT_RTC_ONLY : R/W ;bitpos:[7] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_LACT_RTC_ONLY (BIT(7)) -#define TIMG_LACT_RTC_ONLY_M (BIT(7)) -#define TIMG_LACT_RTC_ONLY_V 0x1 -#define TIMG_LACT_RTC_ONLY_S 7 -/* TIMG_LACT_USE_REFTICK : R/W ;bitpos:[6] ;default: 1'd0 ; */ -/*description: */ -#define TIMG_LACT_USE_REFTICK (BIT(6)) -#define TIMG_LACT_USE_REFTICK_M (BIT(6)) -#define TIMG_LACT_USE_REFTICK_V 0x1 +/** TIMG_LACTCONFIG_REG register + * LACT configuration register + */ +#define TIMG_LACTCONFIG_REG(i) (DR_REG_TIMG_BASE(i) + 0x70) +/** TIMG_LACT_USE_REFTICK : R/W; bitpos: [6]; default: 0; + * Reserved + */ +#define TIMG_LACT_USE_REFTICK (BIT(6)) +#define TIMG_LACT_USE_REFTICK_M (TIMG_LACT_USE_REFTICK_V << TIMG_LACT_USE_REFTICK_S) +#define TIMG_LACT_USE_REFTICK_V 0x00000001U #define TIMG_LACT_USE_REFTICK_S 6 +/** TIMG_LACT_RTC_ONLY : R/W; bitpos: [7]; default: 0; + * Reserved + */ +#define TIMG_LACT_RTC_ONLY (BIT(7)) +#define TIMG_LACT_RTC_ONLY_M (TIMG_LACT_RTC_ONLY_V << TIMG_LACT_RTC_ONLY_S) +#define TIMG_LACT_RTC_ONLY_V 0x00000001U +#define TIMG_LACT_RTC_ONLY_S 7 +/** TIMG_LACT_CPST_EN : R/W; bitpos: [8]; default: 1; + * Reserved + */ +#define TIMG_LACT_CPST_EN (BIT(8)) +#define TIMG_LACT_CPST_EN_M (TIMG_LACT_CPST_EN_V << TIMG_LACT_CPST_EN_S) +#define TIMG_LACT_CPST_EN_V 0x00000001U +#define TIMG_LACT_CPST_EN_S 8 +/** TIMG_LACT_LAC_EN : R/W; bitpos: [9]; default: 1; + * Reserved + */ +#define TIMG_LACT_LAC_EN (BIT(9)) +#define TIMG_LACT_LAC_EN_M (TIMG_LACT_LAC_EN_V << TIMG_LACT_LAC_EN_S) +#define TIMG_LACT_LAC_EN_V 0x00000001U +#define TIMG_LACT_LAC_EN_S 9 +/** TIMG_LACT_ALARM_EN : R/W; bitpos: [10]; default: 0; + * Reserved + */ +#define TIMG_LACT_ALARM_EN (BIT(10)) +#define TIMG_LACT_ALARM_EN_M (TIMG_LACT_ALARM_EN_V << TIMG_LACT_ALARM_EN_S) +#define TIMG_LACT_ALARM_EN_V 0x00000001U +#define TIMG_LACT_ALARM_EN_S 10 +/** TIMG_LACT_LEVEL_INT_EN : R/W; bitpos: [11]; default: 0; + * Reserved + */ +#define TIMG_LACT_LEVEL_INT_EN (BIT(11)) +#define TIMG_LACT_LEVEL_INT_EN_M (TIMG_LACT_LEVEL_INT_EN_V << TIMG_LACT_LEVEL_INT_EN_S) +#define TIMG_LACT_LEVEL_INT_EN_V 0x00000001U +#define TIMG_LACT_LEVEL_INT_EN_S 11 +/** TIMG_LACT_EDGE_INT_EN : R/W; bitpos: [12]; default: 0; + * Reserved + */ +#define TIMG_LACT_EDGE_INT_EN (BIT(12)) +#define TIMG_LACT_EDGE_INT_EN_M (TIMG_LACT_EDGE_INT_EN_V << TIMG_LACT_EDGE_INT_EN_S) +#define TIMG_LACT_EDGE_INT_EN_V 0x00000001U +#define TIMG_LACT_EDGE_INT_EN_S 12 +/** TIMG_LACT_DIVIDER : R/W; bitpos: [28:13]; default: 1; + * Reserved + */ +#define TIMG_LACT_DIVIDER 0x0000FFFFU +#define TIMG_LACT_DIVIDER_M (TIMG_LACT_DIVIDER_V << TIMG_LACT_DIVIDER_S) +#define TIMG_LACT_DIVIDER_V 0x0000FFFFU +#define TIMG_LACT_DIVIDER_S 13 +/** TIMG_LACT_AUTORELOAD : R/W; bitpos: [29]; default: 1; + * Reserved + */ +#define TIMG_LACT_AUTORELOAD (BIT(29)) +#define TIMG_LACT_AUTORELOAD_M (TIMG_LACT_AUTORELOAD_V << TIMG_LACT_AUTORELOAD_S) +#define TIMG_LACT_AUTORELOAD_V 0x00000001U +#define TIMG_LACT_AUTORELOAD_S 29 +/** TIMG_LACT_INCREASE : R/W; bitpos: [30]; default: 1; + * Reserved + */ +#define TIMG_LACT_INCREASE (BIT(30)) +#define TIMG_LACT_INCREASE_M (TIMG_LACT_INCREASE_V << TIMG_LACT_INCREASE_S) +#define TIMG_LACT_INCREASE_V 0x00000001U +#define TIMG_LACT_INCREASE_S 30 +/** TIMG_LACT_EN : R/W; bitpos: [31]; default: 0; + * Reserved + */ +#define TIMG_LACT_EN (BIT(31)) +#define TIMG_LACT_EN_M (TIMG_LACT_EN_V << TIMG_LACT_EN_S) +#define TIMG_LACT_EN_V 0x00000001U +#define TIMG_LACT_EN_S 31 -#define TIMG_LACTRTC_REG(i) (REG_TIMG_BASE(i) + 0x0074) -/* TIMG_LACT_RTC_STEP_LEN : R/W ;bitpos:[31:6] ;default: 26'h0 ; */ -/*description: */ -#define TIMG_LACT_RTC_STEP_LEN 0x03FFFFFF -#define TIMG_LACT_RTC_STEP_LEN_M ((TIMG_LACT_RTC_STEP_LEN_V)<<(TIMG_LACT_RTC_STEP_LEN_S)) -#define TIMG_LACT_RTC_STEP_LEN_V 0x3FFFFFF +/** TIMG_LACTRTC_REG register + * LACT RTC register + */ +#define TIMG_LACTRTC_REG(i) (DR_REG_TIMG_BASE(i) + 0x74) +/** TIMG_LACT_RTC_STEP_LEN : R/W; bitpos: [31:6]; default: 0; + * Reserved + */ +#define TIMG_LACT_RTC_STEP_LEN 0x03FFFFFFU +#define TIMG_LACT_RTC_STEP_LEN_M (TIMG_LACT_RTC_STEP_LEN_V << TIMG_LACT_RTC_STEP_LEN_S) +#define TIMG_LACT_RTC_STEP_LEN_V 0x03FFFFFFU #define TIMG_LACT_RTC_STEP_LEN_S 6 -#define TIMG_LACTLO_REG(i) (REG_TIMG_BASE(i) + 0x0078) -/* TIMG_LACT_LO : RO ;bitpos:[31:0] ;default: 32'h0 ; */ -/*description: */ -#define TIMG_LACT_LO 0xFFFFFFFF -#define TIMG_LACT_LO_M ((TIMG_LACT_LO_V)<<(TIMG_LACT_LO_S)) -#define TIMG_LACT_LO_V 0xFFFFFFFF +/** TIMG_LACTLO_REG register + * LACT low register + */ +#define TIMG_LACTLO_REG(i) (DR_REG_TIMG_BASE(i) + 0x78) +/** TIMG_LACT_LO : RO; bitpos: [31:0]; default: 0; + * Reserved + */ +#define TIMG_LACT_LO 0xFFFFFFFFU +#define TIMG_LACT_LO_M (TIMG_LACT_LO_V << TIMG_LACT_LO_S) +#define TIMG_LACT_LO_V 0xFFFFFFFFU #define TIMG_LACT_LO_S 0 -#define TIMG_LACTHI_REG(i) (REG_TIMG_BASE(i) + 0x007c) -/* TIMG_LACT_HI : RO ;bitpos:[31:0] ;default: 32'h0 ; */ -/*description: */ -#define TIMG_LACT_HI 0xFFFFFFFF -#define TIMG_LACT_HI_M ((TIMG_LACT_HI_V)<<(TIMG_LACT_HI_S)) -#define TIMG_LACT_HI_V 0xFFFFFFFF +/** TIMG_LACTHI_REG register + * LACT high register + */ +#define TIMG_LACTHI_REG(i) (DR_REG_TIMG_BASE(i) + 0x7c) +/** TIMG_LACT_HI : RO; bitpos: [31:0]; default: 0; + * Reserved + */ +#define TIMG_LACT_HI 0xFFFFFFFFU +#define TIMG_LACT_HI_M (TIMG_LACT_HI_V << TIMG_LACT_HI_S) +#define TIMG_LACT_HI_V 0xFFFFFFFFU #define TIMG_LACT_HI_S 0 -#define TIMG_LACTUPDATE_REG(i) (REG_TIMG_BASE(i) + 0x0080) -/* TIMG_LACT_UPDATE : WO ;bitpos:[31:0] ;default: 32'h0 ; */ -/*description: */ -#define TIMG_LACT_UPDATE 0xFFFFFFFF -#define TIMG_LACT_UPDATE_M ((TIMG_LACT_UPDATE_V)<<(TIMG_LACT_UPDATE_S)) -#define TIMG_LACT_UPDATE_V 0xFFFFFFFF +/** TIMG_LACTUPDATE_REG register + * LACT update register + */ +#define TIMG_LACTUPDATE_REG(i) (DR_REG_TIMG_BASE(i) + 0x80) +/** TIMG_LACT_UPDATE : WO; bitpos: [31:0]; default: 0; + * Reserved + */ +#define TIMG_LACT_UPDATE 0xFFFFFFFFU +#define TIMG_LACT_UPDATE_M (TIMG_LACT_UPDATE_V << TIMG_LACT_UPDATE_S) +#define TIMG_LACT_UPDATE_V 0xFFFFFFFFU #define TIMG_LACT_UPDATE_S 0 -#define TIMG_LACTALARMLO_REG(i) (REG_TIMG_BASE(i) + 0x0084) -/* TIMG_LACT_ALARM_LO : R/W ;bitpos:[31:0] ;default: 32'h0 ; */ -/*description: */ -#define TIMG_LACT_ALARM_LO 0xFFFFFFFF -#define TIMG_LACT_ALARM_LO_M ((TIMG_LACT_ALARM_LO_V)<<(TIMG_LACT_ALARM_LO_S)) -#define TIMG_LACT_ALARM_LO_V 0xFFFFFFFF +/** TIMG_LACTALARMLO_REG register + * LACT alarm low register + */ +#define TIMG_LACTALARMLO_REG(i) (DR_REG_TIMG_BASE(i) + 0x84) +/** TIMG_LACT_ALARM_LO : R/W; bitpos: [31:0]; default: 0; + * Reserved + */ +#define TIMG_LACT_ALARM_LO 0xFFFFFFFFU +#define TIMG_LACT_ALARM_LO_M (TIMG_LACT_ALARM_LO_V << TIMG_LACT_ALARM_LO_S) +#define TIMG_LACT_ALARM_LO_V 0xFFFFFFFFU #define TIMG_LACT_ALARM_LO_S 0 -#define TIMG_LACTALARMHI_REG(i) (REG_TIMG_BASE(i) + 0x0088) -/* TIMG_LACT_ALARM_HI : R/W ;bitpos:[31:0] ;default: 32'h0 ; */ -/*description: */ -#define TIMG_LACT_ALARM_HI 0xFFFFFFFF -#define TIMG_LACT_ALARM_HI_M ((TIMG_LACT_ALARM_HI_V)<<(TIMG_LACT_ALARM_HI_S)) -#define TIMG_LACT_ALARM_HI_V 0xFFFFFFFF +/** TIMG_LACTALARMHI_REG register + * LACT alarm high register + */ +#define TIMG_LACTALARMHI_REG(i) (DR_REG_TIMG_BASE(i) + 0x88) +/** TIMG_LACT_ALARM_HI : R/W; bitpos: [31:0]; default: 0; + * Reserved + */ +#define TIMG_LACT_ALARM_HI 0xFFFFFFFFU +#define TIMG_LACT_ALARM_HI_M (TIMG_LACT_ALARM_HI_V << TIMG_LACT_ALARM_HI_S) +#define TIMG_LACT_ALARM_HI_V 0xFFFFFFFFU #define TIMG_LACT_ALARM_HI_S 0 -#define TIMG_LACTLOADLO_REG(i) (REG_TIMG_BASE(i) + 0x008c) -/* TIMG_LACT_LOAD_LO : R/W ;bitpos:[31:0] ;default: 32'h0 ; */ -/*description: */ -#define TIMG_LACT_LOAD_LO 0xFFFFFFFF -#define TIMG_LACT_LOAD_LO_M ((TIMG_LACT_LOAD_LO_V)<<(TIMG_LACT_LOAD_LO_S)) -#define TIMG_LACT_LOAD_LO_V 0xFFFFFFFF +/** TIMG_LACTLOADLO_REG register + * LACT load low register + */ +#define TIMG_LACTLOADLO_REG(i) (DR_REG_TIMG_BASE(i) + 0x8c) +/** TIMG_LACT_LOAD_LO : R/W; bitpos: [31:0]; default: 0; + * Reserved + */ +#define TIMG_LACT_LOAD_LO 0xFFFFFFFFU +#define TIMG_LACT_LOAD_LO_M (TIMG_LACT_LOAD_LO_V << TIMG_LACT_LOAD_LO_S) +#define TIMG_LACT_LOAD_LO_V 0xFFFFFFFFU #define TIMG_LACT_LOAD_LO_S 0 -#define TIMG_LACTLOADHI_REG(i) (REG_TIMG_BASE(i) + 0x0090) -/* TIMG_LACT_LOAD_HI : R/W ;bitpos:[31:0] ;default: 32'h0 ; */ -/*description: */ -#define TIMG_LACT_LOAD_HI 0xFFFFFFFF -#define TIMG_LACT_LOAD_HI_M ((TIMG_LACT_LOAD_HI_V)<<(TIMG_LACT_LOAD_HI_S)) -#define TIMG_LACT_LOAD_HI_V 0xFFFFFFFF +/** TIMG_LACTLOADHI_REG register + * Timer LACT load high register + */ +#define TIMG_LACTLOADHI_REG(i) (DR_REG_TIMG_BASE(i) + 0x90) +/** TIMG_LACT_LOAD_HI : R/W; bitpos: [31:0]; default: 0; + * Reserved + */ +#define TIMG_LACT_LOAD_HI 0xFFFFFFFFU +#define TIMG_LACT_LOAD_HI_M (TIMG_LACT_LOAD_HI_V << TIMG_LACT_LOAD_HI_S) +#define TIMG_LACT_LOAD_HI_V 0xFFFFFFFFU #define TIMG_LACT_LOAD_HI_S 0 -#define TIMG_LACTLOAD_REG(i) (REG_TIMG_BASE(i) + 0x0094) -/* TIMG_LACT_LOAD : WO ;bitpos:[31:0] ;default: 32'h0 ; */ -/*description: */ -#define TIMG_LACT_LOAD 0xFFFFFFFF -#define TIMG_LACT_LOAD_M ((TIMG_LACT_LOAD_V)<<(TIMG_LACT_LOAD_S)) -#define TIMG_LACT_LOAD_V 0xFFFFFFFF +/** TIMG_LACTLOAD_REG register + * Timer LACT load register + */ +#define TIMG_LACTLOAD_REG(i) (DR_REG_TIMG_BASE(i) + 0x94) +/** TIMG_LACT_LOAD : WO; bitpos: [31:0]; default: 0; + * Reserved + */ +#define TIMG_LACT_LOAD 0xFFFFFFFFU +#define TIMG_LACT_LOAD_M (TIMG_LACT_LOAD_V << TIMG_LACT_LOAD_S) +#define TIMG_LACT_LOAD_V 0xFFFFFFFFU #define TIMG_LACT_LOAD_S 0 -#define TIMG_INT_ENA_TIMERS_REG(i) (REG_TIMG_BASE(i) + 0x0098) -/* TIMG_LACT_INT_ENA : R/W ;bitpos:[3] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_LACT_INT_ENA (BIT(3)) -#define TIMG_LACT_INT_ENA_M (BIT(3)) -#define TIMG_LACT_INT_ENA_V 0x1 -#define TIMG_LACT_INT_ENA_S 3 -/* TIMG_WDT_INT_ENA : R/W ;bitpos:[2] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_WDT_INT_ENA (BIT(2)) -#define TIMG_WDT_INT_ENA_M (BIT(2)) -#define TIMG_WDT_INT_ENA_V 0x1 -#define TIMG_WDT_INT_ENA_S 2 -/* TIMG_T1_INT_ENA : R/W ;bitpos:[1] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_T1_INT_ENA (BIT(1)) -#define TIMG_T1_INT_ENA_M (BIT(1)) -#define TIMG_T1_INT_ENA_V 0x1 -#define TIMG_T1_INT_ENA_S 1 -/* TIMG_T0_INT_ENA : R/W ;bitpos:[0] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_T0_INT_ENA (BIT(0)) -#define TIMG_T0_INT_ENA_M (BIT(0)) -#define TIMG_T0_INT_ENA_V 0x1 +/** TIMG_INT_ENA_TIMERS_REG register + * Interrupt enable bits + */ +#define TIMG_INT_ENA_TIMERS_REG(i) (DR_REG_TIMG_BASE(i) + 0x98) +/** TIMG_T0_INT_ENA : R/W; bitpos: [0]; default: 0; + * The interrupt enable bit for the TIMG_T0_INT interrupt. + */ +#define TIMG_T0_INT_ENA (BIT(0)) +#define TIMG_T0_INT_ENA_M (TIMG_T0_INT_ENA_V << TIMG_T0_INT_ENA_S) +#define TIMG_T0_INT_ENA_V 0x00000001U #define TIMG_T0_INT_ENA_S 0 +/** TIMG_T1_INT_ENA : R/W; bitpos: [1]; default: 0; + * The interrupt enable bit for the TIMG_T1_INT interrupt. + */ +#define TIMG_T1_INT_ENA (BIT(1)) +#define TIMG_T1_INT_ENA_M (TIMG_T1_INT_ENA_V << TIMG_T1_INT_ENA_S) +#define TIMG_T1_INT_ENA_V 0x00000001U +#define TIMG_T1_INT_ENA_S 1 +/** TIMG_WDT_INT_ENA : R/W; bitpos: [2]; default: 0; + * The interrupt enable bit for the TIMG_WDT_INT interrupt. + */ +#define TIMG_WDT_INT_ENA (BIT(2)) +#define TIMG_WDT_INT_ENA_M (TIMG_WDT_INT_ENA_V << TIMG_WDT_INT_ENA_S) +#define TIMG_WDT_INT_ENA_V 0x00000001U +#define TIMG_WDT_INT_ENA_S 2 +/** TIMG_LACT_INT_ENA : R/W; bitpos: [3]; default: 0; + * The interrupt enable bit for the TIMG_LACT_INT interrupt. + */ +#define TIMG_LACT_INT_ENA (BIT(3)) +#define TIMG_LACT_INT_ENA_M (TIMG_LACT_INT_ENA_V << TIMG_LACT_INT_ENA_S) +#define TIMG_LACT_INT_ENA_V 0x00000001U +#define TIMG_LACT_INT_ENA_S 3 -#define TIMG_INT_RAW_TIMERS_REG(i) (REG_TIMG_BASE(i) + 0x009c) -/* TIMG_LACT_INT_RAW : RO ;bitpos:[3] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_LACT_INT_RAW (BIT(3)) -#define TIMG_LACT_INT_RAW_M (BIT(3)) -#define TIMG_LACT_INT_RAW_V 0x1 -#define TIMG_LACT_INT_RAW_S 3 -/* TIMG_WDT_INT_RAW : RO ;bitpos:[2] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_WDT_INT_RAW (BIT(2)) -#define TIMG_WDT_INT_RAW_M (BIT(2)) -#define TIMG_WDT_INT_RAW_V 0x1 -#define TIMG_WDT_INT_RAW_S 2 -/* TIMG_T1_INT_RAW : RO ;bitpos:[1] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_T1_INT_RAW (BIT(1)) -#define TIMG_T1_INT_RAW_M (BIT(1)) -#define TIMG_T1_INT_RAW_V 0x1 -#define TIMG_T1_INT_RAW_S 1 -/* TIMG_T0_INT_RAW : RO ;bitpos:[0] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_T0_INT_RAW (BIT(0)) -#define TIMG_T0_INT_RAW_M (BIT(0)) -#define TIMG_T0_INT_RAW_V 0x1 +/** TIMG_INT_RAW_TIMERS_REG register + * Raw interrupt status + */ +#define TIMG_INT_RAW_TIMERS_REG(i) (DR_REG_TIMG_BASE(i) + 0x9c) +/** TIMG_T0_INT_RAW : RO; bitpos: [0]; default: 0; + * The raw interrupt status bit for the TIMG_T0_INT interrupt. + */ +#define TIMG_T0_INT_RAW (BIT(0)) +#define TIMG_T0_INT_RAW_M (TIMG_T0_INT_RAW_V << TIMG_T0_INT_RAW_S) +#define TIMG_T0_INT_RAW_V 0x00000001U #define TIMG_T0_INT_RAW_S 0 +/** TIMG_T1_INT_RAW : RO; bitpos: [1]; default: 0; + * The raw interrupt status bit for the TIMG_T1_INT interrupt. + */ +#define TIMG_T1_INT_RAW (BIT(1)) +#define TIMG_T1_INT_RAW_M (TIMG_T1_INT_RAW_V << TIMG_T1_INT_RAW_S) +#define TIMG_T1_INT_RAW_V 0x00000001U +#define TIMG_T1_INT_RAW_S 1 +/** TIMG_WDT_INT_RAW : RO; bitpos: [2]; default: 0; + * The raw interrupt status bit for the TIMG_WDT_INT interrupt. + */ +#define TIMG_WDT_INT_RAW (BIT(2)) +#define TIMG_WDT_INT_RAW_M (TIMG_WDT_INT_RAW_V << TIMG_WDT_INT_RAW_S) +#define TIMG_WDT_INT_RAW_V 0x00000001U +#define TIMG_WDT_INT_RAW_S 2 +/** TIMG_LACT_INT_RAW : RO; bitpos: [3]; default: 0; + * The raw interrupt status bit for the TIMG_LACT_INT interrupt. + */ +#define TIMG_LACT_INT_RAW (BIT(3)) +#define TIMG_LACT_INT_RAW_M (TIMG_LACT_INT_RAW_V << TIMG_LACT_INT_RAW_S) +#define TIMG_LACT_INT_RAW_V 0x00000001U +#define TIMG_LACT_INT_RAW_S 3 -#define TIMG_INT_ST_TIMERS_REG(i) (REG_TIMG_BASE(i) + 0x00a0) -/* TIMG_LACT_INT_ST : RO ;bitpos:[3] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_LACT_INT_ST (BIT(3)) -#define TIMG_LACT_INT_ST_M (BIT(3)) -#define TIMG_LACT_INT_ST_V 0x1 -#define TIMG_LACT_INT_ST_S 3 -/* TIMG_WDT_INT_ST : RO ;bitpos:[2] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_WDT_INT_ST (BIT(2)) -#define TIMG_WDT_INT_ST_M (BIT(2)) -#define TIMG_WDT_INT_ST_V 0x1 -#define TIMG_WDT_INT_ST_S 2 -/* TIMG_T1_INT_ST : RO ;bitpos:[1] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_T1_INT_ST (BIT(1)) -#define TIMG_T1_INT_ST_M (BIT(1)) -#define TIMG_T1_INT_ST_V 0x1 -#define TIMG_T1_INT_ST_S 1 -/* TIMG_T0_INT_ST : RO ;bitpos:[0] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_T0_INT_ST (BIT(0)) -#define TIMG_T0_INT_ST_M (BIT(0)) -#define TIMG_T0_INT_ST_V 0x1 +/** TIMG_INT_ST_TIMERS_REG register + * Masked interrupt status + */ +#define TIMG_INT_ST_TIMERS_REG(i) (DR_REG_TIMG_BASE(i) + 0xa0) +/** TIMG_T0_INT_ST : RO; bitpos: [0]; default: 0; + * The masked interrupt status bit for the TIMG_T0_INT interrupt. + */ +#define TIMG_T0_INT_ST (BIT(0)) +#define TIMG_T0_INT_ST_M (TIMG_T0_INT_ST_V << TIMG_T0_INT_ST_S) +#define TIMG_T0_INT_ST_V 0x00000001U #define TIMG_T0_INT_ST_S 0 +/** TIMG_T1_INT_ST : RO; bitpos: [1]; default: 0; + * The masked interrupt status bit for the TIMG_T1_INT interrupt. + */ +#define TIMG_T1_INT_ST (BIT(1)) +#define TIMG_T1_INT_ST_M (TIMG_T1_INT_ST_V << TIMG_T1_INT_ST_S) +#define TIMG_T1_INT_ST_V 0x00000001U +#define TIMG_T1_INT_ST_S 1 +/** TIMG_WDT_INT_ST : RO; bitpos: [2]; default: 0; + * The masked interrupt status bit for the TIMG_WDT_INT interrupt. + */ +#define TIMG_WDT_INT_ST (BIT(2)) +#define TIMG_WDT_INT_ST_M (TIMG_WDT_INT_ST_V << TIMG_WDT_INT_ST_S) +#define TIMG_WDT_INT_ST_V 0x00000001U +#define TIMG_WDT_INT_ST_S 2 +/** TIMG_LACT_INT_ST : RO; bitpos: [3]; default: 0; + * The masked interrupt status bit for the TIMG_LACT_INT interrupt. + */ +#define TIMG_LACT_INT_ST (BIT(3)) +#define TIMG_LACT_INT_ST_M (TIMG_LACT_INT_ST_V << TIMG_LACT_INT_ST_S) +#define TIMG_LACT_INT_ST_V 0x00000001U +#define TIMG_LACT_INT_ST_S 3 -#define TIMG_INT_CLR_TIMERS_REG(i) (REG_TIMG_BASE(i) + 0x00a4) -/* TIMG_LACT_INT_CLR : WO ;bitpos:[3] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_LACT_INT_CLR (BIT(3)) -#define TIMG_LACT_INT_CLR_M (BIT(3)) -#define TIMG_LACT_INT_CLR_V 0x1 -#define TIMG_LACT_INT_CLR_S 3 -/* TIMG_WDT_INT_CLR : WO ;bitpos:[2] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_WDT_INT_CLR (BIT(2)) -#define TIMG_WDT_INT_CLR_M (BIT(2)) -#define TIMG_WDT_INT_CLR_V 0x1 -#define TIMG_WDT_INT_CLR_S 2 -/* TIMG_T1_INT_CLR : WO ;bitpos:[1] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_T1_INT_CLR (BIT(1)) -#define TIMG_T1_INT_CLR_M (BIT(1)) -#define TIMG_T1_INT_CLR_V 0x1 -#define TIMG_T1_INT_CLR_S 1 -/* TIMG_T0_INT_CLR : WO ;bitpos:[0] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_T0_INT_CLR (BIT(0)) -#define TIMG_T0_INT_CLR_M (BIT(0)) -#define TIMG_T0_INT_CLR_V 0x1 +/** TIMG_INT_CLR_TIMERS_REG register + * Interrupt clear bits + */ +#define TIMG_INT_CLR_TIMERS_REG(i) (DR_REG_TIMG_BASE(i) + 0xa4) +/** TIMG_T0_INT_CLR : WO; bitpos: [0]; default: 0; + * Set this bit to clear the TIMG_T0_INT interrupt. + */ +#define TIMG_T0_INT_CLR (BIT(0)) +#define TIMG_T0_INT_CLR_M (TIMG_T0_INT_CLR_V << TIMG_T0_INT_CLR_S) +#define TIMG_T0_INT_CLR_V 0x00000001U #define TIMG_T0_INT_CLR_S 0 +/** TIMG_T1_INT_CLR : WO; bitpos: [1]; default: 0; + * Set this bit to clear the TIMG_T1_INT interrupt. + */ +#define TIMG_T1_INT_CLR (BIT(1)) +#define TIMG_T1_INT_CLR_M (TIMG_T1_INT_CLR_V << TIMG_T1_INT_CLR_S) +#define TIMG_T1_INT_CLR_V 0x00000001U +#define TIMG_T1_INT_CLR_S 1 +/** TIMG_WDT_INT_CLR : WO; bitpos: [2]; default: 0; + * Set this bit to clear the TIMG_WDT_INT interrupt. + */ +#define TIMG_WDT_INT_CLR (BIT(2)) +#define TIMG_WDT_INT_CLR_M (TIMG_WDT_INT_CLR_V << TIMG_WDT_INT_CLR_S) +#define TIMG_WDT_INT_CLR_V 0x00000001U +#define TIMG_WDT_INT_CLR_S 2 +/** TIMG_LACT_INT_CLR : WO; bitpos: [3]; default: 0; + * Set this bit to clear the TIMG_LACT_INT interrupt. + */ +#define TIMG_LACT_INT_CLR (BIT(3)) +#define TIMG_LACT_INT_CLR_M (TIMG_LACT_INT_CLR_V << TIMG_LACT_INT_CLR_S) +#define TIMG_LACT_INT_CLR_V 0x00000001U +#define TIMG_LACT_INT_CLR_S 3 -#define TIMG_RTCCALICFG2_REG(i) (REG_TIMG_BASE(i) + 0x00a8) -/* TIMG_RTC_CALI_TIMEOUT_THRES : R/W ;bitpos:[31:7] ;default: 25'h1ffffff ; */ -/*description: timeout if cali value counts over threshold*/ -#define TIMG_RTC_CALI_TIMEOUT_THRES 0x01FFFFFF -#define TIMG_RTC_CALI_TIMEOUT_THRES_M ((TIMG_RTC_CALI_TIMEOUT_THRES_V)<<(TIMG_RTC_CALI_TIMEOUT_THRES_S)) -#define TIMG_RTC_CALI_TIMEOUT_THRES_V 0x1FFFFFF -#define TIMG_RTC_CALI_TIMEOUT_THRES_S 7 -/* TIMG_RTC_CALI_TIMEOUT_RST_CNT : R/W ;bitpos:[6:3] ;default: 4'd3 ; */ -/*description: Cycles that release calibration timeout reset*/ -#define TIMG_RTC_CALI_TIMEOUT_RST_CNT 0x0000000F -#define TIMG_RTC_CALI_TIMEOUT_RST_CNT_M ((TIMG_RTC_CALI_TIMEOUT_RST_CNT_V)<<(TIMG_RTC_CALI_TIMEOUT_RST_CNT_S)) -#define TIMG_RTC_CALI_TIMEOUT_RST_CNT_V 0xF -#define TIMG_RTC_CALI_TIMEOUT_RST_CNT_S 3 -/* TIMG_RTC_CALI_TIMEOUT : RO ;bitpos:[0] ;default: 1'h0 ; */ -/*description: timeout indicator*/ -#define TIMG_RTC_CALI_TIMEOUT (BIT(0)) -#define TIMG_RTC_CALI_TIMEOUT_M (BIT(0)) -#define TIMG_RTC_CALI_TIMEOUT_V 0x1 +/** TIMG_RTCCALICFG2_REG register + * Timer group calibration register + */ +#define TIMG_RTCCALICFG2_REG(i) (DR_REG_TIMG_BASE(i) + 0xa8) +/** TIMG_RTC_CALI_TIMEOUT : RO; bitpos: [0]; default: 0; + * RTC calibration timeout indicator + */ +#define TIMG_RTC_CALI_TIMEOUT (BIT(0)) +#define TIMG_RTC_CALI_TIMEOUT_M (TIMG_RTC_CALI_TIMEOUT_V << TIMG_RTC_CALI_TIMEOUT_S) +#define TIMG_RTC_CALI_TIMEOUT_V 0x00000001U #define TIMG_RTC_CALI_TIMEOUT_S 0 +/** TIMG_RTC_CALI_TIMEOUT_RST_CNT : R/W; bitpos: [6:3]; default: 3; + * Cycles that release calibration timeout reset + */ +#define TIMG_RTC_CALI_TIMEOUT_RST_CNT 0x0000000FU +#define TIMG_RTC_CALI_TIMEOUT_RST_CNT_M (TIMG_RTC_CALI_TIMEOUT_RST_CNT_V << TIMG_RTC_CALI_TIMEOUT_RST_CNT_S) +#define TIMG_RTC_CALI_TIMEOUT_RST_CNT_V 0x0000000FU +#define TIMG_RTC_CALI_TIMEOUT_RST_CNT_S 3 +/** TIMG_RTC_CALI_TIMEOUT_THRES : R/W; bitpos: [31:7]; default: 33554431; + * Threshold value for the RTC calibration timer. If the calibration timer's value + * exceeds this threshold, a timeout is triggered. + */ +#define TIMG_RTC_CALI_TIMEOUT_THRES 0x01FFFFFFU +#define TIMG_RTC_CALI_TIMEOUT_THRES_M (TIMG_RTC_CALI_TIMEOUT_THRES_V << TIMG_RTC_CALI_TIMEOUT_THRES_S) +#define TIMG_RTC_CALI_TIMEOUT_THRES_V 0x01FFFFFFU +#define TIMG_RTC_CALI_TIMEOUT_THRES_S 7 -#define TIMG_NTIMERS_DATE_REG(i) (REG_TIMG_BASE(i) + 0x00f8) -/* TIMG_NTIMERS_DATE : R/W ;bitpos:[27:0] ;default: 28'h1810190 ; */ -/*description: */ -#define TIMG_NTIMERS_DATE 0x0FFFFFFF -#define TIMG_NTIMERS_DATE_M ((TIMG_NTIMERS_DATE_V)<<(TIMG_NTIMERS_DATE_S)) -#define TIMG_NTIMERS_DATE_V 0xFFFFFFF -#define TIMG_NTIMERS_DATE_S 0 - -#define TIMG_CLK_REG(i) (REG_TIMG_BASE(i) + 0x00fc) -/* TIMG_CLK_EN : R/W ;bitpos:[31] ;default: 1'h0 ; */ -/*description: */ -#define TIMG_CLK_EN (BIT(31)) -#define TIMG_CLK_EN_M (BIT(31)) -#define TIMG_CLK_EN_V 0x1 +/** TIMG_TIMERS_DATE_REG register + * Version control register + */ +#define TIMG_TIMERS_DATE_REG(i) (DR_REG_TIMG_BASE(i) + 0xf8) +/** TIMG_TIMERS_DATE : R/W; bitpos: [27:0]; default: 26243681; + * Version control register. + */ +#define TIMG_TIMERS_DATE 0x0FFFFFFFU +#define TIMG_TIMERS_DATE_M (TIMG_TIMERS_DATE_V << TIMG_TIMERS_DATE_S) +#define TIMG_TIMERS_DATE_V 0x0FFFFFFFU +#define TIMG_TIMERS_DATE_S 0 + +/** TIMG_REGCLK_REG register + * Timer group clock gate register + */ +#define TIMG_REGCLK_REG(i) (DR_REG_TIMG_BASE(i) + 0xfc) +/** TIMG_CLK_EN : R/W; bitpos: [31]; default: 0; + * Register clock gate signal. 1: Registers can be read and written to by software. 0: + * Registers can not be read or written to by software. + */ +#define TIMG_CLK_EN (BIT(31)) +#define TIMG_CLK_EN_M (TIMG_CLK_EN_V << TIMG_CLK_EN_S) +#define TIMG_CLK_EN_V 0x00000001U #define TIMG_CLK_EN_S 31 #ifdef __cplusplus } #endif - - - -#endif /*_SOC_TIMG_REG_H_ */ diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/timer_group_struct.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/timer_group_struct.h index 55d6befeae9..d4bb5ebe634 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/timer_group_struct.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/timer_group_struct.h @@ -1,225 +1,789 @@ -// Copyright 2017-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. -#ifndef _SOC_TIMG_STRUCT_H_ -#define _SOC_TIMG_STRUCT_H_ +/** + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#pragma once #include - #ifdef __cplusplus extern "C" { #endif -typedef volatile struct { - struct { - union { - struct { - uint32_t reserved0: 9; - uint32_t use_xtal: 1; - uint32_t alarm_en: 1; - uint32_t level_int_en: 1; - uint32_t edge_int_en: 1; - uint32_t divider: 16; - uint32_t autoreload: 1; - uint32_t increase: 1; - uint32_t enable: 1; - }; - uint32_t val; - } config; - uint32_t cnt_low; /**/ - uint32_t cnt_high; /**/ - union { - struct { - uint32_t reserved0: 31; - uint32_t update: 1; - }; - uint32_t val; - } update; - uint32_t alarm_low; /**/ - uint32_t alarm_high; /**/ - uint32_t load_low; /**/ - uint32_t load_high; /**/ - uint32_t reload; /**/ - } hw_timer[2]; - union { - struct { - uint32_t reserved0: 12; - uint32_t appcpu_reset_en: 1; - uint32_t procpu_reset_en: 1; - uint32_t flashboot_mod_en: 1; - uint32_t sys_reset_length: 3; - uint32_t cpu_reset_length: 3; - uint32_t level_int_en: 1; - uint32_t edge_int_en: 1; - uint32_t stg3: 2; - uint32_t stg2: 2; - uint32_t stg1: 2; - uint32_t stg0: 2; - uint32_t en: 1; - }; - uint32_t val; - } wdt_config0; - union { - struct { - uint32_t reserved0: 16; - uint32_t clk_prescale: 16; - }; - uint32_t val; - } wdt_config1; - uint32_t wdt_config2; /**/ - uint32_t wdt_config3; /**/ - uint32_t wdt_config4; /**/ - uint32_t wdt_config5; /**/ - uint32_t wdt_feed; /**/ - uint32_t wdt_wprotect; /**/ - union { - struct { - uint32_t reserved0: 12; - uint32_t start_cycling: 1; - uint32_t clk_sel: 2; - uint32_t rdy: 1; - uint32_t max: 15; - uint32_t start: 1; - }; - uint32_t val; - } rtc_cali_cfg; - union { - struct { - uint32_t cycling_data_vld: 1; - uint32_t reserved1: 6; - uint32_t value: 25; - }; - uint32_t val; - } rtc_cali_cfg1; - union { - struct { - uint32_t reserved0: 6; - uint32_t use_reftick: 1; - uint32_t rtc_only: 1; - uint32_t cpst_en: 1; - uint32_t lac_en: 1; - uint32_t alarm_en: 1; - uint32_t level_int_en: 1; - uint32_t edge_int_en: 1; - uint32_t divider: 16; - uint32_t autoreload: 1; - uint32_t increase: 1; - uint32_t en: 1; - }; - uint32_t val; - } lactconfig; - union { - struct { - uint32_t reserved0: 6; - uint32_t step_len: 26; - }; - uint32_t val; - } lactrtc; - uint32_t lactlo; /**/ - uint32_t lacthi; /**/ - uint32_t lactupdate; /**/ - uint32_t lactalarmlo; /**/ - uint32_t lactalarmhi; /**/ - uint32_t lactloadlo; /**/ - uint32_t lactloadhi; /**/ - uint32_t lactload; /**/ - union { - struct { - uint32_t t0: 1; - uint32_t t1: 1; - uint32_t wdt: 1; - uint32_t lact: 1; - uint32_t reserved4: 28; - }; - uint32_t val; - } int_ena; - union { - struct { - uint32_t t0: 1; - uint32_t t1: 1; - uint32_t wdt: 1; - uint32_t lact: 1; - uint32_t reserved4: 28; - }; - uint32_t val; - } int_raw; - union { - struct { - uint32_t t0: 1; - uint32_t t1: 1; - uint32_t wdt: 1; - uint32_t lact: 1; - uint32_t reserved4: 28; - }; - uint32_t val; - } int_st; - union { - struct { - uint32_t t0: 1; - uint32_t t1: 1; - uint32_t wdt: 1; - uint32_t lact: 1; - uint32_t reserved4: 28; - }; - uint32_t val; - } int_clr; - union { - struct { - uint32_t timeout: 1; /*timeout indicator*/ - uint32_t reserved1: 2; - uint32_t timeout_rst_cnt: 4; /*Cycles that release calibration timeout reset*/ - uint32_t timeout_thres: 25; /*timeout if cali value counts over threshold*/ - }; - uint32_t val; - } rtc_cali_cfg2; - uint32_t reserved_ac; - uint32_t reserved_b0; - uint32_t reserved_b4; - uint32_t reserved_b8; - uint32_t reserved_bc; - uint32_t reserved_c0; - uint32_t reserved_c4; - uint32_t reserved_c8; - uint32_t reserved_cc; - uint32_t reserved_d0; - uint32_t reserved_d4; - uint32_t reserved_d8; - uint32_t reserved_dc; - uint32_t reserved_e0; - uint32_t reserved_e4; - uint32_t reserved_e8; - uint32_t reserved_ec; - uint32_t reserved_f0; - uint32_t reserved_f4; - union { - struct { - uint32_t date: 28; - uint32_t reserved28: 4; - }; - uint32_t val; - } timg_date; - union { - struct { - uint32_t reserved0: 31; - uint32_t en: 1; - }; - uint32_t val; - } clk; +/** Group: Configuration and Control Register */ +/** Type of txconfig register + * Timer x configuration register + */ +typedef union { + struct { + uint32_t reserved_0:9; + /** tx_use_xtal : R/W; bitpos: [9]; default: 0; + * 1: Use XTAL_CLK as the source clock of timer group. 0: Use APB_CLK as the source + * clock of timer group. + */ + uint32_t tx_use_xtal:1; + /** tx_alarm_en : R/W; bitpos: [10]; default: 0; + * When set, the alarm is enabled. This bit is automatically cleared once an + * + * alarm occurs. + */ + uint32_t tx_alarm_en:1; + /** tx_level_int_en : R/W; bitpos: [11]; default: 0; + * When set, an alarm will generate a level type interrupt. + */ + uint32_t tx_level_int_en:1; + /** tx_edge_int_en : R/W; bitpos: [12]; default: 0; + * When set, an alarm will generate an edge type interrupt. + */ + uint32_t tx_edge_int_en:1; + /** tx_divider : R/W; bitpos: [28:13]; default: 1; + * Timer x clock (Tx_clk) prescaler value. + */ + uint32_t tx_divider:16; + /** tx_autoreload : R/W; bitpos: [29]; default: 1; + * When set, timer x auto-reload at alarm is enabled. + */ + uint32_t tx_autoreload:1; + /** tx_increase : R/W; bitpos: [30]; default: 1; + * When set, the timer x time-base counter will increment every clock tick. When + * + * cleared, the timer x time-base counter will decrement. + */ + uint32_t tx_increase:1; + /** tx_en : R/W; bitpos: [31]; default: 0; + * When set, the timer x time-base counter is enabled. + */ + uint32_t tx_en:1; + }; + uint32_t val; +} timg_txconfig_reg_t; + +/** Type of txlo register + * Timer x current value, low 32 bits + */ +typedef union { + struct { + /** tx_lo : RO; bitpos: [31:0]; default: 0; + * After writing to TIMG_TxUPDATE_REG, the low 32 bits of the time-base counter + * + * of timer x can be read here. + */ + uint32_t tx_lo:32; + }; + uint32_t val; +} timg_txlo_reg_t; + +/** Type of txhi register + * Timer x current value, high 32 bits + */ +typedef union { + struct { + /** tx_hi : RO; bitpos: [31:0]; default: 0; + * After writing to TIMG_TxUPDATE_REG, the high 32 bits of the time-base counter + * + * of timer x can be read here. + */ + uint32_t tx_hi:32; + }; + uint32_t val; +} timg_txhi_reg_t; + +/** Type of txupdate register + * Write to copy current timer value to TIMGn_Tx_(LO/HI)_REG + */ +typedef union { + struct { + uint32_t reserved_0:31; + /** tx_update : R/W; bitpos: [31]; default: 0; + * After writing 0 or 1 to TIMG_TxUPDATE_REG, the counter value is latched. + */ + uint32_t tx_update:1; + }; + uint32_t val; +} timg_txupdate_reg_t; + +/** Type of txalarmlo register + * Timer x alarm value, low 32 bits + */ +typedef union { + struct { + /** tx_alarm_lo : R/W; bitpos: [31:0]; default: 0; + * Timer x alarm trigger time-base counter value, low 32 bits. + */ + uint32_t tx_alarm_lo:32; + }; + uint32_t val; +} timg_txalarmlo_reg_t; + +/** Type of txalarmhi register + * Timer x alarm value, high bits + */ +typedef union { + struct { + /** tx_alarm_hi : R/W; bitpos: [31:0]; default: 0; + * + * + * Timer x alarm trigger time-base counter value, high 32 bits. + */ + uint32_t tx_alarm_hi:32; + }; + uint32_t val; +} timg_txalarmhi_reg_t; + +/** Type of txloadlo register + * Timer x reload value, low 32 bits + */ +typedef union { + struct { + /** tx_load_lo : R/W; bitpos: [31:0]; default: 0; + * + * + * Low 32 bits of the value that a reload will load onto timer x time-base + * + * Counter. + */ + uint32_t tx_load_lo:32; + }; + uint32_t val; +} timg_txloadlo_reg_t; + +/** Type of txloadhi register + * Timer x reload value, high 32 bits + */ +typedef union { + struct { + /** tx_load_hi : R/W; bitpos: [31:0]; default: 0; + * + * + * High 32 bits of the value that a reload will load onto timer x time-base + * + * counter. + */ + uint32_t tx_load_hi:32; + }; + uint32_t val; +} timg_txloadhi_reg_t; + +/** Type of txload register + * Write to reload timer from TIMG_T0_(LOADLOLOADHI)_REG + */ +typedef union { + struct { + /** tx_load : WO; bitpos: [31:0]; default: 0; + * + * + * Write any value to trigger a timer x time-base counter reload. + */ + uint32_t tx_load:32; + }; + uint32_t val; +} timg_txload_reg_t; + + +/** Group: Configuration and Control Register for WDT */ +/** Type of wdtconfig0 register + * Watchdog timer configuration register + */ +typedef union { + struct { + uint32_t reserved_0:12; + /** wdt_appcpu_reset_en : R/W; bitpos: [12]; default: 0; + * Reserved + */ + uint32_t wdt_appcpu_reset_en:1; + /** wdt_procpu_reset_en : R/W; bitpos: [13]; default: 0; + * WDT reset CPU enable. + */ + uint32_t wdt_procpu_reset_en:1; + /** wdt_flashboot_mod_en : R/W; bitpos: [14]; default: 1; + * When set, Flash boot protection is enabled. + */ + uint32_t wdt_flashboot_mod_en:1; + /** wdt_sys_reset_length : R/W; bitpos: [17:15]; default: 1; + * System reset signal length selection. 0: 100 ns, 1: 200 ns, + * + * 2: 300 ns, 3: 400 ns, 4: 500 ns, 5: 800 ns, 6: 1.6 us, 7: 3.2 us. + */ + uint32_t wdt_sys_reset_length:3; + /** wdt_cpu_reset_length : R/W; bitpos: [20:18]; default: 1; + * CPU reset signal length selection. 0: 100 ns, 1: 200 ns, + * + * 2: 300 ns, 3: 400 ns, 4: 500 ns, 5: 800 ns, 6: 1.6 us, 7: 3.2 us. + */ + uint32_t wdt_cpu_reset_length:3; + /** wdt_level_int_en : R/W; bitpos: [21]; default: 0; + * When set, a level type interrupt will occur at the timeout of a stage + * + * configured to generate an interrupt. + */ + uint32_t wdt_level_int_en:1; + /** wdt_edge_int_en : R/W; bitpos: [22]; default: 0; + * When set, an edge type interrupt will occur at the timeout of a stage + * + * configured to generate an interrupt. + */ + uint32_t wdt_edge_int_en:1; + /** wdt_stg3 : R/W; bitpos: [24:23]; default: 0; + * Stage 3 configuration. 0: off, 1: interrupt, 2: reset CPU, 3: reset system. + * + */ + uint32_t wdt_stg3:2; + /** wdt_stg2 : R/W; bitpos: [26:25]; default: 0; + * Stage 2 configuration. 0: off, 1: interrupt, 2: reset CPU, 3: reset system. + * + */ + uint32_t wdt_stg2:2; + /** wdt_stg1 : R/W; bitpos: [28:27]; default: 0; + * Stage 1 configuration. 0: off, 1: interrupt, 2: reset CPU, 3: reset system. + * + */ + uint32_t wdt_stg1:2; + /** wdt_stg0 : R/W; bitpos: [30:29]; default: 0; + * Stage 0 configuration. 0: off, 1: interrupt, 2: reset CPU, 3: reset system. + * + */ + uint32_t wdt_stg0:2; + /** wdt_en : R/W; bitpos: [31]; default: 0; + * When set, MWDT is enabled. + */ + uint32_t wdt_en:1; + }; + uint32_t val; +} timg_wdtconfig0_reg_t; + +/** Type of wdtconfig1 register + * Watchdog timer prescaler register + */ +typedef union { + struct { + uint32_t reserved_0:16; + /** wdt_clk_prescaler : R/W; bitpos: [31:16]; default: 1; + * MWDT clock prescaler value. MWDT clock period = 12.5 ns * + * + * TIMG_WDT_CLK_PRESCALE. + */ + uint32_t wdt_clk_prescaler:16; + }; + uint32_t val; +} timg_wdtconfig1_reg_t; + +/** Type of wdtconfig2 register + * Watchdog timer stage 0 timeout value + */ +typedef union { + struct { + /** wdt_stg0_hold : R/W; bitpos: [31:0]; default: 26000000; + * Stage 0 timeout value, in MWDT clock cycles. + */ + uint32_t wdt_stg0_hold:32; + }; + uint32_t val; +} timg_wdtconfig2_reg_t; + +/** Type of wdtconfig3 register + * Watchdog timer stage 1 timeout value + */ +typedef union { + struct { + /** wdt_stg1_hold : R/W; bitpos: [31:0]; default: 134217727; + * Stage 1 timeout value, in MWDT clock cycles. + */ + uint32_t wdt_stg1_hold:32; + }; + uint32_t val; +} timg_wdtconfig3_reg_t; + +/** Type of wdtconfig4 register + * Watchdog timer stage 2 timeout value + */ +typedef union { + struct { + /** wdt_stg2_hold : R/W; bitpos: [31:0]; default: 1048575; + * Stage 2 timeout value, in MWDT clock cycles. + */ + uint32_t wdt_stg2_hold:32; + }; + uint32_t val; +} timg_wdtconfig4_reg_t; + +/** Type of wdtconfig5 register + * Watchdog timer stage 3 timeout value + */ +typedef union { + struct { + /** wdt_stg3_hold : R/W; bitpos: [31:0]; default: 1048575; + * Stage 3 timeout value, in MWDT clock cycles. + */ + uint32_t wdt_stg3_hold:32; + }; + uint32_t val; +} timg_wdtconfig5_reg_t; + +/** Type of wdtfeed register + * Write to feed the watchdog timer + */ +typedef union { + struct { + /** wdt_feed : WO; bitpos: [31:0]; default: 0; + * Write any value to feed the MWDT. (WO) + */ + uint32_t wdt_feed:32; + }; + uint32_t val; +} timg_wdtfeed_reg_t; + +/** Type of wdtwprotect register + * Watchdog write protect register + */ +typedef union { + struct { + /** wdt_wkey : R/W; bitpos: [31:0]; default: 1356348065; + * If the register contains a different value than its reset value, write + * + * protection is enabled. + */ + uint32_t wdt_wkey:32; + }; + uint32_t val; +} timg_wdtwprotect_reg_t; + + +/** Group: Configuration and Control Register for RTC CALI */ +/** Type of rtccalicfg register + * RTC calibration configuration register + */ +typedef union { + struct { + uint32_t reserved_0:12; + /** rtc_cali_start_cycling : R/W; bitpos: [12]; default: 1; + * Reserved + */ + uint32_t rtc_cali_start_cycling:1; + /** rtc_cali_clk_sel : R/W; bitpos: [14:13]; default: 1; + * 0:rtcslowclock. 1:clk_80m. 2:xtal_32k. + */ + uint32_t rtc_cali_clk_sel:2; + /** rtc_cali_rdy : RO; bitpos: [15]; default: 0; + * Reserved + */ + uint32_t rtc_cali_rdy:1; + /** rtc_cali_max : R/W; bitpos: [30:16]; default: 1; + * Reserved + */ + uint32_t rtc_cali_max:15; + /** rtc_cali_start : R/W; bitpos: [31]; default: 0; + * Reserved + */ + uint32_t rtc_cali_start:1; + }; + uint32_t val; +} timg_rtccalicfg_reg_t; + +/** Type of rtccalicfg1 register + * RTC calibration configuration1 register + */ +typedef union { + struct { + /** rtc_cali_cycling_data_vld : RO; bitpos: [0]; default: 0; + * Reserved + */ + uint32_t rtc_cali_cycling_data_vld:1; + uint32_t reserved_1:6; + /** rtc_cali_value : RO; bitpos: [31:7]; default: 0; + * Reserved + */ + uint32_t rtc_cali_value:25; + }; + uint32_t val; +} timg_rtccalicfg1_reg_t; + +/** Type of rtccalicfg2 register + * Timer group calibration register + */ +typedef union { + struct { + /** rtc_cali_timeout : RO; bitpos: [0]; default: 0; + * RTC calibration timeout indicator + */ + uint32_t rtc_cali_timeout:1; + uint32_t reserved_1:2; + /** rtc_cali_timeout_rst_cnt : R/W; bitpos: [6:3]; default: 3; + * Cycles that release calibration timeout reset + */ + uint32_t rtc_cali_timeout_rst_cnt:4; + /** rtc_cali_timeout_thres : R/W; bitpos: [31:7]; default: 33554431; + * Threshold value for the RTC calibration timer. If the calibration timer's value + * exceeds this threshold, a timeout is triggered. + */ + uint32_t rtc_cali_timeout_thres:25; + }; + uint32_t val; +} timg_rtccalicfg2_reg_t; + + +/** Group: Configuration and Control Register for LACT */ +/** Type of lactconfig register + * LACT configuration register + */ +typedef union { + struct { + uint32_t reserved_0:6; + /** lact_use_reftick : R/W; bitpos: [6]; default: 0; + * Reserved + */ + uint32_t lact_use_reftick:1; + /** lact_rtc_only : R/W; bitpos: [7]; default: 0; + * Reserved + */ + uint32_t lact_rtc_only:1; + /** lact_cpst_en : R/W; bitpos: [8]; default: 1; + * Reserved + */ + uint32_t lact_cpst_en:1; + /** lact_lac_en : R/W; bitpos: [9]; default: 1; + * Reserved + */ + uint32_t lact_lac_en:1; + /** lact_alarm_en : R/W; bitpos: [10]; default: 0; + * Reserved + */ + uint32_t lact_alarm_en:1; + /** lact_level_int_en : R/W; bitpos: [11]; default: 0; + * Reserved + */ + uint32_t lact_level_int_en:1; + /** lact_edge_int_en : R/W; bitpos: [12]; default: 0; + * Reserved + */ + uint32_t lact_edge_int_en:1; + /** lact_divider : R/W; bitpos: [28:13]; default: 1; + * Reserved + */ + uint32_t lact_divider:16; + /** lact_autoreload : R/W; bitpos: [29]; default: 1; + * Reserved + */ + uint32_t lact_autoreload:1; + /** lact_increase : R/W; bitpos: [30]; default: 1; + * Reserved + */ + uint32_t lact_increase:1; + /** lact_en : R/W; bitpos: [31]; default: 0; + * Reserved + */ + uint32_t lact_en:1; + }; + uint32_t val; +} timg_lactconfig_reg_t; + +/** Type of lactrtc register + * LACT RTC register + */ +typedef union { + struct { + uint32_t reserved_0:6; + /** lact_rtc_step_len : R/W; bitpos: [31:6]; default: 0; + * Reserved + */ + uint32_t lact_rtc_step_len:26; + }; + uint32_t val; +} timg_lactrtc_reg_t; + +/** Type of lactlo register + * LACT low register + */ +typedef union { + struct { + /** lact_lo : RO; bitpos: [31:0]; default: 0; + * Reserved + */ + uint32_t lact_lo:32; + }; + uint32_t val; +} timg_lactlo_reg_t; + +/** Type of lacthi register + * LACT high register + */ +typedef union { + struct { + /** lact_hi : RO; bitpos: [31:0]; default: 0; + * Reserved + */ + uint32_t lact_hi:32; + }; + uint32_t val; +} timg_lacthi_reg_t; + +/** Type of lactupdate register + * LACT update register + */ +typedef union { + struct { + /** lact_update : WO; bitpos: [31:0]; default: 0; + * Reserved + */ + uint32_t lact_update:32; + }; + uint32_t val; +} timg_lactupdate_reg_t; + +/** Type of lactalarmlo register + * LACT alarm low register + */ +typedef union { + struct { + /** lact_alarm_lo : R/W; bitpos: [31:0]; default: 0; + * Reserved + */ + uint32_t lact_alarm_lo:32; + }; + uint32_t val; +} timg_lactalarmlo_reg_t; + +/** Type of lactalarmhi register + * LACT alarm high register + */ +typedef union { + struct { + /** lact_alarm_hi : R/W; bitpos: [31:0]; default: 0; + * Reserved + */ + uint32_t lact_alarm_hi:32; + }; + uint32_t val; +} timg_lactalarmhi_reg_t; + +/** Type of lactloadlo register + * LACT load low register + */ +typedef union { + struct { + /** lact_load_lo : R/W; bitpos: [31:0]; default: 0; + * Reserved + */ + uint32_t lact_load_lo:32; + }; + uint32_t val; +} timg_lactloadlo_reg_t; + +/** Type of lactloadhi register + * Timer LACT load high register + */ +typedef union { + struct { + /** lact_load_hi : R/W; bitpos: [31:0]; default: 0; + * Reserved + */ + uint32_t lact_load_hi:32; + }; + uint32_t val; +} timg_lactloadhi_reg_t; + +/** Type of lactload register + * Timer LACT load register + */ +typedef union { + struct { + /** lact_load : WO; bitpos: [31:0]; default: 0; + * Reserved + */ + uint32_t lact_load:32; + }; + uint32_t val; +} timg_lactload_reg_t; + + +/** Group: Interrupt Register */ +/** Type of int_ena_timers register + * Interrupt enable bits + */ +typedef union { + struct { + /** tx_int_ena : R/W; bitpos: [0]; default: 0; + * The interrupt enable bit for the TIMG_T0_INT interrupt. + */ + uint32_t tx_int_ena:1; + /** t1_int_ena : R/W; bitpos: [1]; default: 0; + * The interrupt enable bit for the TIMG_T1_INT interrupt. + */ + uint32_t t1_int_ena:1; + /** wdt_int_ena : R/W; bitpos: [2]; default: 0; + * The interrupt enable bit for the TIMG_WDT_INT interrupt. + */ + uint32_t wdt_int_ena:1; + /** lact_int_ena : R/W; bitpos: [3]; default: 0; + * The interrupt enable bit for the TIMG_LACT_INT interrupt. + */ + uint32_t lact_int_ena:1; + uint32_t reserved_4:28; + }; + uint32_t val; +} timg_int_ena_timers_reg_t; + +/** Type of int_raw_timers register + * Raw interrupt status + */ +typedef union { + struct { + /** t0_int_raw : RO; bitpos: [0]; default: 0; + * The raw interrupt status bit for the TIMG_T0_INT interrupt. + */ + uint32_t t0_int_raw:1; + /** t1_int_raw : RO; bitpos: [1]; default: 0; + * The raw interrupt status bit for the TIMG_T1_INT interrupt. + */ + uint32_t t1_int_raw:1; + /** wdt_int_raw : RO; bitpos: [2]; default: 0; + * The raw interrupt status bit for the TIMG_WDT_INT interrupt. + */ + uint32_t wdt_int_raw:1; + /** lact_int_raw : RO; bitpos: [3]; default: 0; + * The raw interrupt status bit for the TIMG_LACT_INT interrupt. + */ + uint32_t lact_int_raw:1; + uint32_t reserved_4:28; + }; + uint32_t val; +} timg_int_raw_timers_reg_t; + +/** Type of int_st_timers register + * Masked interrupt status + */ +typedef union { + struct { + /** t0_int_st : RO; bitpos: [0]; default: 0; + * The masked interrupt status bit for the TIMG_T0_INT interrupt. + */ + uint32_t t0_int_st:1; + /** t1_int_st : RO; bitpos: [1]; default: 0; + * The masked interrupt status bit for the TIMG_T1_INT interrupt. + */ + uint32_t t1_int_st:1; + /** wdt_int_st : RO; bitpos: [2]; default: 0; + * The masked interrupt status bit for the TIMG_WDT_INT interrupt. + */ + uint32_t wdt_int_st:1; + /** lact_int_st : RO; bitpos: [3]; default: 0; + * The masked interrupt status bit for the TIMG_LACT_INT interrupt. + */ + uint32_t lact_int_st:1; + uint32_t reserved_4:28; + }; + uint32_t val; +} timg_int_st_timers_reg_t; + +/** Type of int_clr_timers register + * Interrupt clear bits + */ +typedef union { + struct { + /** t0_int_clr : WO; bitpos: [0]; default: 0; + * Set this bit to clear the TIMG_T0_INT interrupt. + */ + uint32_t t0_int_clr:1; + /** t1_int_clr : WO; bitpos: [1]; default: 0; + * Set this bit to clear the TIMG_T1_INT interrupt. + */ + uint32_t t1_int_clr:1; + /** wdt_int_clr : WO; bitpos: [2]; default: 0; + * Set this bit to clear the TIMG_WDT_INT interrupt. + */ + uint32_t wdt_int_clr:1; + /** lact_int_clr : WO; bitpos: [3]; default: 0; + * Set this bit to clear the TIMG_LACT_INT interrupt. + */ + uint32_t lact_int_clr:1; + uint32_t reserved_4:28; + }; + uint32_t val; +} timg_int_clr_timers_reg_t; + + +/** Group: Version Register */ +/** Type of timers_date register + * Version control register + */ +typedef union { + struct { + /** timers_date : R/W; bitpos: [27:0]; default: 26243681; + * Version control register. + */ + uint32_t timers_date:28; + uint32_t reserved_28:4; + }; + uint32_t val; +} timg_timers_date_reg_t; + + +/** Group: Configuration Register */ +/** Type of regclk register + * Timer group clock gate register + */ +typedef union { + struct { + uint32_t reserved_0:31; + /** clk_en : R/W; bitpos: [31]; default: 0; + * Register clock gate signal. 1: Registers can be read and written to by software. 0: + * Registers can not be read or written to by software. + */ + uint32_t clk_en:1; + }; + uint32_t val; +} timg_regclk_reg_t; + +typedef struct { + volatile timg_txconfig_reg_t config; + volatile timg_txlo_reg_t lo; + volatile timg_txhi_reg_t hi; + volatile timg_txupdate_reg_t update; + volatile timg_txalarmlo_reg_t alarmlo; + volatile timg_txalarmhi_reg_t alarmhi; + volatile timg_txloadlo_reg_t loadlo; + volatile timg_txloadhi_reg_t loadhi; + volatile timg_txload_reg_t load; +} timg_hwtimer_reg_t; + +typedef struct { + volatile timg_hwtimer_reg_t hw_timer[2]; + volatile timg_wdtconfig0_reg_t wdtconfig0; + volatile timg_wdtconfig1_reg_t wdtconfig1; + volatile timg_wdtconfig2_reg_t wdtconfig2; + volatile timg_wdtconfig3_reg_t wdtconfig3; + volatile timg_wdtconfig4_reg_t wdtconfig4; + volatile timg_wdtconfig5_reg_t wdtconfig5; + volatile timg_wdtfeed_reg_t wdtfeed; + volatile timg_wdtwprotect_reg_t wdtwprotect; + volatile timg_rtccalicfg_reg_t rtccalicfg; + volatile timg_rtccalicfg1_reg_t rtccalicfg1; + volatile timg_lactconfig_reg_t lactconfig; + volatile timg_lactrtc_reg_t lactrtc; + volatile timg_lactlo_reg_t lactlo; + volatile timg_lacthi_reg_t lacthi; + volatile timg_lactupdate_reg_t lactupdate; + volatile timg_lactalarmlo_reg_t lactalarmlo; + volatile timg_lactalarmhi_reg_t lactalarmhi; + volatile timg_lactloadlo_reg_t lactloadlo; + volatile timg_lactloadhi_reg_t lactloadhi; + volatile timg_lactload_reg_t lactload; + volatile timg_int_ena_timers_reg_t int_ena_timers; + volatile timg_int_raw_timers_reg_t int_raw_timers; + volatile timg_int_st_timers_reg_t int_st_timers; + volatile timg_int_clr_timers_reg_t int_clr_timers; + volatile timg_rtccalicfg2_reg_t rtccalicfg2; + uint32_t reserved_0ac[19]; + volatile timg_timers_date_reg_t timers_date; + volatile timg_regclk_reg_t regclk; } timg_dev_t; + extern timg_dev_t TIMERG0; extern timg_dev_t TIMERG1; + +#ifndef __cplusplus +_Static_assert(sizeof(timg_dev_t) == 0x100, "Invalid size of timg_dev_t structure"); +#endif + #ifdef __cplusplus } #endif - -#endif /* _SOC_TIMG_STRUCT_H_ */ diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/twai_struct.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/twai_struct.h index 5cba4d409a2..00a006501cf 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/twai_struct.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/twai_struct.h @@ -35,10 +35,10 @@ typedef volatile struct twai_dev_s { uint32_t lom: 1; /* MOD.1 Listen Only Mode */ uint32_t stm: 1; /* MOD.2 Self Test Mode */ uint32_t afm: 1; /* MOD.3 Acceptance Filter Mode */ - uint32_t reserved28: 28; /* Internal Reserved. MOD.4 Sleep Mode not supported */ + uint32_t reserved4: 28; /* Internal Reserved. MOD.4 Sleep Mode not supported */ }; uint32_t val; - } mode_reg; /* Address 0 */ + } mode_reg; /* Address 0x0000 */ union { struct { uint32_t tr: 1; /* CMR.0 Transmission Request */ @@ -46,10 +46,10 @@ typedef volatile struct twai_dev_s { uint32_t rrb: 1; /* CMR.2 Release Receive Buffer */ uint32_t cdo: 1; /* CMR.3 Clear Data Overrun */ uint32_t srr: 1; /* CMR.4 Self Reception Request */ - uint32_t reserved27: 27; /* Internal Reserved */ + uint32_t reserved5: 27; /* Internal Reserved */ }; uint32_t val; - } command_reg; /* Address 1 */ + } command_reg; /* Address 0x0004 */ union { struct { uint32_t rbs: 1; /* SR.0 Receive Buffer Status */ @@ -61,37 +61,39 @@ typedef volatile struct twai_dev_s { uint32_t es: 1; /* SR.6 Error Status */ uint32_t bs: 1; /* SR.7 Bus Status */ uint32_t ms: 1; /* SR.8 Miss Status */ - uint32_t reserved23: 23; /* Internal Reserved */ + uint32_t reserved9: 23; /* Internal Reserved */ }; uint32_t val; - } status_reg; /* Address 2 */ + } status_reg; /* Address 0x0008 */ union { struct { uint32_t ri: 1; /* IR.0 Receive Interrupt */ uint32_t ti: 1; /* IR.1 Transmit Interrupt */ uint32_t ei: 1; /* IR.2 Error Interrupt */ - uint32_t reserved2: 2; /* Internal Reserved (Data Overrun interrupt and Wake-up not supported) */ + uint32_t doi: 1; /* IR.3 Data Overrun Interrupt */ + uint32_t reserved4: 1; /* Internal Reserved (Wake-up not supported) */ uint32_t epi: 1; /* IR.5 Error Passive Interrupt */ uint32_t ali: 1; /* IR.6 Arbitration Lost Interrupt */ uint32_t bei: 1; /* IR.7 Bus Error Interrupt */ - uint32_t reserved24: 24; /* Internal Reserved */ + uint32_t reserved8: 24; /* Internal Reserved */ }; uint32_t val; - } interrupt_reg; /* Address 3 */ + } interrupt_reg; /* Address 0x000C */ union { struct { uint32_t rie: 1; /* IER.0 Receive Interrupt Enable */ uint32_t tie: 1; /* IER.1 Transmit Interrupt Enable */ uint32_t eie: 1; /* IER.2 Error Interrupt Enable */ - uint32_t reserved2: 2; /* Internal Reserved (Data Overrun interrupt and Wake-up not supported) */ + uint32_t doie: 1; /* IER.3 Data Overrun Interrupt Enable */ + uint32_t reserved4: 1; /* Internal Reserved (Wake-up not supported) */ uint32_t epie: 1; /* IER.5 Error Passive Interrupt Enable */ uint32_t alie: 1; /* IER.6 Arbitration Lost Interrupt Enable */ uint32_t beie: 1; /* IER.7 Bus Error Interrupt Enable */ - uint32_t reserved24: 24; /* Internal Reserved */ + uint32_t reserved8: 24; /* Internal Reserved */ }; uint32_t val; - } interrupt_enable_reg; /* Address 4 */ - uint32_t reserved_05; /* Address 5 */ + } interrupt_enable_reg; /* Address 0x0010 */ + uint32_t reserved_14; union { struct { uint32_t brp: 14; /* BTR0[13:0] Baud Rate Prescaler */ @@ -99,58 +101,58 @@ typedef volatile struct twai_dev_s { uint32_t reserved16: 16; /* Internal Reserved */ }; uint32_t val; - } bus_timing_0_reg; /* Address 6 */ + } bus_timing_0_reg; /* Address 0x0018 */ union { struct { uint32_t tseg1: 4; /* BTR1[3:0] Timing Segment 1 */ uint32_t tseg2: 3; /* BTR1[6:4] Timing Segment 2 */ uint32_t sam: 1; /* BTR1.7 Sampling*/ - uint32_t reserved24: 24; /* Internal Reserved */ + uint32_t reserved8: 24; /* Internal Reserved */ }; uint32_t val; - } bus_timing_1_reg; /* Address 7 */ - uint32_t reserved_08; /* Address 8 (Output control not supported) */ - uint32_t reserved_09; /* Address 9 (Test Register not supported) */ - uint32_t reserved_10; /* Address 10 */ + } bus_timing_1_reg; /* Address 0x001C */ + uint32_t reserved_20; /* Address 0x0020 (Output control not supported) */ + uint32_t reserved_24; /* Address 0x0024 (Test Register not supported) */ + uint32_t reserved_28; /* Address 0x0028 */ //Capture and Counter Registers union { struct { uint32_t alc: 5; /* ALC[4:0] Arbitration lost capture */ - uint32_t reserved27: 27; /* Internal Reserved */ + uint32_t reserved5: 27; /* Internal Reserved */ }; uint32_t val; - } arbitration_lost_captue_reg; /* Address 11 */ + } arbitration_lost_captue_reg; /* Address 0x002C */ union { struct { uint32_t seg: 5; /* ECC[4:0] Error Code Segment 0 to 5 */ uint32_t dir: 1; /* ECC.5 Error Direction (TX/RX) */ uint32_t errc: 2; /* ECC[7:6] Error Code */ - uint32_t reserved24: 24; /* Internal Reserved */ + uint32_t reserved8: 24; /* Internal Reserved */ }; uint32_t val; - } error_code_capture_reg; /* Address 12 */ + } error_code_capture_reg; /* Address 0x0030 */ union { struct { uint32_t ewl: 8; /* EWL[7:0] Error Warning Limit */ - uint32_t reserved24: 24; /* Internal Reserved */ + uint32_t reserved8: 24; /* Internal Reserved */ }; uint32_t val; - } error_warning_limit_reg; /* EWLR[7:0] Error Warning Limit: Address 13 */ + } error_warning_limit_reg; /* Address 0x0034 */ union { struct { uint32_t rxerr: 8; /* RXERR[7:0] Receive Error Counter */ - uint32_t reserved24: 24; /* Internal Reserved */ + uint32_t reserved8: 24; /* Internal Reserved */ }; uint32_t val; - } rx_error_counter_reg; /* Address 12 */ + } rx_error_counter_reg; /* Address 0x0038 */ union { struct { uint32_t txerr: 8; /* TXERR[7:0] Receive Error Counter */ - uint32_t reserved24: 24; /* Internal Reserved */ + uint32_t reserved8: 24; /* Internal Reserved */ }; uint32_t val; - } tx_error_counter_reg; /* Address 15 */ + } tx_error_counter_reg; /* Address 0x003C */ //Shared Registers (TX Buff/RX Buff/Acc Filter) union { @@ -158,45 +160,49 @@ typedef volatile struct twai_dev_s { union { struct { uint32_t byte: 8; /* ACRx[7:0] Acceptance Code */ - uint32_t reserved24: 24; /* Internal Reserved */ + uint32_t reserved8: 24; /* Internal Reserved */ }; uint32_t val; } acr[4]; union { struct { uint32_t byte: 8; /* AMRx[7:0] Acceptance Mask */ - uint32_t reserved24: 24; /* Internal Reserved */ + uint32_t reserved8: 24; /* Internal Reserved */ }; uint32_t val; } amr[4]; - uint32_t reserved32[5]; + uint32_t reserved_60; + uint32_t reserved_64; + uint32_t reserved_68; + uint32_t reserved_6c; + uint32_t reserved_70; } acceptance_filter; union { struct { - uint32_t byte: 8; - uint32_t reserved24: 24; + uint32_t byte: 8; /* TX/RX Byte X [7:0] */ + uint32_t reserved24: 24; /* Internal Reserved */ }; uint32_t val; } tx_rx_buffer[13]; - }; /* Address 16-28 TX/RX Buffer and Acc Filter*/; + }; /* Address 0x0040 - 0x0070 */ //Misc Registers union { struct { uint32_t rmc: 7; /* RMC[6:0] RX Message Counter */ - uint32_t reserved25: 25; /* Internal Reserved */ + uint32_t reserved7: 25; /* Internal Reserved */ }; uint32_t val; - } rx_message_counter_reg; /* Address 29 */ - uint32_t reserved_30; /* Address 30 (RX Buffer Start Address not supported) */ + } rx_message_counter_reg; /* Address 0x0074 */ + uint32_t reserved_78; /* Address 0x0078 (RX Buffer Start Address not supported) */ union { struct { uint32_t cd: 8; /* CDR[7:0] CLKOUT frequency selector based of fOSC */ uint32_t co: 1; /* CDR.8 CLKOUT enable/disable */ - uint32_t reserved24: 23; /* Internal Reserved */ + uint32_t reserved9: 23; /* Internal Reserved */ }; uint32_t val; - } clock_divider_reg; /* Address 31 */ + } clock_divider_reg; /* Address 0x007C */ } twai_dev_t; _Static_assert(sizeof(twai_dev_t) == 128, "TWAI registers should be 32 * 4 bytes"); diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/uart_pins.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/uart_pins.h new file mode 100644 index 00000000000..a6a7d187242 --- /dev/null +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/uart_pins.h @@ -0,0 +1,43 @@ +// Copyright 2015-2021 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/io_mux_reg.h" + +/* Specify the number of pins for UART */ +#define SOC_UART_PINS_COUNT (4) + +/* Specify the GPIO pin number for each UART signal in the IOMUX */ +#define U0RXD_GPIO_NUM (44) +#define U0TXD_GPIO_NUM (43) +#define U0RTS_GPIO_NUM (15) +#define U0CTS_GPIO_NUM (16) + +#define U1RXD_GPIO_NUM (18) +#define U1TXD_GPIO_NUM (17) +#define U1RTS_GPIO_NUM (19) +#define U1CTS_GPIO_NUM (20) + +/* The following defines are necessary for reconfiguring the UART + * to use IOMUX, at runtime. */ +#define U0TXD_MUX_FUNC (FUNC_U0TXD_U0TXD) +#define U0RXD_MUX_FUNC (FUNC_U0RXD_U0RXD) +#define U0RTS_MUX_FUNC (FUNC_XTAL_32K_P_U0RTS) +#define U0CTS_MUX_FUNC (FUNC_XTAL_32K_N_U0CTS) + +#define U1TXD_MUX_FUNC (FUNC_DAC_1_U1TXD) +#define U1RXD_MUX_FUNC (FUNC_DAC_2_U1RXD) +#define U1RTS_MUX_FUNC (FUNC_GPIO19_U1RTS) +#define U1CTS_MUX_FUNC (FUNC_GPIO20_U1CTS) diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/uart_struct.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/uart_struct.h index a470b6b968e..5eb977825b5 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/uart_struct.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/uart_struct.h @@ -17,7 +17,7 @@ extern "C" { #endif -typedef volatile struct { +typedef volatile struct uart_dev_s { union { struct { uint32_t rw_byte;/*note: rw_byte is a uint8_t field, however, ESP32-S2 do not support 8 bits read/write*/ diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/uhci_struct.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/uhci_struct.h index aadc2a63037..63cc0741610 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/uhci_struct.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/uhci_struct.h @@ -17,7 +17,7 @@ extern "C" { #endif -typedef volatile struct { +typedef volatile struct uhci_dev_s { union { struct { uint32_t in_rst: 1; diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/usb_wrap_struct.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/usb_wrap_struct.h index 147afc32289..c196743ec03 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/usb_wrap_struct.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/usb_wrap_struct.h @@ -153,6 +153,7 @@ typedef union { * USB D- rx value in test. */ uint32_t test_rx_dm:1; + uint32_t reserved:25; }; uint32_t val; } usb_wrap_test_conf_reg_t; diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/usbh_struct.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/usbh_struct.h index ace84d7fa9a..182a6034d1d 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/usbh_struct.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/usbh_struct.h @@ -830,7 +830,7 @@ typedef union { uint32_t bbleerr: 1; uint32_t nakintrpt: 1; uint32_t nyetintrpt: 1; - uint32_t reserved16: 16; + uint32_t reserved15: 17; }; uint32_t val; } usb_diepint_reg_t; diff --git a/tools/sdk/esp32s2/include/soc/include/soc/adc_periph.h b/tools/sdk/esp32s2/include/soc/include/soc/adc_periph.h index 796ea18e906..437d8ad6e6a 100644 --- a/tools/sdk/esp32s2/include/soc/include/soc/adc_periph.h +++ b/tools/sdk/esp32s2/include/soc/include/soc/adc_periph.h @@ -18,7 +18,7 @@ #include "soc/soc_caps.h" #include "soc/syscon_struct.h" -#if SOC_ADC_SUPPORT_RTC_CTRL +#if SOC_ADC_RTC_CTRL_SUPPORTED #include "soc/sens_reg.h" #include "soc/sens_struct.h" #endif diff --git a/tools/sdk/esp32s2/include/soc/include/soc/i2s_periph.h b/tools/sdk/esp32s2/include/soc/include/soc/i2s_periph.h index a2b9c542744..167c84700fd 100644 --- a/tools/sdk/esp32s2/include/soc/include/soc/i2s_periph.h +++ b/tools/sdk/esp32s2/include/soc/include/soc/i2s_periph.h @@ -1,4 +1,4 @@ -// Copyright 2019 Espressif Systems (Shanghai) PTE LTD +// Copyright 2020 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. @@ -27,16 +27,21 @@ extern "C" { Stores a bunch of per-I2S-peripheral data. */ typedef struct { - const uint8_t o_bck_in_sig; - const uint8_t o_ws_in_sig; - const uint8_t o_bck_out_sig; - const uint8_t o_ws_out_sig; - const uint8_t o_data_out_sig; - const uint8_t i_bck_in_sig; - const uint8_t i_ws_in_sig; - const uint8_t i_bck_out_sig; - const uint8_t i_ws_out_sig; - const uint8_t i_data_in_sig; + const uint8_t mck_out_sig; + + const uint8_t m_tx_bck_sig; + const uint8_t m_rx_bck_sig; + const uint8_t m_tx_ws_sig; + const uint8_t m_rx_ws_sig; + + const uint8_t s_tx_bck_sig; + const uint8_t s_rx_bck_sig; + const uint8_t s_tx_ws_sig; + const uint8_t s_rx_ws_sig; + + const uint8_t data_out_sig; + const uint8_t data_in_sig; + const uint8_t irq; const periph_module_t module; } i2s_signal_conn_t; diff --git a/tools/sdk/esp32s2/include/soc/include/soc/lcd_periph.h b/tools/sdk/esp32s2/include/soc/include/soc/lcd_periph.h index 6b1071b316c..d7d3ebc68bf 100644 --- a/tools/sdk/esp32s2/include/soc/include/soc/lcd_periph.h +++ b/tools/sdk/esp32s2/include/soc/include/soc/lcd_periph.h @@ -21,6 +21,7 @@ extern "C" { #endif +#if SOC_LCDCAM_SUPPORTED typedef struct { struct { const periph_module_t module; @@ -41,6 +42,19 @@ typedef struct { } panels[SOC_LCD_RGB_PANELS]; } lcd_signal_conn_t; +#endif // SOC_LCDCAM_SUPPORTED + +#if SOC_I2S_LCD_I80_VARIANT +typedef struct { + struct { + const periph_module_t module; + const int irq_id; + const int data_sigs[SOC_LCD_I80_BUS_WIDTH]; + const int wr_sig; + } buses[SOC_LCD_I80_BUSES]; +} lcd_signal_conn_t; +#endif // SOC_I2S_LCD_I80_VARIANT + extern const lcd_signal_conn_t lcd_periph_signals; #ifdef __cplusplus diff --git a/tools/sdk/esp32s2/include/soc/include/soc/mcpwm_periph.h b/tools/sdk/esp32s2/include/soc/include/soc/mcpwm_periph.h index ae5809c91ef..d807600c4a7 100644 --- a/tools/sdk/esp32s2/include/soc/include/soc/mcpwm_periph.h +++ b/tools/sdk/esp32s2/include/soc/include/soc/mcpwm_periph.h @@ -34,13 +34,13 @@ typedef struct { } operators[SOC_MCPWM_OPERATORS_PER_GROUP]; struct { const uint32_t fault_sig; - } detectors[SOC_MCPWM_FAULT_DETECTORS_PER_GROUP]; + } gpio_faults[SOC_MCPWM_GPIO_FAULTS_PER_GROUP]; struct { const uint32_t cap_sig; } captures[SOC_MCPWM_CAPTURE_CHANNELS_PER_TIMER]; struct { const uint32_t sync_sig; - } ext_syncers[SOC_MCPWM_EXT_SYNCERS_PER_GROUP]; + } gpio_synchros[SOC_MCPWM_GPIO_SYNCHROS_PER_GROUP]; } groups[SOC_MCPWM_GROUPS]; } mcpwm_signal_conn_t; diff --git a/tools/sdk/esp32s2/include/soc/include/soc/pcnt_periph.h b/tools/sdk/esp32s2/include/soc/include/soc/pcnt_periph.h index fa0f58221d5..966950c8461 100644 --- a/tools/sdk/esp32s2/include/soc/include/soc/pcnt_periph.h +++ b/tools/sdk/esp32s2/include/soc/include/soc/pcnt_periph.h @@ -1,4 +1,4 @@ -// Copyright 2019 Espressif Systems (Shanghai) PTE LTD +// Copyright 2019-2020 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. @@ -27,12 +27,14 @@ extern "C" { typedef struct { struct { struct { - const uint32_t pulse_sig; - const uint32_t control_sig; - } channels[SOC_PCNT_UNIT_CHANNEL_NUM]; - } units[SOC_PCNT_UNIT_NUM]; - const uint32_t irq; - const periph_module_t module; + struct { + const uint32_t pulse_sig; + const uint32_t control_sig; + } channels[SOC_PCNT_CHANNELS_PER_UNIT]; + } units[SOC_PCNT_UNITS_PER_GROUP]; + const uint32_t irq; + const periph_module_t module; + } groups[SOC_PCNT_GROUPS]; } pcnt_signal_conn_t; extern const pcnt_signal_conn_t pcnt_periph_signals; diff --git a/tools/sdk/esp32s2/include/soc/include/soc/rtc_io_periph.h b/tools/sdk/esp32s2/include/soc/include/soc/rtc_io_periph.h index e9309771c63..618b64cd8f7 100644 --- a/tools/sdk/esp32s2/include/soc/include/soc/rtc_io_periph.h +++ b/tools/sdk/esp32s2/include/soc/include/soc/rtc_io_periph.h @@ -27,7 +27,7 @@ #include "soc/rtc_cntl_reg.h" #include "soc/rtc_cntl_struct.h" -#if SOC_ADC_SUPPORT_RTC_CTRL +#if SOC_ADC_RTC_CTRL_SUPPORTED #include "soc/sens_struct.h" #endif diff --git a/tools/sdk/esp32s2/include/soc/include/soc/sdio_slave_periph.h b/tools/sdk/esp32s2/include/soc/include/soc/sdio_slave_periph.h index d39f72f5269..0f748ae12e5 100644 --- a/tools/sdk/esp32s2/include/soc/include/soc/sdio_slave_periph.h +++ b/tools/sdk/esp32s2/include/soc/include/soc/sdio_slave_periph.h @@ -15,9 +15,12 @@ #pragma once #include //include soc related (generated) definitions +#include "soc/soc_caps.h" #include "soc/soc_pins.h" +#ifdef SOC_SDIO_SLAVE_SUPPORTED #include "soc/slc_reg.h" #include "soc/slc_struct.h" +#endif #include "soc/host_reg.h" #include "soc/host_struct.h" #include "soc/hinf_reg.h" diff --git a/tools/sdk/esp32s2/include/soc/include/soc/spi_periph.h b/tools/sdk/esp32s2/include/soc/include/soc/spi_periph.h index 4ddb8b3f1ef..7aa38650356 100644 --- a/tools/sdk/esp32s2/include/soc/include/soc/spi_periph.h +++ b/tools/sdk/esp32s2/include/soc/include/soc/spi_periph.h @@ -30,8 +30,7 @@ #endif #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif #if CONFIG_IDF_TARGET_ESP32S2 @@ -41,8 +40,6 @@ extern "C" #define SPI_FWRITE_QIO 0 #endif - - /* Stores a bunch of per-spi-peripheral data. */ @@ -53,10 +50,22 @@ typedef struct { const uint8_t spiq_out; const uint8_t spiwp_out; const uint8_t spihd_out; +#if SOC_SPI_SUPPORT_OCT + const uint8_t spid4_out; + const uint8_t spid5_out; + const uint8_t spid6_out; + const uint8_t spid7_out; +#endif // SOC_SPI_SUPPORT_OCT const uint8_t spid_in; //GPIO mux input signals const uint8_t spiq_in; const uint8_t spiwp_in; const uint8_t spihd_in; +#if SOC_SPI_SUPPORT_OCT + const uint8_t spid4_in; + const uint8_t spid5_in; + const uint8_t spid6_in; + const uint8_t spid7_in; +#endif // SOC_SPI_SUPPORT_OCT const uint8_t spics_out[3]; // /CS GPIO output mux signals const uint8_t spics_in; const uint8_t spidqs_out; diff --git a/tools/sdk/esp32s2/include/soc/include/soc/uart_periph.h b/tools/sdk/esp32s2/include/soc/include/soc/uart_periph.h index f7e47099328..320b947c3b8 100644 --- a/tools/sdk/esp32s2/include/soc/include/soc/uart_periph.h +++ b/tools/sdk/esp32s2/include/soc/include/soc/uart_periph.h @@ -18,16 +18,40 @@ #include "soc/uart_struct.h" #include "soc/periph_defs.h" #include "soc/gpio_sig_map.h" +#include "soc/io_mux_reg.h" +#include "soc/uart_pins.h" #ifdef __cplusplus extern "C" { #endif +#define SOC_UART_TX_PIN_IDX (0) +#define SOC_UART_RX_PIN_IDX (1) +#define SOC_UART_RTS_PIN_IDX (2) +#define SOC_UART_CTS_PIN_IDX (3) + +/** + * @brief Macro that can be used to retrieve the signal of a certain pin for a + * certain UART. + */ +#define UART_PERIPH_SIGNAL(IDX, PIN) (uart_periph_signal[(IDX)].pins[(PIN)].signal) + +typedef struct { + /* Default GPIO number for this UART pin in the IOMUX. + * This value can be -1 if there is no default GPIO for a pin. + * For example, ESP32-C3 doesn't have any default GPIO for + * U0CTS and U0RTS. */ + int32_t default_gpio : 15; + /* Func which should be assigned to the GPIO to be used as UART */ + int32_t iomux_func : 4; + /* Marks if the current UART pin is input (or not) */ + uint32_t input : 1; + /* Signal in the GPIO signal map. */ + uint32_t signal : 12; +} uart_periph_sig_t; + typedef struct { - const uint8_t tx_sig; - const uint8_t rx_sig; - const uint8_t rts_sig; - const uint8_t cts_sig; + const uart_periph_sig_t pins[SOC_UART_PINS_COUNT]; const uint8_t irq; const periph_module_t module; } uart_signal_conn_t; diff --git a/tools/sdk/esp32s2/include/soc/include/soc/usb_phy_periph.h b/tools/sdk/esp32s2/include/soc/include/soc/usb_phy_periph.h new file mode 100644 index 00000000000..802d1720cec --- /dev/null +++ b/tools/sdk/esp32s2/include/soc/include/soc/usb_phy_periph.h @@ -0,0 +1,35 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once +#include +#include "soc/soc_caps.h" +#include "soc/periph_defs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + Stores a bunch of USB-peripheral data. +*/ +typedef struct { + const uint8_t extphy_vp_in; + const uint8_t extphy_vm_in; + const uint8_t extphy_rcv_in; + const uint8_t extphy_oen_out; + const uint8_t extphy_vpo_out; + const uint8_t extphy_vmo_out; + const uint8_t extphy_suspend_in; + const uint8_t extphy_speed_in; + const periph_module_t module; +} usb_phy_signal_conn_t; + +extern const usb_phy_signal_conn_t usb_phy_periph_signal; + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32s2/include/spi_flash/include/esp_partition.h b/tools/sdk/esp32s2/include/spi_flash/include/esp_partition.h index e59babb451b..36baea29860 100644 --- a/tools/sdk/esp32s2/include/spi_flash/include/esp_partition.h +++ b/tools/sdk/esp32s2/include/spi_flash/include/esp_partition.h @@ -87,6 +87,7 @@ typedef enum { ESP_PARTITION_SUBTYPE_DATA_COREDUMP = 0x03, //!< COREDUMP partition ESP_PARTITION_SUBTYPE_DATA_NVS_KEYS = 0x04, //!< Partition for NVS keys ESP_PARTITION_SUBTYPE_DATA_EFUSE_EM = 0x05, //!< Partition for emulate eFuse bits + ESP_PARTITION_SUBTYPE_DATA_UNDEFINED = 0x06, //!< Undefined (or unspecified) data partition ESP_PARTITION_SUBTYPE_DATA_ESPHTTPD = 0x80, //!< ESPHTTPD partition ESP_PARTITION_SUBTYPE_DATA_FAT = 0x81, //!< FAT partition diff --git a/tools/sdk/esp32s2/include/spi_flash/include/spi_flash/spi_flash_defs.h b/tools/sdk/esp32s2/include/spi_flash/include/spi_flash/spi_flash_defs.h index cf26fda1486..1ff0bfdea5c 100644 --- a/tools/sdk/esp32s2/include/spi_flash/include/spi_flash/spi_flash_defs.h +++ b/tools/sdk/esp32s2/include/spi_flash/include/spi_flash/spi_flash_defs.h @@ -68,3 +68,7 @@ #define SPI_FLASH_FASTRD_DUMMY_BITLEN 8 #define SPI_FLASH_SLOWRD_ADDR_BITLEN 24 #define SPI_FLASH_SLOWRD_DUMMY_BITLEN 0 +#define SPI_FLASH_OPISTR_ADDR_BITLEN 32 +#define SPI_FLASH_OPISTR_DUMMY_BITLEN 20 +#define SPI_FLASH_OPIDTR_ADDR_BITLEN 32 +#define SPI_FLASH_OPIDTR_DUMMY_BITLEN 40 diff --git a/tools/sdk/esp32s2/include/spi_flash/include/spi_flash_chip_driver.h b/tools/sdk/esp32s2/include/spi_flash/include/spi_flash_chip_driver.h index 9a143d84d2e..d2ef25bf6de 100644 --- a/tools/sdk/esp32s2/include/spi_flash/include/spi_flash_chip_driver.h +++ b/tools/sdk/esp32s2/include/spi_flash/include/spi_flash_chip_driver.h @@ -206,6 +206,11 @@ struct spi_flash_chip_t { * Get the capabilities of the flash chip. See SPI_FLASH_CHIP_CAP_* macros as reference. */ spi_flash_caps_t (*get_chip_caps)(esp_flash_t *chip); + + /** + * Configure the host registers to use the specified read mode set in the ``chip->read_mode``. + */ + esp_err_t (*config_host_io_mode)(esp_flash_t *chip, uint32_t flags); }; /* Pointer to an array of pointers to all known drivers for flash chips. This array is used diff --git a/tools/sdk/esp32s2/include/spi_flash/include/spi_flash_chip_generic.h b/tools/sdk/esp32s2/include/spi_flash/include/spi_flash_chip_generic.h index 9e99f73e44b..019a6966a40 100644 --- a/tools/sdk/esp32s2/include/spi_flash/include/spi_flash_chip_generic.h +++ b/tools/sdk/esp32s2/include/spi_flash/include/spi_flash_chip_generic.h @@ -370,14 +370,15 @@ esp_err_t spi_flash_common_set_io_mode(esp_flash_t *chip, esp_flash_wrsr_func_t * transactions. Also prepare the command to be sent in read functions. * * @param chip Pointer to SPI flash chip to use. If NULL, esp_flash_default_chip is substituted. - * @param addr_32bit Whether 32 bit commands will be used (Currently only W25Q256 and GD25Q256 are supported) + * @param flags Special rules to configure io mode, (i.e. Whether 32 bit commands will be used (Currently only W25Q256 and GD25Q256 are supported)) * * @return * - ESP_OK if success * - ESP_ERR_FLASH_NOT_INITIALISED if chip not initialized properly * - or other error passed from the ``configure_host_mode`` function of host driver */ -esp_err_t spi_flash_chip_generic_config_host_io_mode(esp_flash_t *chip, bool addr_32bit); +esp_err_t spi_flash_chip_generic_config_host_io_mode(esp_flash_t *chip, uint32_t flags); +#define SPI_FLASH_CONFIG_IO_MODE_32B_ADDR BIT(0) /** * @brief Handle explicit yield requests @@ -396,5 +397,15 @@ esp_err_t spi_flash_chip_generic_yield(esp_flash_t* chip, uint32_t wip); */ esp_err_t spi_flash_chip_generic_suspend_cmd_conf(esp_flash_t *chip); +/** + * + * @brief Read the chip unique ID unsupported function. + * + * @param chip Pointer to SPI flash chip to use. + * @param flash_unique_id Pointer to store output unique id (Although this function is an unsupported function, but the parameter should be kept for the consistence of the function pointer). + * @return Always ESP_ERR_NOT_SUPPORTED. + */ +esp_err_t spi_flash_chip_generic_read_unique_id_none(esp_flash_t *chip, uint64_t* flash_unique_id); + /// Default timeout configuration used by most chips -const flash_chip_op_timeout_t spi_flash_chip_generic_timeout; +extern const flash_chip_op_timeout_t spi_flash_chip_generic_timeout; diff --git a/tools/sdk/esp32s2/include/spi_flash/include/spi_flash_chip_mxic.h b/tools/sdk/esp32s2/include/spi_flash/include/spi_flash_chip_mxic.h index f998c1564e5..201ad496e2a 100644 --- a/tools/sdk/esp32s2/include/spi_flash/include/spi_flash_chip_mxic.h +++ b/tools/sdk/esp32s2/include/spi_flash/include/spi_flash_chip_mxic.h @@ -25,3 +25,10 @@ * is not found. */ extern const spi_flash_chip_t esp_flash_chip_mxic; + +/** + * MXIC OPI flash chip_drv, uses all the above functions for its operations. In + * default autodetection, this is used as a catchall if a more specific chip_drv + * is not found. + */ +extern const spi_flash_chip_t esp_flash_chip_mxic_opi; diff --git a/tools/sdk/esp32s2/include/spi_flash/include/spi_flash_private.h b/tools/sdk/esp32s2/include/spi_flash/include/spi_flash_private.h index f792faef657..9d822fb9475 100644 --- a/tools/sdk/esp32s2/include/spi_flash/include/spi_flash_private.h +++ b/tools/sdk/esp32s2/include/spi_flash/include/spi_flash_private.h @@ -26,6 +26,8 @@ #elif CONFIG_IDF_TARGET_ESP32S3 #include "esp32s3/rom/spi_flash.h" #endif +#include "esp_flash.h" +#include "hal/spi_flash_hal.h" #ifdef __cplusplus extern "C" { @@ -38,13 +40,15 @@ esp_err_t esp_opiflash_init(void); /** * @brief Make MSPI work under 20Mhz + * @param control_spi1 Select whether to control SPI1. For tuning, we need to use SPI1. After tuning (during startup stage), let the flash driver to control SPI1 */ -void spi_timing_enter_mspi_low_speed_mode(void); +void spi_timing_enter_mspi_low_speed_mode(bool control_spi1); /** * @brief Make MSPI work under the frequency as users set + * @param control_spi1 Select whether to control SPI1. For tuning, we need to use SPI1. After tuning (during startup stage), let the flash driver to control SPI1 */ -void spi_timing_enter_mspi_high_speed_mode(void); +void spi_timing_enter_mspi_high_speed_mode(bool control_spi1); /** * @brief Tune MSPI flash timing to make it work under high frequency @@ -56,12 +60,34 @@ void spi_timing_flash_tuning(void); */ void spi_timing_psram_tuning(void); +/** + * @brief To initislize the MSPI pins + */ +void esp_mspi_pin_init(void); + /** * @brief Set SPI1 registers to make ROM functions work * @note This function is used for setting SPI1 registers to the state that ROM SPI functions work */ void spi_flash_set_rom_required_regs(void); +/** + * @brief Initialize main flash + * @param chip Pointer to main SPI flash(SPI1 CS0) chip to use.. + */ +esp_err_t esp_flash_init_main(esp_flash_t *chip); + +/** + * @brief Should be only used by SPI1 Flash driver to know the necessary timing registers + * @param out_timing_config Pointer to timing_tuning parameters. + */ +void spi_timing_get_flash_timing_param(spi_flash_hal_timing_config_t *out_timing_config); + +/** + * @brief Judge if the flash in tuned + */ +bool spi_timine_config_flash_is_tuned(void); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32s2/include/usb/include/esp_private/usb_phy.h b/tools/sdk/esp32s2/include/usb/include/esp_private/usb_phy.h new file mode 100644 index 00000000000..5e8f9c8df19 --- /dev/null +++ b/tools/sdk/esp32s2/include/usb/include/esp_private/usb_phy.h @@ -0,0 +1,142 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include +#include +#include "soc/soc_caps.h" +#include "hal/usb_phy_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief USB PHY status + */ +typedef enum { + USB_PHY_STATUS_FREE, /**< PHY is not being used */ + USB_PHY_STATUS_IN_USE, /**< PHY is in use */ +} usb_phy_status_t; + +/** + * @brief USB PHY available actions + */ +typedef enum { + USB_PHY_ACTION_HOST_ALLOW_CONN, /**< Enable physical connection when operating as an OTG Host */ + USB_PHY_ACTION_HOST_FORCE_DISCONN, /**< Disable physical connection when operating as an OTG Host */ + USB_PHY_ACTION_MAX, +} usb_phy_action_t; + +/** + * @brief USB external PHY iopins configure struct + */ +typedef struct { + int vp_io_num; /**< GPIO pin to USB_EXTPHY_VP_IDX */ + int vm_io_num; /**< GPIO pin to USB_EXTPHY_VM_IDX */ + int rcv_io_num; /**< GPIO pin to USB_EXTPHY_RCV_IDX */ + int oen_io_num; /**< GPIO pin to USB_EXTPHY_OEN_IDX */ + int vpo_io_num; /**< GPIO pin to USB_EXTPHY_VPO_IDX */ + int vmo_io_num; /**< GPIO pin to USB_EXTPHY_VMO_IDX */ +} usb_phy_gpio_conf_t; + +/** + * @brief USB PHY configure struct + * + * At minimum the PHY controller and PHY target must be initialized. + */ +typedef struct { + usb_phy_controller_t controller; /**< USB PHY controller */ + usb_phy_target_t target; /**< USB PHY target INT/EXT */ + usb_otg_mode_t otg_mode; /**< USB OTG mode */ + usb_phy_speed_t otg_speed; /**< USB OTG speed */ + usb_phy_gpio_conf_t *gpio_conf; /**< USB external PHY iopins configure */ +} usb_phy_config_t; + +typedef struct phy_context_t *usb_phy_handle_t; /**< USB PHY context handle */ + +/** + * @brief Initialize a new USB PHY + * Configure at least PHY source. + * + * @param[in] config USB PHY configurtion struct + * @param[out] handle_ret USB PHY context handle + * + * @return + * - ESP_OK Success + * - ESP_FAIL USB PHY init error. + * - ESP_ERR_INVALID_STATE USB PHY not installed. + * - ESP_ERR_NO_MEM USB_OTG installation failed due to no mem. + */ +esp_err_t usb_new_phy(const usb_phy_config_t *config, usb_phy_handle_t *handle_ret); + +/** + * @brief Configure OTG mode for a USB PHY + * + * @param handle Pointer of USB PHY context handle + * @param mode USB OTG mode + * + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG Parameter error. + * - ESP_FAIL OTG set mode fail. + */ +esp_err_t usb_phy_otg_set_mode(usb_phy_handle_t handle, usb_otg_mode_t mode); + +/** + * @brief Configure USB speed for a USB PHY that is operating as an OTG Device + * + * @param handle Pointer of USB PHY context handle + * @param mode USB speed + * + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG Parameter error. + * - ESP_FAIL OTG set speed fail. + */ +esp_err_t usb_phy_otg_dev_set_speed(usb_phy_handle_t handle, usb_phy_speed_t speed); + +/** + * @brief Take a action for a USB PHY + * + * @param handle Pointer of USB PHY context handle + * @param action USB PHY action + * + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG Parameter error. + * - ESP_FAIL Action cannot be performed. + */ +esp_err_t usb_phy_action(usb_phy_handle_t handle, usb_phy_action_t action); + +/** + * @brief Delete a USB PHY + * + * @param handle Pointer of USB PHY context handle + * + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG Parameter error. + */ +esp_err_t usb_del_phy(usb_phy_handle_t handle); + +/** + * @brief Get status of a USB PHY + * + * @param[in] target The specific PHY target to check + * @param[out] status Status of the PHY + * + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG Parameter error. + * - ESP_ERR_INVALID_STATE USB PHY not installed. + */ +esp_err_t usb_phy_get_phy_status(usb_phy_target_t target, usb_phy_status_t *status); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32s2/include/usb/include/usb/usb_helpers.h b/tools/sdk/esp32s2/include/usb/include/usb/usb_helpers.h new file mode 100644 index 00000000000..d8405dd5fcd --- /dev/null +++ b/tools/sdk/esp32s2/include/usb/include/usb/usb_helpers.h @@ -0,0 +1,134 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* +Warning: The USB Host Library API is still a beta version and may be subject to change +*/ + +#pragma once + +#include +#include "usb/usb_types_ch9.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// ---------------------------------------- Configuration Descriptor Parsing ------------------------------------------- + +/** + * @brief Get the next descriptor + * + * Given a particular descriptor within a full configuration descriptor, get the next descriptor within the + * configuration descriptor. This is a convenience function that can be used to walk each individual descriptor within + * a full configuration descriptor. + * + * @param[in] cur_desc Current descriptor + * @param[in] wTotalLength Total length of the configuration descriptor + * @param[inout] offset Byte offset relative to the start of the configuration descriptor. On input, it is the offset of + * the current descriptor. On output, it is the offset of the returned descriptor. + * @return usb_standard_desc_t* Next descriptor, NULL if end of configuration descriptor reached + */ +const usb_standard_desc_t *usb_parse_next_descriptor(const usb_standard_desc_t *cur_desc, uint16_t wTotalLength, int *offset); + +/** + * @brief Get the next descriptor of a particular type + * + * Given a particular descriptor within a full configuration descriptor, get the next descriptor of a particular type + * (i.e., using the bDescriptorType value) within the configuration descriptor. + * + * @param[in] cur_desc Current descriptor + * @param[in] wTotalLength Total length of the configuration descriptor + * @param[in] bDescriptorType Type of the next descriptor to get + * @param[inout] offset Byte offset relative to the start of the configuration descriptor. On input, it is the offset of + * the current descriptor. On output, it is the offset of the returned descriptor. + * @return usb_standard_desc_t* Next descriptor, NULL if end descriptor is not found or configuration descriptor reached + */ +const usb_standard_desc_t *usb_parse_next_descriptor_of_type(const usb_standard_desc_t *cur_desc, uint16_t wTotalLength, uint8_t bDescriptorType, int *offset); + +/** + * @brief Get the number of alternate settings for a bInterfaceNumber + * + * Given a particular configuration descriptor, for a particular bInterfaceNumber, get the number of alternate settings + * available for that interface (i.e., the max possible value of bAlternateSetting for that bInterfaceNumber). + * + * @param[in] config_desc Pointer to the start of a full configuration descriptor + * @param[in] bInterfaceNumber Interface number + * @return int The number of alternate settings that the interface has, -1 if bInterfaceNumber not found + */ +int usb_parse_interface_number_of_alternate(const usb_config_desc_t *config_desc, uint8_t bInterfaceNumber); + +/** + * @brief Get a particular interface descriptor (using bInterfaceNumber and bAlternateSetting) + * + * Given a full configuration descriptor, get a particular interface descriptor. + * + * @note To get the number of alternate settings for a particular bInterfaceNumber, call + * usb_parse_interface_number_of_alternate() + * + * @param[in] config_desc Pointer to the start of a full configuration descriptor + * @param[in] bInterfaceNumber Interface number + * @param[in] bAlternateSetting Alternate setting number + * @param[out] offset Byte offset of the interface descriptor relative to the start of the configuration descriptor. Can be NULL. + * @return const usb_intf_desc_t* Pointer to interface descriptor, NULL if not found. + */ +const usb_intf_desc_t *usb_parse_interface_descriptor(const usb_config_desc_t *config_desc, uint8_t bInterfaceNumber, uint8_t bAlternateSetting, int *offset); + +/** + * @brief Get an endpoint descriptor within an interface descriptor + * + * Given an interface descriptor, get the Nth endpoint descriptor of the interface. The number of endpoints in an + * interface is indicated by the bNumEndpoints field of the interface descriptor. + * + * @note If bNumEndpoints is 0, it means the interface uses the default endpoint only + * + * @param[in] intf_desc Pointer to thee start of an interface descriptor + * @param[in] index Endpoint index + * @param[in] wTotalLength Total length of the containing configuration descriptor + * @param[inout] offset Byte offset relative to the start of the configuration descriptor. On input, it is the offset + * of the interface descriptor. On output, it is the offset of the endpoint descriptor. + * @return const usb_ep_desc_t* Pointer to endpoint descriptor, NULL if not found. + */ +const usb_ep_desc_t *usb_parse_endpoint_descriptor_by_index(const usb_intf_desc_t *intf_desc, int index, uint16_t wTotalLength, int *offset); + +/** + * @brief Get an endpoint descriptor based on an endpoint's address + * + * Given a configuration descriptor, get an endpoint descriptor based on it's bEndpointAddress, bAlternateSetting, and + * bInterfaceNumber. + * + * @param[in] config_desc Pointer to the start of a full configuration descriptor + * @param[in] bInterfaceNumber Interface number + * @param[in] bAlternateSetting Alternate setting number + * @param[in] bEndpointAddress Endpoint address + * @param[out] offset Byte offset of the endpoint descriptor relative to the start of the configuration descriptor. Can be NULL + * @return const usb_ep_desc_t* Pointer to endpoint descriptor, NULL if not found. + */ +const usb_ep_desc_t *usb_parse_endpoint_descriptor_by_address(const usb_config_desc_t *config_desc, uint8_t bInterfaceNumber, uint8_t bAlternateSetting, uint8_t bEndpointAddress, int *offset); + +// ------------------------------------------------------ Misc --------------------------------------------------------- + +/** + * @brief Round up to an integer multiple of endpoint's MPS + * + * This is a convenience function to round up a size/length to an endpoint's MPS (Maximum packet size). This is useful + * when calculating transfer or buffer lengths of IN endpoints. + * + * @param[in] num_bytes Number of bytes + * @param[in] mps MPS + * @return int Round up integer multiple of MPS + */ +static inline int usb_round_up_to_mps(int num_bytes, int mps) +{ + if (num_bytes < 0 || mps < 0) { + return 0; + } + return ((num_bytes + mps - 1) / mps) * mps; +} + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32s2/include/usb/include/usb/usb_host.h b/tools/sdk/esp32s2/include/usb/include/usb/usb_host.h new file mode 100644 index 00000000000..6c104af6cfd --- /dev/null +++ b/tools/sdk/esp32s2/include/usb/include/usb/usb_host.h @@ -0,0 +1,412 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* +Warning: The USB Host Library API is still a beta version and may be subject to change +*/ + +#pragma once + +#include +#include "freertos/FreeRTOS.h" +#include "esp_err.h" +#include "esp_intr_alloc.h" +//Include the other USB Host Library headers as well +#include "usb/usb_helpers.h" +#include "usb/usb_types_ch9.h" +#include "usb/usb_types_stack.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// ------------------------------------------------- Macros and Types -------------------------------------------------- + +// ----------------------- Handles ------------------------- + +typedef void * usb_host_client_handle_t; /**< Handle to a client using the USB Host Library */ + +// ----------------------- Events -------------------------- + +#define USB_HOST_LIB_EVENT_FLAGS_NO_CLIENTS 0x01 /**< All clients have been deregistered from the USB Host Library */ +#define USB_HOST_LIB_EVENT_FLAGS_ALL_FREE 0x02 /**< The USB Host Library has freed all devices */ + +/** + * @brief The type event in a client event message + */ +typedef enum { + USB_HOST_CLIENT_EVENT_NEW_DEV, /**< A new device has been enumerated and added to the USB Host Library */ + USB_HOST_CLIENT_EVENT_DEV_GONE, /**< A device opened by the client is now gone */ +} usb_host_client_event_t; + +/** + * @brief Client event message + * + * Client event messages are sent to each client of the USB Host Library in order to notify them of various + * USB Host Library events such as: + * - Addition of new devices + * - Removal of existing devices + * + * @note The event message structure has a union with members corresponding to each particular event. Based on the event + * type, only the relevant member field should be accessed. + */ +typedef struct { + usb_host_client_event_t event; /**< Type of event */ + union { + struct { + uint8_t address; /**< New device's address */ + } new_dev; + struct { + usb_device_handle_t dev_hdl; /**< The handle of the device that was gone */ + } dev_gone; + }; +} usb_host_client_event_msg_t; + +// ---------------------- Callbacks ------------------------ + +/** + * @brief Client event callback + * + * - Each client of the USB Host Library must register an event callback to receive event messages from the USB Host + * Library. + * - The client event callback is run from the context of the clients usb_host_client_handle_events() function + */ +typedef void (*usb_host_client_event_cb_t)(const usb_host_client_event_msg_t *event_msg, void *arg); + +// -------------------- Configurations --------------------- + +/** + * @brief USB Host Library configuration + * + * Configuration structure of the USB Host Library. Provided in the usb_host_install() function + */ +typedef struct { + int intr_flags; /**< Interrupt flags for the underlying ISR used by the USB Host stack */ +} usb_host_config_t; + +/** + * @brief USB Host Library Client configuration + * + * Configuration structure for a USB Host Library client. Provided in usb_host_client_register() + */ +typedef struct { + usb_host_client_event_cb_t client_event_callback; /**< Client's event callback function */ + void *callback_arg; /**< Event callback function argument */ + int max_num_event_msg; /**< Maximum number of event messages that can be stored (e.g., 3) */ +} usb_host_client_config_t; + +// ------------------------------------------------ Library Functions -------------------------------------------------- + +/** + * @brief Install the USB Host Library + * + * - This function should only once to install the USB Host Library + * - This function should be called before any other USB Host Library functions are called + * + * @param[in] config USB Host Library configuration + * @return esp_err_t + */ +esp_err_t usb_host_install(const usb_host_config_t *config); + +/** + * @brief Uninstall the USB Host Library + * + * - This function should be called to uninstall the USB Host Library, thereby freeing its resources + * - All clients must have been deregistered before calling this function + * - All devices must have been freed by calling usb_host_device_free_all() and receiving the + * USB_HOST_LIB_EVENT_FLAGS_ALL_FREE event flag + * + * @return esp_err_t + */ +esp_err_t usb_host_uninstall(void); + +/** + * @brief Handle USB Host Library events + * + * - This function handles all of the USB Host Library's processing and should be called repeatedly in a loop + * - Check event_flags_ret to see if an flags are set indicating particular USB Host Library events + * + * @param[in] timeout_ticks Timeout in ticks to wait for an event to occur + * @param[out] event_flags_ret Event flags that indicate what USB Host Library event occurred + * @return esp_err_t + */ +esp_err_t usb_host_lib_handle_events(TickType_t timeout_ticks, uint32_t *event_flags_ret); + +// ------------------------------------------------ Client Functions --------------------------------------------------- + +/** + * @brief Register a client of the USB Host Library + * + * - This function registers a client of the USB Host Library + * - Once a client is registered, its processing function usb_host_client_handle_events() should be called repeatedly + * + * @param[in] client_config Client configuration + * @param[out] client_hdl_ret Client handle + * @return esp_err_t + */ +esp_err_t usb_host_client_register(const usb_host_client_config_t *client_config, usb_host_client_handle_t *client_hdl_ret); + +/** + * @brief Deregister a USB Host Library client + * + * - This function deregisters a client of the USB Host Library + * - The client must have closed all previously opened devices before attempting to deregister + * + * @param[in] client_hdl Client handle + * @return esp_err_t + */ +esp_err_t usb_host_client_deregister(usb_host_client_handle_t client_hdl); + +/** + * @brief USB Host Library client processing function + * + * - This function handles all of a client's processing and should be called repeatedly in a loop + * + * @param[in] client_hdl Client handle + * @param[in] timeout_ticks Timeout in ticks to wait for an event to occur + * @return esp_err_t + */ +esp_err_t usb_host_client_handle_events(usb_host_client_handle_t client_hdl, TickType_t timeout_ticks); + +/** + * @brief Unblock a client + * + * - This function simply unblocks a client if it is blocked on the usb_host_client_handle_events() function. + * - This function is useful when need to unblock a client in order to deregister it. + * + * @param[in] client_hdl Client handle + * @return esp_err_t + */ +esp_err_t usb_host_client_unblock(usb_host_client_handle_t client_hdl); + +// ------------------------------------------------- Device Handling --------------------------------------------------- + +/** + * @brief Open a device + * + * - This function allows a client to open a device + * - A client must open a device first before attempting to use it (e.g., sending transfers, device requests etc.) + * + * @param[in] client_hdl Client handle + * @param[in] dev_addr Device's address + * @param[out] dev_hdl_ret Device's handle + * @return esp_err_t + */ +esp_err_t usb_host_device_open(usb_host_client_handle_t client_hdl, uint8_t dev_addr, usb_device_handle_t *dev_hdl_ret); + +/** + * @brief Close a device + * + * - This function allows a client to close a device + * - A client must close a device after it has finished using the device (claimed interfaces must also be released) + * - A client must close all devices it has opened before deregistering + * + * @param[in] client_hdl Client handle + * @param[in] dev_hdl Device handle + * @return esp_err_t + */ +esp_err_t usb_host_device_close(usb_host_client_handle_t client_hdl, usb_device_handle_t dev_hdl); + +/** + * @brief Indicate that all devices can be freed when possible + * + * - This function marks all devices as waiting to be freed + * - If a device is not opened by any clients, it will be freed immediately + * - If a device is opened by at least one client, the device will be free when the last client closes that device. + * - Wait for the USB_HOST_LIB_EVENT_FLAGS_ALL_FREE flag to be set by usb_host_lib_handle_events() in order to know + * when all devices have been freed + * - This function is useful when cleaning up devices before uninstalling the USB Host Library + * + * @return esp_err_t + */ +esp_err_t usb_host_device_free_all(void); + +// ------------------------------------------------- Device Requests --------------------------------------------------- + +// ------------------- Cached Requests --------------------- + +/** + * @brief Get device's information + * + * - This function gets some basic information of a device + * - The device must be opened first before attempting to get its information + * + * @param[in] dev_hdl Device handle + * @param[out] dev_info Device information + * @return esp_err_t + */ +esp_err_t usb_host_device_info(usb_device_handle_t dev_hdl, usb_device_info_t *dev_info); + +// ----------------------------------------------- Descriptor Requests ------------------------------------------------- + +// ----------------- Cached Descriptors -------------------- + +/** + * @brief Get device's device descriptor + * + * - A client must call usb_host_device_open() first + * - No control transfer is sent. The device's descriptor is cached on enumeration + * - This function simple returns a pointer to the cached descriptor + * + * @note No control transfer is sent. The device's descriptor is cached on enumeration + * @param[in] dev_hdl Device handle + * @param[out] device_desc Device descriptor + * @return esp_err_t + */ +esp_err_t usb_host_get_device_descriptor(usb_device_handle_t dev_hdl, const usb_device_desc_t **device_desc); + +/** + * @brief Get device's active configuration descriptor + * + * - A client must call usb_host_device_open() first + * - No control transfer is sent. The device's active configuration descriptor is cached on enumeration + * - This function simple returns a pointer to the cached descriptor + * + * @note No control transfer is sent. A device's active configuration descriptor is cached on enumeration + * @param[in] dev_hdl Device handle + * @param[out] config_desc Configuration descriptor + * @return esp_err_t + */ +esp_err_t usb_host_get_active_config_descriptor(usb_device_handle_t dev_hdl, const usb_config_desc_t **config_desc); + +// ----------------------------------------------- Interface Functions ------------------------------------------------- + +/** + * @brief Function for a client to claim a device's interface + * + * - A client must claim a device's interface before attempting to communicate with any of its endpoints + * - Once an interface is claimed by a client, it cannot be claimed by any other client. + * + * @param[in] client_hdl Client handle + * @param[in] dev_hdl Device handle + * @param[in] bInterfaceNumber Interface number + * @param[in] bAlternateSetting Interface alternate setting number + * @return esp_err_t + */ +esp_err_t usb_host_interface_claim(usb_host_client_handle_t client_hdl, usb_device_handle_t dev_hdl, uint8_t bInterfaceNumber, uint8_t bAlternateSetting); + +/** + * @brief Function for a client to release a previously claimed interface + * + * - A client should release a device's interface after it no longer needs to communicate with the interface + * - A client must release all of its interfaces of a device it has claimed before being able to close the device + * + * @param[in] client_hdl Client handle + * @param[in] dev_hdl Device handle + * @param[in] bInterfaceNumber Interface number + * @return esp_err_t + */ +esp_err_t usb_host_interface_release(usb_host_client_handle_t client_hdl, usb_device_handle_t dev_hdl, uint8_t bInterfaceNumber); + +/** + * @brief Halt a particular endpoint + * + * - The device must have been opened by a client + * - The endpoint must be part of an interface claimed by a client + * - Once halted, the endpoint must be cleared using usb_host_endpoint_clear() before it can communicate again + * + * @param dev_hdl Device handle + * @param bEndpointAddress Endpoint address + * @return esp_err_t + */ +esp_err_t usb_host_endpoint_halt(usb_device_handle_t dev_hdl, uint8_t bEndpointAddress); + +/** + * @brief Flush a particular endpoint + * + * - The device must have been opened by a client + * - The endpoint must be part of an interface claimed by a client + * - The endpoint must have been halted (either through a transfer error, or usb_host_endpoint_halt()) + * - Flushing an endpoint will caused an queued up transfers to be canceled + * + * @param dev_hdl Device handle + * @param bEndpointAddress Endpoint address + * @return esp_err_t + */ +esp_err_t usb_host_endpoint_flush(usb_device_handle_t dev_hdl, uint8_t bEndpointAddress); + +/** + * @brief Clear a halt on a particular endpoint + * + * - The device must have been opened by a client + * - The endpoint must be part of an interface claimed by a client + * - The endpoint must have been halted (either through a transfer error, or usb_host_endpoint_halt()) + * - If the endpoint has any queued up transfers, clearing a halt will resume their execution + * + * @param dev_hdl Device handle + * @param bEndpointAddress Endpoint address + * @return esp_err_t + */ +esp_err_t usb_host_endpoint_clear(usb_device_handle_t dev_hdl, uint8_t bEndpointAddress); + +// ------------------------------------------------ Asynchronous I/O --------------------------------------------------- + +/** + * @brief Allocate a transfer object + * + * - This function allocates a transfer object + * - Each transfer object has a fixed sized buffer specified on allocation + * - A transfer object can be re-used indefinitely + * - A transfer can be submitted using usb_host_transfer_submit() or usb_host_transfer_submit_control() + * + * @param[in] data_buffer_size Size of the transfer's data buffer + * @param[in] num_isoc_packets Number of isochronous packets in transfer (set to 0 for non-isochronous transfers) + * @param[out] transfer Transfer object + * @return esp_err_t + */ +esp_err_t usb_host_transfer_alloc(size_t data_buffer_size, int num_isoc_packets, usb_transfer_t **transfer); + +/** + * @brief Free a transfer object + * + * - Free a transfer object previously allocated using usb_host_transfer_alloc() + * - The transfer must not be in-flight when attempting to free it + * + * @param[in] transfer Transfer object + * @return esp_err_t + */ +esp_err_t usb_host_transfer_free(usb_transfer_t *transfer); + +/** + * @brief Submit a non-control transfer + * + * - Submit a transfer to a particular endpoint. The device and endpoint number is specified inside the transfer + * - The transfer must be properly initialized before submitting + * - On completion, the transfer's callback will be called from the client's usb_host_client_handle_events() function. + * + * @param[in] transfer Initialized transfer object + * @return esp_err_t + */ +esp_err_t usb_host_transfer_submit(usb_transfer_t *transfer); + +/** + * @brief Submit a control transfer + * + * - Submit a control transfer to a particular device. The client must have opened the device first + * - The transfer must be properly initialized before submitting. The first 8 bytes of the transfer's data buffer should + * contain the control transfer setup packet + * - On completion, the transfer's callback will be called from the client's usb_host_client_handle_events() function. + * + * @param[in] client_hdl Client handle + * @param[in] transfer Initialized transfer object + * @return esp_err_t + */ +esp_err_t usb_host_transfer_submit_control(usb_host_client_handle_t client_hdl, usb_transfer_t *transfer); + +/** + * @brief Cancel a submitted transfer + * + * - Cancel a previously submitted transfer + * - In its current implementation, any transfer that is already in-flight will not be canceled + * + * @param transfer Transfer object + * @return esp_err_t + */ +esp_err_t usb_host_transfer_cancel(usb_transfer_t *transfer); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32s2/include/usb/include/usb/usb_types_ch9.h b/tools/sdk/esp32s2/include/usb/include/usb/usb_types_ch9.h new file mode 100644 index 00000000000..7d40bc46e0e --- /dev/null +++ b/tools/sdk/esp32s2/include/usb/include/usb/usb_types_ch9.h @@ -0,0 +1,474 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* +Warning: The USB Host Library API is still a beta version and may be subject to change +*/ + +#pragma once + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define USB_DESC_ATTR __attribute__((packed)) + +// ---------------------------------------------------- Chapter 9 ------------------------------------------------------ + +/** + * @brief USB2.0 device states + * + * See Table 9-1 of USB2.0 specification for more details + * + * @note The USB_DEVICE_STATE_NOT_ATTACHED is not part of the USB2.0 specification, but is a catch all state for devices + * that need to be cleaned up after a sudden disconnection or port error. + */ +typedef enum { + USB_DEVICE_STATE_NOT_ATTACHED, /**< The device was previously configured or suspended, but is no longer attached (either suddenly disconnected or a port error) */ + USB_DEVICE_STATE_ATTACHED, /**< Device is attached to the USB, but is not powered. */ + USB_DEVICE_STATE_POWERED, /**< Device is attached to the USB and powered, but has not been reset. */ + USB_DEVICE_STATE_DEFAULT, /**< Device is attached to the USB and powered and has been reset, but has not been assigned a unique address. Device responds at the default address. */ + USB_DEVICE_STATE_ADDRESS, /**< Device is attached to the USB, powered, has been reset, and a unique device address has been assigned. Device is not configured. */ + USB_DEVICE_STATE_CONFIGURED, /**< Device is attached to the USB, powered, has been reset, has a unique address, is configured, and is not suspended. The host may now use the function provided by the device. */ + USB_DEVICE_STATE_SUSPENDED, /**< Device is, at minimum, attached to the USB and is powered and has not seen bus activity for 3 ms. It may also have a unique address and be configured for use. However, because the device is suspended, the host may not use the device’s function. */ +} usb_device_state_t; + +/** + * @brief Descriptor types from USB2.0 specification table 9.5 + */ +#define USB_B_DESCRIPTOR_TYPE_DEVICE 0x01 +#define USB_B_DESCRIPTOR_TYPE_CONFIGURATION 0x02 +#define USB_B_DESCRIPTOR_TYPE_STRING 0x03 +#define USB_B_DESCRIPTOR_TYPE_INTERFACE 0x04 +#define USB_B_DESCRIPTOR_TYPE_ENDPOINT 0x05 +#define USB_B_DESCRIPTOR_TYPE_DEVICE_QUALIFIER 0x06 +#define USB_B_DESCRIPTOR_TYPE_OTHER_SPEED_CONFIGURATION 0x07 +#define USB_B_DESCRIPTOR_TYPE_INTERFACE_POWER 0x08 + +/** + * @brief Descriptor types from USB 2.0 ECN + */ +#define USB_B_DESCRIPTOR_TYPE_OTG 0x09 +#define USB_B_DESCRIPTOR_TYPE_DEBUG 0x0a +#define USB_B_DESCRIPTOR_TYPE_INTERFACE_ASSOCIATION 0x0b + +/** + * @brief Descriptor types from Wireless USB spec + */ +#define USB_B_DESCRIPTOR_TYPE_SECURITY 0x0c +#define USB_B_DESCRIPTOR_TYPE_KEY 0x0d +#define USB_B_DESCRIPTOR_TYPE_ENCRYPTION_TYPE 0x0e +#define USB_B_DESCRIPTOR_TYPE_BOS 0x0f +#define USB_B_DESCRIPTOR_TYPE_DEVICE_CAPABILITY 0x10 +#define USB_B_DESCRIPTOR_TYPE_WIRELESS_ENDPOINT_COMP 0x11 +#define USB_B_DESCRIPTOR_TYPE_WIRE_ADAPTER 0x21 +#define USB_B_DESCRIPTOR_TYPE_RPIPE 0x22 +#define USB_B_DESCRIPTOR_TYPE_CS_RADIO_CONTROL 0x23 + +/** + * @brief Descriptor types from UAS specification + */ +#define USB_B_DESCRIPTOR_TYPE_PIPE_USAGE 0x24 + +// -------------------- Setup Packet ----------------------- + +/** + * @brief Size of a USB control transfer setup packet in bytes + */ +#define USB_SETUP_PACKET_SIZE 8 + +/** + * @brief Structure representing a USB control transfer setup packet + * + * See Table 9-2 of USB2.0 specification for more details + */ +typedef union { + struct { + uint8_t bmRequestType; /**< Characteristics of request */ + uint8_t bRequest; /**< Specific request */ + uint16_t wValue; /**< Word-sized field that varies according to request */ + uint16_t wIndex; /**< Word-sized field that varies according to request; typically used to pass an index or offset */ + uint16_t wLength; /**< Number of bytes to transfer if there is a data stage */ + } __attribute__((packed)); + uint8_t val[USB_SETUP_PACKET_SIZE]; +} usb_setup_packet_t; +_Static_assert(sizeof(usb_setup_packet_t) == USB_SETUP_PACKET_SIZE, "Size of usb_setup_packet_t incorrect"); + +/** + * @brief Bit masks belonging to the bmRequestType field of a setup packet + */ +#define USB_BM_REQUEST_TYPE_DIR_OUT (0X00 << 7) +#define USB_BM_REQUEST_TYPE_DIR_IN (0x01 << 7) +#define USB_BM_REQUEST_TYPE_TYPE_STANDARD (0x00 << 5) +#define USB_BM_REQUEST_TYPE_TYPE_CLASS (0x01 << 5) +#define USB_BM_REQUEST_TYPE_TYPE_VENDOR (0x02 << 5) +#define USB_BM_REQUEST_TYPE_TYPE_RESERVED (0x03 << 5) +#define USB_BM_REQUEST_TYPE_TYPE_MASK (0x03 << 5) +#define USB_BM_REQUEST_TYPE_RECIP_DEVICE (0x00 << 0) +#define USB_BM_REQUEST_TYPE_RECIP_INTERFACE (0x01 << 0) +#define USB_BM_REQUEST_TYPE_RECIP_ENDPOINT (0x02 << 0) +#define USB_BM_REQUEST_TYPE_RECIP_OTHER (0x03 << 0) +#define USB_BM_REQUEST_TYPE_RECIP_MASK (0x1f << 0) + +/** + * @brief Bit masks belonging to the bRequest field of a setup packet + */ +#define USB_B_REQUEST_GET_STATUS 0x00 +#define USB_B_REQUEST_CLEAR_FEATURE 0x01 +#define USB_B_REQUEST_SET_FEATURE 0x03 +#define USB_B_REQUEST_SET_ADDRESS 0x05 +#define USB_B_REQUEST_GET_DESCRIPTOR 0x06 +#define USB_B_REQUEST_SET_DESCRIPTOR 0x07 +#define USB_B_REQUEST_GET_CONFIGURATION 0x08 +#define USB_B_REQUEST_SET_CONFIGURATION 0x09 +#define USB_B_REQUEST_GET_INTERFACE 0x0A +#define USB_B_REQUEST_SET_INTERFACE 0x0B +#define USB_B_REQUEST_SYNCH_FRAME 0x0C + +/** + * @brief Bit masks belonging to the wValue field of a setup packet + */ +#define USB_W_VALUE_DT_DEVICE 0x01 +#define USB_W_VALUE_DT_CONFIG 0x02 +#define USB_W_VALUE_DT_STRING 0x03 +#define USB_W_VALUE_DT_INTERFACE 0x04 +#define USB_W_VALUE_DT_ENDPOINT 0x05 +#define USB_W_VALUE_DT_DEVICE_QUALIFIER 0x06 +#define USB_W_VALUE_DT_OTHER_SPEED_CONFIG 0x07 +#define USB_W_VALUE_DT_INTERFACE_POWER 0x08 + +/** + * @brief Initializer for a SET_ADDRESS request + * + * Sets the address of a connected device + */ +#define USB_SETUP_PACKET_INIT_SET_ADDR(setup_pkt_ptr, addr) ({ \ + (setup_pkt_ptr)->bmRequestType = USB_BM_REQUEST_TYPE_DIR_OUT | USB_BM_REQUEST_TYPE_TYPE_STANDARD |USB_BM_REQUEST_TYPE_RECIP_DEVICE; \ + (setup_pkt_ptr)->bRequest = USB_B_REQUEST_SET_ADDRESS; \ + (setup_pkt_ptr)->wValue = (addr); \ + (setup_pkt_ptr)->wIndex = 0; \ + (setup_pkt_ptr)->wLength = 0; \ +}) + +/** + * @brief Initializer for a request to get a device's device descriptor + */ +#define USB_SETUP_PACKET_INIT_GET_DEVICE_DESC(setup_pkt_ptr) ({ \ + (setup_pkt_ptr)->bmRequestType = USB_BM_REQUEST_TYPE_DIR_IN | USB_BM_REQUEST_TYPE_TYPE_STANDARD | USB_BM_REQUEST_TYPE_RECIP_DEVICE; \ + (setup_pkt_ptr)->bRequest = USB_B_REQUEST_GET_DESCRIPTOR; \ + (setup_pkt_ptr)->wValue = (USB_W_VALUE_DT_DEVICE << 8); \ + (setup_pkt_ptr)->wIndex = 0; \ + (setup_pkt_ptr)->wLength = 18; \ +}) + +/** + * @brief Initializer for a request to get a device's current configuration number + */ +#define USB_SETUP_PACKET_INIT_GET_CONFIG(setup_pkt_ptr) ({ \ + (setup_pkt_ptr)->bmRequestType = USB_BM_REQUEST_TYPE_DIR_IN | USB_BM_REQUEST_TYPE_TYPE_STANDARD | USB_BM_REQUEST_TYPE_RECIP_DEVICE; \ + (setup_pkt_ptr)->bRequest = USB_B_REQUEST_GET_CONFIGURATION; \ + (setup_pkt_ptr)->wValue = 0; \ + (setup_pkt_ptr)->wIndex = 0; \ + (setup_pkt_ptr)->wLength = 1; \ +}) + +/** + * @brief Initializer for a request to get one of the device's current configuration descriptor + * + * - desc_index indicates the configuration's index number + * - Number of bytes of the configuration descriptor to get + */ +#define USB_SETUP_PACKET_INIT_GET_CONFIG_DESC(setup_pkt_ptr, desc_index, desc_len) ({ \ + (setup_pkt_ptr)->bmRequestType = USB_BM_REQUEST_TYPE_DIR_IN | USB_BM_REQUEST_TYPE_TYPE_STANDARD | USB_BM_REQUEST_TYPE_RECIP_DEVICE; \ + (setup_pkt_ptr)->bRequest = USB_B_REQUEST_GET_DESCRIPTOR; \ + (setup_pkt_ptr)->wValue = (USB_W_VALUE_DT_CONFIG << 8) | ((desc_index) & 0xFF); \ + (setup_pkt_ptr)->wIndex = 0; \ + (setup_pkt_ptr)->wLength = (desc_len); \ +}) + +/** + * @brief Initializer for a request to set a device's current configuration number + */ +#define USB_SETUP_PACKET_INIT_SET_CONFIG(setup_pkt_ptr, config_num) ({ \ + (setup_pkt_ptr)->bmRequestType = USB_BM_REQUEST_TYPE_DIR_OUT | USB_BM_REQUEST_TYPE_TYPE_STANDARD | USB_BM_REQUEST_TYPE_RECIP_DEVICE; \ + (setup_pkt_ptr)->bRequest = USB_B_REQUEST_SET_CONFIGURATION; \ + (setup_pkt_ptr)->wValue = (config_num); \ + (setup_pkt_ptr)->wIndex = 0; \ + (setup_pkt_ptr)->wLength = 0; \ +}) + +/** + * @brief Initializer for a request to set an interface's alternate setting + */ +#define USB_SETUP_PACKET_INIT_SET_INTERFACE(setup_pkt_ptr, intf_num, alt_setting_num) ({ \ + (setup_pkt_ptr)->bmRequestType = USB_BM_REQUEST_TYPE_DIR_OUT | USB_BM_REQUEST_TYPE_TYPE_STANDARD | USB_BM_REQUEST_TYPE_RECIP_INTERFACE; \ + (setup_pkt_ptr)->bRequest = USB_B_REQUEST_SET_INTERFACE; \ + (setup_pkt_ptr)->wValue = (alt_setting_num); \ + (setup_pkt_ptr)->wIndex = (intf_num); \ + (setup_pkt_ptr)->wLength = 0; \ +}) + +// ---------------- Standard Descriptor -------------------- + +/** + * @brief Size of dummy USB standard descriptor + */ +#define USB_STANDARD_DESC_SIZE 2 + +/** + * @brief USB standard descriptor + * + * All USB standard descriptors start with these two bytes. Use this type when traversing over configuration descriptors + */ +typedef union { + struct { + uint8_t bLength; /**< Size of the descriptor in bytes */ + uint8_t bDescriptorType; /**< Descriptor Type */ + } USB_DESC_ATTR; + uint8_t val[USB_STANDARD_DESC_SIZE]; +} usb_standard_desc_t; +_Static_assert(sizeof(usb_standard_desc_t) == USB_STANDARD_DESC_SIZE, "Size of usb_standard_desc_t incorrect"); + +// ------------------ Device Descriptor -------------------- + +/** + * @brief Size of a USB device descriptor in bytes + */ +#define USB_DEVICE_DESC_SIZE 18 + +/** + * @brief Structure representing a USB device descriptor + * + * See Table 9-8 of USB2.0 specification for more details + */ +typedef union { + struct { + uint8_t bLength; /**< Size of the descriptor in bytes */ + uint8_t bDescriptorType; /**< DEVICE Descriptor Type */ + uint16_t bcdUSB; /**< USB Specification Release Number in Binary-Coded Decimal (i.e., 2.10 is 210H) */ + uint8_t bDeviceClass; /**< Class code (assigned by the USB-IF) */ + uint8_t bDeviceSubClass; /**< Subclass code (assigned by the USB-IF) */ + uint8_t bDeviceProtocol; /**< Protocol code (assigned by the USB-IF) */ + uint8_t bMaxPacketSize0; /**< Maximum packet size for endpoint zero (only 8, 16, 32, or 64 are valid) */ + uint16_t idVendor; /**< Vendor ID (assigned by the USB-IF) */ + uint16_t idProduct; /**< Product ID (assigned by the manufacturer) */ + uint16_t bcdDevice; /**< Device release number in binary-coded decimal */ + uint8_t iManufacturer; /**< Index of string descriptor describing manufacturer */ + uint8_t iProduct; /**< Index of string descriptor describing product */ + uint8_t iSerialNumber; /**< Index of string descriptor describing the device’s serial number */ + uint8_t bNumConfigurations; /**< Number of possible configurations */ + } USB_DESC_ATTR; + uint8_t val[USB_DEVICE_DESC_SIZE]; +} usb_device_desc_t; +_Static_assert(sizeof(usb_device_desc_t) == USB_DEVICE_DESC_SIZE, "Size of usb_device_desc_t incorrect"); + +/** + * @brief Possible base class values of the bDeviceClass field of a USB device descriptor + */ +#define USB_CLASS_PER_INTERFACE 0x00 +#define USB_CLASS_AUDIO 0x01 +#define USB_CLASS_COMM 0x02 +#define USB_CLASS_HID 0x03 +#define USB_CLASS_PHYSICAL 0x05 +#define USB_CLASS_STILL_IMAGE 0x06 +#define USB_CLASS_PRINTER 0x07 +#define USB_CLASS_MASS_STORAGE 0x08 +#define USB_CLASS_HUB 0x09 +#define USB_CLASS_CDC_DATA 0x0a +#define USB_CLASS_CSCID 0x0b +#define USB_CLASS_CONTENT_SEC 0x0d +#define USB_CLASS_VIDEO 0x0e +#define USB_CLASS_WIRELESS_CONTROLLER 0xe0 +#define USB_CLASS_PERSONAL_HEALTHCARE 0x0f +#define USB_CLASS_AUDIO_VIDEO 0x10 +#define USB_CLASS_BILLBOARD 0x11 +#define USB_CLASS_USB_TYPE_C_BRIDGE 0x12 +#define USB_CLASS_MISC 0xef +#define USB_CLASS_APP_SPEC 0xfe +#define USB_CLASS_VENDOR_SPEC 0xff + +/** + * @brief Vendor specific subclass code + */ +#define USB_SUBCLASS_VENDOR_SPEC 0xff + +// -------------- Configuration Descriptor ----------------- + +/** + * @brief Size of a short USB configuration descriptor in bytes + * + * @note The size of a full USB configuration includes all the interface and endpoint + * descriptors of that configuration. + */ +#define USB_CONFIG_DESC_SIZE 9 + +/** + * @brief Structure representing a short USB configuration descriptor + * + * See Table 9-10 of USB2.0 specification for more details + * + * @note The full USB configuration includes all the interface and endpoint + * descriptors of that configuration. + */ +typedef union { + struct { + uint8_t bLength; /**< Size of the descriptor in bytes */ + uint8_t bDescriptorType; /**< CONFIGURATION Descriptor Type */ + uint16_t wTotalLength; /**< Total length of data returned for this configuration */ + uint8_t bNumInterfaces; /**< Number of interfaces supported by this configuration */ + uint8_t bConfigurationValue; /**< Value to use as an argument to the SetConfiguration() request to select this configuration */ + uint8_t iConfiguration; /**< Index of string descriptor describing this configuration */ + uint8_t bmAttributes; /**< Configuration characteristics */ + uint8_t bMaxPower; /**< Maximum power consumption of the USB device from the bus in this specific configuration when the device is fully operational. */ + } USB_DESC_ATTR; + uint8_t val[USB_CONFIG_DESC_SIZE]; +} usb_config_desc_t; +_Static_assert(sizeof(usb_config_desc_t) == USB_CONFIG_DESC_SIZE, "Size of usb_config_desc_t incorrect"); + +/** + * @brief Bit masks belonging to the bmAttributes field of a configuration descriptor + */ +#define USB_BM_ATTRIBUTES_ONE (1 << 7) //Must be set +#define USB_BM_ATTRIBUTES_SELFPOWER (1 << 6) //Self powered +#define USB_BM_ATTRIBUTES_WAKEUP (1 << 5) //Can wake-up +#define USB_BM_ATTRIBUTES_BATTERY (1 << 4) //Battery powered + +// ---------- Interface Association Descriptor ------------- + +/** + * @brief Size of a USB interface association descriptor in bytes + */ +#define USB_IAD_DESC_SIZE 9 + +/** + * @brief Structure representing a USB interface association descriptor + */ +typedef union { + struct { + uint8_t bLength; /**< Size of the descriptor in bytes */ + uint8_t bDescriptorType; /**< INTERFACE ASSOCIATION Descriptor Type */ + uint8_t bFirstInterface; /**< Interface number of the first interface that is associated with this function */ + uint8_t bInterfaceCount; /**< Number of contiguous interfaces that are associated with this function */ + uint8_t bFunctionClass; /**< Class code (assigned by USB-IF) */ + uint8_t bFunctionSubClass; /**< Subclass code (assigned by USB-IF) */ + uint8_t bFunctionProtocol; /**< Protocol code (assigned by USB-IF) */ + uint8_t iFunction; /**< Index of string descriptor describing this function */ + } USB_DESC_ATTR; + uint8_t val[USB_IAD_DESC_SIZE]; +} usb_iad_desc_t; +_Static_assert(sizeof(usb_iad_desc_t) == USB_IAD_DESC_SIZE, "Size of usb_iad_desc_t incorrect"); + +// ---------------- Interface Descriptor ------------------- + +/** + * @brief Size of a USB interface descriptor in bytes + */ +#define USB_INTF_DESC_SIZE 9 + +/** + * @brief Structure representing a USB interface descriptor + * + * See Table 9-12 of USB2.0 specification for more details + */ +typedef union { + struct { + uint8_t bLength; /**< Size of the descriptor in bytes */ + uint8_t bDescriptorType; /**< INTERFACE Descriptor Type */ + uint8_t bInterfaceNumber; /**< Number of this interface. */ + uint8_t bAlternateSetting; /**< Value used to select this alternate setting for the interface identified in the prior field */ + uint8_t bNumEndpoints; /**< Number of endpoints used by this interface (excluding endpoint zero). */ + uint8_t bInterfaceClass; /**< Class code (assigned by the USB-IF) */ + uint8_t bInterfaceSubClass; /**< Subclass code (assigned by the USB-IF) */ + uint8_t bInterfaceProtocol; /**< Protocol code (assigned by the USB) */ + uint8_t iInterface; /**< Index of string descriptor describing this interface */ + } USB_DESC_ATTR; + uint8_t val[USB_INTF_DESC_SIZE]; +} usb_intf_desc_t; +_Static_assert(sizeof(usb_intf_desc_t) == USB_INTF_DESC_SIZE, "Size of usb_intf_desc_t incorrect"); + +// ----------------- Endpoint Descriptor ------------------- + +/** + * @brief Size of a USB endpoint descriptor in bytes + */ +#define USB_EP_DESC_SIZE 7 + +/** + * @brief Structure representing a USB endpoint descriptor + * + * See Table 9-13 of USB2.0 specification for more details + */ +typedef union { + struct { + uint8_t bLength; /**< Size of the descriptor in bytes */ + uint8_t bDescriptorType; /**< ENDPOINT Descriptor Type */ + uint8_t bEndpointAddress; /**< The address of the endpoint on the USB device described by this descriptor */ + uint8_t bmAttributes; /**< This field describes the endpoint’s attributes when it is configured using the bConfigurationValue. */ + uint16_t wMaxPacketSize; /**< Maximum packet size this endpoint is capable of sending or receiving when this configuration is selected. */ + uint8_t bInterval; /**< Interval for polling Isochronous and Interrupt endpoints. Expressed in frames or microframes depending on the device operating speed (1 ms for Low-Speed and Full-Speed or 125 us for USB High-Speed and above). */ + } USB_DESC_ATTR; + uint8_t val[USB_EP_DESC_SIZE]; +} usb_ep_desc_t; +_Static_assert(sizeof(usb_ep_desc_t) == USB_EP_DESC_SIZE, "Size of usb_ep_desc_t incorrect"); + +/** + * @brief Bit masks belonging to the bEndpointAddress field of an endpoint descriptor + */ +#define USB_B_ENDPOINT_ADDRESS_EP_NUM_MASK 0x0f +#define USB_B_ENDPOINT_ADDRESS_EP_DIR_MASK 0x80 + +/** + * @brief Bit masks belonging to the bmAttributes field of an endpoint descriptor + */ +#define USB_BM_ATTRIBUTES_XFERTYPE_MASK 0x03 +#define USB_BM_ATTRIBUTES_XFER_CONTROL (0 << 0) +#define USB_BM_ATTRIBUTES_XFER_ISOC (1 << 0) +#define USB_BM_ATTRIBUTES_XFER_BULK (2 << 0) +#define USB_BM_ATTRIBUTES_XFER_INT (3 << 0) +#define USB_BM_ATTRIBUTES_SYNCTYPE_MASK 0x0C /* in bmAttributes */ +#define USB_BM_ATTRIBUTES_SYNC_NONE (0 << 2) +#define USB_BM_ATTRIBUTES_SYNC_ASYNC (1 << 2) +#define USB_BM_ATTRIBUTES_SYNC_ADAPTIVE (2 << 2) +#define USB_BM_ATTRIBUTES_SYNC_SYNC (3 << 2) +#define USB_BM_ATTRIBUTES_USAGETYPE_MASK 0x30 +#define USB_BM_ATTRIBUTES_USAGE_DATA (0 << 4) +#define USB_BM_ATTRIBUTES_USAGE_FEEDBACK (1 << 4) +#define USB_BM_ATTRIBUTES_USAGE_IMPLICIT_FB (2 << 4) + +/** + * @brief Macro helpers to get information about an endpoint from its descriptor + */ +#define USB_EP_DESC_GET_XFERTYPE(desc_ptr) ((usb_transfer_type_t) ((desc_ptr)->bmAttributes & USB_BM_ATTRIBUTES_XFERTYPE_MASK)) +#define USB_EP_DESC_GET_EP_NUM(desc_ptr) ((desc_ptr)->bEndpointAddress & USB_B_ENDPOINT_ADDRESS_EP_NUM_MASK) +#define USB_EP_DESC_GET_EP_DIR(desc_ptr) (((desc_ptr)->bEndpointAddress & USB_B_ENDPOINT_ADDRESS_EP_DIR_MASK) ? 1 : 0) +#define USB_EP_DESC_GET_MPS(desc_ptr) ((desc_ptr)->wMaxPacketSize & 0x7FF) + +// ------------------ String Descriptor -------------------- + +/** + * @brief Size of a short USB string descriptor in bytes + */ +#define USB_STR_DESC_SIZE 4 + +/** + * @brief Structure representing a USB string descriptor + */ +typedef union { + struct { + uint8_t bLength; /**< Size of the descriptor in bytes */ + uint8_t bDescriptorType; /**< STRING Descriptor Type */ + uint16_t wData[1]; /**< UTF-16LE encoded */ + } USB_DESC_ATTR; + uint8_t val[USB_STR_DESC_SIZE]; +} usb_str_desc_t; +_Static_assert(sizeof(usb_str_desc_t) == USB_STR_DESC_SIZE, "Size of usb_str_desc_t incorrect"); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32s2/include/usb/include/usb/usb_types_stack.h b/tools/sdk/esp32s2/include/usb/include/usb/usb_types_stack.h new file mode 100644 index 00000000000..438c22d9ef3 --- /dev/null +++ b/tools/sdk/esp32s2/include/usb/include/usb/usb_types_stack.h @@ -0,0 +1,141 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* +Warning: The USB Host Library API is still a beta version and may be subject to change +*/ + +#pragma once + +#include "usb/usb_types_ch9.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// ------------------------------------------------ Protocol Standard -------------------------------------------------- + +/** + * @brief USB Standard Speeds + */ +typedef enum { + USB_SPEED_LOW = 0, /**< USB Low Speed (1.5 Mbit/s) */ + USB_SPEED_FULL, /**< USB Full Speed (12 Mbit/s) */ +} usb_speed_t; + +/** + * @brief The type of USB transfer + * + * @note The enum values need to match the bmAttributes field of an EP descriptor + */ +typedef enum { + USB_TRANSFER_TYPE_CTRL = 0, + USB_TRANSFER_TYPE_ISOCHRONOUS, + USB_TRANSFER_TYPE_BULK, + USB_TRANSFER_TYPE_INTR, +} usb_transfer_type_t; + +// ------------------------------------------------- Device Related ---------------------------------------------------- + +/** + * @brief Handle of a USB Device connected to a USB Host + */ +typedef void * usb_device_handle_t; + +/** + * @brief Basic information of an enumerated device + */ +typedef struct { + usb_speed_t speed; /**< Device's speed */ + uint8_t dev_addr; /**< Device's address */ + uint8_t bMaxPacketSize0; /**< The maximum packet size of the device's default endpoint */ + uint8_t bConfigurationValue; /**< Device's current configuration number */ +} usb_device_info_t; + +// ------------------------------------------------ Transfer Related --------------------------------------------------- + +/** + * @brief The status of a particular transfer + */ +typedef enum { + USB_TRANSFER_STATUS_COMPLETED, /**< The transfer was successful (but may be short) */ + USB_TRANSFER_STATUS_ERROR, /**< The transfer failed because due to excessive errors (e.g. no response or CRC error) */ + USB_TRANSFER_STATUS_TIMED_OUT, /**< The transfer failed due to a time out */ + USB_TRANSFER_STATUS_CANCELED, /**< The transfer was canceled */ + USB_TRANSFER_STATUS_STALL, /**< The transfer was stalled */ + USB_TRANSFER_STATUS_OVERFLOW, /**< The transfer as more data was sent than was requested */ + USB_TRANSFER_STATUS_SKIPPED, /**< ISOC packets only. The packet was skipped due to system latency or bus overload */ +} usb_transfer_status_t; + +/** + * @brief Isochronous packet descriptor + * + * If the number of bytes in an Isochronous transfer is larger than the MPS of the endpoint, the transfer is split + * into multiple packets transmitted at the endpoint's specified interval. An array of Isochronous packet descriptors + * describes how an Isochronous transfer should be split into multiple packets. + */ +typedef struct { + int num_bytes; /**< Number of bytes to transmit/receive in the packet. IN packets should be integer multiple of MPS */ + int actual_num_bytes; /**< Actual number of bytes transmitted/received in the packet */ + usb_transfer_status_t status; /**< Status of the packet */ +} usb_isoc_packet_desc_t; + +/** + * @brief USB transfer structure + * + * This structure is used to represent a transfer from a software client to an endpoint over the USB bus. Some of the + * fields are made const on purpose as they are fixed on allocation. Users should call the appropriate USB Host Library + * function to allocate a USB transfer structure instead of allocating this structure themselves. + * + * The transfer type is inferred from the endpoint this transfer is sent to. Depending on the transfer type, users + * should note the following: + * + * - Bulk: This structure represents a single bulk transfer. If the number of bytes exceeds the endpoint's MPS, the + * transfer will be split into multiple MPS sized packets followed by a short packet. + * - Control: This structure represents a single control transfer. This first 8 bytes of the data_buffer must be filled + * with the setup packet (see usb_setup_packet_t). The num_bytes field should be the total size of the + * transfer (i.e., size of setup packet + wLength). + * - Interrupt: Represents an interrupt transfer. If num_bytes exceeds the MPS of the endpoint, the transfer will be + * split into multiple packets, and each packet is transferred at the endpoint's specified interval. + * - Isochronous: Represents a stream of bytes that should be transferred to an endpoint at a fixed rate. The transfer + * is split into packets according to the each isoc_packet_desc. A packet is transferred at each interval + * of the endpoint. + * + * @note For Bulk/Control/Interrupt IN transfers, the num_bytes must be a integer multiple of the endpoint's MPS + * @note This structure should be allocated via usb_host_transfer_alloc() + * @note Once the transfer has be submitted, users should not modify the structure until the transfer has completed + */ +typedef struct usb_transfer_s usb_transfer_t; + +/** + * @brief USB transfer completion callback + */ +typedef void (*usb_transfer_cb_t)(usb_transfer_t *transfer); + +struct usb_transfer_s{ + uint8_t *const data_buffer; /**< Pointer to data buffer */ + const size_t data_buffer_size; /**< Size of the data buffer in bytes */ + int num_bytes; /**< Number of bytes to transfer. + Control transfers should include the size of the setup packet. + Isochronous transfer should be the total transfer size of all packets. + For non-control IN transfers, num_bytes should be an integer multiple of MPS. */ + int actual_num_bytes; /**< Actual number of bytes transferred */ + uint32_t flags; /**< Transfer flags */ + usb_device_handle_t device_handle; /**< Device handle */ + uint8_t bEndpointAddress; /**< Endpoint Address */ + usb_transfer_status_t status; /**< Status of the transfer */ + uint32_t timeout_ms; /**< Timeout (in milliseconds) of the packet (currently not supported yet) */ + usb_transfer_cb_t callback; /**< Transfer callback */ + void *context; /**< Context variable for transfer to associate transfer with something */ + const int num_isoc_packets; /**< Only relevant to Isochronous. Number of service periods (i.e., intervals) to transfer data buffer over. */ + usb_isoc_packet_desc_t isoc_packet_desc[0]; /**< Descriptors for each Isochronous packet */ +}; + +#define USB_TRANSFER_FLAG_ZERO_PACK 0x01 /**< (For bulk OUT only). Indicates that a bulk OUT transfers should always terminate with a short packet, even if it means adding an extra zero length packet */ + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32s2/include/wpa_supplicant/include/esp_supplicant/esp_dpp.h b/tools/sdk/esp32s2/include/wpa_supplicant/esp_supplicant/include/esp_dpp.h similarity index 100% rename from tools/sdk/esp32s2/include/wpa_supplicant/include/esp_supplicant/esp_dpp.h rename to tools/sdk/esp32s2/include/wpa_supplicant/esp_supplicant/include/esp_dpp.h diff --git a/tools/sdk/esp32s2/include/wpa_supplicant/include/esp_supplicant/esp_rrm.h b/tools/sdk/esp32s2/include/wpa_supplicant/esp_supplicant/include/esp_rrm.h similarity index 100% rename from tools/sdk/esp32s2/include/wpa_supplicant/include/esp_supplicant/esp_rrm.h rename to tools/sdk/esp32s2/include/wpa_supplicant/esp_supplicant/include/esp_rrm.h diff --git a/tools/sdk/esp32s2/include/wpa_supplicant/include/esp_supplicant/esp_wnm.h b/tools/sdk/esp32s2/include/wpa_supplicant/esp_supplicant/include/esp_wnm.h similarity index 100% rename from tools/sdk/esp32s2/include/wpa_supplicant/include/esp_supplicant/esp_wnm.h rename to tools/sdk/esp32s2/include/wpa_supplicant/esp_supplicant/include/esp_wnm.h diff --git a/tools/sdk/esp32s2/include/wpa_supplicant/include/esp_supplicant/esp_wpa.h b/tools/sdk/esp32s2/include/wpa_supplicant/esp_supplicant/include/esp_wpa.h similarity index 100% rename from tools/sdk/esp32s2/include/wpa_supplicant/include/esp_supplicant/esp_wpa.h rename to tools/sdk/esp32s2/include/wpa_supplicant/esp_supplicant/include/esp_wpa.h diff --git a/tools/sdk/esp32s2/include/wpa_supplicant/include/esp_supplicant/esp_wpa2.h b/tools/sdk/esp32s2/include/wpa_supplicant/esp_supplicant/include/esp_wpa2.h similarity index 100% rename from tools/sdk/esp32s2/include/wpa_supplicant/include/esp_supplicant/esp_wpa2.h rename to tools/sdk/esp32s2/include/wpa_supplicant/esp_supplicant/include/esp_wpa2.h diff --git a/tools/sdk/esp32s2/include/wpa_supplicant/include/esp_supplicant/esp_wps.h b/tools/sdk/esp32s2/include/wpa_supplicant/esp_supplicant/include/esp_wps.h similarity index 100% rename from tools/sdk/esp32s2/include/wpa_supplicant/include/esp_supplicant/esp_wps.h rename to tools/sdk/esp32s2/include/wpa_supplicant/esp_supplicant/include/esp_wps.h diff --git a/tools/sdk/esp32s2/ld/esp32s2.peripherals.ld b/tools/sdk/esp32s2/ld/esp32s2.peripherals.ld index 48aa0414ca6..bd1d00c5b70 100644 --- a/tools/sdk/esp32s2/ld/esp32s2.peripherals.ld +++ b/tools/sdk/esp32s2/ld/esp32s2.peripherals.ld @@ -1,3 +1,8 @@ +/* + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ PROVIDE ( UART0 = 0x3f400000 ); PROVIDE ( SPIMEM1 = 0x3f402000 ); PROVIDE ( SPIMEM0 = 0x3f403000 ); diff --git a/tools/sdk/esp32s2/ld/esp32s2.rom.newlib-funcs.ld b/tools/sdk/esp32s2/ld/esp32s2.rom.newlib-funcs.ld index c859f655b47..fc976bbbafe 100644 --- a/tools/sdk/esp32s2/ld/esp32s2.rom.newlib-funcs.ld +++ b/tools/sdk/esp32s2/ld/esp32s2.rom.newlib-funcs.ld @@ -10,8 +10,8 @@ abs = 0x40000618; __ascii_mbtowc = 0x40007a04; __ascii_wctomb = 0x400018d0; -__assert = 0x4001a430; -__assert_func = 0x4001a408; +PROVIDE ( __assert = 0x4001a430 ); +PROVIDE ( __assert_func = 0x4001a408 ); bzero = 0x400078c8; _cleanup_r = 0x4001a480; creat = 0x4000788c; diff --git a/tools/sdk/esp32s2/ld/libcat_face_detect.a b/tools/sdk/esp32s2/ld/libcat_face_detect.a new file mode 100644 index 00000000000..1bc5162b09f Binary files /dev/null and b/tools/sdk/esp32s2/ld/libcat_face_detect.a differ diff --git a/tools/sdk/esp32s2/ld/libdetection.a b/tools/sdk/esp32s2/ld/libdetection.a deleted file mode 100644 index 8d5081bdfd9..00000000000 Binary files a/tools/sdk/esp32s2/ld/libdetection.a and /dev/null differ diff --git a/tools/sdk/esp32s2/ld/libdetection_cat_face.a b/tools/sdk/esp32s2/ld/libdetection_cat_face.a deleted file mode 100644 index e1d42e756b8..00000000000 Binary files a/tools/sdk/esp32s2/ld/libdetection_cat_face.a and /dev/null differ diff --git a/tools/sdk/esp32s2/ld/libdl.a b/tools/sdk/esp32s2/ld/libdl.a index 0160b0edc3c..1e6c8c48421 100644 Binary files a/tools/sdk/esp32s2/ld/libdl.a and b/tools/sdk/esp32s2/ld/libdl.a differ diff --git a/tools/sdk/esp32s2/ld/libfd.a b/tools/sdk/esp32s2/ld/libfd.a deleted file mode 100644 index 9f58faef4a2..00000000000 Binary files a/tools/sdk/esp32s2/ld/libfd.a and /dev/null differ diff --git a/tools/sdk/esp32s2/ld/libfr.a b/tools/sdk/esp32s2/ld/libfr.a deleted file mode 100644 index c824bcd9a3e..00000000000 Binary files a/tools/sdk/esp32s2/ld/libfr.a and /dev/null differ diff --git a/tools/sdk/esp32s2/ld/libhuman_face_detect.a b/tools/sdk/esp32s2/ld/libhuman_face_detect.a new file mode 100644 index 00000000000..72fd6f5eb49 Binary files /dev/null and b/tools/sdk/esp32s2/ld/libhuman_face_detect.a differ diff --git a/tools/sdk/esp32s2/ld/libpe.a b/tools/sdk/esp32s2/ld/libpe.a deleted file mode 100644 index b859f2429eb..00000000000 Binary files a/tools/sdk/esp32s2/ld/libpe.a and /dev/null differ diff --git a/tools/sdk/esp32s2/ld/memory.ld b/tools/sdk/esp32s2/ld/memory.ld index e08fe50f764..2d5a5d24d5d 100644 --- a/tools/sdk/esp32s2/ld/memory.ld +++ b/tools/sdk/esp32s2/ld/memory.ld @@ -1,3 +1,8 @@ +/* + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /* ESP32S2 Linker Script Memory Layout This file describes the memory layout (memory blocks) by virtual memory addresses. @@ -13,6 +18,17 @@ */ /* List of deprecated options */ +/* + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* CPU instruction prefetch padding size for flash mmap scenario */ +_esp_flash_mmap_prefetch_pad_size = 16; +/* CPU instruction prefetch padding size for memory protection scenario */ +_esp_memprot_prefetch_pad_size = 16; +/* Memory alignment size for PMS */ +_esp_memprot_align_size = 4; MEMORY { /* All these values assume the flash cache is on, and have the blocks this uses subtracted from the length @@ -46,6 +62,9 @@ MEMORY len = 0x2000 - 0 /* RTC fast memory (same block as above), viewed from data bus */ rtc_data_seg(RW) : org = 0x3ff9e000, len = 0x2000 - (0x10) + /* external memory, covers the dport, dram0, dram1 cacheable address space */ + extern_ram_seg(RWX) : org = 0x3F500000, + len = 0xA80000 } _static_data_end = _bss_end; _heap_end = 0x40000000; diff --git a/tools/sdk/esp32s2/ld/sections.ld b/tools/sdk/esp32s2/ld/sections.ld index a9b9c27f4b5..94bf03d6a9f 100644 --- a/tools/sdk/esp32s2/ld/sections.ld +++ b/tools/sdk/esp32s2/ld/sections.ld @@ -2,6 +2,12 @@ /* Espressif IoT Development Framework Linker Script */ /* Generated from: /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/ld/esp32s2/sections.ld.in */ +/* + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + /* Default entry point: */ ENTRY(call_start_cpu0); @@ -198,7 +204,7 @@ SECTIONS *libesp_system.a:esp_system.*(.literal.esp_system_abort .text.esp_system_abort) *libesp_system.a:ubsan.*(.literal .literal.* .text .text.*) *libfreertos.a:(EXCLUDE_FILE(*libfreertos.a:port.* *libfreertos.a:port_common.*) .literal EXCLUDE_FILE(*libfreertos.a:port.* *libfreertos.a:port_common.*) .literal.* EXCLUDE_FILE(*libfreertos.a:port.* *libfreertos.a:port_common.*) .text EXCLUDE_FILE(*libfreertos.a:port.* *libfreertos.a:port_common.*) .text.*) - *libfreertos.a:port.*(.literal.pxPortInitialiseStack .literal.unlikely.vPortEndScheduler .literal.vApplicationStackOverflowHook .literal.vPortAssertIfInISR .literal.vPortEnterCritical .literal.vPortExitCritical .literal.vPortSetStackWatchpoint .literal.vPortYieldOtherCore .literal.xPortInIsrContext .literal.xPortStartScheduler .literal.xPortSysTickHandler .text .text.pxPortInitialiseStack .text.unlikely.vPortEndScheduler .text.vApplicationStackOverflowHook .text.vPortAssertIfInISR .text.vPortEnterCritical .text.vPortExitCritical .text.vPortSetStackWatchpoint .text.vPortYieldOtherCore .text.xPortGetTickRateHz .text.xPortInIsrContext .text.xPortStartScheduler .text.xPortSysTickHandler) + *libfreertos.a:port.*(.literal.pxPortInitialiseStack .literal.unlikely.vPortEndScheduler .literal.vApplicationStackOverflowHook .literal.vPortAssertIfInISR .literal.vPortEnterCritical .literal.vPortExitCritical .literal.vPortSetStackWatchpoint .literal.vPortYieldOtherCore .literal.xPortInIsrContext .literal.xPortStartScheduler .text .text.pxPortInitialiseStack .text.unlikely.vPortEndScheduler .text.vApplicationStackOverflowHook .text.vPortAssertIfInISR .text.vPortEnterCritical .text.vPortExitCritical .text.vPortSetStackWatchpoint .text.vPortYieldOtherCore .text.xPortGetTickRateHz .text.xPortInIsrContext .text.xPortStartScheduler) *libfreertos.a:port_common.*(.literal.esp_startup_start_app_common .text .text.esp_startup_start_app_common) *libgcc.a:_divsf3.*(.literal .literal.* .text .text.*) *libgcc.a:lib2funcs.*(.literal .literal.* .text .text.*) @@ -224,6 +230,7 @@ SECTIONS *liblog.a:log_freertos.*(.literal.esp_log_impl_unlock .text.esp_log_impl_unlock) *liblog.a:log_freertos.*(.literal.esp_log_timestamp .text.esp_log_timestamp) *libnewlib.a:abort.*(.literal .literal.* .text .text.*) + *libnewlib.a:assert.*(.literal .literal.* .text .text.*) *libnewlib.a:heap.*(.literal .literal.* .text .text.*) *libnewlib.a:stdatomic.*(.literal .literal.* .text .text.*) *librtc.a:(.literal .literal.* .text .text.*) @@ -245,7 +252,7 @@ SECTIONS _coredump_iram_end = 0; /* align + add 16B for CPU dummy speculative instr. fetch */ - . = ALIGN(4) + 16; + . = ALIGN(_esp_memprot_align_size) + _esp_memprot_prefetch_pad_size; /* iram_end_test section exists for use by memprot unit tests only */ *(.iram_end_test) _iram_text_end = ABSOLUTE(.); @@ -310,6 +317,7 @@ SECTIONS *libheap.a:multi_heap.*(.rodata .rodata.*) *libheap.a:multi_heap_poisoning.*(.rodata .rodata.*) *libnewlib.a:abort.*(.rodata .rodata.*) + *libnewlib.a:assert.*(.rodata .rodata.*) *libnewlib.a:heap.*(.rodata .rodata.*) *libnewlib.a:stdatomic.*(.rodata .rodata.*) _nimble_data_start = ABSOLUTE(.); @@ -345,6 +353,16 @@ SECTIONS _noinit_end = ABSOLUTE(.); } > dram0_0_seg + /* external memory bss, from any global variable with EXT_RAM_ATTR attribute*/ + .ext_ram.bss (NOLOAD) : + { + _ext_ram_bss_start = ABSOLUTE(.); + + + . = ALIGN(4); + _ext_ram_bss_end = ABSOLUTE(.); + } > extern_ram_seg + /* Shared RAM */ .dram0.bss (NOLOAD) : { @@ -353,8 +371,8 @@ SECTIONS *(.ext_ram.bss*) *(.bss .bss.*) - *(.ext_ram.bss .ext_ram.bss.*) *(.dynbss .dynsbss .gnu.linkonce.b .gnu.linkonce.b.* .gnu.linkonce.sb .gnu.linkonce.sb.* .gnu.linkonce.sb2 .gnu.linkonce.sb2.* .sbss .sbss.* .sbss2 .sbss2.* .scommon .share.mem) + *(.ext_ram.bss .ext_ram.bss.*) *(COMMON) _bt_bss_start = ABSOLUTE(.); *libbt.a:(.bss .bss.* COMMON) @@ -403,7 +421,7 @@ SECTIONS { _flash_rodata_start = ABSOLUTE(.); - *(EXCLUDE_FILE(*libgcov.a *libphy.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_hw_support.a:regi2c_ctrl.* *libesp_hw_support.a:rtc_clk.* *libesp_system.a:esp_err.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libheap.a:multi_heap_poisoning.* *libnewlib.a:abort.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .rodata EXCLUDE_FILE(*libgcov.a *libphy.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_hw_support.a:regi2c_ctrl.* *libesp_hw_support.a:rtc_clk.* *libesp_system.a:esp_err.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libheap.a:multi_heap_poisoning.* *libnewlib.a:abort.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .rodata.*) + *(EXCLUDE_FILE(*libgcov.a *libphy.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_hw_support.a:regi2c_ctrl.* *libesp_hw_support.a:rtc_clk.* *libesp_system.a:esp_err.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libheap.a:multi_heap_poisoning.* *libnewlib.a:abort.* *libnewlib.a:assert.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .rodata EXCLUDE_FILE(*libgcov.a *libphy.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_hw_support.a:regi2c_ctrl.* *libesp_hw_support.a:rtc_clk.* *libesp_system.a:esp_err.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libheap.a:multi_heap_poisoning.* *libnewlib.a:abort.* *libnewlib.a:assert.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .rodata.*) *(.rodata_wlog_error .rodata_wlog_error.*) *(.irom1.text) /* catch stray ICACHE_RODATA_ATTR */ @@ -477,7 +495,7 @@ SECTIONS _instruction_reserved_start = ABSOLUTE(.); _text_start = ABSOLUTE(.); - *(EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libxt_hal.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:regi2c_ctrl.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_hw_support.a:rtc_wdt.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libgcc.a:lib2funcs.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libheap.a:multi_heap_poisoning.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.* *libxtensa.a:eri.* *libxtensa.a:xtensa_intr_asm.*) .literal EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libxt_hal.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:regi2c_ctrl.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_hw_support.a:rtc_wdt.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libgcc.a:lib2funcs.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libheap.a:multi_heap_poisoning.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.* *libxtensa.a:eri.* *libxtensa.a:xtensa_intr_asm.*) .literal.* EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libxt_hal.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:regi2c_ctrl.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_hw_support.a:rtc_wdt.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libgcc.a:lib2funcs.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libheap.a:multi_heap_poisoning.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.* *libxtensa.a:eri.* *libxtensa.a:xtensa_intr_asm.*) .text EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libxt_hal.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:regi2c_ctrl.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_hw_support.a:rtc_wdt.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libgcc.a:lib2funcs.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libheap.a:multi_heap_poisoning.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.* *libxtensa.a:eri.* *libxtensa.a:xtensa_intr_asm.*) .text.*) + *(EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libxt_hal.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:regi2c_ctrl.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_hw_support.a:rtc_wdt.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libgcc.a:lib2funcs.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libheap.a:multi_heap_poisoning.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:assert.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.* *libxtensa.a:eri.* *libxtensa.a:xtensa_intr_asm.*) .literal EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libxt_hal.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:regi2c_ctrl.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_hw_support.a:rtc_wdt.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libgcc.a:lib2funcs.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libheap.a:multi_heap_poisoning.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:assert.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.* *libxtensa.a:eri.* *libxtensa.a:xtensa_intr_asm.*) .literal.* EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libxt_hal.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:regi2c_ctrl.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_hw_support.a:rtc_wdt.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libgcc.a:lib2funcs.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libheap.a:multi_heap_poisoning.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:assert.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.* *libxtensa.a:eri.* *libxtensa.a:xtensa_intr_asm.*) .text EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libxt_hal.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:regi2c_ctrl.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_hw_support.a:rtc_wdt.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libgcc.a:lib2funcs.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libheap.a:multi_heap_poisoning.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:assert.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.* *libxtensa.a:eri.* *libxtensa.a:xtensa_intr_asm.*) .text.*) *(.wifi0iram .wifi0iram.*) *(.wifiorslpiram .wifiorslpiram.*) *(.wifirxiram .wifirxiram.*) @@ -503,7 +521,7 @@ SECTIONS * safe access to up to 16 bytes after the last real instruction, add * dummy bytes to ensure this */ - . += 16; + . += _esp_flash_mmap_prefetch_pad_size; _text_end = ABSOLUTE(.); _instruction_reserved_end = ABSOLUTE(.); diff --git a/tools/sdk/esp32s2/lib/libapp_trace.a b/tools/sdk/esp32s2/lib/libapp_trace.a index d84403af1bb..65b1f96e83b 100644 Binary files a/tools/sdk/esp32s2/lib/libapp_trace.a and b/tools/sdk/esp32s2/lib/libapp_trace.a differ diff --git a/tools/sdk/esp32s2/lib/libapp_update.a b/tools/sdk/esp32s2/lib/libapp_update.a index 96082c007a1..36db9c85c17 100644 Binary files a/tools/sdk/esp32s2/lib/libapp_update.a and b/tools/sdk/esp32s2/lib/libapp_update.a differ diff --git a/tools/sdk/esp32s2/lib/libarduino_tinyusb.a b/tools/sdk/esp32s2/lib/libarduino_tinyusb.a index ea8902c57d6..e004a2db069 100644 Binary files a/tools/sdk/esp32s2/lib/libarduino_tinyusb.a and b/tools/sdk/esp32s2/lib/libarduino_tinyusb.a differ diff --git a/tools/sdk/esp32s2/lib/libasio.a b/tools/sdk/esp32s2/lib/libasio.a index 4d06535f0e9..3a23faf503f 100644 Binary files a/tools/sdk/esp32s2/lib/libasio.a and b/tools/sdk/esp32s2/lib/libasio.a differ diff --git a/tools/sdk/esp32s2/lib/libbootloader_support.a b/tools/sdk/esp32s2/lib/libbootloader_support.a index 6999aab8622..ffa6ff3b490 100644 Binary files a/tools/sdk/esp32s2/lib/libbootloader_support.a and b/tools/sdk/esp32s2/lib/libbootloader_support.a differ diff --git a/tools/sdk/esp32s2/lib/libcbor.a b/tools/sdk/esp32s2/lib/libcbor.a index 6bef1010ac7..0e973091ed6 100644 Binary files a/tools/sdk/esp32s2/lib/libcbor.a and b/tools/sdk/esp32s2/lib/libcbor.a differ diff --git a/tools/sdk/esp32s2/lib/libcoap.a b/tools/sdk/esp32s2/lib/libcoap.a index 1a143921003..6a5173eb19d 100644 Binary files a/tools/sdk/esp32s2/lib/libcoap.a and b/tools/sdk/esp32s2/lib/libcoap.a differ diff --git a/tools/sdk/esp32s2/lib/libcoexist.a b/tools/sdk/esp32s2/lib/libcoexist.a index d3d43e37977..0f146c2c899 100644 Binary files a/tools/sdk/esp32s2/lib/libcoexist.a and b/tools/sdk/esp32s2/lib/libcoexist.a differ diff --git a/tools/sdk/esp32s2/lib/libconsole.a b/tools/sdk/esp32s2/lib/libconsole.a index 7d61588a472..3f95dd5e32d 100644 Binary files a/tools/sdk/esp32s2/lib/libconsole.a and b/tools/sdk/esp32s2/lib/libconsole.a differ diff --git a/tools/sdk/esp32s2/lib/libcore.a b/tools/sdk/esp32s2/lib/libcore.a index 9535e48bbcd..e017a1006a3 100644 Binary files a/tools/sdk/esp32s2/lib/libcore.a and b/tools/sdk/esp32s2/lib/libcore.a differ diff --git a/tools/sdk/esp32s2/lib/libcxx.a b/tools/sdk/esp32s2/lib/libcxx.a index d06360a6995..9202ad02b03 100644 Binary files a/tools/sdk/esp32s2/lib/libcxx.a and b/tools/sdk/esp32s2/lib/libcxx.a differ diff --git a/tools/sdk/esp32s2/lib/libdriver.a b/tools/sdk/esp32s2/lib/libdriver.a index 17168ba1dd5..271f07c3d00 100644 Binary files a/tools/sdk/esp32s2/lib/libdriver.a and b/tools/sdk/esp32s2/lib/libdriver.a differ diff --git a/tools/sdk/esp32s2/lib/libefuse.a b/tools/sdk/esp32s2/lib/libefuse.a index 5f19adfeadd..45e85b5b281 100644 Binary files a/tools/sdk/esp32s2/lib/libefuse.a and b/tools/sdk/esp32s2/lib/libefuse.a differ diff --git a/tools/sdk/esp32s2/lib/libesp-dsp.a b/tools/sdk/esp32s2/lib/libesp-dsp.a index 49564c97384..bba63702a29 100644 Binary files a/tools/sdk/esp32s2/lib/libesp-dsp.a and b/tools/sdk/esp32s2/lib/libesp-dsp.a differ diff --git a/tools/sdk/esp32s2/lib/libesp-face.a b/tools/sdk/esp32s2/lib/libesp-face.a deleted file mode 100644 index b5de62de45e..00000000000 Binary files a/tools/sdk/esp32s2/lib/libesp-face.a and /dev/null differ diff --git a/tools/sdk/esp32s2/lib/libesp-tls.a b/tools/sdk/esp32s2/lib/libesp-tls.a index ad20a2b40e4..0fbddfec7bd 100644 Binary files a/tools/sdk/esp32s2/lib/libesp-tls.a and b/tools/sdk/esp32s2/lib/libesp-tls.a differ diff --git a/tools/sdk/esp32s2/lib/libesp32-camera.a b/tools/sdk/esp32s2/lib/libesp32-camera.a index 1c88b056197..b6dff3e52a3 100644 Binary files a/tools/sdk/esp32s2/lib/libesp32-camera.a and b/tools/sdk/esp32s2/lib/libesp32-camera.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_adc_cal.a b/tools/sdk/esp32s2/lib/libesp_adc_cal.a index 9dceb6f9efe..a400ccd3958 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_adc_cal.a and b/tools/sdk/esp32s2/lib/libesp_adc_cal.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_common.a b/tools/sdk/esp32s2/lib/libesp_common.a index 81f2cc8c1c2..3d55f543596 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_common.a and b/tools/sdk/esp32s2/lib/libesp_common.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_eth.a b/tools/sdk/esp32s2/lib/libesp_eth.a index 0f580e7d547..5a3c5d1ec1f 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_eth.a and b/tools/sdk/esp32s2/lib/libesp_eth.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_event.a b/tools/sdk/esp32s2/lib/libesp_event.a index 848535aa4a8..3ba390e2ef4 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_event.a and b/tools/sdk/esp32s2/lib/libesp_event.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_gdbstub.a b/tools/sdk/esp32s2/lib/libesp_gdbstub.a index 78643302b2c..2432b1aeced 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_gdbstub.a and b/tools/sdk/esp32s2/lib/libesp_gdbstub.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_hid.a b/tools/sdk/esp32s2/lib/libesp_hid.a index 7dbdcef22ae..82ea9ff4cbb 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_hid.a and b/tools/sdk/esp32s2/lib/libesp_hid.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_http_client.a b/tools/sdk/esp32s2/lib/libesp_http_client.a index d26969f668f..557786f2310 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_http_client.a and b/tools/sdk/esp32s2/lib/libesp_http_client.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_http_server.a b/tools/sdk/esp32s2/lib/libesp_http_server.a index 595a9e49cb4..7dcb8e9bdb5 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_http_server.a and b/tools/sdk/esp32s2/lib/libesp_http_server.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_https_ota.a b/tools/sdk/esp32s2/lib/libesp_https_ota.a index 63c4ca74888..31fadcfb272 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_https_ota.a and b/tools/sdk/esp32s2/lib/libesp_https_ota.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_https_server.a b/tools/sdk/esp32s2/lib/libesp_https_server.a index 7f44b7ae08f..fe3cf5581d8 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_https_server.a and b/tools/sdk/esp32s2/lib/libesp_https_server.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_hw_support.a b/tools/sdk/esp32s2/lib/libesp_hw_support.a index a05213538a1..2dacebef4e3 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_hw_support.a and b/tools/sdk/esp32s2/lib/libesp_hw_support.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_ipc.a b/tools/sdk/esp32s2/lib/libesp_ipc.a index 1b4a8163508..a846df70856 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_ipc.a and b/tools/sdk/esp32s2/lib/libesp_ipc.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_lcd.a b/tools/sdk/esp32s2/lib/libesp_lcd.a index d9e0b067b5f..4bcdbecb1ca 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_lcd.a and b/tools/sdk/esp32s2/lib/libesp_lcd.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_littlefs.a b/tools/sdk/esp32s2/lib/libesp_littlefs.a index bc04965f247..16cb7dea9b6 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_littlefs.a and b/tools/sdk/esp32s2/lib/libesp_littlefs.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_local_ctrl.a b/tools/sdk/esp32s2/lib/libesp_local_ctrl.a index 8b26c3f7cf7..fabc0fe34f0 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_local_ctrl.a and b/tools/sdk/esp32s2/lib/libesp_local_ctrl.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_netif.a b/tools/sdk/esp32s2/lib/libesp_netif.a index d18e2974c15..e30fa30a9b5 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_netif.a and b/tools/sdk/esp32s2/lib/libesp_netif.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_phy.a b/tools/sdk/esp32s2/lib/libesp_phy.a index 07f2f5cf130..10c41de3f84 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_phy.a and b/tools/sdk/esp32s2/lib/libesp_phy.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_pm.a b/tools/sdk/esp32s2/lib/libesp_pm.a index 1cec707f017..ffa717deb5d 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_pm.a and b/tools/sdk/esp32s2/lib/libesp_pm.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_ringbuf.a b/tools/sdk/esp32s2/lib/libesp_ringbuf.a index 83463ae8770..46a0abb1b61 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_ringbuf.a and b/tools/sdk/esp32s2/lib/libesp_ringbuf.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_rom.a b/tools/sdk/esp32s2/lib/libesp_rom.a index c299003a711..0febf6d1d1b 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_rom.a and b/tools/sdk/esp32s2/lib/libesp_rom.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_serial_slave_link.a b/tools/sdk/esp32s2/lib/libesp_serial_slave_link.a index 5a7e39e5678..eb9d9aa7d49 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_serial_slave_link.a and b/tools/sdk/esp32s2/lib/libesp_serial_slave_link.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_system.a b/tools/sdk/esp32s2/lib/libesp_system.a index 699c0849fbe..338875d18ca 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_system.a and b/tools/sdk/esp32s2/lib/libesp_system.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_timer.a b/tools/sdk/esp32s2/lib/libesp_timer.a index ce47ac02c4c..c869d63ec01 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_timer.a and b/tools/sdk/esp32s2/lib/libesp_timer.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_websocket_client.a b/tools/sdk/esp32s2/lib/libesp_websocket_client.a index 063b9281ab7..86d2344ffa3 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_websocket_client.a and b/tools/sdk/esp32s2/lib/libesp_websocket_client.a differ diff --git a/tools/sdk/esp32s2/lib/libesp_wifi.a b/tools/sdk/esp32s2/lib/libesp_wifi.a index 6cc6490235b..8b21c2fc5a0 100644 Binary files a/tools/sdk/esp32s2/lib/libesp_wifi.a and b/tools/sdk/esp32s2/lib/libesp_wifi.a differ diff --git a/tools/sdk/esp32s2/lib/libespcoredump.a b/tools/sdk/esp32s2/lib/libespcoredump.a index a42b90dce31..25b0cc93cad 100644 Binary files a/tools/sdk/esp32s2/lib/libespcoredump.a and b/tools/sdk/esp32s2/lib/libespcoredump.a differ diff --git a/tools/sdk/esp32s2/lib/libespnow.a b/tools/sdk/esp32s2/lib/libespnow.a index 6472f250f98..debe3c57249 100644 Binary files a/tools/sdk/esp32s2/lib/libespnow.a and b/tools/sdk/esp32s2/lib/libespnow.a differ diff --git a/tools/sdk/esp32s2/lib/libexpat.a b/tools/sdk/esp32s2/lib/libexpat.a index b58abb26d7b..acca6db56f4 100644 Binary files a/tools/sdk/esp32s2/lib/libexpat.a and b/tools/sdk/esp32s2/lib/libexpat.a differ diff --git a/tools/sdk/esp32s2/lib/libfatfs.a b/tools/sdk/esp32s2/lib/libfatfs.a index 57ba827bac8..9a65e421336 100644 Binary files a/tools/sdk/esp32s2/lib/libfatfs.a and b/tools/sdk/esp32s2/lib/libfatfs.a differ diff --git a/tools/sdk/esp32s2/lib/libfreemodbus.a b/tools/sdk/esp32s2/lib/libfreemodbus.a index 99c1a06c60b..50511f3c123 100644 Binary files a/tools/sdk/esp32s2/lib/libfreemodbus.a and b/tools/sdk/esp32s2/lib/libfreemodbus.a differ diff --git a/tools/sdk/esp32s2/lib/libfreertos.a b/tools/sdk/esp32s2/lib/libfreertos.a index 3f0d3730eef..733f6a3ee3a 100644 Binary files a/tools/sdk/esp32s2/lib/libfreertos.a and b/tools/sdk/esp32s2/lib/libfreertos.a differ diff --git a/tools/sdk/esp32s2/lib/libhal.a b/tools/sdk/esp32s2/lib/libhal.a index 483c76a2fe2..c13b15b5ff4 100644 Binary files a/tools/sdk/esp32s2/lib/libhal.a and b/tools/sdk/esp32s2/lib/libhal.a differ diff --git a/tools/sdk/esp32s2/lib/libheap.a b/tools/sdk/esp32s2/lib/libheap.a index 020aa3e98ec..7ed09f63f9c 100644 Binary files a/tools/sdk/esp32s2/lib/libheap.a and b/tools/sdk/esp32s2/lib/libheap.a differ diff --git a/tools/sdk/esp32s2/lib/libjson.a b/tools/sdk/esp32s2/lib/libjson.a index 87da0506c46..a68d1c0e1dc 100644 Binary files a/tools/sdk/esp32s2/lib/libjson.a and b/tools/sdk/esp32s2/lib/libjson.a differ diff --git a/tools/sdk/esp32s2/lib/liblibsodium.a b/tools/sdk/esp32s2/lib/liblibsodium.a index 7e883eb314a..d7bf4c3da7b 100644 Binary files a/tools/sdk/esp32s2/lib/liblibsodium.a and b/tools/sdk/esp32s2/lib/liblibsodium.a differ diff --git a/tools/sdk/esp32s2/lib/liblog.a b/tools/sdk/esp32s2/lib/liblog.a index 965799568af..cd6ad238403 100644 Binary files a/tools/sdk/esp32s2/lib/liblog.a and b/tools/sdk/esp32s2/lib/liblog.a differ diff --git a/tools/sdk/esp32s2/lib/liblwip.a b/tools/sdk/esp32s2/lib/liblwip.a index 34eeed9a831..84c9a7cbc7c 100644 Binary files a/tools/sdk/esp32s2/lib/liblwip.a and b/tools/sdk/esp32s2/lib/liblwip.a differ diff --git a/tools/sdk/esp32s2/lib/libmbedcrypto.a b/tools/sdk/esp32s2/lib/libmbedcrypto.a index 5317db4f5fd..c11c0cb50c2 100644 Binary files a/tools/sdk/esp32s2/lib/libmbedcrypto.a and b/tools/sdk/esp32s2/lib/libmbedcrypto.a differ diff --git a/tools/sdk/esp32s2/lib/libmbedtls.a b/tools/sdk/esp32s2/lib/libmbedtls.a index b58c7faf1c8..c69d43d797a 100644 Binary files a/tools/sdk/esp32s2/lib/libmbedtls.a and b/tools/sdk/esp32s2/lib/libmbedtls.a differ diff --git a/tools/sdk/esp32s2/lib/libmbedx509.a b/tools/sdk/esp32s2/lib/libmbedx509.a index 1331036cb31..55a4fb5da7e 100644 Binary files a/tools/sdk/esp32s2/lib/libmbedx509.a and b/tools/sdk/esp32s2/lib/libmbedx509.a differ diff --git a/tools/sdk/esp32s2/lib/libmdns.a b/tools/sdk/esp32s2/lib/libmdns.a index 0aea34c185e..863f659c447 100644 Binary files a/tools/sdk/esp32s2/lib/libmdns.a and b/tools/sdk/esp32s2/lib/libmdns.a differ diff --git a/tools/sdk/esp32s2/lib/libmesh.a b/tools/sdk/esp32s2/lib/libmesh.a index 083497b688c..8f4fbde53cd 100644 Binary files a/tools/sdk/esp32s2/lib/libmesh.a and b/tools/sdk/esp32s2/lib/libmesh.a differ diff --git a/tools/sdk/esp32s2/lib/libmqtt.a b/tools/sdk/esp32s2/lib/libmqtt.a index c19c0d86996..56d63e439e0 100644 Binary files a/tools/sdk/esp32s2/lib/libmqtt.a and b/tools/sdk/esp32s2/lib/libmqtt.a differ diff --git a/tools/sdk/esp32s2/lib/libnet80211.a b/tools/sdk/esp32s2/lib/libnet80211.a index 9b3996c3fca..93351e991c8 100644 Binary files a/tools/sdk/esp32s2/lib/libnet80211.a and b/tools/sdk/esp32s2/lib/libnet80211.a differ diff --git a/tools/sdk/esp32s2/lib/libnewlib.a b/tools/sdk/esp32s2/lib/libnewlib.a index 1830078dc92..1f724357d57 100644 Binary files a/tools/sdk/esp32s2/lib/libnewlib.a and b/tools/sdk/esp32s2/lib/libnewlib.a differ diff --git a/tools/sdk/esp32s2/lib/libnghttp.a b/tools/sdk/esp32s2/lib/libnghttp.a index a9219c03f6a..b264a45cd59 100644 Binary files a/tools/sdk/esp32s2/lib/libnghttp.a and b/tools/sdk/esp32s2/lib/libnghttp.a differ diff --git a/tools/sdk/esp32s2/lib/libnvs_flash.a b/tools/sdk/esp32s2/lib/libnvs_flash.a index 97e6782964a..a75e4c5782c 100644 Binary files a/tools/sdk/esp32s2/lib/libnvs_flash.a and b/tools/sdk/esp32s2/lib/libnvs_flash.a differ diff --git a/tools/sdk/esp32s2/lib/libopenssl.a b/tools/sdk/esp32s2/lib/libopenssl.a index 129f1130189..0c02d23769a 100644 Binary files a/tools/sdk/esp32s2/lib/libopenssl.a and b/tools/sdk/esp32s2/lib/libopenssl.a differ diff --git a/tools/sdk/esp32s2/lib/libperfmon.a b/tools/sdk/esp32s2/lib/libperfmon.a index 67b5643049f..226764c3eae 100644 Binary files a/tools/sdk/esp32s2/lib/libperfmon.a and b/tools/sdk/esp32s2/lib/libperfmon.a differ diff --git a/tools/sdk/esp32s2/lib/libpp.a b/tools/sdk/esp32s2/lib/libpp.a index fb62ccef23c..3aa7310ee69 100644 Binary files a/tools/sdk/esp32s2/lib/libpp.a and b/tools/sdk/esp32s2/lib/libpp.a differ diff --git a/tools/sdk/esp32s2/lib/libprotobuf-c.a b/tools/sdk/esp32s2/lib/libprotobuf-c.a index 2f46cb77dbb..104d1fb6539 100644 Binary files a/tools/sdk/esp32s2/lib/libprotobuf-c.a and b/tools/sdk/esp32s2/lib/libprotobuf-c.a differ diff --git a/tools/sdk/esp32s2/lib/libprotocomm.a b/tools/sdk/esp32s2/lib/libprotocomm.a index 898dc3fa94a..42d5c8885f5 100644 Binary files a/tools/sdk/esp32s2/lib/libprotocomm.a and b/tools/sdk/esp32s2/lib/libprotocomm.a differ diff --git a/tools/sdk/esp32s2/lib/libpthread.a b/tools/sdk/esp32s2/lib/libpthread.a index bc7df12be78..9bbcb0516fd 100644 Binary files a/tools/sdk/esp32s2/lib/libpthread.a and b/tools/sdk/esp32s2/lib/libpthread.a differ diff --git a/tools/sdk/esp32s2/lib/libsdmmc.a b/tools/sdk/esp32s2/lib/libsdmmc.a index 6a4b5f616fc..ba4320bc74d 100644 Binary files a/tools/sdk/esp32s2/lib/libsdmmc.a and b/tools/sdk/esp32s2/lib/libsdmmc.a differ diff --git a/tools/sdk/esp32s2/lib/libsmartconfig.a b/tools/sdk/esp32s2/lib/libsmartconfig.a index 10effd3ac17..29134ba9039 100644 Binary files a/tools/sdk/esp32s2/lib/libsmartconfig.a and b/tools/sdk/esp32s2/lib/libsmartconfig.a differ diff --git a/tools/sdk/esp32s2/lib/libsoc.a b/tools/sdk/esp32s2/lib/libsoc.a index 0f36bfd5972..57560c731e3 100644 Binary files a/tools/sdk/esp32s2/lib/libsoc.a and b/tools/sdk/esp32s2/lib/libsoc.a differ diff --git a/tools/sdk/esp32s2/lib/libspi_flash.a b/tools/sdk/esp32s2/lib/libspi_flash.a index 43e3d0d813b..7d19d683fd9 100644 Binary files a/tools/sdk/esp32s2/lib/libspi_flash.a and b/tools/sdk/esp32s2/lib/libspi_flash.a differ diff --git a/tools/sdk/esp32s2/lib/libspiffs.a b/tools/sdk/esp32s2/lib/libspiffs.a index 685e6489e13..eb8c65fa83b 100644 Binary files a/tools/sdk/esp32s2/lib/libspiffs.a and b/tools/sdk/esp32s2/lib/libspiffs.a differ diff --git a/tools/sdk/esp32s2/lib/libtcp_transport.a b/tools/sdk/esp32s2/lib/libtcp_transport.a index 2067c82dc6a..993d07d6661 100644 Binary files a/tools/sdk/esp32s2/lib/libtcp_transport.a and b/tools/sdk/esp32s2/lib/libtcp_transport.a differ diff --git a/tools/sdk/esp32s2/lib/libtcpip_adapter.a b/tools/sdk/esp32s2/lib/libtcpip_adapter.a index d55cae05c1b..6c20dd87b02 100644 Binary files a/tools/sdk/esp32s2/lib/libtcpip_adapter.a and b/tools/sdk/esp32s2/lib/libtcpip_adapter.a differ diff --git a/tools/sdk/esp32s2/lib/libtouch_element.a b/tools/sdk/esp32s2/lib/libtouch_element.a index ced46b5bee1..8720a0c1b40 100644 Binary files a/tools/sdk/esp32s2/lib/libtouch_element.a and b/tools/sdk/esp32s2/lib/libtouch_element.a differ diff --git a/tools/sdk/esp32s2/lib/libulp.a b/tools/sdk/esp32s2/lib/libulp.a index ae4e6be9969..b69794e91a2 100644 Binary files a/tools/sdk/esp32s2/lib/libulp.a and b/tools/sdk/esp32s2/lib/libulp.a differ diff --git a/tools/sdk/esp32s2/lib/libunity.a b/tools/sdk/esp32s2/lib/libunity.a index eb4673fb7c3..c4b917780c3 100644 Binary files a/tools/sdk/esp32s2/lib/libunity.a and b/tools/sdk/esp32s2/lib/libunity.a differ diff --git a/tools/sdk/esp32s2/lib/libusb.a b/tools/sdk/esp32s2/lib/libusb.a index 247077937cb..c6004586a2f 100644 Binary files a/tools/sdk/esp32s2/lib/libusb.a and b/tools/sdk/esp32s2/lib/libusb.a differ diff --git a/tools/sdk/esp32s2/lib/libvfs.a b/tools/sdk/esp32s2/lib/libvfs.a index 7b2680b8e12..94902934bd2 100644 Binary files a/tools/sdk/esp32s2/lib/libvfs.a and b/tools/sdk/esp32s2/lib/libvfs.a differ diff --git a/tools/sdk/esp32s2/lib/libwapi.a b/tools/sdk/esp32s2/lib/libwapi.a index 82b9336758a..91bddc368c8 100644 Binary files a/tools/sdk/esp32s2/lib/libwapi.a and b/tools/sdk/esp32s2/lib/libwapi.a differ diff --git a/tools/sdk/esp32s2/lib/libwear_levelling.a b/tools/sdk/esp32s2/lib/libwear_levelling.a index 7093b03e77c..f27dd314042 100644 Binary files a/tools/sdk/esp32s2/lib/libwear_levelling.a and b/tools/sdk/esp32s2/lib/libwear_levelling.a differ diff --git a/tools/sdk/esp32s2/lib/libwifi_provisioning.a b/tools/sdk/esp32s2/lib/libwifi_provisioning.a index 3e854205b3c..40d6d4fc7f7 100644 Binary files a/tools/sdk/esp32s2/lib/libwifi_provisioning.a and b/tools/sdk/esp32s2/lib/libwifi_provisioning.a differ diff --git a/tools/sdk/esp32s2/lib/libwpa_supplicant.a b/tools/sdk/esp32s2/lib/libwpa_supplicant.a index 5bd135ecde4..5afc5fd0100 100644 Binary files a/tools/sdk/esp32s2/lib/libwpa_supplicant.a and b/tools/sdk/esp32s2/lib/libwpa_supplicant.a differ diff --git a/tools/sdk/esp32s2/lib/libxtensa.a b/tools/sdk/esp32s2/lib/libxtensa.a index 2607acc4862..c7ff5169849 100644 Binary files a/tools/sdk/esp32s2/lib/libxtensa.a and b/tools/sdk/esp32s2/lib/libxtensa.a differ diff --git a/tools/sdk/esp32s2/sdkconfig b/tools/sdk/esp32s2/sdkconfig index 15bd9ca2603..be0df95cf98 100644 --- a/tools/sdk/esp32s2/sdkconfig +++ b/tools/sdk/esp32s2/sdkconfig @@ -62,6 +62,7 @@ CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP=y # CONFIG_BOOTLOADER_SKIP_VALIDATE_ALWAYS is not set CONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0x10 # CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC is not set +CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT=y # end of Bootloader config # @@ -93,6 +94,7 @@ CONFIG_ESPTOOLPY_FLASHMODE_QIO=y # CONFIG_ESPTOOLPY_FLASHMODE_DIO is not set # CONFIG_ESPTOOLPY_FLASHMODE_DOUT is not set CONFIG_ESPTOOLPY_FLASHMODE="dio" +# CONFIG_ESPTOOLPY_FLASHFREQ_120M is not set CONFIG_ESPTOOLPY_FLASHFREQ_80M=y # CONFIG_ESPTOOLPY_FLASHFREQ_40M is not set # CONFIG_ESPTOOLPY_FLASHFREQ_26M is not set @@ -284,36 +286,6 @@ CONFIG_APPTRACE_LOCK_ENABLE=y # CONFIG_ASIO_SSL_SUPPORT is not set # end of ESP-ASIO -CONFIG_BTDM_CTRL_BR_EDR_SCO_DATA_PATH_EFF=0 -CONFIG_BTDM_CTRL_PCM_ROLE_EFF=0 -CONFIG_BTDM_CTRL_PCM_POLAR_EFF=0 -CONFIG_BTDM_CTRL_BLE_MAX_CONN_EFF=0 -CONFIG_BTDM_CTRL_BR_EDR_MAX_ACL_CONN_EFF=0 -CONFIG_BTDM_CTRL_BR_EDR_MAX_SYNC_CONN_EFF=0 -CONFIG_BTDM_CTRL_PINNED_TO_CORE=0 -CONFIG_BTDM_BLE_SLEEP_CLOCK_ACCURACY_INDEX_EFF=1 -CONFIG_BT_CTRL_MODE_EFF=1 -CONFIG_BT_CTRL_BLE_MAX_ACT=10 -CONFIG_BT_CTRL_BLE_MAX_ACT_EFF=10 -CONFIG_BT_CTRL_BLE_STATIC_ACL_TX_BUF_NB=0 -CONFIG_BT_CTRL_PINNED_TO_CORE=0 -CONFIG_BT_CTRL_HCI_TL=1 -CONFIG_BT_CTRL_ADV_DUP_FILT_MAX=30 -CONFIG_BT_CTRL_HW_CCA_EFF=0 -CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_EFF=0 -CONFIG_BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP=y -CONFIG_BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_NUM=100 -CONFIG_BT_CTRL_BLE_ADV_REPORT_DISCARD_THRSHOLD=20 -CONFIG_BT_CTRL_BLE_SCAN_DUPL=y -CONFIG_BT_CTRL_SCAN_DUPL_TYPE=0 -CONFIG_BT_CTRL_SCAN_DUPL_CACHE_SIZE=100 -CONFIG_BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_EFF=0 -CONFIG_BT_CTRL_SLEEP_MODE_EFF=0 -CONFIG_BT_CTRL_SLEEP_CLOCK_EFF=0 -CONFIG_BT_CTRL_HCI_TL_EFF=1 -CONFIG_BT_RESERVE_DRAM=0 -CONFIG_BT_NIMBLE_USE_ESP_TIMER=y - # # CoAP Configuration # @@ -334,6 +306,12 @@ CONFIG_COAP_LOG_DEFAULT_LEVEL=0 CONFIG_ADC_DISABLE_DAC=y # end of ADC configuration +# +# MCPWM configuration +# +# CONFIG_MCPWM_ISR_IN_IRAM is not set +# end of MCPWM configuration + # # SPI configuration # @@ -370,6 +348,8 @@ CONFIG_EFUSE_MAX_BLK_LEN=256 CONFIG_ESP_TLS_USING_MBEDTLS=y CONFIG_ESP_TLS_USE_DS_PERIPHERAL=y CONFIG_ESP_TLS_SERVER=y +# CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS is not set +# CONFIG_ESP_TLS_SERVER_SESSION_TICKETS is not set # CONFIG_ESP_TLS_PSK_VERIFICATION is not set # CONFIG_ESP_TLS_INSECURE is not set # end of ESP-TLS @@ -429,6 +409,7 @@ CONFIG_SPIRAM_USE_MALLOC=y CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=4096 CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=32768 +# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set # end of SPI RAM config # CONFIG_ESP32S2_TRAX is not set @@ -544,12 +525,27 @@ CONFIG_ESP32S2_UNIVERSAL_MAC_ADDRESSES=2 # # Sleep Config # +CONFIG_ESP_SLEEP_RTC_BUS_ISO_WORKAROUND=y +# CONFIG_ESP_SLEEP_PSRAM_LEAKAGE_WORKAROUND is not set +# CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND is not set # end of Sleep Config # end of Hardware Settings +# +# IPC (Inter-Processor Call) +# +CONFIG_ESP_IPC_TASK_STACK_SIZE=1024 +# end of IPC (Inter-Processor Call) + # # LCD and Touch Panel # + +# +# LCD Peripheral Configuration +# +CONFIG_LCD_PANEL_IO_FORMAT_BUF_SIZE=32 +# end of LCD Peripheral Configuration # end of LCD and Touch Panel # @@ -591,8 +587,11 @@ CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP=y # # Memory protection # +CONFIG_ESP_SYSTEM_MEMPROT_DEPCHECK=y CONFIG_ESP_SYSTEM_MEMPROT_FEATURE=y CONFIG_ESP_SYSTEM_MEMPROT_FEATURE_LOCK=y +CONFIG_ESP_SYSTEM_MEMPROT_CPU_PREFETCH_PAD_SIZE=16 +CONFIG_ESP_SYSTEM_MEMPROT_MEM_ALIGN_SIZE=4 # end of Memory protection CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE=32 @@ -616,8 +615,8 @@ CONFIG_ESP_TASK_WDT=y CONFIG_ESP_TASK_WDT_PANIC=y CONFIG_ESP_TASK_WDT_TIMEOUT_S=5 # CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0 is not set -CONFIG_ESP_IPC_TASK_STACK_SIZE=1024 # CONFIG_ESP_PANIC_HANDLER_IRAM is not set +CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_4=y # end of ESP System Settings # @@ -735,6 +734,8 @@ CONFIG_FMB_EVENT_QUEUE_TIMEOUT=20 CONFIG_FMB_TIMER_PORT_ENABLED=y CONFIG_FMB_TIMER_GROUP=0 CONFIG_FMB_TIMER_INDEX=0 +CONFIG_FMB_MASTER_TIMER_GROUP=0 +CONFIG_FMB_MASTER_TIMER_INDEX=0 # CONFIG_FMB_TIMER_ISR_IN_IRAM is not set # end of Modbus configuration @@ -743,8 +744,10 @@ CONFIG_FMB_TIMER_INDEX=0 # CONFIG_FREERTOS_UNICORE=y CONFIG_FREERTOS_NO_AFFINITY=0x7FFFFFFF +CONFIG_FREERTOS_TICK_SUPPORT_CORETIMER=y CONFIG_FREERTOS_CORETIMER_0=y # CONFIG_FREERTOS_CORETIMER_1 is not set +CONFIG_FREERTOS_SYSTICK_USES_CCOUNT=y CONFIG_FREERTOS_OPTIMIZED_SCHEDULER=y CONFIG_FREERTOS_HZ=1000 # CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION is not set @@ -773,6 +776,8 @@ CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=y # CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set # CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH is not set CONFIG_FREERTOS_DEBUG_OCDAWARE=y +CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT=y +# CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH is not set # end of FreeRTOS # @@ -837,6 +842,7 @@ CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y # CONFIG_LWIP_LOCAL_HOSTNAME="espressif" # CONFIG_LWIP_NETIF_API is not set +# CONFIG_LWIP_TCPIP_CORE_LOCKING is not set CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y # CONFIG_LWIP_L2_TO_L3_COPY is not set # CONFIG_LWIP_IRAM_OPTIMIZATION is not set @@ -875,7 +881,6 @@ CONFIG_LWIP_IPV6=y # CONFIG_LWIP_IPV6_AUTOCONFIG is not set CONFIG_LWIP_IPV6_NUM_ADDRESSES=3 # CONFIG_LWIP_IPV6_FORWARD is not set -CONFIG_LWIP_IPV6_RDNSS_MAX_DNS_SERVERS=0 # CONFIG_LWIP_NETIF_STATUS_CALLBACK is not set CONFIG_LWIP_NETIF_LOOPBACK=y CONFIG_LWIP_LOOPBACK_MAX_PBUFS=8 @@ -953,7 +958,8 @@ CONFIG_LWIP_MAX_RAW_PCBS=16 # # SNTP # -CONFIG_LWIP_DHCP_MAX_NTP_SERVERS=1 +CONFIG_LWIP_SNTP_MAX_SERVERS=1 +# CONFIG_LWIP_DHCP_GET_NTP_SRV is not set CONFIG_LWIP_SNTP_UPDATE_DELAY=3600000 # end of SNTP @@ -1045,6 +1051,7 @@ CONFIG_MBEDTLS_SSL_RENEGOTIATION=y CONFIG_MBEDTLS_SSL_PROTO_TLS1=y CONFIG_MBEDTLS_SSL_PROTO_TLS1_1=y CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y +# CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1 is not set CONFIG_MBEDTLS_SSL_PROTO_DTLS=y CONFIG_MBEDTLS_SSL_ALPN=y CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS=y @@ -1115,6 +1122,7 @@ CONFIG_MDNS_TASK_AFFINITY=0x0 CONFIG_MDNS_SERVICE_ADD_TIMEOUT_MS=2000 # CONFIG_MDNS_STRICT_MODE is not set CONFIG_MDNS_TIMER_PERIOD_MS=100 +# CONFIG_MDNS_NETWORKING_SOCKET is not set # end of mDNS # @@ -1255,10 +1263,10 @@ CONFIG_WS_BUFFER_SIZE=1024 # end of TCP Transport # -# TinyUSB +# TinyUSB Stack # -# CONFIG_USB_ENABLED is not set -# end of TinyUSB +# CONFIG_TINYUSB is not set +# end of TinyUSB Stack # # Unity unit testing library @@ -1272,6 +1280,16 @@ CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=y # CONFIG_UNITY_ENABLE_BACKTRACE_ON_FAIL is not set # end of Unity unit testing library +# +# USB-OTG +# +CONFIG_USB_OTG_SUPPORTED=y +CONFIG_USB_HOST_CONTROL_TRANSFER_MAX_SIZE=256 +CONFIG_USB_HOST_HW_BUFFER_BIAS_BALANCED=y +# CONFIG_USB_HOST_HW_BUFFER_BIAS_IN is not set +# CONFIG_USB_HOST_HW_BUFFER_BIAS_PERIODIC_OUT is not set +# end of USB-OTG + # # Virtual file system # @@ -1330,37 +1348,6 @@ CONFIG_DSP_MAX_FFT_SIZE_4096=y CONFIG_DSP_MAX_FFT_SIZE=4096 # end of DSP Library -CONFIG_C_IMPL=y -# CONFIG_XTENSA_IMPL is not set - -# -# ESP-FACE Configuration -# -CONFIG_MTMN_LITE_QUANT=y -# CONFIG_MTMN_LITE_FLOAT is not set -# CONFIG_MTMN_HEAVY_QUANT is not set -# CONFIG_FRMN is not set -CONFIG_MFN56_1X=y -# CONFIG_MFN56_2X is not set -# CONFIG_MFN56_3X is not set -# CONFIG_MFN56_4X is not set - -# -# Object Detection -# -# CONFIG_DETECT_WITH_LANDMARK is not set -# end of Object Detection - -# -# Pose Estimation -# -CONFIG_HD_NANO1=y -# CONFIG_HD_LITE1 is not set -CONFIG_HP_NANO1=y -# CONFIG_HP_LITE1 is not set -# end of Pose Estimation -# end of ESP-FACE Configuration - # # Camera configuration # @@ -1433,6 +1420,15 @@ CONFIG_MONITOR_BAUD_115200B=y # CONFIG_MONITOR_BAUD_OTHER is not set CONFIG_MONITOR_BAUD_OTHER_VAL=115200 CONFIG_MONITOR_BAUD=115200 +CONFIG_USB_CDC_ENABLED=y +CONFIG_USB_DESC_CDC_STRING="Espressif CDC Device" +CONFIG_USB_CDC_RX_BUFSIZE=64 +CONFIG_USB_CDC_TX_BUFSIZE=64 +CONFIG_USB_MSC_ENABLED=y +CONFIG_USB_DESC_MSC_STRING="Espressif MSC Device" +CONFIG_USB_MSC_BUFSIZE=512 +CONFIG_USB_DESC_HID_STRING="Espressif HID Device" +CONFIG_USB_DEBUG_LEVEL=0 # CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG is not set # CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE is not set CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED=y @@ -1451,14 +1447,11 @@ CONFIG_WARN_WRITE_STRINGS=y # CONFIG_ESP32_APPTRACE_DEST_TRAX is not set CONFIG_ESP32_APPTRACE_DEST_NONE=y CONFIG_ESP32_APPTRACE_LOCK_ENABLE=y -CONFIG_BTDM_CONTROLLER_BLE_MAX_CONN_EFF=0 -CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_ACL_CONN_EFF=0 -CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_SYNC_CONN_EFF=0 -CONFIG_BTDM_CONTROLLER_PINNED_TO_CORE=0 CONFIG_ADC2_DISABLE_DAC=y # CONFIG_EVENT_LOOP_PROFILING is not set CONFIG_POST_EVENTS_FROM_ISR=y CONFIG_POST_EVENTS_FROM_IRAM_ISR=y +CONFIG_IPC_TASK_STACK_SIZE=1024 # CONFIG_ESP32S2_PANIC_PRINT_HALT is not set CONFIG_ESP32S2_PANIC_PRINT_REBOOT=y # CONFIG_ESP32S2_PANIC_SILENT_REBOOT is not set @@ -1481,7 +1474,6 @@ CONFIG_TASK_WDT=y CONFIG_TASK_WDT_PANIC=y CONFIG_TASK_WDT_TIMEOUT_S=5 # CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0 is not set -CONFIG_IPC_TASK_STACK_SIZE=1024 CONFIG_TIMER_TASK_STACK_SIZE=4096 # CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH is not set # CONFIG_ESP32_ENABLE_COREDUMP_TO_UART is not set @@ -1541,6 +1533,16 @@ CONFIG_ESP32_PTHREAD_TASK_NAME_DEFAULT="pthread" CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS=y # CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_FAILS is not set # CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED is not set +# CONFIG_USB_ENABLED is not set +CONFIG_USB_DEBUG_LEVEL=0 +CONFIG_USB_DESC_CDC_STRING="Espressif CDC Device" +CONFIG_USB_DESC_MSC_STRING="Espressif MSC Device" +CONFIG_USB_DESC_HID_STRING="Espressif HID Device" +CONFIG_USB_MSC_ENABLED=y +CONFIG_USB_MSC_BUFSIZE=512 +CONFIG_USB_CDC_ENABLED=y +CONFIG_USB_CDC_RX_BUFSIZE=64 +CONFIG_USB_CDC_TX_BUFSIZE=64 CONFIG_SUPPRESS_SELECT_DEBUG_OUTPUT=y CONFIG_SUPPORT_TERMIOS=y CONFIG_SEMIHOSTFS_MAX_MOUNT_POINTS=1