summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHiFiPhile <[email protected]>2025-09-12 11:39:41 +0200
committerHiFiPhile <[email protected]>2025-09-12 11:39:41 +0200
commit5755afa690f242988c02932068339ad5ffc4404e (patch)
tree499992bf6e696b354d5faea58e75aeb5db842e39 /src
parentd3ab48bd79e53adbe763c924508edda1d60a968d (diff)
Fix some IAR warnings
Signed-off-by: HiFiPhile <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/class/hid/hid_host.c3
-rw-r--r--src/host/usbh.c27
-rw-r--r--src/portable/ehci/ehci.c5
3 files changed, 19 insertions, 16 deletions
diff --git a/src/class/hid/hid_host.c b/src/class/hid/hid_host.c
index 56fccdd22..a44c83433 100644
--- a/src/class/hid/hid_host.c
+++ b/src/class/hid/hid_host.c
@@ -519,7 +519,8 @@ bool hidh_open(uint8_t rhport, uint8_t daddr, tusb_desc_interface_t const* desc_
// Assume bNumDescriptors = 1
p_hid->report_desc_type = desc_hid->bReportType;
- p_hid->report_desc_len = tu_unaligned_read16(&desc_hid->wReportLength);
+ // Use offsetof to avoid pointer to the odd/misaligned address
+ p_hid->report_desc_len = tu_unaligned_read16((uint8_t const*)desc_hid + offsetof(tusb_hid_descriptor_hid_t, wReportLength));
// Per HID Specs: default is Report protocol, though we will force Boot protocol when set_config
p_hid->protocol_mode = _hidh_default_protocol;
diff --git a/src/host/usbh.c b/src/host/usbh.c
index ce83977c5..1c63ac712 100644
--- a/src/host/usbh.c
+++ b/src/host/usbh.c
@@ -400,7 +400,7 @@ bool tuh_descriptor_get_device_local(uint8_t daddr, tusb_desc_device_t* desc_dev
tusb_speed_t tuh_speed_get(uint8_t daddr) {
tuh_bus_info_t bus_info;
tuh_bus_info_get(daddr, &bus_info);
- return bus_info.speed;
+ return (tusb_speed_t)bus_info.speed;
}
bool tuh_rhport_is_active(uint8_t rhport) {
@@ -651,7 +651,7 @@ void tuh_task_ext(uint32_t timeout_ms, bool in_isr) {
tuh_xfer_t xfer = {
.daddr = event.dev_addr,
.ep_addr = ep_addr,
- .result = event.xfer_complete.result,
+ .result = (xfer_result_t)event.xfer_complete.result,
.actual_len = event.xfer_complete.len,
.buflen = 0, // not available
.buffer = NULL, // not available
@@ -832,18 +832,19 @@ static bool usbh_control_xfer_cb (uint8_t daddr, uint8_t ep_addr, xfer_result_t
}
TU_ATTR_FALLTHROUGH;
- case CONTROL_STAGE_DATA:
- if (request->wLength) {
- TU_LOG_USBH("[%u:%u] Control data:\r\n", rhport, daddr);
- TU_LOG_MEM_USBH(ctrl_info->buffer, xferred_bytes, 2);
- }
- ctrl_info->actual_len = (uint16_t) xferred_bytes;
+ case CONTROL_STAGE_DATA: {
+ if (request->wLength) {
+ TU_LOG_USBH("[%u:%u] Control data:\r\n", rhport, daddr);
+ TU_LOG_MEM_USBH(ctrl_info->buffer, xferred_bytes, 2);
+ }
+ ctrl_info->actual_len = (uint16_t) xferred_bytes;
- // ACK stage: toggle is always 1
- _control_set_xfer_stage(CONTROL_STAGE_ACK);
- const uint8_t ep_status = tu_edpt_addr(0, 1 - request->bmRequestType_bit.direction);
- TU_ASSERT(hcd_edpt_xfer(rhport, daddr, ep_status, NULL, 0));
- break;
+ // ACK stage: toggle is always 1
+ _control_set_xfer_stage(CONTROL_STAGE_ACK);
+ const uint8_t ep_status = tu_edpt_addr(0, 1 - request->bmRequestType_bit.direction);
+ TU_ASSERT(hcd_edpt_xfer(rhport, daddr, ep_status, NULL, 0));
+ break;
+ }
case CONTROL_STAGE_ACK: {
// Abort all pending transfers if SET_CONFIGURATION request
diff --git a/src/portable/ehci/ehci.c b/src/portable/ehci/ehci.c
index da9f49d29..b372fe635 100644
--- a/src/portable/ehci/ehci.c
+++ b/src/portable/ehci/ehci.c
@@ -184,7 +184,8 @@ static void ehci_enable_schedule(ehci_registers_t* regs, bool is_period) {
//--------------------------------------------------------------------+
uint32_t hcd_frame_number(uint8_t rhport) {
(void) rhport;
- return (ehci_data.uframe_number + ehci_data.regs->frame_index) >> 3;
+ uint32_t uframe = ehci_data.regs->frame_index;
+ return (ehci_data.uframe_number + uframe) >> 3;
}
void hcd_port_reset(uint8_t rhport) {
@@ -896,7 +897,7 @@ static void qhd_init(ehci_qhd_t *p_qhd, uint8_t dev_addr, tusb_desc_endpoint_t c
p_qhd->used = 1;
p_qhd->removing = 0;
p_qhd->attached_qtd = NULL;
- p_qhd->pid = tu_edpt_dir(ep_desc->bEndpointAddress) ? EHCI_PID_IN : EHCI_PID_OUT; // PID for TD under this endpoint
+ p_qhd->pid = tu_edpt_dir(ep_desc->bEndpointAddress) == TUSB_DIR_IN ? EHCI_PID_IN : EHCI_PID_OUT; // PID for TD under this endpoint
//------------- active, but no TD list -------------//
p_qhd->qtd_overlay.halted = 0;