Skip to content

Commit 6b86f97

Browse files
authored
Merge pull request #23 from espressif/master
25102021
2 parents f0db73b + 15bbd0a commit 6b86f97

34 files changed

+104
-77
lines changed

Diff for: boards.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -9687,10 +9687,10 @@ deneyapmini.build.boot=qio
96879687
deneyapmini.build.partitions=default
96889688
deneyapmini.build.defines=
96899689

9690-
deneyapmini.menu.SerialMode.default=USB_CDC
9691-
deneyapmini.menu.SerialMode.default.build.serial=1
9692-
deneyapmini.menu.SerialMode.uart=UART0
9693-
deneyapmini.menu.SerialMode.uart.build.serial=0
9690+
deneyapmini.menu.CDCOnBoot.default=Disabled
9691+
deneyapmini.menu.CDCOnBoot.default.build.cdc_on_boot=0
9692+
deneyapmini.menu.CDCOnBoot.cdc=Enabled
9693+
deneyapmini.menu.CDCOnBoot.cdc.build.cdc_on_boot=1
96949694

96959695
deneyapmini.menu.PSRAM.disabled=Disabled
96969696
deneyapmini.menu.PSRAM.disabled.build.defines=

Diff for: libraries/EEPROM/examples/eeprom_class/eeprom_class.ino

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,27 @@
1111
#include "EEPROM.h"
1212

1313
// Instantiate eeprom objects with parameter/argument names and sizes
14-
EEPROMClass NAMES("eeprom0", 0x500);
15-
EEPROMClass HEIGHT("eeprom1", 0x200);
16-
EEPROMClass AGE("eeprom2", 0x100);
14+
EEPROMClass NAMES("eeprom0");
15+
EEPROMClass HEIGHT("eeprom1");
16+
EEPROMClass AGE("eeprom2");
1717

1818
void setup() {
1919
Serial.begin(115200);
2020
delay(1000);
2121
Serial.println("Testing EEPROMClass\n");
22-
if (!NAMES.begin(NAMES.length())) {
22+
if (!NAMES.begin(0x500)) {
2323
Serial.println("Failed to initialise NAMES");
2424
Serial.println("Restarting...");
2525
delay(1000);
2626
ESP.restart();
2727
}
28-
if (!HEIGHT.begin(HEIGHT.length())) {
28+
if (!HEIGHT.begin(0x200)) {
2929
Serial.println("Failed to initialise HEIGHT");
3030
Serial.println("Restarting...");
3131
delay(1000);
3232
ESP.restart();
3333
}
34-
if (!AGE.begin(AGE.length())) {
34+
if (!AGE.begin(0x100)) {
3535
Serial.println("Failed to initialise AGE");
3636
Serial.println("Restarting...");
3737
delay(1000);

Diff for: libraries/EEPROM/src/EEPROM.cpp

+2-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ EEPROMClass::EEPROMClass(void)
3434
, _size(0)
3535
, _dirty(false)
3636
, _name("eeprom")
37-
, _user_defined_size(0)
3837
{
3938
}
4039

@@ -45,17 +44,15 @@ EEPROMClass::EEPROMClass(uint32_t sector)
4544
, _size(0)
4645
, _dirty(false)
4746
, _name("eeprom")
48-
, _user_defined_size(0)
4947
{
5048
}
5149

52-
EEPROMClass::EEPROMClass(const char* name, uint32_t user_defined_size)
50+
EEPROMClass::EEPROMClass(const char* name)
5351
: _handle(0)
5452
, _data(0)
5553
, _size(0)
5654
, _dirty(false)
5755
, _name(name)
58-
, _user_defined_size(user_defined_size)
5956
{
6057
}
6158

@@ -215,7 +212,7 @@ uint8_t * EEPROMClass::getDataPtr() {
215212
*/
216213
uint16_t EEPROMClass::length ()
217214
{
218-
return _user_defined_size;
215+
return _size;
219216
}
220217

221218
/*

Diff for: libraries/EEPROM/src/EEPROM.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ typedef uint32_t nvs_handle;
3535
class EEPROMClass {
3636
public:
3737
EEPROMClass(uint32_t sector);
38-
EEPROMClass(const char* name, uint32_t user_defined_size);
38+
EEPROMClass(const char* name);
3939
EEPROMClass(void);
4040
~EEPROMClass(void);
4141

@@ -112,7 +112,6 @@ class EEPROMClass {
112112
size_t _size;
113113
bool _dirty;
114114
const char* _name;
115-
uint32_t _user_defined_size;
116115
};
117116

118117
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_EEPROM)

Diff for: libraries/WiFiClientSecure/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,18 @@ To use PSK:
6666
encryption for the connection
6767

6868
Please see the WiFiClientPSK example.
69+
70+
Specifying the ALPN Protocol
71+
----------------------------
72+
73+
Application-Layer Protocol Negotiation (ALPN) is a Transport Layer Security (TLS) extension that allows
74+
the application layer to negotiate which protocol should be performed over a secure connection in a manner
75+
that avoids additional round trips and which is independent of the application-layer protocols.
76+
77+
For example, this is used with AWS IoT Custom Authorizers where an MQTT client must set the ALPN protocol to ```mqtt```:
78+
79+
```
80+
const char *aws_protos[] = {"mqtt", NULL};
81+
...
82+
wiFiClient.setAlpnProtocols(aws_protos);
83+
```

Diff for: libraries/WiFiClientSecure/keywords.txt

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ connected KEYWORD2
2929
setCACert KEYWORD2
3030
setCertificate KEYWORD2
3131
setPrivateKey KEYWORD2
32+
setAlpnProtocols KEYWORD2
3233

3334
#######################################
3435
# Constants (LITERAL1)

Diff for: libraries/WiFiClientSecure/src/WiFiClientSecure.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ WiFiClientSecure::WiFiClientSecure()
4343
_pskIdent = NULL;
4444
_psKey = NULL;
4545
next = NULL;
46+
_alpn_protos = NULL;
4647
}
4748

4849

@@ -66,6 +67,7 @@ WiFiClientSecure::WiFiClientSecure(int sock)
6667
_pskIdent = NULL;
6768
_psKey = NULL;
6869
next = NULL;
70+
_alpn_protos = NULL;
6971
}
7072

7173
WiFiClientSecure::~WiFiClientSecure()
@@ -127,7 +129,7 @@ int WiFiClientSecure::connect(const char *host, uint16_t port, const char *CA_ce
127129
if(_timeout > 0){
128130
sslclient->handshake_timeout = _timeout;
129131
}
130-
int ret = start_ssl_client(sslclient, host, port, _timeout, CA_cert, cert, private_key, NULL, NULL, _use_insecure);
132+
int ret = start_ssl_client(sslclient, host, port, _timeout, CA_cert, cert, private_key, NULL, NULL, _use_insecure, _alpn_protos);
131133
_lastError = ret;
132134
if (ret < 0) {
133135
log_e("start_ssl_client: %d", ret);
@@ -147,7 +149,7 @@ int WiFiClientSecure::connect(const char *host, uint16_t port, const char *pskId
147149
if(_timeout > 0){
148150
sslclient->handshake_timeout = _timeout;
149151
}
150-
int ret = start_ssl_client(sslclient, host, port, _timeout, NULL, NULL, NULL, pskIdent, psKey, _use_insecure);
152+
int ret = start_ssl_client(sslclient, host, port, _timeout, NULL, NULL, NULL, pskIdent, psKey, _use_insecure, _alpn_protos);
151153
_lastError = ret;
152154
if (ret < 0) {
153155
log_e("start_ssl_client: %d", ret);
@@ -341,3 +343,8 @@ void WiFiClientSecure::setHandshakeTimeout(unsigned long handshake_timeout)
341343
{
342344
sslclient->handshake_timeout = handshake_timeout * 1000;
343345
}
346+
347+
void WiFiClientSecure::setAlpnProtocols(const char **alpn_protos)
348+
{
349+
_alpn_protos = alpn_protos;
350+
}

Diff for: libraries/WiFiClientSecure/src/WiFiClientSecure.h

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class WiFiClientSecure : public WiFiClient
3939
const char *_private_key;
4040
const char *_pskIdent; // identity for PSK cipher suites
4141
const char *_psKey; // key in hex for PSK cipher suites
42+
const char **_alpn_protos;
4243

4344
public:
4445
WiFiClientSecure *next;
@@ -73,6 +74,7 @@ class WiFiClientSecure : public WiFiClient
7374
bool loadPrivateKey(Stream& stream, size_t size);
7475
bool verify(const char* fingerprint, const char* domain_name);
7576
void setHandshakeTimeout(unsigned long handshake_timeout);
77+
void setAlpnProtocols(const char **alpn_protos);
7678
const mbedtls_x509_crt* getPeerCertificate() { return mbedtls_ssl_get_peer_cert(&sslclient->ssl_ctx); };
7779
bool getFingerprintSHA256(uint8_t sha256_result[32]) { return get_peer_fingerprint(sslclient, sha256_result); };
7880
int setTimeout(uint32_t seconds){ return 0; }

Diff for: libraries/WiFiClientSecure/src/ssl_client.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void ssl_init(sslclient_context *ssl_client)
5151
}
5252

5353

54-
int start_ssl_client(sslclient_context *ssl_client, const char *host, uint32_t port, int timeout, const char *rootCABuff, const char *cli_cert, const char *cli_key, const char *pskIdent, const char *psKey, bool insecure)
54+
int start_ssl_client(sslclient_context *ssl_client, const char *host, uint32_t port, int timeout, const char *rootCABuff, const char *cli_cert, const char *cli_key, const char *pskIdent, const char *psKey, bool insecure, const char **alpn_protos)
5555
{
5656
char buf[512];
5757
int ret, flags;
@@ -156,6 +156,13 @@ int start_ssl_client(sslclient_context *ssl_client, const char *host, uint32_t p
156156
return handle_error(ret);
157157
}
158158

159+
if (alpn_protos != NULL) {
160+
log_v("Setting ALPN protocols");
161+
if ((ret = mbedtls_ssl_conf_alpn_protocols(&ssl_client->ssl_conf, alpn_protos) ) != 0) {
162+
return handle_error(ret);
163+
}
164+
}
165+
159166
// MBEDTLS_SSL_VERIFY_REQUIRED if a CA certificate is defined on Arduino IDE and
160167
// MBEDTLS_SSL_VERIFY_NONE if not.
161168

Diff for: libraries/WiFiClientSecure/src/ssl_client.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ typedef struct sslclient_context {
2929

3030

3131
void ssl_init(sslclient_context *ssl_client);
32-
int start_ssl_client(sslclient_context *ssl_client, const char *host, uint32_t port, int timeout, const char *rootCABuff, const char *cli_cert, const char *cli_key, const char *pskIdent, const char *psKey, bool insecure);
32+
int start_ssl_client(sslclient_context *ssl_client, const char *host, uint32_t port, int timeout, const char *rootCABuff, const char *cli_cert, const char *cli_key, const char *pskIdent, const char *psKey, bool insecure, const char **alpn_protos);
3333
void stop_ssl_socket(sslclient_context *ssl_client, const char *rootCABuff, const char *cli_cert, const char *cli_key);
3434
int data_to_read(sslclient_context *ssl_client);
3535
int send_ssl_data(sslclient_context *ssl_client, const uint8_t *data, size_t len);

Diff for: platform.txt

+3-3
Large diffs are not rendered by default.

Diff for: tools/platformio-build-esp32.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@
301301
"UNITY_INCLUDE_CONFIG_H",
302302
"WITH_POSIX",
303303
"_GNU_SOURCE",
304-
("IDF_VER", '\\"v4.4-dev-3540-g4e03a9c34c\\"'),
304+
("IDF_VER", '\\"v4.4-dev-3544-g2720d45e71\\"'),
305305
"ESP_PLATFORM",
306306
"ARDUINO_ARCH_ESP32",
307307
"ESP32",

Diff for: tools/platformio-build-esp32c3.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@
292292
"UNITY_INCLUDE_CONFIG_H",
293293
"WITH_POSIX",
294294
"_GNU_SOURCE",
295-
("IDF_VER", '\\"v4.4-dev-3540-g4e03a9c34c\\"'),
295+
("IDF_VER", '\\"v4.4-dev-3544-g2720d45e71\\"'),
296296
"ESP_PLATFORM",
297297
"ARDUINO_ARCH_ESP32",
298298
"ESP32",

Diff for: tools/platformio-build-esp32s2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@
287287
"UNITY_INCLUDE_CONFIG_H",
288288
"WITH_POSIX",
289289
"_GNU_SOURCE",
290-
("IDF_VER", '\\"v4.4-dev-3540-g4e03a9c34c\\"'),
290+
("IDF_VER", '\\"v4.4-dev-3544-g2720d45e71\\"'),
291291
"ESP_PLATFORM",
292292
"ARDUINO_ARCH_ESP32",
293293
"ESP32",

Diff for: tools/sdk/esp32/include/config/sdkconfig.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@
371371
#define CONFIG_LWIP_GARP_TMR_INTERVAL 60
372372
#define CONFIG_LWIP_TCPIP_RECVMBOX_SIZE 32
373373
#define CONFIG_LWIP_DHCP_RESTORE_LAST_IP 1
374-
#define CONFIG_LWIP_DHCP_OPTIONS_LEN 68
374+
#define CONFIG_LWIP_DHCP_OPTIONS_LEN 128
375375
#define CONFIG_LWIP_DHCPS 1
376376
#define CONFIG_LWIP_DHCPS_LEASE_UNIT 60
377377
#define CONFIG_LWIP_DHCPS_MAX_STATION_NUM 8
@@ -673,5 +673,5 @@
673673
#define CONFIG_ULP_COPROC_RESERVE_MEM CONFIG_ESP32_ULP_COPROC_RESERVE_MEM
674674
#define CONFIG_WARN_WRITE_STRINGS CONFIG_COMPILER_WARN_WRITE_STRINGS
675675
#define CONFIG_WIFI_LWIP_ALLOCATION_FROM_SPIRAM_FIRST CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP
676-
#define CONFIG_ARDUINO_IDF_COMMIT "4e03a9c34c"
677-
#define CONFIG_ARDUINO_IDF_BRANCH "master"
676+
#define CONFIG_ARDUINO_IDF_COMMIT "2720d45e71"
677+
#define CONFIG_ARDUINO_IDF_BRANCH "release/v4.4"

Diff for: tools/sdk/esp32/lib/libapp_update.a

0 Bytes
Binary file not shown.

Diff for: tools/sdk/esp32/lib/libesp_system.a

0 Bytes
Binary file not shown.

Diff for: tools/sdk/esp32/lib/liblwip.a

-140 Bytes
Binary file not shown.

Diff for: tools/sdk/esp32/sdkconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,7 @@ CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32
10291029
# CONFIG_LWIP_DHCP_DOES_ARP_CHECK is not set
10301030
# CONFIG_LWIP_DHCP_DISABLE_CLIENT_ID is not set
10311031
CONFIG_LWIP_DHCP_RESTORE_LAST_IP=y
1032-
CONFIG_LWIP_DHCP_OPTIONS_LEN=68
1032+
CONFIG_LWIP_DHCP_OPTIONS_LEN=128
10331033

10341034
#
10351035
# DHCP server

Diff for: tools/sdk/esp32c3/include/config/sdkconfig.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@
340340
#define CONFIG_LWIP_GARP_TMR_INTERVAL 60
341341
#define CONFIG_LWIP_TCPIP_RECVMBOX_SIZE 32
342342
#define CONFIG_LWIP_DHCP_DOES_ARP_CHECK 1
343-
#define CONFIG_LWIP_DHCP_OPTIONS_LEN 68
343+
#define CONFIG_LWIP_DHCP_OPTIONS_LEN 128
344344
#define CONFIG_LWIP_DHCPS 1
345345
#define CONFIG_LWIP_DHCPS_LEASE_UNIT 60
346346
#define CONFIG_LWIP_DHCPS_MAX_STATION_NUM 8
@@ -627,5 +627,5 @@
627627
#define CONFIG_TIMER_TASK_STACK_SIZE CONFIG_ESP_TIMER_TASK_STACK_SIZE
628628
#define CONFIG_TOOLPREFIX CONFIG_SDK_TOOLPREFIX
629629
#define CONFIG_UDP_RECVMBOX_SIZE CONFIG_LWIP_UDP_RECVMBOX_SIZE
630-
#define CONFIG_ARDUINO_IDF_COMMIT "4e03a9c34c"
631-
#define CONFIG_ARDUINO_IDF_BRANCH "master"
630+
#define CONFIG_ARDUINO_IDF_COMMIT "2720d45e71"
631+
#define CONFIG_ARDUINO_IDF_BRANCH "release/v4.4"

Diff for: tools/sdk/esp32c3/lib/libapp_update.a

0 Bytes
Binary file not shown.

Diff for: tools/sdk/esp32c3/lib/libesp_system.a

0 Bytes
Binary file not shown.

Diff for: tools/sdk/esp32c3/lib/liblwip.a

280 Bytes
Binary file not shown.

Diff for: tools/sdk/esp32c3/sdkconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@ CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32
10471047
CONFIG_LWIP_DHCP_DOES_ARP_CHECK=y
10481048
# CONFIG_LWIP_DHCP_DISABLE_CLIENT_ID is not set
10491049
# CONFIG_LWIP_DHCP_RESTORE_LAST_IP is not set
1050-
CONFIG_LWIP_DHCP_OPTIONS_LEN=68
1050+
CONFIG_LWIP_DHCP_OPTIONS_LEN=128
10511051

10521052
#
10531053
# DHCP server

Diff for: tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/usbtmc/usbtmc_device.h

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
/*
2-
* usbtmc_device.h
3-
*
4-
* Created on: Sep 10, 2019
5-
* Author: nconrad
6-
*/
71
/*
82
* The MIT License (MIT)
93
*

Diff for: tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/video/video.h

+8
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ TU_VERIFY_STATIC( sizeof(video_probe_and_commit_control_t) == 48, "size is not c
373373
#define TUD_VIDEO_DESC_CS_VC_LEN 12
374374
#define TUD_VIDEO_DESC_INPUT_TERM_LEN 8
375375
#define TUD_VIDEO_DESC_OUTPUT_TERM_LEN 9
376+
#define TUD_VIDEO_DESC_CAMERA_TERM_LEN 18
376377
#define TUD_VIDEO_DESC_STD_VS_LEN 9
377378
#define TUD_VIDEO_DESC_CS_VS_IN_LEN 13
378379
#define TUD_VIDEO_DESC_CS_VS_OUT_LEN 9
@@ -412,6 +413,13 @@ TU_VERIFY_STATIC( sizeof(video_probe_and_commit_control_t) == 48, "size is not c
412413
TUD_VIDEO_DESC_OUTPUT_TERM_LEN, TUSB_DESC_CS_INTERFACE, VIDEO_CS_ITF_VC_OUTPUT_TERMINAL, \
413414
_tid, U16_TO_U8S_LE(_tt), _at, _srcid, _stridx
414415

416+
/* 3.7.2.3 */
417+
#define TUD_VIDEO_DESC_CAMERA_TERM(_tid, _at, _stridx, _focal_min, _focal_max, _focal, _ctls) \
418+
TUD_VIDEO_DESC_CAMERA_TERM_LEN, TUSB_DESC_CS_INTERFACE, VIDEO_CS_ITF_VC_INPUT_TERMINAL, \
419+
_tid, U16_TO_U8S_LE(VIDEO_ITT_CAMERA), _at, _stridx, \
420+
U16_TO_U8S_LE(_focal_min), U16_TO_U8S_LE(_focal_max), U16_TO_U8S_LE(_focal), 3, \
421+
TU_U32_BYTE0(_ctls), TU_U32_BYTE1(_ctls), TU_U32_BYTE2(_ctls)
422+
415423
/* 3.9.1 */
416424
#define TUD_VIDEO_DESC_STD_VS(_itfnum, _alt, _epn, _stridx) \
417425
TUD_VIDEO_DESC_STD_VS_LEN, TUSB_DESC_INTERFACE, _itfnum, _alt, \

Diff for: tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_common.h

+13-13
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,21 @@
3838
#define TU_MIN(_x, _y) ( ( (_x) < (_y) ) ? (_x) : (_y) )
3939
#define TU_MAX(_x, _y) ( ( (_x) > (_y) ) ? (_x) : (_y) )
4040

41-
#define TU_U16_HIGH(_u16) ((uint8_t) (((_u16) >> 8) & 0x00ff))
42-
#define TU_U16_LOW(_u16) ((uint8_t) ((_u16) & 0x00ff))
43-
#define U16_TO_U8S_BE(_u16) TU_U16_HIGH(_u16), TU_U16_LOW(_u16)
44-
#define U16_TO_U8S_LE(_u16) TU_U16_LOW(_u16), TU_U16_HIGH(_u16)
41+
#define TU_U16_HIGH(_u16) ((uint8_t) (((_u16) >> 8) & 0x00ff))
42+
#define TU_U16_LOW(_u16) ((uint8_t) ((_u16) & 0x00ff))
43+
#define U16_TO_U8S_BE(_u16) TU_U16_HIGH(_u16), TU_U16_LOW(_u16)
44+
#define U16_TO_U8S_LE(_u16) TU_U16_LOW(_u16), TU_U16_HIGH(_u16)
4545

46-
#define TU_U32_BYTE3(_u32) ((uint8_t) ((((uint32_t) _u32) >> 24) & 0x000000ff)) // MSB
47-
#define TU_U32_BYTE2(_u32) ((uint8_t) ((((uint32_t) _u32) >> 16) & 0x000000ff))
48-
#define TU_U32_BYTE1(_u32) ((uint8_t) ((((uint32_t) _u32) >> 8) & 0x000000ff))
49-
#define TU_U32_BYTE0(_u32) ((uint8_t) (((uint32_t) _u32) & 0x000000ff)) // LSB
46+
#define TU_U32_BYTE3(_u32) ((uint8_t) ((((uint32_t) _u32) >> 24) & 0x000000ff)) // MSB
47+
#define TU_U32_BYTE2(_u32) ((uint8_t) ((((uint32_t) _u32) >> 16) & 0x000000ff))
48+
#define TU_U32_BYTE1(_u32) ((uint8_t) ((((uint32_t) _u32) >> 8) & 0x000000ff))
49+
#define TU_U32_BYTE0(_u32) ((uint8_t) (((uint32_t) _u32) & 0x000000ff)) // LSB
5050

51-
#define U32_TO_U8S_BE(_u32) TU_U32_BYTE3(_u32), TU_U32_BYTE2(_u32), TU_U32_BYTE1(_u32), TU_U32_BYTE0(_u32)
52-
#define U32_TO_U8S_LE(_u32) TU_U32_BYTE0(_u32), TU_U32_BYTE1(_u32), TU_U32_BYTE2(_u32), TU_U32_BYTE3(_u32)
51+
#define U32_TO_U8S_BE(_u32) TU_U32_BYTE3(_u32), TU_U32_BYTE2(_u32), TU_U32_BYTE1(_u32), TU_U32_BYTE0(_u32)
52+
#define U32_TO_U8S_LE(_u32) TU_U32_BYTE0(_u32), TU_U32_BYTE1(_u32), TU_U32_BYTE2(_u32), TU_U32_BYTE3(_u32)
5353

5454
#define TU_BIT(n) (1UL << (n))
55+
#define TU_GENMASK(h, l) ( (UINT32_MAX << (l)) & (UINT32_MAX >> (31 - (h))) )
5556

5657
//--------------------------------------------------------------------+
5758
// Includes
@@ -161,7 +162,6 @@ static inline uint8_t tu_log2(uint32_t value)
161162
#if TUP_ARCH_STRICT_ALIGN
162163

163164
// Rely on compiler to generate correct code for unaligned access
164-
165165
typedef struct { uint16_t val; } TU_ATTR_PACKED tu_unaligned_uint16_t;
166166
typedef struct { uint32_t val; } TU_ATTR_PACKED tu_unaligned_uint32_t;
167167

@@ -227,8 +227,8 @@ TU_ATTR_ALWAYS_INLINE static inline void tu_unaligned_write16(void* mem, uint16_
227227
#else
228228

229229
// MCU that could access unaligned memory natively
230-
TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_unaligned_read32 (const void* mem ) { return *((uint32_t*) mem); }
231-
TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_unaligned_read16 (const void* mem ) { return *((uint16_t*) mem); }
230+
TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_unaligned_read32 (const void* mem) { return *((uint32_t const *) mem); }
231+
TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_unaligned_read16 (const void* mem) { return *((uint16_t const *) mem); }
232232

233233
TU_ATTR_ALWAYS_INLINE static inline void tu_unaligned_write32 (void* mem, uint32_t value ) { *((uint32_t*) mem) = value; }
234234
TU_ATTR_ALWAYS_INLINE static inline void tu_unaligned_write16 (void* mem, uint16_t value ) { *((uint16_t*) mem) = value; }

0 commit comments

Comments
 (0)