Skip to content

Commit d28cc13

Browse files
committed
-- updating files to v2.18 MLA update --
• Added support for XC8 v2.00 and later • Remove support for C18 • Fix typo when using PIC32MM0064GPM028 device • Add missing header files for printer host, generic host, and MIDI host • Update bytes transferred in HID host from uint8_t to uint16_t to allow for more than 255 bytes of transferred data • Move to use bit flag names for interrupts on PIC24F/dsPIC33 instead of register names so interrupt flag moving to different register is no longer an issue • Adding explicit casts to remove compiler warnings • Adding fixed memory address for SerialState information in CDC device driver for dual port RAM devices. Previously this would cause RAM corruption and invalid values as the USB module may not be able to access the variable based on where it linked • Fix issue where GetStatus(ENDPOINT = 0) would result in null pointer reference
1 parent 31d333c commit d28cc13

14 files changed

+117
-97
lines changed

doc/help_mla_usb.jar

-8.02 MB
Binary file not shown.

doc/help_mla_usb.pdf

7.18 KB
Binary file not shown.

inc/usb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ please contact [email protected]
6161
specific version of the library is being used.
6262
*/
6363
#define USB_MAJOR_VER 2 // Firmware version, major release number.
64-
#define USB_MINOR_VER 13 // Firmware version, minor release number.
64+
#define USB_MINOR_VER 18 // Firmware version, minor release number.
6565
#define USB_DOT_VER 0 // Firmware version, dot release number.
6666

6767
#endif // _USB_H_

inc/usb_ch9.h

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ please contact [email protected]
4242
#include <stdint.h>
4343

4444
#if defined(__XC8)
45-
#define __attribute__(a)
45+
#define PACKED
46+
#else
47+
#define PACKED __attribute__((packed))
4648
#endif
4749

4850
// *****************************************************************************
@@ -66,7 +68,7 @@ please contact [email protected]
6668
6769
This struct defines the structure of a USB Device Descriptor.
6870
*/
69-
typedef struct __attribute__ ((packed)) _USB_DEVICE_DESCRIPTOR
71+
typedef struct PACKED _USB_DEVICE_DESCRIPTOR
7072
{
7173
uint8_t bLength; // Length of this descriptor.
7274
uint8_t bDescriptorType; // DEVICE descriptor type (USB_DESCRIPTOR_DEVICE).
@@ -90,7 +92,7 @@ typedef struct __attribute__ ((packed)) _USB_DEVICE_DESCRIPTOR
9092
9193
This struct defines the structure of a USB Configuration Descriptor.
9294
*/
93-
typedef struct __attribute__ ((packed)) _USB_CONFIGURATION_DESCRIPTOR
95+
typedef struct PACKED _USB_CONFIGURATION_DESCRIPTOR
9496
{
9597
uint8_t bLength; // Length of this descriptor.
9698
uint8_t bDescriptorType; // CONFIGURATION descriptor type (USB_DESCRIPTOR_CONFIGURATION).
@@ -113,7 +115,7 @@ typedef struct __attribute__ ((packed)) _USB_CONFIGURATION_DESCRIPTOR
113115
114116
This struct defines the structure of a USB Interface Descriptor.
115117
*/
116-
typedef struct __attribute__ ((packed)) _USB_INTERFACE_DESCRIPTOR
118+
typedef struct PACKED _USB_INTERFACE_DESCRIPTOR
117119
{
118120
uint8_t bLength; // Length of this descriptor.
119121
uint8_t bDescriptorType; // INTERFACE descriptor type (USB_DESCRIPTOR_INTERFACE).
@@ -132,7 +134,7 @@ typedef struct __attribute__ ((packed)) _USB_INTERFACE_DESCRIPTOR
132134
133135
This struct defines the structure of a USB Endpoint Descriptor.
134136
*/
135-
typedef struct __attribute__ ((packed)) _USB_ENDPOINT_DESCRIPTOR
137+
typedef struct PACKED _USB_ENDPOINT_DESCRIPTOR
136138
{
137139
uint8_t bLength; // Length of this descriptor.
138140
uint8_t bDescriptorType; // ENDPOINT descriptor type (USB_DESCRIPTOR_ENDPOINT).
@@ -197,7 +199,7 @@ This struct defines the structure of a USB OTG Descriptor. Note that this
197199
structure may need to be packed, or even accessed as uint8_ts, to properly access
198200
the correct fields when used on some device architectures.
199201
*/
200-
typedef struct __attribute__ ((packed)) _USB_OTG_DESCRIPTOR
202+
typedef struct PACKED _USB_OTG_DESCRIPTOR
201203
{
202204
uint8_t bLength; // Length of this descriptor.
203205
uint8_t bDescriptorType; // OTG descriptor type (USB_DESCRIPTOR_OTG).
@@ -221,7 +223,7 @@ typedef struct __attribute__ ((packed)) _USB_OTG_DESCRIPTOR
221223
// array of unicode characters making up the string, must be allocated
222224
// immediately following this header with no padding between them.
223225

224-
typedef struct __attribute__ ((packed)) _USB_STRING_DSC
226+
typedef struct PACKED _USB_STRING_DSC
225227
{
226228
uint8_t bLength; // Size of this descriptor
227229
uint8_t bDescriptorType; // Type, USB_DSC_STRING
@@ -240,7 +242,7 @@ typedef struct __attribute__ ((packed)) _USB_STRING_DSC
240242
// If so, it may need to implement the the device qualifier and other
241243
// speed descriptors.
242244

243-
typedef struct __attribute__ ((packed)) _USB_DEVICE_QUALIFIER_DESCRIPTOR
245+
typedef struct PACKED _USB_DEVICE_QUALIFIER_DESCRIPTOR
244246
{
245247
uint8_t bLength; // Size of this descriptor
246248
uint8_t bType; // Type, always USB_DESCRIPTOR_DEVICE_QUALIFIER
@@ -263,18 +265,18 @@ typedef struct __attribute__ ((packed)) _USB_DEVICE_QUALIFIER_DESCRIPTOR
263265
//
264266
// Note: Refer to the USB 2.0 specification for additional details on the
265267
// usage of the setup packet and standard device requests.
266-
typedef union __attribute__ ((packed))
268+
typedef union PACKED
267269
{
268270
/** Standard Device Requests ***********************************/
269-
struct __attribute__ ((packed))
271+
struct PACKED
270272
{
271273
uint8_t bmRequestType; //from table 9-2 of USB2.0 spec
272274
uint8_t bRequest; //from table 9-2 of USB2.0 spec
273275
uint16_t wValue; //from table 9-2 of USB2.0 spec
274276
uint16_t wIndex; //from table 9-2 of USB2.0 spec
275277
uint16_t wLength; //from table 9-2 of USB2.0 spec
276278
};
277-
struct __attribute__ ((packed))
279+
struct PACKED
278280
{
279281
unsigned :8;
280282
unsigned :8;
@@ -311,7 +313,7 @@ typedef union __attribute__ ((packed))
311313
} byte;
312314
} W_Length;
313315
};
314-
struct __attribute__ ((packed))
316+
struct PACKED
315317
{
316318
unsigned Recipient:5; //Device,Interface,Endpoint,Other
317319
unsigned RequestType:2; //Standard,Class,Vendor,Reserved
@@ -324,7 +326,7 @@ typedef union __attribute__ ((packed))
324326
unsigned :8;
325327
unsigned :8;
326328
};
327-
struct __attribute__ ((packed))
329+
struct PACKED
328330
{
329331
union // offset description
330332
{ // ------ ------------------------
@@ -337,7 +339,7 @@ typedef union __attribute__ ((packed))
337339
};
338340
}requestInfo;
339341
};
340-
struct __attribute__ ((packed))
342+
struct PACKED
341343
{
342344
unsigned :8;
343345
unsigned :8;
@@ -347,7 +349,7 @@ typedef union __attribute__ ((packed))
347349
unsigned :8;
348350
unsigned :8;
349351
};
350-
struct __attribute__ ((packed))
352+
struct PACKED
351353
{
352354
unsigned :8;
353355
unsigned :8;
@@ -358,7 +360,7 @@ typedef union __attribute__ ((packed))
358360
unsigned :8;
359361
unsigned :8;
360362
};
361-
struct __attribute__ ((packed))
363+
struct PACKED
362364
{
363365
unsigned :8;
364366
unsigned :8;
@@ -369,7 +371,7 @@ typedef union __attribute__ ((packed))
369371
unsigned :8;
370372
unsigned :8;
371373
};
372-
struct __attribute__ ((packed))
374+
struct PACKED
373375
{
374376
unsigned :8;
375377
unsigned :8;
@@ -380,7 +382,7 @@ typedef union __attribute__ ((packed))
380382
unsigned :8;
381383
unsigned :8;
382384
};
383-
struct __attribute__ ((packed))
385+
struct PACKED
384386
{
385387
unsigned :8;
386388
unsigned :8;
@@ -391,7 +393,7 @@ typedef union __attribute__ ((packed))
391393
unsigned :8;
392394
unsigned :8;
393395
};
394-
struct __attribute__ ((packed))
396+
struct PACKED
395397
{
396398
unsigned :8;
397399
unsigned :8;

inc/usb_device.h

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ please contact [email protected]
4444
#include "usb_config.h"
4545

4646
#if defined(__XC8)
47-
#define __attribute__(a)
47+
#define PACKED
48+
#define ALIGNED
49+
#else
50+
#define PACKED __attribute__((packed))
51+
#define ALIGNED __attribute__((aligned))
4852
#endif
4953

5054
/** DEFINITIONS ****************************************************/
@@ -1987,9 +1991,9 @@ typedef union
19871991
// Definition of the PIPE structure
19881992
// This structure is used to keep track of data that is sent out
19891993
// of the stack automatically.
1990-
typedef struct __attribute__ ((packed))
1994+
typedef struct PACKED
19911995
{
1992-
union __attribute__ ((packed))
1996+
union PACKED
19931997
{
19941998
//Various options of pointers that are available to
19951999
// get the data from
@@ -1998,9 +2002,9 @@ typedef struct __attribute__ ((packed))
19982002
uint16_t *wRam;
19992003
const uint16_t *wRom;
20002004
}pSrc;
2001-
union __attribute__ ((packed))
2005+
union PACKED
20022006
{
2003-
struct __attribute__ ((packed))
2007+
struct PACKED
20042008
{
20052009
//is this transfer from RAM or const?
20062010
uint8_t ctrl_trf_mem :1;
@@ -2013,23 +2017,23 @@ typedef struct __attribute__ ((packed))
20132017
}bits;
20142018
uint8_t Val;
20152019
}info;
2016-
uint16_t_VAL __attribute__((aligned)) wCount;
2020+
uint16_t_VAL ALIGNED wCount;
20172021
}IN_PIPE;
20182022

20192023
extern USB_VOLATILE IN_PIPE inPipes[];
20202024

2021-
typedef struct __attribute__ ((packed))
2025+
typedef struct PACKED
20222026
{
2023-
union __attribute__ ((packed))
2027+
union PACKED
20242028
{
20252029
//Various options of pointers that are available to
20262030
// get the data from
20272031
uint8_t *bRam;
20282032
uint16_t *wRam;
20292033
}pDst;
2030-
union __attribute__ ((packed))
2034+
union PACKED
20312035
{
2032-
struct __attribute__ ((packed))
2036+
struct PACKED
20332037
{
20342038
uint8_t reserved :7;
20352039
//is this PIPE currently in use
@@ -2049,6 +2053,6 @@ extern USB_VOLATILE uint8_t USBTicksSinceSuspendEnd;
20492053
/******************************************************************************/
20502054
/* DOM-IGNORE-END */
20512055

2052-
#include <usb_hal.h>
2056+
#include "usb_hal.h"
20532057

20542058
#endif //USB_DEVICE_H

inc/usb_device_cdc.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ void putsUSBUSART(char *data);
776776
will be transferred to the host.
777777
778778
**************************************************************************/
779-
void putrsUSBUSART(const const char *data);
779+
void putrsUSBUSART(const char *data);
780780

781781
/************************************************************************
782782
Function:
@@ -835,6 +835,11 @@ void CDCTxService(void);
835835

836836
/* Line Coding Structure */
837837
#define LINE_CODING_LENGTH 0x07
838+
#if defined(__XC8)
839+
#define PACKED
840+
#else
841+
#define PACKED __attribute__((packed))
842+
#endif
838843

839844
typedef union _LINE_CODING
840845
{
@@ -865,7 +870,7 @@ typedef union _CONTROL_SIGNAL_BITMAP
865870
/* Functional Descriptor Structure - See CDC Specification 1.1 for details */
866871

867872
/* Header Functional Descriptor */
868-
typedef struct __attribute__((packed)) _USB_CDC_HEADER_FN_DSC
873+
typedef struct PACKED _USB_CDC_HEADER_FN_DSC
869874
{
870875
uint8_t bFNLength;
871876
uint8_t bDscType;
@@ -874,7 +879,7 @@ typedef struct __attribute__((packed)) _USB_CDC_HEADER_FN_DSC
874879
} USB_CDC_HEADER_FN_DSC;
875880

876881
/* Abstract Control Management Functional Descriptor */
877-
typedef struct __attribute__((packed)) _USB_CDC_ACM_FN_DSC
882+
typedef struct PACKED _USB_CDC_ACM_FN_DSC
878883
{
879884
uint8_t bFNLength;
880885
uint8_t bDscType;
@@ -883,7 +888,7 @@ typedef struct __attribute__((packed)) _USB_CDC_ACM_FN_DSC
883888
} USB_CDC_ACM_FN_DSC;
884889

885890
/* Union Functional Descriptor */
886-
typedef struct __attribute__((packed)) _USB_CDC_UNION_FN_DSC
891+
typedef struct PACKED _USB_CDC_UNION_FN_DSC
887892
{
888893
uint8_t bFNLength;
889894
uint8_t bDscType;
@@ -893,7 +898,7 @@ typedef struct __attribute__((packed)) _USB_CDC_UNION_FN_DSC
893898
} USB_CDC_UNION_FN_DSC;
894899

895900
/* Call Management Functional Descriptor */
896-
typedef struct __attribute__((packed)) _USB_CDC_CALL_MGT_FN_DSC
901+
typedef struct PACKED _USB_CDC_CALL_MGT_FN_DSC
897902
{
898903
uint8_t bFNLength;
899904
uint8_t bDscType;
@@ -902,7 +907,7 @@ typedef struct __attribute__((packed)) _USB_CDC_CALL_MGT_FN_DSC
902907
uint8_t bDataInterface;
903908
} USB_CDC_CALL_MGT_FN_DSC;
904909

905-
typedef union __attribute__((packed)) _CDC_NOTICE
910+
typedef union PACKED _CDC_NOTICE
906911
{
907912
LINE_CODING GetLineCoding;
908913
LINE_CODING SetLineCoding;

inc/usb_device_msd.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ please contact [email protected]
2626
#include <stdint.h>
2727
#include "fileio.h"
2828

29+
#if defined(__XC8)
30+
#define PACKED
31+
#else
32+
#define PACKED __attribute__((packed))
33+
#endif
34+
2935
/** D E F I N I T I O N S ****************************************************/
3036

3137
/* MSD Interface Class Code */
@@ -266,7 +272,7 @@ typedef union
266272
typedef union
267273
{
268274
uint8_t v[2];
269-
struct __attribute__((__packed__))
275+
struct PACKED
270276
{
271277
uint8_t LB;
272278
uint8_t HB;
@@ -415,12 +421,12 @@ typedef union
415421
} USB_MSD_CMD_SPECIFIC_INFO;
416422

417423
/* Fixed format if Desc bit of request sense cbw is 0 */
418-
typedef union __attribute__((packed)){
424+
typedef union PACKED{
419425
struct
420426
{
421427
uint8_t _byte[18];
422428
};
423-
struct __attribute__((packed)){
429+
struct PACKED{
424430
unsigned ResponseCode:7; // b6-b0 is Response Code Fixed or descriptor format
425431
unsigned VALID:1; // Set to 1 to indicate information field is a valid value
426432

inc/usb_hal_pic16f1.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ please contact [email protected]
3333
#include <string.h>
3434

3535
#include "usb_config.h"
36+
#include "fixed_address_memory.h"
3637

3738
#ifdef __cplusplus // Provide C++ Compatability
3839
extern "C" {
@@ -183,7 +184,11 @@ please contact [email protected]
183184

184185
//----- Definitions for BDT address --------------------------------------------
185186
#define BDT_BASE_ADDR 0x2000
187+
#if(__XC8_VERSION < 2000)
186188
#define BDT_BASE_ADDR_TAG @ BDT_BASE_ADDR
189+
#else
190+
#define BDT_BASE_ADDR_TAG __at(BDT_BASE_ADDR)
191+
#endif
187192
#define BDT_ENTRY_SIZE 4
188193

189194
#if (USB_PING_PONG_MODE == USB_PING_PONG__NO_PING_PONG)
@@ -200,8 +205,13 @@ please contact [email protected]
200205
#define CTRL_TRF_SETUP_ADDR BDT_BASE_ADDR + (BDT_ENTRY_SIZE * BDT_NUM_ENTRIES)
201206
#define CTRL_TRF_DATA_ADDR CTRL_TRF_SETUP_ADDR + USB_EP0_BUFF_SIZE
202207

208+
#if(__XC8_VERSION < 2000)
203209
#define CTRL_TRF_SETUP_ADDR_TAG @ CTRL_TRF_SETUP_ADDR
204210
#define CTRL_TRF_DATA_ADDR_TAG @ CTRL_TRF_DATA_ADDR
211+
#else
212+
#define CTRL_TRF_SETUP_ADDR_TAG __at(CTRL_TRF_SETUP_ADDR)
213+
#define CTRL_TRF_DATA_ADDR_TAG __at(CTRL_TRF_DATA_ADDR)
214+
#endif
205215

206216
//----- Deprecated definitions - will be removed at some point of time----------
207217
//--------- Deprecated in v2.2

0 commit comments

Comments
 (0)