Update IDF libs and mbedtls options

This commit is contained in:
me-no-dev 2022-03-18 13:32:41 +02:00
parent 2e90c25f7d
commit b3485111ba
209 changed files with 1154 additions and 706 deletions

File diff suppressed because one or more lines are too long

View file

@ -374,6 +374,10 @@ class ESPLoader(object):
if chip_id == cls.IMAGE_CHIP_ID: if chip_id == cls.IMAGE_CHIP_ID:
inst = cls(detect_port._port, baud, trace_enabled=trace_enabled) inst = cls(detect_port._port, baud, trace_enabled=trace_enabled)
inst._post_connect() inst._post_connect()
try:
inst.read_reg(ESPLoader.CHIP_DETECT_MAGIC_REG_ADDR) # Dummy read to check Secure Download mode
except UnsupportedCommandError:
inst.secure_download_mode = True
except (UnsupportedCommandError, struct.error, FatalError) as e: except (UnsupportedCommandError, struct.error, FatalError) as e:
# UnsupportedCmdErr: ESP8266/ESP32 ROM | struct.err: ESP32-S2 | FatalErr: ESP8266/ESP32 STUB # UnsupportedCmdErr: ESP8266/ESP32 ROM | struct.err: ESP32-S2 | FatalErr: ESP8266/ESP32 STUB
print(" Unsupported detection protocol, switching and trying again...") print(" Unsupported detection protocol, switching and trying again...")
@ -2376,6 +2380,11 @@ class ESP32C2ROM(ESP32C3ROM):
CHIP_NAME = "ESP32-C2" CHIP_NAME = "ESP32-C2"
IMAGE_CHIP_ID = 12 IMAGE_CHIP_ID = 12
IROM_MAP_START = 0x42000000
IROM_MAP_END = 0x42400000
DROM_MAP_START = 0x3c000000
DROM_MAP_END = 0x3c400000
CHIP_DETECT_MAGIC_VALUE = [0x6f51306f] CHIP_DETECT_MAGIC_VALUE = [0x6f51306f]
EFUSE_BASE = 0x60008800 EFUSE_BASE = 0x60008800
@ -4730,16 +4739,21 @@ def main(argv=None, esp=None):
print("XMC flash chip boot-up fix successful!") print("XMC flash chip boot-up fix successful!")
# Check flash chip connection # Check flash chip connection
try: if not esp.secure_download_mode:
flash_id = esp.flash_id() try:
if flash_id in (0xffffff, 0x000000): flash_id = esp.flash_id()
print('WARNING: Failed to communicate with the flash chip, read/write operations will fail. ' if flash_id in (0xffffff, 0x000000):
'Try checking the chip connections or removing any other hardware connected to IOs.') print('WARNING: Failed to communicate with the flash chip, read/write operations will fail. '
except Exception as e: 'Try checking the chip connections or removing any other hardware connected to IOs.')
esp.trace('Unable to verify flash chip connection ({}).'.format(e)) except Exception as e:
esp.trace('Unable to verify flash chip connection ({}).'.format(e))
# Check if XMC SPI flash chip booted-up successfully, fix if not # Check if XMC SPI flash chip booted-up successfully, fix if not
flash_xmc_startup() if not esp.secure_download_mode:
try:
flash_xmc_startup()
except Exception as e:
esp.trace('Unable to perform XMC flash chip startup sequence ({}).'.format(e))
if hasattr(args, "flash_size"): if hasattr(args, "flash_size"):
print("Configuring flash size...") print("Configuring flash size...")

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -60,6 +60,9 @@ typedef enum {
#define ESP_HF_CLIENT_PEER_FEAT_ECC 0x80 /* Enhanced Call Control */ #define ESP_HF_CLIENT_PEER_FEAT_ECC 0x80 /* Enhanced Call Control */
#define ESP_HF_CLIENT_PEER_FEAT_EXTERR 0x100 /* Extended error codes */ #define ESP_HF_CLIENT_PEER_FEAT_EXTERR 0x100 /* Extended error codes */
#define ESP_HF_CLIENT_PEER_FEAT_CODEC 0x200 /* Codec Negotiation */ #define ESP_HF_CLIENT_PEER_FEAT_CODEC 0x200 /* Codec Negotiation */
/* HFP 1.7+ */
#define ESP_HF_CLIENT_PEER_FEAT_HF_IND 0x400 /* HF Indicators */
#define ESP_HF_CLIENT_PEER_FEAT_ESCO_S4 0x800 /* eSCO S4 Setting Supported */
/* CHLD feature masks of AG */ /* CHLD feature masks of AG */
#define ESP_HF_CLIENT_CHLD_FEAT_REL 0x01 /* 0 Release waiting call or held calls */ #define ESP_HF_CLIENT_CHLD_FEAT_REL 0x01 /* 0 Release waiting call or held calls */

View file

@ -49,6 +49,8 @@ typedef enum {
RMAKER_EVENT_USER_NODE_MAPPING_DONE, RMAKER_EVENT_USER_NODE_MAPPING_DONE,
/** Local control started. Associated data is the NULL terminated Service Name */ /** Local control started. Associated data is the NULL terminated Service Name */
RMAKER_EVENT_LOCAL_CTRL_STARTED, RMAKER_EVENT_LOCAL_CTRL_STARTED,
/* User reset request successfully sent to ESP RainMaker Cloud */
RMAKER_EVENT_USER_NODE_MAPPING_RESET,
} esp_rmaker_event_t; } esp_rmaker_event_t;
/** ESP RainMaker Node information */ /** ESP RainMaker Node information */

View file

@ -19,6 +19,25 @@ extern "C"
{ {
#endif #endif
/** User-Node Mapping states */
typedef enum {
/** Mapping does not exist or is not initialized */
ESP_RMAKER_USER_MAPPING_RESET = 0,
/** Mapping has started */
ESP_RMAKER_USER_MAPPING_STARTED,
/** Mapping is done */
ESP_RMAKER_USER_MAPPING_DONE,
} esp_rmaker_user_mapping_state_t;
/**
* Get User-Node mapping state
*
* This returns the current user-node mapping state.
*
* @return user mapping state
*/
esp_rmaker_user_mapping_state_t esp_rmaker_user_node_mapping_get_state(void);
/** /**
* Create User Mapping Endpoint * Create User Mapping Endpoint
* *

View file

@ -558,14 +558,14 @@ static inline void __attribute__((always_inline)) uxPortCompareSetExtram(volatil
// --------------------- Interrupts ------------------------ // --------------------- Interrupts ------------------------
static inline UBaseType_t xPortSetInterruptMaskFromISR(void) static inline UBaseType_t __attribute__((always_inline)) xPortSetInterruptMaskFromISR(void)
{ {
UBaseType_t prev_int_level = XTOS_SET_INTLEVEL(XCHAL_EXCM_LEVEL); UBaseType_t prev_int_level = XTOS_SET_INTLEVEL(XCHAL_EXCM_LEVEL);
portbenchmarkINTERRUPT_DISABLE(); portbenchmarkINTERRUPT_DISABLE();
return prev_int_level; return prev_int_level;
} }
static inline void vPortClearInterruptMaskFromISR(UBaseType_t prev_level) static inline void __attribute__((always_inline)) vPortClearInterruptMaskFromISR(UBaseType_t prev_level)
{ {
portbenchmarkINTERRUPT_RESTORE(prev_level); portbenchmarkINTERRUPT_RESTORE(prev_level);
XTOS_RESTORE_JUST_INTLEVEL(prev_level); XTOS_RESTORE_JUST_INTLEVEL(prev_level);

View file

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -342,6 +342,11 @@ static inline uint32_t emac_ll_transmit_frame_ctrl_status(emac_mac_dev_t *mac_re
return mac_regs->emacdebug.mactfcs; return mac_regs->emacdebug.mactfcs;
} }
static inline uint32_t emac_ll_receive_read_ctrl_state(emac_mac_dev_t *mac_regs)
{
return mac_regs->emacdebug.mtlrfrcs;
}
/* emacmiidata */ /* emacmiidata */
static inline void emac_ll_set_phy_data(emac_mac_dev_t *mac_regs, uint32_t data) static inline void emac_ll_set_phy_data(emac_mac_dev_t *mac_regs, uint32_t data)
{ {

View file

@ -567,7 +567,7 @@ static inline void gpio_ll_iomux_in(gpio_dev_t *hw, uint32_t gpio, uint32_t sign
* @param pin_name Pin name to configure * @param pin_name Pin name to configure
* @param func Function to assign to the pin * @param func Function to assign to the pin
*/ */
static inline void gpio_ll_iomux_func_sel(uint32_t pin_name, uint32_t func) static inline __attribute__((always_inline)) void gpio_ll_iomux_func_sel(uint32_t pin_name, uint32_t func)
{ {
PIN_FUNC_SELECT(pin_name, func); PIN_FUNC_SELECT(pin_name, func);
} }

View file

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -225,7 +225,7 @@ void emac_hal_start(emac_hal_context_t *hal);
* @param hal EMAC HAL context infostructure * @param hal EMAC HAL context infostructure
* @return * @return
* - ESP_OK: succeed * - ESP_OK: succeed
* - ESP_ERR_INVALID_STATE: previous frame transmission is not completed. When this error occurs, * - ESP_ERR_INVALID_STATE: previous frame transmission/reception is not completed. When this error occurs,
* wait and reapeat the EMAC stop again. * wait and reapeat the EMAC stop again.
*/ */
esp_err_t emac_hal_stop(emac_hal_context_t *hal); esp_err_t emac_hal_stop(emac_hal_context_t *hal);

View file

@ -35,9 +35,26 @@ typedef enum {
RMAKER_MQTT_EVENT_CONNECTED, RMAKER_MQTT_EVENT_CONNECTED,
/** Disconnected from MQTT Broker */ /** Disconnected from MQTT Broker */
RMAKER_MQTT_EVENT_DISCONNECTED, RMAKER_MQTT_EVENT_DISCONNECTED,
/** MQTT message published successfully */ /** MQTT message published successfully.
* Event data will contain the message ID (integer) of published message.
*/
RMAKER_MQTT_EVENT_PUBLISHED, RMAKER_MQTT_EVENT_PUBLISHED,
} esp_rmaker_mqtt_event_t; /** POSIX Timezone Changed. Associated data would be NULL terminated POSIX Timezone
* Eg. "PST8PDT,M3.2.0,M11.1.0" */
RMAKER_EVENT_TZ_POSIX_CHANGED,
/** Timezone Changed. Associated data would be NULL terminated Timezone.
* Eg. "America/Los_Angeles"
* Note that whenever this event is received, the RMAKER_EVENT_TZ_POSIX_CHANGED event
* will also be received, but not necessarily vice versa.
*/
RMAKER_EVENT_TZ_CHANGED,
/**
* MQTT message deleted from the outbox if the message couldn't have been sent and acknowledged.
* Event data will contain the message ID (integer) of deleted message.
* Valid only if CONFIG_MQTT_REPORT_DELETED_MESSAGES is enabled.
*/
RMAKER_MQTT_EVENT_MSG_DELETED,
} esp_rmaker_common_event_t;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -63,6 +63,12 @@ typedef void (*esp_rmaker_mqtt_subscribe_cb_t)(const char *topic, void *payload,
*/ */
typedef esp_err_t (*esp_rmaker_mqtt_init_t)(esp_rmaker_mqtt_conn_params_t *conn_params); typedef esp_err_t (*esp_rmaker_mqtt_init_t)(esp_rmaker_mqtt_conn_params_t *conn_params);
/** MQTT Deinit function prototype
*
* Call this function after MQTT has disconnected.
*/
typedef void (*esp_rmaker_mqtt_deinit_t)(void);
/** MQTT Connect function prototype /** MQTT Connect function prototype
* *
* Starts the connection attempts to the MQTT broker. * Starts the connection attempts to the MQTT broker.
@ -124,6 +130,8 @@ typedef struct {
esp_rmaker_mqtt_get_conn_params_t get_conn_params; esp_rmaker_mqtt_get_conn_params_t get_conn_params;
/** Pointer to MQTT Init function. */ /** Pointer to MQTT Init function. */
esp_rmaker_mqtt_init_t init; esp_rmaker_mqtt_init_t init;
/** Pointer to MQTT Deinit function. */
esp_rmaker_mqtt_deinit_t deinit;
/** Pointer to MQTT Connect function. */ /** Pointer to MQTT Connect function. */
esp_rmaker_mqtt_connect_t connect; esp_rmaker_mqtt_connect_t connect;
/** Pointer to MQTQ Disconnect function */ /** Pointer to MQTQ Disconnect function */

View file

@ -15,12 +15,24 @@
#include <stdint.h> #include <stdint.h>
#include <sntp.h> #include <sntp.h>
#include <esp_err.h> #include <esp_err.h>
#include <esp_heap_caps.h>
#include <sdkconfig.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#endif #endif
#ifdef CONFIG_SPIRAM
#define MEM_ALLOC_EXTRAM(size) heap_caps_malloc(size, MALLOC_CAP_SPIRAM)
#define MEM_CALLOC_EXTRAM(num, size) heap_caps_calloc(num, size, MALLOC_CAP_SPIRAM)
#define MEM_REALLOC_EXTRAM(ptr, size) heap_caps_realloc(ptr, size, MALLOC_CAP_SPIRAM)
#else
#define MEM_ALLOC_EXTRAM(size) malloc(size)
#define MEM_CALLOC_EXTRAM(num, size) calloc(num, size)
#define MEM_REALLOC_EXTRAM(ptr, size) realloc(ptr, size)
#endif
typedef struct esp_rmaker_time_config { typedef struct esp_rmaker_time_config {
/** If not specified, then 'CONFIG_ESP_RMAKER_SNTP_SERVER_NAME' is used as the SNTP server. */ /** If not specified, then 'CONFIG_ESP_RMAKER_SNTP_SERVER_NAME' is used as the SNTP server. */
char *sntp_server_name; char *sntp_server_name;

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.

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.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -48,6 +48,7 @@
#define CONFIG_LIB_BUILDER_FLASHMODE "dio" #define CONFIG_LIB_BUILDER_FLASHMODE "dio"
#define CONFIG_LIB_BUILDER_FLASHFREQ "40m" #define CONFIG_LIB_BUILDER_FLASHFREQ "40m"
#define CONFIG_ESP_RMAKER_ASSISTED_CLAIM 1 #define CONFIG_ESP_RMAKER_ASSISTED_CLAIM 1
#define CONFIG_ESP_RMAKER_CLAIM_TYPE 2
#define CONFIG_ESP_RMAKER_MQTT_HOST "a1p72mufdu6064-ats.iot.us-east-1.amazonaws.com" #define CONFIG_ESP_RMAKER_MQTT_HOST "a1p72mufdu6064-ats.iot.us-east-1.amazonaws.com"
#define CONFIG_ESP_RMAKER_MAX_PARAM_DATA_SIZE 1024 #define CONFIG_ESP_RMAKER_MAX_PARAM_DATA_SIZE 1024
#define CONFIG_ESP_RMAKER_CONSOLE_UART_NUM_0 1 #define CONFIG_ESP_RMAKER_CONSOLE_UART_NUM_0 1
@ -348,7 +349,6 @@
#define CONFIG_HAL_DEFAULT_ASSERTION_LEVEL 2 #define CONFIG_HAL_DEFAULT_ASSERTION_LEVEL 2
#define CONFIG_HEAP_POISONING_LIGHT 1 #define CONFIG_HEAP_POISONING_LIGHT 1
#define CONFIG_HEAP_TRACING_OFF 1 #define CONFIG_HEAP_TRACING_OFF 1
#define CONFIG_LIBSODIUM_USE_MBEDTLS_SHA 1
#define CONFIG_LOG_DEFAULT_LEVEL_ERROR 1 #define CONFIG_LOG_DEFAULT_LEVEL_ERROR 1
#define CONFIG_LOG_DEFAULT_LEVEL 1 #define CONFIG_LOG_DEFAULT_LEVEL 1
#define CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT 1 #define CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT 1
@ -417,6 +417,7 @@
#define CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL 1 #define CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL 1
#define CONFIG_MBEDTLS_HARDWARE_AES 1 #define CONFIG_MBEDTLS_HARDWARE_AES 1
#define CONFIG_MBEDTLS_HARDWARE_MPI 1 #define CONFIG_MBEDTLS_HARDWARE_MPI 1
#define CONFIG_MBEDTLS_HARDWARE_SHA 1
#define CONFIG_MBEDTLS_ROM_MD5 1 #define CONFIG_MBEDTLS_ROM_MD5 1
#define CONFIG_MBEDTLS_HAVE_TIME 1 #define CONFIG_MBEDTLS_HAVE_TIME 1
#define CONFIG_MBEDTLS_ECDSA_DETERMINISTIC 1 #define CONFIG_MBEDTLS_ECDSA_DETERMINISTIC 1

View file

@ -605,8 +605,8 @@ SECTIONS
_bss_start = ABSOLUTE(.); _bss_start = ABSOLUTE(.);
*(.bss .bss.*) *(.bss .bss.*)
*(.ext_ram.bss .ext_ram.bss.*)
*(.dynbss .dynsbss .gnu.linkonce.b .gnu.linkonce.b.* .gnu.linkonce.sb .gnu.linkonce.sb.* .gnu.linkonce.sb2 .gnu.linkonce.sb2.* .sbss .sbss.* .sbss2 .sbss2.* .scommon .share.mem) *(.dynbss .dynsbss .gnu.linkonce.b .gnu.linkonce.b.* .gnu.linkonce.sb .gnu.linkonce.sb.* .gnu.linkonce.sb2 .gnu.linkonce.sb2.* .sbss .sbss.* .sbss2 .sbss2.* .scommon .share.mem)
*(.ext_ram.bss .ext_ram.bss.*)
*(COMMON) *(COMMON)
_bt_bss_start = ABSOLUTE(.); _bt_bss_start = ABSOLUTE(.);
*libbt.a:(.bss .bss.* COMMON) *libbt.a:(.bss .bss.* COMMON)

View file

@ -134,7 +134,9 @@ CONFIG_LIB_BUILDER_FLASHFREQ="40m"
# #
# ESP RainMaker Config # ESP RainMaker Config
# #
# CONFIG_ESP_RMAKER_NO_CLAIM is not set
CONFIG_ESP_RMAKER_ASSISTED_CLAIM=y CONFIG_ESP_RMAKER_ASSISTED_CLAIM=y
CONFIG_ESP_RMAKER_CLAIM_TYPE=2
CONFIG_ESP_RMAKER_MQTT_HOST="a1p72mufdu6064-ats.iot.us-east-1.amazonaws.com" CONFIG_ESP_RMAKER_MQTT_HOST="a1p72mufdu6064-ats.iot.us-east-1.amazonaws.com"
CONFIG_ESP_RMAKER_MAX_PARAM_DATA_SIZE=1024 CONFIG_ESP_RMAKER_MAX_PARAM_DATA_SIZE=1024
# CONFIG_ESP_RMAKER_DISABLE_USER_MAPPING_PROV is not set # CONFIG_ESP_RMAKER_DISABLE_USER_MAPPING_PROV is not set
@ -996,7 +998,6 @@ CONFIG_HEAP_TRACING_OFF=y
# #
# libsodium # libsodium
# #
CONFIG_LIBSODIUM_USE_MBEDTLS_SHA=y
# end of libsodium # end of libsodium
# #
@ -1205,7 +1206,7 @@ CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y
# CONFIG_MBEDTLS_CMAC_C is not set # CONFIG_MBEDTLS_CMAC_C is not set
CONFIG_MBEDTLS_HARDWARE_AES=y CONFIG_MBEDTLS_HARDWARE_AES=y
CONFIG_MBEDTLS_HARDWARE_MPI=y CONFIG_MBEDTLS_HARDWARE_MPI=y
# CONFIG_MBEDTLS_HARDWARE_SHA is not set CONFIG_MBEDTLS_HARDWARE_SHA=y
CONFIG_MBEDTLS_ROM_MD5=y CONFIG_MBEDTLS_ROM_MD5=y
# CONFIG_MBEDTLS_ATCA_HW_ECDSA_SIGN is not set # CONFIG_MBEDTLS_ATCA_HW_ECDSA_SIGN is not set
# CONFIG_MBEDTLS_ATCA_HW_ECDSA_VERIFY is not set # CONFIG_MBEDTLS_ATCA_HW_ECDSA_VERIFY is not set

View file

@ -60,6 +60,9 @@ typedef enum {
#define ESP_HF_CLIENT_PEER_FEAT_ECC 0x80 /* Enhanced Call Control */ #define ESP_HF_CLIENT_PEER_FEAT_ECC 0x80 /* Enhanced Call Control */
#define ESP_HF_CLIENT_PEER_FEAT_EXTERR 0x100 /* Extended error codes */ #define ESP_HF_CLIENT_PEER_FEAT_EXTERR 0x100 /* Extended error codes */
#define ESP_HF_CLIENT_PEER_FEAT_CODEC 0x200 /* Codec Negotiation */ #define ESP_HF_CLIENT_PEER_FEAT_CODEC 0x200 /* Codec Negotiation */
/* HFP 1.7+ */
#define ESP_HF_CLIENT_PEER_FEAT_HF_IND 0x400 /* HF Indicators */
#define ESP_HF_CLIENT_PEER_FEAT_ESCO_S4 0x800 /* eSCO S4 Setting Supported */
/* CHLD feature masks of AG */ /* CHLD feature masks of AG */
#define ESP_HF_CLIENT_CHLD_FEAT_REL 0x01 /* 0 Release waiting call or held calls */ #define ESP_HF_CLIENT_CHLD_FEAT_REL 0x01 /* 0 Release waiting call or held calls */

View file

@ -49,6 +49,8 @@ typedef enum {
RMAKER_EVENT_USER_NODE_MAPPING_DONE, RMAKER_EVENT_USER_NODE_MAPPING_DONE,
/** Local control started. Associated data is the NULL terminated Service Name */ /** Local control started. Associated data is the NULL terminated Service Name */
RMAKER_EVENT_LOCAL_CTRL_STARTED, RMAKER_EVENT_LOCAL_CTRL_STARTED,
/* User reset request successfully sent to ESP RainMaker Cloud */
RMAKER_EVENT_USER_NODE_MAPPING_RESET,
} esp_rmaker_event_t; } esp_rmaker_event_t;
/** ESP RainMaker Node information */ /** ESP RainMaker Node information */

View file

@ -19,6 +19,25 @@ extern "C"
{ {
#endif #endif
/** User-Node Mapping states */
typedef enum {
/** Mapping does not exist or is not initialized */
ESP_RMAKER_USER_MAPPING_RESET = 0,
/** Mapping has started */
ESP_RMAKER_USER_MAPPING_STARTED,
/** Mapping is done */
ESP_RMAKER_USER_MAPPING_DONE,
} esp_rmaker_user_mapping_state_t;
/**
* Get User-Node mapping state
*
* This returns the current user-node mapping state.
*
* @return user mapping state
*/
esp_rmaker_user_mapping_state_t esp_rmaker_user_node_mapping_get_state(void);
/** /**
* Create User Mapping Endpoint * Create User Mapping Endpoint
* *

View file

@ -380,7 +380,7 @@ static inline void gpio_ll_iomux_in(gpio_dev_t *hw, uint32_t gpio, uint32_t sign
* @param pin_name Pin name to configure * @param pin_name Pin name to configure
* @param func Function to assign to the pin * @param func Function to assign to the pin
*/ */
static inline void gpio_ll_iomux_func_sel(uint32_t pin_name, uint32_t func) static inline __attribute__((always_inline)) void gpio_ll_iomux_func_sel(uint32_t pin_name, uint32_t func)
{ {
// Disable USB Serial JTAG if pins 18 or pins 19 needs to select an IOMUX function // Disable USB Serial JTAG if pins 18 or pins 19 needs to select an IOMUX function
if (pin_name == IO_MUX_GPIO18_REG || pin_name == IO_MUX_GPIO19_REG) { if (pin_name == IO_MUX_GPIO18_REG || pin_name == IO_MUX_GPIO19_REG) {

View file

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -225,7 +225,7 @@ void emac_hal_start(emac_hal_context_t *hal);
* @param hal EMAC HAL context infostructure * @param hal EMAC HAL context infostructure
* @return * @return
* - ESP_OK: succeed * - ESP_OK: succeed
* - ESP_ERR_INVALID_STATE: previous frame transmission is not completed. When this error occurs, * - ESP_ERR_INVALID_STATE: previous frame transmission/reception is not completed. When this error occurs,
* wait and reapeat the EMAC stop again. * wait and reapeat the EMAC stop again.
*/ */
esp_err_t emac_hal_stop(emac_hal_context_t *hal); esp_err_t emac_hal_stop(emac_hal_context_t *hal);

View file

@ -35,9 +35,26 @@ typedef enum {
RMAKER_MQTT_EVENT_CONNECTED, RMAKER_MQTT_EVENT_CONNECTED,
/** Disconnected from MQTT Broker */ /** Disconnected from MQTT Broker */
RMAKER_MQTT_EVENT_DISCONNECTED, RMAKER_MQTT_EVENT_DISCONNECTED,
/** MQTT message published successfully */ /** MQTT message published successfully.
* Event data will contain the message ID (integer) of published message.
*/
RMAKER_MQTT_EVENT_PUBLISHED, RMAKER_MQTT_EVENT_PUBLISHED,
} esp_rmaker_mqtt_event_t; /** POSIX Timezone Changed. Associated data would be NULL terminated POSIX Timezone
* Eg. "PST8PDT,M3.2.0,M11.1.0" */
RMAKER_EVENT_TZ_POSIX_CHANGED,
/** Timezone Changed. Associated data would be NULL terminated Timezone.
* Eg. "America/Los_Angeles"
* Note that whenever this event is received, the RMAKER_EVENT_TZ_POSIX_CHANGED event
* will also be received, but not necessarily vice versa.
*/
RMAKER_EVENT_TZ_CHANGED,
/**
* MQTT message deleted from the outbox if the message couldn't have been sent and acknowledged.
* Event data will contain the message ID (integer) of deleted message.
* Valid only if CONFIG_MQTT_REPORT_DELETED_MESSAGES is enabled.
*/
RMAKER_MQTT_EVENT_MSG_DELETED,
} esp_rmaker_common_event_t;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -63,6 +63,12 @@ typedef void (*esp_rmaker_mqtt_subscribe_cb_t)(const char *topic, void *payload,
*/ */
typedef esp_err_t (*esp_rmaker_mqtt_init_t)(esp_rmaker_mqtt_conn_params_t *conn_params); typedef esp_err_t (*esp_rmaker_mqtt_init_t)(esp_rmaker_mqtt_conn_params_t *conn_params);
/** MQTT Deinit function prototype
*
* Call this function after MQTT has disconnected.
*/
typedef void (*esp_rmaker_mqtt_deinit_t)(void);
/** MQTT Connect function prototype /** MQTT Connect function prototype
* *
* Starts the connection attempts to the MQTT broker. * Starts the connection attempts to the MQTT broker.
@ -124,6 +130,8 @@ typedef struct {
esp_rmaker_mqtt_get_conn_params_t get_conn_params; esp_rmaker_mqtt_get_conn_params_t get_conn_params;
/** Pointer to MQTT Init function. */ /** Pointer to MQTT Init function. */
esp_rmaker_mqtt_init_t init; esp_rmaker_mqtt_init_t init;
/** Pointer to MQTT Deinit function. */
esp_rmaker_mqtt_deinit_t deinit;
/** Pointer to MQTT Connect function. */ /** Pointer to MQTT Connect function. */
esp_rmaker_mqtt_connect_t connect; esp_rmaker_mqtt_connect_t connect;
/** Pointer to MQTQ Disconnect function */ /** Pointer to MQTQ Disconnect function */

View file

@ -15,12 +15,24 @@
#include <stdint.h> #include <stdint.h>
#include <sntp.h> #include <sntp.h>
#include <esp_err.h> #include <esp_err.h>
#include <esp_heap_caps.h>
#include <sdkconfig.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#endif #endif
#ifdef CONFIG_SPIRAM
#define MEM_ALLOC_EXTRAM(size) heap_caps_malloc(size, MALLOC_CAP_SPIRAM)
#define MEM_CALLOC_EXTRAM(num, size) heap_caps_calloc(num, size, MALLOC_CAP_SPIRAM)
#define MEM_REALLOC_EXTRAM(ptr, size) heap_caps_realloc(ptr, size, MALLOC_CAP_SPIRAM)
#else
#define MEM_ALLOC_EXTRAM(size) malloc(size)
#define MEM_CALLOC_EXTRAM(num, size) calloc(num, size)
#define MEM_REALLOC_EXTRAM(ptr, size) realloc(ptr, size)
#endif
typedef struct esp_rmaker_time_config { typedef struct esp_rmaker_time_config {
/** If not specified, then 'CONFIG_ESP_RMAKER_SNTP_SERVER_NAME' is used as the SNTP server. */ /** If not specified, then 'CONFIG_ESP_RMAKER_SNTP_SERVER_NAME' is used as the SNTP server. */
char *sntp_server_name; char *sntp_server_name;

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -51,6 +51,7 @@
#define CONFIG_LIB_BUILDER_FLASHMODE "qio" #define CONFIG_LIB_BUILDER_FLASHMODE "qio"
#define CONFIG_LIB_BUILDER_FLASHFREQ "80m" #define CONFIG_LIB_BUILDER_FLASHFREQ "80m"
#define CONFIG_ESP_RMAKER_ASSISTED_CLAIM 1 #define CONFIG_ESP_RMAKER_ASSISTED_CLAIM 1
#define CONFIG_ESP_RMAKER_CLAIM_TYPE 2
#define CONFIG_ESP_RMAKER_MQTT_HOST "a1p72mufdu6064-ats.iot.us-east-1.amazonaws.com" #define CONFIG_ESP_RMAKER_MQTT_HOST "a1p72mufdu6064-ats.iot.us-east-1.amazonaws.com"
#define CONFIG_ESP_RMAKER_MAX_PARAM_DATA_SIZE 1024 #define CONFIG_ESP_RMAKER_MAX_PARAM_DATA_SIZE 1024
#define CONFIG_ESP_RMAKER_CONSOLE_UART_NUM_0 1 #define CONFIG_ESP_RMAKER_CONSOLE_UART_NUM_0 1

View file

@ -144,7 +144,10 @@ CONFIG_LIB_BUILDER_FLASHFREQ="80m"
# #
# ESP RainMaker Config # ESP RainMaker Config
# #
# CONFIG_ESP_RMAKER_NO_CLAIM is not set
# CONFIG_ESP_RMAKER_SELF_CLAIM is not set
CONFIG_ESP_RMAKER_ASSISTED_CLAIM=y CONFIG_ESP_RMAKER_ASSISTED_CLAIM=y
CONFIG_ESP_RMAKER_CLAIM_TYPE=2
CONFIG_ESP_RMAKER_MQTT_HOST="a1p72mufdu6064-ats.iot.us-east-1.amazonaws.com" CONFIG_ESP_RMAKER_MQTT_HOST="a1p72mufdu6064-ats.iot.us-east-1.amazonaws.com"
CONFIG_ESP_RMAKER_MAX_PARAM_DATA_SIZE=1024 CONFIG_ESP_RMAKER_MAX_PARAM_DATA_SIZE=1024
# CONFIG_ESP_RMAKER_DISABLE_USER_MAPPING_PROV is not set # CONFIG_ESP_RMAKER_DISABLE_USER_MAPPING_PROV is not set

View file

@ -42,14 +42,14 @@
* \defgroup CDC_Serial_Host Host * \defgroup CDC_Serial_Host Host
* @{ */ * @{ */
bool tuh_cdc_set_control_line_state(uint8_t dev_addr, bool dtr, bool rts, tuh_control_complete_cb_t complete_cb); bool tuh_cdc_set_control_line_state(uint8_t dev_addr, bool dtr, bool rts, tuh_control_xfer_cb_t complete_cb);
static inline bool tuh_cdc_connect(uint8_t dev_addr, tuh_control_complete_cb_t complete_cb) static inline bool tuh_cdc_connect(uint8_t dev_addr, tuh_control_xfer_cb_t complete_cb)
{ {
return tuh_cdc_set_control_line_state(dev_addr, true, true, complete_cb); return tuh_cdc_set_control_line_state(dev_addr, true, true, complete_cb);
} }
static inline bool tuh_cdc_disconnect(uint8_t dev_addr, tuh_control_complete_cb_t complete_cb) static inline bool tuh_cdc_disconnect(uint8_t dev_addr, tuh_control_xfer_cb_t complete_cb)
{ {
return tuh_cdc_set_control_line_state(dev_addr, false, false, complete_cb); return tuh_cdc_set_control_line_state(dev_addr, false, false, complete_cb);
} }

View file

@ -50,7 +50,7 @@ typedef struct {
}rndish_data_t; }rndish_data_t;
void rndish_init(void); void rndish_init(void);
tusb_error_t rndish_open_subtask(uint8_t dev_addr, cdch_data_t *p_cdc); bool rndish_open_subtask(uint8_t dev_addr, cdch_data_t *p_cdc);
void rndish_xfer_isr(cdch_data_t *p_cdc, pipe_handle_t pipe_hdl, xfer_result_t event, uint32_t xferred_bytes); void rndish_xfer_isr(cdch_data_t *p_cdc, pipe_handle_t pipe_hdl, xfer_result_t event, uint32_t xferred_bytes);
void rndish_close(uint8_t dev_addr); void rndish_close(uint8_t dev_addr);

View file

@ -49,16 +49,16 @@ static inline bool tusbh_custom_is_mounted(uint8_t dev_addr, uint16_t vendor_id,
return false; return false;
} }
tusb_error_t tusbh_custom_read(uint8_t dev_addr, uint16_t vendor_id, uint16_t product_id, void * p_buffer, uint16_t length); bool tusbh_custom_read(uint8_t dev_addr, uint16_t vendor_id, uint16_t product_id, void * p_buffer, uint16_t length);
tusb_error_t tusbh_custom_write(uint8_t dev_addr, uint16_t vendor_id, uint16_t product_id, void const * p_data, uint16_t length); bool tusbh_custom_write(uint8_t dev_addr, uint16_t vendor_id, uint16_t product_id, void const * p_data, uint16_t length);
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// Internal Class Driver API // Internal Class Driver API
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
void cush_init(void); void cush_init(void);
tusb_error_t cush_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_interface_desc, uint16_t *p_length); bool cush_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_interface_desc, uint16_t *p_length);
void cush_isr(pipe_handle_t pipe_hdl, xfer_result_t event); void cush_isr(pipe_handle_t pipe_hdl, xfer_result_t event);
void cush_close(uint8_t dev_addr); void cush_close(uint8_t dev_addr);
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -71,23 +71,10 @@
#include "tusb_compiler.h" #include "tusb_compiler.h"
#include "tusb_verify.h" #include "tusb_verify.h"
#include "tusb_types.h" #include "tusb_types.h"
#include "tusb_debug.h"
#include "tusb_error.h" // TODO remove
#include "tusb_timeout.h" // TODO remove #include "tusb_timeout.h" // TODO remove
//--------------------------------------------------------------------+
// Internal Helper used by Host and Device Stack
//--------------------------------------------------------------------+
// Check if endpoint descriptor is valid per USB specs
bool tu_edpt_validate(tusb_desc_endpoint_t const * desc_ep, tusb_speed_t speed);
// Bind all endpoint of a interface descriptor to class driver
void tu_edpt_bind_driver(uint8_t ep2drv[][2], tusb_desc_interface_t const* p_desc, uint16_t desc_len, uint8_t driver_id);
// Calculate total length of n interfaces (depending on IAD)
uint16_t tu_desc_get_interface_total_len(tusb_desc_interface_t const* desc_itf, uint8_t itf_count, uint16_t max_len);
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// Internal Inline Functions // Internal Inline Functions
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
@ -268,138 +255,6 @@ TU_ATTR_ALWAYS_INLINE static inline void tu_unaligned_write16 (void* mem, ui
+ TU_BIN8(dlsb)) + TU_BIN8(dlsb))
#endif #endif
//--------------------------------------------------------------------+
// Debug Function
//--------------------------------------------------------------------+
// CFG_TUSB_DEBUG for debugging
// 0 : no debug
// 1 : print error
// 2 : print warning
// 3 : print info
#if CFG_TUSB_DEBUG
void tu_print_mem(void const *buf, uint32_t count, uint8_t indent);
#ifdef CFG_TUSB_DEBUG_PRINTF
extern int CFG_TUSB_DEBUG_PRINTF(const char *format, ...);
#define tu_printf CFG_TUSB_DEBUG_PRINTF
#else
#define tu_printf printf
#endif
static inline
void tu_print_var(uint8_t const* buf, uint32_t bufsize)
{
for(uint32_t i=0; i<bufsize; i++) tu_printf("%02X ", buf[i]);
}
// Log with Level
#define TU_LOG(n, ...) TU_XSTRCAT(TU_LOG, n)(__VA_ARGS__)
#define TU_LOG_MEM(n, ...) TU_XSTRCAT3(TU_LOG, n, _MEM)(__VA_ARGS__)
#define TU_LOG_VAR(n, ...) TU_XSTRCAT3(TU_LOG, n, _VAR)(__VA_ARGS__)
#define TU_LOG_INT(n, ...) TU_XSTRCAT3(TU_LOG, n, _INT)(__VA_ARGS__)
#define TU_LOG_HEX(n, ...) TU_XSTRCAT3(TU_LOG, n, _HEX)(__VA_ARGS__)
#define TU_LOG_LOCATION() tu_printf("%s: %d:\r\n", __PRETTY_FUNCTION__, __LINE__)
#define TU_LOG_FAILED() tu_printf("%s: %d: Failed\r\n", __PRETTY_FUNCTION__, __LINE__)
// Log Level 1: Error
#define TU_LOG1 tu_printf
#define TU_LOG1_MEM tu_print_mem
#define TU_LOG1_VAR(_x) tu_print_var((uint8_t const*)(_x), sizeof(*(_x)))
#define TU_LOG1_INT(_x) tu_printf(#_x " = %ld\r\n", (unsigned long) (_x) )
#define TU_LOG1_HEX(_x) tu_printf(#_x " = %lX\r\n", (unsigned long) (_x) )
// Log Level 2: Warn
#if CFG_TUSB_DEBUG >= 2
#define TU_LOG2 TU_LOG1
#define TU_LOG2_MEM TU_LOG1_MEM
#define TU_LOG2_VAR TU_LOG1_VAR
#define TU_LOG2_INT TU_LOG1_INT
#define TU_LOG2_HEX TU_LOG1_HEX
#endif
// Log Level 3: Info
#if CFG_TUSB_DEBUG >= 3
#define TU_LOG3 TU_LOG1
#define TU_LOG3_MEM TU_LOG1_MEM
#define TU_LOG3_VAR TU_LOG1_VAR
#define TU_LOG3_INT TU_LOG1_INT
#define TU_LOG3_HEX TU_LOG1_HEX
#endif
typedef struct
{
uint32_t key;
const char* data;
} tu_lookup_entry_t;
typedef struct
{
uint16_t count;
tu_lookup_entry_t const* items;
} tu_lookup_table_t;
static inline const char* tu_lookup_find(tu_lookup_table_t const* p_table, uint32_t key)
{
static char not_found[11];
for(uint16_t i=0; i<p_table->count; i++)
{
if (p_table->items[i].key == key) return p_table->items[i].data;
}
// not found return the key value in hex
snprintf(not_found, sizeof(not_found), "0x%08lX", (unsigned long) key);
return not_found;
}
#endif // CFG_TUSB_DEBUG
#ifndef TU_LOG
#define TU_LOG(n, ...)
#define TU_LOG_MEM(n, ...)
#define TU_LOG_VAR(n, ...)
#define TU_LOG_INT(n, ...)
#define TU_LOG_HEX(n, ...)
#define TU_LOG_LOCATION()
#define TU_LOG_FAILED()
#endif
// TODO replace all TU_LOGn with TU_LOG(n)
#define TU_LOG0(...)
#define TU_LOG0_MEM(...)
#define TU_LOG0_VAR(...)
#define TU_LOG0_INT(...)
#define TU_LOG0_HEX(...)
#ifndef TU_LOG1
#define TU_LOG1(...)
#define TU_LOG1_MEM(...)
#define TU_LOG1_VAR(...)
#define TU_LOG1_INT(...)
#define TU_LOG1_HEX(...)
#endif
#ifndef TU_LOG2
#define TU_LOG2(...)
#define TU_LOG2_MEM(...)
#define TU_LOG2_VAR(...)
#define TU_LOG2_INT(...)
#define TU_LOG2_HEX(...)
#endif
#ifndef TU_LOG3
#define TU_LOG3(...)
#define TU_LOG3_MEM(...)
#define TU_LOG3_VAR(...)
#define TU_LOG3_INT(...)
#define TU_LOG3_HEX(...)
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -0,0 +1,174 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2022, Ha Thach (tinyusb.org)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* This file is part of the TinyUSB stack.
*/
#ifndef _TUSB_DEBUG_H_
#define _TUSB_DEBUG_H_
#ifdef __cplusplus
extern "C" {
#endif
//--------------------------------------------------------------------+
// Debug
//--------------------------------------------------------------------+
// CFG_TUSB_DEBUG for debugging
// 0 : no debug
// 1 : print error
// 2 : print warning
// 3 : print info
#if CFG_TUSB_DEBUG
// Enum to String for debugging purposes
#if CFG_TUSB_DEBUG >= 2
extern char const* const tu_str_speed[];
extern char const* const tu_str_std_request[];
#endif
void tu_print_mem(void const *buf, uint32_t count, uint8_t indent);
#ifdef CFG_TUSB_DEBUG_PRINTF
extern int CFG_TUSB_DEBUG_PRINTF(const char *format, ...);
#define tu_printf CFG_TUSB_DEBUG_PRINTF
#else
#define tu_printf printf
#endif
static inline void tu_print_var(uint8_t const* buf, uint32_t bufsize)
{
for(uint32_t i=0; i<bufsize; i++) tu_printf("%02X ", buf[i]);
}
// Log with Level
#define TU_LOG(n, ...) TU_XSTRCAT(TU_LOG, n)(__VA_ARGS__)
#define TU_LOG_MEM(n, ...) TU_XSTRCAT3(TU_LOG, n, _MEM)(__VA_ARGS__)
#define TU_LOG_VAR(n, ...) TU_XSTRCAT3(TU_LOG, n, _VAR)(__VA_ARGS__)
#define TU_LOG_INT(n, ...) TU_XSTRCAT3(TU_LOG, n, _INT)(__VA_ARGS__)
#define TU_LOG_HEX(n, ...) TU_XSTRCAT3(TU_LOG, n, _HEX)(__VA_ARGS__)
#define TU_LOG_LOCATION() tu_printf("%s: %d:\r\n", __PRETTY_FUNCTION__, __LINE__)
#define TU_LOG_FAILED() tu_printf("%s: %d: Failed\r\n", __PRETTY_FUNCTION__, __LINE__)
// Log Level 1: Error
#define TU_LOG1 tu_printf
#define TU_LOG1_MEM tu_print_mem
#define TU_LOG1_VAR(_x) tu_print_var((uint8_t const*)(_x), sizeof(*(_x)))
#define TU_LOG1_INT(_x) tu_printf(#_x " = %ld\r\n", (unsigned long) (_x) )
#define TU_LOG1_HEX(_x) tu_printf(#_x " = %lX\r\n", (unsigned long) (_x) )
// Log Level 2: Warn
#if CFG_TUSB_DEBUG >= 2
#define TU_LOG2 TU_LOG1
#define TU_LOG2_MEM TU_LOG1_MEM
#define TU_LOG2_VAR TU_LOG1_VAR
#define TU_LOG2_INT TU_LOG1_INT
#define TU_LOG2_HEX TU_LOG1_HEX
#endif
// Log Level 3: Info
#if CFG_TUSB_DEBUG >= 3
#define TU_LOG3 TU_LOG1
#define TU_LOG3_MEM TU_LOG1_MEM
#define TU_LOG3_VAR TU_LOG1_VAR
#define TU_LOG3_INT TU_LOG1_INT
#define TU_LOG3_HEX TU_LOG1_HEX
#endif
typedef struct
{
uint32_t key;
const char* data;
} tu_lookup_entry_t;
typedef struct
{
uint16_t count;
tu_lookup_entry_t const* items;
} tu_lookup_table_t;
static inline const char* tu_lookup_find(tu_lookup_table_t const* p_table, uint32_t key)
{
static char not_found[11];
for(uint16_t i=0; i<p_table->count; i++)
{
if (p_table->items[i].key == key) return p_table->items[i].data;
}
// not found return the key value in hex
snprintf(not_found, sizeof(not_found), "0x%08lX", (unsigned long) key);
return not_found;
}
#endif // CFG_TUSB_DEBUG
#ifndef TU_LOG
#define TU_LOG(n, ...)
#define TU_LOG_MEM(n, ...)
#define TU_LOG_VAR(n, ...)
#define TU_LOG_INT(n, ...)
#define TU_LOG_HEX(n, ...)
#define TU_LOG_LOCATION()
#define TU_LOG_FAILED()
#endif
// TODO replace all TU_LOGn with TU_LOG(n)
#define TU_LOG0(...)
#define TU_LOG0_MEM(...)
#define TU_LOG0_VAR(...)
#define TU_LOG0_INT(...)
#define TU_LOG0_HEX(...)
#ifndef TU_LOG1
#define TU_LOG1(...)
#define TU_LOG1_MEM(...)
#define TU_LOG1_VAR(...)
#define TU_LOG1_INT(...)
#define TU_LOG1_HEX(...)
#endif
#ifndef TU_LOG2
#define TU_LOG2(...)
#define TU_LOG2_MEM(...)
#define TU_LOG2_VAR(...)
#define TU_LOG2_INT(...)
#define TU_LOG2_HEX(...)
#endif
#ifndef TU_LOG3
#define TU_LOG3(...)
#define TU_LOG3_MEM(...)
#define TU_LOG3_VAR(...)
#define TU_LOG3_INT(...)
#define TU_LOG3_HEX(...)
#endif
#ifdef __cplusplus
}
#endif
#endif /* _TUSB_DEBUG_H_ */

View file

@ -1,77 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Ha Thach (tinyusb.org)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* This file is part of the TinyUSB stack.
*/
/** \ingroup Group_Common
* \defgroup Group_Error Error Codes
* @{ */
#ifndef _TUSB_ERRORS_H_
#define _TUSB_ERRORS_H_
#include "tusb_option.h"
#ifdef __cplusplus
extern "C" {
#endif
#define ERROR_ENUM(x) x,
#define ERROR_STRING(x) #x,
#define ERROR_TABLE(ENTRY) \
ENTRY(TUSB_ERROR_NONE )\
ENTRY(TUSB_ERROR_INVALID_PARA )\
ENTRY(TUSB_ERROR_DEVICE_NOT_READY )\
ENTRY(TUSB_ERROR_INTERFACE_IS_BUSY )\
ENTRY(TUSB_ERROR_HCD_OPEN_PIPE_FAILED )\
ENTRY(TUSB_ERROR_OSAL_TIMEOUT )\
ENTRY(TUSB_ERROR_CDCH_DEVICE_NOT_MOUNTED )\
ENTRY(TUSB_ERROR_MSCH_DEVICE_NOT_MOUNTED )\
ENTRY(TUSB_ERROR_NOT_SUPPORTED )\
ENTRY(TUSB_ERROR_NOT_ENOUGH_MEMORY )\
ENTRY(TUSB_ERROR_FAILED )\
/// \brief Error Code returned
/// TODO obsolete and to be remove
typedef enum
{
ERROR_TABLE(ERROR_ENUM)
TUSB_ERROR_COUNT
}tusb_error_t;
#if CFG_TUSB_DEBUG
/// Enum to String for debugging purposes. Only available if \ref CFG_TUSB_DEBUG > 0
extern char const* const tusb_strerr[TUSB_ERROR_COUNT];
extern char const* const tusb_speed_str[];
#endif
#ifdef __cplusplus
}
#endif
#endif /* _TUSB_ERRORS_H_ */
/** @} */

View file

@ -0,0 +1,65 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2022, Ha Thach (tinyusb.org)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* This file is part of the TinyUSB stack.
*/
#ifndef _TUSB_PRIVATE_H_
#define _TUSB_PRIVATE_H_
#ifdef __cplusplus
extern "C" {
#endif
typedef struct TU_ATTR_PACKED
{
volatile uint8_t busy : 1;
volatile uint8_t stalled : 1;
volatile uint8_t claimed : 1;
}tu_edpt_state_t;
//--------------------------------------------------------------------+
// Internal Helper used by Host and Device Stack
//--------------------------------------------------------------------+
// Check if endpoint descriptor is valid per USB specs
bool tu_edpt_validate(tusb_desc_endpoint_t const * desc_ep, tusb_speed_t speed);
// Bind all endpoint of a interface descriptor to class driver
void tu_edpt_bind_driver(uint8_t ep2drv[][2], tusb_desc_interface_t const* p_desc, uint16_t desc_len, uint8_t driver_id);
// Calculate total length of n interfaces (depending on IAD)
uint16_t tu_desc_get_interface_total_len(tusb_desc_interface_t const* desc_itf, uint8_t itf_count, uint16_t max_len);
// Claim an endpoint with provided mutex
bool tu_edpt_claim(tu_edpt_state_t* ep_state, osal_mutex_t mutex);
// Release an endpoint with provided mutex
bool tu_edpt_release(tu_edpt_state_t* ep_state, osal_mutex_t mutex);
#ifdef __cplusplus
}
#endif
#endif /* _TUSB_PRIVATE_H_ */

View file

@ -223,19 +223,13 @@ enum {
#define TUSB_DESC_CONFIG_POWER_MA(x) ((x)/2) #define TUSB_DESC_CONFIG_POWER_MA(x) ((x)/2)
/// Device State TODO remove
typedef enum
{
TUSB_DEVICE_STATE_UNPLUG = 0 ,
TUSB_DEVICE_STATE_CONFIGURED ,
TUSB_DEVICE_STATE_SUSPENDED ,
}tusb_device_state_t;
typedef enum typedef enum
{ {
XFER_RESULT_SUCCESS, XFER_RESULT_SUCCESS,
XFER_RESULT_FAILED, XFER_RESULT_FAILED,
XFER_RESULT_STALLED, XFER_RESULT_STALLED,
XFER_RESULT_TIMEOUT,
XFER_RESULT_INVALID
}xfer_result_t; }xfer_result_t;
enum // TODO remove enum // TODO remove
@ -265,6 +259,7 @@ typedef enum
enum enum
{ {
CONTROL_STAGE_IDLE,
CONTROL_STAGE_SETUP, CONTROL_STAGE_SETUP,
CONTROL_STAGE_DATA, CONTROL_STAGE_DATA,
CONTROL_STAGE_ACK CONTROL_STAGE_ACK

View file

@ -74,10 +74,8 @@
#if CFG_TUSB_DEBUG #if CFG_TUSB_DEBUG
#include <stdio.h> #include <stdio.h>
#define _MESS_ERR(_err) tu_printf("%s %d: failed, error = %s\r\n", __func__, __LINE__, tusb_strerr[_err])
#define _MESS_FAILED() tu_printf("%s %d: ASSERT FAILED\r\n", __func__, __LINE__) #define _MESS_FAILED() tu_printf("%s %d: ASSERT FAILED\r\n", __func__, __LINE__)
#else #else
#define _MESS_ERR(_err) do {} while (0)
#define _MESS_FAILED() do {} while (0) #define _MESS_FAILED() do {} while (0)
#endif #endif
@ -144,32 +142,6 @@
#define TU_ASSERT(...) GET_3RD_ARG(__VA_ARGS__, ASSERT_2ARGS, ASSERT_1ARGS,UNUSED)(__VA_ARGS__) #define TU_ASSERT(...) GET_3RD_ARG(__VA_ARGS__, ASSERT_2ARGS, ASSERT_1ARGS,UNUSED)(__VA_ARGS__)
#endif #endif
// TODO remove TU_ASSERT_ERR() later
/*------------- Generator for TU_VERIFY_ERR and TU_VERIFY_ERR_HDLR -------------*/
#define TU_VERIFY_ERR_DEF2(_error, _handler) do \
{ \
uint32_t _err = (uint32_t)(_error); \
if ( 0 != _err ) { _MESS_ERR(_err); _handler; return _err; } \
} while(0)
#define TU_VERIFY_ERR_DEF3(_error, _handler, _ret) do \
{ \
uint32_t _err = (uint32_t)(_error); \
if ( 0 != _err ) { _MESS_ERR(_err); _handler; return _ret; } \
} while(0)
/*------------------------------------------------------------------*/
/* ASSERT Error
* basically TU_VERIFY Error with TU_BREAKPOINT() as handler
*------------------------------------------------------------------*/
#define ASSERT_ERR_1ARGS(_error) TU_VERIFY_ERR_DEF2(_error, TU_BREAKPOINT())
#define ASSERT_ERR_2ARGS(_error, _ret) TU_VERIFY_ERR_DEF3(_error, TU_BREAKPOINT(), _ret)
#ifndef TU_ASSERT_ERR
#define TU_ASSERT_ERR(...) GET_3RD_ARG(__VA_ARGS__, ASSERT_ERR_2ARGS, ASSERT_ERR_1ARGS,UNUSED)(__VA_ARGS__)
#endif
/*------------------------------------------------------------------*/ /*------------------------------------------------------------------*/
/* ASSERT HDLR /* ASSERT HDLR
*------------------------------------------------------------------*/ *------------------------------------------------------------------*/

View file

@ -80,7 +80,7 @@ bool usbd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16
// If caller does not make any transfer, it must release endpoint for others. // If caller does not make any transfer, it must release endpoint for others.
bool usbd_edpt_claim(uint8_t rhport, uint8_t ep_addr); bool usbd_edpt_claim(uint8_t rhport, uint8_t ep_addr);
// Release an endpoint without submitting a transfer // Release claimed endpoint without submitting a transfer
bool usbd_edpt_release(uint8_t rhport, uint8_t ep_addr); bool usbd_edpt_release(uint8_t rhport, uint8_t ep_addr);
// Check if endpoint is busy transferring // Check if endpoint is busy transferring

View file

@ -94,7 +94,8 @@ typedef struct
} hcd_event_t; } hcd_event_t;
typedef struct { typedef struct
{
uint8_t rhport; uint8_t rhport;
uint8_t hub_addr; uint8_t hub_addr;
uint8_t hub_port; uint8_t hub_port;

View file

@ -171,12 +171,35 @@ typedef struct {
TU_VERIFY_STATIC( sizeof(hub_port_status_response_t) == 4, "size is not correct"); TU_VERIFY_STATIC( sizeof(hub_port_status_response_t) == 4, "size is not correct");
bool hub_port_clear_feature(uint8_t hub_addr, uint8_t hub_port, uint8_t feature, tuh_control_complete_cb_t complete_cb); // Clear feature
bool hub_port_set_feature(uint8_t hub_addr, uint8_t hub_port, uint8_t feature, tuh_control_complete_cb_t complete_cb); bool hub_port_clear_feature (uint8_t hub_addr, uint8_t hub_port, uint8_t feature,
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg);
// Set feature
bool hub_port_set_feature (uint8_t hub_addr, uint8_t hub_port, uint8_t feature,
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg);
// Get port status
bool hub_port_get_status (uint8_t hub_addr, uint8_t hub_port, void* resp,
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg);
// Get status from Interrupt endpoint
bool hub_edpt_status_xfer(uint8_t dev_addr);
// Reset a port
static inline bool hub_port_reset(uint8_t hub_addr, uint8_t hub_port,
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg)
{
return hub_port_set_feature(hub_addr, hub_port, HUB_FEATURE_PORT_RESET, complete_cb, user_arg);
}
// Clear Reset Change
static inline bool hub_port_clear_reset_change(uint8_t hub_addr, uint8_t hub_port,
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg)
{
return hub_port_clear_feature(hub_addr, hub_port, HUB_FEATURE_PORT_RESET_CHANGE, complete_cb, user_arg);
}
bool hub_port_reset(uint8_t hub_addr, uint8_t hub_port, tuh_control_complete_cb_t complete_cb);
bool hub_port_get_status(uint8_t hub_addr, uint8_t hub_port, void* resp, tuh_control_complete_cb_t complete_cb);
bool hub_status_pipe_queue(uint8_t dev_addr);
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// Internal Class Driver API // Internal Class Driver API

View file

@ -38,7 +38,31 @@
// MACRO CONSTANT TYPEDEF // MACRO CONSTANT TYPEDEF
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
typedef bool (*tuh_control_complete_cb_t)(uint8_t daddr, tusb_control_request_t const * request, xfer_result_t result); // forward declaration
struct tuh_control_xfer_s;
typedef struct tuh_control_xfer_s tuh_control_xfer_t;
typedef bool (*tuh_control_xfer_cb_t)(uint8_t daddr, tuh_control_xfer_t const * xfer, xfer_result_t result);
struct tuh_control_xfer_s
{
tusb_control_request_t request TU_ATTR_ALIGNED(4);
uint8_t* buffer;
tuh_control_xfer_cb_t complete_cb;
uintptr_t user_arg;
};
//--------------------------------------------------------------------+
// APPLICATION CALLBACK
//--------------------------------------------------------------------+
//TU_ATTR_WEAK uint8_t tuh_attach_cb (tusb_desc_device_t const *desc_device);
// Invoked when device is mounted (configured)
TU_ATTR_WEAK void tuh_mount_cb (uint8_t daddr);
/// Invoked when device is unmounted (bus reset/unplugged)
TU_ATTR_WEAK void tuh_umount_cb(uint8_t daddr);
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// APPLICATION API // APPLICATION API
@ -80,48 +104,102 @@ static inline bool tuh_ready(uint8_t daddr)
return tuh_mounted(daddr) && !tuh_suspended(daddr); return tuh_mounted(daddr) && !tuh_suspended(daddr);
} }
// Carry out control transfer // Carry out a control transfer
bool tuh_control_xfer (uint8_t daddr, tusb_control_request_t const* request, void* buffer, tuh_control_complete_cb_t complete_cb); // true on success, false if there is on-going control transfer or incorrect parameters
// Blocking if complete callback is NULL, in this case 'user_arg' must contain xfer_result_t variable
bool tuh_control_xfer (uint8_t daddr, tuh_control_xfer_t const* xfer);
// Set Configuration // Sync (blocking) version of tuh_control_xfer()
// return transfer result
uint8_t tuh_control_xfer_sync(uint8_t daddr, tuh_control_xfer_t const* xfer, uint32_t timeout_ms);
// Set Configuration (control transfer)
// config_num = 0 will un-configure device. Note: config_num = config_descriptor_index + 1 // config_num = 0 will un-configure device. Note: config_num = config_descriptor_index + 1
bool tuh_configuration_set(uint8_t daddr, uint8_t config_num, tuh_control_complete_cb_t complete_cb); // true on success, false if there is on-going control transfer or incorrect parameters
// Blocking if complete callback is NULL, in this case 'user_arg' must contain xfer_result_t variable
//------------- descriptors -------------// bool tuh_configuration_set(uint8_t daddr, uint8_t config_num,
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg);
// Get an descriptor
bool tuh_descriptor_get(uint8_t daddr, uint8_t type, uint8_t index,
void* buffer, uint16_t len, tuh_control_complete_cb_t complete_cb);
// Get device descriptor
bool tuh_descriptor_device_get(uint8_t daddr, void* buffer, uint16_t len, tuh_control_complete_cb_t complete_cb);
// Get configuration descriptor
bool tuh_descriptor_configuration_get(uint8_t daddr, uint8_t index, void* buffer, uint16_t len, tuh_control_complete_cb_t complete_cb);
// Get string descriptor
bool tuh_descriptor_string_get(uint8_t daddr, uint16_t language_id, uint8_t index,
void* buffer, uint16_t len, tuh_control_complete_cb_t complete_cb);
// Get manufacturer string descriptor
bool tuh_descriptor_string_manufacturer_get(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len, tuh_control_complete_cb_t complete_cb);
// Get product string descriptor
bool tuh_descriptor_string_product_get(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len, tuh_control_complete_cb_t complete_cb);
// Get serial string descriptor
bool tuh_descriptor_string_serial_get(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len, tuh_control_complete_cb_t complete_cb);
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// APPLICATION CALLBACK // Descriptors Asynchronous (non-blocking)
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
//TU_ATTR_WEAK uint8_t tuh_attach_cb (tusb_desc_device_t const *desc_device);
// Invoked when device is mounted (configured) // Get an descriptor (control transfer)
TU_ATTR_WEAK void tuh_mount_cb (uint8_t daddr); // true on success, false if there is on-going control transfer or incorrect parameters
bool tuh_descriptor_get(uint8_t daddr, uint8_t type, uint8_t index, void* buffer, uint16_t len,
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg);
/// Invoked when device is unmounted (bus reset/unplugged) // Get device descriptor (control transfer)
TU_ATTR_WEAK void tuh_umount_cb(uint8_t daddr); // true on success, false if there is on-going control transfer or incorrect parameters
bool tuh_descriptor_get_device(uint8_t daddr, void* buffer, uint16_t len,
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg);
// Get configuration descriptor (control transfer)
// true on success, false if there is on-going control transfer or incorrect parameters
bool tuh_descriptor_get_configuration(uint8_t daddr, uint8_t index, void* buffer, uint16_t len,
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg);
// Get HID report descriptor (control transfer)
// true on success, false if there is on-going control transfer or incorrect parameters
bool tuh_descriptor_get_hid_report(uint8_t daddr, uint8_t itf_num, uint8_t desc_type, uint8_t index, void* buffer, uint16_t len,
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg);
// Get string descriptor (control transfer)
// true on success, false if there is on-going control transfer or incorrect parameters
// Blocking if complete callback is NULL, in this case 'user_arg' must contain xfer_result_t variable
bool tuh_descriptor_get_string(uint8_t daddr, uint8_t index, uint16_t language_id, void* buffer, uint16_t len,
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg);
// Get manufacturer string descriptor (control transfer)
// true on success, false if there is on-going control transfer or incorrect parameters
bool tuh_descriptor_get_manufacturer_string(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len,
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg);
// Get product string descriptor (control transfer)
// true on success, false if there is on-going control transfer or incorrect parameters
bool tuh_descriptor_get_product_string(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len,
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg);
// Get serial string descriptor (control transfer)
// true on success, false if there is on-going control transfer or incorrect parameters
bool tuh_descriptor_get_serial_string(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len,
tuh_control_xfer_cb_t complete_cb, uintptr_t user_arg);
//--------------------------------------------------------------------+
// Descriptors Synchronous (blocking)
//--------------------------------------------------------------------+
// Sync (blocking) version of tuh_descriptor_get()
// return transfer result
uint8_t tuh_descriptor_get_sync(uint8_t daddr, uint8_t type, uint8_t index, void* buffer, uint16_t len, uint8_t timeout_ms);
// Sync (blocking) version of tuh_descriptor_get_device()
// return transfer result
uint8_t tuh_descriptor_get_device_sync(uint8_t daddr, void* buffer, uint16_t len, uint8_t timeout_ms);
// Sync (blocking) version of tuh_descriptor_get_configuration()
// return transfer result
uint8_t tuh_descriptor_get_configuration_sync(uint8_t daddr, uint8_t index, void* buffer, uint16_t len, uint8_t timeout_ms);
// Sync (blocking) version of tuh_descriptor_get_hid_report()
// return transfer result
uint8_t tuh_descriptor_get_hid_report_sync(uint8_t daddr, uint8_t itf_num, uint8_t desc_type, uint8_t index, void* buffer, uint16_t len, uint8_t timeout_ms);
// Sync (blocking) version of tuh_descriptor_get_string()
// return transfer result
uint8_t tuh_descriptor_get_string_sync(uint8_t daddr, uint8_t index, uint16_t language_id, void* buffer, uint16_t len, uint8_t timeout_ms);
// Sync (blocking) version of tuh_descriptor_get_manufacturer_string()
// return transfer result
uint8_t tuh_descriptor_get_manufacturer_string_sync(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len, uint8_t timeout_ms);
// Sync (blocking) version of tuh_descriptor_get_product_string()
// return transfer result
uint8_t tuh_descriptor_get_product_string_sync(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len, uint8_t timeout_ms);
// Sync (blocking) version of tuh_descriptor_get_serial_string()
// return transfer result
uint8_t tuh_descriptor_get_serial_string_sync(uint8_t daddr, uint16_t language_id, void* buffer, uint16_t len, uint8_t timeout_ms);
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -73,6 +73,7 @@ bool usbh_edpt_xfer(uint8_t dev_addr, uint8_t ep_addr, uint8_t * buffer, uint16_
// If caller does not make any transfer, it must release endpoint for others. // If caller does not make any transfer, it must release endpoint for others.
bool usbh_edpt_claim(uint8_t dev_addr, uint8_t ep_addr); bool usbh_edpt_claim(uint8_t dev_addr, uint8_t ep_addr);
// Release claimed endpoint without submitting a transfer
bool usbh_edpt_release(uint8_t dev_addr, uint8_t ep_addr); bool usbh_edpt_release(uint8_t dev_addr, uint8_t ep_addr);
// Check if endpoint transferring is complete // Check if endpoint transferring is complete

View file

@ -111,7 +111,7 @@ typedef struct
typedef osal_queue_def_t* osal_queue_t; typedef osal_queue_def_t* osal_queue_t;
// role device/host is used by OS NONE for mutex (disable usb isr) only // _int_set is used as mutex in OS NONE (disable/enable USB ISR)
#define OSAL_QUEUE_DEF(_int_set, _name, _depth, _type) \ #define OSAL_QUEUE_DEF(_int_set, _name, _depth, _type) \
uint8_t _name##_buf[_depth*sizeof(_type)]; \ uint8_t _name##_buf[_depth*sizeof(_type)]; \
osal_queue_def_t _name = { \ osal_queue_def_t _name = { \

View file

@ -117,8 +117,6 @@
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// APPLICATION API // APPLICATION API
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
/** \ingroup group_application_api
* @{ */
// Initialize device/host stack // Initialize device/host stack
// Note: when using with RTOS, this should be called after scheduler/kernel is started. // Note: when using with RTOS, this should be called after scheduler/kernel is started.
@ -131,8 +129,6 @@ bool tusb_inited(void);
// TODO // TODO
// bool tusb_teardown(void); // bool tusb_teardown(void);
/** @} */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -285,6 +285,9 @@
#define CFG_TUSB_OS_INC_PATH #define CFG_TUSB_OS_INC_PATH
#endif #endif
// mutex is only needed for RTOS TODO also required with multiple core MCUs
#define TUSB_OPT_MUTEX (CFG_TUSB_OS != OPT_OS_NONE)
//-------------------------------------------------------------------- //--------------------------------------------------------------------
// DEVICE OPTIONS // DEVICE OPTIONS
//-------------------------------------------------------------------- //--------------------------------------------------------------------

View file

@ -49,6 +49,8 @@ typedef enum {
RMAKER_EVENT_USER_NODE_MAPPING_DONE, RMAKER_EVENT_USER_NODE_MAPPING_DONE,
/** Local control started. Associated data is the NULL terminated Service Name */ /** Local control started. Associated data is the NULL terminated Service Name */
RMAKER_EVENT_LOCAL_CTRL_STARTED, RMAKER_EVENT_LOCAL_CTRL_STARTED,
/* User reset request successfully sent to ESP RainMaker Cloud */
RMAKER_EVENT_USER_NODE_MAPPING_RESET,
} esp_rmaker_event_t; } esp_rmaker_event_t;
/** ESP RainMaker Node information */ /** ESP RainMaker Node information */

View file

@ -19,6 +19,25 @@ extern "C"
{ {
#endif #endif
/** User-Node Mapping states */
typedef enum {
/** Mapping does not exist or is not initialized */
ESP_RMAKER_USER_MAPPING_RESET = 0,
/** Mapping has started */
ESP_RMAKER_USER_MAPPING_STARTED,
/** Mapping is done */
ESP_RMAKER_USER_MAPPING_DONE,
} esp_rmaker_user_mapping_state_t;
/**
* Get User-Node mapping state
*
* This returns the current user-node mapping state.
*
* @return user mapping state
*/
esp_rmaker_user_mapping_state_t esp_rmaker_user_node_mapping_get_state(void);
/** /**
* Create User Mapping Endpoint * Create User Mapping Endpoint
* *

View file

@ -558,14 +558,14 @@ static inline void __attribute__((always_inline)) uxPortCompareSetExtram(volatil
// --------------------- Interrupts ------------------------ // --------------------- Interrupts ------------------------
static inline UBaseType_t xPortSetInterruptMaskFromISR(void) static inline UBaseType_t __attribute__((always_inline)) xPortSetInterruptMaskFromISR(void)
{ {
UBaseType_t prev_int_level = XTOS_SET_INTLEVEL(XCHAL_EXCM_LEVEL); UBaseType_t prev_int_level = XTOS_SET_INTLEVEL(XCHAL_EXCM_LEVEL);
portbenchmarkINTERRUPT_DISABLE(); portbenchmarkINTERRUPT_DISABLE();
return prev_int_level; return prev_int_level;
} }
static inline void vPortClearInterruptMaskFromISR(UBaseType_t prev_level) static inline void __attribute__((always_inline)) vPortClearInterruptMaskFromISR(UBaseType_t prev_level)
{ {
portbenchmarkINTERRUPT_RESTORE(prev_level); portbenchmarkINTERRUPT_RESTORE(prev_level);
XTOS_RESTORE_JUST_INTLEVEL(prev_level); XTOS_RESTORE_JUST_INTLEVEL(prev_level);

View file

@ -390,7 +390,7 @@ static inline void gpio_ll_iomux_in(gpio_dev_t *hw, uint32_t gpio, uint32_t sign
* @param pin_name Pin name to configure * @param pin_name Pin name to configure
* @param func Function to assign to the pin * @param func Function to assign to the pin
*/ */
static inline void gpio_ll_iomux_func_sel(uint32_t pin_name, uint32_t func) static inline __attribute__((always_inline)) void gpio_ll_iomux_func_sel(uint32_t pin_name, uint32_t func)
{ {
PIN_FUNC_SELECT(pin_name, func); PIN_FUNC_SELECT(pin_name, func);
} }

View file

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -225,7 +225,7 @@ void emac_hal_start(emac_hal_context_t *hal);
* @param hal EMAC HAL context infostructure * @param hal EMAC HAL context infostructure
* @return * @return
* - ESP_OK: succeed * - ESP_OK: succeed
* - ESP_ERR_INVALID_STATE: previous frame transmission is not completed. When this error occurs, * - ESP_ERR_INVALID_STATE: previous frame transmission/reception is not completed. When this error occurs,
* wait and reapeat the EMAC stop again. * wait and reapeat the EMAC stop again.
*/ */
esp_err_t emac_hal_stop(emac_hal_context_t *hal); esp_err_t emac_hal_stop(emac_hal_context_t *hal);

View file

@ -35,9 +35,26 @@ typedef enum {
RMAKER_MQTT_EVENT_CONNECTED, RMAKER_MQTT_EVENT_CONNECTED,
/** Disconnected from MQTT Broker */ /** Disconnected from MQTT Broker */
RMAKER_MQTT_EVENT_DISCONNECTED, RMAKER_MQTT_EVENT_DISCONNECTED,
/** MQTT message published successfully */ /** MQTT message published successfully.
* Event data will contain the message ID (integer) of published message.
*/
RMAKER_MQTT_EVENT_PUBLISHED, RMAKER_MQTT_EVENT_PUBLISHED,
} esp_rmaker_mqtt_event_t; /** POSIX Timezone Changed. Associated data would be NULL terminated POSIX Timezone
* Eg. "PST8PDT,M3.2.0,M11.1.0" */
RMAKER_EVENT_TZ_POSIX_CHANGED,
/** Timezone Changed. Associated data would be NULL terminated Timezone.
* Eg. "America/Los_Angeles"
* Note that whenever this event is received, the RMAKER_EVENT_TZ_POSIX_CHANGED event
* will also be received, but not necessarily vice versa.
*/
RMAKER_EVENT_TZ_CHANGED,
/**
* MQTT message deleted from the outbox if the message couldn't have been sent and acknowledged.
* Event data will contain the message ID (integer) of deleted message.
* Valid only if CONFIG_MQTT_REPORT_DELETED_MESSAGES is enabled.
*/
RMAKER_MQTT_EVENT_MSG_DELETED,
} esp_rmaker_common_event_t;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -63,6 +63,12 @@ typedef void (*esp_rmaker_mqtt_subscribe_cb_t)(const char *topic, void *payload,
*/ */
typedef esp_err_t (*esp_rmaker_mqtt_init_t)(esp_rmaker_mqtt_conn_params_t *conn_params); typedef esp_err_t (*esp_rmaker_mqtt_init_t)(esp_rmaker_mqtt_conn_params_t *conn_params);
/** MQTT Deinit function prototype
*
* Call this function after MQTT has disconnected.
*/
typedef void (*esp_rmaker_mqtt_deinit_t)(void);
/** MQTT Connect function prototype /** MQTT Connect function prototype
* *
* Starts the connection attempts to the MQTT broker. * Starts the connection attempts to the MQTT broker.
@ -124,6 +130,8 @@ typedef struct {
esp_rmaker_mqtt_get_conn_params_t get_conn_params; esp_rmaker_mqtt_get_conn_params_t get_conn_params;
/** Pointer to MQTT Init function. */ /** Pointer to MQTT Init function. */
esp_rmaker_mqtt_init_t init; esp_rmaker_mqtt_init_t init;
/** Pointer to MQTT Deinit function. */
esp_rmaker_mqtt_deinit_t deinit;
/** Pointer to MQTT Connect function. */ /** Pointer to MQTT Connect function. */
esp_rmaker_mqtt_connect_t connect; esp_rmaker_mqtt_connect_t connect;
/** Pointer to MQTQ Disconnect function */ /** Pointer to MQTQ Disconnect function */

View file

@ -15,12 +15,24 @@
#include <stdint.h> #include <stdint.h>
#include <sntp.h> #include <sntp.h>
#include <esp_err.h> #include <esp_err.h>
#include <esp_heap_caps.h>
#include <sdkconfig.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#endif #endif
#ifdef CONFIG_SPIRAM
#define MEM_ALLOC_EXTRAM(size) heap_caps_malloc(size, MALLOC_CAP_SPIRAM)
#define MEM_CALLOC_EXTRAM(num, size) heap_caps_calloc(num, size, MALLOC_CAP_SPIRAM)
#define MEM_REALLOC_EXTRAM(ptr, size) heap_caps_realloc(ptr, size, MALLOC_CAP_SPIRAM)
#else
#define MEM_ALLOC_EXTRAM(size) malloc(size)
#define MEM_CALLOC_EXTRAM(num, size) calloc(num, size)
#define MEM_REALLOC_EXTRAM(ptr, size) realloc(ptr, size)
#endif
typedef struct esp_rmaker_time_config { typedef struct esp_rmaker_time_config {
/** If not specified, then 'CONFIG_ESP_RMAKER_SNTP_SERVER_NAME' is used as the SNTP server. */ /** If not specified, then 'CONFIG_ESP_RMAKER_SNTP_SERVER_NAME' is used as the SNTP server. */
char *sntp_server_name; char *sntp_server_name;

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show more