summaryrefslogtreecommitdiff
path: root/port/renesas/device/r_usb_device.h
blob: 49298bdb374c03752699e1081be1fb9df7bf0d1c (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
 * Copyright (c) 2020 - 2024 Renesas Electronics Corporation and/or its affiliates
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#ifndef R_USB_DEVICE_H
#define R_USB_DEVICE_H

/***********************************************************************************************************************
 * Includes
 **********************************************************************************************************************/
#include "bsp_api.h"
#include "r_usb_device_api.h"
#include "r_usb_device_cfg.h"

/* Common macro for FSP header files. There is also a corresponding FSP_FOOTER macro at the end of this file. */
FSP_HEADER

/***********************************************************************************************************************
 * Macro definitions
 **********************************************************************************************************************/

/**********************************************************************************************************************
 * Typedef definitions
 **********************************************************************************************************************/

typedef enum e_usbd_control_stage
{
    USB_CONTROL_STAGE_IDLE                = 0x0,
    USB_CONTROL_STAGE_SETUP               = 0x0,
    USB_CONTROL_STAGE_READ_DATA           = 0x1,
    USB_CONTROL_STAGE_READ_STATUS         = 0x2,
    USB_CONTROL_STAGE_WRITE_DATA          = 0x3,
    USB_CONTROL_STAGE_WRITE_STATUS        = 0x4,
    USB_CONTROL_STAGE_WRITE_NODATA_STATUS = 0x5,
    USB_CONTROL_STAGE_ERROR               = 0x6,
} usbd_control_stage_t;

typedef struct st_usbd_instance_ctrl
{
    uint32_t           open;
    void             * p_reg;
    usbd_cfg_t const * p_cfg;
    void (* p_callback)(usbd_callback_arg_t * p_args);
    usbd_callback_arg_t         * p_callback_memory;
    void const                  * p_context;
    volatile usbd_control_stage_t dcp_stage;
} usbd_instance_ctrl_t;

/**********************************************************************************************************************
 * Exported global variables
 **********************************************************************************************************************/

fsp_err_t R_USBD_Open(usbd_ctrl_t * const p_api_ctrl, usbd_cfg_t const * const p_cfg);
fsp_err_t R_USBD_RemoteWakeup(usbd_ctrl_t * const p_api_ctrl);
fsp_err_t R_USBD_Connect(usbd_ctrl_t * const p_api_ctrl);
fsp_err_t R_USBD_Disconnect(usbd_ctrl_t * const p_api_ctrl);
fsp_err_t R_USBD_EdptOpen(usbd_ctrl_t * const p_api_ctrl, usbd_desc_endpoint_t const * p_ep_desc);
fsp_err_t R_USBD_EdptClose(usbd_ctrl_t * const p_api_ctrl, uint8_t ep_addr);
fsp_err_t R_USBD_XferStart(usbd_ctrl_t * const p_api_ctrl, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes);
fsp_err_t R_USBD_XferAbort(usbd_ctrl_t * const p_api_ctrl, uint8_t ep_addr);
fsp_err_t R_USBD_EdptStall(usbd_ctrl_t * const p_api_ctrl, uint8_t ep_addr);
fsp_err_t R_USBD_EdptClearStall(usbd_ctrl_t * const p_api_ctrl, uint8_t ep_addr);
fsp_err_t R_USBD_Close(usbd_ctrl_t * const p_api_ctrl);

/* Common macro for FSP header files. There is also a corresponding FSP_HEADER macro at the top of this file. */
FSP_FOOTER

#endif /* R_USB_DEVICE_H */