Hello
I want to use the function "int read(unsigned char data[], REFERENCE_PARAM(unsigned, count));" to read some data over usb. I took the function from "interface usb_cdc_interface " in the xud_cdc.h from an00184.
I want to use it like this : cdc.read..... But unfortunately , i don´t know what parameters are expected in unsigned char data[]. Is it the array where the data that has been read must be stored, or is it something else? And what does reference_param mean.... ?
I will be grateful if someone could explain how this function works. In an00184 there are no explanations and i didn´t see any examples where this function is used like : cdc.read....
Thank you
Regards
cdc interface function read
-
- Member++
- Posts: 16
- Joined: Mon Jun 19, 2023 9:32 pm
-
Verified
- XCore Legend
- Posts: 1154
- Joined: Thu Dec 10, 2009 9:20 pm
- Location: Bristol, UK
The REFERENCE_PARAM() macro just assists with the different pass by reference syntax of XC and pointers in C.
from xcccompat.h:
in xc you can just can use the function something like
The number of bytes read will be stored in count.
from xcccompat.h:
Code: Select all
/**
* Macro that expands to a reference to the specified type when used in
* an XC source file and to a pointer to the specified type when used in
* a C/C++ source file.
*/
#ifdef __XC__
#define REFERENCE_PARAM(type, name) type &name
#else
#define REFERENCE_PARAM(type, name) type *name
#endif
in xc you can just can use the function something like
Code: Select all
unsigned char buffer[10]
unsigned count;
cdc.read(buffer, count);
Technical Director @ XMOS. Opinions expressed are my own