config busid and regbase in usbh_initialize and usbd_initialize
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
#include "usbd_core.h"
|
||||
#include "usbd_hid.h"
|
||||
|
||||
#define CONFIG_USBDEV_DEMO_BUS 0
|
||||
|
||||
/*!< endpoint address */
|
||||
#define HID_INT_EP 0x81
|
||||
#define HID_INT_EP_SIZE 4
|
||||
@@ -196,7 +194,7 @@ static USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX struct hid_mouse mouse_cfg;
|
||||
/*!< hid state ! Data can be sent only when state is idle */
|
||||
static volatile uint8_t hid_state = HID_STATE_IDLE;
|
||||
|
||||
static void usbd_event_handler(uint8_t event)
|
||||
static void usbd_event_handler(uint8_t busid, uint8_t event)
|
||||
{
|
||||
switch (event) {
|
||||
case USBD_EVENT_RESET:
|
||||
@@ -235,13 +233,13 @@ static struct usbd_endpoint hid_in_ep = {
|
||||
|
||||
struct usbd_interface intf0;
|
||||
|
||||
void hid_mouse_init(void)
|
||||
void hid_mouse_init(uint8_t busid, uint32_t reg_base)
|
||||
{
|
||||
usbd_desc_register(CONFIG_USBDEV_DEMO_BUS, hid_descriptor);
|
||||
usbd_add_interface(CONFIG_USBDEV_DEMO_BUS, usbd_hid_init_intf(CONFIG_USBDEV_DEMO_BUS, &intf0, hid_mouse_report_desc, HID_MOUSE_REPORT_DESC_SIZE));
|
||||
usbd_add_endpoint(CONFIG_USBDEV_DEMO_BUS, &hid_in_ep);
|
||||
usbd_desc_register(busid, hid_descriptor);
|
||||
usbd_add_interface(busid, usbd_hid_init_intf(busid, &intf0, hid_mouse_report_desc, HID_MOUSE_REPORT_DESC_SIZE));
|
||||
usbd_add_endpoint(busid, &hid_in_ep);
|
||||
|
||||
usbd_initialize(CONFIG_USBDEV_DEMO_BUS, usbd_event_handler);
|
||||
usbd_initialize(busid, reg_base, usbd_event_handler);
|
||||
|
||||
/*!< init mouse report data */
|
||||
mouse_cfg.buttons = 0;
|
||||
@@ -256,7 +254,7 @@ void hid_mouse_init(void)
|
||||
* @param[in] none
|
||||
* @retval none
|
||||
*/
|
||||
void hid_mouse_test(void)
|
||||
void hid_mouse_test(uint8_t busid)
|
||||
{
|
||||
int counter = 0;
|
||||
while (counter < 1000) {
|
||||
@@ -264,7 +262,7 @@ void hid_mouse_test(void)
|
||||
mouse_cfg.x += 40;
|
||||
mouse_cfg.y += 0;
|
||||
|
||||
int ret = usbd_ep_start_write(CONFIG_USBDEV_DEMO_BUS, HID_INT_EP, (uint8_t *)&mouse_cfg, 4);
|
||||
int ret = usbd_ep_start_write(busid, HID_INT_EP, (uint8_t *)&mouse_cfg, 4);
|
||||
if (ret < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user