Update ESP-IDF to v4.4.5
This commit is contained in:
parent
0ce74087a2
commit
45546e7707
1300 changed files with 30822 additions and 33880 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -11,6 +11,7 @@ tools/mkspiffs
|
|||
tools/mklittlefs
|
||||
tools/mkfatfs.exe
|
||||
tools/openocd-esp32
|
||||
tools/esp32-arduino-libs
|
||||
|
||||
# Ignore editor backup files and macOS system metadata
|
||||
.DS_Store
|
||||
|
|
|
|||
16
platform.txt
16
platform.txt
File diff suppressed because one or more lines are too long
|
|
@ -28,6 +28,10 @@ PARTITION_TABLE_SIZE = 0x1000 # Size of partition table
|
|||
MIN_PARTITION_SUBTYPE_APP_OTA = 0x10
|
||||
NUM_PARTITION_SUBTYPE_APP_OTA = 16
|
||||
|
||||
SECURE_NONE = None
|
||||
SECURE_V1 = 'v1'
|
||||
SECURE_V2 = 'v2'
|
||||
|
||||
__version__ = '1.2'
|
||||
|
||||
APP_TYPE = 0x00
|
||||
|
|
@ -91,13 +95,26 @@ ALIGNMENT = {
|
|||
STRICT_DATA_ALIGNMENT = 0x1000
|
||||
|
||||
|
||||
def get_alignment_for_type(ptype):
|
||||
def get_alignment_offset_for_type(ptype):
|
||||
return ALIGNMENT.get(ptype, ALIGNMENT[DATA_TYPE])
|
||||
|
||||
|
||||
def get_alignment_size_for_type(ptype):
|
||||
if ptype == APP_TYPE and secure == SECURE_V1:
|
||||
# For secure boot v1 case, app partition must be 64K aligned
|
||||
# signature block (68 bytes) lies at the very end of 64K block
|
||||
return 0x10000
|
||||
if ptype == APP_TYPE and secure == SECURE_V2:
|
||||
# For secure boot v2 case, app partition must be 4K aligned
|
||||
# signature block (4K) is kept after padding the unsigned image to 64K boundary
|
||||
return 0x1000
|
||||
# No specific size alignement requirement as such
|
||||
return 0x1
|
||||
|
||||
|
||||
quiet = False
|
||||
md5sum = True
|
||||
secure = False
|
||||
secure = SECURE_NONE
|
||||
offset_part_table = 0
|
||||
|
||||
|
||||
|
|
@ -164,7 +181,7 @@ class PartitionTable(list):
|
|||
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 = get_alignment_for_type(e.type)
|
||||
pad_to = get_alignment_offset_for_type(e.type)
|
||||
if last_end % pad_to != 0:
|
||||
last_end += pad_to - (last_end % pad_to)
|
||||
e.offset = last_end
|
||||
|
|
@ -397,18 +414,20 @@ class PartitionDefinition(object):
|
|||
raise ValidationError(self, 'Subtype field is not set')
|
||||
if self.offset is None:
|
||||
raise ValidationError(self, 'Offset field is not set')
|
||||
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 is None:
|
||||
raise ValidationError(self, 'Size field is not set')
|
||||
offset_align = get_alignment_offset_for_type(self.type)
|
||||
if self.offset % offset_align:
|
||||
raise ValidationError(self, 'Offset 0x%x is not aligned to 0x%x' % (self.offset, offset_align))
|
||||
# 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')
|
||||
if self.type == APP_TYPE and secure is not SECURE_NONE:
|
||||
size_align = get_alignment_size_for_type(self.type)
|
||||
if self.size % size_align:
|
||||
raise ValidationError(self, 'Size 0x%x is not aligned to 0x%x' % (self.size, size_align))
|
||||
|
||||
if self.name in TYPES and TYPES.get(self.name, '') != self.type:
|
||||
critical("WARNING: Partition has name '%s' which is a partition type, but does not match this partition's "
|
||||
|
|
@ -513,7 +532,7 @@ def main():
|
|||
'enabled by default and this flag does nothing.', action='store_true')
|
||||
parser.add_argument('--quiet', '-q', help="Don't print non-critical status messages to stderr", action='store_true')
|
||||
parser.add_argument('--offset', '-o', help='Set offset partition table', default='0x8000')
|
||||
parser.add_argument('--secure', help='Require app partitions to be suitable for secure boot', action='store_true')
|
||||
parser.add_argument('--secure', help='Require app partitions to be suitable for secure boot', nargs='?', const=SECURE_V1, choices=[SECURE_V1, SECURE_V2])
|
||||
parser.add_argument('input', help='Path to CSV or binary file to parse.', type=argparse.FileType('rb'))
|
||||
parser.add_argument('output', help='Path to output converted binary or CSV file. Will use stdout if omitted.',
|
||||
nargs='?', default='-')
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -95,8 +95,6 @@
|
|||
#define CONFIG_ARDUHAL_ESP_LOG 1
|
||||
#define CONFIG_ARDUHAL_PARTITION_SCHEME_DEFAULT 1
|
||||
#define CONFIG_ARDUHAL_PARTITION_SCHEME "default"
|
||||
#define CONFIG_USE_AFE 1
|
||||
#define CONFIG_AFE_INTERFACE_V1 1
|
||||
#define CONFIG_COMPILER_OPTIMIZATION_SIZE 1
|
||||
#define CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE 1
|
||||
#define CONFIG_COMPILER_OPTIMIZATION_ASSERTION_LEVEL 2
|
||||
|
|
@ -137,6 +135,7 @@
|
|||
#define CONFIG_BTDM_SCAN_DUPL_TYPE_DEVICE 1
|
||||
#define CONFIG_BTDM_SCAN_DUPL_TYPE 0
|
||||
#define CONFIG_BTDM_SCAN_DUPL_CACHE_SIZE 20
|
||||
#define CONFIG_BTDM_SCAN_DUPL_CACHE_REFRESH_PERIOD 0
|
||||
#define CONFIG_BTDM_BLE_MESH_SCAN_DUPL_EN 1
|
||||
#define CONFIG_BTDM_MESH_DUPL_SCAN_CACHE_SIZE 100
|
||||
#define CONFIG_BTDM_CTRL_FULL_SCAN_SUPPORTED 1
|
||||
|
|
@ -221,6 +220,11 @@
|
|||
#define CONFIG_ESP32_ECO3_CACHE_LOCK_FIX 1
|
||||
#define CONFIG_ESP32_REV_MIN_0 1
|
||||
#define CONFIG_ESP32_REV_MIN 0
|
||||
#define CONFIG_ESP32_REV_MIN_FULL 0
|
||||
#define CONFIG_ESP_REV_MIN_FULL 0
|
||||
#define CONFIG_ESP32_REV_MAX_FULL_STR_OPT 1
|
||||
#define CONFIG_ESP32_REV_MAX_FULL 399
|
||||
#define CONFIG_ESP_REV_MAX_FULL 399
|
||||
#define CONFIG_ESP32_DPORT_WORKAROUND 1
|
||||
#define CONFIG_ESP32_DEFAULT_CPU_FREQ_160 1
|
||||
#define CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ 160
|
||||
|
|
@ -314,7 +318,8 @@
|
|||
#define CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE 1
|
||||
#define CONFIG_ESP_PHY_MAX_WIFI_TX_POWER 20
|
||||
#define CONFIG_ESP_PHY_MAX_TX_POWER 20
|
||||
#define CONFIG_ESP_PHY_REDUCE_TX_POWER 1
|
||||
#define CONFIG_ESP_PHY_RF_CAL_PARTIAL 1
|
||||
#define CONFIG_ESP_PHY_CALIBRATION_MODE 0
|
||||
#define CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT 1
|
||||
#define CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE 32
|
||||
#define CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE 2048
|
||||
|
|
@ -366,6 +371,7 @@
|
|||
#define CONFIG_ESP_COREDUMP_CHECK_BOOT 1
|
||||
#define CONFIG_ESP_COREDUMP_ENABLE 1
|
||||
#define CONFIG_ESP_COREDUMP_MAX_TASKS_NUM 64
|
||||
#define CONFIG_ESP_COREDUMP_STACK_SIZE 1024
|
||||
#define CONFIG_FATFS_CODEPAGE_850 1
|
||||
#define CONFIG_FATFS_CODEPAGE 850
|
||||
#define CONFIG_FATFS_LFN_STACK 1
|
||||
|
|
@ -439,10 +445,13 @@
|
|||
#define CONFIG_LWIP_ETHARP_TRUST_IP_MAC 1
|
||||
#define CONFIG_LWIP_ESP_GRATUITOUS_ARP 1
|
||||
#define CONFIG_LWIP_GARP_TMR_INTERVAL 60
|
||||
#define CONFIG_LWIP_ESP_MLDV6_REPORT 1
|
||||
#define CONFIG_LWIP_MLDV6_TMR_INTERVAL 40
|
||||
#define CONFIG_LWIP_TCPIP_RECVMBOX_SIZE 32
|
||||
#define CONFIG_LWIP_DHCP_DISABLE_VENDOR_CLASS_ID 1
|
||||
#define CONFIG_LWIP_DHCP_RESTORE_LAST_IP 1
|
||||
#define CONFIG_LWIP_DHCP_OPTIONS_LEN 128
|
||||
#define CONFIG_LWIP_DHCP_COARSE_TIMER_SECS 1
|
||||
#define CONFIG_LWIP_DHCPS 1
|
||||
#define CONFIG_LWIP_DHCPS_LEASE_UNIT 60
|
||||
#define CONFIG_LWIP_DHCPS_MAX_STATION_NUM 8
|
||||
|
|
@ -647,6 +656,8 @@
|
|||
#define CONFIG_RTC_STORE_CRITICAL_DATA_SIZE 2048
|
||||
#define CONFIG_RTC_STORE_REPORTING_WATERMARK_PERCENT 80
|
||||
#define CONFIG_IO_GLITCH_FILTER_TIME_MS 50
|
||||
#define CONFIG_DIAG_DATA_STORE_RTC 1
|
||||
#define CONFIG_DIAG_DATA_STORE_REPORTING_WATERMARK_PERCENT 80
|
||||
#define CONFIG_OV7670_SUPPORT 1
|
||||
#define CONFIG_OV7725_SUPPORT 1
|
||||
#define CONFIG_NT99141_SUPPORT 1
|
||||
|
|
@ -726,6 +737,7 @@
|
|||
#define CONFIG_ESP32_COREDUMP_CHECKSUM_CRC32 CONFIG_ESP_COREDUMP_CHECKSUM_CRC32
|
||||
#define CONFIG_ESP32_COREDUMP_DATA_FORMAT_ELF CONFIG_ESP_COREDUMP_DATA_FORMAT_ELF
|
||||
#define CONFIG_ESP32_CORE_DUMP_MAX_TASKS_NUM CONFIG_ESP_COREDUMP_MAX_TASKS_NUM
|
||||
#define CONFIG_ESP32_CORE_DUMP_STACK_SIZE CONFIG_ESP_COREDUMP_STACK_SIZE
|
||||
#define CONFIG_ESP32_DEFAULT_PTHREAD_CORE_NO_AFFINITY CONFIG_PTHREAD_DEFAULT_CORE_NO_AFFINITY
|
||||
#define CONFIG_ESP32_ENABLE_COREDUMP CONFIG_ESP_COREDUMP_ENABLE
|
||||
#define CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH
|
||||
|
|
@ -738,7 +750,6 @@
|
|||
#define CONFIG_ESP32_PTHREAD_TASK_NAME_DEFAULT CONFIG_PTHREAD_TASK_NAME_DEFAULT
|
||||
#define CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT CONFIG_PTHREAD_TASK_PRIO_DEFAULT
|
||||
#define CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT
|
||||
#define CONFIG_ESP32_REDUCE_PHY_TX_POWER CONFIG_ESP_PHY_REDUCE_TX_POWER
|
||||
#define CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC CONFIG_ESP32_RTC_CLK_SRC_INT_RC
|
||||
#define CONFIG_ESP_GRATUITOUS_ARP CONFIG_LWIP_ESP_GRATUITOUS_ARP
|
||||
#define CONFIG_FLASHMODE_DIO CONFIG_ESPTOOLPY_FLASHMODE_DIO
|
||||
|
|
@ -779,7 +790,6 @@
|
|||
#define CONFIG_OPTIMIZATION_LEVEL_RELEASE CONFIG_COMPILER_OPTIMIZATION_SIZE
|
||||
#define CONFIG_POST_EVENTS_FROM_IRAM_ISR CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR
|
||||
#define CONFIG_POST_EVENTS_FROM_ISR CONFIG_ESP_EVENT_POST_FROM_ISR
|
||||
#define CONFIG_REDUCE_PHY_TX_POWER CONFIG_ESP_PHY_REDUCE_TX_POWER
|
||||
#define CONFIG_SCAN_DUPLICATE_BY_DEVICE_ADDR CONFIG_BTDM_SCAN_DUPL_TYPE_DEVICE
|
||||
#define CONFIG_SCAN_DUPLICATE_TYPE CONFIG_BTDM_SCAN_DUPL_TYPE
|
||||
#define CONFIG_SEMIHOSTFS_MAX_MOUNT_POINTS CONFIG_VFS_SEMIHOSTFS_MAX_MOUNT_POINTS
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -95,8 +95,6 @@
|
|||
#define CONFIG_ARDUHAL_ESP_LOG 1
|
||||
#define CONFIG_ARDUHAL_PARTITION_SCHEME_DEFAULT 1
|
||||
#define CONFIG_ARDUHAL_PARTITION_SCHEME "default"
|
||||
#define CONFIG_USE_AFE 1
|
||||
#define CONFIG_AFE_INTERFACE_V1 1
|
||||
#define CONFIG_COMPILER_OPTIMIZATION_SIZE 1
|
||||
#define CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE 1
|
||||
#define CONFIG_COMPILER_OPTIMIZATION_ASSERTION_LEVEL 2
|
||||
|
|
@ -137,6 +135,7 @@
|
|||
#define CONFIG_BTDM_SCAN_DUPL_TYPE_DEVICE 1
|
||||
#define CONFIG_BTDM_SCAN_DUPL_TYPE 0
|
||||
#define CONFIG_BTDM_SCAN_DUPL_CACHE_SIZE 20
|
||||
#define CONFIG_BTDM_SCAN_DUPL_CACHE_REFRESH_PERIOD 0
|
||||
#define CONFIG_BTDM_BLE_MESH_SCAN_DUPL_EN 1
|
||||
#define CONFIG_BTDM_MESH_DUPL_SCAN_CACHE_SIZE 100
|
||||
#define CONFIG_BTDM_CTRL_FULL_SCAN_SUPPORTED 1
|
||||
|
|
@ -221,6 +220,11 @@
|
|||
#define CONFIG_ESP32_ECO3_CACHE_LOCK_FIX 1
|
||||
#define CONFIG_ESP32_REV_MIN_0 1
|
||||
#define CONFIG_ESP32_REV_MIN 0
|
||||
#define CONFIG_ESP32_REV_MIN_FULL 0
|
||||
#define CONFIG_ESP_REV_MIN_FULL 0
|
||||
#define CONFIG_ESP32_REV_MAX_FULL_STR_OPT 1
|
||||
#define CONFIG_ESP32_REV_MAX_FULL 399
|
||||
#define CONFIG_ESP_REV_MAX_FULL 399
|
||||
#define CONFIG_ESP32_DPORT_WORKAROUND 1
|
||||
#define CONFIG_ESP32_DEFAULT_CPU_FREQ_160 1
|
||||
#define CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ 160
|
||||
|
|
@ -314,7 +318,8 @@
|
|||
#define CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE 1
|
||||
#define CONFIG_ESP_PHY_MAX_WIFI_TX_POWER 20
|
||||
#define CONFIG_ESP_PHY_MAX_TX_POWER 20
|
||||
#define CONFIG_ESP_PHY_REDUCE_TX_POWER 1
|
||||
#define CONFIG_ESP_PHY_RF_CAL_PARTIAL 1
|
||||
#define CONFIG_ESP_PHY_CALIBRATION_MODE 0
|
||||
#define CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT 1
|
||||
#define CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE 32
|
||||
#define CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE 2048
|
||||
|
|
@ -366,6 +371,7 @@
|
|||
#define CONFIG_ESP_COREDUMP_CHECK_BOOT 1
|
||||
#define CONFIG_ESP_COREDUMP_ENABLE 1
|
||||
#define CONFIG_ESP_COREDUMP_MAX_TASKS_NUM 64
|
||||
#define CONFIG_ESP_COREDUMP_STACK_SIZE 1024
|
||||
#define CONFIG_FATFS_CODEPAGE_850 1
|
||||
#define CONFIG_FATFS_CODEPAGE 850
|
||||
#define CONFIG_FATFS_LFN_STACK 1
|
||||
|
|
@ -439,10 +445,13 @@
|
|||
#define CONFIG_LWIP_ETHARP_TRUST_IP_MAC 1
|
||||
#define CONFIG_LWIP_ESP_GRATUITOUS_ARP 1
|
||||
#define CONFIG_LWIP_GARP_TMR_INTERVAL 60
|
||||
#define CONFIG_LWIP_ESP_MLDV6_REPORT 1
|
||||
#define CONFIG_LWIP_MLDV6_TMR_INTERVAL 40
|
||||
#define CONFIG_LWIP_TCPIP_RECVMBOX_SIZE 32
|
||||
#define CONFIG_LWIP_DHCP_DISABLE_VENDOR_CLASS_ID 1
|
||||
#define CONFIG_LWIP_DHCP_RESTORE_LAST_IP 1
|
||||
#define CONFIG_LWIP_DHCP_OPTIONS_LEN 128
|
||||
#define CONFIG_LWIP_DHCP_COARSE_TIMER_SECS 1
|
||||
#define CONFIG_LWIP_DHCPS 1
|
||||
#define CONFIG_LWIP_DHCPS_LEASE_UNIT 60
|
||||
#define CONFIG_LWIP_DHCPS_MAX_STATION_NUM 8
|
||||
|
|
@ -647,6 +656,8 @@
|
|||
#define CONFIG_RTC_STORE_CRITICAL_DATA_SIZE 2048
|
||||
#define CONFIG_RTC_STORE_REPORTING_WATERMARK_PERCENT 80
|
||||
#define CONFIG_IO_GLITCH_FILTER_TIME_MS 50
|
||||
#define CONFIG_DIAG_DATA_STORE_RTC 1
|
||||
#define CONFIG_DIAG_DATA_STORE_REPORTING_WATERMARK_PERCENT 80
|
||||
#define CONFIG_OV7670_SUPPORT 1
|
||||
#define CONFIG_OV7725_SUPPORT 1
|
||||
#define CONFIG_NT99141_SUPPORT 1
|
||||
|
|
@ -726,6 +737,7 @@
|
|||
#define CONFIG_ESP32_COREDUMP_CHECKSUM_CRC32 CONFIG_ESP_COREDUMP_CHECKSUM_CRC32
|
||||
#define CONFIG_ESP32_COREDUMP_DATA_FORMAT_ELF CONFIG_ESP_COREDUMP_DATA_FORMAT_ELF
|
||||
#define CONFIG_ESP32_CORE_DUMP_MAX_TASKS_NUM CONFIG_ESP_COREDUMP_MAX_TASKS_NUM
|
||||
#define CONFIG_ESP32_CORE_DUMP_STACK_SIZE CONFIG_ESP_COREDUMP_STACK_SIZE
|
||||
#define CONFIG_ESP32_DEFAULT_PTHREAD_CORE_NO_AFFINITY CONFIG_PTHREAD_DEFAULT_CORE_NO_AFFINITY
|
||||
#define CONFIG_ESP32_ENABLE_COREDUMP CONFIG_ESP_COREDUMP_ENABLE
|
||||
#define CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH
|
||||
|
|
@ -738,7 +750,6 @@
|
|||
#define CONFIG_ESP32_PTHREAD_TASK_NAME_DEFAULT CONFIG_PTHREAD_TASK_NAME_DEFAULT
|
||||
#define CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT CONFIG_PTHREAD_TASK_PRIO_DEFAULT
|
||||
#define CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT
|
||||
#define CONFIG_ESP32_REDUCE_PHY_TX_POWER CONFIG_ESP_PHY_REDUCE_TX_POWER
|
||||
#define CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC CONFIG_ESP32_RTC_CLK_SRC_INT_RC
|
||||
#define CONFIG_ESP_GRATUITOUS_ARP CONFIG_LWIP_ESP_GRATUITOUS_ARP
|
||||
#define CONFIG_FLASHMODE_DOUT CONFIG_ESPTOOLPY_FLASHMODE_DOUT
|
||||
|
|
@ -779,7 +790,6 @@
|
|||
#define CONFIG_OPTIMIZATION_LEVEL_RELEASE CONFIG_COMPILER_OPTIMIZATION_SIZE
|
||||
#define CONFIG_POST_EVENTS_FROM_IRAM_ISR CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR
|
||||
#define CONFIG_POST_EVENTS_FROM_ISR CONFIG_ESP_EVENT_POST_FROM_ISR
|
||||
#define CONFIG_REDUCE_PHY_TX_POWER CONFIG_ESP_PHY_REDUCE_TX_POWER
|
||||
#define CONFIG_SCAN_DUPLICATE_BY_DEVICE_ADDR CONFIG_BTDM_SCAN_DUPL_TYPE_DEVICE
|
||||
#define CONFIG_SCAN_DUPLICATE_TYPE CONFIG_BTDM_SCAN_DUPL_TYPE
|
||||
#define CONFIG_SEMIHOSTFS_MAX_MOUNT_POINTS CONFIG_VFS_SEMIHOSTFS_MAX_MOUNT_POINTS
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -79,8 +79,15 @@ typedef struct {
|
|||
* pin and sets this field to 0xEE=disabled) */
|
||||
uint8_t spi_pin_drv[3]; /*!< Drive settings for the SPI flash pins (read by ROM bootloader) */
|
||||
esp_chip_id_t chip_id; /*!< Chip identification number */
|
||||
uint8_t min_chip_rev; /*!< Minimum chip revision supported by image */
|
||||
uint8_t reserved[8]; /*!< Reserved bytes in additional header space, currently unused */
|
||||
uint8_t min_chip_rev; /*!< Minimal chip revision supported by image
|
||||
* After the Major and Minor revision eFuses were introduced into the chips, this field is no longer used.
|
||||
* But for compatibility reasons, we keep this field and the data in it.
|
||||
* Use min_chip_rev_full instead.
|
||||
* The software interprets this as a Major version for most of the chips and as a Minor version for the ESP32-C3.
|
||||
*/
|
||||
uint16_t min_chip_rev_full; /*!< Minimal chip revision supported by image, in format: major * 100 + minor */
|
||||
uint16_t max_chip_rev_full; /*!< Maximal chip revision supported by image, in format: major * 100 + minor */
|
||||
uint8_t reserved[4]; /*!< Reserved bytes in additional header space, currently unused */
|
||||
uint8_t hash_appended; /*!< If 1, a SHA256 digest "simple hash" (of the entire image) is appended after the checksum.
|
||||
* Included in image length. This digest
|
||||
* is separate to secure boot and only used for detecting corruption.
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include "esp_spi_flash.h"
|
||||
#endif
|
||||
#include "soc/efuse_periph.h"
|
||||
#include "hal/efuse_hal.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#ifdef CONFIG_EFUSE_VIRTUAL_KEEP_IN_FLASH
|
||||
|
|
@ -46,19 +47,15 @@ typedef enum {
|
|||
*/
|
||||
static inline /** @cond */ IRAM_ATTR /** @endcond */ bool esp_flash_encryption_enabled(void)
|
||||
{
|
||||
#ifndef CONFIG_EFUSE_VIRTUAL_KEEP_IN_FLASH
|
||||
return efuse_hal_flash_encryption_enabled();
|
||||
#else
|
||||
|
||||
uint32_t flash_crypt_cnt = 0;
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#ifndef CONFIG_EFUSE_VIRTUAL_KEEP_IN_FLASH
|
||||
flash_crypt_cnt = REG_GET_FIELD(EFUSE_BLK0_RDATA0_REG, EFUSE_RD_FLASH_CRYPT_CNT);
|
||||
#else
|
||||
esp_efuse_read_field_blob(ESP_EFUSE_FLASH_CRYPT_CNT, &flash_crypt_cnt, ESP_EFUSE_FLASH_CRYPT_CNT[0]->bit_count);
|
||||
#endif
|
||||
esp_efuse_read_field_blob(ESP_EFUSE_FLASH_CRYPT_CNT, &flash_crypt_cnt, ESP_EFUSE_FLASH_CRYPT_CNT[0]->bit_count);
|
||||
#else
|
||||
#ifndef CONFIG_EFUSE_VIRTUAL_KEEP_IN_FLASH
|
||||
flash_crypt_cnt = REG_GET_FIELD(EFUSE_RD_REPEAT_DATA1_REG, EFUSE_SPI_BOOT_CRYPT_CNT);
|
||||
#else
|
||||
esp_efuse_read_field_blob(ESP_EFUSE_SPI_BOOT_CRYPT_CNT, &flash_crypt_cnt, ESP_EFUSE_SPI_BOOT_CRYPT_CNT[0]->bit_count);
|
||||
#endif
|
||||
esp_efuse_read_field_blob(ESP_EFUSE_SPI_BOOT_CRYPT_CNT, &flash_crypt_cnt, ESP_EFUSE_SPI_BOOT_CRYPT_CNT[0]->bit_count);
|
||||
#endif
|
||||
/* __builtin_parity is in flash, so we calculate parity inline */
|
||||
bool enabled = false;
|
||||
|
|
@ -69,6 +66,7 @@ static inline /** @cond */ IRAM_ATTR /** @endcond */ bool esp_flash_encryption_e
|
|||
flash_crypt_cnt >>= 1;
|
||||
}
|
||||
return enabled;
|
||||
#endif // CONFIG_EFUSE_VIRTUAL_KEEP_IN_FLASH
|
||||
}
|
||||
|
||||
/* @brief Update on-device flash encryption
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ typedef struct {
|
|||
*/
|
||||
esp_err_t esp_secure_boot_verify_ecdsa_signature_block(const esp_secure_boot_sig_block_t *sig_block, const uint8_t *image_digest, uint8_t *verified_digest);
|
||||
|
||||
#if !CONFIG_IDF_TARGET_ESP32 || CONFIG_ESP32_REV_MIN_3
|
||||
#if !CONFIG_IDF_TARGET_ESP32 || CONFIG_ESP32_REV_MIN_FULL >= 300
|
||||
/**
|
||||
* @brief Structure to hold public key digests calculated from the signature blocks of a single image.
|
||||
*
|
||||
|
|
@ -223,7 +223,7 @@ typedef struct {
|
|||
*
|
||||
*/
|
||||
esp_err_t esp_secure_boot_verify_rsa_signature_block(const ets_secure_boot_signature_t *sig_block, const uint8_t *image_digest, uint8_t *verified_digest);
|
||||
#endif // !CONFIG_IDF_TARGET_ESP32 || CONFIG_ESP32_REV_MIN_3
|
||||
#endif // !CONFIG_IDF_TARGET_ESP32 || CONFIG_ESP32_REV_MIN_FULL >= 300
|
||||
|
||||
/** @brief Legacy ECDSA verification function
|
||||
*
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ typedef enum {
|
|||
ESP_BLUFI_DATA_FORMAT_ERROR,
|
||||
ESP_BLUFI_CALC_MD5_ERROR,
|
||||
ESP_BLUFI_WIFI_SCAN_FAIL,
|
||||
ESP_BLUFI_MSG_STATE_ERROR,
|
||||
} esp_blufi_error_state_t;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -120,6 +120,52 @@ extern "C" {
|
|||
#define NET_BUF_SIMPLE_ASSERT(cond)
|
||||
#endif
|
||||
|
||||
#if CONFIG_BLE_MESH_BQB_TEST_LOG
|
||||
/**
|
||||
* For example, the test case "MESH/NODE/TNPT/BV-01-C"
|
||||
* could use BT_BQB(BLE_MESH_BQB_TEST_LOG_LEVEL_PRIMARY_ID_NODE | BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_TNPT, "msg %s", msg)
|
||||
* to print some message.
|
||||
*/
|
||||
enum BLE_MESH_BQB_TEST_LOG_LEVEL {
|
||||
BLE_MESH_BQB_TEST_LOG_LEVEL_OUTPUT_ALL = 0, /* Output all BQB related test log */
|
||||
BLE_MESH_BQB_TEST_LOG_LEVEL_PRIMARY_ID_NODE = BIT(0),
|
||||
BLE_MESH_BQB_TEST_LOG_LEVEL_PRIMARY_ID_PVNR = BIT(1),
|
||||
BLE_MESH_BQB_TEST_LOG_LEVEL_PRIMARY_ID_CFGCL = BIT(2),
|
||||
BLE_MESH_BQB_TEST_LOG_LEVEL_PRIMARY_ID_SR = BIT(3),
|
||||
BLE_MESH_BQB_TEST_LOG_LEVEL_PRIMARY_ID_CL = BIT(4),
|
||||
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_PBADV = BIT(5),
|
||||
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_MPS = BIT(6),
|
||||
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_PROV = BIT(7),
|
||||
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_BCN = BIT(8),
|
||||
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_NET = BIT(9),
|
||||
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_RLY = BIT(10),
|
||||
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_TNPT = BIT(11),
|
||||
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_IVU = BIT(12),
|
||||
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_KR = BIT(13),
|
||||
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_FRND_FN = BIT(14),
|
||||
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_FRND_LPN = BIT(15),
|
||||
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_PROX = BIT(16),
|
||||
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_MPXS = BIT(17),
|
||||
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_CFG = BIT(18),
|
||||
BLE_MESH_BQB_TEST_LOG_LEVEL_SUB_ID_HM = BIT(19),
|
||||
};
|
||||
|
||||
#define BLE_MESH_BQB_TEST_LOG_LEVEL_OUTPUT_NONE 0x000FFFFF
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_BQB_TEST_LOG */
|
||||
|
||||
#if (CONFIG_BLE_MESH_BQB_TEST_LOG && !CONFIG_BLE_MESH_NO_LOG)
|
||||
extern bool bt_mesh_bqb_test_flag_check(uint32_t flag_mask);
|
||||
extern int bt_mesh_bqb_test_flag_set(uint32_t value);
|
||||
#define BT_BQB(flag_mask, fmt, args...) \
|
||||
do { \
|
||||
if (bt_mesh_bqb_test_flag_check(flag_mask)) \
|
||||
BLE_MESH_PRINT_I("BLE_MESH_BQB", fmt, ## args); \
|
||||
} while (0)
|
||||
#else
|
||||
#define BT_BQB(flag_mask, fmt, args...)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -302,6 +302,7 @@ typedef union {
|
|||
uint8_t tl; /*!< transaction label, 0 to 15 */
|
||||
uint8_t key_code; /*!< passthrough command code */
|
||||
uint8_t key_state; /*!< 0 for PRESSED, 1 for RELEASED */
|
||||
esp_avrc_rsp_t rsp_code; /*!< response code */
|
||||
} psth_rsp; /*!< passthrough command response */
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ extern "C" {
|
|||
return ESP_ERR_INVALID_STATE; \
|
||||
}
|
||||
|
||||
#define ESP_BT_STATUS_BASE_FOR_HCI_ERR 0X0100 /* base for coverting HCI error code to ESP status */
|
||||
|
||||
/* relate to BT_STATUS_xxx in bt_def.h */
|
||||
/// Status Return Value
|
||||
|
|
@ -53,6 +54,71 @@ typedef enum {
|
|||
ESP_BT_STATUS_ERR_ILLEGAL_PARAMETER_FMT, /* relate to HCI_ERR_ILLEGAL_PARAMETER_FMT in stack/hcidefs.h */
|
||||
ESP_BT_STATUS_MEMORY_FULL = 20, /* relate to BT_STATUS_MEMORY_FULL in bt_def.h */
|
||||
ESP_BT_STATUS_EIR_TOO_LARGE, /* relate to BT_STATUS_EIR_TOO_LARGE in bt_def.h */
|
||||
ESP_BT_STATUS_HCI_SUCCESS = ESP_BT_STATUS_BASE_FOR_HCI_ERR,
|
||||
ESP_BT_STATUS_HCI_PENDING,
|
||||
ESP_BT_STATUS_HCI_ILLEGAL_COMMAND,
|
||||
ESP_BT_STATUS_HCI_NO_CONNECTION,
|
||||
ESP_BT_STATUS_HCI_HW_FAILURE,
|
||||
ESP_BT_STATUS_HCI_PAGE_TIMEOUT,
|
||||
ESP_BT_STATUS_HCI_AUTH_FAILURE,
|
||||
ESP_BT_STATUS_HCI_KEY_MISSING,
|
||||
ESP_BT_STATUS_HCI_MEMORY_FULL,
|
||||
ESP_BT_STATUS_HCI_CONNECTION_TOUT,
|
||||
ESP_BT_STATUS_HCI_MAX_NUM_OF_CONNECTIONS,
|
||||
ESP_BT_STATUS_HCI_MAX_NUM_OF_SCOS,
|
||||
ESP_BT_STATUS_HCI_CONNECTION_EXISTS,
|
||||
ESP_BT_STATUS_HCI_COMMAND_DISALLOWED,
|
||||
ESP_BT_STATUS_HCI_HOST_REJECT_RESOURCES,
|
||||
ESP_BT_STATUS_HCI_HOST_REJECT_SECURITY,
|
||||
ESP_BT_STATUS_HCI_HOST_REJECT_DEVICE,
|
||||
ESP_BT_STATUS_HCI_HOST_TIMEOUT,
|
||||
ESP_BT_STATUS_HCI_UNSUPPORTED_VALUE,
|
||||
ESP_BT_STATUS_HCI_ILLEGAL_PARAMETER_FMT,
|
||||
ESP_BT_STATUS_HCI_PEER_USER,
|
||||
ESP_BT_STATUS_HCI_PEER_LOW_RESOURCES,
|
||||
ESP_BT_STATUS_HCI_PEER_POWER_OFF,
|
||||
ESP_BT_STATUS_HCI_CONN_CAUSE_LOCAL_HOST,
|
||||
ESP_BT_STATUS_HCI_REPEATED_ATTEMPTS,
|
||||
ESP_BT_STATUS_HCI_PAIRING_NOT_ALLOWED,
|
||||
ESP_BT_STATUS_HCI_UNKNOWN_LMP_PDU,
|
||||
ESP_BT_STATUS_HCI_UNSUPPORTED_REM_FEATURE,
|
||||
ESP_BT_STATUS_HCI_SCO_OFFSET_REJECTED,
|
||||
ESP_BT_STATUS_HCI_SCO_INTERVAL_REJECTED,
|
||||
ESP_BT_STATUS_HCI_SCO_AIR_MODE,
|
||||
ESP_BT_STATUS_HCI_INVALID_LMP_PARAM,
|
||||
ESP_BT_STATUS_HCI_UNSPECIFIED,
|
||||
ESP_BT_STATUS_HCI_UNSUPPORTED_LMP_PARAMETERS,
|
||||
ESP_BT_STATUS_HCI_ROLE_CHANGE_NOT_ALLOWED,
|
||||
ESP_BT_STATUS_HCI_LMP_RESPONSE_TIMEOUT,
|
||||
ESP_BT_STATUS_HCI_LMP_ERR_TRANS_COLLISION,
|
||||
ESP_BT_STATUS_HCI_LMP_PDU_NOT_ALLOWED,
|
||||
ESP_BT_STATUS_HCI_ENCRY_MODE_NOT_ACCEPTABLE,
|
||||
ESP_BT_STATUS_HCI_UNIT_KEY_USED,
|
||||
ESP_BT_STATUS_HCI_QOS_NOT_SUPPORTED,
|
||||
ESP_BT_STATUS_HCI_INSTANT_PASSED,
|
||||
ESP_BT_STATUS_HCI_PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED,
|
||||
ESP_BT_STATUS_HCI_DIFF_TRANSACTION_COLLISION,
|
||||
ESP_BT_STATUS_HCI_UNDEFINED_0x2B,
|
||||
ESP_BT_STATUS_HCI_QOS_UNACCEPTABLE_PARAM,
|
||||
ESP_BT_STATUS_HCI_QOS_REJECTED,
|
||||
ESP_BT_STATUS_HCI_CHAN_CLASSIF_NOT_SUPPORTED,
|
||||
ESP_BT_STATUS_HCI_INSUFFCIENT_SECURITY,
|
||||
ESP_BT_STATUS_HCI_PARAM_OUT_OF_RANGE,
|
||||
ESP_BT_STATUS_HCI_UNDEFINED_0x31,
|
||||
ESP_BT_STATUS_HCI_ROLE_SWITCH_PENDING,
|
||||
ESP_BT_STATUS_HCI_UNDEFINED_0x33,
|
||||
ESP_BT_STATUS_HCI_RESERVED_SLOT_VIOLATION,
|
||||
ESP_BT_STATUS_HCI_ROLE_SWITCH_FAILED,
|
||||
ESP_BT_STATUS_HCI_INQ_RSP_DATA_TOO_LARGE,
|
||||
ESP_BT_STATUS_HCI_SIMPLE_PAIRING_NOT_SUPPORTED,
|
||||
ESP_BT_STATUS_HCI_HOST_BUSY_PAIRING,
|
||||
ESP_BT_STATUS_HCI_REJ_NO_SUITABLE_CHANNEL,
|
||||
ESP_BT_STATUS_HCI_CONTROLLER_BUSY,
|
||||
ESP_BT_STATUS_HCI_UNACCEPT_CONN_INTERVAL,
|
||||
ESP_BT_STATUS_HCI_DIRECTED_ADVERTISING_TIMEOUT,
|
||||
ESP_BT_STATUS_HCI_CONN_TOUT_DUE_TO_MIC_FAILURE,
|
||||
ESP_BT_STATUS_HCI_CONN_FAILED_ESTABLISHMENT,
|
||||
ESP_BT_STATUS_HCI_MAC_CONNECTION_FAILED,
|
||||
} esp_bt_status_t;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ typedef uint8_t esp_ble_io_cap_t; /*!< combination of the io capab
|
|||
|
||||
/// GAP BLE callback event type
|
||||
typedef enum {
|
||||
#if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
//BLE_42_FEATURE_SUPPORT
|
||||
ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT = 0, /*!< When advertising data set complete, the event comes */
|
||||
ESP_GAP_BLE_SCAN_RSP_DATA_SET_COMPLETE_EVT, /*!< When scan response data set complete, the event comes */
|
||||
ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT, /*!< When scan parameters set complete, the event comes */
|
||||
|
|
@ -144,7 +144,7 @@ typedef enum {
|
|||
ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT, /*!< When raw advertising data set complete, the event comes */
|
||||
ESP_GAP_BLE_ADV_START_COMPLETE_EVT, /*!< When start advertising complete, the event comes */
|
||||
ESP_GAP_BLE_SCAN_START_COMPLETE_EVT, /*!< When start scan complete, the event comes */
|
||||
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
//BLE_INCLUDED
|
||||
ESP_GAP_BLE_AUTH_CMPL_EVT = 8, /*!< Authentication complete indication. */
|
||||
ESP_GAP_BLE_KEY_EVT, /*!< BLE key event for peer device keys */
|
||||
ESP_GAP_BLE_SEC_REQ_EVT, /*!< BLE security request */
|
||||
|
|
@ -154,10 +154,10 @@ typedef enum {
|
|||
ESP_GAP_BLE_LOCAL_IR_EVT, /*!< BLE local IR (identity Root 128-bit random static value used to generate Long Term Key) event */
|
||||
ESP_GAP_BLE_LOCAL_ER_EVT, /*!< BLE local ER (Encryption Root vakue used to genrate identity resolving key) event */
|
||||
ESP_GAP_BLE_NC_REQ_EVT, /*!< Numeric Comparison request event */
|
||||
#if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
//BLE_42_FEATURE_SUPPORT
|
||||
ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT, /*!< When stop adv complete, the event comes */
|
||||
ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT, /*!< When stop scan complete, the event comes */
|
||||
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
//BLE_INCLUDED
|
||||
ESP_GAP_BLE_SET_STATIC_RAND_ADDR_EVT = 19, /*!< When set the static rand address complete, the event comes */
|
||||
ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT, /*!< When update connection parameters complete, the event comes */
|
||||
ESP_GAP_BLE_SET_PKT_LENGTH_COMPLETE_EVT, /*!< When set pkt length complete, the event comes */
|
||||
|
|
@ -167,11 +167,11 @@ typedef enum {
|
|||
ESP_GAP_BLE_GET_BOND_DEV_COMPLETE_EVT, /*!< When get the bond device list complete, the event comes */
|
||||
ESP_GAP_BLE_READ_RSSI_COMPLETE_EVT, /*!< When read the rssi complete, the event comes */
|
||||
ESP_GAP_BLE_UPDATE_WHITELIST_COMPLETE_EVT, /*!< When add or remove whitelist complete, the event comes */
|
||||
#if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
//BLE_42_FEATURE_SUPPORT
|
||||
ESP_GAP_BLE_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_COMPLETE_EVT, /*!< When update duplicate exceptional list complete, the event comes */
|
||||
#endif //#if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
//BLE_INCLUDED
|
||||
ESP_GAP_BLE_SET_CHANNELS_EVT = 29, /*!< When setting BLE channels complete, the event comes */
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
//BLE_50_FEATURE_SUPPORT
|
||||
ESP_GAP_BLE_READ_PHY_COMPLETE_EVT, /*!< when reading phy complete, this event comes */
|
||||
ESP_GAP_BLE_SET_PREFERED_DEFAULT_PHY_COMPLETE_EVT, /*!< when preferred default phy complete, this event comes */
|
||||
ESP_GAP_BLE_SET_PREFERED_PHY_COMPLETE_EVT, /*!< when preferred phy complete , this event comes */
|
||||
|
|
@ -206,7 +206,10 @@ typedef enum {
|
|||
ESP_GAP_BLE_PERIODIC_ADV_REPORT_EVT, /*!< when periodic report advertising complete, the event comes */
|
||||
ESP_GAP_BLE_PERIODIC_ADV_SYNC_LOST_EVT, /*!< when periodic advertising sync lost complete, the event comes */
|
||||
ESP_GAP_BLE_PERIODIC_ADV_SYNC_ESTAB_EVT, /*!< when periodic advertising sync establish complete, the event comes */
|
||||
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
//BLE_INCLUDED
|
||||
ESP_GAP_BLE_SC_OOB_REQ_EVT, /*!< Secure Connection OOB request event */
|
||||
ESP_GAP_BLE_SC_CR_LOC_OOB_EVT, /*!< Secure Connection create OOB data complete event */
|
||||
ESP_GAP_BLE_GET_DEV_NAME_COMPLETE_EVT, /*!< When getting BT device name complete, the event comes */
|
||||
ESP_GAP_BLE_EVT_MAX, /*!< when maximum advertising event complete, the event comes */
|
||||
} esp_gap_ble_cb_event_t;
|
||||
|
||||
|
|
@ -647,7 +650,9 @@ 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_WHITELIST_CLEAR = 0x02, /*!< clear all device in whitelist */
|
||||
} esp_ble_wl_operation_t;
|
||||
|
||||
#if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
typedef enum {
|
||||
ESP_BLE_DUPLICATE_EXCEPTIONAL_LIST_ADD = 0, /*!< Add device info into duplicate scan exceptional list */
|
||||
|
|
@ -910,6 +915,13 @@ typedef struct {
|
|||
* @brief Gap callback parameters union
|
||||
*/
|
||||
typedef union {
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_GET_DEV_NAME_COMPLETE_EVT
|
||||
*/
|
||||
struct ble_get_dev_name_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate the get device name success status */
|
||||
char *name; /*!< Name of bluetooth device */
|
||||
} get_dev_name_cmpl; /*!< Event parameter of ESP_GAP_BLE_GET_DEV_NAME_COMPLETE_EVT */
|
||||
#if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT
|
||||
|
|
@ -1053,7 +1065,7 @@ typedef union {
|
|||
*/
|
||||
struct ble_update_whitelist_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate the add or remove whitelist operation success status */
|
||||
esp_ble_wl_opration_t wl_opration; /*!< The value is ESP_BLE_WHITELIST_ADD if add address to whitelist operation success, ESP_BLE_WHITELIST_REMOVE if remove address from the whitelist operation success */
|
||||
esp_ble_wl_operation_t wl_opration; /*!< The value is ESP_BLE_WHITELIST_ADD if add address to whitelist operation success, ESP_BLE_WHITELIST_REMOVE if remove address from the whitelist operation success */
|
||||
} update_whitelist_cmpl; /*!< Event parameter of ESP_GAP_BLE_UPDATE_WHITELIST_COMPLETE_EVT */
|
||||
#if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
/**
|
||||
|
|
@ -1461,7 +1473,7 @@ esp_err_t esp_ble_gap_config_local_privacy (bool privacy_enable);
|
|||
*
|
||||
*
|
||||
* @param[in] icon - External appearance value, these values are defined by the Bluetooth SIG, please refer to
|
||||
* https://specificationrefs.bluetooth.com/assigned-values/Appearance%20Values.pdf
|
||||
* https://www.bluetooth.com/specifications/assigned-numbers/
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
|
|
@ -1537,7 +1549,17 @@ esp_err_t esp_ble_gap_set_prefer_conn_params(esp_bd_addr_t bd_addr,
|
|||
esp_err_t esp_ble_gap_set_device_name(const char *name);
|
||||
|
||||
/**
|
||||
* @brief This function is called to get local used address and adress type.
|
||||
* @brief Get device name of the local device
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_get_device_name(void);
|
||||
|
||||
/**
|
||||
* @brief This function is called to get local used address and address type.
|
||||
* uint8_t *esp_bt_dev_get_address(void) get the public address
|
||||
*
|
||||
* @param[in] local_used_addr - current local used ble address (six bytes)
|
||||
|
|
|
|||
|
|
@ -223,6 +223,8 @@ typedef enum {
|
|||
ESP_BT_GAP_MODE_CHG_EVT,
|
||||
ESP_BT_GAP_REMOVE_BOND_DEV_COMPLETE_EVT, /*!< remove bond device complete event */
|
||||
ESP_BT_GAP_QOS_CMPL_EVT, /*!< QOS complete event */
|
||||
ESP_BT_GAP_ACL_CONN_CMPL_STAT_EVT, /*!< ACL connection complete status event */
|
||||
ESP_BT_GAP_ACL_DISCONN_CMPL_STAT_EVT, /*!< ACL disconnection complete status event */
|
||||
ESP_BT_GAP_EVT_MAX,
|
||||
} esp_bt_gap_cb_event_t;
|
||||
|
||||
|
|
@ -376,6 +378,24 @@ typedef union {
|
|||
which from the master to a particular slave on the ACL
|
||||
logical transport. unit is 0.625ms. */
|
||||
} qos_cmpl; /*!< QoS complete parameter struct */
|
||||
|
||||
/**
|
||||
* @brief ESP_BT_GAP_ACL_CONN_CMPL_STAT_EVT
|
||||
*/
|
||||
struct acl_conn_cmpl_stat_param {
|
||||
esp_bt_status_t stat; /*!< ACL connection status */
|
||||
uint16_t handle; /*!< ACL connection handle */
|
||||
esp_bd_addr_t bda; /*!< remote bluetooth device address */
|
||||
} acl_conn_cmpl_stat; /*!< ACL connection complete status parameter struct */
|
||||
|
||||
/**
|
||||
* @brief ESP_BT_GAP_ACL_DISCONN_CMPL_STAT_EVT
|
||||
*/
|
||||
struct acl_disconn_cmpl_stat_param {
|
||||
esp_bt_status_t reason; /*!< ACL disconnection reason */
|
||||
uint16_t handle; /*!< ACL connection handle */
|
||||
esp_bd_addr_t bda; /*!< remote bluetooth device address */
|
||||
} acl_disconn_cmpl_stat; /*!< ACL disconnection complete status parameter struct */
|
||||
} esp_bt_gap_cb_param_t;
|
||||
|
||||
/**
|
||||
|
|
@ -564,7 +584,9 @@ esp_err_t esp_bt_gap_config_eir_data(esp_bt_eir_data_t *eir_data);
|
|||
/**
|
||||
* @brief This function is called to set class of device.
|
||||
* The structure esp_bt_gap_cb_t will be called with ESP_BT_GAP_SET_COD_EVT after set COD ends.
|
||||
* Some profile have special restrictions on class of device, changes may cause these profile do not work.
|
||||
* This function should be called after Bluetooth profiles are initialized, otherwise the user configured
|
||||
* class of device can be overwritten.
|
||||
* Some profiles have special restrictions on class of device, and changes may make these profiles unable to work.
|
||||
*
|
||||
* @param[in] cod - class of device
|
||||
* @param[in] mode - setting mode
|
||||
|
|
|
|||
|
|
@ -285,6 +285,7 @@ typedef enum {
|
|||
#define ESP_GATT_PERM_WRITE_SIGNED_MITM (1 << 8) /* bit 8 - 0x0100 */ /* relate to BTA_GATT_PERM_WRITE_SIGNED_MITM in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_READ_AUTHORIZATION (1 << 9) /* bit 9 - 0x0200 */
|
||||
#define ESP_GATT_PERM_WRITE_AUTHORIZATION (1 << 10) /* bit 10 - 0x0400 */
|
||||
#define ESP_GATT_PERM_ENCRYPT_KEY_SIZE(keysize) (((keysize - 6) & 0xF) << 12) /* bit 12:15 - 0xF000 */
|
||||
typedef uint16_t esp_gatt_perm_t;
|
||||
|
||||
/* relate to BTA_GATT_CHAR_PROP_BIT_xxx in bta/bta_gatt_api.h */
|
||||
|
|
|
|||
|
|
@ -212,6 +212,8 @@ typedef union {
|
|||
uint8_t link_role; /*!< Link role : master role = 0 ; slave role = 1*/
|
||||
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
|
||||
esp_gatt_conn_params_t conn_params; /*!< current connection parameters */
|
||||
esp_ble_addr_type_t ble_addr_type; /*!< Remote BLE device address type */
|
||||
uint16_t conn_handle; /*!< HCI connection handle */
|
||||
} connect; /*!< Gatt client callback param of ESP_GATTC_CONNECT_EVT */
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -199,6 +199,8 @@ typedef union {
|
|||
uint8_t link_role; /*!< Link role : master role = 0 ; slave role = 1*/
|
||||
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
|
||||
esp_gatt_conn_params_t conn_params; /*!< current Connection parameters */
|
||||
esp_ble_addr_type_t ble_addr_type; /*!< Remote BLE device address type */
|
||||
uint16_t conn_handle; /*!< HCI connection handle */
|
||||
} connect; /*!< Gatt server callback param of ESP_GATTS_CONNECT_EVT */
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -23,86 +23,100 @@
|
|||
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 */
|
||||
/// subclass of hid device
|
||||
#define ESP_HID_CLASS_UNKNOWN (0x00<<2) /*!< unknown HID device subclass */
|
||||
#define ESP_HID_CLASS_JOS (0x01<<2) /*!< joystick */
|
||||
#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
|
||||
* @brief HIDD handshake result code
|
||||
*/
|
||||
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_HID_PAR_HANDSHAKE_RSP_SUCCESS = 0, /*!< successful */
|
||||
ESP_HID_PAR_HANDSHAKE_RSP_NOT_READY = 1, /*!< not ready, device is too busy to accept data */
|
||||
ESP_HID_PAR_HANDSHAKE_RSP_ERR_INVALID_REP_ID = 2, /*!< invalid report ID */
|
||||
ESP_HID_PAR_HANDSHAKE_RSP_ERR_UNSUPPORTED_REQ = 3, /*!< device does not support the request */
|
||||
ESP_HID_PAR_HANDSHAKE_RSP_ERR_INVALID_PARAM = 4, /*!< parameter value is out of range or inappropriate */
|
||||
ESP_HID_PAR_HANDSHAKE_RSP_ERR_UNKNOWN = 14, /*!< device could not identify the error condition */
|
||||
ESP_HID_PAR_HANDSHAKE_RSP_ERR_FATAL = 15, /*!< restart is essential to resume functionality */
|
||||
} 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_OTHER = 0, /*!< unknown report type */
|
||||
ESP_HIDD_REPORT_TYPE_INPUT, /*!< input report */
|
||||
ESP_HIDD_REPORT_TYPE_OUTPUT, /*!< output report */
|
||||
ESP_HIDD_REPORT_TYPE_FEATURE, /*!< feature report */
|
||||
ESP_HIDD_REPORT_TYPE_INTRDATA, /*!< special value for reports to be sent on interrupt channel, INPUT is assumed */
|
||||
} 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_CONN_STATE_CONNECTED, /*!< HID connection established */
|
||||
ESP_HIDD_CONN_STATE_CONNECTING, /*!< connection to remote Bluetooth device */
|
||||
ESP_HIDD_CONN_STATE_DISCONNECTED, /*!< connection released */
|
||||
ESP_HIDD_CONN_STATE_DISCONNECTING, /*!< disconnecting to remote Bluetooth device*/
|
||||
ESP_HIDD_CONN_STATE_UNKNOWN, /*!< unknown connection state */
|
||||
} 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_REPORT_MODE = 0x00, /*!< Report Protocol Mode */
|
||||
ESP_HIDD_BOOT_MODE = 0x01, /*!< Boot Protocol Mode */
|
||||
ESP_HIDD_UNSUPPORTED_MODE = 0xff, /*!< unsupported */
|
||||
} esp_hidd_protocol_mode_t;
|
||||
|
||||
/**
|
||||
* @brief HID Boot Protocol report IDs
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_HIDD_BOOT_REPORT_ID_KEYBOARD = 1, /*!< report ID of Boot Protocol keyboard report */
|
||||
ESP_HIDD_BOOT_REPORT_ID_MOUSE = 2, /*!< report ID of Boot Protocol mouse report */
|
||||
} esp_hidd_boot_report_id_t;
|
||||
|
||||
/**
|
||||
* @brief HIDD characteristics for SDP report
|
||||
* @brief HID Boot Protocol report size including report ID
|
||||
*/
|
||||
enum {
|
||||
ESP_HIDD_BOOT_REPORT_SIZE_KEYBOARD = 9, /*!< report size of Boot Protocol keyboard report */
|
||||
ESP_HIDD_BOOT_REPORT_SIZE_MOUSE = 4, /*!< report size of Boot Protocol mouse report */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief HID device characteristics for SDP server
|
||||
*/
|
||||
typedef struct {
|
||||
const char *name;
|
||||
const char *description;
|
||||
const char *provider;
|
||||
uint8_t subclass;
|
||||
uint8_t *desc_list;
|
||||
int desc_list_len;
|
||||
const char *name; /*!< service name */
|
||||
const char *description; /*!< service description */
|
||||
const char *provider; /*!< provider name */
|
||||
uint8_t subclass; /*!< HID device subclass */
|
||||
uint8_t *desc_list; /*!< HID descriptor list */
|
||||
int desc_list_len; /*!< size in bytes of HID descriptor list */
|
||||
} esp_hidd_app_param_t;
|
||||
|
||||
/**
|
||||
* @brief HIDD Quality of Service parameters
|
||||
* @brief HIDD Quality of Service parameters negotiated over L2CAP
|
||||
*/
|
||||
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;
|
||||
uint8_t service_type; /*!< the level of service, 0 indicates no traffic */
|
||||
uint32_t token_rate; /*!< token rate in bytes per second, 0 indicates "don't care" */
|
||||
uint32_t token_bucket_size; /*!< limit on the burstness of the application data */
|
||||
uint32_t peak_bandwidth; /*!< bytes per second, value 0 indicates "don't care" */
|
||||
uint32_t access_latency; /*!< maximum acceptable delay in microseconds */
|
||||
uint32_t delay_variation; /*!< the difference in microseconds between the max and min delay */
|
||||
} esp_hidd_qos_param_t;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ extern "C" {
|
|||
|
||||
#endif //CONFIG_BT_ENABLED
|
||||
|
||||
#define ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL 0x20200622
|
||||
#define ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL 0x20221207
|
||||
|
||||
/**
|
||||
* @brief Bluetooth mode for controller enable/disable
|
||||
|
|
@ -128,6 +128,12 @@ the adv packet will be discarded until the memory is restored. */
|
|||
#define MESH_DUPLICATE_SCAN_CACHE_SIZE 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BTDM_SCAN_DUPL_CACHE_REFRESH_PERIOD
|
||||
#define SCAN_DUPL_CACHE_REFRESH_PERIOD CONFIG_BTDM_SCAN_DUPL_CACHE_REFRESH_PERIOD
|
||||
#else
|
||||
#define SCAN_DUPL_CACHE_REFRESH_PERIOD 0
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BTDM_CTRL_MODE_BLE_ONLY)
|
||||
#define BTDM_CONTROLLER_MODE_EFF ESP_BT_MODE_BLE
|
||||
#elif defined(CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY)
|
||||
|
|
@ -183,6 +189,7 @@ the adv packet will be discarded until the memory is restored. */
|
|||
.pcm_role = CONFIG_BTDM_CTRL_PCM_ROLE_EFF, \
|
||||
.pcm_polar = CONFIG_BTDM_CTRL_PCM_POLAR_EFF, \
|
||||
.hli = BTDM_CTRL_HLI, \
|
||||
.dup_list_refresh_period = SCAN_DUPL_CACHE_REFRESH_PERIOD, \
|
||||
.magic = ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL, \
|
||||
}
|
||||
|
||||
|
|
@ -225,6 +232,7 @@ typedef struct {
|
|||
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 */
|
||||
uint16_t dup_list_refresh_period; /*!< Duplicate scan list refresh period */
|
||||
uint32_t magic; /*!< Magic number */
|
||||
} esp_bt_controller_config_t;
|
||||
|
||||
|
|
|
|||
|
|
@ -364,16 +364,21 @@ esp_err_t gpio_get_drive_capability(gpio_num_t gpio_num, gpio_drive_cap_t *stren
|
|||
/**
|
||||
* @brief Enable gpio pad hold function.
|
||||
*
|
||||
* When the pin is set to hold, the state is latched at that moment and will not change no matter how the internal
|
||||
* signals change or how the IO MUX/GPIO configuration is modified (including input enable, output enable,
|
||||
* output value, function, and drive strength values). It can be used to retain the pin state through a
|
||||
* core reset and system reset triggered by watchdog time-out or Deep-sleep events.
|
||||
*
|
||||
* The gpio pad hold function works in both input and output modes, but must be output-capable gpios.
|
||||
* If pad hold enabled:
|
||||
* in output mode: the output level of the pad will be force locked and can not be changed.
|
||||
* in input mode: the input value read will not change, regardless the changes of input signal.
|
||||
* in input mode: input read value can still reflect the changes of the input signal.
|
||||
*
|
||||
* The state of digital gpio cannot be held during Deep-sleep, and it will resume the hold function
|
||||
* The state of the digital gpio cannot be held during Deep-sleep, and it will resume to hold at its default pin state
|
||||
* when the chip wakes up from Deep-sleep. If the digital gpio also needs to be held during Deep-sleep,
|
||||
* `gpio_deep_sleep_hold_en` should also be called.
|
||||
*
|
||||
* Power down or call gpio_hold_dis will disable this function.
|
||||
* Power down or call `gpio_hold_dis` will disable this function.
|
||||
*
|
||||
* @param gpio_num GPIO number, only support output-capable GPIOs
|
||||
*
|
||||
|
|
@ -403,19 +408,21 @@ esp_err_t gpio_hold_en(gpio_num_t gpio_num);
|
|||
esp_err_t gpio_hold_dis(gpio_num_t gpio_num);
|
||||
|
||||
/**
|
||||
* @brief Enable all digital gpio pad hold function during Deep-sleep.
|
||||
* @brief Enable all digital gpio pads hold function during Deep-sleep.
|
||||
*
|
||||
* When the chip is in Deep-sleep mode, all digital gpio will hold the state before sleep, and when the chip is woken up,
|
||||
* the status of digital gpio will not be held. Note that the pad hold feature only works when the chip is in Deep-sleep mode,
|
||||
* when not in sleep mode, the digital gpio state can be changed even you have called this function.
|
||||
* Enabling this feature makes all digital gpio pads be at the holding state during Deep-sleep. The state of each pad
|
||||
* holds is its active configuration (not pad's sleep configuration!).
|
||||
*
|
||||
* Power down or call gpio_hold_dis will disable this function, otherwise, the digital gpio hold feature works as long as the chip enter Deep-sleep.
|
||||
* Note that this pad hold feature only works when the chip is in Deep-sleep mode. When the chip is in active mode,
|
||||
* the digital gpio state can be changed freely even you have called this function.
|
||||
*
|
||||
* After this API is being called, the digital gpio Deep-sleep hold feature will work during every sleep process. You
|
||||
* should call `gpio_deep_sleep_hold_dis` to disable this feature.
|
||||
*/
|
||||
void gpio_deep_sleep_hold_en(void);
|
||||
|
||||
/**
|
||||
* @brief Disable all digital gpio pad hold function during Deep-sleep.
|
||||
*
|
||||
* @brief Disable all digital gpio pads hold function during Deep-sleep.
|
||||
*/
|
||||
void gpio_deep_sleep_hold_dis(void);
|
||||
|
||||
|
|
@ -437,19 +444,25 @@ void gpio_iomux_out(uint8_t gpio_num, int func, bool oen_inv);
|
|||
|
||||
#if SOC_GPIO_SUPPORT_FORCE_HOLD
|
||||
/**
|
||||
* @brief Force hold digital and rtc gpio pad.
|
||||
* @note GPIO force hold, whether the chip in sleep mode or wakeup mode.
|
||||
* @brief Force hold all digital and rtc gpio pads.
|
||||
*
|
||||
* GPIO force hold, no matter the chip in active mode or sleep modes.
|
||||
*
|
||||
* This function will immediately cause all pads to latch the current values of input enable, output enable,
|
||||
* output value, function, and drive strength values.
|
||||
*
|
||||
* @warning This function will hold flash and UART pins as well. Therefore, this function, and all code run afterwards
|
||||
* (till calling `gpio_force_unhold_all` to disable this feature), MUST be placed in internal RAM as holding the flash
|
||||
* pins will halt SPI flash operation, and holding the UART pins will halt any UART logging.
|
||||
* */
|
||||
esp_err_t gpio_force_hold_all(void);
|
||||
|
||||
/**
|
||||
* @brief Force unhold digital and rtc gpio pad.
|
||||
* @note GPIO force unhold, whether the chip in sleep mode or wakeup mode.
|
||||
* @brief Force unhold all digital and rtc gpio pads.
|
||||
* */
|
||||
esp_err_t gpio_force_unhold_all(void);
|
||||
#endif
|
||||
|
||||
#if SOC_GPIO_SUPPORT_SLP_SWITCH
|
||||
/**
|
||||
* @brief Enable SLP_SEL to change GPIO status automantically in lightsleep.
|
||||
* @param gpio_num GPIO number of the pad.
|
||||
|
|
@ -496,7 +509,6 @@ esp_err_t gpio_sleep_set_direction(gpio_num_t gpio_num, gpio_mode_t mode);
|
|||
* - ESP_ERR_INVALID_ARG : Parameter error
|
||||
*/
|
||||
esp_err_t gpio_sleep_set_pull_mode(gpio_num_t gpio_num, gpio_pull_mode_t pull);
|
||||
#endif
|
||||
|
||||
#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
|
||||
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ esp_err_t rtc_gpio_isolate(gpio_num_t gpio_num);
|
|||
* Force hold signal is enabled before going into deep sleep for pins which
|
||||
* are used for EXT1 wakeup.
|
||||
*/
|
||||
esp_err_t rtc_gpio_force_hold_all(void);
|
||||
esp_err_t rtc_gpio_force_hold_en_all(void);
|
||||
|
||||
/**
|
||||
* @brief Disable force hold signal for all RTC IOs
|
||||
|
|
|
|||
|
|
@ -248,7 +248,8 @@ int spicommon_irqdma_source_for_host(spi_host_device_t host);
|
|||
*/
|
||||
typedef void(*dmaworkaround_cb_t)(void *arg);
|
||||
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
//This workaround is only for esp32
|
||||
/**
|
||||
* @brief Request a reset for a certain DMA channel
|
||||
*
|
||||
|
|
@ -303,6 +304,7 @@ void spicommon_dmaworkaround_idle(int dmachan);
|
|||
* @note This public API is deprecated.
|
||||
*/
|
||||
void spicommon_dmaworkaround_transfer_active(int dmachan);
|
||||
#endif //#if CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
/*******************************************************************************
|
||||
* Bus attributes
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
|
@ -58,6 +58,9 @@ typedef enum {
|
|||
UART_PARITY_ERR, /*!< UART RX parity event*/
|
||||
UART_DATA_BREAK, /*!< UART TX data and break event*/
|
||||
UART_PATTERN_DET, /*!< UART pattern detected */
|
||||
#if SOC_UART_SUPPORT_WAKEUP_INT
|
||||
UART_WAKEUP, /*!< UART wakeup event */
|
||||
#endif
|
||||
UART_EVENT_MAX, /*!< UART event max index*/
|
||||
} uart_event_type_t;
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,9 @@ typedef struct {
|
|||
* USB-SERIAL-JTAG driver's ISR will be attached to the same CPU core that calls this function. Thus, users
|
||||
* should ensure that the same core is used when calling `usb_serial_jtag_driver_uninstall()`.
|
||||
*
|
||||
* @note Blocking mode will result in usb_serial_jtag_write_bytes() blocking until all bytes have been written to the TX FIFO.
|
||||
* @note Blocking mode will result in usb_serial_jtag_write_bytes() blocking for a
|
||||
* short period if the TX FIFO if full. It will not block again until the buffer
|
||||
* has some space available again.
|
||||
*
|
||||
* @param usb_serial_jtag_driver_config_t Configuration for usb_serial_jtag driver.
|
||||
*
|
||||
|
|
@ -73,7 +75,7 @@ int usb_serial_jtag_read_bytes(void* buf, uint32_t length, TickType_t ticks_to_w
|
|||
*
|
||||
* @param src data buffer address
|
||||
* @param size data length to send
|
||||
* @param ticks_to_wait Timeout in RTOS ticks
|
||||
* @param ticks_to_wait Maximum timeout in RTOS ticks
|
||||
*
|
||||
* @return
|
||||
* - The number of bytes pushed to the TX FIFO
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
#include "soc/gdma_channel.h"
|
||||
#include "hal/gdma_types.h"
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
@ -23,34 +24,6 @@ extern "C" {
|
|||
*/
|
||||
typedef struct gdma_channel_t *gdma_channel_handle_t;
|
||||
|
||||
/**
|
||||
* @brief Enumeration of peripherals which have the DMA capability
|
||||
* @note Some peripheral might not be available on certain chip, please refer to `soc_caps.h` for detail.
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
GDMA_TRIG_PERIPH_M2M, /*!< GDMA trigger peripheral: M2M */
|
||||
GDMA_TRIG_PERIPH_UART, /*!< GDMA trigger peripheral: UART */
|
||||
GDMA_TRIG_PERIPH_SPI, /*!< GDMA trigger peripheral: SPI */
|
||||
GDMA_TRIG_PERIPH_I2S, /*!< GDMA trigger peripheral: I2S */
|
||||
GDMA_TRIG_PERIPH_AES, /*!< GDMA trigger peripheral: AES */
|
||||
GDMA_TRIG_PERIPH_SHA, /*!< GDMA trigger peripheral: SHA */
|
||||
GDMA_TRIG_PERIPH_ADC, /*!< GDMA trigger peripheral: ADC */
|
||||
GDMA_TRIG_PERIPH_DAC, /*!< GDMA trigger peripheral: DAC */
|
||||
GDMA_TRIG_PERIPH_LCD, /*!< GDMA trigger peripheral: LCD */
|
||||
GDMA_TRIG_PERIPH_CAM, /*!< GDMA trigger peripheral: CAM */
|
||||
GDMA_TRIG_PERIPH_RMT, /*!< GDMA trigger peripheral: RMT */
|
||||
} gdma_trigger_peripheral_t;
|
||||
|
||||
/**
|
||||
* @brief Enumeration of GDMA channel direction
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
GDMA_CHANNEL_DIRECTION_TX, /*!< GDMA channel direction: TX */
|
||||
GDMA_CHANNEL_DIRECTION_RX, /*!< GDMA channel direction: RX */
|
||||
} gdma_channel_direction_t;
|
||||
|
||||
/**
|
||||
* @brief Collection of configuration items that used for allocating GDMA channel
|
||||
*
|
||||
|
|
@ -124,13 +97,13 @@ typedef struct {
|
|||
*/
|
||||
typedef struct {
|
||||
gdma_trigger_peripheral_t periph; /*!< Target peripheral which will trigger DMA operations */
|
||||
int instance_id; /*!< Peripheral instance ID. Supported IDs are listed in `soc/gdma_channel.h`, e.g. SOC_GDMA_TRIG_PERIPH_UART0 */
|
||||
int instance_id; /*!< Peripheral instance ID. Supported IDs are listed in `soc/gdma_channel.h`, e.g. SOC_GDMA_TRIG_PERIPH_UHCI0 */
|
||||
} gdma_trigger_t;
|
||||
|
||||
/**
|
||||
* @brief Helper macro to initialize GDMA trigger
|
||||
* @note value of `peri` must be selected from `gdma_trigger_peripheral_t` enum.
|
||||
* e.g. GDMA_MAKE_TRIGGER(GDMA_TRIG_PERIPH_UART,0)
|
||||
* e.g. GDMA_MAKE_TRIGGER(GDMA_TRIG_PERIPH_I2S,0)
|
||||
*
|
||||
*/
|
||||
#define GDMA_MAKE_TRIGGER(peri, id) \
|
||||
|
|
@ -325,6 +298,22 @@ esp_err_t gdma_append(gdma_channel_handle_t dma_chan);
|
|||
*/
|
||||
esp_err_t gdma_reset(gdma_channel_handle_t dma_chan);
|
||||
|
||||
/**
|
||||
* @brief Get the mask of free M2M trigger IDs
|
||||
*
|
||||
* @note On some ESP targets (e.g. ESP32C3/S3), DMA trigger used for memory copy can be any of valid peripheral's trigger ID,
|
||||
* which can bring conflict if the peripheral is also using the same trigger ID. This function can return the free IDs
|
||||
* for memory copy, at the runtime.
|
||||
*
|
||||
* @param[in] dma_chan GDMA channel handle, allocated by `gdma_new_channel`
|
||||
* @param[out] mask Returned mask of free M2M trigger IDs
|
||||
* @return
|
||||
* - ESP_OK: Get free M2M trigger IDs successfully
|
||||
* - ESP_ERR_INVALID_ARG: Get free M2M trigger IDs failed because of invalid argument
|
||||
* - ESP_FAIL: Get free M2M trigger IDs failed because of other error
|
||||
*/
|
||||
esp_err_t gdma_get_free_m2m_trig_id_mask(gdma_channel_handle_t dma_chan, uint32_t *mask);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@
|
|||
#include "soc/soc_caps.h"
|
||||
#include "driver/gpio.h"
|
||||
|
||||
#if SOC_GPIO_SUPPORT_SLP_SWITCH
|
||||
#if CONFIG_GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL
|
||||
/**
|
||||
* @brief Emulate ESP32S2 behaviour to backup FUN_PU, FUN_PD information
|
||||
|
|
@ -34,4 +33,3 @@ esp_err_t gpio_sleep_pupd_config_apply(gpio_num_t gpio_num);
|
|||
*/
|
||||
esp_err_t gpio_sleep_pupd_config_unapply(gpio_num_t gpio_num);
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -741,7 +741,7 @@ esp_err_t esp_efuse_write_key(esp_efuse_block_t block, esp_efuse_purpose_t purpo
|
|||
esp_err_t esp_efuse_write_keys(const esp_efuse_purpose_t purposes[], uint8_t keys[][32], unsigned number_of_keys);
|
||||
|
||||
|
||||
#if CONFIG_ESP32_REV_MIN_3 || !CONFIG_IDF_TARGET_ESP32
|
||||
#if CONFIG_ESP32_REV_MIN_FULL >= 300 || !CONFIG_IDF_TARGET_ESP32
|
||||
/**
|
||||
* @brief Read key digests from efuse. Any revoked/missing digests will be marked as NULL
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,135 +0,0 @@
|
|||
// 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
|
||||
#ifndef _ESP_TTS_H_
|
||||
#define _ESP_TTS_H_
|
||||
|
||||
#include "stdlib.h"
|
||||
#include "stdio.h"
|
||||
#include "esp_tts_voice.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
NONE_MODE = 0, //do not play any word before playing a specific number
|
||||
ALI_PAY_MODE, //play zhi fu bao shou kuan before playing a specific number
|
||||
WEIXIN_PAY_MODE //play wei xin shou kuan before playing a specific number
|
||||
} pay_mode_t;
|
||||
|
||||
typedef void * esp_tts_handle_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Init an instance of the TTS voice set structure.
|
||||
*
|
||||
* @param template The const esp_tts_voice_template.
|
||||
* @param data The customize voice data
|
||||
* @return
|
||||
* - NULL: Init failed
|
||||
* - Others: The instance of voice set
|
||||
*/
|
||||
esp_tts_voice_t *esp_tts_voice_set_init(const esp_tts_voice_t *template, void *data);
|
||||
|
||||
/**
|
||||
* @brief Init an instance of the TTS voice set structure.
|
||||
*
|
||||
* @param template The const esp_tts_voice_template.
|
||||
* @param data The customize voice data
|
||||
* @return
|
||||
* - NULL: Init failed
|
||||
* - Others: The instance of voice set
|
||||
*/
|
||||
void esp_tts_voice_set_free(esp_tts_voice_t *voice);
|
||||
|
||||
/**
|
||||
* @brief Creates an instance of the TTS structure.
|
||||
*
|
||||
* @param voice Voice set containing all basic phonemes.
|
||||
* @return
|
||||
* - NULL: Create failed
|
||||
* - Others: The instance of TTS structure
|
||||
*/
|
||||
esp_tts_handle_t esp_tts_create(esp_tts_voice_t *voice);
|
||||
|
||||
/**
|
||||
* @brief parse money pronuciation.
|
||||
*
|
||||
* @param tts_handle Instance of TTS
|
||||
* @param yuan The number of yuan
|
||||
* @param jiao The number of jiao
|
||||
* @param fen The number of fen
|
||||
* @param mode The pay mode: please refer to pay_mode_t
|
||||
* @return
|
||||
* - 0: failed
|
||||
* - 1: succeeded
|
||||
*/
|
||||
int esp_tts_parse_money(esp_tts_handle_t tts_handle, int yuan, int jiao, int fen, pay_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief parse Chinese PinYin pronuciation.
|
||||
*
|
||||
* @param tts_handle Instance of TTS
|
||||
* @param pinyin PinYin string, like this "da4 jia1 hao3"
|
||||
* @return
|
||||
* - 0: failed
|
||||
* - 1: succeeded
|
||||
*/
|
||||
int esp_tts_parse_pinyin(esp_tts_handle_t tts_handle, const char *pinyin);
|
||||
|
||||
/**
|
||||
* @brief parse Chinese string.
|
||||
*
|
||||
* @param tts_handle Instance of TTS
|
||||
* @param str Chinese string, like this "大家好"
|
||||
* @return
|
||||
* - 0: failed
|
||||
* - 1: succeeded
|
||||
*/
|
||||
int esp_tts_parse_chinese(esp_tts_handle_t tts_handle, const char *str);
|
||||
|
||||
/**
|
||||
* @brief output TTS voice data by stream.
|
||||
*
|
||||
* @Warning The output data should not be freed.
|
||||
Once the output length is 0, the all voice data has been output.
|
||||
*
|
||||
* @param tts_handle Instance of TTS
|
||||
* @param len The length of output data
|
||||
* @param speed The speech speed speed of synthesized speech,
|
||||
range:0~5, 0: the slowest speed, 5: the fastest speech
|
||||
* @return
|
||||
* - voice raw data
|
||||
*/
|
||||
short* esp_tts_stream_play(esp_tts_handle_t tts_handle, int *len, unsigned int speed);
|
||||
|
||||
/**
|
||||
* @brief reset tts stream and clean all cache of TTS instance.
|
||||
*
|
||||
* @param tts_handle Instance of TTS
|
||||
*/
|
||||
void esp_tts_stream_reset(esp_tts_handle_t tts_handle);
|
||||
|
||||
/**
|
||||
* @brief Free the TTS instance
|
||||
*
|
||||
* @param tts_handle The instance of TTS.
|
||||
*/
|
||||
void esp_tts_destroy(esp_tts_handle_t tts_handle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
#ifndef _ESP_TTS_PARSER_H_
|
||||
#define _ESP_TTS_PARSER_H_
|
||||
|
||||
#include "stdlib.h"
|
||||
#include "esp_tts_voice.h"
|
||||
|
||||
|
||||
typedef struct {
|
||||
int *syll_idx;
|
||||
int syll_num;
|
||||
int total_num;
|
||||
esp_tts_voice_t *voice;
|
||||
}esp_tts_utt_t;
|
||||
|
||||
esp_tts_utt_t* esp_tts_parser_chinese (const char* str, esp_tts_voice_t *voice);
|
||||
|
||||
esp_tts_utt_t* esp_tts_parser_money(char *play_tag, int yuan, int jiao, int fen, esp_tts_voice_t *voice);
|
||||
|
||||
esp_tts_utt_t* esp_tts_parser_pinyin(char* pinyin, esp_tts_voice_t *voice);
|
||||
|
||||
esp_tts_utt_t* esp_tts_utt_alloc(int syll_num, esp_tts_voice_t *voice);
|
||||
|
||||
void esp_tts_utt_free(esp_tts_utt_t *utt);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
// 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
|
||||
#ifndef _ESP_TTS_PLAYER_H_
|
||||
#define _ESP_TTS_PLAYER_H_
|
||||
|
||||
#include "stdlib.h"
|
||||
#include "stdio.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef void * esp_tts_player_handle_t;
|
||||
|
||||
/**
|
||||
* @brief Creates an instance of the TTS Player structure.
|
||||
*
|
||||
* @param mode mode of player, default:0
|
||||
* @return
|
||||
* - NULL: Create failed
|
||||
* - Others: The instance of TTS Player
|
||||
*/
|
||||
esp_tts_player_handle_t esp_tts_player_create(int mode);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Concatenate audio files.
|
||||
*
|
||||
* @Warning Just support mono audio data.
|
||||
*
|
||||
* @param player The handle of TTS player
|
||||
* @param file_list The dir of files
|
||||
* @param file_num The number of file
|
||||
* @param len The length of return audio buffer
|
||||
* @param sample_rate The sample rate of input audio file
|
||||
* @param sample_width The sample width of input audio file, sample_width=1:8-bit, sample_width=2:16-bit,...
|
||||
* @return
|
||||
* - audio data buffer
|
||||
*/
|
||||
unsigned char* esp_tts_stream_play_by_concat(esp_tts_player_handle_t player, const char **file_list, int file_num, int *len, int *sample_rate, int *sample_width);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Free the TTS Player instance
|
||||
*
|
||||
* @param player The instance of TTS Player.
|
||||
*/
|
||||
void esp_tts_player_destroy(esp_tts_player_handle_t player);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////
|
||||
// **** AUDIO-STRETCH **** //
|
||||
// Time Domain Harmonic Scaler //
|
||||
// Copyright (c) 2019 David Bryant //
|
||||
// All Rights Reserved. //
|
||||
// Distributed under the BSD Software License (see license.txt) //
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// stretch.h
|
||||
|
||||
// Time Domain Harmonic Compression and Expansion
|
||||
//
|
||||
// This library performs time domain harmonic scaling with pitch detection
|
||||
// to stretch the timing of a 16-bit PCM signal (either mono or stereo) from
|
||||
// 1/2 to 2 times its original length. This is done without altering any of
|
||||
// its tonal characteristics.
|
||||
|
||||
#ifndef STRETCH_H
|
||||
#define STRETCH_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void *StretchHandle;
|
||||
|
||||
/* extern function */
|
||||
StretchHandle stretch_init (int shortest_period, int longest_period, int num_chans, int fast_mode);
|
||||
int stretch_samples (StretchHandle handle, short *samples, int num_samples, short *output, float ratio);
|
||||
int stretch_flush (StretchHandle handle, short *output);
|
||||
void stretch_deinit (StretchHandle handle);
|
||||
|
||||
/* internel function */
|
||||
StretchHandle stretcher_init_internal(int shortest_period, int longest_period, int buff_len);
|
||||
void stretcher_deinit (StretchHandle handle);
|
||||
int stretcher_is_empty(StretchHandle handle);
|
||||
int stretcher_is_full(StretchHandle handle, int num_samples);
|
||||
int stretcher_push_data(StretchHandle handle, short *samples, int num_samples);
|
||||
int stretcher_stretch_samples(StretchHandle handle, short *output, float ratio);
|
||||
int stretcher_stretch_samples_flash(StretchHandle handle, short *output, float ratio, const short *period_data,
|
||||
int *start_idx, int end_idx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
#ifndef _ESP_TTS_VOICE_H_
|
||||
#define _ESP_TTS_VOICE_H_
|
||||
|
||||
typedef struct {
|
||||
char *voice_name; // voice set name
|
||||
char *format; // the format of voice data, currently support pcm and amrwb
|
||||
int sample_rate; // the sample rate of voice data, just for pcm format
|
||||
int bit_width; // the bit width of voice data, just for pcm format
|
||||
int syll_num; // the syllable mumber
|
||||
char **sylls; // the syllable names
|
||||
int *syll_pos; // the position of syllable in syllable audio data array
|
||||
short *pinyin_idx; // the index of pinyin
|
||||
short *phrase_dict; // the pinyin dictionary of common phrase
|
||||
short *extern_idx; // the idx of extern phrases
|
||||
short *extern_dict; // the extern phrase dictionary
|
||||
unsigned char *data; // the audio data of all syllables
|
||||
} esp_tts_voice_t;
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
#include "esp_tts.h"
|
||||
extern const esp_tts_voice_t esp_tts_voice_template;
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
#include "esp_tts.h"
|
||||
extern const esp_tts_voice_t esp_tts_voice_xiaole;
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
//Generated by mkmodel_py
|
||||
#pragma once
|
||||
#include <string.h>
|
||||
#include "dl_lib_coefgetter_if.h"
|
||||
#include "dl_lib_matrix.h"
|
||||
#include "dl_lib_matrixq.h"
|
||||
#include "dl_lib_matrixq8.h"
|
||||
|
||||
extern const model_coeff_getter_t get_coeff_customized_word_wn5;
|
||||
|
|
@ -1,411 +0,0 @@
|
|||
// 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.
|
||||
#ifndef DL_LIB_H
|
||||
#define DL_LIB_H
|
||||
|
||||
#include "dl_lib_matrix.h"
|
||||
#include "dl_lib_matrixq.h"
|
||||
#include "dl_lib_matrixq8.h"
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_heap_caps.h"
|
||||
#include "sdkconfig.h"
|
||||
#define DL_SPIRAM_SUPPORT 1
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/rom/cache.h"
|
||||
#endif
|
||||
|
||||
typedef int padding_state;
|
||||
|
||||
// /**
|
||||
// * @brief Allocate a chunk of memory which has the given capabilities.
|
||||
// * Equivalent semantics to libc malloc(), for capability-aware memory.
|
||||
// * In IDF, malloc(p) is equivalent to heap_caps_malloc(p, MALLOC_CAP_8BIT).
|
||||
// *
|
||||
// * @param size In bytes, of the amount of memory to allocate
|
||||
// * @param caps Bitwise OR of MALLOC_CAP_* flags indicating the type of memory to be returned
|
||||
// * MALLOC_CAP_SPIRAM: Memory must be in SPI RAM
|
||||
// * MALLOC_CAP_INTERNAL: Memory must be internal; specifically it should not disappear when flash/spiram cache is switched off
|
||||
// * MALLOC_CAP_DMA: Memory must be able to accessed by DMA
|
||||
// * MALLOC_CAP_DEFAULT: Memory can be returned in a non-capability-specific memory allocation
|
||||
// * @return Pointer to currently allocated heap memory
|
||||
// **/
|
||||
// void *heap_caps_malloc(size_t size, uint32_t caps);
|
||||
|
||||
/**
|
||||
* @brief Allocate aligned memory from internal memory or external memory.
|
||||
* if cnt*size > CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL, allocate memory from internal RAM
|
||||
* else, allocate memory from PSRAM
|
||||
*
|
||||
* @param cnt Number of continuing chunks of memory to allocate
|
||||
* @param size Size, in bytes, of a chunk of memory to allocate
|
||||
* @param align Aligned size, in bits
|
||||
* @return Pointer to currently allocated heap memory
|
||||
*/
|
||||
void *dl_lib_calloc(int cnt, int size, int align);
|
||||
|
||||
/**
|
||||
* @brief Always allocate aligned memory from external memory.
|
||||
*
|
||||
* @param cnt Number of continuing chunks of memory to allocate
|
||||
* @param size Size, in bytes, of a chunk of memory to allocate
|
||||
* @param align Aligned size, in bits
|
||||
* @return Pointer to currently aligned heap memory
|
||||
*/
|
||||
void *dl_lib_calloc_psram(int cnt, int size, int align);
|
||||
|
||||
/**
|
||||
* @brief Free aligned memory allocated by `dl_lib_calloc` or `dl_lib_calloc_psram`
|
||||
*
|
||||
* @param prt Pointer to free
|
||||
*/
|
||||
void dl_lib_free(void *ptr);
|
||||
|
||||
/**
|
||||
* @brief Does a fast version of the exp() operation on a floating point number.
|
||||
*
|
||||
* As described in https://codingforspeed.com/using-faster-exponential-approximation/
|
||||
* Should be good til an input of 5 or so with a steps factor of 8.
|
||||
*
|
||||
* @param in Floating point input
|
||||
* @param steps Approximation steps. More is more precise. 8 or 10 should be good enough for most purposes.
|
||||
* @return Exp()'ed output
|
||||
*/
|
||||
fptp_t fast_exp(double x, int steps);
|
||||
|
||||
/**
|
||||
* @brief Does a fast version of the exp() operation on a floating point number.
|
||||
*
|
||||
* @param in Floating point input
|
||||
* @return Exp()'ed output
|
||||
*/
|
||||
double fast_exp_pro(double x);
|
||||
|
||||
/**
|
||||
* @brief Does a softmax operation on a matrix.
|
||||
*
|
||||
* @param in Input matrix
|
||||
* @param out Output matrix. Can be the same as the input matrix; if so, output results overwrite the input.
|
||||
*/
|
||||
void dl_softmax(const dl_matrix2d_t *in, dl_matrix2d_t *out);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Does a softmax operation on a quantized matrix.
|
||||
*
|
||||
* @param in Input matrix
|
||||
* @param out Output matrix. Can be the same as the input matrix; if so, output results overwrite the input.
|
||||
*/
|
||||
void dl_softmax_q(const dl_matrix2dq_t *in, dl_matrix2dq_t *out);
|
||||
|
||||
/**
|
||||
* @brief Does a sigmoid operation on a floating point number
|
||||
*
|
||||
* @param in Floating point input
|
||||
* @return Sigmoid output
|
||||
*/
|
||||
|
||||
fptp_t dl_sigmoid_op(fptp_t in);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Does a sigmoid operation on a matrix.
|
||||
*
|
||||
* @param in Input matrix
|
||||
* @param out Output matrix. Can be the same as the input matrix; if so, output results overwrite the input.
|
||||
*/
|
||||
void dl_sigmoid(const dl_matrix2d_t *in, dl_matrix2d_t *out);
|
||||
|
||||
/**
|
||||
* @brief Does a tanh operation on a floating point number
|
||||
*
|
||||
* @param in Floating point input number
|
||||
* @return Tanh value
|
||||
*/
|
||||
fptp_t dl_tanh_op(fptp_t v);
|
||||
|
||||
/**
|
||||
* @brief Does a tanh operation on a matrix.
|
||||
*
|
||||
* @param in Input matrix
|
||||
* @param out Output matrix. Can be the same as the input matrix; if so, output results overwrite the input.
|
||||
*/
|
||||
void dl_tanh(const dl_matrix2d_t *in, dl_matrix2d_t *out);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Does a relu (Rectifier Linear Unit) operation on a floating point number
|
||||
*
|
||||
* @param in Floating point input
|
||||
* @param clip If value is higher than this, it will be clipped to this value
|
||||
* @return Relu output
|
||||
*/
|
||||
fptp_t dl_relu_op(fptp_t in, fptp_t clip);
|
||||
|
||||
/**
|
||||
* @brief Does a ReLu operation on a matrix.
|
||||
*
|
||||
* @param in Input matrix
|
||||
* @param clip If values are higher than this, they will be clipped to this value
|
||||
* @param out Output matrix. Can be the same as the input matrix; if so, output results overwrite the input.
|
||||
*/
|
||||
void dl_relu(const dl_matrix2d_t *in, fptp_t clip, dl_matrix2d_t *out);
|
||||
|
||||
/**
|
||||
* @brief Fully connected layer operation
|
||||
*
|
||||
* @param in Input vector
|
||||
* @param weight Weights of the neurons
|
||||
* @param bias Biases for the neurons. Can be NULL if a bias of 0 is required.
|
||||
* @param out Output array. Outputs are placed here. Needs to be an initialized, weight->w by in->h in size, matrix.
|
||||
*/
|
||||
void dl_fully_connect_layer(const dl_matrix2d_t *in, const dl_matrix2d_t *weight, const dl_matrix2d_t *bias, dl_matrix2d_t *out);
|
||||
|
||||
/**
|
||||
* @brief Pre-calculate the sqrtvari variable for the batch_normalize function.
|
||||
* The sqrtvari matrix depends on the variance and epsilon values, which normally are constant. Hence,
|
||||
* this matrix only needs to be calculated once. This function does that.
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void dl_batch_normalize_get_sqrtvar(const dl_matrix2d_t *variance, fptp_t epsilon, dl_matrix2d_t *out);
|
||||
|
||||
/**
|
||||
* @brief Batch-normalize a matrix
|
||||
*
|
||||
* @param m The matrix to normalize
|
||||
* @param offset Offset matrix
|
||||
* @param scale Scale matrix
|
||||
* @param mean Mean matrix
|
||||
* @param sqrtvari Matrix precalculated using dl_batch_normalize_get_sqrtvar
|
||||
* @return
|
||||
*/
|
||||
void dl_batch_normalize(dl_matrix2d_t *m, const dl_matrix2d_t *offset, const dl_matrix2d_t *scale,
|
||||
const dl_matrix2d_t *mean, const dl_matrix2d_t *sqrtvari);
|
||||
|
||||
/**
|
||||
* @brief Do a basic LSTM layer pass.
|
||||
*
|
||||
* @warning Returns state_h pointer, so do not free result.
|
||||
|
||||
* @param in Input vector
|
||||
* @param state_c Internal state of the LSTM network
|
||||
* @param state_h Internal state (previous output values) of the LSTM network
|
||||
* @param weights Weights for the neurons
|
||||
* @param bias Bias for the neurons. Can be NULL if no bias is required
|
||||
* @return Output values of the neurons
|
||||
*/
|
||||
dl_matrix2d_t *dl_basic_lstm_layer(const dl_matrix2d_t *in, dl_matrix2d_t *state_c, dl_matrix2d_t *state_h,
|
||||
const dl_matrix2d_t *weight, const dl_matrix2d_t *bias);
|
||||
|
||||
/**
|
||||
* @brief Do a basic LSTM layer pass, partial quantized version.
|
||||
* This LSTM function accepts 16-bit fixed-point weights and 32-bit float-point bias.
|
||||
*
|
||||
* @warning Returns state_h pointer, so do not free result.
|
||||
|
||||
* @param in Input vector
|
||||
* @param state_c Internal state of the LSTM network
|
||||
* @param state_h Internal state (previous output values) of the LSTM network
|
||||
* @param weights Weights for the neurons, need to be quantised
|
||||
* @param bias Bias for the neurons. Can be NULL if no bias is required
|
||||
* @return Output values of the neurons
|
||||
*/
|
||||
dl_matrix2dq_t *dl_basic_lstm_layer_quantised_weights(const dl_matrix2d_t *in, dl_matrix2d_t *state_c, dl_matrix2d_t *state_h,
|
||||
const dl_matrix2dq_t *weight, const dl_matrix2d_t *bias);
|
||||
|
||||
/**
|
||||
* @brief Do a fully-connected layer pass, fully-quantized version.
|
||||
*
|
||||
* @param in Input vector
|
||||
* @param weight Weights of the neurons
|
||||
* @param bias Bias values of the neurons. Can be NULL if no bias is needed.
|
||||
* @param shift Number of bits to shift the result back by. See dl_lib_matrixq.h for more info
|
||||
* @return Output values of the neurons
|
||||
*/
|
||||
void dl_fully_connect_layer_q(const dl_matrix2dq_t *in, const dl_matrix2dq_t *weight, const dl_matrix2dq_t *bias, dl_matrix2dq_t *out, int shift);
|
||||
|
||||
/**
|
||||
* @brief Do a basic LSTM layer pass, fully-quantized version
|
||||
*
|
||||
* @warning Returns state_h pointer, so do not free result.
|
||||
|
||||
* @param in Input vector
|
||||
* @param state_c Internal state of the LSTM network
|
||||
* @param state_h Internal state (previous output values) of the LSTM network
|
||||
* @param weights Weights for the neurons
|
||||
* @param bias Bias for the neurons. Can be NULL if no bias is required
|
||||
* @param shift Number of bits to shift the result back by. See dl_lib_matrixq.h for more info
|
||||
* @return Output values of the neurons
|
||||
*/
|
||||
dl_matrix2dq_t *dl_basic_lstm_layer_q(const dl_matrix2dq_t *in, dl_matrix2dq_t *state_c, dl_matrix2dq_t *state_h,
|
||||
const dl_matrix2dq_t *weight, const dl_matrix2dq_t *bias, int shift);
|
||||
|
||||
/**
|
||||
* @brief Batch-normalize a matrix, fully-quantized version
|
||||
*
|
||||
* @param m The matrix to normalize
|
||||
* @param offset Offset matrix
|
||||
* @param scale Scale matrix
|
||||
* @param mean Mean matrix
|
||||
* @param sqrtvari Matrix precalculated using dl_batch_normalize_get_sqrtvar
|
||||
* @param shift Number of bits to shift the result back by. See dl_lib_matrixq.h for more info
|
||||
* @return
|
||||
*/
|
||||
void dl_batch_normalize_q(dl_matrix2dq_t *m, const dl_matrix2dq_t *offset, const dl_matrix2dq_t *scale,
|
||||
const dl_matrix2dq_t *mean, const dl_matrix2dq_t *sqrtvari, int shift);
|
||||
|
||||
/**
|
||||
* @brief Does a relu (Rectifier Linear Unit) operation on a fixed-point number
|
||||
* This accepts and returns fixed-point 32-bit number with the last 15 bits being the bits after the decimal
|
||||
* point. (Equivalent to a mantissa in a quantized matrix with exponent -15.)
|
||||
*
|
||||
* @param in Fixed-point input
|
||||
* @param clip If value is higher than this, it will be clipped to this value
|
||||
* @return Relu output
|
||||
*/
|
||||
qtp_t dl_relu_q_op(qtp_t in, qtp_t clip);
|
||||
|
||||
/**
|
||||
* @brief Does a ReLu operation on a matrix, quantized version
|
||||
*
|
||||
* @param in Input matrix
|
||||
* @param clip If values are higher than this, they will be clipped to this value
|
||||
* @param out Output matrix. Can be the same as the input matrix; if so, output results overwrite the input.
|
||||
*/
|
||||
void dl_relu_q(const dl_matrix2dq_t *in, fptp_t clip, dl_matrix2dq_t *out);
|
||||
|
||||
/**
|
||||
* @brief Does a sigmoid operation on a fixed-point number.
|
||||
* This accepts and returns a fixed-point 32-bit number with the last 15 bits being the bits after the decimal
|
||||
* point. (Equivalent to a mantissa in a quantized matrix with exponent -15.)
|
||||
*
|
||||
* @param in Fixed-point input
|
||||
* @return Sigmoid output
|
||||
*/
|
||||
int dl_sigmoid_op_q(const int in);
|
||||
int16_t dl_sigmoid_op_q8(const int16_t in);
|
||||
/**
|
||||
* @brief Does a sigmoid operation on a matrix, quantized version
|
||||
*
|
||||
* @param in Input matrix
|
||||
* @param out Output matrix. Can be the same as the input matrix; if so, output results overwrite the input.
|
||||
*/
|
||||
void dl_sigmoid_q(const dl_matrix2dq_t *in, dl_matrix2dq_t *out);
|
||||
|
||||
/**
|
||||
* @brief Does a tanh operation on a matrix, quantized version
|
||||
*
|
||||
* @param in Input matrix
|
||||
* @param out Output matrix. Can be the same as the input matrix; if so, output results overwrite the input.
|
||||
*/
|
||||
void dl_tanh_q(const dl_matrix2dq_t *in, dl_matrix2dq_t *out);
|
||||
|
||||
/**
|
||||
* @brief Does a tanh operation on a fixed-point number.
|
||||
* This accepts and returns a fixed-point 32-bit number with the last 15 bits being the bits after the decimal
|
||||
* point. (Equivalent to a mantissa in a quantized matrix with exponent -15.)
|
||||
*
|
||||
* @param in Fixed-point input
|
||||
* @return tanh output
|
||||
*/
|
||||
int dl_tanh_op_q(int v);
|
||||
int16_t dl_tanh_op_q8(int16_t v);
|
||||
|
||||
void load_mat_psram_mn4(void);
|
||||
void load_mat_psram_mn3(void);
|
||||
void free_mat_psram_mn4(void);
|
||||
void free_mat_psram_mn3(void);
|
||||
qtp_t dl_hard_sigmoid_op(qtp_t in, int exponent);
|
||||
qtp_t dl_hard_tanh_op(qtp_t in, int exponent);
|
||||
|
||||
int16_t dl_table_tanh_op(int16_t in, int exponent);
|
||||
int16_t dl_table_sigmoid_op(int16_t in, int exponent);
|
||||
|
||||
void dl_hard_sigmoid_q(const dl_matrix2dq_t *in, dl_matrix2dq_t *out);
|
||||
void dl_hard_tanh_q(const dl_matrix2dq_t *in, dl_matrix2dq_t *out);
|
||||
|
||||
void dl_table_sigmoid_q(const dl_matrix2dq_t *in, dl_matrix2dq_t *out);
|
||||
void dl_table_tanh_q(const dl_matrix2dq_t *in, dl_matrix2dq_t *out);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Filter out the number greater than clip in the matrix, quantized version
|
||||
*
|
||||
* @param in Input matrix
|
||||
* @param clip If values are higher than this, they will be clipped to this value
|
||||
* @param out Output matrix. Can be the same as the input matrix; if so, output results overwrite the input.
|
||||
*/
|
||||
void dl_minimum(const dl_matrix2d_t *in, fptp_t clip, dl_matrix2d_t *out);
|
||||
|
||||
/**
|
||||
* @brief Filter out the number greater than clip in the matrix, float version
|
||||
*
|
||||
* @param in Input matrix
|
||||
* @param clip If values are higher than this, they will be clipped to this value
|
||||
* @param out Output matrix. Can be the same as the input matrix; if so, output results overwrite the input.
|
||||
*/
|
||||
void dl_minimum_q(const dl_matrix2dq_t *in, fptp_t clip, dl_matrix2dq_t *out);
|
||||
/**
|
||||
* @brief Do a basic CNN layer pass.
|
||||
*
|
||||
* @Warning This just supports the single channel input image, and the output is single row matrix.
|
||||
That is to say, the height of output is 1, and the weight of output is out_channels*out_image_width*out_image_height
|
||||
*
|
||||
* @param in Input single channel image
|
||||
* @param weight Weights of the neurons, weight->w = out_channels, weight->h = filter_width*filter_height
|
||||
* @param bias Bias for the CNN layer.
|
||||
* @param filter_height The height of convolution kernel
|
||||
* @param filter_width The width of convolution kernel
|
||||
* @param out_channels The number of output channels of convolution kernel
|
||||
* @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 pad One of `"VALID"` or `"SAME"`, 0 is "VALID" and the other is "SAME"
|
||||
* @param out The result of CNN layer, out->h=1.
|
||||
* @return The result of CNN layer.
|
||||
*/
|
||||
dl_matrix2d_t *dl_basic_conv_layer(const dl_matrix2d_t *in, const dl_matrix2d_t *weight, const dl_matrix2d_t *bias, int filter_width, int filter_height,
|
||||
const int out_channels, const int stride_x, const int stride_y, padding_state pad, const dl_matrix2d_t* out);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Do a basic CNN layer pass, quantised wersion.
|
||||
*
|
||||
* @Warning This just supports the single channel input image, and the output is single row matrix.
|
||||
That is to say, the height of output is 1, and the weight of output is out_channels*out_image_width*out_image_height
|
||||
*
|
||||
* @param in Input single channel image
|
||||
* @param weight Weights of the neurons, weight->w = out_channels, weight->h = filter_width*filter_height,
|
||||
* @param bias Bias of the neurons.
|
||||
* @param filter_height The height of convolution kernel
|
||||
* @param filter_width The width of convolution kernel
|
||||
* @param out_channels The number of output channels of convolution kernel
|
||||
* @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 pad One of `"VALID"` or `"SAME"`, 0 is "VALID" and the other is "SAME"
|
||||
* @param out The result of CNN layer, out->h=1
|
||||
* @return The result of CNN layer
|
||||
*/
|
||||
dl_matrix2d_t *dl_basic_conv_layer_quantised_weight(const dl_matrix2d_t *in, const dl_matrix2dq_t *weight, const dl_matrix2d_t *bias, int filter_width, int filter_height,
|
||||
const int out_channels, const int stride_x, const int stride_y, padding_state pad, const dl_matrix2d_t* out);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
// 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.
|
||||
#ifndef DL_LIB_COEFGETTER_IF_H
|
||||
#define DL_LIB_COEFGETTER_IF_H
|
||||
|
||||
#include "dl_lib_matrix.h"
|
||||
#include "dl_lib_matrixq.h"
|
||||
#include "dl_lib_matrixq8.h"
|
||||
#include "cJSON.h"
|
||||
|
||||
//Set this if the coefficient requested is a batch-normalization popvar matrix which needs to be preprocessed by
|
||||
//dl_batch_normalize_get_sqrtvar first.
|
||||
#define COEF_GETTER_HINT_BNVAR (1<<0)
|
||||
|
||||
/*
|
||||
This struct describes the basic information of model data:
|
||||
word_num: the number of wake words or speech commands
|
||||
word_list: the name list of wake words or speech commands
|
||||
thres_list: the threshold list of wake words or speech commands
|
||||
info_str: the string used to reflect the version and information of model data
|
||||
which consist of the architecture of network, the version of model data, wake words and their threshold
|
||||
*/
|
||||
typedef struct {
|
||||
int word_num;
|
||||
char **word_list;
|
||||
int *win_list;
|
||||
float *thresh_list;
|
||||
char *info_str;
|
||||
} model_info_t;
|
||||
|
||||
/*
|
||||
Alphabet struct describes the basic grapheme or phoneme.
|
||||
item_num: the number of baisc item(grapheme or phonemr)
|
||||
items: the list of basic item
|
||||
*/
|
||||
typedef struct {
|
||||
int item_num;
|
||||
char **items;
|
||||
}alphabet_t;
|
||||
|
||||
/*
|
||||
This struct describes a generic coefficient getter: a way to get the constant coefficients needed for a neural network.
|
||||
For the two getters, the name describes the name of the coefficient matrix, usually the same as the Numpy filename the
|
||||
coefficient was originally stored in. The arg argument can be used to optionally pass an additional user-defined argument
|
||||
to the getter (e.g. the directory to look for files in the case of the Numpy file loader getter). The hint argument
|
||||
is a bitwise OR of the COEF_GETTER_HINT_* flags or 0 when none is needed. Use the free_f/free_q functions to release the
|
||||
memory for the returned matrices, when applicable.
|
||||
*/
|
||||
typedef struct {
|
||||
const dl_matrix2d_t* (*getter_f)(const char *name, void *arg, int hint);
|
||||
const dl_matrix2dq_t* (*getter_q)(const char *name, void *arg, int hint);
|
||||
const dl_matrix2dq8_t* (*getter_q8)(const char *name, void *arg, int hint);
|
||||
void (*free_f)(const dl_matrix2d_t *m);
|
||||
void (*free_q)(const dl_matrix2dq_t *m);
|
||||
void (*free_q8)(const dl_matrix2dq8_t *m);
|
||||
const model_info_t* (*getter_info)(void *arg);
|
||||
const alphabet_t* (*getter_alphabet)(void *arg);
|
||||
const cJSON* (*getter_config)(void *arg);
|
||||
} model_coeff_getter_t;
|
||||
|
||||
#endif
|
||||
|
|
@ -1,164 +0,0 @@
|
|||
// 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.
|
||||
#ifndef DL_LIB_CONV_QUEUE_H
|
||||
#define DL_LIB_CONV_QUEUE_H
|
||||
|
||||
|
||||
#include "dl_lib_matrix.h"
|
||||
typedef float fptp_t;
|
||||
|
||||
|
||||
//Flags for matrices
|
||||
#define DL_MF_FOREIGNDATA (1<<0) /*< Matrix *item data actually points to another matrix and should not be freed */
|
||||
|
||||
//Float convolution FIFO queue.
|
||||
typedef struct {
|
||||
int n; /*< the length of queue */
|
||||
int c; /*< the channel number of queue element*/
|
||||
int front; /*< the front(top) position of queue */
|
||||
int flag; /*< not used*/
|
||||
fptp_t *item; /*< Pointer to item array */
|
||||
} dl_conv_queue_t;
|
||||
|
||||
/**
|
||||
* @brief Allocate a convolution queue
|
||||
*
|
||||
* @param n The length of queue
|
||||
* @param c The channel number of elements in the queue
|
||||
* @return The convolution queue, or NULL if out of memory
|
||||
*/
|
||||
dl_conv_queue_t *dl_conv_queue_alloc(int n, int c);
|
||||
|
||||
/**
|
||||
* @brief Free a convolution queue
|
||||
*
|
||||
* @param cq The convolution queue to free
|
||||
*/
|
||||
void dl_conv_queue_free(dl_conv_queue_t *cq);
|
||||
|
||||
void dl_conv_to_matrix2d(dl_conv_queue_t *cq, dl_matrix2d_t* out);
|
||||
|
||||
/**
|
||||
* @brief Move the front pointer of queue forward,
|
||||
the First(oldest) element become the last(newest) element,
|
||||
*
|
||||
* @param cq Input convolution queue
|
||||
* @return Pointer of oldest element
|
||||
*/
|
||||
fptp_t *dl_conv_queue_pop(dl_conv_queue_t *cq);
|
||||
|
||||
/**
|
||||
* @brief Remove the oldest element, then insert the input element at the end of queue
|
||||
*
|
||||
* @param cq Input convolution queue
|
||||
* @param item The new element
|
||||
*/
|
||||
void dl_conv_queue_push(dl_conv_queue_t *cq, fptp_t* item);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the pointer of element in the queue by offset
|
||||
*
|
||||
* @param cq Input convolution queue
|
||||
* @param offset Offset from the front of the queue
|
||||
* @return Pointer of the element
|
||||
*/
|
||||
fptp_t *dl_get_queue_item(dl_conv_queue_t *cq, int offset);
|
||||
|
||||
/**
|
||||
* @brief Does a sigmoid operation on the one of element in the convolution queue.
|
||||
* Gets the pointer of element in the convolution queue by offset, and does a sigmoid operation
|
||||
* by this pointer, then return the pointer
|
||||
*
|
||||
* @param cq Input convolution queue
|
||||
* @param offset Offset from the front of the queue
|
||||
* @return Pointer of the element
|
||||
*/
|
||||
fptp_t *dl_sigmoid_step(dl_conv_queue_t *cq, int offset);
|
||||
|
||||
/**
|
||||
* @brief Does a tanh operation on the one of element in the convolution queue.
|
||||
* Gets the pointer of element in the convolution queue by offset, and does a tanh operation
|
||||
* by this pointer, then return the pointer
|
||||
*
|
||||
* @param cq Input convolution queue
|
||||
* @param offset Offset from the front of the queue
|
||||
* @return Pointer of the element
|
||||
*/
|
||||
fptp_t *dl_tanh_step(dl_conv_queue_t *cq, int offset);
|
||||
|
||||
/**
|
||||
* @brief Does a softmax operation on the one of element in the convolution queue.
|
||||
* Gets the pointer of element in the convolution queue by offset, and does a softmax operation
|
||||
* by this pointer, then return the pointer
|
||||
*
|
||||
* @param cq Input convolution queue
|
||||
* @param offset Offset from the front of the queue
|
||||
* @return Pointer of the element
|
||||
*/
|
||||
fptp_t *dl_softmax_step(dl_conv_queue_t *cq, int offset);
|
||||
|
||||
fptp_t *dl_relu_step(dl_conv_queue_t *cq, int offset);
|
||||
fptp_t *dl_relu_look(dl_matrix2d_t *cq, int offset);
|
||||
dl_matrix2d_t *dl_matrix_concat1(const dl_conv_queue_t *a, const dl_matrix2d_t *b);
|
||||
dl_matrix2d_t *dl_basic_lstm_layer1(const dl_conv_queue_t *in, dl_matrix2d_t *state_c, dl_matrix2d_t *state_h,
|
||||
const dl_matrix2d_t *weight, const dl_matrix2d_t *bias);
|
||||
/**
|
||||
* @brief Fast implement for 1D atrous convolution (a.k.a. convolution with holes or dilated convolution)
|
||||
* based on convolution queue.
|
||||
*
|
||||
* @Warning All input and output convolution queue and matrix should be allocated. The return pointer
|
||||
* is first element of output queue and should not be freed separately.
|
||||
*
|
||||
* @param in Input convolution queue
|
||||
* @param out Output convolution queue
|
||||
* @param rate A positive int, the stride with which we sample input value
|
||||
* @param size A positive int, the size of 1D-filter
|
||||
* @param kernel The kernel matrix of filter
|
||||
* @param bias The bias matrix of filter. Can be NULL if a bias of 0 is required.
|
||||
* @return The result of atrous convolution
|
||||
*/
|
||||
fptp_t *dl_atrous_conv1d_step(dl_conv_queue_t *in, dl_conv_queue_t *out, int rate, int size,
|
||||
dl_matrix2d_t* kernel, dl_matrix2d_t* bias);
|
||||
fptp_t *dl_look_conv_step(dl_conv_queue_t *in, dl_matrix2d_t *out, int rate, int size,
|
||||
dl_matrix2d_t* kernel, dl_matrix2d_t* bias);
|
||||
|
||||
/**
|
||||
* @brief Fast implement of dilation layer as follows
|
||||
*
|
||||
* |-> [gate(sigmoid)] -|
|
||||
* input - | |-> (*) - output
|
||||
* |-> [filter(tanh)] -|
|
||||
*
|
||||
* @Warning All input and output convolution queue and matrix should be allocated. The return pointer
|
||||
* is first element of output queue and should not be freed separately.
|
||||
*
|
||||
* @param in Input convolution queue
|
||||
* @param out Output convolution queue
|
||||
* @param rate A positive int, the stride with which we sample input value
|
||||
* @param size A positive int, the size of 1D-filter
|
||||
* @param filter_kernel The kernel matrix of filter
|
||||
* @param filter_bias The bias matrix of filter. Can be NULL if a bias of 0 is required.
|
||||
* @param gate_kernel The kernel matrix of gate
|
||||
* @param gate_bias The bias matrix of gate. Can be NULL if a bias of 0 is required.
|
||||
* @return The result of dilation layer
|
||||
*/
|
||||
fptp_t *dl_dilation_layer(dl_conv_queue_t *in, dl_conv_queue_t *out, int rate, int size,
|
||||
dl_matrix2d_t* filter_kernel, dl_matrix2d_t* filter_bias,
|
||||
dl_matrix2d_t* gate_kernel, dl_matrix2d_t* gate_bias);
|
||||
|
||||
|
||||
void test_atrous_conv(int size, int rate, int in_channel, int out_channel);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,273 +0,0 @@
|
|||
// 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.
|
||||
#ifndef DL_LIB_CONVQ8_QUEUE_H
|
||||
#define DL_LIB_CONVQ8_QUEUE_H
|
||||
|
||||
|
||||
#include "dl_lib_matrixq.h"
|
||||
#include "dl_lib_matrixq8.h"
|
||||
#include "dl_lib_conv_queue.h"
|
||||
#include "dl_lib_convq_queue.h"
|
||||
|
||||
//[nch, n, c]
|
||||
typedef struct {
|
||||
int n; /*< the length of queue */
|
||||
int c; /*< the number of queue element*/
|
||||
int front; /*< the front(top) position of queue */
|
||||
int nch; /*< the channel of queue */
|
||||
int exponent; /*< The values in items should be multiplied by pow(2,exponent)
|
||||
to get the real values */
|
||||
q8tp_t *itemq; /*< Pointer to item array */
|
||||
} dl_convq8_queue_t;
|
||||
|
||||
/**
|
||||
* @brief Allocate a fixed-point convolution queue
|
||||
*
|
||||
* @param n The length of queue
|
||||
* @param c The number of elements in the queue
|
||||
* @return The convolution queue, or NULL if out of memory
|
||||
*/
|
||||
dl_convq8_queue_t *dl_convq8_queue_alloc(int n, int c);
|
||||
|
||||
/**
|
||||
* @brief Allocate a fixed-point convolution queue
|
||||
*
|
||||
* @param n The length of queue
|
||||
* @param c The number of elements in the queue
|
||||
* @param c The channel of queue
|
||||
* @return The convolution queue, or NULL if out of memory
|
||||
*/
|
||||
dl_convq8_queue_t *dl_convq8_queue_alloc_mc(int n, int c, int nch);
|
||||
|
||||
/**
|
||||
* @brief Free a fixed-point convolution queue
|
||||
*
|
||||
* @param cq The fixed-point convolution queue to free
|
||||
*/
|
||||
void dl_convq8_queue_free(dl_convq8_queue_t *cq);
|
||||
|
||||
/**
|
||||
* @brief Set itemq of convolution queue to 0
|
||||
*
|
||||
* @param cq The fixed-point convolution queue to free
|
||||
*/
|
||||
void dl_convq8_queue_bzero(dl_convq8_queue_t *cqm);
|
||||
|
||||
/**
|
||||
* @brief Insert the float-point element at the end of queue.
|
||||
* The precision of fixed-point numbers is described by the Qm.f notation,
|
||||
*
|
||||
* @param cq Input fixed-point convolution queue
|
||||
* @param item The float-point element
|
||||
* @param m_bit The number of integer bits including the sign bits
|
||||
* @param f_bit The number of fractional bits
|
||||
*/
|
||||
void dl_convq8_queue_push_by_qmf(dl_convq8_queue_t *cq, fptp_t* item, int m_bit, int f_bit);
|
||||
|
||||
/**
|
||||
* @brief Get the pointer of element in the queue by offset
|
||||
*
|
||||
* @param cq Input fixed-point convolution queue
|
||||
* @param offset Offset from the front of the queue
|
||||
* @return Pointer of the element
|
||||
*/
|
||||
q8tp_t *dl_get_queue_itemq8(dl_convq8_queue_t *cq, int offset);
|
||||
|
||||
/**
|
||||
* @brief Get the pointer of element in the queue by offset
|
||||
*
|
||||
* @param cq Input fixed-point convolution queue
|
||||
* @param offset Offset from the front of the queue
|
||||
* @param ch Channel index of queue
|
||||
* @return Pointer of the element
|
||||
*/
|
||||
q8tp_t *dl_get_queue_itemq8_mc(dl_convq8_queue_t *cq, int offset, int ch);
|
||||
|
||||
/**
|
||||
* @brief Fast and quantised implement for 1D atrous convolution (a.k.a. convolution with holes or dilated convolution)
|
||||
* based on convolution queue.
|
||||
*
|
||||
* @Warning All input and output convolution queue and matrix should be allocated. The return pointer
|
||||
* is last element of output queue and should not be freed separately.
|
||||
*
|
||||
* @param in Input fixed-point convolution queue
|
||||
* @param out Output fixed-point convolution queue
|
||||
* @param rate A positive int, the stride with which we sample input value
|
||||
* @param size A positive int, the size of 1D-filter
|
||||
* @param kernel Kernel matrix of filter
|
||||
* @param bias The bias matrix of filter. Can be NULL if a bias of 0 is required.
|
||||
* @param out_exponent Shift ratio used in dot operation between two 16-bit fixed point vector
|
||||
* @param offset Offset used to calculate the beginning of input conv queue
|
||||
* @param prenum The num to control the parameter size of preload operation
|
||||
* @return The result of atrous convolution
|
||||
*/
|
||||
void dl_atrous_conv1dq8_steps(dl_convq8_queue_t *in, dl_convq8_queue_t *out, int rate, int size,
|
||||
dl_matrix2dq8_t* kernel, dl_matrix2dq8_t* bias,
|
||||
int out_exponent, int offset, int prenum);
|
||||
|
||||
/**
|
||||
* @brief Fast implement of dilation layer as follows
|
||||
*
|
||||
* |-> [gate(sigmoid)] -|
|
||||
* input - | |-> (*) - output
|
||||
* |-> [filter(tanh)] -|
|
||||
*
|
||||
* @Warning All input and output convolution queue and matrix should be allocated. The return pointer
|
||||
* is last element of output queue and should not be freed separately.
|
||||
*
|
||||
* @param in Input fixed-point convolution queue
|
||||
* @param out Output fixed-point convolution queue
|
||||
* @param rate A positive int, the stride with which we sample input value
|
||||
* @param size A positive int, the size of 1D-filter
|
||||
* @param filter_kernel The kernel matrix of filter
|
||||
* @param filter_bias The bias matrix of filter. Can be NULL if a bias of 0 is required.
|
||||
* @param gate_kernel The kernel matrix of gate
|
||||
* @param gate_bias The bias matrix of gate. Can be NULL if a bias of 0 is required.
|
||||
* @param offset Offset used to calculate the beginning of input conv queue
|
||||
* @param prenum The num to control the parameter size of preload operation
|
||||
* @return The result of dilation layer
|
||||
*/
|
||||
void dl_dilation_layerq8_steps(dl_convq8_queue_t *in, dl_convq8_queue_t *out, int rate, int size,
|
||||
dl_matrix2dq8_t* filter_kernel, dl_matrix2dq8_t* filter_bias,
|
||||
dl_matrix2dq8_t* gate_kernel, dl_matrix2dq8_t* gate_bias,
|
||||
int offset, int prenum);
|
||||
|
||||
|
||||
|
||||
|
||||
dl_conv_queue_t *dl_convq8_queue_add(dl_convq8_queue_t *cq1, dl_convq8_queue_t *cq2);
|
||||
|
||||
int8_t dl_sigmoid_lutq8(int in);
|
||||
/**
|
||||
* @brief Allocate a 8-bit fixed-point Multi-Channel convolution queue
|
||||
*
|
||||
* @param n The length of queue
|
||||
* @param c The number of elements in the queue
|
||||
* @param nch The channel number
|
||||
* @return The convolution queue, or NULL if out of memory
|
||||
*/
|
||||
dl_convq8_queue_t **dl_convq8_queue_mc_alloc(int n, int c, int nch);
|
||||
|
||||
/**
|
||||
* @brief Free a 8-bit fixed-point Multi-Channel convolution queue
|
||||
*
|
||||
* @param cqm The fixed-point convolution queue to free
|
||||
* @param nch The channel number
|
||||
*/
|
||||
void dl_convq8_queue_mc_free(dl_convq8_queue_t **cqm, int nch);
|
||||
|
||||
/**
|
||||
* @brief Tanh activation function for 8-bit fixed-point Multi-Channel convolution queue input
|
||||
*
|
||||
* @param cqm Input 8-bit fixed-point Multi-Channel convolution queue
|
||||
* @param offset Offset used to calculate the beginning of input conv queue
|
||||
* @param nch The channel number
|
||||
*/
|
||||
void dl_tanh_convq8_mc(dl_convq8_queue_t **cqm, int offset, int nch);
|
||||
|
||||
/**
|
||||
* @brief Fast and quantised 16-bit implement for Multi-channel 1D atrous convolution (a.k.a. convolution with holes or dilated convolution)
|
||||
* Usually, this layer is used as first layer for 8-bit network.
|
||||
*
|
||||
* @Warning All input and output convolution queue and matrix should be allocated. The return pointer
|
||||
* Input is a 16-bit queue point, Output is an 8-bit queue point.
|
||||
*
|
||||
* @param in Input 16bit fixed-point convolution queue array
|
||||
* @param out Output 8bit fixed-point convolution queue array
|
||||
* @param rate A positive int, the stride with which we sample input value
|
||||
* @param size A positive int, the size of 1D-filter
|
||||
* @param kernel The kernel matrix of filter
|
||||
* @param bias The bias matrix of filter. Can be NULL if a bias of 0 is required.
|
||||
* @param out_exponent Exponent of output
|
||||
* @param offset Offset used to calculate the beginning of input conv queue
|
||||
* @param prenum The num to control the parameter size of preload operation
|
||||
*/
|
||||
void dl_atrous_conv1dq8_16in_mc_steps(dl_convq_queue_t **in, dl_convq8_queue_t **out, int nch, int rate, int size,
|
||||
dl_matrix2dq_t* kernel, dl_matrix2dq_t* bias, int out_exponent, int offset, int prenum);
|
||||
|
||||
/**
|
||||
* @brief Fast and quantised 8-bit implement for Multi-channel 1D atrous convolution (a.k.a. convolution with holes or dilated convolution)
|
||||
* based on convolution queue.
|
||||
*
|
||||
* @Warning All input and output convolution queue and matrix should be allocated. The return pointer
|
||||
* is last element of output queue and should not be freed separately.
|
||||
*
|
||||
* @param in Input 8bit fixed-point convolution queue array
|
||||
* @param out Output 8bit fixed-point convolution queue array
|
||||
* @param rate A positive int, the stride with which we sample input value
|
||||
* @param size A positive int, the size of 1D-filter
|
||||
* @param kernel The kernel matrix of filter
|
||||
* @param bias The bias matrix of filter. Can be NULL if a bias of 0 is required.
|
||||
* @param out_exponent Exponent of output
|
||||
* @param offset Offset used to calculate the beginning of input conv queue
|
||||
* @param prenum The num to control the parameter size of preload operation
|
||||
*/
|
||||
void dl_atrous_conv1dq8_mc_steps(dl_convq8_queue_t **in, dl_convq8_queue_t **out,
|
||||
int nch, int rate, int size,
|
||||
dl_matrix2dq8_t* kernel, dl_matrix2dq8_t* bias,
|
||||
int out_exponent, int offset, int prenum);
|
||||
|
||||
/**
|
||||
* @brief Fast implement of 8-bit dilation layer as follows
|
||||
*
|
||||
* |-> [gate(sigmoid)] -|
|
||||
* input - | |-> (*) - output
|
||||
* |-> [filter(tanh)] -|
|
||||
*
|
||||
* @Warning All input and output convolution queue and matrix should be allocated. The return pointer
|
||||
* is last element of output queue and should not be freed separately.
|
||||
*
|
||||
* @param in Input 8-bit fixed-point convolution queue
|
||||
* @param out Output 8-bit fixed-point convolution queue
|
||||
* @param rate A positive int, the stride with which we sample input value
|
||||
* @param size A positive int, the size of 1D-filter
|
||||
* @param filter_kernel The kernel matrix of filter
|
||||
* @param filter_bias The bias matrix of filter. Can be NULL if a bias of 0 is required.
|
||||
* @param gate_kernel The kernel matrix of gate
|
||||
* @param gate_bias The bias matrix of gate. Can be NULL if a bias of 0 is required.
|
||||
* @param offset Offset used to calculate the beginning of input conv queue
|
||||
* @param prenum The num to control the parameter size of preload operation
|
||||
*/
|
||||
void dl_dilation_layerq8_mc_steps(dl_convq8_queue_t **in, dl_convq8_queue_t **out, int nch, int rate, int size,
|
||||
dl_matrix2dq8_t* filter_kernel, dl_matrix2dq8_t* filter_bias,
|
||||
dl_matrix2dq8_t* gate_kernel, dl_matrix2dq8_t* gate_bias,
|
||||
int offset, int prenum);
|
||||
|
||||
void dl_convq8_queue_mc_bzero(dl_convq8_queue_t **cqm, int nch);
|
||||
|
||||
|
||||
|
||||
dl_convq8_queue_t *dl_convq8_queue_alloc_from_psram(int n, int c);
|
||||
|
||||
qtp_t *dl_dilation_layerq16_8(dl_convq_queue_t *in, dl_convq8_queue_t *out, int rate, int size,
|
||||
dl_matrix2dq_t* filter_kernel, dl_matrix2dq_t* filter_bias,
|
||||
dl_matrix2dq_t* gate_kernel, dl_matrix2dq_t* gate_bias, int prenum);
|
||||
|
||||
|
||||
qtp_t *dl_dilation_layerq8(dl_convq8_queue_t *in, dl_convq8_queue_t *out, int rate, int size,
|
||||
dl_matrix2dq8_t* filter_kernel, dl_matrix2dq_t* filter_bias,
|
||||
dl_matrix2dq8_t* gate_kernel, dl_matrix2dq_t* gate_bias, int prenum);
|
||||
|
||||
dl_matrix2dq8_t *dl_convq8_lstm_layer(const dl_convq8_queue_t *in, dl_convq8_queue_t *out, dl_matrix2dq8_t *state_c,
|
||||
dl_matrix2dq8_t *state_h, const dl_matrix2dq8_t *in_weight, const dl_matrix2dq8_t *h_weight,
|
||||
const dl_matrix2dq_t *bias, int prenum);
|
||||
|
||||
qtp_t *dl_atrous_conv1dq8_16_s3(dl_convq8_queue_t *in, dl_convq_queue_t *out, int rate, int size,
|
||||
dl_matrix2dq8_t* kernel, dl_matrix2dq_t* bias, int prenum);
|
||||
|
||||
void print_convq8(dl_convq8_queue_t *cq, int offset);
|
||||
void print_convq(dl_convq_queue_t *cq, int offset);
|
||||
|
||||
void lstmq8_free(void);
|
||||
#endif
|
||||
|
|
@ -1,375 +0,0 @@
|
|||
// 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.
|
||||
#ifndef DL_LIB_CONVQ_QUEUE_H
|
||||
#define DL_LIB_CONVQ_QUEUE_H
|
||||
|
||||
#include "dl_lib_matrixq.h"
|
||||
#include "dl_lib_conv_queue.h"
|
||||
#include "dl_lib.h"
|
||||
|
||||
|
||||
//fixed-point convolution FIFO queue.
|
||||
//[nch, n, c]
|
||||
typedef struct {
|
||||
int n; /*< the length of queue */
|
||||
int c; /*< the number of queue element*/
|
||||
int front; /*< the front(top) position of queue */
|
||||
int nch; /*< the multiple of queue*/
|
||||
int exponent; /*< The values in items should be multiplied by pow(2,exponent)
|
||||
to get the real values */
|
||||
qtp_t *itemq; /*< Pointer to item array */
|
||||
} dl_convq_queue_t;
|
||||
|
||||
/**
|
||||
* @brief Allocate a fixed-point convolution queue
|
||||
*
|
||||
* @param n The length of queue
|
||||
* @param c The number of elements in the queue
|
||||
* @return The convolution queue, or NULL if out of memory
|
||||
*/
|
||||
dl_convq_queue_t *dl_convq_queue_alloc(int n, int c);
|
||||
|
||||
/**
|
||||
* @brief Allocate a fixed-point convolution queue from PSRAM
|
||||
*
|
||||
* @param n The length of queue
|
||||
* @param c The number of elements in the queue
|
||||
* @return The convolution queue, or NULL if out of memory
|
||||
*/
|
||||
dl_convq_queue_t *dl_convq_queue_alloc_from_psram(int n, int c);
|
||||
|
||||
/**
|
||||
* @brief Allocate a fixed-point multi-channel convolution queue
|
||||
*
|
||||
* @param n The length of queue
|
||||
* @param c The number of elements in the queue
|
||||
* @param nch The channel of conv queue
|
||||
* @return The convolution queue, or NULL if out of memory
|
||||
*/
|
||||
dl_convq_queue_t *dl_convq_queue_alloc_mc(int n, int c, int nch);
|
||||
|
||||
/**
|
||||
* @brief Allocate a fixed-point multi-channel convolution queue from PSRAM
|
||||
*
|
||||
* @param n The length of queue
|
||||
* @param c The number of elements in the queue
|
||||
* @param nch The channel of conv queue
|
||||
* @return The convolution queue, or NULL if out of memory
|
||||
*/
|
||||
dl_convq_queue_t *dl_convq_queue_alloc_mc_from_psram(int n, int c, int nch);
|
||||
|
||||
|
||||
void dl_convq_to_matrix2dq(dl_convq_queue_t *cq, dl_matrix2dq_t* out, int row);
|
||||
|
||||
/**
|
||||
* @brief Free a fixed-point convolution queue
|
||||
*
|
||||
* @param cq The fixed-point convolution queue to free
|
||||
*/
|
||||
void dl_convq_queue_free(dl_convq_queue_t *cq);
|
||||
|
||||
/**
|
||||
* @brief Set itemq of convolution queue to 0
|
||||
*
|
||||
* @param cq The fixed-point convolution queue point
|
||||
*/
|
||||
void dl_convq_queue_bzero(dl_convq_queue_t *cq);
|
||||
|
||||
/**
|
||||
* @brief Move the front pointer of queue forward,
|
||||
the First(oldest) element become the last(newest) element,
|
||||
*
|
||||
* @param cq Input fixed-point convolution queue
|
||||
* @return Pointer of oldest element
|
||||
*/
|
||||
inline qtp_t *dl_convq_queue_pop(dl_convq_queue_t *cq);
|
||||
inline qtp_t *dl_convq_queue_popn(dl_convq_queue_t *cq, int n);
|
||||
/**
|
||||
* @brief Remove the oldest element, then insert the input element at the end of queue
|
||||
*
|
||||
* @param cq Input fixed-point convolution queue
|
||||
* @param item The new element
|
||||
*/
|
||||
void dl_convq_queue_push(dl_convq_queue_t *cq, dl_matrix2dq_t *a, int shift);
|
||||
|
||||
/**
|
||||
* @brief Insert the float-point element at the end of queue.
|
||||
* The precision of fixed-point numbers is described by the Qm.f notation,
|
||||
*
|
||||
* @param cq Input fixed-point convolution queue
|
||||
* @param item The float-point element
|
||||
* @param m_bit The number of integer bits including the sign bits
|
||||
* @param f_bit The number of fractional bits
|
||||
*/
|
||||
void dl_convq_queue_push_by_qmf(dl_convq_queue_t *cq, fptp_t* item, int m_bit, int f_bit);
|
||||
|
||||
void dl_convq16_queue_push_by_qmf(dl_convq_queue_t *cq, fptp_t* item, int m_bit, int f_bit);
|
||||
|
||||
dl_conv_queue_t *dl_queue_from_convq(dl_convq_queue_t *cq1);
|
||||
|
||||
/**
|
||||
* @brief Get the pointer of element in the queue by offset
|
||||
*
|
||||
* @param cq Input fixed-point convolution queue
|
||||
* @param last_num Offset from the front of the queue
|
||||
* @return Pointer of the element
|
||||
*/
|
||||
inline qtp_t *dl_get_queue_itemq(dl_convq_queue_t *cq, int last_num);
|
||||
|
||||
/**
|
||||
* @brief Get the pointer of element in the queue by offset
|
||||
*
|
||||
* @param cq Input fixed-point convolution queue
|
||||
* @param offset Offset from the front of the queue
|
||||
* @param ch Channel index of convolution queue
|
||||
* @return Pointer of the element
|
||||
*/
|
||||
qtp_t *dl_get_queue_itemq_mc(dl_convq_queue_t *cq, int offset, int ch);
|
||||
|
||||
/**
|
||||
* @brief Does a tanh operation on the one of element in the convolution queue.
|
||||
* Gets the pointer of element in the convolution queue by offset, and does a
|
||||
* tanh operation by this pointer, then return the pointer
|
||||
*
|
||||
* @param cq Input fixed-point convolution queue
|
||||
* @param offset Offset from the front of the queue
|
||||
* @return Pointer of the element
|
||||
*/
|
||||
void dl_tanh_convq(dl_convq_queue_t *cq, int offset);
|
||||
|
||||
/**
|
||||
* @brief Does a tanh operation on the one of element in multi channel convolution queue.
|
||||
* Gets the pointer of element in the convolution queue by offset, and does a
|
||||
* tanh operation by this pointer, then return the pointer
|
||||
*
|
||||
* @param cq Input fixed-point multi channnel convolution queue
|
||||
* @param offset Offset from the front of the queue
|
||||
* @param nch The channel number of cqm
|
||||
* @return Pointer of the element
|
||||
*/
|
||||
void dl_tanh_convq_mc(dl_convq_queue_t **cqm, int offset, int nch);
|
||||
|
||||
/**
|
||||
* @brief Does a relu operation on the one of element in the convolution queue.
|
||||
* Gets the pointer of element in the convolution queue by offset, and does a
|
||||
* relu operation by this pointer, then return the pointer
|
||||
*
|
||||
* @param cq Input fixed-point convolution queue
|
||||
* @param offset Offset from the front of the queue
|
||||
* @return Pointer of the element
|
||||
*/
|
||||
void dl_relu_convq(dl_convq_queue_t *cq, fptp_t clip, int last_num);
|
||||
|
||||
/**
|
||||
* @brief Does a softmax operation on the one of element in the convolution queue.
|
||||
* Gets the pointer of element in the convolution queue by offset, input data
|
||||
stay as it is. Results are saved into the *out* array.
|
||||
*
|
||||
* @param cq Input fixed-point convolution queue
|
||||
* @param offset Offset from the front of the queue
|
||||
* @param out Old array to re-use. Passing NULL will allocate a new matrix.
|
||||
* @return softmax results
|
||||
*/
|
||||
fptp_t * dl_softmax_step_q(dl_convq_queue_t *cq, int offset, fptp_t *out);
|
||||
|
||||
/**
|
||||
* @brief Fast and quantised implement for 1D atrous convolution (a.k.a. convolution with holes or dilated convolution)
|
||||
* based on convolution queue.
|
||||
*
|
||||
* @Warning All input and output convolution queue and matrix should be allocated. The return pointer
|
||||
* is last element of output queue and should not be freed separately.
|
||||
*
|
||||
* @param in Input fixed-point convolution queue
|
||||
* @param out Output fixed-point convolution queue
|
||||
* @param rate A positive int, the stride with which we sample input value
|
||||
* @param size A positive int, the size of 1D-filter
|
||||
* @param kernel The kernel matrix of filter
|
||||
* @param bias The bias matrix of filter. Can be NULL if a bias of 0 is required.
|
||||
* @param shift Shift ratio used in dot operation between two 16-bit fixed point vector
|
||||
* @return The result of atrous convolution
|
||||
*/
|
||||
qtp_t * dl_atrous_conv1dq(dl_convq_queue_t *in, dl_convq_queue_t *out, int rate, int size,
|
||||
dl_matrix2dq_t* kernel, dl_matrix2dq_t* bias, int shift, int prenum);
|
||||
|
||||
/**
|
||||
* @brief Fast implement of dilation layer as follows
|
||||
*
|
||||
* |-> [gate(sigmoid)] -|
|
||||
* input - | |-> (*) - output
|
||||
* |-> [filter(tanh)] -|
|
||||
*
|
||||
* @Warning All input and output convolution queue and matrix should be allocated. The return pointer
|
||||
* is last element of output queue and should not be freed separately.
|
||||
*
|
||||
* @param in Input fixed-point convolution queue
|
||||
* @param out Output fixed-point convolution queue
|
||||
* @param rate A positive int, the stride with which we sample input value
|
||||
* @param size A positive int, the size of 1D-filter
|
||||
* @param filter_kernel The kernel matrix of filter
|
||||
* @param filter_bias The bias matrix of filter. Can be NULL if a bias of 0 is required.
|
||||
* @param gate_kernel The kernel matrix of gate
|
||||
* @param gate_bias The bias matrix of gate. Can be NULL if a bias of 0 is required.
|
||||
* @param filter_shift Shift ratio used in filter operation between two 16-bit fixed point vector
|
||||
* @param gate_shift Shift ratio used in gate operation between two 16-bit fixed point vector
|
||||
* @return The result of dilation layer
|
||||
*/
|
||||
qtp_t *dl_dilation_layerq_steps(dl_convq_queue_t *in, dl_convq_queue_t *out, int rate, int size,
|
||||
dl_matrix2dq_t* filter_kernel, dl_matrix2dq_t* filter_bias,
|
||||
dl_matrix2dq_t* gate_kernel, dl_matrix2dq_t* gate_bias,
|
||||
int filter_shift, int gate_shift, int offset, int prenum);
|
||||
|
||||
|
||||
qtp_t *dl_dilation_layerq(dl_convq_queue_t *in, dl_convq_queue_t *out, int rate, int size,
|
||||
dl_matrix2dq_t* filter_kernel, dl_matrix2dq_t* filter_bias,
|
||||
dl_matrix2dq_t* gate_kernel, dl_matrix2dq_t* gate_bias,
|
||||
int filter_shift, int gate_shift, int prenum);
|
||||
|
||||
qtp_t *dl_dilation_layerq16(dl_convq_queue_t *in, dl_convq_queue_t *out, int rate, int size,
|
||||
dl_matrix2dq_t* filter_kernel, dl_matrix2dq_t* filter_bias,
|
||||
dl_matrix2dq_t* gate_kernel, dl_matrix2dq_t* gate_bias, int prenum);
|
||||
|
||||
|
||||
qtp_t *dl_atrous_conv1dq_steps(dl_convq_queue_t *in, dl_convq_queue_t *out, int rate, int size,
|
||||
dl_matrix2dq_t* kernel, dl_matrix2dq_t* bias, int shift, int offset, int prenum);
|
||||
|
||||
/**
|
||||
* @brief Add a pair of fixed-point convolution queue item-by-item, and return float-point convolution queue
|
||||
*
|
||||
* @param cq1 First fixed-point convolution queue
|
||||
* @param cq2 Seconf fixed-point convolution queue
|
||||
* @return The result of float-point convolution queue
|
||||
*/
|
||||
dl_conv_queue_t *dl_convq_queue_add(dl_convq_queue_t *cq1, dl_convq_queue_t *cq2);
|
||||
|
||||
/**
|
||||
* @brief Fast implement of LSTM layer by dl_atrous_conv1dq function
|
||||
*
|
||||
* @Warning LSTM kernel is split into two part, the first part input is the last layer output,
|
||||
* and kernel is parameter *in_weight*. The second part input is the last frame LSTM output,
|
||||
* the kernel is parameters *h_weight*.
|
||||
*
|
||||
* @param in Input fixed-point convolution queue
|
||||
* @param out Output fixed-point convolution queue
|
||||
* @param state_c Internal state of the LSTM network
|
||||
* @param state_h Internal state (previous output values) of the LSTM network
|
||||
* @param in_weight the LSTM kernel needed by first part
|
||||
* @param h_weight the LSTM kernel needed by second part
|
||||
* @param bias The bias matrix of LSTM. Can be NULL if a bias of 0 is required.
|
||||
* @in_shift Shift ratio used in first part
|
||||
* @h_shift Shift ratio used in second part
|
||||
* @return The result of LSTM layer
|
||||
*/
|
||||
dl_matrix2dq_t *dl_convq_lstm_layer(const dl_convq_queue_t *in, dl_convq_queue_t *out, dl_matrix2dq_t *state_c,
|
||||
dl_matrix2dq_t *state_h, const dl_matrix2dq_t *in_weight, const dl_matrix2dq_t *h_weight,
|
||||
const dl_matrix2dq_t *bias, int in_shift, int h_shift, int prenum);
|
||||
dl_matrix2dq_t *dl_basic_lstm_layer1_q(const dl_convq_queue_t *in, dl_matrix2dq_t *state_c, dl_matrix2dq_t *state_h,
|
||||
const dl_matrix2dq_t *weight, const dl_matrix2dq_t *bias, int step, int shift);
|
||||
|
||||
dl_matrix2dq_t *dl_convq16_lstm_layer(const dl_convq_queue_t *in, dl_convq_queue_t *out, dl_matrix2dq_t *state_c,
|
||||
dl_matrix2dq_t *state_h, const dl_matrix2dq_t *in_weight, const dl_matrix2dq_t *h_weight,
|
||||
const dl_matrix2dq_t *bias, int prenum);
|
||||
|
||||
/**
|
||||
* @brief Allocate a fixed-point multi channel convolution queue
|
||||
*
|
||||
* @param n The length of queue
|
||||
* @param c The channel number of elements in the queue
|
||||
* @param nch the channel numbet of convolution queue
|
||||
* @return The convolution queue, or NULL if out of memory
|
||||
*/
|
||||
dl_convq_queue_t **dl_convq_queue_mc_alloc(int n, int c, int nch);
|
||||
|
||||
/**
|
||||
* @brief Free a fixed-point multi channel convolution queue
|
||||
*
|
||||
* @param cqm The fixed-point convolution queue to free
|
||||
* @param nch The channel number of cqm
|
||||
*/
|
||||
void dl_convq_queue_mc_free(dl_convq_queue_t **cqm, int nch);
|
||||
|
||||
/**
|
||||
* @brief Fast and quantised implement for 1D atrous convolution (a.k.a. convolution with holes or dilated convolution)
|
||||
* based on convolution queue.
|
||||
*
|
||||
* @Warning All input and output convolution queue and matrix should be allocated. The return pointer
|
||||
* is last element of output queue and should not be freed separately.
|
||||
*
|
||||
* @param in Input fixed-point convolution queue
|
||||
* @param out Output fixed-point convolution queue
|
||||
* @param nch The channel number of input
|
||||
* @param rate A positive int, the stride with which we sample input value
|
||||
* @param size A positive int, the size of 1D-filter
|
||||
* @param kernel The kernel matrix of filter
|
||||
* @param bias The bias matrix of filter. Can be NULL if a bias of 0 is required.
|
||||
* @param shift Shift ratio used in dot operation between two 16-bit fixed point vector
|
||||
* @param offset the offset to calculate input convq
|
||||
* @param prenum the preload size, 0: do not use preload function
|
||||
* @return The result of atrous convolution
|
||||
*/
|
||||
qtp_t *dl_atrous_conv1dq_mc_steps( dl_convq_queue_t **in,
|
||||
dl_convq_queue_t **out,
|
||||
int nch,
|
||||
int rate,
|
||||
int size,
|
||||
dl_matrix2dq_t* kernel,
|
||||
dl_matrix2dq_t* bias,
|
||||
int shift,
|
||||
int offset,
|
||||
int prenum);
|
||||
|
||||
/**
|
||||
* @brief Fast implement of dilation layer as follows for multi channel input
|
||||
*
|
||||
* |-> [gate(sigmoid)] -|
|
||||
* input - | |-> (*) - output
|
||||
* |-> [filter(tanh)] -|
|
||||
*
|
||||
* @Warning All input and output convolution queue and matrix should be allocated. The return pointer
|
||||
* is last element of output queue and should not be freed separately.
|
||||
*
|
||||
* @param in Input fixed-point convolution queue
|
||||
* @param out Output fixed-point convolution queue
|
||||
* @param nch The channel number of input
|
||||
* @param rate A positive int, the stride with which we sample input value
|
||||
* @param size A positive int, the size of 1D-filter
|
||||
* @param filter_kernel The kernel matrix of filter
|
||||
* @param filter_bias The bias matrix of filter. Can be NULL if a bias of 0 is required.
|
||||
* @param gate_kernel The kernel matrix of gate
|
||||
* @param gate_bias The bias matrix of gate. Can be NULL if a bias of 0 is required.
|
||||
* @param filter_shift Shift ratio used in filter operation between two 16-bit fixed point vector
|
||||
* @param gate_shift Shift ratio used in gate operation between two 16-bit fixed point vector
|
||||
* @param offset The offset to calculate input convq
|
||||
* @param prenum The preload size, 0: do not use preload function
|
||||
* @return The result of dilation layer
|
||||
*/
|
||||
qtp_t *dl_dilation_layerq_mc_steps( dl_convq_queue_t **in,
|
||||
dl_convq_queue_t **out,
|
||||
int nch,
|
||||
int rate,
|
||||
int size,
|
||||
dl_matrix2dq_t* filter_kernel,
|
||||
dl_matrix2dq_t* filter_bias,
|
||||
dl_matrix2dq_t* gate_kernel,
|
||||
dl_matrix2dq_t* gate_bias,
|
||||
int filter_shift,
|
||||
int gate_shift,
|
||||
int offset,
|
||||
int prenum);
|
||||
|
||||
void test_atrous_convq(int size, int rate, int in_channel, int out_channel);
|
||||
void test_lstm_convq(int size, int in_dim, int lstm_cell);
|
||||
void dl_nn_tanh_i162(dl_convq_queue_t **cqm, int offset, int nch);
|
||||
void dl_copy_queue_item_by_qmf(dl_convq_queue_t *cq, fptp_t* item, int m_bit, int f_bit, int offset, int ch);
|
||||
void dl_convq_queue_mc_bzero(dl_convq_queue_t **cqm, int nch);
|
||||
#endif
|
||||
|
|
@ -1,252 +0,0 @@
|
|||
// 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.
|
||||
#ifndef DL_LIB_MATRIX_H
|
||||
#define DL_LIB_MATRIX_H
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "esp_system.h"
|
||||
#endif
|
||||
|
||||
// #ifdef CONFIG_IDF_TARGET_ESP32S3
|
||||
// #include "dl_tie728_bzero.h"
|
||||
// #endif
|
||||
|
||||
typedef float fptp_t;
|
||||
|
||||
#if CONFIG_BT_SHARE_MEM_REUSE
|
||||
extern multi_heap_handle_t gst_heap;
|
||||
#endif
|
||||
|
||||
//Flags for matrices
|
||||
#define DL_MF_FOREIGNDATA (1<<0) /*< Matrix *item data actually points to another matrix and should not be freed */
|
||||
|
||||
//'Normal' float matrix
|
||||
typedef struct {
|
||||
int w; /*< Width */
|
||||
int h; /*< Height */
|
||||
int stride; /*< Row stride, essentially how many items to skip to get to the same position in the next row */
|
||||
int flags; /*< Flags. OR of DL_MF_* values */
|
||||
fptp_t *item; /*< Pointer to item array */
|
||||
} dl_matrix2d_t;
|
||||
|
||||
//Macro to quickly access the raw items in a matrix
|
||||
#define DL_ITM(m, x, y) m->item[(x)+(y)*m->stride]
|
||||
|
||||
|
||||
/**
|
||||
* @brief Allocate a matrix
|
||||
*
|
||||
* @param w Width of the matrix
|
||||
* @param h Height of the matrix
|
||||
* @return The matrix, or NULL if out of memory
|
||||
*/
|
||||
dl_matrix2d_t *dl_matrix_alloc(int w, int h);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Free a matrix
|
||||
* Frees the matrix structure and (if it doesn't have the DL_MF_FOREIGNDATA flag set) the m->items space as well.
|
||||
*
|
||||
* @param m Matrix to free
|
||||
*/
|
||||
void dl_matrix_free(dl_matrix2d_t *m);
|
||||
|
||||
/**
|
||||
* @brief Zero out the matrix
|
||||
* Sets all entries in the matrix to 0.
|
||||
*
|
||||
* @param m Matrix to zero
|
||||
*/
|
||||
void dl_matrix_zero(dl_matrix2d_t *m);
|
||||
|
||||
/**
|
||||
* @brief Copy the matrix into psram
|
||||
* Copy the matrix from flash or iram/psram into psram
|
||||
*
|
||||
* @param m Matrix to zero
|
||||
*/
|
||||
dl_matrix2d_t *dl_matrix_copy_to_psram(const dl_matrix2d_t *m);
|
||||
|
||||
/**
|
||||
* @brief Generate a new matrix using a range of items from an existing matrix.
|
||||
* When using this, the data of the new matrix is not allocated/copied but it re-uses a pointer
|
||||
* to the existing data. Changing the data in the resulting matrix, as a result, will also change
|
||||
* the data in the existing matrix that has been sliced.
|
||||
*
|
||||
* @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
|
||||
* @param in Old matrix (with foreign data) to re-use. Passing NULL will allocate a new matrix.
|
||||
* @return The resulting slice matrix, or NULL if out of memory
|
||||
*/
|
||||
dl_matrix2d_t *dl_matrix_slice(const dl_matrix2d_t *src, int x, int y, int w, int h, dl_matrix2d_t *in);
|
||||
|
||||
/**
|
||||
* @brief select a range of items from an existing matrix and flatten them into one dimension.
|
||||
*
|
||||
* @Warning The results are flattened in row-major order.
|
||||
*
|
||||
* @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
|
||||
* @param in Old matrix to re-use. Passing NULL will allocate a new matrix.
|
||||
* @return The resulting flatten matrix, or NULL if out of memory
|
||||
*/
|
||||
dl_matrix2d_t *dl_matrix_flatten(const dl_matrix2d_t *src, int x, int y, int w, int h, dl_matrix2d_t *in);
|
||||
|
||||
/**
|
||||
* @brief Generate a matrix from existing floating-point data
|
||||
*
|
||||
* @param w Width of resulting matrix
|
||||
* @param h Height of resulting matrix
|
||||
* @param data Data to populate matrix with
|
||||
* @return A newaly allocated matrix populated with the given input data, or NULL if out of memory.
|
||||
*/
|
||||
dl_matrix2d_t *dl_matrix_from_data(int w, int h, int stride, const void *data);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Multiply a pair of matrices item-by-item: res=a*b
|
||||
*
|
||||
* @param a First multiplicand
|
||||
* @param b Second multiplicand
|
||||
* @param res Multiplicated data. Can be equal to a or b to overwrite that.
|
||||
*/
|
||||
void dl_matrix_mul(const dl_matrix2d_t *a, const dl_matrix2d_t *b, dl_matrix2d_t *res);
|
||||
|
||||
/**
|
||||
* @brief Do a dotproduct of two matrices : res=a.b
|
||||
*
|
||||
* @param a First multiplicand
|
||||
* @param b Second multiplicand
|
||||
* @param res Dotproduct data. *Must* be a *different* matrix from a or b!
|
||||
*/
|
||||
void dl_matrix_dot(const dl_matrix2d_t *a, const dl_matrix2d_t *b, dl_matrix2d_t *res);
|
||||
|
||||
/**
|
||||
* @brief Add a pair of matrices item-by-item: res=a-b
|
||||
*
|
||||
* @param a First matrix
|
||||
* @param b Second matrix
|
||||
* @param res Added data. Can be equal to a or b to overwrite that.
|
||||
*/
|
||||
void dl_matrix_add(const dl_matrix2d_t *a, const dl_matrix2d_t *b, dl_matrix2d_t *out);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Divide a pair of matrices item-by-item: res=a/b
|
||||
*
|
||||
* @param a First matrix
|
||||
* @param b Second matrix
|
||||
* @param res Divided data. Can be equal to a or b to overwrite that.
|
||||
*/
|
||||
void dl_matrix_div(const dl_matrix2d_t *a, const dl_matrix2d_t *b, dl_matrix2d_t *out);
|
||||
|
||||
/**
|
||||
* @brief Subtract a matrix from another, item-by-item: res=a-b
|
||||
*
|
||||
* @param a First matrix
|
||||
* @param b Second matrix
|
||||
* @param res Subtracted data. Can be equal to a or b to overwrite that.
|
||||
*/
|
||||
void dl_matrix_sub(const dl_matrix2d_t *a, const dl_matrix2d_t *b, dl_matrix2d_t *out);
|
||||
|
||||
/**
|
||||
* @brief Add a constant to every item of the matrix
|
||||
*
|
||||
* @param subj Matrix to add the constant to
|
||||
* @param add The constant
|
||||
*/
|
||||
void dl_matrix_add_const(dl_matrix2d_t *subj, const fptp_t add);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Concatenate the rows of two matrices into a new matrix
|
||||
*
|
||||
* @param a First matrix
|
||||
* @param b Second matrix
|
||||
* @return A newly allocated array with as avlues a|b
|
||||
*/
|
||||
dl_matrix2d_t *dl_matrix_concat(const dl_matrix2d_t *a, const dl_matrix2d_t *b);
|
||||
|
||||
dl_matrix2d_t *dl_matrix_concat_h( dl_matrix2d_t *a, const dl_matrix2d_t *b);
|
||||
|
||||
/**
|
||||
* @brief Print the contents of a matrix to stdout. Used for debugging.
|
||||
*
|
||||
* @param a The matrix to print.
|
||||
*/
|
||||
void dl_printmatrix(const dl_matrix2d_t *a);
|
||||
|
||||
/**
|
||||
* @brief Return the average square error given a correct and a test matrix.
|
||||
*
|
||||
* ...Well, more or less. If anything, it gives an indication of the error between
|
||||
* the two. Check the code for the exact implementation.
|
||||
*
|
||||
* @param a First of the two matrices to compare
|
||||
* @param b Second of the two matrices to compare
|
||||
* @return value indicating the relative difference between matrices
|
||||
*/
|
||||
float dl_matrix_get_avg_sq_err(const dl_matrix2d_t *a, const dl_matrix2d_t *b);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Check if two matrices have the same shape, that is, the same amount of rows and columns
|
||||
*
|
||||
* @param a First of the two matrices to compare
|
||||
* @param b Second of the two matrices to compare
|
||||
* @return true if the two matrices are shaped the same, false otherwise.
|
||||
*/
|
||||
int dl_matrix_same_shape(const dl_matrix2d_t *a, const dl_matrix2d_t *b);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get a specific item from the matrix
|
||||
*
|
||||
* Please use these for external matrix access instead of DL_ITM
|
||||
*
|
||||
* @param m Matrix to access
|
||||
* @param x Column address
|
||||
* @param y Row address
|
||||
* @return Value in that position
|
||||
*/
|
||||
inline static fptp_t dl_matrix_get(const dl_matrix2d_t *m, const int x, const int y) {
|
||||
return DL_ITM(m, x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set a specific item in the matrix to the given value
|
||||
*
|
||||
* Please use these for external matrix access instead of DL_ITM
|
||||
*
|
||||
* @param m Matrix to access
|
||||
* @param x Column address
|
||||
* @param y Row address
|
||||
* @param val Value to write to that position
|
||||
*/
|
||||
inline static void dl_matrix_set(dl_matrix2d_t *m, const int x, const int y, fptp_t val) {
|
||||
DL_ITM(m, x, y)=val;
|
||||
}
|
||||
|
||||
void matrix_get_range(const dl_matrix2d_t *m, fptp_t *rmin, fptp_t *rmax);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,378 +0,0 @@
|
|||
// 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.
|
||||
#ifndef DL_LIB_MATRIXQ_H
|
||||
#define DL_LIB_MATRIXQ_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "dl_lib_matrix.h"
|
||||
|
||||
typedef int16_t qtp_t;
|
||||
|
||||
//Quantized matrix. Uses fixed numbers and has the storage for the rows/columns inverted
|
||||
//for easy use as a multiplicand without stressing out the flash cache too much.
|
||||
typedef struct {
|
||||
int w;
|
||||
int h;
|
||||
int stride; //Normally equals h, not w!
|
||||
int flags;
|
||||
int exponent; //The values in items should be multiplied by pow(2,exponent) to get the real values.
|
||||
qtp_t *itemq;
|
||||
} dl_matrix2dq_t;
|
||||
|
||||
#define DL_QTP_SHIFT 15
|
||||
#define DL_QTP_RANGE ((1<<DL_QTP_SHIFT)-1)
|
||||
#define DL_ITMQ(m, x, y) m->itemq[(y)+(x)*m->stride]
|
||||
#define DL_QTP_EXP_NA 255 //non-applicable exponent because matrix is null
|
||||
|
||||
#define DL_SHIFT_AUTO 32
|
||||
|
||||
/**
|
||||
* @info About quantized matrices and shift values
|
||||
*
|
||||
* Grab a coffee (or tea, or hot water) and sit down when you read this for the first
|
||||
* time. Quantized matrices can speed up your operations, but come with some quirks, and
|
||||
* it's good to understand how they work before using them.
|
||||
*
|
||||
* The data in the quantized matrix type is stored similarily to floating-point types:
|
||||
* when storing a real value, the value is stored as a mantissa (base number) and an
|
||||
* exponent. The 'real' value that can be re-derived from those two numbers is something
|
||||
* similar to mantissa*2^exponent. Up to this point, there's not that much difference from
|
||||
* the standard floating point implementations like e.g. IEEE-754.
|
||||
*
|
||||
* The difference with respect to quantized matrices is that for a quantized matrix, it is
|
||||
* assumed all values stored have more-or-less the same order of magnitude. This allows the
|
||||
* matrix to only store all the mantissas, while the exponents are shared; there is only one
|
||||
* exponent for the entire matrix. This makes it quicker to handle matrix operations - the
|
||||
* logic to fix the exponents only needs to happen once, while the rest can be done in simple
|
||||
* integer arithmetic. It also nets us some memory savings - while normally a floating point
|
||||
* number is 32-bit, storing only 16-bit mantissas as the matrix items almost halves the
|
||||
* memory requirements.
|
||||
*
|
||||
* While most of the details of handling the intricacies of the quantized matrixes are done
|
||||
* transparently by the code in dl_lib_matrixq.c, some implementation details leak out,
|
||||
* specifically in places where addition/subtraction/division happens.
|
||||
*
|
||||
* The problem is that the routines do not know what the size of the resulting operation is. For
|
||||
* instance, when adding two matrices of numbers, the resulting numbers *could* be large enough
|
||||
* to overflow the mantissa of the result if the exponent is the same. However, if by default we
|
||||
* assume the mantissas needs to be scaled back, we may lose precision.
|
||||
*
|
||||
* In order to counter this, all operations that have this issue have a ``shift`` argument. If
|
||||
* the argument is zero, the routine will be conservative, that is, increase the exponent of
|
||||
* the result to such an extent it's mathematically impossible a value in the result will exceed
|
||||
* the maximum value that can be stored. However, when this argument is larger than zero, the
|
||||
* algorithm will hold back on this scaling by the indicated amount of bits, preserving precision
|
||||
* but increasing the chance of some of the calculated values not fitting in the mantissa anymore.
|
||||
* If this happens, the value will be clipped to the largest (or, for negative values, smallest)
|
||||
* value possible. (Neural networks usually are okay with this happening for a limited amount
|
||||
* of matrix indices).
|
||||
*
|
||||
* For deciding on these shift values, it is recommended to start with a shift value of one, then
|
||||
* use dl_matrixq_check_sanity on the result. If this indicates clipping, lower the shift value.
|
||||
* If it indicates bits are under-used, increase it. Note that for adding and subtraction, only
|
||||
* shift values of 0 or 1 make sense; these routines will error out if you try to do something
|
||||
* else.
|
||||
*
|
||||
* For neural networks and other noise-tolerant applications, note that even when
|
||||
* dl_matrixq_check_sanity does not indicate any problems, twiddling with the shift value may lead
|
||||
* to slightly improved precision. Feel free to experiment.
|
||||
**/
|
||||
|
||||
|
||||
/**
|
||||
* @brief Allocate a matrix
|
||||
*
|
||||
* @param w Width of the matrix
|
||||
* @param h Height of the matrix
|
||||
* @return The matrix, or NULL if out of memory
|
||||
*/
|
||||
dl_matrix2dq_t *dl_matrixq_alloc(int w, int h);
|
||||
dl_matrix2dq_t *dl_matrixq_alloc_psram(int w, int h);
|
||||
/**
|
||||
* @brief Convert a floating-point matrix to a quantized matrix
|
||||
*
|
||||
* @param m Floating-point matrix to convert
|
||||
* @param out Quantized matrix to re-use. If NULL, allocate a new one.
|
||||
* @Return The quantized version of the floating-point matrix
|
||||
*/
|
||||
dl_matrix2dq_t *dl_matrixq_from_matrix2d(const dl_matrix2d_t *m, dl_matrix2dq_t *out);
|
||||
|
||||
/**
|
||||
* TODO: DESCRIBE THIS FUNCTION
|
||||
*/
|
||||
dl_matrix2dq_t *dl_matrixq_from_matrix2d_by_qmf(const dl_matrix2d_t *m, dl_matrix2dq_t *out, int m_bit, int f_bit);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Convert a quantized matrix to a floating-point one.
|
||||
*
|
||||
* @param m Floating-point matrix to convert
|
||||
* @param out Quantized matrix to re-use. If NULL, allocate a new one.
|
||||
* @Return The quantized version of the floating-point matrix
|
||||
**/
|
||||
dl_matrix2d_t *dl_matrix2d_from_matrixq(const dl_matrix2dq_t *m, dl_matrix2d_t *out);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Free a quantized matrix
|
||||
* Frees the matrix structure and (if it doesn't have the DL_MF_FOREIGNDATA flag set) the m->items space as well.
|
||||
*
|
||||
* @param m Matrix to free
|
||||
*/
|
||||
void dl_matrixq_free(dl_matrix2dq_t *m);
|
||||
|
||||
/**
|
||||
* @brief Zero out the matrix
|
||||
* Sets all entries in the matrix to 0.
|
||||
*
|
||||
* @param m Matrix to zero
|
||||
*/
|
||||
void dl_matrixq_zero(dl_matrix2dq_t *m);
|
||||
|
||||
/**
|
||||
* @brief Copy the matrix into psram
|
||||
* Copy the matrix from flash or iram/psram into psram
|
||||
*
|
||||
* @param m Matrix to copy
|
||||
*/
|
||||
dl_matrix2dq_t *dl_matrixq_copy_to_psram(const dl_matrix2dq_t *m);
|
||||
|
||||
/**
|
||||
* @brief Do a dotproduct of two quantized matrices : res=a.b, Result is a fixed-point matrix.
|
||||
*
|
||||
* @param a First multiplicand
|
||||
* @param b Second multiplicand
|
||||
* @param res Dotproduct data. *Must* be a *different* matrix from a or b!
|
||||
* @param shift Shift ratio
|
||||
*/
|
||||
void dl_matrixq_dot(const dl_matrix2dq_t *a, const dl_matrix2dq_t *b, dl_matrix2dq_t *res, int shift);
|
||||
|
||||
/**
|
||||
* @brief Do a dotproduct of two quantized matrices: res=a.b, Result is a floating-point matrix.
|
||||
*
|
||||
* @param a First multiplicand
|
||||
* @param b Second multiplicand
|
||||
* @param res Dotproduct data. *Must* be a *different* matrix from a or b!
|
||||
*/
|
||||
void dl_matrixq_dot_matrix_out(const dl_matrix2dq_t *a, const dl_matrix2dq_t *b, dl_matrix2d_t *res);
|
||||
|
||||
/**
|
||||
* @brief Do a dotproduct of two quantized matrices : res=a.b. This always uses the simple & stupid C algo for the dot product.
|
||||
*
|
||||
* Result is a fixed-point matrix.
|
||||
*
|
||||
* Use this only if you expect something is wrong with the accelerated routines that dl_matrixq_dot calls; this function can be
|
||||
* much slower than dl_matrixq_dot .
|
||||
*
|
||||
* @param a First multiplicand
|
||||
* @param b Second multiplicand
|
||||
* @param res Dotproduct data. *Must* be a *different* matrix from a or b!
|
||||
* @param shift Shift ratio
|
||||
*/
|
||||
void dl_matrixq_dot_c_impl(const dl_matrix2dq_t *a, const dl_matrix2dq_t *b, dl_matrix2dq_t *res, int shift);
|
||||
|
||||
/**
|
||||
* @brief Do a dotproduct of two quantized matrices : res=a.b. This always uses the simple & stupid C algo for the dot product.
|
||||
*
|
||||
* Result is a floating-point matrix.
|
||||
*
|
||||
* Use this only if you expect something is wrong with the accelerated routines that dl_matrixq_dot_matrix_out calls; this function can be
|
||||
* much slower than dl_matrixq_dot_matrix_out.
|
||||
*
|
||||
* @param a First multiplicand
|
||||
* @param b Second multiplicand
|
||||
* @param res Dotproduct data. *Must* be a *different* matrix from a or b!
|
||||
*/
|
||||
void dl_matrixq_dot_matrix_out_c_impl(const dl_matrix2dq_t *a, const dl_matrix2dq_t *b, dl_matrix2d_t *res);
|
||||
|
||||
/**
|
||||
* @brief Do a dotproduct of a floating point and a quantized matrix. Result is a floating-point matrix.
|
||||
*
|
||||
* @param a First multiplicand; float matrix
|
||||
* @param b Second multiplicand; quantized matrix
|
||||
* @param res Dotproduct data; float matrix. *Must* be a *different* matrix from a or b!
|
||||
*/
|
||||
void dl_matrix_matrixq_dot(const dl_matrix2d_t *a, const dl_matrix2dq_t *b, dl_matrix2d_t *res);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Print the contents of a quantized matrix to stdout. Used for debugging.
|
||||
*
|
||||
* @param a The matrix to print.
|
||||
*/
|
||||
void dl_printmatrixq(const dl_matrix2dq_t *a);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Add a pair of quantizedmatrices item-by-item: res=a-b
|
||||
*
|
||||
* @param a First matrix
|
||||
* @param b Second matrix
|
||||
* @param res Added data. Can be equal to a or b to overwrite that.
|
||||
* @param shift Shift value. Only 0 or 1 makes sense here. <ToDo: check>
|
||||
*/
|
||||
void dl_matrixq_add(const dl_matrix2dq_t *a, const dl_matrix2dq_t *b, dl_matrix2dq_t *res, int shift);
|
||||
|
||||
/**
|
||||
* @brief Generate a new matrix using a range of items from an existing matrix.
|
||||
* When using this, the data of the new matrix is not allocated/copied but it re-uses a pointer
|
||||
* to the existing data. Changing the data in the resulting matrix, as a result, will also change
|
||||
* the data in the existing matrix that has been sliced.
|
||||
*
|
||||
* @Warning In contrast to the floating point equivalent of this function, the fixed-point version
|
||||
* of this has the issue that as soon as the output exponent of one of the slices changes, the data
|
||||
* in the sliced matrix gets corrupted (because the exponent of that matrix is still the same.) If you
|
||||
* use this function, either treat the slices as read-only, or assume the sliced matrix contains
|
||||
* garbage after modifying the data in one of the slices.
|
||||
*
|
||||
* @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
|
||||
* @param in Old matrix (with foreign data) to re-use. Passing NULL will allocate a new matrix.
|
||||
* @return The resulting slice matrix, or NULL if out of memory
|
||||
*/
|
||||
dl_matrix2dq_t *dl_matrixq_slice(const dl_matrix2dq_t *src, int x, int y, int w, int h, dl_matrix2dq_t *in);
|
||||
|
||||
/**
|
||||
* @brief select a range of items from an existing matrix and flatten them into one dimension.
|
||||
*
|
||||
* @Warning The results are flattened in row-major order.
|
||||
*
|
||||
* @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
|
||||
* @param in Old matrix to re-use. Passing NULL will allocate a new matrix.
|
||||
* @return The resulting flatten matrix, or NULL if out of memory
|
||||
*/
|
||||
dl_matrix2dq_t *dl_matrixq_flatten(const dl_matrix2dq_t *src, int x, int y, int w, int h, dl_matrix2dq_t *in);
|
||||
|
||||
/**
|
||||
* @brief Subtract a quantized matrix from another, item-by-item: res=a-b
|
||||
*
|
||||
* @param a First matrix
|
||||
* @param b Second matrix
|
||||
* @param res Subtracted data. Can be equal to a or b to overwrite that.
|
||||
* @param shift Shift value. Only 0 or 1 makes sense here. <ToDo: check>
|
||||
*/
|
||||
void dl_matrixq_sub(const dl_matrix2dq_t *a, const dl_matrix2dq_t *b, dl_matrix2dq_t *res, int shift);
|
||||
|
||||
/**
|
||||
* @brief Multiply a pair of quantized matrices item-by-item: res=a*b
|
||||
*
|
||||
* @param a First multiplicand
|
||||
* @param b Second multiplicand
|
||||
* @param res Multiplicated data. Can be equal to a or b to overwrite that matrix.
|
||||
*/
|
||||
void dl_matrixq_mul( dl_matrix2dq_t *a, dl_matrix2dq_t *b, dl_matrix2dq_t *res);
|
||||
|
||||
/**
|
||||
* @brief Divide a pair of quantized matrices item-by-item: res=a/b
|
||||
*
|
||||
* @param a First matrix
|
||||
* @param b Second matrix
|
||||
* @param res Divided data. Can be equal to a or b to overwrite that.
|
||||
*/
|
||||
void dl_matrixq_div(const dl_matrix2dq_t *a, const dl_matrix2dq_t *b, dl_matrix2dq_t *out, int shift);
|
||||
|
||||
/**
|
||||
* @brief Check if two quantized matrices have the same shape, that is, the same amount of
|
||||
* rows and columns
|
||||
*
|
||||
* @param a First of the two matrices to compare
|
||||
* @param b Second of the two matrices to compare
|
||||
* @return true if the two matrices are shaped the same, false otherwise.
|
||||
*/
|
||||
int dl_matrixq_same_shape(const dl_matrix2dq_t *a, const dl_matrix2dq_t *b);
|
||||
|
||||
/**
|
||||
* @brief Concatenate the rows of two quantized matrices into a new matrix
|
||||
*
|
||||
* @param a First matrix
|
||||
* @param b Second matrix
|
||||
* @return A newly allocated quantized matrix with as values a|b
|
||||
*/
|
||||
dl_matrix2dq_t *dl_matrixq_concat(const dl_matrix2dq_t *a, const dl_matrix2dq_t *b);
|
||||
|
||||
/**
|
||||
* @brief Add a constant to every item of the quantized matrix
|
||||
*
|
||||
* @param subj Matrix to add the constant to
|
||||
* @param add The constant
|
||||
*/
|
||||
void dl_matrixq_add_const(dl_matrix2dq_t *subj, const fptp_t add, int shift);
|
||||
|
||||
/**
|
||||
* @brief Check the sanity of a quantized matrix
|
||||
*
|
||||
* Due to the nature of quantized matrices, depending on the calculations a quantized
|
||||
* matrix is the result of and the shift values chosen in those calculations, a quantized
|
||||
* matrix may have an exponent and mantissas that lead to a loss of precision, either because
|
||||
* most significant mantissa bits are unused, or because a fair amount of mantissas are
|
||||
* clipped. This function checks if this is the case and will report a message to stdout
|
||||
* if significant loss of precision is detected.
|
||||
*
|
||||
* @param m The quantized matrix to check
|
||||
* @param name A string to be displayed in the message if the sanity check fails
|
||||
* @return True if matrix is sane, false otherwise
|
||||
**/
|
||||
|
||||
int dl_matrixq_check_sanity(dl_matrix2dq_t *m, const char *name);
|
||||
|
||||
/**
|
||||
* @brief re-adjust the exponent of the matrix to fit the mantissa better
|
||||
*
|
||||
* This function will shift up all the data in the mantissas so there are no
|
||||
* most-significant bits that are unused in all mantissas. It will also adjust
|
||||
* the exponent to keep the actua values in the matrix the same.
|
||||
*
|
||||
* Some operations done on a matrix, especially operations that re-use the
|
||||
* result of earlier operations done in the same way, can lead to the loss of
|
||||
* data because the exponent of the quantized matrix is never re-adjusted. You
|
||||
* can do that implicitely by calling this function.
|
||||
*
|
||||
* @param m The matrix to re-adjust
|
||||
**/
|
||||
void dl_matrixq_readjust_exp(dl_matrix2dq_t *m);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the floating-point value of a specific item from the quantized matrix
|
||||
*
|
||||
* @param m Matrix to access
|
||||
* @param x Column address
|
||||
* @param y Row address
|
||||
* @return Value in that position
|
||||
*/
|
||||
fptp_t dl_matrixq_get(const dl_matrix2dq_t *m, const int x, const int y);
|
||||
|
||||
/**
|
||||
* @brief Set a specific item in the quantized matrix to the given
|
||||
* floating-point value
|
||||
*
|
||||
* @warning If the given value is more than the exponent in the quantized matrix
|
||||
* allows for, all mantissas in the matrix will be shifted down to make the value
|
||||
* 'fit'. If, however, the exponent is such that the value would result in a
|
||||
* quantized mantissa of 0, nothing is done.
|
||||
*
|
||||
* @param m Matrix to access
|
||||
* @param x Column address
|
||||
* @param y Row address
|
||||
* @param val Value to write to that position
|
||||
*/
|
||||
void dl_matrixq_set(dl_matrix2dq_t *m, const int x, const int y, fptp_t val);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
// 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.
|
||||
#ifndef DL_LIB_MATRIXQ8_H
|
||||
#define DL_LIB_MATRIXQ8_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "dl_lib_matrix.h"
|
||||
#include "dl_lib.h"
|
||||
#include "dl_lib_matrixq.h"
|
||||
|
||||
typedef int8_t q8tp_t;
|
||||
|
||||
typedef struct {
|
||||
int w;
|
||||
int h;
|
||||
int stride; //Normally equals h, not w!
|
||||
int flags;
|
||||
int exponent; //The values in items should be multiplied by pow(2,exponent) to get the real values.
|
||||
q8tp_t *itemq;
|
||||
} dl_matrix2dq8_t;
|
||||
|
||||
#define DL_Q8TP_SHIFT 7
|
||||
#define DL_Q8TP_RANGE ((1<<DL_Q8TP_SHIFT)-1)
|
||||
#define DL_ITMQ8(m, x, y) m->itemq[(y)+(x)*m->stride]
|
||||
|
||||
/**
|
||||
* @brief Allocate a matrix
|
||||
*
|
||||
* @param w Width of the matrix
|
||||
* @param h Height of the matrix
|
||||
* @return The matrix, or NULL if out of memory
|
||||
*/
|
||||
dl_matrix2dq8_t *dl_matrixq8_alloc(int w, int h);
|
||||
|
||||
/**
|
||||
* @brief Free a quantized matrix
|
||||
* Frees the matrix structure and (if it doesn't have the DL_MF_FOREIGNDATA flag set) the m->items space as well.
|
||||
*
|
||||
* @param m Matrix to free
|
||||
*/
|
||||
void dl_matrixq8_free(dl_matrix2dq8_t *m);
|
||||
|
||||
/**
|
||||
* @brief Copy a quantized matrix
|
||||
* Copy a quantized matrix from flash or iram/psram
|
||||
*
|
||||
* @param m Matrix to copy
|
||||
*/
|
||||
dl_matrix2dq8_t *dl_matrixq8_copy_to_psram(const dl_matrix2dq8_t *m);
|
||||
|
||||
/**
|
||||
* @brief Convert a floating-point matrix to a quantized matrix
|
||||
*
|
||||
* @param m Floating-point matrix to convert
|
||||
* @param out Quantized matrix to re-use. If NULL, allocate a new one.
|
||||
* @Return The quantized version of the floating-point matrix
|
||||
*/
|
||||
dl_matrix2dq8_t *dl_matrixq8_from_matrix2d(const dl_matrix2d_t *m, dl_matrix2dq8_t *out);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,112 +0,0 @@
|
|||
// 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
|
||||
#ifndef _ESP_AEC_H_
|
||||
#define _ESP_AEC_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define USE_AEC_FFT // Not kiss_fft
|
||||
#define AEC_USE_SPIRAM 0
|
||||
#define AEC_SAMPLE_RATE 16000 // Only Support 16000Hz
|
||||
#define AEC_FRAME_LENGTH_MS 16
|
||||
#define AEC_FILTER_LENGTH 1200 // Number of samples of echo to cancel
|
||||
|
||||
typedef void* aec_handle_t;
|
||||
|
||||
/**
|
||||
* @brief Creates an instance to the AEC structure.
|
||||
*
|
||||
* @deprecated This API will be deprecated after version 1.0, please use aec_pro_create
|
||||
*
|
||||
* @param sample_rate The Sampling frequency (Hz) must be 16000.
|
||||
*
|
||||
* @param frame_length The length of the audio processing must be 16ms.
|
||||
*
|
||||
* @param filter_length Number of samples of echo to cancel.
|
||||
*
|
||||
* @return
|
||||
* - NULL: Create failed
|
||||
* - Others: The instance of AEC
|
||||
*/
|
||||
aec_handle_t aec_create(int sample_rate, int frame_length, int filter_length);
|
||||
|
||||
/**
|
||||
* @brief Creates an instance to the AEC structure.
|
||||
*
|
||||
* @deprecated This API will be deprecated after version 1.0, please use aec_pro_create
|
||||
*
|
||||
* @param sample_rate The Sampling frequency (Hz) must be 16000.
|
||||
*
|
||||
* @param frame_length The length of the audio processing must be 16ms.
|
||||
*
|
||||
* @param filter_length Number of samples of echo to cancel.
|
||||
*
|
||||
* @param nch Number of input signal channel.
|
||||
*
|
||||
* @return
|
||||
* - NULL: Create failed
|
||||
* - Others: The instance of AEC
|
||||
*/
|
||||
aec_handle_t aec_create_multimic(int sample_rate, int frame_length, int filter_length, int nch);
|
||||
|
||||
/**
|
||||
* @brief Creates an instance of more powerful AEC.
|
||||
*
|
||||
* @param frame_length Length of input signal. Must be 16ms if mode is 0; otherwise could be 16ms or 32ms. Length of input signal to aec_process must be modified accordingly.
|
||||
*
|
||||
* @param nch Number of microphones.
|
||||
*
|
||||
* @param mode Mode of AEC (0 to 5), indicating aggressiveness and RAM allocation. 0: mild; 1 or 2: medium (1: internal RAM, 2: SPIRAM); 3 and 4: aggressive (3: internal RAM, 4: SPIRAM); 5: agressive, accelerated for ESP32-S3.
|
||||
*
|
||||
* @return
|
||||
* - NULL: Create failed
|
||||
* - Others: An Instance of AEC
|
||||
*/
|
||||
aec_handle_t aec_pro_create(int frame_length, int nch, int mode);
|
||||
|
||||
/**
|
||||
* @brief Performs echo cancellation a frame, based on the audio sent to the speaker and frame from mic.
|
||||
*
|
||||
* @param inst The instance of AEC.
|
||||
*
|
||||
* @param indata An array of 16-bit signed audio samples from mic.
|
||||
*
|
||||
* @param refdata An array of 16-bit signed audio samples sent to the speaker.
|
||||
*
|
||||
* @param outdata Returns near-end signal with echo removed.
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void aec_process(const aec_handle_t inst, int16_t *indata, int16_t *refdata, int16_t *outdata);
|
||||
|
||||
/**
|
||||
* @brief Free the AEC instance
|
||||
*
|
||||
* @param inst The instance of AEC.
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void aec_destroy(aec_handle_t inst);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //_ESP_AEC_H_
|
||||
|
|
@ -1,131 +0,0 @@
|
|||
#pragma once
|
||||
#include "stdint.h"
|
||||
#include "esp_wn_iface.h"
|
||||
#include "esp_wn_models.h"
|
||||
#include "esp_vad.h"
|
||||
|
||||
//AFE: Audio Front-End
|
||||
//SR: Speech Recognition
|
||||
//afe_sr/AFE_SR: the audio front-end for speech recognition
|
||||
|
||||
|
||||
//Set AFE_SR mode
|
||||
typedef enum {
|
||||
SR_MODE_LOW_COST = 0,
|
||||
SR_MODE_HIGH_PERF = 1
|
||||
} afe_sr_mode_t;
|
||||
|
||||
typedef enum {
|
||||
AFE_MEMORY_ALLOC_MORE_INTERNAL = 1, // malloc with more internal ram
|
||||
AFE_MEMORY_ALLOC_INTERNAL_PSRAM_BALANCE = 2, // malloc with internal ram and psram in balance
|
||||
AFE_MEMORY_ALLOC_MORE_PSRAM = 3 // malloc with more psram
|
||||
} afe_memory_alloc_mode_t;
|
||||
|
||||
typedef enum {
|
||||
AFE_MN_PEAK_AGC_MODE_1 = -5, // The peak amplitude of audio fed to multinet is -5dB
|
||||
AFE_MN_PEAK_AGC_MODE_2 = -4, // The peak amplitude of audio fed to multinet is -4dB
|
||||
AFE_MN_PEAK_AGC_MODE_3 = -3, // The peak amplitude of audio fed to multinet is -3dB
|
||||
AFE_MN_PEAK_NO_AGC = 0, // There is no agc gain
|
||||
} afe_mn_peak_agc_mode_t;
|
||||
|
||||
typedef struct {
|
||||
int total_ch_num; // total channel num. It must be: total_ch_num = mic_num + ref_num
|
||||
int mic_num; // mic channel num
|
||||
int ref_num; // reference channel num
|
||||
int sample_rate; // sample rate of audio
|
||||
} afe_pcm_config_t;
|
||||
|
||||
/**
|
||||
* @brief Function to get the debug audio data
|
||||
*
|
||||
* @param data The debug audio data which don't be modify. It should be copied away as soon as possible that avoid blocking for too long.
|
||||
* @param data_size The number of bytes of data.
|
||||
* @returns
|
||||
*/
|
||||
typedef void (*afe_debug_hook_callback_t)(const int16_t* data, int data_size);
|
||||
|
||||
typedef enum {
|
||||
AFE_DEBUG_HOOK_MASE_TASK_IN = 0, // To get the input data of mase task
|
||||
AFE_DEBUG_HOOK_FETCH_TASK_IN = 1, // To get the input data of fetch task
|
||||
AFE_DEBUG_HOOK_MAX = 2
|
||||
} afe_debug_hook_type_t;
|
||||
|
||||
typedef struct {
|
||||
afe_debug_hook_type_t hook_type; // debug type of hook
|
||||
afe_debug_hook_callback_t hook_callback; // callback function which transfer debug audio data
|
||||
} afe_debug_hook_t;
|
||||
|
||||
typedef struct {
|
||||
bool aec_init;
|
||||
bool se_init;
|
||||
bool vad_init;
|
||||
bool wakenet_init;
|
||||
bool voice_communication_init;
|
||||
bool voice_communication_agc_init; // AGC swich for voice communication
|
||||
int voice_communication_agc_gain; // AGC gain(dB) for voice communication
|
||||
vad_mode_t vad_mode; // The value can be: VAD_MODE_0, VAD_MODE_1, VAD_MODE_2, VAD_MODE_3, VAD_MODE_4
|
||||
char *wakenet_model_name; // The model name of wakenet
|
||||
det_mode_t wakenet_mode;
|
||||
afe_sr_mode_t afe_mode;
|
||||
int afe_perferred_core;
|
||||
int afe_perferred_priority;
|
||||
int afe_ringbuf_size;
|
||||
afe_memory_alloc_mode_t memory_alloc_mode;
|
||||
afe_mn_peak_agc_mode_t agc_mode; // The agc mode for ASR
|
||||
afe_pcm_config_t pcm_config; // Config the channel num of original data which is fed to the afe feed function.
|
||||
bool debug_init;
|
||||
afe_debug_hook_t debug_hook[AFE_DEBUG_HOOK_MAX];
|
||||
} afe_config_t;
|
||||
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#define AFE_CONFIG_DEFAULT() { \
|
||||
.aec_init = true, \
|
||||
.se_init = true, \
|
||||
.vad_init = true, \
|
||||
.wakenet_init = true, \
|
||||
.voice_communication_init = false, \
|
||||
.voice_communication_agc_init = false, \
|
||||
.voice_communication_agc_gain = 15, \
|
||||
.vad_mode = VAD_MODE_3, \
|
||||
.wakenet_model_name = NULL, \
|
||||
.wakenet_mode = DET_MODE_90, \
|
||||
.afe_mode = SR_MODE_HIGH_PERF, \
|
||||
.afe_perferred_core = 0, \
|
||||
.afe_perferred_priority = 5, \
|
||||
.afe_ringbuf_size = 50, \
|
||||
.memory_alloc_mode = AFE_MEMORY_ALLOC_INTERNAL_PSRAM_BALANCE, \
|
||||
.agc_mode = AFE_MN_PEAK_AGC_MODE_2, \
|
||||
.pcm_config.total_ch_num = 2, \
|
||||
.pcm_config.mic_num = 1, \
|
||||
.pcm_config.ref_num = 1, \
|
||||
.pcm_config.sample_rate = 16000, \
|
||||
.debug_init = false, \
|
||||
.debug_hook = {{AFE_DEBUG_HOOK_MASE_TASK_IN, NULL}, {AFE_DEBUG_HOOK_FETCH_TASK_IN, NULL}}, \
|
||||
}
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#define AFE_CONFIG_DEFAULT() { \
|
||||
.aec_init = true, \
|
||||
.se_init = true, \
|
||||
.vad_init = true, \
|
||||
.wakenet_init = true, \
|
||||
.voice_communication_init = false, \
|
||||
.voice_communication_agc_init = false, \
|
||||
.voice_communication_agc_gain = 15, \
|
||||
.vad_mode = VAD_MODE_3, \
|
||||
.wakenet_model_name = NULL, \
|
||||
.wakenet_mode = DET_MODE_2CH_90, \
|
||||
.afe_mode = SR_MODE_LOW_COST, \
|
||||
.afe_perferred_core = 0, \
|
||||
.afe_perferred_priority = 5, \
|
||||
.afe_ringbuf_size = 50, \
|
||||
.memory_alloc_mode = AFE_MEMORY_ALLOC_MORE_PSRAM, \
|
||||
.agc_mode = AFE_MN_PEAK_AGC_MODE_2, \
|
||||
.pcm_config.total_ch_num = 3, \
|
||||
.pcm_config.mic_num = 2, \
|
||||
.pcm_config.ref_num = 1, \
|
||||
.pcm_config.sample_rate = 16000, \
|
||||
.debug_init = false, \
|
||||
.debug_hook = {{AFE_DEBUG_HOOK_MASE_TASK_IN, NULL}, {AFE_DEBUG_HOOK_FETCH_TASK_IN, NULL}}, \
|
||||
}
|
||||
#endif
|
||||
|
|
@ -1,199 +0,0 @@
|
|||
#pragma once
|
||||
#include "stdint.h"
|
||||
#include "esp_afe_config.h"
|
||||
|
||||
//AFE: Audio Front-End
|
||||
//SR: Speech Recognition
|
||||
//afe_sr/AFE_SR: the audio front-end for speech recognition
|
||||
|
||||
//Opaque AFE_SR data container
|
||||
typedef struct esp_afe_sr_data_t esp_afe_sr_data_t;
|
||||
|
||||
/**
|
||||
* @brief The state of vad
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AFE_VAD_SILENCE = 0, // noise or silence
|
||||
AFE_VAD_SPEECH // speech
|
||||
} afe_vad_state_t;
|
||||
|
||||
/**
|
||||
* @brief The result of fetch function
|
||||
*/
|
||||
typedef struct afe_fetch_result_t
|
||||
{
|
||||
int16_t *data; // the data of audio.
|
||||
int data_size; // the size of data. The unit is byte.
|
||||
wakenet_state_t wakeup_state; // the value is wakenet_state_t
|
||||
int wake_word_index; // if the wake word is detected. It will store the wake word index which start from 1.
|
||||
afe_vad_state_t vad_state; // the value is afe_vad_state_t
|
||||
int trigger_channel_id; // the channel index of output
|
||||
int wake_word_length; // the length of wake word. It's unit is the number of samples.
|
||||
int ret_value; // the return state of fetch function
|
||||
void* reserved; // reserved for future use
|
||||
} afe_fetch_result_t;
|
||||
|
||||
/**
|
||||
* @brief Function to initialze a AFE_SR instance
|
||||
*
|
||||
* @param afe_config The config of AFE_SR
|
||||
* @returns Handle to the AFE_SR data
|
||||
*/
|
||||
typedef esp_afe_sr_data_t* (*esp_afe_sr_iface_op_create_from_config_t)(afe_config_t *afe_config);
|
||||
|
||||
/**
|
||||
* @brief Get the amount of each channel samples per frame that need to be passed to the function
|
||||
*
|
||||
* Every speech enhancement AFE_SR processes a certain number of samples at the same time. This function
|
||||
* can be used to query that amount. Note that the returned amount is in 16-bit samples, not in bytes.
|
||||
*
|
||||
* @param afe The AFE_SR object to query
|
||||
* @return The amount of samples to feed the fetch function
|
||||
*/
|
||||
typedef int (*esp_afe_sr_iface_op_get_samp_chunksize_t)(esp_afe_sr_data_t *afe);
|
||||
|
||||
/**
|
||||
* @brief Get the total channel number which be config
|
||||
*
|
||||
* @param afe The AFE_SR object to query
|
||||
* @return The amount of total channels
|
||||
*/
|
||||
typedef int (*esp_afe_sr_iface_op_get_total_channel_num_t)(esp_afe_sr_data_t *afe);
|
||||
|
||||
/**
|
||||
* @brief Get the mic channel number which be config
|
||||
*
|
||||
* @param afe The AFE_SR object to query
|
||||
* @return The amount of mic channels
|
||||
*/
|
||||
typedef int (*esp_afe_sr_iface_op_get_channel_num_t)(esp_afe_sr_data_t *afe);
|
||||
|
||||
/**
|
||||
* @brief Get the sample rate of the samples to feed to the function
|
||||
*
|
||||
* @param afe The AFE_SR object to query
|
||||
* @return The sample rate, in hz
|
||||
*/
|
||||
typedef int (*esp_afe_sr_iface_op_get_samp_rate_t)(esp_afe_sr_data_t *afe);
|
||||
|
||||
/**
|
||||
* @brief Feed samples of an audio stream to the AFE_SR
|
||||
*
|
||||
* @Warning The input data should be arranged in the format of channel interleaving.
|
||||
* The last channel is reference signal if it has reference data.
|
||||
*
|
||||
* @param afe The AFE_SR object to query
|
||||
*
|
||||
* @param in The input microphone signal, only support signed 16-bit @ 16 KHZ. The frame size can be queried by the
|
||||
* `get_feed_chunksize`.
|
||||
* @return The size of input
|
||||
*/
|
||||
typedef int (*esp_afe_sr_iface_op_feed_t)(esp_afe_sr_data_t *afe, const int16_t* in);
|
||||
|
||||
/**
|
||||
* @brief fetch enhanced samples of an audio stream from the AFE_SR
|
||||
*
|
||||
* @Warning The output is single channel data, no matter how many channels the input is.
|
||||
*
|
||||
* @param afe The AFE_SR object to query
|
||||
* @return The result of output, please refer to the definition of `afe_fetch_result_t`. (The frame size of output audio can be queried by the `get_fetch_chunksize`.)
|
||||
*/
|
||||
typedef afe_fetch_result_t* (*esp_afe_sr_iface_op_fetch_t)(esp_afe_sr_data_t *afe);
|
||||
|
||||
/**
|
||||
* @brief reset ringbuf of AFE.
|
||||
*
|
||||
* @param afe The AFE_SR object to query
|
||||
* @return -1: fail, 0: success
|
||||
*/
|
||||
typedef int (*esp_afe_sr_iface_op_reset_buffer_t)(esp_afe_sr_data_t *afe);
|
||||
|
||||
/**
|
||||
* @brief Initial wakenet and wake words coefficient, or reset wakenet and wake words coefficient
|
||||
* when wakenet has been initialized.
|
||||
*
|
||||
* @param afe The AFE_SR object to query
|
||||
* @param wakenet_word The wakenet word, should be DEFAULT_WAKE_WORD or EXTRA_WAKE_WORD
|
||||
* @return 0: fail, 1: success
|
||||
*/
|
||||
typedef int (*esp_afe_sr_iface_op_set_wakenet_t)(esp_afe_sr_data_t *afe, char* model_name);
|
||||
|
||||
/**
|
||||
* @brief Disable wakenet model.
|
||||
*
|
||||
* @param afe The AFE_SR object to query
|
||||
* @return 0: fail, 1: success
|
||||
*/
|
||||
typedef int (*esp_afe_sr_iface_op_disable_wakenet_t)(esp_afe_sr_data_t *afe);
|
||||
|
||||
/**
|
||||
* @brief Enable wakenet model.
|
||||
*
|
||||
* @param afe The AFE_SR object to query
|
||||
* @return 0: fail, 1: success
|
||||
*/
|
||||
typedef int (*esp_afe_sr_iface_op_enable_wakenet_t)(esp_afe_sr_data_t *afe);
|
||||
|
||||
/**
|
||||
* @brief Disable AEC algorithm.
|
||||
*
|
||||
* @param afe The AFE_SR object to query
|
||||
* @return 0: fail, 1: success
|
||||
*/
|
||||
typedef int (*esp_afe_sr_iface_op_disable_aec_t)(esp_afe_sr_data_t *afe);
|
||||
|
||||
/**
|
||||
* @brief Enable AEC algorithm.
|
||||
*
|
||||
* @param afe The AFE_SR object to query
|
||||
* @return 0: fail, 1: success
|
||||
*/
|
||||
typedef int (*esp_afe_sr_iface_op_enable_aec_t)(esp_afe_sr_data_t *afe);
|
||||
|
||||
/**
|
||||
* @brief Disable SE algorithm.
|
||||
*
|
||||
* @param afe The AFE_SR object to query
|
||||
* @return 0: fail, 1: success
|
||||
*/
|
||||
typedef int (*esp_afe_sr_iface_op_disable_se_t)(esp_afe_sr_data_t *afe);
|
||||
|
||||
/**
|
||||
* @brief Enable SE algorithm.
|
||||
*
|
||||
* @param afe The AFE_SR object to query
|
||||
* @return 0: fail, 1: success
|
||||
*/
|
||||
typedef int (*esp_afe_sr_iface_op_enable_se_t)(esp_afe_sr_data_t *afe);
|
||||
|
||||
/**
|
||||
* @brief Destroy a AFE_SR instance
|
||||
*
|
||||
* @param afe AFE_SR object to destroy
|
||||
*/
|
||||
typedef void (*esp_afe_sr_iface_op_destroy_t)(esp_afe_sr_data_t *afe);
|
||||
|
||||
|
||||
/**
|
||||
* This structure contains the functions used to do operations on a AFE_SR.
|
||||
*/
|
||||
typedef struct {
|
||||
esp_afe_sr_iface_op_create_from_config_t create_from_config;
|
||||
esp_afe_sr_iface_op_feed_t feed;
|
||||
esp_afe_sr_iface_op_fetch_t fetch;
|
||||
esp_afe_sr_iface_op_reset_buffer_t reset_buffer;
|
||||
esp_afe_sr_iface_op_get_samp_chunksize_t get_feed_chunksize;
|
||||
esp_afe_sr_iface_op_get_samp_chunksize_t get_fetch_chunksize;
|
||||
esp_afe_sr_iface_op_get_total_channel_num_t get_total_channel_num;
|
||||
esp_afe_sr_iface_op_get_channel_num_t get_channel_num;
|
||||
esp_afe_sr_iface_op_get_samp_rate_t get_samp_rate;
|
||||
esp_afe_sr_iface_op_set_wakenet_t set_wakenet;
|
||||
esp_afe_sr_iface_op_disable_wakenet_t disable_wakenet;
|
||||
esp_afe_sr_iface_op_enable_wakenet_t enable_wakenet;
|
||||
esp_afe_sr_iface_op_disable_aec_t disable_aec;
|
||||
esp_afe_sr_iface_op_enable_aec_t enable_aec;
|
||||
esp_afe_sr_iface_op_disable_se_t disable_se;
|
||||
esp_afe_sr_iface_op_enable_se_t enable_se;
|
||||
esp_afe_sr_iface_op_destroy_t destroy;
|
||||
} esp_afe_sr_iface_t;
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#if defined CONFIG_USE_AFE
|
||||
#include "esp_afe_sr_iface.h"
|
||||
|
||||
|
||||
#if CONFIG_AFE_INTERFACE_V1
|
||||
extern const esp_afe_sr_iface_t esp_afe_sr_v1;
|
||||
extern const esp_afe_sr_iface_t esp_afe_vc_v1;
|
||||
#define ESP_AFE_SR_HANDLE esp_afe_sr_v1
|
||||
#define ESP_AFE_VC_HANDLE esp_afe_vc_v1
|
||||
|
||||
#else
|
||||
#error No valid afe selected.
|
||||
#endif
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
||||
#include "esp_afe_sr_iface.h"
|
||||
extern const esp_afe_sr_iface_t esp_afe_sr_v1;
|
||||
extern const esp_afe_sr_iface_t esp_afe_vc_v1;
|
||||
#define ESP_AFE_SR_HANDLE esp_afe_sr_v1
|
||||
#define ESP_AFE_VC_HANDLE esp_afe_vc_v1
|
||||
|
||||
#endif
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
// 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
|
||||
#ifndef _ESP_AGC_H_
|
||||
#define _ESP_AGC_H_
|
||||
|
||||
////all positive value is valid, negective is error
|
||||
typedef enum {
|
||||
ESP_AGC_SUCCESS = 0, ////success
|
||||
ESP_AGC_FAIL = -1, ////agc fail
|
||||
ESP_AGC_SAMPLE_RATE_ERROR = -2, ///sample rate can be only 8khz, 16khz, 32khz
|
||||
ESP_AGC_FRAME_SIZE_ERROR = -3, ////the input frame size should be only 10ms, so should together with sample-rate to get the frame size
|
||||
} ESP_AGE_ERR;
|
||||
|
||||
|
||||
void *esp_agc_open(int agc_mode, int sample_rate);
|
||||
void set_agc_config(void *agc_handle, int gain_dB, int limiter_enable, int target_level_dbfs);
|
||||
int esp_agc_process(void *agc_handle, short *in_pcm, short *out_pcm, int frame_size, int sample_rate);
|
||||
void esp_agc_close(void *agc_handle);
|
||||
|
||||
#endif // _ESP_AGC_H_
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
// 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
|
||||
|
||||
#define MASE_SAMPLE_RATE 16000 // Supports 16kHz only
|
||||
#define MASE_FRAME_SIZE 16 // Supports 16ms only
|
||||
#define MASE_MIC_DISTANCE 65 // According to physical design of mic-array
|
||||
|
||||
/**
|
||||
* @brief Sets mic-array type, currently 2-mic line array and 3-mic circular array
|
||||
* are supported.
|
||||
*/
|
||||
typedef enum {
|
||||
TWO_MIC_LINE = 0,
|
||||
THREE_MIC_CIRCLE = 1
|
||||
} mase_mic_array_type_t;
|
||||
|
||||
/**
|
||||
* @brief Sets operating mode, supporting normal mode and wake-up enhancement mode
|
||||
*/
|
||||
typedef enum {
|
||||
NORMAL_ENHANCEMENT_MODE = 0,
|
||||
WAKE_UP_ENHANCEMENT_MODE = 1
|
||||
} mase_op_mode_t;
|
||||
|
||||
typedef void* mase_handle_t;
|
||||
|
||||
/**
|
||||
* @brief Creates an instance to the MASE structure.
|
||||
*
|
||||
* @param sample_rate The sampling frequency (Hz) must be 16000.
|
||||
*
|
||||
* @param frame_size The length of the audio processing must be 16ms.
|
||||
*
|
||||
* @param array_type '0' for 2-mic line array and '1' for 3-mic circular array.
|
||||
*
|
||||
* @param mic_distance The distance between neiboring microphones in mm.
|
||||
*
|
||||
* @param operating_mode '0' for normal mode and '1' for wake-up enhanced mode.
|
||||
*
|
||||
* @param filter_strength Strengh of the mic-array speech enhancement, must be 0, 1, 2 or 3.
|
||||
*
|
||||
* @return
|
||||
* - NULL: Create failed
|
||||
* - Others: An instance of MASE
|
||||
*/
|
||||
mase_handle_t mase_create(int fs, int frame_size, int array_type, float mic_distance, int operating_mode, int filter_strength);
|
||||
|
||||
/**
|
||||
* @brief Performs mic array processing for one frame.
|
||||
*
|
||||
* @param inst The instance of MASE.
|
||||
*
|
||||
* @param in An array of 16-bit signed audio samples from mic.
|
||||
*
|
||||
* @param dsp_out Returns enhanced signal.
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void mase_process(mase_handle_t st, int16_t *in, int16_t *dsp_out);
|
||||
|
||||
/**
|
||||
* @brief Free the MASE instance
|
||||
*
|
||||
* @param inst The instance of MASE.
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void mase_destory(mase_handle_t st);
|
||||
|
|
@ -1,153 +0,0 @@
|
|||
#pragma once
|
||||
#include "stdint.h"
|
||||
#include "esp_wn_iface.h"
|
||||
|
||||
#define ESP_MN_RESULT_MAX_NUM 5
|
||||
#define ESP_MN_MAX_PHRASE_NUM 200
|
||||
#define ESP_MN_MAX_PHRASE_LEN 63
|
||||
#define ESP_MN_MIN_PHRASE_LEN 2
|
||||
|
||||
#define ESP_MN_PREFIX "mn"
|
||||
#define ESP_MN_ENGLISH "en"
|
||||
#define ESP_MN_CHINESE "cn"
|
||||
|
||||
typedef enum {
|
||||
ESP_MN_STATE_DETECTING = 0, // detecting
|
||||
ESP_MN_STATE_DETECTED = 1, // detected
|
||||
ESP_MN_STATE_TIMEOUT = 2, // time out
|
||||
} esp_mn_state_t;
|
||||
|
||||
// Return all possible recognition results
|
||||
typedef struct{
|
||||
esp_mn_state_t state;
|
||||
int num; // The number of phrase in list, num<=5. When num=0, no phrase is recognized.
|
||||
int command_id[ESP_MN_RESULT_MAX_NUM]; // The list of command id.
|
||||
int phrase_id[ESP_MN_RESULT_MAX_NUM]; // The list of phrase id.
|
||||
float prob[ESP_MN_RESULT_MAX_NUM]; // The list of probability.
|
||||
} esp_mn_results_t;
|
||||
|
||||
typedef struct{
|
||||
int16_t num; // The number of error phrases, which can not added into model
|
||||
int16_t phrase_idx[ESP_MN_MAX_PHRASE_NUM]; // The error phrase index in singly linked list.
|
||||
} esp_mn_error_t;
|
||||
|
||||
typedef struct {
|
||||
char phoneme_string[ESP_MN_MAX_PHRASE_LEN + 1]; // phoneme string
|
||||
int16_t command_id; // the command id
|
||||
float threshold; // trigger threshold, default: 0
|
||||
int16_t *wave; // prompt wave data of the phrase
|
||||
} esp_mn_phrase_t;
|
||||
|
||||
typedef struct _mn_node_ {
|
||||
esp_mn_phrase_t *phrase;
|
||||
struct _mn_node_ *next;
|
||||
} esp_mn_node_t;
|
||||
|
||||
/**
|
||||
* @brief Initialze a model instance with specified model name.
|
||||
*
|
||||
* @param model_name The wakenet model name.
|
||||
* @param duration The duration (ms) to trigger the timeout
|
||||
*
|
||||
* @returns Handle to the model data.
|
||||
*/
|
||||
typedef model_iface_data_t* (*esp_mn_iface_op_create_t)(const char *model_name, int duration);
|
||||
|
||||
/**
|
||||
* @brief Callback function type to fetch the amount of samples that need to be passed to the detect function
|
||||
*
|
||||
* Every speech recognition model processes a certain number of samples at the same time. This function
|
||||
* can be used to query that amount. Note that the returned amount is in 16-bit samples, not in bytes.
|
||||
*
|
||||
* @param model The model object to query
|
||||
* @return The amount of samples to feed the detect function
|
||||
*/
|
||||
typedef int (*esp_mn_iface_op_get_samp_chunksize_t)(model_iface_data_t *model);
|
||||
|
||||
/**
|
||||
* @brief Callback function type to fetch the number of frames recognized by the command word
|
||||
*
|
||||
* @param model The model object to query
|
||||
* @return The number of the frames recognized by the command word
|
||||
*/
|
||||
typedef int (*esp_mn_iface_op_get_samp_chunknum_t)(model_iface_data_t *model);
|
||||
|
||||
/**
|
||||
* @brief Set the detection threshold to manually abjust the probability
|
||||
*
|
||||
* @param model The model object to query
|
||||
* @param det_treshold The threshold to trigger speech commands, the range of det_threshold is 0.0~0.9999
|
||||
*/
|
||||
typedef int (*esp_mn_iface_op_set_det_threshold_t)(model_iface_data_t *model, float det_threshold);
|
||||
|
||||
/**
|
||||
* @brief Get the sample rate of the samples to feed to the detect function
|
||||
*
|
||||
* @param model The model object to query
|
||||
* @return The sample rate, in hz
|
||||
*/
|
||||
typedef int (*esp_mn_iface_op_get_samp_rate_t)(model_iface_data_t *model);
|
||||
|
||||
/**
|
||||
* @brief Get the language of model
|
||||
*
|
||||
* @param model The language name
|
||||
* @return Language name string defined in esp_mn_models.h, eg: ESP_MN_CHINESE, ESP_MN_ENGLISH
|
||||
*/
|
||||
typedef char * (*esp_mn_iface_op_get_language_t)(model_iface_data_t *model);
|
||||
|
||||
/**
|
||||
* @brief Feed samples of an audio stream to the speech recognition model and detect if there is a speech command found.
|
||||
*
|
||||
* @param model The model object to query.
|
||||
* @param samples An array of 16-bit signed audio samples. The array size used can be queried by the
|
||||
* get_samp_chunksize function.
|
||||
* @return The state of multinet
|
||||
*/
|
||||
typedef esp_mn_state_t (*esp_mn_iface_op_detect_t)(model_iface_data_t *model, int16_t *samples);
|
||||
|
||||
/**
|
||||
* @brief Destroy a speech commands recognition model
|
||||
*
|
||||
* @param model The Model object to destroy
|
||||
*/
|
||||
typedef void (*esp_mn_iface_op_destroy_t)(model_iface_data_t *model);
|
||||
|
||||
/**
|
||||
* @brief Get recognition results
|
||||
*
|
||||
* @param model The Model object to query
|
||||
*
|
||||
* @return The current results.
|
||||
*/
|
||||
typedef esp_mn_results_t* (*esp_mn_iface_op_get_results_t)(model_iface_data_t *model);
|
||||
|
||||
/**
|
||||
* @brief Open the log print
|
||||
*
|
||||
* @param model_data The model object to query.
|
||||
*
|
||||
*/
|
||||
typedef void (*esp_mn_iface_op_open_log_t)(model_iface_data_t *model_data);
|
||||
|
||||
/**
|
||||
* @brief Set the speech commands by mn_command_root
|
||||
*
|
||||
* @param model_data The model object to query.
|
||||
* @param mn_command_root The speech commands link.
|
||||
* @return The error phrase id info.
|
||||
*/
|
||||
typedef esp_mn_error_t* (*esp_wn_iface_op_set_speech_commands)(model_iface_data_t *model_data, esp_mn_node_t *mn_command_root);
|
||||
|
||||
typedef struct {
|
||||
esp_mn_iface_op_create_t create;
|
||||
esp_mn_iface_op_get_samp_rate_t get_samp_rate;
|
||||
esp_mn_iface_op_get_samp_chunksize_t get_samp_chunksize;
|
||||
esp_mn_iface_op_get_samp_chunknum_t get_samp_chunknum;
|
||||
esp_mn_iface_op_set_det_threshold_t set_det_threshold;
|
||||
esp_mn_iface_op_detect_t detect;
|
||||
esp_mn_iface_op_destroy_t destroy;
|
||||
esp_mn_iface_op_get_results_t get_results;
|
||||
esp_mn_iface_op_open_log_t open_log;
|
||||
esp_wn_iface_op_set_speech_commands set_speech_commands;
|
||||
} esp_mn_iface_t;
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
#pragma once
|
||||
#include "esp_mn_iface.h"
|
||||
|
||||
//Contains declarations of all available speech recognion models. Pair this up with the right coefficients and you have a model that can recognize
|
||||
//a specific phrase or word.
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the multinet handle from model name
|
||||
*
|
||||
* @param model_name The name of model
|
||||
* @returns The handle of multinet
|
||||
*/
|
||||
esp_mn_iface_t *esp_mn_handle_from_name(char *model_name);
|
||||
|
||||
/**
|
||||
* @brief Get the multinet language from model name
|
||||
*
|
||||
* @param model_name The name of model
|
||||
* @returns The language of multinet
|
||||
*/
|
||||
char *esp_mn_language_from_name(char *model_name);
|
||||
|
||||
/*
|
||||
Configure wake word to use based on what's selected in menuconfig.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_SR_MN_CN_MULTINET2_SINGLE_RECOGNITION
|
||||
#include "multinet2_ch.h"
|
||||
#define MULTINET_COEFF get_coeff_multinet2_ch
|
||||
#define MULTINET_MODEL_NAME "mn2_cn"
|
||||
|
||||
#else
|
||||
#define MULTINET_COEFF "COEFF_NULL"
|
||||
#define MULTINET_MODEL_NAME "NULL"
|
||||
#endif
|
||||
|
||||
|
||||
/* example
|
||||
|
||||
static const esp_mn_iface_t *multinet = &MULTINET_MODEL;
|
||||
|
||||
//Initialize MultiNet model data
|
||||
model_iface_data_t *model_data = multinet->create(&MULTINET_COEFF);
|
||||
add_speech_commands(multinet, model_data);
|
||||
|
||||
//Set parameters of buffer
|
||||
int audio_chunksize=model->get_samp_chunksize(model_data);
|
||||
int frequency = model->get_samp_rate(model_data);
|
||||
int16_t *buffer=malloc(audio_chunksize*sizeof(int16_t));
|
||||
|
||||
//Detect
|
||||
int r=model->detect(model_data, buffer);
|
||||
if (r>0) {
|
||||
printf("Detection triggered output %d.\n", r);
|
||||
}
|
||||
|
||||
//Destroy model
|
||||
model->destroy(model_data)
|
||||
|
||||
*/
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
// 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
|
||||
#ifndef _ESP_NS_H_
|
||||
#define _ESP_NS_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define NS_USE_SPIARM 0
|
||||
#define NS_FRAME_LENGTH_MS 10 //Supports 10ms, 20ms, 30ms
|
||||
|
||||
/**
|
||||
* The Sampling frequency (Hz) must be 16000Hz
|
||||
*/
|
||||
|
||||
typedef void* ns_handle_t;
|
||||
|
||||
/**
|
||||
* @brief Creates an instance to the NS structure.
|
||||
*
|
||||
* @param frame_length The length of the audio processing can be 10ms, 20ms, 30ms.
|
||||
*
|
||||
* @return
|
||||
* - NULL: Create failed
|
||||
* - Others: The instance of NS
|
||||
*/
|
||||
ns_handle_t ns_create(int frame_length);
|
||||
|
||||
/**
|
||||
* @brief Creates an instance of the more powerful noise suppression algorithm.
|
||||
*
|
||||
* @warning frame_length only supports be 10 ms.
|
||||
*
|
||||
* @param frame_length The length of the audio processing can only be 10ms.
|
||||
* @param mode 0: Mild, 1: Medium, 2: Aggressive
|
||||
* @param sample_rate The sample rate of the audio.
|
||||
*
|
||||
* @return
|
||||
* - NULL: Create failed
|
||||
* - Others: The instance of NS
|
||||
*/
|
||||
ns_handle_t ns_pro_create(int frame_length, int mode, int sample_rate);
|
||||
|
||||
/**
|
||||
* @brief Feed samples of an audio stream to the NS and get the audio stream after Noise suppression.
|
||||
*
|
||||
* @param inst The instance of NS.
|
||||
*
|
||||
* @param indata An array of 16-bit signed audio samples.
|
||||
*
|
||||
* @param outdata An array of 16-bit signed audio samples after noise suppression.
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void ns_process(ns_handle_t inst, int16_t *indata, int16_t *outdata);
|
||||
|
||||
/**
|
||||
* @brief Free the NS instance
|
||||
*
|
||||
* @param inst The instance of NS.
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void ns_destroy(ns_handle_t inst);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //_ESP_NS_H_
|
||||
|
|
@ -1,104 +0,0 @@
|
|||
// 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
|
||||
#ifndef _ESP_VAD_H_
|
||||
#define _ESP_VAD_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SAMPLE_RATE_HZ 16000 //Supports 32000, 16000, 8000
|
||||
#define VAD_FRAME_LENGTH_MS 30 //Supports 10ms, 20ms, 30ms
|
||||
|
||||
/**
|
||||
* @brief Sets the VAD operating mode. A more aggressive (higher mode) VAD is more
|
||||
* restrictive in reporting speech.
|
||||
*/
|
||||
typedef enum {
|
||||
VAD_MODE_0 = 0,
|
||||
VAD_MODE_1,
|
||||
VAD_MODE_2,
|
||||
VAD_MODE_3,
|
||||
VAD_MODE_4
|
||||
} vad_mode_t;
|
||||
|
||||
typedef enum {
|
||||
VAD_SILENCE = 0,
|
||||
VAD_SPEECH
|
||||
} vad_state_t;
|
||||
|
||||
typedef void* vad_handle_t;
|
||||
|
||||
/**
|
||||
* @brief Creates an instance to the VAD structure.
|
||||
*
|
||||
* @param vad_mode Sets the VAD operating mode.
|
||||
*
|
||||
* @return
|
||||
* - NULL: Create failed
|
||||
* - Others: The instance of VAD
|
||||
*/
|
||||
vad_handle_t vad_create(vad_mode_t vad_mode);
|
||||
|
||||
/**
|
||||
* @brief Feed samples of an audio stream to the VAD and check if there is someone speaking.
|
||||
*
|
||||
* @param inst The instance of VAD.
|
||||
*
|
||||
* @param data An array of 16-bit signed audio samples.
|
||||
*
|
||||
* @param sample_rate_hz The Sampling frequency (Hz) can be 32000, 16000, 8000, default: 16000.
|
||||
*
|
||||
* @param one_frame_ms The length of the audio processing can be 10ms, 20ms, 30ms, default: 30.
|
||||
*
|
||||
* @return
|
||||
* - VAD_SILENCE if no voice
|
||||
* - VAD_SPEECH if voice is detected
|
||||
*
|
||||
*/
|
||||
vad_state_t vad_process(vad_handle_t inst, int16_t *data, int sample_rate_hz, int one_frame_ms);
|
||||
|
||||
/**
|
||||
* @brief Free the VAD instance
|
||||
*
|
||||
* @param inst The instance of VAD.
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void vad_destroy(vad_handle_t inst);
|
||||
|
||||
/*
|
||||
* Programming Guide:
|
||||
*
|
||||
* @code{c}
|
||||
* vad_handle_t vad_inst = vad_create(VAD_MODE_3, SAMPLE_RATE_HZ, VAD_FRAME_LENGTH_MS); // Creates an instance to the VAD structure.
|
||||
*
|
||||
* while (1) {
|
||||
* //Use buffer to receive the audio data from MIC.
|
||||
* vad_state_t vad_state = vad_process(vad_inst, buffer); // Feed samples to the VAD process and get the result.
|
||||
* }
|
||||
*
|
||||
* vad_destroy(vad_inst); // Free the VAD instance at the end of whole VAD process
|
||||
*
|
||||
* @endcode
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //_ESP_VAD_H_
|
||||
|
|
@ -1,185 +0,0 @@
|
|||
#pragma once
|
||||
#include "stdint.h"
|
||||
|
||||
//Opaque model data container
|
||||
typedef struct model_iface_data_t model_iface_data_t;
|
||||
|
||||
/**
|
||||
* @brief The state of wakeup
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
WAKENET_NO_DETECT = 0, // wake word is not detected
|
||||
WAKENET_CHANNEL_VERIFIED = -1, // output channel is verified
|
||||
WAKENET_DETECTED = 1 // wake word is detected
|
||||
} wakenet_state_t;
|
||||
|
||||
//Set wake words recognition operating mode
|
||||
//The probability of being wake words is increased with increasing mode,
|
||||
//As a consequence also the false alarm rate goes up
|
||||
typedef enum {
|
||||
DET_MODE_90 = 0, // Normal
|
||||
DET_MODE_95 = 1, // Aggressive
|
||||
DET_MODE_2CH_90 = 2,
|
||||
DET_MODE_2CH_95 = 3,
|
||||
DET_MODE_3CH_90 = 4,
|
||||
DET_MODE_3CH_95 = 5,
|
||||
} det_mode_t;
|
||||
|
||||
typedef struct {
|
||||
int wake_word_num; //The number of all wake words
|
||||
char **wake_word_list; //The name list of wake words
|
||||
} wake_word_info_t;
|
||||
|
||||
/**
|
||||
* @brief Easy function type to initialze a model instance with a detection mode and specified wake word coefficient
|
||||
*
|
||||
* @param model_name The specified wake word model coefficient
|
||||
* @param det_mode The wake words detection mode to trigger wake words, DET_MODE_90 or DET_MODE_95
|
||||
* @returns Handle to the model data
|
||||
*/
|
||||
typedef model_iface_data_t* (*esp_wn_iface_op_create_t)(const void *model_name, det_mode_t det_mode);
|
||||
|
||||
/**
|
||||
* @brief Get the amount of samples that need to be passed to the detect function
|
||||
*
|
||||
* Every speech recognition model processes a certain number of samples at the same time. This function
|
||||
* can be used to query that amount. Note that the returned amount is in 16-bit samples, not in bytes.
|
||||
*
|
||||
* @param model The model object to query
|
||||
* @return The amount of samples to feed the detect function
|
||||
*/
|
||||
typedef int (*esp_wn_iface_op_get_samp_chunksize_t)(model_iface_data_t *model);
|
||||
|
||||
/**
|
||||
* @brief Get the channel number of samples that need to be passed to the detect function
|
||||
*
|
||||
* Every speech recognition model processes a certain number of samples at the same time. This function
|
||||
* can be used to query that amount. Note that the returned amount is in 16-bit samples, not in bytes.
|
||||
*
|
||||
* @param model The model object to query
|
||||
* @return The amount of samples to feed the detect function
|
||||
*/
|
||||
typedef int (*esp_wn_iface_op_get_channel_num_t)(model_iface_data_t *model);
|
||||
|
||||
/**
|
||||
* @brief Get the start point of wake word when one wake word is detected.
|
||||
*
|
||||
* @Warning: This function should be called when the channel index is verified.
|
||||
* The returned value is the number of samples from start point of wake word to detected point.
|
||||
*
|
||||
* @param model The model object to query
|
||||
* @return The number of samples from start point to detected point (end point)
|
||||
*/
|
||||
typedef int (*esp_wn_iface_op_get_start_point_t)(model_iface_data_t *model);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the sample rate of the samples to feed to the detect function
|
||||
*
|
||||
* @param model The model object to query
|
||||
* @return The sample rate, in hz
|
||||
*/
|
||||
typedef int (*esp_wn_iface_op_get_samp_rate_t)(model_iface_data_t *model);
|
||||
|
||||
/**
|
||||
* @brief Get the number of wake words
|
||||
*
|
||||
* @param model The model object to query
|
||||
* @returns the number of wake words
|
||||
*/
|
||||
typedef int (*esp_wn_iface_op_get_word_num_t)(model_iface_data_t *model);
|
||||
|
||||
/**
|
||||
* @brief Get the name of wake word by index
|
||||
*
|
||||
* @Warning The index of wake word start with 1
|
||||
|
||||
* @param model The model object to query
|
||||
* @param word_index The index of wake word
|
||||
* @returns the detection threshold
|
||||
*/
|
||||
typedef char* (*esp_wn_iface_op_get_word_name_t)(model_iface_data_t *model, int word_index);
|
||||
|
||||
/**
|
||||
* @brief Set the detection threshold to manually abjust the probability
|
||||
*
|
||||
* @param model The model object to query
|
||||
* @param det_treshold The threshold to trigger wake words, the range of det_threshold is 0.5~0.9999
|
||||
* @param word_index The index of wake word
|
||||
* @return 0: setting failed, 1: setting success
|
||||
*/
|
||||
typedef int (*esp_wn_iface_op_set_det_threshold_t)(model_iface_data_t *model, float det_threshold, int word_index);
|
||||
|
||||
/**
|
||||
* @brief Get the wake word detection threshold of different modes
|
||||
*
|
||||
* @param model The model object to query
|
||||
* @param word_index The index of wake word
|
||||
* @returns the detection threshold
|
||||
*/
|
||||
typedef float (*esp_wn_iface_op_get_det_threshold_t)(model_iface_data_t *model, int word_index);
|
||||
|
||||
/**
|
||||
* @brief Feed samples of an audio stream to the keyword detection model and detect if there is a keyword found.
|
||||
*
|
||||
* @Warning The index of wake word start with 1, 0 means no wake words is detected.
|
||||
*
|
||||
* @param model The model object to query
|
||||
* @param samples An array of 16-bit signed audio samples. The array size used can be queried by the
|
||||
* get_samp_chunksize function.
|
||||
* @return The index of wake words, return 0 if no wake word is detected, else the index of the wake words.
|
||||
*/
|
||||
typedef wakenet_state_t (*esp_wn_iface_op_detect_t)(model_iface_data_t *model, int16_t *samples);
|
||||
|
||||
/**
|
||||
* @brief Get the volume gain
|
||||
*
|
||||
* @param model The model object to query
|
||||
* @param target_db The target dB to calculate volume gain
|
||||
* @returns the volume gain
|
||||
*/
|
||||
typedef float (*esp_wn_iface_op_get_vol_gain_t)(model_iface_data_t *model, float target_db);
|
||||
|
||||
/**
|
||||
* @brief Get the triggered channel index. Channel index starts from zero
|
||||
*
|
||||
* @param model The model object to query
|
||||
* @return The channel index
|
||||
*/
|
||||
typedef int (*esp_wn_iface_op_get_triggered_channel_t)(model_iface_data_t *model);
|
||||
|
||||
/**
|
||||
* @brief Clean all states of model
|
||||
*
|
||||
* @param model The model object to query
|
||||
*/
|
||||
typedef void (*esp_wn_iface_op_clean_t)(model_iface_data_t *model);
|
||||
|
||||
/**
|
||||
* @brief Destroy a speech recognition model
|
||||
*
|
||||
* @param model Model object to destroy
|
||||
*/
|
||||
typedef void (*esp_wn_iface_op_destroy_t)(model_iface_data_t *model);
|
||||
|
||||
|
||||
/**
|
||||
* This structure contains the functions used to do operations on a wake word detection model.
|
||||
*/
|
||||
typedef struct {
|
||||
esp_wn_iface_op_create_t create;
|
||||
esp_wn_iface_op_get_start_point_t get_start_point;
|
||||
esp_wn_iface_op_get_samp_chunksize_t get_samp_chunksize;
|
||||
esp_wn_iface_op_get_channel_num_t get_channel_num;
|
||||
esp_wn_iface_op_get_samp_rate_t get_samp_rate;
|
||||
esp_wn_iface_op_get_word_num_t get_word_num;
|
||||
esp_wn_iface_op_get_word_name_t get_word_name;
|
||||
esp_wn_iface_op_set_det_threshold_t set_det_threshold;
|
||||
esp_wn_iface_op_get_det_threshold_t get_det_threshold;
|
||||
esp_wn_iface_op_get_triggered_channel_t get_triggered_channel;
|
||||
esp_wn_iface_op_get_vol_gain_t get_vol_gain;
|
||||
esp_wn_iface_op_detect_t detect;
|
||||
esp_wn_iface_op_clean_t clean;
|
||||
esp_wn_iface_op_destroy_t destroy;
|
||||
} esp_wn_iface_t;
|
||||
|
|
@ -1,122 +0,0 @@
|
|||
#pragma once
|
||||
#include "esp_wn_iface.h"
|
||||
|
||||
|
||||
// The prefix of wakenet model name is used to filter all wakenet from availabel models.
|
||||
#define ESP_WN_PREFIX "wn"
|
||||
|
||||
/**
|
||||
* @brief Get the wakenet handle from model name
|
||||
*
|
||||
* @param model_name The name of model
|
||||
* @returns The handle of wakenet
|
||||
*/
|
||||
const esp_wn_iface_t *esp_wn_handle_from_name(const char *model_name);
|
||||
|
||||
/**
|
||||
* @brief Get the wake word name from model name
|
||||
*
|
||||
* @param model_name The name of model
|
||||
* @returns The wake word name, like "alexa","hilexin","xiaoaitongxue"
|
||||
*/
|
||||
char* esp_wn_wakeword_from_name(const char *model_name);
|
||||
|
||||
// /**
|
||||
// * @brief Get the model coeff from model name
|
||||
// *
|
||||
// * @Warning: retuen model_coeff_getter_t, when chip is ESP32,
|
||||
// * return string for other chips
|
||||
// *
|
||||
// * @param model_name The name of model
|
||||
// * @returns The handle of wakenet
|
||||
// */
|
||||
// void *esp_wn_coeff_from_name(char *model_name);
|
||||
|
||||
|
||||
#if defined CONFIG_USE_WAKENET
|
||||
/*
|
||||
Configure wake word to use based on what's selected in menuconfig.
|
||||
*/
|
||||
#if CONFIG_SR_WN_WN5_HILEXIN
|
||||
#include "hilexin_wn5.h"
|
||||
#define WAKENET_MODEL_NAME "wn5_hilexin"
|
||||
#define WAKENET_COEFF get_coeff_hilexin_wn5
|
||||
|
||||
#elif CONFIG_SR_WN_WN5X2_HILEXIN
|
||||
#include "hilexin_wn5X2.h"
|
||||
#define WAKENET_MODEL_NAME "wn5_hilexinX2"
|
||||
#define WAKENET_COEFF get_coeff_hilexin_wn5X2
|
||||
|
||||
|
||||
#elif CONFIG_SR_WN_WN5X3_HILEXIN
|
||||
#include "hilexin_wn5X3.h"
|
||||
#define WAKENET_MODEL_NAME "wn5_hilexinX3"
|
||||
#define WAKENET_COEFF get_coeff_hilexin_wn5X3
|
||||
|
||||
|
||||
#elif CONFIG_SR_WN_WN5_NIHAOXIAOZHI
|
||||
#include "nihaoxiaozhi_wn5.h"
|
||||
#define WAKENET_MODEL_NAME "wn5_nihaoxiaozhi"
|
||||
#define WAKENET_COEFF get_coeff_nihaoxiaozhi_wn5
|
||||
|
||||
|
||||
#elif CONFIG_SR_WN_WN5X2_NIHAOXIAOZHI
|
||||
#include "nihaoxiaozhi_wn5X2.h"
|
||||
#define WAKENET_MODEL_NAME "wn5_nihaoxiaozhiX2"
|
||||
#define WAKENET_COEFF get_coeff_nihaoxiaozhi_wn5X2
|
||||
|
||||
|
||||
#elif CONFIG_SR_WN_WN5X3_NIHAOXIAOZHI
|
||||
#include "nihaoxiaozhi_wn5X3.h"
|
||||
#define WAKENET_MODEL_NAME "wn5_nihaoxiaozhiX3"
|
||||
#define WAKENET_COEFF get_coeff_nihaoxiaozhi_wn5X3
|
||||
|
||||
|
||||
#elif CONFIG_SR_WN_WN5X3_NIHAOXIAOXIN
|
||||
#include "nihaoxiaoxin_wn5X3.h"
|
||||
#define WAKENET_MODEL_NAME "wn5_nihaoxiaoxinX3"
|
||||
#define WAKENET_COEFF get_coeff_nihaoxiaoxin_wn5X3
|
||||
|
||||
|
||||
#elif CONFIG_SR_WN_WN5X3_HIJESON
|
||||
#include "hijeson_wn5X3.h"
|
||||
#define WAKENET_MODEL_NAME "wn5_hijesonX3"
|
||||
#define WAKENET_COEFF get_coeff_hijeson_wn5X3
|
||||
|
||||
#elif CONFIG_SR_WN_WN5_CUSTOMIZED_WORD
|
||||
#include "customized_word_wn5.h"
|
||||
#define WAKENET_MODEL_NAME "wn5_customizedword"
|
||||
#define WAKENET_COEFF get_coeff_customizedword_wn5
|
||||
|
||||
#else
|
||||
#define WAKENET_MODEL_NAME "NULL"
|
||||
#define WAKENET_COEFF "COEFF_NULL"
|
||||
#endif
|
||||
|
||||
#else
|
||||
#define WAKENET_MODEL_NAME "NULL"
|
||||
#define WAKENET_COEFF "COEFF_NULL"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
static const sr_model_iface_t *model = esp_wn_handle_from_name(model_name);
|
||||
|
||||
//Initialize wakeNet model data
|
||||
static model_iface_data_t *model_data=model->create(model_name, DET_MODE_90);
|
||||
|
||||
//Set parameters of buffer
|
||||
int audio_chunksize=model->get_samp_chunksize(model_data);
|
||||
int frequency = model->get_samp_rate(model_data);
|
||||
int16_t *buffer=malloc(audio_chunksize*sizeof(int16_t));
|
||||
|
||||
//Detect
|
||||
int r=model->detect(model_data, buffer);
|
||||
if (r>0) {
|
||||
printf("Detection triggered output %d.\n", r);
|
||||
}
|
||||
|
||||
//Destroy model
|
||||
model->destroy(model_data)
|
||||
|
||||
*/
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
//Generated by mkmodel_py
|
||||
#pragma once
|
||||
#include <string.h>
|
||||
#include "dl_lib_coefgetter_if.h"
|
||||
#include "dl_lib_matrix.h"
|
||||
#include "dl_lib_matrixq.h"
|
||||
#include "dl_lib_matrixq8.h"
|
||||
|
||||
extern const model_coeff_getter_t get_coeff_hilexin_wn5;
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
//Generated by mkmodel_py
|
||||
#pragma once
|
||||
#include <string.h>
|
||||
#include "dl_lib_coefgetter_if.h"
|
||||
#include "dl_lib_matrix.h"
|
||||
#include "dl_lib_matrixq.h"
|
||||
#include "dl_lib_matrixq8.h"
|
||||
|
||||
extern const model_coeff_getter_t get_coeff_hilexin_wn5X2;
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
//Generated by mkmodel_py
|
||||
#pragma once
|
||||
#include <string.h>
|
||||
#include "dl_lib_coefgetter_if.h"
|
||||
#include "dl_lib_matrix.h"
|
||||
#include "dl_lib_matrixq.h"
|
||||
#include "dl_lib_matrixq8.h"
|
||||
|
||||
extern const model_coeff_getter_t get_coeff_hilexin_wn5X3;
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
//Generated by mkmodel_py
|
||||
#pragma once
|
||||
#include <string.h>
|
||||
#include "dl_lib_coefgetter_if.h"
|
||||
#include "dl_lib_matrix.h"
|
||||
#include "dl_lib_matrixq.h"
|
||||
#include "dl_lib_matrixq8.h"
|
||||
|
||||
extern const model_coeff_getter_t get_coeff_multinet2_ch;
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
//Generated by mkmodel_py
|
||||
#pragma once
|
||||
#include <string.h>
|
||||
#include "dl_lib_coefgetter_if.h"
|
||||
#include "dl_lib_matrix.h"
|
||||
#include "dl_lib_matrixq.h"
|
||||
#include "dl_lib_matrixq8.h"
|
||||
|
||||
extern const model_coeff_getter_t get_coeff_nihaoxiaoxin_wn5X3;
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
//Generated by mkmodel_py
|
||||
#pragma once
|
||||
#include <string.h>
|
||||
#include "dl_lib_coefgetter_if.h"
|
||||
#include "dl_lib_matrix.h"
|
||||
#include "dl_lib_matrixq.h"
|
||||
#include "dl_lib_matrixq8.h"
|
||||
|
||||
extern const model_coeff_getter_t get_coeff_nihaoxiaozhi_wn5;
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
//Generated by mkmodel_py
|
||||
#pragma once
|
||||
#include <string.h>
|
||||
#include "dl_lib_coefgetter_if.h"
|
||||
#include "dl_lib_matrix.h"
|
||||
#include "dl_lib_matrixq.h"
|
||||
#include "dl_lib_matrixq8.h"
|
||||
|
||||
extern const model_coeff_getter_t get_coeff_nihaoxiaozhi_wn5X2;
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
//Generated by mkmodel_py
|
||||
#pragma once
|
||||
#include <string.h>
|
||||
#include "dl_lib_coefgetter_if.h"
|
||||
#include "dl_lib_matrix.h"
|
||||
#include "dl_lib_matrixq.h"
|
||||
#include "dl_lib_matrixq8.h"
|
||||
|
||||
extern const model_coeff_getter_t get_coeff_nihaoxiaozhi_wn5X3;
|
||||
|
|
@ -1,158 +0,0 @@
|
|||
// Copyright 2015-2022 Espressif Systems (Shanghai) 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 "esp_err.h"
|
||||
#include "esp_mn_iface.h"
|
||||
|
||||
/*
|
||||
esp_mn_node_t is a singly linked list which is used to manage speech commands.
|
||||
It is easy to add one speech command into linked list and remove one speech command from linked list.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initialze the speech commands singly linked list.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_NO_MEM No memory
|
||||
* - ESP_ERR_INVALID_STATE The Speech Commands link has been initialized
|
||||
*/
|
||||
esp_err_t esp_mn_commands_alloc(void);
|
||||
|
||||
/**
|
||||
* @brief Clear the speech commands linked list and free root node.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_STATE The Speech Commands link has not been initialized
|
||||
*/
|
||||
esp_err_t esp_mn_commands_free(void);
|
||||
|
||||
/**
|
||||
* @brief Add one speech commands with phoneme string and command ID
|
||||
*
|
||||
* @param command_id The command ID
|
||||
* @param phoneme_string The phoneme string of the speech commands
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_STATE Fail
|
||||
*/
|
||||
esp_err_t esp_mn_commands_add(int command_id, char *phoneme_string);
|
||||
|
||||
/**
|
||||
* @brief Modify one speech commands with new phoneme string
|
||||
*
|
||||
* @param old_phoneme_string The old phoneme string of the speech commands
|
||||
* @param new_phoneme_string The new phoneme string of the speech commands
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_STATE Fail
|
||||
*/
|
||||
esp_err_t esp_mn_commands_modify(char *old_phoneme_string, char *new_phoneme_string);
|
||||
|
||||
/**
|
||||
* @brief Remove one speech commands by phoneme string
|
||||
*
|
||||
* @param phoneme_string The phoneme string of the speech commands
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_STATE Fail
|
||||
*/
|
||||
esp_err_t esp_mn_commands_remove(char *phoneme_string);
|
||||
|
||||
/**
|
||||
* @brief Clear all speech commands in linked list
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_STATE Fail
|
||||
*/
|
||||
esp_err_t esp_mn_commands_clear(void);
|
||||
|
||||
/**
|
||||
* @brief Get phrase from index, which is the depth from the phrase node to root node
|
||||
*
|
||||
* @Warning: The first phrase index is 0, the second phrase index is 1, and so on.
|
||||
*
|
||||
* @return
|
||||
* - esp_mn_phrase_t* Success
|
||||
* - NULL Fail
|
||||
*/
|
||||
esp_mn_phrase_t *esp_mn_commands_get_from_index(int index);
|
||||
|
||||
/**
|
||||
* @brief Get phrase from phoneme string
|
||||
*
|
||||
* @return
|
||||
* - esp_mn_phrase_t* Success
|
||||
* - NULL Fail
|
||||
*/
|
||||
esp_mn_phrase_t *esp_mn_commands_get_from_string(const char *phoneme_string);
|
||||
|
||||
/**
|
||||
* @brief Update the speech commands of MultiNet
|
||||
*
|
||||
* @Warning: Must be used after [add/remove/modify/clear] function,
|
||||
* otherwise the language model of multinet can not be updated.
|
||||
*
|
||||
* @param multinet The multinet handle
|
||||
* @param model_data The model object to query
|
||||
*
|
||||
* @return
|
||||
* - NULL Success
|
||||
* - others The list of error phrase which can not be parsed by multinet.
|
||||
*/
|
||||
esp_mn_error_t *esp_mn_commands_update(const esp_mn_iface_t *multinet, model_iface_data_t *model_data);
|
||||
|
||||
/**
|
||||
* @brief Print the MultiNet Speech Commands.
|
||||
*/
|
||||
void esp_mn_print_commands(void);
|
||||
|
||||
/**
|
||||
* @brief Initialze the esp_mn_phrase_t struct by command id and phoneme string .
|
||||
*
|
||||
* @return the pointer of esp_mn_phrase_t
|
||||
*/
|
||||
esp_mn_phrase_t *esp_mn_phrase_alloc(int command_id, char *phoneme_string);
|
||||
|
||||
/**
|
||||
* @brief Free esp_mn_phrase_t pointer.
|
||||
*
|
||||
* @param phrase The esp_mn_phrase_t pointer
|
||||
*/
|
||||
void esp_mn_phrase_free(esp_mn_phrase_t *phrase);
|
||||
|
||||
/**
|
||||
* @brief Initialze the esp_mn_node_t struct by esp_mn_phrase_t pointer.
|
||||
*
|
||||
* @return the pointer of esp_mn_node_t
|
||||
*/
|
||||
esp_mn_node_t *esp_mn_node_alloc(esp_mn_phrase_t *phrase);
|
||||
|
||||
/**
|
||||
* @brief Free esp_mn_node_t pointer.
|
||||
*
|
||||
* @param node The esp_mn_node_free pointer
|
||||
*/
|
||||
void esp_mn_node_free(esp_mn_node_t *node);
|
||||
|
||||
/**
|
||||
* @brief Print phrase linked list.
|
||||
*/
|
||||
void esp_mn_commands_print(void);
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
#pragma once
|
||||
#include "esp_err.h"
|
||||
#include "esp_mn_iface.h"
|
||||
|
||||
/**
|
||||
* @brief Check chip config to ensure optimum performance
|
||||
*/
|
||||
void check_chip_config(void);
|
||||
|
||||
/**
|
||||
* @brief Update the speech commands of MultiNet by menuconfig
|
||||
*
|
||||
* @param multinet The multinet handle
|
||||
*
|
||||
* @param model_data The model object to query
|
||||
*
|
||||
* @param langugae The language of MultiNet
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_STATE Fail
|
||||
*/
|
||||
esp_mn_error_t* esp_mn_commands_update_from_sdkconfig(const esp_mn_iface_t *multinet, model_iface_data_t *model_data);
|
||||
|
|
@ -1,94 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char **model_name; // the name of models, like "wn9_hilexin"(wakenet9, hilexin), "mn5_en"(multinet5, english)
|
||||
char *partition_label; // partition label used to save the files of model
|
||||
int num; // the number of models
|
||||
} srmodel_list_t;
|
||||
|
||||
#define MODEL_NAME_MAX_LENGTH 64
|
||||
|
||||
/**
|
||||
* @brief Return all avaliable models in spiffs or selected in Kconfig.
|
||||
*
|
||||
* @param partition_label The spiffs label defined in your partition file used to save models.
|
||||
*
|
||||
* @return all avaliable models in spiffs,save as srmodel_list_t.
|
||||
*/
|
||||
srmodel_list_t* esp_srmodel_init(const char* partition_label);
|
||||
|
||||
/**
|
||||
* @brief Free srmodel_list_t and unregister SPIFFS filesystem if open SPIFFS filesystem.
|
||||
*
|
||||
* @param models The srmodel_list_t point allocated by esp_srmodel_init function.
|
||||
*
|
||||
* @return all avaliable models in spiffs,save as srmodel_list_t.
|
||||
*/
|
||||
void esp_srmodel_deinit(srmodel_list_t *models);
|
||||
|
||||
/**
|
||||
* @brief Return the first model name containing the specified keywords
|
||||
* If keyword is NULL, we will ignore the keyword.
|
||||
*
|
||||
* @param models The srmodel_list_t point allocated by esp_srmodel_init function.
|
||||
* @param keyword1 The specified keyword1 , like ESP_WN_PREDIX(the prefix of wakenet),
|
||||
* ESP_MN_PREFIX(the prefix of multinet),
|
||||
*
|
||||
* @param keyword2 The specified keyword2, like ESP_MN_ENGLISH(the english multinet)
|
||||
* ESP_MN_CHINESE(the chinese multinet)
|
||||
* "alexa" (the "alexa" wakenet)
|
||||
* @return return model name if can find one model name containing the keywords otherwise return NULL.
|
||||
*/
|
||||
char *esp_srmodel_filter(srmodel_list_t *models, const char *keyword1, const char *keyword2);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Check whether the specified model name exists or not.
|
||||
*
|
||||
* @param models The srmodel_list_t point allocated by esp_srmodel_init function.
|
||||
* @param model_name The specified model name
|
||||
* @return return index in models if model name exists otherwise return -1
|
||||
*/
|
||||
int esp_srmodel_exists(srmodel_list_t *models, char *model_name);
|
||||
|
||||
/**
|
||||
* @brief Initialize and mount SPIFFS filesystem, return all avaliable models in spiffs.
|
||||
*
|
||||
* @param partition_label The spiffs label defined in your partition file used to save models.
|
||||
*
|
||||
* @return all avaliable models in spiffs,save as srmodel_list_t.
|
||||
*/
|
||||
srmodel_list_t *srmodel_spiffs_init(const char* partition_label);
|
||||
|
||||
/**
|
||||
* @brief unregister SPIFFS filesystem and free srmodel_list_t.
|
||||
*
|
||||
* @param models The srmodel_list_t point allocated by srmodel_spiffs_init function.
|
||||
*
|
||||
* @return all avaliable models in spiffs,save as srmodel_list_t.
|
||||
*/
|
||||
void srmodel_spiffs_deinit(srmodel_list_t *models);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Return base path of srmodel spiffs
|
||||
*
|
||||
* @return the base path od srmodel spiffs
|
||||
*/
|
||||
char *get_model_base_path(void);
|
||||
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
#include "dl_lib_coefgetter_if.h"
|
||||
/**
|
||||
* @brief Return model_coeff_getter_t pointer base on model_name
|
||||
*
|
||||
* @warning Just support ESP32 to load old wakenet
|
||||
*
|
||||
* @param model_name The model name
|
||||
*
|
||||
* @return model_coeff_getter_t pointer or NULL
|
||||
*/
|
||||
model_coeff_getter_t* srmodel_get_model_coeff(char *model_name);
|
||||
#endif
|
||||
|
|
@ -72,6 +72,12 @@
|
|||
#include "sys/time.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
/**
|
||||
* @brief define for if chip supports camera
|
||||
*/
|
||||
#define ESP_CAMERA_SUPPORTED (CONFIG_IDF_TARGET_ESP32 | CONFIG_IDF_TARGET_ESP32S3 | \
|
||||
CONFIG_IDF_TARGET_ESP32S2)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
@ -85,7 +91,7 @@ typedef enum {
|
|||
} camera_grab_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Camera frame buffer location
|
||||
* @brief Camera frame buffer location
|
||||
*/
|
||||
typedef enum {
|
||||
CAMERA_FB_IN_PSRAM, /*!< Frame buffer is placed in external PSRAM */
|
||||
|
|
@ -99,7 +105,7 @@ typedef enum {
|
|||
typedef enum {
|
||||
CONV_DISABLE,
|
||||
RGB565_TO_YUV422,
|
||||
|
||||
|
||||
YUV422_TO_RGB565,
|
||||
YUV422_TO_YUV420
|
||||
} camera_conv_mode_t;
|
||||
|
|
@ -194,14 +200,14 @@ esp_err_t esp_camera_init(const camera_config_t* config);
|
|||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_STATE if the driver hasn't been initialized yet
|
||||
*/
|
||||
esp_err_t esp_camera_deinit();
|
||||
esp_err_t esp_camera_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief Obtain pointer to a frame buffer.
|
||||
*
|
||||
* @return pointer to the frame buffer
|
||||
*/
|
||||
camera_fb_t* esp_camera_fb_get();
|
||||
camera_fb_t* esp_camera_fb_get(void);
|
||||
|
||||
/**
|
||||
* @brief Return the frame buffer to be reused again.
|
||||
|
|
@ -215,22 +221,28 @@ void esp_camera_fb_return(camera_fb_t * fb);
|
|||
*
|
||||
* @return pointer to the sensor
|
||||
*/
|
||||
sensor_t * esp_camera_sensor_get();
|
||||
sensor_t * esp_camera_sensor_get(void);
|
||||
|
||||
/**
|
||||
* @brief Save camera settings to non-volatile-storage (NVS)
|
||||
*
|
||||
* @param key A unique nvs key name for the camera settings
|
||||
*
|
||||
* @param key A unique nvs key name for the camera settings
|
||||
*/
|
||||
esp_err_t esp_camera_save_to_nvs(const char *key);
|
||||
|
||||
/**
|
||||
* @brief Load camera settings from non-volatile-storage (NVS)
|
||||
*
|
||||
* @param key A unique nvs key name for the camera settings
|
||||
*
|
||||
* @param key A unique nvs key name for the camera settings
|
||||
*/
|
||||
esp_err_t esp_camera_load_from_nvs(const char *key);
|
||||
|
||||
/**
|
||||
* @brief Return all frame buffers to be reused again.
|
||||
*/
|
||||
void esp_camera_return_all(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -130,8 +130,8 @@ FORCE_INLINE_ATTR constexpr TYPE operator<< (TYPE a, int b) { return (TYPE)((INT
|
|||
FORCE_INLINE_ATTR TYPE& operator|=(TYPE& a, TYPE b) { a = a | b; return a; } \
|
||||
FORCE_INLINE_ATTR TYPE& operator&=(TYPE& a, TYPE b) { a = a & b; return a; } \
|
||||
FORCE_INLINE_ATTR TYPE& operator^=(TYPE& a, TYPE b) { a = a ^ b; return a; } \
|
||||
FORCE_INLINE_ATTR TYPE& operator>>=(TYPE& a, int b) { a >>= b; return a; } \
|
||||
FORCE_INLINE_ATTR TYPE& operator<<=(TYPE& a, int b) { a <<= b; return a; }
|
||||
FORCE_INLINE_ATTR TYPE& operator>>=(TYPE& a, int b) { a = a >> b; return a; } \
|
||||
FORCE_INLINE_ATTR TYPE& operator<<=(TYPE& a, int b) { a = a << b; return a; }
|
||||
|
||||
#define FLAG_ATTR_U32(TYPE) FLAG_ATTR_IMPL(TYPE, uint32_t)
|
||||
#define FLAG_ATTR FLAG_ATTR_U32
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ extern "C" {
|
|||
/** Minor version number (x.X.x) */
|
||||
#define ESP_IDF_VERSION_MINOR 4
|
||||
/** Patch version number (x.x.X) */
|
||||
#define ESP_IDF_VERSION_PATCH 4
|
||||
#define ESP_IDF_VERSION_PATCH 5
|
||||
|
||||
/**
|
||||
* Macro to convert IDF version number into an integer
|
||||
|
|
|
|||
|
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <esp_err.h>
|
||||
#include <esp_event.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Data store event base
|
||||
*/
|
||||
ESP_EVENT_DECLARE_BASE(ESP_DIAG_DATA_STORE_EVENT);
|
||||
|
||||
/**
|
||||
* @brief Data store events
|
||||
*
|
||||
* Diagnostics data store emits following events using default event loop,
|
||||
* every event has event data of type \ref esp_diag_data_store_event_data_t
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_DIAG_DATA_STORE_EVENT_CRITICAL_DATA_WRITE_FAIL,
|
||||
ESP_DIAG_DATA_STORE_EVENT_NON_CRITICAL_DATA_WRITE_FAIL,
|
||||
ESP_DIAG_DATA_STORE_EVENT_CRITICAL_DATA_LOW_MEM,
|
||||
ESP_DIAG_DATA_STORE_EVENT_NON_CRITICAL_DATA_LOW_MEM,
|
||||
} esp_diag_data_store_events_t;
|
||||
|
||||
/**
|
||||
* @brief Write critical data to the diagnostics data store
|
||||
*
|
||||
* @param[in] data Buffer holding the data
|
||||
* @param[in] len length of the data to be written
|
||||
*
|
||||
* @return ESP_OK on success, appropriate error code otherwise.
|
||||
*/
|
||||
esp_err_t esp_diag_data_store_critical_write(void *data, size_t len);
|
||||
|
||||
/**
|
||||
* @brief Write non_critical data to the diagnostics data store
|
||||
*
|
||||
* @param[in] dg Data group of the data
|
||||
* @param[in] data Buffer holding the data
|
||||
* @param[in] len length of the data to be written
|
||||
*
|
||||
* @return ESP_OK on success, appropriate error code otherwise.
|
||||
*/
|
||||
esp_err_t esp_diag_data_store_non_critical_write(const char *dg, void *data, size_t len);
|
||||
|
||||
/**
|
||||
* @brief Read critical data from the diagnostics data store
|
||||
*
|
||||
* @param[in] buf buffer to hold the data
|
||||
* @param[out] size Number of bytes read
|
||||
*
|
||||
* @return int bytes > 0 on success. Appropriate error otherwise
|
||||
*/
|
||||
int esp_diag_data_store_critical_read(uint8_t *buf, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Read non_critical data from the diagnostics data store
|
||||
*
|
||||
* @param[in] buf buffer to hold the data
|
||||
* @param[out] size Number of bytes read
|
||||
*
|
||||
* @return int bytes > 0 on success. Appropriate error otherwise
|
||||
*/
|
||||
int esp_diag_data_store_non_critical_read(uint8_t *buf, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Release the size bytes of critical data from diagnostics data store
|
||||
*
|
||||
* This API can be used to remove data from buffer when data is sent asynchronously.
|
||||
*
|
||||
* @param[in] size Number of bytes to free.
|
||||
*
|
||||
* @return ESP_OK on success, appropriate error code otherwise.
|
||||
*/
|
||||
esp_err_t esp_diag_data_store_critical_release(size_t size);
|
||||
|
||||
/**
|
||||
* @brief Release the size bytes of non_critical data from diagnostics data store
|
||||
*
|
||||
* This API can be used to remove data from buffer when data is sent asynchronously.
|
||||
*
|
||||
* @param[in] size Number of bytes to free.
|
||||
*
|
||||
* @return ESP_OK on success, appropriate error code otherwise.
|
||||
*/
|
||||
esp_err_t esp_diag_data_store_non_critical_release(size_t size);
|
||||
|
||||
/**
|
||||
* @brief Initializes the diagnostics data store
|
||||
*
|
||||
* @return ESP_OK on success, appropriate error code otherwise
|
||||
*/
|
||||
esp_err_t esp_diag_data_store_init(void);
|
||||
|
||||
/**
|
||||
* @brief Deinitializes the diagnostics data store
|
||||
*/
|
||||
void esp_diag_data_store_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief Get CRC of diagnostics data store configuration
|
||||
*
|
||||
* @return crc
|
||||
*/
|
||||
uint32_t esp_diag_data_store_get_crc(void);
|
||||
|
||||
/**
|
||||
* @brief Discard values from diagnostics data store. This API should be called after esp_diag_data_store_init();
|
||||
*
|
||||
* @return ESP_OK on success, appropriate error on failure.
|
||||
*/
|
||||
esp_err_t esp_diag_data_discard_data(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,174 @@
|
|||
// 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 <esp_err.h>
|
||||
#include <esp_event.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SHA_SIZE (CONFIG_APP_RETRIEVE_LEN_ELF_SHA / 2)
|
||||
|
||||
/**
|
||||
* @brief header record to identify firmware/boot data a record represent
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t gen_id; // generated on each hard reset
|
||||
uint8_t boot_cnt; // updated on each soft reboot
|
||||
char sha_sum[SHA_SIZE]; // elf shasum
|
||||
bool valid; //
|
||||
} rtc_store_meta_header_t;
|
||||
|
||||
/**
|
||||
* @brief get meta header for idx
|
||||
*
|
||||
* @param idx idx of meta from records
|
||||
* @return rtc_store_meta_header_t*
|
||||
*/
|
||||
rtc_store_meta_header_t *rtc_store_get_meta_record_by_index(uint8_t idx);
|
||||
|
||||
/**
|
||||
* @brief get current meta header
|
||||
*
|
||||
* @return rtc_store_meta_header_t*
|
||||
*/
|
||||
rtc_store_meta_header_t *rtc_store_get_meta_record_current();
|
||||
|
||||
/**
|
||||
* @brief Non critical data header
|
||||
*/
|
||||
typedef struct {
|
||||
const char *dg; /*!< Data group of non critical data eg: heap, wifi, ip */
|
||||
uint32_t len; /*!< Length of data */
|
||||
} rtc_store_non_critical_data_hdr_t;
|
||||
|
||||
/**
|
||||
* @brief Write critical data to the RTC storage
|
||||
*
|
||||
* @param[in] data Pointer to the data
|
||||
* @param[in] len Length of data
|
||||
*
|
||||
* @return ESP_OK on success, appropriate error code otherwise.
|
||||
*/
|
||||
esp_err_t rtc_store_critical_data_write(void *data, size_t len);
|
||||
|
||||
/**
|
||||
* @brief Read critical data from the RTC storage
|
||||
*
|
||||
* @param[in] buf Buffer to read data in
|
||||
* @param[in] size Number of bytes to read
|
||||
*
|
||||
* @return Number of bytes read or -1 on error
|
||||
*/
|
||||
int rtc_store_critical_data_read(uint8_t *buf, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Release the size bytes critical data from RTC storage
|
||||
*
|
||||
* This API can be used to remove data from buffer when data is sent asynchronously.
|
||||
*
|
||||
* @param[in] size Number of bytes to free.
|
||||
*
|
||||
* @return ESP_OK on success, appropriate error code otherwise.
|
||||
*/
|
||||
esp_err_t rtc_store_critical_data_release(size_t size);
|
||||
|
||||
/**
|
||||
* @brief Read critical data from the RTC storage and release that data
|
||||
*
|
||||
* @param[in] buf Buffer to read data in
|
||||
* @param[in] size Number of bytes to read
|
||||
*
|
||||
* @return Number of bytes read or -1 on error
|
||||
*/
|
||||
int rtc_store_critical_data_read_and_release(uint8_t *buf, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Write non critical data to the RTC storage
|
||||
*
|
||||
* This API overwrites the data if non critical storage is full
|
||||
*
|
||||
* @param[in] dg Data group of data eg: heap, wifi, ip(Must be the string stored in RODATA)
|
||||
* @param[in] data Pointer to non critical data
|
||||
* @param[in] len Length of non critical data
|
||||
*
|
||||
* @return ESP_OK on success, appropriate error code otherwise.
|
||||
*
|
||||
* @note Data is stored in Type-Length-Value format
|
||||
* Type(Data group) - 4 byte - Pointer to the string in rodata
|
||||
* Length - 4 byte - Length of data
|
||||
* Value - Length byte - Data
|
||||
*/
|
||||
esp_err_t rtc_store_non_critical_data_write(const char *dg, void *data, size_t len);
|
||||
|
||||
/**
|
||||
* @brief Read non critical data from the RTC storage
|
||||
*
|
||||
* @param[in] buf Buffer to read data in
|
||||
* @param[in] size Number of bytes read
|
||||
*
|
||||
* @return Number of bytes read or -1 on error
|
||||
*/
|
||||
int rtc_store_non_critical_data_read(uint8_t *buf, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Release the size bytes non critical data from RTC storage
|
||||
*
|
||||
* @param[in] size Number of bytes to free.
|
||||
*
|
||||
* @return ESP_OK on success, appropriate error code otherwise.
|
||||
*/
|
||||
esp_err_t rtc_store_non_critical_data_release(size_t size);
|
||||
|
||||
/**
|
||||
* @brief Read non_critical data from the RTC storage and release that data
|
||||
*
|
||||
* @param[in] buf Buffer to read data in
|
||||
* @param[in] size Number of bytes read
|
||||
*
|
||||
* @return Number of bytes read or -1 on error
|
||||
*/
|
||||
int rtc_store_non_critical_data_read_and_release(uint8_t *buf, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Initializes the RTC storage
|
||||
*
|
||||
* @return ESP_OK on success, appropriate error code otherwise
|
||||
*/
|
||||
esp_err_t rtc_store_init(void);
|
||||
|
||||
/**
|
||||
* @brief Deinitializes the RTC storage
|
||||
*/
|
||||
void rtc_store_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief Get CRC of RTC Store configuration
|
||||
*
|
||||
* @return crc
|
||||
*/
|
||||
uint32_t rtc_store_get_crc(void);
|
||||
|
||||
/**
|
||||
* @brief Discard values from RTC Store. This API should be called after rtc_store_init();
|
||||
*
|
||||
* @return ESP_OK on success, appropriate error on failure.
|
||||
*/
|
||||
esp_err_t rtc_store_discard_data(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
@ -291,6 +291,13 @@ void esp_diag_task_snapshot_dump(void);
|
|||
*/
|
||||
uint32_t esp_diag_meta_crc_get(void);
|
||||
|
||||
/**
|
||||
* @brief Get CRC of diagnostics data structures' size
|
||||
*
|
||||
* @return crc
|
||||
*/
|
||||
uint32_t esp_diag_data_size_get_crc(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -15,10 +15,10 @@ extern "C" {
|
|||
/**
|
||||
* @file sleep_gpio.h
|
||||
*
|
||||
* This file contains declarations of GPIO related functions in light sleep mode.
|
||||
* This file contains declarations of GPIO related functions in sleep modes.
|
||||
*/
|
||||
|
||||
#if SOC_GPIO_SUPPORT_SLP_SWITCH && CONFIG_GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL
|
||||
#if CONFIG_GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL
|
||||
|
||||
/**
|
||||
* @brief Save GPIO pull-up and pull-down configuration information in the wake-up state
|
||||
|
|
@ -39,7 +39,12 @@ void gpio_sleep_mode_config_apply(void);
|
|||
*/
|
||||
void gpio_sleep_mode_config_unapply(void);
|
||||
|
||||
#endif // SOC_GPIO_SUPPORT_SLP_SWITCH && CONFIG_GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL
|
||||
#endif // CONFIG_GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL
|
||||
|
||||
/**
|
||||
* @brief Call once in startup to disable the wakeup IO pins and release their holding state after waking up from Deep-sleep
|
||||
*/
|
||||
void esp_deep_sleep_wakeup_io_reset(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -234,25 +234,25 @@ esp_err_t esp_sleep_enable_ext1_wakeup(uint64_t mask, esp_sleep_ext1_wakeup_mode
|
|||
* This function enables an IO pin to wake the chip from deep sleep
|
||||
*
|
||||
* @note This function does not modify pin configuration. The pins are
|
||||
* configured in esp_sleep_start, immediately before
|
||||
* entering sleep mode.
|
||||
* configured inside esp_deep_sleep_start, immediately before entering sleep mode.
|
||||
*
|
||||
* @note You don't need to care to pull-up or pull-down before using this
|
||||
* function, because this will be done in esp_sleep_start based on
|
||||
* param mask you give. BTW, when you use low level to wake up the
|
||||
* chip, we strongly recommand you to add external registors(pull-up).
|
||||
* function, because this will be set internally in esp_deep_sleep_start
|
||||
* based on the wakeup mode. BTW, when you use low level to wake up the
|
||||
* chip, we strongly recommend you to add external resistors (pull-up).
|
||||
*
|
||||
* @param gpio_pin_mask Bit mask of GPIO numbers which will cause wakeup. Only GPIOs
|
||||
* which are have RTC functionality can be used in this bit map.
|
||||
* which have RTC functionality (pads that powered by VDD3P3_RTC) can be used in this bit map.
|
||||
* @param mode Select logic function used to determine wakeup condition:
|
||||
* - ESP_GPIO_WAKEUP_GPIO_LOW: wake up when the gpio turn to low.
|
||||
* - ESP_GPIO_WAKEUP_GPIO_HIGH: wake up when the gpio turn to high.
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if gpio num is more than 5 or mode is invalid,
|
||||
* - ESP_ERR_INVALID_ARG if the mask contains any invalid deep sleep wakeup pin or wakeup mode is invalid
|
||||
*/
|
||||
esp_err_t esp_deep_sleep_enable_gpio_wakeup(uint64_t gpio_pin_mask, esp_deepsleep_gpio_wake_up_mode_t mode);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enable wakeup from light sleep using GPIOs
|
||||
*
|
||||
|
|
@ -458,7 +458,6 @@ void esp_deep_sleep_disable_rom_logging(void);
|
|||
esp_err_t esp_sleep_cpu_pd_low_init(bool enable);
|
||||
#endif
|
||||
|
||||
#if SOC_GPIO_SUPPORT_SLP_SWITCH
|
||||
/**
|
||||
* @brief Configure to isolate all GPIO pins in sleep state
|
||||
*/
|
||||
|
|
@ -469,7 +468,6 @@ void esp_sleep_config_gpio_isolate(void);
|
|||
* @param enable decide whether to switch status or not
|
||||
*/
|
||||
void esp_sleep_enable_gpio_switch(bool enable);
|
||||
#endif
|
||||
|
||||
#if CONFIG_MAC_BB_PD
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
|
@ -31,7 +31,7 @@
|
|||
#define LCD_CMD_RAMRD 0x2E // Read frame memory
|
||||
#define LCD_CMD_PTLAR 0x30 // Define the partial area
|
||||
#define LCD_CMD_VSCRDEF 0x33 // Vertical scrolling definition
|
||||
#define LCD_CMD_TEOFF 0x34 // Turns of tearing effect
|
||||
#define LCD_CMD_TEOFF 0x34 // Turns off tearing effect
|
||||
#define LCD_CMD_TEON 0x35 // Turns on tearing effect
|
||||
|
||||
#define LCD_CMD_MADCTL 0x36 // Memory data access control
|
||||
|
|
@ -48,7 +48,7 @@
|
|||
#define LCD_CMD_COLMOD 0x3A // Defines the format of RGB picture data
|
||||
#define LCD_CMD_RAMWRC 0x3C // Memory write continue
|
||||
#define LCD_CMD_RAMRDC 0x3E // Memory read continue
|
||||
#define LCD_CMD_STE 0x44 // Set tear scanline, tearing effect output signal when display module reaches line N
|
||||
#define LCD_CMD_GDCAN 0x45 // Get scanline
|
||||
#define LCD_CMD_STE 0x44 // Set tear scan line, tearing effect output signal when display module reaches line N
|
||||
#define LCD_CMD_GDCAN 0x45 // Get scan line
|
||||
#define LCD_CMD_WRDISBV 0x51 // Write display brightness
|
||||
#define LCD_CMD_RDDISBV 0x52 // Read display brightness value
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
|
@ -71,7 +71,7 @@ esp_err_t esp_lcd_panel_io_rx_param(esp_lcd_panel_io_handle_t io, int lcd_cmd, v
|
|||
* this function will wait until they are finished and the queue is empty before sending the command(s).
|
||||
*
|
||||
* @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 (set to -1 if no command needed - only in SPI and I2C)
|
||||
* @param[in] lcd_cmd The specific LCD command, set to -1 if no command needed
|
||||
* @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
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ESP_LITTLEFS_VERSION_NUMBER "1.5.3"
|
||||
#define ESP_LITTLEFS_VERSION_NUMBER "1.5.5"
|
||||
#define ESP_LITTLEFS_VERSION_MAJOR 1
|
||||
#define ESP_LITTLEFS_VERSION_MINOR 5
|
||||
#define ESP_LITTLEFS_VERSION_PATCH 3
|
||||
#define ESP_LITTLEFS_VERSION_PATCH 5
|
||||
|
||||
/**
|
||||
*Configuration structure for esp_vfs_littlefs_register.
|
||||
|
|
|
|||
|
|
@ -906,6 +906,27 @@ void esp_netif_netstack_buf_ref(void *netstack_buf);
|
|||
*/
|
||||
void esp_netif_netstack_buf_free(void *netstack_buf);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup ESP_NETIF_TCPIP_EXEC
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief TCPIP thread safe callback used with esp_netif_tcpip_exec()
|
||||
*/
|
||||
typedef esp_err_t (*esp_netif_callback_fn)(void *ctx);
|
||||
|
||||
/**
|
||||
* @brief Utility to execute the supplied callback in TCP/IP context
|
||||
* @param fn Pointer to the callback
|
||||
* @param ctx Parameter to the callback
|
||||
* @return The error code (esp_err_t) returned by the callback
|
||||
*/
|
||||
esp_err_t esp_netif_tcpip_exec(esp_netif_callback_fn fn, void *ctx);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -17,9 +17,15 @@ extern "C" {
|
|||
// Macros to assemble master configs with partial configs from netif, stack and driver
|
||||
//
|
||||
|
||||
#ifdef CONFIG_LWIP_ESP_MLDV6_REPORT
|
||||
#define ESP_NETIF_DEFAULT_MLDV6_REPORT_FLAGS (ESP_NETIF_FLAG_MLDV6_REPORT)
|
||||
#else
|
||||
#define ESP_NETIF_DEFAULT_MLDV6_REPORT_FLAGS (0)
|
||||
#endif
|
||||
|
||||
#define ESP_NETIF_INHERENT_DEFAULT_WIFI_STA() \
|
||||
{ \
|
||||
.flags = (esp_netif_flags_t)(ESP_NETIF_DHCP_CLIENT | ESP_NETIF_FLAG_GARP | ESP_NETIF_FLAG_EVENT_IP_MODIFIED), \
|
||||
.flags = (esp_netif_flags_t)(ESP_NETIF_DHCP_CLIENT | ESP_NETIF_FLAG_GARP | ESP_NETIF_DEFAULT_MLDV6_REPORT_FLAGS | ESP_NETIF_FLAG_EVENT_IP_MODIFIED), \
|
||||
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(mac) \
|
||||
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(ip_info) \
|
||||
.get_ip_event = IP_EVENT_STA_GOT_IP, \
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ extern "C" {
|
|||
#define ESP_ERR_ESP_NETIF_DNS_NOT_CONFIGURED ESP_ERR_ESP_NETIF_BASE + 0x0A
|
||||
#define ESP_ERR_ESP_NETIF_MLD6_FAILED ESP_ERR_ESP_NETIF_BASE + 0x0B
|
||||
#define ESP_ERR_ESP_NETIF_IP6_ADDR_FAILED ESP_ERR_ESP_NETIF_BASE + 0x0C
|
||||
#define ESP_ERR_ESP_NETIF_DHCPS_START_FAILED ESP_ERR_ESP_NETIF_BASE + 0x0D
|
||||
|
||||
|
||||
/** @brief Type of esp_netif_object server */
|
||||
|
|
@ -154,6 +155,7 @@ typedef enum esp_netif_flags {
|
|||
ESP_NETIF_FLAG_EVENT_IP_MODIFIED = 1 << 4,
|
||||
ESP_NETIF_FLAG_IS_PPP = 1 << 5,
|
||||
ESP_NETIF_FLAG_IS_SLIP = 1 << 6,
|
||||
ESP_NETIF_FLAG_MLDV6_REPORT = 1 << 7,
|
||||
} esp_netif_flags_t;
|
||||
|
||||
typedef enum esp_netif_ip_event_type {
|
||||
|
|
|
|||
|
|
@ -150,6 +150,12 @@ esp_err_t esp_phy_store_cal_data_to_nvs(const esp_phy_calibration_data_t* cal_da
|
|||
*/
|
||||
esp_err_t esp_phy_erase_cal_data_in_nvs(void);
|
||||
|
||||
/**
|
||||
* @brief Get phy initialize status
|
||||
* @return return true if phy is already initialized.
|
||||
*/
|
||||
bool esp_phy_is_initialized(void);
|
||||
|
||||
/**
|
||||
* @brief Enable PHY and RF module
|
||||
*
|
||||
|
|
|
|||
|
|
@ -945,6 +945,18 @@ esp_err_t esp_rmaker_ota_enable_default(void);
|
|||
* @return error on failure
|
||||
*/
|
||||
esp_err_t esp_rmaker_test_cmd_resp(const void *cmd, size_t cmd_len, void *priv_data);
|
||||
|
||||
/** This API signs the challenge with RainMaker private key.
|
||||
*
|
||||
* @param[in] challenge Pointer to the data to be signed
|
||||
* @param[in] inlen Length of the challenge
|
||||
* @param[out] response Pointer to the signature.
|
||||
* @param[out] outlen Length of the signature
|
||||
*
|
||||
* @return ESP_OK on success. response is dynamically allocated, free the response on success.
|
||||
* @return Apt error on failure.
|
||||
*/
|
||||
esp_err_t esp_rmaker_node_auth_sign_msg(const void *challenge, size_t inlen, void **response, size_t *outlen);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -111,6 +111,14 @@ void esp_rmaker_create_mqtt_topic(char *buf, size_t buf_size, const char *topic_
|
|||
*/
|
||||
bool esp_rmaker_mqtt_is_budget_available(void);
|
||||
|
||||
/**
|
||||
* @brief Check if device is connected to MQTT Server
|
||||
*
|
||||
* @return true if device is connected
|
||||
* @return false if device is not connected
|
||||
*
|
||||
*/
|
||||
bool esp_rmaker_is_mqtt_connected();
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -79,7 +79,6 @@ esp_err_t esp_rmaker_user_mapping_endpoint_register(void);
|
|||
* @return error on failure.
|
||||
*/
|
||||
esp_err_t esp_rmaker_start_user_node_mapping(char *user_id, char *secret_key);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,21 +1,13 @@
|
|||
// 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-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#ifdef CONFIG_ESP32_REV_MIN_3
|
||||
#if CONFIG_ESP32_REV_MIN_FULL >= 300
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
|
@ -47,4 +39,4 @@ bool ets_emsa_pss_verify(const uint8_t *encoded_message, const uint8_t *mhash, u
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif // CONFIG_ESP32_REV_MIN_3
|
||||
#endif // CONFIG_ESP32_REV_MIN_FULL >= 300
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
|
@ -34,7 +34,7 @@ bool ets_secure_boot_check_start(uint8_t abs_index, uint32_t iv_addr);
|
|||
|
||||
int ets_secure_boot_check_finish(uint32_t *abstract);
|
||||
|
||||
#ifdef CONFIG_ESP32_REV_MIN_3
|
||||
#if CONFIG_ESP32_REV_MIN_FULL >= 300
|
||||
#include "rsa_pss.h"
|
||||
|
||||
#define SECURE_BOOT_NUM_BLOCKS 1
|
||||
|
|
@ -115,7 +115,7 @@ bool ets_use_secure_boot_v2(void);
|
|||
#else
|
||||
#define SECURE_BOOT_NUM_BLOCKS 0
|
||||
|
||||
#endif /* CONFIG_ESP32_REV_MIN_3 */
|
||||
#endif /* CONFIG_ESP32_REV_MIN_FULL >= 300 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue