Merge branch 'idf-release/v4.2' of https://github.com/espressif/arduino-esp32 into espressif-idf-release/v4.2
This commit is contained in:
commit
c7748786cf
1330 changed files with 29947 additions and 7134 deletions
|
|
@ -185,8 +185,8 @@ void uartAttachRx(uart_t* uart, uint8_t rxPin, bool inverted)
|
|||
return;
|
||||
}
|
||||
pinMode(rxPin, INPUT);
|
||||
pinMatrixInAttach(rxPin, UART_RXD_IDX(uart->num), inverted);
|
||||
uartEnableInterrupt(uart);
|
||||
pinMatrixInAttach(rxPin, UART_RXD_IDX(uart->num), inverted);
|
||||
}
|
||||
|
||||
void uartAttachTx(uart_t* uart, uint8_t txPin, bool inverted)
|
||||
|
|
|
|||
|
|
@ -111,10 +111,10 @@ void MDNSResponder::disableArduino(){
|
|||
}
|
||||
}
|
||||
|
||||
void MDNSResponder::enableWorkstation(wifi_interface_t interface){
|
||||
void MDNSResponder::enableWorkstation(esp_interface_t interface){
|
||||
char winstance[21+_hostname.length()];
|
||||
uint8_t mac[6];
|
||||
esp_wifi_get_mac(interface, mac);
|
||||
esp_wifi_get_mac((wifi_interface_t)interface, mac);
|
||||
sprintf(winstance, "%s [%02x:%02x:%02x:%02x:%02x:%02x]", _hostname.c_str(), mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
|
||||
if(mdns_service_add(NULL, "_workstation", "_tcp", 9, NULL, 0)) {
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public:
|
|||
void enableArduino(uint16_t port=3232, bool auth=false);
|
||||
void disableArduino();
|
||||
|
||||
void enableWorkstation(wifi_interface_t interface=ESP_IF_WIFI_STA);
|
||||
void enableWorkstation(esp_interface_t interface=ESP_IF_WIFI_STA);
|
||||
void disableWorkstation();
|
||||
|
||||
IPAddress queryHost(char *host, uint32_t timeout=2000);
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ void WiFiClass::printDiag(Print& p)
|
|||
*/
|
||||
|
||||
wifi_config_t conf;
|
||||
esp_wifi_get_config(WIFI_IF_STA, &conf);
|
||||
esp_wifi_get_config((wifi_interface_t)WIFI_IF_STA, &conf);
|
||||
|
||||
const char* ssid = reinterpret_cast<const char*>(conf.sta.ssid);
|
||||
p.print("SSID (");
|
||||
|
|
|
|||
|
|
@ -134,13 +134,13 @@ bool WiFiAPClass::softAP(const char* ssid, const char* passphrase, int channel,
|
|||
wifi_config_t conf;
|
||||
wifi_config_t conf_current;
|
||||
wifi_softap_config(&conf, ssid, passphrase, channel, WIFI_AUTH_WPA_WPA2_PSK, ssid_hidden, max_connection);
|
||||
esp_err_t err = esp_wifi_get_config(WIFI_IF_AP, &conf_current);
|
||||
esp_err_t err = esp_wifi_get_config((wifi_interface_t)WIFI_IF_AP, &conf_current);
|
||||
if(err){
|
||||
log_e("get AP config failed");
|
||||
return false;
|
||||
}
|
||||
if(!softap_config_equal(conf, conf_current)) {
|
||||
err = esp_wifi_set_config(WIFI_IF_AP, &conf);
|
||||
err = esp_wifi_set_config((wifi_interface_t)WIFI_IF_AP, &conf);
|
||||
if(err){
|
||||
log_e("set AP config failed");
|
||||
return false;
|
||||
|
|
@ -187,7 +187,7 @@ bool WiFiAPClass::softAPdisconnect(bool wifioff)
|
|||
return false;
|
||||
}
|
||||
|
||||
ret = esp_wifi_set_config(WIFI_IF_AP, &conf) == ESP_OK;
|
||||
ret = esp_wifi_set_config((wifi_interface_t)WIFI_IF_AP, &conf) == ESP_OK;
|
||||
|
||||
if(ret && wifioff) {
|
||||
ret = WiFi.enableAP(false) == ESP_OK;
|
||||
|
|
@ -289,7 +289,7 @@ uint8_t WiFiAPClass::softAPSubnetCIDR()
|
|||
uint8_t* WiFiAPClass::softAPmacAddress(uint8_t* mac)
|
||||
{
|
||||
if(WiFiGenericClass::getMode() != WIFI_MODE_NULL){
|
||||
esp_wifi_get_mac(WIFI_IF_AP, mac);
|
||||
esp_wifi_get_mac((wifi_interface_t)WIFI_IF_AP, mac);
|
||||
}
|
||||
return mac;
|
||||
}
|
||||
|
|
@ -305,7 +305,7 @@ String WiFiAPClass::softAPmacAddress(void)
|
|||
if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){
|
||||
return String();
|
||||
}
|
||||
esp_wifi_get_mac(WIFI_IF_AP, mac);
|
||||
esp_wifi_get_mac((wifi_interface_t)WIFI_IF_AP, mac);
|
||||
|
||||
sprintf(macStr, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
return String(macStr);
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ static char default_hostname[32] = {0,};
|
|||
static const char * get_esp_netif_hostname(){
|
||||
if(default_hostname[0] == 0){
|
||||
uint8_t eth_mac[6];
|
||||
esp_wifi_get_mac(WIFI_IF_STA, eth_mac);
|
||||
esp_wifi_get_mac((wifi_interface_t)WIFI_IF_STA, eth_mac);
|
||||
snprintf(default_hostname, 32, "%s%02X%02X%02X", CONFIG_IDF_TARGET "-", eth_mac[3], eth_mac[4], eth_mac[5]);
|
||||
}
|
||||
return (const char *)default_hostname;
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ wl_status_t WiFiSTAClass::begin(const char* ssid, const char *passphrase, int32_
|
|||
|
||||
wifi_sta_config(&conf, ssid, passphrase, bssid, channel);
|
||||
|
||||
if(esp_wifi_get_config(ESP_IF_WIFI_STA, ¤t_conf) != ESP_OK){
|
||||
if(esp_wifi_get_config((wifi_interface_t)ESP_IF_WIFI_STA, ¤t_conf) != ESP_OK){
|
||||
log_e("get current config failed!");
|
||||
return WL_CONNECT_FAILED;
|
||||
}
|
||||
|
|
@ -178,14 +178,14 @@ wl_status_t WiFiSTAClass::begin(const char* ssid, const char *passphrase, int32_
|
|||
return WL_CONNECT_FAILED;
|
||||
}
|
||||
|
||||
if(esp_wifi_set_config(ESP_IF_WIFI_STA, &conf) != ESP_OK){
|
||||
if(esp_wifi_set_config((wifi_interface_t)ESP_IF_WIFI_STA, &conf) != ESP_OK){
|
||||
log_e("set config failed!");
|
||||
return WL_CONNECT_FAILED;
|
||||
}
|
||||
} else if(status() == WL_CONNECTED){
|
||||
return WL_CONNECTED;
|
||||
} else {
|
||||
if(esp_wifi_set_config(ESP_IF_WIFI_STA, &conf) != ESP_OK){
|
||||
if(esp_wifi_set_config((wifi_interface_t)ESP_IF_WIFI_STA, &conf) != ESP_OK){
|
||||
log_e("set config failed!");
|
||||
return WL_CONNECT_FAILED;
|
||||
}
|
||||
|
|
@ -225,7 +225,7 @@ wl_status_t WiFiSTAClass::begin()
|
|||
}
|
||||
|
||||
wifi_config_t current_conf;
|
||||
if(esp_wifi_get_config(ESP_IF_WIFI_STA, ¤t_conf) != ESP_OK || esp_wifi_set_config(ESP_IF_WIFI_STA, ¤t_conf) != ESP_OK) {
|
||||
if(esp_wifi_get_config((wifi_interface_t)ESP_IF_WIFI_STA, ¤t_conf) != ESP_OK || esp_wifi_set_config((wifi_interface_t)ESP_IF_WIFI_STA, ¤t_conf) != ESP_OK) {
|
||||
log_e("config failed");
|
||||
return WL_CONNECT_FAILED;
|
||||
}
|
||||
|
|
@ -272,7 +272,7 @@ bool WiFiSTAClass::disconnect(bool wifioff, bool eraseap)
|
|||
|
||||
if(WiFi.getMode() & WIFI_MODE_STA){
|
||||
if(eraseap){
|
||||
if(esp_wifi_set_config(ESP_IF_WIFI_STA, &conf)){
|
||||
if(esp_wifi_set_config((wifi_interface_t)ESP_IF_WIFI_STA, &conf)){
|
||||
log_e("clear config failed!");
|
||||
}
|
||||
}
|
||||
|
|
@ -398,7 +398,7 @@ IPAddress WiFiSTAClass::localIP()
|
|||
uint8_t* WiFiSTAClass::macAddress(uint8_t* mac)
|
||||
{
|
||||
if(WiFiGenericClass::getMode() != WIFI_MODE_NULL){
|
||||
esp_wifi_get_mac(ESP_IF_WIFI_STA, mac);
|
||||
esp_wifi_get_mac((wifi_interface_t)ESP_IF_WIFI_STA, mac);
|
||||
}
|
||||
else{
|
||||
esp_read_mac(mac, ESP_MAC_WIFI_STA);
|
||||
|
|
@ -418,7 +418,7 @@ String WiFiSTAClass::macAddress(void)
|
|||
esp_read_mac(mac, ESP_MAC_WIFI_STA);
|
||||
}
|
||||
else{
|
||||
esp_wifi_get_mac(ESP_IF_WIFI_STA, mac);
|
||||
esp_wifi_get_mac((wifi_interface_t)ESP_IF_WIFI_STA, mac);
|
||||
}
|
||||
sprintf(macStr, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
return String(macStr);
|
||||
|
|
@ -549,7 +549,7 @@ String WiFiSTAClass::psk() const
|
|||
return String();
|
||||
}
|
||||
wifi_config_t conf;
|
||||
esp_wifi_get_config(ESP_IF_WIFI_STA, &conf);
|
||||
esp_wifi_get_config((wifi_interface_t)ESP_IF_WIFI_STA, &conf);
|
||||
return String(reinterpret_cast<char*>(conf.sta.password));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ static const uint8_t custom_service_uuid[16] = { 0xb4, 0xdf, 0x5a, 0x1c, 0x3f,
|
|||
static void get_device_service_name(prov_scheme_t prov_scheme, char *service_name, size_t max)
|
||||
{
|
||||
uint8_t eth_mac[6] = {0,0,0,0,0,0};
|
||||
if(esp_wifi_get_mac(WIFI_IF_STA, eth_mac) != ESP_OK){
|
||||
if(esp_wifi_get_mac((wifi_interface_t)WIFI_IF_STA, eth_mac) != ESP_OK){
|
||||
log_e("esp_wifi_get_mac failed!");
|
||||
return;
|
||||
}
|
||||
|
|
@ -158,7 +158,7 @@ void WiFiProvClass :: beginProvision(prov_scheme_t prov_scheme, scheme_handler_t
|
|||
log_i("Already Provisioned");
|
||||
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
|
||||
static wifi_config_t conf;
|
||||
esp_wifi_get_config(WIFI_IF_STA,&conf);
|
||||
esp_wifi_get_config((wifi_interface_t)WIFI_IF_STA,&conf);
|
||||
log_i("Attempting connect to AP: %s\n",conf.sta.ssid);
|
||||
#endif
|
||||
esp_wifi_start();
|
||||
|
|
|
|||
|
|
@ -149,8 +149,8 @@
|
|||
"host": "x86_64-apple-darwin",
|
||||
"url": "https://dl.espressif.com/dl/esptool-3.0.0.2-macos.tar.gz",
|
||||
"archiveFileName": "esptool-3.0.0.2-macos.tar.gz",
|
||||
"checksum": "SHA-256:9213f46d5aa865558da4a2ef4218e87eef4782779128083c15ce2b3e4d07a1ea",
|
||||
"size": "3849615"
|
||||
"checksum": "SHA-256:2cafab7f1ebce89475b84c115548eaace40b6366d7b3f9862cdb2fc64f806643",
|
||||
"size": "3859642"
|
||||
},
|
||||
{
|
||||
"host": "x86_64-pc-linux-gnu",
|
||||
|
|
|
|||
12
platform.txt
12
platform.txt
File diff suppressed because one or more lines are too long
|
|
@ -68,7 +68,7 @@ except Exception:
|
|||
raise
|
||||
|
||||
|
||||
__version__ = "3.0-dev"
|
||||
__version__ = "3.1-dev"
|
||||
|
||||
MAX_UINT32 = 0xffffffff
|
||||
MAX_UINT24 = 0xffffff
|
||||
|
|
@ -2051,12 +2051,12 @@ class BaseFirmwareImage(object):
|
|||
raise FatalError('Cannot place SHA256 digest on segment boundary'
|
||||
'(elf_sha256_offset=%d, file_pos=%d, segment_size=%d)' %
|
||||
(self.elf_sha256_offset, file_pos, segment_len))
|
||||
# offset relative to the data part
|
||||
patch_offset -= self.SEG_HEADER_LEN
|
||||
if segment_data[patch_offset:patch_offset + self.SHA256_DIGEST_LEN] != b'\x00' * self.SHA256_DIGEST_LEN:
|
||||
raise FatalError('Contents of segment at SHA256 digest offset 0x%x are not all zero. Refusing to overwrite.' %
|
||||
self.elf_sha256_offset)
|
||||
assert(len(self.elf_sha256) == self.SHA256_DIGEST_LEN)
|
||||
# offset relative to the data part
|
||||
patch_offset -= self.SEG_HEADER_LEN
|
||||
segment_data = segment_data[0:patch_offset] + self.elf_sha256 + \
|
||||
segment_data[patch_offset + self.SHA256_DIGEST_LEN:]
|
||||
return segment_data
|
||||
|
|
@ -2908,8 +2908,8 @@ def write_flash(esp, args):
|
|||
if args.compress is None and not args.no_compress:
|
||||
args.compress = not args.no_stub
|
||||
|
||||
# For encrypt option we do few sanity checks before actual flash write
|
||||
if args.encrypt:
|
||||
# In case we have encrypted files to write, we first do few sanity checks before actual flash
|
||||
if args.encrypt or args.encrypt_files is not None:
|
||||
do_write = True
|
||||
|
||||
if not esp.secure_download_mode:
|
||||
|
|
@ -2929,7 +2929,10 @@ def write_flash(esp, args):
|
|||
print('Flash encryption key is not programmed')
|
||||
do_write = False
|
||||
|
||||
for address, argfile in args.addr_filename:
|
||||
# Determine which files list contain the ones to encrypt
|
||||
files_to_encrypt = args.addr_filename if args.encrypt else args.encrypt_files
|
||||
|
||||
for address, argfile in files_to_encrypt:
|
||||
if address % esp.FLASH_ENCRYPTED_WRITE_ALIGN:
|
||||
print("File %s address 0x%x is not %d byte aligned, can't flash encrypted" %
|
||||
(argfile.name, address, esp.FLASH_ENCRYPTED_WRITE_ALIGN))
|
||||
|
|
@ -2952,29 +2955,54 @@ def write_flash(esp, args):
|
|||
if args.erase_all:
|
||||
erase_flash(esp, args)
|
||||
|
||||
if args.encrypt and args.compress:
|
||||
print('\nWARNING: - compress and encrypt options are mutually exclusive ')
|
||||
print('Will flash uncompressed')
|
||||
args.compress = False
|
||||
""" Create a list describing all the files we have to flash. Each entry holds an "encrypt" flag
|
||||
marking whether the file needs encryption or not. This list needs to be sorted.
|
||||
|
||||
First, append to each entry of our addr_filename list the flag args.encrypt
|
||||
For example, if addr_filename is [(0x1000, "partition.bin"), (0x8000, "bootloader")],
|
||||
all_files will be [(0x1000, "partition.bin", args.encrypt), (0x8000, "bootloader", args.encrypt)],
|
||||
where, of course, args.encrypt is either True or False
|
||||
"""
|
||||
all_files = [(offs, filename, args.encrypt) for (offs, filename) in args.addr_filename]
|
||||
|
||||
"""Now do the same with encrypt_files list, if defined.
|
||||
In this case, the flag is True
|
||||
"""
|
||||
if args.encrypt_files is not None:
|
||||
encrypted_files_flag = [(offs, filename, True) for (offs, filename) in args.encrypt_files]
|
||||
|
||||
# Concatenate both lists and sort them.
|
||||
# As both list are already sorted, we could simply do a merge instead,
|
||||
# but for the sake of simplicity and because the lists are very small,
|
||||
# let's use sorted.
|
||||
all_files = sorted(all_files + encrypted_files_flag, key=lambda x: x[0])
|
||||
|
||||
for address, argfile, encrypted in all_files:
|
||||
compress = args.compress
|
||||
|
||||
# Check whether we can compress the current file before flashing
|
||||
if compress and encrypted:
|
||||
print('\nWARNING: - compress and encrypt options are mutually exclusive ')
|
||||
print('Will flash %s uncompressed' % argfile.name)
|
||||
compress = False
|
||||
|
||||
for address, argfile in args.addr_filename:
|
||||
if args.no_stub:
|
||||
print('Erasing flash...')
|
||||
image = pad_to(argfile.read(), esp.FLASH_ENCRYPTED_WRITE_ALIGN if args.encrypt else 4)
|
||||
image = pad_to(argfile.read(), esp.FLASH_ENCRYPTED_WRITE_ALIGN if encrypted else 4)
|
||||
if len(image) == 0:
|
||||
print('WARNING: File %s is empty' % argfile.name)
|
||||
continue
|
||||
image = _update_image_flash_params(esp, address, args, image)
|
||||
calcmd5 = hashlib.md5(image).hexdigest()
|
||||
uncsize = len(image)
|
||||
if args.compress:
|
||||
if compress:
|
||||
uncimage = image
|
||||
image = zlib.compress(uncimage, 9)
|
||||
ratio = uncsize / len(image)
|
||||
blocks = esp.flash_defl_begin(uncsize, len(image), address)
|
||||
else:
|
||||
ratio = 1.0
|
||||
blocks = esp.flash_begin(uncsize, address, begin_rom_encrypted=args.encrypt)
|
||||
blocks = esp.flash_begin(uncsize, address, begin_rom_encrypted=encrypted)
|
||||
argfile.seek(0) # in case we need it again
|
||||
seq = 0
|
||||
written = 0
|
||||
|
|
@ -2983,12 +3011,12 @@ def write_flash(esp, args):
|
|||
print_overwrite('Writing at 0x%08x... (%d %%)' % (address + seq * esp.FLASH_WRITE_SIZE, 100 * (seq + 1) // blocks))
|
||||
sys.stdout.flush()
|
||||
block = image[0:esp.FLASH_WRITE_SIZE]
|
||||
if args.compress:
|
||||
if compress:
|
||||
esp.flash_defl_block(block, seq, timeout=DEFAULT_TIMEOUT * ratio * 2)
|
||||
else:
|
||||
# Pad the last block
|
||||
block = block + b'\xff' * (esp.FLASH_WRITE_SIZE - len(block))
|
||||
if args.encrypt:
|
||||
if encrypted:
|
||||
esp.flash_encrypt_block(block, seq)
|
||||
else:
|
||||
esp.flash_block(block, seq)
|
||||
|
|
@ -2997,7 +3025,7 @@ def write_flash(esp, args):
|
|||
written += len(block)
|
||||
t = time.time() - t
|
||||
speed_msg = ""
|
||||
if args.compress:
|
||||
if compress:
|
||||
if t > 0.0:
|
||||
speed_msg = " (effective %.1f kbit/s)" % (uncsize / t * 8 / 1000)
|
||||
print_overwrite('Wrote %d bytes (%d compressed) at 0x%08x in %.1f seconds%s...' % (uncsize, written, address, t, speed_msg), last_line=True)
|
||||
|
|
@ -3006,7 +3034,7 @@ def write_flash(esp, args):
|
|||
speed_msg = " (%.1f kbit/s)" % (written / t * 8 / 1000)
|
||||
print_overwrite('Wrote %d bytes at 0x%08x in %.1f seconds%s...' % (written, address, t, speed_msg), last_line=True)
|
||||
|
||||
if not args.encrypt and not esp.secure_download_mode:
|
||||
if not encrypted and not esp.secure_download_mode:
|
||||
try:
|
||||
res = esp.flash_md5sum(address, uncsize)
|
||||
if res != calcmd5:
|
||||
|
|
@ -3025,7 +3053,14 @@ def write_flash(esp, args):
|
|||
# skip sending flash_finish to ROM loader here,
|
||||
# as it causes the loader to exit and run user code
|
||||
esp.flash_begin(0, 0)
|
||||
if args.compress:
|
||||
|
||||
# Get the "encrypted" flag for the last file flashed
|
||||
# Note: all_files list contains triplets like:
|
||||
# (address: Integer, filename: String, encrypted: Boolean)
|
||||
last_file_encrypted = all_files[-1][2]
|
||||
|
||||
# Check whether the last file flashed was compressed or not
|
||||
if args.compress and not last_file_encrypted:
|
||||
esp.flash_defl_finish(False)
|
||||
else:
|
||||
esp.flash_finish(False)
|
||||
|
|
@ -3033,6 +3068,11 @@ def write_flash(esp, args):
|
|||
if args.verify:
|
||||
print('Verifying just-written flash...')
|
||||
print('(This option is deprecated, flash contents are now always read back after flashing.)')
|
||||
# If some encrypted files have been flashed print a warning saying that we won't check them
|
||||
if args.encrypt or args.encrypt_files is not None:
|
||||
print('WARNING: - cannot verify encrypted files, they will be ignored')
|
||||
# Call verify_flash function only if there at least one non-encrypted file flashed
|
||||
if not args.encrypt:
|
||||
verify_flash(esp, args)
|
||||
|
||||
|
||||
|
|
@ -3368,7 +3408,7 @@ def main(custom_commandline=None):
|
|||
parent.add_argument('--flash_size', '-fs', help='SPI Flash size in MegaBytes (1MB, 2MB, 4MB, 8MB, 16M)'
|
||||
' plus ESP8266-only (256KB, 512KB, 2MB-c1, 4MB-c1)' + extra_fs_message,
|
||||
action=FlashSizeAction, auto_detect=auto_detect,
|
||||
default=os.environ.get('ESPTOOL_FS', 'detect' if auto_detect else '1MB'))
|
||||
default=os.environ.get('ESPTOOL_FS', '1MB' if is_elf2image else 'keep'))
|
||||
add_spi_connection_arg(parent)
|
||||
|
||||
parser_write_flash = subparsers.add_parser(
|
||||
|
|
@ -3387,6 +3427,10 @@ def main(custom_commandline=None):
|
|||
'(mostly superfluous, data is read back during flashing)', action='store_true')
|
||||
parser_write_flash.add_argument('--encrypt', help='Apply flash encryption when writing data (required correct efuse settings)',
|
||||
action='store_true')
|
||||
# In order to not break backward compatibility, our list of encrypted files to flash is a new parameter
|
||||
parser_write_flash.add_argument('--encrypt-files', metavar='<address> <filename>',
|
||||
help='Files to be encrypted on the flash. Address followed by binary filename, separated by space.',
|
||||
action=AddrFilenamePairAction)
|
||||
parser_write_flash.add_argument('--ignore-flash-encryption-efuse-setting', help='Ignore flash encryption efuse settings ',
|
||||
action='store_true')
|
||||
|
||||
|
|
@ -3501,7 +3545,6 @@ def main(custom_commandline=None):
|
|||
expand_file_arguments()
|
||||
|
||||
args = parser.parse_args(custom_commandline)
|
||||
|
||||
print('esptool.py v%s' % __version__)
|
||||
|
||||
# operation function can take 1 arg (args), 2 args (esp, arg)
|
||||
|
|
@ -3511,6 +3554,13 @@ def main(custom_commandline=None):
|
|||
parser.print_help()
|
||||
sys.exit(1)
|
||||
|
||||
# Forbid the usage of both --encrypt, which means encrypt all the given files,
|
||||
# and --encrypt-files, which represents the list of files to encrypt.
|
||||
# The reason is that allowing both at the same time increases the chances of
|
||||
# having contradictory lists (e.g. one file not available in one of list).
|
||||
if args.operation == "write_flash" and args.encrypt and args.encrypt_files is not None:
|
||||
raise FatalError("Options --encrypt and --encrypt-files must not be specified at the same time.")
|
||||
|
||||
operation_func = globals()[args.operation]
|
||||
|
||||
if PYTHON2:
|
||||
|
|
@ -3738,7 +3788,7 @@ class AddrFilenamePairAction(argparse.Action):
|
|||
|
||||
# Sort the addresses and check for overlapping
|
||||
end = 0
|
||||
for address, argfile in sorted(pairs):
|
||||
for address, argfile in sorted(pairs, key=lambda x: x[0]):
|
||||
argfile.seek(0, 2) # seek to end
|
||||
size = argfile.tell()
|
||||
argfile.seek(0)
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -74,11 +74,11 @@ env.Append(
|
|||
"-fno-lto",
|
||||
"-Wl,--gc-sections",
|
||||
"-Wl,--undefined=uxTopUsedPriority",
|
||||
"-T", "esp32s2.rom.api.ld",
|
||||
"-T", "esp32s2.rom.ld",
|
||||
"-T", "esp32s2.rom.api.ld",
|
||||
"-T", "esp32s2.rom.libgcc.ld",
|
||||
"-T", "esp32s2.rom.newlib-data.ld",
|
||||
"-T", "esp32s2.rom.newlib-funcs.ld",
|
||||
"-T", "esp32s2.rom.newlib-data.ld",
|
||||
"-T", "esp32s2.rom.spiflash.ld",
|
||||
"-T", "esp32s2_out.ld",
|
||||
"-T", "esp32s2.project.ld",
|
||||
|
|
@ -92,7 +92,6 @@ env.Append(
|
|||
"-u", "vfs_include_syscalls_impl",
|
||||
"-u", "call_user_start_cpu0",
|
||||
"-u", "app_main",
|
||||
"-u", "newlib_include_locks_impl",
|
||||
"-u", "newlib_include_heap_impl",
|
||||
"-u", "newlib_include_syscalls_impl",
|
||||
"-u", "newlib_include_pthread_impl",
|
||||
|
|
@ -104,7 +103,7 @@ env.Append(
|
|||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "config"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "newlib", "platform_include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "freertos", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "freertos", "xtensa", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "freertos", "port", "xtensa", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_hw_support", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_hw_support", "port", "esp32s2"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_hw_support", "port", "esp32s2", "private_include"),
|
||||
|
|
@ -115,23 +114,23 @@ env.Append(
|
|||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "lwip", "lwip", "src", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "lwip", "port", "esp32", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "lwip", "port", "esp32", "include", "arch"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "lwip", "port", "esp32", "tcp_isn"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "soc", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "soc", "esp32s2"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "soc", "esp32s2", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "hal", "esp32s2", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "hal", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_rom", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_rom", "esp32s2"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_common", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_system", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "xtensa", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "xtensa", "esp32s2", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp32s2", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "driver", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "driver", "esp32s2", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_ringbuf", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "efuse", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "efuse", "esp32s2", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "xtensa", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "xtensa", "esp32s2", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "espcoredump", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_timer", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_ipc", "include"),
|
||||
|
|
@ -152,6 +151,9 @@ env.Append(
|
|||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "spi_flash", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "nvs_flash", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "pthread", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_gdbstub", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_gdbstub", "xtensa"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_gdbstub", "esp32s2"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "wpa_supplicant", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "wpa_supplicant", "port", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "wpa_supplicant", "include", "esp_supplicant"),
|
||||
|
|
@ -160,7 +162,6 @@ env.Append(
|
|||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "cbor", "port", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "unity", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "unity", "unity", "src"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "unity", "unity", "extras", "fixture", "src"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "cmock", "CMock", "src"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "coap", "port", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "coap", "port", "include", "coap"),
|
||||
|
|
@ -172,7 +173,6 @@ env.Append(
|
|||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-tls"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-tls", "esp-tls-crypto"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_adc_cal", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_gdbstub", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_hid", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "tcp_transport", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp_http_client", "include"),
|
||||
|
|
@ -210,6 +210,29 @@ env.Append(
|
|||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "tinyusb", "additions", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "ulp", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "wifi_provisioning", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-dsp", "modules", "dotprod", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-dsp", "modules", "support", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-dsp", "modules", "windows", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-dsp", "modules", "windows", "hann", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-dsp", "modules", "windows", "blackman", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-dsp", "modules", "windows", "blackman_harris", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-dsp", "modules", "windows", "blackman_nuttall", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-dsp", "modules", "windows", "nuttall", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-dsp", "modules", "windows", "flat_top", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-dsp", "modules", "iir", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-dsp", "modules", "fir", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-dsp", "modules", "math", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-dsp", "modules", "math", "add", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-dsp", "modules", "math", "sub", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-dsp", "modules", "math", "mul", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-dsp", "modules", "math", "addc", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-dsp", "modules", "math", "mulc", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-dsp", "modules", "math", "sqrt", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-dsp", "modules", "matrix", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-dsp", "modules", "fft", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-dsp", "modules", "dct", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-dsp", "modules", "conv", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-dsp", "modules", "common", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-face", "face_detection", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-face", "face_recognition", "include"),
|
||||
join(FRAMEWORK_DIR, "tools", "sdk", "esp32s2", "include", "esp-face", "object_detection", "include"),
|
||||
|
|
@ -228,7 +251,7 @@ env.Append(
|
|||
],
|
||||
|
||||
LIBS=[
|
||||
"-lxtensa", "-lesp_pm", "-lmbedtls", "-lefuse", "-lbootloader_support", "-lapp_update", "-lesp_ipc", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lesp_ringbuf", "-ldriver", "-lespcoredump", "-lesp32s2", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lasio", "-lcbor", "-lunity", "-lcmock", "-lcoap", "-lconsole", "-lnghttp", "-lesp-tls", "-lesp_adc_cal", "-lesp_gdbstub", "-lesp_hid", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lesp_https_server", "-lprotobuf-c", "-lprotocomm", "-lmdns", "-lesp_local_ctrl", "-lsdmmc", "-lesp_serial_slave_link", "-lesp_websocket_client", "-lexpat", "-lwear_levelling", "-lfatfs", "-lfreemodbus", "-ljsmn", "-ljson", "-llibsodium", "-lmqtt", "-lopenssl", "-lperfmon", "-lspiffs", "-lulp", "-lwifi_provisioning", "-lesp-face", "-lesp_littlefs", "-lfb_gfx", "-lasio", "-lcbor", "-lcmock", "-lunity", "-lcoap", "-lesp_gdbstub", "-lesp_hid", "-lesp_local_ctrl", "-lesp_https_server", "-lesp_websocket_client", "-lexpat", "-lfreemodbus", "-ljsmn", "-llibsodium", "-lmqtt", "-lperfmon", "-lwifi_provisioning", "-lprotocomm", "-lprotobuf-c", "-ljson", "-lesp-face", "-lpe", "-lfd", "-lfr", "-ldetection_cat_face", "-ldetection", "-ldl", "-lesp_littlefs", "-lfb_gfx", "-lesp_adc_cal", "-lmdns", "-lconsole", "-lfatfs", "-lwear_levelling", "-lopenssl", "-lspiffs", "-ltinyusb", "-lxtensa", "-lesp_pm", "-lmbedtls", "-lefuse", "-lbootloader_support", "-lapp_update", "-lesp_ipc", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lesp_ringbuf", "-ldriver", "-lespcoredump", "-lesp32s2", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lrtc", "-lsmartconfig", "-lphy", "-lxtensa", "-lesp_pm", "-lmbedtls", "-lefuse", "-lbootloader_support", "-lapp_update", "-lesp_ipc", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lesp_ringbuf", "-ldriver", "-lespcoredump", "-lesp32s2", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lrtc", "-lsmartconfig", "-lphy", "-lxtensa", "-lesp_pm", "-lmbedtls", "-lefuse", "-lbootloader_support", "-lapp_update", "-lesp_ipc", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lesp_ringbuf", "-ldriver", "-lespcoredump", "-lesp32s2", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lrtc", "-lsmartconfig", "-lphy", "-lxtensa", "-lesp_pm", "-lmbedtls", "-lefuse", "-lbootloader_support", "-lapp_update", "-lesp_ipc", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lesp_ringbuf", "-ldriver", "-lespcoredump", "-lesp32s2", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lrtc", "-lsmartconfig", "-lphy", "-lxt_hal", "-lesp32s2", "-lm", "-lnewlib", "-lgcc", "-lstdc++", "-lpthread", "-lapp_trace", "-lgcov", "-lapp_trace", "-lgcov", "-lc"
|
||||
"-lesp_pm", "-lmbedtls", "-lefuse", "-lbootloader_support", "-lapp_update", "-lesp_ipc", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lesp_ringbuf", "-ldriver", "-lxtensa", "-lespcoredump", "-lesp32s2", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lasio", "-lcbor", "-lunity", "-lcmock", "-lcoap", "-lconsole", "-lnghttp", "-lesp-tls", "-lesp_adc_cal", "-lesp_hid", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lesp_https_server", "-lprotobuf-c", "-lprotocomm", "-lmdns", "-lesp_local_ctrl", "-lsdmmc", "-lesp_serial_slave_link", "-lesp_websocket_client", "-lexpat", "-lwear_levelling", "-lfatfs", "-lfreemodbus", "-ljsmn", "-ljson", "-llibsodium", "-lmqtt", "-lopenssl", "-lperfmon", "-lspiffs", "-lulp", "-lwifi_provisioning", "-lesp-dsp", "-lesp-face", "-lesp_littlefs", "-lfb_gfx", "-lasio", "-lcbor", "-lcmock", "-lunity", "-lcoap", "-lesp_hid", "-lesp_local_ctrl", "-lesp_https_server", "-lesp_websocket_client", "-lexpat", "-lfreemodbus", "-ljsmn", "-llibsodium", "-lmqtt", "-lperfmon", "-lwifi_provisioning", "-lprotocomm", "-lprotobuf-c", "-ljson", "-lesp-dsp", "-lesp-face", "-lpe", "-lfd", "-lfr", "-ldetection_cat_face", "-ldetection", "-ldl", "-lesp_littlefs", "-lfb_gfx", "-lesp_adc_cal", "-lmdns", "-lconsole", "-lfatfs", "-lwear_levelling", "-lopenssl", "-lspiffs", "-ltinyusb", "-lesp_pm", "-lmbedtls", "-lefuse", "-lbootloader_support", "-lapp_update", "-lesp_ipc", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lesp_ringbuf", "-ldriver", "-lxtensa", "-lespcoredump", "-lesp32s2", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lrtc", "-lsmartconfig", "-lphy", "-lesp_pm", "-lmbedtls", "-lefuse", "-lbootloader_support", "-lapp_update", "-lesp_ipc", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lesp_ringbuf", "-ldriver", "-lxtensa", "-lespcoredump", "-lesp32s2", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lrtc", "-lsmartconfig", "-lphy", "-lesp_pm", "-lmbedtls", "-lefuse", "-lbootloader_support", "-lapp_update", "-lesp_ipc", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lesp_ringbuf", "-ldriver", "-lxtensa", "-lespcoredump", "-lesp32s2", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lrtc", "-lsmartconfig", "-lphy", "-lesp_pm", "-lmbedtls", "-lefuse", "-lbootloader_support", "-lapp_update", "-lesp_ipc", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lesp_ringbuf", "-ldriver", "-lxtensa", "-lespcoredump", "-lesp32s2", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lrtc", "-lsmartconfig", "-lphy", "-lesp32s2", "-lxt_hal", "-lm", "-lnewlib", "-lgcc", "-lstdc++", "-lpthread", "-lapp_trace", "-lgcov", "-lapp_trace", "-lgcov", "-lc"
|
||||
],
|
||||
|
||||
CPPDEFINES=[
|
||||
|
|
@ -237,7 +260,7 @@ env.Append(
|
|||
"UNITY_INCLUDE_CONFIG_H",
|
||||
"WITH_POSIX",
|
||||
"_GNU_SOURCE",
|
||||
("IDF_VER", '\\"v4.3-dev-1720-g494a124d9-dirty\\"'),
|
||||
("IDF_VER", '\\"v4.3-dev-2398-g2bfdd036b-dirty\\"'),
|
||||
"ESP_PLATFORM",
|
||||
"ARDUINO_ARCH_ESP32",
|
||||
"ESP32",
|
||||
|
|
|
|||
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.
|
|
@ -157,6 +157,18 @@ esp_err_t esp_ota_write_with_offset(esp_ota_handle_t handle, const void *data, s
|
|||
*/
|
||||
esp_err_t esp_ota_end(esp_ota_handle_t handle);
|
||||
|
||||
/**
|
||||
* @brief Abort OTA update, free the handle and memory associated with it.
|
||||
*
|
||||
* @param handle obtained from esp_ota_begin().
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Handle and its associated memory is freed successfully.
|
||||
* - ESP_ERR_NOT_FOUND: OTA handle was not found.
|
||||
*/
|
||||
esp_err_t esp_ota_abort(esp_ota_handle_t handle);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Configure OTA data for a new boot partition
|
||||
*
|
||||
|
|
|
|||
|
|
@ -31,4 +31,3 @@ int bootloader_clock_get_rated_freq_mhz(void);
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@
|
|||
#include "esp32s2/rom/rtc.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/rom/rtc.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/rtc.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -27,4 +27,3 @@
|
|||
*/
|
||||
esp_err_t bootloader_flash_wrap_set(spi_flash_wrap_mode_t mode);
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ typedef enum {
|
|||
ESP_CHIP_ID_ESP32 = 0x0000, /*!< chip ID: ESP32 */
|
||||
ESP_CHIP_ID_ESP32S2 = 0x0002, /*!< chip ID: ESP32-S2 */
|
||||
ESP_CHIP_ID_ESP32S3 = 0x0004, /*!< chip ID: ESP32-S3 */
|
||||
ESP_CHIP_ID_ESP32C3 = 0x0005, /*!< chip ID: ESP32-C3 */
|
||||
ESP_CHIP_ID_INVALID = 0xFFFF /*!< Invalid chip ID (we defined it to make sure the esp_chip_id_t is 2 bytes size) */
|
||||
} __attribute__((packed)) esp_chip_id_t;
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ static inline /** @cond */ IRAM_ATTR /** @endcond */ bool esp_flash_encryption_e
|
|||
uint32_t flash_crypt_cnt = 0;
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
flash_crypt_cnt = REG_GET_FIELD(EFUSE_BLK0_RDATA0_REG, EFUSE_RD_FLASH_CRYPT_CNT);
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
#else
|
||||
flash_crypt_cnt = REG_GET_FIELD(EFUSE_RD_REPEAT_DATA1_REG, EFUSE_SPI_BOOT_CRYPT_CNT);
|
||||
#endif
|
||||
/* __builtin_parity is in flash, so we calculate parity inline */
|
||||
|
|
|
|||
|
|
@ -22,6 +22,10 @@
|
|||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#include "esp32/rom/secure_boot.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
#include "esp32s2/rom/efuse.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/efuse.h"
|
||||
#endif
|
||||
|
||||
typedef struct ets_secure_boot_signature ets_secure_boot_signature_t;
|
||||
|
|
|
|||
|
|
@ -50,4 +50,3 @@ void osi_mutex_global_lock(void);
|
|||
void osi_mutex_global_unlock(void);
|
||||
|
||||
#endif /* __MUTEX_H__ */
|
||||
|
||||
|
|
|
|||
|
|
@ -292,6 +292,8 @@ typedef enum {
|
|||
ESP_BLE_SM_ONLY_ACCEPT_SPECIFIED_SEC_AUTH,
|
||||
/* Enable/Disable OOB support */
|
||||
ESP_BLE_SM_OOB_SUPPORT,
|
||||
/* Appl encryption key size */
|
||||
ESP_BLE_APP_ENC_KEY_SIZE,
|
||||
ESP_BLE_SM_MAX_PARAM,
|
||||
} esp_ble_sm_param_t;
|
||||
|
||||
|
|
@ -915,7 +917,7 @@ esp_err_t esp_ble_gap_update_conn_params(esp_ble_conn_update_params_t *params);
|
|||
esp_err_t esp_ble_gap_set_pkt_data_len(esp_bd_addr_t remote_device, uint16_t tx_data_length);
|
||||
|
||||
/**
|
||||
* @brief This function sets the random address for the application
|
||||
* @brief This function sets the static Random Address and Non-Resolvable Private Address for the application
|
||||
*
|
||||
* @param[in] rand_addr: the random address which should be setting
|
||||
*
|
||||
|
|
@ -1137,6 +1139,20 @@ esp_err_t esp_ble_gap_clean_duplicate_scan_exceptional_list(esp_duplicate_scan_e
|
|||
/**
|
||||
* @brief Set a GAP security parameter value. Overrides the default value.
|
||||
*
|
||||
* Secure connection is highly recommended to avoid some major
|
||||
* vulnerabilities like 'Impersonation in the Pin Pairing Protocol'
|
||||
* (CVE-2020-26555) and 'Authentication of the LE Legacy Pairing
|
||||
* Protocol'.
|
||||
*
|
||||
* To accept only `secure connection mode`, it is necessary do as following:
|
||||
*
|
||||
* 1. Set bit `ESP_LE_AUTH_REQ_SC_ONLY` (`param_type` is
|
||||
* `ESP_BLE_SM_AUTHEN_REQ_MODE`), bit `ESP_LE_AUTH_BOND` and bit
|
||||
* `ESP_LE_AUTH_REQ_MITM` is optional as required.
|
||||
*
|
||||
* 2. Set to `ESP_BLE_ONLY_ACCEPT_SPECIFIED_AUTH_ENABLE` (`param_type` is
|
||||
* `ESP_BLE_SM_ONLY_ACCEPT_SPECIFIED_SEC_AUTH`).
|
||||
*
|
||||
* @param[in] param_type : the type of the param which to be set
|
||||
* @param[in] value : the param value
|
||||
* @param[in] len : the length of the param value
|
||||
|
|
@ -1303,6 +1319,17 @@ esp_err_t esp_ble_get_current_conn_params(esp_bd_addr_t bd_addr, esp_gap_conn_pa
|
|||
*/
|
||||
esp_err_t esp_gap_ble_set_channels(esp_gap_ble_channels channels);
|
||||
|
||||
/**
|
||||
* @brief This function is called to authorized a link after Authentication(MITM protection)
|
||||
*
|
||||
* @param[in] bd_addr: BD address of the peer device.
|
||||
* @param[out] authorize: Authorized the link or not.
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_gap_ble_set_authorization(esp_bd_addr_t bd_addr, bool authorize);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -222,6 +222,7 @@ typedef enum {
|
|||
ESP_BT_GAP_READ_REMOTE_NAME_EVT, /*!< read Remote Name event */
|
||||
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_EVT_MAX,
|
||||
} esp_bt_gap_cb_event_t;
|
||||
|
||||
|
|
@ -364,6 +365,16 @@ typedef union {
|
|||
esp_bt_status_t status; /*!< Indicate the remove bond device operation success status */
|
||||
}remove_bond_dev_cmpl; /*!< Event parameter of ESP_BT_GAP_REMOVE_BOND_DEV_COMPLETE_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_BT_GAP_QOS_CMPL_EVT
|
||||
*/
|
||||
struct qos_cmpl_param {
|
||||
esp_bt_status_t stat; /*!< QoS status */
|
||||
esp_bd_addr_t bda; /*!< remote bluetooth device address*/
|
||||
uint32_t t_poll; /*!< poll interval, the maximum time between transmissions
|
||||
which from the master to a particular slave on the ACL
|
||||
logical transport. unit is 0.625ms. */
|
||||
} qos_cmpl; /*!< QoS complete parameter struct */
|
||||
} esp_bt_gap_cb_param_t;
|
||||
|
||||
/**
|
||||
|
|
@ -720,6 +731,21 @@ esp_err_t esp_bt_gap_set_afh_channels(esp_bt_gap_afh_channels channels);
|
|||
*/
|
||||
esp_err_t esp_bt_gap_read_remote_name(esp_bd_addr_t remote_bda);
|
||||
|
||||
/**
|
||||
* @brief Config Quality of service
|
||||
*
|
||||
* @param[in] remote_bda: The remote device's address
|
||||
* @param[in] t_poll: Poll interval, the maximum time between transmissions
|
||||
which from the master to a particular slave on the ACL
|
||||
logical transport. unit is 0.625ms
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - ESP_ERR_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_bt_gap_set_qos(esp_bd_addr_t remote_bda, uint32_t t_poll);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -283,6 +283,8 @@ typedef enum {
|
|||
#define ESP_GATT_PERM_WRITE_ENC_MITM (1 << 6) /* bit 6 - 0x0040 */ /* relate to BTA_GATT_PERM_WRITE_ENC_MITM in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_WRITE_SIGNED (1 << 7) /* bit 7 - 0x0080 */ /* relate to BTA_GATT_PERM_WRITE_SIGNED in bta/bta_gatt_api.h */
|
||||
#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 */
|
||||
typedef uint16_t esp_gatt_perm_t;
|
||||
|
||||
/* relate to BTA_GATT_CHAR_PROP_BIT_xxx in bta/bta_gatt_api.h */
|
||||
|
|
|
|||
|
|
@ -613,6 +613,29 @@ esp_err_t esp_ble_gattc_read_char (esp_gatt_if_t gattc_if,
|
|||
uint16_t handle,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
|
||||
/**
|
||||
* @brief This function is called to read a service's characteristics of
|
||||
* the given characteristic UUID
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] conn_id : connection ID.
|
||||
* @param[in] start_handle : the attribute start handle.
|
||||
* @param[in] end_handle : the attribute end handle
|
||||
* @param[in] uuid : The UUID of attribute which will be read.
|
||||
* @param[in] auth_req : authenticate request type
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_read_by_type (esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
uint16_t start_handle,
|
||||
uint16_t end_handle,
|
||||
esp_bt_uuid_t *uuid,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
|
||||
/**
|
||||
* @brief This function is called to read multiple characteristic or
|
||||
* characteristic descriptors.
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
*/
|
||||
#pragma once
|
||||
#define CONFIG_IDF_CMAKE 1
|
||||
#define CONFIG_IDF_TARGET_ARCH_XTENSA 1
|
||||
#define CONFIG_IDF_TARGET "esp32"
|
||||
#define CONFIG_IDF_TARGET_ESP32 1
|
||||
#define CONFIG_IDF_FIRMWARE_CHIP_ID 0x0000
|
||||
|
|
@ -202,6 +203,7 @@
|
|||
#define CONFIG_ESP_MINIMAL_SHARED_STACK_SIZE 2048
|
||||
#define CONFIG_ESP_CONSOLE_UART_DEFAULT 1
|
||||
#define CONFIG_ESP_CONSOLE_UART 1
|
||||
#define CONFIG_ESP_CONSOLE_MULTIPLE_UART 1
|
||||
#define CONFIG_ESP_CONSOLE_UART_NUM 0
|
||||
#define CONFIG_ESP_CONSOLE_UART_BAUDRATE 115200
|
||||
#define CONFIG_ESP_INT_WDT 1
|
||||
|
|
@ -226,6 +228,7 @@
|
|||
#define CONFIG_ETH_DMA_TX_BUFFER_NUM 10
|
||||
#define CONFIG_ETH_USE_SPI_ETHERNET 1
|
||||
#define CONFIG_ETH_SPI_ETHERNET_DM9051 1
|
||||
#define CONFIG_ETH_SPI_ETHERNET_W5500 1
|
||||
#define CONFIG_ESP_EVENT_POST_FROM_ISR 1
|
||||
#define CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR 1
|
||||
#define CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS 1
|
||||
|
|
@ -332,7 +335,6 @@
|
|||
#define CONFIG_LWIP_DHCPS_MAX_STATION_NUM 8
|
||||
#define CONFIG_LWIP_NETIF_LOOPBACK 1
|
||||
#define CONFIG_LWIP_LOOPBACK_MAX_PBUFS 8
|
||||
#define CONFIG_LWIP_TCP_ISN_HOOK 1
|
||||
#define CONFIG_LWIP_MAX_ACTIVE_TCP 16
|
||||
#define CONFIG_LWIP_MAX_LISTENING_TCP 16
|
||||
#define CONFIG_LWIP_TCP_HIGH_SPEED_RETRANSMISSION 1
|
||||
|
|
@ -349,6 +351,7 @@
|
|||
#define CONFIG_LWIP_TCP_RTO_TIME 3000
|
||||
#define CONFIG_LWIP_MAX_UDP_PCBS 16
|
||||
#define CONFIG_LWIP_UDP_RECVMBOX_SIZE 6
|
||||
#define CONFIG_LWIP_CHECKSUM_CHECK_ICMP 1
|
||||
#define CONFIG_LWIP_TCPIP_TASK_STACK_SIZE 2560
|
||||
#define CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0 1
|
||||
#define CONFIG_LWIP_TCPIP_TASK_AFFINITY 0x0
|
||||
|
|
@ -364,6 +367,9 @@
|
|||
#define CONFIG_LWIP_DHCP_MAX_NTP_SERVERS 1
|
||||
#define CONFIG_LWIP_SNTP_UPDATE_DELAY 3600000
|
||||
#define CONFIG_LWIP_ESP_LWIP_ASSERT 1
|
||||
#define CONFIG_LWIP_HOOK_TCP_ISN_DEFAULT 1
|
||||
#define CONFIG_LWIP_HOOK_IP6_ROUTE_NONE 1
|
||||
#define CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE 1
|
||||
#define CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC 1
|
||||
#define CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN 16384
|
||||
#define CONFIG_MBEDTLS_CERTIFICATE_BUNDLE 1
|
||||
|
|
@ -445,9 +451,9 @@
|
|||
#define CONFIG_SPI_FLASH_ROM_DRIVER_PATCH 1
|
||||
#define CONFIG_SPI_FLASH_DANGEROUS_WRITE_ABORTS 1
|
||||
#define CONFIG_SPI_FLASH_YIELD_DURING_ERASE 1
|
||||
#define CONFIG_SPI_FLASH_ERASE_YIELD_DURATION_MS 20
|
||||
#define CONFIG_SPI_FLASH_ERASE_YIELD_TICKS 1
|
||||
#define CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE 8192
|
||||
#define CONFIG_SPI_FLASH_ERASE_YIELD_DURATION_MS 10
|
||||
#define CONFIG_SPI_FLASH_ERASE_YIELD_TICKS 2
|
||||
#define CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE 4096
|
||||
#define CONFIG_SPI_FLASH_SUPPORT_ISSI_CHIP 1
|
||||
#define CONFIG_SPI_FLASH_SUPPORT_MXIC_CHIP 1
|
||||
#define CONFIG_SPI_FLASH_SUPPORT_GD_CHIP 1
|
||||
|
|
@ -480,6 +486,10 @@
|
|||
#define CONFIG_WIFI_PROV_AUTOSTOP_TIMEOUT 30
|
||||
#define CONFIG_WPA_MBEDTLS_CRYPTO 1
|
||||
#define CONFIG_IO_GLITCH_FILTER_TIME_MS 50
|
||||
#define CONFIG_DSP_OPTIMIZED 1
|
||||
#define CONFIG_DSP_OPTIMIZATION 1
|
||||
#define CONFIG_DSP_MAX_FFT_SIZE_4096 1
|
||||
#define CONFIG_DSP_MAX_FFT_SIZE 4096
|
||||
#define CONFIG_XTENSA_IMPL 1
|
||||
#define CONFIG_MTMN_LITE_QUANT 1
|
||||
#define CONFIG_MFN56_1X 1
|
||||
|
|
@ -586,7 +596,6 @@
|
|||
#define CONFIG_SPIRAM_SUPPORT CONFIG_ESP32_SPIRAM_SUPPORT
|
||||
#define CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS CONFIG_SPI_FLASH_DANGEROUS_WRITE_ABORTS
|
||||
#define CONFIG_STACK_CHECK_NORM CONFIG_COMPILER_STACK_CHECK_MODE_NORM
|
||||
#define CONFIG_SUPPORT_STATIC_ALLOCATION CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION
|
||||
#define CONFIG_SUPPORT_TERMIOS CONFIG_VFS_SUPPORT_TERMIOS
|
||||
#define CONFIG_SUPPRESS_SELECT_DEBUG_OUTPUT CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT
|
||||
#define CONFIG_SW_COEXIST_ENABLE CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
|
||||
|
|
@ -617,5 +626,5 @@
|
|||
#define CONFIG_ULP_COPROC_ENABLED CONFIG_ESP32_ULP_COPROC_ENABLED
|
||||
#define CONFIG_ULP_COPROC_RESERVE_MEM CONFIG_ESP32_ULP_COPROC_RESERVE_MEM
|
||||
#define CONFIG_WARN_WRITE_STRINGS CONFIG_COMPILER_WARN_WRITE_STRINGS
|
||||
#define CONFIG_ARDUINO_IDF_COMMIT "494a124d9"
|
||||
#define CONFIG_ARDUINO_IDF_COMMIT "2bfdd036b"
|
||||
#define CONFIG_ARDUINO_IDF_BRANCH "master"
|
||||
|
|
|
|||
|
|
@ -100,6 +100,20 @@ typedef struct {
|
|||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Parameters for console device: USB CDC
|
||||
*
|
||||
* @note It's an empty structure for now, reserved for future
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
|
||||
} esp_console_dev_usb_cdc_config_t;
|
||||
|
||||
#define ESP_CONSOLE_DEV_CDC_CONFIG_DEFAULT() \
|
||||
{ \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief initialize console module
|
||||
* @param config console configuration
|
||||
|
|
@ -304,6 +318,27 @@ struct esp_console_repl_s {
|
|||
*/
|
||||
esp_err_t esp_console_new_repl_uart(const esp_console_dev_uart_config_t *dev_config, const esp_console_repl_config_t *repl_config, esp_console_repl_t **ret_repl);
|
||||
|
||||
/**
|
||||
* @brief Establish a console REPL environment over USB CDC
|
||||
*
|
||||
* @param[in] dev_config USB CDC configuration
|
||||
* @param[in] repl_config REPL configuration
|
||||
* @param[out] ret_repl return REPL handle after initialization succeed, return NULL otherwise
|
||||
*
|
||||
* @note This is a all-in-one function to establish the environment needed for REPL, includes:
|
||||
* - Initializes linenoise
|
||||
* - Spawn new thread to run REPL in the background
|
||||
*
|
||||
* @attention This function is meant to be used in the examples to make the code more compact.
|
||||
* Applications which use console functionality should be based on
|
||||
* the underlying linenoise and esp_console functions.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
esp_err_t esp_console_new_repl_usb_cdc(const esp_console_dev_usb_cdc_config_t *dev_config, const esp_console_repl_config_t *repl_config, esp_console_repl_t **ret_repl);
|
||||
|
||||
/**
|
||||
* @brief Start REPL environment
|
||||
* @param[in] repl REPL handle returned from esp_console_new_repl_xxx
|
||||
|
|
|
|||
|
|
@ -55,4 +55,3 @@ void adc2_cal_include(void);
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -24,25 +24,47 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
/**** `adc1_channel_t` will be deprecated functions, combine into `adc_channel_t` ********/
|
||||
typedef enum {
|
||||
ADC1_CHANNEL_0 = 0, /*!< ADC1 channel 0 is GPIO36 (ESP32), GPIO1 (ESP32-S2) */
|
||||
ADC1_CHANNEL_1, /*!< ADC1 channel 1 is GPIO37 (ESP32), GPIO2 (ESP32-S2) */
|
||||
ADC1_CHANNEL_2, /*!< ADC1 channel 2 is GPIO38 (ESP32), GPIO3 (ESP32-S2) */
|
||||
ADC1_CHANNEL_3, /*!< ADC1 channel 3 is GPIO39 (ESP32), GPIO4 (ESP32-S2) */
|
||||
ADC1_CHANNEL_4, /*!< ADC1 channel 4 is GPIO32 (ESP32), GPIO5 (ESP32-S2) */
|
||||
ADC1_CHANNEL_5, /*!< ADC1 channel 5 is GPIO33 (ESP32), GPIO6 (ESP32-S2) */
|
||||
ADC1_CHANNEL_6, /*!< ADC1 channel 6 is GPIO34 (ESP32), GPIO7 (ESP32-S2) */
|
||||
ADC1_CHANNEL_7, /*!< ADC1 channel 7 is GPIO35 (ESP32), GPIO8 (ESP32-S2) */
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
ADC1_CHANNEL_0 = 0, /*!< ADC1 channel 0 is GPIO36 */
|
||||
ADC1_CHANNEL_1, /*!< ADC1 channel 1 is GPIO37 */
|
||||
ADC1_CHANNEL_2, /*!< ADC1 channel 2 is GPIO38 */
|
||||
ADC1_CHANNEL_3, /*!< ADC1 channel 3 is GPIO39 */
|
||||
ADC1_CHANNEL_4, /*!< ADC1 channel 4 is GPIO32 */
|
||||
ADC1_CHANNEL_5, /*!< ADC1 channel 5 is GPIO33 */
|
||||
ADC1_CHANNEL_6, /*!< ADC1 channel 6 is GPIO34 */
|
||||
ADC1_CHANNEL_7, /*!< ADC1 channel 7 is GPIO35 */
|
||||
ADC1_CHANNEL_MAX,
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
ADC1_CHANNEL_8, /*!< ADC1 channel 6 is GPIO9 (ESP32-S2)*/
|
||||
ADC1_CHANNEL_9, /*!< ADC1 channel 7 is GPIO10 (ESP32-S2) */
|
||||
ADC1_CHANNEL_MAX,
|
||||
#endif
|
||||
} adc1_channel_t;
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 // TODO ESP32-S3 channels are wrong IDF-1776
|
||||
/**** `adc1_channel_t` will be deprecated functions, combine into `adc_channel_t` ********/
|
||||
typedef enum {
|
||||
ADC1_CHANNEL_0 = 0, /*!< ADC1 channel 0 is GPIO1 */
|
||||
ADC1_CHANNEL_1, /*!< ADC1 channel 1 is GPIO2 */
|
||||
ADC1_CHANNEL_2, /*!< ADC1 channel 2 is GPIO3 */
|
||||
ADC1_CHANNEL_3, /*!< ADC1 channel 3 is GPIO4 */
|
||||
ADC1_CHANNEL_4, /*!< ADC1 channel 4 is GPIO5 */
|
||||
ADC1_CHANNEL_5, /*!< ADC1 channel 5 is GPIO6 */
|
||||
ADC1_CHANNEL_6, /*!< ADC1 channel 6 is GPIO7 */
|
||||
ADC1_CHANNEL_7, /*!< ADC1 channel 7 is GPIO8 */
|
||||
ADC1_CHANNEL_8, /*!< ADC1 channel 6 is GPIO9 */
|
||||
ADC1_CHANNEL_9, /*!< ADC1 channel 7 is GPIO10 */
|
||||
ADC1_CHANNEL_MAX,
|
||||
} adc1_channel_t;
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
/**** `adc1_channel_t` will be deprecated functions, combine into `adc_channel_t` ********/
|
||||
typedef enum {
|
||||
ADC1_CHANNEL_0 = 0, /*!< ADC1 channel 0 is GPIO0 */
|
||||
ADC1_CHANNEL_1, /*!< ADC1 channel 1 is GPIO1 */
|
||||
ADC1_CHANNEL_2, /*!< ADC1 channel 2 is GPIO2 */
|
||||
ADC1_CHANNEL_3, /*!< ADC1 channel 3 is GPIO3 */
|
||||
ADC1_CHANNEL_4, /*!< ADC1 channel 4 is GPIO34 */
|
||||
ADC1_CHANNEL_MAX,
|
||||
} adc1_channel_t;
|
||||
#endif // CONFIG_IDF_TARGET_*
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 // TODO ESP32-S3 channels are wrong IDF-1776
|
||||
/**** `adc2_channel_t` will be deprecated functions, combine into `adc_channel_t` ********/
|
||||
typedef enum {
|
||||
ADC2_CHANNEL_0 = 0, /*!< ADC2 channel 0 is GPIO4 (ESP32), GPIO11 (ESP32-S2) */
|
||||
|
|
@ -57,6 +79,14 @@ typedef enum {
|
|||
ADC2_CHANNEL_9, /*!< ADC2 channel 9 is GPIO26 (ESP32), GPIO20 (ESP32-S2) */
|
||||
ADC2_CHANNEL_MAX,
|
||||
} adc2_channel_t;
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
/**** `adc2_channel_t` will be deprecated functions, combine into `adc_channel_t` ********/
|
||||
typedef enum {
|
||||
ADC2_CHANNEL_0 = 0, /*!< ADC2 channel 0 is GPIO5 */
|
||||
ADC2_CHANNEL_MAX,
|
||||
} adc2_channel_t;
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief ADC rtc controller attenuation option.
|
||||
|
|
@ -73,6 +103,13 @@ typedef enum {
|
|||
#define ADC_WIDTH_11Bit ADC_WIDTH_BIT_11
|
||||
#define ADC_WIDTH_12Bit ADC_WIDTH_BIT_12
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32C3
|
||||
/**
|
||||
* @brief Digital ADC DMA read max timeout value, it may make the ``adc_digi_read_bytes`` block forever if the OS supports
|
||||
*/
|
||||
#define ADC_MAX_DELAY UINT32_MAX
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief ADC digital controller encode option.
|
||||
*
|
||||
|
|
@ -84,20 +121,52 @@ typedef enum {
|
|||
ADC_ENCODE_MAX,
|
||||
} adc_i2s_encode_t;
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32C3
|
||||
//This feature is currently supported on ESP32C3, will be supported on other chips soon
|
||||
/**
|
||||
* @brief Digital ADC DMA configuration
|
||||
*/
|
||||
typedef struct adc_digi_init_config_s {
|
||||
uint32_t max_store_buf_size; ///< Max length of the converted data that driver can store before they are processed. When this length is reached, driver will dump out all the old data and start to store them again.
|
||||
uint32_t conv_num_each_intr; ///< Bytes of data that can be converted in 1 interrupt.
|
||||
uint32_t dma_chan; ///< DMA channel.
|
||||
uint16_t adc1_chan_mask; ///< Channel list of ADC1 to be initialized.
|
||||
uint16_t adc2_chan_mask; ///< Channel list of ADC2 to be initialized.
|
||||
} adc_digi_init_config_t;
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
Common setting
|
||||
---------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief Enable ADC power
|
||||
* @deprecated Use adc_power_acquire and adc_power_release instead.
|
||||
*/
|
||||
void adc_power_on(void);
|
||||
void adc_power_on(void) __attribute__((deprecated));
|
||||
|
||||
/**
|
||||
* @brief Power off SAR ADC
|
||||
* This function will force power down for ADC
|
||||
* @deprecated Use adc_power_acquire and adc_power_release instead.
|
||||
* This function will force power down for ADC.
|
||||
* This function is deprecated because forcing power ADC power off may
|
||||
* disrupt operation of other components which may be using the ADC.
|
||||
*/
|
||||
void adc_power_off(void);
|
||||
void adc_power_off(void) __attribute__((deprecated));
|
||||
|
||||
/**
|
||||
* @brief Increment the usage counter for ADC module.
|
||||
* ADC will stay powered on while the counter is greater than 0.
|
||||
* Call adc_power_release when done using the ADC.
|
||||
*/
|
||||
void adc_power_acquire(void);
|
||||
|
||||
/**
|
||||
* @brief Decrement the usage counter for ADC module.
|
||||
* ADC will stay powered on while the counter is greater than 0.
|
||||
* Call this function when done using the ADC.
|
||||
*/
|
||||
void adc_power_release(void);
|
||||
|
||||
/**
|
||||
* @brief Initialize ADC pad
|
||||
|
|
@ -199,6 +268,8 @@ esp_err_t adc1_config_width(adc_bits_width_t width_bit);
|
|||
* the input of GPIO36 and GPIO39 will be pulled down for about 80ns.
|
||||
* When enabling power for any of these peripherals, ignore input from GPIO36 and GPIO39.
|
||||
* Please refer to section 3.11 of 'ECO_and_Workarounds_for_Bugs_in_ESP32' for the description of this issue.
|
||||
* As a workaround, call adc_power_acquire() in the app. This will result in higher power consumption (by ~1mA),
|
||||
* but will remove the glitches on GPIO36 and GPIO39.
|
||||
*
|
||||
* @note Call ``adc1_config_width()`` before the first time this
|
||||
* function is called.
|
||||
|
|
@ -236,10 +307,8 @@ esp_err_t adc_set_clk_div(uint8_t clk_div);
|
|||
/**
|
||||
* @brief Configure ADC capture width.
|
||||
*
|
||||
* @note ESP32-S2 only supports ``ADC_WIDTH_BIT_13``.
|
||||
*
|
||||
* @param adc_unit ADC unit index
|
||||
* @param width_bit Bit capture width for ADC unit. ESP32-S2 only supports ``ADC_WIDTH_BIT_13``.
|
||||
* @param width_bit Bit capture width for ADC unit.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
|
|
@ -312,6 +381,9 @@ esp_err_t adc2_config_channel_atten(adc2_channel_t channel, adc_atten_t atten);
|
|||
* the input of GPIO36 and GPIO39 will be pulled down for about 80ns.
|
||||
* When enabling power for any of these peripherals, ignore input from GPIO36 and GPIO39.
|
||||
* Please refer to section 3.11 of 'ECO_and_Workarounds_for_Bugs_in_ESP32' for the description of this issue.
|
||||
* As a workaround, call adc_power_acquire() in the app. This will result in higher power consumption (by ~1mA),
|
||||
* but will remove the glitches on GPIO36 and GPIO39.
|
||||
*
|
||||
*
|
||||
* @note ESP32:
|
||||
* For a given channel, ``adc2_config_channel_atten()``
|
||||
|
|
@ -323,7 +395,7 @@ esp_err_t adc2_config_channel_atten(adc2_channel_t channel, adc_atten_t atten);
|
|||
* the low priority controller will read the invalid ADC2 data. Default priority: Wi-Fi > RTC > Digital;
|
||||
*
|
||||
* @param channel ADC2 channel to read
|
||||
* @param width_bit Bit capture width for ADC2. ESP32-S2 only supports ``ADC_WIDTH_BIT_13``.
|
||||
* @param width_bit Bit capture width for ADC2
|
||||
* @param raw_out the variable to hold the output data.
|
||||
*
|
||||
* @return
|
||||
|
|
@ -369,7 +441,8 @@ esp_err_t adc2_vref_to_gpio(gpio_num_t gpio) __attribute__((deprecated));
|
|||
/*---------------------------------------------------------------
|
||||
Digital controller setting
|
||||
---------------------------------------------------------------*/
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
|
||||
//These APIs are only supported on ESP32 and ESP32-S2. On ESP32-C3 and later chips, please use ``adc_digi_initialize`` and ``adc_digi_deinitialize``
|
||||
/**
|
||||
* @brief ADC digital controller initialization.
|
||||
* @return
|
||||
|
|
@ -383,17 +456,81 @@ esp_err_t adc_digi_init(void);
|
|||
* - ESP_OK Success
|
||||
*/
|
||||
esp_err_t adc_digi_deinit(void);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Setting the digital controller.
|
||||
*
|
||||
* @param config Pointer to digital controller paramter. Refer to `adc_digi_config_t`.
|
||||
* @param config Pointer to digital controller paramter. Refer to ``adc_digi_config_t``.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_STATE Driver state is invalid.
|
||||
* - ESP_OK On success
|
||||
*/
|
||||
esp_err_t adc_digi_controller_config(const adc_digi_config_t *config);
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32C3
|
||||
//This feature is currently supported on ESP32C3, will be supported on other chips soon
|
||||
/*---------------------------------------------------------------
|
||||
DMA setting
|
||||
---------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Initialize the Digital ADC.
|
||||
*
|
||||
* @param init_config Pointer to Digital ADC initilisation config. Refer to ``adc_digi_init_config_t``.
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG If the combination of arguments is invalid.
|
||||
* - ESP_ERR_NOT_FOUND No free interrupt found with the specified flags
|
||||
* - ESP_ERR_NO_MEM If out of memory
|
||||
* - ESP_OK On success
|
||||
*/
|
||||
esp_err_t adc_digi_initialize(const adc_digi_init_config_t *init_config);
|
||||
|
||||
/**
|
||||
* @brief Start the Digital ADC and DMA peripherals. After this, the hardware starts working.
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_STATE Driver state is invalid.
|
||||
* - ESP_OK On success
|
||||
*/
|
||||
esp_err_t adc_digi_start(void);
|
||||
|
||||
/**
|
||||
* @brief Stop the Digital ADC and DMA peripherals. After this, the hardware stops working.
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_STATE Driver state is invalid.
|
||||
* - ESP_OK On success
|
||||
*/
|
||||
esp_err_t adc_digi_stop(void);
|
||||
|
||||
/**
|
||||
* @brief Read bytes from Digital ADC through DMA.
|
||||
*
|
||||
* @param[out] buf Buffer to read from ADC.
|
||||
* @param[in] length_max Expected length of data read from the ADC.
|
||||
* @param[out] out_length Real length of data read from the ADC via this API.
|
||||
* @param[in] timeout_ms Time to wait for data via this API, in millisecond.
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_STATE Driver state is invalid. Usually it means the ADC sampling rate is faster than the task processing rate.
|
||||
* - ESP_ERR_TIMEOUT Operation timed out
|
||||
* - ESP_OK On success
|
||||
*/
|
||||
esp_err_t adc_digi_read_bytes(uint8_t *buf, uint32_t length_max, uint32_t *out_length, uint32_t timeout_ms);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize the Digital ADC.
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_STATE Driver state is invalid.
|
||||
* - ESP_OK On success
|
||||
*/
|
||||
esp_err_t adc_digi_deinitialize(void);
|
||||
|
||||
#endif //#if CONFIG_IDF_TARGET_ESP32C3
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -96,4 +96,3 @@ esp_err_t dac_cw_generator_config(dac_cw_config_t *cw);
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@
|
|||
#include "esp32/rom/gpio.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
#include "esp32s2/rom/gpio.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/gpio.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LEGACY_INCLUDE_COMMON_HEADERS
|
||||
|
|
@ -93,9 +95,11 @@ esp_err_t gpio_set_intr_type(gpio_num_t gpio_num, gpio_int_type_t intr_type);
|
|||
/**
|
||||
* @brief Enable GPIO module interrupt signal
|
||||
*
|
||||
* @note Please do not use the interrupt of GPIO36 and GPIO39 when using ADC.
|
||||
* @note Please do not use the interrupt of GPIO36 and GPIO39 when using ADC or Wi-Fi with sleep mode enabled.
|
||||
* Please refer to the comments of `adc1_get_raw`.
|
||||
* Please refer to section 3.11 of 'ECO_and_Workarounds_for_Bugs_in_ESP32' for the description of this issue.
|
||||
* As a workaround, call adc_power_acquire() in the app. This will result in higher power consumption (by ~1mA),
|
||||
* but will remove the glitches on GPIO36 and GPIO39.
|
||||
*
|
||||
* @param gpio_num GPIO number. If you want to enable an interrupt on e.g. GPIO16, gpio_num should be GPIO_NUM_16 (16);
|
||||
*
|
||||
|
|
@ -444,4 +448,3 @@ esp_err_t gpio_force_unhold_all(void);
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
@ -24,7 +24,6 @@ extern "C" {
|
|||
#include "esp_intr_alloc.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/xtensa_api.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/ringbuf.h"
|
||||
|
|
|
|||
|
|
@ -662,4 +662,3 @@ esp_err_t mcpwm_isr_register(mcpwm_unit_t mcpwm_num, void (*fn)(void *), void *a
|
|||
#endif
|
||||
|
||||
#endif //SOC_MCPWM_SUPPORTED
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,11 @@ extern "C" {
|
|||
#include "soc/rmt_struct.h"
|
||||
#include "hal/rmt_types.h"
|
||||
|
||||
#define RMT_CHANNEL_FLAGS_ALWAYS_ON (1 << 0) /*!< Channel can work when APB frequency is changing (RMT channel adopts REF_TICK as clock source) */
|
||||
#define RMT_CHANNEL_FLAGS_AWARE_DFS (1 << 0) /*!< Channel can work during APB clock scaling */
|
||||
|
||||
/** @cond */
|
||||
#define RMT_CHANNEL_FLAGS_ALWAYS_ON RMT_CHANNEL_FLAGS_AWARE_DFS /*!< Deprecated name, defined here for compatibility */
|
||||
/** @endcond */
|
||||
|
||||
/**
|
||||
* @brief Define memory space of each RMT channel (in words = 4 bytes)
|
||||
|
|
@ -357,7 +361,7 @@ esp_err_t rmt_rx_start(rmt_channel_t channel, bool rx_idx_rst);
|
|||
esp_err_t rmt_rx_stop(rmt_channel_t channel);
|
||||
|
||||
/**
|
||||
* @brief Reset RMT TX/RX memory index.
|
||||
* @brief Reset RMT TX memory
|
||||
*
|
||||
* @param channel RMT channel
|
||||
*
|
||||
|
|
@ -365,7 +369,18 @@ esp_err_t rmt_rx_stop(rmt_channel_t channel);
|
|||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_OK Success
|
||||
*/
|
||||
esp_err_t rmt_memory_rw_rst(rmt_channel_t channel);
|
||||
esp_err_t rmt_tx_memory_reset(rmt_channel_t channel);
|
||||
|
||||
/**
|
||||
* @brief Reset RMT RX memory
|
||||
*
|
||||
* @param channel RMT channel
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_OK Success
|
||||
*/
|
||||
esp_err_t rmt_rx_memory_reset(rmt_channel_t channel);
|
||||
|
||||
/**
|
||||
* @brief Set RMT memory owner.
|
||||
|
|
@ -504,22 +519,6 @@ esp_err_t rmt_get_idle_level(rmt_channel_t channel, bool *idle_out_en, rmt_idle_
|
|||
*/
|
||||
esp_err_t rmt_get_status(rmt_channel_t channel, uint32_t *status);
|
||||
|
||||
/**
|
||||
* @brief Set mask value to RMT interrupt enable register.
|
||||
*
|
||||
* @param mask Bit mask to set to the register
|
||||
*
|
||||
*/
|
||||
void rmt_set_intr_enable_mask(uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Clear mask value to RMT interrupt enable register.
|
||||
*
|
||||
* @param mask Bit mask to clear the register
|
||||
*
|
||||
*/
|
||||
void rmt_clr_intr_enable_mask(uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Set RMT RX interrupt enable
|
||||
*
|
||||
|
|
@ -833,6 +832,36 @@ esp_err_t rmt_add_channel_to_group(rmt_channel_t channel);
|
|||
esp_err_t rmt_remove_channel_from_group(rmt_channel_t channel);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Reset RMT TX/RX memory index.
|
||||
*
|
||||
* @param channel RMT channel
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_OK Success
|
||||
*/
|
||||
esp_err_t rmt_memory_rw_rst(rmt_channel_t channel)
|
||||
__attribute__((deprecated("use rmt_tx_memory_reset or rmt_rx_memory_reset instead")));
|
||||
|
||||
/**
|
||||
* @brief Set mask value to RMT interrupt enable register.
|
||||
*
|
||||
* @param mask Bit mask to set to the register
|
||||
*
|
||||
*/
|
||||
void rmt_set_intr_enable_mask(uint32_t mask)
|
||||
__attribute__((deprecated("interrupt should be handled by driver")));
|
||||
|
||||
/**
|
||||
* @brief Clear mask value to RMT interrupt enable register.
|
||||
*
|
||||
* @param mask Bit mask to clear the register
|
||||
*
|
||||
*/
|
||||
void rmt_clr_intr_enable_mask(uint32_t mask)
|
||||
__attribute__((deprecated("interrupt should be handled by driver")));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/rtc_io_periph.h"
|
||||
#include "hal/rtc_io_types.h"
|
||||
#ifdef __cplusplus
|
||||
|
|
@ -32,8 +33,11 @@ extern "C" {
|
|||
*/
|
||||
static inline bool rtc_gpio_is_valid_gpio(gpio_num_t gpio_num)
|
||||
{
|
||||
return (gpio_num < GPIO_PIN_COUNT
|
||||
&& rtc_io_num_map[gpio_num] >= 0);
|
||||
#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|
||||
return (gpio_num < GPIO_PIN_COUNT && rtc_io_num_map[gpio_num] >= 0);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
#define RTC_GPIO_IS_VALID_GPIO(gpio_num) rtc_gpio_is_valid_gpio(gpio_num) // Deprecated, use rtc_gpio_is_valid_gpio()
|
||||
|
|
@ -48,9 +52,15 @@ static inline bool rtc_gpio_is_valid_gpio(gpio_num_t gpio_num)
|
|||
*/
|
||||
static inline int rtc_io_number_get(gpio_num_t gpio_num)
|
||||
{
|
||||
#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|
||||
return rtc_io_num_map[gpio_num];
|
||||
#else
|
||||
return gpio_num;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|
||||
|
||||
/**
|
||||
* @brief Init a GPIO as RTC GPIO
|
||||
*
|
||||
|
|
@ -186,6 +196,34 @@ esp_err_t rtc_gpio_pullup_dis(gpio_num_t gpio_num);
|
|||
*/
|
||||
esp_err_t rtc_gpio_pulldown_dis(gpio_num_t gpio_num);
|
||||
|
||||
/**
|
||||
* @brief Set RTC GPIO pad drive capability
|
||||
*
|
||||
* @param gpio_num GPIO number, only support output GPIOs
|
||||
* @param strength Drive capability of the pad
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t rtc_gpio_set_drive_capability(gpio_num_t gpio_num, gpio_drive_cap_t strength);
|
||||
|
||||
/**
|
||||
* @brief Get RTC GPIO pad drive capability
|
||||
*
|
||||
* @param gpio_num GPIO number, only support output GPIOs
|
||||
* @param strength Pointer to accept drive capability of the pad
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t rtc_gpio_get_drive_capability(gpio_num_t gpio_num, gpio_drive_cap_t* strength);
|
||||
|
||||
#endif // SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|
||||
|
||||
#if SOC_RTCIO_HOLD_SUPPORTED
|
||||
|
||||
/**
|
||||
* @brief Enable hold function on an RTC IO pad
|
||||
*
|
||||
|
|
@ -249,29 +287,9 @@ esp_err_t rtc_gpio_force_hold_all(void);
|
|||
*/
|
||||
esp_err_t rtc_gpio_force_hold_dis_all(void);
|
||||
|
||||
/**
|
||||
* @brief Set RTC GPIO pad drive capability
|
||||
*
|
||||
* @param gpio_num GPIO number, only support output GPIOs
|
||||
* @param strength Drive capability of the pad
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t rtc_gpio_set_drive_capability(gpio_num_t gpio_num, gpio_drive_cap_t strength);
|
||||
#endif // SOC_RTCIO_HOLD_SUPPORTED
|
||||
|
||||
/**
|
||||
* @brief Get RTC GPIO pad drive capability
|
||||
*
|
||||
* @param gpio_num GPIO number, only support output GPIOs
|
||||
* @param strength Pointer to accept drive capability of the pad
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t rtc_gpio_get_drive_capability(gpio_num_t gpio_num, gpio_drive_cap_t* strength);
|
||||
#if SOC_RTCIO_WAKE_SUPPORTED
|
||||
|
||||
/**
|
||||
* @brief Enable wakeup from sleep mode using specific GPIO
|
||||
|
|
@ -294,6 +312,8 @@ esp_err_t rtc_gpio_wakeup_enable(gpio_num_t gpio_num, gpio_int_type_t intr_type)
|
|||
*/
|
||||
esp_err_t rtc_gpio_wakeup_disable(gpio_num_t gpio_num);
|
||||
|
||||
#endif // SOC_RTCIO_WAKE_SUPPORTED
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -275,5 +275,3 @@ esp_err_t sdio_slave_wait_int(int pos, TickType_t wait);
|
|||
#endif
|
||||
|
||||
#endif /*_DRIVER_SDIO_SLAVE_H */
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
/** SPI master clock is divided by 80MHz apb clock. Below defines are example frequencies, and are accurate. Be free to specify a random frequency, it will be rounded to closest frequency (to macros below if above 8MHz).
|
||||
* 8MHz
|
||||
*/
|
||||
#if APB_CLK_FREQ==80*1000*1000
|
||||
#define SPI_MASTER_FREQ_8M (APB_CLK_FREQ/10)
|
||||
#define SPI_MASTER_FREQ_9M (APB_CLK_FREQ/9) ///< 8.89MHz
|
||||
#define SPI_MASTER_FREQ_10M (APB_CLK_FREQ/8) ///< 10MHz
|
||||
|
|
@ -33,14 +32,6 @@
|
|||
#define SPI_MASTER_FREQ_26M (APB_CLK_FREQ/3) ///< 26.67MHz
|
||||
#define SPI_MASTER_FREQ_40M (APB_CLK_FREQ/2) ///< 40MHz
|
||||
#define SPI_MASTER_FREQ_80M (APB_CLK_FREQ/1) ///< 80MHz
|
||||
#elif APB_CLK_FREQ==40*1000*1000
|
||||
#define SPI_MASTER_FREQ_7M (APB_CLK_FREQ/6) ///< 13.33MHz
|
||||
#define SPI_MASTER_FREQ_8M (APB_CLK_FREQ/5) ///< 16MHz
|
||||
#define SPI_MASTER_FREQ_10M (APB_CLK_FREQ/4) ///< 20MHz
|
||||
#define SPI_MASTER_FREQ_13M (APB_CLK_FREQ/3) ///< 26.67MHz
|
||||
#define SPI_MASTER_FREQ_20M (APB_CLK_FREQ/2) ///< 40MHz
|
||||
#define SPI_MASTER_FREQ_40M (APB_CLK_FREQ/1) ///< 80MHz
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
|
|
@ -394,4 +385,3 @@ int spi_get_freq_limit(bool gpio_is_used, int input_delay_ns);
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ extern "C" {
|
|||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_NO_MEM Touch pad init error
|
||||
* - ESP_ERR_NOT_SUPPORTED Touch pad is providing current to external XTAL
|
||||
*/
|
||||
esp_err_t touch_pad_init(void);
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ extern "C" {
|
|||
#include "soc/soc_caps.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/xtensa_api.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/ringbuf.h"
|
||||
|
|
@ -867,4 +866,3 @@ void uart_set_always_rx_timeout(uart_port_t uart_num, bool always_rx_timeout_en)
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -69,4 +69,3 @@ extern const esp_efuse_desc_t* ESP_EFUSE_SECURE_VERSION[];
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
70
tools/sdk/esp32/include/efuse/include/esp32c3/esp_efuse.h
Normal file
70
tools/sdk/esp32/include/efuse/include/esp32c3/esp_efuse.h
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Type of eFuse blocks ESP32C3
|
||||
*/
|
||||
typedef enum {
|
||||
EFUSE_BLK0 = 0, /**< Number of eFuse BLOCK0. REPEAT_DATA */
|
||||
|
||||
EFUSE_BLK1 = 1, /**< Number of eFuse BLOCK1. MAC_SPI_8M_SYS */
|
||||
|
||||
EFUSE_BLK2 = 2, /**< Number of eFuse BLOCK2. SYS_DATA_PART1 */
|
||||
EFUSE_BLK_SYS_DATA_PART1 = 2, /**< Number of eFuse BLOCK2. SYS_DATA_PART1 */
|
||||
|
||||
EFUSE_BLK3 = 3, /**< Number of eFuse BLOCK3. USER_DATA*/
|
||||
EFUSE_BLK_USER_DATA = 3, /**< Number of eFuse BLOCK3. USER_DATA*/
|
||||
|
||||
EFUSE_BLK4 = 4, /**< Number of eFuse BLOCK4. KEY0 */
|
||||
EFUSE_BLK_KEY0 = 4, /**< Number of eFuse BLOCK4. KEY0 */
|
||||
|
||||
EFUSE_BLK5 = 5, /**< Number of eFuse BLOCK5. KEY1 */
|
||||
EFUSE_BLK_KEY1 = 5, /**< Number of eFuse BLOCK5. KEY1 */
|
||||
|
||||
EFUSE_BLK6 = 6, /**< Number of eFuse BLOCK6. KEY2 */
|
||||
EFUSE_BLK_KEY2 = 6, /**< Number of eFuse BLOCK6. KEY2 */
|
||||
|
||||
EFUSE_BLK7 = 7, /**< Number of eFuse BLOCK7. KEY3 */
|
||||
EFUSE_BLK_KEY3 = 7, /**< Number of eFuse BLOCK7. KEY3 */
|
||||
|
||||
EFUSE_BLK8 = 8, /**< Number of eFuse BLOCK8. KEY4 */
|
||||
EFUSE_BLK_KEY4 = 8, /**< Number of eFuse BLOCK8. KEY4 */
|
||||
|
||||
EFUSE_BLK9 = 9, /**< Number of eFuse BLOCK9. KEY5 */
|
||||
EFUSE_BLK_KEY5 = 9, /**< Number of eFuse BLOCK9. KEY5 */
|
||||
EFUSE_BLK_KEY_MAX = 10,
|
||||
|
||||
EFUSE_BLK10 = 10, /**< Number of eFuse BLOCK10. SYS_DATA_PART2 */
|
||||
EFUSE_BLK_SYS_DATA_PART2 = 10, /**< Number of eFuse BLOCK10. SYS_DATA_PART2 */
|
||||
|
||||
EFUSE_BLK_MAX
|
||||
} esp_efuse_block_t;
|
||||
|
||||
/**
|
||||
* @brief Type of coding scheme
|
||||
*/
|
||||
typedef enum {
|
||||
EFUSE_CODING_SCHEME_NONE = 0, /**< None */
|
||||
EFUSE_CODING_SCHEME_RS = 3, /**< Reed-Solomon coding */
|
||||
} esp_efuse_coding_scheme_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
@ -49,6 +49,7 @@ typedef enum {
|
|||
|
||||
EFUSE_BLK9 = 9, /**< Number of eFuse BLOCK9. KEY5 */
|
||||
EFUSE_BLK_KEY5 = 9, /**< Number of eFuse BLOCK9. KEY5 */
|
||||
EFUSE_BLK_KEY_MAX = 10,
|
||||
|
||||
EFUSE_BLK10 = 10, /**< Number of eFuse BLOCK10. SYS_DATA_PART2 */
|
||||
EFUSE_BLK_SYS_DATA_PART2 = 10, /**< Number of eFuse BLOCK10. SYS_DATA_PART2 */
|
||||
|
|
@ -56,14 +57,6 @@ typedef enum {
|
|||
EFUSE_BLK_MAX
|
||||
} esp_efuse_block_t;
|
||||
|
||||
struct esp_efuse_desc_s;
|
||||
|
||||
/**
|
||||
* @brief Given a key block in the range EFUSE_BLK_KEY0..EFUSE_BLK_KEY5, return
|
||||
* efuse field for setting the key purpose
|
||||
*/
|
||||
const struct esp_efuse_desc_s **esp_efuse_get_purpose_field(esp_efuse_block_t block);
|
||||
|
||||
/**
|
||||
* @brief Type of coding scheme
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,108 @@
|
|||
// Copyright 2017-2018 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#define RTCCALIB_ESP32S2_ADCCOUNT 2
|
||||
#define RTCCALIB_ESP32S2_ATTENCOUNT 4
|
||||
|
||||
#define RTCCALIB_V1_PARAM_VLOW 0
|
||||
#define RTCCALIB_V1_PARAM_VHIGH 1
|
||||
#define RTCCALIB_V2_PARAM_VHIGH 0
|
||||
#define RTCCALIB_V2_PARAM_VINIT 1
|
||||
|
||||
// these are the tags. Either use them directly or use esp_efuse_rtc_table_get_tag to calculate
|
||||
// the corresponding tag.
|
||||
#define RTCCALIB_V1IDX_A10L 1
|
||||
#define RTCCALIB_V1IDX_A11L 2
|
||||
#define RTCCALIB_V1IDX_A12L 3
|
||||
#define RTCCALIB_V1IDX_A13L 4
|
||||
#define RTCCALIB_V1IDX_A20L 5
|
||||
#define RTCCALIB_V1IDX_A21L 6
|
||||
#define RTCCALIB_V1IDX_A22L 7
|
||||
#define RTCCALIB_V1IDX_A23L 8
|
||||
#define RTCCALIB_V1IDX_A10H 9
|
||||
#define RTCCALIB_V1IDX_A11H 10
|
||||
#define RTCCALIB_V1IDX_A12H 11
|
||||
#define RTCCALIB_V1IDX_A13H 12
|
||||
#define RTCCALIB_V1IDX_A20H 13
|
||||
#define RTCCALIB_V1IDX_A21H 14
|
||||
#define RTCCALIB_V1IDX_A22H 15
|
||||
#define RTCCALIB_V1IDX_A23H 16
|
||||
#define RTCCALIB_V2IDX_A10H 17
|
||||
#define RTCCALIB_V2IDX_A11H 18
|
||||
#define RTCCALIB_V2IDX_A12H 19
|
||||
#define RTCCALIB_V2IDX_A13H 20
|
||||
#define RTCCALIB_V2IDX_A20H 21
|
||||
#define RTCCALIB_V2IDX_A21H 22
|
||||
#define RTCCALIB_V2IDX_A22H 23
|
||||
#define RTCCALIB_V2IDX_A23H 24
|
||||
#define RTCCALIB_V2IDX_A10I 25
|
||||
#define RTCCALIB_V2IDX_A11I 26
|
||||
#define RTCCALIB_V2IDX_A12I 27
|
||||
#define RTCCALIB_V2IDX_A13I 28
|
||||
#define RTCCALIB_V2IDX_A20I 29
|
||||
#define RTCCALIB_V2IDX_A21I 30
|
||||
#define RTCCALIB_V2IDX_A22I 31
|
||||
#define RTCCALIB_V2IDX_A23I 32
|
||||
#define RTCCALIB_IDX_TMPSENSOR 33
|
||||
|
||||
/**
|
||||
* @brief Get rtc calibration version.
|
||||
*/
|
||||
int esp_efuse_rtc_table_read_calib_version(void);
|
||||
|
||||
/**
|
||||
* @brief Helper function to calculate a tag from human-readable parameters.
|
||||
* Tag is used to index the desired data from the efuse.
|
||||
* For example, (1, 1, 3, 1) yields the tag RTCCALIB_V1IDX_A13H
|
||||
* extra params are used for identification when a adc_num-atten combination has
|
||||
* multiple efuse values.
|
||||
* @param adc_channel_num verbatim numbering of the ADC channel. For channel 1, use 1 and not 0.
|
||||
* @param atten attenuation. use the enum value.
|
||||
* @param version the version of the scheme to index for.
|
||||
* @param extra_params defined differently for each version.
|
||||
* */
|
||||
int esp_efuse_rtc_table_get_tag(int version, int adc_channel_num, int atten, int extra_params);
|
||||
|
||||
/**
|
||||
* @brief Fetches a raw value from efuse and does signed bit parsing
|
||||
* @param tag tag obtained with esp_efuse_rtc_table_get_tag
|
||||
*
|
||||
* */
|
||||
int esp_efuse_rtc_table_get_raw_efuse_value(int tag);
|
||||
|
||||
/**
|
||||
* @brief Fetches a raw value from efuse and resolve it to get
|
||||
* the original number that it meant to represent.
|
||||
*
|
||||
* @param tag tag obtained with esp_efuse_rtc_table_get_tag
|
||||
* @param use_zero_inputs Does not perform the raw value fetching before resolving the number,
|
||||
* but proceed as if all zeros were read from efuse.
|
||||
*
|
||||
* */
|
||||
int esp_efuse_rtc_table_get_parsed_efuse_value(int tag, bool skip_efuse_reading);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
@ -49,6 +49,7 @@ typedef enum {
|
|||
|
||||
EFUSE_BLK9 = 9, /**< Number of eFuse BLOCK9. KEY5 */
|
||||
EFUSE_BLK_KEY5 = 9, /**< Number of eFuse BLOCK9. KEY5 */
|
||||
EFUSE_BLK_KEY_MAX = 10,
|
||||
|
||||
EFUSE_BLK10 = 10, /**< Number of eFuse BLOCK10. SYS_DATA_PART2 */
|
||||
EFUSE_BLK_SYS_DATA_PART2 = 10, /**< Number of eFuse BLOCK10. SYS_DATA_PART2 */
|
||||
|
|
@ -56,14 +57,6 @@ typedef enum {
|
|||
EFUSE_BLK_MAX
|
||||
} esp_efuse_block_t;
|
||||
|
||||
struct esp_efuse_desc_s;
|
||||
|
||||
/**
|
||||
* @brief Given a key block in the range EFUSE_BLK_KEY0..EFUSE_BLK_KEY5, return
|
||||
* efuse field for setting the key purpose
|
||||
*/
|
||||
const struct esp_efuse_desc_s **esp_efuse_get_purpose_field(esp_efuse_block_t block);
|
||||
|
||||
/**
|
||||
* @brief Type of coding scheme
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ extern "C" {
|
|||
#include "esp32s2/esp_efuse.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/esp_efuse.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/esp_efuse.h"
|
||||
#endif
|
||||
|
||||
#define ESP_ERR_EFUSE 0x1600 /*!< Base error code for efuse api. */
|
||||
|
|
@ -36,20 +38,16 @@ extern "C" {
|
|||
#define ESP_ERR_EFUSE_CNT_IS_FULL (ESP_ERR_EFUSE + 0x02) /*!< Error field is full. */
|
||||
#define ESP_ERR_EFUSE_REPEATED_PROG (ESP_ERR_EFUSE + 0x03) /*!< Error repeated programming of programmed bits is strictly forbidden. */
|
||||
#define ESP_ERR_CODING (ESP_ERR_EFUSE + 0x04) /*!< Error while a encoding operation. */
|
||||
|
||||
/**
|
||||
* @brief Structure eFuse field
|
||||
*/
|
||||
struct esp_efuse_desc_s {
|
||||
esp_efuse_block_t efuse_block: 8; /**< Block of eFuse */
|
||||
uint8_t bit_start; /**< Start bit [0..255] */
|
||||
uint16_t bit_count; /**< Length of bit field [1..-]*/
|
||||
};
|
||||
#define ESP_ERR_NOT_ENOUGH_UNUSED_KEY_BLOCKS (ESP_ERR_EFUSE + 0x05) /*!< Error not enough unused key blocks available */
|
||||
|
||||
/**
|
||||
* @brief Type definition for an eFuse field
|
||||
*/
|
||||
typedef struct esp_efuse_desc_s esp_efuse_desc_t;
|
||||
typedef struct {
|
||||
esp_efuse_block_t efuse_block: 8; /**< Block of eFuse */
|
||||
uint8_t bit_start; /**< Start bit [0..255] */
|
||||
uint16_t bit_count; /**< Length of bit field [1..-]*/
|
||||
} esp_efuse_desc_t;
|
||||
|
||||
/**
|
||||
* @brief Reads bits from EFUSE field and writes it into an array.
|
||||
|
|
@ -57,6 +55,9 @@ typedef struct esp_efuse_desc_s esp_efuse_desc_t;
|
|||
* The number of read bits will be limited to the minimum value
|
||||
* from the description of the bits in "field" structure or "dst_size_bits" required size.
|
||||
* Use "esp_efuse_get_field_size()" function to determine the length of the field.
|
||||
*
|
||||
* @note Please note that reading in the batch mode does not show uncommitted changes.
|
||||
*
|
||||
* @param[in] field A pointer to the structure describing the fields of efuse.
|
||||
* @param[out] dst A pointer to array that will contain the result of reading.
|
||||
* @param[in] dst_size_bits The number of bits required to read.
|
||||
|
|
@ -77,6 +78,7 @@ esp_err_t esp_efuse_read_field_blob(const esp_efuse_desc_t* field[], void* dst,
|
|||
* in the provided arguments, call esp_efuse_read_field_blob() and check the returned value instead.
|
||||
*
|
||||
* @note If assertions are enabled and the parameter is invalid, execution will abort
|
||||
* @note Please note that reading in the batch mode does not show uncommitted changes.
|
||||
*
|
||||
* @param[in] field A pointer to the structure describing the fields of efuse.
|
||||
* @return
|
||||
|
|
@ -90,6 +92,8 @@ bool esp_efuse_read_field_bit(const esp_efuse_desc_t *field[]);
|
|||
* @brief Reads bits from EFUSE field and returns number of bits programmed as "1".
|
||||
*
|
||||
* If the bits are set not sequentially, they will still be counted.
|
||||
* @note Please note that reading in the batch mode does not show uncommitted changes.
|
||||
*
|
||||
* @param[in] field A pointer to the structure describing the fields of efuse.
|
||||
* @param[out] out_cnt A pointer that will contain the number of programmed as "1" bits.
|
||||
*
|
||||
|
|
@ -195,6 +199,8 @@ int esp_efuse_get_field_size(const esp_efuse_desc_t* field[]);
|
|||
*
|
||||
* This is a thread-safe implementation.
|
||||
* Example: EFUSE_BLK2_RDATA3_REG where (blk=2, num_reg=3)
|
||||
* @note Please note that reading in the batch mode does not show uncommitted changes.
|
||||
*
|
||||
* @param[in] blk Block number of eFuse.
|
||||
* @param[in] num_reg The register number in the block.
|
||||
*
|
||||
|
|
@ -231,6 +237,8 @@ esp_efuse_coding_scheme_t esp_efuse_get_coding_scheme(esp_efuse_block_t blk);
|
|||
/**
|
||||
* @brief Read key to efuse block starting at the offset and the required size.
|
||||
*
|
||||
* @note Please note that reading in the batch mode does not show uncommitted changes.
|
||||
*
|
||||
* @param[in] blk Block number of eFuse.
|
||||
* @param[in] dst_key A pointer to array that will contain the result of reading.
|
||||
* @param[in] offset_in_bits Start bit in block.
|
||||
|
|
@ -407,13 +415,19 @@ esp_err_t esp_efuse_update_secure_version(uint32_t secure_version);
|
|||
*/
|
||||
void esp_efuse_init(uint32_t offset, uint32_t size);
|
||||
|
||||
/* @brief Set the batch mode of writing fields.
|
||||
/**
|
||||
* @brief Set the batch mode of writing fields.
|
||||
*
|
||||
* This mode allows you to write the fields in the batch mode.
|
||||
* If this mode is enabled, esp_efuse_batch_write_commit() must be called
|
||||
* to actually burn any written efuses.
|
||||
* In this mode, reading efuse is not possible.
|
||||
* This mode should be used when burning several efuses at one time.
|
||||
* This mode allows you to write the fields in the batch mode when need to burn several efuses at one time.
|
||||
* To enable batch mode call begin() then perform as usually the necessary operations
|
||||
* read and write and at the end call commit() to actually burn all written efuses.
|
||||
* The batch mode can be used nested. The commit will be done by the last commit() function.
|
||||
* The number of begin() functions should be equal to the number of commit() functions.
|
||||
*
|
||||
* @note Please note that reading in the batch mode does not show uncommitted changes.
|
||||
*
|
||||
* Note: If batch mode is enabled by the first task, at this time the second task cannot write/read efuses.
|
||||
* The second task will wait for the first task to complete the batch operation.
|
||||
*
|
||||
* \code{c}
|
||||
* // Example of using the batch writing mode.
|
||||
|
|
@ -427,10 +441,20 @@ void esp_efuse_init(uint32_t offset, uint32_t size);
|
|||
* esp_efuse_set_write_protect(EFUSE_BLKx);
|
||||
* esp_efuse_write_reg(EFUSE_BLKx, ...);
|
||||
* esp_efuse_write_block(EFUSE_BLKx, ...);
|
||||
* esp_efuse_write(ESP_EFUSE_1, 3); // ESP_EFUSE_1 == 1, here we write a new value = 3. The changes will be burn by the commit() function.
|
||||
* esp_efuse_read_...(ESP_EFUSE_1); // this function returns ESP_EFUSE_1 == 1 because uncommitted changes are not readable, it will be available only after commit.
|
||||
* ...
|
||||
*
|
||||
* // esp_efuse_batch_write APIs can be called recursively.
|
||||
* esp_efuse_batch_write_begin();
|
||||
* esp_efuse_set_write_protect(EFUSE_BLKx);
|
||||
* esp_efuse_batch_write_commit(); // the burn will be skipped here, it will be done in the last commit().
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* // Write all of these fields to the efuse registers
|
||||
* esp_efuse_batch_write_commit();
|
||||
* esp_efuse_read_...(ESP_EFUSE_1); // this function returns ESP_EFUSE_1 == 3.
|
||||
*
|
||||
* \endcode
|
||||
*
|
||||
|
|
@ -460,6 +484,271 @@ esp_err_t esp_efuse_batch_write_cancel(void);
|
|||
*/
|
||||
esp_err_t esp_efuse_batch_write_commit(void);
|
||||
|
||||
|
||||
#ifndef CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
/**
|
||||
* @brief Type of key purpose
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_EFUSE_KEY_PURPOSE_USER = 0,
|
||||
ESP_EFUSE_KEY_PURPOSE_RESERVED = 1,
|
||||
ESP_EFUSE_KEY_PURPOSE_XTS_AES_256_KEY_1 = 2,
|
||||
ESP_EFUSE_KEY_PURPOSE_XTS_AES_256_KEY_2 = 3,
|
||||
ESP_EFUSE_KEY_PURPOSE_XTS_AES_128_KEY = 4,
|
||||
ESP_EFUSE_KEY_PURPOSE_HMAC_DOWN_ALL = 5,
|
||||
ESP_EFUSE_KEY_PURPOSE_HMAC_DOWN_JTAG = 6,
|
||||
ESP_EFUSE_KEY_PURPOSE_HMAC_DOWN_DIGITAL_SIGNATURE = 7,
|
||||
ESP_EFUSE_KEY_PURPOSE_HMAC_UP = 8,
|
||||
ESP_EFUSE_KEY_PURPOSE_SECURE_BOOT_DIGEST0 = 9,
|
||||
ESP_EFUSE_KEY_PURPOSE_SECURE_BOOT_DIGEST1 = 10,
|
||||
ESP_EFUSE_KEY_PURPOSE_SECURE_BOOT_DIGEST2 = 11,
|
||||
ESP_EFUSE_KEY_PURPOSE_MAX,
|
||||
} esp_efuse_purpose_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Returns a pointer to a key purpose for an efuse key block.
|
||||
*
|
||||
* @param[in] block A key block in the range EFUSE_BLK_KEY0..EFUSE_BLK_KEY_MAX
|
||||
*
|
||||
* To get the value of this field use esp_efuse_read_field_blob() or esp_efuse_get_key_purpose().
|
||||
*
|
||||
* @return Pointer: If Successful returns a pointer to the corresponding efuse field otherwise NULL.
|
||||
*/
|
||||
const esp_efuse_desc_t **esp_efuse_get_purpose_field(esp_efuse_block_t block);
|
||||
|
||||
/**
|
||||
* @brief Returns a pointer to a key block.
|
||||
*
|
||||
* @param[in] block A key block in the range EFUSE_BLK_KEY0..EFUSE_BLK_KEY_MAX
|
||||
*
|
||||
* @return Pointer: If Successful returns a pointer to the corresponding efuse field otherwise NULL.
|
||||
*/
|
||||
const esp_efuse_desc_t** esp_efuse_get_key(esp_efuse_block_t block);
|
||||
|
||||
/**
|
||||
* @brief Returns a read protection for the key block.
|
||||
*
|
||||
* @param[in] block A key block in the range EFUSE_BLK_KEY0..EFUSE_BLK_KEY_MAX
|
||||
*
|
||||
* @return True: The key block is read protected
|
||||
* False: The key block is readable.
|
||||
*/
|
||||
bool esp_efuse_get_key_dis_read(esp_efuse_block_t block);
|
||||
|
||||
/**
|
||||
* @brief Sets a read protection for the key block.
|
||||
*
|
||||
* @param[in] block A key block in the range EFUSE_BLK_KEY0..EFUSE_BLK_KEY_MAX
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Successful.
|
||||
* - ESP_ERR_INVALID_ARG: Error in the passed arguments.
|
||||
* - ESP_ERR_EFUSE_REPEATED_PROG: Error repeated programming of programmed bits is strictly forbidden.
|
||||
* - ESP_ERR_CODING: Error range of data does not match the coding scheme.
|
||||
*/
|
||||
esp_err_t esp_efuse_set_key_dis_read(esp_efuse_block_t block);
|
||||
|
||||
/**
|
||||
* @brief Returns a write protection for the key block.
|
||||
*
|
||||
* @param[in] block A key block in the range EFUSE_BLK_KEY0..EFUSE_BLK_KEY_MAX
|
||||
*
|
||||
* @return True: The key block is write protected
|
||||
* False: The key block is writeable.
|
||||
*/
|
||||
bool esp_efuse_get_key_dis_write(esp_efuse_block_t block);
|
||||
|
||||
/**
|
||||
* @brief Sets a write protection for the key block.
|
||||
*
|
||||
* @param[in] block A key block in the range EFUSE_BLK_KEY0..EFUSE_BLK_KEY_MAX
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Successful.
|
||||
* - ESP_ERR_INVALID_ARG: Error in the passed arguments.
|
||||
* - ESP_ERR_EFUSE_REPEATED_PROG: Error repeated programming of programmed bits is strictly forbidden.
|
||||
* - ESP_ERR_CODING: Error range of data does not match the coding scheme.
|
||||
*/
|
||||
esp_err_t esp_efuse_set_key_dis_write(esp_efuse_block_t block);
|
||||
|
||||
/**
|
||||
* @brief Returns the current purpose set for an efuse key block.
|
||||
*
|
||||
* @param[in] block A key block in the range EFUSE_BLK_KEY0..EFUSE_BLK_KEY_MAX
|
||||
*
|
||||
* @return
|
||||
* - Value: If Successful, it returns the value of the purpose related to the given key block.
|
||||
* - ESP_EFUSE_KEY_PURPOSE_MAX: Otherwise.
|
||||
*/
|
||||
esp_efuse_purpose_t esp_efuse_get_key_purpose(esp_efuse_block_t block);
|
||||
|
||||
/**
|
||||
* @brief Sets a key purpose for an efuse key block.
|
||||
*
|
||||
* @param[in] block A key block in the range EFUSE_BLK_KEY0..EFUSE_BLK_KEY_MAX
|
||||
* @param[in] purpose Key purpose.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Successful.
|
||||
* - ESP_ERR_INVALID_ARG: Error in the passed arguments.
|
||||
* - ESP_ERR_EFUSE_REPEATED_PROG: Error repeated programming of programmed bits is strictly forbidden.
|
||||
* - ESP_ERR_CODING: Error range of data does not match the coding scheme.
|
||||
*/
|
||||
esp_err_t esp_efuse_set_key_purpose(esp_efuse_block_t block, esp_efuse_purpose_t purpose);
|
||||
|
||||
/**
|
||||
* @brief Returns a write protection of the key purpose field for an efuse key block.
|
||||
*
|
||||
* @param[in] block A key block in the range EFUSE_BLK_KEY0..EFUSE_BLK_KEY_MAX
|
||||
*
|
||||
* @return True: The key purpose is write protected.
|
||||
* False: The key purpose is writeable.
|
||||
*/
|
||||
bool esp_efuse_get_keypurpose_dis_write(esp_efuse_block_t block);
|
||||
|
||||
/**
|
||||
* @brief Sets a write protection of the key purpose field for an efuse key block.
|
||||
*
|
||||
* @param[in] block A key block in the range EFUSE_BLK_KEY0..EFUSE_BLK_KEY_MAX
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Successful.
|
||||
* - ESP_ERR_INVALID_ARG: Error in the passed arguments.
|
||||
* - ESP_ERR_EFUSE_REPEATED_PROG: Error repeated programming of programmed bits is strictly forbidden.
|
||||
* - ESP_ERR_CODING: Error range of data does not match the coding scheme.
|
||||
*/
|
||||
esp_err_t esp_efuse_set_keypurpose_dis_write(esp_efuse_block_t block);
|
||||
|
||||
/**
|
||||
* @brief Find a key block with the particular purpose set.
|
||||
*
|
||||
* @param[in] purpose Purpose to search for.
|
||||
* @param[out] block Pointer in the range EFUSE_BLK_KEY0..EFUSE_BLK_KEY_MAX which will be set to the key block if found.
|
||||
* Can be NULL, if only need to test the key block exists.
|
||||
*
|
||||
* @return
|
||||
* - True: If found,
|
||||
* - False: If not found (value at block pointer is unchanged).
|
||||
*/
|
||||
bool esp_efuse_find_purpose(esp_efuse_purpose_t purpose, esp_efuse_block_t *block);
|
||||
|
||||
/**
|
||||
* @brief Search for an unused key block and return the first one found.
|
||||
*
|
||||
* See esp_efuse_key_block_unused for a description of an unused key block.
|
||||
*
|
||||
* @return First unused key block, or EFUSE_BLK_KEY_MAX if no unused key block is found.
|
||||
*/
|
||||
esp_efuse_block_t esp_efuse_find_unused_key_block(void);
|
||||
|
||||
/**
|
||||
* @brief Return the number of unused efuse key blocks in the range EFUSE_BLK_KEY0..EFUSE_BLK_KEY_MAX
|
||||
*/
|
||||
unsigned esp_efuse_count_unused_key_blocks(void);
|
||||
|
||||
/**
|
||||
* @brief Returns true if the key block is unused, false otherwise.
|
||||
*
|
||||
* An unused key block is all zero content, not read or write protected,
|
||||
* and has purpose 0 (ESP_EFUSE_KEY_PURPOSE_USER)
|
||||
*
|
||||
* @param block key block to check.
|
||||
*
|
||||
* @return
|
||||
* - True if key block is unused,
|
||||
* - False if key block is used or the specified block index is not a key block.
|
||||
*/
|
||||
bool esp_efuse_key_block_unused(esp_efuse_block_t block);
|
||||
|
||||
/**
|
||||
* @brief Returns the status of the Secure Boot public key digest revocation bit.
|
||||
*
|
||||
* @param[in] num_digest The number of digest in range 0..2
|
||||
*
|
||||
* @return
|
||||
* - True: If key digest is revoked,
|
||||
* - False; If key digest is not revoked.
|
||||
*/
|
||||
bool esp_efuse_get_digest_revoke(unsigned num_digest);
|
||||
|
||||
/**
|
||||
* @brief Sets the Secure Boot public key digest revocation bit.
|
||||
*
|
||||
* @param[in] num_digest The number of digest in range 0..2
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Successful.
|
||||
* - ESP_ERR_INVALID_ARG: Error in the passed arguments.
|
||||
* - ESP_ERR_EFUSE_REPEATED_PROG: Error repeated programming of programmed bits is strictly forbidden.
|
||||
* - ESP_ERR_CODING: Error range of data does not match the coding scheme.
|
||||
*/
|
||||
esp_err_t esp_efuse_set_digest_revoke(unsigned num_digest);
|
||||
|
||||
/**
|
||||
* @brief Returns a write protection of the Secure Boot public key digest revocation bit.
|
||||
*
|
||||
* @param[in] num_digest The number of digest in range 0..2
|
||||
*
|
||||
* @return True: The revocation bit is write protected.
|
||||
* False: The revocation bit is writeable.
|
||||
*/
|
||||
bool esp_efuse_get_write_protect_of_digest_revoke(unsigned num_digest);
|
||||
|
||||
/**
|
||||
* @brief Sets a write protection of the Secure Boot public key digest revocation bit.
|
||||
*
|
||||
* @param[in] num_digest The number of digest in range 0..2
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Successful.
|
||||
* - ESP_ERR_INVALID_ARG: Error in the passed arguments.
|
||||
* - ESP_ERR_EFUSE_REPEATED_PROG: Error repeated programming of programmed bits is strictly forbidden.
|
||||
* - ESP_ERR_CODING: Error range of data does not match the coding scheme.
|
||||
*/
|
||||
esp_err_t esp_efuse_set_write_protect_of_digest_revoke(unsigned num_digest);
|
||||
|
||||
/**
|
||||
* @brief Program a block of key data to an efuse block
|
||||
*
|
||||
* The burn of a key, protection bits, and a purpose happens in batch mode.
|
||||
*
|
||||
* @param[in] block Block to read purpose for. Must be in range EFUSE_BLK_KEY0 to EFUSE_BLK_KEY_MAX. Key block must be unused (esp_efuse_key_block_unused).
|
||||
* @param[in] purpose Purpose to set for this key. Purpose must be already unset.
|
||||
* @param[in] key Pointer to data to write.
|
||||
* @param[in] key_size_bytes Bytes length of data to write.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Successful.
|
||||
* - ESP_ERR_INVALID_ARG: Error in the passed arguments.
|
||||
* - ESP_ERR_INVALID_STATE: Error in efuses state, unused block not found.
|
||||
* - ESP_ERR_EFUSE_REPEATED_PROG: Error repeated programming of programmed bits is strictly forbidden.
|
||||
* - ESP_ERR_CODING: Error range of data does not match the coding scheme.
|
||||
*/
|
||||
esp_err_t esp_efuse_write_key(esp_efuse_block_t block, esp_efuse_purpose_t purpose, const void *key, size_t key_size_bytes);
|
||||
|
||||
/**
|
||||
* @brief Program keys to unused efuse blocks
|
||||
*
|
||||
* The burn of keys, protection bits, and purposes happens in batch mode.
|
||||
*
|
||||
* @param[in] purposes Array of purposes (purpose[number_of_keys]).
|
||||
* @param[in] keys Array of keys (uint8_t keys[number_of_keys][32]). Each key is 32 bytes long.
|
||||
* @param[in] number_of_keys The number of keys to write (up to 6 keys).
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Successful.
|
||||
* - ESP_ERR_INVALID_ARG: Error in the passed arguments.
|
||||
* - ESP_ERR_INVALID_STATE: Error in efuses state, unused block not found.
|
||||
* - ESP_ERR_NOT_ENOUGH_UNUSED_KEY_BLOCKS: Error not enough unused key blocks available
|
||||
* - ESP_ERR_EFUSE_REPEATED_PROG: Error repeated programming of programmed bits is strictly forbidden.
|
||||
* - ESP_ERR_CODING: Error range of data does not match the coding scheme.
|
||||
*/
|
||||
esp_err_t esp_efuse_write_keys(esp_efuse_purpose_t purposes[], uint8_t keys[][32], unsigned number_of_keys);
|
||||
|
||||
#endif // not CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
// Copyright 2018-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 _dsp_common_H_
|
||||
#define _dsp_common_H_
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "dsp_err.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief check power of two
|
||||
* The function check if the argument is power of 2.
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @return
|
||||
* - true if x is power of two
|
||||
* - false if no
|
||||
*/
|
||||
bool dsp_is_power_of_two(int x);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Power of two
|
||||
* The function return power of 2 for values 2^N.
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @return
|
||||
* - power of two
|
||||
*/
|
||||
int dsp_power_of_two(int x);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _dsp_common_H_
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
// Copyright 2018-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
|
||||
|
|
@ -11,12 +11,13 @@
|
|||
// WITHOUT 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 GDBSTUB_H
|
||||
#define GDBSTUB_H
|
||||
|
||||
#include <xtensa/config/core.h>
|
||||
#include "freertos/xtensa_api.h"
|
||||
|
||||
void esp_gdbstub_panic_handler(XtExcFrame *frame) __attribute__((noreturn));
|
||||
#ifndef _DSP_ERR_H_
|
||||
#define _DSP_ERR_H_
|
||||
|
||||
#endif
|
||||
#include "stdint.h"
|
||||
#include "esp_err.h"
|
||||
#include "dsp_err_codes.h"
|
||||
|
||||
#endif // _DSP_ERR_H_
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
// Copyright 2018-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 _dsp_error_codes_H_
|
||||
#define _dsp_error_codes_H_
|
||||
|
||||
#define DSP_OK 0 // For internal use only. Please use ESP_OK instead
|
||||
#define ESP_ERR_DSP_BASE 0x70000
|
||||
#define ESP_ERR_DSP_INVALID_LENGTH (ESP_ERR_DSP_BASE + 1)
|
||||
#define ESP_ERR_DSP_INVALID_PARAM (ESP_ERR_DSP_BASE + 2)
|
||||
#define ESP_ERR_DSP_PARAM_OUTOFRANGE (ESP_ERR_DSP_BASE + 3)
|
||||
#define ESP_ERR_DSP_UNINITIALIZED (ESP_ERR_DSP_BASE + 4)
|
||||
#define ESP_ERR_DSP_REINITIALIZED (ESP_ERR_DSP_BASE + 5)
|
||||
|
||||
|
||||
#endif // _dsp_error_codes_H_
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2018-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 dsp_platform_h_
|
||||
#define dsp_platform_h_
|
||||
#include "soc/cpu.h"
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/portable.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
||||
#endif // dsp_platform_h_
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
// Copyright 2018-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 _DSP_TESTS_H_
|
||||
#define _DSP_TESTS_H_
|
||||
|
||||
#define TEST_ASSERT_EXEC_IN_RANGE(min_exec, max_exec, actual) \
|
||||
if (actual >= max_exec) { \
|
||||
ESP_LOGE("", "Time error. Expected max: %i, reached: %i", (int)max_exec, (int)actual);\
|
||||
TEST_ASSERT_MESSAGE (false, "Exec time takes more than expected! ");\
|
||||
}\
|
||||
if (actual < min_exec) {\
|
||||
ESP_LOGE("", "Time error. Expected min: %i, reached: %i", (int)min_exec, (int)actual);\
|
||||
TEST_ASSERT_MESSAGE (false, "Exec time takes less then expected!");\
|
||||
}
|
||||
|
||||
|
||||
#endif // _DSP_TESTS_H_
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
// Copyright 2018-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_dsp_H_
|
||||
#define _esp_dsp_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
// Common includes
|
||||
#include "dsp_common.h"
|
||||
|
||||
// Signal processing
|
||||
#include "dsps_dotprod.h"
|
||||
#include "dsps_math.h"
|
||||
#include "dsps_fir.h"
|
||||
#include "dsps_biquad.h"
|
||||
#include "dsps_biquad_gen.h"
|
||||
#include "dsps_wind.h"
|
||||
#include "dsps_conv.h"
|
||||
#include "dsps_corr.h"
|
||||
|
||||
#include "dsps_d_gen.h"
|
||||
#include "dsps_h_gen.h"
|
||||
#include "dsps_tone_gen.h"
|
||||
#include "dsps_snr.h"
|
||||
#include "dsps_sfdr.h"
|
||||
|
||||
#include "dsps_fft2r.h"
|
||||
#include "dsps_fft4r.h"
|
||||
#include "dsps_dct.h"
|
||||
|
||||
// Matrix operations
|
||||
#include "dspm_mult.h"
|
||||
|
||||
// Support functions
|
||||
#include "dsps_view.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "mat.h"
|
||||
#endif
|
||||
|
||||
#endif // _esp_dsp_H_
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
// Copyright 2018-2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef _dsps_ccorr_H_
|
||||
#define _dsps_ccorr_H_
|
||||
#include "dsp_err.h"
|
||||
|
||||
#include "dsps_conv_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief Cross correlation
|
||||
*
|
||||
* The function make cross correlate between two ignals.
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param[in] Signal1: input array with input 1 signal values
|
||||
* @param[in] siglen1: length of the input 1 signal array
|
||||
* @param[in] Signal2: input array with input 2 signal values
|
||||
* @param[in] siglen2: length of the input signal array
|
||||
* @param corrout: output array with result of cross correlation. The size of dest array must be (siglen1 + siglen2 - 1) !!!
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library (one of the input array are NULL, or if (siglen < patlen))
|
||||
*/
|
||||
esp_err_t dsps_ccorr_f32_ansi(const float *Signal, const int siglen, const float *Pattern, const int patlen, float *corrout);
|
||||
esp_err_t dsps_ccorr_f32_ae32(const float *Signal, const int siglen, const float *Pattern, const int patlen, float *corrout);
|
||||
/**}@*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CONFIG_DSP_OPTIMIZED
|
||||
#if (dsps_ccorr_f32_ae32_enabled == 1)
|
||||
#define dsps_ccorr_f32 dsps_ccorr_f32_ae32
|
||||
#else
|
||||
#define dsps_ccorr_f32 dsps_ccorr_f32_ansi
|
||||
#endif // dsps_ccorr_f32_ae32_enabled
|
||||
#else
|
||||
#define dsps_ccorr_f32 dsps_ccorr_f32_ansi
|
||||
#endif
|
||||
|
||||
#endif // _dsps_conv_H_
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
// Copyright 2018-2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef _dsps_conv_H_
|
||||
#define _dsps_conv_H_
|
||||
#include "dsp_err.h"
|
||||
|
||||
#include "dsps_conv_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief Convolution
|
||||
*
|
||||
* The function convolve Signal array with Kernel array.
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param[in] Signal: input array with signal
|
||||
* @param[in] siglen: length of the input signal
|
||||
* @param[in] Kernel: input array with convolution kernel
|
||||
* @param[in] kernlen: length of the Kernel array
|
||||
* @param convout: output array with convolution result length of (siglen + Kernel -1)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_conv_f32_ae32(const float *Signal, const int siglen, const float *Kernel, const int kernlen, float *convout);
|
||||
esp_err_t dsps_conv_f32_ansi(const float *Signal, const int siglen, const float *Kernel, const int kernlen, float *convout);
|
||||
/**}@*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CONFIG_DSP_OPTIMIZED
|
||||
|
||||
#if (dsps_conv_f32_ae32_enabled == 1)
|
||||
#define dsps_conv_f32 dsps_conv_f32_ae32
|
||||
#else
|
||||
#define dsps_conv_f32 dsps_conv_f32_ansi
|
||||
#endif // dsps_conv_f32_ae32_enabled
|
||||
|
||||
#else
|
||||
#define dsps_conv_f32 dsps_conv_f32_ansi
|
||||
#endif
|
||||
|
||||
#endif // _dsps_conv_H_
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
#ifndef _dsps_conv_platform_H_
|
||||
#define _dsps_conv_platform_H_
|
||||
|
||||
#include <xtensa/config/core-isa.h>
|
||||
#include <xtensa/config/core-matmap.h>
|
||||
|
||||
|
||||
#if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1))
|
||||
|
||||
#define dsps_conv_f32_ae32_enabled 1
|
||||
#define dsps_ccorr_f32_ae32_enabled 1
|
||||
#define dsps_corr_f32_ae32_enabled 1
|
||||
|
||||
#endif
|
||||
|
||||
#endif // _dsps_conv_platform_H_
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
// Copyright 2018-2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef _dsps_corr_H_
|
||||
#define _dsps_corr_H_
|
||||
#include "dsp_err.h"
|
||||
|
||||
#include "dsps_conv_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief Correlation with pattern
|
||||
*
|
||||
* The function correlate input sigla array with pattern array.
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param[in] Signal: input array with signal values
|
||||
* @param[in] siglen: length of the signal array
|
||||
* @param[in] Pattern: input array with pattern values
|
||||
* @param[in] patlen: length of the pattern array. The siglen must be bigger then patlen!
|
||||
* @param dest: output array with result of correlation
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library (one of the input array are NULL, or if (siglen < patlen))
|
||||
*/
|
||||
esp_err_t dsps_corr_f32_ansi(const float *Signal, const int siglen, const float *Pattern, const int patlen, float *dest);
|
||||
esp_err_t dsps_corr_f32_ae32(const float *Signal, const int siglen, const float *Pattern, const int patlen, float *dest);
|
||||
/**}@*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CONFIG_DSP_OPTIMIZED
|
||||
#if (dsps_corr_f32_ae32_enabled == 1)
|
||||
#define dsps_corr_f32 dsps_corr_f32_ae32
|
||||
#else
|
||||
#define dsps_corr_f32 dsps_corr_f32_ansi
|
||||
#endif // dsps_corr_f32_ae32_enabled
|
||||
#else
|
||||
#define dsps_corr_f32 dsps_corr_f32_ansi
|
||||
#endif
|
||||
|
||||
#endif // _dsps_corr_H_
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
// Copyright 2018-2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef _dsps_dct_H_
|
||||
#define _dsps_dct_H_
|
||||
#include "dsp_err.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief DCT of radix 2, unscaled
|
||||
*
|
||||
* DCT type II of radix 2, unscaled
|
||||
* Function is FFT based
|
||||
* The extension (_ansi) use ANSI C and could be compiled and run on any platform.
|
||||
* The extension (_ae32) is optimized for ESP32 chip.
|
||||
*
|
||||
* @param[inout] data: input/output array with size of N*2. An elements located: Re[0],Re[1], , ... Re[N-1], any data... up to N*2
|
||||
* result of DCT will be stored to this array from 0...N-1.
|
||||
* Size of data array must be N*2!!!
|
||||
* @param[in] N: Size of DCT transform. Size of data array must be N*2!!!
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_dct_f32(float *data, int N);
|
||||
|
||||
/**@}*/
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief Inverce DCT of radix 2
|
||||
*
|
||||
* Inverce DCT type III of radix 2, unscaled
|
||||
* Function is FFT based
|
||||
* The extension (_ansi) use ANSI C and could be compiled and run on any platform.
|
||||
* The extension (_ae32) is optimized for ESP32 chip.
|
||||
*
|
||||
* @param[inout] data: input/output array with size of N*2. An elements located: Re[0],Re[1], , ... Re[N-1], any data... up to N*2
|
||||
* result of DCT will be stored to this array from 0...N-1.
|
||||
* Size of data array must be N*2!!!
|
||||
* @param[in] N: Size of DCT transform. Size of data array must be N*2!!!
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_dct_inv_f32(float *data, int N);
|
||||
|
||||
/**@}*/
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief DCTs
|
||||
*
|
||||
* Direct DCT type II and Inverce DCT type III, unscaled
|
||||
* These functions used as a reference for general purpose. These functions are not optimyzed!
|
||||
* The extension (_ansi) use ANSI C and could be compiled and run on any platform.
|
||||
* The extension (_ae32) is optimized for ESP32 chip.
|
||||
*
|
||||
* @param[in] data: input/output array with size of N. An elements located: Re[0],Re[1], , ... Re[N-1]
|
||||
* @param[in] N: Size of DCT transform. Size of data array must be N*2!!!
|
||||
* @param[out] result: output result array with size of N.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_dct_f32_ref(float *data, int N, float *result);
|
||||
esp_err_t dsps_dct_inverce_f32_ref(float *data, int N, float *result);
|
||||
/**@}*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _dsps_dct_H_
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
// Copyright 2018-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 _DSPI_DOTPROD_H_
|
||||
#define _DSPI_DOTPROD_H_
|
||||
|
||||
#include "esp_log.h"
|
||||
#include "dsp_err.h"
|
||||
|
||||
#include "dsps_dotprod_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
// These functions calculates dotproduct of two vectors.
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief dot product of two 16 bit vectors
|
||||
* Dot product calculation for two signed 16 bit arrays: *dest += (src1[i] * src2[i]) >> (15-shift); i= [0..N)
|
||||
* The extension (_ansi) use ANSI C and could be compiled and run on any platform.
|
||||
* The extension (_ae32) is optimized for ESP32 chip.
|
||||
*
|
||||
* @param[in] src1 source array 1
|
||||
* @param[in] src2 source array 2
|
||||
* @param dest destination pointer
|
||||
* @param[in] len length of input arrays
|
||||
* @param[in] shift shift of the result.
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_dotprod_s16_ansi(const int16_t *src1, const int16_t *src2, int16_t *dest, int len, int8_t shift);
|
||||
esp_err_t dsps_dotprod_s16_ae32(const int16_t *src1, const int16_t *src2, int16_t *dest, int len, int8_t shift);
|
||||
/**@}*/
|
||||
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief dot product of two float vectors
|
||||
* Dot product calculation for two floating point arrays: *dest += (src1[i] * src2[i]); i= [0..N)
|
||||
* The extension (_ansi) use ANSI C and could be compiled and run on any platform.
|
||||
* The extension (_ae32) is optimized for ESP32 chip.
|
||||
*
|
||||
* @param[in] src1 source array 1
|
||||
* @param[in] src2 source array 2
|
||||
* @param dest destination pointer
|
||||
* @param[in] len length of input arrays
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_dotprod_f32_ansi(const float *src1, const float *src2, float *dest, int len);
|
||||
esp_err_t dsps_dotprod_f32_ae32(const float *src1, const float *src2, float *dest, int len);
|
||||
/**@}*/
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief dot product of two float vectors with step
|
||||
* Dot product calculation for two floating point arrays: *dest += (src1[i*step1] * src2[i*step2]); i= [0..N)
|
||||
* The extension (_ansi) use ANSI C and could be compiled and run on any platform.
|
||||
* The extension (_ae32) is optimized for ESP32 chip.
|
||||
*
|
||||
* @param[in] src1 source array 1
|
||||
* @param[in] src2 source array 2
|
||||
* @param dest destination pointer
|
||||
* @param[in] len length of input arrays
|
||||
* @param[in] step1 step over elements in first array
|
||||
* @param[in] step2 step over elements in second array
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_dotprode_f32_ansi(const float *src1, const float *src2, float *dest, int len, int step1, int step2);
|
||||
esp_err_t dsps_dotprode_f32_ae32(const float *src1, const float *src2, float *dest, int len, int step1, int step2);
|
||||
/**@}*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_DSP_OPTIMIZED
|
||||
#if (dsps_dotprod_s16_ae32_enabled == 1)
|
||||
#define dsps_dotprod_s16 dsps_dotprod_s16_ae32
|
||||
#else
|
||||
#define dsps_dotprod_s16 dsps_dotprod_s16_ansi
|
||||
#endif // dsps_dotprod_s16_ae32_enabled
|
||||
#if (dsps_dotprod_f32_ae32_enabled == 1)
|
||||
#define dsps_dotprod_f32 dsps_dotprod_f32_ae32
|
||||
#else
|
||||
#define dsps_dotprod_f32 dsps_dotprod_f32_ansi
|
||||
#endif // dsps_dotprod_f32_ae32_enabled
|
||||
#if (dsps_dotprode_f32_ae32_enabled == 1)
|
||||
#define dsps_dotprode_f32 dsps_dotprode_f32_ae32
|
||||
#else
|
||||
#define dsps_dotprode_f32 dsps_dotprode_f32_ansi
|
||||
#endif // dsps_dotprode_f32_ae32_enabled
|
||||
|
||||
#else // CONFIG_DSP_OPTIMIZED
|
||||
#define dsps_dotprod_s16 dsps_dotprod_s16_ansi
|
||||
#define dsps_dotprod_f32 dsps_dotprod_f32_ansi
|
||||
#define dsps_dotprode_f32 dsps_dotprode_f32_ansi
|
||||
#endif // CONFIG_DSP_OPTIMIZED
|
||||
|
||||
#endif // _DSPI_DOTPROD_H_
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
#ifndef _dsps_dotprod_platform_H_
|
||||
#define _dsps_dotprod_platform_H_
|
||||
|
||||
#include <xtensa/config/core-isa.h>
|
||||
#include <xtensa/config/core-matmap.h>
|
||||
|
||||
|
||||
#if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1))
|
||||
|
||||
#define dotprod_f32_ae32_enabled 1
|
||||
#define dotprode_f32_ae32_enabled 1
|
||||
|
||||
#endif //
|
||||
|
||||
#if ((XCHAL_HAVE_LOOPS == 1) && (XCHAL_HAVE_MAC16 == 1))
|
||||
|
||||
#define dsps_dotprod_s16_ae32_enabled 1
|
||||
|
||||
#endif //
|
||||
|
||||
#endif // _dsps_dotprod_platform_H_
|
||||
233
tools/sdk/esp32/include/esp-dsp/modules/fft/include/dsps_fft2r.h
Normal file
233
tools/sdk/esp32/include/esp-dsp/modules/fft/include/dsps_fft2r.h
Normal file
|
|
@ -0,0 +1,233 @@
|
|||
// Copyright 2018-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 _dsps_fft2r_H_
|
||||
#define _dsps_fft2r_H_
|
||||
|
||||
#include "dsp_err.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "dsps_fft_tables.h"
|
||||
|
||||
#ifndef CONFIG_DSP_MAX_FFT_SIZE
|
||||
#define CONFIG_DSP_MAX_FFT_SIZE 4096
|
||||
#endif // CONFIG_DSP_MAX_FFT_SIZE
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern float *dsps_fft_w_table_fc32;
|
||||
extern int dsps_fft_w_table_size;
|
||||
extern uint8_t dsps_fft2r_initialized;
|
||||
|
||||
extern int16_t *dsps_fft_w_table_sc16;
|
||||
extern int dsps_fft_w_table_sc16_size;
|
||||
extern uint8_t dsps_fft2r_sc16_initialized;
|
||||
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief init fft tables
|
||||
*
|
||||
* Initialization of Complex FFT. This function initialize coefficients table.
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param[inout] fft_table_buff: pointer to floating point buffer where sin/cos table will be stored
|
||||
* if this parameter set to NULL, and table_size value is more then 0, then
|
||||
* dsps_fft2r_init_fc32 will allocate buffer internally
|
||||
* @param[in] table_size: size of the buffer in float words
|
||||
* if fft_table_buff is NULL and table_size is not 0, buffer will be allocated internally.
|
||||
* If table_size is 0, buffer will not be allocated.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_DSP_PARAM_OUTOFRANGE if table_size > CONFIG_DSP_MAX_FFT_SIZE
|
||||
* - ESP_ERR_DSP_REINITIALIZED if buffer already allocated internally by other function
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_fft2r_init_fc32(float *fft_table_buff, int table_size);
|
||||
esp_err_t dsps_fft2r_init_sc16(int16_t *fft_table_buff, int table_size);
|
||||
/**@}*/
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief deinit fft tables
|
||||
*
|
||||
* Free resources of Complex FFT. This function delete coefficients table if it was allocated by dsps_fft2r_init_fc32.
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
void dsps_fft2r_deinit_fc32();
|
||||
void dsps_fft2r_deinit_sc16();
|
||||
/**@}*/
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief complex FFT of radix 2
|
||||
*
|
||||
* Complex FFT of radix 2
|
||||
* The extension (_ansi) use ANSI C and could be compiled and run on any platform.
|
||||
* The extension (_ae32) is optimized for ESP32 chip.
|
||||
*
|
||||
* @param[inout] data: input/output complex array. An elements located: Re[0], Im[0], ... Re[N-1], Im[N-1]
|
||||
* result of FFT will be stored to this array.
|
||||
* @param[in] N: Number of complex elements in input array
|
||||
* @param[in] w: pointer to the sin/cos table
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_fft2r_fc32_ansi_(float *data, int N, float *w);
|
||||
esp_err_t dsps_fft2r_fc32_ae32_(float *data, int N, float *w);
|
||||
esp_err_t dsps_fft2r_sc16_ansi_(int16_t *data, int N, int16_t *w);
|
||||
esp_err_t dsps_fft2r_sc16_ae32_(int16_t *data, int N, int16_t *w);
|
||||
/**@}*/
|
||||
// This is workaround because linker generates permanent error when assembler uses
|
||||
// direct access to the table pointer
|
||||
#define dsps_fft2r_fc32_ae32(data, N) dsps_fft2r_fc32_ae32_(data, N, dsps_fft_w_table_fc32)
|
||||
#define dsps_fft2r_sc16_ae32(data, N) dsps_fft2r_sc16_ae32_(data, N, dsps_fft_w_table_sc16)
|
||||
#define dsps_fft2r_fc32_ansi(data, N) dsps_fft2r_fc32_ansi_(data, N, dsps_fft_w_table_fc32)
|
||||
#define dsps_fft2r_sc16_ansi(data, N) dsps_fft2r_sc16_ansi_(data, N, dsps_fft_w_table_sc16)
|
||||
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief bit reverse operation for the complex input array
|
||||
*
|
||||
* Bit reverse operation for the complex input array
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param[inout] data: input/ complex array. An elements located: Re[0], Im[0], ... Re[N-1], Im[N-1]
|
||||
* result of FFT will be stored to this array.
|
||||
* @param[in] N: Number of complex elements in input array
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_bit_rev_fc32_ansi(float *data, int N);
|
||||
esp_err_t dsps_bit_rev_sc16_ansi(int16_t *data, int N);
|
||||
esp_err_t dsps_bit_rev2r_fc32(float *data, int N);
|
||||
|
||||
/**@{*/
|
||||
|
||||
esp_err_t dsps_bit_rev_lookup_fc32_ansi(float *data, int reverse_size, uint16_t *reverse_tab);
|
||||
esp_err_t dsps_bit_rev_lookup_fc32_ae32(float *data, int reverse_size, uint16_t *reverse_tab);
|
||||
|
||||
/**
|
||||
* @brief Generate coefficients table for the FFT radix 2
|
||||
*
|
||||
* Generate coefficients table for the FFT radix 2. This function called inside init.
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param[inout] w: memory location to store coefficients.
|
||||
* By default coefficients will be stored to the dsps_fft_w_table_fc32.
|
||||
* Maximum size of the FFT must be setup in menuconfig
|
||||
* @param[in] N: maximum size of the FFT that will be used
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_gen_w_r2_fc32(float *w, int N);
|
||||
esp_err_t dsps_gen_w_r2_sc16(int16_t *w, int N);
|
||||
/**@}*/
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief Convert complex array to two real arrays
|
||||
*
|
||||
* Convert complex array to two real arrays in case if input was two real arrays.
|
||||
* This function have to be used if FFT used to process real data.
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param[inout] data: Input complex array and result of FFT2R.
|
||||
* input has size of 2*N, because contains real and imaginary part.
|
||||
* result will be stored to the same array.
|
||||
* Input1: input[0..N-1], Input2: input[N..2*N-1]
|
||||
* @param[in] N: Number of complex elements in input array
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_cplx2reC_fc32_ansi(float *data, int N);
|
||||
esp_err_t dsps_cplx2reC_sc16(int16_t *data, int N);
|
||||
/**@}*/
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief Convert complex FFT result to real array
|
||||
*
|
||||
* Convert FFT result of complex FFT for resl input to real array.
|
||||
* This function have to be used if FFT used to process real data.
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param[inout] data: Input complex array and result of FFT2R.
|
||||
* input has size of 2*N, because contains real and imaginary part.
|
||||
* result will be stored to the same array.
|
||||
* Input1: input[0..N-1], Input2: input[N..2*N-1]
|
||||
* @param[in] N: Number of complex elements in input array
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_cplx2real_sc16_ansi(int16_t *data, int N);
|
||||
/**@}*/
|
||||
esp_err_t dsps_cplx2real256_fc32_ansi(float *data);
|
||||
|
||||
esp_err_t dsps_gen_bitrev2r_table(int N, int step, char *name_ext);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_DSP_OPTIMIZED
|
||||
#define dsps_bit_rev_fc32 dsps_bit_rev_fc32_ansi
|
||||
#define dsps_cplx2reC_fc32 dsps_cplx2reC_fc32_ansi
|
||||
|
||||
#if (dsps_fft2r_fc32_ae32_enabled == 1)
|
||||
#define dsps_fft2r_fc32 dsps_fft2r_fc32_ae32
|
||||
#else
|
||||
#define dsps_fft2r_fc32 dsps_fft2r_fc32_ansi
|
||||
#endif
|
||||
|
||||
#if (dsps_fft2r_sc16_ae32_enabled == 1)
|
||||
#define dsps_fft2r_sc16 dsps_fft2r_sc16_ae32
|
||||
#else
|
||||
#define dsps_fft2r_sc16 dsps_fft2r_sc16_ansi
|
||||
#endif
|
||||
|
||||
#if (dsps_bit_rev_lookup_fc32_ae32_enabled == 1)
|
||||
# define dsps_bit_rev_lookup_fc32 dsps_bit_rev_lookup_fc32_ae32
|
||||
#else
|
||||
#define dsps_bit_rev_lookup_fc32 dsps_bit_rev_lookup_fc32_ansi
|
||||
#endif
|
||||
|
||||
#else // CONFIG_DSP_OPTIMIZED
|
||||
|
||||
#define dsps_fft2r_fc32 dsps_fft2r_fc32_ansi
|
||||
#define dsps_bit_rev_fc32 dsps_bit_rev_fc32_ansi
|
||||
#define dsps_cplx2reC_fc32 dsps_cplx2reC_fc32_ansi
|
||||
#define dsps_bit_rev_sc16 dsps_bit_rev_sc16_ansi
|
||||
#define dsps_bit_rev_lookup_fc32 dsps_bit_rev_lookup_fc32_ansi
|
||||
|
||||
#endif // CONFIG_DSP_OPTIMIZED
|
||||
|
||||
#endif // _dsps_fft2r_H_
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
#ifndef _dsps_fft2r_platform_H_
|
||||
#define _dsps_fft2r_platform_H_
|
||||
|
||||
#include <xtensa/config/core-isa.h>
|
||||
#include <xtensa/config/core-matmap.h>
|
||||
|
||||
|
||||
#if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1))
|
||||
|
||||
#define dsps_fft2r_fc32_ae32_enabled 1
|
||||
|
||||
#endif //
|
||||
|
||||
#if ((XCHAL_HAVE_LOOPS == 1) && (XCHAL_HAVE_MAC16 == 1))
|
||||
|
||||
#define dsps_fft2r_sc16_ae32_enabled 1
|
||||
|
||||
#endif //
|
||||
|
||||
#if (XCHAL_HAVE_LOOPS == 1)
|
||||
|
||||
#define dsps_bit_rev_lookup_fc32_ae32_enabled 1
|
||||
|
||||
#endif //
|
||||
|
||||
|
||||
|
||||
#endif // _dsps_fft2r_platform_H_
|
||||
174
tools/sdk/esp32/include/esp-dsp/modules/fft/include/dsps_fft4r.h
Normal file
174
tools/sdk/esp32/include/esp-dsp/modules/fft/include/dsps_fft4r.h
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
// Copyright 2018-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 _dsps_fft4r_H_
|
||||
#define _dsps_fft4r_H_
|
||||
#include "dsp_err.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#include "dsps_fft_tables.h"
|
||||
#include "dsps_fft4r_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern float *dsps_fft4r_w_table_fc32;
|
||||
extern int dsps_fft4r_w_table_size;
|
||||
extern uint8_t dsps_fft4r_initialized;
|
||||
|
||||
extern int16_t *dsps_fft4r_w_table_sc16;
|
||||
extern int dsps_fft4r_w_table_sc16_size;
|
||||
extern uint8_t dsps_fft4r_sc16_initialized;
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief init fft tables
|
||||
*
|
||||
* Initialization of Complex FFT Radix-4. This function initialize coefficients table.
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param[inout] fft_table_buff: pointer to floating point buffer where sin/cos table will be stored
|
||||
* if this parameter set to NULL, and table_size value is more then 0, then
|
||||
* dsps_fft4r_init_fc32 will allocate buffer internally
|
||||
* @param[in] max_fft_size: maximum fft size. The buffer for sin/cos table that will be used for radix-4 it's
|
||||
* four times maximum length of FFT.
|
||||
* if fft_table_buff is NULL and table_size is not 0, buffer will be allocated internally.
|
||||
* If table_size is 0, buffer will not be allocated.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_DSP_PARAM_OUTOFRANGE if table_size > CONFIG_DSP_MAX_FFT_SIZE
|
||||
* - ESP_ERR_DSP_REINITIALIZED if buffer already allocated internally by other function
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_fft4r_init_fc32(float *fft_table_buff, int max_fft_size);
|
||||
/**@}*/
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief deinit fft tables
|
||||
*
|
||||
* Free resources of Complex FFT Radix-4. This function delete coefficients table if it was allocated by dsps_fft4r_init_fc32.
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
void dsps_fft4r_deinit_fc32();
|
||||
/**@}*/
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief complex FFT of radix 4
|
||||
*
|
||||
* Complex FFT of radix 4
|
||||
* The extension (_ansi) use ANSI C and could be compiled and run on any platform.
|
||||
* The extension (_ae32) is optimized for ESP32 chip.
|
||||
*
|
||||
* @param[inout] data: input/output complex array. An elements located: Re[0], Im[0], ... Re[N-1], Im[N-1]
|
||||
* result of FFT will be stored to this array.
|
||||
* @param[in] N: Number of complex elements in input array
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_fft4r_fc32_ansi_(float *data, int N, float *table, int table_size);
|
||||
esp_err_t dsps_fft4r_fc32_ae32_(float *data, int N, float *table, int table_size);
|
||||
/**@}*/
|
||||
// This is workaround because linker generates permanent error when assembler uses
|
||||
// direct access to the table pointer
|
||||
#define dsps_fft4r_fc32_ansi(data, N) dsps_fft4r_fc32_ansi_(data, N, dsps_fft4r_w_table_fc32, dsps_fft4r_w_table_size)
|
||||
#define dsps_fft4r_fc32_ae32(data, N) dsps_fft4r_fc32_ae32_(data, N, dsps_fft4r_w_table_fc32, dsps_fft4r_w_table_size)
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief bit reverse operation for the complex input array radix-4
|
||||
*
|
||||
* Bit reverse operation for the complex input array
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param[inout] data: input/ complex array. An elements located: Re[0], Im[0], ... Re[N-1], Im[N-1]
|
||||
* result of FFT will be stored to this array.
|
||||
* @param[in] N: Number of complex elements in input array
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_bit_rev4r_fc32(float *data, int N);
|
||||
esp_err_t dsps_bit_rev4r_fc32_ae32(float *data, int N);
|
||||
esp_err_t dsps_bit_rev4r_direct_fc32_ansi(float *data, int N);
|
||||
esp_err_t dsps_bit_rev4r_sc16_ansi(int16_t *data, int N);
|
||||
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief Convert complex FFT result to real array
|
||||
*
|
||||
* Convert FFT result of complex FFT for real input to real array.
|
||||
* This function have to be used if FFT used to process real data.
|
||||
* This function use tabels inside and can be used only it dsps_fft4r_init_fc32(...) was
|
||||
* called and FFT4 was initialized.
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param[inout] data: Input complex array and result of FFT2R/FFT4R.
|
||||
* input has size of 2*N, because contains real and imaginary part.
|
||||
* result will be stored to the same array.
|
||||
* Input1: input[0..N-1], Input2: input[N..2*N-1]
|
||||
* @param[in] N: Number of complex elements in input array
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_cplx2real_fc32_ansi_(float *data, int N, float *table, int table_size);
|
||||
esp_err_t dsps_cplx2real_fc32_ae32_(float *data, int N, float *table, int table_size);
|
||||
/**@}*/
|
||||
#define dsps_cplx2real_fc32_ansi(data, N) dsps_cplx2real_fc32_ansi_(data, N, dsps_fft4r_w_table_fc32, dsps_fft4r_w_table_size)
|
||||
#define dsps_cplx2real_fc32_ae32(data, N) dsps_cplx2real_fc32_ae32_(data, N, dsps_fft4r_w_table_fc32, dsps_fft4r_w_table_size)
|
||||
|
||||
|
||||
esp_err_t dsps_gen_bitrev4r_table(int N, int step, char *name_ext);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_DSP_OPTIMIZED
|
||||
#if (dsps_fft4r_fc32_ae32_enabled == 1)
|
||||
#define dsps_fft4r_fc32 dsps_fft4r_fc32_ae32
|
||||
#else
|
||||
#define dsps_fft4r_fc32 dsps_fft4r_fc32_ansi
|
||||
#endif // dsps_fft4r_fc32_ae32_enabled
|
||||
|
||||
#define dsps_fft4r_sc16 dsps_fft4r_sc16_ae32
|
||||
#define dsps_bit_rev4r_fc32 dsps_bit_rev4r_fc32_ae32
|
||||
|
||||
#if (dsps_cplx2real_fc32_ae32_enabled == 1)
|
||||
#define dsps_cplx2real_fc32 dsps_cplx2real_fc32_ae32
|
||||
#else
|
||||
#define dsps_cplx2real_fc32 dsps_cplx2real_fc32_ansi
|
||||
#endif // dsps_cplx2real_fc32_ae32_enabled
|
||||
|
||||
#else
|
||||
#define dsps_fft4r_fc32 dsps_fft4r_fc32_ansi
|
||||
#define dsps_fft4r_sc16 dsps_fft4r_sc16_ansi
|
||||
#define dsps_bit_rev4r_fc32 dsps_bit_rev4r_fc32_ansi
|
||||
#define dsps_cplx2real_fc32 dsps_cplx2real_fc32_ansi
|
||||
#endif
|
||||
|
||||
#endif // _dsps_fft4r_H_
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
#ifndef _dsps_fft4r_platform_H_
|
||||
#define _dsps_fft4r_platform_H_
|
||||
|
||||
#include <xtensa/config/core-isa.h>
|
||||
#include <xtensa/config/core-matmap.h>
|
||||
|
||||
|
||||
#if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1))
|
||||
|
||||
#define dsps_fft4r_fc32_ae32_enabled 1
|
||||
#define dsps_cplx2real_fc32_ae32_enabled 1
|
||||
|
||||
#endif //
|
||||
|
||||
|
||||
#if ((XCHAL_HAVE_LOOPS == 1) && (XCHAL_HAVE_MAC16 == 1))
|
||||
|
||||
#define dsps_fft2r_sc16_ae32_enabled 1
|
||||
|
||||
#endif //
|
||||
|
||||
#if (XCHAL_HAVE_LOOPS == 1)
|
||||
|
||||
#define dsps_bit_rev_lookup_fc32_ae32_enabled 1
|
||||
|
||||
#endif //
|
||||
|
||||
|
||||
|
||||
#endif // _dsps_fft4r_platform_H_
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
// Copyright 2018-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 _dsps_fft_tables_H_
|
||||
#define _dsps_fft_tables_H_
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
extern const uint16_t bitrev2r_table_16_fc32[];
|
||||
extern const uint16_t bitrev2r_table_16_fc32_size;
|
||||
|
||||
extern const uint16_t bitrev2r_table_32_fc32[];
|
||||
extern const uint16_t bitrev2r_table_32_fc32_size;
|
||||
|
||||
extern const uint16_t bitrev2r_table_64_fc32[];
|
||||
extern const uint16_t bitrev2r_table_64_fc32_size;
|
||||
|
||||
extern const uint16_t bitrev2r_table_128_fc32[];
|
||||
extern const uint16_t bitrev2r_table_128_fc32_size;
|
||||
|
||||
extern const uint16_t bitrev2r_table_256_fc32[];
|
||||
extern const uint16_t bitrev2r_table_256_fc32_size;
|
||||
|
||||
extern const uint16_t bitrev2r_table_512_fc32[];
|
||||
extern const uint16_t bitrev2r_table_512_fc32_size;
|
||||
|
||||
extern const uint16_t bitrev2r_table_1024_fc32[];
|
||||
extern const uint16_t bitrev2r_table_1024_fc32_size;
|
||||
|
||||
extern const uint16_t bitrev2r_table_2048_fc32[];
|
||||
extern const uint16_t bitrev2r_table_2048_fc32_size;
|
||||
|
||||
extern const uint16_t bitrev2r_table_4096_fc32[];
|
||||
extern const uint16_t bitrev2r_table_4096_fc32_size;
|
||||
|
||||
void dsps_fft2r_rev_tables_init_fc32(void);
|
||||
extern uint16_t *dsps_fft2r_rev_tables_fc32[];
|
||||
extern const uint16_t dsps_fft2r_rev_tables_fc32_size[];
|
||||
|
||||
extern const uint16_t bitrev4r_table_16_fc32[];
|
||||
extern const uint16_t bitrev4r_table_16_fc32_size;
|
||||
|
||||
extern const uint16_t bitrev4r_table_32_fc32[];
|
||||
extern const uint16_t bitrev4r_table_32_fc32_size;
|
||||
|
||||
extern const uint16_t bitrev4r_table_64_fc32[];
|
||||
extern const uint16_t bitrev4r_table_64_fc32_size;
|
||||
|
||||
extern const uint16_t bitrev4r_table_128_fc32[];
|
||||
extern const uint16_t bitrev4r_table_128_fc32_size;
|
||||
|
||||
extern const uint16_t bitrev4r_table_256_fc32[];
|
||||
extern const uint16_t bitrev4r_table_256_fc32_size;
|
||||
|
||||
extern const uint16_t bitrev4r_table_512_fc32[];
|
||||
extern const uint16_t bitrev4r_table_512_fc32_size;
|
||||
|
||||
extern const uint16_t bitrev4r_table_1024_fc32[];
|
||||
extern const uint16_t bitrev4r_table_1024_fc32_size;
|
||||
|
||||
extern const uint16_t bitrev4r_table_2048_fc32[];
|
||||
extern const uint16_t bitrev4r_table_2048_fc32_size;
|
||||
|
||||
extern const uint16_t bitrev4r_table_4096_fc32[];
|
||||
extern const uint16_t bitrev4r_table_4096_fc32_size;
|
||||
|
||||
void dsps_fft4r_rev_tables_init_fc32(void);
|
||||
extern uint16_t *dsps_fft4r_rev_tables_fc32[];
|
||||
extern const uint16_t dsps_fft4r_rev_tables_fc32_size[];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _dsps_fft_tables_H_
|
||||
146
tools/sdk/esp32/include/esp-dsp/modules/fir/include/dsps_fir.h
Normal file
146
tools/sdk/esp32/include/esp-dsp/modules/fir/include/dsps_fir.h
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
// Copyright 2018-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 _dsps_fir_H_
|
||||
#define _dsps_fir_H_
|
||||
|
||||
|
||||
#include "dsp_err.h"
|
||||
|
||||
#include "dsps_fir_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Data struct of f32 fir filter
|
||||
*
|
||||
* This structure used by filter internally. User should access this structure only in case of
|
||||
* extensions for the DSP Library.
|
||||
* All fields of this structure initialized by dsps_fir_init_f32(...) function.
|
||||
*/
|
||||
typedef struct fir_f32_s {
|
||||
float *coeffs; /*!< Pointer to the coefficient buffer.*/
|
||||
float *delay; /*!< Pointer to the delay line buffer.*/
|
||||
int N; /*!< FIR filter coefficients amount.*/
|
||||
int pos; /*!< Position in delay line.*/
|
||||
int decim; /*!< Decimation factor.*/
|
||||
int d_pos; /*!< Actual decimation counter.*/
|
||||
} fir_f32_t;
|
||||
|
||||
/**
|
||||
* @brief initialize structure for 32 bit FIR filter
|
||||
*
|
||||
* Function initialize structure for 32 bit floating point FIR filter
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param fir: pointer to fir filter structure, that must be preallocated
|
||||
* @param coeffs: array with FIR filter coefficients. Must be length N
|
||||
* @param delay: array for FIR filter delay line. Must be length N
|
||||
* @param N: FIR filter length. Length of coeffs and delay arrays.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_fir_init_f32(fir_f32_t *fir, float *coeffs, float *delay, int N);
|
||||
|
||||
/**
|
||||
* @brief initialize structure for 32 bit Decimation FIR filter
|
||||
* Function initialize structure for 32 bit floating point FIR filter with decimation
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param fir: pointer to fir filter structure, that must be preallocated
|
||||
* @param coeffs: array with FIR filter coefficients. Must be length N
|
||||
* @param delay: array for FIR filter delay line. Must be length N
|
||||
* @param N: FIR filter length. Length of coeffs and delay arrays.
|
||||
* @param decim: decimation factor.
|
||||
* @param start_pos: initial value of decimation counter. Must be [0..d)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_fird_init_f32(fir_f32_t *fir, float *coeffs, float *delay, int N, int decim, int start_pos);
|
||||
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief FIR filter
|
||||
*
|
||||
* Function implements FIR filter
|
||||
* The extension (_ansi) use ANSI C and could be compiled and run on any platform.
|
||||
* The extension (_ae32) is optimized for ESP32 chip.
|
||||
*
|
||||
* @param fir: pointer to fir filter structure, that must be initialized before
|
||||
* @param[in] input: input array
|
||||
* @param[out] output: array with result of FIR filter
|
||||
* @param[in] len: length of input and result arrays
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_fir_f32_ansi(fir_f32_t *fir, const float *input, float *output, int len);
|
||||
esp_err_t dsps_fir_f32_ae32(fir_f32_t *fir, const float *input, float *output, int len);
|
||||
/**@}*/
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief Decimation FIR filter
|
||||
*
|
||||
* Function implements FIR filter with decimation
|
||||
* The extension (_ansi) use ANSI C and could be compiled and run on any platform.
|
||||
* The extension (_ae32) is optimized for ESP32 chip.
|
||||
*
|
||||
* @param fir: pointer to fir filter structure, that must be initialized before
|
||||
* @param input: input array
|
||||
* @param output: array with result of FIR filter
|
||||
* @param len: length of input and result arrays
|
||||
*
|
||||
* @return: function returns amount of samples stored to the output array
|
||||
* depends on the previous state value could be [0..len/decimation]
|
||||
*/
|
||||
int dsps_fird_f32_ansi(fir_f32_t *fir, const float *input, float *output, int len);
|
||||
int dsps_fird_f32_ae32(fir_f32_t *fir, const float *input, float *output, int len);
|
||||
/**@}*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if CONFIG_DSP_OPTIMIZED
|
||||
|
||||
#if (dsps_fir_f32_ae32_enabled == 1)
|
||||
#define dsps_fir_f32 dsps_fir_f32_ae32
|
||||
#else
|
||||
#define dsps_fir_f32 dsps_fir_f32_ansi
|
||||
#endif
|
||||
|
||||
#if (dsps_fird_f32_ae32_enabled == 1)
|
||||
#define dsps_fird_f32 dsps_fird_f32_ae32
|
||||
#else
|
||||
#define dsps_fird_f32 dsps_fird_f32_ansi
|
||||
#endif
|
||||
|
||||
#else // CONFIG_DSP_OPTIMIZED
|
||||
#define dsps_fir_f32 dsps_fir_f32_ansi
|
||||
#define dsps_fird_f32 dsps_fird_f32_ansi
|
||||
#endif // CONFIG_DSP_OPTIMIZED
|
||||
|
||||
#endif // _dsps_fir_H_
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
#ifndef _dsps_fir_platform_H_
|
||||
#define _dsps_fir_platform_H_
|
||||
|
||||
#include <xtensa/config/core-isa.h>
|
||||
#include <xtensa/config/core-matmap.h>
|
||||
|
||||
|
||||
#if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1))
|
||||
|
||||
#define dsps_fir_f32_ae32_enabled 1
|
||||
#define dsps_fird_f32_ae32_enabled 1
|
||||
|
||||
#endif //
|
||||
|
||||
#endif // _dsps_fir_platform_H_
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
// Copyright 2018-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 _dsps_biquad_H_
|
||||
#define _dsps_biquad_H_
|
||||
|
||||
#include "dsp_err.h"
|
||||
|
||||
#include "dsps_add_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief IIR filter
|
||||
*
|
||||
* IIR filter 2nd order direct form II (bi quad)
|
||||
* The extension (_ansi) use ANSI C and could be compiled and run on any platform.
|
||||
* The extension (_ae32) is optimized for ESP32 chip.
|
||||
*
|
||||
* @param[in] input: input array
|
||||
* @param output: output array
|
||||
* @param len: length of input and output vectors
|
||||
* @param coef: array of coefficients. b0,b1,b2,a1,a2
|
||||
* expected that a0 = 1. b0..b2 - numerator, a0..a2 - denominator
|
||||
* @param w: delay line w0,w1. Length of 2.
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_biquad_f32_ansi(const float *input, float *output, int len, float *coef, float *w);
|
||||
esp_err_t dsps_biquad_f32_ae32(const float *input, float *output, int len, float *coef, float *w);
|
||||
/**@}*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_DSP_OPTIMIZED
|
||||
#if (dsps_biquad_f32_ae32_enabled == 1)
|
||||
#define dsps_biquad_f32 dsps_biquad_f32_ae32
|
||||
#else
|
||||
#define dsps_biquad_f32 dsps_biquad_f32_ansi
|
||||
#endif
|
||||
#else // CONFIG_DSP_OPTIMIZED
|
||||
#define dsps_biquad_f32 dsps_biquad_f32_ansi
|
||||
#endif // CONFIG_DSP_OPTIMIZED
|
||||
|
||||
|
||||
#endif // _dsps_biquad_H_
|
||||
|
|
@ -0,0 +1,200 @@
|
|||
// Copyright 2018-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 _dsps_biquad_gen_H_
|
||||
#define _dsps_biquad_gen_H_
|
||||
|
||||
#include "dsp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
// Common rules for all generated coefficients.
|
||||
// The coefficients placed to the array as follows:
|
||||
// coeffs[0] = b0;
|
||||
// coeffs[1] = b1;
|
||||
// coeffs[2] = b2;
|
||||
// coeffs[3] = a1;
|
||||
// coeffs[4] = a2;
|
||||
// a0 - are not placed and expected always as == 1
|
||||
|
||||
/**
|
||||
* @brief LPF IIR filter coefficients
|
||||
* Coefficients for low pass 2nd order IIR filter (bi-quad)
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param coeffs: result coefficients. b0,b1,b2,a1,a2, a0 are not placed to the array and expected by IIR as 1
|
||||
* @param f: filter cut off frequency in range of 0..0.5 (normalized to sample frequency)
|
||||
* @param qFactor: Q factor of filter
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_biquad_gen_lpf_f32(float *coeffs, float f, float qFactor);
|
||||
|
||||
/**
|
||||
* @brief HPF IIR filter coefficients
|
||||
*
|
||||
* Coefficients for high pass 2nd order IIR filter (bi-quad)
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param coeffs: result coefficients. b0,b1,b2,a1,a2, a0 are not placed to the array and expected by IIR as 1
|
||||
* @param f: filter cut off frequency in range of 0..0.5 (normalized to sample frequency)
|
||||
* @param qFactor: Q factor of filter
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_biquad_gen_hpf_f32(float *coeffs, float f, float qFactor);
|
||||
|
||||
/**
|
||||
* @brief BPF IIR filter coefficients
|
||||
*
|
||||
* Coefficients for band pass 2nd order IIR filter (bi-quad)
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param coeffs: result coefficients. b0,b1,b2,a1,a2, a0 are not placed to the array and expected by IIR as 1
|
||||
* @param f: filter center frequency in range of 0..0.5 (normalized to sample frequency)
|
||||
* @param qFactor: Q factor of filter
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_biquad_gen_bpf_f32(float *coeffs, float f, float qFactor);
|
||||
|
||||
/**
|
||||
* @brief 0 dB BPF IIR filter coefficients
|
||||
*
|
||||
* Coefficients for band pass 2nd order IIR filter (bi-quad) with 0 dB gain in passband
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param coeffs: result coefficients. b0,b1,b2,a1,a2, a0 are not placed to the array and expected by IIR as 1
|
||||
* @param f: filter center frequency in range of 0..0.5 (normalized to sample frequency)
|
||||
* @param qFactor: Q factor of filter
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_biquad_gen_bpf0db_f32(float *coeffs, float f, float qFactor);
|
||||
|
||||
/**
|
||||
* @brief Notch IIR filter coefficients
|
||||
*
|
||||
* Coefficients for notch 2nd order IIR filter (bi-quad)
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param coeffs: result coefficients. b0,b1,b2,a1,a2, a0 are not placed to the array and expected by IIR as 1
|
||||
* @param f: filter notch frequency in range of 0..0.5 (normalized to sample frequency)
|
||||
* @param gain: gain in stopband in dB
|
||||
* @param qFactor: Q factor of filter
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_biquad_gen_notch_f32(float *coeffs, float f, float gain, float qFactor);
|
||||
|
||||
/**
|
||||
* @brief Allpass 360 degree IIR filter coefficients
|
||||
*
|
||||
* Coefficients for all pass 2nd order IIR filter (bi-quad) with 360 degree phase shift
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param coeffs: result coefficients. b0,b1,b2,a1,a2, a0 are not placed to the array and expected by IIR as 1
|
||||
* @param f: filter notch frequency in range of 0..0.5 (normalized to sample frequency)
|
||||
* @param qFactor: Q factor of filter
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_biquad_gen_allpass360_f32(float *coeffs, float f, float qFactor);
|
||||
|
||||
/**
|
||||
* @brief Allpass 180 degree IIR filter coefficients
|
||||
*
|
||||
* Coefficients for all pass 2nd order IIR filter (bi-quad) with 180 degree phase shift
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param coeffs: result coefficients. b0,b1,b2,a1,a2, a0 are not placed to the array and expected by IIR as 1
|
||||
* @param f: filter notch frequency in range of 0..0.5 (normalized to sample frequency)
|
||||
* @param qFactor: Q factor of filter
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_biquad_gen_allpass180_f32(float *coeffs, float f, float qFactor);
|
||||
|
||||
/**
|
||||
* @brief peak IIR filter coefficients
|
||||
*
|
||||
* Coefficients for peak 2nd order IIR filter (bi-quad)
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param coeffs: result coefficients. b0,b1,b2,a1,a2, a0 are not placed to the array and expected by IIR as 1
|
||||
* @param f: filter notch frequency in range of 0..0.5 (normalized to sample frequency)
|
||||
* @param qFactor: Q factor of filter
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_biquad_gen_peakingEQ_f32(float *coeffs, float f, float qFactor);
|
||||
|
||||
/**
|
||||
* @brief low shelf IIR filter coefficients
|
||||
*
|
||||
* Coefficients for low pass Shelf 2nd order IIR filter (bi-quad)
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param coeffs: result coefficients. b0,b1,b2,a1,a2, a0 are not placed to the array and expected by IIR as 1
|
||||
* @param f: filter notch frequency in range of 0..0.5 (normalized to sample frequency)
|
||||
* @param gain: gain in stopband in dB
|
||||
* @param qFactor: Q factor of filter
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_biquad_gen_lowShelf_f32(float *coeffs, float f, float gain, float qFactor);
|
||||
|
||||
/**
|
||||
* @brief high shelf IIR filter coefficients
|
||||
*
|
||||
* Coefficients for high pass Shelf 2nd order IIR filter (bi-quad)
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param coeffs: result coefficients. b0,b1,b2,a1,a2, a0 are not placed to the array and expected by IIR as 1
|
||||
* @param f: filter notch frequency in range of 0..0.5 (normalized to sample frequency)
|
||||
* @param gain: gain in stopband in dB
|
||||
* @param qFactor: Q factor of filter
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_biquad_gen_highShelf_f32(float *coeffs, float f, float gain, float qFactor);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _dsps_biquad_gen_H_
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef _dsps_biquad_platform_H_
|
||||
#define _dsps_biquad_platform_H_
|
||||
|
||||
#include <xtensa/config/core-isa.h>
|
||||
#include <xtensa/config/core-matmap.h>
|
||||
|
||||
|
||||
#if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1))
|
||||
|
||||
#define dsps_biquad_f32_ae32_enabled 1
|
||||
|
||||
#endif
|
||||
|
||||
#endif // _dsps_biquad_platform_H_
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
// Copyright 2018-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 _dsps_add_H_
|
||||
#define _dsps_add_H_
|
||||
#include "dsp_err.h"
|
||||
|
||||
#include "dsps_add_platform.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief add two arrays
|
||||
*
|
||||
* The function add one input array to another
|
||||
* out[i*step_out] = input1[i*step1] + input2[i*step2]; i=[0..len)
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param[in] input1: input array 1
|
||||
* @param[in] input2: input array 2
|
||||
* @param output: output array
|
||||
* @param len: amount of operations for arrays
|
||||
* @param step1: step over input array 1 (by default should be 1)
|
||||
* @param step2: step over input array 2 (by default should be 1)
|
||||
* @param step_out: step over output array (by default should be 1)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_add_f32_ansi(const float *input1, const float *input2, float *output, int len, int step1, int step2, int step_out);
|
||||
esp_err_t dsps_add_f32_ae32(const float *input1, const float *input2, float *output, int len, int step1, int step2, int step_out);
|
||||
|
||||
esp_err_t dsps_add_s16_ansi(const int16_t *input1, const int16_t *input2, int16_t *output, int len, int step1, int step2, int step_out, int shift);
|
||||
esp_err_t dsps_add_s16_ae32(const int16_t *input1, const int16_t *input2, int16_t *output, int len, int step1, int step2, int step_out, int shift);
|
||||
/**@}*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_DSP_OPTIMIZED
|
||||
|
||||
#if (dsps_add_f32_ae32_enabled == 1)
|
||||
#define dsps_add_f32 dsps_add_f32_ae32
|
||||
#else
|
||||
#define dsps_add_f32 dsps_add_f32_ansi
|
||||
#endif
|
||||
|
||||
#if (dsps_add_s16_ae32_enabled == 1)
|
||||
#define dsps_add_s16 dsps_add_s16_ae32
|
||||
#else
|
||||
#define dsps_add_s16 dsps_add_s16_ansi
|
||||
#endif
|
||||
|
||||
#else // CONFIG_DSP_OPTIMIZED
|
||||
#define dsps_add_f32 dsps_add_f32_ansi
|
||||
#define dsps_add_s16 dsps_add_s16_ansi
|
||||
#endif // CONFIG_DSP_OPTIMIZED
|
||||
|
||||
#endif // _dsps_add_H_
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef _dsps_add_platform_H_
|
||||
#define _dsps_add_platform_H_
|
||||
|
||||
#include <xtensa/config/core-isa.h>
|
||||
#include <xtensa/config/core-matmap.h>
|
||||
|
||||
|
||||
#if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1))
|
||||
|
||||
#define dsps_add_f32_ae32_enabled 1
|
||||
|
||||
#endif
|
||||
|
||||
#if (XCHAL_HAVE_LOOPS == 1)
|
||||
#define dsps_add_s16_ae32_enabled 1
|
||||
#endif
|
||||
|
||||
|
||||
#endif // _dsps_add_platform_H_
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
// Copyright 2018-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 _dsps_addc_H_
|
||||
#define _dsps_addc_H_
|
||||
#include "dsp_err.h"
|
||||
|
||||
#include "dsps_addc_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief add constant
|
||||
*
|
||||
* The function adds constant to the input array
|
||||
* x[i*step_out] = y[i*step_in] + C; i=[0..len)
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param[in] input: input array
|
||||
* @param output: output array
|
||||
* @param len: amount of operations for arrays
|
||||
* @param C: constant value
|
||||
* @param step_in: step over input array (by default should be 1)
|
||||
* @param step_out: step over output array (by default should be 1)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_addc_f32_ansi(const float *input, float *output, int len, float C, int step_in, int step_out);
|
||||
esp_err_t dsps_addc_f32_ae32(const float *input, float *output, int len, float C, int step_in, int step_out);
|
||||
/**@}*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if CONFIG_DSP_OPTIMIZED
|
||||
#if (dsps_addc_f32_ae32_enabled == 1)
|
||||
#define dsps_addc_f32 dsps_addc_f32_ae32
|
||||
#else
|
||||
#define dsps_addc_f32 dsps_addc_f32_ansi
|
||||
#endif
|
||||
#else
|
||||
#define dsps_addc_f32 dsps_addc_f32_ansi
|
||||
#endif // CONFIG_DSP_OPTIMIZED
|
||||
|
||||
#endif // _dsps_addc_H_
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
#ifndef _dsps_addc_platform_H_
|
||||
#define _dsps_addc_platform_H_
|
||||
|
||||
#include <xtensa/config/core-isa.h>
|
||||
#include <xtensa/config/core-matmap.h>
|
||||
|
||||
|
||||
#if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1))
|
||||
|
||||
#define dsps_addc_f32_ae32_enabled 1
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif // _dsps_addc_platform_H_
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2018-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 _dsps_math_H_
|
||||
#define _dsps_math_H_
|
||||
|
||||
#include "dsps_add.h"
|
||||
#include "dsps_sub.h"
|
||||
#include "dsps_mul.h"
|
||||
#include "dsps_addc.h"
|
||||
#include "dsps_mulc.h"
|
||||
#include "dsps_sqrt.h"
|
||||
|
||||
#endif // _dsps_math_H_
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
// Copyright 2018-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 _dsps_mul_H_
|
||||
#define _dsps_mul_H_
|
||||
#include "dsp_err.h"
|
||||
|
||||
#include "dsps_mul_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief Multiply two arrays
|
||||
*
|
||||
* The function multiply one input array to another and store result to other array
|
||||
* out[i*step_out] = input1[i*step1] * input2[i*step2]; i=[0..len)
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param[in] input1: input array 1
|
||||
* @param[in] input2: input array 2
|
||||
* @param output: output array
|
||||
* @param len: amount of operations for arrays
|
||||
* @param step1: step over input array 1 (by default should be 1)
|
||||
* @param step2: step over input array 2 (by default should be 1)
|
||||
* @param step_out: step over output array (by default should be 1)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_mul_f32_ansi(const float *input1, const float *input2, float *output, int len, int step1, int step2, int step_out);
|
||||
esp_err_t dsps_mul_f32_ae32(const float *input1, const float *input2, float *output, int len, int step1, int step2, int step_out);
|
||||
/**@}*/
|
||||
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief Multiply two arrays
|
||||
*
|
||||
* The function multiply one input array to another and store result to other array
|
||||
* out[i*step_out] = input1[i*step1] * input2[i*step2]; i=[0..len)
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param[in] input1: input array 1
|
||||
* @param[in] input2: input array 2
|
||||
* @param output: output array
|
||||
* @param len: amount of operations for arrays
|
||||
* @param step1: step over input array 1 (by default should be 1)
|
||||
* @param step2: step over input array 2 (by default should be 1)
|
||||
* @param step_out: step over output array (by default should be 1)
|
||||
* @param shift: output shift after multiplication (by default should be 15)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_mul_s16_ansi(const int16_t *input1, const int16_t *input2, int16_t *output, int len, int step1, int step2, int step_out, int shift);
|
||||
|
||||
/**@}*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_DSP_OPTIMIZED
|
||||
#if (dsps_mul_f32_ae32_enabled == 1)
|
||||
#define dsps_mul_f32 dsps_mul_f32_ae32
|
||||
#else
|
||||
#define dsps_mul_f32 dsps_mul_f32_ansi
|
||||
#endif //
|
||||
#define dsps_mul_s16 dsps_mul_s16_ansi
|
||||
#else // CONFIG_DSP_OPTIMIZED
|
||||
#define dsps_mul_f32 dsps_mul_f32_ansi
|
||||
#define dsps_mul_s16 dsps_mul_s16_ansi
|
||||
#endif
|
||||
#endif // _dsps_mul_H_
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef _dsps_mul_platform_H_
|
||||
#define _dsps_mul_platform_H_
|
||||
|
||||
#include <xtensa/config/core-isa.h>
|
||||
#include <xtensa/config/core-matmap.h>
|
||||
|
||||
|
||||
#if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1))
|
||||
|
||||
#define dsps_mul_f32_ae32_enabled 1
|
||||
|
||||
#endif
|
||||
|
||||
#endif // _dsps_mul_platform_H_
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
// Copyright 2018-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 _dsps_mulc_H_
|
||||
#define _dsps_mulc_H_
|
||||
#include "dsp_err.h"
|
||||
|
||||
#include "dsps_mulc_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief multiply constant
|
||||
*
|
||||
* The function multiplies input array to the constant value
|
||||
* x[i*step_out] = y[i*step_in]*C; i=[0..len)
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param[in] input: input array
|
||||
* @param output: output array
|
||||
* @param len: amount of operations for arrays
|
||||
* @param C: constant value
|
||||
* @param step_in: step over input array (by default should be 1)
|
||||
* @param step_out: step over output array (by default should be 1)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_mulc_f32_ansi(const float *input, float *output, int len, float C, int step_in, int step_out);
|
||||
esp_err_t dsps_mulc_f32_ae32(const float *input, float *output, int len, float C, int step_in, int step_out);
|
||||
|
||||
esp_err_t dsps_mulc_s16_ae32(const int16_t *input, int16_t *output, int len, int16_t C, int step_in, int step_out);
|
||||
esp_err_t dsps_mulc_s16_ansi(const int16_t *input, int16_t *output, int len, int16_t C, int step_in, int step_out);
|
||||
|
||||
/**@}*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_DSP_OPTIMIZED
|
||||
#if (dsps_mulc_f32_ae32_enabled == 1)
|
||||
#define dsps_mulc_f32 dsps_mulc_f32_ae32
|
||||
#else //
|
||||
#define dsps_mulc_f32 dsps_mulc_f32_ansi
|
||||
#endif
|
||||
#if (dsps_mulc_s16_ae32_enabled == 1)
|
||||
#define dsps_mulc_s16 dsps_mulc_s16_ae32
|
||||
#else
|
||||
#define dsps_mulc_s16 dsps_mulc_s16_ansi
|
||||
#endif // dsps_mulc_s16_ae32_enabled
|
||||
|
||||
#else
|
||||
#define dsps_mulc_f32 dsps_mulc_f32_ansi
|
||||
#define dsps_mulc_s16 dsps_mulc_s16_ansi
|
||||
#endif
|
||||
|
||||
|
||||
#endif // _dsps_mulc_H_
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
#ifndef _dsps_mulc_platform_H_
|
||||
#define _dsps_mulc_platform_H_
|
||||
|
||||
#include <xtensa/config/core-isa.h>
|
||||
#include <xtensa/config/core-matmap.h>
|
||||
|
||||
|
||||
#if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1))
|
||||
|
||||
#define dsps_mulc_f32_ae32_enabled 1
|
||||
|
||||
#endif
|
||||
|
||||
#if ((XCHAL_HAVE_LOOPS == 1) && (XCHAL_HAVE_MAC16 == 1))
|
||||
|
||||
#define dsps_mulc_s16_ae32_enabled 1
|
||||
|
||||
#endif //
|
||||
|
||||
|
||||
#endif // _dsps_mulc_platform_H_
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
// Copyright 2018-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 _dsps_sqrt_H_
|
||||
#define _dsps_sqrt_H_
|
||||
#include "dsp_err.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief square root approximation
|
||||
*
|
||||
* The function takes square root approximation
|
||||
* x[i] ~ sqrt(y[i]); i=[0..len)
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param[in] input: input array
|
||||
* @param output: output array
|
||||
* @param len: amount of operations for arrays
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_sqrt_f32_ansi(const float *input, float *output, int len);
|
||||
//esp_err_t dsps_sqrt_s32_ansi(const int32_t *input, int16_t *output, int len);
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief square root approximation
|
||||
*
|
||||
* The function takes square root approximation
|
||||
* x ~ sqrt(y);
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param[in] data: input value
|
||||
*
|
||||
* @return
|
||||
* - square root value
|
||||
*/
|
||||
float dsps_sqrtf_f32_ansi(const float data);
|
||||
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief inverted square root approximation
|
||||
*
|
||||
* The function takes inverted square root approximation
|
||||
* x ~ 1/sqrt(y);
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param[in] data: input value
|
||||
*
|
||||
* @return
|
||||
* - inverted square root value
|
||||
*/
|
||||
float dsps_inverted_sqrtf_f32_ansi(float data );
|
||||
/**@}*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CONFIG_DSP_OPTIMIZED
|
||||
#define dsps_sqrt_f32 dsps_sqrt_f32_ansi
|
||||
#define dsps_sqrtf_f32 dsps_sqrtf_f32_ansi
|
||||
#define dsps_inverted_sqrtf_f32 dsps_inverted_sqrtf_f32_ansi
|
||||
#else
|
||||
#define dsps_sqrt_f32 dsps_sqrt_f32_ansi
|
||||
#define dsps_sqrtf_f32 dsps_sqrtf_f32_ansi
|
||||
#define dsps_inverted_sqrtf_f32 dsps_inverted_sqrtf_f32_ansi
|
||||
#endif
|
||||
|
||||
#endif // _dsps_sqrt_H_
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
// Copyright 2018-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 _dsps_sub_H_
|
||||
#define _dsps_sub_H_
|
||||
#include "dsp_err.h"
|
||||
|
||||
#include "dsps_sub_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief sub arrays
|
||||
*
|
||||
* The function subtract one array from another
|
||||
* out[i*step_out] = input1[i*step1] - input2[i*step2]; i=[0..len)
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param[in] input1: input array 1
|
||||
* @param[in] input2: input array 2
|
||||
* @param output: output array
|
||||
* @param len: amount of operations for arrays
|
||||
* @param step1: step over input array 1 (by default should be 1)
|
||||
* @param step2: step over input array 2 (by default should be 1)
|
||||
* @param step_out: step over output array (by default should be 1)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_sub_f32_ansi(const float *input1, const float *input2, float *output, int len, int step1, int step2, int step_out);
|
||||
esp_err_t dsps_sub_f32_ae32(const float *input1, const float *input2, float *output, int len, int step1, int step2, int step_out);
|
||||
/**@}*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_DSP_OPTIMIZED
|
||||
|
||||
#if (dsps_sub_f32_ae32_enabled == 1)
|
||||
#define dsps_sub_f32 dsps_sub_f32_ae32
|
||||
#else
|
||||
#define dsps_sub_f32 dsps_sub_f32_ansi
|
||||
#endif
|
||||
#else
|
||||
#define dsps_sub_f32 dsps_sub_f32_ansi
|
||||
#endif // CONFIG_DSP_OPTIMIZED
|
||||
|
||||
|
||||
#endif // _dsps_sub_H_
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef _dsps_sub_platform_H_
|
||||
#define _dsps_sub_platform_H_
|
||||
|
||||
#include <xtensa/config/core-isa.h>
|
||||
#include <xtensa/config/core-matmap.h>
|
||||
|
||||
|
||||
#if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1))
|
||||
|
||||
#define dsps_sub_f32_ae32_enabled 1
|
||||
|
||||
#endif
|
||||
|
||||
#endif // _dsps_sub_platform_H_
|
||||
|
|
@ -0,0 +1,182 @@
|
|||
// Copyright 2018-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 _dspm_mult_H_
|
||||
#define _dspm_mult_H_
|
||||
|
||||
#include "dsp_err.h"
|
||||
#include "dspm_mult_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief Matrix multiplication
|
||||
*
|
||||
* Matrix multiplication for two floating point matrices: C[m][k] = A[m][n] * B[n][k]
|
||||
* The extension (_ansi) use ANSI C and could be compiled and run on any platform.
|
||||
* The extension (_ae32) is optimized for ESP32 chip.
|
||||
*
|
||||
* @param[in] A input matrix A[m][n]
|
||||
* @param[in] B input matrix B[n][k]
|
||||
* @param C result matrix C[m][k]
|
||||
* @param[in] m matrix dimension
|
||||
* @param[in] n matrix dimension
|
||||
* @param[in] k matrix dimension
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dspm_mult_f32_ansi(const float *A, const float *B, float *C, int m, int n, int k);
|
||||
esp_err_t dspm_mult_f32_ae32(const float *A, const float *B, float *C, int m, int n, int k);
|
||||
/**@}*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief Matrix multiplication A[3x3]xB[3x1]
|
||||
*
|
||||
* Matrix multiplication for two floating point matrices 3x3 and 3x1: C[1][3] = A[3][3] * B[3][1]
|
||||
* The implementation is optimized for ESP32 chip.
|
||||
*
|
||||
* @param[in] A input matrix A[3][3]
|
||||
* @param[in] B input matrix/vector B[3][1]
|
||||
* @param C result matrix/vector C[3][3]
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dspm_mult_3x3x1_f32_ae32(const float *A, const float *B, float *C);
|
||||
|
||||
/**
|
||||
* @brief Matrix multiplication A[3x3]xB[3x3]
|
||||
*
|
||||
* Matrix multiplication for two square 3x3 floating point matrices: C[3][3] = A[3][3] * B[3][3]
|
||||
* The implementation is optimized for ESP32 chip.
|
||||
*
|
||||
* @param[in] A input matrix A[3][3]
|
||||
* @param[in] B input matrix B[3][3]
|
||||
* @param C result matrix C[3][3]
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dspm_mult_3x3x3_f32_ae32(const float *A, const float *B, float *C);
|
||||
|
||||
/**
|
||||
* @brief Matrix multiplication A[4x4]xB[4x1]
|
||||
*
|
||||
* Matrix multiplication for two floating point matrices 4x4 and 4x1: C[1][4] = A[4][4] * B[4][1]
|
||||
* The implementation is optimized for ESP32 chip.
|
||||
*
|
||||
* @param[in] A input matrix A[4][4]
|
||||
* @param[in] B input matrix/vector B[4][1]
|
||||
* @param C result matrix/vector C[4][4]
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
|
||||
esp_err_t dspm_mult_4x4x1_f32_ae32(const float *A, const float *B, float *C);
|
||||
|
||||
/**
|
||||
* @brief Matrix multiplication A[4x4]xB[4x4]
|
||||
*
|
||||
* Matrix multiplication for two square 3x3 floating point matrices: C[4][4] = A[4][4] * B[4][4]
|
||||
* The implementation is optimized for ESP32 chip.
|
||||
*
|
||||
* @param[in] A input matrix A[4][4]
|
||||
* @param[in] B input matrix B[4][4]
|
||||
* @param C result matrix C[4][4]
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dspm_mult_4x4x4_f32_ae32(const float *A, const float *B, float *C);
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief Matrix multiplication 16 bit signeg int
|
||||
*
|
||||
* Matrix multiplication for two signed 16 bit fixed point matrices: C[m][k] = (A[m][n] * B[n][k]) >> (15- shift)
|
||||
* The extension (_ansi) use ANSI C and could be compiled and run on any platform.
|
||||
* The extension (_ae32) is optimized for ESP32 chip.
|
||||
*
|
||||
* @param[in] A input matrix A[m][n]
|
||||
* @param[in] B input matrix B[n][k]
|
||||
* @param C result matrix C[m][k]
|
||||
* @param[in] m matrix dimension
|
||||
* @param[in] n matrix dimension
|
||||
* @param[in] k matrix dimension
|
||||
* @param[in] shift every result will be shifted and stored as 16 bit signed value.
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dspm_mult_s16_ansi(const int16_t *A, const int16_t *B, int16_t *C, int m, int n, int k, int shift);
|
||||
esp_err_t dspm_mult_s16_ae32(const int16_t *A, const int16_t *B, int16_t *C, int m, int n, int k, int shift);
|
||||
/**@}*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_DSP_OPTIMIZED
|
||||
|
||||
#if (dspm_mult_s16_ae32_enabled == 1)
|
||||
#define dspm_mult_s16 dspm_mult_s16_ae32
|
||||
#else
|
||||
#define dspm_mult_s16 dspm_mult_s16_ansi
|
||||
#endif
|
||||
|
||||
#if (dspm_mult_f32_ae32_enabled == 1)
|
||||
#define dspm_mult_f32 dspm_mult_f32_ae32
|
||||
#else
|
||||
#define dspm_mult_f32 dspm_mult_f32_ansi
|
||||
#endif
|
||||
|
||||
#if (dspm_mult_3x3x1_f32_ae32_enabled == 1)
|
||||
#define dspm_mult_3x3x1_f32 dspm_mult_3x3x1_f32_ae32
|
||||
#else
|
||||
#define dspm_mult_3x3x1_f32(A,B,C) dspm_mult_f32_ansi(A,B,C, 3, 3, 1)
|
||||
#endif
|
||||
#if (dspm_mult_3x3x3_f32_ae32_enabled == 1)
|
||||
#define dspm_mult_3x3x3_f32(A,B,C) dspm_mult_f32_ansi(A,B,C, 3, 3, 3)
|
||||
#else
|
||||
#define dsps_sub_f32 dsps_sub_f32_ansi
|
||||
#endif
|
||||
#if (dspm_mult_4x4x1_f32_ae32_enabled == 1)
|
||||
#define dspm_mult_4x4x1_f32(A,B,C) dspm_mult_f32_ansi(A,B,C, 4, 4, 1)
|
||||
#else
|
||||
#define dsps_sub_f32 dsps_sub_f32_ansi
|
||||
#endif
|
||||
#if (dspm_mult_4x4x4_f32_ae32_enabled == 1)
|
||||
#define dspm_mult_4x4x4_f32 dspm_mult_4x4x4_f32_ae32
|
||||
#else
|
||||
#define dspm_mult_4x4x4_f32(A,B,C) dspm_mult_f32_ansi(A,B,C, 4, 4, 4)
|
||||
#endif
|
||||
|
||||
#else
|
||||
#define dspm_mult_s16 dspm_mult_s16_ansi
|
||||
#define dspm_mult_f32 dspm_mult_f32_ansi
|
||||
#define dspm_mult_3x3x1_f32(A,B,C) dspm_mult_f32_ansi(A,B,C, 3, 3, 1)
|
||||
#define dsps_sub_f32 dsps_sub_f32_ansi
|
||||
#define dsps_sub_f32 dsps_sub_f32_ansi
|
||||
#define dspm_mult_4x4x4_f32(A,B,C) dspm_mult_f32_ansi(A,B,C, 4, 4, 4)
|
||||
#endif // CONFIG_DSP_OPTIMIZED
|
||||
|
||||
|
||||
#endif // _dspm_mult_H_
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
#ifndef _dspm_mult_platform_H_
|
||||
#define _dspm_mult_platform_H_
|
||||
|
||||
|
||||
|
||||
#include <xtensa/config/core-isa.h>
|
||||
#include <xtensa/config/core-matmap.h>
|
||||
|
||||
|
||||
#if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1))
|
||||
|
||||
#define dspm_mult_f32_ae32_enabled 1
|
||||
#define dspm_mult_3x3x1_f32_ae32_enabled 1
|
||||
#define dspm_mult_3x3x3_f32_ae32_enabled 1
|
||||
#define dspm_mult_4x4x1_f32_ae32_enabled 1
|
||||
#define dspm_mult_4x4x4_f32_ae32_enabled 1
|
||||
|
||||
#endif
|
||||
|
||||
#if ((XCHAL_HAVE_LOOPS == 1) && (XCHAL_HAVE_MAC16 == 1))
|
||||
|
||||
#define dspm_mult_s16_ae32_enabled 1
|
||||
|
||||
#endif
|
||||
|
||||
#endif // _dspm_mult_platform_H_
|
||||
504
tools/sdk/esp32/include/esp-dsp/modules/matrix/include/mat.h
Normal file
504
tools/sdk/esp32/include/esp-dsp/modules/matrix/include/mat.h
Normal file
|
|
@ -0,0 +1,504 @@
|
|||
// Copyright 2018-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 _dspm_mat_h_
|
||||
#define _dspm_mat_h_
|
||||
#include <iostream>
|
||||
|
||||
/**
|
||||
* @brief DSP matrix namespace
|
||||
*
|
||||
* DSP library matrix namespace.
|
||||
*/
|
||||
namespace dspm {
|
||||
/**
|
||||
* @brief Matrix
|
||||
*
|
||||
* The Mat class provides basic matrix operations on single-precision floating point values.
|
||||
*/
|
||||
class Mat {
|
||||
public:
|
||||
/**
|
||||
* Constructor allocate internal buffer.
|
||||
* @param[in] rows: amount of matrix rows
|
||||
* @param[in] cols: amount of matrix columns
|
||||
*/
|
||||
Mat(int rows, int cols);
|
||||
/**
|
||||
* Constructor use external buffer.
|
||||
* @param[in] data: external buffer with row-major matrix data
|
||||
* @param[in] rows: amount of matrix rows
|
||||
* @param[in] cols: amount of matrix columns
|
||||
*/
|
||||
Mat(float *data, int rows, int cols);
|
||||
/**
|
||||
* Allocate matrix with undefined size.
|
||||
*/
|
||||
Mat();
|
||||
virtual ~Mat();
|
||||
/**
|
||||
* Make copy of matrix.
|
||||
* @param[in] src: source matrix
|
||||
*/
|
||||
Mat(const Mat &src);
|
||||
/**
|
||||
* Copy operator
|
||||
*
|
||||
* @param[in] src: source matrix
|
||||
*
|
||||
* @return
|
||||
* - matrix copy
|
||||
*/
|
||||
Mat &operator=(const Mat &src);
|
||||
|
||||
bool ext_buff; /*!< Flag indicates that matrix use external buffer*/
|
||||
|
||||
/**
|
||||
* Access to the matrix elements.
|
||||
* @param[in] row: row position
|
||||
* @param[in] col: column position
|
||||
*
|
||||
* @return
|
||||
* - element of matrix M[row][col]
|
||||
*/
|
||||
inline float &operator()(int row, int col)
|
||||
{
|
||||
return data[row * this->cols + col];
|
||||
}
|
||||
/**
|
||||
* Access to the matrix elements.
|
||||
* @param[in] row: row position
|
||||
* @param[in] col: column position
|
||||
*
|
||||
* @return
|
||||
* - element of matrix M[row][col]
|
||||
*/
|
||||
inline const float &operator()(int row, int col) const
|
||||
{
|
||||
return data[row * this->cols + col];
|
||||
}
|
||||
|
||||
/**
|
||||
* += operator
|
||||
* The operator use DSP optimized implementation of multiplication.
|
||||
*
|
||||
* @param[in] A: source matrix
|
||||
*
|
||||
* @return
|
||||
* - result matrix: result += A
|
||||
*/
|
||||
Mat &operator+=(const Mat &A);
|
||||
|
||||
/**
|
||||
* += operator
|
||||
* The operator use DSP optimized implementation of multiplication.
|
||||
*
|
||||
* @param[in] C: constant
|
||||
*
|
||||
* @return
|
||||
* - result matrix: result += C
|
||||
*/
|
||||
Mat &operator+=(float C);
|
||||
/**
|
||||
* -= operator
|
||||
* The operator use DSP optimized implementation of multiplication.
|
||||
*
|
||||
* @param[in] A: source matrix
|
||||
*
|
||||
* @return
|
||||
* - result matrix: result -= A
|
||||
*/
|
||||
Mat &operator-=(const Mat &A);
|
||||
|
||||
/**
|
||||
* -= operator
|
||||
* The operator use DSP optimized implementation of multiplication.
|
||||
*
|
||||
* @param[in] C: constant
|
||||
*
|
||||
* @return
|
||||
* - result matrix: result -= C
|
||||
*/
|
||||
Mat &operator-=(float C);
|
||||
|
||||
/**
|
||||
* *= operator
|
||||
* The operator use DSP optimized implementation of multiplication.
|
||||
*
|
||||
* @param[in] A: source matrix
|
||||
*
|
||||
* @return
|
||||
* - result matrix: result -= A
|
||||
*/
|
||||
Mat &operator*=(const Mat &A);
|
||||
/**
|
||||
* += with constant operator
|
||||
* The operator use DSP optimized implementation of multiplication.
|
||||
*
|
||||
* @param[in] C: constant value
|
||||
*
|
||||
* @return
|
||||
* - result matrix: result *= C
|
||||
*/
|
||||
Mat &operator*=(float C);
|
||||
/**
|
||||
* /= with constant operator
|
||||
* The operator use DSP optimized implementation of multiplication.
|
||||
*
|
||||
* @param[in] C: constant value
|
||||
*
|
||||
* @return
|
||||
* - result matrix: result /= C
|
||||
*/
|
||||
Mat &operator/=(float C);
|
||||
/**
|
||||
* /= operator
|
||||
*
|
||||
* @param[in] B: source matrix
|
||||
*
|
||||
* @return
|
||||
* - result matrix: result[i,j] = result[i,j]/B[i,j]
|
||||
*/
|
||||
Mat &operator/=(const Mat &B);
|
||||
/**
|
||||
* ^= xor with constant operator
|
||||
* The operator use DSP optimized implementation of multiplication.
|
||||
* @param[in] C: constant value
|
||||
*
|
||||
* @return
|
||||
* - result matrix: result ^= C
|
||||
*/
|
||||
Mat operator^(int C);
|
||||
|
||||
/**
|
||||
* Swap two rows between each other.
|
||||
* @param[in] row1: position of first row
|
||||
* @param[in] row2: position of second row
|
||||
*/
|
||||
void swapRows(int row1, int row2);
|
||||
/**
|
||||
* Matrix transpose.
|
||||
* Change rows and columns between each other.
|
||||
*
|
||||
* @return
|
||||
* - transposed matrix
|
||||
*/
|
||||
Mat t();
|
||||
|
||||
/**
|
||||
* Create identity matrix.
|
||||
* Create a square matrix and fill diagonal with 1.
|
||||
*
|
||||
* @param[in] size: matrix size
|
||||
*
|
||||
* @return
|
||||
* - matrix [N]x[N] with 1 in diagonal
|
||||
*/
|
||||
static Mat eye(int size);
|
||||
|
||||
/**
|
||||
* Create matrix with all elements 1.
|
||||
* Create a square matrix and fill all elements with 1.
|
||||
*
|
||||
* @param[in] size: matrix size
|
||||
*
|
||||
* @return
|
||||
* - matrix [N]x[N] with 1 in all elements
|
||||
*/
|
||||
static Mat ones(int size);
|
||||
|
||||
/**
|
||||
* Return part of matrix from defined position (startRow, startCol) as a matrix[blockRows x blockCols].
|
||||
*
|
||||
* @param[in] startRow: start row position
|
||||
* @param[in] startCol: start column position
|
||||
* @param[in] blockRows: amount of rows in result matrix
|
||||
* @param[in] blockCols: amount of columns in the result matrix
|
||||
*
|
||||
* @return
|
||||
* - matrix [blockRows]x[blockCols]
|
||||
*/
|
||||
Mat block(int startRow, int startCol, int blockRows, int blockCols);
|
||||
|
||||
/**
|
||||
* Normalizes the vector, i.e. divides it by its own norm.
|
||||
* If it's matrix, calculate matrix norm
|
||||
*
|
||||
*/
|
||||
void normalize(void);
|
||||
|
||||
/**
|
||||
* Return norm of the vector.
|
||||
* If it's matrix, calculate matrix norm
|
||||
*
|
||||
* @return
|
||||
* - matrix norm
|
||||
*/
|
||||
float norm(void);
|
||||
|
||||
/**
|
||||
* The method fill 0 to the matrix structure.
|
||||
*
|
||||
*/
|
||||
void clear(void);
|
||||
|
||||
/**
|
||||
* @brief Solve the matrix
|
||||
*
|
||||
* Solve matrix. Find roots for the matrix A*x = b
|
||||
*
|
||||
* @param[in] A: matrix [N]x[N] with input coefficients
|
||||
* @param[in] b: vector [N]x[1] with result values
|
||||
*
|
||||
* @return
|
||||
* - matrix [N]x[1] with roots
|
||||
*/
|
||||
static Mat solve(Mat A, Mat b);
|
||||
/**
|
||||
* @brief Band solve the matrix
|
||||
*
|
||||
* Solve band matrix. Find roots for the matrix A*x = b with bandwidth k.
|
||||
*
|
||||
* @param[in] A: matrix [N]x[N] with input coefficients
|
||||
* @param[in] b: vector [N]x[1] with result values
|
||||
* @param[in] k: upper bandwidth value
|
||||
*
|
||||
* @return
|
||||
* - matrix [N]x[1] with roots
|
||||
*/
|
||||
static Mat bandSolve(Mat A, Mat b, int k);
|
||||
/**
|
||||
* @brief Solve the matrix
|
||||
*
|
||||
* Different way to solve the matrix. Find roots for the matrix A*x = y
|
||||
*
|
||||
* @param[in] A: matrix [N]x[N] with input coefficients
|
||||
* @param[in] y: vector [N]x[1] with result values
|
||||
*
|
||||
* @return
|
||||
* - matrix [N]x[1] with roots
|
||||
*/
|
||||
static Mat roots(Mat A, Mat y);
|
||||
|
||||
/**
|
||||
* @brief Dotproduct of two vectors
|
||||
*
|
||||
* The method returns dotproduct of two vectors
|
||||
*
|
||||
* @param[in] A: Input vector A Nx1
|
||||
* @param[in] B: Input vector B Nx1
|
||||
*
|
||||
* @return
|
||||
* - dotproduct value
|
||||
*/
|
||||
static float dotProduct(Mat A, Mat B);
|
||||
|
||||
/**
|
||||
* @brief Augmented matrices
|
||||
*
|
||||
* Augmented matrices
|
||||
*
|
||||
* @param[in] A: Input vector A MxN
|
||||
* @param[in] B: Input vector B MxK
|
||||
*
|
||||
* @return
|
||||
* - Augmented matrix Mx(N+K)
|
||||
*/
|
||||
static Mat augment(Mat A, Mat B);
|
||||
/**
|
||||
* @brief Gaussian Elimination
|
||||
*
|
||||
* Gaussian Elimination of matrix
|
||||
*
|
||||
* @return
|
||||
* - result matrix
|
||||
*/
|
||||
Mat gaussianEliminate();
|
||||
|
||||
/**
|
||||
* Row reduction for Gaussian elimination
|
||||
*
|
||||
* @return
|
||||
* - result matrix
|
||||
*/
|
||||
Mat rowReduceFromGaussian();
|
||||
|
||||
/**
|
||||
* Find the inverse matrix
|
||||
*
|
||||
* @return
|
||||
* - inverse matrix
|
||||
*/
|
||||
Mat inverse();
|
||||
|
||||
/**
|
||||
* Find pseudo inverse matrix
|
||||
*
|
||||
* @return
|
||||
* - inverse matrix
|
||||
*/
|
||||
Mat pinv();
|
||||
|
||||
int rows; /*!< Amount of rows*/
|
||||
int cols; /*!< Amount of columns*/
|
||||
float *data; /*!< Buffer with matrix data*/
|
||||
int length; /*!< Total amount of data in data array*/
|
||||
|
||||
static float abs_tol; /*!< Max acceptable absolute tolerance*/
|
||||
private:
|
||||
Mat cofactor(int row, int col, int n);
|
||||
float det(int n);
|
||||
Mat adjoint();
|
||||
|
||||
void allocate(); // Allocate buffer
|
||||
Mat expHelper(const Mat &m, int num);
|
||||
};
|
||||
/**
|
||||
* Print matrix to the standard iostream.
|
||||
* @param[in] os: output stream
|
||||
* @param[in] m: matrix to print
|
||||
*
|
||||
* @return
|
||||
* - output stream
|
||||
*/
|
||||
std::ostream &operator<<(std::ostream &os, const Mat &m);
|
||||
/**
|
||||
* Fill the matrix from iostream.
|
||||
* @param[in] is: input stream
|
||||
* @param[in] m: matrix to fill
|
||||
*
|
||||
* @return
|
||||
* - input stream
|
||||
*/
|
||||
std::istream &operator>>(std::istream &is, Mat &m);
|
||||
|
||||
/**
|
||||
* + operator, sum of two matrices
|
||||
* The operator use DSP optimized implementation of multiplication.
|
||||
*
|
||||
* @param[in] A: Input matrix A
|
||||
* @param[in] B: Input matrix B
|
||||
*
|
||||
* @return
|
||||
* - result matrix A+B
|
||||
*/
|
||||
Mat operator+(const Mat &A, const Mat &B);
|
||||
/**
|
||||
* + operator, sum of matrix with constant
|
||||
* The operator use DSP optimized implementation of multiplication.
|
||||
*
|
||||
* @param[in] A: Input matrix A
|
||||
* @param[in] C: Input constant
|
||||
*
|
||||
* @return
|
||||
* - result matrix A+C
|
||||
*/
|
||||
Mat operator+(const Mat &A, float C);
|
||||
|
||||
/**
|
||||
* - operator, subtraction of two matrices
|
||||
* The operator use DSP optimized implementation of multiplication.
|
||||
*
|
||||
* @param[in] A: Input matrix A
|
||||
* @param[in] B: Input matrix B
|
||||
*
|
||||
* @return
|
||||
* - result matrix A-B
|
||||
*/
|
||||
Mat operator-(const Mat &A, const Mat &B);
|
||||
/**
|
||||
* - operator, sum of matrix with constant
|
||||
* The operator use DSP optimized implementation of multiplication.
|
||||
*
|
||||
* @param[in] A: Input matrix A
|
||||
* @param[in] C: Input constant
|
||||
*
|
||||
* @return
|
||||
* - result matrix A+C
|
||||
*/
|
||||
Mat operator-(const Mat &A, float C);
|
||||
|
||||
/**
|
||||
* * operator, multiplication of two matrices.
|
||||
* The operator use DSP optimized implementation of multiplication.
|
||||
*
|
||||
* @param[in] A: Input matrix A
|
||||
* @param[in] B: Input matrix B
|
||||
*
|
||||
* @return
|
||||
* - result matrix A*B
|
||||
*/
|
||||
Mat operator*(const Mat &A, const Mat &B);
|
||||
|
||||
/**
|
||||
* * operator, multiplication of matrix with constant
|
||||
* The operator use DSP optimized implementation of multiplication.
|
||||
*
|
||||
* @param[in] A: Input matrix A
|
||||
* @param[in] C: floating point value
|
||||
*
|
||||
* @return
|
||||
* - result matrix A*B
|
||||
*/
|
||||
Mat operator*(const Mat &A, float C);
|
||||
|
||||
/**
|
||||
* * operator, multiplication of matrix with constant
|
||||
* The operator use DSP optimized implementation of multiplication.
|
||||
*
|
||||
* @param[in] C: floating point value
|
||||
* @param[in] A: Input matrix A
|
||||
*
|
||||
* @return
|
||||
* - result matrix A*B
|
||||
*/
|
||||
Mat operator*(float C, const Mat &A);
|
||||
|
||||
/**
|
||||
* / operator, divide of matrix by constant
|
||||
* The operator use DSP optimized implementation of multiplication.
|
||||
*
|
||||
* @param[in] A: Input matrix A
|
||||
* @param[in] C: floating point value
|
||||
*
|
||||
* @return
|
||||
* - result matrix A*B
|
||||
*/
|
||||
Mat operator/(const Mat &A, float C);
|
||||
|
||||
/**
|
||||
* / operator, divide matrix A by matrix B
|
||||
*
|
||||
* @param[in] A: Input matrix A
|
||||
* @param[in] B: Input matrix B
|
||||
*
|
||||
* @return
|
||||
* - result matrix C, where C[i,j] = A[i,j]/B[i,j]
|
||||
*/
|
||||
Mat operator/(const Mat &A, const Mat &B);
|
||||
|
||||
/**
|
||||
* == operator, compare two matrices
|
||||
*
|
||||
* @param[in] A: Input matrix A
|
||||
* @param[in] B: Input matrix B
|
||||
*
|
||||
* @return
|
||||
* - true if matrices are the same
|
||||
* - false if matrices are different
|
||||
*/
|
||||
bool operator==(const Mat &A, const Mat &B);
|
||||
|
||||
}
|
||||
#endif //_dspm_mat_h_
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
// Copyright 2018-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 _dsps_d_gen_H_
|
||||
#define _dsps_d_gen_H_
|
||||
#include "dsp_err.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief delta function
|
||||
*
|
||||
* The function generate delta function.
|
||||
* output[i]=0, if i=[0..N)
|
||||
* output[i]=1, if i=pos, pos: [0..N-1)
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param output: output array.
|
||||
* @param len: length of the input signal
|
||||
* @param pos: delta function position
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_d_gen_f32(float *output, int len, int pos);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _dsps_d_gen_H_
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
// Copyright 2018-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 _dsps_h_gen_H_
|
||||
#define _dsps_h_gen_H_
|
||||
#include "dsp_err.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Heviside function
|
||||
*
|
||||
* The Heviside function.
|
||||
* output[i]=0, if i=[0..pos)
|
||||
* output[i]=1, if i=[pos..N)
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param output: output array.
|
||||
* @param len: length of the input signal
|
||||
* @param pos: heviside function position
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
|
||||
esp_err_t dsps_h_gen_f32(float *output, int len, int pos);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _dsps_h_gen_H_
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
// Copyright 2018-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 _dsps_sfdr_H_
|
||||
#define _dsps_sfdr_H_
|
||||
|
||||
|
||||
#include "dsp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief SFDR
|
||||
*
|
||||
* The function calculates Spurious-Free Dynamic Range.
|
||||
* The function makes FFT of the input, then search a spectrum maximum, and then compare
|
||||
* maximum value with all others. Result calculated as minimum value.
|
||||
* This function have to be used for debug and unit tests only. It's not optimized for real-time processing.
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param[in] input: input array.
|
||||
* @param len: length of the input signal
|
||||
* @param use_dc: this parameter define will be DC value used for calculation or not.
|
||||
* 0 - SNR will not include DC power
|
||||
* 1 - SNR will include DC power
|
||||
*
|
||||
* @return
|
||||
* - SFDR in DB
|
||||
*/
|
||||
float dsps_sfdr_f32(const float *input, int32_t len, int8_t use_dc);
|
||||
float dsps_sfdr_fc32(const float *input, int32_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _dsps_sfdr_H_
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
// Copyright 2018-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 _DSP_SNR_H_
|
||||
#define _DSP_SNR_H_
|
||||
|
||||
#include "dsp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief SNR
|
||||
*
|
||||
* The function calculates signal to noise ration in case if signal is sine tone.
|
||||
* The function makes FFT of the input, then search a spectrum maximum, and then calculated
|
||||
* SNR as sum of all harmonics to the maximum value.
|
||||
* This function have to be used for debug and unit tests only. It's not optimized for real-time processing.
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param input: input array.
|
||||
* @param len: length of the input signal
|
||||
* @param use_dc: this parameter define will be DC value used for calculation or not.
|
||||
* 0 - SNR will not include DC power
|
||||
* 1 - SNR will include DC power
|
||||
*
|
||||
* @return
|
||||
* - SNR in dB
|
||||
*/
|
||||
float dsps_snr_f32(const float *input, int32_t len, uint8_t use_dc);
|
||||
float dsps_snr_fc32(const float *input, int32_t len);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _DSP_SNR_H_
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
// Copyright 2018-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 _dsps_tone_gen_H_
|
||||
#define _dsps_tone_gen_H_
|
||||
#include "dsp_err.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief tone
|
||||
*
|
||||
* The function generate a tone signal.
|
||||
* x[i]=A*sin(2*PI*i + ph/180*PI)
|
||||
* The implementation use ANSI C and could be compiled and run on any platform
|
||||
*
|
||||
* @param output: output array.
|
||||
* @param len: length of the input signal
|
||||
* @param Ampl: amplitude
|
||||
* @param freq: Naiquist frequency -1..1
|
||||
* @param phase: phase in degree
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - One of the error codes from DSP library
|
||||
*/
|
||||
esp_err_t dsps_tone_gen_f32(float *output, int len, float Ampl, float freq, float phase);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _dsps_tone_gen_H_
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
// Copyright 2018-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 _dsps_view_H_
|
||||
#define _dsps_view_H_
|
||||
|
||||
#include "dsp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**@{*/
|
||||
/**
|
||||
* @brief plot view
|
||||
*
|
||||
* Generic view function.
|
||||
* This function takes input samples and show then in console view as a plot.
|
||||
* The main purpose to give and draft debug information to the DSP developer.
|
||||
*
|
||||
* @param[in] data: array with input samples.
|
||||
* @param len: length of the input array
|
||||
* @param width: plot width in symbols
|
||||
* @param height: plot height in lines
|
||||
* @param min: minimum value that will be limited by Axis Y.
|
||||
* @param max: maximum value that will be limited by Axis Y.
|
||||
* @param view_char: character to draw the plot calues ('.' or '|' etc)
|
||||
*
|
||||
*/
|
||||
void dsps_view(const float *data, int32_t len, int width, int height, float min, float max, char view_char);
|
||||
void dsps_view_s16(const int16_t *data, int32_t len, int width, int height, float min, float max, char view_char);
|
||||
/**@}*/
|
||||
|
||||
/**
|
||||
* @brief spectrum view
|
||||
*
|
||||
* The view function to show spectrum values in 64x10 screen.
|
||||
* The function based on dsps_view.
|
||||
*
|
||||
* @param[in] data: array with input samples.
|
||||
* @param len: length of the input array
|
||||
* @param min: minimum value that will be limited by Axis Y.
|
||||
* @param max: maximum value that will be limited by Axis Y.
|
||||
*
|
||||
*/
|
||||
void dsps_view_spectrum(const float *data, int32_t len, float min, float max);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _dsps_view_H_
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
// Copyright 2018-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 _dsps_wind_blackman_H_
|
||||
#define _dsps_wind_blackman_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Blackman window
|
||||
*
|
||||
* The function generates Blackman window for plpha = 0.16.
|
||||
*
|
||||
* @param window: buffer to store window array.
|
||||
* @param len: length of the window array
|
||||
*
|
||||
*/
|
||||
void dsps_wind_blackman_f32(float *window, int len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // _dsps_wind_blackman_H_
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
// Copyright 2018-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 _dsps_wind_blackman_harris_H_
|
||||
#define _dsps_wind_blackman_harris_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Blackman-Harris window
|
||||
*
|
||||
* The function generates Blackman-Harris window.
|
||||
*
|
||||
* @param window: buffer to store window array.
|
||||
* @param len: length of the window array
|
||||
*
|
||||
*/
|
||||
void dsps_wind_blackman_harris_f32(float *window, int len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // _dsps_wind_blackman_harris_H_
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
// Copyright 2018-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 _dsps_wind_blackman_nuttall_H_
|
||||
#define _dsps_wind_blackman_nuttall_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Blackman-Nuttall window
|
||||
*
|
||||
* The function generates Blackman-Nuttall window.
|
||||
*
|
||||
* @param window: buffer to store window array.
|
||||
* @param len: length of the window array
|
||||
*
|
||||
*/
|
||||
void dsps_wind_blackman_nuttall_f32(float *window, int len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // _dsps_wind_blackman_nuttall_H_
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue