Skip to content

Commit

Permalink
-- updating files to v2.18 MLA update --
Browse files Browse the repository at this point in the history
• 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
  • Loading branch information
davidflowers committed Nov 29, 2018
1 parent 31d333c commit d28cc13
Show file tree
Hide file tree
Showing 14 changed files with 117 additions and 97 deletions.
Binary file removed doc/help_mla_usb.jar
Binary file not shown.
Binary file modified doc/help_mla_usb.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion inc/usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ please contact mla_licensing@microchip.com
specific version of the library is being used.
*/
#define USB_MAJOR_VER 2 // Firmware version, major release number.
#define USB_MINOR_VER 13 // Firmware version, minor release number.
#define USB_MINOR_VER 18 // Firmware version, minor release number.
#define USB_DOT_VER 0 // Firmware version, dot release number.

#endif // _USB_H_
Expand Down
40 changes: 21 additions & 19 deletions inc/usb_ch9.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ please contact mla_licensing@microchip.com
#include <stdint.h>

#if defined(__XC8)
#define __attribute__(a)
#define PACKED
#else
#define PACKED __attribute__((packed))
#endif

// *****************************************************************************
Expand All @@ -66,7 +68,7 @@ please contact mla_licensing@microchip.com
This struct defines the structure of a USB Device Descriptor.
*/
typedef struct __attribute__ ((packed)) _USB_DEVICE_DESCRIPTOR
typedef struct PACKED _USB_DEVICE_DESCRIPTOR
{
uint8_t bLength; // Length of this descriptor.
uint8_t bDescriptorType; // DEVICE descriptor type (USB_DESCRIPTOR_DEVICE).
Expand All @@ -90,7 +92,7 @@ typedef struct __attribute__ ((packed)) _USB_DEVICE_DESCRIPTOR
This struct defines the structure of a USB Configuration Descriptor.
*/
typedef struct __attribute__ ((packed)) _USB_CONFIGURATION_DESCRIPTOR
typedef struct PACKED _USB_CONFIGURATION_DESCRIPTOR
{
uint8_t bLength; // Length of this descriptor.
uint8_t bDescriptorType; // CONFIGURATION descriptor type (USB_DESCRIPTOR_CONFIGURATION).
Expand All @@ -113,7 +115,7 @@ typedef struct __attribute__ ((packed)) _USB_CONFIGURATION_DESCRIPTOR
This struct defines the structure of a USB Interface Descriptor.
*/
typedef struct __attribute__ ((packed)) _USB_INTERFACE_DESCRIPTOR
typedef struct PACKED _USB_INTERFACE_DESCRIPTOR
{
uint8_t bLength; // Length of this descriptor.
uint8_t bDescriptorType; // INTERFACE descriptor type (USB_DESCRIPTOR_INTERFACE).
Expand All @@ -132,7 +134,7 @@ typedef struct __attribute__ ((packed)) _USB_INTERFACE_DESCRIPTOR
This struct defines the structure of a USB Endpoint Descriptor.
*/
typedef struct __attribute__ ((packed)) _USB_ENDPOINT_DESCRIPTOR
typedef struct PACKED _USB_ENDPOINT_DESCRIPTOR
{
uint8_t bLength; // Length of this descriptor.
uint8_t bDescriptorType; // ENDPOINT descriptor type (USB_DESCRIPTOR_ENDPOINT).
Expand Down Expand Up @@ -197,7 +199,7 @@ This struct defines the structure of a USB OTG Descriptor. Note that this
structure may need to be packed, or even accessed as uint8_ts, to properly access
the correct fields when used on some device architectures.
*/
typedef struct __attribute__ ((packed)) _USB_OTG_DESCRIPTOR
typedef struct PACKED _USB_OTG_DESCRIPTOR
{
uint8_t bLength; // Length of this descriptor.
uint8_t bDescriptorType; // OTG descriptor type (USB_DESCRIPTOR_OTG).
Expand All @@ -221,7 +223,7 @@ typedef struct __attribute__ ((packed)) _USB_OTG_DESCRIPTOR
// array of unicode characters making up the string, must be allocated
// immediately following this header with no padding between them.

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

typedef struct __attribute__ ((packed)) _USB_DEVICE_QUALIFIER_DESCRIPTOR
typedef struct PACKED _USB_DEVICE_QUALIFIER_DESCRIPTOR
{
uint8_t bLength; // Size of this descriptor
uint8_t bType; // Type, always USB_DESCRIPTOR_DEVICE_QUALIFIER
Expand All @@ -263,18 +265,18 @@ typedef struct __attribute__ ((packed)) _USB_DEVICE_QUALIFIER_DESCRIPTOR
//
// Note: Refer to the USB 2.0 specification for additional details on the
// usage of the setup packet and standard device requests.
typedef union __attribute__ ((packed))
typedef union PACKED
{
/** Standard Device Requests ***********************************/
struct __attribute__ ((packed))
struct PACKED
{
uint8_t bmRequestType; //from table 9-2 of USB2.0 spec
uint8_t bRequest; //from table 9-2 of USB2.0 spec
uint16_t wValue; //from table 9-2 of USB2.0 spec
uint16_t wIndex; //from table 9-2 of USB2.0 spec
uint16_t wLength; //from table 9-2 of USB2.0 spec
};
struct __attribute__ ((packed))
struct PACKED
{
unsigned :8;
unsigned :8;
Expand Down Expand Up @@ -311,7 +313,7 @@ typedef union __attribute__ ((packed))
} byte;
} W_Length;
};
struct __attribute__ ((packed))
struct PACKED
{
unsigned Recipient:5; //Device,Interface,Endpoint,Other
unsigned RequestType:2; //Standard,Class,Vendor,Reserved
Expand All @@ -324,7 +326,7 @@ typedef union __attribute__ ((packed))
unsigned :8;
unsigned :8;
};
struct __attribute__ ((packed))
struct PACKED
{
union // offset description
{ // ------ ------------------------
Expand All @@ -337,7 +339,7 @@ typedef union __attribute__ ((packed))
};
}requestInfo;
};
struct __attribute__ ((packed))
struct PACKED
{
unsigned :8;
unsigned :8;
Expand All @@ -347,7 +349,7 @@ typedef union __attribute__ ((packed))
unsigned :8;
unsigned :8;
};
struct __attribute__ ((packed))
struct PACKED
{
unsigned :8;
unsigned :8;
Expand All @@ -358,7 +360,7 @@ typedef union __attribute__ ((packed))
unsigned :8;
unsigned :8;
};
struct __attribute__ ((packed))
struct PACKED
{
unsigned :8;
unsigned :8;
Expand All @@ -369,7 +371,7 @@ typedef union __attribute__ ((packed))
unsigned :8;
unsigned :8;
};
struct __attribute__ ((packed))
struct PACKED
{
unsigned :8;
unsigned :8;
Expand All @@ -380,7 +382,7 @@ typedef union __attribute__ ((packed))
unsigned :8;
unsigned :8;
};
struct __attribute__ ((packed))
struct PACKED
{
unsigned :8;
unsigned :8;
Expand All @@ -391,7 +393,7 @@ typedef union __attribute__ ((packed))
unsigned :8;
unsigned :8;
};
struct __attribute__ ((packed))
struct PACKED
{
unsigned :8;
unsigned :8;
Expand Down
26 changes: 15 additions & 11 deletions inc/usb_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ please contact mla_licensing@microchip.com
#include "usb_config.h"

#if defined(__XC8)
#define __attribute__(a)
#define PACKED
#define ALIGNED
#else
#define PACKED __attribute__((packed))
#define ALIGNED __attribute__((aligned))
#endif

/** DEFINITIONS ****************************************************/
Expand Down Expand Up @@ -1987,9 +1991,9 @@ typedef union
// Definition of the PIPE structure
// This structure is used to keep track of data that is sent out
// of the stack automatically.
typedef struct __attribute__ ((packed))
typedef struct PACKED
{
union __attribute__ ((packed))
union PACKED
{
//Various options of pointers that are available to
// get the data from
Expand All @@ -1998,9 +2002,9 @@ typedef struct __attribute__ ((packed))
uint16_t *wRam;
const uint16_t *wRom;
}pSrc;
union __attribute__ ((packed))
union PACKED
{
struct __attribute__ ((packed))
struct PACKED
{
//is this transfer from RAM or const?
uint8_t ctrl_trf_mem :1;
Expand All @@ -2013,23 +2017,23 @@ typedef struct __attribute__ ((packed))
}bits;
uint8_t Val;
}info;
uint16_t_VAL __attribute__((aligned)) wCount;
uint16_t_VAL ALIGNED wCount;
}IN_PIPE;

extern USB_VOLATILE IN_PIPE inPipes[];

typedef struct __attribute__ ((packed))
typedef struct PACKED
{
union __attribute__ ((packed))
union PACKED
{
//Various options of pointers that are available to
// get the data from
uint8_t *bRam;
uint16_t *wRam;
}pDst;
union __attribute__ ((packed))
union PACKED
{
struct __attribute__ ((packed))
struct PACKED
{
uint8_t reserved :7;
//is this PIPE currently in use
Expand All @@ -2049,6 +2053,6 @@ extern USB_VOLATILE uint8_t USBTicksSinceSuspendEnd;
/******************************************************************************/
/* DOM-IGNORE-END */

#include <usb_hal.h>
#include "usb_hal.h"

#endif //USB_DEVICE_H
17 changes: 11 additions & 6 deletions inc/usb_device_cdc.h
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ void putsUSBUSART(char *data);
will be transferred to the host.
**************************************************************************/
void putrsUSBUSART(const const char *data);
void putrsUSBUSART(const char *data);

/************************************************************************
Function:
Expand Down Expand Up @@ -835,6 +835,11 @@ void CDCTxService(void);

/* Line Coding Structure */
#define LINE_CODING_LENGTH 0x07
#if defined(__XC8)
#define PACKED
#else
#define PACKED __attribute__((packed))
#endif

typedef union _LINE_CODING
{
Expand Down Expand Up @@ -865,7 +870,7 @@ typedef union _CONTROL_SIGNAL_BITMAP
/* Functional Descriptor Structure - See CDC Specification 1.1 for details */

/* Header Functional Descriptor */
typedef struct __attribute__((packed)) _USB_CDC_HEADER_FN_DSC
typedef struct PACKED _USB_CDC_HEADER_FN_DSC
{
uint8_t bFNLength;
uint8_t bDscType;
Expand All @@ -874,7 +879,7 @@ typedef struct __attribute__((packed)) _USB_CDC_HEADER_FN_DSC
} USB_CDC_HEADER_FN_DSC;

/* Abstract Control Management Functional Descriptor */
typedef struct __attribute__((packed)) _USB_CDC_ACM_FN_DSC
typedef struct PACKED _USB_CDC_ACM_FN_DSC
{
uint8_t bFNLength;
uint8_t bDscType;
Expand All @@ -883,7 +888,7 @@ typedef struct __attribute__((packed)) _USB_CDC_ACM_FN_DSC
} USB_CDC_ACM_FN_DSC;

/* Union Functional Descriptor */
typedef struct __attribute__((packed)) _USB_CDC_UNION_FN_DSC
typedef struct PACKED _USB_CDC_UNION_FN_DSC
{
uint8_t bFNLength;
uint8_t bDscType;
Expand All @@ -893,7 +898,7 @@ typedef struct __attribute__((packed)) _USB_CDC_UNION_FN_DSC
} USB_CDC_UNION_FN_DSC;

/* Call Management Functional Descriptor */
typedef struct __attribute__((packed)) _USB_CDC_CALL_MGT_FN_DSC
typedef struct PACKED _USB_CDC_CALL_MGT_FN_DSC
{
uint8_t bFNLength;
uint8_t bDscType;
Expand All @@ -902,7 +907,7 @@ typedef struct __attribute__((packed)) _USB_CDC_CALL_MGT_FN_DSC
uint8_t bDataInterface;
} USB_CDC_CALL_MGT_FN_DSC;

typedef union __attribute__((packed)) _CDC_NOTICE
typedef union PACKED _CDC_NOTICE
{
LINE_CODING GetLineCoding;
LINE_CODING SetLineCoding;
Expand Down
12 changes: 9 additions & 3 deletions inc/usb_device_msd.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ please contact mla_licensing@microchip.com
#include <stdint.h>
#include "fileio.h"

#if defined(__XC8)
#define PACKED
#else
#define PACKED __attribute__((packed))
#endif

/** D E F I N I T I O N S ****************************************************/

/* MSD Interface Class Code */
Expand Down Expand Up @@ -266,7 +272,7 @@ typedef union
typedef union
{
uint8_t v[2];
struct __attribute__((__packed__))
struct PACKED
{
uint8_t LB;
uint8_t HB;
Expand Down Expand Up @@ -415,12 +421,12 @@ typedef union
} USB_MSD_CMD_SPECIFIC_INFO;

/* Fixed format if Desc bit of request sense cbw is 0 */
typedef union __attribute__((packed)){
typedef union PACKED{
struct
{
uint8_t _byte[18];
};
struct __attribute__((packed)){
struct PACKED{
unsigned ResponseCode:7; // b6-b0 is Response Code Fixed or descriptor format
unsigned VALID:1; // Set to 1 to indicate information field is a valid value

Expand Down
10 changes: 10 additions & 0 deletions inc/usb_hal_pic16f1.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ please contact mla_licensing@microchip.com
#include <string.h>

#include "usb_config.h"
#include "fixed_address_memory.h"

#ifdef __cplusplus // Provide C++ Compatability
extern "C" {
Expand Down Expand Up @@ -183,7 +184,11 @@ please contact mla_licensing@microchip.com

//----- Definitions for BDT address --------------------------------------------
#define BDT_BASE_ADDR 0x2000
#if(__XC8_VERSION < 2000)
#define BDT_BASE_ADDR_TAG @ BDT_BASE_ADDR
#else
#define BDT_BASE_ADDR_TAG __at(BDT_BASE_ADDR)
#endif
#define BDT_ENTRY_SIZE 4

#if (USB_PING_PONG_MODE == USB_PING_PONG__NO_PING_PONG)
Expand All @@ -200,8 +205,13 @@ please contact mla_licensing@microchip.com
#define CTRL_TRF_SETUP_ADDR BDT_BASE_ADDR + (BDT_ENTRY_SIZE * BDT_NUM_ENTRIES)
#define CTRL_TRF_DATA_ADDR CTRL_TRF_SETUP_ADDR + USB_EP0_BUFF_SIZE

#if(__XC8_VERSION < 2000)
#define CTRL_TRF_SETUP_ADDR_TAG @ CTRL_TRF_SETUP_ADDR
#define CTRL_TRF_DATA_ADDR_TAG @ CTRL_TRF_DATA_ADDR
#else
#define CTRL_TRF_SETUP_ADDR_TAG __at(CTRL_TRF_SETUP_ADDR)
#define CTRL_TRF_DATA_ADDR_TAG __at(CTRL_TRF_DATA_ADDR)
#endif

//----- Deprecated definitions - will be removed at some point of time----------
//--------- Deprecated in v2.2
Expand Down
Loading

0 comments on commit d28cc13

Please sign in to comment.