Skip to content

Commit 62fe6a5

Browse files
committed
Merging in changes from 2016-04-27 release:
* Removed requirement to implement system_config.h for USB. Stack now only uses usb_config.h for configuration. * USBInitialize() and USBTasks() removed. Use USBDeviceTasks()/USBHostTasks() or USBHostInit()/USBDeviceInit() as required. * Fixed dereferencing type-punned pointer will break strict-aliasing warning on full optimization. * Added MSDTransferTerminated() function. * Added error checking for NULL data handler * Added return for case in USBHostDeviceStatus() for when the device state variable was invalid value. * Fixed error when parsing HID descriptors resulting in invalid errors reported on well formed HID report descriptors. * Added support for the PIC24FJ1024GB610 family devices.
1 parent b7d7045 commit 62fe6a5

23 files changed

+208
-228
lines changed

doc/help_mla_usb.jar

400 KB
Binary file not shown.

doc/help_mla_usb.pdf

417 KB
Binary file not shown.

inc/usb.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ please contact [email protected]
4242
#ifndef _USB_H_
4343
#define _USB_H_
4444

45-
#include "system.h"
46-
#include "system_config.h" // Must be defined by the application
45+
#include "usb_config.h"
4746

4847
#include "usb_common.h" // Common USB library definitions
4948
#include "usb_ch9.h" // USB device framework definitions

inc/usb_common.h

Lines changed: 0 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ please contact [email protected]
4747
#include <stdbool.h>
4848
#include <stdint.h>
4949

50-
#include "system.h"
51-
#include "system_config.h"
52-
5350
// *****************************************************************************
5451
// *****************************************************************************
5552
// Section: USB Constants
@@ -465,108 +462,6 @@ stalled (ie. bit 0 = EP0, bit 1 = EP1, etc.)
465462

466463
typedef bool (*USB_EVENT_HANDLER) ( USB_EVENT event, void *data, unsigned int size );
467464

468-
469-
// *****************************************************************************
470-
// *****************************************************************************
471-
// Section: USB Application Program Interface (API) Routines
472-
// *****************************************************************************
473-
// *****************************************************************************
474-
475-
/****************************************************************************
476-
Function:
477-
bool USBInitialize ( unsigned long flags )
478-
479-
Summary:
480-
This interface initializes the variables of the USB host stack.
481-
482-
Description:
483-
This interface initializes the USB stack.
484-
485-
Precondition:
486-
None
487-
488-
Parameters:
489-
flags - reserved
490-
491-
Return Values:
492-
true - Initialization successful
493-
false - Initialization failure
494-
495-
Remarks:
496-
This interface is implemented as a macro that can be defined by the
497-
application or by default is defined correctly for the stack mode.
498-
499-
***************************************************************************/
500-
501-
#ifndef USBInitialize
502-
#if defined( USB_SUPPORT_DEVICE )
503-
#if defined( USB_SUPPORT_HOST )
504-
#if defined( USB_SUPPORT_OTG )
505-
#error "USB OTG is not yet supported."
506-
#else
507-
#define USBInitialize(f) \
508-
(USBDEVInitialize(f) && USBHostInit(f)) ? \
509-
true : false
510-
#endif
511-
#else
512-
#define USBInitialize(f) USBDeviceInit()
513-
#endif
514-
#else
515-
#if defined( USB_SUPPORT_HOST )
516-
#define USBInitialize(f) USBHostInit(f)
517-
#else
518-
#error "Application must define support mode in usb_config.h"
519-
#endif
520-
#endif
521-
#endif
522-
523-
524-
/****************************************************************************
525-
Function:
526-
void USBTasks( void )
527-
528-
Summary:
529-
This function executes the tasks for USB operation.
530-
531-
Description:
532-
This function executes the tasks for USB host operation. It must be
533-
executed on a regular basis to keep everything functioning.
534-
535-
Precondition:
536-
USBInitialize() has been called.
537-
538-
Parameters:
539-
None
540-
541-
Returns:
542-
None
543-
544-
Remarks:
545-
This interface is implemented as a macro that can be defined by the
546-
application or by default is defined correctly for the stack mode.
547-
548-
***************************************************************************/
549-
550-
#ifndef USBTasks // Implemented as a macro that can be overridden.
551-
#if defined( USB_SUPPORT_DEVICE )
552-
#if defined( USB_SUPPORT_HOST )
553-
#if defined( USB_SUPPORT_OTG )
554-
#error "USB OTG is not yet supported."
555-
#else
556-
#define USBTasks() {USBHostTasks(); USBHALHandleBusEvent();}
557-
#endif
558-
#else
559-
#define USBTasks() USBDeviceTasks()
560-
#endif
561-
#else
562-
#if defined( USB_SUPPORT_HOST )
563-
#define USBTasks() USBHostTasks()
564-
#else
565-
#error "Application must define support mode in usb_config.h"
566-
#endif
567-
#endif
568-
#endif
569-
570465
#define USB_PING_PONG__NO_PING_PONG 0x00 //0b00
571466
#define USB_PING_PONG__EP0_OUT_ONLY 0x01 //0b01
572467
#define USB_PING_PONG__FULL_PING_PONG 0x02 //0b10

inc/usb_device.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ please contact [email protected]
3838
#ifndef _USB_DEVICE_H
3939
#define _USB_DEVICE_H
4040

41-
#include "usb_common.h"
4241
#include <stdint.h>
4342

43+
#include "usb_common.h"
44+
#include "usb_config.h"
4445

4546
#if defined(__XC8)
4647
#define __attribute__(a)
@@ -2040,14 +2041,6 @@ typedef struct __attribute__ ((packed))
20402041
CTRL_TRF_RETURN (*pFunc)(CTRL_TRF_PARAMS);
20412042
}OUT_PIPE;
20422043

2043-
/************* DWF - SHOULD BE REIMPLEMENTED AS AN EVENT *******************/
2044-
//#if defined(ENABLE_EP0_DATA_RECEIVED_CALLBACK)
2045-
// void USBCBEP0DataReceived(void);
2046-
// #define USBCB_EP0_DATA_RECEIVED() USBCBEP0DataReceived()
2047-
//#else
2048-
// #define USBCB_EP0_DATA_RECEIVED()
2049-
//#endif
2050-
20512044
extern USB_VOLATILE bool RemoteWakeup;
20522045
extern USB_VOLATILE bool USBBusIsSuspended;
20532046
extern USB_VOLATILE USB_DEVICE_STATE USBDeviceState;

inc/usb_device_msd.h

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,6 @@ typedef struct
519519
} LUN_FUNCTIONS;
520520

521521
/** Section: Externs *********************************************************/
522-
extern USB_HANDLE USBMSDOutHandle;
523-
extern USB_HANDLE USBMSDInHandle;
524522
extern volatile USB_MSD_CBW msd_cbw;
525523
extern volatile USB_MSD_CSW msd_csw;
526524
extern volatile char msd_buffer[512];
@@ -618,7 +616,33 @@ void USBMSDInit(void);
618616
**************************************************************************/
619617
#define LUNSoftAttach(LUN) SoftDetach[LUN]=false;
620618

621-
619+
/******************************************************************************
620+
Function:
621+
void MSDTransferTerminated(USB_HANDLE handle)
622+
623+
Description:
624+
Check if the host recently did a clear endpoint halt on the MSD OUT endpoint.
625+
In this case, we want to re-arm the MSD OUT endpoint, so we are prepared
626+
to receive the next CBW that the host might want to send.
627+
Note: If however the STALL was due to a CBW not valid condition,
628+
then we are required to have a persistent STALL, where it cannot
629+
be cleared (until MSD reset recovery takes place). See MSD BOT
630+
specs v1.0, section 6.6.1.
631+
PreCondition:
632+
A transfer was terminated. This should be called from the transfer
633+
terminated event handler.
634+
635+
Parameters:
636+
USB_HANDLE handle - the handle of the transfer that was terminated.
637+
638+
Return Values:
639+
None
640+
641+
Remarks:
642+
None
643+
644+
*****************************************************************************/
645+
void MSDTransferTerminated(USB_HANDLE handle);
622646

623647

624648
#endif

inc/usb_hal_dspic33e.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ please contact [email protected]
2828
/*****************************************************************************/
2929

3030
#include "system.h"
31-
#include "system_config.h"
31+
#include "usb_config.h"
3232

3333
#include <stdint.h>
3434
#include <string.h>

inc/usb_hal_pic16f1.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ please contact [email protected]
2626
/****** include files ********************************************************/
2727
/*****************************************************************************/
2828

29+
#include <xc.h>
30+
2931
#include <stdint.h>
3032
#include <stdbool.h>
3133
#include <string.h>
32-
#include <system.h>
3334

34-
#include "system_config.h"
35+
#include "usb_config.h"
3536

3637
#ifdef __cplusplus // Provide C++ Compatability
3738
extern "C" {

inc/usb_hal_pic18.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ please contact [email protected]
4747

4848
#include <string.h>
4949

50-
#include "system.h"
51-
#include "system_config.h"
50+
#include "usb_config.h"
5251

5352
#ifdef __cplusplus // Provide C++ Compatability
5453
extern "C" {

inc/usb_hal_pic24.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ please contact [email protected]
2626
/****** include files ********************************************************/
2727
/*****************************************************************************/
2828

29-
#include "system.h"
30-
#include "system_config.h"
29+
#include <xc.h>
30+
#include "usb_config.h"
3131

3232
#include <stdint.h>
3333
#include <string.h>

0 commit comments

Comments
 (0)