mirror of
https://github.com/esphome/esphome.git
synced 2025-10-31 23:21:54 +00:00
Fix warning about shift overflow
This commit is contained in:
@@ -65,6 +65,7 @@ static_assert(MAX_REQUESTS >= 1 && MAX_REQUESTS <= 32, "MAX_REQUESTS must be bet
|
|||||||
// This is tied to the static_assert above, which enforces MAX_REQUESTS is between 1 and 32.
|
// This is tied to the static_assert above, which enforces MAX_REQUESTS is between 1 and 32.
|
||||||
// If MAX_REQUESTS is increased above 32, this logic and the static_assert must be updated.
|
// If MAX_REQUESTS is increased above 32, this logic and the static_assert must be updated.
|
||||||
using trq_bitmask_t = std::conditional<(MAX_REQUESTS <= 16), uint16_t, uint32_t>::type;
|
using trq_bitmask_t = std::conditional<(MAX_REQUESTS <= 16), uint16_t, uint32_t>::type;
|
||||||
|
static constexpr trq_bitmask_t ALL_REQUESTS_IN_USE = MAX_REQUESTS == 32 ? ~0 : (1 << MAX_REQUESTS) - 1;
|
||||||
|
|
||||||
static constexpr size_t USB_EVENT_QUEUE_SIZE = 32; // Size of event queue between USB task and main loop
|
static constexpr size_t USB_EVENT_QUEUE_SIZE = 32; // Size of event queue between USB task and main loop
|
||||||
static constexpr size_t USB_TASK_STACK_SIZE = 4096; // Stack size for USB task (same as ESP-IDF USB examples)
|
static constexpr size_t USB_TASK_STACK_SIZE = 4096; // Stack size for USB task (same as ESP-IDF USB examples)
|
||||||
|
|||||||
@@ -338,7 +338,7 @@ TransferRequest *USBClient::get_trq_() {
|
|||||||
// Find first available slot (bit = 0) and try to claim it atomically
|
// Find first available slot (bit = 0) and try to claim it atomically
|
||||||
// We use a while loop to allow retrying the same slot after CAS failure
|
// We use a while loop to allow retrying the same slot after CAS failure
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (mask == (1 << MAX_REQUESTS) - 1) {
|
if (mask == ALL_REQUESTS_IN_USE) {
|
||||||
ESP_LOGE(TAG, "All %zu transfer slots in use", MAX_REQUESTS);
|
ESP_LOGE(TAG, "All %zu transfer slots in use", MAX_REQUESTS);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
usb_host:
|
||||||
|
max_transfer_requests: 32
|
||||||
|
|
||||||
usb_uart:
|
usb_uart:
|
||||||
- id: uart_0
|
- id: uart_0
|
||||||
type: cdc_acm
|
type: cdc_acm
|
||||||
|
|||||||
Reference in New Issue
Block a user