3 Copyright (C) Dean Camera, 2020.
5 dean [at] fourwalledcubicle [dot] com
10 Copyright 2020 Dean Camera (dean [at] fourwalledcubicle [dot] com)
12 Permission to use, copy, modify, distribute, and sell this
13 software and its documentation for any purpose is hereby granted
14 without fee, provided that the above copyright notice appear in
15 all copies and that both that the copyright notice and this
16 permission notice and warranty disclaimer appear in supporting
17 documentation, and that the name of the author not be used in
18 advertising or publicity pertaining to distribution of the
19 software without specific, written prior permission.
21 The author disclaims all warranties with regard to this
22 software, including all implied warranties of merchantability
23 and fitness. In no event shall the author be liable for any
24 special, indirect or consequential damages or any damages
25 whatsoever resulting from loss of use, data or profits, whether
26 in an action of contract, negligence or other tortious action,
27 arising out of or in connection with the use or performance of
31 #if defined(TEMPLATE_FUNC_NAME)
33 uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE
const Buffer
,
35 uint16_t* const BytesProcessed
)
37 uint8_t* DataStream
= ((uint8_t*)Buffer
+ TEMPLATE_BUFFER_OFFSET(Length
));
38 uint16_t BytesInTransfer
= 0;
41 if ((ErrorCode
= Endpoint_WaitUntilReady()))
44 if (BytesProcessed
!= NULL
)
46 Length
-= *BytesProcessed
;
47 TEMPLATE_BUFFER_MOVE(DataStream
, *BytesProcessed
);
52 if (!(Endpoint_IsReadWriteAllowed()))
54 TEMPLATE_CLEAR_ENDPOINT();
56 #if !defined(INTERRUPT_CONTROL_ENDPOINT)
60 if (BytesProcessed
!= NULL
)
62 *BytesProcessed
+= BytesInTransfer
;
63 return ENDPOINT_RWSTREAM_IncompleteTransfer
;
66 if ((ErrorCode
= Endpoint_WaitUntilReady()))
71 TEMPLATE_TRANSFER_BYTE(DataStream
);
72 TEMPLATE_BUFFER_MOVE(DataStream
, 1);
78 return ENDPOINT_RWSTREAM_NoError
;
81 #undef TEMPLATE_FUNC_NAME
82 #undef TEMPLATE_BUFFER_TYPE
83 #undef TEMPLATE_TRANSFER_BYTE
84 #undef TEMPLATE_CLEAR_ENDPOINT
85 #undef TEMPLATE_BUFFER_OFFSET
86 #undef TEMPLATE_BUFFER_MOVE