1 /* 2 * Copyright (c) 2020 - 2024 Renesas Electronics Corporation and/or its affiliates 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef R_USB_HOST_API_H 8 #define R_USB_HOST_API_H 9 10 /*********************************************************************************************************************** 11 * Includes 12 **********************************************************************************************************************/ 13 14 /* Includes board and MCU related header files. */ 15 #include "bsp_api.h" 16 #include "r_usb_api.h" 17 18 /* Common macro for FSP header files. There is also a corresponding FSP_FOOTER macro at the end of this file. */ 19 FSP_HEADER 20 21 /********************************************************************************************************************** 22 * Macro definitions 23 **********************************************************************************************************************/ 24 25 /********************************************************************************************************************** 26 * Typedef definitions 27 **********************************************************************************************************************/ 28 typedef enum e_usbh_event_id 29 { 30 USBH_EVENT_DEVICE_ATTACH = 0, 31 USBH_EVENT_DEVICE_REMOVE, 32 USBH_EVENT_XFER_COMPLETE 33 } usbh_event_id_t; 34 35 typedef struct st_usbh_device_attach 36 { 37 uint8_t hub_addr; 38 uint8_t hub_port; 39 uint8_t speed; 40 } usbh_device_attach_t; 41 42 typedef struct st_usbh_device_remove 43 { 44 uint8_t hub_addr; 45 uint8_t hub_port; 46 uint8_t speed; 47 } usbh_device_remove_t; 48 49 typedef struct st_usbh_xfer_complete 50 { 51 uint8_t ep_addr; 52 uint8_t result; 53 uint32_t len; 54 } usbh_xfer_complete_t; 55 56 typedef struct st_usbh_event 57 { 58 usbh_event_id_t event_id; 59 uint8_t dev_addr; 60 union 61 { 62 usbh_device_attach_t attach; 63 usbh_device_remove_t remove; 64 usbh_xfer_complete_t complete; 65 }; 66 } usbh_event_t; 67 68 typedef uint32_t usb_status_t; 69 70 typedef struct st_usbh_callback_arg 71 { 72 uint32_t module_number; 73 usbh_event_t event; 74 void const * p_context; 75 } usbh_callback_arg_t; 76 77 typedef struct st_usb_cfg 78 { 79 /* USB generic configuration */ 80 uint32_t module_number; 81 IRQn_Type irq; 82 IRQn_Type irq_r; 83 IRQn_Type irq_d0; 84 IRQn_Type irq_d1; 85 IRQn_Type hs_irq; 86 IRQn_Type hsirq_d0; 87 IRQn_Type hsirq_d1; 88 uint8_t ipl; 89 uint8_t ipl_r; 90 uint8_t ipl_d0; 91 uint8_t ipl_d1; 92 uint8_t hsipl; 93 uint8_t hsipl_d0; 94 uint8_t hsipl_d1; 95 96 /* Configuration for USB Event processing */ 97 void (* p_callback)(usbh_callback_arg_t * p_args); 98 void const * p_context; 99 bool high_speed; 100 } usb_cfg_t; 101 102 typedef void usb_ctrl_t; 103 104 FSP_FOOTER 105 106 #endif /* R_USB_HOST_API_H */ 107