usbdev_mock.h
1 /*
2  * Copyright (C) 2019 Koen Zandberg <koen@bergzand.net>
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
17 #ifndef USBDEV_MOCK_H
18 #define USBDEV_MOCK_H
19 
20 #include <stdint.h>
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
29 #define USBDEV_MOCK_NUM_EP (1)
30 
34 typedef enum {
38 
42 typedef struct {
45  size_t available;
46  uint8_t *buf_start;
48 
52 typedef struct usbdev_mock usbdev_mock_t;
53 
59 typedef void (*usbdev_mock_esr_cb_t)(usbdev_mock_t *dev);
60 
68  usbdev_mock_ep_t *ep);
69 
78  usbdev_mock_ep_t *ep,
79  size_t len);
80 
84 struct usbdev_mock {
88  uint8_t config_addr;
89  size_t req_len;
97 };
98 
107  usbdev_mock_ep_esr_cb_t ep_esr_cb,
108  usbdev_mock_ready_cb_t ready_cb);
109 
110 #ifdef __cplusplus
111 }
112 #endif
113 
114 #endif /* USBDEV_MOCK_H */
115 
usbdev_mock::req_len
size_t req_len
Length of the current request
Definition: usbdev_mock.h:89
usbdev_mock::out
usbdev_mock_ep_t out[USBDEV_MOCK_NUM_EP]
OUT endpoints
Definition: usbdev_mock.h:87
usbdev_mock::in
usbdev_mock_ep_t in[USBDEV_MOCK_NUM_EP]
IN endpoints
Definition: usbdev_mock.h:86
usbdev_mock_ep_t::available
size_t available
Bytes available in the buffer
Definition: usbdev_mock.h:45
usbdev_mock::config_addr
uint8_t config_addr
Configured address
Definition: usbdev_mock.h:88
EP_STATE_DATA_AVAILABLE
@ EP_STATE_DATA_AVAILABLE
Endpoint has data
Definition: usbdev_mock.h:36
usbdev_mock_ep_esr_cb_t
void(* usbdev_mock_ep_esr_cb_t)(usbdev_mock_t *dev, usbdev_mock_ep_t *ep)
usbdev mock device callback for endpoint event checking
Definition: usbdev_mock.h:67
usbdev_mock::ready_cb
usbdev_mock_ready_cb_t ready_cb
Endpoint ready cb for validation
Definition: usbdev_mock.h:95
usbdev_mock::ep_esr_cb
usbdev_mock_ep_esr_cb_t ep_esr_cb
Endpoint ESR cb for validation
Definition: usbdev_mock.h:93
usbdev_mock::usbdev
usbdev_t usbdev
Generic usbdev device
Definition: usbdev_mock.h:85
usbdev_mock_setup
void usbdev_mock_setup(usbdev_mock_esr_cb_t esr_cb, usbdev_mock_ep_esr_cb_t ep_esr_cb, usbdev_mock_ready_cb_t ready_cb)
usbdev mock device setup function
USBDEV_MOCK_NUM_EP
#define USBDEV_MOCK_NUM_EP
Number of IN and OUT endpoints available in the mock usbdev device.
Definition: usbdev_mock.h:29
usbdev
usbdev device descriptor
Definition: usbdev.h:217
usbdev_mock_esr_cb_t
void(* usbdev_mock_esr_cb_t)(usbdev_mock_t *dev)
usbdev mock device callback for esr event checking
Definition: usbdev_mock.h:59
usbdev_mock_ready_cb_t
void(* usbdev_mock_ready_cb_t)(usbdev_mock_t *dev, usbdev_mock_ep_t *ep, size_t len)
usbdev mock device callback for endpoint ready call checking
Definition: usbdev_mock.h:77
usbdev_ep
usbdev endpoint descriptor
Definition: usbdev.h:229
EP_STATE_READY
@ EP_STATE_READY
Endpoint is ready/idle.
Definition: usbdev_mock.h:35
usbdev_mock_ep_t::ep
usbdev_ep_t ep
Generic endpoint struct
Definition: usbdev_mock.h:43
usbdev_mock
usbdev mock device
Definition: usbdev_mock.h:84
usbdev_mock_ep_t::buf_start
uint8_t * buf_start
Start location of the buffer
Definition: usbdev_mock.h:46
usbdev_mock_ep_t
usbdev mock device endpoint
Definition: usbdev_mock.h:42
usbdev_mock::esr_cb
usbdev_mock_esr_cb_t esr_cb
ESR callback for validation
Definition: usbdev_mock.h:91
usbdev_mock_ep_state_t
usbdev_mock_ep_state_t
Definition: usbdev_mock.h:34
usbdev_mock_ep_t::state
usbdev_mock_ep_state_t state
Endpoint state
Definition: usbdev_mock.h:44