summaryrefslogtreecommitdiff
path: root/mcc_generated_files/usb/usb_common/usb_core_events.h
blob: bed84e77a5c3f825c6863a54f293e808212f414d (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/**
 * USBCOREEVENTS USB Core Events Header File
 * @file usb_core_events.h
 * @defgroup usb_core_events USB Core Events
 * @ingroup usb_core
 * @brief Event handling for the USB Core Stack.
 * @version USB Device Core Version 1.0.0
 */

/*
    (c) 2021 Microchip Technology Inc. and its subsidiaries.

    Subject to your compliance with these terms, you may use Microchip software and any
    derivatives exclusively with Microchip products. It is your responsibility to comply with third party
    license terms applicable to your use of third party software (including open source software) that
    may accompany Microchip software.

    THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
    EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
    IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
    FOR A PARTICULAR PURPOSE.

    IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
    INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
    WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
    HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
    THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
    CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
    OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
    SOFTWARE.
 */

#ifndef USB_CORE_EVENTS_H
// cppcheck-suppress misra-c2012-2.5
#define USB_CORE_EVENTS_H

#include <stdbool.h>
#include <stdint.h>

#include <usb_common_elements.h>

#include <usb_core_descriptors.h>
#include <usb_core_requests.h>
#include <usb_core_transfer.h>
#include <usb_peripheral.h>
#include <usb_protocol_headers.h>

/**
 * @ingroup usb_core
 * @struct USB_EVENT_HANDLERS_struct
 * @brief Represents the event callbacks, the configuration and the enumeration setups.
 */
typedef struct USB_EVENT_HANDLERS_struct
{
    USB_SETUP_EVENT_CALLBACK_t SetConfiguration;
    USB_SETUP_EVENT_CALLBACK_t SetInterface;
    USB_EVENT_CALLBACK_t InterfaceDisabled;
    USB_SETUP_PROCESS_CALLBACK_t VendorRequest;
    USB_SETUP_PROCESS_CALLBACK_t ClassRequest;
    USB_SETUP_PROCESS_CALLBACK_t OtherRequest;
    USB_EVENT_CALLBACK_t SOFCallback;
    USB_EVENT_CALLBACK_t ResetCallback;
    USB_EVENT_CALLBACK_t SuspendCallback;
    USB_EVENT_CALLBACK_t ResumeCallback;
} USB_EVENT_HANDLERS_t;

extern USB_EVENT_HANDLERS_t event;

/**
 * @ingroup usb_core
 * @brief Handles the different types of events.
 * @param None.
 * @return SUCCESS or an Error code according to RETURN_CODE_t
 */

RETURN_CODE_t USB_EventHandler(void);

/**
 * @ingroup usb_core
 * @brief Registers a callback for Set Configuration requests.
 * @param callback - Reference for the callback function
 * @return None.
 */
void USB_SetConfigurationCallbackRegister(USB_SETUP_EVENT_CALLBACK_t callback);

/**
 * @ingroup usb_core
 * @brief Registers a callback for Set Interface requests.
 * @param callback -  Reference for the callback function
 * @return None.
 */
void USB_SetInterfaceCallbackRegister(USB_SETUP_EVENT_CALLBACK_t callback);

/**
 * @ingroup usb_core
 * @brief Registers a callback for disabling interfaces.
 * @param callback - Reference for the callback function
 * @return None.
 */
void USB_InterfaceDisabledCallbackRegister(USB_EVENT_CALLBACK_t callback);

/**
 * @ingroup usb_core
 * @brief Registers a callback for vendor requests.
 * @param callback - Reference for the callback function
 * @return None.
 */
void USB_VendorRequestCallbackRegister(USB_SETUP_PROCESS_CALLBACK_t callback);

/**
 * @ingroup usb_core
 * @brief Registers a callback for class requests.
 * @param callback - Reference for the callback function
 * @return None.
 */
void USB_ClassRequestCallbackRegister(USB_SETUP_PROCESS_CALLBACK_t callback);

/**
 * @ingroup usb_core
 * @brief Registers a callback for other requests.
 * @param callback - Reference for the callback function
 * @return None.
 */
void USB_OtherRequestCallbackRegister(USB_SETUP_PROCESS_CALLBACK_t callback);

/**
 * @ingroup usb_core
 * @brief Registers a callback for Start-Of-Frame (SOF) events.
 * @param callback - Reference for the callback function
 * @return None.
 */
void USB_SOFCallbackRegister(USB_EVENT_CALLBACK_t callback);

/**
 * @ingroup usb_core
 * @brief Registers a callback for Reset events.
 * @param callback - Reference for the callback function
 * @return None.
 */
void USB_ResetCallbackRegister(USB_EVENT_CALLBACK_t callback);

/**
 * @ingroup usb_core
 * @brief Registers a callback for Suspend events.
 * @param callback - Reference for the callback function
 * @return None.
 */
void USB_SuspendCallbackRegister(USB_EVENT_CALLBACK_t callback);

/**
 * @ingroup usb_core
 * @brief Registers a callback for Resume events.
 * @param callback - Reference for the callback function
 * @return None.
 */
void USB_ResumeCallbackRegister(USB_EVENT_CALLBACK_t callback);

#endif /* USB_CORE_EVENTS_H */