Netcruzer Library API  V2.03
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Groups Pages
nz_serUSB.h
Go to the documentation of this file.
1 
64 #ifndef NZ_USB_BUFFERED_H
65 #define NZ_USB_BUFFERED_H
66 
67 //"Serial Data Port" contain circular buffers, this include is required
68 #include "nz_circularBuffer.h"
69 
70 #if defined(HAS_SERPORT_USB)
71 
72 #if !defined(SERPORT_USB_CREATE_OWN_CIRBUFS)
73 #include "nz_serDataPorts.h"
74 #endif
75 
77 
78 #if !defined(USB_CONTROLS_SYSLED)
79 #define USB_CONTROLS_SYSLED 0
80 #endif
81 
88 #if !defined(USB_TXBUF_SIZE)
89 #define USB_TXBUF_SIZE 256
90 #endif
91 
99 #if !defined(USB_RXBUF_SIZE)
100 #define USB_RXBUF_SIZE 32
101 #endif
102 
103 //TX and RX "Circular Buffers". Use SERPORT_USB_CREATE_OWN_CIRBUFS define to use this
104 //module without SERPORTs. If NOT defined, this modules requires nz_serDataPorts.c
105 #if defined(SERPORT_USB_CREATE_OWN_CIRBUFS)
106  //This is used by others
107  #ifndef THIS_IS_NZ_SER_USB_C
108  #if !defined(CIRBUF_TX_USB)
109  extern CIRBUF cbufTxUsb;
110  #define CIRBUF_TX_USB (&cbufTxUsb)
111  #endif
112 
113  #if !defined(CIRBUF_RX_USB)
114  extern CIRBUF cbufRxUsb;
115  #define CIRBUF_RX_USB (&cbufRxUsb)
116  #endif
117  #endif //#ifndef THIS_IS_NZ_SER_USB_C
118 #endif
119 
120 
122 //Defines
123 
124 //USB "Serial Data Port"
125 #if defined(NZ_USBHID_ENABLE) && !defined(HAS_SERPORT_USB_HID)
126  #define HAS_SERPORT_USB_HID
127 #endif
128 #if defined(NZ_USBCDC_ENABLE) && !defined(HAS_SERPORT_USB_CDC)
129  #define HAS_SERPORT_USB_CDC
130 #endif
131 #if defined(NZ_USBMIDI_ENABLE) && !defined(HAS_SERPORT_USB_MIDI)
132  #define HAS_SERPORT_USB_MIDI
133 #endif
134 #if defined(HAS_SERPORT_USB_HID) || defined(HAS_SERPORT_USB_CDC) || defined(HAS_SERPORT_USB_MIDI)
135  #if !defined(HAS_A_SERPORT)
136  #define HAS_A_SERPORT
137  #endif
138 #endif
139 
140 
142 
143 //If "Power of 2" buffer used, size must by a power of 2
144 #if defined(CIRBUF_USE_CIRCULAR_BUFFER_PWR2)
145 #if defined(HAS_SERPORT_USB)
146  //Ensure size is power of 2
147  #if ((USB_TXBUF_SIZE & ~(USB_TXBUF_SIZE-1))!=USB_TXBUF_SIZE)
148  #error "USB USB_TXBUF_SIZE is not power of 2! Either change size defined in projdefs.h --OR-- use nz_circularBufferStd.c in stead of nz_circularBufferPwr2.c for project!"
149  #endif
150 
151  //Ensure size is power of 2
152  #if ((USB_RXBUF_SIZE & ~(USB_RXBUF_SIZE-1))!=USB_RXBUF_SIZE)
153  #error "USB USB_RXBUF_SIZE is not power of 2! Either change size defined in projdefs.h --OR-- use nz_circularBufferStd.c in stead of nz_circularBufferPwr2.c for project!"
154  #endif
155 #endif
156 #endif
157 
158 
165 void serUSBTask(void);
166 
167 
171 void serUSBInit(void);
172 
173 
174 void usbCBSendResume(void);
175 
176 
177 /*
178 #define serUSBEmptyTxBuf() cbufEmpty(&cbufTxUsb)
179 #define serUSBIsTxBufEmpty() cbufIsEmpty(&cbufTxUsb)
180 #define serUSBIsTxBufFull() cbufIsFull(&cbufTxUsb)
181 #define serUSBGetTxBufCount() cbufGetCount(&cbufTxUsb)
182 #define serUSBGetTxBufFree() cbufGetFree(&cbufTxUsb)
183 #define serUSBPeekTxBuf() cbufPeekByte(&cbufTxUsb)
184 #define serUSBPeekTxBufAt(offset) cbufPeekByteAt(&cbufTxUsb, offset)
185 #define serUSBTxBufRemoveByte() cbufRemoveByte(&cbufTxUsb)
186 #define serUSBTxBufRemoveBytes(n) cbufRemoveBytes(&cbufTxUsb, n)
187 */
188 
189 
197 BOOL serUSBIsSuspended(void);
198 
199 
203 #define serUSBEmptyTxBuf() cbufEmpty(&serports.usb.cbufTx)
204 
205 
211 #define serUSBIsTxBufEmpty() cbufIsEmpty(&serports.usb.cbufTx)
212 
213 
220 #define serUSBIsTxBufFull() cbufIsFull(&serports.usb.cbufTx)
221 
222 #endif //#if defined(HAS_SERPORT_USB)
223 
224 #endif //#ifndef NZ_USB_BUFFERED_H