summaryrefslogtreecommitdiff
path: root/platform/rtthread/rt_usb_msh.c
blob: 8dd61164071c400b0ab085bfde57f5188c116884 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
 * Copyright (c) 2024, sakumisu
 *
 * SPDX-License-Identifier: Apache-2.0
 */
#include "rtthread.h"

#if defined(PKG_CHERRYUSB_HOST) || defined(RT_CHERRYUSB_HOST)

#include "usbh_core.h"

int usbh_init(int argc, char **argv)
{
    uint8_t busid;
    uint32_t reg_base;

    if (argc < 3) {
        USB_LOG_ERR("please input correct command: usbh_init <busid> <reg_base>\r\n");
        return -1;
    }

    busid = atoi(argv[1]);
    reg_base = strtoll(argv[2], NULL, 16);
    usbh_initialize(busid, reg_base, NULL);

    return 0;
}

int usbh_deinit(int argc, char **argv)
{
    uint8_t busid;

    if (argc < 2) {
        USB_LOG_ERR("please input correct command: usbh_deinit <busid>\r\n");
        return -1;
    }

    busid = atoi(argv[1]);
    usbh_deinitialize(busid);

    return 0;
}

MSH_CMD_EXPORT(usbh_init, init usb host);
MSH_CMD_EXPORT(usbh_deinit, deinit usb host);
MSH_CMD_EXPORT(lsusb, ls usb devices);

#ifdef CONFIG_USBHOST_SERIAL
#include "usbh_serial.h"
MSH_CMD_EXPORT(usbh_serial, usbh_serial test);
#endif

#endif