Update repo
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
% let Common = system.getScript("/driverlib/Common.js");
|
||||
% var currnetSDKProductPath = system.getProducts()[0].path
|
||||
% var sdkPath = system.utils.path.join(currnetSDKProductPath + "../../../")
|
||||
% sdkPath = sdkPath.replace(new RegExp('\\' + system.utils.path.sep, 'g'), '/')
|
||||
%
|
||||
% var moduleName = "usb"
|
||||
% var module = system.modules['/libraries/communications/usb/' + moduleName + '.js'];
|
||||
%
|
||||
|
||||
%if(module != null)
|
||||
%{
|
||||
% var instance = module.$instances[0];
|
||||
%
|
||||
% if ((instance.usb_mode == "Host") || (instance.usb_mode == "Dual"))
|
||||
%{
|
||||
uint8_t `instance.usb_host_hcdPool`[`instance.$name`_HCD_MEMORY_SIZE];
|
||||
%}
|
||||
void USBLib_init(){
|
||||
% if (instance.usb_mode == "Device")
|
||||
%{
|
||||
%if (instance.deviceClasses == "Bulk")
|
||||
%{
|
||||
//
|
||||
// Initialize the USB stack mode and pass in a mode callback.
|
||||
//
|
||||
USBStackModeSet(0, eUSBModeForceDevice, `instance.usb_mode_callback`);
|
||||
%}
|
||||
%if ((instance.deviceClasses == "CDC") || (instance.deviceClasses == "Mouse") || (instance.deviceClasses == "Keyboard") )
|
||||
%{
|
||||
//
|
||||
// Set the USB stack mode to Device mode with VBUS monitoring.
|
||||
//
|
||||
USBStackModeSet(0, eUSBModeForceDevice, 0);
|
||||
%}
|
||||
%}
|
||||
% else if (instance.usb_mode == "Host")
|
||||
%{
|
||||
//
|
||||
// Initialize the USB stack mode and pass in a mode callback.
|
||||
//
|
||||
USBStackModeSet(0, eUSBModeForceHost, `instance.usb_mode_callback`);
|
||||
%}
|
||||
% if (instance.usb_mode == "Device")
|
||||
%{
|
||||
% if (instance.deviceClasses == "Mouse")
|
||||
%{
|
||||
USBDHIDMouseInit(0, (tUSBDHIDMouseDevice *)&g_sMouseDevice);
|
||||
%}
|
||||
% else if (instance.deviceClasses == "CDC")
|
||||
% {
|
||||
USBDCDCInit(0, &g_sCDCDevice);
|
||||
%}
|
||||
% else if (instance.deviceClasses == "Keyboard")
|
||||
% {
|
||||
USBDHIDKeyboardInit(0, &g_sKeyboardDevice);
|
||||
%}
|
||||
% else if (instance.deviceClasses == "Bulk")
|
||||
% {
|
||||
USBDBulkInit(0, &g_sBulkDevice);
|
||||
%}
|
||||
%}
|
||||
% if (instance.usb_mode == "Host")
|
||||
%{
|
||||
% var power_fault_options = "";
|
||||
% for (var int_index in instance.usb_host_mode_power_config)
|
||||
% {
|
||||
% power_fault_options += ((power_fault_options == "")?"":" | ") + instance.usb_host_mode_power_config[int_index];
|
||||
% }
|
||||
//
|
||||
// Initialize the power configuration.
|
||||
//
|
||||
USBHCDPowerConfigInit(0,`power_fault_options`);
|
||||
//
|
||||
// Initialize the USB controller for OTG operation with a 2ms polling
|
||||
// rate.
|
||||
//
|
||||
USBHCDInit(0,`instance.usb_host_hcdPool`, `instance.$name`_HCD_MEMORY_SIZE);
|
||||
%}
|
||||
}
|
||||
%}
|
||||
%
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
% let Common = system.getScript("/driverlib/Common.js");
|
||||
% var moduleNameUSB = "usb"
|
||||
% var moduleUSB = system.modules['/libraries/communications/usb' + '/' + moduleNameUSB + '.js'];
|
||||
%
|
||||
%if(moduleUSB != null)
|
||||
%{
|
||||
% var instance = moduleUSB.$instances[0];
|
||||
%{
|
||||
-l"libraries/communications/usb/`Common.getDeviceName().toLowerCase()`/lib/usblib.lib"
|
||||
%}
|
||||
%}
|
||||
@@ -0,0 +1,45 @@
|
||||
% var moduleName = "usb"
|
||||
% var module = system.modules['/libraries/communications/usb/' + moduleName + '.js'];
|
||||
%
|
||||
%if(module != null)
|
||||
%{
|
||||
% var instance = module.$instances[0];
|
||||
#include "usblib.h"
|
||||
#include "usbhid.h"
|
||||
% if (instance.usb_mode == "Device")
|
||||
%{
|
||||
#include "usb_structs.h"
|
||||
% if (instance.deviceClasses == "Mouse")
|
||||
%{
|
||||
#include "device/usbdhid.h"
|
||||
#include "device/usbdhidmouse.h"
|
||||
%}
|
||||
% else if (instance.deviceClasses == "Keyboard")
|
||||
%{
|
||||
#include "device/usbdhid.h"
|
||||
#include "device/usbdhidkeyb.h"
|
||||
%}
|
||||
% else if (instance.deviceClasses == "Bulk")
|
||||
%{
|
||||
extern void `instance.usb_mode_callback`(uint32_t ui32Index, tUSBMode eMode);
|
||||
%}
|
||||
%}
|
||||
% else if (instance.usb_mode == "Host")
|
||||
%{
|
||||
#include "usbmsc.h"
|
||||
#include "host/usbhost.h"
|
||||
#include "host/usbhmsc.h"
|
||||
extern void `instance.usb_mode_callback`(uint32_t ui32Index, tUSBMode eMode);
|
||||
#define `instance.$name`_HCD_MEMORY_SIZE `instance.hcdMemorySize`
|
||||
%}
|
||||
%
|
||||
% else if (instance.usb_mode == "Dual")
|
||||
%{
|
||||
extern void `instance.usb_mode_callback`(uint32_t ui32Index, tUSBMode eMode);
|
||||
#define `instance.$name`_HCD_MEMORY_SIZE `instance.hcdMemorySize`
|
||||
%}
|
||||
|
||||
#define USB_MODE `instance.usb_mode`
|
||||
void USBLib_init();
|
||||
%}
|
||||
%
|
||||
@@ -0,0 +1,5 @@
|
||||
% let Common = system.getScript("/driverlib/Common.js");
|
||||
% var c2000warePath = Common.getC2000WarePath()
|
||||
% var device = Common.getDeviceName().toLowerCase()
|
||||
-Dccs_c2k
|
||||
-I"`c2000warePath`libraries/communications/usb/`device`/include"
|
||||
@@ -0,0 +1,6 @@
|
||||
exports = {
|
||||
USBmoduleStatic: {},
|
||||
templates: {
|
||||
"/libraries/communications/usb/templates/usb_structs.c.xdt" : ""
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,702 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Texas Instruments Incorporated - http://www.ti.com
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of Texas Instruments Incorporated nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
% var moduleName = "usb"
|
||||
% var module = system.modules['/libraries/communications/usb/' + moduleName + '.js'];
|
||||
%
|
||||
% function getCharArray(string)
|
||||
% {
|
||||
% let text = [];
|
||||
% let length = 0;
|
||||
% let index = 0;
|
||||
% for (var i = 0; i < string.length; i++)
|
||||
% {
|
||||
% text[index] = "'" + (string.charAt(i)) + "'";
|
||||
% index++;
|
||||
% text[index] = "0" ;
|
||||
% index++;
|
||||
% }
|
||||
% length = string.length;
|
||||
% return [text,length]
|
||||
% }
|
||||
|
||||
%if(module != null)
|
||||
%{
|
||||
% var instance = module.$instances[0];
|
||||
|
||||
|
||||
% if ((instance.usb_mode == "Device") || (instance.usb_mode == "Dual"))
|
||||
%{
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "usb_structs.h"
|
||||
|
||||
% if (instance.deviceClasses == "CDC")
|
||||
%{
|
||||
|
||||
// Data structures defining this CDC USB device.
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The languages supported by this device.
|
||||
//
|
||||
//******************************************************************************
|
||||
const uint8_t g_pui8LangDescriptor[] =
|
||||
{
|
||||
4,
|
||||
USB_DTYPE_STRING,
|
||||
USBShort(USB_LANG_EN_US)
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The manufacturer string.
|
||||
//
|
||||
//******************************************************************************
|
||||
% var descriptor_str_length = 0;
|
||||
% var descriptor_str = getCharArray(instance.manufacturerString_cdc);
|
||||
% var descriptor_str_length = descriptor_str[1]
|
||||
% var descriptor_str_text = descriptor_str[0];
|
||||
const uint8_t g_pui8ManufacturerString[] =
|
||||
{
|
||||
(`descriptor_str_length` + 1) * 2,
|
||||
USB_DTYPE_STRING,
|
||||
`descriptor_str_text`,
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The product string.
|
||||
//
|
||||
//******************************************************************************
|
||||
% descriptor_str = getCharArray(instance.productString_cdc);
|
||||
% descriptor_str_length = descriptor_str[1]
|
||||
% descriptor_str_text = descriptor_str[0];
|
||||
const uint8_t g_pui8ProdectString[] =
|
||||
{
|
||||
2 + (`descriptor_str_length` * 2),
|
||||
USB_DTYPE_STRING,
|
||||
`descriptor_str_text`,
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The serial number string.
|
||||
//
|
||||
//******************************************************************************
|
||||
% descriptor_str = getCharArray(instance.serialNumberString_cdc);
|
||||
% descriptor_str_length = descriptor_str[1]
|
||||
% descriptor_str_text = descriptor_str[0];
|
||||
const uint8_t g_pui8SerialNumberString[] =
|
||||
{
|
||||
2 + (`descriptor_str_length` * 2),
|
||||
USB_DTYPE_STRING,
|
||||
`descriptor_str_text`,
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The control interface description string.
|
||||
//
|
||||
//******************************************************************************
|
||||
% descriptor_str = getCharArray(instance.controlInterfaceString_cdc);
|
||||
% descriptor_str_length = descriptor_str[1]
|
||||
% descriptor_str_text = descriptor_str[0];
|
||||
const uint8_t g_pui8ControlInterfaceString[] =
|
||||
{
|
||||
2 + (`descriptor_str_length` * 2),
|
||||
USB_DTYPE_STRING,
|
||||
`descriptor_str_text`,
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The configuration description string.
|
||||
//
|
||||
//******************************************************************************
|
||||
% descriptor_str = getCharArray(instance.configString_cdc);
|
||||
% descriptor_str_length = descriptor_str[1]
|
||||
% descriptor_str_text = descriptor_str[0];
|
||||
const uint8_t g_pui8ConfigString[] =
|
||||
{
|
||||
2 + (`descriptor_str_length` * 2),
|
||||
USB_DTYPE_STRING,
|
||||
`descriptor_str_text`,
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The descriptor string table.
|
||||
//
|
||||
//******************************************************************************
|
||||
const uint8_t * const g_pui8StringDescriptors[] =
|
||||
{
|
||||
g_pui8LangDescriptor,
|
||||
g_pui8ManufacturerString,
|
||||
g_pui8ProdectString,
|
||||
g_pui8SerialNumberString,
|
||||
g_pui8ControlInterfaceString,
|
||||
g_pui8ConfigString
|
||||
};
|
||||
|
||||
#define NUM_STRING_DESCRIPTORS (sizeof(g_pui8StringDescriptors) /\
|
||||
sizeof(uint8_t *))
|
||||
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// CDC device callback function prototypes.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t `instance.usbCDCRxHandler`(void *pvCBData, uint32_t ui32Event,
|
||||
uint32_t ui32MsgValue, void *pvMsgData);
|
||||
uint32_t `instance.usbCDCTxHandler`(void *pvCBData, uint32_t ui32Event,
|
||||
uint32_t ui32MsgValue, void *pvMsgData);
|
||||
uint32_t `instance.usbCDCControlHandler`(void *pvCBData, uint32_t ui32Event,
|
||||
uint32_t ui32MsgValue, void *pvMsgData);
|
||||
|
||||
|
||||
|
||||
extern tUSBBuffer `instance.usbCDCTxStruct`;
|
||||
extern tUSBBuffer `instance.usbCDCRxStruct`;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! The structure used by the application to define operating parameters for
|
||||
//! the CDC device.
|
||||
//
|
||||
//*****************************************************************************
|
||||
tUSBDCDCDevice `instance.usbCDCDeviceStruct` =
|
||||
{
|
||||
USB_VID_TI_1CBE,
|
||||
USB_PID_SERIAL,
|
||||
0,
|
||||
USB_CONF_ATTR_SELF_PWR,
|
||||
`instance.usbCDCControlHandler`,
|
||||
(void *)&`instance.usbCDCDeviceStruct`,
|
||||
USBBufferEventCallback,
|
||||
(void *)&`instance.usbCDCRxStruct`,
|
||||
USBBufferEventCallback,
|
||||
(void *)&`instance.usbCDCTxStruct`,
|
||||
g_pui8StringDescriptors,
|
||||
NUM_STRING_DESCRIPTORS
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// Receive buffer (from the USB perspective).
|
||||
//
|
||||
//******************************************************************************
|
||||
uint8_t `instance.usbCDCRxBuffer`[`instance.usbBufferSize`];
|
||||
uint8_t g_pui8RxBufferWorkspace[USB_BUFFER_WORKSPACE_SIZE];
|
||||
tUSBBuffer `instance.usbCDCRxStruct` =
|
||||
{
|
||||
false, // This is a receive buffer.
|
||||
`instance.usbCDCRxHandler`, // pfnCallback
|
||||
(void *)&`instance.usbCDCDeviceStruct`, // Callback data is our device pointer.
|
||||
USBDCDCPacketRead, // pfnTransfer
|
||||
USBDCDCRxPacketAvailable, // pfnAvailable
|
||||
(void *)&`instance.usbCDCDeviceStruct`, // pvHandle
|
||||
`instance.usbCDCRxBuffer`, // pi8Buffer
|
||||
`instance.$name`_SCI_BUFFER_SIZE // ui32BufferSize
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// Transmit buffer (from the USB perspective).
|
||||
//
|
||||
//******************************************************************************
|
||||
uint8_t `instance.usbCDCTxBuffer`[`instance.usbBufferSize`];
|
||||
uint8_t g_pui8TxBufferWorkspace[USB_BUFFER_WORKSPACE_SIZE];
|
||||
tUSBBuffer `instance.usbCDCTxStruct` =
|
||||
{
|
||||
true, // This is a transmit buffer.
|
||||
`instance.usbCDCTxHandler`, // pfnCallback
|
||||
(void *)&`instance.usbCDCDeviceStruct`, // Callback data is our device pointer.
|
||||
USBDCDCPacketWrite, // pfnTransfer
|
||||
USBDCDCTxPacketAvailable, // pfnAvailable
|
||||
(void *)&`instance.usbCDCDeviceStruct`, // pvHandle
|
||||
`instance.usbCDCTxBuffer`, // pi8Buffer
|
||||
`instance.$name`_SCI_BUFFER_SIZE // ui32BufferSize
|
||||
};
|
||||
|
||||
%}
|
||||
% else if (instance.deviceClasses == "Mouse")
|
||||
%{
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "inc/hw_types.h"
|
||||
#include "usblib.h"
|
||||
#include "usbhid.h"
|
||||
#include "usb_ids.h"
|
||||
#include "device/usbdevice.h"
|
||||
#include "device/usbdhid.h"
|
||||
#include "device/usbdhidmouse.h"
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The languages supported by this device.
|
||||
//
|
||||
//******************************************************************************
|
||||
const uint8_t g_pLangDescriptor[] =
|
||||
{
|
||||
4,
|
||||
USB_DTYPE_STRING,
|
||||
USBShort(USB_LANG_EN_US)
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The manufacturer string.
|
||||
//
|
||||
//******************************************************************************
|
||||
% var descriptor_str_length = 0;
|
||||
% var descriptor_str = getCharArray(instance.manufacturerString_mouse);
|
||||
% var descriptor_str_length = descriptor_str[1]
|
||||
% var descriptor_str_text = descriptor_str[0];
|
||||
const uint8_t g_pManufacturerString[] =
|
||||
{
|
||||
(`descriptor_str_length` + 1) * 2,
|
||||
USB_DTYPE_STRING,
|
||||
`descriptor_str_text`
|
||||
};
|
||||
//******************************************************************************
|
||||
//
|
||||
// The product string.
|
||||
//
|
||||
//******************************************************************************
|
||||
% descriptor_str = getCharArray(instance.productString_mouse);
|
||||
% descriptor_str_length = descriptor_str[1]
|
||||
% descriptor_str_text = descriptor_str[0];
|
||||
const uint8_t g_pProductString[] =
|
||||
{
|
||||
(`descriptor_str_length` + 1) * 2,
|
||||
USB_DTYPE_STRING,
|
||||
`descriptor_str_text`
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The serial number string.
|
||||
//
|
||||
//******************************************************************************
|
||||
% descriptor_str = getCharArray(instance.serialNumberString_mouse);
|
||||
% descriptor_str_length = descriptor_str[1]
|
||||
% descriptor_str_text = descriptor_str[0];
|
||||
const uint8_t g_pSerialNumberString[] =
|
||||
{
|
||||
(`descriptor_str_length` + 1) * 2,
|
||||
USB_DTYPE_STRING,
|
||||
`descriptor_str_text`
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The interface description string.
|
||||
//
|
||||
//******************************************************************************
|
||||
% descriptor_str = getCharArray(instance.mouseHIDInterfaceString);
|
||||
% descriptor_str_length = descriptor_str[1]
|
||||
% descriptor_str_text = descriptor_str[0];
|
||||
const uint8_t g_pHIDInterfaceString[] =
|
||||
{
|
||||
(`descriptor_str_length` + 1) * 2,
|
||||
USB_DTYPE_STRING,
|
||||
`descriptor_str_text`
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The configuration description string.
|
||||
//
|
||||
//******************************************************************************
|
||||
% descriptor_str = getCharArray(instance.configString_mouse);
|
||||
% descriptor_str_length = descriptor_str[1]
|
||||
% descriptor_str_text = descriptor_str[0];
|
||||
const uint8_t g_pConfigString[] =
|
||||
{
|
||||
(`descriptor_str_length` + 1) * 2,
|
||||
USB_DTYPE_STRING,
|
||||
`descriptor_str_text`
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The descriptor string table.
|
||||
//
|
||||
//******************************************************************************
|
||||
const uint8_t * const g_pStringDescriptors[] =
|
||||
{
|
||||
g_pLangDescriptor,
|
||||
g_pManufacturerString,
|
||||
g_pProductString,
|
||||
g_pSerialNumberString,
|
||||
g_pHIDInterfaceString,
|
||||
g_pConfigString
|
||||
};
|
||||
|
||||
#define NUM_STRING_DESCRIPTORS (sizeof(g_pStringDescriptors) /\
|
||||
sizeof(uint8_t *))
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The HID mouse device initialization and customization structures.
|
||||
//
|
||||
//******************************************************************************
|
||||
tHIDMouseInstance g_sMouseInstance;
|
||||
|
||||
tUSBDHIDMouseDevice `instance.usbMouseDeviceStruct` =
|
||||
{
|
||||
USB_VID_TI_1CBE,
|
||||
USB_PID_MOUSE,
|
||||
`instance.usbMouseMaxPowerConsumption`,
|
||||
USB_CONF_ATTR_SELF_PWR,
|
||||
`instance.usbMouseHandler`,
|
||||
(void *)&`instance.usbMouseDeviceStruct`,
|
||||
g_pStringDescriptors,
|
||||
NUM_STRING_DESCRIPTORS,
|
||||
};
|
||||
|
||||
%}
|
||||
% else if (instance.deviceClasses == "Keyboard")
|
||||
%{
|
||||
//******************************************************************************
|
||||
//
|
||||
// The languages supported by this device.
|
||||
//
|
||||
//******************************************************************************
|
||||
const uint8_t g_pui8LangDescriptor[] =
|
||||
{
|
||||
4,
|
||||
USB_DTYPE_STRING,
|
||||
USBShort(USB_LANG_EN_US)
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The manufacturer string.
|
||||
//
|
||||
//******************************************************************************
|
||||
% var descriptor_str_length = 0;
|
||||
% var descriptor_str = getCharArray(instance.manufacturerString_keyboard);
|
||||
% var descriptor_str_length = descriptor_str[1]
|
||||
% var descriptor_str_text = descriptor_str[0];
|
||||
const uint8_t g_pui8ManufacturerString[] =
|
||||
{
|
||||
(`descriptor_str_length` + 1) * 2,
|
||||
USB_DTYPE_STRING,
|
||||
`descriptor_str_text`
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The product string.
|
||||
//
|
||||
//******************************************************************************
|
||||
% descriptor_str = getCharArray(instance.productString_keyboard);
|
||||
% descriptor_str_length = descriptor_str[1]
|
||||
% descriptor_str_text = descriptor_str[0];
|
||||
const uint8_t g_pui8ProductString[] =
|
||||
{
|
||||
(`descriptor_str_length` + 1) * 2,
|
||||
USB_DTYPE_STRING,
|
||||
`descriptor_str_text`
|
||||
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The serial number string.
|
||||
//
|
||||
//******************************************************************************
|
||||
% descriptor_str = getCharArray(instance.serialNumberString_keyboard);
|
||||
% descriptor_str_length = descriptor_str[1]
|
||||
% descriptor_str_text = descriptor_str[0];
|
||||
const uint8_t g_pui8SerialNumberString[] =
|
||||
{
|
||||
(`descriptor_str_length` + 1) * 2,
|
||||
USB_DTYPE_STRING,
|
||||
`descriptor_str_text`
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The interface description string.
|
||||
//
|
||||
//******************************************************************************
|
||||
% descriptor_str = getCharArray(instance.keyboardHIDInterfaceString);
|
||||
% descriptor_str_length = descriptor_str[1]
|
||||
% descriptor_str_text = descriptor_str[0];
|
||||
const uint8_t g_pui8HIDInterfaceString[] =
|
||||
{
|
||||
(`descriptor_str_length` + 1) * 2,
|
||||
USB_DTYPE_STRING,
|
||||
`descriptor_str_text`
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The configuration description string.
|
||||
//
|
||||
//******************************************************************************
|
||||
% descriptor_str = getCharArray(instance.configString_keyboard);
|
||||
% descriptor_str_length = descriptor_str[1]
|
||||
% descriptor_str_text = descriptor_str[0];
|
||||
const uint8_t g_pui8ConfigString[] =
|
||||
{
|
||||
(`descriptor_str_length` + 1) * 2,
|
||||
USB_DTYPE_STRING,
|
||||
`descriptor_str_text`
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The descriptor string table.
|
||||
//
|
||||
//******************************************************************************
|
||||
const uint8_t * const g_pui8StringDescriptors[] =
|
||||
{
|
||||
g_pui8LangDescriptor,
|
||||
g_pui8ManufacturerString,
|
||||
g_pui8ProductString,
|
||||
g_pui8SerialNumberString,
|
||||
g_pui8HIDInterfaceString,
|
||||
g_pui8ConfigString
|
||||
};
|
||||
|
||||
#define NUM_STRING_DESCRIPTORS (sizeof(g_pui8StringDescriptors) /\
|
||||
sizeof(uint8_t *))
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The HID keyboard device initialization and customization structures.
|
||||
//
|
||||
//******************************************************************************
|
||||
tUSBDHIDKeyboardDevice `instance.usbKeyboardDeviceStruct` =
|
||||
{
|
||||
USB_VID_TI_1CBE,
|
||||
USB_PID_KEYBOARD,
|
||||
500,
|
||||
USB_CONF_ATTR_SELF_PWR | USB_CONF_ATTR_RWAKE,
|
||||
`instance.usbKeyboardHandler`,
|
||||
(void *)&`instance.usbKeyboardDeviceStruct`,
|
||||
g_pui8StringDescriptors,
|
||||
NUM_STRING_DESCRIPTORS,
|
||||
0//&g_KeyboardInstance
|
||||
};
|
||||
%}
|
||||
% else if (instance.deviceClasses == "Bulk")
|
||||
%{
|
||||
//******************************************************************************
|
||||
//
|
||||
// The languages supported by this device.
|
||||
//
|
||||
//******************************************************************************
|
||||
const uint8_t g_pui8LangDescriptor[] =
|
||||
{
|
||||
4,
|
||||
USB_DTYPE_STRING,
|
||||
USBShort(USB_LANG_EN_US)
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The manufacturer string.
|
||||
//
|
||||
//******************************************************************************
|
||||
% var descriptor_str_length = 0;
|
||||
% var descriptor_str = getCharArray(instance.manufacturerString_bulk);
|
||||
% var descriptor_str_length = descriptor_str[1]
|
||||
% var descriptor_str_text = descriptor_str[0];
|
||||
const uint8_t g_pui8ManufacturerString[] =
|
||||
{
|
||||
(`descriptor_str_length` + 1) * 2,
|
||||
USB_DTYPE_STRING,
|
||||
`descriptor_str_text`
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The product string.
|
||||
//
|
||||
//******************************************************************************
|
||||
% descriptor_str = getCharArray(instance.productString_bulk);
|
||||
% descriptor_str_length = descriptor_str[1]
|
||||
% descriptor_str_text = descriptor_str[0];
|
||||
const uint8_t g_pui8ProductString[] =
|
||||
{
|
||||
(`descriptor_str_length` + 1) * 2,
|
||||
USB_DTYPE_STRING,
|
||||
`descriptor_str_text`
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The serial number string.
|
||||
//
|
||||
//******************************************************************************
|
||||
% descriptor_str = getCharArray(instance.serialNumberString_bulk);
|
||||
% descriptor_str_length = descriptor_str[1]
|
||||
% descriptor_str_text = descriptor_str[0];
|
||||
const uint8_t g_pui8SerialNumberString[] =
|
||||
{
|
||||
(`descriptor_str_length` + 1) * 2,
|
||||
USB_DTYPE_STRING,
|
||||
`descriptor_str_text`
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The data interface description string.
|
||||
//
|
||||
//******************************************************************************
|
||||
% descriptor_str = getCharArray(instance.dataInterfaceString);
|
||||
% descriptor_str_length = descriptor_str[1]
|
||||
% descriptor_str_text = descriptor_str[0];
|
||||
const uint8_t g_pui8DataInterfaceString[] =
|
||||
{
|
||||
(`descriptor_str_length` + 1) * 2,
|
||||
USB_DTYPE_STRING,
|
||||
`descriptor_str_text`
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The configuration description string.
|
||||
//
|
||||
//******************************************************************************
|
||||
% descriptor_str = getCharArray(instance.dataInterfaceString);
|
||||
% descriptor_str_length = descriptor_str[1]
|
||||
% descriptor_str_text = descriptor_str[0];
|
||||
const uint8_t g_pui8ConfigString[] =
|
||||
{
|
||||
(`descriptor_str_length` + 1) * 2,
|
||||
USB_DTYPE_STRING,
|
||||
`descriptor_str_text`
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The descriptor string table.
|
||||
//
|
||||
//******************************************************************************
|
||||
const uint8_t *const g_pui8StringDescriptors[] =
|
||||
{
|
||||
g_pui8LangDescriptor,
|
||||
g_pui8ManufacturerString,
|
||||
g_pui8ProductString,
|
||||
g_pui8SerialNumberString,
|
||||
g_pui8DataInterfaceString,
|
||||
g_pui8ConfigString
|
||||
};
|
||||
|
||||
#define NUM_STRING_DESCRIPTORS (sizeof(g_pui8StringDescriptors) / \
|
||||
sizeof(uint8_t *))
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// The bulk device initialization and customization structures. In this case,
|
||||
// we are using USBBuffers between the bulk device class driver and the
|
||||
// application code. The function pointers and callback data values are set
|
||||
// to insert a buffer in each of the data channels, transmit and receive.
|
||||
//
|
||||
// With the buffer in place, the bulk channel callback is set to the relevant
|
||||
// channel function and the callback data is set to point to the channel
|
||||
// instance data. The buffer, in turn, has its callback set to the application
|
||||
// function and the callback data set to our bulk instance structure.
|
||||
//
|
||||
//******************************************************************************
|
||||
tUSBDBulkDevice `instance.usbBulkDeviceStruct` =
|
||||
{
|
||||
USB_VID_TI_1CBE,
|
||||
USB_PID_BULK,
|
||||
500,
|
||||
USB_CONF_ATTR_SELF_PWR,
|
||||
USBBufferEventCallback,
|
||||
(void *)&`instance.usbBulkRxStruct`,
|
||||
USBBufferEventCallback,
|
||||
(void *)&`instance.usbBulkTxStruct`,
|
||||
g_pui8StringDescriptors,
|
||||
NUM_STRING_DESCRIPTORS
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// Receive buffer (from the USB perspective).
|
||||
//
|
||||
//******************************************************************************
|
||||
uint8_t `instance.usbBulkRxBuffer`[`instance.usbBulkBufferSize`];
|
||||
uint8_t g_pui8RxBufferWorkspace[USB_BUFFER_WORKSPACE_SIZE];
|
||||
tUSBBuffer `instance.usbBulkRxStruct` =
|
||||
{
|
||||
false, // This is a receive buffer.
|
||||
`instance.usbBulkRxHandler`, // pfnCallback
|
||||
(void *)&`instance.usbBulkDeviceStruct`, // Callback data is our device pointer.
|
||||
USBDBulkPacketRead, // pfnTransfer
|
||||
USBDBulkRxPacketAvailable, // pfnAvailable
|
||||
(void *)&`instance.usbBulkDeviceStruct`, // pvHandle
|
||||
`instance.usbBulkRxBuffer`, // pi8Buffer
|
||||
`instance.usbBulkBufferSize` // ui32BufferSize
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
//
|
||||
// Transmit buffer (from the USB perspective).
|
||||
//
|
||||
//******************************************************************************
|
||||
|
||||
uint8_t `instance.usbBulkTxBuffer`[`instance.usbBulkBufferSize`];
|
||||
uint8_t g_pui8TxBufferWorkspace[USB_BUFFER_WORKSPACE_SIZE];
|
||||
tUSBBuffer `instance.usbBulkTxStruct` =
|
||||
{
|
||||
true, // This is a transmit buffer.
|
||||
`instance.usbBulkTxHandler`, // pfnCallback
|
||||
(void *)&`instance.usbBulkDeviceStruct`, // Callback data is our device pointer.
|
||||
USBDBulkPacketWrite, // pfnTransfer
|
||||
USBDBulkTxPacketAvailable, // pfnAvailable
|
||||
(void *)&`instance.usbBulkDeviceStruct`, // pvHandle
|
||||
`instance.usbBulkTxBuffer`, // pi8Buffer
|
||||
`instance.usbBulkBufferSize` // ui32BufferSize
|
||||
};
|
||||
|
||||
%}
|
||||
%}
|
||||
|
||||
%}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,6 @@
|
||||
exports = {
|
||||
USBmoduleStatic: {},
|
||||
templates: {
|
||||
"/libraries/communications/usb/templates/usb_structs.h.xdt" : ""
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Texas Instruments Incorporated - http://www.ti.com
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of Texas Instruments Incorporated nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
% var moduleName = "usb"
|
||||
% var module = system.modules['/libraries/communications/usb/' + moduleName + '.js'];
|
||||
%
|
||||
%if(module != null)
|
||||
%{
|
||||
% var instance = module.$instances[0];
|
||||
|
||||
#ifndef USB_STRUCTS_H
|
||||
#define USB_STRUCTS_H
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "inc/hw_types.h"
|
||||
#include "usb.h"
|
||||
#include "usblib.h"
|
||||
#include "usb_ids.h"
|
||||
|
||||
% if ((instance.usb_mode == "Device") || (instance.usb_mode == "Dual"))
|
||||
%{
|
||||
#include "device/usbdevice.h"
|
||||
|
||||
% if (instance.deviceClasses == "CDC")
|
||||
%{
|
||||
#include "usbcdc.h"
|
||||
#include "device/usbdcdc.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
|
||||
//
|
||||
// The size of the transmit and receive buffers used for the redirected SCI.
|
||||
// This number should be a power of 2 for best performance. 256 is chosen
|
||||
// pretty much at random though the buffer should be at least twice the size of
|
||||
// a maximum-sized USB packet.
|
||||
//
|
||||
#define `instance.$name`_SCI_BUFFER_SIZE `instance.usbBufferSize`
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
extern tUSBBuffer `instance.usbCDCTxStruct`;
|
||||
extern tUSBBuffer `instance.usbCDCRxStruct`;
|
||||
extern tUSBDCDCDevice `instance.usbCDCDeviceStruct`;
|
||||
extern uint8_t `instance.usbCDCTxBuffer`[];
|
||||
extern uint8_t `instance.usbCDCRxBuffer`[];
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
extern uint32_t `instance.usbCDCRxHandler`(void *pvCBData, uint32_t ui32Event,
|
||||
uint32_t ui32MsgValue, void *pvMsgData);
|
||||
extern uint32_t `instance.usbCDCTxHandler`(void *pvi32CBData, uint32_t ui32Event,
|
||||
uint32_t ui32MsgValue, void *pvMsgData);
|
||||
|
||||
%}
|
||||
% else if (instance.deviceClasses == "Mouse")
|
||||
%{
|
||||
#include "usbhid.h"
|
||||
#include "device/usbdhid.h"
|
||||
#include "device/usbdhidmouse.h"
|
||||
extern uint32_t `instance.usbMouseHandler`(void *pvCBData, uint32_t ui32Event,
|
||||
uint32_t ui32MsgData, void *pvMsgData);
|
||||
|
||||
extern tUSBDHIDMouseDevice `instance.usbMouseDeviceStruct`;
|
||||
|
||||
%}
|
||||
% else if (instance.deviceClasses == "Keyboard")
|
||||
%{
|
||||
#include "usbhid.h"
|
||||
#include "device/usbdhid.h"
|
||||
#include "device/usbdhidkeyb.h"
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
extern tUSBDHIDKeyboardDevice `instance.usbKeyboardDeviceStruct`;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
extern uint32_t `instance.usbKeyboardHandler`(void *pvCBData, uint32_t ui32Event,
|
||||
uint32_t ui32MsgData, void *pvMsgData);
|
||||
|
||||
|
||||
%}
|
||||
% else if (instance.deviceClasses == "Bulk")
|
||||
%{
|
||||
#include "device/usbdbulk.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
|
||||
//
|
||||
// The size of the transmit and receive buffers used. 256 is chosen pretty
|
||||
// much at random though the buffer should be at least twice the size of
|
||||
// a maximum-sized USB packet.
|
||||
//
|
||||
#define `instance.$name`_BULK_BUFFER_SIZE `instance.usbBulkBufferSize`
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
extern tUSBBuffer `instance.usbBulkTxStruct`;
|
||||
extern tUSBBuffer `instance.usbBulkRxStruct`;
|
||||
extern tUSBDBulkDevice `instance.usbBulkDeviceStruct`;
|
||||
extern uint8_t `instance.usbBulkTxBuffer`[];
|
||||
extern uint8_t `instance.usbBulkRxBuffer`[];
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
extern uint32_t `instance.usbBulkRxHandler`(void *pvCBData, uint32_t ui32Event,
|
||||
uint32_t ui32MsgValue, void *pvMsgData);
|
||||
extern uint32_t `instance.usbBulkTxHandler`(void *pvi32CBData, uint32_t ui32Event,
|
||||
uint32_t ui32MsgValue, void *pvMsgData);
|
||||
|
||||
%}
|
||||
%}
|
||||
|
||||
#endif // USB_STRUCTS_H
|
||||
%}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,696 @@
|
||||
let Common = system.getScript("/driverlib/Common.js");
|
||||
let Pinmux = system.getScript("/driverlib/pinmux.js");
|
||||
var HIDMouseConfigNames = ["manufacturerString_mouse", "productString_mouse", "serialNumberString_mouse", "mouseHIDInterfaceString" , "configString_mouse", "usbMouseDeviceStruct","usbMouseHandler","usbMouseMaxPowerConsumption"]
|
||||
var CDCConfigNames = ["manufacturerString_cdc", "productString_cdc", "serialNumberString_cdc", "controlInterfaceString_cdc", "configString_cdc", "usbCDCTxStruct", "usbCDCRxStruct", "usbCDCTxBuffer", "usbCDCRxBuffer", "usbBufferSize", "usbCDCDeviceStruct", "usbCDCRxHandler", "usbCDCTxHandler","usbCDCControlHandler"]
|
||||
var HIDKeyboardConfigNames = ["manufacturerString_keyboard", "productString_keyboard", "serialNumberString_keyboard", "keyboardHIDInterfaceString", "configString_keyboard","usbKeyboardDeviceStruct", "usbKeyboardHandler"]
|
||||
var BulkConfigNames = ["manufacturerString_bulk", "productString_bulk", "dataInterfaceString", "configString_bulk", "usbBulkDeviceStruct", "usbBulkTxStruct", "usbBulkRxStruct", "usbBulkTxBuffer", "usbBulkRxBuffer", "usbBulkBufferSize", "usbBulkRxHandler", "usbBulkTxHandler"]
|
||||
|
||||
function onValidate(inst, validation)
|
||||
{
|
||||
for (var configName of CDCConfigNames)
|
||||
{
|
||||
if (inst.configName == "")
|
||||
{
|
||||
validation.logError("Value cannot be empty for ", inst.configName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function onchangeUSBMode(inst, ui)
|
||||
{
|
||||
if (inst.usb_mode == "Device")
|
||||
{
|
||||
ui.deviceClasses.hidden = false;
|
||||
ui.hostApplication.hidden = true;
|
||||
ui.hcdMemorySize.hidden = true;
|
||||
ui.mouseMemorySize.hidden = true;
|
||||
ui.keyboardMemorySize.hidden = true;
|
||||
if(inst.deviceClasses == "Bulk")
|
||||
{
|
||||
ui.usb_mode_callback.hidden = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.usb_mode_callback.hidden = true;
|
||||
}
|
||||
ui.usb_host_mode_power_config.hidden = true;
|
||||
ui.usb_host_hcdPool.hidden = true;
|
||||
for (var configName of CDCConfigNames)
|
||||
{
|
||||
ui[configName].hidden = false;
|
||||
}
|
||||
}
|
||||
else if (inst.usb_mode == "Host")
|
||||
{
|
||||
ui.deviceClasses.hidden = true;
|
||||
ui.hostApplication.hidden = false;
|
||||
ui.hcdMemorySize.hidden = false;
|
||||
ui.mouseMemorySize.hidden = false;
|
||||
ui.usb_mode_callback.hidden = false;
|
||||
ui.usb_host_mode_power_config.hidden = false;
|
||||
ui.usb_host_hcdPool.hidden = false;
|
||||
for (var configName of CDCConfigNames)
|
||||
{
|
||||
ui[configName].hidden = true;
|
||||
}
|
||||
for (var configName of HIDMouseConfigNames)
|
||||
{
|
||||
ui[configName].hidden = true;
|
||||
}
|
||||
for (var configName of HIDKeyboardConfigNames)
|
||||
{
|
||||
ui[configName].hidden = true;
|
||||
}
|
||||
for (var configName of BulkConfigNames)
|
||||
{
|
||||
ui[configName].hidden = true;
|
||||
}
|
||||
}
|
||||
else if(inst.usb_mode == "Dual")
|
||||
{
|
||||
ui.deviceClasses.hidden = false;
|
||||
ui.hostApplication.hidden = false;
|
||||
ui.hcdMemorySize.hidden = false;
|
||||
ui.mouseMemorySize.hidden = false;
|
||||
ui.usb_mode_callback.hidden = false;
|
||||
ui.usb_host_mode_power_config.hidden = false;
|
||||
for (var configName of CDCConfigNames)
|
||||
{
|
||||
ui[configName].hidden = false;
|
||||
}
|
||||
onChangeHostApplication(inst, ui)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function onChangeHostApplication(inst, ui)
|
||||
{
|
||||
if (inst.hostApplication == "Mouse")
|
||||
{
|
||||
ui.mouseMemorySize.hidden = false;
|
||||
ui.keyboardMemorySize.hidden = true;
|
||||
}
|
||||
else if (inst.hostApplication == "Keyboard")
|
||||
{
|
||||
ui.mouseMemorySize.hidden = true;
|
||||
ui.keyboardMemorySize.hidden = false;
|
||||
}
|
||||
else if (inst.hostApplication == "Mass Storage")
|
||||
{
|
||||
ui.mouseMemorySize.hidden = true;
|
||||
ui.keyboardMemorySize.hidden = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function onchangeDeviceClass(inst, ui)
|
||||
{
|
||||
|
||||
if (inst.deviceClasses == "CDC")
|
||||
{
|
||||
for (var configName of CDCConfigNames)
|
||||
{
|
||||
ui[configName].hidden = false;
|
||||
}
|
||||
for (var configName of HIDMouseConfigNames)
|
||||
{
|
||||
ui[configName].hidden = true;
|
||||
}
|
||||
for (var configName of HIDKeyboardConfigNames)
|
||||
{
|
||||
ui[configName].hidden = true;
|
||||
}
|
||||
for (var configName of BulkConfigNames)
|
||||
{
|
||||
ui[configName].hidden = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if(inst.deviceClasses == "Mouse")
|
||||
{
|
||||
for (var configName of HIDMouseConfigNames)
|
||||
{
|
||||
ui[configName].hidden = false;
|
||||
}
|
||||
for (var configName of CDCConfigNames)
|
||||
{
|
||||
ui[configName].hidden = true;
|
||||
}
|
||||
for (var configName of HIDKeyboardConfigNames)
|
||||
{
|
||||
ui[configName].hidden = true;
|
||||
}
|
||||
for (var configName of BulkConfigNames)
|
||||
{
|
||||
ui[configName].hidden = true;
|
||||
}
|
||||
}
|
||||
else if(inst.deviceClasses == "Keyboard")
|
||||
{
|
||||
for (var configName of HIDKeyboardConfigNames)
|
||||
{
|
||||
ui[configName].hidden = false;
|
||||
}
|
||||
for (var configName of HIDMouseConfigNames)
|
||||
{
|
||||
ui[configName].hidden = true;
|
||||
}
|
||||
for (var configName of CDCConfigNames)
|
||||
{
|
||||
ui[configName].hidden = true;
|
||||
}
|
||||
for (var configName of BulkConfigNames)
|
||||
{
|
||||
ui[configName].hidden = true;
|
||||
}
|
||||
}
|
||||
else if(inst.deviceClasses == "Bulk")
|
||||
{
|
||||
for (var configName of BulkConfigNames)
|
||||
{
|
||||
ui[configName].hidden = false;
|
||||
}
|
||||
for (var configName of HIDMouseConfigNames)
|
||||
{
|
||||
ui[configName].hidden = true;
|
||||
}
|
||||
for (var configName of HIDKeyboardConfigNames)
|
||||
{
|
||||
ui[configName].hidden = true;
|
||||
}
|
||||
for (var configName of CDCConfigNames)
|
||||
{
|
||||
ui[configName].hidden = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let staticConfig = [
|
||||
{
|
||||
name : "usb_mode",
|
||||
displayName : "USB Mode",
|
||||
description : 'Configure USB mode: Device/Host/Dual',
|
||||
hidden : false,
|
||||
onChange : onchangeUSBMode,
|
||||
default : 'Device',
|
||||
options : [
|
||||
{ name: "Device", displayName : "Device Mode" },
|
||||
{ name: "Host", displayName : "Host Mode" },
|
||||
{ name: "Dual", displayName : "Dual Mode" },
|
||||
]
|
||||
},
|
||||
{
|
||||
name : "usb_mode_callback",
|
||||
displayName : "USB Mode CallBack",
|
||||
description : 'Function called by the USB library whenever a mode change occurs',
|
||||
hidden : true,
|
||||
default : 'ModeCallback',
|
||||
},
|
||||
{
|
||||
name : "usb_host_mode_power_config",
|
||||
displayName : "USB Host Mode Power Fault Configuration",
|
||||
description : 'Initialize the power fault configuration',
|
||||
hidden : true,
|
||||
default : ['USBHCD_VBUS_AUTO_HIGH', 'USBHCD_VBUS_FILTER'],
|
||||
options : [
|
||||
{ name: "USBHCD_FAULT_LOW", displayName : "Driver the power pin low on fault" },
|
||||
{ name: "USBHCD_FAULT_HIGH", displayName : "Driver the power pin low on fault" },
|
||||
{ name: "USBHCD_FAULT_VBUS_NONE", displayName : "No automatic action when power fault detected" },
|
||||
{ name: "USBHCD_FAULT_VBUS_TRI", displayName : " Tri-state the pin on a power fault." },
|
||||
{ name: "USBHCD_FAULT_VBUS_DIS", displayName : "Drive the USBnEPEN pin to it's inactive state on a power fault." },
|
||||
{ name: "USBHCD_VBUS_MANUAL", displayName : "Power control is completely managed by the application" },
|
||||
{ name: "USBHCD_VBUS_AUTO_LOW", displayName : "Set the power pin to active high" },
|
||||
{ name: "USBHCD_VBUS_AUTO_HIGH", displayName : "Set the power pin to active low" },
|
||||
{ name: "USBHCD_VBUS_FILTER", displayName : "Filter power fault" },
|
||||
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
name : "deviceClasses",
|
||||
displayName : "Device classes",
|
||||
description : 'Device Classes supported: CDC/Mouse/Keyboard/Bulk',
|
||||
hidden : false,
|
||||
default : 'CDC',
|
||||
onChange : onchangeDeviceClass,
|
||||
options : [
|
||||
{ name: "CDC", displayName : "CDC Device class" },
|
||||
{ name: "Mouse", displayName : "HID Mouse Device Class" },
|
||||
{ name: "Keyboard", displayName : "HID Keyboard Device Class" },
|
||||
{ name: "Bulk", displayName : "Bulk Device Class"}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
name : "hcdMemorySize",
|
||||
displayName : "HCD Memory Size",
|
||||
description : "The size of the host controller's memory pool in bytes.",
|
||||
hidden : true,
|
||||
default : 128
|
||||
},
|
||||
|
||||
{
|
||||
name : "mouseMemorySize",
|
||||
displayName : "Mouse Memory Size",
|
||||
description : "The size of the mouse device interface's memory pool in bytes.",
|
||||
hidden : true,
|
||||
default : 128
|
||||
},
|
||||
{
|
||||
name : "keyboardMemorySize",
|
||||
displayName : "Keyboard Memory Size",
|
||||
description : "The memory pool to provide to the keyboard device.",
|
||||
hidden : true,
|
||||
default : 128
|
||||
},
|
||||
{
|
||||
name : "hostApplication",
|
||||
displayName : "Host Application",
|
||||
description : "Host Application",
|
||||
hidden : true,
|
||||
onChange : onChangeHostApplication,
|
||||
default : "Mouse",
|
||||
options : [
|
||||
{ name: "Mouse", displayName : "Host Mouse Application" },
|
||||
{ name: "Keyboard", displayName : "Host Keyboard Application" },
|
||||
{ name: "Mass Storage", displayName : "Host Mass Storage Application"}
|
||||
]
|
||||
},
|
||||
{
|
||||
name : "usb_host_hcdPool",
|
||||
displayName : "HCD Pool Array name",
|
||||
description : "The memory pool to provide to the Host controller driver..",
|
||||
hidden : true,
|
||||
default : "g_pui8HCDPool"
|
||||
},
|
||||
|
||||
|
||||
|
||||
]
|
||||
|
||||
var CDCConfig =[
|
||||
{
|
||||
name : "manufacturerString_cdc",
|
||||
displayName : "Manufacturer string descriptor",
|
||||
description : 'Specify the Manufacturer string',
|
||||
hidden : false,
|
||||
default : "Texas Instruments"
|
||||
},
|
||||
{
|
||||
name : "productString_cdc",
|
||||
displayName : "Product String descriptor",
|
||||
description : 'Specify the product string',
|
||||
hidden : false,
|
||||
default : "Virtual Com Port"
|
||||
},
|
||||
{
|
||||
name : "serialNumberString_cdc",
|
||||
displayName : "Serial Number String",
|
||||
description : 'Specify the serial number string',
|
||||
hidden : false,
|
||||
default : "12345678"
|
||||
},
|
||||
{
|
||||
name : "controlInterfaceString_cdc",
|
||||
displayName : "Control Interface String",
|
||||
description : 'Specify the control interface string',
|
||||
hidden : false,
|
||||
default : "ACM Control Interface"
|
||||
},
|
||||
{
|
||||
name : "configString_cdc",
|
||||
displayName : "Specify the config string",
|
||||
description : 'Specify the config string',
|
||||
hidden : false,
|
||||
default : "Self Powered Configuration"
|
||||
|
||||
},
|
||||
{
|
||||
name : "usbCDCTxStruct",
|
||||
displayName : "USB CDC Tx Struct name for initialization of buffer object for transmit",
|
||||
description : "The structure used by the application to initialize a buffer object for transmit",
|
||||
hidden : false,
|
||||
default : "g_sTxBuffer"
|
||||
},
|
||||
{
|
||||
name : "usbCDCRxStruct",
|
||||
displayName : "USB CDC Rx Struct name for initialization of buffer object for receive",
|
||||
description : "The structure used by the application to initialize a buffer object for receive",
|
||||
hidden : false,
|
||||
default : "g_sRxBuffer"
|
||||
},
|
||||
{
|
||||
name : "usbCDCTxBuffer",
|
||||
displayName : "USB CDC Tx Buffer",
|
||||
description : "Transmit buffer name.",
|
||||
hidden : false,
|
||||
default : "g_pi8USBTxBuffer"
|
||||
},
|
||||
{
|
||||
name : "usbCDCRxBuffer",
|
||||
displayName : "USB CDC Tx Buffer",
|
||||
description : "Receive buffer name",
|
||||
hidden : false,
|
||||
default : "g_pi8USBRxBuffer"
|
||||
},
|
||||
{
|
||||
name : "usbBufferSize",
|
||||
displayName : "USB CDC Buffer Size",
|
||||
description : "CDC Buffer size in bytes.",
|
||||
hidden : false,
|
||||
default : 256
|
||||
},
|
||||
{
|
||||
name : "usbCDCDeviceStruct",
|
||||
displayName : "USB CDC Device Struct Name",
|
||||
description : "Structure to define operating parameters for the CDC device",
|
||||
hidden : false,
|
||||
default : "g_sCDCDevice"
|
||||
},
|
||||
{
|
||||
name : "usbCDCRxHandler",
|
||||
displayName : "USB CDC Device Receive Handler",
|
||||
description : "Callback function name for CDC Receive Events",
|
||||
hidden : false,
|
||||
default : "RxHandler"
|
||||
},
|
||||
{
|
||||
name : "usbCDCTxHandler",
|
||||
displayName : "USB CDC Device Transmit Handler",
|
||||
description : "Callback function name for CDC Transmit Events",
|
||||
hidden : false,
|
||||
default : "TxHandler"
|
||||
},
|
||||
{
|
||||
name : "usbCDCControlHandler",
|
||||
displayName : "USB CDC Device Control Handler",
|
||||
description : "Callback function name for CDC Control Events",
|
||||
hidden : false,
|
||||
default : "ControlHandler"
|
||||
},
|
||||
|
||||
]
|
||||
|
||||
var HIDMouseConfig =[
|
||||
{
|
||||
name : "manufacturerString_mouse",
|
||||
displayName : "Manufacturer string descriptor",
|
||||
description : 'Specify the Manufacturer string',
|
||||
hidden : true,
|
||||
default : "Texas Instruments"
|
||||
},
|
||||
{
|
||||
name : "productString_mouse",
|
||||
displayName : "Product String descriptor",
|
||||
description : 'Specify the product string',
|
||||
hidden : true,
|
||||
default : "MouseExample"
|
||||
},
|
||||
{
|
||||
name : "serialNumberString_mouse",
|
||||
displayName : "Serial Number String",
|
||||
description : 'Specify the serial number string',
|
||||
hidden : true,
|
||||
default : "12345678"
|
||||
},
|
||||
{
|
||||
name : "mouseHIDInterfaceString",
|
||||
displayName : "Mouse HID Interface String",
|
||||
description : 'Specify the mouse HID interface string',
|
||||
hidden : true,
|
||||
default : "HID Mouse Interface"
|
||||
},
|
||||
{
|
||||
name : "configString_mouse",
|
||||
displayName : "Specify the config string",
|
||||
description : 'Specify the config string',
|
||||
hidden : true,
|
||||
default : "HID Mouse Configuration"
|
||||
|
||||
},
|
||||
{
|
||||
name : "usbMouseDeviceStruct",
|
||||
displayName : "USB Mouse Device Struct Name",
|
||||
description : "Structure to define operating parameters for the Mouse device",
|
||||
hidden : true,
|
||||
default : "g_sMouseDevice"
|
||||
},
|
||||
|
||||
{
|
||||
name : "usbMouseMaxPowerConsumption",
|
||||
displayName : "USB Mouse Max Power Consumption in milliamps",
|
||||
description : "The maximum power consumption of the device, expressed in milliamps.",
|
||||
hidden : true,
|
||||
default : 500
|
||||
},
|
||||
{
|
||||
name : "usbMouseHandler",
|
||||
displayName : "USB Mouse Device Handler",
|
||||
description : "Callback function name for Mouse Events",
|
||||
hidden : true,
|
||||
default : "MouseHandler"
|
||||
}
|
||||
|
||||
]
|
||||
|
||||
var HIDKeyboardConfig =[
|
||||
{
|
||||
name : "manufacturerString_keyboard",
|
||||
displayName : "Manufacturer string descriptor",
|
||||
description : 'Specify the Manufacturer string',
|
||||
hidden : true,
|
||||
default : "Texas Instruments"
|
||||
},
|
||||
{
|
||||
name : "productString_keyboard",
|
||||
displayName : "Product String descriptor",
|
||||
description : 'Specify the product string',
|
||||
hidden : true,
|
||||
default : "Keyboard Example"
|
||||
},
|
||||
{
|
||||
name : "serialNumberString_keyboard",
|
||||
displayName : "Serial Number String",
|
||||
description : 'Specify the serial number string',
|
||||
hidden : true,
|
||||
default : "12345678"
|
||||
},
|
||||
{
|
||||
name : "keyboardHIDInterfaceString",
|
||||
displayName : "Keyboard HID Interface String",
|
||||
description : 'Specify the Keyboard HID interface string',
|
||||
hidden : true,
|
||||
default : "HID Keyboard Interface"
|
||||
},
|
||||
{
|
||||
name : "configString_keyboard",
|
||||
displayName : "Specify the config string",
|
||||
description : 'Specify the config string',
|
||||
hidden : true,
|
||||
default : "HID Keyboard Configuration"
|
||||
|
||||
},
|
||||
{
|
||||
name : "usbKeyboardDeviceStruct",
|
||||
displayName : "USB Mouse Device Struct Name",
|
||||
description : "Structure to define operating parameters for the Keyboard device",
|
||||
hidden : true,
|
||||
default : "g_sKeyboardDevice"
|
||||
},
|
||||
{
|
||||
name : "usbKeyboardHandler",
|
||||
displayName : "USB Mouse Device Handler",
|
||||
description : "Callback function name for Keyboard Events",
|
||||
hidden : true,
|
||||
default : "KeyboardHandler"
|
||||
}
|
||||
]
|
||||
|
||||
var BulkConfig =[
|
||||
{
|
||||
name : "manufacturerString_bulk",
|
||||
displayName : "Manufacturer string descriptor",
|
||||
description : 'Specify the Manufacturer string',
|
||||
hidden : true,
|
||||
default : "Texas Instruments"
|
||||
},
|
||||
{
|
||||
name : "productString_bulk",
|
||||
displayName : "Product String descriptor",
|
||||
description : 'Specify the product string',
|
||||
hidden : true,
|
||||
default : "Generic Bulk Device"
|
||||
},
|
||||
{
|
||||
name : "serialNumberString_bulk",
|
||||
displayName : "Serial Number String",
|
||||
description : 'Specify the serial number string',
|
||||
hidden : true,
|
||||
default : "12345678"
|
||||
},
|
||||
{
|
||||
name : "dataInterfaceString",
|
||||
displayName : "Bulk Data Interface String",
|
||||
description : 'Specify the bulk data interface string',
|
||||
hidden : true,
|
||||
default : "Bulk Data Interface"
|
||||
},
|
||||
{
|
||||
name : "configString_bulk",
|
||||
displayName : "Specify the config string",
|
||||
description : 'Specify the config string',
|
||||
hidden : true,
|
||||
default : "Bulk Data Configuration"
|
||||
|
||||
},
|
||||
{
|
||||
name : "usbBulkDeviceStruct",
|
||||
displayName : "USB Bulk Device Struct Name",
|
||||
description : "Structure to define operating parameters for the Bulk device",
|
||||
hidden : true,
|
||||
default : "g_sBulkDevice"
|
||||
},
|
||||
{
|
||||
name : "usbBulkTxStruct",
|
||||
displayName : "USB Bulk Tx Struct name for initialization of buffer object for transmit",
|
||||
description : "The structure used by the application to initialize a buffer object for transmit",
|
||||
hidden : true,
|
||||
default : "g_sTxBuffer"
|
||||
},
|
||||
{
|
||||
name : "usbBulkRxStruct",
|
||||
displayName : "USB Bulk Rx Struct name for initialization of buffer object for receive",
|
||||
description : "The structure used by the application to initialize a buffer object for receive",
|
||||
hidden : true,
|
||||
default : "g_sRxBuffer"
|
||||
},
|
||||
{
|
||||
name : "usbBulkTxBuffer",
|
||||
displayName : "USB Bulk Tx Buffer",
|
||||
description : "Transmit buffer name.",
|
||||
hidden : true,
|
||||
default : "g_pui8USBTxBuffer"
|
||||
},
|
||||
{
|
||||
name : "usbBulkRxBuffer",
|
||||
displayName : "USB Bulk Rx Buffer",
|
||||
description : "Receive buffer name.",
|
||||
hidden : true,
|
||||
default : "g_pui8USBRxBuffer"
|
||||
},
|
||||
{
|
||||
name : "usbBulkBufferSize",
|
||||
displayName : "USB CDC Buffer Size",
|
||||
description : "Buffer size in bytes.",
|
||||
hidden : true,
|
||||
default : 256
|
||||
},
|
||||
{
|
||||
name : "usbBulkRxHandler",
|
||||
displayName : "USB Bulk Device Receive Handler",
|
||||
description : "Callback function name for Bulk Receive Events",
|
||||
hidden : true,
|
||||
default : "RxHandler"
|
||||
},
|
||||
{
|
||||
name : "usbBulkTxHandler",
|
||||
displayName : "USB Bulk Device Transmit Handler",
|
||||
description : "Callback function name for Bulk Transmit Events",
|
||||
hidden : true,
|
||||
default : "TxHandler"
|
||||
},
|
||||
]
|
||||
|
||||
staticConfig = staticConfig.concat([
|
||||
// Group for CDC Device Class
|
||||
{
|
||||
name: "GROUP_CDC_DEVICE",
|
||||
displayName: "CDC Device Class Configuration",
|
||||
description: "",
|
||||
longDescription: "",
|
||||
config: CDCConfig,
|
||||
collapsed: true
|
||||
}
|
||||
])
|
||||
|
||||
staticConfig = staticConfig.concat([
|
||||
// Group for HID Mouse Device Class
|
||||
{
|
||||
name: "GROUP_MOUSE_DEVICE",
|
||||
displayName: "HID Mouse Device Class Configuration",
|
||||
description: "",
|
||||
longDescription: "",
|
||||
config: HIDMouseConfig,
|
||||
collapsed: true
|
||||
}
|
||||
])
|
||||
|
||||
staticConfig = staticConfig.concat([
|
||||
// Group for HID Keyboard Device Class
|
||||
{
|
||||
name: "GROUP_KEYBOARD_DEVICE",
|
||||
displayName: "HID Keyboard Device Class Configuration",
|
||||
description: "",
|
||||
longDescription: "",
|
||||
config: HIDKeyboardConfig,
|
||||
collapsed: true
|
||||
}
|
||||
])
|
||||
|
||||
staticConfig = staticConfig.concat([
|
||||
// Group for Bulk Device Class
|
||||
{
|
||||
name: "GROUP_BULK_DEVICE",
|
||||
displayName: "Bulk Device Class Configuration",
|
||||
description: "",
|
||||
longDescription: "",
|
||||
config: BulkConfig,
|
||||
collapsed: true
|
||||
}
|
||||
])
|
||||
|
||||
var USBLibModule = {
|
||||
c2000wareLibraryName: "USBLib",
|
||||
displayName: "USB Library",
|
||||
defaultInstanceName: "myUSBLib",
|
||||
description: "USB Library",
|
||||
//moduleInstances: moduleInstances,
|
||||
maxInstances : 1,
|
||||
modules : modules,
|
||||
config : staticConfig,
|
||||
templates: {
|
||||
c2000ware_libraries_h : "/libraries/communications/usb/templates/usb.c2000ware_libraries.h.xdt",
|
||||
c2000ware_libraries_c : "/libraries/communications/usb/templates/usb.c2000ware_libraries.c.xdt",
|
||||
c2000ware_libraries_opt : "/libraries/communications/usb/templates/usb.c2000ware_libraries.opt.xdt",
|
||||
c2000ware_libraries_cmd_genlibs : "/libraries/communications/usb/templates/usb.c2000ware_libraries.cmd.genlibs.xdt",
|
||||
},
|
||||
validate : onValidate
|
||||
};
|
||||
|
||||
function modules(inst)
|
||||
{
|
||||
if(inst.usb_mode == "Device" || inst.usb_mode == "Dual")
|
||||
{
|
||||
return [
|
||||
{
|
||||
name: "pullInTemplateUSBStructsC",
|
||||
moduleName: "/libraries/communications/usb/templates/usb_structs.c.dynamic.js",
|
||||
},
|
||||
{
|
||||
name: "pullInTemplateUSBStructsH",
|
||||
moduleName: "/libraries/communications/usb/templates/usb_structs.h.dynamic.js",
|
||||
}
|
||||
];
|
||||
}
|
||||
else
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
exports = USBLibModule;
|
||||
Reference in New Issue
Block a user