Skip to content

Commit 076e91b

Browse files
committed
updated for the v2.13 release
1 parent b45c2cb commit 076e91b

17 files changed

+1063
-1240
lines changed

doc/help_mla_usb.jar

-73.7 KB
Binary file not shown.

doc/help_mla_usb.pdf

-83.9 KB
Binary file not shown.

inc/usb_common.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ please contact [email protected]
3838
not defined by the USB specification.
3939
*******************************************************************************/
4040

41+
//DOM-IGNORE-BEGIN
4142
#ifndef _USB_COMMON_H_
4243
#define _USB_COMMON_H_
44+
//DOM-IGNORE-END
4345

4446
#include <limits.h>
4547
#include <stdbool.h>
@@ -322,6 +324,19 @@ typedef enum
322324
// per call to these functions.
323325
EVENT_1MS,
324326

327+
// In device mode, this event is thrown when we receive a Set Interface request from
328+
// the host. The stack will automatically handle the interface switch, but the app
329+
// may need to know about the interface switch for performing tasks such as powering
330+
// up/down audio hardware.
331+
EVENT_ALT_INTERFACE,
332+
333+
// If the application layer must do things to the device before the device is
334+
// configured, they should be done at this point. The application layer should
335+
// return true to hold the USB state machine at this point, while any USB or other
336+
// processing continues. When the USB state machine can safely proceed, the application
337+
// layer should return FALSE.
338+
EVENT_HOLD_BEFORE_CONFIGURATION,
339+
325340
// Class-defined event offsets start here:
326341
EVENT_GENERIC_BASE = 400, // Offset for Generic class events
327342

@@ -350,7 +365,7 @@ typedef enum
350365
// *****************************************************************************
351366
/* EVENT_TRANSFER Data
352367
353-
This data structure is passed to the appropriate layer
368+
This data structure is passed to the appropriate layer's
354369
USB_EVENT_HANDLER when an EVT_XFER event has occurred, indicating
355370
that a transfer has completed on the USB. It provides the endpoint,
356371
direction, and actual size of the transfer.
@@ -368,7 +383,7 @@ typedef struct _transfer_event_data
368383
// *****************************************************************************
369384
/* EVENT_VBUS_REQUEST_POWER and EVENT_VBUS_RELEASE_POWER Data
370385
371-
This data structure is passed to the appropriate layer
386+
This data structure is passed to the appropriate layer's
372387
USB_EVENT_HANDLER when an EVENT_VBUS_REQUEST_POWER or EVENT_VBUS_RELEASE_POWER
373388
event has occurred, indicating that a change in Vbus power is being requested.
374389
*/

inc/usb_device.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1362,7 +1362,11 @@ void USBSoftDetach(void);
13621362
*************************************************************************/
13631363
bool USBHandleBusy(USB_HANDLE handle);
13641364
/*DOM-IGNORE-BEGIN*/
1365-
#define USBHandleBusy(handle) (handle==0?0:((volatile BDT_ENTRY*)handle)->STAT.UOWN)
1365+
#if defined(__XC8__)
1366+
#define USBHandleBusy(handle) ((handle != 0x0000) && ((*(volatile uint8_t*)handle & _USIE) != 0x00))
1367+
#else
1368+
#define USBHandleBusy(handle) (handle==0?0:((volatile BDT_ENTRY*)handle)->STAT.UOWN)
1369+
#endif
13661370
/*DOM-IGNORE-END*/
13671371

13681372
/********************************************************************

inc/usb_hal_dspic33e.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ please contact [email protected]
3737
/****** Constant definitions *************************************************/
3838
/*****************************************************************************/
3939
#define DEVICE_SPECIFIC_IEC_REGISTER_COUNT 9 //Number of IECx registers implemented in the microcontroller (varies from device to device, make sure this is set correctly for the intended CPU)
40-
40+
#define USB_HAL_VBUSTristate() //No GPIO driver on VBUS on these devices.
4141

4242
#if(USB_PING_PONG_MODE != USB_PING_PONG__FULL_PING_PONG)
4343
#error "Unsupported ping pong mode for this device"

inc/usb_hal_pic16f1.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ please contact [email protected]
4242
// Section: Constants
4343
// *****************************************************************************
4444
// *****************************************************************************
45+
#define USB_HAL_VBUSTristate() //No dedicated VBUS pin on these devices.
4546

47+
4648
//----- USBEnableEndpoint() input definitions ----------------------------------
4749
#define USB_HANDSHAKE_ENABLED 0x10
4850
#define USB_HANDSHAKE_DISABLED 0x00

inc/usb_hal_pic18.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ please contact [email protected]
5959
// Section: Constants
6060
// *****************************************************************************
6161
// *****************************************************************************
62-
62+
#define USB_HAL_VBUSTristate() //No dedicated VBUS pin on these devices.
63+
6364
//----- USBEnableEndpoint() input definitions ----------------------------------
6465
#define USB_HANDSHAKE_ENABLED 0x10
6566
#define USB_HANDSHAKE_DISABLED 0x00

inc/usb_hal_pic24.h

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,38 @@ please contact [email protected]
4848
//IEC0-IEC7 on PIC24FJ128GB204 Family devices
4949
//IEC0-IEC7 on PIC24FJ256GB412 Family devices
5050
#if defined(__PIC24FJ64GB004__) || defined(__PIC24FJ32GB004__) || defined(__PIC24FJ32GB004__) || defined(__PIC24FJ32GB002__) \
51-
|| defined(__PIC24FJ256GB110__) || defined(__PIC24FJ192GB110__) || defined(__PIC24FJ128GB110__) || defined(__PIC24FJ64GB110__) || defined(__PIC24FJ256GB108__) || defined(__PIC24FJ192GB108__) || defined(__PIC24FJ128GB108__) || defined(__PIC24FJ64GB108__) || defined(__PIC24FJ256GB106__) || defined(__PIC24FJ192GB106__) || defined(__PIC24FJ128GB106__) || defined(__PIC24FJ64GB106__) \
52-
|| defined(__PIC24FJ256GB210__) || defined(__PIC24FJ128GB210__) || defined(__PIC24FJ256GB206__) || defined(__PIC24FJ128GB206__)
51+
|| defined(__PIC24FJ256GB110__) || defined(__PIC24FJ192GB110__) || defined(__PIC24FJ128GB110__) || defined(__PIC24FJ64GB110__) || defined(__PIC24FJ256GB108__) || defined(__PIC24FJ192GB108__) || defined(__PIC24FJ128GB108__) || defined(__PIC24FJ64GB108__) || defined(__PIC24FJ256GB106__) || defined(__PIC24FJ192GB106__) || defined(__PIC24FJ128GB106__) || defined(__PIC24FJ64GB106__)
5352

5453
#define DEVICE_SPECIFIC_IEC_REGISTER_COUNT 6 //Number of IECx registers implemented in the microcontroller (varies from device to device, make sure this is set correctly for the intended CPU)
54+
#define USB_HAL_VBUSTristate() //No GPIO driver on VBUS on these devices.
55+
56+
#elif defined(__PIC24FJ256GB210__) || defined(__PIC24FJ128GB210__) || defined(__PIC24FJ256GB206__) || defined(__PIC24FJ128GB206__)
57+
58+
#define DEVICE_SPECIFIC_IEC_REGISTER_COUNT 6 //Number of IECx registers implemented in the microcontroller (varies from device to device, make sure this is set correctly for the intended CPU)
59+
#define USB_HAL_VBUSTristate() {TRISFbits.TRISF7 = 1;}
5560

5661
#elif defined(__PIC24FJ256DA210__) || defined(__PIC24FJ128DA210__) || defined(__PIC24FJ256DA206__) || defined(__PIC24FJ128DA206__) || defined(__PIC24FJ256DA110__) || defined(__PIC24FJ128DA110__) || defined(__PIC24FJ256DA106__) || defined(__PIC24FJ128DA106__)
5762

5863
#define DEVICE_SPECIFIC_IEC_REGISTER_COUNT 7 //Number of IECx registers implemented in the microcontroller (varies from device to device, make sure this is set correctly for the intended CPU)
64+
#define USB_HAL_VBUSTristate() {TRISFbits.TRISF7 = 1;}
5965

60-
#elif defined(__PIC24FJ128GC010__) || defined(__PIC24FJ64GC010__) || defined(__PIC24FJ128GC006__) || defined(__PIC24FJ64GC006__) \
61-
|| defined(__PIC24FJ128GB204__) || defined(__PIC24FJ64GB204) || defined(__PIC24FJ128GB202__) || defined(__PIC24FJ64GB202)
66+
#elif defined(__PIC24FJ128GB204__) || defined(__PIC24FJ64GB204__) || defined(__PIC24FJ128GB202__) || defined(__PIC24FJ64GB202__)
6267

6368
#define DEVICE_SPECIFIC_IEC_REGISTER_COUNT 8 //Number of IECx registers implemented in the microcontroller (varies from device to device, make sure this is set correctly for the intended CPU)
69+
#define USB_HAL_VBUSTristate() {TRISBbits.TRISB6 = 1;}
6470

71+
#elif defined(__PIC24FJ128GC010__) || defined(__PIC24FJ64GC010__) || defined(__PIC24FJ128GC006__) || defined(__PIC24FJ64GC006__) \
72+
|| defined(__PIC24FJ128GB204__) || defined(__PIC24FJ64GB204__) || defined(__PIC24FJ128GB202__) || defined(__PIC24FJ64GB202__) \
73+
|| defined(__PIC24FJ256GB410__) || defined(__PIC24FJ256GB412__) || defined(__PIC24FJ256GB406__) \
74+
|| defined(__PIC24FJ128GB410__) || defined(__PIC24FJ128GB412__) || defined(__PIC24FJ128GB406__) \
75+
|| defined(__PIC24FJ64GB410__) || defined(__PIC24FJ64GB412__) || defined(__PIC24FJ64GB406__)
76+
#define DEVICE_SPECIFIC_IEC_REGISTER_COUNT 8 //Number of IECx registers implemented in the microcontroller (varies from device to device, make sure this is set correctly for the intended CPU)
77+
#define USB_HAL_VBUSTristate() {TRISFbits.TRISF7 = 1;}
6578
#else
6679
#error "Unknown processor type selected. Refer to device datasheet and update the definition for DEVICE_SPECIFIC_IEC_REGISTER_COUNT."
67-
//#define DEVICE_SPECIFIC_IEC_REGISTER_COUNT 8 // <--- Update this number with the real number for your device and uncomment (and delete the above #error).
80+
//#define DEVICE_SPECIFIC_IEC_REGISTER_COUNT 8 // <--- Update this number with the real number for your device and uncomment (and delete the above #error).
81+
//#define USB_HAL_VBUSTristate() {TRISxbits.TRISxx = 1;} // <-- replace the "x" characters with the correct values for the VBUS GPIO pin (if the microcontroller selected has GPIO functionality on VBUS)
82+
6883
#endif
6984

7085

inc/usb_hal_pic24e.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ please contact [email protected]
3636
/****** Constant definitions *************************************************/
3737
/*****************************************************************************/
3838
#define DEVICE_SPECIFIC_IEC_REGISTER_COUNT 9 //Number of IECx registers implemented in the microcontroller (varies from device to device, make sure this is set correctly for the intended CPU)
39-
39+
#define USB_HAL_VBUSTristate() //No GPIO driver on VBUS on these devices.
4040

4141
#if(USB_PING_PONG_MODE != USB_PING_PONG__FULL_PING_PONG)
4242
#error "Unsupported ping pong mode for this device"

inc/usb_hal_pic24f.h

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,38 @@ please contact [email protected]
4848
//IEC0-IEC7 on PIC24FJ128GB204 Family devices
4949
//IEC0-IEC7 on PIC24FJ256GB412 Family devices
5050
#if defined(__PIC24FJ64GB004__) || defined(__PIC24FJ32GB004__) || defined(__PIC24FJ32GB004__) || defined(__PIC24FJ32GB002__) \
51-
|| defined(__PIC24FJ256GB110__) || defined(__PIC24FJ192GB110__) || defined(__PIC24FJ128GB110__) || defined(__PIC24FJ64GB110__) || defined(__PIC24FJ256GB108__) || defined(__PIC24FJ192GB108__) || defined(__PIC24FJ128GB108__) || defined(__PIC24FJ64GB108__) || defined(__PIC24FJ256GB106__) || defined(__PIC24FJ192GB106__) || defined(__PIC24FJ128GB106__) || defined(__PIC24FJ64GB106__) \
52-
|| defined(__PIC24FJ256GB210__) || defined(__PIC24FJ128GB210__) || defined(__PIC24FJ256GB206__) || defined(__PIC24FJ128GB206__)
51+
|| defined(__PIC24FJ256GB110__) || defined(__PIC24FJ192GB110__) || defined(__PIC24FJ128GB110__) || defined(__PIC24FJ64GB110__) || defined(__PIC24FJ256GB108__) || defined(__PIC24FJ192GB108__) || defined(__PIC24FJ128GB108__) || defined(__PIC24FJ64GB108__) || defined(__PIC24FJ256GB106__) || defined(__PIC24FJ192GB106__) || defined(__PIC24FJ128GB106__) || defined(__PIC24FJ64GB106__)
5352

5453
#define DEVICE_SPECIFIC_IEC_REGISTER_COUNT 6 //Number of IECx registers implemented in the microcontroller (varies from device to device, make sure this is set correctly for the intended CPU)
54+
#define USB_HAL_VBUSTristate() //No GPIO driver on VBUS on these devices.
55+
56+
#elif defined(__PIC24FJ256GB210__) || defined(__PIC24FJ128GB210__) || defined(__PIC24FJ256GB206__) || defined(__PIC24FJ128GB206__)
57+
58+
#define DEVICE_SPECIFIC_IEC_REGISTER_COUNT 6 //Number of IECx registers implemented in the microcontroller (varies from device to device, make sure this is set correctly for the intended CPU)
59+
#define USB_HAL_VBUSTristate() {TRISFbits.TRISF7 = 1;}
5560

5661
#elif defined(__PIC24FJ256DA210__) || defined(__PIC24FJ128DA210__) || defined(__PIC24FJ256DA206__) || defined(__PIC24FJ128DA206__) || defined(__PIC24FJ256DA110__) || defined(__PIC24FJ128DA110__) || defined(__PIC24FJ256DA106__) || defined(__PIC24FJ128DA106__)
5762

5863
#define DEVICE_SPECIFIC_IEC_REGISTER_COUNT 7 //Number of IECx registers implemented in the microcontroller (varies from device to device, make sure this is set correctly for the intended CPU)
64+
#define USB_HAL_VBUSTristate() {TRISFbits.TRISF7 = 1;}
5965

60-
#elif defined(__PIC24FJ128GC010__) || defined(__PIC24FJ64GC010__) || defined(__PIC24FJ128GC006__) || defined(__PIC24FJ64GC006__) \
61-
|| defined(__PIC24FJ128GB204__) || defined(__PIC24FJ64GB204) || defined(__PIC24FJ128GB202__) || defined(__PIC24FJ64GB202)
66+
#elif defined(__PIC24FJ128GB204__) || defined(__PIC24FJ64GB204__) || defined(__PIC24FJ128GB202__) || defined(__PIC24FJ64GB202__)
6267

6368
#define DEVICE_SPECIFIC_IEC_REGISTER_COUNT 8 //Number of IECx registers implemented in the microcontroller (varies from device to device, make sure this is set correctly for the intended CPU)
69+
#define USB_HAL_VBUSTristate() {TRISBbits.TRISB6 = 1;}
6470

71+
#elif defined(__PIC24FJ128GC010__) || defined(__PIC24FJ64GC010__) || defined(__PIC24FJ128GC006__) || defined(__PIC24FJ64GC006__) \
72+
|| defined(__PIC24FJ128GB204__) || defined(__PIC24FJ64GB204__) || defined(__PIC24FJ128GB202__) || defined(__PIC24FJ64GB202__) \
73+
|| defined(__PIC24FJ256GB410__) || defined(__PIC24FJ256GB412__) || defined(__PIC24FJ256GB406__) \
74+
|| defined(__PIC24FJ128GB410__) || defined(__PIC24FJ128GB412__) || defined(__PIC24FJ128GB406__) \
75+
|| defined(__PIC24FJ64GB410__) || defined(__PIC24FJ64GB412__) || defined(__PIC24FJ64GB406__)
76+
#define DEVICE_SPECIFIC_IEC_REGISTER_COUNT 8 //Number of IECx registers implemented in the microcontroller (varies from device to device, make sure this is set correctly for the intended CPU)
77+
#define USB_HAL_VBUSTristate() {TRISFbits.TRISF7 = 1;}
6578
#else
6679
#error "Unknown processor type selected. Refer to device datasheet and update the definition for DEVICE_SPECIFIC_IEC_REGISTER_COUNT."
67-
//#define DEVICE_SPECIFIC_IEC_REGISTER_COUNT 8 // <--- Update this number with the real number for your device and uncomment (and delete the above #error).
80+
//#define DEVICE_SPECIFIC_IEC_REGISTER_COUNT 8 // <--- Update this number with the real number for your device and uncomment (and delete the above #error).
81+
//#define USB_HAL_VBUSTristate() {TRISxbits.TRISxx = 1;} // <-- replace the "x" characters with the correct values for the VBUS GPIO pin (if the microcontroller selected has GPIO functionality on VBUS)
82+
6883
#endif
6984

7085

@@ -83,7 +98,7 @@ please contact [email protected]
8398
#endif
8499

85100

86-
//----- USBEnableEndpoint() input defintions ----------------------------------
101+
//----- USBEnableEndpoint() input definitions ----------------------------------
87102
#define USB_HANDSHAKE_ENABLED 0x01
88103
#define USB_HANDSHAKE_DISABLED 0x00
89104

@@ -98,7 +113,7 @@ please contact [email protected]
98113

99114
#define USB_STALL_ENDPOINT 0x02
100115

101-
//----- usb_config.h input defintions -----------------------------------------
116+
//----- usb_config.h input definitions -----------------------------------------
102117
#define USB_PULLUP_ENABLE 0x00
103118
//#define USB_PULLUP_DISABLE 0x00
104119

@@ -166,7 +181,7 @@ please contact [email protected]
166181
#define USBRESUMEIFReg U1IR
167182
#define USBRESUMEIFBitNum 5
168183

169-
//----- Event call back defintions --------------------------------------------
184+
//----- Event call back definitions --------------------------------------------
170185
#if defined(USB_DISABLE_SOF_HANDLER)
171186
#define USB_SOF_INTERRUPT 0x00
172187
#else
@@ -620,12 +635,12 @@ bool USBRemoteWakeupAssertBlocking(void);
620635
that the read could not be performed (ex: if the comparators are currently off).
621636
622637
Specify true, if you want this function to perform a forceful read operation.
623-
In this case, this function will turn on the USB module and/or un-suspend it if
638+
In this case, this function will turn on the USB module and/or unsuspend it if
624639
needed, in order to read the actual value. The function will always return 0 or 1
625640
in this case. However, the function may block for as much time as required to
626641
ensure that any necessary analog startup/settling/propagation times have
627642
elapsed, so as to get an accurate reading. If invasive reads are allowed, and
628-
this function turns on the USB module or un-suspends it, the module will remain
643+
this function turns on the USB module or unsuspends it, the module will remain
629644
on and unsuspended subsequent to returning from this function.
630645
It is the caller's responsibility to turn the USB module off if
631646
desired/appropriate for the application (ex: because the returned value was

0 commit comments

Comments
 (0)