Skip to content

Commit

Permalink
Merging in changes from 2016-04-27 release:
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
davidflowers committed May 16, 2016
1 parent b7d7045 commit 62fe6a5
Show file tree
Hide file tree
Showing 23 changed files with 208 additions and 228 deletions.
Binary file modified doc/help_mla_usb.jar
Binary file not shown.
Binary file modified doc/help_mla_usb.pdf
Binary file not shown.
3 changes: 1 addition & 2 deletions inc/usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ please contact mla_licensing@microchip.com
#ifndef _USB_H_
#define _USB_H_

#include "system.h"
#include "system_config.h" // Must be defined by the application
#include "usb_config.h"

#include "usb_common.h" // Common USB library definitions
#include "usb_ch9.h" // USB device framework definitions
Expand Down
105 changes: 0 additions & 105 deletions inc/usb_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ please contact mla_licensing@microchip.com
#include <stdbool.h>
#include <stdint.h>

#include "system.h"
#include "system_config.h"

// *****************************************************************************
// *****************************************************************************
// Section: USB Constants
Expand Down Expand Up @@ -465,108 +462,6 @@ stalled (ie. bit 0 = EP0, bit 1 = EP1, etc.)

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


// *****************************************************************************
// *****************************************************************************
// Section: USB Application Program Interface (API) Routines
// *****************************************************************************
// *****************************************************************************

/****************************************************************************
Function:
bool USBInitialize ( unsigned long flags )
Summary:
This interface initializes the variables of the USB host stack.
Description:
This interface initializes the USB stack.
Precondition:
None
Parameters:
flags - reserved
Return Values:
true - Initialization successful
false - Initialization failure
Remarks:
This interface is implemented as a macro that can be defined by the
application or by default is defined correctly for the stack mode.
***************************************************************************/

#ifndef USBInitialize
#if defined( USB_SUPPORT_DEVICE )
#if defined( USB_SUPPORT_HOST )
#if defined( USB_SUPPORT_OTG )
#error "USB OTG is not yet supported."
#else
#define USBInitialize(f) \
(USBDEVInitialize(f) && USBHostInit(f)) ? \
true : false
#endif
#else
#define USBInitialize(f) USBDeviceInit()
#endif
#else
#if defined( USB_SUPPORT_HOST )
#define USBInitialize(f) USBHostInit(f)
#else
#error "Application must define support mode in usb_config.h"
#endif
#endif
#endif


/****************************************************************************
Function:
void USBTasks( void )
Summary:
This function executes the tasks for USB operation.
Description:
This function executes the tasks for USB host operation. It must be
executed on a regular basis to keep everything functioning.
Precondition:
USBInitialize() has been called.
Parameters:
None
Returns:
None
Remarks:
This interface is implemented as a macro that can be defined by the
application or by default is defined correctly for the stack mode.
***************************************************************************/

#ifndef USBTasks // Implemented as a macro that can be overridden.
#if defined( USB_SUPPORT_DEVICE )
#if defined( USB_SUPPORT_HOST )
#if defined( USB_SUPPORT_OTG )
#error "USB OTG is not yet supported."
#else
#define USBTasks() {USBHostTasks(); USBHALHandleBusEvent();}
#endif
#else
#define USBTasks() USBDeviceTasks()
#endif
#else
#if defined( USB_SUPPORT_HOST )
#define USBTasks() USBHostTasks()
#else
#error "Application must define support mode in usb_config.h"
#endif
#endif
#endif

#define USB_PING_PONG__NO_PING_PONG 0x00 //0b00
#define USB_PING_PONG__EP0_OUT_ONLY 0x01 //0b01
#define USB_PING_PONG__FULL_PING_PONG 0x02 //0b10
Expand Down
11 changes: 2 additions & 9 deletions inc/usb_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ please contact mla_licensing@microchip.com
#ifndef _USB_DEVICE_H
#define _USB_DEVICE_H

#include "usb_common.h"
#include <stdint.h>

#include "usb_common.h"
#include "usb_config.h"

#if defined(__XC8)
#define __attribute__(a)
Expand Down Expand Up @@ -2040,14 +2041,6 @@ typedef struct __attribute__ ((packed))
CTRL_TRF_RETURN (*pFunc)(CTRL_TRF_PARAMS);
}OUT_PIPE;

/************* DWF - SHOULD BE REIMPLEMENTED AS AN EVENT *******************/
//#if defined(ENABLE_EP0_DATA_RECEIVED_CALLBACK)
// void USBCBEP0DataReceived(void);
// #define USBCB_EP0_DATA_RECEIVED() USBCBEP0DataReceived()
//#else
// #define USBCB_EP0_DATA_RECEIVED()
//#endif

extern USB_VOLATILE bool RemoteWakeup;
extern USB_VOLATILE bool USBBusIsSuspended;
extern USB_VOLATILE USB_DEVICE_STATE USBDeviceState;
Expand Down
30 changes: 27 additions & 3 deletions inc/usb_device_msd.h
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,6 @@ typedef struct
} LUN_FUNCTIONS;

/** Section: Externs *********************************************************/
extern USB_HANDLE USBMSDOutHandle;
extern USB_HANDLE USBMSDInHandle;
extern volatile USB_MSD_CBW msd_cbw;
extern volatile USB_MSD_CSW msd_csw;
extern volatile char msd_buffer[512];
Expand Down Expand Up @@ -618,7 +616,33 @@ void USBMSDInit(void);
**************************************************************************/
#define LUNSoftAttach(LUN) SoftDetach[LUN]=false;


/******************************************************************************
Function:
void MSDTransferTerminated(USB_HANDLE handle)
Description:
Check if the host recently did a clear endpoint halt on the MSD OUT endpoint.
In this case, we want to re-arm the MSD OUT endpoint, so we are prepared
to receive the next CBW that the host might want to send.
Note: If however the STALL was due to a CBW not valid condition,
then we are required to have a persistent STALL, where it cannot
be cleared (until MSD reset recovery takes place). See MSD BOT
specs v1.0, section 6.6.1.
PreCondition:
A transfer was terminated. This should be called from the transfer
terminated event handler.
Parameters:
USB_HANDLE handle - the handle of the transfer that was terminated.
Return Values:
None
Remarks:
None
*****************************************************************************/
void MSDTransferTerminated(USB_HANDLE handle);


#endif
2 changes: 1 addition & 1 deletion inc/usb_hal_dspic33e.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ please contact mla_licensing@microchip.com
/*****************************************************************************/

#include "system.h"
#include "system_config.h"
#include "usb_config.h"

#include <stdint.h>
#include <string.h>
Expand Down
5 changes: 3 additions & 2 deletions inc/usb_hal_pic16f1.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ please contact mla_licensing@microchip.com
/****** include files ********************************************************/
/*****************************************************************************/

#include <xc.h>

#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <system.h>

#include "system_config.h"
#include "usb_config.h"

#ifdef __cplusplus // Provide C++ Compatability
extern "C" {
Expand Down
3 changes: 1 addition & 2 deletions inc/usb_hal_pic18.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ please contact mla_licensing@microchip.com

#include <string.h>

#include "system.h"
#include "system_config.h"
#include "usb_config.h"

#ifdef __cplusplus // Provide C++ Compatability
extern "C" {
Expand Down
4 changes: 2 additions & 2 deletions inc/usb_hal_pic24.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ please contact mla_licensing@microchip.com
/****** include files ********************************************************/
/*****************************************************************************/

#include "system.h"
#include "system_config.h"
#include <xc.h>
#include "usb_config.h"

#include <stdint.h>
#include <string.h>
Expand Down
2 changes: 1 addition & 1 deletion inc/usb_hal_pic24e.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ please contact mla_licensing@microchip.com
/*****************************************************************************/

#include "system.h"
#include "system_config.h"
#include "usb_config.h"

#include <stdint.h>
#include <string.h>
Expand Down
8 changes: 6 additions & 2 deletions inc/usb_hal_pic24f.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ please contact mla_licensing@microchip.com
/****** include files ********************************************************/
/*****************************************************************************/

#include "system.h"
#include "system_config.h"
#include <xc.h>

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

#include "usb_config.h"
#include "usb_common.h"

/*****************************************************************************/
Expand Down Expand Up @@ -75,6 +76,9 @@ please contact mla_licensing@microchip.com
|| defined(__PIC24FJ64GB410__) || defined(__PIC24FJ64GB412__) || defined(__PIC24FJ64GB406__)
#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)
#define USB_HAL_VBUSTristate() {TRISFbits.TRISF7 = 1;}
#elif defined(__PIC24FJ1024GB610__) || defined(__PIC24FJ512GB610__) || defined(__PIC24FJ256GB610__) || defined(__PIC24FJ128GB610__) || defined(__PIC24FJ1024GB606__) || defined(__PIC24FJ512GB606__) || defined(__PIC24FJ256GB606__) || defined(__PIC24FJ128GB606__)
#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)
#define USB_HAL_VBUSTristate() {TRISFbits.TRISF7 = 1;}
#else
#error "Unknown processor type selected. Refer to device datasheet and update the definition for DEVICE_SPECIFIC_IEC_REGISTER_COUNT."
//#define DEVICE_SPECIFIC_IEC_REGISTER_COUNT 8 // <--- Update this number with the real number for your device and uncomment (and delete the above #error).
Expand Down
2 changes: 1 addition & 1 deletion inc/usb_host_msd_scsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ please contact mla_licensing@microchip.com
#define __USBHOSTMSDSCSI_H__

#include "usb.h"
#include "system_config.h"
#include "usb_config.h"
#include "fileio.h"

// *****************************************************************************
Expand Down
Loading

0 comments on commit 62fe6a5

Please sign in to comment.